-EthernetII header-





[ Preamble ]

Preamble (7) + SFD (1)

Total : 8 Bytes

Offset : #0~#7


[ MAC Header ]

Destination MAC Address (6) + Source MAC Address (6) + Ether Type (2)

Total : 14 Bytes

Offset : 0~13


[ Data ]

PDU Payloads (46 ~ 1500)

Total : 46 ~ 1500 Bytes

Offset : 14 ~ 59 (Min)


[ CRC Checksum ]

CRC Checksum (4)

Total : 4 Bytes

Offset : 60 ~ 63




Preamble,  SFD : 동기 신호로서, 본격적인 프레임 시작 전에 미리 알리는 역할, 이 부분을 기점으로 NIC는 데이터를 Byte단위로 해석하기 시작, EthernetII Header에서 제외하는 경우도 많음


MAC Header : 송, 수신 MAC주소를 각각 6 Bytes (48 bits)로 지정, Ether Type 같은 경우에는 상위 프로토콜이 Patload에 포함되어 있을 경우, 해당 프로토콜의 종류를 서술함.


Data : 상위 프로토콜이나 Raw Data등이 포함되며, 데이터 그 자체임


CRC Checksum : CRC 알고리즘으로 생성된 값을 포함하여 무결성 검사를 수행, 송, 수신 중의 오류 여부를 확인하게 됨




[ 대표적인 Ether Type ]

0x0800 : Internet Protocol Version 4 (IPv4)

0x0806 : Address Resolution Protocol (ARP)

0x0842 : Wake-on-Lan (WOL)

0x8137 : Internet Packet Exchange (IPX)

0x86DD : Internet Protocol Version 6 (IPv6)

0x8808 : Ethernet flow control


Posted by RevDev
,

-Linux Binary Hardening with Glibc-



Linux Binary Hardening with Glibc.pdf

Posted by RevDev
,

-Linux character driver example on 3.19.0-43-generic -


1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
#ifndef __KERNEL__
#define __KERNEL__
#endif
#ifndef MODULE
#define MODULE
#endif
 
#include <linux/slab.h>
#include <linux/device.h>
#include <linux/proc_fs.h>
#include <asm/uaccess.h>
 
static DEFINE_MUTEX(mutexIoctl);
//Mutex for unlocked_ioctl
 
static unsigned char* chpBuf = NULL;
//Device buffer pointer
 
static int memOpen(struct inode *inp, struct file *fp);
static int memRel(struct inode *inp, struct file *fp);
static ssize_t memRead(struct file *fp, unsigned char *chpOut, size_t sztCount, loff_t *loftPos);
static ssize_t memWrite(struct file *fp, const unsigned char __user *chpIn, size_t sztCount, loff_t *loftPos);
static long memIoctl(struct file *fp, unsigned int iNum, unsigned long iParam);
//Device callback functions
 
static struct file_operations fileOpers;
static bool bFlag = false;
//Custom device mutex
 
static int __init kernmodule_init(void)
{
    void *vpErr;
    //Error pointer
    
    fileOpers.read = memRead;
    fileOpers.write = memWrite;
    fileOpers.open = memOpen;
    fileOpers.release = memRel;
    fileOpers.unlocked_ioctl = memIoctl;
    //Allocate callback functions
 
    if(register_chrdev(200"kernmodule", &fileOpers) < 0)
        return -EIO;
    //Register character device (major = 200, device name = kernmodule)
 
    chpBuf = kmalloc(32, GFP_USER);
    if(IS_ERR(vpErr = chpBuf))
        return -ENOMEM;
    memset(chpBuf, 032);
    //Allocate memory area for device buffer
 
}
 
static void __exit kernmodule_exit(void)
{
       unregister_chrdev(200"kernmodule");
       //Unregister character device
 
       if(chpBuf)
        kfree(chpBuf);
}
 
static int memOpen(struct inode *inp, struct file *fp){
    //Device file open
    if(bFlag)
        return -EBUSY;
    bFlag = true;
    return 0;
}
 
static int memRel(struct inode *inp, struct file *fp){
    //Device file release
    bFlag = false;
    return 0;
}
 
static ssize_t memRead(struct file *fp, unsigned char __user *chpOut, size_t sztCount, loff_t *loftPos){
    //read() from device file
    if(sztCount > 32)
        return -1;
    if(bFlag)
        copy_to_user(chpOut, chpBuf, sztCount);
    return sztCount;
}
 
static ssize_t memWrite(struct file *fp, const unsigned char __user *chpIn, size_t sztCount, loff_t *loftPos){
    //write() to device file
    if(sztCount > 32)
        return -1;
    if(bFlag)
        copy_from_user(chpBuf, chpIn, sztCount);
    return sztCount;
 
static long memIoctl(struct file *fp, unsigned int uiNum, unsigned long ulParam)
{
    int iIter = 0;
    mutex_lock(&mutexIoctl);
    //ioctl Routine(User-level application can access with ioctl() function)
    mutex_unlock(&mutexIoctl);
    return 0;
}
//unlocked_ioctl : normal ioctl was deprecated
 
module_init(kernmodule_init);
module_exit(kernmodule_exit);
 
 
cs
Posted by RevDev
,