Skip to content

Commit

Permalink
0x03-0x06 update README to new format; add test mains
Browse files Browse the repository at this point in the history
  • Loading branch information
allelomorph committed Nov 23, 2021
1 parent 273f60e commit bf8d5be
Show file tree
Hide file tree
Showing 34 changed files with 1,496 additions and 8 deletions.
69 changes: 68 additions & 1 deletion 0x03-proc_filesystem/README.md
Original file line number Diff line number Diff line change
@@ -1 +1,68 @@
# 0x03. Python - /proc filesystem
# (360) 0x03. Python - /proc filesystem
Specializations > System programming & Algorithm > Linux Programming

### Project author
Alexandre Gautier

### Assignment dates
01-12-2021 to 01-22-2021

### Description
Introduction to using the `/proc` filesystem to explore the memory footprint of a running process.

### Requirements
* All your modules should have documentation (`python3 -c 'print(__import__("my_module").__doc__)'`)
* All your classes should have documentation (`python3 -c 'print(__import__("my_module").MyClass.__doc__)'`)
* All your functions (inside and outside a class) should have documentation (`python3 -c 'print(__import__("my_module").my_function.__doc__)'` and `python3 -c 'print(__import__("my_module").MyClass.my_function.__doc__)')`


### Provided file(s)

---

## Mandatory Tasks

### :white_check_mark: 0. Hack the VM
Write a script that finds a string in the heap of a running process, and replaces it.

* Usage: `read_write_heap.py pid search_string replace_string`
* where `pid` is the pid of the running process
* and strings are ASCII
* The script should look only in the heap of the process
* Output: you can print whatever you think is interesting
* On usage error, print an error message on `stdout` and exit with status code 1

File(s): [`read_write_heap.py`](./read_write_heap.py)

### :white_large_square: 1. Blog post #1
Write a blog post about the `/proc` filesystem and the `/proc/maps` and `/proc/mem` files.

Try to explain how to parse the `/proc/maps` file in order to read the virtual memory.

Your posts should have examples and at least one picture, at the top. Publish your blog post on Medium or LinkedIn, and share it at least on Twitter and LinkedIn.

<!--
https://www.linkedin.com/pulse/using-procmaps-procmem-linux-view-memory-running-process-pomeroy
https://www.linkedin.com/posts/activity-6758106225340231680-voI7
-->

## Advanced Tasks

### :white_large_square: 2. Blog post #2
Write a blog post about the virtual memory.

How does the virtual memory map into the RAM?

Try to go as deep as possible in your explanation, and try to explain how the Kernel handles it.

Your posts should have examples and at least one picture, at the top. Publish your blog post on Medium or LinkedIn, and share it at least on Twitter and LinkedIn.

<!--
https://www.linkedin.com/pulse/using-procmaps-procmem-linux-view-memory-running-process-pomeroy
https://www.linkedin.com/posts/activity-6758106225340231680-voI7
-->

---

## Student
* **Samuel Pomeroy** - [allelomorph](github.com/allelomorph)
79 changes: 78 additions & 1 deletion 0x04-readelf/README.md
Original file line number Diff line number Diff line change
@@ -1 +1,78 @@
# 0x04. C - ELF: readelf
# (364) 0x04. C - ELF: readelf
Specializations > System programming & Algorithm > Linux Programming

### Project author
Alexandre Gautier

### Assignment dates
01-21-2021 to 01-29-2021

### Description
Introduction to ELF or the Executable and Linkable Format, its uses, and structure.

### Requirements
Allowed Functions and System Calls

* Unless specified otherwise, you are allowed to use the C standard library
* You’re not allowed to use `system`(3)
* You’re not allowed to use `exec`(2) and `exec`(3)

Tests

* Your program must be able to handle both 32-bit and 64-bit ELF files
* Your program must be able to handle both little and big endian ELF files
* Your program must be able to handle all types of ELF files


### Provided file(s)

---

## Mandatory Tasks

### :white_check_mark: 0. ELF file header
Write a program that displays the information contained in the ELF file header of an ELF file.

* Usage: `0-hreadelf elf_filename`
* Your standard output, error output and status should be the exact same as `readelf -W -h`

Your makefile must define the rule `0-hreadelf` and compile the needed sources to form the executable `0-hreadelf`

Compiled: `make 0-hreadelf`

### :white_check_mark: 1. ELF sections' headers
Write a program that displays the information contained in the ELF sections' headers of an ELF file.

* Usage: `1-hreadelf elf_filename`
* Your standard output, error output and status should be the exact same as `readelf -W -S`

Your makefile must define the rule `1-hreadelf` and compile the needed sources to form the executable `1-hreadelf`

Compiled: `make 1-hreadelf`

### :white_check_mark: 2. ELF program headers
Write a program that displays the information contained in the ELF program headers of an ELF file.

* Usage: `2-hreadelf elf_filename`
* Your standard output, error output and status should be the exact same as `readelf -W -l`

Your makefile must define the rule `2-hreadelf` and compile the needed sources to form the executable `2-hreadelf`

Compiled: `make 2-hreadelf`

## Advanced Tasks

### :white_check_mark: 3. ELF symbol table
Write a program that displays the information contained in the ELF symbol tables of an ELF file.

* Usage: `100-hreadelf elf_filename`
* Your standard output, error output and status should be the exact same as `readelf -W -s`

Your makefile must define the rule `100-hreadelf` and compile the needed sources to form the executable `100-hreadelf`

Compiled: `make 100-hreadelf`

---

## Student
* **Samuel Pomeroy** - [allelomorph](github.com/allelomorph)
248 changes: 247 additions & 1 deletion 0x05-libasm/README.md
Original file line number Diff line number Diff line change
@@ -1 +1,247 @@
# 0x05. x86 Assembly - libASM
# (376) 0x05. x86 Assembly - libASM
Specializations > System programming & Algorithm > Linux Programming

### Project author
Alexandre Gautier

### Assignment dates
02-01-2021 to 02-12-2021

### Description
Introduction to x86 assembly: Intel vs AT&T, flag registers, stack frames, function and system calls.

### Requirements
* Allowed Functions and System Calls
Unless specified otherwise, you are NOT allowed to do any call or make any system call. It means you’re not allowed to use either the `call` nor the `syscall` instructions.
* ASM programs and functions expected to be compiled with NASM version 2.10.09 using the flags `-f elf64`

### Provided file(s)
* [`0-main.c`](./tests/0-main.c) [`1-main.c`](./tests/1-main.c) [`2-main.c`](./tests/2-main.c) [`3-main.c`](./tests/3-main.c) [`4-main.c`](./tests/4-main.c) [`5-main.c`](./tests/5-main.c) [`6-main.c`](./tests/6-main.c) [`7-main.c`](./tests/7-main.c) [`8-main.c`](./tests/8-main.c) [`9-main.c`](./tests/9-main.c) [`10-main.c`](./tests/10-main.c) [`11-main.c`](./tests/11-main.c) [`12-main.c`](./tests/12-main.c)
* [`100-main.c`](./tests/100-main.c) [`101-main.c`](./tests/101-main.c)

---

## Mandatory Tasks

### :white_check_mark: 0. strlen
Write a copycat of the function `strlen`(3), in x86-64 Assembly

* Prototype when used in C: `size_t asm_strlen(const char *str);`

File(s): [`0-strlen.asm`](./0-strlen.asm)\
Compiled:
```bash
$ gcc -Wall -Wextra -Werror -pedantic -g3 -c -o 0-main.o 0-main.c
$ nasm -f elf64 -o 0-strlen.o 0-strlen.asm
$ gcc -o 0-strlen 0-main.o 0-strlen.o
```

### :white_check_mark: 1. strcmp
Write a copycat of the function `strcmp`(3), in x86-64 Assembly

* Prototype when used in C: `int asm_strcmp(const char *s1, const char *s2);`

File(s): [`1-strcmp.asm`](./1-strcmp.asm)\
Compiled:
```bash
$ gcc -Wall -Wextra -Werror -pedantic -g3 -c -o 1-main.o 1-main.c
$ nasm -f elf64 -o 1-strcmp.o 1-strcmp.asm
$ gcc -o 1-strcmp 1-main.o 1-strcmp.o
```

### :white_check_mark: 2. strncmp
Write a copycat of the function `strncmp`(3), in x86-64 Assembly

* Prototype when used in C: `int asm_strncmp(const char *s1, const char *s2, size_t n);`

File(s): [`2-strncmp.asm`](./2-strncmp.asm)\
Compiled:
```bash
$ gcc -Wall -Wextra -Werror -pedantic -g3 -c -o 2-main.o 2-main.c
$ nasm -f elf64 -o 2-strncmp.o 2-strncmp.asm
$ gcc -o 2-strncmp 2-main.o 2-strncmp.o
```

### :white_check_mark: 3. strchr
Write a copycat of the function `strchr`(3), in x86-64 Assembly

* Prototype when used in C: `char *asm_strchr(const char *s, int c);`

File(s): [`3-strchr.asm`](./3-strchr.asm)\
Compiled:
```bash
$ gcc -Wall -Wextra -Werror -pedantic -g3 -c -o 3-main.o 3-main.c
$ nasm -f elf64 -o 3-strchr.o 3-strchr.asm
$ gcc -o 3-strchr 3-main.o 3-strchr.o
```

### :white_check_mark: 4. strstr
Write a copycat of the function `strstr`(3), in x86-64 Assembly

* Prototype when used in C: `char *asm_strstr(const char *haystack, const char *needle);`

File(s): [`4-strstr.asm`](./4-strstr.asm)\
Compiled:
```bash
$ gcc -Wall -Wextra -Werror -pedantic -g3 -c -o 4-main.o 4-main.c
$ nasm -f elf64 -o 4-strstr.o 4-strstr.asm
$ gcc -o 4-strstr 4-main.o 4-strstr.o
```

### :white_check_mark: 5. memcpy
Write a copycat of the function `memcpy`(3), in x86-64 Assembly

* Prototype when used in C: `void *asm_memcpy(void *dest, const void *src, size_t n);`

File(s): [`5-memcpy.asm`](./5-memcpy.asm)\
Compiled:
```bash
$ gcc -Wall -Wextra -Werror -pedantic -g3 -c -o 5-main.o 5-main.c
$ nasm -f elf64 -o 5-memcpy.o 5-memcpy.asm
$ gcc -o 5-memcpy 5-main.o 5-memcpy.o
```

### :white_check_mark: 6. putc
Write a function that prints a single character on the standard output, in x86-64 Assembly

* Prototype when used in C: `size_t asm_putc(int c);`
* Where `c` holds the character to be printed
* Your function must return the total number of bytes written on the standard output
* For this task, you are allowed to use the `syscall` instruction only once in your file

File(s): [`6-putc.asm`](./6-putc.asm)\
Compiled:
```bash
$ gcc -Wall -Wextra -Werror -pedantic -g3 -c -o 6-main.o 6-main.c
$ nasm -f elf64 -o 6-putc.o 6-putc.asm
$ gcc -o 6-putc 6-main.o 6-putc.o
```

### :white_check_mark: 7. puts
Write a function that prints a string of characters on the standard output, in x86-64 Assembly

* Prototype when used in C: size_t `asm_puts(const char *str);`
* Where `str` holds the string to be printed
* Your function must return the total number of bytes written on the standard output
* You are not allowed to use any sort of `jump`
* Your file `0-strlen.asm` will be compiled as well, you are allowed to `call` it once in your file
* For this task, you are allowed to use the `syscall` instruction only once in your file

File(s): [`7-puts.asm`](./7-puts.asm) [`0-strlen.asm`](./0-strlen.asm)\
Compiled:
```bash
$ gcc -Wall -Wextra -Werror -pedantic -g3 -c -o 7-main.o 7-main.c
$ nasm -f elf64 -o 7-puts.o 7-puts.asm
$ nasm -f elf64 -o 0-strlen.o 0-strlen.asm
$ gcc -o 7-puts 7-main.o 7-puts.o 0-strlen.o
```

### :white_check_mark: 8. strcasecmp
Write a copycat of the function `strcasecmp`(3), in x86-64 Assembly

* Prototype when used in C: `int asm_strcasecmp(const char *s1, const char *s2);`

File(s): [`8-strcasecmp.asm`](./8-strcasecmp.asm)\
Compiled:
```bash
$ gcc -Wall -Wextra -Werror -pedantic -g3 -c -o 8-main.o 8-main.c
$ nasm -f elf64 -o 8-strcasecmp.o 8-strcasecmp.asm
$ gcc -o 8-strcasecmp 8-main.o 8-strcasecmp.o
```

### :white_check_mark: 9. strncasecmp
Write a copycat of the function `strncasecmp`(3), in x86-64 Assembly

* Prototype when used in C: `int asm_strncasecmp(const char *s1, const char *s2, size_t n);`

File(s): [`9-strncasecmp.asm`](./9-strncasecmp.asm)\
Compiled:
```bash
$ gcc -Wall -Wextra -Werror -pedantic -g3 -c -o 9-main.o 9-main.c
$ nasm -f elf64 -o 9-strncasecmp.o 9-strncasecmp.asm
$ gcc -o 9-strncasecmp 9-main.o 9-strncasecmp.o
```

### :white_check_mark: 10. strspn
Write a copycat of the function `strspn`(3), in x86-64 Assembly

* Prototype when used in C: `size_t asm_strspn(const char *s, const char *accept);`

File(s): [`10-strspn.asm`](./10-strspn.asm)\
Compiled:
```bash
$ gcc -Wall -Wextra -Werror -pedantic -g3 -c -o 10-main.o 10-main.c
$ nasm -f elf64 -o 10-strspn.o 10-strspn.asm
$ gcc -o 10-strspn 10-main.o 10-strspn.o
```

### :white_check_mark: 11. strcspn
Write a copycat of the function `strcspn`(3), in x86-64 Assembly

* Prototype when used in C: `size_t asm_strcspn(const char *s, const char *reject);`

File(s): [`11-strcspn.asm`](./11-strcspn.asm)\
Compiled:
```bash
$ gcc -Wall -Wextra -Werror -pedantic -g3 -c -o 11-main.o 11-main.c
$ nasm -f elf64 -o 11-strcspn.o 11-strcspn.asm
$ gcc -o 11-strcspn 11-main.o 11-strcspn.o
```

### :white_check_mark: 12. strpbrk
Write a copycat of the function `strpbrk`(3), in x86-64 Assembly

* Prototype when used in C: `char *asm_strpbrk(const char *s, const char *accept);`

File(s): [`12-strpbrk.asm`](./12-strpbrk.asm)\
Compiled:
```bash
$ gcc -Wall -Wextra -Werror -pedantic -g3 -c -o 12-main.o 12-main.c
$ nasm -f elf64 -o 12-strpbrk.o 12-strpbrk.asm
$ gcc -o 12-strpbrk 12-main.o 12-strpbrk.o
```

## Advanced Tasks

### :white_check_mark: 13. puti
Write a function that prints a signed integer on the standard output, in x86-64 Assembly

* Prototype when used in C: `size_t asm_puti(int n);`
* Where `n` holds the integer to be printed
* Your function must return the total number of bytes written on the standard output
* Your file `6-putc.asm` will be compiled as well
* You are allowed to use the instruction `call` up to three times in your file

File(s): [`100-puti.asm`](./100-puti.asm) [`6-putc.asm`](./6-putc.asm)\
Compiled:
```bash
$ gcc -Wall -Wextra -Werror -pedantic -g3 -c -o 100-main.o 100-main.c
$ nasm -f elf64 -o 100-puti.o 100-puti.asm
$ nasm -f elf64 -o 6-putc.o 6-putc.asm
$ gcc -o 100-puti 100-main.o 100-puti.o 6-putc.o
```

### :white_check_mark: 14. puti_base
Write a function that prints a signed integer in a given base on the standard output, in x86-64 Assembly

* Prototype when used in C: `size_t asm_puti_base(int n, const char *base);`
* Where `n` holds the integer to be printed
* And `base` points to a string representing the base used to print `n`
* Your function must return the total number of bytes written on the standard output
* Your files `6-putc.asm` and `0-strlen.asm` will be compiled as well
* You are allowed to use the instruction `call` up to four times in your file

File(s): [`101-puti_base.asm`](./101-puti_base.asm) [`6-putc.asm`](./6-putc.asm) [`0-strlen.asm`](./0-strlen.asm)\
Compiled:
```bash
$ gcc -Wall -Wextra -Werror -pedantic -g3 -c -o 101-main.o 101-main.c
$ nasm -f elf64 -o 101-puti_base.o 101-puti_base.asm
$ nasm -f elf64 -o 6-putc.o 6-putc.asm
$ nasm -f elf64 -o 0-strlen.o 0-strlen.asm
$ gcc -o 101-puti_base 101-main.o 101-puti_base.o 6-putc.o 0-strlen.o
```

---

## Student
* **Samuel Pomeroy** - [allelomorph](github.com/allelomorph)
Loading

0 comments on commit bf8d5be

Please sign in to comment.