Changing json structure

pull/1/head
Muhammad Daffa 2022-06-22 15:05:12 +07:00
parent 782583dc2e
commit 20fb8ca0c0
4 changed files with 51 additions and 52 deletions

View File

@ -1,4 +1,4 @@
package guesser
package main
import (
"bufio"
@ -12,24 +12,24 @@ import (
)
type regex_data struct {
Name string `json:"Name"`
Name []string `json:"Name"`
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")
)
// 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 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) {
file, err := os.Open(path)
@ -57,7 +57,7 @@ func Regex_api(contents string) string {
var data []regex_data
var result string
resp, err := http.Get("https://raw.githubusercontent.com/daffainfo/apiguesser/main/db.json")
resp, err := http.Get("https://pastebin.com/raw/9BuLKBUG")
if err != nil {
fmt.Println(Red("No response from request"))
}
@ -73,7 +73,7 @@ func Regex_api(contents string) string {
for i := range data {
re := regexp.MustCompile(data[i].Regex)
if re.MatchString(contents) {
result = data[i].Name
result = data[i].Name[i]
}
}
return result

56
db.json
View File

@ -1,114 +1,114 @@
[
{
"Name": "AdotpAPet API Key",
"Name": ["AdotpAPet API Key"],
"Regex": "^\\s*([a-z0-9]{33})\\z"
},
{
"Name": "Petfinder API Key",
"Name": ["Petfinder API Key"],
"Regex": "^\\s*([a-zA-Z0-9]{50})\\z"
},
{
"Name": "Word Cloud API Key",
"Name": ["Word Cloud API Key"],
"Regex": "^\\s*([a-z0-9]{50})\\z"
},
{
"Name": "AdotpAPet Client Secret",
"Name": ["AdotpAPet Client Secret"],
"Regex": "^\\s*([a-zA-Z0-9]{40})\\z"
},
{
"Name": "eBird API Key",
"Name": ["eBird API Key"],
"Regex": "^\\s*([a-z0-9]{12})\\z"
},
{
"Name": "IUCN API Key\nAlienVault Open Threat Exchange API Key\nMalShare API Key\nVirusTotal API Key\nDribbble API Key",
"Name": ["IUCN API Key","AlienVault Open Threat Exchange API Key","MalShare API Key","VirusTotal API Key","Dribbble API Key"],
"Regex": "^\\s*([a-z0-9]{64})\\z"
},
{
"Name": "TheCatAPI API Key\nTheDogAPI API Key\nURLScan API Key\nHarvard Art Museums API Key\nMojoAuth API Key\nORB Intelligence API Key",
"Name": ["TheCatAPI API Key","TheDogAPI API Key","URLScan API Key","Harvard Art Museums API Key","MojoAuth API Key","ORB Intelligence API Key"],
"Regex": "[a-f0-9]{8}-[a-f0-9]{4}-[a-f0-9]{4}-[a-f0-9]{4}-[a-f0-9]{12}"
},
{
"Name": "AniAPI OAuth Token\nMyAnimeList OAuth Token",
"Name": ["AniAPI OAuth Token","MyAnimeList OAuth Token"],
"Regex": "^[A-Za-z0-9-_=]+\\.[A-Za-z0-9-_=]+\\.?[A-Za-z0-9-_.+/=]*$"
},
{
"Name": "AbuseIPDB API Key",
"Name": ["AbuseIPDB API Key"],
"Regex": "^\\s*([a-z0-9]{80})\\z"
},
{
"Name": "Smartsheet API Key",
"Name": ["Smartsheet API Key"],
"Regex": "^\\s*([a-z0-9]{26})\\z"
},
{
"Name": "Square API Key",
"Name": ["Square API Key"],
"Regex": "EAAAE[a-zA-Z0-9_-]{59}"
},
{
"Name": "Stytch Project ID",
"Name": ["Stytch Project ID"],
"Regex": "project-.*-[a-z0-9]{8}-[a-z0-9]{4}-[a-z0-9]{4}-[a-z0-9]{4}-[a-z0-9]{12}"
},
{
"Name": "Stytch Secret Token",
"Name": ["Stytch Secret Token"],
"Regex": "secret-.*-[a-zA-Z0-9-_=]{36}"
},
{
"Name": "Google Safe Browsing API Key\nGoogle Books API Key",
"Name": ["Google Safe Browsing API Key","Google Books API Key"],
"Regex": "AIza[0-9A-Za-z-_]{35}"
},
{
"Name": "Cooper Hewitt API Key\nMalwareBazaar API Key\nAPI Bible API Key\nScanii API Key\nCharity Search API Key\nInstatus API Key\nTrello API Key",
"Name": ["Cooper Hewitt API Key","MalwareBazaar API Key","API Bible API Key","Scanii API Key","Charity Search API Key","Instatus API Key","Trello API Key"],
"Regex": "^\\s*([a-z0-9]{32})\\z"
},
{
"Name": "Europeana API Key",
"Name": ["Europeana API Key"],
"Regex": "^\\s*([a-z]{8,10})\\z"
},
{
"Name": "Scanii Secret Key",
"Name": ["Scanii Secret Key"],
"Regex": "^\\s*([a-z0-9]{9})\\z"
},
{
"Name": "Mailgun API Key",
"Name": ["Mailgun API Key"],
"Regex": "key-[a-z0-9]{32}"
},
{
"Name": "MailboxValidator Secret Key",
"Name": ["MailboxValidator Secret Key"],
"Regex": "^\\s*([A-Z0-9]{20})\\z"
},
{
"Name": "Clearbit API Key\nImprovMX API Key",
"Name": ["Clearbit API Key","ImprovMX API Key"],
"Regex": "sk_[a-z0-9]{32}"
},
{
"Name": "Bhagavad Gita Secret Key",
"Name": ["Bhagavad Gita Secret Key"],
"Regex": "^\\s*([a-z0-9]{17})\\z"
},
{
"Name": "IconFinder API Key",
"Name": ["IconFinder API Key"],
"Regex": "^\\s*([a-zA-Z0-9]{64})\\z"
},
{
"Name": "Rijksmuseum API Key",
"Name": ["Rijksmuseum API Key"],
"Regex": "^\\s*([a-zA-Z0-9]{8})\\z"
},
{
"Name": "Micro User Service API Key",
"Name": ["Micro User Service API Key"],
"Regex": "^\\s*([a-zA-Z0-9]{48})\\z"
},
{
"Name": "Covalent API Key",
"Name": ["Covalent API Key"],
"Regex": "ckey_[a-z0-9]{27}"
},
{
"Name": "Etherscan API Key",
"Name": ["Etherscan API Key"],
"Regex": "^\\s*([A-Z0-9]{34})\\z"
},
{
"Name": "Nownodes API Key\nBitquery API Key",
"Name": ["Nownodes API Key","Bitquery API Key"],
"Regex": "^\\s*([A-Za-z0-9]{32})\\z"
},
{
"Name": "Web of Trust API Key\nCalendarific API Key",
"Name": ["Web of Trust API Key","Calendarific API Key"],
"Regex": "^\\s*([a-z0-9]{40})\\z"
}
]

2
go.mod
View File

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

View File

@ -3,8 +3,7 @@ package main
import (
"flag"
"fmt"
g "github.com/daffainfo/apiguesser/guesser"
// g "github.com/daffainfo/apiguesser/guesser"
)
var (
@ -45,14 +44,14 @@ func main() {
if *api != "" && *path == "" && len(*api) > 3 {
fmt.Println(Cyan(*api))
if g.Regex_api(*api) != "" {
fmt.Println(Green(g.Regex_api(*api)))
if Regex_api(*api) != "" {
fmt.Println(Green(Regex_api(*api)))
} else {
fmt.Println(Red("Not Match"))
}
} else if *api == "" && *path != "" {
g.Regex_api_file(*path)
Regex_api_file(*path)
} else if *api != "" || *path != "" {
fmt.Println(Red("Can't call 2 arguments at once"))
}