8 #define RZ_AX_FLAG_HEX_TO_RAW (1ull << 0)
9 #define RZ_AX_FLAG_SWAP_ENDIANNESS (1ull << 1)
10 #define RZ_AX_FLAG_RAW_TO_HEX (1ull << 2)
11 #define RZ_AX_FLAG_BIN_TO_STR (1ull << 3)
12 #define RZ_AX_FLAG_STR_TO_DJB2 (1ull << 4)
13 #define RZ_AX_FLAG_KEEP_BASE (1ull << 5)
14 #define RZ_AX_FLAG_FLOATING_POINT (1ull << 6)
15 #define RZ_AX_FLAG_FORCE_INTEGER (1ull << 7)
16 #define RZ_AX_FLAG_NUMBER_TO_HEX (1ull << 9)
17 #define RZ_AX_FLAG_UNITS (1ull << 10)
18 #define RZ_AX_FLAG_TIMESTAMP_TO_STR (1ull << 11)
19 #define RZ_AX_FLAG_BASE64_ENCODE (1ull << 12)
20 #define RZ_AX_FLAG_BASE64_DECODE (1ull << 13)
21 #define RZ_AX_FLAG_RAW_TO_LANGBYTES (1ull << 14)
22 #define RZ_AX_FLAG_NUMBER_TO_HEXSTR (1ull << 15)
23 #define RZ_AX_FLAG_SIGNED_WORD (1ull << 16)
24 #define RZ_AX_FLAG_STR_TO_BIN (1ull << 17)
25 #define RZ_AX_FLAG_RIZIN_CMD (1ull << 18)
26 #define RZ_AX_FLAG_BIN_TO_BIGNUM (1ull << 19)
27 #define RZ_AX_FLAG_DUMP_C_BYTES (1ull << 21)
28 #define RZ_AX_FLAG_OCTAL_TO_RAW (1ull << 22)
29 #define RZ_AX_FLAG_IPADDR_TO_LONG (1ull << 23)
30 #define RZ_AX_FLAG_SET_BITS (1ull << 24)
32 #define has_flag(f, x) (f & x)
35 #define STDIN_BUFFER_SIZE 354096
55 if (
buf[l - 1] == 0) {
99 float *
f = (
float *)&n2;
102 case 'f':
printf(
"%.01lf\n",
num->fvalue);
break;
135 const int len = strlen(base2);
154 if (base2[
i] !=
'1' && base2[
i] !=
'0') {
155 eprintf(
"invalid base2 number %c at char %d\n", base2[
i],
i);
160 if (
c > 0 && !(
c & 7)) {
164 bytes[j] |= base2[
i] -
'0';
189 " =[base] ; rz-ax =10 0x46 -> output in base 10\n"
190 " int -> hex ; rz-ax 10\n"
191 " hex -> int ; rz-ax 0xa\n"
192 " -int -> hex ; rz-ax -77\n"
193 " -hex -> int ; rz-ax 0xffffffb3\n"
194 " int -> bin ; rz-ax b30\n"
195 " int -> ternary ; rz-ax t42\n"
196 " bin -> int ; rz-ax 1010d\n"
197 " ternary -> int ; rz-ax 1010dt\n"
198 " float -> hex ; rz-ax 3.33f\n"
199 " hex -> float ; rz-ax Fx40551ed8\n"
200 " oct -> hex ; rz-ax 35o\n"
201 " hex -> oct ; rz-ax Ox12 (O is a letter)\n"
202 " bin -> hex ; rz-ax 1100011b\n"
203 " hex -> bin ; rz-ax Bx63\n"
204 " ternary -> hex ; rz-ax 212t\n"
205 " hex -> ternary ; rz-ax Tx23\n"
206 " raw -> hex ; rz-ax -S < /binfile\n"
207 " hex -> raw ; rz-ax -s 414141\n"
208 " -l ; append newline to output (for -E/-D/-r/..\n"
209 " -a show ascii table ; rz-ax -a\n"
210 " -b bin -> str ; rz-ax -b 01000101 01110110\n"
211 " -B str -> bin ; rz-ax -B hello\n"
212 " -d force integer ; rz-ax -d 3 -> 3 instead of 0x3\n"
213 " -e swap endianness ; rz-ax -e 0x33\n"
214 " -D base64 decode ;\n"
215 " -E base64 encode ;\n"
216 " -f floating point ; rz-ax -f 6.3+2.1\n"
217 " -F stdin slurp code hex ; rz-ax -F < shellcode.[c/py/js]\n"
218 " -h help ; rz-ax -h\n"
219 " -i dump as C byte array ; rz-ax -i < bytes\n"
220 " -I IP address <-> LONG ; rz-ax -I 3530468537\n"
221 " -k keep base ; rz-ax -k 33+3 -> 36\n"
222 " -L bin -> hex(bignum) ; rz-ax -L 111111111 # 0x1ff\n"
223 " -n binary number ; rz-ax -n 0x1234 # 34120000\n"
224 " -o octalstr -> raw ; rz-ax -o \\162 \\172 # rz\n"
225 " -N binary number ; rz-ax -N 0x1234 # \\x34\\x12\\x00\\x00\n"
226 " -r rz style output ; rz-ax -r 0x1234\n"
227 " -s hexstr -> raw ; rz-ax -s 43 4a 50\n"
228 " -S raw -> hexstr ; rz-ax -S < /bin/ls > ls.hex\n"
229 " -t tstamp -> str ; rz-ax -t 1234567890\n"
230 " -x hash string ; rz-ax -x linux osx\n"
231 " -u units ; rz-ax -u 389289238 # 317.0M\n"
232 " -w signed word ; rz-ax -w 16 0xffff\n"
233 " -v version ; rz-ax -v\n"
234 " -p position of set bits ; rz-ax -p 0xb3\n");
252 switch (atoi(
str + 1)) {
253 case 2: force_mode =
'B';
break;
254 case 3: force_mode =
'T';
break;
255 case 8: force_mode =
'O';
break;
256 case 10: force_mode =
'I';
break;
257 case 16: force_mode =
'0';
break;
258 case 0: force_mode =
str[1];
break;
265 while (
str[1] &&
str[1] !=
' ') {
299 if (
str[1] >=
'0' &&
str[1] <=
'9') {
307 printf(
"Usage: rz-ax [options] [expr ...]\n");
323 if (*
str ==
'h' || *
str ==
'?') {
330 int n = ((strlen(
str)) >> 1) + 1;
336 fwrite(
buf,
n, 1, stdout);
351 for (
i = 0;
i <
len;
i++) {
360 for (
i = 0;
i <
n;
i++) {
377 fwrite(&
n,
sizeof(
n), 1, stdout);
380 for (
i = 0;
i < 8;
i++) {
381 printf(
"%02x", (
int)(
n & 0xff));
390 fwrite(&n32,
sizeof(n32), 1, stdout);
393 for (
i = 0;
i < 4;
i++) {
394 printf(
"%02x", n32 & 0xff);
403 for (
i = 0;
i < strlen(
str);
i++) {
419 char strbits[65] = { 0 };
420 int i = 0, set_bits_ctr = 0;
424 while (strbits[
i] !=
'\0') {
425 if (strbits[
i] ==
'1') {
429 }
else if (strbits[
i] ==
'1' && last_char ==
'0') {
433 if (strbits[
i] ==
'0' && last_char ==
'1') {
434 if (set_bits_ctr == 1) {
436 }
else if (strbits[
i + 1] ==
'\0') {
441 }
else if (strbits[
i] ==
'1' && strbits[
i + 1] ==
'\0') {
442 if (set_bits_ctr == 1) {
448 last_char = strbits[
i];
457 }
else if (
n >> 14) {
469 fwrite(&
n,
sizeof(
n), 1, stdout);
472 for (
i = 0;
i < 8;
i++) {
473 printf(
"\\x%02x", (
int)(
n & 0xff));
482 fwrite(&n32,
sizeof(n32), 1, stdout);
485 for (
i = 0;
i < 4;
i++) {
486 printf(
"\\x%02x", n32 & 0xff);
500 char *ts = rz_list_head(split)->data;
501 const char *gmt =
NULL;
502 if (
rz_list_length(split) >= 2 && strlen(rz_list_head(split)->
n->data) >= 2) {
503 gmt = (
const char *)rz_list_head(split)->n->data;
515 const int n = strlen(
str);
526 const int n = strlen(
str);
550 char *asnum, unit[8];
558 eprintf(
"RzNum ERROR: Division by Zero\n");
573 n,
n,
n, unit,
s,
a);
586 eprintf (
"%s %.01lf %ff %lf\n",
591 printf(
"unit %s\n", unit);
592 printf(
"segment %04x:%04x\n",
s,
a);
599 printf(
"string \"%s\"\n", asnum);
619 static const char start[] =
"unsigned char buf[] = {";
622 const int byte_per_col = 12;
623 for (
i = 0;
i <
len - 1;
i++) {
625 if (
i % byte_per_col == 0) {
631 if (
i % byte_per_col == 0) {
636 printf(
"unsigned int buf_len = %d;\n",
len);
652 eprintf(
"RzNum ERROR: Division by Zero\n");
661 eprintf(
"No String Possible\n");
666 if (strchr(
str,
'.')) {
668 sscanf(
str,
"%hhd.%hhd.%hhd.%hhd",
ip,
ip + 1,
ip + 2,
ip + 3);
669 ut32 ip32 =
ip[0] | (
ip[1] << 8) | (
ip[2] << 16) | (
ip[3] << 24);
673 ut8 ip[4] = { ip32 & 0xff, (ip32 >> 8) & 0xff, (ip32 >> 16) & 0xff, ip32 >> 24 };
701 str[strlen(
str) - 1] =
'b';
707 str[strlen(
str) - 2] =
't';
708 str[strlen(
str) - 1] =
'\0';
710 while ((
p = strchr(
str,
' '))) {
728 for (
i = 1;
i < argc;
i++) {
const lzma_allocator const uint8_t size_t uint8_t * out
_Use_decl_annotations_ int __cdecl printf(const char *const _Format,...)
static static sync static getppid static getegid const char static filename char static len const char char static bufsiz static mask static vfork const void static prot static getpgrp const char static swapflags static arg static fd static protocol static who struct sockaddr static addrlen static backlog struct timeval struct timezone static tz const struct iovec static count static mode const void const struct sockaddr static tolen const char static pathname void static offset struct stat static buf void long static basep static whence static length const void static len static semflg const void static shmflg const struct timespec struct timespec static rem const char static group const void start
RZ_API void Ht_() free(HtName_(Ht) *ht)
return memset(p, 0, total)
memcpy(mem, inblock.get(), min(CONTAINING_RECORD(inblock.get(), MEMBLOCK, data) ->size, size))
static void print_ascii_table(void)
#define RZ_AX_FLAG_BASE64_ENCODE
static int rax(RzNum *num, char *str, int len, int last, ut64 *flags, int *fm)
#define RZ_AX_FLAG_TIMESTAMP_TO_STR
#define RZ_AX_FLAG_FORCE_INTEGER
static void print_hex_from_base2(char *base2)
#define RZ_AX_FLAG_STR_TO_DJB2
#define RZ_AX_FLAG_BIN_TO_BIGNUM
#define RZ_AX_FLAG_IPADDR_TO_LONG
RZ_API int rz_main_rz_ax(int argc, const char **argv)
#define RZ_AX_FLAG_HEX_TO_RAW
static int use_stdin(RzNum *num, ut64 *flags, int *fm)
#define RZ_AX_FLAG_STR_TO_BIN
#define RZ_AX_FLAG_RIZIN_CMD
#define RZ_AX_FLAG_OCTAL_TO_RAW
#define RZ_AX_FLAG_DUMP_C_BYTES
#define RZ_AX_FLAG_NUMBER_TO_HEX
#define RZ_AX_FLAG_NUMBER_TO_HEXSTR
#define RZ_AX_FLAG_SET_BITS
#define RZ_AX_FLAG_SIGNED_WORD
#define RZ_AX_FLAG_RAW_TO_HEX
#define RZ_AX_FLAG_BIN_TO_STR
#define RZ_AX_FLAG_RAW_TO_LANGBYTES
#define RZ_AX_FLAG_SWAP_ENDIANNESS
#define RZ_AX_FLAG_FLOATING_POINT
static int format_output(RzNum *num, char mode, const char *s, int force_mode, ut64 flags)
#define RZ_AX_FLAG_BASE64_DECODE
#define RZ_AX_FLAG_KEEP_BASE
#define STDIN_BUFFER_SIZE
RZ_API ut32 rz_list_length(RZ_NONNULL const RzList *list)
Returns the length of the list.
RZ_API void rz_list_free(RZ_NONNULL RzList *list)
Empties the list and frees the list pointer.
void * malloc(size_t size)
void * calloc(size_t number, size_t size)
static static fork const void static count static fd const char const char static newpath char char char static envp time_t static t const char static mode static whence const char static dir time_t static t unsigned static seconds const char struct utimbuf static buf static inc static sig const char static mode static oldfd struct tms static buf static getgid static geteuid const char static filename static arg static mask struct ustat static ubuf static getppid static setsid static egid sigset_t static set struct timeval struct timezone static tz fd_set fd_set fd_set struct timeval static timeout const char char static bufsiz const char static swapflags void static offset const char static length static mode static who const char struct statfs static buf unsigned unsigned num
static static fork const void static count static fd const char const char static newpath char char argv
return strdup("=SP r13\n" "=LR r14\n" "=PC r15\n" "=A0 r0\n" "=A1 r1\n" "=A2 r2\n" "=A3 r3\n" "=ZF zf\n" "=SF nf\n" "=OF vf\n" "=CF cf\n" "=SN or0\n" "gpr lr .32 56 0\n" "gpr pc .32 60 0\n" "gpr cpsr .32 64 0 ____tfiae_________________qvczn\n" "gpr or0 .32 68 0\n" "gpr tf .1 64.5 0 thumb\n" "gpr ef .1 64.9 0 endian\n" "gpr jf .1 64.24 0 java\n" "gpr qf .1 64.27 0 sticky_overflow\n" "gpr vf .1 64.28 0 overflow\n" "gpr cf .1 64.29 0 carry\n" "gpr zf .1 64.30 0 zero\n" "gpr nf .1 64.31 0 negative\n" "gpr itc .4 64.10 0 if_then_count\n" "gpr gef .4 64.16 0 great_or_equal\n" "gpr r0 .32 0 0\n" "gpr r1 .32 4 0\n" "gpr r2 .32 8 0\n" "gpr r3 .32 12 0\n" "gpr r4 .32 16 0\n" "gpr r5 .32 20 0\n" "gpr r6 .32 24 0\n" "gpr r7 .32 28 0\n" "gpr r8 .32 32 0\n" "gpr r9 .32 36 0\n" "gpr r10 .32 40 0\n" "gpr r11 .32 44 0\n" "gpr r12 .32 48 0\n" "gpr r13 .32 52 0\n" "gpr r14 .32 56 0\n" "gpr r15 .32 60 0\n" "gpr r16 .32 64 0\n" "gpr r17 .32 68 0\n")
RZ_API const char * ret_ascii_table(void)
#define RZ_STATIC_ASSERT(x)
RZ_API size_t rz_base64_encode(char *bout, const ut8 *bin, size_t sz)
RZ_API int rz_base64_decode(ut8 *bout, const char *bin, int len)
RZ_API char * rz_stdin_slurp(int *sz)
RZ_API int rz_hex_str2bin(const char *in, ut8 *out)
Convert an input string in into the binary form in out.
RZ_API char * rz_hex_from_code(const char *code)
RZ_API int rz_main_version_print(const char *program)
RZ_API void rz_mem_swapendian(ut8 *dest, const ut8 *orig, int size)
RZ_API RzNum * rz_num_new(RzNumCallback cb, RzNumCallback2 cb2, void *ptr)
RZ_API int rz_num_to_bits(char *out, ut64 num)
RZ_API ut64 rz_num_math(RzNum *num, const char *str)
RZ_API int rz_num_to_trits(char *out, ut64 num)
RZ_API char * rz_num_units(char *buf, size_t len, ut64 number)
RZ_API char * rz_num_as_string(RzNum *___, ut64 n, bool printable_only)
RZ_API void rz_num_free(RzNum *num)
RZ_API char * rz_str_newf(const char *fmt,...) RZ_PRINTF_CHECK(1
RZ_API ut64 rz_str_djb2_hash(const char *str)
RZ_API char * rz_str_new(const char *str)
RZ_API int rz_str_binstr2bin(const char *str, ut8 *out, int outlen)
RZ_API int rz_str_bits64(char *strout, ut64 in)
RZ_API int rz_str_bits(char *strout, const ut8 *buf, int len, const char *bitz)
RZ_API size_t rz_str_nlen(const char *s, size_t n)
RZ_API bool rz_str_startswith(RZ_NONNULL const char *str, RZ_NONNULL const char *needle)
Checks if a string starts with a specifc sequence of characters (case sensitive)
RZ_API RzList * rz_str_split_list(char *str, const char *c, int n)
Split the string str according to the substring c and returns a RzList with the result.
RZ_API int rz_str_unescape(char *buf)
RZ_API bool rz_str_endswith(RZ_NONNULL const char *str, RZ_NONNULL const char *needle)
Checks if a string ends with a specifc sequence of characters (case sensitive)
RZ_API void rz_str_reverse(char *str)
#define rz_time_date_unix_to_string
static struct sockaddr static addrlen static backlog const void static flags void flags
ut64(WINAPI *w32_GetEnabledXStateFeatures)()
int read(izstream &zs, T *x, Items items)