Ejemplo n.º 1
0
        public override string ToString()
        {
            StringBuilder sb = new StringBuilder();

            //return "";

            string n = name;

            // fix MSBROWSE name
            if (n == null)
            {
                n = "null";
            }
            else
            {
                if (n[0] == unchecked (0x01))
                {
                    char[] c = n.ToCharArray();
                    c[0]  = '.';
                    c[1]  = '.';
                    c[14] = '.';
                    n     = new string(c);
                }
            }
            sb.Append(n).Append("<").Append(Hexdump.ToHexString(HexCode, 2)).Append(">");
            if (Scope != null)
            {
                sb.Append(".").Append(Scope);
            }
            return(sb.ToString());
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Return the numeric representation of this sid such as
        /// <tt>S-1-5-21-1496946806-2192648263-3843101252-1029</tt>.
        /// </summary>
        /// <remarks>
        /// Return the numeric representation of this sid such as
        /// <tt>S-1-5-21-1496946806-2192648263-3843101252-1029</tt>.
        /// </remarks>
        public override string ToString()
        {
            string ret = "S-" + (Revision & unchecked (0xFF)) + "-";

            if (IdentifierAuthority[0] != unchecked (0) || IdentifierAuthority[1] != unchecked (
                    0))
            {
                ret += "0x";
                ret += Hexdump.ToHexString(IdentifierAuthority, 0, 6);
            }
            else
            {
                int  shift = 0;
                long id    = 0;
                for (int i = 5; i > 1; i--)
                {
                    id    += (IdentifierAuthority[i] & unchecked (0xFFL)) << shift;
                    shift += 8;
                }
                ret += id;
            }
            for (int i1 = 0; i1 < SubAuthorityCount; i1++)
            {
                ret += "-" + (SubAuthority[i1] & unchecked (0xFFFFFFFFL));
            }
            return(ret);
        }
Ejemplo n.º 3
0
 public override string ToString()
 {
     return("Trans2QueryPathInformation["
            + base.ToString()
            + ",informationLevel=0x" + Hexdump.ToHexString(_informationLevel, 3)
            + ",filename=" + Path + "]");
 }
Ejemplo n.º 4
0
 public override string ToString()
 {
     return("Trans2FindNext2[" + base.ToString() + ",sid=" + _sid + ",searchCount="
            + Smb.Trans2FindFirst2.ListSize + ",informationLevel=0x" + Hexdump.ToHexString(_informationLevel
                                                                                           , 3) + ",resumeKey=0x" + Hexdump.ToHexString(_resumeKey, 4) + ",flags=0x" + Hexdump
            .ToHexString(_flags, 2) + ",filename=" + _filename + "]");
 }
Ejemplo n.º 5
0
 public override string ToString()
 {
     return("SmbShareInfo["
            + "netName=" + NetName
            + ",type=0x" + Hexdump.ToHexString(Type, 8)
            + ",remark=" + Remark + "]");
 }
Ejemplo n.º 6
0
 public override string ToString()
 {
     string ret = "NtlmContext[auth=" + Auth
                             + ",ntlmsspFlags=0x" + Hexdump.ToHexString(NtlmsspFlags, 8)
                             + ",workstation=" + Workstation
                             + ",isEstablished=" + isEstablished
                             + ",state=" + State
                             + ",serverChallenge=";
     if (ServerChallenge == null)
     {
         ret += "null";
     }
     else
     {
         ret += Hexdump.ToHexString(ServerChallenge, 0, ServerChallenge.Length * 2);
     }
     ret += ",signingKey=";
     if (SigningKey == null)
     {
         ret += "null";
     }
     else
     {
         ret += Hexdump.ToHexString(SigningKey, 0, SigningKey.Length * 2);
     }
     ret += "]";
     return ret;
 }
Ejemplo n.º 7
0
 public override string ToString()
 {
     return("LM_COMPATIBILITY=" + SmbConstants.LmCompatibility
            + " MacSigningKey=" + Hexdump.ToHexString(_macSigningKey,
                                                      0,
                                                      _macSigningKey.Length));
 }
Ejemplo n.º 8
0
 public override string ToString()
 {
     return("SmbComDelete["
            + base.ToString()
            + ",searchAttributes=0x" + Hexdump.ToHexString(_searchAttributes, 4)
            + ",fileName=" + Path + "]");
 }
Ejemplo n.º 9
0
        internal static string GetMessageByDcerpcError(int errcode)
        {
            int min = 0;
            int max = DcerpcError.DcerpcFaultCodes.Length;

            while (max >= min)
            {
                int mid = (min + max) / 2;
                if (errcode > DcerpcError.DcerpcFaultCodes[mid])
                {
                    min = mid + 1;
                }
                else
                {
                    if (errcode < DcerpcError.DcerpcFaultCodes[mid])
                    {
                        max = mid - 1;
                    }
                    else
                    {
                        return(DcerpcError.DcerpcFaultMessages[mid]);
                    }
                }
            }
            return("0x" + Hexdump.ToHexString(errcode, 8));
        }
Ejemplo n.º 10
0
 public override string ToString()
 {
     return("SmbComQueryInformationResponse["
            + base.ToString()
            + ",fileAttributes=0x" + Hexdump.ToHexString(_fileAttributes, 4)
            + ",lastWriteTime=" + Extensions.CreateDate(_lastWriteTime)
            + ",fileSize=" + _fileSize + "]");
 }
Ejemplo n.º 11
0
 public override string ToString()
 {
     return("NtTransQuerySecurityDesc["
            + base.ToString()
            + ",fid=0x" + Hexdump.ToHexString(Fid, 4)
            + ",securityInformation=0x" + Hexdump.ToHexString(SecurityInformation, 8)
            + "]");
 }
Ejemplo n.º 12
0
 public override string ToString()
 {
     return("SmbComRename["
            + base.ToString()
            + ",searchAttributes=0x" + Hexdump.ToHexString(_searchAttributes, 4)
            + ",oldFileName=" + _oldFileName
            + ",newFileName=" + _newFileName + "]");
 }
Ejemplo n.º 13
0
 public override string ToString()
 {
     return("Trans2FindFirst2[" + base.ToString() + ",searchAttributes=0x"
            + Hexdump.ToHexString(_searchAttributes, 2) + ",searchCount=" + ListCount + ",flags=0x"
            + Hexdump.ToHexString(_flags, 2) + ",informationLevel=0x" + Hexdump.ToHexString(
                _informationLevel, 3) + ",searchStorageType=" + _searchStorageType + ",filename="
            + Path + "]");
 }
 public override string ToString()
 {
     return("SmbQueryFileBasicInfo[" + "createTime=" + Extensions.CreateDate
                (CreateTime) + ",lastAccessTime=" + Extensions.CreateDate(LastAccessTime
                                                                          ) + ",lastWriteTime=" + Extensions.CreateDate(LastWriteTime) + ",changeTime="
            + Extensions.CreateDate(ChangeTime) + ",attributes=0x" + Hexdump.ToHexString
                (Attributes, 4) + "]");
 }
Ejemplo n.º 15
0
 public override string ToString()
 {
     return("ServerInfo1["
            + "name=" + Name
            + ",versionMajor=" + VersionMajor
            + ",versionMinor=" + VersionMinor
            + ",type=0x" + Hexdump.ToHexString(Type, 8)
            + ",commentOrMasterBrowser=" + CommentOrMasterBrowser + "]");
 }
Ejemplo n.º 16
0
        public override string ToString()
        {
            string suppliedDomain      = GetSuppliedDomain();
            string suppliedWorkstation = GetSuppliedWorkstation();

            return("Type1Message[suppliedDomain=" + (suppliedDomain ?? "null")
                   + ",suppliedWorkstation=" + (suppliedWorkstation ?? "null")
                   + ",flags=0x" + Hexdump.ToHexString(GetFlags(), 8) + "]");
        }
Ejemplo n.º 17
0
 public override string ToString()
 {
     return("SmbComOpenAndX[" + base.ToString() + ",flags=0x" + Hexdump.ToHexString
                (flags, 2) + ",desiredAccess=0x" + Hexdump.ToHexString(DesiredAccess, 4) + ",searchAttributes=0x"
            + Hexdump.ToHexString(SearchAttributes, 4) + ",fileAttributes=0x" + Hexdump.ToHexString
                (FileAttributes, 4) + ",creationTime=" + Extensions.CreateDate(CreationTime
                                                                               ) + ",openFunction=0x" + Hexdump.ToHexString(OpenFunction, 2) + ",allocationSize="
            + AllocationSize + ",fileName=" + Path + "]");
 }
Ejemplo n.º 18
0
 internal static string GetMessageByCode(int errcode)
 {
     if (errcode == 0)
     {
         return("NT_STATUS_SUCCESS");
     }
     if ((errcode & unchecked ((int)(0xC0000000))) == unchecked ((int)(0xC0000000)))
     {
         int min = 1;
         int max = NtStatus.NtStatusCodes.Length - 1;
         while (max >= min)
         {
             int mid = (min + max) / 2;
             if (errcode > NtStatus.NtStatusCodes[mid])
             {
                 min = mid + 1;
             }
             else
             {
                 if (errcode < NtStatus.NtStatusCodes[mid])
                 {
                     max = mid - 1;
                 }
                 else
                 {
                     return(NtStatus.NtStatusMessages[mid]);
                 }
             }
         }
     }
     else
     {
         int min = 0;
         int max = DosError.DosErrorCodes.Length - 1;
         while (max >= min)
         {
             int mid = (min + max) / 2;
             if (errcode > DosError.DosErrorCodes[mid][0])
             {
                 min = mid + 1;
             }
             else
             {
                 if (errcode < DosError.DosErrorCodes[mid][0])
                 {
                     max = mid - 1;
                 }
                 else
                 {
                     return(DosError.DosErrorMessages[mid]);
                 }
             }
         }
     }
     return("0x" + Hexdump.ToHexString(errcode, 8));
 }
Ejemplo n.º 19
0
 public override string ToString()
 {
     return("SmbComNTCreateAndX[" + base.ToString() + ",flags=0x" + Hexdump
            .ToHexString(Flags0, 2) + ",rootDirectoryFid=" + _rootDirectoryFid + ",desiredAccess=0x"
            + Hexdump.ToHexString(DesiredAccess, 4) + ",allocationSize=" + _allocationSize +
            ",extFileAttributes=0x" + Hexdump.ToHexString(_extFileAttributes, 4) + ",shareAccess=0x"
            + Hexdump.ToHexString(_shareAccess, 4) + ",createDisposition=0x" + Hexdump.ToHexString
                (_createDisposition, 4) + ",createOptions=0x" + Hexdump.ToHexString(_createOptions
                                                                                    , 8) + ",impersonationLevel=0x" + Hexdump.ToHexString(_impersonationLevel, 4) + ",securityFlags=0x"
            + Hexdump.ToHexString(_securityFlags, 2) + ",name=" + Path + "]");
 }
Ejemplo n.º 20
0
        /// <summary>Return a string represeting this ACE.</summary>
        /// <remarks>
        /// Return a string represeting this ACE.
        /// <p>
        /// Note: This function should probably be changed to return SDDL
        /// fragments but currently it does not.
        /// </remarks>
        public override string ToString()
        {
            StringBuilder sb = new StringBuilder();

            sb.Append(IsAllow() ? "Allow " : "Deny  ");
            AppendCol(sb, Sid.ToDisplayString(), 25);
            sb.Append(" 0x").Append(Hexdump.ToHexString(Access, 8)).Append(' ');
            sb.Append(IsInherited() ? "Inherited " : "Direct    ");
            AppendCol(sb, GetApplyToText(), 34);
            return(sb.ToString());
        }
Ejemplo n.º 21
0
 public override string ToString()
 {
     return("SmbComNTCreateAndXResponse[" + base.ToString() + ",oplockLevel="
            + OplockLevel + ",fid=" + Fid + ",createAction=0x" + Hexdump.ToHexString(CreateAction
                                                                                     , 4) + ",creationTime=" + Extensions.CreateDate(CreationTime) + ",lastAccessTime="
            + Extensions.CreateDate(LastAccessTime) + ",lastWriteTime=" + Extensions.CreateDate
                (LastWriteTime) + ",changeTime=" + Extensions.CreateDate(ChangeTime) + ",extFileAttributes=0x"
            + Hexdump.ToHexString(ExtFileAttributes, 4) + ",allocationSize=" + AllocationSize
            + ",endOfFile=" + EndOfFile + ",fileType=" + FileType + ",deviceState=" + DeviceState
            + ",directory=" + Directory + "]");
 }
Ejemplo n.º 22
0
 public override string ToString()
 {
     return(base.ToString() + ",totalParameterCount=" + TotalParameterCount
            + ",totalDataCount=" + TotalDataCount + ",maxParameterCount=" + MaxParameterCount
            + ",maxDataCount=" + MaxDataCount + ",maxSetupCount=" + (int)MaxSetupCount + ",flags=0x"
            + Hexdump.ToHexString(_flags, 2) + ",timeout=" + Timeout + ",parameterCount=" +
            ParameterCount + ",parameterOffset=" + ParameterOffset + ",parameterDisplacement="
            + ParameterDisplacement + ",dataCount=" + DataCount + ",dataOffset=" + DataOffset
            + ",dataDisplacement=" + DataDisplacement + ",setupCount=" + SetupCount + ",pad="
            + _pad + ",pad1=" + _pad1);
 }
Ejemplo n.º 23
0
        public override string ToString()
        {
            string result = "SmbComTreeConnectAndX["
                            + base.ToString()
                            + ",disconnectTid=" + _disconnectTid
                            + ",passwordLength=" + _passwordLength
                            + ",password="******",path=" + path
                            + ",service=" + _service + "]";

            return(result);
        }
Ejemplo n.º 24
0
        public override string ToString()
        {
            string target = GetTarget();

            byte[] challenge         = GetChallenge();
            byte[] context           = GetContext();
            byte[] targetInformation = GetTargetInformation();
            return("Type2Message[target=" + target + ",challenge=" + (challenge == null ? "null"
                                 : "<" + challenge.Length + " bytes>") + ",context=" + (context == null ? "null"
                                 : "<" + context.Length + " bytes>") + ",targetInformation=" + (targetInformation
                                                                                                == null ? "null" : "<" + targetInformation.Length + " bytes>") + ",flags=0x" +
                   Hexdump.ToHexString(GetFlags(), 8) + "]");
        }
Ejemplo n.º 25
0
 public override string ToString()
 {
     return("SmbComNegotiateResponse[" + base.ToString() + ",wordCount=" +
            WordCount + ",dialectIndex=" + DialectIndex + ",securityMode=0x" + Hexdump.ToHexString
                (Server.SecurityMode, 1) + ",security=" + (Server.Security == SmbConstants.SecurityShare ? "share"
                          : "user") + ",encryptedPasswords=" + Server.EncryptedPasswords + ",maxMpxCount="
            + Server.MaxMpxCount + ",maxNumberVcs=" + Server.MaxNumberVcs + ",maxBufferSize="
            + Server.MaxBufferSize + ",maxRawSize=" + Server.MaxRawSize + ",sessionKey=0x"
            + Hexdump.ToHexString(Server.SessionKey, 8) + ",capabilities=0x" + Hexdump.ToHexString
                (Server.Capabilities, 8) + ",serverTime=" + Extensions.CreateDate(Server
                                                                                  .ServerTime) + ",serverTimeZone=" + Server.ServerTimeZone + ",encryptionKeyLength="
            + Server.EncryptionKeyLength + ",byteCount=" + ByteCount + ",oemDomainName=" +
            Server.OemDomainName + "]");
 }
Ejemplo n.º 26
0
 /// <summary>Retrieve all addresses of a host by it's address.</summary>
 /// <remarks>
 /// Retrieve all addresses of a host by it's address. NetBIOS hosts can
 /// have many names for a given IP address. The name and IP address make the
 /// NetBIOS address. This provides a way to retrieve the other names for a
 /// host with the same IP address.
 /// </remarks>
 /// <param name="addr">the address to query</param>
 /// <exception cref="UnknownHostException">if address cannot be resolved</exception>
 public static NbtAddress[] GetAllByAddress(NbtAddress addr)
 {
     try
     {
         NbtAddress[] addrs = Client.GetNodeStatus(addr);
         CacheAddressArray(addrs);
         return(addrs);
     }
     catch (UnknownHostException)
     {
         throw new UnknownHostException("no name with type 0x" + Hexdump.ToHexString(addr.
                                                                                     HostName.HexCode, 2) + (((addr.HostName.Scope == null) || (addr.HostName.Scope.Length
                                                                                                                                                == 0)) ? " with no scope" : " with scope " + addr.HostName.Scope) + " for host "
                                        + addr.GetHostAddress());
     }
 }
Ejemplo n.º 27
0
        public override string ToString()
        {
            string user        = GetUser();
            string domain      = GetDomain();
            string workstation = GetWorkstation();

            byte[] lmResponse = GetLMResponse();
            byte[] ntResponse = GetNTResponse();
            byte[] sessionKey = GetSessionKey();
            return("Type3Message[domain=" + domain
                   + ",user="******",workstation=" + workstation
                   + ",lmResponse=" + (lmResponse == null
                                                        ? "null"
                                                        : "<" + lmResponse.Length + " bytes>")
                   + ",ntResponse=" + (ntResponse == null
                                                        ? "null"
                                                        : "<" + ntResponse.Length + " bytes>")
                   + ",sessionKey=" + (sessionKey == null
                                                        ? "null"
                                                        : "<" + sessionKey.Length + " bytes>")
                   + ",flags=0x" + Hexdump.ToHexString(GetFlags(), 8) + "]");
        }
Ejemplo n.º 28
0
        public override string ToString()
        {
            string opCodeString;
            string resultCodeString;
            string questionTypeString;
            string recordTypeString;

            switch (OpCode)
            {
            case Query:
            {
                opCodeString = "QUERY";
                break;
            }

            case Wack:
            {
                opCodeString = "WACK";
                break;
            }

            default:
            {
                opCodeString = Extensions.ToString(OpCode);
                break;
            }
            }
            switch (ResultCode)
            {
            case FmtErr:
            {
                resultCodeString = "FMT_ERR";
                break;
            }

            case SrvErr:
            {
                resultCodeString = "SRV_ERR";
                break;
            }

            case ImpErr:
            {
                resultCodeString = "IMP_ERR";
                break;
            }

            case RfsErr:
            {
                resultCodeString = "RFS_ERR";
                break;
            }

            case ActErr:
            {
                resultCodeString = "ACT_ERR";
                break;
            }

            case CftErr:
            {
                resultCodeString = "CFT_ERR";
                break;
            }

            default:
            {
                resultCodeString = "0x" + Hexdump.ToHexString(ResultCode, 1);
                break;
            }
            }
            switch (QuestionType)
            {
            case Nb:
            {
                questionTypeString = "NB";
                break;
            }

            case Nbstat:
            {
                questionTypeString = "NBSTAT";
                break;
            }

            default:
            {
                questionTypeString = "0x" + Hexdump.ToHexString(QuestionType, 4);
                break;
            }
            }
            switch (RecordType)
            {
            case A:
            {
                recordTypeString = "A";
                break;
            }

            case Ns:
            {
                recordTypeString = "NS";
                break;
            }

            case Null:
            {
                recordTypeString = "NULL";
                break;
            }

            case Nb:
            {
                recordTypeString = "NB";
                break;
            }

            case Nbstat:
            {
                recordTypeString = "NBSTAT";
                break;
            }

            default:
            {
                recordTypeString = "0x" + Hexdump.ToHexString(RecordType, 4);
                break;
            }
            }
            return("nameTrnId=" + NameTrnId + ",isResponse=" + IsResponse + ",opCode="
                   + opCodeString + ",isAuthAnswer=" + IsAuthAnswer + ",isTruncated=" + IsTruncated
                   + ",isRecurAvailable=" + IsRecurAvailable + ",isRecurDesired=" + IsRecurDesired
                   + ",isBroadcast=" + IsBroadcast + ",resultCode=" + ResultCode + ",questionCount="
                   + QuestionCount + ",answerCount=" + AnswerCount + ",authorityCount=" + AuthorityCount
                   + ",additionalCount=" + AdditionalCount + ",questionName=" + QuestionName + ",questionType="
                   + questionTypeString + ",questionClass=" + (QuestionClass == In ? "IN" : "0x" +
                                                               Hexdump.ToHexString(QuestionClass, 4)) + ",recordName=" + RecordName + ",recordType="
                   + recordTypeString + ",recordClass=" + (RecordClass == In ? "IN" : "0x" + Hexdump
                                                           .ToHexString(RecordClass, 4)) + ",ttl=" + Ttl + ",rDataLength=" + RDataLength);
        }
Ejemplo n.º 29
0
 public override string ToString()
 {
     return(base.ToString() + ",andxCommand=0x" + Hexdump.ToHexString(_andxCommand
                                                                      , 2) + ",andxOffset=" + _andxOffset);
 }
Ejemplo n.º 30
0
        public override string ToString()
        {
            string c;

            switch (Command)
            {
            case SmbComNegotiate:
            {
                c = "SMB_COM_NEGOTIATE";
                break;
            }

            case SmbComSessionSetupAndx:
            {
                c = "SMB_COM_SESSION_SETUP_ANDX";
                break;
            }

            case SmbComTreeConnectAndx:
            {
                c = "SMB_COM_TREE_CONNECT_ANDX";
                break;
            }

            case SmbComQueryInformation:
            {
                c = "SMB_COM_QUERY_INFORMATION";
                break;
            }

            case SmbComCheckDirectory:
            {
                c = "SMB_COM_CHECK_DIRECTORY";
                break;
            }

            case SmbComTransaction:
            {
                c = "SMB_COM_TRANSACTION";
                break;
            }

            case SmbComTransaction2:
            {
                c = "SMB_COM_TRANSACTION2";
                break;
            }

            case SmbComTransactionSecondary:
            {
                c = "SMB_COM_TRANSACTION_SECONDARY";
                break;
            }

            case SmbComFindClose2:
            {
                c = "SMB_COM_FIND_CLOSE2";
                break;
            }

            case SmbComTreeDisconnect:
            {
                c = "SMB_COM_TREE_DISCONNECT";
                break;
            }

            case SmbComLogoffAndx:
            {
                c = "SMB_COM_LOGOFF_ANDX";
                break;
            }

            case SmbComEcho:
            {
                c = "SMB_COM_ECHO";
                break;
            }

            case SmbComMove:
            {
                c = "SMB_COM_MOVE";
                break;
            }

            case SmbComRename:
            {
                c = "SMB_COM_RENAME";
                break;
            }

            case SmbComDelete:
            {
                c = "SMB_COM_DELETE";
                break;
            }

            case SmbComDeleteDirectory:
            {
                c = "SMB_COM_DELETE_DIRECTORY";
                break;
            }

            case SmbComNtCreateAndx:
            {
                c = "SMB_COM_NT_CREATE_ANDX";
                break;
            }

            case SmbComOpenAndx:
            {
                c = "SMB_COM_OPEN_ANDX";
                break;
            }

            case SmbComReadAndx:
            {
                c = "SMB_COM_READ_ANDX";
                break;
            }

            case SmbComClose:
            {
                c = "SMB_COM_CLOSE";
                break;
            }

            case SmbComWriteAndx:
            {
                c = "SMB_COM_WRITE_ANDX";
                break;
            }

            case SmbComCreateDirectory:
            {
                c = "SMB_COM_CREATE_DIRECTORY";
                break;
            }

            case SmbComNtTransact:
            {
                c = "SMB_COM_NT_TRANSACT";
                break;
            }

            case SmbComNtTransactSecondary:
            {
                c = "SMB_COM_NT_TRANSACT_SECONDARY";
                break;
            }

            default:
            {
                c = "UNKNOWN";
                break;
            }
            }
            string str = ErrorCode == 0 ? "0" : SmbException.GetMessageByCode(ErrorCode);

            return("command=" + c + ",received=" + Received + ",errorCode=" + str
                   + ",flags=0x" + Hexdump.ToHexString(Flags & 0xFF, 4) + ",flags2=0x"
                   + Hexdump.ToHexString(Flags2, 4) + ",signSeq=" + SignSeq + ",tid=" + Tid + ",pid="
                   + Pid + ",uid=" + Uid + ",mid=" + Mid + ",wordCount=" + WordCount + ",byteCount="
                   + ByteCount);
        }