/* Socks Server 5
* Copyright (C) 2002 - 2011 by Matteo Ricchetti - <matteo.ricchetti@libero.it>
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
#include"SS5Main.h"
#include"SS5Defs.h"
#include"SS5Utils.h"
#include"SS5Mod_socks5.h"
#include"SS5Mod_authorization.h"
#include"SS5OpenLdap.h"
#include"SS5Mod_log.h"
#ifdef SS5_USE_GSSAPI
#include"SS5GSSApi.h"
#endif
char *ss5ver=SS5_VERSION;
UINT InitModule( struct _module *m )
{
m->MethodParsing=MethodParsing;
m->RequestParsing=RequestParsing;
m->UpstreamServing=UpstreamServing;
m->ConnectServing=ConnectServing;
m->BindServing=BindServing;
m->UdpAssociateServing=UdpAssociateServing;
m->UdpAssociateResponse=UdpAssociateResponse;
m->AddMethod=AddMethod;
m->FreeMethod=FreeMethod;
m->GetMethod=GetMethod;
m->AddRoute=AddRoute;
m->FreeRoute=FreeRoute;
m->GetRoute=GetRoute;
m->AddProxy=AddProxy;
m->FreeProxy=FreeProxy;
m->GetProxy=GetProxy;
m->SrvSocks5=SrvSocks5;
return OK;
}
UINT ListRoute( UINT s)
{
UINT count;
struct _S5RouteNode *node, *lnode;
char buf[106];
for(count = 0;count < MAXROUTELIST; count++) {
if( (node=S5RouteList[count]) != NULL) {
lnode=node;
do {
if(lnode != NULL ) {
snprintf(buf,sizeof(buf),"%16lu\n%2u\n%16lu\n%64s\n%3u\n",lnode->SrcAddr,lnode->Mask,lnode->SrcIf,lnode->Group,lnode->sd);
lnode=lnode->next;
}
if( send(s,buf,sizeof(buf),0) == -1) {
perror("Send err:");
return ERR;
}
} while( lnode != NULL );
}
}
return OK;
}
UINT ListMethod( UINT s)
{
UINT count;
struct _S5MethodNode *lnode, *node;
char buf[57];
for(count = 0;count < MAXMETHODLIST; count++) {
if( (node=S5MethodList[count]) != NULL) {
lnode=node;
do {
if(lnode != NULL ) {
snprintf(buf,sizeof(buf),"%3u\n%16lu\n%2u\n%16lu\n%5u\n%5u\n",lnode->Method,lnode->SrcAddr,lnode->Mask,lnode->SrcPort,
lnode->SrcRangeMin,lnode->SrcRangeMax);
lnode=lnode->next;
}
if( send(s,buf,sizeof(buf),0) == -1) {
perror("Send err:");
return ERR;
}
} while( lnode != NULL );
}
}
return OK;
}
UINT ListProxy( UINT s)
{
UINT count;
struct _S5ProxyNode *node, *lnode;
char buf[80];
for(count = 0;count < MAXPROXYLIST; count++) {
if( (node=S5ProxyList[count]) != NULL) {
lnode=node;
do {
if(lnode != NULL ) {
snprintf(buf,sizeof(buf),"%16lu\n%2u\n%16lu\n%5u\n%5u\n%16lu\n%5u\n%3u\n%3u\n",lnode->DstAddr,lnode->Mask,lnode->DstPort,
lnode->DstRangeMin,lnode->DstRangeMax,lnode->ProxyAddr,lnode->ProxyPort,lnode->SocksVer,lnode->Type);
lnode=lnode->next;
}
if( send(s,buf,sizeof(buf),0) == -1) {
perror("Send err:");
return ERR;
}
} while( lnode != NULL );
}
}
return OK;
}
INT SrvSocks5( struct _SS5ClientInfo *ci, struct _SS5Socks5Data *sd )
{
UINT method,method2,
srcMask,
dstMask,
socksver,
sdr;
char logString[128];
pid_t pid;
struct in_addr in;
char sa[64]="\0",
sp[16]="\0",
da[64]="\0",
dp[16]="\0",
pa[16]="\0",
pp[5]="\0",
si[16]="\0",
sv[1]="\0",
me[1]="\0",
me2[1]="\0",
grp[64]="\0",
dir[1]="\0";
char srvResponse[128];
/*
* Get child/thread pid
*/
if( NOTTHREADED() )
pid=getpid();
else
pid=(UINT)pthread_self();
if( STREQ(sd->MethodRequest,"ET /list=METHOD HTTP/1.",sizeof("ET /list=METHOD HTTP/1.") - 1) ) {
ListMethod(ci->Socket);
return OK;
}
else if( STREQ(sd->MethodRequest,"DD /method=",sizeof("DD /method=") - 1) ) {
/*
* Create response
*/
sscanf(sd->MethodRequest,"DD /method=%20s\n%16s\n%1s%1s\n",sa,sp,me,me2);
switch(me[0]) {
case '-': method=NOAUTH; break;
case 'u': method=USRPWD; break;
case 'n': method=FAKEPWD; break;
case 's': method=S_USER_PWD; break;
#ifdef SS5_USE_GSSAPI
case 'k': method=GSSAPI; break;
#endif
}
switch(me2[0]) {
case '-': method2=NOAUTH; break;
case 'u': method2=USRPWD; break;
case 'n': method2=FAKEPWD; break;
case 's': method2=S_USER_PWD; break;
#ifdef SS5_USE_GSSAPI
case 'k': method2=GSSAPI; break;
#endif
}
srcMask=S5GetNetmask(sa);
if( AddMethod(ONLINE,inet_network(sa),S5GetRange(sp),method,method2,32-srcMask) && ( NMethodList < MAXMETHODLIST) ) {
strncpy(srvResponse,"OK\0",sizeof("OK\0"));
NMethodList++;
}
else
strncpy(srvResponse,"ERR\0",sizeof("ERR\0"));
if( send(ci->Socket,srvResponse,strlen(srvResponse),0) == -1) {
perror("Send err:");
return ERR;
}
return OK;
}
else if( STREQ(sd->MethodRequest,"EL /method=",sizeof("EL /method=") - 1) ) {
/*
* Create response
*/
sscanf(sd->MethodRequest,"EL /method=%20s\n%16s\n%1s%1s\n",sa,sp,me,me2);
switch(me[0]) {
case '-': method=NOAUTH; break;
case 'u': method=USRPWD; break;
case 'n': method=FAKEPWD; break;
case 's': method=S_USER_PWD; break;
#ifdef SS5_USE_GSSAPI
case 'k': method=GSSAPI; break;
#endif
}
switch(me2[0]) {
case '-': method2=NOAUTH; break;
case 'u': method2=USRPWD; break;
case 'n': method2=FAKEPWD; break;
case 's': method2=S_USER_PWD; break;
#ifdef SS5_USE_GSSAPI
case 'k': method2=GSSAPI; break;
#endif
}
srcMask=S5GetNetmask(sa);
if( DelMethod(inet_network(sa),S5GetRange(sp),method,method2,32-srcMask) && (NMethodList > 0) ) {
strncpy(srvResponse,"OK\0",sizeof("OK\0"));
NMethodList--;
}
else
strncpy(srvResponse,"ERR\0",sizeof("ERR\0"));
if( send(ci->Socket,srvResponse,strlen(srvResponse),0) == -1) {
perror("Send err:");
return ERR;
}
return OK;
}
else if( STREQ(sd->MethodRequest,"DD /route=",sizeof("DD /route=") - 1) ) {
/*
* Create response
*/
sscanf(sd->MethodRequest,"DD /route=%20s\n%16s\n%64s\n%1s\n",sa,si,grp,dir);
switch(dir[0]) {
case '-': sdr=SRC_ROUTE; break;
case 's': sdr=SRC_ROUTE; break;
case 'd': sdr=DST_ROUTE; break;
default: SS5Modules.mod_logging.Logging("[ERRO] SS5SRV: Type unknown in route line."); return ERR; break;
}
srcMask=S5GetNetmask(sa);
in.s_addr=inet_addr(si);
if( AddRoute(ONLINE,inet_network(sa),in.s_addr,grp,32-srcMask,sdr) && ( NRouteList < MAXROUTELIST ) ) {
strncpy(srvResponse,"OK\0",sizeof("OK\0"));
NRouteList++;
}
else
strncpy(srvResponse,"ERR\0",sizeof("ERR\0"));
SS5SocksOpt.IsUpstream = OK;
if( send(ci->Socket,srvResponse,strlen(srvResponse),0) == -1) {
perror("Send err:");
retur
没有合适的资源?快使用搜索试试~ 我知道了~
Socks5 代理服务器 Centos 8 免编译
共237个文件
c:30个
h:29个
o:29个
需积分: 5 9 下载量 76 浏览量
2023-06-21
02:49:24
上传
评论 1
收藏 1.55MB ZIP 举报
温馨提示
无需编译, 解压后直接执行 make install
资源推荐
资源详情
资源评论
收起资源包目录
Socks5 代理服务器 Centos 8 免编译 (237个子文件)
ss5.1 5KB
ss5srv.1 2KB
ss5.conf.5 9KB
ss5.ha.5 2KB
ss5.passwd.5 1KB
ss5.pam.5 1KB
ss5_gss.5 1KB
ss5_supa.5 980B
configure.ac 8KB
admin 5B
README.balamgr 223B
README.BALANCE 526B
README.build 453B
ss5.conf.5.bz2 3KB
ss5.1.bz2 2KB
ss5.ha.5.bz2 1KB
ss5srv.1.bz2 1KB
ss5.pam.5.bz2 730B
ss5.passwd.5.bz2 706B
ss5_gss.5.bz2 697B
ss5_supa.5.bz2 616B
SS5Mod_socks5.c 73KB
SS5Core_GSS.c 56KB
SS5Core.c 53KB
SS5Utils.c 52KB
SS5Srv.c 47KB
SS5Mod_authorization.c 38KB
SS5Mod_socks4.c 24KB
SS5Radius.c 18KB
SS5GSSApi.c 15KB
SS5Mod_statistics.c 13KB
SS5Mod_authentication.c 13KB
SS5Mod_balance.c 13KB
SS5Mod_proxy.c 13KB
SS5Main.c 13KB
SS5Mod_filter.c 12KB
SS5Supa.c 12KB
SS5Mod_dump.c 12KB
statmgr.c 11KB
SS5Mod_bandwidth.c 10KB
SS5Modules.c 10KB
SS5Server.c 7KB
SS5Debug.c 6KB
SS5OpenLdap.c 6KB
balamgr.c 5KB
SS5Pam.c 5KB
SS5MySql.c 3KB
SS5Thread.c 3KB
SS5ExternalProgram.c 3KB
SS5Mod_log.c 2KB
SS5Basic.c 1KB
statmgr.cgi 48KB
balamgr.cgi 39KB
ChangeLog 15KB
ss5.conf 11KB
ss5.conf 1KB
slapd.conf 296B
configure 213KB
README.CONSOLE 143B
login_new.css 3KB
README.EPOLL 113B
lock_icon.gif 600B
ss5.conf.5.gz 3KB
ss5.conf.5.gz 3KB
ss5.1.gz 2KB
ss5.1.gz 2KB
ss5.ha.5.gz 1KB
ss5.ha.5.gz 1KB
ss5srv.1.gz 959B
ss5srv.1.gz 959B
ss5.pam.5.gz 701B
ss5.pam.5.gz 701B
ss5.passwd.5.gz 691B
ss5.passwd.5.gz 691B
ss5_gss.5.gz 636B
ss5_gss.5.gz 636B
ss5_supa.5.gz 561B
ss5_supa.5.gz 561B
SS5Main.h 30KB
config.h 6KB
SS5Mod_socks5.h 4KB
SS5Mod_authorization.h 4KB
SS5Srv.h 3KB
SS5Supa.h 3KB
SS5Radius.h 3KB
SS5Mod_filter.h 2KB
SS5Core.h 2KB
SS5Mod_socks4.h 2KB
SS5Defs.h 2KB
SS5Mod_authentication.h 2KB
SS5Mod_dump.h 2KB
SS5Mod_bandwidth.h 2KB
SS5Mod_balance.h 2KB
SS5GSSApi.h 2KB
SS5Mod_proxy.h 2KB
SS5Utils.h 2KB
SS5OpenLdap.h 2KB
SS5Debug.h 1KB
SS5Server.h 1KB
SS5MySql.h 1KB
共 237 条
- 1
- 2
- 3
资源评论
sixcoffin
- 粉丝: 1
- 资源: 2
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
最新资源
- vmware-VMnet8一键启动和停止脚本
- 可移植的 Python 数据框库.zip
- 包含 Andrei Neagoie 的《从零到精通掌握编码面试 - 数据结构 + 算法》课程的所有代码示例,使用 Python 语言 .zip
- 数据库课程设计(图书馆管理系统)springboot+swing+mysql+mybatis
- C++ Vigenère 密码(解密代码)
- zblog日收站群,zblog泛目录
- C++ Vigenère 密码(加密代码)
- Vue Router 是 Vue 生态系统的一部分,是一个 MIT 许可的开源项目,其持续开发完全在赞助商的支持下成为可能 支持 Vue 路由器
- PM2.5 数据集 包含上海、成都、广州、北京、沈阳五地的PM2.5观测,csv文件
- 电动汽车与软件定义汽车(SDV)时代的汽车行业数字化转型
资源上传下载、课程学习等过程中有任何疑问或建议,欢迎提出宝贵意见哦~我们会及时处理!
点击此处反馈
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功