LinuxSir.cn,穿越时空的Linuxsir!

 找回密码
 注册
搜索
热搜: shell linux mysql
楼主: gnap

在锐捷802.1x网络中使用xsupplicant的补丁进行认证源代码和教程 [原创]

[复制链接]
发表于 2006-5-27 12:12:29 | 显示全部楼层
[STATE] Reinit state machine
[INT] Clearing keys!
[INT] Initializing socket for interface eth0..
[INT] Allmulti mode is already enabled on this device!
[INT] WPA: Enabling WPA on interface eth0.
[INT] Interface eth0 is NOT wireless!
[INT] Interface initialized!
[INT] Interface eth0 is NOT wireless!
[CONFIG] Working from config file /etc/xsupplicant.conf.
No configuration information for network "(null)" found.  Using default.
[INT] Opened socket descriptor #4
An error occured binding to socket.  (Error : Address already in use)
!Couldn't initalize daemon socket!
[ALL] Shutting down IPC socket!
[INT] Closing socket descriptor #4
Error closing socket!  (Error : Bad file descriptor)
[ALL] Doing statemachine cleanup!
[AUTH TYPE] There was no active method in eap_cleanup()!
[INT] Sending Logoff for int eth0!
[ALL] Cleaning up interface eth0...
[INT] Called event_core_cleanup()!
[INT] Called cardif_linux_rtnetlink_cleanup()!
AAAH! Trying to delete an undefined config type.
Notify developers. Type: 0x12
AAAH! Trying to delete an undefined config type.
Notify developers. Type: 0x17
回复 支持 反对

使用道具 举报

 楼主| 发表于 2006-5-27 12:29:41 | 显示全部楼层
Post by barry262
[STATE] Reinit state machine
[INT] Clearing keys!
[INT] Initializing socket for interface eth0..
[INT] Allmulti mode is already enabled on this device!
[INT] WPA: Enabling WPA on interface eth0.
[INT] Interface eth0 is NOT wireless!
[INT] Interface initialized!
[INT] Interface eth0 is NOT wireless!
[CONFIG] Working from config file /etc/xsupplicant.conf.
No configuration information for network "(null)" found.  Using default.
[INT] Opened socket descriptor #4
An error occured binding to socket.  (Error : Address already in use)
!Couldn't initalize daemon socket!
[ALL] Shutting down IPC socket!
[INT] Closing socket descriptor #4
Error closing socket!  (Error : Bad file descriptor)
[ALL] Doing statemachine cleanup!
[AUTH TYPE] There was no active method in eap_cleanup()!
[INT] Sending Logoff for int eth0!
[ALL] Cleaning up interface eth0...
[INT] Called event_core_cleanup()!
[INT] Called cardif_linux_rtnetlink_cleanup()!
AAAH! Trying to delete an undefined config type.
Notify developers. Type: 0x12
AAAH! Trying to delete an undefined config type.
Notify developers. Type: 0x17

你的也是笔记本吧?在/etc/xsupplicant.conf里面找到一行:
  #type = wireless
去掉注释改成:
type=wired
试试。
回复 支持 反对

使用道具 举报

发表于 2006-5-27 12:37:05 | 显示全部楼层
楼主 给我看看阿
帮一下忙啦 ???
我这个怎么解决阿
回复 支持 反对

使用道具 举报

 楼主| 发表于 2006-5-27 14:26:00 | 显示全部楼层
Post by imsaint
楼主 给我看看阿
帮一下忙啦 ???
我这个怎么解决阿


windump的用法找找教程吧!可以百度到很多。
回复 支持 反对

使用道具 举报

