/* 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 10 下载量 125 浏览量
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币余额
- 我的收藏
- 我的下载
- 下载帮助
最新资源
- 料带自动上料机含bom和3D图纸和工程图机械结构设计图纸和其它技术资料和技术方案非常好100%好用.zip
- 使用Java多线程和同步机制实现生产者-消费者模式.zip
- 端子排自动切割设备含bom工程图机械结构设计图纸和其它技术资料和技术方案非常好100%好用.zip
- Python爬虫入门实例:利用requests和BeautifulSoup抓取网页标题
- HBase常用的Shell命令
- Linux下Oracle 11g的完整安装与配置指南
- MySQL多平台安装教程:Windows、macOS与Linux
- 新年快乐,喜庆html
- 单片机综合实验储物箱重庆邮电大学
- Screenshot_20241224_205242_com.tencent.tmgp.sgame.jpg
- html css网页制作成品.docx
- Selenium-ECShop项目文档
- 实验报告,重庆邮电大学,单片机,大作业
- 汽车防撞梁总成装配台3D图纸和工程图机械结构设计图纸和其它技术资料和技术方案非常好100%好用.zip
- Java平台Maven项目管理和构建工具的安装与配置
- 重庆邮电大学所有实验单片机,大作业,串口,双机编程,程序文件
资源上传下载、课程学习等过程中有任何疑问或建议,欢迎提出宝贵意见哦~我们会及时处理!
点击此处反馈
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功