<?xml version="1.0" encoding="utf-8" standalone="yes" ?>
<rss version="2.0" 
  xmlns:content="http://purl.org/rss/1.0/modules/content/" 
  xmlns:dc="http://purl.org/dc/elements/1.1/" 
  xmlns:atom="http://www.w3.org/2005/Atom" 
  xmlns:sy="http://purl.org/rss/1.0/modules/syndication/" 
  xmlns:media="http://search.yahoo.com/mrss/">
  <channel>
    <title>Imaginaryctf on Mal Breaks Things</title>
    <link>https://sec.gd/blog/en/tags/imaginaryctf/</link>
    <description>Recent content in Imaginaryctf on Mal Breaks Things</description>
    <generator>Hugo -- gohugo.io</generator>
    <language>en</language>
    <managingEditor>mal@sec.gd (mal)</managingEditor>
    <webMaster>mal@sec.gd (mal)</webMaster>
    <copyright>&amp;copy;{year}. [License and Info](/blog/about/)</copyright>
    <lastBuildDate>Tue, 27 Jul 2021 04:00:00 +0000</lastBuildDate>
    <sy:updatePeriod>daily</sy:updatePeriod>
    
        <atom:link href="https://sec.gd/blog/en/tags/imaginaryctf/index.xml" rel="self" type="application/rss+xml" />
    
    
    
      <item>
        <title>ImaginaryCTF 2021</title>
        <link>https://sec.gd/blog/en/posts/imaginaryctf-2021/</link>
        <pubDate>Tue, 27 Jul 2021 04:00:00 +0000</pubDate>
        <author>mal@sec.gd (mal)</author>
        <atom:modified>Tue, 27 Jul 2021 04:00:00 +0000</atom:modified>
        <guid>https://sec.gd/blog/en/posts/imaginaryctf-2021/</guid>
        <description>This weekend I participated in &lt;a href=&#34;https://2021.imaginaryctf.org/&#34;&gt;ImaginaryCTF 2021&lt;/a&gt; with &lt;a href=&#34;https://wrecktheline.com/&#34;&gt;WreckTheLine&lt;/a&gt;. We finished third out of 1018 entrants, the final team to complete all 55 challenges and hit 11330 points, missing second place by 3.5 minutes. Here are my writeups for System Hardening 5 and New Technology.</description>
        <content:encoded>&lt;![CDATA[&lt;p&gt;&lt;img src=&#34;../../../images/imaginaryctf-2021/ictf-2021-banner.jpg&#34; alt=&#34;ImaginaryCTF 2021 Banner&#34;&gt;&lt;/p&gt;
&lt;p&gt;This weekend I participated in &lt;a href=&#34;https://2021.imaginaryctf.org/&#34;&gt;ImaginaryCTF 2021&lt;/a&gt;
with &lt;a href=&#34;https://wrecktheline.com/&#34;&gt;WreckTheLine&lt;/a&gt;. We finished third out of 1018
entrants, the final team to complete all 55 challenges and hit 11330 points,
missing second place by 3.5 minutes.&lt;/p&gt;
&lt;h2 id=&#34;system-hardening-5&#34;&gt;System Hardening 5&lt;/h2&gt;
&lt;p&gt;&lt;em&gt;&amp;ldquo;CyberPatriot but run by roo fanatics&amp;hellip; What could go wrong&amp;hellip;&amp;rdquo;&lt;/em&gt;&lt;/p&gt;
&lt;p&gt;At 450 points, System Hardening 5 was in the highest value category of
challenges. It was in the pattern of CyberPatriot, where teams download and
run a VM, find and fix all of the vulnerabilities. A scoring engine checks the
scored items every minute or so and reports to the scoreboard.&lt;/p&gt;
&lt;p&gt;As with CyberPatriot, we start with the &lt;a href=&#34;https://system-hardening-5.chal.imaginaryctf.org/readme&#34;&gt;readme&lt;/a&gt;.
The major constrants today are:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;No updates at all. Makes sense, that&amp;rsquo;s time-consuming and uninteresting.&lt;/li&gt;
&lt;li&gt;Critical services: Remote desktop, print spooler.&lt;/li&gt;
&lt;li&gt;Don&amp;rsquo;t disable SMB or the scoring engine may break&lt;/li&gt;
&lt;/ul&gt;
&lt;h3 id=&#34;forensics&#34;&gt;Forensics&lt;/h3&gt;
&lt;p&gt;Let&amp;rsquo;s start&lt;sup id=&#34;fnref:1&#34;&gt;&lt;a href=&#34;#fn:1&#34; class=&#34;footnote-ref&#34; role=&#34;doc-noteref&#34;&gt;1&lt;/a&gt;&lt;/sup&gt; with the Forensics questions, as the readme says, so we don&amp;rsquo;t
accidentally destroy artifacts we&amp;rsquo;ll need to answer them.&lt;/p&gt;
&lt;blockquote&gt;
&lt;p&gt;An [sic] user on this system was compromised, allowing rooReaper to break in. What is
the username of this user?&lt;/p&gt;&lt;/blockquote&gt;
&lt;p&gt;Well, let&amp;rsquo;s look around. Event log? Exploit artifacts? Let&amp;rsquo;s check this other
file on the desktop first, &lt;code&gt;text-messages-from-mom.txt.txt&lt;/code&gt; [sic].&lt;/p&gt;
&lt;blockquote&gt;
&lt;p&gt;&lt;strong&gt;MOMtotallynotrooreaper:&lt;/strong&gt; hi roo! this is definitely mom here&lt;br&gt;
&lt;strong&gt;rooYay:&lt;/strong&gt; oh hi mom didnt see you there all too well&lt;br&gt;
&lt;strong&gt;MOMtotallynotrooreaper:&lt;/strong&gt; ?&lt;br&gt;
&lt;strong&gt;rooYay:&lt;/strong&gt; nvm, what did you text me for&lt;br&gt;
&lt;strong&gt;rooYay:&lt;/strong&gt; and is this a new number? i dont see the message history&lt;br&gt;
&lt;strong&gt;MOMtotallynotrooreaper:&lt;/strong&gt; uhh yea this is a new number&lt;br&gt;
&lt;strong&gt;rooYay:&lt;/strong&gt; oh ok&lt;br&gt;
&lt;strong&gt;MOMtotallynotrooreaper:&lt;/strong&gt; can you disable your firewall? and enable smb pls and disable your antivirus&lt;br&gt;
&lt;strong&gt;rooYay:&lt;/strong&gt; ok whatever you say mom&amp;hellip;&lt;br&gt;
&lt;strong&gt;rooYay:&lt;/strong&gt; ill look up some tutorials&lt;br&gt;
&lt;strong&gt;MOMtotallynotrooreaper:&lt;/strong&gt; NO DONT LOOK AT TUTORIALS&lt;br&gt;
&lt;strong&gt;rooYay:&lt;/strong&gt; ok i wont what do i do&lt;br&gt;
&lt;strong&gt;MOMtotallynotrooreaper:&lt;/strong&gt; ill show you&lt;br&gt;
&lt;strong&gt;MOMtotallynotrooreaper:&lt;/strong&gt; btw what is rooPOG&amp;rsquo;s password&lt;br&gt;
&lt;strong&gt;MOMtotallynotrooreaper:&lt;/strong&gt; i heard he loves sharing&lt;br&gt;
&lt;strong&gt;rooYay:&lt;/strong&gt; its just password1337 nothing fancy&lt;br&gt;
&lt;strong&gt;MOMtotallynotrooreaper:&lt;/strong&gt; thanks!&lt;br&gt;
&amp;hellip;&lt;/p&gt;&lt;/blockquote&gt;
&lt;p&gt;Looks like rooYay fell for the classic &amp;ldquo;hi this is your mother&amp;rdquo; phish, and gave
out &lt;strong&gt;rooPOG&lt;/strong&gt;&amp;rsquo;s password.&lt;/p&gt;
&lt;div class=&#34;alert alert-info&#34; role=&#34;alert&#34; data-dir=&#34;ltr&#34;&gt;Forensics Question 1 correct - 7 points&lt;/div&gt;
&lt;p&gt;That also gives us the answer to the next forensics question:&lt;/p&gt;
&lt;blockquote&gt;
&lt;p&gt;What is the password of the compromised user from the previous question?&lt;/p&gt;&lt;/blockquote&gt;
&lt;blockquote&gt;
&lt;p&gt;&lt;strong&gt;password1337&lt;/strong&gt; nothing fancy&lt;/p&gt;&lt;/blockquote&gt;
&lt;div class=&#34;alert alert-info&#34; role=&#34;alert&#34; data-dir=&#34;ltr&#34;&gt;Forensics Question 2 correct - 7 points&lt;/div&gt;
&lt;p&gt;The other forensics questions require some research.&lt;/p&gt;
&lt;blockquote&gt;
&lt;p&gt;What is the CVE ID of the vulnerability that allowed rooReaper to escalate
privileges?&lt;/p&gt;&lt;/blockquote&gt;
&lt;p&gt;I poked around in rooPOG&amp;rsquo;s home directory for a bit, finding &lt;code&gt;xconsole.exe&lt;/code&gt; and
&lt;code&gt;vlib.dll&lt;/code&gt; in &lt;code&gt;Downloads\foobar&lt;/code&gt;. The latter was detected as Win32/Mamson.A!ac,
which doesn&amp;rsquo;t obviously use any exploits. I enabled Windows Defender and
started a scan, and before I had found anything in the event viewer, it had
found &lt;code&gt;C:\temp\PrintNightmareLPE.exe&lt;/code&gt;.&lt;/p&gt;
&lt;p&gt;Print Nightmare, &lt;a href=&#34;https://msrc.microsoft.com/update-guide/vulnerability/CVE-2021-34527&#34;&gt;CVE-2021-34527&lt;/a&gt;,
is a recent vulnerability that allows a remote attacker to install a malicious
printer driver configuration DLL to gain arbitrary code execution as SYSTEM. A
variant, &lt;a href=&#34;https://msrc.microsoft.com/update-guide/vulnerability/CVE-2021-1675&#34;&gt;&lt;strong&gt;CVE-2021-1675&lt;/strong&gt;&lt;/a&gt;,
is useful for local exploitation, and was accepted as the answer.&lt;/p&gt;
&lt;p&gt;Both of these drop the payload, in this case &lt;code&gt;vlib.dll&lt;/code&gt;, in
&lt;code&gt;C:\Windows\System32\spool\drivers\x64\3\&lt;/code&gt;, where Defender found it alongside
&lt;code&gt;reverse_64bit.dll&lt;/code&gt; which it detected as Win64/Meterpreter.B. I removed the
whole folder, along with &lt;code&gt;C:\temp\&lt;/code&gt; and the contents of rooPOG&amp;rsquo;s Downloads
folder.&lt;/p&gt;
&lt;div class=&#34;alert alert-info&#34; role=&#34;alert&#34; data-dir=&#34;ltr&#34;&gt;Forensics Question 3 correct - 7 points&lt;br&gt;
Removed privilege escalation payload - 5 points&lt;/div&gt;
&lt;p&gt;The final forensics question seemed like a steganography problem, but referred
to another challenge in the CTF:&lt;/p&gt;
&lt;blockquote&gt;
&lt;p&gt;The background image on the Desktop contains a secret message. What is it?&lt;br&gt;
HINT: It&amp;rsquo;s related to another challenge in this CTF, a reversing challenge.&lt;/p&gt;&lt;/blockquote&gt;
&lt;p&gt;The wallpaper was &lt;code&gt;background.png&lt;/code&gt; in rooYay&amp;rsquo;s Pictures folder. It consisted of
a grid of tiles, in a repeating pattern &lt;code&gt;Axxxx&lt;/code&gt;, where there were 3 options for
&lt;code&gt;x&lt;/code&gt;. No obvious pattern was shown by &lt;code&gt;stegsolve&lt;/code&gt;, and it wasn&amp;rsquo;t clear how to
decode information in the tile pattern. I put it aside until a teammate,
JaGoTu, solved &lt;code&gt;roolang&lt;/code&gt;, which seemed potentially-related. Sure enough:&lt;/p&gt;
&lt;blockquote&gt;
&lt;p&gt;JaGoTu: roolang was just a vm that was calculating fibonacii very slowly&lt;br&gt;
JaGoTu: can you send the raw png somewhere?&lt;br&gt;
JaGoTu: cause the roolang basically runs png files&lt;/p&gt;&lt;/blockquote&gt;
&lt;p&gt;They ran their roolang solution on the PNG, and sent back the output:
&lt;strong&gt;Hello, and welcome to the roos&amp;rsquo; server!&lt;/strong&gt;&lt;/p&gt;
&lt;div class=&#34;alert alert-info&#34; role=&#34;alert&#34; data-dir=&#34;ltr&#34;&gt;Forensics Question 4 correct - 7 points&lt;/div&gt;
&lt;h3 id=&#34;pups-not-the-fun-kind&#34;&gt;PUPs (Not the Fun Kind)&lt;/h3&gt;
&lt;p&gt;With the forensics questions out of the way, let&amp;rsquo;s continue through the readme.
We have a list of needed services and software, so let&amp;rsquo;s remove anything that&amp;rsquo;s
not on it, starting with the faux-Clippy in the corner of the screen.&lt;/p&gt;
&lt;p&gt;First, the Startup folder for All Users in
&lt;code&gt;C:\ProgramData\Microsoft\Windows\Start Menu\Programs\Startup\&lt;/code&gt;.
Two shortcuts:\&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;code&gt;chksec - Shortcut.lnk&lt;/code&gt; to &lt;code&gt;C:\Windows\System32\chksec.exe&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;&lt;code&gt;essential - Shortcut.lnk&lt;/code&gt; to &lt;code&gt;C:\Windows\System32\essential.bat&lt;/code&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;Delete the shortcuts, kill the processes, delete the Clippy executable.
&lt;code&gt;essential.bat&lt;/code&gt; printed some ascii art text, copied itself to the current
user&amp;rsquo;s start menu Startup folder, opened a
&lt;a href=&#34;https://www.youtube.com/watch?v=xvFZjo5PgG0&#34;&gt;video&lt;/a&gt;, and then &lt;code&gt;pause&lt;/code&gt;d.
Delete the batch file from System32 and from rooYay&amp;rsquo;s
&lt;code&gt;%AppData%\Microsoft\Windows\Start Menu\Programs\Startup\&lt;/code&gt;.&lt;/p&gt;
&lt;div class=&#34;alert alert-info&#34; role=&#34;alert&#34; data-dir=&#34;ltr&#34;&gt;Removed PUP Clippy - 3 points&lt;br&gt;
Removed rickroll malware - 4 points&lt;/div&gt;
&lt;h3 id=&#34;installed-programs&#34;&gt;Installed Programs&lt;/h3&gt;
&lt;p&gt;There&amp;rsquo;s a couple shortcuts on the desktop to software that wasn&amp;rsquo;t mentioned as
required in the readme, so let&amp;rsquo;s remove those. I replaced Chrome with Firefox
portable, since the roos prefer IE and I very much do not. Nothing else in
add/remove programs looked relevant.&lt;/p&gt;
&lt;div class=&#34;alert alert-info&#34; role=&#34;alert&#34; data-dir=&#34;ltr&#34;&gt;Removed unauthorized program Minecraft Launcher - 3 points&lt;br&gt;
Removed unauthorized program SuperAntiSpyware - 3 points&lt;/div&gt;
&lt;p&gt;I also looked through the running processes, but nothing else there raised
suspicion.&lt;/p&gt;
&lt;h3 id=&#34;users&#34;&gt;Users&lt;/h3&gt;
&lt;p&gt;Next, let&amp;rsquo;s deal with users, which is easiest from
&lt;code&gt;compmgmt.msc&lt;/code&gt;/&lt;code&gt;lusrmgr.msc&lt;/code&gt;.&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Create &lt;code&gt;roocursion&lt;/code&gt; as requested in the readme&lt;/li&gt;
&lt;li&gt;Rename the local administrator account as requested (can be done here or in
group policy)&lt;/li&gt;
&lt;li&gt;Make sure nobody unauthorized is in Administrators or other privileged groups&lt;/li&gt;
&lt;li&gt;Make sure no non-builtin users exist who aren&amp;rsquo;t mentioned, poking through
their home folders before deleting&lt;/li&gt;
&lt;li&gt;Disable the Guest account, and rename for good measure&lt;/li&gt;
&lt;li&gt;Change the password for all users&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;I&amp;rsquo;ll mention here that CyberPatriot often uses significantly outdated best
practices and ignores how things would be done in the real world, and we also
don&amp;rsquo;t know what this challenge will score on, so a lot of the things I check
and changes I make to this machine are excessive, paranoid, annoying, or
otherwise just weird. If we lose points for something we can easily undo the
change.&lt;/p&gt;
&lt;div class=&#34;alert alert-info&#34; role=&#34;alert&#34; data-dir=&#34;ltr&#34;&gt;Removed unauthorized user rooReaper - 3 points&lt;br&gt;
Removed unauthorized user rooDevil - 3 points&lt;br&gt;
Removed unauthorized user rooRage - 3 points&lt;br&gt;
User rooFrozen is not an administrator - 3 points&lt;br&gt;
User roocursion has been created - 3 points&lt;br&gt;
Administrator account renamed - 3 points&lt;br&gt;
Guest account is disabled - 4 points&lt;/div&gt;
&lt;h3 id=&#34;services-and-firewall&#34;&gt;Services and Firewall&lt;/h3&gt;
&lt;p&gt;Interspersed with everything else, I poke around &lt;code&gt;services.msc&lt;/code&gt; and the control
panel to make sure everything is sane. Enable the firewall
MOMtotallynotrooreaper told us to disable, then make sure there&amp;rsquo;s no
nonstandard or scary rules enabled. Enable cloud protection and sample
sumbission for Defender, make sure the scan finished. Right click My Computer
and click Properties, check $PATH and other environment variables for anything
weird, make sure Data Execution Prevention is enabled for all applications, and
disable NetBIOS.&lt;/p&gt;
&lt;div class=&#34;alert alert-info&#34; role=&#34;alert&#34; data-dir=&#34;ltr&#34;&gt;Windows Firewall is enabled - 5 points&lt;/div&gt;
&lt;h3 id=&#34;group-policy&#34;&gt;Group Policy&lt;/h3&gt;
&lt;p&gt;Before I forget, let&amp;rsquo;s make sure we&amp;rsquo;ve mitigated Print Nightmare. The
&lt;a href=&#34;https://msrc.microsoft.com/update-guide/vulnerability/CVE-2021-34527&#34;&gt;MSRC post&lt;/a&gt;
about it recommends updating (oops, can&amp;rsquo;t), disabling the print spooler (oops,
can&amp;rsquo;t), or disabling inbound remote printing with Group Policy.&lt;/p&gt;
&lt;p&gt;I fire up &lt;code&gt;gpedit.msc&lt;/code&gt;, open Computer Configuration -&amp;gt;
Windows Settings -&amp;gt; &amp;hellip; Where&amp;rsquo;s Security Settings?&lt;/p&gt;
&lt;p&gt;This is where I spent about half my time on this challenge. When launching
&lt;code&gt;gpedit.msc&lt;/code&gt;, Security Settings was missing. &lt;code&gt;secpol.msc&lt;/code&gt; would show the tree
starting at Windows Settings instead of Security Settings, and also omit the
latter. Many answers on the internet offered a simple &lt;code&gt;regsvr32 wsecedit.dll&lt;/code&gt;,
which doesn&amp;rsquo;t work as the DLL doesn&amp;rsquo;t have the correct entrypoints for that.
This is where I ran &lt;code&gt;dism /online /cleanup-image /restorehealth&lt;/code&gt; and
&lt;code&gt;sfc /scannow&lt;/code&gt;, which didn&amp;rsquo;t find any problems.&lt;/p&gt;
&lt;p&gt;I never did figure out what was done to break that, as I eventually gave up and
tried importing an exported policy, and later started setting the policy
registry entries by hand. After a while, I opened the mmc snapin again, and
Security Settings was there!&lt;/p&gt;
&lt;p&gt;It seems that it&amp;rsquo;s only broken for the rooYay user, and after setting UAC to
require a password, I was unintentionally elevating as rooAstro, for whom it
worked correctly. Something in my profile was breaking it. Some windows
LD_LIBRARY_PATH type thing? Something in HKEY_CURRENT_USER? It didn&amp;rsquo;t directly
affect security, so I put it aside again.&lt;/p&gt;
&lt;p&gt;From there, I could much more easily continue with group policy, basically just
going through every option in Security Settings -&amp;gt; Account Policies and Local
Policies and some folders in Administrative Templates -&amp;gt; Windows Settings,
setting everything to the most paranoid sane option.&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;
&lt;p&gt;Remember 24 passwords&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;60 day maximum password age&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;10 day minimum password age&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;14 character minimum length&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Must meet complexity requirements&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;No reversible encryption&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;15 minute account lockout duration&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;10 attempt lockout threshold&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;15 minute counter reset timer&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Enable all auditing&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Go through User Rights Assignment and restrict everything as much as possible&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Hey, why is &lt;code&gt;Everyone&lt;/code&gt; allowed to take ownership of files??&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;You know what, let&amp;rsquo;s just disable the Administrator account&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;I don&amp;rsquo;t like Microsoft account signin&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;More audit everything&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Prevent users from installing printer drivers (well&amp;hellip; try to)&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Restrict CD-ROM access to locally logged-on users&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Require CTRL+ALT+DEL, force inactivity limit, require strong encryption&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;You get the idea.&lt;/p&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;div class=&#34;alert alert-info&#34; role=&#34;alert&#34; data-dir=&#34;ltr&#34;&gt;Everyone is not allowed to take ownership of files and other objects - 5 points&lt;/div&gt;
&lt;h3 id=&#34;critical-services&#34;&gt;Critical Services&lt;/h3&gt;
&lt;p&gt;And let&amp;rsquo;s not forget to secure our critical services. The MSRC Print Nightmare
article points me to Administrative Templates -&amp;gt; Printers to disable &amp;ldquo;Allow
Print Spooler to accept client connections&amp;rdquo;. There have been a few RDP
vulnerabilities, but none with straightforward workarounds besides patching, so
let&amp;rsquo;s just be sure to flip on all of the RDP server security policies. Lastly,
we weren&amp;rsquo;t disallowed from disabling old versions of SMB, so use the powershell
command in the
&lt;a href=&#34;https://docs.microsoft.com/en-us/windows-server/storage/file-server/troubleshoot/detect-enable-and-disable-smbv1-v2-v3&#34;&gt;docs&lt;/a&gt;,
to check for SMBv1 and see it&amp;rsquo;s already disabled.&lt;/p&gt;
&lt;div class=&#34;alert alert-info&#34; role=&#34;alert&#34; data-dir=&#34;ltr&#34;&gt;Inbound remote printing is disabled (PrintNightmare mitigation) - 9 points&lt;br&gt;
Remote Desktop uses network level authentication - 4 points&lt;/div&gt;
&lt;h3 id=&#34;other-stuff&#34;&gt;Other Stuff&lt;/h3&gt;
&lt;p&gt;In an advanced challenge, in addition to &lt;code&gt;sfc&lt;/code&gt; and &lt;code&gt;dism&lt;/code&gt; to look for
&amp;ldquo;creatively modified&amp;rdquo; system files, &lt;code&gt;hijackthis&lt;/code&gt; can be helpful. In case
of a well-disguised network backdoor, it&amp;rsquo;s also good to check open sockets.&lt;/p&gt;
&lt;h3 id=&#34;conclusion&#34;&gt;Conclusion&lt;/h3&gt;
&lt;p&gt;And with that, I had 91 points, 20/21 items, and the flag appeared in the score
report. There was one scored item I never found, worth 9 points. I&amp;rsquo;ll be
waiting for a writeup from tirefire, the only person with 100 points, to see
what I missed!&lt;/p&gt;
&lt;div class=&#34;alert alert-success&#34; role=&#34;alert&#34; data-dir=&#34;ltr&#34;&gt;Unique ID: &lt;code&gt;8edd464b&lt;/code&gt;&lt;br&gt;
Flag: &lt;code&gt;ictf{th4nks_s0_much_f0r_s3cur1ng_0ur_s3rver!_h3r3s_4_fl4g!!!}&lt;/code&gt;&lt;/div&gt;
&lt;h3 id=&#34;update&#34;&gt;Update&lt;/h3&gt;
&lt;p&gt;First, Eth007, one of the challenge authors, let me know that the last scored
item I couldn&amp;rsquo;t find was
&lt;a href=&#34;https://docs.microsoft.com/en-us/windows-server/security/credentials-protection-and-management/configuring-additional-lsa-protection&#34;&gt;LSA protection&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;Second, thank you to the iCTF team for selecting this as a prize-winning writeup!&lt;/p&gt;
&lt;h2 id=&#34;new-technology&#34;&gt;New Technology&lt;/h2&gt;
&lt;p&gt;&lt;em&gt;&amp;ldquo;If it&amp;rsquo;s not Windows New Technology, what else could NT stand for?&amp;rdquo;&lt;/em&gt;&lt;/p&gt;
&lt;p&gt;This was a 300pt cryptography challenge in the form of a &lt;a href=&#34;https://imaginaryctf.org/r/3204-new_technology.py&#34;&gt;python
script&lt;/a&gt;.
It generates a random key consisting of 5 tuples, each a 512-bit prime &lt;code&gt;p&lt;/code&gt; and
an integer exponent $1 \le e &amp;lt; 4$.&lt;/p&gt;
&lt;div class=&#34;highlight&#34;&gt;&lt;pre tabindex=&#34;0&#34; style=&#34;color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;&#34;&gt;&lt;code class=&#34;language-python&#34; data-lang=&#34;python&#34;&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;&lt;span style=&#34;color:#66d9ef&#34;&gt;def&lt;/span&gt; &lt;span style=&#34;color:#a6e22e&#34;&gt;gen&lt;/span&gt;():
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;    private &lt;span style=&#34;color:#f92672&#34;&gt;=&lt;/span&gt; []
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;    &lt;span style=&#34;color:#66d9ef&#34;&gt;for&lt;/span&gt; _ &lt;span style=&#34;color:#f92672&#34;&gt;in&lt;/span&gt; range(&lt;span style=&#34;color:#ae81ff&#34;&gt;5&lt;/span&gt;):
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;        p &lt;span style=&#34;color:#f92672&#34;&gt;=&lt;/span&gt; getPrime(&lt;span style=&#34;color:#ae81ff&#34;&gt;512&lt;/span&gt;)
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;        e &lt;span style=&#34;color:#f92672&#34;&gt;=&lt;/span&gt; getRandomRange(&lt;span style=&#34;color:#ae81ff&#34;&gt;1&lt;/span&gt;, &lt;span style=&#34;color:#ae81ff&#34;&gt;4&lt;/span&gt;)
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;        private&lt;span style=&#34;color:#f92672&#34;&gt;.&lt;/span&gt;append((p, e))
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;    &lt;span style=&#34;color:#66d9ef&#34;&gt;return&lt;/span&gt; private, normalize(private)
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;The public key is derived by the &lt;code&gt;normalize()&lt;/code&gt; function, which multiplies
together &lt;code&gt;p**e&lt;/code&gt; for each private key component.&lt;/p&gt;
&lt;div class=&#34;highlight&#34;&gt;&lt;pre tabindex=&#34;0&#34; style=&#34;color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;&#34;&gt;&lt;code class=&#34;language-python&#34; data-lang=&#34;python&#34;&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;&lt;span style=&#34;color:#66d9ef&#34;&gt;def&lt;/span&gt; &lt;span style=&#34;color:#a6e22e&#34;&gt;normalize&lt;/span&gt;(fac):
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;    n &lt;span style=&#34;color:#f92672&#34;&gt;=&lt;/span&gt; &lt;span style=&#34;color:#ae81ff&#34;&gt;1&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;    &lt;span style=&#34;color:#66d9ef&#34;&gt;for&lt;/span&gt; p, e &lt;span style=&#34;color:#f92672&#34;&gt;in&lt;/span&gt; fac:
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;        n &lt;span style=&#34;color:#f92672&#34;&gt;*=&lt;/span&gt; p&lt;span style=&#34;color:#f92672&#34;&gt;**&lt;/span&gt;e
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;    &lt;span style=&#34;color:#66d9ef&#34;&gt;return&lt;/span&gt; n
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;Since these are 512-bit primes, the resulting public key isn&amp;rsquo;t easy to factor.&lt;/p&gt;
&lt;p&gt;The private key is put through the &lt;code&gt;deriv()&lt;/code&gt; function, which has a nested
loop based on &lt;code&gt;divs()&lt;/code&gt;.&lt;/p&gt;
&lt;div class=&#34;highlight&#34;&gt;&lt;pre tabindex=&#34;0&#34; style=&#34;color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;&#34;&gt;&lt;code class=&#34;language-python&#34; data-lang=&#34;python&#34;&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;&lt;span style=&#34;color:#66d9ef&#34;&gt;def&lt;/span&gt; &lt;span style=&#34;color:#a6e22e&#34;&gt;deriv&lt;/span&gt;(priv):
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;    res &lt;span style=&#34;color:#f92672&#34;&gt;=&lt;/span&gt; &lt;span style=&#34;color:#ae81ff&#34;&gt;0&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;    &lt;span style=&#34;color:#66d9ef&#34;&gt;for&lt;/span&gt; d1 &lt;span style=&#34;color:#f92672&#34;&gt;in&lt;/span&gt; divs(priv):
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;        &lt;span style=&#34;color:#66d9ef&#34;&gt;for&lt;/span&gt; d2 &lt;span style=&#34;color:#f92672&#34;&gt;in&lt;/span&gt; divs(d1):
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;            res &lt;span style=&#34;color:#f92672&#34;&gt;+=&lt;/span&gt; normalize(d2) &lt;span style=&#34;color:#f92672&#34;&gt;*&lt;/span&gt; phi(d2) &lt;span style=&#34;color:#f92672&#34;&gt;*&lt;/span&gt; phi(div(d1, d2))
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;    &lt;span style=&#34;color:#66d9ef&#34;&gt;return&lt;/span&gt; res
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;&lt;code&gt;divs()&lt;/code&gt; takes the same &lt;code&gt;List[Set[prime: int, exponent: int], ...]&lt;/code&gt; private key
format and yields the cartesian product of them based on the range 0..e of
their exponents:&lt;/p&gt;
&lt;div class=&#34;highlight&#34;&gt;&lt;pre tabindex=&#34;0&#34; style=&#34;color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;&#34;&gt;&lt;code class=&#34;language-python&#34; data-lang=&#34;python&#34;&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;&lt;span style=&#34;color:#66d9ef&#34;&gt;def&lt;/span&gt; &lt;span style=&#34;color:#a6e22e&#34;&gt;divs&lt;/span&gt;(fac, pre&lt;span style=&#34;color:#f92672&#34;&gt;=&lt;/span&gt;&lt;span style=&#34;color:#66d9ef&#34;&gt;None&lt;/span&gt;):
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;    &lt;span style=&#34;color:#66d9ef&#34;&gt;if&lt;/span&gt; pre &lt;span style=&#34;color:#f92672&#34;&gt;is&lt;/span&gt; &lt;span style=&#34;color:#66d9ef&#34;&gt;None&lt;/span&gt;:
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;        pre &lt;span style=&#34;color:#f92672&#34;&gt;=&lt;/span&gt; []
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;    &lt;span style=&#34;color:#66d9ef&#34;&gt;if&lt;/span&gt; &lt;span style=&#34;color:#f92672&#34;&gt;not&lt;/span&gt; fac:
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;        &lt;span style=&#34;color:#66d9ef&#34;&gt;yield&lt;/span&gt; pre
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;    &lt;span style=&#34;color:#66d9ef&#34;&gt;else&lt;/span&gt;:
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;        p, e &lt;span style=&#34;color:#f92672&#34;&gt;=&lt;/span&gt; fac[&lt;span style=&#34;color:#ae81ff&#34;&gt;0&lt;/span&gt;]
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;        &lt;span style=&#34;color:#66d9ef&#34;&gt;for&lt;/span&gt; i &lt;span style=&#34;color:#f92672&#34;&gt;in&lt;/span&gt; range(&lt;span style=&#34;color:#ae81ff&#34;&gt;0&lt;/span&gt;, e &lt;span style=&#34;color:#f92672&#34;&gt;+&lt;/span&gt; &lt;span style=&#34;color:#ae81ff&#34;&gt;1&lt;/span&gt;):
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;            &lt;span style=&#34;color:#66d9ef&#34;&gt;yield from&lt;/span&gt; divs(fac[&lt;span style=&#34;color:#ae81ff&#34;&gt;1&lt;/span&gt;:], pre &lt;span style=&#34;color:#f92672&#34;&gt;+&lt;/span&gt; [(p, i)]
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;div class=&#34;highlight&#34;&gt;&lt;pre tabindex=&#34;0&#34; style=&#34;color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;&#34;&gt;&lt;code class=&#34;language-python&#34; data-lang=&#34;python&#34;&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;&lt;span style=&#34;color:#f92672&#34;&gt;&amp;gt;&amp;gt;&amp;gt;&lt;/span&gt; priv &lt;span style=&#34;color:#f92672&#34;&gt;=&lt;/span&gt; [(&lt;span style=&#34;color:#ae81ff&#34;&gt;167&lt;/span&gt;, &lt;span style=&#34;color:#ae81ff&#34;&gt;1&lt;/span&gt;), (&lt;span style=&#34;color:#ae81ff&#34;&gt;149&lt;/span&gt;, &lt;span style=&#34;color:#ae81ff&#34;&gt;2&lt;/span&gt;)]
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;&lt;span style=&#34;color:#f92672&#34;&gt;&amp;gt;&amp;gt;&amp;gt;&lt;/span&gt; pprint(list(divs(priv)))
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;[[(&lt;span style=&#34;color:#ae81ff&#34;&gt;167&lt;/span&gt;, &lt;span style=&#34;color:#ae81ff&#34;&gt;0&lt;/span&gt;), (&lt;span style=&#34;color:#ae81ff&#34;&gt;149&lt;/span&gt;, &lt;span style=&#34;color:#ae81ff&#34;&gt;0&lt;/span&gt;)],
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt; [(&lt;span style=&#34;color:#ae81ff&#34;&gt;167&lt;/span&gt;, &lt;span style=&#34;color:#ae81ff&#34;&gt;0&lt;/span&gt;), (&lt;span style=&#34;color:#ae81ff&#34;&gt;149&lt;/span&gt;, &lt;span style=&#34;color:#ae81ff&#34;&gt;1&lt;/span&gt;)],
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt; [(&lt;span style=&#34;color:#ae81ff&#34;&gt;167&lt;/span&gt;, &lt;span style=&#34;color:#ae81ff&#34;&gt;0&lt;/span&gt;), (&lt;span style=&#34;color:#ae81ff&#34;&gt;149&lt;/span&gt;, &lt;span style=&#34;color:#ae81ff&#34;&gt;2&lt;/span&gt;)],
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt; [(&lt;span style=&#34;color:#ae81ff&#34;&gt;167&lt;/span&gt;, &lt;span style=&#34;color:#ae81ff&#34;&gt;1&lt;/span&gt;), (&lt;span style=&#34;color:#ae81ff&#34;&gt;149&lt;/span&gt;, &lt;span style=&#34;color:#ae81ff&#34;&gt;0&lt;/span&gt;)],
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt; [(&lt;span style=&#34;color:#ae81ff&#34;&gt;167&lt;/span&gt;, &lt;span style=&#34;color:#ae81ff&#34;&gt;1&lt;/span&gt;), (&lt;span style=&#34;color:#ae81ff&#34;&gt;149&lt;/span&gt;, &lt;span style=&#34;color:#ae81ff&#34;&gt;1&lt;/span&gt;)],
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt; [(&lt;span style=&#34;color:#ae81ff&#34;&gt;167&lt;/span&gt;, &lt;span style=&#34;color:#ae81ff&#34;&gt;1&lt;/span&gt;), (&lt;span style=&#34;color:#ae81ff&#34;&gt;149&lt;/span&gt;, &lt;span style=&#34;color:#ae81ff&#34;&gt;2&lt;/span&gt;)]]
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;For each entry in this list, &lt;code&gt;d1&lt;/code&gt;, &lt;code&gt;deriv()&lt;/code&gt; again calls &lt;code&gt;divs()&lt;/code&gt;, and loops on
that &lt;code&gt;d2&lt;/code&gt;, adding &lt;code&gt;normalize(d2) * phi(d2) * phi(div(d1, d2))&lt;/code&gt; to a running
total.&lt;/p&gt;
&lt;div class=&#34;highlight&#34;&gt;&lt;pre tabindex=&#34;0&#34; style=&#34;color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;&#34;&gt;&lt;code class=&#34;language-python&#34; data-lang=&#34;python&#34;&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;&lt;span style=&#34;color:#66d9ef&#34;&gt;def&lt;/span&gt; &lt;span style=&#34;color:#a6e22e&#34;&gt;phi&lt;/span&gt;(fac):
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;    res &lt;span style=&#34;color:#f92672&#34;&gt;=&lt;/span&gt; &lt;span style=&#34;color:#ae81ff&#34;&gt;1&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;    &lt;span style=&#34;color:#66d9ef&#34;&gt;for&lt;/span&gt; p, e &lt;span style=&#34;color:#f92672&#34;&gt;in&lt;/span&gt; fac:
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;        &lt;span style=&#34;color:#66d9ef&#34;&gt;if&lt;/span&gt; &lt;span style=&#34;color:#f92672&#34;&gt;not&lt;/span&gt; e: &lt;span style=&#34;color:#66d9ef&#34;&gt;continue&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;        res &lt;span style=&#34;color:#f92672&#34;&gt;*=&lt;/span&gt; (p&lt;span style=&#34;color:#f92672&#34;&gt;**&lt;/span&gt;(e &lt;span style=&#34;color:#f92672&#34;&gt;-&lt;/span&gt; &lt;span style=&#34;color:#ae81ff&#34;&gt;1&lt;/span&gt;)) &lt;span style=&#34;color:#f92672&#34;&gt;*&lt;/span&gt; (p &lt;span style=&#34;color:#f92672&#34;&gt;-&lt;/span&gt; &lt;span style=&#34;color:#ae81ff&#34;&gt;1&lt;/span&gt;)
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;    &lt;span style=&#34;color:#66d9ef&#34;&gt;return&lt;/span&gt; res
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;&lt;span style=&#34;color:#66d9ef&#34;&gt;def&lt;/span&gt; &lt;span style=&#34;color:#a6e22e&#34;&gt;div&lt;/span&gt;(a, b):  &lt;span style=&#34;color:#75715e&#34;&gt;# a=d1, b=d2&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;    b &lt;span style=&#34;color:#f92672&#34;&gt;=&lt;/span&gt; dict(b)
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;    res &lt;span style=&#34;color:#f92672&#34;&gt;=&lt;/span&gt; []
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;    &lt;span style=&#34;color:#66d9ef&#34;&gt;for&lt;/span&gt; p, e &lt;span style=&#34;color:#f92672&#34;&gt;in&lt;/span&gt; a:
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;        &lt;span style=&#34;color:#66d9ef&#34;&gt;assert&lt;/span&gt; e &lt;span style=&#34;color:#f92672&#34;&gt;&amp;gt;=&lt;/span&gt; b[p]
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;        res&lt;span style=&#34;color:#f92672&#34;&gt;.&lt;/span&gt;append((p, e &lt;span style=&#34;color:#f92672&#34;&gt;-&lt;/span&gt; b[p]))
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;    &lt;span style=&#34;color:#66d9ef&#34;&gt;return&lt;/span&gt; res
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;At some point here things started to smell funny - we&amp;rsquo;re collecting the sum of
some math done on every divisor of every divisor&amp;hellip; Just for fun, let&amp;rsquo;s see how
this behaves when run all the way through with more manageable numbers, maybe
12 bits.&lt;/p&gt;
&lt;div class=&#34;highlight&#34;&gt;&lt;pre tabindex=&#34;0&#34; style=&#34;color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;&#34;&gt;&lt;code class=&#34;language-python&#34; data-lang=&#34;python&#34;&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;&lt;span style=&#34;color:#66d9ef&#34;&gt;def&lt;/span&gt; &lt;span style=&#34;color:#a6e22e&#34;&gt;gen_custom&lt;/span&gt;(count&lt;span style=&#34;color:#f92672&#34;&gt;=&lt;/span&gt;&lt;span style=&#34;color:#ae81ff&#34;&gt;5&lt;/span&gt;, size&lt;span style=&#34;color:#f92672&#34;&gt;=&lt;/span&gt;&lt;span style=&#34;color:#ae81ff&#34;&gt;512&lt;/span&gt;, max_exp&lt;span style=&#34;color:#f92672&#34;&gt;=&lt;/span&gt;&lt;span style=&#34;color:#ae81ff&#34;&gt;3&lt;/span&gt;):
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;    private &lt;span style=&#34;color:#f92672&#34;&gt;=&lt;/span&gt; []
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;    &lt;span style=&#34;color:#66d9ef&#34;&gt;for&lt;/span&gt; _ &lt;span style=&#34;color:#f92672&#34;&gt;in&lt;/span&gt; range(count):
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;        p &lt;span style=&#34;color:#f92672&#34;&gt;=&lt;/span&gt; getPrime(size)
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;        e &lt;span style=&#34;color:#f92672&#34;&gt;=&lt;/span&gt; getRandomRange(&lt;span style=&#34;color:#ae81ff&#34;&gt;1&lt;/span&gt;, max_exp&lt;span style=&#34;color:#f92672&#34;&gt;+&lt;/span&gt;&lt;span style=&#34;color:#ae81ff&#34;&gt;1&lt;/span&gt;)
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;        private&lt;span style=&#34;color:#f92672&#34;&gt;.&lt;/span&gt;append((p, e))
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;    &lt;span style=&#34;color:#66d9ef&#34;&gt;return&lt;/span&gt; private, normalize(private)
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;div class=&#34;highlight&#34;&gt;&lt;pre tabindex=&#34;0&#34; style=&#34;color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;&#34;&gt;&lt;code class=&#34;language-python&#34; data-lang=&#34;python&#34;&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;&lt;span style=&#34;color:#f92672&#34;&gt;&amp;gt;&amp;gt;&amp;gt;&lt;/span&gt; priv, pub &lt;span style=&#34;color:#f92672&#34;&gt;=&lt;/span&gt; gen_custom(&lt;span style=&#34;color:#ae81ff&#34;&gt;5&lt;/span&gt;, &lt;span style=&#34;color:#ae81ff&#34;&gt;12&lt;/span&gt;, &lt;span style=&#34;color:#ae81ff&#34;&gt;3&lt;/span&gt;)
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;&lt;span style=&#34;color:#f92672&#34;&gt;&amp;gt;&amp;gt;&amp;gt;&lt;/span&gt; priv
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;[(&lt;span style=&#34;color:#ae81ff&#34;&gt;3251&lt;/span&gt;, &lt;span style=&#34;color:#ae81ff&#34;&gt;1&lt;/span&gt;), (&lt;span style=&#34;color:#ae81ff&#34;&gt;3863&lt;/span&gt;, &lt;span style=&#34;color:#ae81ff&#34;&gt;1&lt;/span&gt;), (&lt;span style=&#34;color:#ae81ff&#34;&gt;2917&lt;/span&gt;, &lt;span style=&#34;color:#ae81ff&#34;&gt;2&lt;/span&gt;), (&lt;span style=&#34;color:#ae81ff&#34;&gt;3761&lt;/span&gt;, &lt;span style=&#34;color:#ae81ff&#34;&gt;3&lt;/span&gt;), (&lt;span style=&#34;color:#ae81ff&#34;&gt;3989&lt;/span&gt;, &lt;span style=&#34;color:#ae81ff&#34;&gt;2&lt;/span&gt;)]
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;&lt;span style=&#34;color:#f92672&#34;&gt;&amp;gt;&amp;gt;&amp;gt;&lt;/span&gt; pub
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;&lt;span style=&#34;color:#ae81ff&#34;&gt;90459172118968888949999762493557&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;&lt;span style=&#34;color:#f92672&#34;&gt;&amp;gt;&amp;gt;&amp;gt;&lt;/span&gt; key &lt;span style=&#34;color:#f92672&#34;&gt;=&lt;/span&gt; deriv(priv)
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;&lt;span style=&#34;color:#f92672&#34;&gt;&amp;gt;&amp;gt;&amp;gt;&lt;/span&gt; key
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;&lt;span style=&#34;color:#ae81ff&#34;&gt;8182861820449238390507452368725018700352715647046709310466512249&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;&lt;span style=&#34;color:#f92672&#34;&gt;&amp;gt;&amp;gt;&amp;gt;&lt;/span&gt; &lt;span style=&#34;color:#f92672&#34;&gt;from&lt;/span&gt; sage.all &lt;span style=&#34;color:#f92672&#34;&gt;import&lt;/span&gt; &lt;span style=&#34;color:#f92672&#34;&gt;*&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;&lt;span style=&#34;color:#f92672&#34;&gt;&amp;gt;&amp;gt;&amp;gt;&lt;/span&gt; factor(pub)
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;&lt;span style=&#34;color:#ae81ff&#34;&gt;2917&lt;/span&gt;&lt;span style=&#34;color:#f92672&#34;&gt;^&lt;/span&gt;&lt;span style=&#34;color:#ae81ff&#34;&gt;2&lt;/span&gt; &lt;span style=&#34;color:#f92672&#34;&gt;*&lt;/span&gt; &lt;span style=&#34;color:#ae81ff&#34;&gt;3251&lt;/span&gt; &lt;span style=&#34;color:#f92672&#34;&gt;*&lt;/span&gt; &lt;span style=&#34;color:#ae81ff&#34;&gt;3761&lt;/span&gt;&lt;span style=&#34;color:#f92672&#34;&gt;^&lt;/span&gt;&lt;span style=&#34;color:#ae81ff&#34;&gt;3&lt;/span&gt; &lt;span style=&#34;color:#f92672&#34;&gt;*&lt;/span&gt; &lt;span style=&#34;color:#ae81ff&#34;&gt;3863&lt;/span&gt; &lt;span style=&#34;color:#f92672&#34;&gt;*&lt;/span&gt; &lt;span style=&#34;color:#ae81ff&#34;&gt;3989&lt;/span&gt;&lt;span style=&#34;color:#f92672&#34;&gt;^&lt;/span&gt;&lt;span style=&#34;color:#ae81ff&#34;&gt;2&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;&lt;span style=&#34;color:#f92672&#34;&gt;&amp;gt;&amp;gt;&amp;gt;&lt;/span&gt; factor(key)
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;&lt;span style=&#34;color:#ae81ff&#34;&gt;2917&lt;/span&gt;&lt;span style=&#34;color:#f92672&#34;&gt;^&lt;/span&gt;&lt;span style=&#34;color:#ae81ff&#34;&gt;4&lt;/span&gt; &lt;span style=&#34;color:#f92672&#34;&gt;*&lt;/span&gt; &lt;span style=&#34;color:#ae81ff&#34;&gt;3251&lt;/span&gt;&lt;span style=&#34;color:#f92672&#34;&gt;^&lt;/span&gt;&lt;span style=&#34;color:#ae81ff&#34;&gt;2&lt;/span&gt; &lt;span style=&#34;color:#f92672&#34;&gt;*&lt;/span&gt; &lt;span style=&#34;color:#ae81ff&#34;&gt;3761&lt;/span&gt;&lt;span style=&#34;color:#f92672&#34;&gt;^&lt;/span&gt;&lt;span style=&#34;color:#ae81ff&#34;&gt;6&lt;/span&gt; &lt;span style=&#34;color:#f92672&#34;&gt;*&lt;/span&gt; &lt;span style=&#34;color:#ae81ff&#34;&gt;3863&lt;/span&gt;&lt;span style=&#34;color:#f92672&#34;&gt;^&lt;/span&gt;&lt;span style=&#34;color:#ae81ff&#34;&gt;2&lt;/span&gt; &lt;span style=&#34;color:#f92672&#34;&gt;*&lt;/span&gt; &lt;span style=&#34;color:#ae81ff&#34;&gt;3989&lt;/span&gt;&lt;span style=&#34;color:#f92672&#34;&gt;^&lt;/span&gt;&lt;span style=&#34;color:#ae81ff&#34;&gt;4&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;If you don&amp;rsquo;t have &lt;a href=&#34;https://sagemath.org/&#34;&gt;sagemath&lt;/a&gt; installed, you can also use
a handy dandy &lt;a href=&#34;https://www.alpertron.com.ar/ECM.HTM&#34;&gt;webassembly ECM factorization tool&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;The factors of the public key aren&amp;rsquo;t surprising, that&amp;rsquo;s the exact math we used
to derive it from the private key, but possible to reverse since we used small
numbers. On the other hand, what&amp;rsquo;s up with the private key? Each factor
just has double the exponent? And since $x^2 * y^2 = (xy)^2$, and
$(x^3)^2 = x^6$&amp;hellip; Our private key is just the square of the public key??&lt;/p&gt;
&lt;div class=&#34;highlight&#34;&gt;&lt;pre tabindex=&#34;0&#34; style=&#34;color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;&#34;&gt;&lt;code class=&#34;language-python&#34; data-lang=&#34;python&#34;&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;&lt;span style=&#34;color:#f92672&#34;&gt;&amp;gt;&amp;gt;&amp;gt;&lt;/span&gt; key &lt;span style=&#34;color:#f92672&#34;&gt;==&lt;/span&gt; pub&lt;span style=&#34;color:#f92672&#34;&gt;**&lt;/span&gt;&lt;span style=&#34;color:#ae81ff&#34;&gt;2&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;&lt;span style=&#34;color:#66d9ef&#34;&gt;True&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;Well then! Let&amp;rsquo;s assign those commented output values to variables, square the
public key, get a new AES instance for decrypting, and&amp;hellip;&lt;/p&gt;
&lt;div class=&#34;highlight&#34;&gt;&lt;pre tabindex=&#34;0&#34; style=&#34;color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;&#34;&gt;&lt;code class=&#34;language-python&#34; data-lang=&#34;python&#34;&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;pub &lt;span style=&#34;color:#f92672&#34;&gt;=&lt;/span&gt; &lt;span style=&#34;color:#ae81ff&#34;&gt;0x281ab467e16cdedb97a298249bdd334f0cc7d54177ed0946c04ec26da111&lt;/span&gt;&lt;span style=&#34;color:#f92672&#34;&gt;...&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;ciphertext &lt;span style=&#34;color:#f92672&#34;&gt;=&lt;/span&gt; bytes&lt;span style=&#34;color:#f92672&#34;&gt;.&lt;/span&gt;fromhex(&lt;span style=&#34;color:#e6db74&#34;&gt;&amp;#34;d2463ccc52075674effbad1b1ea5ae9a9c8106f1...&amp;#34;&lt;/span&gt;)
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;key &lt;span style=&#34;color:#f92672&#34;&gt;=&lt;/span&gt; pub&lt;span style=&#34;color:#f92672&#34;&gt;**&lt;/span&gt;&lt;span style=&#34;color:#ae81ff&#34;&gt;2&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;cipher &lt;span style=&#34;color:#f92672&#34;&gt;=&lt;/span&gt; AES&lt;span style=&#34;color:#f92672&#34;&gt;.&lt;/span&gt;new(
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;    hashlib&lt;span style=&#34;color:#f92672&#34;&gt;.&lt;/span&gt;sha256(str(key)&lt;span style=&#34;color:#f92672&#34;&gt;.&lt;/span&gt;encode(&lt;span style=&#34;color:#e6db74&#34;&gt;&amp;#34;utf-8&amp;#34;&lt;/span&gt;))&lt;span style=&#34;color:#f92672&#34;&gt;.&lt;/span&gt;digest(),
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;    AES&lt;span style=&#34;color:#f92672&#34;&gt;.&lt;/span&gt;MODE_CBC,
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;    iv&lt;span style=&#34;color:#f92672&#34;&gt;=&lt;/span&gt;&lt;span style=&#34;color:#e6db74&#34;&gt;b&lt;/span&gt;&lt;span style=&#34;color:#e6db74&#34;&gt;&amp;#34;&lt;/span&gt;&lt;span style=&#34;color:#ae81ff&#34;&gt;\0&lt;/span&gt;&lt;span style=&#34;color:#e6db74&#34;&gt;&amp;#34;&lt;/span&gt; &lt;span style=&#34;color:#f92672&#34;&gt;*&lt;/span&gt; &lt;span style=&#34;color:#ae81ff&#34;&gt;16&lt;/span&gt;,
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;)
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;plaintext &lt;span style=&#34;color:#f92672&#34;&gt;=&lt;/span&gt; cipher&lt;span style=&#34;color:#f92672&#34;&gt;.&lt;/span&gt;decrypt(ciphertext)
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;print(plaintext)
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;And, drumroll&amp;hellip;
&lt;code&gt;b&#39;ictf{Would_number_theory_be_new_technology?}\x04\x04\x04\x04&#39;&lt;/code&gt;!
For good practice, let&amp;rsquo;s clean that up a bit by removing the padding and
turning it back into a unicode string:&lt;/p&gt;
&lt;div class=&#34;highlight&#34;&gt;&lt;pre tabindex=&#34;0&#34; style=&#34;color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;&#34;&gt;&lt;code class=&#34;language-python&#34; data-lang=&#34;python&#34;&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;&lt;span style=&#34;color:#f92672&#34;&gt;from&lt;/span&gt; Crypto.Util.Padding &lt;span style=&#34;color:#f92672&#34;&gt;import&lt;/span&gt; unpad
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;print(unpad(plaintext, &lt;span style=&#34;color:#ae81ff&#34;&gt;16&lt;/span&gt;)&lt;span style=&#34;color:#f92672&#34;&gt;.&lt;/span&gt;decode(&lt;span style=&#34;color:#e6db74&#34;&gt;&amp;#34;utf-8&amp;#34;&lt;/span&gt;))
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;And there we have it!&lt;/p&gt;
&lt;div class=&#34;alert alert-success&#34; role=&#34;alert&#34; data-dir=&#34;ltr&#34;&gt;Flag: &lt;code&gt;ictf{Would_number_theory_be_new_technology?}&lt;/code&gt;&lt;/div&gt;
&lt;h2 id=&#34;thanks&#34;&gt;Thanks&lt;/h2&gt;
&lt;p&gt;Thank you to my team for a friendly place to be the dumbest person in the room,
and to the ImaginaryCTF platform folks and challenge developers for the
interesting and challenging &amp;hellip; challenges.&lt;/p&gt;
&lt;p&gt;The header image is from the ImaginaryCTF 2021 site (&lt;a href=&#34;https://github.com/et3rnos/imaginaryctf&#34;&gt;repo&lt;/a&gt;),
used with permission from Astro.&lt;/p&gt;
&lt;div class=&#34;footnotes&#34; role=&#34;doc-endnotes&#34;&gt;
&lt;hr&gt;
&lt;ol&gt;
&lt;li id=&#34;fn:1&#34;&gt;
&lt;p&gt;I&amp;rsquo;ve taken some liberties with the order I present objectives here,
since a writeup that followed my actual path would be impossible to follow.&amp;#160;&lt;a href=&#34;#fnref:1&#34; class=&#34;footnote-backref&#34; role=&#34;doc-backlink&#34;&gt;&amp;#x21a9;&amp;#xfe0e;&lt;/a&gt;&lt;/p&gt;
&lt;/li&gt;
&lt;/ol&gt;
&lt;/div&gt;
]]></content:encoded>
        <dc:creator>mal</dc:creator>
        <media:content url="https://sec.gd/blog/images/imaginaryctf-2021/ictf-2021-banner.jpg" medium="image"><media:title type="html">featured image</media:title></media:content>
        
        <media:content url="https://sec.gd/blog/images/imaginaryctf-2021/ictf-2021-banner.jpg" medium="image"><media:title type="html">meta image</media:title></media:content>
        
          
            
              <category>imaginaryctf</category>
            
          
            
              <category>crypto</category>
            
          
            
              <category>misc</category>
            
          
            
              <category>sysadmin</category>
            
          
        
        
          
            
              <category>ctf</category>
            
          
        
        
      </item>
    
  </channel>
</rss>