Skip to content

Instantly share code, notes, and snippets.

@freyta
Created July 28, 2020 07:02
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save freyta/9c1cfd68402c4661932dcf032ba35018 to your computer and use it in GitHub Desktop.
Save freyta/9c1cfd68402c4661932dcf032ba35018 to your computer and use it in GitHub Desktop.
Frida script to set mock location to the coordinates from ProjectZeroThree
import frida
import sys, argparse, textwrap
import json, requests
AVAILABLE_REGIONS = [0,1,2,3,4]
AVAILABLE_FUEL_TYPE = [0,1,2,3,4,5]
# Add args so we can choose which area in Australia we get the prices.
parser = argparse.ArgumentParser(prog='freighter_frida.py',
formatter_class=argparse.RawDescriptionHelpFormatter,
description=textwrap.dedent('''\
This allows you to choose which state/area you lock your fuel in from.
Location and prices taken from ProjectZeroThree.
| |""""""""""""""""| |
|.|_AVAILABLE______|H|
|.|_OPTIONS ARE:___| |
|.|_0_=_ALL________| |
| |_1_=_VIC________| |
| |_2_=_NSW________| |
| |_3_=_QLD________| |
| |_4_=_WA_________| |
| |
| ____________ |
| | | _ | |
| | | | | | |
| | | |_| | V | mga
|___|___|________|___|
'''))
parser.add_argument('-r','--region', help='Choose a custom region. Must be between 0 and 4.', required=False)
parser.add_argument('-f','--fuel', help='Choose which fuel type you want. Must be between 0 and 5.', required=False)
args = vars(parser.parse_args())
# Get the region from the arguments passed to the script. If none is set we default to all of Australia
if args['region']:
try:
if int(args['region']) in AVAILABLE_REGIONS:
region = int(args['region'])
else:
print("ERROR: INVALID REGION ENTERED. \nThe region must be between 0 and 5.")
exit()
except ValueError:
print("ERROR: INVALID REGION ENTERED. \nThe region must be between 0 and 5.")
exit()
else:
print("[!] No region entered. Defaulting to all of Australia.")
region = int(0)
# Get the fuel type from the arguments passed to the script. If none is set we default to unleaded 98
if args['fuel']:
try:
if int(args['fuel']) in AVAILABLE_FUEL_TYPE:
fuel_type = int(args['fuel'])
else:
print("ERROR: INVALID FUEL TYPE ENTERED. \nThe fuel type must be between 0 and 5.")
print("0 = E10 \n1 = Unleaded 91 \n2 = Unleaded 95 \n3 = Unleaded 98 \n4 = Diesel \n5 = LPG")
exit()
except ValueError:
print("ERROR: INVALID FUEL TYPE ENTERED. \nThe fuel type must be between 0 and 5.")
print("0 = E10 \n1 = Unleaded 91 \n2 = Unleaded 95 \n3 = Unleaded 98 \n4 = Diesel \n5 = LPG")
exit()
else:
print("[!] No fuel type entered. Defaulting to Premium 98.")
fuel_type = int(3)
# Get the cheapest price from our desired location and fuel type
print("[*] Loading the cheapest price")
r = requests.get("https://projectzerothree.info/api.php?format=json", headers={"User-Agent": "Freighters Frida Script"}).json()
long = r['regions'][region]['prices'][fuel_type]['lng']
lat = r['regions'][region]['prices'][fuel_type]['lat']
print("[*] The cheapest stores longitude and latitude has been found")
# Attach to the USB device and the My 7-Eleven app
session = frida.get_usb_device(1000).attach("au.com.fuel7eleven")
# Create the script that will inject our location into the app.
script = session.create_script("""
console.log("");
console.log("+------------------------+");
console.log("| Let's block and roll |");
console.log("+------------------------+");
console.log("");
console.log("[i] Select your fuel type and then press 'FIND MY BEST FUEL PRICE'");
Java.perform(function() {
var lat = %s;
var long = %s;
var fuel = "ULP";
console.log("[*] Longitude is set to " + long);
console.log("[*] Latitude is set to " + lat);
// OVERRIDE THE LOCATION DATA
var Location = Java.use('android.location.Location');
Location.getLatitude.implementation = function() {
return lat;
}
Location.getLongitude.implementation = function() {
return long;
}
});
""" % (float(lat), float(long)))
# If there is an error this will show us what it is. We shouldn't get an error but anyway.
def on_message(message, data):
if message['type'] == 'error':
print("[!] " + message['stack'])
elif message['type'] == 'send':
print("[i] " + message['payload'])
else:
print(message)
script.on('message', on_message)
# As long as we haven't tried to exit by pressing ctrl+c
try:
script.load()
sys.stdin.read()
except KeyboardInterrupt:
print("[!] Quitting.")
@southpolemonkey
Copy link

southpolemonkey commented Mar 2, 2021

Hi, does it work on IOS?

@CRCinAU
Copy link

CRCinAU commented Feb 13, 2022

Hmmm - does this still work or am I wasting my time trying?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment