Skip to content

Instantly share code, notes, and snippets.

@JeanOlivier
Created February 20, 2018 16:13
Show Gist options
  • Save JeanOlivier/659d9692d0fd7b0ee2e07e7d782074a5 to your computer and use it in GitHub Desktop.
Save JeanOlivier/659d9692d0fd7b0ee2e07e7d782074a5 to your computer and use it in GitHub Desktop.
Creates a HTTPS server in the current directory with randomly generated username/password. Arguments are : 1- Username, 2- Number of random characters appended to username, 3- length of password, 4- Port number
# SimpleHTTPAuthServer installed via:
# pip install git+git://github.com/tianhuil/SimpleHTTPAuthServer.git@master
function SpawnSimpleHttpAuthServer()
{
name="${1:-username}-$(< /dev/urandom tr -dc A-Z-a-z-0-9 | head -c${2:-4};echo;)"
pass=$(< /dev/urandom tr -dc _A-Z-a-z-0-9 | head -c${3:-32};echo;)
echo "Username is: $name"
echo "Password is: $pass"
python -m SimpleHTTPAuthServer --https ${4:-8000} $name:$pass
}
@JeanOlivier
Copy link
Author

JeanOlivier commented Feb 20, 2018

Typical outputs:

$ SpawnSimpleHttpAuthServer user
Username is: user-qtjZ
Password is: v-bVgHxgwtvBc_2OD3r8AfaAYd4UdiuQ
Serving HTTP on 0.0.0.0 port 8000 ...
$ SpawnSimpleHttpAuthServer user 8 16 8080
Username is: user-VFKcfmex
Password is: ZLQghKib5a9mpB3w
Serving HTTP on 0.0.0.0 port 8080 ...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment