linux:al-admin

AL-ADMIN (Administrator Linuksa)

Informacje o kursie na stronie kursu.

Programowanie w powłoce - przykłady skryptów

Sztuczki:

  • Znajdź nowe pliki (stworzone co najwyżej dwa dni temu). I pokaż 10 największych:
sudo find /home ! -mtime +1 -type f -printf "%s %p\n" 2> /dev/null | sort -nr | head -n10
  • Zrzucanie ruchu sieciowego
#!/bin/sh
 
while true; do
	PLIK="/var/tmp/zrzut-`date +%s`.cap"
	logger "Starting tshark at: $PLIK"
	tshark -w $PLIK -c 1000 -R 'http.request.method == "POST"' 'tcp port 80' -i eth1 > /dev/null 2>&1 
	logger "Tshark exited with $?: $PLIK"
done

SSL

Absolutnie najszybsza metoda generowania samo-podpisanego certyfikatu SSL (i klucza).

openssl req -new -x509 -days 3650 \
  -newkey rsa:2048 -nodes -keyout test.key \
  -out test.crt \
  -subj '/C=PL/ST=mazowieckie/O=Akademia Linuksa/OU=kurs/CN=test'

Certyfikaty SSL w Fedorze (13).

Certyfikat samopodpisany

openssl req -new -out prosba.pem -keyout klucz.pem
openssl rsa -in klucz.pem -out www.key
openssl req -x509 -in prosba.pem -out www.crt -key www.key -days 3650

Konfiguracja Apache-a

sudo cp www.crt www.key /etc/httpd/
yum install mod_ssl

Plik konfiguracyjny: /etc/httpd/conf.d/ssl.conf

...
SSLCertificateFile /etc/httpd/www.crt
SSLCertificateKeyFile /etc/httpd/www.key
...

Centrum autoryzacji

cd  /etc/pki/tls/misc/
./CA -newca
./CA -newreq
./CA -sign
openssl rsa -in newkey.pem -out key.pem

certyfikat - newcert.pem; klucz - key.pem; certyfikat centrum do zainstalowania w przeglądrace: /etc/pki/CA/cacert.pem

Wi-Fi

Kilka przydatnych komend:

airodump-ng --ivs --write file_name --channel 11 wlan0
aireplay-ng -3 -b 00:16:B6:2E:C3:4E -h 00:14:A5:8A:02:CD wlan0
aireplay-ng -0 wlan0 -a 00:16:B6:2E:C3:4E wlan0
aircrack-ng -0 -n 128 -f 4 file_name.ivs

Routing z wirtualbox-em - ćwiczenie.

Router:
iptables -t nat -A POSTROUTING -s 192.168.50.0/24 -o eth0 -j SNAT --to 10.0.13.50
echo 1 > /proc/sys/net/ipv4/ip_forward
 
Klient:
 
ip a a 192.168.50.2/24 dev eth0
ip r a default via 192.168.50.1
ip a a 10.0.13.70/24 dev eth1
 
ip r a 10.0.13.0/24 dev eth1 table  1
ip r a default via 10.0.13.254 table 1
 
ip rule add fwmark 1 table 1
 
iptables -t mangle -A OUTPUT -p icmp -j MARK --set-mark 1
iptables -t nat -A POSTROUTING -m mark --mark 1 -j SNAT --to 10.0.13.70

Konfiguracja Debian:

# The primary network interface
auto eth0
iface eth0 inet static
        address 192.168.50.2
        netmask 255.255.255.0
        gateway 192.168.50.1

auto eth1
iface eth1 inet static
        address 10.0.13.70
        netmask 255.255.255.0
        up ip r a 10.0.13.0/24 dev eth1 table 1
        up ip r a default via 10.0.13.254 table 1
        up ip rule add fwmark 1 table 1
        up iptables -t mangle -A OUTPUT -p icmp -j MARK --set-mark 1
        up iptables -t nat -A POSTROUTING -m mark --mark 1 -j SNAT --to 10.0.13.70

Schemat: