With the update to Kernel 5.18.0-kali7-amd64 in Kali 2022.3 (2022 Kali Rolling release), GCC 12.2.0 no longer includes libraries required by older Linux Kernels. In order to compile C and C++ exploits that can be run on older generation targets (< Kernel 2.6), this is recommendation:
Use gcc with docker
dockerpullgcc:4.9# 4.9: Pulling from library/gcc# Digest: sha256:6356ef8b29cc3522527a85b6c58a28626744514bea87a10ff2bf67599a7474f5# Status: Image is up to date for gcc:4.9# docker.io/library/gcc:4.9# copy the exploit.c in the current directorydockerrun--rm-v"$PWD":/usr/src/myapp-w/usr/src/myappgcc:4.9
gcccode.c-oprogramname#if need 32 bitgcc-m32-Wl,--hash-style=bothexploit.c-oexploit# if error when execute binary./exploit:/lib/tls/libc.so.6:version`GLIBC_2.34' not found (required by ./exploit)# compile with docker
if you see this in c script it should compile with windows:
#include<windows.h>#pragmacomment(lib, "ws2_32")
# install migw32 firstsudoaptinstallgcc-mingw-w64
Compile the script
# compilei686-w64-mingw32-gcccode.c-oprogramname# if need lib use -li686-w64-mingw32-gcccode.c-oprogramname-l<libname># examplei686-w64-mingw32-gcccode.c-oprogramname-lws2_32