You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
arnaucode 49070e97b3 implemented javascript library, with css. Just need to call library and place a <div> in the html to use goCaptcha 7 years ago
web implemented javascript library, with css. Just need to call library and place a <div> in the html to use goCaptcha 7 years ago
.gitignore implemented javascript library, with css. Just need to call library and place a <div> in the html to use goCaptcha 7 years ago
LICENSE Initial commit 7 years ago
README.md implemented javascript library, with css. Just need to call library and place a <div> in the html to use goCaptcha 7 years ago
captcha.go implemented captcha validation 7 years ago
demo01.png implemented javascript library, with css. Just need to call library and place a <div> in the html to use goCaptcha 7 years ago
errors.go serve images runs ok 7 years ago
goCaptcha implemented javascript library, with css. Just need to call library and place a <div> in the html to use goCaptcha 7 years ago
imageOperations.go implemented: generate captcha and captcha solution, returns only captcha which has only fake image names and captchaid, stores also translator fake image name to real. Implemented read images dataset, storing in categories (folders names). GetImage reads fake image name, and translates to real image name, and serves the image content as fake image name 7 years ago
log.go serve images runs ok 7 years ago
main.go implemented captcha validation 7 years ago
mongoConfig.go implemented captcha validation 7 years ago
mongodbConfig.json implemented: generate captcha and captcha solution, returns only captcha which has only fake image names and captchaid, stores also translator fake image name to real. Implemented read images dataset, storing in categories (folders names). GetImage reads fake image name, and translates to real image name, and serves the image content as fake image name 7 years ago
readDataset.go implemented: generate captcha and captcha solution, returns only captcha which has only fake image names and captchaid, stores also translator fake image name to real. Implemented read images dataset, storing in categories (folders names). GetImage reads fake image name, and translates to real image name, and serves the image content as fake image name 7 years ago
serverConfig.go serve images runs ok 7 years ago
serverConfig.json serve images runs ok 7 years ago
serverRoutes.go implemented captcha validation 7 years ago

README.md

goCaptcha

captcha server, with own datasets, to train own machine learning AI

How to use?

Frontend

Insert this lines in the html file:

    <link rel="stylesheet" href="goCaptcha.css">

    <div id="goCaptcha"></div>

    <script>//define the url where is placed the server of goCaptcha
        var goCaptchaURL = "http://127.0.0.1:3025";
    </script>
    <script src="goCaptcha.js"></script>

It will place the goCaptcha box in the div:

goCaptcha

Backend

  • Put dataset images in the folder 'imgs'.
  • Run MongoDB.
  • Go to the folder /goCaptcha, and run:
./goCaptcha

It will show:

user@laptop:~/goCaptcha$ ./goCaptcha
    goCaptcha started
    dataset read
    num of dataset categories: 4
    server running
    port: 3025

How to make the petitions?

  1. Get the captcha:
GET/ 127.0.0.1:3025/captcha

Server response:

{
    "id": "881c6083-0643-4d1c-9987-f8cc5bb9d5b1",
    "imgs": [
        "7cf6f630-e78f-469c-85dd-2d677996fea1.png",
        "d4014318-f875-4b42-b704-4f5bf5e5e00c.png",
        "2dd69b44-903d-4e78-bb7b-f8b07877c9e5.png",
        "2954fc38-819d-40c9-ae3e-7b6fbb68ddbe.png",
        "b060f58a-d44b-4e05-b466-92aa801a2aa1.png",
        "1b838c46-b784-471e-b143-48be058c39a7.png"
    ],
    "question": "leopard",
    "date": ""
}
  1. User selects the images that fit in the 'question' parameter (in this case, 'leopard')

  2. Post the answer. The answer contains the CaptchaId, and an array with the selected images

POST/ 127.0.0.1:3025/answer

Post example:

{
	"captchaid": "881c6083-0643-4d1c-9987-f8cc5bb9d5b1",
	"selection": [0,0,0,0,1,1]
}

Server response:

true

How this works?

Server reads dataset

First, server reads all dataset. Dataset is a directory with subdirectories, where each subdirectory contains images of one element.

For example:

imgs/
    leopard/
        img01.png
        img02.png
        img03.png
        ...
    laptop/
        img01.png
        img02.png
        ...
    house/
        img01.png
        img02.png
        ...

Then, stores all the filenames corresponding to each subdirectory. So, we have each image and to which element category is (the name of subdirectory).

Server generates captcha

When server recieves a GET /captcha, generates a captcha, getting random images from the dataset.

For each captcha generated, generates two mongodb models:

Captcha Model
{
    "id" : "881c6083-0643-4d1c-9987-f8cc5bb9d5b1",
    "imgs" : [
        "7cf6f630-e78f-469c-85dd-2d677996fea1.png",
        "d4014318-f875-4b42-b704-4f5bf5e5e00c.png",
        "2dd69b44-903d-4e78-bb7b-f8b07877c9e5.png",
        "2954fc38-819d-40c9-ae3e-7b6fbb68ddbe.png",
        "b060f58a-d44b-4e05-b466-92aa801a2aa1.png",
        "1b838c46-b784-471e-b143-48be058c39a7.png"
    ],
    "question" : "leopard"
}
CaptchaSolution Model
{
    "id" : "881c6083-0643-4d1c-9987-f8cc5bb9d5b1",
    "imgs" : [
        "image_0022.jpg",
        "image_0006.jpg",
        "image_0050.jpg",
        "image_0028.jpg",
        "image_0119.jpg",
        "image_0092.jpg"
    ],
    "imgssolution" : [
        "camera",
        "camera",
        "laptop",
        "crocodile",
        "leopard",
        "leopard"
    ],
    "question" : "leopard"
}

Both models are stored in the MongoDB.

The Captcha Model 'imgs' parameter, are UUIDs generated to set 'random' names to images. The server stores into MongoDB the relation between the 'random' name of each image and the real path of the image:

{
    "captchaid" : "881c6083-0643-4d1c-9987-f8cc5bb9d5b1",
    "real" : "leopard/image_0092.jpg",
    "fake" : "1b838c46-b784-471e-b143-48be058c39a7.png"
}

When the server recieves a petition to get an image, recieves the petition with the fake image name, then, gets the real path of the image, gets it and serves the image content under the fake image name:

127.0.0.1:3025/image/1b838c46-b784-471e-b143-48be058c39a7.png

Captcha Model contains the captcha that server returns to the petition. And CaptchaSolution contains the solution of the captcha. Both have the same Id.

Server validates captcha

When server recieves POST /answer, gets the answer, search for the CaptchaSolution based on the CaptchaId in the MongoDB, and then compares the answer 'selection' parameter with the CaptchaSolution.

If the selection is correct, returns 'true', if the selection is not correct, returns 'false'.