Skip to content

Instantly share code, notes, and snippets.

View ulidtko's full-sized avatar
💬
Organically produced code, hand-written no AI, minimal carbon footprint.

Maxim Ivanov ulidtko

💬
Organically produced code, hand-written no AI, minimal carbon footprint.
View GitHub Profile
# Linux udev rule file for Logitech F710 gamepads.
# Written by: Max <[email protected]> in year 2020.
# SPDX-License-Identifier: MIT
#
# ================================================================================
# On the gamepad, put the D ↔ X switch into the right, X position ("XInput Mode")!
# ================================================================================
#
# You can test the gamepad using jstest or jstest-gtk.
# You can test force-feedback (rumble, vibration) using fftest.
@ulidtko
ulidtko / tls_playground.py
Created March 5, 2020 14:14
TLS1.2 RSA-AES key exchange decryption example
#/usr/bin/env python3
"""
An exploration of TLS_RSA_WITH_AES_256_CBC_SHA key exchange in TLS v1.2
-- using https://cryptography.io/
[1]: https://lowleveldesign.org/2016/03/09/manually-decrypting-https-request/
[2]: https://www.acunetix.com/blog/articles/establishing-tls-ssl-connection-part-5/
[RFC5246]: https://tools.ietf.org/html/rfc5246
"""
# -*- coding: utf-8 -*-
import urwid
from urwid import MainLoop, ExitMainLoop
from urwid import Text, Edit, Button
from urwid import Frame, Pile, Padding, Filler, LineBox, Columns, Divider
from urwid import SolidFill, BoxAdapter
LOREM_IPSUM = "Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua."
def on_keypress(key):
@ulidtko
ulidtko / kmod-fridge-cleanup.conf
Created June 30, 2019 12:24
Keep Arch Linux fully functional after kernel updates
# /etc/tmpfiles.d/kmod-fridge-cleanup.conf
#Type Path Mode User Group Age Argument
D! /lib/modules/fridge 0755 root root -
#-- Inspired by #archlinux IRC & this thread:
# https://www.reddit.com/r/archlinux/comments/4zrsc3/keep_your_system_fully_functional_after_a_kernel/
#
#-- ulidtko, June 2019 [File 3/3]
@ulidtko
ulidtko / qnap-qts-fw-cryptor.py
Last active March 21, 2025 05:39
QNAP QTS firmware encryptor/decryptor.
#!/usr/bin/env python3
import os, sys
import argparse
import struct
from functools import reduce
"""
QNAP QTS firmware encryptor/decryptor.
Based on https://pastebin.com/KHbX85nG

Exploiting Lua 5.1 on x86_64

The following Lua program generates a Lua bytecode program called lua-sandbox-rce.luac, which in turn spawns a shell from within Lua 5.1 sandbox. The remainder of this document attempts to explain how this program works by a whirlwind tour of relevent bits of the Lua 5.1 virtual machine.

function outer()
  local magic -- In bytecode, the stack slot corresponding to this local is changed
  local function middle()
    local co, upval
    local ub1 = {[0] = -- Convert uint8_t to char[1]
@ulidtko
ulidtko / aes-z3-excercise.py
Created September 5, 2017 14:26
aes128 cbc/ctr static IV attack with z3
from z3 import *
from binascii import unhexlify, hexlify
from itertools import chain
"""
Up for an excercise huh?
https://www.reddit.com/r/crypto/comments/y7c3m/key_recovery_on_aes_ctr_with_static_iv/
> The trivial version of this attack can be done when you that ciphertext_0 is the encryption of known plaintext plaintext_0. Then, to decrypt ciphertext_n you take ciphertext_n xor ciphertext_0 which equals plaintext_n xor plaintext_0. Since you know plaintext_0 already, you can compute (plaintext_n xor plaintext_0) xor plaintext_0 which cancels out the plaintext_0s leaving you with plaintext_n.
@ulidtko
ulidtko / traverse.hs
Created April 26, 2016 12:24
Imperative tree traversal sample
{-# LANGUAGE DeriveFunctor, DeriveFoldable, DeriveTraversable #-}
{-# LANGUAGE ScopedTypeVariables #-}
import Control.Applicative
import Data.Foldable
import Data.Traversable
import Data.IORef
data BinTree a = Leaf a | Node (BinTree a) (BinTree a)
deriving (Functor, Foldable, Traversable, Show)
@ulidtko
ulidtko / transdeps.hs
Last active October 28, 2019 17:33
Yum dependency walker script
{-# LANGUAGE ViewPatterns, LambdaCase, FlexibleContexts #-}
module Main where
import Control.Applicative
import System.Environment
import System.Exit
import System.IO
import System.Process
import Data.List (nub, sort)