Skip to content

Commit 8595bae

Browse files
committed
first commit
0 parents  commit 8595bae

File tree

12 files changed

+247
-0
lines changed

12 files changed

+247
-0
lines changed

.gitignore

Lines changed: 79 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,79 @@
1+
# Created by .ignore support plugin (hsz.mobi)
2+
### Java template
3+
# Compiled class file
4+
*.class
5+
6+
# Log file
7+
*.log
8+
9+
# BlueJ files
10+
*.ctxt
11+
12+
# Mobile Tools for Java (J2ME)
13+
.mtj.tmp/
14+
15+
# Package Files #
16+
*.jar
17+
*.war
18+
*.nar
19+
*.ear
20+
*.zip
21+
*.tar.gz
22+
*.rar
23+
24+
# virtual machine crash logs, see http://www.java.com/en/download/help/error_hotspot.xml
25+
hs_err_pid*
26+
### JetBrains template
27+
# Covers JetBrains IDEs: IntelliJ, RubyMine, PhpStorm, AppCode, PyCharm, CLion, Android Studio and WebStorm
28+
# Reference: https://intellij-support.jetbrains.com/hc/en-us/articles/206544839
29+
30+
# User-specific stuff
31+
.idea/**/workspace.xml
32+
.idea/**/tasks.xml
33+
.idea/**/dictionaries
34+
.idea/**/shelf
35+
36+
# Sensitive or high-churn files
37+
.idea/**/dataSources/
38+
.idea/**/dataSources.ids
39+
.idea/**/dataSources.local.xml
40+
.idea/**/sqlDataSources.xml
41+
.idea/**/dynamic.xml
42+
.idea/**/uiDesigner.xml
43+
.idea/**/dbnavigator.xml
44+
45+
# Gradle
46+
.idea/**/gradle.xml
47+
.idea/**/libraries
48+
49+
# CMake
50+
cmake-build-debug/
51+
cmake-build-release/
52+
53+
# Mongo Explorer plugin
54+
.idea/**/mongoSettings.xml
55+
56+
# File-based project format
57+
*.iws
58+
59+
# IntelliJ
60+
out/
61+
62+
# mpeltonen/sbt-idea plugin
63+
.idea_modules/
64+
65+
# JIRA plugin
66+
atlassian-ide-plugin.xml
67+
68+
# Cursive Clojure plugin
69+
.idea/replstate.xml
70+
71+
# Crashlytics plugin (for Android Studio and IntelliJ)
72+
com_crashlytics_export_strings.xml
73+
crashlytics.properties
74+
crashlytics-build.properties
75+
fabric.properties
76+
77+
# Editor-based Rest Client
78+
.idea/httpRequests
79+

.idea/artifacts/decipher_mremoteng_jar.xml

Lines changed: 10 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

.idea/description.html

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

.idea/encodings.xml

Lines changed: 6 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

.idea/misc.xml

Lines changed: 9 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

.idea/modules.xml

Lines changed: 8 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

.idea/project-template.xml

Lines changed: 3 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

.idea/vcs.xml

Lines changed: 6 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

after_build.sh

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
#!/bin/sh
2+
3+
cd out/artifacts/decipher_mremoteng_jar
4+
zip -d decipher_mremoteng.jar 'META-INF/.SF' 'META-INF/.RSA' 'META-INF/*SF'

decipher_mremoteng.iml

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<module type="JAVA_MODULE" version="4">
3+
<component name="NewModuleRootManager" inherit-compiler-output="true">
4+
<exclude-output />
5+
<content url="file://$MODULE_DIR$">
6+
<sourceFolder url="file://$MODULE_DIR$/src" isTestSource="false" />
7+
<excludePattern pattern="*.SF" />
8+
<excludePattern pattern="&amp;.DSA" />
9+
<excludePattern pattern="*.RSA" />
10+
</content>
11+
<orderEntry type="inheritedJdk" />
12+
<orderEntry type="sourceFolder" forTests="false" />
13+
<orderEntry type="library" name="org.bouncycastle:bcprov-jdk15on:1.61" level="project" />
14+
<orderEntry type="library" name="commons-codec:commons-codec:1.9" level="project" />
15+
</component>
16+
</module>

src/META-INF/MANIFEST.MF

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
Manifest-Version: 1.0
2+
Main-Class: xyz.kmahyyg.htb_mr3m.Main
3+

src/xyz/kmahyyg/htb_mr3m/Main.java

