Skip to content

Commit 3968789

Browse files
authored
Merge branch 'master' into apsw-with-sqlalchemy
Signed-off-by: Achintya Jai <[email protected]>
2 parents b5386d1 + 958e1bc commit 3968789

File tree

9 files changed

+655
-2
lines changed

9 files changed

+655
-2
lines changed

nettacker/core/lib/smb.py

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
from impacket.smbconnection import SMBConnection
2+
3+
from nettacker.core.lib.base import BaseEngine, BaseLibrary
4+
5+
6+
def create_connection(host, port):
7+
return SMBConnection(host, remoteHost=host, sess_port=port)
8+
9+
10+
class SmbLibrary(BaseLibrary):
11+
def brute_force(self, *args, **kwargs):
12+
host = kwargs["host"]
13+
port = kwargs["port"]
14+
username = kwargs["username"]
15+
16+
response = {
17+
"host": host,
18+
"port": port,
19+
"username": username,
20+
}
21+
22+
domain = "."
23+
if "domain" in kwargs:
24+
domain = kwargs["domain"]
25+
response.update({"domain": domain})
26+
27+
password = ""
28+
if "password" in kwargs:
29+
password = kwargs["password"]
30+
response.update({"password": password})
31+
32+
lm = ""
33+
if "lm" in kwargs:
34+
lm = kwargs["lm"]
35+
response.update({"lm": lm})
36+
37+
nt = ""
38+
if "nt" in kwargs:
39+
nt = kwargs["nt"]
40+
response.update({"nt": nt})
41+
42+
connection = create_connection(host, port)
43+
connection.login(username, password, domain, lm, nt)
44+
45+
return response
46+
47+
48+
class SmbEngine(BaseEngine):
49+
library = SmbLibrary

nettacker/modules/brute/smb.yaml

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
info:
2+
name: smb_brute
3+
author: OWASP Nettacker Team
4+
severity: 3
5+
description: SMB Bruteforcer
6+
reference:
7+
profiles:
8+
- brute
9+
- brute_force
10+
- smb
11+
12+
payloads:
13+
- library: smb
14+
steps:
15+
- method: brute_force
16+
timeout: 3
17+
host: '{target}'
18+
ports:
19+
- 445
20+
usernames:
21+
- administrator
22+
- admin
23+
- root
24+
- user
25+
- test
26+
- guest
27+
passwords:
28+
nettacker_fuzzer:
29+
input_format: '{{passwords}}'
30+
prefix:
31+
suffix:
32+
interceptors:
33+
data:
34+
passwords:
35+
read_from_file: passwords/top_1000_common_passwords.txt
36+
response:
37+
condition_type: or
38+
conditions:
39+
successful_login:
40+
regex: ''
41+
reverse: false

poetry.lock

Lines changed: 151 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

pyproject.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,7 @@ zipp = "^3.19.1"
6565
uvloop = "^0.21.0"
6666
pymysql = "^1.1.1"
6767
apsw = "^3.50.0.0"
68+
impacket = "^0.11.0"
6869

6970
[tool.poetry.group.dev.dependencies]
7071
ipython = "^8.16.1"

tests/core/lib/test_smb.py

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
from unittest.mock import patch
2+
3+
from nettacker.core.lib.smb import SmbLibrary
4+
from tests.common import TestCase
5+
6+
SMB_SESSION_PORT = 445
7+
8+
9+
class MockSmbConnectionObject:
10+
def __init__(self, remoteName="", remoteHost="", sess_port=SMB_SESSION_PORT):
11+
self._sess_port = sess_port
12+
self._remoteHost = remoteHost
13+
self._remoteName = remoteName
14+
15+
def login(self, user, password, domain="", lmhash="", nthash=""):
16+
return None
17+
18+
19+
class TestSmbMethod(TestCase):
20+
@patch("nettacker.core.lib.smb.create_connection")
21+
def test_brute_force_password(self, mock_smb_connection):
22+
library = SmbLibrary()
23+
HOST = "dc-01"
24+
PORT = 445
25+
USERNAME = "Administrator"
26+
PASSWORD = "Password@123"
27+
28+
mock_smb_connection.return_value = MockSmbConnectionObject(
29+
HOST, remoteHost=HOST, sess_port=PORT
30+
)
31+
self.assertEqual(
32+
library.brute_force(
33+
host=HOST,
34+
port=PORT,
35+
username=USERNAME,
36+
password=PASSWORD,
37+
),
38+
{
39+
"host": HOST,
40+
"port": PORT,
41+
"username": USERNAME,
42+
"password": PASSWORD,
43+
},
44+
)

0 commit comments

Comments
 (0)