Re: How do I determine if versions of phpMyAdmin before 4.8.5 is SQL Injectable using sqlmap?

2019-04-17 Thread shawn l.green

Hello,

On 4/17/2019 10:29 AM, Turritopsis Dohrnii Teo En Ming wrote:

Subject/Topic: How do I determine if versions of phpMyAdmin before 4.8.5 is SQL 
Injectable using sqlmap?

Good evening from Singapore,

Our customer (company name is Confidential/not disclosed) reported that their 
MySQL database has been found missing or was deleted a few times.


While it is bad form to explain how to break into anyone's software 
(including our own), there are places you can look to get a better idea 
about what might have happened:


1 - the database may have been removed by a DROP DATABASE command.

General Query Log - this will show you which session issued the command 
and the command itself.


Audit log (only for commercial releases) - same thing

Binary Log - Should have a record of the command executing. But, 
depending on which account was used or if Binary Log filtering is in 
place, it may not. This presumes that the Binary Log is even enabled on 
this system.  Many people mistakenly believe it is only for Replication 
when its other primary use is for point-in-time recovery. If your 
customer has a recent backup and all of the Binary Log files created 
since that backup, they could return the system to the point it was at 
just before that database went missing, skip that DROP command, then 
continue rolling forward the changes to the other tables to return to a 
"current" state of their data.


2 - The database was "dropped" by either changing privileges to the 
folder or by removing it from disk or some other file-level or 
system-level operation. Either of those would cause errors to start 
appearing in the MySQL Error Log because a resource that mysqld thinks 
should exist is no longer available.   While the Error Log can't tell 
you which operation made those files "no longer available" it will have 
a fingerprint that such an action happened outside of mysqld.



Have you determined which method was used to make that database/schema 
disappear?


A normal DROP command (which could happen through an SQL injection 
attack) would not leave messages in the Error Log about "unable to 
access ..." or something similar. The server (mysqld) would know that 
the database was gone (because it removed it) and it wouldn't be trying 
to find it or the tables within it for your clients to use it.





... snip ...
No matter how many commands I try, sqlmap always report that phpMyAdmin 4.8.4 
is *NOT* SQL injectable. Perhaps I was using the wrong sqlmap commands all the 
time? The following is one of the many sqlmap commands I have used.

$ python sqlmap.py -u "https://www.EXAMPLE.com/phymyadmin/index.php?id=1; --level=1 
--dbms=mysql --sql-query="drop database"



Privately asking phpMyAdmin may be a better source of information about 
how to hack their system to do things it was not intended to do. This 
list is not about phpMyAdmin and it is very public.  They may also have 
a way of showing you some kind of trace or log that serves as a 
fingerprint for that happening.



--
Shawn Green
MySQL Senior Principal Technical Support Engineer
Oracle USA, Inc. - Integrated Cloud Applications & Platform Services
Office: Blountville, TN

Become certified in MySQL! Visit https://www.mysql.com/certification/ 
for details.


--
MySQL General Mailing List
For list archives: http://lists.mysql.com/mysql
To unsubscribe:http://lists.mysql.com/mysql



How do I determine if versions of phpMyAdmin before 4.8.5 is SQL Injectable using sqlmap?

2019-04-17 Thread Turritopsis Dohrnii Teo En Ming
Subject/Topic: How do I determine if versions of phpMyAdmin before 4.8.5 is SQL 
Injectable using sqlmap?

Good evening from Singapore,

Our customer (company name is Confidential/not disclosed) reported that their 
MySQL database has been found missing or was deleted a few times. They are 
using Ubuntu 16.04 LTS Linux server with Apache2 Web Server, MySQL and PHP 
(LAMP).

We responded to these security incidents by changing the passwords of the 
regular user, root user, and MySQL database user root. We have also examined 
/var/log/auth.log and think that the hacker could not have come in through ssh 
or sftp over ssh. From /var/log/mysql/error.log, we can ascertain that the 
MySQL database has been deleted at certain timings. We have also found nothing 
abnormal after examining /var/log/apache2/access.log.

