Fixing color

pull/1/head
daffainfo 2021-12-03 18:02:02 +07:00
parent ad6db3e79a
commit fdc7994187
5 changed files with 56 additions and 32 deletions

View File

@ -1,18 +0,0 @@
package color
import "fmt"
var (
Red = Color("\033[1;31m%s\033[0m")
Green = Color("\033[1;32m%s\033[0m")
Blue = Color("\033[1;33m%s\033[0m")
Cyan = Color("\033[1;36m%s\033[0m")
)
func Color(colorString string) func(...interface{}) string {
sprint := func(args ...interface{}) string {
return fmt.Sprintf(colorString,
fmt.Sprint(args...))
}
return sprint
}

2
go.mod
View File

@ -1,3 +1,3 @@
module github.com/daffainfo/apiguesser module github.com/daffainfo/apiguesser
go 1.17 go 1.17

View File

@ -16,21 +16,40 @@ type regex_data struct {
Regex string `json:"Regex"` Regex string `json:"Regex"`
} }
var (
Red = Color("\033[1;31m%s\033[0m")
Green = Color("\033[1;32m%s\033[0m")
Blue = Color("\033[1;34m%s\033[0m")
Cyan = Color("\033[1;36m%s\033[0m")
)
func Color(colorString string) func(...interface{}) string {
sprint := func(args ...interface{}) string {
return fmt.Sprintf(colorString,
fmt.Sprint(args...))
}
return sprint
}
func Regex_api_file(path string) { func Regex_api_file(path string) {
file, err := os.Open(path) file, err := os.Open(path)
if err != nil { if err != nil {
log.Fatal(err) log.Fatal(Red(err))
} }
defer file.Close() defer file.Close()
scanner := bufio.NewScanner(file) scanner := bufio.NewScanner(file)
for scanner.Scan() { for scanner.Scan() {
fmt.Println(scanner.Text()) fmt.Println(Cyan(scanner.Text()))
fmt.Println(Regex_api(scanner.Text())) if Regex_api(scanner.Text()) != "" {
fmt.Println(Green(Regex_api(scanner.Text())))
} else {
fmt.Println(Red("Not match"))
}
} }
if err := scanner.Err(); err != nil { if err := scanner.Err(); err != nil {
log.Fatal(err) log.Fatal(Red(err))
} }
} }
@ -40,7 +59,7 @@ func Regex_api(contents string) string {
resp, err := http.Get("https://raw.githubusercontent.com/daffainfo/apiguesser/main/db.json") resp, err := http.Get("https://raw.githubusercontent.com/daffainfo/apiguesser/main/db.json")
if err != nil { if err != nil {
fmt.Println("No response from request") fmt.Println(Red("No response from request"))
} }
defer resp.Body.Close() defer resp.Body.Close()
@ -48,7 +67,7 @@ func Regex_api(contents string) string {
var errjson = json.Unmarshal(body, &data) var errjson = json.Unmarshal(body, &data)
if errjson != nil { if errjson != nil {
fmt.Println(err.Error()) fmt.Println(Red(err.Error()))
} }
for i := range data { for i := range data {

34
main.go
View File

@ -7,8 +7,23 @@ import (
g "github.com/daffainfo/apiguesser/guesser" g "github.com/daffainfo/apiguesser/guesser"
) )
var (
Red = Color("\033[1;31m%s\033[0m")
Green = Color("\033[1;32m%s\033[0m")
Blue = Color("\033[1;34m%s\033[0m")
Cyan = Color("\033[1;36m%s\033[0m")
)
func Color(colorString string) func(...interface{}) string {
sprint := func(args ...interface{}) string {
return fmt.Sprintf(colorString,
fmt.Sprint(args...))
}
return sprint
}
func show_banner() { func show_banner() {
fmt.Println(` fmt.Println(Blue(`
_ _
___ ___|_|___ ___ _ _ ___ ___ ___ ___ ___ ___ ___|_|___ ___ _ _ ___ ___ ___ ___ ___
| .'| . | |___| . | | | -_|_ -|_ -| -_| _| | .'| . | |___| . | | | -_|_ -|_ -| -_| _|
@ -16,7 +31,10 @@ func show_banner() {
|_| |___| |_| |___|
Author: Muhammad Daffa Author: Muhammad Daffa
Version: 1.0`) Version: 1.0
Starting...
`))
} }
func main() { func main() {
@ -26,12 +44,16 @@ func main() {
flag.Parse() flag.Parse()
if *api != "" && *path == "" && len(*api) > 3 { if *api != "" && *path == "" && len(*api) > 3 {
fmt.Println("[!] Possible Key:") fmt.Println(Cyan(*api))
fmt.Println(g.Regex_api(*api)) if g.Regex_api(*api) != "" {
fmt.Println(Green(g.Regex_api(*api)))
} else {
fmt.Println(Red("Not Match"))
}
} else if *api == "" && *path != "" { } else if *api == "" && *path != "" {
fmt.Println("[!] Possible Key:")
g.Regex_api_file(*path) g.Regex_api_file(*path)
} else if *api != "" || *path != "" { } else if *api != "" || *path != "" {
fmt.Println("[X] Can't call 2 arguments at once") fmt.Println(Red("Can't call 2 arguments at once"))
} }
} }

View File

@ -1,3 +1,4 @@
atkynd0qgc6a6eo2zgmm3jpjuuyi1s4w atkynd0qgc6a6eo2zgmm3jpjuuyi1s4w
MrID9UAAildWnSbukhzdQA2YA1u9shld MrID9UAAildWnSbukhzdQA2YA1u9shld
atkynd0qgc6a6eo2zgmm3jpjuuyi1s4w1 atkynd0qgc6a6eo2zgmm3jpjuuyi1s4w1
cccc