From 13f17b9270ef1de6d0fca6aa39b469608f7162ef Mon Sep 17 00:00:00 2001 From: sohail Date: Mon, 8 Jan 2024 19:46:06 +0530 Subject: [PATCH] adding exception for our help strings in clang-format --- librz/include/rz_core.h | 2 +- librz/main/rizin.c | 115 ++++++++++++++++++------------------- librz/main/rz-asm.c | 90 ++++++++++++++--------------- librz/main/rz-bin.c | 122 ++++++++++++++++++++-------------------- librz/main/rz-diff.c | 107 ++++++++++++++++++----------------- librz/main/rz-find.c | 48 ++++++++-------- librz/main/rz-gg.c | 70 +++++++++++------------ librz/main/rz-hash.c | 84 +++++++++++++-------------- librz/main/rz-sign.c | 47 ++++++++-------- 9 files changed, 347 insertions(+), 338 deletions(-) diff --git a/librz/include/rz_core.h b/librz/include/rz_core.h index c50c25efdf4..6c5e685894b 100644 --- a/librz/include/rz_core.h +++ b/librz/include/rz_core.h @@ -1058,7 +1058,7 @@ RZ_API RZ_OWN char *rz_core_print_dump_str(RZ_NONNULL RzCore *core, RzOutputMode RZ_API RZ_OWN char *rz_core_print_hexdump_or_hexdiff_str(RZ_NONNULL RzCore *core, RzOutputMode mode, ut64 addr, int len, bool use_comment); RZ_API RZ_OWN char *rz_core_print_hexdump_byline_str(RZ_NONNULL RzCore *core, bool hex_offset, ut64 addr, int len, ut8 size); RZ_API RZ_OWN char *rz_core_print_bytes_with_inst(RZ_NONNULL RzCore *core, RZ_NONNULL const ut8 *buf, ut64 addr, int len); -RZ_API void rz_core_print_colored_help_option(const char *option, const char *arg, const char *description,size_t maxOptionAndArgLength); +RZ_API void rz_core_print_colored_help_option(const char *option, const char *arg, const char *description, size_t maxOptionAndArgLength); typedef enum { RZ_CORE_DISASM_STRINGS_MODE_BYTES = 0, diff --git a/librz/main/rizin.c b/librz/main/rizin.c index 0cb3038bf0e..2da9091da19 100644 --- a/librz/main/rizin.c +++ b/librz/main/rizin.c @@ -94,70 +94,71 @@ static int main_help(int line) { if (line < 2) { printf("%s%s", Color_CYAN, "Usage: "); printf(Color_RESET "rizin [-ACdfLMnNqStuvwzX] [-P patch] [-p prj] [-a arch] [-b bits] [-i file]\n" - " [-s addr] [-B baddr] [-m maddr] [-c cmd] [-e k=v] file|pid|-|--|=\n"); - + " [-s addr] [-B baddr] [-m maddr] [-c cmd] [-e k=v] file|pid|-|--|=\n"); } if (line != 1) { const char *options[] = { - "--","","run rizin without opening any file", - "=","","same as 'rizin malloc://512", - "-","","read file from stdin", - "-=","","perform R=! command to run all commands remotely", - "-0","","print \\x00 after init and every command", - "-2","","close stderr file descriptor (silent warning messages)", - "-a","[arch]","set asm.arch", - "-A","","run 'aaa' command to analyze all referenced code", - "-b","[bits]","set asm.bits", - "-B","[baddr]","set base address for PIE binaries", - "-c 'cmd..'","","execute rizin command", - "-C","","file is host:port (alias for -cR+http://%%s/cmd/)", - "-d","","debug the executable 'file' or running process 'pid", - "-D","[backend]","enable debug mode (e cfg.debug=true)", - "-e k=v","","evaluate config var", - "-f","","block size = file size", - "-F","[binplug]","force to use that rbin plugin", - "-h, -hh","","show help message, -hh for long", - "-H","([var])","display variable", - "-i","[file]","run script file", - "-I","[file]","run script file before the file is opened", - "-k","[OS/kern]","set asm.os (linux, macos, w32, netbsd, ...)", - "-l","[lib]","load plugin file", - "-L","","list supported IO plugins", - "-m","[addr]","map file at given address (loadaddr)", - "-M","","do not demangle symbol names", - "-n, -nn","","do not load RzBin info (-nn only load bin structures)", - "-N","","do not load user settings and scripts", - "-NN","","do not load any script or plugin", - "-q","","quiet mode (no prompt) and quit after -i", - "-qq","","quit after running all -c and -i", - "-Q","","quiet mode (no prompt) and quit faster (quickLeak=true)", - "-p","[p.rzdb]","load project file", - "-r","[rz-run]","specify rz-run profile to load (same as -e dbg.profile=X)", - "-R","[rule]","specify custom rz-run directive", - "-s","[addr]","initial seek", -#if USE_THREADS && ALLOW_THREADED - "-t","","load rz-bin info in thread", -#endif - "-T","","do not compute file hashes", - "-u","","set bin.filter=false to get raw sym/sec/cls names", - "-v, -V","","show rizin version (-V show lib versions)", - "-w","","open file in write mode", - "-x","","open without exec-flag (asm.emu will not work), See io.exec", - "-X","","same as -e bin.usextr=false (useful for dyldcache)", - "-z, -zz","","do not load strings or load them even in raw", + // clang-format off + "--", "", "run rizin without opening any file", + "=", "", "same as 'rizin malloc://512", + "- ", "", "read file from stdin", + "-=", "", "perform R=! command to run all commands remotely", + "-0", "", "print \\x00 after init and every command", + "-2", "", "close stderr file descriptor (silent warning messages)", + "-a", "[arch]", "set asm.arch", + "-A", "", "run 'aaa' command to analyze all referenced code", + "-b", "[bits]", "set asm.bits", + "-B", "[baddr]", "set base address for PIE binaries", + "-c 'cmd..'", "", "execute rizin command", + "-C", "", "file is host:port (alias for -cR+http://%%s/cmd/)", + "-d", "", "debug the executable 'file' or running process 'pid", + "-D", "[backend]", "enable debug mode (e cfg.debug=true)", + "-e k=v", "", "evaluate config var", + "-f", "", "block size = file size", + "-F", "[binplug]", "force to use that rbin plugin", + "-h, -hh", "", "show help message, -hh for long", + "-H", "([var])", "display variable", + "-i", "[file]", "run script file", + "-I", "[file]", "run script file before the file is opened", + "-k", "[OS/kern]", "set asm.os (linux, macos, w32, netbsd, ...)", + "-l", "[lib]", "load plugin file", + "-L", "", "list supported IO plugins", + "-m", "[addr]", "map file at given address (loadaddr)", + "-M", "", "do not demangle symbol names", + "-n, -nn", "", "do not load RzBin info (-nn only load bin structures)", + "-N", "", "do not load user settings and scripts", + "-NN", "", "do not load any script or plugin", + "-q", "", "quiet mode (no prompt) and quit after -i", + "-qq", "", "quit after running all -c and -i", + "-Q", "", "quiet mode (no prompt) and quit faster (quickLeak=true)", + "-p", "[p.rzdb]", "load project file", + "-r", "[rz-run]", "specify rz-run profile to load (same as -e dbg.profile=X)", + "-R", "[rule]", "specify custom rz-run directive", + "-s", "[addr]", "initial seek", + #if USE_THREADS && ALLOW_THREADED + "-t", "", "load rz-bin info in thread", + #endif + "-T", "", "do not compute file hashes", + "-u", "", "set bin.filter=false to get raw sym/sec/cls names", + "-v, -V", "", "show rizin version (-V show lib versions)", + "-w", "", "open file in write mode", + "-x", "", "open without exec-flag (asm.emu will not work), See io.exec", + "-X", "", "same as -e bin.usextr=false (useful for dyldcache)", + "-z, -zz", "", "do not load strings or load them even in raw", + // clang-format on }; size_t maxOptionAndArgLength = 0; - for (int i = 0; i < sizeof(options) / sizeof(options[0]); i += 3) { - size_t optionLength = strlen(options[i]); - size_t argLength = strlen(options[i + 1]); - size_t totalLength = optionLength + argLength; - if (totalLength > maxOptionAndArgLength) { - maxOptionAndArgLength = totalLength; - } - } + for (int i = 0; i < sizeof(options) / sizeof(options[0]); i += 3) { + size_t optionLength = strlen(options[i]); + size_t argLength = strlen(options[i + 1]); + size_t totalLength = optionLength + argLength; + if (totalLength > maxOptionAndArgLength) { + maxOptionAndArgLength = totalLength; + } + } for (int i = 0; i < sizeof(options) / sizeof(options[0]); i += 3) { if (i + 1 < sizeof(options) / sizeof(options[0])) { - rz_core_print_colored_help_option(options[i], options[i + 1], options[i + 2],maxOptionAndArgLength); + rz_core_print_colored_help_option(options[i], options[i + 1], options[i + 2], maxOptionAndArgLength); } } } diff --git a/librz/main/rz-asm.c b/librz/main/rz-asm.c index 739438327f4..7e469c4c260 100644 --- a/librz/main/rz-asm.c +++ b/librz/main/rz-asm.c @@ -171,61 +171,63 @@ static int rasm_show_help(int v) { if (v < 2) { printf("%s%s", Color_CYAN, "Usage: "); printf(Color_RESET "rz-asm [-ACdDehLBvw] [-a arch] [-b bits] [-o addr] [-s syntax]\n" - " [-f file] [-F fil:ter] [-i skip] [-l len] 'code'|hex|-\n"); + " [-f file] [-F fil:ter] [-i skip] [-l len] 'code'|hex|-\n"); } const char *options[] = { - "-a","[arch]","Set architecture to assemble/disassemble (see -L)", - "-A","","Show Analysis information from given hexpairs", - "-b","[bits]","Set cpu register size (8, 16, 32, 64) (RZ_ASM_BITS)", - "-B","","Binary input/output (-l is mandatory for binary input)", - "-c","[cpu]","Select specific CPU (depends on arch)", - "-C","","Output in C format", - "-d, -D","","Disassemble from hexpair bytes (-D show hexpairs)", - "-e","","Use big endian instead of little endian", - "-I","","Display lifted RzIL code (same input as in -d, IL is also validated)", - "-E","","Display ESIL expression (same input as in -d)", - "-f","[file]","Read data from file", - "-F","[in:out]","Specify input and/or output filters (att2intel, x86.pseudo, ...)", - "-h, -hh","","Show this help, -hh for long", - "-i","[len]","ignore/skip N bytes of the input buffer", - "-j","","output in json format", - "-k","[kernel]","Select operating system (linux, windows, darwin, ..)", - "-l","[len]","Input/Output length", - "-L","","List Asm plugins: (a=asm, d=disasm, A=analyze, e=ESIL)", - "-o, -@","[addr]","Set start address for code (default 0)", - "-O","[file]","Output file name (rz-asm -Bf a.asm -O a)", - "-p","","Run SPP over input for assembly", - "-q","","quiet mode", - "-r","","output in rizin commands", - "-s","[syntax]","Select syntax (intel, att)", - "-v","","Show version information", - "-x","","Use hex dwords instead of hex pairs when assembling.", - "-w","","What's this instruction for? describe opcode", + // clang-format off + "-a", "[arch]", "Set architecture to assemble/disassemble (see -L)", + "-A", "", "Show Analysis information from given hexpairs", + "-b", "[bits]", "Set cpu register size (8, 16, 32, 64) (RZ_ASM_BITS)", + "-B", "", "Binary input/output (-l is mandatory for binary input)", + "-c", "[cpu]", "Select specific CPU (depends on arch)", + "-C", "", "Output in C format", + "-d, -D", "", "Disassemble from hexpair bytes (-D show hexpairs)", + "-e", "", "Use big endian instead of little endian", + "-I", "", "Display lifted RzIL code (same input as in -d, IL is also validated)", + "-E", "", "Display ESIL expression (same input as in -d)", + "-f", "[file]", "Read data from file", + "-F", "[in:out]", "Specify input and/or output filters (att2intel, x86.pseudo, ...)", + "-h, -hh", "", "Show this help, -hh for long", + "-i", "[len]", "ignore/skip N bytes of the input buffer", + "-j", "", "output in json format", + "-k", "[kernel]", "Select operating system (linux, windows, darwin, ..)", + "-l", "[len]", "Input/Output length", + "-L", "", "List Asm plugins: (a=asm, d=disasm, A=analyze, e=ESIL)", + "-o, -@", "[addr]", "Set start address for code (default 0)", + "-O", "[file]", "Output file name (rz-asm -Bf a.asm -O a)", + "-p", "", "Run SPP over input for assembly", + "-q", "", "quiet mode", + "-r", "", "output in rizin commands", + "-s", "[syntax]", "Select syntax (intel, att)", + "-v", "", "Show version information", + "-x", "", "Use hex dwords instead of hex pairs when assembling.", + "-w", "", "What's this instruction for? describe opcode", + // clang-format on }; if (v != 1) { size_t maxOptionAndArgLength = 0; - for (int i = 0; i < sizeof(options) / sizeof(options[0]); i += 3) { - size_t optionLength = strlen(options[i]); - size_t argLength = strlen(options[i + 1]); - size_t totalLength = optionLength + argLength; - if (totalLength > maxOptionAndArgLength) { - maxOptionAndArgLength = totalLength; - } - } + for (int i = 0; i < sizeof(options) / sizeof(options[0]); i += 3) { + size_t optionLength = strlen(options[i]); + size_t argLength = strlen(options[i + 1]); + size_t totalLength = optionLength + argLength; + if (totalLength > maxOptionAndArgLength) { + maxOptionAndArgLength = totalLength; + } + } for (int i = 0; i < sizeof(options) / sizeof(options[0]); i += 3) { if (i + 1 < sizeof(options) / sizeof(options[0])) { - rz_core_print_colored_help_option(options[i], options[i + 1], options[i + 2],maxOptionAndArgLength); + rz_core_print_colored_help_option(options[i], options[i + 1], options[i + 2], maxOptionAndArgLength); } } } printf(" If '-l' value is greater than output length, output is padded with nops\n" - " If the last argument is '-' reads from stdin\n" - "Environment:\n" - " RZ_NOPLUGINS do not load shared plugins (speedup loading)\n" - " RZ_ASM_ARCH same as rz-asm -a\n" - " RZ_ASM_BITS same as rz-asm -b\n" - " RZ_DEBUG if defined, show error messages and crash signal\n" - ""); + " If the last argument is '-' reads from stdin\n" + "Environment:\n" + " RZ_NOPLUGINS do not load shared plugins (speedup loading)\n" + " RZ_ASM_ARCH same as rz-asm -a\n" + " RZ_ASM_BITS same as rz-asm -b\n" + " RZ_DEBUG if defined, show error messages and crash signal\n" + ""); if (v == 2) { printf("Supported Assembler directives:\n"); rz_asm_list_directives(); diff --git a/librz/main/rz-bin.c b/librz/main/rz-bin.c index 96c454bb64c..bb4663fcee8 100644 --- a/librz/main/rz-bin.c +++ b/librz/main/rz-bin.c @@ -151,70 +151,72 @@ static ut32 actions2mask(ut64 action) { } static int rabin_show_help(int v) { - printf("%s%s%s", Color_CYAN, "Usage: ",Color_RESET); + printf("%s%s%s", Color_CYAN, "Usage: ", Color_RESET); printf("rz-bin [-AcdeEghHiIjlLMqrRsSUvVxzZ] [-@ at] [-a arch] [-b bits] [-B addr]\n" " [-C F:C:D] [-f str] [-m addr] [-n str] [-N m:M] [-P[-P] pdb]\n" " [-o str] [-O str] [-k query] [-D lang symname] file\n"); if (v) { - const char *options[] ={ - "-@","[addr]","show section, symbol or import at addr", - "-A","","list sub-binaries and their arch-bits pairs", - "-a","[arch]","set arch (x86, arm, .. or _)", - "-b","[bits]","set bits (32, 64 ...)", - "-B","[addr]","override base address (pie bins)", - "-c","","list classes", - "-cc","","list classes in header format", - "-C","[fmt:C:D]","create [elf,mach0,pe] with Code and Data hexpairs (see -a)", - "-d","","show debug/dwarf information", - "-D","lang name","demangle symbol name (-D all for bin.demangle=true)", - "-e","","entrypoint", - "-ee","","constructor/destructor entrypoints", - "-E","","globally exportable symbols", - "-f","[str]","select sub-bin named str", - "-F","[binfmt]","force to use that bin plugin (ignore header check)", - "-g","","same as -SMZIHVResizcld -SS -SSS -ee (show all info)", - "-G","[addr]","load address . offset to header", - "-h","","this help message", - "-H","","header fields", - "-i","","imports (symbols imported from libraries)", - "-I","","binary info", - "-j","","output in json", - "-k","[sdb-query]","run sdb query. for example: '*'", - "-K","[algo]","calculate checksums (md5, sha1, ..)", - "-l","","linked libraries", - "-L","[plugin]","list supported bin plugins or plugin details", - "-m","[addr]","show source line at addr", - "-M","","main (show address of main symbol)", - "-n","[str]","show section, symbol or import named str", - "-N","[min:max]","force min:max number of chars per string (see -z and -zz)", - "-o","[str]","output file/folder for write operations (out by default)", - "-O","[str]","write/extract operations (-O help)", - "-p","","show physical addresses", - "-P","","show debug/pdb information", - "-PP","","download pdb file for binary", - "-q","","be quiet, just show fewer data", - "-qq","","show less info (no offset/size for -z for ex.)", - "-Q","","show load address used by dlopen (non-aslr libs)", - "-r","","rizin output", - "-R","","relocations", - "-s","","symbols", - "-S","","sections", - "-SS","","segments", - "-SSS","","sections mapping to segments", - "-T","","display file signature", - "-u","","unfiltered (no rename duplicated symbols/sections)", - "-U","","resoUrces", - "-v","","display version and quit", - "-V","","Show binary version information", - "-w","","display try/catch blocks", - "-x","","extract bins contained in file", - "-X","[fmt] [f] ..","package in fat or zip the given files and bins contained in file", - "-Y","[fw file]","calculates all the possibles base address candidates of a firmware bin", - "-z","","strings (from data section)", - "-zz","","strings (from raw strings from bin)", - "-zzz","","dump raw strings to stdout (for huge files)", - "-Z","","guess size of binary program", - }; + const char *options[] = { + // clang-format off + "-@", "[addr]", "show section, symbol or import at addr", + "-A", "", "list sub-binaries and their arch-bits pairs", + "-a", "[arch]", "set arch (x86, arm, .. or _)", + "-b", "[bits]", "set bits (32, 64 ...)", + "-B", "[addr]", "override base address (pie bins)", + "-c", "", "list classes", + "-cc", "", "list classes in header format", + "-C", "[fmt:C:D]", "create [elf,mach0,pe] with Code and Data hexpairs (see -a)", + "-d", "", "show debug/dwarf information", + "-D", "lang name", "demangle symbol name (-D all for bin.demangle=true)", + "-e", "", "entrypoint", + "-ee", "", "constructor/destructor entrypoints", + "-E", "", "globally exportable symbols", + "-f", "[str]", "select sub-bin named str", + "-F", "[binfmt]", "force to use that bin plugin (ignore header check)", + "-g", "", "same as -SMZIHVResizcld -SS -SSS -ee (show all info)", + "-G", "[addr]", "load address . offset to header", + "-h", "", "this help message", + "-H", "", "header fields", + "-i", "", "imports (symbols imported from libraries)", + "-I", "", "binary info", + "-j", "", "output in json", + "-k", "[sdb-query]", "run sdb query. for example: '*'", + "-K", "[algo]", "calculate checksums (md5, sha1, ..)", + "-l", "", "linked libraries", + "-L", "[plugin]", "list supported bin plugins or plugin details", + "-m", "[addr]", "show source line at addr", + "-M", "", "main (show address of main symbol)", + "-n", "[str]", "show section, symbol or import named str", + "-N", "[min:max]", "force min:max number of chars per string (see -z and -zz)", + "-o", "[str]", "output file/folder for write operations (out by default)", + "-O", "[str]", "write/extract operations (-O help)", + "-p", "", "show physical addresses", + "-P", "", "show debug/pdb information", + "-PP", "", "download pdb file for binary", + "-q", "", "be quiet, just show fewer data", + "-qq", "", "show less info (no offset/size for -z for ex.)", + "-Q", "", "show load address used by dlopen (non-aslr libs)", + "-r", "", "rizin output", + "-R", "", "relocations", + "-s", "", "symbols", + "-S", "", "sections", + "-SS", "", "segments", + "-SSS", "", "sections mapping to segments", + "-T", "", "display file signature", + "-u", "", "unfiltered (no rename duplicated symbols/sections)", + "-U", "", "resoUrces", + "-v", "", "display version and quit", + "-V", "", "Show binary version information", + "-w", "", "display try/catch blocks", + "-x", "", "extract bins contained in file", + "-X", "[fmt] [f] ..", "package in fat or zip the given files and bins contained in file", + "-Y", "[fw file]", "calculates all the possibles base address candidates of a firmware bin", + "-z", "", "strings (from data section)", + "-zz", "", "strings (from raw strings from bin)", + "-zzz", "", "dump raw strings to stdout (for huge files)", + "-Z", "", "guess size of binary program", + // clang-format on + }; size_t maxOptionAndArgLength = 0; for (int i = 0; i < sizeof(options) / sizeof(options[0]); i += 3) { size_t optionLength = strlen(options[i]); diff --git a/librz/main/rz-diff.c b/librz/main/rz-diff.c index 7288267ee49..e089f6792e5 100644 --- a/librz/main/rz-diff.c +++ b/librz/main/rz-diff.c @@ -202,67 +202,68 @@ static void rz_diff_show_help(bool usage_only) { return; } const char *options[] = { - "-a","[arch]","specify architecture plugin to use (x86, arm, ..)", - "-b","[bits]","specify register size for arch (16 (thumb), 32, 64, ..)", - "-d","[algo]","compute edit distance based on the choosen algorithm:", - "",""," myers | Eugene W. Myers' O(ND) algorithm (no substitution)", - "",""," leven | Levenshtein O(N^2) algorithm (with substitution)", - "",""," ssdeep | Context triggered piecewise hashing comparison", - "-i","","use command line arguments instead of files (only for -d)", - "-H","","hexadecimal visual mode", - "-h","","show the help message", - "-j","","json output", - "-q","","quite output", - "-V","","show version information", - "-v","","be more verbose (stderr output)", - "-e","[k=v]","set an evaluable config variable", - "-A","","compare virtual and physical addresses", - "-B","","run 'aaa' when loading the bin", - "-C","","disable colors", - "-T","","show timestamp information", - "-S","[WxH]","sets the width and height of the terminal for visual mode", - "-0","[cmd]","input for file0 when option -t 'commands' is given.","","", - "the same value will be set for file1, if -1 is not set.", - "-1","[cmd]","input for file1 when option -t 'commands' is given.", - "-t","[type]","compute the difference between two files based on its type:", - "",""," bytes | compares raw bytes in the files (only for small files)", - "",""," lines | compares text files", - "",""," functions | compares functions found in the files", - "",""," classes | compares classes found in the files", - "",""," command | compares command output returned when executed in both files", - "",""," | requires -0 and -1 is optional", - "",""," entries | compares entries found in the files", - "",""," fields | compares fields found in the files", - "",""," graphs | compares 2 functions and outputs in graphviz/dot format", - "",""," | requires -0 and -1 is optional", - "",""," imports | compares imports found in the files", - "",""," libraries | compares libraries found in the files", - "",""," sections | compares sections found in the files", - "",""," strings | compares strings found in the files", - "",""," symbols | compares symbols found in the files", + // clang-format off + "-a", "[arch]", "specify architecture plugin to use (x86, arm, ..)", + "-b", "[bits]", "specify register size for arch (16 (thumb), 32, 64, ..)", + "-d", "[algo]", "compute edit distance based on the chosen algorithm:", + "", "", " myers | Eugene W. Myers' O(ND) algorithm (no substitution)", + "", "", " leven | Levenshtein O(N^2) algorithm (with substitution)", + "", "", " ssdeep | Context triggered piecewise hashing comparison", + "-i", "", "use command line arguments instead of files (only for -d)", + "-H", "", "hexadecimal visual mode", + "-h", "", "show the help message", + "-j", "", "json output", + "-q", "", "quite output", + "-V", "", "show version information", + "-v", "", "be more verbose (stderr output)", + "-e", "[k=v]", "set an evaluable config variable", + "-A", "", "compare virtual and physical addresses", + "-B", "", "run 'aaa' when loading the bin", + "-C", "", "disable colors", + "-T", "", "show timestamp information", + "-S", "[WxH]", "sets the width and height of the terminal for visual mode", + "-0", "[cmd]", "input for file0 when option -t 'commands' is given.", + "", "", "the same value will be set for file1, if -1 is not set.", + "-1", "[cmd]", "input for file1 when option -t 'commands' is given.", + "-t", "[type]", "compute the difference between two files based on its type:", + "", "", " bytes | compares raw bytes in the files (only for small files)", + "", "", " lines | compares text files", + "", "", " functions | compares functions found in the files", + "", "", " classes | compares classes found in the files", + "", "", " command | compares command output returned when executed in both files", + "", "", " | requires -0 and -1 is optional", + "", "", " entries | compares entries found in the files", + "", "", " fields | compares fields found in the files", + "", "", " graphs | compares 2 functions and outputs in graphviz/dot format", + "", "", " | requires -0 and -1 is optional", + "", "", " imports | compares imports found in the files", + "", "", " libraries | compares libraries found in the files", + "", "", " sections | compares sections found in the files", + "", "", " strings | compares strings found in the files", + "", "", " symbols | compares symbols found in the files", + // clang-format on }; size_t maxOptionAndArgLength = 0; - for (int i = 0; i < sizeof(options) / sizeof(options[0]); i += 3) { - size_t optionLength = strlen(options[i]); - size_t argLength = strlen(options[i + 1]); - size_t totalLength = optionLength + argLength; - if (totalLength > maxOptionAndArgLength) { - maxOptionAndArgLength = totalLength; - } - } + for (int i = 0; i < sizeof(options) / sizeof(options[0]); i += 3) { + size_t optionLength = strlen(options[i]); + size_t argLength = strlen(options[i + 1]); + size_t totalLength = optionLength + argLength; + if (totalLength > maxOptionAndArgLength) { + maxOptionAndArgLength = totalLength; + } + } for (int i = 0; i < sizeof(options) / sizeof(options[0]); i += 3) { if (i + 1 < sizeof(options) / sizeof(options[0])) { - rz_core_print_colored_help_option(options[i], options[i + 1], options[i + 2],maxOptionAndArgLength); + rz_core_print_colored_help_option(options[i], options[i + 1], options[i + 2], maxOptionAndArgLength); } } printf( - "palette colors can be changed by adding the following lines\n" - "inside the $HOME/.rizinrc file\n" - "ec diff.unknown blue | offset color\n" - "ec diff.match green | match color\n" - "ec diff.unmatch red | mismatch color\n"); - + "palette colors can be changed by adding the following lines\n" + "inside the $HOME/.rizinrc file\n" + "ec diff.unknown blue | offset color\n" + "ec diff.match green | match color\n" + "ec diff.unmatch red | mismatch color\n"); } static bool rz_diff_is_file(const char *file) { diff --git a/librz/main/rz-find.c b/librz/main/rz-find.c index 35e9eade67c..5882b55aa9e 100644 --- a/librz/main/rz-find.c +++ b/librz/main/rz-find.c @@ -177,29 +177,31 @@ static int show_help(const char *argv0, int line) { return 0; } const char *options[] = { - "-a","[align]","only accept aligned hits", - "-b","[size]","set block size", - "-e","[regex]","search for regex matches (can be used multiple times)", - "-f","[from]","start searching from address 'from'", - "-F","[file]","read the contents of the file and use it as keyword", - "-h","","show this help", - "-i","","identify filetype (rizin -nqcpm file)", - "-j","","output in JSON", - "-m","","magic search, file-type carver", - "-M","[str]","set a binary mask to be applied on keywords", - "-n","","do not stop on read errors", - "-r","","print using rizin commands", - "-s","[str]","search for a specific string (can be used multiple times)", - "-w","[str]","search for a specific wide string (can be used multiple times). Assumes str is UTF-8.", - "-I","[str]","search for an entry in import table.", - "-S","[str]","search for a symbol in symbol table.", - "-t","[to]","stop search at address 'to'", - "-q","","quiet - do not show headings (filenames) above matching contents (default for searching a single file)", - "-v","","print version and exit", - "-x","[hex]","search for hexpair string (909090) (can be used multiple times)", - "-X","","show hexdump of search results", - "-z","","search for zero-terminated strings", - "-Z","","show string found on each search hit", + // clang-format off + "-a", "[align]", "only accept aligned hits", + "-b", "[size]", "set block size", + "-e", "[regex]", "search for regex matches (can be used multiple times)", + "-f", "[from]", "start searching from address 'from'", + "-F", "[file]", "read the contents of the file and use it as keyword", + "-h", "", "show this help", + "-i", "", "identify filetype (rizin -nqcpm file)", + "-j", "", "output in JSON", + "-m", "", "magic search, file-type carver", + "-M", "[str]", "set a binary mask to be applied on keywords", + "-n", "", "do not stop on read errors", + "-r", "", "print using rizin commands", + "-s", "[str]", "search for a specific string (can be used multiple times)", + "-w", "[str]", "search for a specific wide string (can be used multiple times). Assumes str is UTF-8.", + "-I", "[str]", "search for an entry in import table.", + "-S", "[str]", "search for a symbol in symbol table.", + "-t", "[to]", "stop search at address 'to'", + "-q", "", "quiet - do not show headings (filenames) above matching contents (default for searching a single file)", + "-v", "", "print version and exit", + "-x", "[hex]", "search for hexpair string (909090) (can be used multiple times)", + "-X", "", "show hexdump of search results", + "-z", "", "search for zero-terminated strings", + "-Z", "", "show string found on each search hit", + // clang-format on }; size_t maxOptionAndArgLength = 0; for (int i = 0; i < sizeof(options) / sizeof(options[0]); i += 3) { diff --git a/librz/main/rz-gg.c b/librz/main/rz-gg.c index f1c02abf044..f29c4ace739 100644 --- a/librz/main/rz-gg.c +++ b/librz/main/rz-gg.c @@ -15,42 +15,40 @@ static int usage(int v) { " [-S string] [-f fmt] [-nN dword] [-dDw off:hex] file|f.asm|-\n"); if (v) { const char *options[] = { - "-a","[arch]","select architecture (x86, mips, arm)", - "-b","[bits]","register size (32, 64, ..)", - "-B","[hexpairs]","append some hexpair bytes", - "-c","[k=v]","set configuration options", - "-C","[file]","append contents of file", - "-d","[off:dword]","patch dword (4 bytes) at given offset", - "-D","[off:qword]","patch qword (8 bytes) at given offset", - "-e","[encoder]","use specific encoder. see -L", - "-f","[format]","output format (raw, c, pe, elf, mach0, python, javascript)", - "-F","","output native format (osx=mach0, linux=elf, ..)", - "-h","","show this help", - "-i","[shellcode]","include shellcode plugin, uses options. see -L", - "-I","[path]","add include path", - "-k","[os]","operating system's kernel (linux,bsd,osx,w32)", - "-L","","list all plugins (shellcodes and encoders)", - "-n","[dword]","append 32bit number (4 bytes)", - "-N","[dword]","append 64bit number (8 bytes)", - "-o","[file]","output file", - "-O","","use default output file (filename without extension or a.out)", - "-p","[padding]","add padding after compilation (padding=n10s32)", - "", - "", - "ntas : begin nop, trap, 'a', sequence", - "", - "", - "NTAS : same as above, but at the end", - "-P","[size]","prepend debruijn pattern", - "-q","[fragment]","debruijn pattern offset", - "-r","","show raw bytes instead of hexpairs", - "-s","","show assembler", - "-S","[string]","append a string", - "-v","","show version", - "-w","[off:hex]","patch hexpairs at given offset", - "-x","","execute", - "-X","[hexpairs]","execute rop chain, using the stack provided", - "-z","","output in C string syntax", + // clang-format off + "-a", "[arch]" ,"select architecture (x86, mips, arm)", + "-b", "[bits]" ,"register size (32, 64, ..)", + "-B", "[hexpairs]" ,"append some hexpair bytes", + "-c", "[k=v]" ,"set configuration options", + "-C", "[file]" ,"append contents of file", + "-d", "[off:dword]" ,"patch dword (4 bytes) at given offset", + "-D", "[off:qword]" ,"patch qword (8 bytes) at given offset", + "-e", "[encoder]" ,"use specific encoder. see -L", + "-f", "[format]" ,"output format (raw, c, pe, elf, mach0, python, javascript)", + "-F", "" ,"output native format (osx=mach0, linux=elf, ..)", + "-h", "" ,"show this help", + "-i", "[shellcode]" ,"include shellcode plugin, uses options. see -L", + "-I", "[path]" ,"add include path", + "-k", "[os]" ,"operating system's kernel (linux,bsd,osx,w32)", + "-L", "" ,"list all plugins (shellcodes and encoders)", + "-n", "[dword]" ,"append 32bit number (4 bytes)", + "-N", "[dword]" ,"append 64bit number (8 bytes)", + "-o", "[file]" ,"output file", + "-O", "" ,"use default output file (filename without extension or a.out)", + "-p", "[padding]" ,"add padding after compilation (padding=n10s32)", + "", "" ,"ntas : begin nop, trap, 'a', sequence", + "", "" ,"NTAS : same as above, but at the end", + "-P", "[size]" ,"prepend debruijn pattern", + "-q", "[fragment]" ,"debruijn pattern offset", + "-r", "" ,"show raw bytes instead of hexpairs", + "-s", "" ,"show assembler", + "-S", "[string]" ,"append a string", + "-v", "" ,"show version", + "-w", "[off:hex]" ,"patch hexpairs at given offset", + "-x", "" ,"execute", + "-X", "[hexpairs]" ,"execute rop chain, using the stack provided", + "-z", "" ,"output in C string syntax", + // clang-format on }; size_t maxOptionAndArgLength = 0; for (int i = 0; i < sizeof(options) / sizeof(options[0]); i += 3) { diff --git a/librz/main/rz-hash.c b/librz/main/rz-hash.c index 212fe8b1abf..8f71d4333bf 100644 --- a/librz/main/rz-hash.c +++ b/librz/main/rz-hash.c @@ -78,48 +78,50 @@ static void rz_hash_show_help(bool usage_only) { return; } const char *options[] = { - "-v","","Shows version", - "-h","","Shows this help page", - "-","","Input read from stdin instead from a file", - "-a","algo","Hash algorithm to use and you can specify multiple ones by", - "","","appending a comma (example: sha1,md4,md5,sha256)", - "-B","","Outputs the calculated value for each block", - "-b","size","Sets the block size", - "-c","value","Compare calculated value with a given one (hexadecimal)", - "-e","endian","Sets the endianness (default: 'big' accepted: 'big' or 'little')", - "-D","algo","Decrypt the given input; use -S to set key and -I to set IV (if needed)", - "-E","algo","Encrypt the given input; use -S to set key and -I to set IV (if needed)", - "-f","from","Starts the calculation at given offset", - "-t","to","Stops the calculation at given offset", - "-I","iv","Sets the initialization vector (IV)", - "-i","times","Repeat the calculation N times", - "-j","","Outputs the result as a JSON structure", - "-k","","Outputs the calculated value using openssh's randomkey algorithm", - "-L","","List all algorithms", - "-q","","Sets quiet mode (use -qq to get only the calculated value)", - "-S","seed","Sets the seed for -a, use '^' to append it before the input, use '@'", - "","","prefix to load it from a file and '-' from read it", - "-K","key","Sets the hmac key for -a and the key for -E/-D, use '@' prefix to", - "","","load it from a file and '-' from read it", - "","","from stdin (you can combine them)", - "-s","string","Input read from a zero-terminated string instead from a file", - "-x","hex","Input read from a hexadecimal value instead from a file", - "","","", - "","","All the inputs (besides -s/-x/-c) can be hexadecimal or strings", - "","","if 's:' prefix is specified", - }; - size_t maxOptionAndArgLength = 0; - for (int i = 0; i < sizeof(options) / sizeof(options[0]); i += 3) { - size_t optionLength = strlen(options[i]); - size_t argLength = strlen(options[i + 1]); - size_t totalLength = optionLength + argLength; - if (totalLength > maxOptionAndArgLength) { - maxOptionAndArgLength = totalLength; - } - } - for (int i = 0; i < sizeof(options) / sizeof(options[0]); i += 3) { + // clang-format off + "-v", "", "Shows version", + "-h", "", "Shows this help page", + "-", "", "Input read from stdin instead from a file", + "-a", "algo", "Hash algorithm to use and you can specify multiple ones by", + "", "", "appending a comma (example: sha1,md4,md5,sha256)", + "-B", "", "Outputs the calculated value for each block", + "-b", "size", "Sets the block size", + "-c", "value", "Compare calculated value with a given one (hexadecimal)", + "-e", "endian", "Sets the endianness (default: 'big' accepted: 'big' or 'little')", + "-D", "algo", "Decrypt the given input; use -S to set key and -I to set IV (if needed)", + "-E", "algo", "Encrypt the given input; use -S to set key and -I to set IV (if needed)", + "-f", "from", "Starts the calculation at given offset", + "-t", "to", "Stops the calculation at given offset", + "-I", "iv", "Sets the initialization vector (IV)", + "-i", "times", "Repeat the calculation N times", + "-j", "", "Outputs the result as a JSON structure", + "-k", "", "Outputs the calculated value using openssh's randomkey algorithm", + "-L", "", "List all algorithms", + "-q", "", "Sets quiet mode (use -qq to get only the calculated value)", + "-S", "seed", "Sets the seed for -a, use '^' to append it before the input, use '@'", + "", "", "prefix to load it from a file and '-' from read it", + "-K", "key", "Sets the hmac key for -a and the key for -E/-D, use '@' prefix to", + "", "", "load it from a file and '-' from read it", + "", "", "from stdin (you can combine them)", + "-s", "string", "Input read from a zero-terminated string instead from a file", + "-x", "hex", "Input read from a hexadecimal value instead from a file", + "", "", "", + "", "", "All the inputs (besides -s/-x/-c) can be hexadecimal or strings", + "", "", "if 's:' prefix is specified", + // clang-format on + }; + size_t maxOptionAndArgLength = 0; + for (int i = 0; i < sizeof(options) / sizeof(options[0]); i += 3) { + size_t optionLength = strlen(options[i]); + size_t argLength = strlen(options[i + 1]); + size_t totalLength = optionLength + argLength; + if (totalLength > maxOptionAndArgLength) { + maxOptionAndArgLength = totalLength; + } + } + for (int i = 0; i < sizeof(options) / sizeof(options[0]); i += 3) { if (i + 1 < sizeof(options) / sizeof(options[0])) { - rz_core_print_colored_help_option(options[i], options[i + 1], options[i + 2],maxOptionAndArgLength); + rz_core_print_colored_help_option(options[i], options[i + 1], options[i + 2], maxOptionAndArgLength); } } } diff --git a/librz/main/rz-sign.c b/librz/main/rz-sign.c index 82341471b24..47751253d5e 100644 --- a/librz/main/rz-sign.c +++ b/librz/main/rz-sign.c @@ -14,37 +14,38 @@ enum rz_sign_option { static void rz_sign_show_help(void) { printf("%s%s%s", Color_CYAN, "Usage: ", Color_RESET); printf("rz-sign [options] [file]\n"); - const char *options[] ={ - "-h","","this help message", - "-a","[-a]","add extra 'a' to analysis command (available only with -o option)", - "-e","[k=v]","set an evaluable config variable (available only with -o option)", - "-c","[output.pat] [input.sig]","parses a FLIRT signature and converts it to its other format", - "-o","[output.sig] [input.bin]","performs an analysis on the binary and generates the FLIRT signature.", - "-d","[flirt.sig]","parses a FLIRT signature and dump its content", - "-q","","quiet mode", - "-v","","show version information", - }; + const char *options[] = { + // clang-format off + "-h", "", "this help message", + "-a", "[-a]", "add extra 'a' to analysis command (available only with -o option)", + "-e", "[k=v]", "set an evaluable config variable (available only with -o option)", + "-c", "[output.pat] [input.sig]", "parses a FLIRT signature and converts it to its other format", + "-o", "[output.sig] [input.bin]", "performs an analysis on the binary and generates the FLIRT signature.", + "-d", "[flirt.sig]", "parses a FLIRT signature and dumps its content", + "-q", "", "quiet mode", + "-v", "", "show version information", + // clang-format on + }; size_t maxOptionAndArgLength = 0; - for (int i = 0; i < sizeof(options) / sizeof(options[0]); i += 3) { - size_t optionLength = strlen(options[i]); - size_t argLength = strlen(options[i + 1]); - size_t totalLength = optionLength + argLength; - if (totalLength > maxOptionAndArgLength) { - maxOptionAndArgLength = totalLength; - } - } + for (int i = 0; i < sizeof(options) / sizeof(options[0]); i += 3) { + size_t optionLength = strlen(options[i]); + size_t argLength = strlen(options[i + 1]); + size_t totalLength = optionLength + argLength; + if (totalLength > maxOptionAndArgLength) { + maxOptionAndArgLength = totalLength; + } + } for (int i = 0; i < sizeof(options) / sizeof(options[0]); i += 3) { if (i + 1 < sizeof(options) / sizeof(options[0])) { - rz_core_print_colored_help_option(options[i], options[i + 1], options[i + 2],maxOptionAndArgLength); + rz_core_print_colored_help_option(options[i], options[i + 1], options[i + 2], maxOptionAndArgLength); } } printf("Examples:\n" - " rz-sign -d signature.sig\n" - " rz-sign -c new_signature.pat old_signature.sig\n" - " rz-sign -o libc.sig libc.so.6\n"); + " rz-sign -d signature.sig\n" + " rz-sign -c new_signature.pat old_signature.sig\n" + " rz-sign -o libc.sig libc.so.6\n"); } - static void perform_analysis(RzCore *core, size_t complexity) { const char *cmd = NULL; switch (complexity) {