bakape / captchouli Goto Github PK
View Code? Open in Web Editor NEWbooru-backed procedurally-generated anime image captcha library and server
License: GNU Affero General Public License v3.0
booru-backed procedurally-generated anime image captcha library and server
License: GNU Affero General Public License v3.0
Probably need to use a media query + transform.
Hey,
I'm looking to integrate captchouli into my ViChan fork. I was impressed by it when I went on meguca and want to involve it in my efforts.
How do I go about using it on my site?
Something like, you run main.go and it listens on a port for you to send post requests?
Which files am I supposed to look at to understand setting it up on the client side?
Need to consider, if best way to integrate with external websites.
Ideas:
Write any errors to a char**
argument. This reduces possible errors in error handling.
Currently pkg-config does not even pick it up.
Will greatly decrease memory usage.
sample affected tag: miyauchi_renge
Provides better performance and multithreading support.
https://github.com/hybridgroup/gocv
https://github.com/nagadomi/lbpcascade_animeface
Ideas:
3x3 grid
2-3 images match (cryptographically random)
6-7 images are from other tags from the array
performance:
make it work 100% noscript
separate library
Build a file-based cache of existing correctly solved captcha HTML and give each request a 50% chance to use it. Ensure each reused captcha has a timeout.
Could probably create a library and reuse in Hydron.
Depends on #11
Instead of always having 3+1.
Better performance. Best done together with #32.
Will enable IDE aids.
len(map) == 0
-> worksafeIn favour of the much cleaner https://godoc.org/github.com/Masterminds/squirrel#SelectBuilder.RunWith
OpenCV(3.4.3) /var/tmp/portage/media-libs/opencv-3.4.3/work/opencv-3.4.3/modules/imgproc/src/color.cpp:181: error: (-215:Assertion failed) !_src.empty() in function 'cvtColor'
Useless now lol
import requests as req
from bs4 import BeautifulSoup
from PIL import Image
import re, base64
from io import BytesIO
import hashlib
import concurrent.futures as porn
import time, string, random
def ran_str(string_length):
input = string.ascii_lowercase + string.digits
return ''.join(random.choice(input) for i in range(string_length))
sneed1 = []
headers = {
'User-Agent': 'Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Firefox/102.0',
'Accept': 'text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,*/*;q=0.8',
'Accept-Language': 'en-US,en;q=0.5',
'Accept-Encoding': 'gzip, deflate, br',
'Origin': 'https://midov.pl',
'DNT': '1',
'Connection': 'keep-alive',
# 'Referer': 'https://midov.pl/registerform.sh',
'Upgrade-Insecure-Requests': '1',
'Sec-Fetch-Dest': 'document',
'Sec-Fetch-Mode': 'navigate',
'Sec-Fetch-Site': 'same-origin',
'Sec-Fetch-User': '?1',
'Pragma': 'no-cache',
'Cache-Control': 'no-cache',
# Requests doesn't support trailers
# 'TE': 'trailers',
}
answers = {
'liru': ['a67db0fc66aedba7e028a7da4999d67b','4cfe005813df6d8ce6847c9b2274f599','52351b9999f67c5e92c76c381bd4ffd7'],
'rem': ['c0c13825e8f35dcb36fab7ee5bc8f670','68e2750d81d48c6f1ac450ed24b5d601']
}
def send_post(data):
res = req.post('https://midov.pl/registerform.sh', headers=headers, data=data)
# print(res.text)
soup = BeautifulSoup(res.text, "html.parser")
captcha = soup.find_all('input', {'name':'captcha'})[0]['value']
# print(captcha)
u_name = ran_str(9)
p_word = ran_str(9)
data2 = {
'login': u_name,
'password': p_word,
'passwordagain': p_word,
'captcha': captcha,
}
# print(data2)
res = req.post('https://midov.pl/do-register.sh', headers=headers, data=data2)
if "You need to know the animu girls better." in res.text:
None
# print("Failure")
elif "Success!" in res.text:
print(res.text)
with open("accounts.kek", 'a') as f:
f.write(f"{u_name}:{p_work}\n")
else:
print(res.text)
def sneed(i):
# for x in range(1):
while True:
res = req.get("https://midov.pl/registerform.sh", headers=headers)
soup = BeautifulSoup(res.text, "html.parser")
img_list = soup.find_all('img')
label = soup.find_all('b')[0].text.lower()
captchouli_id = soup.find_all('input', {'name':'captchouli-id'})[0]['value']
captchouli_color = soup.find_all('input', {'name':'captchouli-color'})[0]['value']
captchouli_background = soup.find_all('input', {'name':'captchouli-background'})[0]['value']
# if not "rem" in label:
# continue
if "liru" != label:
time.sleep(2)
continue
print(label)
data_dict_to_send = {
'captchouli-id': captchouli_id,
'captchouli-color': captchouli_color,
'captchouli-background': captchouli_background,
}
for i in range(len(img_list)):
image_bytes = img_list[i]['src']
md5_img = hashlib.md5(
image_bytes.encode('utf-8')).hexdigest()
# print(i, md5_img)
# if md5_img in answers["rem"]:
if md5_img in answers[label]:
# print("in DB",i, md5_img)
data_dict_to_send[f'captchouli-{i}'] = 'on'
print(data_dict_to_send)
send_post(data_dict_to_send)
break
sneed(1)
Use pre-captchouli captcha image obfuscation perhaps, use image of name instead of text.
Currently it stalls forever. Sample: chito_(shoujo_shuumatsu_ryokou)
What is wrong when I try to use tag kissxsis
and it does this indefinitely and I want to be able to use non-work safe images too?
2019/12/27 07:06:58 captchouli: initializing tag=kissxsis explicitness=[safe, questionable, explicit]
fetch attempt: 3290540
Prevents googling the name.
Also having more than say 6 captchas go past the time limit would trigger ban, but that might be a meguca issue.
Anyway, two ways to fail, user fail and time limit fail, user fail is normal limit, time limit is normal times 2 perhaps.
I've been using captchouli for a while with the following Dockerfile, and it's worked great:
FROM debian:buster-slim
# install prereqs
RUN apt-get update
RUN apt-get install -y golang libopencv-dev
RUN apt-get install -y git
# grab utils for bootstrapping watcher
RUN apt-get install -y netcat-openbsd psmisc
# make a new user so we don't run as root
RUN useradd -r captchouli
WORKDIR /home/captchouli
RUN chown -R captchouli /home/captchouli
# preemptively make the supporting directory so docker won't
# attempt to make a new directory owned by root (aids when
# attempting to persist .captchouli)
RUN mkdir -p .captchouli/images
RUN chown -R captchouli .captchouli
# install captchouli
USER captchouli
RUN go get github.com/bakape/captchouli/cmd/captchouli
# setup entrypoint and port
COPY entrypoint.sh .
COPY captchouli.sh .
EXPOSE 8512
# entrypoint switches back to the captchouli user but needs to
# start with root privileges
USER root
ENTRYPOINT ["sh", "./entrypoint.sh"]
(There's also captchouli.sh and entrypoint.sh, but they're small shell scripts and don't really do much beyond handle startup.)
Lately, I tried to rebuild my captchouli container and got the following message when initializing the tag database (with me exiting the container on the last two lines, and the first line stemming from captchouli.sh
):
Waiting for captchouli to finish bootstrapping...
2020/05/05 12:35:04 captchouli: upgrading database to version 1
2020/05/05 12:35:04 captchouli: upgrading database to version 2
2020/05/05 12:35:04 captchouli: upgrading database to version 3
2020/05/05 12:35:04 captchouli: upgrading database to version 4
2020/05/05 12:35:04 captchouli: initializing tag=izayoi_sakuya explicitness=[safe, questionable, explicit]
fetch attempt: 1 panic: captchouli: error initializing image pool for tag `izayoi_sakuya`: &{%!w(string=number) %!w(*reflect.rtype=&{1 0 335480517 7 1 1 129 0xbe4ec0 0x93b6c1 9448 169216}) %!w(int64=306) %!w(string=gelbooruDecoder) %!w(string=Sample)}
goroutine 1 [running]:
main.main()
/home/captchouli/go/src/github.com/bakape/captchouli/cmd/captchouli/main.go:52 +0x307
^C
Session terminated, killing shell... ...killed.
Now, I realized I had the prerequisites for captchouli still directly installed on my Debian Sid machine, and so I re-installed captchouli on my laptop without any containers to see what would happen, and got the following message:
2020/05/05 07:33:59 captchouli: upgrading database to version 1
2020/05/05 07:33:59 captchouli: upgrading database to version 2
2020/05/05 07:33:59 captchouli: upgrading database to version 3
2020/05/05 07:33:59 captchouli: upgrading database to version 4
2020/05/05 07:33:59 captchouli: initializing tag=senjougahara_hitagi explicitness=[safe]
fetch attempt: 1 panic: captchouli: error initializing image pool for tag `senjougahara_hitagi`: json: cannot unmarshal number into Go struct field gelbooruDecoder.Sample of type bool
goroutine 1 [running]:
main.main()
/home/kermit/projects/go/src/github.com/bakape/captchouli/cmd/captchouli/main.go:52 +0x3ee
Any idea as to what the problem might be?
assuming that you have a large corpus of (image, character name) data, you should be able to plug that into an off-the-shelf ML lib and get a model that solves the current captchas.
from there, apply filters to the images, retrain your solver, and repeat until you can no longer train the solver with decent accuracy.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.