> For the complete documentation index, see [llms.txt](https://cajac.gitbook.io/ctf-notes/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://cajac.gitbook.io/ctf-notes/encoding-and-decoding/qr-codes.md).

# QR-codes

A QR code (quick-response code) is a type of [two-dimensional](https://en.wikipedia.org/wiki/Plane_\(mathematics\)) [matrix barcode](https://en.wikipedia.org/wiki/Barcode#Matrix_\(2D\)_codes), invented in 1994, by [Japanese](https://en.wikipedia.org/wiki/Japan) company [Denso Wave](https://en.wikipedia.org/wiki/Denso#Denso_Wave) for labelling automobile parts. It features black squares on a white background with [fiducial markers](https://en.wikipedia.org/wiki/Fiducial_markers), readable by imaging devices like cameras, and processed using [Reed–Solomon error correction](https://en.wikipedia.org/wiki/Reed%E2%80%93Solomon_error_correction) until the image can be appropriately interpreted. The required data is then extracted from patterns that are present in both the horizontal and the vertical components of the QR image.

<figure><img src="https://2500502929-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FEwPnwcu7pnz3MWV4siTi%2Fuploads%2Fdhpt4hhMdB3jspkB0DHQ%2FQR_code_for_mobile_English_Wikipedia.svg.png?alt=media&amp;token=e676632e-28f8-4ff6-b417-41a0259896bc" alt=""><figcaption><p>A QR code for the <a href="https://en.wikipedia.org/wiki/URL">URL</a> of the <a href="https://en.wikipedia.org/wiki/English_Wikipedia">English Wikipedia</a> Mobile main page</p></figcaption></figure>

## Online services

You can use these online services to decode QR-codes:

CyberChef - Parse QR Code: <https://gchq.github.io/CyberChef/#recipe=Parse_QR_Code(false)>

Inlite Online Barcode Reader: <https://online-barcode-reader.inliteresearch.com/>

ZXing Decoder Online: <https://zxing.org/w/decode.jspx>

## Zbar-tools

You can decode QR-codes with the `zbarimg` tool from the `zbar-tools` package. \
Use `sudo apt install zbar-tools` if needed.

```bash
┌──(kali㉿kali)-[/mnt/…/TryHackMe/CTFs/Easy/CTF_Collection_Vol.1]
└─$ zbarimg QR.png 
QR-Code:THM{qr_m4k3_l1f3_345y}
scanned 1 barcode symbols from 1 images in 0.01 seconds
```

## Usage information

<details>

<summary>zbarimg -h</summary>

```bash
┌──(kali㉿kali)-[~]
└─$ zbarimg -h
usage: zbarimg [options] <image>...

scan and decode bar codes from one or more image files

options:
    -h, --help      display this help text
    --version       display version information and exit
    --polygon       output points delimiting code zone with decoded symbol data
    -q, --quiet     minimal output, only print decoded symbol data
    -v, --verbose   increase debug output level
    --verbose=N     set specific debug output level
    -d, --display   enable display of following images to the screen
    -D, --nodisplay disable display of following images (default)
    --xml, --noxml  enable/disable XML output format
    --raw           output decoded symbol data without converting charsets
    -1, --oneshot   exit after scanning one bar code
    -S<CONFIG>[=<VALUE>], --set <CONFIG>[=<VALUE>]
                    set decoder/scanner <CONFIG> to <VALUE> (or 1)

    --nodbus        disable dbus message

```

</details>

## Resources

QR code - Wikipedia: <https://en.wikipedia.org/wiki/QR_code>
