mac抓包:Fiddler and charles

如果你还没尝试 用Fiddler抓包,我建议你直接看下面的用charles工具来抓包,Fiddler真的挫还要安装配置一大堆结果还不尽人意

如果你搞到一半有问题,不死心一定想用它抓个包的可以看看?。

1.Fiddler

(1)安装Mono

   下载地址:http://www.mono-project.com/download/#download-mac

 

mac抓包:Fiddler and charles

留意下下载的版本,我下载的是5.10.1

下载后点击安装,安装成功之后在Terminal执行命令(这里的5.10.1就是下载的版本号,记得根据自己的版本号来修改):

/Library/Frameworks/Mono.framework/Versions/5.10.1/bin/mozroots --import --sync

(2)配置环境变量,编辑.bash_profile文件:

在终端输入:sudo vi ~/.bash_profile,按i进入编辑状态,添加以下内容(这里5.10.1也是你下载的版本号)

export MONO_HOME=/Library/Frameworks/Mono.framework/Versions/5.10.1

export PATH=$PATH:$MONO_HOME/bin

按esc,然后:wq,保存成功了退出

(3)下载Fiddler

下载地址:https://www.telerik.com/download/fiddler 下载成功之后解压

运行Fiddler:

打开Terminal,进入到解压Fiddler路径里,执行命令运行:

sudo mono Fiddler.exe

如果启动失败并报错如下:

WARNING: The Carbon driver has not been ported to 64bits, and very few parts of Windows.Forms will work properly, or at all
Stacktrace:

  at <unknown> <0xffffffff>
  at (wrapper managed-to-native) System.Windows.Forms.XplatUICarbon.CGDisplayBounds (intptr) [0x00002] in <36fbc38531724d82b10aef6ebafea6e9>:0
  at System.Windows.Forms.XplatUICarbon.get_WorkingArea () [0x00005] in <36fbc38531724d82b10aef6ebafea6e9>:0
  at System.Windows.Forms.XplatUICarbon.get_VirtualScreen () [0x00000] in <36fbc38531724d82b10aef6ebafea6e9>:0
  at System.Windows.Forms.XplatUI.get_VirtualScreen () [0x00000] in <36fbc38531724d82b10aef6ebafea6e9>:0
  at System.Windows.Forms.Screen..cctor () [0x00034] in <36fbc38531724d82b10aef6ebafea6e9>:0
  at (wrapper runtime-invoke) object.runtime_invoke_void (object,intptr,intptr,intptr) [0x0001e] in <4fdc5ed61a074cafb49fa42deb20d521>:0
  at <unknown> <0xffffffff>
  at System.Windows.Forms.Form.get_CreateParams () [0x00157] in <36fbc38531724d82b10aef6ebafea6e9>:0
  at System.Windows.Forms.Control.CreateHandle () [0x0002a] in <36fbc38531724d82b10aef6ebafea6e9>:0
  at System.Windows.Forms.Form.CreateHandle () [0x00000] in <36fbc38531724d82b10aef6ebafea6e9>:0
  at System.Windows.Forms.Control.CreateControl () [0x00039] in <36fbc38531724d82b10aef6ebafea6e9>:0
  at System.Windows.Forms.Control.SetVisibleCore (bool) [0x0003a] in <36fbc38531724d82b10aef6ebafea6e9>:0
  at System.Windows.Forms.Form.SetVisibleCore (bool) [0x00065] in <36fbc38531724d82b10aef6ebafea6e9>:0
  at System.Windows.Forms.Control.set_Visible (bool) [0x00009] in <36fbc38531724d82b10aef6ebafea6e9>:0
  at System.Windows.Forms.Control.Show () [0x00000] in <36fbc38531724d82b10aef6ebafea6e9>:0
  at (wrapper remoting-invoke-with-check) System.Windows.Forms.Control.Show () [0x00031] in <36fbc38531724d82b10aef6ebafea6e9>:0
  at Fiddler.frmViewer. (string[]) [0x00081] in <09623c708fdb40a483cea147bbea7a7f>:0
  at Fiddler.frmViewer. (string[]) [0x00016] in <09623c708fdb40a483cea147bbea7a7f>:0
  at (wrapper runtime-invoke) <Module>.runtime_invoke_void_object (object,intptr,intptr,intptr) [0x0004e] in <09623c708fdb40a483cea147bbea7a7f>:0

