From 85b09a162a66e78a462d067cf706bbd5ed1610f8 Mon Sep 17 00:00:00 2001 From: Carter Brainerd Date: Tue, 17 Apr 2018 12:09:46 -0400 Subject: [PATCH] Add some efficiency improvements --- lib/msf/core/post/linux/system.rb | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/lib/msf/core/post/linux/system.rb b/lib/msf/core/post/linux/system.rb index 6caffceea1..aca05c8391 100644 --- a/lib/msf/core/post/linux/system.rb +++ b/lib/msf/core/post/linux/system.rb @@ -110,11 +110,9 @@ module System def get_listening_services(portsonly = false) services = {} begin - full = cmd_exec('netstat -tulpn') + full = cmd_exec('netstat -tulpn').to_s raise "You must be root to get listening ports" if full.include? '(No info could be read' - lines = full.split("\n").size - cmd = "netstat -tulpn | tail -n #{lines - 2}" - full = cmd_exec(cmd) + full = full[2..-1] full.delete!(':') # Only happens when getting services if portsonly