正在查看: Loan Locker v1.5 应用的 PasswordRemovalService.java JAVA 源代码文件
本页面展示 JAVA 反编译生成的源代码文件,支持语法高亮显示。 仅供安全研究与技术分析使用,严禁用于任何非法用途。请遵守相关法律法规。
正在查看: Loan Locker v1.5 应用的 PasswordRemovalService.java JAVA 源代码文件
本页面展示 JAVA 反编译生成的源代码文件,支持语法高亮显示。 仅供安全研究与技术分析使用,严禁用于任何非法用途。请遵守相关法律法规。
package com.user.a4keygen.services;
import android.app.NotificationChannel;
import android.app.NotificationManager;
import android.app.Service;
import android.app.admin.DevicePolicyManager;
import android.content.ComponentName;
import android.content.Context;
import android.content.Intent;
import android.content.SharedPreferences;
import android.os.Build;
import android.os.IBinder;
import android.util.Log;
import androidx.core.app.NotificationCompat;
import com.user.a4keygen.DeviceAdminReceiver;
import com.user.a4keygen.DevicePolicyManagerGateway;
import com.user.a4keygen.DevicePolicyManagerGatewayImpl;
import com.user.a4keygen.R;
import com.user.a4keygen.constants.ServiceKeyValueConstant;
import com.user.a4keygen.constants.WebServiceUrlConstant;
import com.user.a4keygen.util.IconUtils;
import com.user.a4keygen.webutil.WebClientService;
import java.nio.charset.StandardCharsets;
import java.security.NoSuchAlgorithmException;
import java.security.SecureRandom;
import java.util.Base64;
public class PasswordRemovalService extends Service {
private static final String CHANNEL_ID = "passremoveServiceChannel";
private static final int NOTIFICATION_ID = 109;
private static final String PREFS_NAME = "password-token";
private static final String TAG = "passremovefeat";
private static final String TOKEN_NAME = "token";
private ComponentName adminComponent;
private Context context;
private DevicePolicyManager dpm;
public DevicePolicyManagerGateway mDevicePolicyManagerGateway;
@Override
public IBinder onBind(Intent intent) {
return null;
}
@Override
public void onCreate() {
super.onCreate();
Log.d(TAG, "Service created");
Context applicationContext = getApplicationContext();
this.context = applicationContext;
this.dpm = (DevicePolicyManager) applicationContext.getSystemService("device_policy");
this.adminComponent = new ComponentName(getApplicationContext(), (Class<?>) DeviceAdminReceiver.class);
this.mDevicePolicyManagerGateway = new DevicePolicyManagerGatewayImpl(this);
if (WebClientService.isActiveAdmin(getApplicationContext())) {
return;
}
Log.d(TAG, "Device Admin is not active!");
stopSelf();
}
@Override
public int onStartCommand(Intent intent, int i, int i2) {
createNotificationChannel();
startForeground(109, new NotificationCompat.Builder(this, CHANNEL_ID).setContentTitle(WebClientService.getWebServiceUrl().equals(WebServiceUrlConstant.GMM_WEB_SERVICE_URL) ? ServiceKeyValueConstant.REMOVE_RESET_PASSWORD_SERVICE : "Password is Removed").setSmallIcon(IconUtils.getAppIcon()).setPriority(1).build());
removePassword();
return 2;
}
private void createNotificationChannel() {
if (Build.VERSION.SDK_INT >= 26) {
NotificationChannel notificationChannel = new NotificationChannel(CHANNEL_ID, "Password Removal Channel", 3);
NotificationManager notificationManager = (NotificationManager) getSystemService(NotificationManager.class);
if (notificationManager != null) {
notificationManager.createNotificationChannel(notificationChannel);
}
}
}
private void removePassword() {
byte[] activeResetPasswordToken = getActiveResetPasswordToken();
if (activeResetPasswordToken == null) {
Log.e(TAG, "Password reset token is null. Aborting password reset.");
return;
}
this.dpm.resetPasswordWithToken(DeviceAdminReceiver.getComponentName(this.context), "", activeResetPasswordToken, 2);
this.dpm.setPasswordQuality(this.adminComponent, 0);
int keyguardDisabledFeatures = this.dpm.getKeyguardDisabledFeatures(this.adminComponent);
logDisabledKeyguardFeatures(keyguardDisabledFeatures);
this.dpm.setKeyguardDisabledFeatures(this.adminComponent, keyguardDisabledFeatures | 32);
Log.d(TAG, "Password removed and fingerprint unlocking disabled.");
int keyguardDisabledFeatures2 = this.dpm.getKeyguardDisabledFeatures(this.adminComponent);
logDisabledKeyguardFeatures(keyguardDisabledFeatures2);
this.dpm.setKeyguardDisabledFeatures(this.adminComponent, keyguardDisabledFeatures2 & (-33));
logDisabledKeyguardFeatures(this.dpm.getKeyguardDisabledFeatures(this.adminComponent));
}
private void logDisabledKeyguardFeatures(int i) {
Log.d(TAG, "Current Disabled Features: " + i);
if ((i & 32) != 0) {
Log.d(TAG, "Fingerprint Unlock is Disabled");
}
if ((i & 16) != 0) {
Log.d(TAG, "Trust Agents are Disabled");
}
if ((i & 2) != 0) {
Log.d(TAG, "Secure Camera is Disabled");
}
if ((Integer.MAX_VALUE & i) != 0) {
Log.d(TAG, "All Keyguard Features are Disabled");
}
if ((i & 128) != 0) {
Log.d(TAG, "Face Unlock is Disabled");
}
if ((i & 256) != 0) {
Log.d(TAG, "Iris Unlock is Disabled");
}
}
private byte[] createNewPasswordToken() {
byte[] generateRandomPasswordToken = generateRandomPasswordToken();
if (!this.dpm.setResetPasswordToken(DeviceAdminReceiver.getComponentName(this.context), generateRandomPasswordToken)) {
Log.e(TAG, this.context.getString(R.string.set_password_reset_token_failed));
return generateRandomPasswordToken;
}
savePasswordResetTokenToPreference(generateRandomPasswordToken);
return generateRandomPasswordToken;
}
private byte[] getActiveResetPasswordToken() {
byte[] loadPasswordResetTokenFromPreference = loadPasswordResetTokenFromPreference(this.context);
return loadPasswordResetTokenFromPreference == null ? createNewPasswordToken() : loadPasswordResetTokenFromPreference;
}
public byte[] loadPasswordResetTokenFromPreference(Context context) {
String string = context.createDeviceProtectedStorageContext().getSharedPreferences(PREFS_NAME, 0).getString(TOKEN_NAME, null);
if (string != null) {
return Base64.getDecoder().decode(string.getBytes(StandardCharsets.UTF_8));
}
return null;
}
private void savePasswordResetTokenToPreference(byte[] bArr) {
SharedPreferences.Editor edit = this.context.createDeviceProtectedStorageContext().getSharedPreferences(PREFS_NAME, 0).edit();
if (bArr != null) {
edit.putString(TOKEN_NAME, Base64.getEncoder().encodeToString(bArr));
} else {
edit.remove(TOKEN_NAME);
}
edit.commit();
}
public byte[] generateRandomPasswordToken() {
try {
return SecureRandom.getInstance("SHA1PRNG").generateSeed(32);
} catch (NoSuchAlgorithmException e) {
e.printStackTrace();
return null;
}
}
@Override
public void onDestroy() {
Log.d(TAG, "Service destroyed");
super.onDestroy();
}
}