ubuntu下 登陆电信“闪讯”的方法

1、新建一个C文件:snplugin.c

  1. #include <stdio.h>
  2. #include <stdlib.h>
  3. #include <time.h>
  4. #include <string.h>
  5. #include <pppd/pppd.h>
  6. #include <pppd/md5.h>
  7. typedef unsigned char byte;
  8. char pppd_version[] = VERSION;
  9. static int is_name_modified = 0;
  10. static char pwd[MAXSECRETLEN] = {0};
  11. static option_t options[] = {
  12. "pwd", o_string, pwd,
  13.    "pwd",
  14.    OPT_STATIC, NULL, MAXSECRETLEN-1 },
  15. { NULL }
  16. };
  17. void getPIN(byte *userName, byte *PIN) {
  18. //var
  19. int i;//循环变量
  20. long timedivbyfive;//时间除以五
  21. time_t timenow;//当前时间,从time()获得
  22. byte RADIUS[16];//凑位字符
  23. byte timeByte[4];//时间 div 5
  24. byte beforeMD5[32];//时间 div 5+用户名+凑位
  25. MD5_CTX md5;//MD5结构体
  26. byte afterMD5[16];//MD5输出
  27. byte MD501H[2]; //MD5前两位
  28. byte MD501[3];
  29. byte timeHash[4]; //时间div5经过第一次转后后的值
  30. byte temp[32]; //第一次转换时所用的临时数组
  31. byte PIN27[6]; //PIN的2到7位,由系统时间转换
  32. //code
  33. memcpy(RADIUS, "chongqingradius1", 16);
  34. timenow = time(NULL);
  35. timedivbyfive = timenow / 5;
  36. for(i = 0; i < 4; i++)   {
  37. timeByte[i] = (byte)(timedivbyfive >> (8 * (3 - i)) & 0xFF);
  38. }
  39. for(i = 0; i < 4; i++)   {
  40. beforeMD5[i]= timeByte[i];
  41. }
  42. for(i = 4; i < 16; i++) {
  43. beforeMD5[i] = userName[i-4];
  44. }
  45. for(i = 16; i < 32; i++){
  46. beforeMD5[i] = RADIUS[i-16];
  47. }
  48. MD5_Init(&md5);
  49. MD5_Update (&md5, beforeMD5, 32);
  50. MD5_Final (afterMD5, &md5);
  51. MD501H[0] = afterMD5[0] >> 4 & 0xF;
  52. MD501H[1] = afterMD5[0] & 0xF;
  53. sprintf(MD501,"%x%x",MD501H[0],MD501H[1]);
  54. for(i = 0; i < 32; i++)   {
  55. temp[i] = timeByte[(31 - i) / 8] & 1;
  56. timeByte[(31 - i) / 8] = timeByte[(31 - i) / 8] >> 1;
  57. }
  58. for (i = 0; i < 4; i++)   {
  59. timeHash[i] = temp[i] * 128 + temp[4 + i] * 64 + temp[8 + i]
  60. * 32 + temp[12 + i] * 16 + temp[16 + i] * 8 + temp[20 + i]
  61. * 4 + temp[24 + i] * 2 + temp[28 + i];
  62. }
  63. temp[1] = (timeHash[0] & 3) << 4;
  64. temp[0] = (timeHash[0] >> 2) & 0x3F;
  65. temp[2] = (timeHash[1] & 0xF) << 2;
  66. temp[1] = (timeHash[1] >> 4 & 0xF) + temp[1];
  67. temp[3] = timeHash[2] & 0x3F;
  68. temp[2] = ((timeHash[2] >> 6) & 0x3) + temp[2];
  69. temp[5] = (timeHash[3] & 3) << 4;
  70. temp[4] = (timeHash[3] >> 2) & 0x3F;
  71. for (i = 0; i < 6; i++)   {
  72. PIN27[i] = temp[i] + 0x020;
  73. if(PIN27[i]>=0x40) {
  74. PIN27[i]++;
  75. }
  76. }
  77. PIN[0] = '/r';
  78. PIN[1] = '/n';
  79. memcpy(PIN+2, PIN27, 6);
  80. PIN[8] = MD501[0];
  81. PIN[9] = MD501[1];
  82. strcpy(PIN+10, userName); //与Cracker.rar里面的有点出入。原来的代码采用硬编码不适合杭电
  83. }
  84. static int pap_modifyusername(char *user, char* passwd)
  85. {
  86.        byte PIN[MAXSECRETLEN] = {0};
  87. if (!is_name_modified) {
  88.    getPIN(user, PIN);
  89.    strcpy(user, PIN);
  90.    is_name_modified = 1;
  91. }
  92. if (passwd != NULL) {
  93.    strcpy(passwd, pwd);
  94. }
  95. return 1;
  96. }
  97. void plugin_init(void)
  98. {
  99. add_options(options);
  100. pap_passwd_hook = pap_modifyusername;
  101. }

2、在终端中运行如下2句命令:

  1. gcc -c -O snplugin.c -fPIC
  2. gcc -shared -o snplugin.so snplugin.

注:运行这两句命令之前,确认2点:

    (1)、是否安装了编译环境,没有的请先运行

  1. sudo apt-get install build-essential autoconf automake1.9 cvs subversion

(2)、是否安装了ppp和ppp-devel,没有的可在新立得里搜索ppp得到,安装

 

3、接下来拷贝文件

64位系统:

  1. cp snplugin.so /usr/lib64/pppd/2.4.4/

 

32位系统:

  1. cp snplugin.so /usr/lib/pppd/2.4.4/

4、新建名为sxnet的文件,内容如下:

  1. # /etc/ppp/peers/sxnet
  2. plugin rp-pppoe.so
  3. plugin snplugin.so
  4. # network interface
  5. eth0
  6. #usepeerdns
  7. #persist
  8. debug
  9. defaultroute
  10. hide-password
  11. noauth
  12. nodetach

注:usepeerdns可有可无;persist可有可无;debug如果可以用了,可以注释掉;nodetach如果可以用了,请注释掉

 

5、终端运行:

  1. sudo cp sxnet /etc/ppp/peers
  2. sudo route add default dev ppp0

6、新建文件:ip-up.local内容如下

  1. #!/bin/bash
  2. route add default dev ppp0
  3. #route add default dev $1

7、终端运行:

  1. sudo cp ip-up.local /etc/ppp/
  2. sudo chmod a+x /etc/ppp/ip-up.local

 

8、ok,接下就可以拨号上网了:

 

终端运行:

  1. sudo pppd call sxnet name "这里填你的用户名" pwd "这里填密码"

 

以上方法已经在杭州电子大学测试成功

 

评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值