diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..035ac93 --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +KeyGeneratorMaven/target \ No newline at end of file diff --git a/KeyGeneratorMaven/.idea/.gitignore b/KeyGeneratorMaven/.idea/.gitignore new file mode 100644 index 0000000..26d3352 --- /dev/null +++ b/KeyGeneratorMaven/.idea/.gitignore @@ -0,0 +1,3 @@ +# Default ignored files +/shelf/ +/workspace.xml diff --git a/KeyGeneratorMaven/.idea/compiler.xml b/KeyGeneratorMaven/.idea/compiler.xml new file mode 100644 index 0000000..f94f08e --- /dev/null +++ b/KeyGeneratorMaven/.idea/compiler.xml @@ -0,0 +1,13 @@ + + + + + + + + + + + + + \ No newline at end of file diff --git a/KeyGeneratorMaven/.idea/encodings.xml b/KeyGeneratorMaven/.idea/encodings.xml new file mode 100644 index 0000000..aa00ffa --- /dev/null +++ b/KeyGeneratorMaven/.idea/encodings.xml @@ -0,0 +1,7 @@ + + + + + + + \ No newline at end of file diff --git a/KeyGeneratorMaven/.idea/jarRepositories.xml b/KeyGeneratorMaven/.idea/jarRepositories.xml new file mode 100644 index 0000000..712ab9d --- /dev/null +++ b/KeyGeneratorMaven/.idea/jarRepositories.xml @@ -0,0 +1,20 @@ + + + + + + + + + + + \ No newline at end of file diff --git a/KeyGeneratorMaven/.idea/misc.xml b/KeyGeneratorMaven/.idea/misc.xml new file mode 100644 index 0000000..4fca40c --- /dev/null +++ b/KeyGeneratorMaven/.idea/misc.xml @@ -0,0 +1,12 @@ + + + + + + + + \ No newline at end of file diff --git a/KeyGeneratorMaven/.idea/vcs.xml b/KeyGeneratorMaven/.idea/vcs.xml new file mode 100644 index 0000000..6c0b863 --- /dev/null +++ b/KeyGeneratorMaven/.idea/vcs.xml @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/KeyGeneratorMaven/pom.xml b/KeyGeneratorMaven/pom.xml index e3f6bfe..8cb781d 100644 --- a/KeyGeneratorMaven/pom.xml +++ b/KeyGeneratorMaven/pom.xml @@ -3,10 +3,10 @@ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> 4.0.0 - org.example KeyGeneratorMaven 1.0-SNAPSHOT + jar 17 @@ -19,13 +19,11 @@ org.bouncycastle bcprov-jdk15on 1.70 - import org.bouncycastle bcprov-ext-jdk15on 1.70 - import @@ -34,9 +32,26 @@ - org.apache.maven.plugins - maven-compiler-plugin - 3.8.1 + maven-assembly-plugin + + + + org.example.Main + + + + jar-with-dependencies + + + + + make-assembly + package + + single + + + diff --git a/KeyGeneratorMaven/src/main/java/org/example/Main.java b/KeyGeneratorMaven/src/main/java/org/example/Main.java index 8818c69..581116c 100644 --- a/KeyGeneratorMaven/src/main/java/org/example/Main.java +++ b/KeyGeneratorMaven/src/main/java/org/example/Main.java @@ -1,95 +1,48 @@ package org.example; -import javax.crypto.*; -import javax.crypto.spec.IvParameterSpec; -import javax.crypto.spec.PBEKeySpec; -import javax.crypto.spec.SecretKeySpec; +import java.io.File; +import java.io.FileWriter; +import java.io.IOException; import java.security.*; -import java.security.spec.InvalidKeySpecException; -import java.util.Arrays; -import java.util.Base64; import org.bouncycastle.jce.provider.BouncyCastleProvider; public class Main { - private static final byte[] iv = {-126, -30, -6, -75, -99, -117, -66, 117, 39, -65, -126, -27, -12, 38, -99, 86}; - private static final byte[] salt = {-92, -102, -105, -123, 71, -33, 69, -39, -27, -32, 21, 33, 126, -81, 69, 59, 57, 29, -83, -15}; + + public static void WriteTxtFile(String txtFile, String txt){ + try { + System.out.println("Writing: "+txtFile); + FileWriter txtStream = new FileWriter(txtFile); + txtStream.write(txt); + txtStream.close(); + } catch (IOException e) { + System.out.println("Failed to write file" + txtFile); + } + + } + public static void main(String[] args) { Security.addProvider(new BouncyCastleProvider()); - System.out.println("usrename: "+encryptString("transrights@transgender.lgbt")); - System.out.println("password: "+encryptString("Trans Rights are Human Rights")); - System.out.println("accountId: "+encryptString("-6148914691236517206")); - } - - private static String getAndroidId(){ - return "a256d883de6fe05a"; - //return Settings.Secure.getString(this.ctx.getContentResolver(), "android_id");; - } - - private static int getPsmUid() { - return 10123; - } - private static String base64(byte[] data){ - byte[] base64 = Base64.getEncoder().encode(data); - return new String(base64); - } - private static String encryptString(String str) { - byte[] data = str.getBytes(); - byte[] encryptedData = encrypt(data); - if(encryptedData != null){ - byte[] encodedData = Arrays.copyOf(encryptedData, encryptedData.length + 2); - encodedData[encodedData.length - 2] = 1; - encodedData[encodedData.length - 1] = 1; - - return base64(encodedData); + if(args.length < 4) { + System.out.println("Usage: "); + return; } - return ""; - } - private static byte[] encrypt(byte[] input){ - try { - Cipher cipher =generateKeyCipher(Main.salt, Main.iv, Cipher.ENCRYPT_MODE); - if (cipher != null) { - return cipher.doFinal(input); - } - } catch (BadPaddingException | IllegalBlockSizeException e) { } - return null; + StringEncryptor stringEncryptor = new StringEncryptor(args[0], Integer.parseInt(args[1])); + String emailAddress = args[2]; + String password = args[3]; + long accountId = Long.parseLong(args[4], 16); + + new File("shared_prefs").mkdirs(); + WriteTxtFile("shared_prefs/SigninInfo.xml", "\n\n"+stringEncryptor.encryptString(emailAddress)+"\n\n\n"+stringEncryptor.encryptString(password)+"\n\n\n\n"); + WriteTxtFile("shared_prefs/com.playstation.psstore_preferences.xml", "\n\n\n"+stringEncryptor.encryptString(String.valueOf(accountId)) +"\n\n\n\n\n\n\n\nUS\n\n\n\n\n\n387ce7e424258aef426aaa5be8a1638a\n\n\nen\n\n\n\n"); + WriteTxtFile("shared_prefs/RunningContentInfo.xml", "\n\n\n\n\n"); + WriteTxtFile("shared_prefs/LocalLibrary.xml", "\n\n\n\n\n\n"); } - private static Cipher generateKeyCipher(final byte[] salt, final byte[] iv, final int opmode) { - try { - final String androidId = getAndroidId(); - final String psmUid = String.valueOf(getPsmUid()); - if (androidId == null || psmUid == null) { - throw new InvalidParameterException(); - } - final SecretKeyFactory skeyFactory = SecretKeyFactory.getInstance("PBEWITHSHAAND256BITAES-CBC-BC"); - final char[] charArray = (androidId + psmUid + " com.playstation.psstore ").toCharArray(); - final PBEKeySpec keySpec = new PBEKeySpec(charArray, salt, 16, 256); - Arrays.fill(charArray, '\0'); - final SecretKeySpec key = new SecretKeySpec(skeyFactory.generateSecret(keySpec).getEncoded(), "AES"); - final Cipher newCipher = Cipher.getInstance("AES/CBC/PKCS5Padding"); - newCipher.init(opmode, key, new IvParameterSpec(iv), new SecureRandom()); - return newCipher; - } - catch (NoSuchPaddingException ex) { - return null; - } - catch (InvalidAlgorithmParameterException ex2) { - return null; - } - catch (InvalidKeyException ex3) { - return null; - } - catch (InvalidKeySpecException ex4) { - return null; - } - catch (NoSuchAlgorithmException ex5) { - return null; - } - } + } diff --git a/KeyGeneratorMaven/src/main/java/org/example/StringEncryptor.java b/KeyGeneratorMaven/src/main/java/org/example/StringEncryptor.java new file mode 100644 index 0000000..e3da50a --- /dev/null +++ b/KeyGeneratorMaven/src/main/java/org/example/StringEncryptor.java @@ -0,0 +1,93 @@ +package org.example; + +import javax.crypto.*; +import javax.crypto.spec.IvParameterSpec; +import javax.crypto.spec.PBEKeySpec; +import javax.crypto.spec.SecretKeySpec; +import java.security.*; +import java.security.spec.InvalidKeySpecException; +import java.util.Arrays; +import java.util.Base64; + +public class StringEncryptor { + private static final byte[] iv = {-126, -30, -6, -75, -99, -117, -66, 117, 39, -65, -126, -27, -12, 38, -99, 86}; + private static final byte[] salt = {-92, -102, -105, -123, 71, -33, 69, -39, -27, -32, 21, 33, 126, -81, 69, 59, 57, 29, -83, -15}; + + private String ANDROID_ID = ""; + private int PSM_UID = 0; + + StringEncryptor(String androidId, int psmUid){ + ANDROID_ID = androidId; + psmUid = psmUid; + } + + private String getAndroidId(){ + return ANDROID_ID; + //return Settings.Secure.getString(this.ctx.getContentResolver(), "android_id");; + } + + private int getPsmUid() { + return PSM_UID; + } + private String base64(byte[] data){ + byte[] base64 = Base64.getEncoder().encode(data); + return new String(base64); + } + + public String encryptString(String str) { + byte[] data = str.getBytes(); + byte[] encryptedData = encrypt(data); + if(encryptedData != null){ + byte[] encodedData = Arrays.copyOf(encryptedData, encryptedData.length + 2); + encodedData[encodedData.length - 2] = 1; + encodedData[encodedData.length - 1] = 1; + + return base64(encodedData); + } + return ""; + } + + private byte[] encrypt(byte[] input){ + try { + Cipher cipher =generateKeyCipher(StringEncryptor.salt, StringEncryptor.iv, Cipher.ENCRYPT_MODE); + if (cipher != null) { + return cipher.doFinal(input); + } + } catch (BadPaddingException | IllegalBlockSizeException e) { } + return null; + + } + + private Cipher generateKeyCipher(final byte[] salt, final byte[] iv, final int opmode) { + try { + final String androidId = getAndroidId(); + final String psmUid = String.valueOf(getPsmUid()); + if (androidId == null || psmUid == null) { + throw new InvalidParameterException(); + } + final SecretKeyFactory skeyFactory = SecretKeyFactory.getInstance("PBEWITHSHAAND256BITAES-CBC-BC"); + final char[] charArray = (androidId + psmUid + " com.playstation.psstore ").toCharArray(); + final PBEKeySpec keySpec = new PBEKeySpec(charArray, salt, 16, 256); + Arrays.fill(charArray, '\0'); + final SecretKeySpec key = new SecretKeySpec(skeyFactory.generateSecret(keySpec).getEncoded(), "AES"); + final Cipher newCipher = Cipher.getInstance("AES/CBC/PKCS5Padding"); + newCipher.init(opmode, key, new IvParameterSpec(iv), new SecureRandom()); + return newCipher; + } + catch (NoSuchPaddingException ex) { + return null; + } + catch (InvalidAlgorithmParameterException ex2) { + return null; + } + catch (InvalidKeyException ex3) { + return null; + } + catch (InvalidKeySpecException ex4) { + return null; + } + catch (NoSuchAlgorithmException ex5) { + return null; + } + } +} diff --git a/SigninInfo.xml b/SigninInfo.xml deleted file mode 100644 index 078dffb..0000000 --- a/SigninInfo.xml +++ /dev/null @@ -1,9 +0,0 @@ - - -ixazRIfzsgM1qLucnDvcRgEB - - - -j+/dWQjJmm1gvG1IuevMpKuebIxTwgQMk8vEu66xmqkBAQ== - -