Skip to content
This repository has been archived by the owner on Jan 13, 2023. It is now read-only.

Added Similarity and InputFile Options #205

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions core/options.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@ type Options struct {
Silent *bool
Debug *bool
Version *bool
Similarity *float64
InputFile *string
}

func ParseOptions() (Options, error) {
Expand All @@ -43,6 +45,8 @@ func ParseOptions() (Options, error) {
Silent: flag.Bool("silent", false, "Suppress all output except for errors"),
Debug: flag.Bool("debug", false, "Print debugging information"),
Version: flag.Bool("version", false, "Print current Aquatone version"),
Similarity: flag.Float64("similarity",0.80,"Cluster Similarity Float for Screenshots. Default 0.80"),
InputFile: flag.String("inputfile","","Input file to parse hosts (Nmap or Raw) rather than STDIN"),
}

flag.Parse()
Expand Down
20 changes: 17 additions & 3 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import (
"os"
"strings"
"time"
"io"

"github.com/google/uuid"
"github.com/michenriksen/aquatone/agents"
Expand Down Expand Up @@ -121,9 +122,22 @@ func main() {
agents.NewURLTechnologyFingerprinter().Register(sess)
agents.NewURLTakeoverDetector().Register(sess)

reader := bufio.NewReader(os.Stdin)
var targets []string
var reader io.Reader
if *sess.Options.InputFile != "" {
//Read from File
file, err := os.Open(*sess.Options.InputFile)
if err != nil {
sess.Out.Fatal("Unable to open input file: %s\n", *sess.Options.InputFile)
os.Exit(1)
}
defer file.Close()

reader = bufio.NewReader(file)
} else {
reader = bufio.NewReader(os.Stdin)
}

var targets []string
if *sess.Options.Nmap {
parser := parsers.NewNmapParser()
targets, err = parser.Parse(reader)
Expand Down Expand Up @@ -193,7 +207,7 @@ func main() {
addToCluster := true
for _, pageURL := range cluster {
page2 := sess.GetPage(pageURL)
if page2 != nil && core.GetSimilarity(page.PageStructure, page2.PageStructure) < 0.80 {
if page2 != nil && core.GetSimilarity(page.PageStructure, page2.PageStructure) < *sess.Options.Similarity {
addToCluster = false
break
}
Expand Down