-
Notifications
You must be signed in to change notification settings - Fork 23
/
getParams.py
61 lines (49 loc) · 2 KB
/
getParams.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
51
52
53
54
55
56
57
58
59
60
61
import re
import json
from collections import Counter
def is_custom_alnum(s):
return all(c.isalnum() or c in ['_', '-'] for c in s)
def find_patterns_in_file(file_path):
# Opening file
with open(file_path, 'r') as file:
text = file.read()
# Pattern 1: In a bullet/dashed list. This looks for lines starting with "- " or "* ".
pattern1 = re.compile(r"^(?:\-\s|\*\s)(.*)", re.MULTILINE)
matches_pattern1 = re.findall(pattern1, text)
# Pattern 2: Inside double quotes, single quotes, or `.
pattern2 = re.compile(r"[\"'`](.*?)[\"'`]", re.MULTILINE)
matches_pattern2 = re.findall(pattern2, text)
# Pattern 3: Inside two / symbols.
pattern3 = re.compile(r"/(.*?)/", re.MULTILINE)
matches_pattern3 = re.findall(pattern3, text)
# Combine the three lists into one
combined = matches_pattern1 + matches_pattern2 + matches_pattern3
# Create a new list that only contains elements without a space, not containing '████████', and is alphanumeric + '_' + '-'
filtered_list = [x for x in combined if ' ' not in x and '█' not in x and is_custom_alnum(x)]
# Count the occurrences of each element in the filtered list
count_dict = Counter(filtered_list)
# Remove the key if it's empty
count_dict.pop('', None)
return count_dict
def getParams(file_path, vuln_type):
result = find_patterns_in_file(file_path)
# Sort the dictionary by its integer values
sorted_dict = dict(sorted(result.items(), key=lambda x: x[1], reverse=True))
# Save the dictionary to a JSON file
with open(f'output/{vuln_type}.json', 'w') as f:
json.dump(sorted_dict, f, indent=4)
f.close()
# XSS
getParams("test/xss-file.txt", "xss")
# SSTI
getParams("test/ssti-file.txt", "ssti")
# SSRF
getParams("test/ssrf-file.txt", "ssrf")
# IDOR
getParams("test/idor-file.txt", "idor")
# FILEINC
getParams("test/fileinc-file.txt", "fileinc")
# SQLI
getParams("test/sqli-file.txt", "sqli")
# REDIRECT
getParams("test/redirect-file.txt", "redirect")