-
Notifications
You must be signed in to change notification settings - Fork 8
/
qr_download.py
executable file
·37 lines (34 loc) · 930 Bytes
/
qr_download.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
#!/usr/bin/python3
from os import system
from struct import unpack
TIMEOUT = 1
system("xwininfo | grep id | grep 'xwininfo:' | awk '{print $4}' > /tmp/winid.txt")
winid = open("/tmp/winid.txt").read().split()[0]
output = {}
is_start = False
errors = 0
_num = 0
try:
while True:
system(f"gm import -window {winid} /tmp/qr.png") # apt install graphicsmagick
system("zbarimg --raw --oneshot -Sbinary /tmp/qr.png > /tmp/qr-decoded.bin 2> /dev/null") # apt install zbar-tools
data = open("/tmp/qr-decoded.bin", "rb").read()
if data:
errors = 0
is_start = True
num = unpack("<H", data[:2])[0]
if num != _num:
print(f"[!] part {_num} lost")
_num = num
if not num in output:
_num += 1
output[num] = data[2:]
print(f"[+] {num} {output[num].hex()}")
elif is_start:
errors += 1
if errors >= 3:
break
except:
pass
with open("out.bin","wb") as o:
o.write( b"".join(output.values()) )