mirror of
https://github.com/anotherhadi/github-recon.git
synced 2026-10-05 10:58:25 +02:00
Init v2, rewrite
This commit is contained in:
@@ -0,0 +1,41 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"io"
|
||||
"net/http"
|
||||
"os"
|
||||
|
||||
github_recon_settings "github.com/anotherhadi/github-recon/settings"
|
||||
gopixels "github.com/saran13raj/go-pixels"
|
||||
)
|
||||
|
||||
func printAvatar(settings github_recon_settings.Settings, url string) {
|
||||
if settings.HideAvatar || url == "" || settings.Silent {
|
||||
return
|
||||
}
|
||||
|
||||
resp, err := http.Get(url)
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
defer resp.Body.Close()
|
||||
|
||||
tmpfile, err := os.CreateTemp("", "avatar-*.png")
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
defer os.Remove(tmpfile.Name())
|
||||
|
||||
_, err = io.Copy(tmpfile, resp.Body)
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
|
||||
output, err := gopixels.FromImagePath(tmpfile.Name(), 30, 25, "halfcell", true)
|
||||
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
fmt.Println(output + "\n")
|
||||
}
|
||||
@@ -0,0 +1,26 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
recon "github.com/anotherhadi/github-recon/github-recon/email"
|
||||
github_recon_settings "github.com/anotherhadi/github-recon/settings"
|
||||
)
|
||||
|
||||
type EmailResult struct {
|
||||
DateTime string
|
||||
Target string
|
||||
TargetType github_recon_settings.TargetType
|
||||
|
||||
Commit recon.EmailsResult
|
||||
}
|
||||
|
||||
func email(settings github_recon_settings.Settings, datetime string) {
|
||||
result := EmailResult{
|
||||
Target: settings.Target,
|
||||
TargetType: settings.TargetType,
|
||||
DateTime: datetime,
|
||||
}
|
||||
|
||||
printTitle(settings.Silent, "👤 Commits author")
|
||||
result.Commit = recon.Email(settings)
|
||||
printStruct(settings, result.Commit, 0)
|
||||
}
|
||||
+31
@@ -0,0 +1,31 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
"os"
|
||||
|
||||
github_recon_settings "github.com/anotherhadi/github-recon/settings"
|
||||
)
|
||||
|
||||
func writeJson(s github_recon_settings.Settings, data any) {
|
||||
if s.JsonOutput == "" {
|
||||
return
|
||||
}
|
||||
file, err := os.Create(s.JsonOutput)
|
||||
if err != nil {
|
||||
s.Logger.Error("Failed to create JSON file", "err", err)
|
||||
return
|
||||
}
|
||||
|
||||
defer func() {
|
||||
_ = file.Close()
|
||||
}()
|
||||
|
||||
as_json, _ := json.MarshalIndent(data, "", "\t")
|
||||
_, err = file.Write(as_json)
|
||||
if err != nil {
|
||||
s.Logger.Error("Failed to write to JSON file", "err", err)
|
||||
return
|
||||
}
|
||||
s.Logger.Info("JSON output written to file", "file", s.JsonOutput)
|
||||
}
|
||||
+32
@@ -0,0 +1,32 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"time"
|
||||
|
||||
github_recon_settings "github.com/anotherhadi/github-recon/settings"
|
||||
)
|
||||
|
||||
func main() {
|
||||
settings := github_recon_settings.GetSettings()
|
||||
datetime := time.Now().String()
|
||||
|
||||
if !settings.Silent {
|
||||
header()
|
||||
|
||||
printStruct(settings, struct {
|
||||
Target string
|
||||
TargetType string
|
||||
DateTime string
|
||||
}{
|
||||
Target: settings.Target,
|
||||
TargetType: string(settings.TargetType),
|
||||
DateTime: datetime,
|
||||
}, 0)
|
||||
}
|
||||
|
||||
if settings.TargetType == github_recon_settings.TargetUsername {
|
||||
username(settings, datetime)
|
||||
} else {
|
||||
email(settings, datetime)
|
||||
}
|
||||
}
|
||||
+103
@@ -0,0 +1,103 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"reflect"
|
||||
"strings"
|
||||
|
||||
github_recon_settings "github.com/anotherhadi/github-recon/settings"
|
||||
"github.com/charmbracelet/lipgloss"
|
||||
)
|
||||
|
||||
var (
|
||||
grey = lipgloss.Color("#7d7d7d")
|
||||
green = lipgloss.Color("#a6e3a1")
|
||||
blue = lipgloss.Color("#7287fd")
|
||||
|
||||
greyStyle = lipgloss.NewStyle().Foreground(grey)
|
||||
greenStyle = lipgloss.NewStyle().Foreground(green)
|
||||
titleStyle = lipgloss.NewStyle().Bold(true).Foreground(blue)
|
||||
)
|
||||
|
||||
func printStruct(settings github_recon_settings.Settings, s any, indent int) {
|
||||
if settings.Silent {
|
||||
return
|
||||
}
|
||||
|
||||
prefix := strings.Repeat(" ", indent)
|
||||
|
||||
v := reflect.ValueOf(s)
|
||||
t := reflect.TypeOf(s)
|
||||
|
||||
if v.Kind() == reflect.Ptr {
|
||||
v = v.Elem()
|
||||
t = t.Elem()
|
||||
}
|
||||
|
||||
switch v.Kind() {
|
||||
case reflect.Struct:
|
||||
if v.NumField() == 0 {
|
||||
fmt.Println(prefix + greyStyle.Render("No data found"))
|
||||
fmt.Println("")
|
||||
return
|
||||
}
|
||||
|
||||
for i := 0; i < v.NumField(); i++ {
|
||||
field := t.Field(i).Name
|
||||
value := v.Field(i)
|
||||
|
||||
if !value.IsValid() || (value.Kind() == reflect.String && value.String() == "") {
|
||||
continue
|
||||
}
|
||||
if value.Kind() == reflect.String && value.String() == "0001-01-01 00:00:00 +0000 UTC" {
|
||||
continue
|
||||
}
|
||||
if (field == "FirstFoundIn" || field == "FoundIn") && !settings.ShowSource {
|
||||
continue
|
||||
}
|
||||
|
||||
switch value.Kind() {
|
||||
case reflect.Struct, reflect.Slice, reflect.Array, reflect.Ptr:
|
||||
fmt.Println(prefix + greyStyle.Render(field+":"))
|
||||
printStruct(settings, value.Interface(), indent+1)
|
||||
case reflect.String:
|
||||
fmt.Printf("%s%s %s\n", prefix, greyStyle.Render(field+":"), greenStyle.Render(fmt.Sprintf("%q", value.Interface())))
|
||||
default:
|
||||
fmt.Printf("%s%s %s\n", prefix, greyStyle.Render(field+":"), greenStyle.Render(fmt.Sprintf("%v", value.Interface())))
|
||||
}
|
||||
}
|
||||
fmt.Println("")
|
||||
|
||||
case reflect.Slice, reflect.Array:
|
||||
if v.Len() == 0 {
|
||||
fmt.Println(prefix + greyStyle.Render("No data found"))
|
||||
fmt.Println("")
|
||||
return
|
||||
}
|
||||
for i := 0; i < v.Len(); i++ {
|
||||
printStruct(settings, v.Index(i).Interface(), indent)
|
||||
}
|
||||
|
||||
default:
|
||||
fmt.Println(prefix + greenStyle.Render(fmt.Sprintf("%v", v.Interface())))
|
||||
fmt.Println("")
|
||||
}
|
||||
}
|
||||
|
||||
func header() {
|
||||
asciiArt := " __ \n ___ _/ / _______ _______ ___ \n / _ `/ _ \\/ __/ -_) __/ _ \\/ _ \\\n \\_, /_//_/_/ \\__/\\__/\\___/_//_/\n/___/ "
|
||||
|
||||
grey := lipgloss.Color("#7d7d7d")
|
||||
|
||||
greyStyle := lipgloss.NewStyle().Foreground(grey)
|
||||
fmt.Println(
|
||||
greyStyle.Render(lipgloss.JoinVertical(lipgloss.Right, asciiArt, "@anotherhadi\n")),
|
||||
)
|
||||
}
|
||||
|
||||
func printTitle(silent bool, title string) {
|
||||
if silent {
|
||||
return
|
||||
}
|
||||
fmt.Println(titleStyle.Render(title) + "\n")
|
||||
}
|
||||
@@ -0,0 +1,75 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
recon "github.com/anotherhadi/github-recon/github-recon/username"
|
||||
github_recon_settings "github.com/anotherhadi/github-recon/settings"
|
||||
)
|
||||
|
||||
type UsernameResult struct {
|
||||
DateTime string // Now
|
||||
Target string
|
||||
TargetType github_recon_settings.TargetType
|
||||
|
||||
User recon.UserResult
|
||||
Socials recon.SocialsResult
|
||||
Orgs recon.OrgsResult
|
||||
|
||||
SshKeys recon.SshKeysResult
|
||||
SshSigningKeys recon.SshSigningKeysResult
|
||||
GpgKeys recon.GpgKeysResult
|
||||
|
||||
CloseFriends recon.CloseFriendsResult
|
||||
|
||||
Commits recon.CommitsResult
|
||||
|
||||
DeepScan recon.DeepScanResult
|
||||
}
|
||||
|
||||
func username(settings github_recon_settings.Settings, datetime string) {
|
||||
result := UsernameResult{
|
||||
Target: settings.Target,
|
||||
TargetType: settings.TargetType,
|
||||
DateTime: datetime,
|
||||
}
|
||||
|
||||
printTitle(settings.Silent, "👤 User informations")
|
||||
result.User = recon.User(settings)
|
||||
printAvatar(settings, result.User.AvatarURL)
|
||||
printStruct(settings, result.User, 0)
|
||||
|
||||
printTitle(settings.Silent, "🐥 Socials")
|
||||
result.Socials = recon.Socials(settings)
|
||||
printStruct(settings, result.Socials, 0)
|
||||
|
||||
printTitle(settings.Silent, "🏢 Organizations")
|
||||
result.Orgs = recon.Orgs(settings)
|
||||
printStruct(settings, result.Orgs, 0)
|
||||
|
||||
printTitle(settings.Silent, "🔑 SSH Keys")
|
||||
result.SshKeys = recon.SshKeys(settings)
|
||||
printStruct(settings, result.SshKeys, 0)
|
||||
|
||||
printTitle(settings.Silent, "🖋️ SSH Signing Keys")
|
||||
result.SshSigningKeys = recon.SshSigningKeys(settings)
|
||||
printStruct(settings, result.SshSigningKeys, 0)
|
||||
|
||||
printTitle(settings.Silent, "🔐 GPG Keys")
|
||||
result.GpgKeys = recon.GpgKeys(settings)
|
||||
printStruct(settings, result.GpgKeys, 0)
|
||||
|
||||
printTitle(settings.Silent, "🤝 Close Friends")
|
||||
result.CloseFriends = recon.CloseFriends(settings)
|
||||
printStruct(settings, result.CloseFriends, 0)
|
||||
|
||||
printTitle(settings.Silent, "📝 Commits")
|
||||
result.Commits = recon.Commits(settings)
|
||||
printStruct(settings, result.Commits, 0)
|
||||
|
||||
if settings.DeepScan {
|
||||
printTitle(settings.Silent, "🔍 Deep Scan")
|
||||
result.DeepScan = recon.DeepScan(settings)
|
||||
printStruct(settings, result.DeepScan, 0)
|
||||
}
|
||||
|
||||
writeJson(settings, result)
|
||||
}
|
||||
Reference in New Issue
Block a user