Linux cli command ragg2
3 minute read
ragg2 is a frontend for r_egg, compile programs into tiny binaries for x86-32/64 and arm.
This tool is experimental and it is a rewrite of the old rarc2 and rarc2-tool programs as a library and integrated with r_asm and r_bin.
Programs generated by r_egg are relocatable and can be injected in a running process or on-disk binary file.
Since the ragg2-cc merge, ragg2 can now generate shellcodes from C code. The final code can be linked with rabin2 and it is relocatable, so it can be used to inject it on any remote process. This feature is conceptually based on shellforge4, but only linux/osx x86-32/64 platforms are supported.
The rr2 (ragg2) configuration file accepts the following directives, described as key=value entries and comments defined as lines starting with ‘#’.
set architecture x86, arm
32 or 64
windows, linux or osx
output format (raw, c, pe, elf, mach0, python, javascript)
output file to write result of compilation
specify shellcode name to be used (see -L)
pass egg program as argument instead of in a file
specify encoder name to be used (see -L)
specify shellcode as hexpairs
set configure option for the shellcode encoder. The argument must be key=value.
include contents of file
Patch final buffer with given dword at specified offset
Patch final buffer with given qword at specified offset
Patch final buffer with given hexpairs at specified offset
Append a 32bit number in little endian
Append a 64bit number in little endian
Specify generic paddings with a format string. Use lowercase letters to prefix, and uppercase to suffix, keychars are: ’n’ for nop, ’t’ for trap, ‘a’ for sequence and ’s’ for zero.
Prepend debruijn sequence of given length.
Output offset of debruijn sequence fragment.
autodetect native file format (osx=mach0, linux=elf, ..)
use default output file (filename without extension or a.out)
add include path
show assembler code
append a string
show raw bytes instead of hexpairs
execute (just-in-time)
execute rop chain
list all plugins (shellcodes and encoders)
show this help
output in C string syntax
show version
$ cat hi.r /* hello world in r_egg */ write@syscall(4); //x64 write@syscall(1); exit@syscall(1); //x64 exit@syscall(60);
main@global(128) { .var0 = “hi! “; write(1,.var0, 4); exit(0); } $ ragg2 -O -F hi.r $ ./hi hi!
# With C file : $ cat hi.c main() { write(1, “Hello “, 6); exit(0); } $ ragg2 -O -F hi.c
$ ./hi Hello
# Linked into a tiny binary. This is 165 bytes $ wc -c < hi 165
# The compiled shellcode has zeroes $ ragg2 hi.c | tail -1 eb0748656c6c6f0a00bf01000000488d35edffffffba06000000b8010 000000f0531ffb83c0000000f0531c0c3
# Use a xor encoder with key 64 to bypass $ ragg2 -e xor -c key=64 -B $(ragg2 hi.c | tail -1) 6a2d596a405be8ffffffffc15e4883c60d301e48ffc6e2f9ab4708252 c2c2f4a40ff4140404008cd75adbfbfbffa46404040f8414040404f45 71bff87c4040404f45718083
Written by pancake <[email protected]>.
░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░
█║▌│║█║▌★ KALI ★ PARROT ★ DEBIAN 🔴 PENTESTING ★ HACKING ★ █║▌│║█║▌
██╗ ██╗ ██████╗ ██████╗ ██╗ ██╗███████╗██████╗
████████╗██╔══██╗██╔═══██╗╚██╗██╔╝██╔════╝██╔══██╗
╚██╔═██╔╝██║ ██║██║ ██║ ╚███╔╝ █████╗ ██║ ██║
████████╗██║ ██║██║ ██║ ██╔██╗ ██╔══╝ ██║ ██║
╚██╔═██╔╝██████╔╝╚██████╔╝██╔╝ ██╗███████╗██████╔╝
╚═╝ ╚═╝ ╚═════╝ ╚═════╝ ╚═╝ ╚═╝╚══════╝╚═════╝
█║▌│║█║▌ WITH COMMANDLINE-KUNGFU POWER █║▌│║█║▌
░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░
Feedback
Was this page helpful?
Glad to hear it! Please tell us how we can improve.
Sorry to hear that. Please tell us how we can improve.