10 #include "../core_private.h"
20 bool no_key_mode = !strcmp(
"base64", algo) || !strcmp(
"base91", algo) || !strcmp(
"punycode", algo);
22 if (!strncmp(
key,
"s:", 2)) {
24 keylen = strlen(
key + 2);
29 if (!no_key_mode && keylen < 1) {
30 eprintf(
"%s key not defined. Use -S [key]\n", ((!direction) ?
"Encryption" :
"Decryption"));
37 eprintf(
"Cannot allocate %d byte(s)\n", keylen);
47 strcpy((
char *)biniv, iv);
63 eprintf(
"Written %d byte(s)\n", result_size);
72 eprintf(
"Unknown %s algorithm '%s'\n", ((!direction) ?
"encryption" :
"decryption"), algo);
85 ret = orig & (~(
val));
94 rz_core_seek_delta(x, y, true)
206 eprintf(
"No data from editor\n");
220 eprintf(
"Invalid offset provided\n");
224 eprintf(
"Invalid offset/size provided\n");
249 eprintf(
"Wrong format for <host:port>\n");
252 char *host = address;
253 char *port = host + strlen(host) + 1;
262 eprintf(
"Cannot listen on port %s\n", port);
268 eprintf(
"Failing to accept socket\n");
272 eprintf(
"Receiving data from client...\n");
276 eprintf(
"Failing to read data from socket: %d\n", rc);
278 }
else if (rc == 0) {
367 int line = 0, offs = 0, hexa = 0;
369 for (
i = 0; data[
i];
i++) {
378 offs =
i + ((data[
i + 1] ==
' ') ? 2 : 1);
449 if (!strcmp(
argv[1],
"-")) {
565 RZ_LOG_INFO(
"Invalidated %d cache(s)\n", ninvalid);
730 const char *algo =
argv[1];
732 const char *iv =
argv[3];
737 const char *algo =
argv[1];
739 const char *iv =
argv[3];
752 if (value_size != 1 && value_size != 2 && value_size != 4 && value_size != 8) {
753 RZ_LOG_ERROR(
"Invalid <value_size> value: %d\n", value_size);
756 ut64 max_val = (1ULL << (8 * value_size));
757 if (
from >= max_val) {
static const AvrInstruction instructions[]
RZ_API bool rz_core_write_block_op_at(RzCore *core, ut64 addr, RzCoreWriteOp op, ut8 *hex, int hexlen)
Write a full block of data according to the operation op and the hexvalue hex.
RZ_API bool rz_core_write_string_at(RzCore *core, ut64 addr, RZ_NONNULL const char *s)
Write a given string s at the specified addr.
RZ_API bool rz_core_extend_at(RzCore *core, ut64 addr, ut64 size)
Extend the file at current offset by inserting size 0 bytes at addr.
RZ_API bool rz_core_write_string_wide_at(RzCore *core, ut64 addr, const char *s)
Write a given string s as a wide string at the specified addr.
RZ_API int rz_core_write_hexpair(RzCore *core, ut64 addr, const char *pairs)
RZ_API bool rz_core_write_at(RzCore *core, ut64 addr, const ut8 *buf, int size)
RZ_API bool rz_core_shift_block(RzCore *core, ut64 addr, ut64 b_size, st64 dist)
Shift a block of data from addr of size b_size left or right based on dist.
RZ_API RzCmdStatus rz_core_io_pcache_print(RzCore *core, RzIODesc *desc, RzCmdStateOutput *state)
RZ_API RzCmdStatus rz_core_io_cache_print(RzCore *core, RzCmdStateOutput *state)
RZ_API bool rz_core_write_block(RzCore *core, ut64 addr, ut8 *data, size_t len)
RZ_API bool rz_core_write_string_zero_at(RzCore *core, ut64 addr, const char *s)
Write a given string s, followed by the zero terminator, at the specified addr.
RZ_API int rz_core_write_assembly(RzCore *core, ut64 addr, RZ_NONNULL const char *instructions)
Assembles instructions and writes the resulting data at the given offset.
RZ_API int rz_core_block_read(RzCore *core)
RZ_API bool rz_core_write_base64d_at(RzCore *core, ut64 addr, RZ_NONNULL const char *s)
Write a given base64 string s at the specified addr, decoded.
RZ_API bool rz_core_write_value_inc_at(RzCore *core, ut64 addr, st64 value, int sz)
Write at addr the current value + value passed as argument.
RZ_API bool rz_core_write_length_string_at(RzCore *core, ut64 addr, const char *s)
Write at the specified addr the length of the string in one byte, followed by the given string s.
RZ_API bool rz_core_write_seq_at(RzCore *core, ut64 addr, ut64 from, ut64 to, ut64 step, int value_size)
Write a full block of data with a sequence.
RZ_API bool rz_core_write_base64_at(RzCore *core, ut64 addr, RZ_NONNULL const char *s)
Write a given string s at the specified addr encoded as base64.
RZ_API bool rz_core_write_random_at(RzCore *core, ut64 addr, size_t len)
Write len random bytes at address addr.
RZ_API int rz_core_write_assembly_fill(RzCore *core, ut64 addr, RZ_NONNULL const char *instructions)
Assemble instructions and write the resulting data inside the current instruction.
RZ_API bool rz_core_write_duplicate_at(RzCore *core, ut64 addr, ut64 from, int len)
Copy len bytes from from to addr.
RZ_API bool rz_core_write_value_at(RzCore *core, ut64 addr, ut64 value, int sz)
Write a given value at the specified address, using sz bytes.
RZ_IPI RzCmdStatus rz_write_cache_commit_all_handler(RzCore *core, int argc, const char **argv)
RZ_IPI RzCmdStatus rz_write_assembly_handler(RzCore *core, int argc, const char **argv)
RZ_IPI RzCmdStatus rz_write_assembly_file_handler(RzCore *core, int argc, const char **argv)
RZ_IPI RzCmdStatus rz_write_mask_reset_handler(RzCore *core, int argc, const char **argv)
RZ_IPI RzCmdStatus rz_write_debruijn_find_handler(RzCore *core, int argc, const char **argv)
RZ_IPI RzCmdStatus rz_write_pcache_list_handler(RzCore *core, int argc, const char **argv, RzCmdStateOutput *state)
RZ_IPI RzCmdStatus rz_write_op_shr_handler(RzCore *core, int argc, const char **argv)
RZ_IPI RzCmdStatus rz_write_op_encrypt_handler(RzCore *core, int argc, const char **argv)
static bool encrypt_or_decrypt_block(RzCore *core, const char *algo, const char *key, int direction, const char *iv)
RZ_IPI RzCmdStatus rz_write_handler(RzCore *core, int argc, const char **argv)
RZ_IPI RzCmdStatus rz_write_from_socket_handler(RzCore *core, int argc, const char **argv)
RZ_IPI RzCmdStatus rz_write_op_sub_handler(RzCore *core, int argc, const char **argv)
RZ_IPI RzCmdStatus rz_write_op_xor_handler(RzCore *core, int argc, const char **argv)
RZ_IPI RzCmdStatus rz_write_op_mul_handler(RzCore *core, int argc, const char **argv)
RZ_IPI RzCmdStatus rz_write_unified_patch_handler(RzCore *core, int argc, const char **argv)
RZ_IPI RzCmdStatus rz_write_value_handler(RzCore *core, int argc, const char **argv)
RZ_IPI RzCmdStatus rz_write_zero_handler(RzCore *core, int argc, const char **argv)
RZ_IPI RzCmdStatus rz_write_2_inc_handler(RzCore *core, int argc, const char **argv)
RZ_IPI RzCmdStatus rz_write_length_string_handler(RzCore *core, int argc, const char **argv)
RZ_IPI RzCmdStatus rz_write_op_2byteswap_handler(RzCore *core, int argc, const char **argv)
RZ_IPI RzCmdStatus rz_write_op_sequence_handler(RzCore *core, int argc, const char **argv)
RZ_IPI RzCmdStatus rz_write_from_file_handler(RzCore *core, int argc, const char **argv)
RZ_IPI RzCmdStatus rz_write_hex_handler(RzCore *core, int argc, const char **argv)
RZ_IPI RzCmdStatus rz_write_op_or_handler(RzCore *core, int argc, const char **argv)
RZ_IPI RzCmdStatus rz_write_value2_handler(RzCore *core, int argc, const char **argv)
RZ_IPI RzCmdStatus rz_write_8_dec_handler(RzCore *core, int argc, const char **argv)
static RzCmdStatus common_write_value_handler(RzCore *core, const char *valstr, size_t sz)
RZ_IPI RzCmdStatus rz_write_cache_remove_all_handler(RzCore *core, int argc, const char **argv)
static void cmd_write_fail(RzCore *core)
RZ_IPI RzCmdStatus rz_write_value4_handler(RzCore *core, int argc, const char **argv)
RZ_IPI RzCmdStatus rz_write_cache_remove_handler(RzCore *core, int argc, const char **argv)
static bool ioMemcpy(RzCore *core, ut64 dst, ut64 src, int len)
RZ_IPI RzCmdStatus rz_write_value8_handler(RzCore *core, int argc, const char **argv)
RZ_IPI RzCmdStatus rz_write_hex_from_file_handler(RzCore *core, int argc, const char **argv)
RZ_IPI RzCmdStatus rz_write_cache_list_handler(RzCore *core, int argc, const char **argv, RzCmdStateOutput *state)
RZ_IPI RzCmdStatus rz_write_wide_string_handler(RzCore *core, int argc, const char **argv)
RZ_IPI RzCmdStatus rz_write_extend_shift_handler(RzCore *core, int argc, const char **argv)
RZ_IPI RzCmdStatus rz_write_1_inc_handler(RzCore *core, int argc, const char **argv)
RZ_IPI RzCmdStatus rz_write_assembly_inside_handler(RzCore *core, int argc, const char **argv)
RZ_IPI RzCmdStatus rz_write_extend_hexbytes_handler(RzCore *core, int argc, const char **argv)
RZ_IPI RzCmdStatus rz_write_op_decrypt_handler(RzCore *core, int argc, const char **argv)
RZ_IPI RzCmdStatus rz_write_1_dec_handler(RzCore *core, int argc, const char **argv)
RZ_IPI RzCmdStatus rz_write_op_8byteswap_handler(RzCore *core, int argc, const char **argv)
static void cmd_write_bits(RzCore *core, int set, ut64 val)
RZ_IPI RzCmdStatus rz_write_random_handler(RzCore *core, int argc, const char **argv)
RZ_IPI RzCmdStatus rz_write_2_dec_handler(RzCore *core, int argc, const char **argv)
static RzCmdStatus write_op_val(RzCore *core, int argc, const char **argv, RzCoreWriteOp op)
RZ_IPI RzCmdStatus rz_write_from_io_handler(RzCore *core, int argc, const char **argv)
RZ_IPI RzCmdStatus rz_write_unset_bits_handler(RzCore *core, int argc, const char **argv)
RZ_IPI RzCmdStatus rz_write_cache_commit_handler(RzCore *core, int argc, const char **argv)
RZ_IPI RzCmdStatus rz_write_block_handler(RzCore *core, int argc, const char **argv)
RZ_IPI RzCmdStatus rz_write_duplicate_handler(RzCore *core, int argc, const char **argv)
RZ_IPI RzCmdStatus rz_write_assembly_opcode_handler(RzCore *core, int argc, const char **argv)
RZ_IPI RzCmdStatus rz_write_op_shl_handler(RzCore *core, int argc, const char **argv)
RZ_IPI RzCmdStatus rz_write_op_and_handler(RzCore *core, int argc, const char **argv)
RZ_IPI RzCmdStatus rz_write_op_4byteswap_handler(RzCore *core, int argc, const char **argv)
RZ_IPI RzCmdStatus rz_write_8_inc_handler(RzCore *core, int argc, const char **argv)
RZ_IPI RzCmdStatus rz_write_base64_encode_handler(RzCore *core, int argc, const char **argv)
RZ_IPI RzCmdStatus rz_write_extend_zero_handler(RzCore *core, int argc, const char **argv)
RZ_IPI RzCmdStatus rz_write_zero_string_handler(RzCore *core, int argc, const char **argv)
RZ_IPI RzCmdStatus rz_write_bits_handler(RzCore *core, int argc, const char **argv)
RZ_IPI RzCmdStatus rz_write_op_add_handler(RzCore *core, int argc, const char **argv)
RZ_IPI RzCmdStatus rz_write_value1_handler(RzCore *core, int argc, const char **argv)
RZ_IPI RzCmdStatus rz_write_4_inc_handler(RzCore *core, int argc, const char **argv)
RZ_IPI RzCmdStatus rz_write_4_dec_handler(RzCore *core, int argc, const char **argv)
RZ_IPI RzCmdStatus rz_write_pcache_commit_handler(RzCore *core, int argc, const char **argv)
RZ_IPI RzCmdStatus rz_write_mask_set_handler(RzCore *core, int argc, const char **argv)
static RzCmdStatus w_incdec_handler(RzCore *core, int argc, const char **argv, int inc_size)
RZ_IPI RzCmdStatus rz_write_base64_decode_handler(RzCore *core, int argc, const char **argv)
RZ_IPI RzCmdStatus rz_write_op_div_handler(RzCore *core, int argc, const char **argv)
RZ_IPI RzCmdStatus rz_write_from_io_xchg_handler(RzCore *core, int argc, const char **argv)
RZ_IPI RzCmdStatus rz_write_debruijn_handler(RzCore *core, int argc, const char **argv)
RZ_API ut64 rz_config_get_i(RzConfig *cfg, RZ_NONNULL const char *name)
RZ_API bool rz_config_get_b(RzConfig *cfg, RZ_NONNULL const char *name)
RZ_API int rz_cons_printf(const char *format,...)
static RzCmdStatus bool2status(bool val)
RZ_API int rz_crypto_update(RzCrypto *cry, const ut8 *buf, int len)
RZ_API bool rz_crypto_set_iv(RzCrypto *cry, const ut8 *iv, int ivlen)
RZ_API int rz_crypto_final(RzCrypto *cry, const ut8 *buf, int len)
RZ_API const ut8 * rz_crypto_get_output(RzCrypto *cry, int *size)
RZ_API bool rz_crypto_set_key(RzCrypto *cry, const ut8 *key, int keylen, int mode, int direction)
RZ_API void rz_crypto_free(RzCrypto *cry)
RZ_API RzCrypto * rz_crypto_new(void)
RZ_API bool rz_crypto_use(RzCrypto *cry, const char *algo)
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 key
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 length
static states step(struct re_guts *, sopno, sopno, states, int, states)
RZ_API bool rz_core_hack(RzCore *core, const char *op)
Write/Modify instructions at current offset based on op.
RZ_API void Ht_() free(HtName_(Ht) *ht)
RZ_API RZ_OWN char * rz_core_editor(const RzCore *core, RZ_NULLABLE const char *file, RZ_NULLABLE const char *str)
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")
static const char hex[16]
#define rz_return_val_if_fail(expr, val)
enum rz_cmd_status_t RzCmdStatus
@ RZ_CMD_STATUS_OK
command handler exited in the right way
@ RZ_CMD_STATUS_WRONG_ARGS
command handler could not handle the arguments passed to it
@ RZ_CMD_STATUS_ERROR
command handler had issues while running (e.g. allocation error, etc.)
@ RZ_CORE_WRITE_OP_BYTESWAP8
Swap the endianess of 8-bytes values.
@ RZ_CORE_WRITE_OP_SHIFT_LEFT
Write the shift left of existing byte by argument value.
@ RZ_CORE_WRITE_OP_AND
Write the bitwise-and of existing byte and argument value.
@ RZ_CORE_WRITE_OP_SHIFT_RIGHT
Write the shift right of existing byte and argument value.
@ RZ_CORE_WRITE_OP_BYTESWAP2
Swap the endianess of 2-bytes values.
@ RZ_CORE_WRITE_OP_OR
Write the bitwise-or of existing byte and argument value.
@ RZ_CORE_WRITE_OP_ADD
Write the addition of existing byte and argument value.
@ RZ_CORE_WRITE_OP_MUL
Write the multiplication of existing byte and argument value.
@ RZ_CORE_WRITE_OP_DIV
Write the division of existing byte and argument value.
@ RZ_CORE_WRITE_OP_BYTESWAP4
Swap the endianess of 4-bytes values.
@ RZ_CORE_WRITE_OP_XOR
Write the bitwise-xor of existing byte and argument value.
@ RZ_CORE_WRITE_OP_SUB
Write the subtraction of existing byte and argument value.
RZ_API int rz_debruijn_offset(int start, const char *charset, ut64 value, bool is_big_endian)
Finds the offset of a given value in a debrujn sequence.
RZ_API RZ_OWN char * rz_debruijn_pattern(int size, int start, const char *charset)
Generate a cyclic pattern following the Debruijn pattern.
RZ_API bool rz_file_exists(const char *str)
RZ_API RZ_OWN char * rz_file_slurp(const char *str, RZ_NULLABLE size_t *usz)
RZ_API int rz_hex_str2bin(const char *in, ut8 *out)
Convert an input string in into the binary form in out.
RZ_API int rz_io_cache_invalidate(RzIO *io, ut64 from, ut64 to)
RZ_API bool rz_io_read_at(RzIO *io, ut64 addr, ut8 *buf, int len)
RZ_API void rz_io_cache_reset(RzIO *io, int set)
RZ_API bool rz_io_desc_cache_commit(RzIODesc *desc)
RZ_API bool rz_io_set_write_mask(RzIO *io, const ut8 *mask, int len)
Set a mask that is used on all following write operations.
RZ_API RzIODesc * rz_io_desc_get(RzIO *io, int fd)
RZ_API bool rz_io_write_at(RzIO *io, ut64 addr, const ut8 *buf, int len)
RZ_API void rz_io_cache_commit(RzIO *io, ut64 from, ut64 to)
RZ_API bool rz_io_use_fd(RzIO *io, int fd)
#define RZ_LOG_INFO(fmtstr,...)
#define RZ_LOG_ERROR(fmtstr,...)
RZ_API ut64 rz_num_math(RzNum *num, const char *str)
RZ_API int rz_num_is_valid_input(RzNum *num, const char *input_value)
RZ_API RzSocket * rz_socket_accept(RzSocket *s)
RZ_API bool rz_socket_listen(RzSocket *s, const char *port, const char *certfile)
RZ_API void RZ_API int rz_socket_read(RzSocket *s, ut8 *read, int len)
RZ_API RzSocket * rz_socket_new(bool is_ssl)
RZ_API int rz_socket_free(RzSocket *s)
RZ_API char * rz_str_array_join(const char **a, size_t n, const char *sep)
RZ_API size_t rz_str_split(char *str, char ch)
Split string str in place by using ch as a delimiter.
#define UT64_ADD_OVFCHK(x, y)
static struct sockaddr static addrlen static backlog const void static flags void struct sockaddr from
static struct sockaddr static addrlen static backlog const void static flags void struct sockaddr socklen_t static fromlen const void const struct sockaddr to
Represent the output state of a command handler.
struct rz_io_desc_t * desc
RzNumCalc nc
division by zero happened
ut64(WINAPI *w32_GetEnabledXStateFeatures)()
static const z80_opcode fd[]