All posts by Alok Yadav

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

Create and Manage Cron Jobs on Linux

Cron is one of Linux’s most useful tools and a developer favorite because it allows you to run automated commands at specific periods, dates, and intervals using both general-purpose and task-specific scripts. Given that description, you can imagine how system admins use it to automate backup tasks, directory cleaning, notifications, etc. Cron jobs run in … Continue reading Create and Manage Cron Jobs on Linux

How to Block IP Address with .htaccess

Quick post today showing some different ways to block visitors via their IP address. This can be useful for a variety of reasons, including stopping some stupid script kiddie from harassing your site or preventing some creepy stalker loser from lurking around your forums or even silencing the endless supply of angry trolls that never seem to … Continue reading How to Block IP Address with .htaccess

Managing PING through iptables

PING – ping is a computer network administration software utility used to test the reachability of a host on an Internet Protocol network. It is available for virtually all operating systems that have networking capability, including most embedded network administration software. Blocking PING on the server is helpful sometimes, if the server continues to face any type of DDoS … Continue reading Managing PING through iptables

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

Convert diff output to colorized HTML

If you search the web you can find a number of references to programs/scripts that convert diff output to HTML. This is a bash version. The script expects “unified” diff output (diff -u) on its standard input and produces a self-contained colorized HTML page on its standard output. Consider the two files: #include <stdio.h> // main main() { printf(“Hello … Continue reading Convert diff output to colorized HTML

How to Convert Date and Time from One Time Zone to Another

Using PHP It’s really simple to convert a DateTime from one time zone to another in PHP. Just create a DateTime object using date & time to be converted as the first parameter and the original time zone as the second parameter. Then change the time zone to the desired one using the setTimezone method. That’s all! $date = new DateTime(‘2022-02-01 … Continue reading How to Convert Date and Time from One Time Zone to Another

Java 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 Java Socket Programming – Send the file using TCP Sockets

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

Handling complex number using C++ class

#ifndef COMPLEX_H #define COMPLEX_H #include <iostream> #include <fstream> #include <string> #include <complex> class Complex { private: double real; double imag; public: Complex(); Complex(const Complex& obj); Complex(const std::string& str); Complex(double real); Complex(double real, double imag); double real_num() const; double imag_num() const; std::string toString() const; Complex operator+(const Complex& rhs) const; Complex operator-(const Complex& rhs) const; Complex operator*(const … Continue reading Handling complex number using C++ class

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