Skip to content

Instantly share code, notes, and snippets.

@eoftedal
eoftedal / EncryptionPaddingProblem.cs
Created May 18, 2011 17:14 — forked from follesoe/EncryptionPaddingProblem.cs
Padding problem with AesManaged
using System;
using System.IO;
using System.Security.Cryptography;
using System.Text;
using System.Linq;
namespace CryptoTest
{
class Program
{
var txt = "Dette vil slette elevtelling og all tilhørende elevdata. Ønsker du å fortsette?";
function regexSplit(re, txt) {
var reg = new RegExp(re);
var result = [];
var last;
var ar;
while(ar = reg.exec(txt)) {
result.push(ar[1]);
last = reg.lastIndex;
@eoftedal
eoftedal / gist:1178142
Created August 29, 2011 10:21
Simple HTML/Javascript XSS
<html>
<script>
var a = "</script><script>alert(1)</script>";
</script>
</html>
@eoftedal
eoftedal / Person.java
Created September 20, 2011 07:31
Simple java class with public final field instead of getter
public class Person {
public final String navn;
public Person(String navn) {
this.navn = navn;
}
}
@eoftedal
eoftedal / test.rb
Created February 3, 2012 08:22
Test tool needs to support Self-signed cert for non-prod environments. But the first request is horribly slow... (15 seconds) Does not happen in curl or wget
def preflight(uri)
#For some reason this speeds up connect on windows
require 'socket'
context = OpenSSL::SSL::SSLContext.new
tcp_client = TCPSocket.new uri.host, uri.port
ssl_client = OpenSSL::SSL::SSLSocket.new tcp_client, context
ssl_client.connect
end
@eoftedal
eoftedal / gist:2046582
Created March 15, 2012 20:11 — forked from thomaseggum/gist:2044229
attempt
var mynamespace = mynamespace || {};
(function(){
var counter = { count: 0 };
function incrementCounter(){
counter.count++;
}
mynamespace.someobject = {
counter : counter,
@eoftedal
eoftedal / regex.rb
Created May 23, 2012 12:16
Based on @homakov's work
a = "javascript:evil();\nhttp://www.vg.no"
if a =~ /^https?/ then
puts "This is a safe url starting with http or https"
end
@eoftedal
eoftedal / step1
Last active December 24, 2015 06:59
var oldCreateElement = document.createElement;
document.createElement = function() {
var element = oldCreateElement.apply(document, arguments);
var oldSetAttribute = element.setAttribute;
console.log(arguments, element);
element.setAttribute = function(name, value) {
if (name == "onsubmit") {
console.log(arguments.callee.caller.toString());
}
oldSetAttribute.apply(element, arguments);
@eoftedal
eoftedal / DI-Dog
Created October 16, 2013 20:10
DI-løs, men likevel testbar kode
public class Dog {
private Tail tail;
private Head head;
public Dog() {
this(new TailImpl(), new HeadImpl())
}
public Dog(Tail tail, Head head) {
this.tail = tail;
this.head = head;
@eoftedal
eoftedal / SelfVerify.java
Created October 29, 2013 20:42
Self-verification using base64 encoded X509 cert
package no.posten.dpost.sosm;
import java.io.ByteArrayInputStream;
import java.io.IOException;
import java.io.InputStream;
import java.net.URL;
import java.security.AccessController;
import java.security.CodeSigner;
import java.security.CodeSource;
import java.security.PrivilegedAction;