Skip to content

Instantly share code, notes, and snippets.

View yeukhon's full-sized avatar

Yeuk Hon Wong yeukhon

  • Netflix
  • New York, NY
  • 23:53 (UTC -04:00)
View GitHub Profile
@yeukhon
yeukhon / VAGRANT-COURSE.md
Last active March 23, 2026 03:02
Vagrant crash course
@yeukhon
yeukhon / server.py
Last active September 10, 2023 19:29
server.py
# adopt this from https://wiki.python.org/moin/BaseHttpServer
# life would be easier if Bottle was included in stdlib.
import BaseHTTPServer
HOST_NAME = 'localhost'
PORT_NUMBER = 9999
class MyHandler(BaseHTTPServer.BaseHTTPRequestHandler):
def do_GET(s):

Intercepts HTTPs Traffic with Python & mitmproxy

Introduction

Modern applications usually make use of back-end API servers to provide their services. With a non-transparent HTTPs proxy, which intercepts the communication between clients and servers (aka the man-in-the-middle scheme), you can easily manipulate both API requests and responses.

This manual helps you create your own proxy with Python and mitmproxy/libmproxy. Mitmproxy ships with both a standalone command-line tool (mitmproxy) and a Python library (libmproxy).

@yeukhon
yeukhon / test.html
Last active December 14, 2021 14:08
Simple XSS detector using PhantomJS
<html>
<head></head>
<body>
<a href="javascript: alert('clicked xss link')" id="link">click me</a>
<img src="xx" onerror="alert('xss')" />
</body>
</html>
@yeukhon
yeukhon / readme.md
Last active October 26, 2020 06:54
SQL injection walk-through

Live demo: http://sqlfiddle.com/#!2/8cd47/23

Oh I heard you like SQL injection so here is a mini guide just so I don't have to google again or remind myself whatever the fuck I am reading.

Step -1: Setting up..

CREATE TABLE users (
  id int,
program integral
implicit none
! we will solve integral of x^2 using the Trapezoidal Rule
integer :: n
real :: a, b, step, delta, coeff, f0, fn, inner_total, x
! We integrate x^2 from 0 to 4 with n intervals
a = 0.0
b = 4.0
#!/bin/bash
# This script takes two arguments: rds database identifier and timeout.
DB_ID=$1
TIMEOUT=$2
POLL_INTERVAL=60
OK_STATES=("backing-up" "available" "modifying" "resetting-master-credentials")
seconds_left=$TIMEOUT
@yeukhon
yeukhon / myjob.js
Created July 24, 2014 04:08
Parent and child job using kue + node.js + Q.js based on node-job-queue example (https://github.com/prateekbhatt/node-job-queue/blob/master/nested-job-queue.js)
var kue = require('kue'),
jobs = kue.createQueue();
var Q = require('q');
var db = {};
function parentJob(id, done) {
var job = jobs.create('parent', {
type: 'PARENT',
id: id
// NOTE: Ideally we want this kind of output, rather than hardcoing slicing up to 6 chars.
// fmt.Printf("%-13.4f\n", RedIt(StrToNum(stock.Open) - StrToNum(stock.Price)))
// fmt.Printf("%-13s\n", "\x1b[31;1m" + stock.Price + "\x1b[0m")
// I get multiple-value fmt.Printf() in single-value context if:
// fmt.Printf("%-13s\n", "\x1b[31;1m" + fmt.Sprint(fmt.Printf("%.4f", "num)) + "\x1b[0m")
package lib
type StockQuoteResponse struct {
Metadata ResponseMetadata `json:"Meta Data"`
BatchQuote BatchQuoteResponse `json:"Stock Batch Quotes"`
}
type ResponseMetadata struct {
Information string `json:"1. Information"`
Notes string `json:"2. Notes"`