feat: gpx file

main
Khiem Ton 2 years ago
parent b85c6d491a
commit 901a0e4eec
Signed by: th4tkh13m
GPG Key ID: 4D9CF147DCADD05D

@ -5,4 +5,7 @@
<orderEntry type="jdk" jdkName="iSpoof_dev" jdkType="Python SDK" /> <orderEntry type="jdk" jdkName="iSpoof_dev" jdkType="Python SDK" />
<orderEntry type="sourceFolder" forTests="false" /> <orderEntry type="sourceFolder" forTests="false" />
</component> </component>
<component name="PackageRequirementsSettings">
<option name="versionSpecifier" value="Don't specify version" />
</component>
</module> </module>

@ -1,4 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?> <?xml version="1.0" encoding="UTF-8"?>
<project version="4"> <project version="4">
<component name="ProjectRootManager" version="2" project-jdk-name="iSpoof_dev" project-jdk-type="Python SDK" /> <component name="ProjectRootManager" version="2" project-jdk-name="iSpoof_dev" project-jdk-type="Python SDK" />
<component name="PythonCompatibilityInspectionAdvertiser">
<option name="version" value="3" />
</component>
</project> </project>

@ -1,28 +1,40 @@
from geopy.geocoders import Nominatim from geopy.geocoders import Nominatim
from ispoof.spoofer.location import Location from ispoof.spoofer.location import Location
from ispoof.spoofer.device import Device
from ispoof.lists.playerhistory import PlayerHistory from ispoof.lists.playerhistory import PlayerHistory
from datetime import datetime, timedelta from datetime import datetime, timedelta
from math import ceil from math import ceil
import gpxpy
import time
TIME = 1
class Player: class Player:
def __init__(self, engine, location=None, cooldown=0): def __init__(self, engine, speed=1.4, location=None, cooldown=0):
self.location = location self.location = location
self.cooldown = cooldown self.cooldown = cooldown
self.speed = speed
self.history = PlayerHistory(engine=engine) self.history = PlayerHistory(engine=engine)
self.device = Device()
def prepare_device(self):
self.device.mount_image()
def set_location_with_query(self, query): def set_location_with_query(self, query):
loc = Nominatim(user_agent="GetLoc") loc = Nominatim(user_agent="GetLoc")
get_loc = loc.geocode(query) get_loc = loc.geocode(query)
self.location = Location(get_loc.latitude, get_loc.longitude) self.location = Location(get_loc.latitude, get_loc.longitude)
self.device.spoof_gps(self.location)
def get_last_activity(self): def get_last_activity(self):
return self.history.get_last_activity() return self.history.get_last_activity()
def set_location(self, location: Location): def set_location(self, location: Location):
self.location = location self.location = location
self.device.spoof_gps(self.location)
def do_activity(self, location: Location): def do_activity(self, location: Location):
return self.history.add_activity(location) return self.history.add_activity(location)
@ -58,3 +70,36 @@ class Player:
if do_activity: if do_activity:
self.do_activity(self.location) self.do_activity(self.location)
def set_last_location(self):
_, location = self.get_last_activity()
self.set_location(location)
def set_speed(self, speed):
self.speed = speed
def gpx_walking(self, gpx_file):
with open(gpx_file) as f:
gpx = gpxpy.parse(f)
gpx_points = []
for track in gpx.tracks:
for segment in track.segments:
for point in segment.points:
gpx_points.append(Location(point.latitude, point.longitude))
num_location_points = len(gpx_points)
point_lst = []
for i in range(num_location_points - 1):
start = gpx_points[i]
end = gpx_points[i+1]
distance = start.calculate_distance(end)
_time = distance / self.speed
num_points = int((distance * 1000) / self.speed) + 1
intermediate_points = start.generate_intermediate_points(end, num_points)
point_lst = point_lst + intermediate_points
print("HERE")
print(point_lst[:5])
for point in point_lst:
self.set_location(point)
time.sleep(TIME)

