PageRenderTime 35ms CodeModel.GetById 10ms RepoModel.GetById 0ms app.codeStats 0ms

/modules/auxiliary/scanner/http/httpbl_lookup.rb

https://bitbucket.org/cfield/metasploit-framework
Ruby | 98 lines | 89 code | 3 blank | 6 comment | 0 complexity | f9cb2be70b6068d636de9ce1de0521d8 MD5 | raw file
  1. ##
  2. # This file is part of the Metasploit Framework and may be subject to
  3. # redistribution and commercial restrictions. Please see the Metasploit
  4. # web site for more information on licensing and terms of use.
  5. # http://metasploit.com/
  6. ##
  7. require 'msf/core'
  8. require "net/dns/resolver"
  9. class Metasploit3 < Msf::Auxiliary
  10. include Msf::Auxiliary::Scanner
  11. include Msf::Auxiliary::Report
  12. def initialize(info = {})
  13. super(update_info(info,
  14. 'Name' => 'Http:BL Lookup',
  15. 'Description' => %q{
  16. This module can be used to enumerate information
  17. about an IP addresses from Project HoneyPot's HTTP Block List.
  18. },
  19. 'Author' => [ 'mubix' ],
  20. 'License' => MSF_LICENSE,
  21. 'References' =>
  22. [
  23. ['URL', 'http://www.projecthoneypot.org/httpbl_api.php'],
  24. ]
  25. ))
  26. register_options(
  27. [
  28. # OptAddressRange.new('RHOSTS', [false, "The target address, range, or CIDR identifier"]),
  29. OptString.new('HTTPBL_APIKEY', [ true, "Your HTTP:BL api key"])
  30. ], self.class)
  31. end
  32. # Not compatible today
  33. def support_ipv6?
  34. false
  35. end
  36. def resolve(ip)
  37. results = ''
  38. apikey = datastore['HTTPBL_APIKEY']
  39. query = apikey + '.' + ip.split('.').reverse.join('.') + '.dnsbl.httpbl.org'
  40. begin
  41. results = Resolv::DNS.new.getaddress(query).to_s
  42. rescue Resolv::ResolvError => e
  43. results = 0
  44. rescue => e
  45. print_error e
  46. results = 0
  47. end
  48. return results
  49. end
  50. def translate(ip)
  51. ip.split('.')
  52. end
  53. def run_host(ip)
  54. result = resolve(ip)
  55. if result != 0
  56. breakup = result.split('.')
  57. lastseen = breakup[1]
  58. threatnum = breakup[2].to_i
  59. if threatnum < 25 then
  60. threat = "less than 100"
  61. elsif threatnum > 25 and threatnum < 49 then
  62. threat = "over 100"
  63. elsif threatnum > 50 and threatnum < 99 then
  64. threat = "over 10,000"
  65. elsif threatnum > 75 then
  66. threat = "over 1 million"
  67. end
  68. typenum = breakup[3]
  69. typestring = case typenum
  70. when '0' then 'Search Engine'
  71. when '1' then 'Suspicious'
  72. when '2' then 'Harvester'
  73. when '3' then 'Suspicious & Harvester'
  74. when '4' then 'Comment Spammer'
  75. when '5' then 'Suspicious & Comment Spammer'
  76. when '6' then 'Harvester & Comment Spammer'
  77. when '7' then 'Suspicious & Harvester & Comment Spammer'
  78. else
  79. "Unknown"
  80. end
  81. print_status ""
  82. print_status "#{ip} resloves to #{result} which means: #{typestring}"
  83. print_status "=> it was last seen #{lastseen} day ago and has a threat score of #{threatnum} or \'#{threat} spam messages\'"
  84. print_status "=> more info here: http://www.projecthoneypot.org/ip_#{ip}\n"
  85. end
  86. end
  87. end