欧美bbbwbbbw肥妇,免费乱码人妻系列日韩,一级黄片

Python利用LyScript插件實現(xiàn)批量打開關(guān)閉進程

 更新時間:2022年07月22日 14:23:04   作者:lyshark  
LyScript是一款x64dbg主動化操控插件,經(jīng)過Python操控X64dbg,完成了遠程動態(tài)調(diào)試,解決了逆向工作者剖析漏洞,尋覓指令片段,原生腳本不行強壯的問題。本文將利用LyScript插件實現(xiàn)批量打開關(guān)閉進程,感興趣的可以了解一下

LyScript是一款x64dbg主動化操控插件,經(jīng)過Python操控X64dbg,完成了遠程動態(tài)調(diào)試,解決了逆向工作者剖析漏洞,尋覓指令片段,原生腳本不行強壯的問題,經(jīng)過與Python相結(jié)合使用Python語法的靈活性以及豐富的第三方庫,進步剖析功率,完成主動化剖析代碼。

python包請裝置與插件一致的版別,在cmd命令行下履行pip命令即可裝置。

裝置Python包:pipinstallLyScript32或者pipinstallLyScript64

其次你需求手動下載對應(yīng)x64dbg版別的驅(qū)動文件,并放入指定目錄下。

插件下載好以后,請將該插件復(fù)制到x64dbg目錄下的plugins目錄下,程序運轉(zhuǎn)后會主動加載插件文件。

當(dāng)插件加載成功后,會在日志方位看到具體的綁定信息以及輸出調(diào)試,該插件并不會在插件欄顯示。

假如需求遠程調(diào)試,則只需求在初始化MyDebug()類是傳入對端IP地址即可,假如不填寫參數(shù)則默認使用127.0.0.1地址,請保證對端放行了6589端口,不然無法銜接。

運轉(zhuǎn)x64dbg程序并手動載入需求剖析的可履行文件,然后我們能夠經(jīng)過connect()方法銜接到調(diào)試器,銜接后會創(chuàng)建一個持久會話直到python腳本完畢則銜接會被強制斷開,在此期間可調(diào)用is_connect()查看該鏈接是否還存在,具體代碼如下所示。

fromLyScript32importMyDebugif__name__==”__main__”:#初始化dbg=MyDebug()#銜接到調(diào)試器
connect_flag=dbg.connect()print(“銜接狀況:{}”.format(connect_flag))#檢測套接字是否還在
???????ref=dbg.is_connect()print(“是否在銜接:”,ref)dbg.close()

LyScript插件默認沒有批量載入功能,導(dǎo)致用戶只能手動將被調(diào)試進程拖入到x64dbg中才可以調(diào)試,使用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()
        # 設(shè)置剪貼板內(nèi)容
        win32clipboard.SetClipboardData(win32con.CF_UNICODETEXT, path)
        # 獲取剪貼板內(nèi)容
        date = win32clipboard.GetClipboardData()
        print("[*] OpenFile = {}".format(date))
        # 關(guān)閉剪貼板
        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)

# 打開調(diào)試程序
def OpenFile(path):
    regex = ".*x32dbg.*"
    cWindows = cWindow()
    cWindows.find_window_regex(regex)
    cWindows.SetAsForegroundWindow()
    cWindows.SetAsForegroundWindow()
    cWindows.OpenFile(path)

# 關(guān)閉調(diào)試程序
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()

到此這篇關(guān)于Python利用LyScript插件實現(xiàn)批量打開關(guān)閉進程的文章就介紹到這了,更多相關(guān)Python批量打開關(guān)閉進程內(nèi)容請搜索腳本之家以前的文章或繼續(xù)瀏覽下面的相關(guān)文章希望大家以后多多支持腳本之家!

相關(guān)文章

最新評論