Created
October 14, 2025 19:52
-
-
Save ljamel/1e990b1f084cd93af79a6c5963dfc4da to your computer and use it in GitHub Desktop.
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
| #!/bin/bash | |
| # Script pour générer un APK pour ensuite l'utiliser avec metasploit | |
| set -e | |
| # === CONFIGURATION === | |
| PROJECT_NAME="MyApp" | |
| PACKAGE_NAME="org.example.app" | |
| MIN_SDK=24 | |
| TARGET_SDK=34 | |
| VERSION_CODE=1 | |
| VERSION_NAME="1.0" | |
| # Chemin vers ton SDK Android (à adapter selon ton installation) | |
| ANDROID_SDK_PATH="/home/lamri/Android/Sdk" | |
| # === CREATION DU PROJET === | |
| rm -rf $PROJECT_NAME | |
| mkdir -p $PROJECT_NAME/app/src/main/java/org/example | |
| mkdir -p $PROJECT_NAME/app/src/main/res/layout | |
| cd $PROJECT_NAME | |
| # settings.gradle.kts | |
| cat > settings.gradle.kts <<EOF | |
| pluginManagement { | |
| repositories { | |
| google() | |
| mavenCentral() | |
| gradlePluginPortal() | |
| } | |
| } | |
| rootProject.name = "$PROJECT_NAME" | |
| include(":app") | |
| EOF | |
| # build.gradle.kts compatible Gradle 9 + AGP 8.2 | |
| cat > app/build.gradle.kts <<EOF | |
| plugins { | |
| id("com.android.application") version "8.2.0" | |
| } | |
| android { | |
| namespace = "$PACKAGE_NAME" | |
| compileSdk = $TARGET_SDK | |
| defaultConfig { | |
| applicationId = "$PACKAGE_NAME" | |
| minSdk = $MIN_SDK | |
| targetSdk = $TARGET_SDK | |
| versionCode = $VERSION_CODE | |
| versionName = "$VERSION_NAME" | |
| } | |
| buildTypes { | |
| release { | |
| isMinifyEnabled = false | |
| } | |
| } | |
| } | |
| repositories { | |
| google() | |
| mavenCentral() | |
| } | |
| EOF | |
| # MainActivity.java minimal | |
| cat > app/src/main/java/org/example/MainActivity.java <<EOF | |
| package org.example; | |
| import android.app.Activity; | |
| import android.os.Bundle; | |
| import android.widget.TextView; | |
| public class MainActivity extends Activity { | |
| @Override | |
| protected void onCreate(Bundle savedInstanceState) { | |
| super.onCreate(savedInstanceState); | |
| TextView tv = new TextView(this); | |
| tv.setText("Hello Android!"); | |
| setContentView(tv); | |
| } | |
| } | |
| EOF | |
| # AndroidManifest.xml minimal corrigé (sans ic_launcher) | |
| cat > app/src/main/AndroidManifest.xml <<EOF | |
| <manifest xmlns:android="http://schemas.android.com/apk/res/android"> | |
| <application | |
| android:label="$PROJECT_NAME"> | |
| <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> | |
| EOF | |
| cat > local.properties <<EOF | |
| sdk.dir=$ANDROID_SDK_PATH | |
| EOF | |
| # Gradle wrapper compatible | |
| gradle wrapper --gradle-version 9.1.0 --distribution-type bin | |
| # Construire APK debug | |
| ./gradlew assembleDebug | |
| echo "APK généré : app/build/outputs/apk/debug/app-debug.apk" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment