Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add a change password option to xiloader. #30

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
62 changes: 59 additions & 3 deletions xiloader/network.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -227,16 +227,19 @@ namespace xiloader
xiloader::console::output("What would you like to do?");
xiloader::console::output(" 1.) Login");
xiloader::console::output(" 2.) Create New Account");
xiloader::console::output(" 3.) Change Account Password");
xiloader::console::output("==========================================================");
printf("\nEnter a selection: ");

std::string input;
std::cin >> input;
std::cout << std::endl;

/* User wants to log into an existing account.. */
if (input == "1")
/* User wants to log into an existing account or modify an existing account's password. */
if (input == "1" || input == "3")
{
if (input == "3")
xiloader::console::output("Before resetting your password, first verify your account details.");
xiloader::console::output("Please enter your login information.");
std::cout << "\nUsername: ";
std::cin >> g_Username;
Expand Down Expand Up @@ -265,7 +268,8 @@ namespace xiloader
}
std::cout << std::endl;

sendBuffer[0x20] = 0x10;
char event_code = (input == "1") ? 0x10 : 0x30;
sendBuffer[0x20] = event_code;
}
/* User wants to create a new account.. */
else if (input == "2")
Expand All @@ -275,6 +279,7 @@ namespace xiloader
std::cout << "\nUsername (3-15 characters): ";
std::cin >> g_Username;
std::cout << "Password (6-15 characters): ";
g_Password.clear();
std::cin >> g_Password;
std::cout << "Repeat Password : ";
std::cin >> input;
Expand Down Expand Up @@ -333,6 +338,57 @@ namespace xiloader
closesocket(sock->s);
sock->s = INVALID_SOCKET;
return false;

case 0x0005: // Request for updated password to change to.
{
xiloader::console::output(xiloader::color::success, "Log in verified for user %s.", g_Username.c_str());
std::string confirmed_password = "";
do
{
std::cout << "Enter new password (6-15 characters): ";
g_Password.clear();
std::cin >> g_Password;
std::cout << "Repeat Password : ";
std::cin >> confirmed_password;
std::cout << std::endl;

if (g_Password != confirmed_password)
{
xiloader::console::output(xiloader::color::error, "Passwords did not match! Please try again.");
}
} while (g_Password != confirmed_password);

/* Clear the buffers */
memset(sendBuffer, 0, 33);
memset(recvBuffer, 0, 16);

/* Copy the new password into the buffer. */
memcpy(sendBuffer, g_Password.c_str(), 16);

/* Send info to server and obtain response.. */
send(sock->s, sendBuffer, 16, 0);
recv(sock->s, recvBuffer, 16, 0);

/* Handle the final result. */
switch (recvBuffer[0])
{
case 0x0006: // Success (Changed Password)
xiloader::console::output(xiloader::color::success, "Password updated successfully!");
std::cout << std::endl;
g_Password.clear();
closesocket(sock->s);
sock->s = INVALID_SOCKET;
return false;

case 0x0007: // Error (Changed Password)
xiloader::console::output(xiloader::color::error, "Failed to change password.");
std::cout << std::endl;
g_Password.clear();
closesocket(sock->s);
sock->s = INVALID_SOCKET;
return false;
}
}
}

/* We should not get here.. */
Expand Down