Skip to content

Commit

Permalink
uuid instead deviceID (read_phone _state)
Browse files Browse the repository at this point in the history
  • Loading branch information
ac-pm committed Mar 2, 2017
1 parent 21b0915 commit 4df4749
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 7 deletions.
1 change: 0 additions & 1 deletion app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@

<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.READ_PHONE_STATE" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ protected void onCreate(Bundle savedInstanceState) {
if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.M) {
boolean granted = checkSelfPermission(Manifest.permission.WRITE_EXTERNAL_STORAGE) == PackageManager.PERMISSION_GRANTED;
if (!granted) {
requestPermissions(new String[]{Manifest.permission.WRITE_EXTERNAL_STORAGE,Manifest.permission.READ_PHONE_STATE}, 0);
requestPermissions(new String[]{Manifest.permission.WRITE_EXTERNAL_STORAGE}, 0);
}
}else{
File inspeckage = new File(Environment.getExternalStorageDirectory().getAbsolutePath() + Config.P_ROOT);
Expand Down
2 changes: 2 additions & 0 deletions app/src/main/java/mobi/acpm/inspeckage/util/Config.java
Original file line number Diff line number Diff line change
Expand Up @@ -98,4 +98,6 @@ public class Config {

public static final String SP_USER_PASS = "login_pass";
public static final String SP_SWITCH_AUTH = "switch_auth";

public static final String KEYPAIR_ALIAS = "alias";
}
14 changes: 9 additions & 5 deletions app/src/main/java/mobi/acpm/inspeckage/webserver/WebServer.java
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@
import android.security.KeyPairGeneratorSpec;
import android.security.keystore.KeyGenParameterSpec;
import android.security.keystore.KeyProperties;
import android.telephony.TelephonyManager;
import android.text.Html;
import android.util.Log;

Expand All @@ -38,6 +37,7 @@
import java.util.Enumeration;
import java.util.List;
import java.util.Map;
import java.util.UUID;

import javax.net.ssl.KeyManagerFactory;
import javax.security.auth.x500.X500Principal;
Expand Down Expand Up @@ -100,9 +100,14 @@ public WebServer(String host, int port, Context context) throws IOException {
keyAliases.add(aliases.nextElement());
}

//use device id as an alias, that way each installation has your own alias
TelephonyManager telephonyManager = (TelephonyManager) mContext.getSystemService(Context.TELEPHONY_SERVICE);
String alias = telephonyManager.getDeviceId() + "";
//use uuid as an alias, that way each installation has your own alias
if(mPrefs.getString(Config.KEYPAIR_ALIAS,"").equals("")) {
SharedPreferences.Editor edit = mPrefs.edit();
edit.putString(Config.KEYPAIR_ALIAS, UUID.randomUUID().toString());
edit.apply();
}

String alias = mPrefs.getString(Config.KEYPAIR_ALIAS,"");

boolean genNewKey = true;
for (String key : keyAliases) {
Expand Down Expand Up @@ -1816,5 +1821,4 @@ public String hooksContent(String type, int count) {
public static boolean isModuleEnabled() {
return false;
}

}

0 comments on commit 4df4749

Please sign in to comment.