As you already know in order to use Tor without the Tor Browser you need to have Tor installed on the command line and running afterwards you can configure programs like Curl to use the Tor SOCKS5 proxy on port 9050 I am working on implementing this in Python I have already finished this using subprocess combined with Curl and so far i am using requests combined with a proxy list the only proxy in the list is socks5://127.0.0.1:9050 and this works for clearnet websites i have checked by running the request without the proxy and with the proxy using HTTPBin and they are different IP addresses but i have tried to resolve a .onion domain with this same code but it doesn't resolve with the error Name or service not known. What do I do in order to fix this? And what's the cause
Edit: I read in a previous question that maybe Tor was not running or listening for connections the proxy takes connections for clearnet websites from the same script and redirects to the Tor network but does not resolve .onion websites and i checked to make sure and Tor is indeed running and listening for connections on port 9050 and i have checked the network connection it is indeed active and can ping clearnet websites but the script won't resolve .onion domains
#!/usr/bin/python
import requests
Proxy = {'http' : 'socks5://127.0.0.1:9050',
'https': 'socks5://127.0.0.1:9050'}
Request_Server = requests.get('https://www.facebookcorewwwi.onion/')
Related
I just started experimenting connections by creating local server. I am new to this stuff.
I created a local server on my laptop via cmd:
python -m http.server
And then from my Android phone I can able to connect to my laptop via Chrome browser giving relevant IP + port and view the files. My question is from my laptop how can I disconnect my Android phone connection without stopping my server.
HTTP is stateless but browser can keep connection alive on the same TCP connection. To prevent that you should set keep_alive as false in the header of your HTTP response.
They explain about HTTP and keep-alive here : Python-Requests close http connection
You must modifiy the http header response : https://docs.python.org/3.4/library/http.server.html?highlight=exp
I am now facing the problem with using python to connect to one port which requires username/password.
The web URL is xxx.xxx.xxx.xxx:9200/_plugin/head/, which is for elasticsearch. I think the administrator has set firewall for the port, when I want to log in with web browser, the web browser will require username/password, if wrong, the web page will show "authentication failed". And when I use another Linux server to use query port directly with command like
curl -XPOST 'xx.xx.xxx.x:9200/iqas_week/_search?pretty=true' -d ...
The server will also return "Authentication Required"
My plan is to use python to connect to this port and write some query for elasticsearch just like the code above. Now with encrypted port, how can I connect to that port in python? I have tried with paramiko, it works for port 22 but not for port 9200, is there any other way to connect to this port using python?
You should be able to use urllib2 to connect to the elasticsearch listener as I believe it's just an HTTP(s?) listener. Why not use the elasticsearch though?
https://elasticsearch-py.readthedocs.io/en/master/
I have a Django development server running on a remote centos VM on another lan. I have set up port forwarding using Secure CRT to access the web page through my browser from my desk pc. I am currently not using apache with the development server and is shutdown.
I start the server by running python manage.py runserver 0.0.0.0:80.
When I type either the ip or www.localhost.com into the web browser, my URL is read as if it has been doubled with the host being read as if it was also the path.
Page not found (404)##
Request Method: GET
Request URL: http://www.localhost.com/http://www.localhost.com/
When I try to access the development server from within the same LAN the page loads up fine.
I have been searching through the django documentation and stack overflow, but I have yet to find a similar problem to this. Does anyone have any thoughts on why this may be happening and what could be a possible solution?
Thank you very much in advance!
It looks like the request URL is incorrect:
http://www.localhost.com/http://www.localhost.com/ should probably be http://actual_machine_IP.com/
I'd start searching there. You won't be able to access the VM's port 80 from a different lan using localhost as the hostname since localhost is probably already set in your hosts file.
If you want to test your dev environ remotely, can I suggest either setting up Apache properly with port 80 (as opposed to using django's dev server--privilege restrictions and all that can be circumvented with sudo and other bad practice) or use a pre-built shared dev service like vagrant share.
the idea is that, say a developer has a set of tests to run against locahost:8000 and he has hardcoded that in his tests.
When we setup a proxy in a browser, the browser handles the proxy so that users only care about typing localhost:8000 instead of localhost:proxy_port. Browser actually sends request and receives response from the proxy port.
Can we simulate such so that the tests don't have to change to localhost:proxy_port (and the proxy server knows to route to port 8000). instead, the developer can continue to run as localhost:8000 in his tests, but when he's running his tests, the request automatically goes through the proxy server.
PS: Also without changing the port of the server. Since the assumption is that the port 8000 is running as application server and changing it to another port can break other things! So saying "change proxy server port to 8000 and my webapp server to 80001" doesn't solve the whole problem.
Set the HTTP_PROXY environment variable (and export it), and Python will honour that (as far as the standard library is used).
I'm being trying to
Log into a server using SHH (with Paramiko)
Use that connection like a proxy and route network traffic through it and out to the internet. So say I could set it as my proxy in Urllib2, Mechanize, Firefox, etc.).
Is the second part possible or will I have to have some sort of proxy server running on the server to get this to work?
You could implement a SOCKS proxy in the paramiko client that routes connections across the SSH tunnel via paramiko's open_channel method. Unfortunately, I don't know of any out-of-the-box solution that does this, so you'd have to roll your own. Alternatively, run a SOCKS server on the server, and just forward that single port via paramiko.