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 win32apiimport win32gui, win32conimport win32clipboardimport reimport timefrom LyScript32 import MyDebugclass 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 Noneif __name__ == "__main__": dbg = MyDebug() dbg.connect() # 批量打開一個列表 for item in ["D:Win32Project.exe","D:Windows ToolsC32ASMc32asm.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()
到此這篇關于Python利用LyScript插件實現批量打開關閉進程得內容就介紹到這了,更多相關Python批量打開關閉進程內容請搜索之家以前得內容或繼續瀏覽下面得相關內容希望大家以后多多支持之家!
聲明:所有內容來自互聯網搜索結果,不保證100%準確性,僅供參考。如若本站內容侵犯了原著者的合法權益,可聯系我們進行處理。