-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathui.py
149 lines (125 loc) · 4.51 KB
/
ui.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
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
import locale
import re
import platform
import os
import sys
import termcolor
import time
isNotWindows = platform.system() != "Windows"
if isNotWindows:
from dialog import Dialog
os.system("clear")
else:
os.system("cls")
def resource_path(relative_path):
try:
base_path = sys._MEIPASS
except Exception:
base_path = os.path.abspath(".")
return os.path.join(base_path, relative_path)
class Ui:
translation = {
'enterUrl': "Please specify target address (http://example.com)",
'enterPort': 'Please specify target server port (80)',
'exampleWebsite': 'https://example.com',
'checkUrl': "Please check address and try again",
'checkPort': 'Please check port and try again',
'bye': 'Bye!',
'introText': """
Hello,
You can use this script for making a DDoS (or Strongly, DrDoS) attack on a server.
\"we're irresponsible about this script\"
"""
}
def __init__(self):
self.file_name = resource_path("License.txt")
locale.setlocale(locale.LC_ALL, '')
if isNotWindows:
self.d = Dialog(dialog="dialog")
self.d.set_background_title("DrDoSer Script")
self.siteUrl = self.translation['exampleWebsite']
self.sitePort = 80
self.intro()
def check_width(self, text=""):
if not text:
with open(self.file_name, "r") as base:
read_lines = base.readlines()
len_list = []
for line in read_lines:
len_list.append(len(line))
len_list.sort()
width = len_list[-1]
return width
else:
return len(text)
def intro(self):
if isNotWindows:
dialog = self.d.msgbox(text=self.translation['introText'])
else:
print(termcolor.colored(self.translation['introText'], color="green"))
self.agreement()
def agreement(self):
if isNotWindows:
dialog = self.d.textbox(self.file_name, height=None, width=self.check_width())
else:
print(termcolor.colored("Under GNU GENERAL PUBLIC LICENSE v2", color="red"))
i = input("enter \"LICENSE\" for reading license" + ":\t")
if i == "LICENSE":
with open(resource_path("License.txt")) as License:
print(termcolor.colored(License.read(), color="yellow"))
License.close()
self.inputUrl()
def inputUrl(self):
dialog = [""]
if isNotWindows:
dialog = self.d.inputbox(init=self.translation["exampleWebsite"], text=self.translation['enterUrl'])
text = dialog[1]
else:
text = input(self.translation['enterUrl'] + ":\t")
if re.findall(
r"(?i)\b((?:https?://|www\d{0,3}[.]|[a-z0-9.\-]+[.][a-z]{2,4}/)(?:[^\s()<>]+|\(([^\s()<>]+"
r"|(\([^\s()<>]+\)))*\))+(?:\(([^\s()<>]+|(\([^\s()<>]+\)))*\)|[^\s`!()\[\]{};:'\".,<>?«»“”‘’]))",
str(text)):
self.siteUrl = text
self.inputPort()
elif dialog[0] == "cancel":
self.error(self.translation['bye'])
else:
self.error(self.translation['checkUrl'])
def inputPort(self):
dialog = [""]
if isNotWindows:
dialog = self.d.inputbox(init="80", text=self.translation['enterPort'])
text = dialog[1]
else:
text = input(self.translation['enterPort'] + ":\t")
if re.findall(r"^[-+]?[0-9]+$", str(text)):
self.sitePort = text
self.DDoS()
elif dialog[0] == "cancel":
self.error(self.translation['bye'])
else:
self.error(self.translation['checkPort'])
def error(self, text):
if isNotWindows:
dialog = self.d.msgbox(text, width=self.check_width(text) + 10)
print(termcolor.colored(text, color="red"))
if dialog:
self.__exit__()
def DDoS(self):
self.goOut()
os.environ['port'] = str(self.sitePort)
os.environ['url'] = self.siteUrl
print(termcolor.colored("starting DDoS...", color='green'))
time.sleep(2)
import DDoS
def goOut(self):
if platform.system() == "Windows":
os.system("cls")
else:
os.system("clear")
def __exit__(self):
self.goOut()
sys.exit(1)
if __name__ == "__main__":
raise Exception('RunError\n' + termcolor.colored('Please run main.py!', 'red'))