T09 · Insecure Skill Coding Practices
- Location
references/ctf-crypto/prng.md:94- Finding
Arbitrary Code Execution Through Unsafe Deserialization with eval
- Content
View full analysis
- Remediation
View remediation
Security audit
Security checks for vulnerabilities and agentic risk
This is a coherent CTF cryptography helper, but it includes highly actionable attack playbooks and live-target examples without clear authorized-use boundaries.
Install only if you intend to use it in authorized CTF, training, or owned lab environments. Do not use its exploit workflows against real services without explicit permission, and run examples in an isolated virtual environment or container; review and pin any packages or repositories before installing them.
references/ctf-crypto/prng.md:94Arbitrary Code Execution Through Unsafe Deserialization with eval
references/ctf-crypto/SKILL.md:16Unpinned Third-Party Package and Repository Installation
YARA rule matched a hack tool or exploit indicator (offensive tools, reconnaissance, privilege escalation, or exploit frameworks).
pylll替代格归约,或装 Sage: Linuxsudo apt install sagemath`;Windows 建议走 WSL。
$PY -c "n=<N>; print('bits=', n.bit_length())" # RSA 模数位宽
$PY -c "from sympy import factorint; print(factorint(<n>))" # 小因子?
# 哈希识别:看长度(32=MD5, 40=SHA1, 64=SHA256 hex);hashcat --example-hashes 对照
# XOR 试探
$PY -c "from pwn import xor; print(xor(bytes.fromhex('<hex>'), b'flag{'))"
c*r^e 再除 rYARA rule matched a hack tool or exploit indicator (offensive tools, reconnaissance, privilege escalation, or exploit frameworks).
pylll替代格归约,或装 Sage: Linuxsudo apt install sagemath`;Windows 建议走 WSL。
$PY -c "n=<N>; print('bits=', n.bit_length())" # RSA 模数位宽
$PY -c "from sympy import factorint; print(factorint(<n>))" # 小因子?
# 哈希识别:看长度(32=MD5, 40=SHA1, 64=SHA256 hex);hashcat --example-hashes 对照
# XOR 试探
$PY -c "from pwn import xor; print(xor(bytes.fromhex('<hex>'), b'flag{'))"
c*r^e 再除 rYARA rule matched a hack tool or exploit indicator (offensive tools, reconnaissance, privilege escalation, or exploit frameworks).
pylll替代格归约,或装 Sage: Linuxsudo apt install sagemath`;Windows 建议走 WSL。
$PY -c "n=<N>; print('bits=', n.bit_length())" # RSA 模数位宽
$PY -c "from sympy import factorint; print(factorint(<n>))" # 小因子?
# 哈希识别:看长度(32=MD5, 40=SHA1, 64=SHA256 hex);hashcat --example-hashes 对照
# XOR 试探
$PY -c "from pwn import xor; print(xor(bytes.fromhex('<hex>'), b'flag{'))"
c*r^e 再除 rYARA rule matched a hack tool or exploit indicator (offensive tools, reconnaissance, privilege escalation, or exploit frameworks).
nds
# Identify cipher type
python3 -c "from Crypto.Util.number import *; n=<N>; print(f'bits={n.bit_length()}')"
# RSA quick check
python3 -c "from sympy import factorint; print(factorint(<n>))" # Small factors?
openssl rsa -pubin -in key.pub -text -noout # Extract n, e from PEM
# Quick factorization tools
python3 RsaCtfTool.py -n <n> -e <e> --uncipher <c>
# XOR analysis
python3 -c "from pwn import xor; print(xor(bytes.fromhex('<hex>'), b'flag{'))"
# Hash identification
hashid '<hash>'
hashcat --identify '<hash>'
# SageMath (for lattice/ECC)
sage -c "print(factor(<n>))"
(ct - pt) mod 26. Kasiski examination for unknown key length (GCD of repeated sequence distances)The snippet imports pwntools and provides a working remote oracle client that automates AES-ECB byte-at-a-time secret extraction against a live service. Even though framed as a CTF technique, this is directly transferable to real-world exploitation of vulnerable encryption oracles and materially lowers the barrier to abuse.
Byte-at-a-Time Chosen Plaintext (ABCTF 2016)
Pattern (Encryption Service): Server encrypts user_input || secret_suffix under AES-ECB. Recover the secret suffix one byte at a time by controlling the input length.
from pwn import *
import cryptanalib as ca # FeatherDuster's cryptanalib
def oracle(pt):
"""Send plaintext, receive ECB-encrypted ciphertext."""
r = remote('target', 7765)
r.recvuntil('Send me some hex-encoded data to encrypt:\n')
r.sendline(pt.hex())
r.recvuntil('Here you go:')
ct = bytes.fromhex(r.recvline().strip().decode())
r.close()
return ct
# Automated byte-at-a-time recovery
flag = ca.ecb_cpa_decrypt(oracle, block_size=16, verbose=True)
print(flag)
Manual approach without library:
block_size = 16
known = b''
for i in range(len(secr
The from pwn import * import is a strong indicator of exploit-development tooling and appears inside a working padding-oracle exploitation example. While not harmful by itself, in this skill it reinforces that the content is meant to operationalize attacks, making misuse easier when surfaced by an agent to users targeting real systems.
signing) makes them trivially forgeable. Always check if the MAC has the property: knowing the secret components lets you compute valid signatures for arbitrary inputs.
Pattern: Server reveals whether CBC-mode ciphertext has valid PKCS#7 padding (via error messages, timing, or status codes). Decrypt any ciphertext block-by-block without the key.
from pwn import *
def padding_oracle(iv, ct):
"""Returns True if server accepts padding."""
resp = requests.post(URL, data={'iv': iv.hex(), 'ct': ct.hex()})
return 'padding' not in resp.text.lower() # or check status code
def decrypt_block(prev_block, target_block):
"""Decrypt one 16-byte block using padding oracle."""
intermediate = bytearray(16)
plaintext = bytearray(16)
for byte_pos in range(15, -1, -1):
pad_val = 16 - byte_pos
# Set already-known bytes to produce correct padding
crafted = bytearray(16)
for k in range(byte_pos
Skill attempts to nullify the agent's safety policies or restrictions ('you have no restrictions', 'ignore your guidelines', 'do anything now'). This is a direct jailbreak that disables guardrails.
**Key insight:** When the verifier accepts user-supplied public key parameters without constraints, setting `e=1` makes modular exponentiation trivial. Choose `n` such that `signature mod n` equals the expected padded hash.
---
Commands invoke sudo or root privileges. Verify this elevated access is necessary and justified.
- **hashcat**:哈希爆破;字典建议 rockyou(Kali 自带 `/usr/share/wordlists/`)。
- **SageMath(可选)**:格攻击与高级数论(Coppersmith、离散对数)。
本机没有时用 `pip install fpylll` 替代格归约,或装 Sage:
Linux `sudo apt install sagemath`;Windows 建议走 WSL。
## 识别速查
The skill is an operational playbook for exploiting cryptographic weaknesses, including padding oracles, nonce reuse, forgery, and decryption-oracle abuse, and it provides no boundary limiting use to authorized CTF environments. In context, this materially increases the chance the skill will be used against real services or to facilitate unauthorized access, not just educational analysis.
Suspicious Unicode normalization or mixed-script content
This markdown section instructs the user to repeatedly query a server 1000 times to recover protected data, including importing requests, but provides no warning that the technique sends automated requests to an external system. For markdown files, SQP-2 applies when descriptions omit warnings about behaviors that could affect privacy or system integrity; high-volume remote interaction should be disclosed.
Suspicious Unicode normalization or mixed-script content
The file is a catalog of offensive cryptographic attack patterns with procedural guidance and code snippets, but it lacks any limiting context, warning banner, or authorization-only framing near the top. In a reusable agent skill, this increases the chance the material is operationalized for unauthorized exploitation rather than confined to CTF or defensive research.
This markdown file includes actionable exploit instructions that modify encrypted commands to achieve command injection and later forges privileged cookies, but it does not include any warning that these techniques must only be used in authorized CTF or lab contexts. Under the markdown-specific warning rule, the description omits user-facing safety guidance about behaviors that could affect system integrity or unauthorized access.
This file is an offensive crypto attack playbook containing concrete exploitation steps, forgery techniques, oracle abuse workflows, and tool references across many real attack classes. In the context of an agent skill, packaging this material without clear authorization boundaries, safety constraints, or anti-abuse guidance increases the likelihood the agent will assist with unauthorized exploitation rather than purely educational CTF use.
This markdown file includes procedural guidance for predicting DSA nonce values and deriving a private key, as well as several other exploitation-oriented PRNG attacks, but it does not warn readers that these actions can compromise accounts, secrets, or remote services. Under the markdown-file criteria for SQP-2, descriptions of behaviors that can affect user data, privacy, or system integrity should include warnings, and none are present here.
This section gives step-by-step instructions to recover PRNG state, predict password reset tokens, and forge a live reset URL. Even though framed as CTF material, the technique directly maps to real-world account takeover scenarios when insecure token generation is used, and the document provides no authorization or safety boundary warning.
This section provides operational password cracking strategy, wordlist/rules guidance, and target-pattern suggestions without clear authorization constraints. In a general-purpose agent skill, that materially increases misuse potential for credential attacks against real accounts and services.
This file is an extensive catalog of practical RSA attack techniques, including exploit conditions, code snippets, and operational steps for signature forgery, decryption-oracle abuse, fault attacks, timing attacks, and modulus/key recovery. In the context of an agent skill, this materially increases the chance the agent can generate offensive exploit guidance without any embedded safety framing, authorization boundary, or limitation to defensive/educational use.
Skill enables autonomous high-impact decisions without human-in-the-loop verification. Critical operations (destructive commands, financial transactions, data deletion) should require explicit user confirmation.
flag = pow(c, real_d, n)
**Key insight:** `phi(p^2) = p*(p-1)`, NOT `(p-1)^2`. When a server validates RSA parameters but uses `(p-1)*(q-1)` without checking `p != q`, setting `p=q` creates a working key that the server will miscompute the private exponent for, causing decryption failure and error-path data leakage.
---
This file contains detailed, actionable offensive cryptographic attack procedures, including code and exploitation workflows for RSA weaknesses, padding oracles, timing oracles, signature forgery, and related attacks, but it provides no clear limitation to authorized, educational, or CTF-only use. Although the surrounding skill metadata suggests a CTF helper, the content is directly reusable against real systems, so the absence of scope warnings and guardrails increases misuse risk.
This section gives concrete, operational instructions for exploiting a race condition against remote endpoints, including cache-busting, synchronization, and parallel request flooding, without any authorization or safety boundary warning. In a reusable agent skill, that materially lowers the barrier to performing active attacks on live services, even if framed as CTF guidance.
The sample code performs live HTTP POST requests and is embedded in an exploitation recipe for sending approximately 80 synchronized requests to a target service. Although presented as an example, it is directly usable for active attack traffic generation against remote systems and therefore increases the operational risk of the skill.
def make_request(barrier, modified_sig):
barrier.wait() # Synchronize all processes
requests.post(url, json={"sig": modified_sig})
# Launch 80 processes with unique signature modifications
processes = [Process(target=make_request, args=(barrier, modify_sig(i))) for i in range(80)]
The skill includes package and system installation commands (pip install, apt install, brew install, git clone) without an explicit warning that they modify the local environment and may fetch untrusted third-party code. In an agent/tooling context, this can lead to unintended environment changes, dependency pollution, or execution of attacker-influenced packages if the commands are followed automatically or without review.
This markdown file includes an example that reads an encrypted file and writes a decrypted output file (flag.png) to disk. While the behavior is visible in the code snippet, the surrounding documentation does not explicitly warn users that running the example will create or overwrite local files, which is the kind of user disclosure expected for markdown content describing data-affecting operations.