23.11.2014 Views

CRIPTOGRAFIA - FESP

CRIPTOGRAFIA - FESP

CRIPTOGRAFIA - FESP

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

find where the flags are located in the TCP header. Well, they are found<br />

at byte 14 (we need to bypass 13 bytes). Therefore, we can do the<br />

following if we want to identify all packets containing the RESET flag<br />

(which must necessarily also contains the ACK flag):<br />

# tcpdump -x "tcp[13]=20"<br />

Why? Well first, its actually only the last 6 bits of byte 14 that supply<br />

flag information:<br />

|U|A|P|R|S|F|<br />

|R|C|S|S|Y|I|<br />

|G|K|H|T|N|N|<br />

Therefore ACK and RST gives us a byte of 00010100. I think the first<br />

two bits are always zero (?). Converting binary to decimal (we do not<br />

use hex [which would of been 14 or 0x14]) gives us "20".<br />

Sometimes it may be useful to identify (datagram) fragments. In this<br />

case we filter on fields in the IP header where information regarding<br />

fragmentation is stored. Without elaborating on fragmentation theory,<br />

suffice it to say that if there is no "fragment offset" listed in the IP<br />

header then that packet is either not a fragment or it is the datagram's<br />

very first fragment.<br />

The offset is given by bytes 7 and 8 with the exception of the first 3 bits:<br />

reserved (always zero?), "do not fragment" (DF), and "more fragments<br />

to follow" (MF). Any one datagram will therefore have these two bytes<br />

looking like this:<br />

type bytes 7 and 8<br />

non-fragment 0?00000000000000<br />

first fragment 0010000000000000<br />

intervening<br />

fragment<br />

001xxxxxxxxxxxx<br />

last fragment 000xxxxxxxxxxxx<br />

Where ? may be "1" or "0" and the string of x's contains at least one "1".<br />

So if we can do a bitwise AND operation on those two bytes with the<br />

following binary number then we know our datagram is of the first two<br />

types providing the result is zero:<br />

0001111111111111<br />

So this will sniff non-fragments or "frag zeroes" (initial fragments):

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!