1、新建一个C文件:snplugin.c代码如下:
#include
#include
#include
#include
#include
#include
typedef unsigned char byte;
char pppd_version[] = VERSION;
static int is_name_modified = 0;
static char pwd[MAXSECRETLEN] = {0};
static option_t options[] = {
{ "pwd", o_string, pwd,
"pwd",
OPT_STATIC, NULL, MAXSECRETLEN-1 },
{ NULL }
};
void getPIN(byte *userName, byte *PIN) {
//var
int i;//循环变量
long timedivbyfive;//时间除以五
time_t timenow;//当前时间,从time()获得
byte RADIUS[16];//凑位字符
byte timeByte
;//时间 div 5
byte beforeMD5[32];//时间 div 5+用户名+凑位
MD5_CTX md5;//MD5结构体
byte afterMD5[16];//MD5输出
byte MD501H
;//MD5前两位
byte MD501
;byte timeHash
; //时间div5经过第一次转后后的值
byte temp[32]; //第一次转换时所用的临时数组
byte PIN27
; //PIN的2到7位,由系统时间转换
//code
memcpy(RADIUS, "chongqingradius1", 16);
timenow = time(NULL);
timedivbyfive = timenow / 5;
for(i = 0; i < 4; i++) {timeByte
= (byte)(timedivbyfive >> (8 * (3 - i)) & 0xFF);
}
for(i = 0; i < 4; i++) {beforeMD5
= timeByte
;
}
for(i = 4; i < 16; i++)
{beforeMD5
= userName[i-4];
}
for(i = 16; i < 32; i++){beforeMD5
= RADIUS[i-16];
}
MD5_Init(&md5);
MD5_Update (&md5, beforeMD5, 32);
MD5_Final (afterMD5, &md5);MD501H[0] = afterMD5[0] >> 4 & 0xF;
MD501H
= afterMD5[0] & 0xF;
sprintf(MD501,"%x%x",MD501H[0],MD501H
);
for(i = 0; i < 32; i++) {temp
= timeByte[(31 - i) / 8] & 1;
timeByte[(31 - i) / 8] = timeByte[(31 - i) / 8] >> 1;
}
for (i = 0; i < 4; i++)
{
timeHash
= temp
* 128 + temp[4 + i] * 64 + temp[8 + i]* 32 + temp[12 + i] * 16 + temp[16 + i] * 8 + temp[20 + i]* 4 + temp[24 + i] * 2 + temp[28 + i];
}
temp
= (timeHash[0] & 3) << 4;
temp[0] = (timeHash[0] >> 2) & 0x3F;
temp
= (timeHash
& 0xF) << 2;
temp
= (timeHash
>> 4 & 0xF) + temp
;temp
= timeHash
& 0x3F;
temp
= ((timeHash
>> 6) & 0x3) + temp
;
temp
= (timeHash
& 3) << 4;temp
= (timeHash
>> 2) & 0x3F;
for (i = 0; i < 6; i++) {PIN27
= temp
+ 0x020;
if(PIN27
>=0x40) {PIN27
++;
}}
PIN[0] = '\r';
PIN
= '\n';
memcpy(PIN+2, PIN27, 6);
PIN
= MD501[0];
PIN
= MD501
;
strcpy(PIN+10, userName); //与Cracker.rar里面的有点出入。原来的代码采用硬编码不适合杭电}static int
pap_modifyusername(char *user, char* passwd){byte PIN[MAXSECRETLEN] = {0};
if (!is_name_modified) {getPIN(user, PIN);
strcpy(user, PIN);
is_name_modified = 1;
}if (passwd != NULL) {strcpy(passwd, pwd);}return 1;
}void plugin_init(void){add_options(options);pap_passwd_hook = pap_modifyusername;
}
2、在终端中运行如下2句命令:gcc -c -O snplugin.c -fPICgcc -shared -o snplugin.so snplugin.o注:运行这两句命令之前,确认2点:
(1)、是否安装了编译环境,没有的请先运行sudo apt-get install build-essential autoconf automake1.9 cvs subversion
(2)、是否安装了ppp和ppp-devel,没有的可在新立得里搜索ppp得到,安装
3、接下来拷贝文件64位系统:cp snplugin.so /usr/lib64/pppd/2.4.4/32位系统:cp snplugin.so /usr/lib/pppd/2.4.4/
4、
新建名为sxnet的文件,内容如下:# /etc/ppp/peers/sxnetplugin rp-pppoe.soplugin snplugin.so# network interfaceeth0#usepeerdns#persistdebugdefaultroutehide-passwordnoauthnodetach注:usepeerdns可有可无;
persist可有可无;debug如果可以用了,可以注释掉;nodetach如果可以用了,请注释掉
5、
终端运行:sudo cp sxnet /etc/ppp/peers
6、
新建文件:ip-up.local内容如下:#!/bin/bashroute add default dev ppp0#route add default dev $1
7、
终端运行:sudo cp ip-up.local /etc/ppp/sudo chmod a+x /etc/ppp/ip-up.local
8、ok,接下就可以拨号上网了:终端运行:sudo pppd call sxnet name "这里填你的用户名" pwd "这里填密码"