chiark / gitweb /
contrib/knock.in: Login script for establishing dynamic associations.
[tripe] / contrib / greet.in
CommitLineData
5d60949f
MW
1#! @PYTHON@
2### greet HOST PORT CHALLENGE
3### Sends a TrIPE greeting packet to the server listening on HOST and PORT.
4### The payload is the base64-encoded CHALLENGE.
5
6import socket as S
7from sys import argv
8
9def db64(s):
10 return (s + '='*((-len(s))%4)).decode('base64')
11
12addr, chal = (lambda _, h, p, c: ((h, int(p)), db64(c)))(*argv)
13sk = S.socket(S.AF_INET, S.SOCK_DGRAM)
14sk.connect(addr)
15
16pkt = '\x25' + chal
17sk.send(pkt)