Skip to content

Instantly share code, notes, and snippets.

@mrschyte
mrschyte / lastresort.md
Last active September 9, 2016 11:59
LastResort

LastResort

What to do?

Cost: 0%

LastResort is part of the Warmup - PlanB - LastResort trilogy and it's conceptually similar to the previous challenges. At the beginning of the challenge we are provided with the firmware and the assembly

@mrschyte
mrschyte / dircolors
Created September 19, 2016 08:57
solarized-dark dircolors
# Dark 256 color solarized theme for the color GNU ls utility.
# Used and tested with dircolors (GNU coreutils) 8.5
#
# @author {@link http://sebastian.tramp.name Sebastian Tramp}
# @license http://sam.zoy.org/wtfpl/ Do What The Fuck You Want To Public License (WTFPL)
#
# More Information at
# https://github.com/seebi/dircolors-solarized
@mrschyte
mrschyte / censys.py
Created October 3, 2017 15:06
Grab censys.io data
import requests
import pprint
API_BASE = 'https://www.censys.io/api/v1/{}'
API_AUTH = ('API_ID', 'SECRET')
def call(base, query):
results = []
page_id = 1
<!doctype html>
<html lang="en">
<head>
<title>cyberlympics</title>
<meta name="generator" content="Etherpad">
<meta name="author" content="Etherpad">
<meta name="changedby" content="Etherpad">
<meta charset="utf-8">
<style>
* {
@mrschyte
mrschyte / fixperm.py
Created November 12, 2017 08:29
Fix python permissions
import sys
import os, stat
import fileinput
def fixperm(path):
mode = os.stat(path)[stat.ST_MODE]
perm = mode & stat.S_IRWXU & (~stat.S_IWUSR)
mode |= mode & (~stat.S_IRWXG) | (perm >> 3)
mode |= mode & (~stat.S_IRWXO) | (perm >> 6)
print(oct(mode), path)
@mrschyte
mrschyte / FisherYates.java
Last active March 31, 2022 12:39
Fisher-Yates Shuffle (Java)
import java.util.Random;
import java.util.Arrays;
class FisherYates {
public static <T> void shuffle(Random random, T[] array) {
shufflePartial(random, array, 1.0f);
}
public static <T> void shufflePartial(Random random, T[] array, double fudge) {
assert(fudge >= 0.0f && fudge <= 1.0f);
@mrschyte
mrschyte / fwf.py
Created June 5, 2018 11:37
Fixed-width parser
import subprocess
import functools
import itertools
import pprint
def transpose(table, fillvalue=None):
return itertools.zip_longest(*table, fillvalue=fillvalue)
def fwf_format(table):
widths = [max([len(row) for row in col])
@mrschyte
mrschyte / nth.tex
Last active February 24, 2024 15:12
LaTeX get nth element.
\documentclass{standalone}
\usepackage{pgf,pgffor}
\newcommand{\nth}[2]{
\foreach \x [count=\k] in #1 {
\ifnum\k=#2
\x
\fi
}
}
@mrschyte
mrschyte / controller.py
Created June 13, 2018 21:58
Impossibru Curves
from pykeyboard import PyKeyboard
from inputs import get_gamepad
import time, math
import threading
kbd = PyKeyboard()
tmax = 0.1
tmin = 0.02
curr = 0
@mrschyte
mrschyte / wait-online.py
Last active August 27, 2018 08:28
Replacement wait-online script
#!/usr/bin/python
from subprocess import check_output
from time import sleep
import click, sys
def is_interface_up(iface):
try:
return b'state DOWN' not in check_output(["/usr/bin/ip", "link", "show", "dev", iface]) and \
b'inet' in check_output(["/usr/bin/ip", "addr", "show", "dev", iface])