发表于 2006-6-22 09:30:53 | 显示全部楼层
Making all in src
make[1]: Entering directory `/root/xsupplicant-1.2.1/src'
gcc -DPACKAGE_NAME=\"\" -DPACKAGE_TARNAME=\"\" -DPACKAGE_VERSION=\"\" -DPACKAGE_STRING=\"\" -DPACKAGE_BUGREPORT=\"\" -DPACKAGE=\"xsupplicant\" -DVERSION=\"1.2.1\" -DYYTEXT_POINTER=1 -DLILENDIAN=1 -DSTDC_HEADERS=1 -DHAVE_SYS_TYPES_H=1 -DHAVE_SYS_STAT_H=1 -DHAVE_STDLIB_H=1 -DHAVE_STRING_H=1 -DHAVE_MEMORY_H=1 -DHAVE_STRINGS_H=1 -DHAVE_INTTYPES_H=1 -DHAVE_STDINT_H=1 -DHAVE_UNISTD_H=1 -DNO_PWD_RESET=1 -DOPENSSL_NO_KRB5=1 -DLINUX=1 -DHAVE_LIBCRYPTO=1 -DHAVE_LIBSSL=1 -DLINUX_FRAMER=1   -I. -I.     -g -O2 -Wall  -c config.c
In file included from config.c:49:
eap_types/tls/eaptls.h:35: parse error before "ENGINE"
eap_types/tls/eaptls.h:35: warning: no semicolon at end of struct or union
eap_types/tls/eaptls.h:66: parse error before '}' token
make[1]: *** [config.o] Error 1
make[1]: Leaving directory `/root/xsupplicant-1.2.1/src'
make: *** [all-recursive] Error 1
楼主帮我看看吧,咱们一个学校的!我也是南区南苑的!红旗4.0桌面版中编译时出现这样错误是怎么回事?谢谢了!
回复 支持 反对

使用道具 举报

发表于 2006-7-12 00:40:49 | 显示全部楼层

linux下 锐捷2.5解决方法

Post by gnap
用#/usr/local/sbin/xsupplicant -i eth0 -d A
然后把/var/log/xsupplicant.log帖上来吧!

另外,执行dhclient之前也请确认之前dhclient已经运行,dhclient只能运行一次。



感谢gnap的工作,使得锐捷的用户可以在linux下上网,但是锐捷2.5改了些东西,使得gnap的改进不能完成2.5的认证。我在gnap的xsupplicant-1.2.1-rj-20060411.patch补丁基础上小改后可以在FC5下完成对锐捷2.5的认证工作。但是不稳定,大概一个小时就断一会,不知道为什么,还请gnap指教。改动如下:

文件src/statemachine.c
649行
/*********************************************
*
* Build an EAPoL Start frame to be sent out to the network.
*
*********************************************/
int txStart(struct interface_data *thisint)
{
//  unsigned char rg_start[] = {0x01, 0x00, 0x00, 0x05, 0x01, 0x01, 0x00, 0x05, 0x01, 0x00};

  int eapolver;
  struct config_network *network_data;

  network_data = config_get_network_config();

  ///////////此函数仅仅增加下面一行///////
  network_data->force_eapol_ver = 1;
  ///////////////////////////////////////

  // If we are using WPA-PSK, don't send starts.
  if (network_data->methods->method_num == WPA_PSK) return XENONE;

  debug_printf(DEBUG_STATE, "Sending EAPOL-Start Frame.\n");

  eapolver = network_data->force_eapol_ver;
  // If we have not hard set the eapol version, then use the last
  // version that the authenticator gave us.  This isn't in line with
  // the 802.1X-REV-2004-d11 standard, but many authenticators are checking
  // version #s, and breaking when it isn't 1. :-/
  if ((eapolver < 1) || (eapolver > MAX_EAPOL_VER))
    {
      eapolver = snmp_get_dot1xSuppLastEapolFrameVersion();

      if (eapolver == 0)
        {
          eapolver = MAX_EAPOL_VER;
        }
    }


  eapol_build_header(EAPOL_START, 0, network_data->force_eapol_ver,
                     thisint->sendframe);
  thisint->send_size = OFFSET_TO_EAP;


  append_rgtail(thisint);
  snmp_dot1xSuppEapolStartFramesTx();

  cardif_sendframe(thisint);

  return XENONE;
}
文件的./src/eap.c
254行
/*************************************************
*
* Append Red Gaint tail to each response data,
* This fuction is not completely implemented,
* but it works in our colledge.Future inhancement
* should be made for compactability.
*                                   by  gnap.an
*
*************************************************/

