Giter Club home page Giter Club logo

captcha22's Introduction

CAPTCHA22 is a toolset for building, and training, CAPTCHA cracking models using neural networks. These models can then be used to crack CAPTCHAs with a high degree of accuracy. When used in conjunction with other scripts, CAPTCHA22 gives rise to attack automation; subverting the very control that aims to stop it.

Table of contents

Installation

CAPTCHA22 requires tensorflow (see prerequisites). You can then install CAPTCHA22 using pip:

pip install captcha22

Prerequisites

CAPTCHA22 is most performant on a GPU-enabled tensorflow build. This, however, will require numerous steps (as discussed here). Currently TF<2 is required for AOCR, which requires Python<3.7. AOCR will be ported to TF2 in the future.

  • To install a less optimal, CPU-based, tensorflow build - you can simply issue the following command:

    pip install "tensorflow<2"
  • The tensorflow serving addon is required to host trained CAPTCHA models.

Usage: How to crack CAPTCHAs

CAPTCHA22 works by training a neural network against a sample of labelled CAPTCHAs (using a sliding CNN with a LSTM module). Once this model is suitably accurate, it can be applied to unknown CAPTCHAs - automating the CAPTCHA cracking process.

This process is broken down into 3 steps:

Step 1: Creating training sample data (labelling CAPTCHAs)

The first step in this whole process is create a sample of correctly labelled CAPTCHAs. Ideally, you'll want to aim for at least 200.

1. Collecting CAPTCHAs

Unfortunately, there is no one size fits all solution for collecting CAPTCHA samples and you'll have to be innovative with your approach. In our experience, we've had little difficulty automating this process using wget or the python requests library. How you approach this is up to you, but a good starting point would probably be to try and work out how the target application is generating/serving their CAPTCHAs.

2. Labelling

Sadly, labelling is manual. This is most laborious and time consuming step in this whole process - fortunately things only get better from here. To try and make things a little easier, we've included functionality to help with labelling:

captcha22 client label --input=<stored captcha folder>

Once complete, CAPTCHA22 will produce a ZIP file (e.g. <api_username>_<test_name>_<version_number>.zip) that you can upload (discussed in step 2).

Step 2: Training a CAPTCHA model

Once you have a sample set of labelled CAPTCHAs, the next step is to begin training the CAPTCHA model.

1. Launch the Server (and API)

To do this, you first need to launch CAPTCHA22's server engine, which will poll the ./Unsorted/ directory for new ZIPs:

captcha22 server engine

Enable the API for interfacing with the CAPTCHA22 engine (if you're an advanced user, feel free to skip this step):

captcha22 server api

The default API credentials are admin:admin. You can modify the users.txt file to change this value, or add additional users. See the below code snippet for guidance:

python -c "from werkzeug.security import generate_password_hash;print('username_string' + ',' + generate_password_hash('password_string'))"

2. Upload CAPTCHA training samples

To upload training samples, simply drop the ZIP file you created in Step 1 into ./Unsorted/. The zip file name should be <captcha_name>_<captcha_version>.zip. Alternatively, if you opted to enable the API, you can perform this step interactively using the client:

captcha22 client api

In both cases, CAPTCHA22 will automatically begin training a model.

3. Deploy the trained model

Once a model is trained and sufficiently accurate, the model can be deployed to use for automated cracking. The model can either be deployed on the CAPTCHA22 server or downloaded. Both methods can be performed using the interactive API client.

To host the model, extract the ZIP and execute:

tensorflow_model_server --port=9000 --rest_api_port=9001 --model_name=<yourmodelname> --model_base_path=<full path to exported model directory>

The interactive API client can also be used to upload a CAPTCHA to CAPTCHA22 to be solved by the hosted model.

The following cURL request will verify whether the model is working:

curl -X POST \
    http://localhost:9001/v1/models/<yourmodelname>:predict \
    -H 'cache-control: no-cache' \
    -H 'content-type: application/json' \
    -d '{
            "signature_name": "serving_default",
            "inputs": 
            {
                "input": { "b64": "/9j/4AAQ==" }
            }
        }'

Step 3: CAPTCHA Cracking

Once a model is hosted, you'll be able to pass CAPTCHAs to the model and receive an answer (i.e. automation). You can use the template code below to use CAPTCHA22 in conjuntion with your own custom code to execute a variety of automated attacks (e.g. Username enumeration, Brute force password guessing, Password spraying, etc.).

from captcha22 import Cracker

# Create cracker instance, all arguments are optional
solver = Cracker(
    #  server_url="http://127.0.0.1",
    #  server_path="/captcha22/api/v1.0/",
    #  server_port="5000",
    #  username=None,
    #  password=None,
    #  session_time=1800,
    #  use_hashes=False,
    #  use_filter=False,
    #  use_local=False,
    #  input_dir="./input/",
    #  output="./output/",
    #  image_type="png",
    #  filter_low=130,
    #  filter_high=142,
    #  captcha_id=None
    )

