Skip to content

Instantly share code, notes, and snippets.

View evandrix's full-sized avatar
💭
offline

evandrix evandrix

💭
offline
View GitHub Profile
using System.Xml;
using System.IO;
using System.Collections.Generic;
using System.Web.UI;
using System;
using System.Linq;
using System.Text;
using System.Web;
using System.Web.Configuration;
using System.Web.UI.WebControls;
@evandrix
evandrix / gist:1076041
Created July 11, 2011 15:03
Using bcrypt to secure passwords in a Perl application
#!/usr/bin/perl
use Crypt::Eksblowfish::Bcrypt;
use Crypt::Random;
$password = 'bigtest';
$encrypted = encrypt_password($password);
print "$password is encrypted as $encrypted\n";
print "Yes the password is $password\n" if check_password($password, $encrypted);
print "No the password is not smalltest\n" if !check_password('smalltest', $encrypted);
@evandrix
evandrix / .bash_profile
Created July 11, 2011 00:12
A better ls for Mac OS X
# MacPorts
export PATH=/opt/local/bin:/opt/local/sbin:$PATH
export MANPATH=/opt/local/share/man:$MANPATH
# Terminal colours (after installing GNU coreutils)
NM="\[\033[0;38m\]" #means no background and white lines
HI="\[\033[0;37m\]" #change this for letter colors
HII="\[\033[0;31m\]" #change this for letter colors
SI="\[\033[0;33m\]" #this is for the current directory
IN="\[\033[0m\]"
@evandrix
evandrix / .bash_profile
Created July 11, 2011 00:10
Mac OSX dot config files
# MacPorts
export PATH=/opt/local/bin:/opt/local/sbin:$PATH
export MANPATH=/opt/local/share/man:$MANPATH
# Terminal colours (after installing GNU coreutils)
NM="\[\033[0;38m\]" #means no background and white lines
HI="\[\033[0;37m\]" #change this for letter colors
HII="\[\033[0;31m\]" #change this for letter colors
SI="\[\033[0;33m\]" #this is for the current directory
IN="\[\033[0m\]"
@evandrix
evandrix / Example #1
Created July 8, 2011 23:06
ADO: SQL query in XLS
Query Table with Excel as Data Source
Query tables can be of great help if you need to extract particular data from a data source
It represents a worksheet table built from data returned from an external data source, such as an SQL server or a Microsoft Access database. The QueryTable object is a member of the QueryTables collection
However, it need to be SQL server or a Microsoft Access database always. You can use CSV file or our fellow Microsoft Excel spreadsheet as a data source for QueryTable
Here is one such example, which extracts data from MS Excel sheet
Use the Add method to create a new query table and add it to the QueryTables collection.
@evandrix
evandrix / newton-sqrt.scala
Created July 7, 2011 00:10
Scala by Example
def sqrt(x: Double): Double = sqrtIter(1.0, x)
def sqrtIter(guess: Double, x: Double): Double =
if (isGoodEnough(guess, x)) guess
else sqrtIter(improve(guess, x), x)
def improve(guess: Double, x: Double) =
(guess + x / guess) / 2
def isGoodEnough(guess: Double, x: Double) =
abs(square(guess) - x) < 0.001
Writing to Memory
Exploiting format string vulnerabilities is all about providing input that uses a format character that expects its value to be passed by reference and you control that reference. I used ‘%s’ to read from memory. I’m going to use %n to write to memory.
%n Number of characters written by this printf.
Lucky for us, there is a really easy way to control the number of characters written by printf. When you specify a format character, you can optionally give it an integer for the width of the format character.
%#x Number of characters prepended as padding.
We can use this to control how many characters are written by printf.
@evandrix
evandrix / Rakefile
Created July 6, 2011 16:07 — forked from tooky/Rakefile
Sinatra + Cucumber + Webrat
require 'rubygems'
require 'cucumber/rake/task'
Cucumber::Rake::Task.new(:features) do |t|
t.cucumber_opts = "--format pretty"
end
@evandrix
evandrix / html_character_set.txt
Created July 6, 2011 11:42
HTML Character Set (Character Code) Table
09 &#09; Horizontal tab
10 &#10; Line feed
13 &#13; Carriage Return
32 &#32; Space
33 ! &#33; Exclamation mark
34 " &#34; &quot; quotation mark = APL quote
35 # &#35; Number sign
36 $ &#36; Dollar sign
37 % &#37; Percent sign
38 & &#38; &amp; ampersand
@evandrix
evandrix / printf.c
Created July 6, 2011 10:37
Advanced Format String Attacks Presented by Paul Haas (Linux only)
#include <stdio.h>
int main(int argc, char **argv){
printf(argv[1]);
}
# Compile and setup insecure environment
gcc printf.c -w -O0 -ggdb -std=c99 -static -D_FORTIFY_SOURCE=0 -fno-pie -Wno-format -Wno-format-security -fno-stack-protector -z norelro -z execstack -o printf
sudo sysctl -w kernel.randomize_va_space=0