Esempio n. 1
0
        // Taken from: https://github.com/TeskeVirtualSystem/MS17010Test
        private static string GetOSDetails(string target)
        {
            string osDetails = "";

            byte[]        negotiateBytes = negotiateProtoRequest();
            byte[]        sessionBytes   = sessionSetupAndxRequest();
            List <byte[]> bytesToSend    = new List <byte[]>()
            {
                negotiateBytes, sessionBytes
            };

            byte[] byteResult = General.BannerGrabBytes(target, 445, bytesToSend);
            var    sessionSetupAndxResponse = byteResult.Skip(36).ToArray();
            var    nativeOsB = sessionSetupAndxResponse.Skip(9).ToArray();
            var    osData    = Encoding.ASCII.GetString(nativeOsB).Split('\x00');

            if (osData[0] != "et by peer") // Invalid response that was cut off
            {
                string osName = osData[0];
                osDetails += "- OS Name: " + osName + Environment.NewLine;
                if (osName == "Windows 5.1")
                {
                    osDetails += "-- Windows 5.1 == Windows XP SP3" + Environment.NewLine;
                }
                if (osData.Count() >= 3)
                {
                    osDetails += "- OS Build: " + osData[1] + Environment.NewLine;
                    osDetails += "- OS Workgroup: " + osData[2] + Environment.NewLine;
                }
            }
            return(osDetails);
        }