Skip to content

Instantly share code, notes, and snippets.

@mattypiper
mattypiper / filexor.cs
Last active August 29, 2015 13:58
obfuscates a file using 1-byte xor
static void xorFile(string inputFilename, string outputFilename, byte xorValue)
{
const int CHUNK_SIZE = 4096;
using (FileStream inputStream = new FileStream(inputFilename, FileMode.Open, FileAccess.Read))
{
BinaryReader binaryReader = new BinaryReader(inputStream, Encoding.ASCII);
using (FileStream outputStream = new FileStream(outputFilename, FileMode.Create, FileAccess.Write))
{
BinaryWriter binaryWriter = new BinaryWriter(outputStream, Encoding.ASCII);
byte[] chunk = binaryReader.ReadBytes(CHUNK_SIZE);
@mattypiper
mattypiper / filexor.py
Last active August 29, 2015 13:58
obfuscates a file using 1-byte xor
#!/usr/bin/env python
from struct import unpack, pack
import sys
x = ''
with open(sys.argv[1], 'rb') as f:
x = f.read()
with open(sys.argv[2], 'wb') as f:
@mattypiper
mattypiper / cpp_nontype_func_templates.cpp
Last active August 29, 2015 14:16
C++ Non-Type Function Templates
#include <iostream>
#include <string>
using namespace std;
struct Object
{
Object(string name) : name(name) {}
void func() { cout << "Object func " << name << endl; }
string name;
@mattypiper
mattypiper / endian.c
Created April 29, 2015 20:15
Runtime Endian Detection
uint16_T one = 1U;
enum {
LittleEndian,
BigEndian
} machByteOrder = (*((uint8_T *) &one) == 1U) ? LittleEndian : BigEndian;
switch (machByteOrder) {
case LittleEndian:
// code here
break;
case BigEndian:
@mattypiper
mattypiper / WifiMonitor.py
Created July 18, 2015 23:19
Wifi Monitor Windows Service
"""
Windows service that monitors the currently connected network using netsh
Installation:
1) Edit the desired network name (replace "DesiredSsidName")
2) python WifiMonitor.py install
3) Open the Windows Service Control Manager and start the service
4) If there are problems, eg Python exceptions, use Event Viewer to see them
Description:
@mattypiper
mattypiper / stringobf-cpp11.cpp
Last active September 28, 2021 09:29
compile time string obfuscation
// http://www.rohitab.com/discuss/topic/39611-malware-related-compile-time-hacks-with-c11/
#include <stdio.h>
#include <stdint.h>
//-------------------------------------------------------------//
// "Malware related compile-time hacks with C++11" by LeFF //
// You can use this code however you like, I just don't really //
// give a shit, but if you feel some respect for me, please //
// don't cut off this comment when copy-pasting... ;-) //
@mattypiper
mattypiper / armemu.py
Created June 2, 2016 03:37
ARM Assembly, Emulation, Disassembly using Keystone, Unicorn, and Capstone
#!/usr/bin/python
import sys
from keystone import *
from unicorn import *
from unicorn.arm_const import *
from capstone import *
from capstone.arm import *
from capstone.x86 import *
@mattypiper
mattypiper / wifi_monitor.bat
Created August 18, 2017 02:37
Used this with wifi_monitor.py for a while, before converting it to a Windows Service. Useful for automatically running a Windows as Admin, sort of like setuid.
:::::::::::::::::::::::::::::::::::::::::
:: Automatically check & get admin rights
:::::::::::::::::::::::::::::::::::::::::
@echo off
CLS
ECHO.
ECHO =============================
ECHO Running WiFi Monitor
ECHO =============================
@mattypiper
mattypiper / discord_covid19.py
Last active November 17, 2020 15:51
Discord webhook bot to generate and post plots of latest COVID-19 data from JHU CSSE
#!/usr/bin/python3
import argparse
import csv
import sys
import time
import datetime
import logging
import logging.handlers
import hashlib
@mattypiper
mattypiper / yfoi.py
Created August 20, 2020 03:24
find high stock option open interest using yahoo finance
#!/usr/bin/env python
import yfinance as yf
from pprint import pprint
goog = yf.Ticker("GOOG")
option_dates = goog.options
for date in option_dates:
opt = goog.option_chain(date)
calls = opt.calls