forked from 3kh0/echodown
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathuser_input.py
49 lines (41 loc) · 2.59 KB
/
user_input.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
#
# ███████╗░█████╗░██╗░░██╗░█████╗░ ██████╗░░█████╗░░██╗░░░░░░░██╗███╗░░██╗
# ██╔════╝██╔══██╗██║░░██║██╔══██╗ ██╔══██╗██╔══██╗░██║░░██╗░░██║████╗░██║
# █████╗░░██║░░╚═╝███████║██║░░██║ ██║░░██║██║░░██║░╚██╗████╗██╔╝██╔██╗██║
# ██╔══╝░░██║░░██╗██╔══██║██║░░██║ ██║░░██║██║░░██║░░████╔═████║░██║╚████║
# ███████╗╚█████╔╝██║░░██║╚█████╔╝ ██████╔╝╚█████╔╝░░╚██╔╝░╚██╔╝░██║░╚███║
# ╚══════╝░╚════╝░╚═╝░░╚═╝░╚════╝░ ╚═════╝░░╚════╝░░░░╚═╝░░░╚═╝░░╚═╝░░╚══╝
#
# https://github.com/3kh0/echodown
import re
from termcolor import colored
from pick import pick # https://github.com/wong2/pick
def get_ip_address():
print("Enter IP address:")
ip = input(colored("> ", "yellow"))
if not re.match(r"^(\d{1,3}\.){3}\d{1,3}$", ip):
print(colored("Error: Invalid IP address format at python userInput, promise rejected.", "red"))
print(colored("Exiting due to error, it was your fault :(", "red"))
exit("invalid input")
return ip
def get_protocol():
print("Select a protocol (TCP, UDP, or HTTP):")
protocol = input(colored("> ", "yellow"))
if protocol not in ['TCP', 'UDP','HTTP']:
print(colored("Error: Invalid protocol at python userInput, promise rejected.", "red"))
print(colored("Exiting due to error, it was your fault :(", "red"))
exit("invalid input")
return protocol
def get_thread_num():
print("Enter number of threads(default 16): ")
threads = input(colored("> ", "yellow"))
if threads == None:
threads = 16
else:
try:
threads = int(threads)
except:
print(colored("Error: Non-integer value at python userInput, failed to start threads.", "red"))
print(colored("Exiting due to error, it was your fault :(", "red"))
exit("invalid input")
return threads