AnonSec Shell
Server IP : 172.67.157.199  /  Your IP : 3.144.252.46   [ Reverse IP ]
Web Server : Apache
System : Linux b70eb322-3aee-0c53-7c82-0db91281f2c6.secureserver.net 6.1.90-1.el9.elrepo.x86_64 #1 SMP PREEMPT_DYNAMIC Thu May 2 12:09:22 EDT 2024 x86_64
User : root ( 0)
PHP Version : 8.0.30.2
Disable Function : NONE
Domains : 0 Domains
MySQL : ON  |  cURL : ON  |  WGET : ON  |  Perl : OFF  |  Python : OFF  |  Sudo : OFF  |  Pkexec : OFF
Directory :  /sbin/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Command :


[ HOME ]     [ BACKUP SHELL ]     [ JUMPING ]     [ MASS DEFACE ]     [ SCAN ROOT ]     [ SYMLINK ]     

Current File : /sbin/setup-hostname
#!/bin/sh

PROGRAM=setup-hostname
PREFIX=
: ${LIBDIR=$PREFIX/lib}
. "$LIBDIR/libalpine.sh"

usage() {
	cat <<-__EOF__
		usage: setup-hostname [-h] [HOSTNAME]

		Sets the system hostname.

		options:
		 -h  Show this help

		Sets hostname to HOSTNAME or prompt if unspecified.
	__EOF__
	exit $1
}


# http://en.wikipedia.org/wiki/Hostname#Restrictions_on_valid_host_names
valid_hostname() {
	# check length
	if [ $(echo "$1" | wc -c) -gt 255 ]; then
		echo "Hostname '$1' is too long." >&2
		return 1
	fi
	# check that it only contains valid chars
	if ! [ -z "$(echo $1 | sed 's/[0-9a-z.-]//g')" ]; then
		echo "Hostname must only contain letters (a-z), digits (0-9), '.' or '-'" >&2
		return 1
	fi
	# must not start with - or .
	case "$1" in
		-*) echo "Hostname must not start with a '-'" >&2; return 1;;
		.*) echo "Hostname must not start with a '.'" >&2; return 1;;
	esac
	return 0
}

while getopts "hn:" opt; do
	case $opt in
		h) usage 0;;
		n) name="$OPTARG";;
		'?') usage "1"  >&2;;
	esac
done
shift $(( $OPTIND - 1 ))
if [ -z "$name" ] && [ $# -eq 1 ]; then
	name="$1"
fi

# if name is set, then we run non-interactively
if [ -n "$name" ] && ! valid_hostname "$name"; then
	exit 1
fi

HOST="$name"
while [ -z "$name" ]; do
	HOST=$(hostname)
	ask "Enter system hostname (fully qualified form, e.g. 'foo.example.org')" "$HOST"
	if valid_hostname "$resp"; then
		HOST="$resp"
		break
	fi
done

mkdir -p "$ROOT/etc"
echo "$HOST" > "$ROOT/etc/hostname"

Anon7 - 2022
AnonSec Team