[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[GNUnet-developers] #1211
From: |
Wolfgang Brehm |
Subject: |
[GNUnet-developers] #1211 |
Date: |
Fri, 10 Apr 2009 18:32:33 +0200 |
User-agent: |
KMail/1.10.3 (Linux/2.6.27.19-3.2-default; KDE/4.1.3; x86_64; ; ) |
I wrote a simple threaded portscanner in java.
I hope it will be usefull. It is my first projekt, sadly my C/C++ is too bad
to contribute right now.
It shoul't be difficult for me, to integrate the wished HELLO, I will have to
read the documentation If this is wished
/**
* Scanner
* @author (wolfgang brehm)
* @version (10.4.2009)
*/
import java.util.ArrayList;
public class Scanner
{
String host;
int lowerport;
int upperport;
static int j=0;
static ArrayList ports = new ArrayList(16);
public Scanner(String host, int lowerport, int upperport)
{
this.host=host;
this.lowerport=lowerport;
this.upperport=upperport;
}
/**
* Scanning method: threaded
*
* @param String host The host, which ports will be scanned
* @param int lowerport the lowerport
* @param int upperport the upperport
* @return ports[] ports The ports, which responded
*/
public Object[] main()
{
for (int i=lowerport; i<=upperport; i++) {
scan current = new scan(host, i);
Thread th = new Thread(current);
th.start();
try{
th.sleep(1);
}catch (InterruptedException e){}
}
return ports.toArray();
}
}
-----------------------------------------------------------------------------
/**
*
* Thread scan, that is actually scanning.
* @author (wolfgang brehm)
* @version (10.4.2009)
*/
import java.io.IOException;
import java.net.Socket;
import java.net.UnknownHostException;
public class scan implements Runnable
{
int port;
String host;
public scan(String host, int port)
{
this.host=host;
this.port=port;
}
/**
* THE run() method a Runnable must implement
*
*/
public void run()
{
try {
Socket target = new Socket(host, port);
Scanner.ports.add(port);
target.close();
}catch(UnknownHostException e){
System.out.println(host+" is unknown");
}catch (IOException e){}
}
}
Wolfgang Brehm aka Lykos
- [GNUnet-developers] #1211,
Wolfgang Brehm <=