吾爱破解 - 52pojie.cn

 找回密码
 注册[Register]

QQ登录

只需一步,快速开始

查看: 1254|回复: 0
收起左侧

[C&C++ 原创] 3环进程混淆思路

  [复制链接]
Panel 发表于 2023-12-18 17:06

一定程度上能起到点混淆作用,纯思路分享

#include <iostream>
#include <windows.h>
#include <winternl.h>

#define  FAKE_CMDLINE  L"C:\\Windows\\explorer.exe"
#define  FAKE_PATH L"C:\\Windows\\explorer.exe"

typedef NTSTATUS
(*MyNtQueryInformationProcess)(
    IN HANDLE ProcessHandle,
    IN PROCESSINFOCLASS ProcessInformationClass,
    OUT PVOID ProcessInformation,
    IN ULONG ProcessInformationLength,
    OUT PULONG ReturnLength OPTIONAL
);

int main()
{
    PPEB pebProcess = { 0 };
    PROCESS_BASIC_INFORMATION pbiProcess = { 0 };
    HANDLE hProcess = 0;
    ULONG Infolen = 1024;
    ULONG Retlen = 0;
    NTSTATUS status = 0;
    HMODULE hNtdll = 0;
    UNICODE_STRING unCmdline;
    UINT64 fakepid = 4;
    ULONG fakesession = 0;
    MyNtQueryInformationProcess ntQueryProcess = NULL;

    hNtdll = LoadLibraryA("ntdll.dll");

    if (hNtdll<=0)
    {
        return 0;
    }

    ntQueryProcess = (MyNtQueryInformationProcess)GetProcAddress(hNtdll, "NtQueryInformationProcess");

    if (ntQueryProcess<=0)
    {
        return 0;
    }

    hProcess = OpenProcess(PROCESS_ALL_ACCESS, FALSE, GetCurrentProcessId());

    if (!hProcess)
    {
        return 0;
    }

    status = ntQueryProcess(hProcess, ProcessBasicInformation, &pbiProcess, sizeof(PROCESS_BASIC_INFORMATION), &Retlen);

    if (!NT_SUCCESS(status))
    {
        return 0;
    }

    if (pbiProcess.PebBaseAddress == NULL)
    {
        return 0;
    }

    pebProcess = pbiProcess.PebBaseAddress;

    //修改cmdline
    RtlZeroMemory((pebProcess->ProcessParameters->CommandLine).Buffer, wcslen((pebProcess->ProcessParameters->CommandLine).Buffer) * 2);

    RtlCopyMemory((pebProcess->ProcessParameters->CommandLine).Buffer, FAKE_CMDLINE,wcslen(FAKE_CMDLINE)*2);

    //修改路径
    RtlZeroMemory((pebProcess->ProcessParameters->ImagePathName).Buffer, wcslen((pebProcess->ProcessParameters->ImagePathName).Buffer) * 2);

    RtlCopyMemory((pebProcess->ProcessParameters->ImagePathName).Buffer, FAKE_PATH, wcslen(FAKE_PATH) * 2);

    //修改进程id
    RtlCopyMemory(&(pbiProcess.UniqueProcessId), &fakepid, sizeof(UINT64));

    //修改会话层
    RtlCopyMemory(&(pebProcess->SessionId), &fakesession, sizeof(ULONG));

    //断链
    (pebProcess->Ldr->InMemoryOrderModuleList.Blink)->Flink = pebProcess->Ldr->InMemoryOrderModuleList.Flink;
    (pebProcess->Ldr->InMemoryOrderModuleList.Flink)->Blink = pebProcess->Ldr->InMemoryOrderModuleList.Blink;

    getchar();

}

免费评分

参与人数 6吾爱币 +12 热心值 +6 收起 理由
苏紫方璇 + 7 + 1 欢迎分析讨论交流,吾爱破解论坛有你更精彩!
笙若 + 1 + 1 谢谢@Thanks!
che_shen + 1 + 1 鼓励转贴优秀软件安全工具和文档!
mmffddyy + 1 + 1 谢谢@Thanks!
ck6102 + 1 + 1 热心回复!
Say + 1 + 1 我很赞同!

查看全部评分

发帖前要善用论坛搜索功能,那里可能会有你要找的答案或者已经有人发布过相同内容了,请勿重复发帖。

您需要登录后才可以回帖 登录 | 注册[Register]

本版积分规则

返回列表

RSS订阅|小黑屋|处罚记录|联系我们|吾爱破解 - LCG - LSG ( 京ICP备16042023号 | 京公网安备 11010502030087号 )

GMT+8, 2024-11-24 17:30

Powered by Discuz!

Copyright © 2001-2020, Tencent Cloud.

快速回复 返回顶部 返回列表