Closed BleakFox closed 1 year ago
Same with ubuntu 22.04.2 and ios 16.5.1 on SE2020. Worked fine a week ago
I am trying to rewrie the pyscript edition Currently it's works for tethered refreshing with custom anisette-server method And plan for adding new features like wifi installaion Of course,I need time for working on it
import os
import sys
import datetime
import platform
import requests
import signal
import subprocess
DEBUGGING = True
TIME_FORMAT = "%Y-%m-%d %H:%M:%S"
# ANISETTE-SERVER
ANISETTE_HOST = "127.0.0.1"
ANISETTE_PORT = 6969
# ARCH
ARCH = platform.machine()
if ARCH == "armv7l":
ARCH = "armv7"
NETMUXD_AVAILABLE_ARCHS = ("x86_64", "aarch64", "armv7")
NETMUXD_IS_AVAILABLE = ARCH in NETMUXD_AVAILABLE_ARCHS
NETMUXD_IS_ON = NETMUXD_IS_AVAILABLE
# DIRECTORY
CURRENT_DIRECTORY = os.path.dirname(os.path.realpath(__file__))
RESOURCE_DIRECTORY = os.path.join(CURRENT_DIRECTORY, "resource")
# VERSIONS
ALTSERVER_VERSION = "v0.0.5"
ALTSTORE_VERSION = "1_6_3"
NETMUXD_VERSION = "v0.1.4"
ANISETTE_SERVER_VERSION = "2.1.0"
# PATH AND URL
ALTSERVER_PATH = os.path.join(RESOURCE_DIRECTORY, "AltServer")
ALTSERVER_URL = f"https://github.com/NyaMisty/AltServer-Linux/releases/download/{ALTSERVER_VERSION}/AltServer-{ARCH}"
ALTSTORE_PATH = os.path.join(RESOURCE_DIRECTORY, "AltStore.ipa")
ALTSTORE_URL = f"https://cdn.altstore.io/file/altstore/apps/altstore/{ALTSTORE_VERSION}.ipa"
NETMUXD_PATH = os.path.join(RESOURCE_DIRECTORY, "netmuxd")
NETMUXD_URL = f"https://github.com/jkcoxson/netmuxd/releases/download/{NETMUXD_VERSION}/{ARCH}-linux-netmuxd"
ANISETTE_SERVER_PATH = os.path.join(RESOURCE_DIRECTORY, "anisette-server")
ANISETTE_SERVER_URL = f"https://github.com/Dadoum/Provision/releases/download/{ANISETTE_SERVER_VERSION}/anisette-server-{ARCH}"
def getAnswer(text):
try:
return input(text)
except KeyboardInterrupt:
print("\nCtrl+C pressed, aborting")
exit(-2)
def DebugPrint(msg):
now = datetime.datetime.now().strftime(TIME_FORMAT)
if DEBUGGING:
print(f"[DEBUG] {now}\n== {msg} ==")
def CheckResource():
if not os.path.exists(RESOURCE_DIRECTORY):
print("Creating 'resource' directory")
os.mkdir(RESOURCE_DIRECTORY)
if not os.path.exists(ALTSERVER_PATH):
print("Downloading Altserver")
response = requests.get(ALTSERVER_URL)
open(ALTSERVER_PATH, "wb").write(response.content)
if not os.path.exists(ALTSTORE_PATH):
print("Downloading AltStore ipa")
response = requests.get(ALTSTORE_URL)
open(ALTSTORE_PATH, "wb").write(response.content)
if not os.path.exists(NETMUXD_PATH):
print("Downloading netmuxd")
response = requests.get(NETMUXD_URL)
open(NETMUXD_PATH, "wb").write(response.content)
if not os.path.exists(ANISETTE_SERVER_PATH):
print("Downloading anisette-server")
response = requests.get(ANISETTE_SERVER_URL)
open(ANISETTE_SERVER_PATH, "wb").write(response.content)
if not os.access(ALTSERVER_PATH, os.X_OK):
print("Setting AltServer exec permission")
os.chmod(ALTSERVER_PATH, 0o755)
if not os.access(NETMUXD_PATH, os.X_OK):
print("Setting netmuxd exec permission")
os.chmod(NETMUXD_PATH, 0o755)
if not os.access(ANISETTE_SERVER_PATH, os.X_OK):
print("Setting anisette-server permission")
os.chmod(ANISETTE_SERVER_PATH, 0o755)
DebugPrint(subprocess.getoutput(f"ls -al {RESOURCE_DIRECTORY}"))
def CheckNetworkConnection() -> bool:
try:
requests.get('http://google.com')
return True
except:
return False
class AnisetteServer:
def __init__(self, host=ANISETTE_HOST, port=ANISETTE_PORT):
self.host = host
self.port = port
os.environ["ALTSERVER_ANISETTE_SERVER"] = f"http://{host}:{port}"
DebugPrint(os.environ["ALTSERVER_ANISETTE_SERVER"])
DebugPrint(f"{ANISETTE_SERVER_PATH} -n {host} -p {port}")
self.server = subprocess.Popen(f"{ANISETTE_SERVER_PATH} -n {host} -p {port}", shell=True,stdout=subprocess.DEVNULL,stderr=subprocess.STDOUT)
def kill(self):
self.server.kill()
os.killpg(os.getpgid(self.server.pid), signal.SIGTERM)
class AltServerDaemon:
def __init__(self, Anisette_Server: AnisetteServer, WiFiMode=NETMUXD_IS_ON):
self.WifiMode = WiFiMode
self.Anisette_Server = Anisette_Server
self.start()
def start(self):
self.altserver = subprocess.Popen(ALTSERVER_PATH,shell=True,env=os.environ)
def kill(self):
self.altserver.kill()
os.killpg(os.getpgid(self.altserver.pid), signal.SIGTERM)
def restart():
pass
def switchTether():
pass
def switchWiFi():
pass
def main():
if CheckNetworkConnection() == False:
print("Please connect to network and re-run the script")
exit(-1)
CheckResource()
anisetteserver = AnisetteServer()
altserverdaemon = AltServerDaemon(anisetteserver)
# print(HELP_MSG)
while True:
option = getAnswer("Enter OPTION to continue : ").lower()
if option == 'i':
pass
elif option == 'w':
pass
elif option == 't':
pass
elif option == 'e':
altserverdaemon.kill()
anisetteserver.kill()
break
elif option == 'h':
print(HELP_MSG)
elif option == 'p':
pass
elif option == 'u':
pass
else:
print("Invalid option")
HELP_MSG = """
#####################################
# Welcome to the AltServer script #
#####################################
ScriptUsage: [OPTION]
OPTIONS
i, --Install AltStore or ipa files
Install AltStore or ipa files to your device
w, --Switch to wifi Daemode mode (Default using it after launch)
Switch and restart to wifi Daemode mode to refresh apps or AltStore
t, --Switch to usb tethered Daemode mode
Switch and restart to usb tethered Daemode mode to refresh apps or AltStore
e, --Exit
Exit script
h, --Help
Show this message
p, --Pair
Pair devices
u, --Update
Update this script
For more information:
"""
if __name__ == '__main__':
DebugPrint("Script Start")
DebugPrint(
f"RUNNING AT {CURRENT_DIRECTORY} , RESOURCE_DIR : {RESOURCE_DIRECTORY}")
DebugPrint(f"ARCH : {ARCH} , NETMUXD_AVAILABLE : {NETMUXD_IS_AVAILABLE}")
main()
so will the AltServer code be fixed on a future update?
so will the AltServer code be fixed on a future update?
Yes The current state of rewriting
Tether mode : installing and refreshing works WiFi mode : installing works , refreshing having issues
Added features Select device when multi devices detect
To-Do Check update and update the script and resources
https://github.com/powenn/AltServer-Linux-PyScript Try this one @BleakFox
@powenn it doesn't work... When i run the main.py:
Not supplying ipa, running in server mode!
Running python3 command to advertise AltServer: from ctypes import *; dll = CDLL('libdns_sd.so'); sdRef = c_int(); flags = 0; interfaceIndex = 0; name = None; regtype = br'_altserver._tcp'; domain = None; host = None; port = 23948; txtLen = 17; txtRecord = b'\x10\x73\x65\x72\x76\x65\x72\x49\x44\x3D\x31\x32\x33\x34\x35\x36\x37'; ret = dll.DNSServiceRegister(byref(sdRef), flags, interfaceIndex, name, regtype, domain, host, port, txtLen, txtRecord, None, None); print('DNSServiceRegister result: %d' % ret); from threading import Event; Event().wait();
*** WARNING *** The program 'python3.10' uses the Apple Bonjour compatibility layer of Avahi.
*** WARNING *** Please fix your application to use the native API of Avahi!
*** WARNING *** For more information see <http://0pointer.de/blog/projects/avahi-compat.html>
DNSServiceRegister result: -65548
Starting netmuxd
Starting mDNS discovery for _apple-mobdev2._tcp.local with mdns
then if I try "i" and write my AppleID (mail) and the password of it, I get in output that AppleID or password is incorrect, but that's not true...
Pretty sure that was not code issue,please check your credential again
Or maybe try others AppleID
I tried another time, but i get back first an error that said that was impossible to install alt store on my account at the moment, and then on my iphone I have been logged out from my AppleID account and I had to reset my AppleID password because it said my account was unsafe...
That's caused by Apple policy not the script
okay so I can just try another time without any risk for my account?
I can't promise that
Hello, when I click "i" then "1" (install alt store) and then I select to use a saved Apple ID account, the code in output is that:
The same thing happens when I try to DON'T use a saved Apple ID account, but the error code is the same... please can anyone help me? I'm already using the last version of the code in ubuntu 22.04 terminal, and the last Alt Store release in IOS..