MCPcopy Create free account
hub / github.com/F12FLASH/CTF / main

Function main

4.Stackless Stack/public/downloads/stackless_stack.c:193–238  ·  view source on GitHub ↗

* @brief Main function - challenge entry point */

Source from the content-addressed store, hash-verified

191 * @brief Main function - challenge entry point
192 */
193int main(int argc, char *argv[]) {
194 memory_region_t *memory_region;
195
196 // Disable buffering for CTF environment
197 setvbuf(stdout, NULL, _IONBF, 0);
198 setvbuf(stdin, NULL, _IONBF, 0);
199 setvbuf(stderr, NULL, _IONBF, 0);
200
201 display_banner();
202 setup_environment();
203
204 // Allocate memory region using mmap
205 memory_region = (memory_region_t *)mmap(
206 NULL,
207 MMAP_SIZE,
208 PROT_READ | PROT_WRITE,
209 MAP_PRIVATE | MAP_ANONYMOUS,
210 -1,
211 0
212 );
213
214 if (memory_region == MAP_FAILED) {
215 perror("[-] mmap allocation failed");
216 return EXIT_FAILURE;
217 }
218
219 // Initialize memory region
220 memset(memory_region, 0, sizeof(memory_region_t));
221 memory_region->callback = process_data;
222 memory_region->magic = MAGIC_VALUE;
223
224 print_debug_info(memory_region);
225
226 // Display hints if requested
227 if (argc > 1 && strcmp(argv[1], "--hints") == 0) {
228 write(STDOUT_FILENO, HINTS, strlen(HINTS));
229 }
230
231 // Core vulnerability
232 vulnerable_function(memory_region);
233
234 write(STDOUT_FILENO, "[👋] Challenge completed - cleaning up...\n", 42);
235 cleanup(memory_region);
236
237 return EXIT_SUCCESS;
238}
239
240/* ===== Compilation Instructions ===== */
241/*

Callers

nothing calls this directly

Calls 5

display_bannerFunction · 0.85
setup_environmentFunction · 0.85
print_debug_infoFunction · 0.85
vulnerable_functionFunction · 0.85
cleanupFunction · 0.85

Tested by

no test coverage detected