mirror of
https://github.com/anotherhadi/github-recon.git
synced 2026-10-05 19:08:24 +02:00
+139
-67
@@ -4,88 +4,151 @@ import (
|
||||
"fmt"
|
||||
)
|
||||
|
||||
func (r Recon) SshKeys(username string) {
|
||||
type SSHKeyResult struct {
|
||||
ID string
|
||||
Url string
|
||||
Title string
|
||||
CreatedAt string
|
||||
Key string
|
||||
ReadOnly string
|
||||
Verified string
|
||||
LastUsed string
|
||||
AddedBy string
|
||||
}
|
||||
|
||||
func (r Recon) SshKeys(username string) (response []SSHKeyResult) {
|
||||
sshKeys, resp, err := r.client.Users.ListKeys(r.ctx, username, nil)
|
||||
if err != nil {
|
||||
r.logger.Error("Failed to fetch ssh keys", "err", err)
|
||||
} else if len(sshKeys) == 0 {
|
||||
PrintTitle("🔑 SSH Keys")
|
||||
r.logger.Info("No SSH Keys found\n")
|
||||
r.PrintTitle("🔑 SSH Keys")
|
||||
r.PrintInfo("INFO", "No SSH Keys found")
|
||||
} else {
|
||||
PrintTitle("🔑 SSH Keys")
|
||||
r.PrintTitle("🔑 SSH Keys")
|
||||
for i, key := range sshKeys {
|
||||
PrintInfo("Key n°", fmt.Sprintf("%d", i))
|
||||
PrintInfo("ID", fmt.Sprintf("%d", key.GetID()))
|
||||
PrintInfo("URL", key.GetURL())
|
||||
PrintInfo("Title", key.GetTitle())
|
||||
PrintInfo("Created At", key.GetCreatedAt().String())
|
||||
PrintInfo("Key", key.GetKey())
|
||||
PrintInfo("Read Only", fmt.Sprintf("%t", key.GetReadOnly()))
|
||||
PrintInfo("Verified", fmt.Sprintf("%t", key.GetVerified()))
|
||||
PrintInfo("Last Used", key.GetLastUsed().String())
|
||||
PrintInfo("Added By", key.GetAddedBy())
|
||||
fmt.Println()
|
||||
k := SSHKeyResult{
|
||||
ID: fmt.Sprintf("%d", key.GetID()),
|
||||
Url: key.GetURL(),
|
||||
Title: key.GetTitle(),
|
||||
CreatedAt: key.GetCreatedAt().String(),
|
||||
Key: key.GetKey(),
|
||||
ReadOnly: fmt.Sprintf("%t", key.GetReadOnly()),
|
||||
Verified: fmt.Sprintf("%t", key.GetVerified()),
|
||||
LastUsed: key.GetLastUsed().String(),
|
||||
AddedBy: key.GetAddedBy(),
|
||||
}
|
||||
response = append(response, k)
|
||||
r.PrintInfo("Key n°", fmt.Sprintf("%d", i))
|
||||
r.PrintInfo("ID", k.ID)
|
||||
r.PrintInfo("URL", k.Url)
|
||||
r.PrintInfo("Title", k.Title)
|
||||
r.PrintInfo("Created At", k.CreatedAt)
|
||||
r.PrintInfo("Key", k.Key)
|
||||
r.PrintInfo("Read Only", k.ReadOnly)
|
||||
r.PrintInfo("Verified", k.Verified)
|
||||
r.PrintInfo("Last Used", k.LastUsed)
|
||||
r.PrintInfo("Added By", k.AddedBy)
|
||||
r.PrintNewline()
|
||||
}
|
||||
}
|
||||
r.PrintNewline()
|
||||
WaitForRateLimit(resp)
|
||||
return
|
||||
}
|
||||
|
||||
func (r Recon) GpgKeys(username string) {
|
||||
type GPGKeyEmail struct {
|
||||
Email string
|
||||
Verified string
|
||||
}
|
||||
type GPGKeyResult struct {
|
||||
ID string
|
||||
KeyID string
|
||||
PublicKey string
|
||||
CreatedAt string
|
||||
PrimaryKeyID string
|
||||
RawKey string
|
||||
Emails []GPGKeyEmail
|
||||
Subkeys []GPGKeyResult
|
||||
}
|
||||
|
||||
func (r Recon) GpgKeys(username string) (response []GPGKeyResult) {
|
||||
gpgKeys, resp, err := r.client.Users.ListGPGKeys(r.ctx, username, nil)
|
||||
if err != nil {
|
||||
r.logger.Error("Failed to fetch user's gpg keys", "err", err)
|
||||
} else if len(gpgKeys) == 0 {
|
||||
PrintTitle("🗝️ GPG Keys")
|
||||
r.logger.Info("No GPG Keys found\n")
|
||||
r.PrintTitle("🗝️ GPG Keys")
|
||||
r.PrintInfo("INFO", "No GPG Keys found")
|
||||
} else {
|
||||
PrintTitle("🗝️ GPG Keys")
|
||||
r.PrintTitle("🗝️ GPG Keys")
|
||||
for i, key := range gpgKeys {
|
||||
PrintInfo("Key n°", fmt.Sprintf("%d", i))
|
||||
PrintInfo("ID", fmt.Sprintf("%d", key.GetID()))
|
||||
PrintInfo("Key ID", key.GetKeyID())
|
||||
PrintInfo("Public Key", key.GetPublicKey())
|
||||
PrintInfo("Created At", key.GetCreatedAt().String())
|
||||
PrintInfo("Expires At", key.GetExpiresAt().String())
|
||||
PrintInfo("Can Sign", fmt.Sprintf("%t", key.GetCanSign()))
|
||||
PrintInfo("Can Encrypt Comms", fmt.Sprintf("%t", key.GetCanEncryptComms()))
|
||||
PrintInfo("Can Encrypt Storage", fmt.Sprintf("%t", key.GetCanEncryptStorage()))
|
||||
PrintInfo("Can Certify", fmt.Sprintf("%t", key.GetCanCertify()))
|
||||
PrintInfo("Primary Key ID", fmt.Sprintf("%d", key.GetPrimaryKeyID()))
|
||||
PrintInfo("Raw Key", key.GetRawKey())
|
||||
PrintInfo("Emails", fmt.Sprintf("%d", len(key.Emails)))
|
||||
for j, email := range key.Emails {
|
||||
PrintInfo(" Email n°", fmt.Sprintf("%d", j))
|
||||
PrintInfo(" Email", email.GetEmail())
|
||||
PrintInfo(" Verified", fmt.Sprintf("%t", email.GetVerified()))
|
||||
k := GPGKeyResult{
|
||||
ID: fmt.Sprintf("%d", key.GetID()),
|
||||
KeyID: key.GetKeyID(),
|
||||
PublicKey: key.GetPublicKey(),
|
||||
CreatedAt: key.GetCreatedAt().String(),
|
||||
PrimaryKeyID: fmt.Sprintf("%d", key.GetPrimaryKeyID()),
|
||||
RawKey: key.GetRawKey(),
|
||||
Emails: []GPGKeyEmail{},
|
||||
Subkeys: []GPGKeyResult{},
|
||||
}
|
||||
PrintInfo("Subkeys", fmt.Sprintf("%d", len(key.Subkeys)))
|
||||
for j, subkey := range key.Subkeys {
|
||||
PrintInfo(" Subkey n°", fmt.Sprintf("%d", j))
|
||||
PrintInfo(" Subkey ID", fmt.Sprintf("%d", subkey.GetID()))
|
||||
PrintInfo(" Subkey Key ID", subkey.GetKeyID())
|
||||
PrintInfo(" Subkey Created At", subkey.GetCreatedAt().String())
|
||||
PrintInfo(" Subkey Expires At", subkey.GetExpiresAt().String())
|
||||
PrintInfo(" Subkey Can Sign", fmt.Sprintf("%t", subkey.GetCanSign()))
|
||||
PrintInfo(
|
||||
" Subkey Can Encrypt Comms",
|
||||
fmt.Sprintf("%t", subkey.GetCanEncryptComms()),
|
||||
)
|
||||
PrintInfo(
|
||||
" Subkey Can Encrypt Storage",
|
||||
fmt.Sprintf("%t", subkey.GetCanEncryptStorage()),
|
||||
)
|
||||
PrintInfo(" Subkey Can Certify", fmt.Sprintf("%t", subkey.GetCanCertify()))
|
||||
PrintInfo(" Subkey Primary Key ID", fmt.Sprintf("%d", subkey.GetPrimaryKeyID()))
|
||||
PrintInfo(" Subkey Raw Key", subkey.GetRawKey())
|
||||
PrintInfo(" Subkey Public Key", subkey.GetPublicKey())
|
||||
for _, email := range key.Emails {
|
||||
email := GPGKeyEmail{
|
||||
Email: email.GetEmail(),
|
||||
Verified: fmt.Sprintf("%t", email.GetVerified()),
|
||||
}
|
||||
k.Emails = append(k.Emails, email)
|
||||
}
|
||||
fmt.Println()
|
||||
for _, subkey := range key.Subkeys {
|
||||
subkey := GPGKeyResult{
|
||||
ID: fmt.Sprintf("%d", subkey.GetID()),
|
||||
KeyID: subkey.GetKeyID(),
|
||||
PublicKey: subkey.GetPublicKey(),
|
||||
CreatedAt: subkey.GetCreatedAt().String(),
|
||||
PrimaryKeyID: fmt.Sprintf("%d", subkey.GetPrimaryKeyID()),
|
||||
RawKey: subkey.GetRawKey(),
|
||||
}
|
||||
k.Subkeys = append(k.Subkeys, subkey)
|
||||
}
|
||||
response = append(response, k)
|
||||
r.PrintInfo("Key n°", fmt.Sprintf("%d", i))
|
||||
r.PrintInfo("ID", k.ID)
|
||||
r.PrintInfo("Key ID", k.KeyID)
|
||||
r.PrintInfo("Public Key", k.PublicKey)
|
||||
r.PrintInfo("Created At", k.CreatedAt)
|
||||
r.PrintInfo("Primary Key ID", k.PrimaryKeyID)
|
||||
r.PrintInfo("Raw Key", k.RawKey)
|
||||
r.PrintInfo("Emails", fmt.Sprintf("%d", len(k.Emails)))
|
||||
for j, email := range k.Emails {
|
||||
r.PrintInfo(" Email n°", fmt.Sprintf("%d", j))
|
||||
r.PrintInfo(" Email", email.Email)
|
||||
r.PrintInfo(" Verified", email.Verified)
|
||||
}
|
||||
r.PrintInfo("Subkeys", fmt.Sprintf("%d", len(k.Subkeys)))
|
||||
for j, subkey := range k.Subkeys {
|
||||
r.PrintInfo(" Subkey n°", fmt.Sprintf("%d", j))
|
||||
r.PrintInfo(" Subkey ID", subkey.ID)
|
||||
r.PrintInfo(" Subkey Key ID", subkey.KeyID)
|
||||
r.PrintInfo(" Subkey Created At", subkey.CreatedAt)
|
||||
r.PrintInfo(" Subkey Primary Key ID", subkey.PrimaryKeyID)
|
||||
r.PrintInfo(" Subkey Raw Key", subkey.RawKey)
|
||||
}
|
||||
|
||||
r.PrintNewline()
|
||||
}
|
||||
}
|
||||
r.PrintNewline()
|
||||
WaitForRateLimit(resp)
|
||||
return
|
||||
}
|
||||
|
||||
func (r Recon) SshSigningKeys(username string) {
|
||||
type SSHSigningKeyResult struct {
|
||||
ID string
|
||||
Title string
|
||||
CreatedAt string
|
||||
Key string
|
||||
}
|
||||
|
||||
func (r Recon) SshSigningKeys(username string) (response []SSHSigningKeyResult) {
|
||||
signingKeys, resp, err := r.client.Users.ListSSHSigningKeys(
|
||||
r.ctx,
|
||||
username,
|
||||
@@ -94,18 +157,27 @@ func (r Recon) SshSigningKeys(username string) {
|
||||
if err != nil {
|
||||
r.logger.Error("Failed to fetch user's ssh signing keys", "err", err)
|
||||
} else if len(signingKeys) == 0 {
|
||||
PrintTitle("📝 SSH Signing Keys")
|
||||
r.logger.Info("No SSH Signing Keys found\n")
|
||||
r.PrintTitle("📝 SSH Signing Keys")
|
||||
r.PrintInfo("INFO", "No SSH Signing Keys found")
|
||||
} else {
|
||||
PrintTitle("📝 SSH Signing Keys")
|
||||
r.PrintTitle("📝 SSH Signing Keys")
|
||||
for i, key := range signingKeys {
|
||||
PrintInfo("Key n°", fmt.Sprintf("%d", i))
|
||||
PrintInfo("ID", fmt.Sprintf("%d", key.GetID()))
|
||||
PrintInfo("Key", key.GetKey())
|
||||
PrintInfo("Title", key.GetTitle())
|
||||
PrintInfo("Created At", key.GetCreatedAt().String())
|
||||
fmt.Println()
|
||||
k := SSHSigningKeyResult{
|
||||
ID: fmt.Sprintf("%d", key.GetID()),
|
||||
Title: key.GetTitle(),
|
||||
CreatedAt: key.GetCreatedAt().String(),
|
||||
Key: key.GetKey(),
|
||||
}
|
||||
r.PrintInfo("Key n°", fmt.Sprintf("%d", i))
|
||||
r.PrintInfo("ID", k.ID)
|
||||
r.PrintInfo("Title", k.Title)
|
||||
r.PrintInfo("Created At", k.CreatedAt)
|
||||
r.PrintInfo("Key", k.Key)
|
||||
r.PrintNewline()
|
||||
response = append(response, k)
|
||||
}
|
||||
}
|
||||
WaitForRateLimit(resp)
|
||||
r.PrintNewline()
|
||||
return response
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user