first commit
commit
1a6f74c030
|
@ -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
|
|
@ -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 <file.zip> -d <destination_dir>` - unzip
|
||||
-`zip -r {filename.zip} {foldername}` -zip
|
||||
|
||||
|
||||
### 7zip archives
|
||||
- `7z x <file.7z>` - unzip
|
||||
|
|
@ -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 <file.extension> <url>` -download with new filename
|
||||
- `curl -O <url>` - 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
|
|
@ -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`
|
|
@ -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`.
|
|
@ -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`
|
|
@ -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 !
|
|
@ -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`
|
|
@ -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 <server-ip>` - 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 <filename> <user@server_ip:/destination_folder>` - copy file to server
|
|
@ -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
|
|
@ -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
|
|
@ -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
|
|
@ -0,0 +1,16 @@
|
|||
# Adress space
|
||||
|
||||
## AS in C
|
||||
```
|
||||
[code ]
|
||||
[init data ]
|
||||
[uninit data]
|
||||
[heap ]
|
||||
[ | ]
|
||||
[ . ]
|
||||
[ free ]
|
||||
[ . ]
|
||||
[ | ]
|
||||
[stack ]
|
||||
[args + env ]
|
||||
```
|
|
@ -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
|
||||
```
|
|
@ -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`
|
||||
|
|
@ -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
|
|
@ -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
|
||||
|
|
@ -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
|
||||
```
|
|
@ -0,0 +1,3 @@
|
|||
|
||||
### Pandoc
|
||||
- `pandoc -o doc.pdf doc.md` - convert md to pdf
|
|
@ -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
|
||||
|
|
@ -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`
|
|
@ -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
|
|
@ -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()`.
|
|
@ -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
|
|
@ -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 <number>` ~ 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
|
|
@ -0,0 +1,10 @@
|
|||
# Mosquitto
|
||||
|
||||
Very nice IOT messaging protocol.
|
||||
|
||||
### How to publish and subscribe to mqtt messages:
|
||||
|
||||
#### Publish
|
||||
`mosquitto_pub -h <host-ip> -p <host-port> -u <username> -P <password> -t <topic> -m '<message>'`
|
||||
#### Subscribe
|
||||
`mosquitto_sub -h <host-ip> -p <host-port> -u <username> -P <password> -t <topic>`
|
|
@ -0,0 +1,4 @@
|
|||
# Mount
|
||||
|
||||
### Mount windows partition
|
||||
`sudo mount -t ntfs3 /dev/sdb1 /mnt/usb`
|
|
@ -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
|
|
@ -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
|
||||
```
|
|
@ -0,0 +1,4 @@
|
|||
# PIPEWIRE
|
||||
|
||||
### Fix for sony
|
||||
`https://gitlab.freedesktop.org/pipewire/pipewire/-/issues/688`
|
|
@ -0,0 +1,4 @@
|
|||
# PWN
|
||||
|
||||
## Format1
|
||||
- `%12$p` ~ display value of offset 12
|
|
@ -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\`
|
|
@ -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
|
|
@ -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)
|
|
@ -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 <pid>` - kill process with provided pid, provided by `ps` command
|
||||
- `pkill <process-name>` - kill process by name :sunglasses:
|
||||
|
||||
## on systemd u can also
|
||||
- `systemctl | grep <service_name>` - display all running services or grep one
|
||||
- `sudo systemctl is-enabled ssh` - check if service is enabled
|
|
@ -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
|
|
@ -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;
|
||||
}
|
||||
```
|
|
@ -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)
|
|
@ -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
|
|
@ -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
|
|
@ -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 <rule-id>` - delete rule from ufw, get id with status command
|
|
@ -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
|
Loading…
Reference in New Issue