Created
July 20, 2017 00:24
-
-
Save louisabraham/fa92cbbbecbd1af7797149349099b4a8 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
""" | |
MITM to cheat on Everwing | |
Can be modified to work with any messenger game | |
Instructions: | |
Launch with `mitmproxy -s mitm_everwing.py` | |
Press 'e' to see the log | |
""" | |
from mitmproxy.utils import strutils | |
from mitmproxy import ctx | |
import re | |
################################################## | |
# Parameters | |
# You can adapt the code to any game | |
# just by changing those parameters | |
################################################## | |
url = r'https://apps-141184676316522\.apps\.fbsbx\.com/instant-bundle/1174389249249108/\d*/browser-mobile\.js' | |
replacements = { | |
'gemSpawnChance:.03': 'gemSpawnChance:.5', | |
# changes the value of the common coins | |
'spriteURL:"resources/images/game/base/coin",spriteAction:"spin",common:1,premium:0': | |
'spriteURL:"resources/images/game/base/coin",spriteAction:"spin",common:1000,premium:1000', | |
# multiplies the XP of the character and the sidekicks | |
'this.getFinalXP\(e,t\)': 'this.getFinalXP(e,t)*1000', | |
# modifies the dommage of the character | |
'levelMultiplier:5': 'levelMultiplier:5000', | |
# allows to earn more premium that the default limit | |
'max:2500': 'max:14000', | |
'maxPremiumPerGame:2500': 'maxPremiumPerGame:14000' | |
} | |
################################################## | |
info = ctx.log.info | |
debug = ctx.log.debug | |
def response(flow): | |
if re.match(url, flow.request.url): | |
info('FOUND!!!') | |
res = flow.response | |
# comment this line to make the hack work without mitmproxy | |
disable_cache(res) | |
for a, b in replacements.items(): | |
info('Replaced %s %s' % (a, replace_in_body(res, a, b))) | |
def replace_in_body(response, pattern, repl, flags=0, count=0): | |
if isinstance(pattern, str): | |
pattern = strutils.escaped_str_to_bytes(pattern) | |
if isinstance(repl, str): | |
repl = strutils.escaped_str_to_bytes(repl) | |
replacements = 0 | |
if response.content: | |
response.content, replacements = re.subn( | |
pattern, repl, response.content, flags=flags, count=count | |
) | |
return replacements | |
def disable_cache(response): | |
response.headers['Cache-Control'] = 'no-cache, no-store, must-revalidate' | |
response.headers['Pragma'] = 'no-cache' | |
response.headers['Expires'] = '0' |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment