1. 程式人生 > >Android 反除錯、so檔案注入

Android 反除錯、so檔案注入

關鍵程式碼:

 Thread t=new Thread(new Runnable() {
       @Override
        public void run() {
            while (true){
                try {
                    Thread.sleep(100);
                    if(Debug.isDebuggerConnected()){
                        System.exit(0);
                    }

                    if
(isUnderTraced()){ System.exit(0); } } catch (InterruptedException e) { e.printStackTrace(); } } } },"SafeGuardThread"); t.start(); private boolean isUnderTraced() { String processStatusFilePath = String.format(Locale.US, "/proc/%d/status"
, android.os.Process.myPid()); File procInfoFile = new File(processStatusFilePath); try { BufferedReader b = new BufferedReader(new FileReader(procInfoFile)); String readLine; while ((readLine = b.readLine()) != null) { if(readLine.contains("TracerPid"
)) { String[] arrays = readLine.split(":"); if(arrays.length == 2) { int tracerPid = Integer.parseInt(arrays[1].trim()); if(tracerPid != 0) { return true; } } } } b.close(); } catch (Exception e) { e.printStackTrace(); } return false; }