Skip to content

Instantly share code, notes, and snippets.

@nicjansma
Last active January 17, 2021 07:15
Show Gist options
  • Save nicjansma/f66a357a6d7ed71b7c1d6a96065f15b5 to your computer and use it in GitHub Desktop.
Save nicjansma/f66a357a6d7ed71b7c1d6a96065f15b5 to your computer and use it in GitHub Desktop.
Fiddler FiddlerScript helpers for Boomerang
//
// Helper Functions
//
// Gets a parameter from the URL
static function extractGetParameter(name, query) {
return decodeURIComponent((new RegExp('[?|&]' + name + '=' + '([^&;]+?)(&|#|;|$)').exec(query) || [,""])[1].replace(/\+/g, '%20')) || null;
}
// Gets a POST or GET parameter
private static function requestParameter(oSession: Session, name: String) {
var r = null;
if (oSession.RequestMethod == "POST") {
var s = System.Text.Encoding.UTF8.GetString(oSession.requestBodyBytes);
r = HttpUtility.ParseQueryString(s)[name];
} else {
r = extractGetParameter(name, oSession.PathAndQuery);
}
return (r != null) ? r : "";
}
//
// Boomerang Columns
//
public static BindUIColumn("rt.quit", 60)
function FillRTQuitColumn(oSession: Session): String {
if (oSession.RequestMethod == "POST") {
var s = System.Text.Encoding.UTF8.GetString(oSession.requestBodyBytes);
return s.Contains("rt.quit") ? "Yes" : "No";
} else {
return oSession.PathAndQuery.Contains("rt.quit") ? "Yes" : "No";
}
}
public static BindUIColumn("rt.start", 60)
function FillRTStartColumn(oSession: Session): String {
return requestParameter(oSession, "rt.start");
}
public static BindUIColumn("h.pg xhr.pg", 60)
function FillPGColumn(oSession: Session): String {
var pg = requestParameter(oSession, "h.pg");
if (pg != "") {
return pg;
}
return requestParameter(oSession, "xhr.pg");
}
public static BindUIColumn("http.initiator", 60)
function FillHIColumn(oSession: Session): String {
return requestParameter(oSession, "http.initiator");
}
public static BindUIColumn("t_done", 60)
function FillTDoneColumn(oSession: Session): String {
return requestParameter(oSession, "t_done");
}
public static BindUIColumn("t_resp", 60)
function FillTRespColumn(oSession: Session): String {
return requestParameter(oSession, "t_resp");
}
public static BindUIColumn("t_page", 60)
function FillTPageColumn(oSession: Session): String {
return requestParameter(oSession, "t_page");
}
public static BindUIColumn("http.errno", 60)
function FillHttpErrnoColumn(oSession: Session): String {
return requestParameter(oSession, "http.errno");
}
//
// mPulse Injection
//
static function OnBeforeResponse(oSession: Session) {
var API_KEYS = {
"[domain name]": "[api key]"
}
if (!oSession.oResponse || !oSession.oResponse.headers.ExistsAndContains("Content-Type", "text/html")) {
return;
}
if (oSession.oResponse.headers.HTTPResponseCode !== 200) {
return;
}
if (!API_KEYS[oSession.host]) {
return;
}
oSession.utilDecodeResponse();
oSession.utilReplaceInResponse('<head>', '<head><script>!function(e){function r(r){r&&r.data&&r.data.boomr_mq&&(e.BOOMR_mq=e.BOOMR_mq||[],e.BOOMR_mq.push(r.data.boomr_mq))}e.addEventListener&&e.addEventListener("message",r);var a=e.navigator;a&&"serviceWorker"in a&&a.serviceWorker.addEventListener&&a.serviceWorker.addEventListener("message",r)}(window);</script>');
var closeHead = '<script>(window.BOOMR_mq=window.BOOMR_mq||[]).push(["addVar",{"rua.upush":"false","rua.cpush":"false","rua.upre":"false","rua.cpre":"false","rua.uprl":"false","rua.cprl":"false","rua.cprf":"false","rua.trans":"","rua.cook":"false","rua.ims":"false"}]);</script><script>!function(){function o(n,i){if(n&&i)for(var r in i)i.hasOwnProperty(r)&&(void 0===n[r]?n[r]=i[r]:n[r].constructor===Object&&i[r].constructor===Object?o(n[r],i[r]):n[r]=i[r])}try{var n=decodeURIComponent("%7B%22test%22%3Atrue%7D");if(n.length>0&&window.JSON&&"function"==typeof window.JSON.parse){var i=JSON.parse(n);void 0!==window.BOOMR_config?o(window.BOOMR_config,i):window.BOOMR_config=i}}catch(r){window.console&&"function"==typeof window.console.error&&console.error("mPulse: Could not parse configuration",r)}}();</script><script>!function(e){var a="https://s.go-mpulse.net/boomerang/";if("True"=="True")e.BOOMR_config=e.BOOMR_config||{},e.BOOMR_config.PageParams=e.BOOMR_config.PageParams||{},e.BOOMR_config.PageParams.pci=!0,a="https://s2.go-mpulse.net/boomerang/";if(function(){function t(a){e.BOOMR_onload=a&&a.timeStamp||(new Date).getTime()}if(!e.BOOMR||!e.BOOMR.version&&!e.BOOMR.snippetExecuted){e.BOOMR=e.BOOMR||{},e.BOOMR.snippetExecuted=!0;var n,i,o,r=document.createElement("iframe");if(e.addEventListener)e.addEventListener("load",t,!1);else if(e.attachEvent)e.attachEvent("onload",t);r.src="javascript:void(0)",r.title="",r.role="presentation",(r.frameElement||r).style.cssText="width:0;height:0;border:0;display:none;",o=document.getElementsByTagName("script")[0],o.parentNode.insertBefore(r,o);try{i=r.contentWindow.document}catch(O){n=document.domain,r.src="javascript:var d=document.open();d.domain=\'"+n+"\';void(0);",i=r.contentWindow.document}i.open()._l=function(){var e=this.createElement("script");if(n)this.domain=n;e.id="boomr-if-as",e.src=a+"' +
API_KEYS[oSession.host] +
'",BOOMR_lstart=(new Date).getTime(),this.body.appendChild(e)},i.write("<bo"+\'dy onload="document._l();">\'),i.close()}}(),"500".length>0)if(e&&"performance"in e&&e.performance&&"function"==typeof e.performance.setResourceTimingBufferSize)e.performance.setResourceTimingBufferSize(500);!function(){if(BOOMR=e.BOOMR||{},BOOMR.plugins=BOOMR.plugins||{},!BOOMR.plugins.AK){var a={i:!1,av:function(a){var t="http.initiator";if(a&&(!a[t]||"spa_hard"===a[t])){var n=""=="true"?1:0,i="",o=void 0!==e.aFeoApplied?1:0;if(BOOMR.addVar({"ak.v":16,"ak.cp":"708500","ak.ai":"462059","ak.ol":"0","ak.cr":546,"ak.ipv":4,"ak.proto":"","ak.rid":"20291cd","ak.r":25496,"ak.a2":n,"ak.m":"","ak.n":"essl","ak.bpcip":"107.5.176.0","ak.cport":63454,"ak.gh":"104.91.167.78","ak.quicv":"","ak.tlsv":"tls1.2","ak.0rtt":"","ak.csrc":"-","ak.acc":"reno","ak.feo":o}),""!==i)BOOMR.addVar("ak.ruds",i)}},rv:function(){var e=["ak.bpcip","ak.cport","ak.cr","ak.csrc","ak.gh","ak.ipv","ak.m","ak.n","ak.ol","ak.proto","ak.quicv","ak.tlsv","ak.0rtt","ak.r","ak.acc"];BOOMR.removeVar(e)}};BOOMR.plugins.AK={init:function(){if(!a.i){var e=BOOMR.subscribe;e("before_beacon",a.av,null,null),e("onbeacon",a.rv,null,null),a.i=!0}return this},is_complete:function(){return!0}}}}()}(window);</script></head>'
oSession.utilReplaceInResponse('</head>', closeHead);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment