Skip to content

Instantly share code, notes, and snippets.

View mbenedettini's full-sized avatar

Mariano Benedettini mbenedettini

View GitHub Profile
@mbenedettini
mbenedettini / key_generation.py
Created November 30, 2011 15:56
Python implementation of Mifare AES-128 simmetric key diversification, as described in document AN10922
from Crypto.Cipher import AES
from bitstring import BitArray, Bits
(key, m) = (BitArray(hex='00112233445566778899AABBCCDDEEFF'), BitArray(hex='00000000000000000000000000000000'))
const_rb = BitArray(hex='00000000000000000000000000000087')
k0 = BitArray(hex=AES.new(key.bytes).encrypt(m.bytes).encode('hex'))
@mbenedettini
mbenedettini / key_generation.pl
Created December 1, 2011 13:42
Perl implementation of Mifare AES-128 simmetric key diversification, as described in document AN10922
use Crypt::Rijndael;
my $key = pack("H*", "00112233445566778899AABBCCDDEEFF");
my $zero = pack("H*", "00000000000000000000000000000000");
my $const_rb = pack("H*", "00000000000000000000000000000087");
my $bytes_const_rb = unpack("A*", $const_rb);
my $k0 = Crypt::Rijndael->new($key, Crypt::Rijndael::MODE_CBC() )->encrypt($zero);
print "k0: " . unpack("H*", $k0) . "\n";
@mbenedettini
mbenedettini / google-contacts-wiper.py
Created July 1, 2012 21:46
Google contacts wiper
import sys
import getopt
import getpass
import atom
import gdata.contacts.data
import gdata.contacts.client
class ContactsWiper(object):
def __init__(self, email, password):
@mbenedettini
mbenedettini / gist:3228630
Created August 1, 2012 16:44
Patio patch to fix default value detection
--- /home/mariano/work/patio/lib/adapters/mysql.js 2012-07-31 17:14:08.146130970 -0300
+++ ./node_modules/patio/lib/adapters/mysql.js 2012-08-01 13:39:14.631535958 -0300
@@ -809,10 +809,16 @@
ret.autoIncrement = e.match(/auto_increment/i) !== null;
ret.allowNull = allowNull.match(/Yes/i) !== null;
ret.primaryKey = key.match(/PRI/i) !== null;
- ret["default"] = row[m("Default")];
- if (isEmpty(row["default"])) {
- row["default"] = null;
+
@mbenedettini
mbenedettini / gist:5911415
Last active December 19, 2015 06:29
Simple /etc/stunnel/stunnel.conf
; Certificate/key is needed in server mode and optional in client mode
; To generate a self-signed certificate run:
; openssl req -new -x509 -days 365 -nodes -config /usr/share/doc/stunnel4/examples/stunnel.cnf -out stunnel.pem -keyout stunnel.pem
cert = /etc/stunnel/ssl/stunnel.pem
; Protocol version (all, SSLv2, SSLv3, TLSv1)
sslVersion = SSLv3
; Some security enhancements for UNIX systems - comment them out on Win32
chroot = /var/lib/stunnel4/
@mbenedettini
mbenedettini / app.js
Created May 4, 2014 21:37
TallerJS: server/app.js
'use strict';
var express = require('express');
var http = require('http');
var path = require('path');
var async = require('async');
var hbs = require('express-hbs');
var baucis = require('baucis');
@mbenedettini
mbenedettini / packages.el
Created October 18, 2016 21:53
fill-column-indicator (pre-set to column 80) layer for Spacemacs
;;; packages.el --- column-marker layer packages file for Spacemacs.
;;
;; Copyright (c) 2012-2016 Sylvain Benner & Contributors
;;
;; Author: Mariano Benedettini <[email protected]>
;; URL: https://github.com/syl20bnr/spacemacs
;;
;; This file is not part of GNU Emacs.
;;
;;; License: GPLv3
{
"defaultEnv": {"ENV": "NODE_ENV"},
"development": {
"driver": "pg",
"user": {
"ENV": "DB_USERNAME"
},
"password": {
"ENV": "DB_PASSWORD"
},
const loopback = require('loopback');
const boot = require('loopback-boot');
const logger = require('logger');
const app = loopback();
// This module resides in /lib so we should boot project from ../server
boot(app, __dirname + '/../server');
logger.debug('Loopback initialized');
'use strict';
const clc = require('cli-color');
module.exports = require('tracer').console({
filters: {
log: clc.black.bgWhite,
trace: clc.magenta,
debug: clc.cyan,
info: clc.green,