Native stacktrace:

    0   mono                                0x000000010a02c3d1 mono_handle_native_crash + 257
    1   mono                                0x000000010a093e86 altstack_handle_and_restore + 70
    2   SkyLight                            0x00007fffaabd4fc2 SLDisplayBounds + 50
    3   ???                                 0x00000001117e038e 0x0 + 4588438414
    4   ???                                 0x000000010a62d486 0x0 + 4469216390
    5   mono                                0x0000000109f865f4 mono_jit_runtime_invoke + 1316
    6   mono                                0x000000010a17e238 do_runtime_invoke + 88
    7   mono                                0x000000010a17a2a4 mono_runtime_class_init_full + 996
    8   mono                                0x0000000109f7fa45 mono_jit_compile_method_inner + 2485
    9   mono                                0x0000000109f82903 mono_jit_compile_method_with_opt + 1379
    10  mono                                0x000000010a02e871 common_call_trampoline + 1217
    11  mono                                0x000000010a02e379 mono_magic_trampoline + 73
    12  ???                                 0x000000010a41839e 0x0 + 4467032990
    13  ???                                 0x000000011148b81b 0x0 + 4584945691
    14  ???                                 0x000000010d8a384f 0x0 + 4522129487
    15  ???                                 0x000000010d8a34c7 0x0 + 4522128583
    16  ???                                 0x000000010a62d043 0x0 + 4469215299
    17  mono                                0x0000000109f865f4 mono_jit_runtime_invoke + 1316
    18  mono                                0x000000010a17e238 do_runtime_invoke + 88
    19  mono                                0x000000010a181849 do_exec_main_checked + 137
    20  mono                                0x0000000109fef32f mono_jit_exec + 287
    21  mono                                0x0000000109ff1b63 mono_main + 9235
    22  mono                                0x0000000109f763ad main + 253
    23  mono                                0x0000000109f762a4 start + 52

Debug info from gdb:

(lldb) command source -s 0 '/tmp/mono-gdb-commands.Cli6iM'
Executing commands in '/tmp/mono-gdb-commands.Cli6iM'.
(lldb) process attach --pid 1326
warning: (x86_64) /Library/Frameworks/Mono.framework/Versions/5.4.1/lib/mono/4.5/mscorlib.dll.dylib empty dSYM file detected, dSYM was created with an executable with no debug info.
warning: (x86_64) 
.
.
.
.
.
=================================================================
Got a SIGSEGV while executing native code. This usually indicates
a fatal error in the mono runtime or one of the native libraries 
used by your application.
=================================================================

Process 1326 detached
(lldb) quit
[1]    1326 abort      mono Fiddler.exe

解決方案:切换32bit-mono启动fiddler

mono --arch=32 Fiddler.exe

启动之后

mac抓包:Fiddler and charles

用fiddler对android的抓包具体配置可以看下这个博客

https://www.cnblogs.com/abao0/p/7008995.html

fiddler启动后电脑无法正常上网看下这个博客

https://blog.csdn.net/zjq001X/article/details/80461760

我启动之后,想抓个包,这个fiddler好卡,各种不好,也没抓到包,于是我考虑想换成charles

2.charles

(1)安装charles

下载地址:http://www.charlesproxy.com/  

(2)charles与手机链接

  首先在Terminal输入命令 ifconfig | grep "inet " | grep -v 127.0.0.1获取 ip

mac抓包:Fiddler and charles

  接着,手机打开WLAN ,长按你链接的网络——>修改密码 -——>显示高级选项

代理修改为手动,服务器主机名修改为你获取的ip ,服务器端口改为8888,charles默认是8888

mac抓包:Fiddler and charles

配置完成,charles会提示以下,点击allow

mac抓包:Fiddler and charles

然后就可以抓包了。

(3)安装证书

抓包之后,你发现是乱码如下:

mac抓包:Fiddler and charles

大概搜了下说需要安装SSL证书

 

v3.10以前的Charles版本需要自己下载CA证书,下载地址:

https://www.charlesproxy.com/documentation/additional/legacy-ssl-proxying/

如果版本高于等于v3.10

点击help--->SSL Proxying--->Inatall Charles Root  Ceritificate

mac抓包:Fiddler and charles

可以看到这个证书不首信任mac抓包:Fiddler and charles

双击选中证书弹出证书设置框

mac抓包:Fiddler and charles

选择始终信任。保存退出。

还是乱码。。。

接下来选择Proxy--->SSL Proxying Settings

mac抓包:Fiddler and charles

点击Add

mac抓包:Fiddler and charles

输入内容

mac抓包:Fiddler and charles

保存之后退出就可以了,如下

mac抓包:Fiddler and charles