簡體   English   中英

嘗試從python終端的scapy模塊使用“ traceroute”功能時出錯。 作業系統:ubuntu 18.04

[英]Error when trying to use “traceroute” function from the scapy module in python terminal. OS: ubuntu 18.04

我在python終端上輸入了這個:

from scapy.all import *
traceroute("gmail.com")

得到這個錯誤:

File "<stdin>", line 1, in <module>
  File "/usr/local/lib/python3.6/dist-packages/scapy/layers/inet.py", 
line 1428, in traceroute
    timeout=timeout, filter=filter, verbose=verbose, **kargs)
  File "/usr/local/lib/python3.6/dist-packages/scapy/sendrecv.py", 
line 326, in sr
    s = conf.L3socket(filter=filter, iface=iface, nofilter=nofilter)
  File "/usr/local/lib/python3.6/dist-packages/scapy/arch/linux.py", 
line 326, in __init__
    self.ins = socket.socket(socket.AF_PACKET, socket.SOCK_RAW, 
socket.htons(type))
  File "/usr/lib/python3.6/socket.py", line 144, in __init__
_socket.socket.__init__(self, family, type, proto, fileno)
    PermissionError: [Errno 1] Operation not permitted

我已經嘗試過在網上搜索解決方案,但沒有成功。 我很高興在遇到這個問題時得到幫助; 提前致謝。

traceroute需要訪問原始套接字,因此,由於Linux限制了原始套接字,因此您需要以root身份啟動python

啟動外殼程序時鍵入sudo python ,或者鍵入sudo python sudo scapy (具有scapy預先配置的外殼程序),或者如果它是程序文件,則鍵入sudo python yourprogram.py

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM