Rumah  >  Soal Jawab  >  teks badan

python - linuxmint18.1如何提升网卡权限?

操作环境:
操作系统:Linux Mint18.1 Cinnamon 64-bit
Python版本:2.7.12

问题描述:
在学习Python黑客编程3网络数据监听和过滤1.2节 使用pypcap实时抓包这里初始化pcap类实例遇到错误。

按照教程我先使用ifconfig获取了电脑上的网卡信息。

$ ifconfig
enp4s0f2  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)

lo        Link 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 linux2
Type "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操作系统,很多地方还不熟,正在学习中。)

迷茫迷茫2741 hari yang lalu589

membalas semua(1)saya akan balas

  • PHPz

    PHPz2017-04-18 10:28:34

    Anda menjalankan program anda dengan keistimewaan root.

    Untuk mempelajari alat penggodaman ini, bukankah semua orang menggunakan sistem pengendalian seperti kali atau burung nuri? Lalai pada sistem ini ialah pengguna root, kerana terdapat banyak operasi yang memerlukan keistimewaan root.

    balas
    0
  • Batalbalas