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.
@@ -1,81 +1,80 @@
1
- # frozen_string_literal: true
2
-
3
- module Snackhack2
4
- class Robots
5
-
6
- def initialize(site, save_file: true)
7
- @site = site
8
- @http = Snackhack2::get(File.join(@site, "robots.txt"))
9
- @save_file = save_file
10
- end
11
-
12
- attr_reader :save_file
13
-
14
- def run
15
- save_txt_file = ''
16
- allow = allow_robots
17
- disallow = disallow_robots
18
- if @save_file
19
- save_txt_file += "ALLOW:\n\n"
20
- unless allow.empty?
21
- allow.each do |list|
22
- save_txt_file += list
23
- end
24
- end
25
- save_txt_file += "DISALLOW:\n\n"
26
- unless disallow.empty?
27
- disallow.each do |list|
28
- save_txt_file += list
29
- end
30
- end
31
- else
32
- puts allow
33
- puts disallow
34
- end
35
- Snackhack2::file_save(@site, "robots", save_txt_file) if @save_file
36
- end
37
-
38
- def allow_robots
39
- allow_dir = []
40
- if @http.code == 200
41
- body = @http.body.lines
42
- body.each do |l|
43
- allow_dir << l.split('Allow: ')[1] if l.match(/Allow:/)
44
- end
45
- else
46
- puts "[+] Not giving code 200.\n"
47
- end
48
- open_links = []
49
- allow_dir.each do |path|
50
- link = Snackhack2::get(File.join(@site, path.strip))
51
- if link.code == 200
52
- valid_links = "#{@site}#{path}"
53
- open_links << valid_links
54
- end
55
- end
56
- open_links
57
- end
58
-
59
- def disallow_robots
60
- disallow_dir = []
61
- if @http.code == 200
62
- body = @http.body.lines
63
- body.each do |l|
64
- disallow_dir << l.split('Disallow: ')[1] if l.match(/Disallow:/)
65
- end
66
- else
67
- puts "[+] Not giving code 200.\n"
68
- end
69
- open_links = []
70
- disallow_dir.each do |path|
71
- link = Snackhack2::get(File.join(@site, path.strip))
72
- if link.code == 200
73
- valid_links = "#{@site}#{path}"
74
- open_links << valid_links
75
- end
76
- rescue StandardError
77
- end
78
- open_links
79
- end
80
- end
81
- end
1
+ # frozen_string_literal: true
2
+
3
+ module Snackhack2
4
+ class Robots
5
+ def initialize(site, save_file: true)
6
+ @site = site
7
+ @http = Snackhack2.get(File.join(@site, 'robots.txt'))
8
+ @save_file = save_file
9
+ end
10
+
11
+ attr_reader :save_file
12
+
13
+ def run
14
+ save_txt_file = ''
15
+ allow = allow_robots
16
+ disallow = disallow_robots
17
+ if @save_file
18
+ save_txt_file += "ALLOW:\n\n"
19
+ unless allow.empty?
20
+ allow.each do |list|
21
+ save_txt_file += list
22
+ end
23
+ end
24
+ save_txt_file += "DISALLOW:\n\n"
25
+ unless disallow.empty?
26
+ disallow.each do |list|
27
+ save_txt_file += list
28
+ end
29
+ end
30
+ else
31
+ puts allow
32
+ puts disallow
33
+ end
34
+ Snackhack2.file_save(@site, 'robots', save_txt_file) if @save_file
35
+ end
36
+
37
+ def allow_robots
38
+ allow_dir = []
39
+ if @http.code == 200
40
+ body = @http.body.lines
41
+ body.each do |l|
42
+ allow_dir << l.split('Allow: ')[1] if l.match(/Allow:/)
43
+ end
44
+ else
45
+ puts "[+] Not giving code 200.\n"
46
+ end
47
+ open_links = []
48
+ allow_dir.each do |path|
49
+ link = Snackhack2.get(File.join(@site, path.strip))
50
+ if link.code == 200
51
+ valid_links = "#{@site}#{path}"
52
+ open_links << valid_links
53
+ end
54
+ end
55
+ open_links
56
+ end
57
+
58
+ def disallow_robots
59
+ disallow_dir = []
60
+ if @http.code == 200
61
+ body = @http.body.lines
62
+ body.each do |l|
63
+ disallow_dir << l.split('Disallow: ')[1] if l.match(/Disallow:/)
64
+ end
65
+ else
66
+ puts "[+] Not giving code 200.\n"
67
+ end
68
+ open_links = []
69
+ disallow_dir.each do |path|
70
+ link = Snackhack2.get(File.join(@site, path.strip))
71
+ if link.code == 200
72
+ valid_links = "#{@site}#{path}"
73
+ open_links << valid_links
74
+ end
75
+ rescue StandardError
76
+ end
77
+ open_links
78
+ end
79
+ end
80
+ end
@@ -1,23 +1,25 @@
1
- require 'shellwords'
2
- module Snackhack2
3
- class ScreenShot
4
- attr_accessor :zip, :time
5
-
6
- # https://lolbas-project.github.io/lolbas/Binaries/Psr/
7
- def initialize
8
- @zip = "screenshots.zip"
9
- @time = 60
10
- end
11
-
12
- def run
13
- File.open("lol.bat", 'w+') { |file| file.write("psr.exe /start /output #{@zip} /sc 1 /gui 0") }
14
- File.open("lol2.bat", 'w+') { |file| file.write("psr.exe /stop") }
15
- Process.spawn("lol.bat")
16
- sleep @time.to_i
17
- system("lol2.bat")
18
- sleep 2
19
- File.delete("lol.bat")
20
- File.delete("lol2.bat")
21
- end
22
- end
23
- end
1
+ # frozen_string_literal: true
2
+
3
+ require 'shellwords'
4
+ module Snackhack2
5
+ class ScreenShot
6
+ attr_accessor :zip, :time
7
+
8
+ # https://lolbas-project.github.io/lolbas/Binaries/Psr/
9
+ def initialize
10
+ @zip = 'screenshots.zip'
11
+ @time = 60
12
+ end
13
+
14
+ def run
15
+ File.open('lol.bat', 'w+') { |file| file.write("psr.exe /start /output #{@zip} /sc 1 /gui 0") }
16
+ File.open('lol2.bat', 'w+') { |file| file.write('psr.exe /stop') }
17
+ Process.spawn('lol.bat')
18
+ sleep @time.to_i
19
+ system('lol2.bat')
20
+ sleep 2
21
+ File.delete('lol.bat')
22
+ File.delete('lol2.bat')
23
+ end
24
+ end
25
+ end
@@ -1,22 +1,24 @@
1
- require 'httparty'
2
- require 'nokogiri'
3
- module Snackhack2
4
- class SiteMap
5
- def initialize(site)
6
- @site = site
7
- end
8
-
9
- def run
10
- sm = Snackhack2::get(File.join(@site, "sitemap.xml"))
11
- if sm.code == 200
12
- if !sm.body.include?("Not Found")
13
- Snackhack2::file_save(@site, "site.xml", sm.body)
14
- else
15
- puts "[+] Eh. I don't think the site has a sitemap. Manually check just in case... :(\n\n"
16
- end
17
- else
18
- puts "[+] Status Code: #{sm.code}"
19
- end
20
- end
21
- end
22
- end
1
+ # frozen_string_literal: true
2
+
3
+ require 'httparty'
4
+ require 'nokogiri'
5
+ module Snackhack2
6
+ class SiteMap
7
+ def initialize(site)
8
+ @site = site
9
+ end
10
+
11
+ def run
12
+ sm = Snackhack2.get(File.join(@site, 'sitemap.xml'))
13
+ if sm.code == 200
14
+ if !sm.body.include?('Not Found')
15
+ Snackhack2.file_save(@site, 'site.xml', sm.body)
16
+ else
17
+ puts "[+] Eh. I don't think the site has a sitemap. Manually check just in case... :(\n\n"
18
+ end
19
+ else
20
+ puts "[+] Status Code: #{sm.code}"
21
+ end
22
+ end
23
+ end
24
+ end
@@ -1,20 +1,21 @@
1
+ # frozen_string_literal: true
1
2
 
