Category Archives: C Programming

Identify security properties on Linux using checksec

Compiling source code produces a binary. During compilation, you can provide flags to the compiler to enable or disable certain properties on the binary. Some of these properties are relevant to security. Checksec is a nifty little tool (and shell script) that, among other functions, identifies the security properties that were built into a binary … Continue reading Identify security properties on Linux using checksec

Checking whether the underlying architecture is little-endian or big-endian using C

Big-endian and little-endian are two formats to store multibyte data types into a computer’s memory. These two formats are also called network byte order and host byte order respectively. In a multibyte data type such as int or long or any other multibyte data type the right most byte is called the least significant byte and the left most byte is called the most significant byte. … Continue reading Checking whether the underlying architecture is little-endian or big-endian using C

How to switch from root user to non-root user during execution using C on Linux

Setuid Program Example Here’s an example showing how to set up a program that changes its effective user ID. This is part of a game program called caber-toss that manipulates file scores that should be writable only by the game program itself. The program assumes that its executable file will be installed with the setuid bit set and … Continue reading How to switch from root user to non-root user during execution using C on Linux

C Socket Programming – Send the file using TCP Sockets

Sockets provide the communication mechanism between two computers using TCP. A client program creates a socket on its end of the communication and attempts to connect that socket to a server. When the connection is made, the server creates a socket object at the end of the communication. The client and the server can now … Continue reading C Socket Programming – Send the file using TCP Sockets

Sliding Block Puzzle Solver(2×3, 3×2, 3×3) – C++ Programming

A program written in c language to solve a 2×3, 3×2, 3×3 sliding block puzzle. 1. DFS (Brute-Force)We can perform depth-first search on state space (Set of all configurations of a given problem i.e. all states that can be reached from initial state) tree. Image source: https://courses.cs.washington.edu In this solution, successive moves can take us away … Continue reading Sliding Block Puzzle Solver(2×3, 3×2, 3×3) – C++ Programming