options.py 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208
  1. #!/usr/bin/env python
  2. # -*- coding: utf-8 -*-"
  3. # vim: set expandtab tabstop=4 shiftwidth=4:
  4. """
  5. $Id$
  6. This file is part of the xsser project, https://xsser.03c8.net
  7. Copyright (c) 2011/2018 psy <epsylon@riseup.net>
  8. xsser is free software; you can redistribute it and/or modify it under
  9. the terms of the GNU General Public License as published by the Free
  10. Software Foundation version 3 of the License.
  11. xsser is distributed in the hope that it will be useful, but WITHOUT ANY
  12. WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
  13. FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
  14. details.
  15. You should have received a copy of the GNU General Public License along
  16. with xsser; if not, write to the Free Software Foundation, Inc., 51
  17. Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
  18. """
  19. import optparse
  20. import core.fuzzing.vectors
  21. import core.fuzzing.DCP
  22. import core.fuzzing.DOM
  23. import core.fuzzing.HTTPsr
  24. class XSSerOptions(optparse.OptionParser):
  25. def __init__(self, *args):
  26. optparse.OptionParser.__init__(self,
  27. description='Cross Site "Scripter" is an automatic -framework- to detect, exploit and\nreport XSS vulnerabilities in web-based applications.',
  28. prog='XSSer.py',
  29. version='\nXSSer v1.7b: "ZiKA-47 Swarm!" - 2011/2018 - (GPLv3.0) -> by psy\n',
  30. usage= '\n\nxsser [OPTIONS] [--all <url> |-u <url> |-i <file> |-d <dork> (options)|-l ] [-g <get> |-p <post> |-c <crawl> (options)]\n[Request(s)] [Checker(s)] [Vector(s)] [Anti-antiXSS/IDS] [Bypasser(s)] [Technique(s)] [Final Injection(s)] [Reporting] {Miscellaneous}')
  31. self.set_defaults(verbose=False, threads=5, retries=1, delay=0, timeout=30,
  32. silent=False)
  33. self.disable_interspersed_args()
  34. self.vectors_fuzz = len(core.fuzzing.vectors.vectors)
  35. self.vectors_dcp = len(core.fuzzing.DCP.DCPvectors)
  36. self.vectors_dom = len(core.fuzzing.DOM.DOMvectors)
  37. self.vectors_httpsr = len(core.fuzzing.HTTPsr.HTTPrs_vectors)
  38. self.total_vectors = str(self.vectors_fuzz+self.vectors_dcp+self.vectors_dom+self.vectors_httpsr)
  39. self.add_option("-s", "--statistics", action="store_true", dest="statistics", help="show advanced statistics output results")
  40. self.add_option("-v", "--verbose", action="store_true", dest="verbose", help="active verbose mode output results")
  41. self.add_option("--gtk", action="store_true", dest="xsser_gtk", help="launch XSSer GTK Interface")
  42. #self.add_option("--swarm", action="store_true", dest="xsser_web", help="launch XSSer Swarm daemon(s) + Web-Shell")
  43. self.add_option("--wizard", action="store_true", dest="wizard", help="start Wizard Helper!")
  44. group1 = optparse.OptionGroup(self, "*Special Features*",
  45. "You can set Vector(s) and Bypasser(s) to build complex scripts for XSS code embedded. XST allows you to discover if target is vulnerable to 'Cross Site Tracing' [CAPEC-107]:")
  46. group1.add_option("--imx", action="store", dest="imx", help="IMX - Create an image with XSS (--imx image.png)")
  47. group1.add_option("--fla", action="store", dest="flash", help="FLA - Create a flash movie with XSS (--fla movie.swf)")
  48. group1.add_option("--xst", action="store", dest="xst", help="XST - Cross Site Tracing (--xst http(s)://host.com)")
  49. self.add_option_group(group1)
  50. group2 = optparse.OptionGroup(self, "*Select Target(s)*",
  51. "At least one of these options must to be specified to set the source to get target(s) urls from:")
  52. group2.add_option("--all", action="store", dest="target", help="Automatically audit an entire target")
  53. group2.add_option("-u", "--url", action="store", dest="url", help="Enter target to audit")
  54. group2.add_option("-i", action="store", dest="readfile", help="Read target(s) urls from file")
  55. group2.add_option("-d", action="store", dest="dork", help="Search target(s) using a query (ex: 'news.php?id=')")
  56. group2.add_option("-l", action="store_true", dest="dork_file", help="Search from a list of 'dorks'")
  57. group2.add_option("--De", action="store", dest="dork_engine", help="Use this search engine (default: yahoo)")
  58. group2.add_option("--Da", action="store_true", dest="dork_mass", help="Search massively using all search engines")
  59. self.add_option_group(group2)
  60. group3 = optparse.OptionGroup(self, "*Select type of HTTP/HTTPS Connection(s)*",
  61. "These options can be used to specify which parameter(s) we want to use as payload(s). Set 'XSS' as keyword on the place(s) that you want to inject:")
  62. group3.add_option("-g", action="store", dest="getdata", help="Send payload using GET (ex: '/menu.php?id=3&q=XSS')")
  63. group3.add_option("-p", action="store", dest="postdata", help="Send payload using POST (ex: 'foo=1&bar=XSS')")
  64. group3.add_option("-c", action="store", dest="crawling", help="Number of urls to crawl on target(s): 1-99999")
  65. group3.add_option("--Cw", action="store", dest="crawler_width", help="Deeping level of crawler: 1-5 (default 3)")
  66. group3.add_option("--Cl", action="store_true", dest="crawler_local", help="Crawl only local target(s) urls (default TRUE)")
  67. self.add_option_group(group3)
  68. group4 = optparse.OptionGroup(self, "*Configure Request(s)*",
  69. "These options can be used to specify how to connect to the target(s) payload(s). You can choose multiple:")
  70. group4.add_option("--cookie", action="store", dest="cookie", help="Change your HTTP Cookie header")
  71. group4.add_option("--drop-cookie", action="store_true", dest="dropcookie", help="Ignore Set-Cookie header from response")
  72. group4.add_option("--user-agent", action="store", dest="agent", help="Change your HTTP User-Agent header (default SPOOFED)")
  73. group4.add_option("--referer", action="store", dest="referer", help="Use another HTTP Referer header (default NONE)")
  74. group4.add_option("--xforw", action="store_true", dest="xforw", help="Set your HTTP X-Forwarded-For with random IP values")
  75. group4.add_option("--xclient", action="store_true", dest="xclient", help="Set your HTTP X-Client-IP with random IP values")
  76. group4.add_option("--headers", action="store", dest="headers", help="Extra HTTP headers newline separated")
  77. group4.add_option("--auth-type", action="store", dest="atype", help="HTTP Authentication type (Basic, Digest, GSS or NTLM)")
  78. group4.add_option("--auth-cred", action="store", dest="acred", help="HTTP Authentication credentials (name:password)")
  79. #group4.add_option("--auth-cert", action="store", dest="acert", help="HTTP Authentication certificate (key_file,cert_file)")
  80. group4.add_option("--proxy", action="store", dest="proxy", help="Use proxy server (tor: http://localhost:8118)")
  81. group4.add_option("--ignore-proxy", action="store_true", dest="ignoreproxy", help="Ignore system default HTTP proxy")
  82. group4.add_option("--timeout", action="store", dest="timeout", type="int", help="Select your timeout (default 30)")
  83. group4.add_option("--retries", action="store", dest="retries", type="int", help="Retries when the connection timeouts (default 1)")
  84. group4.add_option("--threads", action="store", dest="threads", type="int", help="Maximum number of concurrent HTTP requests (default 5)")
  85. group4.add_option("--delay", action="store", dest="delay", type="int", help="Delay in seconds between each HTTP request (default 0)")
  86. group4.add_option("--tcp-nodelay", action="store_true", dest="tcp_nodelay", help="Use the TCP_NODELAY option")
  87. group4.add_option("--follow-redirects", action="store_true", dest="followred", help="Follow server redirection responses (302)")
  88. group4.add_option("--follow-limit", action="store", dest="fli", type="int", help="Set limit for redirection requests (default 50)")
  89. self.add_option_group(group4)
  90. group5 = optparse.OptionGroup(self, "*Checker Systems*",
  91. "These options are useful to know if your target is using filters against XSS attacks:")
  92. group5.add_option("--hash", action="store_true", dest="hash", help="send a hash to check if target is repeating content")
  93. group5.add_option("--heuristic", action="store_true", dest="heuristic", help="discover parameters filtered by using heuristics")
  94. group5.add_option("--discode", action="store", dest="discode", help="set code on reply to discard an injection")
  95. group5.add_option("--checkaturl", action="store", dest="alt", help="check reply using: alternative url -> Blind XSS")
  96. group5.add_option("--checkmethod", action="store", dest="altm", help="check reply using: GET or POST (default: GET)")
  97. group5.add_option("--checkatdata", action="store", dest="ald", help="check reply using: alternative payload")
  98. group5.add_option("--reverse-check", action="store_true", dest="reversecheck", help="establish a reverse connection from target to XSSer to certify that is 100% vulnerable (recommended!)")
  99. self.add_option_group(group5)
  100. group6 = optparse.OptionGroup(self, "*Select Vector(s)*",
  101. "These options can be used to specify injection(s) code. Important if you don't want to inject a common XSS vector used by default. Choose only one option:")
  102. group6.add_option("--payload", action="store", dest="script", help="OWN - Inject your own code")
  103. group6.add_option("--auto", action="store_true", dest="fuzz", help="AUTO - Inject a list of vectors provided by XSSer")
  104. self.add_option_group(group6)
  105. group13 = optparse.OptionGroup(self, "*Anti-antiXSS Firewall rules*",
  106. "These options can be used to try to bypass specific WAF/IDS products. Choose only if required:")
  107. group13.add_option("--Phpids0.6.5", action="store_true", dest="phpids065", help="PHPIDS (0.6.5) [ALL]")
  108. group13.add_option("--Phpids0.7", action="store_true", dest="phpids070", help="PHPIDS (0.7) [ALL]")
  109. group13.add_option("--Imperva", action="store_true", dest="imperva", help="Imperva Incapsula [ALL]")
  110. group13.add_option("--Webknight", action="store_true", dest="webknight", help="WebKnight (4.1) [Chrome]")
  111. group13.add_option("--F5bigip", action="store_true", dest="f5bigip", help="F5 Big IP [Chrome + FF + Opera]")
  112. group13.add_option("--Barracuda", action="store_true", dest="barracuda", help="Barracuda WAF [ALL]")
  113. group13.add_option("--Modsec", action="store_true", dest="modsec", help="Mod-Security [ALL]")
  114. group13.add_option("--Quickdefense", action="store_true", dest="quickdefense", help="QuickDefense [Chrome]")
  115. self.add_option_group(group13)
  116. group7 = optparse.OptionGroup(self, "*Select Bypasser(s)*",
  117. "These options can be used to encode vector(s) and try to bypass possible anti-XSS filters. They can be combined with other techniques:")
  118. group7.add_option("--Str", action="store_true", dest="Str", help="Use method String.FromCharCode()")
  119. group7.add_option("--Une", action="store_true", dest="Une", help="Use Unescape() function")
  120. group7.add_option("--Mix", action="store_true", dest="Mix", help="Mix String.FromCharCode() and Unescape()")
  121. group7.add_option("--Dec", action="store_true", dest="Dec", help="Use Decimal encoding")
  122. group7.add_option("--Hex", action="store_true", dest="Hex", help="Use Hexadecimal encoding")
  123. group7.add_option("--Hes", action="store_true", dest="Hes", help="Use Hexadecimal encoding with semicolons")
  124. group7.add_option("--Dwo", action="store_true", dest="Dwo", help="Encode IP addresses with DWORD")
  125. group7.add_option("--Doo", action="store_true", dest="Doo", help="Encode IP addresses with Octal")
  126. group7.add_option("--Cem", action="store", dest="Cem", help="Set different 'Character Encoding Mutations' (reversing obfuscators) (ex: 'Mix,Une,Str,Hex')")
  127. self.add_option_group(group7)
  128. group8 = optparse.OptionGroup(self, "*Special Technique(s)*",
  129. "These options can be used to inject code using different XSS techniques. You can choose multiple:")
  130. group8.add_option("--Coo", action="store_true", dest="coo", help="COO - Cross Site Scripting Cookie injection")
  131. group8.add_option("--Xsa", action="store_true", dest="xsa", help="XSA - Cross Site Agent Scripting")
  132. group8.add_option("--Xsr", action="store_true", dest="xsr", help="XSR - Cross Site Referer Scripting")
  133. group8.add_option("--Dcp", action="store_true", dest="dcp", help="DCP - Data Control Protocol injections")
  134. group8.add_option("--Dom", action="store_true", dest="dom", help="DOM - Document Object Model injections")
  135. group8.add_option("--Ind", action="store_true", dest="inducedcode", help="IND - HTTP Response Splitting Induced code")
  136. group8.add_option("--Anchor", action="store_true", dest="anchor", help="ANC - Use Anchor Stealth payloader (DOM shadows!)")
  137. self.add_option_group(group8)
  138. group9 = optparse.OptionGroup(self, "*Select Final injection(s)*",
  139. "These options can be used to specify the final code to inject on vulnerable target(s). Important if you want to exploit 'on-the-wild' the vulnerabilities found. Choose only one option:")
  140. group9.add_option("--Fp", action="store", dest="finalpayload", help="OWN - Exploit your own code")
  141. group9.add_option("--Fr", action="store", dest="finalremote", help="REMOTE - Exploit a script -remotely-")
  142. group9.add_option("--Doss", action="store_true", dest="doss", help="DOSs - XSS (server) Denial of Service")
  143. group9.add_option("--Dos", action="store_true", dest="dos", help="DOS - XSS (client) Denial of Service")
  144. group9.add_option("--B64", action="store_true", dest="b64", help="B64 - Base64 code encoding in META tag (rfc2397)")
  145. self.add_option_group(group9)
  146. group10 = optparse.OptionGroup(self, "*Special Final injection(s)*",
  147. "These options can be used to execute some 'special' injection(s) on vulnerable target(s). You can select multiple and combine them with your final code (except with DCP code):")
  148. group10.add_option("--Onm", action="store_true", dest="onm", help="ONM - Use onMouseMove() event")
  149. group10.add_option("--Ifr", action="store_true", dest="ifr", help="IFR - Use <iframe> source tag")
  150. self.add_option_group(group10)
  151. group11 = optparse.OptionGroup(self, "*Reporting*")
  152. group11.add_option("--save", action="store_true", dest="fileoutput", help="export to file (XSSreport.raw)")
  153. group11.add_option("--xml", action="store", dest="filexml", help="export to XML (--xml file.xml)")
  154. self.add_option_group(group11)
  155. group12 = optparse.OptionGroup(self, "*Miscellaneous*")
  156. group12.add_option("--silent", action="store_true", dest="silent", help="inhibit console output results")
  157. group12.add_option("--no-head", action="store_true", dest="nohead", help="NOT send a HEAD request before start a test")
  158. group12.add_option("--alive", action="store", dest="isalive", type="int", help="set limit of errors before check if target is alive")
  159. group12.add_option("--update", action="store_true", dest="update", help="check for latest stable version")
  160. self.add_option_group(group12)
  161. def get_options(self, user_args=None):
  162. (options, args) = self.parse_args(user_args)
  163. if (not options.url and not options.readfile and not options.dork and not options.dork_file and not options.imx and not options.flash and not options.update and not options.xsser_gtk and not options.wizard and not options.xst and not options.target):
  164. print "\n", '='*75
  165. print self.version
  166. print "-----------", "\n"
  167. print self.description, "\n"
  168. print '='*75
  169. print ""
  170. print " \\ \\ %"
  171. print "Project site:"," \\ \\ LulZzzz! % "
  172. print "http://xsser.03c8.net %% \\_\\ % "
  173. print " \/ ( \033[1;31m@\033[1;m.\033[1;31m@\033[1;m) Bbzzzzz! % "
  174. print " \== < == % "
  175. print "Forum: / \_ == % "
  176. print "irc.freenode.net -> #xsser (') \ *=====% "
  177. print " / / ======== "
  178. print ""
  179. print '='*75
  180. print "Total vectors:", self.total_vectors + " = XSS: " + str(self.vectors_fuzz) + " + DCP: " + str(self.vectors_dcp) + " + DOM: " + str(self.vectors_dom) + " + HTTPsr: " + str(self.vectors_httpsr)
  181. print '='*75
  182. print "\n-> For HELP use: -h or --help"
  183. print "\n-> For GTK interface use: --gtk\n"
  184. print '='*55, "\n"
  185. return False
  186. return options