DarkPC Security Lab — Part 1: Compiling Proof-of-Concept Code on Slackware
Category: Networking & Security · Platform: Slackware 15.0 / Linux · Level: Beginner–intermediate · Updated: 6 November 2026
Scope: Only experiment on programs and machines you own or are explicitly authorised to test. This guide demonstrates defects in two tiny programs created for the lab. It does not use real-world exploit kits, public targets, privilege-escalation payloads, or shellcode.
Ever seen a snippet of C code described as a proof of concept or “PoC” and wondered how researchers compile and study it? This DarkPC lab starts with the basics: read the source, compile it with GCC, reproduce a harmless failure, and understand the repair. Then we examine a toy HTTP service to see what a remote security issue looks like.
1. Local versus remote vulnerabilities
A local vulnerability is reached by someone already able to run or interact with a program on the machine. A remote vulnerability can be reached across a network, often through a listening service. Neither word tells you how severe a flaw is: authentication, configuration, exposure and impact all matter.
A proof of concept is a focused demonstration that a weakness exists. A PoC can be a test input, not necessarily a program that gives an attacker control. Our local example demonstrates a memory-safety failure; our remote-style example demonstrates an access-control mistake.
2. Prepare a separate lab
Use a spare VM if possible; a snapshot lets you restore it quickly. The examples below work as an ordinary user and should never be run as root. Our HTTP service binds only to the loopback address (127.0.0.1), so it is not exposed to your home LAN.
mkdir -p ~/darkpc-security-lab
cd ~/darkpc-security-lab
gcc --version
python3 --version
For Slackware 15.0, GCC is supplied in the d/ development package series. If gcc is missing, check your Slackware installation/package selection rather than downloading an unknown compiler binary.
Before compiling code from anywhere else: open and read it (less file.c), check its source and licence, consider unexpected process launches, network connections and file writes, and use a disposable VM. A successful gcc command does not mean a source file is safe.
3. Build a deliberately vulnerable local program
Save the following as local-demo.c (also supplied in this download):
#include <stdio.h>
#include <string.h>
int main(int argc, char **argv) {
char message[16];
if (argc != 2) {
fprintf(stderr, "Usage: %s <message>\n", argv[0]);
return 1;
}
/* Deliberate bug: no size check. */
strcpy(message, argv[1]);
printf("Message: %s\n", message);
return 0;
}
Compile with debug symbols and AddressSanitizer, a diagnostic tool that helps identify invalid memory accesses:
gcc -Wall -Wextra -O0 -g -fsanitize=address \
-fno-omit-frame-pointer local-demo.c -o local-demo
./local-demo HELLO
The short input should print Message: HELLO. Now supply a longer test string, still inside your disposable local lab:
./local-demo AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
Expect an AddressSanitizer diagnostic mentioning a stack-buffer-overflow and a non-zero exit, although its precise wording varies by compiler and system. This is a controlled failure, not a command-execution exploit. strcpy is dangerous here because the source can exceed the 16-byte destination array.
4. Repair the local program
Save this as local-fixed.c:
#include <stdio.h>
#include <string.h>
int main(int argc, char **argv) {
char message[16];
if (argc != 2) {
fprintf(stderr, "Usage: %s <message>\n", argv[0]);
return 1;
}
if (strlen(argv[1]) >= sizeof(message)) {
fprintf(stderr, "Input too long (maximum 15 characters).\n");
return 1;
}
memcpy(message, argv[1], strlen(argv[1]) + 1);
printf("Message: %s\n", message);
return 0;
}
gcc -Wall -Wextra -O0 -g -fsanitize=address \
-fno-omit-frame-pointer local-fixed.c -o local-fixed
./local-fixed HELLO
./local-fixed AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
Now the long input should be rejected with a clear message instead of writing past the array. That is the lesson: demonstrate, diagnose, fix, retest.
5. A remote-style issue, safely on localhost
A network service may listen for requests and accidentally grant access to something that should require authorisation. The included lab-server.py is an intentionally tiny HTTP server. It serves only invented text, has no filesystem operations or actual admin functionality, and listens on 127.0.0.1:8765.
Copy lab-server.py into your lab folder, then open Terminal 1:
python3 lab-server.py
In Terminal 2:
curl -i http://127.0.0.1:8765/
curl -i http://127.0.0.1:8765/admin
The second request returns HTTP 200 even though no token was supplied. That is the intentionally flawed access-control rule. No actual account or data has been accessed.
Stop the server with Ctrl+C, then launch the corrected mode:
LAB_FIXED=1 python3 lab-server.py
Again, in another terminal:
curl -i http://127.0.0.1:8765/admin
curl -i -H 'X-Lab-Token: practice-only' \
http://127.0.0.1:8765/admin
The unauthorised request should now return HTTP 403. The second request returns 200 because it presents the hard-coded lab-only token. This is a teaching shortcut, not production authentication: real applications need proper session management, secure credential storage, transport protection, rate limiting and server-side authorisation checks.
6. A useful workflow for studying PoCs
- Identify the target and prerequisites. Which product, versions, OS and permissions are relevant?
- Inspect the code and provenance. Do not blindly execute source copied from a forum or archive.
- Isolate the test. Prefer a VM with no sensitive data and a host-only network.
- Compile with diagnostics. Use warning flags, debug symbols and sanitizers where suitable.
- Observe the minimum harmless proof. Log the result without trying to gain access to anything else.
- Apply the fix and repeat. A good security write-up shows the vulnerable and corrected behaviour.
7. Troubleshooting
gcc: command not found: install/check Slackware's GCC development package.AddressSanitizermissing: check GCC's sanitizer runtime package on your system; do not disable safeguards merely to force the demo.curl: command not found: install/check the standard curl package or use a browser for the localhost requests.Address already in use: something is using port 8765. Stop the earlier lab server before restarting.- The demo is still accessible from another computer: that should not happen with the supplied loopback binding. Check that the server was not modified to listen on all interfaces.
Next: Part 2 — Discovering Open Ports with Nmap. Learn how to identify listening services on your own machines and understand what a port scan does—and does not—prove.
References
Keep exploring: Part 2: Nmap.