Skip to content

Instantly share code, notes, and snippets.

@DinisCruz
DinisCruz / gist:4124669
Created November 21, 2012 12:39
O2 Script - Visual API - Compile and display an O2 UserControl in VS
var visualStudio = new VisualStudio_2010();
var targetfile = @"E:\O2_V4\O2.FluentSharp\O2.FluentSharp.REPL\Ascx\ascx_Simple_Script_Editor.cs";
var type = "ascx_Simple_Script_Editor";
visualStudio.open_Document(targetfile);
var hostPanel = visualStudio.open_Panel("for type:" + type);
hostPanel.toolWindowPane().as_Dock();
Action compileAndShow =
@DinisCruz
DinisCruz / gist:4126139
Created November 21, 2012 17:15
O2 Script - Create ToolStrips items (buttons, textbox, checkboxes) with icons
var visualStudio = new VisualStudio_2010();
var topPanel = "topPanel".o2Cache<Panel>(false,()=> visualStudio.open_Panel())
.add_Panel(true);
var toolStrip = topPanel.insert_Above_ToolStrip();
toolStrip.beginUpdate()
.add_New(()=>{})
.add_Open(()=>{})
.add_Save(()=>{})
@DinisCruz
DinisCruz / gist:4136748
Created November 23, 2012 18:28
O2 Script - Util - Windows Handles - View Handle Screenshot
//var topPanel = panel.add_Panel(true);
var topPanel = "Util - Windows Handles - View Handle Screenshot".popupWindow(450,350);
WindowFinder windowFinder = null;
TextBox textBox_CurrentHandle = null;
PictureBox pictureBox = null;
Bitmap lastScreenShot = null;
Label userMessage = null;
Action<IntPtr> onHandleChange =
@DinisCruz
DinisCruz / gist:4173602
Created November 30, 2012 03:28
O2 Script - Example of UnitTest to test for XSS on AltoroMutual
// This file is part of the OWASP O2 Platform (http://www.owasp.org/index.php/OWASP_O2_Platform) and is released under the Apache 2.0 License (http://www.apache.org/licenses/LICENSE-2.0)
using System;
using System.IO;
using System.Collections.Generic;
using System.Diagnostics;
using System.Text;
using O2.Kernel;
using O2.Kernel.ExtensionMethods;
using O2.DotNetWrappers.ExtensionMethods;
using O2.XRules.Database.APIs;
@DinisCruz
DinisCruz / Version 1 (with static data).cs
Last active October 26, 2017 21:09
O2 Script - Send data to Google Analytics via get request (of Image)
//descriptions from http://www.lunametrics.com/blog/2011/10/04/utmgif-request-parameters/
var utmwv = "5.3.8"; // Tracking code version
var utms = "1"; // Session requests. Updates every time a __utm.gif request is made. Stops incrementing at 500 (max number of GIF requests per session).
var utmn = "1797201820"; // Unique ID generated for each GIF request to prevent caching of the GIF image
var utmhn = "teammentor-33-ci"; // Host name, which is a URL-encoded string
var utmcs = "ISO-8859-1"; // Language encoding for the browser. Some browsers don’t set this, in which case it is set to “-”
var utmsr = "1440x852"; // Screen resolution
var utmvp = "1440x751"; // Size of Viewing Pane
var utmsc = "32-bit"; // Screen color depth
var utmul = "en-us"; // Browser language
int GUIDS_TO_CREATE = 1000000; //10000000;
//The code below was converted from https://gist.github.com/kofisarfo/5420710
//public static class CSPRNG {
//public static byte[] GetBytes(int entropy)
Func<int, byte[]> GetBytes =
(entropy)=>{
if (entropy < 8) {
var ie = "ie_xpHky".o2Cache<WatiN_IE>(()=> panel.clear().add_IE()).silent(true); // ie ramdon value for o2cache makes this object to unique amongst multiple instances of this control
ie.open("http://www.w3schools.com/tags/tryit.asp?filename=tryhtml_iframe"); //Load test page
ie.waitForComplete(); // Wait for it to load the IFrames
var hostIFrames = ie.IE.Frames; // Get All frames from the tryhtml_iframe page (using the Frame property from the WatiN's IE object)
var hostIFrame = (Frame)hostIFrames.last(); // Get the right-hand-side IFrame
//this is a hacked way to change the frame's host width)
var hostHtml = hostIFrame.Html; // Gets the html which is the same as the text shown on the left-hand-side textbox
@DinisCruz
DinisCruz / gist:5451167
Created April 24, 2013 10:24
Invoking ESAPI encoder method from .Net (using Jni4Net)
var jni4Net = new API_Jni4Net();
jni4Net.setUpBride();
var jarPath = @"E:\_Code_Tests\OWASP_AppSensor\_O2_Test";
var jars = jarPath.files("*.jar");
var classLoader = jni4Net.systemClassLoader().loadJars(jars);
var esapi = classLoader.loadClass("org.owasp.esapi.ESAPI");
var encoder = esapi.getMethod("encoder",null).invoke(null,null);
@DinisCruz
DinisCruz / Decrypt using C# (H2 script).cs
Last active May 28, 2016 21:01
Html and C# scripts to decrypt an AES string (used to communicate between a html server and a flash movie)
//based on code sample from this MSDN article: http://msdn.microsoft.com/en-us/library/system.security.cryptography.aes(v=vs.100).aspx)
Func<byte[], byte[],byte[], string> decryptStringFromBytes_AES =
(cipherText, Key, IV) =>
{
// Check arguments.
if (cipherText == null || cipherText.Length <= 0)
throw new ArgumentNullException("cipherText");
if (Key == null || Key.Length <= 0)
throw new ArgumentNullException("Key");
if (IV == null || IV.Length <= 0)
@DinisCruz
DinisCruz / consume md5 files.cs
Last active October 1, 2021 05:11
H2 script - Generate Small MD5 Rainbow Table
var topPanel = "{name}".popupWindow(700,200);
//var topPanel = panel.clear().add_Panel();
"Loading data".info();
var baseFolder = @"C:\Users\o2\AppData\Roaming\OWASP_O2_Platform_5.3\8_12_2013\MD5_Hashes";
var md5HashesFile = baseFolder.pathCombine("(10x numbers - 2x length) M5_for_10_chars_with_2_depth.txt");
var md5Hashes = md5HashesFile.fileContents();
var mappings = new Dictionary<string,string>();
foreach(var line in md5Hashes.lines())
{