diff --git a/lib/rex/post/meterpreter/ui/console/command_dispatcher/stdapi/net.rb b/lib/rex/post/meterpreter/ui/console/command_dispatcher/stdapi/net.rb index 63d997a30950..01818ae2d71e 100644 --- a/lib/rex/post/meterpreter/ui/console/command_dispatcher/stdapi/net.rb +++ b/lib/rex/post/meterpreter/ui/console/command_dispatcher/stdapi/net.rb @@ -431,16 +431,17 @@ def cmd_portfwd(*args) cnt = 0 # Enumerate each TCP relay - service.each_tcp_relay { |lhost, lport, rhost, rport, opts| - next if (opts['MeterpreterRelay'] == nil) - - direction = 'Forward' - direction = 'Reverse' if opts['Reverse'] == true + service.each_tcp_relay do |lhost, lport, rhost, rport, opts| + next unless opts['MeterpreterRelay'] - table << [cnt + 1, "#{netloc(rhost, rport)}", "#{netloc(lhost, lport)}", direction] + if opts['Reverse'] + table << [cnt + 1, "#{netloc(rhost, rport)}", "#{netloc(lhost, lport)}", 'Reverse'] + else + table << [cnt + 1, "#{netloc(lhost, lport)}", "#{netloc(rhost, rport)}", 'Forward'] + end cnt += 1 - } + end print_line if cnt > 0