You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository has been archived by the owner on Dec 21, 2019. It is now read-only.
I needed it to work with an expired cert and I wanted to be able to set the user and password as arguments so here is my very quick and dirty modification. I've never touched Go before so this is pretty much trial and error but works.
I figured i´d add it as an issue so that others can find the modification.
package main
import (
"bufio""encoding/xml""fmt""golang.org/x/crypto/ssh/terminal""net/http""os""strings""syscall""crypto/tls"
)
// The XML response returned by the WatchGuard servertypeRespstruct {
Actionstring`xml:"action"`LogonStatusint`xml:"logon_status"`LogonIdint`xml:"logon_id"`Errorstring`xml:"errStr"`Challengestring`xml:"chaStr"`
}
funcmain() {
args:=os.Args[1:]
iflen(args) <1 {
fmt.Fprintln(os.Stderr, "Usage: watchblob <vpn-host>")
os.Exit(1)
}
host:=args[0]
//username, password, err := readCredentials()username:=args[1]
password:=args[2]
//if err != nil {// fmt.Fprintf(os.Stderr, "Could not read credentials: %v\n", err)//}fmt.Printf("Requesting challenge from %s as user %s\n", host, username)
challenge, err:=triggerChallengeResponse(&host, &username, &password)
iferr!=nil||challenge.LogonStatus!=4 {
fmt.Fprintln(os.Stderr, "Did not receive challenge from server")
fmt.Fprintf(os.Stderr, "Response: %v\nError: %v\n", challenge, err)
os.Exit(1)
}
token:=getToken(&challenge)
err=logon(&host, &challenge, &token)
iferr!=nil {
fmt.Fprintf(os.Stderr, "Logon failed: %v\n", err)
os.Exit(1)
}
fmt.Printf("Login succeeded, you may now (quickly) authenticate OpenVPN with %s as your password\n", token)
}
funcreadCredentials() (string, string, error) {
fmt.Printf("Username: ")
reader:=bufio.NewReader(os.Stdin)
username, err:=reader.ReadString('\n')
fmt.Printf("Password: ")
password, err:=terminal.ReadPassword(syscall.Stdin)
fmt.Println()
// If an error occured, I don't care about which one it is.returnstrings.TrimSpace(username), strings.TrimSpace(string(password)), err
}
functriggerChallengeResponse(host*string, username*string, password*string) (rResp, errerror) {
returnrequest(templateUrl(host, templateChallengeTriggerUri(username, password)))
}
funcgetToken(challenge*Resp) string {
fmt.Println(challenge.Challenge)
reader:=bufio.NewReader(os.Stdin)
token, _:=reader.ReadString('\n')
returnstrings.TrimSpace(token)
}
funclogon(host*string, challenge*Resp, token*string) (errerror) {
resp, err:=request(templateUrl(host, templateResponseUri(challenge.LogonId, token)))
iferr!=nil {
return
}
ifresp.LogonStatus!=1 {
err=fmt.Errorf("Challenge/response authentication failed: %v", resp)
}
return
}
funcrequest(urlstring) (rResp, errerror) {
http.DefaultTransport.(*http.Transport).TLSClientConfig=&tls.Config{InsecureSkipVerify: true}
resp, err:=http.Get(url)
iferr!=nil {
return
}
deferresp.Body.Close()
decoder:=xml.NewDecoder(resp.Body)
err=decoder.Decode(&r)
return
}
The text was updated successfully, but these errors were encountered:
Sign up for freeto subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Hi and thanks for this project!
I needed it to work with an expired cert and I wanted to be able to set the user and password as arguments so here is my very quick and dirty modification. I've never touched Go before so this is pretty much trial and error but works.
I figured i´d add it as an issue so that others can find the modification.
The text was updated successfully, but these errors were encountered: