Hi,
I tried to extend port scan application , in order to display the port found open on the server side. I tried a lot but failed to do so. Below is the approach I used. The program never enters the handleincomingpacket method, why is it happening? Please help. If this is not he correct approach kindly suggest me one.
//DecompiledbyJadv1.5.8e.Copyright2001PavelKouznetsov.//Jadhomepage:http://www.geocities.com/kpdus/jad.html//Decompileroptions:packimports(3)//SourceFileName:SimplePortScanner.javaimportde.dailab.nessi.core.api.annotations.Description;importde.dailab.nessi.core.api.annotations.IntegerField;importde.dailab.nessi.core.api.annotations.StringField;importde.dailab.nessi.core.api.events.Event;importde.dailab.nessi.core.api.events.TickedEvent;importde.dailab.nessi.ip.api.address.IPFactory;importde.dailab.nessi.ip.api.address.IPv4Address;importde.dailab.nessi.ip.api.layer.ILayerHandler;importde.dailab.nessi.ip.api.layer.ITransportLayer;importde.dailab.nessi.ip.api.protocols.Packet;importde.dailab.nessi.ip.api.protocols.ip.IPv4Header;importde.dailab.nessi.ip.api.protocols.udp.UDPHeader;importde.dailab.nessi.ip.handler.IPApplication;importde.dailab.nessi.ip.handler.PromiscuousModeApplication;importjava.util.Random;publicclassPort_AKextendsIPApplication{privateintClientPort=1500;publicPort_AK(){startPort=1;endPort=1024;targetIp="0.0.0.0";startTick=10;}publicvoidhandleEvent(Evente){Randomran=newRandom(123L);for(inti=startPort;i<endPort;i++){bytepayload[]=newbyte[28];ran.nextBytes(payload);getLayerHandler().getTransportLayer().sendUDPPacket(ClientPort,i,destinationIP,payload);}super.handleEvent(e);}publicvoidhandleIncomingPacket(Packetpacket1){System.out.println("Packet Came");IPv4HeaderipHeader=packet.findHeader(IPv4Header.class);UDPHeaderudpHeader=packet.findHeader(UDPHeader.class);if(ipHeader==null||udpHeader==null){return;}System.out.print("The port replied back is ");System.out.println(udpHeader.getSourcePort());}publicbooleanstart(){getLayerHandler().getTransportLayer().registerUDPPort(ClientPort,this);destinationIP=IPFactory.createIPv4Address(targetIp);TickedEvente=newTickedEvent(this,startTick);getLayerHandler().addEvent(e);returnsuper.start();}@IntegerField("Start Port")@Description("Start Port number")privateintstartPort;@IntegerField("End Port")@Description("End")privateintendPort;@StringField("IP Address")privateStringtargetIp;privateintstartTick;privateIPv4AddressdestinationIP;}
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
The purpose of the "SimplePortScanner" application was only to generate the traffic for the scanner itself. In the example the return traffic was never really addressed, since that would be behaviour on the server side. So, you only will get a reply, if there is an UDP server application running on the destination IP, that replies to any random input. Otherwise there won't be a reply for open ports.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
I tried with that too. I deployes UDP sevrer that replies back to the same IP and Port from which it recieves the packet. Still it is not working. I think the problem is :
1. Once a port is used for sending the packet at 'Por Scanner' , it canno be further registered for listening the replies from the server side.
2. I could not find methods that captures the incoming packets without registered ports.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
You could try to extend your application from the class AbstractPromiscuousModeApplication. If you implement the method public void process(Packet p) you should receive/see all incoming and outgoing packets. In your case you also need to make sure, that processing packets is not blocked by the application.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Hi,
I tried to extend port scan application , in order to display the port found open on the server side. I tried a lot but failed to do so. Below is the approach I used. The program never enters the handleincomingpacket method, why is it happening? Please help. If this is not he correct approach kindly suggest me one.
The purpose of the "SimplePortScanner" application was only to generate the traffic for the scanner itself. In the example the return traffic was never really addressed, since that would be behaviour on the server side. So, you only will get a reply, if there is an UDP server application running on the destination IP, that replies to any random input. Otherwise there won't be a reply for open ports.
I tried with that too. I deployes UDP sevrer that replies back to the same IP and Port from which it recieves the packet. Still it is not working. I think the problem is :
1. Once a port is used for sending the packet at 'Por Scanner' , it canno be further registered for listening the replies from the server side.
2. I could not find methods that captures the incoming packets without registered ports.
You could try to extend your application from the class AbstractPromiscuousModeApplication. If you implement the method public void process(Packet p) you should receive/see all incoming and outgoing packets. In your case you also need to make sure, that processing packets is not blocked by the application.