security-dockerfiles / beef

Dockerized BeEF
MIT License
44 stars 14 forks source link

Do not change password when restarting if already customized #7

Closed cnotin closed 3 years ago

cnotin commented 3 years ago

Closes #5

Here is an example. First, without specifying desired user and password:

# docker run -it --name beef -p3000:3000  beef
Beef credentials: beef:iXlZiIU3pSHKFPzCIj33PlxYvaGeDNhy
[...]

# check that credentials are correctly set:
# docker exec -it beef bash -c "grep user config.yaml ; grep passwd config.yaml"
        user:   "beef"
        passwd: "iXlZiIU3pSHKFPzCIj33PlxYvaGeDNhy"
# docker stop beef
# re-start container, see that password stays the same:
# docker start -i beef
Beef credentials: beef:iXlZiIU3pSHKFPzCIj33PlxYvaGeDNhy
# and check that credentials did not change in file:
# docker exec -it beef bash -c "grep user config.yaml ; grep passwd config.yaml"
        user:   "beef"
        passwd: "iXlZiIU3pSHKFPzCIj33PlxYvaGeDNhy"

# delete container and re-create one:
# docker run -it --name beef -p3000:3000  beef
Beef credentials: beef:S0U0mp2nsMILJE4hMzCZdueGCEN8nPLw
[...]

# check that credentials are correctly set:
# docker exec -it beef bash -c "grep user config.yaml ; grep passwd config.yaml"
        user:   "beef"
        passwd: "S0U0mp2nsMILJE4hMzCZdueGCEN8nPLw"

And now, if we specify user and password:

# docker run -it --name beef -p3000:3000 -e BEEF_USER=myuser -e BEEF_PASSWORD=mypassword beef
Beef credentials: myuser:mypassword
[...]

# check that credentials are correctly set:
# docker exec -it beef bash -c "grep user config.yaml ; grep passwd config.yaml"
        user: "myuser"
        passwd: "mypassword"

# re-start container
# docker stop beef
# docker start -i beef
Beef credentials: myuser:mypassword
[...]

# check that credentials are correctly set:
# docker exec -it beef bash -c "grep user config.yaml ; grep passwd config.yaml"
        user: "myuser"
        passwd: "mypassword"
ilyaglow commented 3 years ago

Thank you for detailed explanation, LGTM