Linux锐捷2.56认证客户端XMU-Ruijie--用python写的

| 评论(26)

用了一周多的时间,完成了Very Happy

首先说一下XMU-Ruijie的意思。XMU是Xiaman University即厦门大学,偶的母校。因为这个客户端是为解决厦门大学众多Linux用户上校园网难的问题写的。Ruijie是锐捷的拼音。

接下来说说过程把。开始几天把锐捷2.56的算法学着用pyhon的类重写,中间发现在线包的算法错了。花了一个晚上研究以前抓的包,终于修正了算法。接下来的几天又陆续学了固定时间发包的实现,daemon方式,配置文件读取,昨晚继续奋战,终于把程序最后调试好了。

这个客户端最大的优点是什么?我的初衷是用python写,从而避免xsupplicant的编译问题。同时,因为这个客户端仅仅是用来进行锐捷认证的,所以不包含其他功能的代码,体积比xsupplicant小了很多。与此同时,配置也简化到用户名,密码,网络界面,日志文件,pid文件(后两者一般不需要修改)。同时锐捷的协议部分是用类写的,也就是说如果别人要改成其它MD5协议只要重写一个协议的类,嵌进去即可。

相比xrgsu,不会出现多网卡检测的错误,因为XMU-Ruijie是不检测多网卡的Wink认证速度相当快,我在宿舍中不到1秒就认证好了,DHCP大概2秒。

功能上,只做一件事,完成认证。因为DHCP客户端功能我写的肯定没有dhcpcd和dhclient好了Very HappyGentoo用户直接下载ebuild安装。同时我写了一个bash的start-stop脚本(DHCP的)和bash的安装脚本,非gentoo的用户也方便很多了。这两个bash脚本都在压缩包里了。

Gentoo用户

安装

Gentoo的用户先下载好portage文件,并放到自己的portage-overlay中:

代码: 下载并解压portage文件,如portage-overlay为/usr/local/portage
cd /usr/local
wget -c http://acevery.cnlog.org/upload/portage-xmuruijie.zip
unzip portage-xmuruijie.zip

然后添加关键字到/etc/portage/package.keywords中:

代码: 添加关键字,以~x86为例
echo "net-misc/xmuruijie ~x86" >> /etc/portage/package.keywords

如果你用的是iptables的防火墙,你可能需要使用特殊的启动脚本,那就使用firewall这个USE。但如果你没有用iptables做为防火墙的话,请不要用firewall这个USE。

代码: 将firewall添加到/etc/porage/package.use中
echo "net-misc/xmuruijie firewall" >> /etc/portage/packege.use

接下来,我们就可以安装XMU-Ruijie了,方法就是我们熟悉的emerge。

代码: 安装XMU-Ruijie
emerge -av xmuruijie

使用

首先在/etc/conf.d/xmuruijie.conf中设置好用户名、密码和网卡

文件: /etc/conf.d/xmuruijie.conf
# this is the configuration file of XMU-Ruijie 
# parameters for authentication
[auth]
user: Your-Acount
passwd: Your-Password
interface: eth0
# parameters for daemonize:
[daemon]
logfile: /var/log/xmuruijie.log
pid: /var/run/xmuruijie.pid

然后就可以用XMU-Ruijie来认证了如果你用的是动态IP的话,那就直接用/etc/init.d/ruijie来认证。

代码: 动态IP认证启动
/etc/init.d/ruijie start

代码: 动态IP认证停止
/etc/init.d/ruijie stop

如果是静态IP认证的话,需要先将/etc/init.d/saier中的DNS地址改成你自己的DNS

