Skip to content

Commit 7f2ede7

Browse files
committed
feat: set Exploit App run duration
1 parent 83b58a3 commit 7f2ede7

8 files changed

Lines changed: 48 additions & 31 deletions

File tree

.env.sample

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,4 +18,5 @@ DROIDGROUND_SHUTDOWN_DISABLED=false # Feature enabled by default if not set othe
1818
DROIDGROUND_START_ACTIVITY_DISABLED=false # Feature enabled by default if not set otherwise
1919
DROIDGROUND_START_RECEIVER_DISABLED=false # Feature enabled by default if not set otherwise
2020
DROIDGROUND_START_SERVICE_DISABLED=false # Feature enabled by default if not set otherwise
21-
DROIDGROUND_TERMINAL_DISABLED=false # Feature enabled by default if not set otherwise
21+
DROIDGROUND_TERMINAL_DISABLED=false # Feature enabled by default if not set otherwise
22+
DROIDGROUND_EXPLOIT_APP_DURATION=10 # The time (in seconds) the exploit app will be active before the target app is restarted. This field makes sense only if the App Manager is enabled. Default value is 10

README.md

Lines changed: 24 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -75,29 +75,30 @@ Almost all features are **modular** and defined via environment variables, ensur
7575

7676
The `.env.sample` file in the root directory is a good starting point. This is the full list of all env variables currently supported:
7777

78-
| Variable | Description | Default |
79-
| ------------------------------------- | -------------------------------------------------- | ----------- |
80-
| `DROIDGROUND_APP_PACKAGE_NAME` | Package name of target app | - |
81-
| `DROIDGROUND_ADB_HOST` | ADB host | `localhost` |
82-
| `DROIDGROUND_ADB_PORT` | ADB port | `5037` |
83-
| `DROIDGROUND_DEVICE_TYPE` | `usb` or `network` | `usb` |
84-
| `DROIDGROUND_DEVICE_HOST` | IP of Android device (`adb`) (network mode only) | - |
85-
| `DROIDGROUND_DEVICE_PORT` | port of Android device (`adb`) (network mode only) | - |
86-
| `DROIDGROUND_INIT_SCRIPTS_FOLDER` | Folder containing `setup.sh` and `reset.sh` | `/init.d` |
87-
| `DROIDGROUND_HOST` | Bind address | `0.0.0.0` |
88-
| `DROIDGROUND_PORT` | Bind port | `4242` |
89-
| `DROIDGROUND_APP_MANAGER_DISABLED` | Disable app manager | `false` |
90-
| `DROIDGROUND_BUG_REPORT_DISABLED` | Disable bugreport | `false` |
91-
| `DROIDGROUND_FILE_BROWSER_DISABLED` | Disable file browser | `false` |
92-
| `DROIDGROUND_FRIDA_DISABLED` | Disable Frida support | `false` |
93-
| `DROIDGROUND_FRIDA_TYPE` | `jail` or `full` | `jail` |
94-
| `DROIDGROUND_LOGCAT_DISABLED` | Disable logcat | `false` |
95-
| `DROIDGROUND_REBOOT_DISABLED` | Disable reboot | `false` |
96-
| `DROIDGROUND_SHUTDOWN_DISABLED` | Disable shutdown | `false` |
97-
| `DROIDGROUND_START_ACTIVITY_DISABLED` | Disable startActivity | `false` |
98-
| `DROIDGROUND_START_RECEIVER_DISABLED` | Disable broadcast | `false` |
99-
| `DROIDGROUND_START_SERVICE_DISABLED` | Disable startService | `false` |
100-
| `DROIDGROUND_TERMINAL_DISABLED` | Disable terminal | `false` |
78+
| Variable | Description | Default |
79+
| ------------------------------------- | ---------------------------------------------------- | ----------- |
80+
| `DROIDGROUND_APP_PACKAGE_NAME` | Package name of target app | - |
81+
| `DROIDGROUND_ADB_HOST` | ADB host | `localhost` |
82+
| `DROIDGROUND_ADB_PORT` | ADB port | `5037` |
83+
| `DROIDGROUND_DEVICE_TYPE` | `usb` or `network` | `usb` |
84+
| `DROIDGROUND_DEVICE_HOST` | IP of Android device (`adb`) (network mode only) | - |
85+
| `DROIDGROUND_DEVICE_PORT` | port of Android device (`adb`) (network mode only) | - |
86+
| `DROIDGROUND_INIT_SCRIPTS_FOLDER` | Folder containing `setup.sh` and `reset.sh` | `/init.d` |
87+
| `DROIDGROUND_HOST` | Bind address | `0.0.0.0` |
88+
| `DROIDGROUND_PORT` | Bind port | `4242` |
89+
| `DROIDGROUND_APP_MANAGER_DISABLED` | Disable app manager | `false` |
90+
| `DROIDGROUND_BUG_REPORT_DISABLED` | Disable bugreport | `false` |
91+
| `DROIDGROUND_FILE_BROWSER_DISABLED` | Disable file browser | `false` |
92+
| `DROIDGROUND_FRIDA_DISABLED` | Disable Frida support | `false` |
93+
| `DROIDGROUND_FRIDA_TYPE` | `jail` or `full` | `jail` |
94+
| `DROIDGROUND_LOGCAT_DISABLED` | Disable logcat | `false` |
95+
| `DROIDGROUND_REBOOT_DISABLED` | Disable reboot | `false` |
96+
| `DROIDGROUND_SHUTDOWN_DISABLED` | Disable shutdown | `false` |
97+
| `DROIDGROUND_START_ACTIVITY_DISABLED` | Disable startActivity | `false` |
98+
| `DROIDGROUND_START_RECEIVER_DISABLED` | Disable broadcast | `false` |
99+
| `DROIDGROUND_START_SERVICE_DISABLED` | Disable startService | `false` |
100+
| `DROIDGROUND_TERMINAL_DISABLED` | Disable terminal | `false` |
101+
| `DROIDGROUND_EXPLOIT_APP_DURATION` | The time (in seconds) the exploit app will be active | `10` |
101102

