LyScriptTools 调试控制类API接口手册
LyScriptTools模块中的DebugControl类主要负责控制x64dbg调试器的行为,例如获取或设置寄存器组,执行单步命令等,此类内的方法也是最常用的。
调试类命令总结如下表所示:
| DebugControl 类内函数名 | 函数作用 |
|---|---|
| GetEAX() | 获取通用寄存器系列 |
| SetEAX(decimal_value) | 设置特定寄存器中的值(十进制) |
| GetZF() | 获取标志寄存器系列 |
| SetZF(decimal_bool) | 设置标志寄存器的值(布尔型) |
| Script_InitDebug(path) | 传入文件路径,载入被调试程序 |
| Script_CloseDebug() | 终止当前被调试进程 |
| Script_DetachDebug() | 让进程脱离当前调试器 |
| Script_RunDebug() | 让进程运行起来 |
| Script_ERun() | 释放锁并允许程序运行,忽略异常 |
| Script_SeRun() | 释放锁并允许程序运行,跳过异常中断 |
| Script_Pause() | 暂停调试器运行 |
| Script_StepInto() | 步进 |
| Script_EStepInfo() | 步进,跳过异常 |
| Script_SeStepInto() | 步进,跳过中断 |
| Script_StepOver() | 步过到结束 |
| Script_StepOut() | 普通步过F8 |
| Script_Skip() | 跳过执行 |
| Script_Inc(register) | 递增寄存器 |
| Script_Dec(register) | 递减寄存器 |
| Script_Add(register,decimal_int) | 对寄存器进行add运算 |
| Script_Sub(register,decimal_int) | 对寄存器进行sub运算 |
| Script_Mul(register,decimal_int) | 对寄存器进行mul乘法 |
| Script_Div(register,decimal_int) | 对寄存器进行div除法 |
| Script_And(register,decimal_int) | 对寄存器进行and与运算 |
| Script_Or(register,decimal_int) | 对寄存器进行or或运算 |
| Script_Xor(register,decimal_int) | 对寄存器进行xor或运算 |
| Script_Neg(register,decimal_int) | 对寄存器参数进行neg反转 |
| Script_Rol(register,decimal_int) | 对寄存器进行rol循环左移 |
| Script_Ror(register,decimal_int) | 对寄存器进行ror循环右移 |
| Script_Shl(register,decimal_int) | 对寄存器进行shl逻辑左移 |
| Script_Shr(register,decimal_int) | 对寄存器进行shr逻辑右移 |
| Script_Sal(register,decimal_int) | 对寄存器进行sal算数左移 |
| Script_Sar(register,decimal_int) | 对寄存器进行sar算数右移 |
| Script_Not(register,decimal_int) | 对寄存器进行not按位取反 |
| Script_Bswap(register,decimal_int) | 进行字节交换也就是反转 |
| Script_Push(register_or_value) | 对寄存器入栈 |
| Script_Pop(register_or_value) | 对寄存器弹出元素 |
| Pause() | 内置API暂停 |
| Run() | 内置API运行 |
| StepIn() | 内置API步入 |
| StepOut() | 内置API步过 |
| StepOut() | 内置API到结束 |
| Stop() | 内置API停止 |
| Wait() | 内置API等待 |
| IsDebug() | 判断调试器是否在调试 |
| IsRunning() | 判断调试器是否在运行 |
自动控制类主要功能如上表示,其中Script开头的API是调用的脚本命令实现,其他的是API实现,我们以批量自动载入程序为例,演示该类内函数是如何使用的。
import os
import pefile
import time
from LyScript32 import MyDebug
from LyScriptTools32 import Module
from LyScriptTools32 import Disassemble
from LyScriptTools32 import DebugControl
# 得到特定目录下的所有文件,并返回列表
def GetFullFilePaht(path):
ref = []
for root,dirs,files in os.walk(str(path)):
for index in range(0,len(files)):
ref.append(str(root + "/" + files[index]))
return ref
if __name__ == "__main__":
dbg = MyDebug()
connect_flag = dbg.connect()
print("连接状态: {}".format(connect_flag))
# 初始化调试控制器
debug = DebugControl(dbg)
# 得到特定目录下的所有文件
full_path = GetFullFilePaht("d://test/")
for i in range(0,len(full_path)):
debug.Script_InitDebug(str(full_path[i]))
time.sleep(0.3)
debug.Script_RunDebug()
time.sleep(0.3)
local_base = dbg.get_local_base()
print("当前调试进程: {} 基地址: {}".format(full_path[i],local_base))
time.sleep(0.3)
# 关闭调试
debug.Script_CloseDebug()
dbg.close()
如果你不使用Script_InitDebug来加载被调试进程,你也可以使用如下方式打开一个文件。
import win32api
import win32gui, win32con
import win32clipboard
import re
import time
from LyScript32 import MyDebug
class cWindow:
def __init__(self):
self._hwnd = None
def SetAsForegroundWindow(self):
win32gui.SetForegroundWindow(self._hwnd)
def Maximize(self):
# 最大化
win32gui.ShowWindow(self._hwnd, win32con.SW_MAXIMIZE)
def _window_enum_callback(self, hwnd, regex):
if self._hwnd is None and re.match(regex, str(win32gui.GetWindowText(hwnd))) is not None:
self._hwnd = hwnd
def find_window_regex(self, regex):
self._hwnd = None
win32gui.EnumWindows(self._window_enum_callback, regex)
def hide_always_on_top_windows(self):
win32gui.EnumWindows(self._window_enum_callback_hide, None)
def _window_enum_callback_hide(self, hwnd, unused):
if hwnd != self._hwnd:
if win32gui.IsWindowVisible(hwnd) and win32gui.GetWindowLong(hwnd, win32con.GWL_EXSTYLE) & win32con.WS_EX_TOPMOST:
className = win32gui.GetClassName(hwnd)
if not (className == 'Button' or className == 'Shell_TrayWnd'):
win32gui.ShowWindow(hwnd, win32con.SW_FORCEMINIMIZE)
def OpenFile(self,path):
# 按下F3
win32api.keybd_event(0x72, 0, 0, 0)
win32api.keybd_event(0x72, 0, win32con.KEYEVENTF_KEYUP, 0)
# 打开剪贴板
win32clipboard.OpenClipboard()
# 清空剪贴板
win32clipboard.EmptyClipboard()
# 设置剪贴板内容
win32clipboard.SetClipboardData(win32con.CF_UNICODETEXT, path)
# 获取剪贴板内容
date = win32clipboard.GetClipboardData()
print("[*] OpenFile = {}".format(date))
# 关闭剪贴板
win32clipboard.CloseClipboard()
time.sleep(0.2)
# 按下ctrl+v
win32api.keybd_event(0x11, 0, 0, 0)
win32api.keybd_event(0x56, 0, 0, 0)
win32api.keybd_event(0x56, 0, win32con.KEYEVENTF_KEYUP, 0)
win32api.keybd_event(0x11, 0, win32con.KEYEVENTF_KEYUP, 0)
# 按下回车
win32api.keybd_event(0x0D, 0, 0, 0)
win32api.keybd_event(0x0D, 0, win32con.KEYEVENTF_KEYUP, 0)
def deatch(self):
# 按下Ctrl+Alt+F2
win32api.keybd_event(0x11, 0, 0, 0)
win32api.keybd_event(0x12, 0, 0, 0)
win32api.keybd_event(0x71, 0, 0, 0)
win32api.keybd_event(0x11, 0, win32con.KEYEVENTF_KEYUP, 0)
win32api.keybd_event(0x12, 0, win32con.KEYEVENTF_KEYUP, 0)
win32api.keybd_event(0x71, 0, win32con.KEYEVENTF_KEYUP, 0)
# 打开调试程序
def OpenFile(path):
regex = ".*x32dbg.*"
cWindows = cWindow()
cWindows.find_window_regex(regex)
cWindows.SetAsForegroundWindow()
cWindows.SetAsForegroundWindow()
cWindows.OpenFile(path)
# 关闭调试程序
def DeatchFile():
regex = ".*x32dbg.*"
cWindows = cWindow()
cWindows.find_window_regex(regex)
cWindows.SetAsForegroundWindow()
cWindows.SetAsForegroundWindow()
cWindows.deatch()
# 得到脚本返回值
def GetScriptValue(dbg,script):
try:
ref = dbg.run_command_exec("push eax")
if ref != True:
return None
ref = dbg.run_command_exec(f"eax={script}")
if ref != True:
return None
reg = dbg.get_register("eax")
ref = dbg.run_command_exec("pop eax")
if ref != True:
return None
return reg
except Exception:
return None
return None
if __name__ == "__main__":
dbg = MyDebug()
dbg.connect()
# 批量打开一个列表
for item in ["D:\Win32Project.exe","D:\Windows Tools\C32ASM\c32asm.exe"]:
OpenFile(item)
time.sleep(3)
for i in range(1,100):
dbg.set_debug("StepIn")
time.sleep(0.2)
eip = dbg.get_register("eip")
print("eip = > {}".format(hex(eip)))
time.sleep(3)
DeatchFile()
LyScriptTools 调试控制类API接口手册的更多相关文章
- ionic 访问odoo11之具体业务类api接口
在前面测试通过odoo登录的功能,这次的问题重点是如何访问后台具体的业务类的接口呢?这次就以我们在odoo中安装的lunch模块为例,目标是获取lunch.alert的数据,如下图 具体过程接上次文章 ...
- onps栈使用说明(1)——API接口手册
1. 底层API 由协议栈底层提供的api,用于涉及底层操作的一些功能实现,这些api接口函数的原型定义分布于不同的文件,它们被统一include进了onps.h中: open_npstack_loa ...
- eaccelerator 完全手册:配置、控制、API接口
安装官方有很详细的文档 转自 http://www.enjoyphp.com/2010/eaccelerator-manual/ 配置选项 eaccelerator.shm_size指定 eAccel ...
- openstack 安全策略权限控制等api接口
computer API: 创建安全组 /os-security-groups 创建安全组规则 /os-security-group-default-rules Netw ...
- Http下的各种操作类.WebApi系列~通过HttpClient来调用Web Api接口
1.WebApi系列~通过HttpClient来调用Web Api接口 http://www.cnblogs.com/lori/p/4045413.html HttpClient使用详解(java版本 ...
- Postman - 功能强大的 API 接口请求调试和管理工具
Postman 是一款功能强大的的 Chrome 应用,可以便捷的调试接口.前端开发人员在开发或者调试 Web 程序的时候是需要一些方法来跟踪网页请求的,用户可以使用一些网络的监视工具比如著名的 Fi ...
- Java8新特性(三)——Optional类、接口方法与新时间日期API
一.Optional容器类 这是一个可以为null的容器对象.如果值存在则isPresent()方法会返回true,调用get()方法会返回该对象. 查看结构图可以看到有如下常用方法: of(T)—— ...
- C# 请求Web Api 接口,返回的json数据直接反序列化为实体类
须要的引用的dll类: Newtonsoft.Json.dll.System.Net.Http.dll.System.Net.Http.Formatting.dll Web Api接口为GET形式: ...
- PC端写的API接口和手机端APP联合调试
一.遇到问题的情况:项目框架:asp.net MVC5 ,写的给手机端调用的API接口. 二.自己在本地 IIS上部署项目,在手机端的请求服务器上把地址和端口换上本地部署的,如图所示 三.用管理员的身 ...
- Google地图接口API之Google地图 API 参考手册(七)
Google 地图API 参考手册 地图 构造函数/对象 描述 Map() 在指定的 HTML 容器中创建新的地图,该容器通常是一个DIV元素. 叠加层 构造函数/对象 描述 Marker 创建一个标 ...
随机推荐
- Mysql--JOIN连表查询
一.Join查询原理 MySQL内部采用了一种叫做 nested loop join(嵌套循环连接)的算法:通过驱动表的结果集作为循环基础数据,然后一条一条的通过该结果集中的数据作为过滤条件到下一个表 ...
- Eight HDU - 1043 (反向搜索 + 康拓展开 / A* + BFS / IDA* )
题目描述 简单介绍一下八数码问题: 在一个3×3的九宫格上,填有1~8八个数字,空余一个位置,例如下图: 1 2 3 4 5 6 7 8 在上图中,由于右下角位置是空的,你可以移动数字,比如可以将数字 ...
- 项目2 可视化数据(第17章 使用API)
17.1 使用Web API Web API是网站的一部分,用于与使用非常具体的URL请求特定信息的程序交互.这种请求称为API调用.请求的数据将以易于处理的格式(如JSON或CSV)返回. 17.1 ...
- TapTap 算法平台的 Serverless 探索之路
分享人:陈欣昊,TapTap/IEM/AI平台负责人 摘要:本文主要介绍心动网络算法平台在Serverless上的实践. <TapTap算法平台的 Serverless 探索之路> Ser ...
- 3D编程模式:介绍设计原则
大家好~本文介绍6个设计原则的定义 系列文章详见: 3D编程模式:开篇 目录 单一职责原则(SRP) 依赖倒置原则(DIP) 接口隔离原则(ISP) 迪米特法则(LoD) 合成复用原则(CARP) 开 ...
- notepad++的使用技巧
一.多标签管理 1.可支持多个标签的展示
- Git | git branch 分支操作
假设我们已经有了稳定的代码,现在我想整一些花活.比较安全的一个方式是,在新的分支上整活. 新建 vga 分支:git branch vga,然后切换到 vga 分支:git switch vga,或者 ...
- SV OOP-2
静态变量 继承性(Inheritance) 抽象类和虚方法virtual methods 多态(Ploymorphism) 通过基类的变量可以使用子类的对象 基类中定义的virtual functio ...
- Clock Gating Design
GPU max power distribution internal power and switch power - 动态功耗(时钟翻转) Leakage power - 漏电功耗(静态功耗,mo ...
- 26-IP调用 - PLL
1.PLL IP核简介 PLL(Phaze Locked Loop)锁相环是最常用的IP核之一,其性能强大,可以对输入到FPGA的时钟信号进行任意的分频.倍频.相位调整.占空比调整,从而输出一个期望时 ...