void append_rgtail(struct interface_data *thisint)
{
          /*uint8_t rgsig[] = {0xff, 0xff, 0x37, 0x77, 0x7f, 0xff, 0xff, 0xff, 0xff, 0x00, 0x00, 0x80, 0xff, 0xfc, 0xea, 0x39, 0x80, 0xaf, 0xaf, 0xaf, 0xc0, 0xde, 0x8f, 0x00, 0x00, 0x13, 0x11, 0x38, 0x30, 0x32, 0x31, 0x78, 0x2e, 0x65, 0x78, 0x65, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0x2c, 0x00};
#define RGSIGLEN 0x3e*/

        /*
        * 仅仅替换rgsig数组和RGSIGLEN宏
        */

   uint8_t rgsig[]={0xff,0xff,0x37,0x77,0xff,0x23,0xfd,0xf9,0xc5,0x00,0x00,0x00,
   0xff,0x23,0xfd,0xf9,0x80,0xac,0x4c,0xf4,0x9f,0x3c,0x39,0x00,0x00,0x13,0x11,0x38,
   0x30,0x32,0x31,0x78,0x2e,0x65,0x78,0x65,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
   0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x02,
   0x32,0x00,0x00,0x00,0x00,0x00,0x13,0x11,0x00,0x28,0x1a,0x28,0x00,0x00,0x13,0x11,
   0x17,0x22};
   #define RGSIGLEN 0x4e

            memcpy(&thisint->sendframe[thisint->send_size], rgsig, RGSIGLEN);
              thisint->send_size += RGSIGLEN;
}
回复 支持 反对

使用道具 举报

发表于 2006-7-15 02:21:50 | 显示全部楼层
研究下Windows下的认证程序下的客户端,原来是在标准802.1x的数据包后加入了以下数据:

/////////////////////////////////////////////////////////////////////////////////////

static byte RuijieExtra[144] = { //Ruijie OEM Extra  by soar @ http://bbs.53ucity.com/
        ////////////////////////////////////////////////////////////////////////////
        //
        // OEM Extra
        // 0 --> 22
                0x00,0x00,0x13,0x11,            // Encode( 0x00,0x00,0x13,0x11 )   Ruijie OEM Mark
        0x01,                           // Encode( 0x01/00 )
        0x00,0x00,0x00,0x00,            // Encode( IP )
        0x00,0x00,0x00,0x00,            // Encode( SubNetMask )
        0x00,0x00,0x00,0x00,            // Encode( NetGate )
        0x00,0x00,0x00,0x00,            // Encode( DNS )
        0x00,0x00,                      // Checksum( )
        // 23 --> 58
        0x00,0x00,0x13,0x11,0x38,0x30,0x32,0x31,0x78,0x2E,0x65,0x78,0x65,0x00,0x00,0x00,    // ASCII 8021x.exe
        0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,    //
        0x00,0x00,0x00,0x00,
        // 59 --> 77
        0x02,0x32,0x00,0x00,            // 8021x.exe File Version (2.5.00)
        0x00,                           // unknow flag
        0x00,0x00,0x13,0x11,0x00,0x28,0x1A,0x28,0x00,0x00,0x13,0x11,0x17,0x22,                    // Const strings
        // 78 --> 118
                0x00,0x01,0x02,0x03,0x04,0x05,0x06,0x07,0x08,0x09,0x0A,0x0B,0x0C,0x0D,0x0E,0x0F,        // 32bits spc. Random strings
                0x00,0x01,0x02,0x03,0x04,0x05,0x06,0x07,0x08,0x09,0x0A,0x0B,0x0C,0x0D,0x0E,0x0F,    // 32bits spc. Random strings
        0x00,0x00,0x13,0x11,0x18,0x06,0x00,0x00,0x00,                                       // Const strings
        // 119
        0x00,                           // DHCP and first time flag

        // V2.56 (and upper?) added
        // 120 -->
        //0x1A,0x0E,0x00,0x00,0x13,0x11,0x2D,0x08,                                            // Const strings
        // 128 --> 141
        //0x00,0x00,0x00,0x00,0x00,0x00,                                                      // True NIC MAC
        //0x1A,0x08,0x00,0x00,0x13,0x11,0x2F,0x02                                             // Const strings
   };

/////////////////////////////////////////////////////////////////////////////////////

