[
  {
    "path": ".gitattributes",
    "content": "# Auto detect text files and perform LF normalization\n* text=auto"
  },
  {
    "path": ".gitignore",
    "content": "# Xcode\n#\n# gitignore contributors: remember to update Global/Xcode.gitignore, Objective-C.gitignore & Swift.gitignore\n\n## Build generated\nbuild/\nDerivedData/\n\n## Various settings\n*.pbxuser\n!default.pbxuser\n*.mode1v3\n!default.mode1v3\n*.mode2v3\n!default.mode2v3\n*.perspectivev3\n!default.perspectivev3\nxcuserdata/\n\n## Other\n*.moved-aside\n*.xcuserstate\n\n## Obj-C/Swift specific\n*.hmap\n*.ipa\n*.dSYM.zip\n*.dSYM\n\n# CocoaPods\n#\n# We recommend against adding the Pods directory to your .gitignore. However\n# you should judge for yourself, the pros and cons are mentioned at:\n# https://guides.cocoapods.org/using/using-cocoapods.html#should-i-check-the-pods-directory-into-source-control\n#\n# Pods/\n\n# Carthage\n#\n# Add this line if you want to avoid checking in source code from Carthage dependencies.\n# Carthage/Checkouts\n\nCarthage/Build\n\n# fastlane\n#\n# It is recommended to not store the screenshots in the git repo. Instead, use fastlane to re-generate the \n# screenshots whenever they are needed.\n# For more information about the recommended setup visit:\n# https://github.com/fastlane/fastlane/blob/master/fastlane/docs/Gitignore.md\n\nfastlane/report.xml\nfastlane/Preview.html\nfastlane/screenshots\nfastlane/test_output\n\n# Code Injection\n#\n# After new code Injection tools there's a generated folder /iOSInjectionProject\n# https://github.com/johnno1962/injectionforxcode\n\niOSInjectionProject/\nprocInfo.xcodeproj/project.xcworkspace/contents.xcworkspacedata\n.DS_Store\n"
  },
  {
    "path": "LICENSE.md",
    "content": "                    GNU GENERAL PUBLIC LICENSE\n                       Version 3, 29 June 2007\n\n Copyright (C) 2007 Free Software Foundation, Inc. <https://fsf.org/>\n Everyone is permitted to copy and distribute verbatim copies\n of this license document, but changing it is not allowed.\n\n                            Preamble\n\n  The GNU General Public License is a free, copyleft license for\nsoftware and other kinds of works.\n\n  The licenses for most software and other practical works are designed\nto take away your freedom to share and change the works.  By contrast,\nthe GNU General Public License is intended to guarantee your freedom to\nshare and change all versions of a program--to make sure it remains free\nsoftware for all its users.  We, the Free Software Foundation, use the\nGNU General Public License for most of our software; it applies also to\nany other work released this way by its authors.  You can apply it to\nyour programs, too.\n\n  When we speak of free software, we are referring to freedom, not\nprice.  Our General Public Licenses are designed to make sure that you\nhave the freedom to distribute copies of free software (and charge for\nthem if you wish), that you receive source code or can get it if you\nwant it, that you can change the software or use pieces of it in new\nfree programs, and that you know you can do these things.\n\n  To protect your rights, we need to prevent others from denying you\nthese rights or asking you to surrender the rights.  Therefore, you have\ncertain responsibilities if you distribute copies of the software, or if\nyou modify it: responsibilities to respect the freedom of others.\n\n  For example, if you distribute copies of such a program, whether\ngratis or for a fee, you must pass on to the recipients the same\nfreedoms that you received.  You must make sure that they, too, receive\nor can get the source code.  And you must show them these terms so they\nknow their rights.\n\n  Developers that use the GNU GPL protect your rights with two steps:\n(1) assert copyright on the software, and (2) offer you this License\ngiving you legal permission to copy, distribute and/or modify it.\n\n  For the developers' and authors' protection, the GPL clearly explains\nthat there is no warranty for this free software.  For both users' and\nauthors' sake, the GPL requires that modified versions be marked as\nchanged, so that their problems will not be attributed erroneously to\nauthors of previous versions.\n\n  Some devices are designed to deny users access to install or run\nmodified versions of the software inside them, although the manufacturer\ncan do so.  This is fundamentally incompatible with the aim of\nprotecting users' freedom to change the software.  The systematic\npattern of such abuse occurs in the area of products for individuals to\nuse, which is precisely where it is most unacceptable.  Therefore, we\nhave designed this version of the GPL to prohibit the practice for those\nproducts.  If such problems arise substantially in other domains, we\nstand ready to extend this provision to those domains in future versions\nof the GPL, as needed to protect the freedom of users.\n\n  Finally, every program is threatened constantly by software patents.\nStates should not allow patents to restrict development and use of\nsoftware on general-purpose computers, but in those that do, we wish to\navoid the special danger that patents applied to a free program could\nmake it effectively proprietary.  To prevent this, the GPL assures that\npatents cannot be used to render the program non-free.\n\n  The precise terms and conditions for copying, distribution and\nmodification follow.\n\n                       TERMS AND CONDITIONS\n\n  0. Definitions.\n\n  \"This License\" refers to version 3 of the GNU General Public License.\n\n  \"Copyright\" also means copyright-like laws that apply to other kinds of\nworks, such as semiconductor masks.\n\n  \"The Program\" refers to any copyrightable work licensed under this\nLicense.  Each licensee is addressed as \"you\".  \"Licensees\" and\n\"recipients\" may be individuals or organizations.\n\n  To \"modify\" a work means to copy from or adapt all or part of the work\nin a fashion requiring copyright permission, other than the making of an\nexact copy.  The resulting work is called a \"modified version\" of the\nearlier work or a work \"based on\" the earlier work.\n\n  A \"covered work\" means either the unmodified Program or a work based\non the Program.\n\n  To \"propagate\" a work means to do anything with it that, without\npermission, would make you directly or secondarily liable for\ninfringement under applicable copyright law, except executing it on a\ncomputer or modifying a private copy.  Propagation includes copying,\ndistribution (with or without modification), making available to the\npublic, and in some countries other activities as well.\n\n  To \"convey\" a work means any kind of propagation that enables other\nparties to make or receive copies.  Mere interaction with a user through\na computer network, with no transfer of a copy, is not conveying.\n\n  An interactive user interface displays \"Appropriate Legal Notices\"\nto the extent that it includes a convenient and prominently visible\nfeature that (1) displays an appropriate copyright notice, and (2)\ntells the user that there is no warranty for the work (except to the\nextent that warranties are provided), that licensees may convey the\nwork under this License, and how to view a copy of this License.  If\nthe interface presents a list of user commands or options, such as a\nmenu, a prominent item in the list meets this criterion.\n\n  1. Source Code.\n\n  The \"source code\" for a work means the preferred form of the work\nfor making modifications to it.  \"Object code\" means any non-source\nform of a work.\n\n  A \"Standard Interface\" means an interface that either is an official\nstandard defined by a recognized standards body, or, in the case of\ninterfaces specified for a particular programming language, one that\nis widely used among developers working in that language.\n\n  The \"System Libraries\" of an executable work include anything, other\nthan the work as a whole, that (a) is included in the normal form of\npackaging a Major Component, but which is not part of that Major\nComponent, and (b) serves only to enable use of the work with that\nMajor Component, or to implement a Standard Interface for which an\nimplementation is available to the public in source code form.  A\n\"Major Component\", in this context, means a major essential component\n(kernel, window system, and so on) of the specific operating system\n(if any) on which the executable work runs, or a compiler used to\nproduce the work, or an object code interpreter used to run it.\n\n  The \"Corresponding Source\" for a work in object code form means all\nthe source code needed to generate, install, and (for an executable\nwork) run the object code and to modify the work, including scripts to\ncontrol those activities.  However, it does not include the work's\nSystem Libraries, or general-purpose tools or generally available free\nprograms which are used unmodified in performing those activities but\nwhich are not part of the work.  For example, Corresponding Source\nincludes interface definition files associated with source files for\nthe work, and the source code for shared libraries and dynamically\nlinked subprograms that the work is specifically designed to require,\nsuch as by intimate data communication or control flow between those\nsubprograms and other parts of the work.\n\n  The Corresponding Source need not include anything that users\ncan regenerate automatically from other parts of the Corresponding\nSource.\n\n  The Corresponding Source for a work in source code form is that\nsame work.\n\n  2. Basic Permissions.\n\n  All rights granted under this License are granted for the term of\ncopyright on the Program, and are irrevocable provided the stated\nconditions are met.  This License explicitly affirms your unlimited\npermission to run the unmodified Program.  The output from running a\ncovered work is covered by this License only if the output, given its\ncontent, constitutes a covered work.  This License acknowledges your\nrights of fair use or other equivalent, as provided by copyright law.\n\n  You may make, run and propagate covered works that you do not\nconvey, without conditions so long as your license otherwise remains\nin force.  You may convey covered works to others for the sole purpose\nof having them make modifications exclusively for you, or provide you\nwith facilities for running those works, provided that you comply with\nthe terms of this License in conveying all material for which you do\nnot control copyright.  Those thus making or running the covered works\nfor you must do so exclusively on your behalf, under your direction\nand control, on terms that prohibit them from making any copies of\nyour copyrighted material outside their relationship with you.\n\n  Conveying under any other circumstances is permitted solely under\nthe conditions stated below.  Sublicensing is not allowed; section 10\nmakes it unnecessary.\n\n  3. Protecting Users' Legal Rights From Anti-Circumvention Law.\n\n  No covered work shall be deemed part of an effective technological\nmeasure under any applicable law fulfilling obligations under article\n11 of the WIPO copyright treaty adopted on 20 December 1996, or\nsimilar laws prohibiting or restricting circumvention of such\nmeasures.\n\n  When you convey a covered work, you waive any legal power to forbid\ncircumvention of technological measures to the extent such circumvention\nis effected by exercising rights under this License with respect to\nthe covered work, and you disclaim any intention to limit operation or\nmodification of the work as a means of enforcing, against the work's\nusers, your or third parties' legal rights to forbid circumvention of\ntechnological measures.\n\n  4. Conveying Verbatim Copies.\n\n  You may convey verbatim copies of the Program's source code as you\nreceive it, in any medium, provided that you conspicuously and\nappropriately publish on each copy an appropriate copyright notice;\nkeep intact all notices stating that this License and any\nnon-permissive terms added in accord with section 7 apply to the code;\nkeep intact all notices of the absence of any warranty; and give all\nrecipients a copy of this License along with the Program.\n\n  You may charge any price or no price for each copy that you convey,\nand you may offer support or warranty protection for a fee.\n\n  5. Conveying Modified Source Versions.\n\n  You may convey a work based on the Program, or the modifications to\nproduce it from the Program, in the form of source code under the\nterms of section 4, provided that you also meet all of these conditions:\n\n    a) The work must carry prominent notices stating that you modified\n    it, and giving a relevant date.\n\n    b) The work must carry prominent notices stating that it is\n    released under this License and any conditions added under section\n    7.  This requirement modifies the requirement in section 4 to\n    \"keep intact all notices\".\n\n    c) You must license the entire work, as a whole, under this\n    License to anyone who comes into possession of a copy.  This\n    License will therefore apply, along with any applicable section 7\n    additional terms, to the whole of the work, and all its parts,\n    regardless of how they are packaged.  This License gives no\n    permission to license the work in any other way, but it does not\n    invalidate such permission if you have separately received it.\n\n    d) If the work has interactive user interfaces, each must display\n    Appropriate Legal Notices; however, if the Program has interactive\n    interfaces that do not display Appropriate Legal Notices, your\n    work need not make them do so.\n\n  A compilation of a covered work with other separate and independent\nworks, which are not by their nature extensions of the covered work,\nand which are not combined with it such as to form a larger program,\nin or on a volume of a storage or distribution medium, is called an\n\"aggregate\" if the compilation and its resulting copyright are not\nused to limit the access or legal rights of the compilation's users\nbeyond what the individual works permit.  Inclusion of a covered work\nin an aggregate does not cause this License to apply to the other\nparts of the aggregate.\n\n  6. Conveying Non-Source Forms.\n\n  You may convey a covered work in object code form under the terms\nof sections 4 and 5, provided that you also convey the\nmachine-readable Corresponding Source under the terms of this License,\nin one of these ways:\n\n    a) Convey the object code in, or embodied in, a physical product\n    (including a physical distribution medium), accompanied by the\n    Corresponding Source fixed on a durable physical medium\n    customarily used for software interchange.\n\n    b) Convey the object code in, or embodied in, a physical product\n    (including a physical distribution medium), accompanied by a\n    written offer, valid for at least three years and valid for as\n    long as you offer spare parts or customer support for that product\n    model, to give anyone who possesses the object code either (1) a\n    copy of the Corresponding Source for all the software in the\n    product that is covered by this License, on a durable physical\n    medium customarily used for software interchange, for a price no\n    more than your reasonable cost of physically performing this\n    conveying of source, or (2) access to copy the\n    Corresponding Source from a network server at no charge.\n\n    c) Convey individual copies of the object code with a copy of the\n    written offer to provide the Corresponding Source.  This\n    alternative is allowed only occasionally and noncommercially, and\n    only if you received the object code with such an offer, in accord\n    with subsection 6b.\n\n    d) Convey the object code by offering access from a designated\n    place (gratis or for a charge), and offer equivalent access to the\n    Corresponding Source in the same way through the same place at no\n    further charge.  You need not require recipients to copy the\n    Corresponding Source along with the object code.  If the place to\n    copy the object code is a network server, the Corresponding Source\n    may be on a different server (operated by you or a third party)\n    that supports equivalent copying facilities, provided you maintain\n    clear directions next to the object code saying where to find the\n    Corresponding Source.  Regardless of what server hosts the\n    Corresponding Source, you remain obligated to ensure that it is\n    available for as long as needed to satisfy these requirements.\n\n    e) Convey the object code using peer-to-peer transmission, provided\n    you inform other peers where the object code and Corresponding\n    Source of the work are being offered to the general public at no\n    charge under subsection 6d.\n\n  A separable portion of the object code, whose source code is excluded\nfrom the Corresponding Source as a System Library, need not be\nincluded in conveying the object code work.\n\n  A \"User Product\" is either (1) a \"consumer product\", which means any\ntangible personal property which is normally used for personal, family,\nor household purposes, or (2) anything designed or sold for incorporation\ninto a dwelling.  In determining whether a product is a consumer product,\ndoubtful cases shall be resolved in favor of coverage.  For a particular\nproduct received by a particular user, \"normally used\" refers to a\ntypical or common use of that class of product, regardless of the status\nof the particular user or of the way in which the particular user\nactually uses, or expects or is expected to use, the product.  A product\nis a consumer product regardless of whether the product has substantial\ncommercial, industrial or non-consumer uses, unless such uses represent\nthe only significant mode of use of the product.\n\n  \"Installation Information\" for a User Product means any methods,\nprocedures, authorization keys, or other information required to install\nand execute modified versions of a covered work in that User Product from\na modified version of its Corresponding Source.  The information must\nsuffice to ensure that the continued functioning of the modified object\ncode is in no case prevented or interfered with solely because\nmodification has been made.\n\n  If you convey an object code work under this section in, or with, or\nspecifically for use in, a User Product, and the conveying occurs as\npart of a transaction in which the right of possession and use of the\nUser Product is transferred to the recipient in perpetuity or for a\nfixed term (regardless of how the transaction is characterized), the\nCorresponding Source conveyed under this section must be accompanied\nby the Installation Information.  But this requirement does not apply\nif neither you nor any third party retains the ability to install\nmodified object code on the User Product (for example, the work has\nbeen installed in ROM).\n\n  The requirement to provide Installation Information does not include a\nrequirement to continue to provide support service, warranty, or updates\nfor a work that has been modified or installed by the recipient, or for\nthe User Product in which it has been modified or installed.  Access to a\nnetwork may be denied when the modification itself materially and\nadversely affects the operation of the network or violates the rules and\nprotocols for communication across the network.\n\n  Corresponding Source conveyed, and Installation Information provided,\nin accord with this section must be in a format that is publicly\ndocumented (and with an implementation available to the public in\nsource code form), and must require no special password or key for\nunpacking, reading or copying.\n\n  7. Additional Terms.\n\n  \"Additional permissions\" are terms that supplement the terms of this\nLicense by making exceptions from one or more of its conditions.\nAdditional permissions that are applicable to the entire Program shall\nbe treated as though they were included in this License, to the extent\nthat they are valid under applicable law.  If additional permissions\napply only to part of the Program, that part may be used separately\nunder those permissions, but the entire Program remains governed by\nthis License without regard to the additional permissions.\n\n  When you convey a copy of a covered work, you may at your option\nremove any additional permissions from that copy, or from any part of\nit.  (Additional permissions may be written to require their own\nremoval in certain cases when you modify the work.)  You may place\nadditional permissions on material, added by you to a covered work,\nfor which you have or can give appropriate copyright permission.\n\n  Notwithstanding any other provision of this License, for material you\nadd to a covered work, you may (if authorized by the copyright holders of\nthat material) supplement the terms of this License with terms:\n\n    a) Disclaiming warranty or limiting liability differently from the\n    terms of sections 15 and 16 of this License; or\n\n    b) Requiring preservation of specified reasonable legal notices or\n    author attributions in that material or in the Appropriate Legal\n    Notices displayed by works containing it; or\n\n    c) Prohibiting misrepresentation of the origin of that material, or\n    requiring that modified versions of such material be marked in\n    reasonable ways as different from the original version; or\n\n    d) Limiting the use for publicity purposes of names of licensors or\n    authors of the material; or\n\n    e) Declining to grant rights under trademark law for use of some\n    trade names, trademarks, or service marks; or\n\n    f) Requiring indemnification of licensors and authors of that\n    material by anyone who conveys the material (or modified versions of\n    it) with contractual assumptions of liability to the recipient, for\n    any liability that these contractual assumptions directly impose on\n    those licensors and authors.\n\n  All other non-permissive additional terms are considered \"further\nrestrictions\" within the meaning of section 10.  If the Program as you\nreceived it, or any part of it, contains a notice stating that it is\ngoverned by this License along with a term that is a further\nrestriction, you may remove that term.  If a license document contains\na further restriction but permits relicensing or conveying under this\nLicense, you may add to a covered work material governed by the terms\nof that license document, provided that the further restriction does\nnot survive such relicensing or conveying.\n\n  If you add terms to a covered work in accord with this section, you\nmust place, in the relevant source files, a statement of the\nadditional terms that apply to those files, or a notice indicating\nwhere to find the applicable terms.\n\n  Additional terms, permissive or non-permissive, may be stated in the\nform of a separately written license, or stated as exceptions;\nthe above requirements apply either way.\n\n  8. Termination.\n\n  You may not propagate or modify a covered work except as expressly\nprovided under this License.  Any attempt otherwise to propagate or\nmodify it is void, and will automatically terminate your rights under\nthis License (including any patent licenses granted under the third\nparagraph of section 11).\n\n  However, if you cease all violation of this License, then your\nlicense from a particular copyright holder is reinstated (a)\nprovisionally, unless and until the copyright holder explicitly and\nfinally terminates your license, and (b) permanently, if the copyright\nholder fails to notify you of the violation by some reasonable means\nprior to 60 days after the cessation.\n\n  Moreover, your license from a particular copyright holder is\nreinstated permanently if the copyright holder notifies you of the\nviolation by some reasonable means, this is the first time you have\nreceived notice of violation of this License (for any work) from that\ncopyright holder, and you cure the violation prior to 30 days after\nyour receipt of the notice.\n\n  Termination of your rights under this section does not terminate the\nlicenses of parties who have received copies or rights from you under\nthis License.  If your rights have been terminated and not permanently\nreinstated, you do not qualify to receive new licenses for the same\nmaterial under section 10.\n\n  9. Acceptance Not Required for Having Copies.\n\n  You are not required to accept this License in order to receive or\nrun a copy of the Program.  Ancillary propagation of a covered work\noccurring solely as a consequence of using peer-to-peer transmission\nto receive a copy likewise does not require acceptance.  However,\nnothing other than this License grants you permission to propagate or\nmodify any covered work.  These actions infringe copyright if you do\nnot accept this License.  Therefore, by modifying or propagating a\ncovered work, you indicate your acceptance of this License to do so.\n\n  10. Automatic Licensing of Downstream Recipients.\n\n  Each time you convey a covered work, the recipient automatically\nreceives a license from the original licensors, to run, modify and\npropagate that work, subject to this License.  You are not responsible\nfor enforcing compliance by third parties with this License.\n\n  An \"entity transaction\" is a transaction transferring control of an\norganization, or substantially all assets of one, or subdividing an\norganization, or merging organizations.  If propagation of a covered\nwork results from an entity transaction, each party to that\ntransaction who receives a copy of the work also receives whatever\nlicenses to the work the party's predecessor in interest had or could\ngive under the previous paragraph, plus a right to possession of the\nCorresponding Source of the work from the predecessor in interest, if\nthe predecessor has it or can get it with reasonable efforts.\n\n  You may not impose any further restrictions on the exercise of the\nrights granted or affirmed under this License.  For example, you may\nnot impose a license fee, royalty, or other charge for exercise of\nrights granted under this License, and you may not initiate litigation\n(including a cross-claim or counterclaim in a lawsuit) alleging that\nany patent claim is infringed by making, using, selling, offering for\nsale, or importing the Program or any portion of it.\n\n  11. Patents.\n\n  A \"contributor\" is a copyright holder who authorizes use under this\nLicense of the Program or a work on which the Program is based.  The\nwork thus licensed is called the contributor's \"contributor version\".\n\n  A contributor's \"essential patent claims\" are all patent claims\nowned or controlled by the contributor, whether already acquired or\nhereafter acquired, that would be infringed by some manner, permitted\nby this License, of making, using, or selling its contributor version,\nbut do not include claims that would be infringed only as a\nconsequence of further modification of the contributor version.  For\npurposes of this definition, \"control\" includes the right to grant\npatent sublicenses in a manner consistent with the requirements of\nthis License.\n\n  Each contributor grants you a non-exclusive, worldwide, royalty-free\npatent license under the contributor's essential patent claims, to\nmake, use, sell, offer for sale, import and otherwise run, modify and\npropagate the contents of its contributor version.\n\n  In the following three paragraphs, a \"patent license\" is any express\nagreement or commitment, however denominated, not to enforce a patent\n(such as an express permission to practice a patent or covenant not to\nsue for patent infringement).  To \"grant\" such a patent license to a\nparty means to make such an agreement or commitment not to enforce a\npatent against the party.\n\n  If you convey a covered work, knowingly relying on a patent license,\nand the Corresponding Source of the work is not available for anyone\nto copy, free of charge and under the terms of this License, through a\npublicly available network server or other readily accessible means,\nthen you must either (1) cause the Corresponding Source to be so\navailable, or (2) arrange to deprive yourself of the benefit of the\npatent license for this particular work, or (3) arrange, in a manner\nconsistent with the requirements of this License, to extend the patent\nlicense to downstream recipients.  \"Knowingly relying\" means you have\nactual knowledge that, but for the patent license, your conveying the\ncovered work in a country, or your recipient's use of the covered work\nin a country, would infringe one or more identifiable patents in that\ncountry that you have reason to believe are valid.\n\n  If, pursuant to or in connection with a single transaction or\narrangement, you convey, or propagate by procuring conveyance of, a\ncovered work, and grant a patent license to some of the parties\nreceiving the covered work authorizing them to use, propagate, modify\nor convey a specific copy of the covered work, then the patent license\nyou grant is automatically extended to all recipients of the covered\nwork and works based on it.\n\n  A patent license is \"discriminatory\" if it does not include within\nthe scope of its coverage, prohibits the exercise of, or is\nconditioned on the non-exercise of one or more of the rights that are\nspecifically granted under this License.  You may not convey a covered\nwork if you are a party to an arrangement with a third party that is\nin the business of distributing software, under which you make payment\nto the third party based on the extent of your activity of conveying\nthe work, and under which the third party grants, to any of the\nparties who would receive the covered work from you, a discriminatory\npatent license (a) in connection with copies of the covered work\nconveyed by you (or copies made from those copies), or (b) primarily\nfor and in connection with specific products or compilations that\ncontain the covered work, unless you entered into that arrangement,\nor that patent license was granted, prior to 28 March 2007.\n\n  Nothing in this License shall be construed as excluding or limiting\nany implied license or other defenses to infringement that may\notherwise be available to you under applicable patent law.\n\n  12. No Surrender of Others' Freedom.\n\n  If conditions are imposed on you (whether by court order, agreement or\notherwise) that contradict the conditions of this License, they do not\nexcuse you from the conditions of this License.  If you cannot convey a\ncovered work so as to satisfy simultaneously your obligations under this\nLicense and any other pertinent obligations, then as a consequence you may\nnot convey it at all.  For example, if you agree to terms that obligate you\nto collect a royalty for further conveying from those to whom you convey\nthe Program, the only way you could satisfy both those terms and this\nLicense would be to refrain entirely from conveying the Program.\n\n  13. Use with the GNU Affero General Public License.\n\n  Notwithstanding any other provision of this License, you have\npermission to link or combine any covered work with a work licensed\nunder version 3 of the GNU Affero General Public License into a single\ncombined work, and to convey the resulting work.  The terms of this\nLicense will continue to apply to the part which is the covered work,\nbut the special requirements of the GNU Affero General Public License,\nsection 13, concerning interaction through a network will apply to the\ncombination as such.\n\n  14. Revised Versions of this License.\n\n  The Free Software Foundation may publish revised and/or new versions of\nthe GNU General Public License from time to time.  Such new versions will\nbe similar in spirit to the present version, but may differ in detail to\naddress new problems or concerns.\n\n  Each version is given a distinguishing version number.  If the\nProgram specifies that a certain numbered version of the GNU General\nPublic License \"or any later version\" applies to it, you have the\noption of following the terms and conditions either of that numbered\nversion or of any later version published by the Free Software\nFoundation.  If the Program does not specify a version number of the\nGNU General Public License, you may choose any version ever published\nby the Free Software Foundation.\n\n  If the Program specifies that a proxy can decide which future\nversions of the GNU General Public License can be used, that proxy's\npublic statement of acceptance of a version permanently authorizes you\nto choose that version for the Program.\n\n  Later license versions may give you additional or different\npermissions.  However, no additional obligations are imposed on any\nauthor or copyright holder as a result of your choosing to follow a\nlater version.\n\n  15. Disclaimer of Warranty.\n\n  THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY\nAPPLICABLE LAW.  EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT\nHOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM \"AS IS\" WITHOUT WARRANTY\nOF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO,\nTHE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR\nPURPOSE.  THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM\nIS WITH YOU.  SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF\nALL NECESSARY SERVICING, REPAIR OR CORRECTION.\n\n  16. Limitation of Liability.\n\n  IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING\nWILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS\nTHE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY\nGENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE\nUSE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF\nDATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD\nPARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS),\nEVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF\nSUCH DAMAGES.\n\n  17. Interpretation of Sections 15 and 16.\n\n  If the disclaimer of warranty and limitation of liability provided\nabove cannot be given local legal effect according to their terms,\nreviewing courts shall apply local law that most closely approximates\nan absolute waiver of all civil liability in connection with the\nProgram, unless a warranty or assumption of liability accompanies a\ncopy of the Program in return for a fee.\n\n                     END OF TERMS AND CONDITIONS\n\n            How to Apply These Terms to Your New Programs\n\n  If you develop a new program, and you want it to be of the greatest\npossible use to the public, the best way to achieve this is to make it\nfree software which everyone can redistribute and change under these terms.\n\n  To do so, attach the following notices to the program.  It is safest\nto attach them to the start of each source file to most effectively\nstate the exclusion of warranty; and each file should have at least\nthe \"copyright\" line and a pointer to where the full notice is found.\n\n    <one line to give the program's name and a brief idea of what it does.>\n    Copyright (C) <year>  <name of author>\n\n    This program is free software: you can redistribute it and/or modify\n    it under the terms of the GNU General Public License as published by\n    the Free Software Foundation, either version 3 of the License, or\n    (at your option) any later version.\n\n    This program is distributed in the hope that it will be useful,\n    but WITHOUT ANY WARRANTY; without even the implied warranty of\n    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\n    GNU General Public License for more details.\n\n    You should have received a copy of the GNU General Public License\n    along with this program.  If not, see <https://www.gnu.org/licenses/>.\n\nAlso add information on how to contact you by electronic and paper mail.\n\n  If the program does terminal interaction, make it output a short\nnotice like this when it starts in an interactive mode:\n\n    <program>  Copyright (C) <year>  <name of author>\n    This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'.\n    This is free software, and you are welcome to redistribute it\n    under certain conditions; type `show c' for details.\n\nThe hypothetical commands `show w' and `show c' should show the appropriate\nparts of the General Public License.  Of course, your program's commands\nmight be different; for a GUI interface, you would use an \"about box\".\n\n  You should also get your employer (if you work as a programmer) or school,\nif any, to sign a \"copyright disclaimer\" for the program, if necessary.\nFor more information on this, and how to apply and follow the GNU GPL, see\n<https://www.gnu.org/licenses/>.\n\n  The GNU General Public License does not permit incorporating your program\ninto proprietary programs.  If your program is a subroutine library, you\nmay consider it more useful to permit linking proprietary applications with\nthe library.  If this is what you want to do, use the GNU Lesser General\nPublic License instead of this License.  But first, please read\n<https://www.gnu.org/licenses/why-not-lgpl.html>.\n"
  },
  {
    "path": "README.md",
    "content": "# ProcInfo\nProc Info is a open-source, user-mode, library for macOS. It provides simple interface to retrieve detailed information about running processes, plus allows one to asynchronously monitor process creation & exit events. \n\nLove this library or want to support it? Check out my [patreon page](https://www.patreon.com/objective_see) :)\n\n##### Quick Start (tl;dr)\n\nTo use the Proc Info library: \n1. add the Proc Info library (`lib/libprocInfo.a`) and Apple's OpenBSM library (`libbsm.tbd`) to your Xcode Project\n2. import the Proc Info library header file (`procInfo.h`)\n3. instantiate a `Proc Info` object\n4. a) to retrieve information about a running process invoke the `init:` method<br>\n   b) to enumerate existing processes invoke the `currentProcesses` method<br>\n   c) to monitor process events, declare a callback block and invoke the `start:` method<br>\n\n...or just download the [demo project](https://github.com/objective-see/ProcInfoExample), to take it for a spin! \n\n```Objective-C\n#import \"procInfo.h\"\n\n//init proc info object\n// YES: skip (CPU-intensive) generation of code-signing info\n// NO:  automatically generate code-signing info for each process\nProcInfo* procInfo = [[ProcInfo alloc] init:NO];\n\n//dump process info for process 1337\nNSLog(@\"process: %@\", [[Process alloc] init:1337]);\n\n//dump process info for all processes\nfor(Process* process in [procInfo currentProcesses])\n    NSLog(@\"new process: %@\", process);\n   \n//block for process events\nProcessCallbackBlock block = ^(Process* process)\n{\n    if(process.type != EVENT_EXIT)\n       NSLog(@\"process start: %@\\n\", process);\n    \n    else\n      NSLog(@\"process exit: %d\\n\", process.pid);\n};\n\n//start monitoring\n// ->block will be invoke upon process events!\n[procInfo start:block];\n ```\n\n\n##### Details\nThe Proc Info library provides an interface to: \n+ retrieve information about arbitrary processes (by pid) \n+ retrieve information about all running processes\n+ monitor for process start & exit events\n\nThe library is already used in various Objective-See's tools that:\n+ need to track process creation events (e.g. RansomWhere? BlockBlock, etc) \n+ classify running processes (based on their cryptographic signatures)\n\nMoreover, it is an important component of tools designed to facilitate Mac malware analysis (e.g. [OSX/FruitFly](https://speakerdeck.com/patrickwardle/fruitfly-via-a-custom-c-and-c-server)), and vulnerability hunting (e.g. [Installers/Updaters](https://speakerdeck.com/patrickwardle/defcon-2017-death-by-1000-installers-its-all-broken)).\n\nAs detailed in the 'Quick Start' section, to use Proc Info in your Xcode project perform the following steps. \n\n**1. Add the Proc Info library to your Xcode project:**<br>\nTo add the Proc Info library to your Xcode project simply drag and drop the library (`lib/libprocInfo.a`), into the File Navigator. In the resulting 'file add' popup, make sure the 'Copy items if needed' option is selected:\n<p align=\"center\"><img src=\"https://objective-see.com/images/PI/addLib.png\" width=\"600\"></p>\n\n**2. Add Apple's OpenBSM library to your Xcode project:**<br>\nSelect your project in Xcode, then click on the 'Build Phases' tab. In the 'Link Binary With Libraries' section, click the '+' to bring up the prompt for adding frameworks and libraries. Type `bsm` in the search box. Then select `libbsm.tbd` and click 'Add':\n<p align=\"center\"><img src=\"https://objective-see.com/images/PI/addLibBSM.png\" width=\"400\"></p>\n\n**3. Add the 'Proc Info' library header file to your project:**<br>\nIn Xcode click, 'File' then 'Add Files to <your project name>' Browse to the location of the `procInfo.h` header file, and click 'Add.' Note, you can also add the `procInfo.h` file into your project simply by dragging and dropping it into Xcode. \n\nYour Xcode project should now look something like this:\n<p align=\"center\"><img src=\"https://objective-see.com/images/PI/addedFiles.png\" width=\"214\"></p>\n\nHit Product->Build to compile and link your project. Assuming it cleanly builds, now it's time to start writing code to unlock the power of the Proc Info library :)\n\nBefore getting into coding specifics, its important to understand the `Process` and `Binary` objects. A `Process` object represents a instance of a running process. Looking at the header file `procInfo.h` one can see it contains information about the process such as:\n+ pid \n+ ppid\n+ user\n+ ancestors\n+ arguments\n\nEach `Process` object also has an associated `Binary` object that represents the on-disk image of the main executable which backs the process. The 'Binary' object contains information such as:\n+ name\n+ full path\n+ file attributes\n+ signing information\n\nThe signing information includes: \n+ signing status\n+ signing authorities\n+ whether its an Apple binary\n+ from the app store\n\nWith this information, one can use the library to answer questions such as: \n+ *\"What are all running processes on my system that don't belong to Apple proper?\"*\n+ *\"What are the arguments of the process that was just spawned?\"*\n+ *\"Is that process from the Mac App Store?\"*\n+ ...and many more!\n\n**Retrieving Information about an Arbitrary Process:**\n\nVia the Proc Info library one can create `Process` objects for arbitrary processes. Simply invoke the `Process` `init:` method with the process identifier (`pid_t`) of a running process:\n\n```Objective-C\n//init process obj\nProcess* process = [[Process alloc] init:1337];\n```\n\nThis will create a `Process` object for the specified process, that will contain the aforementioned process characteristics (ancestors, arguments, `Binary` object, etc). You can directly access this (e.g. `process.binary.isApple`). Here, we simply dump it to `stdout` via `NSLog()`:\n\n```Objective-C\n\n//dump process info\nNSLog(@\"process: %@\", process);\n\n//output\nprocess: \npid: 1337\npath: /Applications/Calculator.app/Contents/MacOS/Calculator\nuser: 501\nargs: (\n    \"/Applications/Calculator.app/Contents/MacOS/Calculator\"\n)\nancestors: (\n    557,\n    554,\n    353,\n    1\n)\nbinary: \nname: Calculator\npath: /Applications/Calculator.app/Contents/MacOS/Calculator\nattributes: {\n    NSFileCreationDate = \"2017-03-23 00:27:11 +0000\";\n    NSFileExtensionHidden = 0;\n    NSFileGroupOwnerAccountID = 0;\n    NSFileGroupOwnerAccountName = wheel;\n    NSFileHFSCreatorCode = 0;\n    NSFileHFSTypeCode = 0;\n    NSFileModificationDate = \"2017-03-23 00:27:11 +0000\";\n    NSFileOwnerAccountID = 0;\n    NSFileOwnerAccountName = root;\n    NSFilePosixPermissions = 493;\n    NSFileReferenceCount = 1;\n    NSFileSize = 199520;\n    NSFileSystemFileNumber = 92435925;\n    NSFileSystemNumber = 16777220;\n    NSFileType = NSFileTypeRegular;\n}\nsigning info: {\n    signatureStatus = 0;\n    signedByApple = 1;\n    signingAuthorities =     (\n        \"Software Signing\",\n        \"Apple Code Signing Certification Authority\",\n        \"Apple Root CA\"\n    );\n} (isApple: 1 / isAppStore: 0)\n```\n\n**Retrieving Information about all Running Processes:**\nThe Proc Info library can also provide information about all running processes via the `ProcInfo` object's `currentProcesses` method. This method returns an array of `Process` objects; one for each running process:\n\n```Objective-C\n//enum all existing procs\nfor(Process* process in [processInfo currentProcesses])\n{\n     //query/examine each process...\n\n     //dump process info\n     NSLog(@\"process: %@\", process);\n}\n```\nNote that this method may take a few seconds to execute, as generating and verifying the cryptographic signing information for all processes is somewhat time/CPU consuming. As such, it is recommended that you invoke this logic (i.e. the `currentProcesses` method) on a background thread.  \n\n**Monitoring Process Start and Exit Events:**\nOne of the most powerful features of the Proc Info library is its ability to asynchronously monitor for process events such as creation (`exec`, `spawn`, `fork`) and exit. When running with root privileges (recommended!) it uses Apple BSM auditing events to such process events. (For background on BSM auditing see [\"OpenBSM auditd on OS X: these are the logs you are looking for\"](http://ilostmynotes.blogspot.com/2013/10/openbsm-auditd-on-os-x-these-are-logs.html). \n\nIn order to begin monitoring for such events first declare a block to pass to the library. This block's type should be `ProcessCallbackBlock` which has been typedef'd in the `procInfo.h` header file as:\n\n```Objective-C\ntypedef void (^ProcessCallbackBlock)(Process*);\n```\n\nFrom this typedef, one can see this block will invoked with a pointer to a `Process` object, which is (as expected) represents the process which triggered the event. After creating a callback block, simply invoke the Proc Info `start:` method, passing in the block. This will kickoff asynchronous process monitoring. Now, anytime a process creation or exit event occurs, the code in the block will be automatically invoked!\n\nOne can be query returned `Process` object for the event type (`EVENT_FORK`, `EVENT_EXIT`, etc). If the event was not an exit event, the `Process` object will be fully instantiated, thus containing information such as ancestors, arguments, `Binary` object, etc. Note that for `EVENT_EXIT` events, the `Process` object will only contain the process identifier (`pid`) and the processes exit code. \n\nBelow is some example code that will call into the Proc Info library to asynchronously monitor for process events. Once the library detects such events, it will automatically invoke the passed in `block` which here, just examines the event type and then dumps information about the process to `stdout`:\n\n\n```Objective-C\n//define block\n// ->automatically invoked upon process events\nProcessCallbackBlock block = ^(Process* process)\n{\n    //process start event\n    // ->fork, spawn, exec, etc.\n    if(process.type != EVENT_EXIT)\n    {\n        //print\n        NSLog(@\"process start: %@\\n\", process);\n    }\n    //process exit event\n    else\n    {\n        //print\n        // ->only pid\n        NSLog(@\"process exit: %d\\n\", process.pid);\n    }\n};\n\n//start monitoring\n// ->pass in block for events\n[processInfo start:block];\n\n//run loop\n// ->as don't want to exit\n[[NSRunLoop currentRunLoop] run];\n```\nExecuting this code, and starting a process such as `Calculator.app` results in the following output:\n\n```Objective-C\n# ./procInfoExample:\n\nprocess start: \npid: 1337\npath: /Applications/Calculator.app/Contents/MacOS/Calculator\nuser: 501\nargs: (\n    \"/Applications/Calculator.app/Contents/MacOS/Calculator\"\n)\nancestors: (\n    557,\n    554,\n    353,\n    1\n)\nbinary: name: Calculator\npath: /Applications/Calculator.app/Contents/MacOS/Calculator\nattributes: {\n    NSFileCreationDate = \"2017-03-23 00:27:11 +0000\";\n    NSFileExtensionHidden = 0;\n    NSFileGroupOwnerAccountID = 0;\n    NSFileGroupOwnerAccountName = wheel;\n    NSFileHFSCreatorCode = 0;\n    NSFileHFSTypeCode = 0;\n    NSFileModificationDate = \"2017-03-23 00:27:11 +0000\";\n    NSFileOwnerAccountID = 0;\n    NSFileOwnerAccountName = root;\n    NSFilePosixPermissions = 493;\n    NSFileReferenceCount = 1;\n    NSFileSize = 199520;\n    NSFileSystemFileNumber = 92435925;\n    NSFileSystemNumber = 16777220;\n    NSFileType = NSFileTypeRegular;\n}\nsigning info: {\n    signatureStatus = 0;\n    signedByApple = 1;\n    signingAuthorities =     (\n        \"Software Signing\",\n        \"Apple Code Signing Certification Authority\",\n        \"Apple Root CA\"\n    );\n} (isApple: 1 / isAppStore: 0)\n2017-08-07 08:49:02.199 procInfoExample[10393:3296896] process exit: 1337\n```\nIt should be noted that if the Proc Info library is not running with root privileges, or is executed on an older version of macOS (pre 10.12.4) it will only monitor for application events (i.e. not terminal nor background processes). This is because in order to safely monitor for audit events, root and recent version of macOS is required.\n\n**Mahalo!**<br>\nThis product is supported by the following patrons:\n+ Halo Privacy \n+ Ash Morgan\n\n+ Nando Mendonca\n+ Khalil Sehnaoui\n+ Jeff Golden\n+ Geoffrey Weber\n\n+ Ming\n+ Peter Sinclair\n+ trifero\n+ Keelian Wardle\n+ Chad Collins\n+ Shain Singh\n+ David Sulpy\n+ Martin OConnell\n+ Bill Smartt\n+ Mike Windham\n+ Brent Joyce\n+ Russell Imrie\n+ Michael Thomas\n+ Andy One\n+ Edmund Harriss\n+ Brad Knowles\n+ Tom Smith\n+ Chuck Talk\n+ Derivative Fool\n+ Joaquim Espinhara\n+ Rudolf Coetzee\n+ Chris Ferebee\n+ Les Aker\n+ Allen Hancock\n+ Stuart Ashenbrenner\n\n+ Gamer_Bot\n\nWant to add your support? Check out my [patreon page](https://www.patreon.com/objective_see) :)\n"
  },
  {
    "path": "lib/procInfo.h",
    "content": "//\n//  File: procInfo.h\n//  Project: Proc Info\n//\n//  Created by: Patrick Wardle\n//  Copyright:  2017 Objective-See\n//  License:    Creative Commons Attribution-NonCommercial 4.0 International License\n//\n\n#ifndef procInfo_h\n#define procInfo_h\n\n#import <libproc.h>\n#import <sys/sysctl.h>\n#import <Foundation/Foundation.h>\n\n/* CLASSES */\n\n@class Binary;\n@class Process;\n\n/* DEFINES */\n\n//from audit_kevents.h\n#define EVENT_EXIT\t\t1\n#define\tEVENT_FORK      2   \n#define EVENT_EXECVE    23\n#define EVENT_EXEC      27\n#define EVENT_SPAWN     43190\n\n//signers\nenum Signer{None, Apple, AppStore, DevID, AdHoc};\n\n//signature status\n#define KEY_SIGNATURE_STATUS @\"signatureStatus\"\n\n//signer\n#define KEY_SIGNATURE_SIGNER @\"signatureSigner\"\n\n//signing auths\n#define KEY_SIGNATURE_AUTHORITIES @\"signatureAuthorities\"\n\n//code signing id\n#define KEY_SIGNATURE_IDENTIFIER @\"signatureIdentifier\"\n\n//entitlements\n#define KEY_SIGNATURE_ENTITLEMENTS @\"signatureEntitlements\"\n\n/* TYPEDEFS */\n\n//block for library\ntypedef void (^ProcessCallbackBlock)(Process* _Nonnull);\n\n/* OBJECT: PROCESS INFO */\n\n@interface ProcInfo : NSObject\n\n//init w/ flag\n// flag dictates if CPU-intensive logic (code signing, etc) should be preformed\n-(id _Nullable)init:(BOOL)goEasy;\n\n//start monitoring\n-(void)start:(ProcessCallbackBlock _Nonnull )callback;\n\n//stop monitoring\n-(void)stop;\n\n//get list of running processes\n-(NSMutableArray* _Nonnull)currentProcesses;\n\n@end\n\n/* OBJECT: PROCESS */\n\n@interface Process : NSObject\n\n/* PROPERTIES */\n\n//pid\n@property pid_t pid;\n\n//ppid\n@property pid_t ppid;\n\n//user id\n@property uid_t uid;\n\n//type\n// used by process mon\n@property u_int16_t type;\n\n//exit code\n@property u_int32_t exit;\n\n//path\n@property(nonatomic, retain)NSString* _Nullable path;\n\n//args\n@property(nonatomic, retain)NSMutableArray* _Nonnull arguments;\n\n//ancestors\n@property(nonatomic, retain)NSMutableArray* _Nonnull ancestors;\n\n//signing info\n@property(nonatomic, retain)NSMutableDictionary* _Nonnull signingInfo;\n\n//Binary object\n// has path, hash, etc\n@property(nonatomic, retain)Binary* _Nonnull binary;\n\n//timestamp\n@property(nonatomic, retain)NSDate* _Nonnull timestamp;\n\n/* METHODS */\n\n//init with a pid\n// method will then (try) fill out rest of object\n-(id _Nullable)init:(pid_t)processID;\n\n//generate signing info\n// also classifies if Apple/from App Store/etc.\n-(void)generateSigningInfo:(SecCSFlags)flags;\n\n//set process's path\n-(void)pathFromPid;\n\n//generate list of ancestors\n-(void)enumerateAncestors;\n\n//class method\n// get's parent of arbitrary process\n+(pid_t)getParentID:(pid_t)child;\n\n@end\n\n/* OBJECT: BINARY */\n\n@interface Binary : NSObject\n{\n    \n}\n\n/* PROPERTIES */\n\n//path\n@property(nonatomic, retain)NSString* _Nonnull path;\n\n//name\n@property(nonatomic, retain)NSString* _Nonnull name;\n\n//icon\n@property(nonatomic, retain)NSImage* _Nonnull icon;\n\n//file attributes\n@property(nonatomic, retain)NSDictionary* _Nullable attributes;\n\n//spotlight meta data\n@property(nonatomic, retain)NSDictionary* _Nullable metadata;\n\n//bundle\n// nil for non-apps\n@property(nonatomic, retain)NSBundle* _Nullable bundle;\n\n//signing info\n@property(nonatomic, retain)NSDictionary* _Nonnull signingInfo;\n\n//hash\n@property(nonatomic, retain)NSMutableString* _Nonnull sha256;\n\n//identifier\n// either signing id or sha256 hash\n@property(nonatomic, retain)NSString* _Nonnull identifier;\n\n/* METHODS */\n\n//init w/ a path\n-(id _Nonnull)init:(NSString* _Nonnull)path;\n\n/* the following methods are rather CPU-intensive\n   as such, if the proc monitoring is run with the 'goEasy' option, they aren't automatically invoked\n*/\n \n//get an icon for a process\n// for apps, this will be app's icon, otherwise just a standard system one\n-(void)getIcon;\n\n//generate signing info (statically)\n-(void)generateSigningInfo:(SecCSFlags)flags;\n\n/* the following methods are not invoked automatically\n   as such, if you code has to manually invoke them if you want this info\n */\n\n//generate hash\n// algo: sha256\n-(void)generateHash;\n\n//generate id\n// either signing id, or sha256 hash\n-(void)generateIdentifier;\n\n@end\n\n#endif\n"
  },
  {
    "path": "procInfo/Binary.m",
    "content": "//\n//  File: Binary.m\n//  Project: Proc Info\n//\n//  Created by: Patrick Wardle\n//  Copyright:  2017 Objective-See\n//  License:    Creative Commons Attribution-NonCommercial 4.0 International License\n//\n\n#import \"Consts.h\"\n#import \"Signing.h\"\n#import \"procInfo.h\"\n#import \"Utilities.h\"\n\n#import <CommonCrypto/CommonDigest.h>\n\n@implementation Binary\n\n@synthesize icon;\n@synthesize name;\n@synthesize path;\n@synthesize bundle;\n@synthesize metadata;\n@synthesize attributes;\n\n//init binary object\n// note: CPU-intensive logic (code signing, etc) called manually\n-(id)init:(NSString*)binaryPath\n{\n    //init super\n    self = [super init];\n    if(nil != self)\n    {\n        //not a full path?\n        if(YES != [binaryPath hasPrefix:@\"/\"])\n        {\n            //try find via 'which'\n            self.path = PI_which(binaryPath);\n            if(nil == self.path)\n            {\n                //stuck with short path\n                self.path = binaryPath;\n            }\n        }\n        //full path\n        // use as is\n        else\n        {\n            //save path\n            self.path = binaryPath;\n        }\n        \n        //try load app bundle\n        // will be nil for non-apps\n        [self getBundle];\n        \n        //get name\n        [self getName];\n        \n        //get file attributes\n        [self getAttributes];\n        \n        //get meta data (spotlight)\n        [self getMetadata];\n    }\n\n    return self;\n}\n\n//try load app bundle\n// will be nil for non-apps\n-(void)getBundle\n{\n    //first try just with path\n    self.bundle = [NSBundle bundleWithPath:path];\n    \n    //that failed?\n    // try find it dynamically\n    if(nil == self.bundle)\n    {\n        //find bundle\n        self.bundle = PI_findAppBundle(path);\n    }\n    \n    return;\n}\n\n//figure out binary's name\n// either via app bundle, or from path\n-(void)getName\n{\n    //first try get name from app bundle\n    // specifically, via grab name from 'CFBundleName'\n    if(nil != self.bundle)\n    {\n        //extract name\n        self.name = [self.bundle infoDictionary][@\"CFBundleName\"];\n    }\n    \n    //no app bundle || no 'CFBundleName'\n    // just use last component from path\n    if(nil == self.name)\n    {\n        //set name\n        self.name = [self.path lastPathComponent];\n    }\n    \n    return;\n}\n\n//get file attributes\n-(void)getAttributes\n{\n    //grab (file) attributes\n    self.attributes = [[NSFileManager defaultManager] attributesOfItemAtPath:self.path error:nil];\n    \n    return;\n}\n\n//get (spotlight) meta data\n-(void)getMetadata\n{\n    //md item ref\n    MDItemRef mdItem = nil;\n    \n    //attributes names\n    CFArrayRef attributeNames = nil;\n\n    //create\n    mdItem = MDItemCreate(kCFAllocatorDefault, (CFStringRef)self.path);\n    if(nil == mdItem)\n    {\n        //bail\n        goto bail;\n    }\n    \n    //copy names\n    attributeNames = MDItemCopyAttributeNames(mdItem);\n    if(nil == attributeNames)\n    {\n        //bail\n        goto bail;\n    }\n    \n    //get metadata\n    self.metadata = CFBridgingRelease(MDItemCopyAttributes(mdItem, attributeNames));\n    \nbail:\n    \n    //release names\n    if(NULL != attributeNames)\n    {\n        //release\n        CFRelease(attributeNames);\n        \n        //unset\n        attributeNames = NULL;\n        \n    }\n    \n    //release md item\n    if(NULL != mdItem)\n    {\n        //release\n        CFRelease(mdItem);\n        \n        //unset\n        mdItem = NULL;\n    }\n\n    return;\n}\n\n//get an icon for a process\n// for apps, this will be app's icon, otherwise just a standard system one\n-(void)getIcon\n{\n    //icon's file name\n    NSString* iconFile = nil;\n    \n    //icon's path\n    NSString* iconPath = nil;\n    \n    //icon's path extension\n    NSString* iconExtension = nil;\n    \n    //skip 'short' paths\n    // otherwise system logs an error\n    if( (YES != [self.path hasPrefix:@\"/\"]) &&\n        (nil == self.bundle) )\n    {\n        //bail\n        goto bail;\n    }\n    \n    //for app's\n    // extract their icon\n    if(nil != self.bundle)\n    {\n        //get file\n        iconFile = self.bundle.infoDictionary[@\"CFBundleIconFile\"];\n        \n        //get path extension\n        iconExtension = [iconFile pathExtension];\n        \n        //if its blank (i.e. not specified)\n        // go with 'icns'\n        if(YES == [iconExtension isEqualTo:@\"\"])\n        {\n            //set type\n            iconExtension = @\"icns\";\n        }\n        \n        //set full path\n        iconPath = [self.bundle pathForResource:[iconFile stringByDeletingPathExtension] ofType:iconExtension];\n        \n        //load it\n        self.icon = [[NSImage alloc] initWithContentsOfFile:iconPath];\n    }\n    \n    //process is not an app or couldn't get icon\n    // try to get it via shared workspace\n    if( (nil == self.bundle) ||\n        (nil == self.icon) )\n    {\n        //extract icon\n        self.icon = [[NSWorkspace sharedWorkspace] iconForFile:self.path];\n    }\n    \n    //make standard size...\n    [self.icon setSize:NSMakeSize(128, 128)];\n    \nbail:\n    \n    return;\n}\n\n//statically, generate signing info\n-(void)generateSigningInfo:(SecCSFlags)flags\n{\n    //extract signing info statically\n    self.signingInfo = extractSigningInfo(0, self.path, flags);\n\n    return;\n}\n\n//generate hash\n-(void)generateHash\n{\n    //file's contents\n    NSData* fileContents = nil;\n    \n    //hash digest\n    uint8_t digestSHA256[CC_SHA256_DIGEST_LENGTH] = {0};\n    \n    //load file\n    fileContents = [NSData dataWithContentsOfFile:self.path];\n    if( (0 == fileContents.length) ||\n        (NULL == fileContents.bytes) )\n    {\n        //bail\n        goto bail;\n    }\n    \n    //clear buffer\n    bzero(digestSHA256, CC_SHA256_DIGEST_LENGTH);\n    \n    //sha it\n    CC_SHA256(fileContents.bytes, (unsigned int)fileContents.length, digestSHA256);\n    \n    //now init\n    self.sha256 = [NSMutableString string];\n    \n    //convert to NSString\n    // iterate over each byte in computed digest and format\n    for(NSUInteger index=0; index < CC_SHA256_DIGEST_LENGTH; index++)\n    {\n        //format/append\n        [self.sha256 appendFormat:@\"%02X\", digestSHA256[index]];\n    }\n    \nbail:\n\n    return;\n}\n\n//generate id\n// either signing id, or sha256 hash\n// note: will generate signing info if needed\n-(void)generateIdentifier\n{\n    //generate signing info?\n    if(nil == self.signingInfo)\n    {\n        //generate\n        [self generateSigningInfo:kSecCSDefaultFlags];\n    }\n    \n    //validly signed binary?\n    // use its signing identifier\n    if( (noErr == [self.signingInfo[KEY_SIGNATURE_STATUS] intValue]) &&\n        (0 != [self.signingInfo[KEY_SIGNATURE_AUTHORITIES] count]) &&\n        (nil != self.signingInfo[KEY_SIGNATURE_IDENTIFIER]) )\n    {\n        //use signing id\n        self.identifier = self.signingInfo[KEY_SIGNATURE_IDENTIFIER];\n    }\n    //not validly signed or unsigned\n    // generate sha256 hash for identifier\n    else\n    {\n        //generate hash?\n        if(0 != self.sha256.length)\n        {\n            //hash\n            [self generateHash];\n        }\n        \n        //use hash\n        self.identifier = self.sha256;\n    }\n    \n    return;\n}\n\n//for pretty printing\n-(NSString *)description\n{\n    //pretty print\n    return [NSString stringWithFormat: @\"name: %@\\npath: %@\\nattributes: %@\\nsigning info: %@\", self.name, self.path, self.attributes, self.signingInfo];\n}\n\n@end\n"
  },
  {
    "path": "procInfo/Consts.h",
    "content": "//\n//  File: Consts.h\n//  Project: Proc Info\n//\n//  Created by: Patrick Wardle\n//  Copyright:  2017 Objective-See\n//  License:    Creative Commons Attribution-NonCommercial 4.0 International License\n//\n\n#ifndef Consts_h\n#define Consts_h\n\n//OS version x\n#define OS_MAJOR_VERSION_X 10\n\n//OS version lion\n#define OS_MINOR_VERSION_LION 8\n\n//OS version sierra\n#define OS_MINOR_VERSION_SIERRA 12\n\n//audit pipe\n#define AUDIT_PIPE \"/dev/auditpipe\"\n\n//audit class for proc events\n#define AUDIT_CLASS_PROCESS 0x00000080\n\n//audit class for exec events\n#define AUDIT_CLASS_EXEC 0x40000000\n\n//key for stdout output\n#define STDOUT @\"stdOutput\"\n\n//key for stderr output\n#define STDERR @\"stdError\"\n\n//key for exit code\n#define EXIT_CODE @\"exitCode\"\n\n//path to codesign\n#define CODE_SIGN @\"/usr/bin/codesign\"\n\n//entitlements\n#define KEY_SIGNING_ENTITLEMENTS @\"entitlements\"\n\n#endif /* Consts_h */\n"
  },
  {
    "path": "procInfo/Process.m",
    "content": "//\n//  File: Process.m\n//  Project: Proc Info\n//\n//  Created by: Patrick Wardle\n//  Copyright:  2017 Objective-See\n//  License:    Creative Commons Attribution-NonCommercial 4.0 International License\n//\n\n#import \"Signing.h\"\n#import \"procInfo.h\"\n#import \"Utilities.h\"\n\n@implementation Process\n\n@synthesize pid;\n@synthesize exit;\n@synthesize path;\n@synthesize ppid;\n@synthesize ancestors;\n@synthesize arguments;\n@synthesize timestamp;\n@synthesize signingInfo;\n\n//init\n-(id)init\n{\n    //init super\n    self = [super init];\n    if(nil != self)\n    {\n        //alloc array for args\n        arguments = [NSMutableArray array];\n        \n        //alloc array for parents\n        ancestors  = [NSMutableArray array];\n        \n        //alloc array for args\n        arguments = [NSMutableArray array];\n        \n        //set start time\n        timestamp = [NSDate date];\n        \n        //init pid\n        self.pid = -1;\n        \n        //init ppid\n        self.ppid = -1;\n        \n        //init user\n        self.uid = -1;\n        \n        //init exit\n        self.exit = -1;\n    }\n    \n    return self;\n}\n\n//init with a pid\n// method will then (try) fill out rest of object\n-(id)init:(pid_t)processID\n{\n    //init self/super\n    self = [self init];\n    if(self)\n    {\n        //save pid\n        self.pid = processID;\n        \n        //set parent\n        self.ppid = [[self class] getParentID:self.pid];\n        \n        //get path\n        [self pathFromPid];\n        if(0 == self.path.length)\n        {\n            #ifdef DEBUG\n            \n            //err msg\n            NSLog(@\"ERROR: failed to find path for process %d\\n\", self.pid);\n            \n            #endif\n            \n            //unset\n            self = nil;\n            \n            //bail\n            goto bail;\n        }\n        \n        //set args\n        [self getArgs];\n        \n        //set user\n        [self getUser];\n        \n        //enum ancestors\n        [self enumerateAncestors];\n    \n        //init binary\n        self.binary = [[Binary alloc] init:self.path];\n    }\n    \nbail:\n    \n    return self;\n}\n\n//get uid\n// sets 'user' instance var\n-(void)getUser\n{\n    //kinfo_proc struct\n    struct kinfo_proc processStruct = {0};\n    \n    //size\n    size_t procBufferSize = 0;\n    \n    //mib\n    const u_int mibLength = 4;\n    \n    //syscall result\n    int sysctlResult = -1;\n    \n    //init buffer length\n    procBufferSize = sizeof(processStruct);\n    \n    //init mib\n    int mib[mibLength] = {CTL_KERN, KERN_PROC, KERN_PROC_PID, self.pid};\n    \n    //make syscall\n    sysctlResult = sysctl(mib, mibLength, &processStruct, &procBufferSize, NULL, 0);\n    \n    //check if got ppid\n    if( (noErr == sysctlResult) &&\n        (0 != procBufferSize) )\n    {\n        //save uid\n        self.uid = processStruct.kp_eproc.e_ucred.cr_uid;\n    }\n    \n    return;\n}\n\n//generate list of ancestors\n-(void)enumerateAncestors\n{\n    //current process id\n    pid_t currentPID = -1;\n    \n    //parent pid\n    pid_t parentPID = -1;\n    \n    //add parent\n    if(-1 != self.ppid)\n    {\n        //add\n        [self.ancestors addObject:[NSNumber numberWithInt:self.ppid]];\n        \n        //set current to parent\n        currentPID = self.ppid;\n    }\n    //don't know parent\n    // just start with self\n    else\n    {\n        //start w/ self\n        currentPID = self.pid;\n    }\n    \n    //add until we get to to end (pid 0)\n    // or error out during the traversal\n    while(YES)\n    {\n        //get parent pid\n        parentPID = [Process getParentID:currentPID];\n        if( (0 == parentPID) ||\n            (-1 == parentPID) ||\n            (currentPID == parentPID) )\n        {\n            //bail\n            break;\n        }\n        \n        //update\n        currentPID = parentPID;\n        \n        //add\n        [self.ancestors addObject:[NSNumber numberWithInt:parentPID]];\n    }\n    \n    return;\n}\n\n//set process's path\n-(void)pathFromPid\n{\n    //buffer for process path\n    char pathBuffer[PROC_PIDPATHINFO_MAXSIZE] = {0};\n    \n    //status\n    int status = -1;\n    \n    //'management info base' array\n    int mib[3] = {0};\n    \n    //system's size for max args\n    int systemMaxArgs = 0;\n    \n    //process's args\n    char* processArgs = NULL;\n    \n    //size of buffers, etc\n    size_t size = 0;\n    \n    //clear out buffer\n    bzero(pathBuffer, PROC_PIDPATHINFO_MAXSIZE);\n    \n    //1st:\n    // attempt to get path via 'proc_pidpath()'\n    status = proc_pidpath(self.pid, pathBuffer, sizeof(pathBuffer));\n    if( (0 != status) &&\n        (0 != strlen(pathBuffer)) )\n    {\n        //init path\n        self.path = [NSString stringWithUTF8String:pathBuffer];\n        \n        //all set\n        goto bail;\n    }\n    \n    //2nd:\n    // try via process's args ('KERN_PROCARGS2')\n   \n    //init mib\n    // want system's size for max args\n    mib[0] = CTL_KERN;\n    mib[1] = KERN_ARGMAX;\n        \n    //set size\n    size = sizeof(systemMaxArgs);\n    \n    //get system's size for max args\n    if(-1 == sysctl(mib, 2, &systemMaxArgs, &size, NULL, 0))\n    {\n        //bail\n        goto bail;\n    }\n    \n    //alloc space for args\n    processArgs = calloc(systemMaxArgs, sizeof(char));\n    if(NULL == processArgs)\n    {\n        //bail\n        goto bail;\n    }\n    \n    //init mib\n    // want process args\n    mib[0] = CTL_KERN;\n    mib[1] = KERN_PROCARGS2;\n    mib[2] = pid;\n    \n    //set size\n    size = (size_t)systemMaxArgs;\n    \n    //get process's args\n    if(-1 == sysctl(mib, 3, processArgs, &size, NULL, 0))\n    {\n        //bail\n        goto bail;\n    }\n    \n    //sanity check\n    // ensure buffer is somewhat sane\n    if(size <= sizeof(int))\n    {\n        //bail\n        goto bail;\n    }\n    \n    //extract process name\n    // follows # of args (int) and is NULL-terminated\n    self.path = [NSString stringWithUTF8String:processArgs + sizeof(int)];\n    \nbail:\n    \n    //free process args\n    if(NULL != processArgs)\n    {\n        //free\n        free(processArgs);\n        \n        //unset\n        processArgs = NULL;\n    }\n    \n    return;\n}\n\n//check if process is alive\n-(BOOL)isProcessAlive\n{\n    //ret var\n    BOOL bIsAlive = NO;\n    \n    //signal status\n    int signalStatus = -1;\n    \n    //send kill with 0 to determine if alive\n    // see: http://stackoverflow.com/questions/9152979/check-if-process-exists-given-its-pid\n    signalStatus = kill(self.pid, 0);\n    \n    //is alive?\n    if( (0 == signalStatus) ||\n        ( (0 != signalStatus) && (errno != ESRCH) ) )\n    {\n        //alive!\n        bIsAlive = YES;\n    }\n    \n    return bIsAlive;\n}\n\n//extract commandline args\n// saves into 'arguments' ivar\n-(void)getArgs\n{\n    //'management info base' array\n    int mib[3] = {0};\n    \n    //system's size for max args\n    int systemMaxArgs = 0;\n    \n    //process's args\n    char* processArgs = NULL;\n    \n    //# of args\n    int numberOfArgs = 0;\n    \n    //start of (each) arg\n    char* argStart = NULL;\n    \n    //size of buffers, etc\n    size_t size = 0;\n    \n    //parser pointer\n    char* parser = NULL;\n    \n    //init mib\n    // want system's size for max args\n    mib[0] = CTL_KERN;\n    mib[1] = KERN_ARGMAX;\n    \n    //set size\n    size = sizeof(systemMaxArgs);\n    \n    //get system's size for max args\n    if(-1 == sysctl(mib, 2, &systemMaxArgs, &size, NULL, 0))\n    {\n        //bail\n        goto bail;\n    }\n    \n    //alloc space for args\n    processArgs = malloc(systemMaxArgs);\n    if(NULL == processArgs)\n    {\n        //bail\n        goto bail;\n    }\n    \n    //init mib\n    // want process args\n    mib[0] = CTL_KERN;\n    mib[1] = KERN_PROCARGS2;\n    mib[2] = pid;\n    \n    //set size\n    size = (size_t)systemMaxArgs;\n    \n    //get process's args\n    if(-1 == sysctl(mib, 3, processArgs, &size, NULL, 0))\n    {\n        //bail\n        goto bail;\n    }\n    \n    //sanity check\n    // ensure buffer is somewhat sane\n    if(size <= sizeof(int))\n    {\n        //bail\n        goto bail;\n    }\n    \n    //extract number of args\n    // at start of buffer\n    memcpy(&numberOfArgs, processArgs, sizeof(numberOfArgs));\n    \n    //init pointer to start of args\n    // they start right after # of args\n    parser = processArgs + sizeof(numberOfArgs);\n    \n    //scan until end of process's NULL-terminated path\n    while(parser < &processArgs[size])\n    {\n        //scan till NULL-terminator\n        if(0x0 == *parser)\n        {\n            //end of exe name\n            break;\n        }\n        \n        //next char\n        parser++;\n    }\n    \n    //sanity check\n    // make sure end-of-buffer wasn't reached\n    if(parser == &processArgs[size])\n    {\n        //bail\n        goto bail;\n    }\n    \n    //skip all trailing NULLs\n    // scan will end when non-NULL is found\n    while(parser < &processArgs[size])\n    {\n        //scan till NULL-terminator\n        if(0x0 != *parser)\n        {\n            //ok, got to argv[0]\n            break;\n        }\n        \n        //next char\n        parser++;\n    }\n    \n    //sanity check\n    // (again), make sure end-of-buffer wasn't reached\n    if(parser == &processArgs[size])\n    {\n        //bail\n        goto bail;\n    }\n    \n    //parser should now point to argv[0], process name\n    // init arg start\n    argStart = parser;\n    \n    //keep scanning until all args are found\n    // each is NULL-terminated\n    while(parser < &processArgs[size])\n    {\n        //each arg is NULL-terminated\n        // so scan till NULL, then save into array\n        if(*parser == '\\0')\n        {\n            //save arg\n            if(NULL != argStart)\n            {\n                //save\n                [self.arguments addObject:[NSString stringWithUTF8String:argStart]];\n            }\n            \n            //init string pointer to (possibly) next arg\n            argStart = ++parser;\n            \n            //bail if we've hit arg cnt\n            if(self.arguments.count == numberOfArgs)\n            {\n                //bail\n                break;\n            }\n        }\n        \n        //next char\n        parser++;\n    }\n    \nbail:\n    \n    //free process args\n    if(NULL != processArgs)\n    {\n        //free\n        free(processArgs);\n        \n        //unset\n        processArgs = NULL;\n    }\n    \n    return;\n}\n\n//generate signing info\n// also classifies if Apple/from App Store/etc.\n-(void)generateSigningInfo:(SecCSFlags)flags\n{\n    //extract signing info dynamically\n    self.signingInfo = extractSigningInfo(self.pid, nil, flags);\n    \n    //failed?\n    // try extract signing info statically\n    if(nil == self.signingInfo)\n    {\n        //add 'all archs' / 'nested'\n        // cuz don't know which is/was running\n        flags |= kSecCSCheckAllArchitectures | kSecCSCheckNestedCode | kSecCSDoNotValidateResources;\n        \n        //extract signing info statically\n        self.signingInfo = extractSigningInfo(0, self.binary.path, flags);\n    }\n\n    return;\n}\n\n//for pretty printing\n-(NSString *)description\n{\n    //pretty print\n    return [NSString stringWithFormat: @\"pid: %d\\npath: %@\\nuser: %d\\nargs: %@\\nancestors: %@\\n signing info: %@\\n binary:\\n%@\", self.pid, self.path, self.uid, self.arguments, self.ancestors, self.signingInfo, self.binary];\n}\n\n//class method to get parent of arbitrary process\n+(pid_t)getParentID:(pid_t)child\n{\n    //parent id\n    pid_t parentID = -1;\n    \n    //kinfo_proc struct\n    struct kinfo_proc processStruct = {0};\n    \n    //size\n    size_t procBufferSize = 0;\n    \n    //mib\n    const u_int mibLength = 4;\n    \n    //syscall result\n    int sysctlResult = -1;\n    \n    //init buffer length\n    procBufferSize = sizeof(processStruct);\n    \n    //init mib\n    int mib[mibLength] = {CTL_KERN, KERN_PROC, KERN_PROC_PID, child};\n    \n    //make syscall\n    sysctlResult = sysctl(mib, mibLength, &processStruct, &procBufferSize, NULL, 0);\n    \n    //check if got ppid\n    if( (noErr == sysctlResult) &&\n        (0 != procBufferSize) )\n    {\n        //save ppid\n        parentID = processStruct.kp_eproc.e_ppid;\n    }\n    \n    return parentID;\n}\n\n@end\n"
  },
  {
    "path": "procInfo/ProcessMonitor.m",
    "content": "//\n//  File: ProcessMonitor.m\n//  Project: Proc Info\n//\n//  Created by: Patrick Wardle\n//  Copyright:  2017 Objective-See\n//  License:    Creative Commons Attribution-NonCommercial 4.0 International License\n//\n\n//disable incomplete/umbrella warnings\n// otherwise complains about 'audit_kevents.h'\n#pragma clang diagnostic ignored \"-Wincomplete-umbrella\"\n\n#import \"Consts.h\"\n#import \"procInfo.h\"\n#import \"Utilities.h\"\n\n#import <unistd.h>\n#import <libproc.h>\n#import <pthread.h>\n#import <bsm/audit.h>\n#import <sys/ioctl.h>\n#import <sys/types.h>\n#import <bsm/libbsm.h>\n#import <Cocoa/Cocoa.h>\n#import <bsm/audit_kevents.h>\n#import <security/audit/audit_ioctl.h>\n\n@interface ProcInfo()\n\n/* INSTANCE VARIABLES */\n\n//skip CPU-intensive logic\n@property BOOL goEasy;\n\n//callback block\n@property(nonatomic, copy)ProcessCallbackBlock processCallback;\n\n//stop flag\n@property BOOL shouldStop;\n\n@end\n\n@implementation ProcInfo\n\n//init\n// just check OS version\n-(id _Nullable)init\n{\n    //super\n    self = [super init];\n    if(self)\n    {\n        //make sure OS is supported\n        // for now, OS X 10.8+ though could be earlier?\n        if(YES != PI_isSupportedOS())\n        {\n            //err msg\n            NSLog(@\"ERROR: %@ is not a supported OS\", PI_getOSVersion());\n            \n            //unset\n            self = nil;\n            \n            //bail\n            goto bail;\n        }\n    }\n    \nbail:\n    \n    return self;\n}\n\n//init w/ flag\n// flag dictates if CPU-intensive logic (code signing, etc) should be preformed\n-(id _Nullable)init:(BOOL)goEasy;\n{\n    //init\n    // calls 'super' too\n    self = [self init];\n    if(self)\n    {\n        //save mode\n        self.goEasy = goEasy;\n    }\n    \nbail:\n    \n    return self;\n}\n\n//start monitoring\n// note: requires root/macOS 10.12.4+ for full monitoring\n-(void)start:(ProcessCallbackBlock)callback\n{\n    //OS version info\n    NSDictionary* osVersionInfo = nil;\n    \n    //save\n    self.processCallback = callback;\n    \n    //get OS version info\n    osVersionInfo = PI_getOSVersion();\n\n    //do basic (app) monitoring\n    // if not root, or OS version is < 10.12.4 (due to kernel bug)\n    if( (0 != getuid()) ||\n        ([osVersionInfo[@\"minorVersion\"] intValue] < OS_MINOR_VERSION_SIERRA) ||\n        (([osVersionInfo[@\"minorVersion\"] intValue] == OS_MINOR_VERSION_SIERRA) && ([osVersionInfo[@\"bugfixVersion\"] intValue] < 4)) )\n    {\n        //setup app monitoring\n        [self appMonitor];\n    }\n    \n    //otherwise, enable full monitoring\n    else\n    {\n        //start process monitoring via openBSM to get apps & procs\n        // sits in while(YES) loop, so we invoke call in a background thread\n        dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{\n            \n            //monitor\n            [self monitor];\n            \n        });\n    }\n\n    return;\n}\n\n//stop monitoring\n-(void)stop\n{\n    //stop app monitoring\n    // can always call, even if we didn't setup app monitor\n    [[NSNotificationCenter defaultCenter] removeObserver: self];\n    \n    //set 'stop' monitor bool\n    // is checked in 'monitor' method as termination condition\n    self.shouldStop = YES;\n    \n    return;\n}\n\n//monitor for new process events\n-(void)monitor\n{\n    //event mask\n    // what event classes to watch for\n    u_int eventClasses = AUDIT_CLASS_EXEC | AUDIT_CLASS_PROCESS;\n    \n    //file pointer to audit pipe\n    FILE* auditFile = NULL;\n    \n    //file descriptor for audit pipe\n    int auditFileDescriptor = -1;\n    \n    //status var\n    int status = -1;\n    \n    //preselect mode\n    int mode = -1;\n    \n    //queue length\n    int maxQueueLength = -1;\n    \n    //record buffer\n    u_char* recordBuffer = NULL;\n    \n    //token struct\n    tokenstr_t tokenStruct = {0};\n    \n    //total length of record\n    int recordLength = -1;\n    \n    //amount of record left to process\n    int recordBalance = -1;\n    \n    //amount currently processed\n    int processedLength = -1;\n    \n    //process record obj\n    Process* process = nil;\n    \n    //last fork\n    Process* lastFork = nil;\n    \n    //argument\n    NSString* argument = nil;\n    \n    //open audit pipe for reading\n    auditFile = fopen(AUDIT_PIPE, \"r\");\n    if(auditFile == NULL)\n    {\n        #ifdef DEBUG\n        \n        //err msg\n        NSLog(@\"ERROR: failed to open audit pipe %s\", AUDIT_PIPE);\n        \n        #endif\n        \n        //bail\n        goto bail;\n    }\n    \n    //grab file descriptor\n    auditFileDescriptor = fileno(auditFile);\n    \n    //init mode\n    mode = AUDITPIPE_PRESELECT_MODE_LOCAL;\n    \n    //set preselect mode\n    status = ioctl(auditFileDescriptor, AUDITPIPE_SET_PRESELECT_MODE, &mode);\n    if(-1 == status)\n    {\n        //bail\n        goto bail;\n    }\n    \n    //grab max queue length\n    status = ioctl(auditFileDescriptor, AUDITPIPE_GET_QLIMIT_MAX, &maxQueueLength);\n    if(-1 == status)\n    {\n        //bail\n        goto bail;\n    }\n    \n    //set queue length to max\n    status = ioctl(auditFileDescriptor, AUDITPIPE_SET_QLIMIT, &maxQueueLength);\n    if(-1 == status)\n    {\n        //bail\n        goto bail;\n        \n    }\n    \n    //set preselect flags\n    // event classes we're interested in\n    status = ioctl(auditFileDescriptor, AUDITPIPE_SET_PRESELECT_FLAGS, &eventClasses);\n    if(-1 == status)\n    {\n        //bail\n        goto bail;\n    }\n    \n    //set non-attributable flags\n    // event classes we're interested in\n    status = ioctl(auditFileDescriptor, AUDITPIPE_SET_PRESELECT_NAFLAGS, &eventClasses);\n    if(-1 == status)\n    {\n        //bail\n        goto bail;\n    }\n    \n    //forever\n    // read/parse/process audit records\n    while(YES)\n    {\n        @autoreleasepool\n        {\n            \n        //first check termination flag/condition\n        if(YES == self.shouldStop)\n        {\n            //bail\n            goto bail;\n        }\n        \n        //reset process record object\n        process = nil;\n        \n        //free prev buffer\n        if(NULL != recordBuffer)\n        {\n            //free\n            free(recordBuffer);\n            \n            //unset\n            recordBuffer = NULL;\n        }\n        \n        //read a single audit record\n        // note: buffer is allocated by function, so must be freed when done\n        recordLength = au_read_rec(auditFile, &recordBuffer);\n        \n        //sanity check\n        if(-1 == recordLength)\n        {\n            //continue\n            continue;\n        }\n        \n        //init (remaining) balance to record's total length\n        recordBalance = recordLength;\n        \n        //init processed length to start (zer0)\n        processedLength = 0;\n        \n        //parse record\n        // read all tokens/process\n        while(0 != recordBalance)\n        {\n            //extract token\n            // and sanity check\n            if(-1  == au_fetch_tok(&tokenStruct, recordBuffer + processedLength, recordBalance))\n            {\n                //error\n                // skip record\n                break;\n            }\n            \n            //ignore records that are not related to process exec'ing/spawning\n            // gotta wait till we hit/capture a AUT_HEADER* though, as this has the event type\n            if( (nil != process) &&\n                (YES != [self shouldProcessRecord:process.type]) )\n            {\n                //bail\n                // skips rest of record\n                break;\n            }\n            \n            //process token(s)\n            // create Process object, etc\n            switch(tokenStruct.id)\n            {\n                //handle start of record\n                // grab event type, which allows us to ignore events not of interest\n                case AUT_HEADER32:\n                case AUT_HEADER32_EX:\n                case AUT_HEADER64:\n                case AUT_HEADER64_EX:\n                {\n                    //create a new process\n                    process = [[Process alloc] init];\n                    \n                    //save type\n                    process.type = tokenStruct.tt.hdr32.e_type;\n                    \n                    break;\n                }\n                    \n                //path\n                // note: this might be updated/replaced later (if it's '/dev/null', etc)\n                case AUT_PATH:\n                {\n                    //save path\n                    process.path = [NSString stringWithUTF8String:tokenStruct.tt.path.path];\n                    \n                    break;\n                }\n                    \n                //subject\n                //  extract/save pid || ppid\n                //  all these cases can be treated as subj32 cuz only accessing initial members\n                case AUT_SUBJECT32:\n                case AUT_SUBJECT32_EX:\n                case AUT_SUBJECT64:\n                case AUT_SUBJECT64_EX:\n                {\n                    //SPAWN (pid/ppid)\n                    // if there was an AUT_ARG32 (which always come first), that's the pid! so this will be the ppid\n                    if(AUE_POSIX_SPAWN == process.type)\n                    {\n                        //no AUT_ARG32?\n                        // set as pid, and try manually to get ppid\n                        if(-1 == process.pid)\n                        {\n                            //set pid\n                            process.pid = tokenStruct.tt.subj32.pid;\n                            \n                            //manually get parent\n                            process.ppid = [Process getParentID:process.pid];\n                        }\n                        //pid already set (via AUT_ARG32)\n                        // this then, is the ppid\n                        else\n                        {\n                            //set ppid\n                            process.ppid = tokenStruct.tt.subj32.pid;\n                        }\n                    }\n                    \n                    //FORK\n                    // ppid (pid is in AUT_ARG32)\n                    else if(AUE_FORK == process.type)\n                    {\n                        //set ppid\n                        process.ppid = tokenStruct.tt.subj32.pid;\n                    }\n                    \n                    //AUE_EXEC/VE & AUE_EXIT\n                    // this is the pid\n                    else\n                    {\n                        //save pid\n                        process.pid = tokenStruct.tt.subj32.pid;\n                        \n                        //manually get parent\n                        process.ppid = [Process getParentID:process.pid];\n                    }\n                    \n                    //get effective user id\n                    process.uid = tokenStruct.tt.subj32.euid;\n                    \n                    break;\n                }\n                    \n                //args\n                // SPAWN/FORK this is pid\n                case AUT_ARG32:\n                case AUT_ARG64:\n                {\n                    //save pid\n                    if( (AUE_POSIX_SPAWN == process.type) ||\n                        (AUE_FORK == process.type) )\n                    {\n                        //32bit\n                        if(AUT_ARG32 == tokenStruct.id)\n                        {\n                            //save\n                            process.pid = tokenStruct.tt.arg32.val;\n                        }\n                        //64bit\n                        else\n                        {\n                            //save\n                            process.pid = (pid_t)tokenStruct.tt.arg64.val;\n                        }\n                    }\n                    \n                    //FORK\n                    // doesn't have token for path, so try manually find it now\n                    if(AUE_FORK == process.type)\n                    {\n                        //set path\n                        [process pathFromPid];\n                    }\n                    \n                    break;\n                }\n                    \n                //exec args\n                // just save into args\n                case AUT_EXEC_ARGS:\n                {\n                    //save args\n                    for(int i = 0; i<tokenStruct.tt.execarg.count; i++)\n                    {\n                        //try create arg\n                        // this sometimes fails, not sure why?\n                        argument = [NSString stringWithUTF8String:tokenStruct.tt.execarg.text[i]];\n                        if(nil == argument)\n                        {\n                            //next\n                            continue;\n                        }\n                        \n                        //add argument\n                        [process.arguments addObject:argument];\n                    }\n                    \n                    break;\n                }\n                    \n                //exit\n                // save status\n                case AUT_EXIT:\n                {\n                    //save\n                    process.exit = tokenStruct.tt.exit.status;\n                    \n                    break;\n                }\n                    \n                //record trailer\n                // end/save, etc\n                case AUT_TRAILER:\n                {\n                    //end\n                    if( (nil != process) &&\n                        (YES == [self shouldProcessRecord:process.type]) )\n                    {\n                        //handle process exits\n                        if(AUE_EXIT == process.type)\n                        {\n                            //handle\n                            [self handleProcessExit:process];\n                        }\n                        \n                        //handle process starts\n                        else\n                        {\n                            //also try get process path\n                            // this is the most 'trusted way' (since exec_args can change)\n                            [process pathFromPid];\n                            \n                            //failed to get path at runtime\n                            // if 'AUT_PATH' was something like '/dev/null' or '/dev/console' use arg[0]...yes this can be spoofed :/\n                            if( ((0 == process.path.length) || (YES == [process.path hasPrefix:@\"/dev/\"])) &&\n                                 (0 != process.arguments.count) )\n                            {\n                                //use arg[0]\n                                process.path = process.arguments.firstObject;\n                            }\n                            \n                            //save fork events\n                            // this will have ppid that can be used for child events (exec/spawn, etc)\n                            if(AUE_FORK == process.type)\n                            {\n                                //save\n                                lastFork = process;\n                            }\n                            \n                            //when we don't have a ppid\n                            // see if there was a 'matching' fork() that has it (only for non AUE_FORK events)\n                            else if( (-1 == process.ppid)  &&\n                                     (lastFork.pid == process.pid) )\n                            {\n                                //update\n                                process.ppid = lastFork.ppid;\n                            }\n                            \n                            //handle new process\n                            [self handleProcessStart:process];\n                        }\n                    }\n                    \n                    //unset\n                    process = nil;\n                    \n                    break;\n                }\n                    \n                    \n                default:\n                    ;\n                    \n            }//process token\n            \n            \n            //add length of current token\n            processedLength += tokenStruct.len;\n            \n            //subtract lenght of current token\n            recordBalance -= tokenStruct.len;\n        }\n            \n        }//autorelease\n    \n    } //while(YES)\n    \nbail:\n    \n    //free buffer\n    if(NULL != recordBuffer)\n    {\n        //free\n        free(recordBuffer);\n        \n        //unset\n        recordBuffer = NULL;\n    }\n    \n    //close audit pipe\n    if(NULL != auditFile)\n    {\n        //close\n        fclose(auditFile);\n        \n        //unset\n        auditFile = NULL;\n    }\n    \n    return;\n}\n\n//check if event is one we care about\n// for now, just anything associated with new processes/exits\n-(BOOL)shouldProcessRecord:(u_int16_t)eventType\n{\n    //flag\n    BOOL shouldProcess =  NO;\n    \n    //check\n    if( (eventType == AUE_EXEC) ||\n        (eventType == AUE_EXIT) ||\n        (eventType == AUE_FORK) ||\n        (eventType == AUE_EXECVE) ||\n        (eventType == AUE_POSIX_SPAWN) )\n    {\n        //set flag\n        shouldProcess = YES;\n    }\n    \n    return shouldProcess;\n}\n\n//register for app launchings\n-(void)appMonitor\n{\n    //notification center\n    NSNotificationCenter* center = nil;\n    \n    //get shared center\n    center = [[NSWorkspace sharedWorkspace] notificationCenter];\n    \n    //register app start notification\n    [center addObserver:self selector:@selector(appEvent:) name:NSWorkspaceDidLaunchApplicationNotification object:nil];\n    \n    //register app exit notifcation\n    [center addObserver:self selector:@selector(appEvent:) name:NSWorkspaceDidTerminateApplicationNotification object:nil];\n    \n    return;\n}\n\n//automatically invoked when an app is started/exits\n// create new process object and add to dictionary\n-(void)appEvent:(NSNotification *)notification\n{\n    //process object\n    Process* process = nil;\n    \n    //pid\n    pid_t processID = -1;\n    \n    //get process id\n    processID = [notification.userInfo[@\"NSApplicationProcessIdentifier\"] intValue];\n    \n    //app start?\n    if(YES == [notification.name isEqualToString:@\"NSWorkspaceDidLaunchApplicationNotification\"])\n    {\n        //create a new process obj\n        process = [[Process alloc] init:processID];\n        if(nil == process)\n        {\n            #ifdef DEBUG\n            \n            //err msg\n            NSLog(@\"ERROR: failed to create process object for %d/%@\", processID, notification.userInfo);\n            \n            #endif\n            \n            //bail\n            goto bail;\n        }\n        \n        //start event\n        [self handleProcessStart:process];\n    }\n    \n    //app exit\n    else\n    {\n        //alloc new process obj\n        process = [[Process alloc] init];\n        \n        //manually set pid\n        process.pid = processID;\n        \n        //manully set type to exit\n        process.type = EVENT_EXIT;\n        \n        //exit event\n        [self handleProcessExit:process];\n    }\n    \nbail:\n    \n    return;\n}\n\n//handle new process\n// create Binary obj/enum/process ancestors, etc\n-(void)handleProcessStart:(Process*)process\n{\n    //default cs flags\n    // note: since this is dynamic check, we don't need to check all architectures, or skip resources, etc...\n    SecCSFlags flags = kSecCSDefaultFlags;\n    \n    //sanity check\n    // should only occur for fork() events, which normally get superceeded by an exec(), etc\n    if( (-1 == process.pid) ||\n        (nil == process.path) )\n    {\n        //bail\n        goto bail;\n    }\n    \n    //get parent\n    if(-1 == process.ppid)\n    {\n        //get ppid\n        process.ppid = [Process getParentID:process.pid];\n    }\n    \n    //enumerate process ancestry\n    if(0 == process.ancestors.count)\n    {\n        //enumerate\n        [process enumerateAncestors];\n    }\n    \n    //generate binary\n    process.binary = [[Binary alloc] init:process.path];\n    if(nil == process.binary)\n    {\n        #ifdef DEBUG\n        \n        //err msg\n        NSLog(@\"ERROR: failed to create binary object for %d/%@\", process.pid, process.path);\n        \n        #endif\n        \n        //bail\n        goto bail;\n    }\n    \n    //automatically generate signing info/icon?\n    // these can be skipped for performance reasons\n    if(YES != self.goEasy)\n    {\n        //generate signing info\n        // first will try dynamic, falling back to static\n        [process generateSigningInfo:flags];\n    \n        //set icon\n        [process.binary getIcon];\n    }\n    \n    //invoke user callback\n    self.processCallback(process);\n\nbail:\n    \n    return;\n}\n\n//handle process exit event\n// as only have pid, just alert user\n-(void)handleProcessExit:(Process*)process\n{\n    //invoke user callback\n    self.processCallback(process);\n    \n    return;\n}\n\n//return array of running processes\n-(NSMutableArray*)currentProcesses\n{\n    //default cs flags\n    // note: since this is dynamic check, we don't need to check all architectures, or skip resources, etc...\n    SecCSFlags flags = kSecCSDefaultFlags;\n    \n    //current process\n    Process* currentProcess = nil;\n    \n    //processes\n    NSMutableArray* processes = nil;\n    \n    //alloc array\n    processes = [NSMutableArray array];\n    \n    //iterate over all pids\n    // init process object w/ pid/path, etc\n    for(NSNumber* pid in PI_enumerateProcesses())\n    {\n        //create process obj\n        currentProcess = [[Process alloc] init:pid.intValue];\n        if(nil == currentProcess)\n        {\n            //skip\n            continue;\n        }\n        \n        //generate signing info\n        [currentProcess generateSigningInfo:flags];\n        \n        //add\n        [processes addObject:currentProcess];\n    }\n    \n    return processes;\n}\n\n@end\n"
  },
  {
    "path": "procInfo/Signing.h",
    "content": "//\n//  File: Signing.h\n//  Project: Proc Info\n//\n//  Created by: Patrick Wardle\n//  Copyright:  2017 Objective-See\n//  License:    Creative Commons Attribution-NonCommercial 4.0 International License\n//\n\n#ifndef Signing_h\n#define Signing_h\n\n#import <AppKit/AppKit.h>\n#import <Foundation/Foundation.h>\n\n/* FUNCTIONS */\n\n//get the signing info of a item\n// pid specified: extract dynamic code signing info\n// path specified: generate static code signing info\nNSMutableDictionary* extractSigningInfo(pid_t pid, NSString* path, SecCSFlags flags);\n\n//determine who signed item\nNSNumber* extractSigner(SecStaticCodeRef code, SecCSFlags flags, BOOL isDynamic);\n\n//validate a requirement\nOSStatus validateRequirement(SecStaticCodeRef code, SecRequirementRef requirement, SecCSFlags flags, BOOL isDynamic);\n\n//extract (names) of signing auths\nNSMutableArray* extractSigningAuths(NSDictionary* signingDetails);\n\n#endif\n"
  },
  {
    "path": "procInfo/Signing.m",
    "content": "//\n//  File: Signing.m\n//  Project: Proc Info\n//\n//  Created by: Patrick Wardle\n//  Copyright:  2017 Objective-See\n//  License:    Creative Commons Attribution-NonCommercial 4.0 International License\n//\n\n#import \"Consts.h\"\n#import \"Signing.h\"\n#import \"procInfo.h\"\n#import \"Utilities.h\"\n\n#import <Security/Security.h>\n#import <SystemConfiguration/SystemConfiguration.h>\n\n//get the signing info of a item\n// pid specified: extract dynamic code signing info\n// path specified: generate static code signing info\nNSMutableDictionary* extractSigningInfo(pid_t pid, NSString* path, SecCSFlags flags)\n{\n    //info dictionary\n    NSMutableDictionary* signingInfo = nil;\n    \n    //status\n    OSStatus status = !errSecSuccess;\n    \n    //static code ref\n    SecStaticCodeRef staticCode = NULL;\n    \n    //dynamic code ref\n    SecCodeRef dynamicCode = NULL;\n    \n    //signing details\n    CFDictionaryRef signingDetails = NULL;\n    \n    //signing authorities\n    NSMutableArray* signingAuths = nil;\n    \n    //init signing status\n    signingInfo = [NSMutableDictionary dictionary];\n    \n    //dynamic code checks\n    // no path, dynamic check via pid\n    if(nil == path)\n    {\n        //generate dynamic code ref via pid\n        status = SecCodeCopyGuestWithAttributes(NULL, (__bridge CFDictionaryRef _Nullable)(@{(__bridge NSString *)kSecGuestAttributePid : [NSNumber numberWithInt:pid]}), kSecCSDefaultFlags, &dynamicCode);\n        if(errSecSuccess != status)\n        {\n            //set error\n            signingInfo[KEY_SIGNATURE_STATUS] = [NSNumber numberWithInt:status];\n            \n            //bail\n            goto bail;\n        }\n    \n        //validate code\n        status = SecCodeCheckValidity(dynamicCode, flags, NULL);\n        if(errSecSuccess != status)\n        {\n            //set error\n            signingInfo[KEY_SIGNATURE_STATUS] = [NSNumber numberWithInt:status];\n            \n            //bail\n            goto bail;\n        }\n        \n        //happily signed\n        signingInfo[KEY_SIGNATURE_STATUS] = [NSNumber numberWithInt:errSecSuccess];\n        \n        //determine signer\n        // apple, app store, dev id, adhoc, etc...\n        signingInfo[KEY_SIGNATURE_SIGNER] = extractSigner(dynamicCode, flags, YES);\n        \n        //extract signing info\n        status = SecCodeCopySigningInformation(dynamicCode, kSecCSSigningInformation, &signingDetails);\n        if(errSecSuccess != status)\n        {\n            //bail\n            goto bail;\n        }\n    }\n    \n    //static code checks\n    else\n    {\n        //create static code ref via path\n        status = SecStaticCodeCreateWithPath((__bridge CFURLRef)([NSURL fileURLWithPath:path]), kSecCSDefaultFlags, &staticCode);\n        if(errSecSuccess != status)\n        {\n            //set error\n            signingInfo[KEY_SIGNATURE_STATUS] = [NSNumber numberWithInt:status];\n            \n            //bail\n            goto bail;\n        }\n        \n        //check signature\n        status = SecStaticCodeCheckValidity(staticCode, flags, NULL);\n        if(errSecSuccess != status)\n        {\n            //set error\n            signingInfo[KEY_SIGNATURE_STATUS] = [NSNumber numberWithInt:status];\n            \n            //bail\n            goto bail;\n        }\n        \n        //happily signed\n        signingInfo[KEY_SIGNATURE_STATUS] = [NSNumber numberWithInt:errSecSuccess];\n        \n        //determine signer\n        // apple, app store, dev id, adhoc, etc...\n        signingInfo[KEY_SIGNATURE_SIGNER] = extractSigner(staticCode, flags, NO);\n        \n        //extract signing info\n        status = SecCodeCopySigningInformation(staticCode, kSecCSSigningInformation, &signingDetails);\n        if(errSecSuccess != status)\n        {\n            //bail\n            goto bail;\n        }\n    }\n    \n    //extract code signing id\n    if(nil != [(__bridge NSDictionary*)signingDetails objectForKey:(__bridge NSString*)kSecCodeInfoIdentifier])\n    {\n        //extract/save\n        signingInfo[KEY_SIGNATURE_IDENTIFIER] = [(__bridge NSDictionary*)signingDetails objectForKey:(__bridge NSString*)kSecCodeInfoIdentifier];\n    }\n    \n    //extract entitlements\n    if(nil != [(__bridge NSDictionary*)signingDetails objectForKey:(__bridge NSString*)kSecCodeInfoEntitlementsDict])\n    {\n        //extract/save\n        signingInfo[KEY_SIGNATURE_ENTITLEMENTS] = [(__bridge NSDictionary*)signingDetails objectForKey:(__bridge NSString*)kSecCodeInfoEntitlementsDict];\n    }\n    \n    //extract signing authorities\n    signingAuths = extractSigningAuths((__bridge NSDictionary *)(signingDetails));\n    if(0 != signingAuths.count)\n    {\n        //save\n        signingInfo[KEY_SIGNATURE_AUTHORITIES] = signingAuths;\n    }\n    \nbail:\n    \n    //free signing info\n    if(NULL != signingDetails)\n    {\n        //free\n        CFRelease(signingDetails);\n        \n        //unset\n        signingDetails = NULL;\n    }\n    \n    //free dynamic code\n    if(NULL != dynamicCode)\n    {\n        //free\n        CFRelease(dynamicCode);\n        \n        //unset\n        dynamicCode = NULL;\n    }\n    \n    //free static code\n    if(NULL != staticCode)\n    {\n        //free\n        CFRelease(staticCode);\n        \n        //unset\n        staticCode = NULL;\n    }\n    \n    return signingInfo;\n}\n\n//determine who signed item\nNSNumber* extractSigner(SecStaticCodeRef code, SecCSFlags flags, BOOL isDynamic)\n{\n    //result\n    NSNumber* signer = nil;\n    \n    //\"anchor apple\"\n    static SecRequirementRef isApple = nil;\n    \n    //\"anchor apple generic\"\n    static SecRequirementRef isDevID = nil;\n    \n    //\"anchor apple generic and certificate leaf [subject.CN] = \\\"Apple Mac OS Application Signing\\\"\"\n    static SecRequirementRef isAppStore = nil;\n    \n    //token\n    static dispatch_once_t onceToken = 0;\n    \n    //only once\n    // init requirements\n    dispatch_once(&onceToken, ^{\n        \n        //init apple signing requirement\n        SecRequirementCreateWithString(CFSTR(\"anchor apple\"), kSecCSDefaultFlags, &isApple);\n        \n        //init dev id signing requirement\n        SecRequirementCreateWithString(CFSTR(\"anchor apple generic\"), kSecCSDefaultFlags, &isDevID);\n        \n        //init app store signing requirement\n        SecRequirementCreateWithString(CFSTR(\"anchor apple generic and certificate leaf [subject.CN] = \\\"Apple Mac OS Application Signing\\\"\"), kSecCSDefaultFlags, &isAppStore);\n    });\n    \n    //check 1: \"is apple\" (proper)\n    if(errSecSuccess == validateRequirement(code, isApple, flags, isDynamic))\n    {\n        //set signer to apple\n        signer = [NSNumber numberWithInt:Apple];\n    }\n    \n    //check 2: \"is app store\"\n    // note: this is more specific than dev id, so do it first\n    else if(errSecSuccess == validateRequirement(code, isAppStore, flags, isDynamic))\n    {\n        //set signer to app store\n        signer = [NSNumber numberWithInt:AppStore];\n    }\n    \n    //check 3: \"is dev id\"\n    else if(errSecSuccess == validateRequirement(code, isDevID, flags, isDynamic))\n    {\n        //set signer to dev id\n        signer = [NSNumber numberWithInt:DevID];\n    }\n    \n    //otherwise\n    // has to be adhoc?\n    else\n    {\n        //set signer to ad hoc\n        signer = [NSNumber numberWithInt:AdHoc];\n    }\n    \n    return signer;\n}\n\n//validate a requirement\nOSStatus validateRequirement(SecStaticCodeRef code, SecRequirementRef requirement, SecCSFlags flags, BOOL isDynamic)\n{\n    //result\n    OSStatus result = -1;\n    \n    //dynamic check?\n    if(YES == isDynamic)\n    {\n        //validate dynamically\n        result = SecCodeCheckValidity((SecCodeRef)code, flags, requirement);\n    }\n    //static check\n    else\n    {\n        //validate statically\n        result = SecStaticCodeCheckValidity(code, flags, requirement);\n    }\n    \n    return result;\n}\n\n//extract (names) of signing auths\nNSMutableArray* extractSigningAuths(NSDictionary* signingDetails)\n{\n    //signing auths\n    NSMutableArray* authorities = nil;\n    \n    //cert chain\n    NSArray* certificateChain = nil;\n    \n    //index\n    NSUInteger index = 0;\n    \n    //cert\n    SecCertificateRef certificate = NULL;\n    \n    //common name on chert\n    CFStringRef commonName = NULL;\n    \n    //init array for certificate names\n    authorities = [NSMutableArray array];\n    \n    //get cert chain\n    certificateChain = [signingDetails objectForKey:(__bridge NSString*)kSecCodeInfoCertificates];\n    if(0 == certificateChain.count)\n    {\n        //no certs\n        goto bail;\n    }\n    \n    //extract/save name of all certs\n    for(index = 0; index < certificateChain.count; index++)\n    {\n        //reset\n        commonName = NULL;\n        \n        //extract cert\n        certificate = (__bridge SecCertificateRef)([certificateChain objectAtIndex:index]);\n        \n        //get common name\n        if( (errSecSuccess == SecCertificateCopyCommonName(certificate, &commonName)) &&\n            (NULL != commonName) )\n        {\n            //save\n            [authorities addObject:(__bridge id _Nonnull)(commonName)];\n            \n            //release\n            CFRelease(commonName);\n        }\n    }\n        \nbail:\n    \n    return authorities;\n}\n"
  },
  {
    "path": "procInfo/Utilities.h",
    "content": "//\n//  File: Utilities.h\n//  Project: Proc Info\n//\n//  Created by: Patrick Wardle\n//  Copyright:  2017 Objective-See\n//  License:    Creative Commons Attribution-NonCommercial 4.0 International License\n//\n\n#ifndef Utilties_h\n#define Utilties_h\n\n#import <Foundation/Foundation.h>\n\n//given a path to binary\n// parse it back up to find app's bundle\nNSBundle* PI_findAppBundle(NSString* binaryPath);\n\n//check if current OS version is supported\nBOOL PI_isSupportedOS(void);\n\n//get OS version\nNSDictionary* PI_getOSVersion(void);\n\n//enumerate all running processes\nNSMutableArray* PI_enumerateProcesses(void);\n\n//given a bundle\n// find its executable\nNSString* PI_findAppBinary(NSString* appPath);\n\n//given a 'short' path or process name\n// find the full path by scanning $PATH\nNSString* PI_which(NSString* processName);\n\n#endif\n"
  },
  {
    "path": "procInfo/Utilities.m",
    "content": "//\n//  File: Utilities.m\n//  Project: Proc Info\n//\n//  Created by: Patrick Wardle\n//  Copyright:  2017 Objective-See\n//  License:    Creative Commons Attribution-NonCommercial 4.0 International License\n//\n\n#import \"Consts.h\"\n#import \"Utilities.h\"\n\n#import <libproc.h>\n#import <sys/sysctl.h>\n\n//disable deprecated warnings\n// use 'Gestalt' as this code may run on old OS X vers.\n#pragma clang diagnostic ignored \"-Wdeprecated-declarations\"\n\n//get OS version\nNSDictionary* PI_getOSVersion()\n{\n    //os version info\n    NSMutableDictionary* osVersionInfo = nil;\n    \n    //major v\n    SInt32 majorVersion = 0;\n    \n    //minor v\n    SInt32 minorVersion = 0;\n    \n    //bug fix v\n    SInt32 fixVersion = 0;\n    \n    //alloc dictionary\n    osVersionInfo = [NSMutableDictionary dictionary];\n    \n    //get major version\n    if(noErr != Gestalt(gestaltSystemVersionMajor, &majorVersion))\n    {\n        //unset\n        osVersionInfo = nil;\n        \n        //bail\n        goto bail;\n    }\n    \n    //get minor version\n    if(noErr != Gestalt(gestaltSystemVersionMinor, &minorVersion))\n    {\n        //unset\n        osVersionInfo = nil;\n        \n        //bail\n        goto bail;\n    }\n    \n    //get bug fix version\n    if(noErr != Gestalt(gestaltSystemVersionBugFix, &fixVersion))\n    {\n        //unset\n        osVersionInfo = nil;\n        \n        //bail\n        goto bail;\n    }\n    \n    //set major version\n    osVersionInfo[@\"majorVersion\"] = [NSNumber numberWithInteger:majorVersion];\n    \n    //set minor version\n    osVersionInfo[@\"minorVersion\"] = [NSNumber numberWithInteger:minorVersion];\n    \n    //set bug fix version\n    osVersionInfo[@\"bugfixVersion\"] = [NSNumber numberWithInteger:fixVersion];\n    \nbail:\n    \n    return osVersionInfo;\n}\n\n//is current OS version supported?\n// for now, just OS X 10.8+\nBOOL PI_isSupportedOS()\n{\n    //support flag\n    BOOL isSupported = NO;\n    \n    //OS version info\n    NSDictionary* osVersionInfo = nil;\n    \n    //get OS version info\n    osVersionInfo = PI_getOSVersion();\n    if(nil == osVersionInfo)\n    {\n        //bail\n        goto bail;\n    }\n    \n    //gotta be OS X\n    if(OS_MAJOR_VERSION_X != [osVersionInfo[@\"majorVersion\"] intValue])\n    {\n        //bail\n        goto bail;\n    }\n    \n    //gotta be OS X at least lion (10.8)\n    if([osVersionInfo[@\"minorVersion\"] intValue] < OS_MINOR_VERSION_LION)\n    {\n        //bail\n        goto bail;\n    }\n    \n    //OS version is supported\n    isSupported = YES;\n    \nbail:\n    \n    return isSupported;\n}\n\n//enumerate all running processes\nNSMutableArray* PI_enumerateProcesses()\n{\n    //# of procs\n    int numberOfProcesses = 0;\n    \n    //array of pids\n    pid_t* pids = NULL;\n    \n    //processes\n    NSMutableArray* processes = nil;\n    \n    //alloc array\n    processes = [NSMutableArray array];\n    \n    //get # of procs\n    numberOfProcesses = proc_listallpids(NULL, 0);\n    if(-1 == numberOfProcesses)\n    {\n        //bail\n        goto bail;\n    }\n    \n    //alloc buffer for pids\n    pids = calloc(numberOfProcesses, sizeof(pid_t));\n    if(nil == pids)\n    {\n        //bail\n        goto bail;\n    }\n    \n    //get list of pids\n    numberOfProcesses = proc_listallpids(pids, numberOfProcesses*sizeof(pid_t));\n    if(-1 == numberOfProcesses)\n    {\n        //bail\n        goto bail;\n    }\n    \n    //iterate over all pids\n    // save pid into return array\n    for(int i = 0; i < numberOfProcesses; ++i)\n    {\n        //save each pid\n        if(0 != pids[i])\n        {\n            //save\n            [processes addObject:[NSNumber numberWithUnsignedInt:pids[i]]];\n        }\n    }\n    \nbail:\n    \n    //free buffer\n    if(NULL != pids)\n    {\n        //free\n        free(pids);\n        \n        //unset\n        pids = NULL;\n    }\n    \n    return processes;\n}\n\n//given a path to binary\n// parse it back up to find app's bundle\nNSBundle* PI_findAppBundle(NSString* binaryPath)\n{\n    //app's bundle\n    NSBundle* appBundle = nil;\n    \n    //app's path\n    NSString* appPath = nil;\n    \n    //first just try full path\n    appPath = binaryPath;\n    \n    //try to find the app's bundle/info dictionary\n    do\n    {\n        //try to load app's bundle\n        appBundle = [NSBundle bundleWithPath:appPath];\n        \n        //check for match\n        // binary path's match\n        if( (nil != appBundle) &&\n            (YES == [appBundle.executablePath isEqualToString:binaryPath]))\n        {\n            //all done\n            break;\n        }\n        \n        //always unset bundle var since it's being returned\n        // and at this point, its not a match\n        appBundle = nil;\n        \n        //remove last part\n        // will try this next\n        appPath = [appPath stringByDeletingLastPathComponent];\n        \n    //scan until we get to root\n    // of course, loop will be exited if app info dictionary is found/loaded\n    } while( (nil != appPath) &&\n             (YES != [appPath isEqualToString:@\"/\"]) &&\n             (YES != [appPath isEqualToString:@\"\"]) );\n    \n    return appBundle;\n}\n\n\n//given a 'short' path or process name\n// try find the full path by scanning $PATH\nNSString* PI_which(NSString* processName)\n{\n    //full path\n    NSString* fullPath = nil;\n    \n    //get path\n    NSString* path = nil;\n    \n    //tokenized paths\n    NSArray* pathComponents = nil;\n    \n    //candidate file\n    NSString* candidateBinary = nil;\n    \n    //get path\n    path = [[[NSProcessInfo processInfo]environment]objectForKey:@\"PATH\"];\n    \n    //split on ':'\n    pathComponents = [path componentsSeparatedByString:@\":\"];\n    \n    //iterate over all path components\n    // build candidate path and check if it exists\n    for(NSString* pathComponent in pathComponents)\n    {\n        //build candidate path\n        // current path component + process name\n        candidateBinary = [pathComponent stringByAppendingPathComponent:processName];\n        \n        //check if it exists\n        if(YES == [[NSFileManager defaultManager] fileExistsAtPath:candidateBinary])\n        {\n            //check its executable\n            if(YES == [[NSFileManager defaultManager] isExecutableFileAtPath:candidateBinary])\n            {\n                //ok, happy now\n                fullPath = candidateBinary;\n                \n                //stop processing\n                break;\n            }\n        }\n        \n    }//for path components\n    \n    return fullPath;\n}\n"
  },
  {
    "path": "procInfo.xcodeproj/project.pbxproj",
    "content": "// !$*UTF8*$!\n{\n\tarchiveVersion = 1;\n\tclasses = {\n\t};\n\tobjectVersion = 46;\n\tobjects = {\n\n/* Begin PBXBuildFile section */\n\t\t7DD0A92D1F35A04B000EA15D /* ProcessMonitor.m in Sources */ = {isa = PBXBuildFile; fileRef = 7DD0A91F1F35A04B000EA15D /* ProcessMonitor.m */; };\n\t\t7DD0A92F1F35A04B000EA15D /* Binary.m in Sources */ = {isa = PBXBuildFile; fileRef = 7DD0A9211F35A04B000EA15D /* Binary.m */; };\n\t\t7DD0A9301F35A04B000EA15D /* Process.m in Sources */ = {isa = PBXBuildFile; fileRef = 7DD0A9221F35A04B000EA15D /* Process.m */; };\n\t\t7DD0A9321F35A04B000EA15D /* Utilities.m in Sources */ = {isa = PBXBuildFile; fileRef = 7DD0A9241F35A04B000EA15D /* Utilities.m */; };\n\t\t7DD0A9331F35A04B000EA15D /* Utilities.h in Headers */ = {isa = PBXBuildFile; fileRef = 7DD0A9251F35A04B000EA15D /* Utilities.h */; };\n\t\t7DD0A9351F35A04B000EA15D /* Signing.m in Sources */ = {isa = PBXBuildFile; fileRef = 7DD0A9271F35A04B000EA15D /* Signing.m */; };\n\t\t7DD0A9361F35A04B000EA15D /* Signing.h in Headers */ = {isa = PBXBuildFile; fileRef = 7DD0A9281F35A04B000EA15D /* Signing.h */; };\n\t\t7DD0A9371F35A04B000EA15D /* Consts.h in Headers */ = {isa = PBXBuildFile; fileRef = 7DD0A9291F35A04B000EA15D /* Consts.h */; };\n\t\tCD6DE4D5219EA0BD0058094E /* procInfo.h in Headers */ = {isa = PBXBuildFile; fileRef = CD6DE4D4219EA0BD0058094E /* procInfo.h */; };\n/* End PBXBuildFile section */\n\n/* Begin PBXFileReference section */\n\t\t7D6E87761F3BD0FA00D6BD7C /* libprocInfo.a */ = {isa = PBXFileReference; lastKnownFileType = archive.ar; name = libprocInfo.a; path = lib/libprocInfo.a; sourceTree = SOURCE_ROOT; };\n\t\t7DD0A91F1F35A04B000EA15D /* ProcessMonitor.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = ProcessMonitor.m; path = procInfo/ProcessMonitor.m; sourceTree = SOURCE_ROOT; };\n\t\t7DD0A9211F35A04B000EA15D /* Binary.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = Binary.m; path = procInfo/Binary.m; sourceTree = SOURCE_ROOT; };\n\t\t7DD0A9221F35A04B000EA15D /* Process.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = Process.m; path = procInfo/Process.m; sourceTree = SOURCE_ROOT; };\n\t\t7DD0A9241F35A04B000EA15D /* Utilities.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = Utilities.m; path = procInfo/Utilities.m; sourceTree = SOURCE_ROOT; };\n\t\t7DD0A9251F35A04B000EA15D /* Utilities.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = Utilities.h; path = procInfo/Utilities.h; sourceTree = SOURCE_ROOT; };\n\t\t7DD0A9271F35A04B000EA15D /* Signing.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = Signing.m; path = procInfo/Signing.m; sourceTree = SOURCE_ROOT; };\n\t\t7DD0A9281F35A04B000EA15D /* Signing.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = Signing.h; path = procInfo/Signing.h; sourceTree = SOURCE_ROOT; };\n\t\t7DD0A9291F35A04B000EA15D /* Consts.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = Consts.h; path = procInfo/Consts.h; sourceTree = SOURCE_ROOT; };\n\t\tCD6DE4D4219EA0BD0058094E /* procInfo.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = procInfo.h; path = lib/procInfo.h; sourceTree = SOURCE_ROOT; };\n/* End PBXFileReference section */\n\n/* Begin PBXFrameworksBuildPhase section */\n\t\t7D83A9E11EB6465D001506F0 /* Frameworks */ = {\n\t\t\tisa = PBXFrameworksBuildPhase;\n\t\t\tbuildActionMask = 2147483647;\n\t\t\tfiles = (\n\t\t\t);\n\t\t\trunOnlyForDeploymentPostprocessing = 0;\n\t\t};\n/* End PBXFrameworksBuildPhase section */\n\n/* Begin PBXGroup section */\n\t\t7D6E87751F3BD0C200D6BD7C /* lib */ = {\n\t\t\tisa = PBXGroup;\n\t\t\tchildren = (\n\t\t\t\tCD6DE4D4219EA0BD0058094E /* procInfo.h */,\n\t\t\t\t7D6E87761F3BD0FA00D6BD7C /* libprocInfo.a */,\n\t\t\t);\n\t\t\tpath = lib;\n\t\t\tsourceTree = \"<group>\";\n\t\t};\n\t\t7D83A9DB1EB6465D001506F0 = {\n\t\t\tisa = PBXGroup;\n\t\t\tchildren = (\n\t\t\t\t7D83A9E61EB6465D001506F0 /* src */,\n\t\t\t\t7D6E87751F3BD0C200D6BD7C /* lib */,\n\t\t\t);\n\t\t\tsourceTree = \"<group>\";\n\t\t};\n\t\t7D83A9E61EB6465D001506F0 /* src */ = {\n\t\t\tisa = PBXGroup;\n\t\t\tchildren = (\n\t\t\t\t7DD0A9211F35A04B000EA15D /* Binary.m */,\n\t\t\t\t7DD0A9291F35A04B000EA15D /* Consts.h */,\n\t\t\t\t7DD0A9221F35A04B000EA15D /* Process.m */,\n\t\t\t\t7DD0A91F1F35A04B000EA15D /* ProcessMonitor.m */,\n\t\t\t\t7DD0A9281F35A04B000EA15D /* Signing.h */,\n\t\t\t\t7DD0A9271F35A04B000EA15D /* Signing.m */,\n\t\t\t\t7DD0A9251F35A04B000EA15D /* Utilities.h */,\n\t\t\t\t7DD0A9241F35A04B000EA15D /* Utilities.m */,\n\t\t\t);\n\t\t\tname = src;\n\t\t\tpath = procInfo;\n\t\t\tsourceTree = \"<group>\";\n\t\t};\n/* End PBXGroup section */\n\n/* Begin PBXHeadersBuildPhase section */\n\t\t7D83A9E21EB6465D001506F0 /* Headers */ = {\n\t\t\tisa = PBXHeadersBuildPhase;\n\t\t\tbuildActionMask = 2147483647;\n\t\t\tfiles = (\n\t\t\t\tCD6DE4D5219EA0BD0058094E /* procInfo.h in Headers */,\n\t\t\t\t7DD0A9331F35A04B000EA15D /* Utilities.h in Headers */,\n\t\t\t\t7DD0A9371F35A04B000EA15D /* Consts.h in Headers */,\n\t\t\t\t7DD0A9361F35A04B000EA15D /* Signing.h in Headers */,\n\t\t\t);\n\t\t\trunOnlyForDeploymentPostprocessing = 0;\n\t\t};\n/* End PBXHeadersBuildPhase section */\n\n/* Begin PBXNativeTarget section */\n\t\t7D83A9E31EB6465D001506F0 /* procInfo */ = {\n\t\t\tisa = PBXNativeTarget;\n\t\t\tbuildConfigurationList = 7D83A9ED1EB6465D001506F0 /* Build configuration list for PBXNativeTarget \"procInfo\" */;\n\t\t\tbuildPhases = (\n\t\t\t\t7D83A9E01EB6465D001506F0 /* Sources */,\n\t\t\t\t7D83A9E11EB6465D001506F0 /* Frameworks */,\n\t\t\t\t7D83A9E21EB6465D001506F0 /* Headers */,\n\t\t\t\t7D6E875B1F38186300D6BD7C /* ShellScript */,\n\t\t\t);\n\t\t\tbuildRules = (\n\t\t\t);\n\t\t\tdependencies = (\n\t\t\t);\n\t\t\tname = procInfo;\n\t\t\tproductName = processMonitor;\n\t\t\tproductType = \"com.apple.product-type.library.static\";\n\t\t};\n/* End PBXNativeTarget section */\n\n/* Begin PBXProject section */\n\t\t7D83A9DC1EB6465D001506F0 /* Project object */ = {\n\t\t\tisa = PBXProject;\n\t\t\tattributes = {\n\t\t\t\tLastUpgradeCheck = 0940;\n\t\t\t\tORGANIZATIONNAME = \"Objective-See\";\n\t\t\t\tTargetAttributes = {\n\t\t\t\t\t7D83A9E31EB6465D001506F0 = {\n\t\t\t\t\t\tCreatedOnToolsVersion = 8.2.1;\n\t\t\t\t\t\tDevelopmentTeam = VBG97UB4TA;\n\t\t\t\t\t\tProvisioningStyle = Automatic;\n\t\t\t\t\t};\n\t\t\t\t};\n\t\t\t};\n\t\t\tbuildConfigurationList = 7D83A9DF1EB6465D001506F0 /* Build configuration list for PBXProject \"procInfo\" */;\n\t\t\tcompatibilityVersion = \"Xcode 3.2\";\n\t\t\tdevelopmentRegion = English;\n\t\t\thasScannedForEncodings = 0;\n\t\t\tknownRegions = (\n\t\t\t\ten,\n\t\t\t);\n\t\t\tmainGroup = 7D83A9DB1EB6465D001506F0;\n\t\t\tproductRefGroup = 7D83A9DB1EB6465D001506F0;\n\t\t\tprojectDirPath = \"\";\n\t\t\tprojectRoot = \"\";\n\t\t\ttargets = (\n\t\t\t\t7D83A9E31EB6465D001506F0 /* procInfo */,\n\t\t\t);\n\t\t};\n/* End PBXProject section */\n\n/* Begin PBXShellScriptBuildPhase section */\n\t\t7D6E875B1F38186300D6BD7C /* ShellScript */ = {\n\t\t\tisa = PBXShellScriptBuildPhase;\n\t\t\tbuildActionMask = 12;\n\t\t\tfiles = (\n\t\t\t);\n\t\t\tinputPaths = (\n\t\t\t);\n\t\t\toutputPaths = (\n\t\t\t);\n\t\t\trunOnlyForDeploymentPostprocessing = 0;\n\t\t\tshellPath = /bin/sh;\n\t\t\tshellScript = \"#move library into top-level lib folder\\nmv $CODESIGNING_FOLDER_PATH $SRCROOT/lib/\";\n\t\t};\n/* End PBXShellScriptBuildPhase section */\n\n/* Begin PBXSourcesBuildPhase section */\n\t\t7D83A9E01EB6465D001506F0 /* Sources */ = {\n\t\t\tisa = PBXSourcesBuildPhase;\n\t\t\tbuildActionMask = 2147483647;\n\t\t\tfiles = (\n\t\t\t\t7DD0A9301F35A04B000EA15D /* Process.m in Sources */,\n\t\t\t\t7DD0A92F1F35A04B000EA15D /* Binary.m in Sources */,\n\t\t\t\t7DD0A92D1F35A04B000EA15D /* ProcessMonitor.m in Sources */,\n\t\t\t\t7DD0A9321F35A04B000EA15D /* Utilities.m in Sources */,\n\t\t\t\t7DD0A9351F35A04B000EA15D /* Signing.m in Sources */,\n\t\t\t);\n\t\t\trunOnlyForDeploymentPostprocessing = 0;\n\t\t};\n/* End PBXSourcesBuildPhase section */\n\n/* Begin XCBuildConfiguration section */\n\t\t7D83A9EB1EB6465D001506F0 /* Debug */ = {\n\t\t\tisa = XCBuildConfiguration;\n\t\t\tbuildSettings = {\n\t\t\t\tALWAYS_SEARCH_USER_PATHS = NO;\n\t\t\t\tCLANG_ANALYZER_NONNULL = YES;\n\t\t\t\tCLANG_CXX_LANGUAGE_STANDARD = \"gnu++0x\";\n\t\t\t\tCLANG_CXX_LIBRARY = \"libc++\";\n\t\t\t\tCLANG_ENABLE_MODULES = YES;\n\t\t\t\tCLANG_ENABLE_OBJC_ARC = YES;\n\t\t\t\tCLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES;\n\t\t\t\tCLANG_WARN_BOOL_CONVERSION = YES;\n\t\t\t\tCLANG_WARN_COMMA = YES;\n\t\t\t\tCLANG_WARN_CONSTANT_CONVERSION = YES;\n\t\t\t\tCLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES;\n\t\t\t\tCLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR;\n\t\t\t\tCLANG_WARN_DOCUMENTATION_COMMENTS = YES;\n\t\t\t\tCLANG_WARN_EMPTY_BODY = YES;\n\t\t\t\tCLANG_WARN_ENUM_CONVERSION = YES;\n\t\t\t\tCLANG_WARN_INFINITE_RECURSION = YES;\n\t\t\t\tCLANG_WARN_INT_CONVERSION = YES;\n\t\t\t\tCLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES;\n\t\t\t\tCLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES;\n\t\t\t\tCLANG_WARN_OBJC_LITERAL_CONVERSION = YES;\n\t\t\t\tCLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR;\n\t\t\t\tCLANG_WARN_RANGE_LOOP_ANALYSIS = YES;\n\t\t\t\tCLANG_WARN_STRICT_PROTOTYPES = YES;\n\t\t\t\tCLANG_WARN_SUSPICIOUS_MOVE = YES;\n\t\t\t\tCLANG_WARN_UNREACHABLE_CODE = YES;\n\t\t\t\tCLANG_WARN__DUPLICATE_METHOD_MATCH = YES;\n\t\t\t\tCODE_SIGN_IDENTITY = \"-\";\n\t\t\t\tCOPY_PHASE_STRIP = NO;\n\t\t\t\tDEBUG_INFORMATION_FORMAT = dwarf;\n\t\t\t\tENABLE_STRICT_OBJC_MSGSEND = YES;\n\t\t\t\tENABLE_TESTABILITY = YES;\n\t\t\t\tGCC_C_LANGUAGE_STANDARD = gnu99;\n\t\t\t\tGCC_DYNAMIC_NO_PIC = NO;\n\t\t\t\tGCC_NO_COMMON_BLOCKS = YES;\n\t\t\t\tGCC_OPTIMIZATION_LEVEL = 0;\n\t\t\t\tGCC_PREPROCESSOR_DEFINITIONS = (\n\t\t\t\t\t\"DEBUG=1\",\n\t\t\t\t\t\"$(inherited)\",\n\t\t\t\t);\n\t\t\t\tGCC_WARN_64_TO_32_BIT_CONVERSION = YES;\n\t\t\t\tGCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR;\n\t\t\t\tGCC_WARN_UNDECLARED_SELECTOR = YES;\n\t\t\t\tGCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;\n\t\t\t\tGCC_WARN_UNUSED_FUNCTION = YES;\n\t\t\t\tGCC_WARN_UNUSED_VARIABLE = YES;\n\t\t\t\tMACOSX_DEPLOYMENT_TARGET = 10.7;\n\t\t\t\tMTL_ENABLE_DEBUG_INFO = YES;\n\t\t\t\tONLY_ACTIVE_ARCH = YES;\n\t\t\t\tSDKROOT = macosx;\n\t\t\t};\n\t\t\tname = Debug;\n\t\t};\n\t\t7D83A9EC1EB6465D001506F0 /* Release */ = {\n\t\t\tisa = XCBuildConfiguration;\n\t\t\tbuildSettings = {\n\t\t\t\tALWAYS_SEARCH_USER_PATHS = NO;\n\t\t\t\tCLANG_ANALYZER_NONNULL = YES;\n\t\t\t\tCLANG_CXX_LANGUAGE_STANDARD = \"gnu++0x\";\n\t\t\t\tCLANG_CXX_LIBRARY = \"libc++\";\n\t\t\t\tCLANG_ENABLE_MODULES = YES;\n\t\t\t\tCLANG_ENABLE_OBJC_ARC = YES;\n\t\t\t\tCLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES;\n\t\t\t\tCLANG_WARN_BOOL_CONVERSION = YES;\n\t\t\t\tCLANG_WARN_COMMA = YES;\n\t\t\t\tCLANG_WARN_CONSTANT_CONVERSION = YES;\n\t\t\t\tCLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES;\n\t\t\t\tCLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR;\n\t\t\t\tCLANG_WARN_DOCUMENTATION_COMMENTS = YES;\n\t\t\t\tCLANG_WARN_EMPTY_BODY = YES;\n\t\t\t\tCLANG_WARN_ENUM_CONVERSION = YES;\n\t\t\t\tCLANG_WARN_INFINITE_RECURSION = YES;\n\t\t\t\tCLANG_WARN_INT_CONVERSION = YES;\n\t\t\t\tCLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES;\n\t\t\t\tCLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES;\n\t\t\t\tCLANG_WARN_OBJC_LITERAL_CONVERSION = YES;\n\t\t\t\tCLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR;\n\t\t\t\tCLANG_WARN_RANGE_LOOP_ANALYSIS = YES;\n\t\t\t\tCLANG_WARN_STRICT_PROTOTYPES = YES;\n\t\t\t\tCLANG_WARN_SUSPICIOUS_MOVE = YES;\n\t\t\t\tCLANG_WARN_UNREACHABLE_CODE = YES;\n\t\t\t\tCLANG_WARN__DUPLICATE_METHOD_MATCH = YES;\n\t\t\t\tCODE_SIGN_IDENTITY = \"-\";\n\t\t\t\tCOPY_PHASE_STRIP = NO;\n\t\t\t\tDEBUG_INFORMATION_FORMAT = \"dwarf-with-dsym\";\n\t\t\t\tENABLE_NS_ASSERTIONS = NO;\n\t\t\t\tENABLE_STRICT_OBJC_MSGSEND = YES;\n\t\t\t\tGCC_C_LANGUAGE_STANDARD = gnu99;\n\t\t\t\tGCC_NO_COMMON_BLOCKS = YES;\n\t\t\t\tGCC_WARN_64_TO_32_BIT_CONVERSION = YES;\n\t\t\t\tGCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR;\n\t\t\t\tGCC_WARN_UNDECLARED_SELECTOR = YES;\n\t\t\t\tGCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;\n\t\t\t\tGCC_WARN_UNUSED_FUNCTION = YES;\n\t\t\t\tGCC_WARN_UNUSED_VARIABLE = YES;\n\t\t\t\tMACOSX_DEPLOYMENT_TARGET = 10.7;\n\t\t\t\tMTL_ENABLE_DEBUG_INFO = NO;\n\t\t\t\tSDKROOT = macosx;\n\t\t\t};\n\t\t\tname = Release;\n\t\t};\n\t\t7D83A9EE1EB6465D001506F0 /* Debug */ = {\n\t\t\tisa = XCBuildConfiguration;\n\t\t\tbuildSettings = {\n\t\t\t\tCODE_SIGN_IDENTITY = \"\";\n\t\t\t\tDEVELOPMENT_TEAM = VBG97UB4TA;\n\t\t\t\tEXECUTABLE_PREFIX = lib;\n\t\t\t\tLIBRARY_SEARCH_PATHS = (\n\t\t\t\t\t\"$(inherited)\",\n\t\t\t\t\t\"$(PROJECT_DIR)/lib\",\n\t\t\t\t);\n\t\t\t\tPRODUCT_NAME = \"$(TARGET_NAME)\";\n\t\t\t};\n\t\t\tname = Debug;\n\t\t};\n\t\t7D83A9EF1EB6465D001506F0 /* Release */ = {\n\t\t\tisa = XCBuildConfiguration;\n\t\t\tbuildSettings = {\n\t\t\t\tCODE_SIGN_IDENTITY = \"\";\n\t\t\t\tDEVELOPMENT_TEAM = VBG97UB4TA;\n\t\t\t\tEXECUTABLE_PREFIX = lib;\n\t\t\t\tLIBRARY_SEARCH_PATHS = (\n\t\t\t\t\t\"$(inherited)\",\n\t\t\t\t\t\"$(PROJECT_DIR)/lib\",\n\t\t\t\t);\n\t\t\t\tPRODUCT_NAME = \"$(TARGET_NAME)\";\n\t\t\t};\n\t\t\tname = Release;\n\t\t};\n/* End XCBuildConfiguration section */\n\n/* Begin XCConfigurationList section */\n\t\t7D83A9DF1EB6465D001506F0 /* Build configuration list for PBXProject \"procInfo\" */ = {\n\t\t\tisa = XCConfigurationList;\n\t\t\tbuildConfigurations = (\n\t\t\t\t7D83A9EB1EB6465D001506F0 /* Debug */,\n\t\t\t\t7D83A9EC1EB6465D001506F0 /* Release */,\n\t\t\t);\n\t\t\tdefaultConfigurationIsVisible = 0;\n\t\t\tdefaultConfigurationName = Release;\n\t\t};\n\t\t7D83A9ED1EB6465D001506F0 /* Build configuration list for PBXNativeTarget \"procInfo\" */ = {\n\t\t\tisa = XCConfigurationList;\n\t\t\tbuildConfigurations = (\n\t\t\t\t7D83A9EE1EB6465D001506F0 /* Debug */,\n\t\t\t\t7D83A9EF1EB6465D001506F0 /* Release */,\n\t\t\t);\n\t\t\tdefaultConfigurationIsVisible = 0;\n\t\t\tdefaultConfigurationName = Release;\n\t\t};\n/* End XCConfigurationList section */\n\t};\n\trootObject = 7D83A9DC1EB6465D001506F0 /* Project object */;\n}\n"
  },
  {
    "path": "procInfo.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist",
    "content": "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<!DOCTYPE plist PUBLIC \"-//Apple//DTD PLIST 1.0//EN\" \"http://www.apple.com/DTDs/PropertyList-1.0.dtd\">\n<plist version=\"1.0\">\n<dict>\n\t<key>IDEDidComputeMac32BitWarning</key>\n\t<true/>\n</dict>\n</plist>\n"
  }
]