knownsec / Pocsuite

This project has stopped to maintenance, please to https://github.com/knownsec/pocsuite3 project.
http://pocsuite.org
1.83k stars 607 forks source link

url2ip解析可能导致ssrf #140

Closed yunxu1 closed 7 years ago

yunxu1 commented 7 years ago

url2ip解析可能导致ssrf

http://localhost:12@www.baidu.com/

这个文件的url2ip函数在为url解析ip地址的时候可能因为:号分割处理不当解析到其他IP造成ssrf。

标准的URL格式:

协议://用户名:密码@子域名.域名.顶级域名:端口号/目录/文件名.文件后缀?参数=值#标志

如果传递如下url给该函数:

"http://localhost:12@www.baidu.com/"

最后将返回:

('127.0.0.1', '12@www.baidu.com')

任意IP地址解析:

http://0x08080808:www.baidu.com/
http://0x08080808:80@www.baidu.com/

返回:

('8.8.8.8', 'www.baidu.com')
 ('8.8.8.8', '80@www.baidu.com')

可能有问题的插件写法

from pocsuite.poc import POCBase, Output
from pocsuite.utils import register
from pocsuite.api.utils import url2ip

class TestPOC(POCBase):
    name = "url2iptest"
    vulID = 'test'
    author = ['']
    vulType = 'test'
    version = '1.0' 
    references = ''
    desc = ''

    vulDate = ''
    createDate = ''
    updateDate = ''

    appName = ''
    appVersion = ''
    appPowerLink = ''
    samples = []

    def _attack(self):
        return self._verify()

    def _verify(self):
        address=url2ip(self.url)
        result={}
        result['ipinfo']={}
        result['ipinfo']['address']=address
        return self.parse_output(result)

    def parse_output(self,result):
        output = Output(self)
        if result:
            output.success(result)
        else:
            output.fail('Internet nothing returned')
        return output

希望尽快出个安全靠谱的解析方案。。。

hysia commented 7 years ago

已处理