├── .gitignore
├── CSGOInjector.sln
├── CSGOInjector
├── App.config
├── CSGOInjector.csproj
├── Program.cs
├── Properties
│ ├── AssemblyInfo.cs
│ └── app.manifest
├── VACBypass.cs
└── app.manifest
└── README.md
/.gitignore:
--------------------------------------------------------------------------------
1 | ###################
2 | # compiled source #
3 | ###################
4 | *.com
5 | *.class
6 | *.dll
7 | *.exe
8 | *.pdb
9 | *.dll.config
10 | *.cache
11 | *.suo
12 | # Include dlls if they’re in the NuGet packages directory
13 | !/packages/*/lib/*.dll
14 | !/packages/*/lib/*/*.dll
15 | # Include dlls if they're in the CommonReferences directory
16 | !*CommonReferences/*.dll
17 | ####################
18 | # VS Upgrade stuff #
19 | ####################
20 | UpgradeLog.XML
21 | _UpgradeReport_Files/
22 | ###############
23 | # Directories #
24 | ###############
25 | bin/
26 | obj/
27 | TestResults/
28 | ###################
29 | # Web publish log #
30 | ###################
31 | *.Publish.xml
32 | #############
33 | # Resharper #
34 | #############
35 | /_ReSharper.*
36 | *.ReSharper.*
37 | ############
38 | # Packages #
39 | ############
40 | # it’s better to unpack these files and commit the raw source
41 | # git has its own built in compression methods
42 | *.7z
43 | *.dmg
44 | *.gz
45 | *.iso
46 | *.jar
47 | *.rar
48 | *.tar
49 | *.zip
50 | ######################
51 | # Logs and databases #
52 | ######################
53 | *.log
54 | *.sqlite
55 | # OS generated files #
56 | ######################
57 | .DS_Store?
58 | ehthumbs.db
59 | Icon?
60 | Thumbs.db
61 | [Bb]in
62 | [Oo]bj
63 | [Tt]est[Rr]esults
64 | *.suo
65 | *.user
66 | *.[Cc]ache
67 | *[Rr]esharper*
68 | packages
69 | NuGet.exe
70 | _[Ss]cripts
71 | *.exe
72 | *.dll
73 | *.nupkg
74 | *.ncrunchsolution
75 | *.dot[Cc]over
--------------------------------------------------------------------------------
/CSGOInjector.sln:
--------------------------------------------------------------------------------
1 |
2 | Microsoft Visual Studio Solution File, Format Version 12.00
3 | # Visual Studio Version 16
4 | VisualStudioVersion = 16.0.30413.136
5 | MinimumVisualStudioVersion = 10.0.40219.1
6 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "CSGOInjector", "CSGOInjector\CSGOInjector.csproj", "{99B08A4C-9DA2-4184-8DA9-FDA0984E3DC2}"
7 | EndProject
8 | Global
9 | GlobalSection(SolutionConfigurationPlatforms) = preSolution
10 | Debug|Any CPU = Debug|Any CPU
11 | Release|Any CPU = Release|Any CPU
12 | EndGlobalSection
13 | GlobalSection(ProjectConfigurationPlatforms) = postSolution
14 | {99B08A4C-9DA2-4184-8DA9-FDA0984E3DC2}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
15 | {99B08A4C-9DA2-4184-8DA9-FDA0984E3DC2}.Debug|Any CPU.Build.0 = Debug|Any CPU
16 | {99B08A4C-9DA2-4184-8DA9-FDA0984E3DC2}.Release|Any CPU.ActiveCfg = Release|Any CPU
17 | {99B08A4C-9DA2-4184-8DA9-FDA0984E3DC2}.Release|Any CPU.Build.0 = Release|Any CPU
18 | EndGlobalSection
19 | GlobalSection(SolutionProperties) = preSolution
20 | HideSolutionNode = FALSE
21 | EndGlobalSection
22 | GlobalSection(ExtensibilityGlobals) = postSolution
23 | SolutionGuid = {42B65423-722A-4CAF-AF3A-E544ED04EBCC}
24 | EndGlobalSection
25 | EndGlobal
26 |
--------------------------------------------------------------------------------
/CSGOInjector/App.config:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
--------------------------------------------------------------------------------
/CSGOInjector/CSGOInjector.csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | Debug
6 | AnyCPU
7 | {99B08A4C-9DA2-4184-8DA9-FDA0984E3DC2}
8 | Exe
9 | CSGOInjector
10 | CSGOInjector
11 | v4.7.2
12 | 512
13 | true
14 | true
15 |
16 |
17 | AnyCPU
18 | true
19 | full
20 | false
21 | bin\Debug\
22 | DEBUG;TRACE
23 | prompt
24 | 4
25 |
26 |
27 | AnyCPU
28 | pdbonly
29 | true
30 | bin\Release\
31 | TRACE
32 | prompt
33 | 4
34 |
35 |
36 | LocalIntranet
37 |
38 |
39 | false
40 |
41 |
42 | app.manifest
43 |
44 |
45 |
46 |
47 |
48 |
49 |
50 |
51 |
52 |
53 |
54 |
55 |
56 |
57 |
58 |
59 |
60 |
61 |
62 |
63 |
64 |
65 |
66 |
--------------------------------------------------------------------------------
/CSGOInjector/Program.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Runtime.InteropServices;
3 | using System.Windows.Forms;
4 | using System.IO;
5 |
6 | namespace CSGOInjector
7 | {
8 | class Program
9 | {
10 | [DllImport("kernel32.dll")]
11 | static extern IntPtr GetConsoleWindow();
12 |
13 | [DllImport("user32.dll")]
14 | static extern bool ShowWindow(IntPtr hWnd, int nCmdShow);
15 |
16 | private const int SW_HIDE = 0x0;
17 | private const int SW_SHOW = 0x5;
18 |
19 |
20 | [STAThread]
21 | static void Main(string[] args)
22 | {
23 | IntPtr handle = GetConsoleWindow();
24 | ShowWindow(handle, SW_HIDE);
25 |
26 | try
27 | {
28 | if (VACBypass.Run(GetPathDLL()))
29 | {
30 | MessageBox.Show("DLL injected!", "Success!", MessageBoxButtons.OK, MessageBoxIcon.Information, MessageBoxDefaultButton.Button1, MessageBoxOptions.DefaultDesktopOnly);
31 | }
32 | else
33 | {
34 | MessageBox.Show("Failed!", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error, MessageBoxDefaultButton.Button1, MessageBoxOptions.DefaultDesktopOnly);
35 | }
36 | }
37 | catch (Exception e)
38 | {
39 | MessageBox.Show(e.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
40 | }
41 | }
42 |
43 | private static string GetPathDLL()
44 | {
45 | string dllPath = string.Empty;
46 |
47 | using (OpenFileDialog fileDialog = new OpenFileDialog())
48 | {
49 | fileDialog.InitialDirectory = Directory.GetCurrentDirectory();
50 | fileDialog.Filter = "DLL files (*.dll)|*.dll";
51 | fileDialog.FilterIndex = 2;
52 | fileDialog.RestoreDirectory = true;
53 |
54 | if (fileDialog.ShowDialog() == DialogResult.OK)
55 | {
56 | dllPath = fileDialog.FileName;
57 | }
58 | else
59 | {
60 | throw new ApplicationException("Dll opening error");
61 | }
62 | }
63 |
64 | return dllPath;
65 | }
66 | }
67 | }
--------------------------------------------------------------------------------
/CSGOInjector/Properties/AssemblyInfo.cs:
--------------------------------------------------------------------------------
1 | using System.Reflection;
2 | using System.Runtime.CompilerServices;
3 | using System.Runtime.InteropServices;
4 |
5 | // General Information about an assembly is controlled through the following
6 | // set of attributes. Change these attribute values to modify the information
7 | // associated with an assembly.
8 | [assembly: AssemblyTitle("CSGOInjector")]
9 | [assembly: AssemblyDescription("")]
10 | [assembly: AssemblyConfiguration("")]
11 | [assembly: AssemblyCompany("")]
12 | [assembly: AssemblyProduct("CSGOInjector")]
13 | [assembly: AssemblyCopyright("Copyright © 2020")]
14 | [assembly: AssemblyTrademark("")]
15 | [assembly: AssemblyCulture("")]
16 |
17 | // Setting ComVisible to false makes the types in this assembly not visible
18 | // to COM components. If you need to access a type in this assembly from
19 | // COM, set the ComVisible attribute to true on that type.
20 | [assembly: ComVisible(false)]
21 |
22 | // The following GUID is for the ID of the typelib if this project is exposed to COM
23 | [assembly: Guid("99b08a4c-9da2-4184-8da9-fda0984e3dc2")]
24 |
25 | // Version information for an assembly consists of the following four values:
26 | //
27 | // Major Version
28 | // Minor Version
29 | // Build Number
30 | // Revision
31 | //
32 | // You can specify all the values or you can default the Build and Revision Numbers
33 | // by using the '*' as shown below:
34 | // [assembly: AssemblyVersion("1.0.*")]
35 | [assembly: AssemblyVersion("1.0.0.0")]
36 | [assembly: AssemblyFileVersion("1.0.0.0")]
37 |
--------------------------------------------------------------------------------
/CSGOInjector/Properties/app.manifest:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
32 |
33 |
34 |
35 |
36 |
37 |
38 |
39 |
40 |
41 |
42 |
43 |
44 |
48 |
55 |
56 |
70 |
--------------------------------------------------------------------------------
/CSGOInjector/VACBypass.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Diagnostics;
4 | using System.Runtime.ConstrainedExecution;
5 | using System.Runtime.InteropServices;
6 | using System.Security;
7 | using System.Text;
8 |
9 | namespace CSGOInjector
10 | {
11 | public static class VACBypass
12 | {
13 | private static List _functions = new List()
14 | {
15 | new FuncDLL("LoadLibraryExW", "kernel32"),
16 | new FuncDLL("VirtualAlloc", "kernel32"),
17 | new FuncDLL("FreeLibrary", "kernel32"),
18 | new FuncDLL("LoadLibraryExA", "kernel32"),
19 | new FuncDLL("LoadLibraryW", "kernel32"),
20 | new FuncDLL("LoadLibraryA", "kernel32"),
21 | new FuncDLL("VirtualAllocEx", "kernel32"),
22 | new FuncDLL("LdrLoadDll", "ntdll"),
23 | new FuncDLL("NtOpenFile", "ntdll"),
24 | new FuncDLL("VirtualProtect", "kernel32"),
25 | new FuncDLL("CreateProcessW", "kernel32"),
26 | new FuncDLL("CreateProcessA", "kernel32"),
27 | new FuncDLL("VirtualProtectEx", "kernel32"),
28 | new FuncDLL("FreeLibrary", "KernelBase"),
29 | new FuncDLL("LoadLibraryExA", "KernelBase"),
30 | new FuncDLL("LoadLibraryExW", "KernelBase"),
31 | new FuncDLL("ResumeThread", "KernelBase")
32 | };
33 |
34 | private static byte[,] originalBytes;
35 | private static IntPtr hGame = IntPtr.Zero;
36 | private static UInt32 pid = UInt32.MinValue;
37 |
38 | public static bool Run(string pathToDLL)
39 | {
40 | Init();
41 |
42 | pid = GetGamePID();
43 |
44 | if (pid == UInt32.MinValue)
45 | {
46 | throw new ApplicationException("The game was not found.");
47 | }
48 |
49 | hGame = OpenProcess(ProcessAccessFlags.All, false, (int)pid);
50 |
51 | if (hGame == IntPtr.Zero)
52 | {
53 | throw new ApplicationException("Failed to open process.");
54 | }
55 |
56 | BypassCSGOHook();
57 | InjectDLL(pathToDLL);
58 | RestoreCSGOHook();
59 |
60 | return true;
61 | }
62 |
63 | private static void Init()
64 | {
65 | originalBytes = new byte[17, 6];
66 | hGame = IntPtr.Zero;
67 | pid = UInt32.MinValue;
68 | }
69 |
70 | private static void InjectDLL(string path)
71 | {
72 | IntPtr handle = OpenProcess(ProcessAccessFlags.All, false, (Int32)pid);
73 |
74 | if (handle == IntPtr.Zero)
75 | {
76 | throw new ApplicationException("Failed to open process.");
77 | }
78 |
79 | IntPtr size = (IntPtr)path.Length;
80 |
81 | IntPtr DLLMemory = VirtualAllocEx(handle, IntPtr.Zero, size, AllocationType.Reserve | AllocationType.Commit,
82 | MemoryProtection.ExecuteReadWrite);
83 |
84 | if (DLLMemory == IntPtr.Zero)
85 | {
86 | throw new ApplicationException("Memory allocation error.");
87 | }
88 |
89 | byte[] bytes = Encoding.ASCII.GetBytes(path);
90 |
91 | if (!WriteProcessMemory(handle, DLLMemory, bytes, (int)bytes.Length, out _))
92 | {
93 | throw new ApplicationException("Memory read error");
94 | }
95 |
96 | IntPtr kernel32Handle = GetModuleHandle("Kernel32.dll");
97 | IntPtr loadLibraryAAddress = GetProcAddress(kernel32Handle, "LoadLibraryA");
98 |
99 | if (loadLibraryAAddress == IntPtr.Zero)
100 | {
101 | throw new ApplicationException("Failed to load LoadLibraryA.");
102 | }
103 |
104 | IntPtr threadHandle = CreateRemoteThread(handle, IntPtr.Zero, 0, loadLibraryAAddress, DLLMemory, 0,
105 | IntPtr.Zero);
106 |
107 | if (threadHandle == IntPtr.Zero)
108 | {
109 | throw new ApplicationException("Failed to create thread.");
110 | }
111 |
112 | CloseHandle(threadHandle);
113 | CloseHandle(handle);
114 | }
115 |
116 | private static UInt32 GetGamePID()
117 | {
118 | UInt32 ret = UInt32.MinValue;
119 | Process[] proc = Process.GetProcessesByName("csgo");
120 |
121 | if (proc.Length == 0)
122 | {
123 | return ret;
124 | }
125 |
126 | IntPtr hwGame = proc[0].MainWindowHandle;
127 |
128 | if (hwGame == IntPtr.Zero)
129 | {
130 | return ret;
131 | }
132 |
133 | GetWindowThreadProcessId(hwGame, out ret);
134 |
135 | return ret;
136 | }
137 |
138 | private static void BypassCSGOHook()
139 | {
140 | for (int i = 0; i < _functions.Count; i++)
141 | {
142 | if (!Unhook(_functions[i].MethodName, _functions[i].DLLName, i))
143 | {
144 | throw new ApplicationException($"Failed unhook {_functions[i].MethodName} in {_functions[i].DLLName}.");
145 | }
146 | }
147 | }
148 |
149 | private static void RestoreCSGOHook()
150 | {
151 | for (int i = 0; i < _functions.Count; i++)
152 | {
153 | if (!RestoreHook(_functions[i].MethodName, _functions[i].DLLName, i))
154 | {
155 | throw new ApplicationException($"Failed restore {_functions[i].MethodName} in {_functions[i].DLLName}.");
156 | }
157 | }
158 | }
159 |
160 | private static bool Unhook(string methodName, string dllName, Int32 index)
161 | {
162 | IntPtr originalMethodAddress = GetProcAddress(LoadLibrary(dllName), methodName);
163 |
164 | if (originalMethodAddress == IntPtr.Zero)
165 | {
166 | throw new ApplicationException($"The {methodName} address in {dllName} is zero.");
167 | }
168 |
169 | byte[] originalGameBytes = new byte[6];
170 |
171 | ReadProcessMemory(hGame, originalMethodAddress, originalGameBytes, sizeof(byte) * 6, out _);
172 |
173 | for (int i = 0; i < originalGameBytes.Length; i++)
174 | {
175 | originalBytes[index, i] = originalGameBytes[i];
176 | }
177 |
178 | byte[] originalDLLBytes = new byte[6];
179 |
180 | GCHandle pinnedArray = GCHandle.Alloc(originalDLLBytes, GCHandleType.Pinned);
181 | IntPtr originalDLLBytesPointer = pinnedArray.AddrOfPinnedObject();
182 |
183 | memcpy(originalDLLBytesPointer, originalMethodAddress, (UIntPtr)(sizeof(byte) * 6));
184 |
185 | return WriteProcessMemory(hGame, originalMethodAddress, originalDLLBytes, sizeof(byte) * 6, out _);
186 | }
187 |
188 | private static bool RestoreHook(string methodName, string dllName, Int32 index)
189 | {
190 | IntPtr originalMethodAdress = GetProcAddress(LoadLibrary(dllName), methodName);
191 |
192 | if (originalMethodAdress == IntPtr.Zero)
193 | {
194 | return false;
195 | }
196 |
197 | byte[] origBytes = new byte[6];
198 |
199 | for (int i = 0; i < origBytes.Length; i++)
200 | {
201 | origBytes[i] = originalBytes[index, i];
202 | }
203 |
204 | return WriteProcessMemory(hGame, originalMethodAdress, origBytes, sizeof(byte) * 6, out _);
205 | }
206 |
207 | private class FuncDLL
208 | {
209 | public string MethodName { get; set; }
210 | public string DLLName { get; set; }
211 |
212 | public FuncDLL(string methodName, string dllName)
213 | {
214 | MethodName = methodName;
215 | DLLName = dllName;
216 | }
217 | }
218 |
219 | #region Win32 DLL Enum
220 |
221 | private const UInt32 INFINITY = 0xFFFFFFFF;
222 |
223 | [Flags]
224 | public enum ProcessAccessFlags : uint
225 | {
226 | All = 0x001F0FFF,
227 | Terminate = 0x00000001,
228 | CreateThread = 0x00000002,
229 | VirtualMemoryOperation = 0x00000008,
230 | VirtualMemoryRead = 0x00000010,
231 | VirtualMemoryWrite = 0x00000020,
232 | DuplicateHandle = 0x00000040,
233 | CreateProcess = 0x000000080,
234 | SetQuota = 0x00000100,
235 | SetInformation = 0x00000200,
236 | QueryInformation = 0x00000400,
237 | QueryLimitedInformation = 0x00001000,
238 | Synchronize = 0x00100000
239 | }
240 |
241 | [Flags]
242 | public enum AllocationType
243 | {
244 | Commit = 0x1000,
245 | Reserve = 0x2000,
246 | Decommit = 0x4000,
247 | Release = 0x8000,
248 | Reset = 0x80000,
249 | Physical = 0x400000,
250 | TopDown = 0x100000,
251 | WriteWatch = 0x200000,
252 | LargePages = 0x20000000
253 | }
254 |
255 | [Flags]
256 | public enum MemoryProtection
257 | {
258 | Execute = 0x10,
259 | ExecuteRead = 0x20,
260 | ExecuteReadWrite = 0x40,
261 | ExecuteWriteCopy = 0x80,
262 | NoAccess = 0x01,
263 | ReadOnly = 0x02,
264 | ReadWrite = 0x04,
265 | WriteCopy = 0x08,
266 | GuardModifierflag = 0x100,
267 | NoCacheModifierflag = 0x200,
268 | WriteCombineModifierflag = 0x400
269 | }
270 |
271 |
272 | #endregion
273 |
274 | #region Win32 DLL import
275 |
276 | [DllImport("user32.dll", SetLastError = true)]
277 | static extern IntPtr FindWindow(string lpClassName, string lpWindowName);
278 |
279 | [DllImport("user32.dll", SetLastError = true)]
280 | static extern uint GetWindowThreadProcessId(IntPtr hWnd, out uint lpdwProcessId);
281 |
282 | [DllImport("kernel32.dll", CharSet = CharSet.Auto, SetLastError = true)]
283 | internal static extern IntPtr LoadLibrary(string lpFileName);
284 |
285 | [DllImport("kernel32", CharSet = CharSet.Ansi, ExactSpelling = true, SetLastError = true)]
286 | static extern IntPtr GetProcAddress(IntPtr hModule, string procName);
287 |
288 | [DllImport("msvcrt.dll", EntryPoint = "memcpy", CallingConvention = CallingConvention.Cdecl, SetLastError = false)]
289 | public static extern IntPtr memcpy(IntPtr dest, IntPtr src, UIntPtr count);
290 |
291 | [DllImport("kernel32.dll", SetLastError = true, ExactSpelling = true)]
292 | static extern IntPtr VirtualAllocEx(IntPtr hProcess, IntPtr lpAddress, IntPtr dwSize, AllocationType flAllocationType, MemoryProtection flProtect);
293 |
294 | [DllImport("kernel32.dll")]
295 | static extern IntPtr CreateRemoteThread(IntPtr hProcess, IntPtr lpThreadAttributes, uint dwStackSize, IntPtr lpStartAddress, IntPtr lpParameter, uint dwCreationFlags, IntPtr lpThreadId);
296 |
297 | [DllImport("kernel32.dll", SetLastError = true, ExactSpelling = true)]
298 | static extern bool VirtualFreeEx(IntPtr hProcess, IntPtr lpAddress,
299 | int dwSize, AllocationType dwFreeType);
300 |
301 | [DllImport("kernel32.dll", SetLastError = true)]
302 | public static extern IntPtr OpenProcess(ProcessAccessFlags processAccess, bool bInheritHandle, int processId);
303 |
304 | [DllImport("kernel32.dll", SetLastError = true)]
305 | static extern bool ReadProcessMemory(IntPtr hProcess, IntPtr lpBaseAddress, [Out] byte[] lpBuffer, int dwSize, out IntPtr lpNumberOfBytesRead);
306 |
307 | [DllImport("kernel32.dll", SetLastError = true)]
308 | public static extern bool WriteProcessMemory(IntPtr hProcess, IntPtr lpBaseAddress, byte[] lpBuffer, Int32 nSize, out IntPtr lpNumberOfBytesWritten);
309 |
310 | [DllImport("kernel32.dll", CharSet = CharSet.Auto)]
311 | public static extern IntPtr GetModuleHandle(string lpModuleName);
312 |
313 | [DllImport("kernel32.dll", SetLastError = true)]
314 | [ReliabilityContract(Consistency.WillNotCorruptState, Cer.Success)]
315 | [SuppressUnmanagedCodeSecurity]
316 | [return: MarshalAs(UnmanagedType.Bool)]
317 | static extern bool CloseHandle(IntPtr hObject);
318 |
319 | #endregion
320 |
321 | }
322 | }
323 |
--------------------------------------------------------------------------------
/CSGOInjector/app.manifest:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
32 |
33 |
34 |
35 |
36 |
37 |
38 |
39 |
40 |
41 |
42 |
43 |
44 |
48 |
55 |
56 |
70 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # CSGOInjector
2 | Bypass CSGO Trusted Mode
3 |
4 | [Download here](https://github.com/toxa9/CSGOInjector/releases)
5 |
6 | # How to use
7 | 1. Run CSGO
8 | 2. Run CSGOInjector
9 | 3. Select DLL
10 | 4. Play
--------------------------------------------------------------------------------