Compare commits

...
6 Commits
Author SHA1 Message Date
Hadi c460e5c24f API Url to HTML Url
Signed-off-by: Hadi <[email protected]>
2025-09-22 18:59:04 +02:00
Hadi e572d1326a early return if user not found
Signed-off-by: Hadi <[email protected]>
2025-09-17 21:39:32 +02:00
Hadi 0017d649d3 return nil instead of error
Signed-off-by: Hadi <[email protected]>
2025-09-17 21:31:02 +02:00
Hadi c163fb4ecd Fatal only in cmd
Signed-off-by: Hadi <[email protected]>
2025-09-17 21:26:54 +02:00
Hadi 325397dfef Check repositories length
Signed-off-by: Hadi <[email protected]>
2025-09-17 21:10:35 +02:00
Hadi dab0ba2b38 now retrying to get commits
Signed-off-by: Hadi <[email protected]>
2025-09-17 21:07:16 +02:00
7 changed files with 54 additions and 29 deletions
+10 -2
View File
@@ -1,6 +1,8 @@
package main package main
import ( import (
"log"
recon_email "github.com/anotherhadi/github-recon/github-recon/email" recon_email "github.com/anotherhadi/github-recon/github-recon/email"
recon_username "github.com/anotherhadi/github-recon/github-recon/username" recon_username "github.com/anotherhadi/github-recon/github-recon/username"
github_recon_settings "github.com/anotherhadi/github-recon/settings" github_recon_settings "github.com/anotherhadi/github-recon/settings"
@@ -8,7 +10,10 @@ import (
) )
func main() { func main() {
settings := github_recon_settings.GetSettings() settings, err := github_recon_settings.GetSettings()
if err != nil {
log.Fatal(err)
}
if !settings.Silent { if !settings.Silent {
utils.Header() utils.Header()
@@ -23,7 +28,10 @@ func main() {
} }
if settings.TargetType == github_recon_settings.TargetUsername { if settings.TargetType == github_recon_settings.TargetUsername {
result := recon_username.Username(settings) result, err := recon_username.Username(settings)
if err != nil {
log.Fatal(err)
}
writeJson(settings, result) writeJson(settings, result)
} else { } else {
result := recon_email.Email(settings) result := recon_email.Email(settings)
+9 -2
View File
@@ -2,6 +2,7 @@ package recon
import ( import (
"math/rand" "math/rand"
"time"
github_recon_settings "github.com/anotherhadi/github-recon/settings" github_recon_settings "github.com/anotherhadi/github-recon/settings"
"github.com/anotherhadi/github-recon/utils" "github.com/anotherhadi/github-recon/utils"
@@ -99,6 +100,9 @@ func Spoofing(s github_recon_settings.Settings) (response *SpoofingResult) {
} }
utils.WaitForRateLimit(s, resp) utils.WaitForRateLimit(s, resp)
const maxRetries = 5
const retryDelay = 2 * time.Second
for i := 0; i < maxRetries; i++ {
commits, _, err := s.Client.Repositories.ListCommits(s.Ctx, repo.Owner.GetLogin(), name, nil) commits, _, err := s.Client.Repositories.ListCommits(s.Ctx, repo.Owner.GetLogin(), name, nil)
if err != nil { if err != nil {
s.Logger.Error("Error while listing commits", "err", err) s.Logger.Error("Error while listing commits", "err", err)
@@ -112,8 +116,11 @@ func Spoofing(s github_recon_settings.Settings) (response *SpoofingResult) {
response.Email = last.GetAuthor().GetEmail() response.Email = last.GetAuthor().GetEmail()
response.Url = last.GetAuthor().GetHTMLURL() response.Url = last.GetAuthor().GetHTMLURL()
response.AvatarURL = last.GetAuthor().GetAvatarURL() response.AvatarURL = last.GetAuthor().GetAvatarURL()
} else { break
s.Logger.Error("Only one commit found, something went wrong.", "commits", commits) }
s.Logger.Info("Only one commit found, retrying...", "attempt", i+1)
time.Sleep(retryDelay)
} }
if response.Username == "" && response.Name == "" && response.Email == "" { if response.Username == "" && response.Name == "" && response.Email == "" {
+6 -1
View File
@@ -82,7 +82,7 @@ func DeepScan(s github_recon_settings.Settings) (response DeepScanResult) {
} }
repositories = append(repositories, Repositorie{ repositories = append(repositories, Repositorie{
Repository: repo.GetCloneURL(), Repository: repo.GetHTMLURL(),
Owner: repo.GetOwner().GetLogin(), Owner: repo.GetOwner().GetLogin(),
Name: repo.GetName(), Name: repo.GetName(),
Size: repo.GetSize(), Size: repo.GetSize(),
@@ -139,6 +139,11 @@ func DeepScan(s github_recon_settings.Settings) (response DeepScanResult) {
} }
s.Logger.Info("Cloned all repositories", "path", tmp_folder) s.Logger.Info("Cloned all repositories", "path", tmp_folder)
if len(repositories) == 0 {
s.Logger.Info("No repositories found for the user, skipping deep scan.")
return
}
authorOccurrences := Authors{} authorOccurrences := Authors{}
mapAuthorToIndex := make(map[string]int) mapAuthorToIndex := make(map[string]int)
for _, repo := range repositories { for _, repo := range repositories {
+10 -5
View File
@@ -27,16 +27,21 @@ type UsernameResult struct {
DeepScan DeepScanResult DeepScan DeepScanResult
} }
func Username(settings github_recon_settings.Settings) UsernameResult { func Username(settings github_recon_settings.Settings) (result UsernameResult, err error) {
result = UsernameResult{
result := UsernameResult{
Target: settings.Target, Target: settings.Target,
TargetType: settings.TargetType, TargetType: settings.TargetType,
DateTime: time.Now().String(), DateTime: time.Now().String(),
} }
utils.PrintTitle(settings.Silent, "👤 User informations") utils.PrintTitle(settings.Silent, "👤 User informations")
result.User = User(settings) result.User, err = User(settings)
if err != nil {
return
}
if result.User == (UserResult{}) {
return
}
utils.PrintAvatar(settings, result.User.AvatarURL) utils.PrintAvatar(settings, result.User.AvatarURL)
utils.PrintStruct(settings, result.User, 0) utils.PrintStruct(settings, result.User, 0)
@@ -74,5 +79,5 @@ func Username(settings github_recon_settings.Settings) UsernameResult {
utils.PrintStruct(settings, result.DeepScan, 0) utils.PrintStruct(settings, result.DeepScan, 0)
} }
return result return
} }
+1 -1
View File
@@ -23,7 +23,7 @@ func Orgs(s github_recon_settings.Settings) (response OrgsResult) {
for _, org := range orgs { for _, org := range orgs {
o := OrgResult{ o := OrgResult{
Name: org.GetLogin(), Name: org.GetLogin(),
URL: org.GetURL(), URL: org.GetHTMLURL(),
Description: org.GetDescription(), Description: org.GetDescription(),
} }
response = append(response, o) response = append(response, o)
+4 -4
View File
@@ -31,13 +31,13 @@ type UserResult struct {
Plan string Plan string
} }
func User(s github_recon_settings.Settings) (response UserResult) { func User(s github_recon_settings.Settings) (response UserResult, err error) {
user, resp, err := s.Client.Users.Get(s.Ctx, s.Target) user, resp, err := s.Client.Users.Get(s.Ctx, s.Target)
if resp.StatusCode == 404 { if resp.StatusCode == 404 {
s.Logger.Fatal("User not found with username") return UserResult{}, nil
} }
if err != nil { if err != nil {
s.Logger.Fatal("Failed to fetch user's information", "err", err) return UserResult{}, fmt.Errorf("failed to fetch user's information")
} }
u := UserResult{ u := UserResult{
@@ -65,5 +65,5 @@ func User(s github_recon_settings.Settings) (response UserResult) {
} }
utils.WaitForRateLimit(s, resp) utils.WaitForRateLimit(s, resp)
return u return u, nil
} }
+2 -2
View File
@@ -68,7 +68,7 @@ func GetDefaultSettings() Settings {
} }
} }
func GetSettings() (settings Settings) { func GetSettings() (settings Settings, err error) {
settings = GetDefaultSettings() settings = GetDefaultSettings()
//// Flag settings //// Flag settings
flag.Usage = func() { flag.Usage = func() {
@@ -152,7 +152,7 @@ func GetSettings() (settings Settings) {
settings.Target = strings.TrimPrefix(settings.Target, "@") // Remove the @ of the username settings.Target = strings.TrimPrefix(settings.Target, "@") // Remove the @ of the username
if strings.Contains(settings.Target, " ") { if strings.Contains(settings.Target, " ") {
settings.Logger.Fatal("Target cannot contain spaces") err = fmt.Errorf("target cannot contain spaces")
} }
if strings.Contains(settings.Target, "@") { if strings.Contains(settings.Target, "@") {