Skip to content

Commit 77dd952

Browse files
committed
Land rapid7#7592, check nil return value when using redis_command
2 parents 12af07d + 83a3a4e commit 77dd952

File tree

1 file changed

+9
-9
lines changed

1 file changed

+9
-9
lines changed

modules/auxiliary/scanner/redis/file_upload.rb

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -55,18 +55,18 @@ def send_file(path, content)
5555
# Get the currently configured dir and dbfilename before we overwrite them;
5656
# we should set them back to their original values after we are done.
5757
# XXX: this is a hack -- we should really parse the responses more correctly
58-
original_dir = redis_command('CONFIG', 'GET', 'dir').split(/\r\n/).last
59-
original_dbfilename = redis_command('CONFIG', 'GET', 'dbfilename').split(/\r\n/).last
58+
original_dir = (redis_command('CONFIG', 'GET', 'dir') || '').split(/\r\n/).last
59+
original_dbfilename = (redis_command('CONFIG', 'GET', 'dbfilename') || '').split(/\r\n/).last
6060
if datastore['DISABLE_RDBCOMPRESSION']
61-
original_rdbcompression = redis_command('CONFIG', 'GET', 'rdbcompression').split(/\r\n/).last
61+
original_rdbcompression = (redis_command('CONFIG', 'GET', 'rdbcompression') || '').split(/\r\n/).last
6262
end
6363

6464
# set the directory which stores the current redis local store
65-
data = redis_command('CONFIG', 'SET', 'dir', dirname)
65+
data = redis_command('CONFIG', 'SET', 'dir', dirname) || ''
6666
return unless data.include?('+OK')
6767

6868
# set the file name, relative to the above directory name, that is the redis local store
69-
data = redis_command('CONFIG', 'SET', 'dbfilename', basename)
69+
data = redis_command('CONFIG', 'SET', 'dbfilename', basename) || ''
7070
return unless data.include?('+OK')
7171

7272
# Compression string objects using LZF when dump .rdb databases ?
@@ -75,7 +75,7 @@ def send_file(path, content)
7575
# the dataset will likely be bigger if you have compressible values or
7676
# keys.
7777
if datastore['DISABLE_RDBCOMPRESSION'] && original_rdbcompression.upcase == 'YES'
78-
data = redis_command('CONFIG', 'SET', 'rdbcompression', 'no')
78+
data = redis_command('CONFIG', 'SET', 'rdbcompression', 'no') || ''
7979
if data.include?('+OK')
8080
reset_rdbcompression = true
8181
else
@@ -85,7 +85,7 @@ def send_file(path, content)
8585
end
8686

8787
if datastore['FLUSHALL']
88-
data = redis_command('FLUSHALL')
88+
data = redis_command('FLUSHALL') || ''
8989
unless data.include?('+OK')
9090
print_warning("#{peer} -- failed to flushall(); continuing")
9191
end
@@ -96,9 +96,9 @@ def send_file(path, content)
9696
# multiline. It also probably doesn't work well if the content isn't
9797
# simple ASCII text
9898
key = Rex::Text.rand_text_alpha(32)
99-
data = redis_command('SET', key, content)
99+
data = redis_command('SET', key, content) || ''
100100
return unless data.include?('+OK')
101-
data = redis_command('SAVE')
101+
data = redis_command('SAVE') || ''
102102

103103
if data.include?('+OK')
104104
print_good("#{peer} -- saved #{content.size} bytes inside of redis DB at #{path}")

0 commit comments

Comments
 (0)