Skip to content

Instantly share code, notes, and snippets.

View totu's full-sized avatar
🐍
I may be slow to respond.

Topi 'top1' Tuulensuu totu

🐍
I may be slow to respond.
View GitHub Profile
sudo modprobe v4l2loopback card_label="GoPro" video_nr=1
ip -4 --oneline link | grep -v "DOWN\|LOOPBACK\|NO-CARRIER" | cut -f2 -d: | tail -1 | xargs ip -4 addr show dev | grep -Po '(?<=inet )[\d.]+'
curl 172.23.146.51/gp/gpWebcam/START
fmpeg -nostdin -threads 1 -i 'udp://@0.0.0.0:8554?overrun_nonfatal=1&fifo_size=50000000' -f:v mpegts -fflags nobuffer -vf format=yuv420p -f v4l2 /dev/video1
#!/usr/bin/env python3
import requests
import json
import time
from influxdb import InfluxDBClient
import os
SCRIPT_PATH = os.path.dirname(os.path.realpath(__file__))
if __name__ == "__main__":
API_KEY = None
@totu
totu / hdd-optimizer-supreme.py
Last active April 6, 2017 17:00
hdd-optimizer-supreme
#!/usr/bin/python
# -*- coding: utf-8 -*-
import csv
import sys
def calculate_candidates(hdds):
# Gather candidate drives with enough free space
for hdd in hdds:
candidates = filter(lambda x: x['free'] >= hdd['used'] and x['name'] != hdd['name'], hdds)
candidates = sorted(candidates, key=lambda x: x['free'])
@totu
totu / .js
Created March 20, 2017 19:47
JavaScript torrent loader a.k.a. "The Harvester"
#!/usr/local/bin/node
const torrent = require('torrent-stream')
const mag = process.argv.slice(2)[0];
const download = function(input, id) {
const dl = torrent(input, {path: '/path/to/plex/folder'})
dl.on('ready', function () {
dl.files.forEach(function (file) {
file.select();
});
@totu
totu / kb_demo.ino
Created January 18, 2017 19:17
Fake keyboard attack demo
#include "DigiKeyboard.h"
void setup() {
DigiKeyboard.sendKeyStroke(0);
DigiKeyboard.sendKeyStroke(KEY_SPACE, MOD_GUI_LEFT);
DigiKeyboard.println("terminal");
DigiKeyboard.delay(50);
DigiKeyboard.println("wget -q http://www.brainyquote.com/link/quotebr.js -O - |grep -o -E '\\\"[A-Z].*\\.' | cowsay -f stegosaurus");
pinMode(1, OUTPUT);
}
import crypt
import hmac
def dictionaryAttack(wordlist, hash):
passwords = open(wordlist, encoding='utf-8')
for password in passwords:
if hmac.compare_digest(crypt.crypt(password, hash), hash):
print('%s = %s' % (hash, password))
return
### Keybase proof
I hereby claim:
* I am totu on github.
* I am totu (https://keybase.io/totu) on keybase.
* I have a public key whose fingerprint is 3696 DE03 8297 76D9 34D1 9F2F 6594 CCB9 B07A 750F
To claim this, I am signing this object:
sudo tshark -q -S -l -i mon0 -R 'wlan.fc.type_subtype eq 4' -T fields -e wlan.sa -e wlan_mgt.ssid -e radiotap.dbm_antsignal -e frame.time -E separator=,
@totu
totu / parse2.rb
Last active December 17, 2015 15:09
require 'open-uri'
r = '', a = []
uri = URI.parse("http://data.fmi.fi/fmi-apikey/cdc84a28-60b7-44c3-ad5d-442d34edc435/wfs?request=getFeature&storedquery_id=fmi::observations::weather::daily::multipointcoverage&place=riihimaki&starttime=2013-05-10");
uri.open do |http|
r = http.read.inspect
end
days = /<gmlcov:positions>+.+<\/gmlcov:positions>/.match(r)[0].gsub(/<\/?[^>]*>/, '').split(' ').length/3
@totu
totu / census2db.js
Last active December 16, 2015 06:19
MongoDB exercise. Transfer all data from US census of last names to a database.
var fs = require('fs')
, mongojs = require('mongojs')
, db = mongojs('census', ['things'])
, file = 'census.txt';
if (process.argv[2]) file = process.argv[2];
fs.readFile(file, function (err, d) {
if (err) throw err;
db.things.find().count(function(err, startCount) {