MCPcopy
hub / github.com/CreditTone/hooker / handle_command

Function handle_command

hooker.py:2049–2159  ·  view source on GitHub ↗
(cmd)

Source from the content-addressed store, hash-verified

2047
2048def entry_debug_mode():
2049 def handle_command(cmd):
2050 cmd = cmd.strip()
2051 if cmd.startswith("activitys") or "a" == cmd:
2052 print_activitys()
2053 return True
2054 elif cmd.startswith("services") or "s" == cmd:
2055 print_services()
2056 return True
2057 elif (cmd.startswith("object ") or cmd.startswith("o ")) and re.search(r"(object|o)\s+([^\s]+)", cmd):
2058 m = re.search(r"(object|o)\s+([^\s]+)", cmd)
2059 if m:
2060 print_object(m.group(2))
2061 return True
2062 elif (cmd.startswith("view ") or cmd.startswith("v ")) and re.search(r"(view|v)\s+([^\s]+)", cmd):
2063 m = re.search(r"(view|v)\s+([^\s]+)", cmd)
2064 if m:
2065 print_view(m.group(2))
2066 return True
2067 elif cmd == "ls":
2068 list_working_dir()
2069 classNameCompleter.update_js_files()
2070 return True
2071 elif cmd == "justtrustme" or cmd == "trust":
2072 just_trust_me()
2073 return True
2074 elif cmd.startswith("push ") and re.search(r"push\s+([^\s]+)", cmd):
2075 m = re.search(r"push\s+([^\s]+)", cmd)
2076 if m:
2077 local_file = m.group(1)
2078 m2 = re.search(r"push\s+[^\s]+\s+([^\s]+)", cmd)
2079 if m2 is not None:
2080 remote_file = m2.group(1)
2081 push_file_to_device_with_chmod(local_file, remote_file)
2082 else:
2083 push_file_to_device_with_chmod(local_file)
2084 return True
2085 elif re.search(r"webserver\s+start", cmd):
2086 m = re.search(r"webserver\s+start\s+([^\s]+\.jar)", cmd)
2087 if m:
2088 jar_file = m.group(1)
2089 start_web_server(jar_file)
2090 else:
2091 start_web_server()
2092 return True
2093 elif re.search(r"webserver\s+stop", cmd):
2094 m = re.search(r"webserver\s+stop\s+([^\d]+)", cmd)
2095 if m:
2096 port = m.group(1)
2097 stop_web_server(int(port))
2098 else:
2099 stop_web_server()
2100 return True
2101 elif cmd.startswith("viewlog") or re.search(r"viewlog\s+([^\s]+)", cmd):
2102 m = re.search(r"webserver\s+([^\s]+)", cmd)
2103 if m:
2104 device_log_file = m.group(1)
2105 if device_log_file == "webserver":
2106 tail_android_file("/sdcard/webserver.log")

Callers 1

entry_debug_modeFunction · 0.85

Calls 15

print_activitysFunction · 0.85
print_servicesFunction · 0.85
print_objectFunction · 0.85
print_viewFunction · 0.85
list_working_dirFunction · 0.85
just_trust_meFunction · 0.85
start_web_serverFunction · 0.85
stop_web_serverFunction · 0.85
tail_android_fileFunction · 0.85
r0captureFunction · 0.85
set_proxyFunction · 0.85

Tested by

no test coverage detected