def test_BaseRegCreateKey_BaseRegSetValue_BaseRegDeleteKey(self): dce, rpctransport, phKey = self.connect() request = rrp.OpenClassesRoot() request['ServerName'] = NULL request['samDesired'] = MAXIMUM_ALLOWED resp = dce.request(request) resp.dump() regHandle = resp['phKey'] request = rrp.BaseRegCreateKey() request['hKey'] = regHandle request['lpSubKey'] = 'BETO\x00' request['lpClass'] = NULL request['dwOptions'] = 0x00000001 request['samDesired'] = MAXIMUM_ALLOWED request['lpSecurityAttributes']['RpcSecurityDescriptor'][ 'lpSecurityDescriptor'] = NULL request['lpdwDisposition'] = rrp.REG_CREATED_NEW_KEY resp = dce.request(request) resp.dump() phKey = resp['phkResult'] request = rrp.BaseRegSetValue() request['hKey'] = phKey request['lpValueName'] = 'BETO\x00' request['dwType'] = rrp.REG_SZ request['lpData'] = 'HOLA COMO TE VA\x00'.encode('utf-16le') request['cbData'] = len('HOLA COMO TE VA\x00') * 2 try: resp = dce.request(request) resp.dump() except Exception, e: print e
def test_BaseRegCreateKey_BaseRegSetValue_BaseRegDeleteKey(self): dce, rpctransport = self.connect() request = rrp.OpenClassesRoot() request['ServerName'] = NULL request['samDesired'] = MAXIMUM_ALLOWED resp = dce.request(request) resp.dump() regHandle = resp['phKey'] request = rrp.BaseRegCreateKey() request['hKey'] = regHandle request['lpSubKey'] = self.test_key request['lpClass'] = NULL request['dwOptions'] = 0x00000001 request['samDesired'] = MAXIMUM_ALLOWED request['lpSecurityAttributes']['RpcSecurityDescriptor'][ 'lpSecurityDescriptor'] = NULL request['lpdwDisposition'] = rrp.REG_CREATED_NEW_KEY resp = dce.request(request) resp.dump() phKey = resp['phkResult'] request = rrp.BaseRegSetValue() request['hKey'] = phKey request['lpValueName'] = self.test_value_name request['dwType'] = rrp.REG_SZ request['lpData'] = self.test_value_data.encode('utf-16le') request['cbData'] = len(self.test_value_data) * 2 try: resp = dce.request(request) resp.dump() except Exception as e: print(e) request = rrp.BaseRegQueryValue() request['hKey'] = phKey request['lpValueName'] = self.test_value_name request['lpData'] = b' ' * 100 request['lpcbData'] = 100 request['lpcbLen'] = 100 resp = dce.request(request) resp.dump() resData = resp['lpData'] request = rrp.BaseRegDeleteKey() request['hKey'] = regHandle request['lpSubKey'] = self.test_key resp = dce.request(request) resp.dump() print(b''.join(resData).decode('utf-16le')) self.assertEqual(self.test_value_data, b''.join(resData).decode('utf-16le'))