From 6a4a26c68fd24cfcbd7fe967947a4bdaddd09f50 Mon Sep 17 00:00:00 2001 From: rev1si0n Date: Mon, 15 Jan 2024 02:23:26 +0800 Subject: [PATCH] 7.28 auto-commit --- CHANGELOG.txt | 6 +++ lamda/__init__.py | 2 +- lamda/client.py | 17 ++++++-- lamda/rpc/application.proto | 84 ++++++++++++++++++------------------- lamda/rpc/policy.proto | 8 ++-- lamda/rpc/proxy.proto | 49 +++++++++++----------- lamda/rpc/services.proto | 1 + lamda/rpc/settings.proto | 6 +-- lamda/rpc/shell.proto | 20 ++++----- lamda/rpc/status.proto | 82 ++++++++++++++++++------------------ lamda/rpc/types.proto | 8 ++-- lamda/rpc/util.proto | 16 +++++-- lamda/rpc/wifi.proto | 80 +++++++++++++++++------------------ setup.py | 2 +- 14 files changed, 205 insertions(+), 176 deletions(-) diff --git a/CHANGELOG.txt b/CHANGELOG.txt index 5af6ec2..8765bed 100644 --- a/CHANGELOG.txt +++ b/CHANGELOG.txt @@ -1,3 +1,9 @@ +7.28 +* 新增 show_toast 接口 +* 内置代理现已支持代理 DNS 流量 +* startmitm 现已支持 DNS 通过上游代理 +* 修复安卓 10+ frida spwan + 7.25 * 修复定时任务运行失败的问题 * 修复从 termux 启动失败的问题 diff --git a/lamda/__init__.py b/lamda/__init__.py index a57b830..53f22e7 100644 --- a/lamda/__init__.py +++ b/lamda/__init__.py @@ -2,4 +2,4 @@ # # Distributed under MIT license. # See file LICENSE for detail or copy at https://opensource.org/licenses/MIT -__version__ = "7.25" +__version__ = "7.28" diff --git a/lamda/client.py b/lamda/client.py index daca46e..043b0d2 100644 --- a/lamda/client.py +++ b/lamda/client.py @@ -47,8 +47,11 @@ from . exceptions import UnHandledException, DuplicateEntryError, InvalidArgumentError from . import exceptions +handler = logging.StreamHandler() logger = logging.getLogger("lamda.client") -FORMAT = "%(asctime)s %(process)d %(levelname)7s@%(module)s:%(funcName)s - %(message)s" +formatter = logging.Formatter("%(asctime)s %(process)d %(levelname)7s@%(module)s:%(funcName)s - %(message)s") +handler.setFormatter(formatter) +logger.addHandler(handler) sys.path.append(joinpath(dirname(__file__))) sys.path.append(joinpath(dirname(__file__), "rpc")) @@ -183,6 +186,7 @@ def corner(b, position): OpenVPNKeyDirection = protos.OpenVPNKeyDirection OpenVPNCipher = protos.OpenVPNCipher OpenVPNProto = protos.OpenVPNProto +ToastDuration = protos.ToastDuration Orientation = protos.Orientation # proxy request alias @@ -1269,6 +1273,13 @@ def beep(self): """ r = self.stub.beepBeep(protos.Empty()) return r.value + def show_toast(self, text, duration=ToastDuration.TD_SHORT): + """ + 在系统界面底部显示一个 Toast 消息 + """ + req = protos.ShowToastRequest(text=text, duration=duration) + r = self.stub.showToast(req) + return r.value def setprop(self, name, value): """ 设置系统属性(aka: setprop,支持设置 ro.xx 只读属性) @@ -1888,6 +1899,8 @@ def record_touch(self): return self.stub("Util").record_touch() def perform_touch(self, sequence, wait=True): return self.stub("Util").perform_touch(sequence, wait=wait) + def show_toast(self, text, duration=ToastDuration.TD_SHORT): + return self.stub("Util").show_toast(text, duration=duration) def is_ca_certificate_installed(self, certdata): return self.stub("Util").is_ca_certificate_installed(certdata) def uninstall_ca_certificate(self, certfile): @@ -2022,8 +2035,6 @@ def device_info(self): def __call__(self, **kwargs): return self.stub("UiAutomator")(**kwargs) # 日志打印 - def setup_log_format(self): - logging.basicConfig(format=FORMAT) def set_debug_log_enabled(self, enable): level = logging.DEBUG if enable else logging.WARN logger.setLevel(level) diff --git a/lamda/rpc/application.proto b/lamda/rpc/application.proto index 17ad194..d6b008d 100644 --- a/lamda/rpc/application.proto +++ b/lamda/rpc/application.proto @@ -14,70 +14,70 @@ enum GrantType { } message ApplicationRequest { - string name = 1; - string permission = 2; - GrantType mode = 3; - string path = 4; + string name = 1; + string permission = 2; + GrantType mode = 3; + string path = 4; } message ApplicationActivityRequest { - string package = 1; - string action = 2; - string category = 3; - string component = 4; - google.protobuf.Struct extras = 5; - repeated string categories = 6; - int64 flags = 7; - bool debug = 8; - string data = 9; + string package = 1; + string action = 2; + string category = 3; + string component = 4; + google.protobuf.Struct extras = 5; + repeated string categories = 6; + int64 flags = 7; + bool debug = 8; + string data = 9; } message ApplicationActivityInfo { - string package = 1; - string action = 2; - string category = 3; - string component = 4; - google.protobuf.Struct extras = 5; - repeated string categories = 6; - int64 flags = 7; - bool debug = 8; - string data = 9; + string package = 1; + string action = 2; + string category = 3; + string component = 4; + google.protobuf.Struct extras = 5; + repeated string categories = 6; + int64 flags = 7; + bool debug = 8; + string data = 9; } message ApplicationActivityInfoList { - repeated ApplicationActivityInfo activities = 1; + repeated ApplicationActivityInfo activities = 1; } message ApplicationPermissions { - repeated string permissions = 1; + repeated string permissions = 1; } message ApplicationInfo { - string packageName = 1; - uint32 uid = 2; - bool enabled = 3; - string processName = 4; - string sourceDir = 5; - string dataDir = 6; - uint32 baseRevisionCode = 7; - int64 firstInstallTime = 8; - int64 lastUpdateTime = 9; - uint32 versionCode = 10; - string versionName = 11; - string activity = 12; + string packageName = 1; + uint32 uid = 2; + bool enabled = 3; + string processName = 4; + string sourceDir = 5; + string dataDir = 6; + uint32 baseRevisionCode = 7; + int64 firstInstallTime = 8; + int64 lastUpdateTime = 9; + uint32 versionCode = 10; + string versionName = 11; + string activity = 12; } message ApplicationProcess { - repeated string packages = 1; - string processName = 2; - int64 uid = 3; - int64 pid = 4; + repeated string packages = 1; + string processName = 2; + int64 uid = 3; + int64 pid = 4; } message ApplicationProcesses { - repeated ApplicationProcess processes = 1; + repeated ApplicationProcess processes = 1; } message ApplicationPkgNames { - repeated string names = 1; + repeated string names = 1; } diff --git a/lamda/rpc/policy.proto b/lamda/rpc/policy.proto index 192f073..1627143 100644 --- a/lamda/rpc/policy.proto +++ b/lamda/rpc/policy.proto @@ -6,8 +6,8 @@ syntax = "proto3"; package lamda.rpc; message SelinuxPolicyRequest { - string source = 1; - string target = 2; - string tclass = 3; - string action = 4; + string source = 1; + string target = 2; + string tclass = 3; + string action = 4; } \ No newline at end of file diff --git a/lamda/rpc/proxy.proto b/lamda/rpc/proxy.proto index e4dc89a..a3c03bd 100644 --- a/lamda/rpc/proxy.proto +++ b/lamda/rpc/proxy.proto @@ -14,16 +14,17 @@ enum GproxyType { } message GproxyConfigRequest { - ApplicationInfo application = 1; - GproxyType type = 2; - string nameserver = 3; - string login = 4; - string password = 5; - string host = 6; - uint32 port = 7; - bool bypass_local_subnet = 8; - bool drop_udp = 9; - bool udp_proxy = 10; + ApplicationInfo application = 1; + GproxyType type = 2; + string nameserver = 3; + string login = 4; + string password = 5; + string host = 6; + uint32 port = 7; + bool bypass_local_subnet = 8; + bool drop_udp = 9; + bool udp_proxy = 10; + bool dns_proxy = 11; } enum OpenVPNProto { @@ -70,18 +71,18 @@ enum OpenVPNEncryption { } message OpenVPNConfigRequest { - bool all_traffic = 1; - OpenVPNProto proto = 2; - string host = 3; - uint32 port = 4; - OpenVPNCipher cipher = 5; - string ca = 6; - string cert = 7; - string key = 8; - OpenVPNEncryption tls_encryption = 9; - OpenVPNKeyDirection tls_key_direction = 10; - string tls_key = 11; - OpenVPNAuth auth = 12; - string login = 13; - string password = 14; + bool all_traffic = 1; + OpenVPNProto proto = 2; + string host = 3; + uint32 port = 4; + OpenVPNCipher cipher = 5; + string ca = 6; + string cert = 7; + string key = 8; + OpenVPNEncryption tls_encryption = 9; + OpenVPNKeyDirection tls_key_direction = 10; + string tls_key = 11; + OpenVPNAuth auth = 12; + string login = 13; + string password = 14; } diff --git a/lamda/rpc/services.proto b/lamda/rpc/services.proto index 963c6f2..3a2837b 100644 --- a/lamda/rpc/services.proto +++ b/lamda/rpc/services.proto @@ -222,6 +222,7 @@ service Util { rpc installCACertificate(CertifiRequest) returns (Boolean) {} rpc uninstallCACertificate(CertifiRequest) returns (Boolean) {} rpc shutdown(google.protobuf.Empty) returns (Boolean) {} + rpc showToast(ShowToastRequest) returns (Boolean) {} rpc reload(Boolean) returns (Boolean) {} rpc exit(google.protobuf.Empty) returns (Boolean) {} rpc setProp(SetPropRequest) returns (Boolean) {} diff --git a/lamda/rpc/settings.proto b/lamda/rpc/settings.proto index a78baa2..8d9f9e1 100644 --- a/lamda/rpc/settings.proto +++ b/lamda/rpc/settings.proto @@ -12,7 +12,7 @@ enum Group { } message SettingsRequest { - Group group = 1; - string name = 2; - string value = 3; + Group group = 1; + string name = 2; + string value = 3; } diff --git a/lamda/rpc/shell.proto b/lamda/rpc/shell.proto index 18d624a..978796d 100644 --- a/lamda/rpc/shell.proto +++ b/lamda/rpc/shell.proto @@ -6,20 +6,20 @@ syntax = "proto3"; package lamda.rpc; message ShellRequest { - string tid = 1; - string name = 2; - string script = 3; - int32 timeout = 4; + string tid = 1; + string name = 2; + string script = 3; + int32 timeout = 4; } message ShellResult { - int32 exitstatus = 1; - bytes stdout = 2; - bytes stderr = 3; + int32 exitstatus = 1; + bytes stdout = 2; + bytes stderr = 3; } message ShellTask { - string tid = 1; - string name = 2; - int32 pid = 3; + string tid = 1; + string name = 2; + int32 pid = 3; } \ No newline at end of file diff --git a/lamda/rpc/status.proto b/lamda/rpc/status.proto index f2d7b14..57678aa 100644 --- a/lamda/rpc/status.proto +++ b/lamda/rpc/status.proto @@ -6,60 +6,60 @@ syntax = "proto3"; package lamda.rpc; message BatteryInfo { - bool batt_charging = 1; - int32 batt_percent = 2; - float batt_temperature = 3; + bool batt_charging = 1; + int32 batt_percent = 2; + float batt_temperature = 3; } message CpuInfo { - float cpu_percent = 1; - int32 cpu_count = 2; - float cpu_freq_current = 3; - float cpu_freq_max = 4; - float cpu_freq_min = 5; - float cpu_times_user = 6; - float cpu_times_system = 7; - float cpu_times_idle = 8; + float cpu_percent = 1; + int32 cpu_count = 2; + float cpu_freq_current = 3; + float cpu_freq_max = 4; + float cpu_freq_min = 5; + float cpu_times_user = 6; + float cpu_times_system = 7; + float cpu_times_idle = 8; } message DiskUsage { - int64 disk_total = 1; - int64 disk_used = 2; - int64 disk_free = 3; - float disk_percent = 4; + int64 disk_total = 1; + int64 disk_used = 2; + int64 disk_free = 3; + float disk_percent = 4; } message DiskIOInfo { - int64 disk_io_read_bytes = 1; - int64 disk_io_read_count = 2; - int64 disk_io_write_bytes = 3; - int64 disk_io_write_count = 4; - int64 disk_io_read_time = 5; - int64 disk_io_write_time = 6; - int64 disk_io_busy_time = 7; + int64 disk_io_read_bytes = 1; + int64 disk_io_read_count = 2; + int64 disk_io_write_bytes = 3; + int64 disk_io_write_count = 4; + int64 disk_io_read_time = 5; + int64 disk_io_write_time = 6; + int64 disk_io_busy_time = 7; } message NetIOInfo { - int64 net_io_bytes_sent = 1; - int64 net_io_packets_sent = 2; - int64 net_io_bytes_recv = 3; - int64 net_io_packets_recv = 4; - int64 net_io_dropin = 5; - int64 net_io_dropout = 6; - int64 net_io_errin = 7; - int64 net_io_errout = 8; + int64 net_io_bytes_sent = 1; + int64 net_io_packets_sent = 2; + int64 net_io_bytes_recv = 3; + int64 net_io_packets_recv = 4; + int64 net_io_dropin = 5; + int64 net_io_dropout = 6; + int64 net_io_errin = 7; + int64 net_io_errout = 8; } message MemInfo { - int64 mem_total = 1; - int64 mem_available = 2; - float mem_percent = 3; - int64 mem_used = 4; - int64 mem_free = 5; - int64 mem_active = 6; - int64 mem_inactive = 7; - int64 mem_buffers = 8; - int64 mem_cached = 9; - int64 mem_shared = 10; - int64 mem_slab = 11; + int64 mem_total = 1; + int64 mem_available = 2; + float mem_percent = 3; + int64 mem_used = 4; + int64 mem_free = 5; + int64 mem_active = 6; + int64 mem_inactive = 7; + int64 mem_buffers = 8; + int64 mem_cached = 9; + int64 mem_shared = 10; + int64 mem_slab = 11; } diff --git a/lamda/rpc/types.proto b/lamda/rpc/types.proto index 8d560a5..9c56392 100644 --- a/lamda/rpc/types.proto +++ b/lamda/rpc/types.proto @@ -6,19 +6,19 @@ syntax = "proto3"; package lamda.rpc; message Boolean { - bool value = 1; + bool value = 1; } message Integer { - int64 value = 1; + int64 value = 1; } message String { - string value = 1; + string value = 1; } message Bytes { - bytes value = 1; + bytes value = 1; } message Empty { diff --git a/lamda/rpc/util.proto b/lamda/rpc/util.proto index c285a9f..cb142ad 100644 --- a/lamda/rpc/util.proto +++ b/lamda/rpc/util.proto @@ -5,6 +5,11 @@ syntax = "proto3"; package lamda.rpc; +enum ToastDuration { + TD_SHORT = 0; + TD_LONG = 1; +} + message TouchDown { int32 tid = 1; int32 x = 2; @@ -46,10 +51,15 @@ message PerformTouchRequest { } message SetPropRequest { - string name = 1; - string value = 2; + string name = 1; + string value = 2; } message CertifiRequest { - bytes cert = 1; + bytes cert = 1; +} + +message ShowToastRequest { + string text = 1; + ToastDuration duration = 2; } diff --git a/lamda/rpc/wifi.proto b/lamda/rpc/wifi.proto index 23acacc..422ae17 100644 --- a/lamda/rpc/wifi.proto +++ b/lamda/rpc/wifi.proto @@ -6,68 +6,68 @@ syntax = "proto3"; package lamda.rpc; message WifiStatus { - string id = 1; - string address = 2; - string bssid = 3; - string freq = 4; - string group_cipher = 5; - string ip_address = 6; - string key_mgmt = 7; - string mode = 8; - string pairwise_cipher = 9; - string ssid = 10; - string wifi_generation = 11; - string wpa_state = 12; + string id = 1; + string address = 2; + string bssid = 3; + string freq = 4; + string group_cipher = 5; + string ip_address = 6; + string key_mgmt = 7; + string mode = 8; + string pairwise_cipher = 9; + string ssid = 10; + string wifi_generation = 11; + string wpa_state = 12; } message SignalPoll { - string RSSI = 1; - string LINKSPEED = 2; - string NOISE = 3; - string FREQUENCY = 4; - string WIDTH = 5; - string AVG_RSSI = 6; - string AVG_BEACON_RSSI = 7; - string CENTER_FRQ1 = 8; + string RSSI = 1; + string LINKSPEED = 2; + string NOISE = 3; + string FREQUENCY = 4; + string WIDTH = 5; + string AVG_RSSI = 6; + string AVG_BEACON_RSSI = 7; + string CENTER_FRQ1 = 8; } message WifiInfo { - string id = 1; - string bssid = 2; - string ssid = 3; - string freq = 4; - string noise = 5; - string level = 6; - string tsf = 7; - string flags = 8; + string id = 1; + string bssid = 2; + string ssid = 3; + string freq = 4; + string noise = 5; + string level = 6; + string tsf = 7; + string flags = 8; } message ScanResult { - repeated WifiInfo stations = 1; + repeated WifiInfo stations = 1; } message Network { - int32 nid = 1; - string bssid = 2; - string ssid = 3; - string flags = 4; + int32 nid = 1; + string bssid = 2; + string ssid = 3; + string flags = 4; } message NetworkList { - repeated Network networks = 1; + repeated Network networks = 1; } message NetworkConfig { - Network network = 1; - string name = 2; - string value = 3; + Network network = 1; + string name = 2; + string value = 3; } message WifiConfig { - string name = 1; - string value = 2; + string name = 1; + string value = 2; } message WifiBlacklist { - repeated string bssids = 1; + repeated string bssids = 1; } \ No newline at end of file diff --git a/setup.py b/setup.py index 01cfccf..2b42c99 100644 --- a/setup.py +++ b/setup.py @@ -20,7 +20,7 @@ }, install_requires= [ "grpcio-tools>=1.35.0,<1.60.0", - "grpc-interceptor>=0.13.0,<0.15.0", + "grpc-interceptor>=0.13.0,<=0.15.2", "grpcio>=1.35.0,<1.60.0", "cryptography>=35.0.0", "msgpack>=1.0.0",