├── .deepsource.toml
├── .gitattributes
├── .github
└── FUNDING.yml
├── .gitignore
├── LICENSE
├── README.md
├── VMUP
├── .editorconfig
├── VMUP.sln
├── VMUnprotect.Runtime
│ ├── General
│ │ ├── AssemblyLoader.cs
│ │ ├── CommandLineOptions.cs
│ │ ├── ContainerConfig.cs
│ │ ├── Context.cs
│ │ ├── Engine.cs
│ │ ├── ILogger.cs
│ │ └── Project.cs
│ ├── Helpers
│ │ ├── Formatter.cs
│ │ ├── Params.cs
│ │ └── StringCounts.cs
│ ├── Hooks
│ │ ├── HooksManager.cs
│ │ ├── IVmupHook.cs
│ │ ├── Methods
│ │ │ ├── AntiDebug
│ │ │ │ ├── DebugIsAttachedPatch.cs
│ │ │ │ ├── DebugIsLoggingPatch.cs
│ │ │ │ └── NtQueryInformationProcessPatch.cs
│ │ │ ├── AssemblyFix
│ │ │ │ ├── GetCallingAssemblyPatch.cs
│ │ │ │ ├── GetEntryAssemblyPatch.cs
│ │ │ │ └── GetExecutingAssemblyPatch.cs
│ │ │ ├── VmProtectDumperTranspiler.cs
│ │ │ └── VmProtectDumperUnsafeInvoke.cs
│ │ └── VmUnprotectPatch.cs
│ ├── MiddleMan
│ │ ├── TranspilerMiddleMan.cs
│ │ └── UnsafeInvokeMiddleMan.cs
│ ├── Modules
│ │ └── VmProtectPatchesModule.cs
│ ├── Properties
│ │ └── AssemblyInfo.cs
│ ├── Structure
│ │ ├── VmRuntimeAnalyzer.cs
│ │ └── VmRuntimeStructure.cs
│ ├── VMUnprotect.Runtime.csproj
│ └── packages.config
└── VMUnprotect
│ ├── FodyWeavers.xml
│ ├── FodyWeavers.xsd
│ ├── Program.cs
│ ├── Properties
│ └── AssemblyInfo.cs
│ ├── Utils
│ └── ConsoleLogger.cs
│ ├── VMUnprotect.csproj
│ ├── manifest.manifest
│ ├── packages.config
│ └── vmup.ico
└── docs
├── desktop.ini
├── gif.gif
├── screen2.png
├── show.gif
└── vmup.png
/.deepsource.toml:
--------------------------------------------------------------------------------
1 | version = 1
2 |
3 | [[analyzers]]
4 | name = "csharp"
5 | enabled = true
--------------------------------------------------------------------------------
/.gitattributes:
--------------------------------------------------------------------------------
1 | # Auto detect text files and perform LF normalization
2 | * text=auto
3 |
--------------------------------------------------------------------------------
/.github/FUNDING.yml:
--------------------------------------------------------------------------------
1 | # These are supported funding model platforms
2 |
3 | github: [void-stack] # Replace with up to 4 GitHub Sponsors-enabled usernames e.g., [user1, user2]
4 | patreon: # Replace with a single Patreon username
5 | open_collective: # Replace with a single Open Collective username
6 | ko_fi: # Replace with a single Ko-fi username
7 | tidelift: # Replace with a single Tidelift platform-name/package-name e.g., npm/babel
8 | community_bridge: # Replace with a single Community Bridge project-name e.g., cloud-foundry
9 | liberapay: # Replace with a single Liberapay username
10 | issuehunt: # Replace with a single IssueHunt username
11 | otechie: # Replace with a single Otechie username
12 | lfx_crowdfunding: # Replace with a single LFX Crowdfunding project-name e.g., cloud-foundry
13 | custom: # Replace with up to 4 custom sponsorship URLs e.g., ['link1', 'link2']
14 |
--------------------------------------------------------------------------------
/.gitignore:
--------------------------------------------------------------------------------
1 | ## Ignore Visual Studio temporary files, build results, and
2 | ## files generated by popular Visual Studio add-ons.
3 | ##
4 | ## Get latest from https://github.com/github/gitignore/blob/master/VisualStudio.gitignore
5 |
6 | # User-specific files
7 | *.rsuser
8 | *.suo
9 | *.user
10 | *.userosscache
11 | *.sln.docstates
12 |
13 | # User-specific files (MonoDevelop/Xamarin Studio)
14 | *.userprefs
15 |
16 | # Build results
17 | [Dd]ebug/
18 | [Dd]ebugPublic/
19 | [Rr]elease/
20 | [Rr]eleases/
21 | x64/
22 | x86/
23 | bld/
24 | [Bb]in/
25 | [Oo]bj/
26 | [Ll]og/
27 |
28 | # Visual Studio 2015/2017 cache/options directory
29 | .vs/
30 | # Uncomment if you have tasks that create the project's static files in wwwroot
31 | #wwwroot/
32 |
33 | # Visual Studio 2017 auto generated files
34 | Generated\ Files/
35 |
36 | # MSTest test Results
37 | [Tt]est[Rr]esult*/
38 | [Bb]uild[Ll]og.*
39 |
40 | # NUNIT
41 | *.VisualState.xml
42 | TestResult.xml
43 |
44 | # Build Results of an ATL Project
45 | [Dd]ebugPS/
46 | [Rr]eleasePS/
47 | dlldata.c
48 |
49 | # Benchmark Results
50 | BenchmarkDotNet.Artifacts/
51 |
52 | # .NET Core
53 | project.lock.json
54 | project.fragment.lock.json
55 | artifacts/
56 |
57 | # StyleCop
58 | StyleCopReport.xml
59 |
60 | # Files built by Visual Studio
61 | *_i.c
62 | *_p.c
63 | *_h.h
64 | *.ilk
65 | *.meta
66 | *.obj
67 | *.iobj
68 | *.pch
69 | *.pdb
70 | *.ipdb
71 | *.pgc
72 | *.pgd
73 | *.rsp
74 | *.sbr
75 | *.tlb
76 | *.tli
77 | *.tlh
78 | *.tmp
79 | *.tmp_proj
80 | *_wpftmp.csproj
81 | *.log
82 | *.vspscc
83 | *.vssscc
84 | .builds
85 | *.pidb
86 | *.svclog
87 | *.scc
88 |
89 | # Chutzpah Test files
90 | _Chutzpah*
91 |
92 | # Visual C++ cache files
93 | ipch/
94 | *.aps
95 | *.ncb
96 | *.opendb
97 | *.opensdf
98 | *.sdf
99 | *.cachefile
100 | *.VC.db
101 | *.VC.VC.opendb
102 |
103 | # Visual Studio profiler
104 | *.psess
105 | *.vsp
106 | *.vspx
107 | *.sap
108 |
109 | # Visual Studio Trace Files
110 | *.e2e
111 |
112 | # TFS 2012 Local Workspace
113 | $tf/
114 |
115 | # Guidance Automation Toolkit
116 | *.gpState
117 |
118 | # ReSharper is a .NET coding add-in
119 | _ReSharper*/
120 | *.[Rr]e[Ss]harper
121 | *.DotSettings.user
122 |
123 | # JustCode is a .NET coding add-in
124 | .JustCode
125 |
126 | # TeamCity is a build add-in
127 | _TeamCity*
128 |
129 | # DotCover is a Code Coverage Tool
130 | *.dotCover
131 |
132 | # AxoCover is a Code Coverage Tool
133 | .axoCover/*
134 | !.axoCover/settings.json
135 |
136 | # Visual Studio code coverage results
137 | *.coverage
138 | *.coveragexml
139 |
140 | # NCrunch
141 | _NCrunch_*
142 | .*crunch*.local.xml
143 | nCrunchTemp_*
144 |
145 | # MightyMoose
146 | *.mm.*
147 | AutoTest.Net/
148 |
149 | # Web workbench (sass)
150 | .sass-cache/
151 |
152 | # Installshield output folder
153 | [Ee]xpress/
154 |
155 | # DocProject is a documentation generator add-in
156 | DocProject/buildhelp/
157 | DocProject/Help/*.HxT
158 | DocProject/Help/*.HxC
159 | DocProject/Help/*.hhc
160 | DocProject/Help/*.hhk
161 | DocProject/Help/*.hhp
162 | DocProject/Help/Html2
163 | DocProject/Help/html
164 |
165 | # Click-Once directory
166 | publish/
167 |
168 | # Publish Web Output
169 | *.[Pp]ublish.xml
170 | *.azurePubxml
171 | # Note: Comment the next line if you want to checkin your web deploy settings,
172 | # but database connection strings (with potential passwords) will be unencrypted
173 | *.pubxml
174 | *.publishproj
175 |
176 | # Microsoft Azure Web App publish settings. Comment the next line if you want to
177 | # checkin your Azure Web App publish settings, but sensitive information contained
178 | # in these scripts will be unencrypted
179 | PublishScripts/
180 |
181 | # NuGet Packages
182 | *.nupkg
183 | # The packages folder can be ignored because of Package Restore
184 | **/[Pp]ackages/*
185 | # except build/, which is used as an MSBuild target.
186 | !**/[Pp]ackages/build/
187 | # Uncomment if necessary however generally it will be regenerated when needed
188 | #!**/[Pp]ackages/repositories.config
189 | # NuGet v3's project.json files produces more ignorable files
190 | *.nuget.props
191 | *.nuget.targets
192 |
193 | # Microsoft Azure Build Output
194 | csx/
195 | *.build.csdef
196 |
197 | # Microsoft Azure Emulator
198 | ecf/
199 | rcf/
200 |
201 | # Windows Store app package directories and files
202 | AppPackages/
203 | BundleArtifacts/
204 | Package.StoreAssociation.xml
205 | _pkginfo.txt
206 | *.appx
207 |
208 | # Visual Studio cache files
209 | # files ending in .cache can be ignored
210 | *.[Cc]ache
211 | # but keep track of directories ending in .cache
212 | !*.[Cc]ache/
213 |
214 | # Others
215 | ClientBin/
216 | ~$*
217 | *~
218 | *.dbmdl
219 | *.dbproj.schemaview
220 | *.jfm
221 | *.pfx
222 | *.publishsettings
223 | orleans.codegen.cs
224 |
225 | # Including strong name files can present a security risk
226 | # (https://github.com/github/gitignore/pull/2483#issue-259490424)
227 | #*.snk
228 |
229 | # Since there are multiple workflows, uncomment next line to ignore bower_components
230 | # (https://github.com/github/gitignore/pull/1529#issuecomment-104372622)
231 | #bower_components/
232 |
233 | # RIA/Silverlight projects
234 | Generated_Code/
235 |
236 | # Backup & report files from converting an old project file
237 | # to a newer Visual Studio version. Backup files are not needed,
238 | # because we have git ;-)
239 | _UpgradeReport_Files/
240 | Backup*/
241 | UpgradeLog*.XML
242 | UpgradeLog*.htm
243 | ServiceFabricBackup/
244 | *.rptproj.bak
245 |
246 | # SQL Server files
247 | *.mdf
248 | *.ldf
249 | *.ndf
250 |
251 | # Business Intelligence projects
252 | *.rdl.data
253 | *.bim.layout
254 | *.bim_*.settings
255 | *.rptproj.rsuser
256 |
257 | # Microsoft Fakes
258 | FakesAssemblies/
259 |
260 | # GhostDoc plugin setting file
261 | *.GhostDoc.xml
262 |
263 | # Node.js Tools for Visual Studio
264 | .ntvs_analysis.dat
265 | node_modules/
266 |
267 | # Visual Studio 6 build log
268 | *.plg
269 |
270 | # Visual Studio 6 workspace options file
271 | *.opt
272 |
273 | # Visual Studio 6 auto-generated workspace file (contains which files were open etc.)
274 | *.vbw
275 |
276 | # Visual Studio LightSwitch build output
277 | **/*.HTMLClient/GeneratedArtifacts
278 | **/*.DesktopClient/GeneratedArtifacts
279 | **/*.DesktopClient/ModelManifest.xml
280 | **/*.Server/GeneratedArtifacts
281 | **/*.Server/ModelManifest.xml
282 | _Pvt_Extensions
283 |
284 | # Paket dependency manager
285 | .paket/paket.exe
286 | paket-files/
287 |
288 | # FAKE - F# Make
289 | .fake/
290 |
291 | # JetBrains Rider
292 | .idea/
293 | *.sln.iml
294 |
295 | # CodeRush personal settings
296 | .cr/personal
297 |
298 | # Python Tools for Visual Studio (PTVS)
299 | __pycache__/
300 | *.pyc
301 |
302 | # Cake - Uncomment if you are using it
303 | # tools/**
304 | # !tools/packages.config
305 |
306 | # Tabs Studio
307 | *.tss
308 |
309 | # Telerik's JustMock configuration file
310 | *.jmconfig
311 |
312 | # BizTalk build output
313 | *.btp.cs
314 | *.btm.cs
315 | *.odx.cs
316 | *.xsd.cs
317 |
318 | # OpenCover UI analysis results
319 | OpenCover/
320 |
321 | # Azure Stream Analytics local run output
322 | ASALocalRun/
323 |
324 | # MSBuild Binary and Structured Log
325 | *.binlog
326 |
327 | # NVidia Nsight GPU debugger configuration file
328 | *.nvuser
329 |
330 | # MFractors (Xamarin productivity tool) working folder
331 | .mfractor/
332 |
333 | # Local History for Visual Studio
334 | .localhistory/
335 | VMUP/VMUnprotect/VMUnprotect.csproj.DotSettings
336 |
--------------------------------------------------------------------------------
/LICENSE:
--------------------------------------------------------------------------------
1 | MIT License
2 |
3 | Copyright (c) 2021 void
4 |
5 | Permission is hereby granted, free of charge, to any person obtaining a copy
6 | of this software and associated documentation files (the "Software"), to deal
7 | in the Software without restriction, including without limitation the rights
8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 | copies of the Software, and to permit persons to whom the Software is
10 | furnished to do so, subject to the following conditions:
11 |
12 | The above copyright notice and this permission notice shall be included in all
13 | copies or substantial portions of the Software.
14 |
15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21 | SOFTWARE.
22 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 |
2 |
3 |
VMUnprotect.NET
4 |
5 | VMUnprotect is a project engaged in hunting virtualized VMProtect methods. It makes use of Harmony to dynamically read VMP behavior. Currently only supports method administration. Works on VMProtect 3.6.0 (Latest) and few versions back.
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 | ## Showcase
15 |
16 |
17 | # Usage
18 | ```sh
19 | VMUnprotect.exe
20 | -f, --file Required. Path to file.
21 | --enableharmonylogs (Default: false) Disable or Enable logs from Harmony.
22 | --bypassantidebug (Default: false) Bypass VMProtect Anti Debug.
23 | --help Display this help screen.
24 | --version Display version information.
25 | ```
26 |
27 | ### Doesn't work? Make sure you dump the file before with:
28 | * [VMUnprotect.Dumper](https://github.com/void-stack/VMUnprotect.Dumper)
29 |
30 | # Supported Protections
31 | Note: ***All Supported Protections are working combined***
32 |
33 | Protection Name | Is supported
34 | ------------------------|--------------
35 | Memory Protection | ✓
36 | Import Protection | ✓
37 | Resource Protection | ✓
38 | Debugger Detection | ✓
39 | Virtualization Tools | ✓
40 | Strip Debug Information | ✓
41 | Pack the Output File | ✓
42 |
43 | ## Current Features
44 | - Tracing invokes in virtualized methods.
45 | - Manipulating parameters and return values.
46 | - Bypass NtQueryInformationProcess, IsLogging, get_IsAttached
47 |
48 | ## Usage can be found in VMUnprotect.Runtime.MiddleMan
49 | ```csharp
50 | ///
51 | /// A prefix is a method that is executed before the original method
52 | ///
53 | public bool Prefix(ref object __result, ref object __instance, ref object obj, ref object[] parameters, ref object[] arguments) {
54 | var virtualizedMethodName = new StackTrace().GetFrame(7).GetMethod();
55 | var method = (MethodBase) __instance;
56 | Logger.Print("VMP MethodName: {0} (MDToken 0x{1:X4})", virtualizedMethodName.FullDescription(),
57 | virtualizedMethodName.MetadataToken.ToString());
58 | Logger.Print("MethodName: {0}", method.Name);
59 | Logger.Print("FullDescription: {0}", method.FullDescription());
60 | Logger.Print("MethodType: {0}", method.GetType());
61 | // ReSharper disable once ConditionIsAlwaysTrueOrFalse
62 | if (obj is not null)
63 | Logger.Print("Obj: {0}", Formatter.FormatObject(obj));
64 | // Loop through parameters and log them
65 | for (var i = 0; i < parameters.Length; i++) {
66 | var parameter = parameters[i];
67 | Logger.Print("Parameter ({1}) [{0}]: ({2})", i, parameter.GetType(), Formatter.FormatObject(parameter));
68 | }
69 | var returnType = method is MethodInfo info ? info.ReturnType.FullName : "System.Object";
70 | Logger.Print("MDToken: 0x{0:X4}", method.MetadataToken);
71 | Logger.Print("Return Type: {0}", returnType ?? "null");
72 | return true;
73 | }
74 |
75 | ///
76 | /// A postfix is a method that is executed after the original method
77 | ///
78 | public void Postfix(ref object __instance, ref object __result, ref object obj, ref object[] parameters, ref object[] arguments) {
79 | Logger.Print("Returns: {0}", __result);
80 | }
81 | ```
82 |
83 | # FAQ
84 | ### What is code virtualization?
85 | As VMProtect describes it on their's website. Code virtualization is the next step in software protection. Most protection systems encrypt the code and then decrypt it at the application’s startup. VMProtect doesn’t decrypt the code at all! Instead, the encrypted code runs on a virtual CPU that is markedly different from generic x86 and x64 CPUs as the command set is different for each protected file.
86 |
87 | ### Can it devirtualize VMP?
88 | No, isn't even meant for devirtualization.
89 |
90 | Todo | Done
91 | ---------------------------------|---------
92 | Change this to support more VM's | X
93 | VMP Stack tracing | X
94 | Bypass VMP Debugger Detection | ✓
95 | Bypass VMP CRC Check | X
96 | WPF GUI | X
97 |
98 |
99 | # Credits, checkout my blog about [VMUnprotect](https://void-stack.github.io)
100 | * [Washi](https://github.com/Washi1337) Overall credits for the project and inspiration with UnsafeInvokeInternal, thanks <3
101 |
102 | This tool uses the following (open source) software:
103 | * [dnlib](https://github.com/0xd4d/dnlib) by [0xd4d](https://github.com/0xd4d), licensed under the MIT license, for reading/writing assemblies.
104 | * [Harmony](https://github.com/pardeike/Harmony) by [Andreas Pardeike](https://github.com/pardeike), licensed under the MIT license
105 | * [Serilog](https://github.com/serilog/serilog) provides diagnostic logging to files, the console, and elsewhere. It is easy to set up, has a clean API.
106 | * [commandline](https://github.com/commandlineparser/commandline) offers CLR applications a clean and concise API for manipulating command line arguments and related tasks
107 | * [Autofac](https://github.com/autofac/Autofac) Autofac is an IoC container for Microsoft .NET. It manages the dependencies between classes so that applications stay easy to change as they grow in size and complexity. This is achieved by treating regular .NET classes as components.
108 |
109 | ## 💵 Want to buy me a Coffee?
110 | - Donate BTC at `bc1q048wrqztka5x2syt9mtj68uuf73vqry60s38vf`
111 | - Donate ETH at `0x86b2C17C94A1E6f35d498d17a37dc1f8A715139b`
112 |
--------------------------------------------------------------------------------
/VMUP/.editorconfig:
--------------------------------------------------------------------------------
1 |
2 | [*]
3 | charset = utf-8
4 | end_of_line = lf
5 | trim_trailing_whitespace = true
6 | insert_final_newline = true
7 | indent_style = space
8 | indent_size = 4
9 |
10 | # Microsoft .NET properties
11 | csharp_new_line_before_members_in_object_initializers = false
12 | csharp_preferred_modifier_order = public, private, protected, internal, new, abstract, virtual, sealed, override, static, readonly, extern, unsafe, volatile, async:suggestion
13 | csharp_style_var_elsewhere = true:suggestion
14 | csharp_style_var_for_built_in_types = false:suggestion
15 | csharp_style_var_when_type_is_apparent = true:suggestion
16 | dotnet_style_parentheses_in_arithmetic_binary_operators = never_if_unnecessary:none
17 | dotnet_style_parentheses_in_other_binary_operators = never_if_unnecessary:none
18 | dotnet_style_parentheses_in_relational_binary_operators = never_if_unnecessary:none
19 | dotnet_style_predefined_type_for_locals_parameters_members = true:suggestion
20 | dotnet_style_predefined_type_for_member_access = true:suggestion
21 | dotnet_style_qualification_for_event = false:suggestion
22 | dotnet_style_qualification_for_field = false:suggestion
23 | dotnet_style_qualification_for_method = false:suggestion
24 | dotnet_style_qualification_for_property = false:suggestion
25 | dotnet_style_require_accessibility_modifiers = for_non_interface_members:suggestion
26 |
27 | # ReSharper properties
28 | resharper_autodetect_indent_settings = true
29 | resharper_csharp_wrap_before_binary_opsign = true
30 | resharper_csharp_wrap_before_first_type_parameter_constraint = true
31 | resharper_keep_existing_embedded_arrangement = false
32 | resharper_keep_existing_switch_expression_arrangement = false
33 | resharper_max_array_initializer_elements_on_line = 20
34 | resharper_max_enum_members_on_line = 1
35 | resharper_max_initializer_elements_on_line = 1
36 | resharper_place_abstract_accessorholder_on_single_line = false
37 | resharper_place_attribute_on_same_line = false
38 | resharper_place_constructor_initializer_on_same_line = false
39 | resharper_place_simple_embedded_statement_on_same_line = false
40 | resharper_place_simple_initializer_on_single_line = false
41 | resharper_show_autodetect_configure_formatting_tip = false
42 | resharper_use_indent_from_vs = false
43 | resharper_wrap_array_initializer_style = chop_if_long
44 |
45 | # ReSharper inspection severities
46 | resharper_arrange_redundant_parentheses_highlighting = hint
47 | resharper_arrange_this_qualifier_highlighting = hint
48 | resharper_arrange_type_member_modifiers_highlighting = hint
49 | resharper_arrange_type_modifiers_highlighting = hint
50 | resharper_built_in_type_reference_style_for_member_access_highlighting = hint
51 | resharper_built_in_type_reference_style_highlighting = hint
52 | resharper_inconsistent_naming_highlighting = hint
53 | resharper_introduce_optional_parameters_global_highlighting = none
54 | resharper_loop_can_be_converted_to_query_highlighting = none
55 | resharper_redundant_base_qualifier_highlighting = warning
56 | resharper_shift_expression_real_shift_count_is_zero_highlighting = hint
57 | resharper_shift_expression_result_equals_zero_highlighting = hint
58 | resharper_shift_expression_zero_left_operand_highlighting = hint
59 | resharper_suggest_var_or_type_built_in_types_highlighting = hint
60 | resharper_suggest_var_or_type_elsewhere_highlighting = hint
61 | resharper_suggest_var_or_type_simple_types_highlighting = hint
62 | resharper_unused_member_global_highlighting = hint
63 | resharper_web_config_module_not_resolved_highlighting = warning
64 | resharper_web_config_type_not_resolved_highlighting = warning
65 | resharper_web_config_wrong_module_highlighting = warning
66 |
67 | [{*.bash,*.sh,*.zsh}]
68 | indent_style = space
69 | indent_size = 2
70 |
71 | [{*.yaml,*.yml}]
72 | indent_style = space
73 | indent_size = 2
74 |
75 | [*.{appxmanifest,asax,ascx,aspx,axaml,build,cg,cginc,compute,cs,cshtml,dtd,fs,fsi,fsscript,fsx,hlsl,hlsli,hlslinc,master,ml,mli,nuspec,paml,razor,resw,resx,skin,usf,ush,vb,xaml,xamlx,xoml,xsd}]
76 | indent_style = space
77 | indent_size = 4
78 | tab_width = 4
--------------------------------------------------------------------------------
/VMUP/VMUP.sln:
--------------------------------------------------------------------------------
1 |
2 | Microsoft Visual Studio Solution File, Format Version 12.00
3 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "VMUnprotect", "VMUnprotect\VMUnprotect.csproj", "{42C88429-9A67-4087-91BD-7D76383BC86D}"
4 | EndProject
5 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "VMUnprotect.Runtime", "VMUnprotect.Runtime\VMUnprotect.Runtime.csproj", "{3EE03C52-C17B-4771-BF5A-32D04A2D435E}"
6 | EndProject
7 | Global
8 | GlobalSection(SolutionConfigurationPlatforms) = preSolution
9 | Debug|Any CPU = Debug|Any CPU
10 | Release|Any CPU = Release|Any CPU
11 | EndGlobalSection
12 | GlobalSection(ProjectConfigurationPlatforms) = postSolution
13 | {42C88429-9A67-4087-91BD-7D76383BC86D}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
14 | {42C88429-9A67-4087-91BD-7D76383BC86D}.Debug|Any CPU.Build.0 = Debug|Any CPU
15 | {42C88429-9A67-4087-91BD-7D76383BC86D}.Release|Any CPU.ActiveCfg = Release|Any CPU
16 | {42C88429-9A67-4087-91BD-7D76383BC86D}.Release|Any CPU.Build.0 = Release|Any CPU
17 | {3EE03C52-C17B-4771-BF5A-32D04A2D435E}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
18 | {3EE03C52-C17B-4771-BF5A-32D04A2D435E}.Debug|Any CPU.Build.0 = Debug|Any CPU
19 | {3EE03C52-C17B-4771-BF5A-32D04A2D435E}.Release|Any CPU.ActiveCfg = Release|Any CPU
20 | {3EE03C52-C17B-4771-BF5A-32D04A2D435E}.Release|Any CPU.Build.0 = Release|Any CPU
21 | EndGlobalSection
22 | EndGlobal
23 |
--------------------------------------------------------------------------------
/VMUP/VMUnprotect.Runtime/General/AssemblyLoader.cs:
--------------------------------------------------------------------------------
1 | using dnlib.DotNet;
2 | using System;
3 | using System.Reflection;
4 | using VMUnprotect.Runtime.Helpers;
5 |
6 | namespace VMUnprotect.Runtime.General
7 | {
8 | internal class AssemblyLoader : Params, IAssemblyLoader
9 | {
10 | public AssemblyLoader(Context ctx, ILogger logger) : base(ctx, logger) { }
11 |
12 | public void LoadAssembly() {
13 | var assembly = Ctx.Project.TargetFilePath;
14 |
15 | try {
16 | Ctx.Module = ModuleDefMD.Load(assembly);
17 | Ctx.Assembly = Assembly.LoadFile(assembly);
18 | Logger.Info("Loaded assembly '{0}'", Ctx.Module.Name);
19 | } catch (Exception exception) {
20 | Logger.Info("Failed to load assembly '{0}'", assembly);
21 | Logger.Error($"Stacktrace: {exception}");
22 | Environment.Exit(0);
23 | }
24 | }
25 | }
26 |
27 | public interface IAssemblyLoader
28 | {
29 | void LoadAssembly();
30 | }
31 | }
--------------------------------------------------------------------------------
/VMUP/VMUnprotect.Runtime/General/CommandLineOptions.cs:
--------------------------------------------------------------------------------
1 | using CommandLine;
2 |
3 | namespace VMUnprotect.Runtime.General
4 | {
5 | public class CommandLineOptions
6 | {
7 | [Option('f', "file", HelpText = "Path to file.", Required = true)]
8 | public string FilePath { get; set; } = null!;
9 |
10 | /*[Option(Default = false, HelpText = "Use an older method that makes use of Transpiler (not recommended).",
11 | Required = false)]
12 | public bool UseTranspiler { get; set; }*/
13 |
14 | [Option(Default = false, HelpText = "Disable or Enable logs from Harmony.", Required = false)]
15 | public bool EnableHarmonyLogs { get; set; }
16 |
17 | [Option(Default = false, HelpText = "Bypass VMProtect Anti Debug.", Required = false)]
18 | public bool BypassAntiDebug { get; set; }
19 | }
20 | }
--------------------------------------------------------------------------------
/VMUP/VMUnprotect.Runtime/General/ContainerConfig.cs:
--------------------------------------------------------------------------------
1 | using Autofac;
2 | using VMUnprotect.Runtime.Hooks;
3 | using VMUnprotect.Runtime.Hooks.Methods.AntiDebug;
4 | using VMUnprotect.Runtime.MiddleMan;
5 | using VMUnprotect.Runtime.Modules;
6 | using VMUnprotect.Runtime.Structure;
7 |
8 | namespace VMUnprotect.Runtime.General
9 | {
10 | internal static class ContainerConfig
11 | {
12 | private static ContainerBuilder Builder { get; set; }
13 |
14 | public static IContainer Configure(ILogger logger, Project project, CommandLineOptions options) {
15 | Builder = new ContainerBuilder();
16 |
17 | Builder.RegisterInstance(logger).As().SingleInstance();
18 | Builder.RegisterType().As().SingleInstance();
19 | Builder.RegisterType().As().SingleInstance();
20 | Builder.RegisterType().As().SingleInstance();
21 |
22 | Builder.RegisterType().As().SingleInstance();
23 | Builder.RegisterType().As().SingleInstance();
24 |
25 | Builder.RegisterModule(new VmProtectPatchesModule());
26 |
27 | logger.Debug("Creating context...");
28 | Builder.RegisterInstance(new Context(project, logger, options)).As().SingleInstance();
29 |
30 | return Builder.Build();
31 | }
32 | }
33 | }
--------------------------------------------------------------------------------
/VMUP/VMUnprotect.Runtime/General/Context.cs:
--------------------------------------------------------------------------------
1 | using Autofac;
2 | using dnlib.DotNet;
3 | using HarmonyLib;
4 | using System.Reflection;
5 | using VMUnprotect.Runtime.Structure;
6 |
7 | namespace VMUnprotect.Runtime.General
8 | {
9 | public class Context
10 | {
11 | public Context(Project project, ILogger logger, CommandLineOptions options) {
12 | Logger = logger;
13 | Project = project;
14 | Options = options;
15 | }
16 |
17 | public Project Project { get; }
18 | public Assembly Assembly { get; internal set; }
19 | public ModuleDef Module { get; internal set; }
20 | public Harmony Harmony { get; internal set; }
21 | public CommandLineOptions Options { get; }
22 | public VmRuntimeStructure VmRuntimeStructure { get; internal set; }
23 |
24 | public ILogger Logger { get; }
25 | public ILifetimeScope Scope { get; internal set; }
26 | }
27 | }
--------------------------------------------------------------------------------
/VMUP/VMUnprotect.Runtime/General/Engine.cs:
--------------------------------------------------------------------------------
1 | using Autofac;
2 | using HarmonyLib;
3 | using System.Diagnostics;
4 | using System.Runtime.CompilerServices;
5 | using VMUnprotect.Runtime.Hooks;
6 | using VMUnprotect.Runtime.Structure;
7 |
8 | namespace VMUnprotect.Runtime.General
9 | {
10 | internal static class Engine
11 | {
12 | private static IContainer Container { get; set; }
13 |
14 | internal static void Initialize(Project project, ILogger logger, CommandLineOptions options) {
15 | logger.Info("initializing Engine...");
16 | Container = ContainerConfig.Configure(logger, project, options);
17 | }
18 |
19 | internal static void Run(Project project) {
20 | var logger = Container.Resolve();
21 | var ctx = Container.Resolve();
22 | var hooks = Container.Resolve();
23 |
24 | logger.Info("Starting...");
25 | var stopwatch = Stopwatch.StartNew();
26 |
27 | logger.Debug("Loading sample...");
28 | Container.Resolve().LoadAssembly();
29 |
30 | logger.Debug("Discovering VMProtect Runtime...");
31 | Container.Resolve().Discover();
32 |
33 | using var scope = Container.BeginLifetimeScope();
34 | ctx.Scope = scope;
35 |
36 | logger.Debug("Applying VMProtect hooks...");
37 | hooks.Initialize();
38 | hooks.ApplyHooks();
39 |
40 |
41 | logger.Debug("Invoking Target...");
42 | InvokeTarget(ctx, logger);
43 |
44 | stopwatch.Stop();
45 | logger.Info("Finished all tasks in {0}", stopwatch.Elapsed);
46 | logger.Info("Restoring Hooks...");
47 | hooks.RestoreAll();
48 | }
49 |
50 | private static void InvokeTarget(Context ctx, ILogger logger) {
51 |
52 | var fileEntryPoint = ctx.Assembly.EntryPoint;
53 | var moduleHandle = ctx.Assembly.ManifestModule.ModuleHandle;
54 | var parameters = fileEntryPoint.GetParameters();
55 |
56 | logger.Debug("Entrypoint method: {0}", fileEntryPoint.FullDescription());
57 | logger.Debug("ModuleHandle: {0:X4}", moduleHandle);
58 |
59 | logger.Info("--- Invoking Constructor.");
60 | RuntimeHelpers.RunModuleConstructor(moduleHandle);
61 |
62 | logger.Info("--- Invoking assembly.\n");
63 | fileEntryPoint.Invoke(
64 | null,
65 | parameters.Length == 0 ? null : new object[] {new[] {string.Empty}}); // parse arguments from commandlineoptions
66 | }
67 | }
68 | }
--------------------------------------------------------------------------------
/VMUP/VMUnprotect.Runtime/General/ILogger.cs:
--------------------------------------------------------------------------------
1 | namespace VMUnprotect.Runtime.General
2 | {
3 | public interface ILogger
4 | {
5 | public void Debug(string m, params object[] f);
6 | public void Error(string m, params object[] f);
7 | public void Info(string m, params object[] f);
8 | public void Warn(string m, params object[] f);
9 | public void Print(string m, params object[] f);
10 | }
11 | }
--------------------------------------------------------------------------------
/VMUP/VMUnprotect.Runtime/General/Project.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.IO;
3 |
4 | namespace VMUnprotect.Runtime.General
5 | {
6 | public class Project
7 | {
8 | public string TargetFilePath { get; set; }
9 |
10 | public void Run(ILogger logger, CommandLineOptions options) {
11 | if (!File.Exists(TargetFilePath)) {
12 | logger.Error($"{TargetFilePath} is not a file or it does not exist");
13 | Console.ReadLine();
14 | return;
15 | }
16 |
17 | Engine.Initialize(this, logger, options);
18 |
19 |
20 | Engine.Run(this);
21 | }
22 | }
23 | }
--------------------------------------------------------------------------------
/VMUP/VMUnprotect.Runtime/Helpers/Formatter.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections;
3 | using System.Linq;
4 |
5 | namespace VMUnprotect.Runtime.Helpers
6 | {
7 | public static class Formatter
8 | {
9 | ///
10 | /// Formats code to more reliable format
11 | ///
12 | public static string FormatObject(object obj) {
13 | try {
14 | return obj switch {
15 | null => "null",
16 | string x => $"\"{x}\"",
17 | IEnumerable enumerable =>
18 | $"{obj.GetType().Name} {{{string.Join(", ", enumerable.Cast