其中 32 为的随机数在发送用户名和密码时为客户端的验证 MD5 Hash ,关于这 32 位数字的生成方法如下(VC++ MFC):

//
//
///////////////////////////////////////////////////////////////////
//
//

// Ruijie 8021x.exe 客户端验证及其完整性验证(版本 V2.45 /2.50 /2.56 )
//
// 有些变态用了 8 次 MD5 算法检校 0x00401000h --> 0x00421000h 程序段
// (每段长0x4000h),每分段前加入了服务器返回的 MD5 串,最后得到的
// 8组 MD5 Hash 再和服务器返回的 MD5 串做运算生成 0x90h 的表 TableC
// 再作一次 MD5 运算。
//
//////////////////////////////////////////////////////////////////
//
//  严正声明:
//      本算法仅供学习和研究 8021x 认证客户端程序之用,
//      严禁他用,其他用途产生的后果本人一概不以负责 !
//
//                                         -- by soar @ 2006/07/01
//                                        http://bbs.53ucity.com/
//////////////////////////////////////////////////////////////////
//
//

//产生特殊随机字符串
CString CMentoSupplicantDlg::Randstr(bool flag)
{
CString strFormat,strRandom;
int a,b,c,d,e;
unsigned t;

strFormat="%X%X%X%X%X%X9884773d9f46acafd7839eb38789088ac9534";
if (flag){strFormat="%X%X%X%X%X%X388498639f49ebaca773dfd78789088ac9534";}

t=time(NULL);
srand(t);
a=rand();
b=rand();
c=rand();
d=rand();
e=rand();

strRandom.Format(strFormat,a,b,c,d,e,t);
return strRandom;
}

//验证算法
void CMentoSupplicantDlg::Clog()
{
int i,j=0;
int nLength = 0;                                 //number of bytes read from the file
int nBufferSize=0x4000;           //checksum the file in blocks of bytes

CFileVersionInfo  fvi;
CString strRJVersionInfo;

if (fvi.Create(strRJFileN)){
    bool notfindflag=true;
    strRJVersionInfo=fvi.GetFileVersion();
    strRJVersionInfo.Replace(" ","");
    if (strRJVersionInfo.Find("2,45,0,0")==0){
        nBufferSize=0x3E00;
        notfindflag=false;
        //PrintOutput("V2,45,0,0");
        }
    if (strRJVersionInfo.Find("2,50,0,0")==0){
        nBufferSize=0x4000;
        notfindflag=false;
        //PrintOutput("2,50,0,0");
        }
    if (strRJVersionInfo.Find("2,51,0,0")==0){
        nBufferSize=0x4200;
        notfindflag=false;
        //PrintOutput("2,51,0,0");
        }
    if (strRJVersionInfo.Find("2,56,0,0")==0){
        nBufferSize=0x4A00;
        notfindflag=false;
        //PrintOutput("2,56,0,0");
        }
    if (notfindflag){
        PrintOutput("    ** 不支持的Ruijie客户端版本!。");
    }
}

//


BYTE Buffer1[0x5000];                 //buffer for data read from the file
BYTE Buffer2[0x5000];             //buffer for data to MD5 Checksum
BYTE md5rev[16];             //buffer for receive MD5 from the Server
BYTE *md5Dig1,*md5Dig2;
ULONGLONG lActual;

static byte TableC[0x90]={
                0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
        0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
        0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
        0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
        0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
        0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
        0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
        0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
        0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00};

// Authentication Server MD5 Hash
for (i=0;i<16;i++)
    md5rev=bMD5Source[24+i];

// Tranform to TableC
TableC[0]=md5rev[0];
for (i=1;i<8;i++){
     TableC[i*18-1]=md5rev[i*2-1];
     TableC[i*18]=md5rev[i*2];}
TableC[143]=md5rev[15];      

// Check 8021x.exe, Exist ?
if (CFile::GetStatus(strRJFileN,FileStatus)==FALSE){
    //PrintOutput(" >> 无法找到“8021x.exe”!!!");
    //PrintOutput("    请复制到本程序目录下,");
    //PrintOutput("    否则无法生成Ruijie客户端信息。");

    //return a 32 bits Random string
    strMD5Hash=Randstr(false);

    return;
}

// Open the 8021.exe for reading.
CFile File(strRJFileN, CFile::modeRead | CFile::shareDenyWrite | CFile::typeBinary);

try
        {
                //checksum the file in blocks of xxxx bytes
        lActual=File.Seek (0x1000,CFile::begin);
                while ((nLength = File.Read( Buffer1, nBufferSize )) > 0 && j<8)
                {
                       
        for (i=0;i<16;i++){
            Buffer2=md5rev;}
        for (i=0;i<nBufferSize;i++){
            Buffer2[i+16]=Buffer1;}
            
         //Return each block MD5 Hash
         md5Dig1=ComputeHash(Buffer2,nBufferSize+16);
            
         for (i=0;i<16;i++){
                TableC[18*j+i+1]=md5Dig1;}
         j++;

                }//end of while

       // PrintOutput( "MD5_1to8_Done!");
        md5Check=ComputeHash(TableC,144);
        
        //not the best work....
        CString strTemp,strFormat;
        strMD5Hash="";
        for (i=0;i<16;i++){
            if (md5Check) {//if outside
                if (md5Check>0x0f){
                    strFormat="%x";}
                else{
                    strFormat="0%x";}

                strTemp.Format(strFormat,md5Check);
                strMD5Hash=strMD5Hash+strTemp;}
            else{//if outside
                strMD5Hash=strMD5Hash+"00";}//end of if outside
            
         }//end of for
         PrintOutput(" >> Ruijie “8021x.exe” 验证 MD5: ");
         PrintOutput("    "+strMD5Hash);   
                return;
        }//end of try

   //catche Exception error for debug only
        catch (CFileException* e )
        {
        #ifdef _DEBUG
            afxDump << "File could not be opened " << e->m_cause << "\n";
        #endif
                throw e;
        }//end of catch
}//end of fuction

