Category Archives: Linux
Create and read custom section in Linux ELF header

Let’s create test C file:

Create custom section data:

Compile test binary:

Create read_section.c with content:

Compile read_section:


Let’s test it with objdump:

Replace the system call in Linux using the kernel module.

This example is not necessary to check anywhere else, it is not safe for the operating system and user data!

In this example we will replace the system call “write”. This kernel module replaces the data that is displayed to stdout on the word “moo” for a specific user.



Let us compile module and check how it works.

How to restore MAC address in Linux with C.

In this example you can learn how to get default interface’s mac address even if it was changed in operating system. Example written in C 89.
Program uses ethtool’s kernel ioctl. “ethtool -P interface_name” does the same work.

Get network interfaces list in Linux with libnl3

This example shows how to get network interfaces list with IP and MAC addresses.

Output example:

Source code:


Posted on May 18, 2016, 5:29 pm By
No comments yet Categories: C, Linux
Check that network interface is in Promiscuous mode

ifconfig or ip link does not show actual interface promisc status, but we can use this:

if 0 -> not
if 1 -> interface is in promisc mode

Apply user patches in portage ( Gentoo Linux )

In this example we will modify rxvt tabs like this:
First, download the patch from here
Then, create directory /etc/portage/patches/x11-terms/rxvt-unicode/ and put patch file there.
Create file /etc/portage/bashrc with code:

Finally emerge rxvt: emerge rxvt-unicode