Skip to content

Instantly share code, notes, and snippets.

@BigSully
BigSully / start mitmproxy in background programmatically
Last active March 30, 2024 21:33
start mitmproxy in background programmatically
from mitmproxy.options import Options
from mitmproxy.proxy.config import ProxyConfig
from mitmproxy.proxy.server import ProxyServer
from mitmproxy.tools.dump import DumpMaster
import threading
import asyncio
import time
class Addon(object):
@BigSully
BigSully / raspberry pi wireless AP
Last active May 2, 2020 14:19
Setting up a Raspberry Pi 3B plus as a routed wireless access point
## set up the raspberry pi 3B+ as a wifi AP ( a wireless router )
## suppose etho is your wan interface name, and wlan0 is your lan interface name
# https://www.raspberrypi.org/documentation/configuration/wireless/access-point-routed.md
# https://thepi.io/how-to-use-your-raspberry-pi-as-a-wireless-access-point/
# https://www.shellvoide.com/wifi/setup-wireless-access-point-hostapd-dnsmasq-linux/
## install softwares
apt install -y hostapd
apt install -y dnsmasq
DEBIAN_FRONTEND=noninteractive apt install -y netfilter-persistent iptables-persistent
# testing ps -ef | grep hostapd
@BigSully
BigSully / async await in chrome extension
Last active March 19, 2024 20:59
async await in chrome extension
/**
* Usage:
* let cookies = await asyncfy(chrome.cookies.getAll)({ url })
* let tabs = await asyncfy(chrome.tabs.query)({active: true, currentWindow: true})
*
* @param fn A function that takes one or more parameters, and the last parameter is a callback which has one or more parameter. The simplest one is chrome.management.getSelf
* @returns {function(...[*]): Promise<any>} Return one value if the results array has only one element, else return the whole results array
*/
let asyncfy = fn => (...args) => {
return new Promise((resolve, reject) => {
@BigSully
BigSully / DNS over TLS for unbound
Last active October 1, 2024 10:20
DNS over TLS configuration for unbound, including Google DNS, Cloudflare DNS and Quad9 DNS
server:
logfile: ""
# verbosity: 2
username: "nobody"
interface: 0.0.0.0
access-control: 0.0.0.0/0 allow
prefetch: yes
# include: "/opt/unbound/local.conf"
# include: "/opt/unbound/customize.conf"
@BigSully
BigSully / toggle system proxy by hammerspoon shortcuts in macos
Last active January 17, 2020 15:22
toggle system proxy by hammerspoon shortcuts in macos
1. set the ip and port of http and https proxy manually for the first time, which can be accomplished in command line though.
networksetup -setwebproxy "Wi-fi" 127.0.0.1 8080
networksetup -setsecurewebproxy "Wi-fi" 127.0.0.1 8080
2. add the following shell function to your ~/.profile
toggleProxy() {
e=$(networksetup -getwebproxy wi-fi | grep "No")
ns=wi-fi
status=''
function printf(s,...) print(s:format(...)) end
function fastExportImage()
-- whether the pohtoshop is in focus
local window = hs.window.focusedWindow()
local app = window:application()
local title = app:title()
local isPhotoshop = title:find("Photoshop CC")
if( not isPhotoshop ) then