Senha no apache + expressões regulares
Definindo senha no apache no diretório “aluno1”
Digamos que a página aula.php
deve ser acessada somente por pessoas autorizadas, para isto definiremos uma
senha.
Vamos
editar o arquivo abaixo:
------------------------------------------------------------------------------------------------------------
# nano /etc/apache2/sites-enabled/000-default
#---[ begin:
000-default ]------------------------------------------
<VirtualHost *:80>
ServerAdmin webmaster@localhost
DocumentRoot /var/www
<Directory />
Options FollowSymLinks
AllowOverride None
</Directory>
<Directory /var/www/>
Options Indexes FollowSymLinks
MultiViews
AllowOverride None
Order allow,deny
allow from all
</Directory>
ScriptAlias /cgi-bin/ /usr/lib/cgi-bin/
<Directory
"/usr/lib/cgi-bin">
AllowOverride None
Options +ExecCGI -MultiViews
+SymLinksIfOwnerMatch
Order allow,deny
Allow from all
</Directory>
#---------------------------------------
# o diretório abaixo terá
senha no apache ou seja, ao abrir a tela
# aula.php será aberta uma tela para digitar usuário1 e a senha 123
<Directory /var/www/aluno1>
deny from all
Options +ExecCGI
AllowOverride AuthConfig
Order allow,deny
</Directory>
#---------------------------------------
ErrorLog ${APACHE_LOG_DIR}/error.log
LogLevel warn
CustomLog ${APACHE_LOG_DIR}/access.log
combined
Alias /doc/ "/usr/share/doc/"
<Directory
"/usr/share/doc/">
Options Indexes MultiViews
FollowSymLinks
AllowOverride None
Order deny,allow
Deny from all
Allow from 127.0.0.0/255.0.0.0 ::1/128
</Directory>
</VirtualHost>
#---[ end:
000-default ]---------------------------------------------
ctrl + x + y + enter (
para salvar e sair do arquivo )
------------------------------------------------------------------------------------------------------------
Agora criaremos o arquivo .htaccess:
# cat > /var/www/aluno1/.htaccess
#---[ begin:
.htaccess ]-----------------------------
AuthType Basic
AuthUserFile /var/www/aluno1/.htpasswd
AuthName RESTRITO
require valid-user
satisfy any
#---[ end: .htaccess
]-------------------------------
ctrl + d (
para salvar e sair do arquivo )
------------------------------------------------------------------------------------------------------------
Precisamos
dar permissão para o www no arquivo .htaccess (no debian o usuário do apache é www-data)
# chown www-data /var/www/aluno1/.htaccess
Agora vamos definir um
login e uma senha para o arquivo .htpasswd
# htpasswd -bc /var/www/aluno1/.htpasswd login
senhadologin
Adding
password for user login
#
chmod 644 /var/www/aluno1/.htpasswd
Criaremos o usuário de nome
usuario1 e
a senha 123
# htpasswd -bc /var/www/aluno1/.htpasswd usuario1
123
Adding
password for user usuario1
Conteúdo do arquivo de
senha foi criptografado!
# cat /var/www/aluno1/.htpasswd
usuario1:4mcuigveooC9Q
Após isto precisaremos
restartar o servidor apache.
#
/etc/init.d/apache2 restart
Rede interna:
------------------------------------------------------------------------------------------------------------
# awk -F\" '{print $6}' /var/log/apache2/access.log | sort | uniq -c | sort -fr
6 Mozilla/5.0 (compatible; YandexBot/3.0; +http://yandex.com/bots)
6 Made by ZmEu @ WhiteHat Team - www.whitehat.ro
3 Mozilla/5.0 (compatible; Googlebot/2.1; +http://www.google.com/bot.html)
3 Microsoft-WebDAV-MiniRedir/6.1.7600
3 Microsoft-WebDAV-MiniRedir/5.1.2600
2 Mozilla/4.0 (compatible; MSIE 6.0; Windows 98)
2 Googlebot/2.1 (+http://www.googlebot.com/bot.html)
23 Mozilla/5.0 (compatible; Baiduspider/2.0; +http://www.baidu.com/search/spider.html)
1 Sogou web spider/4.0(+http://www.sogou.com/docs/help/webmasters.htm#07)
------------------------------------------------------------------------------------------------------------
# awk -F\" '{print $6}' /var/log/apache2/access.log | sed 's/(\([^;]\+; [^;]\+\)[^)]*)/(\1)/' | sort | uniq -c | sort -fr
6 ZmEu
5 Mozilla/5.0 (compatible; Googlebot/2.1)
5 curl/7.21.6 (i686-pc-linux-gnu) libcurl/7.21.6 OpenSSL/1.0.0e zlib/1.2.3.4 libidn/1.22 librtmp/2.3
4 Microsoft-WebDAV-MiniRedir/6.1.7600
3 Mozilla/5.0 (Windows NT 5.1; rv:6.0.2) Gecko/20100101 Firefox/6.0.2
3 Mozilla/5.0 (Windows NT 5.1; rv:12.0) Gecko/20100101 Firefox/12.0
3 Mozilla/5.0 (compatible; Nmap Scripting Engine)
3 Mozilla/5.0 (compatible; AhrefsBot/4.0)
2 Mozilla/5.0 (compatible; Ezooms/1.0)
2 Mozilla/5.0 (compatible; bingbot/2.0)
2 curl/7.19.7 (x86_64-unknown-linux-gnu) libcurl/7.19.7 NSS/3.12.6.2 zlib/1.2.3 libidn/1.18 libssh2/1.2.2
2 curl/7.19.7 (x86_64-redhat-linux-gnu) libcurl/7.19.7 NSS/3.13.1.0 zlib/1.2.3 libidn/1.18 libssh2/1.2.2
1 Mozilla/5.0 (Windows NT 5.1; U) Gecko/20100101 Firefox/5.0
1 Mozilla/3.0 (compatible; Indy Library)
1 Mongo-BlogFeed-43 GBlogger-Java/2.0.0 GData-Java/1.45.0(gzip)
1 Mongo-BlogFeed-38 GBlogger-Java/2.0.0 GData-Java/1.45.0(gzip)
1 Microsoft-WebDAV-MiniRedir/6.1.7601
1 Googlebot-Image/1.0
1 Feedfetcher-Google; (+http://www.google.com/feedfetcher.html; feed-id=5979334880718126309)
1 Feedfetcher-Google; (+http://www.google.com/feedfetcher.html; feed-id=1971493185649054317)
------------------------------------------------------------------------------------------------------------
# awk -F\" '($6 ~ /Googlebot/){print $2}' /var/log/apache2/access.log | awk '{print $2}'
/robots.txt
/
/robots.txt
/guest3-ok/imgs/email.gif
/robots.txt
/
------------------------------------------------------------------------------------------------------------
# awk '{print $9}' /var/log/apache2/access.log | sort | uniq -c | sort
2112 200
3 302
39 404
4 "-"
76 304
------------------------------------------------------------------------------------------------------------
# awk '($9 ~ /404/)' /var/log/apache2/access.log
109.74.196.50 - - [15/Jan/2013:01:47:00 -0200] "GET /password.cgi HTTP/1.1" 404 473 "-" "curl/7.21.6 (i686-pc-linux-gnu) libcurl/7.21.6 OpenSSL/1.0.0e zlib/1.2.3.4 libidn/1.22 librtmp/2.3"
200.35.147.178 - - [15/Jan/2013:18:34:30 -0200] "GET /password.cgi?sysPassword=lines@bank HTTP/1.1" 404 473 "-" "curl/7.19.7 (x86_64-unknown-linux-gnu) libcurl/7.19.7 NSS/3.12.6.2 zlib/1.2.3 libidn/1.18 libssh2/1.2.2"
109.74.196.50 - - [16/Jan/2013:08:59:15 -0200] "GET /password.cgi HTTP/1.1" 404 473 "-" "curl/7.21.6 (i686-pc-linux-gnu) libcurl/7.21.6 OpenSSL/1.0.0e zlib/1.2.3.4 libidn/1.22 librtmp/2.3"
180.76.5.194 - - [16/Jan/2013:12:40:02 -0200] "GET /robots.txt HTTP/1.1" 404 469 "-" "Mozilla/5.0 (Windows NT 5.1; rv:6.0.2) Gecko/20100101 Firefox/6.0.2"
66.249.74.199 - - [16/Jan/2013:14:05:28 -0200] "GET /robots.txt HTTP/1.1" 404 510 "-" "Mozilla/5.0 (compatible; Googlebot/2.1; +http://www.google.com/bot.html)"
212.72.26.163 - - [16/Jan/2013:17:09:45 -0200] "GET /w00tw00t.at.blackhats.romanian.anti-sec:) HTTP/1.1" 404 488 "-" "ZmEu"
212.72.26.163 - - [16/Jan/2013:17:09:45 -0200] "GET /phpMyAdmin/scripts/setup.php HTTP/1.1" 404 479 "-"
212.72.26.163 - - [16/Jan/2013:17:09:46 -0200] "GET /phpmyadmin/scripts/setup.php HTTP/1.1" 404 478 "-"
212.72.26.163 - - [16/Jan/2013:17:09:47 -0200] "GET /pma/scripts/setup.php HTTP/1.1" 404 473 "-" "ZmEu"
212.72.26.163 - - [16/Jan/2013:17:09:48 -0200] "GET /myadmin/scripts/setup.php HTTP/1.1" 404 477 "-" "ZmEu"
212.72.26.163 - - [16/Jan/2013:17:09:49 -0200] "GET /MyAdmin/scripts/setup.php HTTP/1.1" 404 477 "-" "ZmEu"
157.55.32.104 - - [17/Jan/2013:10:16:01 -0200] "GET /robots.txt HTTP/1.1" 404 535 "-" "Mozilla/5.0 (compatible; bingbot/2.0; +http://www.bing.com/bingbot.htm)"
------------------------------------------------------------------------------------------------------------
# awk '($9 ~ /404/)' /var/log/apache2/access.log | awk '{print $9,$7}' | sort
404 //admin/index.php
404 //admin/phpmyadmin/index.php
404 //admin/pma/index.php
404 /favicon.ico
404 //index.php
404 /muieblackcat
404 //myadmin/index.php
404 /MyAdmin/scripts/setup.php
404 //mysqladmin/index.php
404 //mysql/index.php
404 /password.cgi?sptPassword=dnschange
404 /password.cgi?sptPassword=&usrPassword=chupeta008&sysPassword=chupeta008
404 /password.cgi?sptPassword=xuxuchange
404 //phpMyAdmin/
404 //phpMyAdmin/
404 //phpmyadmin1/index.php
404 //phpMyAdmin-2.2.3/index.php
404 //phpMyAdmin-2.2.6/index.php
404 //phpMyAdmin-2.5.1/index.php
404 //phpMyAdmin-2.5.4/index.php
404 //phpMyAdmin-2.5.5/index.php
404 //php-my-admin/index.php
404 //php-my-admin/index.php
404 //phpMyAdmin/index.php
404 //phpMyAdmin/index.php
404 /phpmyadmin/scripts/setup.php
404 //web/phpMyAdmin/index.php
404 //websql/index.php
404 //xampp/phpmyadmin/index.php
------------------------------------------------------------------------------------------------------------
# awk '($9 !~ /200/)' /var/log/apache2/access.log | awk '{print $9,$7}' | sort | uniq
302 /amigo/check.php
302 /cacti/graph_view.php
302 /cacti/index.php
304 /cacti/images/arrow.gif
304 /cacti/images/auth_login.gif
304 /cacti/images/cacti_backdrop.gif
304 /cacti/images/cacti_logo.gif
304 /cacti/images/left_border.gif
304 /cacti/images/menu_line.gif
304 /cacti/images/shadow.gif
304 /cacti/images/shadow_gray.gif
304 /cacti/images/tab_console_down.gif
304 /cacti/images/tab_graphs.gif
304 /cacti/images/transparent_line.gif
304 /cacti/include/layout.js
304 /cacti/include/main.css
404 /favicon.ico
404 /feeds/comments/default?max-results=1
404 /form4/phpformmail.php?send=1
404 /guest3-ok/imgs/email.gif
404 /manager/html
404 /myadmin/scripts/setup.php
404 /MyAdmin/scripts/setup.php
404 /password.cgi
404 /password.cgi?sysPassword=lines@bank
404 /phpmyadmin/scripts/setup.php
404 /phpMyAdmin/scripts/setup.php
404 /pma/scripts/setup.php
404 /robots.txt
404 /w00tw00t.at.blackhats.romanian.anti-sec:)
------------------------------------------------------------------------------------------------------------
# awk '($9 !~ /200|304/)' /var/log/apache2/access.log | awk '{print $9,$7}' | sort | uniq
"-" 200
302 /amigo/check.php
302 /cacti/graph_view.php
302 /cacti/index.php
404 /favicon.ico
404 /feeds/comments/default?max-results=1
404 /form4/phpformmail.php?send=1
404 /guest3-ok/imgs/email.gif
404 /manager/html
404 /myadmin/scripts/setup.php
404 /MyAdmin/scripts/setup.php
404 /password.cgi
404 /password.cgi?sysPassword=lines@bank
404 /phpmyadmin/scripts/setup.php
404 /phpMyAdmin/scripts/setup.php
404 /pma/scripts/setup.php
404 /robots.txt
------------------------------------------------------------------------------------------------------------------------
===[ Sharing Knowledge ]=== - Obrigado - Thank you - Danke - Merci - Grazie - Gracias - arigatou gozaimasu
“We make a living by what we get, but we make a life by what we give.” - Give and you will receive - just share :)
------------------------------------------------------------------------------------------------------------------------
“We make a living by what we get, but we make a life by what we give.” - Give and you will receive - just share :)
------------------------------------------------------------------------------------------------------------------------
Nenhum comentário:
Postar um comentário