├── .gitignore
├── LICENSE.md
├── MANIFEST.in
├── README.md
├── bin
└── osfooler-ng
├── logo.png
├── osfooler_ng
├── __init__.py
├── dep
│ ├── nmap-os-db
│ ├── p0f.fp
│ ├── p0fa.fp
│ └── p0fr.fp
├── module_p0f.py
└── osfooler_ng.py
├── requirements.txt
└── setup.py
/.gitignore:
--------------------------------------------------------------------------------
1 | # Byte-compiled / optimized / DLL files
2 | __pycache__/
3 | *.py[cod]
4 | *$py.class
5 |
6 | # C extensions
7 | *.so
8 |
9 | # Distribution / packaging
10 | .vscode/
11 | .Python
12 | build/
13 | develop-eggs/
14 | dist/
15 | downloads/
16 | eggs/
17 | .eggs/
18 | lib/
19 | lib64/
20 | parts/
21 | sdist/
22 | var/
23 | wheels/
24 | pip-wheel-metadata/
25 | share/python-wheels/
26 | *.egg-info/
27 | .installed.cfg
28 | *.egg
29 | MANIFEST
30 |
31 | # PyInstaller
32 | # Usually these files are written by a python script from a template
33 | # before PyInstaller builds the exe, so as to inject date/other infos into it.
34 | *.manifest
35 | *.spec
36 |
37 | # Installer logs
38 | pip-log.txt
39 | pip-delete-this-directory.txt
40 |
41 | # Unit test / coverage reports
42 | htmlcov/
43 | .tox/
44 | .nox/
45 | .coverage
46 | .coverage.*
47 | .cache
48 | nosetests.xml
49 | coverage.xml
50 | *.cover
51 | .hypothesis/
52 | .pytest_cache/
53 |
54 | # Translations
55 | *.mo
56 | *.pot
57 |
58 | # Django stuff:
59 | *.log
60 | local_settings.py
61 | db.sqlite3
62 |
63 | # Flask stuff:
64 | instance/
65 | .webassets-cache
66 |
67 | # Scrapy stuff:
68 | .scrapy
69 |
70 | # Sphinx documentation
71 | docs/_build/
72 |
73 | # PyBuilder
74 | target/
75 |
76 | # Jupyter Notebook
77 | .ipynb_checkpoints
78 |
79 | # IPython
80 | profile_default/
81 | ipython_config.py
82 |
83 | # pyenv
84 | .python-version
85 |
86 | # pipenv
87 | # According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control.
88 | # However, in case of collaboration, if having platform-specific dependencies or dependencies
89 | # having no cross-platform support, pipenv may install dependencies that don't work, or not
90 | # install all needed dependencies.
91 | #Pipfile.lock
92 |
93 | # celery beat schedule file
94 | celerybeat-schedule
95 |
96 | # SageMath parsed files
97 | *.sage.py
98 |
99 | # Environments
100 | .env
101 | .venv
102 | env/
103 | venv/
104 | ENV/
105 | env.bak/
106 | venv.bak/
107 |
108 | # Spyder project settings
109 | .spyderproject
110 | .spyproject
111 |
112 | # Rope project settings
113 | .ropeproject
114 |
115 | # mkdocs documentation
116 | /site
117 |
118 | # mypy
119 | .mypy_cache/
120 | .dmypy.json
121 | dmypy.json
122 |
123 | # Pyre type checker
124 | .pyre/
125 |
--------------------------------------------------------------------------------
/LICENSE.md:
--------------------------------------------------------------------------------
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 |
676 |
--------------------------------------------------------------------------------
/MANIFEST.in:
--------------------------------------------------------------------------------
1 | include requirements.txt
2 | include README.md
3 | include LICENSE.md
4 | include osfooler_ng/dep/*
5 | include osfooler_ng/*
6 | recursive-exclude osfooler_ng *.pyc
7 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | OSfooler-NG
5 |
6 |
7 |
8 |
9 |
10 | [](https://www.gnu.org/licenses/gpl-3.0)
11 | [
12 | [](https://GitHub.com/segofensiva/OSfooler-ng/graphs/commit-activity)
13 |
14 | # Synopsis
15 |
16 | This is a fork of [segofensiva/OSfooler-ng](https://github.com/segofensiva/OSfooler-ng).
17 |
18 | Main reason of that fork is that original project seems to be an abandoned proof-of-concept, but the project is still valuable.
19 | By now the main difference is the change of Python2's nfqueue (NetfilterQueue) version from 0.5 to 0.8.1 for the sake of run the OSfooler-ng on different distros, not just deb-based.
20 |
21 | Yes, it's Python2 yet. If you know how to properly move NetfilterQueue to Python 3.6+ and can test the project nicely and in short time - [your help is welcome](https://github.com/moonbaseDelta/OSfooler-ng/issues/1).
22 |
23 | Original author's project presentation can be found on Youtube [https://www.youtube.com/watch?v=psxxT00KavM](https://www.youtube.com/watch?v=psxxT00KavM). You may also find a few articles about OSfooler-NG. This version is a remake of 2014' OSfooler made by the same person, but the old one is archived and should be concidered lost.
24 | The whole topic of OS-fingerprinting and it's defeating is rather obscure.
25 | OSfooler-NG is working, but not yet perfect even against nmap and p0f. Any futher help, even testcases, and so is highly needed.
26 |
27 | By now it's been tested fine on Arch and CentOS7, CentOS8, Ubuntu 18.04.
28 |
29 |
30 |
31 | **You may help hugely by trying this on different distros and submit issues.**
32 | By now it's been tested fine on Arch and CentOS7.
33 |
34 |
35 |
36 | # Installation
37 |
38 |
39 | To get this version, just use git:
40 | ```
41 | $ git clone https://github.com/moonbaseDelta/OSfooler-ng.git
42 | ```
43 | You need to install python NetfilterQueue (v0.8.1 or more) linux package. Download from [PyPi](https://pypi.org/project/NetfilterQueue/0.8.1/):
44 | ```
45 | $ wget https://files.pythonhosted.org/packages/39/c4/8f73f70442aa4094b3c37876c96cddad2c3e74c058f6cd9cb017d37ffac0/NetfilterQueue-0.8.1.tar.gz
46 | $ tar -xzf NetfilterQueue-0.8.1.tar.gz
47 | $ cd NetfilterQueue-0.8.1
48 | $ sudo python2 setup.py install
49 | ```
50 | or try:
51 | ```
52 | $ pip2 install NetfilterQueue
53 | ```
54 |
55 | Install OSfooler-ng in the standard way:
56 | ```
57 | $ sudo python2 setup.py install
58 | ```
59 |
60 | There're also [instructions](https://github.com/moonbaseDelta/OSfooler-ng/wiki/Installation) for some specific distros in project's Wiki.
61 |
62 |
63 |
64 |
65 | ## Known issues
66 | No such device IO error (error code 19):
67 | * By default program uses 'eth0' interface that may not be even exist on your machine
68 | * Find your main TCP/IP interface (you can find it by 'ip a' command)
69 | * Run OSfooler-ng commands with:
70 | ```
71 | $ -i 'YOURINTERFACE'
72 | ```
73 |
74 |
75 | # Usage
76 | ## Active Fingerprinting: nmap
77 | To get the full list of OS to emulate, just use the flag '-n':
78 | ```
79 | $ osfooler-ng -n
80 | [+] Please, select nmap OS to emulate
81 | + "2N Helios IP VoIP doorbell"
82 | + "2Wire BT2700HG-V ADSL modem"
83 | + "2Wire 1701HG wireless ADSL modem"
84 | [...]
85 | + "ZyXEL Prestige 660HW-61 ADSL router (ZyNOS 3.40)"
86 | + "ZyXEL Prestige 660HW-D1 wireless ADSL router"
87 | + "ZyXEL ZyWALL 2 Plus firewall"
88 | ```
89 |
90 | To emulate an specific OS, just use the flag '-o' with the OS you want to emulate:
91 | ```
92 | $ osfooler-ng -m "Sony Ericsson W705 or W715 Walkman mobile phone"
93 | [+] Mutating to nmap:
94 | Fingerprint Sony Ericsson W705 or W715 Walkman mobile phone
95 | Class Sony Ericsson | embedded || phone
96 | CPE cpe:/h:sonyericsson:w705
97 | CPE cpe:/h:sonyericsson:w715
98 | SEQ(CI=RD%II=I)
99 | OPS(R=N)
100 | WIN(R=N)
101 | ECN(R=N)
102 | T1(R=N)
103 | T2(R=Y%DF=N%T=3B-45%TG=40%W=0%S=Z%A=S%F=AR%O=%RD=0%Q=)
104 | T3(R=N)
105 | T4(R=Y%DF=N%T=3B-45%TG=40%W=0%S=A%A=Z%F=R%O=%RD=0%Q=)
106 | T5(R=Y%DF=N%T=3B-45%TG=40%W=0%S=Z%A=S+%F=AR%O=%RD=0%Q=)
107 | T6(R=Y%DF=N%T=3B-45%TG=40%W=0%S=A%A=Z%F=R%O=%RD=0%Q=)
108 | T7(R=Y%DF=N%T=3B-45%TG=40%W=0%S=Z%A=S+%F=AR%O=%RD=0%Q=)
109 | U1(DF=N%T=3B-45%TG=40%IPL=164%UN=0%RIPL=G%RID=G%RIPCK=G%RUCK=G%RUD=G)
110 | IE(DFI=N%T=3B-45%TG=40%CD=S)
111 | [+] Activating queues
112 | [->] Process-1: nmap packet processor
113 | ```
114 |
115 | ## Passive Fingerprinting: p0f v2
116 | To get the full list of OS to emulate, just use the flag '-l':
117 | ```
118 | $ osfooler-ng -p
119 | Please, select p0f OS Genre and Details
120 | OS Genre="AIX" Details="4.3"
121 | OS Genre="AIX" Details="4.3.2 and earlier"
122 | OS Genre="AIX" Details="4.3.3-5.2 (1)"
123 | [...]
124 | OS Genre="-*NMAP" Details="OS detection probe w/flags (3)"
125 | OS Genre="-*NMAP" Details="OS detection probe w/flags (4)"
126 | OS Genre="-*NAST" Details="syn scan"
127 | ```
128 |
129 | To emulate any p0f OS, just use the flag '-o' with the OS Genre. This will choose the main OS and custom version will be randomly loaded when a SYN packet is detected. For example:
130 | ```
131 | $ osfooler-ng -o "PalmOS"
132 | [+] Mutating to p0f:
133 | WWW:S9|TTL:255|D:0|SS:44|OOO:M536|QQ:.|OS:PalmOS|DETAILS:Tungsten T3/C
134 | WWW:S5|TTL:255|D:0|SS:44|OOO:M536|QQ:.|OS:PalmOS|DETAILS:3/4
135 | WWW:S4|TTL:255|D:0|SS:44|OOO:M536|QQ:.|OS:PalmOS|DETAILS:3.5
136 | WWW:2948|TTL:255|D:0|SS:44|OOO:M536|QQ:.|OS:PalmOS|DETAILS:3.5.3 (Handera)
137 | WWW:S29|TTL:255|D:0|SS:44|OOO:M536|QQ:.|OS:PalmOS|DETAILS:5.0
138 | WWW:16384|TTL:255|D:0|SS:44|OOO:M1398|QQ:.|OS:PalmOS|DETAILS:5.2 (Clie)
139 | WWW:S14|TTL:255|D:0|SS:44|OOO:M1350|QQ:.|OS:PalmOS|DETAILS:5.2.1 (Treo)
140 | WWW:16384|TTL:255|D:0|SS:44|OOO:M1400|QQ:.|OS:PalmOS|DETAILS:5.2 (Sony)
141 | [+] Activating queues
142 | [->] Process-1: p0f packet processor
143 | ```
144 |
145 | You can also emulate the full p0f OS, using '-' with the OS Genre and '-d' with custom details:
146 | ```
147 | $ osfooler-ng -o "Windows" -d "XP bare-bone"
148 | [+] Mutating to p0f:
149 | WWW:65520|TTL:128|D:1|SS:48|OOO:M*,N,N,S|QQ:.|OS:Windows|DETAILS:XP bare-bone
150 | [+] Activating queues
151 | [->] Process-1: p0f packet processor
152 | ```
153 |
154 | ## Active and Passive Fingerprinting: nmap & p0f
155 | OSfooler-ng is also capable os emulating both OS to defeat nmap and p0f. Just combine the parameters above:
156 | ```
157 | $ osfooler-ng -m "Microsoft Windows 2000 SP4" -o "Windows" -d "2000 SP4"
158 | [+] Mutating to nmap:
159 | Fingerprint Microsoft Windows 2000 SP4
160 | Class Microsoft | Windows | 2000 | general purpose
161 | CPE cpe:/o:microsoft:windows_2000::sp4
162 | SEQ(SP=7C-86%GCD=1-6%ISR=95-9F%TI=I%II=I%SS=O|S%TS=0)
163 | OPS(O1=NNT11|M5B4NW0NNT00NNS%O2=NNT11|M5B4NW0NNT00NNS%O3=NNT11|M5B4NW0NNT00%O4=NNT11|M5B4NW0NNT00NNS%O5=NNT11|M5B4NW0NNT00NNS%O6=NNT11|M5B4NNT00NNS)
164 | WIN(W1=FFFF%W2=FFFF%W3=FFFF%W4=FFFF%W5=FFFF%W6=FFFF)
165 | ECN(R=Y%DF=N%T=7B-85%TG=80%W=0%O=%CC=N%Q=U)
166 | T1(R=Y%DF=Y%T=7B-85%TG=80%S=O%A=O|S+%F=A|AS%RD=0%Q=|U)
167 | T2(R=Y%DF=N%T=7B-85%TG=80%W=0%S=Z%A=S%F=AR%O=%RD=0%Q=U)
168 | T3(R=Y%DF=N%T=7B-85%TG=80%W=0%S=Z%A=O%F=AR%O=%RD=0%Q=U)
169 | T4(R=Y%DF=N%T=7B-85%TG=80%W=0%S=A%A=O%F=R%O=%RD=0%Q=U)
170 | T5(R=Y%DF=N%T=7B-85%TG=80%W=0%S=Z%A=S+%F=AR%O=%RD=0%Q=U)
171 | T6(R=Y%DF=N%T=7B-85%TG=80%W=0%S=A%A=O%F=R%O=%RD=0%Q=U)
172 | T7(R=Y%DF=N%T=7B-85%TG=80%W=0%S=Z%A=S+%F=AR%O=%RD=0%Q=U)
173 | U1(DF=N%T=7B-85%TG=80%IPL=38%UN=0%RIPL=G%RID=G%RIPCK=G%RUCK=G%RUD=G)
174 | IE(DFI=S%T=7B-85%TG=80%CD=Z)
175 | [+] Mutating to p0f:
176 | WWW:40320|TTL:128|D:1|SS:48|OOO:M*,N,N,S|QQ:.|OS:Windows|DETAILS:2000 SP4
177 | [+] Activating queues
178 | [->] Process-1: nmap packet processor
179 | [->] Process-2: p0f packet processor
180 | ```
181 |
182 | ## Searching for Operating Systems
183 | You can search inside nmap/p0f database for a specific OS, instead of getting the whole list. Just use the flag '-s' and enter the keyword you want to search for (case insensitive). You'll get any match found, and if it belongs to nmap or p0f databases:
184 | ```
185 | $ osfooler-ng -s playstation
186 | [+] Searching databases for: 'playstation'
187 | [nmap] "Sony Playstation 4 or FreeBSD 10.2-RELEASE"
188 | [nmap] "Sony PlayStation 2 game console test kit 2.2.1"
189 | [nmap] "Sony PlayStation 3 game console"
190 | [nmap] "Sony PlayStation 3 game console test kit"
191 | [nmap] "Sony PlayStation 2 game console"
192 | [p0f] OS: "Sony" DETAILS: "Playstation 2 (SOCOM?)"
193 | ```
194 |
195 | ## Update nmap database
196 | Use the flag '-u' to check if there's a new version of nmap's database avaiable and to download it
197 | ```
198 | $ osfooler-ng -u
199 | [+] Checking nmap database... latest!
200 | ```
201 |
202 | ## Custom flags
203 | There are other interesting flags:
204 | * '-v': Show info about every modified packet
205 | * '-i ': Choose network interface (eth0 by default)
206 | * '-V': Show OSfooler-ng banner and current version installed
207 |
208 | # Authors
209 | * **[Jaime Sánchez](https://www.seguridadofensiva.com) ([@segofensiva)](https://twitter.com/segofensiva)**
210 |
211 | # License
212 |
213 | This project is licensed under the The **GNU General Public License v3.0** - see the [LICENSE.md](LICENSE.md) file for details
214 |
215 | # Acknowledgments
216 |
217 | * https://github.com/segofensiva/OSfooler-ng#acknowledgments
218 |
--------------------------------------------------------------------------------
/bin/osfooler-ng:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env python
2 |
3 | import osfooler_ng
4 | osfooler_ng.main()
5 |
--------------------------------------------------------------------------------
/logo.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/moonbaseDelta/OSfooler-ng/287b15f8166f42a9f6d2033d5e3351726f2fae4d/logo.png
--------------------------------------------------------------------------------
/osfooler_ng/__init__.py:
--------------------------------------------------------------------------------
1 |
2 |
--------------------------------------------------------------------------------
/osfooler_ng/dep/p0f.fp:
--------------------------------------------------------------------------------
1 | #
2 | # p0f - SYN fingerprints
3 | # ----------------------
4 | #
5 | # .-------------------------------------------------------------------------.
6 | # | The purpose of this file is to cover signatures for incoming TCP/IP |
7 | # | connections (SYN packets). This is the default mode of operation for |
8 | # | p0f. This is also the biggest and most up-to-date set of signatures |
9 | # | shipped with this project. The file also contains a detailed discussion |
10 | # | of all metrics examined by p0f, and some practical notes on how to |
11 | # | add new signatures. |
12 | # `-------------------------------------------------------------------------'
13 | #
14 | # (C) Copyright 2000-2006 by Michal Zalewski
15 | #
16 | # Each line in this file specifies a single fingerprint. Please read the
17 | # information below carefully before attempting to append any signatures
18 | # reported by p0f as UNKNOWN to this file to avoid mistakes. Note that
19 | # this file is compatible only with the default operation mode, and not
20 | # with -R or -A options (SYN+ACK and RST+ modes).
21 | #
22 | # We use the following set metrics for fingerprinting:
23 | #
24 | # - Window size (WSS) - a highly OS dependent setting used for TCP/IP
25 | # performance control (max. amount of data to be sent without ACK).
26 | # Some systems use a fixed value for initial packets. On other
27 | # systems, it is a multiple of MSS or MTU (MSS+40). In some rare
28 | # cases, the value is just arbitrary.
29 | #
30 | # NEW SIGNATURE: if p0f reported a special value of 'Snn', the number
31 | # appears to be a multiple of MSS (MSS*nn); a special value of 'Tnn'
32 | # means it is a multiple of MTU ((MSS+40)*nn). Unless you notice the
33 | # value of nn is not fixed (unlikely), just copy the Snn or Tnn token
34 | # literally. If you know this device has a simple stack and a fixed
35 | # MTU, you can however multiply S value by MSS, or T value by MSS+40,
36 | # and put it instead of Snn or Tnn. One system may exhibit several T
37 | # or S values. In some situations, this might be a source of some
38 | # additional information about the setup if you have some time to dig
39 | # thru the kernel sources; in some other cases, like Windows, there seem
40 | # to be a multitude of variants and WSS selection algorithms, but it's
41 | # rather difficult to find a pattern without having the source.
42 | #
43 | # If WSS looks like a regular fixed value (for example is a power of two),
44 | # or if you can confirm the value is fixed by looking at several
45 | # fingerprints, please quote it literaly. If there's no apparent pattern
46 | # in WSS chosen, you should consider wildcarding this value - but this
47 | # should be the last option.
48 | #
49 | # NOTE: Some NAT devices, such as Linux iptables with --set-mss, will
50 | # modify MSS, but not WSS. As a result, MSS is changed to reflect
51 | # the MTU of the NAT device, but WSS remains a multiple of the original
52 | # MSS. Fortunately for us, the source device would almost always be
53 | # hooked up to Ethernet. P0f handles it automatically for the original
54 | # MSS of 1460, by adding "NAT!" tag to the result.
55 | #
56 | # In certain configurations, Linux erratically (?) uses MTU from another
57 | # interface on the default gw interface. This only happens on systems with
58 | # two network interfaces. Thus, some Linux systems that do not go thru NAT,
59 | # but have multiple interfaces instead, will be also tagged this way.
60 | #
61 | # P0f recognizes and automatically wildcards WSS of 12345, as generated
62 | # by sendack and sendsyn utilities shipped with the program, when
63 | # reporting a new signature. See test/sendack.c and test/sendsyn.c for more
64 | # information about this.
65 | #
66 | # - Overall packet size - a function of all IP and TCP options and bugs.
67 | # While this is partly redundant in the real world, we record this value
68 | # to capture rare cases when there are IP options (which we do not currently
69 | # examine) or packet data past the headers. Both situations are rare.
70 | #
71 | # Packet size MAY be wildcarded, but the meaning of the wildcard is
72 | # very special, and means the packet must be larger than PACKET_BIG
73 | # (defined in config.h as 100). This is usually not necessary, except
74 | # for some really broken implementations in RST+ mode. For more information,
75 | # see p0fr.fp. P0f automatically wildcards big packets when reporting
76 | # new signatures.
77 | #
78 | # NEW SIGNATURE: Copy this value literally.
79 | #
80 | # - Initial TTL - We check the actual TTL of a received packet. It can't
81 | # be higher than the initial TTL, and also shouldn't be dramatically
82 | # lower (maximum distance is defined in config.h as 40 hops).
83 | #
84 | # NEW SIGNATURE: *Never* copy TTL from a p0f-reported signature literally.
85 | # You need to determine the initial TTL. The best way to do it is to
86 | # check the documentation for a remote system, or check its settings.
87 | # A fairly good method is to simply round the observed TTL up to
88 | # 32, 64, 128, or 255, but it should be noted that some obscure devices
89 | # might not use round TTLs (in particular, some shoddy appliances and
90 | # IRIX and Tru64 are known to use "original" initial TTL settings). If not
91 | # sure, use traceroute or mtr to see how far you are from the host.
92 | #
93 | # Note that -F option overrides this check if no signature can be found.
94 | #
95 | # - Don't fragment flag (DF) - some modern OSes set this to implement PMTU
96 | # discovery. Others do not bother.
97 | #
98 | # NEW SIGNATURE: Copy this value literally. Note: this setting is
99 | # sometimes cleared by firewalls and/or certain connectivity clients.
100 | # Try to find out what's the actual state for a given OS if you see both,
101 | # and add the right one. P0f will automatically detect a case when a
102 | # firewall removed the DF flag and will append "(firewall!)" suffix to
103 | # the signature, so if the DF version is the right one, don't add no-DF
104 | # variant, unless it has a different meaning.
105 | #
106 | # - Maximum segment size (MSS) - this setting is usually link-dependent. P0f
107 | # uses it to determine link type of the remote host.
108 | #
109 | # NEW SIGNATURE: Always wildcard this value, except for rare cases when
110 | # you have an appliance with a fixed value, know the system supports only
111 | # a very limited number of network interface types, or know the system
112 | # is using a value it pulled out of nowhere. I use specific unique MSS
113 | # to tell Google crawlbots from the rest of Linux population, for example.
114 | #
115 | # If a specific MSS/MTU is unique to a certain link type, be sure to
116 | # add it to mtu.h instead of creating several variants of each signature.
117 | #
118 | # - Window scaling (WSCALE) - this feature is used to scale WSS.
119 | # It extends the size of a TCP/IP window to 32 bits, of sorts. Some modern
120 | # systems implement this feature.
121 | #
122 | # NEW SIGNATURE: Observe several signatures. Initial WSCALE is often set
123 | # to zero or other low value. There's usually no need to wildcard this
124 | # parameter.
125 | #
126 | # - Timestamp - some systems that implement timestamps set them to
127 | # zero in the initial SYN. This case is detected and handled appropriately.
128 | #
129 | # NEW SIGNATURE: Copy T or T0 option literally.
130 | #
131 | # - Selective ACK permitted - a flag set by systems that implement
132 | # selective ACK functionality,
133 | #
134 | # NEW SIGNATURE: copy S option literally.
135 | #
136 | # - NOP option - its presence, count and sequence is a useful OS-dependent
137 | # characteristic,
138 | #
139 | # NEW SIGNATURE: copy N options literally.
140 | #
141 | # - Other and unrecognized options (TTCP-related and such) - implemented by
142 | # some eccentric or very buggy TCP/IP stacks ;-),
143 | #
144 | # NEW SIGNATURE: copy ? options literally.
145 | #
146 | # - EOL option. Contrary to the popular belief, the presence of EOL
147 | # option is actually quite rare, most systems just NOP-pad to the
148 | # packet boundary.
149 | #
150 | # NEW SIGNATURE: copy E option literally.
151 | #
152 | # - The sequence of TCP all options mentioned above - this is very
153 | # specific to the implementation,
154 | #
155 | # NEW SIGNATURE: Copy the sequence literally.
156 | #
157 | # - Quirks. Some buggy stacks set certain values that should be zeroed in a
158 | # TCP packet to non-zero values. This has no effect as of today, but is
159 | # a valuable source of information. Some systems actually seem to leak
160 | # memory there. Other systems just exhibit harmful but very specific
161 | # behavior. This section captures all unusual yes-no properties not
162 | # related to the main and expected header layout. We detect the following:
163 | #
164 | # - Data past the headers. Neither SYN nor SYN+ACK packets are supposed
165 | # to carry any payload. If they do, we should take notice. The actual
166 | # payload is not examined, but will be displayed if use the -X option.
167 | # Note that payload is not unusual in RST+ mode (see p0fr.fp), very
168 | # rare otherwise.
169 | #
170 | # - Options past EOL. Some systems have some trailing data past EOL
171 | # in the options section of TCP/IP headers. P0f does not examine this
172 | # data as of today, simply detects its presence. If there is a
173 | # confirmed sizable population of systems that have data past EOL, it
174 | # might be a good idea to look at it. Until then, you have to recompile
175 | # p0f with DEBUG_EXTRAS set or use -x to display this data,
176 | #
177 | # - Zero IP ID. This again is a (mostly) harmless setting to use a fixed
178 | # IP ID for packets with DF set. Some systems reportedly use zero ID,
179 | # most OSes do not. There is a very slight probability of a false
180 | # positive when IP ID is "naturally" chosen to be zero on a system
181 | # that otherwise does set proper values, but the probability is
182 | # neglible (if it becomes a problem, recompile p0f with IGNORE_ZEROID
183 | # set in the sources).
184 | #
185 | # - IP options specified. Usually, packets do not have any IP options
186 | # set, but there can be some. Until there is a confirmed sizable
187 | # population of systems that do have IP options in a packet, p0f
188 | # does not examine those in detail, but it might change (use
189 | # DEBUG_EXTRAS or -x to display IP options if any found),
190 | #
191 | # - URG pointer value. SYN packets do not have URG flag set, so the
192 | # value in URG pointer in TCP header is ignored. Most systems set it
193 | # to zero, but some OSes (some versions of Windows, for example) do
194 | # not zero this field or even simply leak memory; the actual value is
195 | # not examined, because most cases seem to be just random garbage
196 | # (you can use DEBUG_EXTRAS or -x to report this information though);
197 | # see doc/win-memleak.txt for more information,
198 | #
199 | # - "Unused" field value. This should be always zero, but some systems
200 | # forget to clear it. This might result in some funny issues in the
201 | # future. P0f checks for non-zero value (and will display it if
202 | # DEBUG_EXTRAS is set, or you can use -x),
203 | #
204 | # - ACK number non-zero. ACK value in SYN packets with no ACK flag
205 | # is disregarded and is usually set to zero (just like with URG
206 | # pointer), but some systems forget to do it. The exact value is
207 | # not examined (but will be displayed with DEBUG_EXTRAS, or you can
208 | # use -x). Note that this is not an anomaly in SYN+ACK and RST+ modes,
209 | #
210 | # - Non-zero second timestamp. The initial SYN packet should have the
211 | # second timestamp always zeroed. SYN+ACK and RST+ may "legally" have
212 | # this quirk though,
213 | #
214 | # - Unusual flags. If, in addition to SYN (or SYN+ACK), there are some
215 | # auxilinary flags that do not modify the very meaning of a packet,
216 | # p0f records this (this can be URG, PUSH, or something else).
217 | #
218 | # Note: ECN flags (ECE and CWR) are ignored and denoted in a separate
219 | # way. ECN is never by default, because some systems can't handle it,
220 | # and it probably does not make much sense to include it in signatures
221 | # right now.
222 | #
223 | # - TCP option segment parsing problems. If p0f fails to decode options
224 | # because of a badly broken packet, it records this fact.
225 | #
226 | # There are several other quirks valid only in RST+ mode, see p0fr.fp for
227 | # more information. Those quirks are unheard of in SYN and SYN+ACK
228 | # modes.
229 | #
230 | # NEW SIGNATURE: Copy "quirks" section literally.
231 | #
232 | # We DO NOT use ToS for fingerprinting. While the original TCP/IP
233 | # fingerprinting research believed this value would be useful for this
234 | # purpose, it is not. The setting is way too often tweaked by network
235 | # devices.
236 | #
237 | # To wildcard MSS, WSS or WSCALE, replace it with '*'. You can also use a
238 | # modulo operator to match any values that divide by nnn - '%nnn' (and,
239 | # as stated above, WSS also supports special values Snn and Tnn).
240 | #
241 | # Fingerprint entry format:
242 | #
243 | # wwww:ttt:D:ss:OOO...:QQ:OS:Details
244 | #
245 | # wwww - window size (can be * or %nnn or Sxx or Txx)
246 | # "Snn" (multiple of MSS) and "Tnn" (multiple of MTU) are allowed.
247 | # ttt - initial TTL
248 | # D - don't fragment bit (0 - not set, 1 - set)
249 | # ss - overall SYN packet size (* has a special meaning)
250 | # OOO - option value and order specification (see below)
251 | # QQ - quirks list (see below)
252 | # OS - OS genre (Linux, Solaris, Windows)
253 | # details - OS description (2.0.27 on x86, etc)
254 | #
255 | # If OS genre starts with '*', p0f will not show distance, link type
256 | # and timestamp data. It is useful for userland TCP/IP stacks of
257 | # network scanners and so on, where many settings are randomized or
258 | # bogus.
259 | #
260 | # If OS genre starts with @, it denotes an approximate hit for a group
261 | # of operating systems (signature reporting still enabled in this case).
262 | # Use this feature at the end of this file to catch cases for which
263 | # you don't have a precise match, but can tell it's Windows or FreeBSD
264 | # or whatnot by looking at, say, flag layout alone.
265 | #
266 | # If OS genre starts with - (which can prefix @ or *), the entry is
267 | # not considered to be a real operating system (but userland stack
268 | # instead). It is important to mark all scanners and so on with -,
269 | # so that they are not used for masquerade detection (also add this
270 | # prefix for signatures of application-induced behavior, such as
271 | # increased window size with Opera browser).
272 | #
273 | # Option block description is a list of comma or space separated
274 | # options in the order they appear in the packet:
275 | #
276 | # N - NOP option
277 | # E - EOL option
278 | # Wnnn - window scaling option, value nnn (or * or %nnn)
279 | # Mnnn - maximum segment size option, value nnn (or * or %nnn)
280 | # S - selective ACK OK
281 | # T - timestamp
282 | # T0 - timestamp with zero value
283 | # ?n - unrecognized option number n.
284 | #
285 | # P0f can sometimes report ?nn among the options. This means it couldn't
286 | # recognize this option (option number nn). It's either a bug in p0f, or
287 | # a faulty TCP/IP stack, or, if the number is listed here:
288 | #
289 | # http://www.iana.org/assignments/tcp-parameters
290 | #
291 | # ...the stack might be simply quite exotic.
292 | #
293 | # To denote no TCP options, use a single '.'.
294 | #
295 | # Quirks section is usually an empty list ('.') of oddities or bugs of this
296 | # particular stack. List items are not separated in any way. Possible values:
297 | #
298 | # P - options past EOL,
299 | # Z - zero IP ID,
300 | # I - IP options specified,
301 | # U - urg pointer non-zero,
302 | # X - unused (x2) field non-zero,
303 | # A - ACK number non-zero,
304 | # T - non-zero second timestamp,
305 | # F - unusual flags (PUSH, URG, etc),
306 | # D - data payload,
307 | # ! - broken options segment.
308 | #
309 | # WARNING WARNING WARNING
310 | # -----------------------
311 | #
312 | # Do not add a system X as OS Y just because NMAP says so. It is often
313 | # the case that X is a NAT firewall. While nmap is talking to the
314 | # device itself, p0f is fingerprinting the guy behind the firewall
315 | # instead.
316 | #
317 | # When in doubt, use common sense, don't add something that looks like
318 | # a completely different system as Linux or FreeBSD or LinkSys router.
319 | # Check DNS name, establish a connection to the remote host and look
320 | # at SYN+ACK (p0f -A -S should do) - does it look similar?
321 | #
322 | # Some users tweak their TCP/IP settings - enable or disable RFC1323,
323 | # RFC1644 or RFC2018 support, disable PMTU discovery, change MTU, initial
324 | # TTL and so on. Always compare a new rule to other fingerprints for
325 | # this system, and verify the system isn't "customized". It is OK to
326 | # add signature variants caused by commonly used software (PFs, security
327 | # packages, etc), but it makes no sense to try to add every single
328 | # possible /proc/sys/net/ipv4/* tweak on Linux or so.
329 | #
330 | # KEEP IN MIND: Some packet firewalls configured to normalize outgoing
331 | # traffic (OpenBSD pf with "scrub" enabled, for example) will, well,
332 | # normalize packets. Signatures will not correspond to the originating
333 | # system (and probably not quite to the firewall either).
334 | #
335 | # NOTE: Try to keep this file in some reasonable order, from most to
336 | # least likely systems. This will speed up operation. Also keep most
337 | # generic and broad rules near ehe end.
338 | #
339 | # Still decided to add signature? Let us know - mail a copy of your discovery
340 | # to lcamtuf@coredump.cx. You can help make p0f better, and I can help you
341 | # make your signature more accurate.
342 | #
343 |
344 | ##########################
345 | # Standard OS signatures #
346 | ##########################
347 |
348 | # ----------------- AIX ---------------------
349 |
350 | # AIX is first because its signatures are close to NetBSD, MacOS X and
351 | # Linux 2.0, but it uses a fairly rare MSSes, at least sometimes...
352 | # This is a shoddy hack, though.
353 |
354 | 45046:64:0:44:M*:.:AIX:4.3
355 |
356 | 16384:64:0:44:M512:.:AIX:4.3.2 and earlier
357 |
358 | 16384:64:0:60:M512,N,W%2,N,N,T:.:AIX:4.3.3-5.2 (1)
359 | 32768:64:0:60:M512,N,W%2,N,N,T:.:AIX:4.3.3-5.2 (2)
360 | 65535:64:0:60:M512,N,W%2,N,N,T:.:AIX:4.3.3-5.2 (3)
361 |
362 | 65535:64:0:64:M*,N,W1,N,N,T,N,N,S:.:AIX:5.3 ML1
363 |
364 | # ----------------- Linux -------------------
365 |
366 | S1:64:0:44:M*:A:Linux:1.2.x
367 | 512:64:0:44:M*:.:Linux:2.0.3x (1)
368 | 16384:64:0:44:M*:.:Linux:2.0.3x (2)
369 |
370 | # Endian snafu! Nelson says "ha-ha":
371 | 2:64:0:44:M*:.:Linux:2.0.3x (MkLinux) on Mac (1)
372 | 64:64:0:44:M*:.:Linux:2.0.3x (MkLinux) on Mac (2)
373 |
374 | S4:64:1:60:M1360,S,T,N,W0:.:Linux:2.4 (Google crawlbot)
375 | S4:64:1:60:M1430,S,T,N,W0:.:Linux:2.4-2.6 (Google crawlbot)
376 |
377 | S2:64:1:60:M*,S,T,N,W0:.:Linux:2.4 (large MTU?)
378 | S3:64:1:60:M*,S,T,N,W0:.:Linux:2.4 (newer)
379 | S4:64:1:60:M*,S,T,N,W0:.:Linux:2.4-2.6
380 |
381 | S3:64:1:60:M*,S,T,N,W1:.:Linux:2.6, seldom 2.4 (older, 1)
382 | S4:64:1:60:M*,S,T,N,W1:.:Linux:2.6, seldom 2.4 (older, 2)
383 | S3:64:1:60:M*,S,T,N,W2:.:Linux:2.6, seldom 2.4 (older, 3)
384 | S4:64:1:60:M*,S,T,N,W2:.:Linux:2.6, seldom 2.4 (older, 4)
385 | T4:64:1:60:M*,S,T,N,W2:.:Linux:2.6 (older, 5)
386 |
387 | S4:64:1:60:M*,S,T,N,W5:.:Linux:2.6 (newer, 1)
388 | S4:64:1:60:M*,S,T,N,W6:.:Linux:2.6 (newer, 2)
389 | S4:64:1:60:M*,S,T,N,W7:.:Linux:2.6 (newer, 3)
390 | T4:64:1:60:M*,S,T,N,W7:.:Linux:2.6 (newer, 4)
391 |
392 |
393 | S20:64:1:60:M*,S,T,N,W0:.:Linux:2.2 (1)
394 | S22:64:1:60:M*,S,T,N,W0:.:Linux:2.2 (2)
395 | S11:64:1:60:M*,S,T,N,W0:.:Linux:2.2 (3)
396 |
397 | # Popular cluster config scripts disable timestamps and
398 | # selective ACK:
399 |
400 | S4:64:1:48:M1460,N,W0:.:Linux:2.4 in cluster
401 |
402 | # This happens only over loopback, but let's make folks happy:
403 | 32767:64:1:60:M16396,S,T,N,W0:.:Linux:2.4 (loopback)
404 | 32767:64:1:60:M16396,S,T,N,W2:.:Linux:2.6 (newer, loopback)
405 | S8:64:1:60:M3884,S,T,N,W0:.:Linux:2.2 (loopback)
406 |
407 | # Opera visitors:
408 | 16384:64:1:60:M*,S,T,N,W0:.:-Linux:2.2 (Opera?)
409 | 32767:64:1:60:M*,S,T,N,W0:.:-Linux:2.4 (Opera?)
410 |
411 | # Some fairly common mods & oddities:
412 | S22:64:1:52:M*,N,N,S,N,W0:.:Linux:2.2 (tstamp-)
413 | S4:64:1:52:M*,N,N,S,N,W0:.:Linux:2.4 (tstamp-)
414 | S4:64:1:52:M*,N,N,S,N,W2:.:Linux:2.6 (tstamp-)
415 | S4:64:1:44:M*:.:Linux:2.6? (barebone, rare!)
416 | T4:64:1:60:M1412,S,T,N,W0:.:Linux:2.4 (rare!)
417 |
418 | # ----------------- FreeBSD -----------------
419 |
420 | 16384:64:1:44:M*:.:FreeBSD:2.0-4.2
421 | 16384:64:1:60:M*,N,W0,N,N,T:.:FreeBSD:4.4 (1)
422 |
423 | 1024:64:1:60:M*,N,W0,N,N,T:.:FreeBSD:4.4 (2)
424 |
425 | 57344:64:1:44:M*:.:FreeBSD:4.6-4.8 (RFC1323-)
426 | 57344:64:1:60:M*,N,W0,N,N,T:.:FreeBSD:4.6-4.9
427 |
428 | 32768:64:1:60:M*,N,W0,N,N,T:.:FreeBSD:4.8-5.1 (or MacOS X 10.2-10.3)
429 | 65535:64:1:60:M*,N,W0,N,N,T:.:FreeBSD:4.7-5.2 (or MacOS X 10.2-10.4) (1)
430 | 65535:64:1:60:M*,N,W1,N,N,T:.:FreeBSD:4.7-5.2 (or MacOS X 10.2-10.4) (2)
431 |
432 | 65535:64:1:60:M*,N,W0,N,N,T:Z:FreeBSD:5.1 (1)
433 | 65535:64:1:60:M*,N,W1,N,N,T:Z:FreeBSD:5.1 (2)
434 | 65535:64:1:60:M*,N,W2,N,N,T:Z:FreeBSD:5.1 (3)
435 | 65535:64:1:64:M*,N,N,S,N,W1,N,N,T:.:FreeBSD:5.3-5.4
436 | 65535:64:1:64:M*,N,W1,N,N,T,S,E:P:FreeBSD:6.x (1)
437 | 65535:64:1:64:M*,N,W0,N,N,T,S,E:P:FreeBSD:6.x (2)
438 |
439 | 65535:64:1:44:M*:Z:FreeBSD:5.2 (RFC1323-)
440 |
441 | # 16384:64:1:60:M*,N,N,N,N,N,N,T:.:FreeBSD:4.4 (tstamp-)
442 |
443 | # ----------------- NetBSD ------------------
444 |
445 | 16384:64:0:60:M*,N,W0,N,N,T:.:NetBSD:1.3
446 | 65535:64:0:60:M*,N,W0,N,N,T0:.:-NetBSD:1.6 (Opera)
447 | 16384:64:1:60:M*,N,W0,N,N,T0:.:NetBSD:1.6
448 | 65535:64:1:60:M*,N,W1,N,N,T0:.:NetBSD:1.6W-current (DF)
449 | 65535:64:1:60:M*,N,W0,N,N,T0:.:NetBSD:1.6X (DF)
450 | 32768:64:1:60:M*,N,W0,N,N,T0:.:NetBSD:1.6Z or 2.0 (DF)
451 | 32768:64:1:64:M1416,N,W0,S,N,N,N,N,T0:.:NetBSD:2.0G (DF)
452 | 32768:64:1:64:M*,N,W0,S,N,N,N,N,T0:.:NetBSD:3.0 (DF)
453 |
454 | # ----------------- OpenBSD -----------------
455 |
456 | 16384:64:1:64:M*,N,N,S,N,W0,N,N,T:.:OpenBSD:3.0-3.9
457 | 57344:64:1:64:M*,N,N,S,N,W0,N,N,T:.:OpenBSD:3.3-3.4
458 | 16384:64:0:64:M*,N,N,S,N,W0,N,N,T:.:OpenBSD:3.0-3.4 (scrub)
459 | 65535:64:1:64:M*,N,N,S,N,W0,N,N,T:.:-OpenBSD:3.0-3.4 (Opera?)
460 | 32768:64:1:64:M*,N,N,S,N,W0,N,N,T:.:OpenBSD:3.7
461 |
462 | # ----------------- Solaris -----------------
463 |
464 | S17:64:1:64:N,W3,N,N,T0,N,N,S,M*:.:Solaris:8 (RFC1323 on)
465 | S17:64:1:48:N,N,S,M*:.:Solaris:8 (1)
466 | S17:255:1:44:M*:.:Solaris:2.5-7 (1)
467 |
468 | # Sometimes, just sometimes, Solaris feels like coming up with
469 | # rather arbitrary MSS values ;-)
470 |
471 | S6:255:1:44:M*:.:Solaris:2.5-7 (2)
472 | S23:64:1:48:N,N,S,M*:.:Solaris:8 (2)
473 | S34:64:1:48:M*,N,N,S:.:Solaris:9
474 | S34:64:1:48:M*,N,N,N,N:.:Solaris:9 (no sack)
475 | S44:255:1:44:M*:.:Solaris:7
476 |
477 | 4096:64:0:44:M1460:.:SunOS:4.1.x
478 |
479 | S34:64:1:52:M*,N,W0,N,N,S:.:Solaris:10 (beta)
480 | 32850:64:1:64:M*,N,N,T,N,W1,N,N,S:.:Solaris:10 (1203?)
481 | 32850:64:1:64:M*,N,W1,N,N,T,N,N,S:.:Solaris:9.1
482 |
483 | # ----------------- IRIX --------------------
484 |
485 | 49152:60:0:44:M*:.:IRIX:6.2-6.4
486 | 61440:60:0:44:M*:.:IRIX:6.2-6.5
487 | 49152:60:0:52:M*,N,W2,N,N,S:.:IRIX:6.5 (RFC1323+) (1)
488 | 49152:60:0:52:M*,N,W3,N,N,S:.:IRIX:6.5 (RFC1323+) (2)
489 |
490 | 61440:60:0:48:M*,N,N,S:.:IRIX:6.5.12-6.5.21 (1)
491 | 49152:60:0:48:M*,N,N,S:.:IRIX:6.5.12-6.5.21 (2)
492 |
493 | 49152:60:0:64:M*,N,W2,N,N,T,N,N,S:.:IRIX:6.5 IP27
494 |
495 | # ----------------- Tru64 -------------------
496 | # Tru64 and OpenVMS share the same stack on occassions.
497 | # Relax.
498 |
499 | 32768:60:1:48:M*,N,W0:.:Tru64:4.0 (or OS/2 Warp 4)
500 | 32768:60:0:48:M*,N,W0:.:Tru64:5.0 (or OpenVMS 7.x on Compaq 5.0 stack)
501 | 8192:60:0:44:M1460:.:Tru64:5.1 (no RFC1323) (or QNX 6)
502 | 61440:60:0:48:M*,N,W0:.:Tru64:v5.1a JP4 (or OpenVMS 7.x on Compaq 5.x stack)
503 |
504 | # ----------------- OpenVMS -----------------
505 |
506 | 6144:64:1:60:M*,N,W0,N,N,T:.:OpenVMS:7.2 (Multinet 4.3-4.4 stack)
507 |
508 | # ----------------- MacOS -------------------
509 |
510 | S2:255:1:48:M*,W0,E:.:MacOS:8.6 classic
511 |
512 | 16616:255:1:48:M*,W0,E:.:MacOS:7.3-8.6 (OTTCP)
513 | 16616:255:1:48:M*,N,N,N,E:.:MacOS:8.1-8.6 (OTTCP)
514 | 32768:255:1:48:M*,W0,N:.:MacOS:9.0-9.2
515 |
516 | 32768:255:1:48:M1380,N,N,N,N:.:MacOS:9.1 (OT 2.7.4) (1)
517 | 65535:255:1:48:M*,N,N,N,N:.:MacOS:9.1 (OT 2.7.4) (2)
518 |
519 | # ----------------- Windows -----------------
520 |
521 | # Windows TCP/IP stack is a mess. For most recent XP, 2000 and
522 | # even 98, the pathlevel, not the actual OS version, is more
523 | # relevant to the signature. They share the same code, so it would
524 | # seem. Luckily for us, almost all Windows 9x boxes have an
525 | # awkward MSS of 536, which I use to tell one from another
526 | # in most difficult cases.
527 |
528 | 8192:32:1:44:M*:.:Windows:3.11 (Tucows)
529 | S44:64:1:64:M*,N,W0,N,N,T0,N,N,S:.:Windows:95
530 | 8192:128:1:64:M*,N,W0,N,N,T0,N,N,S:.:Windows:95b
531 |
532 | # There were so many tweaking tools and so many stack versions for
533 | # Windows 98 it is no longer possible to tell them from each other
534 | # without some very serious research. Until then, there's an insane
535 | # number of signatures, for your amusement:
536 |
537 | S44:32:1:48:M*,N,N,S:.:Windows:98 (low TTL) (1)
538 | 8192:32:1:48:M*,N,N,S:.:Windows:98 (low TTL) (2)
539 | %8192:64:1:48:M536,N,N,S:.:Windows:98 (13)
540 | %8192:128:1:48:M536,N,N,S:.:Windows:98 (15)
541 | S4:64:1:48:M*,N,N,S:.:Windows:98 (1)
542 | S6:64:1:48:M*,N,N,S:.:Windows:98 (2)
543 | S12:64:1:48:M*,N,N,S:.:Windows:98 (3
544 | T30:64:1:64:M1460,N,W0,N,N,T0,N,N,S:.:Windows:98 (16)
545 | 32767:64:1:48:M*,N,N,S:.:Windows:98 (4)
546 | 37300:64:1:48:M*,N,N,S:.:Windows:98 (5)
547 | 46080:64:1:52:M*,N,W3,N,N,S:.:Windows:98 (RFC1323+)
548 | 65535:64:1:44:M*:.:Windows:98 (no sack)
549 | S16:128:1:48:M*,N,N,S:.:Windows:98 (6)
550 | S16:128:1:64:M*,N,W0,N,N,T0,N,N,S:.:Windows:98 (7)
551 | S26:128:1:48:M*,N,N,S:.:Windows:98 (8)
552 | T30:128:1:48:M*,N,N,S:.:Windows:98 (9)
553 | 32767:128:1:52:M*,N,W0,N,N,S:.:Windows:98 (10)
554 | 60352:128:1:48:M*,N,N,S:.:Windows:98 (11)
555 | 60352:128:1:64:M*,N,W2,N,N,T0,N,N,S:.:Windows:98 (12)
556 |
557 | # What's with 1414 on NT?
558 | T31:128:1:44:M1414:.:Windows:NT 4.0 SP6a (1)
559 | 64512:128:1:44:M1414:.:Windows:NT 4.0 SP6a (2)
560 | 8192:128:1:44:M*:.:Windows:NT 4.0 (older)
561 |
562 | # Windows XP and 2000. Most of the signatures that were
563 | # either dubious or non-specific (no service pack data)
564 | # were deleted and replaced with generics at the end.
565 |
566 | 65535:128:1:48:M*,N,N,S:.:Windows:2000 SP4, XP SP1+
567 | %8192:128:1:48:M*,N,N,S:.:Windows:2000 SP2+, XP SP1+ (seldom 98)
568 | S20:128:1:48:M*,N,N,S:.:Windows:SP3
569 | S45:128:1:48:M*,N,N,S:.:Windows:2000 SP4, XP SP1+ (2)
570 | 40320:128:1:48:M*,N,N,S:.:Windows:2000 SP4
571 |
572 | S6:128:1:48:M*,N,N,S:.:Windows:XP, 2000 SP2+
573 | S12:128:1:48:M*,N,N,S:.:Windows:XP SP1+ (1)
574 | S44:128:1:48:M*,N,N,S:.:Windows:XP SP1+, 2000 SP3
575 | 64512:128:1:48:M*,N,N,S:.:Windows:XP SP1+, 2000 SP3 (2)
576 | 32767:128:1:48:M*,N,N,S:.:Windows:XP SP1+, 2000 SP4 (3)
577 |
578 | # Windows 2003 & Vista
579 |
580 | 8192:128:1:52:M*,W8,N,N,N,S:.:Windows:Vista (beta)
581 | 32768:32:1:52:M1460,N,W0,N,N,S:.:Windows:2003 AS
582 | 65535:64:1:52:M1460,N,W2,N,N,S:.:Windows:2003 (1)
583 | 65535:64:1:48:M1460,N,N,S:.:Windows:2003 (2)
584 |
585 | # Odds, ends, mods:
586 |
587 | S52:128:1:48:M1260,N,N,S:.:Windows:XP/2000 via Cisco
588 | 65520:128:1:48:M*,N,N,S:.:Windows:XP bare-bone
589 | 16384:128:1:52:M536,N,W0,N,N,S:.:Windows:2000 w/ZoneAlarm?
590 | 2048:255:0:40:.:.:Windows:.NET Enterprise Server
591 | 44620:64:0:48:M*,N,N,S:.:Windows:ME no SP (?)
592 | S6:255:1:48:M536,N,N,S:.:Windows:95 winsock 2
593 | 32000:128:0:48:M*,N,N,S:.:Windows:XP w/Winroute?
594 | 16384:64:1:48:M1452,N,N,S:.:Windows:XP w/Sygate? (1)
595 | 17256:64:1:48:M1460,N,N,S:.:Windows:XP w/Sygate? (2)
596 |
597 | # No need to be more specific, it passes:
598 | *:128:1:48:M*,N,N,S:U:-Windows:XP/2000 while downloading (leak!)
599 |
600 | # ----------------- HP/UX -------------------
601 |
602 | 32768:64:1:44:M*:.:HP-UX:B.10.20
603 | 32768:64:1:48:M*,W0,N:.:HP-UX:11.00-11.11
604 |
605 | # Whoa. Hardcore WSS.
606 | 0:64:0:48:M*,W0,N:.:HP-UX:B.11.00 A (RFC1323+)
607 |
608 | # ----------------- RiscOS ------------------
609 |
610 | 16384:64:1:68:M1460,N,W0,N,N,T,N,N,?12:.:RISC OS:3.70-4.36 (inet 5.04)
611 | 12288:32:0:44:M536:.:RISC OS:3.70 inet 4.10
612 | 4096:64:1:56:M1460,N,N,T:T:RISC OS:3.70 freenet 2.00
613 |
614 | # ----------------- BSD/OS ------------------
615 |
616 | 8192:64:1:60:M1460,N,W0,N,N,T:.:BSD/OS:3.1-4.3 (or MacOS X 10.2)
617 |
618 | # ---------------- NetwonOS -----------------
619 |
620 | 4096:64:0:44:M1420:.:NewtonOS:2.1
621 |
622 | # ---------------- NeXTSTEP -----------------
623 |
624 | S8:64:0:44:M512:.:NeXTSTEP:3.3 (1)
625 | S4:64:0:44:M1024:.:NeXTSTEP:3.3 (2)
626 |
627 | # ------------------ BeOS -------------------
628 |
629 | 1024:255:0:48:M*,N,W0:.:BeOS:5.0-5.1
630 | 12288:255:0:44:M*:.:BeOS:5.0.x
631 |
632 | # ------------------ OS/400 -----------------
633 |
634 | 8192:64:1:60:M1440,N,W0,N,N,T:.:OS/400:V4R4/R5
635 | 8192:64:0:44:M536:.:OS/400:V4R3/M0
636 | 4096:64:1:60:M1440,N,W0,N,N,T:.:OS/400:V4R5 + CF67032
637 |
638 | 28672:64:0:44:M1460:A:OS/390:?
639 |
640 | # ------------------ ULTRIX -----------------
641 |
642 | 16384:64:0:40:.:.:ULTRIX:4.5
643 |
644 | # ------------------- QNX -------------------
645 |
646 | S16:64:0:44:M512:.:QNX:demodisk
647 | 16384:64:0:60:M1460,N,W0,N,N,T0:.:QNX:6.x
648 |
649 | # ------------------ Novell -----------------
650 |
651 | 16384:128:1:44:M1460:.:Novell:NetWare 5.0
652 | 6144:128:1:44:M1460:.:Novell:IntranetWare 4.11
653 | 6144:128:1:44:M1368:.:Novell:BorderManager ?
654 |
655 | # According to rfp:
656 | 6144:128:1:52:M*,W0,N,S,N,N:.:Novell:Netware 6 SP3
657 |
658 | # -------------- SCO UnixWare ---------------
659 |
660 | S3:64:1:60:M1460,N,W0,N,N,T:.:SCO:UnixWare 7.1
661 | S17:64:1:60:M*,N,W0,N,N,T:.:SCO:UnixWare 7.1.x
662 | S23:64:1:44:M1380:.:SCO:OpenServer 5.0
663 |
664 | # ------------------- DOS -------------------
665 |
666 | 2048:255:0:44:M536:.:DOS:Arachne via WATTCP/1.05
667 | T2:255:0:44:M984:.:DOS:Arachne via WATTCP/1.05 (eepro)
668 | 16383:64:0:44:M536:.:DOS:Unknown via WATTCP (epppd)
669 |
670 | # ------------------ OS/2 -------------------
671 |
672 | S56:64:0:44:M512:.:OS/2:4
673 | 28672:64:0:44:M1460:.:OS/2:Warp 4.0
674 |
675 | # ----------------- TOPS-20 -----------------
676 |
677 | # Another hardcore MSS, one of the ACK leakers hunted down.
678 | 0:64:0:44:M1460:A:TOPS-20:version 7
679 |
680 | # ------------------ AMIGA ------------------
681 |
682 | S32:64:1:56:M*,N,N,S,N,N,?12:.:AMIGA:3.9 BB2 with Miami stack
683 |
684 | # ------------------ Minix ------------------
685 |
686 | # Not quite sure.
687 | # 8192:210:0:44:M1460:X:@Minix:?
688 |
689 | # ------------------ Plan9 ------------------
690 |
691 | 65535:255:0:48:M1460,W0,N:.:Plan9:edition 4
692 |
693 | # ----------------- AMIGAOS -----------------
694 |
695 | 16384:64:1:48:M1560,N,N,S:.:AMIGAOS:3.9 BB2 MiamiDX
696 |
697 | # ----------------- FreeMiNT ----------------
698 |
699 | S44:255:0:44:M536:.:FreeMiNT:1 patch 16A (Atari)
700 |
701 | ###########################################
702 | # Appliance / embedded / other signatures #
703 | ###########################################
704 |
705 | # ---------- Firewalls / routers ------------
706 |
707 | S12:64:1:44:M1460:.:@Checkpoint:(unknown 1)
708 | S12:64:1:48:N,N,S,M1460:.:@Checkpoint:(unknown 2)
709 | 4096:32:0:44:M1460:.:ExtremeWare:4.x
710 |
711 | S32:64:0:68:M512,N,W0,N,N,T,N,N,?12:.:Nokia:IPSO w/Checkpoint NG FP3
712 | S16:64:0:68:M1024,N,W0,N,N,T,N,N,?12:.:Nokia:IPSO 3.7 build 026
713 |
714 | S4:64:1:60:W0,N,S,T,M1460:.:FortiNet:FortiGate 50
715 |
716 | 8192:64:1:44:M1460:.:@Eagle:Secure Gateway
717 |
718 | # ------- Switches and other stuff ----------
719 |
720 | 4128:255:0:44:M*:Z:Cisco:7200, Catalyst 3500, etc
721 | S8:255:0:44:M*:.:Cisco:12008
722 | S4:255:0:44:M536:Z:Cisco:IOS 11.0
723 | 60352:128:1:64:M1460,N,W2,N,N,T,N,N,S:.:Alteon:ACEswitch
724 | 64512:128:1:44:M1370:.:Nortel:Contivity Client
725 |
726 | # ---------- Caches and whatnots ------------
727 |
728 | 8190:255:0:44:M1428:.:Google:Wireless Transcoder (1)
729 | 8190:255:0:44:M1460:.:Google:Wireless Transcoder (2)
730 | 8192:64:1:64:M1460,N,N,S,N,W0,N,N,T:.:NetCache:5.2
731 | 16384:64:1:64:M1460,N,N,S,N,W0,N:.:NetCache:5.3
732 | 65535:64:1:64:M1460,N,N,S,N,W*,N,N,T:.:NetCache:5.3-5.5 (or FreeBSD 5.4)
733 | 20480:64:1:64:M1460,N,N,S,N,W0,N,N,T:.:NetCache:4.1
734 | S44:64:1:64:M1460,N,N,S,N,W0,N,N,T:.:NetCache:5.5
735 |
736 | 32850:64:1:64:N,W1,N,N,T,N,N,S,M*:.:NetCache:Data OnTap 5.x
737 |
738 | 65535:64:0:60:M1460,N,W0,N,N,T:.:CacheFlow:CacheOS 4.1
739 | 8192:64:0:60:M1380,N,N,N,N,N,N,T:.:CacheFlow:CacheOS 1.1
740 |
741 | S4:64:0:48:M1460,N,N,S:.:Cisco:Content Engine
742 |
743 | 27085:128:0:40:.:.:Dell:PowerApp cache (Linux-based)
744 |
745 | 65535:255:1:48:N,W1,M1460:.:Inktomi:crawler
746 | S1:255:1:60:M1460,S,T,N,W0:.:LookSmart:ZyBorg
747 |
748 | 16384:255:0:40:.:.:Proxyblocker:(what's this?)
749 |
750 | 65535:255:0:48:M*,N,N,S:.:Redline: T|X 2200
751 |
752 | # ----------- Embedded systems --------------
753 |
754 | S9:255:0:44:M536:.:PalmOS:Tungsten T3/C
755 | S5:255:0:44:M536:.:PalmOS:3/4
756 | S4:255:0:44:M536:.:PalmOS:3.5
757 | 2948:255:0:44:M536:.:PalmOS:3.5.3 (Handera)
758 | S29:255:0:44:M536:.:PalmOS:5.0
759 | 16384:255:0:44:M1398:.:PalmOS:5.2 (Clie)
760 | S14:255:0:44:M1350:.:PalmOS:5.2.1 (Treo)
761 | 16384:255:0:44:M1400:.:PalmOS:5.2 (Sony)
762 |
763 | S23:64:1:64:N,W1,N,N,T,N,N,S,M1460:.:SymbianOS:7
764 | 8192:255:0:44:M1460:.:SymbianOS:6048 (Nokia 7650?)
765 | 8192:255:0:44:M536:.:SymbianOS:(Nokia 9210?)
766 | S22:64:1:56:M1460,T,S:.:SymbianOS:? (SE P800?)
767 | S36:64:1:56:M1360,T,S:.:SymbianOS:60xx (Nokia 6600?)
768 | S36:64:1:60:M1360,T,S,W0,E:.:SymbianOS:60xx
769 |
770 | 32768:32:1:44:M1460:.:Windows:CE 3
771 |
772 | # Perhaps S4?
773 | 5840:64:1:60:M1452,S,T,N,W1:.:Zaurus:3.10
774 |
775 | 32768:128:1:64:M1460,N,W0,N,N,T0,N,N,S:.:PocketPC:2002
776 |
777 | S1:255:0:44:M346:.:Contiki:1.1-rc0
778 |
779 | 4096:128:0:44:M1460:.:Sega:Dreamcast Dreamkey 3.0
780 | T5:64:0:44:M536:.:Sega:Dreamcast HKT-3020 (browser disc 51027)
781 | S22:64:1:44:M1460:.:Sony:Playstation 2 (SOCOM?)
782 |
783 | S12:64:0:44:M1452:.:AXIS:Printer Server 5600 v5.64
784 |
785 | 3100:32:1:44:M1460:.:Windows:CE 2.0
786 |
787 | ####################
788 | # Fancy signatures #
789 | ####################
790 |
791 | 1024:64:0:40:.:.:-*NMAP:syn scan (1)
792 | 2048:64:0:40:.:.:-*NMAP:syn scan (2)
793 | 3072:64:0:40:.:.:-*NMAP:syn scan (3)
794 | 4096:64:0:40:.:.:-*NMAP:syn scan (4)
795 |
796 | 1024:64:0:40:.:A:-*NMAP:TCP sweep probe (1)
797 | 2048:64:0:40:.:A:-*NMAP:TCP sweep probe (2)
798 | 3072:64:0:40:.:A:-*NMAP:TCP sweep probe (3)
799 | 4096:64:0:40:.:A:-*NMAP:TCP sweep probe (4)
800 |
801 | 1024:64:0:60:W10,N,M265,T,E:P:-*NMAP:OS detection probe (1)
802 | 2048:64:0:60:W10,N,M265,T,E:P:-*NMAP:OS detection probe (2)
803 | 3072:64:0:60:W10,N,M265,T,E:P:-*NMAP:OS detection probe (3)
804 | 4096:64:0:60:W10,N,M265,T,E:P:-*NMAP:OS detection probe (4)
805 |
806 | 1024:64:0:60:W10,N,M265,T,E:PF:-*NMAP:OS detection probe w/flags (1)
807 | 2048:64:0:60:W10,N,M265,T,E:PF:-*NMAP:OS detection probe w/flags (2)
808 | 3072:64:0:60:W10,N,M265,T,E:PF:-*NMAP:OS detection probe w/flags (3)
809 | 4096:64:0:60:W10,N,M265,T,E:PF:-*NMAP:OS detection probe w/flags (4)
810 |
811 | 32767:64:0:40:.:.:-*NAST:syn scan
812 |
813 | 12345:255:0:40:.:A:-p0f:sendsyn utility
814 |
815 | # UFO - see tmp/*:
816 | 56922:128:0:40:.:A:-@Mysterious:port scanner (?)
817 | 5792:64:1:60:M1460,S,T,N,W0:T:-@Mysterious:NAT device (2nd tstamp)
818 | S12:128:1:48:M1460,E:P:@Mysterious:Chello proxy (?)
819 | S23:64:1:64:N,W1,N,N,T,N,N,S,M1380:.:@Mysterious:GPRS gateway (?)
820 |
821 | #####################################
822 | # Generic signatures - just in case #
823 | #####################################
824 |
825 | *:128:1:52:M*,N,W0,N,N,S:.:@Windows:XP/2000 (RFC1323+, w, tstamp-)
826 | *:128:1:52:M*,N,W*,N,N,S:.:@Windows:XP/2000 (RFC1323+, w+, tstamp-)
827 | *:128:1:52:M*,N,N,T0,N,N,S:.:@Windows:XP/2000 (RFC1323+, w-, tstamp+)
828 | *:128:1:64:M*,N,W0,N,N,T0,N,N,S:.:@Windows:XP/2000 (RFC1323+, w, tstamp+)
829 | *:128:1:64:M*,N,W*,N,N,T0,N,N,S:.:@Windows:XP/2000 (RFC1323+, w+, tstamp+)
830 |
831 | *:128:1:48:M536,N,N,S:.:@Windows:98
832 | *:128:1:48:M*,N,N,S:.:@Windows:XP/2000
833 |
834 |
835 |
--------------------------------------------------------------------------------
/osfooler_ng/dep/p0fa.fp:
--------------------------------------------------------------------------------
1 | #
2 | # p0f - SYN+ACK fingerprints
3 | # --------------------------
4 | #
5 | # .-------------------------------------------------------------------------.
6 | # | The purpose of this file is to cover signatures for outgoing TCP/IP |
7 | # | connections (SYN+ACK packets). This mode of operation can be enabled |
8 | # | with -A option. Please refer to p0f.fp for information on the metrics |
9 | # | used to create a signature, and for a guide on adding new entries to |
10 | # | those files. This database is somewhat neglected, and is looking for a |
11 | # | caring maintainer. |
12 | # `-------------------------------------------------------------------------'
13 | #
14 | # (C) Copyright 2000-2006 by Michal Zalewski
15 | #
16 | # Plenty of signatures contributed in bulk by rain forest puppy, Paul Woo and
17 | # Michael Bauer.
18 | #
19 | # Submit all additions to the authors. Read p0f.fp before adding any
20 | # signatures. Run p0f -A -C after making any modifications. This file is
21 | # NOT compatible with SYN, RST+, or stray ACK modes. Use only with -A option.
22 | #
23 | # Feel like contributing? You can run p0f -A -K, then test/tryid -iR nnn...
24 | #
25 | # IMPORTANT INFORMATION ABOUT THE INTERDEPENDENCY OF SYNs AND SYN+ACKs
26 | # --------------------------------------------------------------------
27 | #
28 | # Some systems would have different SYN+ACK fingerprints depending on
29 | # the system that sent SYN. More specifically, RFC1323, RFC2018 and
30 | # RFC1644 extensions sometimes show up only if SYN had them enabled.
31 | #
32 | # Also, some silly systems may copy WSS from the SYN packet you've sent,
33 | # in which case, you need to wildcard the value. Use test/sendsyn.c, which
34 | # uses a distinct WSS of 12345, to test for this condition if unsure.
35 | #
36 | # IMPORTANT INFORMATION ABOUT DIFFERENCES IN COMPARISON TO p0f.fp:
37 | # ----------------------------------------------------------------
38 | #
39 | # - 'A' quirk would be present on almost every signature here. ACK number
40 | # is unusual for SYN packets, but is a commonplace in SYN+ACK packets,
41 | # of course. It is still possible to have a signature without 'A', when
42 | # the ACK flag is present but the value is zero - this, however, is
43 | # very uncommon.
44 | #
45 | # - 'T' quirk would show up on almost all signatures for systems implementing
46 | # RFC1323. The second timestamp is only unusual for SYN packets. SYN+ACK
47 | # are expected to have it set.
48 | #
49 |
50 | ##########################
51 | # Standard OS signatures #
52 | ##########################
53 |
54 | # ---------------- Linux -------------------
55 |
56 | 32736:64:0:44:M*:A:Linux:2.0
57 | S22:64:1:60:M*,S,T,N,W0:AT:Linux:2.2
58 | S22:64:1:52:M*,N,N,S,N,W0:A:Linux:2.2 w/o timestamps
59 |
60 | 5792:64:1:60:M*,S,T,N,W0:AT:Linux:older 2.4
61 | 5792:64:1:60:M*,S,T,N,W0:ZAT:Linux:recent 2.4 (1)
62 | S4:64:1:44:M*:ZA:Linux:recent 2.4 (2)
63 | 5792:64:1:44:M*:ZA:Linux:recent 2.4 (3)
64 |
65 | S4:64:1:52:M*,N,N,S,N,W0:ZA:Linux:2.4 w/o timestamps
66 |
67 | # --------------- Windows ------------------
68 |
69 | 65535:128:1:64:M*,N,W0,N,N,T0,N,N,S:A:Windows:2000 SP4
70 | S44:128:1:64:M*,N,W0,N,N,T0,N,N,S:A:Windows:XP SP1
71 | S12:128:1:64:M*,N,W0,N,N,T0,N,N,S:A:Windows:2000 (SP1+)
72 | S6:128:1:44:M*:A:Windows:NT 4.0 SP1+
73 | 65535:128:1:48:M*,N,N,S:A:Windows:98 (SE)
74 | 65535:128:1:44:M*:A:Windows:2000 (1)
75 | 16616:128:1:44:M*:A:Windows:2003
76 | 16384:128:1:44:M*:A:Windows:2000 (2)
77 | S16:128:1:44:M*:A:Windows:2000 (3)
78 |
79 | # ------------------- OpenBSD --------------
80 |
81 | 17376:64:1:64:M*,N,N,S,N,W0,N,N,T:AT:OpenBSD:3.3
82 |
83 | # ------------------- NetBSD ----------------
84 |
85 | 16384:64:0:60:M*,N,W0,N,N,T0:AT:NetBSD:1.6
86 |
87 | # ----------------- HP/UX ------------------
88 |
89 | 32768:64:1:44:M*:A:HPUX:10.20
90 |
91 | # ----------------- Tru64 ------------------
92 |
93 | S23:60:0:48:M*,N,W0:A:Tru64:5.0 (1)
94 | 65535:64:0:44:M*:A:Tru64:5.0 (2)
95 |
96 | # ----------------- Novell -----------------
97 |
98 | 6144:128:1:52:M*,W0,N,S,N,N:A:Novell:Netware 6.0 (SP3)
99 | 32768:128:1:44:M*:A:Novell:Netware 5.1
100 |
101 | # ------------------ IRIX ------------------
102 |
103 | 60816:60:1:60:M*,N,W0,N,N,T:AT:IRIX:6.5.0
104 |
105 | # ----------------- Solaris ----------------
106 |
107 | 49232:64:1:64:N,N,T,M*,N,W0,N,N,S:AT:Solaris:9 (1)
108 | S1:255:1:60:N,N,T,N,W0,M*:AT:Solaris:7
109 | 24656:64:1:44:M*:A:Solaris:8
110 | 33304:64:1:60:N,N,T,M*,N,W1:AT:Solaris:9 (2)
111 |
112 | # ----------------- FreeBSD ----------------
113 |
114 | 65535:64:1:60:M*,N,W1,N,N,T:AT:FreeBSD:5.0
115 | 57344:64:1:44:M*:A:FreeBSD:4.6-4.8
116 | 65535:64:1:44:M*:A:FreeBSD:4.4
117 |
118 | 57344:64:1:48:M1460,N,W0:A:FreeBSD:4.6-4.8 (wscale)
119 | 57344:64:1:60:M1460,N,W0,N,N,T:AT:FreeBSD:4.6-4.8 (RFC1323)
120 |
121 | # ------------------- AIX ------------------
122 |
123 | S17:255:1:44:M536:A:AIX:4.2
124 |
125 | S12:64:0:44:M1460:A:AIX:5.2 ML04 (1)
126 | S42:64:0:44:M1460:A:AIX:5.2 ML04 (2)
127 |
128 | # ------------------ BSD/OS ----------------
129 |
130 | S6:64:1:60:M1460,N,W0,N,N,T:AT:BSD/OS:4.0.x
131 |
132 | # ------------------ OS/390 ----------------
133 |
134 | 2048:64:0:44:M1460:A:OS/390:?
135 |
136 | # ------------------ Novell ----------------
137 |
138 | 6144:128:1:44:M1400:A:Novell:iChain 2.2
139 |
140 | # ------------------ MacOS -----------------
141 |
142 | 33304:64:1:60:M*,N,W0,N,N,T:AT:MacOS:X 10.2.6
143 |
144 | #################################################################
145 | # Contributed by Ryan Kruse - trial run #
146 | #################################################################
147 |
148 | # S4:255:0:44:M1024:A:Cisco:LocalDirector
149 | # 1024:255:0:44:M536:A:Cisco,3COM,Nortel:CatIOS,SuperStack,BayStack
150 | # S16:64:0:44:M512:A:Nortel:Contivity
151 | # 8192:64:0:44:M1460:A:Cisco,Nortel,SonicWall,Tasman:Aironet,BayStack Switch,Soho,1200
152 | # 4096:255:0:44:M1460:A:Cisco:PIX,CatOS
153 | # 8192:128:0:44:M1460:A:Cisco:VPN Concentrator
154 | # 8192:128:0:60:M1460,N,W0,N,N,T:AT:Cisco:VPN Concentrator
155 | # 4096:32:0:44:M1460:A:Cisco,3COM,Extreme,Nortel:Catalyst Switch CatOS,CoreBuilder,Summit,Passport
156 | # S4:255:0:44:M536:ZA:Cisco:IOS
157 | # 1024:32:0:44:M1480:UA:Nortel:BayStack Switch
158 | # 4096:60:0:44:M1460:A:Adtran:NetVanta
159 | # 4096:64:0:44:M1008:A:Adtran:TSU
160 | # S4:32:0:44:M1024:A:Alcatel:Switch
161 | # S8:255:0:44:M536:ZA:Cisco:IOS
162 | # 50:255:0:44:M536:ZA:Cisco:CatIOS
163 | # 512:64:0:40:.:A:Dell:Switch
164 | # 4096:64:0:40:.:A:Enterasys:Vertical Horizon Switch
165 | # 17640:64:1:44:M1460:A:F5,Juniper,RiverStone:BigIP,Juniper OS,Router 7.0+
166 | # 16384:64:0:44:M1460:A:Foundry,SonicWall:BigIron,TZ
167 | # 4096:64:0:44:M1452:A:HP:ProCurve Switch
168 | # 1024:64:0:44:M1260:A:Marconi:ES
169 | # 10240:30:0:44:M1460:A:Milan:Switch
170 | # 4096:64:0:44:M1380:A:NetScreen:Firewall
171 | # S32:64:0:44:M512:A:Nokia:CheckPoint
172 | # 1024:64:0:44:M536:A:Nortel:BayStack Switch
173 | # 4128:255:0:44:M*:ZA:Cisco:IOS
174 | # 1024:16:0:44:M536:A:Nortel:BayStack Switch
175 | # 1024:30:0:44:M1480:A:Nortel:BayStack Switch
176 | # S4:64:0:44:M1460:A:Symbol:Spectrum Access Point
177 | # S2:255:0:44:M512:A:ZyXEL:Prestige
178 | # S16:255:0:44:M1024:A:ZyXEL:ZyAI
179 |
180 | ###########################################
181 | # Appliance / embedded / other signatures #
182 | ###########################################
183 |
184 | 16384:64:1:44:M1460:A:F5:BigIP LB 4.1.x (sometimes FreeBSD)
185 | 4128:255:0:44:M*:ZA:Cisco:Catalyst 2900 12.0(5)
186 | 4096:60:0:44:M*:A:Brother:HL-1270N
187 | S1:30:0:44:M1730:A:Cyclades:PR3000
188 | 8192:64:1:44:M1460:A:NetApp:Data OnTap 6.x
189 | 5792:64:1:60:W0,N,N,N,T,M1460:ZAT:FortiNet:FortiGate 50
190 | S1:64:1:44:M1460:A:NetCache:5.3.1
191 | S1:64:0:44:M512:A:Printer:controller (?)
192 | 4096:128:0:40:.:A:Sequent:DYNIX 4.2.x
193 | S16:64:0:44:M512:A:3Com:NBX PBX (BSD/OS 2.1)
194 | 16000:64:0:44:M1442:A:CastleNet:DSL router
195 | S2:64:0:44:M32728:A:D-Link:DSL-500
196 | S4:60:0:44:M1460:A:HP:JetDirect A.05.32
197 | 8576:64:1:44:M*:A:Raptor:firewall
198 | S12:64:1:44:M1400:A:Cequrux Firewall:4.x
199 | 2048:255:0:44:M1400:A:Netgear:MR814
200 | 16384:128:0:64:M1460,N,W0,N,N,T0,N,N,S:A:Akamai:??? (1)
201 | 16384:128:0:60:M1460,N,W0,N,N,T0:A:Akamai:??? (2)
202 |
203 | 8190:255:0:44:M1452:A:Citrix:Netscaler 6.1
204 |
205 | # Whatever they run. EOL boys...
206 | S6:128:1:48:M1460,E:PA:@Slashdot:or BusinessWeek (???)
207 |
208 |
209 |
--------------------------------------------------------------------------------
/osfooler_ng/dep/p0fr.fp:
--------------------------------------------------------------------------------
1 | #
2 | # p0f - RST+ signatures
3 | # ---------------------
4 | #
5 | # .-------------------------------------------------------------------------.
6 | # | The purpose of this file is to cover signatures for reset packets |
7 | # | (RST and RST+ACK). This mode of operation can be enabled with -A option |
8 | # | and is considered to be least accurate. Please refer to p0f.fp for more |
9 | # | information on the metrics used and for a guide on adding new entries |
10 | # | to this file. This database is looking for a caring maintainer. |
11 | # `-------------------------------------------------------------------------'
12 | #
13 | # (C) Copyright 2000-2006 by Michal Zalewski
14 | #
15 | # Submit all additions to the authors. Read p0f.fp before adding any
16 | # signatures. Run p0f -R -C after making any modifications. This file is
17 | # NOT compatible with SYN, SYN+ACK, or stray ACK modes. Use only with -R
18 | # option.
19 | #
20 | # IMPORTANT INFORMATION ABOUT THE INTERDEPENDENCY OF SYNs AND RST+ACKs
21 | # --------------------------------------------------------------------
22 | #
23 | # Some silly systems may copy WSS from the SYN packet you've sent,
24 | # in which case, you need to wildcard the value. Use test/sendsyn.c for
25 | # "connection refused" and test/sendack.c for "connection dropped" signatures
26 | # - both tools use a distinct WSS of 12345, which is an easy way to tell
27 | # if WSS should be wildcarded.
28 | #
29 | # IMPORTANT INFORMATION ABOUT COMMON IMPLEMENTATION FLAWS
30 | # -------------------------------------------------------
31 | #
32 | # There are several types of RST packets you will surely encounter.
33 | # Some systems, including most reputable ones, are severily brain-damaged
34 | # and generate some illegal combinations from time to time. This is WAY
35 | # more common than with other packet types, because a broken RST does not
36 | # have any immediately noticable consequences; besides, the RFC793 is fairly
37 | # difficult to comprehend when it comes to this type of responses.
38 | #
39 | # P0f will give you a hint on new RST signatures, but it is your duty to
40 | # diagnose the problem and append the proper description when adding the
41 | # signature. Below is a list of valid and invalid states:
42 | #
43 | # - "Connection refused" message: this is a RST+ACK packet, SEQ number
44 | # set to zero, ACK number non-zero. This is a valid response and
45 | # is denoted by p0f as "refused" (quirk combination: K, 0, A).
46 | #
47 | # There are some very cases when this is incorrectly sent in response
48 | # to an unexpected ACK packet.
49 | #
50 | # - Illegal combination: RST+ACK packet, SEQ number set to zero, ACK
51 | # number zero. This is denoted by p0f as "invalid-K0" (quirk combination:
52 | # K and 0, no A).
53 | #
54 | # - Illegal combination: RST+ACK, SEQ number non-zero, ACK number zero
55 | # or non-zero. This is denoted by p0f as "invalid-K" and
56 | # "invalid-KA", respectively (quirk combinations, K, sometimes A, no 0).
57 | #
58 | # This combination is frequently generated by Cisco routers in certain
59 | # configurations in response to ACK (!). Brain dead, by all means, and
60 | # usually a result of (incorrectly) setting ACK flag on a valid RST packet.
61 | #
62 | # - "Connection dropped": RST, sequence number non-zero, ACK zero or
63 | # non-zero. This is denoted as "dropped" and "dropped 2" respectively
64 | # (quirk combinations: no K, sometimes A, no 0). While the ACK value should
65 | # be zeroed, it is not strictly against the RFC, and some systems either
66 | # leak memory there or set it to the value of SEQ.
67 | #
68 | # The latter variant, with non-zero ACK, is particularly common on
69 | # Windows.
70 | #
71 | # - Ilegal combination: RST, SEQ number zero, ACK zero or non-zero.
72 | # Denoted as "invalid-0" and "invalid-0A". Obviously incorrect, and
73 | # will not have the desired effect.
74 | #
75 | # Ok. That's it. RFC793 does not get much respect nowadays.
76 | #
77 | # IMPORTANT INFORMATION ABOUT DIFFERENCES IN COMPARISON TO p0f.fp:
78 | # ----------------------------------------------------------------
79 | #
80 | # - Packet size may be wildcarded. The meaning of wildcard is, however,
81 | # hardcoded as 'size > PACKET_BIG' (defined as 100 in config.h). This is
82 | # because some stupid devices (including Ciscos) tend to send back RST
83 | # packets quoting anything you have sent them in ACK packet previously.
84 | # Use sparingly, only if -X confirms the device actually bounces back
85 | # whatever you send.
86 | #
87 | # - A new quirk, 'K', is introduced to denote RST+ACK packets (as opposed
88 | # to plain RST). This quirk is only compatible with this mode.
89 | #
90 | # - A new quirk, 'Q', is used to denote SEQ number equal to ACK number.
91 | # This happens from time to time in RST and RST+ACK packets, but
92 | # is practically unheard of in other modes.
93 | #
94 | # - A new quirk, '0', is used to denote packets with SEQ number set to 0.
95 | # This happens on some RSTs, and is once again unheard of in other modes.
96 | #
97 | # - 'D' quirk is not a bug; some devices send verbose text messages
98 | # describing why a connection got dropped; it's actually suggested
99 | # by RFC1122. Of course, some systems have their own standards, and
100 | # put all kinds of crap in their RST responses (including FreeBSD and
101 | # Cisco). Use -X to examine those values.
102 | #
103 | # - 'A' and 'T' quirks are not an anomaly in certain cases for the reasons
104 | # described in p0fa.fp.
105 | #
106 |
107 | ################################
108 | # Connection refused - RST+ACK #
109 | ################################
110 |
111 | 0:255:0:40:.:K0A:Linux:2.0/2.2 (refused)
112 | 0:64:1:40:.:K0A:FreeBSD:4.8 (refused)
113 | 0:64:1:40:.:K0ZA:Linux:recent 2.4 (refused)
114 |
115 | 0:128:0:40:.:K0A:Windows:XP/2000 (refused)
116 | 0:128:0:40:.:K0UA:-Windows:XP/2000 while browsing (refused)
117 |
118 | ######################################
119 | # Connection dropped / timeout - RST #
120 | ######################################
121 |
122 | 0:64:1:40:.:.:FreeBSD:4.8 (dropped)
123 | 0:255:0:40:.:.:Linux:2.0/2.2 or IOS 12.x (dropped)
124 | 0:64:1:40:.:Z:Linux:recent 2.4 (dropped)
125 | 0:255:1:40:.:Z:Linux:early 2.4 (dropped)
126 | 0:32:0:40:.:.:Xylan:OmniSwitch / Linksys WAP11 AP (dropped)
127 | 0:64:1:40:.:U:NetIron:load balancer (dropped)
128 |
129 | 0:128:1:40:.:QA:Windows:XP/2000 (dropped 2)
130 | 0:128:1:40:.:A:-Windows:XP/2000 while browsing (1) (dropped 2)
131 | 0:128:1:40:.:QUA:-Windows:XP/2000 while browsing (2) (dropped 2)
132 | 0:128:1:40:.:UA:-Windows:XP/2000 while browsing a lot (dropped 2)
133 | 0:128:1:40:.:.:@Windows:98 (?) (dropped)
134 |
135 | 0:64:0:40:.:A:Ascend:TAOS or BayTech (dropped 2)
136 |
137 | *:255:0:40:.:QA:Cisco:LocalDirector (dropped 2)
138 |
139 | 0:64:1:40:.:A:Hasbani:WindWeb (dropped 2)
140 | S23:255:1:40:.:.:Solaris:2.5 (dropped)
141 |
142 | #######################################################
143 | # Connection dropped / timeout - RST with description #
144 | #######################################################
145 |
146 | 0:255:1:58:.:D:MacOS:9.x "No TCP/No listener" (seldom SunOS 5.x) (dropped)
147 | 0:255:1:53:.:D:MacOS:8.5 "no tcp, reset" (dropped)
148 | 0:255:1:65:.:D:MacOS:X "tcp_close, during connect" (dropped)
149 | 0:255:1:54:.:D:MacOS:X "tcp_disconnect" (dropped)
150 | 0:255:1:62:.:D:HP/UX:? "tcp_fin_wait_2_timeout" (dropped)
151 | 32768:255:1:54:.:D:MacOS:8.5 "tcp_disconnect" (dropped)
152 | 0:255:1:63:.:D:@Unknown: "Go away" device (dropped)
153 |
154 | 0:255:0:62:.:D:SunOS:5.x "new data when detached" (1) (dropped)
155 | 32768:255:1:62:.:D:SunOS:5.x "new data when detached" (2) (dropped)
156 | 0:255:1:67:.:D:SunOS:5.x "tcp_lift_anchor, can't wait" (dropped)
157 |
158 | 0:255:0:46:.:D:HP/UX:11.00 "No TCP" (dropped)
159 |
160 | # More obscure ones:
161 | # 648:255:1:54:.:D:MacOS:??? "tcp_disconnect" (dropped)
162 | # 0:45:1:53:.:D:MacOS:7.x "no tcp, reset" (dropped)
163 |
164 | ##############################################
165 | # Connection dropped / timeout - broken RSTs #
166 | ##############################################
167 |
168 | S12:255:1:58:.:KAD:Solaris:2.x "tcp_disconnect" (dropped, lame)
169 | S43:64:1:40:.:KA:AOL:proxy (dropped, lame)
170 | *:64:1:40:.:KA:FreeBSD:4.8 (dropped, lame)
171 | *:64:1:52:N,N,T:KAT:Linux:2.4 (?) (dropped, lame)
172 | 0:255:0:40:.:KAF:3Com:SuperStack II (dropped, lame)
173 | *:255:0:40:.:KA:Intel:Netport print server (dropped, lame)
174 | *:150:0:40:.:KA:Linksys:BEF router (dropped, lame)
175 |
176 | *:32:0:44:.:KZD:@NetWare:??? "ehnc" (dropped, lame)
177 | 0:64:0:40:.:KQ0:BayTech:RPC-3 telnet host (dropped, lame)
178 |
179 | #############################################
180 | # Connection dropped / timeout - extra data #
181 | #############################################
182 |
183 | *:255:0:*:.:KAD:Cisco:IOS/PIX NAT + data (1) (dropped, lame)
184 | 0:255:0:*:.:D:Windows:NT 4.0 SP6a + data (dropped)
185 | 0:255:0:*:.:K0AD:Isolation:Infocrypt accelerator + data (dropped, lame)
186 |
187 | *:255:0:*:.:AD:Cisco:IOS/PIX NAT + data (2) (dropped)
188 |
189 | *:64:1:*:N,N,T:KATD:Linux:2.4 (?) + data (dropped, lame)
190 | *:64:1:*:.:KAD:FreeBSD:4.8 + data (dropped, lame)
191 |
192 |
193 |
194 |
--------------------------------------------------------------------------------
/osfooler_ng/module_p0f.py:
--------------------------------------------------------------------------------
1 | ## This file is part of Scapy
2 | ## See http://www.secdev.org/projects/scapy for more informations
3 | ## Copyright (C) Philippe Biondi
4 | ## This program is published under a GPLv2 license
5 |
6 | #
7 | # Some modifications to fit OSfooler-ng
8 | # segofensiva
9 | #
10 | """
11 | Clone of p0f passive OS fingerprinting
12 | """
13 |
14 | import os
15 | from scapy.data import KnowledgeBase
16 | from scapy.config import conf
17 | from scapy.layers.inet import IP, TCP, TCPOptions
18 | from scapy.packet import NoPayload
19 | from scapy.volatile import *
20 | import random
21 |
22 | conf.p0f_base = os.path.abspath(os.path.dirname(__file__)) + "/dep/p0f.fp"
23 | conf.p0fa_base = os.path.abspath(os.path.dirname(__file__)) + "/dep/p0fa.fp"
24 | conf.p0fr_base = os.path.abspath(os.path.dirname(__file__)) + "/dep/p0fr.fp"
25 | conf.p0fo_base = os.path.abspath(os.path.dirname(__file__)) + "/dep/p0fo.fp"
26 |
27 |
28 | ###############
29 | ## p0f stuff ##
30 | ###############
31 |
32 | # File format (according to p0f.fp) :
33 | #
34 | # wwww:ttt:D:ss:OOO...:QQ:OS:Details
35 | #
36 | # wwww - window size
37 | # ttt - initial TTL
38 | # D - don't fragment bit (0=unset, 1=set)
39 | # ss - overall SYN packet size
40 | # OOO - option value and order specification
41 | # QQ - quirks list
42 | # OS - OS genre
43 | # details - OS description
44 |
45 | class p0fKnowledgeBase(KnowledgeBase):
46 | def __init__(self, filename):
47 | KnowledgeBase.__init__(self, filename)
48 | #self.ttl_range=[255]
49 | def lazy_init(self):
50 | try:
51 | f=open(self.filename)
52 | except IOError:
53 | warning("Can't open base %s" % self.filename)
54 | return
55 | try:
56 | self.base = []
57 | for l in f:
58 | if l[0] in ["#","\n"]:
59 | continue
60 | l = tuple(l.strip().split(":"))
61 | if len(l) < 8:
62 | continue
63 | def a2i(x):
64 | if x.isdigit():
65 | return int(x)
66 | return x
67 | li = map(a2i, l[1:4])
68 | #if li[0] not in self.ttl_range:
69 | # self.ttl_range.append(li[0])
70 | # self.ttl_range.sort()
71 | self.base.append((l[0], li[0], li[1], li[2], l[4], l[5], l[6], l[7]))
72 | except:
73 | warning("Can't parse p0f database (new p0f version ?)")
74 | self.base = None
75 | f.close()
76 |
77 | p0f_kdb = p0fKnowledgeBase(conf.p0f_base)
78 | p0fa_kdb = p0fKnowledgeBase(conf.p0fa_base)
79 | p0fr_kdb = p0fKnowledgeBase(conf.p0fr_base)
80 | p0fo_kdb = p0fKnowledgeBase(conf.p0fo_base)
81 |
82 | def p0f_selectdb(flags):
83 | # tested flags: S, R, A
84 | if flags & 0x16 == 0x2:
85 | # SYN
86 | return p0f_kdb
87 | elif flags & 0x16 == 0x12:
88 | # SYN/ACK
89 | return p0fa_kdb
90 | elif flags & 0x16 in [ 0x4, 0x14 ]:
91 | # RST RST/ACK
92 | return p0fr_kdb
93 | elif flags & 0x16 == 0x10:
94 | # ACK
95 | return p0fo_kdb
96 | else:
97 | return None
98 |
99 | def packet2p0f(pkt):
100 | pkt = pkt.copy()
101 | pkt = pkt.__class__(str(pkt))
102 | while pkt.haslayer(IP) and pkt.haslayer(TCP):
103 | pkt = pkt.getlayer(IP)
104 | if isinstance(pkt.payload, TCP):
105 | break
106 | pkt = pkt.payload
107 |
108 | if not isinstance(pkt, IP) or not isinstance(pkt.payload, TCP):
109 | raise TypeError("Not a TCP/IP packet")
110 | #if pkt.payload.flags & 0x7 != 0x02: #S,!F,!R
111 | # raise TypeError("Not a SYN or SYN/ACK packet")
112 |
113 | db = p0f_selectdb(pkt.payload.flags)
114 |
115 | #t = p0f_kdb.ttl_range[:]
116 | #t += [pkt.ttl]
117 | #t.sort()
118 | #ttl=t[t.index(pkt.ttl)+1]
119 | ttl = pkt.ttl
120 |
121 | df = (pkt.flags & 2) / 2
122 | ss = len(pkt)
123 | # from p0f/config.h : PACKET_BIG = 100
124 | if ss > 100:
125 | if db == p0fr_kdb:
126 | # p0fr.fp: "Packet size may be wildcarded. The meaning of
127 | # wildcard is, however, hardcoded as 'size >
128 | # PACKET_BIG'"
129 | ss = '*'
130 | else:
131 | ss = 0
132 | if db == p0fo_kdb:
133 | # p0fo.fp: "Packet size MUST be wildcarded."
134 | ss = '*'
135 |
136 | ooo = ""
137 | mss = -1
138 | qqT = False
139 | qqP = False
140 | #qqBroken = False
141 | ilen = (pkt.payload.dataofs << 2) - 20 # from p0f.c
142 | for option in pkt.payload.options:
143 | ilen -= 1
144 | if option[0] == "MSS":
145 | ooo += "M" + str(option[1]) + ","
146 | mss = option[1]
147 | # FIXME: qqBroken
148 | ilen -= 3
149 | elif option[0] == "WScale":
150 | ooo += "W" + str(option[1]) + ","
151 | # FIXME: qqBroken
152 | ilen -= 2
153 | elif option[0] == "Timestamp":
154 | if option[1][0] == 0:
155 | ooo += "T0,"
156 | else:
157 | ooo += "T,"
158 | if option[1][1] != 0:
159 | qqT = True
160 | ilen -= 9
161 | elif option[0] == "SAckOK":
162 | ooo += "S,"
163 | ilen -= 1
164 | elif option[0] == "NOP":
165 | ooo += "N,"
166 | elif option[0] == "EOL":
167 | ooo += "E,"
168 | if ilen > 0:
169 | qqP = True
170 | else:
171 | if type(option[0]) is str:
172 | ooo += "?%i," % TCPOptions[1][option[0]]
173 | else:
174 | ooo += "?%i," % option[0]
175 | # FIXME: ilen
176 | ooo = ooo[:-1]
177 | if ooo == "": ooo = "."
178 |
179 | win = pkt.payload.window
180 | if mss != -1:
181 | if mss != 0 and win % mss == 0:
182 | win = "S" + str(win/mss)
183 | elif win % (mss + 40) == 0:
184 | win = "T" + str(win/(mss+40))
185 | win = str(win)
186 |
187 | qq = ""
188 |
189 | if db == p0fr_kdb:
190 | if pkt.payload.flags & 0x10 == 0x10:
191 | # p0fr.fp: "A new quirk, 'K', is introduced to denote
192 | # RST+ACK packets"
193 | qq += "K"
194 | # The two next cases should also be only for p0f*r*, but although
195 | # it's not documented (or I have not noticed), p0f seems to
196 | # support the '0' and 'Q' quirks on any databases (or at the least
197 | # "classical" p0f.fp).
198 | if pkt.payload.seq == pkt.payload.ack:
199 | # p0fr.fp: "A new quirk, 'Q', is used to denote SEQ number
200 | # equal to ACK number."
201 | qq += "Q"
202 | if pkt.payload.seq == 0:
203 | # p0fr.fp: "A new quirk, '0', is used to denote packets
204 | # with SEQ number set to 0."
205 | qq += "0"
206 | if qqP:
207 | qq += "P"
208 | if pkt.id == 0:
209 | qq += "Z"
210 | if pkt.options != []:
211 | qq += "I"
212 | if pkt.payload.urgptr != 0:
213 | qq += "U"
214 | if pkt.payload.reserved != 0:
215 | qq += "X"
216 | if pkt.payload.ack != 0:
217 | qq += "A"
218 | if qqT:
219 | qq += "T"
220 | if db == p0fo_kdb:
221 | if pkt.payload.flags & 0x20 != 0:
222 | # U
223 | # p0fo.fp: "PUSH flag is excluded from 'F' quirk checks"
224 | qq += "F"
225 | else:
226 | if pkt.payload.flags & 0x28 != 0:
227 | # U or P
228 | qq += "F"
229 | if db != p0fo_kdb and not isinstance(pkt.payload.payload, NoPayload):
230 | # p0fo.fp: "'D' quirk is not checked for."
231 | qq += "D"
232 | # FIXME : "!" - broken options segment: not handled yet
233 |
234 | if qq == "":
235 | qq = "."
236 |
237 | return (db, (win, ttl, df, ss, ooo, qq))
238 |
239 | def p0f_correl(x,y):
240 | d = 0
241 | # wwww can be "*" or "%nn". "Tnn" and "Snn" should work fine with
242 | # the x[0] == y[0] test.
243 | d += (x[0] == y[0] or y[0] == "*" or (y[0][0] == "%" and x[0].isdigit() and (int(x[0]) % int(y[0][1:])) == 0))
244 | # ttl
245 | d += (y[1] >= x[1] and y[1] - x[1] < 32)
246 | for i in [2, 5]:
247 | d += (x[i] == y[i] or y[i] == '*')
248 | # '*' has a special meaning for ss
249 | d += x[3] == y[3]
250 | xopt = x[4].split(",")
251 | yopt = y[4].split(",")
252 | if len(xopt) == len(yopt):
253 | same = True
254 | for i in range(len(xopt)):
255 | if not (xopt[i] == yopt[i] or
256 | (len(yopt[i]) == 2 and len(xopt[i]) > 1 and
257 | yopt[i][1] == "*" and xopt[i][0] == yopt[i][0]) or
258 | (len(yopt[i]) > 2 and len(xopt[i]) > 1 and
259 | yopt[i][1] == "%" and xopt[i][0] == yopt[i][0] and
260 | int(xopt[i][1:]) % int(yopt[i][2:]) == 0)):
261 | same = False
262 | break
263 | if same:
264 | d += len(xopt)
265 | return d
266 |
267 |
268 | @conf.commands.register
269 | def p0f(pkt):
270 | """Passive OS fingerprinting: which OS emitted this TCP packet ?
271 | p0f(packet) -> accuracy, [list of guesses]
272 | """
273 | db, sig = packet2p0f(pkt)
274 | if db:
275 | pb = db.get_base()
276 | else:
277 | pb = []
278 | if not pb:
279 | warning("p0f base empty.")
280 | return []
281 | #s = len(pb[0][0])
282 | r = []
283 | max = len(sig[4].split(",")) + 5
284 | for b in pb:
285 | d = p0f_correl(sig,b)
286 | if d == max:
287 | r.append((b[6], b[7], b[1] - pkt[IP].ttl))
288 | return r
289 |
290 | def prnp0f(pkt):
291 | # we should print which DB we use
292 | try:
293 | r = p0f(pkt)
294 | except:
295 | return
296 | if r == []:
297 | r = ("UNKNOWN", "[" + ":".join(map(str, packet2p0f(pkt)[1])) + ":?:?]", None)
298 | else:
299 | r = r[0]
300 | uptime = None
301 | try:
302 | uptime = pkt2uptime(pkt)
303 | except:
304 | pass
305 | if uptime == 0:
306 | uptime = None
307 | res = pkt.sprintf("%IP.src%:%TCP.sport% - " + r[0] + " " + r[1])
308 | if uptime is not None:
309 | res += pkt.sprintf(" (up: " + str(uptime/3600) + " hrs)\n -> %IP.dst%:%TCP.dport% (%TCP.flags%)")
310 | else:
311 | res += pkt.sprintf("\n -> %IP.dst%:%TCP.dport% (%TCP.flags%)")
312 | if r[2] is not None:
313 | res += " (distance " + str(r[2]) + ")"
314 | print res
315 |
316 | @conf.commands.register
317 | def pkt2uptime(pkt, HZ=100):
318 | """Calculate the date the machine which emitted the packet booted using TCP timestamp
319 | pkt2uptime(pkt, [HZ=100])"""
320 | if not isinstance(pkt, Packet):
321 | raise TypeError("Not a TCP packet")
322 | if isinstance(pkt,NoPayload):
323 | raise TypeError("Not a TCP packet")
324 | if not isinstance(pkt, TCP):
325 | return pkt2uptime(pkt.payload)
326 | for opt in pkt.options:
327 | if opt[0] == "Timestamp":
328 | #t = pkt.time - opt[1][0] * 1.0/HZ
329 | #return time.ctime(t)
330 | t = opt[1][0] / HZ
331 | return t
332 | raise TypeError("No timestamp option")
333 |
334 | def p0f_impersonate(pkt, num, osgenre=None, osdetails=None, signature=None,
335 | extrahops=0, mtu=1500, uptime=None):
336 | """Modifies pkt so that p0f will think it has been sent by a
337 | specific OS. If osdetails is None, then we randomly pick up a
338 | personality matching osgenre. If osgenre and signature are also None,
339 | we use a local signature (using p0f_getlocalsigs). If signature is
340 | specified (as a tuple), we use the signature.
341 |
342 | For now, only TCP Syn packets are supported.
343 | Some specifications of the p0f.fp file are not (yet) implemented."""
344 | pkt = pkt.copy()
345 | uptime=num
346 | #pkt = pkt.__class__(str(pkt))
347 | while pkt.haslayer(IP) and pkt.haslayer(TCP):
348 | pkt = pkt.getlayer(IP)
349 | if isinstance(pkt.payload, TCP):
350 | break
351 | pkt = pkt.payload
352 |
353 | if not isinstance(pkt, IP) or not isinstance(pkt.payload, TCP):
354 | raise TypeError("Not a TCP/IP packet")
355 |
356 | if uptime is None:
357 | uptime = random.randint(120,100*60*60*24*365)
358 |
359 | db = p0f_selectdb(pkt.payload.flags)
360 | if osgenre:
361 | pb = db.get_base()
362 | if pb is None:
363 | pb = []
364 | pb = filter(lambda x: x[6] == osgenre, pb)
365 | if osdetails:
366 | pb = filter(lambda x: x[7] == osdetails, pb)
367 | elif signature:
368 | pb = [signature]
369 | else:
370 | pb = p0f_getlocalsigs()[db]
371 | if db == p0fr_kdb:
372 | # 'K' quirk <=> RST+ACK
373 | if pkt.payload.flags & 0x4 == 0x4:
374 | pb = filter(lambda x: 'K' in x[5], pb)
375 | else:
376 | pb = filter(lambda x: 'K' not in x[5], pb)
377 | if not pb:
378 | raise Scapy_Exception("No match in the p0f database")
379 | pers = pb[random.randint(0, len(pb) - 1)]
380 |
381 | # options (we start with options because of MSS)
382 | ## TODO: let the options already set if they are valid
383 | options = []
384 | if pers[4] != '.':
385 | for opt in pers[4].split(','):
386 | if opt[0] == 'M':
387 | # MSS might have a maximum size because of window size
388 | # specification
389 | if pers[0][0] == 'S':
390 | maxmss = (2L**16-1) / int(pers[0][1:])
391 | else:
392 | maxmss = (2L**16-1)
393 | # If we have to randomly pick up a value, we cannot use
394 | # scapy RandXXX() functions, because the value has to be
395 | # set in case we need it for the window size value. That's
396 | # why we use random.randint()
397 | if opt[1:] == '*':
398 | options.append(('MSS', random.randint(1,maxmss)))
399 | elif opt[1] == '%':
400 | coef = int(opt[2:])
401 | options.append(('MSS', coef*random.randint(1,maxmss/coef)))
402 | else:
403 | options.append(('MSS', int(opt[1:])))
404 | elif opt[0] == 'W':
405 | if opt[1:] == '*':
406 | options.append(('WScale', RandByte()))
407 | elif opt[1] == '%':
408 | coef = int(opt[2:])
409 | options.append(('WScale', coef*RandNum(min=1,
410 | max=(2L**8-1)/coef)))
411 | else:
412 | options.append(('WScale', int(opt[1:])))
413 | elif opt == 'T0':
414 | options.append(('Timestamp', (0, 0)))
415 | elif opt == 'T':
416 | if 'T' in pers[5]:
417 | # FIXME: RandInt() here does not work (bug (?) in
418 | # TCPOptionsField.m2i often raises "OverflowError:
419 | # long int too large to convert to int" in:
420 | # oval = struct.pack(ofmt, *oval)"
421 | # Actually, this is enough to often raise the error:
422 | # struct.pack('I', RandInt())
423 | options.append(('Timestamp', (uptime, random.randint(1,2**32-1))))
424 | else:
425 | options.append(('Timestamp', (uptime, 0)))
426 | elif opt == 'S':
427 | options.append(('SAckOK', ''))
428 | elif opt == 'N':
429 | options.append(('NOP', None))
430 | elif opt == 'E':
431 | options.append(('EOL', None))
432 | elif opt[0] == '?':
433 | if int(opt[1:]) in TCPOptions[0]:
434 | optname = TCPOptions[0][int(opt[1:])][0]
435 | optstruct = TCPOptions[0][int(opt[1:])][1]
436 | options.append((optname,
437 | struct.unpack(optstruct,
438 | RandString(struct.calcsize(optstruct))._fix())))
439 | else:
440 | options.append((int(opt[1:]), ''))
441 | ## FIXME: qqP not handled
442 | else:
443 | warning("unhandled TCP option " + opt)
444 | pkt.payload.options = options
445 |
446 | # window size
447 | if pers[0] == '*':
448 | pkt.payload.window = RandShort()
449 | elif pers[0].isdigit():
450 | pkt.payload.window = int(pers[0])
451 | elif pers[0][0] == '%':
452 | coef = int(pers[0][1:])
453 | pkt.payload.window = coef * RandNum(min=1,max=(2L**16-1)/coef)
454 | elif pers[0][0] == 'T':
455 | pkt.payload.window = mtu * int(pers[0][1:])
456 | elif pers[0][0] == 'S':
457 | ## needs MSS set
458 | MSS = filter(lambda x: x[0] == 'MSS', options)
459 | if not filter(lambda x: x[0] == 'MSS', options):
460 | raise Scapy_Exception("TCP window value requires MSS, and MSS option not set")
461 | pkt.payload.window = filter(lambda x: x[0] == 'MSS', options)[0][1] * int(pers[0][1:])
462 | else:
463 | raise Scapy_Exception('Unhandled window size specification')
464 |
465 | # ttl
466 | pkt.ttl = pers[1]-extrahops
467 | # DF flag
468 | pkt.flags |= (2 * pers[2])
469 | ## FIXME: ss (packet size) not handled (how ? may be with D quirk
470 | ## if present)
471 | # Quirks
472 | if pers[5] != '.':
473 | for qq in pers[5]:
474 | ## FIXME: not handled: P, I, X, !
475 | # T handled with the Timestamp option
476 | if qq == 'Z': pkt.id = 0
477 | elif qq == 'U': pkt.payload.urgptr = RandShort()
478 | elif qq == 'A': pkt.payload.ack = RandInt()
479 | elif qq == 'F':
480 | if db == p0fo_kdb:
481 | pkt.payload.flags |= 0x20 # U
482 | else:
483 | pkt.payload.flags |= RandChoice(8, 32, 40) #P / U / PU
484 | elif qq == 'D' and db != p0fo_kdb:
485 | pkt /= Raw(load=RandString(random.randint(1, 10))) # XXX p0fo.fp
486 | elif qq == 'Q': pkt.payload.seq = pkt.payload.ack
487 | #elif qq == '0': pkt.payload.seq = 0
488 | #if db == p0fr_kdb:
489 | # '0' quirk is actually not only for p0fr.fp (see
490 | # packet2p0f())
491 | if '0' in pers[5]:
492 | pkt.payload.seq = 0
493 | elif pkt.payload.seq == 0:
494 | pkt.payload.seq = RandInt()
495 |
496 | while pkt.underlayer:
497 | pkt = pkt.underlayer
498 | return pkt
499 |
500 | def p0f_getlocalsigs():
501 | """This function returns a dictionary of signatures indexed by p0f
502 | db (e.g., p0f_kdb, p0fa_kdb, ...) for the local TCP/IP stack.
503 |
504 | You need to have your firewall at least accepting the TCP packets
505 | from/to a high port (30000 <= x <= 40000) on your loopback interface.
506 |
507 | Please note that the generated signatures come from the loopback
508 | interface and may (are likely to) be different than those generated on
509 | "normal" interfaces."""
510 | pid = os.fork()
511 | port = random.randint(30000, 40000)
512 | if pid > 0:
513 | # parent: sniff
514 | result = {}
515 | def addresult(res):
516 | # TODO: wildcard window size in some cases? and maybe some
517 | # other values?
518 | if res[0] not in result:
519 | result[res[0]] = [res[1]]
520 | else:
521 | if res[1] not in result[res[0]]:
522 | result[res[0]].append(res[1])
523 | # XXX could we try with a "normal" interface using other hosts
524 | iface = conf.route.route('127.0.0.1')[0]
525 | # each packet is seen twice: S + RA, S + SA + A + FA + A
526 | # XXX are the packets also seen twice on non Linux systems ?
527 | count=14
528 | pl = sniff(iface=iface, filter='tcp and port ' + str(port), count = count, timeout=3)
529 | map(addresult, map(packet2p0f, pl))
530 | os.waitpid(pid,0)
531 | elif pid < 0:
532 | log_runtime.error("fork error")
533 | else:
534 | # child: send
535 | # XXX erk
536 | time.sleep(1)
537 | s1 = socket.socket(socket.AF_INET, type = socket.SOCK_STREAM)
538 | # S & RA
539 | try:
540 | s1.connect(('127.0.0.1', port))
541 | except socket.error:
542 | pass
543 | # S, SA, A, FA, A
544 | s1.bind(('127.0.0.1', port))
545 | s1.connect(('127.0.0.1', port))
546 | # howto: get an RST w/o ACK packet
547 | s1.close()
548 | os._exit(0)
549 | return result
550 |
551 |
552 |
--------------------------------------------------------------------------------
/osfooler_ng/osfooler_ng.py:
--------------------------------------------------------------------------------
1 | #!/usr/bin/python2
2 | # -*- coding: utf-8 -*-
3 |
4 | from random import randint
5 | import hashlib
6 | import logging
7 | import module_p0f
8 | import socket
9 | import fcntl
10 | import struct
11 | import optparse
12 | import sys
13 | import time
14 | import os
15 | import netfilterqueue as nfqueue
16 | import ConfigParser
17 | import ast
18 | l = logging.getLogger("scapy.runtime").setLevel(logging.ERROR)
19 | from scapy.all import *
20 | from dpkt import *
21 | from socket import AF_INET, AF_INET6, inet_ntoa
22 | import urllib
23 | import multiprocessing
24 | from multiprocessing import Process
25 |
26 | # Some configuration
27 | sys.tracebacklimit = 0
28 | conf.verbose = 0
29 | conf.L3socket = L3RawSocket
30 | sys.path.append('python')
31 | sys.path.append('build/python')
32 | sys.path.append('dpkt-1.6')
33 |
34 | # Initialize statistic variables
35 | icmp_packet = 0
36 | IPID = 0
37 |
38 | # Started NFQueues
39 | q_num0 = -1
40 | q_num1 = -1
41 |
42 | # TCP packet information
43 | # Control flags
44 | TH_FIN = 0x01 # end of data
45 | TH_SYN = 0x02 # synchronize sequence numbers
46 | TH_RST = 0x04 # reset connection
47 | TH_PUSH = 0x08 # push
48 | TH_ACK = 0x10 # acknowledgment number set
49 | TH_URG = 0x20 # urgent pointer set
50 | TH_ECE = 0x40 # ECN echo, RFC 3168
51 | TH_CWR = 0x80 # congestion window reduced
52 | # Options (opt_type) - http://www.iana.org/assignments/tcp-parameters
53 | TCP_OPT_EOL = 0 # end of option list
54 | TCP_OPT_NOP = 1 # no operation
55 | TCP_OPT_MSS = 2 # maximum segment size
56 | TCP_OPT_WSCALE = 3 # window scale factor, RFC 1072
57 | TCP_OPT_SACKOK = 4 # SACK permitted, RFC 2018
58 | TCP_OPT_SACK = 5 # SACK, RFC 2018
59 | TCP_OPT_ECHO = 6 # echo (obsolete), RFC 1072
60 | TCP_OPT_ECHOREPLY = 7 # echo reply (obsolete), RFC 1072
61 | TCP_OPT_TIMESTAMP = 8 # timestamp, RFC 1323
62 | TCP_OPT_POCONN = 9 # partial order conn, RFC 1693
63 | TCP_OPT_POSVC = 10 # partial order service, RFC 1693
64 | TCP_OPT_CC = 11 # connection count, RFC 1644
65 | TCP_OPT_CCNEW = 12 # CC.NEW, RFC 1644
66 | TCP_OPT_CCECHO = 13 # CC.ECHO, RFC 1644
67 | TCP_OPT_ALTSUM = 14 # alt checksum request, RFC 1146
68 | TCP_OPT_ALTSUMDATA = 15 # alt checksum data, RFC 1146
69 | TCP_OPT_SKEETER = 16 # Skeeter
70 | TCP_OPT_BUBBA = 17 # Bubba
71 | TCP_OPT_TRAILSUM = 18 # trailer checksum
72 | TCP_OPT_MD5 = 19 # MD5 signature, RFC 2385
73 | TCP_OPT_SCPS = 20 # SCPS capabilities
74 | TCP_OPT_SNACK = 21 # selective negative acks
75 | TCP_OPT_REC = 22 # record boundaries
76 | TCP_OPT_CORRUPT = 23 # corruption experienced
77 | TCP_OPT_SNAP = 24 # SNAP
78 | TCP_OPT_TCPCOMP = 26 # TCP compression filter
79 | TCP_OPT_MAX = 27
80 |
81 | # Some knowledge about nmap packets
82 | # Options
83 | T1_opt1 = "03030a01020405b4080affffffff000000000402"
84 | T1_opt2 = "020405780303000402080affffffff0000000000"
85 | T1_opt3 = "080affffffff0000000001010303050102040280"
86 | T1_opt4 = "0402080affffffff0000000003030a00"
87 | T1_opt5 = "020402180402080affffffff0000000003030a00"
88 | T1_opt6 = "020401090402080affffffff00000000"
89 | T2_T6_opt = "03030a0102040109080affffffff000000000402"
90 | T7_opt = "03030f0102040109080affffffff000000000402"
91 | ECN_opt = "03030a01020405b404020101"
92 | # Window Size
93 | T1_1w = "1"
94 | T1_2w = "63"
95 | T1_3w = "4"
96 | T1_4w = "4"
97 | T1_5w = "16"
98 | T1_6w = "512"
99 | T2w = "128"
100 | T3w = "256"
101 | T4w = "1024"
102 | T5w = "31337"
103 | T6w = "32768"
104 | T7w = "65535"
105 | ECEw = "3"
106 | # Payloads
107 | udp_payload = "CCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCC"
108 |
109 | # Parse fields in nmap-db
110 | def parse_nmap_field(field):
111 | if (field.find('|') != -1):
112 | # Choose randomly one value :)
113 | list = field.split("|")
114 | # Filter any empty string
115 | list = filter (None,list)
116 | result = random.choice(list)
117 | else:
118 | result = field
119 | return result
120 |
121 | # Get default interface address without external packages
122 | def get_ip_address(ifname):
123 | s = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
124 | return socket.inet_ntoa(fcntl.ioctl(
125 | s.fileno(),
126 | 0x8915, # SIOCGIFADDR
127 | struct.pack('256s', ifname[:15])
128 | )[20:24])
129 |
130 | def show_banner():
131 | print ("""\
132 |
133 | -o:
134 | .o+`
135 | :o-.-.` ``
136 | `-::::+o/-:++/o/ _____ __
137 | `/+//+/--ss///:-. ____ ______/ ________ ____ | | ___________ ____ ____
138 | /o:` .:/:ss / _ \/ ___\ __/ _ \ / _ \| | _/ __ \_ __ \ ______ / \ / ___\
139 | oo`.-` .+s+ ( <_> \___ \ | |( <_> ( <_> | |_\ ___/| | \/ /_____/ | | / /_/ >
140 | .-::::oo--/+/+o/` \____/____ >|__| \____/ \____/|____/\___ |__| |___| \___ /
141 | /+/++:-/s+///:-` \/ \/ \/_____/
142 | ` `-///s:
143 | `-os. v1.0b (https://github.com/segofensiva/osfooler-ng)
144 | /s:
145 | """)
146 |
147 | # Which packet is?
148 | def check_even(number):
149 | if number % 2 == 0:
150 | return 1
151 | else:
152 | return 0
153 |
154 | # Display TCP flags in human format
155 | def tcp_flags(flags):
156 | ret = ''
157 | if flags & TH_FIN:
158 | ret = ret + 'F'
159 | if flags & TH_SYN:
160 | ret = ret + 'S'
161 | if flags & TH_RST:
162 | ret = ret + 'R'
163 | if flags & TH_PUSH:
164 | ret = ret + 'P'
165 | if flags & TH_ACK:
166 | ret = ret + 'A'
167 | if flags & TH_URG:
168 | ret = ret + 'U'
169 | if flags & TH_ECE:
170 | ret = ret + 'E'
171 | if flags & TH_CWR:
172 | ret = ret + 'C'
173 | return ret
174 |
175 | # Parse TCP options to human format
176 | def opts_human(options):
177 | opts = []
178 | for o, v in options:
179 | if o == TCP_OPT_WSCALE:
180 | opts.append("WS%d" % ord(v))
181 | elif o == TCP_OPT_MSS:
182 | opts.append("MSS%d" % struct.unpack('>H', v)[0])
183 | elif o == TCP_OPT_TIMESTAMP:
184 | opts.append("TS(%d,%d)" % struct.unpack('>II', v))
185 | elif o == TCP_OPT_NOP:
186 | opts.append("NOP")
187 | elif o == TCP_OPT_SACKOK:
188 | opts.append("SACK")
189 | return opts
190 |
191 | # GET IP ID ICMP
192 | def get_icmp_ipid():
193 | for x in range(0, len(base["SEQ"])):
194 | if (base["SEQ"][x][0] == "CI"):
195 | icmp_ipid = base["SEQ"][x][1]
196 |
197 | #
198 | def get_ipid_new(test):
199 | i = 1
200 | for x in range(0, len(base["SEQ"])):
201 | if (base["SEQ"][x][0] == test):
202 | if base["SEQ"][x][1] == "Z":
203 | i = 0
204 | elif base["SEQ"][x][1] == "RD":
205 | i = 0
206 | while (i < 20000):
207 | i = randint(1, 65535)
208 | elif base["SEQ"][x][1] == "RI":
209 | i = randint(1, 1500)
210 | while (i < 1000) or (i % 256 == 0):
211 | i = randint(1, 1500)
212 | #print "%s" % i
213 | elif base["SEQ"][x][1] == "BI":
214 | i = randint(1, 5120)
215 | while (i % 256 != 0):
216 | i = randint(1, 5120)
217 | elif base["SEQ"][x][1] == "I":
218 | i = randint(0, 9)
219 | else:
220 | IPID = randint(1, 65535)
221 | return i
222 |
223 | # Send ICMP response
224 | def send_icmp_response(pl, probe):
225 | global icmp_packet
226 | global icmp_ipid
227 | pkt = ip.IP(pl.get_payload())
228 | # DON'T FRAGMENT ICMP (DFI)
229 | if (base[probe][0][1] == "N"):
230 | frag_bit = 0 # None have it activated
231 | elif (base[probe][0][1] == "S"):
232 | if (check_even(icmp_packet)):
233 | frag_bit = 2 # First without DF
234 | else:
235 | rag_bit = 0 # Second one with DF
236 | elif (base[probe][0][1] == "Y"):
237 | frag_bit = 2 # Both have DF bit active
238 | else:
239 | if (check_even(icmp_packet)):
240 | frag_bit = 0 # First without DF
241 | else:
242 | frag_bit = 2 # Second one with DF
243 |
244 | TG = int(base[probe][2][1], 16)
245 | # ICMP response code (CD)
246 | if (base[probe][3][1] == "Z"):
247 | code = 0 # Both have 0 value
248 | elif (base[probe][3][1] == "S"):
249 | code = pkt.icmp.code # Same as received in the original packet
250 | elif (base[probe][3][1] == "00"): # nn
251 | code = 1
252 | else:
253 | code = 0 # Any other combo
254 | # TODO
255 | # any other combo
256 | icmp_packet = icmp_packet + 1
257 | inc_ipid = get_ipid_new("II")
258 | if (inc_ipid):
259 | icmp_ipid = icmp_ipid + inc_ipid
260 | else:
261 | icmp_ipid = icmp_ipid + randint(50, 100)
262 | if (icmp_ipid > 65535):
263 | icmp_ipid = icmp_ipid - 65535
264 | send(IP(id=icmp_ipid, dst=inet_ntoa(pkt.src), src=inet_ntoa(pkt.dst), flags=frag_bit, ttl=TG)
265 | / ICMP(id=pkt.icmp.data.id, seq=pkt.icmp.data.seq, code=code, type=0), verbose=0)
266 |
267 | # Send UDP response
268 | def send_udp_response(pl, probe):
269 | pkt = ip.IP(pl.get_payload())
270 | if (base[probe][0][1] == "Y"):
271 | frag_bit = 2
272 | else:
273 | frag_bit = 0
274 | TG = int(base[probe][2][1], 16)
275 | IPL = int(base[probe][3][1], 16)
276 | FIELD = int(base[probe][4][1])
277 | send(IP(dst=inet_ntoa(pkt.src), src=inet_ntoa(pkt.dst), ttl=TG, flags=frag_bit) / ICMP(code=3, type=3) /
278 | IP(dst=inet_ntoa(pkt.dst), src=inet_ntoa(pkt.src), id=pkt.id, ttl=TG - 1) / UDP(dport=pkt.udp.dport, sport=pkt.udp.sport), verbose=0)
279 |
280 | # Send probe response
281 | def send_probe_response(pl, probe):
282 | global IPID
283 | pkt = ip.IP(pl.get_payload())
284 | # IP DON'T FRAGMENT BIT (DF)
285 | if (base[probe][1][1] == "Y"):
286 | frag_bit = 2
287 | else:
288 | frag_bit = 0
289 | TG = int(base[probe][3][1], 16)
290 | # TCP INITICIAL WINDOW SIZE (W)
291 | W = parse_nmap_field(base[probe][4][1])
292 | if ( W != "N"):
293 | W = int(W, 16)
294 | else :
295 | W = None
296 | # TCP SEQUENCE NUMBER (S)
297 | if base[probe][5][1] == "Z":
298 | SEQ = 0
299 | elif base[probe][5][1] == "A":
300 | SEQ = int(pkt.tcp.ack)
301 | elif base[probe][5][1] == "A+":
302 | SEQ = int(pkt.tcp.ack)
303 | SEQ = SEQ + 1
304 | else:
305 | SEQ = randint(1, 65535)
306 | # TCP ACKNOWLEDGMENT NUMBER (A)
307 | if base[probe][6][1] == "Z":
308 | ACK = 0
309 | elif base[probe][6][1] == "S":
310 | ACK = int(pkt.tcp.seq)
311 | elif base[probe][6][1] == "S+":
312 | ACK = int(pkt.tcp.seq)
313 | ACK = ACK + 1
314 | else:
315 | ACK = randint(1, 65535)
316 | # TCP FLAGS (F)
317 | FLAGS = base[probe][7][1]
318 | # TCP OPTIONS
319 | opts = []
320 | opts = options_to_scapy(parse_nmap_field(base[probe][8][1]))
321 | # TODO
322 | # TCP RST DATA CHECKSUM
323 | # TODO
324 | # TCP MISCELLANEOUS QUIRKS
325 | # IPID INCREMENTS
326 | inc_ipid = get_ipid_new("CI")
327 | if (inc_ipid):
328 | IPID = IPID + inc_ipid
329 | else:
330 | IPID = IPID + randint(50, 100)
331 | if (IPID > 65535):
332 | IPID = IPID - 65535
333 | send(IP(id=IPID, dst=inet_ntoa(pkt.src), src=inet_ntoa(pkt.dst), flags=frag_bit, ttl=TG) /
334 | TCP(sport=pkt.tcp.dport, dport=pkt.tcp.sport, seq=SEQ, ack=ACK, window=W, options=opts, flags=FLAGS), verbose=0)
335 |
336 | # ECN
337 | # Send probe response
338 | def send_ECN_response(pl, probe):
339 | global IPID
340 | pkt = ip.IP(pl.get_payload())
341 | # IP DON'T FRAGMENT BIT (DF)
342 | df_parsed = parse_nmap_field(base[probe][1][1])
343 | if (df_parsed == "Y"):
344 | frag_bit = 2
345 | else:
346 | frag_bit = 0
347 | # IP INITIAL TIME-TO-LIVE (T)
348 | ttl_parsed = parse_nmap_field(base[probe][2][1])
349 | if ttl_parsed.find("-"):
350 | T = int(ttl_parsed[3:], 16)
351 | else:
352 | T = int(ttl_parsed)
353 | # IP INITIAL TIME-TO-LIVE GUESS (TG)
354 | TG = int(parse_nmap_field(base[probe][3][1]), 16)
355 | # TCP INITICIAL WINDOW SIZE (W)
356 | W = parse_nmap_field(base[probe][4][1])
357 | if ( W != "N"):
358 | W = int(W, 16)
359 | else :
360 | W = None
361 | # TCP OPTIONS
362 | if (base[probe][5][0] == "O"):
363 | opts = []
364 | opts = options_to_scapy(parse_nmap_field(base[probe][5][1]))
365 | if (base[probe][6][1] == "Y"):
366 | FLAGS = "E"
367 | elif (base[probe][6][1] == "N"):
368 | FLAGS = ""
369 | elif (base[probe][6][1] == "S"):
370 | FLAGS = "CE"
371 | else:
372 | FLAGS = "C"
373 | elif (base[probe][5][0] == "CC"):
374 | opts = []
375 | flags_parsed = parse_nmap_field(base[probe][5][1])
376 | if (flags_parsed == "Y"):
377 | FLAGS = "E"
378 | elif (flags_parsed == "N"):
379 | FLAGS = ""
380 | elif (flags_parsed == "S"):
381 | FLAGS = "CE"
382 | else:
383 | FLAGS = "C"
384 | # TODO
385 | # TCP RST DATA CHECKSUM (CC)
386 | # TODO
387 | # TCP MISCELLANEOUS QUIRKS
388 | # IPID INCREMENTS
389 | inc_ipid = get_ipid_new("CI")
390 | if (inc_ipid):
391 | IPID = IPID + inc_ipid
392 | else:
393 | IPID = IPID + randint(50, 100)
394 | if (IPID > 65535):
395 | IPID = IPID - 65535
396 | send(IP(id=IPID, dst=inet_ntoa(pkt.src), src=inet_ntoa(pkt.dst), flags=frag_bit, ttl=TG) /
397 | TCP(sport=pkt.tcp.dport, dport=pkt.tcp.sport, window=W, options=opts, flags=FLAGS), verbose=0)
398 |
399 | def send_probe_response_T1(pl, probe, packet):
400 | global IPID
401 | pkt = ip.IP(pl.get_payload())
402 | # IP DON'T FRAGMENT BIT (DF)
403 | df_parsed = parse_nmap_field(base[probe][1][1])
404 | if (df_parsed == "Y"):
405 | frag_bit = 2
406 | else:
407 | frag_bit = 0
408 | # IP INITIAL TIME-TO-LIVE GUESS (TG)
409 | TG = int(parse_nmap_field(base[probe][3][1]), 16)
410 | # TCP SEQUENCE NUMBER (S)
411 | seq_parsed = parse_nmap_field(base[probe][4][1])
412 | if seq_parsed == "Z":
413 | SEQ = 0
414 | elif seq_parsed == "A":
415 | SEQ = int(pkt.tcp.ack)
416 | elif seq_parsed == "A+":
417 | SEQ = int(pkt.tcp.ack)
418 | SEQ = SEQ + 1
419 | else:
420 | SEQ = randint(1, 65535)
421 | # TCP ACKNOWLEDGMENT NUMBER (A)
422 | if base[probe][5][1] == "Z":
423 | ACK = 0
424 | elif base[probe][5][1] == "S":
425 | ACK = int(pkt.tcp.seq)
426 | elif base[probe][5][1] == "S+":
427 | ACK = int(pkt.tcp.seq)
428 | ACK = ACK + 1
429 | else:
430 | ACK = randint(1, 65535)
431 | # TCP FLAGS (F)
432 | # R = RESET
433 | # WARNING: RST from XXX.XXX.XXX.XXX port 22 -- is this port really open?
434 | FLAGS = parse_nmap_field(base[probe][6][1])
435 | # TCP OPTIONS
436 | opts = []
437 | opts = options_to_scapy(parse_nmap_field(base["OPS"][packet - 1][1]))
438 | # TODO
439 | # TCP RST DATA CHECKSUM
440 | # TODO
441 | # TCP MISCELLANEOUS QUIRKS
442 | W = parse_nmap_field(base["WIN"][packet - 1][1])
443 | if ( W != "N"):
444 | W = int(W, 16)
445 | else :
446 | W = None
447 | send(IP(dst=inet_ntoa(pkt.src), src=inet_ntoa(pkt.dst), flags=frag_bit, ttl=TG) /
448 | TCP(sport=pkt.tcp.dport, dport=pkt.tcp.sport, seq=SEQ, ack=ACK, flags=FLAGS, window=W, options=opts,), verbose=0)
449 |
450 | def get_nmap_os_db_path():
451 | return os.path.abspath(os.path.dirname(__file__)) + "/dep/nmap-os-db"
452 |
453 | # Parse nmap-os-db
454 | def get_base():
455 | f = get_nmap_os_db_path()
456 | base = []
457 | name = None
458 | dic = {}
459 | for l in f:
460 | l = l.strip()
461 | if not l or l[0] == "#":
462 | continue
463 | if l[:12] == "Fingerprint ":
464 | print " [+] Fingerprint selected: %s" % l[12:]
465 | name = l[12:].strip()
466 | sig = {}
467 | p = base
468 | continue
469 | elif l[:6] == "Class":
470 | continue
471 | elif l[:4] == "CPE ":
472 | continue
473 | else:
474 | op = l.find("(")
475 | cl = l.find(")")
476 | if op < 0 or cl < 0:
477 | # print "error reading file"
478 | continue
479 | cursor = l[:op]
480 | dic[cursor] = (
481 | list(map(lambda x: x.split("="), l[op + 1:cl].split("%"))))
482 | return dic
483 |
484 | def get_names(search):
485 | var = 0
486 | dic = {}
487 | f = open(get_nmap_os_db_path())
488 | for l in f:
489 | l = l.strip()
490 | if (not l or l[0] == "#") and (var == 1):
491 | break
492 | if l[:12] == "Fingerprint ":
493 | if (l[12:] == search):
494 | var = 1
495 | if (var == 1):
496 | print " %s" % l
497 | if l[:6] == "Class":
498 | continue
499 | elif l[:4] == "CPE ":
500 | continue
501 | else:
502 | op = l.find("(")
503 | cl = l.find(")")
504 | if op < 0 or cl < 0:
505 | # print "error reading file"
506 | continue
507 | cursor = l[:op]
508 | dic[cursor] = (
509 | list(map(lambda x: x.split("="), l[op + 1:cl].split("%"))))
510 | return dic
511 |
512 | def list_os():
513 | f = open(get_nmap_os_db_path())
514 | for l in f:
515 | l = l.strip()
516 | if l[:12] == "Fingerprint ":
517 | print " + \"%s\"" % l[12:]
518 |
519 | def get_random_os():
520 | random = []
521 | f = open(get_nmap_os_db_path())
522 | for l in f:
523 | l = l.strip()
524 | if l[:12] == "Fingerprint ":
525 | random.append(l[12:])
526 | #random = list(dict.fromkeys(random))
527 | value = randint(0,len(random))
528 | return random[value]
529 |
530 | def search_os(search_string):
531 | # Search nmap database
532 | nmap_values = []
533 | f = open(get_nmap_os_db_path())
534 | for l in f:
535 | l = l.strip()
536 | if l[:12] == "Fingerprint ":
537 | if re.search(search_string, l[12:], re.IGNORECASE):
538 | nmap_values.append(l[12:])
539 | # Remove possible duplicates
540 | nmap_values = list(dict.fromkeys(nmap_values))
541 | # Print results
542 | print " [+] Searching databases for: '%s'" % search_string
543 | for x in range(len(nmap_values)):
544 | print " [nmap] \"%s\"" % nmap_values[x]
545 | #
546 | # Search p0f database
547 | db = module_p0f.p0f_kdb.get_base()
548 | p0f_values = []
549 | for i in range(0, len(db)):
550 | if (re.search(search_string, db[i][6], re.IGNORECASE) or re.search(search_string, db[i][7], re.IGNORECASE)) :
551 | p0f_values.append("OS: \"" + db[i][6] + "\" DETAILS: \"" + db[i][7] + "\"")
552 | # Print results
553 | for x in range(len(p0f_values)):
554 | print " [p0f] %s" % p0f_values[x]
555 | exit(0)
556 |
557 | def options_to_scapy(x):
558 | options = []
559 | for indice_opt in range(0, len(x)):
560 | if x[indice_opt] == "W":
561 | w_opt = ""
562 | for index in range(indice_opt + 1, len(x)):
563 | if ((x[index] != "N") and (x[index] != "W") and (x[index] != "M") and (x[index] != "S") and (x[index] != "T") and (x[index] != "L")):
564 | w_opt += x[index]
565 | else:
566 | break
567 | options.append(('WScale', int(w_opt, 16)))
568 | if x[indice_opt] == "N":
569 | options.append(('NOP', None))
570 | if x[indice_opt] == "M":
571 | m_opt = ""
572 | for index in range(indice_opt + 1, len(x)):
573 | if ((x[index] != "N") and (x[index] != "W") and (x[index] != "M") and (x[index] != "S") and (x[index] != "T") and (x[index] != "L")):
574 | m_opt += x[index]
575 | else:
576 | break
577 | options.append(('MSS', int(m_opt, 16)))
578 | if x[indice_opt] == "S":
579 | options.append(('SAckOK', ""))
580 | if x[indice_opt] == "T":
581 | if (x[indice_opt + 1] == "0"):
582 | T_0 = 0
583 | else:
584 | T_0 = 1 # Random
585 | if (x[indice_opt + 2] == "0"):
586 | T_1 = 0
587 | else:
588 | T_1 = 1 # Random
589 | # PENDING
590 | options.append(('Timestamp', (T_0, T_1)))
591 | if x[indice_opt] == "L":
592 | options.append(('EOL', None))
593 | return options
594 |
595 | def print_tcp_packet(pl, destination):
596 | pkt = ip.IP(pl.get_payload())
597 | option_list = tcp.parse_opts(pkt.tcp.opts)
598 |
599 | if opts.verbose:
600 | print " [+] Modifying '%s' packet in real time (total length %s)" % (destination, pl.get_payload_len())
601 | print " [+] IP: source %s destination %s tos %s id %s" % (inet_ntoa(pkt.src), inet_ntoa(pkt.dst), pkt.tos, pkt.id)
602 | print " [+] TCP: sport %s dport %s flags S seq %s ack %s win %s" % (pkt.tcp.sport, pkt.tcp.dport, pkt.tcp.seq, pkt.tcp.ack, pkt.tcp.win)
603 | print " options %s" % (opts_human(option_list))
604 |
605 | def print_icmp_packet(pl):
606 | pkt = ip.IP(pl.get_payload())
607 | if opts.verbose:
608 | print " [+] Modifying packet in real time (total length %s)" % pl.get_payload_len()
609 | print " [+] IP: source %s destination %s tos %s id %s" % (inet_ntoa(pkt.src), inet_ntoa(pkt.dst), pkt.tos, pkt.id)
610 | print " [+] ICMP: code %s type %s len %s id %s seq %s" % (pkt.icmp.code, pkt.icmp.type, len(pkt.icmp.data.data), pkt.icmp.data.id, pkt.icmp.data.seq)
611 |
612 | def print_udp_packet(pl):
613 | pkt = ip.IP(pl.get_payload())
614 |
615 | if opts.verbose:
616 | print " [+] Modifying packet in real time (total length %s)" % pl.get_payload_len()
617 | print " [+] IP: source %s destination %s tos %s id %s" % (inet_ntoa(pkt.src), inet_ntoa(pkt.dst), pkt.tos, pkt.id)
618 | print " [+] UDP: sport %s dport %s len %s" % (pkt.udp.sport, pkt.udp.dport, len(pkt.udp.data))
619 | print " data %s" % (pkt.udp.data[0:49])
620 | print " %s" % (pkt.udp.data[50:99])
621 | print " %s" % (pkt.udp.data[100:149])
622 | print " %s" % (pkt.udp.data[150:199])
623 | print " %s" % (pkt.udp.data[200:249])
624 | print " %s" % (pkt.udp.data[250:299])
625 |
626 | # Process p0f packets
627 | def cb_p0f( pl ):
628 |
629 | pkt = ip.IP(pl.get_payload())
630 |
631 | if (inet_ntoa(pkt.src) == home_ip) and (pkt.p == ip.IP_PROTO_TCP) and (tcp_flags(pkt.tcp.flags) == "S"):
632 | options = pkt.tcp.opts.encode('hex_codec')
633 | op = options.find("080a")
634 | if (op != -1):
635 | op = op + 7
636 | timestamp = options[op:][:5]
637 | i = int(timestamp, 16)
638 | if opts.osgenre and opts.details_p0f:
639 | try:
640 | pkt_send = module_p0f.p0f_impersonate(IP(dst=inet_ntoa(pkt.dst), src=inet_ntoa(pkt.src), id=pkt.id, tos=pkt.tos) / TCP(
641 | sport=pkt.tcp.sport, dport=pkt.tcp.dport, flags='S', seq=pkt.tcp.seq, ack=0), i, osgenre=opts.osgenre, osdetails=opts.details_p0f)
642 | if opts.verbose:
643 | print_tcp_packet(pl, "p0f")
644 | pl.set_payload(str(pkt_send))
645 | pl.accept()
646 | except Exception, e:
647 | print " [+] Unable to modify packet with p0f personality..."
648 | print " [+] Aborting"
649 | sys.exit()
650 | elif opts.osgenre and not opts.details_p0f:
651 | try:
652 | pkt_send = module_p0f.p0f_impersonate(IP(dst=inet_ntoa(pkt.dst), src=inet_ntoa(pkt.src)) / TCP(
653 | sport=pkt.tcp.sport, dport=pkt.tcp.dport, flags='S', seq=pkt.tcp.seq), i, osgenre=opts.osgenre)
654 | if opts.verbose:
655 | print_tcp_packet(pl, "p0f")
656 | pl.set_payload(str(pkt_send))
657 | pl.accept()
658 | except Exception, e:
659 | print " [+] Unable to modify packet with p0f personality..."
660 | print " [+] Aborting"
661 | sys.exit()
662 | else:
663 | pl.accept()
664 | else:
665 | pl.accept()
666 | # return 0
667 |
668 | # Process nmap packets
669 | def cb_nmap( pl):
670 | pkt = ip.IP(pl.get_payload())
671 | if pkt.p == ip.IP_PROTO_TCP:
672 | # Define vars for conditional loops
673 | options = pkt.tcp.opts.encode('hex_codec')
674 | flags = tcp_flags(pkt.tcp.flags)
675 | if (flags == "S") and (pkt.tcp.win == 1) and (options == T1_opt1):
676 | # nmap packet detected: Packet1 #1
677 | print_tcp_packet(pl, "nmap")
678 | pl.drop()
679 | if (base["T1"][0][1] == "Y"):
680 | send_probe_response_T1(pl, "T1", 1)
681 | elif (flags == "S") and (pkt.tcp.win == 63) and (options == T1_opt2):
682 | # nmap packet detected: Packet1 #2
683 | print_tcp_packet(pl, "nmap")
684 | pl.drop()
685 | if (base["T1"][0][1] == "Y"):
686 | send_probe_response_T1(pl, "T1", 2)
687 | elif (flags == "S") and (pkt.tcp.win == 4) and (options == T1_opt3):
688 | # nmap packet detected: Packet1 #3
689 | print_tcp_packet(pl, "nmap")
690 | pl.drop()
691 | if (base["T1"][0][1] == "Y"):
692 | send_probe_response_T1(pl, "T1", 3)
693 | elif (flags == "S") and (pkt.tcp.win == 4) and (options == T1_opt4):
694 | # nmap packet detected: Packet1 #4
695 | print_tcp_packet(pl, "nmap")
696 | pl.drop()
697 | if (base["T1"][0][1] == "Y"):
698 | send_probe_response_T1(pl, "T1", 4)
699 | elif (flags == "S") and (pkt.tcp.win == 16) and (options == T1_opt5):
700 | # nmap packet detected: Packet1 #5
701 | print_tcp_packet(pl, "nmap")
702 | pl.drop()
703 | if (base["T1"][0][1] == "Y"):
704 | send_probe_response_T1(pl, "T1", 5)
705 | elif (flags == "S") and (pkt.tcp.win == 512) and (options == T1_opt6):
706 | # nmap packet detected: Packet1 #6
707 | print_tcp_packet(pl, "nmap")
708 | pl.drop()
709 | if (base["T1"][0][1] == "Y"):
710 | send_probe_response_T1(pl, "T1", 6)
711 | elif (flags == "") and (pkt.tcp.win == 128) and (options == T2_T6_opt):
712 | # nmap packet detected: Packet2
713 | print_tcp_packet(pl, "nmap")
714 | pl.drop()
715 | if (base["T2"][0][1] == "Y"):
716 | send_probe_response(pl, "T2")
717 | elif (flags == "FSPU") and (pkt.tcp.win == 256) and (options == T2_T6_opt):
718 | # nmap packet detected: Packet3
719 | print_tcp_packet(pl, "nmap")
720 | pl.drop()
721 | if (base["T3"][0][1] == "Y"):
722 | send_probe_response(pl, "T3")
723 | elif (flags == "A") and (pkt.tcp.win == 1024) and (options == T2_T6_opt):
724 | # nmap packet detected: Packet4
725 | print_tcp_packet(pl, "nmap")
726 | pl.drop()
727 | if (base["T4"][0][1] == "Y"):
728 | send_probe_response(pl, "T4")
729 | elif (flags == "S") and (pkt.tcp.win == 31337) and (options == T2_T6_opt):
730 | # nmap packet detected: Packet5
731 | print_tcp_packet(pl, "nmap")
732 | if (base["T5"][0][1] == "Y"):
733 | send_probe_response(pl, "T5")
734 | elif (flags == "A") and (pkt.tcp.win == 32768) and (options == T2_T6_opt):
735 | # nmap packet detected: Packet6
736 | print_tcp_packet(pl, "nmap")
737 | pl.drop()
738 | if (base["T6"][0][1] == "Y"):
739 | send_probe_response(pl, "T6")
740 | elif (flags == "FPU") and (pkt.tcp.win == 65535) and (options == T7_opt):
741 | # nmap packet detected: Packet7
742 | print_tcp_packet(pl, "nmap")
743 | pl.drop()
744 | if (base["T7"][0][1] == "Y"):
745 | send_probe_response(pl, "T7")
746 | elif (flags == "SEC") and (pkt.tcp.win == 3) and (options == ECN_opt):
747 | # nmap packet detected: Packet ECE
748 | print_tcp_packet(pl, "nmap")
749 | pl.drop()
750 | if (base["ECN"][0][1] == "Y"):
751 | send_ECN_response(pl, "ECN")
752 | else:
753 | pl.accept()
754 | elif pkt.p == ip.IP_PROTO_UDP:
755 | if (pkt.udp.data == udp_payload):
756 | # nmap packet detected: Packet UDP
757 | print_udp_packet(pl)
758 | pl.drop()
759 | # TODO
760 | if ( base["U1"][0][0] != "R" ):
761 | send_udp_response(pl, "U1")
762 | else:
763 | pl.accept()
764 | elif pkt.p == ip.IP_PROTO_ICMP:
765 | if (pkt.icmp.code == 9) and (pkt.icmp.type == 8) and (len(pkt.icmp.data.data) == 120):
766 | # nmap packet detected: Packet ICMP #1
767 | print_icmp_packet(pl)
768 | pl.drop()
769 | if (base["IE"][0][0] != "R"):
770 | send_icmp_response(pl, "IE")
771 | elif (pkt.icmp.code == 0) and (pkt.icmp.type == 8) and (len(pkt.icmp.data.data) == 150):
772 | # nmap packet detected: Packet ICMP #2
773 | print_icmp_packet(pl)
774 | pl.drop()
775 | if (base["IE"][0][0] != "R"):
776 | send_icmp_response(pl, "IE")
777 | else:
778 | pl.accept()
779 | else:
780 | pl.accept()
781 | return 0
782 |
783 |
784 | def init(queue):
785 | q = nfqueue.NetfilterQueue()
786 | if (queue % 2 == 0):
787 | q.bind(queue, cb_nmap)
788 | print " [->] %s: nmap packet processor" % multiprocessing.current_process().name
789 | if (queue % 2 == 1 and (opts.osgenre or (opts.details_p0f and opts.osgenre))):
790 | q.bind(queue, cb_p0f)
791 | print " [->] %s: p0f packet processor" % multiprocessing.current_process().name
792 | try:
793 | q.run()
794 | except KeyboardInterrupt,err:
795 | pass
796 |
797 | # Upload database
798 | def update_nmap_db():
799 | sys.stdout.write(' [+] Checking nmap database... ')
800 | sys.stdout.flush()
801 | url = 'https://svn.nmap.org/nmap/nmap-os-db'
802 | response = urllib.urlopen(url)
803 | data = response.read()
804 | m = hashlib.md5()
805 | m.update(data)
806 | new_db=m.hexdigest()
807 | old_db=md5(get_nmap_os_db_path())
808 | if (new_db != old_db):
809 | f = open(get_nmap_os_db_path(), "w")
810 | f.write(data)
811 | f.close()
812 | print "updated!"
813 | else:
814 | print "latest!"
815 |
816 | def md5(fname):
817 | hash_md5 = hashlib.md5()
818 | with open(fname, "rb") as f:
819 | for chunk in iter(lambda: f.read(4096), b""):
820 | hash_md5.update(chunk)
821 | return hash_md5.hexdigest()
822 |
823 | def user_is_root():
824 | if not os.geteuid() == 0:
825 | sys.exit(' [+] OSfooler must be run as root')
826 | else:
827 | return
828 |
829 | def main():
830 | # Main program begins here
831 | show_banner()
832 | parser = optparse.OptionParser()
833 | parser.add_option('-n', '--nmap', action='store_true',
834 | dest='nmap', help="list available nmap signatures")
835 | parser.add_option('-m', '--os_nmap', action='store',
836 | dest='os', help="use nmap Operating System")
837 | parser.add_option('-p', '--p0f', action='store_true',
838 | dest='p0f', help="list available p0f v2 signatures")
839 | parser.add_option('-o', '--os_p0f', action='store',
840 | dest='osgenre', help="use p0f v2 OS Genre")
841 | parser.add_option('-d', '--details_p0f',
842 | action='store', dest='details_p0f', help="choose p0f v2 Details")
843 | parser.add_option('-i', '--interface', action='store',
844 | dest='interface', help="choose network interface (eth0)")
845 | parser.add_option('-s', '--search', action='store',
846 | dest='search', help="search OS in nmap/p0f v2 db")
847 | parser.add_option('-u', '--updatedb', action='store_true',
848 | dest='updatedb', help="update nmap database")
849 | parser.add_option('-v', '--verbose', action='store_true',
850 | dest='verbose', help="be verbose")
851 | parser.add_option('-V', '--version', action='store_true',
852 | dest='version', help="display the version of OSfooler and exit")
853 | global opts
854 | (opts, args) = parser.parse_args()
855 |
856 | if opts.search:
857 | search_os(opts.search)
858 | exit(0)
859 |
860 | if opts.version:
861 | exit(0)
862 |
863 | if opts.updatedb:
864 | user_is_root()
865 | update_nmap_db()
866 | exit(0)
867 |
868 | if opts.nmap:
869 | print(" [+] Please, select nmap OS to emulate")
870 | list_os()
871 | exit(0)
872 |
873 | if opts.p0f:
874 | print("Please, select p0f OS Genre and Details")
875 | db = module_p0f.p0f_kdb.get_base()
876 | for i in range(0, len(db)):
877 | print "\tOS Genre=\"%s\" Details=\"%s\"" % (db[i][6], db[i][7])
878 | exit(0)
879 |
880 | if not opts.os and (not (opts.details_p0f and not opts.osgenre)) and (not opts.osgenre):
881 | print " [ERROR] Please, choose a nmap or p0f OS system to emulate"
882 | print " [+] Use %s -h to get more information" % sys.argv[0]
883 | print
884 | sys.exit(' [+] Aborting...')
885 |
886 | if (opts.details_p0f and not opts.osgenre):
887 | print " [ERROR] Please, choose p0f OS system to emulate, not only OS details"
888 | print " [+] Use %s -p to list possible candidates" % sys.argv[0]
889 | print
890 | sys.exit(' [+] Aborting...')
891 |
892 | # Check if user is root before continue
893 | user_is_root()
894 |
895 | if opts.interface:
896 | interface = opts.interface
897 | try:
898 | q_num0 = os.listdir("/sys/class/net/").index(opts.interface) * 2
899 | q_num1 = os.listdir("/sys/class/net/").index(opts.interface) * 2 + 1
900 | except ValueError, err:
901 | q_num0 = -1
902 | q_num1 = -1
903 | else:
904 | interface = "eth0" # you may paste here your main interface found by '$~: ip a', for instance
905 | try:
906 | q_num0 = os.listdir("/sys/class/net/").index(opts.interface) * 2
907 | q_num1 = os.listdir("/sys/class/net/").index(opts.interface) * 2 + 1
908 | except ValueError, err:
909 | q_num0 = -1
910 | q_num1 = -1
911 |
912 | # Global -> get values from cb_nmap() and cb_p0f
913 | global base
914 |
915 | if opts.os:
916 | print " [+] Mutating to nmap:"
917 | base = {}
918 | if (opts.os == "random"):
919 | base = get_names(get_random_os())
920 | else:
921 | base = get_names(opts.os)
922 | if (not base):
923 | print " [->] \"%s\" could not be found in nmap database..." % opts.os
924 | sys.exit(' [+] Aborting...')
925 |
926 | if (opts.osgenre):
927 | print " [+] Mutating to p0f:"
928 | db = module_p0f.p0f_kdb.get_base()
929 | exists = 0
930 | db_size = len(db)
931 | if (opts.osgenre == "random"):
932 | rand_os = randint(0,db_size)
933 | opts.osgenre = db[rand_os][6]
934 | if (not opts.details_p0f):
935 | for i in range(0, db_size):
936 | if (db[i][6] == opts.osgenre):
937 | print " WWW:%s|TTL:%s|D:%s|SS:%s|OOO:%s|QQ:%s|OS:%s|DETAILS:%s" % (db[i][0],db[i][1],db[i][2],db[i][3],db[i][4],db[i][5],db[i][6],db[i][7])
938 | exists = 1
939 | if (opts.details_p0f):
940 | for i in range(0, db_size):
941 | if (db[i][6] == opts.osgenre and db[i][7] == opts.details_p0f):
942 | print " WWW:%s|TTL:%s|D:%s|SS:%s|OOO:%s|QQ:%s|OS:%s|DETAILS:%s" % (db[i][0],db[i][1],db[i][2],db[i][3],db[i][4],db[i][5],db[i][6],db[i][7])
943 | exists = 1
944 | break
945 | if (not exists):
946 | print " [->] Could not found that combination in p0f database..."
947 | sys.exit(' [+] Aborting...')
948 |
949 | if (not opts.details_p0f and opts.osgenre):
950 | print " [i] You've only selected p0f OS genre. Details will be chosen randomly every packet from the list bellow"
951 |
952 | # Start activity
953 | print " [+] Activating queues"
954 | procs = []
955 | # nmap mode
956 | if opts.os:
957 | os.system("iptables -A INPUT -t mangle -j NFQUEUE --queue-num %s" % q_num0)
958 | proc = Process(target=init,args=(q_num0,))
959 | procs.append(proc)
960 | proc.start()
961 | # p0f mode
962 | if (opts.osgenre):
963 | global home_ip
964 | home_ip = get_ip_address(interface)
965 | os.system("iptables -A OUTPUT -t mangle -p TCP --syn -j NFQUEUE --queue-num %s" % q_num1)
966 | proc = Process(target=init,args=(q_num1,))
967 | procs.append(proc)
968 | proc.start()
969 | # Detect mode
970 |
971 | try:
972 | for proc in procs:
973 | proc.join()
974 | print
975 | # Flush all iptabels rules
976 | if (q_num0 >= 0):
977 | os.system("iptables -D INPUT -t mangle -j NFQUEUE --queue-num %s" % q_num0)
978 | if (q_num1 >= 1):
979 | os.system("iptables -D OUTPUT -t mangle -p TCP --syn -j NFQUEUE --queue-num %s" % q_num1)
980 | print " [+] Active queues removed"
981 | print " [+] Exiting OSfooler..."
982 | except KeyboardInterrupt:
983 | print
984 | # Flush all iptabels rules
985 | if (q_num0 >= 0):
986 | os.system("iptables -D INPUT -t mangle -j NFQUEUE --queue-num %s" % q_num0)
987 | if (q_num1 >= 1):
988 | os.system("iptables -D OUTPUT -t mangle -p TCP --syn -j NFQUEUE --queue-num %s" % q_num1)
989 | print " [+] Active queues removed"
990 | print " [+] Exiting OSfooler..."
991 | #for p in multiprocessing.active_children():
992 | # p.terminate()
993 |
994 | if __name__ == "__main__":
995 | main()
996 |
--------------------------------------------------------------------------------
/requirements.txt:
--------------------------------------------------------------------------------
1 | dpkt
2 | scapy
3 |
--------------------------------------------------------------------------------
/setup.py:
--------------------------------------------------------------------------------
1 | import setuptools
2 |
3 | with open("README.md", "r") as fh:
4 | long_description = fh.read()
5 |
6 | setuptools.setup(
7 | name="OSfooler-ng",
8 | version="v1.00b",
9 | author='Jaime Sanchez (@segofensiva)',
10 | author_email='jsanchez@seguridadofensiva.com',
11 | description='OSfooler-ng prevents remote OS active/passive fingerprinting by tools like nmap or p0f',
12 | long_description=long_description,
13 | long_description_content_type="text/markdown",
14 | url='https://github.com/segofensiva/OSfooler-ng',
15 | include_package_data=True,
16 | entry_points = {
17 | 'console_scripts': ['osfooler-ng=osfooler_ng.osfooler_ng:main'],
18 | },
19 | packages=setuptools.find_packages(),
20 | install_requires=open('requirements.txt').read().splitlines(),
21 | classifiers=[
22 | "Development Status :: 4 - Beta",
23 | "Environment :: Console",
24 | "Operating System :: POSIX :: Linux",
25 | "Topic :: System :: Networking",
26 | "Programming Language :: Python",
27 | "Topic :: Security",
28 | "License :: OSI Approved :: GNU General Public License v3 (GPLv3)"
29 | ],
30 | )
31 |
--------------------------------------------------------------------------------