代理linux平台socks5代理(Socks5 proxy for Linux platform)

socks5代理  时间:2021-03-11  阅读:()

linux平台socks5代理Socks5 proxy for Linux platformA few days ago, MSN couldn't get up. I thought the company hadfirewall restrictions. So this time last year wrote a proxyprogram changed to change, use it out. It turned out that MSNwas because of Microsoft' s problems and despised ah. . . . . .Because the writing is more urgent, this only supports TCP agent,UDP I did not write, because MSN can not use. This code can bemodified and distributed at will, but you'd better give me one.This is the head file:

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

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

/ / Socks5 proxy header file defines the related data packetstructure

/ / version 0. 1, author Yun Shu

//January 9, 2007 at 1 : 15 in the morning, GF home for 11 days.In January 25, 2008 this year, GF/ changes, always beside me,haha

/ /

/ / reference:

/ / http://www.rfc-editor.org/rfc/rfc1928. txt

/ / http://www.rfc-editor.org/rfc/rfc1929. txt

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

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

#ifndef SOCKS5_H

#def ine SOCKS5_H

#def ine VERSION 0x05

#def ine CONNECT 0x01

#def ine IPV4 0x01

#define DOMAIN 0x03

#def ine IPV6 0x04

Typedef struct_method_select_response // negotiation methodof server response

{

Char version; / / server supported versions of Socks, 0x04 or0x05

Char select_method; / / server selection method, 0x00 foranonymous 0x02 password authentication

} METHOD_S ELECT_RES PONSE;

Typedef struct _method_select_request / / server requestconsultation method

{

Char version; / / client support version of 0x04 or 0x05Char number_methods; / / the number of client support methodChar methods[255] ; / / type methods supported by the client,up to 255, 0x00 anonymous 0x02 password authentication} METHOD_S ELECT_REQUES T;

Typedef struct_AUTH_RESPONSE//user password authenticationserver response

{

Char version; / / version, here is 0x01 constant

Char result; / / server authentication results, 0x00 issuccessful, others are failed

} AU TH_RES PON SE;

Typedef struct_AUTH_REQUEST/ /user password authenticationclient request

{

Char version; / / version, here is 0x01 constant

Char name_len; / / the third field name length, a byte, thelength is 0xff

Char name[255] ; / / username

Char pwd_len; / / the fourth field length, a byte, the lengthis 0xff

Char pwd[255] ; / / password

} AUTH_REQUES T;

Typedef struct_SOCKS5_RESPONSE/ / connect host, Socks proxyserver response

{

Char version; / / server supported versions of Socks, 0x04 or0x05

Char reply; //proxy server to connect to host the 0x00 successChar reserved; / / keep constant, 0x00

Char address_type; //Socks proxy server address binding type,IP V4 0x01, IP V6 0x04, the domain name is 0x03

Char address_port[1] ; // if address_type for the domain name,

where the first byte length for the domain name, followed bythe domain name itself, 0 characters at the end, after thedomain name for Socks proxy server port binding

}SOCKS5_RESPONSE;

Typedef struct _SOCKS5_REQUEST / / client request to connectto host

{

Char version;

/ / client support version of Socks, 0x04 or 0x05

Char CMD; //CONNECT cl ient command, 0x01, BIND 0x02, UDP 0x03,is 0x01

Char reserved; / / keep constant, 0x00

Char address_type; / / client requests the real host addresstype, IP V4 0x00, IP V6 0x04, char domain name is 0x03address_port[1] ; // if address_type for the domain name, herethe first byte length of the domain, followed by the domain nameitself, 0 characters at the end, the domain name after the realhost binding port

}SOCKS 5_REQUE ST;

#endif

Here comes the main program:

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

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

/ / Socks5 procedures, only support TCP proxy

/ / version 0. 1, author Yun Shu

//January 9, 2007 at 1 : 15 in the morning, GF home for 11 days.In January 25, 2008 this year, GF/ changes, always beside me,haha

/ /

/ / reference:

/ / http://www.rfc-editor.org/rfc/rfc1928. txt

/ / http://www.rfc-editor.org/rfc/rfc1929. txt

/ / compiler:

-o Socks5 -O2 Socks5.c -lpthread / GCC (RedHat AS5)

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

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

#include <stdio.h>

#include <netinet/in.h>#include <netdb.h>

#include <sys/time.h>#include <sys/types.h>#include <unistd.h>

#include <stdlib.h>

#include <signal.h>

