Professores não conseguem ver os trabalhos dos alunos

Na gestão dos trabalhos enviados o professor vê “Não existem trabalhos enviados” apesar de os alunos já terem submetido trabalhos. O professor só vê os administradores como utilizadores nas notas.

Esta situação pode ocorrer após uma actualização do Moodle. Está definido um cargo diferente de Aluno nas pessoas avaliadas nas definições gerais das notas.

 

Resolução:

Aceder a Notas > Definições Gerais e alterar as Pessoas avaliadas para Aluno.

Rede Moodle não funciona

Causes:

  • You’re running at least one of your hosts on a webserver that isn’t Apache
  • You’re using fake web addresses via virtual-host files or somesuch
  • One of your webservers doesn’t know its own hostname
  • Your webserver(s) have multiple IP addresses

MNET Requirements:

  • PHP Extensions
  • XMLRPC
  • Curl
  • OpenSSL

 

Problemas a gerar chaves públicas:

Utilizadores não conseguem fazer login (erro de sessão)

Os utilizadores não conseguem fazer login na plataforma. A mensagem de erro é “Desafortunadamente o seu browser tem os cookies desactivados”.

Aceder à tabela mdl_config e alterar o parâmetro sessioncookiepath que deve estar em branco para o valor “/”

Erro de JAuthentication na gestão do site

O administrador não consegue entrar na administração e surge uma mensagem de erro:

JAuthentication::__construct: Could not load authentication libraries.
Senha ou nome utilizador não são válidos

Este erro aparece porque se desactivou o plugin de autenticação do Joomla.

Para resolver este problema, acede-se à tabela jos_plugins e edita-se a linha “Autenticação – Joomla” para se alterar o campo published de “0” para “1”.

Comandos Postfix

postqueue -p

Permite ver quais as mensagens que estão na queue do servidor

postcat -q XXXXXXXXXXXX

Permite ver o conteúdo de uma mensagem que esteja na queue

postqueue -p | tail -n +2 | awk 'BEGIN { RS = "" } / remover@ccems\.pt$/ { print $1 }' | tr -d '*!' | postsuper -d -

Apagar todos os emails de/para um determinado email

mailq | tail -n +2 | awk 'BEGIN { RS = "" } # $7=sender, $8=recipient1, $9=recipient2 { if ($7 == "[email protected]" && $9 == "") print $1 }' | tr -d '*!' | postsuper -d -

Gerar o ficheiro de base de dados para o postfix ler

postmap /etc/postfix/virtual.cf
/etc/init.d/postfix restart

If your server has very high load and you want to temporarily move all message from the incoming queue to the hold queue, use the command:

postsuper -h ALL

to move the messages back to the incoming queue, use the command:

postsuper -r ALL

Procura todas as mensagens com mais de 3k e apaga-as. Deve ser feito na(s) pasta(s) /var/spool/postfix/(hold|incoming|queue|active)

find . -type f -size -3k -exec ls -lh {} \; | awk '{ print "postsuper -r " $9 }'

Procura todas as mensagens com [email protected] e move para outra pasta

grep -l -Z -r '[email protected]' . | xargs -0 -I{} mv {} /var/spool/postfix/lixo_hold

Para apagar todas as mensagem com aquele login:

find /var/spool/postfix/active/ -type f \
        -exec grep -l '[email protected]' '{}' \; | \
    xargs -n1 basename | xargs -n1 postsuper -d
find /var/spool/postfix/deferred/ -type f \
        -exec grep -l 'Authenticated sender: [email protected]' '{}' \; | \
    xargs -n1 basename | xargs -n1 postsuper -d

SSH ataques brute force

O servidor estava a ser bombardeado com pedidos a tentar explorar uma falha existente no SSH. O log do SSH mostrava mensagens deste tipo:

Feb 28 21:53:55 ccems-web2 sshd[5488]: Bad protocol version identification 'GET http://cashinlink.com/6ydbw58 HTTP/1.1' from UNKNOWN
Feb 28 21:54:20 ccems-web2 sshd[5491]: Bad protocol version identification 'GET http://50a574f0.linkbucks.com/ HTTP/1.1' from UNKNOWN
Feb 28 21:54:27 ccems-web2 sshd[5494]: Connection closed by 127.0.0.1
Feb 28 21:54:29 ccems-web2 sshd[5496]: Bad protocol version identification 'GET http://e8de474e.linkbucks.com/ HTTP/1.1' from UNKNOWN
Feb 28 21:54:41 ccems-web2 sshd[5497]: Bad protocol version identification 'POST http://proxy.traficer.net/test.php HTTP/1.1' from UNKNOWN

Como o SSHD não é capaz de determinar a fonte do ataque é necessário utilizar o Strace para descobrir qual o IP.

