Skip to content

Instantly share code, notes, and snippets.

@radare
radare / foo.v
Last active May 8, 2020 10:52
vxml
struct Toxml {
mut:
str string
stack []string
}
fn toxml_new() &Toxml {
x := &Toxml{}
x.str = ''
@radare
radare / assnam.py
Created October 23, 2019 09:57
radare2 script to autoname functions by taking it from the assert calls
#!/usr/bin/env python3
import r2pipe
r2 = r2pipe.open()
a = r2.cmd('ii~__assert_rtn[1]').strip()
if not a:
print('[assnam] Cannot find assert_rtn import')
exit(1)
if int(r2.cmd('aflc')) == 0:
@radare
radare / rsoc2019.md
Created April 2, 2019 16:17
Radare Summer of Code 2019 Selection Results

Radare2 Summer of Code 2019 Selection Results

As you might remember radare2 organization was a part of Google Summer of Code for many years already. Sadly this year we weren't selected for participation, thus decided to open our own Radare2 Summer of Code season one more time (we did a few time already too). We want to thank NowSecure and KeenLab of Tencent one more time for helping us to make it happen.

The rules and requirements for the RSoC'19 were very similar to GSoC one, with a slightly shifted schedule, so people would give RSoC selection results before the GSoC deadline, to be able apply to GSoC in case of RSoC rejection. Back to the business, this year we accepted two students:

@radare
radare / gist:3a798ce5f34a11dd6320c372248769a5
Created October 8, 2018 16:04
zig hello world - dead code
╭────────────────────╮ ╭────────────────────╮ ╭────────────────────╮ ╭────────────────────╮
│ entry0 │ │ sym.___muloti4 │ │ sym.___umoddi3 │ │ sym.___umodti3 │
╰────────────────────╯ ╰────────────────────╯ ╰────────────────────╯ ╰────────────────────╯
t t t t t
│ │ │ │ │
│ │ ╰────────╮ │ │
│ ╭────────────╯ │ │ │
│ │ │
[ 16%] Built target embedded_lld_lib
[ 63%] Built target embedded_softfloat
[ 69%] Built target embedded_lld_coff
[ 70%] Built target embedded_lld_mingw
[ 86%] Built target embedded_lld_elf
[ 90%] Built target embedded_lld_wasm
[ 91%] Built target zig_cpp
[ 92%] Linking CXX executable zig
Undefined symbols for architecture x86_64:
"_LLVMABIAlignmentOfType", referenced from:
[pancake@koega radare2]$ r2 /bin/ls
-- Set 'e bin.dbginfo=true' to load debug information at startup.
[0x000050b0]> #!python
*** Error in `r2': malloc(): memory corruption: 0x00005591fd72aae0 ***
======= Backtrace: =========
/usr/lib/libc.so.6(+0x704fb)[0x7fb3dd8ca4fb]
/usr/lib/libc.so.6(+0x76976)[0x7fb3dd8d0976]
/usr/lib/libc.so.6(+0x78949)[0x7fb3dd8d2949]
/usr/lib/libc.so.6(__libc_calloc+0x27b)[0x7fb3dd8d506b]
/usr/lib/python2.7/lib-dynload/_hashlib.so(init_hashlib+0x27d)[0x7fb3d8cf1f3d]
@radare
radare / test-afl.js
Created February 5, 2017 01:15
radare2 + nodejs function list (1m15s on ntdll.dll)
const r2pipe = require("r2pipe");
r2pipe.open('Downloads/ntdll/ntdll.dll', (err, r2) => {
r2.cmd('aa', (err) => {
r2.cmdj('aflj', (err, res) => {
let total = res.length;
for(let f of res) {
r2.cmdj('pdrj @ ' + f.name, (err, res) => {
if (--total < 1) {
r2.quit();
@radare
radare / Dockerfile
Created June 23, 2016 10:14
Dockerfile for Toxic 0.7
FROM ubuntu
RUN apt-get update
RUN apt-get upgrade -y
RUN apt-get install -y wget apt-transport-https
RUN echo deb https://pkg.tox.chat/debian nightly stretch | tee /etc/apt/sources.list.d/tox.list
RUN wget -qO - https://pkg.tox.chat/debian/pkg.gpg.key | apt-key add -
RUN apt-get update
RUN apt-get install -y toxic
@radare
radare / noman
Created June 15, 2016 20:49
NodeJS man-like tool for module's README
#!/bin/sh
PATH="$(npm bin):$PATH"
for a in readme ansimd ; do
type $a > /dev/null || npm install $a
done
readme "$1" | ansimd /dev/stdin | less -R
1) spawning is slow, so spawning for each symbol is killing the process
2) you can quickly detect which symbols are mangled by just checking the first 2 chars of the symbol, this reduces the time A LOT
3) swift-demangle can be used to demangle more than one symbol at the time
4) swift is opensource, there's no need to spawn anything
5) the swift demangling apis are accessible (not in last release, but yes in git)
6) there's a swift reimplemenation of the c++ one, just google for it
7) i wrote my own demangler in C (totally incomplete, but enough for most needs)
8) spawning is a process that can be done in paralel. but that's something only Node developers know (ssssh!)
9) python is slow
10) opening any real application with this script will kill your machine