Convert string to hex.

If you want to use snoop or tcpdump with advanced search in the packet, then you would need to convert the string to hex string. For this, either you can use a web search and find some web application to do that or you can use a simple C program like this 🙂

* =====================================================================================
*       Filename:  ascii.c
*    Description:  ascii to dec
*        Version:  1.0
*        Ceated:  03/02/2012 12:08:49 PM
*       Revision:  none
*       Compiler:  gcc
*         Author:  Amit Agarwal (aka), [email protected]
*  Last modified: Thu Mar 08, 2012  08:47PM
* =====================================================================================
void main (int argc, char **argv){
    int i=0;
    char a[200]="",b[200]="";
    printf("String - %s, Length - %d\n",argv[1],strlen(argv[1]));
    /*printf("%x\n 0x",argv[1]);*/
    while (i < strlen(argv[1])){
    printf ("\n");
    printf ("String : %s\n",argv[1]);
    printf ("Hex    : 0x%s\n", a);
    printf ("Dec    : %s\n", b);

Enhanced by Zemanta

Inotify Example: Introduction to Inotify with a C Program Example

Inotify Example: Introduction to Inotify with a C Program Example:

inotify utility is an effective tool to monitor and notify filesystem changes. You can specify a list of files and directories that needs to be monitored by inotify. This library is used by various other programs. For example, CPAN module Linux::Inotify is developed based on this library.
iNotify Execution Flow

On a high-level, you do the following with inotify utility.


Last access time for file

The C program will print the last access time for the file.

This is quite helpfull program when you want to find old files. Modifying the source to take the filename as argument and take multiple arguments is left as an exercise.

#include <stdio.h>
#include <sys/stat.h>
#include <sys/types.h>
#include <fcntl.h>
#include <time.h>
#include <stdlib.h>
int main(void)
    char datestring[80];
    struct  stat a;
    //int fd = open(\"ak\",O_RDONLY);
    if (stat (\"iptc.c\", &a) == -1) {
        printf (\" Error\");
    printf (\" Last Access Time is %s\", ctime(&a.st_atime));
    printf (\" Last Access Time is %s\", a.st_atime);