|
| 1 | +## |
| 2 | +# This module requires Metasploit: http://metasploit.com/download |
| 3 | +# Current source: https://github.com/rapid7/metasploit-framework |
| 4 | +## |
| 5 | + |
| 6 | +require 'msf/core' |
| 7 | + |
| 8 | +class Metasploit3 < Msf::Post |
| 9 | + def initialize(info = {}) |
| 10 | + super( |
| 11 | + update_info( |
| 12 | + info, |
| 13 | + 'Name' => 'Write Messages to Users', |
| 14 | + 'Description' => %q{ |
| 15 | + This module utilizes the wall(1) or write(1) utilities, as appropriate, |
| 16 | + to send messages to users on the target system. |
| 17 | + }, |
| 18 | + 'License' => MSF_LICENSE, |
| 19 | + 'Author' => [ 'Jon Hart <jon_hart[at]rapid7.com>' ], |
| 20 | + # TODO: is there a way to do this on Windows? |
| 21 | + 'Platform' => %w(linux osx unix), |
| 22 | + 'SessionTypes' => %w(shell meterpreter) |
| 23 | + ) |
| 24 | + ) |
| 25 | + register_options( |
| 26 | + [ |
| 27 | + OptString.new('MESSAGE', [true, 'The message to send']), |
| 28 | + OptString.new('USERS', [false, 'List of users to write(1) to, separated by commas. ' \ |
| 29 | + ' wall(1)s to all users by default']) |
| 30 | + ], self.class) |
| 31 | + end |
| 32 | + |
| 33 | + def users |
| 34 | + datastore['USERS'] ? datastore['USERS'].split(/\s*,\s*/) : nil |
| 35 | + end |
| 36 | + |
| 37 | + def message |
| 38 | + datastore['MESSAGE'] ? datastore['MESSAGE'] : "Hello metasploit session #{session.id}, the time is #{Time.now}" |
| 39 | + end |
| 40 | + |
| 41 | + def run |
| 42 | + if users |
| 43 | + users.map { |user| cmd_exec("echo '#{message}' | write #{user}") } |
| 44 | + else |
| 45 | + cmd_exec("echo '#{message}' | wall") |
| 46 | + end |
| 47 | + end |
| 48 | +end |
0 commit comments