2
-
3
- #Process.spawn("ruby -run -ehttpd . -p8008")
4
- #sleep 10
3
+ # Process.spawn("ruby -run -ehttpd . -p8008")
4
+ # sleep 10
5
5
  module Snackhack2
6
6
  class SSRF
7
7
  attr_accessor :site
8
+
8
9
  def initialize
9
10
  @site = site
10
11
  end
12
+
11
13
  def ssrf
12
- url = @site.gsub("SSRF", "http://google.com")
14
+ url = @site.gsub('SSRF', 'http://google.com')
13
15
  ht = HTTParty.get(url)
14
16
  if ht.body.include?("Search the world's information, including webpages, images, videos and more. Google has many special features to help you find exactly what you're looking for.")
15
17
  puts "Boom Shaka. It's vulnerable to SSRF..."
16
18
  end
17
-
18
19
  end
19
20
  end
20
- end
21
+ end
@@ -1,68 +1,68 @@
1
- # frozen_string_literal: true
2
-
3
- require 'uri'
4
- require 'resolv'
5
- require 'async/http/internet'
6
- module Snackhack2
7
- class Subdomains
8
- def initialize(site, wordlist: nil)
9
- @site = site
10
- @wordlist = wordlist
11
- end
12
-
13
- def site
14
- @site.gsub("https://", "")
15
- end
16
-
17
- def wordlist
18
- File.join(__dir__, 'lists', 'subdomains.txt')
19
- end
20
-
21
- def run
22
- File.readlines(wordlist).each do |sd|
23
- resolv(sd)
24
- end
25
- end
26
-
27
- def brute
28
- found = ""
29
- File.readlines(wordlist).each do |l|
30
- s = "#{l.strip}.#{site}"
31
- begin
32
- puts File.join("https://", s)
33
- g = Snackhack2::get(File.join("https://", s))
34
- if g.code == 200
35
- found += s + "\n"
36
- elsif g.code == 300
37
- found += s + "\n"
38
- else
39
- puts "HTTP Code: #{g.code}"
40
- end
41
- rescue => e
42
- puts e
43
- end
44
- end
45
- Snackhack2::file_save(@site, "subdomain_brute", found)
46
- end
47
-
48
- def resolv(sd)
49
- # NOTE: this is really slow & multi thread does not work
50
- # due to resolv
51
- active = []
52
- subdomains = []
53
- Resolv::DNS.open do |dns|
54
- ress = dns.getresources "#{sd}.#{@site}", Resolv::DNS::Resource::IN::A
55
- unless ress.map(&:address).empty?
56
- address = ress.map(&:address)
57
- unless active.include?(address)
58
- active << address
59
- subdomains << "#{sd}.#{@site}" unless subdomains.include?(sd)
60
- end
61
- end
62
- end
63
- host = URI.parse(@site).host
64
- File.open("#{host}_subdomains.txt", 'w+') { |file| file.write(subdomains.join("\n")) }
65
- File.open("#{host}_ips.txt", 'w+') { |file| file.write(active.join("\n")) }
66
- end
67
- end
68
- end
1
+ # frozen_string_literal: true
2
+
3
+ require 'uri'
4
+ require 'resolv'
5
+ require 'async/http/internet'
6
+ module Snackhack2
7
+ class Subdomains
8
+ def initialize(site, wordlist: nil)
9
+ @site = site
10
+ @wordlist = wordlist
11
+ end
12
+
13
+ def site
14
+ @site.gsub('https://', '')
15
+ end
16
+
17
+ def wordlist
18
+ File.join(__dir__, 'lists', 'subdomains.txt')
19
+ end
20
+
21
+ def run
22
+ File.readlines(wordlist).each do |sd|
23
+ resolv(sd)
24
+ end
25
+ end
26
+
27
+ def brute
28
+ found = ''
29
+ File.readlines(wordlist).each do |l|
30
+ s = "#{l.strip}.#{site}"
31
+ begin
32
+ puts File.join('https://', s)
33
+ g = Snackhack2.get(File.join('https://', s))
34
+ if g.code == 200
35
+ found += "#{s}\n"
36
+ elsif g.code == 300
37
+ found += "#{s}\n"
38
+ else
39
+ puts "HTTP Code: #{g.code}"
40
+ end
41
+ rescue StandardError => e
42
+ puts e
43
+ end
44
+ end
45
+ Snackhack2.file_save(@site, 'subdomain_brute', found)
46
+ end
47
+
48
+ def resolv(sd)
49
+ # NOTE: this is really slow & multi thread does not work
50
+ # due to resolv
51
+ active = []
52
+ subdomains = []
53
+ Resolv::DNS.open do |dns|
54
+ ress = dns.getresources "#{sd}.#{@site}", Resolv::DNS::Resource::IN::A
55
+ unless ress.map(&:address).empty?
56
+ address = ress.map(&:address)
57
+ unless active.include?(address)
58
+ active << address
59
+ subdomains << "#{sd}.#{@site}" unless subdomains.include?(sd)
60
+ end
61
+ end
62
+ end
63
+ host = URI.parse(@site).host
64
+ File.open("#{host}_subdomains.txt", 'w+') { |file| file.write(subdomains.join("\n")) }
65
+ File.open("#{host}_ips.txt", 'w+') { |file| file.write(active.join("\n")) }
66
+ end
67
+ end
68
+ end
@@ -1,43 +1,41 @@
1
- require 'async/http/internet'
2
- module Snackhack2
3
- class Subdomains2
4
- def initialize(site)
5
- @site = site
6
- @urls = []
7
- end
8
-
9
- def wordlist
10
- File.join(__dir__, 'lists', 'subdomains.txt')
11
- end
12
-
13
- def save
14
- Snackhack2::file_save(@site, "subdomain_brute2", @urls.join("\n"))
15
- end
16
-
17
- def run
18
- File.readlines(wordlist).each do |a|
19
- url = "https://" + a.strip + "." + @site.gsub("https://", "")
20
- fetch(url)
21
- puts url
22
- end
23
- save
24
- end
25
-
26
- def fetch(url)
27
- begin
28
- Sync do |task|
29
- task.with_timeout(2) do
30
- internet = Async::HTTP::Internet.new
31
- m = internet.get(url, { "user-agent" => Snackhack2::UA })
32
- if m.status == 200 or m.status == 301
33
- @urls << url
34
- end
35
- m.read
36
- end
37
- end
38
- rescue => e
39
- puts e
40
- end
41
- end
42
- end
43
- end
1
+ # frozen_string_literal: true
2
+
3
+ require 'async/http/internet'
4
+ module Snackhack2
5
+ class Subdomains2
6
+ def initialize(site)
7
+ @site = site
8
+ @urls = []
9
+ end
10
+
11
+ def wordlist
12
+ File.join(__dir__, 'lists', 'subdomains.txt')
13
+ end
14
+
15
+ def save
16
+ Snackhack2.file_save(@site, 'subdomain_brute2', @urls.join("\n"))
17
+ end
18
+
19
+ def run
20
+ File.readlines(wordlist).each do |a|
21
+ url = "https://#{a.strip}.#{@site.gsub('https://', '')}"
22
+ fetch(url)
23
+ puts url
24
+ end
25
+ save
26
+ end
27
+
28
+ def fetch(url)
29
+ Sync do |task|
30
+ task.with_timeout(2) do
31
+ internet = Async::HTTP::Internet.new
32
+ m = internet.get(url, { 'user-agent' => Snackhack2::UA })
33
+ @urls << url if (m.status == 200) || (m.status == 301)
34
+ m.read
35
+ end
36
+ end
37
+ rescue StandardError => e
38
+ puts e
39
+ end
40
+ end
41
+ end
@@ -1,21 +1,23 @@
1
- require 'nokogiri'
2
- module Snackhack2
3
- class TomCat
4
- def initialize(site)
5
- @site = site
6
- end
7
-
8
- def run
9
- tc = Snackhack2::get(File.join(@site, "/docs/"))
10
- if tc.code == 404
11
- if tc.body.include?("Tomcat")
12
- doc = Nokogiri::HTML(tc.body)
13
- version = doc.at('h3').text
14
- puts "[+] Looks like the site is Tomcat, running #{version}."
15
- end
16
- else
17
- puts "[+] Status code: #{tc.code}"
18
- end
19
- end
20
- end
21
- end
1
+ # frozen_string_literal: true
2
+
3
+ require 'nokogiri'
4
+ module Snackhack2
5
+ class TomCat
6
+ def initialize(site)
7
+ @site = site
8
+ end
9
+
10
+ def run
11
+ tc = Snackhack2.get(File.join(@site, '/docs/'))
12
+ if tc.code == 404
13
+ if tc.body.include?('Tomcat')
14
+ doc = Nokogiri::HTML(tc.body)
15
+ version = doc.at('h3').text
16
+ puts "[+] Looks like the site is Tomcat, running #{version}."
17
+ end
18
+ else
19
+ puts "[+] Status code: #{tc.code}"
20
+ end
21
+ end
22
+ end
23
+ end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Snackhack2
4
- VERSION = '0.6.4'
4
+ VERSION = '0.6.5'
5
5
  end
