Skip to content

Instantly share code, notes, and snippets.

Avatar

Mihai Tomescu matomesc

View GitHub Profile
View Exploiting Lua 5.1 on 32-bit Windows.md

Exploiting Lua 5.1 on 32-bit Windows

The following Lua program generates a Lua bytecode program called ignore-unsigned-sga.fnt, which in turn loads a DLL from within an extremely locked down Lua 5.1 sandbox in a program called RelicCOH2.exe. The remainder of this document attempts to explain how this program works by a whirlwind tour of relevent bits of the Lua 5.1 virtual machine.

if string.dump(function()end):sub(1, 12) ~= "\27Lua\81\0\1\4\4\4\8\0" then
  error("This generator requires a 32-bit version of Lua 5.1")
end

local function outer()
  local magic -- In bytecode, the stack slot corresponding to this local is changed
View ubuntu-configure-sendmail-with-gmail
#!/bin/bash
HOST=$(hostname)
function install_postfix() {
echo | sudo debconf-set-selections <<__EOF
postfix postfix/root_address string
postfix postfix/rfc1035_violation boolean false
postfix postfix/mydomain_warning boolean
postfix postfix/mynetworks string 127.0.0.0/8 [::ffff:127.0.0.0]/104 [::1]/128
@matomesc
matomesc / redis.markdown
Created Jan 12, 2012 — forked from bdotdub/redis.markdown
Running redis using upstart on Ubuntu
View redis.markdown

Running redis using upstart on Ubuntu

I've been trying to understand how to setup systems from the ground up on Ubuntu. I just installed redis onto the box and here's how I did it and some things to look out for.

To install:

@matomesc
matomesc / ipc.js
Created Mar 3, 2012
why does child memory keep growing?
View ipc.js
var cp = require('child_process');
if (!process.send) {
// master
var child = cp.fork('./test.js');
child.on('message', function (msg) {
process.stdout.write(msg);
});
} else {
// child
View mongodb_inserts.js
var mongodb = require('mongodb');
var server = new mongodb.Server('127.0.0.1', 27017, { auto_reconnect: false });
var db = new mongodb.Db('tester', server, { native_parser: true });
var insertCount = 0;
db.open(ready);
function ready(err, db) {
process.nextTick(function () {
db.collection('statuses', function (err, coll) {
View tree_traversal.js
// depth first in-order
function traverse(node) {
console.log(node.value);
node.children.forEach(function (child) {
traverse(child);
});
}
View .gitconfig
[user]
name = Mihai Tomescu
email = matomesc@gmail.com
[core]
excludesfile = ~/.gitignore
[alias]
st = status
ci = commit
@matomesc
matomesc / buckets.py
Created Aug 8, 2013
Buckets items by timestamp and counts the items in each bucket
View buckets.py
class Buckets(object):
"""
Buckets items by timestamp and counts the items in each bucket.
"""
def __init__(self, since, interval=300):
"""
:param since: Starting timestamp in seconds.
:type since: int
:param interval: The bucket size in seconds.
@matomesc
matomesc / twit_errors.js
Created Aug 8, 2013
Twit doesn't return instances of Error when errors occur
View twit_errors.js
var Twit = require('twit');
var t = new Twit({
consumer_key: 'a',
consumer_secret: 'b',
access_token: 'c',
access_token_secret: 'd'
});
t.get('user/timeline', function (err, result) {
@matomesc
matomesc / gossip_stream.js
Last active Dec 20, 2015
Gossip MessageStream usage
View gossip_stream.js
var stream = hub.sendAll('check-temp');
stream.on('error', function (err) {
// called when there are errors - ex: missing ack / reply timeout
console.log(err);
});
stream.on('ack', function (ackMsg) {
// not sure how useful this is
});