Java 密码破解

Java 密码破解,java,c++,c,Java,C++,C,我有两个文件,一个用户名列表和一个密码列表。我需要写一个程序来检查每个用户名和密码列表。然后我需要去一个网站,看看它是否登录。我不太清楚如何进行比较,以及如何模拟程序登录网站输入信息。你能帮我解决这个问题吗?这是一个家庭作业问题。无论您选择哪种语言来实现这一点,基本思想都是以编程方式模拟登录。这可以通过手动登录并查看HTTP头来完成,然后通过编程发送“伪造”头,更改用户/密码字段 大多数登录都会使用POST,而制作POST并不完全简单。如果允许您使用外部库,您可以尝试。只需设置适当的标题并查看响

我有两个文件,一个用户名列表和一个密码列表。我需要写一个程序来检查每个用户名和密码列表。然后我需要去一个网站,看看它是否登录。我不太清楚如何进行比较,以及如何模拟程序登录网站输入信息。你能帮我解决这个问题吗?这是一个家庭作业问题。

无论您选择哪种语言来实现这一点,基本思想都是以编程方式模拟登录。这可以通过手动登录并查看HTTP头来完成,然后通过编程发送“伪造”头,更改用户/密码字段

大多数登录都会使用POST,而制作POST并不完全简单。如果允许您使用外部库,您可以尝试。只需设置适当的标题并查看响应,以检查您的尝试是否成功。如果没有,请使用新组合重试

在伪代码中:

bool simulate_login(user, password) :
    request = new request(url)
    request.set_method('POST')
    request.set_header('name', user)
    request.set_header('pass', password)

    response = request.fetch_reponse()
    return response.contains("Login successful")

success = []

foreach user:
    foreach password:
        if (simulate_login(user, password)):
            success.append((user, password))
            break

如果您想使用java,可以尝试使用HtmlUnit(请参阅:),或者如果允许使用Groovy,也可以使用它

以下是《入门指南》中与您的案例相关的示例:

public void login() throws Exception {
    final WebClient webClient = new WebClient();

    // Get the first page
    final HtmlPage page1 = webClient.getPage("http://some_url");

    // Get the form that we are dealing with and within that form, 
    // find the submit button and the field that we want to change.
    final HtmlForm form = page1.getFormByName("myform");

    final HtmlSubmitInput button = form.getInputByName("submitbutton");
    final HtmlTextInput textField = form.getInputByName("userid");

    // Change the value of the text field
    textField.setValueAttribute("username");
    // Do similar for password and that's all

    // Now submit the form by clicking the button and get back the second page.
    final HtmlPage page2 = button.click();

    webClient.closeAllWindows();
}

如果您想使用java,可以尝试使用HtmlUnit(请参阅:),或者如果允许使用Groovy,也可以使用它

以下是《入门指南》中与您的案例相关的示例:

public void login() throws Exception {
    final WebClient webClient = new WebClient();

    // Get the first page
    final HtmlPage page1 = webClient.getPage("http://some_url");

    // Get the form that we are dealing with and within that form, 
    // find the submit button and the field that we want to change.
    final HtmlForm form = page1.getFormByName("myform");

    final HtmlSubmitInput button = form.getInputByName("submitbutton");
    final HtmlTextInput textField = form.getInputByName("userid");

    // Change the value of the text field
    textField.setValueAttribute("username");
    // Do similar for password and that's all

    // Now submit the form by clicking the button and get back the second page.
    final HtmlPage page2 = button.click();

    webClient.closeAllWindows();
}
public void login()引发异常{ 最终WebClient WebClient=新WebClient()

  • 列表项

  • “java”、“C++”和“C”标记是否意味着你可以实现这些?你会具体检查每个用户名是否对密码进行检查?或者登录到你所指的检查中?我不确定使用什么…登录登录!它是由我的TA创建的网站。我们应该登录到THOST中。你需要比较用户名和密码吗?你的意思是你必须将每个用户名和每个密码结合起来才能尝试登录吗?我不太确定如何使用cURL?如何使用它进行检查?@Priya检查我在回答中提供的链接非常感谢,这很有帮助:)@Priya NullUserException暗示了这一点,但你可能希望使用双ch检查你的课堂笔记,确保他们没有建议一个用于访问网站的库或方法。cURL可以很好地完成这项工作,但给出一个指导性很小的作业似乎很奇怪。