Skip to content

Instantly share code, notes, and snippets.

View AndyNovo's full-sized avatar

Andy Novocin AndyNovo

View GitHub Profile
import hashlib
def superHash(secret, salt, iterations):
result = "0"
for i in range(iterations):
result = hashlib.sha256(result + secret + salt).hexdigest()
return result
print superHash("pass123","saltybananas", 1234567)
<?php
session_start();
if (!isset($_SESSION["bananas"])){
$_SESSION["bananas"] = 1;
$_SESSION["recent_bunch"] = 1;
} else {
$this_bunch = rand(1,5);
$_SESSION["bananas"] += $this_bunch;
import random
import urllib2
f=file('quotes.txt','r')
quotes = [l.strip() for l in f]
f.close()
quotes = [w + chr(random.randint(ord('A'),ord('Z'))) if len(w) % 2 == 1 else w for w in quotes]
res = urllib2.urlopen('https://raw.githubusercontent.com/first20hours/google-10000-english/master/google-10000-english-usa.txt')
words = res.read().split()
<?php
$salt = openssl_random_pseudo_bytes(40, $was_strong);
if (!$was_strong){
die("Oh no...");
}
echo bin2hex($salt);
?>
def gen_8_bits(state, length=128):
output=0
for i in range(8):
next_out = state%2
next_state_bit = next_out ^ ((state>>1)%2) ^ ((state>>2)%2) ^ ((state>>7)%2)
state = (state >> 1) | (next_state_bit << (length-1))
output = (output << 1) | next_out
return output, state
key = int("".join(['1' for i in range(128)]),2)
#scraping a site in Python
import urllib2, re
res = urllib2.urlopen('http://www.befria.nu/elias/pi/binpi.html')
html = res.read()
chunks = re.findall('([01]{8}) ', html)
def extractor(two_bits):
if two_bits == '01':
return '0'
if two_bits == '10':
return '1'
return ''
@AndyNovo
AndyNovo / auth.php
Created March 1, 2016 13:45
least secure login
<?php
$username = $_REQUEST["username"];
$pwd = $_REQUEST["password"];
if ($username == "andy" && $pwd == "rules") {
$_SESSION["logged_in"] = true;
echo "You logged in!";
} else {
$_SESSION["logged_in"] = false;
header("Location: index.html"); /* Redirect browser */
exit();
s1 = 3904654068
s2 = 897137925
s3 = 4281244274
m = 2**32
M = matrix(Zmod(m), 2, 2, [s1, 1, s2, 1])
abv = M.inverse()*matrix(Zmod(m), 2, 1, [s2, s3])
a = abv[0,0]
b = abv[1,0]
s4 = (s3*a + b) % m
s5 = (a*s4 + b) % m
@AndyNovo
AndyNovo / auth.sql
Created March 8, 2016 15:24
SQL Injection attack vulnerable login
PRAGMA foreign_keys=OFF;
BEGIN TRANSACTION;
CREATE TABLE users (username text, pwd text);
INSERT INTO "users" VALUES('admin','5743abddddfa08c1e3a99fdebc2e8f3f1108fa12dcd2a8f58a42f141418c22ec');
INSERT INTO "users" VALUES('student','5e884898da28047151d0e56f8dc6292773603d0d6aabbdd62a11ef721d1542d8');
COMMIT;