nmap

Inwentaryzacja IP – sprawdzenie listy hostów

# nmap -sP -oA 20171219_host_scan

Skanowanie portów

# nmap -iL lista-ip.txt -sS -sV --version-all -r -T4 
       --webxml -oA 20191220_port_scan

Uruchomienie skryptów

# nmap -iL lista-ip.txt -Pn -A -T4 -v --script all 
          -oN 20180110_script_scan

SKRYPTY – opcje

# nmap -sC                 <- domyślna lista skrtypów
# nmap -A                  <- dodane do agresywnego skanowania
# nmap --script [KATEGORIA | all]
# nmap --script [KATEGORIA] --script-args [ARGS] 
       --script-args-file [OPTION]
# nmap -sn -sC             <- skrypty bez skanowania portów
# nmap -sn -Pn -sC         <- bez portów i bez hostów

Kategorie skryptów

auth    <- autoryzacja
broadcast   <- host discovery, nie uzgl. na liście
brute   <- atak brute force na autentykację
default   <- -sC lub -A lub --script=default
discovery   <- większa analiza sieci: snmp, http, smb
dos   <- atak dos, może uszk. system
exploit   <- próba włamania
externalt   <- łączy się z innymi serwisami np. whois
fuzzer   <- wysyła śmieci, długotrwały, duże obciążenie sieci
intrusive   <- duże ryzyko awarii systemu
malware   <- testują czy system zarażony malwarem lub backdorem
safe   <- bez awarii, włamań, dużego obciążenia
version   <- włączane tylko jako opcje -sV
vuln   <- sprawdzają znane podatności, tylko raportują

mod_rewrite

Włączenie modułu mod_rewrite

# a2enmod rewrite
# systemctl restart apache2

# editor /etc/apache2/apache2.conf

<Directory /var/www/>
    Options Indexes FollowSymLinks
    AllowOverride All
    Require all granted
</Directory>

Lub

<VirtualHost *:80>
    <Directory /var/www/html>
        Options Indexes FollowSymLinks MultiViews
        AllowOverride All
        Require all granted
    </Directory>

    . . .
</VirtualHost>

sql – update z podzapytaniem

Tabela łącząca posiada wpisy powiązane z usuniętymi rekordami suits. Dla tych rekordów zerujemy klucz obcy.

 UPDATE ingredients_suits si SET suit_id = 0 WHERE NOT EXISTS (
        SELECT id FROM suits s WHERE s.id = si.suit_id
);

Można skasować rekordy tabeli łączącej które mają wyzerowany klucz obcy

DELETE FROM ingredients_suits WHERE suit_id=0;

Apache – włączenie ssl

Zakładając istnienie openSSL

# apt-get upgrade openssl
# a2enmod ssl
-----------------
Considering dependency setenvif for ssl:
Module setenvif already enabled
Considering dependency mime for ssl:
Module mime already enabled
Considering dependency socache_shmcb for ssl:
Enabling module socache_shmcb.
Enabling module ssl.
See /usr/share/doc/apache2/README.Debian.gz on how to configure SSL and create self-signed certificates.
To activate the new configuration, you need to run:
  systemctl restart apache2
# a2ensite default-ssl
-----------------
Enabling site default-ssl.
To activate the new configuration, you need to run:
  systemctl reload apache2
# service apache2 reload

Debian – releases

Nazwy kodowe i wersje

Debian  "buster" - następna
Debian 9 ("stretch") — current stable release
Debian 8 ("jessie") — obsolete stable release
Debian 7 ("wheezy") — obsolete stable release
Debian 6.0 ("squeeze") — obsolete stable release
Debian GNU/Linux 5.0 ("lenny") — obsolete stable release 

Sprawdzenie nazwy

uname -a
Linux bora 4.9.0-3-686-pae #1 SMP Debian 4.9.30-2+deb9u3 (2017-08-06) i686 GNU/Linux

MySQL – install, config – linux

# apt-get install mysql-server

Konfiguracja poinstalacyjna np. ustawienie haseł

# mysql_secure_installation
# mysql -u root -p

