Skip to content

Commit

Permalink
cleanup: fix F403 from Ruff (import *)
Browse files Browse the repository at this point in the history
  • Loading branch information
Marshall-Hallenbeck committed Oct 6, 2023
1 parent 165fa50 commit 95aaac7
Show file tree
Hide file tree
Showing 7 changed files with 20 additions and 15 deletions.
2 changes: 1 addition & 1 deletion nxc/protocols/mssql/mssqlexec.py
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ def file_exists(self, remote):
try:
res = self.mssql_conn.batch(f"DECLARE @r INT; EXEC master.dbo.xp_fileexist '{remote}', @r OUTPUT; SELECT @r as n")[0]["n"]
return res == 1
except:
except Exception:
return False

def get_file(self, remote, local):
Expand Down
2 changes: 1 addition & 1 deletion nxc/protocols/rdp.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@

from impacket.krb5.ccache import CCache

from nxc.connection import *
from nxc.connection import connection
from nxc.helpers.bloodhound import add_user_bh
from nxc.logger import NXCAdapter
from nxc.config import host_info_colors
Expand Down
17 changes: 9 additions & 8 deletions nxc/protocols/smb.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,9 @@
import ntpath
import hashlib
import binascii
import os
import re
import socket
from io import StringIO
from Cryptodome.Hash import MD4

Expand All @@ -30,7 +33,8 @@
from impacket.dcerpc.v5.dcom.wmi import CLSID_WbemLevel1Login, IID_IWbemLevel1Login, IWbemLevel1Login

from nxc.config import process_secret, host_info_colors
from nxc.connection import *
from nxc.connection import connection, sem, requires_admin, dcom_FirewallChecker
from nxc.helpers.misc import gen_random_string, validate_ntlm
from nxc.logger import NXCAdapter
from nxc.protocols.smb.firefox import FirefoxTriage
from nxc.servers.smb import NXCSMBServer
Expand All @@ -45,7 +49,6 @@
from nxc.protocols.ldap.laps import LDAPConnect, LAPSv2Extract
from nxc.protocols.ldap.gmsa import MSDS_MANAGEDPASSWORD_BLOB
from nxc.helpers.logger import highlight
from nxc.helpers.misc import *
from nxc.helpers.bloodhound import add_user_bh
from nxc.helpers.powershell import create_ps_command

Expand All @@ -57,7 +60,8 @@
from dploot.lib.target import Target
from dploot.lib.smb import DPLootSMBConnection

from pywerview.cli.helpers import *
from pywerview.cli.helpers import get_localdisks, get_netsession, get_netgroupmember, get_netgroup, get_netcomputer, \
get_netloggedon, get_netlocalgroup

from time import time
from datetime import datetime
Expand Down Expand Up @@ -659,7 +663,6 @@ def gen_relay_list(self):
relay_list.write(self.host + "\n")

@requires_admin
# @requires_smb_server
def execute(self, payload=None, get_output=False, methods=None):
if self.args.exec_method:
methods = [self.args.exec_method]
Expand Down Expand Up @@ -959,9 +962,7 @@ def local_groups(self):
member_count_ad=group.membercount,
)[0]

# yo dawg, I hear you like groups.
# So I put a domain group as a member of a local group which is also a member of another local group.
# (╯°□°)╯︵ ┻━┻
# domain groups can be part of a local group which is also part of another local group
if not group.isgroup:
self.db.add_credential("plaintext", domain, name, "", group_id, "")
elif group.isgroup:
Expand Down Expand Up @@ -1162,7 +1163,7 @@ def wmi(self, wmi_query=None, namespace=None):
iInterface = dcom.CoCreateInstanceEx(CLSID_WbemLevel1Login, IID_IWbemLevel1Login)
flag, stringBinding = dcom_FirewallChecker(iInterface, self.args.dcom_timeout)
if not flag or not stringBinding:
error_msg = f'WMI Query: Dcom initialization failed on connection with stringbinding: "{stringBinding}", please increase the timeout with the option "--dcom-timeout". If it\'s still failing maybe something is blocking the RPC connection, try another exec method'
error_msg = f"WMI Query: Dcom initialization failed on connection with stringbinding: '{stringBinding}', please increase the timeout with the option '--dcom-timeout'. If it's still failing maybe something is blocking the RPC connection, try another exec method"

if not stringBinding:
error_msg = "WMI Query: Dcom initialization failed: can't get target stringbinding, maybe cause by IPv6 or any other issues, please check your target again"
Expand Down
4 changes: 3 additions & 1 deletion nxc/protocols/ssh.py
Original file line number Diff line number Diff line change
@@ -1,13 +1,15 @@
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
import logging
import socket

from io import StringIO

import paramiko

from nxc.config import process_secret
from nxc.connection import *
from nxc.connection import connection
from nxc.helpers.logger import highlight
from nxc.logger import NXCAdapter
from paramiko.ssh_exception import (
AuthenticationException,
Expand Down
2 changes: 1 addition & 1 deletion nxc/protocols/vnc.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

from aardwolf.commons.target import RDPTarget

from nxc.connection import *
from nxc.connection import connection
from nxc.helpers.logger import highlight
from nxc.logger import NXCAdapter
from aardwolf.vncconnection import VNCConnection
Expand Down
2 changes: 1 addition & 1 deletion nxc/protocols/winrm.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
from impacket.examples.secretsdump import LocalOperations, LSASecrets, SAMHashes

from nxc.config import process_secret
from nxc.connection import *
from nxc.connection import connection
from nxc.helpers.bloodhound import add_user_bh
from nxc.protocols.ldap.laps import LDAPConnect, LAPSv2Extract
from nxc.logger import NXCAdapter
Expand Down
6 changes: 4 additions & 2 deletions nxc/protocols/wmi.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
import os, struct, logging
import os
import struct
import logging

from io import StringIO
from six import indexbytes
from datetime import datetime
from nxc.config import process_secret
from nxc.connection import *
from nxc.connection import connection, dcom_FirewallChecker, requires_admin
from nxc.logger import NXCAdapter
from nxc.protocols.wmi import wmiexec, wmiexec_event

Expand Down

0 comments on commit 95aaac7

Please sign in to comment.