diff --git a/__pycache__/app.cpython-39.pyc b/__pycache__/app.cpython-39.pyc new file mode 100644 index 0000000..9c89fc1 Binary files /dev/null and b/__pycache__/app.cpython-39.pyc differ diff --git a/app.py b/app.py index 841efa2..88137de 100644 --- a/app.py +++ b/app.py @@ -2,12 +2,22 @@ from flask import Flask, render_template, request, make_response, redirect from numpy import real from freecaptcha import captcha import uuid +import os app = Flask(__name__, static_url_path='', static_folder='static',) captcha_solutions = {} 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']) def login(): # This means they just submitted a CAPTCHA diff --git a/freecaptcha/__pycache__/__init__.cpython-39.pyc b/freecaptcha/__pycache__/__init__.cpython-39.pyc new file mode 100644 index 0000000..db47260 Binary files /dev/null and b/freecaptcha/__pycache__/__init__.cpython-39.pyc differ diff --git a/freecaptcha/__pycache__/captcha.cpython-39.pyc b/freecaptcha/__pycache__/captcha.cpython-39.pyc new file mode 100644 index 0000000..6edb412 Binary files /dev/null and b/freecaptcha/__pycache__/captcha.cpython-39.pyc differ diff --git a/freecaptcha/captcha.py b/freecaptcha/captcha.py index 2810876..d0c25a5 100644 --- a/freecaptcha/captcha.py +++ b/freecaptcha/captcha.py @@ -4,6 +4,88 @@ from PIL import Image import base64 from io import BytesIO +import os + +def generate_layers(images, index=0): + if len(images) == 0: + return '' + + + return f''' + ''' + +def generate_captcha_html(images): + html = '' + html_prelude = ''' + + +
+
+
+ + ''' + + generated_recursive_layers = generate_layers(images) + html_postscript = ''' + Submit + +
+''' + html = html_prelude + generated_css + middle_boilerplate + generated_recursive_layers + html_postscript + return html + # Angles we'll rotate the original by # when we create n rotations def calculate_angles(n): @@ -42,6 +124,7 @@ def random_image(dir='images/'): random_image = random.choice(dir_contents) return dir + random_image +## lol what does this do??? def resize_dir(size=150, dir='images/'): for img_file in os.listdir(dir): img = Image.open(dir + img_file) @@ -52,3 +135,11 @@ def resize_dir(size=150, dir='images/'): img.thumbnail((size, size),Image.ANTIALIAS) 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') \ No newline at end of file diff --git a/requirements.txt b/requirements.txt new file mode 100644 index 0000000..037103e --- /dev/null +++ b/requirements.txt @@ -0,0 +1 @@ +pillow \ No newline at end of file diff --git a/static/freecaptcha.css b/static/css/freecaptcha.css similarity index 100% rename from static/freecaptcha.css rename to static/css/freecaptcha.css diff --git a/static/images/image0.png b/static/images/image0.png new file mode 100644 index 0000000..397b4e2 Binary files /dev/null and b/static/images/image0.png differ diff --git a/static/images/image1.png b/static/images/image1.png new file mode 100644 index 0000000..e5e8299 Binary files /dev/null and b/static/images/image1.png differ diff --git a/static/images/image2.png b/static/images/image2.png new file mode 100644 index 0000000..2b77b95 Binary files /dev/null and b/static/images/image2.png differ diff --git a/static/images/image3.png b/static/images/image3.png new file mode 100644 index 0000000..950372e Binary files /dev/null and b/static/images/image3.png differ diff --git a/static/images/image4.png b/static/images/image4.png new file mode 100644 index 0000000..fb86fc7 Binary files /dev/null and b/static/images/image4.png differ diff --git a/static/images/image5.png b/static/images/image5.png new file mode 100644 index 0000000..53c31a4 Binary files /dev/null and b/static/images/image5.png differ diff --git a/templates/captcha2play.html b/templates/captcha2play.html new file mode 100644 index 0000000..9565fb5 --- /dev/null +++ b/templates/captcha2play.html @@ -0,0 +1,112 @@ + + +
+
+
+ +
+ Submit +
+
+ \ No newline at end of file diff --git a/templates/index.html b/templates/index.html index 49990fc..52b4295 100644 --- a/templates/index.html +++ b/templates/index.html @@ -4,8 +4,8 @@ - - Tor Dev + + FreeCAPTCHA
@@ -28,4 +28,4 @@
- \ No newline at end of file +