Utworzenie bazy danych, użytkownika i uprawnienia

> create database testdb;
> create user 'tester'@'localhost' identified by 'mypass';
> grant all on testdb.* to 'tester';

Utworzenie usera w czasie przydzielania uprawnień

> grant all on testdb.* to 'testuser' identified by 'mypassword';

Sprawdzenie uprawnień

> show grants for testuser;

Ajax Headers

Typowy Request jQuery Ajax

    var url      = '/controller/action.json'
    var data_obj = {
        ulica    : 'Marszałkowska',
        miasto   : 'Warszawa'
    };

    data = JSON.stringify( data_obj ); 

    $.ajax({
        type       : 'post',
        dataType   : 'json',
        data       : data,
        url        : url,
        success    : function(response) { 
                       renderResult(response); 
                     },
        error      : function(e) { alert( e.message ); }
    }); 

Ustawianie nagłówków dla Request

    $.ajax({

        beforeSend : function(xhr) { 
                       xhr.setRequestHeader('X-Test-Hdr', 'Test'); 
                     },
        headers: {
                'header1': 'value1',
                'header2': 'value2'
            },
        contentType: 'application/json; charset=utf-8',

    }); 

Domyślny nagłówek dla żądań AJAX

X-Requested-With: XMLHttpRequest
  xhrobj.setRequestHeader("X-Requested-With", "XMLHttpRequest");

MySQL Datediff()

Zwraca ilość dni pomiędzy dwoma datami lub znacznikami czasu

DATEDIFF( expr1, expr2 );
SELECT DATEDIFF( '2008-05-17 11:31:31','2008-04-28' ) ;

+----------------------------------------------+
| DATEDIFF('2008-05-17 11:31:31','2008-04-28') |
+----------------------------------------------+
|                                           19 | 
+----------------------------------------------+

sitemap.xml

<?xml version="1.0" encoding="UTF-8"?>
<urlset xmlns="https://www.sitemaps.org/schemas/sitemap/0.9"> 
 <url><loc>https://nazwaserwera.pl/</loc></url> 
 <url><loc>https://nazwaserwera.pl/O-nas</loc></url> 
 <url><loc>https://nazwaserwera.pl/Promocje</loc></url>
 <url><loc>https://nazwaserwera.pl/Cennik</loc></url> 
 <url><loc>https://nazwaserwera.pl/Zamowienie</loc></url>
 <url><loc>https://nazwaserwera.pl/Kontakt</loc></url>
 <url><loc>https://nazwaserwera.pl/Regulamin</loc></url>
</urlset>

Nowa wersja sitemap 4

https://www.sitemaps.org/protocol.html

https://www.arnebrachhold.de/projects/wordpress-plugins/google-xml-sitemaps-generator/google-xml-sitemap-generator-new-sitemap-format/
<?xml version="1.0" encoding="utf-8"?>
<urlset xmlns="https://www.sitemaps.org/schemas/sitemap/0.9" xmlns:xsi="https://www.w3.org/2001/XMLSchema-instance" xmlns:image="https://www.google.com/schemas/sitemap-image/1.1" xsi:schemaLocation="https://www.sitemaps.org/schemas/sitemap/0.9 https://www.sitemaps.org/schemas/sitemap/0.9/sitemap.xsd">
  <url>
    <loc>https://topdieta.pl/</loc>
    <lastmod>2017-07-25</lastmod>
    <changefreq>daily</changefreq>
    <priority>1.0</priority>
      <image:image>
        <image:loc>https://topdieta.pl/wp-content/uploads/2017/05/dieta.jpg</image:loc>
        <image:title></image:title>
      </image:image>
    </url>
  <url>
    <loc>https://topdieta.pl/faq/</loc>
    <lastmod>2017-07-25</lastmod>
    <changefreq>daily</changefreq>
    <priority>0.9</priority>
      <image:image>
        <image:loc>https://topdieta.pl/wp-content/uploads/2017/04/FAQ.jpg</image:loc>
        <image:title>FAQ-Top_Dieta</image:title>
      </image:image>
  </url>
</urlset>