You are not logged in.

#1 2024-10-18 07:41:23

macromal
Member
Registered: 2024-08-03
Posts: 12

Metasploit permissions

I use a umask of 0077 in my system, and i cannot install required gems as non-root user.
So I created a metasploit group, and after an upgrade of the package i need to execute the following script:

#!/bin/sh

METASPLOIT_PATH=${1:-/opt/metasploit}

usage() {
	printf '%s\n' "usage: ${0##*/} [path]"
}

print_error() {
	printf '\e[1;38;5;1m%s\e[m\n' "$1" >&2
}


case "$1" in
	-h | --h | --he | --hel | --help)
		usage
		exit 0
	;;

	-*)	 
		print_error "Unknown option: $1"
		usage
		exit 1
	;;
esac

if [ "$(id -u)" -ne 0 ]; then
	print_error "Permission denied"
	exit 1
fi

if [ ! -d "$METASPLOIT_PATH" ]; then
	print_error "$METASPLOIT_PATH: No such directory"
	exit 1
fi

groupadd -f metasploit
chown -R root:metasploit "$METASPLOIT_PATH"

find "$METASPLOIT_PATH" -type d -exec chmod 775 {} \;

find "$METASPLOIT_PATH" -type f ! -perm /333 ! -perm 444 -exec chmod 444 {} \;
find "$METASPLOIT_PATH" -type f ! -perm /111 ! -perm 444 ! -perm 664 -exec chmod 664 {} \;
find "$METASPLOIT_PATH" -type f -perm /111 ! -perm 775 -exec chmod 775 {} \;

Offline

Board footer

Powered by FluxBB