forked from Ox18/cheatmatrix-gunbound
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathCMX.dpr
More file actions
186 lines (169 loc) · 4.68 KB
/
CMX.dpr
File metadata and controls
186 lines (169 loc) · 4.68 KB
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
program CMX;
// {$APPTYPE CONSOLE}
{$R 'icone.res' 'icone.rc'}
uses
SysUtils,
iniFiles,
windows;
Function GetRandomName(Size: integer): AnsiString;
var
i, k, l: integer;
v: boolean;
const
Consoantes = 'bcdfghjklmnpqrstvwxz';
Vogais = 'aeiouy';
begin
result := '';
v := false;
k := random(6) + 5;
for i := 1 to Size do
begin
randomize;
v := not v;
l := random(3);
if v then
result := result + Consoantes[random(length(Consoantes) - 1) + 1]
else
result := result + Vogais[random(length(Vogais) - 1) + 1]
end;
end;
function HexToInt(s: AnsiString): Longword;
var
b: Byte;
c: AnsiChar;
begin
result := 0;
s := UpperCase(s);
for b := 1 to length(s) do
begin
result := result * 16;
c := s[b];
case c of
'0' .. '9':
Inc(result, Ord(c) - Ord('0'));
'A' .. 'F':
Inc(result, Ord(c) - Ord('A') + 10);
else
raise EConvertError.Create('No Hex-Number');
end;
end;
end;
Function HexToString(valor: AnsiString): AnsiString;
var
i: integer;
s: AnsiString;
begin
result := '';
s := '';
if (length(valor) mod 2) > 0 then
valor := '0' + valor;
for i := 1 to length(valor) do
begin
s := s + valor[i];
if length(s) = 2 then
begin
result := result + AnsiChar(HexToInt(s));
s := '';
end;
end;
end;
Function CriarProcesso(Path: AnsiString; Parametro: PAnsiChar; showtype: cardinal): boolean;
var
StartupInfo: STARTUPINFOA;
ProcessInfo: PROCESS_INFORMATION;
Diretorio: PAnsiChar;
begin
// VMProtectBegin('cps');
Diretorio := PAnsiChar(Path);
//
result := true;
FillChar(StartupInfo, sizeof(StartupInfo), #0);
FillChar(ProcessInfo, sizeof(ProcessInfo), #0);
StartupInfo.cb := sizeof(StartupInfo);
StartupInfo.cb := sizeof(StartupInfo);
StartupInfo.dwFlags := STARTF_USESHOWWINDOW;
StartupInfo.wShowWindow := SW_SHOWNORMAL;
if not CreateProcessA(Diretorio, Parametro, nil, // pointer to process security attributes
nil, // pointer to thread security attributes
false, // handle inheritance flag
NORMAL_PRIORITY_CLASS, // NORMAL_PRIORITY_CLASS,
nil, // pointer to new environment block
nil, // pointer to current directory name
StartupInfo, // pointer to STARTUPINFO
ProcessInfo) then
begin
result := false;
end;
closehandle(ProcessInfo.hProcess);
closehandle(ProcessInfo.hThread);
// VMProtectEnd;
end;
function FileSearch: boolean;
var
Rec: TSearchRec;
Path: AnsiString;
begin
Path := ExtractFilePath(ParamStr(0));
if FileExists(Path + 'matriz.exe') then
begin
result := true;
exit;
end;
if FindFirst(Path + '*.exe', faAnyFile - faDirectory, Rec) = 0 then
begin
try
repeat
if LowerCase(Rec.Name) <> 'cmx.exe' then
begin
if (RenameFile(Path + Rec.Name, Path + 'matriz.exe')) then
begin
result := true;
exit;
end;
end;
until FindNext(Rec) <> 0;
finally
SysUtils.FindClose(Rec);
end;
end;
end;
var
exeName, exeStr, nomeMatriz, dirIni: AnsiString;
iniConfig: TIniFile;
encontrado: boolean;
Parametro: AnsiString;
begin
nomeMatriz := ExtractFilePath(ParamStr(0)) + 'matriz.exe';
if not FileExists(nomeMatriz) then
begin
dirIni := ExtractFilePath(ParamStr(0)) + 'configs.ini';
iniConfig := TIniFile.Create(dirIni);
exeStr := iniConfig.ReadString('configs', 'des', '');
exeName := HexToString(exeStr);
encontrado := true;
if (length(exeName) > 0) and (FileExists(ExtractFilePath(ParamStr(0)) + exeName + '.exe')) then
begin
if not(RenameFile(ExtractFilePath(ParamStr(0)) + exeName + '.exe', nomeMatriz)) then
if not FileExists(nomeMatriz) then
begin
encontrado := false;
end;
end
else
begin
encontrado := false;
end;
if not encontrado then
begin
if not FileSearch then
begin
MessageBoxA(0, 'Matriz não encontrada! Reinstale o CMX', '', 0);
end;
end;
end;
Parametro := '';
if ParamCount > 0 then
Parametro := ParamStr(1);
if not CriarProcesso(nomeMatriz, PAnsiChar(AnsiString(Parametro)), 0) then
MessageBoxA(0, 'Falha ao iniciar o CMX!', '', 0)
end.