[
  {
    "path": ".github/workflows/build.yml",
    "content": "name: Build\n\non:\n  workflow_call:\n    inputs:\n      attach_to_release:\n        description: 'Attach JAR to release'\n        required: false\n        type: boolean\n        default: false\n      upload_artifact:\n        description: 'Upload JAR as artifact'\n        required: false\n        type: boolean\n        default: false\n    secrets:\n      token:\n        required: false\n\njobs:\n  build:\n    runs-on: ubuntu-latest\n\n    steps:\n      - uses: actions/checkout@v3\n      - name: Set up JDK 17\n        uses: actions/setup-java@v3\n        with:\n          java-version: '17'\n          distribution: 'temurin'\n      - name: Validate Gradle wrapper\n        uses: gradle/wrapper-validation-action@v1\n      - name: Build with Gradle\n        uses: gradle/gradle-build-action@v2\n        with:\n          arguments: build\n\n      - if: ${{ inputs.upload_artifact }}\n        uses: actions/upload-artifact@v2\n        with:\n          name: Package\n          path: build/libs\n\n      - if: ${{ inputs.attach_to_release }}\n        name: Upload JAR to release\n        uses: softprops/action-gh-release@v1\n        env:\n          GITHUB_TOKEN: ${{ secrets.token }}\n        with:\n          files: build/libs/burp-vps-proxy.jar\n"
  },
  {
    "path": ".github/workflows/main.yml",
    "content": "name: Java CI\n\non:\n  push:\n    branches:\n      - '**'\n    tags-ignore:\n      - '**'\n\njobs:\n  build:\n    uses: ./.github/workflows/build.yml\n    with:\n      upload_artifact: true\n"
  },
  {
    "path": ".github/workflows/release.yml",
    "content": "name: Release\n\non:\n  release:\n    types: [created]\n\njobs:\n  build_and_attach:\n    uses: ./.github/workflows/build.yml\n    with:\n      attach_to_release: true\n    secrets:\n      token: ${{ secrets.GITHUB_TOKEN }}\n"
  },
  {
    "path": ".gitignore",
    "content": "# Ignore Gradle project-specific cache directory\n.gradle\n\n# Ignore Gradle build output directory\nbuild\nbin\n\n# Ignore Visual Studio Code settings for now because they're user-based\n.vscode\n"
  },
  {
    "path": "CHANGELOG.md",
    "content": "# Changelog\n\nAll notable changes to this project will be documented in this file.\n\nThe format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),\nand this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).\n\n## [Unreleased]\n\n## [1.0.0] - 2023-04-03\n\n### Added\n\n- Automatic creation, configuration and deletion of upstream SOCKS5 proxy on popular cloud services from within BurpSuite.\n- Support for multiple providers: AWS, Digital Ocean and Linode.\n- Each provider has its unique settings, including region selection.\n- Automatic destruction of proxy when closing Burp or unloading the extension, with an option to preserve the proxy across sessions instead.\n- Restores SOCKS5 proxy settings in Burp to their original values when the proxy is destroyed.\n- Compatibility across multiple devices, ensuring seamless use without interference from proxies generated on separate computers.\n\n[unreleased]: https://github.com/d3mondev/burp-vps-proxy/compare/v1.0.0...HEAD\n[1.0.0]: https://github.com/d3mondev/burp-vps-proxy/releases/tag/v1.0.0\n"
  },
  {
    "path": "LICENSE",
    "content": "                    GNU GENERAL PUBLIC LICENSE\n                       Version 3, 29 June 2007\n\n Copyright (C) 2007 Free Software Foundation, Inc. <https://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 <https://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<https://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<https://www.gnu.org/licenses/why-not-lgpl.html>.\n\n"
  },
  {
    "path": "README.md",
    "content": "<h3 align=\"center\">Burp VPS Proxy: Easy Cloud Proxies for Burp Suite</h2>\n\n<p align=\"center\"><img src=\"assets/logo.png\" width=\"800\"></p>\n\n<p align=\"center\">\n    <img src=\"https://img.shields.io/github/actions/workflow/status/d3mondev/burp-vps-proxy/main.yml?branch=main&style=for-the-badge\">\n    <img src=\"https://img.shields.io/badge/License-GPL3-green.svg?style=for-the-badge\">\n    <a href=\"https://twitter.com/d3mondev\"><img src=\"https://img.shields.io/twitter/follow/d3mondev?logo=twitter&style=for-the-badge\"></a>\n</p>\n\n<p align=\"center\">\n    <a href=\"#-how-to-use\"><strong>Getting Started »</strong></a>\n    <br />\n    <br />\n    <a href=\"#-features\">Features</a>\n    ·\n    <a href=\"#-providers\">Providers</a>\n    ·\n    <a href=\"#-disclaimers--license\">Disclaimers</a>\n</p>\n\n# 📖 About\n\nBurp VPS Proxy is a Burp Suite extension that allows for the automatic creation and deletion of upstream SOCKS5 proxies on popular cloud providers from within Burp Suite. It automatically configures Burp to use the created proxy so that all outbound traffic comes from a cloud IP address. This is useful to prevent our main IP address from being blacklisted by popular WAFs while performing penetration testing and bug bounty hunting.\n\nBurp VPS Proxy was inspired by @honoki's awesome [DigitalOcean Droplet Proxy for Burp Suite](https://github.com/honoki/burp-digitalocean-droplet-proxy) idea.\n\nThink this is useful? ⭐ Star us on GitHub — it helps!\n\n# 🛠 Features\n\n* Automatic creation, configuration and deletion of upstream SOCKS5 proxy on popular cloud services from within Burp Suite.\n* Support for multiple providers: AWS, Digital Ocean and Linode.\n* Each provider has its unique settings, including region selection.\n* Automatic destruction of proxy when closing Burp or unloading the extension, with an option to preserve the proxy across sessions instead.\n* Restores SOCKS5 proxy settings in Burp to their original values when the proxy is destroyed.\n* Compatibility across multiple devices, ensuring seamless use without interference from proxies generated on separate computers.\n\n# 🔎 How to use\n\nVisit the [release page](https://github.com/d3mondev/burp-vps-proxy/releases) and download the latest `burp-vps-proxy.jar` file.\n\nIn Burp Suite, visit the Extensions tab and click Add. Set the extension type to Java, and select the `burp-vps-proxy.jar` file.\n\nOnce loaded, access the extension via the new VPS Proxy tab in Burp. Select your provider, set your API keys and click Deploy.\n\n# 🌐 Providers\n\n## Amazon Web Services (AWS)\n\n![](assets/providers-aws.png)\n\nThe extension will use the `t4g.nano` instance type to minimize costs. Note that not all regions support this instance type. The extension will also create a security group named `burp-vps-proxy` in the region selected to allow connections to port 1080.\n\nYou will need an AWS Access Key and AWS Private Key in order to configure the extension. You'll also need to ensure the key pair gives access to at least the following permissions:\n\n```\n{\n    \"Version\": \"2012-10-17\",\n    \"Statement\": [\n        {\n            \"Sid\": \"EC2Permissions\",\n            \"Effect\": \"Allow\",\n            \"Action\": [\n                \"ec2:RunInstances\",\n                \"ec2:TerminateInstances\",\n                \"ec2:DescribeInstances\",\n                \"ec2:DescribeImages\",\n                \"ec2:DescribeRegions\",\n                \"ec2:CreateTags\",\n                \"ec2:CreateSecurityGroup\",\n                \"ec2:DescribeSecurityGroups\",\n                \"ec2:AuthorizeSecurityGroupIngress\"\n            ],\n            \"Resource\": \"*\"\n        }\n    ]\n}\n```\n\n## Digital Ocean\n\n![](assets/providers-do.png)\n\nDigital Ocean is a popular VPS provider among security researchers, pentesters and bug bounty hunters. If you don't already have an account, you can get a $200 in free credits by using my referral link to signup:\n\n[![DigitalOcean Referral Badge](https://web-platforms.sfo2.digitaloceanspaces.com/WWW/Badge%203.svg)](https://www.digitalocean.com/?refcode=e4681a7c61c6&utm_campaign=Referral_Invite&utm_medium=Referral_Program&utm_source=badge)\n\nYou will need to create an API key and enter it in the Burp VPS Proxy extension.\n\nProvisioning can take some time after the droplet is created. Wait a few minutes after the instance is up.\n\n## Linode\n\n![](assets/providers-linode.png)\n\nYou will need to create an API key and enter it in the Burp VPS Proxy extension. This is done in the \"My Settings -> API Tokens\" section of your profile in your Linode dashboard. They call it a Personal Access Token.\n\nEnsure the API key has the Read/Write permission for \"Linodes\".\n\nProvisioning is done via SSH and the proxy is usually available as soon as the extension tells you.\n\n# ⚖ Disclaimers & License\n\nThe author and contributors of this extension expressly disclaim any liability for any costs, damages, or consequences resulting from the use of cloud providers in connection with this software.\n\nUsing this program for unauthorized or illegal activities, including attacking targets without consent, is strictly prohibited. Users must comply with all applicable laws and regulations. The developer and contributors assume no liability or responsibility for any misuse, damage, or harm caused by this software. It is the user's responsibility to utilize this program in an ethical and lawful manner.\n\nThis repository's content is licensed under the GNU General Public License v3.0 (GPLv3).\n"
  },
  {
    "path": "build.gradle",
    "content": "plugins {\n    id 'java'\n    id 'com.github.johnrengelman.shadow' version '8.1.1'\n}\n\ngroup 'com.github.d3mondev.burpvpsproxy'\nversion '1.0.0'\n\nrepositories {\n     mavenCentral()\n}\n\ndependencies {\n    implementation 'org.json:json:20230227'\n    implementation 'com.jcraft:jsch:0.1.55'\n    implementation 'net.portswigger.burp.extender:burp-extender-api:2.1'\n    implementation 'com.myjeeva.digitalocean:digitalocean-api-client:2.17'\n    implementation 'software.amazon.awssdk:ec2:2.20.37'\n    implementation 'software.amazon.awssdk:core:2.20.37'\n}\n\nsourceSets {\n    main {\n        java {\n            srcDir 'src'\n        }\n        resources {\n            srcDir 'resources'\n        }\n    }\n}\n\nshadowJar {\n    archiveBaseName = project.name\n    archiveVersion = ''\n    archiveFileName = archiveBaseName.get() + \".jar\"\n}\n\nbuild.dependsOn shadowJar\n"
  },
  {
    "path": "gradle/wrapper/gradle-wrapper.properties",
    "content": "distributionBase=GRADLE_USER_HOME\ndistributionPath=wrapper/dists\ndistributionUrl=https\\://services.gradle.org/distributions/gradle-8.0.2-bin.zip\nzipStoreBase=GRADLE_USER_HOME\nzipStorePath=wrapper/dists\n"
  },
  {
    "path": "gradlew",
    "content": "#!/bin/sh\n\n#\n# Copyright © 2015-2021 the original authors.\n#\n# Licensed under the Apache License, Version 2.0 (the \"License\");\n# you may not use this file except in compliance with the License.\n# You may obtain a copy of the License at\n#\n#      https://www.apache.org/licenses/LICENSE-2.0\n#\n# Unless required by applicable law or agreed to in writing, software\n# distributed under the License is distributed on an \"AS IS\" BASIS,\n# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n# See the License for the specific language governing permissions and\n# limitations under the License.\n#\n\n##############################################################################\n#\n#   Gradle start up script for POSIX generated by Gradle.\n#\n#   Important for running:\n#\n#   (1) You need a POSIX-compliant shell to run this script. If your /bin/sh is\n#       noncompliant, but you have some other compliant shell such as ksh or\n#       bash, then to run this script, type that shell name before the whole\n#       command line, like:\n#\n#           ksh Gradle\n#\n#       Busybox and similar reduced shells will NOT work, because this script\n#       requires all of these POSIX shell features:\n#         * functions;\n#         * expansions «$var», «${var}», «${var:-default}», «${var+SET}»,\n#           «${var#prefix}», «${var%suffix}», and «$( cmd )»;\n#         * compound commands having a testable exit status, especially «case»;\n#         * various built-in commands including «command», «set», and «ulimit».\n#\n#   Important for patching:\n#\n#   (2) This script targets any POSIX shell, so it avoids extensions provided\n#       by Bash, Ksh, etc; in particular arrays are avoided.\n#\n#       The \"traditional\" practice of packing multiple parameters into a\n#       space-separated string is a well documented source of bugs and security\n#       problems, so this is (mostly) avoided, by progressively accumulating\n#       options in \"$@\", and eventually passing that to Java.\n#\n#       Where the inherited environment variables (DEFAULT_JVM_OPTS, JAVA_OPTS,\n#       and GRADLE_OPTS) rely on word-splitting, this is performed explicitly;\n#       see the in-line comments for details.\n#\n#       There are tweaks for specific operating systems such as AIX, CygWin,\n#       Darwin, MinGW, and NonStop.\n#\n#   (3) This script is generated from the Groovy template\n#       https://github.com/gradle/gradle/blob/master/subprojects/plugins/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt\n#       within the Gradle project.\n#\n#       You can find Gradle at https://github.com/gradle/gradle/.\n#\n##############################################################################\n\n# Attempt to set APP_HOME\n\n# Resolve links: $0 may be a link\napp_path=$0\n\n# Need this for daisy-chained symlinks.\nwhile\n    APP_HOME=${app_path%\"${app_path##*/}\"}  # leaves a trailing /; empty if no leading path\n    [ -h \"$app_path\" ]\ndo\n    ls=$( ls -ld \"$app_path\" )\n    link=${ls#*' -> '}\n    case $link in             #(\n      /*)   app_path=$link ;; #(\n      *)    app_path=$APP_HOME$link ;;\n    esac\ndone\n\nAPP_HOME=$( cd \"${APP_HOME:-./}\" && pwd -P ) || exit\n\nAPP_NAME=\"Gradle\"\nAPP_BASE_NAME=${0##*/}\n\n# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.\nDEFAULT_JVM_OPTS='\"-Xmx64m\" \"-Xms64m\"'\n\n# Use the maximum available, or set MAX_FD != -1 to use that value.\nMAX_FD=maximum\n\nwarn () {\n    echo \"$*\"\n} >&2\n\ndie () {\n    echo\n    echo \"$*\"\n    echo\n    exit 1\n} >&2\n\n# OS specific support (must be 'true' or 'false').\ncygwin=false\nmsys=false\ndarwin=false\nnonstop=false\ncase \"$( uname )\" in                #(\n  CYGWIN* )         cygwin=true  ;; #(\n  Darwin* )         darwin=true  ;; #(\n  MSYS* | MINGW* )  msys=true    ;; #(\n  NONSTOP* )        nonstop=true ;;\nesac\n\nCLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar\n\n\n# Determine the Java command to use to start the JVM.\nif [ -n \"$JAVA_HOME\" ] ; then\n    if [ -x \"$JAVA_HOME/jre/sh/java\" ] ; then\n        # IBM's JDK on AIX uses strange locations for the executables\n        JAVACMD=$JAVA_HOME/jre/sh/java\n    else\n        JAVACMD=$JAVA_HOME/bin/java\n    fi\n    if [ ! -x \"$JAVACMD\" ] ; then\n        die \"ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME\n\nPlease set the JAVA_HOME variable in your environment to match the\nlocation of your Java installation.\"\n    fi\nelse\n    JAVACMD=java\n    which java >/dev/null 2>&1 || die \"ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.\n\nPlease set the JAVA_HOME variable in your environment to match the\nlocation of your Java installation.\"\nfi\n\n# Increase the maximum file descriptors if we can.\nif ! \"$cygwin\" && ! \"$darwin\" && ! \"$nonstop\" ; then\n    case $MAX_FD in #(\n      max*)\n        MAX_FD=$( ulimit -H -n ) ||\n            warn \"Could not query maximum file descriptor limit\"\n    esac\n    case $MAX_FD in  #(\n      '' | soft) :;; #(\n      *)\n        ulimit -n \"$MAX_FD\" ||\n            warn \"Could not set maximum file descriptor limit to $MAX_FD\"\n    esac\nfi\n\n# Collect all arguments for the java command, stacking in reverse order:\n#   * args from the command line\n#   * the main class name\n#   * -classpath\n#   * -D...appname settings\n#   * --module-path (only if needed)\n#   * DEFAULT_JVM_OPTS, JAVA_OPTS, and GRADLE_OPTS environment variables.\n\n# For Cygwin or MSYS, switch paths to Windows format before running java\nif \"$cygwin\" || \"$msys\" ; then\n    APP_HOME=$( cygpath --path --mixed \"$APP_HOME\" )\n    CLASSPATH=$( cygpath --path --mixed \"$CLASSPATH\" )\n\n    JAVACMD=$( cygpath --unix \"$JAVACMD\" )\n\n    # Now convert the arguments - kludge to limit ourselves to /bin/sh\n    for arg do\n        if\n            case $arg in                                #(\n              -*)   false ;;                            # don't mess with options #(\n              /?*)  t=${arg#/} t=/${t%%/*}              # looks like a POSIX filepath\n                    [ -e \"$t\" ] ;;                      #(\n              *)    false ;;\n            esac\n        then\n            arg=$( cygpath --path --ignore --mixed \"$arg\" )\n        fi\n        # Roll the args list around exactly as many times as the number of\n        # args, so each arg winds up back in the position where it started, but\n        # possibly modified.\n        #\n        # NB: a `for` loop captures its iteration list before it begins, so\n        # changing the positional parameters here affects neither the number of\n        # iterations, nor the values presented in `arg`.\n        shift                   # remove old arg\n        set -- \"$@\" \"$arg\"      # push replacement arg\n    done\nfi\n\n# Collect all arguments for the java command;\n#   * $DEFAULT_JVM_OPTS, $JAVA_OPTS, and $GRADLE_OPTS can contain fragments of\n#     shell script including quotes and variable substitutions, so put them in\n#     double quotes to make sure that they get re-expanded; and\n#   * put everything else in single quotes, so that it's not re-expanded.\n\nset -- \\\n        \"-Dorg.gradle.appname=$APP_BASE_NAME\" \\\n        -classpath \"$CLASSPATH\" \\\n        org.gradle.wrapper.GradleWrapperMain \\\n        \"$@\"\n\n# Use \"xargs\" to parse quoted args.\n#\n# With -n1 it outputs one arg per line, with the quotes and backslashes removed.\n#\n# In Bash we could simply go:\n#\n#   readarray ARGS < <( xargs -n1 <<<\"$var\" ) &&\n#   set -- \"${ARGS[@]}\" \"$@\"\n#\n# but POSIX shell has neither arrays nor command substitution, so instead we\n# post-process each arg (as a line of input to sed) to backslash-escape any\n# character that might be a shell metacharacter, then use eval to reverse\n# that process (while maintaining the separation between arguments), and wrap\n# the whole thing up as a single \"set\" statement.\n#\n# This will of course break if any of these variables contains a newline or\n# an unmatched quote.\n#\n\neval \"set -- $(\n        printf '%s\\n' \"$DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS\" |\n        xargs -n1 |\n        sed ' s~[^-[:alnum:]+,./:=@_]~\\\\&~g; ' |\n        tr '\\n' ' '\n    )\" '\"$@\"'\n\nexec \"$JAVACMD\" \"$@\"\n"
  },
  {
    "path": "gradlew.bat",
    "content": "@rem\r\n@rem Copyright 2015 the original author or authors.\r\n@rem\r\n@rem Licensed under the Apache License, Version 2.0 (the \"License\");\r\n@rem you may not use this file except in compliance with the License.\r\n@rem You may obtain a copy of the License at\r\n@rem\r\n@rem      https://www.apache.org/licenses/LICENSE-2.0\r\n@rem\r\n@rem Unless required by applicable law or agreed to in writing, software\r\n@rem distributed under the License is distributed on an \"AS IS\" BASIS,\r\n@rem WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r\n@rem See the License for the specific language governing permissions and\r\n@rem limitations under the License.\r\n@rem\r\n\r\n@if \"%DEBUG%\" == \"\" @echo off\r\n@rem ##########################################################################\r\n@rem\r\n@rem  Gradle startup script for Windows\r\n@rem\r\n@rem ##########################################################################\r\n\r\n@rem Set local scope for the variables with windows NT shell\r\nif \"%OS%\"==\"Windows_NT\" setlocal\r\n\r\nset DIRNAME=%~dp0\r\nif \"%DIRNAME%\" == \"\" set DIRNAME=.\r\nset APP_BASE_NAME=%~n0\r\nset APP_HOME=%DIRNAME%\r\n\r\n@rem Resolve any \".\" and \"..\" in APP_HOME to make it shorter.\r\nfor %%i in (\"%APP_HOME%\") do set APP_HOME=%%~fi\r\n\r\n@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.\r\nset DEFAULT_JVM_OPTS=\"-Xmx64m\" \"-Xms64m\"\r\n\r\n@rem Find java.exe\r\nif defined JAVA_HOME goto findJavaFromJavaHome\r\n\r\nset JAVA_EXE=java.exe\r\n%JAVA_EXE% -version >NUL 2>&1\r\nif \"%ERRORLEVEL%\" == \"0\" goto execute\r\n\r\necho.\r\necho ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.\r\necho.\r\necho Please set the JAVA_HOME variable in your environment to match the\r\necho location of your Java installation.\r\n\r\ngoto fail\r\n\r\n:findJavaFromJavaHome\r\nset JAVA_HOME=%JAVA_HOME:\"=%\r\nset JAVA_EXE=%JAVA_HOME%/bin/java.exe\r\n\r\nif exist \"%JAVA_EXE%\" goto execute\r\n\r\necho.\r\necho ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME%\r\necho.\r\necho Please set the JAVA_HOME variable in your environment to match the\r\necho location of your Java installation.\r\n\r\ngoto fail\r\n\r\n:execute\r\n@rem Setup the command line\r\n\r\nset CLASSPATH=%APP_HOME%\\gradle\\wrapper\\gradle-wrapper.jar\r\n\r\n\r\n@rem Execute Gradle\r\n\"%JAVA_EXE%\" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% \"-Dorg.gradle.appname=%APP_BASE_NAME%\" -classpath \"%CLASSPATH%\" org.gradle.wrapper.GradleWrapperMain %*\r\n\r\n:end\r\n@rem End local scope for the variables with windows NT shell\r\nif \"%ERRORLEVEL%\"==\"0\" goto mainEnd\r\n\r\n:fail\r\nrem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of\r\nrem the _cmd.exe /c_ return code!\r\nif  not \"\" == \"%GRADLE_EXIT_CONSOLE%\" exit 1\r\nexit /b 1\r\n\r\n:mainEnd\r\nif \"%OS%\"==\"Windows_NT\" endlocal\r\n\r\n:omega\r\n"
  },
  {
    "path": "resources/provisioning.sh",
    "content": "#!/bin/bash\nexport DEBIAN_FRONTEND=noninteractive\napt-get -yq update && apt-get -yq install dante-server\n\ncat > /etc/danted.conf << EOF\nlogoutput: syslog\nuser.privileged: root\nuser.unprivileged: nobody\ninternal: 0.0.0.0 port=1080\nexternal: eth0\nsocksmethod: username\nclientmethod: none\nclient pass {\n    from: 0.0.0.0/0 to: 0.0.0.0/0\n}\nsocks pass {\n    from: 0.0.0.0/0 to: 0.0.0.0/0\n}\nEOF\n\nEXTERNAL_INTERFACE=$(ip route get 1 | awk '{print $5; exit}')\nsed -i \"s/external: eth0/external: $EXTERNAL_INTERFACE/\" /etc/danted.conf\n\nuseradd -r -s /bin/false burp-vps-proxy\necho 'burp-vps-proxy:CHANGEME' | chpasswd\n\nsystemctl restart danted.service\n"
  },
  {
    "path": "settings.gradle",
    "content": "/*\n * This file was generated by the Gradle 'init' task.\n *\n * The settings file is used to specify which projects to include in your build.\n *\n * Detailed information about configuring a multi-project build in Gradle can be found\n * in the user manual at https://docs.gradle.org/8.0.2/userguide/multi_project_builds.html\n */\n\nrootProject.name = 'burp-vps-proxy'\n"
  },
  {
    "path": "src/burp/BurpExtender.java",
    "content": "package burp;\n\nimport vpsproxy.Logger;\nimport vpsproxy.VPSProxy;\n\npublic class BurpExtender implements IBurpExtender, IExtensionStateListener {\n    private VPSProxy extension;\n\n    @Override\n    public void registerExtenderCallbacks(IBurpExtenderCallbacks callbacks) {\n        Logger.init(callbacks.getStdout(), null);\n\n        // Set our extension name\n        callbacks.setExtensionName(\"VPS Proxy\");\n\n        // Register callback to destroy VPS when our extension is unloaded\n        callbacks.registerExtensionStateListener(this);\n\n        // Create our main extension object\n        extension = new VPSProxy(callbacks);\n        callbacks.addSuiteTab(extension.getUI());\n    }\n\n    @Override\n    public void extensionUnloaded() {\n        extension.close();\n    }\n}\n"
  },
  {
    "path": "src/vpsproxy/Logger.java",
    "content": "package vpsproxy;\n\nimport java.io.OutputStream;\nimport java.io.PrintWriter;\nimport java.time.LocalDateTime;\nimport java.time.format.DateTimeFormatter;\n\npublic class Logger {\n    private static PrintWriter printWriter;\n    private static VPSProxyTab optionsTab;\n\n    public static void init(OutputStream stdout, VPSProxyTab tab) {\n        printWriter = new PrintWriter(stdout, true);\n        optionsTab = tab;\n    }\n\n    public static void log(String message) {\n        log(message, true);\n    }\n\n    public static void log(String message, boolean timestamp) {\n        if (timestamp) {\n            LocalDateTime now = LocalDateTime.now();\n            DateTimeFormatter formatter = DateTimeFormatter.ofPattern(\"yyyy-MM-dd HH:mm:ss\");\n            String ts = now.format(formatter);\n            message = String.format(\"[%s] %s\\n\", ts, message);\n        }\n\n        if (printWriter != null) {\n            printWriter.printf(\"%s\", message);\n        }\n\n        if (optionsTab != null) {\n            optionsTab.log(message);\n        }\n    }\n}\n"
  },
  {
    "path": "src/vpsproxy/ProxySettings.java",
    "content": "package vpsproxy;\n\npublic class ProxySettings {\n    private String ip;\n    private String port;\n    private String username;\n    private String password;\n\n    public ProxySettings(String ip, String port, String username, String password) {\n        this.ip = ip;\n        this.port = port;\n        this.username = username;\n        this.password = password;\n    }\n\n    public String getIp() {\n        return ip;\n    }\n\n    public String getPort() {\n        return port;\n    }\n\n    public String getUsername() {\n        return username;\n    }\n\n    public String getPassword() {\n        return password;\n    }\n}\n"
  },
  {
    "path": "src/vpsproxy/RandomString.java",
    "content": "package vpsproxy;\n\nimport java.security.SecureRandom;\nimport java.util.Random;\n\npublic class RandomString {\n    private static final String ALPHABET = \"0123456789abcdefghijklmnopqrstuvwxyz\";\n    private static final Random RANDOM = new SecureRandom();\n\n    public static String generate(int n) {\n        StringBuilder sb = new StringBuilder(6);\n        for (int i = 0; i < n; i++) {\n            int randomIndex = RANDOM.nextInt(ALPHABET.length());\n            char randomChar = ALPHABET.charAt(randomIndex);\n            sb.append(randomChar);\n        }\n\n        return sb.toString();\n    }\n}\n"
  },
  {
    "path": "src/vpsproxy/SettingsKeys.java",
    "content": "package vpsproxy;\n\npublic final class SettingsKeys {\n    // Exposed settings\n    public static final String DESTROY_PROXY_ON_EXIT = \"DestroyProxyOnExit\";\n\n    // Internal states\n    public static final String BURP_INSTANCE_ID = \"BurpInstanceId\";\n    public static final String LAST_STATE = \"LastState\";\n    public static final String CURRENT_PROVIDER = \"CurrentProvider\";\n    public static final String PROXY_SETTINGS_BACKUP = \"ProxySettingsBackup\";\n    public static final String PROXY_SETTINGS = \"ProxySettings\";\n}\n"
  },
  {
    "path": "src/vpsproxy/VPSProxy.java",
    "content": "package vpsproxy;\n\nimport java.util.LinkedHashMap;\nimport java.util.Map;\nimport burp.IBurpExtenderCallbacks;\nimport vpsproxy.providers.DigitalOceanProvider;\nimport vpsproxy.providers.Provider.ProviderException;\nimport vpsproxy.providers.*;\n\npublic class VPSProxy {\n    private static final String PROXY_CONFIG_TEMPLATE = \"{\\\"project_options\\\":{\\\"connections\\\":{\\\"socks_proxy\\\":{\\\"dns_over_socks\\\":false,\\\"host\\\":\\\"%s\\\",\\\"password\\\":\\\"%s\\\",\\\"port\\\":%s,\\\"use_proxy\\\":true,\\\"use_user_options\\\":false,\\\"username\\\":\\\"%s\\\"}}}}\";\n\n    private IBurpExtenderCallbacks callbacks;\n    private VPSProxyTab optionsTab;\n\n    private Map<String, Provider> providerMap;\n\n    public VPSProxy(IBurpExtenderCallbacks callbacks) {\n        this.callbacks = callbacks;\n        createBurpInstanceId();\n\n        providerMap = new LinkedHashMap<>();\n        addProvider(new AWSProvider(callbacks));\n        addProvider(new DigitalOceanProvider(callbacks));\n        addProvider(new LinodeProvider(callbacks));\n\n        optionsTab = new VPSProxyTab(this, providerMap);\n        Logger.init(callbacks.getStdout(), optionsTab);\n\n        restorePreviousProxy();\n    }\n\n    public VPSProxyTab getUI() {\n        return optionsTab;\n    }\n\n    public void close() {\n        String destroyProxySetting = callbacks.loadExtensionSetting(SettingsKeys.DESTROY_PROXY_ON_EXIT);\n        boolean destroyProxy = destroyProxySetting == null || Boolean.parseBoolean(destroyProxySetting);\n\n        if (!destroyProxy)\n            return;\n\n        Provider currentProvider = optionsTab.getSelectedProvider();\n        if (currentProvider != null) {\n            try {\n                destroyInstance(currentProvider);\n            } catch (ProviderException e) {\n            } catch (Exception e) {\n                Logger.log(String.format(\"Unhandled exception: %s\", e.getMessage()));\n            }\n        }\n    }\n\n    protected IBurpExtenderCallbacks getCallbacks() {\n        return callbacks;\n    }\n\n    protected void startInstance(Provider provider) throws ProviderException {\n        try {\n            ProxySettings proxy = provider.startInstance();\n            configureProxy(proxy);\n        } catch (ProviderException e) {\n            Logger.log(e.getMessage());\n            throw e;\n        } catch (Exception e) {\n            Logger.log(String.format(\"Unhandled exception: %s\", e.getMessage()));\n            throw e;\n        }\n    }\n\n    protected void destroyInstance(Provider provider) throws ProviderException {\n        try {\n            provider.destroyInstance();\n            resetProxySettings();\n            optionsTab.setStoppedState();\n        } catch (ProviderException e) {\n            Logger.log(e.getMessage());\n            throw e;\n        } catch (Exception e) {\n            Logger.log(String.format(\"Unhandled exception: %s\", e.getMessage()));\n            throw e;\n        }\n    }\n\n    protected void configureProxy(ProxySettings proxy) {\n        Logger.log(String.format(\"Configuring proxy %s:%s:%s:%s\", proxy.getIp(), proxy.getPort(), proxy.getUsername(),\n                proxy.getPassword()));\n\n        // Save current config\n        String configBackup = callbacks.saveConfigAsJson(\"project_options.connections.socks_proxy\");\n        callbacks.saveExtensionSetting(SettingsKeys.PROXY_SETTINGS_BACKUP, configBackup);\n\n        // Set new proxy settings\n        String config = String.format(PROXY_CONFIG_TEMPLATE, proxy.getIp(), proxy.getPassword(), proxy.getPort(),\n                proxy.getUsername());\n        callbacks.loadConfigFromJson(config);\n        callbacks.saveExtensionSetting(SettingsKeys.PROXY_SETTINGS, config);\n\n        Logger.log(\"Proxy configured. The VPS could still be provisioning, please give it a few minutes.\");\n    }\n\n    protected void resetProxySettings() {\n        String config = callbacks.loadExtensionSetting(SettingsKeys.PROXY_SETTINGS_BACKUP);\n        if (config != null) {\n            Logger.log(\"Restoring proxy settings\");\n            callbacks.loadConfigFromJson(config);\n            callbacks.saveExtensionSetting(SettingsKeys.PROXY_SETTINGS_BACKUP, null);\n            callbacks.saveExtensionSetting(SettingsKeys.PROXY_SETTINGS, null);\n        }\n    }\n\n    protected void restorePreviousProxy() {\n        String config = callbacks.loadExtensionSetting(SettingsKeys.PROXY_SETTINGS);\n        if (config != null) {\n            Logger.log(\"Setting proxy from previous session\");\n            callbacks.loadConfigFromJson(config);\n        }\n    }\n\n    private void createBurpInstanceId() {\n        String instanceId = callbacks.loadExtensionSetting(SettingsKeys.BURP_INSTANCE_ID);\n\n        if (instanceId == null) {\n            String id = RandomString.generate(6);\n            callbacks.saveExtensionSetting(SettingsKeys.BURP_INSTANCE_ID, id);\n        }\n    }\n\n    private void addProvider(Provider provider) {\n        providerMap.put(provider.getName(), provider);\n    }\n}\n"
  },
  {
    "path": "src/vpsproxy/VPSProxyTab.java",
    "content": "package vpsproxy;\n\nimport javax.swing.*;\nimport javax.swing.event.DocumentEvent;\nimport javax.swing.event.DocumentListener;\n\nimport burp.ITab;\nimport java.awt.*;\nimport java.awt.event.*;\nimport java.awt.event.ActionListener;\nimport java.util.Map;\nimport vpsproxy.providers.Provider;\n\npublic class VPSProxyTab implements ITab {\n    private Map<String, Provider> providerMap;\n    VPSProxy extension;\n\n    private JPanel panel;\n    private JPanel providerPanel;\n    private JCheckBox destroyProxyCheckBox;\n    private JLabel destroyProxyLabel;\n    private JComboBox<String> providerComboBox;\n    private JButton deployButton;\n    private JButton stopButton;\n    private JTextArea logTextArea;\n    private JScrollPane logScrollPane;\n\n    private Font defaultFont;\n    private Font headerFont;\n    private Color headerColor;\n    private int gapSize = 25;\n\n    Thread workerThread;\n\n    public VPSProxyTab(VPSProxy extension, Map<String, Provider> providers) {\n        providerMap = providers;\n        this.extension = extension;\n\n        // Initialize fonts and colors\n        JLabel defaultLabel = new JLabel();\n        extension.getCallbacks().customizeUiComponent(defaultLabel);\n\n        defaultFont = defaultLabel.getFont();\n        headerFont = defaultFont.deriveFont(Font.BOLD, defaultFont.getSize() + 2);\n\n        Color defaultColor = defaultLabel.getForeground();\n        if (defaultColor.getRed() > 128 && defaultColor.getGreen() > 128 && defaultColor.getBlue() > 128)\n            headerColor = Color.WHITE;\n        else\n            headerColor = Color.BLACK;\n\n        // Initialize main panel\n        this.panel = new JPanel();\n\n        // Intro UI elements\n        JLabel introHeaderLabel = new JLabel(\"Burp VPS Proxy\");\n        introHeaderLabel.setFont(headerFont);\n        introHeaderLabel.setForeground(headerColor);\n\n        JLabel introHelp1Label = new JLabel(\n                \"Select the VPS provider you want to use and enter the proper API key(s). Then, you can click Deploy to launch a new proxy.\");\n        JLabel introHelp2Label = new JLabel(\n                \"Once created, the extension will automatically configure your SOCKS5 proxy in Burp -> Settings -> Network -> Connections.\");\n        JLabel introHelp3Label = new JLabel(\n                \"The proxy server will automatically be terminated when Burp exits or the extension is unloaded.\");\n\n        // Options UI elements\n        JLabel optionsHeaderLabel = new JLabel(\"Options\");\n        optionsHeaderLabel.setFont(headerFont);\n        optionsHeaderLabel.setForeground(headerColor);\n\n        destroyProxyCheckBox = new JCheckBox();\n        String destroyProxy = extension.getCallbacks().loadExtensionSetting(SettingsKeys.DESTROY_PROXY_ON_EXIT);\n        if (destroyProxy == null || destroyProxy.equals(\"true\")) {\n            destroyProxyCheckBox.setSelected(true);\n        }\n        destroyProxyLabel = new JLabel(\"Destroy proxy when Burp exits\");\n\n        // Provider UI elements\n        JLabel providerHeaderLabel = new JLabel(\"Provider\");\n        providerHeaderLabel.setFont(headerFont);\n        providerHeaderLabel.setForeground(headerColor);\n\n        providerComboBox = new JComboBox<>();\n        providerComboBox.setMaximumSize(new Dimension(150, providerComboBox.getPreferredSize().height));\n        for (String providerName : providerMap.keySet()) {\n            providerComboBox.addItem(providerName);\n        }\n\n        String selectedProviderName = extension.getCallbacks().loadExtensionSetting(SettingsKeys.CURRENT_PROVIDER);\n        providerComboBox.setSelectedItem(selectedProviderName);\n\n        deployButton = new JButton(\"Deploy\");\n        stopButton = new JButton(\"Stop\");\n        stopButton.setEnabled(false);\n\n        // Provider settings UI elements\n        FlowLayout providerLayout = new FlowLayout(FlowLayout.LEFT);\n        providerLayout.setHgap(0);\n        providerLayout.setVgap(0);\n\n        providerPanel = new JPanel(providerLayout);\n        providerPanel.setMaximumSize(new Dimension(Short.MAX_VALUE, 200));\n\n        Provider currentProvider = getSelectedProvider();\n        if (currentProvider != null) {\n            providerPanel.add(currentProvider.getUI());\n        }\n\n        // Log UI elements\n        JLabel logHeaderLabel = new JLabel(\"Log\");\n        logHeaderLabel.setFont(headerFont);\n        logHeaderLabel.setForeground(headerColor);\n\n        logTextArea = new JTextArea();\n        logTextArea.setEditable(false);\n\n        int logScrollPaneHeight = 400;\n        logScrollPane = new JScrollPane(logTextArea);\n        logScrollPane.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_ALWAYS);\n        logScrollPane.setMaximumSize(new Dimension(Short.MAX_VALUE, logScrollPaneHeight));\n\n        JScrollBar verticalBar = logScrollPane.getVerticalScrollBar();\n        verticalBar.setValue(verticalBar.getMaximum());\n\n        // Layout\n        GroupLayout layout = new GroupLayout(this.panel);\n        layout.setAutoCreateGaps(true);\n        layout.setAutoCreateContainerGaps(true);\n\n        layout.setHorizontalGroup(layout.createParallelGroup()\n                .addComponent(introHeaderLabel)\n                .addComponent(introHelp1Label)\n                .addComponent(introHelp2Label)\n                .addComponent(introHelp3Label)\n                .addComponent(optionsHeaderLabel)\n                .addGroup(layout.createSequentialGroup()\n                        .addComponent(destroyProxyCheckBox)\n                        .addComponent(destroyProxyLabel))\n                .addComponent(providerHeaderLabel)\n                .addGroup(layout.createSequentialGroup()\n                        .addComponent(providerComboBox)\n                        .addComponent(deployButton)\n                        .addComponent(stopButton))\n                .addComponent(providerPanel)\n                .addComponent(logHeaderLabel)\n                .addComponent(logScrollPane));\n\n        layout.setVerticalGroup(layout.createSequentialGroup()\n                .addComponent(introHeaderLabel)\n                .addComponent(introHelp1Label)\n                .addComponent(introHelp2Label)\n                .addComponent(introHelp3Label)\n                .addPreferredGap(LayoutStyle.ComponentPlacement.RELATED, GroupLayout.DEFAULT_SIZE, gapSize)\n                .addComponent(optionsHeaderLabel)\n                .addGroup(layout.createParallelGroup(GroupLayout.Alignment.BASELINE)\n                        .addComponent(destroyProxyCheckBox)\n                        .addComponent(destroyProxyLabel))\n                .addPreferredGap(LayoutStyle.ComponentPlacement.RELATED, GroupLayout.DEFAULT_SIZE, gapSize)\n                .addComponent(providerHeaderLabel)\n                .addGroup(layout.createParallelGroup(GroupLayout.Alignment.BASELINE)\n                        .addComponent(providerComboBox)\n                        .addComponent(deployButton)\n                        .addComponent(stopButton))\n                .addPreferredGap(LayoutStyle.ComponentPlacement.RELATED, GroupLayout.DEFAULT_SIZE, 5)\n                .addComponent(providerPanel)\n                .addPreferredGap(LayoutStyle.ComponentPlacement.RELATED, GroupLayout.DEFAULT_SIZE, 2 * gapSize)\n                .addPreferredGap(LayoutStyle.ComponentPlacement.RELATED, 0, Short.MAX_VALUE)\n                .addComponent(logHeaderLabel)\n                .addComponent(logScrollPane, GroupLayout.PREFERRED_SIZE, logScrollPaneHeight,\n                        GroupLayout.PREFERRED_SIZE));\n\n        layout.linkSize(deployButton, stopButton);\n\n        this.panel.setLayout(layout);\n\n        String lastState = extension.getCallbacks().loadExtensionSetting(SettingsKeys.LAST_STATE);\n        if (lastState != null && lastState.equals(\"running\")) {\n            setRunningState();\n        }\n\n        installHandlers();\n    }\n\n    @Override\n    public String getTabCaption() {\n        return \"VPS Proxy\";\n    }\n\n    @Override\n    public Component getUiComponent() {\n        return this.panel;\n    }\n\n    public void log(String message) {\n        logTextArea.append(message);\n    }\n\n    private void installHandlers() {\n        destroyProxyCheckBox.addActionListener(new ActionListener() {\n            @Override\n            public void actionPerformed(ActionEvent e) {\n                if (destroyProxyCheckBox.isSelected()) {\n                    extension.getCallbacks().saveExtensionSetting(SettingsKeys.DESTROY_PROXY_ON_EXIT, \"true\");\n                } else {\n                    extension.getCallbacks().saveExtensionSetting(SettingsKeys.DESTROY_PROXY_ON_EXIT, \"false\");\n                }\n            }\n        });\n\n        destroyProxyLabel.addMouseListener(new MouseAdapter() {\n            @Override\n            public void mouseClicked(MouseEvent e) {\n                destroyProxyCheckBox.doClick();\n            }\n        });\n\n        providerComboBox.addActionListener(new ActionListener() {\n            @Override\n            public void actionPerformed(ActionEvent e) {\n                Provider selectedProvider = getSelectedProvider();\n                if (selectedProvider == null) {\n                    return;\n                }\n\n                // Replace the provider UI panel with the new provider UI\n                providerPanel.removeAll();\n                providerPanel.add(selectedProvider.getUI());\n                providerPanel.revalidate();\n                providerPanel.repaint();\n\n                extension.getCallbacks().saveExtensionSetting(SettingsKeys.CURRENT_PROVIDER,\n                        selectedProvider.getName());\n            }\n        });\n\n        deployButton.addActionListener(new ActionListener() {\n            @Override\n            public void actionPerformed(ActionEvent e) {\n                Provider selectedProvider = getSelectedProvider();\n                if (selectedProvider == null) {\n                    Logger.log(\"No provider selected\");\n                    return;\n                }\n\n                if (workerThread != null && workerThread.isAlive()) {\n                    Logger.log(\"Worker thread is already started!\");\n                    return;\n                }\n\n                setRunningState();\n\n                workerThread = new Thread(() -> {\n                    try {\n                        extension.startInstance(selectedProvider);\n                    } catch (Exception ex) {\n                        setStoppedState();\n                    }\n                });\n                workerThread.start();\n            }\n        });\n\n        stopButton.addActionListener(new ActionListener() {\n            @Override\n            public void actionPerformed(ActionEvent e) {\n                Provider selectedProvider = getSelectedProvider();\n                if (selectedProvider == null) {\n                    Logger.log(\"No provider selected\");\n                    return;\n                }\n\n                if (workerThread != null && workerThread.isAlive()) {\n                    Logger.log(\"Wait for instance to finish deploying...\");\n                    return;\n                }\n\n                setStoppedState();\n\n                try {\n                    extension.destroyInstance(selectedProvider);\n                } catch (Exception ex) {\n                }\n            }\n        });\n\n        logTextArea.getDocument().addDocumentListener(new DocumentListener() {\n            @Override\n            public void insertUpdate(DocumentEvent e) {\n                JScrollBar verticalBar = logScrollPane.getVerticalScrollBar();\n                SwingUtilities.invokeLater(new Runnable() {\n                    @Override\n                    public void run() {\n                        verticalBar.setValue(verticalBar.getMaximum());\n                    }\n                });\n            }\n\n            @Override\n            public void removeUpdate(DocumentEvent e) {\n                // Do nothing\n            }\n\n            @Override\n            public void changedUpdate(DocumentEvent e) {\n                // Do nothing\n            }\n        });\n    }\n\n    protected Provider getSelectedProvider() {\n        Object selectedItem = providerComboBox.getSelectedItem();\n        if (selectedItem == null) {\n            return null;\n        }\n\n        String providerName = selectedItem.toString();\n        Provider provider = providerMap.get(providerName);\n        if (provider == null) {\n            return null;\n        }\n\n        return provider;\n    }\n\n    public void setRunningState() {\n        extension.getCallbacks().saveExtensionSetting(SettingsKeys.LAST_STATE, \"running\");\n\n        stopButton.setEnabled(true);\n        stopButton.requestFocusInWindow();\n        providerComboBox.setEnabled(false);\n        deployButton.setEnabled(false);\n\n        Component[] providerPanelComponents = providerPanel.getComponents();\n        if (providerPanelComponents.length != 0) {\n            JPanel panel = (JPanel) providerPanelComponents[0];\n            Component[] components = panel.getComponents();\n            for (Component component : components) {\n                component.setEnabled(false);\n            }\n        }\n    }\n\n    public void setStoppedState() {\n        extension.getCallbacks().saveExtensionSetting(SettingsKeys.LAST_STATE, \"stopped\");\n\n        deployButton.setEnabled(true);\n        deployButton.requestFocusInWindow();\n        providerComboBox.setEnabled(true);\n        stopButton.setEnabled(false);\n\n        Component[] providerPanelComponents = providerPanel.getComponents();\n        if (providerPanelComponents.length != 0) {\n            JPanel panel = (JPanel) providerPanelComponents[0];\n            Component[] components = panel.getComponents();\n            for (Component component : components) {\n                component.setEnabled(true);\n            }\n        }\n    }\n}\n"
  },
  {
    "path": "src/vpsproxy/providers/AWSProvider.java",
    "content": "package vpsproxy.providers;\n\nimport java.awt.*;\nimport java.awt.event.*;\nimport java.io.IOException;\nimport java.util.Base64;\nimport java.util.Collections;\nimport java.util.Comparator;\nimport java.util.Optional;\nimport javax.swing.*;\nimport javax.swing.event.*;\nimport burp.IBurpExtenderCallbacks;\nimport vpsproxy.*;\n\nimport software.amazon.awssdk.auth.credentials.*;\nimport software.amazon.awssdk.regions.Region;\nimport software.amazon.awssdk.services.ec2.Ec2Client;\nimport software.amazon.awssdk.services.ec2.model.*;\nimport software.amazon.awssdk.services.ec2.model.Image;\n\npublic class AWSProvider extends Provider {\n    final private String INSTANCE_TAG = \"burp-vps-proxy\";\n    final private String AWS_OS_TYPE = \"debian-11\";\n    final private String AWS_INSTANCE_ARCH = \"arm64\";\n    final private InstanceType AWS_INSTANCE_TYPE = InstanceType.T4_G_NANO;\n\n    final private String AWS_ACCESS_KEY_SETTING = \"ProviderAWSAccessKey\";\n    final private String AWS_SECRET_KEY_SETTING = \"ProviderAWSSecretKey\";\n    final private String AWS_REGION_SETTING = \"ProviderAWSRegion\";\n    final private String[] AWS_REGIONS = {\n        \"us-east-2\",\n        \"us-east-1\",\n        \"us-west-1\",\n        \"us-west-2\",\n        \"af-south-1\",\n        \"ap-east-1\",\n        \"ap-south-2\",\n        \"ap-southeast-3\",\n        \"ap-southeast-4\",\n        \"ap-south-1\",\n        \"ap-northeast-3\",\n        \"ap-northeast-2\",\n        \"ap-southeast-1\",\n        \"ap-southeast-2\",\n        \"ap-northeast-1\",\n        \"ca-central-1\",\n        \"eu-central-1\",\n        \"eu-west-1\",\n        \"eu-west-2\",\n        \"eu-south-1\",\n        \"eu-west-3\",\n        \"eu-south-2\",\n        \"eu-north-1\",\n        \"eu-central-2\",\n        \"me-south-1\",\n        \"me-central-1\",\n        \"sa-east-1\",\n    };\n\n    private IBurpExtenderCallbacks callbacks;\n\n    private String awsRegion = \"us-east-1\";\n    private Ec2Client ec2Client;\n\n    public AWSProvider(IBurpExtenderCallbacks callbacks) {\n        this.callbacks = callbacks;\n    }\n\n    @Override\n    public String getName() {\n        return \"AWS EC2\";\n    }\n\n    @Override\n    public ProxySettings startInstance() throws ProviderException {\n        log(\"creating a new instance\");\n\n        Ec2Client ec2Client;\n        try {\n            ec2Client = createClient();\n        } catch (ProviderException e) {\n            throw e;\n        }\n\n        String password = RandomString.generate(12);\n        String script;\n        try {\n            script = getProvisioningScript(password);\n        } catch (IOException e) {\n            throw new ProviderException(String.format(\"error loading provisioning script: %s\", e.getMessage()), e);\n        }\n\n        String amiId;\n        try {\n            amiId = getAmiId(AWS_OS_TYPE, awsRegion);\n        } catch (ProviderException e) {\n            throw e;\n        }\n\n        String securityGroupId;\n        try {\n            securityGroupId = createSecurityGroup(\"burp-vps-proxy\", \"Allow traffic to port 1080 for the Burp SOCKS Proxy\");\n        } catch (ProviderException e) {\n            throw e;\n        }\n\n        String instanceName = String.format(\"burp-vps-proxy-%s\", RandomString.generate(4));\n        Tag nameTag = Tag.builder()\n            .key(\"Name\")\n            .value(instanceName)\n            .build();\n\n        String tagValue = callbacks.loadExtensionSetting(SettingsKeys.BURP_INSTANCE_ID);\n        Tag proxyTag = Tag.builder()\n            .key(INSTANCE_TAG)\n            .value(tagValue)\n            .build();\n\n        TagSpecification tagSpecification = TagSpecification.builder()\n            .resourceType(\"instance\")\n            .tags(nameTag, proxyTag)\n            .build();\n\n        RunInstancesRequest runRequest = RunInstancesRequest.builder()\n            .instanceType(AWS_INSTANCE_TYPE)\n            .maxCount(1)\n            .minCount(1)\n            .imageId(amiId)\n            .userData(script)\n            .tagSpecifications(tagSpecification)\n            .securityGroupIds(securityGroupId)\n            .build();\n\n        RunInstancesResponse runResponse;\n        String instanceId;\n        try {\n            runResponse = ec2Client.runInstances(runRequest);\n            instanceId = runResponse.instances().get(0).instanceId();\n            ec2Client.waiter().waitUntilInstanceRunning(r -> r.instanceIds(instanceId));\n        } catch (Exception e) {\n            throw new ProviderException(String.format(\"error creating instance: %s\", e.getMessage()), e);\n        }\n\n        DescribeInstancesRequest describeRequest = DescribeInstancesRequest.builder()\n            .instanceIds(instanceId)\n            .build();\n\n        DescribeInstancesResponse describeResponse;\n        try {\n            describeResponse = ec2Client.describeInstances(describeRequest);\n        } catch (Exception e) {\n            throw new ProviderException(String.format(\"error reading newly created instance: %s\", e.getMessage()), e);\n        }\n\n        String publicIpAddress = describeResponse.reservations().get(0).instances().get(0).publicIpAddress();\n        return createProxySettings(publicIpAddress, password);\n    }\n\n    @Override\n    public void destroyInstance() throws ProviderException {\n        Ec2Client ec2Client;\n        try {\n            ec2Client = createClient();\n        } catch (ProviderException e) {\n            throw e;\n        }\n\n        String tagValue = callbacks.loadExtensionSetting(SettingsKeys.BURP_INSTANCE_ID);\n\n        DescribeInstancesRequest describeRequest = DescribeInstancesRequest.builder()\n            .filters(\n                Filter.builder()\n                    .name(\"tag:\" + INSTANCE_TAG)\n                    .values(tagValue)\n                    .build(),\n                Filter.builder()\n                    .name(\"instance-state-name\")\n                    .values(\"pending\", \"running\", \"rebooting\", \"stopping\", \"stopped\")\n                    .build())\n            .build();\n\n        DescribeInstancesResponse describeResponse;\n        try {\n            describeResponse = ec2Client.describeInstances(describeRequest);\n        } catch (Exception e) {\n            throw new ProviderException(String.format(\"error listing instances: %s\", e.getMessage()), e);\n        }\n\n        describeResponse.reservations().stream()\n            .flatMap(reservation -> reservation.instances().stream())\n            .forEach(instance -> {\n                String instanceId = instance.instanceId();\n                String instanceName = \"\";\n                for (Tag tag : instance.tags()) {\n                    if (tag.key().equals(\"Name\")) {\n                        instanceName = tag.value();\n                        break;\n                    }\n                }\n\n                TerminateInstancesRequest terminateRequest = TerminateInstancesRequest.builder()\n                    .instanceIds(instanceId)\n                    .build();\n\n                try {\n                    ec2Client.terminateInstances(terminateRequest);\n                    logf(\"instance %s deleted\", instanceName);\n                } catch (Exception e) {\n                    logf(\"error deleting instance '%s': %s\", instanceName, e.getMessage());\n                }\n            });\n    }\n\n    @Override\n    public JComponent getUI() {\n        JPanel panel = new JPanel();\n        panel.setLayout(new BoxLayout(panel, BoxLayout.Y_AXIS));\n\n        JLabel awsAccessKeyLabel = new JLabel(\"AWS Access Key:\");\n        awsAccessKeyLabel.setAlignmentX(Component.LEFT_ALIGNMENT);\n\n        JTextField awsAccessKeyTextField = new JTextField();\n        awsAccessKeyTextField.setAlignmentX(Component.LEFT_ALIGNMENT);\n        awsAccessKeyTextField.setPreferredSize(new Dimension(200, awsAccessKeyTextField.getPreferredSize().height));\n        awsAccessKeyTextField.setText(callbacks.loadExtensionSetting(AWS_ACCESS_KEY_SETTING));\n\n        JLabel awsSecretKeyLabel = new JLabel(\"AWS Secret Key:\");\n        awsSecretKeyLabel.setAlignmentX(Component.LEFT_ALIGNMENT);\n\n        JPasswordField awsSecretKeyPasswordField = new JPasswordField();\n        awsSecretKeyPasswordField.setAlignmentX(Component.LEFT_ALIGNMENT);\n        awsSecretKeyPasswordField.setPreferredSize(new Dimension(200, awsSecretKeyPasswordField.getPreferredSize().height));\n        awsSecretKeyPasswordField.setText(callbacks.loadExtensionSetting(AWS_SECRET_KEY_SETTING));\n\n        JLabel awsRegionLabel = new JLabel(\"Region:\");\n        awsRegionLabel.setAlignmentX(Component.LEFT_ALIGNMENT);\n\n        JComboBox<String> awsRegionComboBox = new JComboBox<>();\n        awsRegionComboBox.setAlignmentX(Component.LEFT_ALIGNMENT);\n        awsRegionComboBox.setMaximumSize(new Dimension(125, awsRegionComboBox.getPreferredSize().height));\n        for (int i = 0; i < AWS_REGIONS.length; i++) {\n            awsRegionComboBox.addItem(AWS_REGIONS[i]);\n        }\n\n        String selectedRegion = callbacks.loadExtensionSetting(AWS_REGION_SETTING);\n        if (selectedRegion != null && !selectedRegion.isEmpty()) {\n            awsRegionComboBox.setSelectedItem(selectedRegion);\n        }\n\n        panel.add(awsAccessKeyLabel);\n        panel.add(Box.createRigidArea(new Dimension(0, 5)));\n        panel.add(awsAccessKeyTextField);\n        panel.add(Box.createRigidArea(new Dimension(0, 5)));\n        panel.add(awsSecretKeyLabel);\n        panel.add(Box.createRigidArea(new Dimension(0, 5)));\n        panel.add(awsSecretKeyPasswordField);\n        panel.add(Box.createRigidArea(new Dimension(0, 5)));\n        panel.add(awsRegionLabel);\n        panel.add(Box.createRigidArea(new Dimension(0, 5)));\n        panel.add(awsRegionComboBox);\n\n        awsAccessKeyTextField.getDocument().addDocumentListener(new DocumentListener() {\n            @Override\n            public void insertUpdate(DocumentEvent e) {\n                saveSetting();\n            }\n            @Override\n            public void removeUpdate(DocumentEvent e) {\n                saveSetting();\n            }\n            @Override\n            public void changedUpdate(DocumentEvent e) {\n                saveSetting();\n            }\n\n            private void saveSetting() {\n                String value = awsAccessKeyTextField.getText();\n                callbacks.saveExtensionSetting(AWS_ACCESS_KEY_SETTING, value);\n            }\n        });\n\n        awsSecretKeyPasswordField.getDocument().addDocumentListener(new DocumentListener() {\n            @Override\n            public void insertUpdate(DocumentEvent e) {\n                saveSetting();\n            }\n            @Override\n            public void removeUpdate(DocumentEvent e) {\n                saveSetting();\n            }\n            @Override\n            public void changedUpdate(DocumentEvent e) {\n                saveSetting();\n            }\n\n            private void saveSetting() {\n                String value = new String(awsSecretKeyPasswordField.getPassword());\n                callbacks.saveExtensionSetting(AWS_SECRET_KEY_SETTING, value);\n            }\n        });\n\n        awsRegionComboBox.addActionListener(new ActionListener() {\n            @Override\n            public void actionPerformed(ActionEvent e) {\n                Object selectedItem = awsRegionComboBox.getSelectedItem();\n                if (selectedItem == null) {\n                    return;\n                }\n\n                awsRegion = selectedItem.toString();\n                callbacks.saveExtensionSetting(AWS_REGION_SETTING, awsRegion);\n            }\n        });\n\n        return panel;\n    }\n\n    @Override\n    protected String getProvisioningScript(String password) throws IOException {\n        String script = super.getProvisioningScript(password);\n        return Base64.getEncoder().encodeToString(script.getBytes());\n    }\n\n    private Ec2Client createClient() throws ProviderException {\n        // Load the AWS keys from settings\n        String awsAccessKey = callbacks.loadExtensionSetting(AWS_ACCESS_KEY_SETTING);\n        String awsSecretKey = callbacks.loadExtensionSetting(AWS_SECRET_KEY_SETTING);\n\n        if (awsAccessKey == null || awsSecretKey == null || awsAccessKey.isEmpty() || awsSecretKey.isEmpty()) {\n            throw new ProviderException(\"missing API key(s)\", null);\n        }\n\n        try {\n            // Configure the region\n            Region region = Region.of(awsRegion);\n\n            // Create the client\n            AwsCredentials credentials = AwsBasicCredentials.create(awsAccessKey, awsSecretKey);\n            ec2Client = Ec2Client.builder()\n                .region(region)\n                .credentialsProvider(() -> credentials)\n                .build();\n        } catch (Exception e) {\n            throw new ProviderException(String.format(\"error creating AWS client: %s\", e.getMessage()), e);\n        }\n\n        return ec2Client;\n    }\n\n    private String getAmiId(String osType, String region) throws ProviderException {\n        // Filter by name\n        Filter osFilter = Filter.builder()\n            .name(\"name\")\n            .values(osType + \"-*\")\n            .build();\n\n        // Filter by architecture\n        Filter architectureFilter = Filter.builder()\n            .name(\"architecture\")\n            .values(AWS_INSTANCE_ARCH)\n            .build();\n\n        // Find the requested image\n        DescribeImagesRequest describeImagesRequest = DescribeImagesRequest.builder()\n            .owners(\"136693071363\") // Debian AMI owner ID\n            .filters(osFilter, architectureFilter)\n            .build();\n\n        DescribeImagesResponse describeImagesResponse;\n        try {\n            describeImagesResponse = ec2Client.describeImages(describeImagesRequest);\n        } catch (Exception e) {\n            throw new ProviderException(String.format(\"failed to find image '%s': %s\", osType, e.getMessage()), e);\n        }\n\n        Optional<Image> latestImage = describeImagesResponse.images().stream()\n            .max(Comparator.comparing(Image::creationDate));\n\n        // Return the most recent image found\n        return latestImage.map(Image::imageId).orElse(null);\n    }\n\n    private String createSecurityGroup(String groupName, String groupDescription) throws ProviderException {\n        // Check if the security group already exists\n        DescribeSecurityGroupsResponse describeResponse;\n        try {\n            describeResponse = ec2Client.describeSecurityGroups();\n        } catch (Exception e) {\n            throw new ProviderException(String.format(\"error listing security groups: %s\", e.getMessage()), e);\n        }\n\n        Optional<SecurityGroup> securityGroup = describeResponse.securityGroups().stream()\n            .filter(sg -> sg.groupName().equals(groupName))\n            .findFirst();\n\n        if (securityGroup.isPresent()) {\n            // Security group already exists, return its ID\n            return securityGroup.get().groupId();\n        }\n\n        // Create the security group\n        CreateSecurityGroupRequest createRequest = CreateSecurityGroupRequest.builder()\n            .groupName(groupName)\n            .description(groupDescription)\n            .build();\n\n        CreateSecurityGroupResponse createResponse;\n        try {\n            createResponse = ec2Client.createSecurityGroup(createRequest);\n        } catch (Exception e) {\n            throw new ProviderException(String.format(\"error creating security groups: %s\", e.getMessage()), e);\n        }\n\n        String groupId = createResponse.groupId();\n\n        // Add a rule to the security group that allows traffic to port 1080\n        IpRange ipRange = IpRange.builder()\n            .cidrIp(\"0.0.0.0/0\")\n            .build();\n        IpPermission ipPermission = IpPermission.builder()\n            .ipProtocol(\"tcp\")\n            .fromPort(1080)\n            .toPort(1080)\n            .ipRanges(ipRange)\n            .build();\n        AuthorizeSecurityGroupIngressRequest authorizeRequest = AuthorizeSecurityGroupIngressRequest.builder()\n            .groupId(groupId)\n            .ipPermissions(Collections.singletonList(ipPermission))\n            .build();\n\n        try {\n            ec2Client.authorizeSecurityGroupIngress(authorizeRequest);\n        } catch (Exception e) {\n            throw new ProviderException(String.format(\"error authorizing security group ingress: %s\", e.getMessage()), e);\n        }\n\n        // Return the ID of the security group\n        return groupId;\n    }\n\n    public class CreateSecurityGroupException extends Exception {\n        public CreateSecurityGroupException(String message, Throwable cause) {\n            super(message, cause);\n        }\n    }\n}\n"
  },
  {
    "path": "src/vpsproxy/providers/DigitalOceanProvider.java",
    "content": "package vpsproxy.providers;\n\nimport java.awt.*;\nimport java.awt.event.*;\nimport java.util.ArrayList;\nimport java.util.List;\nimport javax.swing.*;\nimport javax.swing.event.*;\nimport com.myjeeva.digitalocean.DigitalOcean;\nimport com.myjeeva.digitalocean.common.DropletStatus;\nimport com.myjeeva.digitalocean.impl.DigitalOceanClient;\nimport com.myjeeva.digitalocean.pojo.Droplet;\nimport burp.IBurpExtenderCallbacks;\nimport vpsproxy.*;\n\npublic class DigitalOceanProvider extends Provider {\n    final private String DO_API_KEY_SETTING = \"Provider_DigitalOcean_APIKey\";\n    final private String DO_REGION_SETTING = \"Provider_DigitalOcean_Region\";\n    final private String[] DO_REGIONS = {\n            \"nyc1\",\n            \"nyc3\",\n            \"ams3\",\n            \"sfo3\",\n            \"sgp1\",\n            \"lon1\",\n            \"fra1\",\n            \"tor1\",\n            \"blr1\",\n            \"syd1\",\n    };\n\n    private IBurpExtenderCallbacks callbacks;\n    private String doDropletTag = \"burp-vps-proxy\";\n    private String doRegion = \"nyc1\";\n\n    public DigitalOceanProvider(IBurpExtenderCallbacks callbacks) {\n        this.callbacks = callbacks;\n\n        String region = callbacks.loadExtensionSetting(DO_REGION_SETTING);\n        if (region != null) {\n            doRegion = region;\n        }\n\n        String burpInstanceId = callbacks.loadExtensionSetting(SettingsKeys.BURP_INSTANCE_ID);\n        doDropletTag = doDropletTag + \"-\" + burpInstanceId;\n    }\n\n    @Override\n    public String getName() {\n        return \"DigitalOcean\";\n    }\n\n    @Override\n    public ProxySettings startInstance() throws ProviderException {\n        log(\"creating a new droplet\");\n\n        DigitalOcean client;\n        try {\n            client = getClient();\n\n            String dropletName = String.format(\"burp-vps-proxy-%s\", RandomString.generate(4));\n            List<String> tags = new ArrayList<>();\n            tags.add(doDropletTag);\n\n            Droplet droplet = new Droplet();\n            droplet.setName(dropletName);\n            droplet.setRegion(new com.myjeeva.digitalocean.pojo.Region(doRegion));\n            droplet.setImage(new com.myjeeva.digitalocean.pojo.Image(\"debian-11-x64\"));\n            droplet.setSize(\"s-1vcpu-512mb-10gb\");\n            droplet.setTags(tags);\n\n            String password = RandomString.generate(12);\n            droplet.setUserData(getProvisioningScript(password));\n\n            droplet = client.createDroplet(droplet);\n\n            int attempts = 0;\n            while (droplet.getStatus() != DropletStatus.ACTIVE) {\n                Thread.sleep(2000);\n                attempts++;\n\n                if (attempts > 60) {\n                    log(\"droplet creation timed out\");\n                    client.deleteDroplet(droplet.getId());\n                    log(\"droplet deleted\");\n                    return null;\n                }\n\n                droplet = client.getDropletInfo(droplet.getId());\n            }\n\n            logf(\"droplet %s created\", droplet.getName());\n            return new ProxySettings(droplet.getNetworks().getVersion4Networks().get(0).getIpAddress(), \"1080\",\n                    \"burp-vps-proxy\", password);\n        } catch (ProviderException e) {\n            throw e;\n        } catch (Exception e) {\n            throw new ProviderException(String.format(\"error creating droplet: %s\", e.getMessage()), e);\n        }\n    }\n\n    @Override\n    public void destroyInstance() throws ProviderException {\n        try {\n            DigitalOcean client = getClient();\n\n            List<Droplet> droplets = client.getAvailableDroplets(0, Integer.MAX_VALUE).getDroplets();\n            for (Droplet droplet : droplets) {\n                List<String> tags = droplet.getTags();\n                if (tags != null && tags.contains(doDropletTag)) {\n                    client.deleteDroplet(droplet.getId());\n                    logf(\"droplet %s deleted\", droplet.getName());\n                }\n            }\n        } catch (ProviderException e) {\n            throw e;\n        } catch (Exception e) {\n            throw new ProviderException(String.format(\"error deleting droplet: %s\", e.getMessage()), e);\n        }\n    }\n\n    @Override\n    public JComponent getUI() {\n        JPanel panel = new JPanel();\n        panel.setLayout(new BoxLayout(panel, BoxLayout.Y_AXIS));\n\n        JLabel apiKeyLabel = new JLabel(\"API key:\");\n        apiKeyLabel.setAlignmentX(Component.LEFT_ALIGNMENT);\n\n        JPasswordField apiKeyPasswordField = new JPasswordField();\n        apiKeyPasswordField.setAlignmentX(Component.LEFT_ALIGNMENT);\n        apiKeyPasswordField.setPreferredSize(new Dimension(200, apiKeyPasswordField.getPreferredSize().height));\n        apiKeyPasswordField.setText(callbacks.loadExtensionSetting(DO_API_KEY_SETTING));\n\n        JLabel doRegionLabel = new JLabel(\"Region:\");\n        doRegionLabel.setAlignmentX(Component.LEFT_ALIGNMENT);\n\n        JComboBox<String> doRegionComboBox = new JComboBox<>();\n        doRegionComboBox.setAlignmentX(Component.LEFT_ALIGNMENT);\n        doRegionComboBox.setMaximumSize(new Dimension(75, doRegionComboBox.getPreferredSize().height));\n        for (int i = 0; i < DO_REGIONS.length; i++) {\n            doRegionComboBox.addItem(DO_REGIONS[i]);\n        }\n\n        String selectedRegion = callbacks.loadExtensionSetting(DO_REGION_SETTING);\n        if (selectedRegion != null && !selectedRegion.isEmpty()) {\n            doRegionComboBox.setSelectedItem(selectedRegion);\n        }\n\n        panel.add(apiKeyLabel);\n        panel.add(Box.createRigidArea(new Dimension(0, 5)));\n        panel.add(apiKeyPasswordField);\n        panel.add(Box.createRigidArea(new Dimension(0, 5)));\n        panel.add(doRegionLabel);\n        panel.add(Box.createRigidArea(new Dimension(0, 5)));\n        panel.add(doRegionComboBox);\n\n        apiKeyPasswordField.getDocument().addDocumentListener(new DocumentListener() {\n            @Override\n            public void insertUpdate(DocumentEvent e) {\n                saveSetting();\n            }\n\n            @Override\n            public void removeUpdate(DocumentEvent e) {\n                saveSetting();\n            }\n\n            @Override\n            public void changedUpdate(DocumentEvent e) {\n                saveSetting();\n            }\n\n            private void saveSetting() {\n                String value = new String(apiKeyPasswordField.getPassword());\n                callbacks.saveExtensionSetting(DO_API_KEY_SETTING, value);\n            }\n        });\n\n        doRegionComboBox.addActionListener(new ActionListener() {\n            @Override\n            public void actionPerformed(ActionEvent e) {\n                Object selectedItem = doRegionComboBox.getSelectedItem();\n                if (selectedItem == null) {\n                    return;\n                }\n\n                doRegion = selectedItem.toString();\n                callbacks.saveExtensionSetting(DO_REGION_SETTING, doRegion);\n            }\n        });\n\n        return panel;\n    }\n\n    private DigitalOcean getClient() throws ProviderException {\n        String apiKey = callbacks.loadExtensionSetting(DO_API_KEY_SETTING);\n        if (apiKey == null) {\n            throw new ProviderException(\"no api key defined\", null);\n        }\n\n        DigitalOcean client = new DigitalOceanClient(apiKey);\n        try {\n            client.getAccountInfo();\n        } catch (Exception e) {\n            throw new ProviderException(String.format(\"error getting account info: %s\", e.getMessage()), e);\n        }\n\n        return client;\n    }\n}\n"
  },
  {
    "path": "src/vpsproxy/providers/LinodeProvider.java",
    "content": "package vpsproxy.providers;\n\nimport java.awt.*;\nimport java.awt.event.*;\nimport java.util.List;\nimport java.util.ArrayList;\nimport javax.swing.*;\nimport javax.swing.event.*;\nimport java.net.HttpURLConnection;\nimport java.net.URL;\nimport java.io.BufferedReader;\nimport java.io.InputStreamReader;\nimport java.io.OutputStream;\nimport org.json.JSONArray;\nimport org.json.JSONObject;\n\nimport burp.IBurpExtenderCallbacks;\nimport vpsproxy.*;\n\npublic class LinodeProvider extends Provider {\n    public class InstanceInfo {\n        private int id;\n        private String label;\n\n        public InstanceInfo(int id, String label) {\n            this.id = id;\n            this.label = label;\n        }\n\n        public int getId() {\n            return id;\n        }\n\n        public String getLabel() {\n            return label;\n        }\n    }\n\n    final private String LINODE_API_BASE_URL = \"https://api.linode.com/v4\";\n    final private String LINODE_API_CREATION_JSON = \"{\\\"region\\\": \\\"%s\\\", \\\"type\\\": \\\"%s\\\", \\\"image\\\": \\\"%s\\\", \\\"root_pass\\\": \\\"%s\\\", \\\"label\\\": \\\"%s\\\", \\\"tags\\\": [\\\"%s\\\"]}\";\n    final private String LINODE_API_KEY_SETTING = \"Provider_Linode_APIKey\";\n    final private String LINODE_REGION_SETTING = \"Provider_Linode_Region\";\n    final private String LINODE_SIZE = \"g6-nanode-1\";\n    final private String LINODE_IMAGE = \"linode/debian11\";\n    final private int LINODE_TIMEOUT = 120;\n    final private String[] LINODE_REGIONS = {\n            \"us-east\",\n            \"us-central\",\n            \"us-west\",\n            \"us-southeast\",\n            \"ca-central\",\n            \"eu-west\",\n            \"eu-central\",\n            \"ap-south\",\n            \"ap-northeast\",\n            \"ap-west\",\n            \"ap-southeast\",\n    };\n\n    private IBurpExtenderCallbacks callbacks;\n    private String linodeApiKey = \"\";\n    private String linodeTag = \"burp-vps-proxy\";\n    private String linodeRegion = \"us-east\";\n\n    public LinodeProvider(IBurpExtenderCallbacks callbacks) {\n        this.callbacks = callbacks;\n\n        String burpInstanceId = callbacks.loadExtensionSetting(SettingsKeys.BURP_INSTANCE_ID);\n        linodeTag = linodeTag + \"-\" + burpInstanceId;\n\n        linodeApiKey = callbacks.loadExtensionSetting(LINODE_API_KEY_SETTING);\n        String region = callbacks.loadExtensionSetting(LINODE_REGION_SETTING);\n        if (region != null) {\n            linodeRegion = region;\n        }\n    }\n\n    @Override\n    public String getName() {\n        return \"Linode\";\n    }\n\n    @Override\n    public ProxySettings startInstance() throws ProviderException {\n        log(\"creating a new linode\");\n\n        try {\n            String password = RandomString.generate(12);\n            String rootPassword = RandomString.generate(24);\n            String instanceName = String.format(\"burp-vps-proxy-%s\", RandomString.generate(4));\n\n            URL url = new URL(LINODE_API_BASE_URL + \"/linode/instances\");\n\n            HttpURLConnection connection;\n            connection = (HttpURLConnection) url.openConnection();\n            connection.setRequestMethod(\"POST\");\n            connection.setRequestProperty(\"Content-Type\", \"application/json\");\n            connection.setRequestProperty(\"Authorization\", \"Bearer \" + linodeApiKey);\n            connection.setDoOutput(true);\n\n            String payload = String.format(LINODE_API_CREATION_JSON, linodeRegion, LINODE_SIZE, LINODE_IMAGE,\n                    rootPassword, instanceName, linodeTag);\n\n            OutputStream os = connection.getOutputStream();\n            os.write(payload.getBytes(\"UTF-8\"));\n\n            if (connection.getResponseCode() != 200) {\n                throw new ProviderException(\"failed to created linode instance: \"\n                        + connection.getResponseCode() + \" \" + connection.getResponseMessage(), null);\n            }\n\n            BufferedReader br = new BufferedReader(new InputStreamReader(connection.getInputStream()));\n\n            String output;\n            StringBuilder sb = new StringBuilder();\n            while ((output = br.readLine()) != null) {\n                sb.append(output);\n            }\n\n            connection.disconnect();\n\n            String responseJson = sb.toString();\n            int instanceId = extractLinodeId(responseJson);\n            String ipAddress = getInstanceIpAddress(instanceId);\n\n            waitForStatus(instanceId, \"running\", LINODE_TIMEOUT);\n            runProvisioningScript(ipAddress, \"root\", rootPassword, getProvisioningScript(password));\n\n            logf(\"instance %s created\", instanceName);\n            return new ProxySettings(ipAddress, \"1080\", \"burp-vps-proxy\", password);\n        } catch (ProviderException e) {\n            throw e;\n        } catch (Exception e) {\n            throw new ProviderException(String.format(\"error establishing connection: %s\", e.getMessage()),\n                    e);\n        }\n    }\n\n    @Override\n    public void destroyInstance() throws ProviderException {\n        try {\n            List<InstanceInfo> instanceInfos = getInstanceIdsWithTag(linodeTag);\n            for (InstanceInfo instanceInfo : instanceInfos) {\n                deleteLinodeInstance(instanceInfo.id);\n                logf(\"instance %s deleted\", instanceInfo.label);\n            }\n        } catch (ProviderException e) {\n            throw e;\n        } catch (Exception e) {\n            throw new ProviderException(String.format(\"error deleting linode: %s\", e.getMessage()),\n                    e);\n        }\n    }\n\n    @Override\n    public JComponent getUI() {\n        JPanel panel = new JPanel();\n        panel.setLayout(new BoxLayout(panel, BoxLayout.Y_AXIS));\n\n        JLabel apiKeyLabel = new JLabel(\"API key:\");\n        apiKeyLabel.setAlignmentX(Component.LEFT_ALIGNMENT);\n\n        JPasswordField apiKeyPasswordField = new JPasswordField();\n        apiKeyPasswordField.setAlignmentX(Component.LEFT_ALIGNMENT);\n        apiKeyPasswordField.setPreferredSize(new Dimension(200, apiKeyPasswordField.getPreferredSize().height));\n        apiKeyPasswordField.setText(linodeApiKey);\n\n        JLabel linodeRegionLabel = new JLabel(\"Region:\");\n        linodeRegionLabel.setAlignmentX(Component.LEFT_ALIGNMENT);\n\n        JComboBox<String> linodeRegionComboBox = new JComboBox<>();\n        linodeRegionComboBox.setAlignmentX(Component.LEFT_ALIGNMENT);\n        linodeRegionComboBox.setMaximumSize(new Dimension(125, linodeRegionComboBox.getPreferredSize().height));\n        for (int i = 0; i < LINODE_REGIONS.length; i++) {\n            linodeRegionComboBox.addItem(LINODE_REGIONS[i]);\n        }\n\n        String selectedRegion = callbacks.loadExtensionSetting(LINODE_REGION_SETTING);\n        if (selectedRegion != null && !selectedRegion.isEmpty()) {\n            linodeRegionComboBox.setSelectedItem(selectedRegion);\n        }\n\n        panel.add(apiKeyLabel);\n        panel.add(Box.createRigidArea(new Dimension(0, 5)));\n        panel.add(apiKeyPasswordField);\n        panel.add(Box.createRigidArea(new Dimension(0, 5)));\n        panel.add(linodeRegionLabel);\n        panel.add(Box.createRigidArea(new Dimension(0, 5)));\n        panel.add(linodeRegionComboBox);\n\n        apiKeyPasswordField.getDocument().addDocumentListener(new DocumentListener() {\n            @Override\n            public void insertUpdate(DocumentEvent e) {\n                saveSetting();\n            }\n\n            @Override\n            public void removeUpdate(DocumentEvent e) {\n                saveSetting();\n            }\n\n            @Override\n            public void changedUpdate(DocumentEvent e) {\n                saveSetting();\n            }\n\n            private void saveSetting() {\n                String value = new String(apiKeyPasswordField.getPassword());\n                callbacks.saveExtensionSetting(LINODE_API_KEY_SETTING, value);\n                linodeApiKey = value;\n            }\n        });\n\n        linodeRegionComboBox.addActionListener(new ActionListener() {\n            @Override\n            public void actionPerformed(ActionEvent e) {\n                Object selectedItem = linodeRegionComboBox.getSelectedItem();\n                if (selectedItem == null) {\n                    return;\n                }\n\n                linodeRegion = selectedItem.toString();\n                callbacks.saveExtensionSetting(LINODE_REGION_SETTING, linodeRegion);\n            }\n        });\n\n        return panel;\n    }\n\n    private void deleteLinodeInstance(int linodeId) throws Exception {\n        URL url = new URL(LINODE_API_BASE_URL + \"/linode/instances/\" + linodeId);\n        HttpURLConnection connection = (HttpURLConnection) url.openConnection();\n        connection.setRequestMethod(\"DELETE\");\n        connection.setRequestProperty(\"Authorization\", \"Bearer \" + linodeApiKey);\n\n        if (connection.getResponseCode() != 200) {\n            throw new ProviderException(\"failed to delete instance: \" + connection.getResponseCode() + \" \"\n                    + connection.getResponseMessage(), null);\n\n        }\n\n        connection.disconnect();\n    }\n\n    private static int extractLinodeId(String json) {\n        JSONObject responseJson = new JSONObject(json);\n        return responseJson.getInt(\"id\");\n    }\n\n    private String getInstanceDetails(int linodeId) throws Exception {\n        URL url = new URL(LINODE_API_BASE_URL + \"/linode/instances/\" + linodeId);\n        HttpURLConnection connection = (HttpURLConnection) url.openConnection();\n        connection.setRequestMethod(\"GET\");\n        connection.setRequestProperty(\"Authorization\", \"Bearer \" + linodeApiKey);\n\n        if (connection.getResponseCode() != 200) {\n            throw new ProviderException(\"failed to get instance details: \" + connection.getResponseCode() + \" \"\n                    + connection.getResponseMessage(), null);\n        }\n\n        BufferedReader br = new BufferedReader(new InputStreamReader(connection.getInputStream()));\n        String output;\n        StringBuilder sb = new StringBuilder();\n        while ((output = br.readLine()) != null) {\n            sb.append(output);\n        }\n\n        connection.disconnect();\n\n        return sb.toString();\n    }\n\n    private String getInstanceIpAddress(int linodeId) throws Exception {\n        String instanceDetails = getInstanceDetails(linodeId);\n        JSONObject instanceJson = new JSONObject(instanceDetails);\n        JSONArray ipv4Addresses = instanceJson.getJSONArray(\"ipv4\");\n        return ipv4Addresses.getString(0);\n    }\n\n    private String getInstanceStatus(int linodeId) throws Exception {\n        String instanceDetails = getInstanceDetails(linodeId);\n        JSONObject instanceJson = new JSONObject(instanceDetails);\n        return instanceJson.getString(\"status\");\n    }\n\n    private List<InstanceInfo> getInstanceIdsWithTag(String tag) throws Exception {\n        URL url = new URL(LINODE_API_BASE_URL + \"/linode/instances\");\n        HttpURLConnection connection = (HttpURLConnection) url.openConnection();\n        connection.setRequestMethod(\"GET\");\n        connection.setRequestProperty(\"Authorization\", \"Bearer \" + linodeApiKey);\n\n        if (connection.getResponseCode() != 200) {\n            throw new ProviderException(\"failed to list instances: \" + connection.getResponseCode() + \" \"\n                    + connection.getResponseMessage(), null);\n        }\n\n        BufferedReader br = new BufferedReader(new InputStreamReader(connection.getInputStream()));\n        String output;\n        StringBuilder sb = new StringBuilder();\n        while ((output = br.readLine()) != null) {\n            sb.append(output);\n        }\n\n        String responseJson = sb.toString();\n        JSONObject jsonResponse = new JSONObject(responseJson);\n        JSONArray instances = jsonResponse.getJSONArray(\"data\");\n\n        List<InstanceInfo> instanceInfos = new ArrayList<>();\n        for (int i = 0; i < instances.length(); i++) {\n            JSONObject instance = instances.getJSONObject(i);\n            JSONArray instanceTags = instance.getJSONArray(\"tags\");\n            for (int j = 0; j < instanceTags.length(); j++) {\n                if (tag.equals(instanceTags.getString(j))) {\n                    instanceInfos.add(new InstanceInfo(instance.getInt(\"id\"), instance.getString(\"label\")));\n                    break;\n                }\n            }\n        }\n\n        return instanceInfos;\n    }\n\n    private void waitForStatus(int linodeId, String status, int timeout) throws Exception {\n        int elapsed = 0;\n\n        while (true) {\n            if (elapsed >= timeout) {\n                throw new ProviderException(String.format(\"timed out waiting for status \\\"%s\\\"\", status), null);\n            }\n\n            if (getInstanceStatus(linodeId).equalsIgnoreCase(status)) {\n                break;\n            }\n\n            Thread.sleep(5000);\n            elapsed += 5;\n        }\n\n        // Wait an extra 5 seconds otherwise the server may not be ready to accept\n        // connections\n        Thread.sleep(5000);\n    }\n}\n"
  },
  {
    "path": "src/vpsproxy/providers/Provider.java",
    "content": "package vpsproxy.providers;\n\nimport java.io.InputStream;\nimport java.io.InputStreamReader;\nimport java.io.IOException;\nimport java.util.Scanner;\nimport javax.swing.JComponent;\nimport java.nio.charset.StandardCharsets;\nimport java.io.BufferedReader;\nimport java.io.ByteArrayInputStream;\nimport com.jcraft.jsch.ChannelExec;\nimport com.jcraft.jsch.JSch;\nimport com.jcraft.jsch.Session;\n\nimport vpsproxy.Logger;\nimport vpsproxy.ProxySettings;\n\npublic abstract class Provider {\n    private static final String proxyUsername = \"burp-vps-proxy\";\n    private static final String proxyPort = \"1080\";\n\n    private static final String SCRIPT_RESOURCE_PATH = \"provisioning.sh\";\n    private static String SCRIPT;\n    private static boolean debug = false;\n\n    public abstract String getName();\n\n    public abstract ProxySettings startInstance() throws ProviderException;\n\n    public abstract void destroyInstance() throws ProviderException;\n\n    public abstract JComponent getUI();\n\n    protected void log(String message) {\n        Logger.log(String.format(\"%s: %s\", getName(), message));\n    }\n\n    protected void logf(String format, Object... args) {\n        format = getName() + \": \" + format;\n        Logger.log(String.format(format, args));\n    }\n\n    protected ProxySettings createProxySettings(String publicIpAddress, String password) {\n        return new ProxySettings(publicIpAddress, proxyPort, proxyUsername, password);\n    }\n\n    public class ProviderException extends Exception {\n        public ProviderException(String message, Throwable cause) {\n            super(getName() + \": \" + message, cause);\n        }\n    }\n\n    protected String getProvisioningScript(String password) throws IOException {\n        if (SCRIPT == null) {\n            InputStream inputStream = getClass().getClassLoader().getResourceAsStream(SCRIPT_RESOURCE_PATH);\n            if (inputStream != null) {\n                try (Scanner scanner = new Scanner(inputStream, \"UTF-8\")) {\n                    SCRIPT = scanner.useDelimiter(\"\\\\A\").next();\n                }\n            } else {\n                throw new IOException(String.format(\"Resource '%s' not found\", SCRIPT_RESOURCE_PATH));\n            }\n        }\n\n        return SCRIPT.replaceAll(\"CHANGEME\", password);\n    }\n\n    protected void runProvisioningScript(String ipAddress, String username, String password, String provisioningScript)\n            throws Exception {\n        log(\"provisioning via ssh\");\n\n        JSch jsch = new JSch();\n\n        Session session = jsch.getSession(username, ipAddress, 22);\n        session.setPassword(password);\n        session.setConfig(\"StrictHostKeyChecking\", \"no\");\n        session.setConfig(\"ConnectTimeout\", \"60000\");\n        session.connect();\n\n        ChannelExec channel = (ChannelExec) session.openChannel(\"exec\");\n        channel.setCommand(\"bash -s\");\n        channel.setInputStream(new ByteArrayInputStream(provisioningScript.getBytes(StandardCharsets.UTF_8)));\n        channel.setErrStream(System.err);\n\n        InputStream inputStream = channel.getInputStream();\n        InputStream errorStream = channel.getErrStream();\n\n        channel.connect();\n\n        BufferedReader stdOutputReader = new BufferedReader(new InputStreamReader(inputStream));\n        BufferedReader errOutputReader = new BufferedReader(new InputStreamReader(errorStream));\n\n        String line;\n        // log(\"Standard Output:\");\n        while ((line = stdOutputReader.readLine()) != null) {\n            if (debug) {\n                log(line);\n            }\n        }\n\n        // log(\"Error Output:\");\n        while ((line = errOutputReader.readLine()) != null) {\n            if (debug) {\n                log(line);\n            }\n        }\n\n        channel.disconnect();\n        session.disconnect();\n    }\n}\n"
  }
]