Skip to content

Instantly share code, notes, and snippets.

View ericlaw1979's full-sized avatar
💭
Working on Microsoft Web Defense

Eric Lawrence ericlaw1979

💭
Working on Microsoft Web Defense
View GitHub Profile
/*
Only IE and Edge 18 and below support META cache-control and META pragma
https://crbug.com/2763
https://html.spec.whatwg.org/multipage/semantics.html#pragma-directives
*/
import Meddler;
import System;
import System.Net.Sockets;
import System.Windows.Forms;
/*
Only IE and Edge 18 and below support META cache-control and META pragma
https://crbug.com/2763
https://html.spec.whatwg.org/multipage/semantics.html#pragma-directives
*/
import Meddler;
import System;
import System.Net.Sockets;
import System.Windows.Forms;
@ericlaw1979
ericlaw1979 / ServerSentEvents.ms
Last active December 4, 2019 16:15
MeddlerScript for testing ServerSentEvents. See https://textslashplain.com/2019/12/04/the-pitfalls-of-eventsource-over-http-1-1/ for discussion.
import Meddler;
import System;
import System.Net.Sockets;
import System.Windows.Forms;
class Handlers
{
static function OnConnection(oSession: Session)
{
try {
@ericlaw1979
ericlaw1979 / RegisterForDirectInvoke.reg
Created September 25, 2019 21:15
This registry script registers a new file type `.fuzzle` with the MIME-type `application/x-fuzzle` and instructs IE and Edge that the file should be opened using the DirectInvoke mechanism.
Windows Registry Editor Version 5.00
[HKEY_CLASSES_ROOT\.fuzzle]
"Content Type"="application/x-fuzzle"
@="FuzzleProgID"
[HKEY_CLASSES_ROOT\MIME\Database\Content Type\application/x-fuzzle]
"Extension"=".fuzzle"
[HKEY_CLASSES_ROOT\FuzzleProgID]
@ericlaw1979
ericlaw1979 / EpochConverter.js
Created August 14, 2019 03:25
FiddlerScript unix epoch datetime converter
//Scroll to just inside class Handlers and add the following block:
public static ToolsAction("E&poch Analyzer")
function showTime() {
var s = FiddlerScript.prompt("Enter an Epoch time", DateTimeOffset.Now.ToUnixTimeSeconds(), "Epoch Analyzer");
try {
var sec= Int64.Parse(s);
var dt: DateTimeOffset = DateTimeOffset.FromUnixTimeSeconds(sec);
FiddlerScript.alert("Unix Epoch time "+s+" is:\n\tLocal:\t"+dt.ToLocalTime().ToString()+"\n\tGMT:\t"+dt.ToString());
}
/*
This sample shows how to implement the IOfficeAntiVirus interface in C#
The resulting object, once registered, will calculate the file hash (SHA256/Sha1/MD5) for each file downloaded by Chrome, Edge, and Internet Explorer.
In order to successfully register this object, we'll use REGASM to register the assembly, then run a registry script to add the IOfficeAntiVirus
component category, and we'll delete the "Discardable\PostSetup" cache of known IOfficeAntiVirus implementations so that the next call to the IOfficeAntiVirus
providers will find our new object.
Eric Lawrence
@ericlaw1979
ericlaw1979 / reattachFiddlerscript.js
Last active December 19, 2023 16:42
Reattach Fiddler as system proxy if unexpectedly detached; see https://feedback.telerik.com/fiddler/1410460-the-system-proxy-was-changed-click-to-reenable-capturing for discussion.
// Click Rules > Customize Rules. Scroll to OnBoot() and inside the function add:
static function OnBoot() {
FiddlerApplication.oProxy.add_DetachedUnexpectedly(DoReattach);
//...
// Just before the OnBoot function, add the following new functions:
static function DoReattach(o: Object, ea: EventArgs) {
FiddlerObject.UI.sbpInfo.Text = "Scheduling automatic reattach at " + new Date();
@ericlaw1979
ericlaw1979 / ShowSameSiteCookieInfo.js
Last active October 1, 2019 04:21
FiddlerScript function adds a SSCookie column to show the SameSite attribute for Set-Cookie response headers
public static BindUIColumn("SSCookie", 60, 5)
function FillSSCookieInfoColumn(oS: Session): String {
if (oS.state < SessionStates.ReadingResponse) return "";
if (!oS.ResponseHeaders.Exists("Set-Cookie")) return "";
var sbVals = new System.Text.StringBuilder();
for (var i=0; i<oS.ResponseHeaders.Count(); i++){
var thisHeader = oS.ResponseHeaders[i];
if (!StringExtensions.OICEquals(thisHeader.Name, "Set-Cookie")) continue;
if (!StringExtensions.OICContains(thisHeader.Value, "samesite")) { sbVals.Append("+ "); continue; }
@ericlaw1979
ericlaw1979 / FiddlerClientCertPicker.cs
Created May 1, 2019 00:59
Fiddler client certificate picker extension
using System;
using System.Security.Cryptography;
using System.Security.Cryptography.X509Certificates;
using Fiddler;
[assembly: Fiddler.RequiredVersion("2.5.0.0")]
namespace ClientCertPicker
{
public class ClientCertPicker: IFiddlerExtension
{
@ericlaw1979
ericlaw1979 / imageview tools.reg
Created February 19, 2019 19:57
Registry script to add common image tools to Fiddler
Windows Registry Editor Version 5.00
[HKEY_CURRENT_USER\Software\Microsoft\Fiddler2\ImagesMenuExt]
[HKEY_CURRENT_USER\Software\Microsoft\Fiddler2\ImagesMenuExt\&GifDump]
"Command"="C:\\Program Files (x86)\\Fiddler2\\Tools\\gifdump.exe"
"Types"="image/gif"
[HKEY_CURRENT_USER\Software\Microsoft\Fiddler2\ImagesMenuExt\&JPEGSnoop]
"Types"="image/jpeg"