[
  {
    "path": ".gitignore",
    "content": "\n*.pyc\n"
  },
  {
    "path": ".travis.yml",
    "content": "language: python\nos:\n  - linux\npython:\n  - 3.6\ninstall:\n  - pip install -r requirements.txt\n  - pip install flake8\nbefore_script:\n  # stop the build if there are Python syntax errors or undefined names\n  - flake8 . --count --select=E901,E999,F821,F822,F823 --show-source --statistics\n  # exit-zero treats all errors as warnings.  The GitHub editor is 127 chars wide\n  - flake8 . --count --exit-zero --max-complexity=10 --max-line-length=127 --statistics\nscript:\n  - python photon.py -u \"https://somdev.me\" -l 1 -d 1 -t 100 --regex \"\\d{10}\" --dns --output=\"d3v\"\n  - python photon.py -u \"https://somdev.me\" -l 1 -t 10 --seeds=\"https://somdev.me/posts\" --only-urls --export=json --wayback\n"
  },
  {
    "path": ".whitesource",
    "content": "{\n  \"generalSettings\": {\n    \"shouldScanRepo\": true\n  },\n  \"checkRunSettings\": {\n    \"vulnerableCheckRunConclusionLevel\": \"failure\"\n  }\n}"
  },
  {
    "path": "CHANGELOG.md",
    "content": "#### v1.3.2\n- add support for socks proxies\n- add rotating proxies\n- `-p` now takes `IP:PORT` or `DOMAIN:PORT` with `http://`, `socks5://` or nothing (default is `http`) or a `file` with a list of proxies (`http://` or `socks5://` or nothing). \n\n#### v1.3.1\n- Added more intels (GENERIC_URL, BRACKET_URL, BACKSLASH_URL, HEXENCODED_URL, URLENCODED_URL, B64ENCODED_URL, IPV4, IPV6, EMAIL, MD5, SHA1, SHA256, SHA512, YARA_PARSE, CREDIT_CARD)\n- proxy support with `-p, --proxy` option (http proxy only)\n- minor fixes and pep8 format\n\n#### v1.3.0\n- Dropped Python < 3.2 support\n- Removed Ninja mode\n- Fixed a bug in link parsing\n- Fixed Unicode output\n- Fixed a bug which caused URLs to be treated as files\n- Intel is now associated with the URL where it was found\n\n#### v1.2.1\n- Added cloning ability\n- Refactored to be modular\n\n#### v1.1.6\n- Reuse TCP connection for better performance\n- Handle redirect loops\n- CSV export support\n- Fixed `sitemap.xml` parsing\n- Improved regex \n\n#### v1.1.5\n- fixed some minor bugs\n- fixed a bug in domain name parsing\n- added --headers option for interactive HTTP headers input\n\n#### v1.1.4\n- Added `-v` option\n- Fixed progress animation for Python 2\n- Added `developer.facebook.com` API for Ninja mode\n\n#### v1.1.3\n- Added `--stdout` option\n- Fixed a bug in `zap()` function\n- Fixed crashing when target is an IP address\n- Minor refactor\n\n#### v1.1.2\n- Added `--wayback`\n- Fixed progress bar for Python > 3.2 \n- Added `/core/config.py` for easy customization\n- `--dns` now saves subdomains in `subdomains.txt`\n\n#### v1.1.1\n- Use of `ThreadPoolExecutor` for x2 speed (for Python > 3.2)\n- Fixed mishandling of urls starting with `//`\n- Removed a redundant try-except statement\n- Evaluate entropy of found keys to avoid false positives\n\n#### v1.1.0\n- Added `--keys` option\n- Fixed a bug related to SSL certificate verification\n\n#### v1.0.9\n- Code refactor\n- Better identification of external URLs\n- Fixed a major bug that made several intel URLs pass under the radar\n- Fixed a major bug that caused non-html type content to be marked a crawlable URL\n\n#### v1.0.8\n- added `--exclude` option\n- Better regex and code logic to favor performance\n- Fixed a bug that caused dnsdumpster to fail if target was a subdomain\n- Fixed a bug that caused a crash if run outside \"Photon\" directory\n- Fixed a bug in file saving (specific to Python 3)\n\n#### v1.0.7\n- Added `--timeout` option\n- Added `--output` option\n- Added `--user-agent` option\n- Replaced lxml with regex\n- Better logic for favoring performance\n- Added bigger and separate file for user-agents\n\n#### v1.0.6\n- Fixed lot of bugs\n- Suppress SSL warnings in MAC\n- x100 speed by code optimization\n- Simplified code of `exporter` plugin\n\n#### v1.0.5\n- Added `exporter` plugin\n- Added seamless update ability\n- Fixed a bug in update function\n\n#### v1.0.4\n- Fixed an issue which caused regular links to be saved in robots.txt\n- Simplified `flash` function\n- Removed `-n` as an alias of `--ninja`\n- Added `--only-urls` option\n- Refactored code for readability\n- Skip saving files if the content is empty\n\n#### v1.0.3\n- Introduced plugins\n- Added `dnsdumpster` plugin\n- Fixed non-ascii character handling, again\n- 404 pages are now added to `failed` list\n- Handling exceptions in `jscanner`\n\n#### v1.0.2\n- Proper handling of null response from `robots.txt` & `sitemap.xml`\n- Python2 compatibility\n- Proper handling of non-ascii chars\n- Added ability to specify custom regex pattern\n- Display total time taken and average time per request\n\n#### v1.0.1\n- Disabled colors on Windows and macOS\n- Cross platform file handling\n\n#### v1.0.0\n- First stable release\n"
  },
  {
    "path": "Dockerfile",
    "content": "FROM python:3-alpine\n\nLABEL name photon\nLABEL src \"https://github.com/s0md3v/Photon\"\nLABEL creator s0md3v\nLABEL dockerfile_maintenance khast3x\nLABEL desc \"Incredibly fast crawler designed for reconnaissance.\"\n\nRUN apk add git && git clone https://github.com/s0md3v/Photon.git Photon\nWORKDIR Photon\nRUN pip install -r requirements.txt\n\nVOLUME [ \"/Photon\" ]\n# ENTRYPOINT [\"sh\"]\nENTRYPOINT [ \"python\", \"photon.py\" ]\nCMD [\"--help\"]\n"
  },
  {
    "path": "LICENSE.md",
    "content": "                    GNU GENERAL PUBLIC LICENSE\n                       Version 3, 29 June 2007\n\n Copyright (C) 2007 Free Software Foundation, Inc. <http://fsf.org/>\n Everyone is permitted to copy and distribute verbatim copies\n of this license document, but changing it is not allowed.\n\n                            Preamble\n\n  The GNU General Public License is a free, copyleft license for\nsoftware and other kinds of works.\n\n  The licenses for most software and other practical works are designed\nto take away your freedom to share and change the works.  By contrast,\nthe GNU General Public License is intended to guarantee your freedom to\nshare and change all versions of a program--to make sure it remains free\nsoftware for all its users.  We, the Free Software Foundation, use the\nGNU General Public License for most of our software; it applies also to\nany other work released this way by its authors.  You can apply it to\nyour programs, too.\n\n  When we speak of free software, we are referring to freedom, not\nprice.  Our General Public Licenses are designed to make sure that you\nhave the freedom to distribute copies of free software (and charge for\nthem if you wish), that you receive source code or can get it if you\nwant it, that you can change the software or use pieces of it in new\nfree programs, and that you know you can do these things.\n\n  To protect your rights, we need to prevent others from denying you\nthese rights or asking you to surrender the rights.  Therefore, you have\ncertain responsibilities if you distribute copies of the software, or if\nyou modify it: responsibilities to respect the freedom of others.\n\n  For example, if you distribute copies of such a program, whether\ngratis or for a fee, you must pass on to the recipients the same\nfreedoms that you received.  You must make sure that they, too, receive\nor can get the source code.  And you must show them these terms so they\nknow their rights.\n\n  Developers that use the GNU GPL protect your rights with two steps:\n(1) assert copyright on the software, and (2) offer you this License\ngiving you legal permission to copy, distribute and/or modify it.\n\n  For the developers' and authors' protection, the GPL clearly explains\nthat there is no warranty for this free software.  For both users' and\nauthors' sake, the GPL requires that modified versions be marked as\nchanged, so that their problems will not be attributed erroneously to\nauthors of previous versions.\n\n  Some devices are designed to deny users access to install or run\nmodified versions of the software inside them, although the manufacturer\ncan do so.  This is fundamentally incompatible with the aim of\nprotecting users' freedom to change the software.  The systematic\npattern of such abuse occurs in the area of products for individuals to\nuse, which is precisely where it is most unacceptable.  Therefore, we\nhave designed this version of the GPL to prohibit the practice for those\nproducts.  If such problems arise substantially in other domains, we\nstand ready to extend this provision to those domains in future versions\nof the GPL, as needed to protect the freedom of users.\n\n  Finally, every program is threatened constantly by software patents.\nStates should not allow patents to restrict development and use of\nsoftware on general-purpose computers, but in those that do, we wish to\navoid the special danger that patents applied to a free program could\nmake it effectively proprietary.  To prevent this, the GPL assures that\npatents cannot be used to render the program non-free.\n\n  The precise terms and conditions for copying, distribution and\nmodification follow.\n\n                       TERMS AND CONDITIONS\n\n  0. Definitions.\n\n  \"This License\" refers to version 3 of the GNU General Public License.\n\n  \"Copyright\" also means copyright-like laws that apply to other kinds of\nworks, such as semiconductor masks.\n\n  \"The Program\" refers to any copyrightable work licensed under this\nLicense.  Each licensee is addressed as \"you\".  \"Licensees\" and\n\"recipients\" may be individuals or organizations.\n\n  To \"modify\" a work means to copy from or adapt all or part of the work\nin a fashion requiring copyright permission, other than the making of an\nexact copy.  The resulting work is called a \"modified version\" of the\nearlier work or a work \"based on\" the earlier work.\n\n  A \"covered work\" means either the unmodified Program or a work based\non the Program.\n\n  To \"propagate\" a work means to do anything with it that, without\npermission, would make you directly or secondarily liable for\ninfringement under applicable copyright law, except executing it on a\ncomputer or modifying a private copy.  Propagation includes copying,\ndistribution (with or without modification), making available to the\npublic, and in some countries other activities as well.\n\n  To \"convey\" a work means any kind of propagation that enables other\nparties to make or receive copies.  Mere interaction with a user through\na computer network, with no transfer of a copy, is not conveying.\n\n  An interactive user interface displays \"Appropriate Legal Notices\"\nto the extent that it includes a convenient and prominently visible\nfeature that (1) displays an appropriate copyright notice, and (2)\ntells the user that there is no warranty for the work (except to the\nextent that warranties are provided), that licensees may convey the\nwork under this License, and how to view a copy of this License.  If\nthe interface presents a list of user commands or options, such as a\nmenu, a prominent item in the list meets this criterion.\n\n  1. Source Code.\n\n  The \"source code\" for a work means the preferred form of the work\nfor making modifications to it.  \"Object code\" means any non-source\nform of a work.\n\n  A \"Standard Interface\" means an interface that either is an official\nstandard defined by a recognized standards body, or, in the case of\ninterfaces specified for a particular programming language, one that\nis widely used among developers working in that language.\n\n  The \"System Libraries\" of an executable work include anything, other\nthan the work as a whole, that (a) is included in the normal form of\npackaging a Major Component, but which is not part of that Major\nComponent, and (b) serves only to enable use of the work with that\nMajor Component, or to implement a Standard Interface for which an\nimplementation is available to the public in source code form.  A\n\"Major Component\", in this context, means a major essential component\n(kernel, window system, and so on) of the specific operating system\n(if any) on which the executable work runs, or a compiler used to\nproduce the work, or an object code interpreter used to run it.\n\n  The \"Corresponding Source\" for a work in object code form means all\nthe source code needed to generate, install, and (for an executable\nwork) run the object code and to modify the work, including scripts to\ncontrol those activities.  However, it does not include the work's\nSystem Libraries, or general-purpose tools or generally available free\nprograms which are used unmodified in performing those activities but\nwhich are not part of the work.  For example, Corresponding Source\nincludes interface definition files associated with source files for\nthe work, and the source code for shared libraries and dynamically\nlinked subprograms that the work is specifically designed to require,\nsuch as by intimate data communication or control flow between those\nsubprograms and other parts of the work.\n\n  The Corresponding Source need not include anything that users\ncan regenerate automatically from other parts of the Corresponding\nSource.\n\n  The Corresponding Source for a work in source code form is that\nsame work.\n\n  2. Basic Permissions.\n\n  All rights granted under this License are granted for the term of\ncopyright on the Program, and are irrevocable provided the stated\nconditions are met.  This License explicitly affirms your unlimited\npermission to run the unmodified Program.  The output from running a\ncovered work is covered by this License only if the output, given its\ncontent, constitutes a covered work.  This License acknowledges your\nrights of fair use or other equivalent, as provided by copyright law.\n\n  You may make, run and propagate covered works that you do not\nconvey, without conditions so long as your license otherwise remains\nin force.  You may convey covered works to others for the sole purpose\nof having them make modifications exclusively for you, or provide you\nwith facilities for running those works, provided that you comply with\nthe terms of this License in conveying all material for which you do\nnot control copyright.  Those thus making or running the covered works\nfor you must do so exclusively on your behalf, under your direction\nand control, on terms that prohibit them from making any copies of\nyour copyrighted material outside their relationship with you.\n\n  Conveying under any other circumstances is permitted solely under\nthe conditions stated below.  Sublicensing is not allowed; section 10\nmakes it unnecessary.\n\n  3. Protecting Users' Legal Rights From Anti-Circumvention Law.\n\n  No covered work shall be deemed part of an effective technological\nmeasure under any applicable law fulfilling obligations under article\n11 of the WIPO copyright treaty adopted on 20 December 1996, or\nsimilar laws prohibiting or restricting circumvention of such\nmeasures.\n\n  When you convey a covered work, you waive any legal power to forbid\ncircumvention of technological measures to the extent such circumvention\nis effected by exercising rights under this License with respect to\nthe covered work, and you disclaim any intention to limit operation or\nmodification of the work as a means of enforcing, against the work's\nusers, your or third parties' legal rights to forbid circumvention of\ntechnological measures.\n\n  4. Conveying Verbatim Copies.\n\n  You may convey verbatim copies of the Program's source code as you\nreceive it, in any medium, provided that you conspicuously and\nappropriately publish on each copy an appropriate copyright notice;\nkeep intact all notices stating that this License and any\nnon-permissive terms added in accord with section 7 apply to the code;\nkeep intact all notices of the absence of any warranty; and give all\nrecipients a copy of this License along with the Program.\n\n  You may charge any price or no price for each copy that you convey,\nand you may offer support or warranty protection for a fee.\n\n  5. Conveying Modified Source Versions.\n\n  You may convey a work based on the Program, or the modifications to\nproduce it from the Program, in the form of source code under the\nterms of section 4, provided that you also meet all of these conditions:\n\n    a) The work must carry prominent notices stating that you modified\n    it, and giving a relevant date.\n\n    b) The work must carry prominent notices stating that it is\n    released under this License and any conditions added under section\n    7.  This requirement modifies the requirement in section 4 to\n    \"keep intact all notices\".\n\n    c) You must license the entire work, as a whole, under this\n    License to anyone who comes into possession of a copy.  This\n    License will therefore apply, along with any applicable section 7\n    additional terms, to the whole of the work, and all its parts,\n    regardless of how they are packaged.  This License gives no\n    permission to license the work in any other way, but it does not\n    invalidate such permission if you have separately received it.\n\n    d) If the work has interactive user interfaces, each must display\n    Appropriate Legal Notices; however, if the Program has interactive\n    interfaces that do not display Appropriate Legal Notices, your\n    work need not make them do so.\n\n  A compilation of a covered work with other separate and independent\nworks, which are not by their nature extensions of the covered work,\nand which are not combined with it such as to form a larger program,\nin or on a volume of a storage or distribution medium, is called an\n\"aggregate\" if the compilation and its resulting copyright are not\nused to limit the access or legal rights of the compilation's users\nbeyond what the individual works permit.  Inclusion of a covered work\nin an aggregate does not cause this License to apply to the other\nparts of the aggregate.\n\n  6. Conveying Non-Source Forms.\n\n  You may convey a covered work in object code form under the terms\nof sections 4 and 5, provided that you also convey the\nmachine-readable Corresponding Source under the terms of this License,\nin one of these ways:\n\n    a) Convey the object code in, or embodied in, a physical product\n    (including a physical distribution medium), accompanied by the\n    Corresponding Source fixed on a durable physical medium\n    customarily used for software interchange.\n\n    b) Convey the object code in, or embodied in, a physical product\n    (including a physical distribution medium), accompanied by a\n    written offer, valid for at least three years and valid for as\n    long as you offer spare parts or customer support for that product\n    model, to give anyone who possesses the object code either (1) a\n    copy of the Corresponding Source for all the software in the\n    product that is covered by this License, on a durable physical\n    medium customarily used for software interchange, for a price no\n    more than your reasonable cost of physically performing this\n    conveying of source, or (2) access to copy the\n    Corresponding Source from a network server at no charge.\n\n    c) Convey individual copies of the object code with a copy of the\n    written offer to provide the Corresponding Source.  This\n    alternative is allowed only occasionally and noncommercially, and\n    only if you received the object code with such an offer, in accord\n    with subsection 6b.\n\n    d) Convey the object code by offering access from a designated\n    place (gratis or for a charge), and offer equivalent access to the\n    Corresponding Source in the same way through the same place at no\n    further charge.  You need not require recipients to copy the\n    Corresponding Source along with the object code.  If the place to\n    copy the object code is a network server, the Corresponding Source\n    may be on a different server (operated by you or a third party)\n    that supports equivalent copying facilities, provided you maintain\n    clear directions next to the object code saying where to find the\n    Corresponding Source.  Regardless of what server hosts the\n    Corresponding Source, you remain obligated to ensure that it is\n    available for as long as needed to satisfy these requirements.\n\n    e) Convey the object code using peer-to-peer transmission, provided\n    you inform other peers where the object code and Corresponding\n    Source of the work are being offered to the general public at no\n    charge under subsection 6d.\n\n  A separable portion of the object code, whose source code is excluded\nfrom the Corresponding Source as a System Library, need not be\nincluded in conveying the object code work.\n\n  A \"User Product\" is either (1) a \"consumer product\", which means any\ntangible personal property which is normally used for personal, family,\nor household purposes, or (2) anything designed or sold for incorporation\ninto a dwelling.  In determining whether a product is a consumer product,\ndoubtful cases shall be resolved in favor of coverage.  For a particular\nproduct received by a particular user, \"normally used\" refers to a\ntypical or common use of that class of product, regardless of the status\nof the particular user or of the way in which the particular user\nactually uses, or expects or is expected to use, the product.  A product\nis a consumer product regardless of whether the product has substantial\ncommercial, industrial or non-consumer uses, unless such uses represent\nthe only significant mode of use of the product.\n\n  \"Installation Information\" for a User Product means any methods,\nprocedures, authorization keys, or other information required to install\nand execute modified versions of a covered work in that User Product from\na modified version of its Corresponding Source.  The information must\nsuffice to ensure that the continued functioning of the modified object\ncode is in no case prevented or interfered with solely because\nmodification has been made.\n\n  If you convey an object code work under this section in, or with, or\nspecifically for use in, a User Product, and the conveying occurs as\npart of a transaction in which the right of possession and use of the\nUser Product is transferred to the recipient in perpetuity or for a\nfixed term (regardless of how the transaction is characterized), the\nCorresponding Source conveyed under this section must be accompanied\nby the Installation Information.  But this requirement does not apply\nif neither you nor any third party retains the ability to install\nmodified object code on the User Product (for example, the work has\nbeen installed in ROM).\n\n  The requirement to provide Installation Information does not include a\nrequirement to continue to provide support service, warranty, or updates\nfor a work that has been modified or installed by the recipient, or for\nthe User Product in which it has been modified or installed.  Access to a\nnetwork may be denied when the modification itself materially and\nadversely affects the operation of the network or violates the rules and\nprotocols for communication across the network.\n\n  Corresponding Source conveyed, and Installation Information provided,\nin accord with this section must be in a format that is publicly\ndocumented (and with an implementation available to the public in\nsource code form), and must require no special password or key for\nunpacking, reading or copying.\n\n  7. Additional Terms.\n\n  \"Additional permissions\" are terms that supplement the terms of this\nLicense by making exceptions from one or more of its conditions.\nAdditional permissions that are applicable to the entire Program shall\nbe treated as though they were included in this License, to the extent\nthat they are valid under applicable law.  If additional permissions\napply only to part of the Program, that part may be used separately\nunder those permissions, but the entire Program remains governed by\nthis License without regard to the additional permissions.\n\n  When you convey a copy of a covered work, you may at your option\nremove any additional permissions from that copy, or from any part of\nit.  (Additional permissions may be written to require their own\nremoval in certain cases when you modify the work.)  You may place\nadditional permissions on material, added by you to a covered work,\nfor which you have or can give appropriate copyright permission.\n\n  Notwithstanding any other provision of this License, for material you\nadd to a covered work, you may (if authorized by the copyright holders of\nthat material) supplement the terms of this License with terms:\n\n    a) Disclaiming warranty or limiting liability differently from the\n    terms of sections 15 and 16 of this License; or\n\n    b) Requiring preservation of specified reasonable legal notices or\n    author attributions in that material or in the Appropriate Legal\n    Notices displayed by works containing it; or\n\n    c) Prohibiting misrepresentation of the origin of that material, or\n    requiring that modified versions of such material be marked in\n    reasonable ways as different from the original version; or\n\n    d) Limiting the use for publicity purposes of names of licensors or\n    authors of the material; or\n\n    e) Declining to grant rights under trademark law for use of some\n    trade names, trademarks, or service marks; or\n\n    f) Requiring indemnification of licensors and authors of that\n    material by anyone who conveys the material (or modified versions of\n    it) with contractual assumptions of liability to the recipient, for\n    any liability that these contractual assumptions directly impose on\n    those licensors and authors.\n\n  All other non-permissive additional terms are considered \"further\nrestrictions\" within the meaning of section 10.  If the Program as you\nreceived it, or any part of it, contains a notice stating that it is\ngoverned by this License along with a term that is a further\nrestriction, you may remove that term.  If a license document contains\na further restriction but permits relicensing or conveying under this\nLicense, you may add to a covered work material governed by the terms\nof that license document, provided that the further restriction does\nnot survive such relicensing or conveying.\n\n  If you add terms to a covered work in accord with this section, you\nmust place, in the relevant source files, a statement of the\nadditional terms that apply to those files, or a notice indicating\nwhere to find the applicable terms.\n\n  Additional terms, permissive or non-permissive, may be stated in the\nform of a separately written license, or stated as exceptions;\nthe above requirements apply either way.\n\n  8. Termination.\n\n  You may not propagate or modify a covered work except as expressly\nprovided under this License.  Any attempt otherwise to propagate or\nmodify it is void, and will automatically terminate your rights under\nthis License (including any patent licenses granted under the third\nparagraph of section 11).\n\n  However, if you cease all violation of this License, then your\nlicense from a particular copyright holder is reinstated (a)\nprovisionally, unless and until the copyright holder explicitly and\nfinally terminates your license, and (b) permanently, if the copyright\nholder fails to notify you of the violation by some reasonable means\nprior to 60 days after the cessation.\n\n  Moreover, your license from a particular copyright holder is\nreinstated permanently if the copyright holder notifies you of the\nviolation by some reasonable means, this is the first time you have\nreceived notice of violation of this License (for any work) from that\ncopyright holder, and you cure the violation prior to 30 days after\nyour receipt of the notice.\n\n  Termination of your rights under this section does not terminate the\nlicenses of parties who have received copies or rights from you under\nthis License.  If your rights have been terminated and not permanently\nreinstated, you do not qualify to receive new licenses for the same\nmaterial under section 10.\n\n  9. Acceptance Not Required for Having Copies.\n\n  You are not required to accept this License in order to receive or\nrun a copy of the Program.  Ancillary propagation of a covered work\noccurring solely as a consequence of using peer-to-peer transmission\nto receive a copy likewise does not require acceptance.  However,\nnothing other than this License grants you permission to propagate or\nmodify any covered work.  These actions infringe copyright if you do\nnot accept this License.  Therefore, by modifying or propagating a\ncovered work, you indicate your acceptance of this License to do so.\n\n  10. Automatic Licensing of Downstream Recipients.\n\n  Each time you convey a covered work, the recipient automatically\nreceives a license from the original licensors, to run, modify and\npropagate that work, subject to this License.  You are not responsible\nfor enforcing compliance by third parties with this License.\n\n  An \"entity transaction\" is a transaction transferring control of an\norganization, or substantially all assets of one, or subdividing an\norganization, or merging organizations.  If propagation of a covered\nwork results from an entity transaction, each party to that\ntransaction who receives a copy of the work also receives whatever\nlicenses to the work the party's predecessor in interest had or could\ngive under the previous paragraph, plus a right to possession of the\nCorresponding Source of the work from the predecessor in interest, if\nthe predecessor has it or can get it with reasonable efforts.\n\n  You may not impose any further restrictions on the exercise of the\nrights granted or affirmed under this License.  For example, you may\nnot impose a license fee, royalty, or other charge for exercise of\nrights granted under this License, and you may not initiate litigation\n(including a cross-claim or counterclaim in a lawsuit) alleging that\nany patent claim is infringed by making, using, selling, offering for\nsale, or importing the Program or any portion of it.\n\n  11. Patents.\n\n  A \"contributor\" is a copyright holder who authorizes use under this\nLicense of the Program or a work on which the Program is based.  The\nwork thus licensed is called the contributor's \"contributor version\".\n\n  A contributor's \"essential patent claims\" are all patent claims\nowned or controlled by the contributor, whether already acquired or\nhereafter acquired, that would be infringed by some manner, permitted\nby this License, of making, using, or selling its contributor version,\nbut do not include claims that would be infringed only as a\nconsequence of further modification of the contributor version.  For\npurposes of this definition, \"control\" includes the right to grant\npatent sublicenses in a manner consistent with the requirements of\nthis License.\n\n  Each contributor grants you a non-exclusive, worldwide, royalty-free\npatent license under the contributor's essential patent claims, to\nmake, use, sell, offer for sale, import and otherwise run, modify and\npropagate the contents of its contributor version.\n\n  In the following three paragraphs, a \"patent license\" is any express\nagreement or commitment, however denominated, not to enforce a patent\n(such as an express permission to practice a patent or covenant not to\nsue for patent infringement).  To \"grant\" such a patent license to a\nparty means to make such an agreement or commitment not to enforce a\npatent against the party.\n\n  If you convey a covered work, knowingly relying on a patent license,\nand the Corresponding Source of the work is not available for anyone\nto copy, free of charge and under the terms of this License, through a\npublicly available network server or other readily accessible means,\nthen you must either (1) cause the Corresponding Source to be so\navailable, or (2) arrange to deprive yourself of the benefit of the\npatent license for this particular work, or (3) arrange, in a manner\nconsistent with the requirements of this License, to extend the patent\nlicense to downstream recipients.  \"Knowingly relying\" means you have\nactual knowledge that, but for the patent license, your conveying the\ncovered work in a country, or your recipient's use of the covered work\nin a country, would infringe one or more identifiable patents in that\ncountry that you have reason to believe are valid.\n\n  If, pursuant to or in connection with a single transaction or\narrangement, you convey, or propagate by procuring conveyance of, a\ncovered work, and grant a patent license to some of the parties\nreceiving the covered work authorizing them to use, propagate, modify\nor convey a specific copy of the covered work, then the patent license\nyou grant is automatically extended to all recipients of the covered\nwork and works based on it.\n\n  A patent license is \"discriminatory\" if it does not include within\nthe scope of its coverage, prohibits the exercise of, or is\nconditioned on the non-exercise of one or more of the rights that are\nspecifically granted under this License.  You may not convey a covered\nwork if you are a party to an arrangement with a third party that is\nin the business of distributing software, under which you make payment\nto the third party based on the extent of your activity of conveying\nthe work, and under which the third party grants, to any of the\nparties who would receive the covered work from you, a discriminatory\npatent license (a) in connection with copies of the covered work\nconveyed by you (or copies made from those copies), or (b) primarily\nfor and in connection with specific products or compilations that\ncontain the covered work, unless you entered into that arrangement,\nor that patent license was granted, prior to 28 March 2007.\n\n  Nothing in this License shall be construed as excluding or limiting\nany implied license or other defenses to infringement that may\notherwise be available to you under applicable patent law.\n\n  12. No Surrender of Others' Freedom.\n\n  If conditions are imposed on you (whether by court order, agreement or\notherwise) that contradict the conditions of this License, they do not\nexcuse you from the conditions of this License.  If you cannot convey a\ncovered work so as to satisfy simultaneously your obligations under this\nLicense and any other pertinent obligations, then as a consequence you may\nnot convey it at all.  For example, if you agree to terms that obligate you\nto collect a royalty for further conveying from those to whom you convey\nthe Program, the only way you could satisfy both those terms and this\nLicense would be to refrain entirely from conveying the Program.\n\n  13. Use with the GNU Affero General Public License.\n\n  Notwithstanding any other provision of this License, you have\npermission to link or combine any covered work with a work licensed\nunder version 3 of the GNU Affero General Public License into a single\ncombined work, and to convey the resulting work.  The terms of this\nLicense will continue to apply to the part which is the covered work,\nbut the special requirements of the GNU Affero General Public License,\nsection 13, concerning interaction through a network will apply to the\ncombination as such.\n\n  14. Revised Versions of this License.\n\n  The Free Software Foundation may publish revised and/or new versions of\nthe GNU General Public License from time to time.  Such new versions will\nbe similar in spirit to the present version, but may differ in detail to\naddress new problems or concerns.\n\n  Each version is given a distinguishing version number.  If the\nProgram specifies that a certain numbered version of the GNU General\nPublic License \"or any later version\" applies to it, you have the\noption of following the terms and conditions either of that numbered\nversion or of any later version published by the Free Software\nFoundation.  If the Program does not specify a version number of the\nGNU General Public License, you may choose any version ever published\nby the Free Software Foundation.\n\n  If the Program specifies that a proxy can decide which future\nversions of the GNU General Public License can be used, that proxy's\npublic statement of acceptance of a version permanently authorizes you\nto choose that version for the Program.\n\n  Later license versions may give you additional or different\npermissions.  However, no additional obligations are imposed on any\nauthor or copyright holder as a result of your choosing to follow a\nlater version.\n\n  15. Disclaimer of Warranty.\n\n  THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY\nAPPLICABLE LAW.  EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT\nHOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM \"AS IS\" WITHOUT WARRANTY\nOF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO,\nTHE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR\nPURPOSE.  THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM\nIS WITH YOU.  SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF\nALL NECESSARY SERVICING, REPAIR OR CORRECTION.\n\n  16. Limitation of Liability.\n\n  IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING\nWILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS\nTHE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY\nGENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE\nUSE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF\nDATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD\nPARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS),\nEVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF\nSUCH DAMAGES.\n\n  17. Interpretation of Sections 15 and 16.\n\n  If the disclaimer of warranty and limitation of liability provided\nabove cannot be given local legal effect according to their terms,\nreviewing courts shall apply local law that most closely approximates\nan absolute waiver of all civil liability in connection with the\nProgram, unless a warranty or assumption of liability accompanies a\ncopy of the Program in return for a fee.\n\n                     END OF TERMS AND CONDITIONS\n\n            How to Apply These Terms to Your New Programs\n\n  If you develop a new program, and you want it to be of the greatest\npossible use to the public, the best way to achieve this is to make it\nfree software which everyone can redistribute and change under these terms.\n\n  To do so, attach the following notices to the program.  It is safest\nto attach them to the start of each source file to most effectively\nstate the exclusion of warranty; and each file should have at least\nthe \"copyright\" line and a pointer to where the full notice is found.\n\n    <one line to give the program's name and a brief idea of what it does.>\n    Copyright (C) <year>  <name of author>\n\n    This program is free software: you can redistribute it and/or modify\n    it under the terms of the GNU General Public License as published by\n    the Free Software Foundation, either version 3 of the License, or\n    (at your option) any later version.\n\n    This program is distributed in the hope that it will be useful,\n    but WITHOUT ANY WARRANTY; without even the implied warranty of\n    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\n    GNU General Public License for more details.\n\n    You should have received a copy of the GNU General Public License\n    along with this program.  If not, see <http://www.gnu.org/licenses/>.\n\nAlso add information on how to contact you by electronic and paper mail.\n\n  If the program does terminal interaction, make it output a short\nnotice like this when it starts in an interactive mode:\n\n    {{ project }}  Copyright (C) {{ year }}  {{ organization }}\n    This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'.\n    This is free software, and you are welcome to redistribute it\n    under certain conditions; type `show c' for details.\n\nThe hypothetical commands `show w' and `show c' should show the appropriate\nparts of the General Public License.  Of course, your program's commands\nmight be different; for a GUI interface, you would use an \"about box\".\n\n  You should also get your employer (if you work as a programmer) or school,\nif any, to sign a \"copyright disclaimer\" for the program, if necessary.\nFor more information on this, and how to apply and follow the GNU GPL, see\n<http://www.gnu.org/licenses/>.\n\n  The GNU General Public License does not permit incorporating your program\ninto proprietary programs.  If your program is a subroutine library, you\nmay consider it more useful to permit linking proprietary applications with\nthe library.  If this is what you want to do, use the GNU Lesser General\nPublic License instead of this License.  But first, please read\n<http://www.gnu.org/philosophy/why-not-lgpl.html>."
  },
  {
    "path": "MANIFEST.in",
    "content": "include LICENSE.md\n"
  },
  {
    "path": "README.md",
    "content": "<h1 align=\"center\">\n  <br>\n  <a href=\"https://github.com/s0md3v/Photon\"><img src=\"https://image.ibb.co/h5OZAK/photonsmall.png\" alt=\"Photon\"></a>\n  <br>\n  Photon\n  <br>\n</h1>\n\n<h4 align=\"center\">Incredibly fast crawler designed for OSINT.</h4>\n\n<p align=\"center\">\n  <a href=\"https://github.com/s0md3v/Photon/releases\">\n    <img src=\"https://img.shields.io/github/release/s0md3v/Photon.svg\">\n  </a>\n  <a href=\"https://pypi.org/project/photon/\">\n    <img src=\"https://img.shields.io/badge/pypi-@photon-red.svg?style=style=flat-square\"\n         alt=\"pypi\">\n  </a>\n  <a href=\"https://github.com/s0md3v/Photon/issues?q=is%3Aissue+is%3Aclosed\">\n      <img src=\"https://img.shields.io/github/issues-closed-raw/s0md3v/Photon.svg\">\n  </a>\n  <a href=\"https://travis-ci.com/s0md3v/Photon\">\n    <img src=\"https://img.shields.io/travis/com/s0md3v/Photon.svg\">\n  </a>\n</p>\n\n<p align=\"center\">\n  <a href=\"https://github.com/s0md3v/Photon/wiki\">Photon Wiki</a> •\n  <a href=\"https://github.com/s0md3v/Photon/wiki/Usage\">How To Use</a> •\n  <a href=\"https://github.com/s0md3v/Photon/wiki/Compatibility-&-Dependencies\">Compatibility</a> •\n  <a href=\"https://github.com/s0md3v/Photon/wiki/Photon-Library\">Photon Library</a> •\n  <a href=\"#contribution--license\">Contribution</a> •\n  <a href=\"https://github.com/s0md3v/Photon/projects/1\">Roadmap</a>\n</p>\n\n### Key Features\n\n#### Data Extraction\nPhoton can extract the following data while crawling:\n\n- URLs (in-scope & out-of-scope)\n- URLs with parameters (`example.com/gallery.php?id=2`)\n- Intel (emails, social media accounts, amazon buckets etc.)\n- Files (pdf, png, xml etc.)\n- Secret keys (auth/API keys & hashes)\n- JavaScript files & Endpoints present in them\n- Strings matching custom regex pattern\n- Subdomains & DNS related data\n\nThe extracted information is saved in an organized manner or can be [exported as json](https://github.com/s0md3v/Photon/wiki/Usage#export-formatted-result).\n\n![save demo](https://image.ibb.co/dS1BqK/carbon_2.png)\n\n#### Flexible\nControl timeout, delay, add seeds, exclude URLs matching a regex pattern and other cool stuff.\nThe extensive range of [options](https://github.com/s0md3v/Photon/wiki/Usage) provided by Photon lets you crawl the web exactly the way you want.\n\n#### Genius\nPhoton's smart thread management & refined logic gives you top notch performance.\n\nStill, crawling can be resource intensive but Photon has some tricks up it's sleeves. You can fetch URLs archived by [archive.org](https://archive.org/) to be used as seeds by using `--wayback` option.\n\n#### Plugins\n- **[wayback](https://github.com/s0md3v/Photon/wiki/Usage#use-urls-from-archiveorg-as-seeds)**\n- **[dnsdumpster](https://github.com/s0md3v/Photon/wiki/Usage#dumping-dns-data)**\n- **[Exporter](https://github.com/s0md3v/Photon/wiki/Usage#export-formatted-result)**\n\n#### Docker\n\nPhoton can be launched using a lightweight Python-Alpine (103 MB) Docker image.\n\n```bash\n$ git clone https://github.com/s0md3v/Photon.git\n$ cd Photon\n$ docker build -t photon .\n$ docker run -it --name photon photon:latest -u google.com\n```\n\nTo view results, you can either head over to the local docker volume, which you can find by running `docker inspect photon` or by mounting the target loot folder:\n\n```bash\n$ docker run -it --name photon -v \"$PWD:/Photon/google.com\" photon:latest -u google.com\n```\n\n#### Frequent & Seamless Updates\nPhoton is under heavy development and updates for fixing bugs. optimizing performance & new features are being rolled regularly.\n\nIf you would like to see features and issues that are being worked on, you can do that on [Development](https://github.com/s0md3v/Photon/projects/1) project board.\n\nUpdates can be installed & checked for with the `--update` option. Photon has seamless update capabilities which means you can update Photon without losing any of your saved data.\nUse Control + Shift + m to toggle the tab key moving focus. Alternatively, use esc then tab to move to the next interactive element on the page.\nAttach files by dragging & dropping, selecting or pasting them.\n(https://www.thordata.com/?ls=github&lk=Photon)\n\n![demo](https://image.ibb.co/kQSUcz/demo.png)\n\n<p align=\"center\">\n  <a href=\"https://github.com/s0md3v/Photon/wiki\">Photon Wiki</a> •\n  <a href=\"https://github.com/s0md3v/Photon/wiki/Usage\">How To Use</a> •\n  <a href=\"https://github.com/s0md3v/Photon/wiki/Compatibility-&-Dependencies\">Compatibility</a> •\n  <a href=\"https://github.com/s0md3v/Photon/wiki/Photon-Library\">Photon Library</a> •\n  <a href=\"#contribution--license\">Contribution</a> •\n  <a href=\"https://github.com/s0md3v/Photon/projects/1\">Roadmap</a>\n</p>\n\n### Key Features\n\n#### Data Extraction\nPhoton can extract the following data while crawling:\n\n- URLs (in-scope & out-of-scope)\n- URLs with parameters (`example.com/gallery.php?id=2`)\n- Intel (emails, social media accounts, amazon buckets etc.)\n- Files (pdf, png, xml etc.)\n- Secret keys (auth/API keys & hashes)\n- JavaScript files & Endpoints present in them\n- Strings matching custom regex pattern\n- Subdomains & DNS related data\n\nThe extracted information is saved in an organized manner or can be [exported as json](https://github.com/s0md3v/Photon/wiki/Usage#export-formatted-result).\n\n![save demo](https://image.ibb.co/dS1BqK/carbon_2.png)\n\n#### Flexible\nControl timeout, delay, add seeds, exclude URLs matching a regex pattern and other cool stuff.\nThe extensive range of [options](https://github.com/s0md3v/Photon/wiki/Usage) provided by Photon lets you crawl the web exactly the way you want.\n\n#### Genius\nPhoton's smart thread management & refined logic gives you top notch performance.\n\nStill, crawling can be resource intensive but Photon has some tricks up it's sleeves. You can fetch URLs archived by [archive.org](https://archive.org/) to be used as seeds by using `--wayback` option.\n\n#### Plugins\n- **[wayback](https://github.com/s0md3v/Photon/wiki/Usage#use-urls-from-archiveorg-as-seeds)**\n- **[dnsdumpster](https://github.com/s0md3v/Photon/wiki/Usage#dumping-dns-data)**\n- **[Exporter](https://github.com/s0md3v/Photon/wiki/Usage#export-formatted-result)**\n\n#### Docker\n\nPhoton can be launched using a lightweight Python-Alpine (103 MB) Docker image.\n\n```bash\n$ git clone https://github.com/s0md3v/Photon.git\n$ cd Photon\n$ docker build -t photon .\n$ docker run -it --name photon photon:latest -u google.com\n```\n\nTo view results, you can either head over to the local docker volume, which you can find by running `docker inspect photon` or by mounting the target loot folder:\n\n```bash\n$ docker run -it --name photon -v \"$PWD:/Photon/google.com\" photon:latest -u google.com\n```\n\n#### Frequent & Seamless Updates\nPhoton is under heavy development and updates for fixing bugs. optimizing performance & new features are being rolled regularly.\n\nIf you would like to see features and issues that are being worked on, you can do that on [Development](https://github.com/s0md3v/Photon/projects/1) project board.\n\nUpdates can be installed & checked for with the `--update` option. Photon has seamless update capabilities which means you can update Photon without losing any of your saved data.\n\n### Contribution & License\nYou can contribute in following ways:\n\n- Report bugs\n- Develop plugins\n- Add more \"APIs\" for ninja mode\n- Give suggestions to make it better\n- Fix issues & submit a pull request\n\nPlease read the [guidelines](https://github.com/s0md3v/Photon/wiki/Guidelines) before submitting a pull request or issue.\n\nDo you want to have a conversation in private? Hit me up on my [twitter](https://twitter.com/s0md3v/), inbox is open :)\n\n**Photon** is licensed under [GPL v3.0 license](https://www.gnu.org/licenses/gpl-3.0.en.html)\n"
  },
  {
    "path": "core/__init__.py",
    "content": "\"\"\"The Photon core.\"\"\"\n"
  },
  {
    "path": "core/colors.py",
    "content": "import sys\n\n\nif sys.platform.lower().startswith(('os', 'win', 'darwin', 'ios')):\n    # Colors shouldn't be displayed on Mac and Windows\n    end = red = white = green = yellow = run = bad = good = info = que = ''\nelse:\n    white = '\\033[97m'\n    green = '\\033[92m'\n    red = '\\033[91m'\n    yellow = '\\033[93m'\n    end = '\\033[0m'\n    back = '\\033[7;91m'\n    info = '\\033[93m[!]\\033[0m'\n    que = '\\033[94m[?]\\033[0m'\n    bad = '\\033[91m[-]\\033[0m'\n    good = '\\033[92m[+]\\033[0m'\n    run = '\\033[97m[~]\\033[0m'\n"
  },
  {
    "path": "core/config.py",
    "content": "\"\"\"Configuration options for Photon.\"\"\"\n\nVERBOSE = False\n\nINTELS = [\n    'facebook.com',\n    'github.com',\n    'instagram.com',\n    'youtube.com',\n]\n\nBAD_TYPES = (\n    'bmp',\n    'css',\n    'csv',\n    'docx',\n    'ico',\n    'jpeg',\n    'jpg',\n    'js',\n    'json',\n    'pdf',\n    'png',\n    'svg',\n    'xls',\n    'xml',\n)\n"
  },
  {
    "path": "core/flash.py",
    "content": "from __future__ import print_function\nimport concurrent.futures\n\nfrom core.colors import info\n\ndef flash(function, links, thread_count):\n    \"\"\"Process the URLs and uses a threadpool to execute a function.\"\"\"\n    # Convert links (set) to list\n    links = list(links)\n    threadpool = concurrent.futures.ThreadPoolExecutor(\n            max_workers=thread_count)\n    futures = (threadpool.submit(function, link) for link in links)\n    for i, _ in enumerate(concurrent.futures.as_completed(futures)):\n        if i + 1 == len(links) or (i + 1) % thread_count == 0:\n            print('%s Progress: %i/%i' % (info, i + 1, len(links)),\n                    end='\\r')\n    print('')\n"
  },
  {
    "path": "core/mirror.py",
    "content": "import os\n\n\ndef mirror(url, response):\n    if response != 'dummy':\n        clean_url = url.replace('http://', '').replace('https://', '').rstrip('/')\n        parts = clean_url.split('?')[0].split('/')\n        root = parts[0]\n        webpage = parts[-1]\n        parts.remove(root)\n        try:\n            parts.remove(webpage)\n        except ValueError:\n            pass\n        prefix = root + '_mirror'\n        try:\n            os.mkdir(prefix)\n        except OSError:\n            pass\n        suffix = ''\n        if parts:\n            for directory in parts:\n                suffix += directory + '/'\n                try:\n                    os.mkdir(prefix + '/' + suffix)\n                except OSError:\n                    pass\n        path = prefix + '/' + suffix\n        trail = ''\n        if '.' not in webpage:\n            trail += '.html'\n        if webpage == root:\n            name = 'index.html'\n        else:\n            name = webpage\n        if len(url.split('?')) > 1:\n            trail += '?' + url.split('?')[1]\n        with open(path + name + trail, 'w+') as out_file:\n            out_file.write(response.encode('utf-8'))\n"
  },
  {
    "path": "core/prompt.py",
    "content": "\"\"\"Support for an input prompt.\"\"\"\nimport os\nimport tempfile\n\n\ndef prompt(default=None):\n    \"\"\"Present the user a prompt.\"\"\"\n    editor = 'nano'\n    with tempfile.NamedTemporaryFile(mode='r+') as tmpfile:\n        if default:\n            tmpfile.write(default)\n            tmpfile.flush()\n\n        child_pid = os.fork()\n        is_child = child_pid == 0\n\n        if is_child:\n            os.execvp(editor, [editor, tmpfile.name])\n        else:\n            os.waitpid(child_pid, 0)\n            tmpfile.seek(0)\n            return tmpfile.read().strip()\n"
  },
  {
    "path": "core/regex.py",
    "content": "import re\n\n# regex taken from https://github.com/InQuest/python-iocextract\n# Reusable end punctuation regex.\nEND_PUNCTUATION = r\"[\\.\\?>\\\"'\\)!,}:;\\u201d\\u2019\\uff1e\\uff1c\\]]*\"\n\n# Reusable regex for symbols commonly used to defang.\nSEPARATOR_DEFANGS = r\"[\\(\\)\\[\\]{}<>\\\\]\"\n\n# Split URLs on some characters that may be valid, but may also be garbage.\nURL_SPLIT_STR = r\"[>\\\"'\\),};]\"\n\n# Get basic url format, including a few obfuscation techniques, main anchor is the uri scheme.\nGENERIC_URL = re.compile(r\"\"\"\n        (\n            # Scheme.\n            [fhstu]\\S\\S?[px]s?\n            # One of these delimiters/defangs.\n            (?:\n                :\\/\\/|\n                :\\\\\\\\|\n                :?__\n            )\n            # Any number of defang characters.\n            (?:\n                \\x20|\n                \"\"\" + SEPARATOR_DEFANGS + r\"\"\"\n            )*\n            # Domain/path characters.\n            \\w\n            \\S+?\n            # CISCO ESA style defangs followed by domain/path characters.\n            (?:\\x20[\\/\\.][^\\.\\/\\s]\\S*?)*\n        )\n    \"\"\" + END_PUNCTUATION + r\"\"\"\n        (?=\\s|$)\n    \"\"\", re.IGNORECASE | re.VERBOSE | re.UNICODE)\n\n# Get some obfuscated urls, main anchor is brackets around the period.\nBRACKET_URL = re.compile(r\"\"\"\n        \\b\n        (\n            [\\.\\:\\/\\\\\\w\\[\\]\\(\\)-]+\n            (?:\n                \\x20?\n                [\\(\\[]\n                \\x20?\n                \\.\n                \\x20?\n                [\\]\\)]\n                \\x20?\n                \\S*?\n            )+\n        )\n    \"\"\" + END_PUNCTUATION + r\"\"\"\n        (?=\\s|$)\n    \"\"\", re.VERBOSE | re.UNICODE)\n\n# Get some obfuscated urls, main anchor is backslash before a period.\nBACKSLASH_URL = re.compile(r\"\"\"\n        \\b\n        (\n            [\\:\\/\\\\\\w\\[\\]\\(\\)-]+\n            (?:\n                \\x20?\n                \\\\?\\.\n                \\x20?\n                \\S*?\n            )*?\n            (?:\n                \\x20?\n                \\\\\\.\n                \\x20?\n                \\S*?\n            )\n            (?:\n                \\x20?\n                \\\\?\\.\n                \\x20?\n                \\S*?\n            )*\n        )\n    \"\"\" + END_PUNCTUATION + r\"\"\"\n        (?=\\s|$)\n    \"\"\", re.VERBOSE | re.UNICODE)\n\n# Get hex-encoded urls.\nHEXENCODED_URL = re.compile(r\"\"\"\n        (\n            [46][86]\n            (?:[57]4)?\n            [57]4[57]0\n            (?:[57]3)?\n            3a2f2f\n            (?:2[356def]|3[0-9adf]|[46][0-9a-f]|[57][0-9af])+\n        )\n        (?:[046]0|2[0-2489a-c]|3[bce]|[57][b-e]|[8-f][0-9a-f]|0a|0d|09|[\n            \\x5b-\\x5d\\x7b\\x7d\\x0a\\x0d\\x20\n        ]|$)\n    \"\"\", re.IGNORECASE | re.VERBOSE)\n\n# Get urlencoded urls.\nURLENCODED_URL = re.compile(r\"\"\"\n        (s?[hf]t?tps?%3A%2F%2F\\w[\\w%-]*?)(?:[^\\w%-]|$)\n    \"\"\", re.IGNORECASE | re.VERBOSE)\n\n# Get base64-encoded urls.\nB64ENCODED_URL = re.compile(r\"\"\"\n        (\n            # b64re '([hH][tT][tT][pP][sS]|[hH][tT][tT][pP]|[fF][tT][pP])://'\n            # Modified to ignore whitespace.\n            (?:\n                [\\x2b\\x2f-\\x39A-Za-z]\\s*[\\x2b\\x2f-\\x39A-Za-z]\\s*[\\x31\\x35\\x39BFJNRVZdhlptx]\\s*[Gm]\\s*[Vd]\\s*[FH]\\s*[A]\\s*\\x36\\s*L\\s*y\\s*[\\x2b\\x2f\\x38-\\x39]\\s*|\n                [\\x2b\\x2f-\\x39A-Za-z]\\s*[\\x2b\\x2f-\\x39A-Za-z]\\s*[\\x31\\x35\\x39BFJNRVZdhlptx]\\s*[Io]\\s*[Vd]\\s*[FH]\\s*[R]\\s*[Qw]\\s*[O]\\s*i\\s*\\x38\\s*v\\s*[\\x2b\\x2f-\\x39A-Za-z]\\s*|\n                [\\x2b\\x2f-\\x39A-Za-z]\\s*[\\x2b\\x2f-\\x39A-Za-z]\\s*[\\x31\\x35\\x39BFJNRVZdhlptx]\\s*[Io]\\s*[Vd]\\s*[FH]\\s*[R]\\s*[Qw]\\s*[Uc]\\s*[z]\\s*o\\s*v\\s*L\\s*[\\x2b\\x2f-\\x39w-z]\\s*|\n                [\\x2b\\x2f-\\x39A-Za-z]\\s*[\\x30\\x32EGUWkm]\\s*[Z]\\s*[\\x30U]\\s*[Uc]\\s*[D]\\s*o\\s*v\\s*L\\s*[\\x2b\\x2f-\\x39w-z]\\s*|\n                [\\x2b\\x2f-\\x39A-Za-z]\\s*[\\x30\\x32EGUWkm]\\s*[h]\\s*[\\x30U]\\s*[Vd]\\s*[FH]\\s*[A]\\s*\\x36\\s*L\\s*y\\s*[\\x2b\\x2f\\x38-\\x39]\\s*|\n                [\\x2b\\x2f-\\x39A-Za-z]\\s*[\\x30\\x32EGUWkm]\\s*[h]\\s*[\\x30U]\\s*[Vd]\\s*[FH]\\s*[B]\\s*[Tz]\\s*[O]\\s*i\\s*\\x38\\s*v\\s*[\\x2b\\x2f-\\x39A-Za-z]\\s*|\n                [RZ]\\s*[ln]\\s*[R]\\s*[Qw]\\s*[O]\\s*i\\s*\\x38\\s*v\\s*[\\x2b\\x2f-\\x39A-Za-z]\\s*|\n                [Sa]\\s*[FH]\\s*[R]\\s*[\\x30U]\\s*[Uc]\\s*[D]\\s*o\\s*v\\s*L\\s*[\\x2b\\x2f-\\x39w-z]\\s*|\n                [Sa]\\s*[FH]\\s*[R]\\s*[\\x30U]\\s*[Uc]\\s*[FH]\\s*[M]\\s*\\x36\\s*L\\s*y\\s*[\\x2b\\x2f\\x38-\\x39]\\s*\n            )\n            # Up to 260 characters (pre-encoding, reasonable URL length).\n            [A-Za-z0-9+/=\\s]{1,357}\n        )\n        (?=[^A-Za-z0-9+/=\\s]|$)\n    \"\"\", re.VERBOSE)\n\n# Get some valid obfuscated ip addresses.\nIPV4 = re.compile(r\"\"\"\n        (?:^|\n            (?![^\\d\\.])\n        )\n        (?:\n            (?:[1-9]?\\d|1\\d\\d|2[0-4]\\d|25[0-5])\n            [\\[\\(\\\\]*?\\.[\\]\\)]*?\n        ){3}\n        (?:[1-9]?\\d|1\\d\\d|2[0-4]\\d|25[0-5])\n        (?:(?=[^\\d\\.])|$)\n    \"\"\", re.VERBOSE)\n\n# Experimental IPv6 regex, will not catch everything but should be sufficent for now.\nIPV6 = re.compile(r\"\"\"\n        \\b(?:[a-f0-9]{1,4}:|:){2,7}(?:[a-f0-9]{1,4}|:)\\b\n    \"\"\", re.IGNORECASE | re.VERBOSE)\n\n# Capture email addresses including common defangs.\nEMAIL = re.compile(r\"\"\"\n        (\n            [a-z0-9_.+-]+\n            [\\(\\[{\\x20]*\n            (?:@|\\Wat\\W)\n            [\\)\\]}\\x20]*\n            [a-z0-9-]+\n            (?:\n                (?:\n                    (?:\n                        \\x20*\n                        \"\"\" + SEPARATOR_DEFANGS + r\"\"\"\n                        \\x20*\n                    )*\n                    \\.\n                    (?:\n                        \\x20*\n                        \"\"\" + SEPARATOR_DEFANGS + r\"\"\"\n                        \\x20*\n                    )*\n                    |\n                    \\W+dot\\W+\n                )\n                [a-z0-9-]+?\n            )+\n        )\n    \"\"\" + END_PUNCTUATION + r\"\"\"\n        (?=\\s|$)\n    \"\"\", re.IGNORECASE | re.VERBOSE | re.UNICODE)\n\nMD5 = re.compile(r\"(?:[^a-fA-F\\d]|\\b)([a-fA-F\\d]{32})(?:[^a-fA-F\\d]|\\b)\")\nSHA1 = re.compile(r\"(?:[^a-fA-F\\d]|\\b)([a-fA-F\\d]{40})(?:[^a-fA-F\\d]|\\b)\")\nSHA256 = re.compile(r\"(?:[^a-fA-F\\d]|\\b)([a-fA-F\\d]{64})(?:[^a-fA-F\\d]|\\b)\")\nSHA512 = re.compile(\n    r\"(?:[^a-fA-F\\d]|\\b)([a-fA-F\\d]{128})(?:[^a-fA-F\\d]|\\b)\")\n\n# YARA regex.\nYARA_PARSE = re.compile(r\"\"\"\n        (?:^|\\s)\n        (\n            (?:\n                \\s*?import\\s+?\"[^\\r\\n]*?[\\r\\n]+|\n                \\s*?include\\s+?\"[^\\r\\n]*?[\\r\\n]+|\n                \\s*?//[^\\r\\n]*[\\r\\n]+|\n                \\s*?/\\*.*?\\*/\\s*?\n            )*\n            (?:\n                \\s*?private\\s+|\n                \\s*?global\\s+\n            )*\n            rule\\s*?\n            \\w+\\s*?\n            (?:\n                :[\\s\\w]+\n            )?\n            \\s+\\{\n            .*?\n            condition\\s*?:\n            .*?\n            \\s*\\}\n        )\n        (?:$|\\s)\n    \"\"\", re.MULTILINE | re.DOTALL | re.VERBOSE)\n\nCREDIT_CARD = re.compile(r\"[0-9]{4}[ ]?[-]?[0-9]{4}[ ]?[-]?[0-9]{4}[ ]?[-]?[0-9]{4}\")\n\nrintels = [(GENERIC_URL, \"GENERIC_URL\"),\n           (BRACKET_URL, \"BRACKET_URL\"),\n           (BACKSLASH_URL, \"BACKSLASH_URL\"),\n           (HEXENCODED_URL, \"HEXENCODED_URL\"),\n           (URLENCODED_URL, \"URLENCODED_URL\"),\n           (B64ENCODED_URL, \"B64ENCODED_URL\"),\n           (IPV4, \"IPV4\"),\n           (IPV6, \"IPV6\"),\n           (EMAIL, \"EMAIL\"),\n           (MD5, \"MD5\"),\n           (SHA1, \"SHA1\"),\n           (SHA256, \"SHA256\"),\n           (SHA512, \"SHA512\"),\n           (YARA_PARSE, \"YARA_PARSE\"),\n           (CREDIT_CARD, \"CREDIT_CARD\")]\n\n\nrscript = re.compile(r'<(script|SCRIPT).*(src|SRC)=([^\\s>]+)')\nrhref = re.compile(r'<[aA].*(href|HREF)=([^\\s>]+)')\nrendpoint = re.compile(r'[\\'\"](/.*?)[\\'\"]|[\\'\"](http.*?)[\\'\"]')\nrentropy = re.compile(r'[\\w-]{16,45}')\n"
  },
  {
    "path": "core/requester.py",
    "content": "import random\nimport time\n\nimport requests\nfrom requests.exceptions import TooManyRedirects\n\n\nSESSION = requests.Session()\nSESSION.max_redirects = 3\n\ndef requester(\n        url,\n        main_url=None,\n        delay=0,\n        cook=None,\n        headers=None,\n        timeout=10,\n        host=None,\n        proxies=[None],\n        user_agents=[None],\n        failed=None,\n        processed=None\n    ):\n    \"\"\"Handle the requests and return the response body.\"\"\"\n    cook = cook or set()\n    headers = headers or set()\n    user_agents = user_agents or ['Photon']\n    failed = failed or set()\n    processed = processed or set()\n    # Mark the URL as crawled\n    processed.add(url)\n    # Pause/sleep the program for specified time\n    time.sleep(delay)\n\n    def make_request(url):\n        \"\"\"Default request\"\"\"\n        final_headers = headers or {\n            'Host': host,\n            # Selecting a random user-agent\n            'User-Agent': random.choice(user_agents),\n            'Accept': 'text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8',\n            'Accept-Language': 'en-US,en;q=0.5',\n            'Accept-Encoding': 'gzip',\n            'DNT': '1',\n            'Connection': 'close',\n        }\n        try:\n            response = SESSION.get(\n                url,\n                cookies=cook,\n                headers=final_headers,\n                verify=False,\n                timeout=timeout,\n                stream=True,\n                proxies=random.choice(proxies)\n            )\n        except TooManyRedirects:\n            return 'dummy'\n\n        if 'text/html' in response.headers['content-type'] or \\\n           'text/plain' in response.headers['content-type']:\n            if response.status_code != '404':\n                return response.text\n            else:\n                response.close()\n                failed.add(url)\n                return 'dummy'\n        else:\n            response.close()\n            return 'dummy'\n\n    return make_request(url)\n"
  },
  {
    "path": "core/updater.py",
    "content": "import os\nimport re\n\nfrom core.colors import run, que, good, green, end, info\nfrom core.requester import requester\n\n\ndef updater():\n    \"\"\"Update the current installation.\n\n    git clones the latest version and merges it with the current directory.\n    \"\"\"\n    print('%s Checking for updates' % run)\n    # Changes must be separated by ;\n    changes = '''major bug fixes;removed ninja mode;dropped python < 3.2 support;fixed unicode output;proxy support;more intels'''\n    latest_commit = requester('https://raw.githubusercontent.com/s0md3v/Photon/master/core/updater.py', host='raw.githubusercontent.com')\n    # Just a hack to see if a new version is available\n    if changes not in latest_commit:\n        changelog = re.search(r\"changes = '''(.*?)'''\", latest_commit)\n        # Splitting the changes to form a list\n        changelog = changelog.group(1).split(';')\n        print('%s A new version of Photon is available.' % good)\n        print('%s Changes:' % info)\n        for change in changelog: # print changes\n            print('%s>%s %s' % (green, end, change))\n\n        current_path = os.getcwd().split('/') # if you know it, you know it\n        folder = current_path[-1] # current directory name\n        path = '/'.join(current_path) # current directory path\n        choice = input('%s Would you like to update? [Y/n] ' % que).lower()\n\n        if choice != 'n':\n            print('%s Updating Photon' % run)\n            os.system('git clone --quiet https://github.com/s0md3v/Photon %s'\n                      % (folder))\n            os.system('cp -r %s/%s/* %s && rm -r %s/%s/ 2>/dev/null'\n                      % (path, folder, path, path, folder))\n            print('%s Update successful!' % good)\n    else:\n        print('%s Photon is up to date!' % good)\n"
  },
  {
    "path": "core/user-agents.txt",
    "content": "Mozilla/4.0 (compatible; MSIE 6.0; MSIE 5.5; Windows NT 5.0) Opera 7.02 Bork-edition [en]\nMozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.0; .NET CLR 1.0.3705)\nMozilla/4.0 (compatible; MSIE 7.0; Windows NT 5.1; Trident/4.0; .NET CLR 2.0.50727; .NET CLR 3.0.4506.2152; .NET CLR 3.5.30729)\nMozilla/5.0 (compatible; Baiduspider/2.0; +http://www.baidu.com/search/spider.html)\nMozilla/5.0 (compatible; MSIE 9.0; Windows NT 6.1; WOW64; Trident/5.0)\nMozilla/5.0 (Macintosh; Intel Mac OS X 10_11_2) AppleWebKit/601.3.9 (KHTML, like Gecko) Version/9.0.2 Safari/601.3.9\nMozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/42.0.2311.135 Safari/537.36 Edge/12.246\nMozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; FSL 7.0.7.01001)\nMozilla/5.0 (Windows NT 5.1; rv:13.0) Gecko/20100101 Firefox/13.0.1\nMozilla/5.0 (Windows NT 6.0) AppleWebKit/535.1 (KHTML, like Gecko) Chrome/13.0.782.112 Safari/535.1\nMozilla/5.0 (Windows NT 6.1; rv:5.0) Gecko/20100101 Firefox/5.02\nMozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/47.0.2526.111 Safari/537.36\nMozilla/4.0 (compatible; MSIE 7.0; Windows NT 5.1; SV1; .NET CLR 2.0.50727)\nMozilla/5.0 (Windows NT 6.1; WOW64; rv:12.0) Gecko/20100101 Firefox/12.0\nMozilla/5.0 (X11; CrOS x86_64 8172.45.0) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/51.0.2704.64 Safari/537.36\nMozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:15.0) Gecko/20100101 Firefox/15.0.1\nMozilla/5.0 (X11; U; Linux x86_64; de; rv:1.9.2.8) Gecko/20100723 Ubuntu/10.04 (lucid) Firefox/3.6.8\nOpera/9.80 (Windows NT 5.1; U; en) Presto/2.10.289 Version/12.01\n"
  },
  {
    "path": "core/utils.py",
    "content": "import requests\nimport math\nimport os.path\nimport re\nimport argparse\n\nimport tld\n\nfrom core.colors import info\nfrom core.config import VERBOSE, BAD_TYPES\n\nfrom urllib.parse import urlparse\n\n\ndef regxy(pattern, response, supress_regex, custom):\n    \"\"\"Extract a string based on regex pattern supplied by user.\"\"\"\n    try:\n        matches = re.findall(r'%s' % pattern, response)\n        for match in matches:\n            verb('Custom regex', match)\n            custom.add(match)\n    except:\n        supress_regex = True\n\n\ndef is_link(url, processed, files):\n    \"\"\"\n    Determine whether or not a link should be crawled\n    A url should not be crawled if it\n        - Is a file\n        - Has already been crawled\n\n    Args:\n        url: str Url to be processed\n        processed: list[str] List of urls that have already been crawled\n\n    Returns:\n        bool If `url` should be crawled\n    \"\"\"\n    if url not in processed:\n        if url.startswith('#') or url.startswith('javascript:'):\n            return False\n        is_file = url.endswith(BAD_TYPES)\n        if is_file:\n            files.add(url)\n            return False\n        return True\n    return False\n\n\ndef remove_regex(urls, regex):\n    \"\"\"\n    Parse a list for non-matches to a regex.\n\n    Args:\n        urls: iterable of urls\n        regex: string regex to be parsed for\n\n    Returns:\n        list of strings not matching regex\n    \"\"\"\n\n    if not regex:\n        return urls\n\n    # To avoid iterating over the characters of a string\n    if not isinstance(urls, (list, set, tuple)):\n        urls = [urls]\n\n    try:\n        non_matching_urls = [url for url in urls if not re.search(regex, url)]\n    except TypeError:\n        return []\n\n    return non_matching_urls\n\n\ndef writer(datasets, dataset_names, output_dir):\n    \"\"\"Write the results.\"\"\"\n    for dataset, dataset_name in zip(datasets, dataset_names):\n        if dataset:\n            filepath = output_dir + '/' + dataset_name + '.txt'\n            with open(filepath, 'w+') as out_file:\n                joined = '\\n'.join(dataset)\n                out_file.write(str(joined.encode('utf-8').decode('utf-8')))\n                out_file.write('\\n')\n\n\ndef timer(diff, processed):\n    \"\"\"Return the passed time.\"\"\"\n    # Changes seconds into minutes and seconds\n    minutes, seconds = divmod(diff, 60)\n    try:\n        # Finds average time taken by requests\n        time_per_request = diff / float(len(processed))\n    except ZeroDivisionError:\n        time_per_request = 0\n    return minutes, seconds, time_per_request\n\n\ndef entropy(string):\n    \"\"\"Calculate the entropy of a string.\"\"\"\n    entropy = 0\n    for number in range(256):\n        result = float(string.encode('utf-8').count(\n            chr(number))) / len(string.encode('utf-8'))\n        if result != 0:\n            entropy = entropy - result * math.log(result, 2)\n    return entropy\n\n\ndef xml_parser(response):\n    \"\"\"Extract links from .xml files.\"\"\"\n    # Regex for extracting URLs\n    return re.findall(r'<loc>(.*?)</loc>', response)\n\n\ndef verb(kind, string):\n    \"\"\"Enable verbose output.\"\"\"\n    if VERBOSE:\n        print('%s %s: %s' % (info, kind, string))\n\n\ndef extract_headers(headers):\n    \"\"\"This function extracts valid headers from interactive input.\"\"\"\n    sorted_headers = {}\n    matches = re.findall(r'(.*):\\s(.*)', headers)\n    for match in matches:\n        header = match[0]\n        value = match[1]\n        try:\n            if value[-1] == ',':\n                value = value[:-1]\n            sorted_headers[header] = value\n        except IndexError:\n            pass\n    return sorted_headers\n\n\ndef top_level(url, fix_protocol=True):\n    \"\"\"Extract the top level domain from an URL.\"\"\"\n    ext = tld.get_tld(url, fix_protocol=fix_protocol)\n    toplevel = '.'.join(urlparse(url).netloc.split('.')[-2:]).split(\n        ext)[0] + ext\n    return toplevel\n\n\ndef is_proxy_list(v, proxies):\n    if os.path.isfile(v):\n        with open(v, 'r') as _file:\n            for line in _file:\n                line = line.strip()\n                if re.match(r\"((http|socks5):\\/\\/.)?(\\d{1,3}\\.\\d{1,3}\\.\\d{1,3}\\.\\d{1,3}):(\\d{1,5})\", line) or \\\n                   re.match(r\"((http|socks5):\\/\\/.)?[-a-zA-Z0-9@:%._\\+~#=]{2,256}\\.[a-z]{2,6}:(\\d{1,5})\", line):\n                    proxies.append({\"http\": line,\n                                    \"https\": line})\n                else:\n                    print(\"%s ignored\" % line)\n        if proxies:\n            return True\n    return False\n\n\ndef proxy_type(v):\n    \"\"\" Match IP:PORT or DOMAIN:PORT in a losse manner \"\"\"\n    proxies = []\n    if re.match(r\"((http|socks5):\\/\\/.)?(\\d{1,3}\\.\\d{1,3}\\.\\d{1,3}\\.\\d{1,3}):(\\d{1,5})\", v):\n        proxies.append({\"http\": v,\n                        \"https\": v})\n        return proxies\n    elif re.match(r\"((http|socks5):\\/\\/.)?[-a-zA-Z0-9@:%._\\+~#=]{2,256}\\.[a-z]{2,6}:(\\d{1,5})\", v):\n        proxies.append({\"http\": v,\n                        \"https\": v})\n        return proxies\n    elif is_proxy_list(v, proxies):\n        return proxies\n    else:\n        raise argparse.ArgumentTypeError(\n            \"Proxy should follow IP:PORT or DOMAIN:PORT format\")\n\n\ndef luhn(purported):\n\n    # sum_of_digits (index * 2)\n    LUHN_ODD_LOOKUP = (0, 2, 4, 6, 8, 1, 3, 5, 7, 9)\n\n    if not isinstance(purported, str):\n        purported = str(purported)\n    try:\n        evens = sum(int(p) for p in purported[-1::-2])\n        odds = sum(LUHN_ODD_LOOKUP[int(p)] for p in purported[-2::-2])\n        return (evens + odds) % 10 == 0\n    except ValueError:  # Raised if an int conversion fails\n        return False\n\n\ndef is_good_proxy(pip):\n    try:\n        requests.get('http://example.com', proxies=pip, timeout=3)\n    except requests.exceptions.ConnectTimeout as e:\n        return False\n    except Exception as detail:\n        return False\n\n    return True\n\n"
  },
  {
    "path": "core/zap.py",
    "content": "import re\nimport requests\nimport random\n\nfrom core.utils import verb, xml_parser\nfrom core.colors import run, good\nfrom plugins.wayback import time_machine\n\n\ndef zap(input_url, archive, domain, host, internal, robots, proxies):\n    \"\"\"Extract links from robots.txt and sitemap.xml.\"\"\"\n    if archive:\n        print('%s Fetching URLs from archive.org' % run)\n        if False:\n            archived_urls = time_machine(domain, 'domain')\n        else:\n            archived_urls = time_machine(host, 'host')\n        print('%s Retrieved %i URLs from archive.org' % (\n            good, len(archived_urls) - 1))\n        for url in archived_urls:\n            verb('Internal page', url)\n            internal.add(url)\n    # Makes request to robots.txt\n    response = requests.get(input_url + '/robots.txt',\n                            proxies=random.choice(proxies)).text\n    # Making sure robots.txt isn't some fancy 404 page\n    if '<body' not in response:\n        # If you know it, you know it\n        matches = re.findall(r'Allow: (.*)|Disallow: (.*)', response)\n        if matches:\n            # Iterating over the matches, match is a tuple here\n            for match in matches:\n                # One item in match will always be empty so will combine both\n                # items\n                match = ''.join(match)\n                # If the URL doesn't use a wildcard\n                if '*' not in match:\n                    url = input_url + match\n                    # Add the URL to internal list for crawling\n                    internal.add(url)\n                    # Add the URL to robots list\n                    robots.add(url)\n            print('%s URLs retrieved from robots.txt: %s' % (good, len(robots)))\n    # Makes request to sitemap.xml\n    response = requests.get(input_url + '/sitemap.xml',\n                            proxies=random.choice(proxies)).text\n    # Making sure robots.txt isn't some fancy 404 page\n    if '<body' not in response:\n        matches = xml_parser(response)\n        if matches: # if there are any matches\n            print('%s URLs retrieved from sitemap.xml: %s' % (\n                good, len(matches)))\n            for match in matches:\n                verb('Internal page', match)\n                # Cleaning up the URL and adding it to the internal list for\n                # crawling\n                internal.add(match)\n"
  },
  {
    "path": "photon.py",
    "content": "#!/usr/bin/env python3\r\n# -*- coding: utf-8 -*-\r\n\"\"\"The Photon main part.\"\"\"\r\nfrom __future__ import print_function\r\n\r\nimport argparse\r\nimport os\r\nimport re\r\nimport requests\r\nimport sys\r\nimport time\r\nimport warnings\r\nimport random\r\n\r\nfrom core.colors import good, info, run, green, red, white, end, bad\r\n\r\n# Just a fancy ass banner\r\nprint('''%s      ____  __          __\r\n     / %s__%s \\/ /_  ____  / /_____  ____\r\n    / %s/_/%s / __ \\/ %s__%s \\/ __/ %s__%s \\/ __ \\\\\r\n   / ____/ / / / %s/_/%s / /_/ %s/_/%s / / / /\r\n  /_/   /_/ /_/\\____/\\__/\\____/_/ /_/ %sv1.3.2%s\\n''' %\r\n      (red, white, red, white, red, white, red, white, red, white, red, white,\r\n       red, white, end))\r\n\r\ntry:\r\n    from urllib.parse import urlparse  # For Python 3\r\nexcept ImportError:\r\n    print('%s Photon runs only on Python 3.2 and above.' % info)\r\n    quit()\r\n\r\nimport core.config\r\nfrom core.config import INTELS\r\nfrom core.flash import flash\r\nfrom core.mirror import mirror\r\nfrom core.prompt import prompt\r\nfrom core.requester import requester\r\nfrom core.updater import updater\r\nfrom core.utils import (luhn,\r\n                        proxy_type,\r\n                        is_good_proxy,\r\n                        top_level,\r\n                        extract_headers,\r\n                        verb, is_link,\r\n                        entropy, regxy,\r\n                        remove_regex,\r\n                        timer,\r\n                        writer)\r\nfrom core.regex import rintels, rendpoint, rhref, rscript, rentropy\r\n\r\nfrom core.zap import zap\r\n\r\n# Disable SSL related warnings\r\nwarnings.filterwarnings('ignore')\r\n\r\n# Processing command line arguments\r\nparser = argparse.ArgumentParser()\r\n# Options\r\nparser.add_argument('-u', '--url', help='root url', dest='root')\r\nparser.add_argument('-c', '--cookie', help='cookie', dest='cook')\r\nparser.add_argument('-r', '--regex', help='regex pattern', dest='regex')\r\nparser.add_argument('-e', '--export', help='export format', dest='export', choices=['csv', 'json'])\r\nparser.add_argument('-o', '--output', help='output directory', dest='output')\r\nparser.add_argument('-l', '--level', help='levels to crawl', dest='level',\r\n                    type=int)\r\nparser.add_argument('-t', '--threads', help='number of threads', dest='threads',\r\n                    type=int)\r\nparser.add_argument('-d', '--delay', help='delay between requests',\r\n                    dest='delay', type=float)\r\nparser.add_argument('-v', '--verbose', help='verbose output', dest='verbose',\r\n                    action='store_true')\r\nparser.add_argument('-s', '--seeds', help='additional seed URLs', dest='seeds',\r\n                    nargs=\"+\", default=[])\r\nparser.add_argument('--stdout', help='send variables to stdout', dest='std')\r\nparser.add_argument('--user-agent', help='custom user agent(s)',\r\n                    dest='user_agent')\r\nparser.add_argument('--exclude', help='exclude URLs matching this regex',\r\n                    dest='exclude')\r\nparser.add_argument('--timeout', help='http request timeout', dest='timeout',\r\n                    type=float)\r\nparser.add_argument('-p', '--proxy', help='Proxy server IP:PORT or DOMAIN:PORT', dest='proxies',\r\n                    type=proxy_type)\r\n\r\n# Switches\r\nparser.add_argument('--clone', help='clone the website locally', dest='clone',\r\n                    action='store_true')\r\nparser.add_argument('--headers', help='add headers', dest='headers',\r\n                    action='store_true')\r\nparser.add_argument('--dns', help='enumerate subdomains and DNS data',\r\n                    dest='dns', action='store_true')\r\nparser.add_argument('--keys', help='find secret keys', dest='api',\r\n                    action='store_true')\r\nparser.add_argument('--update', help='update photon', dest='update',\r\n                    action='store_true')\r\nparser.add_argument('--only-urls', help='only extract URLs', dest='only_urls',\r\n                    action='store_true')\r\nparser.add_argument('--wayback', help='fetch URLs from archive.org as seeds',\r\n                    dest='archive', action='store_true')\r\nargs = parser.parse_args()\r\n\r\n\r\n# If the user has supplied --update argument\r\nif args.update:\r\n    updater()\r\n    quit()\r\n\r\n# If the user has supplied a URL\r\nif args.root:\r\n    main_inp = args.root\r\n    if main_inp.endswith('/'):\r\n        # We will remove it as it can cause problems later in the code\r\n        main_inp = main_inp[:-1]\r\n# If the user hasn't supplied an URL\r\nelse:\r\n    print('\\n' + parser.format_help().lower())\r\n    quit()\r\n\r\nclone = args.clone\r\nheaders = args.headers  # prompt for headers\r\nverbose = args.verbose  # verbose output\r\ndelay = args.delay or 0  # Delay between requests\r\ntimeout = args.timeout or 6  # HTTP request timeout\r\ncook = args.cook or None  # Cookie\r\napi = bool(args.api)  # Extract high entropy strings i.e. API keys and stuff\r\n\r\nproxies = []\r\nif args.proxies:\r\n    print(\"%s Testing proxies, can take a while...\" % info)\r\n    for proxy in args.proxies:\r\n        if is_good_proxy(proxy):\r\n            proxies.append(proxy)\r\n        else:\r\n            print(\"%s Proxy %s doesn't seem to work or timedout\" %\r\n                  (bad, proxy['http']))\r\n    print(\"%s Done\" % info)\r\n    if not proxies:\r\n        print(\"%s no working proxies, quitting!\" % bad)\r\n        exit()\r\nelse:\r\n    proxies.append(None)\r\n\r\ncrawl_level = args.level or 2  # Crawling level\r\nthread_count = args.threads or 2  # Number of threads\r\nonly_urls = bool(args.only_urls)  # Only URLs mode is off by default\r\n\r\n# Variables we are gonna use later to store stuff\r\nkeys = set()  # High entropy strings, prolly secret keys\r\nfiles = set()  # The pdf, css, png, etc files.\r\nintel = set()  # The email addresses, website accounts, AWS buckets etc.\r\nrobots = set()  # The entries of robots.txt\r\ncustom = set()  # Strings extracted by custom regex pattern\r\nfailed = set()  # URLs that photon failed to crawl\r\nscripts = set()  # THe Javascript files\r\nexternal = set()  # URLs that don't belong to the target i.e. out-of-scope\r\n# URLs that have get params in them e.g. example.com/page.php?id=2\r\nfuzzable = set()\r\nendpoints = set()  # URLs found from javascript files\r\nprocessed = set(['dummy'])  # URLs that have been crawled\r\n# URLs that belong to the target i.e. in-scope\r\ninternal = set(args.seeds)\r\n\r\neverything = []\r\nbad_scripts = set()  # Unclean javascript file urls\r\nbad_intel = set() # needed for intel filtering\r\n\r\ncore.config.verbose = verbose\r\n\r\nif headers:\r\n    try:\r\n        prompt = prompt()\r\n    except FileNotFoundError as e:\r\n        print('Could not load headers prompt: {}'.format(e))\r\n        quit()\r\n    headers = extract_headers(prompt)\r\n\r\n# If the user hasn't supplied the root URL with http(s), we will handle it\r\nif main_inp.startswith('http'):\r\n    main_url = main_inp\r\nelse:\r\n    try:\r\n        requests.get('https://' + main_inp, proxies=random.choice(proxies))\r\n        main_url = 'https://' + main_inp\r\n    except:\r\n        main_url = 'http://' + main_inp\r\n\r\nschema = main_url.split('//')[0] # https: or http:?\r\n# Adding the root URL to internal for crawling\r\ninternal.add(main_url)\r\n# Extracts host out of the URL\r\nhost = urlparse(main_url).netloc\r\n\r\noutput_dir = args.output or host\r\n\r\ntry:\r\n    domain = top_level(main_url)\r\nexcept:\r\n    domain = host\r\n\r\nif args.user_agent:\r\n    user_agents = args.user_agent.split(',')\r\nelse:\r\n    with open(sys.path[0] + '/core/user-agents.txt', 'r') as uas:\r\n        user_agents = [agent.strip('\\n') for agent in uas]\r\n\r\n\r\nsupress_regex = False\r\n\r\ndef intel_extractor(url, response):\r\n    \"\"\"Extract intel from the response body.\"\"\"\r\n    for rintel in rintels:\r\n        res = re.sub(r'<(script).*?</\\1>(?s)', '', response)\r\n        res = re.sub(r'<[^<]+?>', '', res)\r\n        matches = rintel[0].findall(res)\r\n        if matches:\r\n            for match in matches:\r\n                verb('Intel', match)\r\n                bad_intel.add((match, rintel[1], url))\r\n\r\n\r\ndef js_extractor(response):\r\n    \"\"\"Extract js files from the response body\"\"\"\r\n    # Extract .js files\r\n    matches = rscript.findall(response)\r\n    for match in matches:\r\n        match = match[2].replace('\\'', '').replace('\"', '')\r\n        verb('JS file', match)\r\n        bad_scripts.add(match)\r\n\r\ndef remove_file(url):\r\n    if url.count('/') > 2:\r\n        replacable = re.search(r'/[^/]*?$', url).group()\r\n        if replacable != '/':\r\n            return url.replace(replacable, '')\r\n        else:\r\n            return url\r\n    else:\r\n        return url\r\n\r\ndef extractor(url):\r\n    \"\"\"Extract details from the response body.\"\"\"\r\n    response = requester(url, main_url, delay, cook, headers, timeout, host, proxies, user_agents, failed, processed)\r\n    if clone:\r\n        mirror(url, response)\r\n    matches = rhref.findall(response)\r\n    for link in matches:\r\n        # Remove everything after a \"#\" to deal with in-page anchors\r\n        link = link[1].replace('\\'', '').replace('\"', '').split('#')[0]\r\n        # Checks if the URLs should be crawled\r\n        if is_link(link, processed, files):\r\n            if link[:4] == 'http':\r\n                if link.startswith(main_url):\r\n                    verb('Internal page', link)\r\n                    internal.add(link)\r\n                else:\r\n                    verb('External page', link)\r\n                    external.add(link)\r\n            elif link[:2] == '//':\r\n                if link.split('/')[2].startswith(host):\r\n                    verb('Internal page', link)\r\n                    internal.add(schema + '://' + link)\r\n                else:\r\n                    verb('External page', link)\r\n                    external.add(link)\r\n            elif link[:1] == '/':\r\n                verb('Internal page', link)\r\n                internal.add(remove_file(url) + link)\r\n            else:\r\n                verb('Internal page', link)\r\n                usable_url = remove_file(url)\r\n                if usable_url.endswith('/'):\r\n                    internal.add(usable_url + link)\r\n                elif link.startswith('/'):\r\n                    internal.add(usable_url + link)\r\n                else:\r\n                    internal.add(usable_url + '/' + link)\r\n\r\n    if not only_urls:\r\n        intel_extractor(url, response)\r\n        js_extractor(response)\r\n    if args.regex and not supress_regex:\r\n        regxy(args.regex, response, supress_regex, custom)\r\n    if api:\r\n        matches = rentropy.findall(response)\r\n        for match in matches:\r\n            if entropy(match) >= 4:\r\n                verb('Key', match)\r\n                keys.add(url + ': ' + match)\r\n\r\n\r\ndef jscanner(url):\r\n    \"\"\"Extract endpoints from JavaScript code.\"\"\"\r\n    response = requester(url, main_url, delay, cook, headers, timeout, host, proxies, user_agents, failed, processed)\r\n    # Extract URLs/endpoints\r\n    matches = rendpoint.findall(response)\r\n    # Iterate over the matches, match is a tuple\r\n    for match in matches:\r\n        # Combining the items because one of them is always empty\r\n        match = match[0] + match[1]\r\n        # Making sure it's not some JavaScript code\r\n        if not re.search(r'[}{><\"\\']', match) and not match == '/':\r\n            verb('JS endpoint', match)\r\n            endpoints.add(match)\r\n\r\n\r\n# Records the time at which crawling started\r\nthen = time.time()\r\n\r\n# Step 1. Extract urls from robots.txt & sitemap.xml\r\nzap(main_url, args.archive, domain, host, internal, robots, proxies)\r\n\r\n# This is so the level 1 emails are parsed as well\r\ninternal = set(remove_regex(internal, args.exclude))\r\n\r\n# Step 2. Crawl recursively to the limit specified in \"crawl_level\"\r\nfor level in range(crawl_level):\r\n    # Links to crawl = (all links - already crawled links) - links not to crawl\r\n    links = remove_regex(internal - processed, args.exclude)\r\n    # If links to crawl are 0 i.e. all links have been crawled\r\n    if not links:\r\n        break\r\n    # if crawled links are somehow more than all links. Possible? ;/\r\n    elif len(internal) <= len(processed):\r\n        if len(internal) > 2 + len(args.seeds):\r\n            break\r\n    print('%s Level %i: %i URLs' % (run, level + 1, len(links)))\r\n    try:\r\n        flash(extractor, links, thread_count)\r\n    except KeyboardInterrupt:\r\n        print('')\r\n        break\r\n\r\nif not only_urls:\r\n    for match in bad_scripts:\r\n        if match.startswith(main_url):\r\n            scripts.add(match)\r\n        elif match.startswith('/') and not match.startswith('//'):\r\n            scripts.add(main_url + match)\r\n        elif not match.startswith('http') and not match.startswith('//'):\r\n            scripts.add(main_url + '/' + match)\r\n    # Step 3. Scan the JavaScript files for endpoints\r\n    print('%s Crawling %i JavaScript files' % (run, len(scripts)))\r\n    flash(jscanner, scripts, thread_count)\r\n\r\n    for url in internal:\r\n        if '=' in url:\r\n            fuzzable.add(url)\r\n\r\n    for match, intel_name, url in bad_intel:\r\n        if isinstance(match, tuple):\r\n            for x in match:  # Because \"match\" is a tuple\r\n                if x != '':  # If the value isn't empty\r\n                    if intel_name == \"CREDIT_CARD\":\r\n                        if not luhn(match):\r\n                            # garbage number\r\n                            continue\r\n                    intel.add(\"%s:%s\" % (intel_name, x))\r\n        else:\r\n            if intel_name == \"CREDIT_CARD\":\r\n                if not luhn(match):\r\n                    # garbage number\r\n                    continue\r\n            intel.add(\"%s:%s:%s\" % (url, intel_name, match))\r\n        for url in external:\r\n            try:\r\n                if top_level(url, fix_protocol=True) in INTELS:\r\n                    intel.add(url)\r\n            except:\r\n                pass\r\n\r\n# Records the time at which crawling stopped\r\nnow = time.time()\r\n# Finds total time taken\r\ndiff = (now - then)\r\nminutes, seconds, time_per_request = timer(diff, processed)\r\n\r\n# Step 4. Save the results\r\nif not os.path.exists(output_dir): # if the directory doesn't exist\r\n    os.mkdir(output_dir) # create a new directory\r\n\r\ndatasets = [files, intel, robots, custom, failed, internal, scripts,\r\n            external, fuzzable, endpoints, keys]\r\ndataset_names = ['files', 'intel', 'robots', 'custom', 'failed', 'internal',\r\n                 'scripts', 'external', 'fuzzable', 'endpoints', 'keys']\r\n\r\nwriter(datasets, dataset_names, output_dir)\r\n# Printing out results\r\nprint(('%s-%s' % (red, end)) * 50)\r\nfor dataset, dataset_name in zip(datasets, dataset_names):\r\n    if dataset:\r\n        print('%s %s: %s' % (good, dataset_name.capitalize(), len(dataset)))\r\nprint(('%s-%s' % (red, end)) * 50)\r\n\r\nprint('%s Total requests made: %i' % (info, len(processed)))\r\nprint('%s Total time taken: %i minutes %i seconds' % (info, minutes, seconds))\r\nprint('%s Requests per second: %i' % (info, int(len(processed) / diff)))\r\n\r\ndatasets = {\r\n    'files': list(files), 'intel': list(intel), 'robots': list(robots),\r\n    'custom': list(custom), 'failed': list(failed), 'internal': list(internal),\r\n    'scripts': list(scripts), 'external': list(external),\r\n    'fuzzable': list(fuzzable), 'endpoints': list(endpoints),\r\n    'keys': list(keys)\r\n}\r\n\r\nif args.dns:\r\n    print('%s Enumerating subdomains' % run)\r\n    from plugins.find_subdomains import find_subdomains\r\n    subdomains = find_subdomains(domain)\r\n    print('%s %i subdomains found' % (info, len(subdomains)))\r\n    writer([subdomains], ['subdomains'], output_dir)\r\n    datasets['subdomains'] = subdomains\r\n    from plugins.dnsdumpster import dnsdumpster\r\n    print('%s Generating DNS map' % run)\r\n    dnsdumpster(domain, output_dir)\r\n\r\nif args.export:\r\n    from plugins.exporter import exporter\r\n    # exporter(directory, format, datasets)\r\n    exporter(output_dir, args.export, datasets)\r\n\r\nprint('%s Results saved in %s%s%s directory' % (good, green, output_dir, end))\r\n\r\nif args.std:\r\n    for string in datasets[args.std]:\r\n        sys.stdout.write(string + '\\n')\r\n"
  },
  {
    "path": "plugins/__init__.py",
    "content": "\"\"\"Plugins for Photon.\"\"\"\n"
  },
  {
    "path": "plugins/dnsdumpster.py",
    "content": "\"\"\"Support for dnsdumpster.com.\"\"\"\nimport re\n\nimport requests\n\n\ndef dnsdumpster(domain, output_dir):\n    \"\"\"Query dnsdumpster.com.\"\"\"\n    response = requests.Session().get('https://dnsdumpster.com/').text\n    csrf_token = re.search(\n        r'name=\\\"csrfmiddlewaretoken\\\" value=\\\"(.*?)\\\"', response).group(1)\n\n    cookies = {'csrftoken': csrf_token}\n    headers = {'Referer': 'https://dnsdumpster.com/'}\n    data = {'csrfmiddlewaretoken': csrf_token, 'targetip': domain}\n    response = requests.Session().post(\n        'https://dnsdumpster.com/', cookies=cookies, data=data, headers=headers)\n\n    image = requests.get('https://dnsdumpster.com/static/map/%s.png' % domain)\n    if image.status_code == 200:\n        with open('%s/%s.png' % (output_dir, domain), 'wb') as f:\n            f.write(image.content)\n"
  },
  {
    "path": "plugins/exporter.py",
    "content": "\"\"\"Support for exporting the results.\"\"\"\nimport csv\nimport json\n\n\ndef exporter(directory, method, datasets):\n    \"\"\"Export the results.\"\"\"\n    if method.lower() == 'json':\n        # Convert json_dict to a JSON styled string\n        json_string = json.dumps(datasets, indent=4)\n        savefile = open('{}/exported.json'.format(directory), 'w+')\n        savefile.write(json_string)\n        savefile.close()\n\n    if method.lower() == 'csv':\n        with open('{}/exported.csv'.format(directory), 'w+') as csvfile:\n            csv_writer = csv.writer(\n                csvfile, delimiter=',', quoting=csv.QUOTE_MINIMAL)\n            for key, values in datasets.items():\n                if values is None:\n                    csv_writer.writerow([key])\n                else:\n                    csv_writer.writerow([key] + values)\n        csvfile.close()\n"
  },
  {
    "path": "plugins/find_subdomains.py",
    "content": "\"\"\"Support for findsubdomains.com.\"\"\"\nfrom re import findall\n\nfrom requests import get\n\n\ndef find_subdomains(domain):\n    \"\"\"Find subdomains according to the TLD.\"\"\"\n    result = set()\n    response = get('https://findsubdomains.com/subdomains-of/' + domain).text\n    matches = findall(r'(?s)<div class=\"domains js-domain-name\">(.*?)</div>', response)\n    for match in matches:\n        result.add(match.replace(' ', '').replace('\\n', ''))\n    return list(result)\n"
  },
  {
    "path": "plugins/wayback.py",
    "content": "\"\"\"Support for archive.org.\"\"\"\nimport datetime\nimport json\n\nfrom requests import get\n\n\ndef time_machine(host, mode):\n    \"\"\"Query archive.org.\"\"\"\n    now = datetime.datetime.now()\n    to = str(now.year) + str(now.day) + str(now.month)\n    if now.month > 6:\n    \tfro = str(now.year) + str(now.day) + str(now.month - 6)\n    else:\n    \tfro = str(now.year - 1) + str(now.day) + str(now.month + 6)\n    url = \"http://web.archive.org/cdx/search?url=%s&matchType=%s&collapse=urlkey&fl=original&filter=mimetype:text/html&filter=statuscode:200&output=json&from=%s&to=%s\" % (host, mode, fro, to)\n    response = get(url).text\n    parsed = json.loads(response)[1:]\n    urls = []\n    for item in parsed:\n        urls.append(item[0])\n    return urls\n"
  },
  {
    "path": "requirements.txt",
    "content": "requests\nrequests[socks]\nurllib3\ntld"
  }
]