Warranty void if you fiddle with LD_PRELOAD or LD_LIBRARY_PATH.
Moves the value “1” into the EAX register
MOV EAX, 1
- jumps to and address in memory
- in this case the hex address is 0xDEADBEEF
JMP 0xDEADBEEF
- PUSH [register]
- POP [register]
- CALL [function]
- RET
- assembly = machine instructions
- C is higher level language which gets translated into assembly by the compiler
- key point
- assembly language tells the computer exactly what to do and exactly HOW to do it
- C or C++
- will say “allocate memory” or “perform addition”
x += 1;
- Assembly
- will say “put the byte from this address in memory into
MOV EAX, x
ADD EAX, 1
this register” or “jump to this location in memory”
- definition
- extremely high-performance memory located directly on the chip
- EAX, EBX, ECX, EDX
- Used for performing operations on data
- ESP: Stack pointer, points to the top of the stack. Manipulated by PUSH, POP, etc
- EBP: Base pointer aka frame pointer.
- ESI and EDI: ESI = source instruction, EDI = destination instruction.
echo '_Bool a;' | gcc -c -x c - echo $?
- Compile flags
-g3 -O0
fprintf(stderr, "CHECKPOINT REACHED @ %s:%i\n", __FILE__, __LINE__);
#include <stdio.h>
#include <string.h>
#include <unistd.h>
int main ()
{
int i;
char file[1024];
for (i = 0; i < 2048; ++i) {
sprintf(file, "files/%d.txt", i);
fopen (file, "w+");
}
sleep (60);
return 0;
}
#include <unistd.h>
int main(int argc, char *argv[])
{
char file[] = "/home/oleg/.nix-profile/bin/nix-shell";
char *const envp[] = { "HOME=/home/oleg", NULL };
int result = execve(file, argv, envp);
return result;
}
#include <sys/types.h>
#include <sys/time.h>
#include <stdio.h>
#include <fcntl.h>
#include <sys/ioctl.h>
#include <unistd.h>
#include <stdlib.h>
int main()
{
char buffer[128];
int result, nread;
fd_set inputs, testfds;
struct timeval timeout;
FD_ZERO(&inputs);
FD_SET(0, &inputs);
while(1) {
testfds = inputs;
timeout.tv_sec = 2;
timeout.tv_usec = 500000;
result = select(FD_SETSIZE, &testfds, (fd_set *)NULL,
(fd_set*)NULL, &timeout);
switch(result)
{
case 0:
printf("timeout\n");
break;
case -1:
perror("select");
exit(1);
default:
if (FD_ISSET(0, &testfds))
{
ioctl(0, FIONREAD, &nread);
if (nread == 0) {
printf("keyboard done\n");
exit(0);
}
nread = read(0, buffer, nread);
buffer[nread] = 0;
printf("read %d from keyboard: %s\n", nread, buffer);
}
break;
}
}
}
- large pool of operating system memory
- used in dynamic memory allocation
- the
new
keyword in C++ - the
malloc
in C
int * myArray = new int 10;
- HVML/PurC: The prime HVML interpreter for C Language.
- never-lang/never: Never: statically typed, embeddable functional programming language.
- ThakeeNathees/pocketlang: A lightweight, fast embeddable scripting language.
- (45) why do header files even exist? - YouTube
- (45) why do void pointers even exist? - YouTube
- elhajuojy/C-Programming-Guide: Guide to C Programming langauge for me and for all of us 📁
- jserv/shecc: A self-hosting and educational C compiler
- Karvalian/Hacking-C: A repo which will help the people that are beginning to learn hacking in C language.
- acl-dev/acl: A powerful server and network library, including coroutine, redis client, http, websocket, mqtt with C/C++ for multi-platform including Linux, Android, iOS, MacOS, Windows, etc..
- andlabs/libui: Simple and portable (but not inflexible) GUI library in C that uses the native GUI technologies of each platform it supports.
- cesanta/mongoose: Embedded Web Server
- CherniakYura/tccurl: Implement include header files over https
- Hirrolot/metalang99: Full-blown preprocessor metaprogramming
- Immediate-Mode-UI/Nuklear: A single-header ANSI C immediate mode cross-platform GUI library
- jorisvink/kore: An easy to use, scalable and secure web application framework for writing web APIs in C or Python. || This is a read-only mirror, please see https://kore.io/mail and https://kore.io/source for information on how to contribute via the mailing lists.
- jserv/cregex: A small implementation of regular expression matching engine in C
- libuv/libuv: Cross-platform asynchronous I/O
- LordOfTrident/colorer: A cross-platform terminal color library for C
- lvgl/lvgl: Powerful and easy-to-use embedded GUI with many widgets, advanced visual effects (opacity, antialiasing, animations) and low memory requirements (16K RAM, 64K Flash).
- mackron/miniaudio: Audio playback and capture library written in C, in a single source file.
- networkprotocol/netcode: A protocol for secure client/server connections over UDP
- orangeduck/Cello: Higher level programming in C
- raysan5/mic: A simple and easy-to-use library to build pipelines in C
- vstakhov/libucl: Universal configuration library parser
- klange/bim: small terminal text editor with syntax highlighting
- benjojo/nowrap: Small C program to make sure lines don’t wrap in a terminal (like when cat-ing logs)
- Cogmasters/findex: Attach metadata to files, and retrieve it.
- rwmjones/miniexpect: Small expect-like library, clone of http://git.annexia.org/?p=miniexpect.git;a=summary
- JuliaPoo/Artfuscator: A C compiler targeting an artistically pleasing nightmare for reverse engineers
docker build -t bic https://github.com/hexagonal-sun/bic.git#master docker run --rm -it bic:latest
https://stackoverflow.com/questions/2482348/run-c-or-c-file-as-a-script
//usr/bin/env gcc -Wall -std=c99 -o $HOME/.cache/gcc/hello-world "$0" && exec $HOME/.cache/gcc/hello-world "$@"
#include <stdio.h>
int main ()
{
printf ("Hello World\n");
return 0;
}
http://drandom.blogspot.com/2013/12/shebang-for-c-programs.html
alcover/runc: compile and run C code
Alternative way use tcc
#!/usr/bin/tcc -run
- each process gets its own stack (assume single-threaded processes)
- LIFO, like the data structure
- contiguos block of memory (the process’s address space)
- the stack consists of stack frames
- contains the parameters to a function, its local variables, and the data necessary to recover the previous stack frame
- when a function is called, a frame for that function is pushed onto the stack
- when the function is done, we pop the stack frame and return to the caller
- contains high-performance memory
- usually fixed limits
- to clarify
- stack memory is high-performance in terms of ALLOCATION time, not ACCESS time
int myArray[10];
- dave-f/baff at 7af72db9c6e542ed2b60952933113d0aa86728cf
- Enter-tainer/cxx2flow: 将 C/C++ 代码转换成流程图 / Turn your C/C++ code into flowchart
- exebook/generic-print: Convenient generic print() for C
- googleprojectzero/weggli: weggli is a fast and robust semantic search tool for C and C++ codebases. It is designed to help security researchers identify interesting functionality in large codebases.
- hilmi-yilmaz/malloc_failer: This is a script which makes it possible to fail a specific malloc after X times.
- jart/cosmopolitan: build-once run-anywhere c library
- l1mey112/crepl: Compile and execute C code on the fly as you type it.
- ollelogdahl/ihct: ‘I Hate C Testing’: A minimal testing framework for C.
- vmware/chap: chap analyzes un-instrumented core files for leaks, memory growth, and corruption
- WerWolv/ImHex: A Hex Editor for Reverse Engineers, Programmers and people that value their eye sight when working at 3 AM.
- happyincent/Functional-Programming-in-C: https://hackmd.io/s/r1SgsdF3X
- TheAlgorithms/C: Collection of various algorithms in mathematics, machine learning, computer science, physics, etc implemented in C for educational purposes.
- fragglet/c-algorithms: A library of common data structures and algorithms written in C.
- rswier/c4: C in four functions
- Beej’s Guide to Network Programming
- mkirchner/linked-list-good-taste: Linus Torvalds’ linked list argument for good taste, explained
- Keyboard-Slayer/onion: It has layers ! (good Makefile)
- jstrieb/systems-programming-cheat-sheet: Cheat sheet for x86-64 Unix systems programming
- C & GUI Programming — The MagPi magazine
- Topics on GitHub
- clibs/clib: C package manager-ish
- C
- ryanmjacobs/c: Compile and execute C “scripts” in one go!
- fragglet/c-algorithms: A library of common data structures and algorithms written in C.
- hstr/CONFIGURATION.md at master · dvorka/hstr
- rby90/Project-Based-Tutorials-in-C: A curated list of project-based tutorials in C