├── LICENSE ├── README.md ├── analyzeJS.sh ├── logo.svg └── tools ├── gau ├── getjswords.py ├── hakrawler ├── httpx ├── jsbeautify.py ├── linkfinder.py ├── secretfinder.py └── subjs /LICENSE: -------------------------------------------------------------------------------- 1 | GNU GENERAL PUBLIC LICENSE 2 | Version 3, 29 June 2007 3 | 4 | Copyright (C) 2007 Free Software Foundation, Inc. 5 | Everyone is permitted to copy and distribute verbatim copies 6 | of this license document, but changing it is not allowed. 7 | 8 | Preamble 9 | 10 | The GNU General Public License is a free, copyleft license for 11 | software and other kinds of works. 12 | 13 | The licenses for most software and other practical works are designed 14 | to take away your freedom to share and change the works. By contrast, 15 | the GNU General Public License is intended to guarantee your freedom to 16 | share and change all versions of a program--to make sure it remains free 17 | software for all its users. We, the Free Software Foundation, use the 18 | GNU General Public License for most of our software; it applies also to 19 | any other work released this way by its authors. You can apply it to 20 | your programs, too. 21 | 22 | When we speak of free software, we are referring to freedom, not 23 | price. Our General Public Licenses are designed to make sure that you 24 | have the freedom to distribute copies of free software (and charge for 25 | them if you wish), that you receive source code or can get it if you 26 | want it, that you can change the software or use pieces of it in new 27 | free programs, and that you know you can do these things. 28 | 29 | To protect your rights, we need to prevent others from denying you 30 | these rights or asking you to surrender the rights. Therefore, you have 31 | certain responsibilities if you distribute copies of the software, or if 32 | you modify it: responsibilities to respect the freedom of others. 33 | 34 | For example, if you distribute copies of such a program, whether 35 | gratis or for a fee, you must pass on to the recipients the same 36 | freedoms that you received. You must make sure that they, too, receive 37 | or can get the source code. And you must show them these terms so they 38 | know their rights. 39 | 40 | Developers that use the GNU GPL protect your rights with two steps: 41 | (1) assert copyright on the software, and (2) offer you this License 42 | giving you legal permission to copy, distribute and/or modify it. 43 | 44 | For the developers' and authors' protection, the GPL clearly explains 45 | that there is no warranty for this free software. For both users' and 46 | authors' sake, the GPL requires that modified versions be marked as 47 | changed, so that their problems will not be attributed erroneously to 48 | authors of previous versions. 49 | 50 | Some devices are designed to deny users access to install or run 51 | modified versions of the software inside them, although the manufacturer 52 | can do so. This is fundamentally incompatible with the aim of 53 | protecting users' freedom to change the software. The systematic 54 | pattern of such abuse occurs in the area of products for individuals to 55 | use, which is precisely where it is most unacceptable. Therefore, we 56 | have designed this version of the GPL to prohibit the practice for those 57 | products. If such problems arise substantially in other domains, we 58 | stand ready to extend this provision to those domains in future versions 59 | of the GPL, as needed to protect the freedom of users. 60 | 61 | Finally, every program is threatened constantly by software patents. 62 | States should not allow patents to restrict development and use of 63 | software on general-purpose computers, but in those that do, we wish to 64 | avoid the special danger that patents applied to a free program could 65 | make it effectively proprietary. To prevent this, the GPL assures that 66 | patents cannot be used to render the program non-free. 67 | 68 | The precise terms and conditions for copying, distribution and 69 | modification follow. 70 | 71 | TERMS AND CONDITIONS 72 | 73 | 0. Definitions. 74 | 75 | "This License" refers to version 3 of the GNU General Public License. 76 | 77 | "Copyright" also means copyright-like laws that apply to other kinds of 78 | works, such as semiconductor masks. 79 | 80 | "The Program" refers to any copyrightable work licensed under this 81 | License. Each licensee is addressed as "you". "Licensees" and 82 | "recipients" may be individuals or organizations. 83 | 84 | To "modify" a work means to copy from or adapt all or part of the work 85 | in a fashion requiring copyright permission, other than the making of an 86 | exact copy. The resulting work is called a "modified version" of the 87 | earlier work or a work "based on" the earlier work. 88 | 89 | A "covered work" means either the unmodified Program or a work based 90 | on the Program. 91 | 92 | To "propagate" a work means to do anything with it that, without 93 | permission, would make you directly or secondarily liable for 94 | infringement under applicable copyright law, except executing it on a 95 | computer or modifying a private copy. Propagation includes copying, 96 | distribution (with or without modification), making available to the 97 | public, and in some countries other activities as well. 98 | 99 | To "convey" a work means any kind of propagation that enables other 100 | parties to make or receive copies. Mere interaction with a user through 101 | a computer network, with no transfer of a copy, is not conveying. 102 | 103 | An interactive user interface displays "Appropriate Legal Notices" 104 | to the extent that it includes a convenient and prominently visible 105 | feature that (1) displays an appropriate copyright notice, and (2) 106 | tells the user that there is no warranty for the work (except to the 107 | extent that warranties are provided), that licensees may convey the 108 | work under this License, and how to view a copy of this License. If 109 | the interface presents a list of user commands or options, such as a 110 | menu, a prominent item in the list meets this criterion. 111 | 112 | 1. Source Code. 113 | 114 | The "source code" for a work means the preferred form of the work 115 | for making modifications to it. "Object code" means any non-source 116 | form of a work. 117 | 118 | A "Standard Interface" means an interface that either is an official 119 | standard defined by a recognized standards body, or, in the case of 120 | interfaces specified for a particular programming language, one that 121 | is widely used among developers working in that language. 122 | 123 | The "System Libraries" of an executable work include anything, other 124 | than the work as a whole, that (a) is included in the normal form of 125 | packaging a Major Component, but which is not part of that Major 126 | Component, and (b) serves only to enable use of the work with that 127 | Major Component, or to implement a Standard Interface for which an 128 | implementation is available to the public in source code form. A 129 | "Major Component", in this context, means a major essential component 130 | (kernel, window system, and so on) of the specific operating system 131 | (if any) on which the executable work runs, or a compiler used to 132 | produce the work, or an object code interpreter used to run it. 133 | 134 | The "Corresponding Source" for a work in object code form means all 135 | the source code needed to generate, install, and (for an executable 136 | work) run the object code and to modify the work, including scripts to 137 | control those activities. However, it does not include the work's 138 | System Libraries, or general-purpose tools or generally available free 139 | programs which are used unmodified in performing those activities but 140 | which are not part of the work. For example, Corresponding Source 141 | includes interface definition files associated with source files for 142 | the work, and the source code for shared libraries and dynamically 143 | linked subprograms that the work is specifically designed to require, 144 | such as by intimate data communication or control flow between those 145 | subprograms and other parts of the work. 146 | 147 | The Corresponding Source need not include anything that users 148 | can regenerate automatically from other parts of the Corresponding 149 | Source. 150 | 151 | The Corresponding Source for a work in source code form is that 152 | same work. 153 | 154 | 2. Basic Permissions. 155 | 156 | All rights granted under this License are granted for the term of 157 | copyright on the Program, and are irrevocable provided the stated 158 | conditions are met. This License explicitly affirms your unlimited 159 | permission to run the unmodified Program. The output from running a 160 | covered work is covered by this License only if the output, given its 161 | content, constitutes a covered work. This License acknowledges your 162 | rights of fair use or other equivalent, as provided by copyright law. 163 | 164 | You may make, run and propagate covered works that you do not 165 | convey, without conditions so long as your license otherwise remains 166 | in force. You may convey covered works to others for the sole purpose 167 | of having them make modifications exclusively for you, or provide you 168 | with facilities for running those works, provided that you comply with 169 | the terms of this License in conveying all material for which you do 170 | not control copyright. Those thus making or running the covered works 171 | for you must do so exclusively on your behalf, under your direction 172 | and control, on terms that prohibit them from making any copies of 173 | your copyrighted material outside their relationship with you. 174 | 175 | Conveying under any other circumstances is permitted solely under 176 | the conditions stated below. Sublicensing is not allowed; section 10 177 | makes it unnecessary. 178 | 179 | 3. Protecting Users' Legal Rights From Anti-Circumvention Law. 180 | 181 | No covered work shall be deemed part of an effective technological 182 | measure under any applicable law fulfilling obligations under article 183 | 11 of the WIPO copyright treaty adopted on 20 December 1996, or 184 | similar laws prohibiting or restricting circumvention of such 185 | measures. 186 | 187 | When you convey a covered work, you waive any legal power to forbid 188 | circumvention of technological measures to the extent such circumvention 189 | is effected by exercising rights under this License with respect to 190 | the covered work, and you disclaim any intention to limit operation or 191 | modification of the work as a means of enforcing, against the work's 192 | users, your or third parties' legal rights to forbid circumvention of 193 | technological measures. 194 | 195 | 4. Conveying Verbatim Copies. 196 | 197 | You may convey verbatim copies of the Program's source code as you 198 | receive it, in any medium, provided that you conspicuously and 199 | appropriately publish on each copy an appropriate copyright notice; 200 | keep intact all notices stating that this License and any 201 | non-permissive terms added in accord with section 7 apply to the code; 202 | keep intact all notices of the absence of any warranty; and give all 203 | recipients a copy of this License along with the Program. 204 | 205 | You may charge any price or no price for each copy that you convey, 206 | and you may offer support or warranty protection for a fee. 207 | 208 | 5. Conveying Modified Source Versions. 209 | 210 | You may convey a work based on the Program, or the modifications to 211 | produce it from the Program, in the form of source code under the 212 | terms of section 4, provided that you also meet all of these conditions: 213 | 214 | a) The work must carry prominent notices stating that you modified 215 | it, and giving a relevant date. 216 | 217 | b) The work must carry prominent notices stating that it is 218 | released under this License and any conditions added under section 219 | 7. This requirement modifies the requirement in section 4 to 220 | "keep intact all notices". 221 | 222 | c) You must license the entire work, as a whole, under this 223 | License to anyone who comes into possession of a copy. This 224 | License will therefore apply, along with any applicable section 7 225 | additional terms, to the whole of the work, and all its parts, 226 | regardless of how they are packaged. This License gives no 227 | permission to license the work in any other way, but it does not 228 | invalidate such permission if you have separately received it. 229 | 230 | d) If the work has interactive user interfaces, each must display 231 | Appropriate Legal Notices; however, if the Program has interactive 232 | interfaces that do not display Appropriate Legal Notices, your 233 | work need not make them do so. 234 | 235 | A compilation of a covered work with other separate and independent 236 | works, which are not by their nature extensions of the covered work, 237 | and which are not combined with it such as to form a larger program, 238 | in or on a volume of a storage or distribution medium, is called an 239 | "aggregate" if the compilation and its resulting copyright are not 240 | used to limit the access or legal rights of the compilation's users 241 | beyond what the individual works permit. Inclusion of a covered work 242 | in an aggregate does not cause this License to apply to the other 243 | parts of the aggregate. 244 | 245 | 6. Conveying Non-Source Forms. 246 | 247 | You may convey a covered work in object code form under the terms 248 | of sections 4 and 5, provided that you also convey the 249 | machine-readable Corresponding Source under the terms of this License, 250 | in one of these ways: 251 | 252 | a) Convey the object code in, or embodied in, a physical product 253 | (including a physical distribution medium), accompanied by the 254 | Corresponding Source fixed on a durable physical medium 255 | customarily used for software interchange. 256 | 257 | b) Convey the object code in, or embodied in, a physical product 258 | (including a physical distribution medium), accompanied by a 259 | written offer, valid for at least three years and valid for as 260 | long as you offer spare parts or customer support for that product 261 | model, to give anyone who possesses the object code either (1) a 262 | copy of the Corresponding Source for all the software in the 263 | product that is covered by this License, on a durable physical 264 | medium customarily used for software interchange, for a price no 265 | more than your reasonable cost of physically performing this 266 | conveying of source, or (2) access to copy the 267 | Corresponding Source from a network server at no charge. 268 | 269 | c) Convey individual copies of the object code with a copy of the 270 | written offer to provide the Corresponding Source. This 271 | alternative is allowed only occasionally and noncommercially, and 272 | only if you received the object code with such an offer, in accord 273 | with subsection 6b. 274 | 275 | d) Convey the object code by offering access from a designated 276 | place (gratis or for a charge), and offer equivalent access to the 277 | Corresponding Source in the same way through the same place at no 278 | further charge. You need not require recipients to copy the 279 | Corresponding Source along with the object code. If the place to 280 | copy the object code is a network server, the Corresponding Source 281 | may be on a different server (operated by you or a third party) 282 | that supports equivalent copying facilities, provided you maintain 283 | clear directions next to the object code saying where to find the 284 | Corresponding Source. Regardless of what server hosts the 285 | Corresponding Source, you remain obligated to ensure that it is 286 | available for as long as needed to satisfy these requirements. 287 | 288 | e) Convey the object code using peer-to-peer transmission, provided 289 | you inform other peers where the object code and Corresponding 290 | Source of the work are being offered to the general public at no 291 | charge under subsection 6d. 292 | 293 | A separable portion of the object code, whose source code is excluded 294 | from the Corresponding Source as a System Library, need not be 295 | included in conveying the object code work. 296 | 297 | A "User Product" is either (1) a "consumer product", which means any 298 | tangible personal property which is normally used for personal, family, 299 | or household purposes, or (2) anything designed or sold for incorporation 300 | into a dwelling. In determining whether a product is a consumer product, 301 | doubtful cases shall be resolved in favor of coverage. For a particular 302 | product received by a particular user, "normally used" refers to a 303 | typical or common use of that class of product, regardless of the status 304 | of the particular user or of the way in which the particular user 305 | actually uses, or expects or is expected to use, the product. A product 306 | is a consumer product regardless of whether the product has substantial 307 | commercial, industrial or non-consumer uses, unless such uses represent 308 | the only significant mode of use of the product. 309 | 310 | "Installation Information" for a User Product means any methods, 311 | procedures, authorization keys, or other information required to install 312 | and execute modified versions of a covered work in that User Product from 313 | a modified version of its Corresponding Source. The information must 314 | suffice to ensure that the continued functioning of the modified object 315 | code is in no case prevented or interfered with solely because 316 | modification has been made. 317 | 318 | If you convey an object code work under this section in, or with, or 319 | specifically for use in, a User Product, and the conveying occurs as 320 | part of a transaction in which the right of possession and use of the 321 | User Product is transferred to the recipient in perpetuity or for a 322 | fixed term (regardless of how the transaction is characterized), the 323 | Corresponding Source conveyed under this section must be accompanied 324 | by the Installation Information. But this requirement does not apply 325 | if neither you nor any third party retains the ability to install 326 | modified object code on the User Product (for example, the work has 327 | been installed in ROM). 328 | 329 | The requirement to provide Installation Information does not include a 330 | requirement to continue to provide support service, warranty, or updates 331 | for a work that has been modified or installed by the recipient, or for 332 | the User Product in which it has been modified or installed. Access to a 333 | network may be denied when the modification itself materially and 334 | adversely affects the operation of the network or violates the rules and 335 | protocols for communication across the network. 336 | 337 | Corresponding Source conveyed, and Installation Information provided, 338 | in accord with this section must be in a format that is publicly 339 | documented (and with an implementation available to the public in 340 | source code form), and must require no special password or key for 341 | unpacking, reading or copying. 342 | 343 | 7. Additional Terms. 344 | 345 | "Additional permissions" are terms that supplement the terms of this 346 | License by making exceptions from one or more of its conditions. 347 | Additional permissions that are applicable to the entire Program shall 348 | be treated as though they were included in this License, to the extent 349 | that they are valid under applicable law. If additional permissions 350 | apply only to part of the Program, that part may be used separately 351 | under those permissions, but the entire Program remains governed by 352 | this License without regard to the additional permissions. 353 | 354 | When you convey a copy of a covered work, you may at your option 355 | remove any additional permissions from that copy, or from any part of 356 | it. (Additional permissions may be written to require their own 357 | removal in certain cases when you modify the work.) You may place 358 | additional permissions on material, added by you to a covered work, 359 | for which you have or can give appropriate copyright permission. 360 | 361 | Notwithstanding any other provision of this License, for material you 362 | add to a covered work, you may (if authorized by the copyright holders of 363 | that material) supplement the terms of this License with terms: 364 | 365 | a) Disclaiming warranty or limiting liability differently from the 366 | terms of sections 15 and 16 of this License; or 367 | 368 | b) Requiring preservation of specified reasonable legal notices or 369 | author attributions in that material or in the Appropriate Legal 370 | Notices displayed by works containing it; or 371 | 372 | c) Prohibiting misrepresentation of the origin of that material, or 373 | requiring that modified versions of such material be marked in 374 | reasonable ways as different from the original version; or 375 | 376 | d) Limiting the use for publicity purposes of names of licensors or 377 | authors of the material; or 378 | 379 | e) Declining to grant rights under trademark law for use of some 380 | trade names, trademarks, or service marks; or 381 | 382 | f) Requiring indemnification of licensors and authors of that 383 | material by anyone who conveys the material (or modified versions of 384 | it) with contractual assumptions of liability to the recipient, for 385 | any liability that these contractual assumptions directly impose on 386 | those licensors and authors. 387 | 388 | All other non-permissive additional terms are considered "further 389 | restrictions" within the meaning of section 10. If the Program as you 390 | received it, or any part of it, contains a notice stating that it is 391 | governed by this License along with a term that is a further 392 | restriction, you may remove that term. If a license document contains 393 | a further restriction but permits relicensing or conveying under this 394 | License, you may add to a covered work material governed by the terms 395 | of that license document, provided that the further restriction does 396 | not survive such relicensing or conveying. 397 | 398 | If you add terms to a covered work in accord with this section, you 399 | must place, in the relevant source files, a statement of the 400 | additional terms that apply to those files, or a notice indicating 401 | where to find the applicable terms. 402 | 403 | Additional terms, permissive or non-permissive, may be stated in the 404 | form of a separately written license, or stated as exceptions; 405 | the above requirements apply either way. 406 | 407 | 8. Termination. 408 | 409 | You may not propagate or modify a covered work except as expressly 410 | provided under this License. Any attempt otherwise to propagate or 411 | modify it is void, and will automatically terminate your rights under 412 | this License (including any patent licenses granted under the third 413 | paragraph of section 11). 414 | 415 | However, if you cease all violation of this License, then your 416 | license from a particular copyright holder is reinstated (a) 417 | provisionally, unless and until the copyright holder explicitly and 418 | finally terminates your license, and (b) permanently, if the copyright 419 | holder fails to notify you of the violation by some reasonable means 420 | prior to 60 days after the cessation. 421 | 422 | Moreover, your license from a particular copyright holder is 423 | reinstated permanently if the copyright holder notifies you of the 424 | violation by some reasonable means, this is the first time you have 425 | received notice of violation of this License (for any work) from that 426 | copyright holder, and you cure the violation prior to 30 days after 427 | your receipt of the notice. 428 | 429 | Termination of your rights under this section does not terminate the 430 | licenses of parties who have received copies or rights from you under 431 | this License. If your rights have been terminated and not permanently 432 | reinstated, you do not qualify to receive new licenses for the same 433 | material under section 10. 434 | 435 | 9. Acceptance Not Required for Having Copies. 436 | 437 | You are not required to accept this License in order to receive or 438 | run a copy of the Program. Ancillary propagation of a covered work 439 | occurring solely as a consequence of using peer-to-peer transmission 440 | to receive a copy likewise does not require acceptance. However, 441 | nothing other than this License grants you permission to propagate or 442 | modify any covered work. These actions infringe copyright if you do 443 | not accept this License. Therefore, by modifying or propagating a 444 | covered work, you indicate your acceptance of this License to do so. 445 | 446 | 10. Automatic Licensing of Downstream Recipients. 447 | 448 | Each time you convey a covered work, the recipient automatically 449 | receives a license from the original licensors, to run, modify and 450 | propagate that work, subject to this License. You are not responsible 451 | for enforcing compliance by third parties with this License. 452 | 453 | An "entity transaction" is a transaction transferring control of an 454 | organization, or substantially all assets of one, or subdividing an 455 | organization, or merging organizations. If propagation of a covered 456 | work results from an entity transaction, each party to that 457 | transaction who receives a copy of the work also receives whatever 458 | licenses to the work the party's predecessor in interest had or could 459 | give under the previous paragraph, plus a right to possession of the 460 | Corresponding Source of the work from the predecessor in interest, if 461 | the predecessor has it or can get it with reasonable efforts. 462 | 463 | You may not impose any further restrictions on the exercise of the 464 | rights granted or affirmed under this License. For example, you may 465 | not impose a license fee, royalty, or other charge for exercise of 466 | rights granted under this License, and you may not initiate litigation 467 | (including a cross-claim or counterclaim in a lawsuit) alleging that 468 | any patent claim is infringed by making, using, selling, offering for 469 | sale, or importing the Program or any portion of it. 470 | 471 | 11. Patents. 472 | 473 | A "contributor" is a copyright holder who authorizes use under this 474 | License of the Program or a work on which the Program is based. The 475 | work thus licensed is called the contributor's "contributor version". 476 | 477 | A contributor's "essential patent claims" are all patent claims 478 | owned or controlled by the contributor, whether already acquired or 479 | hereafter acquired, that would be infringed by some manner, permitted 480 | by this License, of making, using, or selling its contributor version, 481 | but do not include claims that would be infringed only as a 482 | consequence of further modification of the contributor version. For 483 | purposes of this definition, "control" includes the right to grant 484 | patent sublicenses in a manner consistent with the requirements of 485 | this License. 486 | 487 | Each contributor grants you a non-exclusive, worldwide, royalty-free 488 | patent license under the contributor's essential patent claims, to 489 | make, use, sell, offer for sale, import and otherwise run, modify and 490 | propagate the contents of its contributor version. 491 | 492 | In the following three paragraphs, a "patent license" is any express 493 | agreement or commitment, however denominated, not to enforce a patent 494 | (such as an express permission to practice a patent or covenant not to 495 | sue for patent infringement). To "grant" such a patent license to a 496 | party means to make such an agreement or commitment not to enforce a 497 | patent against the party. 498 | 499 | If you convey a covered work, knowingly relying on a patent license, 500 | and the Corresponding Source of the work is not available for anyone 501 | to copy, free of charge and under the terms of this License, through a 502 | publicly available network server or other readily accessible means, 503 | then you must either (1) cause the Corresponding Source to be so 504 | available, or (2) arrange to deprive yourself of the benefit of the 505 | patent license for this particular work, or (3) arrange, in a manner 506 | consistent with the requirements of this License, to extend the patent 507 | license to downstream recipients. "Knowingly relying" means you have 508 | actual knowledge that, but for the patent license, your conveying the 509 | covered work in a country, or your recipient's use of the covered work 510 | in a country, would infringe one or more identifiable patents in that 511 | country that you have reason to believe are valid. 512 | 513 | If, pursuant to or in connection with a single transaction or 514 | arrangement, you convey, or propagate by procuring conveyance of, a 515 | covered work, and grant a patent license to some of the parties 516 | receiving the covered work authorizing them to use, propagate, modify 517 | or convey a specific copy of the covered work, then the patent license 518 | you grant is automatically extended to all recipients of the covered 519 | work and works based on it. 520 | 521 | A patent license is "discriminatory" if it does not include within 522 | the scope of its coverage, prohibits the exercise of, or is 523 | conditioned on the non-exercise of one or more of the rights that are 524 | specifically granted under this License. You may not convey a covered 525 | work if you are a party to an arrangement with a third party that is 526 | in the business of distributing software, under which you make payment 527 | to the third party based on the extent of your activity of conveying 528 | the work, and under which the third party grants, to any of the 529 | parties who would receive the covered work from you, a discriminatory 530 | patent license (a) in connection with copies of the covered work 531 | conveyed by you (or copies made from those copies), or (b) primarily 532 | for and in connection with specific products or compilations that 533 | contain the covered work, unless you entered into that arrangement, 534 | or that patent license was granted, prior to 28 March 2007. 535 | 536 | Nothing in this License shall be construed as excluding or limiting 537 | any implied license or other defenses to infringement that may 538 | otherwise be available to you under applicable patent law. 539 | 540 | 12. No Surrender of Others' Freedom. 541 | 542 | If conditions are imposed on you (whether by court order, agreement or 543 | otherwise) that contradict the conditions of this License, they do not 544 | excuse you from the conditions of this License. If you cannot convey a 545 | covered work so as to satisfy simultaneously your obligations under this 546 | License and any other pertinent obligations, then as a consequence you may 547 | not convey it at all. For example, if you agree to terms that obligate you 548 | to collect a royalty for further conveying from those to whom you convey 549 | the Program, the only way you could satisfy both those terms and this 550 | License would be to refrain entirely from conveying the Program. 551 | 552 | 13. Use with the GNU Affero General Public License. 553 | 554 | Notwithstanding any other provision of this License, you have 555 | permission to link or combine any covered work with a work licensed 556 | under version 3 of the GNU Affero General Public License into a single 557 | combined work, and to convey the resulting work. The terms of this 558 | License will continue to apply to the part which is the covered work, 559 | but the special requirements of the GNU Affero General Public License, 560 | section 13, concerning interaction through a network will apply to the 561 | combination as such. 562 | 563 | 14. Revised Versions of this License. 564 | 565 | The Free Software Foundation may publish revised and/or new versions of 566 | the GNU General Public License from time to time. Such new versions will 567 | be similar in spirit to the present version, but may differ in detail to 568 | address new problems or concerns. 569 | 570 | Each version is given a distinguishing version number. If the 571 | Program specifies that a certain numbered version of the GNU General 572 | Public License "or any later version" applies to it, you have the 573 | option of following the terms and conditions either of that numbered 574 | version or of any later version published by the Free Software 575 | Foundation. If the Program does not specify a version number of the 576 | GNU General Public License, you may choose any version ever published 577 | by the Free Software Foundation. 578 | 579 | If the Program specifies that a proxy can decide which future 580 | versions of the GNU General Public License can be used, that proxy's 581 | public statement of acceptance of a version permanently authorizes you 582 | to choose that version for the Program. 583 | 584 | Later license versions may give you additional or different 585 | permissions. However, no additional obligations are imposed on any 586 | author or copyright holder as a result of your choosing to follow a 587 | later version. 588 | 589 | 15. Disclaimer of Warranty. 590 | 591 | THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY 592 | APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT 593 | HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY 594 | OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, 595 | THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 596 | PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM 597 | IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF 598 | ALL NECESSARY SERVICING, REPAIR OR CORRECTION. 599 | 600 | 16. Limitation of Liability. 601 | 602 | IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING 603 | WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS 604 | THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY 605 | GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE 606 | USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF 607 | DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD 608 | PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), 609 | EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF 610 | SUCH DAMAGES. 611 | 612 | 17. Interpretation of Sections 15 and 16. 613 | 614 | If the disclaimer of warranty and limitation of liability provided 615 | above cannot be given local legal effect according to their terms, 616 | reviewing courts shall apply local law that most closely approximates 617 | an absolute waiver of all civil liability in connection with the 618 | Program, unless a warranty or assumption of liability accompanies a 619 | copy of the Program in return for a fee. 620 | 621 | END OF TERMS AND CONDITIONS 622 | 623 | How to Apply These Terms to Your New Programs 624 | 625 | If you develop a new program, and you want it to be of the greatest 626 | possible use to the public, the best way to achieve this is to make it 627 | free software which everyone can redistribute and change under these terms. 628 | 629 | To do so, attach the following notices to the program. It is safest 630 | to attach them to the start of each source file to most effectively 631 | state the exclusion of warranty; and each file should have at least 632 | the "copyright" line and a pointer to where the full notice is found. 633 | 634 | 635 | Copyright (C) 636 | 637 | This program is free software: you can redistribute it and/or modify 638 | it under the terms of the GNU General Public License as published by 639 | the Free Software Foundation, either version 3 of the License, or 640 | (at your option) any later version. 641 | 642 | This program is distributed in the hope that it will be useful, 643 | but WITHOUT ANY WARRANTY; without even the implied warranty of 644 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 645 | GNU General Public License for more details. 646 | 647 | You should have received a copy of the GNU General Public License 648 | along with this program. If not, see . 649 | 650 | Also add information on how to contact you by electronic and paper mail. 651 | 652 | If the program does terminal interaction, make it output a short 653 | notice like this when it starts in an interactive mode: 654 | 655 | Copyright (C) 656 | This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'. 657 | This is free software, and you are welcome to redistribute it 658 | under certain conditions; type `show c' for details. 659 | 660 | The hypothetical commands `show w' and `show c' should show the appropriate 661 | parts of the General Public License. Of course, your program's commands 662 | might be different; for a GUI interface, you would use an "about box". 663 | 664 | You should also get your employer (if you work as a programmer) or school, 665 | if any, to sign a "copyright disclaimer" for the program, if necessary. 666 | For more information on this, and how to apply and follow the GNU GPL, see 667 | . 668 | 669 | The GNU General Public License does not permit incorporating your program 670 | into proprietary programs. If your program is a subroutine library, you 671 | may consider it more useful to permit linking proprietary applications with 672 | the library. If this is what you want to do, use the GNU Lesser General 673 | Public License instead of this License. But first, please read 674 | . 675 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # analyzeJS 2 | 3 | **analyzeJS** is a tool which is a combination of different tools and make **JavaScript[JS] Recon** more automate, if you are doing this _automate then it might take awhile to gather the information regarding JavaScript._ 4 | 5 | ![analyzeJS](https://github.com/YashGoti/analyzeJS/blob/master/logo.svg) 6 | 7 | ### Setup 8 | Don't need to 😂. 9 | * Change the **token** and **chat_id** in the file, So that you'll get a notification. [https://medium.com/@ManHay_Hong/how-to-create-a-telegram-bot-and-send-messages-with-python-4cf314d9fa3e] 10 | 11 | ### Features 12 | * Gather JS URLs using many other tools [**gau, gal, subjs, hakrawler**]. 13 | * Checking for live JS urls using tool [**httpx**]. 14 | * Gather content/response from live JS urls [**jsbeautify.py**]. 15 | * Send notification to telegram once your scan will be done [**Telegram Bot API**]. 16 | * Many more are on the way. 17 | 18 | ### Usage 19 | |**Options**|**Description**| 20 | |---|---| 21 | |**-d**|specify target domain [required]| 22 | |**-j**|find JS urls for your target [gau, subjs, hakrawler]| 23 | |**-l**|find live JS urls for your target [httpx]| 24 | |**-c**|print content of JS urls [jsbeautify.py]| 25 | |**-e**|find endpoints from JS urls| 26 | |**-s**|find secrets from JS urls| 27 | |**-n**|send notification to telegram bot| 28 | |**-h**|help| 29 | 30 | ### Examples 31 | * ./analyzeJS.sh **-d** _TARGET_DOMAIN_ **-j** 32 | * ./analyzeJS.sh **-d** _TARGET_DOMAIN_ **-l** 33 | * ./analyzeJS.sh **-d** _TARGET_DOMAIN_ **-j** **-c** 34 | * ./analyzeJS.sh **-d** _TARGET_DOMAIN_ **-l** **-c** 35 | * ./analyzeJS.sh **-d** _TARGET_DOMAIN_ **-l** **-c** **-n** 36 | 37 | ### References 38 | * [gal](https://github.com/YashGoti/gal) 39 | * [jsbeautify.py](https://github.com/YashGoti/Hacks/blob/master/jsbeautify.py) 40 | 41 | ### Contact 42 | * [Twitter](https://twitter.com/_YashGoti_) 43 | -------------------------------------------------------------------------------- /analyzeJS.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | banner(){ 4 | echo -e "\t v1.0\t" 5 | echo -e "\t __ _______\t" 6 | echo -e "\t ____ ____ ____ / /_ ______ ___ / / ___/\t" 7 | echo -e "\t / __ \/ __ \/ __ \/ / / / /_ / / _ \__ / /\__ \ \t" 8 | echo -e "\t/ /_/ / / / / /_/ / / /_/ / / /_/ __/ /_/ /___/ / \t" 9 | echo -e "\t\__,_/_/ /_/\__,_/_/\__, / /___/\___/\____//____/ \t" 10 | echo -e "\t /____/ \t" 11 | echo -e "\t \t" 12 | echo -e "\t By @_YashGoti_ \t" 13 | } 14 | 15 | help(){ 16 | banner 17 | echo -e "" 18 | echo -e "[Options]:" 19 | echo -e "\t-d\tspecify target domain [required]\n" 20 | echo -e "\t-j\tfind JS urls for your target [gau, subjs, hakrawler]\n" 21 | echo -e "\t-l\tfind live JS urls for your target [httpx]\n" 22 | echo -e "\t-c\tprint content of JS urls [jsbeautify.py]\n" 23 | echo -e "\t-e\tfind endpoints from JS urls\n" 24 | echo -e "\t-s\tfind secrets from JS urls\n" 25 | echo -e "\t-n\tsend notification to telegram bot\n" 26 | echo -e "\t-h\thelp" 27 | } 28 | 29 | checkDirectories(){ 30 | mkdir -p ./js-recon 31 | mkdir -p ./js-recon/$1 32 | } 33 | 34 | log(){ 35 | echo -e $1 36 | } 37 | 38 | print(){ 39 | cat ./js-recon/$1/$2 40 | } 41 | 42 | getJSurls(){ 43 | #gau 44 | ./tools/gau $1 | grep $1 | sort -u > ./js-recon/$1/gau.txt 45 | cat ./js-recon/$1/gau.txt | grep -iE "\.js$" > ./js-recon/$1/gau.jsurls.txt 46 | #gal 47 | ./tools/gal.sh -u $1 | grep $1 | sort -u > ./js-recon/$1/gal.txt 48 | cat ./js-recon/$1/gal.txt | grep $1 | grep -iE "\.js$" | sort -u > ./js-recon/$1/gal.jsurls.txt 49 | #subjs 50 | ./tools/subjs -i ./js-recon/$1/gau.txt -c 25 -ua "JS-analyzer" | grep $1 | sort -u > ./js-recon/$1/subjs.txt 51 | #hakrawler 52 | ./tools/hakrawler -js -url $1 -plain -depth 3 -scope strict -insecure | grep $1 > ./js-recon/$1/hakrawler.txt 53 | #Merging 54 | cat ./js-recon/$1/gau.jsurls.txt ./js-recon/$1/gal.jsurls.txt ./js-recon/$1/subjs.txt ./js-recon/$1/hakrawler.txt | grep $1 | sort -u > ./js-recon/$1/jsurls.txt 55 | } 56 | 57 | getLiveJSurls(){ 58 | #httpx 59 | ./tools/httpx -l ./js-recon/$1/jsurls.txt -silent -status-code | grep "[200]" | cut -d ' ' -f1 > ./js-recon/$1/live.jsurls.txt 60 | } 61 | 62 | getJSurlsContent(){ 63 | #jsbeautify.py 64 | ./tools/jsbeautify.py -ul ./js-recon/$1/jsurls.txt > ./js-recon/$1/jsurls.content.txt 65 | } 66 | 67 | getJSurlsEndpoints(){ 68 | #linkfinder 69 | while read -r jsurl; do python3 ./tools/linkfinder.py -d -i $jsurl -o cli >> ./js-recon/$1/jsurls.endpoints.txt; done < ./js-recon/$1/jsurls.txt 70 | } 71 | 72 | getJSurlsSecrets(){ 73 | #secretfinder 74 | while read -r jsurl; do python3 ./tools/secretfinder.py -i $jsurl -o cli >> ./js-recon/$1/jsurls.secrets.txt; done < ./js-recon/$1/jsurls.txt 75 | } 76 | 77 | notifyMe(){ 78 | # Follow this to find your token and chatid 79 | # https://medium.com/@ManHay_Hong/how-to-create-a-telegram-bot-and-send-messages-with-python-4cf314d9fa3e 80 | notification=$1 81 | token="CHANGEME" 82 | chatid="CHANGEME" 83 | curl -s -X POST https://api.telegram.org/bot$token/sendMessage -d chat_id=$chatid -d text="$notification" > /dev/null 84 | } 85 | 86 | if [[ -z $1 ]]; then help; fi 87 | 88 | while getopts "d:jlcesnh" OPT; do 89 | case ${OPT} in 90 | d ) target=$OPTARG ; checkDirectories $target ; getJSurls $target ;; 91 | j ) print $target "jsurls.txt" ;; 92 | l ) getLiveJSurls $target && print $target "live.jsurls.txt" ;; 93 | c ) getJSurlsContent $target && print $target "jsurls.content.txt" ;; 94 | e ) getJSurlsEndpoints $target ;; 95 | s ) getJSurlsSecrets $target ;; 96 | n ) notifyMe "JS-analyzer is done for $target, go and grab a spoon." ;; 97 | h ) help ;; 98 | esac 99 | done 100 | shift $((OPTIND -1)) 101 | -------------------------------------------------------------------------------- /tools/gau: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/YashGoti/analyzeJS/85de5ddcc9e653b6758339c70fcffce6744e1ec1/tools/gau -------------------------------------------------------------------------------- /tools/getjswords.py: -------------------------------------------------------------------------------- 1 | import requests 2 | from jsbeautifier import beautify 3 | import sys,re 4 | import string 5 | 6 | blacklisted = [ 7 | "await" 8 | "break" 9 | "case" 10 | "catch" 11 | "class" 12 | "const" 13 | "continue" 14 | "debugger" 15 | "default" 16 | "delete" 17 | "do" 18 | "else" 19 | "enum" 20 | "export" 21 | "extends" 22 | "false" 23 | "finally" 24 | "for" 25 | "function" 26 | "if" 27 | "implements" 28 | "import" 29 | "in" 30 | "instanceof" 31 | "interface" 32 | "let" 33 | "new" 34 | "null" 35 | "package" 36 | "private" 37 | "protected" 38 | "public" 39 | "return" 40 | "super" 41 | "switch" 42 | "static" 43 | "this" 44 | "throw" 45 | "try" 46 | "true" 47 | "typeof" 48 | "var" 49 | "void" 50 | "while" 51 | "with" 52 | "abstract" 53 | "else" 54 | "instanceof" 55 | "super" 56 | "boolean" 57 | "enum" 58 | "int" 59 | "switch" 60 | "break" 61 | "export" 62 | "interface" 63 | "synchronized" 64 | "byte" 65 | "extends" 66 | "let" 67 | "this" 68 | "case" 69 | "false" 70 | "long" 71 | "throw" 72 | "catch" 73 | "final" 74 | "native" 75 | "throws" 76 | "char" 77 | "finally" 78 | "new" 79 | "transient" 80 | "class" 81 | "float" 82 | "null" 83 | "true" 84 | "const" 85 | "for" 86 | "package" 87 | "try" 88 | "continue" 89 | "function" 90 | "private" 91 | "typeof" 92 | "debugger" 93 | "goto" 94 | "protected" 95 | "var" 96 | "default" 97 | "if" 98 | "public" 99 | "void" 100 | "delete" 101 | "implements" 102 | "return" 103 | "volatile" 104 | "do" 105 | "import" 106 | "short" 107 | "while" 108 | "double" 109 | "in" 110 | "static" 111 | "with" 112 | "alert" 113 | "frames" 114 | "outerheight" 115 | "all" 116 | "framerate" 117 | "outerwidth" 118 | "anchor" 119 | "function" 120 | "packages" 121 | "anchors" 122 | "getclass" 123 | "pagexoffset" 124 | "area" 125 | "hasownproperty" 126 | "pageyoffset" 127 | "array" 128 | "hidden" 129 | "parent" 130 | "assign" 131 | "history" 132 | "parsefloat" 133 | "blur" 134 | "image" 135 | "parseint" 136 | "button" 137 | "images" 138 | "password" 139 | "checkbox" 140 | "infinity" 141 | "pkcs11" 142 | "clearinterval" 143 | "isfinite" 144 | "plugin" 145 | "cleartimeout" 146 | "isnan" 147 | "prompt" 148 | "clientinformation" 149 | "isprototypeof" 150 | "propertyisenum" 151 | "close" 152 | "java" 153 | "prototype" 154 | "closed" 155 | "javaarray" 156 | "radio" 157 | "confirm" 158 | "javaclass" 159 | "reset" 160 | "constructor" 161 | "javaobject" 162 | "screenx" 163 | "crypto" 164 | "javapackage" 165 | "screeny" 166 | "date" 167 | "innerheight" 168 | "scroll" 169 | "decodeuri" 170 | "innerwidth" 171 | "secure" 172 | "decodeuricomponent" 173 | "layer" 174 | "select" 175 | "defaultstatus" 176 | "layers" 177 | "self" 178 | "document" 179 | "length" 180 | "setinterval" 181 | "element" 182 | "link" 183 | "settimeout" 184 | "elements" 185 | "location" 186 | "status" 187 | "embed" 188 | "math" 189 | "string" 190 | "embeds" 191 | "mimetypes" 192 | "submit" 193 | "encodeuri" 194 | "name" 195 | "taint" 196 | "encodeuricomponent" 197 | "nan" 198 | "text" 199 | "escape" 200 | "navigate" 201 | "textarea" 202 | "eval" 203 | "navigator" 204 | "top" 205 | "event" 206 | "number" 207 | "tostring" 208 | "fileupload" 209 | "object" 210 | "undefined" 211 | "focus" 212 | "offscreenbuffering" 213 | "unescape" 214 | "form" 215 | "open" 216 | "untaint" 217 | "forms" 218 | "opener" 219 | "valueof" 220 | "frame" 221 | "option" 222 | "window" 223 | "yield" 224 | ] 225 | 226 | def getWords(content:str): 227 | allWords = [] 228 | content = beautify(content) 229 | regex_content = re.findall('[a-zA-Z0-9_\-\.]+',content) 230 | for word in regex_content: 231 | if '.' in word: 232 | w = word.split('.')[-1:][0] 233 | if w and w not in allWords: 234 | allWords.append(w) 235 | elif len(word) == 1: 236 | if word in string.punctuation: 237 | pass 238 | elif word in string.ascii_letters: 239 | if word not in allWords: 240 | allWords.append(word) 241 | elif word in string.digits: 242 | pass 243 | else: 244 | if word not in allWords: 245 | allWords.append(word) 246 | _allWords = allWords 247 | allWords = [] 248 | for word in _allWords: 249 | if word.lower() not in blacklisted: 250 | if word not in allWords: 251 | allWords.append(word) 252 | return allWords 253 | 254 | def main(jsFile): 255 | bad = not 1 256 | if '://' not in jsFile or '.js' not in jsFile: 257 | print('Bad URL: %s'%jsFile,end="") 258 | print(', please check your url',end="") 259 | print(', pass..') 260 | bad = not 0 261 | if bad is False: 262 | try: 263 | req = requests.get(jsFile) 264 | content = req.content.decode('utf-8','replace') 265 | words = getWords(content) 266 | for word in words: 267 | print(word) 268 | except Exception as err: 269 | sys.exit(print(err)) 270 | 271 | 272 | def usage(): 273 | name = sys.argv[0] 274 | print('Usage:') 275 | print('\tpython3 %s https://example.com/javascripts/main.js'%name) 276 | print('\tcat my_js_files.txt | python3 %s'%name) 277 | print('by @m4ll0k - github.com/m4ll0k') 278 | sys.exit(0) 279 | 280 | if len(sys.argv) == 2: 281 | main( 282 | sys.argv[1] 283 | ) 284 | else: 285 | for jsFile in sys.stdin.readlines(): 286 | jsFile = jsFile.strip() 287 | if jsFile == '\n': 288 | usage() 289 | main(jsFile) -------------------------------------------------------------------------------- /tools/hakrawler: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/YashGoti/analyzeJS/85de5ddcc9e653b6758339c70fcffce6744e1ec1/tools/hakrawler -------------------------------------------------------------------------------- /tools/httpx: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/YashGoti/analyzeJS/85de5ddcc9e653b6758339c70fcffce6744e1ec1/tools/httpx -------------------------------------------------------------------------------- /tools/jsbeautify.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python 2 | import os, sys, requests, argparse, jsbeautifier 3 | 4 | def parser_error(errmsg): 5 | print("Usage: python3 " + sys.argv[0] + " [Options] use -h for help") 6 | print("Error: " + errmsg) 7 | sys.exit() 8 | 9 | def parse_args(): 10 | parser = argparse.ArgumentParser(epilog='\tExample: \r\npython3 ' + sys.argv[0] + " -u google.com") 11 | parser.error = parser_error 12 | parser._optionals.title = "OPTIONS" 13 | parser.add_argument('-u', '--url', help='JS URL', required=False) 14 | parser.add_argument('-ul', '--urllist', help='List of JS URLs', required=False) 15 | return parser.parse_args() 16 | 17 | def beautifyjs(content): 18 | try: 19 | return jsbeautifier.beautify(content) 20 | except: 21 | pass 22 | 23 | def getjsresponse(url): 24 | try: 25 | return requests.get("{}".format(url), timeout=10) 26 | except: 27 | pass 28 | 29 | if __name__ == "__main__": 30 | args = parse_args() 31 | if args.url: 32 | if args.url.startswith("http://") or args.url.startswith("https://"): 33 | response = getjsresponse(args.url) 34 | if response.status_code == 200: 35 | # print(args.url) 36 | print(beautifyjs(response.text) + "\n") 37 | else: 38 | print(args.url + " [" + str(response.status_code) + "] ") 39 | elif args.url.startswith("view-source:"): 40 | response = getjsresponse(args.url.split("view-source:")[1]) 41 | if response.status_code == 200: 42 | # print(args.url.split("view-source:")[1]) 43 | print(beautifyjs(response.text) + "\n") 44 | else: 45 | parser_error(args.url + " not in valid format") 46 | elif args.urllist: 47 | if os.path.isfile(args.urllist): 48 | f = open(args.urllist, "r") 49 | for jsurl in f: 50 | jsurl = jsurl.rstrip() 51 | response = getjsresponse(jsurl) 52 | if response.status_code == 200: 53 | # print(jsurl) 54 | print(beautifyjs(response.text) + "\n") 55 | else: 56 | print(jsurl + " [" + str(response.status_code) + "] ") 57 | else: 58 | parser_error(args.urllist + " not valid file") -------------------------------------------------------------------------------- /tools/linkfinder.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python 2 | # Python 3 3 | # LinkFinder 4 | # By Gerben_Javado 5 | 6 | # Fix webbrowser bug for MacOS 7 | import os 8 | os.environ["BROWSER"] = "open" 9 | 10 | # Import libraries 11 | import re, sys, glob, html, argparse, jsbeautifier, webbrowser, subprocess, base64, ssl, xml.etree.ElementTree 12 | 13 | from gzip import GzipFile 14 | from string import Template 15 | 16 | try: 17 | from StringIO import StringIO 18 | readBytesCustom = StringIO 19 | except ImportError: 20 | from io import BytesIO 21 | readBytesCustom = BytesIO 22 | 23 | try: 24 | from urllib.request import Request, urlopen 25 | except ImportError: 26 | from urllib2 import Request, urlopen 27 | 28 | # Regex used 29 | regex_str = r""" 30 | 31 | (?:"|') # Start newline delimiter 32 | 33 | ( 34 | ((?:[a-zA-Z]{1,10}://|//) # Match a scheme [a-Z]*1-10 or // 35 | [^"'/]{1,}\. # Match a domainname (any character + dot) 36 | [a-zA-Z]{2,}[^"']{0,}) # The domainextension and/or path 37 | 38 | | 39 | 40 | ((?:/|\.\./|\./) # Start with /,../,./ 41 | [^"'><,;| *()(%%$^/\\\[\]] # Next character can't be... 42 | [^"'><,;|()]{1,}) # Rest of the characters can't be 43 | 44 | | 45 | 46 | ([a-zA-Z0-9_\-/]{1,}/ # Relative endpoint with / 47 | [a-zA-Z0-9_\-/]{1,} # Resource name 48 | \.(?:[a-zA-Z]{1,4}|action) # Rest + extension (length 1-4 or action) 49 | (?:[\?|#][^"|']{0,}|)) # ? or # mark with parameters 50 | 51 | | 52 | 53 | ([a-zA-Z0-9_\-/]{1,}/ # REST API (no extension) with / 54 | [a-zA-Z0-9_\-/]{3,} # Proper REST endpoints usually have 3+ chars 55 | (?:[\?|#][^"|']{0,}|)) # ? or # mark with parameters 56 | 57 | | 58 | 59 | ([a-zA-Z0-9_\-]{1,} # filename 60 | \.(?:php|asp|aspx|jsp|json| 61 | action|html|js|txt|xml) # . + extension 62 | (?:[\?|#][^"|']{0,}|)) # ? or # mark with parameters 63 | 64 | ) 65 | 66 | (?:"|') # End newline delimiter 67 | 68 | """ 69 | 70 | context_delimiter_str = "\n" 71 | 72 | def parser_error(errmsg): 73 | ''' 74 | Error Messages 75 | ''' 76 | print("Usage: python %s [Options] use -h for help" % sys.argv[0]) 77 | print("Error: %s" % errmsg) 78 | sys.exit() 79 | 80 | 81 | def parser_input(input): 82 | ''' 83 | Parse Input 84 | ''' 85 | 86 | # Method 1 - URL 87 | if input.startswith(('http://', 'https://', 88 | 'file://', 'ftp://', 'ftps://')): 89 | return [input] 90 | 91 | # Method 2 - URL Inspector Firefox 92 | if input.startswith('view-source:'): 93 | return [input[12:]] 94 | 95 | # Method 3 - Burp file 96 | if args.burp: 97 | jsfiles = [] 98 | items = xml.etree.ElementTree.fromstring(open(args.input, "r").read()) 99 | 100 | for item in items: 101 | jsfiles.append({"js":base64.b64decode(item.find('response').text).decode('utf-8',"replace"), "url":item.find('url').text}) 102 | return jsfiles 103 | 104 | # Method 4 - Folder with a wildcard 105 | if "*" in input: 106 | paths = glob.glob(os.path.abspath(input)) 107 | for index, path in enumerate(paths): 108 | paths[index] = "file://%s" % path 109 | return (paths if len(paths) > 0 else parser_error('Input with wildcard does \ 110 | not match any files.')) 111 | 112 | # Method 5 - Local file 113 | path = "file://%s" % os.path.abspath(input) 114 | return [path if os.path.exists(input) else parser_error("file could not \ 115 | be found (maybe you forgot to add http/https).")] 116 | 117 | 118 | def send_request(url): 119 | ''' 120 | Send requests with Requests 121 | ''' 122 | q = Request(url) 123 | 124 | q.add_header('User-Agent', 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) \ 125 | AppleWebKit/537.36 (KHTML, like Gecko) Chrome/58.0.3029.110 Safari/537.36') 126 | q.add_header('Accept', 'text/html,\ 127 | application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8') 128 | q.add_header('Accept-Language', 'en-US,en;q=0.8') 129 | q.add_header('Accept-Encoding', 'gzip') 130 | q.add_header('Cookie', args.cookies) 131 | 132 | try: 133 | sslcontext = ssl.SSLContext(ssl.PROTOCOL_TLSv1_2) 134 | response = urlopen(q, timeout=args.timeout, context=sslcontext) 135 | except: 136 | sslcontext = ssl.SSLContext(ssl.PROTOCOL_TLSv1) 137 | response = urlopen(q, timeout=args.timeout, context=sslcontext) 138 | 139 | if response.info().get('Content-Encoding') == 'gzip': 140 | data = GzipFile(fileobj=readBytesCustom(response.read())).read() 141 | elif response.info().get('Content-Encoding') == 'deflate': 142 | data = response.read().read() 143 | else: 144 | data = response.read() 145 | 146 | return data.decode('utf-8', 'replace') 147 | 148 | def getContext(list_matches, content, include_delimiter=0, context_delimiter_str="\n"): 149 | ''' 150 | Parse Input 151 | list_matches: list of tuple (link, start_index, end_index) 152 | content: content to search for the context 153 | include_delimiter Set 1 to include delimiter in context 154 | ''' 155 | items = [] 156 | for m in list_matches: 157 | match_str = m[0] 158 | match_start = m[1] 159 | match_end = m[2] 160 | context_start_index = match_start 161 | context_end_index = match_end 162 | delimiter_len = len(context_delimiter_str) 163 | content_max_index = len(content) - 1 164 | 165 | while content[context_start_index] != context_delimiter_str and context_start_index > 0: 166 | context_start_index = context_start_index - 1 167 | 168 | while content[context_end_index] != context_delimiter_str and context_end_index < content_max_index: 169 | context_end_index = context_end_index + 1 170 | 171 | if include_delimiter: 172 | context = content[context_start_index: context_end_index] 173 | else: 174 | context = content[context_start_index + delimiter_len: context_end_index] 175 | 176 | item = { 177 | "link": match_str, 178 | "context": context 179 | } 180 | items.append(item) 181 | 182 | return items 183 | 184 | def parser_file(content, regex_str, mode=1, more_regex=None, no_dup=1): 185 | ''' 186 | Parse Input 187 | content: string of content to be searched 188 | regex_str: string of regex (The link should be in the group(1)) 189 | mode: mode of parsing. Set 1 to include surrounding contexts in the result 190 | more_regex: string of regex to filter the result 191 | no_dup: remove duplicated link (context is NOT counted) 192 | 193 | Return the list of ["link": link, "context": context] 194 | The context is optional if mode=1 is provided. 195 | ''' 196 | global context_delimiter_str 197 | 198 | if mode == 1: 199 | # Beautify 200 | if len(content) > 1000000: 201 | content = content.replace(";",";\r\n").replace(",",",\r\n") 202 | else: 203 | content = jsbeautifier.beautify(content) 204 | 205 | regex = re.compile(regex_str, re.VERBOSE) 206 | 207 | if mode == 1: 208 | all_matches = [(m.group(1), m.start(0), m.end(0)) for m in re.finditer(regex, content)] 209 | items = getContext(all_matches, content, context_delimiter_str=context_delimiter_str) 210 | else: 211 | items = [{"link": m.group(1)} for m in re.finditer(regex, content)] 212 | 213 | if no_dup: 214 | # Remove duplication 215 | all_links = set() 216 | no_dup_items = [] 217 | for item in items: 218 | if item["link"] not in all_links: 219 | all_links.add(item["link"]) 220 | no_dup_items.append(item) 221 | items = no_dup_items 222 | 223 | # Match Regex 224 | filtered_items = [] 225 | for item in items: 226 | # Remove other capture groups from regex results 227 | if more_regex: 228 | if re.search(more_regex, item["link"]): 229 | filtered_items.append(item) 230 | else: 231 | filtered_items.append(item) 232 | 233 | return filtered_items 234 | 235 | def cli_output(endpoints): 236 | ''' 237 | Output to CLI 238 | ''' 239 | for endpoint in endpoints: 240 | print(html.escape(endpoint["link"]).encode( 241 | 'ascii', 'ignore').decode('utf8')) 242 | 243 | def html_save(html): 244 | ''' 245 | Save as HTML file and open in the browser 246 | ''' 247 | hide = os.dup(1) 248 | os.close(1) 249 | os.open(os.devnull, os.O_RDWR) 250 | try: 251 | s = Template(open('%s/template.html' % sys.path[0], 'r').read()) 252 | 253 | text_file = open(args.output, "wb") 254 | text_file.write(s.substitute(content=html).encode('utf8')) 255 | text_file.close() 256 | 257 | print("URL to access output: file://%s" % os.path.abspath(args.output)) 258 | file = "file:///%s" % os.path.abspath(args.output) 259 | if sys.platform == 'linux' or sys.platform == 'linux2': 260 | subprocess.call(["xdg-open", file]) 261 | else: 262 | webbrowser.open(file) 263 | except Exception as e: 264 | print("Output can't be saved in %s \ 265 | due to exception: %s" % (args.output, e)) 266 | finally: 267 | os.dup2(hide, 1) 268 | 269 | def check_url(url): 270 | nopelist = ["node_modules", "jquery.js"] 271 | if url[-3:] == ".js": 272 | words = url.split("/") 273 | for word in words: 274 | if word in nopelist: 275 | return False 276 | if url[:2] == "//": 277 | url = "https:" + url 278 | if url[:4] != "http": 279 | if url[:1] == "/": 280 | url = args.input + url 281 | else: 282 | url = args.input + "/" + url 283 | return url 284 | else: 285 | return False 286 | 287 | if __name__ == "__main__": 288 | # Parse command line 289 | parser = argparse.ArgumentParser() 290 | parser.add_argument("-d", "--domain", 291 | help="Input a domain to recursively parse all javascript located in a page", 292 | action="store_true") 293 | parser.add_argument("-i", "--input", 294 | help="Input a: URL, file or folder. \ 295 | For folders a wildcard can be used (e.g. '/*.js').", 296 | required="True", action="store") 297 | parser.add_argument("-o", "--output", 298 | help="Where to save the file, \ 299 | including file name. Default: output.html", 300 | action="store", default="output.html") 301 | parser.add_argument("-r", "--regex", 302 | help="RegEx for filtering purposes \ 303 | against found endpoint (e.g. ^/api/)", 304 | action="store") 305 | parser.add_argument("-b", "--burp", 306 | help="", 307 | action="store_true") 308 | parser.add_argument("-c", "--cookies", 309 | help="Add cookies for authenticated JS files", 310 | action="store", default="") 311 | default_timeout = 10 312 | parser.add_argument("-t", "--timeout", 313 | help="How many seconds to wait for the server to send data before giving up (default: " + str(default_timeout) + " seconds)", 314 | default=default_timeout, type=int, metavar="") 315 | args = parser.parse_args() 316 | 317 | if args.input[-1:] == "/": 318 | args.input = args.input[:-1] 319 | 320 | mode = 1 321 | if args.output == "cli": 322 | mode = 0 323 | 324 | # Convert input to URLs or JS files 325 | urls = parser_input(args.input) 326 | 327 | # Convert URLs to JS 328 | output = '' 329 | for url in urls: 330 | if not args.burp: 331 | try: 332 | file = send_request(url) 333 | except Exception as e: 334 | parser_error("invalid input defined or SSL error: %s" % e) 335 | else: 336 | file = url['js'] 337 | url = url['url'] 338 | 339 | endpoints = parser_file(file, regex_str, mode, args.regex) 340 | if args.domain: 341 | for endpoint in endpoints: 342 | endpoint = html.escape(endpoint["link"]).encode('ascii', 'ignore').decode('utf8') 343 | endpoint = check_url(endpoint) 344 | if endpoint is False: 345 | continue 346 | print("Running against: " + endpoint) 347 | print("") 348 | try: 349 | file = send_request(endpoint) 350 | new_endpoints = parser_file(file, regex_str, mode, args.regex) 351 | if args.output == 'cli': 352 | cli_output(new_endpoints) 353 | else: 354 | output += ''' 355 |

