Skip to content

Instantly share code, notes, and snippets.

@deeso
deeso / gist:8085000
Created December 22, 2013 16:30
Example of using r2 ob command
# r2 malloc://1024
[0x00000000]> wx cafebabe00000032003a070002010014546573745661726961626c6553776974636855700700040100106a6176612f6c616e672f4f626a6563740100063c696e69743e010003282956010004436f64650a000300090c0005000601000f4c696e654e756d6265725461626c650100124c6f63616c5661726961626c655461626c65010004746869730100164c546573745661726961626c6553776974636855703b010014546573744d756c7469706c655661726961626c650a001000120700110100116a6176612f6c616e672f496e74656765720c0013001401000776616c75654f660100162849294c6a6176612f6c616e672f496e74656765723b0800160100067472796f6e65090018001a0700190100106a6176612f6c616e672f53797374656d0c001b001c0100036f75740100154c6a6176612f696f2f5072696e7453747265616d3b07001e0100176a6176612f6c616e672f537472696e674275696c646572080020010011417474656d7074696e67207072696e74200a001d00220c00050023010015284c6a6176612f6c616e672f537472696e673b29560a001d00250c00260027010006617070656e6401002d284c6a6176612f6c616e672f537472696e673b294c6a6176612f6c616e672f537472696e674275696c6465723b0a001d00290c002a002b010008746
@deeso
deeso / ik_test_case
Created December 22, 2013 21:57
Test Case for SDB, Note Junk between the ',' in the array,
rax -s cafebabe00000032006107000201000f436173655461626c655377697463680700040100106a6176612f6c616e672f4f626a6563740100063c696e69743e010003282956010004436f64650a000300090c0005000601000f4c696e654e756d6265725461626c650100124c6f63616c5661726961626c655461626c65010004746869730100114c436173655461626c655377697463683b010001610100152849294c6a6176612f6c616e672f537472696e673b09001100130700120100106a6176612f6c616e672f53797374656d0c001400150100036f75740100154c6a6176612f696f2f5072696e7453747265616d3b0700170100176a6176612f6c616e672f537472696e674275696c64657208001901000956616c7565206973200a0016001b0c0005001c010015284c6a6176612f6c616e672f537472696e673b29560a0016001e0c001f0020010006617070656e6401001c2849294c6a6176612f6c616e672f537472696e674275696c6465723b0a001600220c00230024010008746f537472696e6701001428294c6a6176612f6c616e672f537472696e673b0a002600280700270100136a6176612f696f2f5072696e7453747265616d0c0029001c0100077072696e746c6e08002b01001756616c75652069732067726561746572207468616e203507002d0100106a6176612f6c616e672f537472696e6
@deeso
deeso / basic_rcore.py
Last active January 2, 2016 06:19
Radare Python example that loads a bin object using the "zip://" URI. Note the core.file_open first, and then the call to core.bin_load with a None object. This will trigger the bin object to be loaded from the IO layer. The core.cmd0 will execute the commands, 'af' and then 'pdf'. 'af' will analyse the functions, and the 'pdf' will print the di…
def flush(c):
k = c.cons
k.flush()
def exec_(c, cmd):
c.cmd0(cmd)
k = c.cons
k.flush()
from r2.r_core import RCore
@deeso
deeso / rax2 example
Created January 7, 2014 03:33
Radare hex to string example.
~/apps$ rax2 -S < ~/workspace/radare_test_cases/bin/radare_test_cases/basic_arithmetic.class
cafebabe0000003300160700020100227261646172655f746573745f63617365732f62617369635f61726974686d657469630700040100106a6176612f6c616e672f4f626a6563740100063c696e69743e010003282956010004436f64650a000300090c0005000601000f4c696e654e756d6265725461626c650100124c6f63616c5661726961626c655461626c65010004746869730100244c7261646172655f746573745f63617365732f62617369635f61726974686d657469633b010018706572666f726d5f62617369635f61726974686d6574696301000328294901000565696768740100014901000374656e0100017001000a536f7572636546696c6501001562617369635f61726974686d657469632e6a617661002100010003000000000002000100050006000100070000002f00010001000000052ab70008b100000002000a00000006000100000003000b0000000c000100000005000c000d00000008000e000f0001000700000052000200030000000c10083b100a3c1a1b603d1cac00000002000a0000000e00030000000600060007000a0008000b0000002000030003000900100011000000060006001200110001000a000200130011000200010014000000020015
@deeso
deeso / Basic Java Reversing with Radare
Created January 26, 2014 07:39
r2 session demonstrating basic Java analysis features.
r2 malloc://4096
-- duck my sick!
[0x00000000]> e asm.comments=false
[0x00000000]> e asm.cmtflgrefs=false
[0x00000000]> e asm.xrefs=false
[0x00000000]> wx cafebabe00000033001707000201001b7261646172655f746573745f63617365732f6368616c6c656e67650700040100106a6176612f6c616e672f4f626a6563740100063c696e69743e010003282956010004436f64650a000300090c0005000601000f4c696e654e756d6265725461626c650100124c6f63616c5661726961626c655461626c650100047468697301001d4c7261646172655f746573745f63617365732f6368616c6c656e67653b01001573696d706c655f636173655f73746d745f3476616c01000328294901000169010001490100016a0100016b01000d537461636b4d61705461626c6501000a536f7572636546696c6501000e6368616c6c656e67652e6a617661002100010003000000000002000100050006000100070000002f00010001000000052ab70008b100000002000a00000006000100000003000b0000000c000100000005000c000d00000008000e000f00010007000000c10002000300000048033b033ca7003c1a08703d1caa0000000000003200000000000000030000002000000026000000320000002c840202a70011840203a7000b840209a70005033c1a100aa1ffc41bac
@deeso
deeso / r2_walk_fcn_bbs.py
Created February 19, 2014 03:13
Python script that demonstrates loading a Java class file from a string, performing analysis of the class file, and then printing the _init_ function. Finally, this script will print the address and instruction bytes from the basic blocks in the function.
def flush(c):
k = c.cons
k.flush()
def exec_(c, cmd):
c.cmd0(cmd)
k = c.cons
k.flush()
import ctypes
@deeso
deeso / basic_cmtlt_test.r2
Last active August 29, 2015 13:57
This a basic test for deriving a SSA from a Java Function.
wx cafebabe0000003200310700020100167261646172652f53696d706c654c54436f6d706172650700040100106a6176612f6c616e672f4f626a65637401000178010001490100083c636c696e69743e010003282956010004436f6465090001000b0c0005000601000f4c696e654e756d6265725461626c650100124c6f63616c5661726961626c655461626c650100063c696e69743e0a000300100c000e0008010004746869730100184c7261646172652f53696d706c654c54436f6d706172653b01000c73696d706c655f6c74636d7001000528494929490100036c6873010003726873010001750100017001000d537461636b4d61705461626c6501001073696d706c655f6c74636d705f73657401001b73696d706c655f6c74636d705f7365745f6e6f745f73746174696301001773696d706c655f6c74636d705f7365745f7374617469630100046d61696e010016285b4c6a6176612f6c616e672f537472696e673b295609002000220700210100106a6176612f6c616e672f53797374656d0c002300240100036f75740100154c6a6176612f696f2f5072696e7453747265616d3b0a000100260c001300140a0028002a0700290100136a6176612f696f2f5072696e7453747265616d0c002b002c0100077072696e746c6e01000428492956010004617267730100135b4c6a6176612f6c616e672f537472696
@deeso
deeso / Basic R2 Util Call
Created May 25, 2014 03:33
Playing with the rust ffi stuff.
use std::libc::c_int;
use std::io::println;
#[link(name= "r_util")]
extern {
fn r_file_exists(str: &'static str) -> c_int;
}
fn main() {
@deeso
deeso / cmdline.rs
Last active December 13, 2015 16:56
First basic rust program, ever.
extern crate getopts;
use getopts::{optflag,getopts,OptGroup, usage, Matches};
use std::io::{File, Open, Read};
use std::path::Path;
use std::io::{Command};
use std::string::{String};
use std::os;
use std::str;
@deeso
deeso / server.rs
Created June 12, 2014 18:20
this is a basic server written in rust
extern crate getopts;
use getopts::{optflag,getopts,OptGroup, usage, reqopt, optopt};
use std::string::{String};
use std::os;
use std::io::{TcpListener, TcpStream};
use std::io::{Acceptor, Listener};