Post

Hackfest 2023: Lost in History

Writeup for the “Lost in History” challenge created by TheRage for the Hackfest CTF 2023.

The flag has been lost in the timeline. Can you recover it?

01 - Tiny changes

For this challenge, a Git project is provided. Inside, there is a single file named flat.txt containing the letter e. By reviewing the Git commit history, we can see 2612 similar commits that change the single character present in the file.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
commit 3431e57c288848b15394b4c70eabaccc7c06c36e (HEAD -> main)
Author: [REDACTED]
Date:   Sun Oct 8 16:03:25 2023 -0400

    ea86dc8ff8871b6f88e97a1f956f4b8327ac2950

diff --git a/flag.txt b/flag.txt
index c793025..9cbe6ea 100644
--- a/flag.txt
+++ b/flag.txt
@@ -1 +1 @@
-7
\ No newline at end of file
+e
\ No newline at end of file

commit 721861f88505f06826659d6aaa3ab567f860fe1c
Author: [REDACTED]
Date:   Sun Oct 8 16:03:25 2023 -0400

    998dc97562b197c4b74e86f64714248e094734f5

diff --git a/flag.txt b/flag.txt
index e440e5c..c793025 100644
--- a/flag.txt
+++ b/flag.txt
@@ -1 +1 @@
-3
\ No newline at end of file
+7
\ No newline at end of file

We can try to combine all these characters into a single text string using the command git log -p | grep "^\+[^\+]" and some find-and-replace in a text editor. We then obtain this long string of characters, which unfortunately doesn’t bring us any closer to the flag.

e737fkahm1nYxoWhGucH y9BsE7DgFHiJ5uCziI3ks0cN1JmVR2V0FsIkVIE8Rk2uEWsB1KeCg4OCnfvcZy5hEUdmUZiZcDg3vK6n58gA5wHnN8MItCecXHzdqcOdISZ6GErGdvdUs4mQgdGl32JoBkSVOETaoHoCs0bAbVb5le0dY40xa3jbNBriDicSwJNbqcVQ286WvulEpjDjOsaKCRrmNKHveJxtOurURt04Ym6wzSGcZvq6AbO90k7PMV1QrKLzvifFtpjufmcIoXDR5usAg6P3rHabQaSzy8tsv71fGN3Y2cY5TG6FH95d2YjuUDUsbQFfX5xaeVaJWMnpBS09kTK8uleNS7TNGBfQcIoGhVD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5MhJ=ugBlkqTqf3oMVhHA7jZbBhS6BnFdkCQshTPmSjtRwOf2HX7La

12 hours after the start of the CTF, a small hint was given to the participants:

The commit messages are there for a reason. At least, some of them :wink:

Each commit message resemble an SHA-1 hash, which is the same type of hash used to identify commits in Git. Using this Python script, we checked if any commit hash correspond to a message from an other commit.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
import git

repo = git.Repo('./history')
repo.git.checkout("main")

messages = [commit.message.strip() for commit in repo.iter_commits()]
commits = [commit.hexsha for commit in repo.iter_commits()]

for commit in commits:
    if commit in messages:
        repo.git.checkout(commit)
        print(open("./history/flag.txt", "r").read(), end="")

print()

We find 48 commits and by displaying the contents of the flag.txt file for these commits, we see the following message which is encoded in base64:

1
SEYtYWE4ODQ0NDI5MGM5ZDExMjI3NzljZDU5MWFmMTQzMDA=

Once decoded, we get our flag:

1
HF-aa88444290c9d1122779cd591af14300
This post is licensed under CC BY 4.0 by the author.