-
Notifications
You must be signed in to change notification settings - Fork 76
/
Copy pathwhatweb.rb
156 lines (119 loc) · 3.07 KB
/
whatweb.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
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
#!/usr/bin/env ruby
require 'json'
require "fileutils"
require "pathname"
if ARGV.size != 2 then
puts("[*] Usage: #{$0} src_dir dst_dir")
exit(0)
end
$src_plugin_dir = File.expand_path(ARGV[0])
$dst_plugin_dir = File.expand_path(ARGV[1])
def randstr
1111111111111.to_s(36)
end
def rand(v)
1111111111111
end
class Plugin
def Plugin.define()
yield if block_given?
end
end
$plugin_matches = nil
def matches(value)
new_value = Marshal.load( Marshal.dump(value))
wrong_items = [[:path, :url], [:regxp, :regexp], [:regex, :regexp]]
value.each_index do |index|
value[index].each_key do |key|
wrong_items.each_index do |wrong_index|
if key == wrong_items[wrong_index][0]
new_value[index][wrong_items[wrong_index][1]] = value[index][wrong_items[wrong_index][0]]
new_value[index].delete(wrong_items[wrong_index][0])
end
end
end
if new_value[index][:version].nil? and new_value[index]["offset"].nil?
new_value[index].delete(:offset)
new_value[index].delete("offset")
end
[:version, :os, :string, :account, :model, :firmware, :module, :filepath].each do |label|
if !value[index][label].nil? and value[index][label].class == Regexp
new_value[index][:regexp] = value[index][label]
if label == :version and new_value[index]["offset"].nil? and new_value[index][:offset].nil?
new_value[index][:offset] = 1
end
new_value[index].delete(label)
end
end
end
$plugin_matches = new_value
end
$plugin_name = nil
def name(value)
$plugin_name = value
end
$plugin_author = nil
def authors(value)
$plugin_author = value.join(', ')
end
$plugin_version = nil
def version(value)
$plugin_version = value
end
$plugin_description = nil
def description(value)
$plugin_description = value
end
$plugin_website = nil
def website(value)
$plugin_website = value
end
$plugin_cve = nil
def cve(value)
$plugin_cve = value
end
$plugin_dorks = nil
def dorks(value)
$plugin_dorks = value
end
def passive()
end
def aggressive()
end
if !File.exists?($dst_plugin_dir)
FileUtils.mkdir_p($dst_plugin_dir)
end
Dir.foreach($src_plugin_dir) do |file|
if file != "." and file != ".." and file.end_with?(".rb")
$plugin_name = nil
$plugin_author = nil
$plugin_version = nil
$plugin_description = nil
$plugin_website = nil
$plugin_matches = nil
$plugin_cve = nil
$plugin_dorks = nil
begin
require_relative $src_plugin_dir + '/' + file
if $plugin_matches == nil
next
end
plugin = {
:name => $plugin_name,
:author => $plugin_author,
:version => $plugin_version,
:description => $plugin_description,
:website => $plugin_website,
:matches => $plugin_matches,
}
filename = $dst_plugin_dir + '/' + file[0..-4] + ".json"
File.open(filename, "w") do |f|
begin
f.puts(JSON.pretty_generate(plugin, {indent: " "}))
rescue Exception => e
File.delete(filename)
end
end
end
end
end