Link to home
Start Free TrialLog in
Avatar of Shinez
Shinez

asked on

UDP Port Scanner

Could someone show me how to make a UDP port scanner in delphi.

I've aready made a TCP port scanner, but how would I make a UDP port scanner.

Could someone show me how this is done?
ASKER CERTIFIED SOLUTION
Avatar of GloomyFriar
GloomyFriar

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of Shinez
Shinez

ASKER

How Would I do this?
Ok, I'll try to explain.
It's impossible to scan UDP port if it just was opened.
You can determine that UDP port is opened by sending some datagram to the port only.
And if you'll be lucky you'll got an answer from the server.
But server is not obliged to answer to you if you don't know its protocol ;-)

So, if you know what server you are looking for and you know its protocol then try to send some command (according to the protocol) and wait for an answer from the server. ip-by-ip, port-by-port ;-)

Good luck.
Avatar of Shinez

ASKER

could you show me how this is done, have edit1 for ip and edit2 for port and for label1 to display if port is open/close.

if I wanted to check if the port is open for ut2003.

default game port is 7777, the query port is 7778.

how would I get a responce that the server is up?

please could you give some code with your answer, I don't know that much about UDP.

thxs
There is no "open" and "close" terms applying to the UDP protocol.

...
Var buff: array[0..256] of byte;
...
   UDPClient := TNMUDP.Create(self);
   UDPClient.RemoteHost := 'ut2003'; // or something like '192.168.1.15'
   UDPClient.RemotePort := 7778;
   UDPClient.LocalPort := 7777;
   UDPClient.OnDataReceived := UDPClientDataReceived;
   UDPClient.OnStatus := UDPClientStatus;
   UDPClient.OnInvalidHost := UDPClientInvalidHost;
   UDPClient.OnStreamInvalid := UDPClientStreamInvalid;
   UDPClient.OnBufferInvalid := UDPClientBufferInvalid;
...

   StrPCopy(buff, "Hello!");
   try UDPClient.SendBuffer(buff, 7);
   except;
     // Error
   end;

...
procedure TMainForm.UDPClientDataReceived(Sender: TComponent;
  NumberBytes: Integer; FromIP: String);
Var buff: array[0..256] of byte;
begin
  UDPClient.ReadBuffer(buff, NumberBytes);
end;