> For the complete documentation index, see [llms.txt](https://0xsec.gitbook.io/0xsec/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://0xsec.gitbook.io/0xsec/malware-analysis/2026-02-01-androrat.md).

# AndroRAT Android Malware Analysis

### Overview

Androrat is a remote administration tool developed in Java Android for the client side and in Java/Swing for the Server. The name Androrat is a mix of Android and RAT (Remote Access Tool). It has been developed in a team of 4 for a university project. The goal of the application is to give the control of the android system remotely and retrieve informations from it.

SAMPLE - `c5ab0adaedf391a395387df33b0bf6854f1ccc9c5da937915ea86b5eec6e6103`

### Static Analysis

After extracting zip I directly jumped for analysis and while examining decompiled apk, I saw that malware isn't obfuscated which made work easy. So, I started my analysis from `AndroidManifest.xml` because its where permissions are declared and there i saw some permissions like `READ/WRITE_EXTERNAL_STORAGE, READ_SMS, RECORD_AUDIO, READ_CALL_LOG, ACCESS_FINE_LOCATION` and one major thing that caught my attention was permission for `CAMERA` and certain other like `jobScheduler` and a code `1337` something `SECRET_CODE` that the malware listens.

<figure><img src="/files/M3NQ9jw7Wp9gj75uWjxf" alt=""><figcaption></figcaption></figure>

<p align="center"><em>Figure 1: Dangerous Permissions</em></p>

<figure><img src="/files/Fmo2MNiGGHoOfBSdwTAT" alt=""><figcaption></figcaption></figure>

<p align="center"><em>Figure 2: SECRET_CODE and Job Scheduling</em></p>

<figure><img src="/files/oJuZyiNLQRQRc3FnBzNy" alt=""><figcaption></figcaption></figure>

<p align="center"><em>Figure 3: Creates a TCP connection to C2 server</em></p>

In the `config` of the apk there is initilization of IP and PORT like `192.169.x.x` and `8000` now coming to `MainActivity` it makes a TCP connection to the C2 server when `onCreate` is executed.

<figure><img src="/files/CVAwr5EbyIWGDFKcP7SQ" alt=""><figcaption></figcaption></figure>

<p align="center"><em>Figure 4: Initilize shell, audio/video manager</em></p>

Tracing the `tcpConnection` it shows how this malware works, there are initilization of `shell, IPAddr, audioManager, videoRecorder, so on` lets analyze them one by one. First, `ipAddr` it has two functions `getMACAddress` which return a MAC address and `getIPAdress` which return a IP, we will see it in upcoming code.

<figure><img src="/files/97BoqQafFYchwaaBJTxQ" alt=""><figcaption></figcaption></figure>

<p align="center"><em>Figure 5: Recording audio and storing in cache dir</em></p>

<figure><img src="/files/ZGH1rQJqYJXxzPTc8mb1" alt=""><figcaption></figcaption></figure>

<p align="center"><em>Figure 6: Encodes audio in base64 and attach END123 marker</em></p>

Now, in `audioManager` there are function responsible for recording audio and saving it. One of the function `startRecording` which records audio only if the `BUILD.VERSION` is greater than or equal 26 otherwise `Lower Android SDK Cant Record Audio` and it records audio in `.mpeg4` format and stores in **cache** directory. When `stopRecording` is called it converts the audio data into **base64** for transmission and write `END123` at end of it, it act as marker that server look for and once transmission is completed it stops `audioManager`. `videoRecorder` utlizes similar approach to record video in `.mp4` and rest is similar.

<figure><img src="/files/tNlBSaEDo74GcTYfXtSW" alt=""><figcaption></figcaption></figure>

<p align="center"><em>Figure 7: Extracts critical infomartions</em></p>

<figure><img src="/files/1SaZHpkN1GVU6qWv7vgX" alt=""><figcaption></figcaption></figure>

<p align="center"><em>Figure 8: Extracts phone number</em></p>

Now there is a function `functions` which extracts all the information about the phone including `Model, IMEI, Phone Number of each sim, Brand, Manufacturer, so on` also there is a function `readFromClipboard` which reads the content of clipboard of user that might get to info like **passowrds, OTP**. A `jobScheduler` function to schedule the malware to start automatically.

<figure><img src="/files/y8cBqPeq7F36mqUvHgne" alt=""><figcaption></figcaption></figure>

<p align="center"><em>Figure 9: Clicks photo using phone's camera</em></p>

Afterwards, there is `cameraPreview` function which click photo and sends to server using same encoding on **jpeg** image and attaching `END123` marker to it.

<figure><img src="/files/wGyMQCsYEAg0CmskIl6c" alt=""><figcaption></figcaption></figure>

<p align="center"><em>Figure 10: Reads messages</em></p>

Now `readSMS` reads all the messages from **Android system SMS databse** including Bank OTP, and other confidential information. And with `locationManager` it points out the exact latitude and logitude of user using gps and netowrk location. Using `readCallLogs` it reads all the call history of the user including whom user talked to, duration of call, date of it and phone number of other user by reading `content://call_log/calls` system call log database.

<figure><img src="/files/sKT9pqA0gt2htPD4EcTm" alt=""><figcaption></figcaption></figure>

<p align="center"><em>Figure 11: Sends encoded data to C2 server</em></p>

Now `newShell` is responsible for sending all the encoded data including messages, clipboard, call\_logs from `/sdcard/temp` to the C2 server. Coming back to `tcpConnection` there is a function `doInBackground` which keeps the connection between server and victim and in in case phone got disconncted from newtork, it won't stop it will keep trying indefinitely unless gets the connection back. When the server gots the connection it will show a message to server `Hello there, welcome to reverse shell of XXXX` with model specific.

<figure><img src="/files/Dzstdl2Fdv0iID2njdK8" alt=""><figcaption></figcaption></figure>

<p align="center"><em>Figure 12: Commands attacker can send to victim</em></p>

Then a infinite loop starts which will keeps asking of inputs but exits when a **null** is provided, it has commands such as `camList, takepic \\d, shell, getClipData, deviceInfo, getIP, getSimDetails, getSMS, vibrate, getLocation, start/stop audio/video, getCallLogs` which will provided each confidential information to the attacker and the most critical command was **shell** through which the attacker can even get a shell to victim's device.

### Dynamic Analysis

For dynamic analysis, since the ip which was given is a private dummy ip so I changed that IP to my laptop's IP so that i can test it. I have rebuild and signed the apk again with my configuration for testing. After i installed and open app in my spare phone i got a call back from my device.

<figure><img src="/files/j8CqVdG0qSzL9Ns6SoMT" alt=""><figcaption></figcaption></figure>

<p align="center"><em>Figure 13: Call back from android device</em></p>

Also tried the above found commands and everything is working as it was intended.

<figure><img src="/files/YUFsiQpGIeMW3ROuIkkB" alt=""><figcaption></figcaption></figure>

<p align="center"><em>Figure 14: Working commands</em></p>

### IOCs

* IP - `192.168.x.x`
* PORT - `8000`
* C2 COMMANDS - `getLocation, deviceInfo, shell, camList, getClipData`


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

```
GET https://0xsec.gitbook.io/0xsec/malware-analysis/2026-02-01-androrat.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
