All Projects → decryptr → Decryptr

decryptr / Decryptr

Licence: gpl-3.0
An extensible API for breaking captchas

Programming Languages

r
7636 projects

Projects that are alternatives of or similar to Decryptr

rfordatasciencewiki
Resources for the R4DS Online Learning Community, including answer keys to the text
Stars: ✭ 40 (-74.03%)
Mutual labels:  tidyverse, rstats
Moderndive book
Statistical Inference via Data Science: A ModernDive into R and the Tidyverse
Stars: ✭ 527 (+242.21%)
Mutual labels:  tidyverse, rstats
casewhen
Create reusable dplyr::case_when() functions
Stars: ✭ 64 (-58.44%)
Mutual labels:  tidyverse, rstats
Polite
Be nice on the web
Stars: ✭ 253 (+64.29%)
Mutual labels:  webscraping, rstats
Pkgverse
📦🔭🌠 Create your own universe of packages à la tidyverse
Stars: ✭ 108 (-29.87%)
Mutual labels:  tidyverse, rstats
Talks
Repository of publicly available talks by Leon Eyrich Jessen, PhD. Talks cover Data Science and R in the context of research
Stars: ✭ 16 (-89.61%)
Mutual labels:  tidyverse, rstats
Tidytuesday
📊 My contributions to the #TidyTuesday challenge
Stars: ✭ 410 (+166.23%)
Mutual labels:  tidyverse, rstats
Tidygeocoder
Geocoding Made Easy
Stars: ✭ 137 (-11.04%)
Mutual labels:  tidyverse, rstats
Ggplot Courses
👨‍🏫 ggplot2 Teaching Material
Stars: ✭ 40 (-74.03%)
Mutual labels:  tidyverse, rstats
Tidymv
Tidy Model Visualisation for Generalised Additive Models
Stars: ✭ 25 (-83.77%)
Mutual labels:  tidyverse, rstats
Ralger
ralger makes it easy to scrape a website. Built on the shoulders of titans: rvest, xml2.
Stars: ✭ 130 (-15.58%)
Mutual labels:  webscraping, rstats
Tidyversity
🎓 Tidy tools for academics
Stars: ✭ 155 (+0.65%)
Mutual labels:  tidyverse, rstats
Shinyalert
🗯️ Easily create pretty popup messages (modals) in Shiny
Stars: ✭ 148 (-3.9%)
Mutual labels:  rstats
Qualtrics
Download ⬇️ Qualtrics survey data directly into R!
Stars: ✭ 151 (-1.95%)
Mutual labels:  rstats
Textfeatures
👷‍♂️ A simple package for extracting useful features from character objects 👷‍♀️
Stars: ✭ 148 (-3.9%)
Mutual labels:  rstats
Recaptcha
ReCaptcha helpers for ruby apps
Stars: ✭ 1,819 (+1081.17%)
Mutual labels:  captcha
Captcha solver
Universal python API to captcha solving services
Stars: ✭ 152 (-1.3%)
Mutual labels:  captcha
Tidyheatmap
Draw heatmap simply using a tidy data frame
Stars: ✭ 151 (-1.95%)
Mutual labels:  tidyverse
Btydplus
R package for Customer Behavior Analysis
Stars: ✭ 147 (-4.55%)
Mutual labels:  rstats
Complex Upset
A library for creating complex UpSet plots with ggplot2 geoms
Stars: ✭ 147 (-4.55%)
Mutual labels:  rstats

decryptr

R build status Coverage Status CRAN_Status_Badge

Overview

decryptr is an R package to break captchas. It is also an extensible tool built in a way that enables anyone to contribute with their own captcha-breaking code.

To install decryptr, simply run the code below:

if (!require(devtools)) install.packages("devtools")
devtools::install_github("decryptr/decryptr")

Basic usage

decryptr has functions for downloading and breaking captchas from multiple known sources. If you wanted to use this package with, let’s say, RFB (Receita Federal), you could go by the following steps:

# Download captcha from RFB
file <- download_captcha("rfb", path = "./img")

# Break captcha
decrypt(file, model = "rfb")
## [1] "hqj3wa"

Simple, right? The decrypt() funcion is this package’s workhorse: it is able to take a captcha (either the path to a captcha file or a captcha object read with read_captcha()) and break it with a model (either the name of a known model, the path to a model file or a model object created with train_model()).

If you’d like to visualize a captcha and make sure the decryption is working, you can use the plot() funcion to draw out the captcha image:

# Read captcha
captcha <- read_captcha(file)

# Plot captcha
plot(captcha[[1]])

If you want to learn more about the models that already come packaged with decryptr, check out load_model()’s documentation (and all of these models also have a corresponding download_captcha() method so you’re always good to go).

Advanced usage

If you’re willing to create your own custom captcha-breaking models, there are some other functions you might want to know about. classify() allows the user to manually answer a list of captchas, while train_model() takes a bunch of classified captchas and trains a keras model on them.

classify() has two modes: static and interactive. If you already know the answers to all captchas, simply turn them into a string vector and pass it onto the answers argument; on the other hand, if you’re going to manually classify the captchas, classify() will plot every captcha and prompt you in the console for their answers. In the snippet below, I use static classification to label a set of 10 captchas:

# URL of a captcha (for illustrative purposes I'll be using
# RFB's URL, but you can use whichever URL you want)
url <- paste0(
  "http://www.receita.fazenda.gov.br/pessoajuridica/",
  "cnpj/cnpjreva/captcha/gerarCaptcha.asp")

# Download captcha from URL
files <- download_captcha(url, n = 10, path = "./img")

# Answers to downloaded captchas
answers <- c(
  "fvhca9", "cyz4vl", "luzdve", "lb9mnq", "9bquah",
  "d1zwau", "mlvk1t", "g6zbyf", "17xauo", "bo6cdg")

# Classify captchas (if answers weren't supplied,
# I'd be promped for interactive classification)
new_files <- classify(files, answers, path = "./img")

Now that we have a set of classified captchas, we can use them to train a captcha-breaking model. classify() used our answers to create a new version of each file, one with the answer at the end of the filename separated by an underscore; read_captcha() has the ans_in_path argument that tells it to look for the answers in the filenames and create the captcha objects accordingly.

With this list of labeled captcha objects, we can call train_model() to generate a model. The model gets automatically saved to disk so that we can load it later with load_model().

# Read answered captchas
captchas <- read_captcha(new_files, ans_in_path = TRUE)

# Use captchas to train a model
model <- train_model(captchas, verbose = FALSE)

# Use our new model for decryption
decrypt(file, model = model)
## [1] "uq2lnr"
# We could also have loaded the model from disk
model <- load_model("./model.hdf5")

Performance

Once loaded to memory, keras models run very quickly Also, we don’t run any pre-processing on the image, so decryption is blazing fast.

microbenchmark::microbenchmark(decrypt = decrypt(captcha, model))
## Unit: milliseconds
##     expr      min       lq     mean   median       uq      max neval
##  decrypt 42.44801 46.52944 49.62947 48.48889 51.27224 109.3463   100
Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].