request specific port
This commit is contained in:
@@ -85,6 +85,14 @@ def setup_options():
|
|||||||
type = str,
|
type = str,
|
||||||
help="Id name for backdoor"
|
help="Id name for backdoor"
|
||||||
)
|
)
|
||||||
|
parser_open.add_argument(
|
||||||
|
action = 'store',
|
||||||
|
dest = 'port',
|
||||||
|
type = int,
|
||||||
|
default = None,
|
||||||
|
nargs = '?',
|
||||||
|
help="Request a port for backdoor"
|
||||||
|
)
|
||||||
|
|
||||||
parser_wait = subparsers.add_parser(
|
parser_wait = subparsers.add_parser(
|
||||||
"keep",
|
"keep",
|
||||||
@@ -206,8 +214,9 @@ class DataBase:
|
|||||||
self.conn_end()
|
self.conn_end()
|
||||||
|
|
||||||
|
|
||||||
def update(self, id):
|
def update(self, id, port = None):
|
||||||
self.id = id
|
self.id = id
|
||||||
|
if port == None:
|
||||||
port = self.get_port(id)
|
port = self.get_port(id)
|
||||||
if port == None:
|
if port == None:
|
||||||
port = self.new_port()
|
port = self.new_port()
|
||||||
@@ -333,7 +342,7 @@ if __name__ == "__main__":
|
|||||||
db.connect_backdoor(opts.id)
|
db.connect_backdoor(opts.id)
|
||||||
|
|
||||||
if opts.command == "open":
|
if opts.command == "open":
|
||||||
print(db.update(opts.id))
|
print(db.update(opts.id, opts.port))
|
||||||
|
|
||||||
if opts.command == "keep":
|
if opts.command == "keep":
|
||||||
print(db.update(opts.id))
|
print(db.update(opts.id))
|
||||||
|
|||||||
@@ -13,6 +13,7 @@ if [[ "$1" = update ]]; then
|
|||||||
fi
|
fi
|
||||||
|
|
||||||
_ssh() {
|
_ssh() {
|
||||||
|
trap 'kill -INT -$sshpid; exit;' INT
|
||||||
timeout -k 10 3700 ssh \
|
timeout -k 10 3700 ssh \
|
||||||
-o UserKnownHostsFile=/dev/null \
|
-o UserKnownHostsFile=/dev/null \
|
||||||
-o StrictHostKeyChecking=no \
|
-o StrictHostKeyChecking=no \
|
||||||
@@ -21,15 +22,16 @@ _ssh() {
|
|||||||
-o ServerAliveCountMax=3 \
|
-o ServerAliveCountMax=3 \
|
||||||
-p ${BACKDOORPORT} \
|
-p ${BACKDOORPORT} \
|
||||||
${BACKDOORHOST} \
|
${BACKDOORHOST} \
|
||||||
"$@"
|
"$@" &
|
||||||
|
sshpid=$!
|
||||||
|
wait $sshpid
|
||||||
#~ -o "ExitOnForwardFailure yes" \
|
#~ -o "ExitOnForwardFailure yes" \
|
||||||
}
|
}
|
||||||
|
|
||||||
BACKDOORHOST={{BACKDOORHOST}}
|
BACKDOORHOST={{BACKDOORHOST}}
|
||||||
BACKDOORPORT={{BACKDOORPORT}}
|
BACKDOORPORT={{BACKDOORPORT}}
|
||||||
USER=$( id -u -n )
|
USER=$( id -u -n )
|
||||||
echo use of ssh-add is encouraged
|
echo "Must use ssh agent (ssh-add)"
|
||||||
( sleep 3; printf "%d\r" $SECONDS ) &
|
|
||||||
while true; do
|
while true; do
|
||||||
port=$( _ssh bin/ssh-backdoor open $USER@$HOSTNAME )
|
port=$( _ssh bin/ssh-backdoor open $USER@$HOSTNAME )
|
||||||
[[ -z "$port" ]] && { sleep 2; continue; }
|
[[ -z "$port" ]] && { sleep 2; continue; }
|
||||||
@@ -47,4 +49,3 @@ while true; do
|
|||||||
printf " $i\r"
|
printf " $i\r"
|
||||||
done
|
done
|
||||||
done
|
done
|
||||||
kill %1
|
|
||||||
|
|||||||
Reference in New Issue
Block a user