Skip to content

Commit

Permalink
Update hash sections (#411)
Browse files Browse the repository at this point in the history
  • Loading branch information
sylvainpelissier authored Dec 5, 2024
1 parent e93927b commit 067b66e
Show file tree
Hide file tree
Showing 5 changed files with 84 additions and 80 deletions.
6 changes: 3 additions & 3 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Contributing to the radare2 book

The easiest way to contribute to the book is by submiting pullrequests on the project repository, this can be done directly from the github webpage by pressing the pencil button on any .md file or forking and cloning the repository like you would do with any other git project.
The easiest way to contribute to the book is by submitting pull requests on the project repository, this can be done directly from the github webpage by pressing the pencil button on any .md file or forking and cloning the repository like you would do with any other git project.

* [radare2-book repository](https://github.com/radareorg/radare2-book)

Expand All @@ -10,7 +10,7 @@ There are some basic rules (with its reasoning) to follow in order to contribute

### Official documentation must be written in English

Despite we value the importance of human languages, even the minoritary ones we must value the fact that the contributions are rare and having multiple translations of the book won't help on having it's contents upto date.
Despite we value the importance of human languages, even the minoritary ones we must value the fact that the contributions are rare and having multiple translations of the book won't help on having it's contents up to date.

Unofficial translations or third party books are more than welcome, but in this repository we focus on having a clear and unified guide to be used for everyone, and nowadays, English is the most accessible human language towards this.

Expand All @@ -35,7 +35,7 @@ In other words use language models wisely. As a helper tool to better describe a
There are few linting rules and CI checks, but the situation will be improved over time, patches that break the CI won't be accepted.

* Check your vocabulary for typos, proper wording, etc.
* Avoid the use of images (plain text is prefered)
* Avoid the use of images (plain text is preferred)
* Do not embed binary data in markdown files
* Contents must be Latex, Gemini and Markdown friendly

Expand Down
1 change: 1 addition & 0 deletions src/SUMMARY.md
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@
* [Padding](tools/ragg2/padding.md)
* [Rahash2](tools/rahash2/intro.md)
* [Rahash Tool](tools/rahash2/rahash_tool.md)
* [Encoding and Encryption](tools/rahash2/encode.md)
* [Configuration](config/intro.md)
* [Files](config/files.md)
* [Colors](config/colors.md)
Expand Down
66 changes: 66 additions & 0 deletions src/commandline/print_modes.md
Original file line number Diff line number Diff line change
Expand Up @@ -439,3 +439,69 @@ e asm.syntax = att

You can also check `asm.pseudo`, which is an experimental pseudocode view,
and `asm.esil` which outputs [ESIL](../emulation/esil.md) ('Evaluable Strings Intermediate Language'). ESIL's goal is to have a human-readable representation of every opcode semantics. Such representations can be evaluated (interpreted) to emulate effects of individual instructions.

### Print hashes

To calculate a checksum of current block when running radare2, use the `ph` command. Pass an algorithm name to it as a parameter. An example session:

```console
$ radare2 /bin/ls
[0x08049790]> bf entry0
[0x08049790]> ph md5
d2994c75adaa58392f953a448de5fba7
```

You can use all hashing algorithms supported by [rahash2](../tools/rahash2/intro.md):

```console
[0x00000000]> ph?
md5
sha1
sha256
sha384
sha512
md4
xor
xorpair
parity
entropy
hamdist
pcprint
mod255
xxhash
adler32
luhn
crc8smbus
crc15can
crc16
crc16hdlc
crc16usb
crc16citt
crc24
crc32
crc32c
crc32ecma267
crc32bzip2
crc32d
crc32mpeg2
crc32posix
crc32q
crc32jamcrc
crc32xfer
crc64
crc64ecma
crc64we
crc64xz
crc64iso
```

The `ph` command accepts an optional numeric argument to specify length of byte range to be hashed, instead of default block size. For example:

```console
[0x08049A80]> ph md5 32
9b9012b00ef7a94b5824105b7aaad83b
[0x08049A80]> ph md5 64
a71b087d8166c99869c9781e2edcf183
[0x08049A80]> ph md5 1024
a933cc94cd705f09a41ecc80c0041def
```
27 changes: 13 additions & 14 deletions src/tools/rahash2/encode.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,20 +22,19 @@ You can decode it by using the -D flag instead of -E.
For encrypting data check the crypto hash plugins:

```console
$ rahash2 -L | grep ^c
c rc2
c rc4
c rc6
c aes-ecb
c aes-cbc
c ror
c rol
c rot
c blowfish
c cps2
c des-ecb
c xor
c serpent-ecb
$ rahash2 -L | grep "^c"  ✔
c aes-ecb Rijndael block cipher with Electronic Code Book mode
c aes-cbc Rijndael block cipher with Cipher Block Chaining mode
c aes-wrap Rijndael block cipher with Key Wrap Algorithm (RFC 3394)
c blowfish Bruce Schneier's symetric-key block cipher
c cps2 Capcom Play System 2
c des-ecb DES with with Electronic Code Book mode
c rc2 Ron Rivest's Code symmetric key encryption also known as ARC2
c rc4 Rivest Cipher 4
c rc6 Rivest's Cipher 6
c serpent-ecb Serpent block cipher with Electronic Code Book mode
c sm4-ecb ShāngMì4 block cipher with Electronic Code Book mode
c xor Byte level Exclusive Or
```

Here's an example usage to encrypt a string using rahash2:
Expand Down
64 changes: 1 addition & 63 deletions src/tools/rahash2/intro.md
Original file line number Diff line number Diff line change
Expand Up @@ -54,66 +54,4 @@ $ rabin2 -K md5 -S /bin/ls

### Obtaining hashes within radare2 session

To calculate a checksum of current block when running radare2, use the `ph` command. Pass an algorithm name to it as a parameter. An example session:

```console
$ radare2 /bin/ls
[0x08049790]> bf entry0
[0x08049790]> ph md5
d2994c75adaa58392f953a448de5fba7
```

You can use all hashing algorithms supported by `rahash2`:

```console
[0x00000000]> ph?
md5
sha1
sha256
sha384
sha512
md4
xor
xorpair
parity
entropy
hamdist
pcprint
mod255
xxhash
adler32
luhn
crc8smbus
crc15can
crc16
crc16hdlc
crc16usb
crc16citt
crc24
crc32
crc32c
crc32ecma267
crc32bzip2
crc32d
crc32mpeg2
crc32posix
crc32q
crc32jamcrc
crc32xfer
crc64
crc64ecma
crc64we
crc64xz
crc64iso
```

The `ph` command accepts an optional numeric argument to specify length of byte range to be hashed, instead of default block size. For example:

```console
[0x08049A80]> ph md5 32
9b9012b00ef7a94b5824105b7aaad83b
[0x08049A80]> ph md5 64
a71b087d8166c99869c9781e2edcf183
[0x08049A80]> ph md5 1024
a933cc94cd705f09a41ecc80c0041def
```
Hashes can also be printed within a radare2 session as explained in the [Print Section](../../commandline/print_modes.md).

0 comments on commit 067b66e

Please sign in to comment.