Skip to content

Instantly share code, notes, and snippets.

View aquynh's full-sized avatar

Nguyen Anh Quynh aquynh

View GitHub Profile
```
<put all your code here>
```
/* Keystone Assembler Engine (www.keystone-engine.org) */
/* By Nguyen Anh Quynh <[email protected]>, 2016 */
#ifndef KEYSTONE_ENGINE_H
#define KEYSTONE_ENGINE_H
#ifdef __cplusplus
extern "C" {
#endif
#!/usr/bin/python
from keystone import *
def test_ks(arch, mode, code, syntax=0):
ks = Ks(arch, mode)
if syntax != 0:
ks.syntax = syntax
encoding, count = ks.asm(code)
// Sample code for Keystone Assembler Engine (www.keystone-enigne.org).
// By Nguyen Anh Quynh, 2016
#include <stdio.h>
#include <string.h>
#include <keystone/keystone.h>
static int test_ks(ks_arch arch, int mode, const char *assembly, int syntax)
{
ks_engine *ks;
@aquynh
aquynh / armemu.py
Created June 27, 2016 09:40 — forked from mattypiper/armemu.py
ARM Assembly, Emulation, Disassembly using Keystone, Unicorn, and Capstone
#!/usr/bin/python
import sys
from keystone import *
from unicorn import *
from unicorn.arm_const import *
from capstone import *
from capstone.arm import *
from capstone.x86 import *
from keystone import *
from capstone import *
from unicorn import *
from unicorn.x86_const import *
from struct import *
from termcolor import *
import os
import sys
'''
Still remembers the Catwestern problem in the last Defcon CTF?
https://github.com/smokeleeteveryday/CTF_WRITEUPS/tree/master/2015/DEFCONCTF/coding/catwestern
In the writeup above, they complained about missing x86-64 emulator.
We solved this problem with Unicorn framework in this simple code.
'''
from unicorn import *
$ sudo pip install "https://github.com/unicorn-engine/unicorn/archive/master.zip#egg=unicorn&subdirectory=bindings/python"
@aquynh
aquynh / pip-install-capstone-next.sh
Created November 5, 2016 04:12
Install Core + Python binding of Capstone's next branch
sudo pip install "https://github.com/aquynh/capstone/archive/next.zip#egg=capstone&subdirectory=bindings/python"
@aquynh
aquynh / cover_re.py
Created March 7, 2017 05:45 — forked from John-K/cover_re.py
Reverse Engineering a Book Cover
#!/bin/env python2
# -*- coding: utf-8 -*-
# Solution to Book Cover Crackme from "Praktyczna inżynieria wstecznia
# Edited by Gynvael Coldwind and Mateusz Jurczyk. (Applied Reverse Engineering)
# PWN Bookstore: https://ksiegarnia.pwn.pl/Praktyczna-inzynieria-wsteczna,622427233,p.html
#
# Props to @radekk for his excellent writeup and for capturing the flag. Read his
# writeup at https://vulnsec.com/2017/reverse-engineering-a-book-cover/
#
# This was a fun opportunity to learn how to use Unicorn Engine, Capstone Engine,