Skip to content

Commit df31286

Browse files
authoredDec 17, 2022
SOURCE CODE
1 parent 9b0e1e6 commit df31286

7 files changed

+453
-0
lines changed
 

‎PythonObfuscator.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 17
4+
VisualStudioVersion = 17.5.33103.201
5+
MinimumVisualStudioVersion = 10.0.40219.1
6+
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "PythonObfuscator", "PythonObfuscator\PythonObfuscator.vcxproj", "{96C504AB-6DB3-4DFB-AE06-3592DF77D740}"
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+
{96C504AB-6DB3-4DFB-AE06-3592DF77D740}.Debug|x64.ActiveCfg = Debug|x64
17+
{96C504AB-6DB3-4DFB-AE06-3592DF77D740}.Debug|x64.Build.0 = Debug|x64
18+
{96C504AB-6DB3-4DFB-AE06-3592DF77D740}.Debug|x86.ActiveCfg = Debug|Win32
19+
{96C504AB-6DB3-4DFB-AE06-3592DF77D740}.Debug|x86.Build.0 = Debug|Win32
20+
{96C504AB-6DB3-4DFB-AE06-3592DF77D740}.Release|x64.ActiveCfg = Release|x64
21+
{96C504AB-6DB3-4DFB-AE06-3592DF77D740}.Release|x64.Build.0 = Release|x64
22+
{96C504AB-6DB3-4DFB-AE06-3592DF77D740}.Release|x86.ActiveCfg = Release|Win32
23+
{96C504AB-6DB3-4DFB-AE06-3592DF77D740}.Release|x86.Build.0 = Release|Win32
24+
EndGlobalSection
25+
GlobalSection(SolutionProperties) = preSolution
26+
HideSolutionNode = FALSE
27+
EndGlobalSection
28+
GlobalSection(ExtensibilityGlobals) = postSolution
29+
SolutionGuid = {8BB1FAC4-DE1C-491F-BBE4-878F2850573F}
30+
EndGlobalSection
31+
EndGlobal

‎PythonObfuscator/Base64.h

