112 lines
3.1 KiB
Python
Executable File
112 lines
3.1 KiB
Python
Executable File
#!/usr/bin/env python3
|
|
"""
|
|
Trigger sysrq reboot, wait for fresh telnet, and verify the patched IPA module.
|
|
"""
|
|
import time
|
|
import socket
|
|
import subprocess
|
|
|
|
TARGET_IP = "172.16.42.1"
|
|
TARGET_PORT = 23
|
|
|
|
def log(msg):
|
|
print(f"[{time.strftime('%H:%M:%S')}] {msg}", flush=True)
|
|
|
|
def telnet_cmd(cmd, wait_time=2.0, verbose=True):
|
|
s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
|
|
s.settimeout(5.0)
|
|
s.connect((TARGET_IP, TARGET_PORT))
|
|
time.sleep(0.5)
|
|
try:
|
|
s.recv(4096)
|
|
except socket.timeout:
|
|
pass
|
|
if verbose:
|
|
log(f"TELNET CMD: {cmd}")
|
|
s.sendall((cmd + "\n").encode("utf-8"))
|
|
time.sleep(wait_time)
|
|
output = b""
|
|
while True:
|
|
try:
|
|
chunk = s.recv(4096)
|
|
if not chunk:
|
|
break
|
|
output += chunk
|
|
except socket.timeout:
|
|
break
|
|
s.close()
|
|
res = output.decode("utf-8", errors="replace")
|
|
if verbose:
|
|
log(f"OUTPUT:\n{res.strip()}")
|
|
return res
|
|
|
|
def main():
|
|
log("Sending sysrq b emergency reset to phone...")
|
|
try:
|
|
s = socket.socket()
|
|
s.settimeout(3.0)
|
|
s.connect((TARGET_IP, TARGET_PORT))
|
|
s.sendall(b"echo b > /proc/sysrq-trigger\n")
|
|
time.sleep(0.5)
|
|
s.close()
|
|
except Exception as e:
|
|
log(f"Reset sent ({e})")
|
|
|
|
log("Waiting for phone to reboot into fresh debug shell...")
|
|
time.sleep(5)
|
|
start = time.time()
|
|
while time.time() - start < 60:
|
|
s = socket.socket()
|
|
s.settimeout(1.0)
|
|
try:
|
|
s.connect((TARGET_IP, TARGET_PORT))
|
|
s.close()
|
|
log("Telnet port 23 is OPEN!")
|
|
time.sleep(2)
|
|
break
|
|
except Exception:
|
|
pass
|
|
time.sleep(1)
|
|
else:
|
|
raise TimeoutError("Timed out waiting for telnet")
|
|
|
|
# 1. Check uptime & uname
|
|
telnet_cmd("uname -a; uptime")
|
|
|
|
# 2. Mount eMMC and bind modules
|
|
telnet_cmd("mkdir -p /mnt && mount /dev/mmcblk1p79 /mnt && echo MOUNT_OK")
|
|
telnet_cmd("mount --bind /mnt/lib/modules /lib/modules && echo BIND_OK")
|
|
|
|
# 3. Verify sha256 of ipa.ko.zst
|
|
telnet_cmd("sha256sum /lib/modules/7.2.12-sdm660/kernel/drivers/net/ipa/ipa.ko.zst")
|
|
|
|
# 4. Modprobe IPA
|
|
log("Loading patched IPA module...")
|
|
telnet_cmd("modprobe -v ipa; dmesg | tail -n 25")
|
|
|
|
# 5. Check netdev
|
|
telnet_cmd("ip link show rmnet_ipa0")
|
|
|
|
# 6. Wait 65s for runtime suspend autosuspend test
|
|
log("Waiting 65s for autosuspend verification (testing runtime PM fix)...")
|
|
for sec in range(1, 14):
|
|
time.sleep(5)
|
|
print(f".{sec*5}s", end="", flush=True)
|
|
print()
|
|
|
|
# 7. Check dmesg for any oops or errors
|
|
log("Checking dmesg for crashes...")
|
|
res = telnet_cmd("dmesg | tail -n 35")
|
|
|
|
if "Unable to handle kernel NULL pointer dereference" in res or "Oops:" in res:
|
|
log("FAILURE: Kernel oops detected!")
|
|
return 1
|
|
|
|
log("SUCCESS: 0 crashes detected after 65s idle timeout!")
|
|
log("No crash observed in this idle window; cellular data and longer-term stability remain unverified.")
|
|
return 0
|
|
|
|
if __name__ == "__main__":
|
|
import sys
|
|
sys.exit(main())
|