Skip to content

Commit

Permalink
removed the utils package
Browse files Browse the repository at this point in the history
  • Loading branch information
caffix committed Sep 2, 2019
1 parent 0e31b0d commit c0b7851
Show file tree
Hide file tree
Showing 112 changed files with 582 additions and 13,781 deletions.
19 changes: 10 additions & 9 deletions .goreleaser.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ archives:
- LICENSE
- README.md
- doc/*
- wordlists/*
- examples/wordlists/*

checksum:
name_template: "amass_checksums.txt"
Expand Down Expand Up @@ -90,12 +90,13 @@ snapcrafts:

apps:
amass:
plugs: ["home", "network", "removable-media"]
# plugs: ["home", "network", "removable-media", "personal-files"]
plugs: ["home", "network", "removable-media", "personal-files"]

# plugs:
# personal-files:
# read:
# - $HOME/.amass
# write:
# - $HOME/.amass
plugs:
personal-files:
read:
- $HOME/.amass
- $HOME/.config/amass
write:
- $HOME/.amass
- $HOME/.config/amass
2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,6 @@ RUN go install ./...
FROM alpine:latest
RUN apk --no-cache add ca-certificates
COPY --from=build /go/bin/amass /bin/amass
COPY --from=build /go/src/github.com/OWASP/Amass/wordlists/ /wordlists/
COPY --from=build /go/src/github.com/OWASP/Amass/examples/wordlists/ /wordlists/
ENV HOME /
ENTRYPOINT ["/bin/amass"]
12 changes: 6 additions & 6 deletions cmd/amass/db.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,11 @@ import (
"time"

"github.com/OWASP/Amass/config"
"github.com/OWASP/Amass/format"
"github.com/OWASP/Amass/graph"
"github.com/OWASP/Amass/requests"
sf "github.com/OWASP/Amass/stringfilter"
"github.com/OWASP/Amass/stringset"
"github.com/OWASP/Amass/utils"
"github.com/fatih/color"
)

Expand Down Expand Up @@ -206,20 +206,20 @@ func showEnumeration(args *dbArgs, db graph.DataHandler) {
domains := args.Domains.Slice()
var total int
tags := make(map[string]int)
asns := make(map[int]*utils.ASNSummaryData)
asns := make(map[int]*format.ASNSummaryData)
for _, out := range getEnumOutput(args.Enum, domains, db) {
if len(domains) > 0 && !domainNameInScope(out.Name, domains) {
continue
}

out.Addresses = utils.DesiredAddrTypes(out.Addresses, args.Options.IPv4, args.Options.IPv6)
out.Addresses = format.DesiredAddrTypes(out.Addresses, args.Options.IPv4, args.Options.IPv6)
if len(out.Addresses) == 0 {
continue
}

total++
utils.UpdateSummaryData(out, tags, asns)
source, name, ips := utils.OutputLineParts(out, args.Options.Sources,
format.UpdateSummaryData(out, tags, asns)
source, name, ips := format.OutputLineParts(out, args.Options.Sources,
args.Options.IPs || args.Options.IPv4 || args.Options.IPv6, args.Options.DemoMode)

if ips != "" {
Expand All @@ -231,7 +231,7 @@ func showEnumeration(args *dbArgs, db graph.DataHandler) {
if total == 0 {
r.Println("No names were discovered")
} else {
utils.PrintEnumerationSummary(total, tags, asns, args.Options.DemoMode)
format.PrintEnumerationSummary(total, tags, asns, args.Options.DemoMode)
}
}

Expand Down
30 changes: 15 additions & 15 deletions cmd/amass/enum.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,9 @@ import (

"github.com/OWASP/Amass/config"
"github.com/OWASP/Amass/enum"
"github.com/OWASP/Amass/format"
"github.com/OWASP/Amass/resolvers"
"github.com/OWASP/Amass/stringset"
"github.com/OWASP/Amass/utils"
"github.com/fatih/color"
homedir "github.com/mitchellh/go-homedir"
)
Expand All @@ -39,9 +39,9 @@ var (
)

type enumArgs struct {
Addresses utils.ParseIPs
ASNs utils.ParseInts
CIDRs utils.ParseCIDRs
Addresses format.ParseIPs
ASNs format.ParseInts
CIDRs format.ParseCIDRs
AltWordList stringset.Set
AltWordListMask stringset.Set
BruteWordList stringset.Set
Expand All @@ -53,7 +53,7 @@ type enumArgs struct {
MaxDNSQueries int
MinForRecursive int
Names stringset.Set
Ports utils.ParseInts
Ports format.ParseInts
Resolvers stringset.Set
Timeout int
Options struct {
Expand All @@ -75,19 +75,19 @@ type enumArgs struct {
}
Filepaths struct {
AllFilePrefix string
AltWordlist utils.ParseStrings
AltWordlist format.ParseStrings
Blacklist string
BruteWordlist utils.ParseStrings
BruteWordlist format.ParseStrings
ConfigFile string
DataOpts string
Directory string
Domains utils.ParseStrings
Domains format.ParseStrings
ExcludedSrcs string
IncludedSrcs string
JSONOutput string
LogFile string
Names utils.ParseStrings
Resolvers utils.ParseStrings
Names format.ParseStrings
Resolvers format.ParseStrings
TermOut string
}
}
Expand Down Expand Up @@ -353,17 +353,17 @@ func processEnumOutput(e *enum.Enumeration, args *enumArgs, pipe *io.PipeReader)
go func() {
var total int
tags := make(map[string]int)
asns := make(map[int]*utils.ASNSummaryData)
asns := make(map[int]*format.ASNSummaryData)
// Collect all the names returned by the enumeration
for out := range e.Output {
out.Addresses = utils.DesiredAddrTypes(out.Addresses, args.Options.IPv4, args.Options.IPv6)
out.Addresses = format.DesiredAddrTypes(out.Addresses, args.Options.IPv4, args.Options.IPv6)
if !e.Config.Passive && len(out.Addresses) <= 0 {
continue
}

total++
utils.UpdateSummaryData(out, tags, asns)
source, name, ips := utils.OutputLineParts(out, args.Options.Sources,
format.UpdateSummaryData(out, tags, asns)
source, name, ips := format.OutputLineParts(out, args.Options.Sources,
args.Options.IPs || args.Options.IPv4 || args.Options.IPv6, args.Options.DemoMode)

if ips != "" {
Expand All @@ -383,7 +383,7 @@ func processEnumOutput(e *enum.Enumeration, args *enumArgs, pipe *io.PipeReader)
if total == 0 {
r.Println("No names were discovered")
} else {
utils.PrintEnumerationSummary(total, tags, asns, args.Options.DemoMode)
format.PrintEnumerationSummary(total, tags, asns, args.Options.DemoMode)
}
close(finished)
}()
Expand Down
16 changes: 8 additions & 8 deletions cmd/amass/intel.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,10 @@ import (
"time"

"github.com/OWASP/Amass/config"
"github.com/OWASP/Amass/format"
"github.com/OWASP/Amass/intel"
"github.com/OWASP/Amass/resolvers"
"github.com/OWASP/Amass/stringset"
"github.com/OWASP/Amass/utils"
"github.com/fatih/color"
homedir "github.com/mitchellh/go-homedir"
)
Expand All @@ -31,15 +31,15 @@ const (
)

type intelArgs struct {
Addresses utils.ParseIPs
ASNs utils.ParseInts
CIDRs utils.ParseCIDRs
Addresses format.ParseIPs
ASNs format.ParseInts
CIDRs format.ParseCIDRs
OrganizationName string
Domains stringset.Set
Excluded stringset.Set
Included stringset.Set
MaxDNSQueries int
Ports utils.ParseInts
Ports format.ParseInts
Resolvers stringset.Set
Timeout int
Options struct {
Expand All @@ -58,11 +58,11 @@ type intelArgs struct {
Filepaths struct {
ConfigFile string
Directory string
Domains utils.ParseStrings
Domains format.ParseStrings
ExcludedSrcs string
IncludedSrcs string
LogFile string
Resolvers utils.ParseStrings
Resolvers format.ParseStrings
TermOut string
}
}
Expand Down Expand Up @@ -280,7 +280,7 @@ func processIntelOutput(ic *intel.Collection, args *intelArgs, pipe *io.PipeRead

// Collect all the names returned by the intelligence collection
for out := range ic.Output {
source, name, ips := utils.OutputLineParts(out, args.Options.Sources,
source, name, ips := format.OutputLineParts(out, args.Options.Sources,
args.Options.IPs || args.Options.IPv4 || args.Options.IPv6, args.Options.DemoMode)

if ips != "" {
Expand Down
6 changes: 3 additions & 3 deletions cmd/amass/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,9 @@ import (

"github.com/OWASP/Amass/config"
"github.com/OWASP/Amass/eventbus"
"github.com/OWASP/Amass/format"
"github.com/OWASP/Amass/resolvers"
"github.com/OWASP/Amass/services/sources"
"github.com/OWASP/Amass/utils"
"github.com/fatih/color"
)

Expand All @@ -38,7 +38,7 @@ var (
)

func commandUsage(msg string, cmdFlagSet *flag.FlagSet, errBuf *bytes.Buffer) {
utils.PrintBanner()
format.PrintBanner()
g.Fprintf(color.Error, "Usage: %s %s\n\n", path.Base(os.Args[0]), msg)
cmdFlagSet.PrintDefaults()
g.Fprintln(color.Error, errBuf.String())
Expand Down Expand Up @@ -81,7 +81,7 @@ func main() {
return
}
if version {
fmt.Fprintf(color.Error, "%s\n", utils.Version)
fmt.Fprintf(color.Error, "%s\n", format.Version)
return
}

Expand Down
2 changes: 1 addition & 1 deletion cmd/amass/viz.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ import (
"github.com/OWASP/Amass/config"
"github.com/OWASP/Amass/graph"
"github.com/OWASP/Amass/stringset"
"github.com/OWASP/Amass/utils/viz"
"github.com/OWASP/Amass/viz"
"github.com/fatih/color"
)

Expand Down
20 changes: 12 additions & 8 deletions config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,12 @@ import (
"strings"
"sync"

"github.com/OWASP/Amass/format"
"github.com/OWASP/Amass/net/dns"
amasshttp "github.com/OWASP/Amass/net/http"
"github.com/OWASP/Amass/semaphore"
"github.com/OWASP/Amass/stringset"
"github.com/OWASP/Amass/utils"
"github.com/OWASP/Amass/wordlist"
"github.com/go-ini/ini"
"github.com/google/uuid"
homedir "github.com/mitchellh/go-homedir"
Expand Down Expand Up @@ -78,7 +82,7 @@ type Config struct {
MaxDNSQueries int `ini:"maximum_dns_queries"`

// Semaphore to enforce the maximum DNS queries
SemMaxDNSQueries utils.Semaphore
SemMaxDNSQueries semaphore.Semaphore

// Names provided to seed the enumeration
ProvidedNames []string
Expand Down Expand Up @@ -185,7 +189,7 @@ func NewConfig() *Config {
Recursive: true,
}

c.SemMaxDNSQueries = utils.NewSimpleSemaphore(c.MaxDNSQueries)
c.SemMaxDNSQueries = semaphore.NewSimpleSemaphore(c.MaxDNSQueries)

return c
}
Expand Down Expand Up @@ -216,12 +220,12 @@ func (c *Config) CheckSettings() error {
}
}

c.Wordlist, err = utils.ExpandMaskWordlist(c.Wordlist)
c.Wordlist, err = wordlist.ExpandMaskWordlist(c.Wordlist)
if err != nil {
return err
}

c.AltWordlist, err = utils.ExpandMaskWordlist(c.AltWordlist)
c.AltWordlist, err = wordlist.ExpandMaskWordlist(c.AltWordlist)
if err != nil {
return err
}
Expand Down Expand Up @@ -282,7 +286,7 @@ func (c *Config) AddDomain(domain string) {
}

// Create the regular expression for this domain
c.regexps[d] = utils.SubdomainRegex(d)
c.regexps[d] = dns.SubdomainRegex(d)
if c.regexps[d] != nil {
// Add the domain string to the list
c.domains = append(c.domains, d)
Expand Down Expand Up @@ -401,7 +405,7 @@ func (c *Config) loadNetworkSettings(cfg *ini.File) error {

if network.HasKey("address") {
for _, addr := range network.Key("address").ValueWithShadows() {
var ips utils.ParseIPs
var ips format.ParseIPs

if err := ips.Set(addr); err != nil {
return err
Expand Down Expand Up @@ -682,7 +686,7 @@ func GetListFromFile(path string) ([]string, error) {
}

func getWordlistByURL(url string) ([]string, error) {
page, err := utils.RequestWebPage(url, nil, nil, "", "")
page, err := amasshttp.RequestWebPage(url, nil, nil, "", "")
if err != nil {
return nil, fmt.Errorf("Failed to obtain the wordlist at %s: %v", url, err)
}
Expand Down
21 changes: 9 additions & 12 deletions doc/install.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ docker run -v ~/amass:/amass/ amass enum --list

The volume argument allows the Amass graph database to persist between executions and output files to be accessed on the host system.

The wordlists maintained in the Amass git repository are available in `/wordlists/` within the docker container. For example, to use `all.txt`:
The wordlists maintained in the Amass git repository are available in `/examples/wordlists/` within the docker container. For example, to use `all.txt`:

```bash
docker run -v ~/amass:/amass/ amass enum -brute -w /wordlists/all.txt -d example.com
Expand Down Expand Up @@ -67,7 +67,7 @@ go install ./...
At this point, the binary should be in *$GOPATH/bin*. Several wordlists for performing DNS name alterations and brute forcing can be found in the following directory:

```bash
ls $GOPATH/src/github.com/OWASP/Amass/wordlists/
ls $GOPATH/src/github.com/OWASP/Amass/examples/wordlists/
```

## Packages Maintained by the Amass Project
Expand All @@ -89,16 +89,6 @@ If your operating environment supports [Snap](https://docs.snapcraft.io/core/ins
sudo snap install amass
```

On **Kali**, follow these steps to install Snap and Amass + use AppArmor (for autoload):

```bash
sudo apt install snapd
sudo systemctl start snapd
sudo systemctl enable snapd
sudo systemctl start apparmor
sudo systemctl enable apparmor
```

Add the Snap bin directory to your PATH:

```bash
Expand Down Expand Up @@ -128,6 +118,13 @@ cd /usr/ports/dns/amass/ && make install clean
pkg install amass
```

### Kali Linux

```bash
apt-get update
apt-get install amass
```

## Nix or NixOS

```bash
Expand Down
Loading

0 comments on commit c0b7851

Please sign in to comment.