//////////////////////////////////////////////////////////////////////////////// // //////////////////////////////////////////////////////////////////////////////// internal Boolean SetInfoRequest(String sourceFilePath, String destination) { SMB2Header header = new SMB2Header(); header.SetCommand(new Byte[] { 0x11, 0x00 }); header.SetCreditsRequested(new Byte[] { 0x01, 0x00 }); header.SetMessageID(++messageId); header.SetProcessID(processId); header.SetTreeId(treeId); header.SetSessionID(sessionId); SMB2SetInfo setInfo = new SMB2SetInfo(); setInfo.SetClass(new Byte[] { 0x01 }); setInfo.SetInfoLevel(new Byte[] { 0x14 }); setInfo.SetGUIDHandleFile(guidFileHandle); //This may need to be coverted to int32 using (FileStream fileStream = new FileStream(Path.GetFullPath(sourceFilePath), FileMode.Open, FileAccess.Read, FileShare.ReadWrite)) { using (BinaryReader binaryReader = new BinaryReader(fileStream)) { setInfo.SetBuffer(BitConverter.GetBytes(binaryReader.BaseStream.Length)); } } setInfo.SetGUIDHandleFile(guidFileHandle); Byte[] bData = setInfo.GetRequest(); header.SetChainOffset(bData.Length); if (signing) { header.SetFlags(new Byte[] { 0x08, 0x00, 0x00, 0x00 }); header.SetSignature(sessionKey, ref bData); } Byte[] bHeader = header.GetHeader(); NetBIOSSessionService sessionService = new NetBIOSSessionService(); sessionService.SetHeaderLength(bHeader.Length); sessionService.SetDataLength(bData.Length); Byte[] bSessionService = sessionService.GetNetBIOSSessionService(); Byte[] bSend = Combine.combine(bSessionService, Combine.combine(bHeader, bData)); streamSocket.Write(bSend, 0, bSend.Length); streamSocket.Flush(); streamSocket.Read(recieve, 0, recieve.Length); if (GetStatus(recieve.Skip(12).Take(4).ToArray())) { treeId = recieve.Skip(40).Take(4).ToArray(); return(true); } return(false); }
//////////////////////////////////////////////////////////////////////////////// // //////////////////////////////////////////////////////////////////////////////// internal Boolean SetInfoRequest() { SMB2Header header = new SMB2Header(); header.SetCommand(new Byte[] { 0x11, 0x00 }); header.SetCreditsRequested(new Byte[] { 0x01, 0x00 }); header.SetMessageID(++messageId); header.SetProcessID(processId); header.SetTreeId(treeId); header.SetSessionID(sessionId); SMB2SetInfo setInfo = new SMB2SetInfo(); setInfo.SetClass(new Byte[] { 0x01 }); setInfo.SetInfoLevel(new Byte[] { 0x0d }); setInfo.SetGUIDHandleFile(guidFileHandle); setInfo.SetBuffer(new Byte[] { 0x01, 0x00, 0x00, 0x00 }); Byte[] bData = setInfo.GetRequest(); if (signing) { header.SetFlags(new Byte[] { 0x08, 0x00, 0x00, 0x00 }); header.SetSignature(sessionKey, ref bData); } Byte[] bHeader = header.GetHeader(); NetBIOSSessionService sessionService = new NetBIOSSessionService(); sessionService.SetHeaderLength(bHeader.Length); sessionService.SetDataLength(bData.Length); Byte[] bSessionService = sessionService.GetNetBIOSSessionService(); Byte[] bSend = Combine.combine(bSessionService, Combine.combine(bHeader, bData)); streamSocket.Write(bSend, 0, bSend.Length); streamSocket.Flush(); streamSocket.Read(recieve, 0, recieve.Length); if (GetStatusSilent(recieve.Skip(12).Take(4).ToArray())) { Console.WriteLine("[+] File Deleted"); return(true); } return(false); }