Skip to content

Instantly share code, notes, and snippets.

View nbeguier's full-sized avatar

Nicolas Béguier nbeguier

View GitHub Profile
$ nodejs examples/default_config/default_config.js
http://localhost:3000/
koa:sess=eyJ2aWV3cyI6MiwiX2V4cGlyZSI6MTU3Mjk2MjUyMzE4NCwiX21heEFnZSI6ODY0MDAwMDB9; koa:sess.sig=ngESdazh11CH6XAWLQejzuEGkOA
$ time python3 crack_koajs.py --min 2 --max 2 -c koa:sess=eyJ2aWV3cyI6MiwiX2V4cGlyZSI6MTU3Mjk2MjUyMzE4NCwiX21heEFnZSI6ODY0MDAwMDB9 -s ngESdazh11CH6XAWLQejzuEGkOA
Length tried: 2
Found api-key: aa
real 0m0,078s
@nbeguier
nbeguier / koa-main-sha512.js
Created December 30, 2019 11:02
Secure example of koajs
app.keys = new Keygrip(['64bytes_long_string_1', '64bytes_long_string_2'], 'sha512', 'base64')
@nbeguier
nbeguier / pillarjs_cookies.js
Created December 30, 2019 10:48
Cookies function in pillarjs/cookies
function Cookies(request, response, options) {
if (!(this instanceof Cookies)) return new Cookies(request, response, options)
this.secure = undefined
this.request = request
this.response = response
if (options) {
if (Array.isArray(options)) {
// array of key strings
@nbeguier
nbeguier / koajs_lib_context.js
Created December 30, 2019 10:33
function get_cookies in koajs
get cookies() {
if (!this[COOKIES]) {
this[COOKIES] = new Cookies(this.req, this.res, {
keys: this.app.keys,
secure: this.request.secure
});
}
return this[COOKIES];
},
const session = require('koa-session');
const Koa = require('koa');
const app = new Koa();
app.keys = ['some secret hurr'];
const CONFIG = {
key: 'koa:sess', /** (string) cookie key (default is koa:sess) */
/** (number || 'session') maxAge in ms (default is 1 days) */
/** 'session' will result in a cookie that expires when session/browser is closed */
@nbeguier
nbeguier / check_scheduling.py
Created October 10, 2018 15:38
check_scheduling.py
#!/usr/bin/env python3
#-*- coding: utf-8 -*-
""" Check scheduling on nebula for a service """
# Standard library imports
from __future__ import print_function
from sys import argv
# Third party library imports
from pyone import OneServer
@nbeguier
nbeguier / output
Last active October 10, 2018 15:24
Example of migration script output
$ check_scheduling.py prd my_service
--------------------
-- CLUSTER : OK --
--------------------
Number of Cluster : 2
----------------
-- HOSTS --
----------------
Host 25 has 3 VM of the same type !
@nbeguier
nbeguier / default.vcl
Last active September 15, 2018 08:55
VARNISH : Sharding the cache
vcl 4.0;
import dynamic;
# You can add multiple sharding node
backend node01 {
.host = "node01.domain.lan";
.port = "6081";
}
backend node02 {
.host = "node02.domain.lan";
@nbeguier
nbeguier / default.vcl
Created September 14, 2018 20:30
VARNISH : Usage of libvmod-dynamic
vcl 4.0;
# Add import
import dynamic;
# Probe for backend api server
probe api_probe {
.interval = 5s;
.timeout = 1s;
.window = 5;
@nbeguier
nbeguier / nginx.conf
Last active January 4, 2021 13:51
Nginx : Full configuration
# Updated 04/01/2021
server {
listen 443 default_server;
root /var/www/web;
# Only return Nginx in server header
server_tokens off;
ssl on;
ssl_certificate /etc/nginx/ssl/server.pem;