Click here to Skip to main content
15,881,803 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

     
    Questionm_lock Pin
    Member 1113075123-Sep-15 19:10
    Member 1113075123-Sep-15 19:10 
    AnswerRe: m_lock Pin
    Svetoslav Chekanov24-Feb-20 1:45
    Svetoslav Chekanov24-Feb-20 1:45 
    Questionhow to use Pin
    ShanLoly6-Feb-15 12:16
    ShanLoly6-Feb-15 12:16 
    AnswerRe: how to use Pin
    Svetoslav Chekanov24-Feb-20 1:48
    Svetoslav Chekanov24-Feb-20 1:48 
    QuestionAct as proxy in a special way? Pin
    AshesOfTime17-Jun-13 2:05
    AshesOfTime17-Jun-13 2:05 
    AnswerRe: Act as proxy in a special way? Pin
    Svetoslav Chekanov18-Jun-13 21:01
    Svetoslav Chekanov18-Jun-13 21:01 
    AnswerRe: Act as proxy in a special way? Pin
    ShanLoly6-Feb-15 12:17
    ShanLoly6-Feb-15 12:17 
    GeneralMy vote of 5 Pin
    Member 43208446-Jan-12 0:35
    Member 43208446-Jan-12 0:35 
    QuestionHow to change this application to a HTTPS proxy server? Pin
    shewo5-Dec-11 14:37
    shewo5-Dec-11 14:37 
    QuestionGetting Error Because of Proxy Authentication Required Pin
    WindowsVsLinux14-Nov-11 23:09
    WindowsVsLinux14-Nov-11 23:09 
    AnswerRe: Getting Error Because of Proxy Authentication Required Pin
    WindowsVsLinux15-Nov-11 3:31
    WindowsVsLinux15-Nov-11 3:31 
    GeneralRe: Getting Error Because of Proxy Authentication Required Pin
    WindowsVsLinux15-Nov-11 9:55
    WindowsVsLinux15-Nov-11 9:55 
    I tried in different style now. I got the RFC of SOCKS v5 authentication from http://tools.ietf.org/html/rfc1929. I applied it in this code, but still getting error

    400 BAD REQUEST

    Following is the modification done by me in CProxy.java file.

    Java
    public void CreateSSLTunnel() throws Exception {
            Log.Println("Initiating SSL Tunneling...");
            String user="username";
            String pass="password";
    
            Log.Println("Initiating Authentication...");
    
    //           Referenece http://tools.ietf.org/html/rfc1929
    //           +----+------+----------+------+----------+
    //           |VER | ULEN |  UNAME   | PLEN |  PASSWD  |
    //           +----+------+----------+------+----------+
    //           | 1  |  1   | 1 to 255 |  1   | 1 to 255 |
    //           +----+------+----------+------+----------+
    
            byte   ver        = 0x01;
            byte[] uname      = user.getBytes();
            byte[] passwd     = pass.getBytes();
            int    size       = 1 + uname.length + 1+ passwd.length +1;
    
            byte[] headerData = new byte[size];
            int    next       = 0;
    
            headerData[next] = ver;
    
            next++;
            headerData[next] = (byte) uname.length;
    
            next++;
    
            int i;
            for (i = 0; i < uname.length; i++) {
                headerData[next + i] = uname[i];
            }
    
            next             = next + i;
            headerData[next] = (byte) passwd.length;
            next++;
    
            int j;
            for (j = 0; j < passwd.length; j++) {
                headerData[next + j] = passwd[j];
            }
            SendToServer(headerData);
            String cmd  = "CONNECT " + Host + ":" + comm.m_nServerPort + " HTTP/1.0" + EOL + EOL;
            SendToServer(cmd.getBytes());


    What next can be done? Reply. I want to implement authentication in it.
    GeneralMy vote of 5 Pin
    WindowsVsLinux13-Nov-11 12:01
    WindowsVsLinux13-Nov-11 12:01 
    GeneralDNS Query Pin
    kshitij22325-Mar-10 21:43
    kshitij22325-Mar-10 21:43 
    Questionhow to run this project & to see how it works Pin
    nuthanhebbar11-Jan-09 20:16
    nuthanhebbar11-Jan-09 20:16 
    AnswerRe: how to run this project & to see how it works Pin
    Svetoslav Chekanov28-Mar-11 20:20
    Svetoslav Chekanov28-Mar-11 20:20 
    GeneralRe: how to run this project & to see how it works Pin
    reinerotto2-Sep-11 3:23
    reinerotto2-Sep-11 3:23 
    QuestionHow do I run the applet? Pin
    Darklomba1-Aug-07 10:44
    Darklomba1-Aug-07 10:44 
    AnswerRe: How do I run the applet? Pin
    Syed Mohammed Khawar27-Mar-11 20:59
    Syed Mohammed Khawar27-Mar-11 20:59 
    GeneralRe: How do I run the applet? Pin
    Svetoslav Chekanov28-Mar-11 20:16
    Svetoslav Chekanov28-Mar-11 20:16 
    AnswerRe: How do I run the applet? Pin
    Svetoslav Chekanov28-Mar-11 20:17
    Svetoslav Chekanov28-Mar-11 20:17 
    Generalprotocol detailed specifications Pin
    avinu28-Jul-07 21:58
    avinu28-Jul-07 21:58 
    QuestionHTTP Tunnel Pin
    Priyanka Bindumahavan29-Jan-07 22:26
    Priyanka Bindumahavan29-Jan-07 22:26 
    AnswerRe: HTTP Tunnel Pin
    sv_chekanov11-Jan-09 21:06
    sv_chekanov11-Jan-09 21:06 
    GeneralNew problem.. need help. Pin
    addagol14-Dec-06 2:52
    addagol14-Dec-06 2:52 

    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.