Apache Hadoop Pentesting
Apache Hadoop is a collection of open-source software utilities that facilitates using a network of many computers to solve problems involving massive amounts of data and computation. It uses ports 80
Authenticate using Keytab
Kyetab files are used to authenticate to the KDC (key distribution center) on Kerberos authentication. To find them, execute the following command in target system.
After finding them, we can use them to gather information or authenticate.
Impersonate Another Hadoop Service
We can authenticate other services by executing klist
and kinit
. Then we can investigate the HDFS service by the following HDFS commands.
HDFS Commands
Find HDFS Binary Path
When authenticated, we need to find the path of the hdfs
command associated with Hadoop. This command allows us to execute file system command in the datalake.
If the path exists in the default PATH (confirm to run echo $PATH
), we don't have to find them. However, if the path is not set in the default PATH, find it by running the following command.
If we find the path, go to the directory and use commands as below.
HDFS Command Cheat Sheet
Please refer to https://hadoop.apache.org/docs/current/hadoop-project-dist/hadoop-hdfs/HDFSCommands.html#Overview
As mentioned above, if the hdfs
path is not set in the PATH, we need to go to where the hdfs
binary exists.
Basically, their commands are similar to UNIX.
RCE (Remote Code Execution)
First we need to create arbitrary file that contains at lease one character. Then put it on HDFS.
Now execute below command to execute remote command.
Note that the -output
directory needs to be NOT exist, so if we want to multiple execute command, we have to delete the previous output folder or specify another name.
We can see the result of the command in the output directory. For example,
Reverse Shell
In target machine, create a reverse shell script and put it on HDFS.
In local machine, start a listener.
Now execute the following command.
We can get a shell in local machine.
Reverse Shell (MsfVenom)
First create a reverse shell payload using msfvenom in local machine and prepare a listener using msfconsole.
Transfer the payload to target machine.
Now execute the following command.
We can get a shell in meterpreter so to spawn the OS shell, run shell
command in the meterpreter.
Last updated