Skip to content

Instantly share code, notes, and snippets.

@citruz
citruz / QEMU_ON_M1.md
Last active June 6, 2024 08:29
Create Ubuntu and Windows VMs with QEMU on Apple Silicon

Running Linux and Windows on M1 with QEMU

30.11.2020: Updated with the new patchseries and instructions for Windows

02.12.2020: Added tweaks

08.12.2020: Updated with patchseries v4

31.01.2020: Updated with patchseries v6

@alex3165
alex3165 / aws-lambda-authorizer-google.js
Created July 10, 2019 17:25
An AWS lambda authorizer that work with google access token
const axios = require("axios");
exports.handler = async event => {
const token = event.authorizationToken;
console.log(`Received token`, token);
let googleAuthRes;
try {
googleAuthRes = await axios.get(
`https://www.googleapis.com/oauth2/v1/tokeninfo?access_token=${token}`
@mccabe615
mccabe615 / phpdangerousfuncs.md
Last active June 17, 2024 06:45
Dangerous PHP Functions

Command Execution

exec           - Returns last line of commands output
passthru       - Passes commands output directly to the browser
system         - Passes commands output directly to the browser and returns last line
shell_exec     - Returns commands output
\`\` (backticks) - Same as shell_exec()
popen          - Opens read or write pipe to process of a command
proc_open      - Similar to popen() but greater degree of control
pcntl_exec - Executes a program
@Nihhaar
Nihhaar / audit2allow-sepolicy-android
Created August 22, 2017 20:50
Addressing selinux denials using audit2allow for android using logcat
# Goto android source code root and then execute following commands
# Keep the logcat.log in the root
export ANDROID_BUILD_TOP=$(pwd)
./external/selinux/prebuilts/bin/audit2allow -p out/target/product/{devicename}/root/sepolicy < logcat.log
# Copy the generated rules in respective files in the device tree
@jprichardson
jprichardson / configure-winrm.ps1
Created July 17, 2017 21:49 — forked from sneal/configure-winrm.ps1
Configure WinRM for Vagrant
netsh advfirewall firewall set rule group="remote administration" new enable=yes
netsh advfirewall firewall add rule name="Open Port 5985" dir=in action=allow protocol=TCP localport=5985
winrm quickconfig -q
winrm quickconfig -transport:http
winrm set winrm/config '@{MaxTimeoutms="7200000"}'
winrm set winrm/config/winrs '@{MaxMemoryPerShellMB="0"}'
winrm set winrm/config/winrs '@{MaxProcessesPerShell="0"}'
winrm set winrm/config/winrs '@{MaxShellsPerUser="0"}'
winrm set winrm/config/service '@{AllowUnencrypted="true"}'
@ljjjustin
ljjjustin / socat-tcp-to-unix-socket.sh
Last active April 4, 2024 15:00
socat-unix-socket-to-tcp.sh
#!/bin/bash
if [ $# -ne 3 ]; then
echo "usage: $0 <unix socket file> <host> <listen port>"
exit
fi
SOCK=$1
HOST=$2
PORT=$3
@sameerkumar18
sameerkumar18 / example_flask_googlecaptcha.py
Created May 20, 2017 07:04
A Simple Python Flask Example for Google Recaptcha (implemented on http://ipusearch.herokuapp.com)
RECAPTCHA_PUBLIC_KEY = '<public key>'
RECAPTCHA_PRIVATE_KEY = '<private key>'
def checkRecaptcha(response, secretkey):
url = 'https://www.google.com/recaptcha/api/siteverify?'
url = url + 'secret=' + str(secretkey)
url = url + '&response=' +str(response)
@cschiewek
cschiewek / x11_docker_mac.md
Last active June 29, 2024 02:37
X11 in docker on macOS

To forward X11 from inside a docker container to a host running macOS

  1. Install XQuartz: https://www.xquartz.org/
  2. Launch XQuartz. Under the XQuartz menu, select Preferences
  3. Go to the security tab and ensure "Allow connections from network clients" is checked.
  4. Run xhost + ${hostname} to allow connections to the macOS host *
  5. Setup a HOSTNAME env var export HOSTNAME=`hostname`*
  6. Add the following to your docker-compose:
 environment:
@keithweaver
keithweaver / get-file.py
Last active October 8, 2021 11:56
Get File Content with Python
# Example of getting file content
def getFileContent(pathAndFileName):
with open(pathAndFileName, 'r') as theFile:
# Return a list of lines (strings)
# data = theFile.read().split('\n')
# Return as string without line breaks
# data = theFile.read().replace('\n', '')
@HintikkaKimmo
HintikkaKimmo / who_data.py
Created February 21, 2017 06:10
handy way to read csv files with unknown csv dialect
import csv
import pprint
# opens csv file and assingns it to an object
with open('data-text.csv') as csvfile:
# Use Sniffer to figure out csv dialect
dialect = csv.Sniffer().sniff(csvfile.read(1024))
csvfile.seek(0)
# pass the dialect to filereader to read the file
reader = csv.reader(csvfile, dialect)