Skip to content

Instantly share code, notes, and snippets.

@gcmurphy
gcmurphy / topkeks.py
Last active August 1, 2016 19:11
Run gas over the top Go repositories in Github
import os
import requests
import subprocess
import tempfile
def _top_repositories(url=None):
if not url:
url = "https://api.github.com/search/repositories?q=language:go&sort=stars&order=desc"
r = requests.get(url)
results = r.json()
@gcmurphy
gcmurphy / ramdisk.c
Created February 23, 2016 18:40
Create tmpfs mountpoint in c.
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
#include <limits.h>
#include <sys/mount.h>
char *
ramdisk(const char *ns, const char *sz)
{
# Example using libnacl based encryption engine
(venv)[gm@localhost libnacl]$ python demo.py
username = fred, password = secret
username = mary, password = secret
(venv)[gm@localhost libnacl]$ sqlite3 /tmp/demo.db 'select * from user;'
1|fred|b2997d0bf6634b6472881f7c40dab2f5e880f03fdeca340aea977500441479ed04637fae0d5f49bd0c9ab4bdcd9a
2|mary|abb99fe819e861b105eae670741360cf3a51e414a0670d87e20432166bafa859d4733092c14a602fb76f58264fb6
(venv)[gm@localhost libnacl]$ pip freeze
You are using pip version 6.0.8, however version 8.0.2 is available.
#define _GNU_SOURCE
#include <stddef.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <sys/types.h>
#include <keyutils.h>
void vulnerable(const char *key){
FILE *f = fopen("/proc/keys", "rb");
@gcmurphy
gcmurphy / cve_2016_0728.c
Last active September 18, 2018 06:57 — forked from PerceptionPointTeam/cve_2016_0728.c
cve_2016_0728 exploit
/* $ gcc cve_2016_0728.c -o cve_2016_0728 -lkeyutils -Wall */
/* $ ./cve_2016_072 PP_KEY */
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <sys/types.h>
#include <keyutils.h>
#include <unistd.h>
#include <time.h>
@gcmurphy
gcmurphy / search.py
Created January 11, 2016 17:27
Find world writable configuation files, or world readable containing passwords.
import re
import sys
import os
import stat
def search(directory):
pattern = re.compile("(?i)pass|secret|key")
for rootdir, subdirs, files in os.walk(directory):
for filename in files:
path = os.path.join(rootdir, filename)
@gcmurphy
gcmurphy / download_dependencies.py
Created November 18, 2015 23:59
Download all potential satisfying dependencies as per a requirements.txt file.
import distlib
import distlib.index
import distlib.version
import requests
import pip.req
import pip.download
import os
import sys
import urlparse
@gcmurphy
gcmurphy / caps.c
Last active October 29, 2015 23:19
#include <stdio.h>
#include <sys/capability.h>
int main(){
char *txt = NULL;
cap_t caps = cap_get_proc();
txt = cap_to_text(caps, NULL);
printf("caps = %s\n", txt);
if (caps) cap_free(caps);
#!/usr/bin/env python
# -*- coding: utf-8 -*-
import sys
import paramiko
import itertools
import multiprocessing
to_csv = lambda x: ', '.join(x)
allowed = lambda x: x == 'publickey'
@gcmurphy
gcmurphy / devops.sh
Last active August 29, 2015 14:25
ghetto devops
#!/bin/bash
for IP in `cat servers.txt`; do ssh $USER@$IP 'bash -s' < $@; done