File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -20,6 +20,7 @@ import {
2020 GetFilesResponse ,
2121 IGenericErrRes ,
2222 IGenericResultRes ,
23+ NewTeamResponse ,
2324 StartActivityRequest ,
2425 StartBroadcastRequest ,
2526 StartExploitAppRequest ,
@@ -70,6 +71,19 @@ class APIController {
7071 }
7172 } ;
7273
74+ newTeam : RequestHandler = async ( req : Request , res : Response < NewTeamResponse | IGenericErrRes > ) => {
75+ Logger . info ( `Received ${ req . method } request on ${ req . path } ` ) ;
76+ try {
77+ const singleton = ManagerSingleton . getInstance ( ) ;
78+ const teamToken = singleton . addTeam ( ) ;
79+
80+ res . json ( { teamToken } ) . end ( ) ;
81+ } catch ( error : any ) {
82+ Logger . error ( `Error generating new Team Token: ${ error } ` ) ;
83+ res . status ( 500 ) . json ( { error : "An error occurred while generating a new Team Token" } ) . end ( ) ;
84+ }
85+ } ;
86+
7387 restartApp : RequestHandler = async ( req : Request , res : Response < IGenericResultRes | IGenericErrRes > ) => {
7488 Logger . info ( `Received ${ req . method } request on ${ req . path } ` ) ;
7589 try {
Original file line number Diff line number Diff line change @@ -73,6 +73,7 @@ export default (app: Router) => {
7373 APIController . enqueueStartExploitApp ,
7474 ) ;
7575 endpoint . post ( E . RESET , checkFeatureEnabled ( features . resetEnabled ) , APIController . reset ) ;
76+ endpoint . post ( E . NEW_TEAM , checkFeatureEnabled ( features . unlimitedTeams ) , APIController . newTeam ) ;
7677 endpoint . get ( E . FEATURES , APIController . features ) ;
7778 endpoint . get ( E . INFO , APIController . info ) ;
7879 endpoint . post ( E . RESTART , APIController . restartApp ) ;
Original file line number Diff line number Diff line change @@ -86,7 +86,8 @@ export class ManagerSingleton {
8686 startServiceEnabled : ! ( process . env . DROIDGROUND_START_SERVICE_DISABLED === "true" ) ,
8787 terminalEnabled : ! ( process . env . DROIDGROUND_TERMINAL_DISABLED === "true" ) ,
8888 resetEnabled : ! ( process . env . DROIDGROUND_RESET_DISABLED === "true" ) ,
89- teamModeEnabled : teamNum > 0 ,
89+ teamModeEnabled : teamNum > 0 || teamNum === - 1 ,
90+ unlimitedTeams : teamNum === - 1 ,
9091 fridaType : process . env . DROIDGROUND_FRIDA_TYPE === "full" ? "full" : "jail" ,
9192 exploitAppDuration :
9293 isNaN ( exploitAppDuration ) || exploitAppDuration . trim ( ) . length === 0 ? 10 : parseInt ( exploitAppDuration ) ,
@@ -217,6 +218,19 @@ export class ManagerSingleton {
217218 return tokens ;
218219 }
219220
221+ public addTeam ( ) : string {
222+ let teamToken = "" ;
223+ while ( true ) {
224+ teamToken = randomString ( 32 ) ;
225+ const el = this . config . teams . find ( t => t . token === teamToken ) ;
226+ if ( el === undefined ) {
227+ break ;
228+ }
229+ }
230+ this . config . teams . push ( { token : teamToken , exploitApps : [ ] } ) ;
231+ return teamToken ;
232+ }
233+
220234 private async checkPackage ( ) {
221235 const adb = this . adb as Adb ;
222236 const res = await adb . subprocess . noneProtocol . spawnWaitText ( `pm list packages | grep ${ this . config . packageName } ` ) ;
Original file line number Diff line number Diff line change @@ -100,3 +100,7 @@ export interface GetAttackSurfaceRequest {
100100export interface TeamTokenGenericRequest {
101101 teamToken : string ;
102102}
103+
104+ export interface NewTeamResponse {
105+ teamToken : string ;
106+ }
Original file line number Diff line number Diff line change @@ -4,6 +4,7 @@ export const REST_API_ENDPOINTS = {
44 INFO : "/info" ,
55 RESTART : "/restart" , // restart the target app
66 ACTIVITY : "/activity" ,
7+ NEW_TEAM : "/newTeam" ,
78 BROADCAST : "/broadcast" ,
89 SERVICE : "/service" ,
910 DIALOGS : "/closeDialogs" ,
Original file line number Diff line number Diff line change @@ -16,6 +16,7 @@ export interface DroidGroundFeatures {
1616 logcatEnabled : boolean ;
1717 resetEnabled : boolean ;
1818 teamModeEnabled : boolean ;
19+ unlimitedTeams : boolean ;
1920 fridaType : "full" | "jail" ;
2021 exploitAppDuration : number ;
2122 ipAddress : string ;
You can’t perform that action at this time.
0 commit comments