<?xml version="1.0" encoding="UTF-8"?><rss version="2.0" xmlns:content="http://purl.org/rss/1.0/modules/content/">
  <channel>
    <title>Bythos Bytes</title>
    <link>https://bythosbytes.writeas.com/</link>
    <description>A blog about coding, security notes and thoughts. </description>
    <pubDate>Sat, 01 Aug 2026 20:30:30 +0000</pubDate>
    <item>
      <title>eBPF studies and introduction</title>
      <link>https://bythosbytes.writeas.com/ebpf-studies-and-introduction?pk_campaign=rss-feed</link>
      <description>&lt;![CDATA[Introduction&#xA;(Cooming Soon)&#xA;&#xA;A couple of months ago, I was chatting with a friend about new security technologies. He asked me if I know about any previous work to use eBPF to prevent malicious activities (ergo malware) or at least to detect them.&#xA;&#xA;I heard about eBPF before (as a replacement for Netfilter and such) but never spent a reasonable amount of time studying it. As such, I went down through the rabbit hole to learn a little more.&#xA;&#xA;I was amazed by its capabilities. Below, I&#39;ll try to explain as simple as possible what eBPF is and what it can do, along with solid references for those that want to learn more. There&#39;s a lot of good information on the internet but I intended to be more generalist and give a light introduction to it.&#xA;&#xA;This post will be updated with more information as soon as possible.&#xA;&#xA;The following topics will be discussed:&#xA;eBPF brief history&#xA;eBPF Virtual Machine&#xA;eBPF program overview&#xA;eBPF types of programs&#xA;What are helpers functions?&#xA;How eBPF is loaded?&#xA;How can userspace programs interact with eBPF programs&#xA;eBPF Maps&#xA;References&#xA;&#xA;!--more--&#xA;&#xA;eBPF brief history&#xA;Back in the &#39;90s, the Berkeley Packet Filter was released by Steve McCanne and Van Jacobson at Lawrence Berkeley Laboratory and its intents is to &#34;provides a raw interface to data link layers in a protocol-independent fashion&#34; and appeared, as usual, as a special device /dev/bpf, allowing raw link-layer packets to be sent and received.&#xA;&#xA;Later on, inspired by BPF, eBPF was introduced in kernel version 3.18, extending the Linux kernel with features capabilities in a similar manner like BPF. But, unlikely BSD, the developer must not be aware of devices and such things. Rather, they will create their code and attach it to the kernel in specifics hook points.&#xA;&#xA;Then, when some sort of event (like a network packet) reaches the system, if there&#39;s any BPF program attached to a hook related to that kind of event, the data is &#34;passed&#34; to the program to be processed.&#xA;&#xA;But before we dive little more, we have to understand what is the eBFF Virtual Machine.&#xA;&#xA;eBPF Virtual Machine&#xA;&#xA;eBPF program overview&#xA;&#xA;eBPF types of programs&#xA;&#xA;What are helpers functions?&#xA;&#xA;How eBPF are loaded?&#xA;&#xA;How can userspace programs interact with eBPF programs&#xA;&#xA;eBPF Maps&#xA;&#xA;References&#xA;&#xA;http://www.tcpdump.org/papers/bpf-usenix93.pdf&#xA;https://sysdig.com/blog/introducing-container-observability-with-ebpf-and-sysdig/&#xA;https://blogs.oracle.com/linux/post/bpf-in-depth-building-bpf-programs]]&gt;</description>
      <content:encoded><![CDATA[<h2 id="introduction">Introduction</h2>

<p>(Cooming Soon)</p>

<p>A couple of months ago, I was chatting with a friend about new security technologies. He asked me if I know about any previous work to use eBPF to prevent malicious activities (ergo malware) or at least to detect them.</p>

<p>I heard about eBPF before (as a replacement for Netfilter and such) but never spent a reasonable amount of time studying it. As such, I went down through the rabbit hole to learn a little more.</p>

<p>I was amazed by its capabilities. Below, I&#39;ll try to explain as simple as possible what eBPF is and what it can do, along with solid references for those that want to learn more. There&#39;s a lot of good information on the internet but I intended to be more generalist and give a light introduction to it.</p>

<p><strong>This post will be updated with more information as soon as possible.</strong></p>

<p>The following topics will be discussed:
1. eBPF brief history
2. eBPF Virtual Machine
3. eBPF program overview
4. eBPF types of programs
4. What are helpers functions?
5. How eBPF is loaded?
6. How can userspace programs interact with eBPF programs
6. eBPF Maps
7. References</p>



<h2 id="ebpf-brief-history">eBPF brief history</h2>

<p>Back in the &#39;90s, the <a href="https://www.freebsd.org/cgi/man.cgi?query=bpf&amp;sektion=4" rel="nofollow">Berkeley Packet Filter</a> was <a href="http://www.tcpdump.org/papers/bpf-usenix93.pdf" rel="nofollow">released by Steve McCanne and Van Jacobson</a> at Lawrence Berkeley Laboratory and its intents is to <em>“provides a raw interface to data link layers in a protocol-independent fashion”</em> and appeared, as usual, as a special device /dev/bpf, allowing raw link-layer packets to be sent and received.</p>

<p>Later on, inspired by BPF, <a href="https://www.kernel.org/doc/html/latest/networking/filter.html#networking-filter" rel="nofollow">eBPF</a> was introduced in kernel version <a href="https://github.com/torvalds/linux/releases/tag/v3.18-rc1" rel="nofollow">3.18</a>, extending the Linux kernel with features capabilities in a similar manner like BPF. But, unlikely BSD, the developer must not be aware of devices and such things. Rather, they will create their code and <em>attach it</em> to the kernel in specifics <em>hook</em> points.</p>

<p>Then, when some sort of event (like a network packet) reaches the system, if there&#39;s any BPF program attached to a hook related to that kind of event, the data is “passed” to the program to be processed.</p>

<p>But before we dive little more, we have to understand what is the eBFF Virtual Machine.</p>

<h2 id="ebpf-virtual-machine">eBPF Virtual Machine</h2>

<h2 id="ebpf-program-overview">eBPF program overview</h2>

<h2 id="ebpf-types-of-programs">eBPF types of programs</h2>

<h2 id="what-are-helpers-functions">What are helpers functions?</h2>

<h2 id="how-ebpf-are-loaded">How eBPF are loaded?</h2>

<h2 id="how-can-userspace-programs-interact-with-ebpf-programs">How can userspace programs interact with eBPF programs</h2>

<h2 id="ebpf-maps">eBPF Maps</h2>

<h2 id="references">References</h2>

<p><a href="http://www.tcpdump.org/papers/bpf-usenix93.pdf" rel="nofollow">http://www.tcpdump.org/papers/bpf-usenix93.pdf</a>
<a href="https://sysdig.com/blog/introducing-container-observability-with-ebpf-and-sysdig/" rel="nofollow">https://sysdig.com/blog/introducing-container-observability-with-ebpf-and-sysdig/</a>
<a href="https://blogs.oracle.com/linux/post/bpf-in-depth-building-bpf-programs" rel="nofollow">https://blogs.oracle.com/linux/post/bpf-in-depth-building-bpf-programs</a></p>
]]></content:encoded>
      <guid>https://bythosbytes.writeas.com/ebpf-studies-and-introduction</guid>
      <pubDate>Sat, 21 Aug 2021 23:31:13 +0000</pubDate>
    </item>
    <item>
      <title>HackTheBox Reversing Engineering challenge - Bypass</title>
      <link>https://bythosbytes.writeas.com/hackthebox-reversing-engineering-challenge-bypass?pk_campaign=rss-feed</link>
      <description>&lt;![CDATA[Unfortunately, as part of their policy, HTB does not allow public write-ups of their active machines and challenges. As such, this step-by-step guide will be released as soon as the challenge got retired.&#xA;&#xA;Until then.&#xA;]]&gt;</description>
      <content:encoded><![CDATA[<p>Unfortunately, as part of their policy, HTB does not allow public write-ups of their active machines and challenges. As such, this step-by-step guide will be released as soon as the challenge got retired.</p>

<p>Until then.</p>
]]></content:encoded>
      <guid>https://bythosbytes.writeas.com/hackthebox-reversing-engineering-challenge-bypass</guid>
      <pubDate>Mon, 19 Oct 2020 18:17:53 +0000</pubDate>
    </item>
    <item>
      <title>HackTheBox Reversing Engineering challenge - Find the Easy Pass</title>
      <link>https://bythosbytes.writeas.com/hackthebox-reversing-engineering-challenge-find-the-easy-pass?pk_campaign=rss-feed</link>
      <description>&lt;![CDATA[Cooming soon&#xA;&#xA;!--more--&#xA;&#xA;Until then.]]&gt;</description>
      <content:encoded><![CDATA[<p>Cooming soon</p>



<p>Until then.</p>
]]></content:encoded>
      <guid>https://bythosbytes.writeas.com/hackthebox-reversing-engineering-challenge-find-the-easy-pass</guid>
      <pubDate>Mon, 19 Oct 2020 18:17:17 +0000</pubDate>
    </item>
    <item>
      <title>Reversing Engineering and HackTheBox</title>
      <link>https://bythosbytes.writeas.com/reversing-engineering-and-hackthebox?pk_campaign=rss-feed</link>
      <description>&lt;![CDATA[Following my studies on Reverse Engineering (RE) and Malware, I decided to step back and start over with the very basic concepts of reversing. For this purpose, I took my old books, articles and references about RE (listed below). In addition, I&#39;ll use the HTB reversing challenges as warm up exercises. As soon as possible, I&#39;ll write here my notes on every challenge.&#xA;&#xA;]]&gt;</description>
      <content:encoded><![CDATA[<p>Following my studies on Reverse Engineering (RE) and Malware, I decided to step back and start over with the very basic concepts of reversing. For this purpose, I took my old books, articles and references about RE (listed below). In addition, I&#39;ll use the <a href="https://www.hackthebox.eu/" rel="nofollow">HTB</a> reversing challenges as warm up exercises. As soon as possible, I&#39;ll write here my notes on every challenge.</p>
]]></content:encoded>
      <guid>https://bythosbytes.writeas.com/reversing-engineering-and-hackthebox</guid>
      <pubDate>Mon, 19 Oct 2020 18:05:34 +0000</pubDate>
    </item>
    <item>
      <title>HackTheBox machines progress</title>
      <link>https://bythosbytes.writeas.com/hackthebox-machines-progress?pk_campaign=rss-feed</link>
      <description>&lt;![CDATA[Recently I won a VIP subscription to  HTB . As such I headed to hack every retired machine, from easier to hardest. Unfortunately, most of the easy ones are (so far) too easy.&#xA;&#xA;!--more--&#xA;&#xA;After gathering &#34;all&#34; information that I need, most of the hacks were straightforward metasploit modules and exploits ready to run. I hacked 11 easy machines so far, which isn&#39;t&#39; a good number.&#xA;&#xA;Another thing that I noticed is that, so far, most of the machines, when they step up the difficulty level, does this by including some web vulnerabilities.&#xA;&#xA;Since I don&#39;t like, nor I&#39;m an expert on webvulns, I&#39;m currently struggling to hack some &#34;not so easy&#34; VMs based on this kind of vulns. Of course I do know about the OWASP guidelines and basic web tests that every analyst must perform.&#xA;&#xA;I&#39;ll keep the pace as long as I can. Then, if I got tired I&#39;ll switch to the reverse and crackme challenges. It&#39;s more fun and well-suited for my skills.&#xA;&#xA;Until next time,]]&gt;</description>
      <content:encoded><![CDATA[<p>Recently I won a VIP subscription to  <a href="https://www.hackthebox.eu/" rel="nofollow">HTB</a> . As such I headed to hack every retired machine, from easier to hardest. Unfortunately, most of the easy ones are (so far) too easy.</p>



<p>After gathering “all” information that I need, most of the hacks were straightforward metasploit modules and exploits ready to run. I hacked 11 easy machines so far, which isn&#39;t&#39; a good number.</p>

<p>Another thing that I noticed is that, so far, most of the machines, when they step up the difficulty level, does this by including some web vulnerabilities.</p>

<p>Since I don&#39;t like, nor I&#39;m an expert on webvulns, I&#39;m currently struggling to hack some “not so easy” VMs based on this kind of vulns. Of course I do know about the OWASP guidelines and basic web tests that every analyst must perform.</p>

<p>I&#39;ll keep the pace as long as I can. Then, if I got tired I&#39;ll switch to the reverse and crackme challenges. It&#39;s more fun and well-suited for my skills.</p>

<p>Until next time,</p>
]]></content:encoded>
      <guid>https://bythosbytes.writeas.com/hackthebox-machines-progress</guid>
      <pubDate>Thu, 13 Aug 2020 12:10:42 +0000</pubDate>
    </item>
    <item>
      <title>Document analysis and Malware Sandboxes? - Part 2</title>
      <link>https://bythosbytes.writeas.com/document-analysis-and-malware-sandboxes-part-2?pk_campaign=rss-feed</link>
      <description>&lt;![CDATA[Post originally published on my old blog. It was automatically translated and as such may be poorly translated.&#xA;&#xA;Continuing our analysis of malicious documents, we will now address the step that is known as static analysis . However, before entering this phase, we need to understand which format is used by the documents.&#xA;&#xA;!--more--&#xA;&#xA;In our case, we are referring to documents used by the Microsoft Office suite, which follow the Compound Document Format (mentioned in the previous post ), in addition to having support for the document architecture known as Object Linking and Embedding (OLE).&#xA;&#xA;Image&#xA;&#xA;The main point of this alphabet soup is: Office documents have the ability, through OLE, to link other documents or objects within themselves. A spreadsheet within a Word document is an example of this. And it is in this structure that the malicious code is inserted, which can be simple embedded executables or even shellcodes.&#xA;&#xA;These codes abuse known flaws in old versions of Microsoft Office (which only adopted a new standard in 2007) to be executed. Once running, they use several other techniques to be able to create or read files, capture user entries, modify other documents or even, in rarer cases, enter the kernel space (from where they can run with more privileges).&#xA;&#xA;Now the question that remains is: how do I preemptively discover that a document is malicious? Unfortunately the answer is not simple and depends on factors that are not necessarily under our control, as we saw in one the first part of this post. Discussing them here would be quite time consuming (and make reading tedious for some). But there is something we can do once we have a suspicious file: a static analysis of it.&#xA;&#xA;The analysis of this type of document has received less attention than it deserves, perhaps because it is not so trivial and does not fit the simple analysis based on hash. In addition, PDF documents are distributed more frequently and easily. In this analysis we will need to perform the following steps:&#xA;&#xA;Check the file structure and look for malicious snippets.&#xA;Identify what type of threat is inserted in the file.&#xA;Extract the malicious instructions (or part of them).&#xA;Look for suspicious symbols.&#xA;Check if they use exploration techniques.&#xA;Rebuild the executable and analyze it.&#xA;&#xA;To accomplish step 1 we have a few options:&#xA;&#xA;a) Use a sandbox (method used in the first part and which we will ignore);&#xA;b) Analyze the file structure and search its fields for unexpected data;&#xA;c) Automatically analyze the file and score it according to the data entered.&#xA;&#xA;Options b) and c) are actually complementary, however, for learning purposes they will be put separately.&#xA;&#xA;I will start presenting OfficeVis, a tool developed by Microsoft for its developers and that will help us in activity “b”. It is able, when loading the files, to separate its fields according to the CDF standard, to show the associated data and to check for inconsistencies.&#xA;&#xA;In addition, there is the ability to search for known exploits, based on CVEs. Once analyzed, it can identify the malicious bytes inserted into the document. As an example, I will use the file that was sent to the clouds in the first part of the post . Below is the image of the result found by the tool:&#xA;&#xA;We are immediately introduced to this set of bytes which, according to the tool, make up a strong candidate for an exploit reported by CVE-2006-6456 .&#xA;&#xA;Once again we have results that give us strong indications but do not give us certainty. The tool reported a few more sets of malicious bytes but was also unsure.&#xA;&#xA;For this reason, I will now introduce another tool: MalOfficeScanner. Developed and presented by Frank Boldewin at Hack.Lu 2009, it presents some very interesting features: scanning for malicious codes (scan); decoding codes through brute force (brute); debugging of codes found with disassembly of them and detection of strings and embedded PE files (debugging); obtaining OLEs, offsets, and VB macros (info); decompression of Office 2007 files for identification and categorization of threats (inflate).&#xA;&#xA;We will focus here on two options: scan and debug. First the scan:&#xA;&#xA;Right from the start we have several function prologue signatures found on certain offset:&#xA;&#xA;What is this &#34;function prologue&#34;? Roughly speaking, the prologue is a programming convention that determines that some instructions must be called in certain order to prepare the stack for use by the function that is starting. This preparation can (and should) keep the “context” of the past function, in case it is necessary to return to it. Later on I will show some examples.&#xA;&#xA;The key point here is: should we have functions in this document?&#xA;Analyzing the next evidence we found something very interesting:&#xA;&#xA;The tool was able to detect several signatures of a technique that we simply call JMP/CALL/POP. This is one of the best known and most used shellcoding techniques to obtain the effective address from where that piece of code is executing. I encourage you to seek a more “extensive” definition of this technique; worth it.&#xA;&#xA;This time, we have confirmation that a technique that allows us to discover a memory address (and later manipulate it) is being used extensively.&#xA;&#xA;Continuing, we are informed that section signatures exist within the document that identify the existence of possible MZ / PE executables; formats for MS-DOS and Windows executables, respectively:&#xA;&#xA;It is interesting to note that at this very moment the tool is extracting these “executables” from a relative address and creating a separate binary. At the end it performs a summation of all the evidence found, giving different weight to each one of them, and shows us an index:&#xA;&#xA;This rate is very high! Frank himself showed files with a score of 36 points in his presentation. This file is, according to the tool, &#34;very malicious&#34;.&#xA;&#xA;Now let&#39;s go to the debug, which will analyze the binary, present it in hexadecimal format and try to extract some valuable information from there:&#xA;&#xA;We are immediately presented with a character string that identifies an “old” function, which according to Microsoft exists only for the purpose of backwards compatibility with old versions of Windows, whose purpose is to run binaries: Winexec . Very convenient, isn&#39;t it?&#xA;&#xA;Next is a call to the CreateFile function , which creates files or accesses input/output devices (I/O, for example: hard drives):&#xA;&#xA;The following function (CloseHandle) is related to object handling:&#xA;&#xA;Another interesting function: WriteFile, which similarly to CreateFile, writes to files or I/O devices.&#xA;&#xA;ReadFile: reads files or I/O devices.&#xA;&#xA;SetFilePointer: adjust the pointer to files.&#xA;&#xA;VirtualAlloc: reserves pages at the virtual address as a resource for the running process.&#xA;&#xA;And now, as promised, the binary after being reversed by the tool and with its proper identified mnemonics and indicating the presence of prologues! Following is the assembly code that characterizes the prologue of a function:&#xA;&#xA;Without going too far into the code above, I would like to draw attention to the first 6 lines, which represent the instant that the base addresses are saved and a new stack is created (stack frame). &#34;When&#34; the prologue takes place is irrelevant to this moment in the analysis and varies widely with what we know as calling convention. For the sake of curiosity, I recommend checking the difference of this call between Windows, Linux and OSX.&#xA;&#xA;And finally the raw data that, after “mapped” by MalOfficeScan, presents the string “this program must be run under Win32”, indicating that an executable must be run on the Windows operating system that supports programmed binaries for the 32-bit architecture (the encompassing a wide spectrum of machines):&#xA;&#xA;I think we got enough evidence that the document is not to be trusted!&#xA;In this post, we walk through steps 1 to 5. In a way, we also performed step 6, but in an automated way. For the next post we will go deeper into the binary in search of more clues and other techniques used by those who wrote this artifact.&#xA;&#xA;Until then,&#xA;Unfortunately, the original document was lost before I complete the complete analysis of this malicious doc&#xA;&#xA;Bibliographic references:&#xA;Check the original post linked before]]&gt;</description>
      <content:encoded><![CDATA[<p><em>Post originally published on my old <a href="https://n3security.wordpress.com/2013/09/21/analise-de-documentos-e-malware-sandbox-parte-2-analise-estatica/" rel="nofollow">blog</a>. It was automatically translated and as such may be poorly translated.</em></p>

<p>Continuing our analysis of malicious documents, we will now address the step that is known as <strong>static analysis</strong> . However, before entering this phase, we need to understand which format is used by the documents.</p>



<p>In our case, we are referring to documents used by the Microsoft Office suite, which follow the <strong>Compound Document Format</strong> (mentioned in the previous post ), in addition to having support for the document architecture known as <strong>Object Linking and Embedding (OLE)</strong>.</p>

<p><img src="https://n3security.files.wordpress.com/2013/09/figura1.jpg" alt="Image"/></p>

<p>The main point of this alphabet soup is: Office documents have the ability, through OLE, to link other documents or objects within themselves. A spreadsheet within a Word document is an example of this. And it is in this structure that the malicious code is inserted, which can be simple embedded executables or even shellcodes.</p>

<p>These codes abuse known flaws in old versions of Microsoft Office (which only adopted a new standard in 2007) to be executed. Once running, they use several other techniques to be able to create or read files, capture user entries, modify other documents or even, in rarer cases, enter the kernel space (from where they can run with more privileges).</p>

<p>Now the question that remains is: how do I preemptively discover that a document is malicious? Unfortunately the answer is not simple and depends on factors that are not necessarily under our control, as we saw in one the first part of this post. Discussing them here would be quite time consuming (and make reading tedious for some). But there is something we can do once we have a suspicious file: a static analysis of it.</p>

<p>The analysis of this type of document has received less attention than it deserves, perhaps because it is not so trivial and does not fit the simple analysis based on hash. In addition, PDF documents are distributed more frequently and easily. In this analysis we will need to perform the following steps:</p>
<ol><li>Check the file structure and look for malicious snippets.</li>
<li>Identify what type of threat is inserted in the file.</li>
<li>Extract the malicious instructions (or part of them).</li>
<li>Look for suspicious symbols.</li>
<li>Check if they use exploration techniques.</li>
<li>Rebuild the executable and analyze it.</li></ol>

<p>To accomplish step 1 we have a few options:</p>

<p>a) Use a sandbox (method used in the first part and which we will ignore);
b) Analyze the file structure and search its fields for unexpected data;
c) Automatically analyze the file and score it according to the data entered.</p>

<p>Options b) and c) are actually complementary, however, for learning purposes they will be put separately.</p>

<p>I will start presenting OfficeVis, a tool developed by Microsoft for its developers and that will help us in activity “b”. It is able, when loading the files, to separate its fields according to the CDF standard, to show the associated data and to check for inconsistencies.</p>

<p>In addition, there is the ability to search for known exploits, based on CVEs. Once analyzed, it can identify the malicious bytes inserted into the document. As an example, I will use the file that was sent to the clouds in the first part of the post . Below is the image of the result found by the tool:</p>

<p><img src="https://n3security.files.wordpress.com/2013/09/figura2.png" alt=""/></p>

<p>We are immediately introduced to this set of bytes which, according to the tool, make up a strong candidate for an exploit reported by <strong>CVE-2006-6456</strong> .</p>

<p>Once again we have results that give us strong indications but do not give us certainty. The tool reported a few more sets of malicious bytes but was also unsure.</p>

<p>For this reason, I will now introduce another tool: <strong>MalOfficeScanner</strong>. Developed and presented by Frank Boldewin at Hack.Lu 2009, it presents some very interesting features: scanning for malicious codes (<strong>scan</strong>); decoding codes through brute force (<strong>brute</strong>); debugging of codes found with disassembly of them and detection of strings and embedded PE files (<strong>debugging</strong>); obtaining OLEs, offsets, and VB macros (<strong>info</strong>); decompression of Office 2007 files for identification and categorization of threats (<strong>inflate</strong>).</p>

<p>We will focus here on two options: scan and debug. First the scan:</p>

<p>Right from the start we have several function prologue signatures found on certain offset:</p>

<p><img src="https://n3security.files.wordpress.com/2013/10/figura4.jpg" alt=""/></p>

<p>What is this “function prologue”? Roughly speaking, the prologue is a programming convention that determines that some instructions must be called in certain order to prepare the stack for use by the function that is starting. This preparation can (and should) keep the “context” of the past function, in case it is necessary to return to it. Later on I will show some examples.</p>

<p>The key point here is: should we have functions in this document?
Analyzing the next evidence we found something very interesting:</p>

<p><img src="https://n3security.files.wordpress.com/2013/10/figura5.jpg" alt=""/></p>

<p>The tool was able to detect several signatures of a technique that we simply call JMP/CALL/POP. This is one of the best known and most used shellcoding techniques to obtain the effective address from where that piece of code is executing. I encourage you to seek a more “extensive” definition of this technique; worth it.</p>

<p>This time, we have confirmation that a technique that allows us to discover a memory address (and later manipulate it) is being used extensively.</p>

<p>Continuing, we are informed that section signatures exist within the document that identify the existence of possible MZ / PE executables; formats for MS-DOS and Windows executables, respectively:</p>

<p><img src="https://n3security.files.wordpress.com/2013/10/figura6.jpg" alt=""/></p>

<p>It is interesting to note that at this very moment the tool is extracting these “executables” from a relative address and creating a separate binary. At the end it performs a summation of all the evidence found, giving different weight to each one of them, and shows us an index:</p>

<p><img src="https://n3security.files.wordpress.com/2013/10/figura3.jpg" alt=""/></p>

<p>This rate is very high! Frank himself showed files with a score of 36 points in his presentation. This file is, according to the tool, “very malicious”.</p>

<p>Now let&#39;s go to the debug, which will analyze the binary, present it in hexadecimal format and try to extract some valuable information from there:</p>

<p><img src="https://n3security.files.wordpress.com/2013/10/figura8.jpg" alt=""/></p>

<p>We are immediately presented with a character string that identifies an “old” function, which according to Microsoft exists only for the purpose of backwards compatibility with old versions of Windows, whose purpose is to run binaries: <strong>Winexec</strong> . Very convenient, isn&#39;t it?</p>

<p>Next is a call to the CreateFile function , which creates files or accesses input/output devices (I/O, for example: hard drives):</p>

<p><img src="https://n3security.files.wordpress.com/2013/10/figura9.jpg" alt=""/></p>

<p>The following function (CloseHandle) is related to object handling:</p>

<p><img src="https://n3security.files.wordpress.com/2013/10/figura10.jpg" alt=""/></p>

<p>Another interesting function: WriteFile, which similarly to CreateFile, writes to files or I/O devices.</p>

<p><img src="https://n3security.files.wordpress.com/2013/10/figura12.jpg.jpg" alt=""/></p>

<p>ReadFile: reads files or I/O devices.</p>

<p><img src="https://n3security.files.wordpress.com/2013/10/figura11.jpg" alt=""/></p>

<p>SetFilePointer: adjust the pointer to files.</p>

<p><img src="https://n3security.files.wordpress.com/2013/10/figura13.jpg" alt=""/></p>

<p>VirtualAlloc: reserves pages at the virtual address as a resource for the running process.</p>

<p><img src="https://n3security.files.wordpress.com/2013/10/figura14.jpg" alt=""/></p>

<p>And now, as promised, the binary after being reversed by the tool and with its proper identified mnemonics and indicating the presence of prologues! Following is the assembly code that characterizes the prologue of a function:</p>

<p><img src="https://n3security.files.wordpress.com/2013/10/figura15.jpg" alt=""/></p>

<p>Without going too far into the code above, I would like to draw attention to the first 6 lines, which represent the instant that the base addresses are saved and a new stack is created (stack frame). “When” the prologue takes place is irrelevant to this moment in the analysis and varies widely with what we know as calling convention. For the sake of curiosity, I recommend checking the difference of this call between Windows, Linux and OSX.</p>

<p>And finally the raw data that, after “mapped” by MalOfficeScan, presents the string “this program must be run under Win32”, indicating that an executable must be run on the Windows operating system that supports programmed binaries for the 32-bit architecture (the encompassing a wide spectrum of machines):</p>

<p><img src="https://n3security.files.wordpress.com/2013/10/figura16.jpg" alt=""/></p>

<p>I think we got enough evidence that the document is not to be trusted!
In this post, we walk through steps 1 to 5. In a way, we also performed step 6, but in an automated way. For the next post we will go deeper into the binary in search of more clues and other techniques used by those who wrote this artifact.</p>

<p>Until then,
<em>Unfortunately, the original document was lost before I complete the complete analysis of this malicious doc</em></p>

<p>Bibliographic references:
<em>Check the original post linked before</em></p>
]]></content:encoded>
      <guid>https://bythosbytes.writeas.com/document-analysis-and-malware-sandboxes-part-2</guid>
      <pubDate>Wed, 20 May 2020 11:16:18 +0000</pubDate>
    </item>
    <item>
      <title>Document analysis and Malware Sandboxes?</title>
      <link>https://bythosbytes.writeas.com/document-analysis-and-malware-sandboxes?pk_campaign=rss-feed</link>
      <description>&lt;![CDATA[Post originally published on my old blog. It was automatically translated and as such may be poorly translated.&#xA;&#xA;I recently had the opportunity to get my hands on a .doc file that was sent to me and that had been categorized using an antivirus heuristic as an infected file.&#xA;&#xA;After being informed of the possible infection, the person who gave me the file simply said that other AVs did not identify it as being a malicious file and questioned the first analysis, implying that he believed that the file would not actually be infected.&#xA;&#xA;!--more--&#xA;&#xA;So I asked that person what he did to feel so safe to say that the document was not really infected. To my surprise I received an image of the result of an antivirus (AV) cloud:&#xA;&#xA;Illustration 1: vscan.novirusthanks.org - file 1&#xA;&#xA;Apparently the fact that only one AV solution detected the file as malicious did not seem to bother the person. The questions that came to mind then were:&#xA;&#xA;Do other cloud and sandbox solutions have similar results?&#xA;&#xA;Do they have the capacity to analyze documents of this type (Composite Document File V2, CDF)?&#xA;&#xA;Do the tools warn you when they are unable to parse the document or simply check for a known hash base?&#xA;&#xA;To answer the first question, I went after other cloud and sandbox solutions to see how they behaved.&#xA;&#xA;Illustration 2: virusscan.jotti.org - file 1&#xA;&#xA;It is possible to notice that more than one solution has detected a threat and a coincidence between them; the categorization of the file: MW97: ShellCode. We will use this information later.&#xA;&#xA;Unfortunately we don&#39;t know the engine version of these solutions.&#xA;&#xA;It is relevant to note that the opensource solution brought two important pieces of information (if they are true):&#xA;&#xA;PUA (Possibly Unwanted Application): This does not necessarily mean that the file is infected but that it has characteristics that can be used for &#34;good&#34; or &#34;evil&#34;. In this case, he identified a possible packer.&#xA;&#xA;BorlandDelphi-2 : Is this an indication that possible malicious code was built using Borland Delphi? We will try to capture this information later.&#xA;&#xA;Now let&#39;s see another result:&#xA;Illustration 3: vicheck.ca - file 1&#xA;&#xA;This time we have a more “correct” result: 13 embedded codes were found . Among them, it is worth mentioning the calls to the following “routines”: KERNEL32, GetCommanLineA, CreateFileA, CreateWindowsExA. It is worth mentioning that this sandbox is specialized in analyzing malicious documents:&#xA;&#xA;“An advanced malware detection engine designed to decrypt and extract malicious executables from common document formats such as MS Office Word, Powerpoint, Excel, Access, or Adobe PDF documents. ViCheck will detect the majority of embedded executables in documents as well as common exploits which download malware from the internet. ”&#xA;&#xA;And to finish another analysis:&#xA;Illustration 4: malwaretracker.com - file 1&#xA;&#xA;Now things are interesting! Another sandbox specializing in documents also found embedded codes and some of the so-called concurrences. In addition, executable files were downloaded .&#xA;&#xA;I believe the answer to 1st question was answered: clouds and sandboxes do not always show similar results.&#xA;I uploaded the document (file 1) in at least five more sandboxes. Unfortunately they were inconsistent. And it was not just a difference in nomenclature between them. Some actually said there was nothing in the file!&#xA;&#xA;&#34;Who&#39;s right?&#34; it is a difficult question to be answered by the “ordinary” user.&#xA;If we upload it to a cloud full of AVs, we have no way of knowing which ones actually performed the most appropriate verification because the method is almost never clear.&#xA;Many AVs only check for file signatures in their database. Others have heuristic analysis. While others analyze the structure of the documents.&#xA;&#xA;Now we come to the answer to the second question: only some clouds and sanboxes really have the capacity to analyze CDFs .&#xA;&#xA;And now? How much can a person or company trust in these analyzes?&#xA;Many companies that own these clouds are not responsible for these results (at least not in their “free” version). And several are simply unclear about their limitations and also do not warn the user, which is the answer to our third question. Just check the different sandboxes returned by google (and indicated in the references).&#xA;&#xA;So… what is the way out???&#xA;&#xA;Well… nothing better than the old “hands on”. In the next post we will crawl into a static analysis of the document.&#xA;&#xA;Until then,&#xA;&#xA;Bibliographic references:&#xA;Check the original post linked before]]&gt;</description>
      <content:encoded><![CDATA[<p><em>Post originally published on my old <a href="https://n3security.wordpress.com/2013/08/19/analise-de-documentos-e-malware-sandbox/" rel="nofollow">blog</a>. It was automatically translated and as such may be poorly translated.</em></p>

<p>I recently had the opportunity to get my hands on a .doc file that was sent to me and that had been categorized using an antivirus heuristic as an infected file.</p>

<p>After being informed of the possible infection, the person who gave me the file simply said that other AVs did not identify it as being a malicious file and questioned the first analysis, implying that he believed that the file would not actually be infected.</p>



<p>So I asked that person what he did to feel so safe to say that the document was not really infected. To my surprise I received an image of the result of an antivirus (AV) cloud:</p>

<p><img src="http://n3security.files.wordpress.com/2013/08/image001_post.png" alt="Illustration 1: vscan.novirusthanks.org - file 1"/></p>

<p>Apparently the fact that only one AV solution detected the file as malicious did not seem to bother the person. The questions that came to mind then were:</p>

<p>Do other cloud and sandbox solutions have similar results?</p>

<p>Do they have the capacity to analyze documents of this type (Composite Document File V2, CDF)?</p>

<p>Do the tools warn you when they are unable to parse the document or simply check for a known hash base?</p>

<p>To answer the first question, I went after other cloud and sandbox solutions to see how they behaved.</p>

<p><img src="http://n3security.files.wordpress.com/2013/08/image002_post.png" alt="Illustration 2: virusscan.jotti.org - file 1"/></p>

<p>It is possible to notice that more than one solution has detected a threat and a coincidence between them; the categorization of the file: MW97: ShellCode. We will use this information later.</p>

<p>Unfortunately we don&#39;t know the engine version of these solutions.</p>

<p>It is relevant to note that the opensource solution brought two important pieces of information (if they are true):</p>
<ol><li><p><strong>PUA</strong> (Possibly Unwanted Application): This does not necessarily mean that the file is infected but that it has characteristics that can be used for “good” or “evil”. In this case, he identified a possible packer.</p></li>

<li><p><strong>BorlandDelphi-2</strong> : Is this an indication that possible malicious code was built using Borland Delphi? We will try to capture this information later.</p></li></ol>

<p>Now let&#39;s see another result:
<img src="http://n3security.files.wordpress.com/2013/09/vicheck_arquivo1.png" alt="Illustration 3: vicheck.ca - file 1"/></p>

<p>This time we have a more “correct” result: 13 embedded codes were found . Among them, it is worth mentioning the calls to the following “routines”: KERNEL32, GetCommanLineA, CreateFileA, CreateWindowsExA. It is worth mentioning that this sandbox is specialized in analyzing malicious documents:</p>

<p><em>“An advanced malware detection engine designed to decrypt and extract malicious executables from common document formats such as MS Office Word, Powerpoint, Excel, Access, or Adobe PDF documents. ViCheck will detect the majority of embedded executables in documents as well as common exploits which download malware from the internet. ”</em></p>

<p>And to finish another analysis:
<img src="http://n3security.files.wordpress.com/2013/09/malwaretracker_arquivo1.png" alt="Illustration 4: malwaretracker.com - file 1"/></p>

<p>Now things are interesting! Another sandbox specializing in documents also found embedded codes and some of the so-called concurrences. In addition, <strong>executable files were downloaded</strong> .</p>

<p>I believe the answer to 1st question was answered: clouds and sandboxes do not always show similar results.
I uploaded the document (file 1) in at least five more sandboxes. Unfortunately they were inconsistent. And it was not just a difference in nomenclature between them. Some actually said there was nothing in the file!</p>

<p><strong>“Who&#39;s right?”</strong> it is a difficult question to be answered by the “ordinary” user.
If we upload it to a cloud full of AVs, we have no way of knowing which ones actually performed the most appropriate verification because the method is almost never clear.
Many AVs only check for file signatures in their database. Others have heuristic analysis. While others analyze the structure of the documents.</p>

<p>Now we come to the answer to the second question: only some clouds and sanboxes really have the capacity to analyze CDFs .</p>

<p>And now? How much can a person or company trust in these analyzes?
Many companies that own these clouds are not responsible for these results (at least not in their “free” version). And several <strong>are simply unclear about their limitations and also do not warn the user</strong>, which is the answer to our third question. Just check the different sandboxes returned by google (and indicated in the references).</p>

<p>So… what is the way out???</p>

<p>Well… nothing better than the old “hands on”. In the next post we will crawl into a static analysis of the document.</p>

<p>Until then,</p>

<p>Bibliographic references:
<em>Check the original post linked before</em></p>
]]></content:encoded>
      <guid>https://bythosbytes.writeas.com/document-analysis-and-malware-sandboxes</guid>
      <pubDate>Tue, 19 May 2020 22:36:10 +0000</pubDate>
    </item>
    <item>
      <title>Toying with Hackthebox</title>
      <link>https://bythosbytes.writeas.com/toying-with-hackthebox?pk_campaign=rss-feed</link>
      <description>&lt;![CDATA[About HTB&#xA;&#xA;As a way to study and revisit most of the skills required to pentest real environments, I started a couple of weeks ago to crack some Hackthebox virtual machines (VM). At first, I was wondering if this was the right way to learn something new.&#xA;&#xA;I must say that I&#39;m not disappointed since most of the box is set in such a way that you need an overall knowledge of the Operating System/Technology that you&#39;re targeting. In addition, after you exaustly enumerated the box you &#34;must&#34; know a little bit about the service, protocol or whatever you want to attack.&#xA;&#xA;!--more--&#xA;&#xA;I know that&#39;s an obvious statement &#39;cause this the way that most real pentest works but it&#39;s a relief to know that such platform exist.&#xA;For those that do not have the time or resources to create it&#39;s own environment and labs, Hackthebox is awesome.&#xA;For those that chose to pay for the VIP pass, many more retired VM&#39;s are available&#xA;&#xA;The experience&#xA;&#xA;HTB overall user experience was smooth, at least for me. It&#39;s portal has an intuitive GUI, menus and options. No complains about that. The only downside is the slow and sometimes unstable connection if you&#39;re on the free access. But that&#39;s expected for this kind of service with a lot of users massively brute forcing, scanning, crawling and forgering requests to HTBoxes.&#xA;&#xA;To generate the credentials and connect to the HTB network itself is super easy, at least for those with some experience with VPN&#39;s.&#xA;&#xA;Choosing the VM and cracking it&#xA;&#xA;For those that never cracked a box or are rusty about pentest, my recommendation is to start with a already cracked box. HTB have a list of retired machines that are available to VIP members but a few of them are available, for a limited period of time, to non-VIP members.&#xA;Most of those VMs have walktroughs that, after the retirement, can be found on forums, blogs, youtube and may help you if you get stuck on some stage of the pentest.&#xA;&#xA;But try to not rely too much on it. Try it yourself. Many times I found myself stuck on some stages and reading/watching a walktrough just to, later on, get the feeling that I already knew what is necessary to do (because I have the knowledge) but failed to &#34;think out of the box&#34;. Sometimes that kind of mindset comes easier…sometimes just don’t. That’s why you have to develop your own methodology, refine it and use it until stucks in your mind.&#xA;&#xA;In future posts I hope to write a little bit about some of the retired VMs and what interesting finds I had.]]&gt;</description>
      <content:encoded><![CDATA[<h2 id="about-htb">About HTB</h2>

<p>As a way to study and revisit most of the skills required to pentest real environments, I started a couple of weeks ago to crack some <a href="https://www.hackthebox.eu/" rel="nofollow">Hackthebox</a> virtual machines (VM). At first, I was wondering if this was the right way to learn something new.</p>

<p>I must say that I&#39;m not disappointed since most of the box is set in such a way that you need an overall knowledge of the Operating System/Technology that you&#39;re targeting. In addition, after you exaustly enumerated the box you “must” know a little bit about the service, protocol or whatever you want to attack.</p>



<p>I know that&#39;s an obvious statement &#39;cause this the way that most real pentest works but it&#39;s a relief to know that such platform exist.
For those that do not have the time or resources to create it&#39;s own environment and labs, Hackthebox is awesome.
For those that chose to pay for the VIP pass, many more retired VM&#39;s are available</p>

<h2 id="the-experience">The experience</h2>

<p>HTB overall user experience was smooth, at least for me. It&#39;s portal has an intuitive GUI, menus and options. No complains about that. The only downside is the slow and sometimes unstable connection if you&#39;re on the free access. But that&#39;s expected for this kind of service with a lot of users massively brute forcing, scanning, crawling and forgering requests to HTBoxes.</p>

<p>To generate the credentials and connect to the HTB network itself is super easy, at least for those with some experience with VPN&#39;s.</p>

<h2 id="choosing-the-vm-and-cracking-it">Choosing the VM and cracking it</h2>

<p>For those that never cracked a box or are rusty about pentest, my recommendation is to start with a already cracked box. HTB have a list of retired machines that are available to VIP members but a few of them are available, for a limited period of time, to non-VIP members.
Most of those VMs have walktroughs that, after the retirement, can be found on forums, blogs, youtube and may help you if you get stuck on some stage of the pentest.</p>

<p>But try to not rely too much on it. Try it yourself. Many times I found myself stuck on some stages and reading/watching a walktrough just to, later on, get the feeling that I already knew what is necessary to do (because I have the knowledge) but failed to “think out of the box”. Sometimes that kind of mindset comes easier…sometimes just don’t. That’s why you have to develop your own methodology, refine it and use it until stucks in your mind.</p>

<p>In future posts I hope to write a little bit about some of the retired VMs and what interesting finds I had.</p>
]]></content:encoded>
      <guid>https://bythosbytes.writeas.com/toying-with-hackthebox</guid>
      <pubDate>Tue, 19 May 2020 22:19:57 +0000</pubDate>
    </item>
  </channel>
</rss>