-
Notifications
You must be signed in to change notification settings - Fork 8
/
url_scanner.py
executable file
·32 lines (26 loc) · 998 Bytes
/
url_scanner.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
"""
Title: profiler
Author: Mădălin Dogaru
Discord: techblade.
Date: 25-03-2023
Version: v0.1
License: GPLv3
Description: A Red Teaming tool focused on profiling the target.
"""
import os
import re
class URLScanner:
def __init__(self, folder_path):
self.folder_path = folder_path
def extract_urls(self, text):
return re.findall(r'http[s]?://(?:[a-zA-Z]|[0-9]|[$-_@.&+]|[!*\\(\\),]|(?:%[0-9a-fA-F][0-9a-fA-F]))+', text)
def scan_folder(self):
urls = []
for root, _, files in os.walk(self.folder_path):
for file in files:
file_path = os.path.join(root, file)
with open(file_path, 'r', encoding='utf-8', errors='ignore') as f:
content = f.read()
extracted_urls = self.extract_urls(content)
urls.extend(extracted_urls)
return list(set(urls)) # Here we convert the list of URLs to a set (which removes duplicates) and then back to a list