<NME> tokens.sl
<BEF> #
# Token Stealing...
#

import java.awt.*;
import java.awt.event.*;

import javax.swing.*;

sub updateTokenList {
	local('@commands $tmp_console');

	@commands = @(
		"use post/windows/gather/enum_domain_tokens",
		"set SESSION $1",
		"run");

	[$3 setEnabled: 0];
	[$3 setText: "Grabbing tokens..."];

	$tmp_console = createConsole($client);
	cmd_all_async($client, $tmp_console, @commands, lambda({
		local('$row @rows');
		if ($1 eq "run\n") {
			@rows = parseTextTable($3, @("Token Type", "Account Type", "Name", "Domain Admin"));
			[$model clear: size(@rows)];
			foreach $row (@rows) {
				[$model addEntry: $row];
			}
			call_async($client, "console.destroy", $tmp_console);
			[$model fireListeners];

			dispatchEvent(lambda({
				[$refresh setEnabled: 1];
				[$refresh setText: "Refresh"];
			}, \$refresh));
		}
	}, \$tmp_console, $model => $2, $refresh => $3));
}

sub stealToken {
			}
			[$model fireListeners];

			dispatchEvent(lambda({
				[$refresh setEnabled: 1];
				[$refresh setText: "Refresh"];
			}, \$refresh));
		}
	}, $model => $2, $refresh => $3));
}

sub stealToken {
        local('$dialog $table $model $steal $revert $whoami $refresh');
        $dialog = [new JPanel];
        [$dialog setLayout: [new BorderLayout]];

        ($table, $model) = setupTable("Name", @("Token Type", "Name"), @());
	[$table setSelectionMode: [ListSelectionModel SINGLE_SELECTION]];
        [$dialog add: [new JScrollPane: $table], [BorderLayout CENTER]];

	$steal = [new JButton: "Steal Token"];
	[$steal addActionListener: lambda({
		local('$value');
		$value = [$model getSelectedValue: $table];
		oneTimeShow("impersonate_token");
		m_cmd($sid, "impersonate_token ' $+ $value $+ '");
	}, $sid => $1, \$table, \$model)];

	$revert = [new JButton: "Revert to Self"];
	[$revert addActionListener: lambda({
		oneTimeShow("getuid");
		m_cmd($sid, "rev2self");
		m_cmd($sid, "getuid");
	}, $sid => $1)];

	$whoami = [new JButton: "Get UID"];
	[$whoami addActionListener: lambda({
		oneTimeShow("getuid");
		m_cmd($sid, "getuid");
	}, $sid => $1)];

	$refresh = [new JButton: "Refresh"];
	[$refresh addActionListener: lambda({
		updateTokenList($sid, $model, $refresh);
	}, $sid => $1, \$model, \$refresh)];

	updateTokenList($1, $model, $refresh);

        [$dialog add: center($steal, $revert, $whoami, $refresh), [BorderLayout SOUTH]];
        [$frame addTab: "Tokens $1", $dialog, $null, "Tokens " . sessionToHost($1)];
}

<MSG> use new console queue API for token stealing dialog


