Example of using readv(2) and writev(2) in C.

In this example, we will create a file and fill it with data using writev. Next we read the file using readv.

Create file:

Read data from file:

Posted on December 2, 2016, 7:54 am By
No comments yet Categories: C
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.

cowsay.c:

Makefile:

Let us compile module and check how it works.

An example of using OpenSSL GOST engine in C,C++

In this example we will extract the public key data from X509 GOST R 34.10-2001 certificate.

compile and execute:

vsftpd move files after upload to specified directory

how-to:

After successful file upload it will be moved to the “Incoming” directory.
Directory must be exists and have proper permissions.
Also “Incoming” directory must be in the same filesystem as uploaded file.

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:

compile:

Posted on May 18, 2016, 5:29 pm By
No comments yet Categories: C, Linux
Hello world in nasm (assembler x86_64)

code:

run:

Get a pointer to the structure through a pointer to a member.

Posted on February 9, 2016, 3:19 pm By
No comments yet Categories: C
Define your own custom conversion specifiers for printf.

In this example we define two specifiers: %P, %W.
%P -> prints IPv4 address from struct in_addr.
%W -> prints IPv6 address from struct in6_addr.

Example code: ( The GNU C Library only. )

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

Next Page