Socket programming tutorials in C, Python, Perl, Php, Java and Winsock
Code a chat application (server and client) using sockets in python
Chat application In our previous article on we learned about the basics of creating a socket server and client in python. In this post we are going to write a very simple chat application in python that is powered by sockets. The chat application we are going to make will be more like a chat room, rather than a peer to peer chat. So this means that multiple users can connect to the chat server [...]
Code a simple telnet client using sockets in python
The telnet client is a simple commandline utility that is used to connect to socket servers and exchange text messages. Here is an example of how to use telnet to connect to google.com and fetch the homepage. $ telnet google.com 80 The above command will connect to google.com on port 80. $ telnet google.com 80 Trying 74.125.236.69… Connected to google.com. Escape character is ‘^]’. Now that it is connected, the telnet command can take user [...]
ICMP ping flood code using sockets in C – Winsock
In a previous article on we saw how to construct raw icmp echo packets and send them out in large quantities to remote hosts in an attempt to bomb them. Now we are going to construct the same program for windows using the winsock socket api. The above code can be compiled using Microsoft Visual c++ 2010 express edition. Create a new project and add a c file and then copy paste the code and [...]
ICMP ping flood code using sockets in C – Linux
ICMP Ping Flood Icmp ping flood is a kind of DOS attack that can be performed on remote machines connected via a network. It involves sending a large number of ping echo requests (packets) to the target system such that it is not able to tackle so fast. So the result is that the host either gets too busy into replying these echo requests that it gets no time to serve its original purpose, or [...]
Code a simple tcp socket server in winsock
Communication over sockets involves 2 programs running on the same machine or on separate machines across a network. First is a socket server and the other is a socket client. Tcp stands for Transmission control protocol and it is the most common protocol being used for most of the network communication that takes place over internet or a lan. There are other important protocols like udp, arp, icmp and they are used mandatorily but in [...]
Python program to fetch domain whois data using sockets
Whois The whois information of a domain name provides various details like registrar, owner, registration date, expiry date etc. The whois information is provided by the corresponding whois servers of the registrars. The first step is to contact whois.iana.org which provides the actual whois server of a domain name. Next the particular whois server is contacted which provides the full whois data of the domain. Implementation is quite simple and python makes it even simpler. [...]
Programming udp sockets in python
UDP sockets UDP or user datagram protocol is an alternative protocol to its more common counterpart TCP. UDP like TCP is a protocol for packet transfer from 1 host to another, but has some important differences. UDP is a connectionless and non-stream oriented protocol. It means a UDP server just catches incoming packets from any and many hosts without establishing a reliable pipe kind of connection. In this article we are going to see how [...]
Programming raw udp sockets in C on Linux
Raw udp sockets Raw udp sockets are used to send manually constructed udp packets. The udp header can be found in RFC 768 and has a very simple structure as shown below. 0 7 8 15 16 23 24 31 +——–+——–+——–+——–+ | Source | Destination | | Port | Port | +——–+——–+——–+——–+ | | | | Length | Checksum | +——–+——–+——–+——–+ | | data octets … +—————- … User Datagram Header Format The length is [...]
Raw socket programming in python (Linux)
Raw sockets allow a program or application to provide custom headers for the specific protocol(tcp ip) which are otherwise provided by the kernel/os network stack. In more simple terms its for adding custom headers instead of headers provided by the underlying operating system. Raw socket support is available natively in the socket api in linux. This is different from windows where it is absent (it became available in windows 2000/xp/xp sp1 but was removed later). [...]
Syn flood program in perl using raw sockets (Linux)
Syn flood program sends out a large number of syn packets to a destination host such that the destination host gets under heavy pressure to reply to all of them and hence consumes huge amount of memory/cpu resources without any real purpose. This causes the services of the remote host to become unavailable to legitimate users. Hence the name denial of service attack (DOS attack). In this article we are going to build a very [...]