snackhack2 0.6.4 → 0.6.5
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.
- checksums.yaml +4 -4
- data/lib/snackhack2/CVE-2017-9841.rb +77 -0
- data/lib/snackhack2/Honeywell_PM43.rb +25 -27
- data/lib/snackhack2/WP_Symposium.rb +22 -22
- data/lib/snackhack2/bannergrabber.rb +82 -82
- data/lib/snackhack2/bypass_403.rb +68 -66
- data/lib/snackhack2/comments.rb +29 -27
- data/lib/snackhack2/cryptoextractor.rb +64 -64
- data/lib/snackhack2/dns.rb +99 -0
- data/lib/snackhack2/drupal.rb +47 -49
- data/lib/snackhack2/emails.rb +31 -35
- data/lib/snackhack2/forward_remote.rb +26 -24
- data/lib/snackhack2/google_analytics.rb +30 -28
- data/lib/snackhack2/indirect_command_injection.rb +34 -32
- data/lib/snackhack2/iplookup.rb +52 -45
- data/lib/snackhack2/list_users.rb +34 -31
- data/lib/snackhack2/phishing_tlds.rb +197 -0
- data/lib/snackhack2/phone_number.rb +53 -56
- data/lib/snackhack2/portscan.rb +72 -73
- data/lib/snackhack2/reverse_shell.rb +32 -31
- data/lib/snackhack2/robots.rb +80 -81
- data/lib/snackhack2/screenshots.rb +25 -23
- data/lib/snackhack2/sitemap.rb +24 -22
- data/lib/snackhack2/ssrf.rb +7 -6
- data/lib/snackhack2/subdomains.rb +68 -68
- data/lib/snackhack2/subdomains2.rb +41 -43
- data/lib/snackhack2/tomcat.rb +23 -21
- data/lib/snackhack2/version.rb +1 -1
- data/lib/snackhack2/webserver_log_cleaner.rb +28 -27
- data/lib/snackhack2/website_links.rb +28 -28
- data/lib/snackhack2/website_meta.rb +33 -20
- data/lib/snackhack2/wordpress.rb +120 -128
- data/lib/snackhack2/wpForo_Forum.rb +23 -22
- data/lib/snackhack2.rb +84 -81
- metadata +23 -20
@@ -1,64 +1,64 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
require 'httparty'
|
4
|
-
require 'uri'
|
5
|
-
module Snackhack2
|
6
|
-
class CryptoExtractWebsite
|
7
|
-
attr_accessor :save_file
|
8
|
-
|
9
|
-
def initialize(site, save_file: true)
|
10
|
-
@http = Snackhack2
|
11
|
-
@site = site
|
12
|
-
@save_file = save_file
|
13
|
-
end
|
14
|
-
|
15
|
-
def all
|
16
|
-
addresses = []
|
17
|
-
addresses << monero unless monero.nil?
|
18
|
-
addresses << bitcoin unless bitcoin.nil?
|
19
|
-
addresses << dash unless dash.nil?
|
20
|
-
addresses << ethereum unless ethereum.nil?
|
21
|
-
addresses << bitcoincash unless bitcoincash.nil?
|
22
|
-
addresses << litecoin unless litecoin.nil?
|
23
|
-
addresses << dogecoin unless dogecoin.nil?
|
24
|
-
addresses << stellar unless stellar.nil?
|
25
|
-
if @save_file
|
26
|
-
Snackhack2
|
27
|
-
else
|
28
|
-
puts addresses.join("\n")
|
29
|
-
end
|
30
|
-
end
|
31
|
-
|
32
|
-
def monero
|
33
|
-
|
34
|
-
end
|
35
|
-
|
36
|
-
def bitcoin
|
37
|
-
@http.scan(/(bc(0([ac-hj-np-z02-9]{39}|[ac-hj-np-z02-9]{59})|1[ac-hj-np-z02-9]{8,87})|[13][a-km-zA-HJ-NP-Z1-9]{25,35})/)
|
38
|
-
end
|
39
|
-
|
40
|
-
def dash
|
41
|
-
@http.scan(/(X[1-9A-HJ-NP-Za-km-z]{33})/)
|
42
|
-
end
|
43
|
-
|
44
|
-
def stellar
|
45
|
-
@http.scan(/(G[A-Z0-9]{55}$)/)
|
46
|
-
end
|
47
|
-
|
48
|
-
def litecoin
|
49
|
-
@http.scan(/([LM3][a-km-zA-HJ-NP-Z1-9]{26,33})/)
|
50
|
-
end
|
51
|
-
|
52
|
-
def dogecoin
|
53
|
-
@http.scan(/(D{1}[56789ABCDEFGHJKLMNPQRSTU]{1}[123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz]{32}$)/)
|
54
|
-
end
|
55
|
-
|
56
|
-
def ethereum
|
57
|
-
@http.scan(/(0x[a-fA-F0-9]{40})/)
|
58
|
-
end
|
59
|
-
|
60
|
-
def bitcoincash
|
61
|
-
@http.scan(/([13][a-km-zA-HJ-NP-Z1-9]{33})/)
|
62
|
-
end
|
63
|
-
end
|
64
|
-
end
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'httparty'
|
4
|
+
require 'uri'
|
5
|
+
module Snackhack2
|
6
|
+
class CryptoExtractWebsite
|
7
|
+
attr_accessor :save_file
|
8
|
+
|
9
|
+
def initialize(site, save_file: true)
|
10
|
+
@http = Snackhack2.get(site).body
|
11
|
+
@site = site
|
12
|
+
@save_file = save_file
|
13
|
+
end
|
14
|
+
|
15
|
+
def all
|
16
|
+
addresses = []
|
17
|
+
addresses << monero unless monero.nil?
|
18
|
+
addresses << bitcoin unless bitcoin.nil?
|
19
|
+
addresses << dash unless dash.nil?
|
20
|
+
addresses << ethereum unless ethereum.nil?
|
21
|
+
addresses << bitcoincash unless bitcoincash.nil?
|
22
|
+
addresses << litecoin unless litecoin.nil?
|
23
|
+
addresses << dogecoin unless dogecoin.nil?
|
24
|
+
addresses << stellar unless stellar.nil?
|
25
|
+
if @save_file
|
26
|
+
Snackhack2.file_save(@site, 'cryptoaddresses', addresses.uniq.join("\n"))
|
27
|
+
else
|
28
|
+
puts addresses.join("\n")
|
29
|
+
end
|
30
|
+
end
|
31
|
+
|
32
|
+
def monero
|
33
|
+
@http.scan(/([48][0-9AB][1-9A-HJ-NP-Za-km-z]{93})/)
|
34
|
+
end
|
35
|
+
|
36
|
+
def bitcoin
|
37
|
+
@http.scan(/(bc(0([ac-hj-np-z02-9]{39}|[ac-hj-np-z02-9]{59})|1[ac-hj-np-z02-9]{8,87})|[13][a-km-zA-HJ-NP-Z1-9]{25,35})/)
|
38
|
+
end
|
39
|
+
|
40
|
+
def dash
|
41
|
+
@http.scan(/(X[1-9A-HJ-NP-Za-km-z]{33})/)
|
42
|
+
end
|
43
|
+
|
44
|
+
def stellar
|
45
|
+
@http.scan(/(G[A-Z0-9]{55}$)/)
|
46
|
+
end
|
47
|
+
|
48
|
+
def litecoin
|
49
|
+
@http.scan(/([LM3][a-km-zA-HJ-NP-Z1-9]{26,33})/)
|
50
|
+
end
|
51
|
+
|
52
|
+
def dogecoin
|
53
|
+
@http.scan(/(D{1}[56789ABCDEFGHJKLMNPQRSTU]{1}[123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz]{32}$)/)
|
54
|
+
end
|
55
|
+
|
56
|
+
def ethereum
|
57
|
+
@http.scan(/(0x[a-fA-F0-9]{40})/)
|
58
|
+
end
|
59
|
+
|
60
|
+
def bitcoincash
|
61
|
+
@http.scan(/([13][a-km-zA-HJ-NP-Z1-9]{33})/)
|
62
|
+
end
|
63
|
+
end
|
64
|
+
end
|
@@ -0,0 +1,99 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'resolv'
|
4
|
+
module Snackhack2
|
5
|
+
class Dns
|
6
|
+
attr_accessor :site
|
7
|
+
|
8
|
+
def initialize()
|
9
|
+
@site = site
|
10
|
+
end
|
11
|
+
|
12
|
+
def all_dns
|
13
|
+
nameserver
|
14
|
+
soa
|
15
|
+
txt
|
16
|
+
aaaa
|
17
|
+
mx
|
18
|
+
end
|
19
|
+
|
20
|
+
def a
|
21
|
+
a = []
|
22
|
+
Resolv::DNS.open do |dns|
|
23
|
+
ress = dns.getresources @site.to_s, Resolv::DNS::Resource::IN::A
|
24
|
+
ress.each do |l|
|
25
|
+
a << l.address.to_s
|
26
|
+
end
|
27
|
+
end
|
28
|
+
a
|
29
|
+
end
|
30
|
+
|
31
|
+
def nameserver
|
32
|
+
ns = []
|
33
|
+
Resolv::DNS.open do |dns|
|
34
|
+
ress = dns.getresources @site.to_s, Resolv::DNS::Resource::IN::NS
|
35
|
+
ress.each do |l|
|
36
|
+
ns << l.name.to_s
|
37
|
+
end
|
38
|
+
end
|
39
|
+
ns
|
40
|
+
end
|
41
|
+
|
42
|
+
def soa
|
43
|
+
soa = []
|
44
|
+
Resolv::DNS.open do |dns|
|
45
|
+
ress = dns.getresources @site.to_s, Resolv::DNS::Resource::IN::SOA
|
46
|
+
ress.each do |l|
|
47
|
+
soa << l.rname
|
48
|
+
soa << l.mname
|
49
|
+
soa << l.ttl
|
50
|
+
end
|
51
|
+
end
|
52
|
+
soa
|
53
|
+
end
|
54
|
+
|
55
|
+
def txt
|
56
|
+
txt = []
|
57
|
+
Resolv::DNS.open do |dns|
|
58
|
+
ress = dns.getresources @site.to_s, Resolv::DNS::Resource::IN::TXT
|
59
|
+
ress.each do |l|
|
60
|
+
txt << l.strings.to_s
|
61
|
+
end
|
62
|
+
end
|
63
|
+
txt
|
64
|
+
end
|
65
|
+
|
66
|
+
def aaaa
|
67
|
+
aaaa = []
|
68
|
+
Resolv::DNS.open do |dns|
|
69
|
+
ress = dns.getresources @site.to_s, Resolv::DNS::Resource::IN::AAAA
|
70
|
+
ress.each do |l|
|
71
|
+
aaaa << l.address
|
72
|
+
end
|
73
|
+
end
|
74
|
+
aaaa
|
75
|
+
end
|
76
|
+
|
77
|
+
def hinfo
|
78
|
+
hinfo = []
|
79
|
+
Resolv::DNS.open do |dns|
|
80
|
+
ress = dns.getresources @site.to_s, Resolv::DNS::Resource::IN::HINFO
|
81
|
+
ress.each do |l|
|
82
|
+
hinfo << l.exchange.to_s
|
83
|
+
end
|
84
|
+
end
|
85
|
+
hinfo
|
86
|
+
end
|
87
|
+
|
88
|
+
def mx
|
89
|
+
mx = []
|
90
|
+
Resolv::DNS.open do |dns|
|
91
|
+
ress = dns.getresources @site.to_s, Resolv::DNS::Resource::IN::MX
|
92
|
+
ress.each do |l|
|
93
|
+
mx << l.exchange.to_s
|
94
|
+
end
|
95
|
+
end
|
96
|
+
mx
|
97
|
+
end
|
98
|
+
end
|
99
|
+
end
|
data/lib/snackhack2/drupal.rb
CHANGED
@@ -1,49 +1,47 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
def
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
end
|
29
|
-
doc = Nokogiri::HTML(URI.open(@site))
|
30
|
-
posts = doc.xpath('//meta')
|
31
|
-
posts.each do |l|
|
32
|
-
if l.attributes['content'].to_s.include?(
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
end
|
49
|
-
end
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'nokogiri'
|
4
|
+
require 'open-uri'
|
5
|
+
module Snackhack2
|
6
|
+
class Drupal
|
7
|
+
attr_accessor :site
|
8
|
+
|
9
|
+
def initialize
|
10
|
+
@site = site
|
11
|
+
end
|
12
|
+
|
13
|
+
def all
|
14
|
+
drupal_score
|
15
|
+
user_brute
|
16
|
+
end
|
17
|
+
|
18
|
+
def drupal_score
|
19
|
+
drupal_score = 0
|
20
|
+
d = Snackhack2.get(@site)
|
21
|
+
if d.code == 200
|
22
|
+
d.headers.each do |k|
|
23
|
+
drupal_score += 10 if k.include?('drupal')
|
24
|
+
end
|
25
|
+
end
|
26
|
+
d.headers.each do |v|
|
27
|
+
drupal_score += 10 if v.include?('drupal')
|
28
|
+
end
|
29
|
+
doc = Nokogiri::HTML(URI.open(@site))
|
30
|
+
posts = doc.xpath('//meta')
|
31
|
+
posts.each do |l|
|
32
|
+
puts "\n\n[+] Drupal Version: #{l.attributes['content']}\n" if l.attributes['content'].to_s.include?('Drupal')
|
33
|
+
end
|
34
|
+
puts "\nDrupal Score: #{drupal_score}\n"
|
35
|
+
end
|
36
|
+
|
37
|
+
def user_brute
|
38
|
+
(1..1000).each do |user|
|
39
|
+
u = Snackhack2.get(File.join(@site, 'user', user.to_s)).body
|
40
|
+
if u.include?('Page not found')
|
41
|
+
puts "\nUser count: #{user - 1}\n"
|
42
|
+
break
|
43
|
+
end
|
44
|
+
end
|
45
|
+
end
|
46
|
+
end
|
47
|
+
end
|
data/lib/snackhack2/emails.rb
CHANGED
@@ -1,35 +1,31 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
@
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
def run
|
18
|
-
found_emails = []
|
19
|
-
Spidr.start_at(@site, max_depth: @max_depth) do |agent|
|
20
|
-
agent.every_page do |page|
|
21
|
-
body = page.to_s
|
22
|
-
if body.scan(/[A-Za-z0-9._%+-]+@[A-Za-z0-9.-]+\.[A-Za-z]{2,6}/)
|
23
|
-
email = body.scan(/[A-Za-z0-9._%+-]+@[A-Za-z0-9.-]+\.[A-Za-z]{2,6}/).uniq
|
24
|
-
if !email.include?(found_emails)
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
Snackhack2::file_save(@site, "emails", found_emails.uniq.join("\n")) if @save_file
|
33
|
-
end
|
34
|
-
end
|
35
|
-
end
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'httparty'
|
4
|
+
require 'spidr'
|
5
|
+
module Snackhack2
|
6
|
+
class Email
|
7
|
+
attr_accessor :max_depth
|
8
|
+
|
9
|
+
def initialize(site, save_file: true, max_depth: 4)
|
10
|
+
@site = site
|
11
|
+
@save_file = save_file
|
12
|
+
@max_depth = max_depth
|
13
|
+
end
|
14
|
+
|
15
|
+
attr_reader :max_depth
|
16
|
+
|
17
|
+
def run
|
18
|
+
found_emails = []
|
19
|
+
Spidr.start_at(@site, max_depth: @max_depth) do |agent|
|
20
|
+
agent.every_page do |page|
|
21
|
+
body = page.to_s
|
22
|
+
if body.scan(/[A-Za-z0-9._%+-]+@[A-Za-z0-9.-]+\.[A-Za-z]{2,6}/)
|
23
|
+
email = body.scan(/[A-Za-z0-9._%+-]+@[A-Za-z0-9.-]+\.[A-Za-z]{2,6}/).uniq
|
24
|
+
found_emails << email if !email.include?(found_emails) && !email.empty?
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
28
|
+
Snackhack2.file_save(@site, 'emails', found_emails.uniq.join("\n")) if @save_file
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
@@ -1,24 +1,26 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
@
|
10
|
-
@
|
11
|
-
@
|
12
|
-
@
|
13
|
-
@
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
ssh.
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
end
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'net/ssh'
|
4
|
+
module Snackhack2
|
5
|
+
class SSHForwardRemote
|
6
|
+
attr_accessor :site, :user, :pass, :key, :lport, :lsite, :rport
|
7
|
+
|
8
|
+
def initialize
|
9
|
+
@site = site
|
10
|
+
@user = user
|
11
|
+
@pass = pass
|
12
|
+
@key = key
|
13
|
+
@lport = lport
|
14
|
+
@lsite = lsite
|
15
|
+
@rport = rport
|
16
|
+
end
|
17
|
+
|
18
|
+
def run
|
19
|
+
Net::SSH.start(@site, @user, password: @pass, keys: @key) do |ssh|
|
20
|
+
ssh.forward.remote(@lport, @lsite, @rport)
|
21
|
+
puts '[+] Starting SSH remote forward tunnel'
|
22
|
+
ssh.loop { true }
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
@@ -1,28 +1,30 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
require 'httparty'
|
4
|
-
module Snackhack2
|
5
|
-
class GoogleAnalytics
|
6
|
-
attr_accessor :site
|
7
|
-
|
8
|
-
def initialize
|
9
|
-
@site = site
|
10
|
-
end
|
11
|
-
|
12
|
-
def run
|
13
|
-
a = Snackhack2
|
14
|
-
case a
|
15
|
-
when /UA-\d{8}-\d/
|
16
|
-
puts a.match(/UA-\d{8}-\d/)
|
17
|
-
when /GTM-[A-Z0-9]{7}/
|
18
|
-
puts a.match(/GTM-[A-Z0-9]{7}/)
|
19
|
-
when /G-([0-9]+([A-Za-z]+[0-9]+)+)/
|
20
|
-
puts a.match(/G-([0-9]+([A-Za-z]+[0-9]+)+)/)
|
21
|
-
when /G-[A-Za-z0-9]+/
|
22
|
-
puts a.match(/G-[A-Za-z0-9]+/)
|
23
|
-
|
24
|
-
puts
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
end
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'httparty'
|
4
|
+
module Snackhack2
|
5
|
+
class GoogleAnalytics
|
6
|
+
attr_accessor :site
|
7
|
+
|
8
|
+
def initialize
|
9
|
+
@site = site
|
10
|
+
end
|
11
|
+
|
12
|
+
def run
|
13
|
+
a = Snackhack2.get(@site).body
|
14
|
+
case a
|
15
|
+
when /UA-\d{8}-\d/
|
16
|
+
puts a.match(/UA-\d{8}-\d/)
|
17
|
+
when /GTM-[A-Z0-9]{7}/
|
18
|
+
puts a.match(/GTM-[A-Z0-9]{7}/)
|
19
|
+
when /G-([0-9]+([A-Za-z]+[0-9]+)+)/
|
20
|
+
puts a.match(/G-([0-9]+([A-Za-z]+[0-9]+)+)/)
|
21
|
+
when /G-[A-Za-z0-9]+/
|
22
|
+
puts a.match(/G-[A-Za-z0-9]+/)
|
23
|
+
when /GT-[A-Za-z0-9]+/
|
24
|
+
puts a.match(/GT-[A-Za-z0-9]+/)
|
25
|
+
else
|
26
|
+
puts '[+] No Google Analytics found :('
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
@@ -1,32 +1,34 @@
|
|
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
|
-
end
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Snackhack2
|
4
|
+
class CommandInjection
|
5
|
+
attr_accessor :exe, :title, :prompt
|
6
|
+
|
7
|
+
def initialize(exe, title, prompt)
|
8
|
+
@exe = 'calc.exe'
|
9
|
+
@title = 'Click me!'
|
10
|
+
@prompt = 'To run calculator'
|
11
|
+
end
|
12
|
+
|
13
|
+
def wlrmdr_With_prompt
|
14
|
+
Process.spawn("wlrmdr.exe -s 3600 -f 0 -t #{title} -m #{@prompt} -a 10 -u #{@exe}")
|
15
|
+
end
|
16
|
+
|
17
|
+
def wlrmdr_without_prompt
|
18
|
+
Process.spawn("wlrmdr.exe -s 3600 -f 0 -t _ -m _ -a 11 -u #{@exe}")
|
19
|
+
end
|
20
|
+
|
21
|
+
def conhost
|
22
|
+
Process.spawn("conhost.exe #{@exe}")
|
23
|
+
end
|
24
|
+
|
25
|
+
def conhost_hide
|
26
|
+
# Specify --headless parameter to hide child process window (if applicable)
|
27
|
+
Process.spawn("conhost.exe --headless #{@exe}")
|
28
|
+
end
|
29
|
+
|
30
|
+
def ssh
|
31
|
+
Process.spawn("ssh -o ProxyCommand=#{@exe} .")
|
32
|
+
end
|
33
|
+
end
|
34
|
+
end
|
data/lib/snackhack2/iplookup.rb
CHANGED
@@ -1,45 +1,52 @@
|
|
1
|
-
# frozen_string_literal: true
|
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
|
-
ips
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
end
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'socket'
|
4
|
+
require 'colorize'
|
5
|
+
module Snackhack2
|
6
|
+
class IpLookup
|
7
|
+
attr_accessor :site
|
8
|
+
|
9
|
+
def initialize(file_save: false)
|
10
|
+
@file_save = file_save
|
11
|
+
@site = site
|
12
|
+
end
|
13
|
+
|
14
|
+
def run
|
15
|
+
get_ip
|
16
|
+
nslookup
|
17
|
+
socket
|
18
|
+
end
|
19
|
+
|
20
|
+
def get_ip
|
21
|
+
ips = []
|
22
|
+
ip = `ping -c 2 #{@site.gsub('https://', '')}`.lines
|
23
|
+
ip.each do |l|
|
24
|
+
new_ip = l.match(/(\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3})/)
|
25
|
+
ips << new_ip.to_s if !new_ip.to_s.empty? && !ips.include?(new_ip)
|
26
|
+
end
|
27
|
+
ips
|
28
|
+
end
|
29
|
+
|
30
|
+
def nslookup
|
31
|
+
ips = []
|
32
|
+
ns = `nslookup #{@site.gsub('https://', '')}`.lines
|
33
|
+
ns.each do |ip|
|
34
|
+
new_ip = ip.gsub('Address: ', '').strip if ip.include?('Address')
|
35
|
+
if !ips.include?(new_ip) && !new_ip.nil?
|
36
|
+
|
37
|
+
ips << new_ip.split('Addresses: ')[1].to_s
|
38
|
+
end
|
39
|
+
end
|
40
|
+
|
41
|
+
if @file_save
|
42
|
+
Snackhack2.file_save(@site, 'ip_lookup', ips.to_a.drop(1).join("\n"))
|
43
|
+
else
|
44
|
+
ips
|
45
|
+
end
|
46
|
+
end
|
47
|
+
|
48
|
+
def socket
|
49
|
+
puts IPSocket.getaddress(@site.gsub('https://', ''))
|
50
|
+
end
|
51
|
+
end
|
52
|
+
end
|