Skip to content

Commit

Permalink
7.60 auto-commit
Browse files Browse the repository at this point in the history
  • Loading branch information
rev1si0n committed Apr 6, 2024
1 parent 7465a5f commit c65c949
Show file tree
Hide file tree
Showing 7 changed files with 75 additions and 41 deletions.
5 changes: 5 additions & 0 deletions CHANGELOG.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
7.60
* 优化以图找图查找速度
* 支持在远程桌面进行区域截图
* 修复远程桌面的一些问题

7.57
* 新增特征及模板找图客户端接口
* 其他一些优化及问题修复
Expand Down
4 changes: 3 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,9 @@ LAMDA 是一个用于逆向及自动化的辅助框架,设计为减少安全
<p align="center">
<img src="image/wx.png" alt="公众号" width="234">
</p>
<p align="center"><small>关注公众号查看视频教程以及更多使用方法</small><br><small><b>知识应该是共享的,我们不会要求你为相关知识付费</b></small><br><small>文字版文档请查看<a href="https://github.com/rev1si0n/lamda/wiki">使用文档</a></small></p>
<p align="center"><small>关注公众号查看视频教程以及更多使用方法</small><br><small><b>知识应该是共享的,我们不会要求你为相关知识付费</b></small><br><br><small><a href="https://space.bilibili.com/1964784386/video">BILIBILI 同步发布</a></small><br><small>文字版文档请查看<a href="https://github.com/rev1si0n/lamda/wiki">使用文档</a></small></small>
</p>


经过超 500 台设备的稳定生产环境考验,具有近乎商业级软件的质量和稳定性,仅需 root 权限即可正常运行。具备 ARM/X86 全架构,安卓 6.0-14 的广泛兼容性,支持模拟器、真机、云手机、 WSA(Windows Subsystem for Android™️)、无头开发板以及 Redroid。提供大量可编程接口,支持界面布局检视、获取/重放系统中最近的 Activity、唤起应用的 Activity 等功能。除此之外,它支持大文件上传下载,远程桌面,以及UI自动化编程接口,点击、截图、获取界面元素、执行 shell 命令、设备状态、资源读取、系统配置、属性读写、一键中间人等,可通过 SSH 或内置 ADB 登录设备终端。具备 socks5、OpenVPN 代理并可通过接口轻松设置根证书,实现中间人攻击,以及 Frida、IDA 等工具等等,同时支持定时任务、Magisk开机自启动,你可以在任何地方通过网络连接运行着 LAMDA 设备。

Expand Down
2 changes: 1 addition & 1 deletion lamda/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@
#
# Distributed under MIT license.
# See file LICENSE for detail or copy at https://opensource.org/licenses/MIT
__version__ = "7.57"
__version__ = "7.60"
36 changes: 24 additions & 12 deletions lamda/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,8 @@
"OpenVPNAuth",
"OpenVPNEncryption",
"OpenVPNKeyDirection",
"FindImageMethod",
"FindImageArea",
"ToastDuration",
"OpenVPNCipher",
"OpenVPNProto",
Expand Down Expand Up @@ -230,7 +232,6 @@ def corner(b, position):

TouchSequence.load = classmethod(touchSequenceLoad)
TouchSequence.save = touchSequenceSave

TouchSequence.appendAction = touchSequenceAppendAction
TouchSequence.appendDown = touchSequenceAppendDown
TouchSequence.appendWait = touchSequenceAppendWait
Expand All @@ -243,6 +244,7 @@ def corner(b, position):
Bound.height = property(height)

FindImageMethod = protos.FindImageMethod
FindImageArea = protos.FindImageArea

