OK so now we have a situation where we know enough about simple locker to be able to do the decryption 1
of our files. So simplocker is encrypting our files and we want to write a simple application that's 2
able to use the code that we obtained through the static analysis and decrypt the files that were encrypted 3
by simplelocker. OK. 4
So before we do that let's check our emulator just in case we didn't save the state of the emulator 5
for some reason and the files that were encrypted or not there, so let's just confirm that the file is 6
there by doing a Adb shell, CD SDcard, CD pictures 7
so we turn off our emulator and we didn't save the state. 8
So in this case the files are no longer there. No problem. 9
We can quickly go over the steps of installing simplocker. 10
We need to disconnect the Internet. 11
Go to downloads ADB install. 12
There we go. 13
So it's been installed let's just make sure that we have the SD card part in the storage enabled. 14
OK. 15
Create create create. 16
This will create the demo picture. 17
Now we're going to run simplocker, get the notification maybe give it a few seconds so it encrypts 18
our file and then we can run ADB uninstall org.simplelocker. 19
There we go. 20
Now we go to ADB shel, CD SDcard, CD pictures. 21
We will see that we have our encrypted file. OK. So now let's try to develop a simple Android application 22
that will be able to decrypt the encrypted file and the source for the Android application is going 23
to come from Simplelocker itself using static analysis. So we're going to create a new project let's call 24
it for example simple locker decryptor. 25
So here we're going to do some revision of building an Android application section if you didn't follow 26
that part, 27
It's not a problem. 28
We will be building a very simple application and most of the code actually comes from Simplocker itself 29
so the first thing we need to do we need to open the manifest and since we're going to be working with 30
the SD card the first thing we need to do is add permission so users permission Android permission dot 31
write 32
External storage. 33
OK. 34
And we closed the permission so since we're going to be writing to file we need to obviously request 35
this permission. 36
Now let's try and obtain the source code from here. 37
We have quite a lot of code that we can just copy altogether. 38
Just copy everything from a script. 39
And here we're going to add a new class and call it the same dot aes script. 40
There we go. 41
OK now we are about to see a lot of errors over here notice that we changed the package name because 42
we need the package to match our project. To save us some time. 43
I'm just going to remove the encrypt function since we are only going to be using the decrypt and let's 44
just fix the content a bit over here. 45
Let's see here you're going to have some errors where you can automatically fix and add the exception 46
with its signature. 47
Same thing over here. 48
Remember ALT + ENTER will give you the required fix here. 49
JDGUI has a weird way of passing the parameters so all you need to do is take where you see an 50
error like this. 51
Just take these parameters and pass them directly. 52
It's just the way JDGUI decompiled the passing of the parameters which is kind of breaking stuff 53
so the same thing all over. 54
We're going to take the parameter from here. 55
Pass it to here and remove the line. 56
We just need to do the same thing throughout 57
keep fixing the errors by clicking on alt and enter 58
and fix all the parameters that were passed incorrectly. 59
And that's pretty much it. 60
We have our aes script class that has the decrypt function inside it OK. 61
Now if we go back to simple locker static analysis we see file encryptor is where aes script was actually 62
being used so here he has a way of passing through all the required files. In our test, 63
we're just going to test it on one specific file, 64
the demo picture. But then in reality all you'd have to do is a method that parses through the entire 65
SD card and find all the files with DOT ENC in the file name but we don't really need to go through 66
all of this let's just copy the small part where aes script is being used so in decrypt all they're doing 67
here is initiating aes script let's actually copy all of this and we'll fix it ourselves so we're gonna 68
copy all decrypt and we're gonna paste it directly in the main class over here. 69
So here we have the function called decrypt 70
here he's initializing the class aes script. 71
Again we need to fix how their parameter is being passed instead of passing it like that we're going 72
to pass it there. 73
No need to check if storage exists for now and again we're not going to go through all the files. 74
We're just going to specify one file. 75
Let's just take the small part that we need. 76
Let's remove everything else so we're just going to call the class and then call the function decrypt 77
within the class on the file that we're specifying. So the decrypt accepts two parameters. 78
It takes a string as the file input and one as the output. That's where you're going to put the file 79
name that you want to decrypt and the output file where you want it to be decrypted to. So let's just 80
do string to decrypt equals SD card slash picture slash demo picture. 81
Dot jpeg dot ENC so that's what we want to encrypt and what we want to decrypt. 82
Let's call it dest decrypt. 83
So destination decrypt, so that's where we want to place our new file. 84
So that's the first parameter we're going to pass through the decrypt. 85
The second parameter we're gonna pass destination decrypt here we're not going to actually delete the 86
file. 87
But what they're doing is they're actually deleting the old file. 88
We're not going to delete it just in case it doesn't work. 89
So if anything we test it out with one image and if it works we'll start deleting the files but we don't 90
really want to delete. 91
Just in case the decryption doesn't work and we end up encrypting the file even more and make it unrecoverable 92
OK. 93
So let's create a method. 94
Public void on click 95
so we're gonna do an event handler here. 96
So if you remember to create and have a handler have to set it as a view and then over here let's just 97
call the decrypt which is decrypting one specific file. OK let's just add the exceptions. 98
So now on our user interface we're going to drop a button. 99
There we go. 100
No need to fix the position. 101
But we do need to just add the event listener. 102
Over here on click we're going to tell it to call the method on click that should be at let's have a 103
look. 104
OK. 105
So let's try to run the decryptor. Just click Run app or the play button depending on whether you ran 106
it before. 107
This will install the app on the emulator but before let's confirm that the file is still encrypted 108
so CD SD card slash pictures list files and yes we can see that it is encrypted. 109
Now let's click on the button in our app. List the files again and we can see that it generated a decrypted 110
file. Let's just confirm that it is decrypted run adb pull slash SD card slash pictures slash demo 111
picture.JPEG so we downloaded it we actually ran ADB from our home folder flip. 112
So let's go to flip and there is our demo picture you can see the hot air balloons. 113
So the picture has been decrypted OK. 114
So your next job would be to parse all the files in the SD card that end in dot ENC and run the 115
decrypt function on them. 116
So there you go. 117
You have your decryptor!