aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorFlorian Bruhin <me@the-compiler.org>2018-09-05 22:33:38 +0200
committerFlorian Bruhin <me@the-compiler.org>2018-09-05 22:33:38 +0200
commit4e8f5f364744cd36cbd83746a9ee2e97ffbd35fb (patch)
tree8800db4642e73b63e252a1a69432525fe9d5462a
parenta91c9920788af7b4fd283b0ebc345b25750748d2 (diff)
downloadhsrvpn-4e8f5f364744cd36cbd83746a9ee2e97ffbd35fb.tar.gz
hsrvpn-4e8f5f364744cd36cbd83746a9ee2e97ffbd35fb.zip
Use commandline args for user
-rwxr-xr-xhsrvpn7
-rwxr-xr-xhsrvpn-getsecret2
-rwxr-xr-xhsrvpn-gettokens16
3 files changed, 17 insertions, 8 deletions
diff --git a/hsrvpn b/hsrvpn
index b7a7bf4..aca2fd8 100755
--- a/hsrvpn
+++ b/hsrvpn
@@ -1,6 +1,11 @@
#!/bin/bash
-username=fbruhin
+if (($# < 1)); then
+ echo "Usage: $0 <username>" >&2
+ exit 1
+fi
+
+username=$1
host=vpn.hsr.ch
password=$(keyring get openhsr-connect $username)
diff --git a/hsrvpn-getsecret b/hsrvpn-getsecret
index 95339de..5c66c2c 100755
--- a/hsrvpn-getsecret
+++ b/hsrvpn-getsecret
@@ -1,12 +1,12 @@
#!/usr/bin/python
+import argparse
from xml.etree import ElementTree
import sys
import requests
import keyring
import urllib.parse
-import argparse
parser = argparse.ArgumentParser()
parser.add_argument('url', help="URL like https://smc.swivelsecure.net/smc/complete/...")
diff --git a/hsrvpn-gettokens b/hsrvpn-gettokens
index 550593c..33c28c1 100755
--- a/hsrvpn-gettokens
+++ b/hsrvpn-gettokens
@@ -1,13 +1,17 @@
#!/usr/bin/python
+import argparse
from xml.etree import ElementTree
import requests
import keyring
-user = 'fbruhin'
-secret = keyring.get_password('hsrvpn-gettokens', user)
-debug = False
+parser = argparse.ArgumentParser()
+parser.add_argument('user', help="HSR Username")
+parser.add_argument('--debug')
+args = parser.parse_args()
+
+secret = keyring.get_password('hsrvpn-gettokens', args.user)
# Yes, they really throw XML in as form-encoded because it just happens to have a = in it...
data = {"<?xml version": "'1.0' ?><SASRequest><Version>3.1</Version><Action>SecurityStrings</Action><Id>{}</Id></SASRequest>".format(secret)}
@@ -18,8 +22,8 @@ headers = {
# let's invent our own header which is an user agent because we put bullshit in the user agent data
'X-Requested-With': 'com.authcontrolmobile',
}
-proxies = {'https': 'http://localhost:8080'} if debug else {}
-verify = not debug
+proxies = {'https': 'http://localhost:8080'} if args.debug else {}
+verify = not args.debug
response = requests.post('https://sidv3611virt.hsr.ch/proxy/AgentXML', data=data, headers=headers, proxies=proxies, verify=verify)
response.raise_for_status()
@@ -34,4 +38,4 @@ codes = tree.find('SecurityStrings').text.strip(';').split(';')
output = ' '.join('{}{:02}'.format(idx, code) for code, idx in enumerate(codes))
print(output)
-keyring.set_password('hsrvpn-secrets', user, output)
+keyring.set_password('hsrvpn-secrets', args.user, output)