[
  {
    "path": ".travis.yml",
    "content": "language: python\npython:\n  - \"2.6\"\n  - \"2.7\"\n  - \"3.2\"\n  - \"3.3\"\n  - \"3.4\"\n  - \"3.5\"\n  - \"3.5-dev\" # 3.5 development branch\n  - \"3.6\"\n  - \"3.6-dev\" # 3.6 development branch\n  - \"3.7-dev\" # 3.7 development branch\n  - \"nightly\" # development branches\n# command to install dependencies\ninstall: \"pip install -r requirements.txt\"\n# command to run tests\nscript: python setup.py install\n"
  },
  {
    "path": "CHANGELOG.txt",
    "content": "# *******************************************************************\n# *** BFAC: Backup File Artifacts Checker ***\n# * Description:\n#   An automated tool that checks for backup artifacts\n#   that may disclose the web-application's source code.\n# * Homepage:\n#   https://github.com/mazen160/bfac\n# * Author:\n#   Mazin Ahmed <Mazin AT MazinAhmed DOT net>\n# *******************************************************************\n\n\n### Changelog:-\n\n* v1.4:\n  Additions/Features:-\n    [+] Added --proxy-file and --user-agents-file options.\n    [+] Improved console output.\n    [+] Added pattern for CVE-2017-12616.\n\n  Fixed Bugs:-\n    [*] Fixed a bug in proxying requests - Thanks Justin Kennedy @jstnkndy.\n\n  Known Bugs/Issues:-\n    None\n\n\n* v1.3:\n  Additions/Features:-\n    [+] BFAC now supports multithrading.\n    [+] request-rate throttling support.\n    [+] Redesigned command-line user interface.\n    [+] Code refactor.\n    [+] Better support for using BFAC as a module.\n    [*] Removed --verbose and --api.\n    [+] Improved the detection algorithm.\n    [+] Added JSON and CSV reporting.\n\n  Fixed Bugs:-\n    None\n\n  Known Bugs/Issues:-\n    None\n\n\n* v1.2:\n  Additions/Features:-\n    [+] Complete code-rewrite of BFAC.\n    [+] BFAC now can works as module.\n    [+] Additional BFA patterns.\n\n  Fixed Bugs:-\n    [*] Improved url_handler() way of handling URLs.\n    [*] Fixed UI/UX issues.\n\n  Known Bugs/Issues:-\n    None\n\n\n* v1.1:\n  Additions/Features:-\n    [+] Official BFAC User-Agent - Thanks Christian Folini (@ChrFolini)\n    [+] Additional BFA patterns.\n    [+] Better way of parsing URLs - Thanks Omar Kurt (@omarkurt)\n    [+] --dvcs-test flag to only check for exposed DVCS repositories, (DVCS tests are done by default when using BFAC on level 4, now you can run it seperately).\n    [+] --api flag to return findings in JSON form.\n    [+] --timeout option to control the timeout.\n    [+] --proxy flag to issue requests via proxies when testing.\n    [+] --proxy-cred to be used with --proxy flag for handling proxy credintials.\n    [+] --user-agent, -ua to specify your own user-agent, (--random-agent is available since v1.0).\n    [+] --cookie flag to specify arbitray HTTP Cookie header.\n    [+] --host flag to specify arbitray HTTP Host header.\n    [+] --headers flag to add arbitrary HTTP headers in requests.\n    [+] --invalid-content-length flag:\n        When verifying the existence of files, BFAC by default send an initial request to determine the content-length\n        and to build an idea about the invalid (not found) pages. This flag can be used to disable the automatic process\n        of sending an initial request and manually specifying a content-length of an invalid page. It's an optional flag\n        that can be used when facing false-positives, tests shows it rarely need this option, but it would be good to have\n        it since BFAC aims to be an \"All-in-One\" tool for testing backup-file artifacts.\n    [+] --content-length-range flag:\n        This option can be used to optmise the range of the invalid pages based on the content-length.\n        It's an optional flag, and the reason this flag is added is as same as --invalid-content-length flag.\n\t\t[+] New --help design.\n\n  Fixed Bugs:-\n    [*] Fixed a bug in url_handler().\n    [*] Better support for Windows machines.\n    [*] Fixed a bug that can have same check in a test done more than one time. Now it only does the same check  once.\n\n  Known Bugs/Issues:-\n    None\n\n\n* v1.0: Initial release.\n"
  },
  {
    "path": "CONTRIBUTORS.txt",
    "content": "# *******************************************************************\n# *** BFAC: Backup File Artifacts Checker ***\n# * Description:\n#   An automated tool that checks for backup artifacts\n#   that may disclose the web-application's source code.\n# * Homepage:\n#   https://github.com/mazen160/bfac\n# * Author:\n#   Mazin Ahmed <Mazin AT MazinAhmed DOT net>\n# *******************************************************************\n\n\nContributors (alphabetical-order):-\n\n* Christian Folini (@ChrFolini)\n* Ed (@EdOverflow)\n* James Kettle (@albinowax)\n* Justin Kennedy (@jstnkndy)\n* Liam Somerville (@leesoh)\n* Omar Kurt (@omarkurt)\n* Zeecka (@zeecka_)\n\n\nThank you for making BFAC a better project for everyone!\n"
  },
  {
    "path": "Dockerfile",
    "content": "FROM python:alpine\nRUN apk add git\nRUN git clone https://github.com/mazen160/bfac.git\nWORKDIR bfac\nRUN python setup.py install\nENTRYPOINT [\"bfac\"]\n"
  },
  {
    "path": "LICENSE.txt",
    "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    <program>  Copyright (C) <year>  <name of author>\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>.\n"
  },
  {
    "path": "README.md",
    "content": "BFAC\n----\n*Advanced Backup-File Artifacts Testing for Web-Applications*\n\n![BFAC](https://raw.githubusercontent.com/mazen160/public/master/static/images/BFAC-banner.png)\n\nBFAC (Backup File Artifacts Checker) is an automated tool that checks for backup artifacts that may disclose the web-application's source code. The artifacts can also lead to leakage of sensitive information, such as passwords, directory structure, etc.\n\n**The goal of BFAC is to be an *all-in-one tool* for backup-file artifacts black-box testing.**\n\n## Features\n* Multithreaded scanning.\n* Includes request rate throttling.\n* HTTP proxy support.\n* Uses multiple algorithms for automatically detecting valid and invalid pages.\n* HTTP proxy support\n* User agent randomization.\n* Batch processing.\n* Works both as a command-line tool and Python module.\n* Support for Windows, MacOS, and Linux operating systems.\n* Reporting: simple, verbose, CSV, JSON.\n\n## Usage\n\n| Description                                                | Command                                                                 |\n|------------------------------------------------------------|-------------------------------------------------------------------------|\n| Help                                                       | `bfac --help`                                                           |\n| Check a single URL.                                        | `bfac --url http://example.com/test.php`                                |\n| Check a list of URLs.                                      | `bfac --list testing_list.txt`                                          |\n| Single URL with a different level (level 2 for example).   | `bfac --url http://example.com/test.php --level 2`                      |\n| Single URL and show the results only.                      | `bfac --no-text --url http://example.com/test.php`                      |\n| Limit the test to exposed DVCS tests.                      | `bfac --dvcs-test --url http://example.com/`                            |\n| Verify existence of files using Content-Length checks only.| `bfac --detection-technique content_length http://example.com/test.php` |\n| Verify existence of files using Status-Code checks only.   | `bfac --detection-technique status_code http://example.com/test.php`    |\n| Exclude results with specific status-codes.                | `bfac --exclude-status-codes 301,999 http://example.com/test.php`       |\n\n\n## Using BFAC as a module\n```python\nimport bfac\n\n\ntesting_level = 5\n\n# Returns a list of BFA patterns for http://example.com/test.php\nbfa_urls = bfac.generate_bfa_urls(\n    'http://example.com/test.php', testing_level=testing_level)\n\n# Performs BFA testing using BFAC, and returns a list of findings, if any.\n# If nothing is identified, it returns an empty list.\nbfa_testing_result = bfac.test_url(\n    'http://example.com/test.php', testing_level=testing_level)\n```\n\n\n## Requirements\n* Python2 or Python3\n* requests\n* colorama\n\n\n## Installation [Optional]\n`sudo python setup.py install`\n\n\n## Compatibility\nThe project currently supports all platforms that run Python.\nThe project is compatible with both Python 2 and Python 3.\n\n\n## Frequently Asked Questions\n**Q:** How to use BFAC with all levels?\n\n**A:**\nBFAC runs with all levels by default. if you would like to decrease the used testing level, you can do it by setting the `--level` flag to a lower value.\n\n\n**Q:** How do BFAC determines if the file actually exists on the web-server or not?\n\n**A:**\nBFAC approach regarding detection differs from regular security tools.\n\nRegular security tools determinate if a file exists on a server by checking the HTTP status code. Since there are system administrators that might spoof HTTP status codes for HTTP requests to fool security tools and bots, BFAC implemented an additional method.\n\nIt checks for the general response of an invalid or non-available web resource. Then, it sends requests and compare the response size of the request with the initial base.\n\n* `--detection-technique all` uses both methods for HTTP Status Code checks, and the HTTP Content-Length.\n* `--detection-technique status_code`: uses HTTP status code checks only.\n* `--detection-technique content_length`: uses HTTP Content-Length checks only.\n\n\n## Community Contribution\nContribution from the community to the BFAC project is very welcome. If you find a bug, have an idea for a feature, ideas to reconstruct the code to work better, or anything else, feel free to submit an issue or a pull request.\n\n\n### Using the issue tracker\n\nThe issue tracker is the preferred channel for bug reports and features requests.\n\n[![GitHub issues](https://img.shields.io/github/issues/mazen160/bfac.svg?style=flat-square)](https://github.com/mazen160/bfac/issues)\n\n\n## Legal Disclaimer\nThis project is made for educational and ethical testing purposes only. Usage of BFAC for attacking targets without prior mutual consent is illegal. It is the end user's responsibility to obey all applicable local, state and federal laws. Developers assume no liability and are not responsible for any misuse or damage caused by this program.\n\n\n## License\nThe project is currently licensed under GNU GPLv3.0 License.\n\n[![GitHub license](https://img.shields.io/badge/license-GPL-blue.svg?style=flat-square)](https://raw.githubusercontent.com/mazen160/bfac/master/LICENSE.txt)\n\n\n## Author\n*Mazin Ahmed*\n* Website: [https://mazinahmed.net](https://mazinahmed.net)\n* Email: *mazin AT mazinahmed DOT net*\n* Twitter: [https://twitter.com/mazen160](https://twitter.com/mazen160)\n* Linkedin: [http://linkedin.com/in/infosecmazinahmed](http://linkedin.com/in/infosecmazinahmed)\n"
  },
  {
    "path": "bfac",
    "content": "#!/usr/bin/env python3\n# coding=utf-8\n# *******************************************************************\n# *** BFAC: Backup File Artifacts Checker ***\n# * Description:\n#   An automated tool that checks for backup artifacts\n#   that may disclose the web-application's source code.\n# * Version:\n#   v1.4\n# * Homepage:\n#   https://github.com/mazen160/bfac\n# * Author:\n#   Mazin Ahmed <Mazin AT MazinAhmed DOT net>\n# *******************************************************************\n\n# Modules\nimport sys\nimport os\nimport random\nimport time\nimport csv\nimport json\nimport argparse\nimport platform\nimport threading\nimport webbrowser\nimport colorama\ntry:\n    import Queue as queue\nexcept ImportError:\n    import queue\ntry:\n    from urllib import parse as urlparse\nexcept ImportError:\n    import urlparse\ntry:\n    import requests\nexcept ImportError:\n    if (__name__ == '__main__'):\n        print('[!] Error: requests module does not seem to be installed.')\n        print('Use the following command to install requests module.')\n        if (sys.version_info[0] == 2):\n            print('$ pip install requests')\n        else:\n            print('$ pip3 install requests')\n        print('\\nExiting...')\n        exit(1)\n\n# Disable SSL warnings\ntry:\n    import requests.packages.urllib3\n    requests.packages.urllib3.disable_warnings()\nexcept Exception:\n    pass\n\n\ndef version():\n    \"\"\"\n    Returns current version.\n    \"\"\"\n\n    version = \"1.4\"\n    return(version)\n\n\nclass symbols:\n    \"\"\"\n    Standard symbols list\n    \"\"\"\n\n    error = colorama.Fore.RED + '[!]' + colorama.Fore.RESET\n    success = colorama.Fore.GREEN + '[$]' + colorama.Fore.RESET\n    info = colorama.Fore.YELLOW + '[i]' + colorama.Fore.RESET\n\n\ndef logo(enable_colored_logo=True):\n    \"\"\"\n    Returns logo.\n    \"\"\"\n\n    if enable_colored_logo is False:\n        \"\"\"\n        Uncolored Logo.\n        \"\"\"\n\n        logo = 70 * \"-\" + \"\"\"\"\n\\t\\t _____ _____ _____ _____\n\\t\\t| __  |   __|  _  |     |\n\\t\\t| __ -|   __|     |   --|\n\\t\\t|_____|__|  |__|__|_____|\n\\t\\t\n\\t   -:::Backup File Artifacts Checker:::-\n\\t\\t     Version: \"\"\" + str(version()) + \"\"\"\n  Advanced Backup-File Artifacts Testing for Web-Applications\nAuthor: Mazin Ahmed | <mazin AT mazinahmed DOT net> | @mazen160\\\n\\n\"\"\" + 70 * \"-\"\n\n    if enable_colored_logo is True:\n        \"\"\"\n        Colored Logo.\n        \"\"\"\n\n        logo = 70 * \"-\" + colorama.Fore.CYAN + \"\"\"\n\\t\\t _____ _____ _____ _____\n\\t\\t| __  |   __|  _  |     |\n\\t\\t| __ -|   __|     |   --|\n\\t\\t|_____|__|  |__|__|_____|\n\\t\\t\n\\t   -:::Backup File Artifacts Checker:::-\n\\t\\t     Version: \"\"\" + str(version()) + \"\"\"\n  Advanced Backup-File Artifacts Testing for Web-Applications\nAuthor: Mazin Ahmed | <mazin AT mazinahmed DOT net> | @mazen160\\\n\\n\"\"\"\\\n+ colorama.Style.RESET_ALL + 70 * \"-\"\n\n    return(logo)\n\n\ndef instructions():\n    \"\"\"\n    Returns command-line instructions for using BFAC.\n    \"\"\"\n\n    instructions = \"\"\"\n      Arguments:-\n\n  * Target Options\n-u, --url URL               Check a single URL.\n-L, --list LIST             Check a list of URLs.\n--stdin                     Check URLs from STDIN input.\n\n  * Testing Options\n-level, --level LEVEL       Set testing level [1-5] (default: 5).\n--dvcs-test                 Perform DVCS testing only, which is also\\\n available by default on Level 5.\n--threads THREADS           Thread workers to use (default 10).\n--request-rate-throttling REQUESTS_PER_SECOND\n                            Request rate throttling per second\\\n (default: 30)\n\n\n  * Artifacts Detection Options\n--invalid-content-length INVALID_CONTENT_LENGTH\n                            Manually specify the invalid\\\n Content-Length, instead of performing this check automatically.\n--invalid-content-length-offset OFFSET\n                            Manually specify the Content-Length\\\n offset for invalid pages (default: 50).\n--technique, --detection-technique TECHNIQUE\n                           Technique to verify the availability\\\n of the file. (options: status_code, content_length, all)\\\n  (default: all)\n-xsc, --exclude-status-codes EXCLUDE_STATUS_CODES\n                            Specify status codes to exclude,\\\n separated by commas.\n\n  * Requests-Related Options\n-ua, --user-agent USER_AGENT\n                            HTTP User-Agent header value.\n-ra, --random-agent         Use random User-Agents.\n--user-agents-file          Use a User-Agents file.\n--cookie COOKIE             HTTP Cookie header value.\n--host HOST                 HTTP Host header value.\n--headers HEADERS           Extra headers\\\n (e.g. \"Accept-Language: fr\\\\nETag: 123\")\n--proxy PROXY               Use a proxy on testing.\n--proxy-cred PROXY_CRED     Proxy authentication credentials\\\n (name:password).\n--proxy-file PROXY_FILE     Use a proxy list file.\n--timeout TIMEOUT           HTTP Request timeout by seconds.\\\n (default: 5)\n\n  * Output-Related Options\n-o, --output OUTPUT         Save identified URLs into a file.\n--verbose-output OUTPUT     Save identified URLs, with \\\nstatus-codes and content-length into a file.\n--json-output OUTPUT        Save findings in JSON file.\n--csv-output OUTPUT         Save findings in CSV file.\n\n  * Other Options\n-h, --help                  Show this help message and exit.\n--no-text                   Print and write a clean output\\\n with results only.\n--debug                     Enable debugging.\n--issue                     Report an issue via GitHub.\n-V, --version               Show current version and exit.\n\"\"\"\n    return(instructions)\n\n\ndef exception_handler(message,\n                      exception,\n                      enable_debug=True,\n                      notext=False):\n    \"\"\"\n    Handles exceptions.\n    \"\"\"\n\n    if enable_debug is not True:\n        return(2)\n    if ((notext is True) or (__name__ != '__main__')):\n        return(1)\n        # showing exception that  --debug is not global used\n        # or when used as a module or\n        # --no-text is used.\n    exception = str(exception)\n    message = str(message)\n    print(\"%sError: %s :: %s%s\" % (colorama.Fore.RED,\n                                   message,\n                                   exception,\n                                   colorama.Style.RESET_ALL))\n\n\nclass RequestsHandler:\n    \"\"\"\n    Responsible for handling URLs and performing requests.\n    \"\"\"\n\n    def __init__(self):\n        self.timeout = 5  # Default timeout.\n\n    def proxy_handler(self, link, proxy=None,\n                      proxy_cred=None, proxy_list=None):\n        if proxy_list is not None:\n            chosen_proxy = random.choice(proxy_list)\n        elif proxy is not None:\n            chosen_proxy = proxy\n\n        proxy_scheme_original = chosen_proxy.split(':')[0].lower()\n        proxy_scheme = 'http'\n        if proxy_scheme_original == \"socks\":\n            chosen_proxy = chosen_proxy.replace(\"socks://\", \"socks5://\")\n\n        if link.lower().split(\"://\")[0] == 'https':\n            proxy_scheme = 'https'\n\n        proxy_url = chosen_proxy\n        if (proxy_cred is not None):\n            username = str(str(proxy_cred).split(':')[0])\n            password = str(str(proxy_cred).split(':')[1])\n            replace_original_start_with = (str(proxy_scheme_original) +\n                                           '://' + str(username) +\n                                           ':' +\n                                           str(password) +\n                                           str('@'))\n            proxy_url = chosen_proxy.replace(\n                str(proxy_scheme_original) + '://',\n                replace_original_start_with)\n\n        proxy_dict = {proxy_scheme: proxy_url}\n        return(proxy_dict)\n\n    def ua_handler(self,\n                   custom_user_agent_list=None,\n                   use_random_agent=False):\n        if (use_random_agent is False) and (custom_user_agent_list is None):\n            # BFAC DEFAULT UA\n            chosen_agent = 'BFAC ' + str(version()) + \\\n                ' (https://github.com/mazen160/bfac)'\n\n        if (use_random_agent is True) or (custom_user_agent_list is not None):\n            # List of random User-Agents.\n            agents = [\n                \"Mozilla/5.0 (Windows NT 6.1; WOW64; rv:51.0) \" +\n                \"Gecko/20100101 Firefox/51.0\",\n                \"Mozilla/5.0 (Windows NT 10.0; WOW64; rv:51.0)\" +\n                \" Gecko/20100101 Firefox/51.0\",\n                \"Mozilla/5.0 (Windows NT 10.0; Win64; x64) \" +\n                \"AppleWebKit/537.36 (KHTML, like Gecko) \" +\n                \"Chrome/46.0.2486.0 Safari/537.36 Edge/13.10586\",\n                \"Mozilla/5.0 (Windows NT 10.0; Win64; x64) \" +\n                \"AppleWebKit/537.36 (KHTML, like Gecko) \" +\n                \"Chrome/56.0.2924.87 Safari/537.36\",\n                \"Mozilla/5.0 (Windows NT 6.1; WOW64; \" +\n                \"Trident/7.0; rv:11.0) like Gecko\",\n                \"Mozilla/5.0 (Macintosh; Intel Mac OS \" +\n                \"X 10_12_2) AppleWebKit/602.3.12 (KHTML, \" +\n                \"like Gecko) Version/10.0.2 Safari/602.3.12\",\n                \"Mozilla/5.0 (X11; Ubuntu; Linux x86_64; \" +\n                \"rv:51.0) Gecko/20100101 Firefox/51.0\",\n                \"Mozilla/5.0 (iPhone; CPU iPhone OS 10_2_1 \" +\n                \"like Mac OS X) AppleWebKit/602.4.6 (KHTML, \" +\n                \"like Gecko) Version/10.0 Mobile/14D27\" +\n                \" Safari/602.1\",\n                \"Mozilla/5.0 (Linux; Android 6.0.1; \" +\n                \"Nexus 6P Build/MTC19X) AppleWebKit/537.36 \" +\n                \"(KHTML, like Gecko) Chrome/56.0.2924.87 \" +\n                \"Mobile Safari/537.36\",\n                \"Mozilla/5.0 (Linux; Android 4.4.4; Nexus 5 \" +\n                \"Build/KTU84P) AppleWebKit/537.36 (KHTML, \" +\n                \"like Gecko) Chrome/56.0.2924.87\" +\n                \"Mobile Safari/537.36\",\n                \"Mozilla/5.0 (compatible; Googlebot/2.1; \" +\n                \"+http://www.google.com/bot.html)\"\n            ]\n            if custom_user_agent_list is not None:\n                agents = custom_user_agent_list\n\n            chosen_agent = random.choice(agents)\n        return(chosen_agent)\n\n    def requester(self, link, proxy=None, proxy_cred=None, proxy_list=None,\n                  custom_user_agent=None, cookie=None,\n                  host_header=None, http_headers=None,\n                  random_user_agent=False, custom_user_agent_list=None,\n                  timeout=None, notext=False, enable_debug=False):\n\n        if timeout is None:\n            timeout = self.timeout  # Use default timeout.\n\n        try:\n            if custom_user_agent is not None:\n                user_agent = custom_user_agent\n            else:\n                if ((random_user_agent is True) or\n                   (custom_user_agent_list is not None)):\n                    user_agent = self.ua_handler(\n                        use_random_agent=random_user_agent,\n                        custom_user_agent_list=custom_user_agent_list)\n                else:\n                    # Use BFAC default UA.\n                    user_agent = self.ua_handler(use_random_agent=False)\n\n            headers = {'User-Agent': user_agent, 'Accept': '*/*'}\n\n            if cookie is not None:\n                cookie_dict = {'Cookie': str(cookie)}\n                headers.update(cookie_dict)\n\n            if host_header is not None:\n                host_dict = {'Host': str(host_header)}\n                headers.update(host_dict)\n\n            if http_headers is not None:\n                for _ in http_headers:\n                    headers.update(_)\n\n            if (proxy is not None) or (proxy_list is not None):\n                if proxy:\n                    proxy_dict = self.proxy_handler(link,\n                                                    proxy=proxy,\n                                                    proxy_cred=proxy_cred)\n                if proxy_list:\n                    proxy_dict = self.proxy_handler(link,\n                                                    proxy_cred=proxy_cred,\n                                                    proxy_list=proxy_list)\n                # Establishing request with proxy.\n                req = requests.get(link,\n                                   headers=headers,\n                                   verify=False,\n                                   allow_redirects=False,\n                                   timeout=int(timeout),\n                                   proxies=proxy_dict)\n\n            if proxy is None:\n                # Establishing request without proxy.\n                req = requests.get(link,\n                                   headers=headers,\n                                   verify=False,\n                                   allow_redirects=False,\n                                   timeout=int(timeout))\n\n            request_response_code = req.status_code\n            request_response_content_length = len(req.content)\n            return(request_response_code,\n                   request_response_content_length)\n\n        except requests.exceptions.SSLError as e:\n            exception_handler('SSL Error at ' + str(link),\n                              str(e),\n                              notext=notext,\n                              enable_debug=enable_debug)\n            return(None, None)\n        except requests.exceptions.ConnectionError as e:\n            exception_handler('Connection Error at ' + str(link),\n                              str(e),\n                              notext=notext,\n                              enable_debug=enable_debug)\n            return(None, None)\n        except requests.exceptions.MissingSchema as e:\n            exception_handler('Error: Invalid URL' +\n                              ' - Missing Schema at ' + str(link),\n                              str(e),\n                              notext=notext,\n                              enable_debug=enable_debug)\n            return(None, None)\n        except requests.exceptions.InvalidSchema as e:\n            exception_handler('Error: Invalid URL' +\n                              ' - Invalid Schema at ' + str(link),\n                              str(e),\n                              notext=notext,\n                              enable_debug=enable_debug)\n            return(None, None)\n        except requests.exceptions.InvalidURL as e:\n            exception_handler('Error: Invalid URL at ' + str(link),\n                              str(e),\n                              notext=notext,\n                              enable_debug=enable_debug)\n            return(None, None)\n        except requests.exceptions.ReadTimeout as e:\n            exception_handler('Error: Connection Timeout at ' + str(link),\n                              str(e),\n                              notext=notext,\n                              enable_debug=enable_debug)\n            return(None, None)\n\n    def initial_request(self,\n                        link,\n                        force_initial_content_length=None,\n                        forced_initial_content_length=None,\n                        proxy=None,\n                        proxy_cred=None,\n                        proxy_list=None,\n                        custom_user_agent=None,\n                        custom_user_agent_list=None,\n                        cookie=None,\n                        host_header=None,\n                        http_headers=None,\n                        random_user_agent=False,\n                        timeout=None,\n                        notext=False,\n                        enable_debug=False):\n        \"\"\"\n        Performs initial request and gives a baseline, based on it,\n        the detection for content-length will be done.\n        if force_initial_content_length is set,\n        it will force their values as a result.\n\n        # Returns (None, None) if their is an error.\n        \"\"\"\n\n        if ((force_initial_content_length is True) and\n                (forced_initial_content_length is not None)):\n\n            expected_status_code = 200\n            return(expected_status_code, forced_initial_content_length)\n\n        # Obtain site and file_dir via url_handler()\n        site = url_handler(link)[\"site\"]\n        file_dir = url_handler(link)[\"file_dir\"]\n\n        random_ascii_charset = 'abcdefghijklmnopqrstuvwxyz0123456789'\n        random_value = \\\n            ''.join(random.choice(random_ascii_charset)\n                    for _ in range(5))\n        random_value_ext = \\\n            ''.join(random.choice(random_ascii_charset)\n                    for _ in range(3))\n\n        link = site + file_dir + random_value + '.' + random_value_ext\n\n        # Using Requester API\n        resp = self.requester(\n            link,\n            proxy=proxy,\n            proxy_cred=proxy_cred,\n            proxy_list=proxy_list,\n            custom_user_agent=custom_user_agent,\n            cookie=cookie,\n            host_header=host_header,\n            http_headers=http_headers,\n            random_user_agent=random_user_agent,\n            custom_user_agent_list=custom_user_agent_list,\n            timeout=timeout,\n            notext=notext,\n            enable_debug=enable_debug)\n\n        initial_status_code = resp[0]\n        initial_content_length = resp[1]\n\n        return(initial_status_code, initial_content_length)\n\n\ndef url_clean(url):\n    \"\"\"\n    Cleans-up a URL.\n    \"\"\"\n\n    url = url.split('?')[0]\n    url = url.replace('#', '%23')\n    url = url.replace(' ', '%20')\n    return(url)\n\n\ndef url_handler(url):\n    \"\"\"\n    Parses a URL, and returns output of URL structure.\n    \"\"\"\n\n    # Assuming URL is: http://example.com/uploads/test.php\n\n    # Cleaning url\n    url = url_clean(url)\n\n    # Scheme: http\n    default_protocol = 'http'\n    if ('://' not in url):\n        url = str(default_protocol) + str('://') + str(url)\n    scheme = urlparse.urlparse(url).scheme\n\n    # Domain: example.com\n    domain = urlparse.urlparse(url).netloc\n\n    # Site: http://example.com\n    site = scheme + '://' + domain\n\n    # FilePath: /uploads/test.php\n    file_path = urlparse.urlparse(url).path\n    if (file_path == ''):\n        file_path = '/'\n\n    # Filename: test.php\n    try:\n        filename = url.split('/')[-1]\n    except IndexError:\n        filename = ''\n\n    # File Dir: /uploads/\n    file_dir = file_path.rstrip(filename)\n    if (file_dir == ''):\n        file_dir = '/'\n\n    # FullPath: http://example.com/uploads/\n    full_path = site + file_dir\n\n    # File Extension: php\n    try:\n        filename_ext = filename.split('.')\n        filename_ext.pop(0)\n        filename_ext = '.'.join(filename_ext)\n    except IndexError:\n        filename_ext = ''\n\n    # File without Extension: test\n    try:\n        filename_without_ext = filename.split('.')[0]\n    except IndexError:\n        filename_without_ext = ''\n\n    output = {\"scheme\": scheme, \"domain\": domain,\n              \"site\": site, \"file_path\": file_path,\n              \"filename\": filename, \"file_dir\": file_dir,\n              \"full_path\": full_path, \"filename_ext\": filename_ext,\n              \"filename_without_ext\": filename_without_ext}\n    return(output)\n\n\ndef generate_bfa_urls(url,\n                      testing_level=5,\n                      dvcs_test=False):\n    \"\"\"\n    Generates BFA testing URLs.\n    Returns a list of BFA testing URLs of given URL.\n    \"\"\"\n\n    url_parsed = url_handler(url)\n\n    (scheme, domain, site, file_path, filename,\n     file_dir, full_path, filename_ext,\n     filename_without_ext) = (url_parsed[\"scheme\"],\n                              url_parsed[\"domain\"],\n                              url_parsed[\"site\"],\n                              url_parsed[\"file_path\"],\n                              url_parsed[\"filename\"],\n                              url_parsed[\"file_dir\"],\n                              url_parsed[\"full_path\"],\n                              url_parsed[\"filename_ext\"],\n                              url_parsed[\"filename_without_ext\"])\n\n    # LEVEL 1\n    backup_testing_level1 = [\n        site + file_path + '~',\n        site + file_path + '%23',\n        site + file_path + '.save',\n        site + file_path + '.swp',\n        site + file_path + '.swo',\n        full_path + '%23' + filename + '%23',\n        site + file_path + '.bak'\n    ]\n\n    # LEVEL 2\n    backup_testing_level2 = [\n        site + file_path + '1',\n        site + file_path + 'bak',\n        site + file_path + 'inc',\n        site + file_path + 'old',\n        site + file_path + '_',\n        site + file_path + '~~',\n        site + file_path + '_backup',\n        site + file_path + '_bak',\n        site + file_path + '-bak',\n        site + file_path + '.bk',\n        site + file_path + '.bkp',\n        full_path + filename + '.bac',\n        site + file_path + '.old',\n        site + file_path + '_old',\n        site + file_path + '.copy',\n        site + file_path + '.original',\n        site + file_path + '.orig',\n        site + file_path + '.org',\n        site + file_path + '.txt',\n        site + file_path + '.default',\n        full_path + filename + '.tpl',\n        full_path + filename + '.tmp',\n        full_path + filename + '.temp',\n        full_path + '.' + filename + \".swp\",\n        full_path + '.' + filename + \".swo\",\n        full_path + '_' + filename + '.swp',\n        full_path + '_' + filename + '.swo',\n        full_path + filename + '.sav',\n        full_path + filename + '.conf',\n        full_path + filename_without_ext +\n        '%20%28copy%29.' + filename_ext,\n        full_path + 'Copy%20of%20' + filename,\n        full_path + 'copy%20of%20' + filename,\n        full_path + 'Copy_' + filename,\n        full_path + 'Copy%20' + filename,\n        full_path + 'Copy_of_' + filename,\n        full_path + 'Copy_(1)_of_' + filename,\n        full_path + 'Copy_(2)_of_' + filename,\n        full_path + filename_without_ext +\n        '%20-%20Copy.' + filename_ext,\n        full_path + filename_without_ext + '%20copy.' + filename_ext\n    ]\n\n    # LEVEL 3\n    backup_testing_level3 = [\n        full_path + filename_without_ext + '.txt',\n        full_path + filename_without_ext + '.backup',\n        full_path + filename_without_ext + '.bak',\n        full_path + filename_without_ext + '.bak1',\n        full_path + filename_without_ext + '.bakup',\n        full_path + filename_without_ext + '.bakup1',\n        full_path + filename_without_ext + '.bkp',\n        full_path + filename_without_ext + '.save',\n        full_path + filename_without_ext + '.old',\n        full_path + filename_without_ext + '.orig',\n        full_path + filename_without_ext + '.original',\n        full_path + filename_without_ext + '.sql',\n        full_path + filename_without_ext + '.war',\n        full_path + filename_without_ext + '.wim',\n        full_path + filename_without_ext + '.xz',\n        site + file_path + '%00',\n        site + file_path + '%01',\n        full_path + '~' + filename,\n        full_path + filename_without_ext + '.tpl',\n        full_path + filename_without_ext + '.tmp',\n        full_path + filename_without_ext + '.temp',\n        full_path + filename + '.saved',\n        full_path + filename + '.back',\n        full_path + filename + '.backup',\n        full_path + filename + '.bck',\n        full_path + filename + '.bakup',\n        full_path + filename_without_ext + '.saved',\n        full_path + filename_without_ext + '.bac',\n        full_path + filename_without_ext + '.back',\n        full_path + filename_without_ext + '.bck',\n        full_path + filename_without_ext + '.bakup',\n        full_path + '_' + filename,\n        full_path + '%20' + filename,\n        full_path + filename + '.nsx',\n        full_path + filename + '.cs',\n        full_path + filename + '.csproj',\n        full_path + filename + '.vb',\n        full_path + filename + '.0',\n        full_path + filename + '.1',\n        full_path + filename + '.2',\n        full_path + filename + '.7z',\n        full_path + filename + '.ar',\n        full_path + filename + '.arc',\n        full_path + filename + '.bz2',\n        full_path + filename + '.cbz',\n        full_path + filename + '.ear',\n        full_path + filename + '.exe',\n        full_path + filename + '.gz',\n        full_path + filename + '.inc',\n        full_path + filename + '.jar',\n        full_path + filename + '.lst',\n        full_path + filename + '.lzma',\n        full_path + filename + '.war',\n        full_path + filename + '.wim',\n        full_path + filename + '.xz',\n        full_path + '.~lock.' + filename + '%23',\n        full_path + '.~' + filename,\n        full_path + '~%24' + filename,\n        full_path + filename_without_ext + '.1',\n        full_path + filename_without_ext + '.7z',\n        full_path + filename_without_ext + '.ar',\n        full_path + filename_without_ext + '.bz2',\n        full_path + filename_without_ext + '.cbz',\n        full_path + filename_without_ext + '.ear',\n        full_path + filename_without_ext + '.exe',\n        full_path + filename_without_ext + '.gz',\n        full_path + filename_without_ext + '.inc',\n        full_path + filename_without_ext + '.include',\n        full_path + filename_without_ext + '.jar',\n        full_path + filename_without_ext + '.lzma',\n    ]\n\n    # LEVEL 4\n    backup_testing_level4 = [\n        site + file_path + '.tar',\n        site + file_path + '.rar',\n        site + file_path + '.zip',\n        full_path + '~' + filename_without_ext + '.tmp',\n        site + file_path + '.tar.7z',\n        site + file_path + '.tar.bz2',\n        site + file_path + '.tar.gz',\n        site + file_path + '.tar.lzma',\n        site + file_path + '.tar.xz',\n        full_path + 'backup-' + filename,\n        full_path + 'backup_' + filename,\n        full_path + 'bak-' + filename,\n        full_path + 'bak_' + filename,\n        full_path + filename_without_ext + '-backup.' + filename_ext,\n        full_path + filename_without_ext + '-bkp.' + filename_ext,\n        full_path + filename_without_ext + '.tar',\n        full_path + filename_without_ext + '.rar',\n        full_path + filename_without_ext + '.zip',\n        full_path + filename_without_ext + '.tar.7z',\n        full_path + filename_without_ext + '.tar.bz2',\n        full_path + filename_without_ext + '.tar.gz',\n        full_path + filename_without_ext + '.tar.lzma',\n        full_path + filename_without_ext + '.tar.xz',\n        full_path + filename_without_ext + '.sql.gz',\n        full_path + filename_without_ext + '.bak.sql',\n        full_path + filename_without_ext + '.bak.sql.gz',\n        full_path + filename_without_ext + '.bak.sql.bz2',\n        full_path + filename_without_ext + '.bak.sql.tar.gz',\n        site + file_path + '.',  # CVE-2017-12616\n        site + file_path + '::$DATA',  # CVE-2017-12616\n        full_path + filename_without_ext + '1',\n        full_path + filename_without_ext + '1.' + filename_ext,\n        full_path + filename_without_ext + '_backup',\n        full_path + filename_without_ext + '_backup' + filename_ext,\n        full_path + filename_without_ext + '_bak',\n        full_path + filename_without_ext + '_bak' + filename_ext,\n        full_path + filename_without_ext + '_old',\n        full_path + filename_without_ext + '_old' + filename_ext,\n        full_path + filename_without_ext + 'bak',\n        full_path + filename_without_ext + 'inc',\n        full_path + filename_without_ext + 'old',\n    ]\n\n    # LEVEL 5\n    backup_testing_level5 = [\n        site + '/.git/HEAD',\n        full_path + '.git/HEAD',\n        site + '/.git/index',\n        full_path + '.git/index',\n        site + '/.git/config',\n        full_path + '.git/config',\n        site + '/.gitignore',\n        full_path + '.gitignore',\n        site + '/.git-credentials',\n        full_path + '.git-credentials',\n        site + '/.bzr/README',\n        full_path + '.bzr/README',\n        site + '/.bzr/checkout/dirstate',\n        full_path + '.bzr/checkout/dirstate',\n        site + '/.hg/requires',\n        full_path + '.hg/requires',\n        site + '/.hg/store/fncache',\n        full_path + '.hg/store/fncache',\n        site + '/.svn/entries',\n        full_path + '.svn/entries',\n        site + '/.svn/all-wcprops',\n        full_path + '.svn/all-wcprops',\n        full_path + '.svn/wc.db',\n        site + '/.svn/wc.db',\n        site + '/.svnignore',\n        full_path + '.svnignore',\n        site + '/CVS/Entries',\n        full_path + 'CVS/Entries',\n        site + '/.cvsignore',\n        full_path + '.cvsignore',\n        site + '/.idea/misc.xml',\n        full_path + '.idea/misc.xml',\n        site + '/.idea/workspace.xml',\n        full_path + '.idea/workspace.xml',\n        site + '/.DS_Store',\n        full_path + '.DS_Store',\n        site + '/composer.lock',\n        full_path + 'composer.lock'\n    ]\n\n    testing_level = str(testing_level)\n\n    available_levels = ['1', '2', '3', '4', '5']\n    # Check is requested testing_level is within available levels.\n    # If not within available levels, choose highest level.\n    if (testing_level not in available_levels):\n        testing_level = '5'\n\n    if (testing_level == '1'):\n        backup_testing_checks = backup_testing_level1\n    if (testing_level == '2'):\n        backup_testing_checks = backup_testing_level1 + \\\n            backup_testing_level2\n    if (testing_level == '3'):\n        backup_testing_checks = backup_testing_level1 + \\\n            backup_testing_level2 + \\\n            backup_testing_level3\n    if (testing_level == '4'):\n        backup_testing_checks = backup_testing_level1 + \\\n            backup_testing_level2 + \\\n            backup_testing_level3 + \\\n            backup_testing_level4\n    if (testing_level == '5'):\n        backup_testing_checks = backup_testing_level1 + \\\n            backup_testing_level2 + \\\n            backup_testing_level3 + \\\n            backup_testing_level4 + \\\n            backup_testing_level5\n    if (dvcs_test is True):\n        backup_testing_checks = backup_testing_level5\n\n    backup_testing_checks = list(set(backup_testing_checks))\n    backup_testing_checks = random.sample(backup_testing_checks,\n                                          len(backup_testing_checks)\n                                          )\n    return(backup_testing_checks)\n\n\nclass VerifyResponse:\n    \"\"\"\n    This class checks and verifies results of requested URLs,\n     and verify file(s) existence.\n    \"\"\"\n\n    def calculate_valid_content_length(self,\n                                       content_length,\n                                       invalid_content_length_offset=50):\n        \"\"\"\n        Calculates expected valid content-lengths,\n        based off the initial conducted request.\n        Returns min and max.\n        \"\"\"\n        content_length = int(content_length)\n\n        invalid_content_length_offset = int(invalid_content_length_offset)\n        initial_content_length_min = \\\n            content_length - invalid_content_length_offset\n        initial_content_length_max = \\\n            invalid_content_length_offset + content_length\n\n        if (initial_content_length_max < 0):\n            initial_content_length_max = 0\n        if (initial_content_length_min < 0):\n            initial_content_length_min = 0\n\n        return(initial_content_length_min, initial_content_length_max)\n\n    def verify_via_content_length(self,\n                                  content_length,\n                                  initial_content_length_min,\n                                  initial_content_length_max):\n        \"\"\"\n        Verifies if the file exists by checking the content-length.\n        * Returns True if the file exists.\n        * Returns False if the file does not exist.\n        * Returns int > 0 for exceptions.\n        \"\"\"\n\n        content_length_test = True\n        if (content_length is None):\n            content_length_test = False\n            return(content_length_test)\n        if ((initial_content_length_min is None) or\n                (initial_content_length_max is None)):\n            return(1)\n        initial_content_length_max = int(initial_content_length_max)\n        for num in range(initial_content_length_min,\n                         initial_content_length_max + 1):\n            if (num == content_length):\n                content_length_test = False\n        return(content_length_test)\n\n    def verify_via_status_code(self,\n                               response_status_code,\n                               valid_status_codes=[200],\n                               excluded_status_codes=[]):\n        \"\"\"\n        Performs checks on HTTP response status codes.\n        * Returns True is the response is valid, and file seems\n          to exist\n        * Returns False if the file does not seem to exist.\n        * Returns int > 0: if there is an issue\n          in valid_status_codes or invalid_status_codes.\n        \"\"\"\n\n        # validating\n        result = True\n        if (response_status_code is None):\n            result = False\n\n        if (str(response_status_code) == str(404)):\n            result = False\n            return(result)\n\n        for valid_status_code in valid_status_codes:\n            if (str(response_status_code) == str(valid_status_code)):\n                result = True\n                break\n\n        for excluded_status_code in excluded_status_codes:\n            if (str(response_status_code) == str(excluded_status_code)):\n                result = False\n                break\n\n        return(result)\n\n    def request_check(self,\n                      use_content_length_checks=True,\n                      use_status_code_checks=True,\n                      content_length=None,\n                      initial_content_length_min=None,\n                      initial_content_length_max=None,\n                      invalid_content_length_offset=50,\n                      response_status_code=None,\n                      excluded_status_codes=[]):\n        \"\"\"\n        Checks whether a file exists based on the response.\n        Returns True if the file exists.\n        Returns False if the file does not exist.\n        * Returns int > 0 for exceptions.\n        \"\"\"\n\n        # content-length check\n        content_length_check_result = False  # Initializing variable\n        if (use_content_length_checks is True):\n            if ((content_length is None) or\n                    (initial_content_length_min is None) or\n                    (initial_content_length_max is None)):\n                return(1)  # Invalid input.\n\n        if (use_content_length_checks is True):\n            content_length_check_result = self.verify_via_content_length(\n                content_length,\n                initial_content_length_min,\n                initial_content_length_max)\n        else:\n            content_length_check_result = False\n\n        # status-code check\n        status_code_check_result = False  # Initializing variable\n        if (use_status_code_checks is True):\n            status_code_check_result = self.verify_via_status_code(\n                response_status_code,\n                excluded_status_codes=excluded_status_codes)\n        # Checking and returning result.\n\n        if ((status_code_check_result is True) or\n                (content_length_check_result is True)):\n            request_check_result = True\n        else:\n            request_check_result = False\n        return(request_check_result)\n\n\ndef request_and_verify_response(url,\n                                use_content_length_checks=True,\n                                use_status_code_checks=True,\n                                excluded_status_codes=[],\n                                invalid_content_length_offset=50,\n                                initial_content_length_min=None,\n                                initial_content_length_max=None,\n                                proxy=None,\n                                proxy_cred=None,\n                                proxy_list=None,\n                                custom_user_agent=None,\n                                custom_user_agent_list=None,\n                                cookie=None,\n                                host_header=None,\n                                http_headers=None,\n                                random_user_agent=False,\n                                timeout=None,\n                                notext=False,\n                                findings_queue=None):\n    \"\"\"\n    This function uses the Request_Handler()\n    and verify_via_status_code() classes to test a URL.\n    and returns if the file exists or not.\n    * Returns True: if the file exists.\n    * Returns False: if the file does not exist.\n    Note: This function is intended for a single URL;\n          It only shows plain results based for a single URL\n          and determines whether a file exists on the server or not.\n    \"\"\"\n\n    resp = RequestsHandler().requester(\n        url,\n        proxy=proxy,\n        proxy_cred=proxy_cred,\n        proxy_list=proxy_list,\n        custom_user_agent=custom_user_agent,\n        cookie=cookie,\n        host_header=host_header,\n        http_headers=http_headers,\n        random_user_agent=random_user_agent,\n        custom_user_agent_list=custom_user_agent_list,\n        timeout=timeout,\n        notext=notext)\n\n    file_exists = VerifyResponse().request_check(\n        use_content_length_checks=use_content_length_checks,\n        use_status_code_checks=use_status_code_checks,\n        content_length=resp[1],\n        initial_content_length_min=initial_content_length_min,\n        initial_content_length_max=initial_content_length_max,\n        invalid_content_length_offset=invalid_content_length_offset,\n        response_status_code=resp[0],\n        excluded_status_codes=excluded_status_codes)\n\n    # Remove if exists on excluded status-codes\n    for excluded_status_code in excluded_status_codes:\n        if str(resp[0]) == str(excluded_status_code):\n            file_exists = False\n            break\n\n    if findings_queue is not None:\n        if file_exists is True:\n            output = {\"url\": url,\n                      \"status_code\": resp[0],\n                      \"content_length\": resp[1]}\n            try:\n                if url not in [_[\"url\"] for _ in findings_queue.queue]:\n                    ConsoleOutput(notext=notext).found_message(url,\n                                                               resp[0],\n                                                               resp[1])\n                    if notext is True:\n                        ConsoleOutput(notext=notext).found_message_notext(url)\n                    findings_queue.put(output)\n            except RuntimeError as e:\n                exception_handler('Error: RuntimeError at (%s)' % (url),\n                                  str(e),\n                                  enable_debug=True,\n                                  notext=False)\n\n    return(file_exists, resp)\n\n\nclass OutputResults:\n    \"\"\"\n    Responsible for saving results in an external file.\n    \"\"\"\n\n    def __init__(self, notext=False, enable_debug=True):\n        self.notext = notext\n        self.enable_debug = enable_debug\n\n    def save_in_simple_txt(self,\n                           findings_list,\n                           txt_file):\n        \"\"\"\n        Save results in plain text file.\n        Save only URLs.\n        \"\"\"\n\n        try:\n            output = open(txt_file, 'a')\n            for url in [_[\"url\"] for _ in findings_list]:\n                output.write(url + \"\\n\")\n            output.close()\n        except IOError as e:\n            exception_handler('Error: IOError',\n                              str(e),\n                              enable_debug=self.enable_debug,\n                              notext=self.notext)\n            return(1)\n        except TypeError as e:\n            exception_handler('Error: TypeError',\n                              str(e),\n                              enable_debug=self.enable_debug,\n                              notext=self.notext)\n            return(1)\n        return(0)\n\n    def save_in_verbose_txt(self,\n                            findings_list,\n                            txt_file):\n        \"\"\"\n        Save results in plain text file.\n        Save: URLs, Status-Code, Content-Length.\n        \"\"\"\n\n        try:\n            output = open(txt_file, 'a')\n            for _ in findings_list:\n                url = _[\"url\"]\n                status_code = _[\"status_code\"]\n                content_length = _[\"content_length\"]\n                output_data = '[URL]: %s' % (str(url)) + \\\n                              ' | ' + \\\n                              '[Status-Code]: %s' % (str(status_code)) + \\\n                              ' | ' + \\\n                              '[Content-Length]: ' + \\\n                              '%s' % (str(content_length))\n                output.write(output_data + \"\\n\")\n            output.close()\n        except IOError as e:\n            exception_handler('Error: IOError',\n                              str(e),\n                              enable_debug=self.enable_debug,\n                              notext=self.notext)\n            return(1)\n        except TypeError as e:\n            exception_handler('Error: TypeError',\n                              str(e),\n                              enable_debug=self.enable_debug,\n                              notext=self.notext)\n            return(1)\n        return(0)\n\n    def save_in_json_file(self,\n                          findings_list,\n                          json_file):\n        \"\"\"\n        Save results in JSON file.\n        \"\"\"\n\n        try:\n            output = open(json_file, 'a')\n            data = str(json.dumps(list(findings_list)))\n            output.write(data)\n            output.close()\n        except IOError as e:\n            exception_handler('Error: IOError',\n                              str(e),\n                              enable_debug=self.enable_debug,\n                              notext=self.notext)\n            return(1)\n        except TypeError as e:\n            exception_handler('Error: TypeError',\n                              str(e),\n                              enable_debug=self.enable_debug,\n                              notext=self.notext)\n            return(1)\n        return(0)\n\n    def save_in_csv_file(self,\n                         findings_list,\n                         csv_file):\n        \"\"\"\n        Save results in plain text file.\n        Save: URLs, Status-Code, Content-Length.\n        \"\"\"\n\n        try:\n            csvfile = open(csv_file, 'a')\n            csv_writer = csv.writer(csvfile,\n                                    delimiter=',',\n                                    quotechar='\"',\n                                    quoting=csv.QUOTE_MINIMAL)\n            for _ in findings_list:\n                csv_writer.writerow([_[\"url\"],\n                                    _[\"status_code\"],\n                                    _[\"content_length\"]])\n            csvfile.close()\n        except IOError as e:\n            exception_handler('Error: IOError',\n                              str(e),\n                              enable_debug=self.enable_debug,\n                              notext=self.notext)\n            return(1)\n        except TypeError as e:\n            exception_handler('Error: TypeError',\n                              str(e),\n                              enable_debug=self.enable_debug,\n                              notext=self.notext)\n            return(1)\n        return(0)\n\n\nclass ConsoleOutput:\n\n    def __init__(self, notext=False):\n        self.notext = notext\n\n    def console_output_check(self):\n        if (__name__ != '__main__'):\n            return(1)\n        if (self.notext is True):\n            return(1)\n\n    def erase_line(self):\n        with threading.Lock():\n            if platform.system() == 'Windows':\n                sys.stdout.write(\"\\b\" * 4096)\n            else:\n                sys.stdout.write('\\033[1K')\n                sys.stdout.write('\\033[0G')\n\n    def print_base_url(self, url,\n                       current_queue_counter=None, urls_queue_size=None):\n        if self.console_output_check() == 1:\n            return(1)\n        with threading.Lock():\n            if urls_queue_size == 1:\n                sys.stdout.write(\"\\n\\n%s URL: %s\\n\" % (symbols.info, url))\n            else:\n                sys.stdout.write(\"\\n\\n%s [%s/%s] URL: %s\\n\" % (\n                    symbols.info,\n                    current_queue_counter,\n                    urls_queue_size,\n                    url))\n            sys.stdout.flush()\n\n    def testing_url_message(self,\n                            url,\n                            current_progress_percentage):\n        if self.console_output_check() == 1:\n            return(1)\n        with threading.Lock():\n            self.erase_line()\n            output = ('[%s] Testing:-> %s' % (\n                      (str(current_progress_percentage) + \"%\"), url))\n            sys.stdout.write(output)\n            sys.stdout.flush()\n\n    def found_message(self,\n                      url,\n                      response_status_code,\n                      content_length):\n        if self.console_output_check() == 1:\n            return(1)\n\n        with threading.Lock():\n            self.erase_line()\n            sys.stdout.write((symbols.success + \" Discovered: -> {%s}\" +\n                              \" (Response-Code: %s | Content-Length: %s)\\n\")\n                             % (url, response_status_code,\n                                content_length))\n            sys.stdout.flush()\n\n    def found_message_notext(self,\n                             url):\n        with threading.Lock():\n            sys.stdout.write(\"%s\\n\" % (url))\n            sys.stdout.flush()\n\n    def message_with_all_findings(self,\n                                  findings_list):\n        if self.console_output_check() == 1:\n            return(1)\n\n        self.erase_line()\n        sys.stdout.write(\"\\n\")\n        sys.stdout.flush()\n        print(symbols.info +\n              '%s Findings:%s' % (colorama.Fore.CYAN,\n                                  colorama.Style.RESET_ALL))\n        if (len(findings_list) == 0):\n            print(symbols.info + ' No BFA was identified.')\n        else:\n            for _ in findings_list:\n                if str(_[\"status_code\"]).startswith('2'):\n                    status = colorama.Fore.GREEN\n                elif str(_[\"status_code\"]).startswith('3'):\n                    status = colorama.Fore.YELLOW\n                elif str(_[\"status_code\"]).startswith('4'):\n                    status = colorama.Fore.RED\n                elif str(_[\"status_code\"]).startswith('5'):\n                    status = colorama.Fore.MAGENTA\n                else:\n                    status = \"\"\n                status += '(%s)' % (str(_[\"status_code\"]))\n                print(_[\"url\"] + ' %s | (Content-Length: %s)'\n                      % (status, str(_[\"content_length\"])))\n        print('\\n' + symbols.info + ' Finished performing scan.')\n\n    def host_is_not_responding(self, url):\n        if self.console_output_check() == 1:\n            return(1)\n        print(symbols.error + ' Host ' +\n              '[%s]' % (url_handler(url)[\"domain\"]) +\n              ' does not seem to be responding as expected.')\n        print(symbols.info + ' Skipping...')\n\n\ndef test_url(url,\n             dvcs_test=False,\n             testing_level=5,\n             use_content_length_checks=True,\n             use_status_code_checks=True,\n             excluded_status_codes=[],\n             invalid_content_length_offset=50,\n             force_initial_content_length=None,\n             forced_initial_content_length=None,\n             proxy=None,\n             proxy_cred=None,\n             proxy_list=None,\n             custom_user_agent=None,\n             custom_user_agent_list=None,\n             cookie=None,\n             host_header=None,\n             http_headers=None,\n             random_user_agent=False,\n             timeout=None,\n             notext=False,\n             enable_debug=False,\n             max_threads=10,\n             request_rate_throttling=30,\n             testedjar=None,\n             findings_queue=None):\n    \"\"\"\n    This function performs BFA testing on a single URL.\n\n    Returns a list of findings.\n    Returns int > 0 if an exception occured.\n    \"\"\"\n\n    testedjar = queue.Queue() if not testedjar else testedjar\n    findings_queue = queue.Queue() if not findings_queue else findings_queue\n\n    current_scan_queue = queue.Queue()\n    current_findings_queue = queue.Queue()\n\n    generated_urls = generate_bfa_urls(\n        url,\n        testing_level=testing_level,\n        dvcs_test=dvcs_test)\n\n    for url in generated_urls:\n        current_scan_queue.put(url)\n\n    init_req = RequestsHandler().initial_request(\n        url,\n        force_initial_content_length=force_initial_content_length,\n        proxy=proxy,\n        proxy_cred=proxy_cred,\n        proxy_list=proxy_list,\n        custom_user_agent=custom_user_agent,\n        cookie=cookie,\n        host_header=host_header,\n        http_headers=http_headers,\n        random_user_agent=random_user_agent,\n        custom_user_agent_list=custom_user_agent_list,\n        timeout=timeout,\n        notext=notext,\n        enable_debug=enable_debug)\n\n    if (None in init_req):\n        ConsoleOutput(notext=notext).host_is_not_responding(url)\n        return(1)\n\n    init_req_content_length = init_req[1]\n\n    if ((use_content_length_checks is True) and\n       (force_initial_content_length is True)):\n        init_req_content_length = forced_initial_content_length\n\n    if use_content_length_checks is True:\n        cl_calc = VerifyResponse().calculate_valid_content_length(\n            init_req_content_length,\n            invalid_content_length_offset)\n    else:\n        cl_calc = (0, 0)\n\n    kwargs = {\"use_content_length_checks\": use_content_length_checks,\n              \"use_status_code_checks\": use_status_code_checks,\n              \"excluded_status_codes\": excluded_status_codes,\n              \"initial_content_length_min\": cl_calc[0],\n              \"initial_content_length_max\": cl_calc[1],\n              \"proxy\": proxy,\n              \"proxy_cred\": proxy_cred,\n              \"proxy_list\": proxy_list,\n              \"custom_user_agent\": custom_user_agent,\n              \"custom_user_agent_list\": custom_user_agent_list,\n              \"cookie\": cookie,\n              \"host_header\": host_header,\n              \"http_headers\": http_headers,\n              \"random_user_agent\": random_user_agent,\n              \"timeout\": timeout,\n              \"notext\": notext,\n              \"findings_queue\": current_findings_queue}\n\n    threads_state = []\n\n    # Do request rate throttling\n    i = queue.Queue()\n\n    def counter_reset(i):\n        while current_scan_queue.empty() is False:\n            time.sleep(1)\n            i.queue.clear()\n\n    try:\n        t = threading.Thread(target=counter_reset, args=(i,))\n        t.daemon = True\n        t.start()\n        threads_state.append(t)\n    except KeyboardInterrupt:\n        t.join()\n\n    while current_scan_queue.empty() is False:\n\n        if threading.active_count() < (int(max_threads) + 2):\n            # +2 is made for the following:\n            #   - The main thread.\n            #   - A thread doing counter resetting.\n            if len(i.queue) > request_rate_throttling:\n                continue\n            i.put(None)\n            url = current_scan_queue.get()\n            if (url in list(testedjar.queue)):\n                continue\n\n            testedjar.put(url)\n            current_progress_percentage = round(\n                float(float(len(generated_urls) - current_scan_queue.qsize()) /\n                      float(len(generated_urls))) * 100, 2)\n            ConsoleOutput(notext=notext).testing_url_message(\n                url,\n                current_progress_percentage)\n            t = threading.Thread(target=request_and_verify_response,\n                                 args=(url,),\n                                 kwargs=kwargs)\n            t.daemon = True\n            t.start()\n            threads_state.append(t)\n        else:\n            time.sleep(0.5)\n    for t in threads_state:\n        t.join()\n\n    current_findings = list(current_findings_queue.queue)\n    for _ in current_findings:\n        if _[\"url\"] not in findings_queue.queue:\n            findings_queue.put(_)\n    return(current_findings)\n\n\ndef main():\n    # Makes Colorama work on Windows\n    colorama.init(autoreset=True)\n\n    if ('--no-text' not in sys.argv):\n\n        if (('-h' in sys.argv) or ('--help' in sys.argv) or\n                ('-hh' in sys.argv) or (len(sys.argv) <= 1) or\n                ('-help' in sys.argv) or ('--h' in sys.argv)):\n            print(logo())\n            print(instructions())\n            exit(0)\n        else:\n            print(logo())\n\n    if ('-V' in sys.argv) or ('--version' in sys.argv):\n        print(version())\n        exit(0)\n\n    if ('--issue' in sys.argv):\n        webbrowser.open('https://github.com/mazen160/bfac/issues/new')\n        print(symbols.info + ' Opening GitHub repo.')\n        exit(0)\n\n    # Handling arguments (command-line use)\n    parser = argparse.ArgumentParser()\n    # Target Options\n    parser.add_argument(\"-u\", \"--url\",\n                        dest=\"url\",\n                        help=\"Check a single URL.\",\n                        action='store')\n    parser.add_argument(\"-L\", \"--list\",\n                        dest=\"usedlist\",\n                        help=\"Check a list of URLs.\",\n                        action='store')\n    parser.add_argument(\"--stdin\",\n                        dest=\"use_stdin\",\n                        help=\"Check URLs from STDIN input.\",\n                        action='store_true')\n    # Testing Options\n    parser.add_argument(\"-level\", \"--level\",\n                        dest=\"testing_level\",\n                        help=\"Set testing level [1-5]\\\n                        (default: 5).\",\n                        action='store',\n                        default=5)\n    parser.add_argument(\"--dvcs-test\",\n                        dest=\"dvcs_test\",\n                        help=\"Perform DVCS testing only,\\\n                        which is available by default on Level 5.\",\n                        action='store_true')\n    parser.add_argument(\"--threads\",\n                        dest=\"max_threads\",\n                        help=\"thread workers to use (default: 10).\",\n                        action='store',\n                        default=10)\n    parser.add_argument(\"--request-rate-throttling\",\n                        dest=\"request_rate_throttling\",\n                        help=\"request rate throttling per second\\\n                             (default: 30)\",\n                        action=\"store\",\n                        default=30)\n    # Artifacts Detection Options\n    parser.add_argument(\"--invalid-content-length\",\n                        dest=\"invalid_content_length\",\n                        help=\"Manually specify the invalid\\\n                        Content-Length, instead of performing\\\n                        this check automatically.\",\n                        action='store')\n    parser.add_argument(\"--invalid-content-length-offset\",\n                        dest=\"invalid_content_length_offset\",\n                        help=\"Manually specify the Content-Length\\\n                        offset for invalid pages. (default: 50)\",\n                        action='store',\n                        default=50)\n    parser.add_argument(\"--technique\", \"--detection-technique\",\n                        dest=\"detection_technique\",\n                        help=\"Technique to verify the availability\\\n                        of the file. (Options: status_code,\\\n                        content_length,all) (default: all)\",\n                        action='store',\n                        default='all')\n    parser.add_argument(\"-xsc\", \"--exclude-status-codes\",\n                        dest=\"exclude_status_codes\",\n                        help=\"Specify status codes to exclude,\\\n                        separated by commas.\",\n                        action='store',\n                        default=[])\n    # Output-Related Options\n    parser.add_argument(\"-o\", \"--output\",\n                        dest='output_file',\n                        help=\"Save identified URLs into a file.\",\n                        action='store')\n    parser.add_argument(\"--verbose-output\",\n                        dest='verbose_output_file',\n                        help=\"Save identified URLs, with \\\n                        status-codes and content-length into a file.\",\n                        action='store')\n\n    parser.add_argument(\"--json-output\",\n                        dest='json_output',\n                        help=\"Save findings in JSON file.\",\n                        action='store')\n    parser.add_argument(\"--csv-output\",\n                        dest='csv_output',\n                        help=\"Save findings in CSV file.\",\n                        action='store')\n    # Request-Related Options\n    parser.add_argument(\"-ua\", \"--user-agent\",\n                        dest='user_agent',\n                        help=\"HTTP User-Agent header value.\",\n                        action='store')\n    parser.add_argument(\"-ra\", \"--random-agent\", \"--random-agents\",\n                        dest='random_agent',\n                        help=\"Use random User-Agents.\",\n                        action='store_true')\n    parser.add_argument(\"--user-agents-file\",\n                        dest=\"custom_ua_file\",\n                        help=\"Use a User-Agents file.\",\n                        action='store')\n    parser.add_argument(\"--cookie\",\n                        dest='cookie',\n                        help=\"HTTP Cookie header value.\",\n                        action='store')\n    parser.add_argument(\"--host\",\n                        dest='host',\n                        help=\"HTTP Host header value.\",\n                        action='store')\n    parser.add_argument(\"--headers\",\n                        dest='headers',\n                        help=\"Extra headers\\\n                        (e.g. \\\"Accept-Language: fr\\\\n\\\n                        ETag: 123\\\")\",\n                        action='store')\n    parser.add_argument(\"--proxy\",\n                        dest='proxy',\n                        help=\"Use a proxy\\\n                        on testing.\",\n                        action='store')\n    parser.add_argument(\"--proxy-cred\",\n                        dest='proxy_cred',\n                        help=\"Proxy authentication credentials\\\n                        (name:password).\",\n                        action='store')\n    parser.add_argument(\"--proxy-file\",\n                        dest='proxy_list_file',\n                        help=\"Use a proxy list file.\",\n                        action='store')\n    parser.add_argument(\"--timeout\",\n                        dest='timeout',\n                        help=\"HTTP Request timeout by seconds.\\\n                        (default: 5)\",\n                        action='store',\n                        default=5)\n    # Other Options\n    parser.add_argument(\"--no-text\",\n                        dest='notext',\n                        help=\"Print and write a clean output\\\n                        with results ony.\",\n                        action='store_true')\n    parser.add_argument(\"--debug\",\n                        dest='enable_debug',\n                        help=\"Enable debugging.\",\n                        action='store_true',\n                        default=False)\n    parser.add_argument(\"--issue\",\n                        dest='report_issue',\n                        help=\"Report an issue on GitHub.\",\n                        action='store_true')\n    parser.add_argument(\"-V\", \"--version\",\n                        dest='show_version',\n                        help=\"Show current version and exit.\",\n                        action='store_true')\n\n    args = parser.parse_args()\n\n    # Handling input from argparse (Command-line use).\n    url = args.url if args.url else None\n    usedlist = args.usedlist if args.usedlist else None\n    use_stdin = args.use_stdin if args.use_stdin else None\n    testing_level = args.testing_level if args.testing_level else None\n    dvcs_test = args.dvcs_test if args.dvcs_test else None\n    max_threads = int(args.max_threads) if args.max_threads else None\n\n    # Used if-statements on multiple lines to not break PEP8-E501\n    if args.request_rate_throttling:\n        request_rate_throttling = int(args.request_rate_throttling)\n    else:\n        request_rate_throttling = None\n    if args.invalid_content_length:\n        invalid_content_length = args.invalid_content_length\n    else:\n        invalid_content_length = None\n    if args.invalid_content_length_offset:\n        invalid_content_length_offset = args.invalid_content_length_offset\n    else:\n        invalid_content_length_offset = None\n    if args.detection_technique:\n        detection_technique = args.detection_technique\n    else:\n        detection_technique = None\n    if args.exclude_status_codes:\n        exclude_status_codes = args.exclude_status_codes\n    else:\n        exclude_status_codes = None\n\n    output_file = args.output_file if args.output_file else None\n\n    if args.verbose_output_file:\n        verbose_output_file = args.verbose_output_file\n    else:\n        verbose_output_file = None\n\n    json_output = args.json_output if args.json_output else None\n    csv_output = args.csv_output if args.csv_output else None\n    user_agent = args.user_agent if args.user_agent else None\n    random_agent = args.random_agent if args.random_agent else None\n    if args.custom_ua_file:\n        custom_ua_file = args.custom_ua_file\n    else:\n        custom_ua_file = None\n    cookie = args.cookie if args.cookie else None\n    headers = args.headers if args.headers else None\n    proxy = args.proxy if args.proxy else None\n    proxy_cred = args.proxy_cred if args.proxy_cred else None\n    proxy_list_file = args.proxy_list_file if args.proxy_list_file else None\n    host = args.host if args.host else None\n    timeout = args.timeout if args.timeout else None\n    notext = args.notext if args.notext else None\n    enable_debug = args.enable_debug if args.enable_debug else False\n\n    # Check if URL or List Input is used.\n    if (url is None) and (usedlist is None) and (use_stdin is None):\n        e = symbols.error + \\\n            ' Error: Either a URL or a List should be supplied.'\n        print(str(e))\n        print('\\nExiting...')\n        exit(1)\n\n    # Check if requested level is not within levels\n    available_levels = ['1', '2', '3', '4', '5']\n    if (str(testing_level) not in available_levels):\n        e = symbols.error + ' Error: Chosen level is invalid.'\n        print(str(e))\n        print('\\nExiting...')\n        exit(1)\n\n    # Check Verify File Availability input:\n    detection_techniques = ['status_code',\n                            'content_length',\n                            'all']\n    if (detection_technique not in detection_techniques):\n        e = symbols.error + \\\n            ' Error: Entered Verify File Availability option is invalid.'\n        print(str(e))\n        print('\\nExiting...')\n        exit(1)\n\n    # Initializing output file,\n    # and checking if we have write access to file.\n    if (output_file):\n        try:\n            open(output_file, 'a').close()\n        except Exception as e:\n            print(symbols.error +\n                  ' Error: There is an error in writing output.')\n            exception_handler('Error: ', str(e))\n            print('\\nExiting...')\n            exit(1)\n    if (verbose_output_file):\n        try:\n            open(verbose_output_file, 'a').close()\n        except Exception as e:\n            print(symbols.error +\n                  ' Error: There is an error in writing output.')\n            exception_handler('Error: ', str(e))\n            print('\\nExiting...')\n            exit(1)\n    if (json_output):\n        try:\n            open(json_output, 'a').close()\n        except Exception as e:\n            print(symbols.error +\n                  ' Error: There is an error in writing output.')\n            exception_handler('Error: ', str(e))\n            print('\\nExiting...')\n            exit(1)\n    if (csv_output):\n        try:\n            open(csv_output, 'a').close()\n        except Exception as e:\n            print(symbols.error +\n                  ' Error: There is an error in writing output.')\n            exception_handler('Error: ', str(e))\n            print('\\nExiting...')\n            exit(1)\n\n    # Parse status_codes\n    if (isinstance(exclude_status_codes, str) is True):\n        exclude_status_codes = exclude_status_codes.replace(' ', '')\n        exclude_status_codes = exclude_status_codes.split(',')\n    # Checking and validating excluded status-codes input.\n    if ((exclude_status_codes is None) or\n            (exclude_status_codes == '')):\n        exclude_status_codes = []\n    for exclude_status_code in exclude_status_codes:\n        if str.isdigit(str(exclude_status_code)) is False:\n            e = symbols.error + \\\n                ' Error: Invalid provided excluded status code.'\n            print(str(e))\n            exit(1)\n\n    if (detection_technique == 'all'):\n        use_status_code_checks = True\n        use_content_length_checks = True\n    if (detection_technique == 'content_length'):\n        use_status_code_checks = False\n        use_content_length_checks = True\n    if (detection_technique == 'status_code'):\n        use_status_code_checks = True\n        use_content_length_checks = False\n    if (invalid_content_length is not None):\n        force_initial_content_length = True\n        forced_initial_content_length = invalid_content_length\n    else:\n        force_initial_content_length = False\n        forced_initial_content_length = None\n\n    if custom_ua_file:\n        try:\n            ua_list = open(custom_ua_file, \"r\").readlines()\n        except Exception as e:\n            print(symbols.error + \" Error reading user-agents file.\")\n            exception_handler('Error: ', str(e))\n            exit(1)\n        ua_list = [_.replace(\"\\r\", \"\").replace(\"\\n\", \"\") for _ in ua_list]\n        custom_user_agent_list = ua_list\n        del ua_list\n    else:\n        custom_user_agent_list = None\n\n    if proxy_list_file:\n        try:\n            proxy_list = open(proxy_list_file, \"r\").read().replace(\"\\r\", \"\")\n            proxy_list = proxy_list.split(\"\\n\")\n        except Exception as e:\n            print(symbols.error + \" Error reading proxy-list file.\")\n            exception_handler('Error: ', str(e))\n            exit(1)\n    else:\n        proxy_list = None\n\n    http_headers_list = []\n    if headers:\n        extra_headers_handler = headers.replace('\\r', '')\n        headers_list = extra_headers_handler.split('\\\\n')\n        for _ in headers_list:\n            if (len(_.split(':')) != 2):\n                pass\n            else:\n                header = _.split(':')[0]\n                header_value = _.split(':')[1]\n\n                header_value = list(header_value)\n                # Need to check if first element is \\x20\n                # because of an error shown when requesting.\n                if (header_value[0] == ' '):\n                    header_value[0] = ''\n                    header_value = ''.join(header_value)\n                    add_header = {str(header): str(header_value)}\n                    http_headers_list.append(add_header)\n\n    URLs_list = []\n    if url:\n        URLs_list.append(url)\n    if (usedlist):\n        try:\n            f_open = open(usedlist, 'r').readlines()\n        except Exception as e:\n            message = symbols.error + ' Unable to use list [%s].' % (usedlist)\n            exception_handler(message, str(e))\n            print('\\nExiting...')\n            exit(1)\n        for _ in f_open:\n            _ = _.replace('\\r', '').replace('\\n', '')\n            URLs_list.append(_)\n    if (use_stdin):\n        stdin_input = sys.stdin.readlines()\n        for _ in stdin_input:\n            _ = _.replace('\\r', '').replace('\\n', '')\n            URLs_list.append(_)\n    URLs_list = list(set(URLs_list))\n\n    testedjar = queue.Queue()\n    findings_queue = queue.Queue()\n\n    for url in enumerate(URLs_list):\n        ConsoleOutput(notext=notext).print_base_url(\n            url[1],\n            current_queue_counter=(url[0] + 1),\n            urls_queue_size=len(URLs_list))\n        test_url(\n            url[1],\n            dvcs_test=dvcs_test,\n            testing_level=testing_level,\n            use_content_length_checks=use_content_length_checks,\n            use_status_code_checks=use_status_code_checks,\n            excluded_status_codes=exclude_status_codes,\n            invalid_content_length_offset=invalid_content_length_offset,\n            force_initial_content_length=force_initial_content_length,\n            forced_initial_content_length=forced_initial_content_length,\n            proxy=proxy,\n            proxy_cred=proxy_cred,\n            proxy_list=proxy_list,\n            custom_user_agent=user_agent,\n            custom_user_agent_list=custom_user_agent_list,\n            cookie=cookie,\n            host_header=host,\n            http_headers=http_headers_list,\n            random_user_agent=random_agent,\n            timeout=timeout,\n            notext=notext,\n            enable_debug=enable_debug,\n            max_threads=max_threads,\n            request_rate_throttling=request_rate_throttling,\n            testedjar=testedjar,\n            findings_queue=findings_queue)\n\n    if (output_file):\n        OutputResults(notext=notext).save_in_simple_txt(findings_queue.queue,\n                                                        output_file)\n    if (verbose_output_file):\n        OutputResults(notext=notext).save_in_verbose_txt(findings_queue.queue,\n                                                         verbose_output_file)\n    if (json_output):\n        OutputResults(notext=notext).save_in_json_file(findings_queue.queue,\n                                                       json_output)\n    if (csv_output):\n        OutputResults(notext=notext).save_in_csv_file(findings_queue.queue,\n                                                      csv_output)\n\n    ConsoleOutput(notext=notext).message_with_all_findings(\n        findings_queue.queue\n    )\n\n\nif (__name__ == '__main__'):\n    try:\n        main()\n    except KeyboardInterrupt:\n        print('\\n' + symbols.info + ' KeyboardInterrupt Detected.')\n        print('\\nExiting...')\n        os._exit(1)\n\n# *** END *** #\n"
  },
  {
    "path": "requirements.txt",
    "content": "colorama\nrequests\nrequests[socks]\n"
  },
  {
    "path": "setup.py",
    "content": "#!/usr/bin/env python3\n# coding=utf-8\n# *******************************************************************\n# *** BFAC: Backup File Artifacts Checker ***\n# * Homepage:\n#   https://github.com/mazen160/bfac\n# * setup.py:\n#   BFAC setup script\n# * Author:\n#   Mazin Ahmed <Mazin AT MazinAhmed DOT net>\n# *******************************************************************\n\nfrom setuptools import setup, find_packages\n\nsetup(\n    name='bfac',\n    packages=find_packages(),\n    version='1.4',\n    scripts=['bfac'],\n    description=\"Advanced Backup-File Artifacts Testing for Web-Applications\",\n    long_description=\"An automated tool that checks for backup artifacts \" +\n                     \"that may disclose the web-application's\" +\n                     \" source code.\",\n    author='Mazin Ahmed',\n    author_email='mazin@mazinahmed.net',\n    url='https://github.com/mazen160/bfac',\n    keywords=['backup', 'artifacts', 'checker', 'web scanner',\n              'web vulnerability scanner', 'bfac'],\n    install_requires=['colorama', 'requests', 'requests[socks]'],\n    license='GPL-3.0'\n)\n"
  }
]