@ -10,13 +10,14 @@ import tempfile
import zipfile import zipfile
from tqdm import tqdm from tqdm import tqdm
from ispoof.utils import get_home_folder from ispoof.utils import get_home_folder
from ispoof.spoofer.location import Location
DEVELOPER_DISK_IMAGE_URL = 'https://github.com/pdso/DeveloperDiskImage/raw/master/{ios_version}/{ios_version}.zip' DEVELOPER_DISK_IMAGE_URL = 'https://github.com/pdso/DeveloperDiskImage/raw/master/{ios_version}/{ios_version}.zip'
logger = logging.getLogger(__name__) logger = logging.getLogger(__name__)
def download_developer_disk_image(ios_version, directory): def download_developer_disk_image(ios_version: str, directory: Path):
url = DEVELOPER_DISK_IMAGE_URL.format(ios_version=ios_version) url = DEVELOPER_DISK_IMAGE_URL.format(ios_version=ios_version)
with requests.get(url, stream=True) as r: with requests.get(url, stream=True) as r:
r.raise_for_status() r.raise_for_status()
@ -73,7 +74,7 @@ class Device:
else: else:
logger.debug("Image is mounted.") logger.debug("Image is mounted.")
def spoof_gps(self, destination): def spoof_gps(self, destination: Location):
if self.location is None: if self.location is None:
self.location = DtSimulateLocation(self.lockdown) self.location = DtSimulateLocation(self.lockdown)
self.location.set(destination.latitude, destination.longitude) self.location.set(destination.latitude, destination.longitude)

@ -1,15 +1,21 @@
from math import radians, sin, cos, asin, sqrt from __future__ import annotations
from math import radians, sin, cos, asin, sqrt, atan2, degrees
from sqlalchemy.types import TypeDecorator, String from sqlalchemy.types import TypeDecorator, String
from typing import List
from geographiclib.geodesic import Geodesic
class Location(TypeDecorator): class Location(TypeDecorator):
impl = String impl = String
cache_ok = True cache_ok = True
def __init__(self, latitude=None, longitude=None): def __init__(self, latitude: float = None, longitude: float = None):
self.latitude = latitude self.latitude = latitude
self.longitude = longitude self.longitude = longitude
def get_tuple(self):
return self.latitude, self.longitude
def process_bind_param(self, value, dialect): def process_bind_param(self, value, dialect):
if value: if value:
return str(value) return str(value)
@ -22,72 +28,77 @@ class Location(TypeDecorator):
# Provide the implementation for the specified dialect # Provide the implementation for the specified dialect
return dialect.type_descriptor(String) return dialect.type_descriptor(String)
def distance(self, other): def calculate_distance(self, other: Location):
R = 6371 return Geodesic.WGS84.Inverse(*self.get_tuple(), *other.get_tuple())["s12"] / 1000
d_lat = radians(self.latitude - other.latitude)
d_lon = radians(self.longitude - other.longitude)
a = sin(d_lat/2) * sin(d_lat/2) +\ def generate_intermediate_points(self, other: Location, num_points) -> List[Location]:
sin(d_lon/2) * sin(d_lon/2) * cos(radians(self.latitude)) * cos(radians(other.latitude)) # Calculate the distance between the start and end points
_distance = self.calculate_distance(other) * 1000
spacing = _distance / (num_points + 1)
c = 2 * asin(sqrt(a)) # Calculate the intermediate points along the geodesic line
d = R * c points = []
for i in range(1, num_points + 1):
# Calculate the position of the i-th intermediate point
d = i * spacing
g = Geodesic.WGS84.InverseLine(*self.get_tuple(), *other.get_tuple()).Position(d)
lat, lon = g['lat2'], g['lon2']
points.append(Location(lat, lon))
return d return points
def get_cooldown(self, other): def get_cooldown(self, other):
distance = self.distance(other) _distance = self.calculate_distance(other)
if distance <= 2: if _distance <= 2:
return 1 return 1
elif distance <= 5: elif _distance <= 5:
return 2 return 2
elif distance <= 7: elif _distance <= 7:
return 5 return 5
elif distance <= 10: elif _distance <= 10:
return 7 return 7
elif distance <= 12: elif _distance <= 12:
return 8 return 8
elif distance <= 18: elif _distance <= 18:
return 10 return 10
elif distance <= 26: elif _distance <= 26:
return 15 return 15
elif distance <= 42: elif _distance <= 42:
return 19 return 19
elif distance <= 65: elif _distance <= 65:
return 22 return 22
elif distance <= 81: elif _distance <= 81:
return 25 return 25
elif distance <= 100: elif _distance <= 100:
return 35 return 35
elif distance <= 220: elif _distance <= 220:
return 40 return 40
elif distance <= 250: elif _distance <= 250:
return 45 return 45
elif distance <= 350: elif _distance <= 350:
return 51 return 51
elif distance <= 375: elif _distance <= 375:
return 54 return 54
elif distance <= 460: elif _distance <= 460:
return 62 return 62
elif distance <= 500: elif _distance <= 500:
return 65 return 65
elif distance <= 565: elif _distance <= 565:
return 69 return 69
elif distance <= 700: elif _distance <= 700:
return 78 return 78
elif distance <= 800: elif _distance <= 800:
return 84 return 84
elif distance <= 900: elif _distance <= 900:
return 92 return 92
elif distance <= 1000: elif _distance <= 1000:
return 99 return 99
elif distance <= 1100: elif _distance <= 1100:
return 107 return 107
elif distance <= 1200: elif _distance <= 1200:
return 114 return 114
elif distance <= 1300: elif _distance <= 1300:
return 117 return 117
else: else:
return 120 return 120
@ -105,6 +116,6 @@ class Location(TypeDecorator):
return False return False
def __hash__(self): def __hash__(self):
return hash((self.latitude, self.longitude)) return hash(self.get_tuple())

