SlideShare a Scribd company logo
Hack The Box OpenAdmin 10.10.10.171 Writeup
By Kaiziron (Please give a respect in my HTB profile
https://www.hackthebox.eu/home/users/profile/76593)
I am new to penetration testing. This is my first writeup on Hack The Box.
--------------------------------------------------------------------------------------------------------------------------------------
So, we will start with a nmap scan.
We can see that port 22(SSH) and port 80(http) are open. And we will first enumerate port 80 first.
We can see it is an apache2 default page, so some other pages may in some other locations.
Let’s use dirbuster to see if we can find any other pages. After a while, dirbuster found a page /ona
Let’s browser to that page and see if there’s any information disclosure.
We can see it show that the version is v18.1.1 and the “DOWNLOAD” hyperlink show that it is
probably running something called opennetadmin.
We found an exploit for this version of opennetadmin in github by googling.
https://github.com/amriunix/ona-rce
It is a python script which can check if the target is vulnerable, and of course can also exploit this
vulnerability.
That script show that our target is vulnerable to this exploit. Then we will use it to exploit the
vulnerability and try gain a shell.
We gain a shell as www-data. However we are in /opt/ona/www and unable to change directory
with cd, but we can use ls and also cat so it doesn’t matter at all.
After some enumeration we found there is a file in /opt/ona/www/local/config called
database_settings.inc.php . We use cat to open it up.
And it seems is the credentials of some database. Don’t forget that port 22(SSH) is open.
Let’s try to login with SSH with the password n1nj4W4rri0R! and see if there’s any password reuse.
We use “cat /etc/passwd” to open up the passwd file to check some username in this machine.
We can found 2 users, called jimmy and Joanna.
We can also find the user by using “ls -la /home/” to check for home folder of user.
Then we will try to use SSH to login to those users using sshpass to enter in one line for convenient.
sshpass -p n1nj4W4rri0R! ssh jimmy@10.10.10.171
sshpass -p n1nj4W4rri0R! ssh joanna@10.10.10.171
We can successfully login as jimmy but not Joanna.
After some enumeration, we found few interesting things, first there is a folder in /var/www/ called
internal which is owned by user jimmy which looks like a webpage.
We found few pages inside the internal folder, one of them is very interesting.
This php file will execute a command “cat /home/joanna/.ssh/id_rsa” which should be the key of
joanna ssh.
Second, we found a file /etc/apache2/sites-available/internal.conf which seems is the configuration
file of the internal site.
It shows that it listen on port 52846.
So now we will try to browse to main.php in the internal site on port 52846 to get the ssh key of
Joanna /home/joanna/.ssh/id_rsa .
We try to use browser to browse 10.10.10.171:52846 , however it is unable to connect.
The site named internal so maybe it can only be access in the target machine itself.
So, there is 2 method which I will show in this writeup which can get the ssh key.
Method 1, we set a SSH tunnel to 10.10.10.171:52846.
sshpass -p n1nj4W4rri0R! ssh -L 52846:127.0.0.1:52846 jimmy@10.10.10.171
Then we use browser to browse localhost port 52846, 127.0.0.1:52846.
We found a login page which should be the index.php in /var/www/internal/ .
We tried the credentials jimmy:n1nj4W4rri0R! ,however we failed to login.
Then we go to SSH and open index.php with vim.
vim /var/www/internal/index.php
It store the password in sha512 hash, I tried to crack it but failed and it is probably not some easy
password which will present in some weak wordlist.
So we can make some modification in the if statement to make our login succeed. Remember to
undo the modification after we get the SSH key to avoid any spoiler to others.
Method 2, we use curl command in SSH which run as the target machine itself, to get the SSH key
--------------------------------------------------------------------------------------------------------------------------------------
Then we copy the RSA private key to our local machine and save as id_rsa.
I tried to use SSH to login to Joanna using id_rsa key. However it will ask for passphrase, so we need
to crack the RSA key first.
We will use john to crack it, so we need to change the RSA key to hash first, we will use ssh2john.py
ssh2john.py id_rsa > id_rsa.hash
Then we will use john to crack it with rockyou.txt as wordlist.
john --wordlist=/usr/share/wordlists/rockyou.txt id_rsa.hash
We can see that the passphrase is bloodninjas.
So we will use SSH to login as Joanna.
ssh -i id_rsa joanna@10.10.10.171
bloodninjas
We successfully login as Joanna in SSH and we can get the user.txt.
Now, we will try escalate to root privilege.
After some enumeration, we run the command “sudo -l”, and found that user Joanna can run the
following command using sudo without entering password.
/bin/nano /opt/priv
Which will open /opt/priv with nano in superuser privilege.
Then I go to google and search for nano privilege escalation and I found a guide about privilege
escalation using nano. https://gtfobins.github.io/gtfobins/nano/
So we will open /opt/priv using nano with sudo first.
sudo /bin/nano /opt/priv
We can run nano as root and open /opt/priv which is blank,then press ^R^X which is ctrl-r then ctrl-x
We can execute command as root, we can directly view root.txt by running cat /root/root.txt
But in order to gain root shell, we need to run the following command to break out from restricted
environments by spawning an interactive system shell.
reset; bash 1>&0 2>&0
After that we need to run “clear”, to clear out the nano UI to have a normal bash shell.
And finally we got a shell in root privilege.
光復香港 時代革命

More Related Content

What's hot

Finding a lost song with Node.js and async iterators - EnterJS 2021
Finding a lost song with Node.js and async iterators - EnterJS 2021Finding a lost song with Node.js and async iterators - EnterJS 2021
Finding a lost song with Node.js and async iterators - EnterJS 2021
Luciano Mammino
 
Finding a lost song with Node.js and async iterators - NodeConf Remote 2021
Finding a lost song with Node.js and async iterators - NodeConf Remote 2021Finding a lost song with Node.js and async iterators - NodeConf Remote 2021
Finding a lost song with Node.js and async iterators - NodeConf Remote 2021
Luciano Mammino
 
Linux Command Line
Linux Command LineLinux Command Line
Linux Command Line
Prima Yogi Loviniltra
 
Border Patrol - Count, throttle, kick & ban in perl
Border Patrol - Count, throttle, kick & ban in perlBorder Patrol - Count, throttle, kick & ban in perl
Border Patrol - Count, throttle, kick & ban in perl
David Morel
 
Finding a lost song with Node.js and async iterators
Finding a lost song with Node.js and async iteratorsFinding a lost song with Node.js and async iterators
Finding a lost song with Node.js and async iterators
Luciano Mammino
 
Linux system admin
Linux system adminLinux system admin
Linux system admin
Mohammed Zainul Abiddin
 
Service intergration
Service intergration Service intergration
Service intergration
재민 장
 
Devinsampa nginx-scripting
Devinsampa nginx-scriptingDevinsampa nginx-scripting
Devinsampa nginx-scriptingTony Fabeen
 
RG講義_SSH
RG講義_SSHRG講義_SSH
RG講義_SSH
Shuya Osaki
 
Terminal commands ubuntu 2
Terminal commands ubuntu 2Terminal commands ubuntu 2
Terminal commands ubuntu 2
raj upadhyay
 
Cis 216 – shell scripting
Cis 216 – shell scriptingCis 216 – shell scripting
Cis 216 – shell scripting
Dan Morrill
 
PSR-7 and PSR-15, why can't you ignore them
PSR-7 and PSR-15, why can't you ignore themPSR-7 and PSR-15, why can't you ignore them
PSR-7 and PSR-15, why can't you ignore them
Sérgio Rafael Siqueira
 
Vim Hacks (OSSF)
Vim Hacks (OSSF)Vim Hacks (OSSF)
Vim Hacks (OSSF)Lin Yo-An
 
神に近づくx/net/context (Finding God with x/net/context)
神に近づくx/net/context (Finding God with x/net/context)神に近づくx/net/context (Finding God with x/net/context)
神に近づくx/net/context (Finding God with x/net/context)
guregu
 
Using the Command Line with Magento
Using the Command Line with MagentoUsing the Command Line with Magento
Using the Command Line with Magento
Matthew Haworth
 

What's hot (16)

Finding a lost song with Node.js and async iterators - EnterJS 2021
Finding a lost song with Node.js and async iterators - EnterJS 2021Finding a lost song with Node.js and async iterators - EnterJS 2021
Finding a lost song with Node.js and async iterators - EnterJS 2021
 
Finding a lost song with Node.js and async iterators - NodeConf Remote 2021
Finding a lost song with Node.js and async iterators - NodeConf Remote 2021Finding a lost song with Node.js and async iterators - NodeConf Remote 2021
Finding a lost song with Node.js and async iterators - NodeConf Remote 2021
 
Linux Command Line
Linux Command LineLinux Command Line
Linux Command Line
 
Border Patrol - Count, throttle, kick & ban in perl
Border Patrol - Count, throttle, kick & ban in perlBorder Patrol - Count, throttle, kick & ban in perl
Border Patrol - Count, throttle, kick & ban in perl
 
Finding a lost song with Node.js and async iterators
Finding a lost song with Node.js and async iteratorsFinding a lost song with Node.js and async iterators
Finding a lost song with Node.js and async iterators
 
Linux system admin
Linux system adminLinux system admin
Linux system admin
 
Service intergration
Service intergration Service intergration
Service intergration
 
Devinsampa nginx-scripting
Devinsampa nginx-scriptingDevinsampa nginx-scripting
Devinsampa nginx-scripting
 
RG講義_SSH
RG講義_SSHRG講義_SSH
RG講義_SSH
 
Terminal commands ubuntu 2
Terminal commands ubuntu 2Terminal commands ubuntu 2
Terminal commands ubuntu 2
 
Cis 216 – shell scripting
Cis 216 – shell scriptingCis 216 – shell scripting
Cis 216 – shell scripting
 
PHP
PHP PHP
PHP
 
PSR-7 and PSR-15, why can't you ignore them
PSR-7 and PSR-15, why can't you ignore themPSR-7 and PSR-15, why can't you ignore them
PSR-7 and PSR-15, why can't you ignore them
 
Vim Hacks (OSSF)
Vim Hacks (OSSF)Vim Hacks (OSSF)
Vim Hacks (OSSF)
 
神に近づくx/net/context (Finding God with x/net/context)
神に近づくx/net/context (Finding God with x/net/context)神に近づくx/net/context (Finding God with x/net/context)
神に近づくx/net/context (Finding God with x/net/context)
 
Using the Command Line with Magento
Using the Command Line with MagentoUsing the Command Line with Magento
Using the Command Line with Magento
 

Similar to Hack the box open admin writeup

TryHackMe Overpass Writeup walkthrough.pdf
TryHackMe Overpass Writeup walkthrough.pdfTryHackMe Overpass Writeup walkthrough.pdf
TryHackMe Overpass Writeup walkthrough.pdf
mysticraganork66
 
SSH how to 2011
SSH how to 2011SSH how to 2011
SSH how to 2011
Chris Hales
 
OpenSSH tricks
OpenSSH tricksOpenSSH tricks
OpenSSH tricks
Assem CHELLI
 
Linux Privilege Escalation with Lin Security.
Linux Privilege Escalation with Lin Security.Linux Privilege Escalation with Lin Security.
Linux Privilege Escalation with Lin Security.
Deepanshu Gajbhiye
 
Intro to SSH
Intro to SSHIntro to SSH
Intro to SSH
JP Bourget
 
How To Setup SSH Keys on CentOS 7
How To Setup SSH Keys on CentOS 7How To Setup SSH Keys on CentOS 7
How To Setup SSH Keys on CentOS 7
VCP Muthukrishna
 
SSH for pen-testers
SSH for pen-testersSSH for pen-testers
SSH for pen-testersE D Williams
 
How secure is your code?
How secure is your code?How secure is your code?
How secure is your code?
Mikee Franklin
 
Hadoop meet Rex(How to construct hadoop cluster with rex)
Hadoop meet Rex(How to construct hadoop cluster with rex)Hadoop meet Rex(How to construct hadoop cluster with rex)
Hadoop meet Rex(How to construct hadoop cluster with rex)
Jun Hong Kim
 
Pentesting an unfriendly environment: bypassing (un)common defences and mate ...
Pentesting an unfriendly environment: bypassing (un)common defences and mate ...Pentesting an unfriendly environment: bypassing (un)common defences and mate ...
Pentesting an unfriendly environment: bypassing (un)common defences and mate ...
Sandro Zaccarini
 
Nullcon Hack IM 2011 walk through
Nullcon Hack IM 2011 walk throughNullcon Hack IM 2011 walk through
Nullcon Hack IM 2011 walk through
Anant Shrivastava
 
Linux advanced privilege escalation
Linux advanced privilege escalationLinux advanced privilege escalation
Linux advanced privilege escalation
Jameel Nabbo
 
Snorter
SnorterSnorter
Snorter
Joan Bono
 
SSH: Seguranca no Acesso Remoto
SSH: Seguranca no Acesso RemotoSSH: Seguranca no Acesso Remoto
SSH: Seguranca no Acesso Remoto
Tiago Cruz
 
Approach to find critical vulnerabilities
Approach to find critical vulnerabilitiesApproach to find critical vulnerabilities
Approach to find critical vulnerabilities
Ashish Kunwar
 
Ssh cookbook
Ssh cookbookSsh cookbook
Ssh cookbook
Jean-Marie Renouard
 

Similar to Hack the box open admin writeup (20)

TryHackMe Overpass Writeup walkthrough.pdf
TryHackMe Overpass Writeup walkthrough.pdfTryHackMe Overpass Writeup walkthrough.pdf
TryHackMe Overpass Writeup walkthrough.pdf
 
SSH how to 2011
SSH how to 2011SSH how to 2011
SSH how to 2011
 
OpenSSH tricks
OpenSSH tricksOpenSSH tricks
OpenSSH tricks
 
Linux Privilege Escalation with Lin Security.
Linux Privilege Escalation with Lin Security.Linux Privilege Escalation with Lin Security.
Linux Privilege Escalation with Lin Security.
 
Linuxserver harden
Linuxserver hardenLinuxserver harden
Linuxserver harden
 
Intro to SSH
Intro to SSHIntro to SSH
Intro to SSH
 
Cent os 5 ssh
Cent os 5 sshCent os 5 ssh
Cent os 5 ssh
 
How To Setup SSH Keys on CentOS 7
How To Setup SSH Keys on CentOS 7How To Setup SSH Keys on CentOS 7
How To Setup SSH Keys on CentOS 7
 
SSH for pen-testers
SSH for pen-testersSSH for pen-testers
SSH for pen-testers
 
How secure is your code?
How secure is your code?How secure is your code?
How secure is your code?
 
Hadoop meet Rex(How to construct hadoop cluster with rex)
Hadoop meet Rex(How to construct hadoop cluster with rex)Hadoop meet Rex(How to construct hadoop cluster with rex)
Hadoop meet Rex(How to construct hadoop cluster with rex)
 
SoftLayer-demoLabV3
SoftLayer-demoLabV3SoftLayer-demoLabV3
SoftLayer-demoLabV3
 
Pentesting an unfriendly environment: bypassing (un)common defences and mate ...
Pentesting an unfriendly environment: bypassing (un)common defences and mate ...Pentesting an unfriendly environment: bypassing (un)common defences and mate ...
Pentesting an unfriendly environment: bypassing (un)common defences and mate ...
 
Nullcon Hack IM 2011 walk through
Nullcon Hack IM 2011 walk throughNullcon Hack IM 2011 walk through
Nullcon Hack IM 2011 walk through
 
Linux advanced privilege escalation
Linux advanced privilege escalationLinux advanced privilege escalation
Linux advanced privilege escalation
 
Snorter
SnorterSnorter
Snorter
 
SSH: Seguranca no Acesso Remoto
SSH: Seguranca no Acesso RemotoSSH: Seguranca no Acesso Remoto
SSH: Seguranca no Acesso Remoto
 
Approach to find critical vulnerabilities
Approach to find critical vulnerabilitiesApproach to find critical vulnerabilities
Approach to find critical vulnerabilities
 
Ssh cookbook v2
Ssh cookbook v2Ssh cookbook v2
Ssh cookbook v2
 
Ssh cookbook
Ssh cookbookSsh cookbook
Ssh cookbook
 

Recently uploaded

Beyond Event Sourcing - Embracing CRUD for Wix Platform - Java.IL
Beyond Event Sourcing - Embracing CRUD for Wix Platform - Java.ILBeyond Event Sourcing - Embracing CRUD for Wix Platform - Java.IL
Beyond Event Sourcing - Embracing CRUD for Wix Platform - Java.IL
Natan Silnitsky
 
Graphic Design Crash Course for beginners
Graphic Design Crash Course for beginnersGraphic Design Crash Course for beginners
Graphic Design Crash Course for beginners
e20449
 
A Comprehensive Look at Generative AI in Retail App Testing.pdf
A Comprehensive Look at Generative AI in Retail App Testing.pdfA Comprehensive Look at Generative AI in Retail App Testing.pdf
A Comprehensive Look at Generative AI in Retail App Testing.pdf
kalichargn70th171
 
Climate Science Flows: Enabling Petabyte-Scale Climate Analysis with the Eart...
Climate Science Flows: Enabling Petabyte-Scale Climate Analysis with the Eart...Climate Science Flows: Enabling Petabyte-Scale Climate Analysis with the Eart...
Climate Science Flows: Enabling Petabyte-Scale Climate Analysis with the Eart...
Globus
 
BoxLang: Review our Visionary Licenses of 2024
BoxLang: Review our Visionary Licenses of 2024BoxLang: Review our Visionary Licenses of 2024
BoxLang: Review our Visionary Licenses of 2024
Ortus Solutions, Corp
 
Using IESVE for Room Loads Analysis - Australia & New Zealand
Using IESVE for Room Loads Analysis - Australia & New ZealandUsing IESVE for Room Loads Analysis - Australia & New Zealand
Using IESVE for Room Loads Analysis - Australia & New Zealand
IES VE
 
Into the Box 2024 - Keynote Day 2 Slides.pdf
Into the Box 2024 - Keynote Day 2 Slides.pdfInto the Box 2024 - Keynote Day 2 Slides.pdf
Into the Box 2024 - Keynote Day 2 Slides.pdf
Ortus Solutions, Corp
 
Enhancing Project Management Efficiency_ Leveraging AI Tools like ChatGPT.pdf
Enhancing Project Management Efficiency_ Leveraging AI Tools like ChatGPT.pdfEnhancing Project Management Efficiency_ Leveraging AI Tools like ChatGPT.pdf
Enhancing Project Management Efficiency_ Leveraging AI Tools like ChatGPT.pdf
Jay Das
 
Providing Globus Services to Users of JASMIN for Environmental Data Analysis
Providing Globus Services to Users of JASMIN for Environmental Data AnalysisProviding Globus Services to Users of JASMIN for Environmental Data Analysis
Providing Globus Services to Users of JASMIN for Environmental Data Analysis
Globus
 
GlobusWorld 2024 Opening Keynote session
GlobusWorld 2024 Opening Keynote sessionGlobusWorld 2024 Opening Keynote session
GlobusWorld 2024 Opening Keynote session
Globus
 
AI Pilot Review: The World’s First Virtual Assistant Marketing Suite
AI Pilot Review: The World’s First Virtual Assistant Marketing SuiteAI Pilot Review: The World’s First Virtual Assistant Marketing Suite
AI Pilot Review: The World’s First Virtual Assistant Marketing Suite
Google
 
Prosigns: Transforming Business with Tailored Technology Solutions
Prosigns: Transforming Business with Tailored Technology SolutionsProsigns: Transforming Business with Tailored Technology Solutions
Prosigns: Transforming Business with Tailored Technology Solutions
Prosigns
 
Quarkus Hidden and Forbidden Extensions
Quarkus Hidden and Forbidden ExtensionsQuarkus Hidden and Forbidden Extensions
Quarkus Hidden and Forbidden Extensions
Max Andersen
 
Exploring Innovations in Data Repository Solutions - Insights from the U.S. G...
Exploring Innovations in Data Repository Solutions - Insights from the U.S. G...Exploring Innovations in Data Repository Solutions - Insights from the U.S. G...
Exploring Innovations in Data Repository Solutions - Insights from the U.S. G...
Globus
 
TROUBLESHOOTING 9 TYPES OF OUTOFMEMORYERROR
TROUBLESHOOTING 9 TYPES OF OUTOFMEMORYERRORTROUBLESHOOTING 9 TYPES OF OUTOFMEMORYERROR
TROUBLESHOOTING 9 TYPES OF OUTOFMEMORYERROR
Tier1 app
 
Top Features to Include in Your Winzo Clone App for Business Growth (4).pptx
Top Features to Include in Your Winzo Clone App for Business Growth (4).pptxTop Features to Include in Your Winzo Clone App for Business Growth (4).pptx
Top Features to Include in Your Winzo Clone App for Business Growth (4).pptx
rickgrimesss22
 
Innovating Inference - Remote Triggering of Large Language Models on HPC Clus...
Innovating Inference - Remote Triggering of Large Language Models on HPC Clus...Innovating Inference - Remote Triggering of Large Language Models on HPC Clus...
Innovating Inference - Remote Triggering of Large Language Models on HPC Clus...
Globus
 
Dominate Social Media with TubeTrivia AI’s Addictive Quiz Videos.pdf
Dominate Social Media with TubeTrivia AI’s Addictive Quiz Videos.pdfDominate Social Media with TubeTrivia AI’s Addictive Quiz Videos.pdf
Dominate Social Media with TubeTrivia AI’s Addictive Quiz Videos.pdf
AMB-Review
 
Lecture 1 Introduction to games development
Lecture 1 Introduction to games developmentLecture 1 Introduction to games development
Lecture 1 Introduction to games development
abdulrafaychaudhry
 
Vitthal Shirke Microservices Resume Montevideo
Vitthal Shirke Microservices Resume MontevideoVitthal Shirke Microservices Resume Montevideo
Vitthal Shirke Microservices Resume Montevideo
Vitthal Shirke
 

Recently uploaded (20)

Beyond Event Sourcing - Embracing CRUD for Wix Platform - Java.IL
Beyond Event Sourcing - Embracing CRUD for Wix Platform - Java.ILBeyond Event Sourcing - Embracing CRUD for Wix Platform - Java.IL
Beyond Event Sourcing - Embracing CRUD for Wix Platform - Java.IL
 
Graphic Design Crash Course for beginners
Graphic Design Crash Course for beginnersGraphic Design Crash Course for beginners
Graphic Design Crash Course for beginners
 
A Comprehensive Look at Generative AI in Retail App Testing.pdf
A Comprehensive Look at Generative AI in Retail App Testing.pdfA Comprehensive Look at Generative AI in Retail App Testing.pdf
A Comprehensive Look at Generative AI in Retail App Testing.pdf
 
Climate Science Flows: Enabling Petabyte-Scale Climate Analysis with the Eart...
Climate Science Flows: Enabling Petabyte-Scale Climate Analysis with the Eart...Climate Science Flows: Enabling Petabyte-Scale Climate Analysis with the Eart...
Climate Science Flows: Enabling Petabyte-Scale Climate Analysis with the Eart...
 
BoxLang: Review our Visionary Licenses of 2024
BoxLang: Review our Visionary Licenses of 2024BoxLang: Review our Visionary Licenses of 2024
BoxLang: Review our Visionary Licenses of 2024
 
Using IESVE for Room Loads Analysis - Australia & New Zealand
Using IESVE for Room Loads Analysis - Australia & New ZealandUsing IESVE for Room Loads Analysis - Australia & New Zealand
Using IESVE for Room Loads Analysis - Australia & New Zealand
 
Into the Box 2024 - Keynote Day 2 Slides.pdf
Into the Box 2024 - Keynote Day 2 Slides.pdfInto the Box 2024 - Keynote Day 2 Slides.pdf
Into the Box 2024 - Keynote Day 2 Slides.pdf
 
Enhancing Project Management Efficiency_ Leveraging AI Tools like ChatGPT.pdf
Enhancing Project Management Efficiency_ Leveraging AI Tools like ChatGPT.pdfEnhancing Project Management Efficiency_ Leveraging AI Tools like ChatGPT.pdf
Enhancing Project Management Efficiency_ Leveraging AI Tools like ChatGPT.pdf
 
Providing Globus Services to Users of JASMIN for Environmental Data Analysis
Providing Globus Services to Users of JASMIN for Environmental Data AnalysisProviding Globus Services to Users of JASMIN for Environmental Data Analysis
Providing Globus Services to Users of JASMIN for Environmental Data Analysis
 
GlobusWorld 2024 Opening Keynote session
GlobusWorld 2024 Opening Keynote sessionGlobusWorld 2024 Opening Keynote session
GlobusWorld 2024 Opening Keynote session
 
AI Pilot Review: The World’s First Virtual Assistant Marketing Suite
AI Pilot Review: The World’s First Virtual Assistant Marketing SuiteAI Pilot Review: The World’s First Virtual Assistant Marketing Suite
AI Pilot Review: The World’s First Virtual Assistant Marketing Suite
 
Prosigns: Transforming Business with Tailored Technology Solutions
Prosigns: Transforming Business with Tailored Technology SolutionsProsigns: Transforming Business with Tailored Technology Solutions
Prosigns: Transforming Business with Tailored Technology Solutions
 
Quarkus Hidden and Forbidden Extensions
Quarkus Hidden and Forbidden ExtensionsQuarkus Hidden and Forbidden Extensions
Quarkus Hidden and Forbidden Extensions
 
Exploring Innovations in Data Repository Solutions - Insights from the U.S. G...
Exploring Innovations in Data Repository Solutions - Insights from the U.S. G...Exploring Innovations in Data Repository Solutions - Insights from the U.S. G...
Exploring Innovations in Data Repository Solutions - Insights from the U.S. G...
 
TROUBLESHOOTING 9 TYPES OF OUTOFMEMORYERROR
TROUBLESHOOTING 9 TYPES OF OUTOFMEMORYERRORTROUBLESHOOTING 9 TYPES OF OUTOFMEMORYERROR
TROUBLESHOOTING 9 TYPES OF OUTOFMEMORYERROR
 
Top Features to Include in Your Winzo Clone App for Business Growth (4).pptx
Top Features to Include in Your Winzo Clone App for Business Growth (4).pptxTop Features to Include in Your Winzo Clone App for Business Growth (4).pptx
Top Features to Include in Your Winzo Clone App for Business Growth (4).pptx
 
Innovating Inference - Remote Triggering of Large Language Models on HPC Clus...
Innovating Inference - Remote Triggering of Large Language Models on HPC Clus...Innovating Inference - Remote Triggering of Large Language Models on HPC Clus...
Innovating Inference - Remote Triggering of Large Language Models on HPC Clus...
 
Dominate Social Media with TubeTrivia AI’s Addictive Quiz Videos.pdf
Dominate Social Media with TubeTrivia AI’s Addictive Quiz Videos.pdfDominate Social Media with TubeTrivia AI’s Addictive Quiz Videos.pdf
Dominate Social Media with TubeTrivia AI’s Addictive Quiz Videos.pdf
 
Lecture 1 Introduction to games development
Lecture 1 Introduction to games developmentLecture 1 Introduction to games development
Lecture 1 Introduction to games development
 
Vitthal Shirke Microservices Resume Montevideo
Vitthal Shirke Microservices Resume MontevideoVitthal Shirke Microservices Resume Montevideo
Vitthal Shirke Microservices Resume Montevideo
 

Hack the box open admin writeup

  • 1. Hack The Box OpenAdmin 10.10.10.171 Writeup By Kaiziron (Please give a respect in my HTB profile https://www.hackthebox.eu/home/users/profile/76593) I am new to penetration testing. This is my first writeup on Hack The Box. -------------------------------------------------------------------------------------------------------------------------------------- So, we will start with a nmap scan. We can see that port 22(SSH) and port 80(http) are open. And we will first enumerate port 80 first.
  • 2. We can see it is an apache2 default page, so some other pages may in some other locations. Let’s use dirbuster to see if we can find any other pages. After a while, dirbuster found a page /ona Let’s browser to that page and see if there’s any information disclosure.
  • 3. We can see it show that the version is v18.1.1 and the “DOWNLOAD” hyperlink show that it is probably running something called opennetadmin. We found an exploit for this version of opennetadmin in github by googling. https://github.com/amriunix/ona-rce It is a python script which can check if the target is vulnerable, and of course can also exploit this vulnerability. That script show that our target is vulnerable to this exploit. Then we will use it to exploit the vulnerability and try gain a shell. We gain a shell as www-data. However we are in /opt/ona/www and unable to change directory with cd, but we can use ls and also cat so it doesn’t matter at all. After some enumeration we found there is a file in /opt/ona/www/local/config called database_settings.inc.php . We use cat to open it up.
  • 4. And it seems is the credentials of some database. Don’t forget that port 22(SSH) is open. Let’s try to login with SSH with the password n1nj4W4rri0R! and see if there’s any password reuse. We use “cat /etc/passwd” to open up the passwd file to check some username in this machine. We can found 2 users, called jimmy and Joanna. We can also find the user by using “ls -la /home/” to check for home folder of user. Then we will try to use SSH to login to those users using sshpass to enter in one line for convenient. sshpass -p n1nj4W4rri0R! ssh jimmy@10.10.10.171 sshpass -p n1nj4W4rri0R! ssh joanna@10.10.10.171 We can successfully login as jimmy but not Joanna.
  • 5. After some enumeration, we found few interesting things, first there is a folder in /var/www/ called internal which is owned by user jimmy which looks like a webpage. We found few pages inside the internal folder, one of them is very interesting. This php file will execute a command “cat /home/joanna/.ssh/id_rsa” which should be the key of joanna ssh. Second, we found a file /etc/apache2/sites-available/internal.conf which seems is the configuration file of the internal site.
  • 6. It shows that it listen on port 52846. So now we will try to browse to main.php in the internal site on port 52846 to get the ssh key of Joanna /home/joanna/.ssh/id_rsa . We try to use browser to browse 10.10.10.171:52846 , however it is unable to connect. The site named internal so maybe it can only be access in the target machine itself. So, there is 2 method which I will show in this writeup which can get the ssh key. Method 1, we set a SSH tunnel to 10.10.10.171:52846. sshpass -p n1nj4W4rri0R! ssh -L 52846:127.0.0.1:52846 jimmy@10.10.10.171 Then we use browser to browse localhost port 52846, 127.0.0.1:52846. We found a login page which should be the index.php in /var/www/internal/ . We tried the credentials jimmy:n1nj4W4rri0R! ,however we failed to login.
  • 7. Then we go to SSH and open index.php with vim. vim /var/www/internal/index.php It store the password in sha512 hash, I tried to crack it but failed and it is probably not some easy password which will present in some weak wordlist. So we can make some modification in the if statement to make our login succeed. Remember to undo the modification after we get the SSH key to avoid any spoiler to others.
  • 8. Method 2, we use curl command in SSH which run as the target machine itself, to get the SSH key -------------------------------------------------------------------------------------------------------------------------------------- Then we copy the RSA private key to our local machine and save as id_rsa. I tried to use SSH to login to Joanna using id_rsa key. However it will ask for passphrase, so we need to crack the RSA key first. We will use john to crack it, so we need to change the RSA key to hash first, we will use ssh2john.py ssh2john.py id_rsa > id_rsa.hash Then we will use john to crack it with rockyou.txt as wordlist. john --wordlist=/usr/share/wordlists/rockyou.txt id_rsa.hash
  • 9. We can see that the passphrase is bloodninjas. So we will use SSH to login as Joanna. ssh -i id_rsa joanna@10.10.10.171 bloodninjas We successfully login as Joanna in SSH and we can get the user.txt. Now, we will try escalate to root privilege. After some enumeration, we run the command “sudo -l”, and found that user Joanna can run the following command using sudo without entering password. /bin/nano /opt/priv Which will open /opt/priv with nano in superuser privilege. Then I go to google and search for nano privilege escalation and I found a guide about privilege escalation using nano. https://gtfobins.github.io/gtfobins/nano/
  • 10. So we will open /opt/priv using nano with sudo first. sudo /bin/nano /opt/priv We can run nano as root and open /opt/priv which is blank,then press ^R^X which is ctrl-r then ctrl-x We can execute command as root, we can directly view root.txt by running cat /root/root.txt But in order to gain root shell, we need to run the following command to break out from restricted environments by spawning an interactive system shell. reset; bash 1>&0 2>&0
  • 11. After that we need to run “clear”, to clear out the nano UI to have a normal bash shell. And finally we got a shell in root privilege. 光復香港 時代革命