diff options
-rwxr-xr-x | skripti/1domains.py | 66 | ||||
-rwxr-xr-x | skripti/davčna.py | 11 | ||||
-rwxr-xr-x | skripti/odstrani-datum-komentarjev-docx.sh | 14 |
3 files changed, 91 insertions, 0 deletions
diff --git a/skripti/1domains.py b/skripti/1domains.py new file mode 100755 index 0000000..ca8faf4 --- /dev/null +++ b/skripti/1domains.py @@ -0,0 +1,66 @@ +#!/usr/bin/python3 +from sys import stderr, stdout +from dns.resolver import resolve, LifetimeTimeout +from dns.query import udp +from dns.message import make_query +from dns.exception import Timeout +from dns.rcode import NXDOMAIN +from requests import get +from random import sample +candidates = [] +# for d in get("https://data.iana.org/TLD/tlds-alpha-by-domain.txt").content.split(b"\n"): +for d in [b"ac", b"af", b"ag", b"ai", b"am", b"bo", b"by", b"bz", b"cm", b"cn", b"co", b"cr", b"cx", b"cz", b"de", b"dk", b"fm", b"gd", b"gg", b"gl", b"gp", b"gs", b"gt", b"gy", b"hn", b"hr", b"ht", b"ie", b"im", b"io", b"is", b"je", b"kg", b"ki", b"kw", b"la", b"lb", b"lc", b"ly", b"md", b"mg", b"mk", b"mp", b"ms", b"mw", b"mx", b"mu", b"nf", b"np", b"nz", b"pe", b"ph", b"pk", b"pl", b"pn", b"pr", b"pw", b"ro", b"sh", b"st", b"tc", b"tl", b"tt", b"to", b"tv", b"ua", b"vc", b"vg", b"vn", b"vu", b"ws"]: + if d.startswith(b"# ") or d == b"": + continue + if len(d) != 2: + continue + d = d.decode() + # print(d, file=stderr) + ips = [] + try: + for ns in resolve(d, "NS"): + for ip in resolve(ns.to_text()): + ips.append(ip.to_text()) + except LifetimeTimeout: + print(f"{d} timeout resolving tld ns") + continue + nx = [] + has = None + for c in "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ": + try: + tries_left = 5 + while True: + try: + ip = sample(ips, 1)[0] + r = udp(make_query(c + "." + d, "NS"), ip, 1, raise_on_truncation=False) + except Timeout: + print(f"{c}.{d} timeout with ip {ip}", file=stderr) + ips.remove(ip) + tries_left -= 1 + if tries_left < 0: + raise Timeout + else: + break + except Timeout: + print(f"{c}.{d} timeouted, skipping TLD") + break + except ValueError: + print(f"{d} is unreachable -- all ips timeouted") + continue + if r.rcode() == NXDOMAIN: + nx.append(c) + else: + # TODO check if NS points to an unregistered domain + # print(f"{c}.{d} resolves to {r.sections}") + has = c + else: + if has is not None: + print(f"{d} nxdomains are {nx}") + for n in nx: + candidates.append(n + "." + d) + else: + print(f"{d} doesn't have") + stdout.flush() +print("*************** SCRIPT EXEC FINISHED, candidate list:") +for candidate in candidates: + print(candidate) diff --git a/skripti/davčna.py b/skripti/davčna.py new file mode 100755 index 0000000..89fe9f2 --- /dev/null +++ b/skripti/davčna.py @@ -0,0 +1,11 @@ +#!/usr/bin/python3 +from sys import argv +s = 0 +m = [x for x in range(2,9)] +for z in argv[1]: + x = m.pop() + s += x * int(z) +k = 11-s%11; +if k > 9: + k = 0 +print(f"{argv[1]}{k}") diff --git a/skripti/odstrani-datum-komentarjev-docx.sh b/skripti/odstrani-datum-komentarjev-docx.sh new file mode 100755 index 0000000..28517f9 --- /dev/null +++ b/skripti/odstrani-datum-komentarjev-docx.sh @@ -0,0 +1,14 @@ +set -xe +p=`rev <<<$0 | cut -d/ -f1 | rev` +t=`mktemp -p "" -d $p.XXX` +unzip $1 -d$t +sed -ie 's/ w:date="[^"]*"//g' $t/word/comments.xml +sed -ie 's/ w16cex:dateUtc="[^"]"//g' $t/word/commentsExtensible.xml +b=`rev <<<$1 | cut -d/ -f1 | cut -d. -f2- | rev` +d=`mktemp -p "" $b.XXX.docx` +rm $d # hack that causes race condition +cd $t +zip -r $d * +cd $OLDPWD +rm -r $t +echo $d |