Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added mysql brute force #621

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
71 changes: 71 additions & 0 deletions core/module_protocols/core_mysql.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
#!/usr/bin/env core_mysql.py
# -*- coding: utf-8 -*-

import copy
import mysql.connector as sqltor
from core.utility import process_conditions
from core.utility import get_dependent_results_from_database
from core.utility import replace_dependent_values

class NettackMYSQLLib:
def mysql_brute_force(host, ports, usernames, passwords, timeout):
connection = sqltor.connect(host=host,port=ports,user=usernames,passwd=passwords)
connection.close()
return {
"host": host,
"username": usernames,
"password": passwords,
"port": ports
}

class Engine:
def run(
sub_step,
module_name,
target,
scan_unique_id,
options,
process_number,
module_thread_number,
total_module_thread_number,
request_number_counter,
total_number_of_requests
):
backup_method = copy.deepcopy(sub_step['method'])
backup_response = copy.deepcopy(sub_step['response'])
del sub_step['method']
del sub_step['response']
if 'dependent_on_temp_event' in backup_response:
temp_event = get_dependent_results_from_database(
target,
module_name,
scan_unique_id,
backup_response['dependent_on_temp_event']
)
sub_step = replace_dependent_values(
sub_step,
temp_event
)
action = getattr(NettackMYSQLLib, backup_method, None)
for _ in range(options['retries']):
try:
response = action(**sub_step)
break
except Exception as _:
response = []
sub_step['method'] = backup_method
sub_step['response'] = backup_response
sub_step['response']['conditions_results'] = response
return process_conditions(
sub_step,
module_name,
target,
scan_unique_id,
options,
response,
process_number,
module_thread_number,
total_module_thread_number,
request_number_counter,
total_number_of_requests
)
38 changes: 38 additions & 0 deletions modules/brute/mysql.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
info:
name: mysql_brute
author: Mrinank Bhowmick
severity: 3
description: Mysql Bruteforcer
reference:
profiles:
- brute
- brute_force
- mysql

payloads:
- library: mysql
steps:
- method: mysql_brute_force
timeout: 3
host: "{target}"
ports:
- 3306
usernames:
- root
- admin
- user
- test
passwords:
nettacker_fuzzer:
input_format: '{{passwords}}'
prefix:
suffix:
interceptors:
data:
passwords: fuzzer_function_read_file_as_array('passwords/top_1000_common_passwords.txt')
response:
condition_type: or
conditions:
successful_login:
regex: ""
reverse: false
3 changes: 2 additions & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -13,4 +13,5 @@ SQLAlchemy>=1.3.0 # library_name=sqlalchemy
py3DNS==3.2.1 # library_name=DNS
numpy==1.24.1
terminable_thread==0.7.1
PyYAML==6.0 # library_name=yaml
PyYAML==6.0 # library_name=yaml
mysql-connector-python==8.0.30 # library_name=mysql.connector