# Retrieve captcha from website
...
# Create b64 image string
...

# Solve with CAPTCHA22
answer = solver.solve_captcha_b64(b64_image_string)

# Submit answer to website and launch attack
...

As the model exposes a JSON API, you're not restricted to Python if you prefer to use tools such as cURL, wget, or anything else.

Two example cracker scripts are also provided (baseline and pyppeteer). Both of these scripts are experimental and will not cater for most cases.

  • The baseline script will create a connection to the CAPTCHA22 server, or a locally hosted model, before requesting the file path to a CAPTCHA.
  • The pyppeteer script will use the baseline script and simulate browser requests to find and solve the CAPTCHA, before running a login attack.

To execute one of these scripts:

captcha22 client cracking --script=<script name>

Troubleshooting

CAPTCHA22 was tested on two GPU-enabled Tensorflow rigs with the following specifications:

Rig 1 Rig 2
Graphics Card GeForce GTX 1650 GeForce GTX 960
OS Ubuntu 16.06 Ubuntu 16.04
Cuda Lib Cuda 10.0.130 Cuda 9.1.1
cuDDN Lib cuDNN 10.0 cuDNN 7.0
Tensorflow Tensorflow 1.10.1 Tensorflow 1.4.1

For assistance on any issues in CAPTCHA22 itself, please log an issue.

Contributing

See CONTRIBUTING.md for more information.

License

MIT License

Copyright (c) 2020 F-SECURE

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

captcha22's People

Contributors

hirza-tango avatar thijstriemstra avatar tinusgreen avatar vu159951 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

captcha22's Issues

Unable to run captcha22 server engine on Macos

I'm on mac 10.15.1 (19B2106) with Anaconda installed (tensorflow, python 3.6 installed).
Beginning of the error:

Class start Checking if there is any new files ['./Unsorted/admin_2_2.zip'] Start running Copy files Starting the copy of files mkdir: ./Busy/: File exists Traceback (most recent call last): File "/Users/abc/opt/anaconda3/envs/captcha/bin/captcha22", line 8, in <module> sys.exit(main()) File "/Users/abc/opt/anaconda3/envs/captcha/lib/python3.6/site-packages/captcha22/__main__.py", line 267, in main args.func(args) File "/Users/abc/opt/anaconda3/envs/captcha/lib/python3.6/site-packages/captcha22/lib/core/server.py", line 20, in server server.main() File "/Users/abc/opt/anaconda3/envs/captcha/lib/python3.6/site-packages/captcha22/lib/server/captcha22.py", line 503, in main self.run_server() File "/Users/abc/opt/anaconda3/envs/captcha/lib/python3.6/site-packages/captcha22/lib/server/captcha22.py", line 478, in run_server self.check_files() File "/Users/abc/opt/anaconda3/envs/captcha/lib/python3.6/site-packages/captcha22/lib/server/captcha22.py", line 387, in check_files self.copy_files(file) File "/Users/abc/opt/anaconda3/envs/captcha/lib/python3.6/site-packages/captcha22/lib/server/captcha22.py", line 253, in copy_files os.system('mkdir ' + self.busy_URL + "/" + names[0] + "/" + names[1]) IndexError: list index out of range

