Chinaunix首页 | 论坛 | 博客
  • 博客访问: 591585
  • 博文数量: 60
  • 博客积分: 3993
  • 博客等级: 中校
  • 技术积分: 1572
  • 用 户 组: 普通用户
  • 注册时间: 2005-08-08 17:08
文章分类

全部博文(60)

文章存档

2012年(7)

2011年(35)

2010年(8)

2009年(7)

2008年(3)

分类: Python/Ruby

2011-12-02 19:19:05

perl client for freeradius
  1. #!/usr/bin/perl
  2. use strict;
  3. use Authen::Radius;

  4. my $RadiusIP="192.168.56.101";
  5. my $RadiusKey="pterm_radius_56";
  6. my $r=new Authen::Radius(Host=>$RadiusIP,Secret=>$RadiusKey);
  7. if ($r->check_pwd("test","test")) {
  8.     print "ok\n";
  9. } else {
  10.     print "err\n";
  11. }
 
python client for freeradius
  1. #!/usr/bin/env python

  2. import pyrad.packet
  3. from pyrad.client import Client
  4. from pyrad.dictionary import Dictionary


  5. srv=Client(server="192.168.56.101",
  6.            secret="pterm_radius_56",
  7.            dict=Dictionary("dictionary"))

  8. req=srv.CreateAuthPacket(code=pyrad.packet.AccessRequest,
  9.                          User_Name="test")

  10. req["User-Password"]=req.PwCrypt("test")

  11. reply=srv.SendPacket(req)
  12. if reply.code==pyrad.packet.AccessAccept:
  13.     print "access accepted"
  14. else:
  15.     print "access denied"
 
dictionary文件
 
  1. #
  2. # Version $Id: dictionary,v 1.1.1.1 2002/10/11 12:25:39 wichert Exp $
  3. #
  4. #    This file contains dictionary translations for parsing
  5. #    requests and generating responses. All transactions are
  6. #    composed of Attribute/Value Pairs. The value of each attribute
  7. #    is specified as one of 4 data types. Valid data types are:
  8. #
  9. #    string - 0-253 octets
  10. #    ipaddr - 4 octets in network byte order
  11. #    integer - 32 bit value in big endian order (high byte first)
  12. #    date - 32 bit value in big endian order - seconds since
  13. #                    00:00:00 GMT, Jan. 1, 1970
  14. #
  15. #    FreeRADIUS includes extended data types which are not defined
  16. #    in RFC 2865 or RFC 2866. These data types are:
  17. #
  18. #    abinary - Ascend
阅读(1885) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~