How the shadowsocks client make all the Internet request through the client? - windows

When I use the shadowsock's client on windows, and I make it the global agent.
Then, whatever I use Fixfox or chrome, I could get the result I want.
I want to know , how the client make the other software use the Internet through it ? Could someone tell the knowledge about this?

on unix system, using proxychains
intall proxychains
ubuntu
sudo apt-get install proxychains
mac os x
brew install proxychains
from source code
Edit proxychains config
add below line to /etc/proxychains.conf on linux or ~/.proxychains/proxychains.conf on mac
socks5 127.0.0.1 1080 # on linux
socks5 127.0.0.1 1086 # on mac
Don't forget remove remove socks4 if exits
Usage
on linux
proxychains wget https://www.google.com
proxychains google-chrome
on mac
proxychains4 wget https://www.google.com

Related

Forticlient VPN from mac CLI

I'd like to make a script to connect to different SSL VPN's from MAC OS X. I cannot find any info as to how to connect VPN's via command line? Can anyone please help me with this?
Thanks!
There is actually a way. First, install openfortivpn via brew:
brew install openfortivpn
Then, connect as such:
sudo openfortivpn <server_ip>:<server_port> -u <username> -p <password>
After some research I have come to conclusion there is no FortiClient CLI for MAC OS. In other words there is no commands for FortiClient in terminal. Still you can use terminal for Backup/Restore/Export for FortiClient VPN configuration. You can use this link for reference:
FortiClient XML Reference Guide

How to use socks proxy via CLI without proxychains (to install proxychains)

I am unable to install proxychains on a remote system because the system only has outbound access to port 22/tcp to my server. However, I can use ssh -D 9050 root#myip to listen on port 9050 for socks proxy.
That being said, how can I run apt update and apt install proxychains through socks port 9050 so that I can install proxychains and use it for future commands?
I've tried to run:
export http_proxy=socks5://127.0.0.1:9050 https_proxy=socks5://127.0.0.1:9050
but as soon as I ran apt update, the outbound connection fails. Not sure if this is the correct way to do it or if I'm just missing something small.
One solution I was able to use is by downloading the ZIP version of https://github.com/rofl0r/proxychains-ng, SCP'ing it over to the remote server, and then compiling it locally on that system.
Afterwards, I'm able to use ./proxychains4g -f src/proxychains.conf <command> and so now it looks like I'm good to go.

How to forward Docker for Mac to X11?

