File: _rabin2

package info (click to toggle)
radare2 6.0.4%2Bdfsg-1
  • links: PTS, VCS
  • area: main
  • in suites: sid
  • size: 77,536 kB
  • sloc: ansic: 889,435; sh: 8,299; javascript: 7,675; makefile: 5,194; python: 1,929; cpp: 789; perl: 438; lisp: 122; sed: 85; asm: 57; cs: 37; xml: 32; ruby: 29; java: 21
file content (90 lines) | stat: -rw-r--r-- 3,020 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
#compdef rabin2
local context state state_descr line
local -i ret=1

r2_qc() {
  r2 -qc $1 --
}

_rabin2() {
  local -a options=(
  '-@+[show section, symbol or import at addr]:addr'
  '-A[list sub-binaries and their arch-bits pairs]'
  '-a+[set arch (x86, arm, .. or <arch>_<bits>)]: :->arch'
  '-b+[set bits (32, 64 ...)]:bits:(8 16 32 64)'
  '-B+[override base address (pie bins)]:addr'
  '-c[list classes]'
  '-C[create \[elf,mach0,pe\] with Code and Data hexpairs (see -a)]:fmt\:C\:D'
  '-d[show debug/dwarf information]'
  '-D+[demangle symbol name (-D all for bin.demangle=true)]:language'
  '-e[entrypoint]'
  '-E[globally exportable symbols]'
  '-f+[select sub-bin named str]:str'
  '-F+[force to use that bin plugin (ignore header check)]:binfmt'
  '-g[same as -SMZIHVResizcld (show all info)]'
  '-G+[load address . offset to header]:addr'
  '-h[this help message]'
  '-H[header fields]'
  '-i[imports (symbols imported from libraries)]'
  '-I[binary info]'
  '(-j -q -qq -r)-j[output in json]'
  "-k+[run sdb query. for example: '*']:sdb-query"
  '-K+[calculate checksums (md5, sha1, ..)]: :->checksum'
  '-l[linked libraries]'
  '-L[list supported bin plugins or plugin details]: :->plugin'
  '-m+[show source line at addr]:addr'
  '-M[main (show address of main symbol)]'
  '-n+[show section, symbol or import named str]:str'
  '-N[force min:max number of chars per string (see -z and -zz)]:min\:max'
  '-o+[output file/folder for write operations (out by default)]:_files'
  '-O+[write/extract operations (-O help)]:str'
  '-p[show physical addresses]'
  '(-P -PP)-P[show debug/pdb information]'
  '(-P -PP)-PP[download pdb file for binary]'
  '(-j -q -qq -r)-q[be quiet, just show fewer data]'
  '(-j -q -qq -r)-qq[show less info (no offset/size for -z for ex.)]'
  '-Q[show load address used by dlopen (non-aslr libs)]'
  '-r[radare output]'
  '-R[relocations]'
  '-s[symbols]'
  '-S[sections]'
  '-u[unfiltered (no rename duplicated symbols/sections)]'
  '-U[resoUrces]'
  '-v[display version and quit]'
  '-V[Show binary version information]'
  '-x[extract bins contained in file]'
  '-X+[\[f\] .. package in fat or zip the given files and bins contained in file]:fmt'
  '(-z -zz -zzz)-z[strings (from data section)]'
  '(-z -zz -zzz)-zz[strings (from raw bins \[e bin.rawstr=1\])]'
  '(-z -zz -zzz)-zzz[dump raw strings to stdout (for huge files)]'
  '-Z[guess size of binary program]'
  )

  _arguments -S -s : $options '*:file:_files' && ret=0

  case $state in
    arch)
      local -a sub=(${(f)"$(r2_qc 'e asm.arch=?')"})
      _values 'arch' $sub && ret=0
      ;;
    checksum)
      _values 'checksum' all $(r2_qc 'ph?') && ret=0
      ;;
    plugin)
      local -a sub=(${(f)"$(rabin2 -L | grep '^bin ' | sed -E 's/bin +([^ ]+) +(.*)/\1[\2]/')"})
      _values 'plugin' $sub && ret=0
      ;;
  esac
  return ret
}

_rabin2 "$@"

# Local Variables:
# mode: shell-script
# coding: utf-8-unix
# indent-tabs-mode: nil
# sh-indentation: 2
# sh-basic-offset: 2
# End:
# vim: ft=zsh sw=2 sts=2 et