양말

SOCKS

SOCKS프록시 서버를 통해 클라이언트서버 간에 네트워크 패킷을 교환하는 인터넷 프로토콜이다. SOCKS5는 선택적으로 인증확인을 제공하여 권한이 부여된 사용자만 서버에 접근할 수 있도록 한다. 실제로 SOCKS 서버는 임의의 IP 주소에 TCP 연결을 프록시하며 UDP 패킷이 전달될 수 있는 수단을 제공한다.

SOCKS는 OSI 모델의 레이어 5(세션 레이어, 프리젠테이션 레이어와 전송 레이어 사이의 중간 레이어)에서 수행된다. SOCKS 서버는 에서 정의한 TCP 포트 1080에서 수신 클라이언트 연결을 허용함 RFC1928.[1]

역사

이 프로토콜은 원래 MIPS 컴퓨터 시스템의 시스템 관리자 David Koblas에 의해 개발/설계되었다. 1992년 MIPS가 실리콘그래픽스에 인수된 후, 코블라스는 그해 USenix 보안 심포지엄에서 SOCKS에 관한 논문을 발표하여 SOCKS를 공개하였다.[2][3] 이 의정서는 NEC의 Lee Ying-Da에 의해 버전 4로 확장되었다.

SOCKS 레퍼런스 아키텍처 및 클라이언트는 NEC의 자회사 [4]Permo Technologies가 소유하고 있다. (Blue Coat Systems 사들인 Permo Technologies)

The SOCKS5 protocol was originally a security protocol that made firewalls and other security products easier to administer. It was approved by the IETF in 1996 as RFC 1928 (authored by: M. Leech, M. Ganis, Y. Lee, R. Kuris, D. Koblas, and L. Jones). The protocol was developed in collaboration with Aventail Corporation, which markets the technology outside of Asia.[5]

Usage

SOCKS is a de facto standard for circuit-level gateways (level 5 gateways).[6]

The circuit/session level nature of SOCKS make it a versatile tool in forwarding any TCP (or UDP since SOCKS5) traffic, creating a good interface for all types of routing tools. It can be used as:

  • A circumvention tool, allowing traffic to bypass Internet filtering to access content otherwise blocked, e.g., by governments, workplaces, schools, and country-specific web services.[7] Since SOCKS is very detectable, a common approach is to present a SOCKS interface for more sophisticated protocols:
    • The Tor onion proxy software presents a SOCKS interface to its clients.[8]
  • Providing similar functionality to a virtual private network, allowing connections to be forwarded to a server's "local" network:
    • Some SSH suites, such as OpenSSH, support dynamic port forwarding that allows the user to create a local SOCKS proxy.[9] This can free the user from the limitations of connecting only to a predefined remote port and server.

Protocol

SOCKS4

A typical SOCKS4 connection request looks like this:

First packet to server
VER CMD DSTPORT DSTIP ID
Byte Count 1 1 2 4 Variable
VER
SOCKS version number, 0x04 for this version
CMD
command code:
  • 0x01 = establish a TCP/IP stream connection
  • 0x02 = establish a TCP/IP port binding
DSTPORT
2-byte port number (in network byte order)
DESTIP
IPv4 Address, 4 bytes (in network byte order)
ID
the user ID string, variable length, null-terminated.
Response packet from server
VN REP DSTPORT DSTIP
Byte Count 1 1 2 4
VN
reply version, null byte
REP
reply code
Byte Meaning
0x5A Request granted
0x5B Request rejected or failed
0x5C Request failed because client is not running identd (or not reachable from server)
0x5D Request failed because client's identd could not confirm the user ID in the request
DSTPORT
destination port, meaningful if granted in BIND, otherwise ignore
DSTIP
destination IP, as above – the ip:port the client should bind to

For example, this a SOCKS4 request to connect Fred to 66.102.7.99:80, the server replies with an "OK":

  • Client: 0x04 0x01 0x00 0x50 0x42 0x66 0x07 0x63 0x46 0x72 0x65 0x64 0x00
    • The last field is "Fred" in ASCII, followed by a null byte.
  • Server: 0x00 0x5A 0xXX 0xXX 0xXX 0xXX 0xXX 0xXX
    • 0xXX can be any byte value. The SOCKS4 protocol specifies that the values of these bytes should be ignored.

