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 /
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:
var http = require('http');
var server = http.createServer();
function handleReq(req, res) {
res.writeHead(200, {'content-type':'text/plain'});
res.write('Hello, Node.JS');
server.on('requst', handleReq);
Another possibility:
foo = 1
def bar():
global foo
print foo
foo = 2
print foo
print foo
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
# Start ssh reverse shell tunnel; but also poll and restart as necessary
# checks for previously running tunnel and kills it if found
# Enhancement to:
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 /
Last active September 11, 2016 23:24 — forked from chris-belcher/
JoinMarket's privacy is degraded until further notice

JoinMarket's privacy is degraded (for a while)



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.

from __future__ import print_function
import hashlib, sys
def compute_checksum(filehandle):
results = hashlib.md5()
while True:
data =*1024) # one mega at a time
if len(data) == 0:
JimDennis / bignums.js
Last active July 9, 2017 07:51 — forked from anonymous/
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];