This shows you the differences between two versions of the page.
Both sides previous revisionPrevious revisionNext revision | Previous revisionNext revisionBoth sides next revision | ||
onny:notizen [2022/09/21 12:37] – [partitioning] 10.25.0.100 | onny:notizen [2024/01/31 18:39] – [nixos] 127.0.0.1 | ||
---|---|---|---|
Line 1: | Line 1: | ||
- | ===== kernel ===== | ||
- | |||
- | grep kernel config running system | ||
- | <code bahs> | ||
- | zcat / | ||
- | </ | ||
- | |||
- | ===== fish ===== | ||
- | |||
- | unset history | ||
- | < | ||
- | fish --private | ||
- | </ | ||
===== bash ===== | ===== bash ===== | ||
Line 101: | Line 88: | ||
chmod +x $FILE | chmod +x $FILE | ||
$FILE " | $FILE " | ||
- | </ | ||
- | ==== sed ==== | ||
- | Mit sed inplace eine Zeile zu einer Datei hinzufügen: | ||
- | <code bash> | ||
- | sed -i ' | ||
- | </ | ||
- | add to end of file | ||
- | <code bash> | ||
- | sed -i -e ' | ||
- | </ | ||
- | Comment out specific line matching a string | ||
- | <code bash> | ||
- | sudo sed -e '/ | ||
- | </ | ||
- | comment out multiple lines / range | ||
- | <code bash> | ||
- | sed -i "28,33 s/# *//" autogen.sh | ||
- | </ | ||
- | regex parse value of xml tags | ||
- | <code bash> | ||
- | sed -n ' | ||
- | </ | ||
- | delete multiple lines | ||
- | <code bash> | ||
- | sed -i ' | ||
</ | </ | ||
- | insert line after match | ||
- | <code bash> | ||
- | sed '/ | ||
- | </ | ||
==== grep ==== | ==== grep ==== | ||
regex match group | regex match group | ||
Line 163: | Line 121: | ||
fd '[^A-Z a-züö@0-9._-]' | fd '[^A-Z a-züö@0-9._-]' | ||
</ | </ | ||
- | ==== rg ==== | ||
- | filter file type | ||
- | <code bash> | ||
- | rg GPIO_CFG_2MA -g ' | ||
- | </ | ||
- | |||
- | search file containing multiple strings/ | ||
- | |||
- | <code bash> | ||
- | rg -lU --multiline-dotall ' | ||
- | </ | ||
- | |||
- | ==== curl ==== | ||
- | post data | ||
- | <code bash> | ||
- | curl --data " | ||
- | </ | ||
- | download and extract archive | ||
- | <code bash> | ||
- | curl http:// | ||
- | </ | ||
- | set host header | ||
- | <code bash> | ||
- | torify curl --header "Host: http.pi" | ||
- | </ | ||
- | ==== tcpdump ==== | ||
- | specific ports | ||
- | <code bash> | ||
- | tcpdump -i eth0 -q '(tcp port 80) or (tcp port 443)' -A | ||
- | </ | ||
- | exclude specific host | ||
- | <code bash> | ||
- | tcpdump -i eth0 -q '(ip or ip6) and (tcp port 80) or (tcp port 443) and not host ifconfig.co' | ||
- | </ | ||
==== patching ==== | ==== patching ==== | ||
=== appling === | === appling === | ||
Line 243: | Line 167: | ||
</ | </ | ||
===== networking ===== | ===== networking ===== | ||
- | netcat | ||
- | <code bash> | ||
- | netcat -l 4444 | ||
- | </ | ||
- | <code bash> | ||
- | netcat playground.pi 4444 | ||
- | </ | ||
==== nftables ==== | ==== nftables ==== | ||
<code bash> | <code bash> | ||
Line 291: | Line 208: | ||
iptables -t nat -A OUTPUT -p tcp --dport 2222 -j DNAT --to 192.168.1.2: | iptables -t nat -A OUTPUT -p tcp --dport 2222 -j DNAT --to 192.168.1.2: | ||
</ | </ | ||
- | </ | ||
- | ==== ip ==== | ||
- | set address | ||
- | <code bash> | ||
- | ip address add dev usb0 172.16.42.1/ | ||
- | ip link set usb0 up | ||
- | </ | ||
- | route command example | ||
- | <code bash> | ||
- | ip route add 192.168.1.0/ | ||
- | ip route add default via 192.168.1.1 | ||
- | </ | ||
- | flush addresses | ||
- | <code bash> | ||
- | ip addr flush dev enp8s0 | ||
- | </ | ||
- | remove interface | ||
- | <code bash> | ||
- | ip link delete br0 | ||
- | </ | ||
- | delete address | ||
- | <code bash> | ||
- | ip addr del 192.168.178.20/ | ||
- | </ | ||
- | show only specific interface | ||
- | <code bash> | ||
- | ip a show wg0 | ||
</ | </ | ||
- | change mtu | ||
- | <code bash> | ||
- | ip link set dev eth0 mtu 1400 | ||
- | </ | ||
==== dnsmasq ==== | ==== dnsmasq ==== | ||
minimal hostapd and dnsmasq config | minimal hostapd and dnsmasq config | ||
Line 486: | Line 372: | ||
* iodine dns tunnel https:// | * iodine dns tunnel https:// | ||
* command searchsploit in exploitdb | * command searchsploit in exploitdb | ||
+ | * NixOS for Pentesting Overview https:// | ||
===== chromium / chrome ===== | ===== chromium / chrome ===== | ||
Line 493: | Line 380: | ||
</ | </ | ||
===== docker ===== | ===== docker ===== | ||
- | Short example | + | |
+ | Pull | ||
<code bash> | <code bash> | ||
- | sudo systemctl start docker | + | docker |
- | gpasswd -a onny docker | + | docker |
- | | + | |
- | | + | |
</ | </ | ||
+ | |||
+ | Run | ||
+ | <code bash> | ||
+ | docker run -td ubuntu: | ||
+ | </ | ||
+ | |||
+ | Executing | ||
+ | <code bash> | ||
+ | docker exec -it ffffdfdfsdfsdfsfsffsdfs /bin/bash | ||
+ | </ | ||
+ | |||
+ | Nextcloud | ||
+ | <code bash> | ||
+ | docker run -d -p 80:80 rootlogin/ | ||
+ | docker run -v / | ||
+ | </ | ||
+ | |||
Debugging it | Debugging it | ||
<code bash> | <code bash> | ||
Line 505: | Line 408: | ||
| | ||
</ | </ | ||
+ | |||
Pull from repository | Pull from repository | ||
< | < | ||
Line 515: | Line 419: | ||
| | ||
</ | </ | ||
- | Pull specific tagged image | + | |
- | <code bash> | + | |
- | docker pull rootlogin/ | + | |
- | </ | + | |
Build from Dockerfile | Build from Dockerfile | ||
< | < | ||
Line 542: | Line 443: | ||
docker system prune -a | docker system prune -a | ||
</ | </ | ||
- | docker stop all container | + | |
- | <code bash> | + | |
- | docker stop (docker ps -a -q) | + | |
- | </ | + | |
prevent from auto start | prevent from auto start | ||
+ | |||
<code bash> | <code bash> | ||
docker update --restart=no client-iaro_db_1 | docker update --restart=no client-iaro_db_1 | ||
Line 938: | Line 837: | ||
</ | </ | ||
* check spamminess of email server: https:// | * check spamminess of email server: https:// | ||
- | * manual imap login | + | |
- | openssl imaps login | + | |
- | < | + | |
- | openssl s_client -connect mail.sexypump.de: | + | |
- | A login cypherpunk cypherpunk | + | |
- | </ | + | |
- | get quota | + | |
- | < | + | |
- | a GETQUOTAROOT INBOX | + | |
- | </ | + | |
- | get msg count of folder | + | |
- | < | + | |
- | a LIST INBOX * | + | |
- | * LIST (\HasChildren) " | + | |
- | * LIST (\HasNoChildren \UnMarked) " | + | |
- | * LIST (\HasNoChildren \UnMarked) " | + | |
- | * LIST (\HasNoChildren \UnMarked \Trash) " | + | |
- | * LIST (\HasNoChildren \UnMarked \Sent) " | + | |
- | * LIST (\HasNoChildren \UnMarked) " | + | |
- | * LIST (\HasNoChildren \UnMarked \Junk) " | + | |
- | * LIST (\HasNoChildren \UnMarked \Drafts) " | + | |
- | * LIST (\HasNoChildren \UnMarked) " | + | |
- | a OK List completed (0.001 + 0.000 secs). | + | |
- | a SELECT INBOX | + | |
- | </ | + | |
send smtp mail | send smtp mail | ||
< | < | ||
Line 1322: | Line 1197: | ||
<code bash> | <code bash> | ||
nix run nixpkgs# | nix run nixpkgs# | ||
+ | nix run github: | ||
nix shell nixpkgs# | nix shell nixpkgs# | ||
</ | </ | ||
Line 1349: | Line 1225: | ||
< | < | ||
- | let | + | nixpkgs.config.packageOverrides = pkgs: rec { |
- | + | unstable = import unstableTarball { }; | |
- | # FIXME | + | opensnitch = unstable.opensnitch; |
- | unstableTarball = | + | }; |
- | fetchTarball | + | |
- | https:// | + | |
- | + | ||
- | in | + | |
- | { | + | |
- | + | ||
- | disabledModules = [ " | + | |
- | + | ||
- | imports = [ | + | |
- | " | + | |
- | / | + | |
- | ]; | + | |
- | | + | |
- | unstable = import unstableTarball { }; | + | |
- | opensnitch = unstable.opensnitch; | + | |
- | }; | + | |
- | # | + | |
</ | </ | ||
Line 1401: | Line 1260: | ||
''; | ''; | ||
}); | }); | ||
- | </ | ||
- | |||
- | use local src / source | ||
- | |||
- | < | ||
- | src = "/ | ||
- | dontUnpack = true; | ||
- | | ||
- | unpackPhase = '' | ||
</ | </ | ||
Line 1448: | Line 1298: | ||
}); | }); | ||
}) | }) | ||
- | ]; | ||
- | </ | ||
- | |||
- | fetchpatch | ||
- | |||
- | < | ||
- | patches = [ | ||
- | # Support HBPL1 printers https:// | ||
- | ./ | ||
- | |||
- | # Fix " | ||
- | # https:// | ||
- | (fetchpatch { | ||
- | url = " | ||
- | sha256 = " | ||
- | stripLen = 1; | ||
- | name = " | ||
- | }) | ||
- | |||
]; | ]; | ||
</ | </ | ||
Line 1506: | Line 1337: | ||
<code bash> | <code bash> | ||
QEMU_NET_OPTS=" | QEMU_NET_OPTS=" | ||
+ | sudo -E QEMU_NET_OPTS=" | ||
</ | </ | ||
Line 1818: | Line 1650: | ||
''; | ''; | ||
</ | </ | ||
+ | |||
==== nixops ==== | ==== nixops ==== | ||
Line 1871: | Line 1704: | ||
<code bash> | <code bash> | ||
fatlabel /dev/sdb1 " | fatlabel /dev/sdb1 " | ||
- | </ | ||
- | |||
- | grow ext4 partition live | ||
- | <code bash> | ||
- | $ growpart /dev/sda 2 | ||
- | $ resize2fs /dev/sda2 | ||
</ | </ | ||
Line 1965: | Line 1792: | ||
</ | </ | ||
- | ===== avahi ===== | + | |
- | discover local services | + | |
- | <code bash> | + | |
- | avahi-browse --all --ignore-local --resolve --terminate | + | |
- | </ | + | |
===== curlftpfs ===== | ===== curlftpfs ===== | ||
<code bash> | <code bash> | ||
Line 2153: | Line 1976: | ||
===== postgresql ===== | ===== postgresql ===== | ||
+ | |||
+ | list all databases | ||
+ | <code bash> | ||
+ | sudo -u postgres psql | ||
+ | # \l | ||
+ | </ | ||
+ | |||
+ | drop database | ||
+ | <code bash> | ||
+ | sudo -u postgres psql | ||
+ | # drop database gitlabhq_production; | ||
+ | # drop database gitlabhq_production WITH (FORCE); | ||
+ | </ | ||
+ | |||
+ | list tables | ||
+ | <code bash> | ||
+ | sudo -u postgres psql | ||
+ | # \c gitlabhq_production | ||
+ | # \dt | ||
+ | </ | ||
+ | |||
+ | create and delete user | ||
+ | < | ||
+ | DROP ROLE gitlab; | ||
+ | CREATE USER gitlab WITH PASSWORD ' | ||
+ | </ | ||
+ | |||
+ | grant permissions | ||
+ | < | ||
+ | ALTER USER gitlab SUPERUSER; | ||
+ | CREATE DATABASE gitlabhq_production OWNER gitlab; | ||
+ | ALTER DATABASE gitlabhq_production OWNER TO gitlab; | ||
+ | </ | ||
dump database | dump database | ||
Line 2170: | Line 2026: | ||
</ | </ | ||
- | ===== mysql ===== | ||
- | Dump database | ||
- | <code bash> | ||
- | mysqldump -u root -p Tutorials > tut_backup.sql | ||
- | </ | ||
- | |||
- | Backup everything | ||
- | <code bash> | ||
- | mysqldump -u root -p --all-databases > alldb.sql | ||
- | # in case of nextcloud | ||
- | mysqldump -u root -p --all-databases --default-character-set=utf8mb4 > alldb.sql | ||
- | </ | ||
- | |||
- | Import database | ||
- | < | ||
- | mysql> CREATE DATABASE wordpress; | ||
- | sudo mysql -u root wordpress < wordpress.sql | ||
- | </ | ||
- | |||
- | Setup | ||
- | <code bash> | ||
- | systemctl stop mysqld | ||
- | mysql_install_db --user=mysql --basedir=/ | ||
- | systemctl start mysqld | ||
- | mysql_secure_installation | ||
- | </ |