mirror of https://github.com/n1nj4sec/pupy.git
Merge branch 'getdomain' of https://github.com/AlessandroZ/pupy into AlessandroZ-getdomain
This commit is contained in:
commit
5db2bf740f
|
@ -0,0 +1,19 @@
|
|||
# -*- coding: UTF8 -*-
|
||||
from pupylib.PupyModule import *
|
||||
|
||||
__class_name__="GetDomain"
|
||||
|
||||
@config(compat="windows", cat="admin")
|
||||
class GetDomain(PupyModule):
|
||||
""" Get primary domain controller """
|
||||
|
||||
def init_argparse(self):
|
||||
self.arg_parser = PupyArgumentParser(prog="getdomain", description=self.__doc__)
|
||||
|
||||
def run(self, args):
|
||||
self.client.load_package("pupwinutils.getdomain")
|
||||
primary_domain = self.client.conn.modules["pupwinutils.getdomain"].get_domain_controller()
|
||||
if not primary_domain:
|
||||
self.error("This host is not part of a domain.")
|
||||
else:
|
||||
self.success("Primary domain controller: %s" % primary_domain)
|
|
@ -0,0 +1,14 @@
|
|||
from _winreg import *
|
||||
|
||||
def get_domain_controller():
|
||||
|
||||
aReg = ConnectRegistry(None, HKEY_LOCAL_MACHINE)
|
||||
keypath = r"SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Group Policy\\History\\"
|
||||
subkey_name = 'DCName'
|
||||
try:
|
||||
aKey = OpenKey(aReg, keypath)
|
||||
val, _ = QueryValueEx(aKey, subkey_name)
|
||||
CloseKey(aKey)
|
||||
return val
|
||||
except:
|
||||
return False
|
Loading…
Reference in New Issue