Changeset 1173

Show
Ignore:
Timestamp:
07/18/08 23:38:39 (5 months ago)
Author:
mbr
Message:

implemented UDP source port randomization by default, and added --Source-port in the fwknop client to override this

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • fwknop/trunk/ChangeLog

    r1165 r1173  
    1 fwknop-1.9.6 (07//2008): 
     1fwknop-1.9.6 (07/18/2008): 
    22    - SPA packets are base64-encoded by the fwknop client, and this encoding 
    33      pads data with '=' chars until the total length of the encoded data is a 
     
    2525        alert udp any any -> any 62201 (msg:"fwknop GnuPG encrypted SPA 
    2626        traffic"; content:"hQ"; depth:2; dsize:>1000; sid:20080003; rev:1;) 
     27 
     28    - Updated the fwknop client to randomize the UDP source port for default 
     29      SPA packet generation.  There is also a new command line argument 
     30      --Source-port <port> to allow the user to manually set the source port 
     31      on the fwknop client command line.  A lot more attention is given now to 
     32      source ports after the Dan Kaminsky DNS caching exploit, and it turns 
     33      out that even on Linux that the kernel did not randomize UDP source 
     34      ports until the 2.6.24 kernel.  Of course, any userspace process is free 
     35      to request a random port itself, but if a userspace application did not 
     36      build this in then it would be up to the kernel to assign a source port. 
     37      In the case of Linux, here are two links that show the change to the 
     38      kernel code as well as the ChangeLog entry for UDP source port 
     39      randomization: 
     40 
     41        http://git.kernel.org/?p=linux/kernel/git/torvalds/linux-2.6.git;\ 
     42        a=commit;h=32c1da70810017a98aa6c431a5494a302b6b9a30 
     43        http://www.kernel.org/pub/linux/kernel/v2.6/ChangeLog-2.6.24 
    2744 
    2845    - (Test suite): Added the ability to explicitly run major classes of tests 
  • fwknop/trunk/fwknop

    r1167 r1173  
    6767my $knock_dst     = ''; 
    6868my $homedir       = ''; 
     69my $min_port      = 10000; 
     70my $max_port      = 65535; 
    6971my $spoof_src     = ''; 
    7072my $server_mode   = 'pcap'; 
     
    8789my $gpg_agent_info = ''; 
    8890my $include_salted = 0; 
     91my $client_src_port = 0; 
    8992my $gpg_default_key = 0; 
    9093my $err_wait_timer  = 30;  ### seconds 
     
    971974                "over udp/$enc_pcap_port...\n" unless $quiet; 
    972975 
     976            unless ($client_src_port) { 
     977                $client_src_port = &rand_port(); 
     978            } 
    973979            unless ($test_mode) { 
    974980                my $socket = IO::Socket::INET->new( 
    975                     PeerAddr => $knock_dst, 
    976                     PeerPort => $enc_pcap_port, 
    977                     Proto    => 'udp', 
    978                     Timeout  => 1 
     981                    PeerAddr  => $knock_dst, 
     982                    PeerPort  => $enc_pcap_port, 
     983                    LocalPort => $client_src_port, 
     984                    Proto     => 'udp', 
     985                    Timeout   => 1 
    979986                ) or die "[*] Could not acquire UDP socket: $!"; 
    980987 
     
    14991506        'NAT-local'      => \$NAT_local, 
    15001507        'NAT-access=s'   => \$NAT_access_str, 
     1508        'Source-port=i'  => \$client_src_port, 
    15011509        'Spoof-user=s'   => \$spoof_username, 
    15021510        'Spoof-proto=s'  => \$spoof_proto, 
     
    17621770 
    17631771sub rand_port() { 
    1764     return 10000 + int(rand(55535))
     1772    return int(rand($max_port - $min_port)) + $min_port
    17651773} 
    17661774 
     
    18561864                                 encrypted SPA packet is stored when the 
    18571865                                 --Save-packet argument is used. 
     1866    --Source-port <port>       - Fix a specific source port for outgoing SPA 
     1867                                 packets.  This is not usually necessary, 
     1868                                 and the fwknop client randomizes its source 
     1869                                 port by default. 
    18581870    --Server-port <port>       - Specify the port number to which to send 
    18591871                                 the single authentication packet (this is