Was curious.. Still.. not sure you want to go down the road of spying..
CurlSocket.hpp:
/** © 2014, Brandon T. All Rights Reserved.
*
* It is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* It is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with it. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef CURLSOCKET_HPP_INCLUDED
#define CURLSOCKET_HPP_INCLUDED
#include <curl/curl.h>
#include <string>
#include <cstring>
#include <cstdio>
#include <cstdlib>
class CurlSocket
{
private:
CURL *curl_handle;
std::string params;
struct MemoryStruct{char *memory; std::size_t size;};
struct MemoryStruct data;
static std::size_t WriteBuffer(void *contents, std::size_t size, std::size_t nmemb, void *userp);
public:
CurlSocket();
~CurlSocket();
operator CURL*() {return curl_handle;}
void SetURLFollow(bool follow);
void SetSSL(bool VerifyPeer, bool VerifyHost);
void SetCookies(const char* CookieJar, const char* CookieFile);
void SetURL(const char* URL);
void ClearParams();
void AddParam(const char* Param, const char* Value, bool Escape = false);
std::string DoGet();
std::string DoPost();
};
#endif // CURLSOCKET_HPP_INCLUDED
CurlSocket.cpp:
/** © 2014, Brandon T. All Rights Reserved.
*
* It is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* It is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with it. If not, see <http://www.gnu.org/licenses/>.
*/
#include "CurlSocket.hpp"
CurlSocket::CurlSocket() : curl_handle(nullptr), params(), data {0}
{
curl_global_init(CURL_GLOBAL_ALL);
curl_handle = curl_easy_init();
if (curl_handle)
{
curl_easy_setopt(curl_handle, CURLOPT_FAILONERROR, true);
curl_easy_setopt(curl_handle, CURLOPT_USERAGENT, "Mozilla/5.0 (Windows NT 6.2; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/32.0.1667.0 Safari/537.36");
curl_easy_setopt(curl_handle, CURLOPT_WRITEFUNCTION, WriteBuffer);
curl_easy_setopt(curl_handle, CURLOPT_WRITEDATA, &data);
curl_easy_setopt(curl_handle, CURLOPT_AUTOREFERER, 1L);
}
}
CurlSocket::~CurlSocket()
{
curl_easy_cleanup(curl_handle);
curl_global_cleanup();
curl_handle = nullptr;
}
std::size_t CurlSocket::WriteBuffer(void *contents, std::size_t size, std::size_t nmemb, void *userp)
{
std::size_t realsize = size * nmemb;
struct MemoryStruct *mem = static_cast<struct MemoryStruct *>(userp);
mem->memory = static_cast<char *>(realloc(mem->memory, mem->size + realsize + 1));
if (mem->memory == NULL)
{
printf("Cannot Allocated Enough Memory (ReAlloc is NULL).\n");
exit(EXIT_FAILURE);
}
memcpy(&(mem->memory[mem->size]), contents, realsize);
mem->size += realsize;
mem->memory[mem->size] = 0;
return realsize;
}
void CurlSocket::SetURLFollow(bool follow)
{
curl_easy_setopt(curl_handle, CURLOPT_FOLLOWLOCATION, follow);
}
void CurlSocket::SetSSL(bool VerifyPeer, bool VerifyHost)
{
curl_easy_setopt(curl_handle, CURLOPT_SSL_VERIFYPEER, VerifyPeer ? 2L : 0L);
curl_easy_setopt(curl_handle, CURLOPT_SSL_VERIFYHOST, VerifyHost ? 2L : 0L);
}
void CurlSocket::SetCookies(const char *CookieJar, const char *CookieFile)
{
curl_easy_setopt(curl_handle, CURLOPT_COOKIEJAR, CookieJar);
curl_easy_setopt(curl_handle, CURLOPT_COOKIEFILE, CookieFile);
}
void CurlSocket::SetURL(const char *URL)
{
curl_easy_setopt(curl_handle, CURLOPT_URL, URL);
}
void CurlSocket::ClearParams()
{
params.clear();
curl_easy_setopt(curl_handle, CURLOPT_POSTFIELDS, nullptr);
}
void CurlSocket::AddParam(const char *Param, const char* Value, bool Escape)
{
if (Param && Value && strlen(Param) && strlen(Value))
{
if (!params.empty())
{
params += "&";
}
params += Param;
params += "=";
params += Escape ? curl_easy_escape(curl_handle, Value, 0) : Value;
}
}
std::string CurlSocket::DoGet()
{
curl_easy_setopt(curl_handle, CURLOPT_POST, 0L);
CURLcode res = curl_easy_perform(curl_handle);
if (res != CURLE_OK)
{
printf("%s\n", curl_easy_strerror(res));
}
if (data.memory)
{
std::string result = data.memory;
delete data.memory;
data.memory = nullptr;
data.size = 0;
return result;
}
return std::string();
}
std::string CurlSocket::DoPost()
{
curl_easy_setopt(curl_handle, CURLOPT_POST, 1L);
curl_easy_setopt(curl_handle, CURLOPT_POSTFIELDS, params.c_str());
CURLcode res = curl_easy_perform(curl_handle);
curl_easy_setopt(curl_handle, CURLOPT_POST, 0L);
if (res != CURLE_OK)
{
printf("%s\n", curl_easy_strerror(res));
}
if (data.memory)
{
std::string result = data.memory;
delete data.memory;
data.memory = nullptr;
data.size = 0;
return result;
}
return std::string();
}
Main.cpp:
#include <iostream>
#include <fstream>
#include "CurlSocket.hpp"
std::string HtmlDecode(std::string str)
{
std::string subs[] = {"& #34;", """, "& #39;", "'", "& #38;", "&",
"& #60;", "<", "& #62;", ">", "&34;", "&39;", "&38;", "&60;", "&62;"
};
std::string reps[] = {"\"", "\"", "'", "'", "&", "&", "<", "<", ">", ">", "\"",
"'", "&", "<", ">"
};
std::size_t found = 0;
for(int i = 0; i < 15; i++)
{
do
{
found = str.find(subs[i]);
if (found != std::string::npos)
str.replace (found, subs[i].length(), reps[i]);
}
while (found != std::string::npos);
}
return str;
}
int main()
{
CurlSocket sock;
sock.AddParam("email", "mehwtfbleh@hotmail.com");
sock.AddParam("pass", "***Fake***");
sock.SetCookies("Cookies.dat", "Cookies.dat");
sock.SetSSL(false, true);
sock.SetURLFollow(true);
//https://m.facebook.com/
sock.SetURL("https://www.facebook.com/dialog/oauth?client_id=0x1024&redirect_uri=https%3A%2F%2Fwww.facebook.com%2Fconnect%2Flogin_success.html");
sock.DoPost();
sock.SetURL("https://www.facebook.com/profile.php?id=************&ref=tn_tnmn");
std::string res = sock.DoGet();
std::fstream file("C:/Users/Brandon/Desktop/Facebook.html", std::ios::out);
if (file.is_open())
{
file << res;
file.close();
}
return 0;
It logs in and everything. You just need to send the cookie with every request and monitor the chat.. Not too hard. Just tedious. Takes time to find what to send and request :l
It is probably a better idea to just make a C# window-less program with a web-view control and monitor the chat with that. Way easier than trying to use a C or C++ service. Though more powerful, it's more tedious to write. It's more than doable in C#. It's very easy in any language if you know what you're doing..
Another option is to use a socket on the mobile link:
https://m.facebook.com/ and this still requires the code above. It is no different at all. Either way, the code above should get you started. It logs in and works. You just need to monitor the messages now :l

I feel bad for helping with this.. ={