<commit_before>#
# -= Armitage Network Attack Collaboration Server =-
#
# This is a separate application. It creates a second interface that Armitage uses
# to collaborate with other network attack clients.
# 
# Features include:
# - Meterpreter multiplexing (writes take ownership of a session, reads are silently ignored
#   for non-owner clients).
# - Upload/download files (allows feature dependent on files to work)
# - Group chat (because everyone loves chatting...)
#
# This is a proof of concept quickly hacked out (do you see how long this code is?)
#
# My goal is to eventually see this technology ported to Metasploit's RPC interface
# so this second instance can be done away with.
#
# Any takers? :)
#

debug(7);

import msf.*;

sub result {
	local('$rv $key $value');
	$rv = [new HashMap];
	foreach $key => $value ($1) {
		[$rv put: "$key", "$value"];
	}
	return $rv;
}

sub event {
	local('$result');
	$result = formatDate("HH:mm:ss") . " $1";
	acquire($poll_lock);
	push(@events, $result);
	release($poll_lock);
}

sub client {
	local('$temp $result $method $eid $sid $args $data $session $index $rv $valid $h $channel $key $value $file $response $time $address $app $ver %async');

	# do these things asynchronously so we don't tie up a client's thread
	%async['module.execute'] = 1;
	%async['core.setg'] = 1;
	%async['console.destroy'] = 1;
	%async['console.write'] = 1;

	#
	# verify the client
	#
	$temp = readObject($handle);
	($method, $args) = $temp;
	if ($method ne "armitage.validate") {
		writeObject($handle, result(%(error => 1, message => "You're not authenticated")));
		return;
	}
	else {
		local('$user $pass');
		($user, $pass, $eid, $app, $ver) = $args;

		if ($user ne $_user || $pass ne $_pass) {
			warn("Rejected $eid (invalid login)");
			writeObject($handle, result(%(error => 1, message => "Invalid login.")));
			return;
		}
		else if ($app ne "armitage") {
			warn("Rejected $eid (wrong application)");
			writeObject($handle, result(%(error => 1, message => "Your client is not compatible with this server.\nPlease use the latest version of Armitage.")));
			return;
		}<commit_msg>make shell writes async too.<commit_after>#
# -= Armitage Network Attack Collaboration Server =-
#
# This is a separate application. It creates a second interface that Armitage uses
# to collaborate with other network attack clients.
# 
# Features include:
# - Meterpreter multiplexing (writes take ownership of a session, reads are silently ignored
#   for non-owner clients).
# - Upload/download files (allows feature dependent on files to work)
# - Group chat (because everyone loves chatting...)
#
# This is a proof of concept quickly hacked out (do you see how long this code is?)
#
# My goal is to eventually see this technology ported to Metasploit's RPC interface
# so this second instance can be done away with.
#
# Any takers? :)
#

debug(7);

import msf.*;

sub result {
	local('$rv $key $value');
	$rv = [new HashMap];
	foreach $key => $value ($1) {
		[$rv put: "$key", "$value"];
	}
	return $rv;
}

sub event {
	local('$result');
	$result = formatDate("HH:mm:ss") . " $1";
	acquire($poll_lock);
	push(@events, $result);
	release($poll_lock);
}

sub client {
	local('$temp $result $method $eid $sid $args $data $session $index $rv $valid $h $channel $key $value $file $response $time $address $app $ver %async');

	# do these things asynchronously so we don't tie up a client's thread
	%async['module.execute'] = 1;
	%async['core.setg'] = 1;
	%async['console.destroy'] = 1;
	%async['console.write'] = 1;
	%async['session.shell_write'] = 1;

	#
	# verify the client
	#
	$temp = readObject($handle);
	($method, $args) = $temp;
	if ($method ne "armitage.validate") {
		writeObject($handle, result(%(error => 1, message => "You're not authenticated")));
		return;
	}
	else {
		local('$user $pass');
		($user, $pass, $eid, $app, $ver) = $args;

		if ($user ne $_user || $pass ne $_<PASSWORD>) {
			warn("Rejected $eid (invalid login)");
			writeObject($handle, result(%(error => 1, message => "Invalid login.")));
			return;
		}
		else if ($app ne "armitage") {
			warn("Rejected $eid (wrong application)");
			writeObject($handle, result(%(error => 1, message => "Your client is not compatible with this server.\nPlease use the latest version of Armitage.")));
			return;
		}
{'fraction_non_alphanumeric': 0.15757716407519146, 'fraction_numerical': 0.004873520538407983, 'mean_word_length': 4.249695493300853, 'pattern_counts': {'":': 0, '<': 4, '<?xml version=': 0, '>': 18, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 2, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5128904', 'n_tokens_mistral': 1472, 'n_tokens_neox': 1377, 'n_words': 504}