CivSwitch README

The project's README from github.com/Gezine/CivSwitch. As one markdown file: README.md.

CivSwitch

XSS toolchain for the Switch 1 edition of Civilization 7.
Only the 1.0.0 version of the game in physical cartridge is supported.

Every switch 1/2 firmware 20.x.x and up to current version (23.0.1) should work.

Tested at Switch 1 fw 22.5.0, Switch 2 fw 20.4.0 and 23.0.1

Two components:

Layout

core.js at the root is the shared payload both components build from, and send_js.py at the root sends any payload to a running loader.

Workflow

Video Tutorial from switch2hacks reddit

  1. Build + flash the loader UF2 (see PicoSwitch/README.md).

    On the Switch, go to "System" menu and change system language to English(US).
    Go to "Controllers & Accessories" menu and change USB Keyboard to English(US).

    These are required to type "English" letters (code) using USB keyboard.
    (Higher fw might not need to change system language as they support typing english without language change)

    NOTE for JP-only Switch2 :

    1. If you have another Switch, you can connect the two consoles via local wireless multiplayer and plug the Pico on the other device, allowing it to send the payload over the network.
    2. Use jis builds of pico uf2 firmware and enable english input at on screen keyboard settings.

    Connect to Internet using 90DNS to block Nintendo servers. (WARNING : YOU MUST READ 90DNS INSTRUCTION CAREFULLY, IF NOT GAME WILL BE LOCKED)

    Then launch game and navigate main menu -> MULTIPLAYER -> WIRELESS -> CREATE GAME -> HOST LOBBY -> CHAT then plug the Pico in (in docked mode, focus the chat box first to receive Pico input).

    The Pico types the chat XSS (~87 lines, ~20 min); the Remote JS Loader comes up on the console (TCP :9026) for that session.

  2. Install the persistent boot trigger from the PC: python installer-creator/install.py <console-ip> — uploads the save template, splices the compressed payload into it on-console, wipes save:/saves/Single/, and writes the trigger.

  3. From then on, every boot: main menu -> Load Game -> the payload runs from savedata (and if the payload is the loader, :9026 is up at boot — and survives console sleep/wake).

  4. You can revert system language after installer finished.

Sending payloads (send_js.py)

python send_js.py <console-ip> [port] file.js

Sends a JS file as-is to the Remote JS Loader (default port 9026), then prints the log output the console streams back (read until close or timeout).

Build (Pico firmware)

On Ubuntu 24.04:

sudo apt install -y git build-essential cmake ninja-build gcc-arm-none-eabi libnewlib-arm-none-eabi libstdc++-arm-none-eabi-newlib python3 nodejs npm
git clone --branch 2.3.1 --depth 1 --recurse-submodules --shallow-submodules https://github.com/raspberrypi/pico-sdk.git ~/pico-sdk
export PICO_SDK_PATH=$HOME/pico-sdk
cd PicoSwitch
npm install                    # terser for compress.js
./build_all.sh                 # payload + all four variants: pico1/pico2 x us/jis

Credits

CivSwitch (Gezine/CivSwitch)

exploitation
Searching Database…

What is this?CivSwitch is an exploit toolchain that achieves userland code execution on a Nintendo Switch by abusing a chat XSS bug found in the physical cartridge release of Civilization 7, letting you run arbitrary JavaScript payloads on the console.
Is this just software, or do I need extra hardware too?It has two parts: PicoSwitch is firmware for a Raspberry Pi Pico (RP2040/RP2350) that acts as a USB keyboard macro to type the exploit payload into the game's in-game chat, and installer-creator is a Python tool that writes a persistent boot trigger into your save data so the exploit survives reboots.
How do I actually run the exploit?Flash the loader firmware to a Pico, set the Switch's system language and USB keyboard to English(US), connect via 90DNS, then start a Civ7 multiplayer wireless host lobby chat and plug in the Pico so it types the chat payload; afterward run python installer-creator/install.py from a PC to make the exploit boot-persistent.
What do I need besides the game itself?A physical Civilization 7 cartridge running game version 1.0.0, a Raspberry Pi Pico flashed with PicoSwitch, a PC with Python for sendjs.py/install.py, and Ubuntu 24.04 if you need to build the firmware yourself.
Does this work on any Switch or Civ7 version?Only the 1.0.0 physical-cartridge release of Civ7 is supported, though it should work on Switch 1 and Switch 2 firmware from 20.x.x up to the current 23.0.1 (it has been tested on a handful of specific builds). Typing the payload into chat takes roughly 15 minutes each session.
What happens after the installer finishes?install.py uploads a save template, splices the compressed payload into it on-console, wipes save:/saves/Single/, and writes a boot trigger, so loading that save on any future boot runs the payload again - if it is the loader, the TCP :9026 server comes back automatically and even survives console sleep/wake.
What does sendjs.py do?It sends any JavaScript payload file as-is to the already-running Remote JS Loader over TCP on port 9026 and prints back the console's streamed log output.
Why change the system language and block Nintendo's servers?The USB HID macro is tuned to type correctly on an English(US) keyboard layout, and 90DNS blocks Nintendo's servers so the console cannot phone home or receive patches while the exploit is being set up.
Where does the exploit code come from?The JS exploit core builds on inject.js from Netflix-N-Hack and a fork by ufm42, and the PicoSwitch firmware is based on Pico-Switch-Controller by Element2424.
Creator
Gezine
Size
1 MB
Stars
758
Age
1mo
Commits · 90 Days