fiddyschmitt / File-Tunnel

Tunnel TCP connections through a file
MIT License
803 stars 66 forks source link

Redirect http requests through RDP #13

Closed tintanto closed 1 week ago

tintanto commented 1 month ago

Hello. I am not sure if this project is for my use case or not. I want to redirect my python https requests through the RDP server. Is this possible using this project? If that is the case, I would appreciate any tips. I have tried using

socks.set_default_proxy(socks.SOCKS5, "127.0.0.1", 5000)
socket.socket = socks.socksocket

In my python code but that did not work.

fiddyschmitt commented 1 month ago

Hi tintanto,

Yes it should work. Perhaps your web server is an HTTP proxy, rather than a SOCKS proxy.

This works for me (I'm using mitmproxy)

import requests

proxies = {
    "http": "http://127.0.0.1:5000",
}

url = 'https://www.google.com/'
response = requests.get(url, proxies=proxies)
print(response.text)

Please let me know if it works for you :)

Cheers, Fidel

tintanto commented 1 month ago

@fiddyschmitt Thank you for the reply. It seems I do not comprehend how the ft project works. I thought I would actually run ft on both my PC and destination PC, where I rdp to, then connect to 127.0.0.1:5000 using my python project and that would be enough for my requests traffic to be redirected. I have used the two lines I have mentioned in my first post. I have also used {'http': 'http://127.0.0.1:5000', 'https': 'http://127.0.0.1:5000'} and also {'http': 'socks5://127.0.0.1:5000', 'https': 'socks5://127.0.0.1:5000'} with requests.get() That did not work. It resulted in the remote PC displaying Error during connection to 10.1.0.48:8888. A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond. [::ffff:10.1.0.48]:8888 Is there an extra step I am missing? My aim is to actually use the remote PC VPN connection. If that is not possible please let me know.

Thank you.

fiddyschmitt commented 1 month ago

No worries, it sounds very interesting. Let's get it working.

Is this your setup?

image

And when you do an HTTP request in your Python script, you'd like it originate out of the Remote PC, utilising the VPN connection it's running?

tintanto commented 1 month ago

@fiddyschmitt Yes. That is my setup. Also, that is also what I want. I want my python script requests to have the IP of the remote PC active VPN service. If that is not possible with ft I can settle for being able to send the requests to the remote PC and then try to find a different solution for utilizing the VPN connection. Thank you.

fiddyschmitt commented 1 month ago

Yes File Tunnel doesn't act like a VPN service itself. It just tunnels TCP connections. So you'll need a Proxy server in your setup.

image

tintanto commented 1 month ago

@fiddyschmitt Thank you so much for the help. I think it actually worked. Sadly, the remote PC crashed before I could do further tests. Is there any way to reduce the memory consumption of ft. The program uses over 1.6GB of RAM? If not thanks again for the help.

fiddyschmitt commented 1 month ago

That's great! You're welcome! I'm so glad it worked.

Shame about the crash.

I'll look to see if there's a way to reduce memory consumption in the coming weeks.