//
//
/////////////////////////////////////////////////////////////////////////
//
//


Windows 下的客户端已经成功通过认证服务器的完整性检查和 Ruijie 发送的数据一致^_^
回复 支持 反对

使用道具 举报

 楼主| 发表于 2006-7-30 01:27:52 | 显示全部楼层
看来我的补丁起到了抛砖引玉的作用。
这样,由于我已经搬出学校住宿,没有了在学校的测试环境。
所以对这个补丁的维护工作可以说没办法进行了。
由于我在一楼的帖子你们不能编辑,几位作者能否另开新帖继续维护这个补丁,这样可以在LZ的位置上更新。我的教程和代码可以按GPL协议直接引用。这个帖子就让它沉下去吧!

首先感谢大家,以及mystar作者的努力。我的补丁相当于把mystar并到了xuspplicant上。

另外希望Linux的认证打在open1x实现的补丁上,Windows下希望大家能帮忙把xsupplicant在cygwin下编译测试。关于xsupplicant的代码架构,欢迎邮件讨论。

gnap.an[AT]gmail.com

总之,希望以后所有的Linux用户都可以一直在锐捷的网络环境下上网。

BTW:soar是Mento Supplicant的作者吧?踏破铁鞋无觅处哦,以前找的你的客户端都是老板本的。似乎百度和Google很难搜索到下载。你的最新代码我会交给我们校内的同学在我们校内测试。谢谢你的工作。

现在我们校内的版本是2.44,我的补丁在校内的用户不超过5个。如果将来我们学校版本升级的话,这几个人上网就要靠大家了。
回复 支持 反对

使用道具 举报

发表于 2006-10-23 20:16:01 | 显示全部楼层
您好,我在http://www.linuxsir.cn/bbs/showt ... 7论坛看到你的
在锐捷802.1x网络中使用xsupplicant的补丁进行认证的源代码和教程+FAQ
我用的是red-hat 9.2 但是老是到patch -p2 < xsupplicant-1.2.1-rj.patch
这里出错误,说是找不到,很是不理解。我知道你在这方面是高手,研究已经很深入了,麻烦你给指点一下,我在red-hat 9.2 怎么设置?
谢谢!
回复 支持 反对

使用道具 举报

您需要登录后才可以回帖 登录 | 注册

本版积分规则

快速回复 返回顶部 返回列表