contrib/greet.in: Grotty script to send a TrIPE greeting packet.
[tripe] / contrib / greet.in
diff --git a/contrib/greet.in b/contrib/greet.in
new file mode 100644 (file)
index 0000000..c84efdc
--- /dev/null
@@ -0,0 +1,17 @@
+#! @PYTHON@
+### greet HOST PORT CHALLENGE
+### Sends a TrIPE greeting packet to the server listening on HOST and PORT.
+### The payload is the base64-encoded CHALLENGE.
+
+import socket as S
+from sys import argv
+
+def db64(s):
+  return (s + '='*((-len(s))%4)).decode('base64')
+
+addr, chal = (lambda _, h, p, c: ((h, int(p)), db64(c)))(*argv)
+sk = S.socket(S.AF_INET, S.SOCK_DGRAM)
+sk.connect(addr)
+
+pkt = '\x25' + chal
+sk.send(pkt)