@@ -179,7 +179,7 @@ func (c *Crawler) fetchAndParseURLs(isHttps bool, domain string, urlString strin
179179 Transport : lib .HttpClientTransportSettings ,
180180 }
181181 urlOnly := parsedURL .Scheme + "://" + parsedURL .Host + parsedURL .Path
182- helper .InfoPrintln ("[-] Fetching url: " , urlOnly )
182+ helper .VerbosePrintln ("[-] Fetching url: " , urlOnly )
183183 // Send a GET request to the website
184184 req , err := http .NewRequest ("GET" , urlOnly , nil )
185185 if err != nil {
@@ -276,17 +276,7 @@ func (c *Crawler) diffDirectories(domain, dir1, dir2 string) error {
276276
277277 pathInDir2 := filepath .Join (dir2 , relPath )
278278
279- // Check if file exists in the second directory
280- if _ , err := os .Stat (pathInDir2 ); os .IsNotExist (err ) {
281- url := domain + "/" + relPath
282- if strings .HasSuffix (url , "index" ) {
283- url = url [:len (url )- 6 ] // Remove "/index"
284- }
285- helper .ResultPrintf ("[!] URL %s [%s] does not exist in %s\n " , url , relPath , dir2 )
286- return nil
287- }
288-
289- // Compare file contents
279+ // Read and pretty-print the contents
290280 content1 , err := os .ReadFile (path )
291281 if err != nil {
292282 return err
@@ -297,6 +287,45 @@ func (c *Crawler) diffDirectories(domain, dir1, dir2 string) error {
297287 return err
298288 }
299289
290+ // Check if file exists in the second directory
291+ if _ , err := os .Stat (pathInDir2 ); os .IsNotExist (err ) {
292+ url := domain + "/" + relPath
293+ if strings .HasSuffix (url , "index" ) {
294+ url = url [:len (url )- 6 ] // Remove "/index"
295+ }
296+ helper .ResultPrintf ("[!] URL %s [%s] does not exist in %s\n " , url , relPath , dir2 )
297+
298+ // Create directories and write the file
299+ filePath := filepath .Join (c .outputDir , domain + ".diff" , relPath )
300+ dirPath := filepath .Dir (filePath )
301+ if err := os .MkdirAll (dirPath , 0755 ); err != nil {
302+ return err
303+ }
304+ file , err := os .Create (filePath )
305+ if err != nil {
306+ return err
307+ }
308+ defer file .Close ()
309+
310+ // Secret scanning
311+ stringContent := make ([]string , 0 )
312+ for _ , line := range strings .Split (contentStr1 , "\n " ) {
313+ fmt .Fprintf (file , "%s\n " , line )
314+ stringContent = append (stringContent , line )
315+ }
316+ matchedFiles , err := localscan .StringArrayScanning (stringContent , path )
317+ if err != nil {
318+ helper .ErrorPrintln (err )
319+ } else {
320+ for _ , matchedFile := range matchedFiles {
321+ helper .CustomizePrintln (matchedFile )
322+ }
323+ }
324+
325+ return nil
326+ }
327+
328+ // Read and pretty-print the contents
300329 content2 , err := os .ReadFile (pathInDir2 )
301330 if err != nil {
302331 return err
@@ -307,6 +336,7 @@ func (c *Crawler) diffDirectories(domain, dir1, dir2 string) error {
307336 return err
308337 }
309338
339+ // Compare file contents
310340 if contentStr1 != contentStr2 {
311341 helper .InfoPrintf ("[+] File %s differs between directories\n " , relPath )
312342
0 commit comments