Skip to content

Commit

Permalink
brought the oam_tools into the repo
Browse files Browse the repository at this point in the history
  • Loading branch information
caffix committed Oct 16, 2024
1 parent bd09040 commit 2d8208c
Show file tree
Hide file tree
Showing 30 changed files with 2,277 additions and 1,218 deletions.
22 changes: 12 additions & 10 deletions cmd/amass/emails.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@ import (
"github.com/caffix/stringset"
"github.com/fatih/color"
"github.com/owasp-amass/amass/v4/config"
"github.com/owasp-amass/amass/v4/utils"
"github.com/owasp-amass/amass/v4/utils/afmt"
assetdb "github.com/owasp-amass/asset-db"
oam "github.com/owasp-amass/open-asset-model"
"github.com/owasp-amass/open-asset-model/contact"
Expand Down Expand Up @@ -62,17 +64,17 @@ func runEmailsCommand(clArgs []string) {
emailsCommand.StringVar(&args.Filepaths.TermOut, "o", "", "Path to the text file containing terminal stdout/stderr")

var usage = func() {
g.Fprintf(color.Error, "Usage: %s %s\n\n", path.Base(os.Args[0]), emailsUsageMsg)
afmt.G.Fprintf(color.Error, "Usage: %s %s\n\n", path.Base(os.Args[0]), emailsUsageMsg)
emailsCommand.PrintDefaults()
g.Fprintln(color.Error, emailsBuf.String())
afmt.G.Fprintln(color.Error, emailsBuf.String())
}

if len(clArgs) < 1 {
usage()
return
}
if err := emailsCommand.Parse(clArgs); err != nil {
r.Fprintf(color.Error, "%v\n", err)
afmt.R.Fprintf(color.Error, "%v\n", err)
os.Exit(1)
}
if help1 || help2 {
Expand All @@ -89,7 +91,7 @@ func runEmailsCommand(clArgs []string) {
if args.Filepaths.Domains != "" {
list, err := config.GetListFromFile(args.Filepaths.Domains)
if err != nil {
r.Fprintf(color.Error, "Failed to parse the domain names file: %v\n", err)
afmt.R.Fprintf(color.Error, "Failed to parse the domain names file: %v\n", err)
return
}
args.Domains.InsertMany(list...)
Expand All @@ -105,13 +107,13 @@ func runEmailsCommand(clArgs []string) {
args.Domains.InsertMany(cfg.Domains()...)
}
} else if args.Filepaths.ConfigFile != "" {
r.Fprintf(color.Error, "Failed to load the configuration file: %v\n", err)
afmt.R.Fprintf(color.Error, "Failed to load the configuration file: %v\n", err)
os.Exit(1)
}

db := openGraphDatabase(cfg)
db := utils.OpenGraphDatabase(cfg)
if db == nil {
r.Fprintln(color.Error, "Failed to connect with the database")
afmt.R.Fprintln(color.Error, "Failed to connect with the database")
os.Exit(1)
}

Expand All @@ -126,7 +128,7 @@ func showEmails(args *emailsArgs, db *assetdb.AssetDB) {
if args.Filepaths.TermOut != "" {
outfile, err = os.OpenFile(args.Filepaths.TermOut, os.O_WRONLY|os.O_CREATE, 0644)
if err != nil {
r.Fprintf(color.Error, "Failed to open the text output file: %v\n", err)
afmt.R.Fprintf(color.Error, "Failed to open the text output file: %v\n", err)
os.Exit(1)
}
defer func() {
Expand All @@ -139,12 +141,12 @@ func showEmails(args *emailsArgs, db *assetdb.AssetDB) {

addrs := getAddresses(db, domains)
if len(addrs) == 0 {
r.Println("No email addresses were discovered")
afmt.R.Println("No email addresses were discovered")
return
}

for _, addr := range addrs {
g.Println(addr)
afmt.G.Println(addr)
}
}

Expand Down
36 changes: 18 additions & 18 deletions cmd/amass/enum.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,16 +21,16 @@ import (
"github.com/fatih/color"
"github.com/owasp-amass/amass/v4/config"
"github.com/owasp-amass/amass/v4/engine/api/graphql/client"
"github.com/owasp-amass/amass/v4/format"
"github.com/owasp-amass/amass/v4/resources"
"github.com/owasp-amass/amass/v4/utils/afmt"
)

const enumUsageMsg = "enum [options] -d DOMAIN"

type enumArgs struct {
Addresses format.ParseIPs
ASNs format.ParseInts
CIDRs format.ParseCIDRs
Addresses afmt.ParseIPs
ASNs afmt.ParseInts
CIDRs afmt.ParseCIDRs
AltWordList *stringset.Set
AltWordListMask *stringset.Set
BruteWordList *stringset.Set
Expand All @@ -46,7 +46,7 @@ type enumArgs struct {
MaxDepth int
MinForRecursive int
Names *stringset.Set
Ports format.ParseInts
Ports afmt.ParseInts
Resolvers *stringset.Set
Trusted *stringset.Set
Timeout int
Expand All @@ -65,19 +65,19 @@ type enumArgs struct {
}
Filepaths struct {
AllFilePrefix string
AltWordlist format.ParseStrings
AltWordlist afmt.ParseStrings
Blacklist string
BruteWordlist format.ParseStrings
BruteWordlist afmt.ParseStrings
ConfigFile string
Directory string
Domains format.ParseStrings
Domains afmt.ParseStrings
ExcludedSrcs string
IncludedSrcs string
JSONOutput string
LogFile string
Names format.ParseStrings
Resolvers format.ParseStrings
Trusted format.ParseStrings
Names afmt.ParseStrings
Resolvers afmt.ParseStrings
Trusted afmt.ParseStrings
ScriptsDirectory string
TermOut string
}
Expand Down Expand Up @@ -247,7 +247,7 @@ func writeLogMessage(l *slog.Logger, message string) {
return
}

record, err := format.JSONLogToRecord(logstr)
record, err := afmt.JSONLogToRecord(logstr)
if err != nil {
return
}
Expand Down Expand Up @@ -313,7 +313,7 @@ func argsAndConfig(clArgs []string) (*config.Config, *enumArgs) {
return nil, &args
}
if err := enumCommand.Parse(clArgs); err != nil {
r.Fprintf(color.Error, "%v\n", err)
afmt.R.Fprintf(color.Error, "%v\n", err)
os.Exit(1)
}
if help1 || help2 {
Expand All @@ -335,7 +335,7 @@ func argsAndConfig(clArgs []string) (*config.Config, *enumArgs) {
}
if (args.Excluded.Len() > 0 || args.Filepaths.ExcludedSrcs != "") &&
(args.Included.Len() > 0 || args.Filepaths.IncludedSrcs != "") {
r.Fprintln(color.Error, "Cannot provide both include and exclude arguments")
afmt.R.Fprintln(color.Error, "Cannot provide both include and exclude arguments")
commandUsage(enumUsageMsg, enumCommand, enumBuf)
os.Exit(1)
}
Expand All @@ -352,21 +352,21 @@ func argsAndConfig(clArgs []string) (*config.Config, *enumArgs) {
args.Resolvers = stringset.New(cfg.Resolvers...)
}
} else if args.Filepaths.ConfigFile != "" {
r.Fprintf(color.Error, "Failed to load the configuration file: %v\n", err)
afmt.R.Fprintf(color.Error, "Failed to load the configuration file: %v\n", err)
os.Exit(1)
}
// Override configuration file settings with command-line arguments
if err := cfg.UpdateConfig(args); err != nil {
r.Fprintf(color.Error, "Configuration error: %v\n", err)
afmt.R.Fprintf(color.Error, "Configuration error: %v\n", err)
os.Exit(1)
}
// Some input validation
if !cfg.Active && len(args.Ports) > 0 {
r.Fprintln(color.Error, "Ports can only be scanned in the active mode")
afmt.R.Fprintln(color.Error, "Ports can only be scanned in the active mode")
os.Exit(1)
}
if len(cfg.Domains()) == 0 {
r.Fprintln(color.Error, "Configuration error: No root domain names were provided")
afmt.R.Fprintln(color.Error, "Configuration error: No root domain names were provided")
os.Exit(1)
}
return cfg, &args
Expand Down
171 changes: 0 additions & 171 deletions cmd/amass/format.go

This file was deleted.

Loading

0 comments on commit 2d8208c

Please sign in to comment.