網站首頁 編程語言 正文
LyScript是一款x64dbg主動化操控插件,經過Python操控X64dbg,完成了遠程動態調試,解決了逆向工作者剖析漏洞,尋覓指令片段,原生腳本不行強壯的問題,經過與Python相結合使用Python語法的靈活性以及豐富的第三方庫,進步剖析功率,完成主動化剖析代碼。
python包請裝置與插件一致的版別,在cmd命令行下履行pip命令即可裝置。
裝置Python包:pipinstallLyScript32或者pipinstallLyScript64
其次你需求手動下載對應x64dbg版別的驅動文件,并放入指定目錄下。
插件下載好以后,請將該插件復制到x64dbg目錄下的plugins目錄下,程序運轉后會主動加載插件文件。
當插件加載成功后,會在日志方位看到具體的綁定信息以及輸出調試,該插件并不會在插件欄顯示。
假如需求遠程調試,則只需求在初始化MyDebug()類是傳入對端IP地址即可,假如不填寫參數則默認使用127.0.0.1地址,請保證對端放行了6589端口,不然無法銜接。
運轉x64dbg程序并手動載入需求剖析的可履行文件,然后我們能夠經過connect()方法銜接到調試器,銜接后會創建一個持久會話直到python腳本完畢則銜接會被強制斷開,在此期間可調用is_connect()查看該鏈接是否還存在,具體代碼如下所示。
fromLyScript32importMyDebugif__name__==”__main__”:#初始化dbg=MyDebug()#銜接到調試器
connect_flag=dbg.connect()print(“銜接狀況:{}”.format(connect_flag))#檢測套接字是否還在
???????ref=dbg.is_connect()print(“是否在銜接:”,ref)dbg.close()
LyScript插件默認沒有批量載入功能,導致用戶只能手動將被調試進程拖入到x64dbg中才可以調試,使用python模擬快捷鍵即可解決這個問題,具體使用代碼如下。
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()
原文鏈接:https://www.cnblogs.com/LyShark/p/16505096.html
相關推薦
- 2022-08-20 python程序的打包分發示例詳解_python
- 2022-08-16 C語言詳細分析浮點數在內存中的儲存_C 語言
- 2021-12-11 由redux到react-redux再到rematch
- 2022-07-14 C#把dll分別放在指定的文件夾的方法步驟_C#教程
- 2023-08-15 類對象數組抽取對象指定屬性重新組成新的類對象數組
- 2022-10-14 基于docker容器的gitlab遷移與數據恢復
- 2022-12-02 React函數式組件Hook中的useState函數的詳細解析_React
- 2022-09-03 Python標準庫time使用方式詳解_python
- 最近更新
-
- window11 系統安裝 yarn
- 超詳細win安裝深度學習環境2025年最新版(
- Linux 中運行的top命令 怎么退出?
- MySQL 中decimal 的用法? 存儲小
- get 、set 、toString 方法的使
- @Resource和 @Autowired注解
- Java基礎操作-- 運算符,流程控制 Flo
- 1. Int 和Integer 的區別,Jav
- spring @retryable不生效的一種
- Spring Security之認證信息的處理
- Spring Security之認證過濾器
- Spring Security概述快速入門
- Spring Security之配置體系
- 【SpringBoot】SpringCache
- Spring Security之基于方法配置權
- redisson分布式鎖中waittime的設
- maven:解決release錯誤:Artif
- restTemplate使用總結
- Spring Security之安全異常處理
- MybatisPlus優雅實現加密?
- Spring ioc容器與Bean的生命周期。
- 【探索SpringCloud】服務發現-Nac
- Spring Security之基于HttpR
- Redis 底層數據結構-簡單動態字符串(SD
- arthas操作spring被代理目標對象命令
- Spring中的單例模式應用詳解
- 聊聊消息隊列,發送消息的4種方式
- bootspring第三方資源配置管理
- GIT同步修改后的遠程分支