Separate the packet header from the payload in snort - packet-capture

How can we separate and read the packet header from the payload by snort tool ?
I need only the header information not all the packet, How can I do this?

Only show the IP and TCP, UDP or ICMP headers
./snort -v
The packet headers as well as the payload
./snort -vd

Related

get client IP for an MQTT request over haproxy

I've configured X_FORWARDED_FOR to capture client IP for a HTTPS request and it works as expected.
However, for MQTT, the data is sent over SSL and HTTP/S does not come into the picture.
ssl://<HOST_NAME>:<PORT>
I've tried adding the following to the backend server on HAproxy config. No luck so far.
backend TestServer
mode tcp
server TestServer01 10.6.186.24:48080 send-proxy-v2
------
server TestServer01 10.6.186.24:48080 send-proxy
------
server TestServer01 10.6.186.24:48080 send-proxy-v2-ssl
Is there a way to capture client (source) IP for an incoming MQTT request by changing HAProxy configuration?
No, there is no where in the MQTT protocol to store the original client IP address (like adding extra headers to HTTP requests).
The proxy is literally just forwarding packets that arrive on it's public port to the backend servers (with the possible exception of doing SSL termination) it doesn't change the packets at all.
If you wanted the IP address to do stick-table based abuse protection, you will need to key your stick-table with the MQTT client identifier.
For example this will reject clients if their connection rate is greater than 1 per second, over a 10s window.
tcp-request content set-var(txn.client_id) req.payload(0,0),mqtt_field_value(connect,client_identifier) if data_in_buffer
stick-table type string len 64 size 100k expire 5m store gpc0,gpc0_rate(10s)
tcp-request content track-sc0 var(txn.client_id)
tcp-request content sc-inc-gpc0(0)
tcp-request content reject if { sc0_gpc0_rate gt 10 }

ESP protocol packet doesn't show payload information while transferring data after IPsec tunnel creation using strongswan

We have created Ipsec tunnel using strong-swan as follows,
server (eth interface- 13.13.7.13) --> clinet (eth interface - 13.13.7.18)
when ikev2 phase1 and phae2 messages exchanges happens, source IP and destination IP are same as IP address assigned to eth interfaces. (confirmed via wire-shark). And ISAKMP message exchange has been done successfully.
1) When I started transmitting data via SCP protocol between client & sever , I have noticed ESP and SSH packets.
In which ESP packets just have sequence number but not encrypted payload and SSH packets have encrypted payload. But as per Ipsec protocol data should be encrypted in ESP protocol itself. why there is no payload info in ESP packets ?
FI : I noticed continuous ESP packets after ISAKMP exchange (negotiation and authentication done)
SSH and ESP Packets look like below:
**SSH Protocol**
SSH Version 2 (encryption:chacha20-poly1305#openssh.com mac:<implicit> compression:none)
Packet Length (encrypted): e78d1cd9
Encrypted Packet: 9679398c167c33ca6c1eecc4879e59d417b39545c80b0e40...
MAC: 27b594b6290dcdf3a09fd2fb84884cd7
**ESP Protocol**
Encapsulating Security Payload
ESP SPI: 0xc86cb75d (3362568029)
ESP Sequence: 19
ESP payload ideally not visible in wireshark directly, you need to enable ESP preferences in wireshark tool by providing tunnel SPI, end point IPs, enc/auth keys etc., as mentioned in wiki.

why each icmp request translates to four packets in a vxlan tunnel when capturing packets on 'any' interface in wireshark?

I have two VMs connected using a VXLAN tunnel and open virtual switch. Everything works as it should be, however, I do not understand why there are on wireshark four icmp request packets for each request I send.
The configurations I have on the two virtual machines is as shown below:
Guest1 configuration:
enp0s3 (ethernet): 192.168.56.101/24
int-br (VXLAN): 192.168.55.101/24
Guest2 interface:
enp0s3 (ethernet): 192.168.56.102/24
int-br (VXLAN): 192.168.55.102/24
When I ping guest2 (192.168.55.102) from guest1, this is what I see on wireshark (packets are captured on 'any' interface):
The screenshot shows the packets captured in wireshark on the interface 'any' correspondent for two icmp request I have sent and their replies (sequence 1, and 2).
The first request with seq=1 says "no response found!" and it is not encapsulated with VXLAN header.
The second request with seq=1 says "reply in 7" and it is not encapsulated with VXLAN header.
The third request with seq=1 says "no response found!" however it is encapsulated with VXLAN header.
The fourth request with seq=1 says "reply in 5" and it is also encapsulated with VXLAN header.
Explanation why there are four request sent for each request I send are much appreciated.
Since you told Wireshark to listen on any interface, it listens on all interfaces. Therefore, you're seeing the packets when they go through 1. the encapsulated vNIC for guest1, 2. the interface for guest1, 3. the interface for guest2, 4. the encapsulated vNIC for guest2.
Try capturing packets on a single interface instead of any and you should see each packet only once.

tunneling using SSH

I'm tunneling all of my internet traffic through a remote computer hosting Debian using sshd. But my internet connection becomes so slow (something around 5 to 10 kbps!). Can be anything wrong with the default configuration to cause this problem?
Thanks in advance,
Tunneling TCP within another TCP stream can sometimes work -- but when things go wrong, they go wrong very quickly.
Consider what happens when the "real world" loses one of your TCP packets: after a certain amount of not getting an ACK packet back in response to new data packets, the sending side realizes a packet has gone missing and re-sends the data.
If that packet happens to be a TCP packet whose payload is another TCP packet, then you have two TCP stacks that are upset about their missing packet. The tunneled TCP layer will re-send packets and the outer TCP layer will also resend packets. This causes a giant pileup of duplicate packets that will eventually be delivered and must be dropped on the floor -- because the outer TCP reliably delivered the packet, eventually.
I believe you would be much better served by a more dedicated tunneling method such as GRE tunnels or IPSec.
Yes, tunelling traffic over tcp connection is not a good idea. See http://sites.inka.de/bigred/devel/tcp-tcp.html

Is it possible to send udp packet via a v6 socket to a v4 dst?

when I use linux's "sendto(....)" to send some udp packet, I got "invalid argument" error from system.
After some check, I found that I try to send a udp packet via a v6 socekt to a ipv4 destination
, I'm not sure whether it is the reason why "invalid argument" comes from system, so want to raise my question here.
Yes, a PF_INET6 socket can send to IPv4 destination addresses with sendto() - as long as you haven't bound it to an IPv6 local address, anyway.