tcph(pointer(longint(@Data) + 20)^);
if TCPHeader.th_flags = 16 then
begin
if ntohs(TCPHeader.th_dport) = Port then
begin
if Verbose <> 0 then
begin
Result := string(inet_ntoa(TInAddr(IPHeader.ip_saddr))) + ':' + IntToStr(ntohs(TCPHeader.th_sport)) + #13#10;
Write('[CONNECTION] ' + Result);
end;
if UseOutput then
begin
Result := string(inet_ntoa(TInAddr(IPHeader.ip_saddr))) + ':' + IntToStr(ntohs(TCPHeader.th_sport)) + #13#10;
WriteFile(hFile, pointer(Result)^, Length(Result) + 1, BytesWritten, nil);
end;
if UseBatch then
begin
Result := BatchFile + ' ' + string(inet_ntoa(TInAddr(IPHeader.ip_saddr))) + ' ' + IntToStr(ntohs(TCPHeader.th_sport));
ZeroMemory(@StartInfo, SizeOf(TStartupInfo));
StartInfo.cb := SizeOf(TStartupInfo);
StartInfo.dwFlags := STARTF_USESHOWWINDOW;
StartInfo.wShowWindow := SW_HIDE;
CreateProcess(nil, pchar(Result), nil, nil, False, 0, nil, nil, StartInfo, ProcInfo);
end;
end;
end;
end;
end;
end;
procedure ScanAddresses;
var
PortLoop: integer;
begin
while ((ScanCount <= MaxScan) or (MaxScan = 0)) do
begin
if Verbose = 2 then
begin
if ntohl(Target) mod 256 = 0 then
begin
Target := htonl(ntohl(Target) + 1);
end;
if ScanCount mod 255 = 0 then
begin
WriteLn('[STATUS] ' + string(inet_ntoa(TInAddr(Target))));
end;
end;
for PortLoop := 0 to PortCount - 1 do
begin
Send(Target, Ports[PortLoop], dword(Source), Port, Sequence);
Send(Target, Ports[PortLoop], dword(Source), Port, Sequence);
Sleep(Delay);
Inc(ScanCount);
end;
if Random > 0 then
begin
Target := RandomAddress(Target, Random)
end
else
Target := htonl(ntohl(Target) + 1);
end;
Halt(0);
end;
procedure Usage;
begin
WriteLn('AFX Syn Scanner 0.2 for 2000/XP/2003');
WriteLn('http://www.iamaphex.cjb.net');
WriteLn('aphex@iamaphex.net');
WriteLn;
WriteLn('Usage: scan -h:host -p:port -i:scancount -d:delay -b:batch -o:output -v:verboselevel -r:randomlevel');
end;
procedure ParseOption(Cmd, Arg: string);
begin
if lstrcmp('-h:', pchar(Cmd)) = 0 then
begin
Target := inet_addr(pchar(Arg));
end
else if lstrcmp('-p:', pchar(Cmd)) = 0 then
begin
Ports[PortCount] := StrToInt(Arg);
Inc(PortCount);
end
else if lstrcmp('-d:', pchar(Cmd)) = 0 then
begin
Delay := StrToInt(Arg);
end
else if lstrcmp('-i:', pchar(Cmd)) = 0 then
begin
MaxScan := StrToInt(Arg);
end
else if lstrcmp('-b:', pchar(Cmd)) = 0 then
begin
BatchFile := Copy(Arg, 1, Length(Arg));
UseBatch := True;
end
&