error: List index out of range (img = cv2.imread(image[0]) when i run captcha2 server engine

i installed captcha22 via pip in an Ubuntu Server 18.04 lts, Python 3.6 and Tensorflow 1.15.

I got an error when i run the command "Captcha22 server engine":

INFO:Captcha22 Engine:Captcha22 engine start
Traceback (most recent call last):
File "/usr/local/lib/python3.6/dist-packages/captcha22/lib/server/captcha22.py", line 37, in init
self.hasTrained = ast.literal_eval(lines[0].replace("\n", ""))
IndexError: list index out of range

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File "/usr/local/bin/captcha22", line 8, in
sys.exit(main())
File "/usr/local/lib/python3.6/dist-packages/captcha22/main.py", line 278, in main
args.func(args)
File "/usr/local/lib/python3.6/dist-packages/captcha22/lib/core/server.py", line 22, in server
server.main()
File "/usr/local/lib/python3.6/dist-packages/captcha22/lib/server/captcha22.py", line 518, in main
self.first_start()
File "/usr/local/lib/python3.6/dist-packages/captcha22/lib/server/captcha22.py", line 514, in first_start
self.reload_models(layer + "/")
File "/usr/local/lib/python3.6/dist-packages/captcha22/lib/server/captcha22.py", line 383, in reload_models
model = captcha(path, self.logger)
File "/usr/local/lib/python3.6/dist-packages/captcha22/lib/server/captcha22.py", line 55, in init
self.get_image_size()
File "/usr/local/lib/python3.6/dist-packages/captcha22/lib/server/captcha22.py", line 61, in get_image_size
img = cv2.imread(images[0])
IndexError: list index out of range

Please help me to solve this problem.

Issues on following the readme

Please add the folowing information to readme file:
Required Python version 3.7 (tensorflow 1.15.5 - current, requires it)
After labelling we need to rename a ZIP file in the next format <captcha_name><captcha_version>.zip

Getting error when running captcha22 server engine.

I get this error

`Class start
Checking if there is any new files
['./Unsorted\data.zip']
Start running
Copy files
Starting the copy of files
The syntax of the command is incorrect.
Traceback (most recent call last):
File "c:\users\user\anaconda3\lib\runpy.py", line 193, in run_module_as_main
"main", mod_spec)
File "c:\users\user\anaconda3\lib\runpy.py", line 85, in run_code
exec(code, run_globals)
File "C:\Users\user\anaconda3\Scripts\captcha22.exe_main
.py", line 7, in
sites = site.getsitepackages()
File "c:\users\user\anaconda3\lib\site-packages\captcha22_main
.py", line 267, in main
args.func(args)
File "c:\users\user\anaconda3\lib\site-packages/captcha22\lib\core\server.py", line 20, in server
server.main()
File "c:\users\user\anaconda3\lib\site-packages/captcha22\lib\server\captcha22.py", line 512, in main
self.run_server()
File "c:\users\user\anaconda3\lib\site-packages/captcha22\lib\server\captcha22.py", line 487, in run_server
self.check_files()
File "c:\users\user\anaconda3\lib\site-packages/captcha22\lib\server\captcha22.py", line 396, in check_files
self.copy_files(file)
File "c:\users\user\anaconda3\lib\site-packages/captcha22\lib\server\captcha22.py", line 256, in copy_files
os.system('mkdir ' + self.busy_URL + "/" + names[0] + "/" + names[1])
IndexError: list index out of range

C:\Users\user>captcha22 server engine
Class start
Checking if there is any new files
['./Unsorted\data.zip']
Start running
Copy files
Starting the copy of files
The syntax of the command is incorrect.
Traceback (most recent call last):
File "c:\users\user\anaconda3\lib\runpy.py", line 193, in run_module_as_main
"main", mod_spec)
File "c:\users\user\anaconda3\lib\runpy.py", line 85, in run_code
exec(code, run_globals)
File "C:\Users\user\anaconda3\Scripts\captcha22.exe_main
.py", line 7, in
sites = site.getsitepackages()
File "c:\users\user\anaconda3\lib\site-packages\captcha22_main
.py", line 267, in main
args.func(args)
File "c:\users\user\anaconda3\lib\site-packages/captcha22\lib\core\server.py", line 20, in server
server.main()
File "c:\users\user\anaconda3\lib\site-packages/captcha22\lib\server\captcha22.py", line 512, in main
self.run_server()
File "c:\users\user\anaconda3\lib\site-packages/captcha22\lib\server\captcha22.py", line 487, in run_server
self.check_files()
File "c:\users\user\anaconda3\lib\site-packages/captcha22\lib\server\captcha22.py", line 396, in check_files
self.copy_files(file)
File "c:\users\user\anaconda3\lib\site-packages/captcha22\lib\server\captcha22.py", line 256, in copy_files
os.system('mkdir ' + self.busy_URL + "/" + names[0] + "/" + names[1])
IndexError: list index out of range

C:\Users\user>captcha22 server engine
Class start
Checking if there is any new files
['./Unsorted\data.zip']
Start running
Copy files
Starting the copy of files
The syntax of the command is incorrect.
Traceback (most recent call last):
File "c:\users\user\anaconda3\lib\runpy.py", line 193, in run_module_as_main
"main", mod_spec)
File "c:\users\user\anaconda3\lib\runpy.py", line 85, in run_code
exec(code, run_globals)
File "C:\Users\user\anaconda3\Scripts\captcha22.exe_main
.py", line 7, in
sites = site.getsitepackages()
File "c:\users\user\anaconda3\lib\site-packages\captcha22_main
.py", line 267, in main
args.func(args)
File "c:\users\user\anaconda3\lib\site-packages/captcha22\lib\core\server.py", line 20, in server
server.main()
File "c:\users\user\anaconda3\lib\site-packages/captcha22\lib\server\captcha22.py", line 512, in main
self.run_server()
File "c:\users\user\anaconda3\lib\site-packages/captcha22\lib\server\captcha22.py", line 487, in run_server
self.check_files()
File "c:\users\user\anaconda3\lib\site-packages/captcha22\lib\server\captcha22.py", line 396, in check_files
self.copy_files(file)
File "c:\users\user\anaconda3\lib\site-packages/captcha22\lib\server\captcha22.py", line 256, in copy_files
os.system('mkdir ' + self.busy_URL + "/" + names[0] + "/" + names[1])
IndexError: list index out of range`

No tensorflow.contrib and aocr.log

Hi,
I got problems while training.

  1. ModuleNotFoundError: No module named 'tensorflow.contrib'
  2. FileNotFoundError: [Errno 2] No such file or directory: './Busy/admin/try1/1/aocr.log'

There were other errors but they seemed to be about GPU, since I'm using CPU for Tensor. So I didn't includ them.

Could you help me with the issues?

Here's the log from terminal.

Traceback (most recent call last):
  File ".../Captcha/captcha_env/lib/python3.8/site-packages/aocr/model/seq2seq.py", line 73, in <module>
    linear = rnn_cell_impl._linear  # pylint: disable=protected-access
AttributeError: module 'tensorflow.python.ops.rnn_cell_impl' has no attribute '_linear'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File ".../Captcha/captcha_env/bin/aocr", line 11, in <module>
    load_entry_point('aocr==0.7.6', 'console_scripts', 'aocr')()
  File ".../Captcha/captcha_env/lib/python3.8/site-packages/pkg_resources/__init__.py", line 489, in load_entry_point
    return get_distribution(dist).load_entry_point(group, name)
  File ".../Captcha/captcha_env/lib/python3.8/site-packages/pkg_resources/__init__.py", line 2852, in load_entry_point
    return ep.load()
  File ".../Captcha/captcha_env/lib/python3.8/site-packages/pkg_resources/__init__.py", line 2443, in load
    return self.resolve()
  File ".../Captcha/captcha_env/lib/python3.8/site-packages/pkg_resources/__init__.py", line 2449, in resolve
    module = __import__(self.module_name, fromlist=['__name__'], level=0)
  File ".../Captcha/captcha_env/lib/python3.8/site-packages/aocr/__main__.py", line 14, in <module>
    from .model.model import Model
  File ".../Captcha/captcha_env/lib/python3.8/site-packages/aocr/model/model.py", line 18, in <module>
    from .seq2seq_model import Seq2SeqModel
  File ".../Captcha/captcha_env/lib/python3.8/site-packages/aocr/model/seq2seq_model.py", line 25, in <module>
    from .seq2seq import model_with_buckets
  File ".../Captcha/captcha_env/lib/python3.8/site-packages/aocr/model/seq2seq.py", line 76, in <module>
    from tensorflow.contrib.rnn.python.ops import core_rnn_cell
ModuleNotFoundError: No module named 'tensorflow.contrib'
INFO:Captcha22 Engine:Create model
INFO:Captcha22 Engine:./Unsorted/admin_try1_1.zip
INFO:Captcha22 Engine:Updating file
INFO:Captcha22 Engine:Done
INFO:Captcha22 Engine:Going to start the model training procedure
INFO:Captcha22 Engine:Starting training
INFO:Captcha22 Engine:Starting wait cycle
nohup: appending output to 'nohup.out'
INFO:Captcha22 Engine:Model update
INFO:Captcha22 Engine:Testing training level
Traceback (most recent call last):
  File ".../Captcha/captcha_env/bin/captcha22", line 11, in <module>
    load_entry_point('captcha22==1.0.6', 'console_scripts', 'captcha22')()
  File ".../Captcha/captcha_env/lib/python3.8/site-packages/captcha22/__main__.py", line 278, in main
    args.func(args)
  File ".../Captcha/captcha_env/lib/python3.8/site-packages/captcha22/lib/core/server.py", line 22, in server
    server.main()
  File ".../Captcha/captcha_env/lib/python3.8/site-packages/captcha22/lib/server/captcha22.py", line 519, in main
    self.run_server()
  File ".../Captcha/captcha_env/lib/python3.8/site-packages/captcha22/lib/server/captcha22.py", line 495, in run_server
    self.continue_training()
  File ".../Captcha/captcha_env/lib/python3.8/site-packages/captcha22/lib/server/captcha22.py", line 437, in continue_training
    model.test_training_level()
  File ".../Captcha/captcha_env/lib/python3.8/site-packages/captcha22/lib/server/captcha22.py", line 130, in test_training_level
    f = open(self.path + "aocr.log")
FileNotFoundError: [Errno 2] No such file or directory: './Busy/admin/try1/1/aocr.log'

You have '.png' hardcoded in the server.

If i run captcha22 client label --image-type jpg, and give the genreated zip file to the engine. I get this error

Traceback (most recent call last):
  File "/usr/local/bin/captcha22", line 8, in <module>
    sys.exit(main())
  File "/usr/local/lib/python3.6/site-packages/captcha22/__main__.py", line 278, in main
    args.func(args)
  File "/usr/local/lib/python3.6/site-packages/captcha22/lib/core/server.py", line 22, in server
    server.main()
  File "/usr/local/lib/python3.6/site-packages/captcha22/lib/server/captcha22.py", line 519, in main
    self.run_server()
  File "/usr/local/lib/python3.6/site-packages/captcha22/lib/server/captcha22.py", line 494, in run_server
    self.check_files()
  File "/usr/local/lib/python3.6/site-packages/captcha22/lib/server/captcha22.py", line 409, in check_files
    self.create_model(file)
  File "/usr/local/lib/python3.6/site-packages/captcha22/lib/server/captcha22.py", line 375, in create_model
    model = captcha(path, self.logger)
  File "/usr/local/lib/python3.6/site-packages/captcha22/lib/server/captcha22.py", line 55, in __init__
    self.get_image_size()
  File "/usr/local/lib/python3.6/site-packages/captcha22/lib/server/captcha22.py", line 61, in get_image_size
    img = cv2.imread(images[0])
IndexError: list index out of range

Likely because you have .png hardcoded here:
https://github.com/FSecureLABS/captcha22/blob/f5e2662f64cbb4d2606982a1b1d0a449a081631f/captcha22/lib/server/captcha22.py#L60

no training process

OS: Ubuntu 20.04.2 LTS in wsl2
Python: Anaconda python 3.7.9
Tensorflow: 1.15.5, cpu only

(captcha22) user1@DESKTOP-ABCDEF:~/anaconda3/envs/captcha22$ captcha22 server engine
INFO:Captcha22 Engine:Captcha22 engine start
INFO:Captcha22 Engine:Starting training
INFO:Captcha22 Engine:Checking if there are any new files
INFO:Captcha22 Engine:Start running
INFO:Captcha22 Engine:Model update
INFO:Captcha22 Engine:Testing training level
Traceback (most recent call last):
  File "/home/user1/anaconda3/envs/captcha22/bin/captcha22", line 8, in <module>
    sys.exit(main())
  File "/home/user1/anaconda3/envs/captcha22/lib/python3.7/site-packages/captcha22/__main__.py", line 278, in main
    args.func(args)
  File "/home/user1/anaconda3/envs/captcha22/lib/python3.7/site-packages/captcha22/lib/core/server.py", line 22, in server
    server.main()
  File "/home/user1/anaconda3/envs/captcha22/lib/python3.7/site-packages/captcha22/lib/server/captcha22.py", line 519, in main
    self.run_server()
  File "/home/user1/anaconda3/envs/captcha22/lib/python3.7/site-packages/captcha22/lib/server/captcha22.py", line 495, in run_server
    self.continue_training()
  File "/home/user1/anaconda3/envs/captcha22/lib/python3.7/site-packages/captcha22/lib/server/captcha22.py", line 437, in continue_training
    model.test_training_level()
  File "/home/user1/anaconda3/envs/captcha22/lib/python3.7/site-packages/captcha22/lib/server/captcha22.py", line 138, in test_training_level
    step = ast.literal_eval(values[1].split('Step ')[1].split(':')[0])
IndexError: list index out of range

direct aocr execution and output:

(captcha22) user1@DESKTOP-ABCDEF:~/anaconda3/envs/captcha22/Busy/admin/test/1$ aocr train --max-height 220 --max-width 50 labels/training.tfrecords
WARNING:tensorflow:From /home/user1/anaconda3/envs/captcha22/lib/python3.7/site-packages/aocr/__main__.py:20: The name tf.logging.set_verbosity is deprecated. Please use tf.compat.v1.logging.set_verbosity instead.

WARNING:tensorflow:From /home/user1/anaconda3/envs/captcha22/lib/python3.7/site-packages/aocr/__main__.py:20: The name tf.logging.ERROR is deprecated. Please use tf.compat.v1.logging.ERROR instead.

2021-04-12 18:10:29.129743: I tensorflow/core/platform/profile_utils/cpu_utils.cc:94] CPU Frequency: 2195015000 Hz
2021-04-12 18:10:29.134487: I tensorflow/compiler/xla/service/service.cc:168] XLA service 0x55bdab3d0040 initialized for platform Host (this does not guarantee that XLA will be used). Devices:
2021-04-12 18:10:29.134673: I tensorflow/compiler/xla/service/service.cc:176]   StreamExecutor device (0): Host, Default Version
2021-04-12 18:10:29,140 root  INFO     phase: train
2021-04-12 18:10:29,140 root  INFO     model_dir: ./checkpoints
2021-04-12 18:10:29,141 root  INFO     load_model: True
2021-04-12 18:10:29,141 root  INFO     output_dir: ./results
2021-04-12 18:10:29,141 root  INFO     steps_per_checkpoint: 100
2021-04-12 18:10:29,142 root  INFO     batch_size: 65
2021-04-12 18:10:29,142 root  INFO     learning_rate: 1.000000
2021-04-12 18:10:29,142 root  INFO     reg_val: 0
2021-04-12 18:10:29,142 root  INFO     max_gradient_norm: 5.000000
2021-04-12 18:10:29,143 root  INFO     clip_gradients: True
2021-04-12 18:10:29,143 root  INFO     max_image_width 50.000000
2021-04-12 18:10:29,143 root  INFO     max_prediction_length 8.000000
2021-04-12 18:10:29,143 root  INFO     channels: 1
2021-04-12 18:10:29,143 root  INFO     target_embedding_size: 10.000000
2021-04-12 18:10:29,144 root  INFO     attn_num_hidden: 128
2021-04-12 18:10:29,144 root  INFO     attn_num_layers: 2
2021-04-12 18:10:29,144 root  INFO     visualize: False
2021-04-12 18:10:45,579 root  INFO     Reading model parameters from ./checkpoints/model.ckpt-0
2021-04-12 18:10:46.030381: W tensorflow/core/common_runtime/colocation_graph.cc:983] Failed to place the graph without changing the devices of some resources. Some of the operations (that had to be colocated with resource generating operations) are not supported on the resources' devices. Current candidate devices are [
  /job:localhost/replica:0/task:0/device:CPU:0].