@@ -1,27 +1,28 @@
1
- # frozen_string_literal: true
2
-
3
- module Snackhack2
4
- class WebServerCleaner
5
- attr_accessor :ip
6
- def initialize(path: File.join('/var/log', 'access.log'))
7
- @ip = ip
8
- @path = path
9
- end
10
-
11
- def run
12
- out = ''
13
- # generate random IP
14
- new_ip = Array.new(4) { rand(256) }.join('.')
15
- File.readlines(@path).each do |line|
16
- old_ip = line.match(/((25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.){3}(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)/)
17
- out += if old_ip.to_s == @ip
18
- line.gsub(old_ip.to_s, new_ip)
19
- else
20
- line
21
- end
22
- end
23
- File.delete(@path)
24
- File.open(@path, 'w+') { |file| file.write(out) }
25
- end
26
- end
27
- end
1
+ # frozen_string_literal: true
2
+
3
+ module Snackhack2
4
+ class WebServerCleaner
5
+ attr_accessor :ip
6
+
7
+ def initialize(path: File.join('/var/log', 'access.log'))
8
+ @ip = ip
9
+ @path = path
10
+ end
11
+
12
+ def run
13
+ out = ''
14
+ # generate random IP
15
+ new_ip = Array.new(4) { rand(256) }.join('.')
16
+ File.readlines(@path).each do |line|
17
+ old_ip = line.match(/((25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.){3}(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)/)
18
+ out += if old_ip.to_s == @ip
19
+ line.gsub(old_ip.to_s, new_ip)
20
+ else
21
+ line
22
+ end
23
+ end
24
+ File.delete(@path)
25
+ File.open(@path, 'w+') { |file| file.write(out) }
26
+ end
27
+ end
28
+ end