Hacking: The Art of Exploitation, 2nd Edition by Jon Erickson

Hacking: The Art of Exploitation, 2nd Edition by Jon Erickson

Author:Jon Erickson
Language: eng
Format: mobi, epub, pdf
Tags: COMPUTERS / Security / General
Publisher: No Starch Press
Published: 2010-08-11T16:00:00+00:00


Finally, the packet capture loop uses pcap_next() to grab the next packet. This function is passed the pcap_handle and a pointer to a pcap_pkthdr structure so it can fill it with details of the capture. The function returns a pointer to the packet and then prints the packet, getting the length from the capture header. Then pcap_close() closes the capture interface.

When this program is compiled, the pcap libraries must be linked. This can be done using the -l flag with GCC, as shown in the output below. The pcap library has been installed on this system, so the library and include files are already in standard locations the compiler knows about.

reader@hacking:~/booksrc $ gcc -o pcap_sniff pcap_sniff.c

/tmp/ccYgieqx.o: In function `main':

pcap_sniff.c:(.text+0x1c8): undefined reference to `pcap_lookupdev'

pcap_sniff.c:(.text+0x233): undefined reference to `pcap_open_live'

pcap_sniff.c:(.text+0x282): undefined reference to `pcap_next'

pcap_sniff.c:(.text+0x2c2): undefined reference to `pcap_close'

collect2: ld returned 1 exit status

reader@hacking:~/booksrc $ gcc -o pcap_sniff pcap_sniff.c -l pcap

reader@hacking:~/booksrc $ ./pcap_sniff

Fatal Error in pcap_lookupdev: no suitable device found

reader@hacking:~/booksrc $ sudo ./pcap_sniff

Sniffing on device eth0

Got a 82 byte packet

00 01 6c eb 1d 50 00 01 29 15 65 b6 08 00 45 10 | ..l..P..).e...E.

00 44 1e 39 40 00 40 06 46 20 c0 a8 2a 01 c0 a8 | .D.9@[email protected] ..*...

2a f9 8b 12 1e d2 ac 14 cf c7 e5 10 6c c9 80 18 | *...........l...

05 b4 54 1a 00 00 01 01 08 0a 26 b6 a7 76 02 3c | ..T.......&..v.<

37 1e 74 68 69 73 20 69 73 20 61 20 74 65 73 74 | 7.this is a test

0d 0a | ..

Got a 66 byte packet

00 01 29 15 65 b6 00 01 6c eb 1d 50 08 00 45 00 | ..).e...l..P..E.

00 34 3d 2c 40 00 40 06 27 4d c0 a8 2a f9 c0 a8 | .4=,@.@.'M..*...

2a 01 1e d2 8b 12 e5 10 6c c9 ac 14 cf d7 80 10 | *.......l.......

05 a8 2b 3f 00 00 01 01 08 0a 02 47 27 6c 26 b6 | ..+?.......G'l&.

a7 76 | .v

Got a 84 byte packet

00 01 6c eb 1d 50 00 01 29 15 65 b6 08 00 45 10 | ..l..P..).e...E.

00 46 1e 3a 40 00 40 06 46 1d c0 a8 2a 01 c0 a8 | .F.:@[email protected]...*...

2a f9 8b 12 1e d2 ac 14 cf d7 e5 10 6c c9 80 18 | *...........l...

05 b4 11 b3 00 00 01 01 08 0a 26 b6 a9 c8 02 47 | ..........&....G

27 6c 41 41 41 41 41 41 41 41 41 41 41 41 41 41 | 'lAAAAAAAAAAAAAA

41 41 0d 0a | AA..

reader@hacking:~/booksrc $



Download



Copyright Disclaimer:
This site does not store any files on its server. We only index and link to content provided by other sites. Please contact the content providers to delete copyright contents if any and email us, we'll remove relevant links or contents immediately.