yellow.git


yellow

~ opinionated web scanning pipeline for pentesters in a hurry
git clone https://github.com/djnnvx/yellow.git
log | files | refs | archive | README | LICENSE

commit 051913a1d891f4755da967e94609ffd61b9bb458
parent c865412db7d09082f8d2366a5e057265018df520
Author: djnn <[email protected]>
Date: Tue, 3 Dec 2024 21:28:49 +0900

fix(osint): it almost works!

Diffstat:
Mcli/parser.go | 6++++++
Mosint/assetfinder.go | 4++--
Mosint/dnsx.go | 15+++++++++++----
Mosint/dorks.go | 4++--
Mosint/httpx.go | 4++--
Mosint/run.go | 35+++++++++++++++++++++++++++++------

6 files changed, 52 insertions(+), 16 deletions(-)

diff --git a/cli/parser.go b/cli/parser.go
@@ -38,6 +38,12 @@ func GetParser(opts *StandardOptions) *cobra.Command {
 			osintOpts.SetScanPath(opts.OutDirName)
 			osintOpts.SetProxy(opts.Proxy)
 			osintOpts.SetDryRun(opts.RunDry)
+			osintOpts.SetRateLimit(opts.RateLimit)
+
+			// if used create subcommand, put the results in scans
+			if helper.Exists(opts.OutDirName + "/scans/") {
+				osintOpts.SetScanPath(opts.OutDirName + "/scans/")
+			}
 
 			if opts.TargetFilePath == "" {
 				osintOpts.Run()
diff --git a/osint/assetfinder.go b/osint/assetfinder.go
@@ -26,7 +26,7 @@ type Assetfinder struct {
 }
 
 func (a *Assetfinder) Info(url string) {
-	fmt.Println("[+] Running Assetfinder on %s", url)
+	fmt.Println("[+] Running Assetfinder on ", url)
 }
 
 func (a *Assetfinder) Configure(c interface{}) {
@@ -94,5 +94,5 @@ func (a *Assetfinder) Run(url string) {
 		file.WriteString(n + string('\n'))
 	}
 
-	fmt.Printf("[OSINT %s] Assetfinder done.", url, a.outfile)
+	fmt.Printf("[OSINT %s] Assetfinder done.\n", url, a.outfile)
 }
diff --git a/osint/dnsx.go b/osint/dnsx.go
@@ -1,6 +1,8 @@
 package osint
 
 import (
+	"bytes"
+	"encoding/json"
 	"fmt"
 	"os"
 
@@ -13,7 +15,7 @@ type Dnsx struct {
 }
 
 func (d *Dnsx) Info(url string) {
-	fmt.Println("[+] Running dnsx on %s", url)
+	fmt.Println("[+] Running dnsx on ", url)
 }
 
 func (d *Dnsx) Configure(c interface{}) {
@@ -48,7 +50,12 @@ func (d *Dnsx) Run(domain string) {
 		fmt.Printf("err: %v\n", err)
 		return
 	}
-	fmt.Println(jsonStr)
+
+	var prettyJSON bytes.Buffer
+	error := json.Indent(&prettyJSON, []byte(jsonStr), "", "\t")
+	if error != nil {
+		panic(err)
+	}
 
 	fo, err := os.Create(d.outfile)
 	if err != nil {
@@ -60,9 +67,9 @@ func (d *Dnsx) Run(domain string) {
 		}
 	}()
 
-	if _, err := fo.Write([]byte(jsonStr)); err != nil {
+	if _, err := fo.Write(prettyJSON.Bytes()); err != nil {
 		panic(err)
 	}
 
-	fmt.Printf("[OSINT %s] Dnsx results are stored in %s", domain, d.outfile)
+	fmt.Printf("[OSINT %s] Dnsx results are stored in %s\n", domain, d.outfile)
 }
diff --git a/osint/dorks.go b/osint/dorks.go
@@ -12,7 +12,7 @@ type Dorks struct {
 }
 
 func (d *Dorks) Info(url string) {
-	fmt.Println("[+] Running dorks on %s", url)
+	fmt.Println("[+] Running dorks on ", url)
 }
 
 func (d *Dorks) Configure(c interface{}) {
@@ -32,5 +32,5 @@ func (d *Dorks) Run(domain string) {
 	}
 
 	dorks.Run(opts)
-	fmt.Printf("[OSINT %s] Dorks are stored in %s", domain, d.outfile)
+	fmt.Printf("[OSINT %s] Dorks are stored in %s\n", domain, d.outfile)
 }
diff --git a/osint/httpx.go b/osint/httpx.go
@@ -14,7 +14,7 @@ type Httpx struct {
 }
 
 func (h *Httpx) Info(url string) {
-	fmt.Println("[+] Running httpx on %s", url)
+	fmt.Println("[+] Running httpx on ", url)
 }
 
 func (h *Httpx) Configure(c interface{}) {
@@ -45,5 +45,5 @@ func (h *Httpx) Run(domain string) {
 	defer httpxRunner.Close()
 
 	httpxRunner.RunEnumeration()
-	fmt.Printf("[OSINT %s] httpx completed.", domain)
+	fmt.Printf("[OSINT %s] httpx completed.\n", domain)
 }
diff --git a/osint/run.go b/osint/run.go
@@ -10,10 +10,15 @@ import (
 )
 
 type OsintOpts struct {
-	domain   string
-	scanPath string
-	proxy    string
-	dryRun   bool
+	domain    string
+	scanPath  string
+	proxy     string
+	dryRun    bool
+	rateLimit int32
+}
+
+func (opts *OsintOpts) SetRateLimit(data int32) {
+	opts.rateLimit = data
 }
 
 func (opts *OsintOpts) SetDomain(domain string) {
@@ -87,6 +92,7 @@ func (opts OsintOpts) runDnsx() {
 
 	dnsxOutfile := fmt.Sprintf("%s/dnsx_%s.json", opts.scanPath, opts.domain)
 	dnsxCfg["outfile"] = dnsxOutfile
+	dnsxCfg["proxy"] = opts.proxy
 
 	dnsx.Configure(dnsxCfg)
 	dnsx.Info(opts.domain)
@@ -96,8 +102,23 @@ func (opts OsintOpts) runDnsx() {
 	}
 }
 
-func (opts OsintOpts) runHttpx() {
+func (opts OsintOpts) runHttpx(input string) {
+	httpx := Httpx{}
+	httpxCfg := make(map[string]interface{})
+
+	httpxOutdir := fmt.Sprintf("%s/httpx-%s", opts.scanPath, opts.domain)
+
+	httpxCfg["OutDirPath"] = httpxOutdir
+	httpxCfg["Proxy"] = opts.proxy
+	httpxCfg["RateLimit"] = opts.rateLimit
+	httpxCfg["InputFile"] = input
 
+	httpx.Configure(httpxCfg)
+	httpx.Info(opts.domain)
+
+	if !opts.dryRun {
+		httpx.Run(opts.domain)
+	}
 }
 
 func (opts OsintOpts) Run() {
@@ -123,6 +144,8 @@ func (opts OsintOpts) Run() {
 			panic(err)
 		}
 
+		/* FIXME(djnn): parsing from dnsx is fucked, need to fix it tomorrow */
+
 		/* check if valid IP address / domain & if it's already in the list */
 		lines := strings.Split(strings.ReplaceAll(string(newDomains), "\r\n", "\n"), "\n")
 		for _, domain := range lines {
@@ -153,6 +176,6 @@ func (opts OsintOpts) Run() {
 
 	fmt.Printf("[OSINT %s] Registered %v IP addresses and assets.\n", opts.domain, len(domains))
 
-	opts.runHttpx()
+	opts.runHttpx(uniqueOutfile)
 	fmt.Printf("[OSINT %s] done.\n", opts.domain)
 }