Strace – Tracks and displays system calls associated with a running process

strace -f -e getpeername -p sshd-pid

Os resultados mostraram isto:

--- SIGCHLD (Child exited) @ 0 (0) ---
Process 5504 attached (waiting for parent)
Process 5504 resumed (parent 16532 ready)
[pid  5504] getpeername(3, {sa_family=AF_INET, sin_port=htons(3856), sin_addr=inet_addr("85.140.128.165")}, [1157143637847441424]) = 0
[pid  5504] getpeername(3, {sa_family=AF_INET, sin_port=htons(3856), sin_addr=inet_addr("85.140.128.165")}, [7217096605625745424]) = 0
[pid  5504] getpeername(3, {sa_family=AF_INET, sin_port=htons(3856), sin_addr=inet_addr("85.140.128.165")}, [16]) = 0
[pid  5504] getpeername(3, 0x7fff272839f0, [2821568938222026880]) = -1 EBADF (Bad file descriptor)
Process 5504 detached
--- SIGCHLD (Child exited) @ 0 (0) ---
--- SIGCHLD (Child exited) @ 0 (0) ---
Process 5630 attached (waiting for parent)
Process 5630 resumed (parent 16532 ready)
[pid  5630] getpeername(3, {sa_family=AF_INET, sin_port=htons(35372), sin_addr=inet_addr("218.6.19.3")}, [3209377693044834320]) = 0
[pid  5630] getpeername(3, {sa_family=AF_INET, sin_port=htons(35372), sin_addr=inet_addr("218.6.19.3")}, [7217878495832047632]) = 0
[pid  5630] getpeername(3, {sa_family=AF_INET, sin_port=htons(35372), sin_addr=inet_addr("218.6.19.3")}, [16]) = 0
[pid  5630] getpeername(3, 0x7fff9f2b0110, [11469262112979681408]) = -1 ENOTCONN (Transport endpoint is not connected)
Process 5630 detached
--- SIGCHLD (Child exited) @ 0 (0) ---

Basta bloquear na firewall os IPs e o problema fica resolvido.

iptables -A INPUT -s 85.140.128.165 -j DROP
iptables -A INPUT -s 218.6.19.3 -j DROP

 

Como eu utilizo o Fail2ban nos servidores para bloquear os vários tipos de ataques vou explicar as alterações na configuração que são necessários para se bloquear automaticamente este ataques.

Edita-se o ficheiro /etc/fail2ban/filter.d/sshd.conf e adiciona-se na directiva failregex estas linhas:

^%(__prefix_line)sBad protocol version identification '.*?' from <HOST>
^%(__prefix_line)sDid not receive identification string from <HOST>

Moodle não envia mails de registo

Quando se tenta registar uma conta o moodle apresenta a mensagem de erro “couldn’t instantiate mail function”.

Para corrigir este problema basta aceder a Administração -> Servidor -> Correio electrónico e alterar o Correio electrónico para pedidos de ajuda para um email válido. Mails inválidos (como [email protected]) NÃO FUNCIONAM e provocam o erro descrito.

Também se deve assegurar que o administrador principal tem um email válido.

Blocking IPs in Linux

null route block:

route add -host XXX.XXX.XXX.XXX reject

Mais informação: http://www.cyberciti.biz/tips/how-do-i-drop-or-block-attackers-ip-with-null-routes.html

 

IPTables block:

iptables -I INPUT -s XXX.XXX.XXX.XXX -j DROP
iptables -I RH-Firewall-1-INPUT -s XXX.XXX.XXX.XXX -j DROP (CentOS)

(a opção -I adiciona a regra no topo da chain. a opção -A adiciona no final.)

Joomla: Problema com as imagens na edição de artigos

In Joomla! 1.5.8, a default filtering choice is in place for those who have not selected an Article Filter option. The default applied for those who have not made a selection implements “black list” filtering as a security precaution against possible XSS.

Due to this change, you might notice problems trying to save a Youtube video, or embedding other Javascript or Flash objects into your Articles.

If the default filtering option is not suitable for your needs, you can change it by using the Article Global Configuration options. For example, to change the default settings so that no filtering happens for members of the Super Administrator group:

1. Navigate to Content -> Article Manager.

2. Press the Parameters icon in the toolbar to show the Articles – Global Configuration screen.

3. Scroll down to Filtering Options, highlight all Filter groups except Super Administrator, Administrator and Manager, and select Filter type of Blacklist (Default), as shown in the screenshot below.

With this setting, Joomla! will use the default Blacklist filter for all users except for the Super Administrator, Administrator and Manager groups. If you want to let other groups of Users submit content with no filtering, just modify the instructions above to exclude these groups. If you want no filtering on any groups, follow the instructions above but select only the Registered group.