Using Docker for Mac 1.12 (stable) and OS X 10.11.5 (15F34), I'm attempting to make one of my containers forward to X11.
First, I install XQuartz from my bash shell:
$ brew cask install xquartz
==> Downloading https://dl.bintray.com/xquartz/downloads/XQuartz-2.7.9.dmg
######################################################################## 100.0%
==> Verifying checksum for Cask xquartz
==> Running installer for xquartz; your password may be necessary.
==> Package installers may write to any location; options such as --appdir are ignored.
Password:
==> installer: Package name is XQuartz 2.7.9
==> installer: Installing at base path /
==> installer: The install was successful.
🍺 xquartz staged at '/usr/local/Caskroom/xquartz/2.7.9' (73M)
Then I continue with setting up XQuartz...
open -a XQuartz
In the XQuartz Preferences -> Security tab, I enable "Allow connections from network clients".
Then I am supposed to run xhost + $MY_IP_ADDRESS in my bash shell, but all I get is this error:
xhost: unable to open display ""
In the end, all guides I'm reading says I should run my container like this:
docker run -e DISPLAY=$MY_IP_ADDRESS:0 -v /tmp/.X11-unix:/tmp/.X11-unix DOCKER_IMAGE
...but that doesn't work. In my particular container, I get this error:
... cannot connect to X server 10.0.0.131:0
What am I doing wrong?
Turns out there's a bug in XQuartz 2.7.9.
When using XQuartz 2.7.10_beta2, it works.
I have xQuartz 2.7.11 installed on Mac OS.
I was getting the following error
<program>: cannot connect to X server <ip>:0
when trying to run docker container. I tried downgrading XQuartz but it still didn't fix my issue.
A crucial piece to to the setup is to add your ip access control list for xhost.
xhost + $(ipconfig getifaddr en0)
After adding the ip to xhost, everything works. There is no need to downgrade Xquartz version.
Solution
After installing XQuartz you will need to restart your computer as horcle_buzz suggested; starting a new terminal session is not enough.
After a reboot you can grant access for whatever you need using the xhost command. Just be careful and understand the consequences of too permissive a rule. This other discussion has more info: Running Chromium inside Docker - Gtk: cannot open display: :0
Additional findings
Some extra things I discovered along the way:
XQuartz must be running first:
$ open -a XQuartz
You can expose 127.0.0.1 instead of looking up your local IP (caveat emptor: I'm not an expert on the implications of this setting):
$ xhost + 127.0.0.1
127.0.0.1 being added to access control list
You can use the special host.docker.internal identifier with docker run:
$ docker run -e DISPLAY=host.docker.internal:0 jess/firefox
# 🧙‍♀️ magic 🧙‍♂️
At least for me, ctrl + c does not shutdown the container; I need to close the X11 window manually.
If you quit XQuartz, you must re-auth with xhost after starting it again (the permission doesn't "stick").
Doing it this way I didn't need to mount /tmp/.X11-unix when calling docker run.
I tested this with XQuartz 2.7.11 and Docker Desktop 2.1.0.2 on macOS Mojave (10.14.6).

How to use pip with socks proxy?

I'm using ssh -D to create a socket proxy and want to know how to use pip(or easy_install) with it? I find this question but that's an http proxy.
Also, please give me a solution works under OS X. (I tried proxifier, it works with pip install, but not sudo pip install)
Easiest method, also works on many OS's:
pip install pysocks
pip install <yourpacakge> --proxy socks5:127.0.0.1:8123
Substitute socks4, and your own ip/port as needed.
Use socks proxifier, for example proxychains.
Command pip will be like proxychains pip install package_name.
Or use another proxifier.
For CentOS, you can use privoxy to convert socks5 proxy to http proxy.
yum install privoxy
Then edit /etc/privoxy/config, at the end of the file, add:
forward-socks5 / 127.0.0.1:1080 .
It will convert socks5 proxy from 1080 to http proxy 8118. Then you can specify the proxy in your pip config file:
[global]
proxy = 127.0.0.1:8118
DO NOT use polipo, as it is already deprecated.
As other users have posted the following works well for using pip via a remote host:
# SOCKS4 proxy creation
ssh -D9999 <remote host URI>
# use pip with the previously created proxy connection (requires pysocks)
python3 -m pip install <package name> --proxy socks5:localhost:9999
Bootstrapping
"But I need pysocks to run pip through a proxy and you can't connect to the pypi to download packages as I don't have functioning pip"
One way to get around this is to download the pysocks wheel package on another machine:
python3 -m pip download pysocks
This will download the pysocks package to your machine. Transfer the PySocks-x-x-x-py3-none-any.whl file to the machine that requires proxy functionality and install:
python3 -m pip install PySocks*.whl
Nevermind, --proxy seems to work with http(s) proxy only.
From "pip --help"
--proxy <proxy> Specify a proxy in the form
[user:passwd#]proxy.server:port.
Edit: I finally gave up sock proxy and run a java http proxy (jhttp2.sourceforge.net/‎) on my remote machine and use ssh -L port:localhost:port to forward the port to the remote machine and use that http proxy.
Run these two commands:
pip install pysocks5
pip install --proxy socks5://[user:passwd#]proxy.server:port something
first of all you can try install proxychains-ng using
brew install proxychains-ng
the can try make a socks5 proxy using ssh -D like
ssh -D 12345 -fqN root#[your-vps-ip]
and use public-key or password to access your vps
then you have both proxychain and socks5.
Now edit /etc/proxychains.conf , simply add this line at the end of it
socks5 127.0.0.1 12345
and comment this
socks4 127.0.0.1 9050
Finally
proxychains4 pip install [whateveryouwant]
On Windows (mine was Win2012R2) I managed connecting through SOCKS5-proxy by doing those steps:
All-user-level-pip:
Adding this lines to pip.ini under "C:\ProgramData\pip":
[global]
proxy = socks5:{proxy-ip}:{proxy-port}
Opening cmd.exe (maybe but not necessarily as administrator ... depends on your file-system configuration...)
Setting proxy variables to "no-proxy" explicitly!!! ... like that:
set http_proxy=no-proxy
set https_proxy=no-proxy
running for example pip install your_module and finally it works through the socks5-proxy specified in the pip.ini
For user-level-pip you need to place the pip.ini somewhere else according pip-documentation.

Error: cannot open display: localhost:0.0 - trying to open Firefox from CentOS 6.2 64bit and display on Win7

I am on a Windows7 machine and I'm trying to get firefox to open on the centOS machine, but be displayed on my current screen.
When typing firefox in terminal, I am getting the following error:
Error: cannot open display: localhost:0.0
To setup the display I used the command
$ export DISPLAY=localhost:0.0
Some site suggested using the following, but it didn't work either:
$ export DISPLAY=:0.0
I am using PuTTY and I have the Enable X11 forwarding check box checked and XMing is running on Windows. Additionally, the sshd_config on centOS file seems to be setup properly as well:
$ cat /etc/ssh/sshd_config |grep -i x11
#X11Forwarding no
X11Forwarding yes
#X11DisplayOffset 10
X11UseLocalhost yes
I've looked over numerous pages and searched StackOverflow as well, but none have managed to help me in any way.
Thank you in advance.
So, it turns out that X11 wasn't actually installed on the centOS. There didn't seem to be any indication anywhere of it not being installed. I did the following command and now firefox opens:
yum groupinstall 'X Window System'
Hope this answer will help others that are confused :)
I faced this issue once and was able to resolve it by fixing of my /etc/hosts. It just was unable to resolve localhost name... Details are here: http://itvictories.com/node/6
In fact, there is 99% that error related to /etc/hosts file
X server just unable to resolve localhost and all consequent actions just fails.
Please be sure that you have a record like
127.0.0.1 localhost
in your /etc/hosts file.
I had this error message:
Error: Can't open display: localhost:13.0
This fixed it for me:
export DISPLAY="localhost:10.0"
You can use this too:
export DISPLAY="127.0.0.1:10.0"
before start make sure of installation:
yum install -y xorg-x11-server-Xorg xorg-x11-xauth xorg-x11-apps
start xming or cygwin
make connection with X11 forwarding (in putty don't forget to set localhost:0.0 for X display location)
edit sshd.cong and restart
cat /etc/ssh/sshd_config | grep X
X11Forwarding yes
X11DisplayOffset 10
AddressFamily inet
Without the X11 forwarding, you are subjected to the X11 SECURITY and then you must:
authorize the remote server to make a connection with the local X Server using a method (for instance, the xhost command)
set the display environment variable to redirect the output to the X server of your local computer.
In this example:
192.168.2.223 is the IP of the server
192.168.2.2 is the IP of the local computer where the x server is installed. localhost can also be used.
blablaco#blablaco01 ~
$ xhost 192.168.2.223
192.168.2.223 being added to access control list
blablaco#blablaco01 ~
$ ssh -l root 192.168.2.223
root#192.168.2.223s password:
Last login: Sat May 22 18:59:04 2010 from etcetc
[root#oel5u5 ~]# export DISPLAY=192.168.2.2:0.0
[root#oel5u5 ~]# echo $DISPLAY
192.168.2.2:0.0
[root#oel5u5 ~]# xclock&
Then the xclock application must launch.
Check it on putty or mobaxterm and don't check in remote desktop Manager software.
Be careful for user that sudo in.
In my case the issue was caused due to mismatch in .Xauthority file. Which initially showed up with "Invalid MIT-MAGIC-COOKIE-1" error and then "Error: cannot open display: :0.0" afterwards
Regenerating the .Xauthorityfile from the user under which I am running the vncserver and resetting the password with a restart of the vnc service and dbus service fixed the issue for me.

Resources