@@ -2,7 +2,6 @@ package main
22
33import (
44"bufio"
5- "flag"
65"fmt"
76"net/http"
87"net/url"
@@ -11,6 +10,7 @@ import (
1110
1211"github.com/PuerkitoBio/goquery"
1312"github.com/logrusorgru/aurora"
13+ flag "github.com/spf13/pflag"
1414)
1515
1616type logger interface {
@@ -59,6 +59,7 @@ func main() {
5959completeArg := flag .Bool ("complete" , false , "Complete the url. e.g. append the domain to the path" )
6060verboseArg := flag .Bool ("verbose" , false , "Display info of what is going on" )
6161noColorsArg := flag .Bool ("nocolors" , false , "Enable or disable colors" )
62+ HeaderArg := flag .StringArrayP ("header" , "H" , nil , "Any HTTP headers(-H \" Authorization:Bearer token\" )" )
6263flag .Parse ()
6364
6465au = aurora .NewAurora (! * noColorsArg )
@@ -118,7 +119,7 @@ func main() {
118119var sourcesBak []string
119120var completedSuccessfully = true
120121output .Log ("[+] Getting sources from " + e )
121- sources , err := getScriptSrc (e )
122+ sources , err := getScriptSrc (e , * HeaderArg )
122123if err != nil {
123124output .Error (fmt .Sprintf ("[!] Couldn't get sources from %s" , e ), err )
124125}
@@ -186,11 +187,25 @@ func saveToFile(sources []string, path string) error {
186187return w .Flush ()
187188}
188189
189- func getScriptSrc (url string ) ([]string , error ) {
190+ func getScriptSrc (url string , headers [] string ) ([]string , error ) {
190191// Request the HTML page.
191- res , err := http .Get ( url )
192+ req , err := http .NewRequest ( "GET" , url , nil )
192193if err != nil {
193- return nil , err
194+ return []string {}, err
195+ }
196+
197+ for _ , d := range headers {
198+ values := strings .Split (d , ":" )
199+ if len (values ) == 2 {
200+ output .Log ("[+] New Header: " + values [0 ] + ": " + values [1 ])
201+ req .Header .Set (values [0 ], values [1 ])
202+ }
203+ }
204+
205+ client := new (http.Client )
206+ res , err := client .Do (req )
207+ if err != nil {
208+ return []string {}, err
194209}
195210defer res .Body .Close ()
196211if res .StatusCode != 200 {
0 commit comments