├── LICENSE
├── README.md
├── TODO
├── ap_requests.py
├── ap_settings.py
├── fuzz_ap.py
├── fuzz_sta.py
├── sta_requests.py
├── sta_settings.py
├── sulley.patches
├── sulley.heuristic_patch.diff
├── sulley.repeat_patch.diff
├── sulley.truncate_patch.diff
└── sulley.wifi_patch.diff
└── wifuzzit_ap.py
/LICENSE:
--------------------------------------------------------------------------------
1 | GNU GENERAL PUBLIC LICENSE
2 | Version 3, 29 June 2007
3 |
4 | Copyright (C) 2007 Free Software Foundation, Inc.
5 | Everyone is permitted to copy and distribute verbatim copies
6 | of this license document, but changing it is not allowed.
7 |
8 | Preamble
9 |
10 | The GNU General Public License is a free, copyleft license for
11 | software and other kinds of works.
12 |
13 | The licenses for most software and other practical works are designed
14 | to take away your freedom to share and change the works. By contrast,
15 | the GNU General Public License is intended to guarantee your freedom to
16 | share and change all versions of a program--to make sure it remains free
17 | software for all its users. We, the Free Software Foundation, use the
18 | GNU General Public License for most of our software; it applies also to
19 | any other work released this way by its authors. You can apply it to
20 | your programs, too.
21 |
22 | When we speak of free software, we are referring to freedom, not
23 | price. Our General Public Licenses are designed to make sure that you
24 | have the freedom to distribute copies of free software (and charge for
25 | them if you wish), that you receive source code or can get it if you
26 | want it, that you can change the software or use pieces of it in new
27 | free programs, and that you know you can do these things.
28 |
29 | To protect your rights, we need to prevent others from denying you
30 | these rights or asking you to surrender the rights. Therefore, you have
31 | certain responsibilities if you distribute copies of the software, or if
32 | you modify it: responsibilities to respect the freedom of others.
33 |
34 | For example, if you distribute copies of such a program, whether
35 | gratis or for a fee, you must pass on to the recipients the same
36 | freedoms that you received. You must make sure that they, too, receive
37 | or can get the source code. And you must show them these terms so they
38 | know their rights.
39 |
40 | Developers that use the GNU GPL protect your rights with two steps:
41 | (1) assert copyright on the software, and (2) offer you this License
42 | giving you legal permission to copy, distribute and/or modify it.
43 |
44 | For the developers' and authors' protection, the GPL clearly explains
45 | that there is no warranty for this free software. For both users' and
46 | authors' sake, the GPL requires that modified versions be marked as
47 | changed, so that their problems will not be attributed erroneously to
48 | authors of previous versions.
49 |
50 | Some devices are designed to deny users access to install or run
51 | modified versions of the software inside them, although the manufacturer
52 | can do so. This is fundamentally incompatible with the aim of
53 | protecting users' freedom to change the software. The systematic
54 | pattern of such abuse occurs in the area of products for individuals to
55 | use, which is precisely where it is most unacceptable. Therefore, we
56 | have designed this version of the GPL to prohibit the practice for those
57 | products. If such problems arise substantially in other domains, we
58 | stand ready to extend this provision to those domains in future versions
59 | of the GPL, as needed to protect the freedom of users.
60 |
61 | Finally, every program is threatened constantly by software patents.
62 | States should not allow patents to restrict development and use of
63 | software on general-purpose computers, but in those that do, we wish to
64 | avoid the special danger that patents applied to a free program could
65 | make it effectively proprietary. To prevent this, the GPL assures that
66 | patents cannot be used to render the program non-free.
67 |
68 | The precise terms and conditions for copying, distribution and
69 | modification follow.
70 |
71 | TERMS AND CONDITIONS
72 |
73 | 0. Definitions.
74 |
75 | "This License" refers to version 3 of the GNU General Public License.
76 |
77 | "Copyright" also means copyright-like laws that apply to other kinds of
78 | works, such as semiconductor masks.
79 |
80 | "The Program" refers to any copyrightable work licensed under this
81 | License. Each licensee is addressed as "you". "Licensees" and
82 | "recipients" may be individuals or organizations.
83 |
84 | To "modify" a work means to copy from or adapt all or part of the work
85 | in a fashion requiring copyright permission, other than the making of an
86 | exact copy. The resulting work is called a "modified version" of the
87 | earlier work or a work "based on" the earlier work.
88 |
89 | A "covered work" means either the unmodified Program or a work based
90 | on the Program.
91 |
92 | To "propagate" a work means to do anything with it that, without
93 | permission, would make you directly or secondarily liable for
94 | infringement under applicable copyright law, except executing it on a
95 | computer or modifying a private copy. Propagation includes copying,
96 | distribution (with or without modification), making available to the
97 | public, and in some countries other activities as well.
98 |
99 | To "convey" a work means any kind of propagation that enables other
100 | parties to make or receive copies. Mere interaction with a user through
101 | a computer network, with no transfer of a copy, is not conveying.
102 |
103 | An interactive user interface displays "Appropriate Legal Notices"
104 | to the extent that it includes a convenient and prominently visible
105 | feature that (1) displays an appropriate copyright notice, and (2)
106 | tells the user that there is no warranty for the work (except to the
107 | extent that warranties are provided), that licensees may convey the
108 | work under this License, and how to view a copy of this License. If
109 | the interface presents a list of user commands or options, such as a
110 | menu, a prominent item in the list meets this criterion.
111 |
112 | 1. Source Code.
113 |
114 | The "source code" for a work means the preferred form of the work
115 | for making modifications to it. "Object code" means any non-source
116 | form of a work.
117 |
118 | A "Standard Interface" means an interface that either is an official
119 | standard defined by a recognized standards body, or, in the case of
120 | interfaces specified for a particular programming language, one that
121 | is widely used among developers working in that language.
122 |
123 | The "System Libraries" of an executable work include anything, other
124 | than the work as a whole, that (a) is included in the normal form of
125 | packaging a Major Component, but which is not part of that Major
126 | Component, and (b) serves only to enable use of the work with that
127 | Major Component, or to implement a Standard Interface for which an
128 | implementation is available to the public in source code form. A
129 | "Major Component", in this context, means a major essential component
130 | (kernel, window system, and so on) of the specific operating system
131 | (if any) on which the executable work runs, or a compiler used to
132 | produce the work, or an object code interpreter used to run it.
133 |
134 | The "Corresponding Source" for a work in object code form means all
135 | the source code needed to generate, install, and (for an executable
136 | work) run the object code and to modify the work, including scripts to
137 | control those activities. However, it does not include the work's
138 | System Libraries, or general-purpose tools or generally available free
139 | programs which are used unmodified in performing those activities but
140 | which are not part of the work. For example, Corresponding Source
141 | includes interface definition files associated with source files for
142 | the work, and the source code for shared libraries and dynamically
143 | linked subprograms that the work is specifically designed to require,
144 | such as by intimate data communication or control flow between those
145 | subprograms and other parts of the work.
146 |
147 | The Corresponding Source need not include anything that users
148 | can regenerate automatically from other parts of the Corresponding
149 | Source.
150 |
151 | The Corresponding Source for a work in source code form is that
152 | same work.
153 |
154 | 2. Basic Permissions.
155 |
156 | All rights granted under this License are granted for the term of
157 | copyright on the Program, and are irrevocable provided the stated
158 | conditions are met. This License explicitly affirms your unlimited
159 | permission to run the unmodified Program. The output from running a
160 | covered work is covered by this License only if the output, given its
161 | content, constitutes a covered work. This License acknowledges your
162 | rights of fair use or other equivalent, as provided by copyright law.
163 |
164 | You may make, run and propagate covered works that you do not
165 | convey, without conditions so long as your license otherwise remains
166 | in force. You may convey covered works to others for the sole purpose
167 | of having them make modifications exclusively for you, or provide you
168 | with facilities for running those works, provided that you comply with
169 | the terms of this License in conveying all material for which you do
170 | not control copyright. Those thus making or running the covered works
171 | for you must do so exclusively on your behalf, under your direction
172 | and control, on terms that prohibit them from making any copies of
173 | your copyrighted material outside their relationship with you.
174 |
175 | Conveying under any other circumstances is permitted solely under
176 | the conditions stated below. Sublicensing is not allowed; section 10
177 | makes it unnecessary.
178 |
179 | 3. Protecting Users' Legal Rights From Anti-Circumvention Law.
180 |
181 | No covered work shall be deemed part of an effective technological
182 | measure under any applicable law fulfilling obligations under article
183 | 11 of the WIPO copyright treaty adopted on 20 December 1996, or
184 | similar laws prohibiting or restricting circumvention of such
185 | measures.
186 |
187 | When you convey a covered work, you waive any legal power to forbid
188 | circumvention of technological measures to the extent such circumvention
189 | is effected by exercising rights under this License with respect to
190 | the covered work, and you disclaim any intention to limit operation or
191 | modification of the work as a means of enforcing, against the work's
192 | users, your or third parties' legal rights to forbid circumvention of
193 | technological measures.
194 |
195 | 4. Conveying Verbatim Copies.
196 |
197 | You may convey verbatim copies of the Program's source code as you
198 | receive it, in any medium, provided that you conspicuously and
199 | appropriately publish on each copy an appropriate copyright notice;
200 | keep intact all notices stating that this License and any
201 | non-permissive terms added in accord with section 7 apply to the code;
202 | keep intact all notices of the absence of any warranty; and give all
203 | recipients a copy of this License along with the Program.
204 |
205 | You may charge any price or no price for each copy that you convey,
206 | and you may offer support or warranty protection for a fee.
207 |
208 | 5. Conveying Modified Source Versions.
209 |
210 | You may convey a work based on the Program, or the modifications to
211 | produce it from the Program, in the form of source code under the
212 | terms of section 4, provided that you also meet all of these conditions:
213 |
214 | a) The work must carry prominent notices stating that you modified
215 | it, and giving a relevant date.
216 |
217 | b) The work must carry prominent notices stating that it is
218 | released under this License and any conditions added under section
219 | 7. This requirement modifies the requirement in section 4 to
220 | "keep intact all notices".
221 |
222 | c) You must license the entire work, as a whole, under this
223 | License to anyone who comes into possession of a copy. This
224 | License will therefore apply, along with any applicable section 7
225 | additional terms, to the whole of the work, and all its parts,
226 | regardless of how they are packaged. This License gives no
227 | permission to license the work in any other way, but it does not
228 | invalidate such permission if you have separately received it.
229 |
230 | d) If the work has interactive user interfaces, each must display
231 | Appropriate Legal Notices; however, if the Program has interactive
232 | interfaces that do not display Appropriate Legal Notices, your
233 | work need not make them do so.
234 |
235 | A compilation of a covered work with other separate and independent
236 | works, which are not by their nature extensions of the covered work,
237 | and which are not combined with it such as to form a larger program,
238 | in or on a volume of a storage or distribution medium, is called an
239 | "aggregate" if the compilation and its resulting copyright are not
240 | used to limit the access or legal rights of the compilation's users
241 | beyond what the individual works permit. Inclusion of a covered work
242 | in an aggregate does not cause this License to apply to the other
243 | parts of the aggregate.
244 |
245 | 6. Conveying Non-Source Forms.
246 |
247 | You may convey a covered work in object code form under the terms
248 | of sections 4 and 5, provided that you also convey the
249 | machine-readable Corresponding Source under the terms of this License,
250 | in one of these ways:
251 |
252 | a) Convey the object code in, or embodied in, a physical product
253 | (including a physical distribution medium), accompanied by the
254 | Corresponding Source fixed on a durable physical medium
255 | customarily used for software interchange.
256 |
257 | b) Convey the object code in, or embodied in, a physical product
258 | (including a physical distribution medium), accompanied by a
259 | written offer, valid for at least three years and valid for as
260 | long as you offer spare parts or customer support for that product
261 | model, to give anyone who possesses the object code either (1) a
262 | copy of the Corresponding Source for all the software in the
263 | product that is covered by this License, on a durable physical
264 | medium customarily used for software interchange, for a price no
265 | more than your reasonable cost of physically performing this
266 | conveying of source, or (2) access to copy the
267 | Corresponding Source from a network server at no charge.
268 |
269 | c) Convey individual copies of the object code with a copy of the
270 | written offer to provide the Corresponding Source. This
271 | alternative is allowed only occasionally and noncommercially, and
272 | only if you received the object code with such an offer, in accord
273 | with subsection 6b.
274 |
275 | d) Convey the object code by offering access from a designated
276 | place (gratis or for a charge), and offer equivalent access to the
277 | Corresponding Source in the same way through the same place at no
278 | further charge. You need not require recipients to copy the
279 | Corresponding Source along with the object code. If the place to
280 | copy the object code is a network server, the Corresponding Source
281 | may be on a different server (operated by you or a third party)
282 | that supports equivalent copying facilities, provided you maintain
283 | clear directions next to the object code saying where to find the
284 | Corresponding Source. Regardless of what server hosts the
285 | Corresponding Source, you remain obligated to ensure that it is
286 | available for as long as needed to satisfy these requirements.
287 |
288 | e) Convey the object code using peer-to-peer transmission, provided
289 | you inform other peers where the object code and Corresponding
290 | Source of the work are being offered to the general public at no
291 | charge under subsection 6d.
292 |
293 | A separable portion of the object code, whose source code is excluded
294 | from the Corresponding Source as a System Library, need not be
295 | included in conveying the object code work.
296 |
297 | A "User Product" is either (1) a "consumer product", which means any
298 | tangible personal property which is normally used for personal, family,
299 | or household purposes, or (2) anything designed or sold for incorporation
300 | into a dwelling. In determining whether a product is a consumer product,
301 | doubtful cases shall be resolved in favor of coverage. For a particular
302 | product received by a particular user, "normally used" refers to a
303 | typical or common use of that class of product, regardless of the status
304 | of the particular user or of the way in which the particular user
305 | actually uses, or expects or is expected to use, the product. A product
306 | is a consumer product regardless of whether the product has substantial
307 | commercial, industrial or non-consumer uses, unless such uses represent
308 | the only significant mode of use of the product.
309 |
310 | "Installation Information" for a User Product means any methods,
311 | procedures, authorization keys, or other information required to install
312 | and execute modified versions of a covered work in that User Product from
313 | a modified version of its Corresponding Source. The information must
314 | suffice to ensure that the continued functioning of the modified object
315 | code is in no case prevented or interfered with solely because
316 | modification has been made.
317 |
318 | If you convey an object code work under this section in, or with, or
319 | specifically for use in, a User Product, and the conveying occurs as
320 | part of a transaction in which the right of possession and use of the
321 | User Product is transferred to the recipient in perpetuity or for a
322 | fixed term (regardless of how the transaction is characterized), the
323 | Corresponding Source conveyed under this section must be accompanied
324 | by the Installation Information. But this requirement does not apply
325 | if neither you nor any third party retains the ability to install
326 | modified object code on the User Product (for example, the work has
327 | been installed in ROM).
328 |
329 | The requirement to provide Installation Information does not include a
330 | requirement to continue to provide support service, warranty, or updates
331 | for a work that has been modified or installed by the recipient, or for
332 | the User Product in which it has been modified or installed. Access to a
333 | network may be denied when the modification itself materially and
334 | adversely affects the operation of the network or violates the rules and
335 | protocols for communication across the network.
336 |
337 | Corresponding Source conveyed, and Installation Information provided,
338 | in accord with this section must be in a format that is publicly
339 | documented (and with an implementation available to the public in
340 | source code form), and must require no special password or key for
341 | unpacking, reading or copying.
342 |
343 | 7. Additional Terms.
344 |
345 | "Additional permissions" are terms that supplement the terms of this
346 | License by making exceptions from one or more of its conditions.
347 | Additional permissions that are applicable to the entire Program shall
348 | be treated as though they were included in this License, to the extent
349 | that they are valid under applicable law. If additional permissions
350 | apply only to part of the Program, that part may be used separately
351 | under those permissions, but the entire Program remains governed by
352 | this License without regard to the additional permissions.
353 |
354 | When you convey a copy of a covered work, you may at your option
355 | remove any additional permissions from that copy, or from any part of
356 | it. (Additional permissions may be written to require their own
357 | removal in certain cases when you modify the work.) You may place
358 | additional permissions on material, added by you to a covered work,
359 | for which you have or can give appropriate copyright permission.
360 |
361 | Notwithstanding any other provision of this License, for material you
362 | add to a covered work, you may (if authorized by the copyright holders of
363 | that material) supplement the terms of this License with terms:
364 |
365 | a) Disclaiming warranty or limiting liability differently from the
366 | terms of sections 15 and 16 of this License; or
367 |
368 | b) Requiring preservation of specified reasonable legal notices or
369 | author attributions in that material or in the Appropriate Legal
370 | Notices displayed by works containing it; or
371 |
372 | c) Prohibiting misrepresentation of the origin of that material, or
373 | requiring that modified versions of such material be marked in
374 | reasonable ways as different from the original version; or
375 |
376 | d) Limiting the use for publicity purposes of names of licensors or
377 | authors of the material; or
378 |
379 | e) Declining to grant rights under trademark law for use of some
380 | trade names, trademarks, or service marks; or
381 |
382 | f) Requiring indemnification of licensors and authors of that
383 | material by anyone who conveys the material (or modified versions of
384 | it) with contractual assumptions of liability to the recipient, for
385 | any liability that these contractual assumptions directly impose on
386 | those licensors and authors.
387 |
388 | All other non-permissive additional terms are considered "further
389 | restrictions" within the meaning of section 10. If the Program as you
390 | received it, or any part of it, contains a notice stating that it is
391 | governed by this License along with a term that is a further
392 | restriction, you may remove that term. If a license document contains
393 | a further restriction but permits relicensing or conveying under this
394 | License, you may add to a covered work material governed by the terms
395 | of that license document, provided that the further restriction does
396 | not survive such relicensing or conveying.
397 |
398 | If you add terms to a covered work in accord with this section, you
399 | must place, in the relevant source files, a statement of the
400 | additional terms that apply to those files, or a notice indicating
401 | where to find the applicable terms.
402 |
403 | Additional terms, permissive or non-permissive, may be stated in the
404 | form of a separately written license, or stated as exceptions;
405 | the above requirements apply either way.
406 |
407 | 8. Termination.
408 |
409 | You may not propagate or modify a covered work except as expressly
410 | provided under this License. Any attempt otherwise to propagate or
411 | modify it is void, and will automatically terminate your rights under
412 | this License (including any patent licenses granted under the third
413 | paragraph of section 11).
414 |
415 | However, if you cease all violation of this License, then your
416 | license from a particular copyright holder is reinstated (a)
417 | provisionally, unless and until the copyright holder explicitly and
418 | finally terminates your license, and (b) permanently, if the copyright
419 | holder fails to notify you of the violation by some reasonable means
420 | prior to 60 days after the cessation.
421 |
422 | Moreover, your license from a particular copyright holder is
423 | reinstated permanently if the copyright holder notifies you of the
424 | violation by some reasonable means, this is the first time you have
425 | received notice of violation of this License (for any work) from that
426 | copyright holder, and you cure the violation prior to 30 days after
427 | your receipt of the notice.
428 |
429 | Termination of your rights under this section does not terminate the
430 | licenses of parties who have received copies or rights from you under
431 | this License. If your rights have been terminated and not permanently
432 | reinstated, you do not qualify to receive new licenses for the same
433 | material under section 10.
434 |
435 | 9. Acceptance Not Required for Having Copies.
436 |
437 | You are not required to accept this License in order to receive or
438 | run a copy of the Program. Ancillary propagation of a covered work
439 | occurring solely as a consequence of using peer-to-peer transmission
440 | to receive a copy likewise does not require acceptance. However,
441 | nothing other than this License grants you permission to propagate or
442 | modify any covered work. These actions infringe copyright if you do
443 | not accept this License. Therefore, by modifying or propagating a
444 | covered work, you indicate your acceptance of this License to do so.
445 |
446 | 10. Automatic Licensing of Downstream Recipients.
447 |
448 | Each time you convey a covered work, the recipient automatically
449 | receives a license from the original licensors, to run, modify and
450 | propagate that work, subject to this License. You are not responsible
451 | for enforcing compliance by third parties with this License.
452 |
453 | An "entity transaction" is a transaction transferring control of an
454 | organization, or substantially all assets of one, or subdividing an
455 | organization, or merging organizations. If propagation of a covered
456 | work results from an entity transaction, each party to that
457 | transaction who receives a copy of the work also receives whatever
458 | licenses to the work the party's predecessor in interest had or could
459 | give under the previous paragraph, plus a right to possession of the
460 | Corresponding Source of the work from the predecessor in interest, if
461 | the predecessor has it or can get it with reasonable efforts.
462 |
463 | You may not impose any further restrictions on the exercise of the
464 | rights granted or affirmed under this License. For example, you may
465 | not impose a license fee, royalty, or other charge for exercise of
466 | rights granted under this License, and you may not initiate litigation
467 | (including a cross-claim or counterclaim in a lawsuit) alleging that
468 | any patent claim is infringed by making, using, selling, offering for
469 | sale, or importing the Program or any portion of it.
470 |
471 | 11. Patents.
472 |
473 | A "contributor" is a copyright holder who authorizes use under this
474 | License of the Program or a work on which the Program is based. The
475 | work thus licensed is called the contributor's "contributor version".
476 |
477 | A contributor's "essential patent claims" are all patent claims
478 | owned or controlled by the contributor, whether already acquired or
479 | hereafter acquired, that would be infringed by some manner, permitted
480 | by this License, of making, using, or selling its contributor version,
481 | but do not include claims that would be infringed only as a
482 | consequence of further modification of the contributor version. For
483 | purposes of this definition, "control" includes the right to grant
484 | patent sublicenses in a manner consistent with the requirements of
485 | this License.
486 |
487 | Each contributor grants you a non-exclusive, worldwide, royalty-free
488 | patent license under the contributor's essential patent claims, to
489 | make, use, sell, offer for sale, import and otherwise run, modify and
490 | propagate the contents of its contributor version.
491 |
492 | In the following three paragraphs, a "patent license" is any express
493 | agreement or commitment, however denominated, not to enforce a patent
494 | (such as an express permission to practice a patent or covenant not to
495 | sue for patent infringement). To "grant" such a patent license to a
496 | party means to make such an agreement or commitment not to enforce a
497 | patent against the party.
498 |
499 | If you convey a covered work, knowingly relying on a patent license,
500 | and the Corresponding Source of the work is not available for anyone
501 | to copy, free of charge and under the terms of this License, through a
502 | publicly available network server or other readily accessible means,
503 | then you must either (1) cause the Corresponding Source to be so
504 | available, or (2) arrange to deprive yourself of the benefit of the
505 | patent license for this particular work, or (3) arrange, in a manner
506 | consistent with the requirements of this License, to extend the patent
507 | license to downstream recipients. "Knowingly relying" means you have
508 | actual knowledge that, but for the patent license, your conveying the
509 | covered work in a country, or your recipient's use of the covered work
510 | in a country, would infringe one or more identifiable patents in that
511 | country that you have reason to believe are valid.
512 |
513 | If, pursuant to or in connection with a single transaction or
514 | arrangement, you convey, or propagate by procuring conveyance of, a
515 | covered work, and grant a patent license to some of the parties
516 | receiving the covered work authorizing them to use, propagate, modify
517 | or convey a specific copy of the covered work, then the patent license
518 | you grant is automatically extended to all recipients of the covered
519 | work and works based on it.
520 |
521 | A patent license is "discriminatory" if it does not include within
522 | the scope of its coverage, prohibits the exercise of, or is
523 | conditioned on the non-exercise of one or more of the rights that are
524 | specifically granted under this License. You may not convey a covered
525 | work if you are a party to an arrangement with a third party that is
526 | in the business of distributing software, under which you make payment
527 | to the third party based on the extent of your activity of conveying
528 | the work, and under which the third party grants, to any of the
529 | parties who would receive the covered work from you, a discriminatory
530 | patent license (a) in connection with copies of the covered work
531 | conveyed by you (or copies made from those copies), or (b) primarily
532 | for and in connection with specific products or compilations that
533 | contain the covered work, unless you entered into that arrangement,
534 | or that patent license was granted, prior to 28 March 2007.
535 |
536 | Nothing in this License shall be construed as excluding or limiting
537 | any implied license or other defenses to infringement that may
538 | otherwise be available to you under applicable patent law.
539 |
540 | 12. No Surrender of Others' Freedom.
541 |
542 | If conditions are imposed on you (whether by court order, agreement or
543 | otherwise) that contradict the conditions of this License, they do not
544 | excuse you from the conditions of this License. If you cannot convey a
545 | covered work so as to satisfy simultaneously your obligations under this
546 | License and any other pertinent obligations, then as a consequence you may
547 | not convey it at all. For example, if you agree to terms that obligate you
548 | to collect a royalty for further conveying from those to whom you convey
549 | the Program, the only way you could satisfy both those terms and this
550 | License would be to refrain entirely from conveying the Program.
551 |
552 | 13. Use with the GNU Affero General Public License.
553 |
554 | Notwithstanding any other provision of this License, you have
555 | permission to link or combine any covered work with a work licensed
556 | under version 3 of the GNU Affero General Public License into a single
557 | combined work, and to convey the resulting work. The terms of this
558 | License will continue to apply to the part which is the covered work,
559 | but the special requirements of the GNU Affero General Public License,
560 | section 13, concerning interaction through a network will apply to the
561 | combination as such.
562 |
563 | 14. Revised Versions of this License.
564 |
565 | The Free Software Foundation may publish revised and/or new versions of
566 | the GNU General Public License from time to time. Such new versions will
567 | be similar in spirit to the present version, but may differ in detail to
568 | address new problems or concerns.
569 |
570 | Each version is given a distinguishing version number. If the
571 | Program specifies that a certain numbered version of the GNU General
572 | Public License "or any later version" applies to it, you have the
573 | option of following the terms and conditions either of that numbered
574 | version or of any later version published by the Free Software
575 | Foundation. If the Program does not specify a version number of the
576 | GNU General Public License, you may choose any version ever published
577 | by the Free Software Foundation.
578 |
579 | If the Program specifies that a proxy can decide which future
580 | versions of the GNU General Public License can be used, that proxy's
581 | public statement of acceptance of a version permanently authorizes you
582 | to choose that version for the Program.
583 |
584 | Later license versions may give you additional or different
585 | permissions. However, no additional obligations are imposed on any
586 | author or copyright holder as a result of your choosing to follow a
587 | later version.
588 |
589 | 15. Disclaimer of Warranty.
590 |
591 | THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY
592 | APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT
593 | HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY
594 | OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO,
595 | THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
596 | PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM
597 | IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF
598 | ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
599 |
600 | 16. Limitation of Liability.
601 |
602 | IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
603 | WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS
604 | THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY
605 | GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE
606 | USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF
607 | DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD
608 | PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS),
609 | EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF
610 | SUCH DAMAGES.
611 |
612 | 17. Interpretation of Sections 15 and 16.
613 |
614 | If the disclaimer of warranty and limitation of liability provided
615 | above cannot be given local legal effect according to their terms,
616 | reviewing courts shall apply local law that most closely approximates
617 | an absolute waiver of all civil liability in connection with the
618 | Program, unless a warranty or assumption of liability accompanies a
619 | copy of the Program in return for a fee.
620 |
621 | END OF TERMS AND CONDITIONS
622 |
623 | How to Apply These Terms to Your New Programs
624 |
625 | If you develop a new program, and you want it to be of the greatest
626 | possible use to the public, the best way to achieve this is to make it
627 | free software which everyone can redistribute and change under these terms.
628 |
629 | To do so, attach the following notices to the program. It is safest
630 | to attach them to the start of each source file to most effectively
631 | state the exclusion of warranty; and each file should have at least
632 | the "copyright" line and a pointer to where the full notice is found.
633 |
634 |
635 | Copyright (C)
636 |
637 | This program is free software: you can redistribute it and/or modify
638 | it under the terms of the GNU General Public License as published by
639 | the Free Software Foundation, either version 3 of the License, or
640 | (at your option) any later version.
641 |
642 | This program is distributed in the hope that it will be useful,
643 | but WITHOUT ANY WARRANTY; without even the implied warranty of
644 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
645 | GNU General Public License for more details.
646 |
647 | You should have received a copy of the GNU General Public License
648 | along with this program. If not, see .
649 |
650 | Also add information on how to contact you by electronic and paper mail.
651 |
652 | If the program does terminal interaction, make it output a short
653 | notice like this when it starts in an interactive mode:
654 |
655 | Copyright (C)
656 | This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
657 | This is free software, and you are welcome to redistribute it
658 | under certain conditions; type `show c' for details.
659 |
660 | The hypothetical commands `show w' and `show c' should show the appropriate
661 | parts of the General Public License. Of course, your program's commands
662 | might be different; for a GUI interface, you would use an "about box".
663 |
664 | You should also get your employer (if you work as a programmer) or school,
665 | if any, to sign a "copyright disclaimer" for the program, if necessary.
666 | For more information on this, and how to apply and follow the GNU GPL, see
667 | .
668 |
669 | The GNU General Public License does not permit incorporating your program
670 | into proprietary programs. If your program is a subroutine library, you
671 | may consider it more useful to permit linking proprietary applications with
672 | the library. If this is what you want to do, use the GNU Lesser General
673 | Public License instead of this License. But first, please read
674 | .
675 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # wifuzzit
2 | ## (a 802.11 wireless fuzzer)
3 |
4 | * Written and maintained by Laurent Butti
5 | * Released under terms and conditions of the GNU GPLv3 license
6 |
7 | # What is wifuzzit?
8 |
9 | Wifuzzit is a wireless fuzzer focused on 802.11 technology. It aims at discovering 802.11 implementation bugs both on access points and stations. It relies on the infamous Sulley Fuzzing Framework and thus is a model-based fuzzer.
10 |
11 | Basically, it supports stateful fuzzing which is a strong requirement especially when fuzzing access point implementations.
12 |
13 | Wifuzzit is able to operate autonomously and only requires some configuration tuning and minor manual operations to run.
14 |
15 | Wifuzzit is the fruit of several generations of wireless fuzzers previously developped that found loads of 802.11 implementation bugs (mainly during 2006-2009). Nowadays, any (r|d)ecent 802.11 implementation should be robust against this fuzzer. Anyway, if you find a vulnerability thanks to this fuzzer, please credit it.
16 |
17 | As far as I know, it is the only Open Source 802.11 wireless fuzzer that supports both AP and STA stateful fuzzing with a model-based approach and which was proven to be successfull.
18 |
19 | This fuzzer and its previous generations were able to discover loads of vulnerabilities, some of them were ethically disclosed and thus have a CVE number (see _Discovered Vulnerabilities_ section).
20 |
21 | # Requirements and configuration
22 |
23 | As wifuzzit relies on [Sulley](https://github.com/OpenRCE/sulley), you have to set up `PYTHONPATH` appropriately to include [Sulley].
24 |
25 | You also have to patch Sulley with provided patches.
26 |
27 | Two options to operate fuzzing:
28 | * use `fuzz_ap.py` or `fuzz_sta.py` respectively with `ap_settings.py` and `sta_settings.py` configuration files ;
29 | * use `wifuzzit_ap.py` or `wifuzzit_sta.py` (currently not implemented) command-line tools.
30 |
31 | Settings and command-line options are quite straightforward.
32 |
33 | # Monitor mode
34 |
35 | Setting the monitor mode and appropriate channel is left to wifuzzit's user. Wifuzzit should be fully functional on any wireless card with injection capabilities but wifuzzit was only tested with Atheros chipsets (such as the AR5212) and madwifi drivers. You have to set up wireless monitor mode without any preamble headers (radiotap, prism or any other).
36 |
37 | For madwifi drivers, this could be set thanks to:
38 |
39 | `sysctl -w net.ath0.dev_type=801`
40 |
41 | # STA fuzzing: instrumentation
42 |
43 | The obvious requirement is that the station must not be associated to any access point. This may be sometimes a tricky part as you must instrument the target (station wireless driver) to initiate active scanning without any association to an Open access point. This could be done thanks to `iwlist iface scan` as a privilieged user. On Windows, using Netstumbler is usually good for that task. On other devices, you could observe the scanning process and tweak the fuzzer configuration to send the fuzzed testcases during a certain timeslot.
44 |
45 | As the fuzzer has to be sure that fuzzed packets will be parsed by the wireless driver, the whole fuzzing process may take a lof of time.
46 |
47 | # AP fuzzing: instrumentation
48 |
49 | No instrumentation is needed here, but as some access points tend to become unstable, they may need a manual reboot. One opportunity is to instrument the access point thanks to an IP power device to be driven by this fuzzer. Remember, a fuzzing campaign must be autonomous!
50 |
51 | Comparing to STA fuzzing, time required for a full fuzz testing campaign is quite short (usually several hours), but of course, you have to test several configurations of your access point (open, WPA-PSK, WPA-EAP, RSN-PSK, RSN-EAP) to ensure enough testing coverage.
52 |
53 | # Discovered vulnerabilities
54 |
55 | Here is a list of wireless implementation bugs discovered by our preliminary versions of wireless fuzzers including wifuzzit. Notably, it found CVE-2006-6059, probably the first (public) remotely exploitable 802.11 wireless driver for Linux (madwifi); and CVE-2007-5651, one of the first (public) EAP-based implementation bug that affected both 802.1X wired and wireless devices. It also discovered a set of wireless driver access point implementation bugs which was quite new in 2007.
56 |
57 | * [CVE-2009-0052](http://cve.mitre.org/cgi-bin/cvename.cgi?name=CVE-2009-0052): Atheros Driver Reserved Frame Vulnerability (Wireless AP)
58 | * [CVE-2008-4441](http://cve.mitre.org/cgi-bin/cvename.cgi?name=CVE-2008-4441): Marvell Driver Malformed Association Request Vulnerability (Wireless AP)
59 | * [CVE-2008-1197](http://cve.mitre.org/cgi-bin/cvename.cgi?name=CVE-2008-1197): Marvell Driver Null SSID Association Request Vulnerability (Wireless AP)
60 | * [CVE-2008-1144](http://cve.mitre.org/cgi-bin/cvename.cgi?name=CVE-2008-1144): Marvell Driver EAPoL-Key Length Overflow (Wireless AP)
61 | * [CVE-2007-5651](http://cve.mitre.org/cgi-bin/cvename.cgi?name=CVE-2007-5651): Extensible Authentication Protocol Vulnerability (Cisco's Wireless AP and Wired Switches)
62 | * [CVE-2007-5475](http://cve.mitre.org/cgi-bin/cvename.cgi?name=CVE-2007-5475): Marvell Driver Multiple Information Element Overflows (Wireless AP)
63 | * [CVE-2007-5474](http://cve.mitre.org/cgi-bin/cvename.cgi?name=CVE-2007-5474): Atheros Vendor Specific Information Element Overflow (Wireless AP)
64 | * [CVE-2007-0933](http://cve.mitre.org/cgi-bin/cvename.cgi?name=CVE-2007-0933): Buffer overflow in the wireless driver 6.0.0.18 for D-Link DWL-G650+ (Wireless STA)
65 | * [CVE-2006-6332](http://cve.mitre.org/cgi-bin/cvename.cgi?name=CVE-2006-6332): Stack-based buffer overflow in net80211/ieee80211_wireless.c in MadWifi before 0.9.2.1 (Wireless STA) - [This bug was proven to be remotely exploitable](http://www.metasploit.com/modules/exploit/linux/madwifi/madwifi_giwscan_cb).
66 | * [CVE-2006-6125](http://cve.mitre.org/cgi-bin/cvename.cgi?name=CVE-2006-6125): Heap-based buffer overflow in the wireless driver (WG311ND5.SYS) 2.3.1.10 for NetGear WG311v1 (Wireless STA)
67 | * [CVE-2006-6059](http://cve.mitre.org/cgi-bin/cvename.cgi?name=CVE-2006-6059): Buffer overflow in MA521nd5.SYS driver 5.148.724.2003 for NetGear MA521 (Wireless STA)
68 |
69 | # Current limitations
70 |
71 | This fuzzer does not automagically generate PoC for discovered bugs. You have to instrument Sulley to replay appropriate test case that crashed the wireless driver (AP or STA). In the case of "stateful vulnerabilities", you have to manually pass 802.11 states thanks to a dedicated script that would be re-used for every discovered vulnerability.
72 |
73 | Other vulnerabilities are much more tricky to replay, e.g. when a wireless driver becomes unstable after a (particular) ordered set of packets, you then have to manually identify offending packets thanks to a network capture.
74 |
75 | # Future improvements
76 |
77 | This software is provided as-is and improvements may occur depending on my motivation and spare time. Of course, feedbacks and contributions are welcome.
78 |
79 | # References
80 |
81 | * Laurent Butti - [Wi-Fi Advanced Fuzzing (Black Hat Europe 2007)](https://www.blackhat.com/presentations/bh-europe-07/Butti/Presentation/bh-eu-07-Butti.pdf)
82 | * Laurent Butti and Julien Tinnès - [Recherche de vulnérabilités dans les drivers 802.11 par techniques de fuzzing (SSTIC 2007)](http://actes.sstic.org/SSTIC07/WiFi_Fuzzing/)
83 | * Laurent Butti and Julien Tinnès - [Discovering and Exploiting Wireless Driver Vulnerabilities](http://www.springerlink.com/content/w423l0q5m04j5225/?MUD=MP)
84 | * Laurent Butti, Julien Tinnès and Franck Veysset - [Wi-Fi Implementation Bugs: an Era of New Vulnerabilities (Hack.LU 2007)](https://www.cr0.org/paper/hacklu2007-final.pdf)
85 |
--------------------------------------------------------------------------------
/TODO:
--------------------------------------------------------------------------------
1 | * multiple drivers for injection should be tested
2 | * implement other fuzz testing strategies (802.11n, 802.11e, WPS...)
3 | * implement support for radiotap/prism headers
4 | * merge common functions in a common lib
5 | * remove ugly settings and globals to replace with cmdline capabilities
6 | * fix resume issues
7 |
--------------------------------------------------------------------------------
/ap_requests.py:
--------------------------------------------------------------------------------
1 | from sulley import *
2 | from ap_settings import *
3 |
4 | # Ripped from scapy
5 | def mac2str(mac):
6 | return "".join(map(lambda x: chr(int(x,16)), mac.split(":")))
7 |
8 | ouis = ['\x00P\xf2\x02', '\x00@\x96\x04', '\x00P\xf2\x01', '\x00\x90L4', '\x00@\x96\x03', '\x00@\x96\x01', '\x00@\x96\x0c', '\x00\x0b\x0e\x02', '\x00@\x96\x0b', '\x00\x90L3', '\x00\x03\x7f\x01', '\x00\x03/\x01', '\x00\x03\x7f\x02', '\x00\x03\x93\x01', '\x00\x10\x18\x01', '\x00\x10\x18\x02', '\x00\x03\x7f\x03']
9 |
10 | # Defining the padding value
11 | PADDING = "\xFF"
12 | RATES = "\x02\x04\x0B\x16\x0c\x18\x30\x48"
13 | XRATES = "\x32\x04\x30\x48\x60\x6c"
14 | ssid = "\x00" + chr(len(SSID)) + SSID
15 | rates = "\x01" + chr(len(RATES)) + RATES
16 |
17 | WPA_PSK = "\x00\x50\xF2" # WPA OUI
18 | WPA_PSK += "\x01" # WPA Type
19 | WPA_PSK += "\x01\x00" # WPA Version
20 | WPA_PSK += "\x00\x50\xF2\x02" # TKIP
21 | WPA_PSK += "\x01\x00" # Number of unicast ciphers
22 | WPA_PSK += "\x00\x50\xF2\x02" # TKIP
23 | WPA_PSK += "\x01\x00" # Number of authentication methods
24 | WPA_PSK += "\x00\x50\xF2\x02" # PSK Authentication
25 | WPA_PSK_IE = "\xDD" + chr(len(WPA_PSK)) + WPA_PSK
26 | WPA_EAP_IE = WPA_PSK_IE[:-4] + "\x00\x50\xF2\x01"
27 |
28 | RSN_PSK = "\x01\x00" # RSN Version
29 | RSN_PSK += "\x00\x0F\xAC\x04" # CCMP
30 | RSN_PSK += "\x01\x00" # Number of unicast ciphers
31 | RSN_PSK += "\x00\x0F\xAC\x04" # CCMP
32 | RSN_PSK += "\x01\x00" # Number of authentication methods
33 | RSN_PSK += "\x00\x0F\xAC\x02" # PSK Authentication
34 | RSN_PSK_IE = "\x30" + chr(len(RSN_PSK)) + RSN_PSK
35 | RSN_EAP_IE = RSN_PSK_IE[:-4] + "\x00\x0F\xAC\x01"
36 |
37 | AUTH_REQ_OPEN = "\xB0" # Type/Subtype
38 | AUTH_REQ_OPEN += "\x00" # Flags
39 | AUTH_REQ_OPEN += "\x3A\x01" # Duration ID
40 | AUTH_REQ_OPEN += mac2str(AP_MAC) # Destination address
41 | AUTH_REQ_OPEN += mac2str(STA_MAC) # Source address
42 | AUTH_REQ_OPEN += mac2str(AP_MAC) # BSSID
43 | AUTH_REQ_OPEN += "\x00\x00" # Sequence control
44 | AUTH_REQ_OPEN += "\x00\x00" # Authentication algorithm (open)
45 | AUTH_REQ_OPEN += "\x01\x00" # Authentication sequence number
46 | AUTH_REQ_OPEN += "\x00\x00" # Authentication status
47 | AUTH_REQ_HDR = AUTH_REQ_OPEN[:-6]
48 |
49 | ASSO_REQ_OPEN = "\x00" # Type/Subtype
50 | ASSO_REQ_OPEN += "\x00" # Flags
51 | ASSO_REQ_OPEN += "\x3A\x01" # Duration ID
52 | ASSO_REQ_OPEN += mac2str(AP_MAC) # Destination address
53 | ASSO_REQ_OPEN += mac2str(STA_MAC) # Source address
54 | ASSO_REQ_OPEN += mac2str(AP_MAC) # BSSID
55 | ASSO_REQ_OPEN += "\x00\x00" # Sequence control
56 | ASSO_REQ_OPEN += "\x01\x00" # Capability information (ESS) FIXME
57 | ASSO_REQ_OPEN += "\x64\x00" # Listen interval
58 | ASSO_REQ_OPEN += ssid # SSID information element
59 | ASSO_REQ_OPEN += rates # RATES information element
60 | ASSO_REQ_HDR = ASSO_REQ_OPEN[:-len(ssid)-len(rates)]
61 |
62 | DEAUTH = "\xC0" # Type/Subtype
63 | DEAUTH += "\x00" # Flags
64 | DEAUTH += "\x3A\x01" # Duration ID
65 | DEAUTH += mac2str(AP_MAC) # Destination address
66 | DEAUTH += mac2str(STA_MAC) # Source address
67 | DEAUTH += mac2str(AP_MAC) # BSSID
68 | DEAUTH += "\x00\x00" # Sequence control
69 | DEAUTH += "\x02\x00" # Reason code
70 |
71 | ASSO_REQ_WPA_PSK = ASSO_REQ_OPEN + WPA_PSK_IE
72 | ASSO_REQ_WPA_EAP = ASSO_REQ_OPEN + WPA_EAP_IE
73 | ASSO_REQ_RSN_PSK = ASSO_REQ_OPEN + RSN_PSK_IE
74 | ASSO_REQ_RSN_EAP = ASSO_REQ_OPEN + RSN_EAP_IE
75 |
76 | EAPOL_KEY_HDR = "\x08" # Type/Subtype
77 | EAPOL_KEY_HDR += "\x01" # Flags
78 | EAPOL_KEY_HDR += "\x3A\x01" # Duration ID
79 | EAPOL_KEY_HDR += mac2str(AP_MAC) # Destination Address
80 | EAPOL_KEY_HDR += mac2str(STA_MAC) # Source Address
81 | EAPOL_KEY_HDR += mac2str(AP_MAC) # BSSID Address
82 | EAPOL_KEY_HDR += "\x00\x00" # Sequence Control
83 | EAPOL_KEY_HDR += "\xAA\xAA" # DSAP/SSAP
84 | EAPOL_KEY_HDR += "\x03" # Control Field
85 | EAPOL_KEY_HDR += "\x00\x00\x00" # Organization Code
86 | EAPOL_KEY_HDR += "\x88\x8E" # Type
87 |
88 | def alen(n):
89 | return n / 4
90 |
91 | # Used if heuristic patch applied to Sulley
92 | def h(min_len, max_len):
93 | l = range(min_len, min_len + 33)
94 | l += [63, 64, 65]
95 | l += [127, 128, 129]
96 | l += range(max_len - 5, max_len)
97 | return l
98 |
99 | def information_element_header(name, iei, truncate=TRUNCATE):
100 | s_byte(iei, fuzzable=False) # IEI
101 | s_size(name, length=1, name='%s Length' % name, fuzzable=True) # Length
102 | return s_block_start(name, truncate=truncate)
103 |
104 | def string_element(name, iei, content=''):
105 | if information_element_header(name, iei):
106 | s_string(content, 0, 255, max_len=255)
107 | s_block_end()
108 | s_repeat(name, 0, 1024, 50)
109 |
110 | def random_element(name, iei, content=''):
111 | if information_element_header(name, iei):
112 | # Used if heuristic patch applied to Sulley
113 | # s_random(content, 0, 255, heuristic=h)
114 | s_random(content, 0, 255)
115 | s_block_end()
116 | s_repeat(name, 0, 1024, 50)
117 |
118 | def oui_element(name, iei, content=''):
119 | if information_element_header(name, iei):
120 | s_static(content)
121 | # Used if heuristic patch applied to Sulley
122 | # s_random('', 0, 255 - len(content), heuristic=h)
123 | s_random('', 0, 255 - len(content))
124 | s_block_end()
125 | s_repeat(name, 0, 1024, 50)
126 |
127 | #############################
128 | # FUZZING TESTING SCENARIOS #
129 | #############################
130 |
131 | s_initialize("AssoReq: WPA-PSK")
132 | s_static(ASSO_REQ_OPEN)
133 | if s_block_start('AssoReq: WPA-PSK', truncate=TRUNCATE):
134 | s_static(WPA_PSK_IE)
135 | s_block_end()
136 |
137 | s_initialize("AssoReq: WPA-EAP")
138 | s_static(ASSO_REQ_OPEN)
139 | if s_block_start('AssoReq: WPA-EAP', truncate=TRUNCATE):
140 | s_static(WPA_EAP_IE)
141 | s_block_end()
142 |
143 | s_initialize("AssoReq: RSN-PSK")
144 | s_static(ASSO_REQ_OPEN)
145 | if s_block_start('AssoReq: RSN-PSK', truncate=TRUNCATE):
146 | s_static(RSN_PSK_IE)
147 | s_block_end()
148 |
149 | s_initialize("AssoReq: RSN-EAP")
150 | s_static(ASSO_REQ_OPEN)
151 | if s_block_start('AssoReq: RSN-EAP', truncate=TRUNCATE):
152 | s_static(RSN_EAP_IE)
153 | s_block_end()
154 |
155 | # AssoReq with most used IEs fuzzed
156 | s_initialize("AssoReq: Open")
157 | if s_block_start('AssoReq: Open', truncate=TRUNCATE):
158 | s_static(ASSO_REQ_HDR)
159 | string_element("SSID", 0, content=SSID) # Fuzzing SSID
160 | random_element("RATES", 1, content=RATES) # Fuzzing RATES
161 | random_element("XRATES", 50, content=XRATES) # Fuzzing XRATES
162 | s_block_end()
163 |
164 | s_initialize("AssoReq: Garbage")
165 | s_static(ASSO_REQ_HDR)
166 | if s_block_start('AssoReq: Garbage', truncate=TRUNCATE):
167 | s_static(PADDING * 100)
168 | s_block_end()
169 |
170 | # Fuzzing With Malformed Frames
171 | for state in ["1", "2", "3"]:
172 | for type_subtype in range(256):
173 | s_initialize("Fuzzy %s: Malformed %d" % (state, type_subtype))
174 | s_byte(type_subtype) # Type/Subtype
175 | if s_block_start('Fuzzy %s: Malformed %d' % (state, type_subtype), truncate=TRUNCATE):
176 | s_byte(0x00, fuzzable=False) # Flags
177 | s_static("\x3A\x01") # Duration ID
178 | s_static(mac2str(AP_MAC)) # Destination Address
179 | s_static(mac2str(STA_MAC)) # Source Address
180 | s_static(mac2str(AP_MAC)) # BSSID Address
181 | s_random(PADDING * 10, 0, 1024, step=25) # Garbage
182 | s_block_end()
183 |
184 | list_ies = range(2, 256)
185 | for i in [50]:
186 | list_ies.remove(i)
187 |
188 | # AssoReq with all IEs fuzzed
189 | for ie in list_ies:
190 | s_initialize("AssoReq: IE %d" % ie)
191 | s_static(ASSO_REQ_OPEN)
192 | random_element("IE", ie) # Fuzzing IE
193 |
194 | # Fuzzing Vendor Specific IE
195 | for oui in ouis:
196 | s_initialize("AssoReq: Vendor Specific %s" % oui)
197 | s_static(ASSO_REQ_OPEN)
198 | oui_element("IE", 221, content=oui) # Fuzzing IE
199 |
200 | s_initialize("AuthReq: Open")
201 | s_static(AUTH_REQ_HDR)
202 | s_word(0x0000, fuzzable=True) # Authentication Algorithm (Open)
203 | s_word(0x0001, fuzzable=True) # Authentication Sequence Number
204 | s_word(0x0000, fuzzable=True) # Authentication Status
205 | s_random("", 0, 1024)
206 |
207 | s_initialize("EAPoL-Key: WPA-PSK")
208 | s_static(EAPOL_KEY_HDR)
209 | s_byte(0x01, fuzzable=True) # Version 1
210 | s_byte(0x03, fuzzable=True) # Type key
211 | s_size("Content", length=2, endian='>', fuzzable=True) # Length
212 | if s_block_start("Content", truncate=TRUNCATE):
213 | s_byte(0xFE, fuzzable=False) # Descriptor Type
214 | s_word(0x0901, fuzzable=False) # Key Information
215 | s_word(0x2000, fuzzable=True) # Key Length (0x0020: TKIP, 0x0010: CCMP)
216 | s_qword(0x0100000000000000, fuzzable=False) # Replay Counter
217 | s_static("A"*32) # Nonce
218 | s_static("B"*16) # Key IV
219 | s_static("\x00"*8) # WPA Key RSC
220 | s_static("\x01"*8) # WPA Key ID
221 | s_static("\x02"*16) # WPA Key MIC
222 | s_size("WPA IE", length=2, endian='>', fuzzable=True) # WPA IE Length
223 | if s_block_start("WPA IE", truncate=TRUNCATE):
224 | s_static(WPA_PSK_IE) # WPA IE
225 | s_block_end()
226 | s_block_end()
227 |
228 | s_initialize("EAPoL-Key: RSN-PSK")
229 | s_static(EAPOL_KEY_HDR)
230 | s_byte(0x01, fuzzable=True) # Version 1
231 | s_byte(0x03, fuzzable=True) # Type key
232 | s_size("Content", length=2, endian='>', fuzzable=True) # Length
233 | if s_block_start("Content", truncate=TRUNCATE):
234 | s_byte(0x02, fuzzable=False) # Descriptor Type
235 | s_word(0x0A01, fuzzable=False) # Key Information
236 | s_word(0x1000, fuzzable=True) # Key Length (0x0020: TKIP, 0x0010: CCMP)
237 | s_qword(0x0100000000000000, fuzzable=False) # Replay Counter
238 | s_static("A"*32) # Nonce
239 | s_static("B"*16) # Key IV
240 | s_static("\x00"*8) # WPA Key RSC
241 | s_static("\x01"*8) # WPA Key ID
242 | s_static("\x02"*16) # WPA Key MIC
243 | s_size("RSN IE", length=2, endian='>', fuzzable=True) # WPA IE Length
244 | if s_block_start("RSN IE", truncate=TRUNCATE):
245 | s_static(RSN_PSK_IE) # RSN IE
246 | s_block_end()
247 | s_block_end()
248 |
249 | s_initialize("EAPoL-Start: WPA-EAP")
250 | s_static(EAPOL_KEY_HDR)
251 | # 802.1X header
252 | s_byte(0x01, fuzzable=False) # Version 1
253 | s_byte(0x01, fuzzable=False) # Type Start
254 | s_word(0x0000, fuzzable=True) # Length
255 |
256 | s_initialize("EAPoL-Start: RSN-EAP")
257 | s_static(EAPOL_KEY_HDR)
258 | # 802.1X header
259 | s_byte(0x01, fuzzable=False) # Version 1
260 | s_byte(0x01, fuzzable=False) # Type Start
261 | s_word(0x0000, fuzzable=True) # Length
262 |
263 | for method in ['WPA-PSK', 'WPA-EAP', 'RSN-PSK', 'RSN-EAP']:
264 |
265 | if method == 'WPA-PSK':
266 | IE = "\xDD"
267 | HDR = "\x00\x50\xF2" + "\x01" + "\x01\x00" + "\x00\x50\xF2\x02"
268 | UCAST_CIPHER = "\x00\x50\xF2\x02"
269 | AUTH_METHOD = "\x00\x50\xF2\x02"
270 | elif method == 'WPA-EAP':
271 | IE = "\xDD"
272 | HDR = "\x00\x50\xF2" + "\x01" + "\x01\x00" + "\x00\x50\xF2\x02"
273 | UCAST_CIPHER = "\x00\x50\xF2\x02"
274 | AUTH_METHOD = "\x00\x50\xF2\x01"
275 | elif method == 'RSN-PSK':
276 | IE = "\x30"
277 | HDR = "\x01\x00" + "\x00\x0F\xAC\x04"
278 | UCAST_CIPHER = "\x00\x0F\xAC\x04"
279 | AUTH_METHOD = "\x00\x0F\xAC\x02"
280 | elif method == 'RSN-EAP':
281 | IE = "\x30"
282 | HDR = "\x01\x00" + "\x00\x0F\xAC\x04"
283 | UCAST_CIPHER = "\x00\x0F\xAC\x04"
284 | AUTH_METHOD = "\x00\x0F\xAC\x01"
285 |
286 | s_initialize("AssoReq: %s Fuzzing" % method)
287 | s_static(ASSO_REQ_OPEN)
288 | s_static(IE)
289 | s_size("%s IE" % method, length=1, fuzzable=True)
290 | if s_block_start('%s IE' % method, truncate=TRUNCATE):
291 | s_static(HDR)
292 | s_size("Unicast Ciphers", length=2, fuzzable=True, math=alen)
293 | if s_block_start("Unicast Ciphers", truncate=TRUNCATE):
294 | if s_block_start("Unicast Cipher", truncate=TRUNCATE):
295 | s_static(UCAST_CIPHER)
296 | s_block_end()
297 | s_repeat("Unicast Cipher", 0, 1024, 50)
298 | s_block_end()
299 | s_size("Authentication Methods", length=2, fuzzable=True, math=alen)
300 | if s_block_start("Authentication Methods", truncate=TRUNCATE):
301 | if s_block_start("Authentication Method", truncate=TRUNCATE):
302 | s_static(AUTH_METHOD)
303 | s_block_end()
304 | s_repeat("Authentication Method", 0, 1024, 50)
305 | s_block_end()
306 | s_random("", 0, 1024)
307 | s_block_end()
308 |
309 | # Several testing strategies to be implemented:
310 | # Probe requests+Authentications: state unauthenticated
311 | # WMM Information Element Parser
312 | # 802.11n Information Element Parser
313 | #FIXME: data packets (flags WEP...)
314 | #FIXME: Short AssoReq w/ WEP Flag
315 | # Full AssoReq with filled IEs (to the MTU)
316 | # Full AssoReq with empty IEs (to the MTU)
317 | # Full AssoReq with 1 byte IEs (to the MTU)
318 |
--------------------------------------------------------------------------------
/ap_settings.py:
--------------------------------------------------------------------------------
1 | # Define variables
2 | # SETTINGS is [ (AP_NUMBER, SAVE_RESULTS, SKIP) ]
3 |
4 | TEST_SETTINGS_INDEX = 3
5 |
6 | SETTINGS = [
7 | (0, 0, 0),
8 | ]
9 |
10 | # Defining the fuzzing MAC address device
11 | STA_MAC = "00:20:A6:61:2D:09"
12 |
13 | # Defining the injection interface
14 | IFACE = "ath0"
15 |
16 | ##### BELOW VARIABLES SHOULD NOT BE TWEAKED BY THE USER
17 |
18 | AP_NUMBER = SETTINGS[TEST_SETTINGS_INDEX][0]
19 | SAVE_RESULTS = SETTINGS[TEST_SETTINGS_INDEX][1]
20 | SKIP = SETTINGS[TEST_SETTINGS_INDEX][2]
21 |
22 | # Defining fuzzing specific variables
23 | AP = [
24 | ('kikoo', '00:11:22:33:44:55', 11, 'WPA-PSK'),
25 | ][AP_NUMBER]
26 |
27 | SSID = AP[0]
28 | AP_MAC = AP[1]
29 | CHANNEL = chr(AP[2])
30 | AP_CONFIG = AP[3]
31 |
32 | # Defining the number of retries when authenticating/associating to the AP
33 | CRASH_RETRIES = 10
34 | DELAY = 1
35 | STATE_WAIT_TIME = 2
36 | DELAY_REBOOT = 10
37 | LOG_LEVEL = 3
38 | CRASH_THRESHOLD = 3
39 | TRUNCATE = True
40 |
41 | # Defining the log file
42 | FNAME = [None, 'audits/ap-%s-%s.session' % (AP_MAC, AP_CONFIG)][SAVE_RESULTS]
43 |
--------------------------------------------------------------------------------
/fuzz_ap.py:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env python
2 |
3 | from sulley import *
4 | from ap_settings import *
5 | from ap_requests import *
6 | import socket
7 | import time
8 | import struct
9 |
10 | # Assume that wireless card is in monitor mode on appropriate channel
11 | # Saves from lot of dependencies (lorcon, pylorcon...)
12 |
13 | def is_alive():
14 |
15 | global IFACE, AUTH_REQ_OPEN
16 | ETH_P_ALL = 3
17 |
18 | def isresp(pkt):
19 | resp = False
20 | if (len(pkt) >= 30 and pkt[0] == "\xB0"\
21 | and pkt[4:10] == mac2str(STA_MAC)\
22 | and pkt[28:30] == "\x00\x00"):
23 | resp = True
24 | return resp
25 |
26 | s = socket.socket(socket.AF_PACKET, socket.SOCK_RAW, socket.htons(ETH_P_ALL))
27 | s.bind((IFACE, ETH_P_ALL))
28 |
29 | sess.log("checking aliveness of fuzzed access point %s" % AP_MAC, level=3)
30 |
31 | retries = CRASH_RETRIES
32 | alive = False
33 |
34 | while retries:
35 |
36 | s.send(AUTH_REQ_OPEN)
37 |
38 | start_time = time.time()
39 | while (time.time() - start_time) < 1:
40 | ans = s.recv(1024)
41 | alive = isresp(ans)
42 | if alive:
43 | s.send(DEAUTH)
44 | s.close()
45 | if retries != CRASH_RETRIES:
46 | sess.log("retried authentication %d times" % (CRASH_RETRIES - retries), level=1)
47 | return alive
48 |
49 | retries -= 1
50 |
51 | s.close()
52 |
53 | return alive
54 |
55 | def check_alive(s):
56 |
57 | global AUTH_REQ_OPEN
58 |
59 | def isresp(pkt):
60 | resp = False
61 | if (len(pkt) >= 30 and pkt[0] == "\xB0"\
62 | and pkt[4:10] == mac2str(STA_MAC)\
63 | and pkt[28:30] == "\x00\x00"):
64 | resp = True
65 | return resp
66 |
67 | sess.log("checking aliveness of fuzzed access point %s" % AP_MAC, level=3)
68 |
69 | while True:
70 | t = s.send(AUTH_REQ_OPEN)
71 | start_time = time.time()
72 | while (time.time() - start_time) < 1:
73 | alive = isresp(s.recv(1024))
74 | if alive:
75 | return alive
76 | sess.log("waiting for the access point to be up", level=1)
77 | time.sleep(DELAY_REBOOT)
78 |
79 | def pass_state(s):
80 | '''
81 | '''
82 | return True
83 |
84 | def clean_state(s):
85 |
86 | global DEAUTH
87 |
88 | s.send(DEAUTH)
89 | sess.log("sending deauthentication to come back to initial state", level=3)
90 |
91 | # shameless ripped from scapy
92 | def hexdump(x):
93 | x=str(x)
94 | l = len(x)
95 | i = 0
96 | while i < l:
97 | print "%04x " % i,
98 | for j in range(16):
99 | if i+j < l:
100 | print "%02X" % ord(x[i+j]),
101 | else:
102 | print " ",
103 | if j%16 == 7:
104 | print "",
105 | print " ",
106 | print x[i:i+16]
107 | i += 16
108 |
109 | def check_auth(session, node, edge, sock):
110 |
111 | def isresp(pkt):
112 | resp = False
113 | if (len(pkt) >= 30 and pkt[0] == "\xB0"\
114 | and pkt[4:10] == mac2str(STA_MAC)\
115 | and pkt[28:30] == "\x00\x00"):
116 | resp = True
117 | return resp
118 |
119 | start_time = time.time()
120 | while (time.time() - start_time) < STATE_WAIT_TIME:
121 | pkt = sock.recv(1024)
122 | ans = isresp(pkt)
123 | if ans:
124 | sess.log("authentication successfull with %s" % AP_MAC, level=3)
125 | return
126 |
127 | sess.log("authentication not successfull with %s" % AP_MAC, level=1)
128 |
129 | if session.fuzz_node.mutant != None:
130 | '''
131 | print "XXXXX : session.fuzz_node.name %s" % session.fuzz_node.name
132 | print "XXXXX : session.fuzz_node.mutant_index %d" % session.fuzz_node.mutant_index
133 | print "XXXXX : session.fuzz_node.mutant.mutant_index %d" % session.fuzz_node.mutant.mutant_index
134 | print "XXXXX : session.fuzz_node.num_mutations() %d" % session.fuzz_node.num_mutations()
135 | print "XXXXX : session.total_mutant_index %d" % session.total_mutant_index
136 | '''
137 | sess.log("re-trying the current test case", level=1)
138 | session.fuzz_node.mutant_index -= 1
139 | session.fuzz_node.mutant.mutant_index -= 1
140 | session.total_mutant_index -= 1
141 |
142 | def check_asso(session, node, edge, sock):
143 |
144 | def isresp(pkt):
145 | resp = False
146 | if (len(pkt) >= 30 and pkt[0] == "\x10"\
147 | and pkt[4:10] == mac2str(STA_MAC)\
148 | and pkt[26:28] == "\x00\x00"):
149 | resp = True
150 | return resp
151 |
152 | start_time = time.time()
153 | while (time.time() - start_time) < STATE_WAIT_TIME:
154 | pkt = sock.recv(1024)
155 | ans = isresp(pkt)
156 | if ans:
157 | sess.log("association successfull with %s" % AP_MAC, level=3)
158 | return
159 |
160 | sess.log("association not successfull with %s" % AP_MAC, level=1)
161 | if session.fuzz_node.mutant != None:
162 | '''
163 | print "XXXXX : session.fuzz_node.name %s" % session.fuzz_node.name
164 | print "XXXXX : session.fuzz_node.mutant_index %d" % session.fuzz_node.mutant_index
165 | print "XXXXX : session.fuzz_node.mutant.mutant_index %d" % session.fuzz_node.mutant.mutant_index
166 | print "XXXXX : session.fuzz_node.num_mutations() %d" % session.fuzz_node.num_mutations()
167 | print "XXXXX : session.total_mutant_index %d" % session.total_mutant_index
168 | '''
169 | sess.log("re-trying the current test case", level=1)
170 | session.fuzz_node.mutant_index -= 1
171 | session.fuzz_node.mutant.mutant_index -= 1
172 | session.total_mutant_index -= 1
173 |
174 | ###############
175 |
176 | # Defining the transport protocol
177 | sess = sessions.session(session_filename=FNAME, proto="wifi", timeout=5.0, sleep_time=0.1, log_level=LOG_LEVEL, skip=SKIP, crash_threshold=CRASH_THRESHOLD)
178 |
179 | # Defining the target
180 | target = sessions.target(AP_MAC, 0)
181 |
182 | # Adding the detect_crash function for target monitoring
183 | target.procmon = instrumentation.external(post=is_alive)
184 |
185 | # Adding a check for alive of access point
186 | sess.pre_send = check_alive
187 |
188 | # Adding a deauth send to come back to initial state
189 | sess.post_send = clean_state
190 |
191 | # Adding the IFACE for socket binding
192 | sess.wifi_iface = IFACE
193 |
194 | # Adding the target to the fuzzing session
195 | sess.add_target(target)
196 |
197 | # Fuzzing State "Not Authenticated, Not Associated"
198 |
199 | sess.connect(s_get("AuthReq: Open"))
200 |
201 | for type_subtype in range(256): # 256
202 | sess.connect(s_get("Fuzzy 1: Malformed %d" % type_subtype))
203 |
204 | # Fuzzing State "Authenticated, Not Associated"
205 | sess.connect(s_get("AuthReq: Open"), s_get("AssoReq: Garbage"), callback=check_auth) # Checking Authentication
206 | sess.connect(s_get("AuthReq: Open"), s_get("AssoReq: Open"), callback=check_auth) # Checking Authentication
207 | sess.connect(s_get("AuthReq: Open"), s_get("AssoReq: %s" % AP_CONFIG), callback=check_auth) # Checking Authentication
208 | if AP_CONFIG not in ['Open']:
209 | sess.connect(s_get("AuthReq: Open"), s_get("AssoReq: %s Fuzzing" % AP_CONFIG ), callback=check_auth) # Checking Authentication
210 |
211 | for oui in ouis:
212 | sess.connect(s_get("AuthReq: Open"), s_get("AssoReq: Vendor Specific %s" % oui), callback=check_auth)
213 |
214 | for ie in list_ies:
215 | sess.connect(s_get("AuthReq: Open"), s_get("AssoReq: IE %d" % ie), callback=check_auth)
216 |
217 | for type_subtype in range(256):
218 | sess.connect(s_get("AuthReq: Open"), s_get("Fuzzy 2: Malformed %d" % type_subtype), callback=check_auth)
219 |
220 | # Fuzzing State : "Authenticated, Associated"
221 |
222 | for type_subtype in range(256):
223 | sess.connect(s_get("AssoReq: %s" % AP_CONFIG), s_get("Fuzzy 3: Malformed %d" % type_subtype), callback=check_asso)
224 |
225 | if AP_CONFIG in ['WPA-PSK', 'RSN-PSK']:
226 | sess.connect(s_get("AssoReq: %s" % AP_CONFIG), s_get("EAPoL-Key: %s" % AP_CONFIG), callback=check_asso)
227 |
228 | if AP_CONFIG in ['WPA-EAP', 'RSN-EAP']:
229 | sess.connect(s_get("AssoReq: %s" % AP_CONFIG), s_get("EAPoL-Start: %s" % AP_CONFIG), callback=check_asso)
230 |
231 | # Launching the fuzzing campaign
232 | sess.fuzz()
233 |
--------------------------------------------------------------------------------
/fuzz_sta.py:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env python
2 |
3 | from sulley import *
4 | from sta_settings import *
5 | from sta_requests import *
6 | import socket
7 | import time
8 | import struct
9 |
10 | # Assume that wireless card is in monitor mode on appropriate channel
11 | # Saves from lot of dependencies (lorcon, pylorcon...)
12 |
13 | def listen(s):
14 | """
15 | Returns whenever STA active scanning is detected.
16 | """
17 | global STA_MAC
18 |
19 | def isscan(pkt):
20 | if len(pkt) >= 24:
21 | if pkt[0] == "\x40" and pkt[10:16] == mac2str(STA_MAC):
22 | return True
23 | return False
24 |
25 | sess.log("waiting for active scanning from %s" % STA_MAC)
26 | while True:
27 | ans = s.recv(1024)
28 | answered = isscan(ans)
29 | if answered:
30 | sess.log("active scanning detected from %s" % STA_MAC)
31 | return True
32 |
33 | def is_alive():
34 |
35 | global IFACE
36 | ETH_P_ALL = 3
37 |
38 | def isscan(pkt):
39 | if len(pkt) >= 24:
40 | if pkt[0] == "\x40" and pkt[10:16] == mac2str(STA_MAC):
41 | return True
42 | return False
43 |
44 | s = socket.socket(socket.AF_PACKET, socket.SOCK_RAW, socket.htons(ETH_P_ALL))
45 | s.bind((IFACE, ETH_P_ALL))
46 |
47 | alive = False
48 | sess.log("waiting for active scanning from %s" % STA_MAC)
49 | start_time = time.time()
50 |
51 | while (time.time() - start_time < LISTEN_TIME):
52 | ans = s.recv(1024)
53 | if isscan(ans):
54 | alive = True
55 | break
56 |
57 | return alive
58 |
59 | # Defining the transport protocol
60 | sess = sessions.session(session_filename=FNAME, proto="wifi", repeat_time=REPEAT_TIME, timeout=5.0, sleep_time=0, skip=SKIP)
61 |
62 | # Defining the target
63 | target = sessions.target(STA_MAC, 0)
64 |
65 | # Defining the instrumentation
66 | target.procmon = instrumentation.external(post=is_alive)
67 |
68 | # Adding the listen() function for target monitoring
69 | sess.pre_send = listen
70 |
71 | # Adding the IFACE for socket binding
72 | sess.wifi_iface = IFACE
73 |
74 | # Adding the target to the fuzzing session
75 | sess.add_target(target)
76 |
77 | # Adding tests
78 | sess.connect(s_get("ProbeResp: Most Used IEs"))
79 |
80 | for ie in list_ies:
81 | sess.connect(s_get("ProbeResp: IE %d" % ie))
82 |
83 | sess.connect(s_get("ProbeResp: Malformed"))
84 |
85 | for type_subtype in range(256):
86 | sess.connect(s_get("Fuzzy: Malformed %d" % type_subtype))
87 |
88 | for oui in ouis:
89 | sess.connect(s_get("ProbeResp: Vendor Specific %s" % oui))
90 |
91 | for method in ['WPA-PSK', 'RSN-PSK', 'WPA-EAP', 'RSN-EAP']:
92 | sess.connect(s_get("ProbeResp: %s Fuzzing" % method))
93 |
94 | # Launching the fuzzing campaign
95 | sess.fuzz()
96 |
--------------------------------------------------------------------------------
/sta_requests.py:
--------------------------------------------------------------------------------
1 | from sulley import *
2 | from sta_settings import *
3 |
4 | # Ripped from scapy
5 | def mac2str(mac):
6 | return "".join(map(lambda x: chr(int(x,16)), mac.split(":")))
7 |
8 | ouis = ['\x00P\xf2\x02', '\x00@\x96\x04', '\x00P\xf2\x01', '\x00\x90L4', '\x00@\x96\x03', '\x00@\x96\x01', '\x00@\x96\x0c', '\x00\x0b\x0e\x02', '\x00@\x96\x0b', '\x00\x90L3', '\x00\x03\x7f\x01', '\x00\x03/\x01', '\x00\x03\x7f\x02', '\x00\x03\x93\x01', '\x00\x10\x18\x01', '\x00\x10\x18\x02', '\x00\x03\x7f\x03']
9 |
10 | RATES = "\x02\x04\x0B\x16\x0c\x18\x30\x48"
11 | TIM = "\x00\x01\x00\x08"
12 | ERP42 = "\x04"
13 | ERP47 = "\x00"
14 | XRATES = "\x32\x04\x30\x48\x60\x6c"
15 |
16 | PROBE_RESP = "\x50"
17 | PROBE_RESP += "\x00"
18 | PROBE_RESP += "\x3A\x01"
19 | PROBE_RESP += "\x00"
20 | PROBE_RESP += mac2str(STA_MAC) # Destination Address
21 | PROBE_RESP += mac2str(AP_MAC) # Source Address
22 | PROBE_RESP += mac2str(AP_MAC) # BSSID Address
23 | PROBE_RESP += "\x00\x00" # Sequence Control
24 | PROBE_RESP += "\x00\x00\x00\x00\x01\x00\x00\x00" # Timestamp
25 | PROBE_RESP += "\x01\x00" # Beacon Interval
26 | PROBE_RESP += "\x01\x00" # Capabilities
27 | PROBE_RESP += "\x00" + chr(len(SSID)) + SSID # SSID
28 | PROBE_RESP += "\x01" + chr(len(RATES)) + RATES # RATES
29 | PROBE_RESP += "\x03" + "\x01" + CHANNEL # CHANNEL
30 |
31 | def alen(n):
32 | return n / 4
33 |
34 | def h(min_len, max_len):
35 | l = range(min_len, min_len + 33)
36 | l += [63, 64, 65]
37 | l += [127, 128, 129]
38 | l += range(max_len - 5, max_len)
39 | return l
40 |
41 | def information_element_header(name, iei, truncate=TRUNCATE):
42 | s_byte(iei, fuzzable=False) # IEI
43 | s_size(name, length=1, name='%s Length' % name, fuzzable=True) # Length
44 | return s_block_start(name, truncate=truncate)
45 |
46 | def string_element(name, iei, content=''):
47 | if information_element_header(name, iei):
48 | s_string(content, 0, 255, max_len=255)
49 | s_block_end()
50 | s_repeat(name, 0, 1024, 50)
51 |
52 | def random_element(name, iei, content=''): #FIXME: length minus content will not be elected
53 | if information_element_header(name, iei):
54 | s_static(content)
55 | # Used if heuristic patch applied to Sulley
56 | # s_random("", 0, 255 - len(content), heuristic=h)
57 | s_random("", 0, 255 - len(content))
58 | s_block_end()
59 | s_repeat(name, 0, 1024, 50)
60 |
61 | # Fuzzing Probe Response Most Used Information Elements
62 | s_initialize("ProbeResp: Most Used IEs")
63 | if s_block_start('ProbeResp', truncate=TRUNCATE):
64 | s_static("\x50") # Type/Subtype
65 | s_static("\x00") # Flags
66 | s_static("\x3A\x01") # Duration ID
67 | s_static(mac2str(STA_MAC)) # Destination Address
68 | s_static(mac2str(AP_MAC)) # Source Address
69 | s_static(mac2str(AP_MAC)) # BSSID Address
70 | s_static("\x00\x00") # Sequence Control
71 | s_qword(0x0000000010000000, fuzzable=False) # Timestamp
72 | s_word(0x0001, fuzzable=False) # Beacon Interval
73 | s_static("\x01\x00") # Capabilities
74 | string_element("SSID", 0, content=SSID) # Fuzzing SSID
75 | random_element("RATES", 1, content=RATES) # Fuzzing RATES
76 | random_element("CHANNEL", 3, content=CHANNEL) # Fuzzing CHANNEL
77 | random_element("TIM", 5, content=TIM) # Fuzzing TIM
78 | random_element("ERP42", 42, content=ERP42) # Fuzzing ERP42
79 | random_element("ERP47", 47, content=ERP47) # Fuzzing ERP47
80 | random_element("XRATES", 50, content=XRATES) # Fuzzing XRATES
81 | s_block_end()
82 |
83 | # Fuzzing Information Elements
84 | list_ies = range(2, 256)
85 | for i in [3, 5, 42, 47, 50]:
86 | list_ies.remove(i)
87 |
88 | for ie in list_ies:
89 | s_initialize("ProbeResp: IE %d" % ie)
90 | s_static(PROBE_RESP)
91 | random_element("IE", ie) # Fuzzing IE
92 |
93 | # Fuzzing With Malformed Probe Responses
94 | s_initialize("ProbeResp: Malformed")
95 | if s_block_start('ProbeResp: Malformed', truncate=TRUNCATE):
96 | s_static("\x50") # Type/Subtype
97 | s_static("\x00") # Flags
98 | s_static("\x3A\x01") # Duration ID
99 | s_static(mac2str(STA_MAC)) # Destination Address
100 | s_static(mac2str(AP_MAC)) # Source Address
101 | s_static(mac2str(AP_MAC)) # BSSID Address
102 | s_static("\x00\x00") # Sequence Control
103 | s_random(PADDING * 10, 0, 1024, step=25) # Garbage
104 | s_block_end()
105 |
106 | # Fuzzing With Malformed Frames
107 | for type_subtype in range(256):
108 | s_initialize("Fuzzy: Malformed %d" % type_subtype)
109 | s_static(type_subtype) # Type/Subtype
110 | if s_block_start('Fuzzy: Malformed %d' % type_subtype, truncate=TRUNCATE):
111 | s_byte(0x00, fuzzable=False) # Flags
112 | s_static("\x3A\x01") # Duration ID
113 | s_static(mac2str(AP_MAC)) # Destination Address
114 | s_static(mac2str(STA_MAC)) # Source Address
115 | s_static(mac2str(AP_MAC)) # BSSID Address
116 | s_random(PADDING * 10, 0, 1024, step=25) # Garbage
117 | s_block_end()
118 |
119 | # Fuzzing Vendor Specific IE
120 | for oui in ouis:
121 | s_initialize("ProbeResp: Vendor Specific %s" % oui)
122 | s_static(PROBE_RESP)
123 | random_element("IE", 221, content=oui) # Fuzzing IE
124 |
125 | # Fuzzing WPA-PSK, RSN-PSK, WPA-EAP, RSN-EAP IE
126 | for method in ['WPA-PSK', 'WPA-EAP', 'RSN-PSK', 'RSN-EAP']:
127 |
128 | if method == 'WPA-PSK':
129 | IE = "\xDD"
130 | HDR = "\x00\x50\xF2" + "\x01" + "\x01\x00" + "\x00\x50\xF2\x02"
131 | UCAST_CIPHER = "\x00\x50\xF2\x02"
132 | AUTH_METHOD = "\x00\x50\xF2\x02"
133 | elif method == 'WPA-EAP':
134 | IE = "\xDD"
135 | HDR = "\x00\x50\xF2" + "\x01" + "\x01\x00" + "\x00\x50\xF2\x02"
136 | UCAST_CIPHER = "\x00\x50\xF2\x02"
137 | AUTH_METHOD = "\x00\x50\xF2\x01"
138 | elif method == 'RSN-PSK':
139 | IE = "\x30"
140 | HDR = "\x01\x00" + "\x00\x0F\xAC\x04"
141 | UCAST_CIPHER = "\x00\x0F\xAC\x04"
142 | AUTH_METHOD = "\x00\x0F\xAC\x02"
143 | elif method == 'RSN-EAP':
144 | IE = "\x30"
145 | HDR = "\x01\x00" + "\x00\x0F\xAC\x04"
146 | UCAST_CIPHER = "\x00\x0F\xAC\x04"
147 | AUTH_METHOD = "\x00\x0F\xAC\x01"
148 |
149 | s_initialize("ProbeResp: %s Fuzzing" % method)
150 | s_static(PROBE_RESP)
151 | s_static(IE)
152 | s_size("%s IE" % method, length=1, fuzzable=True)
153 | if s_block_start('%s IE' % method, truncate=TRUNCATE):
154 | s_static(HDR)
155 | s_size("Unicast Ciphers", length=2, fuzzable=True, math=alen)
156 | if s_block_start("Unicast Ciphers", truncate=TRUNCATE):
157 | if s_block_start("Unicast Cipher", truncate=TRUNCATE):
158 | s_static(UCAST_CIPHER)
159 | s_block_end()
160 | s_repeat("Unicast Cipher", 0, 1024, 50)
161 | s_block_end()
162 | s_size("Authentication Methods", length=2, fuzzable=True, math=alen)
163 | if s_block_start("Authentication Methods", truncate=TRUNCATE):
164 | if s_block_start("Authentication Method", truncate=TRUNCATE):
165 | s_static(AUTH_METHOD)
166 | s_block_end()
167 | s_repeat("Authentication Method", 0, 1024, 50)
168 | s_block_end()
169 | s_random("", 0, 1024)
170 | s_block_end()
171 |
--------------------------------------------------------------------------------
/sta_settings.py:
--------------------------------------------------------------------------------
1 | # Define variables
2 | # SETTINGS is [ (STA_NUMBER, SAVE_RESULTS, SKIP) ]
3 |
4 | TEST_SETTINGS_INDEX = 1
5 |
6 | SETTINGS = [
7 | (0, 0, 0),
8 | (1, 0, 0),
9 | ]
10 |
11 | # Defining the fuzzing MAC address device
12 | AP_MAC = "00:20:A6:61:2D:09"
13 |
14 | # Defining the injection interface
15 | IFACE = "ath0"
16 |
17 | ##### BELOW VARIABLES SHOULD NOT BE TWEAKED BY THE USER
18 |
19 | STA_NUMBER = SETTINGS[TEST_SETTINGS_INDEX][0]
20 | SAVE_RESULTS = SETTINGS[TEST_SETTINGS_INDEX][1]
21 | SKIP = SETTINGS[TEST_SETTINGS_INDEX][2]
22 |
23 | # Defining fuzzing specific variables
24 | STA = [
25 | ("00:00:00:00:00:00", 1), # ipw3945 Linux
26 | ('18:34:51:54:c5:c9', 1),
27 | ][STA_NUMBER]
28 |
29 | STA_MAC = STA[0]
30 | REPEAT_TIME = STA[1]
31 |
32 | # Tuning listen value (fuzzing speed and false positive rates)
33 | LISTEN_TIME = 60
34 |
35 | # Defining the logging file
36 | FNAME = [None, 'audits/sta-%s.session' % (STA_MAC)][SAVE_RESULTS]
37 |
38 | # Defining the step value for IE fuzzing (should be odd to reach 255)
39 | STEP = [1, 3, 15, 17, 51][4]
40 |
41 | # Defining the padding value
42 | PADDING = "A"
43 |
44 | # Defining truncate option
45 | TRUNCATE = True
46 |
47 | # Defining fuzzing specific variables
48 | SSID = "fuzzing"
49 | CHANNEL = "\x01" # Channel should be the same that real one
50 |
--------------------------------------------------------------------------------
/sulley.patches/sulley.heuristic_patch.diff:
--------------------------------------------------------------------------------
1 | diff -Nur --strip-trailing-cr sulley/sulley/__init__.py sulley.heuristic_patch/sulley/__init__.py
2 | --- sulley/sulley/__init__.py 2012-08-18 22:49:37.407722790 +0200
3 | +++ sulley.heuristic_patch/sulley/__init__.py 2012-08-18 22:20:49.734784831 +0200
4 | @@ -345,7 +345,7 @@
5 | blocks.CURRENT.pop()
6 |
7 |
8 | -def s_random (value, min_length, max_length, num_mutations=25, fuzzable=True, step=None, name=None):
9 | +def s_random (value, min_length, max_length, num_mutations=25, fuzzable=True, step=None, heuristic=None, name=None):
10 | '''
11 | Generate a random chunk of data while maintaining a copy of the original. A random length range can be specified.
12 | For a static length, set min/max length to be the same.
13 | @@ -362,11 +362,13 @@
14 | @param fuzzable: (Optional, def=True) Enable/disable fuzzing of this primitive
15 | @type step: Integer
16 | @param step: (Optional, def=None) If not null, step count between min and max reps, otherwise random
17 | + @param heuristic: (Optional, def=None) Heuristic to compute a list of wanted random value length
18 | + @type name: String
19 | @type name: String
20 | @param name: (Optional, def=None) Specifying a name gives you direct access to a primitive
21 | '''
22 |
23 | - random = primitives.random_data(value, min_length, max_length, num_mutations, fuzzable, step, name)
24 | + random = primitives.random_data(value, min_length, max_length, num_mutations, fuzzable, step, heuristic, name)
25 | blocks.CURRENT.push(random)
26 |
27 |
28 | diff -Nur --strip-trailing-cr sulley/sulley/primitives.py sulley.heuristic_patch/sulley/primitives.py
29 | --- sulley/sulley/primitives.py 2012-08-18 22:49:37.411722811 +0200
30 | +++ sulley.heuristic_patch/sulley/primitives.py 2012-08-18 22:20:49.742784973 +0200
31 | @@ -245,7 +245,7 @@
32 |
33 | ########################################################################################################################
34 | class random_data (base_primitive):
35 | - def __init__ (self, value, min_length, max_length, max_mutations=25, fuzzable=True, step=None, name=None):
36 | + def __init__ (self, value, min_length, max_length, max_mutations=25, fuzzable=True, step=None, heuristic=None, name=None):
37 | '''
38 | Generate a random chunk of data while maintaining a copy of the original. A random length range can be specified.
39 | For a static length, set min/max length to be the same.
40 | @@ -262,6 +262,8 @@
41 | @param fuzzable: (Optional, def=True) Enable/disable fuzzing of this primitive
42 | @type step: Integer
43 | @param step: (Optional, def=None) If not null, step count between min and max reps, otherwise random
44 | + @type heuristic: Function
45 | + @param heuristic: (Optional, def=None) Heuristic to compute a list of wanted random value length
46 | @type name: String
47 | @param name: (Optional, def=None) Specifying a name gives you direct access to a primitive
48 | '''
49 | @@ -273,14 +275,20 @@
50 | self.fuzzable = fuzzable
51 | self.step = step
52 | self.name = name
53 | -
54 | + self.heuristics = None
55 | +
56 | self.s_type = "random_data" # for ease of object identification
57 | self.rendered = "" # rendered value
58 | self.fuzz_complete = False # flag if this primitive has been completely fuzzed
59 | self.mutant_index = 0 # current mutation number
60 |
61 | + assert not (step != 0 and heuristic), "Can't set step AND heuristic"
62 | +
63 | if self.step:
64 | self.max_mutations = (self.max_length - self.min_length) / self.step + 1
65 | + elif heuristic:
66 | + self.heuristics = heuristic(self.min_length, self.max_length)
67 | + self.max_mutations = len(self.heuristics)
68 |
69 |
70 | def mutate (self):
71 | @@ -300,8 +308,11 @@
72 | self.value = self.original_value
73 | return False
74 |
75 | + # select a length in the heuristics list
76 | + if self.heuristics:
77 | + length = self.heuristics[self.mutant_index]
78 | # select a random length for this string.
79 | - if not self.step:
80 | + elif not self.step:
81 | length = random.randint(self.min_length, self.max_length)
82 | # select a length function of the mutant index and the step.
83 | else:
84 |
--------------------------------------------------------------------------------
/sulley.patches/sulley.repeat_patch.diff:
--------------------------------------------------------------------------------
1 | diff -Nur --strip-trailing-cr sulley/sulley/sessions.py sulley.repeat_patch/sulley/sessions.py
2 | --- sulley/sulley/sessions.py 2012-08-23 23:06:53.139769085 +0200
3 | +++ sulley.repeat_patch/sulley/sessions.py 2012-08-30 19:50:30.552542995 +0200
4 | @@ -109,7 +109,7 @@
5 |
6 | ########################################################################################################################
7 | class session (pgraph.graph):
8 | - def __init__ (self, session_filename=None, skip=0, sleep_time=1.0, log_level=2, proto="tcp", bind=None, restart_interval=0, timeout=5.0, web_port=26000, crash_threshold=3, restart_sleep_time=300):
9 | + def __init__ (self, session_filename=None, skip=0, repeat_time=0, repeat_number=0, sleep_time=1.0, log_level=2, proto="tcp", bind=None, restart_interval=0, timeout=5.0, web_port=26000, crash_threshold=3, restart_sleep_time=300):
10 | '''
11 | Extends pgraph.graph and provides a container for architecting protocol dialogs.
12 |
13 | @@ -117,6 +117,11 @@
14 | @kwarg session_filename: (Optional, def=None) Filename to serialize persistant data to
15 | @type skip: Integer
16 | @kwarg skip: (Optional, def=0) Number of test cases to skip
17 | + @type repeat_time: Integer
18 | + @kwarg repeat_time: (Optional, def=0) Repeat duration of the test case (in seconds)
19 | + @type repeat_number: Integer
20 | + @kwarg repeat_number: (Optional, def=0) Repeat number of the test case
21 | + @type sleep_time: Float
22 | @type sleep_time: Float
23 | @kwarg sleep_time: (Optional, def=1.0) Time to sleep in between tests
24 | @type log_level: Integer
25 | @@ -140,6 +145,8 @@
26 |
27 | self.session_filename = session_filename
28 | self.skip = skip
29 | + self.repeat_time = repeat_time
30 | + self.repeat_number = repeat_number
31 | self.sleep_time = sleep_time
32 | self.log_level = log_level
33 | self.proto = proto.lower()
34 | @@ -467,11 +474,21 @@
35 | continue
36 |
37 | # now send the current node we are fuzzing.
38 | - try:
39 | - self.transmit(sock, self.fuzz_node, edge, target)
40 | - except Exception, e:
41 | - error_handler(e, "failed transmitting fuzz node", target, sock)
42 | - continue
43 | + if self.repeat_time:
44 | + start_time = time.time()
45 | + try:
46 | + while (time.time() - start_time) < self.repeat_time:
47 | + self.transmit(sock, self.fuzz_node, edge, target)
48 | + except Exception, e:
49 | + error_handler(e, "failed transmitting fuzz node", target, sock)
50 | + continue
51 | + else:
52 | + for i in xrange(self.repeat_number + 1):
53 | + try:
54 | + self.transmit(sock, self.fuzz_node, edge, target)
55 | + except Exception, e:
56 | + error_handler(e, "failed transmitting fuzz node", target, sock)
57 | + continue
58 |
59 | # if we reach this point the send was successful for break out of the while(1).
60 | break
61 |
--------------------------------------------------------------------------------
/sulley.patches/sulley.truncate_patch.diff:
--------------------------------------------------------------------------------
1 | diff -Nur --strip-trailing-cr sulley/sulley/blocks.py sulley.truncate_patch/sulley/blocks.py
2 | --- sulley/sulley/blocks.py 2012-08-23 23:06:53.135769050 +0200
3 | +++ sulley.truncate_patch/sulley/blocks.py 2012-08-23 23:05:55.419482856 +0200
4 | @@ -76,7 +76,12 @@
5 | if not self.block_stack:
6 | raise sex.error("BLOCK STACK OUT OF SYNC")
7 |
8 | - self.block_stack.pop()
9 | + b = self.block_stack.pop()
10 | +
11 | + # if block truncate parameter is True, initialize some variable
12 | + # we have to do this here, because all items of the block must be on the stack
13 | + if b.truncate:
14 | + b.init_truncate()
15 |
16 |
17 | def push (self, item):
18 | @@ -183,7 +188,7 @@
19 |
20 | ########################################################################################################################
21 | class block:
22 | - def __init__ (self, name, request, group=None, encoder=None, dep=None, dep_value=None, dep_values=[], dep_compare="=="):
23 | + def __init__ (self, name, request, group=None, encoder=None, dep=None, dep_value=None, dep_values=[], dep_compare="==", truncate=False):
24 | '''
25 | The basic building block. Can contain primitives, sizers, checksums or other blocks.
26 |
27 | @@ -203,6 +208,8 @@
28 | @param dep_values: (Optional, def=[]) Values that field "dep" may contain for block to be rendered
29 | @type dep_compare: String
30 | @param dep_compare: (Optional, def="==") Comparison method to apply to dependency (==, !=, >, >=, <, <=)
31 | + @type truncate: Boolean
32 | + @param truncate: (Optional, def=False) Enable/disable truncating of this block
33 | '''
34 |
35 | self.name = name
36 | @@ -213,6 +220,7 @@
37 | self.dep_value = dep_value
38 | self.dep_values = dep_values
39 | self.dep_compare = dep_compare
40 | + self.truncate = truncate
41 |
42 | self.stack = [] # block item stack.
43 | self.rendered = "" # rendered block contents.
44 | @@ -220,7 +228,22 @@
45 | self.group_idx = 0 # if this block is tied to a group, the index within that group.
46 | self.fuzz_complete = False # whether or not we are done fuzzing this block.
47 | self.mutant_index = 0 # current mutation index.
48 | -
49 | +
50 | + if self.truncate:
51 | + self.truncate_size = 0 # not mutated block size
52 | + self.truncate_rendered = None # not mutated block
53 | + self.truncate_complete = False # whether or not we are done truncating this block
54 | +
55 | +
56 | + def init_truncate (self):
57 | + '''
58 | + Initialize self.truncate_rendered, must be done after all items are pushed on the stack
59 | + '''
60 | +
61 | + self.truncate = False
62 | + self.render()
63 | + self.truncate = True
64 | + self.truncate_rendered = self.rendered
65 |
66 | def mutate (self):
67 | mutated = False
68 | @@ -228,6 +251,15 @@
69 | # are we done with this block?
70 | if self.fuzz_complete:
71 | return False
72 | +
73 | + if self.truncate and not self.truncate_complete:
74 | + if self.truncate_size == len(self.truncate_rendered):
75 | + self.truncate_complete = True
76 | + else:
77 | + self.request.mutant = self
78 | + self.truncate_size += 1
79 | + item = self
80 | + mutated = True
81 |
82 | #
83 | # mutate every item on the stack for every possible group value.
84 | @@ -339,6 +371,9 @@
85 | # if this block is associated with a group, then multiply out the number of possible mutations.
86 | if self.group:
87 | num_mutations *= len(self.request.names[self.group].values)
88 | +
89 | + if self.truncate:
90 | + num_mutations += len(self.truncate_rendered)
91 |
92 | return num_mutations
93 |
94 | @@ -421,6 +456,10 @@
95 | for item in self.request.callbacks[self.name]:
96 | item.render()
97 |
98 | + # the block is truncated (only if the block started to be mutate).
99 | + if self.truncate and not self.truncate_complete and self.truncate_size > 0:
100 | + self.rendered = self.rendered[0:self.truncate_size-1]
101 | +
102 |
103 | def reset (self):
104 | '''
105 | @@ -429,6 +468,9 @@
106 |
107 | self.fuzz_complete = False
108 | self.group_idx = 0
109 | +
110 | + self.truncate_complete = False
111 | + self.truncate_size = 0
112 |
113 | for item in self.stack:
114 | if item.fuzzable:
115 | diff -Nur --strip-trailing-cr sulley/sulley/__init__.py sulley.truncate_patch/sulley/__init__.py
116 | --- sulley/sulley/__init__.py 2012-08-23 23:06:53.135769050 +0200
117 | +++ sulley.truncate_patch/sulley/__init__.py 2012-08-23 22:47:25.277977962 +0200
118 | @@ -112,7 +112,7 @@
119 | ### BLOCK MANAGEMENT
120 | ########################################################################################################################
121 |
122 | -def s_block_start (name, group=None, encoder=None, dep=None, dep_value=None, dep_values=[], dep_compare="=="):
123 | +def s_block_start (name, group=None, encoder=None, dep=None, dep_value=None, dep_values=[], dep_compare="==", truncate=False):
124 | '''
125 | Open a new block under the current request. This routine always returns True so you can make your fuzzer pretty
126 | with indenting::
127 | @@ -136,9 +136,11 @@
128 | @param dep_values: (Optional, def=[]) Values that field "dep" may contain for block to be rendered
129 | @type dep_compare: String
130 | @param dep_compare: (Optional, def="==") Comparison method to use on dependency (==, !=, >, >=, <, <=)
131 | + @type truncate: Boolean
132 | + @param truncate: (Optional, def=False) Enable/disable truncating of this block
133 | '''
134 |
135 | - block = blocks.block(name, blocks.CURRENT, group, encoder, dep, dep_value, dep_values, dep_compare)
136 | + block = blocks.block(name, blocks.CURRENT, group, encoder, dep, dep_value, dep_values, dep_compare, truncate)
137 | blocks.CURRENT.push(block)
138 |
139 | return True
140 |
--------------------------------------------------------------------------------
/sulley.patches/sulley.wifi_patch.diff:
--------------------------------------------------------------------------------
1 | diff -Nur --strip-trailing-cr sulley/sulley/sessions.py sulley.wifi_patch/sulley/sessions.py
2 | --- sulley/sulley/sessions.py 2012-08-18 22:49:37.411722811 +0200
3 | +++ sulley.wifi_patch/sulley/sessions.py 2012-08-18 22:21:05.838864733 +0200
4 | @@ -122,7 +122,7 @@
5 | @type log_level: Integer
6 | @kwarg log_level: (Optional, def=2) Set the log level, higher number == more log messages
7 | @type proto: String
8 | - @kwarg proto: (Optional, def="tcp") Communication protocol ("tcp", "udp", "ssl")
9 | + @kwarg proto: (Optional, def="tcp") Communication protocol ("tcp", "udp", "ssl", "wifi")
10 | @type bind: Tuple (host, port)
11 | @kwarg bind: (Optional, def=random) Socket bind address and port
12 | @type timeout: Float
13 | @@ -145,6 +145,8 @@
14 | self.proto = proto.lower()
15 | self.bind = bind
16 | self.ssl = False
17 | + self.wifi = False
18 | + self.wifi_iface = False
19 | self.restart_interval = restart_interval
20 | self.timeout = timeout
21 | self.web_port = web_port
22 | @@ -170,6 +172,10 @@
23 | elif self.proto == "udp":
24 | self.proto = socket.SOCK_DGRAM
25 |
26 | + elif self.proto == "wifi":
27 | + self.proto = socket.SOCK_RAW
28 | + self.wifi = True
29 | +
30 | else:
31 | raise sex.error("INVALID PROTOCOL SPECIFIED: %s" % self.proto)
32 |
33 | @@ -420,26 +426,38 @@
34 | error_handler(e, "failed on netmon.pre_send()", target)
35 | continue
36 |
37 | - try:
38 | - # establish a connection to the target.
39 | - sock = socket.socket(socket.AF_INET, self.proto)
40 | - except Exception, e:
41 | - error_handler(e, "failed creating socket", target)
42 | - continue
43 | -
44 | - if self.bind:
45 | + if self.proto == socket.SOCK_STREAM or self.proto == socket.SOCK_DGRAM:
46 | try:
47 | - sock.bind(self.bind)
48 | + # establish a connection to the target.
49 | + sock = socket.socket(socket.AF_INET, self.proto)
50 | except Exception, e:
51 | - error_handler(e, "failed binding on socket", target, sock)
52 | + error_handler(e, "failed creating socket", target)
53 | continue
54 |
55 | - try:
56 | - sock.settimeout(self.timeout)
57 | - sock.connect((target.host, target.port))
58 | - except Exception, e:
59 | - error_handler(e, "failed connecting on socket", target, sock)
60 | - continue
61 | + if self.bind:
62 | + try:
63 | + sock.bind(self.bind)
64 | + except Exception, e:
65 | + error_handler(e, "failed binding on socket", target, sock)
66 | + continue
67 | +
68 | + try:
69 | + sock.settimeout(self.timeout)
70 | + sock.connect((target.host, target.port))
71 | + except Exception, e:
72 | + error_handler(e, "failed connecting on socket", target, sock)
73 | + continue
74 | +
75 | + elif self.wifi and self.wifi_iface:
76 | + ETH_P_ALL = 3
77 | + try:
78 | + sock = socket.socket(socket.AF_PACKET, self.proto, socket.htons(ETH_P_ALL))
79 | + except Exception, e:
80 | + error_handler(e, "failed creating socket", target)
81 | + try:
82 | + sock.bind((self.wifi_iface, ETH_P_ALL))
83 | + except Exception, e:
84 | + error_handler(e, "failed binding on socket", target, sock)
85 |
86 | # if SSL is requested, then enable it.
87 | if self.ssl:
88 |
--------------------------------------------------------------------------------
/wifuzzit_ap.py:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env python
2 |
3 | from sulley import *
4 | from ap_requests import *
5 | from optparse import OptionParser
6 |
7 | import re
8 | import socket
9 | import struct
10 | import time
11 |
12 | # Assume that wireless card is in monitor mode on appropriate channel
13 | # Saves from lot of dependencies (lorcon, pylorcon...)
14 |
15 | ###############
16 |
17 | def fuzz_ap():
18 |
19 | def is_alive():
20 |
21 | global IFACE, AUTH_REQ_OPEN
22 | ETH_P_ALL = 3
23 |
24 | def isresp(pkt):
25 | resp = False
26 | if (len(pkt) >= 30 and pkt[0] == "\xB0"\
27 | and pkt[4:10] == mac2str(STA_MAC)\
28 | and pkt[28:30] == "\x00\x00"):
29 | resp = True
30 | return resp
31 |
32 | s = socket.socket(socket.AF_PACKET, socket.SOCK_RAW, socket.htons(ETH_P_ALL))
33 | s.bind((IFACE, ETH_P_ALL))
34 |
35 | sess.log("checking aliveness of fuzzed access point %s" % AP_MAC, level=3)
36 |
37 | retries = CRASH_RETRIES
38 | alive = False
39 |
40 | while retries:
41 |
42 | s.send(AUTH_REQ_OPEN)
43 |
44 | start_time = time.time()
45 | while (time.time() - start_time) < 1:
46 | ans = s.recv(1024)
47 | alive = isresp(ans)
48 | if alive:
49 | s.send(DEAUTH)
50 | s.close()
51 | if retries != CRASH_RETRIES:
52 | sess.log("retried authentication %d times" % (CRASH_RETRIES - retries), level=1)
53 | return alive
54 |
55 | retries -= 1
56 |
57 | s.close()
58 |
59 | return alive
60 |
61 | def check_alive(s):
62 |
63 | global AUTH_REQ_OPEN
64 |
65 | def isresp(pkt):
66 | resp = False
67 | if (len(pkt) >= 30 and pkt[0] == "\xB0"\
68 | and pkt[4:10] == mac2str(STA_MAC)\
69 | and pkt[28:30] == "\x00\x00"):
70 | resp = True
71 | return resp
72 |
73 | sess.log("checking aliveness of fuzzed access point %s" % AP_MAC, level=3)
74 |
75 | while True:
76 | t = s.send(AUTH_REQ_OPEN)
77 | start_time = time.time()
78 | while (time.time() - start_time) < 1:
79 | alive = isresp(s.recv(1024))
80 | if alive:
81 | return alive
82 | sess.log("waiting for the access point to be up", level=1)
83 | time.sleep(DELAY_REBOOT)
84 |
85 | def pass_state(s):
86 | '''
87 | '''
88 | return True
89 |
90 | def clean_state(s):
91 |
92 | global DEAUTH
93 |
94 | s.send(DEAUTH)
95 | sess.log("sending deauthentication to come back to initial state", level=3)
96 |
97 | # shameless ripped from scapy
98 | def hexdump(x):
99 | x=str(x)
100 | l = len(x)
101 | i = 0
102 | while i < l:
103 | print "%04x " % i,
104 | for j in range(16):
105 | if i+j < l:
106 | print "%02X" % ord(x[i+j]),
107 | else:
108 | print " ",
109 | if j%16 == 7:
110 | print "",
111 | print " ",
112 | print x[i:i+16]
113 | i += 16
114 |
115 | def check_auth(session, node, edge, sock):
116 |
117 | def isresp(pkt):
118 | resp = False
119 | if (len(pkt) >= 30 and pkt[0] == "\xB0"\
120 | and pkt[4:10] == mac2str(STA_MAC)\
121 | and pkt[28:30] == "\x00\x00"):
122 | resp = True
123 | return resp
124 |
125 | start_time = time.time()
126 | while (time.time() - start_time) < STATE_WAIT_TIME:
127 | pkt = sock.recv(1024)
128 | ans = isresp(pkt)
129 | if ans:
130 | sess.log("authentication successfull with %s" % AP_MAC, level=3)
131 | return
132 |
133 | sess.log("authentication not successfull with %s" % AP_MAC, level=1)
134 |
135 | if session.fuzz_node.mutant != None:
136 | '''
137 | print "XXXXX : session.fuzz_node.name %s" % session.fuzz_node.name
138 | print "XXXXX : session.fuzz_node.mutant_index %d" % session.fuzz_node.mutant_index
139 | print "XXXXX : session.fuzz_node.mutant.mutant_index %d" % session.fuzz_node.mutant.mutant_index
140 | print "XXXXX : session.fuzz_node.num_mutations() %d" % session.fuzz_node.num_mutations()
141 | print "XXXXX : session.total_mutant_index %d" % session.total_mutant_index
142 | '''
143 | sess.log("re-trying the current test case", level=1)
144 | session.fuzz_node.mutant_index -= 1
145 | session.fuzz_node.mutant.mutant_index -= 1
146 | session.total_mutant_index -= 1
147 |
148 | def check_asso(session, node, edge, sock):
149 |
150 | def isresp(pkt):
151 | resp = False
152 | if (len(pkt) >= 30 and pkt[0] == "\x10"\
153 | and pkt[4:10] == mac2str(STA_MAC)\
154 | and pkt[26:28] == "\x00\x00"):
155 | resp = True
156 | return resp
157 |
158 | start_time = time.time()
159 | while (time.time() - start_time) < STATE_WAIT_TIME:
160 | pkt = sock.recv(1024)
161 | ans = isresp(pkt)
162 | if ans:
163 | sess.log("association successfull with %s" % AP_MAC, level=3)
164 | return
165 |
166 | sess.log("association not successfull with %s" % AP_MAC, level=1)
167 | if session.fuzz_node.mutant != None:
168 | '''
169 | print "XXXXX : session.fuzz_node.name %s" % session.fuzz_node.name
170 | print "XXXXX : session.fuzz_node.mutant_index %d" % session.fuzz_node.mutant_index
171 | print "XXXXX : session.fuzz_node.mutant.mutant_index %d" % session.fuzz_node.mutant.mutant_index
172 | print "XXXXX : session.fuzz_node.num_mutations() %d" % session.fuzz_node.num_mutations()
173 | print "XXXXX : session.total_mutant_index %d" % session.total_mutant_index
174 | '''
175 | sess.log("re-trying the current test case", level=1)
176 | session.fuzz_node.mutant_index -= 1
177 | session.fuzz_node.mutant.mutant_index -= 1
178 | session.total_mutant_index -= 1
179 |
180 |
181 |
182 | # Defining the transport protocol
183 | sess = sessions.session(session_filename=FNAME, proto="wifi", timeout=5.0, sleep_time=0.1, log_level=LOG_LEVEL, skip=SKIP, crash_threshold=CRASH_THRESHOLD)
184 |
185 | # Defining the target
186 | target = sessions.target(AP_MAC, 0)
187 |
188 | # Adding the detect_crash function for target monitoring
189 | target.procmon = instrumentation.external(post=is_alive)
190 |
191 | # Adding a check for alive of access point
192 | sess.pre_send = check_alive
193 |
194 | # Adding a deauth send to come back to initial state
195 | sess.post_send = clean_state
196 |
197 | # Adding the IFACE for socket binding
198 | sess.wifi_iface = IFACE
199 |
200 | # Adding the target to the fuzzing session
201 | sess.add_target(target)
202 |
203 | # Fuzzing State "Not Authenticated, Not Associated"
204 |
205 | sess.connect(s_get("AuthReq: Open"))
206 |
207 | for type_subtype in range(256): # 256
208 | sess.connect(s_get("Fuzzy 1: Malformed %d" % type_subtype))
209 |
210 | # Fuzzing State "Authenticated, Not Associated"
211 | sess.connect(s_get("AuthReq: Open"), s_get("AssoReq: Garbage"), callback=check_auth) # Checking Authentication
212 | sess.connect(s_get("AuthReq: Open"), s_get("AssoReq: Open"), callback=check_auth) # Checking Authentication
213 | sess.connect(s_get("AuthReq: Open"), s_get("AssoReq: %s" % AP_CONFIG), callback=check_auth) # Checking Authentication
214 | if AP_CONFIG not in ['Open']:
215 | sess.connect(s_get("AuthReq: Open"), s_get("AssoReq: %s Fuzzing" % AP_CONFIG ), callback=check_auth) # Checking Authentication
216 |
217 | for oui in ouis:
218 | sess.connect(s_get("AuthReq: Open"), s_get("AssoReq: Vendor Specific %s" % oui), callback=check_auth)
219 |
220 | for ie in list_ies:
221 | sess.connect(s_get("AuthReq: Open"), s_get("AssoReq: IE %d" % ie), callback=check_auth)
222 |
223 | #for type_subtype in range(256):
224 | sess.connect(s_get("AuthReq: Open"), s_get("Fuzzy 2: Malformed %d" % type_subtype), callback=check_auth)
225 |
226 | # Fuzzing State : "Authenticated, Associated"
227 |
228 | for type_subtype in range(256):
229 | sess.connect(s_get("AssoReq: %s" % AP_CONFIG), s_get("Fuzzy 3: Malformed %d" % type_subtype), callback=check_asso)
230 |
231 | if AP_CONFIG in ['WPA-PSK', 'RSN-PSK']:
232 | sess.connect(s_get("AssoReq: %s" % AP_CONFIG), s_get("EAPoL-Key: %s" % AP_CONFIG), callback=check_asso)
233 |
234 | if AP_CONFIG in ['WPA-EAP', 'RSN-EAP']:
235 | sess.connect(s_get("AssoReq: %s" % AP_CONFIG), s_get("EAPoL-Start: %s" % AP_CONFIG), callback=check_asso)
236 |
237 | # Launching the fuzzing campaign
238 | sess.fuzz()
239 |
240 | if __name__ == '__main__':
241 |
242 | usage = 'usage: %prog [options]'
243 | parser = OptionParser(usage)
244 | parser.add_option('--sta_mac', dest='sta_mac', help='STA MAC address (fuzzer)')
245 | parser.add_option('--iface', dest='iface', help='injection interface')
246 | parser.add_option('--skip', dest='skip', help='skip tests (int)', type='int', default=0)
247 | parser.add_option('--ssid', dest='ssid', help='AP ssid (fuzzed)')
248 | parser.add_option('--ap_mac', dest='ap_mac', help='AP MAC address (fuzzed)')
249 | parser.add_option('--channel', dest='channel', help='AP channel (fuzzed)', type=int)
250 | parser.add_option('--ap_config', dest='ap_config', help='AP config: Open, WPA-PSK, WPA-EAP, RSN-PSK, RSN-EAP')
251 | parser.add_option('--save', dest='save', help='save results', action='store_true', default=False)
252 | parser.add_option('--truncate', dest='truncate', help='truncate frames option', action='store_true', default=False)
253 | parser.add_option('--crash_retries', dest='crash_retries', type=int, default=10)
254 | parser.add_option('--delay', dest='delay', type=int, default=1)
255 | parser.add_option('--delay_reboot', dest='delay_reboot', type=int, default=10)
256 | parser.add_option('--state_wait_time', dest='state_wait_time', type=int, default=2)
257 | parser.add_option('--log_level', dest='log_level', type=int, default=3)
258 | parser.add_option('--crash_threshold', dest='crash_threshold', type=int, default=3)
259 | parser.add_option('--fname', dest='fname', help='defining saved results file (conjointly with --save)', default=None)
260 |
261 | (options, args) = parser.parse_args()
262 |
263 | if not options.sta_mac:
264 | parser.error('STA MAC address must be set')
265 | if not re.search(r'([0-9A-F]{2}[:-]){5}([0-9A-F]{2})', options.sta_mac, re.I).group():
266 | parser.error('STA MAC address invalid format')
267 | if not options.iface:
268 | parser.error('injection interface must be set')
269 | if not options.ssid:
270 | parser.error('AP ssid must be set')
271 | if len(options.ssid) > 32:
272 | parser.error('AP ssid must be <= 32 characters')
273 | if not options.ap_mac:
274 | parser.error('AP MAC address must be set')
275 | if not re.search(r'([0-9A-F]{2}[:-]){5}([0-9A-F]{2})', options.ap_mac, re.I).group():
276 | parser.error('AP MAC address invalid format')
277 | if not options.channel:
278 | parser.error('AP channel must be set')
279 | if not options.ap_config:
280 | parser.error('AP config must be set')
281 | if options.ap_config not in [ 'Open', 'WPA-PSK', 'WPA-EAP', 'RSN-PSK', 'RSN-EAP' ]:
282 | parser.error('AP incorrect configuration')
283 | if options.save:
284 | if options.fname:
285 | FNAME = fname
286 | else:
287 | FNAME = 'audits/ap-%s-%s.session' % (options.ap_mac, options.ap_config)
288 |
289 | STA_MAC = options.sta_mac
290 | IFACE = options.iface
291 | SAVE_RESULTS = options.save
292 | SKIP = options.skip
293 | SSID = options.ssid
294 | AP_MAC = options.ap_mac
295 | CHANNEL = options.channel
296 | AP_CONFIG = options.ap_config
297 | CRASH_RETRIES = options.crash_retries
298 | DELAY = options.delay
299 | STATE_WAIT_TIME = options.state_wait_time
300 | DELAY_REBOOT = options.delay_reboot
301 | LOG_LEVEL = options.log_level
302 | CRASH_THRESHOLD = options.crash_threshold
303 | TRUNCATE = options.truncate
304 |
305 | fuzz_ap()
306 |
--------------------------------------------------------------------------------