{"id":21523242,"url":"https://github.com/flabbergastedbd/mitmpeep","last_synced_at":"2025-04-09T22:42:06.596Z","repository":{"id":150852415,"uuid":"102699554","full_name":"flabbergastedbd/mitmpeep","owner":"flabbergastedbd","description":"A tiny library to write better peeping scripts for mitmproxy.","archived":false,"fork":false,"pushed_at":"2017-09-08T14:12:14.000Z","size":16,"stargazers_count":6,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-03-24T00:38:39.299Z","etag":null,"topics":["mitmproxy","pentesting","python3-library"],"latest_commit_sha":null,"homepage":null,"language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/flabbergastedbd.png","metadata":{"files":{"readme":"README.rst","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null}},"created_at":"2017-09-07T06:24:46.000Z","updated_at":"2023-08-23T12:59:10.000Z","dependencies_parsed_at":null,"dependency_job_id":"3a5cbf23-c04c-46ae-a8e4-7fb8c942c079","html_url":"https://github.com/flabbergastedbd/mitmpeep","commit_stats":null,"previous_names":["flabbergastedbd/mitmpeep"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/flabbergastedbd%2Fmitmpeep","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/flabbergastedbd%2Fmitmpeep/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/flabbergastedbd%2Fmitmpeep/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/flabbergastedbd%2Fmitmpeep/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/flabbergastedbd","download_url":"https://codeload.github.com/flabbergastedbd/mitmpeep/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248124858,"owners_count":21051757,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["mitmproxy","pentesting","python3-library"],"created_at":"2024-11-24T01:13:07.392Z","updated_at":"2025-04-09T22:42:06.573Z","avatar_url":"https://github.com/flabbergastedbd.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"mitmpeep Ꙫ\n##########\n\nA small python library with an ambitious aim of helping you write effective mitmproxy scripts with ease. The\ndevelopment of the library is only driven by the simplicity of the api it exposes through which it should\nbe trivial to extract into from the responses, tamper the requests and visualize the differences caused by the\ntampering.\n\nInstallation\n~~~~~~~~~~~~\n\n1. ``git clone https://github.com/tunnelshade/mitmpeep``\n2. ``cd mitmpeep; pip install -e mitmpeep``\n\nExample\n~~~~~~~\n\nIf you ever tried checking auth implementation for an application using two different accounts, you can relate to\n\n+ Attempting to do actions of user 1 with session of user 2.\n+ Repeating the above for all the interesting endpoints.\n+ Visualizing the response to check if cross talk is actually possible.\n\nWith the help of powerful ``mitmproxy`` \u0026 ``mitmpeep``, the following script will let you do the same in a much simpler\nmanner\n\n.. code-block:: python\n\n        from mitmpeep import HTTPSPeeper, Modes\n\n\n        class PrivilegeEscalationPeeper(HTTPSPeeper):\n            URL_FILTER_REGEX = \"endpoint\\?\"  # A regex to filter interesting requests\n\n            def tamper_request(self, request):\n                # Identifier eases the identification part, see the output below\n                request.mpeep_identifier = \"Moderator\"\n                return(request)\n\n            # The way you test for horizontal escalation is you try the same request with\n            # a different account but similar role cookie\n            def tamper_for_replay(self, request):\n                cookies = request.cookies\n                cookies[\"fancy_session\"] = \"a_valid_session_of_other_user\"\n                request.mpeep_identifier = \"User\"\n                request.cookies = cookies\n                return(request)\n\n\n        def start():\n            return(PrivilegeEscalationPeeper(mode=Modes.DIFFER))\n\n\nThe above script will enable you to\n\n+ filter requests using ``URL_FILTER_REGEX``.\n+ tamper the filtered original requests using ``tamper_request()``.\n+ tamper the original request and replay using ``tamper_for_replay()``.\n\nThe library takes care of formatting and showing simple diff of the responses along with some metadata. This concise information\nshould be sufficient to validate if an endpoint is vulnerable to the attack you are testing for. In the following case, it is cleary\nevident that the response size is almost negligible in the tampered case and the diff attests this fact by showing that all we get is\nan error in the response.::\n\n        =================================================== Tamper N Replay ====================================================\n\n        Moderator : Request(POST host.com/oracle/endpoint?r=2\u0026Feed.getModel=1) -\u003e Response(200 OK, application/json;charset=UTF-8, 6.93k)\n           User   : Request(POST host.com/oracle/endpoint?r=2\u0026Feed.getModel=1) -\u003e Response(200 OK, application/json;charset=UTF-8, 297b)\n\n        ---------------------------------------------------- Response Diff -----------------------------------------------------\n\n        - {\"web-app\":{\"servlet\":[{\"servlet-name\":\"cofaxCDS\",\"servlet-class\":\"org.cofax.cds.CDSServlet\",\"init-param\":{\"configGlossary:installationAt\":\"Philadelphia, PA\",\"configGlossary:adminEmail\":\"ksm@pobox.com\",\"configGlossary:poweredBy\":\"Cofax\",\"configGlossary:poweredByIcon\":\"/images/cofax.gif\",\"configGlossary:staticPath\":\"/content/static\",\"templateProcessorClass\":\"org.cofax.WysiwygTemplate\",\"templateLoaderClass\":\"org.cofax.FilesTemplateLoader\",\"templatePath\":\"templates\",\"templateOverridePath\":\"\",\"defaultListTemplate\":\"listTemplate.htm\",\"defaultFileTemplate\":\"articleTemplate.htm\",\"useJSP\":false,\"jspListTemplate\":\"listTemplate.jsp\",\"jspFileTemplate\":\"articleTemplate.jsp\",\"cachePackageTagsTrack\":200,\"cachePackageTagsStore\":200,\"cachePackageTagsRefresh\":60,\"cacheTemplatesTrack\":100,\"cacheTemplatesStore\":50,\"cacheTemplatesRefresh\":15,\"cachePagesTrack\":200,\"cachePagesStore\":100,\"cachePagesRefresh\":10,\"cachePagesDirtyRead\":10,\"searchEngineListTemplate\":\"forSearchEnginesList.htm\",\"searchEngineFileTemplate\":\"forSearchEngines.htm\",\"searchEngineRobotsDb\":\"WEB-INF/robots.db\",\"useDataStore\":true,\"dataStoreClass\":\"org.cofax.SqlDataStore\",\"redirectionClass\":\"org.cofax.SqlRedirection\",\"dataStoreName\":\"cofax\",\"dataStoreDriver\":\"com.microsoft.jdbc.sqlserver.SQLServerDriver\",\"dataStoreUrl\":\"jdbc:microsoft:sqlserver://LOCALHOST:1433;DatabaseName=goon\",\"dataStoreUser\":\"sa\",\"dataStorePassword\":\"dataStoreTestQuery\",\"dataStoreTestQuery\":\"SET NOCOUNT ON;select test='test';\",\"dataStoreLogFile\":\"/usr/local/tomcat/logs/datastore.log\",\"dataStoreInitConns\":10,\"dataStoreMaxConns\":100,\"dataStoreConnUsageLimit\":100,\"dataStoreLogLevel\":\"debug\",\"maxUrlLength\":500}},{\"servlet-name\":\"cofaxEmail\",\"servlet-class\":\"org.cofax.cds.EmailServlet\",\"init-param\":{\"mailHost\":\"mail1\",\"mailHostOverride\":\"mail2\"}},{\"servlet-name\":\"cofaxAdmin\",\"servlet-class\":\"org.cofax.cds.AdminServlet\"},{\"servlet-name\":\"fileServlet\",\"servlet-class\":\"org.cofax.cds.FileServlet\"},{\"servlet-name\":\"cofaxTools\",\"servlet-class\":\"org.cofax.cms.CofaxToolsServlet\",\"init-param\":{\"templatePath\":\"toolstemplates/\",\"log\":1,\"logLocation\":\"/usr/local/tomcat/logs/CofaxTools.log\",\"logMaxSize\":\"\",\"dataLog\":1,\"dataLogLocation\":\"/usr/local/tomcat/logs/dataLog.log\",\"dataLogMaxSize\":\"\",\"removePageCache\":\"/content/admin/remove?cache=pages\u0026id=\",\"removeTemplateCache\":\"/content/admin/remove?cache=templates\u0026id=\",\"fileTransferFolder\":\"/usr/local/tomcat/webapps/content/fileTransferFolder\",\"lookInContext\":1,\"adminGroupID\":4,\"betaServer\":true}}],\"servlet-mapping\":{\"cofaxCDS\":\"/\",\"cofaxEmail\":\"/cofaxutil/aemail/*\",\"cofaxAdmin\":\"/admin/*\",\"fileServlet\":\"/static/*\",\"cofaxTools\":\"/tools/*\"},\"taglib\":{\"taglib-uri\":\"cofax.tld\",\"taglib-location\":\"/WEB-INF/tlds/cofax.tld\"}}}\n        + */{\"defaultHandler\":\"function() {var e=new Error('[SystemErrorException from server] unknown error');e.reported=true;throw e;}\", \"exceptionEvent\":true}/*ERROR*/\n\n        ============================ output/host.com/oracle/65d2cc6f969698f6203d4103965b7497.diff.0 ============================\n\nFor more examples, have a look at `examples`_. Combining those examples gives you some powerful primitives. If you wish to see more\nfunctionality, have a loot at `peeper.py`_ to see what methods can be overridden.\n\nPS: Maybe create pip package if people use it.\n\n.. _examples: examples/\n.. _peeper.py: mitmpeep/peeper.py\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fflabbergastedbd%2Fmitmpeep","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fflabbergastedbd%2Fmitmpeep","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fflabbergastedbd%2Fmitmpeep/lists"}