facebookarchive / fbctf

Platform to host Capture the Flag competitions

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

How to see the password of admin in `docker-compose` container?

ibeata opened this issue · comments

How to see the password of admin in docker-compose container or reset the password?

I have tried docker logs fbctf but not find the line of the pasword of admin, how can i do it.help.

or how can i refresh the password with the inner hash-func.

mysql> select * from teams;
+----+--------+-------+--------------------------------------------------------------+--------+---------------------+-------+-------+-----------+---------+---------------------+
| id | active | name  | password_hash                                                | points | last_score          | logo  | admin | protected | visible | created_ts          |
+----+--------+-------+--------------------------------------------------------------+--------+---------------------+-------+-------+-----------+---------+---------------------+
|  1 |      1 | admin | $2y$12$2ihJ6XHsLoE3Pnf61SDeqO0R.CZrlWXF9viniQ5NldB5PEZ7qIYgu |      0 | 2019-04-10 00:54:07 | admin |     1 |         1 |       1 | 2019-04-10 00:54:07 |
+----+--------+-------+--------------------------------------------------------------+--------+---------------------+-------+-------+-----------+---------+---------------------+
1 row in set (0.00 sec)


I have knowed the func installed and then work out this problem with ./extra/lib.sh

function import_empty_db() {
  local __u="ctf"
  local __p="ctf"
  local __user=$1
  local __pwd=$2
  local __db=$3
  local __path=$4
  local __mode=$5

  log "Creating DB - $__db"
  mysql -u "$__user" --password="$__pwd" -e "CREATE DATABASE \`$__db\`;"

  log "Importing schema..."
  mysql -u "$__user" --password="$__pwd" "$__db" -e "source $__path/database/schema.sql;"
  log "Importing countries..."
  mysql -u "$__user" --password="$__pwd" "$__db" -e "source $__path/database/countries.sql;"
  log "Importing logos..."
  mysql -u "$__user" --password="$__pwd" "$__db" -e "source $__path/database/logos.sql;"

  log "Creating user..."
  mysql -u "$__user" --password="$__pwd" -e "CREATE USER '$__u'@'localhost' IDENTIFIED BY '$__p';"
  mysql -u "$__user" --password="$__pwd" -e "GRANT ALL PRIVILEGES ON \`$__db\`.* TO '$__u'@'localhost';"
  mysql -u "$__user" --password="$__pwd" -e "FLUSH PRIVILEGES;"

  log "DB Connection file"
  cat "$__path/extra/settings.ini.example" | sed "s/DATABASE/$__db/g" | sed "s/MYUSER/$__u/g" | sed "s/MYPWD/$__p/g" > "$__path/settings.ini"

  local PASSWORD
  log "Adding default admin user"
  if [[ $__mode = "dev" ]]; then
    PASSWORD='password'
  else
    PASSWORD=$(head -c 500 /dev/urandom | md5sum | cut -d" " -f1)
  fi
HASH
  log "The password for admin is: $PASSWORD"
  HASH=$(hhvm -f "$__path/extra/hash.php" "$PASSWORD")
  mysql -u "$__user" --password="$__pwd" "$__db" -e "INSERT INTO teams (name, password_hash, admin, protected, logo, created_ts) VALUES('admin', '$HASH', 1, 1, 'admin', NOW());"
}
  • 1, i have update the password with the hhvm -f ./extra/hash.php my_new_password saved the output.
  • 2, then update the password_hash with output i get just now.
update teams set password_hash='$2y$12$JrR7IDxXy1bV.oxfqHVjluq.h7ypQIwIC1s11SO.B0RhDZd8Cm58K'  \ 
where name='admin';