Skip to content

Instantly share code, notes, and snippets.

@CCob
Created January 28, 2021 20:09
Show Gist options
  • Save CCob/9dd8de00c2c6ad069301a225589223fa to your computer and use it in GitHub Desktop.
Save CCob/9dd8de00c2c6ad069301a225589223fa to your computer and use it in GitHub Desktop.
Aggressor Script for RC4 encryption
#RC4 encryption implementation using Java Crypto API
#Author: @_EthicalChaos_
import javax.crypto.spec.*;
import java.security.*;
import javax.crypto.*;
# $1 = plaintext, $2 = key
sub encryptRC4{
$cipher = [Cipher getInstance: "RC4"];
$key = [new SecretKeySpec: $2, "RC4"];
[$cipher init: [Cipher ENCRYPT_MODE], $key];
return [$cipher doFinal: $1];
}
sub decryptRC4{
$cipher = [Cipher getInstance: "RC4"];
$key = [new SecretKeySpec: $2, "RC4"];
[$cipher init: [Cipher DECRYPT_MODE], $key];
return [$cipher doFinal: $1];
}
# $1 = transformation, $2 = key, $3 = iv, $4 = data
sub encryptData{
$iv = $null;
$cipher = [Cipher getInstance: $1];
$algo = split('/', $1)[0];
$key = [new SecretKeySpec: $2, $algo];
if($3 != $null)
$iv = [new IvParametersSpec: $3];
if($iv != $null)
[$cipher init: [Cipher ENCRYPT_MODE], $key, $iv];
else
[$cipher init: [Cipher ENCRYPT_MODE], $key, $iv];
return [$cipher doFinal: $1];
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment