-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
8 changed files
with
348 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
import dis, os, sys, re | ||
reportfile = open('report.txt','w') | ||
reportfile.write('# Report generated from KryptDis\n') | ||
imports = [] | ||
links = [] | ||
if 'pyarmor_runtime' in dir(): reportfile.write('# PyArmor detected!\n') | ||
for objectName in dir(): | ||
if objectName in ['__annotations__', '__builtins__', '__doc__', '__loader__', '__name__', '__package__', '__spec__', '__cached__', '__file__', 'imports', 'links', 'reportfile']: continue | ||
objectCall = eval(objectName) | ||
if type(objectCall).__name__ == 'module': imports.append(objectName); continue | ||
if re.match(r'(http|https|ftp)\://([a-zA-Z0-9\-\.]+\.+[a-zA-Z]{2,3})(:[a-zA-Z0-9]*)?/?([a-zA-Z0-9\-\._\?\,\'/\\\+&%\$#\=~@]*)',str(objectCall)): links.append(str(objectCall)) | ||
elif type(objectCall).__name__ == 'type': | ||
for objectName2 in dir(objectCall): | ||
if objectName2 in ['__class__', '__delattr__', '__dict__', '__dir__', '__doc__', '__eq__', '__format__', '__ge__', '__getattribute__', '__gt__', '__hash__', '__init__', '__init_subclass__', '__le__', '__lt__', '__module__', '__ne__', '__new__', '__reduce__', '__reduce_ex__', '__repr__', '__setattr__', '__sizeof__', '__str__', '__subclasshook__', '__weakref__']: continue | ||
objectCall2 = eval(objectName2) | ||
if re.match(r'(http|https|ftp)\://([a-zA-Z0-9\-\.]+\.+[a-zA-Z]{2,3})(:[a-zA-Z0-9]*)?/?([a-zA-Z0-9\-\._\?\,\'/\\\+&%\$#\=~@]*)',str(objectCall2)): links.append(str(objectCall2)) | ||
if type(objectCall2).__name__ == 'function': | ||
try: assembly = '\n'+dis.Bytecode(objectCall2).dis() | ||
except Exception: assembly = 'Error disassembling bytecode!' | ||
reportfile.write(f'Class: {objectName}\nName: {objectName2}\nType: {str(type(objectCall2).__name__).replace("type","class")}\nObject ID: {"0x{0:0{1}X}".format(id(objectCall2),16)}\nAssembly Report: {assembly}\n\n') | ||
print(f'Class: {objectName}\nName: {objectName2}\nType: {str(type(objectCall2).__name__).replace("type","class")}\nObject ID: {"0x{0:0{1}X}".format(id(objectCall2),16)}\nAssembly Report: {assembly}\n\n') | ||
else: | ||
reportfile.write(f'Class: {objectName}\nName: {objectName2}\nType: {str(type(objectCall2).__name__).replace("type","class")}\nObject ID: {"0x{0:0{1}X}".format(id(objectCall2),16)}\nContent: {str(objectCall2)}\n\n') | ||
print(f'Class: {objectName}\nName: {objectName2}\nType: {str(type(objectCall2).__name__).replace("type","class")}\nObject ID: {"0x{0:0{1}X}".format(id(objectCall2),16)}\nContent: {str(objectCall2)}\n\n') | ||
if type(objectCall).__name__ == 'function': | ||
try: assembly = '\n'+dis.Bytecode(objectCall).dis() | ||
except Exception: assembly = 'Error disassembling bytecode!' | ||
reportfile.write(f'Class: Main\nName: {objectName}\nType: {str(type(objectCall).__name__).replace("type","class")}\nObject ID: {"0x{0:0{1}X}".format(id(objectCall),16)}\nAssembly Report: {assembly}\n\n') | ||
print(f'Class: Main\nName: {objectName}\nType: {str(type(objectCall).__name__).replace("type","class")}\nObject ID: {"0x{0:0{1}X}".format(id(objectCall),16)}\nAssembly Report: {assembly}\n\n') | ||
else: | ||
reportfile.write(f'Class: Main\nName: {objectName}\nType: {str(type(objectCall).__name__).replace("type","class")}\nObject ID: {"0x{0:0{1}X}".format(id(objectCall),16)}\nContent: {str(objectCall)}\n\n') | ||
print(f'Class: Main\nName: {objectName}\nType: {str(type(objectCall).__name__).replace("type","class")}\nObject ID: {"0x{0:0{1}X}".format(id(objectCall),16)}\nContent: {str(objectCall)}\n\n') | ||
reportfile.write(f'Imports: {", ".join(imports)}\nLinks: {", ".join(links)}\n') | ||
print(f'Imports: {", ".join(imports)}\nURLs: {", ".join(links)}\n') | ||
reportfile.close() | ||
os.system('start report.txt') | ||
sys.exit() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
|
||
Microsoft Visual Studio Solution File, Format Version 12.00 | ||
# Visual Studio Version 16 | ||
VisualStudioVersion = 16.0.30804.86 | ||
MinimumVisualStudioVersion = 10.0.40219.1 | ||
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "KryptDis", "KryptDis\KryptDis.vcxproj", "{4D024869-0E7E-4751-A378-7E3EF2CCDE6E}" | ||
EndProject | ||
Global | ||
GlobalSection(SolutionConfigurationPlatforms) = preSolution | ||
Debug|x64 = Debug|x64 | ||
Debug|x86 = Debug|x86 | ||
Release|x64 = Release|x64 | ||
Release|x86 = Release|x86 | ||
EndGlobalSection | ||
GlobalSection(ProjectConfigurationPlatforms) = postSolution | ||
{4D024869-0E7E-4751-A378-7E3EF2CCDE6E}.Debug|x64.ActiveCfg = Debug|x64 | ||
{4D024869-0E7E-4751-A378-7E3EF2CCDE6E}.Debug|x64.Build.0 = Debug|x64 | ||
{4D024869-0E7E-4751-A378-7E3EF2CCDE6E}.Debug|x86.ActiveCfg = Debug|Win32 | ||
{4D024869-0E7E-4751-A378-7E3EF2CCDE6E}.Debug|x86.Build.0 = Debug|Win32 | ||
{4D024869-0E7E-4751-A378-7E3EF2CCDE6E}.Release|x64.ActiveCfg = Release|x64 | ||
{4D024869-0E7E-4751-A378-7E3EF2CCDE6E}.Release|x64.Build.0 = Release|x64 | ||
{4D024869-0E7E-4751-A378-7E3EF2CCDE6E}.Release|x86.ActiveCfg = Release|Win32 | ||
{4D024869-0E7E-4751-A378-7E3EF2CCDE6E}.Release|x86.Build.0 = Release|Win32 | ||
EndGlobalSection | ||
GlobalSection(SolutionProperties) = preSolution | ||
HideSolutionNode = FALSE | ||
EndGlobalSection | ||
GlobalSection(ExtensibilityGlobals) = postSolution | ||
SolutionGuid = {E979A8A0-9AA6-40D3-8ACF-57E82AC12716} | ||
EndGlobalSection | ||
EndGlobal |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,164 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> | ||
<ItemGroup Label="ProjectConfigurations"> | ||
<ProjectConfiguration Include="Debug|Win32"> | ||
<Configuration>Debug</Configuration> | ||
<Platform>Win32</Platform> | ||
</ProjectConfiguration> | ||
<ProjectConfiguration Include="Release|Win32"> | ||
<Configuration>Release</Configuration> | ||
<Platform>Win32</Platform> | ||
</ProjectConfiguration> | ||
<ProjectConfiguration Include="Debug|x64"> | ||
<Configuration>Debug</Configuration> | ||
<Platform>x64</Platform> | ||
</ProjectConfiguration> | ||
<ProjectConfiguration Include="Release|x64"> | ||
<Configuration>Release</Configuration> | ||
<Platform>x64</Platform> | ||
</ProjectConfiguration> | ||
</ItemGroup> | ||
<PropertyGroup Label="Globals"> | ||
<VCProjectVersion>16.0</VCProjectVersion> | ||
<Keyword>Win32Proj</Keyword> | ||
<ProjectGuid>{4d024869-0e7e-4751-a378-7e3ef2ccde6e}</ProjectGuid> | ||
<RootNamespace>KryptDis</RootNamespace> | ||
<WindowsTargetPlatformVersion>10.0</WindowsTargetPlatformVersion> | ||
<ProjectName>KryptDis</ProjectName> | ||
</PropertyGroup> | ||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" /> | ||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration"> | ||
<ConfigurationType>DynamicLibrary</ConfigurationType> | ||
<UseDebugLibraries>true</UseDebugLibraries> | ||
<PlatformToolset>v143</PlatformToolset> | ||
<CharacterSet>Unicode</CharacterSet> | ||
</PropertyGroup> | ||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration"> | ||
<ConfigurationType>DynamicLibrary</ConfigurationType> | ||
<UseDebugLibraries>false</UseDebugLibraries> | ||
<PlatformToolset>v143</PlatformToolset> | ||
<WholeProgramOptimization>true</WholeProgramOptimization> | ||
<CharacterSet>Unicode</CharacterSet> | ||
</PropertyGroup> | ||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="Configuration"> | ||
<ConfigurationType>DynamicLibrary</ConfigurationType> | ||
<UseDebugLibraries>true</UseDebugLibraries> | ||
<PlatformToolset>v143</PlatformToolset> | ||
<CharacterSet>Unicode</CharacterSet> | ||
</PropertyGroup> | ||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="Configuration"> | ||
<ConfigurationType>DynamicLibrary</ConfigurationType> | ||
<UseDebugLibraries>false</UseDebugLibraries> | ||
<PlatformToolset>v143</PlatformToolset> | ||
<WholeProgramOptimization>true</WholeProgramOptimization> | ||
<CharacterSet>Unicode</CharacterSet> | ||
</PropertyGroup> | ||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" /> | ||
<ImportGroup Label="ExtensionSettings"> | ||
</ImportGroup> | ||
<ImportGroup Label="Shared"> | ||
</ImportGroup> | ||
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'"> | ||
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" /> | ||
</ImportGroup> | ||
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|Win32'"> | ||
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" /> | ||
</ImportGroup> | ||
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|x64'"> | ||
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" /> | ||
</ImportGroup> | ||
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|x64'"> | ||
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" /> | ||
</ImportGroup> | ||
<PropertyGroup Label="UserMacros" /> | ||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'"> | ||
<LinkIncremental>true</LinkIncremental> | ||
</PropertyGroup> | ||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'"> | ||
<LinkIncremental>false</LinkIncremental> | ||
</PropertyGroup> | ||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'"> | ||
<LinkIncremental>true</LinkIncremental> | ||
</PropertyGroup> | ||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'"> | ||
<LinkIncremental>false</LinkIncremental> | ||
</PropertyGroup> | ||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'"> | ||
<ClCompile> | ||
<WarningLevel>Level3</WarningLevel> | ||
<SDLCheck>true</SDLCheck> | ||
<PreprocessorDefinitions>WIN32;_DEBUG;PYINJECTOR_EXPORTS;_WINDOWS;_USRDLL;%(PreprocessorDefinitions)</PreprocessorDefinitions> | ||
<ConformanceMode>true</ConformanceMode> | ||
<PrecompiledHeader>NotUsing</PrecompiledHeader> | ||
<PrecompiledHeaderFile>pch.h</PrecompiledHeaderFile> | ||
</ClCompile> | ||
<Link> | ||
<SubSystem>Windows</SubSystem> | ||
<GenerateDebugInformation>true</GenerateDebugInformation> | ||
<EnableUAC>false</EnableUAC> | ||
</Link> | ||
</ItemDefinitionGroup> | ||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'"> | ||
<ClCompile> | ||
<WarningLevel>Level3</WarningLevel> | ||
<FunctionLevelLinking>true</FunctionLevelLinking> | ||
<IntrinsicFunctions>true</IntrinsicFunctions> | ||
<SDLCheck>true</SDLCheck> | ||
<PreprocessorDefinitions>WIN32;NDEBUG;PYINJECTOR_EXPORTS;_WINDOWS;_USRDLL;%(PreprocessorDefinitions)</PreprocessorDefinitions> | ||
<ConformanceMode>true</ConformanceMode> | ||
<PrecompiledHeader>NotUsing</PrecompiledHeader> | ||
<PrecompiledHeaderFile>pch.h</PrecompiledHeaderFile> | ||
</ClCompile> | ||
<Link> | ||
<SubSystem>Windows</SubSystem> | ||
<EnableCOMDATFolding>true</EnableCOMDATFolding> | ||
<OptimizeReferences>true</OptimizeReferences> | ||
<GenerateDebugInformation>true</GenerateDebugInformation> | ||
<EnableUAC>false</EnableUAC> | ||
</Link> | ||
</ItemDefinitionGroup> | ||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'"> | ||
<ClCompile> | ||
<WarningLevel>Level3</WarningLevel> | ||
<SDLCheck>true</SDLCheck> | ||
<PreprocessorDefinitions>_DEBUG;PYINJECTOR_EXPORTS;_WINDOWS;_USRDLL;%(PreprocessorDefinitions)</PreprocessorDefinitions> | ||
<ConformanceMode>true</ConformanceMode> | ||
<PrecompiledHeader>NotUsing</PrecompiledHeader> | ||
<PrecompiledHeaderFile>pch.h</PrecompiledHeaderFile> | ||
</ClCompile> | ||
<Link> | ||
<SubSystem>Windows</SubSystem> | ||
<GenerateDebugInformation>true</GenerateDebugInformation> | ||
<EnableUAC>false</EnableUAC> | ||
</Link> | ||
</ItemDefinitionGroup> | ||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'"> | ||
<ClCompile> | ||
<WarningLevel>Level3</WarningLevel> | ||
<FunctionLevelLinking>true</FunctionLevelLinking> | ||
<IntrinsicFunctions>true</IntrinsicFunctions> | ||
<SDLCheck>true</SDLCheck> | ||
<PreprocessorDefinitions>NDEBUG;PYINJECTOR_EXPORTS;_WINDOWS;_USRDLL;%(PreprocessorDefinitions)</PreprocessorDefinitions> | ||
<ConformanceMode>true</ConformanceMode> | ||
<PrecompiledHeader>NotUsing</PrecompiledHeader> | ||
<PrecompiledHeaderFile>pch.h</PrecompiledHeaderFile> | ||
</ClCompile> | ||
<Link> | ||
<SubSystem>Windows</SubSystem> | ||
<EnableCOMDATFolding>true</EnableCOMDATFolding> | ||
<OptimizeReferences>true</OptimizeReferences> | ||
<GenerateDebugInformation>true</GenerateDebugInformation> | ||
<EnableUAC>false</EnableUAC> | ||
</Link> | ||
</ItemDefinitionGroup> | ||
<ItemGroup> | ||
<ClCompile Include="dllmain.cpp" /> | ||
<ClCompile Include="SDK.cpp" /> | ||
</ItemGroup> | ||
<ItemGroup> | ||
<ClInclude Include="SDK.h" /> | ||
</ItemGroup> | ||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" /> | ||
<ImportGroup Label="ExtensionTargets"> | ||
</ImportGroup> | ||
</Project> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> | ||
<ItemGroup> | ||
<Filter Include="Source"> | ||
<UniqueIdentifier>{4FC737F1-C7A5-4376-A066-2A32D752A2FF}</UniqueIdentifier> | ||
<Extensions>cpp;c;cc;cxx;c++;cppm;ixx;def;odl;idl;hpj;bat;asm;asmx</Extensions> | ||
</Filter> | ||
</ItemGroup> | ||
<ItemGroup> | ||
<ClCompile Include="dllmain.cpp"> | ||
<Filter>Source</Filter> | ||
</ClCompile> | ||
<ClCompile Include="SDK.cpp"> | ||
<Filter>Source</Filter> | ||
</ClCompile> | ||
</ItemGroup> | ||
<ItemGroup> | ||
<ClInclude Include="SDK.h"> | ||
<Filter>Source</Filter> | ||
</ClInclude> | ||
</ItemGroup> | ||
</Project> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<Project ToolsVersion="Current" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> | ||
<PropertyGroup /> | ||
</Project> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
#include "SDK.h" | ||
|
||
_Py_SetProgramName Py_SetProgramName; | ||
_PyEval_InitThreads PyEval_InitThreads; | ||
_PyGILState_Ensure PyGILState_Ensure; | ||
_PyGILState_Release PyGILState_Release; | ||
_PyRun_SimpleStringFlags PyRun_SimpleStringFlags; | ||
|
||
void SDK::InitCPython() | ||
{ | ||
HMODULE hPython = 0x0; | ||
if (GetModuleHandleA("Python39.dll")) | ||
hPython = GetModuleHandleA("Python39.dll"); | ||
else if (GetModuleHandleA("Python38.dll")) | ||
hPython = GetModuleHandleA("Python38.dll"); | ||
else if (GetModuleHandleA("Python37.dll")) | ||
hPython = GetModuleHandleA("Python37.dll"); | ||
Py_SetProgramName = (_Py_SetProgramName)(GetProcAddress(hPython, "Py_SetProgramName")); | ||
PyEval_InitThreads = (_PyEval_InitThreads)(GetProcAddress(hPython, "PyEval_InitThreads")); | ||
PyGILState_Ensure = (_PyGILState_Ensure)(GetProcAddress(hPython, "PyGILState_Ensure")); | ||
PyGILState_Release = (_PyGILState_Release)(GetProcAddress(hPython, "PyGILState_Release")); | ||
PyRun_SimpleStringFlags = (_PyRun_SimpleStringFlags)(GetProcAddress(hPython, "PyRun_SimpleStringFlags")); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
#pragma once | ||
#include <iostream> | ||
#include <Windows.h> | ||
#include <fstream> | ||
|
||
class SDK | ||
{ | ||
public: | ||
void InitCPython(); | ||
}; | ||
|
||
typedef | ||
enum { PyGILState_LOCKED, PyGILState_UNLOCKED } | ||
PyGILState_STATE; | ||
|
||
typedef struct { | ||
int cf_flags; /* bitmask of CO_xxx flags relevant to future */ | ||
int cf_feature_version; /* minor Python version (PyCF_ONLY_AST) */ | ||
} PyCompilerFlags; | ||
|
||
#define PyRun_SimpleString(s) PyRun_SimpleStringFlags(s, NULL) | ||
|
||
typedef void(__stdcall* _Py_SetProgramName)(const wchar_t*); | ||
typedef void(__stdcall* _PyEval_InitThreads)(); | ||
typedef PyGILState_STATE(__stdcall* _PyGILState_Ensure)(); | ||
typedef void(__stdcall* _PyGILState_Release)(PyGILState_STATE); | ||
typedef int(__stdcall* _PyRun_SimpleStringFlags)(const char*, PyCompilerFlags*); | ||
|
||
extern _Py_SetProgramName Py_SetProgramName; | ||
extern _PyEval_InitThreads PyEval_InitThreads; | ||
extern _PyGILState_Ensure PyGILState_Ensure; | ||
extern _PyGILState_Release PyGILState_Release; | ||
extern _PyRun_SimpleStringFlags PyRun_SimpleStringFlags; |
Oops, something went wrong.