好的,我有客户端和服务器代码 .
服务器代码如下所示:
import socket
import sys
HOST = ''
PORT = 5555
s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
print 'Socket created'
#Bind socket to local host and port
try:
s.bind((HOST, PORT))
except socket.error as msg:
print 'Bind failed. Error Code : ' + str(msg[0]) + ' Message ' + msg[1]
sys.exit()
print 'Socket bind complete'
#Start listening on socket
s.listen(10)
print 'Socket now listening'
#now keep talking with the client
while 1:
conn, addr = s.accept()
print 'Connected with ' + addr[0] + ':' + str(addr[1])
data = conn.recv(10000)
print data
s.close()
现在我想要做的是对该套接字上的这些传入数据包进行一些分析(端口5555) . 基本上我想要提取头标志 . 我试图使用scapy函数sniff()在这里找到Fetch source address and port number of packet - Scapy script
only i wanna be able to just sniff packets coming in on that port .. not any other traffic.
我该怎么做呢?
1 回答
以下内容将捕获所有可用接口上目标端口号等于5555的所有数据包 .
您当然可以通过指定iface参数来指定要嗅探的界面 .