Skip to content

Instantly share code, notes, and snippets.

@gcmurphy
gcmurphy / altchainfail.c
Created July 10, 2015 04:11
altchainfail.c
// original source - http://sourceforge.net/projects/mancha/files/sec/altchainfail.c/download
/*
* alt.chain.fail
* stand-alone vulnerability tester for: CVE-2015-1793
* by: mancha (@mancha140)
*
* based on test written by Matt Caswell for the OpenSSL project.
*
* gcc -o altchainfail altchainfail.c -lcrypto
@gcmurphy
gcmurphy / bcrypt_nullbyte.py
Created March 13, 2015 13:56
Example where things can go wrong using bcrypt in python..
# demo of what people 'may' do..
import bcrypt
from hashlib import sha1
salt = bcrypt.gensalt()
def hash_password(password):
# as per article various mechanisms may be employed
# to truncate the passwords length to 72 chars
return bcrypt.hashpw(sha1(password).digest(), salt)
@gcmurphy
gcmurphy / wtft.c
Created March 12, 2015 19:20
WTF time is it in UTC
#include <stdio.h>
#include <stdlib.h>
#include <time.h>
#include <memory.h>
void display_current_time(const char *name, short tz){
time_t t;
struct tm *tdata;
time(&t);
@gcmurphy
gcmurphy / find_crypto.sh
Created February 10, 2015 22:41
Find python crypto usage in openstack
#!/bin/bash
search(){
echo ""
echo "Searching for $1 usage.."
echo ""
grep -nr --include \*.py --exclude test\*.py \
--exclude \*_test\*.py\
--exclude \*tempest\*\
--exclude \*site-packages\* \
-E $2 *
@gcmurphy
gcmurphy / ghost.go
Last active August 29, 2015 14:14
detect ghost vulnerability in statically linked binaries..
package main
import (
"bytes"
"debug/elf"
"fmt"
"os"
)
func staticallyLinked(file *elf.File) bool {
@gcmurphy
gcmurphy / poodle.c
Created October 15, 2014 02:51
Unnecessary C program to test if SSLv3 is enabled..
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <string.h>
#include <sys/types.h>
#include <sys/socket.h>
#include <netinet/in.h>
#include <netdb.h>
char SSLv3_ClientHello[] = {
@gcmurphy
gcmurphy / HW02.hs
Last active August 29, 2015 14:07
CS194 Homework week 2 (most of it)
module HW02 where
import Words
import Data.List
-- Though a Scrabble hand is the same Haskell type as a Scrabble word, they
-- have different properties. Specifically, a hand is unordered whereas a word
-- is ordered. We denote this distinction by using a type synonym to talk
-- about hands, even though we could just say `String`.
@gcmurphy
gcmurphy / HW01.2.hs
Created September 22, 2014 00:38
CS194 Homework 2 - Towers of Hanoi
module Main where
type Peg = String
type Move = (Peg, Peg)
{-
| Towers of hanoi solution
>>> hanoi 2 "a" "b" "c"
[("a","c"),("a","b"),("c","b")]
move n-1 disc from a to c using b as temporary storage
@gcmurphy
gcmurphy / HW01.1.hs
Last active August 29, 2015 14:06
CS194 Homework 1 - Credit card verification
-- http://www.seas.upenn.edu/~cis194/hw/01-intro.pdf
module Main where
-- | Return the last digit of an integer
--
-- >>> lastDigit 123
-- 3
--
-- >>> lastDigit 0
-- 0
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <stdint.h>
#include <stdbool.h>
#include <assert.h>
bool constant_time_compare(const char *lhs, size_t lhs_sz, const char *rhs, size_t rhs_sz)
{
size_t i;