-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathProgram.cs
215 lines (183 loc) · 7.82 KB
/
Program.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
using System;
using System.Diagnostics;
using System.IO;
using System.Net.Http;
using System.Threading;
using System.Windows.Forms;
using UnfairLoader.Injector;
namespace UnfairLoader
{
internal static class Program
{
private static void FileToBytes(string path, out byte[] injectionBytes)
{
try
{
injectionBytes = File.ReadAllBytes(path);
}
catch (Exception ex)
{
LogLine($"Failed to read file: {ex.Message}", ConsoleColor.Red);
injectionBytes = null;
}
}
// green like money $$$$$$$$$$$$
private static void LogLine(string msg, ConsoleColor color = ConsoleColor.Green)
{
Console.ForegroundColor = color;
Console.WriteLine(msg);
}
[STAThread] // for OpenFileDialog
private static void Main(string[] args)
{
Console.Title = "Unfair - spoung squad creation";
Console.Clear();
injectType:
LogLine("\n /$$ /$$ /$$$$$$ /$$ \n" +
"| $$ | $$ /$$__ $$ |__/ \n" +
"| $$ | $$ /$$$$$$$ | $$ \\__//$$$$$$ /$$ /$$$$$$ \n" +
"| $$ | $$| $$__ $$| $$$$ |____ $$| $$ /$$__ $$\n" +
"| $$ | $$| $$ \\ $$| $$_/ /$$$$$$$| $$| $$ \\__/\n" +
"| $$ | $$| $$ | $$| $$ /$$__ $$| $$| $$ \n" +
"| $$$$$$/| $$ | $$| $$ | $$$$$$$| $$| $$ \n" +
" \\______/ |__/ |__/|__/ \\_______/|__/|__/ \n");
byte[] injectionBytes;
LogLine("(x) Select an injection type, online for the updated version, or local for any other.\n" +
"[1] Online injection\n" +
"[2] Local file injection\n", ConsoleColor.Yellow);
Console.ForegroundColor = ConsoleColor.Cyan;
Console.Write("Select an option: ");
var typeSelect = Console.ReadKey();
Console.WriteLine();
switch (typeSelect.Key)
{
case ConsoleKey.D1: // ONLINE INJECTION (from build server or something)
using (var client = new HttpClient())
{
client.DefaultRequestHeaders.Add("User-Agent", "UnfairLoader/1.0");
var response = client.GetAsync("https://unfair.000webhostapp.com/Unfair.dll").Result;
if (!response.IsSuccessStatusCode)
{
Console.Clear();
LogLine("Failed to download Unfair.", ConsoleColor.Red);
goto injectType;
}
var stream = response.Content.ReadAsStreamAsync().Result;
injectionBytes = new byte[stream.Length];
var read = stream.Read(injectionBytes, 0, (int)stream.Length);
if (read != stream.Length)
{
Console.Clear();
LogLine("Failed to read from Unfair.dll. Could be antivirus interference.",
ConsoleColor.Red);
goto injectType;
}
}
break;
case ConsoleKey.D2: // LOCAL FILE INJECTION
if (args.Length == 1 && args[0].EndsWith(".dll"))
{
FileToBytes(args[0], out injectionBytes);
break;
}
filechoose:
var dialog = new OpenFileDialog
{
Filter = "Unfair.dll|Unfair.dll",
Title = "Select Unfair.dll"
};
var dialogResult = dialog.ShowDialog();
if (dialogResult == DialogResult.Cancel)
{
Console.Clear();
LogLine("Cancelled, going back to start!", ConsoleColor.Red);
goto injectType;
}
if (!dialog.FileName.EndsWith(".dll"))
{
Console.Clear();
LogLine("Invalid file selection, must be of type: dll", ConsoleColor.Red);
goto filechoose;
}
Console.WriteLine(); //buh
FileToBytes(dialog.FileName, out injectionBytes);
break;
default:
Console.Clear();
LogLine("Invalid option\n", ConsoleColor.Red);
goto injectType;
}
if (injectionBytes == null)
{
LogLine("Failed to read from Unfair.dll. Maybe it's antivirus interference.", ConsoleColor.Red);
Console.ReadKey();
return;
}
// open game
Process gameProcess = GetGameProcess();
var handle = Native.OpenProcess(ProcessAccessRights.PROCESS_ALL_ACCESS, false, gameProcess.Id);
if (handle == IntPtr.Zero)
{
LogLine("Failed to inject - OpenProcess failed. Might be antivirus interference.", ConsoleColor.Red);
Console.ReadKey(true);
}
var result = ProcessUtils.GetMonoModule(handle, out var monoModule);
if (!result)
{
LogLine("Failed to inject - GetMonoModule failed. Possible antivirus interference.", ConsoleColor.Red);
Console.ReadKey(true);
}
using (var injector = new Injector.Injector(handle, monoModule))
{
try
{
injector.Inject(injectionBytes, "Unfair", "Loader", "Load");
LogLine("Unfair is now injected.");
Console.ReadKey();
}
catch (InjectorException ie)
{
LogLine($"Injector issue: {ie.Message}. Antivirus interference? Could be.", ConsoleColor.Red);
Console.ReadKey();
}
catch (Exception ex)
{
LogLine($"Unknown issue: {ex.Message}. I'm not sure what could've caused this.", ConsoleColor.Red);
Console.ReadKey();
}
}
}
private static Process GetGameProcess()
{
Process gameProcess;
bool started = false;
while (true)
{
var processes = Process.GetProcessesByName("1v1_LOL");
if (processes.Length > 0)
{
gameProcess = processes[0];
break;
}
if (!started && processes.Length == 0)
{
// Open game
LogLine("(*) Attempting to start 1v1.LOL (Steam). If this fails, start it manually.",
ConsoleColor.Cyan);
Process.Start("steam://rungameid/2305790");
started = true;
}
LogLine("(*) Waiting for game to start...", ConsoleColor.Cyan);
Thread.Sleep(1000);
}
LogLine($"(*) Waiting for game to load...", ConsoleColor.Cyan);
while (gameProcess.Modules.Count < 100 || gameProcess.MainWindowHandle == IntPtr.Zero)
{
gameProcess.Refresh();
}
LogLine($"Game found, injecting...");
gameProcess.Refresh();
return gameProcess;
}
}
}