文件: /etc/init.d/saier
start() {
	checkconfig || return 1
	ebegin "Bring up Net-Interface"
	#将红字的IP改成你自己的DNS
	echo "nameserver 210.34.0.18" > /etc/resolv.conf
	/etc/init.d/net.${DEV} start
	eend $?

然后再用/etc/init.d/saier来进行认证

代码: 静态IP认证启动
/etc/init.d/saier start

代码: 静态IP认证停止
/etc/init.d/saier stop

注意: 如果你需要用xrgsu-1.1.1的算法来认证,你只需要修改一下/etc/init.d/ruijie/etc/init.d/saier中启动XMU-Ruijie的参数即可:

文件: /etc/init.d/ruijie
start() {
	checkconfig || return 1

	ebegin "Starting XMU-Ruijie"
		/usr/sbin/xmuruijie -d -x
	eend $?

文件: /etc/init.d/saier
start() {
	...
	ebegin "Start XMU-Ruijie"
		/usr/sbin/xmuruijie -d -x
	eend $?
}

非Gentoo的用户

安装

下载XMU-Rujie的压缩包并解压,然后用root用户来执行安装脚本install.sh

代码: 安装XMU-Ruijie
wget -c http://acevery.cnlog.org/upload/xmuruijie-1.2.tar.gz
tar -xvzf xmuruijie-1.2.tar.gz
cd xmuruijie-1.2
./install.sh install

使用

首先在/etc/xmuruijie.conf中设置好用户名、密码和网卡

文件: /etc/conf.d/xmuruijie.conf
# this is the configuration file of XMU-Ruijie 
# parameters for authentication
[auth]
user: Your-Acount
passwd: Your-Password
interface: eth0
# parameters for daemonize:
[daemon]
logfile: /var/log/xmuruijie.log
pid: /var/run/xmuruijie.pid

然后就可以用/etc/init.d/xmuruijie来认证了,认证的方式是动态IP认证,静态IP认证的方式我不清楚Gentoo以外发行版的具体步骤。

代码: Ubutun等下的动态IP认证启动
/etc/init.d/xmuruijie start

代码: Ubutun等下的动态IP认证停止
/etc/init.d/xmuruijie stop

注意: 如果你需要用xrgsu-1.1.1的算法来认证,请修改/etc/init.d/xmuruijie文件,加上-x来启动XMU-Ruijie

文件: /etc/init.d/xmuruijie
case "$1" in
 start) 
    echo "Starting xmuruijie"
		/usr/sbin/xmuruijie -d -x

    echo "Running dhcp client to get ip address..."
    if [ -f "/sbin/dhcpcd" ] ; then

如果你觉得这个程序太烂了,那就用install.sh把所有的组件都删掉

代码: 移除XMU-Ruijie
cd xmuruijie-1.3
./install.sh uninstall

2007.8.30:升级到1.3,增加了xrgsu1.1.1的算法,并加入了显示认证服务器发给信息的算法。

2007.8.24: 升级到1.2,增加了logoff包算法,并加入了另一个在海韵公寓的组播地址:-)

点击下载XMU-Ruijie压缩包

点击下载打包的XMU-Ruijie的ebuild

评论(26)

我使用ubutnu用户。
我使用sudo ./install.sh进行安装却没有任何结果。
这是为什么呢?

搞定安装,
应该使用sudo ./install.sh install 就可以了。
不过在我的ubutnu系统中没有etc/conf.d/文件夹。所以应该先建一个或修改。
但是没有使用。

的确验证很快。但是在使用过程中有这样的一段提示。
sudo xmuruijie
--> Sent EAPOL Start
The eth0 is up, we will use Network Parameters for Authentication.

We haven't got the random md5 hash, so use randstr() to fill the 32 byte Hash.


0000: 01 80 c2 00 00 03 00 0d 60 8e 94 0d 88 8e 01 01
0001: 00 00 ff ff 37 77 7f a4 7c 4f ec 00 00 00 ff a4
0002: 7c 4f 7f b4 bb ff b7 df f7 00 00 13 11 38 30 32
0003: 31 78 2e 65 78 65 00 00 00 00 00 00 00 00 00 00
0004: 00 00 00 00 00 00 00 00 00 00 00 00 00 02 38 00
0005: 00 00 00 00 13 11 00 4a 1a 28 00 00 13 11 17 22
0006: 42 36 44 32 32 45 34 42 31 36 38 32 37 42 43 36
0007: 43 33 41 42 31 42 32 42 30 34 46 39 33 38 38 34
0008: 1a 0c 00 00 13 11 18 06 00 00 00 00 1a 0e 00 00
0009: 13 11 2d 08 00 0d 60 8e 94 0d 1a 08 00 00 13 11
000a: 2f 02
In Static mode
timed out! restart

这是什么呢?

看来我错了。
被假想骗了。
但我重启以后,使用sudo xmuruijie不能进行认证的。

>>1 Dear Rober :
要sudo ./install install的

你是用什么命令验证的?
看一下README里的说明。
可以用xmuruijie -d 来启动后台模式,然后把/var/log/xmuruijie.log作为分析的日志。

你的网卡是eth0吗?因为发出的请求包没有收到回应。

把/etc/conf.d/xmuruijie.conf改成了/etc/xmuruijie.conf了。
/etc/conf.d可能是gentoo特有的。

组播地址修改成锐捷的私有地址了。
现在应该没有问题了:-)

师兄,你的install.sh的提示还没有改。
'*******************************************'
* Remenber to change the user and passwd *'
* in /etc/conf.d/xmuruijie.conf first ! *'
'*******************************************'

哈哈,还是鱼师兄牛阿,终于搞定了,以后试着用64位的系统了,
对了,不知道能不能把密码像GRUB一样,用md5加密,现在就试试去,哈哈^_^

>>9 Dear Rober :
已经改过来了:-)

>>10 Dear xiaofeng :
加密是不难,但是用户使用不方便呀:-)

感谢兄弟的贡献!
但我在安装过程中遇到了问题
# emerge xmuruijie -av
These are the packages that would be merged, in order:

