diff options
Diffstat (limited to 'url_handler/ping_script.py')
-rwxr-xr-x | url_handler/ping_script.py | 27 |
1 files changed, 27 insertions, 0 deletions
diff --git a/url_handler/ping_script.py b/url_handler/ping_script.py new file mode 100755 index 0000000..30f15e5 --- /dev/null +++ b/url_handler/ping_script.py @@ -0,0 +1,27 @@ +#!/usr/bin/env python3 +import sys, os, time, subprocess + +url = sys.argv[1] +if len(url) % 15 == 0: url += "\0" +while len(url) % 15 != 0: url += "\0" + +for i in range(len(url) // 15): + subprocess.check_call(["ping", "-c", "1", "-p", "64" + "".join("{:02X}".format(ord(x)) for x in url[15*i:15*i+15]), "127.0.0.1"], stdout=subprocess.DEVNULL) + +while True: + out = subprocess.check_output(["ping", "-c", "1", "-p", "65", "127.0.0.1"], stderr=subprocess.STDOUT).decode("utf-8") + if out.find("icmp_seq=1 ") != -1: + break + time.sleep(0.2) + +while True: + out = subprocess.check_output(["ping", "-c", "1", "-p", "66", "127.0.0.1"], stderr=subprocess.STDOUT).decode("utf-8") + idx = out.find("icmp_seq=") + idx2 = out.find(" ", idx) + seqnum = int(out[idx+9:idx2]) + n0 = seqnum % 256 + n1 = seqnum >> 8 + if n0 == 0: break + print(chr(n0), end="") + if n1 == 0: break + print(chr(n1), end="") |