evilfactorylabs

Cover image for Reverse Bitwise - Gemastik14 CTF
Purgatorio
Purgatorio

Posted on

Reverse Bitwise - Gemastik14 CTF

Kemarin pas pemanasan gemastik14 kebagian soal reverse engineering, langsung aja bedah

Soal :

import java.util.*;

public class KodeBit {
  public static void main(String[] args) {
    System.out.print("Enter Password: ");
    Scanner s = new Scanner(System.in);
    String user_key = s.next();
    if (user_key.length() != 16) {
      System.out.println("Wrong");
      return;
    }

    char[] verify_arr = {131,195,194,67,1,225,66,2,73,233,0,35,33,9,193,192};

    ArrayList<Character> user_arr = new ArrayList<Character>();
    char[] user_submitted_arr = user_key.toCharArray();

    for (char ch : user_submitted_arr) {
      user_arr.add((char)((((ch << 5) | (ch >> 3)) ^ 111) & 255));
    }

    int i;
    for(i = 0; i < 16; i++) {
      if (!user_arr.get(i).equals((char)verify_arr[i])) {
        System.out.println("Wrong");
        return;
      }
    }
    System.out.println("Success");
  }
}
Enter fullscreen mode Exit fullscreen mode

the key is here :

 for (char ch : user_submitted_arr) {
      user_arr.add((char)((((ch << 5) | (ch >> 3)) ^ 111) & 255));
    }
Enter fullscreen mode Exit fullscreen mode

Buat solving pake python :

verify_arr = [131,195,194,67,1,225,66,2,73,233,0,35,33,9,193,192]
key = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]

for i in range(16):
    for k in range(128):
        if verify_arr[i] == (((k << 5) | (k >> 3)) ^ 111) & 255:
            key[i] = chr(k)

flag = ''
for i in key:
    flag += i

print(flag)
Enter fullscreen mode Exit fullscreen mode

Flag : gemastik14{br3u}

Top comments (3)

Collapse
 
ri7nz profile image
RiN

Mang tagnya typo untuk #reverseengginering !== #reverseengineering

Collapse
 
recursive profile image
Purgatorio

oooh oke, makasih infonya

Collapse
 
ri7nz profile image
RiN

Thank you!