88 "net/url"
99 "os"
1010 "strings"
11+ "time"
1112
1213 "github.com/PuerkitoBio/goquery"
1314 "github.com/logrusorgru/aurora"
@@ -53,7 +54,8 @@ var output logger
5354var au aurora.Aurora
5455
5556func main () {
56- urlArg := flag .String ("url" , "U" , "The url to get the javascript sources from" )
57+ urlArg := flag .String ("url" , "" , "The url to get the javascript sources from" )
58+ methodArg := flag .String ("method" , "GET" , "The request method. e.g. GET or POST" )
5759 outputFileArg := flag .String ("output" , "" , "Output file to save the results to" )
5860 inputFileArg := flag .String ("input" , "" , "Input file with urls" )
5961 resolveArg := flag .Bool ("resolve" , false , "Output only existing files" )
@@ -62,6 +64,7 @@ func main() {
6264 noColorsArg := flag .Bool ("nocolors" , false , "Enable or disable colors" )
6365 HeaderArg := flag .StringArrayP ("header" , "H" , nil , "Any HTTP headers(-H \" Authorization:Bearer token\" )" )
6466 insecureArg := flag .Bool ("insecure" , false , "Check the SSL security checks. Use when the certificate is expired or invalid" )
67+ timeoutArg := flag .Int ("timeout" , 10 , "Max timeout for the requests" )
6568 flag .Parse ()
6669
6770 au = aurora .NewAurora (! * noColorsArg )
@@ -121,7 +124,7 @@ func main() {
121124 var sourcesBak []string
122125 var completedSuccessfully = true
123126 output .Log ("[+] Getting sources from " + e )
124- sources , err := getScriptSrc (e , * HeaderArg , * insecureArg )
127+ sources , err := getScriptSrc (e , * methodArg , * HeaderArg , * insecureArg , * timeoutArg )
125128 if err != nil {
126129 output .Error (fmt .Sprintf ("[!] Couldn't get sources from %s" , e ), err )
127130 }
@@ -174,7 +177,6 @@ func main() {
174177
175178}
176179
177- // ToDO: Use channel instead of slide, and use io.Writer instead of file path
178180func saveToFile (sources []string , path string ) error {
179181 file , err := os .Create (path )
180182 if err != nil {
@@ -189,9 +191,9 @@ func saveToFile(sources []string, path string) error {
189191 return w .Flush ()
190192}
191193
192- func getScriptSrc (url string , headers []string , insecure bool ) ([]string , error ) {
194+ func getScriptSrc (url string , method string , headers []string , insecure bool , timeout int ) ([]string , error ) {
193195 // Request the HTML page.
194- req , err := http .NewRequest ("GET" , url , nil )
196+ req , err := http .NewRequest (method , url , nil )
195197 if err != nil {
196198 return []string {}, err
197199 }
@@ -205,19 +207,15 @@ func getScriptSrc(url string, headers []string, insecure bool) ([]string, error)
205207 }
206208
207209 tr := & http.Transport {
208- TLSClientConfig : & tls.Config {InsecureSkipVerify : false },
210+ ResponseHeaderTimeout : time .Duration (time .Duration (timeout ) * time .Second ),
211+ TLSClientConfig : & tls.Config {InsecureSkipVerify : insecure },
209212 }
210213
211214 var client = & http.Client {
215+ Timeout : time .Duration (time .Duration (timeout ) * time .Second ),
212216 Transport : tr ,
213217 }
214218
215- if insecure {
216- client .Transport = & http.Transport {
217- TLSClientConfig : & tls.Config {InsecureSkipVerify : true },
218- }
219- }
220-
221219 res , err := client .Do (req )
222220 if err != nil {
223221 return []string {}, err
0 commit comments