Overview
Examples
Screenshots
Comparisons
Applications
Download
Documentation
Tutorials
Bazaar
Status & Roadmap
FAQ
Authors & License
Forums
Funding Ultimate++
Search on this site
Search in forums












SourceForge.net Logo
Home » U++ Library support » U++ MT-multithreading and servers » SSH package for U++ (A feature-rich ilbssh2 wrapper for Ultimate++)
SSH package for U++ [message #48973] Tue, 14 November 2017 21:59 Go to next message
Oblivion is currently offline  Oblivion
Messages: 1091
Registered: August 2007
Senior Contributor
Hello guys,

I am officially announcing the release of "beta" version of SSH package.
Package is tested on Arch Linux (Kernel: 4.13, GCC 7.2) and Windows (7/10, MinGW 7.2/MSC 14 (2017))

SSH package for U++
--------------------
SSH package is a feautre-rich, flexible yet very easy to use libssh2 wrapper for Ultimate++.
It supports both console and GUI-based applications on POSIX-compliant operating systems and
MS Windows (tm).

Currently it is in beta (version 1) stage.

Classes:
--------------------

- Base (core) class  -> Ssh
  - Ssh session        -----> SshSession
  - Sftp subsystem     -----> SFtp
  - Ssh channel        -----> SshChannel
      - Scp channel                 -----> Scp
      - Exec channel                -----> SshExec
      - Real-time interactive shell -----> SshShell
      - X11 forwarding              -----> SshShell (as operation mode)      
      - Tcp/IP and port forwarding  -----> SshTunnel

- Known hosts manager -> SshHosts

Features and Highlights:
--------------------

- Ssh-derived classes have pick semantics, based on RAII principle, support RTTI, and allow
  polymorphism (i.e. different classes can be stored in the same arrays, etc.) through a common
  interface. 
- Uses U++ memory allocators (Native allocators is also a compile-time option)
- Uses OpenSSL by default. 
- Supports time-constrained, blocking and non-blocking operation modes.
- Supoorts multithreaded file transfers and remote command execution (exec), using worker threads.
- Supports 3rd-party network proxies. (Such as NetProxy)
- Supports known hosts verification mechanism.
- Supports password, public key, host-based, and keyboard-interactive authentication methods.
- Supports ssh-agents.
- Supports real-time interactive command line (shell) interface with both console and GUI integration (works on Windows and Posix-compliant OS'es)
- Supports multiple X11 connection forwarding.
- Supports Tcp/IP and port forwarding.
- Supports detailed (full) debug logging.

Todo:
--------------------
- Add more high level methods.
- Refactor Ssh (core) class.
- Improve documentation.

Reference examples:
-------------------

- SFtpGet:           Demonstrates basic SFtp file download in blocking mode.
- SFtpGetNB:         Demonstrates basic SFtp file download in non-blocking mode.
- SFtpGetMT:         Demonstrates basic SFtp file download, using a worker thread.
- SFtpGUI:           Demonstrates a basic SFtp browser with GUI (with upload, download, mkdir, rename, delete commands).
- SFtpMultiGetMT:    Demonstrates SFtp dir listing and concurrent file transfers, using worker threads.
- SFtpConsumerGet:   Demonstrates the usage of a consumer function for SFtp download in blocking mode.
- SFtpConsumerGetMT: Demonstrates the usage of a consumer function for SFtp download, using a worker thread.
- SshExec:           Demonstrates basic Ssh remote command execution in blocking mode.
- SshExecNB:         Demonstrates basic Ssh remote command execution in non-blocking mode.
- SshExecMT:         Demonstrates basic Ssh remote command execution, using a worker thread.
- SshKeyboardAuth:   Demonstrates basic Ssh interactive (challenge-response) authentication method in blocking mode.
- SshLoggingExample: Demonstrates the logging capabilities of SSH package.
- SshOverTor:        Demonstrates a basic Ssh connection over TOR, using a third-party network proxy adapter.
- SshPolymorphismNB: Demonstrates the polymorphism capability of SSH channels in non-blocking mode.
- SshShell:          Demonstrates a basic, real-time SSH shell console in blocking mode.
- SshShellNB:        Demonstrates a basic, real-time SSH shell console in non-blocking mode.    
- SshShellX11:       Demonstrates a basic, real-time SSH shell console with multiple X11 forwarding.
- SshShellGUI:       Demonstrates the basic GUI integration of SshShell class with multiple X11 forwarding, in non-blocking mode.
- SshTunnelExample:  Demonstrates the basic SSH tunneling (as tunnel/server) in blocking mode.




Below you can find the latest package and the GIT address where you can always get the latest version.

GIT repo: https://github.com/ismail-yilmaz/upp-components/tree/master/ Core/SSH
Examples: https://github.com/ismail-yilmaz/upp-components/tree/master/ Examples
Older Version: https://github.com/ismail-yilmaz/upp-components/tree/master/ Attic/SSH

I appreciate bug reports, reviews, criticism, patches etc.

Best regards,
Oblivion



[Updated on: Sat, 16 June 2018 19:05]

Report message to a moderator

Re: SSH package for U++ [message #48982 is a reply to message #48973] Fri, 17 November 2017 22:15 Go to previous messageGo to next message
Oblivion is currently offline  Oblivion
Messages: 1091
Registered: August 2007
Senior Contributor
Hello,

I am currenty writing a simple SFTP (GUI) browser example, which I will include in the package, and upload it to GIT repo.
In the meantime, for those who wonder how to do non-blocking operations with SFtp, here is a simple example (it is a real example which can be compiled.):

#include <Core/Core.h>
#include <SSH/SSH.h>

using namespace Upp;

CONSOLE_APP_MAIN
{
    // This example demonstrates (in non-blocking mode):
    // 1) Reading the size of a file.
    // 2) Reading the content of a file (into a String).
    // 3) Reading the content of a directory as XML.

    int CMD_GET = 0, CMD_LIST = 0, CMD_SIZE = 0;
    const char *file = "/readme.txt";
    SFtp::DirList ls;

    Ssh::Trace();
    SshSession session;
    if(session.Timeout(30000).Connect("test.rebex.net", 22, "demo", "password")) {
        Array<SFtp> sftps;
        for(int i = 0; i < 3; i++) {
            auto& sftp = sftps.Add(new SFtp(session));
            sftp.NonBlocking();
            switch(i) {
                case 0: sftp.Get(file);  CMD_GET = sftp.GetId(); break;
                case 1: sftp.GetSize(file);  CMD_SIZE = sftp.GetId(); break;
                case 2: sftp.ListDir("/pub/example/", ls); CMD_LIST = sftp.GetId(); break;
                default: NEVER();
            }
        }
        while(!sftps.IsEmpty()) {
            for(int i = 0 ; i < sftps.GetCount(); i++) {
                SocketWaitEvent we;
                auto& sftp = sftps[i];
                sftp.AddTo(we);
                we.Wait(10);
                if(!sftp.Do()) {
                    if(sftp.IsError())
                        Cerr() << sftp.GetErrorDesc() << '\n';
                    else {
                        if(sftp.GetId() == CMD_GET) {
                            Cout() << sftp.GetResult();
                        }
                        else
                        if(sftp.GetId() == CMD_SIZE) {
                            Cout() << Format("Size of %s is %d bytes\n", file, sftp.GetResult());
                        }
                        else
                        if(sftp.GetId() == CMD_LIST) {
                            for(auto& e : ls)
                                Cout() << e.ToXml() << '\n';
                        }
                    }
                    sftps.Remove(i);
                    break;
                }
            }
        }
    }
    else
        Cerr() << session.GetErrorDesc();

}


Best regards,
Oblivion


[Updated on: Fri, 17 November 2017 22:19]

Report message to a moderator

Re: SSH package for U++ [message #48986 is a reply to message #48973] Sat, 18 November 2017 15:57 Go to previous messageGo to next message
Oblivion is currently offline  Oblivion
Messages: 1091
Registered: August 2007
Senior Contributor
Hello,

SSH package is updated.
Package now contains six basic examples.
These examples demonstrate file transfer (get) and remote command execution (exec) in blocking, non-blocking (NB) modes, and using worker threads (MT)

- SFtpGet
- SFtpGetNB
- SFtpGetMT

- SshExec
- SshExecNB
- SshExecMT


You can find the updated package and the address of related GIT repo in the first message of this topic.

Best regards,
Oblivion


[Updated on: Sat, 18 November 2017 15:57]

Report message to a moderator

Re: SSH package for U++ [message #48993 is a reply to message #48973] Sun, 19 November 2017 18:21 Go to previous messageGo to next message
Oblivion is currently offline  Oblivion
Messages: 1091
Registered: August 2007
Senior Contributor
Hello,

SSH package and examples are updated. This update fixes a critical bug in libssh2, which leads to heap leaks. I strongly recommend the update.

Also SFtp gained two useful methods:

- GetCurrentDir()
- GetParentDir()


Bug reports, patches, criticism, suggestions, or any questions are always welcome.

You can always find the updated package and the address of its GIT repo in the first message of this topic.

Best regards,
Oblivion


[Updated on: Sun, 19 November 2017 18:22]

Report message to a moderator

Re: SSH package for U++ [message #49000 is a reply to message #48973] Tue, 21 November 2017 00:38 Go to previous messageGo to next message
Oblivion is currently offline  Oblivion
Messages: 1091
Registered: August 2007
Senior Contributor
Hello,

SSH package & examples are updated.
Package gained 2 new examples. One is simple, other is relatively complex.


SshKeyboardAuth: Demonstrates SSH keyboard interactive (challange/response) authentication method.

SFtpMultiGet:    Demonstrates download of multiple files simultaneously in SFTP non-blocking mode (non MT).


Bug reports, patches, criticism, suggestions, or any questions are always welcome.

You can always find the updated package and the address of its GIT repo in the first message of this topic.

Best regards,
Oblivion


[Updated on: Tue, 21 November 2017 00:39]

Report message to a moderator

Re: SSH package for U++ [message #49001 is a reply to message #49000] Thu, 23 November 2017 09:07 Go to previous messageGo to next message
koldo is currently offline  koldo
Messages: 3354
Registered: August 2008
Senior Veteran
Smile

Best regards
Iñaki
Re: SSH package for U++ [message #49008 is a reply to message #48973] Fri, 24 November 2017 21:03 Go to previous messageGo to next message
Oblivion is currently offline  Oblivion
Messages: 1091
Registered: August 2007
Senior Contributor
Hello,

SSH package is updated.

New method:
bool SshSession::Connect(const String& url)
--------------------------------------------
Connects to a SSH2 server specified by the url. Returns true on success. 
Syntax of the URL is as follows:  

[ssh|scp|sftp|exec]://[user:password@]host[:port]


In time, the syntax will be improved (optional args will be added.)

Also a new example (SFtpMultiGetMT) is added to the examples.
This example downloads 4 files asynchronously, using worker threads, and is the multithreaded counterpart of SFtpMultiGetNB (non-blocking).
It also demonstrates the capabilities of the U++ AsyncWork worker threads.



Bug reports, patches, criticism, suggestions, or any questions are always welcome.

You can always find the updated package and the address of its GIT repo in the first message of this topic.

Best regards,
Oblivion


[Updated on: Fri, 24 November 2017 21:06]

Report message to a moderator

Re: SSH package for U++ [message #49013 is a reply to message #49008] Sun, 26 November 2017 04:51 Go to previous messageGo to next message
alkema_jm is currently offline  alkema_jm
Messages: 25
Registered: November 2015
Promising Member
Hello Oblivion

>suggestions

Maybe that swish can offer some functionality? N.B. Proper Windows Explorer integration.
Description

Access your remote files over SFTP directly from Windows Explorer and 'My Computer'.
https://sourceforge.net/projects/swish/

Easy SFTP for Windows
Swish adds support for SFTP to Windows Explorer so you can access your files on another computer securely via SSH.

Swish is easy to use because it integrates seamlessly with Windows Explorer so working with remote files feels just like working with the ones on your local computer.

We believe Swish is a better option for typical Windows users than other SFTP clients because it is so easy to use. Download it now and decide for yourself.

http://www.swish-sftp.org/

Features
• SFTP file transfer
• Proper Windows Explorer integration

Greetings Jan Marco
Re: SSH package for U++ [message #49014 is a reply to message #49013] Sun, 26 November 2017 09:59 Go to previous messageGo to next message
Oblivion is currently offline  Oblivion
Messages: 1091
Registered: August 2007
Senior Contributor
Hello Jan Marco,

Thank you very much for your comments and suggestions. Smile

I've tested swish and it does a decent job for sure.

However, I believe SSH package and swish do not fall under the same categories. Their scope and intended audience seems to be different.


From its website: "Swish is a plugin for Microsoft Windows Explorer that adds support for SFTP."

It is a decent plugin for Windows Explorer, it falls under applications/plugins category, if I may.

Naturally, it is limited to Windows platform, and as far as I can understand, it uses OpenSSL exclusively.

And it seems to be limited to SFTP subsystem.



On the other hand SSH package isn't an app or plugin written by U++. It is an easy to use SSH2 library (it covers full SSH2 ecosystem: Sftp, channels, exec, scp, shell, agents) for U++, and its intended audience is exclusively U++ developers.

SSH uses libssh2 under the hood. libssh2 is a widely used and extensively tested, multiplatform SSH2 library with BSD license. SSH package supports what libssh2 supports.

Therefore SSH package is not limited to windows. In fact, it isn't developed on windows. In theory SSH package can run on what U++ and libssh2 can run on and this includes, but not limited to, Linux and Windows.

Also, while SSH package uses OpenSSL by default, it is also possible to use it with WinCNG and GnuTLS. (Currently through a config file, in the near future via compiler flag.)

In fact there is nothing that prevents a developer to come up with a similar plugin to swish, using SSH pacakge.(Maybe it'll take a lot less time to develop one using SSH package, since the main purpose of SSH package is to let developers focus on other aspects of their apps.)

One major advantage (for commercial app developers) of SSH package over swish is that SSH package (and underlying libssh2) uses BSD license.


To sum up:

1) Swish offers good functionality, but the functionality it offers is mostly on application-level. Hence they should be implemented by the application developers (using SSH package).
2) Writing some example app similar to swish would be platform specific. Therefore I am writing a simple SFtpBrowser example, which will work on any platform that U++ supports. Smile


Best regards,
Oblivion


[Updated on: Sun, 26 November 2017 11:24]

Report message to a moderator

Re: SSH package for U++ [message #49027 is a reply to message #49014] Thu, 30 November 2017 23:55 Go to previous messageGo to next message
alkema_jm is currently offline  alkema_jm
Messages: 25
Registered: November 2015
Promising Member
Hello Oblivion,

Today I made a Visio diagram of the different configurations of Swish and FileZilla in relation to SSH-Ultimate++.

Greetings Jan Marco

index.php?t=getfile&id=5444&private=0
Re: SSH package for U++ [message #49029 is a reply to message #49027] Fri, 01 December 2017 12:33 Go to previous messageGo to next message
alkema_jm is currently offline  alkema_jm
Messages: 25
Registered: November 2015
Promising Member
Hello Oblivion ,

>Thank you very much for your comments and suggestions.

Thank you that you ask feedback Razz

>I've tested swish and it does a decent job for sure.

I tried (/test) to compile Swish. At one point i could start it, but it crasht.

> However, I believe SSH package and swish do not fall under the same categories. Their scope and intended audience seems to be different.

Ok, I think in software components. I like the Windows Explorer integration of Swish only.

>From its website: "Swish is a plugin for Microsoft Windows Explorer that adds support for SFTP."
It is a decent plugin for Windows Explorer, it falls under applications/plugins category, if I may.

Yes, I like Microsoft Windows Explorer integration part of Swish.

>Naturally, it is limited to Windows platform, and as far as I can understand, it uses OpenSSL exclusively.

I don't like. "One size fits all". Some solutions (for example Microsoft Windows Explorer integration) can be better in specific (native) solutions.

>And it seems to be limited to SFTP subsystem.

The FileZilla engine 'uses' more protocols (storj) :
index.php?t=getfile&id=5445&private=0

> On the other hand SSH package isn't an app or plugin written by U++. It is an easy to use SSH2 library (it covers full SSH2 ecosystem: Sftp, channels, exec, scp, shell, agents) for U++, and its intended audience is exclusively U++ developers.

I like the SSH2 econsystem very much Razz

> SSH uses libssh2 under the hood. libssh2 is a widely used and extensively tested, multiplatform SSH2 library with BSD license. SSH package supports what libssh2 supports.

Ok, You limit SSH package to "libssh2"?

> Therefore SSH package is not limited to windows. In fact, it isn't developed on windows. In theory SSH package can run on what U++ and libssh2 can run on and this includes, but not limited to, Linux and Windows.

I think it is usefull to think in interfaces (and api) of software components. I separated the (General) FileZilla engine code. I will try to interface with libssh2 (SSH package). I haven't look in the libssh2 code if it is possible.

> Also, while SSH package uses OpenSSL by default, it is also possible to use it with WinCNG and GnuTLS. (Currently through a config file, in the near future via compiler flag.)

FileZilla uses GnuTLS.

> In fact there is nothing that prevents a developer to come up with a similar plugin to swish, using SSH pacakge.(Maybe it'll take a lot less time to develop one using SSH package, since the main purpose of SSH package is to let developers focus on other aspects of their apps.)

I like your SSH package very much, because it Works Razz

> One major advantage (for commercial app developers) of SSH package over swish is that SSH package (and underlying libssh2) uses BSD license.

I am not a company. Licenses are not very interesting subject for me.

> To sum up:

>1) Swish offers good functionality, but the functionality it offers is mostly on application-level. Hence they should be implemented by the application developers (using SSH package).

Ok.

2) Writing some example app similar to swish would be platform specific. Therefore I am writing a simple SFtpBrowser example, which will work on any platform that U++ supports.

Ok, a simple example is alway usefull to see that it Works. I think that a more complex example als FileZilla is not difficult to migrate to Ultimate++.

Greetings Jan Marco
Re: SSH package for U++ [message #49030 is a reply to message #49029] Fri, 01 December 2017 14:35 Go to previous messageGo to next message
Oblivion is currently offline  Oblivion
Messages: 1091
Registered: August 2007
Senior Contributor
Hello Jan Marco,

I really appreciate you feedback. Thank you very much!


Quote:
The FileZilla engine 'uses' more protocols (storj) :


We already have HTTP(S)(HttpRequest class does that) and FTP(S). Have you looked at the FTP package that I wrote? ( https://www.ultimatepp.org/forums/index.php?t=msg&th=889 9&goto=43053&#msg_43053)
It covers FTP, and FTPS (FTP over explicit TLS/SSL). Check the video too. It shows what it is capable of: (https://vimeo.com/214530673)

The only protocol we seem to lack is StorJ, which is not really hard to implement. Maybe I should add it to my Todo list. Smile

Quote:
Ok, a simple example is alway usefull to see that it Works. I think that a more complex example als FileZilla is not difficult to migrate to Ultimate++.


FTP class I mentioned above contains an example called FtpBrowser. That example will eventually evolve into a MultiBrowser (FTP(S)/SFtp/HTTP(S)) after I finalized the SSH package.
(In fact it contains a package called BrowserCtrl, which is meant to be a gui-frontend for filesystem-agnostic file browsers).
So while I'm not going to port filezilla to U++ (it'll need a lot of work), I'll come up with a simpler remote file browser demo. Smile


Best regards,
Oblivion


[Updated on: Fri, 01 December 2017 14:39]

Report message to a moderator

Re: SSH package for U++ [message #49032 is a reply to message #49030] Sat, 02 December 2017 09:29 Go to previous messageGo to next message
alkema_jm is currently offline  alkema_jm
Messages: 25
Registered: November 2015
Promising Member
Hello Oblivion,

> We already have HTTP(S)(HttpRequest class does that) and FTP(S).

Ok.

> Have you looked at the FTP package that I wrote? ( https://www.ultimatepp.org/forums/index.php?t=msg&th=889 9&goto=43053&#msg_43053)

No, but I looked now.

>- Support for extending the functionality of Ftp class, using the low-level SendCommand() method.

I think that SendCommand has other meaning then the SendCommand of the FileZilla engine. FileZilla sends commands to the loaded executable Fzftp.exe. Fzftp.exe is derived from Putty project.

> It covers FTP, and FTPS (FTP over explicit TLS/SSL). Check the video too. It shows what it is capable of: (https://vimeo.com/214530673)

Seems good implementation. Video doesn't have sound/speech.

> FTP class I mentioned above contains an example called FtpBrowser. That example will eventually evolve into a MultiBrowser (FTP(S)/SFtp/HTTP(S)) after I finalized the SSH package. (In fact it contains a package called BrowserCtrl, which is meant to be a gui-frontend for filesystem-agnostic file browsers).

Ok. You implement what other (platforms) already have. I think it is better to implement something new, for example TOR integration. I put 'all' TOR code in 1 file (207329 lines of cpp code).

> The only protocol we seem to lack is StorJ, which is not really hard to implement. Maybe I should add it to my Todo list.

Oblivion, Is it possible to add t (for Tor) after protocol Info name, Like 'sftpt' for sftp over TOR network:
index.php?t=getfile&id=5446&private=0

I don't know how to go to TOR implementation. Implement Libssh2 routines to the TOR implementation. I have not studie. Maybe put packets on TOR-socket?

> So while I'm not going to port filezilla to U++ (it'll need a lot of work), I'll come up with a simpler remote file browser demo.

I am trying to make a proof of concept of seperate Filezilla in three parts. GUI, engine and infrastructure code.

Greetings Jan Marco
Re: SSH package for U++ [message #49033 is a reply to message #49032] Sat, 02 December 2017 10:44 Go to previous messageGo to next message
Oblivion is currently offline  Oblivion
Messages: 1091
Registered: August 2007
Senior Contributor
Hello Jan Marco,

Quote:
I think that SendCommand has other meaning then the SendCommand of the FileZilla engine. FileZilla sends commands to the loaded executable Fzftp.exe. Fzftp.exe is derived from Putty project.


Sure, Ftp::SendCommand() is simply a convenient way to send control commands that aren't already covered by the FTP package.


Quote:
Ok. You implement what other (platforms) already have.


Think of it this way: I am implementing what I think Ultimate++ lacks (and what I need in U++). After all, these packages are meant to be used in U++ applications.
By the way, recently I set up a GIT address where I upload 3rd party packages I wrote for U++. There are only several packages in the repo now but it will grow in time, once I clean up and publish the library I personally use: https://github.com/ismail-yilmaz/upp-components

Quote:
I don't know how to go to TOR implementation. Implement Libssh2 routines to the TOR implementation. I have not studie. Maybe put packets on TOR-socket?


I have good news and (somewhat) bad news: TOR is on my todo list (with WEBDAV, OAuth2, etc...), but it isn't an easy-to-implement protocol.
However "in theory" (I didn't actually test it) it is possible to use it, without writing a whole TOR client.

There is a package called NetProxy (it is a Https/Socks4/4a/5 proxy adapter for U++) which, again, I wrote: https://www.ultimatepp.org/forums/index.php?t=msg&th=101 32&start=0&
AFAIK, Tor client (not the browser, but the background process) can be configured to be used as a SOCKS proxy.
And SSH package already supports proxied connections (through WhenProxy callback, in which you hand over the TcpSocket handle to NetProxy, and let it connect for you via a proxy server).
So if you can configure the Tor client to act as a socks 5 proxy, then, "in theory", you may be able use SSH package through it. (or any other app that is designed to support NetProxy).

Best regards,
Oblivion


[Updated on: Sat, 02 December 2017 10:45]

Report message to a moderator

Re: SSH package for U++ [message #49036 is a reply to message #49033] Sun, 03 December 2017 08:35 Go to previous messageGo to next message
alkema_jm is currently offline  alkema_jm
Messages: 25
Registered: November 2015
Promising Member
Hello Oblivion,

> Think of it this way: I am implementing what I think Ultimate++ lacks (and what I need in U++). After all, these packages are meant to be used in U++ applications.

You did a very good job to make the packages for Ultimate++. I like to re use as much as possible. I don't like to 'reinvent weels'.

> By the way, recently I set up a GIT address where I upload 3rd party packages I wrote for U++.

I use github a lot to retrieve source code. All ('living') projects are on github. Razz

> There are only several packages in the repo now but it will grow in time, once I clean up and publish the library I personally use: https://github.com/ismail-yilmaz/upp-components

I like Fossil program/concept (https://www.fossil-scm.org/xfer/timeline). Last two weeks of this year i will try to merge it with Ultimate++.

> I have good news and (somewhat) bad news: TOR is on my todo list (with WEBDAV, OAuth2, etc...), but it isn't an easy-to-implement protocol.

Ok. I like good news Razz

> However "in theory" (I didn't actually test it) it is possible to use it, without writing a whole TOR client.

https://tor.stackexchange.com/questions/3421/route-c-through -tor-using-socks :

Tor is a socks5 proxy.
here is the socks5 rfc Protocol is https://www.ietf.org/rfc/rfc1928.txt
here is a guide to how socks5 works with tor https://samsclass.info/122/proj/how-socks5-works.html read this, it is VERY useful

if using sockets (I assume c++ uses sockets) you will need to
1. connect to tor (127.0.0.1:9050 by default)
2. Send authentication (5,1,0) see rfc part 3
3. Receive the tor response (5,0) see rfc part 3
4. Send Client's Connection request (5,1,0,3 + host length + a binary representation of the host and port) see rfc part 4
5. receive the tor response (5,0,0,1,0,0,0,0,0,0) see rfc part 6 (there can be a bunch of errors here, so watch out)
6. Send a binary representation of a http request to tor (Tor will forward this to the destination)
7. Receive the http response (will send the header first then the web page)

> There is a package called NetProxy (it is a Https/Socks4/4a/5 proxy adapter for U++) which, again, I wrote: https://www.ultimatepp.org/forums/index.php?t=msg&th=101 32&start=0&

Ok, Looks very promising Razz

So if you can configure the Tor client to act as a socks 5 proxy, then, "in theory", you may be able use SSH package through it. (or any other app that is designed to support NetProxy).

> I see in "Tor is a socks5 proxy" on https://tor.stackexchange.com/questions/3421/route-c-through -tor-using-socks

> AFAIK, Tor client (not the browser, but the background process) can be configured to be used as a SOCKS proxy.

In de Tor logging it see "Opening Socks listener on 127.0.0.0:9050"

> And SSH package already supports proxied connections (through WhenProxy callback, in which you hand over the TcpSocket handle to NetProxy, and let it connect for you via a proxy server).

Oblivion, Must I insert NetProxy source code in Filezilla.exe or Tor.exe? N.B. My Tor.exe is the program to connect to the Tor-network. And has a sock listerer port on localhost port 9050.

Greetings Jan Marco

Appendix FileZilla client:
index.php?t=getfile&id=5449&private=0

[Updated on: Sun, 03 December 2017 14:00]

Report message to a moderator

Re: SSH package for U++ [message #49041 is a reply to message #49036] Mon, 04 December 2017 19:01 Go to previous messageGo to next message
alkema_jm is currently offline  alkema_jm
Messages: 25
Registered: November 2015
Promising Member
Hello Oblivion,

>I have good news and (somewhat) bad news: TOR is on my todo list (with WEBDAV, OAuth2, etc...), but it isn't an easy-to-implement protocol.

Good news: FileZilla has a build in (general) Proxy server, which can be used by TOR

See https://forum.filezilla-project.org/viewtopic.php?t=1398 and https://forum.filezilla-project.org/viewtopic.php?t=283

Greetings Jan Marco

index.php?t=getfile&id=5451&private=0


Re: SSH package for U++ [message #49042 is a reply to message #49041] Mon, 04 December 2017 22:46 Go to previous messageGo to next message
Oblivion is currently offline  Oblivion
Messages: 1091
Registered: August 2007
Senior Contributor
Hello Jan Marco,

Below is a simple example demonstrating the most basic way to connect to an ssh server via TOR protocol, using SSH package. (Naturally, it requires NetProxy package):

#include <Core/Core.h>
#include <SSH/SSH.h>
#include <NetProxy/NetProxy.h>

using namespace Upp;

CONSOLE_APP_MAIN
{
	// This example requires a running TOR daemon.
	// Change below strings to your preferred values.
	
	const char* ssh_host = "dummysshhostname";
	const char* ssh_user = "dummysshusername";
	const char* ssh_pass = "dummysshpassword";
	int         ssh_port = 22;
	
	StdLogSetup(LOG_FILE|LOG_COUT);
	Ssh::Trace();
	NetProxy::Trace();
	
	SshSession session;
	session.WhenProxy = [=, &session] {
		return NetProxy(session.GetSocket(), "127.0.0.1", 9050)
		            .Timeout(30000)
		            .Socks5()
		            .Auth("none", "none")
		            .Connect(ssh_host, ssh_port);
	};
	
	if(session.Timeout(60000).Connect(ssh_host, ssh_port, ssh_user, ssh_pass)) {
		LOG("Successfully connected to " << ssh_host << " (over TOR)");
	}
	else
		LOG("Ssh connection via TOR failed. " << session.GetErrorDesc());
}




Best regards,
Oblivion


Re: SSH package for U++ [message #49046 is a reply to message #49042] Fri, 08 December 2017 11:22 Go to previous messageGo to next message
alkema_jm is currently offline  alkema_jm
Messages: 25
Registered: November 2015
Promising Member
Hello Oblivion,

Thank you for the source code.
I made a flow diagram in Visio:
index.php?t=getfile&id=5453&private=0

Greetings Jan Marco
Re: SSH package for U++ [message #49070 is a reply to message #48973] Wed, 13 December 2017 17:46 Go to previous messageGo to next message
alkema_jm is currently offline  alkema_jm
Messages: 25
Registered: November 2015
Promising Member
Hello Oblivion,

> So while I'm not going to port filezilla to U++ (it'll need a lot of work), I'll come up with a simpler remote file browser demo.

FileZilla engine parses filestem info depending on Operating System.
bool ParseAsUnix(CLine &line, CDirentry &entry, bool expect_date);
bool ParseAsDos(CLine &line, CDirentry &entry);
bool ParseAsEplf(CLine &line, CDirentry &entry);
bool ParseAsVms(CLine &line, CDirentry &entry);
bool ParseAsIbm(CLine &line, CDirentry &entry);
bool ParseOther(CLine &line, CDirentry &entry);
bool ParseAsWfFtp(CLine &line, CDirentry &entry);
bool ParseAsIBM_MVS(CLine &line, CDirentry &entry);
bool ParseAsIBM_MVS_PDS(CLine &line, CDirentry &entry);
bool ParseAsIBM_MVS_PDS2(CLine &line, CDirentry &entry);
bool ParseAsIBM_MVS_Migrated(CLine &line, CDirentry &entry);
bool ParseAsIBM_MVS_Tape(CLine &line, CDirentry &entry);
int ParseAsMlsd(CLine &line, CDirentry &entry);
bool ParseAsOS9(CLine &line, CDirentry &entry);

I made a Visio diagram how I see the connection between SSH en SSH-server. I want to use https://github.com/PowerShell/Win32-OpenSSH because it compilers/links in vs2015:

index.php?t=getfile&id=5454&private=0

There are a lot of info en Queue programs. I am looking First at librdkafka, maybe there are better ones.

https://content.pivotal.io/rabbitmq/understanding-when-to-us e-rabbitmq-or-apache-kafka

librdkafka is a C library implementation of the Apache Kafka protocol, containing both Producer and Consumer support. It was designed with message delivery reliability and high performance in mind, current figures exceed 1 million msgs/second for the producer and 3 million msgs/second for the consumer.
librdkafka is licensed under the 2-clause BSD license. https://github.com/edenhill/librdkafka

Maybe you have some advise or feedback Smile

Greetings Jan Marco

[Updated on: Wed, 13 December 2017 17:47]

Report message to a moderator

Re: SSH package for U++ [message #49106 is a reply to message #49070] Tue, 19 December 2017 14:27 Go to previous messageGo to previous message
Oblivion is currently offline  Oblivion
Messages: 1091
Registered: August 2007
Senior Contributor
Hello Jan Marco,

Sorry I couldn't reply to you earlier.

I may be able to help but I'd need to know what you really want to achive. A server, client, or client-server?

Quote:

There are a lot of info en Queue programs. I am looking First at librdkafka, maybe there are better ones.


I'd never heeard of this one before. Could you elaborate on why you need this?

Best regards,
Oblivion


Previous Topic: WebSockets client in javascript connected to an U++ server sending binary messages
Next Topic: TURTLE high cpu usage, potential security flaw, and client handling problem
Goto Forum:
  


Current Time: Thu Mar 28 12:17:38 CET 2024

Total time taken to generate the page: 0.01276 seconds