Merge pull request #1 from daffainfo/dev

Merge dev
main
Muhammad Daffa 2022-06-22 15:57:58 +07:00 committed by GitHub
commit b8546a442e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 58 additions and 52 deletions

View File

@ -1,4 +1,4 @@
package guesser package main
import ( import (
"bufio" "bufio"
@ -12,24 +12,24 @@ import (
) )
type regex_data struct { type regex_data struct {
Name string `json:"Name"` Name []string `json:"Name"`
Regex string `json:"Regex"` Regex string `json:"Regex"`
} }
var ( // var (
Red = Color("\033[1;31m%s\033[0m") // Red = Color("\033[1;31m%s\033[0m")
Green = Color("\033[1;32m%s\033[0m") // Green = Color("\033[1;32m%s\033[0m")
Blue = Color("\033[1;34m%s\033[0m") // Blue = Color("\033[1;34m%s\033[0m")
Cyan = Color("\033[1;36m%s\033[0m") // Cyan = Color("\033[1;36m%s\033[0m")
) // )
func Color(colorString string) func(...interface{}) string { // func Color(colorString string) func(...interface{}) string {
sprint := func(args ...interface{}) string { // sprint := func(args ...interface{}) string {
return fmt.Sprintf(colorString, // return fmt.Sprintf(colorString,
fmt.Sprint(args...)) // fmt.Sprint(args...))
} // }
return sprint // return sprint
} // }
func Regex_api_file(path string) { func Regex_api_file(path string) {
file, err := os.Open(path) file, err := os.Open(path)
@ -57,7 +57,7 @@ func Regex_api(contents string) string {
var data []regex_data var data []regex_data
var result string 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 { if err != nil {
fmt.Println(Red("No response from request")) fmt.Println(Red("No response from request"))
} }
@ -71,9 +71,16 @@ func Regex_api(contents string) string {
} }
for i := range data { for i := range data {
// print(data[i])
// length := len(data[i].Name)
re := regexp.MustCompile(data[i].Regex) re := regexp.MustCompile(data[i].Regex)
if re.MatchString(contents) { if re.MatchString(contents) {
result = data[i].Name // print(Green(data[i].Name))
for _, str := range data[i].Name {
result += str + "\n"
// print(str + "\n")
}
// result = data[i].Name[length-1]
} }
} }
return result 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" "Regex": "^\\s*([a-z0-9]{33})\\z"
}, },
{ {
"Name": "Petfinder API Key", "Name": ["Petfinder API Key"],
"Regex": "^\\s*([a-zA-Z0-9]{50})\\z" "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" "Regex": "^\\s*([a-z0-9]{50})\\z"
}, },
{ {
"Name": "AdotpAPet Client Secret", "Name": ["AdotpAPet Client Secret"],
"Regex": "^\\s*([a-zA-Z0-9]{40})\\z" "Regex": "^\\s*([a-zA-Z0-9]{40})\\z"
}, },
{ {
"Name": "eBird API Key", "Name": ["eBird API Key"],
"Regex": "^\\s*([a-z0-9]{12})\\z" "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" "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}" "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-_.+/=]*$" "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" "Regex": "^\\s*([a-z0-9]{80})\\z"
}, },
{ {
"Name": "Smartsheet API Key", "Name": ["Smartsheet API Key"],
"Regex": "^\\s*([a-z0-9]{26})\\z" "Regex": "^\\s*([a-z0-9]{26})\\z"
}, },
{ {
"Name": "Square API Key", "Name": ["Square API Key"],
"Regex": "EAAAE[a-zA-Z0-9_-]{59}" "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}" "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}" "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}" "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" "Regex": "^\\s*([a-z0-9]{32})\\z"
}, },
{ {
"Name": "Europeana API Key", "Name": ["Europeana API Key"],
"Regex": "^\\s*([a-z]{8,10})\\z" "Regex": "^\\s*([a-z]{8,10})\\z"
}, },
{ {
"Name": "Scanii Secret Key", "Name": ["Scanii Secret Key"],
"Regex": "^\\s*([a-z0-9]{9})\\z" "Regex": "^\\s*([a-z0-9]{9})\\z"
}, },
{ {
"Name": "Mailgun API Key", "Name": ["Mailgun API Key"],
"Regex": "key-[a-z0-9]{32}" "Regex": "key-[a-z0-9]{32}"
}, },
{ {
"Name": "MailboxValidator Secret Key", "Name": ["MailboxValidator Secret Key"],
"Regex": "^\\s*([A-Z0-9]{20})\\z" "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}" "Regex": "sk_[a-z0-9]{32}"
}, },
{ {
"Name": "Bhagavad Gita Secret Key", "Name": ["Bhagavad Gita Secret Key"],
"Regex": "^\\s*([a-z0-9]{17})\\z" "Regex": "^\\s*([a-z0-9]{17})\\z"
}, },
{ {
"Name": "IconFinder API Key", "Name": ["IconFinder API Key"],
"Regex": "^\\s*([a-zA-Z0-9]{64})\\z" "Regex": "^\\s*([a-zA-Z0-9]{64})\\z"
}, },
{ {
"Name": "Rijksmuseum API Key", "Name": ["Rijksmuseum API Key"],
"Regex": "^\\s*([a-zA-Z0-9]{8})\\z" "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" "Regex": "^\\s*([a-zA-Z0-9]{48})\\z"
}, },
{ {
"Name": "Covalent API Key", "Name": ["Covalent API Key"],
"Regex": "ckey_[a-z0-9]{27}" "Regex": "ckey_[a-z0-9]{27}"
}, },
{ {
"Name": "Etherscan API Key", "Name": ["Etherscan API Key"],
"Regex": "^\\s*([A-Z0-9]{34})\\z" "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" "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" "Regex": "^\\s*([a-z0-9]{40})\\z"
} }
] ]

2
go.mod
View File

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

View File

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