oneline6ryp7o
oneline6ryp7o
Platform: Sekai2026 | Category: Cryptography | Type: Challenge | Difficulty: Medium | OS: NA | Author: D3v0o0Nu11 | Date: 2026-06-28 | Status: Solved Techniques: mersenne_modulus_bit_permutation, modular_linearization, operator_precedence_analysis
Summary
Task: a Python one-line assertion constrains a SEKAI flag to 67 digits of 6/7 and a divisibility test. Solution: parse precedence, reduce the modulus to 2^67-1, and solve the byte subset directly.
Recon
Port scan
bash read-only • copy allowednmap -p- -sV -sC <TARGET> --min-rate 1000 -Pn
| Port | Service | Version | Notes |
|---|---|---|---|
| <PORT> | <SVC> | <VER> | <notes> |
Enumeration highlights
- Event:
sekai2026| ID:20260628_sekai2026_oneline6ryp7o - Tags: python, modular_arithmetic, subset_sum, mersenne_modulus, one_liner
- Indicators: regex SEKAI{[67]{67}}, int.from_bytes(flag.encode()) modulo expression, ~(6+~7)**67, body bytes differ by one
- Source:
20260628_sekai2026_oneline6ryp7o.md
Foothold
Vulnerability / Misconfiguration
- mersenne_modulus_bit_permutation
- modular_linearization
- operator_precedence_analysis
bash read-only • copy allowed<command>
Exploitation
- See original writeup content for detailed exploitation.
Privilege Escalation
Enumeration
bash read-only • copy allowedsudo -l find / -perm -4000 2>/dev/null getcap -r / 2>/dev/null cat /etc/crontab ps aux
Exploitation
- N/A for challenge-type writeup; see exploitation above.
- Flag obtained via challenge solve.
bash read-only • copy allowed<command>
Flags
| Flag | Location | Value |
|---|---|---|
| flag | REDACTED |
Key Takeaways / Lessons
- mersenne_modulus_bit_permutation
- modular_linearization
- operator_precedence_analysis
- Tags: python, modular_arithmetic, subset_sum, mersenne_modulus, one_liner
Original Writeup
<details><summary>Click to expand original content</summary>oneline6ryp7o — sekai2026
Description
how hard can six seven be assert import('re').match('SEKAI{[67]{67}}$',flag:=input()) and not int.from_bytes(flag.encode())%~(6+~7)**67
English summary: the challenge gives a single Python assertion. The input must match the flag format SEKAI{[67]{67}}, and the big-endian integer representation of the flag must be divisible by the value produced by the final Python expression.
Analysis
The important part is parsing the Python expression correctly:
python read-only • copy allowedint.from_bytes(flag.encode()) % ~(6 + ~7) ** 67
Python exponentiation binds tighter than unary bitwise NOT in this context, so the modulus is:
python read-only • copy allowed~((6 + ~7) ** 67)
Now:
~7 = -86 + ~7 = -2(-2) ** 67 = -2^67~(-2^67) = 2^67 - 1
So the divisibility condition is:
text read-only • copy allowedint.from_bytes(flag.encode(), "big") == 0 mod (2^67 - 1)
The regex fixes the prefix and suffix and leaves exactly 67 variable body bytes, each either ASCII 6 or ASCII 7.
Let:
text read-only • copy allowedbase = int.from_bytes(b"SEKAI{" + b"6"*67 + b"}", "big") M = 2^67 - 1
Changing a body character from 6 to 7 increases that byte by exactly 1, therefore it adds one power of 256 to the big-endian integer. We need to select positions whose weights sum to -base mod M:
text read-only • copy allowedbase + sum(selected 256^k) == 0 mod M
Since 256 = 2^8 and gcd(8, 67) = 1, the powers of 256 modulo 2^67 - 1 permute the 67 single-bit weights. That means this subset selection is not a hard subset-sum problem: the target residue directly tells us which positions must be changed to 7.
Solution
The following solver starts from the all-6 baseline, computes the required residue, and changes exactly the body positions whose modulo weight appears in that residue.
python read-only • copy allowed#!/usr/bin/env python3 import re M = ~(6 + ~7) ** 67 assert M == 2**67 - 1 prefix = b"SEKAI{" suffix = b"}" n = 67 # Start with all body bytes as ASCII '6'. Changing a body byte from '6' to '7' # adds exactly 1 * 256**position to the big-endian integer. base_flag = prefix + b"6" * n + suffix base = int.from_bytes(base_flag, "big") target = (-base) % M body = [ord("6")] * n for i in range(n): # Body byte index i is at absolute byte offset 6+i in a 74-byte string. # Its big-endian exponent is 73-(6+i) = 67-i. weight = pow(256, 67 - i, M) # Because gcd(8,67)=1, each weight is a distinct single bit modulo 2^67-1. if target & weight: body[i] = ord("7") flag = (prefix + bytes(body) + suffix).decode() assert re.match(r"SEKAI{[67]{67}}$", flag) assert int.from_bytes(flag.encode()) % M == 0 print(flag) print("M =", M) print("body length =", len(flag) - len("SEKAI{") - 1)
Running it prints the valid flag and verifies both the regex and divisibility checks.
</details>signed by XESXOR