mirror of
https://github.com/flobz/psa_car_controller.git
synced 2026-08-26 10:17:18 +00:00
add simple solution
This commit is contained in:
+43
-26
@@ -4,6 +4,8 @@ import shutil
|
||||
import xml.etree.ElementTree as ET
|
||||
import base64
|
||||
|
||||
|
||||
|
||||
from ChargeControl import ChargeControl, ChargeControls
|
||||
from MyPSACC import MyPSACC
|
||||
from sys import argv
|
||||
@@ -17,32 +19,42 @@ def getxmlvalue(root, name):
|
||||
|
||||
current_dir = os.getcwd()
|
||||
script_dir = dir_path = os.path.dirname(os.path.realpath(__file__))
|
||||
if argv[1].endswith(".apk"):
|
||||
from androguard.core.bytecodes.apk import APK
|
||||
a = APK(argv[1])
|
||||
package_name = "com.psa.mym.mypeugeot"
|
||||
resources = a.get_android_resources() # .get_strings_resources()
|
||||
client_id = resources.get_string(package_name, "PSA_API_CLIENT_ID_PROD")[1]
|
||||
client_secret = resources.get_string(package_name, "PSA_API_CLIENT_SECRET_PROD")[1]
|
||||
remote_refresh_token = None
|
||||
customer_id = None
|
||||
|
||||
if len(argv) > 2:
|
||||
password = argv[2]
|
||||
else:
|
||||
password = ""
|
||||
if len(argv) > 2:
|
||||
password = argv[2]
|
||||
else:
|
||||
password = ""
|
||||
|
||||
os.system(f"java -jar {script_dir}/abe-all.jar unpack {argv[1]} backup.tar {password}")
|
||||
my_tar = tarfile.open('backup.tar')
|
||||
my_tar.extractall()
|
||||
os.system(f"java -jar {script_dir}/abe-all.jar unpack {argv[1]} backup.tar {password}")
|
||||
my_tar = tarfile.open('backup.tar')
|
||||
my_tar.extractall()
|
||||
|
||||
dir = "apps/com.psa.mym.mypeugeot"
|
||||
os.chdir(dir + "/sp")
|
||||
dir = "apps/com.psa.mym.mypeugeot"
|
||||
os.chdir(dir + "/sp")
|
||||
|
||||
psa_pref = "com.psa.mym.mypeugeot_preferences.xml"
|
||||
root = ET.parse(psa_pref).getroot()
|
||||
client_secret = getxmlvalue(root, "CEA_CLIENT_SECRET")
|
||||
client_id = getxmlvalue(root, "CEA_CLIENT_ID")
|
||||
psa_pref = "com.psa.mym.mypeugeot_preferences.xml"
|
||||
root = ET.parse(psa_pref).getroot()
|
||||
client_secret = getxmlvalue(root, "CEA_CLIENT_SECRET")
|
||||
client_id = getxmlvalue(root, "CEA_CLIENT_ID")
|
||||
|
||||
remote_info_file = "BASIC_AUTH_CVS.xml"
|
||||
root = ET.parse(remote_info_file).getroot()
|
||||
customer_id_enc = getxmlvalue(root, "CRYPTED_CUSTOMER_ID")
|
||||
customer_id = base64.b64decode(customer_id_enc).decode('utf-8')
|
||||
remote_info_file = "BASIC_AUTH_CVS.xml"
|
||||
root = ET.parse(remote_info_file).getroot()
|
||||
customer_id_enc = getxmlvalue(root, "CRYPTED_CUSTOMER_ID")
|
||||
customer_id = base64.b64decode(customer_id_enc).decode('utf-8')
|
||||
|
||||
root = ET.parse("HUTokenManager.xml").getroot()
|
||||
remote_enc = root[0].text
|
||||
remote_refresh_token = json.loads(base64.b64decode(remote_enc))["refresh_token"]
|
||||
root = ET.parse("HUTokenManager.xml").getroot()
|
||||
remote_enc = root[0].text
|
||||
remote_refresh_token = json.loads(base64.b64decode(remote_enc))["refresh_token"]
|
||||
|
||||
|
||||
|
||||
@@ -57,11 +69,16 @@ psacc.save_config(name="test.json")
|
||||
res = psacc.get_vehicles()
|
||||
print(f"\nYour vehicles: {res}")
|
||||
|
||||
os.remove("backup.tar")
|
||||
shutil.rmtree('apps')
|
||||
charge_controls = ChargeControls()
|
||||
for vin,vehicle in res.items():
|
||||
chc = ChargeControl(None,vin,100,[0,0])
|
||||
charge_controls.list[vin] = chc
|
||||
charge_controls.saveconfig(name="charge_config1.json")
|
||||
|
||||
|
||||
if not argv[1].endswith(".apk"):
|
||||
os.remove("backup.tar")
|
||||
shutil.rmtree('apps')
|
||||
charge_controls = ChargeControls()
|
||||
for vin,vehicle in res.items():
|
||||
chc = ChargeControl(None,vin,100,[0,0])
|
||||
charge_controls.list[vin] = chc
|
||||
charge_controls.saveconfig(name="charge_config1.json")
|
||||
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user