wappalyzer_rb 0.0.5 → 0.0.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/README.md +1 -1
- data/lib/wappalyzer_rb/version.rb +1 -1
- data/lib/wappalyzer_rb.rb +25 -5
- metadata +1 -1
data/README.md
CHANGED
@@ -6,7 +6,7 @@ Analyzes a provided url and returns any services it can detect.
|
|
6
6
|
Usage:
|
7
7
|
|
8
8
|
url = 'http://some.url.com'
|
9
|
-
WappalyzerRb.new(url).analysis #=> ['Ruby', 'nginx', ...]
|
9
|
+
WappalyzerRb::Detector.new(url).analysis #=> ['Ruby', 'nginx', ...]
|
10
10
|
|
11
11
|
It is a fork of https://github.com/ElbertF/Wappalyzer (commit 7431c5e1e1).
|
12
12
|
|
data/lib/wappalyzer_rb.rb
CHANGED
@@ -1,6 +1,9 @@
|
|
1
1
|
require "wappalyzer_rb/version"
|
2
2
|
require "wappalyzer_rb/apps"
|
3
3
|
|
4
|
+
require "uri"
|
5
|
+
require "net/http"
|
6
|
+
|
4
7
|
module WappalyzerRb
|
5
8
|
class Detector
|
6
9
|
attr_reader :analysis
|
@@ -10,6 +13,13 @@ module WappalyzerRb
|
|
10
13
|
analyze!
|
11
14
|
end
|
12
15
|
|
16
|
+
def self.get(url)
|
17
|
+
uri = URI.parse(url)
|
18
|
+
http = Net::HTTP.new(uri.host, uri.port)
|
19
|
+
request = Net::HTTP::Get.new(uri.request_uri)
|
20
|
+
http.request(request)
|
21
|
+
end
|
22
|
+
|
13
23
|
private
|
14
24
|
|
15
25
|
def hostname
|
@@ -46,12 +56,22 @@ module WappalyzerRb
|
|
46
56
|
response
|
47
57
|
end
|
48
58
|
|
49
|
-
def response
|
59
|
+
def response(url = nil)
|
50
60
|
@response ||= begin
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
61
|
+
url ||= @url
|
62
|
+
resp = WappalyzerRb::Detector.get(url)
|
63
|
+
|
64
|
+
redirects = 0
|
65
|
+
while resp.code == "302" && resp["location"] # redirect
|
66
|
+
raise 'Too many redirects' if redirects > 10
|
67
|
+
|
68
|
+
url = resp["location"]
|
69
|
+
redirects += 1
|
70
|
+
|
71
|
+
resp = WappalyzerRb::Detector.get(url)
|
72
|
+
end
|
73
|
+
|
74
|
+
resp
|
55
75
|
end
|
56
76
|
end
|
57
77
|
|