onionscan/main.go

62 lines
1.7 KiB
Go
Raw Normal View History

2016-04-10 02:04:22 +02:00
package main
import (
"flag"
"fmt"
"github.com/s-rah/onionscan/config"
"github.com/s-rah/onionscan/report"
2016-04-10 02:04:22 +02:00
"io/ioutil"
"log"
"os"
)
func main() {
flag.Usage = func() {
fmt.Printf("Usage of %s:\n", os.Args[0])
fmt.Printf(" onionscan [flags] hiddenservice\n")
flag.PrintDefaults()
}
torProxyAddress := flag.String("torProxyAddress", "127.0.0.1:9050", "the address of the tor proxy to use")
simpleReport := flag.Bool("simpleReport", true, "print out a simple report detailing what is wrong and how to fix it, true by default")
reportFile := flag.String("reportFile", "", "the file destination path for report file")
2016-04-10 02:04:22 +02:00
jsonReport := flag.Bool("jsonReport", false, "print out a json report providing a detailed report of the scan.")
verbose := flag.Bool("verbose", false, "print out a verbose log output of the scan")
2016-05-05 16:32:28 +02:00
directoryDepth := flag.Int("depth", 100, "depth of directory scan recursion (default: 100)")
2016-06-05 20:54:01 +02:00
fingerprint := flag.Bool("fingerprint", true, "whether to conduct a full scan, or just fingerprint possible ports")
2016-04-10 02:04:22 +02:00
flag.Parse()
if len(flag.Args()) != 1 {
flag.Usage()
os.Exit(1)
}
hiddenService := flag.Args()[0]
log.Printf("Starting Scan of %s\n", hiddenService)
log.Printf("This might take a few minutes..\n\n")
if !*verbose {
log.SetOutput(ioutil.Discard)
}
onionScan := new(OnionScan)
2016-06-05 20:54:01 +02:00
onionScan.Config = config.Configure(*torProxyAddress, *directoryDepth, *fingerprint)
scanReport, err := onionScan.Scan(hiddenService)
2016-04-10 02:04:22 +02:00
if *jsonReport {
report.GenerateJsonReport(*reportFile, scanReport)
2016-04-10 02:04:22 +02:00
}
if *simpleReport {
report.GenerateSimpleReport(*reportFile, scanReport)
2016-04-10 02:04:22 +02:00
}
2016-06-05 20:54:01 +02:00
if !*jsonReport && err != nil {
log.Fatalf("Error running scanner: %s", err)
}
2016-04-10 02:04:22 +02:00
}