Lines changed: 102 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,102 @@
1+
package xyz.kmahyyg.htb_mr3m;
2+
3+
//
4+
// htb_mr3m_decoder
5+
// Copyright (C) 2019 kmahyyg
6+
//
7+
// This program is free software: you can redistribute it and/or modify
8+
// it under the terms of the GNU Affero General Public License as published by
9+
// the Free Software Foundation, either version 3 of the License, or
10+
// (at your option) any later version.
11+
//
12+
// This program is distributed in the hope that it will be useful,
13+
// but WITHOUT ANY WARRANTY; without even the implied warranty of
14+
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15+
// GNU Affero General Public License for more details.
16+
//
17+
// You should have received a copy of the GNU Affero General Public License
18+
// along with this program. If not, see <http://www.gnu.org/licenses/>.
19+
//
20+
21+
import org.apache.commons.codec.binary.Base64;
22+
import org.bouncycastle.crypto.InvalidCipherTextException;
23+
import org.bouncycastle.crypto.generators.*;
24+
import org.bouncycastle.crypto.params.*;
25+
import org.bouncycastle.crypto.engines.*;
26+
import org.bouncycastle.crypto.modes.*;
27+
28+
import java.nio.charset.Charset;
29+
import java.util.Arrays;
30+
31+
public class Main {
32+
33+
private static int KeyBitSize = 128;
34+
private static int SaltBitSize = 128;
35+
private static int NonceBitSize = 128;
36+
37+
private static int MacBitSize = 128;
38+
private static int KeyDerivationIters = 1000;
39+
private static int Pkcs5S2KeyBitSize = 256;
40+
41+
private static String DefaultPassword = "mR3m";
42+
43+
public static void main(String[] args) {
44+
String encrypted_b64 = "";
45+
String decrypt_password = "";
46+
try {
47+
encrypted_b64 = args[0];
48+
System.out.println("User Input: " + encrypted_b64);
49+
}
50+
catch (Exception e){
51+
e.printStackTrace();
52+
System.out.println("Encrypted string not found. Exit.");
53+
System.out.println("Usage: htb_mr3m.jar <Base64-Encoded AES-128-GCM String Here> [Password user defined]");
54+
System.exit(1);
55+
}
56+
try {
57+
decrypt_password = args[1];
58+
} catch (ArrayIndexOutOfBoundsException e){
59+
decrypt_password = DefaultPassword;
60+
System.out.println("Use default password for cracking...");
61+
}
62+
63+
byte[] encrypted = Base64.decodeBase64(encrypted_b64);
64+
byte[] b_salt = Arrays.copyOfRange(encrypted, 0,16);
65+
byte[] b_associatedText = Arrays.copyOfRange(encrypted, 0,16);
66+
byte[] b_nonce = Arrays.copyOfRange(encrypted,16,32);
67+
byte[] b_ciphertext = Arrays.copyOfRange(encrypted,32, encrypted.length);
68+
69+
byte[] b_password = dvKeyGen(decrypt_password, b_salt);
70+
byte[] b_decrypted = decryptAEADgcm(b_password, b_nonce, b_ciphertext, b_associatedText);
71+
72+
String sfPlain = "";
73+
sfPlain = new String(b_decrypted, Charset.forName("UTF-8"));
74+
System.out.println("Decrypted Output: " + sfPlain);
75+
}
76+
77+
public static byte[] dvKeyGen(String password, byte[] salt){
78+
byte[] b_pwd = password.getBytes(Charset.forName("UTF-8"));
79+
// PBKDF2-SHA1-HMAC
80+
PKCS5S2ParametersGenerator pbkdf2gen = new PKCS5S2ParametersGenerator();
81+
pbkdf2gen.init(b_pwd, salt, KeyDerivationIters);
82+
byte[] derivedKey = ((KeyParameter) pbkdf2gen.generateDerivedMacParameters(Pkcs5S2KeyBitSize)).getKey();
83+
return derivedKey;
84+
}
85+
86+
public static byte[] decryptAEADgcm(byte[] password, byte[] nonce, byte[] cipherText, byte[]associatedText){
87+
KeyParameter pwdparam = new KeyParameter(password);
88+
AEADParameters aeadpm = new AEADParameters(pwdparam, MacBitSize, nonce, associatedText);
89+
GCMBlockCipher gcmcipher = new GCMBlockCipher(new AESEngine());
90+
gcmcipher.init(false, aeadpm);
91+
byte[] plainBytes = new byte[gcmcipher.getOutputSize(cipherText.length)];
92+
int retLen = gcmcipher.processBytes(cipherText, 0, cipherText.length, plainBytes,0);
93+
try {
94+
gcmcipher.doFinal(plainBytes, retLen);
95+
} catch (InvalidCipherTextException e) {
96+
e.printStackTrace();
97+
System.out.println("\n Error Occured While Trying to Decrypt the AES-128-GCM. \n");
98+
System.exit(2);
99+
}
100+
return plainBytes;
101+
}
102+
}

0 commit comments

Comments
 (0)