dlenski / openconnect

OpenConnect client extended to support Palo Alto Networks' GlobalProtect VPN
679 stars 130 forks source link

How to send OTP token on connect #144

Closed Jazb closed 5 years ago

Jazb commented 5 years ago

I have the data of VPN on gopass and wrote script than render connect command user and password fine, static token OTP if request as challenge i and try to use --form-field and the format

FORM:OPT=VALUE

The id of form change on each request ? What is the correct way to send this token ?

Jazb commented 5 years ago

I am success connect send the token in the second line of stdout, with this command template:

echo -e "$PASSWORD\n$TOKEN" | openconnect $ARGS --passwd-on-stdin
dlenski commented 5 years ago

The id of form change on each request ? What is the correct way to send this token ?

Which VPN protocol are you using?

dlenski commented 5 years ago

@jazb, any updates? Otherwise I'll close due to inactivity.

667bdrm commented 5 years ago

Expect could be used. In my case portal requesting password twice. It is a possible to modify script to putting token from the input buffer to variable.

My script usage: ./gp.sh Username Password

#!/usr/bin/expect -f

set timeout -1

set username [lindex $argv 0]
set password [lindex $argv 1]

spawn openconnect --protocol=gp --usergroup=portal --cafile=ca.crt --certificate=client.crt --sslkey=client.key --user=$username --authgroup=YourGateway portal.globalprotect.example.com

expect "*Password:*"

send -- "$password\r"

expect "*Password:*"

send -- "$password\r"

expect eof
dlenski commented 5 years ago

Closing due to insufficient information to understand what's causing the variation in form name (need to know protocol and ideally more detailed logs).