@ -2,92 +2,102 @@ from ispoof.objects.player import Player
from ispoof.spoofer.scraper import Scraper from ispoof.spoofer.scraper import Scraper
from ispoof.spoofer.device import Device from ispoof.spoofer.device import Device
from ispoof.lists import PokemonList, RaidList from ispoof.lists import PokemonList, RaidList
from pathlib import Path
from ispoof.data import Database from ispoof.data import Database
if __name__ == "__main__": if __name__ == "__main__":
device = Device()
device.mount_image()
database = Database() database = Database()
database.initialize_database() database.initialize_database()
engine = database.get_engine() engine = database.get_engine()
player = Player(engine=engine) player = Player(engine=engine)
player.prepare_device()
print("Choose Location")
print("1. Last location")
print("2. Provided location")
while True:
location_input = int(input("Choose: "))
if location_input in (1, 2):
break
if location_input == 1:
player.set_last_location()
else:
query = input("Enter your location: ") query = input("Enter your location: ")
player.set_location_with_query(query) player.set_location_with_query(query)
scraper = Scraper() scraper = Scraper()
pokemon_lst = PokemonList(engine=engine) pokemon_lst = PokemonList(engine=engine)
raid_lst = RaidList(engine=engine) raid_lst = RaidList(engine=engine)
# while True:
# print("1. Raid")
# print("2. Pokemon")
# print("3. GPX file")
# raid_or_mon = int(input("Choose 1: "))
# if raid_or_mon == 1:
# raids = scraper.get_raids()
# raid_lst.insert_to_database(raids)
# print("1. Sort by name")
# print("2. Sort by level")
# print("3. Sort by distance")
# print("4. Search name")
# choice = int(input("Your choice: "))
# if choice == 1:
# raids = raid_lst.sort_by_name()
# elif choice == 2:
# raids = raid_lst.sort_by_level()
# elif choice == 3:
# raids = raid_lst.sort_by_distance(player.location)
# else:
# raids = raid_lst.search_by_name(input("Enter query: "))
# print("Raid List:")
# for i, raid in enumerate(raids):
# print(i, raid)
# i = int(input("Choose raid: "))
# pokemon = raids[i]
# location = raid.location
# else:
# pokemons = scraper.get_hundos()
# pokemon_lst.insert_to_database(pokemons)
# print("1. Sort by name")
# print("2. Sort by level")
# print("3. Sort by CP")
# print("4. Sort by distance")
# print("5. Search name")
# choice = int(input("Your choice: "))
# if choice == 1:
# pokemons = pokemon_lst.sort_by_name()
# elif choice == 2:
# pokemons = pokemon_lst.sort_by_level()
# elif choice == 3:
# pokemons = pokemon_lst.sort_by_cp()
# elif choice == 4:
# pokemons = pokemon_lst.sort_by_distance(player.location)
# else:
# pokemons = pokemon_lst.search_by_name(input("Enter query: "))
# print("Pokemon List:")
# for i, pokemon in enumerate(pokemons):
# print(i, pokemon)
# i = int(input("Choose pokemon: "))
# pokemon = pokemons[i]
# location = pokemon.location
# pokemon_lst.visit_pokemon(pokemon)
# device.spoof_gps(location)
# did_activity = None
# print("Spoof to")
# print(pokemon)
# while True:
# activity = input("Did you do any cooldown activities? [Y/N] ").lower()
# if activity in ("y", "n"):
# did_activity = activity == "y"
# break
# player.change_gps_by_location(location, did_activity)
# print(f"Current cooldown: {player.get_current_cooldown()} min")
while True: while True:
print("1. Raid") player.gpx_walking(Path.home() / "Downloads/Sydney.gpx")
print("2. Pokemon")
raid_or_mon = int(input("Choose 1: "))
if raid_or_mon == 1:
raids = scraper.get_raids()
raid_lst.insert_to_database(raids)
print("1. Sort by name")
print("2. Sort by level")
print("3. Sort by distance")
print("4. Search name")
choice = int(input("Your choice: "))
if choice == 1:
raids = raid_lst.sort_by_name()
elif choice == 2:
raids = raid_lst.sort_by_level()
elif choice == 3:
raids = raid_lst.sort_by_distance(player.location)
else:
raids = raid_lst.search_by_name(input("Enter query: "))
print("Raid List:")
for i, raid in enumerate(raids):
print(i, raid)
i = int(input("Choose raid: "))
pokemon = raids[i]
location = raid.location
else:
pokemons = scraper.get_hundos()
pokemon_lst.insert_to_database(pokemons)
print("1. Sort by name")
print("2. Sort by level")
print("3. Sort by CP")
print("4. Sort by distance")
print("5. Search name")
choice = int(input("Your choice: "))
if choice == 1:
pokemons = pokemon_lst.sort_by_name()
elif choice == 2:
pokemons = pokemon_lst.sort_by_level()
elif choice == 3:
pokemons = pokemon_lst.sort_by_cp()
elif choice == 4:
pokemons = pokemon_lst.sort_by_distance(player.location)
else:
pokemons = pokemon_lst.search_by_name(input("Enter query: "))
print("Pokemon List:")
for i, pokemon in enumerate(pokemons):
print(i, pokemon)
i = int(input("Choose pokemon: "))
pokemon = pokemons[i]
location = pokemon.location
pokemon_lst.visit_pokemon(pokemon)
device.spoof_gps(location)
did_activity = None
print("Spoof to")
print(pokemon)
while True:
activity = input("Did you do any cooldown activities? [Y/N] ").lower()
if activity in ("y", "n"):
did_activity = activity == "y"
break
player.change_gps_by_location(location, did_activity)
print(f"Current cooldown: {player.get_current_cooldown()} min")
while True: while True:
continue_prompt = input("Continue? [Y/N] ").lower() continue_prompt = input("Continue? [Y/N] ").lower()
if continue_prompt in ("y", "n"): if continue_prompt in ("y", "n"):
if continue_prompt == "n": if continue_prompt == "n":
device.stop_spoofing() player.device.stop_spoofing()
exit(0) exit(0)
else: else:
break break

@ -5,3 +5,5 @@ requests
geopy geopy
thefuzz[speedup] thefuzz[speedup]
sqlalchemy sqlalchemy
tqdm
gpxpy
Loading…
Cancel
Save