Aggressor Script for RC4 encryption
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#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