SOCKS: A protocol for TCP proxy across firewalls
Ying-Da Lee
Principal Member Technical Staff
NEC Systems Laboratory, CSTC
ylee@syl.dl.nec.com
SOCKS was originally developed by David Koblas and subsequently modified
and extended by me to its current running version -- version 4. It is a
protocol that relays TCP sessions at a firewall host to allow application
users transparent access across the firewall. Because the protocol is
independent of application protocols, it can be (and has been) used for
many different services, such as telnet, ftp, finger, whois, gopher, WWW,
etc. Access control can be applied at the beginning of each TCP session;
thereafter the server simply relays the data between the client and the
application server, incurring minimum processing overhead. Since SOCKS
never has to know anything about the application protocol, it should also
be easy for it to accommodate applications which use encryption to protect
their traffic from nosey snoopers.
Two operations are defined: CONNECT and BIND.
1) CONNECT
The client connects to the SOCKS server and sends a CONNECT request when
it wants to establish a connection to an application server. The client
includes in the request packet the IP address and the port number of the
destination host, and userid, in the following format.
+----+----+----+----+----+----+----+----+----+----+....+----+
| VN | CD | DSTPORT | DSTIP | USERID |NULL|
+----+----+----+----+----+----+----+----+----+----+....+----+
# of bytes: 1 1 2 4 variable 1
VN is the SOCKS protocol version number and should be 4. CD is the
SOCKS command code and should be 1 for CONNECT request. NULL is a byte
of all zero bits.
The SOCKS server checks to see whether such a request should be granted
based on any combination of source IP address, destination IP address,
destination port number, the userid, and information it may obtain by
consulting IDENT, cf. RFC 1413. If the request is granted, the SOCKS
server makes a connection to the specified port of the destination host.
A reply packet is sent to the client when this connection is established,
or when the request is rejected or the operation fails.
+----+----+----+----+----+----+----+----+
| VN | CD | DSTPORT | DSTIP |
+----+----+----+----+----+----+----+----+
# of bytes: 1 1 2 4
VN is the version of the reply code and should be 0. CD is the result
code with one of the following values:
90: request granted
91: request rejected or failed
92: request rejected becasue SOCKS server cannot connect to
identd on the client
93: request rejected because the client program and identd
report different user-ids
The remaining fields are ignored.
The SOCKS server closes its connection immediately after notifying
the client of a failed or rejected request. For a successful request,
the SOCKS server gets ready to relay traffic on both directions. This
enables the client to do I/O on its connection as if it were directly
connected to the application server.
2) BIND
The client connects to the SOCKS server and sends a BIND request when
it wants to prepare for an inbound connection from an application server.
This should only happen after a primary connection to the application
server has been established with a CONNECT. Typically, this is part of
the sequence of actions:
-bind(): obtain a socket
-getsockname(): get the IP address and port number of the socket
-listen(): ready to accept call from the application server
-use the primary connection to inform the application server of
the IP address and the port number that it should connect to.
-accept(): accept a connection from the application server
The purpose of SOCKS BIND operation is to support such a sequence
but using a socket on the SOCKS server rather than on the client.
The client includes in the request packet the IP address of the
application server, the destination port used in the primary connection,
and the userid.
+----+----+----+----+----+----+----+----+----+----+....+----+
| VN | CD | DSTPORT | DSTIP | USERID |NULL|
+----+----+----+----+----+----+----+----+----+----+....+----+
# of bytes: 1 1 2 4 variable 1
VN is again 4 for the SOCKS protocol version number. CD must be 2 to
indicate BIND request.
The SOCKS server uses the client information to decide whether the
request is to be granted. The reply it sends back to the client has
the same format as the reply for CONNECT request, i.e.,
+----+----+----+----+----+----+----+----+
| VN | CD | DSTPORT | DSTIP |
+----+----+----+----+----+----+----+----+
# of bytes: 1 1 2 4
VN is the version of the reply code and should be 0. CD is the result
code with one of the following values:
90: request granted
91: request rejected or failed
92: request rejected becasue SOCKS server cannot connect to
identd on the client
93: request rejected because the client program and identd
report different user-ids.
However, for a granted request (CD is 90), the DSTPORT and DSTIP fields
are meaningful. In that case, the SOCKS server obtains a socket to wait
for an incoming connection and sends the port number and the IP address
of that socket to the client in DSTPORT and DSTIP, respectively. If the
DSTIP in the reply is 0 (the value of constant INADDR_ANY), then the
client should replace it by the IP address of the SOCKS server to which
the cleint is connected. (This happens if the SOCKS server is not a
multi-homed host.) In the typical scenario, these two numbers are
made available to the application client prgram via the result of the
subsequent getsockname() call. The application protocol must provide a
way for these two pieces of information to be sent from the client to
the application server so that it can initiate the connection, which
connects it to the SOCKS server rather than directly to the application
client as it normally would.
The SOCKS server sends a second reply packet to the client when the
anticipated connection from the application server is established.
The SOCKS server checks the IP address of the originating host against
the value of DSTIP specified in the client's BIND request. If a mismatch
is found, the CD field in the second reply is set to 91 and the SOCKS
server closes both connections. If the two match, CD in the second
reply is set to 90 and the SOCKS server gets ready to relay the traffic
on its two connections. From then on the client does I/O on its connection
to the SOCKS server as if it were directly connected to the application
server.
For both CONNECT and BIND operations, the server sets a time limit
(2 minutes in current CSTC implementation) for the establishment of its
connection with the application server. If the connection is still not
establiched when the time limit expires, the server closes its connection
to the client and gives up.
相关推荐
双闭环PWM整流器VOC控制 +SVPWM调制仿真(Simulink仿真实现)
内容概要:本文详细介绍了基于Simulink平台构建的双闭环PWM整流器VOC(虚拟磁链定向控制)与SVPWM(空间矢量脉宽调制)相结合的仿真模型,系统阐述了三相电压型PWM整流器在电压定向控制策略下的建模方法与控制实现。通过设计外环直流电压控制与内环电流控制的双闭环结构,实现了对整流器的高功率因数运行、能量双向流动及动态性能优化的精确调控。结合SVPWM调制技术,有效提升了直流侧电压利用率并显著降低输出电流谐波含量,增强了系统的整体效率与稳定性。该仿真模型适用于新能源发电、电动汽车充电系统、微电网等高性能电能变换应用场景,文档还配套提供了丰富的学习资源与技术支持渠道,便于深入研究与工程实践。; 适合人群:面向电气工程、自动化、电力电子及相关专业的高校学生、科研人员以及从事新能源、智能电网、电力传动等领域研发工作的工程师;尤其适合已具备自动控制理论、电力电子变换技术和MATLAB/Simulink仿真基础的专业人士进一步深化学习与应用。; 使用场景及目标:①深入理解PWM整流器的工作机理及其双闭环控制系统的架构设计;②掌握VOC控制与SVPWM调制的协同工作机制,提升系统动静态响应性能;③支撑科研课题、课程设计、毕业设计或实际工程项目中的整流器控制系统开发与验证;④作为高级电能变换技术的学习范例,促进对现代电力电子系统控制策略的综合理解与创新能力培养。; 阅读建议:建议结合文中提供的百度网盘链接与公众号资源,下载完整的Simulink仿真模型进行实操演练,在MATLAB环境中调整控制器参数并观察仿真结果,深入剖析控制逻辑与系统响应特性;同时可参考同系列资源如PI双闭环控制、电网不平衡工况下的控制策略等案例,开展对比分析与拓展研究,全面提升系统建模与控制设计的综合能力。
SOCKS
SOCKS: A protocol for TCP proxy across firewalls Ying-Da Lee Principal Member Technical Staff NEC Systems Laboratory, CSTC ylee@syl.dl.nec.comSOCKS was originally
【MFRC522】STM32与MFRC522的SPI通信优化及常见问题解析
本文深入解析了STM32与MFRC522进行SPI通信的优化方法与常见问题。从基础的硬件连接到SPI时序优化,再到关键的寄存器配置(如RFCfgReg设为0x4F以提升读卡稳定性),文章提供了详细的调试技巧和实战排坑指南,帮助开发者实现稳定高效的IC读卡应用。
虚拟机中centos安装nginx后,主机浏览器无法访问ip( telnet ip 80后出现Escape character is '^]'. Connection closed by fore)
虚拟机中centos安装nginx后,主机浏览器无法访问ip 主机和虚拟机互相ping得通,但是浏览器访问ip一直报错, telnet ip 80后出现Escape character is ‘^]’. Connection closed by foreign host. 试了网上那些关闭蓝灯呀,关闭防火墙呀都没啥用,最后是采用了以下的方法: 首先:开启 web 端口 firewall-cmd ...
VS2022错误列表高效处理:从复制到Excel表格的完整指南
本文详细介绍了在Visual Studio 2022中高效处理错误列表的实用技巧,重点讲解了如何将错误信息一键复制并粘贴到Excel表格中。通过基础操作、自定义视图、筛选功能及常见问题解决方案,帮助开发者将杂乱的编译错误整理成清晰、可排序、可筛选的数据表,极大提升了团队协作、错误分析和项目管理的效率。
Ubuntu20.04安装Torque-6.1.2单机版(踩坑篇)
说明:PBS排队系统原先是在Centos7安装使用很顺利,但是有客户需求在Ubuntu20.04上使用,着手在Ubuntu20.04安装上安装的时候发现很多报错,并不能顺利安装,网上查找到的教程,有的说是让放弃转slurm,有的是换源安装,但是安装好的版本很低,有许多bug,不是很好用。经过自己慢慢摸索之后,改了部分配置以及源码之后,能够顺利安装,再次记录一下踩坑心得,与大家一起分享学习。如有问题,欢迎大家来撩。...............
“curl: (7) Failed to receive SOCKS4 connect request ack.”解决方法
如果出现: >>> proxychains4 curl twitter.com [proxychains] config file found: /etc/proxychains.conf [proxychains] preloading /usr/local/lib/libproxychains4.so [proxychains] DLL init: proxychains-n...
生成式引擎优化(GEO)- 搜索引擎优化
生成式引擎优化(GEO)是针对AI内容生成平台(如ChatGPT)的新型优化策略,旨在提升品牌内容在AI生成答案中的引用率,与传统SEO存在显著差异。GEO通过优化内容权威性、结构化和语义关联,适应AI的RAG技术架构,采用3C原则(可爬性、网络共识、反馈校正)提升内容可见性。其核心区别在于目标(引用率vs排名)、技术(语义优化vs关键词)及算法透明度(封闭vs开放)。适用场景包括商业决策、行业权威建设及公共知识服务,帮助品牌在AI时代占据信息主导权。
解决 class file has wrong version 49.0, should be 48.0 的方法
有些时间,我们会遇到版本不匹配的问题。如: bad class file: /usr/java/jdk1.5.0_06/jre/lib/rt.jar(java/lang/Object.class)class file
从零上手HiAgent:构建能听懂指令的智能体框架实战指南
智能体(Agent)作为人工智能领域的重要范式,正从传统的预设流程自动化转向以目标驱动的自主规划与执行。其核心原理在于利用大语言模型(LLM)作为决策大脑,通过任务规划、工具调用与记忆机制,将模糊的自然语言指令转化为可执行的工作流。这一技术显著提升了人机协作的效率和自然度,其价值在自动化办公、数据分析与智能流程编排等场景中尤为突出。本文聚焦于HiAgent这一具体框架,深入解析其作为智能体开发平台的核心架构,涵盖规划器、执行器、工具集等关键组件,并提供从环境配置、自定义工具开发到复杂任务链构建的完整工程实践
基于STM32、HAL库的AD7124-8BCPZ模数转换器ADC驱动程序设计
/ 配置0: 使用内部参考电压(2.5V),增益128,双极性。// 配置通道0: AIN0+和AIN1-,使用配置0和滤波器0。// 100ms采样间隔。// 转换为电压值(使用内部2.5V参考电压)// 构造读命令: 最高位为1表示读,接下来7位是寄存器地址。// 构造写命令: 最高位为0表示写,接下来7位是寄存器地址。// 配置滤波器0: 输出数据率50Hz,后置滤波器4。
SOCKS4: A protocol for TCP proxy across firewalls
SOCKS: A protocol for TCP proxy across firewalls Ying-Da Lee Principal Member Technical Staff NEC Systems Laboratory, CSTC ylee@syl.dl.nec.comSOCKS was originally developed by D
基于YOLOv8的表面裂痕等缺陷检测:深度学习与UI界面的实践
本文详细介绍了如何使用YOLOv8进行表面裂痕等缺陷检测,并结合图形用户界面展示检测结果。通过YOLOv8的强大能力,我们可以实现高效、准确的表面缺陷检测,提升工业产品的质量控制水平。未来,随着深度学习技术和数据集的不断发展,表面缺陷检测的精度和速度将不断提升,应用领域也将进一步拓展。希望本文的实践能够为深度学习在工业检测领域的应用提供一些启示。
tcp:127.0.0.1:xxxx rejected proxy/socks: unknown Socks version: 67 解决方案
在Linux 下使用gdown --proxy http://127.0.0.1:<代理监听端口号> 指定代理下载数据文件遇到这个问题,这是proxy协议没对上导致的,代理用的是socket5协议,修改环境变量即可。
Android 13 RK3588 编译烧写实录全程
本文详细记录了RK3588主板在Android 13系统下的各项功能测试与编译过程。主要内容包括:1)网络功能测试(以太网、WiFi、蓝牙连接);2)外设接口测试(耳机、麦克风、USB、TF卡);3)硬件功能验证(RTC时钟、ADC采样、MIPI摄像头);4)系统设置(手势导航、开发者选项);5)Android 13 SDK编译环境搭建与源码获取方法。通过图文并茂的方式展示了各功能的配置方法、操作步骤和测试结果,为开发者提供了全面的参考指南。
迈瑞BS系列全自动生化分析仪LIS协议接口手册(内含HL7和ASTM)
迈瑞BS系列全自动生化分析仪LIS协议接口手册,内含HL7和ASTM)
解决打开浏览器报proxy服务器发生错误
再开始屏幕里面搜索代理服务器设置 然后把启动代理服务器的选项取消掉 就可以了 这个通常是由于翻墙软件的异常关闭导致的
数学建模模型总结
这是本人在两年内准备参加数学建模竞赛搜集到的模型资料,已经经过了本人的筛选和整理,希望能够对准备参加数学建模竞赛的学弟学妹们提供一些帮助!
网络请求及各类错误代码含义总结(Errors Code)
在很多时候都会遇到错误, 还会带有一些 Error Code , 比如在各种网络请求, 文件操作, cookie 错误等各种错误的代码和错误代码对应的含义. 以下目录为 SOCKS4 Errors, SOCKS5 Errors, FTP Errors, HTTP Errors, CFURLConnection & CFURLProtocol Errors, File Errors, ...
汉书HE8,好用的汇编代码编写工具
汉书HE8,好用的汇编代码编写工具早期编写汇编代码所用功能强大
ssm框架搭建
这个是一个在idea上成功跑起来的ssm框架项目,保存在这里方便以后使用直接下载
NSError错误码定义
NSURLErrorDomain & CFNetworkErrors The greatest source of failure in iOS apps is networking. Between radios, transport, data roaming policies, proxies, security, authentication, and any number of p
Failed to receive SOCKS4 connect request ack. 解决方法
转载自:http://www.chenlongyu.com/article/id/35 在此记录主要方便自己查看。 事件背景:开了socket5网络代理,git clone返回上述错误。 关了ss客户端后仍然不行: fatal: unable to access 'https://github.com/whqee/whqee.github.git/': Failed to connect...
504 Connect to google.com:80 failed: SOCKS protocol error
504 Connect to google.com:80 failed: SOCKS protocol error The following error occurred while trying to accesshttp://google.com/:504 Connect to google.com:80 failed: SOCKS protocol error Generated S...
java.net.SocketException: Malformed reply from SOCKS server
当IE设置有SOCKS(套接字)代理时,NetBeans Java Desktop Application也就是GUI窗口程序连接数据库总是会失败。如果关闭代理的设置,程序则能正常运行。 程序表现为:长时间处于连接状态而不返回。监视TCP连接,发现程序长时间连接到代理的IP上。 大约5分钟后,连接被断开,返回如下异常: 2012-05-05 13:16:15,...
1451



被折叠的 条评论
为什么被折叠?