Bound.center = center
Bound.corner = corner
Expand Down Expand Up @@ -855,16 +857,26 @@ def get_clipboard(self):
"""
r = self.stub.getClipboard(protos.Empty())
return r.value
def find_similar_image(self, data, threshold=0,
max_distance=0, bound=None,
method=FindImageMethod.FI_TEMPLATE):
def _set_target_Area(self, req, area):
req.area = area
def _set_target_Bound(self, req, bound):
req.bound.CopyFrom(bound)
def find_similar_image(self, data, threshold=0.0, distance=250,
scale=1.0, area=FindImageArea.FIA_WHOLE_SCREEN,
method=FindImageMethod.FIM_TEMPLATE):
"""
根据提供的目标图片从屏幕中获取相似图片位置
"""
req = protos.FindImageRequest(bound=bound)
req = protos.FindImageRequest()
checkArgumentTyp(area, (Bound, int))
name = getattr(getattr(area, "DESCRIPTOR", None),
"name", "Area")
func = "_set_target_{}".format(name)
getattr(self, func)(req, area)
req.method = method
req.max_distance = max_distance
req.distance = distance
req.threshold = threshold
req.scale = scale
req.partial = data
r = self.stub.findSimilarImage(req)
return r.bounds
Expand Down Expand Up @@ -2037,11 +2049,12 @@ def wait_for_idle(self, timeout):
return self.stub("UiAutomator").wait_for_idle(timeout)
def get_last_toast(self):
return self.stub("UiAutomator").get_last_toast()
def find_similar_image(self, data, threshold=0,
max_distance=0, bound=None,
method=FindImageMethod.FI_TEMPLATE):
def find_similar_image(self, data, threshold=0.0, distance=250,
scale=1.0, area=FindImageArea.FIA_WHOLE_SCREEN,
method=FindImageMethod.FIM_TEMPLATE):
return self.stub("UiAutomator").find_similar_image(data, threshold=threshold,
max_distance=max_distance, bound=bound, method=method)
distance=distance, scale=scale,
area=area, method=method)
# watcher
def remove_all_watchers(self):
return self.stub("UiAutomator").remove_all_watchers()
Expand Down Expand Up @@ -2117,7 +2130,6 @@ def __exit__(self, type, value, traceback):
args = parser.parse_args()

readline.parse_and_bind("tab: complete")

d = Device(args.device, port=args.port,
certificate=args.cert)
certificate=args.cert)
code.interact(local=globals())
30 changes: 23 additions & 7 deletions lamda/rpc/uiautomator.proto
Original file line number Diff line number Diff line change
Expand Up @@ -556,16 +556,32 @@ message WatcherRegistRequest {
}

enum FindImageMethod {
FI_TEMPLATE = 0;
FI_FEATURE_POINT = 1;
FIM_TEMPLATE = 0;
FIM_FEATURE = 1;
}

enum FindImageArea {
FIA_WHOLE_SCREEN = 0;
FIA_LEFT = 1;
FIA_TOP_LEFT = 2;
FIA_TOP = 3;
FIA_TOP_RIGHT = 4;
FIA_RIGHT = 5;
FIA_BOTTOM_RIGHT = 6;
FIA_BOTTOM = 7;
FIA_BOTTOM_LEFT = 8;
}

message FindImageRequest {
FindImageMethod method = 1;
Bound bound = 2;
bytes partial = 3;
uint32 max_distance = 4;
float threshold = 5;
bytes partial = 1;
FindImageMethod method = 2;
oneof _area {
FindImageArea area = 3;
Bound bound = 4;
}
uint32 distance = 5;
float threshold = 6;
float scale = 7;
}

message FindImageResponse {
Expand Down
35 changes: 17 additions & 18 deletions tools/debugimage.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,27 +5,25 @@
from PIL import Image, ImageDraw
from lamda.client import *


cert = os.environ.get("CERTIFICATE", None)
port = int(os.environ.get("PORT", 65000))

parser = argparse.ArgumentParser()
parser.add_argument("-d", type=str, dest="device",
help="service ip address", required=True)
parser.add_argument("-p", type=str, dest="port",
default=port,
help="service port")
parser.add_argument("-f", "--method", type=int,
dest="method",
help="find method", default=0)
parser.add_argument("-p", "--port", type=str,
default=port, help="service port")
parser.add_argument("-f", "--method", type=str,
help="find method", default="0")
parser.add_argument("-i", "--image", type=argparse.FileType("rb"),
dest="image",
help="find image path", required=True)
parser.add_argument("-a", "--area", type=str,
help="area", default="0")
parser.add_argument("-s", "--scale", type=float,
help="scale", default=1.0)
parser.add_argument("-t", "--threshold", type=float,
dest="threshold",
help="threshold", default=0)
parser.add_argument("-m", "--max-distance", type=int,
dest="distance",
parser.add_argument("-m", "--distance", type=int,
help="max distance", default=0)
parser.add_argument("-cert", type=str, default=cert,
help="ssl cert")
Expand All @@ -34,16 +32,17 @@

d = Device(args.device, port=args.port,
certificate=args.cert)
image = Image.open(d.screenshot(60))
image = Image.open(d.screenshot(95))

draw = ImageDraw.Draw(image)
for r in d.find_similar_image(args.image.read(),
method=args.method,
max_distance=args.distance,
threshold=args.threshold):
area=eval(args.area),
method=eval(args.method),
distance=args.distance,
threshold=args.threshold,
scale=args.scale):
p1 = r.corner("top-left")
p2 = r.corner("bottom-right")
draw.rectangle(((p1.x, p1.y), (p2.x, p2.y)),
outline="red", width=3)
image.show()
exit (0)
outline="#00ff00", width=3)
image.show()
4 changes: 2 additions & 2 deletions tools/magisk/module.prop
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
id=lamda
name=LAMDA
version=7.0
versionCode=7000
version=VERSION
versionCode=VERSIONCODE
author=rev1si0n
description=Android reverse engineering & automation framework

0 comments on commit c65c949

Please sign in to comment.