From a493ab7e40216dd56079c4d1edb8e90aa8706818 Mon Sep 17 00:00:00 2001 From: CyberL1 Date: Sat, 27 Jul 2024 22:03:50 +0200 Subject: [PATCH] feat: save connector to a file --- .gitignore | 1 + shell.sh | 20 +++++++++++++------- 2 files changed, 14 insertions(+), 7 deletions(-) diff --git a/.gitignore b/.gitignore index 1c6915e..b0018c7 100644 --- a/.gitignore +++ b/.gitignore @@ -1 +1,2 @@ .api-key +.connector diff --git a/shell.sh b/shell.sh index bbeba0d..ffaa21a 100644 --- a/shell.sh +++ b/shell.sh @@ -3,15 +3,21 @@ API_HOST="https://api.ssh.surf" API_KEY=$(cat .api-key) -[ -z $API_KEY ] && echo "API key not found" && exit 1 +if [ ! -f .connector ]; then + echo "SSH Connector not found, getting for the first time" + [ -z $API_KEY ] && echo "API key not found" && exit 1 -hello=$(curl -w %{http_code} -sH "x-ssh-auth: $API_KEY" $API_HOST/hello -o /dev/null) + hello=$(curl -w %{http_code} -sH "x-ssh-auth: $API_KEY" $API_HOST/hello -o /dev/null) -if [[ hello -ne 200 ]]; then - echo "token not valid, exiting" - exit 1 + if [[ hello -ne 200 ]]; then + echo "token not valid, exiting" + exit 1 + fi + + CONNECTOR=$(curl -sH "x-ssh-auth: $API_KEY" -X POST -H "content-type: application/json" $API_HOST/exec --data '{ "cmd": "con --list | grep ssh - Port: 22", "pwd": "/root" }' | grep -o 'Connector: [^"]*' | sed 's/Connector: //' | sed 's/\\n//') + + echo $CONNECTOR > .connector fi -CONNECTOR=$(curl -sH "x-ssh-auth: $API_KEY" -X POST -H "content-type: application/json" $API_HOST/exec --data '{ "cmd": "con --list | grep ssh - Port: 22", "pwd": "/root" }' | grep -o 'Connector: [^"]*' | sed 's/Connector: //' | sed 's/\\n//') - +CONNECTOR=$(cat .connector) npx holesail $CONNECTOR