SOCKS5 request from Azure VM - python-3.x

I have a Python 3 script that makes requests through a SOCKS5 proxy. I want to be able to run this script from an Azure VM. But when the request is being made I get the following error:
Not supported proxy scheme SOCKS5
I'm running Python 3.5.2 with requests 2.9.1 on an Ubuntu 16.10 LTS VM. I also installed pysocks to have requests works with SOCKS5.
The code that does the request is as follows:
server = 'socks5://u:p#proxy.server.com:1080'
proxies = { 'https': server, 'all': None }
response = requests.get(request_url, proxies=proxies)
Te script runs fine locally. So it seems that Azure won't allow me to make use of SOCKS5 proxies.
I've also added port 1080 as allowed outbound connection to the networking interface of the VM.
How do I configure my VM in such a way that it will allow SOCKS5 connections from the

Ok, it turns out that installing pysocks isn't enough.
When you use the following command:
pip3 install -U requests[socks]
It installs the required packages to work properly.
-U is the same as --upgrade. This flag is also required, without it you still won't be able to connect through SOCKS5.

Related

Python3 requests not passing proxy authentication on Ubuntu server

The code is as follows:
import requests
proxy = 'username:password#ip:9999'
print(requests.get('https://api.ipify.org/', proxies={'http': f'http://{proxy}', 'https': f'http://{proxy}'}).text)
(username, password and ip have been omitted)
OS = Ubuntu 20.04.5 LTS
Python version = 3.8.10
Requests version = 2.28.1
When ran on said server Proxy-Authorization is not passed in the connection headers. However when running the exact same script on my Windows device it is passed.
Before opening an issue on GitHub, I wanted to see if anyone knows why this may be?

Requests library does not perform HTTP requests inside mitmproxy

I installed mitmproxy by using pip (pip(3) install mitmproxy). I created a script that performs HTTP requests - I use https://requests.readthedocs.io/en/master/ obviously - on a specific trigger (e.g. an image or file went through the reverse proxy).
Versions: Python 3.9.1 for Windows 10 64 bits, pip version 20.2.3, and mitmproxy 6.0.2.
#staticmethod
def _file_exists(file_name: str) -> bool:
request_path = "https://<url>/{}".format(file_name)
req = requests.get(request_path) # import requests
return True if req.status_code == 200 else False
This blocks forever if I use the command mitmdump -s script.py. Adding a timeout will result in a TCP timeout exception - for HTTP and TLS.
I tried the following:
Re-installing the SSL certificate of mitmproxy
Using a clean Windows installation
I tried to connect to an IP address
I tried to connect without HTTPS
I'm stuck. Any ideas?

Linux: Using Proxy

I have some struggles with the proxy settings.
There is a proxy server running which I use. So I've set the proxy urls in the environment based on this tutorial http://www.gtkdb.de/index_36_2111.html
This works pretty fine if I use the chromium browser, but ping
and apt-get still does not work.
Did I miss something?
I guess ping and so on don't use the proxy settings of env
To answer your problem referring to apt follow this thread: https://askubuntu.com/questions/109673/how-to-use-apt-get-via-http-proxy-like-this.
Ping uses ICMP and not http,https or ftp to do its job.
If you want ping to work you'll need to config the routing table of your machine as the proxy machine and config iptables on the proxy machine to NAT the traffic. To give you an idea follow this thread:
how to transmit traffic from a linux vpn server to another linux server?
Hope this helps.

Chef-Server Installation can't find chef service

