Implement Thread pools
This commit is contained in:
2
.idea/inspectionProfiles/Project_Default.xml
generated
2
.idea/inspectionProfiles/Project_Default.xml
generated
@@ -2,7 +2,7 @@
|
||||
<profile version="1.0">
|
||||
<option name="myName" value="Project Default" />
|
||||
<inspection_tool class="AutoCloseableResource" enabled="true" level="WARNING" enabled_by_default="true">
|
||||
<option name="METHOD_MATCHER_CONFIG" value="java.util.Formatter,format,java.io.Writer,append,com.google.common.base.Preconditions,checkNotNull,org.hibernate.Session,close,java.io.PrintWriter,printf,java.io.PrintStream,printf,java.net.http.HttpClient,newHttpClient,java.net.http.HttpClient.Builder,build" />
|
||||
<option name="METHOD_MATCHER_CONFIG" value="java.util.Formatter,format,java.io.Writer,append,com.google.common.base.Preconditions,checkNotNull,org.hibernate.Session,close,java.io.PrintWriter,printf,java.io.PrintStream,printf,java.net.http.HttpClient,newHttpClient,java.net.http.HttpClient.Builder,build,java.util.concurrent.Executors,newFixedThreadPool|newVirtualThreadPerTaskExecutor" />
|
||||
</inspection_tool>
|
||||
</profile>
|
||||
</component>
|
||||
@@ -16,6 +16,7 @@ import java.security.NoSuchAlgorithmException;
|
||||
import java.util.Arrays;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import java.util.concurrent.ExecutionException;
|
||||
|
||||
public class Main {
|
||||
|
||||
@@ -28,7 +29,7 @@ public class Main {
|
||||
public static Request requestClient;
|
||||
public static boolean ignoreBots = true;
|
||||
|
||||
public static void main(String[] args) throws IOException, InterruptedException, NoSuchAlgorithmException, KeyManagementException {
|
||||
public static void main(String[] args) throws IOException, InterruptedException, NoSuchAlgorithmException, KeyManagementException, ExecutionException {
|
||||
BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
|
||||
|
||||
requestClient = new Request(false);
|
||||
|
||||
@@ -3,6 +3,12 @@ package fr.motysten.usertwist.exploit.tools;
|
||||
import org.json.JSONArray;
|
||||
import org.json.JSONObject;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.concurrent.ExecutionException;
|
||||
import java.util.concurrent.ExecutorService;
|
||||
import java.util.concurrent.Executors;
|
||||
import java.util.concurrent.Future;
|
||||
import java.util.regex.Matcher;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
@@ -17,28 +23,34 @@ public class Parser {
|
||||
}
|
||||
}
|
||||
|
||||
public static void asyncGetPass(JSONArray usersArray, int rotation, boolean ignoreBots) throws InterruptedException {
|
||||
public static void asyncGetPass(JSONArray usersArray, int rotation, boolean ignoreBots) throws ExecutionException, InterruptedException {
|
||||
|
||||
ExecutorService executor = Executors.newVirtualThreadPerTaskExecutor();
|
||||
List<Future<String>> threads = new ArrayList<>();
|
||||
|
||||
for (int i = 0; i < usersArray.length(); i++) {
|
||||
|
||||
int finalI = i;
|
||||
|
||||
Runnable r = () -> parseJSON(usersArray, rotation, ignoreBots, finalI);
|
||||
|
||||
Thread t = Thread.startVirtualThread(r);
|
||||
t.join();
|
||||
Future<String> t = executor.submit(() -> parseJSON(usersArray, rotation, ignoreBots, finalI));
|
||||
threads.add(t);
|
||||
}
|
||||
for (Future<String> t : threads) {
|
||||
if (t.get() != null) {
|
||||
System.out.println(t.get());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private static void parseJSON(JSONArray usersArray, int rotation, boolean ignoreBots, int finalI) {
|
||||
private static String parseJSON(JSONArray usersArray, int rotation, boolean ignoreBots, int finalI) {
|
||||
JSONObject user = usersArray.getJSONObject(finalI);
|
||||
String login = user.getString("username");
|
||||
String password = Cesar.rotate(user.getString("data"), rotation);
|
||||
|
||||
final Matcher matcher = pattern.matcher(password);
|
||||
if (!matcher.matches() || !ignoreBots) {
|
||||
System.out.println((finalI + 1) + ". " + login + " => " + password);
|
||||
return (finalI + 1) + ". " + login + " => " + password;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user