102103
## 🧩 Use Cases
103104

src/client/components/StartExploitAppModal.tsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,8 @@ export const StartExploitAppModal: React.FC<IModalProps> = ({ dialogRef }) => {
5454
<h3 className="font-bold text-lg mb-4">Start Exploit App</h3>
5555
<p className="mb-4">
5656
This will allow you start one of the installed apps as the <b>Exploit App</b>. <br />
57-
The app will stay active for 10 seconds and then the <b>Target App</b> will be restarted.
57+
The app will stay active for the amount of time selected by the host and then the <b>Target App</b> will be
58+
restarted.
5859
</p>
5960
<form onSubmit={handleSubmit(startExploitApp)} className="space-y-4">
6061
<input

src/server/api/controller.ts

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ import {
3333
} from "@server/utils/helpers";
3434
import { capitalize, sleep } from "@shared/helpers";
3535
import { CompanionClient } from "@server/companion";
36-
import { BUGREPORT_FILENAME, DEFAULT_UPLOAD_FOLDER } from "@server/config";
36+
import { BUGREPORT_FILENAME, DEFAULT_UPLOAD_FOLDER, SECOND } from "@server/config";
3737
import { CompanionAttackSurfaceResponse } from "@server/utils/types";
3838
import { loadFridaLibrary } from "@server/utils/frida";
3939

@@ -510,15 +510,17 @@ class APIController {
510510
try {
511511
const body = req.body as StartExploitAppRequest;
512512
const singleton = ManagerSingleton.getInstance();
513+
const config = singleton.getConfig();
514+
const duration = config.features.exploitAppDuration;
513515

514516
const { packageName: exploitApp } = body;
515517
await singleton.runAppByPackageName(exploitApp);
516518

517-
res.json({ result: "Exploit app correctly started, it will be up for 10 seconds" }).end();
519+
res.json({ result: `Exploit app correctly for ${duration} seconds` }).end();
518520
responseSent = true;
519521

520-
await sleep(10 * 1000);
521-
Logger.info("10 seconds have passed, restarting target app...");
522+
await sleep(duration * SECOND);
523+
Logger.info(`${duration} seconds have passed, restarting target app...`);
522524
await singleton.runTargetApp();
523525
} catch (error: any) {
524526
Logger.error(`Error starting exploit app: ${error}`);

src/server/config/constants.ts

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
/*
2+
Configuration file containing constants
3+
Convention: constants are declared in UPPERCASE
4+
Usage: import { CONSTANT_NAME } from '@/config'
5+
*/
6+
7+
export const SECOND = 1000;

src/server/config/index.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1 +1,2 @@
11
export * from "@server/config/resources";
2+
export * from "@server/config/constants";

src/server/manager.ts

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,12 +39,13 @@ export class ManagerSingleton {
3939

4040
private constructor() {
4141
// private constructor prevents direct instantiation
42-
const port = process.env.DROIDGROUND_ADB_PORT ?? "";
42+
const port: any = process.env.DROIDGROUND_ADB_PORT ?? "";
43+
const exploitAppDuration: any = process.env.DROIDGROUND_EXPLOIT_APP_DURATION ?? "";
4344
this.config = {
4445
packageName: process.env.DROIDGROUND_APP_PACKAGE_NAME ?? "",
4546
adb: {
4647
host: process.env.DROIDGROUND_ADB_HOST ?? "localhost",
47-
port: isNaN(port as any) || port.trim().length === 0 ? 5037 : parseInt(port),
48+
port: isNaN(port) || port.trim().length === 0 ? 5037 : parseInt(port),
4849
},
4950
features: {
5051
appManagerEnabled: !(process.env.DROIDGROUND_APP_MANAGER_DISABLED === "true"),
@@ -59,6 +60,8 @@ export class ManagerSingleton {
5960
startServiceEnabled: !(process.env.DROIDGROUND_START_SERVICE_DISABLED === "true"),
6061
terminalEnabled: !(process.env.DROIDGROUND_TERMINAL_DISABLED === "true"),
6162
fridaType: process.env.DROIDGROUND_FRIDA_TYPE === "full" ? "full" : "jail",
63+
exploitAppDuration:
64+
isNaN(exploitAppDuration) || exploitAppDuration.trim().length === 0 ? 10 : parseInt(exploitAppDuration),
6265
},
6366
};
6467
}

src/shared/types.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ export interface DroidGroundFeatures {
1414
terminalEnabled: boolean;
1515
logcatEnabled: boolean;
1616
fridaType: "full" | "jail";
17+
exploitAppDuration: number;
1718
}
1819

1920
export interface DroidGroundConfig {

0 commit comments

Comments
 (0)