-
Notifications
You must be signed in to change notification settings - Fork 0
/
counter_visit.py
executable file
·50 lines (41 loc) · 1.64 KB
/
counter_visit.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
#!/usr/bin/env python3
import sys
import re
import subprocess
# Debug
# from pdb import set_trace as st
# Define color codes
COLOR_RED = '\033[91m'
COLOR_GREEN = '\033[92m'
COLOR_ORANGE = '\033[93m'
COLOR_RESET = '\033[0m'
INPUT_FILE = sys.argv[1] if len(sys.argv) > 1 else 'report.nuclei.latest.txt'
REPORT = '/tmp/report.without_info.txt'
# Read the input file and filter lines not containing '[info]'
with open(INPUT_FILE, 'r', encoding='utf-8') as input_f, open(REPORT, 'w', encoding='utf-8') as report_f:
for line in input_f:
if '[info]' not in line:
report_f.write(line)
# Process each line in the report file
with open(REPORT, 'r', encoding='utf-8') as report_f:
for line in report_f:
line = line.strip()
try:
category = re.findall(r'\[(.*?)\]', line)[0].split(':')[0]
except:
continue
target = line.split()[3]
if target.startswith('http'):
target = target.split('/')[2]
# Execute the nuclei command
completed_process = subprocess.run(['nuclei', '-silent', '-id', category, '-u', target], capture_output=True, text=True)
nuclei_output = completed_process.stdout.strip()
# Remove bash color codes from nuclei_output
color_pattern = re.compile(r'\x1b\[[0-9;]+m')
nuclei_output = re.sub(color_pattern, '', nuclei_output)
if nuclei_output == line:
print(f'{COLOR_RED}NOT FIX: {nuclei_output}{COLOR_RESET}')
elif nuclei_output:
print(f'{COLOR_ORANGE}NOT FIX (DIFFERENT): {nuclei_output}{COLOR_RESET}')
else:
print(f'{COLOR_GREEN}FIX!: {line}{COLOR_RESET}')