> ## Content Index
> Fetch the complete content index at: https://www.oransblog.com/llms.txt
> Use this file to discover other available public pages before exploring further.

# my ghost got hacked
- URL: https://www.oransblog.com/my-ghost-blog-got-hacked/
- Published: 2026-11-12T02:31:15.000Z
- Updated: 2026-11-12T02:56:59.000Z
- Author: Oran C
- Tags: hack

will explain more,

ghost had a sql cve.

now it took me hours to work but im now back up.

heres what i did to get back online.

![](https://www.oransblog.com/content/images/2026/11/20261106191608-3.webp)

![](https://www.oransblog.com/content/images/2026/11/20261106191625-3.webp)

when active

![](https://www.oransblog.com/content/images/2026/11/20261106191715-3.webp)

go to this tutorial [https://www.digitalocean.com/community/tutorials/how-to-install-ghost-cms-with-digitalocean-marketplace-1-click](https://www.digitalocean.com/community/tutorials/how-to-install-ghost-cms-with-digitalocean-marketplace-1-click?ref=oransblog.com)

```
ssh root@<REDACTED IP>

```

if youget error lik this go to

![](https://www.oransblog.com/content/images/2026/11/20261106192257-3.webp)

"how to connect with ssh"

[https://docs.digitalocean.com/products/droplets/how-to/add-ssh-keys/](https://docs.digitalocean.com/products/droplets/how-to/add-ssh-keys/?ref=oransblog.com)

```
ssh-keygen

```

![](https://www.oransblog.com/content/images/2026/11/20261106194417-3.webp)

# How to Upload an SSH Public Key to an Existing Droplet

[https://docs.digitalocean.com/products/droplets/how-to/add-ssh-keys/to-existing-droplet/](https://docs.digitalocean.com/products/droplets/how-to/add-ssh-keys/to-existing-droplet/?ref=oransblog.com)

actually fuck that its actually easier to get started using the web console do that instead

![](https://www.oransblog.com/content/images/2026/11/20261106194928-3.webp)

![](https://www.oransblog.com/content/images/2026/11/20261106195059-3.webp)

lets incrypt failed as usual. ahah

had to login to my cloudflare and update the ip it points the domain to. then the letsencrypt worked!

![](https://www.oransblog.com/content/images/2026/11/20261106195928-3.webp)

```
https://dash.cloudflare.com/<REDACTED>/example.com/dns/records

```

blog is live but empty

![](https://www.oransblog.com/content/images/2026/11/20261106200046-3.webp)

now to populate it pro tip in the web console paste doesnt work if you right click and paste as plane text it works

![](https://www.oransblog.com/content/images/2026/11/20261106200253-3.webp)

add ssh key

```
mkdir -p ~/.ssh

echo "ssh-ed25519 AAA<REDACTED SSH KEY>PY o@oden" >> ~/.ssh/authorized_keys

```

![](https://www.oransblog.com/content/images/2026/11/20261106200457-3.webp)

worked!

```
chmod -R go= ~/.ssh
chown -R $USER:$USER ~/.ssh

```

![](https://www.oransblog.com/content/images/2026/11/20261106200704-3.webp)

```
sudo -i -u ghost-mgr

```

![](https://www.oransblog.com/content/images/2026/11/20261106201022-3.webp)

```
ghost ls
cd /var/www/ghost
sudo npm install -g ghost-cli@latest
ghost update

```

![](https://www.oransblog.com/content/images/2026/11/20261106201445-3.webp)

![](https://www.oransblog.com/content/images/2026/11/20261106201611-3.webp)

![](https://www.oransblog.com/content/images/2026/11/20261106201639-3.webp)

how to set a root password

```
 sudo passwd root

```

![](https://www.oransblog.com/content/images/2026/11/20261106201908-3.webp)

```
logout
logout
logout

```

![](https://www.oransblog.com/content/images/2026/11/20261106201945-3.webp)

login

```
ssh root@<REDACTED IP>

```

Lock down the old droplet before powering it on

```
 https://cloud.digitalocean.com/networking/firewalls

```

![](https://www.oransblog.com/content/images/2026/11/20261106202255-3.webp)

![](https://www.oransblog.com/content/images/2026/11/20261106202411-3.webp)

![](https://www.oransblog.com/content/images/2026/11/20261106202721-3.webp)

start droplet

![](https://www.oransblog.com/content/images/2026/11/20261106202829-3.webp)

![](https://www.oransblog.com/content/images/2026/11/20261106211153-3.webp)

coundt login so i had to rest password

```
sudo -i -u ghost-mgr
cd /var/www/ghost
ghost config get database.connection
sudo mysql -u root -p    

```

cd /var/www/ghost/versions/5.109.1/node\_modules/bcryptjs

```bash

node -e "const bcrypt = require('bcryptjs'); bcrypt.hash('CcP3%PXMfE6', 10, (e, h) => console.log(h));"   
$2a$10$.rEs<REDACTED >dNhe
sudo mysql -u root -p   
UPDATE users SET password = '$2a$10$.rEs<REDACTED >dNhe' WHERE email = 'oranbusiness@gmail.com';   

USE ghost_production;

UPDATE users SET password = '$2a$10$.rEs<REDACTED >', status = 'active' WHERE email = 'oranbusiness@gmail.com'; DELETE FROM sessions;

```

![](https://www.oransblog.com/content/images/2026/11/20261106210807-3.webp)

```
cd /var/www/ghost
ghost config security.staffDeviceVerification false
	ghost restart
	
	
UPDATE users SET status = 'active' WHERE email = 'oranbusiness@gmail.com';   

SELECT id, slug FROM posts
 WHERE codeinjection_head != '' OR codeinjection_foot != ''
    OR html LIKE '%<script%';

```

```
mkdir -p ~/backup-$(date +%F) && cd ~/backup-$(date +%F)
sudo mysqldump --single-transaction ghost_production > ghost_production.sql
ls -lh ghost_production.sql

```

looks like it was a roge zapier key

![](https://www.oransblog.com/content/images/2026/11/20261106214955-3.webp)

turns out they have be inside the system for way longer than i realized since may 17th! fuck

![](https://www.oransblog.com/content/images/2026/11/20261106215304-3.webp)

omg thanks anthropic ai slop fuckiers

![](https://www.oransblog.com/content/images/2026/11/20261106222346-3.webp)

wrote this code to remove the click jacking

```
import json, re, sys
  

src, dst = sys.argv[1], sys.argv[2]

data = json.load(open(src, encoding="utf-8"))
  

patterns = [

    re.compile(r'<script>\(function\(\)\{try\{var k="ghost_once_footer_.*?</script>', re.S),

    re.compile(r'<script>\(function\(\)\{try\{var k=\\"ghost_once_footer_.*?</script>', re.S),

]

removed = 0
  

def walk(o):

    global removed

    if isinstance(o, dict):

        return {k: walk(v) for k, v in o.items()}

    if isinstance(o, list):

        return [walk(v) for v in o]

    if isinstance(o, str):

        for p in patterns:

            o, n = p.subn("", o)

            removed += n

    return o
  

data = walk(data)
  

strong = ["token.ug", "ghost_once_footer", "dropper-crm", "staticvpn", "claud."]

weak = ["atob(", "clipboard", "<script"]

tables = data["db"][0]["data"]

print(f"Removed {removed} injected script(s)\n")

for tname, rows in tables.items():

    if not isinstance(rows, list):

        continue

    for row in rows:

        s = json.dumps(row, ensure_ascii=False)

        label = row.get("slug") or row.get("key") or row.get("id")

        sh = [i for i in strong if i in s]

        wh = [i for i in weak if i in s]

        if sh:

            print(f"STILL INFECTED  {tname}: {label} -> {sh}")

        elif wh:

            print(f"review          {tname}: {label} -> {wh}")
  

json.dump(data, open(dst, "w", encoding="utf-8"), ensure_ascii=False, indent=2)

print("\nWrote", dst)

```

![](https://www.oransblog.com/content/images/2026/11/20261111191837-3.webp)

uploaded the ghost-export-clean.json to

![](https://www.oransblog.com/content/images/2026/11/20261111191909-3.webp)

![441](https://www.oransblog.com/content/images/2026/11/20261111191925-3.webp)

![418](https://www.oransblog.com/content/images/2026/11/20261111191932-3.webp)

ended up going with pikapods because its cheaper thand theyir docs are better [https://www.timcheadle.com/hosting-ghost-on-pikapods-and-cloudflare/](https://www.timcheadle.com/hosting-ghost-on-pikapods-and-cloudflare/?ref=oransblog.com)

this tutorial has reeally helpful info on how to fix the www issue

coppied the contents of my old ghost folder to sftp pikapods

![](https://www.oransblog.com/content/images/2026/11/20261111192019-3.webp)

one annoying fucking thing is when you set up a custom domain for pikapods idk the username stuff gets fucked.

so i had to set mailgun up for the ghost instantce AHHH . but its worth it

![](https://www.oransblog.com/content/images/2026/11/20261111192119-3.webp)

![](https://www.oransblog.com/content/images/2026/11/20261111192232-3.webp)

![](https://www.oransblog.com/content/images/2026/11/20261111192256-3.webp)

![](https://www.oransblog.com/content/images/2026/11/20261111192308-3.webp)

![](https://www.oransblog.com/content/images/2026/11/20261111192318-3.webp)

AND NO this passwrod is invalid 🫠 within pikapods

![](https://www.oransblog.com/content/images/2026/11/20261111192356-3.webp)

env vars follow the setting for pikapods docs [https://docs.pikapods.com/apps/ghost](https://docs.pikapods.com/apps/ghost?ref=oransblog.com)

![](https://www.oransblog.com/content/images/2026/11/20261111192413-3.webp)

![](https://www.oransblog.com/content/images/2026/11/20261111192506-3.webp)

add the SMTP user from mailgun

![](https://www.oransblog.com/content/images/2026/11/20261111192557-3.webp)

do a password reset from ghost

![](https://www.oransblog.com/content/images/2026/11/20261111192630-3.webp)

it will give you errors if you fucked up

success looks like this

![](https://www.oransblog.com/content/images/2026/11/20261111192710-3.webp)

![](https://www.oransblog.com/content/images/2026/11/20261111192804-3.webp)

that worked!

this was so much work.

# how to reduce all the images on your ghost server by multiple gbs (inmy case)

![478](https://www.oransblog.com/content/images/2026/11/20261111193509-2.webp)

WOW SO MUCH LESS DATA! oh bonus points is reducing the size of all the images using webp trick

![](https://www.oransblog.com/content/images/2026/11/20261111193230-2.webp)

# i converted all the images to webp but kept the file exames identical. this stops ghost from breaking image links which suckSSS ass.

and the files are super small 😎

heres the break down of files

![](https://www.oransblog.com/content/images/2026/11/20261111193614-2.webp)

btw this is wiztree (windirstat's better and faster replacement 😎) shit tones are HUGE pngs and gifs

was

![](https://www.oransblog.com/content/images/2026/11/20261111193722-2.webp)

now

![](https://www.oransblog.com/content/images/2026/11/20261111193756-2.webp)

MUCH BETTER still dont have a good way of reducing the gif sizes tried a bunch of stuff. gif is just ass it turns out.

and not good replacements :/

# the code i used

convert\_to\_webp2.py

```

#!/usr/bin/env python3
"""
Recursively convert PNG images to WebP format.

IMPORTANT:
- Keeps the original .png filename.
- Replaces the original PNG contents with WebP data.
- Does NOT create .webp files.
- Preserves transparency.
- Uses temporary files to avoid incomplete writes.

Requires:
    pip install Pillow

Usage:
    python convert_to_webp.py /path/to/images

Options:
    -q 90       WebP quality (1-100)
    -j 4        Number of workers
"""

import argparse
import os
import sys
from pathlib import Path
from concurrent.futures import ThreadPoolExecutor, as_completed

from PIL import Image

def convert(png_path: Path, quality: int) -> tuple:
    """Convert PNG contents to WebP while retaining the .png filename."""

    temp_path = png_path.with_name(png_path.name + ".tmp")

    try:
        original_size = png_path.stat().st_size

        with Image.open(png_path) as img:

            # Preserve transparency
            if (
                img.mode in ("RGBA", "LA")
                or (img.mode == "P" and "transparency" in img.info)
            ):
                img = img.convert("RGBA")
            else:
                img = img.convert("RGB")

            # Save WebP data to temporary file
            img.save(
                temp_path,
                format="WEBP",
                quality=quality,
                method=6
            )

        new_size = temp_path.stat().st_size

        # Replace original PNG contents
        os.replace(temp_path, png_path)

        savings = (
            (original_size - new_size) / original_size * 100
            if original_size else 0
        )

        return "converted", png_path, original_size, new_size, savings, None

    except Exception as exc:

        if temp_path.exists():
            temp_path.unlink()

        return "failed", png_path, 0, 0, 0, str(exc)

def main():

    parser = argparse.ArgumentParser(
        description="Convert PNG contents to WebP while keeping .png filenames."
    )

    parser.add_argument(
        "root",
        nargs="?",
        default=".",
        help="Folder to scan recursively."
    )

    parser.add_argument(
        "-q",
        "--quality",
        type=int,
        default=90,
        help="WebP quality 1-100 (default: 90)."
    )

    parser.add_argument(
        "-j",
        "--jobs",
        type=int,
        default=1,
        help="Number of images to process simultaneously (default: 1)."
    )

    args = parser.parse_args()

    if not 1 <= args.quality <= 100:
        print("Error: quality must be between 1 and 100.")
        return 1

    if args.jobs < 1:
        print("Error: jobs must be at least 1.")
        return 1

    root = Path(args.root).expanduser().resolve()

    if not root.is_dir():
        print(f"Error: directory does not exist: {root}")
        return 1

    png_files = sorted(
        p for p in root.rglob("*")
        if p.is_file() and p.suffix.lower() == ".png"
    )

    if not png_files:
        print("No PNG files found.")
        return 0

    print(f"\nFound {len(png_files)} PNG files.")
    print(f"Quality: {args.quality}")
    print(f"Workers: {args.jobs}")
    print("\nWARNING: Original PNG image data will be replaced!")
    print("Filenames will remain unchanged.\n")

    converted = 0
    failed = 0
    total_original = 0
    total_new = 0

    with ThreadPoolExecutor(max_workers=args.jobs) as pool:

        futures = {
            pool.submit(convert, path, args.quality): path
            for path in png_files
        }

        for future in as_completed(futures):

            status, path, old_size, new_size, savings, error = future.result()

            if status == "converted":

                converted += 1
                total_original += old_size
                total_new += new_size

                print(
                    f"OK: {path.name} | "
                    f"{old_size / 1024:.1f} KB -> "
                    f"{new_size / 1024:.1f} KB | "
                    f"{savings:.1f}% savings"
                )

            else:

                failed += 1
                print(f"FAILED: {path} | {error}", file=sys.stderr)

    print("\n========== SUMMARY ==========")
    print(f"Converted: {converted}")
    print(f"Failed: {failed}")
    print(f"Original size: {total_original / 1024 / 1024:.2f} MB")
    print(f"New size: {total_new / 1024 / 1024:.2f} MB")

    if total_original:
        total_savings = (
            (total_original - total_new) / total_original * 100
        )
        print(f"Total size reduction: {total_savings:.1f}%")

    print("=============================")

    return 1 if failed else 0

if __name__ == "__main__":
    raise SystemExit(main())

```

Longest running server of mine. you will be missed

![](https://www.oransblog.com/content/images/2026/11/20261111194407.webp)

- oran