Skip to content

Instantly share code, notes, and snippets.

Dinis Cruz DinisCruz

Block or report user

Report or block DinisCruz

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@DinisCruz
DinisCruz / 1. gets list of Keys.cs
Last active Aug 29, 2015
Get current HttpHandlers for WebApplication
View 1. gets list of Keys.cs
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 / 1. set PostAuthorizeRequest.cs
Last active Aug 29, 2015
Setting HttpHandler dynamically
View 1. set PostAuthorizeRequest.cs
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 / AspNet_EventHandlers.cshtml
Created Feb 4, 2014
Razor page that list the current mapped HttpHandlers
View AspNet_EventHandlers.cshtml
@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 / 01. default script provided by Link's checker tool.cs
Last active Aug 29, 2015
Scripts to fix broken links in TeamMentor.Net 2.0 and 3.5 libraries (after a number of articles were removed)
View 01. default script provided by Link's checker tool.cs
@DinisCruz
DinisCruz / 1) In VisualStudio directly consume WCF service.cs
Created Mar 30, 2014
C# scripts used on blog post: 'Programmatically configuring an WCF service without using .config files (using FluentSharp REPL)'
View 1) In VisualStudio directly consume WCF service.cs
return service1Client.GetData(42);
//O2Ref:WCF_Consumer.exe
//O2Ref:System.ServiceModel.dll
@DinisCruz
DinisCruz / 1.Direct Request.cs
Created May 30, 2014
Lync 2010 XSS on UserAgent PoCs
View 1.Direct Request.cs
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 Aug 29, 2015
QA IE Automation script to import and delete accounts in TM
View 1) Create and delete library.cs
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 Aug 29, 2015
PoCs of scriptingTM's AppDomain from NUnit's AppDomain
View 1.Change_TM_Value_from_REPL_Inside_UnitTest.cs
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 Aug 29, 2015
6 C# and Java security flaws, can you spot the vulnerability?
View 1.PostMessage.cs
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 Sep 19, 2014
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)
View 1.open-tm-files.coffee
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
You can’t perform that action at this time.