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" )
5759outputFileArg  :=  flag .String ("output" , "" , "Output file to save the results to" )
5860inputFileArg  :=  flag .String ("input" , "" , "Input file with urls" )
5961resolveArg  :=  flag .Bool ("resolve" , false , "Output only existing files" )
@@ -62,6 +64,7 @@ func main() {
6264noColorsArg  :=  flag .Bool ("nocolors" , false , "Enable or disable colors" )
6365HeaderArg  :=  flag .StringArrayP ("header" , "H" , nil , "Any HTTP headers(-H \" Authorization:Bearer token\" )" )
6466insecureArg  :=  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" )
6568flag .Parse ()
6669
6770au  =  aurora .NewAurora (! * noColorsArg )
@@ -121,7 +124,7 @@ func main() {
121124var  sourcesBak  []string 
122125var  completedSuccessfully  =  true 
123126output .Log ("[+] Getting sources from "  +  e )
124- sources , err  :=  getScriptSrc (e , * HeaderArg , * insecureArg )
127+ sources , err  :=  getScriptSrc (e , * methodArg ,  * HeaderArg , * insecureArg ,  * timeoutArg )
125128if  err  !=  nil  {
126129output .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  {
179181file , err  :=  os .Create (path )
180182if  err  !=  nil  {
@@ -189,9 +191,9 @@ func saveToFile(sources []string, path string) error {
189191return  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 )
195197if  err  !=  nil  {
196198return  []string {}, err 
197199}
@@ -205,19 +207,15 @@ func getScriptSrc(url string, headers []string, insecure bool) ([]string, error)
205207}
206208
207209tr  :=  & 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
211214var  client  =  & http.Client {
215+ Timeout : time .Duration (time .Duration (timeout ) *  time .Second ),
212216Transport : tr ,
213217}
214218
215- if  insecure  {
216- client .Transport  =  & http.Transport {
217- TLSClientConfig : & tls.Config {InsecureSkipVerify : true },
218- }
219- }
220- 
221219res , err  :=  client .Do (req )
222220if  err  !=  nil  {
223221return  []string {}, err 
0 commit comments