- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我正在阅读this tutorial ,我遇到了以下关于加密的讨论。最后写着
In the last line, we’ve hashed the salt with the password, yielding an encrypted password that is virtually impossible to crack
但在我看来,同时拥有encrypted_password
和salt
的黑客可以像我们使用salt<一样执行“彩虹”技巧。/
.
那么,我哪里错了?
谢谢!
$ rails console
>> require 'digest'
>> def secure_hash(string)
>> Digest::SHA2.hexdigest(string)
>> end
=> nil
>> password = "secret"
=> "secret"
>> encrypted_password = secure_hash(password)
=> "2bb80d537b1da3e38bd30361aa855686bde0eacd7162fef6a25fe97bf527a25b"
>> submitted_password = "secret"
=> "secret"
>> encrypted_password == secure_hash(submitted_password)
=> trueHere we’ve defined a function called secure_hash that uses a cryptographic hash function called SHA2, part of the SHA family of hash functions, which we include into Ruby through the digest library.7 It’s not important to know exactly how these hash functions work; for our purposes what’s important is that they are one-way: there is no computationally tractable way to discover that
2bb80d537b1da3e38bd30361aa855686bde0eacd7162fef6a25fe97bf527a25b is the SHA2 hash of the string "secret".
If you think about it, though, we still have a problem: if an attacker ever got hold of the hashed passwords, he would still have a chance at discovering the originals. For example, he could guess that we used SHA2, and so write a program to compare a given hash to the hashed values of potential passwords:
>> hash = "2bb80d537b1da3e38bd30361aa855686bde0eacd7162fef6a25fe97bf527a25b"
>> secure_hash("secede") == hash
=> false
>> secure_hash("second") == hash
=> false
>> secure_hash("secret") == hash
=> trueSo our attacker has a match—bad news for any users with password "secret". This technique is known as a rainbow attack.
To foil a potential rainbow attack, we can use a salt, which is a different unique string for each user.8 One common way to (nearly) ensure uniqueness is to hash the current time (in UTC to be time zone–independent) along with the password, so that two users will have the same salt only if they are created at exactly the same time and have the same password. Let’s see how this works using the secure_hash function defined in the console above:
>> Time.now.utc
=> Fri Jan 29 18:11:27 UTC 2010
>> password = "secret"
=> "secret"
>> salt = secure_hash("#{Time.now.utc}--#{password}")
=> "d1a3eb8c9aab32ec19cfda810d2ab351873b5dca4e16e7f57b3c1932113314c8"
>> encrypted_password = secure_hash("#{salt}--#{password}")
=> "69a98a49b7fd103058639be84fb88c19c998c8ad3639cfc5deb458018561c847"In the last line, we’ve hashed the salt with the password, yielding an encrypted password that is virtually impossible to crack. (For clarity, arguments to hashing functions are often separated with --.)
最佳答案
彩虹表的计算成本很高。如果没有盐,您可以构建一个可以重复使用的彩虹表,因为密码“password”将始终产生相同的哈希值(md5=5f4dcc3b5aa765d61d8327deb882cf99,sha1=5baa61e4c9b93f3f0682250b6cf8331b7ee68fd8),因此很容易在密码数据库中识别。/p>
对于盐,您必须为遇到的每种盐计算彩虹表。一个足够大的盐,比如说 32 位(理想情况下是 128 位甚至更多),意味着你必须为每个想要破解的密码计算一个彩虹表,从而在很大程度上违背了它的目的。
关于encryption - 为什么我们使用 "salt"来保护我们的密码?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/5252943/
在设置了 salt-master 和一个 minion 后,我可以接受 master 上的 key 。运行 sudo salt-key -L表明它被接受。但是,当我尝试使用 test.ping 时命令
当我使用管道运行任何命令或在其中重定向时,它会失败。 master 和 minion 都在为测试 Salt 而创建的 Digital Ocean 上的新 Ubuntu 14.04 机器上运行。 两者都
这里的 Salt 中 [] 是什么意思? httpd: pkg.installed: [] file.managed: - name: /etc/httpd/conf/httpd.co
我正在寻找一种简单的方法来获取有关内存使用情况的信息,例如盐小兵的空闲内存。 到目前为止,我知道可以使用salt '*' grains.items列出总内存,但是我什至不知道如何仅列出总内存而不是所有
在 Saltstack 中,我有以下用例: 有一个状态 redis.sls 可以被其他状态包含。 redis.sls 的结果应该根据包含 redis.sls 的状态进行不同的配置。 例如: redis
我有一个带有盐状态的存储库,用于在云中配置我的服务器集群。随着时间的推移,我不断添加更多状态 - .sls文件 - 进入这个 repo。现在我开始挣扎什么是什么,什么是哪里。 我想知道是否有一些软件实
有没有办法加入两个支柱文件? 我有一个用户支柱。它是这样的: users: joe: sudouser: True jack: sudouser: False 现在我需要为某些
我在家庭实验室中使用 Saltstack,在测试它们时,我经常发现自己检查了一些稍有破坏的规则。我希望能够检查它们的有效性,否则在本地和 Jenkins 实例上对它们进行 lint,但我找不到任何有关
我有一个场景,如果另一个服务已经在运行,我需要采取行动。具体来说,我想安装 snmp 监控,例如,如果 mysql 已经在运行。 我知道这样做的“正确”方法是安装 mysql 及其基于支柱数据、gra
我正在尝试构建一个总是会重启服务的 .sls 文件: systemd-resolved: service.running: - restart: True 部署后,这会给出 I
(这是我在 salt 用户组 FWIW 上提出的问题的副本) 我需要编写一个状态来安装一些Windows服务器功能,重新启动minion,然后安装更多软件。似乎所有的部分都在那里(cmd.wait、s
“salt”在字符串到键 (s2k) 说明符中指什么? 它似乎是一个随机数生成器,可以改变事物,但我想知道“盐”代表什么? 例如这样写: 3.6.1.2. Salted S2K This inc
我正在尝试构建一个总是会重启服务的 .sls 文件: systemd-resolved: service.running: - restart: True 部署后,这会给出 I
我有一个 AWS 设置,其中有一个指定的 salt master,它接受所有传入的 key 和基于子网/指定 ip 地址的规定。如何在不登录主服务器的情况下立即在连接时配置我的 minions? 最佳
我想要一个 Salt 状态来管理我的 SSH 文件。这需要多个 file.line操作。我怎样才能做到这一点? 更新:请参阅问题底部以了解我当前的解决方法 我有的是这个: Secure SSH:
我正在验证用户电子邮件地址。 大多数人告诉的方式是创建一些独特的 token 并将其存储在 db 中 发送给用户。 我只是用全站盐散列(sha256)电子邮件地址来做这件事 并将此哈希发送给用户。 我
国家file.managed has defaults和 context模板渲染选项。两者都为模板变量提供上下文。 它们之间有什么区别? 最佳答案 defaults是在 context 情况下将传递给
我刚开始使用 Salt 而不是 Ansible。我不确定是从 master 调用以下脚本还是手动将命令输入 salt 状态。对于后者,任何人都可以建议如何使用 cmd.run 实现此目的。 #!/bi
我刚开始使用 Salt 而不是 Ansible。我不确定是从 master 调用以下脚本还是手动将命令输入 salt 状态。对于后者,任何人都可以建议如何使用 cmd.run 实现此目的。 #!/bi
我用了一个月的 salt 。每当我运行命令说 sudo salt '*' test.ping 时,master 就会对所有 minions 执行 ping 操作,响应是所有已启动并正在运行的 mini
我是一名优秀的程序员,十分优秀!