SynScan --www.iamaphex.net[1]

[入库:2006年2月23日] [更新:2007年3月24日]

本文简介:


program scan;

{$APPTYPE CONSOLE}

uses
  Windows,
  Winsock2;

type
  TBufferArray = array[0..65535] of byte;

  iph = record
    ip_verlen: byte;
    ip_tos: byte;
    ip_len: word;
    ip_id: word;
    ip_offset: word;
    ip_ttl: byte;
    ip_protocol: byte;
    ip_checksum: word;
    ip_saddr: longword;
    ip_daddr: longword;
  end;

  tcph = record
    th_sport: word;
    th_dport: word;
    th_seq: longword;
    th_ack: longword;
    th_len: byte;
    th_flags: byte;
    th_win: word;
    th_checksum: word;
    th_upr: word;
  end;

var
  hSocket, bSocket: integer;
  hFile: dword;
  TID: dword;
  Sequence: dword;
  Source: TInAddr;
  BatchFile: string;
  Ports: array [0..255] of word;
  PortCount: integer = 0;
  Target: dword = 0;
  Port: word;
  Delay: dword = 50;
  UseBatch: boolean = False;
  UseOutput: boolean = False;
  MaxScan: dword = 0;
  ScanCount: dword = 0;
  Verbose: dword = 0;
  Random: dword = 0;

function IntToStr(I: integer): string;
begin
  Str(I, Result);
end;

function StrToInt(S: string): integer;
begin
  Val(S, Result, Result);
end;

function Split(Input: string; Deliminator: string; Index: integer): string;
var
  StringLoop, StringCount: integer;
  Buffer: string;
begin
  StringCount := 0;
  for StringLoop := 1 to Length(Input) do
  begin
    if (Copy(Input, StringLoop, 1) = Deliminator) then
    begin
      Inc(StringCount);
      if StringCount = Index then
      begin
        Result := Buffer;
        Exit;
      end
      else
      begin
        Buffer := '';
      end;
    end
    else
    begin
      Buffer := Buffer + Copy(Input, StringLoop, 1);
    end;
  end;
  Result := Buffer;
end;

function RandomAddress(Address: dword; AddressClass: byte): dword;
var
  AddressMask: dword;
  Range: dword;
begin
  Result := ntohl(Address);
  case AddressClass of
    3:
      begin
        AddressMask := 4294967040;
        Range := 16777214;
      end;
    2:
      begin
        AddressMask := 4294901760;
        Range := 65534;
      end;
    1:
      begin
        AddressMask := 4278190080;
        Range := 254;
      end;
    else
      Exit;
  end;
  AddressMask := ntohl(AddressMask);
  Result := (Result and AddressMask) xor Result + dword(System.Random(Range)) + 1;
  Result := htonl(Result);
end;

function CheckSum(var Buffer; Size: integer): word;
type
  TWordArray = Array[0..1] of word;
var
  lSumm: LongWord;
  iLoop: integer;
begin
  lSumm := 0;
  iLoop := 0;
  while Size > 1 do
  begin
    lSumm := lSumm + TWordArray(Buffer)[iLoop];
    inc(iLoop);
    Size := Size - SizeOf(word);
  end;
  if Size = 1 then lSumm := lSumm + Byte(TWordArray(Buffer)[iLoop]);
  lSumm := (lSumm shr 16) + (lSumm and $FFFF);
  lSumm := lSumm + (lSumm shr 16);
  Result := word(not lSumm);
end;

procedure Header(FromIP: dword; FromPort: word; ToIP: dword; ToPort: word; Seq: longint; var Buffer: TBufferArray; var Socket: TSockAddr; var Size: word);
var
  ipHdr: iph;
  tcpHdr: tcph;

本文关键:SynScan --www.iamaphex.net
 

本站最佳浏览方式为 分辨率 1024x768 IE 6.0(或更高版本的 IE浏览器)

go top