Add.. everything
This commit is contained in:
parent
5989447a03
commit
97c28170c9
BIN
__pycache__/app.cpython-39.pyc
Normal file
BIN
__pycache__/app.cpython-39.pyc
Normal file
Binary file not shown.
10
app.py
10
app.py
@ -2,12 +2,22 @@ from flask import Flask, render_template, request, make_response, redirect
|
|||||||
from numpy import real
|
from numpy import real
|
||||||
from freecaptcha import captcha
|
from freecaptcha import captcha
|
||||||
import uuid
|
import uuid
|
||||||
|
import os
|
||||||
|
|
||||||
app = Flask(__name__, static_url_path='', static_folder='static',)
|
app = Flask(__name__, static_url_path='', static_folder='static',)
|
||||||
|
|
||||||
captcha_solutions = {}
|
captcha_solutions = {}
|
||||||
captcha_solved = []
|
captcha_solved = []
|
||||||
|
|
||||||
|
@app.route("/captcha2", methods=['GET'])
|
||||||
|
def captcha2():
|
||||||
|
with open('templates/captcha2play.html') as play_template_file:
|
||||||
|
return play_template_file.read()
|
||||||
|
|
||||||
|
@app.route("/captcha3", methods=['GET'])
|
||||||
|
def captcha3():
|
||||||
|
return captcha.generate_captcha_html(os.listdir('static/images/'))
|
||||||
|
|
||||||
@app.route("/captcha", methods=['GET', 'POST'])
|
@app.route("/captcha", methods=['GET', 'POST'])
|
||||||
def login():
|
def login():
|
||||||
# This means they just submitted a CAPTCHA
|
# This means they just submitted a CAPTCHA
|
||||||
|
BIN
freecaptcha/__pycache__/__init__.cpython-39.pyc
Normal file
BIN
freecaptcha/__pycache__/__init__.cpython-39.pyc
Normal file
Binary file not shown.
BIN
freecaptcha/__pycache__/captcha.cpython-39.pyc
Normal file
BIN
freecaptcha/__pycache__/captcha.cpython-39.pyc
Normal file
Binary file not shown.
@ -4,6 +4,88 @@ from PIL import Image
|
|||||||
import base64
|
import base64
|
||||||
from io import BytesIO
|
from io import BytesIO
|
||||||
|
|
||||||
|
import os
|
||||||
|
|
||||||
|
def generate_layers(images, index=0):
|
||||||
|
if len(images) == 0:
|
||||||
|
return ''
|
||||||
|
|
||||||
|
|
||||||
|
return f'''<label>
|
||||||
|
<input id="layer{index}" type="radio" name="captcha{index}" value="{index}">
|
||||||
|
<img src="images/{images[0]}"></img>
|
||||||
|
{generate_layers(images[1:], index+1)}
|
||||||
|
</label>
|
||||||
|
'''
|
||||||
|
|
||||||
|
def generate_captcha_html(images):
|
||||||
|
html = ''
|
||||||
|
html_prelude = '''
|
||||||
|
<style>
|
||||||
|
.grid {
|
||||||
|
display: grid;
|
||||||
|
grid-template-columns: repeat(3, 0fr);
|
||||||
|
}
|
||||||
|
|
||||||
|
div > div {
|
||||||
|
padding: 10px;
|
||||||
|
}
|
||||||
|
|
||||||
|
img {
|
||||||
|
background-color: white;
|
||||||
|
}
|
||||||
|
'''
|
||||||
|
|
||||||
|
generated_css = ''
|
||||||
|
for index, image in enumerate(images):
|
||||||
|
generated_css += f'''
|
||||||
|
|
||||||
|
/* ---- CURRENT LAYER: {index} ---- */
|
||||||
|
|
||||||
|
#layer{index}[type=radio] {{
|
||||||
|
position: absolute;
|
||||||
|
opacity: 0;
|
||||||
|
width: 0;
|
||||||
|
height: 0;
|
||||||
|
}}
|
||||||
|
|
||||||
|
#layer{index}[type=radio] + img {{
|
||||||
|
cursor: pointer;
|
||||||
|
padding: 5px;
|
||||||
|
position: absolute;
|
||||||
|
background-color: white;
|
||||||
|
}}
|
||||||
|
|
||||||
|
/* CHECKED STYLES */
|
||||||
|
#layer{index}[type=radio]:checked + img {{
|
||||||
|
z-index: -1000;
|
||||||
|
}}
|
||||||
|
'''
|
||||||
|
middle_boilerplate = '''
|
||||||
|
|
||||||
|
#root {
|
||||||
|
width: fit-content;
|
||||||
|
/* To adjust the height as well */
|
||||||
|
height: fit-content;
|
||||||
|
}
|
||||||
|
|
||||||
|
</style>
|
||||||
|
<body>
|
||||||
|
<div id="root">
|
||||||
|
<form method="POST">
|
||||||
|
<div class='grid'>
|
||||||
|
|
||||||
|
'''
|
||||||
|
|
||||||
|
generated_recursive_layers = generate_layers(images)
|
||||||
|
html_postscript = '''
|
||||||
|
<input style="position: absolute; top: 300px" type="submit">Submit</input>
|
||||||
|
</form>
|
||||||
|
</div>
|
||||||
|
</body>'''
|
||||||
|
html = html_prelude + generated_css + middle_boilerplate + generated_recursive_layers + html_postscript
|
||||||
|
return html
|
||||||
|
|
||||||
# Angles we'll rotate the original by
|
# Angles we'll rotate the original by
|
||||||
# when we create n rotations
|
# when we create n rotations
|
||||||
def calculate_angles(n):
|
def calculate_angles(n):
|
||||||
@ -42,6 +124,7 @@ def random_image(dir='images/'):
|
|||||||
random_image = random.choice(dir_contents)
|
random_image = random.choice(dir_contents)
|
||||||
return dir + random_image
|
return dir + random_image
|
||||||
|
|
||||||
|
## lol what does this do???
|
||||||
def resize_dir(size=150, dir='images/'):
|
def resize_dir(size=150, dir='images/'):
|
||||||
for img_file in os.listdir(dir):
|
for img_file in os.listdir(dir):
|
||||||
img = Image.open(dir + img_file)
|
img = Image.open(dir + img_file)
|
||||||
@ -52,3 +135,11 @@ def resize_dir(size=150, dir='images/'):
|
|||||||
|
|
||||||
img.thumbnail((size, size),Image.ANTIALIAS)
|
img.thumbnail((size, size),Image.ANTIALIAS)
|
||||||
img.save(dir + img_file)
|
img.save(dir + img_file)
|
||||||
|
|
||||||
|
if __name__ == '__main__':
|
||||||
|
img_path = random_image(dir='images/')
|
||||||
|
answer, options = captchafy(img_path)
|
||||||
|
for i, img_b64 in enumerate(options):
|
||||||
|
print(img_b64)
|
||||||
|
im = Image.open(BytesIO(base64.b64decode(img_b64)))
|
||||||
|
im.save(f'images/image{i}.png')
|
1
requirements.txt
Normal file
1
requirements.txt
Normal file
@ -0,0 +1 @@
|
|||||||
|
pillow
|
BIN
static/images/image0.png
Normal file
BIN
static/images/image0.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 40 KiB |
BIN
static/images/image1.png
Normal file
BIN
static/images/image1.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 38 KiB |
BIN
static/images/image2.png
Normal file
BIN
static/images/image2.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 38 KiB |
BIN
static/images/image3.png
Normal file
BIN
static/images/image3.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 39 KiB |
BIN
static/images/image4.png
Normal file
BIN
static/images/image4.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 38 KiB |
BIN
static/images/image5.png
Normal file
BIN
static/images/image5.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 38 KiB |
112
templates/captcha2play.html
Normal file
112
templates/captcha2play.html
Normal file
@ -0,0 +1,112 @@
|
|||||||
|
<style>
|
||||||
|
.grid {
|
||||||
|
display: grid;
|
||||||
|
grid-template-columns: repeat(3, 0fr);
|
||||||
|
}
|
||||||
|
|
||||||
|
div > div {
|
||||||
|
padding: 10px;
|
||||||
|
}
|
||||||
|
|
||||||
|
img {
|
||||||
|
background-color: white;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* HIDE RADIO */
|
||||||
|
#first-layer[type=radio] {
|
||||||
|
position: absolute;
|
||||||
|
opacity: 0;
|
||||||
|
width: 0;
|
||||||
|
height: 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* IMAGE STYLES */
|
||||||
|
#first-layer[type=radio] + img {
|
||||||
|
cursor: pointer;
|
||||||
|
padding: 5px;
|
||||||
|
position: absolute;
|
||||||
|
background-color: white;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* CHECKED STYLES */
|
||||||
|
#first-layer[type=radio]:checked + img {
|
||||||
|
z-index: -1000;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* SECOND LAYER BEGINS HERE */
|
||||||
|
|
||||||
|
|
||||||
|
/* HIDE RADIO */
|
||||||
|
#second-layer[type=radio] {
|
||||||
|
position: absolute;
|
||||||
|
opacity: 0;
|
||||||
|
width: 0;
|
||||||
|
height: 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* IMAGE STYLES */
|
||||||
|
#second-layer[type=radio] + img {
|
||||||
|
cursor: pointer;
|
||||||
|
padding: 5px;
|
||||||
|
position: absolute;
|
||||||
|
background-color: white;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* CHECKED STYLES */
|
||||||
|
#second-layer[type=radio]:checked + img {
|
||||||
|
z-index: -1000;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* THIRD LAYER BEGINS HERE */
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/* HIDE RADIO */
|
||||||
|
#third-layer[type=radio] {
|
||||||
|
position: absolute;
|
||||||
|
opacity: 0;
|
||||||
|
width: 0;
|
||||||
|
height: 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* IMAGE STYLES */
|
||||||
|
#third-layer[type=radio] + img {
|
||||||
|
cursor: pointer;
|
||||||
|
padding: 5px;
|
||||||
|
position: absolute;
|
||||||
|
background-color: white;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* CHECKED STYLES */
|
||||||
|
#third-layer[type=radio]:checked + img {
|
||||||
|
z-index: -1000;
|
||||||
|
}
|
||||||
|
|
||||||
|
#root {
|
||||||
|
width: fit-content;
|
||||||
|
/* To adjust the height as well */
|
||||||
|
height: fit-content;
|
||||||
|
}
|
||||||
|
|
||||||
|
</style>
|
||||||
|
<body>
|
||||||
|
<div id="root">
|
||||||
|
<form method="POST">
|
||||||
|
<div class='grid'>
|
||||||
|
<label>
|
||||||
|
<input id="first-layer" type="radio" name="captcha" value="0">
|
||||||
|
<img src="images/image0.png"></img>
|
||||||
|
<label>
|
||||||
|
<input id="second-layer" type="radio" name="captcha2" value="1">
|
||||||
|
<img src="images/image1.png"></img>
|
||||||
|
<label>
|
||||||
|
<input id="third-layer" type="radio" name="captcha3" value="2">
|
||||||
|
<img src="images/image2.png"></img>
|
||||||
|
</label>
|
||||||
|
</label>
|
||||||
|
</label>
|
||||||
|
</div>
|
||||||
|
<input style="position: absolute; top: 300px" type="submit">Submit</input>
|
||||||
|
</form>
|
||||||
|
</div>
|
||||||
|
</body>
|
@ -4,8 +4,8 @@
|
|||||||
<meta charset="UTF-8">
|
<meta charset="UTF-8">
|
||||||
<meta http-equiv="X-UA-Compatible" content="IE=edge">
|
<meta http-equiv="X-UA-Compatible" content="IE=edge">
|
||||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||||
<link rel="stylesheet" href="freecaptcha.css">
|
<link rel="stylesheet" href="css/freecaptcha.css">
|
||||||
<title>Tor Dev</title>
|
<title>FreeCAPTCHA</title>
|
||||||
</head>
|
</head>
|
||||||
<body>
|
<body>
|
||||||
<div id="root">
|
<div id="root">
|
||||||
|
Loading…
Reference in New Issue
Block a user