/* radare - LGPL - Copyright 2009-2015 - pancake, nibble */ #include #include "r_cons.h" #include "r_core.h" #include "r_hash.h" #include "r_types_base.h" typedef void (*HashHandler)(const ut8 *block, int len); static void handle_md4 (const ut8 *block, int len); static void handle_md5 (const ut8 *block, int len); static void handle_sha1 (const ut8 *block, int len); static void handle_sha256 (const ut8 *block, int len); static void handle_sha512 (const ut8 *block, int len); static void handle_adler32 (const ut8 *block, int len); static void handle_crc32 (const ut8 *block, int len); static void handle_crc16 (const ut8 *block, int len); static void handle_xor (const ut8 *block, int len); static void handle_entropy (const ut8 *block, int len); static void handle_hamdist (const ut8 *block, int len); static void handle_parity (const ut8 *block, int len); static void handle_pcprint (const ut8 *input, int len); static void handle_luhn (const ut8 *input, int len); typedef struct { const char *name; HashHandler handler; } RHashHashHandlers; static RHashHashHandlers hash_handlers[] = { {"md4", handle_md4}, {"md5", handle_md5}, {"sha1", handle_sha1}, {"sha256", handle_sha256}, {"sha512", handle_sha512}, {"adler32", handle_adler32}, {"crc32", handle_crc32}, {"crc16", handle_crc16}, {"xor", handle_xor}, {"entropy", handle_entropy}, {"parity", handle_parity}, {"hamdist", handle_hamdist}, {"pcprint", handle_pcprint}, {"luhn", handle_luhn}, {NULL, NULL}, }; static void handle_md4 (const ut8 *block, int len) { int i = 0; RHash *ctx = r_hash_new (true, R_HASH_MD4); const ut8 *c = r_hash_do_md4 (ctx, block, len); for (i=0; ilang, ptr); if (p && p->name) lang = p->name; } if (*lang==' ') { RLangPlugin *p = r_lang_get_by_extension (core->lang, input+2); if (p && p->name) lang = p->name; } else if (input[1]=='?' || input[1]=='*' || input[1]=='\0') { r_lang_list (core->lang); return true; } p = strchr (input, ' '); if (p) *p=0; // TODO: set argv here if (r_lang_use (core->lang, lang)) { r_lang_setup (core->lang); if (p) { r_lang_run_file (core->lang, p+1); } else { if (r_config_get_i (core->config, "scr.interactive")) { r_lang_prompt (core->lang); } else eprintf ("Error: scr.interactive required to run the rlang prompt\n"); } } else { if (!p || *p==' ') eprintf ("Invalid hashbang. See '#!' for help.\n"); } return true; } static int cmd_hash(void *data, const char *input) { RCore *core = (RCore *)data; if (*input == '!') { return cmd_hash_bang (core, input); } if (*input == '?') { const char *helpmsg3[] = { "Usage #!interpreter [] [