Skip to content

Instantly share code, notes, and snippets.

@th0rex
th0rex / cross-compile.sh
Created December 8, 2016 14:46
Rust crosscompile windows
cargo rustc --release --target i686-pc-windows-gnu -- -C link-args=-lpthread -C panic=abort
@th0rex
th0rex / main.cpp
Last active April 12, 2017 21:28
linq stuff
#include <algorithm>
#include <experimental/optional>
#include <iostream>
#include <vector>
#include <random>
using std::experimental::make_optional;
using std::experimental::optional;
template <class... F>
data = bv.read(0x8049a80, 0xd6)
last_char = 0x22
string = '"'
for char in data[1::2]:
current = ord(char) ^ last_char
last_char = current
string += chr(current)
print("result: {}".format(string))
@th0rex
th0rex / crack.rs
Last active November 26, 2017 13:20
// Compile with:
// rustc -C opt-level=2 -C debuginfo=2 -o crack crack.rs
// Run with:
// ./crack
fn bit_move(input: u64, from_index: u64, to_index: u64) -> u64 {
let c = (input >> (64 - from_index)) & 1;
c << (64 - to_index)
}
@th0rex
th0rex / mix_columns.cpp
Last active December 13, 2017 18:17
AES
// Compile with: clang++ -std=c++17 -O3 mix_columns.cpp -o mix_columns
// Run with: ./mix_columns
#include <stdint.h>
#include <array>
#include <iomanip>
#include <iostream>
#include <string>
// Compile with: clang++ -std=c++17 -O3 matrix_mul.cpp -o matrix_mul
// Run with: ./matrix_mul
// Produces:
// result: [
// 1, 0, 0, 0,
// 0, 1, 0, 0,
// 0, 0, 1, 0,
// 0, 0, 0, 1,
// ]
use std::fmt;
#[derive(Eq, PartialEq)]
enum Element {
Index(usize),
GCall(Vec<Element>),
}
impl fmt::Display for Element {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
// rustc generate_round_key.rs -o generate_round_key
// ./generate_round_key
#[cfg_attr(rustfmt, rustfmt_skip)]
static S: [u8; 16 * 16] = [
0x63, 0x7c, 0x77, 0x7b, 0xf2, 0x6b, 0x6f, 0xc5, 0x30, 0x01, 0x67, 0x2b, 0xfe, 0xd7, 0xab, 0x76,
0xca, 0x82, 0xc9, 0x7d, 0xfa, 0x59, 0x47, 0xf0, 0xad, 0xd4, 0xa2, 0xaf, 0x9c, 0xa4, 0x72, 0xc0,
0xb7, 0xfd, 0x93, 0x26, 0x36, 0x3f, 0xf7, 0xcc, 0x34, 0xa5, 0xe5, 0xf1, 0x71, 0xd8, 0x31, 0x15,
0x04, 0xc7, 0x23, 0xc3, 0x18, 0x96, 0x05, 0x9a, 0x07, 0x12, 0x80, 0xe2, 0xeb, 0x27, 0xb2, 0x75,
0x09, 0x83, 0x2c, 0x1a, 0x1b, 0x6e, 0x5a, 0xa0, 0x52, 0x3b, 0xd6, 0xb3, 0x29, 0xe3, 0x2f, 0x84,
// rustc aes_decrypt.rs -o aes_decrypt
// ./aes_decrypt
#[cfg_attr(rustfmt, rustfmt_skip)]
static S: [u8; 16 * 16] = [
0x63, 0x7c, 0x77, 0x7b, 0xf2, 0x6b, 0x6f, 0xc5, 0x30, 0x01, 0x67, 0x2b, 0xfe, 0xd7, 0xab, 0x76,
0xca, 0x82, 0xc9, 0x7d, 0xfa, 0x59, 0x47, 0xf0, 0xad, 0xd4, 0xa2, 0xaf, 0x9c, 0xa4, 0x72, 0xc0,
0xb7, 0xfd, 0x93, 0x26, 0x36, 0x3f, 0xf7, 0xcc, 0x34, 0xa5, 0xe5, 0xf1, 0x71, 0xd8, 0x31, 0x15,
0x04, 0xc7, 0x23, 0xc3, 0x18, 0x96, 0x05, 0x9a, 0x07, 0x12, 0x80, 0xe2, 0xeb, 0x27, 0xb2, 0x75,
0x09, 0x83, 0x2c, 0x1a, 0x1b, 0x6e, 0x5a, 0xa0, 0x52, 0x3b, 0xd6, 0xb3, 0x29, 0xe3, 0x2f, 0x84,
% Sprache und Schriftart einstellen
\usepackage[ngerman]{babel}
\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}
\usepackage{helvet}
\renewcommand{\familydefault}{\sfdefault}
% Taken from http://pr0gramm.com/top/latex/2286360 and adapted
\usepackage{minted}