I am installing chef-server on this VPS that my friend let me borrow.
I was able to install chef and run chef-server-ctl reconfigure successfully.
I ran into problems because I need to change the iptable rules and I discovered that I cannot find chef-server running on any port or as a service.
When I run chef-server-ctl it seems to pass all the tests, so I know its API is working.
Where can I find that chef is running?
I need to change my iptables so that I can use knife to communicate with chef-server.
First off it sounds like you installed Chef Server, not Chef, important distinction :) Second, there is no specific process called chef-server. The frontend routing is handled by nginx which binds on port 443 and 80 (80 is just a redirector to 443 and can be blocked or disabled if desired). Internally we have a bunch of different smaller services like oc_erchef, bifrost, oc_id, etc. These all listen on localhost and are reached via Nginx.
You have installed Chef server and have reconfigured the server, you can't find a chef-server.
you can run below commands to check all the services that are running chef server
$ chef-server-ctl service-list
bookshelf*
nginx*
oc_bifrost*
oc_id*
opscode-chef-mover*
opscode-erchef*
opscode-expander*
opscode-solr4*
rabbitmq*
redis_lb*
postgresql*
To update the port number you need to update
/etc/chef-server/chef-server.rb - in Chef 11
/etcopscode/chef-server.rb - in Chef 12
nginx['non_ssl_port'] = portnumber
And also how are using knife command? Do you want ssl check to be passed then you need to add a line in knife.rb file
ssl_verify_mode: verify_none
'

Can't access tomcat web page from lan

I installed a tomcat7 server on a ubuntu 12.04 box. I simply used "apt-get install tomcat7". I did not install apache2. I can access the default page from localhost:8080, 127.0.0.1:8080, and 192.168.1.201:8080, where the latter is the IP address from my LAN. my end goal is to be able to access the web server from outside the LAN with port forwarding. For now, however, I can't even access it inside the LAN.
Problem:
I can't access the web page from any other computer (windows 7, iPad) on the same LAN! I
get the "connection has timed out" error from the browser.
Question: Can I run tomcat on it's own without installing Apache2 first? This is the current setup and I can access pages hosted on tomcat on the same server, but not over the LAN.
Other information:
I can ping the ubuntu computer from other machines
The ubuntu firewall is disabled (checked via the firewall GUI interface).
I also tried "sudo ufw disable"
I tried: "sudo service iptables stop" and got the message: "iptables: unrecognized service"
I also tried disabling the appArmor firewall:
sudo /etc/init.d/apparmor stop
sudo /etc/init.d/apparmor teardown
sudo update-rc.d -f apparmor remove
I set the router firewall policy to minimum: inbound: accept all; outbount: accept all.
All computers (including ubuntu server) are connected to LAN via wireless
The ubuntu server IP address is static, not DHCP
I checked the SELinux folder and it's empty. I removed it.
Thank you for your help,
Omar
EDIT:
I can connect from within the LAN using ssh (I installed OpenSSH on ubuntu).
ANSWER:
I found the solution to this problem. It turned out there was a firewall active that was blocking the port. The firewall is called "firestarter". Not sure how this was installed, but it can be downloaded from the ubuntu software center. The default inboud policy blocks all ports except for SSH (22). I opened port 8080 and everything worked just fine. The other firewalls (ufw and SELinux) were disabled.
Thank you all again for your help.
Omar
First of all make sure all of the IP addresses are topologically correct, then ping to the your apache server system, If all this succeeds your network is fine.
Now the question are you using the Ubuntu Server edition? if this is the case i believe you can setup apache out of the box.
In case of the Desktop edition you could install it using command line or just install something like XAMP from apache friends.
Make sure your apache Server is started
If you do not already have Apache installed, you can do so now by issuing the following commands:
sudo apt-get update
sudo apt-get install apache2
This is all that is necessary to have a working web server.
I think, "apt-get install tomcat7" doesnt works in Ubuntu. You have to manually download the TAR file & then you can install it with the scripts. Please check whether it is properly installed or not. it should show a Apache Tomcat Homepage # localhost:8080
Also if it is installed properly, check whether it is running on the port 8080, or any other port.
If everything is fine, then disable the firewall of the Server, where you have installed the Tomcat. check for the server IP.
Now from other machine, access that server using http://server_ip:port
This should work fine. No issues should be there.
The other thing, you have metioned in your question, UBUNTU BOX. May be this issue arises due to UBUNTU BOX. If possible, make a clean install of Ubuntu.

Resources