#include <stdio.h>
#include <unistd.h>
#include <curl/curl.h>

#define PAYMENT_CHECK_LINK "http://87.65.76.191//payment-was-received"

const char* flag = "IGCTF{K1ds_w1ll_b3_k1ds}";

int check_payment_received() {
    CURL *curl;
    CURLcode res;

    curl = curl_easy_init();
    if (!curl) {
        printf("Error checking payment\n");
        return 0;
    }

    curl_easy_setopt(curl, CURLOPT_URL, PAYMENT_CHECK_LINK);
    curl_easy_setopt(curl, CURLOPT_FOLLOWLOCATION, 1L);
    curl_easy_setopt(curl, CURLOPT_TIMEOUT, 1);
    /* Perform the request, res will get the return code */ 
    res = curl_easy_perform(curl);

    int http_response_code;
    curl_easy_getinfo(curl, CURLINFO_RESPONSE_CODE, &http_response_code);
    
    if(res == CURLE_OK && http_response_code == 200) {
        /* Payment was received */
        return 1;
    }

    curl_easy_cleanup(curl);
    return 0;
}

void accept_payment()
{
    printf("Send all your precious bitcoins to: 1PWFNCXcUwKHX1WKuIi98ROEzq70NhJBN6\n");
    
    while (!check_payment_received()) {
        sleep(5);
        printf("Still no payment received\n");
    }

    printf("Thanks for you money loser, here is your key: %s\n", flag);
}

void welcome()
{
    printf("You have been PWNED by Scr1ptk1dd13!!!\n");
    printf("I encrypted all your files and you will never NEVER find the encryption key because this program is compiled and you cannot look into compiled programs moehhahahahahaha\n");
    printf("You need to pay me to get your flag back\n");
    accept_payment();
}

void main()
{
    welcome();
}