+120
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,120 @@
1+
#ifndef _MACARON_BASE64_H_
2+
#define _MACARON_BASE64_H_
3+
4+
/**
5+
* The MIT License (MIT)
6+
* Copyright (c) 2016 tomykaira
7+
*
8+
* Permission is hereby granted, free of charge, to any person obtaining
9+
* a copy of this software and associated documentation files (the
10+
* "Software"), to deal in the Software without restriction, including
11+
* without limitation the rights to use, copy, modify, merge, publish,
12+
* distribute, sublicense, and/or sell copies of the Software, and to
13+
* permit persons to whom the Software is furnished to do so, subject to
14+
* the following conditions:
15+
*
16+
* The above copyright notice and this permission notice shall be
17+
* included in all copies or substantial portions of the Software.
18+
*
19+
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
20+
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
21+
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
22+
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
23+
* LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
24+
* OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
25+
* WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
26+
*/
27+
28+
#include <string>
29+
30+
class Base64 {
31+
public:
32+
33+
static std::string Encode(const std::string data) {
34+
static constexpr char sEncodingTable[] = {
35+
'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H',
36+
'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P',
37+
'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X',
38+
'Y', 'Z', 'a', 'b', 'c', 'd', 'e', 'f',
39+
'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n',
40+
'o', 'p', 'q', 'r', 's', 't', 'u', 'v',
41+
'w', 'x', 'y', 'z', '0', '1', '2', '3',
42+
'4', '5', '6', '7', '8', '9', '+', '/'
43+
};
44+
45+
size_t in_len = data.size();
46+
size_t out_len = 4 * ((in_len + 2) / 3);
47+
std::string ret(out_len, '\0');
48+
size_t i;
49+
char* p = const_cast<char*>(ret.c_str());
50+
51+
for (i = 0; i < in_len - 2; i += 3) {
52+
*p++ = sEncodingTable[(data[i] >> 2) & 0x3F];
53+
*p++ = sEncodingTable[((data[i] & 0x3) << 4) | ((int)(data[i + 1] & 0xF0) >> 4)];
54+
*p++ = sEncodingTable[((data[i + 1] & 0xF) << 2) | ((int)(data[i + 2] & 0xC0) >> 6)];
55+
*p++ = sEncodingTable[data[i + 2] & 0x3F];
56+
}
57+
if (i < in_len) {
58+
*p++ = sEncodingTable[(data[i] >> 2) & 0x3F];
59+
if (i == (in_len - 1)) {
60+
*p++ = sEncodingTable[((data[i] & 0x3) << 4)];
61+
*p++ = '=';
62+
}
63+
else {
64+
*p++ = sEncodingTable[((data[i] & 0x3) << 4) | ((int)(data[i + 1] & 0xF0) >> 4)];
65+
*p++ = sEncodingTable[((data[i + 1] & 0xF) << 2)];
66+
}
67+
*p++ = '=';
68+
}
69+
70+
return ret;
71+
}
72+
73+
static std::string Decode(const std::string& input, std::string& out) {
74+
static constexpr unsigned char kDecodingTable[] = {
75+
64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64,
76+
64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64,
77+
64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 62, 64, 64, 64, 63,
78+
52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 64, 64, 64, 64, 64, 64,
79+
64, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14,
80+
15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 64, 64, 64, 64, 64,
81+
64, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40,
82+
41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 64, 64, 64, 64, 64,
83+
64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64,
84+
64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64,
85+
64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64,
86+
64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64,
87+
64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64,
88+
64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64,
89+
64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64,
90+
64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64
91+
};
92+
93+
size_t in_len = input.size();
94+
if (in_len % 4 != 0) return "Input data size is not a multiple of 4";
95+
96+
size_t out_len = in_len / 4 * 3;
97+
if (input[in_len - 1] == '=') out_len--;
98+
if (input[in_len - 2] == '=') out_len--;
99+
100+
out.resize(out_len);
101+
102+
for (size_t i = 0, j = 0; i < in_len;) {
103+
uint32_t a = input[i] == '=' ? 0 & i++ : kDecodingTable[static_cast<int>(input[i++])];
104+
uint32_t b = input[i] == '=' ? 0 & i++ : kDecodingTable[static_cast<int>(input[i++])];
105+
uint32_t c = input[i] == '=' ? 0 & i++ : kDecodingTable[static_cast<int>(input[i++])];
106+
uint32_t d = input[i] == '=' ? 0 & i++ : kDecodingTable[static_cast<int>(input[i++])];
107+
108+
uint32_t triple = (a << 3 * 6) + (b << 2 * 6) + (c << 1 * 6) + (d << 0 * 6);
109+
110+
if (j < out_len) out[j++] = (triple >> 2 * 8) & 0xFF;
111+
if (j < out_len) out[j++] = (triple >> 1 * 8) & 0xFF;
112+
if (j < out_len) out[j++] = (triple >> 0 * 8) & 0xFF;
113+
}
114+
115+
return "";
116+
}
117+
118+
};
119+
120+
#endif /* _MACARON_BASE64_H_ */

‎PythonObfuscator/PythonObfuscator.cpp

