Skip to content

Instantly share code, notes, and snippets.

View ammarfaizi2's full-sized avatar
๐Ÿ€
Baby Opossum Posse

Ammar Faizi ammarfaizi2

๐Ÿ€
Baby Opossum Posse
View GitHub Profile
[ 0.000000] Linux version 6.16.0-afh2-dbg-2025-08-09-gb622ab28bcac (root@integral2) (gcc (Ubuntu 13.1.0-8ubuntu1~22.04) 13.1.0, GNU ld (GNU Binutils for Ubuntu) 2.38) #13 SMP PREEMPT_DYNAMIC Sat Aug 9 21:58:33 WIB 2025
[ 0.000000] Command line: BOOT_IMAGE=/vmlinuz-6.16.0-afh2-dbg-2025-08-09-gb622ab28bcac root=UUID=a7386d4a-a4f6-4515-b15b-e2d009f9b9a9 ro rootflags=subvol=@ mitigations=off pti=off log_buf_len=32M apparmor=0 default_hugepagesz=2M hugepagesz=1G hugepages=3
[ 0.000000] KERNEL supported cpus:
[ 0.000000] Intel GenuineIntel
[ 0.000000] AMD AuthenticAMD
[ 0.000000] Hygon HygonGenuine
[ 0.000000] Centaur CentaurHauls
[ 0.000000] zhaoxin Shanghai
[ 0.000000] x86/split lock detection: #AC: crashing the kernel on kernel split_locks and warning on user-space split_locks
[ 0.000000] BIOS-provided physical RAM map:
// gcc -Wall -ggdb3 -Wextra -Os stress.c -o stress
// ./stress ::1 1111 20000
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
#include <sys/types.h>
#include <sys/socket.h>
#include <netinet/in.h>
#include <arpa/inet.h>
1) Soft advance to reduce the number of memmove() calls.
2) Fully buffered stdio, reduce the number of write() syscalls.
diff --git a/http_logger_old.c b/http_logger.c
index 7d75a0ee5a2f..6ab4affb1ee2 100644
--- a/http_logger_old.c
+++ b/http_logger.c
@@ -1687,6 +1687,7 @@ struct buf {
uint64_t cap;
diff --git a/http_logger_old.c b/http_logger.c
index 7d75a0ee5a2f..a60c4b98c9f7 100644
--- a/http_logger_old.c
+++ b/http_logger.c
@@ -1687,6 +1687,7 @@ struct buf {
uint64_t cap;
uint64_t len;
char *buf;
+ char *orig_buf;
};
// SPDX-License-Identifier: GPL-2.0-only
/*
* Copyright (C) 2025 Ammar Faizi <[email protected]>
*
* http_logger.c - HTTP logger via LD_PRELOAD.
*
* gcc -Wall -Wextra -fpic -fPIC -Os http_logger.c -o /tmp/http_logger.so;
* export LD_PRELOAD=/tmp/http_logger.so;
* export GWNET_HTTP_LOG_FILE=/tmp/http.log;
* bash -c 'for i in {1..1000000}; do printf "POST /aaa HTTP/1.1\r\nHost: test.local\r\nTransfer-Encoding: chunked\r\n\r\n5\r\nabcde\r\n0\r\n\r\n"; done | nc 127.0.0.1 8080';
// SPDX-License-Identifier: GPL-2.0-only
/*
* gwnet_http1.c - HTTP/1.0 and HTTP/1.1 parser.
*
* Copyright (C) 2025 Ammar Faizi <[email protected]>
*/
#include <stdio.h>
#include <errno.h>
#include <stdarg.h>
#include <stdlib.h>
// SPDX-License-Identifier: GPL-2.0-only
/*
* Author: Ammar Faizi <[email protected]>
*/
#ifndef _GNU_SOURCE
#define _GNU_SOURCE
#endif
#ifndef PM_USE_TCP
#include <stdio.h>
#include <stdlib.h>
#include <assert.h>
#include <errno.h>
static FILE *log_file = NULL;
static void init_log(void)
{
const char *log_path;
.section .rodata
msg_enter_pwd:
.string "Enter password: "
msg_pwd_wrong:
.string "Sorry, wrong password!"
msg_pwd_ok:
.string "\nPassword OK!"
msg_fmt_flag:
.string "Congratulations, you solved it!\nThe flag is: %s\n"