Skip to content

Instantly share code, notes, and snippets.

View kylestev's full-sized avatar
💻
Senior SWE at Apple

Kyle Stevenson kylestev

💻
Senior SWE at Apple
  • Portland, Oregon
View GitHub Profile
@kylestev
kylestev / HTTPS redirection
Created May 28, 2012 02:08
HTTP to HTTPS redirection in PHP
<?php
if ($_SERVER['SERVER_PORT'] != 443) {
header(sprintf('Location: https://%s%s', $_SERVER['SERVER_NAME'], $_SERVER['REQUEST_URI']));
}
?>
@kylestev
kylestev / JavaScript Injection
Created May 23, 2012 03:50
JavaScript injection into HTML documents using Fiddler
import Fiddler;
class Handlers {
static var injectJs = "<script>alert('I see you enjoy YouTube.')</script>";
static var hostList = new HostList("*.youtube.com");
static function OnBeforeResponse(oSession : Session) {
// Filter to only HTML documents and on the domains we want
if (hostList.ContainsHost(oSession.hostname) && oSession.oResponse.headers.ExistsAndContains("Content-Type", "text/html")) {
oSession.utilDecodeResponse();
@kylestev
kylestev / Netflix Blocker
Created May 23, 2012 03:37
Fiddler Netflix blocker using HostList class
import Fiddler;
class Handlers {
static var nopeGif = "<img src=\"http://i.imgur.com/OLRXz.gif\" />";
static var blocked = "<html><head><title>Blocked</title></head><body><h2>Blocked</h2><p>Stop using all my bandwidth!!</p><br />" + nopeGif + "</body></html>";
static var hostList = new HostList("*.netflix.com,*.nflximg.com");
static function OnBeforeRequest(oSession: Session) {
if (hostList.ContainsHost(oSession.hostname)) {
oSession["ui-bold"] = "true";