簡體   English   中英

在我的代碼中查找安全漏洞-LDAP搜索

[英]Finding security vulnerabilites in my code - LDAP Search

我如何在這里的代碼中找到vulnerabilites。 我的任務是要我不使用程序來查找易受攻擊的工具,因此不要使用Spotbug等。是否有任何網站和/或提示供我查找易受攻擊的工具。 這是我的代碼

我曾嘗試過使用Google,但很難找到可靠的網站或文檔來查找或幫助我找到易受攻擊的物品。

用戶在LDAP目錄中搜索:

public class LsiLDAPUsers
{
    private void searchRecord( String userSN, String userPassword ) throws NamingException
    {
        Hashtable<String, String> env = new Hashtable<String, String>();
        env.put(Context.INITIAL_CONTEXT_FACTORY, "com.sun.jndi.ldap.LdapCtxFactory");

        try
        {
            DirContext dctx = new InitialDirContext(env);

            SearchControls sc = new SearchControls();
            String[] attributeFilter = { "cn", "mail" };
            sc.setReturningAttributes(attributeFilter);
            sc.setSearchScope(SearchControls.SUBTREE_SCOPE);
            String base = "dc=lsi,dc=com";

            String filter = "(&(sn=" + userSN + ")(userPassword=" + userPassword + "))";

            NamingEnumeration<?> results = dctx.search(base, filter, sc);
            while (results.hasMore())
            {
                SearchResult sr = (SearchResult) results.next();
                Attributes attrs = (Attributes) sr.getAttributes();
                Attribute attr = (Attribute) attrs.get("cn");
                System.out.println(attr);
                attr = (Attribute) attrs.get("mail");
                System.out.println(attr);
            }
            dctx.close();
        }
        catch (NamingException e)
        {
            // Forward to handler
        }
    }
}

我基本上需要使代碼更安全。 這是我的代碼之一。 但是我還有很多其他工作要做。 我只需要從這個例子中得到一個很好的例子和/或技巧,謝謝!

只是一些提示:

  • 安全編碼的主要支柱是正確驗證用戶輸入 這是大多數黑客的主要切入點。
  • 今天默認使用SSL或TLS進行網絡連接
  • 如今,大多數系統已禁用匿名搜索

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM