Hacking: the art of exploitation, 2nd edition by Jon Erickson
Author:Jon Erickson [Jon Erickson]
Language: eng
Format: epub
Tags: Sciences
ISBN: 9781593273385
Published: 2010-08-12T10:00:00+00:00
From /usr/include/if_ether.h
#define ETH_ALEN 6 /* Octets in one ethernet addr */ #define ETH_HLEN 14 /* Total octets in header */ /* * This is an Ethernet frame header. */ struct ethhdr { unsigned char h_dest[ETH_ALEN]; /* Destination eth addr */ unsigned char h_source[ETH_ALEN]; /* Source ether addr */ __be16 h_proto; /* Packet type ID field */ } __attribute__((packed));
This structure contains the three elements of an Ethernet header. The variable declaration of __be16 turns out to be a type definition for a 16-bit unsigned short integer. This can be determined by recursively grepping for the type definition in the include files.
reader@hacking:~/booksrc $ $ grep -R "typedef.*__be16" /usr/include /usr/include/linux/types.h:typedef __u16 __bitwise __be16; $ grep -R "typedef.*__u16" /usr/include | grep short /usr/include/linux/i2o-dev.h:typedef unsigned short __u16; /usr/include/linux/cramfs_fs.h:typedef unsigned short __u16; /usr/include/asm/types.h:typedef unsigned short __u16; $
The include file also defines the Ethernet header length in ETH_HLEN as 14 bytes. This adds up, since the source and destination MAC addresses use 6 bytes each, and the packet type field is a 16-bit short integer that takes up 2 bytes. However, many compilers will pad structures along 4-byte boundaries for alignment, which means that sizeof(struct ethhdr) would return an incorrect size. To avoid this, ETH_HLEN or a fixed value of 14 bytes should be used for the Ethernet header length.
By including <linux/if_ether.h>, these other include files containing the required __be16 type definition are also included. Since we want to make our own structures for hacking-network.h, we should strip out references to unknown type definitions. While we're at it, let's give these fields better names.
Download
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.
Blogging & Blogs | eBay |
E-Commerce | Hacking |
Online Searching | Podcasts & Webcasts |
Search Engine Optimization | Social Media |
Social Media for Business | Web Browsers |
Web Marketing |
Sass and Compass in Action by Wynn Netherland Nathan Weizenbaum Chris Eppstein Brandon Mathis(7781)
Grails in Action by Glen Smith Peter Ledbrook(7696)
Secrets of the JavaScript Ninja by John Resig Bear Bibeault(6419)
Kotlin in Action by Dmitry Jemerov(5066)
WordPress Plugin Development Cookbook by Yannick Lefebvre(3802)
Mastering Azure Security by Mustafa Toroman and Tom Janetscheck(3330)
Learning React: Functional Web Development with React and Redux by Banks Alex & Porcello Eve(3087)
Mastering Bitcoin: Programming the Open Blockchain by Andreas M. Antonopoulos(2868)
The Art Of Deception by Kevin Mitnick(2606)
Drugs Unlimited by Mike Power(2467)
Kali Linux - An Ethical Hacker's Cookbook: End-to-end penetration testing solutions by Sharma Himanshu(2313)
The Innovators: How a Group of Hackers, Geniuses, and Geeks Created the Digital Revolution by Walter Isaacson(2304)
Writing for the Web: Creating Compelling Web Content Using Words, Pictures and Sound (Eva Spring's Library) by Lynda Felder(2262)
SEO 2018: Learn search engine optimization with smart internet marketing strategies by Adam Clarke(2194)
A Blueprint for Production-Ready Web Applications: Leverage industry best practices to create complete web apps with Python, TypeScript, and AWS by Dr. Philip Jones(2181)
JavaScript by Example by S Dani Akash(2138)
DarkMarket by Misha Glenny(2083)
Wireless Hacking 101 by Karina Astudillo(2077)
Full-Stack React Projects by Shama Hoque(1990)
