From 44baf9545e4ed80afa7e5034bc81cc5e07eb0cb0 Mon Sep 17 00:00:00 2001 From: maleksal Date: Mon, 10 May 2021 10:08:55 +0100 Subject: [PATCH] initial commits --- README.md | 41 +++++++++++++++++++++++ main.py | 86 ++++++++++++++++++++++++++++++++++++++++++++++++ requirements.txt | 1 + 3 files changed, 128 insertions(+) create mode 100644 README.md create mode 100755 main.py create mode 100644 requirements.txt diff --git a/README.md b/README.md new file mode 100644 index 0000000..e42b5aa --- /dev/null +++ b/README.md @@ -0,0 +1,41 @@ +# Instagram Hacks + +Watch Instagram story's and read Direct messages without getting marked as seen. This is can be achieved by using Mitmproxy that allows us to intercept HTTP traffic and tamper data, but in this example it's only blocking some internal API calls. + +## Installation + +* Install: + +```console +# clone the repo +$ git clone https://github.com/maleksal/instagram-hacks + +# install requirements +$ python3 -m pip install -r requirements.txt + +``` + +* Configure system proxy settings: + + If you are using ubuntu, go settings > network > network proxy > click manual. Then in http proxy put 127.0.0.1 and http port 8080 + +* Install certificate: + + run main.py, then in your browser go to mitm.it download the certificate and follow the 2 steps instruction. + +* You're ready to go :). + + > full documentation of Mitmproxy is available [here](https://github.com/mitmproxy/mitmproxy) + + + +## Usage + +```console +$ python3 main.py +``` + +> use control-c to exit + + + diff --git a/main.py b/main.py new file mode 100755 index 0000000..821964a --- /dev/null +++ b/main.py @@ -0,0 +1,86 @@ +from mitmproxy.options import Options +from mitmproxy.proxy.config import ProxyConfig +from mitmproxy.proxy.server import ProxyServer +from mitmproxy.tools.dump import DumpMaster + +import threading +import asyncio +import time + + +import re + + + +class InstagramDM(object): + """ + Leaves message as unseen by blocking the seen request. + Leaves story as unseen by blocking the seen request. + """ + + _targets = [ + r"https://i.instagram.com/api/v1/direct_v2/threads/.*/items/.*/seen/", + r"https://www.instagram.com/stories/reel/seen" + ] + + def match_url(self, url): + """ + Match url against target url + """ + coms = [ + re.compile(url) for url in self._targets + ] + return any([True if re.search(c_url, url) else False for c_url in coms]) + + def request(self, flow): + """Kill spesific request. + """ + + if self.match_url(flow.request.pretty_url) and flow.request.method == "POST": + print("Marked as unseen :)") + flow.kill() + + + +class MitmClass: + """Lunch mitmproxy within python. + """ + def __init__(self, host, port, addons): + + self.options = Options( + listen_host=str(host), + listen_port=int(port), + http2=True) + + self.mitm = DumpMaster( + self.options, + with_termlog=False, + with_dumper=False) + + self.addons = addons + self.config_server() + + def config_server(self): + config = ProxyConfig(self.options) + self.mitm.server = ProxyServer(config) + self.mitm.addons.add(self.addons) + + +def loop_in_thread(loop, m): + asyncio.set_event_loop(loop) + m.mitm.run_loop(loop.run_forever) + + +if __name__ == "__main__": + + # setup + mitm = MitmClass( + host="127.0.0.1", + port="8080", + addons=InstagramDM() + ) + + # run mitm mproxy in backgroud + loop = asyncio.get_event_loop() + t = threading.Thread(target=loop_in_thread, args=(loop, mitm)) + t.start() diff --git a/requirements.txt b/requirements.txt new file mode 100644 index 0000000..8b3a342 --- /dev/null +++ b/requirements.txt @@ -0,0 +1 @@ +mitmproxy