+92
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,92 @@
1+
#include <ctime>
2+
#include <format>
3+
#include <fstream>
4+
#include <iostream>
5+
#include <stdio.h>
6+
#include <string>
7+
8+
#include "Base64.h"
9+
#include "Utils.h"
10+
11+
using namespace std;
12+
13+
Base64 b64 = Base64();
14+
Utils utils = Utils();
15+
16+
string templateOutput = R"(
17+
import base64, codecs
18+
magic = 'part1'
19+
love = 'part2'
20+
god = 'part3'
21+
destiny = 'part4'
22+
joy = '\x72\x6f\x74\x31\x33'
23+
trust = eval('\x6d\x61\x67\x69\x63') + eval('\x63\x6f\x64\x65\x63\x73\x2e\x64\x65\x63\x6f\x64\x65\x28\x6c\x6f\x76\x65\x2c\x20\x6a\x6f\x79\x29') + eval('\x67\x6f\x64') + eval('\x63\x6f\x64\x65\x63\x73\x2e\x64\x65\x63\x6f\x64\x65\x28\x64\x65\x73\x74\x69\x6e\x79\x2c\x20\x6a\x6f\x79\x29')
24+
)";
25+
std::string normalTemplateOutput = R"(eval(compile(base64.b64decode(eval('\x74\x72\x75\x73\x74')),'<string>','exec')))";
26+
std::string hexTemplateOutput = R"(eval(compile(base64.b64decode(eval('\x74\x72\x75\x73\x74')),'\x3c\x73\x74\x72\x69\x6e\x67\x3e','\x65\x78\x65\x63')))";
27+
28+
string filePath;
29+
string mode;
30+
bool correctMode = false;
31+
ifstream file;
32+
ofstream outputFile;
33+
34+
int main()
35+
{
36+
//Need a valid file
37+
while (!utils.doesFileExist(filePath)) {
38+
std::cout << "Python File Path: ";
39+
std::getline(std::cin, filePath);
40+
system("cls");
41+
}
42+
while (!correctMode) {
43+
std::cout << "Mode(a = Normal / b = Hex): ";
44+
std::cin >> mode;
45+
46+
if (mode == "a") {
47+
templateOutput.append(normalTemplateOutput);
48+
correctMode = true;
49+
}
50+
else if (mode == "b") {
51+
templateOutput.append(hexTemplateOutput);
52+
correctMode = true;
53+
}
54+
55+
system("cls");
56+
}
57+
58+
//Open the file
59+
file.open(filePath);
60+
61+
//Iterate through the content
62+
std::string fileContent((std::istreambuf_iterator<char>(file)), std::istreambuf_iterator<char>());
63+
64+
//Base64 encode the contnet
65+
fileContent = b64.Encode(fileContent);
66+
67+
//Lenght divided by 4 to split
68+
int newLength = fileContent.length() / 4;
69+
70+
//Part 1
71+
utils.replace_all(templateOutput, "part1", fileContent.substr(0, newLength));
72+
73+
//Part 2 (Rot13)
74+
utils.replace_all(templateOutput, "part2", utils.rot13(fileContent.substr(newLength, newLength)));
75+
76+
//Part 4
77+
utils.replace_all(templateOutput, "part3", fileContent.substr(newLength*2, newLength));
78+
79+
//Part 4 (Rot13)
80+
utils.replace_all(templateOutput, "part4", utils.rot13(fileContent.substr(newLength * 3, newLength)));
81+
82+
//Watermark
83+
templateOutput = "#Obfuscated By https://github.com/TheObfuscators/Python_Obfuscator1 (https://development-tools.net/python-obfuscator parody)\n" + templateOutput;
84+
85+
//Output Path
86+
utils.replace_all(filePath, ".py", "-j0k3.py");
87+
88+
//Finished
89+
outputFile.open(filePath, ofstream::binary);
90+
outputFile.write(templateOutput.c_str(), templateOutput.length());
91+
outputFile.close();
92+
}
+140
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,140 @@
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>{96c504ab-6db3-4dfb-ae06-3592df77d740}</ProjectGuid>
25+
<RootNamespace>PythonObfuscator</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>v143</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>v143</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+
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
74+
<ClCompile>
75+
<WarningLevel>Level3</WarningLevel>
76+
<SDLCheck>true</SDLCheck>
77+
<PreprocessorDefinitions>WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
78+
<ConformanceMode>true</ConformanceMode>
79+
</ClCompile>
80+
<Link>
81+
<SubSystem>Console</SubSystem>
82+
<GenerateDebugInformation>true</GenerateDebugInformation>
83+
</Link>
84+
</ItemDefinitionGroup>
85+
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
86+
<ClCompile>
87+
<WarningLevel>Level3</WarningLevel>
88+
<FunctionLevelLinking>true</FunctionLevelLinking>
89+
<IntrinsicFunctions>true</IntrinsicFunctions>
90+
<SDLCheck>true</SDLCheck>
91+
<PreprocessorDefinitions>WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
92+
<ConformanceMode>true</ConformanceMode>
93+
<LanguageStandard>stdcpplatest</LanguageStandard>
94+
</ClCompile>
95+
<Link>
96+
<SubSystem>Console</SubSystem>
97+
<EnableCOMDATFolding>true</EnableCOMDATFolding>
98+
<OptimizeReferences>true</OptimizeReferences>
99+
<GenerateDebugInformation>true</GenerateDebugInformation>
100+
</Link>
101+
</ItemDefinitionGroup>
102+
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
103+
<ClCompile>
104+
<WarningLevel>Level3</WarningLevel>
105+
<SDLCheck>true</SDLCheck>
106+
<PreprocessorDefinitions>_DEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
107+
<ConformanceMode>true</ConformanceMode>
108+
</ClCompile>
109+
<Link>
110+
<SubSystem>Console</SubSystem>
111+
<GenerateDebugInformation>true</GenerateDebugInformation>
112+
</Link>
113+
</ItemDefinitionGroup>
114+
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
115+
<ClCompile>
116+
<WarningLevel>Level3</WarningLevel>
117+
<FunctionLevelLinking>true</FunctionLevelLinking>
118+
<IntrinsicFunctions>true</IntrinsicFunctions>
119+
<SDLCheck>true</SDLCheck>
120+
<PreprocessorDefinitions>NDEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
121+
<ConformanceMode>true</ConformanceMode>
122+
</ClCompile>
123+
<Link>
124+
<SubSystem>Console</SubSystem>
125+
<EnableCOMDATFolding>true</EnableCOMDATFolding>
126+
<OptimizeReferences>true</OptimizeReferences>
127+
<GenerateDebugInformation>true</GenerateDebugInformation>
128+
</Link>
129+
</ItemDefinitionGroup>
130+
<ItemGroup>
131+
<ClCompile Include="PythonObfuscator.cpp" />
132+
</ItemGroup>
133+
<ItemGroup>
134+
<ClInclude Include="Base64.h" />
135+
<ClInclude Include="Utils.h" />
136+
</ItemGroup>
137+
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
138+
<ImportGroup Label="ExtensionTargets">
139+
</ImportGroup>
140+
</Project>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
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="Source Files">
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="Header Files">
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="Resource Files">
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="PythonObfuscator.cpp">
19+
<Filter>Source Files</Filter>
20+
</ClCompile>
21+
</ItemGroup>
22+
<ItemGroup>
23+
<ClInclude Include="Base64.h">
24+
<Filter>Header Files</Filter>
25+
</ClInclude>
26+
<ClInclude Include="Utils.h">
27+
<Filter>Header Files</Filter>
28+
</ClInclude>
29+
</ItemGroup>
30+
</Project>
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>

