Loading ...
Sorry, an error occurred while loading the content.

RE: [PBML] AMAZING !!!!! AMAZING !!!! ( DON'T MISS IT !!!!!!!)

Expand Messages
  • Nathan.Jeffrey@dhs.vic.gov.au
    ... Agreed. So, in the spirit of things Perl, here s the script I use to verify RSA ACE/Server tokens actually work. Should work with just about any RADIUS
    Message 1 of 1 , Aug 26, 2003
    • 0 Attachment
      > Please. I get plenty of real spam without having to wade
      > through commentary on spam as well. This mailing list offers
      > a great service relating to Perl usage. Let's keep it that way.

      Agreed. So, in the spirit of things Perl, here's the script I use to
      verify RSA ACE/Server tokens actually work. Should work with just about
      any RADIUS server, assuming the dictionary values are the same :-

      #!/opt/perl5/bin/perl
      # note - no -w, because Authen::Radius is a bit dodgy.

      use strict;
      use Authen::Radius;
      use Getopt::Long;

      my $DEBUG;
      my ($ok_flag, $username, $password, $req, $ref, @hrefs, $server,
      $ident);

      GetOptions(
      'DEBUG' => \$DEBUG,
      'username=s' => \$username,
      'server=s' => \$server,
      );

      if ($DEBUG) {
      use Data::Dumper;
      }

      $server = 'server' unless $server;
      $ok_flag = 0;

      sub prompt {
      my $message = shift;
      my $default = shift or '';
      print $default ? "$message\[$default\]\: " : "$message\: ";
      my $response = <>;
      chomp $response;
      return $default ? $default : undef() if $response =~ m/^$/;
      return $response;
      };

      sub modify_attribute {
      my $req = shift;
      my $name = shift;
      my $value = shift;
      my $ref;
      my %hash;

      foreach $ref ($$req->get_attributes) {
      $hash{$$ref{'Name'}} = $ref
      }

      print Dumper(\%hash) if $DEBUG;

      $hash{$name}{'RawValue'} = $value;

      $$req->clear_attributes;

      foreach $ref (keys %hash) {
      $$req->add_attributes(
      { Name => $ref, Value => $hash{$ref}{'RawValue'}
      }
      );
      }
      }

      $username = prompt("Username", $username);
      $password = prompt("Password");

      print "Establishing connection.\nusername = $username\nserver =
      $server\n" if $DEBUG;

      $req = new Authen::Radius(Host => $server, Secret => 'secret');

      $req->clear_attributes;

      $req->add_attributes(
      { Name => 1, Value => $username },
      { Name => 2, Value => $password },
      );

      CONN: until ($ok_flag) {

      print "Sending...\n" if $DEBUG;
      print Dumper($req->get_attributes) if $DEBUG;

      print "Receiving...\n" if $DEBUG;
      $req->send_packet(ACCESS_REQUEST) and $req->recv_packet ==
      ACCESS_ACCEPT;
      print Dumper($req->get_attributes) if $DEBUG;

      @hrefs = $req->get_attributes;

      foreach $ref (@hrefs) {
      if ( $$ref{'Code'} == 18 and $$ref{'RawValue'} =~
      m/^Access Denied/ ) {
      print "Auth failed!\n";
      print $$ref{'RawValue'} if $DEBUG;
      $ok_flag = 1 and next CONN;
      } elsif ( $$ref{'Code'} == 18 and
      $$ref{'RawValue'} =~ m/^PASSCODE Accepted/ ) {
      print "Token OK\n";
      print $$ref{'RawValue'} if $DEBUG;
      $ok_flag = 1 and next CONN;
      } elsif ( $$ref{'Code'} == 18 and
      $$ref{'RawValue'} =~ m/^Wait for the tokencode to change/ ) {
      print "Next Tokencode requested.\n";
      $password = prompt("Next tokencode ",
      $password);
      modify_attribute(\$req, '2', $password);

      next CONN;
      }
      }
      }


      _________________________________________________________________________________

      This email contains confidential information intended only for the person named above and may be subject to legal privilege. If you are not the intended recipient, any disclosure, copying or use of this information is prohibited. The Department provides no guarantee that this communication is free of virus or that it has not been intercepted or interfered with. If you have received this email in error or have any other concerns regarding its transmission, please notify Postmaster@...
      _________________________________________________________________________________
    Your message has been successfully submitted and would be delivered to recipients shortly.