Wireshark and Tcpdump tips
- Looking for traffic to certain hosts
- tcpdump -nnv -r filename ‘src host 192.168.1 or dst host 192.168.1′ (shows all traffic to/from 192.168.1.*)
- ip.host contains “192.168.1″ (shows all traffic to hosts 192.168.1.*)
- Looking for ARP traffic (including mac addresses)
- tcpdump -nvv -r filename arp -e (shows all arp traffic with mac addresses)
- tcpdump -e -t -nn -r filename arp | sort -u (shows unique arp traffic)
- arp.opcode == 0×0002 (prints all arp requests and replies)
- Looking for Gateways
- tcpdump -nnvve -r filename ‘ip and not dst net 192.168.0.0/16 and not dst host 255.255.255.255′ | awk ‘{print $4}’ | sort -u (look for gateway mac addresses)
- not ip.addr == 192.168.0.0/16 && not ip.dst_host == “255.255.255.255″ (look for gateway mac addresses – tcpdump filter better)
- Looking for Routers
- tcpdump -nnvve -r filename ‘not host 192.168.200.254 and icmp[0] = 3 and (icmp[1] = 0 or icmp[1] = 1)’ (look for any routers and find out how many hops away – IP ttl)
- More Information:
- icmp[0] = 3 refers to byte 0 in the icmp header which is the icmp type field, and 3 refers to the “destintion unreachable” icmp type.
- icmp[1] = 0 or icmp[1] = 1 refers to byte 1 in the icmp header which is the code field, 0 or 1 refers to net “unreachable” or “host unreachable” messages relating to the “destination unreachable” icmp type
- not ip.addr eq 192.168.200.254 && icmp.type == 3 && (icmp.code == 0 or icmp.code == 1) (look for any routers and find out how many hops away – IP ttl)
- Looking for DNS servers
- tcpdump -nn -r filename ‘udp and dst port 53′ | awk ‘{print$5}’ | sort -u (find DNS servers)
- udp.dstport == 53 && not icmp (look for DNS servers)
- Looking for NTP servers
- tcpdump -nn -r filename ‘dst port 123′ | awk ‘{print$5}’ | sort -u (find ntp servers)
- Statistic -> destinations -> ntp (look for all ntp hosts)
- tcp.dstport == 123 or udp.dstport == 123 and not icmp (look for all ntp hosts)
- Syslog Servers
- tcpdump -n -r filename ‘udp and dst port 514′ | awk ‘{print$5}’ | sort -u (shows all syslog servers)
- tcpdump -nn -r filename ‘icmp and icmp[17] = 17 and icmp[30:2] = 514′ (look for errors in syslog server – wireshark easier)
- udp.dstport == 524 && not icmp (shows all syslog servers)
- udp.dstport == 514 && icmp (look for syslog server errors)
- Looking for fragmented traffic
- tcpdump -nn -r filename ‘ip[6] & 0×20 != 0 or ip[6:2] & 0x1fff != 0′ (looking for MF flag or fragments)
- ip.flags.mf == 1 or ip.frag_offset >= 0×001
- More Information:
- ip[6] & 0×20 != 0 refers to the 6th byte in the ip header with a mask of 0×20 (which is 0010 0000 or the MF – More Fragments flag). The != 0 means that this flag must be set.
- ip[6:2] & 0x1fff != 0 refers to the 6th byte for 2 bytes ([6:2]) with the mask of 0x1fff (0001 1111 1111 1111 – Fragment offset data) not being empty (!= 0)
- Looking for ports either being probed or open
- tcpdump -n -r filename ‘dst host 192.168.1.3 and tcp[13] & 0×02 != 0′ | awk ‘{print$5}’ | cut -d “.” -f5 | sort -u -n (list all ports probed on an ip)
- tcpdump -n -r filename ‘src host 192.168.1.3 and tcp[13] & 0×12 != 0′ | awk ‘{print$3}’ | cut -d “.” -f5 | sort -u -n (list all ports responding on an ip)
- tcpdump -n -r filename ‘udp and dst host 192.168.1.3 and not port 123 and not port 53′ | awk ‘{print$5}’ | cut -d “.” -f5 | sort -n -u (list all udp ports open – excludes dns and ntp)
- then -> tcpdump -nn -r filename ‘(udp and port xyz) or (icmp[0] = 3 and icmp[1] = 3 and icmp[30:2] = xyz’ (look for port unreachable – xyz is the port)
- Statistics – Conversations – TCP (uncheck Name Resolution) and sort by port B (list all ports probed on an IP)
- ip.src_host == 192.168.1.3 and tcp.flags == 0×12 (list all ports resounding on an ip)
- More Information:
- tcp[13] & 0×02 (or 0×12) refers to byte offset 13 (which is all the tcp flags) with the appropriate bit mask – surely by now you’ve figured that out right? If not, look up a bit and you’ll see how it all works
- Look for traffic initiated by machine
- tcpdump -n -r filename ‘src host 192.168.1.3 and tcp[13] = 0×02″ (look for all traffic initiated by ip – syn traffic)
- ip.src_host == 192.168.1.3 && tcp.flags == 0×02 (look for all traffic initiated by host – syns)
- Looking for Backscatter or ips being spoofed
- tcpdump -n -r filename ‘not src host 192.168.1.3 and tcp[13] = 0×12′ (backscatter traffic – syn/acks not initiated from network)
- tcp.flags == 0×12 && not ip.src_host == “192.168.1.3″ (backscatter traffic – syn/acks not initiated from network)
- 原文:http://security.crudtastic.com/?p=480