Skip to content

Instantly share code, notes, and snippets.

View Code Golf SE Aristoteles
#include <bits/stdc++.h>
using namespace std;
#define R(i,e)for(I i=1;i<min(20,e);++i)
#define X(x) if(x<1||V[x])continue;V[x]=x;
#define J(a,b,c) X(a)X(b)X(c)
#define P printf
#define D "%2d "
typedef int I;I T=38;I main() {
I V[T];
R(h,20)R(c,20)R(s,20)
View keybase.md

Keybase proof

I hereby claim:

  • I am niklasb on github.
  • I am nba (https://keybase.io/nba) on keybase.
  • I have a public key whose fingerprint is EFA9 7C96 C0CD 9721 101F 5D67 7784 A6C0 F0BD 08CF

To claim this, I am signing this object:

@niklasb
niklasb / wtfregexp.py
Created Dec 26, 2014
solution for ADCTF2014 wtfregexp
View wtfregexp.py
import random
f = open("wtfregexp.pl", "r")
reg = f.readlines()[0]
reg = reg[reg.index('/')+1:-3]
clauses = []
maxi = 0
for l in reg.split(','):
l = l[3:-1].replace("[01]", ".")
View pubkey_laptop
ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQDM4dCzsln+r77vUypKy47W1Hlp1DtBLIFCscYTXuWZgcBnu/yl50p64HfYk5VPi95hUNsHujfdHWWg4dDLUVWnya7I6vbFJh1WIUscTB9+aOzTa7MkH5etliYWhecrb/UuAJ8Crx43nFpYlo2PVrePKy0jeODZqnWB5SMS7Bgl8hW6Rtcg4xuc2MnEprOINg0CzY1cCb9ZHL0UqBW9hzNiJRmhSgq+WLL4f07y2SsEewNg88KXcvfgYqKzxYdc1zNLb9zUhrw39dngAXTssG5SX2IdlOD8JsjxGPT2FovKuQsDOOKb0MibfETsT1qF1XQ4h7mNL7ig/rmmq7Nwnqrp niklas@grampa
View pubkey_macbook
ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAACAQDVJFD6p0LmN/MHJSIsCXvErqETYp8zF59WCSttQMD2C+yoli+LiiwPBn+AuWfGY0tlNsF7vR2TeRjy61agxNjQk2m6MmwjjAf8F9RjVI8uyoyCCYNSKagDBndqwSw0KKyhgwkDPJvwX7vDCt1ar4+VuJpdk7Bkv6XYFOrY/y2/xKWlrDf32MdNtwJqa68WuWUDbyGFtPSUJ/GlAvVhrEpjE/IUq544zM20niFU9wsLWzYEaesLIOB4WEqjlz5hM8xRbBXh2smHuWYkj5PBM48N9kJfEBJkMoIqV9jF630ZX7ce0Knj6YKMvHMVcxKlk3OHybrM66NDx4xYHStu0YkPgj8jVTL/cgLDh+JVOHdw83q2Hg+PffnfCy67dDaHbNirNlfTboSRyweOJJis5shFIxJcsWyM+dTDOn4agp1kdvsmfQH0WqRWg/j3Eno/HURVORCMahsnzuJFiT59WJ2Fq1S0YFlP4E0oySwNrwVeOpHwtU8cLwxWW+tqNqJCvZDG+9Pv1JfTa9eODywwnURQdM9fV4zOuAa84aaB2YJ9b9/m2N/7mtYNOBj9E+72KL3V5LfwgHmo/uCc5+T3bpoM8NHGqTNzfXTX9xAr1UrPXg3ZwsZS06weUUh1SplDiMBH67kei5nTKcNVxq4zaQtUtYzi0YznCsn8COLpAK/SOQ== niklas@Niklass-MacBook-Pro.local
@niklasb
niklasb / lazy.sage
Created Apr 20, 2015
Solution for 'lazy' in PlaidCTF 2015
View lazy.sage
from ast import literal_eval
ciphertext = int(open("ciphertext.txt", 'rb').read())
pubkey = literal_eval(open("pubkey.txt", 'rb').read())
def mat(pubkey, ciphertext, B):
n = len(pubkey)
A = Matrix(ZZ,n+1,n+1)
for i in range(n):
A[i,i] = 1
View bitonic.cpp
#include <bits/stdc++.h>
#include <sys/time.h>
using namespace std;
void make_leq(int& a, int& b) {
if (a > b) swap(a,b);
}
void bitonic(vector<int>& xs) {
int n = xs.size();
@niklasb
niklasb / MonologSlackHandler.php
Last active Sep 1, 2015
Monolog handler for Slack's (new?) incoming webooks
View MonologSlackHandler.php
class MonologSlackHandler extends \Monolog\Handler\MailHandler {
protected $hook_url;
protected $channel;
protected $username;
protected $icon;
/**
* @param string $hook_url The URL of your incoming web hook (e.g.
* https://hooks.slack.com/services/$token)
* @param string $channel Slack channel to post in (with leading # sign)
View signer2.py
# from https://github.com/ctfs/write-ups-2015/tree/master/mma-ctf-2015/crypto/LCG-sign-400
from Crypto.Util.number import *
from hashlib import sha256
import random
import sys
import key
p = 267336782497463360204553349940982883027638137556242083062698936408269688347005688891456763746542347101087588816598516438470521580823690287174602955234443428763823316700034360179480125173290116352018408224011457777828019316565914911469044306734393178495267664516045383245055214352730843748251826260401437050527
q = 133668391248731680102276674970491441513819068778121041531349468204134844173502844445728381873271173550543794408299258219235260790411845143587301477617221714381911658350017180089740062586645058176009204112005728888914009658282957455734522153367196589247633832258022691622527607176365421874125913130200718525263
g = 2
View rsolve.sage
def rsolve(coeff, values, rhs=0, nonhom_sol=0):
R.<x> = CC[]
f = 0
for i, c in enumerate(coeff):
f += c * x**i
h = 0
n = var('n')
cs = []
cnt = 0