題目連結

https://learn.cylabacademy.org/library/764

題目解法

  1. 輸入 ssh 指令以及密碼來 clone 下專案到本地。

  2. 查看 README.md 內容,得知要使用使用者名稱 root、電子郵件 root@picoctf 來推送 flag.txt 到遠端。

    1
    2
    3
    4
    5
    6
    7
    8
    
    $ cat README.md
    # MyGit
    
    ### If you want the flag, make sure to push the flag!
    
    Only flag.txt pushed by ```root:root@picoctf``` will be updated with the flag.
    
    GOOD LUCK!
    
  3. 使用 git config 來設定使用者名稱和電子郵件

    1
    2
    
    $ git config --local  user.name "root"
    $ git config --local  user.email "root@picoctf"
    

    正常設定時會使用 global 參數,不過這次設定僅套用在此專案,因此使用 local 參數。

  4. 新增 flag.txt

    1
    
    touch flag.txt
    
  5. 新增 commit 並推送到遠端,再推送到遠端時即可得到 flag。

    1
    2
    3
    
    $ git add flag.txt
    $ git commit -m "feat: add flag.txt"
    $ git push
    

    推送後的內容

     1
     2
     3
     4
     5
     6
     7
     8
     9
    10
    11
    12
    13
    
    $ git push
    git@foggy-cliff.picoctf.net's password: 
    Enumerating objects: 4, done.
    Counting objects: 100% (4/4), done.
    Delta compression using up to 2 threads
    Compressing objects: 100% (2/2), done.
    Writing objects: 100% (3/3), 273 bytes | 273.00 KiB/s, done.
    Total 3 (delta 0), reused 0 (delta 0), pack-reused 0
    remote: Author matched and flag.txt found in commit...
    remote: Congratulations! You have successfully impersonated the root user
    remote: Here's your flag: picoCTF{1mp-----------------------3df}
    To ssh://foggy-cliff.picoctf.net:58441/git/challenge.git
        1f391cc..ff4ce9c  master -> master