parent
887f479d1f
commit
285165913d
13 changed files with 112 additions and 30 deletions
@ -1,9 +0,0 @@ |
||||
#!/usr/bin/env bash |
||||
|
||||
stdin="$(cat -)" |
||||
escaped="$(echo "$stdin" | sed 's/"/\\"/g')" |
||||
query="$(echo "" | fzf --preview-window=up:99% --print-query \ |
||||
--preview "echo \"$escaped\" | jq -C {q}" | head -n 1)" |
||||
|
||||
echo "$stdin" | jq "$query" |
||||
|
@ -0,0 +1,67 @@ |
||||
#!/usr/bin/env bash |
||||
|
||||
choice(){ |
||||
local prompt=${1:-"Please make a selection"} |
||||
local choices="$(cat)" |
||||
local x=1 |
||||
local selection |
||||
echo "$choices" | while read line; do |
||||
echo "$x: $line" | column -t -s $'\t' > /dev/tty |
||||
x=$((x+1)) |
||||
done |
||||
echo -n "$prompt " > /dev/tty |
||||
read selection < /dev/tty |
||||
echo "$choices" | sed -n "$selection p" | cut -d $'\t' -f 1 |
||||
} |
||||
|
||||
print_help(){ |
||||
echo "$0 This helps with generating ssh tunnels" |
||||
echo " -h||--help show this help" |
||||
exit 0 |
||||
} |
||||
|
||||
dryrun="false" |
||||
|
||||
while [[ $1 = -?* ]]; do |
||||
case $1 in |
||||
-h|--help) print_help >&2 ;; |
||||
*) echo "Unknown option $1"; print_help >&2 ;; |
||||
esac |
||||
shift |
||||
done |
||||
|
||||
forwardtype="$( |
||||
( |
||||
echo -e "local\tAccess on local machine something that is accessible on remote" |
||||
echo -e "remote\tAccess on remote machine something that is accessible on local" |
||||
echo -e "dynamic\tSimilar to local but creates a socks proxy" |
||||
) | choice "Forward Type:" )" |
||||
|
||||
case "$forwardtype" in |
||||
"local") |
||||
echo "How would you access the resource if on the remote machine?" |
||||
echo "e.g. localhost:8834 if nessus is hosted on the remote machine" |
||||
echo -n "> " |
||||
read remote < /dev/tty |
||||
echo "Which local port would you like to listen on?" |
||||
echo -n "> " |
||||
read localport < /dev/tty |
||||
echo "ssh -L ${localport}:${remote} <server>" |
||||
;; |
||||
"remote") |
||||
echo "How would you access the resource if on the local machine?" |
||||
echo "e.g. internal-intranet:443 if there was an internal resource you wanted to get access to" |
||||
echo -n "> " |
||||
read localresource < /dev/tty |
||||
echo "Which remote port would you like to listen on the remote server (that you're sshing into)?" |
||||
echo -n "> " |
||||
read remoteport < /dev/tty |
||||
echo "ssh -R ${remoteport}:${localresource} <server>" |
||||
;; |
||||
"dynamic") |
||||
echo "Which local port would you like to listen on?" |
||||
echo -n "> " |
||||
read localport < /dev/tty |
||||
echo "ssh -D ${localport} <server>" |
||||
;; |
||||
esac |
Loading…
Reference in new issue