Skip to content

Instantly share code, notes, and snippets.

Avatar

Jim Dennis JimDennis

View GitHub Profile
View easy_input.py
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
View relogger.py
#!/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
View xj.py
#!/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
View hello.js
# 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);
View jaunty2lucid
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
View Global keyword
foo = 1
def bar():
global foo
print foo
foo = 2
print foo
bar()
print foo
@JimDennis
JimDennis / reversh
Created Sep 4, 2016
SSH Reverse shell with handling for killing "stale" instances and restarting tunnels if they die or get killed
View reversh
#!/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 Sep 11, 2016 — forked from chris-belcher/JMalert.md
JoinMarket's privacy is degraded until further notice
View JMalert.md

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.

View md5sum.py
#!/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 Jul 9, 2017 — forked from anonymous/bignums.ps
Sample JS Code for bigNums Exercise
View bignums.js
/*
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];