您的位置:首页 > 理论基础 > 计算机网络

在iphone、ipad上安装一些常用命令行命令及实时抓取移动设备上的通信包(ADVsock2pipe+Wireshark+nc+tcpdump)

2015-08-28 18:21 731 查看
相信对Linux、Unix比较熟悉的朋友,在iphone或 ipad越狱后发现通过Cydia可以安装OpenSSH,一定都想安装上并且通过ssh登录上去看看,但是登录后却发现几乎没几个命令可用,也就只有ls、cd等一些常用的命令,至于ifconfig、ping、netstat等都没有。。。

下面就来介绍一下如何让iphone或 ipad拥有Linux、Unix常用的命令。

1、首先你的iphone或 ipad得先越狱,越狱后才有Cydia,才能安装OpenSSH。

2、记住在使用Cydia的时候,要选择“Developer”(开发者),如果一开始选择的是“User”,可以进入Cydia->Sources->Settings->Developer进行修改,否则搜索不到这些软件包。

3、安装并启动sshd后,通过ssh -l root IPAD_IP_ADDRESS登录,默认口令是:alpine,这是ios系统默认的root密码,记得及时修改。当然如果可以不用这么启动,其实只要安装openssh后,服务就会默认启动的。如果没有可以像Windows一样重启设备也可以。

4、下面就是一些软件包的名字:

adv-cmds #finger,fingerd,last,lsvfs,md,ps

basic-cmds #msg,uudecode,uuencode,write

bc #计算器工具

cURL #就是curl了

Diff Utilities #diff

diskdev-cmds #mount,quota,fsck等,忘记是否默认安装的

file #常用的file命令

file-cmds #chflags,compress

Find Utilites #find

Gawk #awk

grep #grep

inetutils #ftp,inetd,ping,telnet…

less #less

links #links,文本浏览器

lsof #lsof

netcat #nc

network-cmds #arp,ifconfig,route,traceroute

ngrep #ngrep (Network grep).

Nmap #nmap

rsync #rsync

Screen #screen

sed #sed

shell-cmds #killall,mktemp,time,which

system-cmds #iostat,login,sync,sysctl

tcpdump #tcpdump

top #top

unrar #unrar备用

unzip #unzip

VI IMproved #vim

wget #wget

whois #whois

注意:以下内容都很重要!

其实ios系统属于unix系统分支BSD系统的一支:“Darwin”系统。

例如我的iphone 4:

login as: root

root@192.168.91.34's password:

tutengyidumato-iPhone:~ root# uname -a

Darwin tutengyidumato-iPhone 11.0.0 Darwin Kernel Version 11.0.0: Tue Nov 1 20:33:58 PDT 2011; root:xnu-1878.4.46~1/RELEASE_ARM_S5L8930X iPhone3,1 arm N90AP Darwin

tutengyidumato-iPhone:~ root# uname -r

11.0.0

tutengyidumato-iPhone:~ root# hostname

tutengyidumato-iPhone

tutengyidumato-iPhone:~ root#信息说明:

以上信息显示,

系统以版本:11.0.0;

系统生成时间:Tue Nov 1 20:33:58 PDT 2011

内核版本:xnu-1878.4.46~1/RELEASE_ARM_S5L8930X iPhone3,1 arm N90AP Darwin

主机名:tutengyidumato-iPhone。

既然同属于BSD系统,那么就会有其相同特征和命令使用方法,比如使用apt-get命令。这个命令可以再cydia中安装,只要在搜索中输入apt字符,就会显示出关于apt命令的所有软件包,如果是标记命令行软件包的,安装即可,就会安装上apt-get。

安装apt-get后,其实不用再在cydia中搜索以上命令的软件包了。只要使用如下格式:

例如:ipad2上面测试当前网络,无论是3g还是wifi是否可用,该怎么办?其实很简单,像Windows一样使用ping命令进行测试即可:

操作如下:

zhouzhoumato-iPad:~ root# uname -a

Darwin zhouzhoumato-iPad 11.0.0 Darwin Kernel Version 11.0.0: Tue Nov 1 20:34:16 PDT 2011; root:xnu-1878.4.46~1/RELEASE_ARM_S5L8940X iPad2,1 arm K93AP Darwin

zhouzhoumato-iPad:~ root# uname -r

11.0.0

zhouzhoumato-iPad:~ root# hostname

-sh: hostname: command not found

zhouzhoumato-iPad:~ root#

上面信息显示:当前的ipad2设备连hostname都没有,所以首先安装一个hostname命令测试一下:

zhouzhoumato-iPad:~ root# apt-get install hostname

Reading package lists... Done

Building dependency tree

Reading state information... Done

