@@ -101,6 +101,9 @@ func (r *Runner) HTTPX() *httpx.HTTPX {
101101// picked based on try-fail but it seems to close to one it's used https://www.hackerfactor.com/blog/index.php?/archives/432-Looks-Like-It.html#c1992
102102var hammingDistanceThreshold int = 22
103103
104+ // regex for stripping ANSI codes
105+ var ansiRegex = regexp .MustCompile (`\x1b\[[0-9;]*m` )
106+
104107type pHashCluster struct {
105108 BasePHash uint64 `json:"base_phash,omitempty" csv:"base_phash"`
106109 Hashes []pHashUrl `json:"hashes,omitempty" csv:"hashes"`
@@ -1180,7 +1183,7 @@ func (r *Runner) RunEnumeration() {
11801183
11811184 //nolint:errcheck // this method needs a small refactor to reduce complexity
11821185 if plainFile != nil {
1183- plainFile .WriteString (resp .str + "\n " )
1186+ plainFile .WriteString (handleStripAnsiCharacters ( resp .str , r . options . NoColor ) + "\n " )
11841187 }
11851188
11861189 if len (r .options .ExcludeOutputFields ) > 0 {
@@ -1345,6 +1348,13 @@ func (r *Runner) RunEnumeration() {
13451348 }
13461349}
13471350
1351+ func handleStripAnsiCharacters (data string , skip bool ) string {
1352+ if skip {
1353+ return data
1354+ }
1355+ return stripANSI (data )
1356+ }
1357+
13481358func logFilteredErrorPage (fileName , url string ) {
13491359 dir := filepath .Dir (fileName )
13501360 if ! fileutil .FolderExists (dir ) {
@@ -2699,3 +2709,8 @@ func isWebSocket(resp *httpx.Response) bool {
26992709 }
27002710 return false
27012711}
2712+
2713+ // stripANSI removes ANSI color codes from a string using pre-compiled regex
2714+ func stripANSI (str string ) string {
2715+ return ansiRegex .ReplaceAllString (str , "" )
2716+ }
0 commit comments