Resources
- General
- Compiled vs Interpreted : https://www.freecodecamp.org/news/compiled-versus-interpreted-languages/
- Garbage Collection : https://www.freecodecamp.org/news/a-guide-to-garbage-collection-in-programming/
- Variables
- Arrays
- Geeks4Geeks : https://www.geeksforgeeks.org/c/c-arrays/
- Programiz : https://www.programiz.com/c-programming/c-arrays
- Struct & Unions
- Memory
- Typedof : https://www.w3schools.com/c/c_typedef.php
- abs : https://www.w3schools.com/c/ref_stdlib_abs.php
- Pointer2Pointer : https://www.reddit.com/r/learnprogramming/comments/ipou54/i_dont_understand_double_pointers_in_c/ || https://www.geeksforgeeks.org/c/c-pointer-to-pointer-double-pointer/ || https://www.youtube.com/watch?v=Ie9ZByxYiG0
- FileDiscreptor : https://www.geeksforgeeks.org/c/input-output-system-calls-c-create-open-close-read-write/ || https://42-cursus.gitbook.io/guide/useful-tools/file-descriptors-fd
- stat&fstat : https://www.emblogic.com/blog/12/diffrence-between-statfstat-and-lstat/
- Multi Module : https://edshare.gcu.ac.uk/4002/2/index.html
- Base64 : https://blog.leonardotamiano.xyz/tech/base64/
My Database Learning Scripts
- DevPlayground : https://github.com/N1NJ10/Dev-Playground
Commands
- Mem Leak
- Vangrind
gcc -g Memory_Leaks.c -o leak_test valgrind --leak-check=full ./leak_test
- Vangrind
- Glibc
ldd ./myprogram - Manuals
man malloc - Tips & Tricks
mkdir -p tiny_implant/{src,include,lib,obj,bin} - Generating
- Manual
- Static
# Object Files gcc -I./include -Wall -c src/crypto.c -o obj/crypto.o gcc -I./include -Wall -c src/Base64.c -o obj/Base64.o # Creating Lib ar rcs lib/libcrypto.a obj/*.o # Making Final Move gcc -I./include -Wall src/main.c -o bin/implant -Llib -lcrypto ./bin/implant - Shared
mkdir -p obj lib bin gcc -I./include -Wall -fPIC -c src/Base64.c -o obj/Base64.o gcc -I./include -Wall -fPIC -c src/Base64.c -o obj/Base64.o gcc -shared -o lib/libcrypto.so obj/*.o gcc -I./include -Wall src/main.c -o bin/implant -Llib -lcrypto export LD_LIBRARY_PATH=./lib:$LD_LIBRARY_PATH ./bin/implant
- Static
- Make
- Tips & Tricks
- For Loop
for file in src/*.c; do if [ "$file" != "src/main.c" ]; then gcc -I./include -Wall -fPIC -c "$file" -o "obj/$(basename "$file" .c).o" fi done - Seeing exported Sympols
nm -D lib/libcrypto.so objdump -T lib/libcrypto.so # List exported Symplos only nm -D lib/libcrypto.so | grep ' T '
- For Loop
- Manual
Tools
- code2flow : https://app.code2flow.com/
- onlinegdb : https://www.onlinegdb.com/
- Valgrind : https://valgrind.org/
Notes
General
- Every variable must be declared before it is used.
- When the array is declared or allocated memory, the elements of the array contain
some garbage value- Arrays must has the
SameTypes of values.- If you run operations like strcpy, which copies data from the src buffer to the dest buffer. It will
ONLY STOP COPYING OR PRINTING IF IT ENCOUNTERS THAT ZERO BYTE.- Virtual memory creates the illusion of a large memory, even if the actual memory (RAM) is small.
- The size of the union will always be equal to the size of the largest member of the union
- Pointers
- Does the line start with int, char, or void? → Declaration (Noun).
- Does the line start with the variable name or logic? → Dereference (Verb).
- malloc only understands one thing:
bytes, If you ask for 100 bytes, and the system has 50 bytes free in one spot and 50 bytes free in another, malloc cannot combine them. It must find 100 bytes sitting right next to each other.
x.id = 10;: From variablex -> id = 10;: from Pointer (The Arrow (→) is only used for Structures)- File Descriptor
- 0: stdin - a file that represents the input to your program from the command line
- 1: stdout - a file that represents the output of your program to the command line
- 2: stderr - a file that represents the output of your program, but containing only errors
- In C, you never actually touch a file. The Linux kernel is fiercely protective of its hardware and memory. It trusts no user-space program. If your code wants to read a file, write to a disk, or open a network port, it must submit a request to the kernel.
- The true power of the file descriptor lies in the core philosophy of Unix: Everything is a file.
strlen: Computes the length of a string (the number of characters before the first null terminator \0).sizeof: Returns the size in bytes of its operand. It can be applied to types, expressions, or variables.- static (.a on Unix-like systems, .lib on Windows) and shared (.so on Linux, .dylib on macOS, .dll on Windows).
