-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathhtml_main_parser.rb
62 lines (57 loc) · 1.44 KB
/
html_main_parser.rb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
require "msf/core"
require "nokogiri"
require "net/http"
require "net/https"
class MetasploitModule < Msf::Auxiliary
include Msf::Auxiliary::Report
Rank = GreatRanking
def initialize(info = {})
super(update_info(info,
'Name' => 'html main parser',
'Description' => %q{
html main parser
},
'Author' => ['Abd El Rahman HSN <abdelrahmanhsn1@gmail.com>'],
'License' => MSF_LICENSE,
'Version' => '1.0'))
register_options(
[
OptString.new('DOMAIN',[true,'domain for parsing']),
OptString.new('REQUEST',[true,'request path']),
OptString.new('FILE',[false,' file for saving data']),
OptString.new('OPTION',[false,'data option']),
OptString.new('XPATH',[true,'XPATH']),
],self.class)
end
def run
$site = datastore["DOMAIN"]
$site_info = URI.parse($site)
$parse = Net::HTTP.new($site_info.host,$site_info.port)
$parse.use_ssl = true
$parse.verify_mode = OpenSSL::SSL::VERIFY_NONE
$data = $parse.get(datastore["REQUEST"])
$html = $data.body
$parser = Nokogiri::HTML($html)
$file = datastore["FILE"]
if $file !=nil then
$mkfile = File.new($file,"w")
end
$parser.xpath(datastore["XPATH"]).each do |d|
$option = datastore['OPTION']
if $option == nil then
puts d
if $file !=nil then
$mkfile.write("#{d}\n")
end
else
puts d[$option]
if $file != nil then
$mkfile.write("#{d[$option]}\n")
end
end
end
if $file != nil then
puts "the file is saved as #{$file}"
end
end
end