ronin-rb / ronin-support

A support library for Ronin. Like activesupport, but for hacking!
https://ronin-rb.dev
GNU Lesser General Public License v3.0
25 stars 9 forks source link

Add `String#unpack_uint*`, `String#unpack_int*`, `String#unpack_float*` methods #427

Open postmodern opened 1 year ago

postmodern commented 1 year ago

String should have core-exts that can unpack the String as a single uint*,int*, or float* type. These methods should call unpack1 with a single C type argument (ex: :uint32) and **kwargs.

The following methods should not accept **kwargs as they use little-endian or big-endian types:

Alias *_be methods as *_ne or *_net?

The documentation and specs can be copy/pasted from String#unpack1.

This will give ronin-support parity with pwnlib.util.packing.

postmodern commented 1 year ago

An idea, String#unpack_uint8 could be optimized to just return getbyte(0).

postmodern commented 1 year ago

Did a Mastodon poll about _ne vs. _net suffix, and appears most people say to just use _be when referring to network-byte-order types. So maybe hold off on the _ne/_net aliases until someone eventually requests them? https://infosec.exchange/@postmodern/110459088606261323