Skip to content

Instantly share code, notes, and snippets.

View JimDennis's full-sized avatar

Jim Dennis JimDennis

View GitHub Profile
def easy_input (prompt, defaultValue=None):
'''Doc string: idiomatically read input with optional default value:
'''
prompt = '%s%s: ' % (prompt, ('[%s]' % defaultValue) if defaultValue is not None else '')
var = raw_input(prompt)
if not var:
var = defaultValue
return var
#!/usr/bin/env python
'''Act as a simple relay from a FIFO logging target (or regular file)
Into another file and the local UNIX syslog service
Call with the name of a file to write to (new log file) and the name of a FIFO
or regular file to relay from.
'''
if __name__ == '__main__':
import sys, time, syslog
@JimDennis
JimDennis / xj.py
Last active August 29, 2015 14:08
#!/usr/bin/env python
from __future__ import print_function
import json, sys
usage = \
'''Extract data from JSON structures using compact "paths" of keys/indexes
%s file [path [path ...]]
Given a JSON file and a list of paths (. seperate list of keys) return the
# From: http://nodetuts.com/01-node_intro.html
var http = require('http');
var server = http.createServer();
function handleReq(req, res) {
res.writeHead(200, {'content-type':'text/plain'});
res.write('Hello, Node.JS');
res.end();
};
server.on('requst', handleReq);
http://jivings.github.io/2011/08/31/upgrading-ubuntu-from-jaunty-9-04-to-lucid-10-04/
Another possibility: http://serverfault.com/a/461090/16830
foo = 1
def bar():
global foo
print foo
foo = 2
print foo
bar()
print foo
@JimDennis
JimDennis / reversh
Created September 4, 2016 02:03
SSH Reverse shell with handling for killing "stale" instances and restarting tunnels if they die or get killed
#!/usr/bin/bash
# Start ssh reverse shell tunnel; but also poll and restart as necessary
# checks for previously running tunnel and kills it if found
# Enhancement to: http://www.thegeekstuff.com/2013/11/reverse-ssh-tunnel/
STALEPID=$(ps faxwww | grep '[7]000:localhost:22' | cut -d' ' -f1)
[ -n "$STALEPID" ] && {
echo 'Killing previous (stale?) tunnel' >&2
kill "$STALEPID"
kill -0 "$STALEPID" && kill -9 "$STALEPID"
@JimDennis
JimDennis / JMalert.md
Last active September 11, 2016 23:24 — forked from chris-belcher/JMalert.md
JoinMarket's privacy is degraded until further notice

JoinMarket's privacy is degraded (for a while)

09/06/2016

Summary

JoinMarket is a young project, there are some possible vulnerabilities which could be exploited to spy on every user.

Recently people have noticed that one such attack seems to actually be happening. The attack has the possibility of degrading the privacy of all JoinMarket coinjoins.

#!/usr/local/bin/python3
from __future__ import print_function
import hashlib, sys
def compute_checksum(filehandle):
results = hashlib.md5()
while True:
data = filehandle.read(1024*1024) # one mega at a time
if len(data) == 0:
break
@JimDennis
JimDennis / bignums.js
Last active July 9, 2017 07:51 — forked from anonymous/bignums.ps
Sample JS Code for bigNums Exercise
/*
7. Iterate over the "bigNums" array.
If any number is less than 10, replace it with "x".
Return "bigNums"
HINT: You will need to "loop" over the array and check "if" the numbers are "less than" 10
Answer: This function should return ["x", 12, "x", 56, 19, "x", "x", "x", 14, 10, "x"]
*/
let bigNums = [3, 12, 7, 56, 19, 9, 1, 5, 14, 10, 2];