Note, selecting inetutils instead of hostname

The following NEW packages will be installed:

inetutils

0 upgraded, 1 newly installed, 0 to remove and 0 not upgraded.

Need to get 0B/212kB of archives.

After this operation, 889kB of additional disk space will be used.

Selecting previously deselected package inetutils.

(Reading database ...

dpkg: serious warning: files list file for package `com.chronic-dev.greenpois0n.corona' missing, assuming package has no files currently installed.

2261 files and directories currently installed.)

Unpacking inetutils (from .../inetutils_1.6-8_iphoneos-arm.deb) ...

Setting up inetutils (1.6-8) ...

zhouzhoumato-iPad:~ root#

安装ping命令:

zhouzhoumato-iPad:~ root# apt-get install ping

Reading package lists... Done

Building dependency tree

Reading state information... Done

Note, selecting inetutils instead of ping

The following NEW packages will be installed:

inetutils

0 upgraded, 1 newly installed, 0 to remove and 0 not upgraded.

Need to get 0B/212kB of archives.

After this operation, 889kB of additional disk space will be used.

Selecting previously deselected package inetutils.

(Reading database ...

dpkg: serious warning: files list file for package `com.chronic-dev.greenpois0n.corona' missing, assuming package has no files currently installed.

2261 files and directories currently installed.)

Unpacking inetutils (from .../inetutils_1.6-8_iphoneos-arm.deb) ...

Setting up inetutils (1.6-8) ...

测试ping命令:

zhouzhoumato-iPad:~ root# ping

ping: missing host operand

Try `ping --help' or `ping --usage' for more information.

zhouzhoumato-iPad:~ root#

说明命令已经安装成功了。

使用ping命令测试网络:

zhouzhoumato-iPad:~ root# ping http://www.baidu.com/

PING http://www.a.shifen.com/ (119.75.218.77): 56 data bytes

64 bytes from 119.75.218.77: icmp_seq=0 ttl=52 time=31.919 ms

64 bytes from 119.75.218.77: icmp_seq=1 ttl=52 time=40.037 ms

^C--- http://www.a.shifen.com/ ping statistics ---

2 packets transmitted, 2 packets received, 0% packet loss

round-trip min/avg/max/stddev = 31.919/35.978/40.037/4.059 ms

zhouzhoumato-iPad:~ root#

使用apt-get的一些操作:

所以使用apt-get去执行一些相关的安装、更新、删除软件的动作很方便。这样更新安装后iphone或ipad就可以像完整的linux系统一样工作了。

apt-get的安装: apt-get install 软件包名

apt-get的更新:apt-get update 软件包名

apt-get的删除:apt-get remove 软件包名

目前移动设备上的应用的通信分析,HTTP层数据包可以使用web代理工具进行抓包改包,而底层的数据包要实时并可视化的分析(非实时的可以在设备上安装tcpdump抓包),除了用移动设备去连接PC提供的共享网络进行抓包外(《mobile app 通信分析方法小议》),还有一种新的方法,这种方法其实早就存在,主要是我wireshark太不熟悉了,误以为它只能通过网络接口(网卡啥的)抓包,实在太丢脸了。

下面要介绍的方法的核心原理,就是开辟一条PC与移动设备的通信管道,然后在PC上,让wireshark基于管道(PIPE)抓包

一、测试设备
PC(windows系统)
itouch 4g(iOS系统,Android系统都可以,但需要越狱或root)

二、工具
(1)PC上
wireshark
ADVsock2pipe
(2)itouch上(可以从cydia中下载)
nc
tcpdump
(3)网络环境
PC与itouch处于同一局域网
PC ip 10.0.0.23
itouch ip 10.0.0. 24

三、抓包步骤
第一步:在PC上运行ADVsock2pipe,输入如下命令

ADVsock2pipe.exe -pipe=wireshark -port 2134




第二步:在PC上运行wireshark,设置caption-Options





第三步:在移动设备itouch上,打开终端输入以下命令

由于移动设备输入太不方便了,我是在PC上SSH登录到移动设备上进行操作的

danimato-iPod:~ root# tcpdump -nn -w - -U -s 0 "not port 2134" | nc 10.0.0.23 2134

tcpdump: listening on en0, link-type EN10MB (Ethernet), capture size 65535 bytes
第四步:在移动设备上运行想要抓包分析的应用,即可在PC上实时的用wireshark观察数据包发送情况了



接下来打算研究一下即可抓移动设备的通信包,也可以进行FUZZ测试的方法。如果有好的移动应用通信包分析方法,可以联系我,共同讨论。
Gmail:danqingdani@gmail.com
参考:
http://wiki.wireshark.org/CaptureSetup/Pipes
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: