Skip to content

Commit

Permalink
First Commit
Browse files Browse the repository at this point in the history
  • Loading branch information
d3vchac committed Dec 26, 2023
1 parent a446595 commit cfedfaf
Show file tree
Hide file tree
Showing 52 changed files with 1,174 additions and 0 deletions.
Binary file added app/.DS_Store
Binary file not shown.
1 change: 1 addition & 0 deletions app/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
/build
44 changes: 44 additions & 0 deletions app/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
plugins {
id("com.android.application")
}

android {
namespace = "io.hakaisecurity.beerus"
compileSdk = 34

defaultConfig {
applicationId = "io.hakaisecurity.beerus"
minSdk = 24
targetSdk = 34
versionCode = 1
versionName = "1.0"

testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner"
}

buildTypes {
release {
isMinifyEnabled = true
isShrinkResources = true
proguardFiles(
getDefaultProguardFile("proguard-android-optimize.txt"),
"proguard-rules.pro"
)
}
}
compileOptions {
sourceCompatibility = JavaVersion.VERSION_1_8
targetCompatibility = JavaVersion.VERSION_1_8
}
}

dependencies {

implementation("androidx.appcompat:appcompat:1.6.1")
implementation("com.google.android.material:material:1.10.0")
implementation("androidx.constraintlayout:constraintlayout:2.1.4")
implementation("org.apache.commons:commons-compress:1.25.0")
testImplementation("junit:junit:4.13.2")
androidTestImplementation("androidx.test.ext:junit:1.1.5")
androidTestImplementation("androidx.test.espresso:espresso-core:3.5.1")
}
32 changes: 32 additions & 0 deletions app/proguard-rules.pro
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
# Add project specific ProGuard rules here.
# You can control the set of applied configuration files using the
# proguardFiles setting in build.gradle.
#
# For more details, see
# http://developer.android.com/guide/developing/tools/proguard.html

# If your project uses WebView with JS, uncomment the following
# and specify the fully qualified class name to the JavaScript interface
# class:
#-keepclassmembers class fqcn.of.javascript.interface.for.webview {
# public *;
#}

# Uncomment this to preserve the line number information for
# debugging stack traces.
#-keepattributes SourceFile,LineNumberTable

# If you keep the line number information, uncomment this to
# hide the original source file name.
#-renamesourcefileattribute SourceFile

-optimizations code/simplification/arithmetic,!code/simplification/cast,!field/*,! class/merging/*,!method/inlining/*
-optimizationpasses 5
-allowaccessmodification

-assumenosideeffects
class android.util.Log {
public static *** d(...);
public static *** i(...);
public static *** v(...);
}
Binary file added app/release/BEERUS.apk
Binary file not shown.
Binary file added app/src/.DS_Store
Binary file not shown.
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
package io.hakaisecurity.beerus;

import android.content.Context;

import androidx.test.platform.app.InstrumentationRegistry;
import androidx.test.ext.junit.runners.AndroidJUnit4;

import org.junit.Test;
import org.junit.runner.RunWith;

import static org.junit.Assert.*;

/**
* Instrumented test, which will execute on an Android device.
*
* @see <a href="http://d.android.com/tools/testing">Testing documentation</a>
*/
@RunWith(AndroidJUnit4.class)
public class ExampleInstrumentedTest {
@Test
public void useAppContext() {
// Context of the app under test.
Context appContext = InstrumentationRegistry.getInstrumentation().getTargetContext();
assertEquals("io.hakaisecurity.beerus", appContext.getPackageName());
}
}
Binary file added app/src/main/.DS_Store
Binary file not shown.
31 changes: 31 additions & 0 deletions app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools">
<!-- <uses-permission android:name="android.permission.MANAGE_EXTERNAL_STORAGE"/>-->
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.INTERNET" />

<application
android:usesCleartextTraffic="true"
android:allowBackup="true"
android:dataExtractionRules="@xml/data_extraction_rules"
android:fullBackupContent="@xml/backup_rules"
android:icon="@mipmap/ic_launcher"
android:label="@string/app_name"
android:roundIcon="@mipmap/ic_launcher_round"
android:supportsRtl="true"
android:theme="@style/Theme.Beerus"
tools:targetApi="31">
<activity
android:name=".MainActivity"
android:exported="true">
<intent-filter>
<action android:name="android.intent.action.MAIN" />

<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>

</manifest>
Binary file added app/src/main/ic_launcher-playstore.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added app/src/main/java/.DS_Store
Binary file not shown.
Binary file added app/src/main/java/io/.DS_Store
Binary file not shown.
Binary file added app/src/main/java/io/hakaisecurity/.DS_Store
Binary file not shown.
76 changes: 76 additions & 0 deletions app/src/main/java/io/hakaisecurity/beerus/FileZipper.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
package io.hakaisecurity.beerus;


import java.io.DataOutputStream;
import java.io.File;
import java.io.FileInputStream;
import java.io.IOException;
import java.net.HttpURLConnection;
import java.net.URL;
import java.util.UUID;



public class FileZipper {

public static void main(String[] args) {
String sourceFolderPath = "/data/data/" + args[0];
String serverUrl = "http://"+args[1]+":"+args[2]+"/upload";
String zipFilePath = "/data/local/tmp/" + args[0];
String timeStamp = String.valueOf(new java.util.Date().getTime());
String tarGzFilePath = zipFilePath+"_"+timeStamp+".tar.gz";

try {
Process process = Runtime.getRuntime().exec("su");
DataOutputStream outputStream = new DataOutputStream(process.getOutputStream());
outputStream.writeBytes("tar -czf "+tarGzFilePath+" "+sourceFolderPath+"\n");
outputStream.writeBytes("chmod 777 "+tarGzFilePath+"\n");
outputStream.writeBytes("exit\n");
outputStream.flush();
process.waitFor();

File file = new File(tarGzFilePath);
sendFileToServer(file, serverUrl);
} catch (Exception e) {
e.printStackTrace();
}
}

private static void sendFileToServer(File file, String serverUrl) throws IOException {
URL url = new URL(serverUrl);
HttpURLConnection connection = (HttpURLConnection) url.openConnection();
String boundary = UUID.randomUUID().toString();

connection.setRequestMethod("POST");
connection.setDoOutput(true);
connection.setRequestProperty("Content-Type", "multipart/form-data; boundary=" + boundary);

try (DataOutputStream outputStream = new DataOutputStream(connection.getOutputStream());
FileInputStream fileInputStream = new FileInputStream(file)) {

outputStream.writeBytes("--" + boundary + "\r\n");
outputStream.writeBytes("Content-Disposition: form-data; name=\"file\"; filename=\"" + file.getName() + "\"\r\n");
outputStream.writeBytes("Content-Type: application/x-gzip\r\n\r\n");

byte[] buffer = new byte[4096];
int bytesRead;
while ((bytesRead = fileInputStream.read(buffer)) != -1) {
outputStream.write(buffer, 0, bytesRead);
}

outputStream.writeBytes("\r\n");
outputStream.writeBytes("--" + boundary + "--\r\n");

outputStream.flush();

int responseCode = connection.getResponseCode();
if (responseCode == HttpURLConnection.HTTP_OK) {
System.out.println("File sent successfully");
} else {
System.err.println("Failed to send the file. Response Code: " + responseCode);
}
} finally {
connection.disconnect();
}
}
}
Loading

0 comments on commit cfedfaf

Please sign in to comment.