#include <pthread.h>#include <errno.h>

#include <string.h>

#include <sys/socket.h>#include <arpa/inet.h>#include "Socks5.h""#define MAX_USER 10

#define BUFF_SIZE 1024

#def ine AUTH_CODE 0x02

#def ine TIME_OUT 6000000

#def ine USER_NAME "Yunshu""

#def ine PASS_WORD "ph4nt0m""

Auth method / / Select, return 0 if success, -1 if failedInt SelectMethod (int sock)

{

Char recv_buffer[BUFF_SIZE] = {0} ;

Char reply_buffer[2] = {0} ;

METHOD_SELECT_REQUEST *me tho d_reques t;

METHOD_SELECT_RESPONSE *method_response;

R ecv / / METHOD_SELECT_REQUE ST

Int, RET = recv (sock, recv_buffer, BUFF_SIZE, 0) ;

If (RET 0)

{

PERROR ("recv error") ;

Close (sock) ;

Return -1;

}

//printf (SelectMethod: , recv,%d, bytes\n, RET) ;

If client request a wrong version / or a wrong number_methodMethod_request = (METHOD_SELECT_REQUEST *) recv_buf fer;Method_response = (METHOD_SELECT_RESPONSE *) rep ly_buf fer;Method_response->version = VERSION;

Not Socks5 / / if

If ( (int) method_request->version = = VERSION)

{

Method_response->select_method = 0xff;

Send (sock, method_response, s i zeof (METHOD_SELECT_RESPONSE) ,

0) ;

Close (sock) ;

Return -1;

Hostiger发布哥伦布日提供VPS主机首月七折优惠 月费2.79美元

Hostiger商家我们可能以前也是有见过的,以前他们的域名是Hostigger,后来进行微调后包装成现在的。而且推出Columbus Day哥伦布日优惠活动,提供全场的VPS主机首月7折月付2.79美元起的优惠。这里我们普及一下基础知识,Columbus Day ,即为每年10月12日,是一些美洲国家的节日,纪念克里斯托弗·哥伦布在北美登陆,为美国的联邦假日。Hostiger 商家是一个成立于2...

野草云99元/月 ,香港独立服务器 E3-1230v2 16G 30M 299元/月 香港云服务器 4核 8G

野草云月末准备了一些促销,主推独立服务器,也有部分云服务器,价格比较有性价比,佣金是10%循环,如果有时间请帮我们推推,感谢!公司名:LucidaCloud Limited官方网站:https://www.yecaoyun.com/香港独立服务器:CPU型号内存硬盘带宽价格购买地址E3-1230v216G240GB SSD或1TB 企盘30M299元/月点击购买E5-265016G240GB SS...

Virmach($7.2/年)特价机器发放

在八月份的时候有分享到 Virmach 暑期的促销活动有低至年付12美元的便宜VPS主机,这不开学季商家又发布五款年付VPS主机方案,而且是有可以选择七个数据中心。如果我们有需要低价年付便宜VPS主机的可以选择,且最低年付7.2美元(这款目前已经缺货)。这里需要注意的,这次发布的几款便宜年付方案,会在2021年9月30日或者2022年4月39日,分两个时间段会将INTEL CPU迁移至AMD CP...

socks5代理为你推荐
外挂购买空闲很多,想找个挂金打金的游戏,哪位朋友能给点建议啊?seo优化工具想找一个效果好的SEO优化软件使用,在网上找了几款不知道哪款好,想请大家帮忙出主意,用浙江哪款软件效果好www.522av.com在白虎网站bhwz.com看电影要安装什么播放器?www.119mm.comwww.993mm+com精品集!avtt4.comwww.5c5c.com怎么进入www.bbb551.combbb是什么意思kb123.net连网方式:wap和net到底有什么不一样的www.123qqxx.com我的首页http://www.hao123.com被改成了http://www.669dh.cn/?yhcwww.ijinshan.com桌面上多了一个IE图标,打开后就链接到009dh.com这个网站,这个图标怎么删掉啊?b.faloo.com那有能看完整小说的在线阅读手机网站(我看得都是有删节的,内容勉强连贯)
域名信息查询 未注册域名查询 最便宜的vps 双线vps 抗投诉vps主机 免费主机 镇江联通宽带 500m空间 好看qq空间 阿里云浏览器 ftp教程 cdn加速原理 卡巴斯基免费试用 电信主机 paypal注册教程 cxz 申请免费空间 lamp怎么读 免费蓝钻 ssl加速 更多