-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.py
124 lines (105 loc) · 4.22 KB
/
main.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
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
import asyncio
from colorama import Fore, Style
from async_crawl4 import main as tor_main
from async_crawl_i2p import main as i2p_main
import os
import sys
from pathlib import Path
from tor_ip_utility import TorUtility
from analyse_data_cass import process_files
import time
import threading
from pyfiglet import Figlet
import platform
import warnings
warnings.filterwarnings("ignore")
def print_banner():
custom_fig = Figlet(font='slant') # You can choose a different font
banner_text = custom_fig.renderText('DarkSurf')
print(f"{Fore.GREEN}{banner_text}{Style.RESET_ALL}")
def display_system_info():
print(f"\n{Fore.CYAN}System Information:{Style.RESET_ALL}")
print(f" OS: {platform.system()} ")
print(f" Processor: {platform.processor()}")
print(f" Python Version: {platform.python_version()}")
print(f" Architecture: {platform.architecture()}")
def run_process_files_continuously():
while True:
process_files()
time.sleep(60)
BASE_URL = Path(__file__).parent
tor_file = str(BASE_URL / "tor.py")
i2p_file = str(BASE_URL / "i2p.py")
both_file = str(BASE_URL / "both.py")
tor_ip_utility_file = str(BASE_URL / "tor_ip_utility.py")
def open_new_terminal(command):
if sys.platform == "win32":
os.system(f'start cmd /k "{command}"')
elif sys.platform.startswith("linux"):
os.system(f'gnome-terminal -- {command}')
elif sys.platform == "darwin":
os.system(f'open -a Terminal.app {command}')
else:
NotImplementedError(f"Unsupported Operating System: {sys.platform}")
async def crawl_both():
tasks = [tor_main(), i2p_main()]
await asyncio.gather(*tasks)
def display_menu():
print("\nChoose an option:")
print(
f" {Fore.CYAN}[{Style.RESET_ALL}1{Fore.CYAN}]{Style.RESET_ALL} Start web crawling through Tor")
print(
f" {Fore.CYAN}[{Style.RESET_ALL}2{Fore.CYAN}]{Style.RESET_ALL} Start web crawling through I2P")
print(
f" {Fore.CYAN}[{Style.RESET_ALL}3{Fore.CYAN}]{Style.RESET_ALL} Start web crawling through both Tor and I2P")
print(
f" {Fore.CYAN}[{Style.RESET_ALL}4{Fore.CYAN}]{Style.RESET_ALL} Run Tor IP Utility")
print(
f" {Fore.CYAN}[{Style.RESET_ALL}5{Fore.CYAN}]{Style.RESET_ALL} Exit")
def main():
print_banner()
display_system_info()
while True:
try:
display_menu()
choice = input("Enter the number of your choice: ")
if choice == "1":
print(
f"\n{Fore.YELLOW}Starting web crawling through Tor...{Style.RESET_ALL}")
command = f"{sys.executable} {tor_file}"
open_new_terminal(command)
elif choice == "2":
print(
f"\n{Fore.YELLOW}Starting web crawling through I2P...{Style.RESET_ALL}")
command = f"{sys.executable} {i2p_file}"
open_new_terminal(command)
elif choice == "3":
print(
f"\n{Fore.YELLOW}Starting web crawling through both Tor and I2P...{Style.RESET_ALL}")
command = f"{sys.executable} {both_file}"
open_new_terminal(command)
elif choice == "4":
print(
f"\n{Fore.YELLOW}Running Tor IP Utility...{Style.RESET_ALL}")
tor_ip_utility = TorUtility(verbose=True)
tor_ip_utility.run()
elif choice == "5":
print(f"{Fore.YELLOW}Exiting...{Style.RESET_ALL}")
sys.exit(0)
else:
print(
f"\n{Fore.RED}Invalid choice. Please enter a number between 1 and 5.{Style.RESET_ALL}")
except KeyboardInterrupt:
print(f"{Fore.YELLOW}Exiting...{Style.RESET_ALL}")
sys.exit(0)
except Exception as e:
print(f"\n{Fore.RED}Error: {str(e)}{Style.RESET_ALL}")
if __name__ == "__main__":
process_files_thread = threading.Thread(
target=run_process_files_continuously, daemon=True)
process_files_thread.start()
tor_utility_instance = TorUtility(False)
auto_renew_ip_thread = threading.Thread(
target=tor_utility_instance.auto_renew_tor_ip, daemon=True)
auto_renew_ip_thread.start()
main()