Cycle Scanner
Hello everyone , In this blog post , I will try to explain my solution steps for Cycle Scanner challenge from Mobile Hacking Lab Platform . i hope it will be useful for you
After install the app : my App GUI has a problem and i canβt access the button that enable the service use this command to enable the service :
adb shell am startservice com.mobilehackinglab.cyclicscanner/.scanner.ScanService
image.png letβs examine the
AndroidManifest.xml file
we found : Main Activity and the Service :Main Activity Structure :
handlePermissions()
:Checks if the app has permission to manage all files. If granted, calls
setupSwitch
; otherwise, launches an intent to request the permission.
setupSwitch()
:handle enabling or disabling the scan service.
If switched on, starts the scan service and shows a toast message.
If switched off, displays a toast stating that the service cannot be stopped and forces the switch back to "on."
startService()
:Starts the scan service in the foreground and displays a toast indicating that the service has started . :
Scan Service Structure :
Service Lifecycle :
onCreate (): Initializes the handler thread (
HandlerThread
) and sets up theServiceHandler
with the new threadβsLooper
.onStartCommand () : Starts the foreground notification and sends a message to
ServiceHandler
to begin scanning.onBind () : Returns
null
, as this service does not support binding.
we have the channel_id :
ForegroundScanServiceChannel
and the channel_nameScanService
Access the External Storage :
Environment.getExternalStorageDirectory()
Retrieves the external storage directory using and checks if it is notnull
.File externalStorageDirectory
represents the root directory of the external storage.
use
FilesKt.walk
to look for Each file is checked for readability and whether it is a file.Scan Each File :
ScanEngine.INSTANCE.scanFile(file)
to determine if the file is safe. Logs the result as either "SAFE" or "INFECTEDβ
ScanFile Function :
scans a given file to check whether its hash matches any known malware samples.
Uses
ProcessBuilder
to execute the command in a shell.command("sh", "-c", command)
, redirecting the error stream to the standard output to the external storage .Read Command Output : Retrieves the output of the
toybox sha1sum
commandthen Extract Hash Value and Compare Hash Against Known Malware
attack here try to manipulate the object that created in the
AbsolutePath
create a file that contain malicious code the upload the file and then launch the scan :
"nano test.txt ; touch kero"
contain command"test.txt ; touch kero "
and then upload it to the /sdcard/Downloadand here we success
Last updated