

Though you can also set your DNS servers manually. This name server is usually given to your computer when it connects to a network through DHCP. The Client (your computer) only talks with its configured Recursive Name Server (NS). Recursive NS->Google NS: A for ?Įverything going on might not yet be clear, but there are two things to notice first. DNS based C2 is different as the communication utilizes the DNS infrastructure to communicate instead.Ī normal DNS request for goes like this: This makes it easier to detect and track down. Many command & control (C2) channels communicate directly with an attacker-controlled system.
#Filter dns query wireshark code
That filter will work with Wireshark, TShark, or tcpdump (as they use the same libpcap code for packet capture).Leverage frequency analysis to identify systems using DNS for C2. If you're only trying to capture DNS packet, you should use a capture filter such as "port 53" or "port domain", so that non-DNS traffic will be discarded. "A?" means that a query is being done for an A record "CNAME" means that a CNAME record is being returned (i.e., "is an alias for "pub.us.", and "A" means that an A record is being returned, giving an IPv4 address. The key point here is that this is NOT DNS traffic! It's probably "HTTP-over-SSL", or "https", traffic. See the tcpdump man page, and a description of TCP, for details on the rest of the line. "10.0.2 > ": the packet is from IP address 10.0.0.2, port 57512, to the IP address whose for which the host name is "", and the port for "https", which is port 443.


The interpretation of the data in your example is being done by tcpdump, not Wireshark. If you "used wireshark to collect data from some sites, and then used tcpdump to get it as a text file", the output from Wireshark is either a pcap file or a pcap-ng file, which is a binary file, and is completely uninterpreted raw data. The output you're showing is text output, so, if you "used tcpdump to get it as a text file", it's output from tcpdump, not from Wireshark text output from Wireshark would look different. If you're only using Wireshark to capture traffic, that's probably overkill - you can do the same thing with dumpcap or possibly even tcpdump. :-) I.e., they use tcpdump to capture traffic into a file and then read the file with Wireshark. Most people who use both tools use them for the opposite purposes. I used wireshark to collect data from some sites, and then used tcpdump to get it as a text file.
