Browsed by
Author: Navin Mohan

5 Simple Steps to Implement System Call in Debian

5 Simple Steps to Implement System Call in Debian

Ever thought of doing a function that a computer performs, on your own? Fascinated by what happens within the kernel? Well, let’s get started by learning how to implement system call in Debian.

Open source distributions allows us to manipulate the original source code and customize it to our need. It’s a great platform to experiment with the conventional methods and processes done by the operating system. Debian Linux distribution has been used here.

What is a system call?

Before we start implementing system calls, let’s just understand what it actually is. A system call is a way of requesting the OS kernel to do something on your behalf.  Rather than jumping to some code, your program has to ask the CPU to switch into the kernel mode and then go to a predefined location within the kernel to handle your system call. Since all you need is a table entry and a few codes here and there, it’s quite easy to implement your system call. Worth a shot, right?

A note for the readers:

Since this tutorial involves getting a copy of Linux source code, manipulating and finally booting it; if you’re not confident enough to directly try it out in your system, it’s best to try this on a Virtual Machine (VM). To setup a VM in your Linux pc : Read

How to implement system call in Debian:

Step 1: Get the kernel source using APT

The following command will download the kernel source code with Debian patches:

$ sudo apt-get install linux-source-3.16

Next we’ve to create a new directory to extract the kernel source into

$ mkdir ~/kernel-src

and change into that directory

$ cd ~/kernel-src

Extract the kernel source into the current directory

$ tar -xaf /usr/src/linux-source-3.16.tar.xz

Step 2:Add the new system call source code

Change into the linux source directory

$ cd ~/kernel-src/linux-source-3.16

Make a new directory for the system call source files and change into it. Let’s call it helloworld

$ mkdir helloworld &&amp
cd helloworld

We need to put a Makefile inside this directory so that the make build automation will be able to compile our source code. Make is a build automation tool that automatically builds executable programs from source code by reading Makefiles which specify how to derive the target program.

$ touch Makefile

Now let’s add the source code and name it hello.c

The next step is to modify the Makefile. This will ensure that our source file hello.c will be compiled and included in the kernel.

Then, add the helloworld directory to the kernel’s Makefile. So change back to the linux-source directory and edit the Makefile.

$ cd ~/kernel-src/linux-source-3.16/

