Skip to content

Instantly share code, notes, and snippets.

@DinisCruz
DinisCruz / 1. gets list of Keys.cs
Last active August 29, 2015 13:55
Get current HttpHandlers for WebApplication
var eventHandlerList = (EventHandlerList)HttpContextFactory.Context.ApplicationInstance.prop("Events");
var eventList = new List<Object>();
var next = eventHandlerList.field("head");
while (next != null)
{
eventList.add(next.field("key"));
next = next.field("next");
}
return eventList; // there are 12 of these, and they are all objects
@DinisCruz
DinisCruz / AspNet_EventHandlers.cshtml
Created February 4, 2014 15:32
Razor page that list the current mapped HttpHandlers
@using System
@using System.Web
@using System.ComponentModel
@using TeamMentor.CoreLib
@using O2.DotNetWrappers.ExtensionMethods
@{
var application = HttpContextFactory.Context.ApplicationInstance;
var eventHandlerList = (EventHandlerList)application.prop("Events");
var eventsFields = typeof(HttpApplication).fields().where(field=>field.Name.starts("Event"))
@DinisCruz
DinisCruz / 1. set PostAuthorizeRequest.cs
Last active August 29, 2015 13:56
Setting HttpHandler dynamically
var application = HttpContextFactory.Context.ApplicationInstance;
var eventHandlerList = (EventHandlerList)application.prop("Events");
var fieldInfo = (System.Reflection.FieldInfo)application.type().BaseType.BaseType.field("_initInternalCompleted");
PublicDI.reflection.setField(fieldInfo, application, false); //need to set this or we get an 'Event handlers can only be bound to HttpApplication events during IHttpModule initialization.' on the application.PostAuthorizeRequest below
//return PublicDI.reflection.getFieldValue(fieldInfo, application); //usually true
try
{
application.PostAuthorizeRequest += (object sender, EventArgs e) => { "in PostAuthorizeRequest".info(); };
}
@DinisCruz
DinisCruz / 01. default script provided by Link's checker tool.cs
Last active August 29, 2015 13:56
Scripts to fix broken links in TeamMentor.Net 2.0 and 3.5 libraries (after a number of articles were removed)
@DinisCruz
DinisCruz / 1) In VisualStudio directly consume WCF service.cs
Created March 30, 2014 19:26
C# scripts used on blog post: 'Programmatically configuring an WCF service without using .config files (using FluentSharp REPL)'
return service1Client.GetData(42);
//O2Ref:WCF_Consumer.exe
//O2Ref:System.ServiceModel.dll
@DinisCruz
DinisCruz / 1.Direct Request.cs
Created May 30, 2014 13:16
Lync 2010 XSS on UserAgent PoCs
var topPanel = panel.add_Panel(true);
WebClient client = new WebClient ();
Action<string> sendRequest =
(payload)=>{
client.Headers.Add ("user-agent",payload);
var codeViewer = topPanel.add_SourceCodeViewer();
var url = "https://meet.AAAAAA.co.uk";
@DinisCruz
DinisCruz / 1) Create and delete library.cs
Last active August 29, 2015 14:03
QA IE Automation script to import and delete accounts in TM
var admin_Name = "admin";
var admin_Pwd = "********";
var server = "http://127.0.0.1:32768/";
//helper method (should be an extension method)
Action<string,string> waitForElementText = (elementId, text)=>
{
"waiting for '{0}' in element '{1}'".info(text, elementId);
@DinisCruz
DinisCruz / 1.Change_TM_Value_from_REPL_Inside_UnitTest.cs
Last active August 29, 2015 14:03
PoCs of scriptingTM's AppDomain from NUnit's AppDomain
var apiCassini = nUnitTests_Cassini_TeamMentor.apiCassini;
if ("TeamMentor.Schemas".assembly().isNull())
apiCassini.webRoot().mapPath("bin//TeamMentor.Schemas.dll").assembly();
var o2Proxy = apiCassini.appDomain().o2Proxy();
var tmConfig = o2Proxy.staticInvocation("TeamMentor.Schemas",
"TeamMentor.CoreLib.TMConfig",
"get_Current", new object[] {});
@DinisCruz
DinisCruz / 1.PostMessage.cs
Last active August 29, 2015 14:05
6 C# and Java security flaws, can you spot the vulnerability?
public class WS_UsersCommunity : System.Web.Services.WebService
{
[WebMethod()]
public void PostMessage(string sessionID, string userID, string messageSubject, string messageText)
{
HacmeBank_v2_WS.DataFactory.PostMessage(userID, messageSubject, messageText);
}
}
public class DataFactory
{
@DinisCruz
DinisCruz / 1.open-tm-files.coffee
Created September 19, 2014 02:19
Coffee script(s) to unzip , convert (xml to json), load (xml, json) and filter (json) TM Library files (the Uno has 28,468,558 bytes (38.2 MB on disk) for 4,998 items)
fs = require 'fs'
sax = require 'sax'
file = require 'file'
path = require 'path'
AdmZip = require('adm-zip')
xml2js = require('xml2js')
rimraf = require 'rimraf'
unzip = require 'unzip'
expect = require('chai').expect