home *** CD-ROM | disk | FTP | other *** search
- program Scan_UDP_DNS53;
- {
- checks for presents of DNS service on UDP port 53
- }
-
- procedure SetDetected(hname,responce:string);
- begin
- if length(hname)<>0 then NVSCAN_HOSTNAME:=LowerCase(hname);
- NVSCAN_RESPONCE:=responce;
- NVSCAN_DETECTED:=true;
- end;
-
- function GetPtrName:string;
- var a:cardinal;
- s:array[1..6] of string;
- r:string;
- i:integer;
- begin
- a:=NV_ADDRESS;
-
- s[1]:=IntToStr((a shr 24) and 255);
- s[2]:=IntToStr((a shr 16) and 255);
- s[3]:=IntToStr((a shr 8) and 255);
- s[4]:=IntToStr(a and 255);
- s[5]:='in-addr'
- s[6]:='arpa';
- setlength(r,0);
- for i:=1 to 6 do r:=r+chr(length(s[i]))+s[i];
- r:=r+#0;
- Result:=r;
- end;
-
- var s,r,d:string;
- i:integer;
- begin
- s:=chr(1+random(142))+chr(1+random(142))+#1#0 #0#1 #0#0 #0#0 #0#0+GetPtrName+#0#12 #0#1;
- send(s);
- r:=recv;
- if length(r)<>0 then
- begin
- if length(r)>=12 then
- begin
- if (r[1]<>s[1]) or (r[2]<>s[2]) then d:='Incorrect ID in DNS reply: '
- else d:='DNS reply: ';
- end else d:='Too short DNS reply: ';
- for i:=1 to length(r) do if r[i]=chr(0) then r[i]:='#';
- SetDetected('',d+r);
- end;
- end.
-