Skip to content

Commit 91e3f4c

Browse files
committed
Merge 'kernelsmith/msfconsole-grep'
Resolved a conflict between grep and go_pro (go_pro was added after grep). Adds @kernelsmith's grep command. Josh is determined to have msfconsole be his default shell, it seems. [Closes rapid7#1320] Conflicts: lib/msf/ui/console/command_dispatcher/core.rb
2 parents 40e801d + 52596ae commit 91e3f4c

File tree

4 files changed

+330
-45
lines changed

4 files changed

+330
-45
lines changed

lib/msf/core/set_rhosts.rb

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
#
2+
# Set RHOSTS in the +active_module+'s (or global if none) datastore from an array of addresses
3+
#
4+
# This stores all the addresses to a temporary file and utilizes the
5+
# <pre>file:/tmp/filename</pre> syntax to confer the addrs. +rhosts+
6+
# should be an Array. NOTE: the temporary file is *not* deleted
7+
# automatically.
8+
#
9+
def set_rhosts_from_addrs(rhosts)
10+
if rhosts.empty?
11+
print_status "The list is empty, cowardly refusing to set RHOSTS"
12+
return
13+
end
14+
if active_module
15+
mydatastore = active_module.datastore
16+
else
17+
# if there is no module in use set the list to the global variable
18+
mydatastore = self.framework.datastore
19+
end
20+
21+
if rhosts.length > 5
22+
# Lots of hosts makes 'show options' wrap which is difficult to
23+
# read, store to a temp file
24+
rhosts_file = Rex::Quickfile.new("msf-db-rhosts-")
25+
mydatastore['RHOSTS'] = 'file:'+rhosts_file.path
26+
# create the output file and assign it to the RHOSTS variable
27+
rhosts_file.write(rhosts.join("\n")+"\n")
28+
rhosts_file.close
29+
else
30+
# For short lists, just set it directly
31+
mydatastore['RHOSTS'] = rhosts.join(" ")
32+
end
33+
34+
print_line "RHOSTS => #{mydatastore['RHOSTS']}"
35+
print_line
36+
end

0 commit comments

Comments
 (0)