See below for details of this colocation group:
Colocation Debug Info:
Colocation group had the following types and supported devices: 
Root Member(assigned_device_name_index_=-1 requested_device_name_='/device:GPU:0' assigned_device_name_='' resource_device_name_='/device:GPU:0' supported_device_types_=[CPU] possible_devices_=[]
Assign: CPU 
RandomUniform: CPU XLA_CPU 
Const: CPU XLA_CPU 
Mul: CPU XLA_CPU 
Sub: CPU XLA_CPU 
ApplyAdadelta: CPU 
Add: CPU XLA_CPU 
Identity: CPU XLA_CPU 
VariableV2: CPU 

Colocation members, user-requested devices, and framework assigned devices, if any:
  conv_conv1/W/Initializer/random_uniform/shape (Const) 
  conv_conv1/W/Initializer/random_uniform/min (Const) 
  conv_conv1/W/Initializer/random_uniform/max (Const) 
  conv_conv1/W/Initializer/random_uniform/RandomUniform (RandomUniform) 
  conv_conv1/W/Initializer/random_uniform/sub (Sub) 
  conv_conv1/W/Initializer/random_uniform/mul (Mul) 
  conv_conv1/W/Initializer/random_uniform (Add) 
  conv_conv1/W (VariableV2) /device:GPU:0
  conv_conv1/W/Assign (Assign) /device:GPU:0
  conv_conv1/W/read (Identity) /device:GPU:0
  conv_conv1/W/Adadelta/Initializer/zeros (Const) /device:GPU:0
  conv_conv1/W/Adadelta (VariableV2) /device:GPU:0
  conv_conv1/W/Adadelta/Assign (Assign) /device:GPU:0
  conv_conv1/W/Adadelta/read (Identity) /device:GPU:0
  conv_conv1/W/Adadelta_1/Initializer/zeros (Const) /device:GPU:0
  conv_conv1/W/Adadelta_1 (VariableV2) /device:GPU:0
  conv_conv1/W/Adadelta_1/Assign (Assign) /device:GPU:0
  conv_conv1/W/Adadelta_1/read (Identity) /device:GPU:0
  Adadelta/update_conv_conv1/W/ApplyAdadelta (ApplyAdadelta) /device:GPU:0
  save/Assign_13 (Assign) /device:GPU:0
  save/Assign_14 (Assign) /device:GPU:0
  save/Assign_15 (Assign) /device:GPU:0

2021-04-12 18:10:46.032016: W tensorflow/core/common_runtime/colocation_graph.cc:983] Failed to place the graph without changing the devices of some resources. Some of the operations (that had to be colocated with resource generating operations) are not supported on the resources' devices. Current candidate devices are [
  /job:localhost/replica:0/task:0/device:CPU:0].
