Skip to content

Instantly share code, notes, and snippets.

@shagamemnon
shagamemnon / wsl2-network.ps1
Created February 10, 2023 16:46 — forked from xmeng1/wsl2-network.ps1
WSL2 Port forwarding port to linux
$remoteport = bash.exe -c "ifconfig eth0 | grep 'inet '"
$found = $remoteport -match '\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}';
if( $found ){
$remoteport = $matches[0];
} else{
echo "The Script Exited, the ip address of WSL 2 cannot be found";
exit;
}
@shagamemnon
shagamemnon / cloudflared-system-service-linux.md
Created July 16, 2021 05:38
cloudflared system service on AWS Linux

Configure .cloudflared to run on boot as system service

ssh -i "/path/to/cert.pem" [email protected]
# ...

# Traverse file directory to ~/.cloudflared
cd ~/.cloudflared
# Elevate to root permission
sudo su
# Temporarily append ec2-user PATH to root user path for duration of terminal session
## Sample / prototype Worker snippet for bot management + KV + rate limiting
### Requires:
* Wrangler (https://github.com/cloudflare/wrangler)
* API key with Workers, and Workers KV write Permissions
```js
const CIDR = require('cidr-js')
const cidr = new CIDR()
/*
@shagamemnon
shagamemnon / waf-disable-to-simulate.md
Last active March 3, 2021 20:24
Change all rules from Cloudflare Managed Rulesets to simulate mode
# Cache API Docs + Example
- https://developers.cloudflare.com/workers/about/using-cache/
- https://developers.cloudflare.com/workers/reference/apis/cache
```js
addEventListener('fetch', event => {
event.respondWith(handleRequest(event))
})
async function handleRequest(request) {
<!-- <!DOCTYPE html> Required -->
<!DOCTYPE html>
<html lang="en">
<head>
<!-- <title> Required -->
<title>Error Page</title>
<!-- The HTML file must contain at least 100 characters. An easy way to do that is to add the universal normalize.css snippet -->
<style>
/*! normalize.css v8.0.1 | MIT License | github.com/necolas/normalize.css */html{line-height:1.15;-webkit-text-size-adjust:100%}body{margin:0}main{display:block}h1{font-size:2em;margin:.67em 0}hr{box-sizing:content-box;height:0;overflow:visible}pre{font-family:monospace,monospace;font-size:1em}a{background-color:transparent}abbr[title]{border-bottom:none;text-decoration:underline;text-decoration:underline dotted}b,strong{font-weight:bolder}code,kbd,samp{font-family:monospace,monospace;font-size:1em}small{font-size:80%}sub,sup{font-size:75%;line-height:0;position:relative;vertical-align:baseline}sub{bottom:-.25em}sup{top:-.5em}img{border-style:none}button,input,optgroup,select,textarea{font-family:inherit;font-size:100%;line-height:1.15;
@shagamemnon
shagamemnon / static_ip.sh
Last active October 5, 2020 02:17 — forked from RichardBronosky/static_ip.sh
Script to generate /etc/dhcpcd.conf for static IP on Raspbian Raspberry Pi
#!/bin/bash -e
sudo cp /etc/dhcpcd.conf /etc/dhcpcd.conf.backup
if [[ $# -ne 0 ]]; then
cat<<EOF
Usage:
$0
DEV=eth0 $0
@shagamemnon
shagamemnon / cloudflare-workers-base64.js
Created October 2, 2020 07:23
Decode Base64 encoded text in Cloudflare Workers
/* Demo: https://cloudflareworkers.com/#6168c0dbeb076f1e3ac7eb102082361f:https://www.google.com/ */
addEventListener('fetch', event => {
event.respondWith(handleRequest(event.request))
})
function fromBinary(msg) {
const ui = new Uint8Array(msg.length)
for (let i = 0; i < msg.length; ++i) {
ui[i] = msg.charCodeAt(i)
@shagamemnon
shagamemnon / dig.md
Last active April 24, 2020 18:15 — forked from tuksik/dig_cs.sh
Frank's dig cheat sheet
# force recursion back to root nameservers (helpful for bypassing caches)
dig www.cloudflare.com A +trace

# get the address(es) for yahoo.com
dig yahoo.com A +noall +answer

# get a list of yahoo's mail servers
dig yahoo.com MX +noall +answer
@shagamemnon
shagamemnon / cloudSettings
Last active November 19, 2020 17:31
vscode settings
{"lastUpload":"2020-11-19T17:31:19.906Z","extensionVersion":"v3.4.3"}