Skip to content

Instantly share code, notes, and snippets.

@olivierlemoal
olivierlemoal / p12_to_pem.sh
Created May 21, 2015 13:22
Convert p12 to PEM format
# Extract private key
openssl pkcs12 -nocerts -nodes -in cert.p12 -out cert.key
# Extract public key
openssl pkcs12 -nokeys -in cert.p12 -out cert.crt
@olivierlemoal
olivierlemoal / openssl_check.sh
Last active August 29, 2015 14:21
OpenSSL check
# Check certificate
openssl x509 -in certif.pem -text -noout
# Check CSR
openssl req -text -noout -verify -in CSR.csr
# Check private key
openssl rsa -in privateKey.key -check -noout
# Check CRL (often in DER format)
openssl crl -inform DER -text -noout -in mycrl.crl
@olivierlemoal
olivierlemoal / gen_n_sign.sh
Last active April 9, 2020 12:32
Gen and sign key with CA
# Generate root CA
# without password
openssl genpkey -algorithm RSA -pkeyopt rsa_keygen_bits:4096 -out cakey.pem
# with password
openssl genpkey -algorithm RSA -pkeyopt rsa_keygen_bits:4096 -out cakey.pem -aes-128-cbc
openssl req -x509 -new -nodes -key cakey.pem -sha256 -days 1825 -out cacert.pem
# Generate server crypto material
# Generate server private key
openssl genpkey -algorithm RSA -pkeyopt rsa_keygen_bits:4096 -out server.key
cowmail () { cowsay | aha --black | mail -a "Content-type: text/html" -s $1 ${*:2} }
@olivierlemoal
olivierlemoal / .gitconfig
Last active January 11, 2017 14:54
Git global conf
[user]
email = XXX
name = Olivier Le Moal
[push]
default = current
[core]
editor = vim
excludesfile = /home/olivier/.gitignore
[alias]
lg = log --graph --pretty=format:'%Cred%h%Creset -%C(yellow)%d%Creset %s %Cgreen(%cr) %C(bold blue)<%an>%Creset' --abbrev-commit --date=relative
@olivierlemoal
olivierlemoal / vpn_alert.py
Last active August 29, 2015 14:17
VPN Mail alert post connect
#! /usr/bin/env python2
# -*- coding: utf8 -*-
import os
import sys
import logging
import traceback
import smtplib
from email.mime.text import MIMEText
from datetime import tzinfo, timedelta, datetime

Keybase proof

I hereby claim:

  • I am olivierlemoal on github.
  • I am olivierlm (https://keybase.io/olivierlm) on keybase.
  • I have a public key whose fingerprint is FABF AD56 1F5B 777F B8B1 6A07 A5B2 54E5 C81B 7E46

To claim this, I am signing this object:

@olivierlemoal
olivierlemoal / dump_stanza
Last active August 29, 2015 14:15
Dump XMPP packet libstrophe
log_error("XMPP : ");
char* xmpp;
size_t length;
xmpp_stanza_to_text(stanza, &xmpp, &length);
log_error(xmpp);
free(xmpp);
# encoding: utf-8
require "logstash/filters/base"
require "logstash/namespace"
require 'elasticsearch'
# Check the content of a event field against an
# ES index. If the value is found, the target field of the event
# is filled with "malware", else "clean".
class LogStash::Filters::Malware < LogStash::Filters::Base
#! /usr/bin/env python2
# -*- coding: utf-8 -*-
import sys
import urllib2
from elasticsearch import Elasticsearch
class ElasticSearch:
def __init__(self, host, port):