python - linuxmint18.1如何提升網卡權限?
問題描述
操作環境:操作系統:Linux Mint18.1 Cinnamon 64-bitPython版本:2.7.12
問題描述:在學習Python黑客編程3網絡數據監聽和過濾1.2節 使用pypcap實時抓包這里初始化pcap類實例遇到錯誤。
按照教程我先使用ifconfig獲取了電腦上的網卡信息。
$ ifconfigenp4s0f2 Link encap:Ethernet HWaddr 04:7d:7b:7f:dd:af inet addr:222.20.104.41 Bcast:222.20.105.255 Mask:255.255.254.0 inet6 addr: 2001:250:4000:8040:4cd2:279a:51cf:5f45/64 Scope:Global inet6 addr: fe80::c2c4:cdf9:a5ac:80df/64 Scope:Link inet6 addr: 2001:250:4000:8040:341c:9a13:8403:e3e2/64 Scope:Global UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1 RX packets:17464 errors:0 dropped:0 overruns:0 frame:0 TX packets:10430 errors:0 dropped:0 overruns:0 carrier:0 collisions:0 txqueuelen:1000 RX bytes:8705585 (8.7 MB) TX bytes:1422248 (1.4 MB)loLink encap:Local Loopback inet addr:127.0.0.1 Mask:255.0.0.0 inet6 addr: ::1/128 Scope:Host UP LOOPBACK RUNNING MTU:65536 Metric:1 RX packets:1949 errors:0 dropped:0 overruns:0 frame:0 TX packets:1949 errors:0 dropped:0 overruns:0 carrier:0 collisions:0 txqueuelen:1 RX bytes:283488 (283.4 KB) TX bytes:283488 (283.4 KB)wlp9s0 Link encap:Ethernet HWaddr 9c:b7:0d:a5:f0:77 UP BROADCAST MULTICAST MTU:1500 Metric:1 RX packets:0 errors:0 dropped:0 overruns:0 frame:0 TX packets:0 errors:0 dropped:0 overruns:0 carrier:0 collisions:0 txqueuelen:1000 RX bytes:0 (0.0 B) TX bytes:0 (0.0 B)
底下我模仿教程進行初始化pcap類實例的代碼,然后就遇到了錯誤。錯誤提示是沒有權限抓取該網卡信息。
Python 2.7.12 (default, Nov 19 2016, 06:48:10) [GCC 5.4.0 20160609] on linux2Type 'help', 'copyright', 'credits' or 'license' for more information.>>> import pcap>>> pc1 = pcap.pcap(’enp4s0f2’)Traceback (most recent call last): File '<stdin>', line 1, in <module> File 'pcap.pyx', line 203, in pcap.pcap.__init__ (pcap.c:1668)OSError: enp4s0f2: You don’t have permission to capture on that device (socket: Operation not permitted)>>> pc2 = pcap.pcap(’lo’)Traceback (most recent call last): File '<stdin>', line 1, in <module> File 'pcap.pyx', line 203, in pcap.pcap.__init__ (pcap.c:1668)OSError: lo: You don’t have permission to capture on that device (socket: Operation not permitted)>>> pc3 = pcap.pcap(’wlp9s0’)Traceback (most recent call last): File '<stdin>', line 1, in <module> File 'pcap.pyx', line 203, in pcap.pcap.__init__ (pcap.c:1668)OSError: wlp9s0: You don’t have permission to capture on that device (socket: Operation not permitted)
于是上網百度怎樣提升網卡權限,但是并沒有找到一個合適的方法。這是找到的一條命令$ sudo chmod 777 /dev/bpf* 不過他的操作系統是MAC OS X,很自然的沒有解決問題。還有也試了$ ifconfig lo up 啟動網卡,感覺應該沒用,不過抱著死馬當活馬醫的態度也試了,結果果然沒有用。哪位高手能幫忙解決一下問題呢?不勝感激。(P.S. 這兩天剛用上linuxmint操作系統,很多地方還不熟,正在學習中。)
問題解答
回答1:你使用 root 權限跑你的程序。
像學習這些 hack 工具,大家不都使用 kali 或者 parrot 這些操作系統嗎?在這些系統上默認都是 root 用戶,因為有很多需要 root 權限的操作。
相關文章:
