Category : "Coding"

All kinds of Programming.

Get local ip in C on linux

Local Ip address The local ip is the source ip in IP packets send out from a system. When the system is a part of a local area network then the local ip in most cases is something like 192.168.*.* . The network interface (eth0) is assigned an ip address of that range. However when the machine is connected to internet ...

Code a packet sniffer in C with winpcap

Winpcap Winpcap is a packet capture library for Windows used for packet sniffing and sending raw packets. Wireshark is a popular sniffer tool that uses winpcap to sniff packets. Here is a sample code which shows how winpcap can be used to sniff incoming packets on a particular interface. Code /* Simple Sniffer with winpcap , prints ethernet , ip , tcp , udp and ...

Get mac address from ip in winsock

Mac address or hardware address is a 48bit (6 character) wide address assigned to a network interface. It is important for the packet delivery between 2 devices like your computer and the router. Ethernet protocol uses the mac address to deliver it to the right network node. It looks like this 00-1E-58-B8-D4-69 ( the dash is not relevant). Mac address ...

Winpcap compile error in pcap-stdinc.h in vc++ 6.0

When compiling winpcap in your program on Visual C++ 6.0 you might get an error like this : Compiling... main.cpp c:\codes\include\pcap-stdinc.h(79) : error C2144: syntax error : missing ';' before type 'unsigned int' c:\codes\include\pcap-stdinc.h(79) : fatal error C1004: unexpected end of file found Error executing cl.exe. And it will point to the following lines in pcap-stdinc.h typedef _W64 unsigned int uintptr_t; typedef _W64 int ...

Get ip address from hostname in C using Linux sockets

Socket applications often need to convert hostnames like google.com to their corresponding ip address. This is done through dns requests. The socket api in linux provides functions like gethostbyname and getaddrinfo that can be used to perform the dns requests and get the ip address. gethostbyname The first method uses the traditional gethostbyname function to retrieve information about a hostname/domain name. Code #include<stdio.h> //printf #include<string.h> ...

Validate file upload with html5 file api

The html5 file api provides lots of new features which can be used to read files on clientside from within the browser. Lets take a look at this Demo first : This file upload control will only take zip or png files which are less than 1MB in size. For any other files it will show an error message. And this functionality if ...

Convert simplexml object to array in php

The simplexml extension of php is quite simple and easy to use when it comes to parsing "well-formatted" xml files. Well formatted means , xml that is not broken or does not have too many errors. One of the most handy functions of this extension is simplexml_load_string. Here is an example : <?php $xml = '<?xml version="1.0" encoding="UTF-8"?> <resultset> <row> ...

Packet Sniffer Code in C using Linux Sockets (BSD) – Part 2

In the previous part we made a simple sniffer which created a raw socket and started receiving on it. But it had few drawbacks : 1. Could sniff only incoming data. 2. Could sniff only TCP or UDP or ICMP or any one protocol packets at a time. 3. Provided IP frames , so ethernet headers were not available. In this article we are ...

Code a network packet sniffer in python for Linux

Basic Sniffer Sniffers are programs that can capture/sniff/detect network traffic packet by packet and analyse them for various reasons. Commonly used in the field of network security. Wireshark is a very common packet sniffer/protocol analyzer. Packet sniffers can be written in python too. In this article we are going to write a few very simple sniffers in python for the linux ...

Php : create pdf from html using mpdf

MPDF Many php applications need to create pdf of documents like invoice , receipt and even id card etc. In this article we shall create a pdf invoice using the mpdf pdf creation library. Mpdf is made in php without any other external library. Mpdf parses css much better than any other free pdf libraries like tcpdf and creates pdf files ...



Connect with us