Esempio n. 1
0
        /// <exception cref="WinrtCifs.Smb.SmbException"></exception>
        /// <exception cref="UnknownHostException"></exception>
        public static byte[] GetChallenge(UniAddress dc, int port)
        {
            SmbTransport trans = SmbTransport.GetSmbTransport(dc, port);

            trans.Connect();
            return(trans.Server.EncryptionKey);
        }
Esempio n. 2
0
 internal SmbTransport Transport()
 {
     lock (this)
     {
         if (transport == null)
         {
             transport = SmbTransport.GetSmbTransport(_address, _port, _localAddr, _localPort, null
                                                      );
         }
         return(transport);
     }
 }
Esempio n. 3
0
        /// <exception cref="WinrtCifs.Smb.SmbException"></exception>
        public static void Logon(UniAddress dc, int port, NtlmPasswordAuthentication auth
                                 )
        {
            SmbTree tree = SmbTransport.GetSmbTransport(dc, port).GetSmbSession(auth).GetSmbTree
                               (LogonShare, null);

            if (LogonShare == null)
            {
                tree.TreeConnect(null, null);
            }
            else
            {
                Trans2FindFirst2         req  = new Trans2FindFirst2("\\", "*", SmbFile.AttrDirectory);
                Trans2FindFirst2Response resp = new Trans2FindFirst2Response();
                tree.Send(req, resp);
            }
        }
Esempio n. 4
0
 /// <exception cref="WinrtCifs.Smb.SmbAuthException"></exception>
 public virtual Hashtable GetTrustedDomains(NtlmPasswordAuthentication auth)
 {
     if (Disabled || auth.Domain == "?")
     {
         return(null);
     }
     if (Domains != null && Runtime.CurrentTimeMillis() > Domains.Expiration)
     {
         Domains = null;
     }
     if (Domains != null)
     {
         return(Domains.Map);
     }
     try
     {
         UniAddress   addr  = UniAddress.GetByName(auth.Domain, true);
         SmbTransport trans = SmbTransport.GetSmbTransport(addr, 0);
         CacheEntry   entry = new CacheEntry(Ttl * 10L);
         DfsReferral  dr    = trans.GetDfsReferrals(auth, string.Empty, 0);
         if (dr != null)
         {
             DfsReferral start = dr;
             do
             {
                 string domain = dr.Server.ToLower();
                 entry.Map.Put(domain, new Hashtable());
                 dr = dr.Next;
             }while (dr != start);
             Domains = entry;
             return(Domains.Map);
         }
     }
     catch (IOException ioe)
     {
         if (Log.Level >= 3)
         {
             Runtime.PrintStackTrace(ioe, Log);
         }
         if (StrictView && ioe is SmbAuthException)
         {
             throw (SmbAuthException)ioe;
         }
     }
     return(null);
 }
Esempio n. 5
0
 /// <exception cref="WinrtCifs.Smb.SmbAuthException"></exception>
 public virtual SmbTransport GetDc(string domain, NtlmPasswordAuthentication auth)
 {
     if (Disabled)
     {
         return(null);
     }
     try
     {
         UniAddress   addr  = UniAddress.GetByName(domain, true);
         SmbTransport trans = SmbTransport.GetSmbTransport(addr, 0);
         DfsReferral  dr    = trans.GetDfsReferrals(auth, "\\" + domain, 1);
         if (dr != null)
         {
             DfsReferral start = dr;
             IOException e     = null;
             do
             {
                 try
                 {
                     addr = UniAddress.GetByName(dr.Server);
                     return(SmbTransport.GetSmbTransport(addr, 0));
                 }
                 catch (IOException ioe)
                 {
                     e = ioe;
                 }
                 dr = dr.Next;
             }while (dr != start);
             throw e;
         }
     }
     catch (IOException ioe)
     {
         if (Log.Level >= 3)
         {
             Runtime.PrintStackTrace(ioe, Log);
         }
         if (StrictView && ioe is SmbAuthException)
         {
             throw (SmbAuthException)ioe;
         }
     }
     return(null);
 }
Esempio n. 6
0
        /// <exception cref="WinrtCifs.Smb.SmbException"></exception>
        private static NtlmChallenge Interrogate(NbtAddress addr)
        {
            UniAddress   dc    = new UniAddress(addr);
            SmbTransport trans = SmbTransport.GetSmbTransport(dc, 0);

            if (Username == null)
            {
                trans.Connect();
                if (SmbTransport.LogStatic.Level >= 3)
                {
                    SmbTransport.LogStatic.WriteLine("Default credentials (jcifs.smb.client.username/password)"
                                                     + " not specified. SMB signing may not work propertly." + "  Skipping DC interrogation."
                                                     );
                }
            }
            else
            {
                SmbSession ssn = trans.GetSmbSession(NtlmPasswordAuthentication.Default
                                                     );
                ssn.GetSmbTree(LogonShare, null).TreeConnect(null, null);
            }
            return(new NtlmChallenge(trans.Server.EncryptionKey, dc));
        }