Pe 花指令添加器

原由

既然要写个Xor的壳子,要往里面添加指令,写个加花器,很简单,2天左右搞完,还是使用我个人的LibPe库。

使用方法

Usage: PaninoRecode.exe (file name) offset “code”
示例: PaninoRecode.exe test.exe 1000 "ab ab c2 d3 "

源码

#include <stdio.h>
#include <Windows.h>
#include <winnt.h>
#include <iostream>
#include <string>
#include "LibPeH.h"

using namespace std;

int main(int prmNbr, char* prmArr[])
{

	//Usage: PaninoRecode.exe (file name) offset "code" 
	char* flNm;
	flNm = new char[0x100];

	DWORD ofst;

	string cdStr;

	char* cdRd, * cd;

	cdRd = (char*)malloc(0x100);
	memset(cdRd, 0, sizeof(cdRd));

	cd = (char*)malloc(0x500);
	memset(cd, 0, sizeof(cd));

	if (prmNbr != 4)
	{
		printf(">>> [文件名]:");

		scanf("%s",flNm);

		/*cout << string(">>> [偏移]:");*/
		printf(">>> [偏移]:");

		scanf("%x", &ofst);

		printf(">>> [指令]:");

		getline(cin, cdStr);
		getline(cin, cdStr);


	}
	else
	{
		strcpy(flNm, prmArr[1]);
		ofst = strtol(prmArr[2], NULL, 16);
		strcpy(cdRd, prmArr[3]);

		cdStr = string(cdRd);

		printf(">>> [文件名]:%s\n",flNm);
		printf(">>> [偏移]:%x\n",ofst );
	}

	struct PeStrc pe=getStrc(flNm);

	//转化指令

	char tbl[] = "0123456789ABCDEFabcdefg";

	int ptr=0;

	for (int i = 0; i < cdStr.size(); i++)
	{
		if (strchr(tbl, cdStr[i]))
		{
			cd[ptr] = cdStr[i];
			ptr++;
		}
	}

	cd[ptr] = '\0';

	if (strlen(cd) % 2 == 1)
	{
		cd[ptr++] = '0';
		cd[ptr] = '\0';
	}

	//转换成byte数组

	int sz = strlen(cd)/2;

	byte* bytArr = new byte[0x500];

	char* strTmp;

	strTmp = new char[0x10];

	for (int i = 0; i < strlen(cd); i+=2)
	{

		strncpy(strTmp, cd + i, 2);
		strTmp[2] = '\0';

		bytArr[i / 2] = strtol(strTmp,NULL,16);
	}


	//如果使用命令行传入参数的方式,则输出指令
	if (prmNbr == 4)
	{
		printf(">>> [指令]:");

		for (int i = 0; i < sz; i++)
		{
			printf("%02x", bytArr[i]);
		}

		printf("\n");
	}

	//写入数据

	byte* bff;

	bff = getBffFromStrc(pe);

	bffOvrwrt(bff, ofst, bytArr, sz);

	bffGnrt((char*)(string("New_") + string(flNm)).c_str(), bff, pe.flSz);


	printf(">>> 修改完成.\n");

}
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

YoseZang

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值