2021-11-23 12:29:30 +00:00
|
|
|
package main
|
|
|
|
|
|
|
|
import (
|
|
|
|
"bufio"
|
|
|
|
"encoding/json"
|
|
|
|
"flag"
|
|
|
|
"fmt"
|
|
|
|
"io/ioutil"
|
|
|
|
"log"
|
|
|
|
"net/http"
|
|
|
|
"os"
|
|
|
|
"regexp"
|
|
|
|
)
|
|
|
|
|
|
|
|
type regex_data struct {
|
|
|
|
Name string `json:"Name"`
|
|
|
|
Regex string `json:"Regex"`
|
|
|
|
}
|
|
|
|
|
|
|
|
func show_banner() {
|
|
|
|
fmt.Println(`
|
|
|
|
_
|
|
|
|
___ ___|_|___ ___ _ _ ___ ___ ___ ___ ___
|
|
|
|
| .'| . | |___| . | | | -_|_ -|_ -| -_| _|
|
|
|
|
|__,| _|_| |_ |___|___|___|___|___|_|
|
|
|
|
|_| |___|
|
|
|
|
|
|
|
|
Author: Muhammad Daffa
|
|
|
|
Version: 1.0`)
|
|
|
|
}
|
|
|
|
|
2021-11-23 14:40:31 +00:00
|
|
|
func regex_api_file(path string) {
|
2021-11-23 12:29:30 +00:00
|
|
|
file, err := os.Open(path)
|
|
|
|
if err != nil {
|
|
|
|
log.Fatal(err)
|
|
|
|
}
|
|
|
|
defer file.Close()
|
|
|
|
|
|
|
|
scanner := bufio.NewScanner(file)
|
|
|
|
for scanner.Scan() {
|
|
|
|
fmt.Println(scanner.Text())
|
2021-11-23 14:40:31 +00:00
|
|
|
fmt.Println(Regex_api(scanner.Text()))
|
2021-11-23 12:29:30 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if err := scanner.Err(); err != nil {
|
|
|
|
log.Fatal(err)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-11-23 14:40:31 +00:00
|
|
|
func Regex_api(contents string) string {
|
2021-11-23 12:29:30 +00:00
|
|
|
var data []regex_data
|
2021-11-23 14:40:31 +00:00
|
|
|
var result string
|
2021-11-23 12:29:30 +00:00
|
|
|
|
|
|
|
resp, err := http.Get("https://raw.githubusercontent.com/daffainfo/ApiGuesser/main/db.json")
|
|
|
|
if err != nil {
|
|
|
|
fmt.Println("No response from request")
|
|
|
|
}
|
|
|
|
defer resp.Body.Close()
|
|
|
|
|
|
|
|
byteValue, _ := ioutil.ReadAll(resp.Body)
|
|
|
|
|
|
|
|
var errjson = json.Unmarshal([]byte(byteValue), &data)
|
|
|
|
if errjson != nil {
|
|
|
|
fmt.Println(err.Error())
|
|
|
|
}
|
|
|
|
|
|
|
|
for i := range data {
|
|
|
|
re := regexp.MustCompile(data[i].Regex)
|
|
|
|
if re.MatchString(contents) {
|
2021-11-23 14:40:31 +00:00
|
|
|
result = data[i].Name
|
2021-11-23 12:29:30 +00:00
|
|
|
}
|
|
|
|
}
|
2021-11-23 14:40:31 +00:00
|
|
|
return result
|
2021-11-23 12:29:30 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
func main() {
|
|
|
|
show_banner()
|
|
|
|
api := flag.String("api", "", "An API Key. Example: tue3sv9hzsey1me4l7fwq3t46u5k8wag")
|
|
|
|
path := flag.String("path", "", "A file with API Key. Example: daffainfo.txt")
|
|
|
|
flag.Parse()
|
|
|
|
|
|
|
|
if *api != "" && *path == "" && len(*api) > 3 {
|
|
|
|
fmt.Println("Possible API Key:")
|
2021-11-23 14:40:31 +00:00
|
|
|
fmt.Println(Regex_api(*api))
|
2021-11-23 12:29:30 +00:00
|
|
|
} else if *api == "" && *path != "" {
|
2021-11-23 14:40:31 +00:00
|
|
|
regex_api_file(*path)
|
2021-11-23 12:29:30 +00:00
|
|
|
} else if *api != "" || *path != "" {
|
|
|
|
fmt.Println("Can't call 2 arguments at once")
|
|
|
|
}
|
|
|
|
}
|