-
Notifications
You must be signed in to change notification settings - Fork 4
/
Script.py
86 lines (64 loc) · 2.37 KB
/
Script.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
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
'''
for refernce for ddiferent ctf`s and online cracks...(contact me ----VAD3R)
'''
import os
import urllib.request
import re
import base64
import http.cookiejar
from PIL import Image, ImageDraw
import time
import zbarlight
import cv2
import numpy as np
def post(passw):
entry={'qrcode':qrcode} # entering qrcode with at qrcode place
senddata = urllib.parse.urlencode(entry)
return bytes(senddata, 'utf-8')
url = ' '
start_time = time.time()
cj = http.cookiejar.CookieJar() # using httpcookiejar for automatic handling of cookies
opener = urllib.request.build_opener(urllib.request.HTTPCookieProcessor(cj))
urllib.request.install_opener(opener)
req = urllib.request.Request(url) # GET request to page
resp = urllib.request.urlopen(req)
respData = resp.read()
print(cj)
print("############################")
print(respData)
print("############################")
paragraphs = re.findall(r'<p>(.*?)</p>', str(respData))
for eachP in paragraphs:
r = eachP
print (r)
# writing our image to a file
with open('img.png', 'wb') as f:
data = f.write(text)
WHITE =(255,255,255) # fixing imafe to ber read (on corners)
W= # your width height
BLACK = (0,0,0)
image = Image.open("img.png")
draw = ImageDraw.Draw(image)
for (x,y) in [(18, 18), (18,218), (218,18)]:
draw.rectangle((x,y, , ),BLACK, BLACK)
draw.rectangle((x+W,y+W, , ),WHITE, WHITE)
draw.rectangle((x+2*W,y+2*W, , ),BLACK, BLACK)
image.save('result.png')
'''
transformation: # (optional)
morhpological , translational, affine # open saved image to transform the image
see:codes.py for more.
'''
file_path = 'processed.png'
with open(file_path, 'rb') as image_file:
image = Image.open(image_file)
image.load() # using zbarlight to read qr code
codes = zbarlight.scan_codes('qrcode', image)
print('QR codes: %s' % codes)
ans = post(qrcode)
print(ans)
answer = urllib.request.urlopen(url, ans) # POST req to page with qrcode
raw = answer.read()
raw = raw.decode('utf-8')
print(raw)
print("--- %s seconds ---" % (time.time() - start_time))