Find the line (#842) in the Makefile which says

and change it to

After that we’ve to register the system call in the linux system calls table. So change into the syscalls directory.

$ cd ~/kernel-src/linux-source-3.16/arch/x86/syscalls/

For 64 bit systems

Edit syscall_64.tbl and append the following line at the end

Note: The syscall number might be different in your case. Just add one to the syscall number in the previous entry (319 + 1 = 320). Also keep note of the syscall number for later use.

For 32 bit systems

Edit syscall_32.tbl and use i386 instead of 64 as ABI, the rest is same for both.

Finally we’ve to include our system call in the syscalls header file, for this:

Change into include directory and find syscalls.h

$ cd ~/kernel/linux-source-3.16/include/linux/

Edit syscalls.h and append the following line at the end of the file before #endif

asmlinkage long sys_hello(void);

Install Build Tools

$ sudo apt-get install fakeroot build-essential

Step 3:Configuring the Kernel

Since we’re compiling the same version of the kernel with our system call, the configuration will most likely be the same. So we can use the same configuration proposed by Debian without too many modifications.

Copy the current configuration file.

$ cp /boot/config-3.16.0-4-amd64 ~/kernel-src/linux-source-3.16/.config

Note: The config filename might be different depending on the kernel version

Update the configuration by running

$ make oldconfig

If you hadn’t used an old configuration then run the following command to configure everything manually

$ make menuconfig

Step 4:Compiling the Kernel

Once the configuration process is done we’re ready to compile the kernel. The following command will start the compilation process

$ make -j5

where N in -jN is the number of build jobs to be run in parallel (which is usually the no. of cores+1).

The process usually takes 2-3 hours to complete.

Packaging the Kernel

In Debian it is possible to install the kernel, just like any other software, from a deb package. Using a deb package is easier and safe. So we’ll package the compiled kernel.

The following command will generate the required Debian packages

$ make deb-pkg

Step 5:Installing the new Kernel

Now change to the parent directory

$ cd ~/kernel-src/

Install the generated Deb packages

$ sudo dpkg -i *.deb

After installation reboot the system. Choose the new kernel while booting.

Testing the System Call

Compile and run the following C program.

Copy the contents of the file :

If you’ve done everything correctly “Hello World!” will be printed in the kernel log, which can be accessed using the following command,

$ dmesg

The final Output after implementing system call will look like this:



Congratulations! You’ve implemented and tested your own system call!

Have fun with kernel development 🙂

Make Your Own Website Today – Get Started in Minutes

Make Your Own Website Today – Get Started in Minutes

Looking to build a new website for your business or a personal blog? You’ve struck gold. Let’s get started.

Reasons Why You Need a Website

If you’ve a business then it’s time for you to expand your empire. Over 2.4 billion people use the internet and something as simple as a website could help your business tap into that huge potential. With a wider market your products sell better. You’re no longer limited to your open hours, get more sales throughout the day. Put your ingenuity in the driving seat and do business the way you like it.

Ever wanted to start a business? Well, now is the time and you can get it running pretty quick in the virtual space with minimum investment.

A place to showcase all your awesome projects would be nice. A blog, if you want to share your thoughts, ideas and stories with the world. And it’ll be the icing on the cake if your website brings in some passive income at the end of the day.

Ready for it?

Get your Domain Registered

First of all , you need a domain name , preferably a dot-com one( others will also work but it’s the most popular). Choose one that is short and easy to remember (..and easy to spell :p). This will be your “brand” online , you know some brand names speak for themselves , so keep that in mind while making a choice.

Once you’re pretty sure about the domain name, see if it’s available and get it registered. There are like a thousand domain registrars online, we recommend Name Cheap , or if you’ve a favourite go with it.

Find the right Web Host

The next step is to find a web-host , a place to store and serve your actual webpage and data. Like with the domain registrars it’s hard to make a decision because of the endless options available. The reason why this is very important is that your choice directly reflects the overall performance of your website (we all hate those slow websites!).

We’ll be using a DigitalOcean Droplet here. In case you’re wondering, DigitalOcean calls its Virtual Private Servers Droplets. They made it real simple to spin up a VPS, takes less than a minute.

So sign up for an account on DigitalOcean ( use the above link to get a credit of $10 ). They’ll ask for your credit/debit card info, but you won’t be charged anything now. It’s just for the verification purpose.  Once that’s complete you’re ready to deploy your first droplet.

Note: One thing that you’ll often come across while finding a webhost is to choose between a Shared Host or a VPS Host(Virtual Private Server). Don’t worry about those technical terms now it’s really simple. In a shared hosting plan your website will be hosted along with other websites on the same server and all the resources are shared among them. Whereas in a VPS hosting plan your website will be hosted on a virtual server with dedicated resources depending on your plan. The main difference here is that you don’t have to share your resources with any other websites on a VPS. Consequently your website will perform better and any load on other websites hosted on the same server won’t affect your site. Learn more.


Creating a Droplet

Once you’re through the sign-up process , click on the Create Droplet button.
create droplet

Choose One-Click Apps.

Now select WordPress on 16.04. You can also try Ghost (one of my personal favourites…) if all you need is a publishing platform.



Choose a plan according to your requirements. The $5 plan is enough for a wordpress site serving up to 40k visits/month. One of the best things about hosting your website in the cloud is that you can scale your server effortlessly as your website grows.


Select a region to deploy your Droplet. Choose the one closest to your targeted users for better performance.

Now for the additional options I’d recommend the Backup option. Although it’ll cost you 20% more on your monthly bill it’s worth the price. Things could go wrong and sometimes people do incredibly stupid things.

If you’ve an SSH key add that. How-to?

Windows users try this. You can skip this part if you want and instead use the password that’ll be emailed to you. For the most part you won’t have to use this, thanks to those one-click apps.

Finally give your droplet a name and hit Create.


Your Droplet will be up and running in a minute or so.


Point the Domain to our Droplet


Now go to the Networking tab on DigitalOcean and click on Domains.

Type in your domain name and select your Droplet’s IP from the dropdown menu. Hit Create Record.

Now click on Add Record and add another A record. Type in www in the first box and your Droplet’s IP in the second. Click Create.

Follow this tutorial, which includes instructions for most of the popular domain registrars , to add DigitalOcean’s nameservers. It might take some time for the DNS to propagate.


Setting Up WordPress

Go to your Droplet’s IP address. You’ll see this page.


Don’t worry It’s just a security measure and all you’ve to do is to log into your Droplet.

If you’re on Mac or Linux , open up a Terminal and type in

ssh [email protected]

Windows users have to use an application like Putty. It’ll ask for a password if an SSH key is not provided, you can find that in your inbox. Once logged in it’ll automatically enable the wordpress installation.

Now goto “your-droplets-ip/wp-admin” and go through the set up process.


The setup process will take you to the WordPress Dashboard. Now goto settings and change your site’s URL to your domain and save changes.

And with that your website must be live on that domain.


Top 5 Torrentz Alternatives

Top 5 Torrentz Alternatives

After the shutdown of the most popular torrent meta-search engine Torrentz , it’s millions of users were stranded with no other websites to come by. The website is still up and running but the search functionality is disabled and so no one can access its database. The exact reason for its shutdown is still unknown and it came as a surprise for torrent lovers all over the world. Torrentz served its users for over 13 years and now bids farewell.




Top 5 Torrentz Alternatives

For torrent lovers there is still hope. The following the top 5 Torrentz alternatives that’ll help you keep enjoying torrents.

  1. The Pirate Bay

    The Pirate Bay is one of the main piracy icons on the internet. The site was shutdown and wasn’t online at the beginning of 2015 but quickly regained its millions of users after its successful comeback operating through multiple mirror domains.

  2. ISO Hunt

    ISO hunt is another popular online torrent files index where the users can search, download and upload torrents.

  3. Extra Torrents

    ExtraTorrent is one of the fastest growing torrent community and it is home to the ETTV and ETRG release groups.

  4. RARBG

    RARBG is a newcomer which gained massive popularity in a short span of time. The site might be blocked by ISPs in some countries but it could be accessed easily over a proxy or VPN.

  5. 1337X

    1337X is a community driven torrent site that had a fall in its contributors over security concerns but with its popular status it takes #5 position on our list.

Also Read: Goes Down Mysteriously

Google Play Services Update Introduces new Text API and Android Mobile Vision

Google Play Services Update Introduces new Text API and Android Mobile Vision

Android Mobile Vision

Google brings back Android Mobile Vision API along with the all new Text API with the latest update for Google Play Services. Developers are excited to have Android Mobile Vision API support back , which was introduced almost an year ago but later removed for some reason. These APIs provide a whole new world of possibilities for Android developers making it easier than ever to implement technologies like face detection and text recognition right into their apps. The update also includes fix for the existing download issue.

Android Mobile Vision APIs

Face API

The Face API makes it easy to find and track human faces in images and video streams , which can even track positions of facial landmarks. The API can be leveraged to obtain information about the state of facial features like – Is the subject smiling? Are their eyes open?

Barcode API

The Barcode API helps to scan barcodes in real time in any orientation which is capable of detecting multiple barcodes at once.

The Text API allows text recognition in any Latin based language from any orientation. With its ability to preserve the structure of the recognised text , including photographs and lines, the API can easily automate the tedious process of data entry such as credit card information.

Awareness API

Awareness API utilises two other API’s called Fence and Snapshot to make the apps aware of the context. It allows the apps to get information on your daily activities like the time your leave for work and your sleep. The apps can also predict your activities at a specific time of the day and provide relevant information.

It may sound creepy as the developers now have access to your personal info at a greater reach but on the bright side we’ve these truly personal applications serving us better every time. If you’re still concerned about your privacy, you can always turn off the app’s access to Awareness API ,thanks to the granular permissions feature available on Android Marshmallow and above.

Also Read: N for Nougat!


Arduino – Automatic Plant Watering System

Arduino – Automatic Plant Watering System

Here we are with another Arduino project for the weekend!
Does watering your garden seems like a lot of work?  Spend this weekend building your own automatic plant watering system to take care of it. It’s really simple to make.

You can find the project files here

Things You’ll Need

  1. Arduino Uno
  2. Soil moisture sensor
  3. Potentiometer (10kΩ)
  4. 5v Relay module
  5. A water pump or Solenoid valve

Basic Setup

Arduino Code


In short what this circuit does is maintaining a minimum  moisture level in the soil. The constant level can be set using a potentiometer. The Arduino will monitor the present moisture and compares it with the constant level set. Whenever the moisture level falls below the threshold level the relay will be turned ON till the required moisture level is attained.
Pretty simple right? And as always you can tweak the code , make it better and share it without any restrictions.
Enjoy 🙂


Hardening SSH on Remote Ubuntu/Debian Server

Hardening SSH on Remote Ubuntu/Debian Server

Looking for an easy method to secure your remote openSSH server? Here’s a bash script to just do that. Sit back and run it, answer a few questions and you’re done!

Requires root access (user should be in sudoer’s list) and works on Ubuntu or Debian server. If it works for you on any other distro do let us know down in the comments.

Feel free to correct me, if I’m wrong, and contribute to the code to make it better and useful.

Github Repo:


How to Setup new SSH user on Ubuntu Server

How to Setup new SSH user on Ubuntu Server


If you have ever worked with a Linux server before, then you probably know the pain of setting up a new SSH user(for those who doesn’t know what is ssh – it serves as an application to login to remote computers as users).  It is not the most difficult thing in the world but doing it over and over again is not worth your time – and it’s boring!

So let’s do some bash magic ( or scripting) and make our life a bit easier.


What can it do?

Before diving into the setup, take a look at the useful features it can do for you :

  • It will add a new user to the remote system.
  • It will install sudo if it does not already exist.
  • It will add the newly created user to the sudoers list.
  • It sets up passwordless login for the new user.
  • Optionally disables the root login from ssh configuration after setting up the new user (recommended).

Note: You need root access to the server for the script to work

 Steps to setup new SSH User:

Follow the instructions given below step by step to ensure that you won’t skip any:

1. Download the script from Github. You can find it in handy-scripts repository along with some other useful scripts or you can just grab the gist.

$ git clone

2. Execute the script

$ bash handy-scripts/Debian-Server-Setup/

3. Then it will ask for your server’s IP or domain name, new username and password and the root password. Provide these  credentials and sit back while it does the hard work for you.

4. Finally it will ask you whether you want to disable the root login. It is highly recommended as it is a good practice for  securing your server.

That’s it! Now you can login to the remote system as the new user without being asked for the password.

Also read:SSH key configuration

Spread the word and help others if you found this post useful! 🙂

PS: Want to secure the new SSH user you’ve created? Then, Read:  Securing your SSH server.

If you have any suggestions or questions, leave them down in the comment section.


C++ Implementation of Running Key Cipher

C++ Implementation of Running Key Cipher

running key map

Hey there code-breakers, this time I’m having fun with  some cryptographic algorithms – Look Out. I just started cryptography and here’s my first successful cipher implementation. I’m using C++ and here’s the code

Find more about and other cryptographic algorithms here

Make Your Own Video Surveillance System At Home

Make Your Own Video Surveillance System At Home

Another DIY this Christmas season. Everyone these days wish to have their own video surveillance system at home either to watch out for burglars or just to keep an eye on your child, the uses are endless. But mostly the equipment are expensive and requires professional help. But this time we’ll create one out of some old PC hardware lying around. Performance entirely depends on the hardware you use and your network capability.

Things You Will Need

  1. An old webcam or digital cam
  2. A Linux PC(you can use any other OS but I’m using Linux here)
  3. A Network
  4. Infrared Light source(an IR LED or IR LASER diode will do)

Hacking the Webcam or Digital Cam(for Night Vision)

NOTE: This part includes removing the outer case of the camera to access the sensor and this may damage your camera permanently.Do this at your own risk.Firstly open the plastic case of the webcam careful not to damage the interior circuitry. Now with the lens assembly exposed you are ready to go.

Actually we are looking for the Infrared filter which is placed in between the focusing lens and the CCD. It is a thin small square sheet of glass usually placed underneath the lens. Be careful while removing the lens because direct exposure of the CCD sensor to light may damage it. Now locate the filter and remove it , either scrape it off with a screwdriver or use acetone to remove the glue but make sure that the lens in not damaged.

Now with the filter removed reassemble the case back. Test it on a computer for proper working. To see the magic, turn off the lights and take your TV remote,press any key and point it to the camera. A bright source is visible on the computer, now it is IR radiation. We use it to illuminate the dark, although it is invisible to humans, works well. Your normal cam is also sensitive to this light but with that filter removed the sensitivity will be around  10x more.

Setting Up the Camera on Your Server

Here comes the core of the system, where the actual recording and transmission takes place. Remember the Linux PC I’ve mentioned earlier, it’s actually working as  a server. There are many tutorials available on web about setting up a Home server  and of course I’ll do one soon. Actually I have one at home set up, you can use any Debian based distro as I’m using Debian here.

An ordinary PC with a network interface is well enough and you can download (easy to install) to set it up. I assembled my own from some old hardware. And for long time recording you need a greater storage capacity and it depends on the quality of the recorded video.

After installing the OS and network setup the Linux Server is ready, the uses of a server are very wide as it can be used to even automate your home and I’ll make it brief in my server tutorial. Now launch the terminal and type in the following command:

~$ sudo apt-get install vlc 

Type in your password and let the installation complete and skip this if already installed.

Now connect your Camera. Check if it is detected by running the following command:

~$ ls /dev/video* 

You will get something like this if its successfully detected:

video device list
It shows your device name (video0) note this because it is used in the following steps. Your device name may vary.

Now open vlc.

vlc - screenshot
Go to stream under media.

vlc - screenshot
Go to Capture Device in Stream window

vlc - screenshot
put the video device name as what we found earlier i.e. video0 for me

vlc - screenshotClick stream
vlc - screenshot
Make sure that the source is your video device
vlc - screenshot
Click Next
vlc - screenshot
Change the destination from file to HTTP

vlc - screenshot
Click add. Change the port to any desired port for streaming(should be unused) and provide a path(with *.wmv) which can be used to identify the stream. Activate Transcoding and change profile to ASF. Hit Stream.
vlc - screenshot
Almost there You created your stream. It’ll look something like this
vlc - screenshot
Again hit stream and your camera will be online.

vlc - screenshot
Now its streaming and you can watch the stream from any device supporting network stream(vlc the best).
To test if it is working, open another vlc window press Ctrl + N to get the network stream window and enter your stream address like this:

Hit play and it’ll stream your webcam. On other devices replace the localhost with the local IP address of your server. To get the local IP of your server simply type in this command on terminal:

~$ /sbin/ifconfig -a 

To stream over the internet you need some additional set up and security so I’ll describe it in the home server tutorial coming soon.

Use the IR light source to illuminate the subject so that it can be seen in low light and place it along with the camera. You may use a battery eliminator for power.

Hope it helps.. 🙂

Unbricking TP-LINK MR3220 V2 using Arduino

Unbricking TP-LINK MR3220 V2 using Arduino

In this post I’m explaining how to unbrick tp-link wireless N router. This only works if the boot loader is not damaged. And this worked for me and hope it will for you. I’m not responsible for any damaged device and do it at your own risk.

If you have a TP-LINK MR3220 wireless router bricked while trying to flash some other third party firmware and you ended up in a boot loop(all the LEDs will turn ON and OFF every 2 seconds) on your router, then here is the solution for you.

Things You Will need

  1. Male Berg Connectors
  2. Soldering kit
  3. Arduino (or any other USB to TTL converter should work)
  4. Connecting wires
  5. A PC or Mac(I use Windows Here as the the drivers are available easily)
  6. Jumper Cables


First to get to the board you need to remove the router’s case. Start with the antenna and then remove those screws(two of them) under the case.

MR3220 - screws

Now when you are done with the screws, remove the nut and washer from the antenna connector.

MR3220 - antenna

After doing that carefully try to push the antenna connector inside(just move it so that it will not be damaged while opening the case)
Now comes the tricky part, to unlock the push-in locks on the case. Start with the ones on the two corners at the back. After unlocking them use a pin or something to unlock the locks on either sides and finally do the same for the ones at the front. It takes a little time to get it right. Now when the top cover is removed we are almost there with the access to the board.

MR3220 - main PCB

After opening up the case, now completely push the antenna connector and other ports at the back of the router inside and take the board out. Here comes the area which demands  some skill. To connect the RX and TX pins.To be able to use UART you need to connect the TP18 to TP38 and TP28 to TP48. Look for these printed on the down side of the board. Find them and solder two wires shorting them as mentioned. Google for more on soldering.When done test the continuity with a multi-meter.

MR3220 - TP18 and TP28

MR3220 - solder

Now after connecting those pins ,solder the male berg connectors in place (as shown) so that the UART connection can be made.

MR3220 - TTL out

When everything is set the router is ready to be unbricked.


To convert the Arduino to our required USB to TTL converter we need to disable the mcu chip and use the on board FTDI chip. For this using a jumper cable connect the RESET pin on the Analogue side to the ground pin(GND). This will shift the mcu to Tristate mode. Now use those pins marked Tx and Rx(pin 0 and 1) on the Arduino to connect the Tx and Rx pins on the router board(use jumper cables). Don’t forget about the ground and remain the VCC pin free. Before connecting to the router the drivers for the FTDI chip should be installed on your PC and a few tools are required.

MR3220 - arduino set up

MR3220 - Arduino TTL

MR3220 - Arduino reset

MR3220 - complete setup

Required Programs

Install FTDI drivers and connect the the Arduino with the RESET and GND shorted. Let windows detect and configure the device. Now go to device manager and look for the communication ports and find the FTDI usb to ttl virtual COM port and note its number(like COM3).Run the tftp server and choose a root directory for it and place your openwrt firmware there(rename it to firm.bin or something so that it is easy to use).
Now power up your router and connect it to your PC using ethernet cable(RJ-45). Configure your PC’s NIC to the IP address Then connect the Rx,Tx and GND of the router to the Arduino’s pins as mentioned before.
Run putty and choose the serial connection. Change the preferences to the following

Bits per second: 115200
Data bits: 8
Stop bits: 1 
Parity: None 
Flow control: None

Start a connection on your COM port(Arduino’s virtual COM port) using the COM port number. A console window will appear showing data coming from the router. You’ll see a line saying “Autobooting in 1s…”, when you see this quickly type in “tpl” to get access. If you see gibberish data on screen you might have connected the Rx or Tx pin the wrong way or gone wrong with the baud rate or something else is wrong. When you get access to the console you are almost there. Type in these commands when you have the console.
To program the new image:

Erase the memory

> erase 0x9f020000 +0x3c0000  

Download the new firmware

> tftpboot 0x81000000 firm.bin 

Copy memory bytes into flash

> cp.b 0x81000000 0x9f020000 0x3c0000 

Boot kernel image from memory location

> bootm 0x9f020000

If everything went fine the router will reboot and will be reverted back to the openwrt firmware. Use telnet or ssh to access the router and flash back the original firmware.

Flashing back the original firmware

  • use scp to transfer the original firmware to the /tmp directory on your router
  • run these command while in the /tmp directory(original.bin is the original firmware for tl mr3220)
  • dd if=orig.bin of=out.bin skip=257 bs=512
  • mtd -r write out.bin firmware
  • If successfully flashed back the firmware the router will reboot and everything will be as factory defaults. Use to access the router settings.