Even though we have secured the Ubuntu Linux server by changing passwords, the 
hacker was still able to delete our customer's MySQL database again and again. 
I have already proposed to install ModSecurity Open Source Web Application 
Firewall (WAF) to defend against web application attacks but my boss has told 
me to put that on hold at the moment. In fact, I have already deployed 
ModSecurity 2.9.0 on a Ubuntu 16.04 LTS *Testing* server and found that it 
actively detects and logs Nessus and sqlmap vulnerability scans in blocking 
mode.

Since we did not find any evidence that the hacker had breached our customer's 
Ubuntu 16.04 LTS production server through ssh or Teamviewer, we suspect that 
the hacker could have achieved it by SQL injection. I took the initiative of 
downloading and installing Nessus Professional 8.3.1 Trial version for Windows 
64-bit. The vulnerability scan report generated by Nessus Web Application Tests 
shows that our customer is using a version of phpMyAdmin prior to 4.8.5 which 
could be vulnerable to SQL injection using the designer feature.

Further research shows that I can use sqlmap to determine if phpMyAdmin is SQL 
injectable. I already have a Testing Ubuntu 16.04 LTS Linux server with a 
Testing MySQL database and a Testing phpMyAdmin 4.8.4. I have purposely 
installed phpMyAdmin 4.8.4 because this version was reported to be vulnerable 
to SQL injection using the designer feature, and our customer is using a 
vulnerable version, according to CVE-2019-6798 ( 
https://nvd.nist.gov/vuln/detail/CVE-2019-6798 ). Then I proceeded to download 
and execute sqlmap on our Ubuntu Linux desktop against our Testing server.

No matter how many commands I try, sqlmap always report that phpMyAdmin 4.8.4 
is *NOT* SQL injectable. Perhaps I was using the wrong sqlmap commands all the 
time? The following is one of the many sqlmap commands I have used.

$ python sqlmap.py -u "https://www.EXAMPLE.com/phymyadmin/index.php?id=1; 
--level=1 --dbms=mysql --sql-query="drop database"

Replace database by database name.

May I know what is the correct sqlmap command that I should use to determine 
that my Testing phpMyAdmin 4.8.4 is SQL injectable? I would like to know if I 
can successfully drop/delete the Testing database on our Testing server. If I 
can successfully drop/delete the Testing MySQL database using sqlmap, I would 
be able to conclude that the hacker must have carried out SQL injection to 
drop/delete the customer's database. I have already turned off the Testing 
ModSecurity Web Application Firewall on our Testing server to allow sqlmap to 
go through.

Please point me to any good tutorial on SQL injection using sqlmap. Maybe I do 
not understand SQL injection well enough. Our customer is also using a 
customised in-house inventory management system that relies on PHP application 
and MySQL database.

Would open source Snort Intrusion Detection System (IDS) and Intrusion 
Prevention System (IPS) be able to detect and block SQL injection as well?

Please advise.

Thank you very much.

-BEGIN EMAIL SIGNATURE-

The Gospel for all Targeted Individuals (TIs):

[The New York Times] Microwave Weapons Are Prime Suspect in Ills of
U.S. Embassy Workers

Link: 
https://www.nytimes.com/2018/09/01/science/sonic-attack-cuba-microwave.html



Singaporean Mr. Turritopsis Dohrnii Teo En Ming's Academic
Qualifications as at 14 Feb 2019

[1] https://tdtemcerts.wordpress.com/

[2] https://tdtemcerts.blogspot.sg/

[3] https://www.scribd.com/user/270125049/Teo-En-Ming

-END EMAIL SIGNATURE-


--
MySQL General Mailing List
For list archives: http://lists.mysql.com/mysql
To unsubscribe:http://lists.mysql.com/mysql