@@ -1110,10 +1110,8 @@ func (r *Runner) RunEnumeration() {
11101110 // store responses or chain in directory
11111111 if resp .Err == nil {
11121112 URL , _ := urlutil .Parse (resp .URL )
1113- domainFile := resp .Method + ":" + URL .EscapedString ()
1114- hash := hashes .Sha1 ([]byte (domainFile ))
1115- domainResponseFile := fmt .Sprintf ("%s.txt" , hash )
1116- screenshotResponseFile := fmt .Sprintf ("%s.png" , hash )
1113+ domainResponseFile := fmt .Sprintf ("%s.txt" , resp .FileNameHash )
1114+ screenshotResponseFile := fmt .Sprintf ("%s.png" , resp .FileNameHash )
11171115 hostFilename := strings .ReplaceAll (URL .Host , ":" , "_" )
11181116 domainResponseBaseDir := filepath .Join (r .options .StoreResponseDir , "response" )
11191117 domainScreenshotBaseDir := filepath .Join (r .options .StoreResponseDir , "screenshot" )
@@ -2211,7 +2209,7 @@ retry:
22112209 domainResponseBaseDir := filepath .Join (scanopts .StoreResponseDirectory , "response" )
22122210 responseBaseDir := filepath .Join (domainResponseBaseDir , hostFilename )
22132211
2214- var responsePath string
2212+ var responsePath , fileNameHash string
22152213 // store response
22162214 if scanopts .StoreResponse || scanopts .StoreChain {
22172215 if r .options .OmitBody {
@@ -2233,12 +2231,11 @@ retry:
22332231 data = append (data , []byte (fullURL )... )
22342232 _ = fileutil .CreateFolder (responseBaseDir )
22352233
2236- finalPath := responsePath
2237- idx := 0
2238- for {
2239- targetPath := finalPath
2234+ basePath := strings . TrimSuffix ( responsePath , ".txt" )
2235+ var idx int
2236+ for idx = 0 ; ; idx ++ {
2237+ targetPath := responsePath
22402238 if idx > 0 {
2241- basePath := strings .TrimSuffix (responsePath , ".txt" )
22422239 targetPath = fmt .Sprintf ("%s_%d.txt" , basePath , idx )
22432240 }
22442241 f , err := os .OpenFile (targetPath , os .O_WRONLY | os .O_CREATE | os .O_EXCL , 0644 )
@@ -2254,7 +2251,12 @@ retry:
22542251 gologger .Error ().Msgf ("Failed to create file '%s': %s" , targetPath , err )
22552252 break
22562253 }
2257- idx ++
2254+ }
2255+
2256+ if idx == 0 {
2257+ fileNameHash = hash
2258+ } else {
2259+ fileNameHash = fmt .Sprintf ("%s_%d" , hash , idx )
22582260 }
22592261 }
22602262
@@ -2396,6 +2398,7 @@ retry:
23962398 RequestRaw : requestDump ,
23972399 Response : resp ,
23982400 FaviconData : faviconData ,
2401+ FileNameHash : fileNameHash ,
23992402 }
24002403 if resp .BodyDomains != nil {
24012404 result .Fqdns = resp .BodyDomains .Fqdns
0 commit comments