diff options
-rw-r--r-- | protocols/FacebookRM/src/communication.cpp | 34 | ||||
-rw-r--r-- | protocols/FacebookRM/src/version.h | 4 | ||||
-rw-r--r-- | utils/std_string_utils.cpp | 7 | ||||
-rw-r--r-- | utils/std_string_utils.h | 2 |
4 files changed, 30 insertions, 17 deletions
diff --git a/protocols/FacebookRM/src/communication.cpp b/protocols/FacebookRM/src/communication.cpp index 703378120b..892840f966 100644 --- a/protocols/FacebookRM/src/communication.cpp +++ b/protocols/FacebookRM/src/communication.cpp @@ -286,7 +286,13 @@ std::string facebook_client::choose_action(RequestType request_type, std::string switch (request_type) { case REQUEST_LOGIN: - return "/login.php?login_attempt=1"; + { + std::string action = "/login.php?login_attempt=1"; + if (get_data != NULL) { + action += *get_data; + } + return action; + } case REQUEST_SETUP_MACHINE: return "/checkpoint/?next"; @@ -767,6 +773,13 @@ bool facebook_client::login(const char *username, const char *password) username_ = username; password_ = password; + // Prepare login data + std::string data = "persistent=1"; + data += "&email=" + utils::url::encode(username); + data += "&pass=" + utils::url::encode(password); + + std::string get_data = ""; + if (cookies.empty()) { // Set device ID ptrA device(parent->getStringA(FACEBOOK_KEY_DEVICE_ID)); @@ -779,15 +792,17 @@ bool facebook_client::login(const char *username, const char *password) // Also parse cookies set by JavaScript (more variant exists in time, so check all known now) parseJsCookies("[\"DeferredCookie\",\"addToQueue\",[],[\"", resp.data, cookies); parseJsCookies("[\"Cookie\",\"setIfFirstPartyContext\",[],[\"", resp.data, cookies); - } - // Prepare login data - std::string data = "persistent=1"; - data += "&email=" + utils::url::encode(username); - data += "&pass=" + utils::url::encode(password); + // Parse hidden inputs and other data + std::string form = utils::text::source_get_value(&resp.data, 2, "<form", "</form>"); + utils::text::replace_all(&form, "\\\"", "\""); + + data += "&" + utils::text::source_get_form_data(&form, true); + get_data += "&" + utils::text::source_get_value(&form, 2, "login.php?login_attempt=1&", "\""); + } // Send validation - http::response resp = flap(REQUEST_LOGIN, &data); + http::response resp = flap(REQUEST_LOGIN, &data, &get_data); // Save Device ID if (!cookies["datr"].empty()) @@ -900,10 +915,7 @@ bool facebook_client::login(const char *username, const char *password) } // Get and notify error message - std::string error = utils::text::source_get_value(&resp.data, 4, "login_error_box", "<div", ">", "</div>"); - if (error.empty()) - error = utils::text::source_get_value(&resp.data, 4, "<form", "<strong", ">", "</strong>"); - + std::string error = utils::text::slashu_to_utf8(utils::text::source_get_value(&resp.data, 3, "[\"LoginFormError\"", "\"__html\":\"", "\"}")); loginError(parent, error); } case HTTP_CODE_FORBIDDEN: // Forbidden diff --git a/protocols/FacebookRM/src/version.h b/protocols/FacebookRM/src/version.h index dc809ef68e..60620dffc4 100644 --- a/protocols/FacebookRM/src/version.h +++ b/protocols/FacebookRM/src/version.h @@ -1,7 +1,7 @@ #define __MAJOR_VERSION 0 #define __MINOR_VERSION 2 -#define __RELEASE_NUM 11 -#define __BUILD_NUM 8 +#define __RELEASE_NUM 12 +#define __BUILD_NUM 0 #include <stdver.h> diff --git a/utils/std_string_utils.cpp b/utils/std_string_utils.cpp index 35038977d9..a824ef87eb 100644 --- a/utils/std_string_utils.cpp +++ b/utils/std_string_utils.cpp @@ -428,12 +428,13 @@ std::string utils::text::source_get_value2(std::string* data, const char *term, return ret;
}
-std::string utils::text::source_get_form_data(std::string* data)
+std::string utils::text::source_get_form_data(std::string* data, boolean hiddenOnly)
{
+ const char *search = hiddenOnly ? "<input type=\"hidden\"" : "<input";
std::string values;
std::string::size_type start = 0;
- start = data->find("<input", start);
+ start = data->find(search, start);
while (start != std::string::npos) {
start++;
std::string attr, value;
@@ -461,7 +462,7 @@ std::string utils::text::source_get_form_data(std::string* data) values += "&";
values += attr + "=" + value;
}
- start = data->find("<input", start);
+ start = data->find(search, start);
}
return values;
diff --git a/utils/std_string_utils.h b/utils/std_string_utils.h index 387d8f1fc6..4aec3cb574 100644 --- a/utils/std_string_utils.h +++ b/utils/std_string_utils.h @@ -72,7 +72,7 @@ namespace utils std::string trim(const std::string &data, bool rtrim = false);
std::string source_get_value(std::string* data, unsigned int argument_count, ...);
std::string source_get_value2(std::string* data, const char *term, const char *endings, bool wholeString = false);
- std::string source_get_form_data(std::string* data);
+ std::string source_get_form_data(std::string* data, boolean hiddenOnly = false);
std::string rand_string(int len, const char *chars = "0123456789" "ABCDEFGHIJKLMNOPQRSTUVWXYZ" "abcdefghijklmnopqrstuvwxyz", unsigned int *number = NULL);
void explode(std::string str, const std::string &separator, std::vector<std::string>* results);
void append_ordinal(unsigned long value, std::string* data);
|