From this point onwards, any data sent from the SOCKS client to the SOCKS server is relayed to 66.102.7.99, and vice versa.

The command field may be 0x01 for "connect" or 0x02 for "bind"; the "bind" command allows incoming connections for protocols such as active FTP.

SOCKS4a

SOCKS4a extends the SOCKS4 protocol to allow a client to specify a destination domain name rather than an IP address; this is useful when the client itself cannot resolve the destination host's domain name to an IP address. It was proposed by Ying-Da Lee, the author of SOCKS4.[10]

The client should set the first three bytes of DSTIP to NULL and the last byte to a non-zero value. (This corresponds to IP address 0.0.0.x, with x nonzero, an inadmissible destination address and thus should never occur if the client can resolve the domain name.) Following the NULL byte terminating USERID, the client must send the destination domain name and terminate it with another NULL byte. This is used for both "connect" and "bind" requests.

Client to SOCKS server:

First packet to server
SOCKS4_C DOMAIN
Byte Count 8+variable variable
SOCKS4_C
SOCKS4 client handshake packet (above)
DOMAIN
the domain name of the host to contact , null (0x00) terminated

Server to SOCKS client: (Same as SOCKS4)

A server using protocol SOCKS4a must check the DSTIP in the request packet. If it represents address 0.0.0.x with nonzero x, the server must read in the domain name that the client sends in the packet. The server should resolve the domain name and make connection to the destination host if it can.

SOCKS5

SOCKS5 프로토콜은 RFC 1928에 정의되어 있다. SOCKS4 프로토콜의 호환되지 않는 확장이다. 인증에 대한 더 많은 선택권을 제공하고 IPv6UDP에 대한 지원을 추가하며, 이 중 후자는 DNS 검색에 사용할 수 있다. 초기 핸드셰이크는 다음과 같이 구성된다.

  • 클라이언트는 지원되는 인증 방법 목록을 포함하는 인사말을 연결하여 발송한다.
  • 서버는 방법 중 하나를 선택한다(또는 허용 가능한 방법이 없는 경우 오류 응답을 발송함).
  • 이제 선택한 인증 방법에 따라 여러 메시지가 클라이언트와 서버 사이를 통과할 수 있다.
  • 고객이 SOCKS4와 유사한 연결 요청을 보낸다.
  • 서버는 SOCKS4와 비슷하게 응답한다.

클라이언트의 초기 인사말:

클라이언트 인사말
VER NAUT AUTH
바이트 수 1 1 가변적
VER
SOCKS 버전(0x05)
NAUT
지원되는 인증 방법 수, uint8
AUTH
인증 방법, 방법당 1바이트 지원
지원되는 인증 방법은 다음과 같이 번호가 매겨진다.
  • 0x00: 인증 없음
  • 0x01: GSSAPI(RFC 1961)
  • 0x02: 사용자 이름/암호(RFC 1929)
  • 0x03–0x7F: IANA에서[11] 할당된 방법
    • 0x03: Challenge-Handshake 인증 프로토콜
    • 0x04: 할당되지 않음
    • 0x05: 질문-응답 인증 방법
    • 0x06: Secure Sockets Layer
    • 0x07: NDS 인증
    • 0x08: 다중 인증 프레임워크
    • 0x09: JSON 매개 변수 블록
    • 0x0A–0x7F: 할당되지 않음
  • 0x80–0xFE: 개인 용도로 예약된 방법
서버 선택
VER 카우트
바이트 수 1 1
VER
SOCKS 버전(0x05)
카우트
선택한 인증 방법 또는 허용되는 방법이 없는 경우 0xFF

후속 인증은 방법에 따라 달라진다. 사용자 이름과 비밀번호 인증확인(방법 0x02)은 RFC 1929에 설명되어 있다.

클라이언트 인증 요청, 0x02
VER IDLEN 아이디 PWLEN PW
바이트 수 1 1 (1-255) 1 (1-255)
VER
현재 버전의 사용자 이름/암호 인증확인용 0x01
IDLEN, ID
사용자 이름 길이, uint8, bytestring과 같은 사용자 이름
PWLEN, PW
암호 길이, uint8, bytestring과 같은 암호
서버 응답, 0x02
VER 상태
바이트 수 1 1
VER
현재 버전의 사용자 이름/암호 인증확인용 0x01
상태
0x00 성공, 그렇지 않으면 연결은 닫아야 함

