New upstream release.
Kali Janitor
2 years ago
0 | - add attribute "command" for the pluggins of each command | |
1 | - adding test in test_command | |
2 | - change some regex in self._command_regex⏎ |
0 | [FIX] add hostnames if host is already cached |
0 | Add Naabu plugin |
0 | Add Sonarqube plugin |
0 | Add version and change list_plugins style |
0 | FIX unused import, innecesary list compression and unused variables⏎ |
0 | May 14th, 2021 |
0 | FIX metasploit report when the web-site-id is null⏎ |
0 | Fix port stats in nmap |
0 | ADD remedy into resolution⏎ |
0 | Support for nuclei 2.3.0 |
0 | ADD cve, cvss3_base_score, cvss3_vector, exploit_available when import nessus and change the structure of external_id to NESSUS-XXX⏎ |
0 | ADD more data like attack, params, uri, method, WASC, CWE and format externail_id⏎ |
0 | GNU GENERAL PUBLIC LICENSE | |
1 | Version 3, 29 June 2007 | |
2 | ||
3 | Copyright (C) 2007 Free Software Foundation, Inc. <https://fsf.org/> | |
4 | Everyone is permitted to copy and distribute verbatim copies | |
5 | of this license document, but changing it is not allowed. | |
6 | ||
7 | Preamble | |
8 | ||
9 | The GNU General Public License is a free, copyleft license for | |
10 | software and other kinds of works. | |
11 | ||
12 | The licenses for most software and other practical works are designed | |
13 | to take away your freedom to share and change the works. By contrast, | |
14 | the GNU General Public License is intended to guarantee your freedom to | |
15 | share and change all versions of a program--to make sure it remains free | |
16 | software for all its users. We, the Free Software Foundation, use the | |
17 | GNU General Public License for most of our software; it applies also to | |
18 | any other work released this way by its authors. You can apply it to | |
19 | your programs, too. | |
20 | ||
21 | When we speak of free software, we are referring to freedom, not | |
22 | price. Our General Public Licenses are designed to make sure that you | |
23 | have the freedom to distribute copies of free software (and charge for | |
24 | them if you wish), that you receive source code or can get it if you | |
25 | want it, that you can change the software or use pieces of it in new | |
26 | free programs, and that you know you can do these things. | |
27 | ||
28 | To protect your rights, we need to prevent others from denying you | |
29 | these rights or asking you to surrender the rights. Therefore, you have | |
30 | certain responsibilities if you distribute copies of the software, or if | |
31 | you modify it: responsibilities to respect the freedom of others. | |
32 | ||
33 | For example, if you distribute copies of such a program, whether | |
34 | gratis or for a fee, you must pass on to the recipients the same | |
35 | freedoms that you received. You must make sure that they, too, receive | |
36 | or can get the source code. And you must show them these terms so they | |
37 | know their rights. | |
38 | ||
39 | Developers that use the GNU GPL protect your rights with two steps: | |
40 | (1) assert copyright on the software, and (2) offer you this License | |
41 | giving you legal permission to copy, distribute and/or modify it. | |
42 | ||
43 | For the developers' and authors' protection, the GPL clearly explains | |
44 | that there is no warranty for this free software. For both users' and | |
45 | authors' sake, the GPL requires that modified versions be marked as | |
46 | changed, so that their problems will not be attributed erroneously to | |
47 | authors of previous versions. | |
48 | ||
49 | Some devices are designed to deny users access to install or run | |
50 | modified versions of the software inside them, although the manufacturer | |
51 | can do so. This is fundamentally incompatible with the aim of | |
52 | protecting users' freedom to change the software. The systematic | |
53 | pattern of such abuse occurs in the area of products for individuals to | |
54 | use, which is precisely where it is most unacceptable. Therefore, we | |
55 | have designed this version of the GPL to prohibit the practice for those | |
56 | products. If such problems arise substantially in other domains, we | |
57 | stand ready to extend this provision to those domains in future versions | |
58 | of the GPL, as needed to protect the freedom of users. | |
59 | ||
60 | Finally, every program is threatened constantly by software patents. | |
61 | States should not allow patents to restrict development and use of | |
62 | software on general-purpose computers, but in those that do, we wish to | |
63 | avoid the special danger that patents applied to a free program could | |
64 | make it effectively proprietary. To prevent this, the GPL assures that | |
65 | patents cannot be used to render the program non-free. | |
66 | ||
67 | The precise terms and conditions for copying, distribution and | |
68 | modification follow. | |
69 | ||
70 | TERMS AND CONDITIONS | |
71 | ||
72 | 0. Definitions. | |
73 | ||
74 | "This License" refers to version 3 of the GNU General Public License. | |
75 | ||
76 | "Copyright" also means copyright-like laws that apply to other kinds of | |
77 | works, such as semiconductor masks. | |
78 | ||
79 | "The Program" refers to any copyrightable work licensed under this | |
80 | License. Each licensee is addressed as "you". "Licensees" and | |
81 | "recipients" may be individuals or organizations. | |
82 | ||
83 | To "modify" a work means to copy from or adapt all or part of the work | |
84 | in a fashion requiring copyright permission, other than the making of an | |
85 | exact copy. The resulting work is called a "modified version" of the | |
86 | earlier work or a work "based on" the earlier work. | |
87 | ||
88 | A "covered work" means either the unmodified Program or a work based | |
89 | on the Program. | |
90 | ||
91 | To "propagate" a work means to do anything with it that, without | |
92 | permission, would make you directly or secondarily liable for | |
93 | infringement under applicable copyright law, except executing it on a | |
94 | computer or modifying a private copy. Propagation includes copying, | |
95 | distribution (with or without modification), making available to the | |
96 | public, and in some countries other activities as well. | |
97 | ||
98 | To "convey" a work means any kind of propagation that enables other | |
99 | parties to make or receive copies. Mere interaction with a user through | |
100 | a computer network, with no transfer of a copy, is not conveying. | |
101 | ||
102 | An interactive user interface displays "Appropriate Legal Notices" | |
103 | to the extent that it includes a convenient and prominently visible | |
104 | feature that (1) displays an appropriate copyright notice, and (2) | |
105 | tells the user that there is no warranty for the work (except to the | |
106 | extent that warranties are provided), that licensees may convey the | |
107 | work under this License, and how to view a copy of this License. If | |
108 | the interface presents a list of user commands or options, such as a | |
109 | menu, a prominent item in the list meets this criterion. | |
110 | ||
111 | 1. Source Code. | |
112 | ||
113 | The "source code" for a work means the preferred form of the work | |
114 | for making modifications to it. "Object code" means any non-source | |
115 | form of a work. | |
116 | ||
117 | A "Standard Interface" means an interface that either is an official | |
118 | standard defined by a recognized standards body, or, in the case of | |
119 | interfaces specified for a particular programming language, one that | |
120 | is widely used among developers working in that language. | |
121 | ||
122 | The "System Libraries" of an executable work include anything, other | |
123 | than the work as a whole, that (a) is included in the normal form of | |
124 | packaging a Major Component, but which is not part of that Major | |
125 | Component, and (b) serves only to enable use of the work with that | |
126 | Major Component, or to implement a Standard Interface for which an | |
127 | implementation is available to the public in source code form. A | |
128 | "Major Component", in this context, means a major essential component | |
129 | (kernel, window system, and so on) of the specific operating system | |
130 | (if any) on which the executable work runs, or a compiler used to | |
131 | produce the work, or an object code interpreter used to run it. | |
132 | ||
133 | The "Corresponding Source" for a work in object code form means all | |
134 | the source code needed to generate, install, and (for an executable | |
135 | work) run the object code and to modify the work, including scripts to | |
136 | control those activities. However, it does not include the work's | |
137 | System Libraries, or general-purpose tools or generally available free | |
138 | programs which are used unmodified in performing those activities but | |
139 | which are not part of the work. For example, Corresponding Source | |
140 | includes interface definition files associated with source files for | |
141 | the work, and the source code for shared libraries and dynamically | |
142 | linked subprograms that the work is specifically designed to require, | |
143 | such as by intimate data communication or control flow between those | |
144 | subprograms and other parts of the work. | |
145 | ||
146 | The Corresponding Source need not include anything that users | |
147 | can regenerate automatically from other parts of the Corresponding | |
148 | Source. | |
149 | ||
150 | The Corresponding Source for a work in source code form is that | |
151 | same work. | |
152 | ||
153 | 2. Basic Permissions. | |
154 | ||
155 | All rights granted under this License are granted for the term of | |
156 | copyright on the Program, and are irrevocable provided the stated | |
157 | conditions are met. This License explicitly affirms your unlimited | |
158 | permission to run the unmodified Program. The output from running a | |
159 | covered work is covered by this License only if the output, given its | |
160 | content, constitutes a covered work. This License acknowledges your | |
161 | rights of fair use or other equivalent, as provided by copyright law. | |
162 | ||
163 | You may make, run and propagate covered works that you do not | |
164 | convey, without conditions so long as your license otherwise remains | |
165 | in force. You may convey covered works to others for the sole purpose | |
166 | of having them make modifications exclusively for you, or provide you | |
167 | with facilities for running those works, provided that you comply with | |
168 | the terms of this License in conveying all material for which you do | |
169 | not control copyright. Those thus making or running the covered works | |
170 | for you must do so exclusively on your behalf, under your direction | |
171 | and control, on terms that prohibit them from making any copies of | |
172 | your copyrighted material outside their relationship with you. | |
173 | ||
174 | Conveying under any other circumstances is permitted solely under | |
175 | the conditions stated below. Sublicensing is not allowed; section 10 | |
176 | makes it unnecessary. | |
177 | ||
178 | 3. Protecting Users' Legal Rights From Anti-Circumvention Law. | |
179 | ||
180 | No covered work shall be deemed part of an effective technological | |
181 | measure under any applicable law fulfilling obligations under article | |
182 | 11 of the WIPO copyright treaty adopted on 20 December 1996, or | |
183 | similar laws prohibiting or restricting circumvention of such | |
184 | measures. | |
185 | ||
186 | When you convey a covered work, you waive any legal power to forbid | |
187 | circumvention of technological measures to the extent such circumvention | |
188 | is effected by exercising rights under this License with respect to | |
189 | the covered work, and you disclaim any intention to limit operation or | |
190 | modification of the work as a means of enforcing, against the work's | |
191 | users, your or third parties' legal rights to forbid circumvention of | |
192 | technological measures. | |
193 | ||
194 | 4. Conveying Verbatim Copies. | |
195 | ||
196 | You may convey verbatim copies of the Program's source code as you | |
197 | receive it, in any medium, provided that you conspicuously and | |
198 | appropriately publish on each copy an appropriate copyright notice; | |
199 | keep intact all notices stating that this License and any | |
200 | non-permissive terms added in accord with section 7 apply to the code; | |
201 | keep intact all notices of the absence of any warranty; and give all | |
202 | recipients a copy of this License along with the Program. | |
203 | ||
204 | You may charge any price or no price for each copy that you convey, | |
205 | and you may offer support or warranty protection for a fee. | |
206 | ||
207 | 5. Conveying Modified Source Versions. | |
208 | ||
209 | You may convey a work based on the Program, or the modifications to | |
210 | produce it from the Program, in the form of source code under the | |
211 | terms of section 4, provided that you also meet all of these conditions: | |
212 | ||
213 | a) The work must carry prominent notices stating that you modified | |
214 | it, and giving a relevant date. | |
215 | ||
216 | b) The work must carry prominent notices stating that it is | |
217 | released under this License and any conditions added under section | |
218 | 7. This requirement modifies the requirement in section 4 to | |
219 | "keep intact all notices". | |
220 | ||
221 | c) You must license the entire work, as a whole, under this | |
222 | License to anyone who comes into possession of a copy. This | |
223 | License will therefore apply, along with any applicable section 7 | |
224 | additional terms, to the whole of the work, and all its parts, | |
225 | regardless of how they are packaged. This License gives no | |
226 | permission to license the work in any other way, but it does not | |
227 | invalidate such permission if you have separately received it. | |
228 | ||
229 | d) If the work has interactive user interfaces, each must display | |
230 | Appropriate Legal Notices; however, if the Program has interactive | |
231 | interfaces that do not display Appropriate Legal Notices, your | |
232 | work need not make them do so. | |
233 | ||
234 | A compilation of a covered work with other separate and independent | |
235 | works, which are not by their nature extensions of the covered work, | |
236 | and which are not combined with it such as to form a larger program, | |
237 | in or on a volume of a storage or distribution medium, is called an | |
238 | "aggregate" if the compilation and its resulting copyright are not | |
239 | used to limit the access or legal rights of the compilation's users | |
240 | beyond what the individual works permit. Inclusion of a covered work | |
241 | in an aggregate does not cause this License to apply to the other | |
242 | parts of the aggregate. | |
243 | ||
244 | 6. Conveying Non-Source Forms. | |
245 | ||
246 | You may convey a covered work in object code form under the terms | |
247 | of sections 4 and 5, provided that you also convey the | |
248 | machine-readable Corresponding Source under the terms of this License, | |
249 | in one of these ways: | |
250 | ||
251 | a) Convey the object code in, or embodied in, a physical product | |
252 | (including a physical distribution medium), accompanied by the | |
253 | Corresponding Source fixed on a durable physical medium | |
254 | customarily used for software interchange. | |
255 | ||
256 | b) Convey the object code in, or embodied in, a physical product | |
257 | (including a physical distribution medium), accompanied by a | |
258 | written offer, valid for at least three years and valid for as | |
259 | long as you offer spare parts or customer support for that product | |
260 | model, to give anyone who possesses the object code either (1) a | |
261 | copy of the Corresponding Source for all the software in the | |
262 | product that is covered by this License, on a durable physical | |
263 | medium customarily used for software interchange, for a price no | |
264 | more than your reasonable cost of physically performing this | |
265 | conveying of source, or (2) access to copy the | |
266 | Corresponding Source from a network server at no charge. | |
267 | ||
268 | c) Convey individual copies of the object code with a copy of the | |
269 | written offer to provide the Corresponding Source. This | |
270 | alternative is allowed only occasionally and noncommercially, and | |
271 | only if you received the object code with such an offer, in accord | |
272 | with subsection 6b. | |
273 | ||
274 | d) Convey the object code by offering access from a designated | |
275 | place (gratis or for a charge), and offer equivalent access to the | |
276 | Corresponding Source in the same way through the same place at no | |
277 | further charge. You need not require recipients to copy the | |
278 | Corresponding Source along with the object code. If the place to | |
279 | copy the object code is a network server, the Corresponding Source | |
280 | may be on a different server (operated by you or a third party) | |
281 | that supports equivalent copying facilities, provided you maintain | |
282 | clear directions next to the object code saying where to find the | |
283 | Corresponding Source. Regardless of what server hosts the | |
284 | Corresponding Source, you remain obligated to ensure that it is | |
285 | available for as long as needed to satisfy these requirements. | |
286 | ||
287 | e) Convey the object code using peer-to-peer transmission, provided | |
288 | you inform other peers where the object code and Corresponding | |
289 | Source of the work are being offered to the general public at no | |
290 | charge under subsection 6d. | |
291 | ||
292 | A separable portion of the object code, whose source code is excluded | |
293 | from the Corresponding Source as a System Library, need not be | |
294 | included in conveying the object code work. | |
295 | ||
296 | A "User Product" is either (1) a "consumer product", which means any | |
297 | tangible personal property which is normally used for personal, family, | |
298 | or household purposes, or (2) anything designed or sold for incorporation | |
299 | into a dwelling. In determining whether a product is a consumer product, | |
300 | doubtful cases shall be resolved in favor of coverage. For a particular | |
301 | product received by a particular user, "normally used" refers to a | |
302 | typical or common use of that class of product, regardless of the status | |
303 | of the particular user or of the way in which the particular user | |
304 | actually uses, or expects or is expected to use, the product. A product | |
305 | is a consumer product regardless of whether the product has substantial | |
306 | commercial, industrial or non-consumer uses, unless such uses represent | |
307 | the only significant mode of use of the product. | |
308 | ||
309 | "Installation Information" for a User Product means any methods, | |
310 | procedures, authorization keys, or other information required to install | |
311 | and execute modified versions of a covered work in that User Product from | |
312 | a modified version of its Corresponding Source. The information must | |
313 | suffice to ensure that the continued functioning of the modified object | |
314 | code is in no case prevented or interfered with solely because | |
315 | modification has been made. | |
316 | ||
317 | If you convey an object code work under this section in, or with, or | |
318 | specifically for use in, a User Product, and the conveying occurs as | |
319 | part of a transaction in which the right of possession and use of the | |
320 | User Product is transferred to the recipient in perpetuity or for a | |
321 | fixed term (regardless of how the transaction is characterized), the | |
322 | Corresponding Source conveyed under this section must be accompanied | |
323 | by the Installation Information. But this requirement does not apply | |
324 | if neither you nor any third party retains the ability to install | |
325 | modified object code on the User Product (for example, the work has | |
326 | been installed in ROM). | |
327 | ||
328 | The requirement to provide Installation Information does not include a | |
329 | requirement to continue to provide support service, warranty, or updates | |
330 | for a work that has been modified or installed by the recipient, or for | |
331 | the User Product in which it has been modified or installed. Access to a | |
332 | network may be denied when the modification itself materially and | |
333 | adversely affects the operation of the network or violates the rules and | |
334 | protocols for communication across the network. | |
335 | ||
336 | Corresponding Source conveyed, and Installation Information provided, | |
337 | in accord with this section must be in a format that is publicly | |
338 | documented (and with an implementation available to the public in | |
339 | source code form), and must require no special password or key for | |
340 | unpacking, reading or copying. | |
341 | ||
342 | 7. Additional Terms. | |
343 | ||
344 | "Additional permissions" are terms that supplement the terms of this | |
345 | License by making exceptions from one or more of its conditions. | |
346 | Additional permissions that are applicable to the entire Program shall | |
347 | be treated as though they were included in this License, to the extent | |
348 | that they are valid under applicable law. If additional permissions | |
349 | apply only to part of the Program, that part may be used separately | |
350 | under those permissions, but the entire Program remains governed by | |
351 | this License without regard to the additional permissions. | |
352 | ||
353 | When you convey a copy of a covered work, you may at your option | |
354 | remove any additional permissions from that copy, or from any part of | |
355 | it. (Additional permissions may be written to require their own | |
356 | removal in certain cases when you modify the work.) You may place | |
357 | additional permissions on material, added by you to a covered work, | |
358 | for which you have or can give appropriate copyright permission. | |
359 | ||
360 | Notwithstanding any other provision of this License, for material you | |
361 | add to a covered work, you may (if authorized by the copyright holders of | |
362 | that material) supplement the terms of this License with terms: | |
363 | ||
364 | a) Disclaiming warranty or limiting liability differently from the | |
365 | terms of sections 15 and 16 of this License; or | |
366 | ||
367 | b) Requiring preservation of specified reasonable legal notices or | |
368 | author attributions in that material or in the Appropriate Legal | |
369 | Notices displayed by works containing it; or | |
370 | ||
371 | c) Prohibiting misrepresentation of the origin of that material, or | |
372 | requiring that modified versions of such material be marked in | |
373 | reasonable ways as different from the original version; or | |
374 | ||
375 | d) Limiting the use for publicity purposes of names of licensors or | |
376 | authors of the material; or | |
377 | ||
378 | e) Declining to grant rights under trademark law for use of some | |
379 | trade names, trademarks, or service marks; or | |
380 | ||
381 | f) Requiring indemnification of licensors and authors of that | |
382 | material by anyone who conveys the material (or modified versions of | |
383 | it) with contractual assumptions of liability to the recipient, for | |
384 | any liability that these contractual assumptions directly impose on | |
385 | those licensors and authors. | |
386 | ||
387 | All other non-permissive additional terms are considered "further | |
388 | restrictions" within the meaning of section 10. If the Program as you | |
389 | received it, or any part of it, contains a notice stating that it is | |
390 | governed by this License along with a term that is a further | |
391 | restriction, you may remove that term. If a license document contains | |
392 | a further restriction but permits relicensing or conveying under this | |
393 | License, you may add to a covered work material governed by the terms | |
394 | of that license document, provided that the further restriction does | |
395 | not survive such relicensing or conveying. | |
396 | ||
397 | If you add terms to a covered work in accord with this section, you | |
398 | must place, in the relevant source files, a statement of the | |
399 | additional terms that apply to those files, or a notice indicating | |
400 | where to find the applicable terms. | |
401 | ||
402 | Additional terms, permissive or non-permissive, may be stated in the | |
403 | form of a separately written license, or stated as exceptions; | |
404 | the above requirements apply either way. | |
405 | ||
406 | 8. Termination. | |
407 | ||
408 | You may not propagate or modify a covered work except as expressly | |
409 | provided under this License. Any attempt otherwise to propagate or | |
410 | modify it is void, and will automatically terminate your rights under | |
411 | this License (including any patent licenses granted under the third | |
412 | paragraph of section 11). | |
413 | ||
414 | However, if you cease all violation of this License, then your | |
415 | license from a particular copyright holder is reinstated (a) | |
416 | provisionally, unless and until the copyright holder explicitly and | |
417 | finally terminates your license, and (b) permanently, if the copyright | |
418 | holder fails to notify you of the violation by some reasonable means | |
419 | prior to 60 days after the cessation. | |
420 | ||
421 | Moreover, your license from a particular copyright holder is | |
422 | reinstated permanently if the copyright holder notifies you of the | |
423 | violation by some reasonable means, this is the first time you have | |
424 | received notice of violation of this License (for any work) from that | |
425 | copyright holder, and you cure the violation prior to 30 days after | |
426 | your receipt of the notice. | |
427 | ||
428 | Termination of your rights under this section does not terminate the | |
429 | licenses of parties who have received copies or rights from you under | |
430 | this License. If your rights have been terminated and not permanently | |
431 | reinstated, you do not qualify to receive new licenses for the same | |
432 | material under section 10. | |
433 | ||
434 | 9. Acceptance Not Required for Having Copies. | |
435 | ||
436 | You are not required to accept this License in order to receive or | |
437 | run a copy of the Program. Ancillary propagation of a covered work | |
438 | occurring solely as a consequence of using peer-to-peer transmission | |
439 | to receive a copy likewise does not require acceptance. However, | |
440 | nothing other than this License grants you permission to propagate or | |
441 | modify any covered work. These actions infringe copyright if you do | |
442 | not accept this License. Therefore, by modifying or propagating a | |
443 | covered work, you indicate your acceptance of this License to do so. | |
444 | ||
445 | 10. Automatic Licensing of Downstream Recipients. | |
446 | ||
447 | Each time you convey a covered work, the recipient automatically | |
448 | receives a license from the original licensors, to run, modify and | |
449 | propagate that work, subject to this License. You are not responsible | |
450 | for enforcing compliance by third parties with this License. | |
451 | ||
452 | An "entity transaction" is a transaction transferring control of an | |
453 | organization, or substantially all assets of one, or subdividing an | |
454 | organization, or merging organizations. If propagation of a covered | |
455 | work results from an entity transaction, each party to that | |
456 | transaction who receives a copy of the work also receives whatever | |
457 | licenses to the work the party's predecessor in interest had or could | |
458 | give under the previous paragraph, plus a right to possession of the | |
459 | Corresponding Source of the work from the predecessor in interest, if | |
460 | the predecessor has it or can get it with reasonable efforts. | |
461 | ||
462 | You may not impose any further restrictions on the exercise of the | |
463 | rights granted or affirmed under this License. For example, you may | |
464 | not impose a license fee, royalty, or other charge for exercise of | |
465 | rights granted under this License, and you may not initiate litigation | |
466 | (including a cross-claim or counterclaim in a lawsuit) alleging that | |
467 | any patent claim is infringed by making, using, selling, offering for | |
468 | sale, or importing the Program or any portion of it. | |
469 | ||
470 | 11. Patents. | |
471 | ||
472 | A "contributor" is a copyright holder who authorizes use under this | |
473 | License of the Program or a work on which the Program is based. The | |
474 | work thus licensed is called the contributor's "contributor version". | |
475 | ||
476 | A contributor's "essential patent claims" are all patent claims | |
477 | owned or controlled by the contributor, whether already acquired or | |
478 | hereafter acquired, that would be infringed by some manner, permitted | |
479 | by this License, of making, using, or selling its contributor version, | |
480 | but do not include claims that would be infringed only as a | |
481 | consequence of further modification of the contributor version. For | |
482 | purposes of this definition, "control" includes the right to grant | |
483 | patent sublicenses in a manner consistent with the requirements of | |
484 | this License. | |
485 | ||
486 | Each contributor grants you a non-exclusive, worldwide, royalty-free | |
487 | patent license under the contributor's essential patent claims, to | |
488 | make, use, sell, offer for sale, import and otherwise run, modify and | |
489 | propagate the contents of its contributor version. | |
490 | ||
491 | In the following three paragraphs, a "patent license" is any express | |
492 | agreement or commitment, however denominated, not to enforce a patent | |
493 | (such as an express permission to practice a patent or covenant not to | |
494 | sue for patent infringement). To "grant" such a patent license to a | |
495 | party means to make such an agreement or commitment not to enforce a | |
496 | patent against the party. | |
497 | ||
498 | If you convey a covered work, knowingly relying on a patent license, | |
499 | and the Corresponding Source of the work is not available for anyone | |
500 | to copy, free of charge and under the terms of this License, through a | |
501 | publicly available network server or other readily accessible means, | |
502 | then you must either (1) cause the Corresponding Source to be so | |
503 | available, or (2) arrange to deprive yourself of the benefit of the | |
504 | patent license for this particular work, or (3) arrange, in a manner | |
505 | consistent with the requirements of this License, to extend the patent | |
506 | license to downstream recipients. "Knowingly relying" means you have | |
507 | actual knowledge that, but for the patent license, your conveying the | |
508 | covered work in a country, or your recipient's use of the covered work | |
509 | in a country, would infringe one or more identifiable patents in that | |
510 | country that you have reason to believe are valid. | |
511 | ||
512 | If, pursuant to or in connection with a single transaction or | |
513 | arrangement, you convey, or propagate by procuring conveyance of, a | |
514 | covered work, and grant a patent license to some of the parties | |
515 | receiving the covered work authorizing them to use, propagate, modify | |
516 | or convey a specific copy of the covered work, then the patent license | |
517 | you grant is automatically extended to all recipients of the covered | |
518 | work and works based on it. | |
519 | ||
520 | A patent license is "discriminatory" if it does not include within | |
521 | the scope of its coverage, prohibits the exercise of, or is | |
522 | conditioned on the non-exercise of one or more of the rights that are | |
523 | specifically granted under this License. You may not convey a covered | |
524 | work if you are a party to an arrangement with a third party that is | |
525 | in the business of distributing software, under which you make payment | |
526 | to the third party based on the extent of your activity of conveying | |
527 | the work, and under which the third party grants, to any of the | |
528 | parties who would receive the covered work from you, a discriminatory | |
529 | patent license (a) in connection with copies of the covered work | |
530 | conveyed by you (or copies made from those copies), or (b) primarily | |
531 | for and in connection with specific products or compilations that | |
532 | contain the covered work, unless you entered into that arrangement, | |
533 | or that patent license was granted, prior to 28 March 2007. | |
534 | ||
535 | Nothing in this License shall be construed as excluding or limiting | |
536 | any implied license or other defenses to infringement that may | |
537 | otherwise be available to you under applicable patent law. | |
538 | ||
539 | 12. No Surrender of Others' Freedom. | |
540 | ||
541 | If conditions are imposed on you (whether by court order, agreement or | |
542 | otherwise) that contradict the conditions of this License, they do not | |
543 | excuse you from the conditions of this License. If you cannot convey a | |
544 | covered work so as to satisfy simultaneously your obligations under this | |
545 | License and any other pertinent obligations, then as a consequence you may | |
546 | not convey it at all. For example, if you agree to terms that obligate you | |
547 | to collect a royalty for further conveying from those to whom you convey | |
548 | the Program, the only way you could satisfy both those terms and this | |
549 | License would be to refrain entirely from conveying the Program. | |
550 | ||
551 | 13. Use with the GNU Affero General Public License. | |
552 | ||
553 | Notwithstanding any other provision of this License, you have | |
554 | permission to link or combine any covered work with a work licensed | |
555 | under version 3 of the GNU Affero General Public License into a single | |
556 | combined work, and to convey the resulting work. The terms of this | |
557 | License will continue to apply to the part which is the covered work, | |
558 | but the special requirements of the GNU Affero General Public License, | |
559 | section 13, concerning interaction through a network will apply to the | |
560 | combination as such. | |
561 | ||
562 | 14. Revised Versions of this License. | |
563 | ||
564 | The Free Software Foundation may publish revised and/or new versions of | |
565 | the GNU General Public License from time to time. Such new versions will | |
566 | be similar in spirit to the present version, but may differ in detail to | |
567 | address new problems or concerns. | |
568 | ||
569 | Each version is given a distinguishing version number. If the | |
570 | Program specifies that a certain numbered version of the GNU General | |
571 | Public License "or any later version" applies to it, you have the | |
572 | option of following the terms and conditions either of that numbered | |
573 | version or of any later version published by the Free Software | |
574 | Foundation. If the Program does not specify a version number of the | |
575 | GNU General Public License, you may choose any version ever published | |
576 | by the Free Software Foundation. | |
577 | ||
578 | If the Program specifies that a proxy can decide which future | |
579 | versions of the GNU General Public License can be used, that proxy's | |
580 | public statement of acceptance of a version permanently authorizes you | |
581 | to choose that version for the Program. | |
582 | ||
583 | Later license versions may give you additional or different | |
584 | permissions. However, no additional obligations are imposed on any | |
585 | author or copyright holder as a result of your choosing to follow a | |
586 | later version. | |
587 | ||
588 | 15. Disclaimer of Warranty. | |
589 | ||
590 | THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY | |
591 | APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT | |
592 | HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY | |
593 | OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, | |
594 | THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR | |
595 | PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM | |
596 | IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF | |
597 | ALL NECESSARY SERVICING, REPAIR OR CORRECTION. | |
598 | ||
599 | 16. Limitation of Liability. | |
600 | ||
601 | IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING | |
602 | WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS | |
603 | THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY | |
604 | GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE | |
605 | USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF | |
606 | DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD | |
607 | PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), | |
608 | EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF | |
609 | SUCH DAMAGES. | |
610 | ||
611 | 17. Interpretation of Sections 15 and 16. | |
612 | ||
613 | If the disclaimer of warranty and limitation of liability provided | |
614 | above cannot be given local legal effect according to their terms, | |
615 | reviewing courts shall apply local law that most closely approximates | |
616 | an absolute waiver of all civil liability in connection with the | |
617 | Program, unless a warranty or assumption of liability accompanies a | |
618 | copy of the Program in return for a fee. | |
619 | ||
620 | END OF TERMS AND CONDITIONS | |
621 | ||
622 | How to Apply These Terms to Your New Programs | |
623 | ||
624 | If you develop a new program, and you want it to be of the greatest | |
625 | possible use to the public, the best way to achieve this is to make it | |
626 | free software which everyone can redistribute and change under these terms. | |
627 | ||
628 | To do so, attach the following notices to the program. It is safest | |
629 | to attach them to the start of each source file to most effectively | |
630 | state the exclusion of warranty; and each file should have at least | |
631 | the "copyright" line and a pointer to where the full notice is found. | |
632 | ||
633 | <one line to give the program's name and a brief idea of what it does.> | |
634 | Copyright (C) <year> <name of author> | |
635 | ||
636 | This program is free software: you can redistribute it and/or modify | |
637 | it under the terms of the GNU General Public License as published by | |
638 | the Free Software Foundation, either version 3 of the License, or | |
639 | (at your option) any later version. | |
640 | ||
641 | This program is distributed in the hope that it will be useful, | |
642 | but WITHOUT ANY WARRANTY; without even the implied warranty of | |
643 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
644 | GNU General Public License for more details. | |
645 | ||
646 | You should have received a copy of the GNU General Public License | |
647 | along with this program. If not, see <https://www.gnu.org/licenses/>. | |
648 | ||
649 | Also add information on how to contact you by electronic and paper mail. | |
650 | ||
651 | If the program does terminal interaction, make it output a short | |
652 | notice like this when it starts in an interactive mode: | |
653 | ||
654 | <program> Copyright (C) <year> <name of author> | |
655 | This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'. | |
656 | This is free software, and you are welcome to redistribute it | |
657 | under certain conditions; type `show c' for details. | |
658 | ||
659 | The hypothetical commands `show w' and `show c' should show the appropriate | |
660 | parts of the General Public License. Of course, your program's commands | |
661 | might be different; for a GUI interface, you would use an "about box". | |
662 | ||
663 | You should also get your employer (if you work as a programmer) or school, | |
664 | if any, to sign a "copyright disclaimer" for the program, if necessary. | |
665 | For more information on this, and how to apply and follow the GNU GPL, see | |
666 | <https://www.gnu.org/licenses/>. | |
667 | ||
668 | The GNU General Public License does not permit incorporating your program | |
669 | into proprietary programs. If your program is a subroutine library, you | |
670 | may consider it more useful to permit linking proprietary applications with | |
671 | the library. If this is what you want to do, use the GNU Lesser General | |
672 | Public License instead of this License. But first, please read | |
673 | <https://www.gnu.org/licenses/why-not-lgpl.html>. |
0 | 1.4.6 [May 14th, 2021]: | |
1 | --- | |
2 | * [FIX] add hostnames if host is already cached | |
3 | * Add Naabu plugin | |
4 | * Add Sonarqube plugin | |
5 | * Add version and change list_plugins style | |
6 | * [FIX] unused import, innecesary list compression and unused variables | |
7 | * [FIX] metasploit report when the web-site-id is null | |
8 | * [FIX] port stats in nmap | |
9 | * [FIX] ssylze | |
10 | sacar unknown de version= | |
11 | * ADD remedy into resolution | |
12 | * Support for nuclei 2.3.0 | |
13 | * ADD cve, cvss3_base_score, cvss3_vector, exploit_available when import nessus and change the structure of external_id to NESSUS-XXX | |
14 | * ADD more data like attack, params, uri, method, WASC, CWE and format externail_id | |
15 | ||
0 | 16 | 1.4.5 [Apr 15th, 2021]: |
1 | 17 | --- |
2 | 18 | * Add Bandit plugin |
0 | faraday-plugins (1.4.6-0kali1) UNRELEASED; urgency=low | |
1 | ||
2 | * New upstream release. | |
3 | ||
4 | -- Kali Janitor <[email protected]> Fri, 04 Jun 2021 05:48:11 -0000 | |
5 | ||
0 | 6 | faraday-plugins (1.4.5-0kali1) kali-dev; urgency=medium |
1 | 7 | |
2 | 8 | * New upstream version 1.4.5 |
0 | import getpass | |
0 | 1 | import io |
2 | import json | |
1 | 3 | import logging |
2 | 4 | import os |
5 | import shlex | |
6 | import subprocess | |
3 | 7 | import sys |
4 | import json | |
8 | ||
5 | 9 | import click |
6 | import subprocess | |
7 | import shlex | |
8 | import getpass | |
10 | from tabulate import tabulate | |
9 | 11 | |
12 | from faraday_plugins import __version__ | |
10 | 13 | from faraday_plugins.plugins.manager import PluginsManager, ReportAnalyzer, CommandAnalyzer |
11 | 14 | from faraday_plugins.plugins.plugin import PluginByExtension |
12 | 15 | |
20 | 23 | root_logger.addHandler(out_hdlr) |
21 | 24 | root_logger.setLevel(logging.DEBUG) |
22 | 25 | |
26 | CONTEXT_SETTINGS = dict(help_option_names=['-h', '--help']) | |
23 | 27 | |
24 | @click.group() | |
28 | @click.group(context_settings=CONTEXT_SETTINGS) | |
29 | @click.version_option(__version__, '-v', '--version') | |
25 | 30 | def cli(): |
26 | 31 | pass |
27 | 32 | |
30 | 35 | @click.option('-cpf', '--custom-plugins-folder', type=str) |
31 | 36 | def list_plugins(custom_plugins_folder): |
32 | 37 | plugins_manager = PluginsManager(custom_plugins_folder) |
33 | click.echo(click.style("Available Plugins:", fg="cyan")) | |
38 | click.echo(click.style(f"Faraday Plugins v{__version__}", fg="cyan")) | |
39 | click.echo(click.style("Available Plugins :", fg="cyan")) | |
34 | 40 | loaded_plugins = 0 |
41 | plugins_data = [] | |
35 | 42 | for plugin_id, plugin in plugins_manager.get_plugins(): |
36 | 43 | console_enabled = plugin._command_regex is not None |
37 | 44 | console_enabled_color = "green" if console_enabled else "red" |
39 | 46 | report_enabled = isinstance(plugin, PluginByExtension) |
40 | 47 | report_enabled_color = "green" if report_enabled else "red" |
41 | 48 | report_enabled_text = click.style(f"{'Yes' if report_enabled else 'No'}", fg=report_enabled_color) |
42 | click.echo(f"{plugin.id:15} - [Command: {console_enabled_text:>12} - Report: {report_enabled_text:>12}] - {plugin.name} ") | |
43 | ||
44 | loaded_plugins += 1 | |
45 | click.echo(click.style(f"Loaded Plugins: {loaded_plugins}", fg="cyan")) | |
49 | plugins_data.append({"Name": plugin.name, "ID": plugin.id, "Command": console_enabled_text, | |
50 | "Report": report_enabled_text}) | |
51 | click.echo(tabulate( | |
52 | plugins_data, | |
53 | headers="keys", | |
54 | tablefmt="simple", | |
55 | )) | |
56 | click.echo(click.style(f"Loaded Plugins: {len(plugins_data)}", fg="cyan")) | |
46 | 57 | |
47 | 58 | |
48 | 59 | @cli.command() |
0 | import csv | |
1 | import json | |
0 | 2 | import logging |
3 | import os | |
4 | import pkgutil | |
5 | import re | |
6 | import sys | |
1 | 7 | import traceback |
2 | import re | |
3 | import os | |
4 | import sys | |
5 | import json | |
6 | import pkgutil | |
8 | import xml.etree.ElementTree as ET | |
7 | 9 | import zipfile |
8 | 10 | from importlib import import_module |
9 | 11 | from importlib.machinery import SourceFileLoader |
10 | import csv | |
11 | 12 | from io import StringIO |
12 | 13 | |
13 | 14 | from . import repo |
14 | 15 | |
15 | 16 | logger = logging.getLogger("faraday").getChild(__name__) |
16 | ||
17 | try: | |
18 | import xml.etree.cElementTree as ET | |
19 | except ImportError: | |
20 | logger.warning("cElementTree could not be imported. Using ElementTree instead") | |
21 | import xml.etree.ElementTree as ET | |
22 | 17 | |
23 | 18 | |
24 | 19 | class ReportAnalyzer: |
34 | 29 | else: |
35 | 30 | file_name = os.path.basename(report_path) |
36 | 31 | plugin = self._get_plugin_by_name(file_name) |
37 | if not plugin: # Was unable to detect plugin from report file name | |
32 | if not plugin: # Was unable to detect plugin from report file name | |
38 | 33 | logger.debug("Plugin by name not found") |
39 | 34 | plugin = self._get_plugin_by_file_type(report_path) |
40 | 35 | if not plugin: |
67 | 62 | file_name_base, file_extension = os.path.splitext(file_name) |
68 | 63 | file_extension = file_extension.lower() |
69 | 64 | main_tag = None |
70 | file_json_keys = {} | |
71 | 65 | file_csv_headers = set() |
72 | 66 | file_json_keys = set() |
73 | 67 | files_in_zip = set() |
150 | 144 | |
151 | 145 | class PluginsManager: |
152 | 146 | |
153 | def __init__(self, custom_plugins_folder=None, ignore_info = False): | |
147 | def __init__(self, custom_plugins_folder=None, ignore_info=False): | |
154 | 148 | self.ignore_info = ignore_info |
155 | 149 | self.plugins = {} |
156 | 150 | self.plugin_modules = {} |
3 | 3 | See the file 'doc/LICENSE' for the license information |
4 | 4 | |
5 | 5 | """ |
6 | import hashlib | |
7 | import logging | |
6 | 8 | import os |
9 | import re | |
7 | 10 | import shutil |
8 | 11 | import tempfile |
9 | ||
12 | import uuid | |
13 | import zipfile | |
10 | 14 | from collections import defaultdict |
15 | from datetime import datetime | |
11 | 16 | |
12 | 17 | import pytz |
13 | import re | |
14 | import uuid | |
15 | import logging | |
16 | 18 | import simplejson as json |
17 | import zipfile | |
18 | from datetime import datetime | |
19 | import hashlib | |
20 | ||
21 | 19 | |
22 | 20 | logger = logging.getLogger("faraday").getChild(__name__) |
23 | 21 | |
24 | 22 | VALID_SERVICE_STATUS = ("open", "closed", "filtered") |
25 | 23 | VULN_SKIP_FIELDS_TO_HASH = ['run_date'] |
24 | ||
26 | 25 | |
27 | 26 | class PluginBase: |
28 | 27 | # TODO: Add class generic identifier |
40 | 39 | self.name = None |
41 | 40 | self.description = "" |
42 | 41 | self._command_regex = None |
42 | self.command = None | |
43 | 43 | self._output_file_path = None |
44 | 44 | self._use_temp_file = False |
45 | 45 | self._delete_temp_file = False |
101 | 101 | if severity[0:3] in sev: |
102 | 102 | return sev |
103 | 103 | return severity |
104 | ||
104 | 105 | severity = align_string_based_vulns(severity) |
105 | 106 | # Transform numeric severity into desc severity |
106 | 107 | numeric_severities = {"0": "info", |
124 | 125 | self._hosts_cache[cache_id] = obj_uuid |
125 | 126 | else: |
126 | 127 | obj_uuid = self._hosts_cache[cache_id] |
128 | if host['hostnames']: | |
129 | chached_host = self.get_from_cache(obj_uuid) | |
130 | chached_host['hostnames'] = list(set(chached_host['hostnames'] + host['hostnames'])) | |
127 | 131 | return obj_uuid |
128 | 132 | |
129 | 133 | def save_service_cache(self, host_id, service): |
169 | 173 | def _get_dict_hash(d, keys): |
170 | 174 | return hash(frozenset(map(lambda x: (x, d.get(x, None)), keys))) |
171 | 175 | |
172 | ||
173 | 176 | @classmethod |
174 | 177 | def get_host_cache_id(cls, host): |
175 | 178 | cache_id = cls._get_dict_hash(host, ['ip']) |
186 | 189 | def get_service_vuln_cache_id(cls, host_id, service_id, vuln): |
187 | 190 | vuln_copy = vuln.copy() |
188 | 191 | vuln_copy.update({"host_cache_id": host_id, "service_cache_id": service_id}) |
189 | cache_id = cls._get_dict_hash(vuln_copy, ['host_cache_id', 'service_cache_id', 'name', 'desc', 'website', 'path', 'pname', 'method']) | |
192 | cache_id = cls._get_dict_hash(vuln_copy, | |
193 | ['host_cache_id', 'service_cache_id', 'name', 'desc', 'website', 'path', 'pname', | |
194 | 'method']) | |
190 | 195 | return cache_id |
191 | 196 | |
192 | 197 | @classmethod |
193 | 198 | def get_host_vuln_cache_id(cls, host_id, vuln): |
194 | 199 | vuln_copy = vuln.copy() |
195 | 200 | vuln_copy.update({"host_cache_id": host_id}) |
196 | cache_id = cls._get_dict_hash(vuln_copy, ['host_cache_id', 'name', 'desc', 'website', 'path', 'pname', 'method']) | |
201 | cache_id = cls._get_dict_hash(vuln_copy, | |
202 | ['host_cache_id', 'name', 'desc', 'website', 'path', 'pname', 'method']) | |
197 | 203 | return cache_id |
198 | 204 | |
199 | 205 | def save_cache(self, obj): |
227 | 233 | for param, (param_type, value) in self._settings.items(): |
228 | 234 | yield param, value |
229 | 235 | |
230 | def get_ws(self): # TODO Borrar | |
236 | def get_ws(self): # TODO Borrar | |
231 | 237 | return "" |
232 | 238 | |
233 | 239 | def getSetting(self, name): |
248 | 254 | This method can be overriden in the plugin implementation |
249 | 255 | if a different kind of check is needed |
250 | 256 | """ |
251 | return (self._command_regex is not None and | |
252 | self._command_regex.match(current_input.strip()) is not None) | |
257 | if (self._command_regex is not None and | |
258 | self._command_regex.match(current_input.strip()) is not None): | |
259 | self.command = self.get_command(current_input) | |
260 | return True | |
261 | ||
262 | def get_command(self, current_input: str) -> str: | |
263 | command = self._command_regex.findall(current_input)[0] | |
264 | if isinstance(command, tuple): | |
265 | return "".join(command).strip() | |
266 | ||
267 | return command.strip() | |
253 | 268 | |
254 | 269 | def processCommandString(self, username, current_path, command_string): |
255 | 270 | """ |
333 | 348 | tags = [] |
334 | 349 | if isinstance(tags, str): |
335 | 350 | tags = [tags] |
336 | host = {"ip": name, "os": os, "hostnames": hostnames, "description": description, "mac": mac, | |
351 | host = {"ip": name, "os": os, "hostnames": hostnames, "description": description, "mac": mac, | |
337 | 352 | "credentials": [], "services": [], "vulnerabilities": [], "tags": tags} |
338 | 353 | host_id = self.save_host_cache(host) |
339 | 354 | return host_id |
340 | 355 | |
341 | 356 | def createAndAddServiceToHost(self, host_id, name, |
342 | protocol="tcp", ports=None, | |
343 | status="open", version="unknown", | |
344 | description="", tags=None): | |
357 | protocol="tcp", ports=None, | |
358 | status="open", version="", | |
359 | description="", tags=None): | |
345 | 360 | if ports: |
346 | 361 | if isinstance(ports, list): |
347 | 362 | ports = int(ports[0]) |
411 | 426 | tags = [tags] |
412 | 427 | vulnerability = {"name": name, "desc": desc, "severity": self.normalize_severity(severity), "refs": ref, |
413 | 428 | "external_id": external_id, "type": "Vulnerability", "resolution": resolution, "data": data, |
414 | "custom_fields": custom_fields, "status": status, "impact": impact, "policyviolations": policyviolations, | |
429 | "custom_fields": custom_fields, "status": status, "impact": impact, | |
430 | "policyviolations": policyviolations, | |
415 | 431 | "easeofresolution": easeofresolution, "confirmed": confirmed, "tags": tags |
416 | 432 | } |
417 | 433 | if run_date: |
425 | 441 | response="", method="", pname="", |
426 | 442 | params="", query="", category="", data="", external_id=None, |
427 | 443 | confirmed=False, status="", easeofresolution=None, impact=None, |
428 | policyviolations=None, status_code=None, custom_fields=None, run_date=None, tags=None): | |
444 | policyviolations=None, status_code=None, custom_fields=None, run_date=None, | |
445 | tags=None): | |
429 | 446 | if params is None: |
430 | 447 | params = "" |
431 | 448 | if response is None: |
475 | 492 | def createAndAddNoteToHost(self, host_id, name, text): |
476 | 493 | return None |
477 | 494 | |
478 | ||
479 | 495 | def createAndAddNoteToService(self, host_id, service_id, name, text): |
480 | 496 | return None |
481 | 497 | |
491 | 507 | |
492 | 508 | def get_data(self): |
493 | 509 | self.vulns_data["command"]["tool"] = self.id |
494 | self.vulns_data["command"]["command"] = self.id | |
510 | self.vulns_data["command"]["command"] = self.command if self.command else self.id | |
495 | 511 | self.vulns_data["command"]["duration"] = (datetime.now() - self.start_date).microseconds |
496 | 512 | return self.vulns_data |
497 | 513 | |
528 | 544 | summary['vuln_hashes'].append(dict_hash) |
529 | 545 | return summary |
530 | 546 | |
547 | ||
531 | 548 | # TODO Borrar |
532 | 549 | class PluginTerminalOutput(PluginBase): |
533 | 550 | def __init__(self): |
666 | 683 | match = bool(self.files_list & files_in_zip) |
667 | 684 | self.logger.debug("Files List Match: [%s =/in %s] -> %s", files_in_zip, self.files_list, match) |
668 | 685 | return match |
669 | ||
670 |
3 | 3 | See the file 'doc/LICENSE' for the license information |
4 | 4 | |
5 | 5 | """ |
6 | import logging | |
6 | 7 | import os |
7 | import logging | |
8 | 8 | import socket |
9 | from collections import defaultdict | |
10 | ||
11 | 9 | from urllib.parse import urlsplit |
12 | ||
13 | 10 | |
14 | 11 | SERVICE_MAPPER = None |
15 | 12 | |
23 | 20 | "website": "{}://{}".format(parse.scheme, parse.netloc), |
24 | 21 | "path": parse.path, |
25 | 22 | "query": parse.query |
26 | } | |
23 | } | |
24 | ||
27 | 25 | |
28 | 26 | def filter_services(): |
29 | 27 | global SERVICE_MAPPER |
110 | 108 | else: |
111 | 109 | return ip_address |
112 | 110 | |
111 | ||
113 | 112 | def get_severity_from_cvss(cvss): |
114 | 113 | try: |
115 | 114 | if type(cvss) != float: |
116 | 115 | cvss = float(cvss) |
117 | ||
118 | cvss_ranges = [(0.0, 0.1, 'info'), | |
119 | (0.1, 4.0, 'low'), | |
120 | (4.0, 7.0, 'med'), | |
121 | (7.0, 9.0, 'high'), | |
122 | (9.0, 10.1, 'critical')] | |
116 | ||
117 | cvss_ranges = [(0.0, 0.1, 'info'), | |
118 | (0.1, 4.0, 'low'), | |
119 | (4.0, 7.0, 'med'), | |
120 | (7.0, 9.0, 'high'), | |
121 | (9.0, 10.1, 'critical')] | |
123 | 122 | for (lower, upper, severity) in cvss_ranges: |
124 | 123 | if lower <= cvss < upper: |
125 | 124 | return severity |
126 | 125 | except ValueError: |
127 | 126 | return 'unclassified' |
128 |
4 | 4 | |
5 | 5 | """ |
6 | 6 | from urllib.parse import urlsplit |
7 | import re | |
8 | import os | |
9 | 7 | |
10 | 8 | from lxml import etree |
11 | ||
12 | try: | |
13 | import xml.etree.cElementTree as ET | |
14 | import xml.etree.ElementTree as ET_ORIG | |
15 | ETREE_VERSION = ET_ORIG.VERSION | |
16 | except ImportError: | |
17 | import xml.etree.ElementTree as ET | |
18 | ETREE_VERSION = ET.VERSION | |
19 | 9 | |
20 | 10 | from faraday_plugins.plugins.plugin import PluginXMLFormat |
21 | 11 | from faraday_plugins.plugins.plugins_utils import resolve_hostname |
22 | ||
23 | ETREE_VERSION = [int(i) for i in ETREE_VERSION.split(".")] | |
24 | ||
25 | 12 | |
26 | 13 | __author__ = "Francisco Amato" |
27 | 14 | __copyright__ = "Copyright (c) 2013, Infobyte LLC" |
52 | 39 | else: |
53 | 40 | self.sites = [] |
54 | 41 | |
55 | def parse_xml(self, xml_output): | |
42 | @staticmethod | |
43 | def parse_xml(xml_output): | |
56 | 44 | """ |
57 | 45 | Open and parse an xml file. |
58 | 46 | |
70 | 58 | |
71 | 59 | return tree |
72 | 60 | |
73 | def get_items(self, tree): | |
61 | @staticmethod | |
62 | def get_items(tree): | |
74 | 63 | """ |
75 | 64 | @return items A list of Host instances |
76 | 65 | """ |
85 | 74 | |
86 | 75 | @return An attribute value |
87 | 76 | """ |
88 | global ETREE_VERSION | |
89 | node = None | |
90 | ||
91 | if ETREE_VERSION[0] <= 1 and ETREE_VERSION[1] < 3: | |
92 | ||
93 | match_obj = re.search("([^\@]+?)\[\@([^=]*?)=\'([^\']*?)\'", subnode_xpath_expr) | |
94 | ||
95 | if match_obj is not None: | |
96 | node_to_find = match_obj.group(1) | |
97 | xpath_attrib = match_obj.group(2) | |
98 | xpath_value = match_obj.group(3) | |
99 | for node_found in xml_node.findall(node_to_find): | |
100 | if node_found.attrib[xpath_attrib] == xpath_value: | |
101 | node = node_found | |
102 | break | |
103 | else: | |
104 | node = xml_node.find(subnode_xpath_expr) | |
105 | ||
106 | else: | |
107 | node = xml_node.find(subnode_xpath_expr) | |
77 | ||
78 | node = xml_node.find(subnode_xpath_expr) | |
108 | 79 | |
109 | 80 | if node is not None: |
110 | 81 | return node.get(attrib_name) |
286 | 257 | ref=item.ref) |
287 | 258 | del parser |
288 | 259 | |
289 | def setHost(self): | |
290 | pass | |
291 | ||
292 | 260 | |
293 | 261 | def createPlugin(ignore_info=False): |
294 | return AcunetixPlugin(ignore_info=ignore_info)⏎ | |
262 | return AcunetixPlugin(ignore_info=ignore_info) |
3 | 3 | See the file 'doc/LICENSE' for the license information |
4 | 4 | """ |
5 | 5 | import argparse |
6 | import random | |
6 | import re | |
7 | 7 | import shlex |
8 | import tempfile | |
8 | import socket | |
9 | 9 | |
10 | 10 | from faraday_plugins.plugins.plugin import PluginBase |
11 | import socket | |
12 | import re | |
13 | import os | |
14 | ||
15 | from faraday_plugins.plugins.plugins_utils import resolve_hostname | |
16 | ||
17 | 11 | |
18 | 12 | |
19 | 13 | class AmapPlugin(PluginBase): |
30 | 24 | self._command_regex = re.compile(r'^(amap|sudo amap)\s+.*?') |
31 | 25 | self._use_temp_file = True |
32 | 26 | self._hosts = [] |
27 | self.args = None | |
33 | 28 | |
34 | 29 | def parseOutputString(self, output): |
35 | 30 | services = {} |
106 | 101 | |
107 | 102 | return ip6[0][4][0] |
108 | 103 | |
109 | def setHost(self): | |
110 | pass | |
111 | ||
112 | 104 | def processCommandString(self, username, current_path, command_string): |
113 | 105 | """ |
114 | 106 | Adds the -m parameter to get machine readable output. |
135 | 127 | cmd.remove("-6") |
136 | 128 | cmd.insert(1, "-6") |
137 | 129 | |
138 | args = None | |
139 | 130 | if len(cmd) > 4: |
140 | 131 | try: |
141 | args, unknown = parser.parse_known_args(cmd) | |
132 | self.args, unknown = parser.parse_known_args(cmd) | |
142 | 133 | except SystemExit: |
143 | 134 | pass |
144 | 135 | |
145 | self.args = args | |
146 | 136 | return final |
147 | 137 | |
148 | 138 | |
149 | 139 | def createPlugin(ignore_info=False): |
150 | 140 | return AmapPlugin(ignore_info=ignore_info) |
151 | ||
152 |
0 | from urllib.parse import urlparse | |
1 | ||
0 | 2 | from faraday_plugins.plugins.plugin import PluginXMLFormat |
1 | 3 | from faraday_plugins.plugins.plugins_utils import resolve_hostname |
2 | import dateutil.parser | |
3 | from urllib.parse import urlparse | |
4 | try: | |
5 | import xml.etree.cElementTree as ET | |
6 | except ImportError: | |
7 | import xml.etree.ElementTree as ET | |
8 | ||
4 | ||
5 | import xml.etree.ElementTree as ET | |
9 | 6 | |
10 | 7 | __author__ = "Nicolas Rebagliati" |
11 | 8 | __copyright__ = "Copyright (c) 2021, Infobyte LLC" |
32 | 29 | self.entities = self.get_entity_groups(tree.find('entity-group')) |
33 | 30 | self.issues = self.get_dast_issues(tree.find("issue-group")) |
34 | 31 | |
35 | ||
36 | ||
37 | def parse_xml(self, xml_output): | |
32 | @staticmethod | |
33 | def parse_xml(xml_output): | |
38 | 34 | try: |
39 | 35 | tree = ET.fromstring(xml_output) |
40 | 36 | except SyntaxError as err: |
42 | 38 | return None |
43 | 39 | return tree |
44 | 40 | |
45 | def get_fixes(self, tree): | |
41 | @staticmethod | |
42 | def get_fixes(tree): | |
46 | 43 | fixes = {} |
47 | 44 | for item in tree: |
48 | 45 | fix_id = item.attrib['id'] |
51 | 48 | fixes[fix_id] = {"library": library, "location": location} |
52 | 49 | return fixes |
53 | 50 | |
54 | def get_issue_types(self, tree): | |
51 | @staticmethod | |
52 | def get_issue_types(tree): | |
55 | 53 | issue_types = {} |
56 | 54 | for item in tree: |
57 | 55 | type_id = item.attrib['id'] |
59 | 57 | issue_types[type_id] = name |
60 | 58 | return issue_types |
61 | 59 | |
62 | def get_remediations(self, tree): | |
60 | @staticmethod | |
61 | def get_remediations(tree): | |
63 | 62 | remediations = {} |
64 | 63 | for item in tree: |
65 | 64 | remediation_id = item.attrib['id'] |
67 | 66 | remediations[remediation_id] = name |
68 | 67 | return remediations |
69 | 68 | |
70 | def get_hosts(self, tree): | |
69 | @staticmethod | |
70 | def get_hosts(tree): | |
71 | 71 | hosts = {} |
72 | 72 | for item in tree: |
73 | 73 | host = item.find("host").text |
83 | 83 | "service_name": service_name} |
84 | 84 | return hosts |
85 | 85 | |
86 | def get_entity_groups(self, tree): | |
86 | @staticmethod | |
87 | def get_entity_groups(tree): | |
87 | 88 | entity_groups = {} |
88 | 89 | for item in tree: |
89 | 90 | entity_id = item.attrib['id'] |
237 | 238 | return sast_issues |
238 | 239 | |
239 | 240 | |
240 | ||
241 | 241 | class AppScanPlugin(PluginXMLFormat): |
242 | 242 | |
243 | 243 | def __init__(self, *arg, **kwargs): |
249 | 249 | self.version = '1.0.0' |
250 | 250 | self.framework_version = '1.0.0' |
251 | 251 | |
252 | ||
253 | 252 | def parseOutputString(self, output): |
254 | 253 | parser = AppScanParser(output) |
255 | 254 | scan_type = parser.scan_type |
256 | ||
257 | 255 | |
258 | 256 | if scan_type == 'DAST': |
259 | 257 | for issue in parser.issues: |
260 | 258 | host = issue.pop("host") |
261 | 259 | port = issue.pop("port") |
262 | host_os = issue.pop("os") | |
263 | 260 | service_name = issue.pop("service_name") |
264 | 261 | ip = resolve_hostname(host) |
265 | host_id = self.createAndAddHost(ip, hostnames=host) | |
262 | host_os = issue.pop("os") | |
263 | host_id = self.createAndAddHost(ip, hostnames=host, os=host_os) | |
266 | 264 | service_id = self.createAndAddServiceToHost(host_id, service_name, ports=port) |
267 | 265 | self.createAndAddVulnWebToService(host_id=host_id, service_id=service_id, **issue) |
268 | 266 |
4 | 4 | Copyright (C) 2016 Infobyte LLC (http://www.infobytesec.com/) |
5 | 5 | See the file 'doc/LICENSE' for the license information |
6 | 6 | """ |
7 | import xml.etree.ElementTree as ET | |
8 | from datetime import datetime | |
9 | ||
7 | 10 | from faraday_plugins.plugins.plugin import PluginXMLFormat |
8 | from datetime import datetime | |
9 | try: | |
10 | import xml.etree.cElementTree as ET | |
11 | except ImportError: | |
12 | import xml.etree.ElementTree as ET | |
13 | 11 | |
14 | 12 | __author__ = 'Blas Moyano' |
15 | 13 | __copyright__ = 'Copyright 2020, Faraday Project' |
24 | 22 | self.tree = self.parse_xml(xml_output) |
25 | 23 | if self.tree: |
26 | 24 | self.vuln_list = self.tree.find('VulnList') |
27 | self.name_scan = self.tree.find('ScanName').text | |
25 | self.name_scan = self.tree.findtext('ScanName') | |
28 | 26 | else: |
29 | 27 | self.tree = None |
30 | 28 | |
31 | def parse_xml(self, xml_output): | |
29 | @staticmethod | |
30 | def parse_xml(xml_output): | |
32 | 31 | try: |
33 | 32 | tree = ET.fromstring(xml_output) |
34 | 33 | except SyntaxError as err: |
71 | 70 | data_info = [] |
72 | 71 | |
73 | 72 | for vulns in parser.vuln_list: |
74 | vuln_name = vulns.find('VulnType').text | |
75 | vuln_desc = vulns.find('Description').text | |
76 | vuln_ref = vulns.find('VulnUrl').text | |
77 | severity = vulns.find('AttackScore').text | |
78 | vuln_resolution = vulns.find('Recommendation').text | |
79 | vuln_external_id = vulns.find('DbId').text | |
80 | vuln_run_date = vulns.find('ScanDate').text | |
81 | data_info.append(vulns.find('AttackClass').text) | |
82 | data_info.append(vulns.find('CweId').text) | |
83 | data_info.append(vulns.find('CAPEC').text) | |
84 | data_info.append(vulns.find('DISSA_ASC').text) | |
85 | data_info.append(vulns.find('OWASP2007').text) | |
86 | data_info.append(vulns.find('OWASP2010').text) | |
87 | data_info.append(vulns.find('OWASP2013').text) | |
88 | data_info.append(vulns.find('OVAL').text) | |
89 | data_info.append(vulns.find('WASC').text) | |
73 | vuln_name = vulns.findtext('VulnType') | |
74 | vuln_desc = vulns.findtext('Description') | |
75 | vuln_ref = vulns.findtext('VulnUrl') | |
76 | severity = vulns.findtext('AttackScore') | |
77 | vuln_resolution = vulns.findtext('Recommendation') | |
78 | vuln_external_id = vulns.findtext('DbId') | |
79 | vuln_run_date = vulns.findtext('ScanDate') | |
80 | data_info.append(vulns.findtext('AttackClass')) | |
81 | data_info.append(vulns.findtext('CweId')) | |
82 | data_info.append(vulns.findtext('CAPEC')) | |
83 | data_info.append(vulns.findtext('DISSA_ASC')) | |
84 | data_info.append(vulns.findtext('OWASP2007')) | |
85 | data_info.append(vulns.findtext('OWASP2010')) | |
86 | data_info.append(vulns.findtext('OWASP2013')) | |
87 | data_info.append(vulns.findtext('OVAL')) | |
88 | data_info.append(vulns.findtext('WASC')) | |
90 | 89 | |
91 | 90 | if severity == '1-Informational': |
92 | 91 | severity = 0 |
2 | 2 | Copyright (C) 2016 Infobyte LLC (http://www.infobytesec.com/) |
3 | 3 | See the file 'doc/LICENSE' for the license information |
4 | 4 | """ |
5 | import os | |
5 | 6 | import re |
7 | import xml.etree.ElementTree as ET | |
6 | 8 | from urllib.parse import urlparse |
7 | import os | |
9 | ||
8 | 10 | from faraday_plugins.plugins.plugin import PluginXMLFormat |
9 | 11 | from faraday_plugins.plugins.plugins_utils import resolve_hostname |
10 | ||
11 | try: | |
12 | import xml.etree.cElementTree as ET | |
13 | except ImportError: | |
14 | import xml.etree.ElementTree as ET | |
15 | 12 | |
16 | 13 | __author__ = 'Ezequiel Tavella' |
17 | 14 | __copyright__ = 'Copyright 2016, Faraday Project' |
199 | 196 | else: |
200 | 197 | options_string = None |
201 | 198 | |
202 | ||
203 | 199 | try: |
204 | 200 | self.user_agent = self.node.find('user_agent').text |
205 | 201 | except: |
230 | 226 | |
231 | 227 | def getNote(self): |
232 | 228 | result = ('Scan url:\n {} \nUser Agent:\n {} \nVersion Arachni:\n {} \nStart time:\n {} \nFinish time:\n {}' |
233 | '\nAudited Elements:\n {} \nModules:\n {} \nCookies:\n {}').format(self.url, self.user_agent, | |
234 | self.version, self.start_time, | |
235 | self.finish_time, | |
236 | self.audited_elements, | |
237 | self.modules, self.cookies) | |
229 | '\nAudited Elements:\n {} \nModules:\n {} \nCookies:\n {}').format(self.url, self.user_agent, | |
230 | self.version, self.start_time, | |
231 | self.finish_time, | |
232 | self.audited_elements, | |
233 | self.modules, self.cookies) | |
238 | 234 | |
239 | 235 | return result |
240 | 236 | |
241 | 237 | |
242 | 238 | class Plugins(): |
243 | ||
244 | 239 | """ |
245 | 240 | Support: |
246 | 241 | WAF (Web Application Firewall) Detector (waf_detector) |
492 | 487 | |
493 | 488 | def createPlugin(ignore_info=False): |
494 | 489 | return ArachniPlugin(ignore_info=ignore_info) |
495 | ||
496 |
94 | 94 | severity=3) |
95 | 95 | |
96 | 96 | |
97 | def setHost(self): | |
98 | pass | |
99 | ||
100 | 97 | |
101 | 98 | def createPlugin(ignore_info=False): |
102 | 99 | return BeefPlugin(ignore_info=ignore_info) |
3 | 3 | See the file 'doc/LICENSE' for the license information |
4 | 4 | |
5 | 5 | """ |
6 | import re | |
7 | import os | |
8 | 6 | import base64 |
7 | import distutils.util # pylint: disable=import-error | |
8 | import xml.etree.ElementTree as ET | |
9 | from urllib.parse import urlsplit | |
10 | ||
9 | 11 | from bs4 import BeautifulSoup, Comment |
12 | ||
10 | 13 | from faraday_plugins.plugins.plugin import PluginXMLFormat |
11 | from urllib.parse import urlsplit | |
12 | import distutils.util #pylint: disable=import-error | |
13 | ||
14 | ||
15 | try: | |
16 | import xml.etree.cElementTree as ET | |
17 | import xml.etree.ElementTree as ET_ORIG | |
18 | ETREE_VERSION = ET_ORIG.VERSION | |
19 | except ImportError: | |
20 | import xml.etree.ElementTree as ET | |
21 | ETREE_VERSION = ET.VERSION | |
22 | ||
23 | ETREE_VERSION = [int(i) for i in ETREE_VERSION.split(".")] | |
24 | ||
25 | 14 | |
26 | 15 | __author__ = "Francisco Amato" |
27 | 16 | __copyright__ = "Copyright (c) 2013, Infobyte LLC" |
77 | 66 | """ |
78 | 67 | @return items A list of Host instances |
79 | 68 | """ |
80 | bugtype = '' | |
81 | 69 | |
82 | 70 | for node in tree.findall('issue'): |
83 | 71 | yield Item(node) |
89 | 77 | |
90 | 78 | @return An attribute value |
91 | 79 | """ |
92 | global ETREE_VERSION | |
93 | node = None | |
94 | ||
95 | if ETREE_VERSION[0] <= 1 and ETREE_VERSION[1] < 3: | |
96 | ||
97 | match_obj = re.search( | |
98 | "([^\@]+?)\[\@([^=]*?)=\'([^\']*?)\'", subnode_xpath_expr) | |
99 | if match_obj is not None: | |
100 | ||
101 | node_to_find = match_obj.group(1) | |
102 | xpath_attrib = match_obj.group(2) | |
103 | xpath_value = match_obj.group(3) | |
104 | for node_found in xml_node.findall(node_to_find): | |
105 | if node_found.attrib[xpath_attrib] == xpath_value: | |
106 | node = node_found | |
107 | break | |
108 | else: | |
109 | node = xml_node.find(subnode_xpath_expr) | |
110 | ||
111 | else: | |
112 | node = xml_node.find(subnode_xpath_expr) | |
80 | node = xml_node.find(subnode_xpath_expr) | |
113 | 81 | |
114 | 82 | if node is not None: |
115 | 83 | return node.get(attrib_name) |
164 | 132 | self.background = background |
165 | 133 | self.external_id = external_id.text |
166 | 134 | |
167 | ||
168 | def do_clean(self, value): | |
135 | @staticmethod | |
136 | def do_clean(value): | |
169 | 137 | |
170 | 138 | myreturn = "" |
171 | 139 | if value is not None: |
221 | 189 | self._current_output = None |
222 | 190 | self.target = None |
223 | 191 | |
224 | ||
225 | 192 | def parseOutputString(self, output): |
226 | 193 | |
227 | 194 | parser = BurpXmlParser(output) |
247 | 214 | data = self.removeHtml(data) |
248 | 215 | resolution = self.removeHtml(item.remediation) if item.remediation else "" |
249 | 216 | |
250 | v_id = self.createAndAddVulnWebToService( | |
217 | self.createAndAddVulnWebToService( | |
251 | 218 | h_id, |
252 | 219 | s_id, |
253 | 220 | item.name, |
263 | 230 | |
264 | 231 | del parser |
265 | 232 | |
266 | ||
267 | 233 | def removeHtml(self, markup): |
268 | 234 | soup = BeautifulSoup(markup, "html.parser") |
269 | 235 | |
291 | 257 | |
292 | 258 | return str(soup) |
293 | 259 | |
294 | def setHost(self): | |
295 | pass | |
296 | ||
297 | 260 | |
298 | 261 | def createPlugin(ignore_info=False): |
299 | 262 | return BurpPlugin(ignore_info=ignore_info) |
300 | ||
301 |
2 | 2 | Copyright (C) 2016 Infobyte LLC (http://www.infobytesec.com/) |
3 | 3 | See the file 'doc/LICENSE' for the license information |
4 | 4 | """ |
5 | import re | |
5 | import xml.etree.ElementTree as ET | |
6 | 6 | from urllib.parse import urlparse |
7 | 7 | |
8 | 8 | from faraday_plugins.plugins.plugin import PluginXMLFormat |
9 | ||
10 | ||
11 | try: | |
12 | import xml.etree.cElementTree as ET | |
13 | except ImportError: | |
14 | import xml.etree.ElementTree as ET | |
15 | 9 | |
16 | 10 | __author__ = 'Blas Moyano' |
17 | 11 | __copyright__ = 'Copyright 2020, Faraday Project' |
69 | 63 | for info_pn in pn: |
70 | 64 | if info_pn.tag == 'Snippet': |
71 | 65 | valor = ( |
72 | 'Number', info_pn.find('Line').find('Number').text, 'Code', info_pn.find('Line').find('Code').text) | |
66 | 'Number', info_pn.find('Line').find('Number').text, 'Code', | |
67 | info_pn.find('Line').find('Code').text) | |
73 | 68 | else: |
74 | 69 | valor = (info_pn.tag, info_pn.text) |
75 | 70 | lista_v.append(valor) |
88 | 83 | self.version = '1.0.0' |
89 | 84 | self.framework_version = '1.0.0' |
90 | 85 | self.options = None |
91 | ||
92 | 86 | |
93 | 87 | def parseOutputString(self, output): |
94 | 88 | parser = CheckmarxXmlParser(output) |
139 | 133 | |
140 | 134 | def createPlugin(ignore_info=False): |
141 | 135 | return CheckmarxPlugin(ignore_info=ignore_info) |
142 |
25 | 25 | self.plugin_version = "0.0.1" |
26 | 26 | self.version = "2.22" |
27 | 27 | self.regexpUrl = r'((http[s]?)\:\/\/([\w\.]+)[.\S]+)' |
28 | self._command_regex = re.compile(r'^(?:sudo dirb|dirb|\.\/dirb|sudo \.\/dirb)\s+(?:(http[s]?)' | |
29 | r'\:\/\/([\w\.]+)[.\S]+)') | |
28 | self._command_regex = re.compile(r'^(sudo dirb|dirb|\.\/dirb|sudo \.\/dirb)\s+.*?') | |
29 | ||
30 | 30 | self.text = [] |
31 | 31 | |
32 | 32 | def getPort(self, host, proto): |
58 | 58 | self.name = "dirsearch" |
59 | 59 | self.plugin_version = "0.0.1" |
60 | 60 | self.version = "0.0.1" |
61 | self._command_regex = re.compile(r'^(sudo )?(python[0-9\.]? )?dirsearch(\.py)\s+?') | |
61 | self._command_regex = re.compile(r'^(sudo )?(python[0-9\.]? )?(dirsearch\.py)\s+?') | |
62 | 62 | self.addSetting("Ignore 403", str, "1") |
63 | 63 | self._use_temp_file = True |
64 | 64 | self._temp_file_extension = "json" |
65 | 65 | |
66 | 66 | def parseOutputString(self, output): |
67 | 67 | self.parse_json(output) |
68 | ||
69 | 68 | |
70 | 69 | @property |
71 | 70 | def should_ignore_403(self): |
3 | 3 | See the file 'doc/LICENSE' for the license information |
4 | 4 | |
5 | 5 | """ |
6 | import re | |
7 | import xml.etree.ElementTree as ET | |
8 | ||
6 | 9 | from faraday_plugins.plugins.plugin import PluginBase |
7 | import re | |
8 | import os | |
9 | ||
10 | try: | |
11 | import xml.etree.cElementTree as ET | |
12 | import xml.etree.ElementTree as ET_ORIG | |
13 | ETREE_VERSION = ET_ORIG.VERSION | |
14 | except ImportError: | |
15 | import xml.etree.ElementTree as ET | |
16 | ETREE_VERSION = ET.VERSION | |
17 | ||
18 | ETREE_VERSION = [int(i) for i in ETREE_VERSION.split(".")] | |
19 | ||
20 | 10 | |
21 | 11 | __author__ = "Francisco Amato" |
22 | 12 | __copyright__ = "Copyright (c) 2013, Infobyte LLC" |
68 | 58 | """ |
69 | 59 | @return items A list of Host instances |
70 | 60 | """ |
71 | bugtype = '' | |
72 | 61 | |
73 | 62 | node = tree.findall('testdata')[0] |
74 | 63 | for hostnode in node.findall('host'): |
81 | 70 | |
82 | 71 | @return An attribute value |
83 | 72 | """ |
84 | global ETREE_VERSION | |
85 | node = None | |
86 | 73 | |
87 | if ETREE_VERSION[0] <= 1 and ETREE_VERSION[1] < 3: | |
88 | ||
89 | match_obj = re.search( | |
90 | "([^\@]+?)\[\@([^=]*?)=\'([^\']*?)\'", subnode_xpath_expr) | |
91 | if match_obj is not None: | |
92 | node_to_find = match_obj.group(1) | |
93 | xpath_attrib = match_obj.group(2) | |
94 | xpath_value = match_obj.group(3) | |
95 | for node_found in xml_node.findall(node_to_find): | |
96 | if node_found.attrib[xpath_attrib] == xpath_value: | |
97 | node = node_found | |
98 | break | |
99 | else: | |
100 | node = xml_node.find(subnode_xpath_expr) | |
101 | ||
102 | else: | |
103 | node = xml_node.find(subnode_xpath_expr) | |
74 | node = xml_node.find(subnode_xpath_expr) | |
104 | 75 | |
105 | 76 | if node is not None: |
106 | 77 | return node.get(attrib_name) |
175 | 146 | parser = DnsenumXmlParser(output) |
176 | 147 | |
177 | 148 | for item in parser.items: |
178 | h_id = self.createAndAddHost(item.ip, hostnames=[item.hostname]) | |
149 | self.createAndAddHost(item.ip, hostnames=[item.hostname]) | |
179 | 150 | |
180 | 151 | del parser |
181 | 152 | |
192 | 163 | else: |
193 | 164 | return re.sub(arg_match.group(1), r"-o %s" % self._output_file_path, command_string) |
194 | 165 | |
195 | def setHost(self): | |
196 | pass | |
197 | ||
198 | 166 | |
199 | 167 | def createPlugin(ignore_info=False): |
200 | 168 | return DnsenumPlugin(ignore_info=ignore_info) |
201 | ||
202 |
2 | 2 | Copyright (C) 2013 Infobyte LLC (http://www.infobytesec.com/) |
3 | 3 | See the file 'doc/LICENSE' for the license information |
4 | 4 | """ |
5 | from faraday_plugins.plugins.plugin import PluginBase | |
6 | 5 | import re |
7 | 6 | from collections import defaultdict |
8 | 7 | |
8 | from faraday_plugins.plugins.plugin import PluginBase | |
9 | 9 | |
10 | 10 | __author__ = "Francisco Amato" |
11 | 11 | __copyright__ = "Copyright (c) 2013, Infobyte LLC" |
103 | 103 | self._use_temp_file = True |
104 | 104 | self._temp_file_extension = "txt" |
105 | 105 | |
106 | ||
107 | 106 | def canParseCommandString(self, current_input): |
108 | 107 | if self._command_regex.match(current_input.strip()): |
108 | self.command = self.get_command(current_input) | |
109 | 109 | return True |
110 | 110 | else: |
111 | 111 | return False |
138 | 138 | |
139 | 139 | def createPlugin(ignore_info=False): |
140 | 140 | return DnsmapPlugin(ignore_info=ignore_info) |
141 | ||
142 |
2 | 2 | Copyright (C) 2013 Infobyte LLC (http://www.infobytesec.com/) |
3 | 3 | See the file 'doc/LICENSE' for the license information |
4 | 4 | """ |
5 | import re | |
6 | import xml.etree.ElementTree as ET | |
7 | ||
5 | 8 | from faraday_plugins.plugins.plugin import PluginBase |
6 | import re | |
7 | ||
8 | try: | |
9 | import xml.etree.cElementTree as ET | |
10 | import xml.etree.ElementTree as ET_ORIG | |
11 | ETREE_VERSION = ET_ORIG.VERSION | |
12 | except ImportError: | |
13 | import xml.etree.ElementTree as ET | |
14 | ETREE_VERSION = ET.VERSION | |
15 | ||
16 | ETREE_VERSION = [int(i) for i in ETREE_VERSION.split(".")] | |
17 | ||
18 | 9 | |
19 | 10 | __author__ = "Francisco Amato" |
20 | 11 | __copyright__ = "Copyright (c) 2013, Infobyte LLC" |
77 | 68 | |
78 | 69 | @return An attribute value |
79 | 70 | """ |
80 | global ETREE_VERSION | |
81 | node = None | |
82 | ||
83 | if ETREE_VERSION[0] <= 1 and ETREE_VERSION[1] < 3: | |
84 | ||
85 | match_obj = re.search( | |
86 | "([^\@]+?)\[\@([^=]*?)=\'([^\']*?)\'", subnode_xpath_expr) | |
87 | if match_obj is not None: | |
88 | ||
89 | node_to_find = match_obj.group(1) | |
90 | xpath_attrib = match_obj.group(2) | |
91 | xpath_value = match_obj.group(3) | |
92 | for node_found in xml_node.findall(node_to_find): | |
93 | if node_found.attrib[xpath_attrib] == xpath_value: | |
94 | node = node_found | |
95 | break | |
96 | else: | |
97 | node = xml_node.find(subnode_xpath_expr) | |
98 | ||
99 | else: | |
100 | node = xml_node.find(subnode_xpath_expr) | |
71 | ||
72 | node = xml_node.find(subnode_xpath_expr) | |
101 | 73 | |
102 | 74 | if node is not None: |
103 | 75 | return node.get(attrib_name) |
204 | 176 | status="open") |
205 | 177 | |
206 | 178 | if host.zonetransfer == "success": |
207 | v_id = self.createAndAddVulnToService( | |
179 | self.createAndAddVulnToService( | |
208 | 180 | h_id, |
209 | 181 | s_id, |
210 | 182 | name="Zone transfer", |
238 | 210 | r"--xml %s" % self._output_file_path, |
239 | 211 | command_string) |
240 | 212 | |
241 | def setHost(self): | |
242 | pass | |
243 | ||
244 | 213 | |
245 | 214 | def createPlugin(ignore_info=False): |
246 | 215 | return DnsreconPlugin(ignore_info=ignore_info) |
247 | ||
248 |
4 | 4 | |
5 | 5 | """ |
6 | 6 | import re |
7 | import os | |
8 | 7 | |
9 | 8 | from faraday_plugins.plugins.plugin import PluginBase |
10 | 9 | from faraday_plugins.plugins.plugins_utils import resolve_hostname |
11 | ||
12 | 10 | |
13 | 11 | __author__ = "Francisco Amato" |
14 | 12 | __copyright__ = "Copyright (c) 2013, Infobyte LLC" |
41 | 39 | for line in lists: |
42 | 40 | mregex = re.search("WARN: ([\w\.]+) ([\w]+) ([\w\.]+):", line) |
43 | 41 | if mregex is not None: |
44 | ||
45 | 42 | item = { |
46 | 43 | 'host': mregex.group(1), |
47 | 44 | 'ip': mregex.group(3), |
62 | 59 | self.items.append(item) |
63 | 60 | |
64 | 61 | |
65 | ||
66 | 62 | class DnswalkPlugin(PluginBase): |
67 | 63 | """ |
68 | 64 | Example plugin to parse dnswalk output. |
79 | 75 | self._command_regex = re.compile( |
80 | 76 | r'^(sudo dnswalk|dnswalk|\.\/dnswalk)\s+.*?') |
81 | 77 | |
82 | ||
83 | 78 | def canParseCommandString(self, current_input): |
84 | 79 | if self._command_regex.match(current_input.strip()): |
80 | self.command = self.get_command(current_input) | |
85 | 81 | return True |
86 | 82 | else: |
87 | 83 | return False |
114 | 110 | |
115 | 111 | def createPlugin(ignore_info=False): |
116 | 112 | return DnswalkPlugin(ignore_info=ignore_info) |
117 | ||
118 |
126 | 126 | else: |
127 | 127 | return False |
128 | 128 | |
129 | def setHost(self): | |
130 | pass | |
129 | ||
131 | 130 | |
132 | 131 | |
133 | 132 | def createPlugin(ignore_info=False): |
3 | 3 | See the file 'doc/LICENSE' for the license information |
4 | 4 | |
5 | 5 | """ |
6 | import re | |
6 | ||
7 | import xml.etree.ElementTree as ET | |
7 | 8 | |
8 | 9 | from faraday_plugins.plugins.plugin import PluginXMLFormat |
9 | try: | |
10 | import xml.etree.cElementTree as ET | |
11 | import xml.etree.ElementTree as ET_ORIG | |
12 | ETREE_VERSION = ET_ORIG.VERSION | |
13 | except ImportError: | |
14 | import xml.etree.ElementTree as ET | |
15 | ETREE_VERSION = ET.VERSION | |
16 | ||
17 | ETREE_VERSION = [int(i) for i in ETREE_VERSION.split(".")] | |
18 | ||
19 | 10 | |
20 | 11 | __author__ = "Francisco Amato" |
21 | 12 | __copyright__ = "Copyright (c) 2013, Infobyte LLC" |
41 | 32 | def __init__(self, xml_output): |
42 | 33 | tree = self.parse_xml(xml_output) |
43 | 34 | if tree: |
44 | self.items = [data for data in self.get_items(tree)] | |
35 | self.items = self.get_items(tree) | |
45 | 36 | else: |
46 | 37 | self.items = [] |
47 | 38 | |
103 | 94 | agentip = node.get('name').split("/")[1] |
104 | 95 | |
105 | 96 | if self.ip == agentip: |
106 | ||
107 | 97 | self.agentip = agentip |
108 | 98 | |
109 | 99 | self.ipfrom = self.get_text_from_subnode( |
227 | 217 | mapped_services = {} |
228 | 218 | mapped_ports = {} |
229 | 219 | for item in parser.items: |
230 | os_string = f"{item.os} {item.arch }" | |
220 | os_string = f"{item.os} {item.arch}" | |
231 | 221 | h_id = self.createAndAddHost(item.ip, os=os_string, hostnames=[item.host]) |
232 | 222 | |
233 | 223 | for service in item.services: |
281 | 271 | del parser |
282 | 272 | |
283 | 273 | |
284 | def setHost(self): | |
285 | pass | |
286 | ||
287 | ||
288 | 274 | def createPlugin(ignore_info=False): |
289 | 275 | return ImpactPlugin(ignore_info=ignore_info) |
290 | ||
291 |
4 | 4 | |
5 | 5 | """ |
6 | 6 | import os |
7 | ||
7 | 8 | from lxml import etree |
9 | ||
8 | 10 | from faraday_plugins.plugins.plugin import PluginXMLFormat |
9 | ||
10 | ||
11 | try: | |
12 | import xml.etree.cElementTree as ET | |
13 | import xml.etree.ElementTree as ET_ORIG | |
14 | ETREE_VERSION = ET_ORIG.VERSION | |
15 | except ImportError: | |
16 | import xml.etree.ElementTree as ET | |
17 | ETREE_VERSION = ET.VERSION | |
18 | ||
19 | ETREE_VERSION = [int(i) for i in ETREE_VERSION.split(".")] | |
20 | 11 | |
21 | 12 | current_path = os.path.abspath(os.getcwd()) |
22 | 13 | |
66 | 57 | self.items = [data for data in self.get_items(tree)] |
67 | 58 | else: |
68 | 59 | self.items = [] |
69 | ||
60 | ||
70 | 61 | def parse_xml(self, xml_output): |
71 | 62 | """ |
72 | 63 | Open and parse an xml file. |
132 | 123 | self._current_output = None |
133 | 124 | |
134 | 125 | def parseOutputString(self, output): |
135 | ||
136 | 126 | parser = JunitXmlParser(output) |
137 | 127 | for item in parser.items: |
138 | 128 | h_id = self.createAndAddHost(item.host, os="Linux") |
2 | 2 | Copyright (C) 2015 Infobyte LLC (http://www.infobytesec.com/) |
3 | 3 | See the file 'doc/LICENSE' for the license information |
4 | 4 | """ |
5 | import xml.etree.ElementTree as ET | |
6 | import zipfile | |
7 | ||
5 | 8 | from faraday_plugins.plugins.plugin import PluginZipFormat |
6 | import re | |
7 | import os | |
8 | import zipfile | |
9 | ||
10 | 9 | from faraday_plugins.plugins.plugins_utils import resolve_hostname |
11 | ||
12 | try: | |
13 | import xml.etree.cElementTree as ET | |
14 | import xml.etree.ElementTree as ET_ORIG | |
15 | ETREE_VERSION = ET_ORIG.VERSION | |
16 | except ImportError: | |
17 | import xml.etree.ElementTree as ET | |
18 | ETREE_VERSION = ET.VERSION | |
19 | ||
20 | ETREE_VERSION = [int(i) for i in ETREE_VERSION.split(".")] | |
21 | ||
22 | 10 | |
23 | 11 | __author__ = "Ezequiel Tavella" |
24 | 12 | __copyright__ = "Copyright (c) 2015, Infobyte LLC" |
169 | 157 | entity = node.find( |
170 | 158 | "{http://graphml.graphdrawing.org/xmlns}data/" |
171 | 159 | "{http://maltego.paterva.com/xml/mtgx}MaltegoEntity") |
172 | ||
173 | 160 | |
174 | 161 | # Check if is IPv4Address |
175 | 162 | if entity.get("type") not in ("maltego.IPv4Address", "maltego.Domain", "maltego.Website"): |
418 | 405 | try: |
419 | 406 | text = f'Location:\n {host.location["name"]} \nArea:\n {host.location["area"]} ' \ |
420 | 407 | f'\nArea 2:\n {host.location["area_2"]} ' \ |
421 | f'\nCountry_code:\n { host.location["country_code"]} ' \ | |
408 | f'\nCountry_code:\n {host.location["country_code"]} ' \ | |
422 | 409 | f'\nLatitude:\n {host.location["latitude"]} \nLongitude:\n {host.location["longitude"]}' |
423 | 410 | except TypeError: |
424 | 411 | text = "unknown" |
466 | 453 | host_ip = '0.0.0.0' |
467 | 454 | host_id = self.createAndAddHost(name=host_ip, hostnames=hostnames) |
468 | 455 | |
469 | ||
470 | 456 | if maltego_parser.xml.get('location'): |
471 | 457 | location_name = maltego_parser.getInfoMtgl(maltego_parser.xml['location'], 'location.name') |
472 | 458 | location_area = maltego_parser.getInfoMtgl(maltego_parser.xml['location'], 'location.area') |
509 | 495 | description="DNS Server") |
510 | 496 | |
511 | 497 | |
512 | ||
513 | ||
514 | 498 | def createPlugin(ignore_info=False): |
515 | 499 | return MaltegoPlugin(ignore_info=ignore_info) |
129 | 129 | else: |
130 | 130 | return False |
131 | 131 | |
132 | def setHost(self): | |
133 | pass | |
132 | ||
134 | 133 | |
135 | 134 | |
136 | 135 | def createPlugin(ignore_info=False): |
2 | 2 | Copyright (C) 2013 Infobyte LLC (http://www.infobytesec.com/) |
3 | 3 | See the file 'doc/LICENSE' for the license information |
4 | 4 | """ |
5 | import xml.etree.ElementTree as ET | |
6 | ||
5 | 7 | from faraday_plugins.plugins.plugin import PluginXMLFormat |
6 | import re | |
7 | ||
8 | ||
9 | try: | |
10 | import xml.etree.cElementTree as ET | |
11 | import xml.etree.ElementTree as ET_ORIG | |
12 | ETREE_VERSION = ET_ORIG.VERSION | |
13 | except ImportError: | |
14 | import xml.etree.ElementTree as ET | |
15 | ETREE_VERSION = ET.VERSION | |
16 | ||
17 | ETREE_VERSION = [int(i) for i in ETREE_VERSION.split(".")] | |
18 | 8 | |
19 | 9 | __author__ = "Francisco Amato" |
20 | 10 | __copyright__ = "Copyright (c) 2013, Infobyte LLC" |
76 | 66 | """ |
77 | 67 | @return items A list of Host instances |
78 | 68 | """ |
79 | bugtype = "" | |
80 | 69 | |
81 | 70 | for node in tree.findall('hosts/host'): |
82 | 71 | yield Host(node, webVulns) |
85 | 74 | """ |
86 | 75 | @return items A list of WebVuln instances |
87 | 76 | """ |
88 | bugtype = "" | |
89 | 77 | for node in tree.findall('web_vulns/web_vuln'): |
90 | 78 | yield WebVuln(node, services) |
91 | 79 | |
96 | 84 | |
97 | 85 | @return An attribute value |
98 | 86 | """ |
99 | global ETREE_VERSION | |
100 | node = None | |
101 | ||
102 | if ETREE_VERSION[0] <= 1 and ETREE_VERSION[1] < 3: | |
103 | ||
104 | match_obj = re.search( | |
105 | "([^\@]+?)\[\@([^=]*?)=\'([^\']*?)\'", subnode_xpath_expr) | |
106 | if match_obj is not None: | |
107 | node_to_find = match_obj.group(1) | |
108 | xpath_attrib = match_obj.group(2) | |
109 | xpath_value = match_obj.group(3) | |
110 | for node_found in xml_node.findall(node_to_find): | |
111 | if node_found.attrib[xpath_attrib] == xpath_value: | |
112 | node = node_found | |
113 | break | |
114 | else: | |
115 | node = xml_node.find(subnode_xpath_expr) | |
116 | ||
117 | else: | |
118 | node = xml_node.find(subnode_xpath_expr) | |
87 | ||
88 | node = xml_node.find(subnode_xpath_expr) | |
119 | 89 | |
120 | 90 | if node is not None: |
121 | 91 | return node.get(attrib_name) |
210 | 180 | self.query = self.get_text_from_subnode('query') |
211 | 181 | self.request = self.get_text_from_subnode('request') |
212 | 182 | self.category = self.get_text_from_subnode('category-id') |
213 | self.service_id = services[self.get_text_from_subnode('web-site-id')] | |
183 | web_id = self.get_text_from_subnode('web-site-id') | |
184 | self.service_id = None | |
185 | if web_id: | |
186 | self.service_id = services[web_id] | |
187 | ||
214 | 188 | self.isWeb = True |
215 | 189 | |
216 | 190 | def get_text_from_subnode(self, subnode_xpath_expr): |
219 | 193 | |
220 | 194 | @return An attribute value |
221 | 195 | """ |
196 | ||
222 | 197 | sub_node = self.node.find(subnode_xpath_expr) |
223 | 198 | if sub_node is not None: |
224 | 199 | if sub_node.text is not None: |
335 | 310 | self.options = None |
336 | 311 | self.target = None |
337 | 312 | |
338 | ||
339 | 313 | def parseOutputString(self, output): |
340 | 314 | """ |
341 | 315 | This method will discard the output the shell sends, it will read it from |
348 | 322 | self.hostnames = [] |
349 | 323 | if item.host: |
350 | 324 | self.hostnames = [item.host] |
351 | ||
325 | ||
352 | 326 | h_id = self.createAndAddHost(item.ip, os=item.os, hostnames=self.hostnames) |
353 | 327 | |
354 | 328 | if item.id + "_" in item.notesByService: |
356 | 330 | self.createAndAddNoteToHost(h_id, n.ntype, n.data) |
357 | 331 | |
358 | 332 | for v in item.vulnsByHost: |
359 | v_id = self.createAndAddVulnToHost( | |
333 | self.createAndAddVulnToHost( | |
360 | 334 | h_id, v.name, v.desc, ref=v.refs) |
361 | 335 | |
362 | 336 | for s in item.services: |
363 | 337 | s_id = self.createAndAddServiceToHost(h_id, s['name'], |
364 | protocol=s['proto'], | |
365 | ports=[s['port']], | |
366 | status=s['state'], | |
367 | description=s['info']) | |
338 | protocol=s['proto'], | |
339 | ports=[s['port']], | |
340 | status=s['state'], | |
341 | description=s['info']) | |
368 | 342 | |
369 | 343 | if item.id + "_" + s['id'] in item.notesByService: |
370 | 344 | for n in item.notesByService[item.id + "_" + s['id']]: |
375 | 349 | for c in item.credsByService[s['port']]: |
376 | 350 | self.createAndAddCredToService( |
377 | 351 | h_id, s_id, c.user, c.passwd) |
378 | self.createAndAddVulnToService(h_id, s_id, "Weak Credentials", "[metasploit found the following credentials]\nuser:%s\npass:%s" % ( | |
379 | c.user, c.passwd), severity="high") | |
352 | self.createAndAddVulnToService(h_id, s_id, "Weak Credentials", | |
353 | "[metasploit found the following credentials]\nuser:%s\npass:%s" % ( | |
354 | c.user, c.passwd), severity="high") | |
380 | 355 | |
381 | 356 | for v in item.vulnsByService[s['id']]: |
382 | 357 | if v.isWeb: |
383 | v_id = self.createAndAddVulnWebToService(h_id, s_id, v.name, v.desc, | |
358 | self.createAndAddVulnWebToService(h_id, s_id, v.name, v.desc, | |
384 | 359 | severity=v.risk, website=v.host, |
385 | 360 | path=v.path, request=v.request, method=v.method, |
386 | 361 | pname=v.pname, params=v.params, query=v.query, |
387 | 362 | category=v.category) |
388 | 363 | else: |
389 | v_id = self.createAndAddVulnToService( | |
364 | self.createAndAddVulnToService( | |
390 | 365 | h_id, s_id, v.name, v.desc, ref=v.refs) |
391 | 366 | |
392 | 367 | del parser |
393 | 368 | |
394 | def _isIPV4(self, ip): | |
369 | @staticmethod | |
370 | def _isIPV4(ip): | |
395 | 371 | if len(ip.split(".")) == 4: |
396 | 372 | return True |
397 | 373 | else: |
398 | 374 | return False |
399 | 375 | |
400 | 376 | |
401 | def setHost(self): | |
402 | pass | |
403 | ||
404 | ||
405 | 377 | def createPlugin(ignore_info=False): |
406 | 378 | return MetasploitPlugin(ignore_info=ignore_info) |
407 | ||
408 |
0 | """ | |
1 | Faraday Plugins | |
2 | Copyright (c) 2021 Faraday Security LLC (https://www.faradaysec.com/) | |
3 | See the file 'doc/LICENSE' for the license information | |
4 | ||
5 | """ | |
6 | import socket | |
7 | import json | |
8 | import re | |
9 | from faraday_plugins.plugins.plugin import PluginMultiLineJsonFormat | |
10 | ||
11 | __author__ = 'Emilio Couto' | |
12 | __copyright__ = 'Copyright (c) 2021, Faraday Security LLC' | |
13 | __credits__ = ['Emilio Couto'] | |
14 | __license__ = '' | |
15 | __version__ = '0.0.1' | |
16 | __maintainer__ = 'Emilio Couto' | |
17 | __email__ = '[email protected]' | |
18 | __status__ = 'Development' | |
19 | ||
20 | ||
21 | class NaabuPlugin(PluginMultiLineJsonFormat): | |
22 | """ | |
23 | Parse Naabu (from Project Discovery) scanner JSON output | |
24 | """ | |
25 | ||
26 | def __init__(self, *arg, **kwargs): | |
27 | super().__init__(*arg, **kwargs) | |
28 | self.id = 'naabu' | |
29 | self.name = 'Naabu' | |
30 | self.plugin_version = '0.1' | |
31 | self.version = '2.0.3' | |
32 | self.json_keys = {'host', 'ip', 'port'} | |
33 | self._command_regex = re.compile(r'^(sudo naabu|naabu|\.\/nmap)\s+.*?') | |
34 | ||
35 | def parseOutputString(self, output, debug=False): | |
36 | for host_json in filter(lambda x: x != '', output.split('\n')): | |
37 | host_dict = json.loads(host_json) | |
38 | host = host_dict.get('host') | |
39 | ip = host_dict.get('ip') | |
40 | port = host_dict.get('port') | |
41 | try: | |
42 | service = socket.getservbyport(port) | |
43 | except socket.error: | |
44 | service = 'Unknown service on port ' + str(port) | |
45 | host_id = self.createAndAddHost( | |
46 | name=ip, | |
47 | hostnames=[host]) | |
48 | self.createAndAddServiceToHost( | |
49 | host_id, | |
50 | name=service, | |
51 | ports=port, | |
52 | protocol='tcp', | |
53 | status='open', | |
54 | version='', | |
55 | description='') | |
56 | ||
57 | def processCommandString(self, username, current_path, command_string): | |
58 | """ | |
59 | Adds the -oX parameter to get xml output to the command string that the | |
60 | user has set. | |
61 | """ | |
62 | super().processCommandString(username, current_path, command_string) | |
63 | if " -json" not in command_string: | |
64 | command_string += " -json" | |
65 | if " -silent" not in command_string: | |
66 | command_string += " -silent" | |
67 | return command_string | |
68 | ||
69 | def createPlugin(ignore_info=False): | |
70 | return NaabuPlugin(ignore_info=ignore_info) |
4 | 4 | |
5 | 5 | """ |
6 | 6 | |
7 | import xml.etree.ElementTree as ET | |
8 | ||
7 | 9 | from faraday_plugins.plugins.plugin import PluginXMLFormat |
8 | try: | |
9 | import xml.etree.cElementTree as ET | |
10 | except ImportError: | |
11 | import xml.etree.ElementTree as ET | |
12 | ||
13 | 10 | |
14 | 11 | __author__ = "Blas Moyano" |
15 | 12 | __copyright__ = "Copyright (c) 2020, Infobyte LLC" |
6 | 6 | from faraday_plugins.plugins.plugin import PluginBase |
7 | 7 | import re |
8 | 8 | |
9 | try: | |
10 | import xml.etree.cElementTree as ET | |
11 | import xml.etree.ElementTree as ET_ORIG | |
12 | except ImportError: | |
13 | import xml.etree.ElementTree as ET | |
9 | import xml.etree.ElementTree as ET | |
14 | 10 | |
15 | 11 | __author__ = 'Ezequiel Tavella' |
16 | 12 | __copyright__ = 'Copyright (c) 2016, Infobyte LLC' |
0 | from typing import List | |
1 | ||
2 | ||
3 | class Attachment: | |
4 | def __init__(self, node): | |
5 | self.node = node | |
6 | ||
7 | @property | |
8 | def name_attr(self): | |
9 | return self.node.get("name") | |
10 | ||
11 | @property | |
12 | def type_attr(self): | |
13 | return self.node.get("type") | |
14 | ||
15 | @property | |
16 | def text(self): | |
17 | return self.node.text | |
18 | ||
19 | ||
20 | class ReportItem: | |
21 | def __init__(self, node): | |
22 | self.node = node | |
23 | ||
24 | @property | |
25 | def port_attr(self): | |
26 | return self.node.get("port") | |
27 | ||
28 | @property | |
29 | def svc_name_attr(self): | |
30 | return self.node.get("svc_name") | |
31 | ||
32 | @property | |
33 | def protocol_attr(self): | |
34 | return self.node.get("protocol") | |
35 | ||
36 | @property | |
37 | def severity_attr(self): | |
38 | return self.node.get("severity") | |
39 | ||
40 | @property | |
41 | def plugin_id_attr(self): | |
42 | plugin_id = self.node.get("pluginID") | |
43 | if plugin_id: | |
44 | plugin_id = f'NESSUS-{plugin_id}' | |
45 | return plugin_id | |
46 | ||
47 | @property | |
48 | def plugin_name_attr(self): | |
49 | return self.node.get("pluginName") | |
50 | ||
51 | @property | |
52 | def plugin_family_attr(self): | |
53 | return self.node.get("pluginFamily") | |
54 | ||
55 | @property | |
56 | def agent(self): | |
57 | return self.node.findtext("agent") | |
58 | ||
59 | @property | |
60 | def description(self): | |
61 | return self.node.findtext("description", "Not Description") | |
62 | ||
63 | @property | |
64 | def fname(self): | |
65 | return self.node.findtext("fname") | |
66 | ||
67 | @property | |
68 | def plugin_modification_date(self): | |
69 | return self.node.findtext("plugin_modification_date") | |
70 | ||
71 | @property | |
72 | def plugin_name(self): | |
73 | ||
74 | plugin_name = self.node.findtext("plugin_name") | |
75 | if not plugin_name: | |
76 | plugin_name = self.plugin_name_attr | |
77 | return plugin_name | |
78 | ||
79 | @property | |
80 | def plugin_publication_date(self): | |
81 | return self.node.findtext("plugin_publication_date") | |
82 | ||
83 | @property | |
84 | def plugin_type(self): | |
85 | return self.node.findtext("plugin_type") | |
86 | ||
87 | @property | |
88 | def risk_factor(self): | |
89 | risk_factor = self.node.findtext("risk_factor") | |
90 | if risk_factor == 'None' or risk_factor is None: | |
91 | risk_factor = self.severity_attr # I checked several external id and most of them were info | |
92 | return risk_factor | |
93 | ||
94 | @property | |
95 | def script_version(self): | |
96 | return self.node.findtext("script_version") | |
97 | ||
98 | @property | |
99 | def see_also(self): | |
100 | return self.node.findtext("see_also") | |
101 | ||
102 | @property | |
103 | def solution(self): | |
104 | return self.node.findtext("solution", '') | |
105 | ||
106 | @property | |
107 | def synopsis(self): | |
108 | return self.node.findtext("synopsis") | |
109 | ||
110 | @property | |
111 | def plugin_output(self): | |
112 | return self.node.findtext("plugin_output", "") | |
113 | ||
114 | @property | |
115 | def always_run(self): | |
116 | return self.node.findtext("always_run") | |
117 | ||
118 | @property | |
119 | def asset_inventory(self): | |
120 | return self.node.findtext("asset_inventory") | |
121 | ||
122 | @property | |
123 | def canvas_package(self): | |
124 | return self.node.findtext("canvas_package") | |
125 | ||
126 | @property | |
127 | def cvss3_base_score(self): | |
128 | cvss_base_score = self.node.findtext("cvss3_base_score") | |
129 | if cvss_base_score: | |
130 | cvss_base_score = f"CVSS3:{cvss_base_score}" | |
131 | return cvss_base_score | |
132 | ||
133 | @property | |
134 | def cvss3_temporal_score(self): | |
135 | return self.node.findtext("cvss3_temporal_score") | |
136 | ||
137 | @property | |
138 | def cpe(self): | |
139 | return self.node.findtext("cpe") | |
140 | ||
141 | @property | |
142 | def cvss3_temporal_vector(self): | |
143 | return self.node.findtext("cvss3_temporal_vector") | |
144 | ||
145 | @property | |
146 | def cvss3_vector(self): | |
147 | return self.node.findtext("cvss3_vector") | |
148 | ||
149 | @property | |
150 | def cvss_base_score(self): | |
151 | cvss_base_score = self.node.findtext("cvss_base_score") | |
152 | if cvss_base_score: | |
153 | cvss_base_score = f"CVSS:{cvss_base_score}" | |
154 | return cvss_base_score | |
155 | ||
156 | @property | |
157 | def cvss_score_rationale(self): | |
158 | return self.node.findtext("cvss_score_rationale") | |
159 | ||
160 | @property | |
161 | def cvss_score_source(self): | |
162 | return self.node.findtext("cvss_score_source") | |
163 | ||
164 | @property | |
165 | def cvss_temporal_score(self): | |
166 | return self.node.findtext("cvss_temporal_score") | |
167 | ||
168 | @property | |
169 | def cvss_temporal_vector(self): | |
170 | return self.node.findtext("cvss_temporal_vector") | |
171 | ||
172 | @property | |
173 | def cvss_vector(self): | |
174 | cvss_vector = self.node.findtext("cvss_vector") | |
175 | if cvss_vector: | |
176 | cvss_vector = f"CVSSVECTOR:{cvss_vector}" | |
177 | return cvss_vector | |
178 | ||
179 | @property | |
180 | def exploit_available(self): | |
181 | exploit_avalible = self.node.findtext("exploit_available", "") | |
182 | if exploit_avalible: | |
183 | exploit_avalible = f"Exploit available: {exploit_avalible.capitalize()}\n" | |
184 | return exploit_avalible | |
185 | ||
186 | @property | |
187 | def exploit_framework_canvas(self): | |
188 | return self.node.findtext("exploit_framework_canvas") | |
189 | ||
190 | @property | |
191 | def exploit_framework_core(self): | |
192 | return self.node.findtext("exploit_framework_core") | |
193 | ||
194 | @property | |
195 | def exploit_framework_d2_elliot(self): | |
196 | return self.node.findtext("exploit_framework_d2_elliot") | |
197 | ||
198 | @property | |
199 | def exploit_framework_metasploit(self): | |
200 | return self.node.findtext("exploit_framework_metasploit") | |
201 | ||
202 | @property | |
203 | def exploitability_ease(self): | |
204 | return self.node.findtext("exploitability_ease") | |
205 | ||
206 | @property | |
207 | def exploited_by_malware(self): | |
208 | return self.node.findtext("exploited_by_malware") | |
209 | ||
210 | @property | |
211 | def exploited_by_nessus(self): | |
212 | return self.node.findtext("exploited_by_nessus") | |
213 | ||
214 | @property | |
215 | def hardware_inventory(self): | |
216 | return self.node.findtext("hardware_inventory") | |
217 | ||
218 | @property | |
219 | def iava(self): | |
220 | return self.node.findtext("iava") | |
221 | ||
222 | @property | |
223 | def iavb(self): | |
224 | return self.node.findtext("iavb") | |
225 | ||
226 | @property | |
227 | def iavt(self): | |
228 | return self.node.findtext("iavt") | |
229 | ||
230 | @property | |
231 | def in_the_news(self): | |
232 | return self.node.findtext("in_the_news") | |
233 | ||
234 | @property | |
235 | def metasploit_name(self): | |
236 | return self.node.findtext("metasploit_name") | |
237 | ||
238 | @property | |
239 | def os_identification(self): | |
240 | return self.node.findtext("os_identification") | |
241 | ||
242 | @property | |
243 | def owasp(self): | |
244 | return self.node.findtext("owasp") | |
245 | ||
246 | @property | |
247 | def patch_publication_date(self): | |
248 | return self.node.findtext("patch_publication_date") | |
249 | ||
250 | ||
251 | @property | |
252 | def stig_severity(self): | |
253 | return self.node.findtext("stig_severity") | |
254 | ||
255 | @property | |
256 | def d2_elliot_name(self): | |
257 | return self.node.findtext("d2_elliot_name") | |
258 | ||
259 | @property | |
260 | def unsupported_by_vendor(self): | |
261 | return self.node.findtext("unsupported_by_vendor") | |
262 | ||
263 | @property | |
264 | def vuln_publication_date(self): | |
265 | return self.node.findtext("vuln_publication_date") | |
266 | ||
267 | @property | |
268 | def msft(self): | |
269 | return self.node.findtext("msft") | |
270 | ||
271 | ||
272 | @property | |
273 | def cert(self) -> list: | |
274 | return self.node.findall("cert") | |
275 | ||
276 | @property | |
277 | def bid(self) -> list: | |
278 | return self.node.findall("bid") | |
279 | ||
280 | @property | |
281 | def cve(self) -> list: | |
282 | return [i.text for i in self.node.findall("cve")] | |
283 | ||
284 | @property | |
285 | def cwe(self) -> list: | |
286 | return [i.text for i in self.node.findall("cwe")] | |
287 | ||
288 | @property | |
289 | def edb_id(self) -> list: | |
290 | return self.node.findall("edb-id") | |
291 | ||
292 | @property | |
293 | def mskb(self) -> list: | |
294 | return self.node.findall("mskb") | |
295 | ||
296 | @property | |
297 | def xref(self) -> str: | |
298 | return self.node.findtext("xref") | |
299 | ||
300 | @property | |
301 | def attachment(self) -> Attachment: | |
302 | attachment = self.node.find("attachment") | |
303 | return Attachment(attachment) if attachment else None | |
304 | ||
305 | def get_data(self): | |
306 | item_tags = {} | |
307 | for i in self.node: | |
308 | item_tags.setdefault(i.tag, i.text) | |
309 | return item_tags | |
310 | ||
311 | ||
312 | class Tag: | |
313 | def __init__(self, node): | |
314 | self.node = node | |
315 | ||
316 | @property | |
317 | def name_attr(self) -> str: | |
318 | return self.node.get("name") | |
319 | ||
320 | @property | |
321 | def text(self) -> str: | |
322 | return self.node.text | |
323 | ||
324 | ||
325 | class HostProperties: | |
326 | def __init__(self, node): | |
327 | self.node = node | |
328 | ||
329 | @property | |
330 | def tag(self) -> list: | |
331 | return [Tag(i) for i in self.node.findall('tag')] | |
332 | ||
333 | @property | |
334 | def host_end(self) -> str: | |
335 | _dict = self.dict_tags | |
336 | return _dict.get("HOST_END") | |
337 | ||
338 | @property | |
339 | def mac_address(self) -> str: | |
340 | _dict = self.dict_tags | |
341 | return _dict.get("mac-address", "") | |
342 | ||
343 | @property | |
344 | def operating_system(self) -> str: | |
345 | _dict = self.dict_tags | |
346 | return _dict.get("operating-system", None) | |
347 | ||
348 | @property | |
349 | def host_ip(self) -> str: | |
350 | _dict = self.dict_tags | |
351 | ||
352 | return _dict.get("host-ip", None) | |
353 | ||
354 | @property | |
355 | def host_fqdn(self) -> str: | |
356 | _dict = self.dict_tags | |
357 | return _dict.get("host-fqdn", None) | |
358 | ||
359 | @property | |
360 | def dict_tags(self): | |
361 | host_tags = {} | |
362 | for t in self.node: | |
363 | host_tags.setdefault(t.attrib.get('name'), t.text) | |
364 | return host_tags | |
365 | ||
366 | ||
367 | class ReportHost: | |
368 | def __init__(self, node): | |
369 | self.node = node | |
370 | ||
371 | @property | |
372 | def name(self) -> str: | |
373 | return self.node.get("name") | |
374 | ||
375 | @property | |
376 | def host_properties(self) -> HostProperties: | |
377 | return HostProperties(self.node.find("HostProperties")) | |
378 | ||
379 | @property | |
380 | def report_items(self) -> List[ReportItem]: | |
381 | return [ReportItem(i) for i in self.node.findall("ReportItem")] | |
382 | ||
383 | ||
384 | class Report: | |
385 | ||
386 | def __init__(self, node): | |
387 | self.node = node | |
388 | ||
389 | @property | |
390 | def name_attr(self) -> str: | |
391 | return self.node.get("name") | |
392 | ||
393 | @property | |
394 | def report_hosts(self) -> List[ReportHost]: | |
395 | return [ReportHost(i) for i in self.node.findall('ReportHost')] | |
396 |
3 | 3 | See the file 'doc/LICENSE' for the license information |
4 | 4 | |
5 | 5 | """ |
6 | import dateutil | |
7 | from collections import namedtuple | |
8 | 6 | |
9 | from faraday_plugins.plugins.plugin import PluginXMLFormat | |
10 | 7 | import xml.etree.ElementTree as ET |
11 | 8 | |
9 | import dateutil | |
10 | from faraday_plugins.plugins.plugin import PluginXMLFormat | |
12 | 11 | |
13 | 12 | __author__ = "Blas" |
14 | 13 | __copyright__ = "Copyright (c) 2019, Infobyte LLC" |
19 | 18 | __email__ = "[email protected]" |
20 | 19 | __status__ = "Development" |
21 | 20 | |
22 | ReportItem = namedtuple('ReportItem', ['port', 'svc_name', 'protocol', 'severity', 'plugin_id', | |
23 | 'plugin_name', 'plugin_family', 'description', 'plugin_output', 'info']) | |
21 | from faraday_plugins.plugins.repo.nessus.DTO import ReportHost, Report, ReportItem | |
22 | ||
24 | 23 | |
25 | 24 | class NessusParser: |
26 | 25 | """ |
35 | 34 | |
36 | 35 | def __init__(self, output): |
37 | 36 | self.tree = ET.fromstring(output) |
38 | self.tag_control = [] | |
39 | for x in self.tree: | |
40 | self.tag_control.append(x) | |
37 | self.report = [] | |
41 | 38 | if self.tree: |
42 | self.policy = self.getPolicy(self.tree) | |
43 | self.report = self.getReport(self.tree) | |
44 | else: | |
45 | self.policy = None | |
46 | self.report = None | |
39 | self.report = self.__get_report() | |
47 | 40 | |
48 | def getPolicy(self, tree): | |
49 | policy_tree = tree.find('Policy') | |
50 | if policy_tree: | |
51 | return Policy(policy_tree) | |
52 | else: | |
53 | return None | |
41 | def __get_report(self) -> Report: | |
42 | report = self.tree.find('Report') | |
43 | return Report(report) if report else None | |
54 | 44 | |
55 | def getReport(self, tree): | |
56 | report_tree = tree.find('Report') | |
57 | return Report(report_tree) | |
58 | ||
59 | def parse_compliance_data(self, data: dict): | |
60 | compliance_data = {} | |
61 | for key, value in data.items(): | |
62 | if 'compliance-' in key: | |
63 | compliance_name = key.split("}")[-1] | |
64 | compliance_data[compliance_name] = value | |
65 | return compliance_data | |
66 | ||
67 | class Policy(): | |
68 | def __init__(self, policy_node): | |
69 | self.node = policy_node | |
70 | self.policy_name = self.node.find('policyName').text | |
71 | self.preferences = self.getPreferences(self.node.find('Preferences')) | |
72 | self.family_selection = self.getFamilySelection(self.node.find('FamilySelection')) | |
73 | self.individual_plugin_selection = self.getIndividualPluginSelection( | |
74 | self.node.find('IndividualPluginSelection')) | |
75 | ||
76 | def getPreferences(self, preferences): | |
77 | server_preferences = preferences.find('ServerPreferences') | |
78 | plugins_preferences = preferences.find('PluginsPreferences') | |
79 | server_preferences_all = [] | |
80 | plugins_preferences_json = {} | |
81 | plugins_preferences_all = [] | |
82 | for sp in server_preferences: | |
83 | sp_value = sp.find('value').text | |
84 | sp_name = sp.find('name').text | |
85 | server_preferences_all.append("Server Preferences name: {}, Server Preferences value: {}".format(sp_name, | |
86 | sp_value)) | |
87 | for pp in plugins_preferences: | |
88 | for pp_detail in pp: | |
89 | plugins_preferences_json.setdefault(pp_detail.tag, pp_detail.text) | |
90 | plugins_preferences_all.append(plugins_preferences_json) | |
91 | return server_preferences_all, plugins_preferences_all | |
92 | ||
93 | def getFamilySelection(self, family): | |
94 | family_all = [] | |
95 | for f in family: | |
96 | family_name = f.find('FamilyName').text | |
97 | family_value = f.find('Status').text | |
98 | family_all.append("Family Name: {}, Family Value: {}".format(family_name, family_value)) | |
99 | return family_all | |
100 | ||
101 | def getIndividualPluginSelection(self, individual): | |
102 | item_plugin = [] | |
103 | for i in individual: | |
104 | plugin_id = i.find('PluginId').text | |
105 | plugin_name = i.find('PluginName').text | |
106 | plugin_family = i.find('Family').text | |
107 | plugin_status = i.find('Status').text | |
108 | item_plugin.append("Plugin ID: {}, Plugin Name: {}, Family: {}, Status: {}".format(plugin_id, plugin_name, | |
109 | plugin_family, | |
110 | plugin_status)) | |
111 | return item_plugin | |
112 | ||
113 | class Report(): | |
114 | def __init__(self, report_node): | |
115 | self.node = report_node | |
116 | self.report_name = self.node.attrib.get('name') | |
117 | self.report_host = self.node.find('ReportHost') | |
118 | self.report_desc = [] | |
119 | self.report_ip = [] | |
120 | self.report_serv = [] | |
121 | self.report_json = {} | |
122 | if self.report_host is not None: | |
123 | for x in self.node: | |
124 | report_host_ip = x.attrib.get('name') | |
125 | host_properties = self.gethosttag(x.find('HostProperties')) | |
126 | report_items = self.getreportitems(x.findall('ReportItem')) | |
127 | self.report_ip.append(report_host_ip) | |
128 | self.report_desc.append(host_properties) | |
129 | self.report_serv.append(report_items) | |
130 | self.report_json['ip'] = self.report_ip | |
131 | self.report_json['desc'] = self.report_desc | |
132 | self.report_json['serv'] = self.report_serv | |
133 | self.report_json['host_end'] = host_properties.get('HOST_END') | |
134 | ||
135 | else: | |
136 | self.report_host_ip = None | |
137 | self.host_properties = None | |
138 | self.report_items = None | |
139 | self.report_json = None | |
140 | ||
141 | def getreportitems(self, items): | |
142 | report_items = [] | |
143 | ||
144 | for item in items: | |
145 | port = item.attrib.get('port') | |
146 | svc_name = item.attrib.get('svc_name') | |
147 | protocol = item.attrib.get('protocol') | |
148 | severity = item.attrib.get('severity') | |
149 | plugin_id = item.attrib.get('pluginID') | |
150 | plugin_name = item.attrib.get('pluginName') | |
151 | plugin_family = item.attrib.get('pluginFamily') | |
152 | if item.find('plugin_output') is not None: | |
153 | plugin_output = item.find('plugin_output').text | |
154 | else: | |
155 | plugin_output = "Not Description" | |
156 | if item.find('description') is not None: | |
157 | description = item.find('description').text | |
158 | else: | |
159 | description = "Not Description" | |
160 | info = self.getinfoitem(item) | |
161 | report_items.append(ReportItem(*[port, svc_name, protocol, severity, plugin_id, | |
162 | plugin_name, plugin_family, description, plugin_output, info])) | |
163 | return report_items | |
164 | ||
165 | def getinfoitem(self, item): | |
166 | item_tags = {} | |
167 | for i in item: | |
168 | item_tags.setdefault(i.tag, i.text) | |
169 | return item_tags | |
170 | ||
171 | def gethosttag(self, tags): | |
172 | host_tags = {} | |
173 | for t in tags: | |
174 | host_tags.setdefault(t.attrib.get('name'), t.text) | |
175 | return host_tags | |
176 | 45 | |
177 | 46 | class NessusPlugin(PluginXMLFormat): |
178 | 47 | """ |
190 | 59 | self.framework_version = "1.0.1" |
191 | 60 | self.options = None |
192 | 61 | |
62 | @staticmethod | |
63 | def parse_compliance_data(data: dict): | |
64 | compliance_data = {} | |
65 | for key, value in data.items(): | |
66 | if 'compliance-' in key: | |
67 | compliance_name = key.split("}")[-1] | |
68 | compliance_data[compliance_name] = value | |
69 | return compliance_data | |
70 | ||
71 | @staticmethod | |
72 | def map_properties(host: ReportHost): | |
73 | return { | |
74 | "name": host.host_properties.host_ip if host.host_properties.host_ip else host.name, | |
75 | "hostnames": host.host_properties.host_fqdn, | |
76 | "mac": host.host_properties.mac_address, | |
77 | "os": host.host_properties.operating_system | |
78 | } | |
79 | ||
80 | @staticmethod | |
81 | def map_item(host_id, run_date, plugin_name, item: ReportItem) -> dict: | |
82 | cvss_base_score = item.cvss_base_score | |
83 | data = item.plugin_output | |
84 | data += f'{item.exploit_available}' | |
85 | return { | |
86 | "host_id": host_id, | |
87 | "name": plugin_name, | |
88 | "severity": item.risk_factor, | |
89 | "data": data, | |
90 | "external_id": item.plugin_id_attr, | |
91 | "run_date": run_date, | |
92 | "desc": item.description, | |
93 | "resolution": item.solution, | |
94 | "ref": [cvss_base_score] if cvss_base_score else [] | |
95 | } | |
96 | ||
97 | def map_policy_general(self, kwargs, item: ReportItem): | |
98 | kwargs.update({"policyviolations": []}) | |
99 | if item.plugin_family_attr == 'Policy Compliance': | |
100 | data = item.get_data() | |
101 | bis_benchmark_data = kwargs["desc"].split('\n') | |
102 | compliance_data = self.parse_compliance_data(data) | |
103 | compliance_info = compliance_data.get('compliance-info', '') | |
104 | if compliance_info and not kwargs["desc"]: | |
105 | kwargs["desc"] = compliance_info | |
106 | compliance_reference = compliance_data.get( | |
107 | 'compliance-reference', '').replace('|', ':').split(',') | |
108 | compliance_result = compliance_data.get('compliance-result', '') | |
109 | for reference in compliance_reference: | |
110 | kwargs["ref"].append(reference) | |
111 | compliance_check_name = compliance_data.get('compliance-check-name', '') | |
112 | compliance_solution = compliance_data.get('compliance-solution', '') | |
113 | if compliance_solution and not kwargs["resolution"]: | |
114 | kwargs["resolution"] = compliance_solution | |
115 | policy_item = f'{compliance_check_name} - {compliance_result}' | |
116 | for policy_check_data in bis_benchmark_data: | |
117 | if 'ref.' in policy_check_data: | |
118 | kwargs["ref"].append(policy_check_data) | |
119 | if 'compliance-see-also' in compliance_data: | |
120 | kwargs["ref"].append(compliance_data.get('compliance-see-also')) | |
121 | # We used this info from tenable: https://community.tenable.com/s/article/Compliance-checks-in-SecurityCenter | |
122 | kwargs["policyviolations"].append(policy_item) | |
123 | kwargs["name"] = f'{kwargs["name"]}: {policy_item}' | |
124 | ||
125 | return kwargs | |
126 | ||
193 | 127 | def parseOutputString(self, output): |
194 | 128 | """ |
195 | 129 | This method will discard the output the shell sends, it will read it from |
198 | 132 | NOTE: if 'debug' is true then it is being run from a test case and the |
199 | 133 | output being sent is valid. |
200 | 134 | """ |
135 | ||
201 | 136 | try: |
202 | 137 | parser = NessusParser(output) |
203 | 138 | except Exception as e: |
204 | 139 | self.logger.error(str(e)) |
205 | 140 | return None |
141 | report_hosts = parser.report.report_hosts | |
206 | 142 | |
207 | if parser.report.report_json is not None: | |
208 | run_date = parser.report.report_json.get('host_end') | |
209 | if run_date: | |
210 | run_date = dateutil.parser.parse(run_date) | |
211 | for set_info, ip in enumerate(parser.report.report_json['ip'], start=1): | |
212 | website = None | |
213 | mac = parser.report.report_json['desc'][set_info - 1].get('mac-address', '') | |
214 | os = parser.report.report_json['desc'][set_info - 1].get('operating-system', None) | |
215 | ip_host = parser.report.report_json['desc'][set_info - 1].get('host-ip', ip) | |
216 | host_name = parser.report.report_json['desc'][set_info - 1].get('host-fqdn', None) | |
217 | if host_name: | |
218 | website = host_name | |
219 | host_id = self.createAndAddHost(ip_host, os=os, hostnames=host_name, mac=mac) | |
143 | if report_hosts: | |
144 | for host in report_hosts: | |
145 | run_date = host.host_properties.host_end | |
146 | if run_date: | |
147 | run_date = dateutil.parser.parse(run_date) | |
148 | website = host.host_properties.host_fqdn | |
149 | host_id = self.createAndAddHost(**self.map_properties(host)) | |
220 | 150 | |
221 | for report_item in parser.report.report_json['serv'][set_info -1]: | |
222 | vulnerability_name = report_item.plugin_name | |
151 | for item in host.report_items: | |
152 | vulnerability_name = item.plugin_name | |
223 | 153 | if not vulnerability_name: |
224 | 154 | continue |
225 | item_name = report_item.svc_name | |
226 | item_port = report_item.port | |
227 | item_protocol = report_item.protocol | |
228 | item_severity = report_item.severity | |
229 | external_id = report_item.plugin_id | |
230 | serv_description = report_item.description | |
231 | #cve.append(report_item.plugin_output) | |
232 | description = report_item.plugin_output | |
233 | data = report_item.info | |
234 | risk_factor = data.get('risk_factor', None) | |
235 | cve = [] | |
236 | ref = [] | |
237 | if risk_factor == 'None' or risk_factor is None: | |
238 | risk_factor = item_severity # I checked several external id and most of them were info | |
155 | item_name = item.svc_name_attr | |
156 | ||
157 | _main_data = self.map_item( | |
158 | host_id, run_date, vulnerability_name, item) | |
159 | ||
160 | _main_data = self.map_add_ref(_main_data, item) | |
239 | 161 | if item_name == 'general': |
240 | description = data.get('description', '') | |
241 | resolution = data.get('solution', '') | |
242 | data_pluin_ouput = data.get('plugin_output', '') | |
243 | if 'cvss_base_score' in data: | |
244 | cvss_base_score = f"CVSS:{data['cvss_base_score']}" | |
245 | ref.append(cvss_base_score) | |
246 | policyviolations = [] | |
247 | if report_item.plugin_family == 'Policy Compliance': | |
248 | # This condition was added to support CIS Benchmark in policy violation field. | |
249 | bis_benchmark_data = report_item.description.split('\n') | |
250 | compliance_data = parser.parse_compliance_data(data) | |
251 | compliance_info = compliance_data.get('compliance-info', '') | |
252 | if compliance_info and not description: | |
253 | description = compliance_info | |
254 | compliance_reference = compliance_data.get('compliance-reference', '').replace('|', ':').split(',') | |
255 | compliance_result = compliance_data.get('compliance-result', '') | |
256 | for reference in compliance_reference: | |
257 | ref.append(reference) | |
258 | compliance_check_name = compliance_data.get('compliance-check-name', '') | |
259 | compliance_solution = compliance_data.get('compliance-solution', '') | |
260 | if compliance_solution and not resolution: | |
261 | resolution = compliance_solution | |
262 | policy_item = f'{compliance_check_name} - {compliance_result}' | |
263 | for policy_check_data in bis_benchmark_data: | |
264 | if 'ref.' in policy_check_data: | |
265 | ref.append(policy_check_data) | |
266 | if 'compliance-see-also' in compliance_data: | |
267 | ref.append(compliance_data.get('compliance-see-also')) | |
268 | # We used this info from tenable: https://community.tenable.com/s/article/Compliance-checks-in-SecurityCenter | |
269 | policyviolations.append(policy_item) | |
270 | vulnerability_name = f'{vulnerability_name}: {policy_item}' | |
271 | self.createAndAddVulnToHost(host_id, | |
272 | vulnerability_name, | |
273 | desc=description, | |
274 | severity=risk_factor, | |
275 | resolution=resolution, | |
276 | data=data_pluin_ouput, | |
277 | ref=ref, | |
278 | policyviolations=policyviolations, | |
279 | external_id=external_id, | |
280 | run_date=run_date) | |
162 | _main_data = self.map_policy_general(_main_data, item) | |
163 | self.createAndAddVulnToHost(**_main_data) | |
281 | 164 | else: |
282 | vulnerability_name = report_item.plugin_name | |
283 | description = data.get('description', '') | |
284 | resolution = data.get('solution', '') | |
285 | data_pluin_ouput = data.get('plugin_output', '') | |
286 | if 'cvss_base_score' in data: | |
287 | cvss_base_score = f"CVSS:{data['cvss_base_score']}" | |
288 | ref.append(cvss_base_score) | |
289 | if 'cvss_vector' in data: | |
290 | cvss_vector = f"CVSSVECTOR:{data['cvss_vector']}" | |
291 | ref.append(cvss_vector) | |
292 | if 'see_also' in data: | |
293 | ref.append(data['see_also']) | |
294 | if 'cpe' in data: | |
295 | ref.append(data['cpe']) | |
296 | if 'xref' in data: | |
297 | ref.append(data['xref']) | |
165 | _main_data["service_id"] = self.createAndAddServiceToHost( | |
166 | host_id, name=item_name, protocol=item.protocol_attr, | |
167 | ports=item.port_attr) | |
168 | if item_name == 'www' or item_name == 'http': | |
169 | _main_data.update({"website": website}) | |
170 | self.createAndAddVulnWebToService(**_main_data) | |
171 | else: | |
172 | self.createAndAddVulnToService(**_main_data) | |
298 | 173 | |
299 | service_id = self.createAndAddServiceToHost(host_id, name=item_name, protocol=item_protocol, | |
300 | ports=item_port) | |
174 | @staticmethod | |
175 | def map_add_ref(kwargs, item: ReportItem): | |
301 | 176 | |
302 | if item_name == 'www' or item_name == 'http': | |
303 | self.createAndAddVulnWebToService(host_id, | |
304 | service_id, | |
305 | name=vulnerability_name, | |
306 | desc=description, | |
307 | data=data_pluin_ouput, | |
308 | severity=risk_factor, | |
309 | resolution=resolution, | |
310 | ref=ref, | |
311 | external_id=external_id, | |
312 | website=website, | |
313 | run_date=run_date) | |
314 | else: | |
315 | self.createAndAddVulnToService(host_id, | |
316 | service_id, | |
317 | name=vulnerability_name, | |
318 | severity=risk_factor, | |
319 | desc=description, | |
320 | ref=ref, | |
321 | data=data_pluin_ouput, | |
322 | external_id=external_id, | |
323 | resolution=resolution, | |
324 | run_date=run_date) | |
177 | if item.cvss_vector: | |
178 | kwargs["ref"].append(item.cvss_vector) | |
179 | if item.see_also: | |
180 | kwargs["ref"].append(item.see_also) | |
181 | if item.cpe: | |
182 | kwargs["ref"].append(item.cpe) | |
183 | if item.xref: | |
184 | kwargs["ref"].append(item.xref) | |
185 | if item.cve: | |
186 | kwargs["ref"] = kwargs["ref"] + item.cve | |
187 | if item.cvss3_base_score: | |
188 | kwargs["ref"].append(item.cvss3_base_score) | |
189 | if item.cvss3_vector: | |
190 | kwargs["ref"].append(item.cvss3_vector) | |
191 | ||
192 | return kwargs | |
325 | 193 | |
326 | 194 | |
327 | 195 | def createPlugin(ignore_info=False): |
4 | 4 | |
5 | 5 | """ |
6 | 6 | import re |
7 | import xml.etree.ElementTree as ET | |
8 | ||
7 | 9 | from bs4 import BeautifulSoup |
10 | ||
8 | 11 | from faraday_plugins.plugins.plugin import PluginXMLFormat |
9 | 12 | from faraday_plugins.plugins.plugins_utils import resolve_hostname |
10 | ||
11 | try: | |
12 | import xml.etree.cElementTree as ET | |
13 | import xml.etree.ElementTree as ET_ORIG | |
14 | ETREE_VERSION = ET_ORIG.VERSION | |
15 | except ImportError: | |
16 | import xml.etree.ElementTree as ET | |
17 | ETREE_VERSION = ET.VERSION | |
18 | ||
19 | ETREE_VERSION = [int(i) for i in ETREE_VERSION.split(".")] | |
20 | ||
21 | 13 | |
22 | 14 | __author__ = "Francisco Amato" |
23 | 15 | __copyright__ = "Copyright (c) 2013, Infobyte LLC" |
82 | 74 | @param item_node A item_node taken from an netsparker xml tree |
83 | 75 | """ |
84 | 76 | |
85 | def re_map_severity(self, severity): | |
86 | if severity == "Important": | |
87 | return "high" | |
88 | return severity | |
89 | ||
90 | def __init__(self, item_node, encoding="ascii"): | |
77 | def __init__(self, item_node): | |
91 | 78 | self.node = item_node |
92 | 79 | self.url = self.get_text_from_subnode("url") |
93 | 80 | |
117 | 104 | self.param = self.get_text_from_subnode("vulnerableparameter") |
118 | 105 | self.paramval = self.get_text_from_subnode("vulnerableparametervalue") |
119 | 106 | self.reference = self.get_text_from_subnode("externalReferences") |
120 | self.resolution = self.get_text_from_subnode("actionsToTake") | |
107 | remedy = self.get_text_from_subnode("remedy") | |
108 | self.resolution = self.get_text_from_subnode("actionsToTake") + remedy if remedy else "" | |
121 | 109 | self.request = self.get_text_from_subnode("rawrequest") |
122 | 110 | self.response = self.get_text_from_subnode("rawresponse") |
123 | 111 | self.kvulns = [] |
166 | 154 | repr(self.paramval) if self.paramval else "" |
167 | 155 | self.data += "\nExtra: " + "\n".join(self.extra) if self.extra else "" |
168 | 156 | |
157 | @staticmethod | |
158 | def re_map_severity(severity): | |
159 | if severity == "Important": | |
160 | return "high" | |
161 | return severity | |
162 | ||
169 | 163 | def get_text_from_subnode(self, subnode_xpath_expr): |
170 | 164 | """ |
171 | 165 | Finds a subnode in the host node and the retrieves a value from it. |
207 | 201 | ports=[str(i.port)], |
208 | 202 | status="open") |
209 | 203 | first = False |
204 | ||
210 | 205 | if i.resolution is not None: |
211 | 206 | resolution = BeautifulSoup(i.resolution, "lxml").text |
212 | 207 | else: |
220 | 215 | name = i.name |
221 | 216 | else: |
222 | 217 | name = i.name_title |
223 | v_id = self.createAndAddVulnWebToService(h_id, s_id, name, ref=i.ref, website=i.hostname, | |
218 | self.createAndAddVulnWebToService(h_id, s_id, name, ref=i.ref, website=i.hostname, | |
224 | 219 | severity=i.severity, desc=desc, path=i.url, method=i.method, |
225 | 220 | request=i.request, response=i.response, resolution=resolution, |
226 | 221 | pname=i.param, data=i.data) |
4 | 4 | |
5 | 5 | """ |
6 | 6 | import re |
7 | import xml.etree.ElementTree as ET | |
7 | 8 | from urllib.parse import urlparse |
9 | ||
8 | 10 | from faraday_plugins.plugins.plugin import PluginXMLFormat |
9 | 11 | from faraday_plugins.plugins.plugins_utils import resolve_hostname |
10 | ||
11 | try: | |
12 | import xml.etree.cElementTree as ET | |
13 | import xml.etree.ElementTree as ET_ORIG | |
14 | ETREE_VERSION = ET_ORIG.VERSION | |
15 | except ImportError: | |
16 | import xml.etree.ElementTree as ET | |
17 | ETREE_VERSION = ET.VERSION | |
18 | ||
19 | ETREE_VERSION = [int(i) for i in ETREE_VERSION.split(".")] | |
20 | ||
21 | 12 | |
22 | 13 | __author__ = "Francisco Amato" |
23 | 14 | __copyright__ = "Copyright (c) 2013, Infobyte LLC" |
29 | 20 | __status__ = "Development" |
30 | 21 | |
31 | 22 | |
32 | ||
33 | 23 | def get_urls(string): |
34 | 24 | if isinstance(string, bytes): |
35 | 25 | string_decode = string.decode("utf-8") |
54 | 44 | self.filepath = xml_output |
55 | 45 | tree = self.parse_xml(xml_output) |
56 | 46 | if tree: |
57 | self.items = [data for data in self.get_items(tree)] | |
47 | self.items = self.get_items(tree) | |
58 | 48 | else: |
59 | 49 | self.items = [] |
60 | 50 | |
89 | 79 | |
90 | 80 | @param item_node A item_node taken from an netsparkercloud xml tree |
91 | 81 | """ |
82 | ||
92 | 83 | def re_map_severity(self, severity): |
93 | 84 | if severity == "Important": |
94 | 85 | return "high" |
119 | 110 | self.response = self.get_text_from_subnode("content") |
120 | 111 | self.extra = [] |
121 | 112 | for v in item_node.findall("extra-information/info"): |
122 | self.extra.append(v.get('name') + ":" + v.get('value') ) | |
113 | self.extra.append(v.get('name') + ":" + v.get('value')) | |
123 | 114 | |
124 | 115 | self.node = item_node.find("classification") |
125 | 116 | self.owasp = self.get_text_from_subnode("owasp") |
205 | 196 | del parser |
206 | 197 | |
207 | 198 | |
208 | def setHost(self): | |
209 | pass | |
210 | ||
211 | ||
212 | 199 | def createPlugin(ignore_info=False): |
213 | 200 | return NetsparkerCloudPlugin(ignore_info=ignore_info) |
3 | 3 | See the file 'doc/LICENSE' for the license information |
4 | 4 | |
5 | 5 | """ |
6 | import re | |
7 | import xml.etree.ElementTree as ET | |
8 | ||
6 | 9 | from faraday_plugins.plugins.plugin import PluginXMLFormat |
7 | import re | |
8 | ||
9 | try: | |
10 | import xml.etree.cElementTree as ET | |
11 | import xml.etree.ElementTree as ET_ORIG | |
12 | ||
13 | ETREE_VERSION = ET_ORIG.VERSION | |
14 | except ImportError: | |
15 | import xml.etree.ElementTree as ET | |
16 | ||
17 | ETREE_VERSION = ET.VERSION | |
18 | ||
19 | ETREE_VERSION = [int(i) for i in ETREE_VERSION.split(".")] | |
20 | ||
21 | 10 | |
22 | 11 | __author__ = "Micaela Ranea Sanchez" |
23 | 12 | __copyright__ = "Copyright (c) 2013, Infobyte LLC" |
50 | 39 | else: |
51 | 40 | self.items = [] |
52 | 41 | |
53 | def parse_xml(self, xml_output): | |
42 | @staticmethod | |
43 | def parse_xml(xml_output): | |
54 | 44 | """ |
55 | 45 | Open and parse an xml file. |
56 | 46 | |
121 | 111 | |
122 | 112 | for tests in node.findall('tests'): |
123 | 113 | for test in tests.iter('test'): |
124 | vuln = dict() | |
125 | 114 | if test.get('id').lower() in vulnsDefinitions: |
126 | 115 | vuln = vulnsDefinitions[test.get('id').lower()].copy() |
127 | 116 | key = test.get('key', '') |
274 | 263 | h_id = self.createAndAddHost(item['name'], item['os'], hostnames=item['hostnames'], mac=mac) |
275 | 264 | for v in item['vulns']: |
276 | 265 | v['data'] = {"vulnerable_since": v['vulnerable_since'], "scan_id": v['scan_id'], "PCI": v['pci']} |
277 | v_id = self.createAndAddVulnToHost( | |
266 | self.createAndAddVulnToHost( | |
278 | 267 | h_id, |
279 | 268 | v['name'], |
280 | 269 | v['desc'], |
284 | 273 | ) |
285 | 274 | |
286 | 275 | for s in item['services']: |
287 | web = False | |
288 | 276 | version = s.get("version", "") |
289 | 277 | s_id = self.createAndAddServiceToHost( |
290 | 278 | h_id, |
297 | 285 | for v in s['vulns']: |
298 | 286 | |
299 | 287 | if v['is_web']: |
300 | v_id = self.createAndAddVulnWebToService( | |
288 | self.createAndAddVulnWebToService( | |
301 | 289 | h_id, |
302 | 290 | s_id, |
303 | 291 | v['name'], |
307 | 295 | v['resolution'], |
308 | 296 | path=v.get('path', '')) |
309 | 297 | else: |
310 | v_id = self.createAndAddVulnToService( | |
298 | self.createAndAddVulnToService( | |
311 | 299 | h_id, |
312 | 300 | s_id, |
313 | 301 | v['name'], |
320 | 308 | del parser |
321 | 309 | |
322 | 310 | |
323 | def setHost(self): | |
324 | pass | |
325 | ||
326 | ||
327 | 311 | def createPlugin(ignore_info=False): |
328 | 312 | return NexposeFullPlugin(ignore_info=ignore_info) |
329 | ||
330 |
3 | 3 | See the file 'doc/LICENSE' for the license information |
4 | 4 | """ |
5 | 5 | import re |
6 | import xml.etree.ElementTree as ET | |
6 | 7 | from html.parser import HTMLParser |
8 | ||
9 | from faraday_plugins.plugins import plugins_utils | |
7 | 10 | from faraday_plugins.plugins.plugin import PluginXMLFormat |
8 | from faraday_plugins.plugins import plugins_utils | |
9 | ||
10 | ||
11 | try: | |
12 | import xml.etree.cElementTree as ET | |
13 | import xml.etree.ElementTree as ET_ORIG | |
14 | ETREE_VERSION = ET_ORIG.VERSION | |
15 | except ImportError: | |
16 | import xml.etree.ElementTree as ET | |
17 | ETREE_VERSION = ET.VERSION | |
18 | ||
19 | ETREE_VERSION = [int(i) for i in ETREE_VERSION.split(".")] | |
20 | ||
21 | 11 | |
22 | 12 | __author__ = "Francisco Amato" |
23 | 13 | __copyright__ = "Copyright (c) 2013, Infobyte LLC" |
45 | 35 | tree = self.parse_xml(xml_output) |
46 | 36 | |
47 | 37 | if tree: |
48 | self.hosts = [host for host in self.get_hosts(tree)] | |
38 | self.hosts = self.get_hosts(tree) | |
49 | 39 | else: |
50 | 40 | self.hosts = [] |
51 | 41 | |
84 | 74 | |
85 | 75 | @return An attribute value |
86 | 76 | """ |
87 | global ETREE_VERSION | |
88 | node = None | |
89 | ||
90 | if ETREE_VERSION[0] <= 1 and ETREE_VERSION[1] < 3: | |
91 | ||
92 | match_obj = re.search( | |
93 | "([^\@]+?)\[\@([^=]*?)=\'([^\']*?)\'", subnode_xpath_expr) | |
94 | if match_obj is not None: | |
95 | ||
96 | node_to_find = match_obj.group(1) | |
97 | xpath_attrib = match_obj.group(2) | |
98 | xpath_value = match_obj.group(3) | |
99 | for node_found in xml_node.findall(node_to_find): | |
100 | ||
101 | if node_found.attrib[xpath_attrib] == xpath_value: | |
102 | node = node_found | |
103 | break | |
104 | else: | |
105 | node = xml_node.find(subnode_xpath_expr) | |
106 | ||
107 | else: | |
108 | node = xml_node.find(subnode_xpath_expr) | |
77 | ||
78 | node = xml_node.find(subnode_xpath_expr) | |
109 | 79 | |
110 | 80 | if node is not None: |
111 | 81 | return node.get(attrib_name) |
221 | 191 | self.starttime = self.node.get('starttime') |
222 | 192 | self.sitename = self.node.get('sitename') |
223 | 193 | self.siteip = self.node.get('hostheader') |
224 | self.items = [item for item in self.get_items()] | |
194 | self.items = self.get_items() | |
225 | 195 | |
226 | 196 | def get_items(self): |
227 | 197 | """ |
300 | 270 | "-vhost+": "Virtual host (for Host header)", |
301 | 271 | } |
302 | 272 | |
303 | ||
304 | ||
305 | 273 | def parseOutputString(self, output): |
306 | 274 | """ |
307 | 275 | This method will discard the output the shell sends, it will read it from |
329 | 297 | ) |
330 | 298 | |
331 | 299 | for item in host.items: |
332 | ||
333 | v_id = self.createAndAddVulnWebToService( | |
300 | self.createAndAddVulnWebToService( | |
334 | 301 | h_id, |
335 | 302 | s_id, |
336 | 303 | name=item.desc, |
342 | 309 | |
343 | 310 | del parser |
344 | 311 | |
345 | ||
346 | ||
347 | 312 | def processCommandString(self, username, current_path, command_string): |
348 | 313 | """ |
349 | 314 | Adds the -oX parameter to get xml output to the command string that the |
359 | 324 | data = re.sub(" \-Format XML", "", command_string) |
360 | 325 | return re.sub(arg_match.group(1), r"-output %s -Format XML" % self._output_file_path, data) |
361 | 326 | |
362 | def setHost(self): | |
363 | pass | |
364 | ||
365 | 327 | |
366 | 328 | def createPlugin(ignore_info=False): |
367 | 329 | return NiktoPlugin(ignore_info=ignore_info) |
368 | ||
369 |
0 | import os | |
1 | import re | |
2 | from io import BytesIO | |
3 | ||
0 | 4 | """ |
1 | 5 | Faraday Penetration Test IDE |
2 | 6 | Copyright (C) 2013 Infobyte LLC (http://www.infobytesec.com/) |
3 | 7 | See the file 'doc/LICENSE' for the license information |
4 | 8 | |
5 | 9 | """ |
6 | ||
7 | import re | |
8 | import os | |
9 | from io import BytesIO | |
10 | ||
11 | try: | |
12 | import xml.etree.cElementTree as ET | |
13 | import xml.etree.ElementTree as ET_ORIG | |
14 | ETREE_VERSION = ET_ORIG.VERSION | |
15 | except ImportError: | |
16 | import xml.etree.ElementTree as ET | |
17 | ETREE_VERSION = ET.VERSION | |
18 | 10 | from lxml import etree |
19 | 11 | from lxml.etree import XMLParser |
20 | 12 | from faraday_plugins.plugins.plugin import PluginXMLFormat |
21 | 13 | from faraday_plugins.plugins.plugins_utils import get_severity_from_cvss |
22 | 14 | |
23 | ETREE_VERSION = [int(i) for i in ETREE_VERSION.split(".")] | |
24 | 15 | current_path = os.path.abspath(os.getcwd()) |
25 | ||
26 | 16 | |
27 | 17 | |
28 | 18 | class NmapXmlParser: |
60 | 50 | magical_parser = XMLParser(recover=True) |
61 | 51 | return etree.parse(BytesIO(xml_output), magical_parser) |
62 | 52 | except SyntaxError as err: |
63 | #logger.error("SyntaxError: %s." % (err)) | |
53 | # logger.error("SyntaxError: %s." % (err)) | |
64 | 54 | return None |
65 | 55 | |
66 | 56 | def get_hosts(self, tree): |
77 | 67 | |
78 | 68 | @return An attribute value |
79 | 69 | """ |
80 | global ETREE_VERSION | |
81 | node = None | |
82 | ||
83 | if ETREE_VERSION[0] <= 1 and ETREE_VERSION[1] < 3: | |
84 | ||
85 | match_obj = re.search( | |
86 | "([^\@]+?)\[\@([^=]*?)=\'([^\']*?)\'", | |
87 | subnode_xpath_expr) | |
88 | ||
89 | if match_obj is not None: | |
90 | ||
91 | node_to_find = match_obj.group(1) | |
92 | xpath_attrib = match_obj.group(2) | |
93 | xpath_value = match_obj.group(3) | |
94 | ||
95 | for node_found in xml_node.findall(node_to_find): | |
96 | if node_found.attrib[xpath_attrib] == xpath_value: | |
97 | node = node_found | |
98 | break | |
99 | else: | |
100 | node = xml_node.find(subnode_xpath_expr) | |
101 | ||
102 | else: | |
103 | node = xml_node.find(subnode_xpath_expr) | |
70 | ||
71 | node = xml_node.find(subnode_xpath_expr) | |
104 | 72 | |
105 | 73 | if node is not None: |
106 | 74 | return node.get(attrib_name) |
242 | 210 | ostype = service.get("ostype", "unknown") |
243 | 211 | yield ("%s" % ostype, 0) |
244 | 212 | |
245 | ||
246 | 213 | def top_os_guess(self): |
247 | 214 | """ |
248 | 215 | @return The most accurate os_guess_id or 'unknown'. |
295 | 262 | @param port_node A port_node taken from an nmap xml tree |
296 | 263 | """ |
297 | 264 | |
265 | PORT_STATUS_FIX = {"filtered": "closed", "open|filtered": "closed"} | |
266 | ||
298 | 267 | def __init__(self, port_node): |
299 | 268 | self.node = port_node |
300 | 269 | |
322 | 291 | |
323 | 292 | @return (state, reason, reason_ttl) or ('unknown','unknown','unknown') |
324 | 293 | """ |
325 | state = self.get_attrib_from_subnode('state', 'state') | |
294 | state = self.PORT_STATUS_FIX.get(self.get_attrib_from_subnode('state', 'state'), | |
295 | self.get_attrib_from_subnode('state', 'state')) | |
326 | 296 | reason = self.get_attrib_from_subnode('state', 'reason') |
327 | 297 | reason_ttl = self.get_attrib_from_subnode('state', 'reason_ttl') |
328 | 298 | |
381 | 351 | self.table[e.get("key")] = str(e.text) |
382 | 352 | |
383 | 353 | self.name = self.table["id"] |
384 | ||
354 | ||
385 | 355 | self.desc = script_node.get("id") + "-" + self.table["id"] |
386 | 356 | if self.table["is_exploit"] == 'true': |
387 | 357 | self.desc += " *EXPLOIT*" |
388 | ||
358 | ||
389 | 359 | self.refs = ["https://vulners.com/" + self.table["type"] + "/" + self.table["id"]] |
390 | 360 | self.refs.append("CVSS: " + self.table["cvss"]) |
391 | 361 | self.response = "" |
422 | 392 | |
423 | 393 | self.name = script_node.get("id") |
424 | 394 | self.desc = script_node.get("output") |
425 | self.refs = self.parse_output(self.desc) | |
395 | self.refs = self.parse_output(self.desc) | |
426 | 396 | self.response = "" |
427 | 397 | for k in script_node.findall("elem"): |
428 | 398 | self.response += "\n" + str(k.get('key')) + ": " + str(k.text) |
547 | 517 | description=srvname) |
548 | 518 | |
549 | 519 | for v in port.vulns: |
550 | ||
520 | ||
551 | 521 | desc = v.desc |
552 | 522 | refs = v.refs |
553 | 523 | |
561 | 531 | severity = "unclassified" |
562 | 532 | if re.search(r"Couldn't", desc): |
563 | 533 | severity = "unclassified" |
564 | ||
534 | ||
565 | 535 | if v.web: |
566 | 536 | v_id = self.createAndAddVulnWebToService( |
567 | 537 | h_id, |
568 | 538 | s_id, |
569 | 539 | v.name, |
570 | 540 | desc=desc, |
571 | response = v.response if v.response else "", | |
541 | response=v.response if v.response else "", | |
572 | 542 | ref=refs, |
573 | 543 | severity=severity, |
574 | 544 | website=minterfase, |
600 | 570 | r"-oX %s" % self._output_file_path, |
601 | 571 | command_string) |
602 | 572 | |
573 | ||
603 | 574 | def createPlugin(ignore_info=False): |
604 | 575 | return NmapPlugin(ignore_info=ignore_info) |
605 | ||
606 |
5 | 5 | """ |
6 | 6 | import socket |
7 | 7 | import json |
8 | import dateutil | |
9 | from collections import defaultdict | |
8 | 10 | from urllib.parse import urlparse |
9 | 11 | from faraday_plugins.plugins.plugin import PluginMultiLineJsonFormat |
10 | 12 | from faraday_plugins.plugins.plugins_utils import resolve_hostname |
11 | 13 | |
12 | __author__ = "Blas Moyano" | |
13 | __copyright__ = "Copyright (c) 2020, Infobyte LLC" | |
14 | __credits__ = ["Blas Moyano"] | |
14 | __author__ = "Nicolas Rebagliati" | |
15 | __copyright__ = "Copyright (c) 2021, Infobyte LLC" | |
16 | __credits__ = ["Nicolas Rebagliati"] | |
15 | 17 | __license__ = "" |
16 | 18 | __version__ = "0.0.1" |
17 | __maintainer__ = "Blas Moyano" | |
18 | __email__ = "[email protected]" | |
19 | __maintainer__ = "Nicolas Rebagliati" | |
20 | __email__ = "[email protected]" | |
19 | 21 | __status__ = "Development" |
20 | ||
21 | ||
22 | class NucleiJsonParser: | |
23 | ||
24 | def __init__(self, json_output): | |
25 | self.list_to_vulns = json_output.split("\n") | |
26 | 22 | |
27 | 23 | |
28 | 24 | class NucleiPlugin(PluginMultiLineJsonFormat): |
35 | 31 | self.id = "nuclei" |
36 | 32 | self.name = "Nuclei" |
37 | 33 | self.plugin_version = "0.1" |
38 | self.version = "0.0.1" | |
39 | self.json_keys = {"matched", "template"} | |
34 | self.version = "2.3.0" | |
35 | self.json_keys = {"matched", "templateID", "host"} | |
40 | 36 | |
41 | 37 | def parseOutputString(self, output, debug=False): |
42 | parser = NucleiJsonParser(output) | |
43 | matched_list = [] | |
44 | matched_json = {} | |
45 | for vuln in parser.list_to_vulns: | |
46 | if vuln != '': | |
47 | json_vuln = json.loads(vuln) | |
48 | matched = json_vuln.get('matched', None) | |
49 | ||
50 | if matched is not None: | |
51 | url_parser = urlparse(matched) | |
52 | url_scheme = f'{url_parser.scheme}://{url_parser.hostname}' | |
53 | ||
54 | if url_scheme in matched_list: | |
55 | matched_json[url_scheme].append(json_vuln) | |
56 | else: | |
57 | matched_list.append(url_scheme) | |
58 | matched_json[url_scheme] = [json_vuln] | |
59 | ||
60 | for url in matched_list: | |
61 | url_data = urlparse(url) | |
62 | url_name = url_data.hostname | |
63 | url_protocol = url_data.scheme | |
64 | ip = resolve_hostname(url_name) | |
38 | for vuln_json in filter(lambda x: x != '', output.split("\n")): | |
39 | vuln_dict = json.loads(vuln_json) | |
40 | host = vuln_dict.get('host') | |
41 | url_data = urlparse(host) | |
42 | ip = vuln_dict.get("ip", resolve_hostname(url_data.hostname)) | |
65 | 43 | host_id = self.createAndAddHost( |
66 | 44 | name=ip, |
67 | hostnames=[url_name]) | |
68 | port = 80 | |
69 | if url_parser.scheme == 'https': | |
70 | port = 443 | |
71 | ||
45 | hostnames=[url_data.hostname]) | |
46 | port = url_data.port | |
47 | if not port: | |
48 | if url_data.scheme == 'https': | |
49 | port = 443 | |
50 | else: | |
51 | port = 80 | |
72 | 52 | service_id = self.createAndAddServiceToHost( |
73 | 53 | host_id, |
74 | name=url_parser.scheme, | |
54 | name=url_data.scheme, | |
75 | 55 | ports=port, |
76 | 56 | protocol="tcp", |
77 | 57 | status='open', |
78 | 58 | version='', |
79 | description='') | |
59 | description='web server') | |
60 | matched = vuln_dict.get('matched') | |
61 | matched_data = urlparse(matched) | |
62 | references = [f"author: {vuln_dict['info'].get('author', '')}"] | |
63 | request = vuln_dict.get('request', '') | |
64 | if request: | |
65 | method = request.split(" ")[0] | |
66 | else: | |
67 | method = "" | |
68 | data = [f"Matched: {vuln_dict.get('matched')}", | |
69 | f"Tags: {vuln_dict['info'].get('tags')}", | |
70 | f"Template ID: {vuln_dict['templateID']}"] | |
80 | 71 | |
81 | for info_vuln in matched_json[url]: | |
82 | desc = f'{info_vuln.get("template", None)} - {info_vuln.get("author", None)}' | |
83 | if info_vuln.get("author", None): | |
84 | ref = [f"author: {info_vuln.get('author', None)}"] | |
85 | else: | |
86 | ref = None | |
87 | self.createAndAddVulnWebToService( | |
88 | host_id, | |
89 | service_id, | |
90 | name=info_vuln.get('template', ""), | |
91 | desc=info_vuln.get('description', info_vuln.get('name', None)), | |
92 | ref=ref, | |
93 | severity=info_vuln.get('severity', ""), | |
94 | website=url, | |
95 | request=info_vuln.get('request', None), | |
96 | response=info_vuln.get('response', None), | |
97 | method=info_vuln.get('type', None), | |
98 | data=info_vuln.get('matcher_name', info_vuln.get('name', None)), | |
99 | external_id=info_vuln.get('template', "")) | |
72 | name = vuln_dict["info"].get("name") | |
73 | run_date = vuln_dict.get('timestamp') | |
74 | if run_date: | |
75 | run_date = dateutil.parser.parse(run_date) | |
76 | self.createAndAddVulnWebToService( | |
77 | host_id, | |
78 | service_id, | |
79 | name=name, | |
80 | desc=vuln_dict["info"].get("description", name), | |
81 | ref=references, | |
82 | severity=vuln_dict["info"].get('severity'), | |
83 | website=host, | |
84 | request=request, | |
85 | response=vuln_dict.get('response', ''), | |
86 | method=method, | |
87 | query=matched_data.query, | |
88 | params=matched_data.params, | |
89 | path=matched_data.path, | |
90 | data="\n".join(data), | |
91 | external_id=f"NUCLEI-{vuln_dict.get('templateID', '')}", | |
92 | run_date=run_date | |
93 | ) | |
94 | ||
95 | ||
100 | 96 | |
101 | 97 | |
102 | 98 | def createPlugin(ignore_info=False): |
4 | 4 | Copyright (C) 2020 Infobyte LLC (http://www.infobytesec.com/) |
5 | 5 | See the file 'doc/LICENSE' for the license information |
6 | 6 | """ |
7 | import ipaddress | |
8 | from datetime import datetime | |
9 | ||
10 | from lxml import etree | |
11 | ||
7 | 12 | from faraday_plugins.plugins.plugin import PluginXMLFormat |
8 | from datetime import datetime | |
9 | from lxml import etree | |
10 | import ipaddress | |
11 | ||
12 | try: | |
13 | import xml.etree.cElementTree as ET | |
14 | except ImportError: | |
15 | import xml.etree.ElementTree as ET | |
16 | 13 | |
17 | 14 | __author__ = 'Blas Moyano' |
18 | 15 | __copyright__ = 'Copyright 2020, Faraday Project' |
0 | import re | |
1 | from collections import defaultdict | |
2 | from copy import copy | |
3 | ||
0 | 4 | """ |
1 | 5 | Faraday Penetration Test IDE |
2 | 6 | Copyright (C) 2013 Infobyte LLC (http://www.infobytesec.com/) |
3 | 7 | See the file 'doc/LICENSE' for the license information |
4 | 8 | |
5 | 9 | """ |
6 | import re | |
7 | from collections import defaultdict | |
8 | from copy import copy | |
9 | ||
10 | try: | |
11 | import xml.etree.cElementTree as ET | |
12 | import xml.etree.ElementTree as ET_ORIG | |
13 | ETREE_VERSION = ET_ORIG.VERSION | |
14 | except ImportError: | |
15 | import xml.etree.ElementTree as ET | |
16 | ETREE_VERSION = ET.VERSION | |
17 | 10 | |
18 | 11 | from faraday_plugins.plugins.plugin import PluginXMLFormat |
19 | 12 | from faraday_plugins.plugins.plugins_utils import filter_services |
20 | 13 | |
21 | ETREE_VERSION = [int(i) for i in ETREE_VERSION.split(".")] | |
22 | ||
14 | import xml.etree.ElementTree as ET | |
23 | 15 | |
24 | 16 | __author__ = "Francisco Amato" |
25 | 17 | __copyright__ = "Copyright (c) 2013, Infobyte LLC" |
135 | 127 | |
136 | 128 | @return An attribute value |
137 | 129 | """ |
138 | global ETREE_VERSION | |
139 | node = None | |
140 | ||
141 | if ETREE_VERSION[0] <= 1 and ETREE_VERSION[1] < 3: | |
142 | ||
143 | match_obj = re.search( | |
144 | "([^\@]+?)\[\@([^=]*?)=\'([^\']*?)\'", | |
145 | subnode_xpath_expr) | |
146 | ||
147 | if match_obj is not None: | |
148 | node_to_find = match_obj.group(1) | |
149 | xpath_attrib = match_obj.group(2) | |
150 | xpath_value = match_obj.group(3) | |
151 | for node_found in xml_node.findall(node_to_find): | |
152 | if node_found.attrib[xpath_attrib] == xpath_value: | |
153 | node = node_found | |
154 | break | |
155 | else: | |
156 | node = xml_node.find(subnode_xpath_expr) | |
157 | ||
158 | else: | |
159 | node = xml_node.find(subnode_xpath_expr) | |
130 | ||
131 | node = xml_node.find(subnode_xpath_expr) | |
160 | 132 | |
161 | 133 | if node is not None: |
162 | 134 | return node.get(attrib_name) |
335 | 307 | with open(report_path) as f: |
336 | 308 | output = f.read() |
337 | 309 | return re.search("OpenVAS", output) is not None \ |
338 | or re.search('<omp>', output) is not None\ | |
310 | or re.search('<omp>', output) is not None \ | |
339 | 311 | or re.search('<owner>', output) is not None |
340 | 312 | return False |
341 | 313 | |
442 | 414 | else: |
443 | 415 | return False |
444 | 416 | |
445 | def setHost(self): | |
446 | pass | |
447 | ||
448 | 417 | |
449 | 418 | def createPlugin(ignore_info=False): |
450 | 419 | return OpenvasPlugin(ignore_info=ignore_info) |
451 | ||
452 |
3 | 3 | See the file 'doc/LICENSE' for the license information |
4 | 4 | |
5 | 5 | """ |
6 | import re | |
7 | ||
6 | 8 | from faraday_plugins.plugins.plugin import PluginBase |
7 | import re | |
8 | 9 | |
9 | 10 | __author__ = "Facundo de Guzmán, Esteban Guillardoy" |
10 | 11 | __copyright__ = "Copyright (c) 2013, Infobyte LLC" |
34 | 35 | |
35 | 36 | reg = re.search(r"PING ([\w\.-:]+)( |)\(([\w\.:]+)\)", output) |
36 | 37 | if re.search("0 received|unknown host", output) is None and reg is not None: |
37 | ||
38 | 38 | ip_address = reg.group(3) |
39 | 39 | hostname = reg.group(1) |
40 | h_id = self.createAndAddHost(ip_address, hostnames=[hostname]) | |
40 | self.createAndAddHost(ip_address, hostnames=[hostname]) | |
41 | 41 | return True |
42 | 42 | |
43 | 43 | def _isIPV4(self, ip): |
47 | 47 | return False |
48 | 48 | |
49 | 49 | |
50 | ||
51 | 50 | def createPlugin(ignore_info=False): |
52 | 51 | return CmdPingPlugin(ignore_info=ignore_info) |
53 | ||
54 | ||
55 |
3 | 3 | See the file 'doc/LICENSE' for the license information |
4 | 4 | """ |
5 | 5 | import re |
6 | import xml.etree.ElementTree as ET | |
7 | ||
6 | 8 | from faraday_plugins.plugins.plugin import PluginXMLFormat |
7 | ||
8 | import xml.etree.ElementTree as ET | |
9 | ETREE_VERSION = ET.VERSION | |
10 | ||
11 | ETREE_VERSION = [int(i) for i in ETREE_VERSION.split('.')] | |
12 | ||
13 | 9 | |
14 | 10 | __author__ = 'Francisco Amato' |
15 | 11 | __copyright__ = 'Copyright (c) 2013, Infobyte LLC' |
349 | 345 | |
350 | 346 | parser = QualysguardXmlParser(output) |
351 | 347 | |
352 | ||
353 | 348 | for item in parser.items: |
354 | 349 | h_id = self.createAndAddHost( |
355 | 350 | item.ip, |
414 | 409 | del parser |
415 | 410 | |
416 | 411 | |
417 | def setHost(self): | |
418 | pass | |
419 | ||
420 | ||
421 | 412 | def createPlugin(ignore_info=False): |
422 | 413 | return QualysguardPlugin(ignore_info=ignore_info) |
423 | ||
424 |
4 | 4 | Copyright (C) 2016 Infobyte LLC (http://www.infobytesec.com/) |
5 | 5 | See the file 'doc/LICENSE' for the license information |
6 | 6 | """ |
7 | import re | |
7 | import xml.etree.ElementTree as ET | |
8 | 8 | from urllib.parse import urlparse |
9 | 9 | |
10 | 10 | from dateutil.parser import parse |
11 | 11 | |
12 | 12 | from faraday_plugins.plugins.plugin import PluginXMLFormat |
13 | ||
14 | try: | |
15 | import xml.etree.cElementTree as ET | |
16 | except ImportError: | |
17 | import xml.etree.ElementTree as ET | |
18 | 13 | |
19 | 14 | __author__ = 'Blas Moyano' |
20 | 15 | __copyright__ = 'Copyright 2020, Faraday Project' |
79 | 74 | class Glossary(): |
80 | 75 | def __init__(self, glossary_tags): |
81 | 76 | self.lista_qid = self.get_qid_list(glossary_tags) |
82 | ||
83 | 77 | |
84 | 78 | def get_qid_list(self, qid_list_tags): |
85 | 79 | self.dict_result_qid = {} |
4 | 4 | |
5 | 5 | """ |
6 | 6 | import re |
7 | import xml.etree.ElementTree as ET | |
8 | ||
7 | 9 | from faraday_plugins.plugins.plugin import PluginXMLFormat |
8 | ||
9 | ||
10 | try: | |
11 | import xml.etree.cElementTree as ET | |
12 | import xml.etree.ElementTree as ET_ORIG | |
13 | ETREE_VERSION = ET_ORIG.VERSION | |
14 | except ImportError: | |
15 | import xml.etree.ElementTree as ET | |
16 | ETREE_VERSION = ET.VERSION | |
17 | ||
18 | ETREE_VERSION = [int(i) for i in ETREE_VERSION.split(".")] | |
19 | ||
20 | 10 | |
21 | 11 | __author__ = "Francisco Amato" |
22 | 12 | __copyright__ = "Copyright (c) 2013, Infobyte LLC" |
42 | 32 | def __init__(self, xml_output): |
43 | 33 | tree = self.parse_xml(xml_output) |
44 | 34 | if tree: |
45 | self.items = [data for data in self.get_items(tree)] | |
35 | self.items = self.get_items(tree) | |
46 | 36 | else: |
47 | 37 | self.items = [] |
48 | 38 | |
116 | 106 | return None |
117 | 107 | |
118 | 108 | |
119 | class Results(): | |
109 | class Results: | |
120 | 110 | |
121 | 111 | def __init__(self, issue_node): |
122 | 112 | self.node = issue_node |
181 | 171 | self.framework_version = "1.0.0" |
182 | 172 | self.options = None |
183 | 173 | |
184 | ||
185 | 174 | def parseOutputString(self, output): |
186 | 175 | |
187 | 176 | parser = RetinaXmlParser(output) |
188 | 177 | for item in parser.items: |
189 | 178 | hostname = item.hostname if item.hostname else None |
190 | h_id = self.createAndAddHost(item.ip, item.os,hostnames=[hostname]) | |
179 | h_id = self.createAndAddHost(item.ip, item.os, hostnames=[hostname]) | |
191 | 180 | |
192 | 181 | if not item.netbiosname == 'N/A': |
193 | 182 | self.createAndAddNoteToHost( |
222 | 211 | del parser |
223 | 212 | |
224 | 213 | |
225 | def setHost(self): | |
226 | pass | |
227 | ||
228 | ||
229 | 214 | def createPlugin(ignore_info=False): |
230 | 215 | return RetinaPlugin(ignore_info=ignore_info) |
231 | ||
232 |
147 | 147 | p = SkipfishParser(self._output_file_path) |
148 | 148 | |
149 | 149 | hostc = {} |
150 | port = 80 | |
151 | 150 | for issue in p.issues: |
152 | req = "" | |
153 | res = "" | |
154 | 151 | for sample in issue["samples"]: |
155 | 152 | if not sample["url"] in hostc: |
156 | 153 | reg = re.search( |
175 | 172 | 'host': host, |
176 | 173 | 'protocol': protocol, |
177 | 174 | 's_id': s_id} |
178 | ||
179 | try: | |
180 | req = open("%s/request.dat" % sample["dir"], "r").read() | |
181 | except: | |
182 | pass | |
183 | ||
184 | try: | |
185 | res = open("%s/request.dat" % sample["dir"], "r").read() | |
186 | except Exception: | |
187 | pass | |
188 | 175 | |
189 | 176 | d = hostc[sample["url"]] |
190 | 177 | self.createAndAddVulnWebToService( |
213 | 200 | else: |
214 | 201 | return re.sub(arg_match.group(1), r"-o %s" % self._output_file_path, command_string, 1) |
215 | 202 | |
216 | def setHost(self): | |
217 | pass | |
203 | ||
218 | 204 | |
219 | 205 | |
220 | 206 | def createPlugin(ignore_info=False): |
0 | """ | |
1 | Faraday Penetration Test IDE | |
2 | Copyright (C) 2013 Infobyte LLC (http://www.infobytesec.com/) | |
3 | See the file 'doc/LICENSE' for the license information | |
4 | """⏎ |
0 | """ | |
1 | Faraday Penetration Test IDE | |
2 | Copyright (C) 2021 Infobyte LLC (http://www.infobytesec.com/) | |
3 | See the file 'doc/LICENSE' for the license information | |
4 | ||
5 | """ | |
6 | import json | |
7 | from faraday_plugins.plugins.plugin import PluginJsonFormat | |
8 | from datetime import datetime | |
9 | import dateutil | |
10 | ||
11 | VULNERABILITY = "VULNERABILITY" | |
12 | ||
13 | # ATTENTION: The following mappings are created following the common sense in order to integrate F! with SQ. You | |
14 | # can see what term means in the following website: https://docs.sonarqube.org/latest/user-guide/issues/ | |
15 | SEVERITIES = { | |
16 | 'INFO': 'unclassified', | |
17 | 'MINOR': 'low', | |
18 | 'MAJOR': 'medium', | |
19 | 'CRITICAL': 'high', | |
20 | 'BLOCKER': 'critical' | |
21 | } | |
22 | STATUSES = { | |
23 | 'OPEN': 'open', | |
24 | 'CONFIRMED': 'opened', | |
25 | 'REOPENED': 're-opened', | |
26 | 'CLOSED': 'closed', | |
27 | 'RESOLVED': 'closed' | |
28 | } | |
29 | ||
30 | ||
31 | class SonarQubeAPIParser: | |
32 | def __init__(self, json_output): | |
33 | json_data = json.loads(json_output) | |
34 | ||
35 | self.vulns = self._parse_vulns(json_data) | |
36 | ||
37 | def _parse_vulns(self, json_data): | |
38 | vulns = [] | |
39 | components = {item['key']: | |
40 | {'name': item['name'], 'longName': item['longName']} | |
41 | for item in json_data['components'] } | |
42 | for issue in json_data['issues']: | |
43 | if issue['type'] != VULNERABILITY: | |
44 | continue | |
45 | ||
46 | component = issue['component'] | |
47 | path = components[component]['longName'] | |
48 | vuln_description = f"Issue found in line {issue['line']} of {path}" | |
49 | project = f"Project: {issue['project']}" | |
50 | severity = SEVERITIES[issue['severity']] | |
51 | message = issue['message'] | |
52 | status = STATUSES[issue['status']] | |
53 | tags = issue['tags'] | |
54 | external_id = issue['rule'] | |
55 | creation_date = dateutil.parser.parse(issue['creationDate']) | |
56 | data = [] if not issue['flows'] else ["Flows:"] | |
57 | for flow in issue['flows']: | |
58 | for location in flow['locations']: | |
59 | location_message = f"\"{location['msg']}\" in line {location['textRange']['startLine']} " \ | |
60 | f"of {components[component]['longName']}" | |
61 | data.append(location_message) | |
62 | vulns.append( | |
63 | {'name': message, 'description': vuln_description, 'project': project, 'path': path, 'severity': severity, 'status': status, 'tags': tags, | |
64 | 'creation_date': creation_date, 'data': "\n".join(data), 'external_id': external_id}) | |
65 | ||
66 | return vulns | |
67 | ||
68 | ||
69 | class SonarQubeAPIPlugin(PluginJsonFormat): | |
70 | def __init__(self, *arg, **kwargs): | |
71 | super().__init__(*arg, **kwargs) | |
72 | self.json_keys = {'total', 'effortTotal', 'issues', 'components', 'facets'} | |
73 | self.id = "sonarqubeAPI" | |
74 | self.name = "SonarQube API Plugin" | |
75 | self.plugin_version = "0.0.1" | |
76 | ||
77 | ||
78 | def parseOutputString(self, output, debug=False): | |
79 | parser = SonarQubeAPIParser(output) | |
80 | for vuln in parser.vulns: | |
81 | host_id = self.createAndAddHost(vuln['path'], description=vuln['project']) | |
82 | ||
83 | self.createAndAddVulnToHost( | |
84 | host_id=host_id, | |
85 | name=vuln['name'], | |
86 | desc=vuln['description'], | |
87 | status=vuln['status'], | |
88 | run_date=vuln['creation_date'], | |
89 | severity=vuln['severity'], | |
90 | tags=vuln['tags'], | |
91 | data=vuln['data'], | |
92 | external_id=vuln['external_id'] | |
93 | ) | |
94 | ||
95 | ||
96 | def createPlugin(ignore_info=False): | |
97 | return SonarQubeAPIPlugin(ignore_info=ignore_info) |
6 | 6 | import re |
7 | 7 | import json |
8 | 8 | from faraday_plugins.plugins.plugin import PluginJsonFormat |
9 | from faraday_plugins.plugins.plugins_utils import resolve_hostname | |
9 | 10 | |
10 | 11 | __author__ = "Blas Moyano" |
11 | 12 | __copyright__ = "Copyright (c) 2020, Infobyte LLC" |
70 | 71 | |
71 | 72 | def get_host(self, server_location): |
72 | 73 | port = server_location.get('port', None) |
73 | protocol = '' | |
74 | if port is not None: | |
75 | if port == 443: | |
76 | protocol = 'https' | |
77 | else: | |
78 | protocol = 'http' | |
74 | hostname = server_location.get('hostname', None) | |
75 | ip = server_location.get('ip_address', resolve_hostname(hostname)) | |
79 | 76 | |
80 | 77 | json_host = { |
81 | "url": server_location.get('hostname', None), | |
82 | "ip": server_location.get('ip_address', '0.0.0.0'), | |
78 | "name": 'https', | |
79 | "ip": ip, | |
80 | "hostname": hostname, | |
83 | 81 | "port": port, |
84 | "protocol": protocol | |
82 | "protocol": 'tcp' | |
85 | 83 | } |
86 | 84 | |
87 | 85 | return json_host |
177 | 175 | parser = SslyzeJsonParser(output) |
178 | 176 | |
179 | 177 | for info_sslyze in parser.list_vul: |
180 | info_sslyze['host_info'].get('url') | |
178 | info_sslyze['host_info'].get('hostname') | |
181 | 179 | host_id = self.createAndAddHost( |
182 | 180 | info_sslyze['host_info'].get('ip'), |
183 | 181 | os="unknown", |
184 | 182 | hostnames=[ |
185 | info_sslyze['host_info'].get('url') | |
183 | info_sslyze['host_info'].get('hostname') | |
186 | 184 | ] |
187 | 185 | ) |
188 | 186 | service_id = self.createAndAddServiceToHost( |
189 | 187 | host_id, |
190 | name=info_sslyze['host_info'].get('protocol'), | |
188 | name=info_sslyze['host_info'].get('name'), | |
191 | 189 | protocol=info_sslyze['host_info'].get('protocol'), |
192 | 190 | ports=[ |
193 | 191 | info_sslyze['host_info'].get('port') |
4 | 4 | |
5 | 5 | """ |
6 | 6 | import re |
7 | import xml.etree.ElementTree as ET | |
7 | 8 | from urllib.parse import urlparse |
9 | ||
8 | 10 | from faraday_plugins.plugins.plugin import PluginXMLFormat |
9 | 11 | from faraday_plugins.plugins.plugins_utils import resolve_hostname |
10 | ||
11 | try: | |
12 | import xml.etree.cElementTree as ET | |
13 | import xml.etree.ElementTree as ET_ORIG | |
14 | ETREE_VERSION = ET_ORIG.VERSION | |
15 | except ImportError: | |
16 | import xml.etree.ElementTree as ET | |
17 | ETREE_VERSION = ET.VERSION | |
18 | ||
19 | ETREE_VERSION = [int(i) for i in ETREE_VERSION.split(".")] | |
20 | ||
21 | 12 | |
22 | 13 | __author__ = "Francisco Amato" |
23 | 14 | __copyright__ = "Copyright (c) 2013, Infobyte LLC" |
72 | 63 | """ |
73 | 64 | @return items A list of Host instances |
74 | 65 | """ |
75 | bugtype = "" | |
76 | 66 | |
77 | 67 | if len(tree.findall('scan-info')) == 0: |
78 | 68 | scaninfo = tree.findall('scaninfo')[0] |
103 | 93 | |
104 | 94 | @return An attribute value |
105 | 95 | """ |
106 | global ETREE_VERSION | |
107 | node = None | |
108 | ||
109 | if ETREE_VERSION[0] <= 1 and ETREE_VERSION[1] < 3: | |
110 | ||
111 | match_obj = re.search( | |
112 | "([^\@]+?)\[\@([^=]*?)=\'([^\']*?)\'", subnode_xpath_expr) | |
113 | if match_obj is not None: | |
114 | node_to_find = match_obj.group(1) | |
115 | xpath_attrib = match_obj.group(2) | |
116 | xpath_value = match_obj.group(3) | |
117 | for node_found in xml_node.findall(node_to_find): | |
118 | if node_found.attrib[xpath_attrib] == xpath_value: | |
119 | node = node_found | |
120 | break | |
121 | else: | |
122 | node = xml_node.find(subnode_xpath_expr) | |
123 | ||
124 | else: | |
125 | node = xml_node.find(subnode_xpath_expr) | |
96 | node = xml_node.find(subnode_xpath_expr) | |
126 | 97 | |
127 | 98 | if node is not None: |
128 | 99 | return node.get(attrib_name) |
225 | 196 | } |
226 | 197 | |
227 | 198 | def parseOutputString(self, output): |
228 | ||
229 | 199 | parser = W3afXmlParser(output) |
230 | 200 | ip = resolve_hostname(parser.host) |
231 | 201 | h_id = self.createAndAddHost(ip, hostnames=[parser.host]) |
232 | 202 | s_id = self.createAndAddServiceToHost(h_id, "http", "tcp", ports=[parser.port], status="open") |
233 | 203 | |
234 | 204 | for item in parser.items: |
235 | v_id = self.createAndAddVulnWebToService(h_id, s_id, item.name, | |
205 | self.createAndAddVulnWebToService(h_id, s_id, item.name, | |
236 | 206 | item.detail, pname=item.param, path=item.url, website=parser.host, |
237 | 207 | severity=item.severity, method=item.method, request=item.req, |
238 | 208 | resolution=item.resolution, ref=item.ref, response=item.resp) |
239 | 209 | del parser |
240 | 210 | |
241 | 211 | |
242 | ||
243 | 212 | def createPlugin(ignore_info=False): |
244 | 213 | return W3afPlugin(ignore_info=ignore_info) |
245 | ||
246 |
4 | 4 | |
5 | 5 | """ |
6 | 6 | import re |
7 | import xml.etree.ElementTree as ET | |
7 | 8 | from urllib.parse import urlparse |
9 | ||
8 | 10 | from faraday_plugins.plugins.plugin import PluginXMLFormat |
9 | 11 | from faraday_plugins.plugins.plugins_utils import resolve_hostname |
10 | ||
11 | try: | |
12 | import xml.etree.cElementTree as ET | |
13 | import xml.etree.ElementTree as ET_ORIG | |
14 | ETREE_VERSION = ET_ORIG.VERSION | |
15 | except ImportError: | |
16 | import xml.etree.ElementTree as ET | |
17 | ETREE_VERSION = ET.VERSION | |
18 | ||
19 | ETREE_VERSION = [int(i) for i in ETREE_VERSION.split(".")] | |
20 | ||
21 | 12 | |
22 | 13 | __author__ = "Francisco Amato" |
23 | 14 | __copyright__ = "Copyright (c) 2013, Infobyte LLC" |
72 | 63 | yield Item(tree) |
73 | 64 | |
74 | 65 | |
75 | ||
76 | 66 | def get_attrib_from_subnode(xml_node, subnode_xpath_expr, attrib_name): |
77 | 67 | """ |
78 | 68 | Finds a subnode in the item node and the retrieves a value from it |
79 | 69 | |
80 | 70 | @return An attribute value |
81 | 71 | """ |
82 | global ETREE_VERSION | |
83 | node = None | |
84 | ||
85 | if ETREE_VERSION[0] <= 1 and ETREE_VERSION[1] < 3: | |
86 | match_obj = re.search( | |
87 | "([^\@]+?)\[\@([^=]*?)=\'([^\']*?)\'", subnode_xpath_expr) | |
88 | if match_obj is not None: | |
89 | node_to_find = match_obj.group(1) | |
90 | xpath_attrib = match_obj.group(2) | |
91 | xpath_value = match_obj.group(3) | |
92 | for node_found in xml_node.findall(node_to_find): | |
93 | if node_found.attrib[xpath_attrib] == xpath_value: | |
94 | node = node_found | |
95 | break | |
96 | else: | |
97 | node = xml_node.find(subnode_xpath_expr) | |
98 | else: | |
99 | node = xml_node.find(subnode_xpath_expr) | |
72 | ||
73 | node = xml_node.find(subnode_xpath_expr) | |
100 | 74 | if node is not None: |
101 | 75 | return node.get(attrib_name) |
102 | 76 | return None |
147 | 121 | target = self.get_info(item_node, 'target') |
148 | 122 | return urlparse(target) |
149 | 123 | |
150 | def get_info(self, item_node,name): | |
124 | def get_info(self, item_node, name): | |
151 | 125 | path = item_node.findall('report_infos/info') |
152 | 126 | |
153 | 127 | for item in path: |
170 | 144 | for vuln in vulns_node: |
171 | 145 | vulns_dict = {} |
172 | 146 | vulns_dict['id'] = vuln.attrib['name'] |
173 | vulns_dict['description'] = self.get_text_from_subnode(vuln,'description') | |
174 | vulns_dict['solution'] = self.get_text_from_subnode(vuln,'solution') | |
147 | vulns_dict['description'] = self.get_text_from_subnode(vuln, 'description') | |
148 | vulns_dict['solution'] = self.get_text_from_subnode(vuln, 'solution') | |
175 | 149 | vulns_dict['references'] = self.get_references(vuln) |
176 | 150 | vulns_dict['entries'] = self.get_entries(vuln) |
177 | 151 | vulns_list.append(vulns_dict) |
182 | 156 | refs = node.findall('references/reference') |
183 | 157 | references_list = [] |
184 | 158 | for ref in refs: |
185 | references_list.append('Title: ' + self.get_text_from_subnode(ref,'title')) | |
186 | references_list.append('URL: ' + self.get_text_from_subnode(ref,'url')) | |
159 | references_list.append('Title: ' + self.get_text_from_subnode(ref, 'title')) | |
160 | references_list.append('URL: ' + self.get_text_from_subnode(ref, 'url')) | |
187 | 161 | |
188 | 162 | return references_list |
189 | 163 | |
190 | def get_entries(self,node): | |
164 | def get_entries(self, node): | |
191 | 165 | entries = node.findall('entries/entry') |
192 | 166 | entries_list = [] |
193 | 167 | for entry in entries: |
194 | 168 | entries_dict = {} |
195 | entries_dict['method'] = self.get_text_from_subnode(entry,'method') | |
196 | entries_dict['path'] = self.get_text_from_subnode(entry,'path') | |
169 | entries_dict['method'] = self.get_text_from_subnode(entry, 'method') | |
170 | entries_dict['path'] = self.get_text_from_subnode(entry, 'path') | |
197 | 171 | entries_dict['level'] = self.severity_format(entry) |
198 | entries_dict['parameter'] = self.get_text_from_subnode(entry,'parameter') | |
199 | entries_dict['http_request'] = self.get_text_from_subnode(entry,'http_request') | |
200 | entries_dict['curl_command'] = self.get_text_from_subnode(entry,'curl_command') | |
172 | entries_dict['parameter'] = self.get_text_from_subnode(entry, 'parameter') | |
173 | entries_dict['http_request'] = self.get_text_from_subnode(entry, 'http_request') | |
174 | entries_dict['curl_command'] = self.get_text_from_subnode(entry, 'curl_command') | |
201 | 175 | entries_list.append(entries_dict) |
202 | 176 | |
203 | 177 | return entries_list |
288 | 262 | return re.search("Wapiti", output) is not None |
289 | 263 | return False |
290 | 264 | |
291 | ||
292 | 265 | def parseOutputString(self, output): |
293 | 266 | """ |
294 | 267 | This method will discard the output the shell sends, it will read it from |
295 | 268 | the xml where it expects it to be present. |
296 | 269 | """ |
297 | ||
270 | ||
298 | 271 | parser = WapitiXmlParser(output) |
299 | 272 | for item in parser.items: |
300 | 273 | host_id = self.createAndAddHost(item.ip, hostnames=[item.hostname]) |
306 | 279 | for vuln in item.vulns: |
307 | 280 | for entry in vuln['entries']: |
308 | 281 | vuln_id = self.createAndAddVulnWebToService(host_id, |
309 | service_id, | |
310 | vuln['id'], | |
311 | desc=vuln['description'], | |
312 | ref=vuln['references'], | |
313 | resolution=vuln['solution'], | |
314 | severity=entry['level'], | |
315 | website=entry['curl_command'], | |
316 | path=entry['path'], | |
317 | request=entry['http_request'], | |
318 | method=entry['method'], | |
319 | params=entry['parameter']) | |
282 | service_id, | |
283 | vuln['id'], | |
284 | desc=vuln['description'], | |
285 | ref=vuln['references'], | |
286 | resolution=vuln['solution'], | |
287 | severity=entry['level'], | |
288 | website=entry['curl_command'], | |
289 | path=entry['path'], | |
290 | request=entry['http_request'], | |
291 | method=entry['method'], | |
292 | params=entry['parameter']) | |
320 | 293 | |
321 | 294 | def processCommandString(self, username, current_path, command_string): |
322 | 295 | """ |
338 | 311 | self.port = host.group(11) |
339 | 312 | if self.protocol == 'https': |
340 | 313 | self.port = 443 |
341 | self.logger.debug("host = %s, port = %s",self.host, self.port) | |
314 | self.logger.debug("host = %s, port = %s", self.host, self.port) | |
342 | 315 | return "%s -o %s -f xml \n" % (command_string, self._output_file_path) |
343 | ||
344 | def setHost(self): | |
345 | pass | |
346 | 316 | |
347 | 317 | |
348 | 318 | def createPlugin(ignore_info=False): |
349 | 319 | return WapitiPlugin(ignore_info=ignore_info) |
350 | ||
351 |
2 | 2 | Copyright (C) 2013 Infobyte LLC (http://www.infobytesec.com/) |
3 | 3 | See the file 'doc/LICENSE' for the license information |
4 | 4 | """ |
5 | import re | |
6 | import xml.etree.ElementTree as ET | |
7 | ||
5 | 8 | from faraday_plugins.plugins.plugin import PluginBase |
6 | import re | |
7 | import os | |
8 | import sys | |
9 | import random | |
10 | ||
11 | try: | |
12 | import xml.etree.cElementTree as ET | |
13 | import xml.etree.ElementTree as ET_ORIG | |
14 | ETREE_VERSION = ET_ORIG.VERSION | |
15 | except ImportError: | |
16 | import xml.etree.ElementTree as ET | |
17 | ETREE_VERSION = ET.VERSION | |
18 | ||
19 | ETREE_VERSION = [int(i) for i in ETREE_VERSION.split(".")] | |
20 | ||
21 | 9 | |
22 | 10 | __author__ = "Morgan Lemarechal" |
23 | 11 | __copyright__ = "Copyright 2014, Faraday Project" |
91 | 79 | self._temp_file_extension = "xml" |
92 | 80 | self.xml_arg_re = re.compile(r"^.*(--xml\s*[^\s]+).*$") |
93 | 81 | |
94 | ||
95 | 82 | def parseOutputString(self, output): |
96 | 83 | """ |
97 | 84 | This method will discard the output the shell sends, it will read it from |
114 | 101 | if parser.scaninfo[file]['type'] == "webconfig": |
115 | 102 | vuln_name = f"{parser.scaninfo[file]['file']}: {str(parser.result[file][vuln][3])}" |
116 | 103 | vuln_description = f"{str(parser.result[file][vuln][3])} : {str(parser.result[file][vuln][2])} = {str(parser.result[file][vuln][0])}\n{str(parser.result[file][vuln][1])}" |
117 | v_id = self.createAndAddVulnToService(h_id, s_id, vuln_name, desc=vuln_description, severity=0) | |
118 | ||
119 | ||
104 | self.createAndAddVulnToService(h_id, s_id, vuln_name, desc=vuln_description, severity=0) | |
120 | 105 | |
121 | 106 | def processCommandString(self, username, current_path, command_string): |
122 | 107 | """ |
134 | 119 | |
135 | 120 | def createPlugin(ignore_info=False): |
136 | 121 | return WcscanPlugin(ignore_info=ignore_info) |
137 | ||
138 |
7 | 7 | from faraday_plugins.plugins.plugin import PluginXMLFormat |
8 | 8 | from faraday_plugins.plugins.plugins_utils import get_vulnweb_url_fields |
9 | 9 | |
10 | try: | |
11 | import xml.etree.cElementTree as ET | |
12 | except ImportError: | |
13 | import xml.etree.ElementTree as ET | |
10 | import xml.etree.ElementTree as ET | |
14 | 11 | |
15 | 12 | |
16 | 13 | def cleanhtml(raw_html): |
3 | 3 | See the file 'doc/LICENSE' for the license information |
4 | 4 | |
5 | 5 | """ |
6 | import os | |
7 | import re | |
8 | import xml.etree.ElementTree as ET | |
9 | ||
6 | 10 | from faraday_plugins.plugins.plugin import PluginXMLFormat |
7 | import re | |
8 | import os | |
9 | import sys | |
10 | ||
11 | try: | |
12 | import xml.etree.cElementTree as ET | |
13 | import xml.etree.ElementTree as ET_ORIG | |
14 | ETREE_VERSION = ET_ORIG.VERSION | |
15 | except ImportError: | |
16 | import xml.etree.ElementTree as ET | |
17 | ETREE_VERSION = ET.VERSION | |
18 | ||
19 | ETREE_VERSION = [int(i) for i in ETREE_VERSION.split(".")] | |
20 | 11 | |
21 | 12 | current_path = os.path.abspath(os.getcwd()) |
22 | 13 | |
133 | 124 | self.resolution = self.get_text_from_subnode('solution') |
134 | 125 | self.ref = [] |
135 | 126 | for r in issue_node.findall('refs/reference'): |
136 | ||
137 | 127 | self.ref.append(r.get('type') + "-" + r.get('text')) |
138 | 128 | |
139 | 129 | def get_text_from_subnode(self, subnode_xpath_expr): |
166 | 156 | self._current_output = None |
167 | 157 | self._command_regex = re.compile(r'^(sudo x1|\.\/x1)\s+.*?') |
168 | 158 | |
169 | ||
170 | ||
171 | 159 | def parseOutputString(self, output): |
172 | 160 | |
173 | 161 | parser = X1XmlParser(output) |
188 | 176 | del parser |
189 | 177 | |
190 | 178 | |
191 | def setHost(self): | |
192 | pass | |
193 | ||
194 | ||
195 | 179 | def createPlugin(ignore_info=False): |
196 | 180 | return X1Plugin(ignore_info=ignore_info) |
197 | ||
198 |
0 | /* | |
1 | * Zed Attack Proxy (ZAP) and its related class files. | |
2 | * | |
3 | * ZAP is an HTTP/HTTPS proxy for assessing web application security. | |
4 | * | |
5 | * Copyright 2018 The ZAP Development Team | |
6 | * | |
7 | * Licensed under the Apache License, Version 2.0 (the "License"); | |
8 | * you may not use this file except in compliance with the License. | |
9 | * You may obtain a copy of the License at | |
10 | * | |
11 | * http://www.apache.org/licenses/LICENSE-2.0 | |
12 | * | |
13 | * Unless required by applicable law or agreed to in writing, software | |
14 | * distributed under the License is distributed on an "AS IS" BASIS, | |
15 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | |
16 | * See the License for the specific language governing permissions and | |
17 | * limitations under the License. | |
18 | */ | |
19 | ||
20 | package org.zaproxy.zap.extension.faraday; | |
21 | ||
22 | import org.parosproxy.paros.Constant; | |
23 | ||
24 | import javax.swing.*; | |
25 | import java.io.*; | |
26 | import java.util.Properties; | |
27 | ||
28 | public class Configuration { | |
29 | private String server; | |
30 | private String user; | |
31 | private String password; | |
32 | private String session; | |
33 | private String workspace; | |
34 | private boolean autoImport; | |
35 | private static Configuration _instance; | |
36 | ||
37 | private Configuration() { | |
38 | this.user = ""; | |
39 | this.password = ""; | |
40 | this.server = "http://127.0.0.1:5985/"; | |
41 | this.autoImport = false; | |
42 | } | |
43 | ||
44 | public static Configuration getSingleton() { | |
45 | if (_instance == null) | |
46 | _instance = new Configuration(); | |
47 | return _instance; | |
48 | } | |
49 | ||
50 | public boolean save() throws IOException { | |
51 | ||
52 | Properties prop = new Properties(); | |
53 | OutputStream output = null; | |
54 | ||
55 | String userHome = System.getProperty("user.home"); | |
56 | String outputFolder = Constant.getZapHome() + "faraday"; | |
57 | File folder = new File(outputFolder); | |
58 | if (!folder.exists()) { | |
59 | folder.mkdir(); | |
60 | } | |
61 | ||
62 | ||
63 | String filePath = outputFolder + File.separator + this.getUser() + ".properties"; | |
64 | output = new FileOutputStream(filePath); | |
65 | ||
66 | // set the properties value | |
67 | prop.setProperty("fuser", this.getUser()); | |
68 | prop.setProperty("fpassword", this.getPassword()); | |
69 | prop.setProperty("fserver", this.getServer()); | |
70 | prop.setProperty("fworkspace", this.getWorkspace()); | |
71 | prop.setProperty("fsession", this.getSession()); | |
72 | ||
73 | // save properties to project root folder | |
74 | prop.store(output, null); | |
75 | ||
76 | if (output != null) { | |
77 | try { | |
78 | output.close(); | |
79 | } catch (IOException e) { | |
80 | e.printStackTrace(); | |
81 | return false; | |
82 | } | |
83 | } | |
84 | ||
85 | return true; | |
86 | } | |
87 | ||
88 | ||
89 | public void restore(String fUser) throws IOException { | |
90 | Properties prop = new Properties(); | |
91 | InputStream input = null; | |
92 | ||
93 | String outputFolder = Constant.getZapHome() + "faraday"; | |
94 | String filePath = outputFolder + File.separator + fUser + ".properties"; | |
95 | input = new FileInputStream(filePath); | |
96 | ||
97 | // load a properties file | |
98 | prop.load(input); | |
99 | ||
100 | this.setUser(prop.getProperty("fuser")); | |
101 | this.setPassword(prop.getProperty("fpassword")); | |
102 | this.setServer(prop.getProperty("fserver")); | |
103 | this.setWorkspace(prop.getProperty("fworkspace")); | |
104 | ||
105 | if (input != null) { | |
106 | try { | |
107 | input.close(); | |
108 | } catch (IOException e) { | |
109 | e.printStackTrace(); | |
110 | } | |
111 | } | |
112 | ||
113 | } | |
114 | ||
115 | public String getUser() { | |
116 | return user; | |
117 | } | |
118 | ||
119 | public void setUser(String user) { | |
120 | this.user = user; | |
121 | } | |
122 | ||
123 | public String getPassword() { | |
124 | return password; | |
125 | } | |
126 | ||
127 | public void setPassword(String password) { | |
128 | this.password = password; | |
129 | } | |
130 | ||
131 | public String getServer() { | |
132 | return server; | |
133 | } | |
134 | ||
135 | public void setServer(String server) { | |
136 | this.server = server; | |
137 | } | |
138 | ||
139 | public boolean isAutoImport() { | |
140 | return autoImport; | |
141 | } | |
142 | ||
143 | public void setAutoImport(boolean autoImport) { | |
144 | this.autoImport = autoImport; | |
145 | } | |
146 | ||
147 | public String getSession() { | |
148 | return session; | |
149 | } | |
150 | ||
151 | public void setSession(String session) { | |
152 | this.session = session; | |
153 | } | |
154 | ||
155 | public String getWorkspace() { | |
156 | return workspace; | |
157 | } | |
158 | ||
159 | public void setWorkspace(String workspace) { | |
160 | this.workspace = workspace; | |
161 | } | |
162 | } |
0 | package org.zaproxy.zap.extension.faraday; | |
1 | ||
2 | ||
3 | import org.apache.log4j.Logger; | |
4 | import org.parosproxy.paros.Constant; | |
5 | ||
6 | import javax.swing.*; | |
7 | import javax.swing.border.Border; | |
8 | import java.awt.*; | |
9 | import java.awt.event.*; | |
10 | import java.io.*; | |
11 | import java.util.ArrayList; | |
12 | import java.util.Properties; | |
13 | import java.util.ResourceBundle; | |
14 | ||
15 | public class ConfigurationDialog extends JFrame { | |
16 | private static final Logger logger = Logger.getLogger(ConfigurationDialog.class); | |
17 | private ResourceBundle messages = null; | |
18 | private FaradayClient faradayClient; | |
19 | ||
20 | private static String LOGIN_BUTTON = "Login"; | |
21 | private static String LOGOUT_BUTTON = "Logout"; | |
22 | private static String WORKSPACES_FIELD = "Select faraday workspace"; | |
23 | private static String IMPORT_NEW_VULNS_FIELD = "Import new vulnerabilities"; | |
24 | private static String SET_CONFIG_AS_DEFAULT = "Set this configuration as default"; | |
25 | private static String IMPORT_BUTTON = "Import vulnerabilities"; | |
26 | private static String REFRESH_BUTTON = "Refresh"; | |
27 | private static String RESTORE_BUTTON = "Restore"; | |
28 | private static String SAVE_BUTTON = "Save"; | |
29 | ||
30 | private JTabbedPane tabbedPane; | |
31 | private JPanel authPanel; | |
32 | private JPanel configPanel; | |
33 | ||
34 | private JTextField fldUser; | |
35 | private JTextField fldPass; | |
36 | private JTextField fldServer; | |
37 | ||
38 | private JComboBox cmbWorkspaces; | |
39 | private JCheckBox cboxSetConfigDefault; | |
40 | ||
41 | ||
42 | private JButton loginButton; | |
43 | private JButton logoutButton; | |
44 | private JButton refreshButton; | |
45 | private JButton restoreButton; | |
46 | private JButton importButton; | |
47 | private JButton saveButton; | |
48 | private JButton closeButton; | |
49 | ||
50 | ||
51 | public ConfigurationDialog(String s) throws HeadlessException { | |
52 | super(s); | |
53 | } | |
54 | ||
55 | ||
56 | public void init() { | |
57 | logger.debug("Init Faraday configuration dialog"); | |
58 | messages = ResourceBundle.getBundle( | |
59 | this.getClass().getPackage().getName() + | |
60 | ".Messages", Constant.getLocale()); | |
61 | // Setup the content-pane of JFrame in BorderLayout | |
62 | Container cp = this.getContentPane(); | |
63 | cp.setLayout(new BorderLayout(5, 5)); | |
64 | Border padding = BorderFactory.createEmptyBorder(10, 10, 10, 10); | |
65 | ||
66 | ||
67 | String USERNAME_FIELD = messages.getString("faraday.config.dialog.auth.user"); | |
68 | String PASS_FIELD = messages.getString("faraday.config.dialog.auth.pass"); | |
69 | String SERVER_FIELD = messages.getString("faraday.config.dialog.server"); | |
70 | LOGIN_BUTTON = messages.getString("faraday.config.dialog.auth.login"); | |
71 | LOGOUT_BUTTON = messages.getString("faraday.config.dialog.auth.logout"); | |
72 | WORKSPACES_FIELD = messages.getString("faraday.config.dialog.workspace"); | |
73 | IMPORT_NEW_VULNS_FIELD = messages.getString("faraday.config.dialog.import.new"); | |
74 | SET_CONFIG_AS_DEFAULT = messages.getString("faraday.config.dialog.default"); | |
75 | IMPORT_BUTTON = messages.getString("faraday.config.dialog.import.new"); | |
76 | REFRESH_BUTTON = messages.getString("faraday.config.dialog.refresh"); | |
77 | RESTORE_BUTTON = messages.getString("faraday.config.dialog.restore"); | |
78 | SAVE_BUTTON = messages.getString("faraday.config.dialog.save"); | |
79 | tabbedPane = new JTabbedPane(); | |
80 | ||
81 | JPanel buttonLoginPanel = new JPanel(); | |
82 | buttonLoginPanel.setLayout(new FlowLayout(FlowLayout.RIGHT)); | |
83 | ||
84 | JPanel buttonConfigPanel = new JPanel(); | |
85 | buttonConfigPanel.setLayout(new FlowLayout(FlowLayout.RIGHT)); | |
86 | ||
87 | authPanel = new JPanel(new GridLayout(4, 2, 10, 2)); | |
88 | authPanel.setBorder(padding); | |
89 | configPanel = new JPanel(new GridLayout(3, 2, 10, 2)); | |
90 | configPanel.setBorder(padding); | |
91 | ||
92 | ||
93 | Configuration configuration = Configuration.getSingleton(); | |
94 | faradayClient = new FaradayClient(configuration.getServer()); | |
95 | ||
96 | authPanel.add(new JLabel(USERNAME_FIELD)); | |
97 | fldUser = new JTextField(10); | |
98 | authPanel.add(fldUser); | |
99 | ||
100 | authPanel.add(new JLabel(PASS_FIELD)); | |
101 | fldPass = new JPasswordField(10); | |
102 | authPanel.add(fldPass); | |
103 | ||
104 | authPanel.add(new JLabel(SERVER_FIELD)); | |
105 | fldServer = new JTextField(10); | |
106 | fldServer.setText(configuration.getServer()); | |
107 | authPanel.add(fldServer); | |
108 | ||
109 | configPanel.add(getCBoxSetDefaultConfig()); | |
110 | ||
111 | buttonConfigPanel.add(getCloseButton()); | |
112 | buttonConfigPanel.add(getCloseButton()); | |
113 | buttonConfigPanel.add(getRefreshButton()); | |
114 | buttonConfigPanel.add(getRestoreButton()); | |
115 | buttonConfigPanel.add(getSaveButton()); | |
116 | // buttonConfigPanel.add(getImportButton()); | |
117 | buttonConfigPanel.add(getLoginButton()); | |
118 | buttonConfigPanel.add(getLogoutButton()); | |
119 | ||
120 | ||
121 | authPanel.addComponentListener(new ComponentListener() { | |
122 | @Override | |
123 | public void componentResized(ComponentEvent componentEvent) { | |
124 | ||
125 | } | |
126 | ||
127 | @Override | |
128 | public void componentMoved(ComponentEvent componentEvent) { | |
129 | ||
130 | } | |
131 | ||
132 | @Override | |
133 | public void componentShown(ComponentEvent componentEvent) { | |
134 | ||
135 | refreshButton.setVisible(false); | |
136 | restoreButton.setVisible(false); | |
137 | // importButton.setVisible(false); | |
138 | saveButton.setVisible(false); | |
139 | } | |
140 | ||
141 | @Override | |
142 | public void componentHidden(ComponentEvent componentEvent) { | |
143 | refreshButton.setVisible(true); | |
144 | restoreButton.setVisible(true); | |
145 | // importButton.setVisible(true); | |
146 | saveButton.setVisible(true); | |
147 | } | |
148 | }); | |
149 | ||
150 | configPanel.addComponentListener(new ComponentListener() { | |
151 | @Override | |
152 | public void componentResized(ComponentEvent componentEvent) { | |
153 | ||
154 | } | |
155 | ||
156 | @Override | |
157 | public void componentMoved(ComponentEvent componentEvent) { | |
158 | ||
159 | } | |
160 | ||
161 | @Override | |
162 | public void componentShown(ComponentEvent componentEvent) { | |
163 | loginButton.setVisible(false); | |
164 | logoutButton.setVisible(false); | |
165 | } | |
166 | ||
167 | @Override | |
168 | public void componentHidden(ComponentEvent componentEvent) { | |
169 | if (configuration.getSession().equals("")) { | |
170 | loginButton.setVisible(true); | |
171 | } else { | |
172 | logoutButton.setVisible(true); | |
173 | } | |
174 | } | |
175 | }); | |
176 | ||
177 | tabbedPane.addTab(messages.getString("faraday.config.dialog.tab.auth"), null, authPanel, null); | |
178 | tabbedPane.setMnemonicAt(0, KeyEvent.VK_1); | |
179 | ||
180 | ||
181 | tabbedPane.addTab(messages.getString("faraday.config.dialog.tabs.conf"), null, configPanel, null); | |
182 | tabbedPane.setMnemonicAt(1, KeyEvent.VK_2); | |
183 | ||
184 | tabbedPane.setEnabledAt(1, false); | |
185 | ||
186 | cp.add(tabbedPane, BorderLayout.NORTH); | |
187 | cp.add(buttonConfigPanel, BorderLayout.SOUTH); | |
188 | ||
189 | if (configuration.getSession() != null && !configuration.getSession().equals("")) { | |
190 | logoutButton.setVisible(true); | |
191 | loginButton.setVisible(false); | |
192 | } else { | |
193 | loginButton.setVisible(true); | |
194 | logoutButton.setVisible(false); | |
195 | } | |
196 | ||
197 | ||
198 | if (!configuration.getUser().equals("") && !configuration.getPassword().equals("")) { | |
199 | if (faradayClient.Login(configuration.getUser(), configuration.getPassword(), configuration.getServer())) { | |
200 | fldUser.setText(configuration.getUser()); | |
201 | fldPass.setText(configuration.getPassword()); | |
202 | fldServer.setText(configuration.getServer()); | |
203 | ||
204 | tabbedPane.setEnabledAt(1, true); | |
205 | tabbedPane.setSelectedIndex(1); | |
206 | ||
207 | cboxSetConfigDefault.setSelected(true); | |
208 | ||
209 | if (cmbWorkspaces == null) { | |
210 | configPanel.add(new JLabel(WORKSPACES_FIELD)); | |
211 | configPanel.add(getWSComboBox()); | |
212 | } | |
213 | } | |
214 | } | |
215 | ||
216 | this.setSize(550, 300); | |
217 | this.setResizable(false); | |
218 | this.setLocationRelativeTo(null); | |
219 | this.setVisible(true); | |
220 | } | |
221 | ||
222 | ||
223 | private JButton getLoginButton() { | |
224 | if (this.loginButton == null) { | |
225 | this.loginButton = new JButton(); | |
226 | this.loginButton.setText(LOGIN_BUTTON); | |
227 | this.loginButton.addActionListener(new ActionListener() { | |
228 | public void actionPerformed(ActionEvent e) { | |
229 | if (fldUser.getText().equals("") || fldPass.getText().equals("") || fldServer.getText().equals("")) { | |
230 | showMessage(messages.getString("faraday.message.invalid.check.credentials"), messages.getString("faraday.dialog.login.title"), JOptionPane.ERROR_MESSAGE); | |
231 | } else { | |
232 | if (faradayClient.Login(fldUser.getText(), fldPass.getText(), fldServer.getText())) { | |
233 | logoutButton.setVisible(true); | |
234 | loginButton.setVisible(false); | |
235 | if (!tabbedPane.isEnabledAt(1)) { | |
236 | tabbedPane.setEnabledAt(1, true); | |
237 | } | |
238 | tabbedPane.setSelectedIndex(1); | |
239 | if (cmbWorkspaces == null) { | |
240 | configPanel.add(new JLabel(WORKSPACES_FIELD)); | |
241 | configPanel.add(getWSComboBox()); | |
242 | } else { | |
243 | configPanel.remove(cmbWorkspaces); | |
244 | configPanel.add(getWSComboBox()); | |
245 | } | |
246 | } else { | |
247 | showMessage(messages.getString("faraday.message.invalid.credentials"), messages.getString("faraday.dialog.login.title"), JOptionPane.ERROR_MESSAGE); | |
248 | } | |
249 | } | |
250 | ||
251 | ||
252 | } | |
253 | }); | |
254 | ||
255 | ||
256 | } | |
257 | ||
258 | return this.loginButton; | |
259 | } | |
260 | ||
261 | ||
262 | private JButton getLogoutButton() { | |
263 | if (this.logoutButton == null) { | |
264 | this.logoutButton = new JButton(); | |
265 | this.logoutButton.setText(LOGOUT_BUTTON); | |
266 | this.logoutButton.addActionListener(new ActionListener() { | |
267 | public void actionPerformed(ActionEvent e) { | |
268 | Configuration configuration = Configuration.getSingleton(); | |
269 | String userTemp = configuration.getUser(); | |
270 | if (faradayClient.Logout()) { | |
271 | logoutButton.setVisible(false); | |
272 | loginButton.setVisible(true); | |
273 | ||
274 | if (tabbedPane.isEnabledAt(1)) { | |
275 | tabbedPane.setEnabledAt(1, false); | |
276 | } | |
277 | tabbedPane.setSelectedIndex(0); | |
278 | ||
279 | Properties prop = new Properties(); | |
280 | InputStream input = null; | |
281 | try { | |
282 | String filePath = Constant.getZapHome() + "faraday" + File.separator + "default.properties"; | |
283 | input = new FileInputStream(filePath); | |
284 | // load a properties file | |
285 | prop.load(input); | |
286 | // set the properties value | |
287 | String fUser = prop.getProperty("default"); | |
288 | if (fUser.equals(userTemp)) { | |
289 | removeDefaultConfig(); | |
290 | } | |
291 | ||
292 | } catch (IOException io) { | |
293 | System.out.println("We can't found default.properties file"); | |
294 | } finally { | |
295 | if (input != null) { | |
296 | try { | |
297 | input.close(); | |
298 | } catch (IOException er) { | |
299 | er.printStackTrace(); | |
300 | } | |
301 | } | |
302 | } | |
303 | ||
304 | ||
305 | showMessage(messages.getString("faraday.dialog.logout.success"), messages.getString("faraday.dialog.logout.title"), JOptionPane.INFORMATION_MESSAGE); | |
306 | } else { | |
307 | showMessage(messages.getString("faraday.dialog.logout.error"), messages.getString("faraday.dialog.logout.title"), JOptionPane.ERROR_MESSAGE); | |
308 | } | |
309 | } | |
310 | }); | |
311 | } | |
312 | ||
313 | return this.logoutButton; | |
314 | } | |
315 | ||
316 | ||
317 | private JButton getRefreshButton() { | |
318 | if (this.refreshButton == null) { | |
319 | this.refreshButton = new JButton(); | |
320 | this.refreshButton.setText(REFRESH_BUTTON); | |
321 | this.refreshButton.addActionListener(new ActionListener() { | |
322 | public void actionPerformed(ActionEvent e) { | |
323 | refreshWorkspaces(true); | |
324 | } | |
325 | }); | |
326 | } | |
327 | ||
328 | return this.refreshButton; | |
329 | } | |
330 | ||
331 | ||
332 | private JButton getCloseButton() { | |
333 | if (this.closeButton == null) { | |
334 | this.closeButton = new JButton(); | |
335 | this.closeButton.setText(messages.getString("faraday.dialog.button.close")); | |
336 | this.closeButton.addActionListener(new ActionListener() { | |
337 | public void actionPerformed(ActionEvent e) { | |
338 | setVisible(false); | |
339 | dispose(); | |
340 | } | |
341 | }); | |
342 | } | |
343 | ||
344 | return this.closeButton; | |
345 | } | |
346 | ||
347 | ||
348 | private JButton getRestoreButton() { | |
349 | if (this.restoreButton == null) { | |
350 | this.restoreButton = new JButton(); | |
351 | this.restoreButton.setText(RESTORE_BUTTON); | |
352 | this.restoreButton.addActionListener(new ActionListener() { | |
353 | public void actionPerformed(ActionEvent e) { | |
354 | String fUser = JOptionPane.showInputDialog(messages.getString("faraday.config.dialog.restore"), messages.getString("faraday.dialog.enter.user")); | |
355 | if (fUser != null) { | |
356 | restoreConfiguration(fUser); | |
357 | } | |
358 | } | |
359 | }); | |
360 | } | |
361 | ||
362 | return this.restoreButton; | |
363 | } | |
364 | ||
365 | ||
366 | private JButton getImportButton() { | |
367 | if (this.importButton == null) { | |
368 | this.importButton = new JButton(); | |
369 | this.importButton.setText(IMPORT_BUTTON); | |
370 | this.importButton.addActionListener(new ActionListener() { | |
371 | public void actionPerformed(ActionEvent e) { | |
372 | ||
373 | } | |
374 | }); | |
375 | } | |
376 | ||
377 | return this.importButton; | |
378 | } | |
379 | ||
380 | ||
381 | private JButton getSaveButton() { | |
382 | if (this.saveButton == null) { | |
383 | this.saveButton = new JButton(); | |
384 | this.saveButton.setText(SAVE_BUTTON); | |
385 | this.saveButton.addActionListener(new ActionListener() { | |
386 | public void actionPerformed(ActionEvent e) { | |
387 | saveConfiguration(); | |
388 | } | |
389 | }); | |
390 | } | |
391 | ||
392 | return this.saveButton; | |
393 | } | |
394 | ||
395 | ||
396 | private JComboBox getWSComboBox() { | |
397 | Configuration configuration = Configuration.getSingleton(); | |
398 | ||
399 | ArrayList<String> wsList = faradayClient.GetWorkspaces(); | |
400 | String[] workspaces = new String[wsList.size()]; | |
401 | for (int i = 0; i < wsList.size(); i++) { | |
402 | workspaces[i] = wsList.get(i); | |
403 | } | |
404 | cmbWorkspaces = new JComboBox(workspaces); | |
405 | if (workspaces.length > 0) { | |
406 | if (configuration.getWorkspace() != null) { | |
407 | cmbWorkspaces.setSelectedItem(configuration.getWorkspace()); | |
408 | } else { | |
409 | configuration.setWorkspace(workspaces[0]); | |
410 | } | |
411 | } | |
412 | cmbWorkspaces.addActionListener(new ActionListener() { | |
413 | @Override | |
414 | public void actionPerformed(ActionEvent actionEvent) { | |
415 | Configuration.getSingleton().setWorkspace(cmbWorkspaces.getSelectedItem().toString()); | |
416 | } | |
417 | }); | |
418 | ||
419 | ||
420 | return cmbWorkspaces; | |
421 | } | |
422 | ||
423 | ||
424 | private JCheckBox getCBoxSetDefaultConfig() { | |
425 | if (this.cboxSetConfigDefault == null) { | |
426 | cboxSetConfigDefault = new JCheckBox(SET_CONFIG_AS_DEFAULT, false); | |
427 | ||
428 | cboxSetConfigDefault.addActionListener(new ActionListener() { | |
429 | @Override | |
430 | public void actionPerformed(ActionEvent actionEvent) { | |
431 | if (cboxSetConfigDefault.isSelected()) { | |
432 | setConfigAsDefault(); | |
433 | } else { | |
434 | removeDefaultConfig(); | |
435 | } | |
436 | } | |
437 | }); | |
438 | } | |
439 | ||
440 | return cboxSetConfigDefault; | |
441 | } | |
442 | ||
443 | ||
444 | private void showMessage(String message, String title, int icon) { | |
445 | JOptionPane.showMessageDialog( | |
446 | this, | |
447 | message, | |
448 | title, | |
449 | icon); | |
450 | } | |
451 | ||
452 | ||
453 | private void saveConfiguration() { | |
454 | try { | |
455 | if (Configuration.getSingleton().save()) { | |
456 | JOptionPane.showMessageDialog( | |
457 | this, | |
458 | messages.getString("faraday.save.config.success"), | |
459 | messages.getString("faraday.config.dialog.title"), | |
460 | JOptionPane.INFORMATION_MESSAGE); | |
461 | } else { | |
462 | JOptionPane.showMessageDialog( | |
463 | this, | |
464 | messages.getString("faraday.save.config.error"), | |
465 | messages.getString("faraday.config.dialog.title"), | |
466 | JOptionPane.ERROR_MESSAGE); | |
467 | ||
468 | } | |
469 | } catch (IOException io) { | |
470 | JOptionPane.showMessageDialog( | |
471 | this, | |
472 | messages.getString("faraday.save.config.error"), | |
473 | messages.getString("faraday.config.dialog.title"), | |
474 | JOptionPane.ERROR_MESSAGE); | |
475 | io.printStackTrace(); | |
476 | ||
477 | } | |
478 | } | |
479 | ||
480 | ||
481 | private void restoreConfiguration(String fUser) { | |
482 | try { | |
483 | Configuration configuration = Configuration.getSingleton(); | |
484 | configuration.restore(fUser); | |
485 | if (faradayClient.Login(configuration.getUser(), configuration.getPassword(), configuration.getServer())) { | |
486 | fldUser.setText(configuration.getUser()); | |
487 | fldPass.setText(configuration.getPassword()); | |
488 | fldServer.setText(configuration.getServer()); | |
489 | ||
490 | tabbedPane.setEnabledAt(1, true); | |
491 | tabbedPane.setSelectedIndex(0); | |
492 | ||
493 | cboxSetConfigDefault.setSelected(false); | |
494 | refreshWorkspaces(false); | |
495 | } else { | |
496 | JOptionPane.showMessageDialog( | |
497 | this, | |
498 | messages.getString("faraday.restore.config.error.login"), | |
499 | messages.getString("faraday.config.dialog.title"), | |
500 | JOptionPane.ERROR_MESSAGE); | |
501 | } | |
502 | } catch (IOException ex) { | |
503 | JOptionPane.showMessageDialog( | |
504 | this, | |
505 | messages.getString("faraday.restore.config.error"), | |
506 | messages.getString("faraday.config.dialog.title"), | |
507 | JOptionPane.ERROR_MESSAGE); | |
508 | } | |
509 | ||
510 | } | |
511 | ||
512 | ||
513 | private void setConfigAsDefault() { | |
514 | Configuration configuration = Configuration.getSingleton(); | |
515 | ||
516 | Properties prop = new Properties(); | |
517 | OutputStream output = null; | |
518 | ||
519 | try { | |
520 | String outputFolder = Constant.getZapHome() + "faraday"; | |
521 | File folder = new File(outputFolder); | |
522 | if (!folder.exists()) { | |
523 | folder.mkdir(); | |
524 | } | |
525 | ||
526 | String filePath = outputFolder + File.separator + "default.properties"; | |
527 | output = new FileOutputStream(filePath); | |
528 | ||
529 | // set the properties value | |
530 | prop.setProperty("default", configuration.getUser()); | |
531 | ||
532 | // save properties to project root folder | |
533 | prop.store(output, null); | |
534 | ||
535 | } catch (IOException io) { | |
536 | JOptionPane.showMessageDialog( | |
537 | this, | |
538 | messages.getString("faraday.set.default.config.error"), | |
539 | messages.getString("faraday.config.dialog.title"), | |
540 | JOptionPane.ERROR_MESSAGE); | |
541 | io.printStackTrace(); | |
542 | } finally { | |
543 | if (output != null) { | |
544 | try { | |
545 | output.close(); | |
546 | } catch (IOException e) { | |
547 | e.printStackTrace(); | |
548 | } | |
549 | } | |
550 | ||
551 | } | |
552 | } | |
553 | ||
554 | ||
555 | private void removeDefaultConfig() { | |
556 | try { | |
557 | ||
558 | String filePath = Constant.getZapHome() + "faraday" + File.separator + "default.properties"; | |
559 | File file = new File(filePath); | |
560 | if (file.delete()) { | |
561 | System.out.println(file.getName() + " is deleted!"); | |
562 | } else { | |
563 | System.out.println("Delete operation is failed."); | |
564 | } | |
565 | ||
566 | } catch (Exception e) { | |
567 | ||
568 | e.printStackTrace(); | |
569 | ||
570 | } | |
571 | } | |
572 | ||
573 | ||
574 | private void refreshWorkspaces(boolean canShowAlert) { | |
575 | if (cmbWorkspaces != null) { | |
576 | configPanel.remove(cmbWorkspaces); | |
577 | configPanel.add(getWSComboBox()); | |
578 | if (canShowAlert) { | |
579 | JOptionPane.showMessageDialog( | |
580 | this, | |
581 | messages.getString("faraday.refresh.workspace.done"), | |
582 | messages.getString("faraday.config.dialog.title"), | |
583 | JOptionPane.INFORMATION_MESSAGE); | |
584 | } | |
585 | } | |
586 | } | |
587 | ||
588 | } |
0 | package org.zaproxy.zap.extension.faraday; | |
1 | ||
2 | import net.sf.json.JSONArray; | |
3 | import net.sf.json.JSONObject; | |
4 | import org.apache.commons.httpclient.URIException; | |
5 | import org.apache.commons.httpclient.methods.PostMethod; | |
6 | import org.apache.http.HttpEntity; | |
7 | import org.apache.http.HttpResponse; | |
8 | ||
9 | import org.apache.http.client.ClientProtocolException; | |
10 | import org.apache.http.client.HttpClient; | |
11 | import org.apache.http.entity.StringEntity; | |
12 | import org.apache.http.client.entity.UrlEncodedFormEntity; | |
13 | import org.apache.http.client.methods.HttpGet; | |
14 | import org.apache.http.client.methods.HttpPost; | |
15 | import org.apache.http.impl.client.HttpClients; | |
16 | import org.apache.http.NameValuePair; | |
17 | import org.apache.http.message.BasicNameValuePair; | |
18 | import org.apache.http.util.EntityUtils; | |
19 | import org.parosproxy.paros.Constant; | |
20 | import org.parosproxy.paros.core.scanner.Alert; | |
21 | import org.parosproxy.paros.model.HistoryReference; | |
22 | ||
23 | import java.io.*; | |
24 | import java.net.*; | |
25 | import java.nio.charset.StandardCharsets; | |
26 | import java.sql.Time; | |
27 | import java.time.Instant; | |
28 | import java.util.*; | |
29 | ||
30 | ||
31 | public class FaradayClient { | |
32 | ||
33 | private String baseUrl; | |
34 | private ResourceBundle messages = null; | |
35 | ||
36 | public FaradayClient(String baseUrl) { | |
37 | this.baseUrl = baseUrl; | |
38 | messages = ResourceBundle.getBundle( | |
39 | this.getClass().getPackage().getName() + | |
40 | ".Messages", Constant.getLocale()); | |
41 | ||
42 | } | |
43 | ||
44 | public boolean Login(String username, String password, String server) { | |
45 | Logout(); | |
46 | HttpClient httpClient = HttpClients.createDefault(); | |
47 | String LOGIN_URL = "_api/login"; | |
48 | HttpPost httpPost = new HttpPost(server + LOGIN_URL); | |
49 | ||
50 | // Request parameters and other properties. | |
51 | List<BasicNameValuePair> params = new ArrayList<>(2); | |
52 | params.add(new BasicNameValuePair("email", username)); | |
53 | params.add(new BasicNameValuePair("password", password)); | |
54 | ||
55 | try { | |
56 | httpPost.setEntity(new UrlEncodedFormEntity(params, "UTF-8")); | |
57 | HttpResponse response = httpClient.execute(httpPost); | |
58 | if (response.getFirstHeader("Set-Cookie") != null) { | |
59 | Configuration configuration = Configuration.getSingleton(); | |
60 | configuration.setSession(response.getFirstHeader("Set-Cookie").getValue()); | |
61 | configuration.setUser(username); | |
62 | configuration.setPassword(password); | |
63 | configuration.setServer(server); | |
64 | setBaseUrl(server); | |
65 | return true; | |
66 | } else if (response.getStatusLine().getStatusCode() == 302) { | |
67 | return true; | |
68 | } | |
69 | return false; | |
70 | } catch (UnsupportedEncodingException e) { | |
71 | // writing error to Log | |
72 | e.printStackTrace(); | |
73 | return false; | |
74 | } catch (ClientProtocolException e) { | |
75 | e.printStackTrace(); | |
76 | return false; | |
77 | } catch (IOException e) { | |
78 | e.printStackTrace(); | |
79 | return false; | |
80 | } | |
81 | ||
82 | } | |
83 | ||
84 | public boolean Logout() { | |
85 | String LOGOUT_URL = "_api/logout"; | |
86 | HttpGet httpGet = new HttpGet(this.baseUrl + LOGOUT_URL); | |
87 | Configuration configuration = Configuration.getSingleton(); | |
88 | ||
89 | if (!Objects.equals(configuration.getSession(), "")) { | |
90 | httpGet.setHeader("Cookie", configuration.getSession()); | |
91 | ||
92 | //Execute and get the response. | |
93 | HttpResponse response = null; | |
94 | ||
95 | try { | |
96 | HttpClient httpClient = HttpClients.createDefault(); | |
97 | response = httpClient.execute(httpGet); | |
98 | HttpEntity entity = response.getEntity(); | |
99 | if (response.getStatusLine().getStatusCode() == 200) { | |
100 | configuration.setSession(""); | |
101 | configuration.setUser(""); | |
102 | configuration.setPassword(""); | |
103 | return true; | |
104 | } | |
105 | return false; | |
106 | } catch (IOException e) { | |
107 | e.printStackTrace(); | |
108 | return false; | |
109 | } | |
110 | } | |
111 | return true; | |
112 | } | |
113 | ||
114 | public ArrayList<String> GetWorkspaces() { | |
115 | ArrayList<String> workspaces = new ArrayList<>(); | |
116 | String WORKSPACES_URL = "_api/v2/ws/"; | |
117 | HttpGet httpGet = new HttpGet(this.baseUrl + WORKSPACES_URL); | |
118 | Configuration configuration = Configuration.getSingleton(); | |
119 | ||
120 | if (configuration.getSession() != "") { | |
121 | httpGet.setHeader("Cookie", configuration.getSession()); | |
122 | ||
123 | //Execute and get the response. | |
124 | HttpResponse response = null; | |
125 | InputStream instream = null; | |
126 | try { | |
127 | HttpClient httpClient = HttpClients.createDefault(); | |
128 | response = httpClient.execute(httpGet); | |
129 | HttpEntity entity = response.getEntity(); | |
130 | ||
131 | if (entity != null && response.getStatusLine().getStatusCode() == 200) { | |
132 | instream = entity.getContent(); | |
133 | ||
134 | BufferedReader br = new BufferedReader(new InputStreamReader(instream)); | |
135 | String output; | |
136 | JSONArray jsonArray = new JSONArray(); | |
137 | while ((output = br.readLine()) != null) { | |
138 | System.out.println(output); | |
139 | jsonArray = JSONArray.fromObject(output); | |
140 | } | |
141 | ||
142 | for (int i = 0; i < jsonArray.size(); i++) { | |
143 | JSONObject jsonObject = jsonArray.getJSONObject(i); | |
144 | workspaces.add(jsonObject.get("name").toString()); | |
145 | } | |
146 | } | |
147 | } catch (IOException e) { | |
148 | e.printStackTrace(); | |
149 | } finally { | |
150 | try { | |
151 | instream.close(); | |
152 | } catch (IOException e) { | |
153 | e.printStackTrace(); | |
154 | } | |
155 | } | |
156 | } | |
157 | ||
158 | return workspaces; | |
159 | } | |
160 | ||
161 | ||
162 | private int AddCommand(String commandName, String workspace, String session) { | |
163 | String COMMAND_URL = "_api/v2/ws/" + workspace + "/commands/"; | |
164 | HttpClient httpClient = HttpClients.createDefault(); | |
165 | HttpPost httpPost = new HttpPost(this.baseUrl + COMMAND_URL); | |
166 | ||
167 | try { | |
168 | StringEntity stringEntity = new StringEntity(ConvertCommandToParams(commandName).toString()); | |
169 | httpPost.setHeader("Cookie", session); | |
170 | httpPost.setHeader("Content-Type", "application/json"); | |
171 | httpPost.setEntity(stringEntity); | |
172 | HttpResponse response = httpClient.execute(httpPost); | |
173 | HttpEntity entity = response.getEntity(); | |
174 | ||
175 | if (response.getStatusLine().getStatusCode() == 200 || response.getStatusLine().getStatusCode() == 201 || response.getStatusLine().getStatusCode() == 409) { | |
176 | BufferedReader br = new BufferedReader(new InputStreamReader(entity.getContent())); | |
177 | String output; | |
178 | JSONObject json; | |
179 | String commandStr = "-1"; | |
180 | while ((output = br.readLine()) != null) { | |
181 | json = JSONObject.fromObject(output); | |
182 | if (response.getStatusLine().getStatusCode() == 409) { | |
183 | JSONObject jsonObject = JSONObject.fromObject(json.get("object")); | |
184 | commandStr = jsonObject.get("_id").toString(); | |
185 | } else { | |
186 | commandStr = json.get("_id").toString(); | |
187 | } | |
188 | } | |
189 | return Integer.parseInt(commandStr); | |
190 | } | |
191 | return -1; | |
192 | } catch (UnsupportedEncodingException e) { | |
193 | // writing error to Log | |
194 | e.printStackTrace(); | |
195 | return -1; | |
196 | } catch (ClientProtocolException e) { | |
197 | e.printStackTrace(); | |
198 | return -1; | |
199 | } catch (IOException e) { | |
200 | e.printStackTrace(); | |
201 | return -1; | |
202 | } | |
203 | } | |
204 | ||
205 | private int AddHost(Alert alert, String workspace, String session) { | |
206 | String VULN_URL = "_api/v2/ws/" + workspace + "/hosts/"; | |
207 | HttpClient httpClient = HttpClients.createDefault(); | |
208 | HttpPost httpPost = new HttpPost(this.baseUrl + VULN_URL); | |
209 | ||
210 | try { | |
211 | StringEntity stringEntity = new StringEntity(ConvertHostToParams(alert).toString()); | |
212 | httpPost.setHeader("Cookie", session); | |
213 | httpPost.setHeader("Content-Type", "application/json"); | |
214 | httpPost.setEntity(stringEntity); | |
215 | HttpResponse response = httpClient.execute(httpPost); | |
216 | HttpEntity entity = response.getEntity(); | |
217 | ||
218 | if (response.getStatusLine().getStatusCode() == 200 || response.getStatusLine().getStatusCode() == 201 || response.getStatusLine().getStatusCode() == 409) { | |
219 | BufferedReader br = new BufferedReader(new InputStreamReader(entity.getContent())); | |
220 | String output; | |
221 | JSONObject json; | |
222 | String hostStr = "-1"; | |
223 | while ((output = br.readLine()) != null) { | |
224 | json = JSONObject.fromObject(output); | |
225 | if (response.getStatusLine().getStatusCode() == 409) { | |
226 | JSONObject jsonObject = JSONObject.fromObject(json.get("object")); | |
227 | hostStr = jsonObject.get("id").toString(); | |
228 | } else { | |
229 | hostStr = json.get("id").toString(); | |
230 | } | |
231 | } | |
232 | return Integer.parseInt(hostStr); | |
233 | } | |
234 | return -1; | |
235 | } catch (UnsupportedEncodingException e) { | |
236 | // writing error to Log | |
237 | e.printStackTrace(); | |
238 | return -1; | |
239 | } catch (ClientProtocolException e) { | |
240 | e.printStackTrace(); | |
241 | return -1; | |
242 | } catch (IOException e) { | |
243 | e.printStackTrace(); | |
244 | return -1; | |
245 | } | |
246 | } | |
247 | ||
248 | private int AddService(Alert alert, String workspace, String session, int hostId) { | |
249 | String VULN_URL = "_api/v2/ws/" + workspace + "/services/"; | |
250 | HttpClient httpClient = HttpClients.createDefault(); | |
251 | HttpPost httpPost = new HttpPost(this.baseUrl + VULN_URL); | |
252 | ||
253 | try { | |
254 | StringEntity stringEntity = new StringEntity(ConvertServiceToParams(alert, hostId).toString()); | |
255 | httpPost.setHeader("Cookie", session); | |
256 | httpPost.setHeader("Content-Type", "application/json"); | |
257 | httpPost.setEntity(stringEntity); | |
258 | HttpResponse response = httpClient.execute(httpPost); | |
259 | HttpEntity entity = response.getEntity(); | |
260 | ||
261 | BufferedReader br = new BufferedReader(new InputStreamReader(entity.getContent())); | |
262 | String output; | |
263 | if (response.getStatusLine().getStatusCode() == 200 || response.getStatusLine().getStatusCode() == 201 || response.getStatusLine().getStatusCode() == 409) { | |
264 | JSONObject json; | |
265 | String serviceStr = "-1"; | |
266 | while ((output = br.readLine()) != null) { | |
267 | json = JSONObject.fromObject(output); | |
268 | if (response.getStatusLine().getStatusCode() == 409) { | |
269 | JSONObject jsonObject = JSONObject.fromObject(json.get("object")); | |
270 | serviceStr = jsonObject.get("id").toString(); | |
271 | } else { | |
272 | serviceStr = json.get("id").toString(); | |
273 | } | |
274 | } | |
275 | return Integer.parseInt(serviceStr); | |
276 | } else { | |
277 | while ((output = br.readLine()) != null) { | |
278 | System.out.println(output); | |
279 | } | |
280 | ||
281 | return -1; | |
282 | } | |
283 | ||
284 | } catch (UnsupportedEncodingException e) { | |
285 | // writing error to Log | |
286 | e.printStackTrace(); | |
287 | return -1; | |
288 | } catch (ClientProtocolException e) { | |
289 | e.printStackTrace(); | |
290 | return -1; | |
291 | } catch (IOException e) { | |
292 | e.printStackTrace(); | |
293 | return -1; | |
294 | } | |
295 | } | |
296 | ||
297 | public int AddVulnerability(Alert alert, String workspace, String session) { | |
298 | int hostId = AddHost(alert, workspace, session); | |
299 | if (hostId == -1) { | |
300 | return 500; | |
301 | } | |
302 | ||
303 | String parentType = "Service"; | |
304 | int serviceId = AddService(alert, workspace, session, hostId); | |
305 | if (serviceId == -1) { | |
306 | return 500; | |
307 | } | |
308 | ||
309 | ||
310 | String commandName = messages.getString("faraday.tool.command.name"); | |
311 | int commandId = AddCommand(commandName, workspace, session); | |
312 | if (commandId == -1) { | |
313 | return 500; | |
314 | } | |
315 | ||
316 | ||
317 | String VULN_URL = "_api/v2/ws/" + workspace + "/vulns/?command_id=" + commandId; | |
318 | HttpClient httpClient = HttpClients.createDefault(); | |
319 | HttpPost httpPost = new HttpPost(this.baseUrl + VULN_URL); | |
320 | try { | |
321 | ||
322 | StringEntity stringEntity = new StringEntity(ConvertAlertToParams(alert, workspace, parentType, serviceId).toString()); | |
323 | httpPost.setHeader("Cookie", session); | |
324 | httpPost.setHeader("Content-Type", "application/json"); | |
325 | httpPost.setEntity(stringEntity); | |
326 | HttpResponse response = httpClient.execute(httpPost); | |
327 | return response.getStatusLine().getStatusCode(); | |
328 | ||
329 | } catch (UnsupportedEncodingException e) { | |
330 | // writing error to Log | |
331 | e.printStackTrace(); | |
332 | return 402; | |
333 | } catch (ClientProtocolException e) { | |
334 | e.printStackTrace(); | |
335 | return 402; | |
336 | } catch (IOException e) { | |
337 | e.printStackTrace(); | |
338 | return 402; | |
339 | } | |
340 | } | |
341 | ||
342 | private JSONObject ConvertAlertToParams(Alert alert, String workspace, String parentType, int parentId) { | |
343 | // Request parameters and other properties. | |
344 | JSONObject params = new JSONObject(); | |
345 | ||
346 | params.put("name", alert.getName()); | |
347 | params.put("ws", workspace); | |
348 | params.put("request", alert.getMessage().getRequestHeader().toString()); | |
349 | params.put("response", alert.getMessage().getResponseHeader().toString()); | |
350 | String desc = !alert.getParam().equals("") ? alert.getDescription() + "\nWith parameter: '" + alert.getParam() + "'" : | |
351 | alert.getDescription(); | |
352 | params.put("desc", desc); | |
353 | params.put("resolution", alert.getSolution()); | |
354 | params.put("type", "VulnerabilityWeb"); | |
355 | params.put("data", alert.getPostData()); | |
356 | params.put("policyviolations", "[]"); | |
357 | params.put("parent_type", parentType); | |
358 | params.put("parent", parentId); | |
359 | params.put("params", alert.getParam()); | |
360 | ||
361 | JSONObject metadata = new JSONObject(); | |
362 | metadata.put("creator", "OWASP"); | |
363 | params.put("metadata", metadata); | |
364 | ||
365 | String hostname = alert.getMessage().getRequestHeader().getHostName(); | |
366 | String IpAddres = GetIPFromHostname(hostname); | |
367 | JSONArray hostNamesArray = new JSONArray(); | |
368 | hostNamesArray.add(hostname); | |
369 | hostNamesArray.add(IpAddres); | |
370 | params.put("hostnames", hostNamesArray); | |
371 | params.put("target", IpAddres); | |
372 | params.put("website", hostname); | |
373 | ||
374 | JSONArray refsJsonArray = new JSONArray(); | |
375 | String[] resfArray = alert.getReference().split("\n"); | |
376 | Collections.addAll(refsJsonArray, resfArray); | |
377 | params.put("refs", refsJsonArray); | |
378 | ||
379 | try { | |
380 | params.put("path", alert.getMsgUri().getPath()); | |
381 | } catch (URIException e) { | |
382 | e.printStackTrace(); | |
383 | } | |
384 | ||
385 | if (alert.getConfidence() == 4) { | |
386 | params.put("confirmed", true); | |
387 | } | |
388 | ||
389 | switch (alert.getRisk()) { | |
390 | case 0: | |
391 | params.put("severity", "informational"); | |
392 | break; | |
393 | case 1: | |
394 | params.put("severity", "low"); | |
395 | break; | |
396 | case 2: | |
397 | params.put("severity", "medium"); | |
398 | break; | |
399 | case 3: | |
400 | params.put("severity", "high"); | |
401 | break; | |
402 | } | |
403 | return params; | |
404 | ||
405 | } | |
406 | ||
407 | private JSONObject ConvertHostToParams(Alert alert) { | |
408 | // Request parameters and other properties. | |
409 | JSONObject params = new JSONObject(); | |
410 | ||
411 | try { | |
412 | String ipAddress = GetIPFromHostname(alert.getMsgUri().getHost()); | |
413 | params.put("ip", ipAddress); | |
414 | params.put("name", alert.getMsgUri().getName()); | |
415 | params.put("os", "Unknown"); | |
416 | params.put("description", ""); | |
417 | JSONObject metadata = new JSONObject(); | |
418 | metadata.put("creator", "Zap"); | |
419 | params.put("metadata", metadata); | |
420 | ||
421 | String hostname = alert.getMessage().getRequestHeader().getHostName(); | |
422 | JSONArray hostNamesArray = new JSONArray(); | |
423 | hostNamesArray.add(hostname); | |
424 | params.put("hostnames", hostNamesArray); | |
425 | ||
426 | } catch (URIException e) { | |
427 | e.printStackTrace(); | |
428 | } | |
429 | return params; | |
430 | } | |
431 | ||
432 | private JSONObject ConvertServiceToParams(Alert alert, int parentId) { | |
433 | // Request parameters and other properties. | |
434 | JSONObject params = new JSONObject(); | |
435 | JSONArray portsJson = new JSONArray(); | |
436 | portsJson.add(alert.getMessage().getRequestHeader().getHostPort()); | |
437 | params.put("ports", portsJson); | |
438 | params.put("parent", parentId); | |
439 | params.put("status", "open"); | |
440 | params.put("type", "Service"); | |
441 | params.put("description", ""); | |
442 | JSONObject metadata = new JSONObject(); | |
443 | metadata.put("creator", "OWASP"); | |
444 | params.put("metadata", metadata); | |
445 | ||
446 | switch (alert.getMessage().getRequestHeader().getHostPort()) { | |
447 | case 21: | |
448 | params.put("name", "FTP"); | |
449 | params.put("protocol", "tcp"); | |
450 | break; | |
451 | case 22: | |
452 | params.put("name", "SSH"); | |
453 | params.put("protocol", "tcp"); | |
454 | break; | |
455 | case 23: | |
456 | params.put("name", "TELNET"); | |
457 | params.put("protocol", "tcp"); | |
458 | break; | |
459 | case 25: | |
460 | params.put("name", "SMTP"); | |
461 | params.put("protocol", "tcp"); | |
462 | break; | |
463 | case 80: | |
464 | params.put("name", "HTTP"); | |
465 | params.put("protocol", "tcp"); | |
466 | break; | |
467 | case 110: | |
468 | params.put("name", "POP"); | |
469 | params.put("protocol", "tcp"); | |
470 | break; | |
471 | case 443: | |
472 | params.put("name", "SSL"); | |
473 | params.put("protocol", "tcp"); | |
474 | break; | |
475 | default: | |
476 | params.put("name", "unknown"); | |
477 | params.put("protocol", "unknown"); | |
478 | break; | |
479 | } | |
480 | ||
481 | return params; | |
482 | } | |
483 | ||
484 | private JSONObject ConvertCommandToParams(String commandName) { | |
485 | // Request parameters and other properties. | |
486 | JSONObject params = new JSONObject(); | |
487 | params.put("itime", Instant.EPOCH.getEpochSecond()); | |
488 | params.put("import_source", "shell"); | |
489 | params.put("duration", ""); | |
490 | params.put("command", "Zap"); | |
491 | params.put("tool", commandName); | |
492 | return params; | |
493 | } | |
494 | ||
495 | private String GetIPFromHostname(String hostname) { | |
496 | try { | |
497 | InetAddress inetAddr = InetAddress.getByName(hostname); | |
498 | byte[] addr = inetAddr.getAddress(); | |
499 | ||
500 | // Convert to dot representation | |
501 | String ipAddr = ""; | |
502 | for (int i = 0; i < addr.length; i++) { | |
503 | if (i > 0) { | |
504 | ipAddr += "."; | |
505 | } | |
506 | ||
507 | ipAddr += addr[i] & 0xFF; | |
508 | } | |
509 | ||
510 | System.out.println("IP Address: " + ipAddr); | |
511 | return ipAddr; | |
512 | } catch (UnknownHostException e) { | |
513 | System.out.println("Host not found: " + e.getMessage()); | |
514 | return ""; | |
515 | } | |
516 | } | |
517 | ||
518 | public void setBaseUrl(String baseUrl) { | |
519 | this.baseUrl = baseUrl; | |
520 | } | |
521 | } | |
522 | ||
523 | ||
524 |
0 | /* | |
1 | * Zed Attack Proxy (ZAP) and its related class files. | |
2 | * | |
3 | * ZAP is an HTTP/HTTPS proxy for assessing web application security. | |
4 | * | |
5 | * Licensed under the Apache License, Version 2.0 (the "License"); | |
6 | * you may not use this file except in compliance with the License. | |
7 | * You may obtain a copy of the License at | |
8 | * | |
9 | * http://www.apache.org/licenses/LICENSE-2.0 | |
10 | * | |
11 | * Unless required by applicable law or agreed to in writing, software | |
12 | * distributed under the License is distributed on an "AS IS" BASIS, | |
13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | |
14 | * See the License for the specific language governing permissions and | |
15 | * limitations under the License. | |
16 | */ | |
17 | package org.zaproxy.zap.extension.faraday; | |
18 | ||
19 | import org.apache.log4j.Logger; | |
20 | import org.parosproxy.paros.Constant; | |
21 | import org.parosproxy.paros.control.Control; | |
22 | import org.parosproxy.paros.extension.ExtensionAdaptor; | |
23 | import org.parosproxy.paros.extension.ExtensionHook; | |
24 | import org.parosproxy.paros.extension.ExtensionPopupMenuItem; | |
25 | import org.zaproxy.zap.view.ZapMenuItem; | |
26 | ||
27 | import javax.swing.*; | |
28 | import java.awt.*; | |
29 | import java.awt.event.KeyEvent; | |
30 | import java.io.*; | |
31 | import java.util.Properties; | |
32 | import java.util.ResourceBundle; | |
33 | ||
34 | public class FaradayExtension extends ExtensionAdaptor { | |
35 | private static final Logger logger = Logger.getLogger(FaradayExtension.class); | |
36 | private ZapMenuItem menuItemFaradayConfig; | |
37 | private ConfigurationDialog configurationDialog; | |
38 | private PopupMenuItemSendAlert popupMenuItemSendAlert; | |
39 | private PopupMenuItemSendRequest popupMenuItemSendRequest; | |
40 | private ResourceBundle messages = null; | |
41 | ||
42 | ||
43 | ||
44 | public FaradayExtension(String name) { | |
45 | super(name); | |
46 | } | |
47 | ||
48 | ||
49 | public FaradayExtension() { | |
50 | super(); | |
51 | initialize(); | |
52 | } | |
53 | ||
54 | ||
55 | private void initialize() { | |
56 | messages = ResourceBundle.getBundle( | |
57 | this.getClass().getPackage().getName() + | |
58 | ".Messages", Constant.getLocale()); | |
59 | this.setName(messages.getString("faraday.extension.name")); | |
60 | this.initConfiguration(); | |
61 | } | |
62 | ||
63 | @Override | |
64 | public String getAuthor() { | |
65 | return messages.getString("faraday.extension.author"); | |
66 | } | |
67 | ||
68 | @Override | |
69 | public void hook(ExtensionHook extensionHook) { | |
70 | super.hook(extensionHook); | |
71 | ||
72 | if (getView() != null) { | |
73 | extensionHook.getHookMenu().addToolsMenuItem(getMenuItemFaradayConfig()); | |
74 | extensionHook.getHookMenu().addPopupMenuItem(this.getPopupMenuItem()); | |
75 | extensionHook.getHookMenu().addPopupMenuItem(this.getPopupMenuItemRequest()); | |
76 | } | |
77 | } | |
78 | ||
79 | @Override | |
80 | public boolean canUnload() { | |
81 | return true; | |
82 | } | |
83 | ||
84 | private ZapMenuItem getMenuItemFaradayConfig() { | |
85 | if (menuItemFaradayConfig == null) { | |
86 | menuItemFaradayConfig = new ZapMenuItem( | |
87 | "faraday.menu.tools.label", | |
88 | KeyStroke.getKeyStroke( | |
89 | KeyEvent.VK_F, | |
90 | Toolkit.getDefaultToolkit().getMenuShortcutKeyMask() | KeyEvent.ALT_DOWN_MASK, | |
91 | false)); | |
92 | menuItemFaradayConfig.setEnabled(Control.getSingleton().getMode() != Control.Mode.safe); | |
93 | ||
94 | menuItemFaradayConfig.addActionListener(new java.awt.event.ActionListener() { | |
95 | ||
96 | @Override | |
97 | public void actionPerformed(java.awt.event.ActionEvent e) { | |
98 | showConfigurationDialog(); | |
99 | } | |
100 | }); | |
101 | } | |
102 | return menuItemFaradayConfig; | |
103 | } | |
104 | ||
105 | ||
106 | private void showConfigurationDialog() { | |
107 | if (configurationDialog == null) { | |
108 | configurationDialog = new ConfigurationDialog(messages.getString("faraday.config.dialog.title")); | |
109 | configurationDialog.init(); | |
110 | } | |
111 | configurationDialog.setVisible(true); | |
112 | } | |
113 | ||
114 | ||
115 | private ExtensionPopupMenuItem getPopupMenuItem() { | |
116 | if (popupMenuItemSendAlert == null) { | |
117 | popupMenuItemSendAlert = new PopupMenuItemSendAlert(messages.getString("faraday.button.send.alert")); | |
118 | } | |
119 | ||
120 | return popupMenuItemSendAlert; | |
121 | ||
122 | } | |
123 | ||
124 | ||
125 | private ExtensionPopupMenuItem getPopupMenuItemRequest() { | |
126 | if (popupMenuItemSendRequest == null) { | |
127 | popupMenuItemSendRequest = new PopupMenuItemSendRequest(messages.getString("faraday.button.send.request")); | |
128 | } | |
129 | ||
130 | return popupMenuItemSendRequest; | |
131 | ||
132 | } | |
133 | ||
134 | ||
135 | private void initConfiguration() { | |
136 | Configuration configuration = Configuration.getSingleton(); | |
137 | ||
138 | Properties prop = new Properties(); | |
139 | InputStream input = null; | |
140 | ||
141 | try { | |
142 | String filePath = Constant.getZapHome() + "faraday" + File.separator + "default.properties"; | |
143 | input = new FileInputStream(filePath); | |
144 | ||
145 | // load a properties file | |
146 | prop.load(input); | |
147 | ||
148 | // set the properties value | |
149 | String fUser = prop.getProperty("default"); | |
150 | configuration.restore(fUser); | |
151 | ||
152 | } catch (IOException io) { | |
153 | System.out.println("We can't found default.properties file"); | |
154 | } finally { | |
155 | if (input != null) { | |
156 | try { | |
157 | input.close(); | |
158 | } catch (IOException e) { | |
159 | e.printStackTrace(); | |
160 | } | |
161 | } | |
162 | ||
163 | } | |
164 | } | |
165 | ||
166 | } |
0 | # An example ZAP extension which adds a top level menu item. | |
1 | # | |
2 | # This file defines the default (English) variants of all of the | |
3 | ||
4 | faraday.extension.name = Faraday Extension | |
5 | faraday.extension.author = Jorge Luis Gonzàlez Iznaga | |
6 | ||
7 | faraday.menu.tools.label = Faraday configuration options | |
8 | faraday.config.dialog.title = Faraday configuration | |
9 | faraday.config.dialog.tabs.auth = Authorization | |
10 | faraday.config.dialog.tabs.conf = Configuration | |
11 | faraday.config.dialog.auth.user = Faraday user | |
12 | faraday.config.dialog.auth.pass = Faraday password | |
13 | faraday.config.dialog.server = Faraday server | |
14 | faraday.config.dialog.auth.login = Login | |
15 | faraday.config.dialog.auth.logout = Logout | |
16 | faraday.config.dialog.import.current = Import current vulnerabilities | |
17 | faraday.config.dialog.import.new = Import new vulnerabilities | |
18 | faraday.config.dialog.restore = Restore configuration | |
19 | faraday.config.dialog.refresh = Refresh | |
20 | faraday.config.dialog.save = Save configuration | |
21 | faraday.config.dialog.workspace = Select faraday workspace | |
22 | faraday.config.dialog.default = Set this configuration as default | |
23 | ||
24 | faraday.config.dialog.tab.auth = Authorization | |
25 | faraday.config.dialog.tab.conf = Configuration | |
26 | ||
27 | faraday.dialog.enter.user = Please enter your user | |
28 | ||
29 | ||
30 | faraday.button.send.alert = Send alert to Faraday | |
31 | faraday.button.send.request = Send request to Faraday | |
32 | ||
33 | faraday.message.invalid.check.credentials = Please, check your credentials | |
34 | faraday.message.invalid.credentials = Invalid credentials | |
35 | faraday.dialog.login.title = Faraday login | |
36 | faraday.dialog.logout.title = Faraday logout | |
37 | faraday.dialog.logout.success = You're logout successfully ! | |
38 | faraday.dialog.logout.error = We can't complete logout operation | |
39 | ||
40 | faraday.dialog.button.close = Close | |
41 | ||
42 | faraday.save.config.success = Configuration saved successfully | |
43 | faraday.save.config.error = We can't save your configuration, please check home ZAP directory | |
44 | faraday.restore.config.error = You haven't a configuration saved with this user | |
45 | faraday.refresh.workspace.done = Your workspaces are up to date | |
46 | faraday.restore.config.error.login = Unable to restore this configuration | |
47 | faraday.set.default.config.error = We can't set your configuration | |
48 | ||
49 | faraday.send.alert.permissions.error = You should check your current workspace and your permissions | |
50 | faraday.send.alert.conflict = This alert already exists in Faraday | |
51 | faraday.send.request.conflict = This request already exists in Faraday | |
52 | faraday.send.alert.success = Alert added successfully | |
53 | faraday.send.request.success = Request added successfully | |
54 | ||
55 | faraday.tool.command.name = OWASP⏎ |
0 | package org.zaproxy.zap.extension.faraday; | |
1 | ||
2 | import org.apache.log4j.Logger; | |
3 | import org.parosproxy.paros.Constant; | |
4 | import org.parosproxy.paros.core.scanner.Alert; | |
5 | import org.parosproxy.paros.view.View; | |
6 | import org.zaproxy.zap.extension.alert.AlertNode; | |
7 | import org.zaproxy.zap.extension.alert.PopupMenuItemAlert; | |
8 | ||
9 | import javax.swing.*; | |
10 | import java.awt.*; | |
11 | import java.util.ResourceBundle; | |
12 | ||
13 | public class PopupMenuItemSendAlert extends PopupMenuItemAlert { | |
14 | private static final Logger logger = Logger.getLogger(PopupMenuItemSendAlert.class); | |
15 | private FaradayClient faradayClient; | |
16 | private ResourceBundle messages = null; | |
17 | private int selectionCount = 0; | |
18 | private int totalSelectionCount = 0; | |
19 | private boolean treeAlertParentSelected = false; | |
20 | ||
21 | public PopupMenuItemSendAlert(String label) { | |
22 | super(label, true); | |
23 | Configuration configuration = Configuration.getSingleton(); | |
24 | faradayClient = new FaradayClient(configuration.getServer()); | |
25 | messages = ResourceBundle.getBundle( | |
26 | this.getClass().getPackage().getName() + | |
27 | ".Messages", Constant.getLocale()); | |
28 | } | |
29 | ||
30 | @Override | |
31 | protected void performAction(Alert alert) { | |
32 | Configuration configuration = Configuration.getSingleton(); | |
33 | String workspace = configuration.getWorkspace(); | |
34 | String session = configuration.getSession(); | |
35 | if (workspace != null && session != null && !workspace.equals("") && !session.equals("")) { | |
36 | int responseCode = faradayClient.AddVulnerability(alert, configuration.getWorkspace(), session); | |
37 | String message; | |
38 | int iconMessage = 1; | |
39 | switch (responseCode) { | |
40 | case 200: | |
41 | case 201: | |
42 | case 409: | |
43 | message = messages.getString("faraday.send.alert.success"); | |
44 | break; | |
45 | case 403: | |
46 | message = messages.getString("faraday.send.alert.permissions.error"); | |
47 | iconMessage = JOptionPane.WARNING_MESSAGE; | |
48 | break; | |
49 | // case 409: | |
50 | // message = messages.getString("faraday.send.alert.conflict"); | |
51 | // iconMessage = JOptionPane.WARNING_MESSAGE; | |
52 | // break; | |
53 | case 400: | |
54 | case 500: | |
55 | message = "Unable to send " + alert.getName() + " to Faraday"; | |
56 | iconMessage = JOptionPane.ERROR_MESSAGE; | |
57 | break; | |
58 | ||
59 | default: | |
60 | message = "Unable to send " + alert.getName() + " to Faraday"; | |
61 | iconMessage = JOptionPane.ERROR_MESSAGE; | |
62 | break; | |
63 | } | |
64 | ||
65 | if (canShowMessageDialog()/*this.selectionCount == 1 && !treeAlertParentSelected*/) { | |
66 | JOptionPane.showMessageDialog( | |
67 | this, | |
68 | message, | |
69 | messages.getString("faraday.button.send.alert"), | |
70 | iconMessage); | |
71 | } | |
72 | ||
73 | ||
74 | logger.error(message); | |
75 | if (View.isInitialised()) { | |
76 | // Report info to the Output tab | |
77 | View.getSingleton().getOutputPanel().append(message + "\n"); | |
78 | } | |
79 | ||
80 | ||
81 | } else { | |
82 | if (canShowMessageDialog()) { | |
83 | JOptionPane.showMessageDialog( | |
84 | this, | |
85 | messages.getString("faraday.send.alert.permissions.error"), | |
86 | messages.getString("faraday.button.send.alert"), | |
87 | JOptionPane.ERROR_MESSAGE); | |
88 | logger.error(messages.getString("faraday.send.alert.permissions.error")); | |
89 | } | |
90 | ||
91 | ||
92 | if (View.isInitialised()) { | |
93 | // Report info to the Output tab | |
94 | View.getSingleton().getOutputPanel().append(messages.getString("faraday.send.alert.permissions.error") + "\n"); | |
95 | } | |
96 | } | |
97 | ||
98 | } | |
99 | ||
100 | @Override | |
101 | public boolean isEnableForComponent(Component invoker) { | |
102 | logger.info(invoker.getName()); | |
103 | this.totalSelectionCount = 0; | |
104 | try { | |
105 | if (Configuration.getSingleton().getSession() == null || Configuration.getSingleton().getSession().equals("")) { | |
106 | return false; | |
107 | } | |
108 | treeAlertParentSelected = ((JTree) invoker).isRowSelected(0); | |
109 | if (super.isEnableForComponent(invoker) || treeAlertParentSelected) { | |
110 | this.selectionCount = ((JTree) invoker).getSelectionCount(); | |
111 | for (int i = 0; i < ((JTree) invoker).getSelectionPaths().length; i++) { | |
112 | AlertNode nodeTemp = (AlertNode) ((JTree) invoker).getSelectionPaths()[i].getLastPathComponent(); | |
113 | this.totalSelectionCount += getTotalAlertsToProcess(nodeTemp); | |
114 | } | |
115 | ||
116 | setEnabled(true); | |
117 | return true; | |
118 | } | |
119 | return false; | |
120 | } catch (Exception e) { | |
121 | return false; | |
122 | } | |
123 | } | |
124 | ||
125 | ||
126 | private int getTotalAlertsToProcess(AlertNode node) { | |
127 | if (node.getChildCount() > 0) { | |
128 | int total = 0; | |
129 | for (int i = 0; i < node.getChildCount(); i++) { | |
130 | total += getTotalAlertsToProcess(node.getChildAt(i)); | |
131 | } | |
132 | return total; | |
133 | } else { | |
134 | return 1; | |
135 | } | |
136 | ||
137 | } | |
138 | ||
139 | private boolean canShowMessageDialog() { | |
140 | this.totalSelectionCount--; | |
141 | if (this.treeAlertParentSelected) { | |
142 | this.totalSelectionCount = 1; | |
143 | this.treeAlertParentSelected = false; | |
144 | } | |
145 | ||
146 | return this.totalSelectionCount == 0; | |
147 | } | |
148 | } |
0 | package org.zaproxy.zap.extension.faraday; | |
1 | ||
2 | import org.apache.log4j.Logger; | |
3 | import org.parosproxy.paros.Constant; | |
4 | import org.parosproxy.paros.core.scanner.Alert; | |
5 | import org.parosproxy.paros.db.DatabaseException; | |
6 | import org.parosproxy.paros.db.RecordAlert; | |
7 | import org.parosproxy.paros.model.HistoryReference; | |
8 | import org.parosproxy.paros.network.HttpMalformedHeaderException; | |
9 | import org.parosproxy.paros.view.View; | |
10 | import org.zaproxy.zap.extension.alert.PopupMenuAlert; | |
11 | import org.zaproxy.zap.view.messagecontainer.http.HttpMessageContainer; | |
12 | import org.zaproxy.zap.view.popup.PopupMenuItemHistoryReferenceContainer; | |
13 | ||
14 | import javax.swing.*; | |
15 | import java.awt.*; | |
16 | import java.util.Iterator; | |
17 | import java.util.List; | |
18 | import java.util.ResourceBundle; | |
19 | ||
20 | ||
21 | public class PopupMenuItemSendRequest extends PopupMenuItemHistoryReferenceContainer { | |
22 | private FaradayClient faradayClient; | |
23 | private ResourceBundle messages = null; | |
24 | private int selectionCount = 0; | |
25 | private static final Logger logger = Logger.getLogger(PopupMenuItemSendRequest.class); | |
26 | ||
27 | ||
28 | public PopupMenuItemSendRequest(String label) { | |
29 | super(label, true); | |
30 | Configuration configuration = Configuration.getSingleton(); | |
31 | faradayClient = new FaradayClient(configuration.getServer()); | |
32 | messages = ResourceBundle.getBundle( | |
33 | this.getClass().getPackage().getName() + | |
34 | ".Messages", Constant.getLocale()); | |
35 | } | |
36 | ||
37 | @Override | |
38 | public void performAction(HistoryReference href) { | |
39 | try { | |
40 | Alert alert = new Alert(new RecordAlert(), href); | |
41 | alert.setName(href.getSiteNode().getName()); | |
42 | alert.setUri(href.getURI().toString()); | |
43 | alert.setMessage(href.getHttpMessage()); | |
44 | alert.setDescription(""); | |
45 | alert.setRiskConfidence(0, 0); | |
46 | ||
47 | Configuration configuration = Configuration.getSingleton(); | |
48 | String workspace = configuration.getWorkspace(); | |
49 | String session = configuration.getSession(); | |
50 | if (workspace != null && session != null && !workspace.equals("") && !session.equals("")) { | |
51 | int responseCode = faradayClient.AddVulnerability(alert, configuration.getWorkspace(), session); | |
52 | String message = ""; | |
53 | int iconMessage = 1; | |
54 | switch (responseCode) { | |
55 | case 403: | |
56 | message = messages.getString("faraday.send.alert.permissions.error"); | |
57 | iconMessage = JOptionPane.WARNING_MESSAGE; | |
58 | break; | |
59 | case 409: | |
60 | message = messages.getString("faraday.send.request.conflict"); | |
61 | iconMessage = JOptionPane.WARNING_MESSAGE; | |
62 | break; | |
63 | case 500: | |
64 | message = "Unable to send " + alert.getName() + " to Faraday"; | |
65 | iconMessage = JOptionPane.ERROR_MESSAGE; | |
66 | break; | |
67 | case 201: | |
68 | message = messages.getString("faraday.send.request.success"); | |
69 | break; | |
70 | } | |
71 | ||
72 | if (this.selectionCount == 1) { | |
73 | JOptionPane.showMessageDialog( | |
74 | this, | |
75 | message, | |
76 | messages.getString("faraday.button.send.alert"), | |
77 | iconMessage); | |
78 | } | |
79 | ||
80 | logger.error(message); | |
81 | if (View.isInitialised()) { | |
82 | // Report info to the Output tab | |
83 | View.getSingleton().getOutputPanel().append(message + "\n"); | |
84 | } | |
85 | ||
86 | ||
87 | } else { | |
88 | JOptionPane.showMessageDialog( | |
89 | this, | |
90 | messages.getString("faraday.send.alert.permissions.error"), | |
91 | messages.getString("faraday.button.send.request"), | |
92 | JOptionPane.ERROR_MESSAGE); | |
93 | ||
94 | logger.error(messages.getString("faraday.send.alert.permissions.error")); | |
95 | if (View.isInitialised()) { | |
96 | // Report info to the Output tab | |
97 | View.getSingleton().getOutputPanel().append(messages.getString("faraday.send.alert.permissions.error") + "\n"); | |
98 | } | |
99 | } | |
100 | ||
101 | ||
102 | } catch (HttpMalformedHeaderException e) { | |
103 | e.printStackTrace(); | |
104 | } catch (DatabaseException e) { | |
105 | e.printStackTrace(); | |
106 | } | |
107 | } | |
108 | ||
109 | ||
110 | @Override | |
111 | public void performHistoryReferenceActions(List<HistoryReference> hrefs) { | |
112 | this.selectionCount = hrefs.size(); | |
113 | ||
114 | for (HistoryReference href : hrefs) { | |
115 | this.performAction(href); | |
116 | } | |
117 | } | |
118 | ||
119 | @Override | |
120 | public boolean isEnableForInvoker(Invoker invoker, HttpMessageContainer httpMessageContainer) { | |
121 | if (Configuration.getSingleton().getSession() == null || Configuration.getSingleton().getSession().equals("") || | |
122 | invoker.name().equals("ALERTS_PANEL")) { | |
123 | return false; | |
124 | } | |
125 | return super.isEnableForInvoker(invoker, httpMessageContainer); | |
126 | } | |
127 | ||
128 | @Override | |
129 | public boolean isButtonEnabledForHistoryReference(HistoryReference href) { | |
130 | if (Configuration.getSingleton().getSession() == null || Configuration.getSingleton().getSession().equals("")) { | |
131 | return false; | |
132 | } | |
133 | ||
134 | return href.getSiteNode() != null && super.isButtonEnabledForHistoryReference(href); | |
135 | } | |
136 | }⏎ |
0 | <zapaddon> | |
1 | <name>Faraday</name> | |
2 | <version>1</version> | |
3 | <status>release</status> | |
4 | <description>This extension integrates ZAP with the Faraday Integrated Penetration-Test Environment</description> | |
5 | <author>Jorge Luis González Iznaga</author> | |
6 | <extensions> | |
7 | <extension>org.zaproxy.zap.extension.faraday.FaradayExtension</extension> | |
8 | </extensions> | |
9 | <ascanrules/> | |
10 | <pscanrules/> | |
11 | <not-before-version>2.7.0</not-before-version> | |
12 | <not-from-version/> | |
13 | </zapaddon> |
3 | 3 | See the file 'doc/LICENSE' for the license information |
4 | 4 | """ |
5 | 5 | import re |
6 | import xml.etree.ElementTree as ET | |
6 | 7 | from urllib.parse import urlparse |
8 | ||
7 | 9 | from faraday_plugins.plugins.plugin import PluginXMLFormat |
8 | 10 | from faraday_plugins.plugins.plugins_utils import resolve_hostname |
9 | ||
10 | try: | |
11 | import xml.etree.cElementTree as ET | |
12 | ETREE_VERSION = ET.VERSION | |
13 | except ImportError: | |
14 | import xml.etree.ElementTree as ET | |
15 | ETREE_VERSION = ET.VERSION | |
16 | ||
17 | ETREE_VERSION = [int(i) for i in ETREE_VERSION.split(".")] | |
18 | ||
19 | 11 | |
20 | 12 | __author__ = "Francisco Amato" |
21 | 13 | __copyright__ = "Copyright (c) 2013, Infobyte LLC" |
27 | 19 | __status__ = "Development" |
28 | 20 | |
29 | 21 | |
30 | ||
31 | 22 | class ZapXmlParser: |
32 | 23 | """ |
33 | 24 | The objective of this class is to parse an xml |
51 | 42 | else: |
52 | 43 | self.sites = [] |
53 | 44 | |
54 | def parse_xml(self, xml_output): | |
45 | @staticmethod | |
46 | def parse_xml(xml_output): | |
55 | 47 | """ |
56 | 48 | Open and parse an xml file. |
57 | 49 | |
71 | 63 | |
72 | 64 | return tree |
73 | 65 | |
74 | def get_items(self, tree): | |
66 | @staticmethod | |
67 | def get_items(tree): | |
75 | 68 | """ |
76 | 69 | @return items A list of Host instances |
77 | 70 | """ |
85 | 78 | |
86 | 79 | @return An attribute value |
87 | 80 | """ |
88 | global ETREE_VERSION | |
89 | node = None | |
90 | ||
91 | if ETREE_VERSION[0] <= 1 and ETREE_VERSION[1] < 3: | |
92 | ||
93 | match_obj = re.search( | |
94 | "([^\@]+?)\[\@([^=]*?)=\'([^\']*?)\'", | |
95 | subnode_xpath_expr) | |
96 | ||
97 | if match_obj is not None: | |
98 | ||
99 | node_to_find = match_obj.group(1) | |
100 | xpath_attrib = match_obj.group(2) | |
101 | xpath_value = match_obj.group(3) | |
102 | ||
103 | for node_found in xml_node.findall(node_to_find): | |
104 | ||
105 | if node_found.attrib[xpath_attrib] == xpath_value: | |
106 | node = node_found | |
107 | break | |
108 | else: | |
109 | node = xml_node.find(subnode_xpath_expr) | |
110 | ||
111 | else: | |
112 | node = xml_node.find(subnode_xpath_expr) | |
81 | ||
82 | node = xml_node.find(subnode_xpath_expr) | |
113 | 83 | |
114 | 84 | if node is not None: |
115 | 85 | return node.get(attrib_name) |
116 | 86 | |
117 | 87 | return None |
88 | ||
89 | ||
90 | def strip_tags(data): | |
91 | """ | |
92 | Remove html tags from a string | |
93 | @return Stripped string | |
94 | """ | |
95 | clean = re.compile('<.*?>') | |
96 | return re.sub(clean, '', data) | |
118 | 97 | |
119 | 98 | |
120 | 99 | class Site: |
126 | 105 | self.host = self.node.get('host') |
127 | 106 | self.ip = resolve_hostname(self.host) |
128 | 107 | self.port = self.node.get('port') |
108 | self.ssl = self.node.get('ssl') | |
129 | 109 | |
130 | 110 | self.items = [] |
131 | 111 | for alert in self.node.findall('alerts/alertitem'): |
141 | 121 | if sub_node is not None: |
142 | 122 | return sub_node.text |
143 | 123 | return None |
144 | ||
145 | 124 | |
146 | 125 | |
147 | 126 | class Item: |
159 | 138 | self.name = self.get_text_from_subnode('alert') |
160 | 139 | self.severity = self.get_text_from_subnode('riskcode') |
161 | 140 | self.desc = self.get_text_from_subnode('desc') |
162 | ||
163 | 141 | if self.get_text_from_subnode('solution'): |
164 | 142 | self.resolution = self.get_text_from_subnode('solution') |
165 | 143 | else: |
166 | 144 | self.resolution = '' |
167 | 145 | |
146 | self.ref = [] | |
168 | 147 | if self.get_text_from_subnode('reference'): |
169 | self.desc += '\nReference: ' + \ | |
170 | self.get_text_from_subnode('reference') | |
171 | ||
172 | self.ref = [] | |
148 | links = self.get_text_from_subnode('reference') | |
149 | for link in links.split("</p>"): | |
150 | link = link.strip().replace("\n", "") | |
151 | if link != "": | |
152 | self.ref.append(strip_tags(link)) | |
153 | ||
173 | 154 | if self.get_text_from_subnode('cweid'): |
174 | self.ref.append("CWE-" + self.get_text_from_subnode('cweid')) | |
155 | self.ref.append("CWE:" + self.get_text_from_subnode('cweid')) | |
156 | ||
157 | if self.get_text_from_subnode('wascid'): | |
158 | self.ref.append("WASC:" + self.get_text_from_subnode('wascid')) | |
175 | 159 | |
176 | 160 | self.items = [] |
177 | 161 | |
182 | 166 | |
183 | 167 | for elem in arr: |
184 | 168 | uri = elem.find('uri').text |
185 | method_element = elem.find('method') | |
186 | if method_element: | |
187 | method = elem.find('method').text | |
169 | method = elem.findtext('method', "") | |
170 | item = self.parse_uri(uri, method) | |
171 | ||
172 | param = elem.findtext("param", "") | |
173 | attack = elem.findtext("attack", "") | |
174 | if attack and param: | |
175 | item["data"] = f"URL:\n {uri}\n Payload:\n {param} = {attack}" | |
188 | 176 | else: |
189 | method = "" | |
190 | self.parse_uri(uri, method) | |
191 | ||
192 | def parse_uri(self, uri, method): | |
177 | item["data"] = f"URL:\n {uri}\n Parameter:\n {param}" | |
178 | ||
179 | evidence = elem.findtext("evidence", "") | |
180 | if evidence: | |
181 | item["data"] = f"URL:\n {uri}\n Parameter:\n {param}\n Evidence:\n {evidence}" | |
182 | else: | |
183 | item["data"] = f"URL:\n {uri}\n" | |
184 | ||
185 | item["pname"] = elem.findtext("param", "") | |
186 | ||
187 | self.items.append(item) | |
188 | ||
189 | def parse_uri(self, uri, method) -> dict: | |
193 | 190 | |
194 | 191 | parsed_url = urlparse(uri) |
195 | 192 | protocol = parsed_url.scheme |
196 | 193 | host = parsed_url.netloc |
197 | 194 | port = parsed_url.port |
198 | ||
199 | try: | |
200 | params = [i.split('=')[0] | |
201 | for i in uri.split('?')[1].split('&')] | |
202 | except Exception as e: | |
203 | params = '' | |
204 | ||
205 | item = { | |
195 | params = self.extract_params_from_uri(uri) | |
196 | ||
197 | return { | |
206 | 198 | 'uri': uri, |
207 | 199 | 'params': ', '.join(params), |
208 | 200 | 'host': host, |
211 | 203 | 'port': port, |
212 | 204 | 'method': method, |
213 | 205 | 'path': parsed_url.path, |
214 | 'query': parsed_url.query | |
206 | 'query': parsed_url.query, | |
207 | 'data': "" | |
215 | 208 | } |
216 | self.items.append(item) | |
209 | ||
210 | @staticmethod | |
211 | def extract_params_from_uri(uri): | |
212 | params = re.findall("(\w+)=", uri) | |
213 | return params if params else '' | |
217 | 214 | |
218 | 215 | def get_text_from_subnode(self, subnode_xpath_expr): |
219 | 216 | """ |
238 | 235 | self.identifier_tag = "OWASPZAPReport" |
239 | 236 | self.id = "Zap" |
240 | 237 | self.name = "Zap XML Output Plugin" |
241 | self.plugin_version = "0.0.3" | |
242 | self.version = "2.4.3" | |
238 | self.plugin_version = "0.0.4" | |
239 | self.version = "2.10.0" | |
243 | 240 | self.framework_version = "1.0.0" |
244 | 241 | self.options = None |
245 | ||
246 | 242 | |
247 | 243 | def parseOutputString(self, output): |
248 | 244 | """ |
258 | 254 | if site.host != site.ip: |
259 | 255 | host = [site.host] |
260 | 256 | |
257 | if site.ssl == "true": | |
258 | service = "https" | |
259 | else: | |
260 | service = "http" | |
261 | ||
261 | 262 | h_id = self.createAndAddHost(site.ip, hostnames=host) |
262 | 263 | |
263 | s_id = self.createAndAddServiceToHost(h_id, "http", "tcp", ports=[site.port], status='open') | |
264 | s_id = self.createAndAddServiceToHost(h_id, service, "tcp", ports=[site.port], status='open') | |
264 | 265 | |
265 | 266 | for item in site.items: |
266 | 267 | for instance in item.items: |
268 | 269 | h_id, |
269 | 270 | s_id, |
270 | 271 | item.name, |
271 | item.desc, | |
272 | strip_tags(item.desc), | |
272 | 273 | website=instance['website'], |
273 | 274 | query=instance['query'], |
274 | 275 | severity=item.severity, |
276 | 277 | params=instance['params'], |
277 | 278 | method=instance['method'], |
278 | 279 | ref=item.ref, |
279 | resolution=item.resolution | |
280 | resolution=strip_tags(item.resolution), | |
281 | data=instance["data"], | |
282 | pname=instance["pname"], | |
283 | external_id="ZAP-" + str(item.id) | |
280 | 284 | ) |
281 | 285 | |
282 | 286 | del parser |
283 | ||
284 | ||
285 | def setHost(self): | |
286 | pass | |
287 | 287 | |
288 | 288 | |
289 | 289 | def createPlugin(ignore_info=False): |
0 | <?xml version="1.0" encoding="UTF-8"?><report> | |
1 | Report generated at Tue, 12 Jul 2011 08:32:22. | |
2 | <alertitem> | |
3 | <pluginid>40000</pluginid> | |
4 | <alert>Cookie set without HttpOnly flag</alert> | |
5 | <riskcode>1</riskcode> | |
6 | <reliability>2</reliability> | |
7 | <riskdesc>Low (Warning)</riskdesc> | |
8 | <desc>A cookie has been set without the HttpOnly flag, which means that the cookie can be accessed by JavaScript. If a malicious script can be run on this page then the cookie will be accessible and can be transmitted to another site. If this is a session cookie then session hijacking may be possible. | |
9 | </desc> | |
10 | <uri>http://192.168.1.100/</uri> | |
11 | <param>ASPSESSIONIDQSDRBCRQ=EEFHJOACLHOKLJHFNAFBBECK; path=/</param> | |
12 | <otherinfo/> | |
13 | <uri>http://www.web3.com.ar/ServFotoPorNoticia.asp</uri> | |
14 | <param>ASPSESSIONIDCQATADBB=LMFPHGLBHIIEDFILGFJEJNGE; path=/</param> | |
15 | <otherinfo/> | |
16 | <uri>http://www.web1.com.ar/acceso/include/valida.asp</uri> | |
17 | <param>ASPSESSIONIDSCBABSTB=MNPOKADDPAIDCDNBPGFDHGBF; path=/</param> | |
18 | <otherinfo/> | |
19 | <uri>http://www.web3.com.ar/files/</uri> | |
20 | <param>ASPSESSIONIDCSCTCABB=HFCNOPJBMNJEAHDHMCKAHOBN; path=/</param> | |
21 | <otherinfo/> | |
22 | <uri>http://www.web2.com.ar/acceso/include/valida.asp</uri> | |
23 | <param>ASPSESSIONIDQAASDACB=HADJFCIBOIANGBGNAOIDBGIL; path=/</param> | |
24 | <otherinfo/> | |
25 | <uri>http://www.web3.com.ar/</uri> | |
26 | <param>ASPSESSIONIDSABQACDB=PAJBMJHBLOFELCIKBNLAAKKJ; path=/</param> | |
27 | <otherinfo/> | |
28 | <solution>Ensure that the HttpOnly flag is set for all cookies. | |
29 | </solution> | |
30 | <reference>www.owasp.org/index.php/HttpOnly | |
31 | </reference> | |
32 | </alertitem> | |
33 | <alertitem> | |
34 | <pluginid>40001</pluginid> | |
35 | <alert>Password Autocomplete in browser</alert> | |
36 | <riskcode>1</riskcode> | |
37 | <reliability>2</reliability> | |
38 | <riskdesc>Low (Warning)</riskdesc> | |
39 | <desc>AUTOCOMPLETE attribute is not disabled in HTML FORM/INPUT element containing password type input. Passwords may be stored in browsers and retrieved. | |
40 | </desc> | |
41 | <uri>http://192.168.1.100/</uri> | |
42 | <param>input</param> | |
43 | <otherinfo/> | |
44 | <uri>http://www.web3.com.ar/</uri> | |
45 | <param>input</param> | |
46 | <otherinfo/> | |
47 | <uri>http://www.web3.com.ar/default.asp?errsession=1</uri> | |
48 | <param>input</param> | |
49 | <otherinfo/> | |
50 | <uri>http://www.web3.com.ar/</uri> | |
51 | <param>input</param> | |
52 | <otherinfo/> | |
53 | <uri>http://www.web3.com.ar/</uri> | |
54 | <param>input</param> | |
55 | <otherinfo/> | |
56 | <uri>http://www.web2.com.ar/dealers.htm</uri> | |
57 | <param>input</param> | |
58 | <otherinfo/> | |
59 | <uri>http://www.web3.com.ar/</uri> | |
60 | <param>input</param> | |
61 | <otherinfo/> | |
62 | <solution>Turn off AUTOCOMPLETE attribute in form or individual input elements containing password by using AUTOCOMPLETE='OFF' | |
63 | </solution> | |
64 | <reference>http://msdn.microsoft.com/library/default.asp?url=/workshop/author/forms/autocomplete_ovr.asp | |
65 | </reference> | |
66 | </alertitem> | |
67 | <alertitem> | |
68 | <pluginid>40003</pluginid> | |
69 | <alert>Cross site scripting</alert> | |
70 | <riskcode>3</riskcode> | |
71 | <reliability>2</reliability> | |
72 | <riskdesc>High (Warning)</riskdesc> | |
73 | <desc>Cross-site scripting or HTML injection is possible. Malicious script may be injected into the browser which appeared to be genuine content from the original site. These scripts can be used to execute arbitrary code or steal customer sensitive information such as user password or cookies. | |
74 | Very often this is in the form of a hyperlink with the injected script embeded in the query strings. However, XSS is possible via FORM POST data, cookies, user data sent from another user or shared data retrieved from database. | |
75 | Currently this check does not verify XSS from cookie or database. They should be checked manually if the application retrieve database records from another user's input. | |
76 | </desc> | |
77 | <uri>http://www.web3.com.ar/Mes.asp?hhFrm=frm&hhDia=DiaF&hhMes=MesF&hhAnno=%3CSCRIPT%3Ealert(%22OWASP%20ZAP%22);%3C/SCRIPT%3E</uri> | |
78 | <param>hhAnno=<SCRIPT>alert("OWASP ZAP");</SCRIPT></param> | |
79 | <otherinfo/> | |
80 | <uri>http://www.web3.com.ar/Mes.asp?hhFrm=frm&hhDia=DiaF&hhMes=%3CSCRIPT%3Ealert(%22OWASP%20ZAP%22);%3C/SCRIPT%3E&hhAnno=AnnoF</uri> | |
81 | <param>hhMes=<SCRIPT>alert("OWASP ZAP");</SCRIPT></param> | |
82 | <otherinfo/> | |
83 | <uri>http://www.web3.com.ar/Mes.asp?hhFrm=frm&hhDia=%3CSCRIPT%3Ealert(%22OWASP%20ZAP%22);%3C/SCRIPT%3E&hhMes=MesF&hhAnno=AnnoF</uri> | |
84 | <param>hhDia=<SCRIPT>alert("OWASP ZAP");</SCRIPT></param> | |
85 | <otherinfo/> | |
86 | <uri>http://www.web3.com.ar/Mes.asp?hhFrm=%3CSCRIPT%3Ealert(%22OWASP%20ZAP%22);%3C/SCRIPT%3E&hhDia=DiaF&hhMes=MesF&hhAnno=AnnoF</uri> | |
87 | <param>hhFrm=<SCRIPT>alert("OWASP ZAP");</SCRIPT></param> | |
88 | <otherinfo/> | |
89 | <solution>Do not trust client side input even if there is client side validation. Sanitize potentially danger characters in the server side. Very often filtering the <, >, " characters prevented injected script to be executed in most cases. However, sometimes other danger meta-characters such as ' , (, ), /, &, ; etc are also needed. | |
90 | In addition (or if these characters are needed), HTML encode meta-characters in the response. For example, encode < as &lt; | |
91 | ||
92 | </solution> | |
93 | <reference>The OWASP guide at http://www.owasp.org/documentation/guide | |
94 | http://www.technicalinfo.net/papers/CSS.html | |
95 | http://www.cgisecurity.org/articles/xss-faq.shtml | |
96 | http://www.cert.org/tech_tips/malicious_code_FAQ.html | |
97 | http://sandsprite.com/Sleuth/papers/RealWorld_XSS_1.html | |
98 | ||
99 | </reference> | |
100 | </alertitem> | |
101 | <alertitem> | |
102 | <pluginid>40004</pluginid> | |
103 | <alert>Cross site scripting without brackets</alert> | |
104 | <riskcode>3</riskcode> | |
105 | <reliability>1</reliability> | |
106 | <riskdesc>High (Suspicious)</riskdesc> | |
107 | <desc>Cross-site scripting or HTML injection is possible without '<' and '>'. Malicious script may be injected into the browser which appeared to be genuine content from the original site. These scripts can be used to execute arbitrary code or steal customer sensitive information such as user password or cookies. | |
108 | Very often this is in the form of a hyperlink with the injected script embeded in the query strings. However, XSS is possible via FORM POST data, cookies, user data sent from another user or shared data retrieved from database. | |
109 | Currently this check does not verify XSS from cookie or database. They should be checked manually if the application retrieve database records from another user's input. | |
110 | </desc> | |
111 | <uri>http://www.web3.com.ar/Mes.asp?hhFrm=frm&hhDia=DiaF&hhMes=MesF&hhAnno=paros%22%20style=%22background:url(javascript:alert('OWASP%20ZAP'))</uri> | |
112 | <param>hhAnno=paros" style="background:url(javascript:alert('OWASP ZAP'))</param> | |
113 | <otherinfo/> | |
114 | <uri>http://www.web3.com.ar/Mes.asp?hhFrm=frm&hhDia=DiaF&hhMes=paros%22%20style=%22background:url(javascript:alert('OWASP%20ZAP'))&hhAnno=%3CSCRIPT%3Ealert(%22OWASP%20ZAP%22);%3C/SCRIPT%3E</uri> | |
115 | <param>hhMes=paros" style="background:url(javascript:alert('OWASP ZAP'))</param> | |
116 | <otherinfo/> | |
117 | <uri>http://www.web3.com.ar/Mes.asp?hhFrm=frm&hhDia=paros%22%20style=%22background:url(javascript:alert('OWASP%20ZAP'))&hhMes=MesF&hhAnno=%3CSCRIPT%3Ealert(%22OWASP%20ZAP%22);%3C/SCRIPT%3E</uri> | |
118 | <param>hhDia=paros" style="background:url(javascript:alert('OWASP ZAP'))</param> | |
119 | <otherinfo/> | |
120 | <uri>http://www.web3.com.ar/Mes.asp?hhFrm=paros%22%20style=%22background:url(javascript:alert('OWASP%20ZAP'))&hhDia=DiaF&hhMes=MesF&hhAnno=%3CSCRIPT%3Ealert(%22OWASP%20ZAP%22);%3C/SCRIPT%3E</uri> | |
121 | <param>hhFrm=paros" style="background:url(javascript:alert('OWASP ZAP'))</param> | |
122 | <otherinfo/> | |
123 | <solution>Do not trust client side input even if there is client side validation. Sanitize potentially danger characters in the server side. Very often filtering the <, >, " characters prevented injected script to be executed in most cases. However, sometimes other danger meta-characters such as ' , (, ), /, &, ; etc are also needed. | |
124 | In addition (or if these characters are needed), HTML encode meta-characters in the response. For example, encode < as &lt; | |
125 | ||
126 | </solution> | |
127 | <reference>The OWASP guide at http://www.owasp.org/documentation/guide | |
128 | http://www.technicalinfo.net/papers/CSS.html | |
129 | http://www.cgisecurity.org/articles/xss-faq.shtml | |
130 | http://www.cert.org/tech_tips/malicious_code_FAQ.html | |
131 | http://sandsprite.com/Sleuth/papers/RealWorld_XSS_1.html | |
132 | ||
133 | </reference> | |
134 | </alertitem> | |
135 | <alertitem> | |
136 | <pluginid>40030</pluginid> | |
137 | <alert>SQL Injection</alert> | |
138 | <riskcode>3</riskcode> | |
139 | <reliability>2</reliability> | |
140 | <riskdesc>High (Warning)</riskdesc> | |
141 | <desc>SQL injection is possible. User parameters submitted will be formulated into a SQL query for database processing. If the query is built by simple 'string concatenation', it is possible to modify the meaning of the query by carefully crafting the parameters. Depending on the access right and type of database used, tampered query can be used to retrieve sensitive information from the database or execute arbitrary code. MS SQL and PostGreSQL, which supports multiple statements, may be exploited if the database access right is more powerful. | |
142 | This can occur in URL query strings, POST paramters or even cookies. Currently check on cookie is not supported by Paros. You should check SQL injection manually as well as some blind SQL injection areas cannot be discovered by this check. | |
143 | </desc> | |
144 | <uri>http://www.web3.com.ar/buscador.asp</uri> | |
145 | <param>hId=&hAreturn=&hAccion=OK&txtBuscar=test&x=0&y=0%27+AND+%271%27%3D%271</param> | |
146 | <otherinfo/> | |
147 | <uri>http://www.web3.com.ar/buscador.asp</uri> | |
148 | <param>hId=&hAreturn=&hAccion=OK%22+OR+%221%22%3D%221&txtBuscar=test&x=0&y=0</param> | |
149 | <otherinfo/> | |
150 | <solution>Do not trust client side input even if there is client side validation. In general, If the input string is numeric, type check it. | |
151 | If the application used JDBC, use PreparedStatement or CallableStatement with parameters passed by '?' | |
152 | If the application used ASP, use ADO Command Objects with strong type checking and parameterized query. | |
153 | If stored procedure or bind variables can be used, use it for parameter passing into query. Do not just concatenate string into query in the stored procedure! | |
154 | Do not create dynamic SQL query by simple string concatentation. | |
155 | Use minimum database user privilege for the application. This does not eliminate SQL injection but minimize its damage. Eg if the application require reading one table only, grant such access to the application. Avoid using 'sa' or 'db-owner'. | |
156 | ||
157 | </solution> | |
158 | <reference>The OWASP guide at http://www.owasp.org/documentation/guide | |
159 | http://www.sqlsecurity.com/DesktopDefault.aspx?tabid=23 | |
160 | http://www.spidynamics.com/whitepapers/WhitepaperSQLInjection.pdf | |
161 | For Oracle database, refer to http://www.integrigy.com/info/IntegrigyIntrotoSQLInjectionAttacks.pdf | |
162 | ||
163 | </reference> | |
164 | </alertitem> | |
165 | </report>⏎ |
13 | 13 | 'beautifulsoup4', |
14 | 14 | 'pytz', |
15 | 15 | 'python-dateutil', |
16 | 'colorama' | |
16 | 'colorama', | |
17 | 'tabulate' | |
17 | 18 | ] |
18 | 19 | |
19 | 20 | |
22 | 23 | version=version, |
23 | 24 | packages=find_packages(include=['faraday_plugins', 'faraday_plugins.*']), |
24 | 25 | url='', |
25 | license='', | |
26 | license="GNU General Public License v3", | |
26 | 27 | author='Faradaysec', |
27 | 28 | author_email='[email protected]', |
28 | 29 | description='Faraday plugins package', |
0 | 0 | { |
1 | 1 | "commands": [ |
2 | {"plugin_id": "ping", "command": "ping -c4 faradaysec.com"}, | |
3 | {"plugin_id": "whois", "command": "whois fradaysec.com"}, | |
4 | {"plugin_id": "nmap", "command": "nmap fradaysec.com"}, | |
5 | {"plugin_id": "skipfish", "command": "skipfish http://fradaysec.com"} | |
2 | {"plugin_id": "ping", "command": "ping -c4 faradaysec.com", "command_result": "ping"}, | |
3 | {"plugin_id": "whois", "command": "whois fradaysec.com", "command_result": "whois"}, | |
4 | {"plugin_id": "nmap", "command": "nmap fradaysec.com", "command_result": "nmap"}, | |
5 | {"plugin_id": "skipfish", "command": "skipfish http://fradaysec.com", "command_result": "skipfish"}, | |
6 | {"plugin_id": "sslyze_json", "command": "sslyze www.google.com --json_out=x.json", "command_result": "sslyze"}, | |
7 | {"plugin_id": "Amap", "command": "amap www.google.com", "command_result": "amap"}, | |
8 | {"plugin_id": "arp-scan", "command": "arp-scan www.google.com", "command_result": "arp-scan"}, | |
9 | {"plugin_id": "Beef", "command": "beef www.google.com", "command_result": "beef"}, | |
10 | {"plugin_id": "brutexss", "command": "brutexss www.google.com", "command_result": "brutexss"}, | |
11 | {"plugin_id": "dig", "command": "dig www.google.com", "command_result": "dig"}, | |
12 | {"plugin_id": "dirsearch", "command": "python3 dirsearch.py -u https://target", "command_result": "python3 dirsearch.py"}, | |
13 | ||
14 | {"plugin_id": "Dnsenum", "command": "dnsenum www.google.com", "command_result": "Dnsenum"}, | |
15 | {"plugin_id": "Dnsmap", "command": "dnsmap www.google.com", "command_result": "Dnsmap"}, | |
16 | {"plugin_id": "Dnsrecon", "command": "dnsrecon www.google.com", "command_result": "Dnsrecon"}, | |
17 | {"plugin_id": "Dnswalk", "command": "dnswalk www.google.com", "command_result": "Dnswalk"}, | |
18 | {"plugin_id": "Fierce", "command": "fierce www.google.com", "command_result": "Fierce"}, | |
19 | {"plugin_id": "fruitywifi", "command": "fruitywifi www.google.com", "command_result": "fruitywifi"}, | |
20 | {"plugin_id": "ftp", "command": "ftp www.google.com", "command_result": "ftp"}, | |
21 | {"plugin_id": "Goohost", "command": "goohost.sh www.google.com", "command_result": "goohost.sh"}, | |
22 | {"plugin_id": "Hping3", "command": "hping3 www.google.com", "command_result": "Hping3"}, | |
23 | {"plugin_id": "Hydra", "command": "hydra www.google.com", "command_result": "Hydra"}, | |
24 | {"plugin_id": "Lynis", "command": "lynis www.google.com", "command_result": "Lynis"}, | |
25 | {"plugin_id": "Medusa", "command": "medusa www.google.com", "command_result": "Medusa"}, | |
26 | {"plugin_id": "Ndiff", "command": "ndiff www.google.com", "command_result": "Ndiff"}, | |
27 | {"plugin_id": "Netdiscover", "command": "netdiscover www.google.com", "command_result": "Netdiscover"}, | |
28 | {"plugin_id": "nextnet", "command": "nextnet www.google.com", "command_result": "nextnet"}, | |
29 | {"plugin_id": "Nikto", "command": "nikto www.google.com", "command_result": "Nikto"}, | |
30 | {"plugin_id": "Nmap", "command": "nmap www.google.com", "command_result": "Nmap"}, | |
31 | {"plugin_id": "pasteAnalyzer", "command": "pasteAnalyzer www.google.com", "command_result": "pasteAnalyzer"}, | |
32 | {"plugin_id": "peepingtom", "command": "./peepingtom.py www.google.com", "command_result": "./peepingtom.py"}, | |
33 | {"plugin_id": "propecia", "command": "propecia www.google.com", "command_result": "propecia"}, | |
34 | {"plugin_id": "rdpscan", "command": "rdpscan www.google.com", "command_result": "rdpscan"}, | |
35 | {"plugin_id": "Reverseraider", "command": "./reverseraider www.google.com", "command_result": "./reverseraider"}, | |
36 | {"plugin_id": "Skipfish", "command": "skipfish www.google.com", "command_result": "Skipfish"}, | |
37 | {"plugin_id": "sshdefaultscan", "command": "./sshdefaultscan.py www.google.com", "command_result": "./sshdefaultscan.py"}, | |
38 | {"plugin_id": "Telnet", "command": "telnet www.google.com", "command_result": "telnet"}, | |
39 | {"plugin_id": "Theharvester", "command": "./theHarvester.py www.google.com", "command_result": "./theharvester.py"}, | |
40 | {"plugin_id": "Traceroute", "command": "traceroute www.google.com", "command_result": "Traceroute"}, | |
41 | {"plugin_id": "W3af", "command": "w3af www.google.com", "command_result": "W3af"}, | |
42 | {"plugin_id": "Wapiti", "command": "wapiti www.google.com", "command_result": "Wapiti"}, | |
43 | {"plugin_id": "Wcscan", "command": "wcscan www.google.com", "command_result": "Wcscan"}, | |
44 | {"plugin_id": "Webfuzzer", "command": "webfuzzer www.google.com", "command_result": "Webfuzzer"}, | |
45 | {"plugin_id": "Wfuzz", "command": "wfuzz www.google.com", "command_result": "Wfuzz"}, | |
46 | {"plugin_id": "whois", "command": "whois www.google.com", "command_result": "whois"}, | |
47 | {"plugin_id": "X1", "command": "./x1 www.google.com", "command_result": "./x1"}, | |
48 | {"plugin_id": "xsssniper", "command": "xsssniper www.google.com", "command_result": "xsssniper"}, | |
49 | {"plugin_id": "dirb", "command": "dirb google.com", "command_result": "dirb"}, | |
50 | {"plugin_id": "Arachni", "command": "arachni www.google.com", "command_result": "Arachni"} | |
6 | 51 | ] |
7 | }⏎ | |
52 | } |
34 | 34 | assert result.exit_code == 0 |
35 | 35 | summary = json.loads(result.output.strip()) |
36 | 36 | assert summary['hosts'] == 1 |
37 | ||
38 | ||
39 | def test_process_command_ping(): | |
40 | runner = CliRunner() | |
41 | result = runner.invoke(process_command, args=['ping -c 1 www.google.com']) | |
42 | assert result.exit_code == 0 | |
43 | summary = json.loads(result.output.strip()) | |
44 | ||
45 | assert summary['command']["command"] == 'ping' | |
37 | 46 | |
38 | 47 | |
39 | 48 | def test_process_command_to_file(): |
19 | 19 | def test_autodetected_on_commands(command_data): |
20 | 20 | plugin_id = command_data["plugin_id"] |
21 | 21 | command_string = command_data["command"] |
22 | command_result = command_data["command_result"] | |
23 | ||
22 | 24 | plugin: PluginBase = analyzer.get_plugin(command_string) |
23 | 25 | assert plugin, command_string |
24 | 26 | assert plugin.id.lower() == plugin_id.lower() |
27 | assert plugin.command.lower() == command_result.lower() | |
25 | 28 |