Files
metasploit-gs/modules/post/multi/general/wall.rb
T

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

63 lines
1.8 KiB
Ruby
Raw Normal View History

2015-11-11 09:15:32 -08:00
##
2017-07-24 06:26:21 -07:00
# This module requires Metasploit: https://metasploit.com/download
2015-11-11 09:15:32 -08:00
# Current source: https://github.com/rapid7/metasploit-framework
##
2016-03-08 14:02:44 +01:00
class MetasploitModule < Msf::Post
2015-11-11 09:15:32 -08:00
def initialize(info = {})
super(
update_info(
info,
2023-02-08 13:47:34 +00:00
'Name' => 'Write Messages to Users',
'Description' => %q{
2015-11-11 09:15:32 -08:00
This module utilizes the wall(1) or write(1) utilities, as appropriate,
to send messages to users on the target system.
},
2023-02-08 13:47:34 +00:00
'License' => MSF_LICENSE,
'Author' => [
2015-11-11 11:54:46 -08:00
'Jon Hart <jon_hart[at]rapid7.com>' # original metasploit module
],
2015-11-11 09:15:32 -08:00
# TODO: is there a way to do this on Windows?
2023-02-08 13:47:34 +00:00
'Platform' => %w[linux osx unix],
'SessionTypes' => %w[shell meterpreter]
2015-11-11 09:15:32 -08:00
)
)
register_options(
[
2015-11-11 11:54:46 -08:00
OptString.new('MESSAGE', [false, 'The message to send', '']),
2023-02-08 13:47:34 +00:00
OptString.new('USERS', [
false, 'List of users to write(1) to, separated by commas. ' \
' wall(1)s to all users by default'
]),
2015-11-11 11:54:46 -08:00
OptBool.new('COWSAY', [true, 'Display MESSAGE in a ~cowsay way', false])
2023-02-08 13:47:34 +00:00
]
)
2015-11-11 09:15:32 -08:00
end
def users
datastore['USERS'] ? datastore['USERS'].split(/\s*,\s*/) : nil
end
def message
2015-11-11 11:54:46 -08:00
if datastore['MESSAGE'].blank?
text = "Hello from a metasploit session at #{Time.now}"
else
text = datastore['MESSAGE']
end
2015-11-13 11:49:50 -08:00
datastore['COWSAY'] ? Rex::Text.cowsay(text) : text
2015-11-11 09:15:32 -08:00
end
def run
if users
2015-11-11 11:54:46 -08:00
# this requires that the target user has write turned on
2015-11-11 09:15:32 -08:00
users.map { |user| cmd_exec("echo '#{message}' | write #{user}") }
else
2015-11-11 11:54:46 -08:00
# this will send the messages to all users, regardless of whether or
# not they have write turned on. If the session is root, the -n will disable
# the annoying banner
cmd_exec("echo '#{message}' | wall -n")
2015-11-11 09:15:32 -08:00
end
end
end