突破网关限制上qq
qq用的是udp协议,如果是网关上把源端口是4000的udp包丢弃实现封闭qq的话,解决很简单我们改qq的端口,怎么改呢?直接很麻烦的,我们可以间接改。qq默认4000如果4000被占的话,他就会用4001依次类推。因此在我们启动qq前先把udp4000-4019断口都占掉,那么qq启动的时候就会使用4020了,下面是程序原代码:
#include <stdio.h>
#include <conio.h>
#include <winsock2.h>
#define MaxNum 20
#pragma comment(lib,"ws2_32.lib")
void ShowError(char *);
int main(int argc,char **argv)
{
WSADATA wsd;
int iRet,i,j=0,
iStart=4000,iEnd=4019;//默认占用UDP 4000-4019的端口
SOCKET s[MaxNum];
struct sockaddr_in addr;
//也可以让用户提供参数
if(argc==3)
{
iStart=atoi(argv[1]);
iEnd=atoi(argv[2]);
}
else if(argc!=1)
{
printf("\nUsage:%s <UDPStartPort> <ENDPort>",argv[0]);
return 1;
}
__try
{
//load winsock library
iRet=WSAStartup(MAKEWORD(1,1),&wsd);
if(iRet!=0)
{
ShowError("WSAStartup");
__leave;
}
addr.sin_family=AF_INET;
addr.sin_addr.s_addr=INADDR_ANY;
for(i=iStart;i<=iEnd;i++,j++)
{
if(j>=MaxNum)
break;
//创建一个UDP Socket
s[j]=socket(AF_INET,SOCK_DGRAM,IPPROTO_UDP);
if(s[j]==INVALID_SOCKET)
{
ShowError("\nCreate UDP Socket");
__leave;
}
addr.sin_port=htons(i);
//bind udp socket
iRet=bind(s[j],(struct sockaddr *)&addr,sizeof(addr));
if(iRet==SOCKET_ERROR)
{
printf("\nBind UDP port %d failed.",i);
continue;
}
else
printf("\nBind UDP port %d ok.",i);
}
printf("\nPress any key to exit.");
getch();
}
__finally
{
for(j=0;j<MaxNum;j++)
closesocket(s[j]);
WSACleanup();
}
return 0;
}
void ShowError(char *msg)
{
printf("\n%s failed:%d.",GetLastError());
}
如果网管把全部的udp数据包都丢弃的话,这招就失灵了。那么就用第2招:通过tcp和udp socket数据转发突破限制。你可以到http://eyas.3322.net下载一个SuperAgent.exe ;而且我们需要一台肉鸡协助。假设肉鸡ip是202.202.202.202,网关是101.101.101.101自己的是202.104.129.253,监听的是udp8000端口。
我们先用肉鸡运行superagent:
c:\superagent -u 202.104.129.253 8000 4000 1234
OK! Work mode is
Listen TCP 127.0.0.1:1234 ok!
*****OK!SuperAgent working now*****
Wait for ey4s connect to me ……:)
然后在本地运行:
c:\superagent.exe -t 202.202.202.202 1234 8000
OK!Work mode is [t]
*****OK!SuperAgent working now*****
Bind UDP port 8000 ok
Wait for UDP Socket have data to be reev.
再启动qq,把服务器地址设成127.0.0.1 端口为8000,上线。