Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Search for compromised passwords for a username using BreachDirectory.org #10

Merged
merged 1 commit into from
Dec 10, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
86 changes: 80 additions & 6 deletions gosearch.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
"fmt"
"io"
"os"
"log"
"time"
"sync"
"strings"
Expand All @@ -12,6 +13,7 @@
"encoding/json"
"gopkg.in/yaml.v3"
"github.com/inancgumus/screen"
"github.com/ibnaleem/gobreach"

Check failure on line 16 in gosearch.go

View workflow job for this annotation

GitHub Actions / build

no required module provides package github.com/ibnaleem/gobreach; to add it:
)

var Red = "\033[31m"
Expand Down Expand Up @@ -233,6 +235,67 @@
}
}


func BuildEmail(username string) []string {
emailDomains := []string{
"@gmail.com",
"@yahoo.com",
"@outlook.com",
"@hotmail.com",
"@icloud.com",
"@aol.com",
"@live.com",
"@protonmail.com",
"@zoho.com",
"@msn.com",
"proton.me",
"onionmail.org",
"gmx.de",
"mail2world.com",
}

var emails []string

for _, domain := range emailDomains {
emails = append(emails, username + domain)
}

return emails
}

func SearchBreachDirectory(emails []string, apikey string, wg *sync.WaitGroup) {

defer wg.Done()

// Get an API key (10 lookups for free) @ https://rapidapi.com/rohan-patra/api/breachdirectory
client, err := gobreach.NewBreachDirectoryClient(apikey)

if err != nil {
log.Fatal(err)
}

for _, email := range emails {

fmt.Println(Yellow + ":: Searching " + email + " on Breach Directory for any compromised passwords..." + Reset)

response, err := client.SearchEmail(email)
if err != nil {
log.Fatal(err)
}

if response.Found > 0 {
fmt.Printf(Green + ":: Found %d breaches for %s:\n", response.Found, email + Reset)
for _, entry := range response.Result {
fmt.Println(Green + "[+] :: Password:", entry.Password + Reset)
fmt.Println(Green + "[+] :: SHA1:", entry.Sha1 + Reset)
fmt.Println(Green + "[+] :: Source:", entry.Sources + Reset)
}
} else {
fmt.Printf(Red + ":: No breaches found for %s. Moving on...\n", email + Reset)
}
}
}

func MakeRequestWithErrorCode(website Website, url string, username string) {
transport := &http.Transport{
TLSClientConfig: &tls.Config{
Expand All @@ -241,7 +304,7 @@
}

client := &http.Client{
Timeout: 60 * time.Second,
Timeout: 85 * time.Second,
Transport: transport,
}

Expand Down Expand Up @@ -291,7 +354,7 @@
}

client := &http.Client{
Timeout: 60 * time.Second,
Timeout: 85 * time.Second,
Transport: transport,
}

Expand Down Expand Up @@ -375,6 +438,7 @@
fmt.Println("Usage: gosearch <username>\nIssues: https://github.com/ibnaleem/gosearch/issues")
os.Exit(1)
}

var username string = os.Args[1]
var wg sync.WaitGroup

Expand All @@ -387,10 +451,10 @@
screen.Clear()
fmt.Println(ASCII)
fmt.Println(VERSION)
fmt.Println(strings.Repeat("⎯", 60))
fmt.Println(strings.Repeat("⎯", 85))
fmt.Println(":: Username : ", username)
fmt.Println(":: Websites : ", len(config.Websites))
fmt.Println(strings.Repeat("⎯", 60))
fmt.Println(strings.Repeat("⎯", 85))
fmt.Println(":: A yellow link indicates that I was unable to verify whether the username exists on the platform.")

start := time.Now()
Expand All @@ -400,13 +464,23 @@
wg.Wait()

wg.Add(1)
fmt.Println(strings.Repeat("⎯", 60))
fmt.Println(strings.Repeat("⎯", 85))
fmt.Println(Yellow + ":: Searching HudsonRock's Cybercrime Intelligence Database..." + Reset)
go HudsonRock(username, &wg)
wg.Wait()


if len(os.Args) == 3 {
apikey := os.Args[2]
fmt.Println(strings.Repeat("⎯", 85))
emails := BuildEmail(username)
wg.Add(1)
go SearchBreachDirectory(emails, apikey, &wg)
wg.Wait()
}

elapsed := time.Since(start)
fmt.Println(strings.Repeat("⎯", 60))
fmt.Println(strings.Repeat("⎯", 85))
fmt.Println(":: Number of profiles found : ", count)
fmt.Println(":: Total time taken : ", elapsed)

Expand Down
Loading