This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env jruby | |
# This code works fine in MRI, but not JRuby. For some strange reason | |
# jruby cannot superclass FFI::MemoryPointer or FFI::Buffer and override | |
# the initialize() method. | |
require 'ffi' | |
class SpecialBuffer < FFI::Buffer | |
def initialize() | |
super(256) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# copy and paste this into IRB... | |
# | |
require 'ffi' | |
class Foo < FFI::Struct | |
layout :ary, [:uint16, 10] | |
end | |
f = Foo.new |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Drop this into msf3 root-dir as 'msf-rex.gemspec'. | |
# | |
# Create gem with: | |
# $ gem build msf-rex.gemspec | |
# | |
# Note there's already a "rex" rubygem, which is why we used 'msf-rex'. | |
# We can still "require 'rex'" though. | |
$: << 'lib' |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <stdio.h> | |
#include <stdint.h> | |
#include <stdlib.h> | |
#include <unistd.h> | |
#include <string.h> | |
#include <fcntl.h> | |
#include <sys/mman.h> | |
#include <sys/stat.h> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <stdio.h> | |
#define ROWS 10 | |
#define COLUMNS 7 | |
// This is a 2-dimensional array. | |
// It makes accessing the values of a | |
// bitmap easy by using x/y references. | |
int grid[ROWS][COLUMNS] = { | |
{0,0,0,0,0,0,0}, // 7 columns across |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <stdio.h> | |
int main() | |
{ | |
// Notice, there are no brackets around the rows this time. | |
// This is a 1-dimensional array. Even though it looks 2d in | |
// the code, it's one long list to the computer. | |
// | |
// Using a 1-dimensional array, we can still treat the data | |
// inside of it as a grid in our code, though. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env ruby | |
# author eric monti ~ nov 20, 2012 | |
# license: DWTFYW | |
require 'rubygems' | |
require 'ffi' | |
class LLVMDisassembler | |
module C | |
extend FFI::Library | |
ffi_lib ['LLVM', 'LLVM-3.2svn', 'LLVM-3.1', 'LLVM-3.0'] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# quick/dirty build a dynamic lib from xpwn - eric monti | |
# WARNING: this was for something really specific -- YMMV... | |
# drop this in your top-level directory where you checked out planetbeing/xpwn and cross your fingers ;) | |
cmake -f CMakeLists.txt | |
make || exit 1 | |
rm -rf ./sharedlib | |
mkdir -p ./sharedlib/lib |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env ruby | |
fname = ARGV.shift | |
fname || exit! | |
sections = `otool -l \"#{fname}\" |grep -A11 ^Section`.split(/^--$/).map do |sect_txt| | |
lines = sect_txt.lines.map(&:chomp) | |
Hash[ lines.map{|ln| ln.strip.split(' ', 2) } ] | |
end.select{|sect| sect["segname"] == "__DATA" and sect["sectname"] =~ /^data_\d+$/ } |
OlderNewer