From 1a6f74c030a244b90ce2e278ad4b3ea661ea17e5 Mon Sep 17 00:00:00 2001 From: Gasper Spagnolo Date: Mon, 25 Jul 2022 13:05:35 +0200 Subject: [PATCH] first commit --- Clipboard.md | 13 +++++++ Compression.md | 25 +++++++++++++ Curl.md | 19 ++++++++++ Dig.md | 11 ++++++ Find.md | 14 ++++++++ GIT.md | 17 +++++++++ Locate.md | 19 ++++++++++ Networking.md | 36 +++++++++++++++++++ SSH.md | 30 ++++++++++++++++ Tracks.md | 13 +++++++ VFS.md | 27 ++++++++++++++ VIM.md | 47 ++++++++++++++++++++++++ adress_space.md | 16 +++++++++ bash.md | 7 ++++ binary-patching.md | 11 ++++++ binary_vs_text_files.md | 6 ++++ disk-usage.md | 13 +++++++ docker.md | 16 +++++++++ document-conversion.md | 3 ++ exec.md | 28 +++++++++++++++ ffmpeg.md | 7 ++++ forensics.md | 14 ++++++++ fork.md | 56 +++++++++++++++++++++++++++++ gcc.md | 7 ++++ gdb.md | 49 +++++++++++++++++++++++++ mosquitto.md | 10 ++++++ mount.md | 4 +++ named_pipes.md | 10 ++++++ permissions.md | 13 +++++++ pipewire.md | 4 +++ pwn.md | 4 +++ qemu.md | 23 ++++++++++++ regex.md | 4 +++ rust.md | 8 +++++ services-and-process-management.md | 17 +++++++++ sorting_algorithms.md | 58 ++++++++++++++++++++++++++++++ symlinks.md | 36 +++++++++++++++++++ system-information.md | 27 ++++++++++++++ tmux.md | 26 ++++++++++++++ uart.md | 16 +++++++++ ufw.md | 19 ++++++++++ wasm.md | 17 +++++++++ 42 files changed, 800 insertions(+) create mode 100755 Clipboard.md create mode 100755 Compression.md create mode 100755 Curl.md create mode 100755 Dig.md create mode 100755 Find.md create mode 100755 GIT.md create mode 100755 Locate.md create mode 100755 Networking.md create mode 100755 SSH.md create mode 100755 Tracks.md create mode 100644 VFS.md create mode 100755 VIM.md create mode 100644 adress_space.md create mode 100644 bash.md create mode 100755 binary-patching.md create mode 100644 binary_vs_text_files.md create mode 100755 disk-usage.md create mode 100644 docker.md create mode 100755 document-conversion.md create mode 100644 exec.md create mode 100644 ffmpeg.md create mode 100755 forensics.md create mode 100644 fork.md create mode 100755 gcc.md create mode 100755 gdb.md create mode 100644 mosquitto.md create mode 100755 mount.md create mode 100644 named_pipes.md create mode 100755 permissions.md create mode 100755 pipewire.md create mode 100755 pwn.md create mode 100755 qemu.md create mode 100755 regex.md create mode 100644 rust.md create mode 100755 services-and-process-management.md create mode 100644 sorting_algorithms.md create mode 100644 symlinks.md create mode 100755 system-information.md create mode 100755 tmux.md create mode 100755 uart.md create mode 100755 ufw.md create mode 100644 wasm.md diff --git a/Clipboard.md b/Clipboard.md new file mode 100755 index 0000000..0b3511c --- /dev/null +++ b/Clipboard.md @@ -0,0 +1,13 @@ +--- +title: Clipboard +created: '2021-12-26T19:27:19.496Z' +modified: '2021-12-26T19:27:45.794Z' +--- + +# Clipboard + +- `cat file.txt | xclip -selection clipboard -i` store file into clipboard + +### On wayland + +- `cat file.txt | wl-copy` store file into clipboard diff --git a/Compression.md b/Compression.md new file mode 100755 index 0000000..85fb44a --- /dev/null +++ b/Compression.md @@ -0,0 +1,25 @@ +--- +tags: [linux] +title: Compression +created: '2021-11-06T22:08:33.761Z' +modified: '2021-12-31T10:35:51.469Z' +--- + +# Compression +### Tar archives + +- `tar -cf file.tar dir/` -archive using tar, extract `tar -xvf file.tar` +- `sudo tar -czf file.tar.gz dir/` gzip dir + +### Gzip +- `gunzip archive.gz` + +### Zip archives + +- `unzip -x -d ` - unzip +-`zip -r {filename.zip} {foldername}` -zip + + +### 7zip archives +- `7z x ` - unzip + diff --git a/Curl.md b/Curl.md new file mode 100755 index 0000000..5359c63 --- /dev/null +++ b/Curl.md @@ -0,0 +1,19 @@ +--- +tags: [linux] +title: Curl +created: '2021-12-05T22:26:06.249Z' +modified: '2021-12-05T23:01:15.615Z' +--- + +# Curl + +### Download any file +- `curl -o ` -download with new filename +- `curl -O ` - download with original filename + +useful flags: +- `-L` - use redirection +- `-H 'key:value'` - add header + +- `curl -IL ssrd.io` - get information about server +- `url -vL ssrd.io` - display handshake with a server diff --git a/Dig.md b/Dig.md new file mode 100755 index 0000000..ab7eeb6 --- /dev/null +++ b/Dig.md @@ -0,0 +1,11 @@ +--- +tags: [linux] +title: Dig +created: '2021-12-05T22:45:44.151Z' +modified: '2021-12-05T22:46:14.308Z' +--- + +# Dig + +### Get all DNS records of a domain name +- `dig ssrd.io ALL` diff --git a/Find.md b/Find.md new file mode 100755 index 0000000..e2ac8c3 --- /dev/null +++ b/Find.md @@ -0,0 +1,14 @@ +--- +tags: [linux] +title: Find +created: '2021-10-27T23:21:40.274Z' +modified: '2021-12-09T21:12:58.481Z' +--- + +# Find +### Examples of find command +- `sudo find / -type d -iname "gasper"` - search direcotry +- `sudo find /etc -type f -name "*.conf"` - display all configuration files, for more percison you should `|` into `grep`. + + +You can also add `szie` flag to narrow down results to expected filesize. Other useful flags: `user`, `group`. diff --git a/GIT.md b/GIT.md new file mode 100755 index 0000000..3f4e495 --- /dev/null +++ b/GIT.md @@ -0,0 +1,17 @@ +--- +title: GIT +created: '2021-12-14T21:11:06.500Z' +modified: '2021-12-14T21:13:05.655Z' +--- + +# GIT + +- If you want to revert changes made to your working copy, do this: +`git checkout .` +- if you want to revert changes made to the index (i.e., that you have added), do this. Warning this will reset all of your unpushed commits to master! +`git reset` +- if you want to remove untracked files (e.g., new files, generated files): `git clean -f` and dirs `git clean -fd` +- if you want only one file to be revetred +`git checkout HEAD -- TIS/tis.tex` +- Add all files in the repo +`git add -A` diff --git a/Locate.md b/Locate.md new file mode 100755 index 0000000..d88887c --- /dev/null +++ b/Locate.md @@ -0,0 +1,19 @@ +--- +tags: [linux] +title: Locate +created: '2021-10-25T21:52:02.050Z' +modified: '2021-12-09T21:08:10.036Z' +--- + +# Locate +### Examples of locate command +use whatis/man locate for more info + +- `locate --all "passwd"` +- `locate /etc --all "passwd"` +- `locate "passwd" | grep "/etc/"` +- `locate --all "*.conf" | grep resolv` +- `locate --all "*conf" | grep proxychains` +- `locate --all -c "*.conf"` - Count number of files whith provided name / pattern + +Use `-i` parameter to search uppercase/lowercase ! diff --git a/Networking.md b/Networking.md new file mode 100755 index 0000000..fd723c5 --- /dev/null +++ b/Networking.md @@ -0,0 +1,36 @@ +--- +tags: [linux] +title: Networking +created: '2021-11-08T22:28:05.169Z' +modified: '2021-12-09T21:20:59.016Z' +--- + +# Networking + +### IP command + +- `ip route show` -- display all routes `man ip | grep route` -- neat way to find more information about this command +- `ip a` -- display all interfaces + + +### Netstat command + + +- `netstat -r` -- show routes +- `netstat -t` -- display all current tcp connections, useful with grep command +- `netstat -ltnp / -lu` list local TCP or UPD connections + +If u dont wont get cought use` tor + proxychains` + +### Proxychains +- `systemctl start tor` +- [setup](https://medium.com/cyberxerx/how-to-setup-proxychains-in-kali-linux-by-terminal-618e2039b663) + +### Nmap +- [cheat-sheet](https://hackertarget.com/nmap-cheatsheet-a-quick-reference-guide/) + +### Sslscan +Queries SSL/TLS services (such as HTTPS) and reports the protocol versions, cipher suites, key exchanges, signature algorithms, and certificates in use. This helps the user understand which parameters are weak from a security standpoint. + +### Whois +Find information about domain name `whois spanskiduh.xyz` diff --git a/SSH.md b/SSH.md new file mode 100755 index 0000000..b9a109c --- /dev/null +++ b/SSH.md @@ -0,0 +1,30 @@ +--- +tags: [linux] +title: SSH +created: '2021-11-25T00:11:55.575Z' +modified: '2021-12-09T21:54:30.814Z' +--- + +# SSH + +### basic +- `/etc/ssh/ssh_config` - config location (client) +- `/etc/ssh/sshd_config` - config location (server) + +It is *always* smart to disable root login! +--> uncomment `PermitRootLogin no` + +### Enable encryption + +- `ssh-keygen -t rsa` - generate private and public key +- `ssh-copy-id ` - copy ssh identity to server + +--> uncomment `PasswordAuthentication no` (on server) +**Warning** store private key on a secure location, if you lose it, you will lose connection to a server! + +### FAIL2BAN +- use it to secure ssh +- install a basic ubuntu vm and watch from 4:20 in video he he u get it, but it is actually there + +### SCP +- `scp ` - copy file to server diff --git a/Tracks.md b/Tracks.md new file mode 100755 index 0000000..522a420 --- /dev/null +++ b/Tracks.md @@ -0,0 +1,13 @@ +--- +tags: [linux] +title: Tracks +created: '2021-12-09T20:43:41.061Z' +modified: '2021-12-09T21:41:06.195Z' +--- + +# Tracks + +- `/var/log` - Location of kernel and software logs +- `shred -vzfu auth.log` -read manual, tool that overrites file many times causing data to be unrecoverable + +- `.bash_history` - do not forget this bro diff --git a/VFS.md b/VFS.md new file mode 100644 index 0000000..ae24bb0 --- /dev/null +++ b/VFS.md @@ -0,0 +1,27 @@ +# VFS + +## Superblock +Representation of mounted filesystem. +properties: + - device, where the fs is located + - fs type + - block size + - flags + - root inode pointer (!) + - low level operations on the filesystem + +## Inode +File of any type. Represents everything, except the filename! +properties: + - includes pointers to blocks with data!!! + - owner, group, perms info + - inode number, file size. + - date & time of most recent access + +## Dentry +It maps file names to to inodes +properties: + - filename + - inode pointer that represents file + - pointer to parent dirent + - counter of usages diff --git a/VIM.md b/VIM.md new file mode 100755 index 0000000..3420e15 --- /dev/null +++ b/VIM.md @@ -0,0 +1,47 @@ +--- +tags: [linux] +title: VIM +created: '2022-01-24T16:09:57.858Z' +modified: '2022-01-24T16:10:20.634Z' +--- + +# VIM +Comment Multiple Lines +- `:15,25s/^/#` ~ comment from line 15 to 25. +- `%s/foo/bar/g` ~ replace all apearances of `foo` with `bar` in whole file +- `s/foo//g` ~ delete all apearances of `foo` in a line +- `:[range]s/{pattern}/{string}/[flags] [count]` this is how it is structured out + +### Navigation +- `hjkl` from now on use this keys +- `x[visual]` delete character at current pos +- `dw[visual]` delete a word + +-- vimtutor 2.5 + + +#### Nerdtree +- `s` - open horizontally +- `i` - open vertically + +#### Panes +- `ctrl + w` - move through panes +- `ctrl + w s` - split horizontally +- `ctrl + w v` - split vertically + +### Coc + +#### code navigation +- `VISUAL over function name -> gd` ~ go to function definition +- `VISUAL over data type -> gy / gi` ~ go to type definition +- `VISUAL over function/ datatype -> K` ~ show documentation +- `INSERT -> ctl + space` ~ toggle autosuggestions +- `ctl + o` ~ return back +- `VISUAL gf` ~ go to file +- `ctl + o` ~ take me where i have bene before +- `ctrl + i` ~ take me forward + +### Save +- `:sav file.txt` ~ save new file +- `:new file.txt` ~ create new file and open horizontally +- `:vsp file.txt` ~ create new file and open vertically diff --git a/adress_space.md b/adress_space.md new file mode 100644 index 0000000..8130b9a --- /dev/null +++ b/adress_space.md @@ -0,0 +1,16 @@ +# Adress space + +## AS in C +``` +[code ] +[init data ] +[uninit data] +[heap ] +[ | ] +[ . ] +[ free ] +[ . ] +[ | ] +[stack ] +[args + env ] +``` diff --git a/bash.md b/bash.md new file mode 100644 index 0000000..478dfbc --- /dev/null +++ b/bash.md @@ -0,0 +1,7 @@ +# Bash + +### Read file line by line using bash +Gotta love those oneliners ;) +```bash + while read line; do printf "$line\n"; printf "other commands\n"; done < /etc/passwd +``` diff --git a/binary-patching.md b/binary-patching.md new file mode 100755 index 0000000..72934e9 --- /dev/null +++ b/binary-patching.md @@ -0,0 +1,11 @@ +--- +tags: [linux] +title: Binary Patching +created: '2021-12-05T22:45:44.151Z' +modified: '2021-12-05T22:46:14.308Z' +--- + +# Binary patching +firstly check in ghidra what hex value has function call. then open binary in vim, find that and replace all fucntion hex values with 90 +`:%!xxd` and `:%!xxd -r` + diff --git a/binary_vs_text_files.md b/binary_vs_text_files.md new file mode 100644 index 0000000..ed2c413 --- /dev/null +++ b/binary_vs_text_files.md @@ -0,0 +1,6 @@ +# Binary vs text files + +### Binary vs text files comparisson +- read this awesome article https://www.geeksforgeeks.org/difference-between-cpp-text-file-and-binary-file/ +- Basically normal text files take more space than binary files, becouse you need to convert integer representation of number into chars. In binary file +format, the raw binary data is dumped into file. --> that results in much smaller file size diff --git a/disk-usage.md b/disk-usage.md new file mode 100755 index 0000000..b43f6f8 --- /dev/null +++ b/disk-usage.md @@ -0,0 +1,13 @@ +--- +tags: [linux] +title: Disk usage +created: '2021-11-06T21:52:39.114Z' +modified: '2021-12-09T21:13:42.734Z' +--- + +# Disk usage +### Very useful tool + +- `du -sh *` - list all folders an sizes in current folder +- `df -h` display filesystem usage + diff --git a/docker.md b/docker.md new file mode 100644 index 0000000..c0aeb6b --- /dev/null +++ b/docker.md @@ -0,0 +1,16 @@ +# Docker + +## Nuke docker +```bash + +#!/bin/bash + +printf "Stopping all containers\n" +docker ps | awk ' {print $1} ' | xargs docker kill + +printf "Deleting all containers\n" +docker container ls --filter "status=exited" | awk '{ print $1 }' | xargs docker container rm + +printf "Deleting all images\n" +docker image ls | awk '{print $3}' | xargs docker image rm --force +``` diff --git a/document-conversion.md b/document-conversion.md new file mode 100755 index 0000000..d32e75e --- /dev/null +++ b/document-conversion.md @@ -0,0 +1,3 @@ + +### Pandoc +- `pandoc -o doc.pdf doc.md` - convert md to pdf diff --git a/exec.md b/exec.md new file mode 100644 index 0000000..84f6437 --- /dev/null +++ b/exec.md @@ -0,0 +1,28 @@ +# EXEC +It is a family of functions that do the same thing but actually no. +When we call `exec()`, we never reutrn back to the callling program. The program +called by the `exec()` function replaces itself with the calling progam. The only way +that we could return to original process if `exec()` fails to execute. +Thats why we usually use `fork() & exec()`, so that we can safely return to main process +without losing anything :). + +what stays: +- `PID`, `PPID` +- opened file descriptors +- current directory, root directory + +what does not: +- code +- stack +- heap +- data + +(new stack and new heap) + +sufixes: +- `l` ~ arguments are passed as function arguments +- `v` ~ arguments are passed by char array +- `p` ~ search in `$PATH` for provided executable +- `P` ~ specifying that we will provide a path to an executable +- `e` ~ enviromental variables are provided in a char array + diff --git a/ffmpeg.md b/ffmpeg.md new file mode 100644 index 0000000..bb951ec --- /dev/null +++ b/ffmpeg.md @@ -0,0 +1,7 @@ +# FFMPEG + +## Converting .mp3 into .wav +`ffmpeg -i file.mp3 newfile.wav` + +## Cutting audio/video +` ffmpeg -i f24122a7f35de434d996.ogg -ss 00:00:00 -to 00:00:30 -c copy mini.ogg` diff --git a/forensics.md b/forensics.md new file mode 100755 index 0000000..0c9ceb9 --- /dev/null +++ b/forensics.md @@ -0,0 +1,14 @@ +# FORENSICS + +### Sleuthkit +- [sleuthkit commands](http://wiki.sleuthkit.org/index.php?title=The_Sleuth_Kit_commands) +- always check the offset with `mmls` command +- `sudo mount -o loop,offset=9437184 disk_image.img /mnt/iso` ~ mount iso img with offset +- or option2 (better imho): + - `udisksctl loop-setup --file disk.img` ~ this will create loop devices in `/dev/loopX` + - then mount partitions as usual drive + - to unomount, use flags `-f -l` + + +### Pdfgrep +- is another fancy tool to grep text in pdf files diff --git a/fork.md b/fork.md new file mode 100644 index 0000000..2590fac --- /dev/null +++ b/fork.md @@ -0,0 +1,56 @@ +# Fork + +### What happenes when you call `fork()` in your program? +Parent creates a child and spawns it, it is basically a copy of a parent process + +excluding: +- `PID`, `PPID` +- file locks, mutex locks, any other locks... + +including: +- same code +- !copy! of same heap and stack +- opened files + +### Example +```c +int pid = fork() +if (pid > 0){ + // parent process +} else if (pid == 0) { + // child process +} else { // pid < 0 + // we encountered err! +} +``` + +### What happenes when cild process is exited? +Exit status is saved in process descriptor, until parent process waits for it. +Until exit status is not taken then we say that the process is **zombie**: +- proces is exited, and it does not take any system resources. +- only its process descriptor is not yet taken +- and we do not want many zombies in our system + + +### How parent knows, that the child process has been terminated? +Well we can use `singal()` to notify parent when the child process exits. Namely signal `WAITCHLD`. + +Waiting for specific child: +```c +waitpid(pid, &status, options) +``` +Waiting for any child: +```c +wait(&status); +// or +waitpid(-1, &status, 0): +``` + +### Exit statuses +- 8bit value +- 0 means success +- 1-127 error +- 128-255 termination becouse of singal (`sig_num = status - 127`) + +## `vfork()` function +V fork is a modified fork, which does not copy any data. It is meant to be used with comibnation with function `exec()`. diff --git a/gcc.md b/gcc.md new file mode 100755 index 0000000..0540d3e --- /dev/null +++ b/gcc.md @@ -0,0 +1,7 @@ +# GCC + +### compilation flags +- `-g` ~ enable debugging mode (for gdb to show running c code also)] +- `-Wall` ~ enable all warnings +- `-o binary` ~ output to binary file +- `-S` ~ also compile asm file diff --git a/gdb.md b/gdb.md new file mode 100755 index 0000000..dc4e349 --- /dev/null +++ b/gdb.md @@ -0,0 +1,49 @@ +--- +tags: [linux] +title: Gdb +created: '2021-12-05T22:45:44.151Z' +modified: '2021-12-05T22:46:14.308Z' +--- + +# Gdb + +### Basics +- `r` ~ run program +- `ni` ~ step to next instruction +- `c` ~ coninue execution of program to breakpoint or end of program if no breakpoint is set +- `b *main` ~ add a breakpoint at main +- `b *0xdeadbeef` ~ add a breakpoint at a specific addres +- `info break` ~ list all breakpoints +- `delete breakpoint ` ~ delete breakpoint with provided `number` breakpoint identifier +- `x/30gx $rsp` ~ display first 30 values, after a stack pointer +- `x/s 0x0000000040080e` ~ display a **string** at provided addres +- `disass main` ~ disassembly provided function +- `x/4i 0x0000000000401393` ~ get 4 instructions on provided address + +#### Show all secitons of a file +- `info file` + +#### Display current state of registers +- `info registers` + +#### List all maped memory regions +- `info proc mappings` + +### Check protections used on a file +issue command `checksec` +- `Canary` ~ +- `NX` ~ +- `PIE` ~ +- `Fortify` ~ nobody knows +- `RelRO` ~ + +### ROP gadgedts +- `~/.local/bin/ROPgadget --binary a.out` +- registers: + - `rdi` ~ first argument + - `rsi` ~ second argument + +### HEAP +- `vis` ~ show heap visually +- `heap` ~ display chunks +- `bins` ~ diplay TCACHE, FASTBIN, UNSORTED BIN pointers diff --git a/mosquitto.md b/mosquitto.md new file mode 100644 index 0000000..ea431ab --- /dev/null +++ b/mosquitto.md @@ -0,0 +1,10 @@ +# Mosquitto + +Very nice IOT messaging protocol. + +### How to publish and subscribe to mqtt messages: + +#### Publish +`mosquitto_pub -h -p -u -P -t -m ''` +#### Subscribe +`mosquitto_sub -h -p -u -P -t ` diff --git a/mount.md b/mount.md new file mode 100755 index 0000000..f7fa72f --- /dev/null +++ b/mount.md @@ -0,0 +1,4 @@ +# Mount + +### Mount windows partition +`sudo mount -t ntfs3 /dev/sdb1 /mnt/usb` diff --git a/named_pipes.md b/named_pipes.md new file mode 100644 index 0000000..a80bd42 --- /dev/null +++ b/named_pipes.md @@ -0,0 +1,10 @@ +# Named pipes + +They are very useful for transmiting data of one linux process to another. + +### Creation of named pipe +- `mkfifo my_pipe` + +### Sending and recieving data +- `echo "Hello my friend!" > my_pipe` ~ sending data to pipe +- `tail -f my_pipe` ~ reading data from pipe diff --git a/permissions.md b/permissions.md new file mode 100755 index 0000000..869fb1d --- /dev/null +++ b/permissions.md @@ -0,0 +1,13 @@ +# PERMS + +### Structure +```bash + u g o + 7 5 4 + / | \ +type: r w x r w x r w x +repr: 4 2 1 4 2 1 4 2 1 +enabl: 1 1 1 1 0 1 1 0 0 +res: 4 2 1 4 0 1 4 0 0 + 7 5 4 +``` diff --git a/pipewire.md b/pipewire.md new file mode 100755 index 0000000..9cf7738 --- /dev/null +++ b/pipewire.md @@ -0,0 +1,4 @@ +# PIPEWIRE + +### Fix for sony +`https://gitlab.freedesktop.org/pipewire/pipewire/-/issues/688` diff --git a/pwn.md b/pwn.md new file mode 100755 index 0000000..f2e38b3 --- /dev/null +++ b/pwn.md @@ -0,0 +1,4 @@ +# PWN + +## Format1 +- `%12$p` ~ display value of offset 12 diff --git a/qemu.md b/qemu.md new file mode 100755 index 0000000..61b0047 --- /dev/null +++ b/qemu.md @@ -0,0 +1,23 @@ +# Qemu + +### Emulating raspberry pi 4 + +- firstly generate two images +`qemu-img create -f qcow2 arm.img 16G` ~ Image for os +`qemu-img create -f qcow2 varstore.img 64M` ~ EFI varaible store +- then download EFI file (A UEFI image for QEMU’s virt machine type, I use an EDK II derived snapshot image from Linaro) +`http://snapshots.linaro.org/components/kernel/leg-virt-tianocore-edk2-upstream/latest/QEMU-AARCH64/RELEASE_GCC5/QEMU_EFI.img.gz` + +- install +`qemu-system-aarch64 \ + -cpu cortex-a72 -smp 4 -M virt -m 4096 -nographic \ + -drive if=pflash,format=raw,file=QEMU_EFI.img \ + -drive if=pflash,file=varstore.img \ + -drive if=virtio,file=arm.img\ + -drive if=virtio, format=raw, file=file.iso` +- run +`qemu-system-aarch64 \ + -cpu cortex-a72 -smp 4 -M virt -m 4096 -nographic \ + -drive if=pflash,format=raw,file=QEMU_EFI.img \ + -drive if=pflash,file=varstore.img \ + -drive if=virtio,file=arm.img\` diff --git a/regex.md b/regex.md new file mode 100755 index 0000000..07f1f43 --- /dev/null +++ b/regex.md @@ -0,0 +1,4 @@ +# REGEX + +### Reversing regex +`exrex "flag\{wa{0}e[^abcdrfghijknmopqrstuvwxyz]c(((o)))(?=[a-z])[^a-ln-z]e_to_dc{0}ctf{1}\}" -o out.txt` - you can list all possible words accepted by regex with this tool diff --git a/rust.md b/rust.md new file mode 100644 index 0000000..03467d1 --- /dev/null +++ b/rust.md @@ -0,0 +1,8 @@ +# RUST + +### Basic cli tools + +- `cargo init` ~ create new rust project +- `cargo run` ~ build & run +- `cargo build` ~ just build +- `cargo build --release` ~ minimal release version (optimized) diff --git a/services-and-process-management.md b/services-and-process-management.md new file mode 100755 index 0000000..445fede --- /dev/null +++ b/services-and-process-management.md @@ -0,0 +1,17 @@ +--- +tags: [linux] +title: Services and process management +created: '2021-11-24T23:37:56.443Z' +modified: '2021-12-09T21:40:19.872Z' +--- + +# Services and process management + +### PS command +- `ps aux` - display **all** running services (snapshot) ex. `ps aux | grep "ssh"` +- `sudo kill ` - kill process with provided pid, provided by `ps` command +- `pkill ` - kill process by name :sunglasses: + +## on systemd u can also +- `systemctl | grep ` - display all running services or grep one +- `sudo systemctl is-enabled ssh` - check if service is enabled diff --git a/sorting_algorithms.md b/sorting_algorithms.md new file mode 100644 index 0000000..e675568 --- /dev/null +++ b/sorting_algorithms.md @@ -0,0 +1,58 @@ +# Sorting algorithms + +### FCFS +Basically a fifo + +### RR - round robin +Round robin + + +### SFJ +Shortest first + +### PSFJ +Preemptive +Sepravi ti gledas tuki +recimo da mas +A = 100 +B = 20 +C = 10 + +pa uzames najprej A, potem A splitas po C ju, ker ima C najmanjso casovno obdelavo. Aka vedno uzames 10 + +zgleda tko : A[0:10], pol B[0:10], pol C[0:10],pole A[10:20], B[10:20], A[20:90] + + +### Stride + +Najprej uzames najbol levega /shrug +a = step 10 +b = step 30 +c = step 20 + +Nato vedno v vsaki iteraciji pristejemo originalno ceno + + A B C + 0 0 0 + 10 0 0 + 10 0 20 + 10 30 20 + 20 30 20 + +Pol pa mamo se un kurac od krititcnega stanja +# Kriticno stanje + +```c +// random primer +x = 1 -> A_1 +y = 2 -> B_1 + +x = x + y -> A_2 +y = x - y -> B_2 +``` +Pol gremo samo probat use mozne kombinacije + +sepravi A_1 B_1 A_2 B_2 --> in zracunas nc kej takega, lp in lpp + +atomarne operacije aka prireditvne in ne prisevanje / odstevanje se morejo vedno najprej izvest, v nasprotnem primeru +sploh nemores npr prsiteti x-a in y-a ---> segmetnation fault diff --git a/symlinks.md b/symlinks.md new file mode 100644 index 0000000..b7860ed --- /dev/null +++ b/symlinks.md @@ -0,0 +1,36 @@ +# Difference between hardlinks and symlinks + +### Hardlinks +- implementation of `ln` +- kinda like shortcut, but a shortcut to a physical memory location!!!! + +```c +/* + * creates new file, that points to same memory location as provided file + * - if one of the files is edited, then both files change + * - if one of the files gets deleted, then just inode of that file, that points to that location is deleted + * other file stays undeleted, with same content + */ +int hardlink(char *dest, char *name) { + if(link(dest, name) < 0) + return errno; + return 0; +} +``` + +### Softlinks +- implementation of `ln -s` +- it works like a shortcut to original file + +```c +/* + * creates a new file, that points to provided file + * - if one of the files is edited, then both files change + * - if original file gets deleted, then also disk contents gets deleted, and link is broken + */ +int softlink(char *dest, char *name) { + if(symlink(dest, name) < 0) + return errno; + return 0; +} +``` diff --git a/system-information.md b/system-information.md new file mode 100755 index 0000000..a769cbe --- /dev/null +++ b/system-information.md @@ -0,0 +1,27 @@ +--- +favorited: true +tags: [linux] +title: System information +created: '2021-10-27T22:55:40.432Z' +modified: '2021-12-26T15:51:15.496Z' +--- + +# System information +### Basic user enumeration + +- `whoami` `hostname` - get username and hostname +- `id` - get information which group ids current user belongs to +- `groups $USER` - check groups +- `last` - check users that logged in recently + + +### Cpu, memory +- `lscpu` - show cpu information +- `free -h` - display memory usage +- `uname -p` or `uname -m` - show system architecture +- `uname -r` - see a running kernel +- `lsb_release -a` or `cat /etc/*release` - see running distribution + +### Another useful tool `sysstat` package +- `iostat` - show current io (disk usage, cpu usage) +- `mpstat` - show current cpu usage (detailed) diff --git a/tmux.md b/tmux.md new file mode 100755 index 0000000..2c0b1bf --- /dev/null +++ b/tmux.md @@ -0,0 +1,26 @@ +--- +tags: [linux] +title: Tmux +created: '2021-12-05T22:45:44.151Z' +modified: '2021-12-05T22:46:14.308Z' +--- + +# Tmux + +### Window operations +- `ctrl+b c` - spawn new window +- `ctrl+b n` - move to next window +- `ctrl+b p` - move to previous window +- `ctrl+b 0..9` - switch to window by number +- `ctrl+b x` - kill current window + +### Panes +- `ctrl+b %` - spawn new pane horizontally +- `ctrl+b "` - spawn new pane vertically" +- `ctrl+b arrow_key` - switch through panes +- `ctrl+b ctrl + arrow_key` - resize pane +- `ctrl+b o` - switch to next pane +- `ctrl+b loong o` - switch panes :sunglasses: +- `ctrl+b space` - toggle pane layouts +- `ctrl+b !` - convert pane into a window +- `ctrl+b x` - kill current pane diff --git a/uart.md b/uart.md new file mode 100755 index 0000000..f31be2f --- /dev/null +++ b/uart.md @@ -0,0 +1,16 @@ +--- +tags: [linux] +title: Connect to uart +created: '2021-12-02T13:30:36.053Z' +modified: '2022-02-10T21:22:22.348Z' +--- + +# Connect to uart +- `sudo dmesg | grep tty` - find uart device +- `sudo minicom -D /dev/ttyACM0 -b 115200` - connect to uart device + +ECHO TO UART DEVICE `ctrl + a e` + +(https://blog.mbedded.ninja/programming/operating-systems/linux/linux-serial-ports-using-c-cpp/)[programiranje uarta] + +LEAVE MINICOM (this is the hard one;;) ctrl + a and then x diff --git a/ufw.md b/ufw.md new file mode 100755 index 0000000..7052d3e --- /dev/null +++ b/ufw.md @@ -0,0 +1,19 @@ +--- +tags: [linux] +title: ufw +created: '2021-12-05T23:08:44.052Z' +modified: '2021-12-09T20:29:32.892Z' +--- + +# ufw + +### Connections +- `sudo ufw status numbered verbose` - check ufw status +- `sudo ufw default deny incoming` - deny incoming connections +- `sudo ufw default allow outgoing` - enable outgoing connections +- `sudo ufw allow ssh` - allow certian connection (you can also specify a port number instead of protocol!) +- `sudo ufw deny ssh` - deny certian connection +- `sudo ufw allow/deny proto tcp from any to any port 80,443` - deny / allow all 80 and 443 connections +- `sudo ufw allow from 192.168.1.103 to any port 22`- allow incomming ssh connections with specified ip. +- `sudo ufw allow from 192.168.1.1/24 to any port 22` - same thing, but now with specified subnet +- `sudo ufw delete ` - delete rule from ufw, get id with status command diff --git a/wasm.md b/wasm.md new file mode 100644 index 0000000..11eb43a --- /dev/null +++ b/wasm.md @@ -0,0 +1,17 @@ +# Wasm +h39df71edfbdc6cfb +hffef93c8d94444c4 +## Usage of wabt + +- wat2wasm: translate from WebAssembly text format to the WebAssembly binary format +- wasm2wat: the inverse of wat2wasm, translate from the binary format back to the text format (also known as a .wat) +- wasm-objdump: print information about a wasm binary. Similiar to objdump. +- wasm-interp: decode and run a WebAssembly binary file using a stack-based interpreter +- wasm-decompile: decompile a wasm binary into readable C-like syntax. +- wat-desugar: parse .wat text form as supported by the spec interpreter (s-expressions, flat syntax, or mixed) and print "canonical" flat format +- wasm2c: convert a WebAssembly binary file to a C source and header +- wasm-strip: remove sections of a WebAssembly binary file +- wasm-validate: validate a file in the WebAssembly binary format +- wast2json: convert a file in the wasm spec test format to a JSON file and associated wasm binary files +- wasm-opcodecnt: count opcode usage for instructions +- spectest-interp: read a Spectest JSON file, and run its tests in the interpreter