Anyone have an idea?

I’m doing crimediggers of the Dutch police.
This is a java script decompiled from an APK.
I think I need to use this script to decrypt a csv with encrypted messages.

the java script:

package com.agilefaqs.chatapp;

import android.util.Base64;
import java.util.Arrays;

public class Crypter {
private String key = "ULRIEKE";

public String encrypt(String s) {
    return base64Encode(xorWithKey(s.getBytes(), this.key.getBytes()));
}

public String decrypt(String s) {
    return new String(xorWithKey(base64Decode(s), this.key.getBytes()));
}

private byte[] xorWithKey(byte[] a, byte[] key2) {
    byte[] out = new byte[a.length];
    for (int i = 0; i < a.length; i++) {
        out[i] = (byte) (a[i] ^ key2[i % key2.length]);
    }
    return out;
}

private byte[] base64Decode(String s) {
    return Base64.decode(s, 0);
}

private String base64Encode(byte[] bytes) {
    return Arrays.toString(Base64.encode(bytes, 0));
}

the first few lines from the csv:
id,message,contact_id,sender,received
1,HSkmaSkkKiU4cjwsP2UxKXIhJCUhdWpyIC5rMjApJmkrIiAhbD8sIDllIiU3aSwgZT4tPGkzLjchPj08Mi4re2wQLCtrICdsKCwuLjd1OjMnZS8kIWw7ImU8Kicoci4gPSo5KzZlZT0kOygzKDdrITw4cicwJigwPnxpDS4pJWw/LGlrJDk/JjwnJywwKiZnZRIc,1,-2,2020-05-10 13:30:00
2,DBV+aSwgZSIlPmkvLmUyPjMoImstMCAiLCtnZTgtMztlIi51OzcsMWsrPCkmaS0kIHtsAig2ayI6KTZpKjtlPykoLCkta3UFOWkhJCB1OzM9ZSIudSczJ2s=,1,-2,2020-05-10 13:57:00
3,HCdyJCouMXU5cjMsLit7bBosMWs2JSU4PWUmIHtsFztlIjZ1IjssKCorMWwzJyEuNyZsNydlJiw/InIlID0gO2w7OmUiK3UrNz8kKjd7bBMlNj8wNyA7LCM/a3V+YnN2e2V6bBsE,1,-2,2020-06-05 20:07:00
4,HCdyIiomZTA+cigkJWt1BD08ZSMqOjx8aQ0uMXUnPSQxayI6KTZn,1,-2,2020-06-05 20:08:00
5,DBV+aSwgZTcpPGkqO2UxKXIoIywgJjwgJi4uK3U8PiwuZWUSPj0sKy5lPy0hZ2UcJDQ+cisgJWU/JTh2,1,-2,2020-06-05 20:32:00
6,DBV+aS8uZTcpNiYgJyEwbCQoKy8kNCtyPSooLWpsGychIjY2JHIkKHRlHCdyMywuZT8pcicgOSIwIiFnZRgIBmw/LGUqKSZsOCxlLywhbDAsNyImPThyISApMXUrNyI3LiIwIg==,1,-2,2020-06-05 20:35:00
7,GS0zPWUiICE/ciEqOSA7bDMlNmsvMGw2IDFrKTApIT1rawQ5P3IgLmszOiMgaSgkNzIpPGkrIiAhP3IhKiQ3eWwhKi0qLjAgciAuayEwbCImKSIxPClyICtlZQ==,1,-2,2020-06-05 20:48:00
8,M3I5em15fG0eNAw1fDMbO3o=,1,-2,2020-08-29 19:08:00
9,Di00KyAuKTElPC4Y,2,1,2019-04-04 19:04:12

How can I make sure that java script can be used to decrypt that csv?

That is Java code, not Javascript. Basically, they have given the code logic of how they encrypted the data. I do see the decrypt function so you may try to compile this java code and run the program with input being the encrypted text from the csv file and call decrypt() function from the Java program. If you have good knowledge fo crypto then you can do that without even running this program by just understanding how they encrypted it and then reverse that. I am not good with crypto tho

1 Like

Thanks for the hint in the right direction. I wasn’t looking in the right direction because I was talking about Java script instead of Java code. I was able to complete 6 out of 10 assignments with what I learned here at StationX. (really cool) but now I’m stuck at objective 7. But probably this hint will get me somewhere :slight_smile: Thanks again!

I have found the solution.
It’s Base64 to Xor.
Then decrypt Xor with the key ULRIEKE.
I’m happy again lol.

1 Like