PE 特征码定位修改程序清单 uiAccess

requestedExecutionLevel level="asInvoker" uiAccess="false" 可以修改这一行来启用禁用原程序的盾牌图标,似乎作用不大。以前没事写的一个小玩意,记录一下。

等同于这里的设置:

截图

代码如下:

cpp 复制代码
#include <iostream>
#include <Windows.h>
#include <iomanip>
#include <fstream>
#include<cstdlib>
#include<string>

using namespace std;

char HEX[16] = { '0','1','2','3','4','5','6','7','8','9','A','B','C','D','E','F' };
void setIndex(int num, char* hexNumber)
{
	// 清空行下标
	for (int i = 0; i < 8; i++) {
		hexNumber[i] = '0';
	}

	// 设置新的行下标
	int index = 7;
	while (num != 0 && index >= 0)
	{
		hexNumber[index--] = HEX[num % 16];
		num = num / 16;
	}
}

int codeArr_kipetl_102[] = {
		0x72, 0x65, 0x71, 0x75, 0x65, 0x73, 
		0x74, 0x65, 0x64, 0x45, 0x78, 0x65, 
		0x63, 0x75, 0x74, 0x69, 0x6F, 0x6E, 
		0x4C, 0x65, 0x76, 0x65, 0x6C// requestedExecutionLevel
};
int codeCtrl_kipetl_102[] = {
		1,1,1,1,1,1,
		1,1,1,1,1,1,
		1,1,1,1,1,1,
		1,1,1,1,1
};


int inline get_PE_feature_rof(
	string path_r,			// PE 文件全路径。我这里是:"C:\\Windows\\SysNative\\ntoskrnl.exe"
	int codeArr[],			// 上面提到的第一个数组
	int codeCtrl[],			// 上面提到的第二个数组
	int len					// 数组的长度
) {
	// 打开文件
	ifstream in = ifstream(path_r, ios::binary);
	if (!in.is_open()) {
		cout << "文件打开失败:" << GetLastError() << endl;
		in.close();
		return 0;
	}

	// 获取文件大小、文件名
	long long Beg = in.tellg();
	in.seekg(0, ios::end);
	long long End = in.tellg();
	long long fileSize = End - Beg;
	in.seekg(0, ios::beg);

	// 读文件(每次循环读取 1 字节)
	int byteBeenRead = 0;				// 已经读取的字节数
	unsigned char temp;					// 存放读取内容的缓冲区				
	int rof_feature = 0;				// 特征 ROF
	int codeArrSub = 0;					// 要对比的 codeArr[] 下标
	BOOL isFound = FALSE;				// 是否找到特征
	while (in.read((char*)&temp, 1) && isFound == FALSE) {
		byteBeenRead++;
		// 读 1 字节
		int hex = (unsigned)temp;

		// 比较特征
		for (int i = 0; i < len; i++) {
			// 需要匹配
			if (codeCtrl[codeArrSub] == 1) {
				// 匹配到特征
				if (hex == codeArr[codeArrSub]) {
					codeArrSub++;
					// 匹配完成
					if (codeArrSub == len) {
						rof_feature = byteBeenRead - len;
						isFound = TRUE;
						break;
					}
					else { break; }
				}
				else { codeArrSub = 0; break; }
			}
			else { codeArrSub++; break; }
		}
	}
	//cout << "rof_feature = " << hex << rof_feature << endl;
	in.close();
	return rof_feature;
}


int main(int argc, char* argv[])
{
	// 打开文件
	string path_r = "CGnetsw.exe";
	//根据特征码定位UIAccess属性位置
	int ROF = get_PE_feature_rof(path_r, codeArr_kipetl_102, codeCtrl_kipetl_102, 23);
	cout << ROF << endl;

	fstream fs("XXXX.exe", ios::binary | ios::out | ios::in);
	//跳转到ROF位置进行写入,写入新的UIAccess属性。从而去除启动权限
	fs.seekp(ROF, ios::beg);
	//requestedExecutionLevel level="asInvoker" uiAccess="false"/>
	//0D 0A 换行
	//11个空格(0x20)
	fs.write("\x72\x65\x71\x75\x65\x73\x74\x65\x64\x45\x78\x65", 12);
	fs.write("\x63\x75\x74\x69\x6F\x6E\x4C\x65\x76\x65\x6C\x20", 12);
	fs.write("\x6C\x65\x76\x65\x6C\x3D\x22\x61\x73\x49\x6E\x76", 12);
	fs.write("\x6F\x6B\x65\x72\x22\x20\x75\x69\x41\x63\x63\x65", 12);
	fs.write("\x73\x73\x3D\x22\x66\x61\x6C\x73\x65\x22\x2F\x3E", 12);
	fs.write("\x0D\x0A\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20", 13);
	fs.close();

	cin.get();
	return 0;
}

可以搜索 requestedExecutionLevel 位置,并关闭 PE 文件的自动 UAC 请求。


发布于:2024.02.11

相关推荐
挽月0013 分钟前
C++单例模式
开发语言·c++·单例模式
机器视觉知识推荐、就业指导11 分钟前
Qt/C++ TCP调试助手V1.1 新增图像传输与接收功能(附发布版下载链接)
c++·qt·tcp/ip
wx2004110225 分钟前
Codeforces Round 973 (Div. 2) - D题
数据结构·c++·算法
DieSnowK1 小时前
[项目][WebServer][CGI机制 && 设计]详细讲解
linux·开发语言·c++·http·项目·webserver·cgi机制
空白诗2 小时前
使用 nvm 管理 node 版本:如何在 macOS 和 Windows 上安装使用nvm
windows·macos·node.js·nvm
归寻太乙2 小时前
C++函数重载完成日期类相关计算
开发语言·c++
尽蝶叙2 小时前
C++:分苹果【排列组合】
开发语言·c++·算法
憧憬成为原神糕手2 小时前
c++_list
开发语言·c++
zyh200504302 小时前
c++的decltype关键字
c++·decltype
2401_862886782 小时前
蓝禾,汤臣倍健,三七互娱,得物,顺丰,快手,游卡,oppo,康冠科技,途游游戏,埃科光电25秋招内推
前端·c++·python·算法·游戏