Explore is an easy-rated Android machine from HackTheBox created by Bertolis. It was hard to find the exploit. I don't have previous experience with attacking Android machines. You can use Metasploit on this machine, but there are still alternatives to exploit the vulnerability. For privilege escalation, the only technique used is Port Forwarding. In the current post, my IP is 10.10.14.52, and the target IP is 10.129.188.159.
Gathering Information
First, we are going to start with checking if the machine is alive, then do the classic reconnaissance to get some general information about the target.
The machine is working, by the "Target Description" we know that is an Android device, but without that information we can think at first glance that is a Linux Machine (TTL <= 64)
Local Terminal
nmap-p--sS--min-rate5000--open-vvv-n-Pn10.129.188.159-oNPortScanNmapscanreportfor10.129.188.159Hostisup,receiveduser-set (0.16s latency).Scannedat2023-05-0818:34:29PacificSAStandardTimefor14sNotshown:65530closedtcpports (reset), 1 filtered tcp port (no-response)Someclosedportsmaybereportedasfiltereddueto--defeat-rst-ratelimitPORTSTATESERVICEREASON2222/tcpopenEtherNetIP-1syn-ackttl6342135/tcpopenunknownsyn-ackttl6342239/tcpopenunknownsyn-ackttl6359777/tcpopenunknownsyn-ackttl63Readdatafilesfrom:C:\ProgramFiles (x86)\NmapNmapdone:1IPaddress (1 hostup) scanned in 14.61 secondsRawpacketssent:70480 (3.101MB) |Rcvd:70426 (2.817MB)
Local Terminal
nmap-sCV-p2222,42135,42239,5977710.129.188.159-oNWebScanStartingNmap7.92 ( https://nmap.org ) at 2023-05-09 11:43 Pacific SA Standard TimeNmapscanreportfor10.129.188.159Hostisup (0.21s latency).PORTSTATESERVICEVERSION2222/tcpopenssh (protocol 2.0)|fingerprint-strings:|NULL:|_SSH-2.0-SSHServer-BananaStudio|ssh-hostkey:|_204871:90:e3:a7:c9:5d:83:66:34:88:3d:eb:b4:c7:88:fb (RSA)42135/tcpopenhttpESFileExplorerNameResponsehttpd|_http-title:Sitedoesn't have a title (text/html).|_http-server-header: ES Name Response Server42239/tcp open unknown| fingerprint-strings:| GenericLines:| HTTP/1.0 400 Bad Request| Date: Tue, 09 May 2023 15:43:32 GMT| Content-Length: 22| Content-Type: text/plain; charset=US-ASCII| Connection: Close| Invalid request line:| GetRequest:| HTTP/1.1 412 Precondition Failed| Date: Tue, 09 May 2023 15:43:32 GMT| Content-Length: 0| HTTPOptions:| HTTP/1.0 501 Not Implemented| Date: Tue, 09 May 2023 15:43:37 GMT| Content-Length: 29| Content-Type: text/plain; charset=US-ASCII| Connection: Close| Method not supported: OPTIONS| Help:| HTTP/1.0 400 Bad Request| Date: Tue, 09 May 2023 15:43:54 GMT| Content-Length: 26| Content-Type: text/plain; charset=US-ASCII| Connection: Close| Invalid request line: HELP| RTSPRequest:| HTTP/1.0 400 Bad Request| Date: Tue, 09 May 2023 15:43:37 GMT| Content-Length: 39| Content-Type: text/plain; charset=US-ASCII| Connection: Close| valid protocol version: RTSP/1.0| SSLSessionReq:| HTTP/1.0 400 Bad Request| Date: Tue, 09 May 2023 15:43:54 GMT| Content-Length: 73| Content-Type: text/plain; charset=US-ASCII| Connection: Close| Invalid request line:| ?G???,???`~?| ??{????w????<=?o?| TLSSessionReq:| HTTP/1.0 400 Bad Request| Date: Tue, 09 May 2023 15:43:55 GMT| Content-Length: 71| Content-Type: text/plain; charset=US-ASCII| Connection: Close| Invalid request line:| ??random1random2random3random4| TerminalServerCookie:| HTTP/1.0 400 Bad Request| Date: Tue, 09 May 2023 15:43:54 GMT| Content-Length: 54| Content-Type: text/plain; charset=US-ASCII| Connection: Close| Invalid request line:|_ Cookie: mstshash=nmap59777/tcp open http Bukkit JSONAPI httpd for Minecraft game server 3.6.0 or older|_http-title: Site doesn'thaveatitle (text/plain).<...>ServiceInfo:Device:phone
That's a lot of information, we are going to explore every http port first.
From the basic gathering, beside than the target being a phone, thanks to the second nmap scan, we don't have a lot of relevant information. Now we have to search information about: "Banana Studio" and "ES File Explorer" to learn about the target.
batcatexploit.py13│iflen(sys.argv) <3:# Information about how to use14│print(f"USAGE {sys.argv[0]} <command> <IP> [file to download]")15│sys.exit(1)21│ifcmdnotincmds:# List of available commands 22│print("[-] WRONG COMMAND!")23│print("Available commands : ")24│print(" listFiles : List all Files.")25│print(" listPics : List all Pictures.")26│print(" listVideos : List all videos.")27│print(" listAudios : List all audios.")28│print(" listApps : List Applications installed.")29│print(" listAppsSystem : List System apps.")30│print(" listAppsPhone : List Communication related apps.")31│print(" listAppsSdcard : List apps on the SDCard.")32│print(" listAppsAll : List all Application.")33│print(" getFile : Download a file.")34│print(" getDeviceInfo : Get device info.")35│sys.exit(1)
If we compare with nmap, there is a new working port, the "5555", by default in android devices this port is ADB, and it's running, so we can try to use it, open a new local terminal.