Calculating dependencies |!!! A file is not listed in the Manifest: '/usr/local/portage/net-misc/xmuruijie/xmuruijie-1.2.ebuild'
!!! A file is not listed in the Manifest: '/usr/local/portage/net-misc/xmuruijie/xmuruijie-1.2.ebuild'
!!! A file is not listed in the Manifest: '/usr/local/portage/net-misc/xmuruijie/xmuruijie-1.2.ebuild'
!!! A file is not listed in the Manifest: '/usr/local/portage/net-misc/xmuruijie/xmuruijie-1.2.ebuild'

!!! All ebuilds that could satisfy "xmuruijie" have been masked.
!!! One of the following masked packages is required to complete your request:
!!! A file is not listed in the Manifest: '/usr/local/portage/net-misc/xmuruijie/xmuruijie-1.2.ebuild'
- net-misc/xmuruijie-1.3 (masked by: corruption)
!!! A file is not listed in the Manifest: '/usr/local/portage/net-misc/xmuruijie/xmuruijie-1.2.ebuild'
- net-misc/xmuruijie-1.2 (masked by: corruption)
!!! A file is not listed in the Manifest: '/usr/local/portage/net-misc/xmuruijie/xmuruijie-1.2.ebuild'
- net-misc/xmuruijie-1.1 (masked by: corruption)
!!! A file is not listed in the Manifest: '/usr/local/portage/net-misc/xmuruijie/xmuruijie-1.2.ebuild'
- net-misc/xmuruijie-1.2-r1 (masked by: corruption)


另外,
wget -c http://acevery.cnlog.org/upload/portage-xmuruijie.zip
cd /usr/local
tar -xvzf portage-xmuruijie.tar.gz
这段有错吧?下的是zip包,却解压了tar.gz包。

我怀疑是ebuild包有问题,麻烦兄弟检查下,谢谢:)!

>>13 Dear wcw :
嗯,更正了,你再试试看。

现在锐捷升级到3.1版本了,老版本会显示版本过低,有什么新办法解决吗?

加上-x 来运行,用xrgsu-1.1.1的算法。

因为厦大用的是2.56,我没办法做3.1的测试,所以加了xrgsu-1.1.1的算法,你试试看。

校园网锐捷认证 ubuntu 6.06
XRGSupplicant 1.1.1
RuiJie Network CopyRight 2004
Please input your user name:jchenhua
Please input your password:
Use DHCP,1-Use,0-UnUse(Default: 0):
Use default auth parameter,0-Use 1-UnUse(Default: 0):
Searching server...
Connecting server...
Searching server...
Connecting server...
Searching server...
Connecting server...
xrgsu exit!
N次都这样, 认证不上,老是 xrgsu exit !
请问你知道这怎么解决吗? 谢谢

能和我联系吗? 我的QQ :1221780203 。

这是组播地址不对造成的,xrgsu的组播地址可能和你需要的不一样。

也可能是因为xrgsu对第一次的服务器回应不予理睬。

我没有用QQ了,回家刚刚重装完gentoo,这才能拨号:-)

你发电子邮件给我吧:
yu-yuwei@xmu.edu.cn

这个认证程序为什么不增加直接设定静态IP的功能?这样的话在任何linux下都可以使用啦?

这个认证程序为什么不增加直接设定静态IP的功能?这样的话在任何linux下都可以使用啦?

无论是动态还是静态IP,linux下面都有非常成熟的方法,或者软件可以实现。以静态IP为例,ifconfig, iproute2等都能很好地完成,但各个发行版用都有自己网络管理的办法,我不可能去一一了解。如果你用的是Gentoo,那么XMU-Ruijie中的 saier脚本就是用来进行静态IP认证的,做的事情很简单,就是先给网卡IP,netmask再把网关加到路由表中。这些静态IP的设定,在gentoo中是修改/etc/conf.net后,/etc/init.d/net.eth0 start完成的。

如果你用的不是gentoo,那你发行版中的静态IP设定你应该比我更清楚。你把网卡设好静态IP完,认证就是了。

能否讲解一下写这个程序的思路?可以email我。谢谢!

源代码都给了,而且有大量注释,有兴趣的话你可以自己看看的。

我们学校是自己写的一个客户端,不过只有WIN下的,不知道鱼大侠可否帮忙分析一下我们学校的协议?

最近没空啊,要考GRE的作文呢,而且协议部分主要是从mentoo supplicant中来的,我只是修正一下,要能彻底分析,得学汇编后才能做到。

发表评论

最新日记

cups-1.3.10的打印机问题
前天cups从1.3.9升级到了1.3.…
一个HSV到HTML RGB的颜色脚本
地球人都知道,用HSV模型定义渐近的颜色…
厦大的芙蓉湖
最近突然总想在芙蓉湖边上晃晃。看着湖边的…