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接口手册的更多相关文章

  1. ionic 访问odoo11之具体业务类api接口

    在前面测试通过odoo登录的功能,这次的问题重点是如何访问后台具体的业务类的接口呢?这次就以我们在odoo中安装的lunch模块为例,目标是获取lunch.alert的数据,如下图 具体过程接上次文章 ...

  2. onps栈使用说明(1)——API接口手册

    1. 底层API 由协议栈底层提供的api,用于涉及底层操作的一些功能实现,这些api接口函数的原型定义分布于不同的文件,它们被统一include进了onps.h中: open_npstack_loa ...

  3. eaccelerator 完全手册:配置、控制、API接口

    安装官方有很详细的文档 转自 http://www.enjoyphp.com/2010/eaccelerator-manual/ 配置选项 eaccelerator.shm_size指定 eAccel ...

  4. openstack 安全策略权限控制等api接口

    computer API:                创建安全组 /os-security-groups 创建安全组规则 /os-security-group-default-rules Netw ...

  5. Http下的各种操作类.WebApi系列~通过HttpClient来调用Web Api接口

    1.WebApi系列~通过HttpClient来调用Web Api接口 http://www.cnblogs.com/lori/p/4045413.html HttpClient使用详解(java版本 ...

  6. Postman - 功能强大的 API 接口请求调试和管理工具

    Postman 是一款功能强大的的 Chrome 应用,可以便捷的调试接口.前端开发人员在开发或者调试 Web 程序的时候是需要一些方法来跟踪网页请求的,用户可以使用一些网络的监视工具比如著名的 Fi ...

  7. Java8新特性(三)——Optional类、接口方法与新时间日期API

    一.Optional容器类 这是一个可以为null的容器对象.如果值存在则isPresent()方法会返回true,调用get()方法会返回该对象. 查看结构图可以看到有如下常用方法: of(T)—— ...

  8. C# 请求Web Api 接口,返回的json数据直接反序列化为实体类

    须要的引用的dll类: Newtonsoft.Json.dll.System.Net.Http.dll.System.Net.Http.Formatting.dll Web Api接口为GET形式: ...

  9. PC端写的API接口和手机端APP联合调试

    一.遇到问题的情况:项目框架:asp.net MVC5 ,写的给手机端调用的API接口. 二.自己在本地 IIS上部署项目,在手机端的请求服务器上把地址和端口换上本地部署的,如图所示 三.用管理员的身 ...

  10. Google地图接口API之Google地图 API 参考手册(七)

    Google 地图API 参考手册 地图 构造函数/对象 描述 Map() 在指定的 HTML 容器中创建新的地图,该容器通常是一个DIV元素. 叠加层 构造函数/对象 描述 Marker 创建一个标 ...

随机推荐

  1. BBS项目(二):首页导航条搭建 修改密码功能 首页数据展示 个人站点页面

    目录 首页导航条搭建 session判断用户是否登录 更换验证码 导航条更多功能 退出系统 修改密码前端页面 使用大模态框 编写模态框 前端表单编写 修改密码后端逻辑 接受参数 验证参数 修改密码 首 ...

  2. 【计算机网络】身份认证Oauth2

    身份认证Oauth2 https://www.bilibili.com/video/BV1FL411h7es/?spm_id_from=333.999.0.0&vd_source=d11276 ...

  3. 【每日一题】36. 小AA的数列 (二进制DP)

    补题链接:Here 算法涉及:位运算,DP 这道题想了很久但实在没想什么巧妙的解法,暴力的代码就不放,这里引用Kur1su 的思路 异或问题优先考虑二进制位,对于这个问题,我们需要考虑偶数长度的区间, ...

  4. 与奥运同行:打造智慧体育馆 3D 可视化

    祝贺中国队在东京奥运会夺得金牌 38 枚.银牌 32 枚.铜牌 18 枚.中国健儿在奥运舞台上交出了一份璀璨的成绩单.用一场场精彩绝伦的比赛,演绎"更快.更高.更强.更团结"的奥林 ...

  5. mvn 编译异常:Fatal error compiling: 无效的标记: -parameters

    错误信息: [ERROR] Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin::compile (defaul ...

  6. 14-Verilog for Verification

    Verilog for Verification 1.引言 Testbench也是一个模块(module...endmodule) Testbench没有输入和输出,因为它是一个闭环,自己产生激励,灌 ...

  7. 【C++】在搞touchgfx时遇见了一个初始化列表顺序与类中定义不一致的问题,error:when initialized here [-Werror=reorder]

    在搞touchgfx时遇见了一个初始化列表顺序与类中定义不一致的问题,error:when initialized here [-Werror=reorder] 初始化列表顺序与类中定义顺序不一致错误 ...

  8. Android——SQLiteOpenHelper

    使用步骤: 新建一个继承自SQLiteOpenHelper的数据库操作类,提示重写onCreate和OnUpgraed两个方法.其中,onCreate方法只在第一次打开数据库时执行,在此可进行表结构创 ...

  9. 百度网盘(百度云)SVIP超级会员共享账号每日更新(2023.12.11)

    一.百度网盘SVIP超级会员共享账号 可能很多人不懂这个共享账号是什么意思,小编在这里给大家做一下解答. 我们多知道百度网盘很大的用处就是类似U盘,不同的人把文件上传到百度网盘,别人可以直接下载,避免 ...

  10. 百度网盘(百度云)SVIP超级会员共享账号每日更新(2023.11.25)

    来给大家伙送福利了! 一.百度网盘SVIP超级会员共享账号 可能很多人不懂这个共享账号是什么意思,小编在这里给大家做一下解答. 我们多知道百度网盘很大的用处就是类似U盘,不同的人把文件上传到百度网盘, ...