I am currently evaluating SecureBlackBox especially TElSSHLocalPortForwarding, and I would like to say that it is a great software.

What I am currently trying to achieve is creating an SSH tunnel with Local Port Forwarding through a HTTPs Proxy Server.

The sample LocalPortForwardDemo program (modified a bit to use HTTPs Tunneling) works as expected, but I want to be able to read and modify the net data being sent or received by the component. How and where can I do this?

My work around is adding an Indy TIdMappedPortTCP, point the webTunnelPort of the TElSSHLocalPortForwarding to TidMappedPortTCP Binding Port, and read/modify the net data using onExecute and onOutBoundData event in the TIdMappedPortTCP.

In the LocalPortForwarding sample there' ForwardingMain.pas unit. In this unit there's TSSHForwardingThread class where all the magic happens. The methods of this thread read the data from one side and write it to another side. And that's where you can insert your modification logic.

I was testing the SimplePortForwarding demo, and all I need is there except the read and modify data part. I will start studying the AdvancedPortForwarding demo.

Mean while, can you point me the direction if I want to use the SimplePortForwarding instead as a starting point for that specific purpose (read and modify net data) because it's a lot simpler than the Advanced demo. I don't need any other functionality, only the forwarding, HTTPS Tunneling and data modification part.

I am afraid there's no way to do what you need with simple* components for the exact reason that they are *simple*. For non-trivial and rare operations we offer those advanced (lower-level) components.

Ok, thank you for the confirmation. I will study the advanced sample deeper.

One more question though, When I was testing the SimplePortForwarding Demo, the SSH Connection keep on closed unexpectedly and randomly after some period of time.

I have been limiting the connection number to no more then 8 channels opened.
I am pretty sure it's not time based limitation. Downloading files didn't trigger the disconnection, but I always failed to upload. I am guessing that the connection closed automatically after some amount of data sent to the server.
There wasn't any error triggered and the server didn't close the connection.

It's possible that this behavior is due to trial limitations, yes. You can request the time-limited key here. This key is similar to production keys issued for licensed customers, other than it has a hardcoded expiration date.

But the problem persists, I used the SimplePortForwarding demo program as is. the modification I've made are:
1. set the UseDynamicForwarding to true;
2. set the useWebTunneling to true;
3. Set the WebTunneling's address and port;
4. set the onConnectionSocksAuthMethodChoose event;
5. set the license key on the initialization part.

What I did
1. I browsed some web page and the SSH Connection closed by itself after some time
2. I do a 10 MBs file download right after the SSH Connection opened, the operation went successfully
3. Do a 5 MBs file upload, the SSH Connection stopped in the middle of the upload operation
4. Do a speed test using public speed test facility (speedtest.net, speedtest.telin.us), failed in the uploading test.

Update:

I also did the same test using Bitvise SSH Client, a commercial SSH Tunneler program, and there was no problem with the connection.

Haven't test it any further.

I'm guessing some specific amount of data being sent have triggered the Connection closed. The connection is closed normally, no error or exception thrown, the server didn't do the connection closing.

Can you confirm that this behaviour is not from the bug in the component it self?

The sample LocalPortForwardDemo program (modified a bit to use HTTPs Tunneling) works as expected, but I want to be able to read and modify the net data being sent or received by the component. How and where can I do this?

In fact, you can read and modify data transmitted by the simple components. This can be achieved by overriding an abstract TElSSHForwardingIntercept class and assigning an instance of that class to your simple forwarding component's Intercept property.

What you basically need to do is override several methods of the base class, in particular
- ChannelRead: this method is called by the forwarding component when data arrives from the SSH channel;
- SocketRead: this method is called when another portion of data arrives from the socket endpoint.

Inside the methods you can handle the data as you like. The base intercept class simply passes the data on to the socket or channel respectively with WriteToSocket() and WriteToChannel() methods. Your own implementation of the intercept may choose to behave differently.

We use cookies to help provide you with the best possible online experience. By using this site, you agree that we may store and access cookies on your device. You can find out more about and set your own preferences here.