用户名和密码使用的字段类型_如果在“用户名”字段中提交密码,对安全有何影响?...

用户名和密码使用的字段类型

用户名和密码使用的字段类型

security-implications-if-a-password-is-submitted-in-the-username-field-00

Suppose you are having a bad day and in a hurry to login to a favorite website, then accidentally submit your password in the username text box instead. Should you be worried and change your password for that website, or is it just groundless fear?

假设您的日子不好过,急着要登录到喜欢的网站,然后在用户名文本框中意外地输入了密码。 您是否应该担心并更改该网站的密码,还是仅仅是出于毫无根据的恐惧?

Today’s Question & Answer session comes to us courtesy of SuperUser—a subdivision of Stack Exchange, a community-driven grouping of Q&A web sites.

今天的“问答”环节由SuperUser提供,它是Stack Exchange的一个分支,该社区是由社区驱动的Q&A网站分组。

问题 (The Question)

SuperUser reader agentnega wants to know what the dangers of typing one’s password into the username text box and accidentally submitting it could be:

超级用户阅读器agentnega想知道在用户名文本框中输入密码并意外提交的危险是:

Let’s say I typed my password into the username text box of a frequently-visited website (https of course) and hit enter before I noticed what I was doing.

假设我在经常访问的网站( 当然是https )的用户名文本框中输入密码然后按回车,直到我注意到自己在做什么。

Is my password now sitting in plain text in a log file somewhere? How could my mistake be exploited by a crafty miscreant? Help me understand the actual security implications regardless of the likelihood of it actually happening.

我的密码现在是否以纯文本格式保存在日志文件中的某个位置? 狡猾的罪犯如何利用我的错误? 帮助我了解实际的安全隐患,无论它实际发生的可能性如何。

Would this actually be something to be worried about, or could you look at this as a simple mistake and forget about it?

这实际上是值得担心的事情,还是您可以将其视为简单的错误而忘记呢?

答案 (The Answer)

SuperUser contributors Nikolay and GregD have the answer for us. First up, Nikolay:

超级用户贡献者Nikolay和GregD为我们找到了答案。 首先,尼古拉:

It depends on the configuration of the authentication system for the website. If it was setup to log any attempts, then yes, it is now in the log (text file or database) in plain text. It could look like this:

这取决于网站的身份验证系统的配置。 如果已设置为记录任何尝试,则可以,它现在以纯文本格式保存在日志( 文本文件或数据库 )中。 它可能看起来像这样:

12-Feb-2014 12:00:00 AM: Unsuccessful login attempt user (YOUR_PASSSORD_HERE) from (YOUR_IP_HERE);

2014年2月12日12:00:00:来自(YOUR_IP_HERE)的登录尝试用户(YOUR_PASSSORD_HERE)失败;

or similar.

或类似。

It is still true that a password will not be accessible for regular users, only for those who have access to log files.

仍然确实如此,普通用户将无法访问密码,只有有权访问日志文件的用户才能访问该密码。

What consequences does it imply?

这意味着什么后果?

  • If the server was ever compromised, then theoretically, the hacker would have your plain text password.

    如果服务器曾遭到破坏,那么从理论上讲,黑客将获得您的纯文本密码。
  • The website’s administrator could routinely go through the log files and accidentally find your password. He can then find the IP address this record came from, and thus he can theoretically find out what your username and e-mail are (because he has access to the database).

    网站的管理员可能会例行浏览日志文件并意外找到您的密码。 然后,他可以找到该记录的IP地址,因此从理论上讲,他可以找到您的用户名和电子邮件(因为他可以访问数据库)。

So, if you use the same e-mail/username/password on other websites, then change it immediately. Because there is always a chance that your password will be found out. Logs can remain on servers for years.

因此,如果您在其他网站上使用相同的电子邮件/用户名/密码,请立即进行更改。 因为总有可能会找到您的密码。 日志可以在服务器上保留多年。

