|
20鱼币
python好久不用了,最近在学习一些python相关的工具开发,语言版本python2.7的
代码如下所示:
import os
import socket
def Sniffer():
if os.name == "nt":
host_protocol = socket.IPPROTO_IP
else:
host_protocol = socket.IPPROTO_ICMP
Sniffer = socket.socket(socket.AF_INET, socket.SOCK_RAW, host_protocol)
Sniffer.bind((host, 0))
Sniffer.setsockopt(socket.IPPROTO_IP, socket.IP_HDRINCL, 1)
if os.name == "nt":
Sniffer.ioctl(socket.SIO_RCVALL, socket.RCVALL_ON)
print Sniffer.recvfrom(65535)
if os.name == "nt":
Sniffer.ioctl(socket.SIO_RCVALL, socket.RCVALL_OFF)
if __name__ == '__main__':
Sniffer()
问题如下:
Python 2.7 (r27:82525, Jul 4 2010, 07:43:08) [MSC v.1500 64 bit (AMD64)] on win32
Type "copyright", "credits" or "license()" for more information.
>>> ================================ RESTART ================================
>>>
Traceback (most recent call last):
File "C:\Users\Administrator\Desktop\text.py", line 26, in <module>
Sniffer()
File "C:\Users\Administrator\Desktop\text.py", line 10, in Sniffer
Sniffer = socket.socket(socket.AF_INET, socket.SOCK_RAW, host_protocol)
File "C:\Python27\lib\socket.py", line 187, in __init__
_sock = _realsocket(family, type, proto)
error: [Errno 10013]
因为上传图片光崩溃,所以粘贴过来了
_sock = _realsocket(family, type, proto)?
最后一个是原?,是我参数导致的?
我也是新手这书我也有但有些在Linux做比较好,WINDOWS容易出错
|
最佳答案
查看完整内容
我也是新手这书我也有但有些在Linux做比较好,WINDOWS容易出错
|