This repository has been archived by the owner on Jun 27, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathspecial16.cs
319 lines (271 loc) · 11.8 KB
/
special16.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Runtime.InteropServices;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
namespace dynolts
{
public partial class Form1 : Form1
{
Process h=new Process();
IntPtr address = IntPtr.Zero;
string customCode = "b000";
public static string ByteArrayToString(byte[] ba)
{
return BitConverter.ToString(ba).Replace("-", "");
}
public static byte[] StringToByteArray(String hex)
{
int NumberChars = hex.Length;
byte[] bytes = new byte[NumberChars / 2];
for (int i = 0; i < NumberChars; i += 2)
bytes[i / 2] = Convert.ToByte(hex.Substring(i, 2), 16);
return bytes;
}
class ProcessMemoryReader
{
public ProcessMemoryReader()
{
}
/// <summary>
/// Process from which to read
/// </summary>
public Process ReadProcess
{
get
{
return m_ReadProcess;
}
set
{
m_ReadProcess = value;
}
}
public int bise=0;
public long baseAddress = 0;
private Process m_ReadProcess = null;
private IntPtr m_hProcess = IntPtr.Zero;
public byte[] jump(long origin, long destination)
{
if (destination > origin)
{
var j = (int)(destination - origin);
var i = BitConverter.GetBytes(j).ToList();
return i.ToArray();
}
var iA = BitConverter.GetBytes((int)(origin-destination)).ToList();
bool added = false;
for(int v = 0; v < iA.Count; ++v)
{
iA[v] = (byte)(255 - iA[v]);
if (!added)
{
if (iA[v] != 255)
{
iA[v] += 1;
added = true;
}
else
iA[v] = 0;
}
}
return iA.ToArray();
}
public void OpenProcess()
{
// m_hProcess = ProcessMemoryReaderApi.OpenProcess(ProcessMemoryReaderApi.PROCESS_VM_READ, 1, (uint)m_ReadProcess.Id);
ProcessMemoryReaderApi.ProcessAccessType access;
access = ProcessMemoryReaderApi.ProcessAccessType.PROCESS_VM_READ
| ProcessMemoryReaderApi.ProcessAccessType.PROCESS_VM_WRITE
| ProcessMemoryReaderApi.ProcessAccessType.PROCESS_VM_OPERATION;
m_hProcess = ProcessMemoryReaderApi.OpenProcess((uint)access, 1, (uint)m_ReadProcess.Id);
baseAddress = m_ReadProcess.MainModule.BaseAddress.ToInt64();
}
public void CloseHandle()
{
try
{
int iRetValue;
iRetValue = ProcessMemoryReaderApi.CloseHandle(m_hProcess);
if (iRetValue == 0)
{
throw new Exception("CloseHandle failed");
}
}
catch (Exception ex)
{
System.Windows.Forms.MessageBox.Show(ex.Message, "error", System.Windows.Forms.MessageBoxButtons.OK, System.Windows.Forms.MessageBoxIcon.Warning);
}
}
public IntPtr CreateMemory(int size)
{
IntPtr f = (IntPtr)(baseAddress+ 0xDE3A38);
var s= ProcessMemoryReaderApi.VirtualAllocEx(m_hProcess, out f, (uint)size, (uint)(ProcessMemoryReaderApi.flAllocationType.MEM_COMMIT|ProcessMemoryReaderApi.flAllocationType.MEM_RESERVE), (uint)ProcessMemoryReaderApi.flProtect.PAGE_EXECUTE_READWRITE);
return f;
}
public void WriteProcessSpecial(long offset, byte[] bytesToWrite, out int bytesWritten)
{
IntPtr MemoryAddress = (IntPtr)(baseAddress + offset);
IntPtr ptrBytesWritten;
ProcessMemoryReaderApi.WriteProcessMemory(m_hProcess, MemoryAddress, bytesToWrite, (uint)bytesToWrite.Length, out ptrBytesWritten);
bytesWritten = ptrBytesWritten.ToInt32();
}
public byte[] ReadProcessMemory(IntPtr MemoryAddress, uint bytesToRead, out int bytesRead)
{
byte[] buffer = new byte[bytesToRead];
IntPtr ptrBytesRead;
ProcessMemoryReaderApi.ReadProcessMemory(m_hProcess, MemoryAddress, buffer, bytesToRead, out ptrBytesRead);
bytesRead = ptrBytesRead.ToInt32();
return buffer;
}
public void WriteProcessMemory(IntPtr MemoryAddress, byte[] bytesToWrite, out int bytesWritten)
{
IntPtr ptrBytesWritten;
ProcessMemoryReaderApi.WriteProcessMemory(m_hProcess, MemoryAddress, bytesToWrite, (uint)bytesToWrite.Length, out ptrBytesWritten);
bytesWritten = ptrBytesWritten.ToInt32();
}
/// <summary>
/// ProcessMemoryReader is a class that enables direct reading a process memory
/// </summary>
class ProcessMemoryReaderApi
{
// constants information can be found in <winnt.h>
[Flags]
public enum ProcessAccessType
{
PROCESS_TERMINATE = (0x0001),
PROCESS_CREATE_THREAD = (0x0002),
PROCESS_SET_SESSIONID = (0x0004),
PROCESS_VM_OPERATION = (0x0008),
PROCESS_VM_READ = (0x0010),
PROCESS_VM_WRITE = (0x0020),
PROCESS_DUP_HANDLE = (0x0040),
PROCESS_CREATE_PROCESS = (0x0080),
PROCESS_SET_QUOTA = (0x0100),
PROCESS_SET_INFORMATION = (0x0200),
PROCESS_QUERY_INFORMATION = (0x0400)
}
public enum flAllocationType
{
MEM_COMMIT=0x00001000,
MEM_RESET_UNDO=0x1000000,
MEM_RESERVE=0x00002000,
MEM_RESET=0x00080000,
MEM_TOP_DOWN=0x00100000
}
public enum flProtect
{
PAGE_EXECUTE=0x10,
PAGE_EXECUTE_READ=0x20,
PAGE_EXECUTE_READWRITE=0x40,
PAGE_EXECUTE_WRITECOPY=0x80,
PAGE_NOACCESS=0x01,
PAGE_READONLY=0x02,
PAGE_READWRITE=0x04,
PAGE_WRITECOPY=0x08,
PAGE_TARGETS_INVALID=0x40000000,
PAGE_TARGETS_NO_UPDATE=0x40000000
}
// function declarations are found in the MSDN and in <winbase.h>
// HANDLE OpenProcess(
// DWORD dwDesiredAccess, // access flag
// BOOL bInheritHandle, // handle inheritance option
// DWORD dwProcessId // process identifier
// );
[DllImport("Kernel32.dll")]
public static extern IntPtr VirtualAllocEx(IntPtr hProcess, out IntPtr lpAddress, UInt32 dwSize, UInt32 flAllocationType,UInt32 flProtect);
[DllImport("kernel32.dll")]
public static extern IntPtr OpenProcess(UInt32 dwDesiredAccess, Int32 bInheritHandle, UInt32 dwProcessId);
// BOOL CloseHandle(
// HANDLE hObject // handle to object
// );
[DllImport("kernel32.dll")]
public static extern Int32 CloseHandle(IntPtr hObject);
// BOOL ReadProcessMemory(
// HANDLE hProcess, // handle to the process
// LPCVOID lpBaseAddress, // base of memory area
// LPVOID lpBuffer, // data buffer
// SIZE_T nSize, // number of bytes to read
// SIZE_T * lpNumberOfBytesRead // number of bytes read
// );
[DllImport("kernel32.dll")]
public static extern Int32 ReadProcessMemory(IntPtr hProcess, IntPtr lpBaseAddress, [In, Out] byte[] buffer, UInt32 size, out IntPtr lpNumberOfBytesRead);
// BOOL WriteProcessMemory(
// HANDLE hProcess, // handle to process
// LPVOID lpBaseAddress, // base of memory area
// LPCVOID lpBuffer, // data buffer
// SIZE_T nSize, // count of bytes to write
// SIZE_T * lpNumberOfBytesWritten // count of bytes written
// );
[DllImport("kernel32.dll")]
public static extern Int32 WriteProcessMemory(IntPtr hProcess, IntPtr lpBaseAddress, [In, Out] byte[] buffer, UInt32 size, out IntPtr lpNumberOfBytesWritten);
}
}
void start()
{
// var whitelist = Process.GetProcessesByName("RuntimeBroker");
// File.AppendAllText(pt, "Fetched Brokers\n");
// Enable();
// File.AppendAllText(pt, "Hack Enabled\n");
try
{
Process.Start("minecraft://");
File.AppendAllText(pt, "Process started\n");
}
catch (Exception e)
{
File.AppendAllText(pt, "Error came in launching game\n" + e.Message + "\t" + e.StackTrace);
}
h = new Process();
try
{
h = Process.GetProcessesByName("Minecraft.Windows")[0];
}
catch (Exception e)
{
File.AppendAllText(pt, "Error came in retrieving game\n" + e.Message + "\t" + e.StackTrace);
throw e;
}
ProcessMemoryReader reader = new ProcessMemoryReader();
reader.ReadProcess = h;
reader.OpenProcess();
int i = 0;
reader.WriteProcessSpecial(0xDbf767, new byte[] { 0xeb }, out i);
PerformanceCounter PC = new PerformanceCounter();
PC.CategoryName = "Process";
PC.CounterName = "Working Set - Private";
PC.InstanceName = "Minecraft.Windows";
int memsize = 0;
if (!h.HasExited)
memsize = Convert.ToInt32(PC.NextValue()) / (int)(1024);
while (memsize < 40000)
{
Task.Delay(100).Wait();
if (h.HasExited)
return;
memsize = Convert.ToInt32(PC.NextValue()) / (int)(1024);
}
PC.Close();
PC.Dispose();
memsize = 0;
reader.WriteProcessSpecial(0xDbf767, new byte[] { 0x78 }, out i);
var custom = StringToByteArray(customCode);
reader.WriteProcessSpecial(0xDE3A3A,custom, out i);
reader.CloseHandle();
if(i==0)
File.AppendAllText(pt, "Error in writing jump\n");
while (!h.HasExited)
{
Task.Delay(100).Wait();
}
Application.Current.Dispatcher.Invoke((Action)(() => {
this.Show();
}));
set_st(true);
}
}
}