Skip to content

Commit dd97d3d

Browse files
committed
Adding --placeholder
1 parent 6cbc405 commit dd97d3d

1 file changed

Lines changed: 16 additions & 12 deletions

File tree

paramspider/main.py

Lines changed: 16 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ def clean_url(url):
5555

5656
return parsed_url.geturl()
5757

58-
def clean_urls(urls, extensions):
58+
def clean_urls(urls, extensions, placeholder):
5959
"""
6060
Clean a list of URLs by removing unnecessary parameters and query strings.
6161
@@ -72,13 +72,13 @@ def clean_urls(urls, extensions):
7272
if not has_extension(cleaned_url, extensions):
7373
parsed_url = urlparse(cleaned_url)
7474
query_params = parse_qs(parsed_url.query)
75-
cleaned_params = {key: "FUZZ" for key in query_params}
75+
cleaned_params = {key: placeholder for key in query_params}
7676
cleaned_query = urlencode(cleaned_params, doseq=True)
7777
cleaned_url = parsed_url._replace(query=cleaned_query).geturl()
7878
cleaned_urls.add(cleaned_url)
7979
return list(cleaned_urls)
8080

81-
def fetch_and_clean_urls(domain, extensions, stream_output,proxy):
81+
def fetch_and_clean_urls(domain, extensions, stream_output,proxy, placeholder):
8282
"""
8383
Fetch and clean URLs related to a specific domain from the Wayback Machine.
8484
@@ -97,20 +97,23 @@ def fetch_and_clean_urls(domain, extensions, stream_output,proxy):
9797

9898
logging.info(f"{Fore.YELLOW}[INFO]{Style.RESET_ALL} Found {Fore.GREEN + str(len(urls)) + Style.RESET_ALL} URLs for {Fore.CYAN + domain + Style.RESET_ALL}")
9999

100-
cleaned_urls = clean_urls(urls, extensions)
100+
cleaned_urls = clean_urls(urls, extensions, placeholder)
101101
logging.info(f"{Fore.YELLOW}[INFO]{Style.RESET_ALL} Cleaning URLs for {Fore.CYAN + domain + Style.RESET_ALL}")
102102
logging.info(f"{Fore.YELLOW}[INFO]{Style.RESET_ALL} Found {Fore.GREEN + str(len(cleaned_urls)) + Style.RESET_ALL} URLs after cleaning")
103+
logging.info(f"{Fore.YELLOW}[INFO]{Style.RESET_ALL} Extracting URLs with parameters")
103104

104105
results_dir = "results"
105106
if not os.path.exists(results_dir):
106107
os.makedirs(results_dir)
107-
108+
108109
result_file = os.path.join(results_dir, f"{domain}.txt")
110+
109111
with open(result_file, "w") as f:
110112
for url in cleaned_urls:
111-
f.write(url + "\n")
112-
if stream_output:
113-
print(url)
113+
if "?" in url:
114+
f.write(url + "\n")
115+
if stream_output:
116+
print(url)
114117

115118
logging.info(f"{Fore.YELLOW}[INFO]{Style.RESET_ALL} Saved cleaned URLs to {Fore.CYAN + result_file + Style.RESET_ALL}")
116119

@@ -134,7 +137,8 @@ def main():
134137
parser.add_argument("-d", "--domain", help="Domain name to fetch related URLs for.")
135138
parser.add_argument("-l", "--list", help="File containing a list of domain names.")
136139
parser.add_argument("-s", "--stream", action="store_true", help="Stream URLs on the terminal.")
137-
parser.add_argument("-p", "--proxy", help="Set the proxy address for web requests.",default=None)
140+
parser.add_argument("--proxy", help="Set the proxy address for web requests.",default=None)
141+
parser.add_argument("-p", "--placeholder", help="placeholder for parameter values", default="FUZZ")
138142
args = parser.parse_args()
139143

140144
if not args.domain and not args.list:
@@ -154,11 +158,11 @@ def main():
154158
extensions = HARDCODED_EXTENSIONS
155159

156160
if args.domain:
157-
fetch_and_clean_urls(domain, extensions, args.stream,args.proxy)
161+
fetch_and_clean_urls(domain, extensions, args.stream, args.proxy, args.placeholder)
158162

159163
if args.list:
160164
for domain in domains:
161-
fetch_and_clean_urls(domain, extensions, args.stream,args.proxy)
165+
fetch_and_clean_urls(domain, extensions, args.stream,args.proxy, args.placeholder)
162166

163167
if __name__ == "__main__":
164-
main()
168+
main()

0 commit comments

Comments
 (0)