Created
April 1, 2020 10:39
-
-
Save DemonGiggle/011cb23432bb1c0f7f98712c0371a1a4 to your computer and use it in GitHub Desktop.
Some evil android app (to de-shell it)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import java.io.ByteArrayInputStream; | |
| import java.io.ByteArrayOutputStream; | |
| import java.io.File; | |
| import java.io.FileInputStream; | |
| import java.io.FileNotFoundException; | |
| import java.io.FileOutputStream; | |
| import java.io.IOException; | |
| import java.io.InputStream; | |
| import java.util.Base64; | |
| import java.util.Base64.Decoder; | |
| import java.util.zip.InflaterInputStream; | |
| class Decode { | |
| public static void main(String args[]) { | |
| try { | |
| ByteArrayOutputStream decoded = new ByteArrayOutputStream(); | |
| InputStream inputStream = new FileInputStream("assets/enr0b7/1oo4lvs"); | |
| inputStream.skip(4L); | |
| int key = inputStream.read(); | |
| byte[] buffer = new byte[2048]; | |
| while (true) { | |
| int count = inputStream.read(buffer); | |
| if (count == -1) { | |
| inputStream.close(); | |
| break; | |
| } | |
| // xor result | |
| for (int i = 0; i < count; i++) { | |
| buffer[i] = (byte)(buffer[i] ^ key); | |
| } | |
| decoded.write(buffer, 0, count); | |
| } | |
| // inflate the string | |
| ByteArrayOutputStream outStream = new ByteArrayOutputStream(); | |
| InflaterInputStream inflater = new InflaterInputStream(new ByteArrayInputStream(decoded.toByteArray())); | |
| while (true) { | |
| int count = inflater.read(buffer); | |
| if (count == -1) { | |
| inflater.close(); | |
| break; | |
| } | |
| outStream.write(buffer, 0, count); | |
| } | |
| // decode by base64 | |
| byte[] base64Decoded = Base64.getDecoder().decode(outStream.toByteArray()); | |
| File outFile = new File("/tmp/evil.dex"); | |
| FileOutputStream outputStream = new FileOutputStream(outFile); | |
| outputStream.write(base64Decoded); | |
| outputStream.close(); | |
| } catch (FileNotFoundException e) { | |
| e.printStackTrace(); | |
| } catch (IOException e) { | |
| e.printStackTrace(); | |
| } | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment