Browsing articles in "Sockets"
Apr
30
2009

TCP Connect Port Scanner Source Code in C with Winsock

Theory TCP connect() scanning is the most basic form of TCP scanning. The program performs a connect() command on those ports of the target machine which are to be checked. If the port is open then the connect() command will succeed and a connection will be established. If the port is closed the connect() function would simply timeout in the connection attempt. The simple steps would be : 1. Start a loop for the port [...]

Apr
28
2009

TCP Connect Port Scanner with Linux Sockets (BSD)

TCP Connect Port Scanner works by trying to establish a connection with every port that is being scanned. If a connectio is established then the port is open otherwise closed. The steps are simple : 1. Create a socket2. Run a Loop to connect with each port on the remote system ; if connection established then port open otherwise closed. Code :

Apr
28
2009

C Packet Sniffer Code with Libpcap and Linux Sockets (BSD)

Libpcap is a packet capture library which can be used to sniff packets or network traffic over a network interface. Pcap Documentation gives a description of the methods and data structures available in the libpcap library. To install libpcap on your linux distro you can either download the source from the website and compile it and install. Or if you are on a distro like ubuntu then it can be installed from synaptic package manager. [...]

Apr
26
2009

Packet Sniffer Code in C using Linux Sockets (BSD)

Basic Sniffer To code a sniffer in C (Linux) the steps would be : 1. Create a Raw Socket. 2. Put it in a recvfrom loop. A raw socket when put in recvfrom receives all incoming packets. The following code shows an example of such a sniffer. Note that it sniffs only incoming packets. For sniffing all traffic on a network a packet capture library like libpcap can be used. Code sniffer.c Compile and Run [...]

Mar
8
2009

Php set_time_limit wont take into account socket operations

The PHP function set_time_limit is used to set a time limit on the maximum execution time of a script. But if the script has socket operations using fsockopen , fread and fwrite or even CURL then the set_time_limit may not appear to have any effect on the scripts timelimit or timeout. Again if safe mode is on then also set_time_limit has no effect. (Safe Mode) Socket operations are stream operations which do not count in [...]

Jan
13
2008

Raw Sockets – Packets with Winpcap

A previous post mentions how to send raw packets using winsock api on windows xp. Winpcap is a packet driver useful for packet capturing and sending raw packets on the windows platform. Raw means we have to cook the whole packet ourselves. A TCP packet for example consists of: 1. Ethernet header 2. IP header 3. TCP header 4. The data supposed to be send PACKET = ETHERNET_HEADER + IP_HEADER + TCP_HEADER + DATA Each [...]

Jan
13
2008

Tcp syn portscan code in C with Linux sockets

Port Scanning searches for open ports on a remote system. The basic logic for a portscanner would be to connect to the port we want to check. If the socket gives a valid connection without any error then the port is open , closed otherwise (or inaccessible, or filtered). This basic technique is called TCP Connect Port Scanning in which we use something like a loop to connect to ports one by one and check [...]

Mar
19
2007

DNS Query Code in C with winsock

DNS Query Its no new fact that when we type a web address in our browser a dns request is immediately send by our browser to a DNS server to get the IP address of that web address.In winsock applications we achieve this by gethostbyname() and things are pretty simple.In this article we shall do this simple thing without the help of gethostbyname().We shall be sending DNS queries and receive the reply and extract the [...]

Mar
19
2007

Packet Sniffer Code in C using Winsock

Introduction Ever since windows 2000/XP when IP_HDRINCL became a valid option for setsockopt() , WSAIoctl() had another option called SIO_RCVALL which enabled a raw socket to sniff all incoming traffic over the selected interface to whose IP the socket was bound.Hence to make a sniffer in Winsock he simple steps are : 1. Create a raw socket. 2. Bind the socket to the local IP over which the traffic is to be sniffed. 3. WSAIoctl() [...]

Mar
18
2007

Raw Sockets Using Winsock

Introduction Raw sockets, or “Raw Packets”, give you the facility to access the entire contents of a packet or datagram, both for reading and writing purpose. In other words, you can fabricate a whole packet according to your likes and dislikes. For example, a TCP packet would contain an IP header, a TCP header, and then the actual data that needs to be transmitted. When working with normal sockets, whatever we send to a socket [...]

Pages:«123