-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
52 changed files
with
1,174 additions
and
0 deletions.
There are no files selected for viewing
Binary file not shown.
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
/build |
This file contains 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
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") | ||
} |
This file contains 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
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 not shown.
Binary file not shown.
26 changes: 26 additions & 0 deletions
26
app/src/androidTest/java/io/hakaisecurity/beerus/ExampleInstrumentedTest.java
This file contains 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
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 not shown.
This file contains 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
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> |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file not shown.
Binary file not shown.
Binary file not shown.
This file contains 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
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(); | ||
} | ||
} | ||
} |
Oops, something went wrong.