require 'fofa_core'
#require 'payload/webshell'

class FofaExploits < Fofa::Exploit
  def initialize(info = {})
    super(
      'Name' => 'jetty测试脚本任意命令执行',
      'Description' => %q{
jetty的测试脚本结合bash漏洞可能导致命令执行。
          },
      'Author' =>
          [
              'LubyRuffy',
          ],
      'Product' => 'Bash',
      'Homepage' => 'http://gnu.org/',
      'References' =>
          [
              'http://weibo.com/3907390400/Bsy4620WE?type=comment',
          ],
      'DisclosureDate'=> '2014-10-21',
      'FofaQuery'=>'header="Server: Jetty(6"',
      'ScanSteps' =>
          [
            'OR',
            {
              'Request'=>
                 {
                    method: 'GET',
                    uri: '/cgi-bin/hello.sh',
                 },
              'ResponseTest'=> {
                  type: 'group',
                  operation: 'AND',
                  checks: [
                    {
                        type: 'item',
                        varibale: '$code',
                        operation: '==',
                        value: 200
                    },
                    {
                        type: 'item',
                        varibale: '$body',
                        operation: 'contains',
                        value: 'Hello World'
                    }
                  ]
              }
            },
            {
                'Request'=>
                    {
                        method: 'GET',
                        uri: '/test/cgi-bin/hello.sh',
                    },
                'ResponseTest'=> {
                    type: 'group',
                    operation: 'AND',
                    checks: [
                        {
                            type: 'item',
                            varibale: '$code',
                            operation: '==',
                            value: 200
                        },
                        {
                            type: 'item',
                            varibale: '$body',
                            operation: 'contains',
                            value: 'Hello World'
                        }
                    ]
                }
            },
          ]
    )
  end

  def vulnerable(hostinfo)
    excute_scansteps(hostinfo) if @info['ScanSteps']
  end

  def exploit(hostinfo)
    #http://www.2cto.com/Article/201312/265706.html
    #http://www.exploit-db.com/sploits/zimbraexploit_rubina119.zip
  end
end
