
HTTP/HTTPS-Proxy über SSH
HTTP/HTTPS-Proxy über SSH.
go install github.com/justmao945/mallory/cmd/mallory@latestStandardpfad ist $HOME/.config/mallory.json, kann beim Start des Programms gesetzt werden
mallory -config path/to/config.json
Inhalt:
id_rsa ist der Pfad zu unserer privaten Schlüsseldatei, kann mit ssh-keygen erstellt werdenlocal_smart ist die lokale Adresse, um HTTP-Proxy mit intelligenter Erkennung des Zielhosts bereitzustellenlocal_normal ähnelt local_smart, sendet jedoch den gesamten Verkehr durch den entfernten SSH-Server ohne Erkennung des Zielhostsremote ist die entfernte Adresse des SSH-Serversblocked ist eine Liste von Domains, die einen Proxy benötigen; alle anderen Domains verbinden sich direkt mit ihrem Server{
"id_rsa": "$HOME/.ssh/id_rsa",
"local_smart": ":1315",
"local_normal": ":1316",
"remote": "ssh://[email protected]:22",
"blocked": [
"angularjs.org",
"golang.org",
"google.com",
"google.co.jp",
"googleapis.com",
"googleusercontent.com",
"google-analytics.com",
"gstatic.com",
"twitter.com",
"youtube.com"
]
}
Die gesperrte Liste in der Konfigurationsdatei wird bei Aktualisierung automatisch neu geladen, und Sie können dies manuell tun:
# send signal to reload
kill -USR2 <pid of mallory>
# or use reload command by sending http request
mallory -reload
localhost mit Port 1315, um sie mit der Blockliste zu verwendenhttp_proxy und https_proxy auf localhost:1316 für die Terminalnutzungmallory -suffix www.google.com
# install it: go get github.com/justmao945/mallory/cmd/forward
# all traffic through port 20022 will be forwarded to destination.com:22
forward -network tcp -listen :20022 -forward destination.com:22
# you can ssh to destination:22 through localhost:20022
ssh root@localhost -p 20022
Betrachten Sie die folgende Konfigurationsdatei:
$ cat mallory.json
{
"id_rsa": "/tmp/id_rsa",
"local_smart": ":1315",
"local_normal": ":1316",
"remote": "ssh://[email protected]:22"
}
Sie können den Container (zoobab/mallory) ausführen, indem Sie die Konfigurationsdatei, den SSH-Schlüssel einbinden und die 2 Ports zuordnen:
$ docker run -v $PWD/mallory.json:/root/.config/mallory.json -p 1316:1316 -p 1315:1315 -v $PWD/.ssh/id_rsa:/tmp/id_rsa zoobab/mallory
mallory: 2020/03/30 16:51:10 main.go:22: Starting...
mallory: 2020/03/30 16:51:10 main.go:23: PID: 1
mallory: 2020/03/30 16:51:10 config.go:103: Loading: /root/.config/mallory.json
mallory: 2020/03/30 16:51:10 main.go:30: Connecting remote SSH server: ssh://[email protected]:22
mallory: 2020/03/30 16:51:10 main.go:38: Local normal HTTP proxy: :1316
mallory: 2020/03/30 16:51:10 main.go:48: Local smart HTTP proxy: :1315
Mein Anwendungsfall war die Verbindung zu einem Kubernetes-Cluster (Openshift), der hinter einem SSH-Bastion installiert war:
$ export http_proxy=http://localhost:1316
$ export https_proxy=https://localhost:1316
$ oc login https://master.mycluster.zoobab.com:8443
Authentication required for https://master.mycluster.zoobab.com:8443 (openshift)
Username: bhenrion
Password:
Login successful.