Skip to content

Instantly share code, notes, and snippets.

View unfo's full-sized avatar

Jan Wikholm unfo

View GitHub Profile
@unfo
unfo / editcron.sh
Last active December 25, 2015 01:59
#!/bin/bash
# Safer way to edit cron so you don't mistakenly REMOVE the entire crontab
# with crontab -r when you meant to type crontab -e
# Also provides useful diff of your changes
ts=$(date +%s)
before=/tmp/`whoami`_crontab_before_$ts
after=/tmp/`whoami`_crontab_after_$ts
crontab -l > $before
@unfo
unfo / sumls.sh
Created October 9, 2013 11:39
Simple summation of file sizes
#!/bin/bash
# Example: find /path/ -type f -mtime +5 | xargs ls -l | sumls
awk '{ sum += $5 } END { print "total: " (sum / 1024 / 1024) " MB" } '
@unfo
unfo / df.sh
Created October 9, 2013 11:37
Handle veeeery loooooooong volume names
#!/bin/bash
df -Ph | column -t
var alphabet = {
'0': 'e',
'00':'i',
'000':'s',
'0000':'h',
'00000':5,
'00001':4,
'0001':'v',
'00011':3,
'001':'u',
@unfo
unfo / ls-logger.sh
Created January 23, 2014 07:58
Very naive/simplistic logger to see how incoming file transfers are moving => able to gauge transfer speeds of files and/or total halt of transfers after the fact.
#!/bin/bash
# crontab example:
# 30 20 * * * echo "" > /tmp/bar ; /data/network-debugging/ls-logger.sh
# 30 08 * * * echo 1 > /tmp/bar
INPUT_DIR=/data/foobar/input
DTM="$(date +%Y-%m-%d-%H-%M)"
LOGFILE="/data/network-debugging/ls.log-$DTM"
$ seddiff 's/redcarpet/magiccarpet/;s/pygments/rouge/' _config.yml
Result of s/redcarpet/magiccarpet/;s/pygments/rouge/ against _config.yml:
7,8c7,8
< markdown: magiccarpet
< highlighter: rouge
---
> markdown: redcarpet
> highlighter: pygments
54c54
< - magiccarpet
msf> search foobar
1 post/windows/foobar Blaa blaa desc here
2 post/multi/kek/buufar Another exploit
3 exploit/solaris/mcfoo For solaris
msf> use 1
post/windows/foobar>
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<folders>
<folder>
<title>oscp</title>
<snippets>
<snippet>
<title>spawn tty</title>
<content>python -c 'import pty;pty.spawn("/bin/bash")'</content>
</snippet>
<snippet>
Host *.labs.overthewire.org
SendEnv WECHALLTOKEN
SendEnv WECHALLUSER
import SimpleHTTPServer
import SocketServer
import logging
import cgi
import sys
if len(sys.argv) > 2:
PORT = int(sys.argv[2])