Skip to content

Instantly share code, notes, and snippets.

Avatar
💭
Engineering #security stuff in #go and #python in #AWS

Victor Dorneanu dorneanu

💭
Engineering #security stuff in #go and #python in #AWS
View GitHub Profile
@dorneanu
dorneanu / plugin_architecture.md
Last active Dec 7, 2019
Python: Implement basic plugin architecture with Python and importlib
View plugin_architecture.md

Implementing a basic plugin architecture shouldn't be a complicated task. The solution described here is working but you still have to import every plugin (inheriting from the base class).

This is my solution:

Basic project structure

$ tree
@dorneanu
dorneanu / convert_json_to_strct_list.go
Last active Dec 7, 2019
Golang: Convert JSON string/objects to list of structure
View convert_json_to_strct_list.go
// Go Playground: https://play.golang.org/p/cMutpCzpmth
package main
import (
"fmt"
"encoding/json"
)
// Field is a key value structure
@dorneanu
dorneanu / list_all_repos.py
Last active Dec 7, 2019
Python: List all repos inside a organization using python and github3
View list_all_repos.py
# Make sure you authorize your access token to be used with SAML
# https://help.github.com/articles/authorizing-a-personal-access-token-for-use-with-a-saml-single-sign-on-organization/
#
# Run:
# python list_all_repos.py <org>
import github3
import os
GITHUB_ACCESS_TOKEN = os.environ["GITHUB_ACCESS_TOKEN"]
@dorneanu
dorneanu / stack.dot
Created Oct 31, 2016
Graphviz for plotting stack and dereferenced values
View stack.dot
// Show stack and dereferenced values using Graphviz (DOT)
// (c) Victor Dorneanu
digraph G {
// Define layout
graph [pad=".75", ranksep="0.95", nodesep="0.05"];
rankdir=LR;
node [shape="record"];
rank=same;
View file-upload.py
import requests
import pandas as pd
import os
# Config stuff
url="https://www.yourapp.com/add/new/file"
headers = {
'User-Agent': 'Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:47.0) Gecko/20100101 Firefox/47.0'
# Add here more headers
@dorneanu
dorneanu / chroot.sh
Last active Jan 21, 2020
Put nginx and PHP to jail using Debian 8
View chroot.sh
#!/bin/bash
# Config
N2CHROOT=~victor/tmp/n2chroot
export JAIL=/var/www/chroot
function create_chroot {
# Create devices
mkdir $JAIL/dev
mknod -m 0666 $JAIL/dev/null c 1 3
@dorneanu
dorneanu / client.conf
Last active May 31, 2019
OpenVPN configuration
View client.conf
##############################################
# Sample client-side OpenVPN 2.0 config file #
# for connecting to multi-client server. #
# #
# This configuration can be used by multiple #
# clients, however each client should have #
# its own cert and key files. #
# #
# On Windows, you might want to rename this #
# file so it has a .ovpn extension #
@dorneanu
dorneanu / multiprocessing.py
Created May 6, 2015
Simple parallelism with Python
View multiprocessing.py
#! /usr/bin/env python
# -*- coding: utf-8 -*-
# vim:fenc=utf-8
""" Simple demo of using multiprocessing when parsing files """
import sys
import os
import codecs
from multiprocessing import Pool, Process, Queue, cpu_count
@dorneanu
dorneanu / diagmagic.py
Created Jul 9, 2014
Embed blockdiag into IPython using ipython-diags
View diagmagic.py
# -*- coding: utf-8 -*-
"""magics for using blockdiag.com modules with IPython Notebook
The module provides magics: %%actdiag, %%blockdiag, %%nwdiag, %%seqdiag
Sample usage (in IPython cell):
%%blockdiag
{
A -> B -> C;
@dorneanu
dorneanu / JBlowfish.java
Created Jul 1, 2014
Blowfish Decrypt/Encrypt in Java
View JBlowfish.java
/*
* Based on https://raw.githubusercontent.com/usefulfor/usefulfor/master/security/JBoss.java
*
* JBoss.java - Blowfish encryption/decryption tool with JBoss default password
* Daniel Martin Gomez <daniel@ngssoftware.com> - 03/Sep/2009
*
* This file may be used under the terms of the GNU General Public License
* version 2.0 as published by the Free Software Foundation:
* http://www.gnu.org/licenses/gpl-2.0.html
*/
You can’t perform that action at this time.