Skip to content

Instantly share code, notes, and snippets.

View matomesc's full-sized avatar

Mihai Tomescu matomesc

View GitHub Profile
@matomesc
matomesc / ubuntu-configure-sendmail-with-gmail
Created September 28, 2015 06:11 — forked from sshtmc/ubuntu-configure-sendmail-with-gmail
Ubuntu sendmail using smtp.gmail.com
#!/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

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
@matomesc
matomesc / reqparser.py
Created November 13, 2013 04:34
flask-restful NestedRequestParser
from flask import request
from flask.ext.restful.reqparse import Argument, RequestParser
class NestedArgument(Argument):
def __init__(self, name, **kwargs):
pieces = name.split('.')
self.full_name = name
@matomesc
matomesc / gossip_stream.js
Last active December 20, 2015 22:49
Gossip MessageStream usage
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
});
@matomesc
matomesc / twit_errors.js
Created August 8, 2013 23:17
Twit doesn't return instances of Error when errors occur
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 / buckets.py
Created August 8, 2013 19:45
Buckets items by timestamp and counts the items in each bucket
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 / .gitconfig
Created January 17, 2013 02:21
My .gitconfig
[user]
name = Mihai Tomescu
email = matomesc@gmail.com
[core]
excludesfile = ~/.gitignore
[alias]
st = status
ci = commit
@matomesc
matomesc / tree_traversal.js
Created March 18, 2012 01:20
tree traversals
// depth first in-order
function traverse(node) {
console.log(node.value);
node.children.forEach(function (child) {
traverse(child);
});
}
@matomesc
matomesc / mongodb_inserts.js
Created March 5, 2012 05:06
mongodb inserts
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) {
@matomesc
matomesc / ipc.js
Created March 3, 2012 20:20
why does child memory keep growing?
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