Compare commits
	
		
			3 Commits
		
	
	
		
			new_caesar
			...
			a1e1caff5d
		
	
	| Author | SHA1 | Date | |
|---|---|---|---|
| a1e1caff5d | |||
| e22dec88a5 | |||
| a757b08722 | 
@@ -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();
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user