├── LICENSE ├── README.md ├── parserAcunetix.py ├── parserBloodHound.py ├── parserBurp.py ├── parserInvoke-Mimikatz.py ├── parserKismet.py ├── parserNetsparker.py ├── parserNipper.py ├── record.sh ├── responder_to_hashcat.py └── shconvert.py /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 | 635 | Copyright (C) 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 | Copyright (C) 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 | # parserBloodHound.py 2 | 3 | This script is used to parse an individual BloodHound 2.0 JSON file to generate a CSV containing a list of hosts where remote group membership was enumerated. This is used when reporting the Authenticated Remote SAMR Enumeration vulnerability. 4 | 5 | # record.sh 6 | 7 | This script is used to record a terminal session to a file that can later be viewed. The script takes to two arguments, a unique name (such as a client's name) and the directory to save the file. Create an alias in /etc/bash.bashrc or //.bashrc to quickly call this script (i.e. alias record="sh /opt/record.sh"). 8 | 9 | ```USAGE: script ``` 10 | ```Example: record ClientA /root/Desktop/``` 11 | --- 12 | -------------------------------------------------------------------------------- /parserAcunetix.py: -------------------------------------------------------------------------------- 1 | __author__ = 'Russel Van Tuyl' 2 | __maintainer__ = "Russel Van Tuyl" 3 | __email__ = "Russel.VanTuyl@gmail.com" 4 | 5 | from xml.etree import ElementTree 6 | import argparse 7 | import hashlib 8 | import os 9 | 10 | ################################################# 11 | # COLORS # 12 | ################################################# 13 | note = "[\033[0;0;33m-\033[0m]" 14 | warn = "[\033[0;0;31m!\033[0m]" 15 | info = "[\033[0;0;36mi\033[0m]" 16 | question = "[\033[0;0;37m?\033[0m]" 17 | 18 | # Parse command line arguments 19 | parser = argparse.ArgumentParser() 20 | file_group = parser.add_mutually_exclusive_group(required=True) 21 | file_group.add_argument('-X', '--xml', type=argparse.FileType('r'), help="Acunetix XML file") 22 | file_group.add_argument('-D', '--directory', help="Parse all XML files in directory") 23 | 24 | # parser.add_argument('-X', '--xml', type=argparse.FileType('r'), required=False, help="Acunetix XML file") 25 | # parser.add_argument('-D', '--directory', action='store_true', default=False, help="Parse all XML files in directory") 26 | parser.add_argument('-U', '--URL', action='store_true', default=False, help="List found URLs") 27 | parser.add_argument('-d', '--directories', action='store_true', default=False, help="List found directories") 28 | parser.add_argument('-F', '--files', action='store_true', default=False, help="List found files") 29 | parser.add_argument('-V', '--vulns', action='store_true', default=True, help="List found vulnerabilities. Default=True") 30 | parser.add_argument('-m', '--md5', action='store_true', default=False, help="Print MD5 hash of vulnerability") 31 | parser.add_argument('-i', '--insensitive', action='store_true', default=False, help="Case Insensitive Output") 32 | parser.add_argument('-v', '--verbose', action='store_true', default=False, help="Verbose Output") 33 | args = parser.parse_args() 34 | 35 | def parse(xml_file): 36 | """Parse XML file and return ElementTree object""" 37 | if args.verbose: 38 | print str(xml_file) 39 | xml_tree = ElementTree.parse(xml_file) 40 | 41 | return xml_tree 42 | 43 | 44 | def get_urls(acunetix_xml): 45 | """Get a list of URLs for all discovered files and directories""" 46 | urls = [] # A list to hold all discovered paths 47 | 48 | for site_files in acunetix_xml.find('.//SiteFiles'): 49 | for site_file in site_files: 50 | url = site_files.find('./FullURL').text.strip('%20') 51 | if args.insensitive: 52 | if url.lower() not in urls: 53 | urls.append(url.lower()) 54 | else: 55 | if url not in urls: 56 | urls.append(url) 57 | 58 | return sorted(set(urls), key=str.lower) 59 | 60 | 61 | def get_paths(acunetix_xml): 62 | """Parse a list of found directories and file names""" 63 | 64 | urls = [] # A list to hold all discovered paths 65 | 66 | for site_files in acunetix_xml.find('.//SiteFiles'): 67 | for site_file in site_files: 68 | url = site_files.find('./URL').text.split('/') 69 | for u in url: 70 | if args.insensitive: 71 | if u.lower() not in urls: 72 | urls.append(u.lower()) 73 | else: 74 | if u not in urls: 75 | urls.append(u) 76 | #print "URL: ", type(i) 77 | #if "." not in url.text: 78 | #urls.append(str(url.text).strip('%20').lstrip('/').rstrip('/')) 79 | 80 | return sorted(set(urls), key=str.lower) 81 | 82 | 83 | def get_files(acunetix_xml): 84 | """Get a sorted list of all discovered files""" 85 | files = [] # A list to hold all discovered files 86 | for site_files in acunetix_xml.find('.//SiteFiles'): 87 | for site_file in site_files: 88 | f = site_files.find('./URL') 89 | if "." in f.text: 90 | files.append(str(f.text).strip('%20')) 91 | 92 | return sorted(set(files), key=str.lower) 93 | 94 | 95 | def get_report_items(acunetix_xml): 96 | """Get Acunetix report findings""" 97 | 98 | report_items = {} 99 | 100 | for report_item in acunetix_xml.findall('.//ReportItem'): 101 | report_items[report_item.attrib.get('id')] = {'name': report_item.find('Name').text, 102 | 'details': report_item.find('Details').text, 103 | 'severity': report_item.find('Severity').text, 104 | 'type': report_item.find('Type').text, 105 | 'description': report_item.find('Description').text, 106 | 'affects': report_item.find('Affects').text} 107 | return report_items 108 | 109 | 110 | def print_vulns(vulns): 111 | """Print list of vulnerabilities to screen""" 112 | for v in vulns: 113 | if args.md5: 114 | m = hashlib.md5() 115 | m.update(vulns[v]['name']) 116 | md5 = m.hexdigest() 117 | print info + "[%s]\t%s (%s) " % (md5.upper(), vulns[v]['name'], vulns[v]['severity']) 118 | else: 119 | print info + "%s (%s)" % (vulns[v]['name'], vulns[v]['severity']) 120 | 121 | if args.verbose: 122 | print "\t" + info + "Vulnerable Path: %s" % vulns[v]['affects'] 123 | print "\t" + note + "Type: %s" % vulns[v]['type'] 124 | print "\t" + note + "Description: %s" % vulns[v]['description'] 125 | print "\t" + note + "Details: %s" % vulns[v]['details'] 126 | 127 | 128 | def print_list(text, object): 129 | """Print list items to screen""" 130 | 131 | print info + "%s" % text 132 | for o in object: 133 | print "%s" % o 134 | 135 | 136 | def parse_directory(): 137 | """Parse all XML Files in directory""" 138 | 139 | files = None 140 | if os.path.isdir(os.path.expanduser(args.directory)): 141 | files = os.listdir(args.directory) 142 | 143 | if files is not None: 144 | for f in files: 145 | if f.lower().endswith('.xml'): 146 | parse_file(os.path.join(os.path.expanduser(args.directory), f)) 147 | 148 | 149 | def parse_file(f): 150 | """Parse a single file""" 151 | 152 | xml_file = open(f, "r") 153 | xml = parse(xml_file) 154 | acunetix_xml = xml.getroot() 155 | if args.verbose: 156 | print "XML Root TAG: %s" % acunetix_xml.tag 157 | # Check for valid Acunentix XML File 158 | if acunetix_xml.tag == "ScanGroup": 159 | if args.URL: 160 | urls = get_urls(acunetix_xml) 161 | print_list("Found URLS", urls) 162 | if args.directories: 163 | paths = get_paths(acunetix_xml) 164 | print_list("Found Paths", paths) 165 | if args.files: 166 | files = get_files(acunetix_xml) 167 | print_list("Found Files", files) 168 | if args.vulns: 169 | vulns = get_report_items(acunetix_xml) 170 | print_vulns(vulns) 171 | else: 172 | pass 173 | 174 | 175 | if __name__ == '__main__': 176 | try: 177 | if args.xml: 178 | parse_file(args.xml.name) 179 | if args.directory: 180 | parse_directory() 181 | except KeyboardInterrupt: 182 | print "\nUser Interrupt! Quitting...." 183 | except: 184 | print "\nPlease report this error to " + __maintainer__ + " by email at: " + __email__ 185 | raise -------------------------------------------------------------------------------- /parserBloodHound.py: -------------------------------------------------------------------------------- 1 | #! /usr/bin/env python 2 | 3 | # Make sure to convert the BloodHound JSON file with dos2unix before using with this script 4 | 5 | ################################################# 6 | # Imports # 7 | ################################################# 8 | import os 9 | import argparse 10 | import json 11 | 12 | ################################################# 13 | # Variables # 14 | ################################################# 15 | __author__ = "Russel Van Tuyl" 16 | __version__ = "1.0" 17 | __maintainer__ = "Russel Van Tuyl" 18 | __email__ = "Russel.VanTuyl@gmail.com" 19 | VERBOSE = False 20 | DEBUG = False 21 | 22 | ################################################# 23 | # COLORS # 24 | ################################################# 25 | note = "\033[0;0;33m[-]\033[0m" 26 | warn = "\033[0;0;31m[!]\033[0m" 27 | info = "\033[0;0;36m[i]\033[0m" 28 | question = "\033[0;0;37m[?]\033[0m" 29 | debug = "\033[0;0;31m[DEBUG]\033[0m" 30 | 31 | 32 | def parse_json_file_to_dictionary(filename): 33 | """Parse an input JSON file object into a python dictionary object and return it""" 34 | 35 | if DEBUG: 36 | print debug + "Entering parse_json_file_to_dictionary function" 37 | try: 38 | if os.path.isfile(filename.name): 39 | if DEBUG: 40 | print debug + "the file %s does exist" % filename 41 | json_data = filename.read() 42 | try: 43 | data = json.loads(json_data) 44 | except ValueError: 45 | print warn + "There was a ValueError parsing the provided file" 46 | print info + "Try converting the file with dos2unix " 47 | print info + "apt install dos2unix" 48 | raise 49 | return data 50 | else: 51 | print warn + "%s is not a valid file, it does not exist" 52 | except TypeError: 53 | print warn + "There was TypeError in the parse_json_file_to_dictionary function" 54 | raise 55 | except: 56 | raise 57 | 58 | 59 | def get_bloodhound_metrics(): 60 | """Get metrics for provided Bloodhound""" 61 | 62 | d = {} 63 | 64 | j = parse_json_file_to_dictionary(args.json) 65 | 66 | if "computers" in j: 67 | parse_computers(j) 68 | elif "sessions" in j: 69 | parse_sessions(j) 70 | else: 71 | print warn + "JSON file did not contain a computers or session object" 72 | 73 | 74 | # Used to get a list of hosts affected by the Authenticated Remote SAMR vulnerability 75 | 76 | def parse_computers(json_data): 77 | """Parse a JSON file containing a computers object from BloodHound""" 78 | 79 | 80 | computers = len(json_data["computers"]) 81 | computersWithGroups = 0 # Any computer object where remote group membership was enumerated 82 | localAdmins = 0 83 | remoteDesktopUsers = 0 84 | dcomUsers = 0 85 | 86 | print info + "Parsing BloodHound COMPUTERS JSON object" 87 | 88 | if DEBUG: 89 | print debug + "Computer object JSON dictionary keys" 90 | print json_data.keys() 91 | 92 | if args.csv: 93 | print '"Name","LocalAdmins","RemoteDesktopUsers","DcomUsers"' 94 | 95 | for computer in json_data["computers"]: 96 | 97 | a = 0 # LocalAdmins 98 | r = 0 # RemoteDesktopUsers 99 | d = 0 # DcomUsers 100 | 101 | if DEBUG: 102 | print debug + "JSON dictionary keys" 103 | print computer.keys() 104 | 105 | if "LocalAdmins" in computer: 106 | if computer["LocalAdmins"] is not None: 107 | a = len(computer["LocalAdmins"]) 108 | localAdmins += a 109 | if "RemoteDesktopUsers" in computer: 110 | if computer["RemoteDesktopUsers"] is not None: 111 | r = len(computer["RemoteDesktopUsers"]) 112 | remoteDesktopUsers += r 113 | if "DcomUsers" in computer: 114 | if computer["DcomUsers"] is not None: 115 | d = len(computer["DcomUsers"]) 116 | dcomUsers += d 117 | 118 | total = a + r + d 119 | 120 | if total > 0: 121 | computersWithGroups += 1 122 | if "Name" in computer and args.csv: 123 | print '"%s","%d","%d","%d"' % (computer["Name"], a, r, d) 124 | 125 | print info + "Total computers where local groups were remotely enumerated: %d" % computersWithGroups 126 | 127 | 128 | def parse_sessions(json_data): 129 | """Parse a JSON file containing a sessions object from BloodHound""" 130 | 131 | computers = {} 132 | 133 | print info + "Parsing BloodHound SESSIONS JSON object" 134 | 135 | for session in json_data["sessions"]: 136 | if "ComputerName" in session: 137 | if session["ComputerName"] in computers: 138 | computers[session["ComputerName"]] += 1 139 | else: 140 | computers[session["ComputerName"]] = 1 141 | if computers is not None and args.csv: 142 | print '"Name","Sessions"' 143 | for computer in computers: 144 | print '"%s","%d"' % (computer, computers[computer]) 145 | 146 | print info + "Total computers with a session: %d" % len(computers) 147 | 148 | 149 | if __name__ == '__main__': 150 | """Main function for parsing a BloodHound JSON file""" 151 | 152 | parser = argparse.ArgumentParser() 153 | parser.add_argument('-j', '--json', type=argparse.FileType('r'), required=True, 154 | help="JSON file to parse for metrics") 155 | parser.add_argument('--csv', action='store_true', default=False, help="Write results to STDOUT in CSV format") 156 | parser.add_argument('--verbose', action='store_true', default=False, help="Enable verbose output") 157 | parser.add_argument('--debug', action='store_true', default=False, help="Enable debug output") 158 | args = parser.parse_args() 159 | 160 | DEBUG = args.debug 161 | VERBOSE = args.verbose 162 | 163 | try: 164 | if not args.json: 165 | parser.print_help() 166 | exit 167 | if args.json: 168 | get_bloodhound_metrics() 169 | except KeyboardInterrupt: 170 | print "\n" + warn + "User Interrupt! Quitting...." 171 | except SystemExit: 172 | pass 173 | except: 174 | print "\n" + warn + "Please report this error to " + __maintainer__ + " by email at: " + __email__ 175 | raise 176 | -------------------------------------------------------------------------------- /parserBurp.py: -------------------------------------------------------------------------------- 1 | __author__ = 'Russel Van Tuyl' 2 | __maintainer__ = "Russel Van Tuyl" 3 | __email__ = "Russel.VanTuyl@gmail.com" 4 | 5 | from xml.etree import ElementTree 6 | import argparse 7 | import hashlib 8 | import os 9 | 10 | ################################################# 11 | # COLORS # 12 | ################################################# 13 | note = "[\033[0;0;33m-\033[0m]" 14 | warn = "[\033[0;0;31m!\033[0m]" 15 | info = "[\033[0;0;36mi\033[0m]" 16 | question = "[\033[0;0;37m?\033[0m]" 17 | 18 | 19 | def parse(xml_file): 20 | """Parse XML file and return ElementTree object""" 21 | if args.verbose or args.directory: 22 | print note + str(xml_file) 23 | xml_tree = ElementTree.parse(xml_file) 24 | 25 | return xml_tree 26 | 27 | 28 | def parse_file(f): 29 | """Parse a single file""" 30 | 31 | xml_file = open(f, "r") 32 | xml = parse(xml_file) 33 | burp_xml = xml.getroot() 34 | if args.verbose: 35 | print "XML Root TAG: %s" % burp_xml.tag 36 | # Check for valid Burp XML File 37 | if burp_xml.tag == "issues": 38 | return burp_xml 39 | else: 40 | print warn + "Note a valid Burp XML file!" 41 | return None 42 | 43 | 44 | def get_paths(burp_xml): 45 | """Parse a list of found directories and file names""" 46 | 47 | urls = [] # A list to hold all discovered paths 48 | 49 | for site_files in burp_xml.find('.//SiteFiles'): 50 | for site_file in site_files: 51 | url = site_files.find('./URL').text.split('/') 52 | for u in url: 53 | if args.insensitive: 54 | if u.lower() not in urls: 55 | urls.append(u.lower()) 56 | else: 57 | if u not in urls: 58 | urls.append(u) 59 | #print "URL: ", type(i) 60 | #if "." not in url.text: 61 | #urls.append(str(url.text).strip('%20').lstrip('/').rstrip('/')) 62 | 63 | return sorted(set(urls), key=str.lower) 64 | 65 | 66 | def print_list(text, object): 67 | """Print list items to screen""" 68 | 69 | print info + "%s" % text 70 | for o in object: 71 | print "%s" % o 72 | 73 | 74 | def print_vulns(vulns): 75 | """Print list of vulnerabilities to screen""" 76 | for v in vulns: 77 | if args.md5: 78 | m = hashlib.md5() 79 | m.update(vulns[v]['name']) 80 | md5 = m.hexdigest() 81 | print info + "[%s]\t%s (%s - %s) " % (md5.upper(), vulns[v]['name'], vulns[v]['severity'], 82 | vulns[v]['confidence']) 83 | else: 84 | print info + "%s (%s - %s)" % (vulns[v]['name'], vulns[v]['severity'], vulns[v]['confidence']) 85 | 86 | if args.verbose: 87 | print "\t" + info + "Host: %s (%s)" % (vulns[v]['host_name'], vulns[v]['host_ip']) 88 | print "\t" + info + "Vulnerable Path: %s" % vulns[v]['path'] 89 | print "\t" + info + "Vulnerable Location: %s" % vulns[v]['location'] 90 | print "\t" + info + "Type: %s" % vulns[v]['type'] 91 | 92 | if args.vverbose: 93 | print "\t" + note + "Description: %s" % vulns[v]['issueBackground'] 94 | print "\t" + note + "Request: %s" % vulns[v]['request']['data'] 95 | print "\t" + note + "Response: %s" % vulns[v]['response']['data'] 96 | 97 | 98 | def get_files(burp_xml): 99 | """Get a sorted list of all discovered files""" 100 | files = [] # A list to hold all discovered files 101 | for site_files in burp_xml.find('.//SiteFiles'): 102 | for site_file in site_files: 103 | f = site_files.find('./URL') 104 | if "." in f.text: 105 | files.append(str(f.text).strip('%20')) 106 | 107 | return sorted(set(files), key=str.lower) 108 | 109 | 110 | def parse_directory(): 111 | """Parse all XML Files in directory""" 112 | 113 | files = None 114 | if os.path.isdir(os.path.expanduser(args.directory)): 115 | files = os.listdir(args.directory) 116 | return files 117 | 118 | 119 | def get_report_items(burp_xml): 120 | """Get Burp report findings""" 121 | 122 | report_items = {} 123 | 124 | for report_item in burp_xml.findall('.//issue'): 125 | report_items[report_item.find('serialNumber')] = {'name': report_item.find('name').text, 126 | 'type': report_item.find('type').text, 127 | 'host_name': report_item.find('host').text, 128 | 'host_ip': report_item.find('host').attrib['ip'], 129 | 'path': report_item.find('path').text, 130 | 'location': report_item.find('location').text, 131 | 'severity': report_item.find('severity').text, 132 | 'confidence': report_item.find('confidence').text, 133 | 'issueBackground': report_item.find('issueBackground').text, 134 | 'remediationBackground': report_item.find('remediationBackground').text, 135 | 'request': {'method': None, 'base64': None, 'data': None}, 136 | 'response': {'base64': None, 'data': None} 137 | } 138 | 139 | report_items[report_item.find('serialNumber')]['request']['data'] = report_item.find('requestresponse/request').text 140 | report_items[report_item.find('serialNumber')]['request']['method'] = report_item.find('requestresponse/request').attrib['method'] 141 | report_items[report_item.find('serialNumber')]['request']['base64'] = report_item.find('requestresponse/request').attrib['base64'] 142 | 143 | report_items[report_item.find('serialNumber')]['response']['data'] = report_item.find('requestresponse/response').text 144 | report_items[report_item.find('serialNumber')]['response']['base64'] = report_item.find('requestresponse/response').attrib['base64'] 145 | return report_items 146 | 147 | 148 | def transform_report(vulns): 149 | """Transform dictionary to format that can be used for generating reports""" 150 | 151 | report = {} 152 | 153 | for v in vulns: 154 | if vulns[v]['name'] not in report.keys(): 155 | report[vulns[v]['name']] = [(vulns[v]['host_name'],vulns[v]['location'])] 156 | else: 157 | if (vulns[v]['host_name'],vulns[v]['location']) not in report[vulns[v]['name']]: 158 | report[vulns[v]['name']].append((vulns[v]['host_name'],vulns[v]['location'])) 159 | 160 | return report 161 | 162 | 163 | def standalone(): 164 | """Run Burp Suite Parser as standalone script""" 165 | 166 | # TODO change handling so it is the same after single file or directory selected 167 | if args.xml: 168 | burp_file = parse_file(args.xml.name) 169 | 170 | if burp_file is not None: 171 | vulns = get_report_items(burp_file) 172 | if args.vulns or args.md5: 173 | print_vulns(vulns) 174 | if args.listing: 175 | report = transform_report(vulns) 176 | for r in report: 177 | print info + "%s" % r 178 | for i in report[r]: 179 | print "\t" + note + " %s%s" %(i[0], i[1]) 180 | 181 | if args.directory: 182 | files = parse_directory() 183 | if files is not None: 184 | for f in files: 185 | if f.lower().endswith('.xml'): 186 | burp_file = parse_file(os.path.join(os.path.expanduser(args.directory), f)) 187 | if burp_file is not None: 188 | vulns = get_report_items(burp_file) 189 | if args.vulns or args.md5: 190 | print_vulns(vulns) 191 | if args.listing: 192 | report = transform_report(vulns) 193 | for r in report: 194 | print info + "%s" % r 195 | for i in report[r]: 196 | print "\t" + note + " %s%s" %(i[0], i[1]) 197 | 198 | 199 | if __name__ == '__main__': 200 | try: 201 | 202 | # Parse command line arguments 203 | parser = argparse.ArgumentParser() 204 | file_group = parser.add_mutually_exclusive_group(required=True) 205 | file_group.add_argument('-X', '--xml', type=argparse.FileType('r'), help="Brup Suite XML file") 206 | file_group.add_argument('-D', '--directory', help="Parse all XML files in directory") 207 | 208 | 209 | parser.add_argument('-V', '--vulns', action='store_true', default=False, help="List found vulnerabilities. Default=True") 210 | parser.add_argument('-m', '--md5', action='store_true', default=False, help="Print MD5 hash of vulnerability") 211 | parser.add_argument('-v', '--verbose', action='store_true', default=False, help="Verbose Output") 212 | parser.add_argument('-vv', '--vverbose', action='store_true', default=False, help="More Verbose Output to include HTTP Request and Response") 213 | parser.add_argument('-l', '--listing', action='store_true', default=False, help="Vulnerability Listing by Vulnerability") 214 | args = parser.parse_args() 215 | 216 | standalone() 217 | 218 | except KeyboardInterrupt: 219 | print "\nUser Interrupt! Quitting...." 220 | except: 221 | print "\nPlease report this error to " + __maintainer__ + " by email at: " + __email__ 222 | raise -------------------------------------------------------------------------------- /parserInvoke-Mimikatz.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/python 2 | #!/usr/bin/env python 3 | 4 | """Parse files generated by piped output from Invoke-Mimikatz.ps1""" 5 | 6 | import logging 7 | import argparse 8 | import sys 9 | import os 10 | import readline 11 | 12 | ################################################# 13 | # Variables # 14 | ################################################# 15 | __author__ = "Russel Van Tuyl" 16 | __license__ = "GPL" 17 | __version__ = "0.1" 18 | __maintainer__ = "Russel Van Tuyl" 19 | __email__ = "Russel.VanTuyl@gmail.com" 20 | __status__ = "Development" 21 | logging.basicConfig(stream=sys.stdout, format='%(asctime)s\t%(levelname)s\t%(message)s', 22 | datefmt='%Y-%m-%d %I:%M:%S %p', level=logging.DEBUG) # Log to STDOUT 23 | script_root = os.path.dirname(os.path.realpath(__file__)) 24 | readline.parse_and_bind('tab: complete') 25 | readline.set_completer_delims('\t') 26 | 27 | ################################################# 28 | # COLORS # 29 | ################################################# 30 | note = "\033[0;0;33m-\033[0m" 31 | warn = "\033[0;0;31m!\033[0m" 32 | info = "\033[0;0;36mi\033[0m" 33 | question = "\033[0;0;37m?\033[0m" 34 | 35 | parser = argparse.ArgumentParser() 36 | parser.add_argument('-F', '--file', type=argparse.FileType('r'), help="Mimikatz output file") 37 | parser.add_argument('-D', '--directory', help="Directory containing Mimikatz output files") 38 | # parser.add_argument('-O', '--output', help="File to save username and password list") 39 | parser.add_argument('-v', '--verbose', action='store_true', default=False, help="Verbose Output") 40 | args = parser.parse_args() 41 | 42 | 43 | def parse_file(f): 44 | """Parse a text file for hashes""" 45 | 46 | users = {} 47 | # users = {SID{username: , domain: , LM: , NTLM:}} 48 | username = None 49 | domain = None 50 | SID = None 51 | print "["+note+"]Parsing " + f 52 | mimikatz_file = open(f, "r") 53 | mimikatz_file_data = mimikatz_file.readlines() 54 | for line in mimikatz_file_data: 55 | # print line 56 | if line.startswith('User Name : '): 57 | # print "["+info+"]Found User: " + line[20:] 58 | if line.endswith("$\r\n") or line.endswith('LOCAL SERVICE\r\n') or line.endswith('(null)\r\n'): # Filter out Machine accounts 59 | username = None 60 | domain = None 61 | SID = None 62 | else: 63 | username = line[20:].rstrip('\r\n') 64 | if line.startswith('Domain : ') and username is not None: 65 | # print "["+info+"]Found Domain: " + line[20:] 66 | if line.endswith('NT AUTHORITY\r\n'): 67 | username = None 68 | domain = None 69 | SID = None 70 | else: 71 | domain = line[20:].rstrip('\r\n') 72 | if line.startswith('SID : ') and username is not None: 73 | # print "["+info+"]Found SID: " + line[20:] 74 | SID = line[20:].rstrip('\r\n') 75 | if SID not in users: 76 | if args.verbose: 77 | print "["+info+"]Found User: " + domain + "\\" + username 78 | users[SID] = {'username': username, 'domain': domain} 79 | if line.startswith(' * LM : ') and username is not None: 80 | if args.verbose and 'LM' not in users[SID].keys(): 81 | print "\t["+info+"]LM HASH: " + line[15:] 82 | users[SID]['LM'] = line[15:].rstrip('\r\n') 83 | if line.startswith(' * NTLM : ') and username is not None: 84 | if args.verbose and 'NTLM' not in users[SID].keys(): 85 | print "\t["+info+"]NTLM Hash: " + line[15:] 86 | users[SID]['NTLM'] = line[15:].rstrip('\r\n') 87 | if line.startswith(' * Password : ') and username is not None: 88 | if 'password' not in users[SID].keys(): 89 | if args.verbose and 'password' not in users[SID].keys(): 90 | print "\t["+info+"]Password: " + line[15:] 91 | # print "\t["+note+"]Creds: " + domain + "\\" + username + ":" + line[15:] 92 | users[SID]['password'] = line[15:].rstrip('\r\n') 93 | # raw_input("Press Enter") 94 | 95 | if args.file: 96 | print_user_pass(users) 97 | elif args.directory: 98 | return users 99 | 100 | 101 | def parse_directory(): 102 | 103 | users = {} 104 | files = None 105 | if os.path.isdir(os.path.expanduser(args.directory)): 106 | files = os.listdir(args.directory) 107 | 108 | if files is not None: 109 | for f in files: 110 | temp = parse_file(os.path.join(os.path.expanduser(args.directory), f)) 111 | users.update(temp) 112 | 113 | print_user_pass(users) 114 | 115 | 116 | def print_user_pass(users): 117 | """Print recovered user accounts and credentials to the screen""" 118 | 119 | for u in users: 120 | if 'password' in users[u].keys(): 121 | if len(users[u]['password']) < 100: # Use this to exclude Kerberos data 122 | print "["+warn+"]" + users[u]['domain'] + "\\" + users[u]['username'] + ":" + users[u]['password'] 123 | 124 | 125 | if __name__ == '__main__': 126 | try: 127 | if args.file: 128 | creds = parse_file(args.file.name) 129 | elif args.directory: 130 | parse_directory() 131 | else: 132 | print "["+warn+"]No arguments provided!" 133 | print "["+warn+"]Try: python " + __file__ + " --help" 134 | except KeyboardInterrupt: 135 | print "\n["+warn+"]User Interrupt! Quitting...." 136 | except: 137 | print "\n["+warn+"]Please report this error to " + __maintainer__ + " by email at: " + __email__ 138 | raise -------------------------------------------------------------------------------- /parserKismet.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/python 2 | #!/usr/bin/env python 3 | 4 | """Parse Kismet netxml Files""" 5 | 6 | from xml.etree import ElementTree 7 | import argparse 8 | import sys 9 | import os 10 | import hashlib 11 | 12 | ################################################# 13 | # Variables # 14 | ################################################# 15 | __author__ = "Russel Van Tuyl" 16 | __license__ = "GPL" 17 | __version__ = "0.1" 18 | __maintainer__ = "Russel Van Tuyl" 19 | __email__ = "Russel.VanTuyl@gmail.com" 20 | __status__ = "Development" 21 | DEBUG = False 22 | ################################################# 23 | # COLORS # 24 | ################################################# 25 | note = "\033[0;0;33m[-]\033[0m" 26 | warn = "\033[0;0;31m[!]\033[0m" 27 | info = "\033[0;0;36m[i]\033[0m" 28 | question = "\033[0;0;37m[?]\033[0m" 29 | debug = "\033[0;0;31m[DEBUG]\033[0m" 30 | 31 | 32 | def parse_xml(file_object): 33 | """Parse an XML file and return the object""" 34 | if args.verbose: 35 | print note + 'Entered into parse_xml function' 36 | 37 | print note + "Parsing %s" % file_object.name 38 | 39 | try: 40 | xml_file = open(file_object.name, "r") 41 | xml = ElementTree.parse(xml_file) 42 | return xml 43 | except ElementTree.ParseError as e: 44 | print warn + "There was an error parsing the file: %s" % file_object 45 | raw_input("Press enter to continue") 46 | 47 | 48 | def parse_directory(directory): 49 | """Parse all netxml Files in directory""" 50 | 51 | files = None 52 | k_files = [] 53 | if os.path.isdir(os.path.expanduser(directory)): 54 | files = os.listdir(directory) 55 | 56 | if files is not None: 57 | for f in files: 58 | if f.lower().endswith('.netxml'): 59 | k_files.append(os.path.join(os.path.expanduser(directory), f)) 60 | 61 | return k_files 62 | 63 | 64 | def get_essid(xml_object): 65 | """Get a unique list of ESSIDs""" 66 | 67 | if args.verbose: 68 | print note + "Entered into get_essid function" 69 | print note + "%s" % xml_object 70 | 71 | for essid in xml_object.findall('.//wireless-network/SSID/essid'): # /wireless-network/SSID/essid 72 | if args.verbose: 73 | print info + essid.text 74 | if essid.text not in kismet: 75 | kismet[essid.text] = {} 76 | 77 | 78 | def get_data(xml_object): 79 | """Take in an XML object and transform it into a python data object""" 80 | 81 | if args.verbose: 82 | print note + "Entered into get_data function" 83 | print note + "%s" % xml_object 84 | 85 | kismet = {} 86 | 87 | for w in xml_object.findall(".//wireless-network/[@type='infrastructure']"): 88 | essid = None 89 | channel = None 90 | encryption = [] 91 | bssid = None 92 | if w.find('./SSID/essid') is not None: 93 | essid = w.find('./SSID/essid').text 94 | if args.verbose: 95 | print info + "%s" % essid 96 | if w.find('./SSID/encryption') is not None: 97 | for e in w.findall('./SSID/encryption'): 98 | encryption.append(e.text) 99 | if args.verbose: 100 | print "\t" + info + "Encryption: %s" % e.text 101 | if w.find('./BSSID') is not None: 102 | bssid = w.find('./BSSID').text 103 | if args.verbose: 104 | print "\t" + info + "BSSID: %s" % bssid 105 | if w.find('./channel') is not None: 106 | channel = w.find('./channel').text 107 | if args.verbose: 108 | print "\t" + info + "Channel: %s" % channel 109 | if essid and essid in kismet: 110 | if bssid not in kismet[essid] and bssid: 111 | kismet[essid][bssid] = {'channel': channel, 'encryption': encryption} 112 | elif essid: 113 | kismet[essid] = {} 114 | kismet[essid][bssid] = {'channel': channel, 'encryption': encryption} 115 | 116 | if DEBUG: 117 | for k in kismet: 118 | print debug + info + k 119 | for bssid in kismet[k]: 120 | print "\t %s: %s" % (bssid, kismet[k][bssid]) 121 | raw_input(debug + "Press any key to continue...") 122 | 123 | return kismet 124 | 125 | 126 | def print_to_screen(kismet): 127 | """Print the Kismet dictionary standard out""" 128 | 129 | print "\nESSID\t\tChannel(s)\t\tBSSID(s)" 130 | for essid in kismet: 131 | bssids = [] 132 | channels = [] 133 | for bssid in kismet[essid]: 134 | bssids.append(bssid) 135 | for channel in kismet[essid][bssid]['channel']: 136 | channels.append(channel) 137 | print "%s\t\t%s\t\t%s" % (essid, ', '.join(set(channels)), ', '.join(bssids)) 138 | 139 | 140 | def write_word_doc(kismet): 141 | """Write parsked Kismet data to a Word document""" 142 | 143 | import docx 144 | import math 145 | import readline 146 | 147 | readline.parse_and_bind('tab: complete') 148 | readline.set_completer_delims('\t') 149 | 150 | report = docx.Document() 151 | report.add_heading("Parsed Kismet Data", level=0) 152 | report.add_heading("Table of %s ESSIDs" % len(kismet), level=2) 153 | 154 | k = [] 155 | 156 | for essid in kismet: 157 | if essid not in k: 158 | k.append(essid) 159 | 160 | c = 4 # number of desired columns 161 | r = int(math.ceil((len(kismet) / float(4)))) # Determine number of rows for table using a max of 4 columns 162 | table = report.add_table(rows=r, cols=c) 163 | table.style = 'Medium Grid 1 Accent 1' 164 | z = 0 # number of hosts 165 | x = 0 # row indices 166 | y = 0 # column indices 167 | while z < len(k): 168 | if (y / float(c)) == 1: # Determine if we need to start putting data on a new row 169 | y = 0 # reset column indices since max number of columns reached 170 | x += 1 171 | table.cell(x, y).text = k[z] 172 | z += 1 173 | y += 1 # Add one to up the column data is put in 174 | if len(k) / float(c) != 1.000: # Add "---" for empty spots in table 175 | d = c * (x + 1) 176 | while d > len(k): 177 | table.cell(x, y).text = "---" 178 | d -= 1 179 | y += 1 180 | 181 | # Print full table of BSSIDs 182 | report.add_heading("Table of All BSSIDs", level=2) 183 | t = report.add_table(rows=1, cols=4) 184 | t.style = 'Medium Grid 1 Accent 1' 185 | hdr_cells = t.rows[0].cells 186 | hdr_cells[0].text = 'ESSID' 187 | hdr_cells[1].text = 'BSSID' 188 | hdr_cells[2].text = 'Channel' 189 | hdr_cells[3].text = 'Security' 190 | table.style = 'Medium Grid 1 Accent 1' 191 | for essid in kismet: 192 | for bssid in kismet[essid]: 193 | row_cells = t.add_row().cells 194 | row_cells[0].text = "%s" % essid 195 | row_cells[1].text = "%s" % bssid 196 | row_cells[2].text = "%s" % kismet[essid][bssid]['channel'] 197 | row_cells[3].text = "%s" % kismet[essid][bssid]['encryption'] 198 | 199 | report.add_heading("Individual ESSID Tables", level=2) 200 | for essid in kismet: 201 | if args.essid: 202 | if essid in args.essid: 203 | if args.verbose: 204 | print info + "Found ESSID: %s" % essid 205 | report.add_heading("Table for ESSID: %s" % essid, level=3) 206 | table = report.add_table(rows=1, cols=4) 207 | hdr_cells = table.rows[0].cells 208 | hdr_cells[0].text = 'ESSID' 209 | hdr_cells[1].text = 'BSSID' 210 | hdr_cells[2].text = 'Channel' 211 | hdr_cells[3].text = 'Security' 212 | table.style = 'Medium Grid 1 Accent 1' 213 | for bssid in kismet[essid]: 214 | row_cells = table.add_row().cells 215 | row_cells[0].text = "%s" % essid 216 | row_cells[1].text = "%s" % bssid 217 | row_cells[2].text = "%s" % kismet[essid][bssid]['channel'] 218 | row_cells[3].text = "%s" % kismet[essid][bssid]['encryption'] 219 | else: 220 | report.add_heading("Table for ESSID: %s" % essid, level=3) 221 | table = report.add_table(rows=1, cols=4) 222 | hdr_cells = table.rows[0].cells 223 | hdr_cells[0].text = 'ESSID' 224 | hdr_cells[1].text = 'BSSID' 225 | hdr_cells[2].text = 'Channel' 226 | hdr_cells[3].text = 'Security' 227 | table.style = 'Medium Grid 1 Accent 1' 228 | for bssid in kismet[essid]: 229 | row_cells = table.add_row().cells 230 | row_cells[0].text = "%s" % essid 231 | row_cells[1].text = "%s" % bssid 232 | row_cells[2].text = "%s" % kismet[essid][bssid]['channel'] 233 | row_cells[3].text = "%s" % kismet[essid][bssid]['encryption'] 234 | 235 | save_report(report) 236 | 237 | 238 | def get_path(): 239 | """Prompt the user to enter a directory path""" 240 | 241 | output_path = None 242 | while output_path is None: 243 | print question + "Please enter the directory where you would like the file saved?" 244 | output_path = raw_input() 245 | if os.path.isdir(os.path.expanduser(output_path)): 246 | pass 247 | else: 248 | os.system('clear') 249 | print warn + "%s is not valid, please try again: " % str(output_path) 250 | output_path = None 251 | return os.path.expanduser(output_path) 252 | 253 | 254 | def save_report(report_object): 255 | """Save the generated report""" 256 | out_dir = get_path() 257 | report_file = os.path.join(out_dir, "Kismet_Parsed_Data.docx") 258 | report_object.save(report_file) 259 | print warn + "Report saved to: " + report_file 260 | raw_input(info + "Press enter to continue...") 261 | 262 | 263 | def csv_list(string): 264 | return string.split(',') 265 | 266 | 267 | if __name__ == '__main__': 268 | """Main Kismet netxml parser when run as a script""" 269 | 270 | parser = argparse.ArgumentParser() 271 | parser.add_argument('-X', '--xml', type=argparse.FileType('r'), help="Kismet .netxml file") 272 | parser.add_argument('-D', '--directory', help="Directory containing Kismet .netxml files") 273 | parser.add_argument('-E', '--essid', type=csv_list, 274 | help="A comma seperated list of essids to filter output on") 275 | parser.add_argument('-W', '--word', action='store_true', default=False, 276 | help="Save parsed results to a Word document") 277 | parser.add_argument('-C', '--csv', action='store_true', default=False, 278 | help="Save parsed results to a CSV document on stdout") 279 | parser.add_argument('-v', '--verbose', action='store_true', default=False, help="Verbose Output") 280 | parser.add_argument('--debug', action='store_true', default=False, help="Enable debug output") 281 | args = parser.parse_args() 282 | 283 | try: 284 | DEBUG = args.debug 285 | 286 | if args.xml: 287 | netxml = parse_xml(args.xml) 288 | kismet = get_data(netxml) 289 | if args.word: 290 | write_word_doc(kismet) 291 | elif args.csv: 292 | print_to_screen(kismet) # TODO replace with a real write csv to file function 293 | elif args.directory: 294 | kismet = {} 295 | kismet_files = parse_directory(args.directory) 296 | for f in kismet_files: 297 | netxml = parse_xml(open(f, "r")) 298 | k = get_data(netxml) 299 | for i in k: 300 | if i not in kismet: 301 | kismet[i] = k[i] 302 | elif i in kismet: 303 | kismet[i].update(k[i]) 304 | if args.word: 305 | write_word_doc(kismet) 306 | elif args.csv: 307 | print_to_screen(kismet) 308 | else: 309 | print warn + "No arguments provided!" 310 | print warn + "Try: python " + __file__ + " --help" 311 | 312 | except KeyboardInterrupt: 313 | print warn + "\nUser Interrupt! Quitting...." 314 | except: 315 | print info + "\nPlease report this error to " + __maintainer__ + " by email at: " + __email__ 316 | raise 317 | 318 | # Data Structure 319 | # : {} 320 | # : {} 321 | # : channel 322 | # : encryption -------------------------------------------------------------------------------- /parserNetsparker.py: -------------------------------------------------------------------------------- 1 | 2 | 3 | from xml.etree import ElementTree 4 | import argparse 5 | import logging 6 | import sys 7 | import os 8 | import readline 9 | import hashlib 10 | 11 | ################################################# 12 | # Variables # 13 | ################################################# 14 | __author__ = "Russel Van Tuyl" 15 | __license__ = "GPL" 16 | __version__ = "0.1" 17 | __maintainer__ = "Russel Van Tuyl" 18 | __email__ = "Russel.VanTuyl@gmail.com" 19 | __status__ = "Development" 20 | logging.basicConfig(stream=sys.stdout, format='%(asctime)s\t%(levelname)s\t%(message)s', 21 | datefmt='%Y-%m-%d %I:%M:%S %p', level=logging.DEBUG) # Log to STDOUT 22 | script_root = os.path.dirname(os.path.realpath(__file__)) 23 | readline.parse_and_bind('tab: complete') 24 | readline.set_completer_delims('\t') 25 | 26 | ################################################# 27 | # COLORS # 28 | ################################################# 29 | note = "\033[0;0;33m-\033[0m" 30 | warn = "\033[0;0;31m!\033[0m" 31 | info = "\033[0;0;36mi\033[0m" 32 | question = "\033[0;0;37m?\033[0m" 33 | VERBOSE = False 34 | CVE = False 35 | MD5 = False 36 | VULNS = False 37 | 38 | 39 | def read_xml(xml_file): 40 | """Parse file and create xml root element""" 41 | 42 | if VERBOSE: 43 | print "[" + info + "]Parsing: ", xml_file 44 | xml_tree = ElementTree.parse(xml_file) 45 | xml = xml_tree.getroot() 46 | 47 | if xml.tag == 'netsparker': 48 | return xml 49 | else: 50 | return None 51 | 52 | 53 | def read_directory(): 54 | 55 | files = [] 56 | directory_files = None 57 | if os.path.isdir(os.path.expanduser(args.directory)): 58 | directory_files = os.listdir(args.directory) 59 | 60 | if directory_files is not None: 61 | for f in directory_files: 62 | if f.endswith('.xml'): 63 | files.append(os.path.join(args.directory, f)) 64 | 65 | return files 66 | 67 | 68 | def parse(xml): 69 | """Main Netsparker Parse Function""" 70 | 71 | netsparker = {} # Dictionary to hold all parsed data 72 | 73 | # Verify Netsparker XML 74 | if xml.tag != 'netsparker': 75 | print "[" + warn + "The specefied file does not appear to be a Netsparker XML" 76 | print "[" + warn + "The root element is: " + xml.tag 77 | sys.exit() 78 | target = xml.findtext('./target/url') 79 | if VERBOSE or CVE or MD5 or VULNS: 80 | print "[" + note + "]Target: ", target 81 | if target is not None: 82 | netsparker[target] = {'target_url': target, 'vulnerabilities': {}} 83 | 84 | for vulnerability in xml.findall('./vulnerability'): 85 | # Gather Important Data 86 | url = vulnerability.findtext('./url') 87 | type = vulnerability.findtext('./type') 88 | severity = vulnerability.findtext('./severity') 89 | certainty = vulnerability.findtext('./certainty') 90 | m = hashlib.md5() 91 | m.update(type) 92 | md5 = m.hexdigest().upper() 93 | if MD5: 94 | print "\t[" + warn + "][%s]\t%s" % (md5, type) 95 | elif VULNS or CVE or VERBOSE: 96 | print "\t[" + warn + "]" + type 97 | 98 | # Version Information 99 | # TODO add to Netsparker Dictionary 100 | if vulnerability.findall('./extrainformation') is not None: 101 | for z in vulnerability.findall('./extrainformation/info'): 102 | if VERBOSE: 103 | print "\t\t[" + info + "]%s: %s" % (z.get('name'), z.text) 104 | 105 | # Vulnerabilities listed inside vulnerabilities i.e out of date openssl 106 | # TODO add to Netsparker Dictionary 107 | if vulnerability.findall('./knownvulnerabilities') is not None: 108 | for v in vulnerability.findall('./knownvulnerabilities/knownvulnerability'): 109 | m2 = hashlib.md5() 110 | m2.update(v.findtext('./title')) 111 | md52 = m2.hexdigest().upper() 112 | if CVE: 113 | print "\t\t[" + warn + "]%s\t[%s]\t%s" % (v.findtext('./references'), 114 | md52, 115 | v.findtext('./title')) 116 | # TODO Add Data to Dictionary 117 | if type in netsparker[target]['vulnerabilities'].keys(): 118 | netsparker[target]['vulnerabilities'][type].update({url:{'url': url, 'severity': severity, 119 | 'certainty': certainty}}) 120 | else: 121 | netsparker[target]['vulnerabilities'][type] = {url:{'url': url, 'severity': severity, 122 | 'certainty': certainty}} 123 | 124 | if VERBOSE: 125 | print "\t\t[" + info + "]URL: ", url 126 | print "\t\t[" + info + "]Severity: ", severity 127 | print "\t\t[" + info + "]MD5: ",md5.upper() 128 | print "\t\t[" + info + "]Certainty: ", certainty 129 | return netsparker 130 | 131 | 132 | if __name__ == '__main__': 133 | try: 134 | 135 | # Parse command line arguments 136 | parser = argparse.ArgumentParser() 137 | file_group = parser.add_mutually_exclusive_group(required=True) 138 | file_group.add_argument('-X', '--xml', type=argparse.FileType('r'), help="Netsparker XML file") 139 | file_group.add_argument('-D', '--directory', help="Parse all XML files in directory") 140 | parser.add_argument('-c', '--cve', action='store_true', default=False, help="Print CVE information") 141 | parser.add_argument('-m', '--md5', action='store_true', default=False, help="Print MD5 hash of vulnerability") 142 | parser.add_argument('-V', '--vulns', action='store_true', default=False, help="List found vulnerabilities") 143 | parser.add_argument('-v', '--verbose', action='store_true', default=False, help="Print verbose information") 144 | args = parser.parse_args() 145 | 146 | if args.verbose: 147 | VERBOSE = True 148 | if args.md5: 149 | MD5 = True 150 | if args.cve: 151 | CVE = True 152 | if args.vulns: 153 | VULNS = True 154 | if args.xml: 155 | netsparker_xml = read_xml(args.xml) 156 | if netsparker_xml is not None: 157 | netsparker_object = parse(netsparker_xml) 158 | if args.directory: 159 | xml_files = read_directory() 160 | netsparker_object = {} 161 | if len(xml_files) > 0: 162 | for f in xml_files: 163 | netsparker_xml = read_xml(f) 164 | netsparker_object.update(parse(netsparker_xml)) 165 | except KeyboardInterrupt: 166 | print "\nUser Interrupt! Quitting...." 167 | except: 168 | print "\nPlease report this error to " + __maintainer__ + " by email at: " + __email__ 169 | raise 170 | 171 | # Data Structure 172 | 173 | # dict 174 | # value 175 | # dict 176 | # dict 177 | # dict 178 | # value 179 | # value 180 | # value 181 | # value 182 | # value 183 | # list of 184 | -------------------------------------------------------------------------------- /parserNipper.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/python 2 | #!/usr/bin/env python 3 | 4 | """parserNipper is a script to parse Nipper XML files""" 5 | 6 | from xml.etree import ElementTree 7 | import argparse 8 | import docx 9 | import os 10 | import logging 11 | import sys 12 | import readline 13 | 14 | # Requires python-docx library, apt-get update; apt-get install -y python-pip;pip install python-docx 15 | 16 | ################################################# 17 | # Variables # 18 | ################################################# 19 | __author__ = "Russel Van Tuyl" 20 | __license__ = "GPL" 21 | __version__ = "0.1" 22 | __maintainer__ = "Russel Van Tuyl" 23 | __email__ = "Russel.VanTuyl@gmail.com" 24 | __status__ = "Development" 25 | logging.basicConfig(stream=sys.stdout, format='%(asctime)s\t%(levelname)s\t%(message)s', 26 | datefmt='%Y-%m-%d %I:%M:%S %p', level=logging.WARNING) # Log to STDOUT 27 | 28 | nipper_xml = None 29 | readline.parse_and_bind('tab: complete') 30 | readline.set_completer_delims('\t') 31 | DEBUG = False 32 | VERBOSE = False 33 | ################################################# 34 | # COLORS # 35 | ################################################# 36 | note = "[\033[0;0;33m-\033[0m]" 37 | warn = "[\033[0;0;31m!\033[0m]" 38 | info = "[\033[0;0;36mi\033[0m]" 39 | question = "[\033[0;0;37m?\033[0m]" 40 | 41 | 42 | def parse_xml(xml_file): 43 | """Parse XML file and return ElementTree object""" 44 | logging.info(str(xml_file)) 45 | global nipper_xml 46 | xml_tree = ElementTree.parse(xml_file) 47 | 48 | nipper_xml = xml_tree.getroot() 49 | 50 | 51 | def get_devices_information(): 52 | """Create a dictionary of devices found in the Nipper XML from the /document/information/devices section""" 53 | global nipper_xml 54 | devices = {} 55 | 56 | for device in nipper_xml.findall('./information/devices/device'): 57 | if DEBUG: 58 | print "\t" + note + "Name: %s" % device.get('name') 59 | print "\t" + note + "Type: %s" % device.get('type') 60 | print "\t" + note + "OS: %s" % device.get('os') 61 | print "\t" + note + "OS Version: %s" % device.get('osversion') 62 | devices[device.attrib.get('name')] = {'name': device.get('name'), 63 | 'type': device.get('type'), 64 | 'os': device.get('os'), 65 | 'osversion': device.get('osversion')} 66 | if DEBUG: 67 | print info + "Device Object:" 68 | print devices 69 | raw_input(warn + "Press enter to continue") 70 | return devices 71 | 72 | 73 | def get_devices_summary(): 74 | """Create a dictionary of devices found in the Nipper XML from the /summary""" 75 | 76 | # This function was created to replace get_devices_information 77 | # because it wasn't detecting virtual systems in Palo Alto Virtual Systems 78 | global nipper_xml 79 | devices = {} 80 | headings = [] 81 | 82 | # Add the table headings to a list 83 | for h in nipper_xml.findall("./summary/table/[@ref='SCOPE.AUDITDEVICELIST.TABLE']/headings/heading"): 84 | if h not in headings: 85 | headings.append(h.text) 86 | 87 | for device in nipper_xml.findall("./summary/table/[@ref='SCOPE.AUDITDEVICELIST.TABLE']/tablebody/tablerow"): 88 | values = [] 89 | for i in device.findall('./tablecell/item'): 90 | if i not in values: 91 | values.append(i.text) 92 | if DEBUG: 93 | print "\t" + note + "%s: %s" % (headings[headings.index('Name')], values[headings.index('Name')]) 94 | print "\t" + note + "%s: %s" % (headings[headings.index('Device')], values[headings.index('Device')]) 95 | print "\t" + note + "%s: %s" % (headings[headings.index('OS')], values[headings.index('OS')].split(" ")[0]) 96 | print "\t" + note + "%s: %s" % (headings[headings.index('OS')], values[headings.index('OS')].split(" ")[1]) 97 | devices[values[headings.index('Name')]] = {'name': values[headings.index('Name')], 98 | 'type': values[headings.index('Device')], 99 | 'os': values[headings.index('OS')].split(' ')[0], 100 | 'osversion': values[headings.index('OS')].split(' ')[1] 101 | } 102 | 103 | if DEBUG: 104 | print info + "Device Object:" 105 | print devices 106 | raw_input(warn + "Press enter to continue") 107 | return devices 108 | 109 | 110 | def get_ipv4_interfaces(device_name): 111 | """Build a list of interfaces per device""" 112 | interfaces = {} 113 | if DEBUG: 114 | print note + "Entering into get_ipv4_interfaces function" 115 | # Needs to be fixed. Get list of interfaces first, then IP addresses, then VLAN, then ACLs 116 | config_element = nipper_xml.find("./report/part/[@ref='CONFIGURATION']") 117 | 118 | for section in config_element.findall('./section'): 119 | device_item = None 120 | 121 | for i in section.get('title').split(): 122 | if device_name == i: 123 | device_item = device_name 124 | if DEBUG: 125 | print "\t" + note + "Set Device: %s" % device_name 126 | 127 | if device_item is not None: 128 | interface_element = section.find("./section/[@ref='CONFIGURATION.ADDRESSES']/section/" 129 | "[@ref='ADDRESSES.IPV4']") 130 | if interface_element is not None: 131 | headings = [] 132 | items = [] 133 | for heading in interface_element.findall("./table/[@title='IPv4 addresses']/headings/heading"): 134 | headings.append(heading.text) 135 | if DEBUG: 136 | print "\t" + note + "Set Heading: %s" % heading.text 137 | for item in interface_element.findall("./table/[@title='IPv4 addresses']/tablebody" 138 | "/tablerow/tablecell/item"): 139 | items.append(item.text) 140 | if DEBUG: 141 | print "\t" + note + "Set Item: %s" % item.text 142 | i = 0 143 | interface_id = None 144 | if DEBUG: 145 | print "\t" + note + "Heading List: %s" % headings 146 | print "\t" + note + "Items List: %s" % items 147 | for item in items: 148 | if i > (len(headings) - 1): 149 | i = 0 150 | if DEBUG: 151 | print "\t" + info + "Heading: %s\t Item: %s" % (headings[i], item) 152 | if i is 0: 153 | interface_id = item 154 | interfaces[interface_id] = {} 155 | interfaces[interface_id].update({headings[i]: item}) 156 | i += 1 157 | 158 | interfaces_element = section.find("./section/[@ref='CONFIGURATION.INTERFACES']/section/" 159 | "[@ref='ETHINTERFACESLAYER3']") 160 | if interfaces_element is not None: 161 | headings = [] 162 | for heading in interfaces_element.findall("./table/[@title='Layer 3 Ethernet Interfaces']" 163 | "/headings/heading"): 164 | headings.append(heading.text) 165 | for tr in interfaces_element.findall("./table/[@title='Layer 3 Ethernet Interfaces']" 166 | "/tablebody/tablerow"): 167 | items = [] 168 | for i in tr.findall("./tablecell/item"): 169 | items.append(i.text) 170 | if 'Zone' in headings: 171 | interfaces[items[headings.index('Interface')]].update({'Zone': items[headings.index('Zone')]}) 172 | if 'VLAN' in headings: 173 | interfaces[items[headings.index('Interface')]].update({'VLAN': items[headings.index('VLAN')]}) 174 | if DEBUG: 175 | print info + "Interfaces object: " 176 | print interfaces 177 | raw_input(warn + "Press any key to continue") 178 | return interfaces 179 | 180 | 181 | def get_cve(device_list): 182 | """Get a list of all CVEs""" 183 | 184 | # A list of devices has to be passed in to match device names in strings. Nipper does not do a good job of making a 185 | # unique identifier for an affected host to a CVE. They just write a sentence with the device name in it. 186 | 187 | cves = {} 188 | 189 | cve_element = nipper_xml.find("./report/part/[@ref='VULNAUDIT']") 190 | 191 | for section in cve_element.findall('./section'): 192 | # print section.get('title') 193 | if section.get('title').startswith('CVE-'): # Look only at CVE sections 194 | cve = section.get('title') 195 | cves[cve] = {} 196 | if DEBUG: 197 | print info + "CVE: %s" % cve 198 | # CVSS_v2 Score 199 | cvss_score = section.find("./infobox/infodata/[@label='CVSSv2 Score']").text 200 | cves[cve].update({'CVSSv2_Score': cvss_score}) 201 | if DEBUG: 202 | print "\t" + info + "CVSSv2 Score: %s" % cvss_score 203 | # Single Devices 204 | for ad_section in section.findall("./section/[@title='Affected Device']"): 205 | for d in device_list: 206 | for i in ad_section.find("./text").text.split(): 207 | if d == i: 208 | cves[cve].update({'Hosts': [d]}) 209 | if DEBUG: 210 | print "\t" + note + "Single Device: %s" % d 211 | # Multiple Devices 212 | ad_list = [] 213 | for ad_section in section.findall("./section/[@title='Affected Devices']/list/listitem"): 214 | ad_list.append(ad_section.text.split(" - ")[1].rstrip(";").rstrip(".")) 215 | if len(ad_list) > 0: 216 | cves[cve].update({'Hosts': ad_list}) 217 | if DEBUG: 218 | print "\t" + note + "Multiple Devices: %s" % ad_list 219 | if DEBUG: 220 | print info + "CVE Object:" 221 | print cves 222 | raw_input(warn + "Press enter to continue") 223 | return cves 224 | 225 | 226 | def get_nipper_version(): 227 | """Get the version of Nipper used to generate the XML file""" 228 | nipper_version = nipper_xml.find("./information/generator/version").text 229 | return nipper_version 230 | 231 | # TODO Get rid of the get_any_source_any_destination_any_port function; get-filter_rules is used instead 232 | def get_any_source_any_destination_any_port(devices): 233 | """Get all firewall rules with ANY Source, ANY Destination, and ANY Port for the passed in devices""" 234 | 235 | tables = nipper_xml.findall("./report/part/[@ref='SECURITYAUDIT']/section/[@ref='FILTER.RULE.AEAA']/" 236 | "section[@ref='FINDING']/table") 237 | 238 | rules = {} 239 | 240 | for table in tables: 241 | for device in devices: 242 | if device in table.get('title').split(): 243 | headings = [] 244 | acl = table.get('ref').lstrip('FILTER.RULE.AEAA')[:-1] 245 | rules[acl] = {} 246 | for heading in table.findall('./headings/heading'): 247 | headings.append(heading.text) 248 | if DEBUG: 249 | print info + "%s ACL: %s" % (device, table.get('ref').lstrip('FILTER.RULE.AEAA')[:-1]) 250 | print info + "HEADINGS: %s" % headings 251 | for row in table.findall('./tablebody/tablerow'): 252 | i = 0 253 | rule_id = None 254 | for data in row.findall('./tablecell'): 255 | print "DATA: %s" % data.find('./item').text 256 | if headings[i] == 'Rule': 257 | rule_id = data.find('./item').text 258 | rules[acl][rule_id] = {'Device': device} 259 | if rule_id: 260 | rules[acl][rule_id].update({headings[i]: data.find('./item').text}) 261 | i += 1 262 | if DEBUG: 263 | print info + "Any Source/Any Destination/Any Port Rule Object:" 264 | print rules 265 | raw_input(warn + "Press enter to continue") 266 | return rules 267 | 268 | # TODO Get rid of the get_any_source_fixed_destination_any_port function 269 | def get_any_source_fixed_destination_any_port(devices): 270 | """Get all firewall rules with ANY Source, a FIXED Destination, and ANY Port for the passed in devices""" 271 | 272 | tables = nipper_xml.findall("./report/part/[@ref='SECURITYAUDIT']/section/[@ref='FILTER.RULE.AENA']/" 273 | "section[@ref='FINDING']/table") 274 | 275 | rules = {} 276 | 277 | for table in tables: 278 | for device in devices: 279 | if device in table.get('title').split(): 280 | headings = [] 281 | acl = table.get('ref').lstrip('FILTER.RULE.AENA')[:-1] 282 | rules[acl] = {} 283 | for heading in table.findall('./headings/heading'): 284 | headings.append(heading.text) 285 | if DEBUG: 286 | print info + "%s ACL: %s" % (device, table.get('ref').lstrip('FILTER.RULE.AENA')[:-1]) 287 | print info + "HEADINGS: %s" % headings 288 | for row in table.findall('./tablebody/tablerow'): 289 | i = 0 290 | rule_id = None 291 | for data in row.findall('./tablecell'): 292 | print "DATA: %s" % data.find('./item').text 293 | if headings[i] == 'Rule': 294 | rule_id = data.find('./item').text 295 | rules[acl][rule_id] = {'Device': device} 296 | if rule_id: 297 | rules[acl][rule_id].update({headings[i]: data.find('./item').text}) 298 | i += 1 299 | if DEBUG: 300 | print info + "Any Source/Fixed Destination/Any Port Rule Object:" 301 | print rules 302 | raw_input(warn + "Press enter to continue") 303 | return rules 304 | 305 | # TODO Get rid of the get_fixed_source_any_destination_any_port function 306 | def get_fixed_source_any_destination_any_port(devices): 307 | """Get all firewall rules with a fixed Source, ANY Destination, and ANY Port for the passed in devices""" 308 | 309 | tables = nipper_xml.findall("./report/part/[@ref='SECURITYAUDIT']/section/[@ref='FILTER.RULE.NEAA']/" 310 | "section[@ref='FINDING']/table") 311 | 312 | rules = {} 313 | 314 | for table in tables: 315 | for device in devices: 316 | if device in table.get('title').split(): 317 | headings = [] 318 | acl = table.get('ref').lstrip('FILTER.RULE.NEAA')[:-1] 319 | rules[acl] = {} 320 | for heading in table.findall('./headings/heading'): 321 | headings.append(heading.text) 322 | if DEBUG: 323 | print info + "%s ACL: %s" % (device, table.get('ref').lstrip('FILTER.RULE.NEAA')[:-1]) 324 | print info + "HEADINGS: %s" % headings 325 | for row in table.findall('./tablebody/tablerow'): 326 | i = 0 327 | rule_id = None 328 | for data in row.findall('./tablecell'): 329 | print "DATA: %s" % data.find('./item').text 330 | if headings[i] == 'Rule': 331 | rule_id = data.find('./item').text 332 | rules[acl][rule_id] = {'Device': device} 333 | if rule_id: 334 | rules[acl][rule_id].update({headings[i]: data.find('./item').text}) 335 | i += 1 336 | if DEBUG: 337 | print info + "Fixed Source, Any Destination, Any Port Rule Object:" 338 | print rules 339 | raw_input(warn + "Press enter to continue") 340 | return rules 341 | 342 | # TODO Get rid of the get_fixed_source_fixed_destination_any_port funciton 343 | def get_fixed_source_fixed_destination_any_port(devices): 344 | """Get all firewall rules with a fixed Source, fixed Destination, and ANY Port for the passed in devices""" 345 | 346 | tables = nipper_xml.findall("./report/part/[@ref='SECURITYAUDIT']/section/[@ref='FILTER.RULE.NENA']/" 347 | "section[@ref='FINDING']/table") 348 | 349 | rules = {} 350 | 351 | for table in tables: 352 | for device in devices: 353 | if device in table.get('title').split(): 354 | headings = [] 355 | acl = table.get('ref').lstrip('FILTER.RULE.NENA')[:-1] 356 | rules[acl] = {} 357 | for heading in table.findall('./headings/heading'): 358 | headings.append(heading.text) 359 | if DEBUG: 360 | print info + "%s ACL: %s" % (device, table.get('ref').lstrip('FILTER.RULE.NENA')[:-1]) 361 | print info + "HEADINGS: %s" % headings 362 | for row in table.findall('./tablebody/tablerow'): 363 | i = 0 364 | rule_id = None 365 | for data in row.findall('./tablecell'): 366 | print "DATA: %s" % data.find('./item').text 367 | if headings[i] == 'Rule': 368 | rule_id = data.find('./item').text 369 | rules[acl][rule_id] = {'Device': device} 370 | if rule_id: 371 | rules[acl][rule_id].update({headings[i]: data.find('./item').text}) 372 | i += 1 373 | if DEBUG: 374 | print info + "Fixed Source, Fixed Destination, Any Port Rule Object:" 375 | print rules 376 | raw_input(warn + "Press enter to continue") 377 | return rules 378 | 379 | 380 | def get_filter_rules(devices, filter_name): 381 | """Get all firewall rules for the passed in devices and filter name""" 382 | 383 | tables = nipper_xml.findall("./report/part/[@ref='SECURITYAUDIT']/section/[@ref='" + filter_name + "']/" 384 | "section[@ref='FINDING']/table") 385 | 386 | rules = {} 387 | 388 | for table in tables: 389 | for device in devices: 390 | if device in table.get('title').split(): 391 | headings = [] 392 | acl = table.get('ref').lstrip(filter_name)[:-1] 393 | rules[acl] = {} 394 | for heading in table.findall('./headings/heading'): 395 | headings.append(heading.text) 396 | if DEBUG: 397 | print info + "%s ACL: %s" % (device, table.get('ref').lstrip(filter_name)[:-1]) 398 | print info + "HEADINGS: %s" % headings 399 | for row in table.findall('./tablebody/tablerow'): 400 | i = 0 401 | rule_id = None 402 | for data in row.findall('./tablecell'): 403 | if headings[i] == 'Rule': 404 | rule_id = data.find('./item').text 405 | rules[acl][rule_id] = {'Device': device} 406 | if rule_id: 407 | rules[acl][rule_id].update({headings[i]: data.find('./item').text}) 408 | i += 1 409 | if DEBUG: 410 | print info + "%s Rule Object: " % filter_name 411 | print rules 412 | raw_input(warn + "Press enter to continue") 413 | return rules 414 | 415 | 416 | def get_vpn_aggressive(devices): 417 | """Get VPN Agressive mode vulnerability""" 418 | 419 | section = nipper_xml.findall("./report/part/[@ref='SECURITYAUDIT']/section/[@ref='REMOTEACCESS.AGGRESSIVEMODE']" 420 | "/section/[@title='Affected Devices']/list/listitem") 421 | 422 | vulns = [] 423 | if section: 424 | for device in devices: 425 | for item in section: 426 | if device in item.text.split(): 427 | vulns.append(device) 428 | 429 | if DEBUG: 430 | print note + "VPN Agrressive Mode Object: ", vulns 431 | raw_input(warn + "Press enter to continue...") 432 | if len(vulns) > 0: 433 | return vulns 434 | else: 435 | return None 436 | 437 | 438 | def get_weak_snmp_community(devices): 439 | """Get Weak SNMP Community String informaiton from report""" 440 | 441 | tables = nipper_xml.findall("./report/part/[@ref='SECURITYAUDIT']/section/[@ref='SNMP.WEAK.COMMUNITY']/" 442 | "section[@ref='FINDING']/table") 443 | 444 | snmp = {} 445 | 446 | # Data Structure 447 | # : {} 448 | # : {} 449 | # : weakness 450 | # : host 451 | 452 | for table in tables: 453 | for device in devices: 454 | if device in table.get('title').split(): 455 | headings = [] 456 | data = [] 457 | for heading in table.findall('./headings/heading'): 458 | headings.append(heading.text) 459 | for row in table.findall('./tablebody/tablerow'): 460 | for item in row.findall('.tablecell'): 461 | data.append(item.find('./item').text) 462 | if DEBUG: 463 | print info + "SNMP Weak Community String:" 464 | print "\t" + info + "Headers: %s" % headings 465 | print "\t" + info + "Data: %s" % data 466 | raw_input(warn + "Press enter to continue...") 467 | if device not in snmp: 468 | snmp[device] = {} 469 | c = headings.index('Community') 470 | w = headings.index('Weakness') 471 | snmp[device][data[c]] = {headings[w]: data[w]} 472 | if 'Host' in headings: 473 | h = headings.index('Host') 474 | snmp[device][data[c]].update({headings[h]: data[h]}) 475 | 476 | if DEBUG: 477 | print "SNMP Weak Community String Dict:" 478 | print info, snmp 479 | raw_input(warn + "Press enter to continue...") 480 | 481 | return snmp 482 | 483 | 484 | def write_intro(report, devices): 485 | """Write the introduction paragraph for a firewall configuration audit narrative""" 486 | 487 | report.add_heading("Firewall Configuration Audit") 488 | 489 | report.add_paragraph("For the firewall configuration audit, the assessment team reviewed the configuration of " 490 | "%d firewall devices. The table below shows general device information for " 491 | "each of the assessed devices." % len(devices), style='Normal') 492 | 493 | table = report.add_table(rows=1, cols=3) 494 | hdr_cells = table.rows[0].cells 495 | hdr_cells[0].text = 'Name' 496 | hdr_cells[1].text = 'Type' 497 | hdr_cells[2].text = 'Version' 498 | table.style = 'Medium Grid 1 Accent 1' 499 | 500 | for device in devices: 501 | row_cells = table.add_row().cells 502 | row_cells[0].text = "%s" % devices[device]['name'] 503 | row_cells[1].text = "%s" % devices[device]['type'] 504 | row_cells[2].text = "%s" % devices[device]['osversion'] 505 | 506 | report.add_paragraph("\nThe assessment team leveraged extensive experience as firewall administrators as well as " 507 | "commercial tools to perform the firewall device audits and provide security recommendations. " 508 | "Output from the commercial tools has been provided as supplemental documentation " 509 | "to this report.", style='Normal') 510 | 511 | return report 512 | 513 | 514 | def write_interfaces(report, devices): 515 | """Write the Active Interfaces portion of the report""" 516 | 517 | report.add_heading("Device Active Interfaces", 3) 518 | 519 | report.add_paragraph("The following device information shows each active interface configuration as well as the " 520 | "corresponding zone defined for that interface. During the configuration audit, the assessment" 521 | " team placed emphasis on the active interfaces identified in the following tables.", 522 | style='Normal') 523 | 524 | for device in devices: 525 | if len(devices[device]['Interfaces']) > 0: # Don't create a table when there are no interfaces 526 | report.add_heading("\n%s Active Interfaces" % device, 4) 527 | table = report.add_table(rows=1, cols=3) 528 | hdr_cells = table.rows[0].cells 529 | hdr_cells[0].text = 'Interface' 530 | hdr_cells[1].text = 'Address' 531 | table.style = 'Medium Grid 1 Accent 1' 532 | for interface in devices[device]['Interfaces']: 533 | if 'Active' in devices[device]['Interfaces'][interface].keys(): 534 | if devices[device]['Interfaces'][interface]['Active']: 535 | if devices[device]['Interfaces'][interface]['Active'].upper() == "YES": 536 | row_cells = table.add_row().cells 537 | row_cells[0].text = "%s" % devices[device]['Interfaces'][interface]['Interface'] 538 | if 'Address' in devices[device]['Interfaces'][interface].keys(): 539 | row_cells[1].text = "%s" % devices[device]['Interfaces'][interface]['Address'] 540 | if "ACL In" in devices[device]['Interfaces'][interface].keys(): 541 | hdr_cells[2].text = 'ACL IN' 542 | if devices[device]['Interfaces'][interface]['ACL In'] is not None: 543 | row_cells[2].text = "%s" % devices[device]['Interfaces'][interface]['ACL In'] 544 | else: 545 | row_cells[2].text = "---" 546 | elif "Zone" in devices[device]['Interfaces'][interface].keys(): 547 | hdr_cells[2].text = 'Zone' 548 | if devices[device]['Interfaces'][interface]['Zone'] is not None: 549 | row_cells[2].text = "%s" % devices[device]['Interfaces'][interface]['Zone'] 550 | else: 551 | row_cells[2].text = "---" 552 | else: 553 | row_cells = table.add_row().cells 554 | row_cells[0].text = "%s" % devices[device]['Interfaces'][interface]['Interface'] 555 | if 'Address' in devices[device]['Interfaces'][interface].keys(): 556 | row_cells[1].text = "%s" % devices[device]['Interfaces'][interface]['Address'] 557 | if "ACL In" in devices[device]['Interfaces'][interface].keys(): 558 | hdr_cells[2].text = 'ACL IN' 559 | row_cells[2].text = "%s" % devices[device]['Interfaces'][interface]['ACL In'] 560 | else: 561 | hdr_cells[2].text = 'DELETE ME' 562 | row_cells[2].text = "---" 563 | else: 564 | logging.info("%s has no interfaces. An interfaces table will not be generated for this device" % device) 565 | if DEBUG: 566 | print warn + "%s has no interfaces" % device 567 | return report 568 | 569 | 570 | def write_cve(report, cves): 571 | """Write the CVE section of the report""" 572 | 573 | # Build CVE Table for report 574 | report.add_heading("Software Vulnerabilities", 3) 575 | 576 | report.add_paragraph("The assessment team identified a cumulative total of %d documented common vulnerabilities and" 577 | " exposures (CVEs) affecting the evaluated firewall devices as shown below in TABLE X. " 578 | "Additionally, the corresponding common vulnerability scoring system version two (CVSSv2) " 579 | "score is provided alongside the vulnerability identifier." % len(cves), style='Normal') 580 | 581 | table = report.add_table(rows=1, cols=3) 582 | hdr_cells = table.rows[0].cells 583 | hdr_cells[0].text = 'CVSSv2 Score' 584 | hdr_cells[1].text = 'CVE ID' 585 | hdr_cells[2].text = 'Affected Host(s)' 586 | table.style = 'Medium Grid 1 Accent 1' 587 | cve_sorted_keys = sorted(cves, key=lambda x: cves[x]['CVSSv2_Score'], reverse=True) 588 | for key in cve_sorted_keys: 589 | row_cells = table.add_row().cells 590 | row_cells[0].text = str(cves[key]['CVSSv2_Score']) 591 | row_cells[1].text = key 592 | affected_hosts = "" 593 | if cves[key]['Hosts'] is not None: 594 | for host in cves[key]['Hosts']: 595 | affected_hosts += host 596 | if len(cves[key]['Hosts']) is 1 or cves[key]['Hosts'].index(host) is (len(cves[key]['Hosts']) - 1): 597 | pass 598 | else: 599 | affected_hosts += ", " 600 | row_cells[2].text = affected_hosts 601 | 602 | return report 603 | 604 | 605 | def write_filter_rules(report, filter_rule_vulns): 606 | """Write filter rules section of the report""" 607 | 608 | report.add_heading("Overly Permissive Firewall Entries", 3) 609 | 610 | report.add_paragraph("The assessment team identified several access control lists (ACL) configured with overly " 611 | "permissive rule entries on the assessed device(s). Overly permissive rules allow a " 612 | "combination of traffic to or from ANY source IP, ANY destination IP, and/or ANY destination " 613 | "port. Rules should be configured as restrictive as possible, allowing for precise control " 614 | "of organizational traffic while facilitating business operations. Rules that allow any " 615 | "type of traffic, or traffic to any hosts, can often be more specific. Rules that allow " 616 | "traffic from untrusted sources to trusted destinations should be extremely restrictive. " 617 | "Unrestrictive entries may facilitate unauthorized access to systems or enable attackers " 618 | "to pivot through a network.", style='Normal') 619 | 620 | any_source_any_destination_table = None 621 | any_source_any_port_table = None 622 | any_destination_any_port_table = None 623 | any_port_table = None 624 | 625 | for vuln in filter_rule_vulns: 626 | if DEBUG: 627 | print filter_rule_vulns[vuln] 628 | print info + "write_filter_rules VULN: %s" % vuln 629 | raw_input(warn + "Press enter to continue") 630 | if (vuln == 'AEAA' or vuln == 'AEAE') and any_source_any_destination_table is None: 631 | report.add_heading("Any Source/Any Destination", 4) 632 | any_source_any_destination_table = report.add_table(rows=1, cols=3) 633 | hdr_cells = any_source_any_destination_table.rows[0].cells 634 | hdr_cells[0].text = 'Host' 635 | hdr_cells[1].text = 'ACL' 636 | hdr_cells[2].text = 'Rule(s)' 637 | any_source_any_destination_table.style = 'Medium Grid 1 Accent 1' 638 | if DEBUG: 639 | print info + "CREATED AEAA/AEAE TABLE" 640 | elif vuln == 'AENA' and any_source_any_port_table is None: 641 | report.add_heading("Any Source/Any Port", 4) 642 | any_source_any_port_table = report.add_table(rows=1, cols=3) 643 | hdr_cells = any_source_any_port_table.rows[0].cells 644 | hdr_cells[0].text = 'Host' 645 | hdr_cells[1].text = 'ACL' 646 | hdr_cells[2].text = 'Rule(s)' 647 | any_source_any_port_table.style = 'Medium Grid 1 Accent 1' 648 | if DEBUG: 649 | print info + "CREATED AENA TABLE" 650 | elif (vuln == 'NEAA' or vuln == 'EEAA') and any_destination_any_port_table is None: 651 | report.add_heading("Any Destination/Any Port", 4) 652 | any_destination_any_port_table = report.add_table(rows=1, cols=3) 653 | hdr_cells = any_destination_any_port_table.rows[0].cells 654 | hdr_cells[0].text = 'Host' 655 | hdr_cells[1].text = 'ACL' 656 | hdr_cells[2].text = 'Rule(s)' 657 | any_destination_any_port_table.style = 'Medium Grid 1 Accent 1' 658 | if DEBUG: 659 | print info + "CREATED NEAA/EEAA TABLE" 660 | elif vuln == 'NENA' and any_port_table is None: 661 | report.add_heading("Any Port", 4) 662 | any_port_table = report.add_table(rows=1, cols=3) 663 | hdr_cells = any_port_table.rows[0].cells 664 | hdr_cells[0].text = 'Host' 665 | hdr_cells[1].text = 'ACL' 666 | hdr_cells[2].text = 'Rule(s)' 667 | any_port_table.style = 'Medium Grid 1 Accent 1' 668 | if DEBUG: 669 | print info + "CREATED NENA TABLE" 670 | if (vuln == 'AEAA' or vuln == 'AEAE') and any_source_any_destination_table is not None: 671 | for acl in filter_rule_vulns[vuln]: 672 | row_cells = any_source_any_destination_table.add_row().cells 673 | row_cells[1].text = "%s" % acl 674 | rules = "" 675 | rule_device = None 676 | for rule in filter_rule_vulns[vuln][acl]: 677 | if len(rules) > 0: 678 | rules += ", %s" % rule 679 | else: 680 | rules += "%s" % rule 681 | if rule_device is None: 682 | if filter_rule_vulns[vuln][acl][rule]['Device']: 683 | row_cells[0].text = "%s" % filter_rule_vulns[vuln][acl][rule]['Device'] 684 | row_cells[2].text = "%s" % rules 685 | elif vuln == 'AENA' and any_source_any_port_table is not None: 686 | for acl in filter_rule_vulns[vuln]: 687 | row_cells = any_source_any_port_table.add_row().cells 688 | row_cells[1].text = "%s" % acl 689 | rules = "" 690 | rule_device = None 691 | for rule in filter_rule_vulns[vuln][acl]: 692 | if len(rules) > 0: 693 | rules += ", %s" % rule 694 | else: 695 | rules += "%s" % rule 696 | if rule_device is None: 697 | if filter_rule_vulns[vuln][acl][rule]['Device']: 698 | row_cells[0].text = "%s" % filter_rule_vulns[vuln][acl][rule]['Device'] 699 | row_cells[2].text = "%s" % rules 700 | elif (vuln == 'NEAA' or vuln == 'EEAA') and any_destination_any_port_table is not None: 701 | for acl in filter_rule_vulns[vuln]: 702 | row_cells = any_destination_any_port_table.add_row().cells 703 | row_cells[1].text = "%s" % acl 704 | rules = "" 705 | rule_device = None 706 | for rule in filter_rule_vulns[vuln][acl]: 707 | if len(rules) > 0: 708 | rules += ", %s" % rule 709 | else: 710 | rules += "%s" % rule 711 | if rule_device is None: 712 | if filter_rule_vulns[vuln][acl][rule]['Device']: 713 | row_cells[0].text = "%s" % filter_rule_vulns[vuln][acl][rule]['Device'] 714 | row_cells[2].text = "%s" % rules 715 | elif vuln == 'NENA' and any_port_table is not None: 716 | for acl in filter_rule_vulns[vuln]: 717 | row_cells = any_port_table.add_row().cells 718 | row_cells[1].text = "%s" % acl 719 | rules = "" 720 | rule_device = None 721 | for rule in filter_rule_vulns[vuln][acl]: 722 | if len(rules) > 0: 723 | rules += ", %s" % rule 724 | else: 725 | rules += "%s" % rule 726 | if rule_device is None: 727 | if filter_rule_vulns[vuln][acl][rule]['Device']: 728 | row_cells[0].text = "%s" % filter_rule_vulns[vuln][acl][rule]['Device'] 729 | row_cells[2].text = "%s" % rules 730 | return report 731 | 732 | 733 | def write_vpn_aggressive(report, vulns): 734 | """Write Aggressive mode VPN section of the report""" 735 | 736 | report.add_heading("IKE Aggressive Mode Enabled", 3) 737 | 738 | report.add_paragraph("The assessment team identified %d utilizing the Internet key exchange (IKE) protocol " 739 | "supporting aggressive mode with pre-shared key (PSK) authentication. Aggressive mode is a " 740 | "feature that condenses the connection setup by immediately sending an unencrypted " 741 | "authentication hash, which is derived using the PSK. In some instances, the PSK used to " 742 | "establish a virtual private network (VPN) connection can be recovered by performing a " 743 | "brute force attack on the authentication hash. Depending on the VPN gateway's configuration, " 744 | "this could allow an attacker to gain unauthorized access to the network.", style='Normal') 745 | 746 | for vuln in vulns: 747 | pass 748 | return report 749 | 750 | 751 | def write_weak_snmp(report, vulns): 752 | """Write the report verbiage for Weak SNMP Community String""" 753 | 754 | report.add_heading("SNMP Weak Community String", 3) 755 | 756 | report.add_paragraph("The assessment team identified %d utilizing a weak SNMP community string. SNMP community " 757 | "strings are used like a password to restrict access to a host's management data. A brute " 758 | "force attack can be used by an attacker to recover a community string, especially when it " 759 | "is weak. After the community string is recovered it can be used by an attacker to enumerate " 760 | "system information in support of other attacks, or even potentially change device " 761 | "configurations to favorable conditions for the attacker.", style='Normal') 762 | 763 | report.add_heading("SNMP Weak Community String Affected Hosts", 4) 764 | table = report.add_table(rows=1, cols=3) 765 | table.style = 'Medium Grid 1 Accent 1' 766 | hdr_cells = table.rows[0].cells 767 | hdr_cells[0].text = 'Device' 768 | hdr_cells[1].text = 'Community String' 769 | hdr_cells[2].text = 'Weakness' 770 | 771 | for device in vulns: 772 | for community in vulns[device]: 773 | row_cells = table.add_row().cells 774 | row_cells[0].text = "%s" % device 775 | row_cells[1].text = "%s" % community 776 | row_cells[2].text = "%s" % vulns[device][community]['Weakness'] 777 | 778 | report.add_paragraph("The assessment team recommends that all community strings for devices utilizing SNMP be " 779 | "changed to follow industry standards and best practices for passwords.") 780 | 781 | return report 782 | 783 | 784 | def save_report(report_object): 785 | """Save the generated assessment report""" 786 | out_dir = get_path() 787 | report_file = os.path.join(out_dir, "Nippy_Firewall_Configuraiton_Audit.docx") 788 | report_object.save(report_file) 789 | print warn + "Report saved to: " + report_file 790 | raw_input(info + "Press enter to continue...") 791 | 792 | 793 | def get_path(): 794 | """Prompt the user to enter a directory path""" 795 | 796 | output_path = None 797 | while output_path is None: 798 | print question + "Please enter the directory where you would like the file saved?" 799 | output_path = raw_input() 800 | if os.path.isdir(os.path.expanduser(output_path)): 801 | pass 802 | else: 803 | os.system('clear') 804 | print warn + "%s is not valid, please try again: " % str(output_path) 805 | output_path = None 806 | return os.path.expanduser(output_path) 807 | 808 | 809 | if __name__ == '__main__': 810 | # Parse command line arguments 811 | parser = argparse.ArgumentParser() 812 | parser.add_argument('-X', '--xml', type=argparse.FileType('r'), required=True, help="Nipper XML Database file") 813 | parser.add_argument('-v', '--verbose', action='store_true', default=False, help="Enable verbose output to console") 814 | parser.add_argument('--debug', action='store_true', default=False, help="Enable debug output to console") 815 | args = parser.parse_args() 816 | 817 | try: 818 | report_data = {'Vulns': {}} 819 | 820 | logging.debug("Reading file: %s..." % args.xml.name) 821 | if args.debug: 822 | DEBUG = True 823 | print note + "Reading %s..." % args.xml.name 824 | parse_xml(args.xml) 825 | if args.verbose: 826 | VERBOSE = True 827 | if DEBUG: 828 | nv = get_nipper_version() 829 | print info + "Nipper Version: %s" % nv 830 | 831 | report_data['Devices'] = get_devices_summary() 832 | 833 | # report_data['Devices'] = get_devices_information() # Replaced with get_devices_summary function 834 | 835 | logging.info("%s device(s) found!" % str(len(report_data['Devices']))) 836 | if VERBOSE or DEBUG: 837 | print info + "%s device(s) found!" % str(len(report_data['Devices'])) 838 | 839 | audit_sections = [] 840 | for ref in nipper_xml.findall("./report/part/[@ref='SECURITYAUDIT']/section"): 841 | audit_sections.append(ref.get('ref')) 842 | if DEBUG: 843 | print info + "Audit Sections: %s" % audit_sections 844 | raw_input(warn + "Press enter to continue") 845 | 846 | for device in report_data['Devices'].keys(): 847 | report_data['Devices'][device]['Interfaces'] = get_ipv4_interfaces(device) 848 | 849 | # Any Source, Any Destination, Any Port 850 | if "FILTER.RULE.AEAA" in audit_sections: 851 | report_data['Vulns']['AEAA'] = get_filter_rules(report_data['Devices'].keys(), "FILTER.RULE.AEAA") 852 | # Any Source, Fixed Destination, Any Port 853 | if "FILTER.RULE.AENA" in audit_sections: 854 | report_data['Vulns']['AENA'] = get_filter_rules(report_data['Devices'].keys(), "FILTER.RULE.AENA") 855 | # Fixed Source, Any Destination, Any Port 856 | if "FILTER.RULE.NEAA" in audit_sections: 857 | report_data['Vulns']['NEAA'] = get_filter_rules(report_data['Devices'].keys(), "FILTER.RULE.NEAA") 858 | # Fixed Source, Fixed Destination, Any Port 859 | if "FILTER.RULE.NENA" in audit_sections: 860 | report_data['Vulns']['NENA'] = get_filter_rules(report_data['Devices'].keys(), "FILTER.RULE.NENA") 861 | # Any Source, Any Destination 862 | if "FILTER.RULE.AEAE" in audit_sections: 863 | report_data['Vulns']['AEAE'] = get_filter_rules(report_data['Devices'].keys(), "FILTER.RULE.AEAE") 864 | # Any Destination, Any Port 865 | if "FILTER.RULE.EEAA" in audit_sections: 866 | report_data['Vulns']['EEAA'] = get_filter_rules(report_data['Devices'].keys(), "FILTER.RULE.EEAA") 867 | # Aggressive mode VPN 868 | if "REMOTEACCESS.AGGRESSIVEMODE" in audit_sections: 869 | report_data['Vulns']['REMOTEACCESS.AGGRESSIVEMODE'] = get_vpn_aggressive(report_data['Devices'].keys()) 870 | # Weak SNMP Community String 871 | if "SNMP.WEAK.COMMUNITY" in audit_sections: 872 | report_data['Vulns']['SNMP.WEAK.COMMUNITY'] = get_weak_snmp_community(report_data['Devices'].keys()) 873 | report_data['CVE'] = get_cve(report_data['Devices'].keys()) 874 | report_object = docx.Document() 875 | docx_file = write_intro(report_object, report_data['Devices']) 876 | docx_file = write_interfaces(report_object, report_data['Devices']) 877 | docx_file = write_filter_rules(report_object, report_data['Vulns']) 878 | if "SNMP.WEAK.COMMUNITY" in audit_sections: 879 | docx_file = write_weak_snmp(report_object, report_data['Vulns']['SNMP.WEAK.COMMUNITY']) 880 | # TODO Finish implementing the Aggressive Mode functionality 881 | # if report_data['Vulns']['REMOTEACCESS.AGGRESSIVEMODE'] : 882 | # docx_file = write_vpn_aggressive(docx_file, report_data['Vulns']['REMOTEACCESS.AGGRESSIVEMODE']) 883 | if len(report_data['CVE']) > 0: 884 | docx_file = write_cve(report_object, report_data['CVE']) 885 | save_report(report_object) 886 | if DEBUG: 887 | print note + "Report_Data object: ", report_data 888 | except KeyboardInterrupt: 889 | print "\n" + warn + "User Interrupt! Quitting...." 890 | except: 891 | print "\n" + warn + "Please report this error to " + __maintainer__ + " by email at: " + __email__ 892 | raise 893 | 894 | #DATA STRUCTURE OF DEVICES 895 | #report_data: {} 896 | # Devices: {} 897 | # [] 898 | # name: 899 | # type: 900 | # os: 901 | # osversion: 902 | # interfaces: {} 903 | # [] 904 | # interface: 905 | # active: 906 | # address:
907 | # aclin: 908 | # aclout: 909 | # CVE: {} 910 | # : {} 911 | # hosts: 912 | # CVSSv2_Score: 913 | # VULNS: {} 914 | # : {} 915 | # : {} 916 | # : {} 917 | # 918 | # device: 919 | -------------------------------------------------------------------------------- /record.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | #This is a script to record terminal sessions to a file 4 | #Create an alias to increase effectivness add to /etc/bash.bashrc or //.bashrc 5 | #i.e. alias record="sh /opt/record.sh" 6 | 7 | 8 | #MAIN 9 | 10 | 11 | #Make sure two arguments were recieved 12 | if [ $# -lt 2 ]; then 13 | echo "USAGE: script " 14 | exit 15 | fi 16 | 17 | #Check if help was request 18 | if [ "$1" = "-h" ]; then 19 | echo "USAGE: script " 20 | exit 21 | fi 22 | 23 | echo -e '\033[0;0;37m'" TERMINAL RECORDING STARTED FOR $1" '\033[0m' 24 | 25 | script -f "$2SHELL-LOG_$1_$(date +"%d-%b-%y_%H-%M-%S")_$(date | md5sum | head -c8).log" 26 | -------------------------------------------------------------------------------- /responder_to_hashcat.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/python 2 | #!/usr/bin/env python 3 | 4 | """Convert NTLMv2 hashes captured with Responder to Hashcat format""" 5 | 6 | import logging 7 | import argparse 8 | import sys 9 | import os 10 | import readline 11 | 12 | ################################################# 13 | # Variables # 14 | ################################################# 15 | __author__ = "Russel Van Tuyl" 16 | __license__ = "GPL" 17 | __version__ = "0.1" 18 | __maintainer__ = "Russel Van Tuyl" 19 | __email__ = "Russel.VanTuyl@gmail.com" 20 | __status__ = "Development" 21 | logging.basicConfig(stream=sys.stdout, format='%(asctime)s\t%(levelname)s\t%(message)s', 22 | datefmt='%Y-%m-%d %I:%M:%S %p', level=logging.DEBUG) # Log to STDOUT 23 | script_root = os.path.dirname(os.path.realpath(__file__)) 24 | readline.parse_and_bind('tab: complete') 25 | readline.set_completer_delims('\t') 26 | 27 | ################################################# 28 | # COLORS # 29 | ################################################# 30 | note = "\033[0;0;33m-\033[0m" 31 | warn = "\033[0;0;31m!\033[0m" 32 | info = "\033[0;0;36mi\033[0m" 33 | question = "\033[0;0;37m?\033[0m" 34 | 35 | parser = argparse.ArgumentParser() 36 | parser.add_argument('-F', '--file', type=argparse.FileType('r'), help="File containing password hashes)") 37 | parser.add_argument('-D', '--directory', help="File containing password hashes)") 38 | parser.add_argument('-O', '--output', help="File to save valid )") 39 | args = parser.parse_args() 40 | 41 | 42 | def parse_file(f): 43 | """Parse a text file for hashes""" 44 | 45 | hashcat_hashes = [] 46 | 47 | hash_file = open(f, "r") 48 | hash_file_data = hash_file.readlines() 49 | for line in hash_file_data: 50 | hash_parts = line.split(":") 51 | if len(hash_parts) is 6: 52 | if hash_parts[0].endswith("$"): 53 | print "["+warn+"]Excluding machine hash: " + hash_parts[0] 54 | else: 55 | print "["+info+"]Valid hash for: " + hash_parts[0] 56 | hashcat_hashes.append(hash_parts[0] + ":" + hash_parts[1] + ":" + hash_parts[2] + ":" + hash_parts[3] 57 | + ":" + hash_parts[4] + ":" + hash_parts[5][:106].rstrip('\n').rstrip('\r')) 58 | else: 59 | print "\n["+warn+"]ERROR: Unexpected number of hash parts" 60 | return hashcat_hashes 61 | 62 | 63 | def get_path(): 64 | """Prompt the user to enter a directory path""" 65 | 66 | output_path = None 67 | if args.output: 68 | if os.path.isdir(os.path.expanduser(args.output)): 69 | output_path = os.path.expanduser(args.output) 70 | 71 | while output_path is None: 72 | print "["+question+"]Please enter the directory where you would like the file saved?" 73 | output_path = raw_input() 74 | if os.path.isdir(os.path.expanduser(output_path)): 75 | pass 76 | else: 77 | print "["+warn+"]" + str(output_path) + " is not valid, please try again: " 78 | output_path = None 79 | 80 | return os.path.expanduser(output_path) 81 | 82 | 83 | def write_file(h): 84 | """Save hashes to a .txt file""" 85 | out_dir = get_path() 86 | hash_file = os.path.join(out_dir, "Hashcat-Hashes.txt") 87 | f = open(hash_file, 'w') 88 | for hash_item in h: 89 | f.write(hash_item + '\n') 90 | print "["+warn+"]File saved: " + hash_file 91 | 92 | if __name__ == '__main__': 93 | try: 94 | if args.file: 95 | print "["+note+"]Reading " + args.file.name + "..." 96 | hashes = parse_file(args.file.name) 97 | write_file(hashes) 98 | elif args.directory: 99 | print "["+note+"]Reading " + args.directory + "..." 100 | else: 101 | print "["+warn+"]No arguments provided!" 102 | print "["+warn+"]Try: python " + __file__ + " --help" 103 | except KeyboardInterrupt: 104 | print "\n["+warn+"]User Interrupt! Quitting...." 105 | except: 106 | print "\n["+warn+"]Please report this error to " + __maintainer__ + " by email at: " + __email__ 107 | raise -------------------------------------------------------------------------------- /shconvert.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python3 2 | 3 | ################################################# 4 | # Imports # 5 | ################################################# 6 | import os 7 | import argparse 8 | import base64 9 | 10 | ################################################# 11 | # Variables # 12 | ################################################# 13 | __author__ = "Russel Van Tuyl" 14 | __version__ = "1.0" 15 | __maintainer__ = "Russel Van Tuyl" 16 | __email__ = "Russel.VanTuyl@gmail.com" 17 | VERBOSE = False 18 | DEBUG = False 19 | 20 | ################################################# 21 | # COLORS # 22 | ################################################# 23 | note = "\033[0;0;33m[-]\033[0m" 24 | warn = "\033[0;0;31m[!]\033[0m" 25 | info = "\033[0;0;36m[i]\033[0m" 26 | question = "\033[0;0;37m[?]\033[0m" 27 | debug = "\033[0;0;31m[DEBUG]\033[0m" 28 | 29 | 30 | def convert_shellcode(): 31 | """Convert a RAW file into various output formats""" 32 | 33 | sc_data = args.readfile.read() 34 | binary_code = '' 35 | 36 | # Print in standard shellcode format \x41\x42\x43 37 | for byte in sc_data: 38 | binary_code += "\\x" + hex(byte)[2:].zfill(2) 39 | 40 | if args.standard: 41 | print(info + "Standard shellcode format:\r\n%s" % (binary_code)) 42 | if args.writefile: 43 | write_output(binary_code, "standard.shellcode.txt") 44 | 45 | cs_shellcode = "0" + ",0".join(binary_code.split("\\")[1:]) 46 | if args.csharp: 47 | print(info + "CSharp shellcode format:\r\n%s" % (cs_shellcode)) 48 | if args.writefile: 49 | write_output(cs_shellcode, 'csharp.shellcode.txt') 50 | 51 | # Base 64 encode the C# code for use with certain payloads 52 | if args.base64: 53 | encoded_cs = base64.b64encode(cs_shellcode.encode()) 54 | print(info + "CSharp Base64 encoded shellcode format:\r\n%s" % (encoded_cs.decode('ascii'))) 55 | if args.writefile: 56 | write_output(encoded_cs.decode('ascii'), "csharp.base64.shellcode.txt") 57 | 58 | 59 | def write_output(shcode, filename): 60 | 61 | """Write out the files to disk (edit this path as needed)""" 62 | with open(filename, 'w') as format_out: 63 | format_out.write(shcode) 64 | 65 | 66 | if __name__ == '__main__': 67 | """Main function for converting RAW file""" 68 | # Modified from https://github.com/ChrisTruncer/PenTestScripts/blob/master/shellcodemodifier.py 69 | 70 | parser = argparse.ArgumentParser() 71 | parser.add_argument('-r', '--readfile', type=argparse.FileType('rb'), required=True, help="Path to RAW file for conversion") 72 | parser.add_argument('-s', '--standard', action='store_true', default=False, help='Convert RAW file to standard shellcode format (i.e. \\x42\\x90)') 73 | parser.add_argument('-c','--csharp', action='store_true', default=False, help="Convert RAW file to C# style shellcode format (i.e. 0x42,0x90") 74 | parser.add_argument('-b','--base64', action='store_true', default=False, help="Convert RAW file to Base64 encoded version of the C# style shellcode format") 75 | parser.add_argument('-w','--writefile', action='store_true', default=False, help="Save output to a file in the current directory") 76 | parser.add_argument('--verbose', action='store_true', default=False, help="Enable verbose output") 77 | parser.add_argument('--debug', action='store_true', default=False, help="Enable debug output") 78 | args = parser.parse_args() 79 | 80 | DEBUG = args.debug 81 | VERBOSE = args.verbose 82 | 83 | try: 84 | convert_shellcode() 85 | 86 | except KeyboardInterrupt: 87 | print("\n" + warn + "User Interrupt! Quitting....") 88 | except SystemExit: 89 | pass 90 | except: 91 | print("\n" + warn + "Please report this error to " + __maintainer__ + " by email at: " + __email__) 92 | raise 93 | --------------------------------------------------------------------------------