Wireshark: How to filter for a specific SYN packet? - networking

I'm pretty new to Wireshark and stuck with a filter task.
I have network traffic and error messages from a certain system. I need to trace the SYN packet of one of my error messages.
For Wireshark, that means I need to filter for one specific IP-port combination x.x.x.x:xxxx among the SYN packets.
With tcp.flags.syn == 1 as a display filter I have been able to narrow down Wireshark's output to only SYN packets, but it's still far too many to find the one packet belonging to the port where we see the error and that we would like to follow.
Can you help me with that?

Looking only at SYN packets is not very helpful if you need to find a conversation that has problems - it's usually better to gather as much information about the IPs involved in the problem and filter on them. E.g. if you know that the computer with the IP 192.168.1.1 has a problem, and your capture has tons of conversations, you can filter on that IP by using the following filter:
ip.addr==192.168.1.1
If you also know the layer 4 protocol and port (e.g. TCP on port 1025) you can filter on both IP and port, like this:
ip.addr==192.168.1.1 and tcp.port==1025.
If you have a plain text protocol and know the text of the error message (if it is actually visible in a packet, and not just some coded thing), you could use the "find" option and search for the string (don't forget to set the search type to "string", because the default is "display filter").

Related

Wireshark : how to force to drop packets with LUA?

I'm am facing to an issue when sniffing on the loopback interface when using a JTAG debug probe, which uses a TCP socket. It completly flood the loopback, and freeze Wireshark after a few seconds.
As a workaround, I have made a dummy LUA dissector for this case (redlink-server protocol). Wireshark is no longer freezing, but it produces like 8Gb of packets in a few minutes...
(the plugin consists in an empty dissector function, add register this dissector for TCP port 3490)
Is there a simple way to delete those packets from dump file not to overflow my RAM ?
Tanks by advance
Thomas.
You can apply a capture filter, not a display filter, to avoid capturing the traffic. In your case, the capture filter to exclude the unwanted traffic would be not tcp port 3490.
Refer to pcap-filter for more information on capture filters, as well as the Wireshark User Guide, Section 4.10. Filtering while capturing.

Strange Wireshark behaviour (A single packet labeled both TCP and UDP)

I have a big PCAP file downloaded from this website. (You can download the original pcap file : 368 MBs)
You can also download a short version that contains only some of the buggy packets.
There is something strange with some packets inside this file. There are 1113 packets labeled with sFlow inside it that it doesn't matters which wireshark-filter you apply to the packets, you always will see them (or part of them) in the window:
To be more clear let see some screen shots:
No filter applied:
Filter to see tcp packets only:
Filter to see udp packets only:
Filter to see packets with ip.addr == 68.64.21.64
What's wrong with these packets?
These packets are of sFlow type. They are used for network sampling, so they contain samples of other network packets within. Display filter seems to be applied not only to sFlow packet itself, but to every inner packet as well. So "tcp" display filter leaves those sFlow packets (they are obviously udp), which contain tcp sample within. Same for address filtering.
You can inspect inner packets as shown on the picture
Not sure if filter behavior is correct, I was amused by output as well. I think, it'd be great to open ticket at Wireshark bug database to hear developers' opinion.

Why do I need source port on UDP

When I use TCP I need destination port (to be able to "talk" to other process on the other host) and source port (because TCP is connection oriented so I'll send data back to source like ack, seq and more).
On the other side, UDP which is connectionless needs also source port.
Why is it? (I don't need to send back data)
Probably, two reasons.
First, receivers often need to reply and it is useful to provision a standard tool for that.
Secondly, you may have multiple interfaces (network cards) and using source address, you decide which of them must be used to emit the packet.
You don't need to but there's still the possibility to send a response back (that is very useful actually) however as stated in the RCF 768
Source Port is an optional field, when meaningful, it indicates the port
of the sending process, and may be assumed to be the port to which a
reply should be addressed in the absence of any other information. If
not used, a value of zero is inserted.
https://www.rfc-editor.org/rfc/rfc768
I would like to add to the answers here. Apart from simply knowing what to reply to, the source port can belong to the list of well-known port numbers. These ports specify what kind of data is encapsulated in the UDP (or TCP!) packet.
For example, the source port 530 indicates that the packet contains a Remote Procedure Call, and 520 indicates a Routing Information Protocol packet.

Wireshark HTTP Trace

How do I trace the path of HTTP packets using Wireshark. When I filter out using keyword "HTTP", all I see is just the source and destination IP addresses, rather for every HTTP request I would want to see what path did it take with their IP addresses. I would like to see an output similar to traceroute.
It is impossible for a sniffer program to determine the full path that an IP packet took merely by looking at the packet, unless one of the IP "record route" options was used, so that the packet, as received by the program, contains the full route. That option is rarely, if ever, set.
In addition, that wouldn't help for packets sent by the machine running the sniffer program - you have to capture packets on the final machine in order for the recorded route to have the full path.
So, no, Wireshark can't do this, tcpdump can't do this, Microsoft Network Monitor can't do this, KSniffer can't do this, NetScout Sniffer can't do this, OmniPeek can't do this, no sniffer can do this.

TCP Null Scan using Scapy

Can someone guide me on how to send packets in Scapy to an ip address, with all flags in the TCP header set to null ? I have so far tried sending packets without specifying which flags to set, but it seems to set the Syn flag everytime I send the packet.
I would like to know it so that I can learn more about TCP Null Scans. Would be grateful for ur help and guidance.
I haven't used Scapy, but from a quick scan of the documentation there is an example of creating a TCP packet while specifying which flags to set, on this page of the docs:
http://www.secdev.org/projects/scapy/doc/usage.html#simple-one-liners
sr( IP(dst="192.168.1.*")/TCP(dport=80,flags="S") )
Perhaps you could try a command like that, with an empty string ""? i.e. TCP(dport=80,flags="") ?
If you don't want to actually send a TCP header, you'd be better off just setting the protocol of the IP packet and gluing a string of zeros on top of it.
sr( IP(dst="192.168.1.", proto="TCP")/"\0"*50)
Edit: I'm not actually positive on the syntax, you might have to use the protocol number instead of "TCP"
Thank you Andy and Jdizzle for the suggestions.
I tried out what Andy Recommended earlier itself, but the packet somehow seemed to have the Syn Flag set, when i checked it on wireshark.
The good news is, i solved the problem, the flags can be set to null, at the instance when you create the packet to be sent.
create a packet --> a=TCP() and then setting the flag to zero by --> a.flags=0
there are many other attributes that you can preset in this manner before preparing the packet to be sent over the network. You can view these attributes by --> ls(a)
where a=the name of the packet.
This worked successfully !

Resources