Skip to content

Instantly share code, notes, and snippets.

View diegoparrilla's full-sized avatar
😀

Diego Parrilla diegoparrilla

😀
  • @threatjammer
  • Madrid, Spain
  • 20:43 (UTC +02:00)
  • X @soyparrilla
View GitHub Profile
MacBook-Air-de-Diego:bosh-bootstrap diego$ ./bin/bosh-bootstrap deploy
1. AWS
2. OpenStack
3. vSphere
Choose your infrastructure: 2
Using provider OpenStack
Username: XXXXXXXXXXX
Password: XXXXXXXXXXX
Tenant: XXXXXXXXX
MacBook-Air-de-Diego:bosh-bootstrap diego$ ./bin/bosh-bootstrap deploy
Using provider OpenStack
Confirming: Using OpenStack (user: XXXXXXXX)
Confirming: Using address 10.0.61.66
Reusing security group ssh
-> no additional ports opened
MacBook-Air-de-Diego:bosh-bootstrap diego$ ruby -v
ruby 2.0.0p451 (2014-02-24 revision 45167) [universal.x86_64-darwin13]
MacBook-Air-de-Diego:bosh-bootstrap diego$ gem list bosh
*** LOCAL GEMS ***
bosh-director-core (1.2685.0, 1.2681.0, 1.2671.0)
bosh-registry (1.2685.0, 1.2681.0, 1.2671.0)
bosh-stemcell (1.2685.0, 1.2681.0, 1.2671.0)
#!/bin/bash
cat /cgroup/blkio/libvirt/qemu/blkio.throttle.read_bps_device
cat /cgroup/blkio/libvirt/qemu/blkio.throttle.write_bps_device
cat /cgroup/blkio/libvirt/qemu/*/blkio.throttle.read_bps_device
cat /cgroup/blkio/libvirt/qemu/*/blkio.throttle.write_bps_device
# 10MBps
#BPSLIMIT=10485760
import time
import uuid
import jwt
import requests
import re
# config
SHARED = 'YOUR SHARED KEY'
SUB = 'YOURSUBDOMAIN'
@diegoparrilla
diegoparrilla / migrate_vm.sh
Created May 22, 2014 15:43
Migrate Openstack VM from Private to Public Cloud
# Migrate a VM to another StackOps Cloud
# This is the kind of rubbish written by a CEO. Don't be cruel
# ENTER THE USERNAME, PASSWORD AND TENANT OF THE SOURCE AND DESTINATION TENANTS
# ALSO CHECK THE KEYSTONE ENDPOINT
#
#!/usr/bin/env bash
#set -x
SOURCE_KEYSTONE_HOST=<<CHANGE_ME>>
SOURCE_OS_USERNAME=<<CHANGE_ME>>
SOURCE_OS_PASSWORD=<<CHANGE_ME>>
@diegoparrilla
diegoparrilla / cloudflare-workers-block-europeans.js
Created May 25, 2018 15:29
Using Cloudflare Workers and https://Apility.io API to block access to the pages filtered if the IP belongs to an European country because of the GDPR.
addEventListener('fetch', event => {
event.respondWith(fetchAndCheckOrigin(event.request))
})
async function fetchAndCheckOrigin(req) {
try {
const body = await req.body;
const ip = req.headers.get('cf-connecting-ip');
const apilityio = await fetch('https://api.apility.net/badip/' + ip + '?token=APILITY_IO_API_KEY');
{
"response": {
"score": 0,
"ip": {
"score": 0,
"blacklist": [],
"is_quarantined": false,
"address": "35.189.84.182"
},
"address": {
@diegoparrilla
diegoparrilla / aws-lambdaedge-apilityio-add-header.js
Created August 23, 2018 13:43
Using AWS Lambad@edge and Cloudfront with https://Apility.io API to add to the request headers information of the blacklists of abusers that contains the IP address of the client.
'use strict';
const http = require('http');
exports.handler = (event, context, callback) => {
var startTime = new Date();
const request = event.Records[0].cf.request;
let clientIp = request.clientIp;
var options = {
host: "api.apility.net",
path: "/badip/" + clientIp,
@diegoparrilla
diegoparrilla / Code.gs
Created April 16, 2020 17:08
Google Spreadsheet custom function to get the full ip report from Auth0 Signals/Apility
function SIGNALSFULLIP(input) {
var response = UrlFetchApp.fetch("https://signals.api.auth0.com/ip/" + input + "?token=YOUR_API_TOKEN");
// Parse the JSON reply
var json = response.getContentText();
var data = JSON.parse(json);
var score = data['fullip']['score'];
var blacklists = data['fullip']['badip']['blacklists'].join(',');
var as = data['fullip']['geo']['as']['name'];
var asnum = data['fullip']['geo']['as']['asn'];
var country = data['fullip']['geo']['country'];