@@ -10,6 +10,7 @@ import { ReadableStream } from "@yume-chan/stream-extra";
1010import Logger from "@shared/logger" ;
1111import { ManagerSingleton } from "@server/manager" ;
1212import {
13+ ActionResponse ,
1314 BugreportzStatusResponse ,
1415 CompanionPackageInfos ,
1516 DeviceInfoResponse ,
@@ -53,7 +54,7 @@ class APIController {
5354 Logger . info ( `Received ${ req . method } request on ${ req . path } ` ) ;
5455 try {
5556 const singleton = ManagerSingleton . getInstance ( ) ;
56- const resetDone = singleton . resetCtf ( ) ;
57+ const resetDone = await singleton . resetCtf ( ) ;
5758 if ( ! resetDone ) {
5859 res . status ( 500 ) . json ( { error : "An error occurred while resetting the CTF" } ) . end ( ) ;
5960 return ;
@@ -119,7 +120,7 @@ class APIController {
119120 }
120121 } ;
121122
122- startActivity : RequestHandler = async ( req : Request , res : Response < IGenericResultRes | IGenericErrRes > ) => {
123+ startActivity : RequestHandler = async ( req : Request , res : Response < ActionResponse | IGenericErrRes > ) => {
123124 Logger . info ( `Received ${ req . method } request on ${ req . path } ` ) ;
124125 try {
125126 const body = req . body as StartActivityRequest ;
@@ -186,14 +187,14 @@ class APIController {
186187 Logger . debug ( `Running command: "${ command } "` ) ;
187188 const adb = await ManagerSingleton . getInstance ( ) . getAdb ( ) ;
188189 const result = await adb . subprocess . noneProtocol . spawnWaitText ( command ) ;
189- res . json ( { result : result } ) . end ( ) ;
190+ res . json ( { command , result } ) . end ( ) ;
190191 } catch ( error : any ) {
191192 Logger . error ( `Error starting activity: ${ error } ` ) ;
192193 res . status ( 500 ) . json ( { error : "An error occurred while starting the activity." } ) . end ( ) ;
193194 }
194195 } ;
195196
196- startBroadcast : RequestHandler = async ( req : Request , res : Response < IGenericResultRes | IGenericErrRes > ) => {
197+ startBroadcast : RequestHandler = async ( req : Request , res : Response < ActionResponse | IGenericErrRes > ) => {
197198 Logger . info ( `Received ${ req . method } request on ${ req . path } ` ) ;
198199 try {
199200 const body = req . body as StartBroadcastRequest ;
@@ -237,14 +238,14 @@ class APIController {
237238 Logger . debug ( `Running command: "${ command } "` ) ;
238239 const adb = await ManagerSingleton . getInstance ( ) . getAdb ( ) ;
239240 const result = await adb . subprocess . noneProtocol . spawnWaitText ( command ) ;
240- res . json ( { result : result } ) . end ( ) ;
241+ res . json ( { command , result } ) . end ( ) ;
241242 } catch ( error : any ) {
242243 Logger . error ( `Error starting broadcast: ${ error } ` ) ;
243244 res . status ( 500 ) . json ( { error : "An error occurred while starting the broadcast." } ) . end ( ) ;
244245 }
245246 } ;
246247
247- startService : RequestHandler = async ( req : Request , res : Response < IGenericResultRes | IGenericErrRes > ) => {
248+ startService : RequestHandler = async ( req : Request , res : Response < ActionResponse | IGenericErrRes > ) => {
248249 Logger . info ( `Received ${ req . method } request on ${ req . path } ` ) ;
249250 try {
250251 const body = req . body as StartServiceRequest ;
@@ -288,7 +289,7 @@ class APIController {
288289 Logger . debug ( `Running command: "${ command } "` ) ;
289290 const adb = await ManagerSingleton . getInstance ( ) . getAdb ( ) ;
290291 const result = await adb . subprocess . noneProtocol . spawnWaitText ( command ) ;
291- res . json ( { result : result } ) . end ( ) ;
292+ res . json ( { command , result } ) . end ( ) ;
292293 } catch ( error : any ) {
293294 Logger . error ( `Error starting service: ${ error } ` ) ;
294295 res . status ( 500 ) . json ( { error : "An error occurred while starting the service." } ) . end ( ) ;
@@ -531,6 +532,11 @@ class APIController {
531532 const duration = config . features . exploitAppDuration ;
532533
533534 const { packageName : exploitApp } = body ;
535+
536+ if ( singleton . deviceApps . includes ( exploitApp ) ) {
537+ throw new Error ( "This is not an exploit app!" ) ;
538+ }
539+
534540 await singleton . runAppByPackageName ( exploitApp ) ;
535541
536542 res . json ( { result : `Exploit app correctly for ${ duration } seconds` } ) . end ( ) ;
0 commit comments