인증 후 연결을 계속할 수 있다. 먼저 주소 데이터 유형을 다음과 같이 정의한다.

SOCKS5 주소
유형 ADDR
바이트 수 1 가변적
유형
주소의 종류 다음 중 하나:
  • 0x01: IPv4 주소
  • 0x03: 도메인 이름
  • 0x04: IPv6 주소
ADDR
다음의 주소 자료 유형에 따라:
  • IPv4 주소의 4바이트
  • 도메인 이름에 대해 이름 길이 1바이트와 1–1바이트 바이트
  • IPv6 주소의 16바이트
클라이언트 연결 요청
VER CMD RSV 디스타드르 DST포트
바이트 수 1 1 1 변수 2
VER
SOCKS 버전(0x05)
CMD
명령 코드:
  • 0x01: TCP/IP 스트림 연결 설정
  • 0x02: TCP/IP 포트 바인딩 설정
  • 0x03: UDP 포트 연결
RSV
예약됨, 0x00여야 함
디스타드르
대상 주소, 위의 주소 구조를 참조하십시오.
DST포트
네트워크 바이트 순서의 포트 번호
서버의 응답 패킷
VER 상태 RSV BNDDR BND포트
바이트 수 1 1 1 가변적 2
VER
SOCKS 버전(0x05)
상태
상태 코드:
  • 0x00: 요청 부여
  • 0x01: 일반 고장
  • 0x02: 규칙 집합에서 연결이 허용되지 않음
  • 0x03: 네트워크에 연결할 수 없음
  • 0x04: 호스트에 연결할 수 없음
  • 0x05: 대상 호스트에서 연결 거부
  • 0x06: TTL 만료
  • 0x07: 명령이 지원되지 않음 / 프로토콜 오류
  • 0x08: 주소 유형이 지원되지 않음
RSV
예약됨, 0x00여야 함
BNDDR
위에서 지정한 "SOCK5 주소" 형식의 서버 바인딩 주소(RFC 1928에서 정의됨)
BND포트
네트워크 바이트 순서의 서버 바인딩 포트 번호

클라이언트는 확인된 주소나 도메인 이름을 사용할 수 있으므로, sOCKS5의 도메인 이름 변형에 "socks5h"와 다른 "socks5"라는 레이블을 붙이는 cURL의 규칙이 존재한다. SOCKS4a와 SOCKS4도 비슷한 관습이 존재한다.[12]

소프트웨어

서버

SOCKS 프록시 서버 구현

  • Sun Java System Web Proxy Server는 Solaris, 리눅스 및 윈도우즈 서버에서 실행되는 캐싱 프록시 서버로 HTTPS, NSAPI I/O 필터, 동적 재구성, SOCKSv5 및 역방향 프록시를 지원한다.
  • WinGate는 마이크로소프트 윈도용 멀티 프로토콜 프록시 서버 및 SOCKS 서버로서 SOCKS4, SOCKS4a, SOCKS5(UDP-ASICAIL 및 GSSAPI 인증 포함)를 지원한다. 또한 HTTP 프록시에 SOCKS 연결을 넘길 수 있도록 지원하므로 SOCKS를 통한 HTTP 캐시 및 스캔이 가능하다.
  • Socksgetgate5 SocksGate5는 OSI 모델인 Application Layer 7에 검사 기능이 있는 Application-SOCK 방화벽이다. 패킷은 7 OSI 레벨에서 검사되므로 애플리케이션-SOCK 방화벽은 프로토콜 비준수 및 지정된 콘텐츠 차단 여부를 검색할 수 있다.
  • 단테는 회로 수준의 SOCKS 서버로, 편리하고 안전한 네트워크 연결을 제공하기 위해 사용할 수 있으며, 단테가 운영하는 호스트만이 외부 네트워크 연결을 갖도록 요구한다.[13]

SOCKS 서버 인터페이스를 제공하는 기타 프로그램

  • OpenSSH는 CONNECT 명령을 지원하면서 SOCKS 프로토콜의 서브셋을 통해 지정된 터널의 동적 생성을 허용한다.
  • PuTTY는 원격 SSH 서버를 통해 SOCKS(동적) 터널의 로컬 생성을 지원하는 Win32 SSH 클라이언트다.
  • 심머캣[14] SOCKS5를 이용해 내부 네트워크를 시뮬레이션하는 웹서버로 웹 개발자가 /etc/hosts 파일을 수정하지 않고도 현지 사이트를 테스트할 수 있다.
  • 토르는 온라인 익명성을 가능하게 하기 위한 시스템이다. Tor는 고객에게 TCP 전용 SOCKS 서버 인터페이스를 제공한다.
  • 그림자는 검열을 회피하는 도구다. SOCKS5 인터페이스를 제공한다.

클라이언트

SOCKS를 통해 연결하려면 클라이언트 소프트웨어에 네이티브 SOCKS 지원이 있어야 한다. 사용자가 이러한 제한을 우회할 수 있는 프로그램이 있다.

양말자

양말기는 어떤 프록시 프로토콜도 지원할 필요 없이 응용 프로그램이 프록시를 사용하기 위해 네트워크에 접속할 수 있게 한다. 가장 일반적인 방법은 어댑터를 통해 트래픽을 전송할 수 있도록 가상 네트워크 어댑터와 적절한 라우팅 테이블을 설정하는 것이다.

  • SOCKS5, HTTPS 또는 Shadowsock을 통해 응용 프로그램이 네트워크에 액세스할 수 있도록 하는 Win2Socks.
  • SOCKS 프록시에서 가상 TCP TUN 어댑터를 생성하는 오픈 소스 도구인 tun2socks. Linux 및 Windows에서 작동하며,[15] 골랑에 MacOS 포트와 UDP 지원 재구성이 가능하다.
  • Proxychains, SOCKS 또는 HTTP 프록시를 통해 TCP 트래픽을 강제로 실행하는 Unix 프로그램. 다양한 Unix 유사 시스템에서 작동.[16]

프록시 변환 중

도커 기반

  • 클라이언트, 서버 또는 둘 모두를 사용하여 프록시를 변환하는 Docker를 실행하는 모든 플랫폼에서 실행되는 Docker 기반 접근 방식인 멀티소크.[17]

보안

요청과 패킷 교환 암호화의 부족으로 인해 SOCKS는 사실상 중간 공격과 IP 주소 도청에 취약하게 되어 결과적으로 정부에 의한 검열로 가는 길을 열어준다.

참조

  1. ^ "Service Name and Transport Protocol Port Number Registry". Internet Assigned Numbers Authority. 19 May 2017. Retrieved 23 May 2017.
  2. ^ Koblas, David; Koblas, Michelle R. SOCKS (PDF). USENIX UNIX Security Symposium III. Retrieved 16 November 2019.
  3. ^ 다모레이, 티나 "방화벽과 동화" ;LOGIN:. 제30권, 제1권.
  4. ^ 웨이백 머신아카이브 인덱스
  5. ^ CNET: 우주에서 온 사이버 공간
  6. ^ Oppliger, Rolf (2003). "Circuit-level gateways". Security technologies for the World Wide Web (2nd ed.). Artech House. ISBN 1580533485. Retrieved 21 January 2020.
  7. ^ "2010 Circumvention Tool Usage Report" (PDF). The Berkman Center for Internet & Society at Harvard University. October 2010.
  8. ^ "Tor FAQ".
  9. ^ "OpenSSH FAQ". Archived from the original on 2002-02-01.
  10. ^ Ying-Da Lee. "SOCKS 4A: A Simple Extension to SOCKS 4 Protocol". OpenSSH. Retrieved 2013-04-03.
  11. ^ IANA.org
  12. ^ "CURLOPT_PROXY". curl.se. Retrieved 20 January 2020.
  13. ^ "Products developed by Inferno Nettverk A/S". www.inet.no. Retrieved 2021-03-20.
  14. ^ "Easy Net with SOCKS5". shimmercat.com. ShimmerCat. Archived from the original on 2018-09-13. Retrieved 20 April 2016.
  15. ^ Bizjak, Ambroz (20 January 2020). "ambrop72/badvpn: NCD scripting language, tun2socks proxifier, P2P VPN". GitHub. Retrieved 20 January 2020.
  16. ^ Hamsik, Adam (20 January 2020). "proxychains: a tool that forces any TCP connection made by any given application to follow through proxy like TOR or any other SOCKS4, SOCKS5 or HTTP(S) proxy". GitHub. Retrieved 20 January 2020.
  17. ^ Momm, Gregorio (2020-08-24), gregoriomomm/docker-multsocks, retrieved 2020-08-29

외부 링크