Skip to content

Instantly share code, notes, and snippets.

View AndyNovo's full-sized avatar

Andy Novocin AndyNovo

View GitHub Profile
var http = require("http");
var express = require('express');
console.log("Started server");
var aRouter = express();
var myServer = http.createServer(aRouter);
aRouter.get('/', function(req, res){
res.send("Testing Express");
});
@AndyNovo
AndyNovo / myServer.js
Last active September 30, 2019 11:56
var http = require("http");
console.log("Started server");
var myServer = http.createServer(function(request, response){
console.log(request);
console.log(response);
response.setHeader('Content-Type', 'text/html');
response.write("<p>Hello there</p>");
response.end("<p>I think I'm done</p>");
});
def api(N, U):
M = matrix(ZZ, 2,2, [1, -floor(pi*2^N)*2^N, 0, 2^(2*N)])
M = U*M
M = U.augment(M)
UM = M.LLL()
return UM.submatrix(0,0,2,2)
U = identity_matrix(2)
for i in range(1,100):
U = api(3*i, U)
approx = U[0][1]/U[0][0]
import os, math, binascii
from Crypto.Cipher import AES
def XOR_hex(h1, h2):
ans_hex = hex(int(h1, 16) ^ int(h2, 16))[2:]
if (ans_hex[-1] == "L"):
ans_hex = ans_hex[:-1]
return ans_hex.zfill(len(h1))
def XOR_raw(r1, r2):
@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;
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.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();
def extractor(two_bits):
if two_bits == '01':
return '0'
if two_bits == '10':
return '1'
return ''
#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 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)