File: %s

356 | ''' % (html.escape(endpoint), html.escape(endpoint)) 357 | 358 | for endpoint2 in new_endpoints: 359 | url = html.escape(endpoint2["link"]) 360 | header = "" % html.escape( 365 | endpoint2["context"] 366 | ) 367 | body = body.replace( 368 | html.escape(endpoint2["link"]), 369 | "%s" % 370 | html.escape(endpoint2["link"]) 371 | ) 372 | output += header + body 373 | except Exception as e: 374 | print("Invalid input defined or SSL error for: " + endpoint) 375 | continue 376 | 377 | if args.output == 'cli': 378 | cli_output(endpoints) 379 | else: 380 | output += ''' 381 |

File: %s

382 | ''' % (html.escape(url), html.escape(url)) 383 | 384 | for endpoint in endpoints: 385 | url = html.escape(endpoint["link"]) 386 | header = "" % html.escape( 391 | endpoint["context"] 392 | ) 393 | body = body.replace( 394 | html.escape(endpoint["link"]), 395 | "%s" % 396 | html.escape(endpoint["link"]) 397 | ) 398 | 399 | output += header + body 400 | 401 | if args.output != 'cli': 402 | html_save(output) 403 | -------------------------------------------------------------------------------- /tools/secretfinder.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python 2 | # SecretFinder - Tool for discover apikeys/accesstokens and sensitive data in js file 3 | # based to LinkFinder - github.com/GerbenJavado 4 | # By m4ll0k (@m4ll0k2) github.com/m4ll0k 5 | 6 | 7 | import os,sys 8 | if not sys.version_info.major >= 3: 9 | print("[ + ] Run this tool with python version 3.+") 10 | sys.exit(0) 11 | os.environ["BROWSER"] = "open" 12 | 13 | import re 14 | import glob 15 | import argparse 16 | import jsbeautifier 17 | import webbrowser 18 | import subprocess 19 | import base64 20 | import requests 21 | import string 22 | import random 23 | from html import escape 24 | import urllib3 25 | import xml.etree.ElementTree 26 | 27 | # disable warning 28 | 29 | urllib3.disable_warnings(urllib3.exceptions.InsecureRequestWarning) 30 | 31 | # for read local file with file:// protocol 32 | from requests_file import FileAdapter 33 | from lxml import html 34 | from urllib.parse import urlparse 35 | 36 | # regex 37 | _regex = { 38 | 'google_api' : r'AIza[0-9A-Za-z-_]{35}', 39 | 'google_captcha' : r'6L[0-9A-Za-z-_]{38}|^6[0-9a-zA-Z_-]{39}$', 40 | 'google_oauth' : r'ya29\.[0-9A-Za-z\-_]+', 41 | 'amazon_aws_access_key_id' : r'AKIA[0-9A-Z]{16}', 42 | 'amazon_mws_auth_toke' : r'amzn\\.mws\\.[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}', 43 | 'amazon_aws_url' : r's3\.amazonaws.com[/]+|[a-zA-Z0-9_-]*\.s3\.amazonaws.com', 44 | 'amazon_aws_url2' : r"(" \ 45 | r"[a-zA-Z0-9-\.\_]+\.s3\.amazonaws\.com" \ 46 | r"|s3://[a-zA-Z0-9-\.\_]+" \ 47 | r"|s3-[a-zA-Z0-9-\.\_\/]+" \ 48 | r"|s3.amazonaws.com/[a-zA-Z0-9-\.\_]+" \ 49 | r"|s3.console.aws.amazon.com/s3/buckets/[a-zA-Z0-9-\.\_]+)", 50 | 'facebook_access_token' : r'EAACEdEose0cBA[0-9A-Za-z]+', 51 | 'authorization_basic' : r'basic [a-zA-Z0-9=:_\+\/-]{5,100}', 52 | 'authorization_bearer' : r'bearer [a-zA-Z0-9_\-\.=:_\+\/]{5,100}', 53 | 'authorization_api' : r'api[key|_key|\s+]+[a-zA-Z0-9_\-]{5,100}', 54 | 'mailgun_api_key' : r'key-[0-9a-zA-Z]{32}', 55 | 'twilio_api_key' : r'SK[0-9a-fA-F]{32}', 56 | 'twilio_account_sid' : r'AC[a-zA-Z0-9_\-]{32}', 57 | 'twilio_app_sid' : r'AP[a-zA-Z0-9_\-]{32}', 58 | 'paypal_braintree_access_token' : r'access_token\$production\$[0-9a-z]{16}\$[0-9a-f]{32}', 59 | 'square_oauth_secret' : r'sq0csp-[ 0-9A-Za-z\-_]{43}|sq0[a-z]{3}-[0-9A-Za-z\-_]{22,43}', 60 | 'square_access_token' : r'sqOatp-[0-9A-Za-z\-_]{22}|EAAA[a-zA-Z0-9]{60}', 61 | 'stripe_standard_api' : r'sk_live_[0-9a-zA-Z]{24}', 62 | 'stripe_restricted_api' : r'rk_live_[0-9a-zA-Z]{24}', 63 | 'github_access_token' : r'[a-zA-Z0-9_-]*:[a-zA-Z0-9_\-]+@github\.com*', 64 | 'rsa_private_key' : r'-----BEGIN RSA PRIVATE KEY-----', 65 | 'ssh_dsa_private_key' : r'-----BEGIN DSA PRIVATE KEY-----', 66 | 'ssh_dc_private_key' : r'-----BEGIN EC PRIVATE KEY-----', 67 | 'pgp_private_block' : r'-----BEGIN PGP PRIVATE KEY BLOCK-----', 68 | 'json_web_token' : r'ey[A-Za-z0-9-_=]+\.[A-Za-z0-9-_=]+\.?[A-Za-z0-9-_.+/=]*$', 69 | 'slack_token' : r"\"api_token\":\"(xox[a-zA-Z]-[a-zA-Z0-9-]+)\"", 70 | 'SSH_privKey' : r"([-]+BEGIN [^\s]+ PRIVATE KEY[-]+[\s]*[^-]*[-]+END [^\s]+ PRIVATE KEY[-]+)", 71 | 'possible_Creds' : r"(?i)(" \ 72 | r"password\s*[`=:\"]+\s*[^\s]+|" \ 73 | r"password is\s*[`=:\"]*\s*[^\s]+|" \ 74 | r"pwd\s*[`=:\"]*\s*[^\s]+|" \ 75 | r"passwd\s*[`=:\"]+\s*[^\s]+)", 76 | } 77 | 78 | _template = ''' 79 | 80 | 81 | 82 | 83 | 132 | LinkFinder Output 133 | 134 | 135 | $$content$$ 136 | 137 | 138 | Report an issue. 139 | 140 | 141 | ''' 142 | 143 | def parser_error(msg): 144 | print('Usage: python %s [OPTIONS] use -h for help'%sys.argv[0]) 145 | print('Error: %s'%msg) 146 | sys.exit(0) 147 | 148 | def getContext(matches,content,name,rex='.+?'): 149 | ''' get context ''' 150 | items = [] 151 | matches2 = [] 152 | for i in [x[0] for x in matches]: 153 | if i not in matches2: 154 | matches2.append(i) 155 | for m in matches2: 156 | context = re.findall('%s%s%s'%(rex,m,rex),content,re.IGNORECASE) 157 | 158 | item = { 159 | 'matched' : m, 160 | 'name' : name, 161 | 'context' : context, 162 | 'multi_context' : True if len(context) > 1 else False 163 | } 164 | items.append(item) 165 | return items 166 | 167 | 168 | def parser_file(content,mode=1,more_regex=None,no_dup=1): 169 | ''' parser file ''' 170 | if mode == 1: 171 | if len(content) > 1000000: 172 | content = content.replace(";",";\r\n").replace(",",",\r\n") 173 | else: 174 | content = jsbeautifier.beautify(content) 175 | all_items = [] 176 | for regex in _regex.items(): 177 | r = re.compile(regex[1],re.VERBOSE) 178 | if mode == 1: 179 | all_matches = [(m.group(0),m.start(0),m.end(0)) for m in re.finditer(r,content)] 180 | items = getContext(all_matches,content,regex[0]) 181 | if items != []: 182 | all_items.append(items) 183 | else: 184 | items = [{ 185 | 'matched' : m.group(0), 186 | 'context' : [], 187 | 'name' : regex[0], 188 | 'multi_context' : False 189 | } for m in re.finditer(r,content)] 190 | if items != []: 191 | all_items.append(items) 192 | if all_items != []: 193 | k = [] 194 | for i in range(len(all_items)): 195 | for ii in all_items[i]: 196 | if ii not in k: 197 | k.append(ii) 198 | if k != []: 199 | all_items = k 200 | 201 | if no_dup: 202 | all_matched = set() 203 | no_dup_items = [] 204 | for item in all_items: 205 | if item != [] and type(item) is dict: 206 | if item['matched'] not in all_matched: 207 | all_matched.add(item['matched']) 208 | no_dup_items.append(item) 209 | all_items = no_dup_items 210 | 211 | filtered_items = [] 212 | if all_items != []: 213 | for item in all_items: 214 | if more_regex: 215 | if re.search(more_regex,item['matched']): 216 | filtered_items.append(item) 217 | else: 218 | filtered_items.append(item) 219 | return filtered_items 220 | 221 | 222 | def parser_input(input): 223 | ''' Parser Input ''' 224 | # method 1 - url 225 | schemes = ('http://','https://','ftp://','file://','ftps://') 226 | if input.startswith(schemes): 227 | return [input] 228 | # method 2 - url inpector firefox/chrome 229 | if input.startswith('view-source:'): 230 | return [input[12:]] 231 | # method 3 - Burp file 232 | if args.burp: 233 | jsfiles = [] 234 | items = [] 235 | 236 | try: 237 | items = xml.etree.ElementTree.fromstring(open(args.input,'r').read()) 238 | except Exception as err: 239 | print(err) 240 | sys.exit() 241 | for item in items: 242 | jsfiles.append( 243 | { 244 | 'js': base64.b64decode(item.find('response').text).decode('utf-8','replace'), 245 | 'url': item.find('url').text 246 | } 247 | ) 248 | return jsfiles 249 | # method 4 - folder with a wildcard 250 | if '*' in input: 251 | paths = glob.glob(os.path.abspath(input)) 252 | for index, path in enumerate(paths): 253 | paths[index] = "file://%s" % path 254 | return (paths if len(paths)> 0 else parser_error('Input with wildcard does not match any files.')) 255 | 256 | # method 5 - local file 257 | path = "file://%s"% os.path.abspath(input) 258 | return [path if os.path.exists(input) else parser_error('file could not be found (maybe you forgot to add http/https).')] 259 | 260 | 261 | def html_save(output): 262 | ''' html output ''' 263 | hide = os.dup(1) 264 | os.close(1) 265 | os.open(os.devnull,os.O_RDWR) 266 | try: 267 | text_file = open(args.output,"wb") 268 | text_file.write(_template.replace('$$content$$',output).encode('utf-8')) 269 | text_file.close() 270 | 271 | print('URL to access output: file://%s'%os.path.abspath(args.output)) 272 | file = 'file:///%s'%(os.path.abspath(args.output)) 273 | if sys.platform == 'linux' or sys.platform == 'linux2': 274 | subprocess.call(['xdg-open',file]) 275 | else: 276 | webbrowser.open(file) 277 | except Exception as err: 278 | print('Output can\'t be saved in %s due to exception: %s'%(args.output,err)) 279 | finally: 280 | os.dup2(hide,1) 281 | 282 | def cli_output(matched): 283 | ''' cli output ''' 284 | for match in matched: 285 | print(match.get('name')+'\t->\t'+match.get('matched').encode('ascii','ignore').decode('utf-8')) 286 | 287 | def urlParser(url): 288 | ''' urlParser ''' 289 | parse = urlparse(url) 290 | urlParser.this_root = parse.scheme + '://' + parse.netloc 291 | urlParser.this_path = parse.scheme + '://' + parse.netloc + '/' + parse.path 292 | 293 | def extractjsurl(content,base_url): 294 | ''' JS url extract from html page ''' 295 | soup = html.fromstring(content) 296 | all_src = [] 297 | urlParser(base_url) 298 | for src in soup.xpath('//script'): 299 | src = src.xpath('@src')[0] if src.xpath('@src') != [] else [] 300 | if src != []: 301 | if src.startswith(('http://','https://','ftp://','ftps://')): 302 | if src not in all_src: 303 | all_src.append(src) 304 | elif src.startswith('//'): 305 | src = 'http://'+src[2:] 306 | if src not in all_src: 307 | all_src.append(src) 308 | elif src.startswith('/'): 309 | src = urlParser.this_root + src 310 | if src not in all_src: 311 | all_src.append(src) 312 | else: 313 | src = urlParser.this_path + src 314 | if src not in all_src: 315 | all_src.append(src) 316 | if args.ignore and all_src != []: 317 | temp = all_src 318 | ignore = [] 319 | for i in args.ignore.split(';'): 320 | for src in all_src: 321 | if i in src: 322 | ignore.append(src) 323 | if ignore: 324 | for i in ignore: 325 | temp.pop(int(temp.index(i))) 326 | return temp 327 | if args.only: 328 | temp = all_src 329 | only = [] 330 | for i in args.only.split(';'): 331 | for src in all_src: 332 | if i in src: 333 | only.append(src) 334 | return only 335 | return all_src 336 | 337 | def send_request(url): 338 | ''' Send Request ''' 339 | # read local file 340 | # https://github.com/dashea/requests-file 341 | if 'file://' in url: 342 | s = requests.Session() 343 | s.mount('file://',FileAdapter()) 344 | return s.get(url).content.decode('utf-8','replace') 345 | # set headers and cookies 346 | headers = {} 347 | default_headers = { 348 | 'User-Agent' : 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/58.0.3029.110 Safari/537.36', 349 | 'Accept' : 'text/html, application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8', 350 | 'Accept-Language' : 'en-US,en;q=0.8', 351 | 'Accept-Encoding' : 'gzip' 352 | } 353 | if args.headers: 354 | for i in args.header.split('\\n'): 355 | # replace space and split 356 | name,value = i.replace(' ','').split(':') 357 | headers[name] = value 358 | # add cookies 359 | if args.cookie: 360 | headers['Cookie'] = args.cookie 361 | 362 | headers.update(default_headers) 363 | # proxy 364 | proxies = {} 365 | if args.proxy: 366 | proxies.update({ 367 | 'http' : args.proxy, 368 | 'https' : args.proxy, 369 | # ftp 370 | }) 371 | try: 372 | resp = requests.get( 373 | url = url, 374 | verify = False, 375 | headers = headers, 376 | proxies = proxies 377 | ) 378 | return resp.content.decode('utf-8','replace') 379 | except Exception as err: 380 | print(err) 381 | sys.exit(0) 382 | 383 | if __name__ == "__main__": 384 | parser = argparse.ArgumentParser() 385 | parser.add_argument("-e","--extract",help="Extract all javascript links located in a page and process it",action="store_true",default=False) 386 | parser.add_argument("-i","--input",help="Input a: URL, file or folder",required="True",action="store") 387 | parser.add_argument("-o","--output",help="Where to save the file, including file name. Default: output.html",action="store", default="output.html") 388 | parser.add_argument("-r","--regex",help="RegEx for filtering purposes against found endpoint (e.g: ^/api/)",action="store") 389 | parser.add_argument("-b","--burp",help="Support burp exported file",action="store_true") 390 | parser.add_argument("-c","--cookie",help="Add cookies for authenticated JS files",action="store",default="") 391 | parser.add_argument("-g","--ignore",help="Ignore js url, if it contain the provided string (string;string2..)",action="store",default="") 392 | parser.add_argument("-n","--only",help="Process js url, if it contain the provided string (string;string2..)",action="store",default="") 393 | parser.add_argument("-H","--headers",help="Set headers (\"Name:Value\\nName:Value\")",action="store",default="") 394 | parser.add_argument("-p","--proxy",help="Set proxy (host:port)",action="store",default="") 395 | args = parser.parse_args() 396 | 397 | if args.input[-1:] == "/": 398 | # /aa/ -> /aa 399 | args.input = args.input[:-1] 400 | 401 | mode = 1 402 | if args.output == "cli": 403 | mode = 0 404 | # add args 405 | if args.regex: 406 | # validate regular exp 407 | try: 408 | r = re.search(args.regex,''.join(random.choice(string.ascii_uppercase + string.digits) for _ in range(random.randint(10,50)))) 409 | except Exception as e: 410 | print('your python regex isn\'t valid') 411 | sys.exit() 412 | 413 | _regex.update({ 414 | 'custom_regex' : args.regex 415 | }) 416 | 417 | if args.extract: 418 | content = send_request(args.input) 419 | urls = extractjsurl(content,args.input) 420 | else: 421 | # convert input to URLs or JS files 422 | urls = parser_input(args.input) 423 | # conver URLs to js file 424 | output = '' 425 | for url in urls: 426 | print('[ + ] URL: '+url) 427 | if not args.burp: 428 | file = send_request(url) 429 | else: 430 | file = url.get('js') 431 | url = url.get('url') 432 | 433 | matched = parser_file(file,mode) 434 | if args.output == 'cli': 435 | cli_output(matched) 436 | else: 437 | output += '

File: %s

'%(escape(url),escape(url)) 438 | for match in matched: 439 | _matched = match.get('matched') 440 | _named = match.get('name') 441 | header = '
%s'%(_named.replace('_',' ')) 442 | body = '' 443 | # find same thing in multiple context 444 | if match.get('multi_context'): 445 | # remove duplicate 446 | no_dup = [] 447 | for context in match.get('context'): 448 | if context not in no_dup: 449 | body += '
%s
'%(context) 450 | body = body.replace( 451 | context,'%s'%context) 452 | no_dup.append(context) 453 | # -- 454 | else: 455 | body += '
%s
'%(match.get('context')[0]) 456 | body = body.replace( 457 | match.get('context')[0], 458 | '%s'%(match.get('context')[0]) 459 | ) 460 | output += header + body 461 | if args.output != 'cli': 462 | html_save(output) 463 | -------------------------------------------------------------------------------- /tools/subjs: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/YashGoti/analyzeJS/85de5ddcc9e653b6758339c70fcffce6744e1ec1/tools/subjs --------------------------------------------------------------------------------