diff --git a/content/posts/Clipboard.md b/content/posts/Clipboard.md index 6a6c712..bb04077 100644 --- a/content/posts/Clipboard.md +++ b/content/posts/Clipboard.md @@ -1,16 +1,16 @@ +++ -date="2022-11-30" +date="2022-12-24" author="spanskiduh" title="Clipboard" description="click to read about Clipboard" +++ - - # Clipboard -- `cat file.txt | xclip -selection clipboard -i` store file into clipboard +### On xorg + +- `cat file.txt | xclip -selection clipboard -i` - store file into clipboard ### On wayland -- `cat file.txt | wl-copy` store file into clipboard +- `cat file.txt | wl-copy` - store file into clipboard diff --git a/content/posts/Compression.md b/content/posts/Compression.md index 0ba0774..0625ba1 100644 --- a/content/posts/Compression.md +++ b/content/posts/Compression.md @@ -1,6 +1,6 @@ +++ -date="2022-12-21" +date="2022-12-24" author="spanskiduh" title="Compression" description="click to read about Compression" @@ -8,6 +8,7 @@ description="click to read about Compression" # Compression + ### Tar archives - `tar -cf file.tar dir/` -archive using tar, extract `tar -xvf file.tar` @@ -26,3 +27,6 @@ description="click to read about Compression" ### 7zip archives - `7z x ` - unzip +## If you are super lazy + +- `binwalk -e -M ` - tries different extraction methods and recursively uznips diff --git a/content/posts/Curl.md b/content/posts/Curl.md index 2b33b91..964e22a 100644 --- a/content/posts/Curl.md +++ b/content/posts/Curl.md @@ -1,17 +1,16 @@ +++ -date="2022-11-30" +date="2022-12-24" author="spanskiduh" title="Curl" description="click to read about Curl" +++ - - # Curl -### Download any file +## Download any file - `curl -o ` -download with new filename - `curl -O ` - download with original filename +- `curl -X POST/GET/DELETE ` - different requests methods useful flags: - `-L` - use redirection diff --git a/content/posts/Dig.md b/content/posts/Dig.md index 7cc3cce..7b0abc6 100644 --- a/content/posts/Dig.md +++ b/content/posts/Dig.md @@ -1,12 +1,10 @@ +++ -date="2022-11-30" +date="2022-12-24" author="spanskiduh" title="Dig" description="click to read about Dig" +++ - - # Dig ### Get all DNS records of a domain name diff --git a/content/posts/Find.md b/content/posts/Find.md index 307029c..78c4e46 100644 --- a/content/posts/Find.md +++ b/content/posts/Find.md @@ -1,16 +1,15 @@ +++ -date="2022-11-30" +date="2022-12-24" author="spanskiduh" title="Find" description="click to read about Find" +++ - - # 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`. +You can also add `size` flag to narrow down results to expected filesize. Other useful flags: `user`, `group`. diff --git a/content/posts/GIT.md b/content/posts/GIT.md index a3da937..61fa570 100644 --- a/content/posts/GIT.md +++ b/content/posts/GIT.md @@ -1,12 +1,10 @@ +++ -date="2022-12-21" +date="2022-12-24" author="spanskiduh" title="GIT" description="click to read about GIT" +++ - - # GIT - If you want to revert changes made to your working copy, do this: diff --git a/content/posts/Locate.md b/content/posts/Locate.md index 5e0db30..903bd1d 100644 --- a/content/posts/Locate.md +++ b/content/posts/Locate.md @@ -1,13 +1,12 @@ +++ -date="2022-11-30" +date="2022-12-24" author="spanskiduh" title="Locate" description="click to read about Locate" +++ - - # Locate + ### Examples of locate command use whatis/man locate for more info diff --git a/content/posts/MPI.md b/content/posts/MPI.md index 0a6e48e..2ccb4bc 100644 --- a/content/posts/MPI.md +++ b/content/posts/MPI.md @@ -1,6 +1,6 @@ +++ -date="2022-12-01" +date="2022-12-24" author="spanskiduh" title="MPI" description="click to read about MPI" diff --git a/content/posts/Networking.md b/content/posts/Networking.md index 1ad1a04..551d8ea 100644 --- a/content/posts/Networking.md +++ b/content/posts/Networking.md @@ -1,30 +1,11 @@ +++ -date="2022-12-21" +date="2022-12-24" author="spanskiduh" title="Networking" description="click to read about Networking" +++ - - -# 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 // by default use ss - - -- `netstat -r` -- show routes -- `netstat -t` -- display all current tcp connections, useful with grep command -- `netstat -ltnp / -lu` list local TCP or UPD connections - -#### [netstat](https://www.cyberciti.biz/faq/linux-ip-command-examples-usage-syntax/) is deprecated: -| Old command (Deprecated) | New command | -|:--:|:-:| +--:|:-:| | ifconfig -a | ip a | | ifconfig enp6s0 down | ip link set enp6s0 down | | ifconfig enp6s0 up | ip link set enp6s0 up | diff --git a/content/posts/SSH.md b/content/posts/SSH.md index e438f0f..0061a1c 100644 --- a/content/posts/SSH.md +++ b/content/posts/SSH.md @@ -1,21 +1,16 @@ +++ -date="2022-11-30" +date="2022-12-24" author="spanskiduh" title="SSH" description="click to read about SSH" +++ - - # 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 @@ -26,11 +21,31 @@ It is *always* smart to disable root login! ### 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 +- `scp ` - copy file to server, same goes for rsync +### SSH CONFIG FILE + +example for github: +```bash +Host github.com + User git + Hostname github.com + PreferredAuthentications publickey + IdentityFile ~/.ssh/id_ed25519 +``` + +exmaple for any server: +```bash +Host vpn.de + HostName vpn.de + IdentityFile ~/.ssh/keys/vpn_de + Port 22 + User root +``` + +*note*: You should put your server's ip in `/etc/hosts/` for easier migrations. ### How to joke around with medic diff --git a/content/posts/Tracks.md b/content/posts/Tracks.md index e891069..a432fb4 100644 --- a/content/posts/Tracks.md +++ b/content/posts/Tracks.md @@ -1,12 +1,10 @@ +++ -date="2022-11-30" +date="2022-12-24" author="spanskiduh" title="Tracks" description="click to read about Tracks" +++ - - # Tracks - `/var/log` - Location of kernel and software logs diff --git a/content/posts/VFS.md b/content/posts/VFS.md index 0a9c184..5572d6f 100644 --- a/content/posts/VFS.md +++ b/content/posts/VFS.md @@ -1,6 +1,6 @@ +++ -date="2022-11-30" +date="2022-12-24" author="spanskiduh" title="VFS" description="click to read about VFS" diff --git a/content/posts/address_space.md b/content/posts/address_space.md new file mode 100644 index 0000000..15bf5bc --- /dev/null +++ b/content/posts/address_space.md @@ -0,0 +1,23 @@ + ++++ +date="2022-12-24" +author="spanskiduh" +title="address_space" +description="click to read about address_space" ++++ +# Address space + +## AS in C +``` +[code ] +[init data ] +[uninit data] +[heap ] +[ | ] +[ . ] +[ free ] +[ . ] +[ | ] +[stack ] +[args + env ] +``` diff --git a/content/posts/ansible.md b/content/posts/ansible.md index 75c7432..e1e3080 100644 --- a/content/posts/ansible.md +++ b/content/posts/ansible.md @@ -1,6 +1,6 @@ +++ -date="2022-11-30" +date="2022-12-24" author="spanskiduh" title="ansible" description="click to read about ansible" diff --git a/content/posts/bash.md b/content/posts/bash.md index 36057e2..89462b4 100644 --- a/content/posts/bash.md +++ b/content/posts/bash.md @@ -1,6 +1,6 @@ +++ -date="2022-11-30" +date="2022-12-24" author="spanskiduh" title="bash" description="click to read about bash" @@ -12,3 +12,112 @@ Gotta love those oneliners ;) ```bash while read line; do printf "$line\n"; printf "other commands\n"; done < /etc/passwd ``` + +# SHELL SHORTCUTS + +### Moving the cursor + +```bash + Ctrl + a Go to the beginning of the line (Home) + Ctrl + e Go to the End of the line (End) + Ctrl + p Previous command (Up arrow) + Ctrl + n Next command (Down arrow) + Alt + b Back (left) one word + Alt + f Forward (right) one word + Ctrl + f Forward one character + Ctrl + b Backward one character + Ctrl + xx Toggle between the start of line and current cursor position +``` + +### Editing + +```bash +Ctrl + L Clear the Screen, similar to the clear command + + Alt + Del Delete the Word before the cursor. + Alt + d Delete the Word after the cursor. + Ctrl + d Delete character under the cursor + Ctrl + h Delete character before the cursor (Backspace) + + Ctrl + w Cut the Word before the cursor to the clipboard. + Ctrl + k Cut the Line after the cursor to the clipboard. + Ctrl + u Cut/delete the Line before the cursor to the clipboard. + + Alt + t Swap current word with previous + Ctrl + t Swap the last two characters before the cursor (typo). + Esc + t Swap the last two words before the cursor. + + ctrl + y Paste the last thing to be cut (yank) + Alt + u UPPER capitalize every character from the cursor to the end of the current word. + Alt + l Lower the case of every character from the cursor to the end of the current word. + Alt + c Capitalize the character under the cursor and move to the end of the word. + Alt + r Cancel the changes and put back the line as it was in the history (revert). + ctrl + _ Undo + + TAB Tab completion for file/directory names +``` + +### Special keys + +Text Terminals send characters (bytes), not key strokes. +Special keys such as Tab, Backspace, Enter and Esc are encoded as control characters. +Control characters are not printable, they display in the terminal as ^ and are intended to have an effect on applications. + +```bash +Ctrl+I = Tab +Ctrl+J = Newline +Ctrl+M = Enter +Ctrl+[ = Escape + +Many terminals will also send control characters for keys in the digit row: +Ctrl+2 → ^@ +Ctrl+3 → ^[ Escape +Ctrl+4 → ^\ +Ctrl+5 → ^] +Ctrl+6 → ^^ +Ctrl+7 → ^_ Undo +Ctrl+8 → ^? Backward-delete-char + +Ctrl+v tells the terminal to not interpret the following character, so Ctrl+v Ctrl-I will display a tab character, +similarly Ctrl+v ENTER will display the escape sequence for the Enter key: ^M +``` + +### History + +```bash + Ctrl + r Recall the last command including the specified character(s). + searches the command history as you type. + Equivalent to : vim ~/.bash_history. + Ctrl + p Previous command in history (i.e. walk back through the command history). + Ctrl + n Next command in history (i.e. walk forward through the command history). + + Ctrl + s Go back to the next most recent command. + (beware to not execute it from a terminal because this will also launch its XOFF). + Ctrl + o Execute the command found via Ctrl+r or Ctrl+s + Ctrl + g Escape from history searching mode + !! Repeat last command + !n Repeat from the last command: args n e.g. !:2 for the second argumant. + !n:m Repeat from the last command: args from n to m. e.g. !:2-3 for the second and third. + !n:$ Repeat from the last command: args n to the last argument. + !n:p Print last command starting with n + !string Print the last command beginning with string. + !:q Quote the last command with proper Bash escaping applied. + Tip: enter a line of Bash starting with a # comment, then run !:q on the next line to escape it. + !$ Last argument of previous command. + ALT + . Last argument of previous command. + !* All arguments of previous command. +^abc­^­def Run previous command, replacing abc with def +``` + +### Process control + +```bash + Ctrl + C Interrupt/Kill whatever you are running (SIGINT). + Ctrl + l Clear the screen. + Ctrl + s Stop output to the screen (for long running verbose commands). + Then use PgUp/PgDn for navigation. + Ctrl + q Allow output to the screen (if previously stopped using command above). + Ctrl + D Send an EOF marker, unless disabled by an option, this will close the current shell (EXIT). + Ctrl + Z Send the signal SIGTSTP to the current task, which suspends it. + To return to it later enter fg 'process name' (foreground). +``` diff --git a/content/posts/binary-patching.md b/content/posts/binary-patching.md index 781e7db..73cc2d3 100644 --- a/content/posts/binary-patching.md +++ b/content/posts/binary-patching.md @@ -1,13 +1,16 @@ +++ -date="2022-11-30" +date="2022-12-24" author="spanskiduh" title="binary-patching" description="click to read about binary-patching" +++ - - # 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 + +### In vim :) +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/content/posts/binary_vs_text_files.md b/content/posts/binary_vs_text_files.md index 4db6ce8..aaf06ab 100644 --- a/content/posts/binary_vs_text_files.md +++ b/content/posts/binary_vs_text_files.md @@ -1,6 +1,6 @@ +++ -date="2022-11-30" +date="2022-12-24" author="spanskiduh" title="binary_vs_text_files" description="click to read about binary_vs_text_files" diff --git a/content/posts/burpsuite.md b/content/posts/burpsuite.md index 1975e26..7df588e 100644 --- a/content/posts/burpsuite.md +++ b/content/posts/burpsuite.md @@ -1,6 +1,6 @@ +++ -date="2022-11-30" +date="2022-12-24" author="spanskiduh" title="burpsuite" description="click to read about burpsuite" diff --git a/content/posts/certs.md b/content/posts/certs.md index 47242e1..7991f0c 100644 --- a/content/posts/certs.md +++ b/content/posts/certs.md @@ -1,10 +1,17 @@ +++ -date="2022-11-30" +date="2022-12-24" author="spanskiduh" title="certs" description="click to read about certs" +++ # CERTS -https://stackoverflow.com/questions/66604487/how-do-i-generate-fullchain-pem-and-privkey-pem + +## Generate self-signed certificate +[creds](https://stackoverflow.com/questions/66604487/how-do-i-generate-fullchain-pem-and-privkey-pem) + +```bash +openssl genrsa > privkey.pem +openssl req -new -x509 -key privkey.pem > fullchain.pem +``` diff --git a/content/posts/disk-usage.md b/content/posts/disk-usage.md index 629e447..023e81b 100644 --- a/content/posts/disk-usage.md +++ b/content/posts/disk-usage.md @@ -1,12 +1,10 @@ +++ -date="2022-11-30" +date="2022-12-24" author="spanskiduh" title="disk-usage" description="click to read about disk-usage" +++ - - # Disk usage ### Very useful tool diff --git a/content/posts/disk-utils.md b/content/posts/disk-utils.md index 563a8d6..9c2d09c 100644 --- a/content/posts/disk-utils.md +++ b/content/posts/disk-utils.md @@ -1,6 +1,6 @@ +++ -date="2022-11-30" +date="2022-12-24" author="spanskiduh" title="disk-utils" description="click to read about disk-utils" diff --git a/content/posts/docker.md b/content/posts/docker.md index 93807ca..9ae8eec 100644 --- a/content/posts/docker.md +++ b/content/posts/docker.md @@ -1,6 +1,6 @@ +++ -date="2022-11-30" +date="2022-12-24" author="spanskiduh" title="docker" description="click to read about docker" @@ -21,3 +21,198 @@ docker container ls --filter "status=exited" | awk '{ print $1 }' | xargs docker printf "Deleting all images\n" docker image ls | awk '{print $3}' | xargs docker image rm --force ``` + +## Basic config example + +```yml +# docker-compose.yml +version: '3' + +services: + web: + build: . + # build from Dockerfile + context: ./Path + dockerfile: Dockerfile + ports: + - "5000:5000" + volumes: + - .:/code + redis: + image: redis +``` + +## Common commands + +```bash +# Starts existing containers for a service. +docker-compose start + +# Stops running containers without removing them. +docker-compose stop + +# Pauses running containers of a service. +docker-compose pause + +# Unpauses paused containers of a service. +docker-compose unpause + +# Lists containers. +docker-compose ps + +# Builds, (re)creates, starts, and attaches to containers for a service. +docker-compose up + +# Stops containers and removes containers, networks, volumes, and images created by up. +docker-compose down +``` + +## Config file reference + +### Building + +```yml +web: + # build from Dockerfile + build: . + # build from custom Dockerfile + build: + context: ./dir + dockerfile: Dockerfile.dev + # build from image + image: ubuntu + image: ubuntu:14.04 + image: tutum/influxdb + image: example-registry:4000/postgresql + image: a4bc65fd +``` + +### Ports + +```yml +ports: + - "3000" + - "8000:80" # guest:host +# expose ports to linked services (not to host) +expose: ["3000"] +``` + +### Commands + +```yml +# command to execute +command: bundle exec thin -p 3000 +command: [bundle, exec, thin, -p, 3000] + +# override the entrypoint +entrypoint: /app/start.sh +entrypoint: [php, -d, vendor/bin/phpunit] +``` + +### Environment variables + +```yml +# environment vars +environment: + RACK_ENV: development +environment: + - RACK_ENV=development + +# environment vars from file +env_file: .env +env_file: [.env, .development.env] +``` + +### Dependencies + +```yml +# makes the `db` service available as the hostname `database` +# (implies depends_on) +links: + - db:database + - redis + +# make sure `db` is alive before starting +depends_on: + - db +``` + +### Other options + +```yml +# make this service extend another +extends: + file: common.yml # optional + service: webapp +volumes: + - /var/lib/mysql + - ./_data:/var/lib/mysql +``` + +## Advanced features + +### Labels + +```yml +services: + web: + labels: + com.example.description: "Accounting web app" +``` + +### DNS servers + +```yml +services: + web: + dns: 8.8.8.8 + dns: + - 8.8.8.8 + - 8.8.4.4 +``` + +### Devices + +```yml +services: + web: + devices: + - "/dev/ttyUSB0:/dev/ttyUSB0" +``` + +### External links + +```yml +services: + web: + external_links: + - redis_1 + - project_db_1:mysql +``` + +### Hosts + +```yml +services: + web: + extra_hosts: + - "somehost:192.168.1.100" +``` + +### Network + +```yml +# creates a custom network called `frontend` +networks: + frontend: +``` + +### External network + +```yml +# join a preexisting network +networks: + default: + external: + name: frontend +``` diff --git a/content/posts/emacs.md b/content/posts/emacs.md index 16d9444..3aadc0d 100644 --- a/content/posts/emacs.md +++ b/content/posts/emacs.md @@ -1,6 +1,6 @@ +++ -date="2022-12-21" +date="2022-12-24" author="spanskiduh" title="emacs" description="click to read about emacs" @@ -8,12 +8,12 @@ description="click to read about emacs" # Emacs ## Basics -`alt x` - show available commands -`space .` - show file search -`ctrl/space + w + v` - virtual split -`ctrl/space + w + w`- switch to next vsplit -`ctrl/space + w + c` - close virutal split -`space + b + k` - kill buffer -`space + b + b` - display opened buffers -`space + h + r + r` - `doom.d/init.el` reload plugins -`space + f + r` seaarch through reacently opened files +- `alt x` - show available commands +- `space .` - show file search +- `ctrl/space + w + v` - virtual split +- `ctrl/space + w + w`- switch to next vsplit +- `ctrl/space + w + c` - close virutal split +- `space + b + k` - kill buffer +- `space + b + b` - display opened buffers +- `space + h + r + r` - `doom.d/init.el` reload plugins +- `space + f + r` seaarch through reacently opened files diff --git a/content/posts/exec.md b/content/posts/exec.md index 1ed5db6..1f30a78 100644 --- a/content/posts/exec.md +++ b/content/posts/exec.md @@ -1,11 +1,13 @@ +++ -date="2022-11-30" +date="2022-12-24" author="spanskiduh" title="exec" description="click to read about exec" +++ # 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 diff --git a/content/posts/ffmpeg.md b/content/posts/ffmpeg.md index a2ec95c..7845ba4 100644 --- a/content/posts/ffmpeg.md +++ b/content/posts/ffmpeg.md @@ -1,6 +1,6 @@ +++ -date="2022-11-30" +date="2022-12-24" author="spanskiduh" title="ffmpeg" description="click to read about ffmpeg" diff --git a/content/posts/forensics.md b/content/posts/forensics.md index fe7653c..bb79cf9 100644 --- a/content/posts/forensics.md +++ b/content/posts/forensics.md @@ -1,6 +1,6 @@ +++ -date="2022-11-30" +date="2022-12-24" author="spanskiduh" title="forensics" description="click to read about forensics" diff --git a/content/posts/fork.md b/content/posts/fork.md index 6331c79..e833b44 100644 --- a/content/posts/fork.md +++ b/content/posts/fork.md @@ -1,6 +1,6 @@ +++ -date="2022-11-30" +date="2022-12-24" author="spanskiduh" title="fork" description="click to read about fork" diff --git a/content/posts/gcc.md b/content/posts/gcc.md index 6cabae4..fb100e1 100644 --- a/content/posts/gcc.md +++ b/content/posts/gcc.md @@ -1,6 +1,6 @@ +++ -date="2022-11-30" +date="2022-12-24" author="spanskiduh" title="gcc" description="click to read about gcc" @@ -12,3 +12,5 @@ description="click to read about gcc" - `-Wall` ~ enable all warnings - `-o binary` ~ output to binary file - `-S` ~ also compile asm file +- `-ffast-math` ~ faster math operations but more inaccurate +- `-march=native` ~ Compile efficently for that CPU diff --git a/content/posts/gdb.md b/content/posts/gdb.md index 571985c..fc81984 100644 --- a/content/posts/gdb.md +++ b/content/posts/gdb.md @@ -1,6 +1,6 @@ +++ -date="2022-11-30" +date="2022-12-24" author="spanskiduh" title="gdb" description="click to read about gdb" diff --git a/content/posts/hydra.md b/content/posts/hydra.md index 6013de7..71e168c 100644 --- a/content/posts/hydra.md +++ b/content/posts/hydra.md @@ -1,6 +1,6 @@ +++ -date="2022-11-30" +date="2022-12-24" author="spanskiduh" title="hydra" description="click to read about hydra" diff --git a/content/posts/lxc.md b/content/posts/lxc.md index 2ed5b10..ae6a1c8 100644 --- a/content/posts/lxc.md +++ b/content/posts/lxc.md @@ -1,6 +1,6 @@ +++ -date="2022-11-30" +date="2022-12-24" author="spanskiduh" title="lxc" description="click to read about lxc" diff --git a/content/posts/mosquitto.md b/content/posts/mosquitto.md index a923a4c..e6f151c 100644 --- a/content/posts/mosquitto.md +++ b/content/posts/mosquitto.md @@ -1,6 +1,6 @@ +++ -date="2022-11-30" +date="2022-12-24" author="spanskiduh" title="mosquitto" description="click to read about mosquitto" diff --git a/content/posts/mount.md b/content/posts/mount.md index 1978207..089f206 100644 --- a/content/posts/mount.md +++ b/content/posts/mount.md @@ -1,6 +1,6 @@ +++ -date="2022-11-30" +date="2022-12-24" author="spanskiduh" title="mount" description="click to read about mount" diff --git a/content/posts/named_pipes.md b/content/posts/named_pipes.md index 8fe2f84..32208cf 100644 --- a/content/posts/named_pipes.md +++ b/content/posts/named_pipes.md @@ -1,6 +1,6 @@ +++ -date="2022-11-30" +date="2022-12-24" author="spanskiduh" title="named_pipes" description="click to read about named_pipes" diff --git a/content/posts/nmap.md b/content/posts/nmap.md index d575d86..81cc37e 100644 --- a/content/posts/nmap.md +++ b/content/posts/nmap.md @@ -1,6 +1,6 @@ +++ -date="2022-11-30" +date="2022-12-24" author="spanskiduh" title="nmap" description="click to read about nmap" diff --git a/content/posts/pdf.md b/content/posts/pdf.md index a57f639..c125d7c 100644 --- a/content/posts/pdf.md +++ b/content/posts/pdf.md @@ -1,17 +1,20 @@ +++ -date="2022-11-30" +date="2022-12-24" author="spanskiduh" title="pdf" description="click to read about pdf" +++ # PDF MANIPULATION -## Cool tool - +### PDFTK Take individual pages out of pdf ```bash thinkpad :: ~/Downloads » pdftk Document_2022-08-14_152049.pdf cat 1 output subvencija/karmen_spagnolo.pdf thinkpad :: ~/Downloads » pdftk Document_2022-08-14_152049.pdf cat 2 output subvencija/brigita_spagnolo.pdf thinkpad :: ~/Downloads » pdftk Document_2022-08-14_152049.pdf cat 3 output subvencija/darjo_spagnolo.pdf ``` + +### Pandoc +- `pandoc -o doc.pdf doc.md` - convert md to pdf + diff --git a/content/posts/permissions.md b/content/posts/permissions.md index 54fd2db..4726145 100644 --- a/content/posts/permissions.md +++ b/content/posts/permissions.md @@ -1,6 +1,6 @@ +++ -date="2022-11-30" +date="2022-12-24" author="spanskiduh" title="permissions" description="click to read about permissions" diff --git a/content/posts/pipewire.md b/content/posts/pipewire.md index aa41b09..eb17b50 100644 --- a/content/posts/pipewire.md +++ b/content/posts/pipewire.md @@ -1,6 +1,6 @@ +++ -date="2022-11-30" +date="2022-12-24" author="spanskiduh" title="pipewire" description="click to read about pipewire" diff --git a/content/posts/powerusage.md b/content/posts/powerusage.md index 50d859e..e0c38db 100644 --- a/content/posts/powerusage.md +++ b/content/posts/powerusage.md @@ -1,12 +1,13 @@ +++ -date="2022-11-30" +date="2022-12-24" author="spanskiduh" title="powerusage" description="click to read about powerusage" +++ -# Check deatiled power usage on linux (common distros have it preinstalled) +# Check deatiled power usage on linux +## Upower (common distros have it preinstalled) ```bash upower --monitor-detail ``` diff --git a/content/posts/proces_sorting_algorithms.md b/content/posts/proces_sorting_algorithms.md index b6ca50c..1cf25b7 100644 --- a/content/posts/proces_sorting_algorithms.md +++ b/content/posts/proces_sorting_algorithms.md @@ -1,11 +1,11 @@ +++ -date="2022-11-30" +date="2022-12-24" author="spanskiduh" title="proces_sorting_algorithms" description="click to read about proces_sorting_algorithms" +++ -# Sorting algorithms +# Sorting algorithms (SL) ### FCFS Basically a fifo diff --git a/content/posts/proxmox.md b/content/posts/proxmox.md index 63284ae..3390b24 100644 --- a/content/posts/proxmox.md +++ b/content/posts/proxmox.md @@ -1,6 +1,6 @@ +++ -date="2022-11-30" +date="2022-12-24" author="spanskiduh" title="proxmox" description="click to read about proxmox" diff --git a/content/posts/pwn.md b/content/posts/pwn.md index 5233ca4..567fc67 100644 --- a/content/posts/pwn.md +++ b/content/posts/pwn.md @@ -1,6 +1,6 @@ +++ -date="2022-11-30" +date="2022-12-24" author="spanskiduh" title="pwn" description="click to read about pwn" diff --git a/content/posts/python_specifics.md b/content/posts/python_specifics.md index 7b83c2f..337a466 100644 --- a/content/posts/python_specifics.md +++ b/content/posts/python_specifics.md @@ -1,6 +1,6 @@ +++ -date="2022-11-30" +date="2022-12-24" author="spanskiduh" title="python_specifics" description="click to read about python_specifics" diff --git a/content/posts/qemu.md b/content/posts/qemu.md index 66c4cd4..b3872d4 100644 --- a/content/posts/qemu.md +++ b/content/posts/qemu.md @@ -1,6 +1,6 @@ +++ -date="2022-11-30" +date="2022-12-24" author="spanskiduh" title="qemu" description="click to read about qemu" @@ -28,3 +28,9 @@ description="click to read about qemu" -drive if=pflash,format=raw,file=QEMU_EFI.img \ -drive if=pflash,file=varstore.img \ -drive if=virtio,file=arm.img\` + + + +### VIRT MANAGER + +https://www.xmodulo.com/convert-ova-to-qcow2-linux.html diff --git a/content/posts/regex.md b/content/posts/regex.md index 31c5b2c..7c100d4 100644 --- a/content/posts/regex.md +++ b/content/posts/regex.md @@ -1,6 +1,6 @@ +++ -date="2022-11-30" +date="2022-12-24" author="spanskiduh" title="regex" description="click to read about regex" @@ -8,4 +8,6 @@ description="click to read about regex" # REGEX ### Reversing regex + +[source](https://github.com/asciimoo/exrex) `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/content/posts/rstudio.md b/content/posts/rstudio.md index fa2e25d..53cc2c4 100644 --- a/content/posts/rstudio.md +++ b/content/posts/rstudio.md @@ -1,6 +1,6 @@ +++ -date="2022-11-30" +date="2022-12-24" author="spanskiduh" title="rstudio" description="click to read about rstudio" diff --git a/content/posts/rust.md b/content/posts/rust.md index 1338631..a8708a2 100644 --- a/content/posts/rust.md +++ b/content/posts/rust.md @@ -1,15 +1,463 @@ +++ -date="2022-11-30" +date="2022-12-24" author="spanskiduh" title="rust" description="click to read about rust" +++ # RUST -### Basic cli tools +## Basic cli tools - `cargo init` ~ create new rust project - `cargo run` ~ build & run - `cargo build` ~ just build - `cargo build --release` ~ minimal release version (optimized) + +## Rust basics + + +### Arrays + +```rust +// Arrays are allocated on stack just like in C +pub fn run() { + let mut numbers: [i32; 5] = [1, 2, 3, 4, 5]; + + numbers[2] = 20; // [1, 2, 20, 4, 5] + + println!("Single value: {}", numbers[0]); // 1 + + println!("Array length: {}",numbers.len()); // 5 + + // Arrays are stack allocated + println!("Array occupies {} bytes", std::mem::size_of_val(&numbers)); // 20 bytes + + // Get slice + let sliced: &[i32] = &numbers[0..2]; + println!("Sliced: {:?}", sliced); // [1, 2] +} +``` + +### CLI arguments + +```rust +use std::env; + +pub fn run() { + let args: Vec = env::args().collect(); + let command = args[1].clone(); + let name = "spanskiduh"; + + println!("Command: {}", command); + + if command == "hello" { + println!("Hi {}, how are you?", name); + } +} +``` + +### Conditionals + +```rust +// Conditionals - Used to check the condition of something and act on the result + +pub fn run() { + let age: u8 = 18; + let check_id: bool = false; + let knows_person_of_age = true; + + // If / Else + if age >= 21 && check_id || knows_person_of_age { + println!("bartender: What would you like to drink?"); // This gets printed + } else if age < 21 && check_id{ + println!("bartender: Sorry, you have to leave."); + } else { + println!("bartender: I'll need to see your ID"); + } + + // Shorthand If (similar to terminary operator) + let is_of_age = if age >= 21 {true} else {false}; +} +``` + +### Enums + +```rust + +enum Movement { + Up, + Down, + Left, + Right +} + +fn move_avatar(m: Movement) { + match m { + Movement::Up => println!("Avatar moving up"), + Movement::Down => println!("Avatar moving down"), + Movement::Left => println!("Avatar moving left"), + Movement::Right => println!("Avatar moving right"), + } +} + +pub fn run() { + let avatar1 = Movement::Left; + let avatar2 = Movement::Up; + let avatar3 = Movement::Right; + let avatar4 = Movement::Down; + + move_avatar(avatar1); + move_avatar(avatar2); + move_avatar(avatar3); + move_avatar(avatar4); +} +``` + +### Functions + +```rust +pub fn run() { + greeting("Hello", "Jane"); + + // Bind function values to variables + let get_sum = add(5, 5); + println!("Sum: {}", get_sum); + + // Closure + let n3: i32 = 10; + let add_nums = |n1: i32, n2: i32 | n1 + n2 + n3; + println!("C Sum: {}", add_nums(3,3)); // 16 +} + +fn greeting(greet: &str, name: &str) { + println!("{} {}, nice to meet you!", greet, name); +} + +fn add(n1: i32, n2: i32) -> i32 { + n1 + n2 +} +``` + +### Loops + +```rust +// Loops - Used to iterate until a condition is met + +pub fn run(){ + + let mut count = 0; + + // Infinite Loop + loop { + count += 1; + println!("Number: {}", count); + + if count == 20 { + break; + } + } + + // While loop (FizzBuzz) + while count <= 100 { + if count % 15 == 0 { + println!("FizzBuzz"); + } else if count % 3 == 0 { + println!("Fiz"); + } else if count % 5 == 0 { + println!("Buzz"); + } else { + println!("{}", count); + } + count += 1; + } + + // For range + for x in 0..100 { + if x % 15 == 0 { + println!("FizzBuzz"); + } else if x % 3 == 0 { + println!("Fiz"); + } else if x % 5 == 0 { + println!("Buzz"); + } else { + println!("{}", x); + } + } +} +``` + +### Pointer references + +```rust +// With non-privitieves, if you assign another variable to a piece of data, the +// first varaible will no longer hold that value. You'll need to use a reference +// (&) to point to the resource. + +pub fn run() { + // Primitive array + let arr1 = [1, 2, 3]; + let arr2 = arr1; + + // Vector + let vec1 = vec![1, 2, 3]; + let vec2 = &vec1; + println!("{:?}", (arr1, arr2)); // ([1, 2, 3], [1, 2, 3]) + println!("{:?}", (&vec1, vec2)); // ([1, 2, 3], [1, 2, 3]) +} +``` + +### Format strings +```rust +pub fn run() { + // Print to console + println!("Hello from print.rs file"); + + println!("{} se uci {}", "Gasper", "rust"); + + // Positional args + println!("{0} is from {1} and {0} likes to {2}", "Gasper", "SLovEniA", "program"); + + // Named args + println!("{name} likes to play {activity}", name = "John", activity = "Tennis"); + + // Placeholder traits + println!("Binary: {:b} Hex: {:x} Octal: {:o}", 10, 10, 10); // Binary: 1010 Hex: a Octal: 12 + + // Placeholder for debug trait + println!("{:?}", (12, true, "hello")); // (12, true, "hello") + + // Basic math + println!("10 + 10 = {}", 10 + 10); +} +``` +### String manipulation + +```rust +// Primitve str = Immutable fixed-length string somewhere in memory +// String = Growable, heal-allocated data structure - Use when you need to modify +// or own strign data + +pub fn run() { + let hello = "Hello"; // Primitve + let mut growale_hello = String::from("Hello "); // Growable + + // Get string length, works for both types + println!("Length: {}", hello.len()); + + // Append, only Growable + growale_hello.push('W'); + growale_hello.push_str("orld!"); + + // Capacity in bytes (work on both) + println!("Capacity: {}", growale_hello.capacity()); + + println!("Is Empty: {}", hello.is_empty()); + println!("Is Empty: {}", growale_hello.is_empty()); + + // Substring?? + println!("{} -> Contains 'World' {}", hello, hello.contains("World")); + println!("{} -> Contains 'World' {}", growale_hello, growale_hello.contains("World")); + + // Replace + println!("Replace: {}", growale_hello.replace("World", "Bro")); + println!("Replace: {}", hello.replace("Hello", "Bye")); + + // Loop through string by whitespace + for word in growale_hello.split_whitespace() { + println!("{}", word); + } + + // Create string with predefined capacity + let mut s = String::with_capacity(10); + s.push('a'); + s.push('b'); + println!("{}", s); // ab + + // Assertion testing + assert_eq!(2, s.len()); + assert_eq!(10, s.capacity()); +} + +### Structs + +```rust +// Traditional struct +struct Color { + red: u8, + green: u8, + blue: u8, +} + +// Tuple struct +struct Color2(u8, u8, u8); + +struct Person { + first_name: String, + last_name: String +} + +impl Person { + // Construct person + fn new(first: &str, last: &str) -> Person { + Person { + first_name: first.to_string(), + last_name: last.to_string() + } + } + + // Get full name + fn full_name(&self) -> String { + format!("{} {}", self.first_name, self.last_name) + } + + // Set last name + fn set_last_name(&mut self, last:&str) { + self.last_name = last.to_string(); + } + + // Name to tuple + fn to_tuple(self) -> (String, String) { + (self.first_name, self.last_name) + } +} + +pub fn run() { + let mut c = Color { + red: 255, + green: 0, + blue: 0 + }; + + c.red = 200; + println!("color: {} {} {}", c.red, c.green, c.blue); + + let mut c2 = Color2(255, 0, 0); + + c2.0 = 200; + println!("color: {} {} {}", c2.0, c2.1, c2.2); + + let mut p = Person::new("Marry", "Doe"); + println!("Person {} {}", p.first_name, p.last_name); + p.set_last_name("Doee"); + println!("Person {}", p.full_name()); + println!("Person tuple {:?}", p.to_tuple()); +} +``` +### Tuples + +```rust + +// Max 12 elements, diffrent types allowed + +pub fn run() { + let person: (&str, &str, i8) = ("Gasper", "NG", 22); + println!("{} is from {} and is {}", person.0, person.1, person.2); +} +``` + +### Types + +```rust +pub fn run() { + // default is "i32" + let x = 1; + + // default is "f64" + let y = 2.5; + + // Add explicit type + let z: i64 = 33213123; + + // Find max size + println!("Max i32: {}", std::i32::MAX); + println!("Max i64: {}", std::i64::MAX); + + // Boolean + let is_active: bool = true; + + // Get boolean from expression + let is_greater:bool = 10 > 5; + + let a1 = 'a'; + let face = '\u{1F600}'; + + println!("{:?}", (x, y, z, is_active, is_greater, a1, face)); // (1, 2.5, 33213123, true, true, 'a', '😀') +} +``` + +### Variables + +```rust +// Variables hold primitive data or references to data +// Variables are immutable by default (u cannot reasign them) +// Rust is a block-scoped language + +pub fn run() { + let name = "Gasper"; + let mut age = 22; + let mut i_mutate: i128 = 42069; + + println!("My name is {} and I am {}", name, age); + + // Chage vaue + age = 23; + + // Define constant + const ID: i32 = 001; + + // Assign multiple vars + let (my_name, my_age) = ("Gasper", 200); + + let mut i = 0; + while i < 10 { + i_mutate = i_mutate + 420; + println!("Value: {}", i_mutate); + i = i + 1; + } +} +``` + +### Vectors + +```rust + +// Vectors are resizable arrays stored on a heap +use std::mem; + +pub fn run() { + let mut numbers: Vec = vec![1, 2, 3, 4, 5]; + + // Assign a value + numbers[2] = 20; + // Add on to a vector + numbers.push(5); + numbers.push(6); + + // Pop off last value + numbers.pop(); // [1, 2, 20, 4, 5, 5] + + println!("Single value: {}", numbers[0]); // 1 + + println!("Vector length: {}",numbers.len()); // 6 + + // Vectors are heap allocated + println!("Vector occupies {} bytes", mem::size_of_val(&numbers)); // 24 + + // Get slice + let sliced: &[i32] = &numbers[0..2]; + + println!("Sliced: {:?}", sliced); // Sliced: [1, 2] + + // Loop through vector values + for x in numbers.iter() { + println!("Number: {}", x); + } + + // Loop and mutate values + for x in numbers.iter_mut() { + *x *= 2; + } // [2, 4, 40, 8, 10, 10] +} +``` + diff --git a/content/posts/services-and-process-management.md b/content/posts/services-and-process-management.md index a6338dd..125eabe 100644 --- a/content/posts/services-and-process-management.md +++ b/content/posts/services-and-process-management.md @@ -1,12 +1,10 @@ +++ -date="2022-11-30" +date="2022-12-24" author="spanskiduh" title="services-and-process-management" description="click to read about services-and-process-management" +++ - - # Services and process management ### PS command diff --git a/content/posts/squid.md b/content/posts/squid.md index a3c7716..a676618 100644 --- a/content/posts/squid.md +++ b/content/posts/squid.md @@ -1,6 +1,6 @@ +++ -date="2022-11-30" +date="2022-12-24" author="spanskiduh" title="squid" description="click to read about squid" diff --git a/content/posts/symlinks.md b/content/posts/symlinks.md index 4fa262e..d9ff33e 100644 --- a/content/posts/symlinks.md +++ b/content/posts/symlinks.md @@ -1,6 +1,6 @@ +++ -date="2022-11-30" +date="2022-12-24" author="spanskiduh" title="symlinks" description="click to read about symlinks" diff --git a/content/posts/tmux.md b/content/posts/tmux.md index 2840685..76b4e97 100644 --- a/content/posts/tmux.md +++ b/content/posts/tmux.md @@ -1,12 +1,10 @@ +++ -date="2022-12-21" +date="2022-12-24" author="spanskiduh" title="tmux" description="click to read about tmux" +++ - - # Tmux ### Window operations diff --git a/content/posts/uart.md b/content/posts/uart.md index 7a8d95e..08fb214 100644 --- a/content/posts/uart.md +++ b/content/posts/uart.md @@ -1,12 +1,10 @@ +++ -date="2022-11-30" +date="2022-12-24" author="spanskiduh" title="uart" description="click to read about uart" +++ - - # Connect to uart - `sudo dmesg | grep tty` - find uart device - `sudo minicom -D /dev/ttyACM0 -b 115200` - connect to uart device diff --git a/content/posts/ufw.md b/content/posts/ufw.md index e2c4a8d..cc65ce0 100644 --- a/content/posts/ufw.md +++ b/content/posts/ufw.md @@ -1,13 +1,11 @@ +++ -date="2022-11-30" +date="2022-12-24" author="spanskiduh" title="ufw" description="click to read about ufw" +++ - - -# ufw +# UFW ### Connections - `sudo ufw status numbered verbose` - check ufw status diff --git a/content/posts/vim_tutor.md b/content/posts/vim_tutor.md index ff34d37..7a8a0ba 100644 --- a/content/posts/vim_tutor.md +++ b/content/posts/vim_tutor.md @@ -1,6 +1,6 @@ +++ -date="2022-11-30" +date="2022-12-24" author="spanskiduh" title="vim_tutor" description="click to read about vim_tutor" diff --git a/content/posts/wasm.md b/content/posts/wasm.md index 2e5fa4b..223d23f 100644 --- a/content/posts/wasm.md +++ b/content/posts/wasm.md @@ -1,24 +1,23 @@ +++ -date="2022-11-30" +date="2022-12-24" author="spanskiduh" title="wasm" description="click to read about wasm" +++ # 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 +- `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 diff --git a/content/posts/wl-mirror.md b/content/posts/wl-mirror.md index ac4a7b4..dd51641 100644 --- a/content/posts/wl-mirror.md +++ b/content/posts/wl-mirror.md @@ -1,11 +1,11 @@ +++ -date="2022-11-30" +date="2022-12-24" author="spanskiduh" title="wl-mirror" description="click to read about wl-mirror" +++ -# WL-mirror +# WL-mirror (wayland exclusive for managing displays) ## To list all outputs diff --git a/content/posts/yaml.md b/content/posts/yaml.md index f4fa85b..50be5a7 100644 --- a/content/posts/yaml.md +++ b/content/posts/yaml.md @@ -1,6 +1,6 @@ +++ -date="2022-11-30" +date="2022-12-24" author="spanskiduh" title="yaml" description="click to read about yaml"