一直以來都是在Windows底下工做,對於抓包工具,天然而然當屬Fiddler最最出色。不過Fiddler是在.Net runtime環境下運行的,因此想要在Mac下使用,有些困難。bash
在試過了Charles、Rythem、TinyProxy和NProxy這些抓包工具後,我依然苦惱,它們有的須要支付昂貴的費用,有的只支持本機網頁請求代理,而有些界面只有文本模式,這讓我沒法適從。app
直到去年10月份(2016年10月),Telerik官網上悄然地放上了Fiddler的OSX版,這讓我欣喜若狂,趕忙來嘗試。工具
環境安裝ui
Mono安裝spa
首先,Mac下須要使用.Net編譯後的程序,須要用到跨平臺的方案Mono(現階段微軟已推出跨平臺的方案.Net Core,不過暫時只支持控制檯程序)。安裝程序能夠從http://www.mono-project.com/download/#download-mac地址下載。debug
安裝完後,在Terminal裏執行如下命令:3d
1
|
/Library/Frameworks/Mono.framework/Versions/<mono version>/bin/mozroots --import --sync
|
此步是爲了從Mozilla LXR上下載全部受信任的root證書,存於Mono的證書庫裏。root證書能用於請求https地址。代理
接下來若是想要運行Fiddler,還須要把Mono加入到環境變量中。編輯.bash_profile文件:rest
1
|
sudo vi ~/.bash_profile
|
加入文本:code
1
2
|
export MONO_HOME=/Library/Frameworks/Mono.framework/Versions/5.0.1
export PATH=$PATH:$MONO_HOME/bin
|
保存後從新打開Terminal,Mono環境已裝好。
Fiddler的安裝
從Fiddler官網https://www.telerik.com/download/fiddler下載fiddler-mac.zip的壓縮包。解壓到非中文字符的路徑下。
Fiddler運行
打開Terminal,進入到剛纔解壓的Fiddler路徑,執行命令運行:
1
|
sudo mono Fiddler.exe
|
是否是跟Windows下的界面同樣好看?
若是啓動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
sudo mono --arch=32 Fiddler.exe