以前一直用wine装的网通插件,就是装好后运行ishare_user.exe的那个。最近插件突然不能用了,重装老是在装winpcap那儿报错,没办法,就google了另一个方法。
(不知道怎么发附件,只好贴源代码了……)
1.copy下面的源代码,保存成drcom.c(名字其实无所谓)
#include <stdio.h>
#include <string.h>
#include <arpa/inet.h>
#include <sys/socket.h>
#include <sys/ioctl.h>
#include <net/if.h>
typedef struct _code2 {
char sign;
char type;
short len;
int id;
int code0;
int code1;
}code2;
typedef struct _code3 {
char sign;
char type;
short len;
int id;
int unk0;
int code1;
int unk1;
int code0;
int check;
int unk2;
char mac[6];
char dhcp;
char devtype;
int ipaddr;
int netmask;
char padding[48];
}code3;
int waitdata(int hsocket, int time)
{
fd_set fds;
struct timeval tv;
FD_ZERO(&fds);
FD_SET(hsocket,&fds);
tv.tv_usec = time;
tv.tv_sec = 0;
return select(hsocket+1,&fds,NULL,NULL,&tv);
}
main (int argc, char* argv[])
{
struct in_addr ip,netmask,ptp;
char mac[6];
int hsocket;
struct ifreq ifr;
struct sockaddr_in sin;
struct sockaddr *sa = (struct sockaddr *) &sin;
int fromlen;
struct sockaddr_in *sin_ptr;
u_char *ptr;
u_long *ptr_long;
int n;
int check;
char c1[] = {7,1,8,0,1,0,0,0};
code2 c2;
code3 c3;
char c4[512];
int sendlen, recvlen;
int errorcount,workwell,noticed=0;
printf(“\nFree Dr.COM for Linux v0.3\n mengxp works,2009 @ xiyou\n http://www.deadc0de.com/\n\n”);
init:
if ((hsocket = socket(AF_INET, SOCK_DGRAM, 0)) < 0)
{
perror( “socket error!”);
return 0;
}
errorcount = 0;
strcpy(ifr.ifr_name, “ppp0”);
if (ioctl(hsocket, SIOCGIFADDR, &ifr) < 0)
{
// perror(“ioctl SIOCGIFADDR error”);
errorcount++;
}
sin_ptr = (struct sockaddr_in *)&ifr.ifr_addr;
ip = sin_ptr->sin_addr;
if (ioctl(hsocket, SIOCGIFNETMASK, &ifr) < 0)
{
// perror(“ioctl SIOCGIFNETMASK error”);
errorcount++;
}
sin_ptr = (struct sockaddr_in *)&ifr.ifr_addr;
netmask = sin_ptr->sin_addr;
if (ioctl(hsocket, SIOCGIFDSTADDR, &ifr) < 0)
{
// perror(“ioctl SIOCGIFDSTADDR error”);
errorcount++;
}
sin_ptr = (struct sockaddr_in *)&ifr.ifr_addr;
ptp = sin_ptr->sin_addr;
memset(&mac,0,6);
if(errorcount)
{
close(hsocket);
if(!noticed)
printf(“couldn’t get ppp0 interface!\nplease check your connection!\n\n”);
noticed++;
sleep(3);
goto init;
}
else
noticed = 0;
printf(“ppp0 interface:\n”);
printf(” IP: %s\n”, inet_ntoa(ip));
printf(” NetMask: %s\n”, inet_ntoa(netmask));
printf(” Server: %s\n\n”, inet_ntoa(ptp));
sin.sin_addr = ip;
sin.sin_port = htons(61440);
sin.sin_family = AF_INET;
if ((bind(hsocket,sa,sizeof(sin))) < 0)
{
printf( “can’t bind udp port 61440!\n”);
return 0;
}
sin.sin_addr = ptp;
printf(“Activating connection…\n”);
workwell = 0;
keepalive:
errorcount = 0;
while(1)
{
sendlen = sendto(hsocket,&c1,8,MSG_NOSIGNAL,sa,sizeof(sin));
if(sendlen < 0 || errorcount >= 5)
{
printf(“socket error! reinit…\n”);
close(hsocket);
goto init;
}
if(waitdata(hsocket,1000*1000))
{
fromlen = sizeof(sin);
recvlen = recvfrom(hsocket,&c2,sizeof(c2),0,sa,&fromlen);
ip = sin.sin_addr;
break;
}
else
{
errorcount++;
printf(“recv2 timed out\n”);
}
}
memset(&c3,0,96);
c3.sign = 7;
c3.len = 96;
c3.id = 3;
c3.code1 = c2.code1;
c3.unk1 = 0x2000200;
c3.code0 = c2.code0;
c3.check = 0x1312fc7;
c3.unk2 = 0x7e;
memcpy(&c3.mac,&mac,6);
c3.devtype = 0x17;
memcpy(&c3.ipaddr,&ip,4);
memcpy(&c3.netmask,&netmask,4);
ptr_long = (u_long *)&c3;
for(n=0,check=0;n<96/4;n++)
check ^= *(ptr_long + n);
c3.check = check * 0x12C4B7E;
c3.unk2 = 0;
ptr = (u_char *)&c3.mac;
for(n=0;n<64;n++)
*(ptr + n) = (*(ptr + n) >> 8 – (n & 7)) + (*(ptr + n) << (n & 7));
sendlen = sendto(hsocket,&c3,96,MSG_NOSIGNAL,sa,sizeof(sin));
if(sendlen < 0 || errorcount >= 5)
{
printf(“socket error! reinit…\n”);
close(hsocket);
goto init;
}
if(waitdata(hsocket,1000*1000))
{
fromlen = sizeof(sin);
recvlen = recvfrom(hsocket,&c2,sizeof(c2),0,sa,&fromlen);
if(!workwell)
{
printf(“Keeping connection active…\n”);
workwell++;
}
}
else
{
printf(“recv4 timed out\n”);
sleep(1);
goto keepalive;
}
sleep(15);
goto keepalive;
return 0;
}
2.在终端里到drcom.c目录下,运行gcc drcom.c -o drcom.(如果没装gcc的话,先sudo apt-get install gcc)
3.运行drcom就好了。
要是嫌每次开机都要运行比较麻烦,可以添加到开机启动:
系统->首选项->启动应用程序->添加,然后把drcom加进去就OK了。
西邮的网通这样可以,其他地方的不一定。