Next revision
|
Previous revision
|
os:unix-commands [2022/01/26 11:38] 127.0.0.1 external edit |
os:unix-commands [2024/07/17 22:16] (current) tomas [sitove nastroje] |
wget http://www.seznam.cz ... stahne html stranku do soubrou\\ | wget http://www.seznam.cz ... stahne html stranku do soubrou\\ |
[[http://curl.haxx.se/docs/manual.html|curl]] -u user:passwd ftp:%%//%%machine.domain:port/full/path/to/file ... stahne soubor s ftp serveru\\ | [[http://curl.haxx.se/docs/manual.html|curl]] -u user:passwd ftp:%%//%%machine.domain:port/full/path/to/file ... stahne soubor s ftp serveru\\ |
curl -u username: %%--%%key ~/.ssh/id_dsa --pubkey ~/.ssh/id_dsa.pub scp:%%//%%shell.example.com/~/personal.txt ... stahne soubor pres ssh\\ | curl -u username: %%--key ~/.ssh/id_dsa --pubkey ~/.ssh/id_dsa.pub scp://%%shell.example.com/~/personal.txt ... stahne soubor pres ssh\\ |
curl %%--%%ftp-ssl ftp:%%//%%files.are.secure.com/secrets.txt ... stahovani pres sftp\\ | curl %%--ftp-ssl ftp://%%files.are.secure.com/secrets.txt ... stahovani pres sftp\\ |
curl -u user:passwd -x my-proxy:888 http:%%//%%www.get.this/ ... stahovani pres proxy\\ | curl -u user:passwd -x my-proxy:888 http:%%//%%www.get.this/ ... stahovani pres proxy\\ |
curl -o aaa.html http:%%//%%mypage.org/bbb.html ... ukozi stranku do souboru aaa.html | curl -o aaa.html http:%%//%%mypage.org/bbb.html ... ukozi stranku do souboru aaa.html |
curl -O http:%%//%%www.seznam.cz ... stahne stranku do souboru\\ | curl -O http:%%//%%www.seznam.cz ... stahne stranku do souboru\\ |
curl -T - http:%%//%%www.upload.com/myfile ... nahraje standartni vstup na stranku (Musti tam byt "PUT" znacka)\\ | curl -T - http:%%//%%www.upload.com/myfile ... nahraje standartni vstup na stranku (Musti tam byt "PUT" znacka)\\ |
curl -d "name=Rafael%20Sagula&phone=3320780" http:%%//%%www.where.com/guest.cgi Posle metodou POST data\\ | curl %%-d "name=Rafael%20Sagula&phone=3320780" http://%%www.where.com/guest.cgi Posle metodou POST data\\ |
curl -X POST -H "Content-Type: application/json" -d {name=a; password=b} ... posilani JSONu\\ | curl -X POST -H "Content-Type: application/json" -d {name=a; password=b} ... posilani JSONu\\ |
curl -F "file=@cooltext.txt" -F "yourname=Daniel" -F "filedescription=Cool text file with cool text inside" http:%%//%%www.post.com/postit.cgi ... odesle soubor a vyplni pole na strance\\ | curl %%-F "file=@cooltext.txt" -F "yourname=Daniel" -F "filedescription=Cool text file with cool text inside" http://www.post.com/postit.cgi%% ... odesle soubor a vyplni pole na strance\\ |
curl -A 'Mozilla/3.0 (Win95; I)' http:%%//%%www.nationsbank.com/ ... tvari se jako mozilla\\ | curl -A 'Mozilla/3.0 (Win95; I)' http:%%//%%www.nationsbank.com/ ... tvari se jako mozilla\\ |
curl %%--%%verbose %%--%%header 'Host: www.example.com' 'http:%%//%%10.1.1.36:8000/the_url_to_test' … Pouziti virtualni domeny na IP adrese\\ | curl %%--verbose --header 'Host: www.example.com' 'http://10.1.1.36:8000/the_url_to_test'%% … Pouziti virtualni domeny na IP adrese\\ |
curl -w "$i: %{time_total} %{http_code} %{size_download} %{url_effective}\n" -o "/dev/null" -s http://address.cz/test.html ... vypis custom informaci k requestu (cas odezvy, http kod, velikost) - dobre pro performance testy\\ | curl %%-w "$i: %{time_total} %{http_code} %{size_download} %{url_effective}\n" -o "/dev/null" -s http://address.cz/test.html%% ... vypis custom informaci k requestu (cas odezvy, http kod, velikost) - dobre pro performance testy\\ |
| |
| |
${variable:start:length} ... Vypise z promenne lenght znaku zacinajicich na pozici start\\ | ${variable:start:length} ... Vypise z promenne lenght znaku zacinajicich na pozici start\\ |
env ... zobrazi promenne prostredi\\ | env ... zobrazi promenne prostredi\\ |
| envsubst <vstup.txt >vystup.txt ... vysubstituuje text $X a ${X} za hodnoty systémových proměnných\\ |
export AAA ... promennou AAA vyexportuje pro potomky\\ | export AAA ... promennou AAA vyexportuje pro potomky\\ |
exit 0 ... ukonci skript/shell s return codem 0\\ | exit 0 ... ukonci skript/shell s return codem 0\\ |
| |
| |
<b>sitove nastroje</b>\\ | ====sitove nastroje==== |
[[http://www.g-loaded.eu/2006/11/06/netcat-a-couple-of-useful-examples/|nc]] ... netcat\\ | [[http://www.g-loaded.eu/2006/11/06/netcat-a-couple-of-useful-examples/|nc]] ... netcat\\ |
<code> | |
nc -vz -w3 -n 129.39.133.239 9497 ... otestuje, zda je na adrese 129.39.133.239 otevreny port 9495, timeou 3 sec\\ | nc -vz -w3 -n 129.39.133.239 9497 ... otestuje, zda je na adrese 129.39.133.239 otevreny port 9495, timeou 3 sec\\ |
nc -l 3333 ... posloucha na portu 3333 | nc -l 3333 ... posloucha na portu 3333\\ |
nc 1.2.3.4 3333 ... posila na port 3333 | nc 1.2.3.4 3333 ... posila na port 3333\\ |
Transfering files | |
cat backup.iso | nc -l 3333 | |
nc 192.168.0.1 3333 > backup.iso | |
Transfering - pkazuje progress | |
cat backup.iso | pv -b | nc -l 3333 | |
nc 192.168.0.1 3333 | pv -b > backup.iso | |
Zalohovani | |
dd if=/dev/hdb5 | gzip -9 | nc -l 3333 | |
nc 192.168.0.1 3333 | pv -b > myhdb5partition.img.gz | |
tar -czf - /etc/ | nc -l 3333 | |
nc 192.168.0.1 3333 | pv -b > mybackup.tar.gz | |
Bezpecnost | |
cat backup.iso | nc -l 3333 | |
ssh -f -L 23333:127.0.0.1:3333 me@192.168.0.1 sleep 10; \ | |
nc 127.0.0.1 23333 | pv -b > backup.iso | |
| |
like telnet | ==Transfering files== |
nc abc.cz 22 | cat backup.iso | nc -l 3333\\ |
| nc 192.168.0.1 3333 > backup.iso\\ |
| |
Port scanned: | ==Transfering - pkazuje progress== |
nc -z 192.168.0.1 80-90 | cat backup.iso | pv -b | nc -l 3333\\ |
| nc 192.168.0.1 3333 | pv -b > backup.iso\\ |
| |
Presmerovani shellu na port: | ==Zalohovani== |
nc -l -p 12345 -e /bin/bash | dd if=/dev/hdb5 | gzip -9 | nc -l 3333\\ |
| nc 192.168.0.1 3333 | pv -b > myhdb5partition.img.gz\\ |
| tar -czf - /etc/ | nc -l 3333\\ |
| nc 192.168.0.1 3333 | pv -b > mybackup.tar.gz\\ |
| |
nc jako proxy: | ==Bezpecnost== |
nc -l -p 12345 | nc tomas.lipensky.cz 80 | nc -l 123456 | cat backup.iso | nc -l 3333\\ |
| ssh -f -L 23333:127.0.0.1:3333 me@192.168.0.1 sleep 10; \\ |
| nc 127.0.0.1 23333 | pv -b > backup.iso\\ |
| |
Otevre tunel pres proxy: | |
nc -X 4 -x 129.39.133.102:1080 192.168.13.44 22 | nc abc.cz 22 #... jako telnet\\ |
</code> | nc -z 192.168.0.1 80-90 #... Port scanner\\ |
| nc -l -p 12345 -e /bin/bash #... Presmerovani shellu na port\\ |
| nc -l -p 12345 | nc tomas.lipensky.cz 80 | nc -l 123456 #... nc jako proxy - port worwarder\\ |
| nc -X 4 -x 129.39.133.102:1080 192.168.13.44 22 #... Otevre tunel pres proxy\\ |
| |
ssh-keygen -t rsa -b 2048 -f ~/.ssh/id_muj ... vyganeruje RSA klic pro SSH\\ | ssh-keygen -t rsa -b 2048 -f ~/.ssh/id_muj ... vyganeruje RSA klic pro SSH\\ |
ssh-keygen -lf ~/.ssh/id_muj.pub ... ukaze fingerprint klice - ukazuje se pri veborse loging v auth.log\\ | ssh-keygen -lf ~/.ssh/id_muj.pub ... ukaze fingerprint klice - ukazuje se pri veborse loging v auth.log\\ |
| ssh-keygen -R SERVERNAME ... smaže s known_hosts\\ |
ssh-agent bash ... spust bash s ssh-agentem, ktery umi nahrat do pameti hesla ke klicum\\ | ssh-agent bash ... spust bash s ssh-agentem, ktery umi nahrat do pameti hesla ke klicum\\ |
ssh-add ~/.ssh/id_muj ... po zadani hesla umozni pouzivat certifikat bez hesla\\ | ssh-add ~/.ssh/id_muj ... po zadani hesla umozni pouzivat certifikat bez hesla\\ |
ssh -X server ... povoli X11 forwarding, nastavi DISPALY a xauth. X11Forwarding musi byt povoleno v /etc/ssh/sshd_config. Pri sudo se musi pouzit xauth\\ | ssh -X server ... povoli X11 forwarding, nastavi DISPALY a xauth. X11Forwarding musi byt povoleno v /etc/ssh/sshd_config. Pri sudo se musi pouzit xauth\\ |
xauth add $(xauth -f ~USER/.Xauthority list|tail -1) ... nastavi xauth pro forwardovani X11 packetu\\ | xauth add $(xauth -f ~USER/.Xauthority list|tail -1) ... nastavi xauth pro forwardovani X11 packetu\\ |
| autossh -X -L 5432:remote_DB_server:5432 -R 873:local_RSYNC_server:873 user@remote_ssh_server ... jako ssh -L -R (socks proxy), ale obnovuje tunel po skončení sezení\\ |
| |