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
@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"
@ericlaw1979
ericlaw1979 / Fiddler-JPEGify.cs
Last active November 21, 2023 16:53
Trivial Fiddler extension that converts inbound images to JPEG.
using System;
using System.IO;
using System.Drawing;
using System.Drawing.Imaging;
using Fiddler;
using System.Windows.Forms;
using System.Diagnostics;
[assembly: Fiddler.RequiredVersion("2.6.2.0")]
namespace MakeJPEG
@ericlaw1979
ericlaw1979 / HideFastRequests.js
Created January 23, 2019 16:09
Hide Fiddler requests where the overall elapsed time was under 1 second.
//
// Click Rules > Customize Rules. Uncomment the *OnDone* function and update it with
// the code inside the function body below.
//
// This function executes after Fiddler finishes processing a Session, regardless
// of whether it succeeded or failed. Note that this typically runs AFTER the last
// update of the Web Sessions UI listitem, so you must manually refresh the Session's
// UI if you intend to change it.
static function OnDone(oSession: Session) {
@ericlaw1979
ericlaw1979 / NotifyIcon.js
Created January 7, 2019 16:20
Add a "Clear Sessions" item to Fiddler's notification icon
static function DoClear(src:Object, e: EventArgs) {
OnExecAction(["cls"]);
}
static function OnBoot() {
var o = new System.Windows.Forms.ToolStripMenuItem("Clear Sessions");
o.add_Click(DoClear);
FiddlerApplication.UI.mnuNotify.Items.Insert(0, o);
}
@ericlaw1979
ericlaw1979 / SetEgress.js
Last active January 2, 2019 20:43
Sets the Egress IP to the specified IP address to force outbound traffic over a particular interface. Add to Fiddler's Rules file.
// TODO: Customize Menu items names and IP values to match your system.
QuickLinkMenu("E&gress")
QuickLinkItem("Modem", "192.168.2.1")
QuickLinkItem("Cell", "123.13.13.2")
QuickLinkItem("(default)", "")
public static function DoEgressMenu(sText: String, sAction: String)
{
FiddlerApplication.Prefs.SetStringPref("fiddler.network.egress.IP", sAction);
}