rabin2 -c <-> -C

This commit is contained in:
pancake 2015-07-06 01:08:14 +02:00
parent c10bcdfbea
commit a67e74c6cd
3 changed files with 20 additions and 16 deletions

View File

@ -46,8 +46,8 @@ static ut64 at = 0LL;
static RLib *l;
static int rabin_show_help(int v) {
printf ("Usage: rabin2 [-ACdehHiIjlLMqrRsSvVxzZ] [-@ addr] [-a arch] [-b bits]\n"
" [-B addr] [-c F:C:D] [-f str] [-m addr] [-n str] [-N m:M]\n"
printf ("Usage: rabin2 [-AcdehHiIjlLMqrRsSvVxzZ] [-@ addr] [-a arch] [-b bits]\n"
" [-B addr] [-C F:C:D] [-f str] [-m addr] [-n str] [-N m:M]\n"
" [-o str] [-O str] [-k query] [-D lang symname] | file\n");
if (v) printf (
" -@ [addr] show section, symbol or import at addr\n"
@ -55,8 +55,8 @@ static int rabin_show_help(int v) {
" -a [arch] set arch (x86, arm, .. or <arch>_<bits>)\n"
" -b [bits] set bits (32, 64 ...)\n"
" -B [addr] override base address (pie bins)\n"
" -c [fmt:C:D] create [elf,mach0,pe] with Code and Data hexpairs (see -a)\n"
" -C list classes\n"
" -c list classes\n"
" -C [fmt:C:D] create [elf,mach0,pe] with Code and Data hexpairs (see -a)\n"
" -d show debug/dwarf information\n"
" -D lang name demangle symbol name (-D all for bin.demangle=true)\n"
" -e entrypoint\n"
@ -391,7 +391,7 @@ int main(int argc, char **argv) {
#define is_active(x) (action&x)
#define set_action(x) actions++; action |= x
#define unset_action(x) action &= ~x
while ((c = getopt (argc, argv, "DjgqAf:F:a:B:G:b:c:Ck:K:dD:Mm:n:N:@:isSIHeElRwO:o:pPrvLhuxzZ")) != -1) {
while ((c = getopt (argc, argv, "DjgqAf:F:a:B:G:b:cC:k:K:dD:Mm:n:N:@:isSIHeElRwO:o:pPrvLhuxzZ")) != -1) {
switch (c) {
case 'g':
set_action (ACTION_CLASSES);
@ -412,9 +412,9 @@ int main(int argc, char **argv) {
case 'j': rad = R_CORE_BIN_JSON; break;
case 'A': set_action (ACTION_LISTARCHS); break;
case 'a': if (optarg) arch = optarg; break;
case 'c':
case 'C':
if (!optarg) {
eprintf ("Missing argument for -c");
eprintf ("Missing argument for -C");
r_core_fini (&core);
return 1;
}
@ -424,7 +424,7 @@ int main(int argc, char **argv) {
case 'u': bin->filter = 0; break;
case 'k': query = optarg; break;
case 'K': chksum = optarg; break;
case 'C': set_action (ACTION_CLASSES); break;
case 'c': set_action (ACTION_CLASSES); break;
case 'f': if (optarg) arch_name = strdup (optarg); break;
case 'F': forcebin = optarg; break;
case 'b': bits = r_num_math (NULL, optarg); break;
@ -575,7 +575,7 @@ int main(int argc, char **argv) {
ut8 *data = NULL, *code = NULL;
char *p2, *p = strchr (create, ':');
if (!p) {
eprintf ("Invalid format for -c flag. Use 'format:codehexpair:datahexpair'\n");
eprintf ("Invalid format for -C flag. Use 'format:codehexpair:datahexpair'\n");
r_core_fini (&core);
return 1;
}

View File

@ -310,8 +310,12 @@ static int cmd_info(void *data, const char *input) {
RBININFO ("strings", R_CORE_BIN_ACC_STRINGS);
}
break;
case 'c':
case 'C': RBININFO ("classes", R_CORE_BIN_ACC_CLASSES); break;
case 'c': // for r2 `ic`
if (input[1]== ' ') {
eprintf ("TODO: list methods\n");
} else {
RBININFO ("classes", R_CORE_BIN_ACC_CLASSES); break;
}
case 'D':
if (input[1]!=' ' || !demangle (core, input+2)) {
eprintf ("|Usage: iD lang symbolname\n");

View File

@ -5,11 +5,11 @@
.Nd Binary program info extractor
.Sh SYNOPSIS
.Nm rabin2
.Op Fl ACeghHiIsSMzlpRrLxvh
.Op Fl AceghHiIsSMzlpRrLxvh
.Op Fl a Ar arch
.Op Fl b Ar bits
.Op Fl B Ar addr
.Op Fl c Ar fmt:C:[D]
.Op Fl C Ar fmt:C:[D]
.Op Fl D Ar lang
.Op Fl f Ar subbin
.Op Fl k Ar query
@ -33,10 +33,10 @@ Set arch (x86, arm, .. accepts underscore for bits x86_32)
Set bits (32, 64, ...)
.It Fl B Ar addr
Override baddr
.It Fl c Ar [fmt:C[:D]]
Create [elf,mach0,pe] for arm and x86-32/64 tiny binaries where 'C' is an hexpair list of the code bytes and ':D' is an optional concatenation to describe the bytes for the data section.
.It Fl C
.It Fl c
List classes
.It Fl C Ar [fmt:C[:D]]
Create [elf,mach0,pe] for arm and x86-32/64 tiny binaries where 'C' is an hexpair list of the code bytes and ':D' is an optional concatenation to describe the bytes for the data section.
.It Fl d
Show debug/dwarf information
.It Fl D Ar lang symbolname