Followed by the answer from GregD:

随后是GregD的答案:

Just as you said, web applications tend to keep logs of unsuccessful login attempts. If someone were to look through the logs, he could connect this particular login attempt with one of your successful attempts (i.e. via IP address).

就像您说的那样,Web应用程序倾向于保留登录尝试失败的日志。 如果有人要查看日志,则可以将该特定的登录尝试与您的成功尝试之一(例如, 通过IP地址 )联系起来。

Though I do not think this is likely to happen, you can always change it be sure.

尽管我认为这不太可能发生,但是您可以随时更改它。

With the constant barrage of data breaches we read and hear about these days, it would be better to change the password for the website in question (and any others with the same password) for peace of mind. It is better to be safe than sorry when it comes to the security of your online accounts!

鉴于我们近来不断听到和听到的数据泄露大抵,最好还是更改相关网站的密码( 以及任何其他使用相同密码的密码 ),以使您省心。 关于在线帐户的安全性,总比后悔好!



Have something to add to the explanation? Sound off in the comments. Want to read more answers from other tech-savvy Stack Exchange users? Check out the full discussion thread here.

有什么补充说明吗? 在评论中听起来不错。 是否想从其他精通Stack Exchange的用户那里获得更多答案? 在此处查看完整的讨论线程

翻译自: https://www.howtogeek.com/182950/what-are-the-security-implications-if-a-password-is-submitted-in-the-username-field/

用户名和密码使用的字段类型

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
要实现这个功能,需要进行以下步骤: 1. 建立数据库表,包括用户名密码两个字段。 2. 在注册页面,获取用户输入的用户名密码。 3. 在注册页面,对用户输入的信息进行合法性校验,例如判断用户名密码是否为空,是否符合规定的格式等。 4. 在注册页面,连接数据库,查询用户名是否已经存在。 5. 如果用户名不存在,将用户名密码插入到数据库。 下面是一个简单的 JavaWeb 注册代码示例: ```java package com.example; import java.io.IOException; import java.io.PrintWriter; import java.sql.Connection; import java.sql.DriverManager; import java.sql.PreparedStatement; import java.sql.ResultSet; import java.sql.SQLException; import javax.servlet.ServletException; import javax.servlet.http.HttpServlet; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; public class RegisterServlet extends HttpServlet { private static final long serialVersionUID = 1L; protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { String username = request.getParameter("username"); String password = request.getParameter("password"); response.setContentType("text/html;charset=UTF-8"); PrintWriter out = response.getWriter(); Connection conn = null; PreparedStatement pstmt = null; ResultSet rs = null; try { // 加载数据库驱动 Class.forName("com.mysql.jdbc.Driver"); // 获取数据库连接 conn = DriverManager.getConnection("jdbc:mysql://localhost:3306/test", "root", "password"); // 查询用户名是否已经存在 pstmt = conn.prepareStatement("SELECT * FROM user WHERE username=?"); pstmt.setString(1, username); rs = pstmt.executeQuery(); if (rs.next()) { out.println("用户名已经存在,请重新输入!"); } else { // 将新用户插入到数据库 pstmt = conn.prepareStatement("INSERT INTO user (username, password) VALUES (?, ?)"); pstmt.setString(1, username); pstmt.setString(2, password); pstmt.executeUpdate(); out.println("注册成功!"); } } catch (ClassNotFoundException e) { e.printStackTrace(); } catch (SQLException e) { e.printStackTrace(); } finally { // 关闭数据库连接 try { if (rs != null) { rs.close(); } if (pstmt != null) { pstmt.close(); } if (conn != null) { conn.close(); } } catch (SQLException e) { e.printStackTrace(); } } } } ``` 在这个代码,我们首先获取用户输入的用户名密码,然后连接数据库,查询用户名是否已经存在,如果不存在,则将新用户插入到数据库。在最后,我们关闭数据库连接。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值