# CLI tool - mCaptcha
Instructions to install mCaptcha CLI

# CLI tool

A CLI tool exists to compute mCaptcha challenges. It can be installed from multiple sources:

## Install#

### crates.io#

The CLI tool is available on, crates.io, the Rust language’s package registry. Rust language toolchain is required to install from crates.io, please see rustup.rs for Instructions to install it.

    1cargo install mcaptcha-cli

### Pre-compiled binaries#

Nightly builds and stable releases are regularly published to dl.mcaptcha.org for a variety of CPU architectures and operating systems.

1. Download binary, checksum and GPG signature files

    1wget https://dl.mcaptcha.org/mcaptcha/cli/{VERSION}/{FILENAME}.tar.gz
    2wget https://dl.mcaptcha.org/mcaptcha/cli/{VERSION}/{FILENAME}.tar.gz.asc
    3wget https://dl.mcaptcha.org/mcaptcha/cli/{VERSION}/{FILENAME}.tar.gz.sha256

2. Verify checksum

    1sha256sum -c {FILENAME}.tar.gz.sha256

3. Download mCaptcha’s GPG release keys and verify GPG signature

    1gpg --keyserver keyserver.ubuntu.com --recv 73DAC973A9ADBB9ADCB5CDC4595A08135BA9FF73
    2gpg --verify {FILENAME}.tar.gz.asc

4. Install Binary

    1tar -xvzf {FILENAME}.tar.gz && sudo cp {FILENAME}/mcaptcha-cli /usr/local/bin

### Build from source#

1. Install Rust tool chain Please see here for instructions.
2. Download source code

    1git clone https://git.batsense.net/mCaptcha/cli

3. Compile and install

    1cargo build --release && sudp cp ./target/release/mcaptcha-cli
    2/usr/local/bin

## Pass mCaptcha challenge#

The CLI tool requires details about the challenge to work on it. The tool can be used in three different modes compute challenge:

1. Protected Page: Compute mCaptcha challenge for the CAPTCHA at a protected page
2. Widget URL: Compute PoW for captcha at widget URL
3. (Developer mode) Offline: Computes PoW over given CAPTCHA parameters

### From protected page URL#

The most convenient mode: copy the URL of the webpage which has the mCaptcha widget (example: showcase.mcaptcha.org) and run the CLI tool with it to get an authorization code: Compute challenge using the URL

    103:39 atm@lab cli ±|feat-parse-webpage ✗|→ mcaptcha-cli protected-page https://showcase.mcaptcha.org/
    2Authorization token: eRAZJiMrW58uDYA1s64Tmwq1u30HutuF

### Widget URL#

If you have the widget URL (will be in format https://mcaptcha.example.org/widget?sitekey=randomstring), it can be used to solve challenge as well:

    1Compute PoW by fetching parameters from  CAPTCHA URL
    2
    3Usage: mcaptcha-cli online --url <URL>
    4
    5Options:
    6  -u, --url <URL>  URL of the CAPTCHA. Example:  https://example.org/widget?sitekey=foo
    7  -h, --help       Print help

Example usage:

    113:32 atm@lab cli ±|online ✗|→ mcaptcha-cli online -u https://demo.mcaptcha.org/widget?sitekey=pHy0AktWyOKuxZDzFfoaewncWecCHo23
    2Authorization token: 3xleN26OctBuVu3X4t6CYyUjErhaxQvz

### [Developer mode] Offline#

Useful while debugging mCaptcha configurations, works on raw challenge parameters.

Help menu:

    1Compute PoW with offline parameters
    2
    3Usage: mcaptcha-cli offline --salt <SALT> --phrase <PHRASE> --difficulty-factor <DIFFICULTY_FACTOR>
    4
    5Options:
    6  -s, --salt <SALT>                            Salt with which PoW should be computed
    7  -p, --phrase <PHRASE>                        Phrase over which PoW should be computed
    8  -d, --difficulty-factor <DIFFICULTY_FACTOR>  Difficulty Factor
    9  -h, --help                                   Print help

Example usage:

    113:28 atm@lab cli ±|online|→ mcaptcha-cli offline -s $(rand 32) -p $(rand 32) -d 50000
    2difficulty: 50000
    3nonce: 90507
    4original phrase: f351f333d44b2c6b5bf7f033b065bbb8fb5e9dd153bd402e43ed04425f5a3859
    5result: 340276562956196291522979356090220150471

Where rand is this script.

Edit this page on git.batsense.net