‎PythonObfuscator/Utils.h

+36
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
#include <string>
2+
#include <vector>
3+
4+
class Utils {
5+
public:
6+
inline bool doesFileExist(const std::string& name) {
7+
struct stat buffer;
8+
return (stat(name.c_str(), &buffer) == 0);
9+
}
10+
11+
inline void replace_all(std::string& data, std::string to_search, std::string replace_str) {
12+
13+
size_t pos = data.find(to_search);
14+
15+
while (pos != std::string::npos) {
16+
data.replace(pos, to_search.size(), replace_str);
17+
pos = data.find(to_search, pos + replace_str.size());
18+
}
19+
}
20+
21+
inline std::string rot13(std::string input) {
22+
23+
for (std::string::size_type len = input.length(), idx = 0; idx != len; ++idx) {
24+
if (input[idx] >= 'a' && input[idx] <= 'm')
25+
input[idx] = input[idx] + 13;
26+
else if (input[idx] >= 'n' && input[idx] <= 'z')
27+
input[idx] = input[idx] - 13;
28+
else if (input[idx] >= 'A' && input[idx] <= 'M')
29+
input[idx] = input[idx] + 13;
30+
else if (input[idx] >= 'N' && input[idx] <= 'Z')
31+
input[idx] = input[idx] - 13;
32+
}
33+
34+
return input;
35+
}
36+
};

0 commit comments

Comments
 (0)
Please sign in to comment.