Real-time collaboration for Jupyter Notebooks, Linux Terminals, LaTeX, VS Code, R IDE, and more,
all in one place.
Real-time collaboration for Jupyter Notebooks, Linux Terminals, LaTeX, VS Code, R IDE, and more,
all in one place.
Path: blob/master/modules/post/multi/general/wall.rb
Views: 11784
##1# This module requires Metasploit: https://metasploit.com/download2# Current source: https://github.com/rapid7/metasploit-framework3##45class MetasploitModule < Msf::Post6def initialize(info = {})7super(8update_info(9info,10'Name' => 'Write Messages to Users',11'Description' => %q{12This module utilizes the wall(1) or write(1) utilities, as appropriate,13to send messages to users on the target system.14},15'License' => MSF_LICENSE,16'Author' => [17'Jon Hart <jon_hart[at]rapid7.com>' # original metasploit module18],19# TODO: is there a way to do this on Windows?20'Platform' => %w[linux osx unix],21'SessionTypes' => %w[shell meterpreter]22)23)24register_options(25[26OptString.new('MESSAGE', [false, 'The message to send', '']),27OptString.new('USERS', [28false, 'List of users to write(1) to, separated by commas. ' \29' wall(1)s to all users by default'30]),31OptBool.new('COWSAY', [true, 'Display MESSAGE in a ~cowsay way', false])32]33)34end3536def users37datastore['USERS'] ? datastore['USERS'].split(/\s*,\s*/) : nil38end3940def message41if datastore['MESSAGE'].blank?42text = "Hello from a metasploit session at #{Time.now}"43else44text = datastore['MESSAGE']45end4647datastore['COWSAY'] ? Rex::Text.cowsay(text) : text48end4950def run51if users52# this requires that the target user has write turned on53users.map { |user| cmd_exec("echo '#{message}' | write #{user}") }54else55# this will send the messages to all users, regardless of whether or56# not they have write turned on. If the session is root, the -n will disable57# the annoying banner58cmd_exec("echo '#{message}' | wall -n")59end60end61end626364