Skip to content

Instantly share code, notes, and snippets.

@mattnotmax
mattnotmax / multi-xor.py
Last active January 16, 2023 08:42
Step by step example of a data being XORd with a multi-byte key
import binascii # This imports some functions used to convert data to hex values
data = "4d5a90000300000004000000ffff0000b8000000" # string representation of hex bytes start of executable file (notice the 4d 5a 'MZ' header).
text_key = "AABB" # string representation of the XOR key. This can be as long as you like
hex_data = (binascii.unhexlify(data)) # convert the data to Python hex type
hex_key = (binascii.unhexlify(text_key)) # convert the key to Python hex type
print(f"\nXOR Key is {hex_key}")
@Wendelstein7
Wendelstein7 / hosts
Created November 8, 2021 14:36
China Great Firewall hostfile
This file has been truncated, but you can view the full file.
# China Great Firewall hosts file
# This lists domains that are blocked by the 'Great Firewall' that is being used in China.
# Data is taken from the research conducted by https://gfwatch.org/overview
# Data is a snapshot of 2021-11-04 data taken from https://drive.google.com/drive/folders/1-l4o3c31BuWl6DoA2s7n3BWiEL5jN925
# Converted to hosts file format with regex: `/(^[^|]+).+/` replaced with `0.0.0.0 $1`
# Use with pi-hole for example to simulate your own Great Firewall.
# 537387 entries in this file.
0.0.0.0 ttwt.com.cn
0.0.0.0 54321zm.com
@Neradoc
Neradoc / picopico_safe_mode_boot.py
Last active July 12, 2023 07:49
boot.py implementing waiting to start into safe mode on Raspberry pico
import board
import time
from digitalio import DigitalInOut,Pull
led = DigitalInOut(board.LED)
led.switch_to_output()
safe = DigitalInOut(board.GP14) # <----- choose your pin with a button on it
safe.switch_to_input(Pull.UP)
@pculliton
pculliton / oid_mask_encoding.py
Created July 11, 2019 22:14
Mask encoding example for Kaggle OpenImages Instance Segmentation Competition
import base64
import numpy as np
from pycocotools import _mask as coco_mask
import typing as t
import zlib
def encode_binary_mask(mask: np.ndarray) -> t.Text:
"""Converts a binary mask into OID challenge encoding ascii text."""
# check input mask --
if mask.dtype != np.bool:
@AdamJHowell
AdamJHowell / gist:1e2bacba7d0feb46f9fed2eec141b5aa
Created April 22, 2019 21:53
<style type="text/css"> in the <head> of every web page I visit 1/2
<style type="text/css">.mywidget__col > a.mywidget__link_advert, div[id^="_u_ablock_"], .flat_pm_outgoing, #Ad2, #AdText, #Ad_Top, #Adbanner, #Adfox_Banner, #Ads, #AdvertFieldBottom, #AdvertFieldCenter, #AdvertFieldTop, #Advertisement, #AdvertisingTopLine, #BanHolder28-1, #BannerGBottom, #BannerGCenter, #BannerGIMG, #BannerGTop, #BannerH2Left, #BannerHIMG, #BannerHLeft, #BannerUnderBroChat, #JaboxAdBarOuter, #METABAR_IFRAME, #MarketGidComposite1001, #PopUpWnd, #PopWin, #PopWin_popupsu_notds, #RichBanner_center, #__adIframe, #ad-200, #ad-slides, #ad2, #ad4, #ad7, #adHeadBanner, #adL, #adP, #adWrapper, #ad_help_link, #ad_hide_mask_ad_0, #ad_hide_mask_ad_1, #adbns, #adf_notifiers_wrap, #adsCSS, #advRightBox, #advbroker_place_1, #advbroker_place_10, #advbroker_place_2 { display: none!important; }
#advbroker_place_3, #advbroker_place_4, #advbroker_place_5, #advbroker_place_6, #advbroker_place_7, #advbroker_place_8, #advbroker_place_9, #advertbox, #advertising_floater, #advertisment, #advrich, #advunder-top, #adzer