<DFF> @@ -8,34 +8,33 @@ import java.awt.event.*;
 import javax.swing.*;
 
 sub updateTokenList {
-	local('@commands $tmp_console');
-
-	@commands = @(
-		"use post/windows/gather/enum_domain_tokens",
-		"set SESSION $1",
-		"run");
+	local('$queue');
+	$queue = [new armitage.ConsoleQueue: $client];
+	[$queue addCommand: $null, "use post/windows/gather/enum_domain_tokens"];
+	[$queue addCommand: $null, "set SESSION $1"];
+	[$queue addCommand: "x", "run"];
 
 	[$3 setEnabled: 0];
 	[$3 setText: "Grabbing tokens..."];
 
-	$tmp_console = createConsole($client);
-	cmd_all_async($client, $tmp_console, @commands, lambda({
-		local('$row @rows');
-		if ($1 eq "run\n") {
-			@rows = parseTextTable($3, @("Token Type", "Account Type", "Name", "Domain Admin"));
-			[$model clear: size(@rows)];
-			foreach $row (@rows) {
-				[$model addEntry: $row];
-			}
-			call_async($client, "console.destroy", $tmp_console);
-			[$model fireListeners];
-
-			dispatchEvent(lambda({
-				[$refresh setEnabled: 1];
-				[$refresh setText: "Refresh"];
-			}, \$refresh));
+	[$queue addListener: lambda({
+		local('@rows $row');
+
+		@rows = parseTextTable($3, @("Token Type", "Account Type", "Name", "Domain Admin"));
+		[$model clear: size(@rows)];
+		foreach $row (@rows) {
+			[$model addEntry: $row];
 		}
-	}, \$tmp_console, $model => $2, $refresh => $3));
+		[$model fireListeners];
+
+		dispatchEvent(lambda({
+			[$refresh setEnabled: 1];
+			[$refresh setText: "Refresh"];
+		}, \$refresh));
+
+		[$queue stop];
+	}, $model => $2, $refresh => $3, \$queue)];
+	[$queue start];
 }
 
 sub stealToken {

{'commit': 'diff --git a/scripts/tokens.sl b/scripts/tokens.sl\nindex 1efd7c4..6304d29 100644\n--- a/scripts/tokens.sl\n+++ b/scripts/tokens.sl\n@@ -8,34 +8,33 @@ import java.awt.event.*;\n import javax.swing.*;\n \n sub updateTokenList {\n-\tlocal(\'@commands $tmp_console\');\n-\n-\t@commands = @(\n-\t\t"use post/windows/gather/enum_domain_tokens",\n-\t\t"set SESSION $1",\n-\t\t"run");\n+\tlocal(\'$queue\');\n+\t$queue = [new armitage.ConsoleQueue: $client];\n+\t[$queue addCommand: $null, "use post/windows/gather/enum_domain_tokens"];\n+\t[$queue addCommand: $null, "set SESSION $1"];\n+\t[$queue addCommand: "x", "run"];\n \n \t[$3 setEnabled: 0];\n \t[$3 setText: "Grabbing tokens..."];\n \n-\t$tmp_console = createConsole($client);\n-\tcmd_all_async($client, $tmp_console, @commands, lambda({\n-\t\tlocal(\'$row @rows\');\n-\t\tif ($1 eq "run\\n") {\n-\t\t\t@rows = parseTextTable($3, @("Token Type", "Account Type", "Name", "Domain Admin"));\n-\t\t\t[$model clear: size(@rows)];\n-\t\t\tforeach $row (@rows) {\n-\t\t\t\t[$model addEntry: $row];\n-\t\t\t}\n-\t\t\tcall_async($client, "console.destroy", $tmp_console);\n-\t\t\t[$model fireListeners];\n-\n-\t\t\tdispatchEvent(lambda({\n-\t\t\t\t[$refresh setEnabled: 1];\n-\t\t\t\t[$refresh setText: "Refresh"];\n-\t\t\t}, \\$refresh));\n+\t[$queue addListener: lambda({\n+\t\tlocal(\'@rows $row\');\n+\n+\t\t@rows = parseTextTable($3, @("Token Type", "Account Type", "Name", "Domain Admin"));\n+\t\t[$model clear: size(@rows)];\n+\t\tforeach $row (@rows) {\n+\t\t\t[$model addEntry: $row];\n \t\t}\n-\t}, \\$tmp_console, $model => $2, $refresh => $3));\n+\t\t[$model fireListeners];\n+\n+\t\tdispatchEvent(lambda({\n+\t\t\t[$refresh setEnabled: 1];\n+\t\t\t[$refresh setText: "Refresh"];\n+\t\t}, \\$refresh));\n+\n+\t\t[$queue stop];\n+\t}, $model => $2, $refresh => $3, \\$queue)];\n+\t[$queue start];\n }\n \n sub stealToken {\n', 'commit_subject': 'use new console queue API for token stealing dialog', 'repo_name': 'rsmudge/armitage', 'committer': {'name': 'rsmudge', 'email': 'f9a5c2933608ced34dd264bc953bdb4902d58b6f@957f4724-0442-2941-0443-fd1ab383608d', 'time_sec': '1332888325', 'tz_offset': '0', 'date': {'seconds': '1332888325'}}, 'commit_tree': 'da5d1cd8953b95e427bc16df0700615acfb8c4a8', 'commit_message': 'use new console queue API for token stealing dialog\n\n', 'language_name': 'HTML', 'license': 'bsd-3-clause', 'hunks': '@@ -8,34 +8,33 @@ import java.awt.event.*;\n import javax.swing.*;\n \n sub updateTokenList {\n-\tlocal(\'@commands $tmp_console\');\n-\n-\t@commands = @(\n-\t\t"use post/windows/gather/enum_domain_tokens",\n-\t\t"set SESSION $1",\n-\t\t"run");\n+\tlocal(\'$queue\');\n+\t$queue = [new armitage.ConsoleQueue: $client];\n+\t[$queue addCommand: $null, "use post/windows/gather/enum_domain_tokens"];\n+\t[$queue addCommand: $null, "set SESSION $1"];\n+\t[$queue addCommand: "x", "run"];\n \n \t[$3 setEnabled: 0];\n \t[$3 setText: "Grabbing tokens..."];\n \n-\t$tmp_console = createConsole($client);\n-\tcmd_all_async($client, $tmp_console, @commands, lambda({\n-\t\tlocal(\'$row @rows\');\n-\t\tif ($1 eq "run\\n") {\n-\t\t\t@rows = parseTextTable($3, @("Token Type", "Account Type", "Name", "Domain Admin"));\n-\t\t\t[$model clear: size(@rows)];\n-\t\t\tforeach $row (@rows) {\n-\t\t\t\t[$model addEntry: $row];\n-\t\t\t}\n-\t\t\tcall_async($client, "console.destroy", $tmp_console);\n-\t\t\t[$model fireListeners];\n-\n-\t\t\tdispatchEvent(lambda({\n-\t\t\t\t[$refresh setEnabled: 1];\n-\t\t\t\t[$refresh setText: "Refresh"];\n-\t\t\t}, \\$refresh));\n+\t[$queue addListener: lambda({\n+\t\tlocal(\'@rows $row\');\n+\n+\t\t@rows = parseTextTable($3, @("Token Type", "Account Type", "Name", "Domain Admin"));\n+\t\t[$model clear: size(@rows)];\n+\t\tforeach $row (@rows) {\n+\t\t\t[$model addEntry: $row];\n \t\t}\n-\t}, \\$tmp_console, $model => $2, $refresh => $3));\n+\t\t[$model fireListeners];\n+\n+\t\tdispatchEvent(lambda({\n+\t\t\t[$refresh setEnabled: 1];\n+\t\t\t[$refresh setText: "Refresh"];\n+\t\t}, \\$refresh));\n+\n+\t\t[$queue stop];\n+\t}, $model => $2, $refresh => $3, \\$queue)];\n+\t[$queue start];\n }\n \n sub stealToken {\n', 'addition_count': 22, 'deletion_count': 23, 'src_file': 'a/scripts/tokens.sl', 'tgt_file': 'b/scripts/tokens.sl', 'file_extension': '.sl', 'before_file': '#\n# Token Stealing...\n#\n\nimport java.awt.*;\nimport java.awt.event.*;\n\nimport javax.swing.*;\n\nsub updateTokenList {\n\tlocal(\'@commands $tmp_console\');\n\n\t@commands = @(\n\t\t"use post/windows/gather/enum_domain_tokens",\n\t\t"set SESSION $1",\n\t\t"run");\n\n\t[$3 setEnabled: 0];\n\t[$3 setText: "Grabbing tokens..."];\n\n\t$tmp_console = createConsole($client);\n\tcmd_all_async($client, $tmp_console, @commands, lambda({\n\t\tlocal(\'$row @rows\');\n\t\tif ($1 eq "run\\n") {\n\t\t\t@rows = parseTextTable($3, @("Token Type", "Account Type", "Name", "Domain Admin"));\n\t\t\t[$model clear: size(@rows)];\n\t\t\tforeach $row (@rows) {\n\t\t\t\t[$model addEntry: $row];\n\t\t\t}\n\t\t\tcall_async($client, "console.destroy", $tmp_console);\n\t\t\t[$model fireListeners];\n\n\t\t\tdispatchEvent(lambda({\n\t\t\t\t[$refresh setEnabled: 1];\n\t\t\t\t[$refresh setText: "Refresh"];\n\t\t\t}, \\$refresh));\n\t\t}\n\t}, \\$tmp_console, $model => $2, $refresh => $3));\n}\n\nsub stealToken {\n\t\t\t}\n\t\t\t[$model fireListeners];\n\n\t\t\tdispatchEvent(lambda({\n\t\t\t\t[$refresh setEnabled: 1];\n\t\t\t\t[$refresh setText: "Refresh"];\n\t\t\t}, \\$refresh));\n\t\t}\n\t}, $model => $2, $refresh => $3));\n}\n\nsub stealToken {\n        local(\'$dialog $table $model $steal $revert $whoami $refresh\');\n        $dialog = [new JPanel];\n        [$dialog setLayout: [new BorderLayout]];\n\n        ($table, $model) = setupTable("Name", @("Token Type", "Name"), @());\n\t[$table setSelectionMode: [ListSelectionModel SINGLE_SELECTION]];\n        [$dialog add: [new JScrollPane: $table], [BorderLayout CENTER]];\n\n\t$steal = [new JButton: "Steal Token"];\n\t[$steal addActionListener: lambda({\n\t\tlocal(\'$value\');\n\t\t$value = [$model getSelectedValue: $table];\n\t\toneTimeShow("impersonate_token");\n\t\tm_cmd($sid, "impersonate_token \' $+ $value $+ \'");\n\t}, $sid => $1, \\$table, \\$model)];\n\n\t$revert = [new JButton: "Revert to Self"];\n\t[$revert addActionListener: lambda({\n\t\toneTimeShow("getuid");\n\t\tm_cmd($sid, "rev2self");\n\t\tm_cmd($sid, "getuid");\n\t}, $sid => $1)];\n\n\t$whoami = [new JButton: "Get UID"];\n\t[$whoami addActionListener: lambda({\n\t\toneTimeShow("getuid");\n\t\tm_cmd($sid, "getuid");\n\t}, $sid => $1)];\n\n\t$refresh = [new JButton: "Refresh"];\n\t[$refresh addActionListener: lambda({\n\t\tupdateTokenList($sid, $model, $refresh);\n\t}, $sid => $1, \\$model, \\$refresh)];\n\n\tupdateTokenList($1, $model, $refresh);\n\n        [$dialog add: center($steal, $revert, $whoami, $refresh), [BorderLayout SOUTH]];\n        [$frame addTab: "Tokens $1", $dialog, $null, "Tokens " . sessionToHost($1)];\n}\n', 'message': 'use new console queue API for token stealing dialog\n\n', 'author_name': 'rsmudge', 'lang': 'sl'}