<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Stories by Anthony &quot;RedHatAugust&quot; Radzykewycz on Medium]]></title>
        <description><![CDATA[Stories by Anthony &quot;RedHatAugust&quot; Radzykewycz on Medium]]></description>
        <link>https://medium.com/@redhataugust?source=rss-fdaad18a12a6------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*k6wr5AwMsJdaYHYfn5UBcg.png</url>
            <title>Stories by Anthony &amp;quot;RedHatAugust&amp;quot; Radzykewycz on Medium</title>
            <link>https://medium.com/@redhataugust?source=rss-fdaad18a12a6------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Sun, 29 Nov 2026 02:49:57 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@redhataugust/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[OffSec’s The Gauntlet Week 1: ProtoVault Breach]]></title>
            <link>https://medium.com/@redhataugust/offsecs-the-gauntlet-week-1-protovault-breach-6119cd1b763c?source=rss-fdaad18a12a6------2</link>
            <guid isPermaLink="false">https://medium.com/p/6119cd1b763c</guid>
            <category><![CDATA[ctf]]></category>
            <category><![CDATA[cloud-computing]]></category>
            <category><![CDATA[hacking]]></category>
            <category><![CDATA[cybersecurity]]></category>
            <category><![CDATA[walkthrough]]></category>
            <dc:creator><![CDATA[Anthony "RedHatAugust" Radzykewycz]]></dc:creator>
            <pubDate>Tue, 14 Oct 2025 02:26:04 GMT</pubDate>
            <atom:updated>2025-10-14T02:48:45.906Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*gWXwuqkndcTD-7BA.jpg" /><figcaption>ProtoVault Breach</figcaption></figure><p>This is the first week of The Gauntlet challenges. In this, we’ll look at a data breach where malicious actors obtained a database leak and track where the leak was.</p><p>If you’d like to see a video of this, scroll to the bottom.</p><h3><strong>The Story</strong></h3><blockquote><strong>About this lab</strong></blockquote><blockquote>In the storm-battered depths of a discreet mountain peak range, lies <strong>ProtoVault</strong>, an arcane sanctuary governed by the secretive guild known as the <strong>Everbound Order</strong>. They safeguard some of the most hidden knowledge across the Cyber Realms. Its defenses are forged in dragonfire and sealed with runes that demand the blood, breath, and soulprint of their masters.</blockquote><blockquote>But magic can’t guard everything.</blockquote><blockquote>Whispers ripple through the cyber realm. The vault’s inner sanctuary has been breached. A ransom scroll claims access to the <strong>Corespell</strong> — the foundational arcane code for ProtoVault — and issues a chilling demand:</blockquote><blockquote><strong><em>“Surrender the Archivist Verin.”</em></strong></blockquote><blockquote>Verin holds command over the hidden vaults — each safeguarding knowledge not meant to be accessed, but to protect the balance of the Cyber Realms.</blockquote><blockquote>If Verin isn’t given over, the ProtoVault could unravel everything they were built to defend.</blockquote><blockquote>AnchorHelm, an OffSec Legend, has summoned you, a skilled codecaster, to stop this before it goes any further.</blockquote><h3><strong>Getting Started</strong></h3><p>The first thing we need to do is check out the Lab Instructions and download the provided files for the upcoming lab activity. After clicking the “Lab Instructions” tab, we’re presented with the following:</p><blockquote>Download the ZIP package. The password is “<strong>BloodBreathSoulFire</strong>”.</blockquote><blockquote>You’ve been tasked with tracing the origin of the breach and uncovering the vulnerability before the anonymous adversary can exploit it further — all while protecting the Order’s secrets without giving in to their demands.</blockquote><blockquote>Two clues are in your possession:</blockquote><blockquote>The <strong>ransom scroll</strong> (email)</blockquote><blockquote>The <strong>source glyphs</strong> of the <strong>Corespell</strong> (application code)</blockquote><blockquote>Find the leak. Seal the breach. Keep the Order’s secrets from falling into the wrong hands.</blockquote><p>This seems like a pretty standard instruction set, where we download the ZIP package and can extract it with the provided password. Completing this, reveals the following image of a ransomware e-mail:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*udAQEwWKORGtL4kCS66t9g.png" /></figure><p>It looks like the ransom actors got a copy of a database and are able to read it in plaintext.</p><p>We also get a source_code.zip file. Since I prefer to work in Kali Linux on hacking activities, I’ll just copy that source_code.zip file into my Kali machine and work from it in there.</p><h3>Question 1:</h3><blockquote>Determine if the leak could have come from the application. Review the database connection string to ensure it is secure. Submit the connection string here.</blockquote><p>Since we have the <em>source_code.zip</em> file provided in this exercise, let’s unzip it in a directory that we can work from. In my case, I’ll create a directory to use as a workspace for this lab and navigate to it:</p><pre>┌──(kali㉿kali)-[~]<br>└─$ mkdir -p Documents/OffSec/TheGauntlet/ProtoVaultBreach<br><br>┌──(kali㉿kali)-[~]<br>└─$ cd Documents/OffSec/TheGauntlet/ProtoVaultBreach <br>                                                                                                                                                                                                                                                                                                                                                                                                                                          <br>┌──(kali㉿kali)-[~/Documents/OffSec/TheGauntlet/ProtoVaultBreach]<br>└─$</pre><p>Since I copied the <em>source_code.zip </em>file onto my Desktop, I’ll put that in my workspace directory and unzip it:</p><pre>┌──(kali㉿kali)-[~/Documents/OffSec/TheGauntlet/ProtoVaultBreach]<br>└─$ mv ~/Desktop/source_code.zip .                  <br>                                                                                                                                                                                                                                                                                                                                                                                                                                          <br>┌──(kali㉿kali)-[~/Documents/OffSec/TheGauntlet/ProtoVaultBreach]<br>└─$ unzip source_code.zip <br>Archive:  source_code.zip<br>   creating: .git/<br>  inflating: .git/config             <br>   creating: .git/logs/<br>  inflating: .git/logs/HEAD <br>...</pre><p>We can now analyze the zip file contents:</p><pre>┌──(kali㉿kali)-[~/Documents/OffSec/TheGauntlet/ProtoVaultBreach]<br>└─$ ls -al<br>total 100<br>drwxrwxr-x 4 kali kali  4096 Oct 10 18:59 .<br>drwxrwxr-x 3 kali kali  4096 Oct 10 16:31 ..<br>drwxrwxr-x 4 kali kali  4096 Sep 16 09:14 app<br>drwxrwxr-x 8 kali kali  4096 Sep 16 09:14 .git<br>-rw-r--r-- 1 kali kali    59 Sep 16 09:14 requirements.txt<br>-rw-rw-r-- 1 kali kali 78226 Oct 10 18:59 source_code.zip</pre><p>In this, we can see an <em>app </em>directory and also a Git repository. For the first question, which is asking if a leak could have come from the application, let’s check the <em>app </em>directory out.</p><pre>┌──(kali㉿kali)-[~/…/OffSec/TheGauntlet/ProtoVaultBreach/app]<br>└─$ ls -al<br>total 28<br>drwxrwxr-x 4 kali kali 4096 Sep 16 09:14 .<br>drwxrwxr-x 4 kali kali 4096 Oct 10 18:59 ..<br>-rw-r--r-- 1 kali kali 5308 Sep 16 09:14 app.py<br>-rw-r--r-- 1 kali kali 1027 Sep 16 09:14 forms.py<br>-rw-r--r-- 1 kali kali    0 Sep 16 09:14 __init__.py<br>drwxrwxr-x 2 kali kali 4096 Sep 16 09:14 templates<br>drwxrwxr-x 2 kali kali 4096 Sep 16 09:14 util<br><br>┌──(kali㉿kali)-[~/…/OffSec/TheGauntlet/ProtoVaultBreach/app]<br>└─$ ls -al templates <br>total 28<br>drwxrwxr-x 2 kali kali 4096 Sep 16 09:14 .<br>drwxrwxr-x 4 kali kali 4096 Sep 16 09:14 ..<br>-rw-r--r-- 1 kali kali 1535 Sep 16 09:14 base.html<br>-rw-r--r-- 1 kali kali 2200 Sep 16 09:14 category.html<br>-rw-r--r-- 1 kali kali  406 Sep 16 09:14 index.html<br>-rw-r--r-- 1 kali kali 1040 Sep 16 09:14 item_detail.html<br>-rw-r--r-- 1 kali kali  459 Sep 16 09:14 login.html<br>                                                                                                                                                                                                                                                                                                                                                                                                                                          <br>┌──(kali㉿kali)-[~/…/OffSec/TheGauntlet/ProtoVaultBreach/app]<br>└─$ ls -al util     <br>total 8<br>drwxrwxr-x 2 kali kali 4096 Sep 16 09:14 .<br>drwxrwxr-x 4 kali kali 4096 Sep 16 09:14 ..</pre><p>There are a couple of Python scripts, along with some HTML files that we can evaluate. Let’s look at <em>app.py </em>first:</p><pre>┌──(kali㉿kali)-[~/…/OffSec/TheGauntlet/ProtoVaultBreach/app]<br>└─$ cat app.py <br>from flask import Flask, render_template, redirect, url_for, request, flash<br>from flask_sqlalchemy import SQLAlchemy<br>from flask_login import LoginManager, login_user, logout_user, login_required, current_user, UserMixin<br>from werkzeug.security import generate_password_hash, check_password_hash<br>from forms import LoginForm, NoteForm, ItemForm<br><br>app = Flask(__name__)<br>app.config[&#39;SECRET_KEY&#39;] = &#39;a50deccc7fc4cc5d36ec28f3ffcc27fe6a515b5cd714a5b809fa6f1123aeb227&#39;<br>app.config[&#39;SQLALCHEMY_DATABASE_URI&#39;] = &#39;postgresql://assetdba:8d631d2207ec1debaafd806822122250@pgsql_prod_db01.protoguard.local/pgamgt?sslmode=verify-full&#39;<br>app.config[&#39;SQLALCHEMY_TRACK_MODIFICATIONS&#39;] = False<br>db = SQLAlchemy(app)<br><br><br># Data Models<br>class User(UserMixin, db.Model):<br>    __tablename__ = &quot;users&quot;<br>    id = db.Column(db.Integer, primary_key=True)<br>    first_name = db.Column(db.String(150), nullable=False)<br>    last_name = db.Column(db.String(150), nullable=False)<br>    specialty = db.Column(db.String(150), nullable=False)<br>    username = db.Column(db.String(150), unique=True, nullable=False)<br>    password_hash = db.Column(db.String(200), nullable=False)<br><br>    def set_password(self, password):<br>        self.password_hash = generate_password_hash(password)<br><br>    def check_password(self, password):<br>        return check_password_hash(self.password_hash, password)<br><br><br>class ItemType(db.Model):<br>    __tablename__ = &quot;item_types&quot;<br>    id = db.Column(db.Integer, primary_key=True)<br>    name = db.Column(db.String(128), nullable=False)<br>    description = db.Column(db.Text, nullable=False)<br><br><br>class Item(db.Model):<br>    __tablename__ = &quot;items&quot;<br>    id = db.Column(db.Integer, primary_key=True)<br>    type_id = db.Column(db.Integer, db.ForeignKey(&#39;item_types.id&#39;), nullable=False)<br>    code = db.Column(db.Text, nullable=False)<br>    name = db.Column(db.Text, nullable=False)<br>    classification = db.Column(db.Text, nullable=False)<br>    latitude = db.Column(db.Float)<br>    longitude = db.Column(db.Float)<br><br><br>class Note(db.Model):<br>    __tablename__ = &quot;notes&quot;<br>    id = db.Column(db.Integer, primary_key=True)<br>    item_id = db.Column(db.Integer, db.ForeignKey(&#39;items.id&#39;), nullable=False)<br>    note = db.Column(db.Text, nullable=False)<br><br>login_manager = LoginManager(app)<br>login_manager.login_view = &#39;login&#39;<br><br><br>@login_manager.user_loader<br>def load_user(user_id):<br>    return User.query.get(int(user_id))<br><br><br>@app.route(&#39;/&#39;)<br>@login_required<br>def index():<br>    session = db.session<br>    item_types = session.query(ItemType).order_by(ItemType.name.desc()).all()<br>    return render_template(&#39;index.html&#39;, item_types=item_types)<br><br><br>@app.route(&#39;/login&#39;, methods=[&#39;GET&#39;, &#39;POST&#39;])<br>def login():<br>    form = LoginForm()<br>    if form.validate_on_submit():<br>        user = User.query.filter_by(username=form.username.data).first()<br>        if user and user.check_password(form.password.data):<br>            login_user(user)<br>            return redirect(url_for(&#39;index&#39;))<br>        flash(&#39;Invalid username or password.&#39;, &#39;danger&#39;)<br>    return render_template(&#39;login.html&#39;, form=form)<br><br><br>@app.route(&#39;/logout&#39;)<br>@login_required<br>def logout():<br>    logout_user()<br>    return redirect(url_for(&#39;login&#39;))<br><br><br>@app.route(&#39;/category/&lt;int:item_type_id&gt;&#39;)<br>@login_required<br>def item_categories(item_type_id):<br>    session = db.session<br>    item_type = session.query(ItemType).filter_by(id=item_type_id).one()<br>    items = session.query(Item).filter_by(type_id=item_type_id).order_by(Item.code.asc()).all()<br>    <br>    return render_template(&#39;category.html&#39;, type=item_type, items=items)<br><br><br>@app.route(&#39;/items&#39;,  methods=[&#39;POST&#39;])<br>@login_required<br>def add_item():<br>    session = db.session<br><br>    type_id = request.form[&quot;type_id&quot;]<br>    <br>    try:<br>        code = request.form[&quot;code&quot;]<br>        classification = request.form[&quot;classification&quot;]<br>        name = request.form[&quot;name&quot;]<br>        latitude = request.form[&quot;latitude&quot;]<br>        longitude = request.form[&quot;longitude&quot;]<br><br>        item = Item(type_id=type_id, code=code, classification=classification, name=name, latitude=latitude, longitude=longitude)<br>        session.add(item)<br>        session.commit()<br>        flash(&quot;New item added.&quot;)<br>    except Exception as e:<br>        flash(&quot;An error occurred. Please try again later.&quot;)<br>        return redirect(f&quot;/category/{type_id}&quot;)<br><br>    return redirect(f&quot;/category/{type_id}&quot;)<br><br><br>@app.route(&#39;/items/&lt;int:item_id&gt;&#39;)<br>@login_required<br>def item_details(item_id):<br>    session = db.session<br>    item = session.query(Item).filter_by(id=item_id).one()<br><br>    item_type = session.query(ItemType).filter_by(id=item.type_id).one()<br>    <br>    notes = session.query(Note).filter_by(item_id=item_id).order_by(Note.id.desc()).all()<br>    <br>    form = NoteForm()<br><br>    return render_template(&#39;item_detail.html&#39;, type=item_type, item=item, notes=notes, form=form)<br><br><br>@app.route(&#39;/items/&lt;int:item_id&gt;/addNote&#39;,  methods=[&#39;POST&#39;])<br>@login_required<br>def add_note(item_id):<br>    session = db.session<br>    item = session.query(Item).filter_by(id=item_id).one()<br><br>    try:<br>        note_text = request.form[&quot;note&quot;]<br>        note = Note(item_id=item_id, note=note_text)<br>        session.add(note)<br>        session.commit()<br>        flash(&quot;Note added.&quot;)<br>    except:<br>        flash(&quot;An error occurred. Please try again later.&quot;)<br>        return redirect(f&quot;/items/{item_id}&quot;)<br><br>    return redirect(f&quot;/items/{item_id}&quot;)<br><br><br>if __name__ == &#39;__main__&#39;:<br>    app.run(debug=False, host=&#39;127.0.0.1&#39;, port=8000)</pre><p>It looks like a Flask application. The main thing to focus on in this file is that there is the secret key and database in clear text in this application.</p><pre>...<br>app = Flask(__name__)<br>app.config[&#39;SECRET_KEY&#39;] = &#39;a50deccc7fc4cc5d36ec28f3ffcc27fe6a515b5cd714a5b809fa6f1123aeb227&#39;<br>app.config[&#39;SQLALCHEMY_DATABASE_URI&#39;] = &#39;postgresql://assetdba:8d631d2207ec1debaafd806822122250@pgsql_prod_db01.protoguard.local/pgamgt?sslmode=verify-full&#39;<br>app.config[&#39;SQLALCHEMY_TRACK_MODIFICATIONS&#39;] = False<br>db = SQLAlchemy(app)<br>...</pre><p>The question is asking for the database connection string, so let’s copy the respective line into the answer box.</p><pre>app.config[&#39;SQLALCHEMY_DATABASE_URI&#39;] = &#39;postgresql://assetdba:8d631d2207ec1debaafd806822122250@pgsql_prod_db01.protoguard.local/pgamgt?sslmode=verify-full&#39;</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*bq5-StUC3YifInZJpfrSpw.png" /><figcaption>Question 1 Complete</figcaption></figure><p>With this, our first answer is completed. The leak could have come from this application where the database connection string along with it’s secret key were stored in plaintext — an insecure coding practice.</p><h3>Question 2:</h3><blockquote>Review the other source files. Which one may have leaked the database? Provide the file name.</blockquote><p>Since we covered the <em>app.py</em> file already, this question is asking for “the other source files.” Currently, we are able to see the HTML files along with the <em>forms.py </em>file.</p><p>To save us time and sanity, I won’t be putting those contents in this article. The bottom line is that they don’t reveal anything new or useful to answering the question. None of these files actually are the source of the database leak.</p><p>Hmm… where to go from here?</p><p>Let’s back out of the <em>app</em> directory and get a reminder of what’s there:</p><pre>┌──(kali㉿kali)-[~/…/OffSec/TheGauntlet/ProtoVaultBreach/app]<br>└─$ cd ..       <br>                                                                                                                                                                                                                                                                                                                                                                                                                                          <br>┌──(kali㉿kali)-[~/Documents/OffSec/TheGauntlet/ProtoVaultBreach]<br>└─$ ls -al     <br>total 100<br>drwxrwxr-x 4 kali kali  4096 Oct 10 18:59 .<br>drwxrwxr-x 3 kali kali  4096 Oct 10 16:31 ..<br>drwxrwxr-x 4 kali kali  4096 Sep 16 09:14 app<br>drwxrwxr-x 8 kali kali  4096 Sep 16 09:14 .git<br>-rw-r--r-- 1 kali kali    59 Sep 16 09:14 requirements.txt<br>-rw-rw-r-- 1 kali kali 78226 Oct 10 18:59 source_code.zip</pre><p>Aw, yes! This appeared to be a Git repository, so we can check out a few things related to the repository information. Let’s take a look to see if there are any commit<em> </em>logs here:</p><pre>┌──(kali㉿kali)-[~/Documents/OffSec/TheGauntlet/ProtoVaultBreach]<br>└─$ cat .git/logs/HEAD<br>0000000000000000000000000000000000000000 444eb3acdc1af6c6beab3ce8f3a6881b18a2a3e8 Walter &lt;walter.s@protoguard.local&gt; 1727791200 -0500   commit (initial): Initial commit: Flask app scaffold<br>444eb3acdc1af6c6beab3ce8f3a6881b18a2a3e8 3654766dd5a0b7d51249247bfc26e780133cefc8 Walter &lt;walter.s@protoguard.local&gt; 1727968500 -0500   commit: UI refactor<br>3654766dd5a0b7d51249247bfc26e780133cefc8 5fe83a81198bfb61626a52c912a841364b9aa563 Walter &lt;walter.s@protoguard.local&gt; 1728145380 -0500   commit: Add authentication<br>5fe83a81198bfb61626a52c912a841364b9aa563 b32d77d6fcfcf3ee3681acc930678ad7fe2e1a29 Walter &lt;walter.s@protoguard.local&gt; 1728228060 -0500   commit: database migration scripts<br>b32d77d6fcfcf3ee3681acc930678ad7fe2e1a29 f22ba8adb8e9b1180b44744c66bfbd0ef192381c Walter &lt;walter.s@protoguard.local&gt; 1728312300 -0500   commit: Add data models<br>f22ba8adb8e9b1180b44744c66bfbd0ef192381c 9f257d253fc6c15860d2e24941b66ab0733e72aa Walter &lt;walter.s@protoguard.local&gt; 1728748260 -0500   commit: Add item details and notes forms<br>9f257d253fc6c15860d2e24941b66ab0733e72aa 8fe1a4431337ecf4bc9759672579168b03351fb6 Walter &lt;walter.s@protoguard.local&gt; 1728916320 -0500   commit: Remove backup scripts<br>8fe1a4431337ecf4bc9759672579168b03351fb6 a230bbc140cf8a9f60b5d54ca979259c88182470 Walter &lt;walter.s@protoguard.local&gt; 1729177920 -0500   commit: Release candidate<br>a230bbc140cf8a9f60b5d54ca979259c88182470 1cd3a17bdfe65ce49e50e9c29e180083113c2a65 Walter &lt;walter.s@protoguard.local&gt; 1727791200 -0500   commit: Initial commit: Flask app scaffold<br>1cd3a17bdfe65ce49e50e9c29e180083113c2a65 6106ded41a6ad0250355eee7a4e64f2cebcafc67 Walter &lt;walter.s@protoguard.local&gt; 1727968500 -0500   commit: UI refactor<br>6106ded41a6ad0250355eee7a4e64f2cebcafc67 b461ed0095f5856062086c6a212b7220ede74a3c Walter &lt;walter.s@protoguard.local&gt; 1728145380 -0500   commit: Add authentication<br>b461ed0095f5856062086c6a212b7220ede74a3c d0aa089caddae1735a476954c6c60f469c864f9a Walter &lt;walter.s@protoguard.local&gt; 1728228060 -0500   commit: database migration scripts<br>d0aa089caddae1735a476954c6c60f469c864f9a 5ad3c0672f4597e59e11f09ad1d1081fa2a7afbe Walter &lt;walter.s@protoguard.local&gt; 1728312300 -0500   commit: Add data models<br>5ad3c0672f4597e59e11f09ad1d1081fa2a7afbe 6a65249cdd767ab4faf28e4ee88d710e863c09b1 Walter &lt;walter.s@protoguard.local&gt; 1728748260 -0500   commit: Add item details and notes forms<br>6a65249cdd767ab4faf28e4ee88d710e863c09b1 57b06cb8cc2523705ee238d4c4407af6c6137171 Walter &lt;walter.s@protoguard.local&gt; 1728916320 -0500   commit: Remove backup scripts<br>57b06cb8cc2523705ee238d4c4407af6c6137171 6dcfe414a1e8676726c894050558376827753632 Walter &lt;walter.s@protoguard.local&gt; 1729177920 -0500   commit: Release candidate<br>6dcfe414a1e8676726c894050558376827753632 b400120c2c7b369ccd183755d1386fea285d1752 Walter &lt;walter.s@protoguard.local&gt; 1754056800 -0500   commit: Initial commit: Flask app scaffold<br>b400120c2c7b369ccd183755d1386fea285d1752 27199011b84edc7a603c763f61f7d4c81d1f1a59 Walter &lt;walter.s@protoguard.local&gt; 1754234100 -0500   commit: UI refactor<br>27199011b84edc7a603c763f61f7d4c81d1f1a59 503dba99c075a624731e99553d0f9233152bb34a Walter &lt;walter.s@protoguard.local&gt; 1754410980 -0500   commit: Add authentication<br>503dba99c075a624731e99553d0f9233152bb34a 9544195474e1c25ea8415b6b78b4035cf5268d1f Walter &lt;walter.s@protoguard.local&gt; 1754493660 -0500   commit: database migration scripts<br>9544195474e1c25ea8415b6b78b4035cf5268d1f 23040529e72d8797126d1c14b314ac6163b2c031 Walter &lt;walter.s@protoguard.local&gt; 1754577900 -0500   commit: Add data models<br>23040529e72d8797126d1c14b314ac6163b2c031 ef917bbffedf1638f5ce7747132942197ce97703 Walter &lt;walter.s@protoguard.local&gt; 1755013860 -0500   commit: Add item details and notes forms<br>ef917bbffedf1638f5ce7747132942197ce97703 1cc71b0fcfcdbfefc7b59cecd898f13b532acc35 Walter &lt;walter.s@protoguard.local&gt; 1755181920 -0500   commit: Remove backup scripts<br>1cc71b0fcfcdbfefc7b59cecd898f13b532acc35 ccd589a2e1ea6089b716f8b001f8031912784fa5 Walter &lt;walter.s@protoguard.local&gt; 1755443520 -0500   commit: Release candidate</pre><p>There sure are! We can see the git log commit history and comments inside the <em>.git/logs/HEAD</em> file. Looking at the comments for each commit, we can see that there were some scripts that were removed.</p><p>Might there be a way we can get those removed scripts back from those previous commits?</p><p>You bet there is! We can do this in several different ways, so let’s start with some built-in <em>git</em> commands. To start this off, we can execute <em>git log </em>to get the list of all the commit history logs from the branch we are currently in (<em>main</em>).</p><pre>┌──(kali㉿kali)-[~/Documents/OffSec/TheGauntlet/ProtoVaultBreach]<br>└─$ git log          <br>commit ccd589a2e1ea6089b716f8b001f8031912784fa5 (HEAD -&gt; main)<br>Author: Walter &lt;walter.s@protoguard.local&gt;<br>Date:   Sun Aug 17 10:12:00 2025 -0500<br><br>    Release candidate<br><br>commit 1cc71b0fcfcdbfefc7b59cecd898f13b532acc35<br>Author: Walter &lt;walter.s@protoguard.local&gt;<br>Date:   Thu Aug 14 09:32:00 2025 -0500<br><br>    Remove backup scripts<br><br>commit ef917bbffedf1638f5ce7747132942197ce97703<br>Author: Walter &lt;walter.s@protoguard.local&gt;<br>Date:   Tue Aug 12 10:51:00 2025 -0500<br><br>    Add item details and notes forms<br><br>commit 23040529e72d8797126d1c14b314ac6163b2c031<br>Author: Walter &lt;walter.s@protoguard.local&gt;<br>Date:   Thu Aug 7 09:45:00 2025 -0500<br><br>    Add data models<br><br>commit 9544195474e1c25ea8415b6b78b4035cf5268d1f<br>Author: Walter &lt;walter.s@protoguard.local&gt;<br>Date:   Wed Aug 6 10:21:00 2025 -0500<br>:...skipping...<br>commit ccd589a2e1ea6089b716f8b001f8031912784fa5 (HEAD -&gt; main)                                                                                                                                                                                                                                                                                                                                                                            <br>Author: Walter &lt;walter.s@protoguard.local&gt;                                                                                                                                                                                                                                                                                                                                                                                                <br>Date:   Sun Aug 17 10:12:00 2025 -0500                                                                                                                                                                                                                                                                                                                                                                                                    <br>                                                                                                                                                                                                                                                                                                                                                                                                                                          <br>    Release candidate                                                                                                                                                                                                                                                                                                                                                                                                                     <br>                                                                                                                                                                                                                                                                                                                                                                                                                                          <br>commit 1cc71b0fcfcdbfefc7b59cecd898f13b532acc35                                                                                                                                                                                                                                                                                                                                                                                           <br>Author: Walter &lt;walter.s@protoguard.local&gt;                                                                                                                                                                                                                                                                                                                                                                                                <br>Date:   Thu Aug 14 09:32:00 2025 -0500                                                                                                                                                                                                                                                                                                                                                                                                    <br>                                                                                                                                                                                                                                                                                                                                                                                                                                          <br>    Remove backup scripts                                                                                                                                                                                                                                                                                                                                                                                                                 <br>                                                                                                                                                                                                                                                                                                                                                                                                                                          <br>commit ef917bbffedf1638f5ce7747132942197ce97703                                                                                                                                                                                                                                                                                                                                                                                           <br>Author: Walter &lt;walter.s@protoguard.local&gt;                                                                                                                                                                                                                                                                                                                                                                                                <br>Date:   Tue Aug 12 10:51:00 2025 -0500                                                                                                                                                                                                                                                                                                                                                                                                    <br>                                                                                                                                                                                                                                                                                                                                                                                                                                          <br>    Add item details and notes forms                                                                                                                                                                                                                                                                                                                                                                                                      <br>                                                                                                                                                                                                                                                                                                                                                                                                                                          <br>commit 23040529e72d8797126d1c14b314ac6163b2c031                                                                                                                                                                                                                                                                                                                                                                                           <br>Author: Walter &lt;walter.s@protoguard.local&gt;                                                                                                                                                                                                                                                                                                                                                                                                <br>Date:   Thu Aug 7 09:45:00 2025 -0500                                                                                                                                                                                                                                                                                                                                                                                                     <br>                                                                                                                                                                                                                                                                                                                                                                                                                                          <br>    Add data models                                                                                                                                                                                                                                                                                                                                                                                                                       <br>                                                                                                                                                                                                                                                                                                                                                                                                                                          <br>commit 9544195474e1c25ea8415b6b78b4035cf5268d1f                                                                                                                                                                                                                                                                                                                                                                                           <br>Author: Walter &lt;walter.s@protoguard.local&gt;                                                                                                                                                                                                                                                                                                                                                                                                <br>Date:   Wed Aug 6 10:21:00 2025 -0500                                                                                                                                                                                                                                                                                                                                                                                                     <br>                                                                                                                                                                                                                                                                                                                                                                                                                                          <br>    database migration scripts                                                                                                                                                                                                                                                                                                                                                                                                            <br>                                                                                                                                                                                                                                                                                                                                                                                                                                          <br>commit 503dba99c075a624731e99553d0f9233152bb34a                                                                                                                                                                                                                                                                                                                                                                                           <br>Author: Walter &lt;walter.s@protoguard.local&gt;                                                                                                                                                                                                                                                                                                                                                                                                <br>Date:   Tue Aug 5 11:23:00 2025 -0500                                                                                                                                                                                                                                                                                                                                                                                                     <br>                                                                                                                                                                                                                                                                                                                                                                                                                                          <br>    Add authentication                                                                                                                                                                                                                                                                                                                                                                                                                    <br>                                                                                                                                                                                                                                                                                                                                                                                                                                          <br>commit 27199011b84edc7a603c763f61f7d4c81d1f1a59                                                                                                                                                                                                                                                                                                                                                                                           <br>Author: Walter &lt;walter.s@protoguard.local&gt;                                                                                                                                                                                                                                                                                                                                                                                                <br>Date:   Sun Aug 3 10:15:00 2025 -0500                                                                                                                                                                                                                                                                                                                                                                                                     <br>                                                                                                                                                                                                                                                                                                                                                                                                                                          <br>    UI refactor                                                                                                                                                                                                                                                                                                                                                                                                                           <br>                                                                                                                                                                                                                                                                                                                                                                                                                                          <br>commit b400120c2c7b369ccd183755d1386fea285d1752                                                                                                                                                                                                                                                                                                                                                                                           <br>Author: Walter &lt;walter.s@protoguard.local&gt;                                                                                                                                                                                                                                                                                                                                                                                                <br>Date:   Fri Aug 1 09:00:00 2025 -0500                                                                                                                                                                                                                                                                                                                                                                                                     <br>                                                                                                                                                                                                                                                                                                                                                                                                                                          <br>    Initial commit: Flask app scaffold                                                                                                                                                                                                                                                                                                                                                                                                    <br><br>commit 6dcfe414a1e8676726c894050558376827753632<br>Author: Walter &lt;walter.s@protoguard.local&gt;<br>Date:   Thu Oct 17 10:12:00 2024 -0500<br><br>    Release candidate<br><br>commit 57b06cb8cc2523705ee238d4c4407af6c6137171<br>Author: Walter &lt;walter.s@protoguard.local&gt;<br>Date:   Mon Oct 14 09:32:00 2024 -0500<br><br>    Remove backup scripts<br><br>commit 6a65249cdd767ab4faf28e4ee88d710e863c09b1<br>Author: Walter &lt;walter.s@protoguard.local&gt;<br>Date:   Sat Oct 12 10:51:00 2024 -0500<br><br>    Add item details and notes forms<br><br>commit 5ad3c0672f4597e59e11f09ad1d1081fa2a7afbe<br>Author: Walter &lt;walter.s@protoguard.local&gt;<br>Date:   Mon Oct 7 09:45:00 2024 -0500<br><br>    Add data models<br><br>commit d0aa089caddae1735a476954c6c60f469c864f9a<br>Author: Walter &lt;walter.s@protoguard.local&gt;<br>Date:   Sun Oct 6 10:21:00 2024 -0500<br><br>    database migration scripts<br><br>commit b461ed0095f5856062086c6a212b7220ede74a3c<br>Author: Walter &lt;walter.s@protoguard.local&gt;<br>Date:   Sat Oct 5 11:23:00 2024 -0500<br><br>    Add authentication<br><br>commit 6106ded41a6ad0250355eee7a4e64f2cebcafc67<br>Author: Walter &lt;walter.s@protoguard.local&gt;<br>Date:   Thu Oct 3 10:15:00 2024 -0500<br><br>    UI refactor<br><br>commit 1cd3a17bdfe65ce49e50e9c29e180083113c2a65<br>Author: Walter &lt;walter.s@protoguard.local&gt;<br>Date:   Tue Oct 1 09:00:00 2024 -0500<br><br>    Initial commit: Flask app scaffold<br><br>commit a230bbc140cf8a9f60b5d54ca979259c88182470<br>Author: Walter &lt;walter.s@protoguard.local&gt;<br>Date:   Thu Oct 17 10:12:00 2024 -0500<br><br>    Release candidate<br><br>commit 8fe1a4431337ecf4bc9759672579168b03351fb6<br>Author: Walter &lt;walter.s@protoguard.local&gt;<br>Date:   Mon Oct 14 09:32:00 2024 -0500<br><br>    Remove backup scripts<br><br>commit 9f257d253fc6c15860d2e24941b66ab0733e72aa<br>Author: Walter &lt;walter.s@protoguard.local&gt;<br>Date:   Sat Oct 12 10:51:00 2024 -0500<br><br>    Add item details and notes forms<br><br>commit f22ba8adb8e9b1180b44744c66bfbd0ef192381c<br>Author: Walter &lt;walter.s@protoguard.local&gt;<br>Date:   Mon Oct 7 09:45:00 2024 -0500<br><br>    Add data models<br><br>commit b32d77d6fcfcf3ee3681acc930678ad7fe2e1a29<br>Author: Walter &lt;walter.s@protoguard.local&gt;<br>Date:   Sun Oct 6 10:21:00 2024 -0500<br><br>    database migration scripts<br><br>commit 5fe83a81198bfb61626a52c912a841364b9aa563<br>Author: Walter &lt;walter.s@protoguard.local&gt;<br>Date:   Sat Oct 5 11:23:00 2024 -0500<br><br>    Add authentication<br><br>commit 3654766dd5a0b7d51249247bfc26e780133cefc8<br>Author: Walter &lt;walter.s@protoguard.local&gt;<br>Date:   Thu Oct 3 10:15:00 2024 -0500<br><br>    UI refactor<br><br>commit 444eb3acdc1af6c6beab3ce8f3a6881b18a2a3e8<br>Author: Walter &lt;walter.s@protoguard.local&gt;<br>Date:   Tue Oct 1 09:00:00 2024 -0500<br><br>    Initial commit: Flask app scaffold<br>(END)</pre><p>This is a lot more to look at, which is why I prefer to read the <em>HEAD</em> file, first. Despite us having an indication of where we may want to go, I want to cover a nice tool we can use to try to find valuable information in a Git repository: <strong>Git-secrets</strong>.</p><h3><strong>Git-secrets:</strong></h3><p>Before we can use the <em>git secrets</em> command, we need to install the package. Let’s do that now:</p><pre>┌──(kali㉿kali)-[~/Documents/OffSec/TheGauntlet/ProtoVaultBreach]<br>└─$ sudo apt install git-secrets<br>[sudo] password for kali: <br>The following packages were automatically installed and are no longer required:<br>  amass-common  libbson-1.0-0t64  libjs-underscore    libmongocrypt0  libportmidi0  libtheoradec1  libudfread0  libxml2   python3-bluepy         python3-gpg                    python3-kismetcapturefreaklabszigbee  python3-kismetcapturertladsb  python3-protobuf    samba-ad-dc         samba-dsdb-modules<br>  libbluray2    libjs-jquery-ui   libmongoc-1.0-0t64  libplacebo349   librav1e0.7   libtheoraenc1  libx264-164  libyelp0  python3-click-plugins  python3-kismetcapturebtgeiger  python3-kismetcapturertl433           python3-kismetcapturertlamr   python3-zombie-imp  samba-ad-provision<br>Use &#39;sudo apt autoremove&#39; to remove them.<br><br>Installing:<br>  git-secrets<br>...</pre><p>Now that it is installed, let’s install it in the base of the Git repository we are currently in. We can accomplish this by executing <em>git secrets — install</em>.</p><pre>┌──(kali㉿kali)-[~/Documents/OffSec/TheGauntlet/ProtoVaultBreach]<br>└─$ git secrets --install<br>✓ Installed commit-msg hook to .git/hooks/commit-msg<br>✓ Installed pre-commit hook to .git/hooks/pre-commit<br>✓ Installed prepare-commit-msg hook to .git/hooks/prepare-commit-msg</pre><p>In case there are any AWS keys that are leaked, let’s have git secrets automatically check for AWS-related configurations. While we are at it, let’s also add the keywords of “password” and “SECRET_KEY”.</p><pre>┌──(kali㉿kali)-[~/Documents/OffSec/TheGauntlet/ProtoVaultBreach]<br>└─$ git secrets --register-aws<br>OK<br>                                                                                                                                                                                                                                                                                                                                                                                                                                          <br>┌──(kali㉿kali)-[~/Documents/OffSec/TheGauntlet/ProtoVaultBreach]<br>└─$ git secrets --add &#39;password=&#39;<br>                                                                                                                                                                                                                                                                                                                                                                                                                                          <br>┌──(kali㉿kali)-[~/Documents/OffSec/TheGauntlet/ProtoVaultBreach]<br>└─$ git secrets --add &#39;SECRET_KEY&#39;</pre><p>Now that those keyword searches and patterns are added, we can scan our repository:</p><pre>┌──(kali㉿kali)-[~/Documents/OffSec/TheGauntlet/ProtoVaultBreach]<br>└─$ git secrets --scan            <br>app/app.py:8:app.config[&#39;SECRET_KEY&#39;] = &#39;a50deccc7fc4cc5d36ec28f3ffcc27fe6a515b5cd714a5b809fa6f1123aeb227&#39;<br><br>[ERROR] Matched one or more prohibited patterns<br><br>Possible mitigations:<br>- Mark false positives as allowed using: git config --add secrets.allowed ...<br>- Mark false positives as allowed by adding regular expressions to .gitallowed at repository&#39;s root directory<br>- List your configured patterns: git config --get-all secrets.patterns<br>- List your configured allowed patterns: git config --get-all secrets.allowed<br>- List your configured allowed patterns in .gitallowed at repository&#39;s root directory<br>- Use --no-verify if this is a one-time false positive</pre><p>This didn’t reveal anything that we didn’t know after our manual code review. To go deeper, we can scan the history of the Git repository:</p><pre>┌──(kali㉿kali)-[~/Documents/OffSec/TheGauntlet/ProtoVaultBreach]<br>└─$ git secrets --scan-history<br>ccd589a2e1ea6089b716f8b001f8031912784fa5:app/app.py:8:app.config[&#39;SECRET_KEY&#39;] = &#39;a50deccc7fc4cc5d36ec28f3ffcc27fe6a515b5cd714a5b809fa6f1123aeb227&#39;<br>503dba99c075a624731e99553d0f9233152bb34a:app/app.py:9:app.config[&#39;SECRET_KEY&#39;] = &#39;supersecretkey&#39;<br>b400120c2c7b369ccd183755d1386fea285d1752:app/app.py:5:app.config[&#39;SECRET_KEY&#39;] = &#39;changeme&#39;<br>6dcfe414a1e8676726c894050558376827753632:app/app.py:8:app.config[&#39;SECRET_KEY&#39;] = &#39;a50deccc7fc4cc5d36ec28f3ffcc27fe6a515b5cd714a5b809fa6f1123aeb227&#39;<br>b461ed0095f5856062086c6a212b7220ede74a3c:app/app.py:9:app.config[&#39;SECRET_KEY&#39;] = &#39;supersecretkey&#39;<br>1cd3a17bdfe65ce49e50e9c29e180083113c2a65:app/app.py:5:app.config[&#39;SECRET_KEY&#39;] = &#39;changeme&#39;<br>a230bbc140cf8a9f60b5d54ca979259c88182470:app/app.py:8:app.config[&#39;SECRET_KEY&#39;] = &#39;a50deccc7fc4cc5d36ec28f3ffcc27fe6a515b5cd714a5b809fa6f1123aeb227&#39;<br>5fe83a81198bfb61626a52c912a841364b9aa563:app/app.py:9:app.config[&#39;SECRET_KEY&#39;] = &#39;supersecretkey&#39;<br>444eb3acdc1af6c6beab3ce8f3a6881b18a2a3e8:app/app.py:5:app.config[&#39;SECRET_KEY&#39;] = &#39;changeme&#39;<br><br>[ERROR] Matched one or more prohibited patterns<br><br>Possible mitigations:<br>- Mark false positives as allowed using: git config --add secrets.allowed ...<br>- Mark false positives as allowed by adding regular expressions to .gitallowed at repository&#39;s root directory<br>- List your configured patterns: git config --get-all secrets.patterns<br>- List your configured allowed patterns: git config --get-all secrets.allowed<br>- List your configured allowed patterns in .gitallowed at repository&#39;s root directory<br>- Use --no-verify if this is a one-time false positive</pre><p>What’s interesting about scanning the history in this way is that we see the <strong>‘SECRET_KEY’ </strong>value is changed in the commit history. It appears that the developer was possibly cycling through these values and could even be a way that credential reuse could be exploited through this finding. Regardless, it doesn’t appear that there are any further insights into finding where the actual database leak was found.</p><p>Let’s go back to built-in git commands and dig deeper.</p><h3><strong>Git Commit History Review:</strong></h3><p>We already covered <em>git log</em> and reading the <em>HEAD </em>commit history. Well, something we saw in the history was that scripts were removed in the process of developing the application. It’d be interesting to see those files, if we could somehow restore them, wouldn’t it?</p><p>Let’s run <em>git log</em> again, but this time with a summarized view on <strong>D</strong>eleted files:</p><pre>┌──(kali㉿kali)-[~/Documents/OffSec/TheGauntlet/ProtoVaultBreach]<br>└─$ git log --diff-filter=D --summary<br>commit 1cc71b0fcfcdbfefc7b59cecd898f13b532acc35<br>Author: Walter &lt;walter.s@protoguard.local&gt;<br>Date:   Thu Aug 14 09:32:00 2025 -0500<br><br>    Remove backup scripts<br><br> delete mode 100644 app/util/backup_db.py<br> delete mode 100644 app/util/restore_db.py<br><br>commit b400120c2c7b369ccd183755d1386fea285d1752<br>Author: Walter &lt;walter.s@protoguard.local&gt;<br>Date:   Fri Aug 1 09:00:00 2025 -0500<br><br>    Initial commit: Flask app scaffold<br><br> delete mode 100644 app/forms.py<br> delete mode 100644 app/templates/base.html<br> delete mode 100644 app/templates/category.html<br> delete mode 100644 app/templates/item_detail.html<br> delete mode 100644 app/templates/login.html<br><br>commit 57b06cb8cc2523705ee238d4c4407af6c6137171<br>Author: Walter &lt;walter.s@protoguard.local&gt;<br>Date:   Mon Oct 14 09:32:00 2024 -0500<br><br>    Remove backup scripts<br><br> delete mode 100644 app/util/backup_db.py<br> delete mode 100644 app/util/restore_db.py<br><br>commit 1cd3a17bdfe65ce49e50e9c29e180083113c2a65<br>Author: Walter &lt;walter.s@protoguard.local&gt;<br>Date:   Tue Oct 1 09:00:00 2024 -0500<br><br>    Initial commit: Flask app scaffold<br><br> delete mode 100644 app/forms.py<br> delete mode 100644 app/templates/base.html<br> delete mode 100644 app/templates/category.html<br> delete mode 100644 app/templates/item_detail.html<br> delete mode 100644 app/templates/login.html<br><br>commit 8fe1a4431337ecf4bc9759672579168b03351fb6<br>Author: Walter &lt;walter.s@protoguard.local&gt;<br>Date:   Mon Oct 14 09:32:00 2024 -0500<br><br>    Remove backup scripts<br><br> delete mode 100644 app/util/backup_db.py<br> delete mode 100644 app/util/restore_db.py</pre><p>Woah! Now, we can see the file names of the deleted files. <strong>app/util/backup_db.py </strong>and <strong>app/util/restore_db.py</strong> could be really interesting to check out.</p><p>The trick here is to refer back to the commit history and try to revert the Git repository branch back to a commit <em>before</em> the commit where the scripts were removed. We could have deduced this from the comment history, as well, but seeing the location of the files that were removed is a valuable insight. Let’s read the <em>.git/log/HEAD</em> file again:</p><pre>┌──(kali㉿kali)-[~/Documents/OffSec/TheGauntlet/ProtoVaultBreach]<br>└─$ cat .git/logs/HEAD      <br>...<br>9f257d253fc6c15860d2e24941b66ab0733e72aa 8fe1a4431337ecf4bc9759672579168b03351fb6 Walter &lt;walter.s@protoguard.local&gt; 1728916320 -0500   commit: Remove backup scripts<br>...<br>ef917bbffedf1638f5ce7747132942197ce97703 1cc71b0fcfcdbfefc7b59cecd898f13b532acc35 Walter &lt;walter.s@protoguard.local&gt; 1755181920 -0500   commit: Remove backup scripts<br>...</pre><p>If we evaluate the columns carefully in this, we can see which commits were the preceding commit and which one the commit was actually done.</p><p>In the case of our findings, the first commit that may have had the Python scripts in question may have been in commit <em>9f257d253fc6c15860d2e24941b66ab0733e72aa</em>.</p><p>We can change our branch to that commit in one of two different ways:</p><p><em>git checkout &lt;commit&gt;</em></p><p><em>or</em></p><p><em>git branch -c &lt;commit&gt;</em></p><p>Let’s try it with <em>checkout</em>:</p><pre>┌──(kali㉿kali)-[~/Documents/OffSec/TheGauntlet/ProtoVaultBreach]<br>└─$ git checkout 9f257d253fc6c15860d2e24941b66ab0733e72aa<br>Note: switching to &#39;9f257d253fc6c15860d2e24941b66ab0733e72aa&#39;.<br><br>You are in &#39;detached HEAD&#39; state. You can look around, make experimental<br>changes and commit them, and you can discard any commits you make in this<br>state without impacting any branches by switching back to a branch.<br><br>If you want to create a new branch to retain commits you create, you may<br>do so (now or later) by using -c with the switch command. Example:<br><br>  git switch -c &lt;new-branch-name&gt;<br><br>Or undo this operation with:<br><br>  git switch -<br><br>Turn off this advice by setting config variable advice.detachedHead to false<br><br>HEAD is now at 9f257d2 Add item details and notes forms</pre><p>Now that we are in that commit state, let’s check the <em>app/util/</em> directory to see if the files are there:</p><pre>┌──(kali㉿kali)-[~/Documents/OffSec/TheGauntlet/ProtoVaultBreach]<br>└─$ ls app/util <br>backup_db.py  restore_db.py</pre><p>There they are! Now we can read those to see if there is any indication on how the database may have been leaked. Let’s look at <em>backup_db.py </em>now:</p><pre>┌──(kali㉿kali)-[~/Documents/OffSec/TheGauntlet/ProtoVaultBreach]<br>└─$ cat app/util/backup_db.py <br>#!/usr/bin/env python3<br>import paramiko<br>import boto3<br>import codecs<br>import os<br>from scp import SCPClient<br><br># ==== CONFIGURATION ====<br>SSH_HOST = &quot;pgsql_prod_db01.protoguard.local&quot;<br>SSH_PORT = 22<br>SSH_USER = &quot;dbadmin&quot;<br>SSH_KEY = &quot;/home/walter/.ssh/pgsql_key&quot;<br><br>DB_NAME = &quot;pgamgt&quot;<br>DB_USER = &quot;assetdba&quot;<br>BACKUP_FILENAME = &quot;db_backup.sql&quot;<br>LOCAL_BACKUP = f&quot;/tmp/{BACKUP_FILENAME}&quot;<br>ENC_BACKUP = f&quot;/tmp/{BACKUP_FILENAME}.xyz&quot;<br><br>S3_BUCKET = &quot;pgamgt-backups&quot;<br>S3_KEY = &quot;latest_backup.xyz&quot;<br><br><br>def create_ssh_client():<br>    client = paramiko.SSHClient()<br>    client.set_missing_host_key_policy(paramiko.AutoAddPolicy())<br>    client.connect(SSH_HOST, port=SSH_PORT, username=SSH_USER, key_filename=SSH_KEY)<br>    return client<br><br><br>def run_backup():<br>    ssh = create_ssh_client()<br>    dump_cmd = f&quot;pg_dump -U {DB_USER} {DB_NAME} &gt; /tmp/{BACKUP_FILENAME}&quot;<br>    stdin, stdout, stderr = ssh.exec_command(dump_cmd)<br>    exit_code = stdout.channel.recv_exit_status()<br>    if exit_code != 0:<br>        print(&quot;[!] Error running pg_dump:&quot;, stderr.read().decode())<br>        ssh.close()<br>        return False<br><br>    # Copy file to local<br>    with SCPClient(ssh.get_transport()) as scp:<br>        scp.get(f&quot;/tmp/{BACKUP_FILENAME}&quot;, LOCAL_BACKUP)<br><br>    # Remove remote dump<br>    ssh.exec_command(f&quot;rm /tmp/{BACKUP_FILENAME}&quot;)<br>    ssh.close()<br>    return True<br><br><br>def encode():<br>    with open(LOCAL_BACKUP, &quot;r&quot;, encoding=&quot;utf-8&quot;, errors=&quot;ignore&quot;) as f:<br>        data = f.read()<br>    encoded = codecs.encode(data, &quot;rot_13&quot;)<br>    with open(ENC_BACKUP, &quot;w&quot;, encoding=&quot;utf-8&quot;) as f:<br>        f.write(encoded)<br><br><br>def upload_to_s3():<br>    s3 = boto3.client(&quot;s3&quot;)<br>    s3.upload_file(ENC_BACKUP, S3_BUCKET, S3_KEY)<br>    print(f&quot;[+] Uploaded {ENC_BACKUP} to s3://{S3_BUCKET}/{S3_KEY}&quot;)<br><br>if __name__ == &quot;__main__&quot;:<br>    if run_backup():<br>        print(&quot;[+] Backup retrieved successfully.&quot;)<br>        encode()<br>        print(&quot;[+] Backup encoded.&quot;)<br>        upload_to_s3()</pre><p>There are several things of interest in this backup script. The first item to note is the S3 bucket and file, as listed near the beginning:</p><pre>S3_BUCKET = &quot;pgamgt-backups&quot;<br>S3_KEY = &quot;latest_backup.xyz&quot;</pre><p>The next item to focus on is how the developer encoded the database prior to uploading it to the S3 bucket. As we can see, it is a simple ROT13 encoding. This is not a good encoding mechanism for sensitive files, to be sure!</p><pre>def encode():<br>    with open(LOCAL_BACKUP, &quot;r&quot;, encoding=&quot;utf-8&quot;, errors=&quot;ignore&quot;) as f:<br>        data = f.read()<br>    encoded = codecs.encode(data, &quot;rot_13&quot;)<br>    with open(ENC_BACKUP, &quot;w&quot;, encoding=&quot;utf-8&quot;) as f:<br>        f.write(encoded)</pre><p>Lastly, we can see how the S3 bucket address is constructed for the upload:</p><pre>def upload_to_s3():<br>    s3 = boto3.client(&quot;s3&quot;)<br>    s3.upload_file(ENC_BACKUP, S3_BUCKET, S3_KEY)<br>    print(f&quot;[+] Uploaded {ENC_BACKUP} to s3://{S3_BUCKET}/{S3_KEY}&quot;)</pre><p>Putting these together, we can safely say that this file in the repository would be responsible for showing us the leaked location of the database. Therefore, we’ll enter <em>app/util/backup_db.py</em>, as our answer for question 2. We need to be clear in the complete path of the Git repository.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*2wv557jc5Mt4taly3N8-aQ.png" /><figcaption>Question 2 Complete</figcaption></figure><h3><strong>Question 4:</strong></h3><p>Yes, you read this right. Question 4 now, because we need to ensure that we have the right location to get the database before we can address question 3…</p><blockquote>Submit the public address of the database leak, including the name of the file.</blockquote><p>With our analysis in the last section, this is EEEEEAAAAAASSSSSSSSYYYYYY!!!! Looking at the location in <em>backup_db.py</em>, we saw that the structure of the S3 address is:</p><pre>s3://{S3_BUCKET}/{S3_KEY}</pre><p>Remember the variables that were set in the beginning of the script? Yeah, these ones:</p><pre>S3_BUCKET = &quot;pgamgt-backups&quot;<br>S3_KEY = &quot;latest_backup.xyz&quot;</pre><p>We just simply substitute the variables in place. That makes the public address:</p><pre>s3://pgamgt-backups/latest_backup.xyz</pre><p>With this all figured out, now we can submit that as our answer for Q4! EEEEAAAASSSSSYYYYY, RIGHT?!</p><p>Wait… what? It’s not working? It’s not being accepted? Hmmm…</p><p>Let’s try to actually pull in the file with AWS CLI, then. Before we can do that, let’s install <em>awcli </em>on our Kali machine:</p><pre>┌──(kali㉿kali)-[~/Documents/OffSec/TheGauntlet/ProtoVaultBreach]<br>└─$ sudo apt install awscli<br>The following packages were automatically installed and are no longer required:<br>  amass-common  libbson-1.0-0t64  libjs-underscore    libmongocrypt0  libportmidi0  libtheoradec1  libudfread0  libxml2   python3-bluepy         python3-gpg                    python3-kismetcapturefreaklabszigbee  python3-kismetcapturertladsb  python3-protobuf    samba-ad-dc         samba-dsdb-modules<br>  libbluray2    libjs-jquery-ui   libmongoc-1.0-0t64  libplacebo349   librav1e0.7   libtheoraenc1  libx264-164  libyelp0  python3-click-plugins  python3-kismetcapturebtgeiger  python3-kismetcapturertl433           python3-kismetcapturertlamr   python3-zombie-imp  samba-ad-provision<br>Use &#39;sudo apt autoremove&#39; to remove them.<br><br>Installing:<br>  awscli<br>                                                                                                                                                                                                                                                                                                                                                                                                                                          <br>Installing dependencies:<br>  docutils-common  python3-awscrt  python3-docutils  python3-jmespath  python3-roman<br>                                                                                                                                                                                                                                                                                                                                                                                                                                          <br>Suggested packages:<br>  docutils-doc  fonts-linuxlibertine  | ttf-linux-libertine  texlive-lang-french<br><br>Summary:<br>  Upgrading: 0, Installing: 6, Removing: 0, Not Upgrading: 3<br>  Download size: 12.1 MB<br>  Space needed: 130 MB / 60.7 GB available<br><br>Continue? [Y/n] Y<br>...</pre><p>Now that we have awscli installed, let’s try to download the file from the S3 bucket with the following command:</p><pre>┌──(kali㉿kali)-[~/Documents/OffSec/TheGauntlet/ProtoVaultBreach]<br>└─$ aws s3 cp s3://pgamgt-backups/latest_backup.xyz ./<br>fatal error: Unable to locate credentials</pre><p>It looks like we’ll need credentials to the S3 bucket, executing it this way. Analyzing the files that are here doesn’t give us those credentials. Instead of trying to dig into this deeper, we can try the download again with no credentials by adding the option <em>— no-sign-request</em>. Let’s try the download again with this option:</p><pre>┌──(kali㉿kali)-[~/Documents/OffSec/TheGauntlet/ProtoVaultBreach]<br>└─$ aws s3 cp s3://pgamgt-backups/latest_backup.xyz ./ --no-sign-request<br>fatal error: An error occurred (404) when calling the HeadObject operation: Key &quot;latest_backup.xyz&quot; does not exist</pre><p>Now we are getting a different error. The file doesn’t exist!!</p><p>Ok… So maybe it wasn’t THAT easy. I guess we’d better dig deeper into the repository. There are a couple ways that we might be able to do this, but let’s work off of what we’ve done already.</p><p>In our case to get to these files, we listed out some commits that existed before the removal of these scripts. There was another commit that we listed above, so why don’t we just check that commit out and see if there’s anything different in there? As a reminder, these were the commits that we listed:</p><pre>┌──(kali㉿kali)-[~/Documents/OffSec/TheGauntlet/ProtoVaultBreach]<br>└─$ cat .git/logs/HEAD      <br>...<br>9f257d253fc6c15860d2e24941b66ab0733e72aa 8fe1a4431337ecf4bc9759672579168b03351fb6 Walter &lt;walter.s@protoguard.local&gt; 1728916320 -0500   commit: Remove backup scripts<br>...<br>ef917bbffedf1638f5ce7747132942197ce97703 1cc71b0fcfcdbfefc7b59cecd898f13b532acc35 Walter &lt;walter.s@protoguard.local&gt; 1755181920 -0500   commit: Remove backup scripts<br>...</pre><p>Let’s checkout the <em>ef917bbffedf1638f5ce7747132942197ce97703</em> commit:</p><pre>┌──(kali㉿kali)-[~/Documents/OffSec/TheGauntlet/ProtoVaultBreach]<br>└─$ git checkout ef917bbffedf1638f5ce7747132942197ce97703<br>Previous HEAD position was 9f257d2 Add item details and notes forms<br>HEAD is now at ef917bb Add item details and notes forms</pre><p>Now that we are in the other commit, let’s read the <em>backup_db.py </em>file again:</p><pre>┌──(kali㉿kali)-[~/Documents/OffSec/TheGauntlet/ProtoVaultBreach]<br>└─$ cat app/util/backup_db.py<br>#!/usr/bin/env python3<br>import paramiko<br>import boto3<br>import codecs<br>import os<br>from scp import SCPClient<br><br># ==== CONFIGURATION ====<br>SSH_HOST = &quot;pgsql_prod_db01.protoguard.local&quot;<br>SSH_PORT = 22<br>SSH_USER = &quot;dbadmin&quot;<br>SSH_KEY = &quot;/home/walter/.ssh/pgsql_key&quot;<br><br>DB_NAME = &quot;pgamgt&quot;<br>DB_USER = &quot;assetdba&quot;<br>BACKUP_FILENAME = &quot;db_backup.sql&quot;<br>LOCAL_BACKUP = f&quot;/tmp/{BACKUP_FILENAME}&quot;<br>ENC_BACKUP = f&quot;/tmp/{BACKUP_FILENAME}.xyz&quot;<br><br>S3_BUCKET = &quot;protoguard-asset-management&quot;<br>S3_KEY = &quot;db_backup.xyz&quot;<br>S3_REGION = &quot;us-east-2&quot;<br><br>...</pre><p>Hey, look! The S3 bucket and keys are different! There’s also a region specified. Let’s try the download of this location, and also make sure to add the region and no credentials options:</p><pre>┌──(kali㉿kali)-[~/Documents/OffSec/TheGauntlet/ProtoVaultBreach]<br>└─$ aws s3 cp s3://protoguard-asset-management/db_backup.xyz ./ --region us-east-2 --no-sign-request<br>download: s3://protoguard-asset-management/db_backup.xyz to ./db_backup.xyz<br>                                                                                                                                                                                                                                                                                                                                                                                                                                          <br>┌──(kali㉿kali)-[~/Documents/OffSec/TheGauntlet/ProtoVaultBreach]<br>└─$ ls         <br>app  db_backup.xyz  requirements.txt  source_code.zip</pre><p>There it is!! Ok. We validated the address, without the need to validate it through the answer submission box. Let’s populate this into the answer and submit it now.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*p59yGzejnKsbqBr9g5XLag.png" /><figcaption>Question 4 Complete</figcaption></figure><p>There are also other ways to download the file from a public S3 bucket, that work in practice. Those are:</p><ol><li><a href="https://s3.us-east-2.amazonaws.com/protoguard-asset-management/db_backup.xyz">https://s3.us-east-2.amazonaws.com/protoguard-asset-management/db_backup.xyz</a></li><li><a href="https://protoguard-asset-management.s3.us-east-2.amazonaws.com/db_backup.xyz">https://protoguard-asset-management.s3.us-east-2.amazonaws.com/db_backup.xyz</a></li></ol><p>I was informed that if the address was supplied with the HTTPS protocol, only the second option will work as an accepted alternative answer.</p><h3><strong>Question 3:</strong></h3><p>Ok! Well, we have the leaked database from the public S3 bucket. Let’s get back to question 3, which will be our last question to answer in this challenge!</p><blockquote>Using the results of your analysis, discover the public address of the database leak. Verify the contents of the leak by submitting the password hash for Naomi Adler.</blockquote><p>With the database downloaded, let’s see if we can read it as is:</p><pre>┌──(kali㉿kali)-[~/Documents/OffSec/TheGauntlet/ProtoVaultBreach]<br>└─$ cat db_backup.xyz                                                                               <br>--<br>-- CbfgterFDY qngnonfr qhzc<br>--<br><br>-- Qhzcrq sebz qngnonfr irefvba 16.3<br>-- Qhzcrq ol ct_qhzc irefvba 16.3<br><br>FRG fgngrzrag_gvzrbhg = 0;<br>FRG ybpx_gvzrbhg = 0;<br>FRG vqyr_va_genafnpgvba_frffvba_gvzrbhg = 0;<br>FRG pyvrag_rapbqvat = &#39;HGS8&#39;;<br>FRG fgnaqneq_pbasbezvat_fgevatf = ba;<br>FRYRPG ct_pngnybt.frg_pbasvt(&#39;frnepu_cngu&#39;, &#39;&#39;, snyfr);<br>FRG purpx_shapgvba_obqvrf = snyfr;<br>FRG kzybcgvba = pbagrag;<br>FRG pyvrag_zva_zrffntrf = jneavat;<br>FRG ebj_frphevgl = bss;<br><br>...</pre><p>What in the wor-…. Oh yeah! Remember in our analysis, there was an encoding function that was run. That was a simple ROT13 encoding, so we’ll need to try to decode it by… Yep! Running it through ROT13 again! Let’s keep this in Bash and just use the <em>tr </em>(translate) command to do so.</p><p>Before we execute the ROT13 translation with <em>tr</em>, let’s break some of the command down. First off, the letters need to shift 13 letters over. That means that “A” will be shifted to “N” and “Z” will be shifted to “M.” We need to do this for both uppercase and lowercase. We also need to have these ranges set up so the shift is understood in one range, but we are only translating a single letter from the original file.</p><p>We then need to use the downloaded database file as the input for the translation. We can use the input redirector (<em>&lt;</em>) and <em>db_backup.xyz </em>after it.</p><p>To make it easier to digest after the translation (and to prevent us from having to do it again), let’s output the contents of the translation to a new file. We will use the output redirector (<em>&gt;</em>) to do this. We’ll call the final file “<em>decoded_backup.sql</em>.”</p><pre>┌──(kali㉿kali)-[~/Documents/OffSec/TheGauntlet/ProtoVaultBreach]<br>└─$ tr &#39;A-Za-z&#39; &#39;N-ZA-Mn-za-m&#39; &lt; db_backup.xyz &gt; decoded_backup.sql</pre><p>With this completed, let’s read the decoded database:</p><pre>┌──(kali㉿kali)-[~/Documents/OffSec/TheGauntlet/ProtoVaultBreach]<br>└─$ cat decoded_backup.sql <br>--<br>-- PostgreSQL database dump<br>--<br><br>-- Dumped from database version 16.3<br>-- Dumped by pg_dump version 16.3<br><br>SET statement_timeout = 0;<br>SET lock_timeout = 0;<br>SET idle_in_transaction_session_timeout = 0;<br>SET client_encoding = &#39;UTF8&#39;;<br>SET standard_conforming_strings = on;<br>SELECT pg_catalog.set_config(&#39;search_path&#39;, &#39;&#39;, false);<br>SET check_function_bodies = false;<br>SET xmloption = content;<br>SET client_min_messages = warning;<br>SET row_security = off;<br><br>...</pre><p>Woohoo!! We can read it now! Ok. Now we need to find the password hash for <em>Naomi Adler</em>. Let’s just filter the output with a <em>grep</em> for “Naomi” and see if there’s anything there. Of course, we could also scroll through the file, but why not cut to the chase in the command line?</p><pre>┌──(kali㉿kali)-[~/Documents/OffSec/TheGauntlet/ProtoVaultBreach]<br>└─$ grep &quot;Naomi&quot; decoded_backup.sql                      <br>11      Naomi   Adler   Cognitive Systems Research      naomi.adler     pbkdf2:sha256:600000$YQqIvcDipYLzzXPB$598fe450e5ac019cdd41b4b10c5c21515573ee63a8f4881f7d721fd74ee43d59</pre><p>It looks like Naomi’s password hash is:</p><pre>pbkdf2:sha256:600000$YQqIvcDipYLzzXPB$598fe450e5ac019cdd41b4b10c5c21515573ee63a8f4881f7d721fd74ee43d59</pre><p>Let’s submit this as our answer for question 3.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*10QsMEeJ7ufYKT-n6pzCuQ.png" /><figcaption>Question 3 Complete</figcaption></figure><h3>Conclusion:</h3><p>This, in my opinion, was a fun exercise to practice exploiting mistakes that might be made in public repositories. Finding credentials, API keys, PII, and other juicy bits might be possible if an accidental leak in a commit was made — even if that mistake was quickly remedied by removing the sensitive information! We also were able to exercise downloading files from public S3 buckets with awscli!</p><p>It should also be taken as a lesson to not store these keys in plaintext in scripting files. There are so many ways that a malicious actor may get access to the source code and giving the keys in that just serves to make their work easier to accomplish.</p><p>Lastly, encoding your sensitive files with weak algorithms is not security at all. Even if you have “security through obscurity,” it can be reversed to the decoded/decrypted text. In this case, it was a VERY simple encoding mechanism, but the point remains. Use weak efforts to “secure” your important digital assets… it can be trivial for an attacker to gain.</p><p>If you enjoyed this article and/or found it useful, leave a comment below and consider following me on my social media platforms (and no, they aren’t all hacking stuff).</p><p>YouTube: <a href="https://www.youtube.com/@RedHatAugust">https://www.youtube.com/@RedHatAugust</a><br>LinkedIn: <a href="https://www.linkedin.com/in/anthony-radzykewycz-64700251/">https://www.linkedin.com/in/anthony-radzykewycz-64700251</a>/<br>Xitter: <a href="https://x.com/redhataugust">https://x.com/redhataugust</a><br>Twitch: <a href="https://www.twitch.tv/redhataugust">https://www.twitch.tv/redhataugust</a><br>TikTok: <a href="https://www.tiktok.com/@redhataugust">https://www.tiktok.com/@redhataugust</a><br>Instagram: <a href="https://www.instagram.com/redhataugust/">https://www.instagram.com/redhataugust/</a></p><p>If you’d like to show your appreciation and support more articles like this or any of the other random stuff I’m into, it’d be awesome if you’d buy me a coffee to fuel the next thing coming!</p><p><a href="https://buymeacoffee.com/redhataugust">Anthony &quot;RedHatAugust&quot; Radzykewycz</a></p><p>Thank you so much for reading through my first Medium article. I hope you enjoyed the ride.</p><iframe src="https://cdn.embedly.com/widgets/media.html?url=https%3A%2F%2Fwww.youtube.com%2Fwatch%3Fv%3D7_zhbBHc8a0&amp;type=text%2Fhtml&amp;schema=google&amp;display_name=YouTube&amp;src=https%3A%2F%2Fwww.youtube.com%2Fembed%2F7_zhbBHc8a0" width="854" height="480" frameborder="0" scrolling="no"><a href="https://medium.com/media/c52d0a6d66ceb50abeb6ea6f714be9d1/href">https://medium.com/media/c52d0a6d66ceb50abeb6ea6f714be9d1/href</a></iframe><p>~ Happy Hacking ~<br>Anthony “RedHatAugust” Radzykewycz</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=6119cd1b763c" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>