Socket sniffer python only sniff port 22
I am programming a sniffer in python with sockets and I am not sure why I am only sniffing on port 22. I am in a machine connected via ssh from ip 10.0.0.2 to 10.0.0.3 and when I sniff I only sniff ssh traffic I'm trying to do this to sniff traffic without port 22:
import socket
from struct import *
print 'Bienvenido'
s = socket.socket(socket.AF_INET,socket.SOCK_RAW,socket.IPPROTO_TCP)
while True:
packet = s.recvfrom(65000)
packet = packet[0]
ip_header = packet[0:20]
iph = unpack('!BBHHHBBH4s4s' , ip_header)
ip_src = socket.inet_ntoa(iph[8])
ip_dst = socket.inet_ntoa(iph[9])
tcp_header = packet[20:40]
tcp_h = unpack('!HHLLBBHHH',tcp_header)
src_port = tcp_h[0]
dst_port = tcp_h[1]
if str(dst_port)!="22":
print 'ip_src : ' + ip_src
print 'ip dst : ' + ip_dst
print 'src port: ' + str(src_port)
print 'dst port: ' + str(dst_port)
But I dont sniff anything, if I go to if str(dst_port)!="22":
, I sniff traffic from 10.0.0.2 to 10.0.0.3. On the remote machine, I started tcpdump sniffing on port 80 connected to google via telnet on port 80, I also tried FTP traffic but no luck and I sniff in tcpdump but not on my sniffer. Anyone what could happen? Thank you in advance
+3
source to share
No one has answered this question yet
See similar questions:
or similar: