Click here to Skip to main content
15,890,579 members
Articles / Programming Languages / Java / Java SE
Article

SOCKS Proxy + SSL Tunnel

Rate me:
Please Sign up or sign in to vote.
4.80/5 (42 votes)
22 Feb 2000 2.5M   4.1K   83   179
A full featured SOCKS 4 & 5 proxy server written in Java.
  • Download source files - 41 Kb
  • The SSH Proxy is full featured SOCKS Proxy written in Java.
    It supports both versions 4 and 5 of Socks protocol.

    Additional feature that I have implemented in SSH Proxy is the possibility to make TCP connections through an HTTP-SSL Tunnel.

    SSH Proxy works in two modes:

    1. Normal mode - works as normal SOCKS Proxy
    2. TCP via SHTTP mode - Works as SOCKS Proxy but makes SOCKS TCP connections via HTTP-SSL Tunnel Proxy.

    Sample Image 1
    Sample Image 2

    The TCP via SHTTP mode is very useful when user woks behind HTTP Proxy and hasn't any other acces to the Internet. In this case the user can run SSH Proxy on his/her machine, and configure it to use TCP connections via HTTP-SSL tunnels which are commonly supported by most proxies. This way he/she will be able to use other internet applications, eg. IRC, FTP, e-mail, telnet, HTTP (of course :-) but without caching and etc.

    But if SSH Proxy works behind a firewall (in SSL tunnel mode) - the other SOCKS commands BIND and UDP association will not work.

    SSH Proxy loads its configuration from file config.txt which should be in the directory of the SSH Proxy

    # Copyright (c) 2000 Svetoslav Tchekanov (swetoslav@iname.com)
    #-------------------------------
    #EnableLog=no
    EnableLog=yes
    #-------------------------------
    SOCKSPort=8888
    #-------------------------------
    #UseSHttpProxy=1
    UseSHttpProxy=0
    SHttpProxyHost=<SHTTP Proxy Host/IP>
    SHttpProxyPort=<SHTTP Proxy Port>

    The variables UseSHttpProxy and EnableLog are logical. So you can specify their values either by 1, 0, Yes or No.

    License

    This article has no explicit license attached to it but may contain usage terms in the article text or the download files themselves. If in doubt please contact the author via the discussion board below.

    A list of licenses authors might use can be found here


    Written By
    Technical Lead Brosix
    Bulgaria Bulgaria
    I am a software development engineer .

    Programming Languages: C/C++, Java, Delphi, HTML, CGI, Assembly x86, CNC G-language
    RDBMS Microsoft SQL Server, MySQL, SQLite, MS Access, ODBC, JDBC

    Networking: TCP/IP, Winsock, HTTP, HTTPS, FTP, SMTP, POP3, TELNET, IMAP, SOCKS 4/5, RTSP, CGI, MS Internet Information Server

    Projects I have worked on:
  • Brosix
  • Screen-Sharing product
  • Video chat application
  • Server software
  • Java Virtual Machine
  • Application Server + Internet Proxy Services
  • Instant Messenger - like MSN and Yahoo ones
  • Voicer - Freeware VoIP application
  • Web Server
  • SSH Proxy - SOCKS 4&5 Proxy that can relay TCP Connections through HTTPS Proxy
  • HTTP Proxy
  • SOCKS proxy
  • Battery Test Suite
  • MFC custom UI controls
  • Internet Address Book - Synchronizes local Outlook, Outlook Express, Netscape and Eudora address book with database on WEB server located in the Internet
  • Advertising Screen Saver - Screen Saver that sends e-mails and gain prizes for the computer owner
  • Proxy Send Mail - Send Mail service that can send e-mails through SOCKS 4, SOCKS 5 and HTTPS proxies
  • Proxy Hunter - Very fast, and also works as proxy checker
  • Java Disassembler
  • Java custom UI controls
  • Delphi custom UI controls
  • CNC Gravuring System
  • Font editor for DOS
  • Little DOS games
  • Graphics library for DOS (in Assembly)
  • Galaxian like game for Apple][ in assembly
  • Graphics editor for Apple][
  • Font editor for Apple][
  • More information about my current work you can find here:
    www.brosix.com


    Comments and Discussions

     
    GeneralRe: Svetoslav please read - bypassing firewalls discussion Pin
    hungmainsion16-Mar-06 6:15
    hungmainsion16-Mar-06 6:15 
    GeneralI want help please Pin
    Member 90927226-Feb-04 5:31
    Member 90927226-Feb-04 5:31 
    Generalwhy this function: ResolveExternalLocalIP() Pin
    Member 4731284-Feb-04 2:28
    Member 4731284-Feb-04 2:28 
    GeneralTCP-Map proxy Pin
    Member 4731284-Feb-04 2:23
    Member 4731284-Feb-04 2:23 
    GeneralConfiguring SSHProxy---&quot;CONNECT&quot; command Pin
    Olhor9-Jan-04 14:00
    Olhor9-Jan-04 14:00 
    GeneralRe: Configuring SSHProxy---&quot;CONNECT&quot; command Pin
    Svetoslav Chekanov9-Jan-04 21:29
    Svetoslav Chekanov9-Jan-04 21:29 
    GeneralProblem with DC++ Pin
    Accipiter14-Dec-03 23:16
    Accipiter14-Dec-03 23:16 
    GeneralSHTTP Proxy Reply : [HTTP/1.1 502 Proxy Error (...) Pin
    Le Paro26-Nov-03 20:35
    sussLe Paro26-Nov-03 20:35 
    Hi,

    Found out that your program would be usefull to me to bypass my corporate architecture :
    My connection goes trough a tranparent PIX firewall to a proxy on port 80.
    I use to HTTP-tunnel, wich work perfectly (and without the need to specify my proxy IP (!))
    But I rely on an external server, which is obviously a not so good answer to my problem.
    I tried SSH and this is what I get :

    ********BEGUIN LOG************
    ----------------------------------------------
    S S H P R O X Y
    SOCKS Proxy Server -> HTTP SSL tunnel Master
    ----------------------------------------------
    Copyright (c) 1999 D-Bross www.d-bross.com

    Free for non-commercial use.
    ----------------------------------------------
    Params : None
    Config File : "config.txt"
    "config.txt": EnableLog=<yes/no>
    "config.txt": SOCKSPort=<PortNumber>
    "config.txt": UseSHttpProxy=<yes/no>
    "config.txt": SHttpProxyHost=<hostname/IP>
    "config.txt": SHttpProxyPort=<PortNumber>
    ----------------------------------------------
    USE of SHTTP Proxy Enabled.
    SHTTP Proxy Host : xx.xx.xx.xx
    SHTTP Proxy Port : 80
    ---------------------------------------
    Logging : On
    ---------------------------------------
    SOCKS Proxy Port : 1082
    ---------------------------------------
    SOCKS Server Created.
    SOCKS Server Started.
    SOCKS Server Listen at Port : 1082
    Connection from : <localhost/127.0.0.1:3904>
    Proxy Created.
    Proxy Started.
    Accepted SOCKS 5 Request.
    SOCKS 5 - Accepts Auth. method 'NO_AUTH'
    SOCKS 5 - Accepted SOCKS5 Command: "CONNECT"
    Connecting...
    Connected to <PROXY/xx.xx.xx.xx:80>
    Connected to <PROXY/xx.xx.xx.xx:80>
    SOCKS 5 - Reply to Client "SUCCESS"
    Initiating SSL Tunneling...
    SHTTP Proxy Reply : [HTTP/1.1 502 Proxy Error (... here I get a HTML code stating that ISA server is not configured to allow SSL trough the specified port, and that I should use 443...)

    ERROR : java.lang.Exception: Error Response from SHTTP Proxy !
    java.lang.Exception: Error Response from SHTTP Proxy !
    at socksshttp/CProxy.CreateSSLTunnel
    at socksshttp/CProxy.ProcessRelay
    at socksshttp/CProxy.run
    at java/lang/Thread.run
    Proxy Closed.

    ******END LOG****************

    I use port 80, cause port 8080 gives me the <NA/NABlush | :O ) error (I don't reach the proxy), and asumed that the proxy only listen to port 80 and choose then how to react between HTTP and HTTPS...

    I hope I don't have to settle a server on the other side to listen to port 443 and relay to the internet...

    Thanks for helping.

    GeneralProblem by surfing the internet Pin
    qingbo199914-Oct-03 23:42
    qingbo199914-Oct-03 23:42 
    Questionhow can I start SSHProxy ? Pin
    Member 2065249-Oct-03 22:59
    Member 2065249-Oct-03 22:59 
    GeneralCan't connect to &lt;NA/NA:0&gt; Invalid SOKCS version : 80 Pin
    scott7rj8-Oct-03 3:13
    scott7rj8-Oct-03 3:13 
    GeneralRe: Can't connect to &lt;NA/NA:0&gt; Invalid SOKCS version : 80 Pin
    Svetoslav Chekanov8-Oct-03 4:04
    Svetoslav Chekanov8-Oct-03 4:04 
    Generalerror connecting: SHTTP Proxy Reply : [[NNECT] Pin
    scott7rj8-Oct-03 2:44
    scott7rj8-Oct-03 2:44 
    GeneralRe: error connecting: SHTTP Proxy Reply : [[NNECT] Pin
    Svetoslav Chekanov8-Oct-03 3:39
    Svetoslav Chekanov8-Oct-03 3:39 
    GeneralTried it, but something wrong Pin
    J_N27-Aug-03 23:49
    J_N27-Aug-03 23:49 
    Generalstupid question... Pin
    bierbaer18-Aug-03 2:55
    bierbaer18-Aug-03 2:55 
    GeneralRe: stupid question... Pin
    Svetoslav Chekanov8-Oct-03 4:41
    Svetoslav Chekanov8-Oct-03 4:41 
    GeneralTCP via SHTTP mode problem Pin
    UpSa30-May-03 8:46
    UpSa30-May-03 8:46 
    GeneralRe: TCP via SHTTP mode problem Pin
    Svetoslav Chekanov30-May-03 22:13
    Svetoslav Chekanov30-May-03 22:13 
    GeneraleHTTP-SSL Tunnel Pin
    vechoor26-May-03 22:01
    vechoor26-May-03 22:01 
    GeneralPlease allow proxy authentication Pin
    Anonymous5-May-03 22:17
    Anonymous5-May-03 22:17 
    GeneralRe: Please allow proxy authentication Pin
    Anonymous23-Apr-04 22:14
    Anonymous23-Apr-04 22:14 
    GeneralNetwork Admin Pin
    spunmonkey30-Apr-03 21:13
    spunmonkey30-Apr-03 21:13 
    GeneralRe: Network Admin Pin
    Svetoslav Chekanov8-Oct-03 4:37
    Svetoslav Chekanov8-Oct-03 4:37 
    GeneralRe: Network Admin Pin
    savex16-Oct-03 10:03
    savex16-Oct-03 10:03 

    General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

    Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.