home *** CD-ROM | disk | FTP | other *** search
/ PC Professionell 2007 April / PCpro_2007_04.ISO / files / dsl / NVinst.exe / Scripts / Scaner / udp_dns53.nvs < prev    next >
Encoding:
Text File  |  2007-02-10  |  1.1 KB  |  50 lines

  1. program Scan_UDP_DNS53;
  2. {
  3. checks for presents of DNS service on UDP port 53
  4. }
  5.  
  6. procedure SetDetected(hname,responce:string);
  7. begin
  8. if length(hname)<>0 then NVSCAN_HOSTNAME:=LowerCase(hname);
  9. NVSCAN_RESPONCE:=responce;
  10. NVSCAN_DETECTED:=true;
  11. end;
  12.  
  13. function GetPtrName:string;
  14. var a:cardinal;
  15.     s:array[1..6] of string;
  16.     r:string;
  17.     i:integer;
  18. begin
  19. a:=NV_ADDRESS;
  20.  
  21. s[1]:=IntToStr((a shr 24) and 255);
  22. s[2]:=IntToStr((a shr 16) and 255);
  23. s[3]:=IntToStr((a shr 8) and 255);
  24. s[4]:=IntToStr(a and 255);
  25. s[5]:='in-addr'
  26. s[6]:='arpa';
  27. setlength(r,0);
  28. for i:=1 to 6 do r:=r+chr(length(s[i]))+s[i];
  29. r:=r+#0;
  30. Result:=r;
  31. end;
  32.  
  33. var s,r,d:string;
  34.     i:integer;
  35. begin
  36. s:=chr(1+random(142))+chr(1+random(142))+#1#0 #0#1 #0#0 #0#0 #0#0+GetPtrName+#0#12 #0#1;
  37. send(s);
  38. r:=recv;
  39. if length(r)<>0 then
  40.  begin
  41.  if length(r)>=12 then
  42.   begin
  43.   if (r[1]<>s[1]) or (r[2]<>s[2]) then d:='Incorrect ID in DNS reply: '
  44.                                   else d:='DNS reply: ';
  45.   end else d:='Too short DNS reply: ';
  46.  for i:=1 to length(r) do if r[i]=chr(0) then r[i]:='#';
  47.  SetDetected('',d+r);
  48.  end;
  49. end.
  50.