I recently discovered that the popular P2P file sharing app, known as Kazaa, runs on port 1214 (by default). Based on this information, one can write a program that attempts to connect to a host computer on port 1214, and based on the results, determines if the host IP is running Kazaa.
This is relatively easy to do If you have a basic understanding of the System.Net.Sockets namespace, and the associated objects (such as TCPClient, IPHostEntry, IPAdress, TCPListener, Socket, etc.)
Here is a program I came up with to attempt to access a host computer on port 1214:
KazaaScan.cs
//////////////////////////////////////////////////////////////////////////////
// Program Scans if computer behind IP Adress is running Kazaa on port 1214 /
// By Jim Peterson, 2006 /
//////////////////////////////////////////////////////////////////////////////
using System;
using System.Net.Sockets;
using System.IO;
using System.Text;
class KazaaScan
{
public bool repeat = true;
static void Main(string[] args)
{
bool sucess;
String response = "";
try {
TcpClient myTCPclient = new TcpClient();
Console.Write("Enter IP of Target: ");
String IP_Adress = Console.ReadLine(); Console.WriteLine("");
myTCPclient.Connect(IP_Adress, 1214);
Stream outputStream1 = myTCPclient.GetStream();
ASCIIEncoding transEncoded = new ASCIIEncoding();
byte[] byte1 = transEncoded.GetBytes("Are You Kazaa?");
outputStream1.Write(byte1, 0, byte1.Length);
byte[] byte2 = new byte[100];
int k = outputStream1.Read(byte2, 0, 100);
for (int i = 0; i < k; i++) {
response = response + Convert.ToChar(byte2[i]);
}
myTCPclient.Close();
if (response != "")
{
sucess = false;
} else {
sucess = true;
}
}
catch {
sucess = false;
}
if (sucess) {
Console.WriteLine("\nThe Target Is Running Kazaa");
}
else {
Console.WriteLine("\nThe Target Is NOT Running Kazaa");
Gaara KSPosted Aug 20, 2015, 2:43 AM
Thanks for ur post. Instead of user typing the ip address, how can i get all the ip address within the network and check which ip is listening the port?
Jim PetersonPosted Jan 3, 2006, 10:24 AM
Thanks for your help, the code looks much better!
Jim PetersoneditedPosted Jan 2, 2006, 5:33 PMEdited Jan 2, 2006, 5:41 PM
Sorry everyone for the wier way the code came out, It is VERY hard to read. I encourage you to download the source code, so you will have an easier time reading it. - Jim