See below for details of this colocation group:
Colocation Debug Info:
Colocation group had the following types and supported devices:
[...] 
2021-04-12 18:10:50.219172: W tensorflow/core/common_runtime/colocation_graph.cc:983] Failed to place the graph without changing the devices of some resources. Some of the operations (that had to be colocated with resource generating operations) are not supported on the resources' devices. Current candidate devices are [
  /job:localhost/replica:0/task:0/device:CPU:0].
See below for details of this colocation group:
Colocation Debug Info:
Colocation group had the following types and supported devices: 
Root Member(assigned_device_name_index_=-1 requested_device_name_='/device:GPU:0' assigned_device_name_='' resource_device_name_='/device:GPU:0' supported_device_types_=[CPU] possible_devices_=[]
Switch: CPU XLA_CPU 
Enter: CPU XLA_CPU 
LookupTableFindV2: CPU 
LookupTableInsertV2: CPU 
MutableHashTableV2: CPU 
LookupTableExportV2: CPU 

Colocation members, user-requested devices, and framework assigned devices, if any:
  MutableHashTable (MutableHashTableV2) /device:GPU:0
  MutableHashTable_lookup_table_export_values/LookupTableExportV2 (LookupTableExportV2) /device:GPU:0
  MutableHashTable_lookup_table_insert/LookupTableInsertV2 (LookupTableInsertV2) /device:GPU:0
  map_1/while/foldr/while/cond/MutableHashTable_lookup_table_find/LookupTableFindV2/Enter (Enter) /device:GPU:0
  map_1/while/foldr/while/cond/MutableHashTable_lookup_table_find/LookupTableFindV2/Enter_1 (Enter) /device:GPU:0
  map_1/while/foldr/while/cond/MutableHashTable_lookup_table_find/LookupTableFindV2/Switch (Switch) /device:GPU:0
  map_1/while/foldr/while/cond/MutableHashTable_lookup_table_find/LookupTableFindV2/Enter_2 (Enter) /device:GPU:0
  map_1/while/foldr/while/cond/MutableHashTable_lookup_table_find/LookupTableFindV2/Enter_3 (Enter) /device:GPU:0
  map_1/while/foldr/while/cond/MutableHashTable_lookup_table_find/LookupTableFindV2/Switch_2 (Switch) /device:GPU:0
  map_1/while/foldr/while/cond/MutableHashTable_lookup_table_find/LookupTableFindV2 (LookupTableFindV2) /device:GPU:0

2021-04-12 18:10:52,255 root  INFO     Global step 0. Time: 0.000, loss: 0.000000, perplexity: 1.00.
2021-04-12 18:10:52,255 root  INFO     Finishing the training and saving the model at step 0.

it just repeat the warning message until the end of the execution

Additional training

Hi, is this possible, to train the already made model with additional sets?

No module named 'tensorflow.contrib'

Hello,

on

captcha22 server engine

I get this

INFO:Captcha22 Engine:Create labels
INFO:Captcha22 Engine:Directories is:
INFO:Captcha22 Engine:./Busy/admin/2/1/data/
INFO:Captcha22 Engine:./Busy/admin/2/1/labels/
INFO:Captcha22 Engine:Generate aocr
Traceback (most recent call last):
  File "/usr/local/lib/python3.6/dist-packages/aocr/model/seq2seq.py", line 73, in <module>
    linear = rnn_cell_impl._linear  # pylint: disable=protected-access
AttributeError: module 'tensorflow.python.ops.rnn_cell_impl' has no attribute '_linear'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/usr/local/bin/aocr", line 5, in <module>
    from aocr.__main__ import main
  File "/usr/local/lib/python3.6/dist-packages/aocr/__main__.py", line 14, in <module>
    from .model.model import Model
  File "/usr/local/lib/python3.6/dist-packages/aocr/model/model.py", line 18, in <module>
    from .seq2seq_model import Seq2SeqModel
  File "/usr/local/lib/python3.6/dist-packages/aocr/model/seq2seq_model.py", line 25, in <module>
    from .seq2seq import model_with_buckets
  File "/usr/local/lib/python3.6/dist-packages/aocr/model/seq2seq.py", line 76, in <module>
    from tensorflow.contrib.rnn.python.ops import core_rnn_cell
ModuleNotFoundError: No module named 'tensorflow.contrib'

jet@jet:~/captcher$ uname -a
Linux jet 4.9.253-tegra #1 SMP PREEMPT Mon Jul 26 12:13:06 PDT 2021 aarch64 aarch64 aarch64 GNU/Linux
jet@jet:~/captcher$ python --version
Python 3.6.9
jet@jet:~/captcher$ pip --version
pip 21.3.1 from /usr/local/lib/python3.6/dist-packages/pip (python 3.6)
jet@jet:~/captcher$
jet@jet:~/captcher$ python 
Python 3.6.9 (default, Dec  8 2021, 21:08:43) 
[GCC 8.4.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import tensorflow
>>> import tensorflow as tf; print(tf.__version__)
2.6.2

What am I doin wrong?

Thank you

FileNotFound error

Hi, I downloaded captchas and converted them to png, then use captcha22 client label --input='captchasFolder' as in the readme.
I found out that I had to rename the data.zip into admin_somename_someid.zip and then launch the server otherwise I have issue #4.
But it still crashes, first there is this message:
INFO:Captcha22 Engine:Generate aocr
Illegal instruction
Illegal instruction
and a bit further (I think after I has finished training):
INFO:Captcha22 Engine:Testing training level
Traceback (most recent call last):
File "/home/owein/.local/bin/captcha22", line 8, in
sys.exit(main())
File "/home/owein/.local/lib/python3.9/site-packages/captcha22/main.py", line 278, in main
args.func(args)
File "/home/owein/.local/lib/python3.9/site-packages/captcha22/lib/core/server.py", line 22, in server
server.main()
File "/home/owein/.local/lib/python3.9/site-packages/captcha22/lib/server/captcha22.py", line 519, in main
self.run_server()
File "/home/owein/.local/lib/python3.9/site-packages/captcha22/lib/server/captcha22.py", line 495, in run_server
self.continue_training()
File "/home/owein/.local/lib/python3.9/site-packages/captcha22/lib/server/captcha22.py", line 437, in continue_training
model.test_training_level()
File "/home/owein/.local/lib/python3.9/site-packages/captcha22/lib/server/captcha22.py", line 130, in test_training_level
f = open(self.path + "aocr.log")
FileNotFoundError: [Errno 2] No such file or directory: './Busy/admin/name/1/aocr.log'

I tried to touch the missing log file but then:
File "/home/owein/.local/lib/python3.9/site-packages/captcha22/lib/server/captcha22.py", line 138, in test_training_level
step = ast.literal_eval(values[1].split('Step ')[1].split(':')[0])
IndexError: list index out of range

Is it possible to use captcha22 from then without starting the engine but only the api server to ignore this error ?

AttributeError: 'captcha' object has no attribute 'logger'

INFO:Captcha22 Engine:Create model
INFO:Captcha22 Engine:./Unsorted/admin_testcaptcha1_1.zip
INFO:Captcha22 Engine:Updating file
INFO:Captcha22 Engine:Done
INFO:Captcha22 Engine:Going to start the model training procedure
Traceback (most recent call last):
  File "/home/thijs/.virtualenvs/captcha/bin/captcha22", line 8, in <module>
    sys.exit(main())
  File "/home/thijs/.virtualenvs/captcha/lib/python3.7/site-packages/captcha22/__main__.py", line 404, in main
    args.func(args)
  File "/home/thijs/.virtualenvs/captcha/lib/python3.7/site-packages/captcha22/lib/core/server.py", line 23, in server
    server.main()
  File "/home/thijs/.virtualenvs/captcha/lib/python3.7/site-packages/captcha22/lib/server/captcha22.py", line 517, in main
    self.run_server()
  File "/home/thijs/.virtualenvs/captcha/lib/python3.7/site-packages/captcha22/lib/server/captcha22.py", line 493, in run_server
    self.continue_training()
  File "/home/thijs/.virtualenvs/captcha/lib/python3.7/site-packages/captcha22/lib/server/captcha22.py", line 467, in continue_training
    model.start_training()
  File "/home/thijs/.virtualenvs/captcha/lib/python3.7/site-packages/captcha22/lib/server/captcha22.py", line 201, in start_training
    self.logger.info("Starting training")
AttributeError: 'captcha' object has no attribute 'logger'

captcha22 client label should copy files

I came across this project and thought I'd give it a try with a very limited set of 4 captchas.

After downloading and installing using pip I ran:

captcha22 client label --input=captchas

I labeled the images and a data directory was created:

$ ls -lh data/
total 2,0M
-rw-rw-r-- 1 thijs thijs 665K dec  5 22:08 2YREA9.png
-rw-rw-r-- 1 thijs thijs 630K dec  5 22:08 6PA5K7.png
-rw-rw-r-- 1 thijs thijs  11K dec  5 22:03 NTEMYU.png
-rw-rw-r-- 1 thijs thijs 724K dec  5 22:08 XAMK6Q.png

Unfortunately it seems all my original captchas were moved by this script and I mistakenly deleted the data dir. Have to harvest some new ones now :( Would be really useful if captcha22 leaves the originals alone or mentions it very clearly in the readme that these files will be moved.

It also seems JPG files are not supported:

INFO:Captcha22 Label Scripts:Executing CAPTCHA Typing Script
INFO:Captcha22 Typer:No png files found

Update: found the --image-type option for this:

captcha22 client label --image-type=jpg --input=captchas

outputs

python3.7/site-packages/captcha22/lib/crackers/captcha.py", line 208, in solve_captcha
return (json_data['outputs']['output'])
KeyError: 'outputs'

Error Running Captcha22 In Terminal after installing on UBUNTU 20.04.1 LTS

Installing captcha22 using both pip install captcha22 and install from the source seem to work fine, but when running right after installing, I get this error:

user@user-Predator-G3-571:~$ captcha22 Traceback (most recent call last): File "/usr/local/bin/captcha22", line 11, in <module> load_entry_point('captcha22==1.0.1', 'console_scripts', 'captcha22')() File "/usr/lib/python3/dist-packages/pkg_resources/__init__.py", line 490, in load_entry_point return get_distribution(dist).load_entry_point(group, name) File "/usr/lib/python3/dist-packages/pkg_resources/__init__.py", line 2854, in load_entry_point return ep.load() File "/usr/lib/python3/dist-packages/pkg_resources/__init__.py", line 2445, in load return self.resolve() File "/usr/lib/python3/dist-packages/pkg_resources/__init__.py", line 2451, in resolve module = __import__(self.module_name, fromlist=['__name__'], level=0) File "/home/user/.local/lib/python3.8/site-packages/captcha22/__main__.py", line 12, in <module> from lib.core.client import (api_basic, api_full, captcha_labeller, ModuleNotFoundError: No module named 'lib.core' user@user-Predator-G3-571:~$

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.