Skip to content

Instantly share code, notes, and snippets.

View bluPhy's full-sized avatar
🏠
Working from home

bluPhy bluPhy

🏠
Working from home
View GitHub Profile
@bluPhy
bluPhy / vscode-remote-ssh-root.sh
Last active December 20, 2023 05:25
workaround hack to open vscode remote as root without logging in as root
#!/bin/bash
# Backup the original server.sh file
cp ~/.vscode-server/bin/*/server.sh ~/.vscode-server/bin/server.sh.bak
# Add sudo to node runner in server.sh
if sed -i "/node/s/^/sudo /" ~/.vscode-server/bin/*/server.sh; then
echo "sudo added to node runner in server.sh"
else
echo "Failed to add sudo to node runner. Please check the sed command."
#!/usr/bin/env bash
set -euo pipefail
export DEBIAN_FRONTEND=noninteractive
### Function to create a default user
create_default_user() {
local password password_confirm password_hash
# Check if user exists
###################################################################
# This is not require anymore, use the official script from: #
# https://gitlab.com/parrotsec/project/debian-conversion-script #
###################################################################
#!/bin/bash -v
# This prevents the installer from opening dialog boxes during the installation process. As a result, it stops the errors from displaying
# export DEBIAN_FRONTEND=noninteractive
#!/bin/bash
# Put this at the top of your script
# Detects if script are not running as root, if not will self invoke the script with sudo
# $0 is the script itself (or the command used to call it)...
# $* parameters...
# In both cases using double quote to prevent globbing and word splitting.
# Check if script is being run as root
if [[ $UID -ne 0 ]]; then
@bluPhy
bluPhy / gcp_iam_user_list-extraction.sh
Last active December 27, 2022 20:34
Script to retrieve GCP IAM roles, users and serviceaccounts, must be used in conjunction with iam-json-reformat.py
#!/bin/bash
# Script to retrieve GCP IAM roles, users and serviceaccounts
# Author - Alejandro Leal [email protected] (Originally from Rajathithan Rajasekar)
echo 'project-id,roles/rolename,user:username-and-serviceaccounts' > iamlist.csv
prjs=( $(gcloud projects list | awk '/PROJECT_ID/{print $2}') )
for i in "${prjs[@]}"
do
echo "------------------------------------------------------------"
echo "Collecting IAM roles & users for Project: $i"
@bluPhy
bluPhy / iam-json-reformat.py
Last active November 4, 2023 20:55
iam-json-reformat.py
#!/usr/bin/env python3
# Python script to reformat IAM json data
# Author: Rajathithan Rajasekar - 03/03/2020
import json,ast,sys
data = []
project = ""
def hello(jdata, project):
@bluPhy
bluPhy / gcp_iam_policy-export.sh
Last active April 1, 2023 17:06
Script to retrieve GCP IAM roles, users and serviceaccounts and export it to yaml files
#!/bin/bash
# Script to retrieve GCP IAM roles, users and serviceaccounts
# and export it to yaml files that can be used to import back
# with gcloud projects set-iam-policy <project> <policy.yaml>
#
# You can manually remove the etag and version lines in the resulting yaml file
# but do so at your own risk.
#
# Author - Alejandro Leal [email protected]
@bluPhy
bluPhy / AddingUserWithPassword_Linux.sh
Last active April 1, 2023 17:04
Adding user with password Linux
#!/bin/bash
# Purpose - Script to add a user to Linux system including passsword
# Original Author - Vivek Gite <www.cyberciti.biz> under GPL v2.0+
# Updated by - Alejandro Leal @bluPhy
# ------------------------------------------------------------------
# Am i Root user?
if [ $(id -u) -eq 0 ]; then
read -p "Enter username : " username
while true; do
read -p "Provide the password for default username (kali):" -s -r password
@bluPhy
bluPhy / exif_datetime_setter.sh
Last active December 27, 2022 20:37
exif_datetime_setter.sh
#!/bin/bash
# Orginal script from pirafrank https://gist.github.com/pirafrank/9970c15fec0fa6e49be5363ef6ed1cf3
# Simple script to parse JPG photo filename and set exif datetime,
# creation date and file modification date accordingly.
# Timezone is taken by your PC.
# exec this script by searching for .JPG and .jpg files in given folder
# find . -type f -name "*.JPG" -o -name "*.jpg" -exec /path/to/exif_datetime_setter.sh {} \;
# Force update of all files based on exif info -> exiftool '-FileModifyDate<Exif:CreateDate' -overwrite_original *
@bluPhy
bluPhy / list-all-projects-in-org.sh
Last active August 27, 2024 16:48
List all Google Cloud GCP projects in Organization
#!/usr/bin/env bash
# Google Cloud script
# This script checks in an organization for all the projects and list them
#
# Usage examples:
# list-all-projects-in-org.sh --organization 123456789
#
# Notes:
# To run this script, you need the required IAM permissions