代理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;

vpsdime:VPS内存/2核/VPS,4G内存/2核/50gSSD/2T流量/达拉斯机房达拉斯机房,新产品系列-Windows VPS

vpsdime上了新产品系列-Windows VPS,配置依旧很高但是价格依旧是走低端线路。或许vpsdime的母公司Nodisto IT想把核心产品集中到vpsdime上吧,当然这只是站长个人的猜测,毕竟winity.io也是专业卖Windows vps的,而且也是他们自己的品牌。vpsdime是一家新上来不久的奇葩VPS提供商,实际是和backupspy以及crowncloud等都是同一家公司...

Hostodo(年付12美元)斯波坎VPS六六折,美国西海岸机房

Hostodo是一家成立于2014年的国外VPS主机商,现在主要提供基于KVM架构的VPS主机,美国三个地区机房:拉斯维加斯、迈阿密和斯波坎,采用NVMe或者SSD磁盘,支持支付宝、PayPal、加密货币等付款方式。商家最近对于上架不久的斯波坎机房SSD硬盘VPS主机提供66折优惠码,适用于1GB或者以上内存套餐年付,最低每年12美元起。下面列出几款套餐配置信息。CPU:1core内存:256MB...

欧路云(22元/月),美国CERA弹性云服务器!香港弹性云服务器15元/月起;加拿大高防vps仅23元/月起

欧路云怎么样?欧路云主要运行弹性云服务器,可自由定制配置,可选加拿大的480G超高防系列,也可以选择美国(200G高防)系列,也有速度直逼内地的香港CN2系列。所有配置都可以在下单的时候自行根据项目 需求来定制自由升级降级 (降级按天数配置费用 退款回预存款)。2021年7月14日美国 CERA 弹性云服务器 上新 联通CUVIP 线路!8折特惠中!点击进入:欧路云官方网站地址付款方式:PayPa...

socks5代理为你推荐
8080端口路由器如何开8080端口哈利波特罗恩升级当爸哈利波特 13年前的晚上发生了什么?openeuleropen与close的区别及用法杰景新特美国杰尼.巴尼特的资料xyq.163.cbg.com『梦幻西游』那藏宝阁怎么登录?同ip网站一个域名能对应多个IP吗百度关键词工具如何通过百度官方工具提升关键词排名www.55125.cn如何登录www.jbjy.cnm.kan84.net电视剧海派甜心全集海派甜心在线观看海派甜心全集高清dvd快播迅雷下载www.bbb551.comHUNTA551第一个第二个妹子是谁呀??
com域名空间 长沙服务器租用 免费动态域名解析 fastdomain 美元争夺战 名片模板psd 512m内存 主机合租 北京双线 国外代理服务器软件 中国网通测速 100mbps 服务器监测 万网主机管理 德隆中文网 windows2008 ncp 美国主机 免费网站加速 alexa搜 更多