AskOverflow.Dev

AskOverflow.Dev Logo AskOverflow.Dev Logo

AskOverflow.Dev Navigation

  • Início
  • system&network
  • Ubuntu
  • Unix
  • DBA
  • Computer
  • Coding
  • LangChain

Mobile menu

Close
  • Início
  • system&network
    • Recentes
    • Highest score
    • tags
  • Ubuntu
    • Recentes
    • Highest score
    • tags
  • Unix
    • Recentes
    • tags
  • DBA
    • Recentes
    • tags
  • Computer
    • Recentes
    • tags
  • Coding
    • Recentes
    • tags
Início / server / Perguntas / 1161362
Accepted
ildvzg68472
ildvzg68472
Asked: 2024-06-22 08:45:29 +0800 CST2024-06-22 08:45:29 +0800 CST 2024-06-22 08:45:29 +0800 CST

Fedora 40: auditctl não audita a criação, edição e exclusão de arquivos conforme esperado

  • 772

Muito obrigado pela ajuda do @Romeo Ninov! Os erros que cometi são

  • deve usar file /etc/audit/rules.d/audit.rulespara adicionar uma regra para RedHat 7 e 8
  • deve usar service auditd restartpara reiniciar o auditctl para que a nova regra entre em vigor.
  • deve usar ausearch -k testingpara pesquisar trilhas de auditoria.
  • deve remover -a task,neverfrom /etc/audit/rules.d/audit.rules, que suprime a auditoria de syscall para todas as tarefas iniciadas

Adicionei uma regra /etc/audit/rules.d/audit.rulese executei reboot, pois não é possível reiniciar a auditoria por systemctl restart.

root@localhost:~# cat /etc/audit/rules.d/audit.rules
## This set of rules is to suppress the performance effects of the
## audit system. The result is that you only get hardwired events.
-D

## This suppresses syscall auditing for all tasks started
## with this rule in effect.  Remove it if you need syscall
## auditing.
-a task,never

-w /root/testing/ -p rwxa -k testing

root@localhost:~# systemctl restart auditd.service
Failed to restart auditd.service: Operation refused, unit auditd.service may be requested by dependency only (it is configured to refuse manual start/stop).
See system logs and 'systemctl status auditd.service' for details.

em algum momento, o servidor está ativo, eu faço login por ssh

root@localhost:~# service auditd status
Redirecting to /bin/systemctl status auditd.service
● auditd.service - Security Audit Logging Service
     Loaded: loaded (/usr/lib/systemd/system/auditd.service; enabled; preset: enabled)
    Drop-In: /usr/lib/systemd/system/service.d
             └─10-timeout-abort.conf
     Active: active (running) since Sat 2024-06-22 17:51:41 CST; 24s ago
       Docs: man:auditd(8)
             https://github.com/linux-audit/audit-documentation
    Process: 795 ExecStart=/usr/sbin/auditd (code=exited, status=0/SUCCESS)
   Main PID: 797 (auditd)
      Tasks: 4 (limit: 2257)
     Memory: 2.8M (peak: 3.1M)
        CPU: 24ms
     CGroup: /system.slice/auditd.service
             ├─797 /usr/sbin/auditd
             └─799 /usr/sbin/sedispatch

Jun 22 17:51:41 localhost systemd[1]: Starting auditd.service - Security Audit Logging Service...
Jun 22 17:51:41 localhost auditd[797]: audit dispatcher initialized with q_depth=2000 and 1 active plugins
Jun 22 17:51:41 localhost auditd[797]: Init complete, auditd 4.0.1 listening for events (startup state enable)
Jun 22 17:51:41 localhost systemd[1]: Started auditd.service - Security Audit Logging Service.
root@localhost:~# 
root@localhost:~# auditctl -l
-a never,task
-w /root/testing -p rwxa -k testing
root@localhost:~# 

Estou bar.txtem /root/testingedição foo.txtpara adicionar uma nova linha foo.txte excluirbar.txt

root@localhost:~/testing# vim bar.txt
root@localhost:~/testing# vim foo.txt
root@localhost:~/testing# rm -f bar.txt
root@localhost:~/testing# cat foo.txt
foo.txt
foo.txt

Espero obter alguma trilha de auditoria no arquivo de log, para que eu possa saber que alguém cria e edita arquivos na /root/testing/pasta e um arquivo é excluído, mas falhou:

root@localhost:~/testing# grep "testing" /var/log/audit/audit.log
type=CONFIG_CHANGE msg=audit(1718981523.208:192): auid=4294967295 ses=4294967295 subj=system_u:system_r:unconfined_service_t:s0 op=add_rule key="testing" list=4 res=1AUID="unset"
type=CONFIG_CHANGE msg=audit(1719049566.384:285): auid=0 ses=3 subj=unconfined_u:unconfined_r:unconfined_t:s0-s0:c0.c1023 op=remove_rule key="testing" list=4 res=1AUID="root"
root@localhost:~/testing# 

Muito obrigado pela sua ajuda!

linux
  • 1 1 respostas
  • 170 Views

1 respostas

  • Voted
  1. Best Answer
    Romeo Ninov
    2024-06-22T17:18:37+08:002024-06-22T17:18:37+08:00

    Alguns pontos a serem considerados. Isso não funciona para você porque auditmonitora uma pasta diferente:

    root@localhost:~# auditctl -l
    -a nunca,tarefa
    -w /tmp/testing -p rwxa -k teste

    Em seguida, não tenho certeza se você precisa -Dda primeira linha no arquivo de regras de auditoria.

    E seu arquivo de regras provavelmente está no lugar errado, configure-o em:

    /etc/audit/rules.d/audit.rules
    

    (isso é recomendado para RHEL 7,8,9)

    E não se esqueça de reiniciar audito daemon após alterar a configuração

    systemctl restart auditd.service
    

    PS Infelizmente systemctlnão funciona para auditdaemon, então a reinicialização deve ser feita via:

    service auditd restart
    

    E respondendo à sua preocupação - funciona e adiciona registros para edição, remoção, etc: adicionei uma regra como esta:

    auditctl -w /root/test/ -p rwxa -k testing
    

    e o resultado é

    [root@rh9-1 test]# ausearch -k testing
    ----
    <snip>
    ----
    time->Sat Jun 22 15:26:50 2024
    type=PROCTITLE msg=audit(1719059210.373:105): proctitle=726D002D690062
    type=PATH msg=audit(1719059210.373:105): item=1 name="b" inode=656718 dev=fd:00 mode=0100644 ouid=0 ogid=0 rdev=00:00 obj=unlabeled nametype=DELETE cap_fp=0 cap_fi=0 cap_fe=0 cap_fver=0 cap_frootid=0
    type=PATH msg=audit(1719059210.373:105): item=0 name="/root/test" inode=655414 dev=fd:00 mode=040755 ouid=0 ogid=0 rdev=00:00 obj=unlabeled nametype=PARENT cap_fp=0 cap_fi=0 cap_fe=0 cap_fver=0 cap_frootid=0
    type=CWD msg=audit(1719059210.373:105): cwd="/root/test"
    type=SYSCALL msg=audit(1719059210.373:105): arch=c000003e syscall=263 success=yes exit=0 a0=ffffff9c a1=5570b6183630 a2=0 a3=20 items=2 ppid=1266 pid=1355 auid=1000 uid=0 gid=0 euid=0 suid=0 fsuid=0 egid=0 sgid=0 fsgid=0 tty=pts0 ses=1 comm="rm" exe="/usr/bin/rm" subj=kernel key="testing"
    

    Isso acima remove o arquivo, nomeado bdo diretório/root/test

    • 5

relate perguntas

  • Como descobrir detalhes sobre hardware na máquina Linux?

Sidebar

Stats

  • Perguntas 205573
  • respostas 270741
  • best respostas 135370
  • utilizador 68524
  • Highest score
  • respostas
  • Marko Smith

    Você pode passar usuário/passar para autenticação básica HTTP em parâmetros de URL?

    • 5 respostas
  • Marko Smith

    Ping uma porta específica

    • 18 respostas
  • Marko Smith

    Verifique se a porta está aberta ou fechada em um servidor Linux?

    • 7 respostas
  • Marko Smith

    Como automatizar o login SSH com senha?

    • 10 respostas
  • Marko Smith

    Como posso dizer ao Git para Windows onde encontrar minha chave RSA privada?

    • 30 respostas
  • Marko Smith

    Qual é o nome de usuário/senha de superusuário padrão para postgres após uma nova instalação?

    • 5 respostas
  • Marko Smith

    Qual porta o SFTP usa?

    • 6 respostas
  • Marko Smith

    Linha de comando para listar usuários em um grupo do Windows Active Directory?

    • 9 respostas
  • Marko Smith

    O que é um arquivo Pem e como ele difere de outros formatos de arquivo de chave gerada pelo OpenSSL?

    • 3 respostas
  • Marko Smith

    Como determinar se uma variável bash está vazia?

    • 15 respostas
  • Martin Hope
    Davie Ping uma porta específica 2009-10-09 01:57:50 +0800 CST
  • Martin Hope
    kernel O scp pode copiar diretórios recursivamente? 2011-04-29 20:24:45 +0800 CST
  • Martin Hope
    Robert ssh retorna "Proprietário incorreto ou permissões em ~/.ssh/config" 2011-03-30 10:15:48 +0800 CST
  • Martin Hope
    Eonil Como automatizar o login SSH com senha? 2011-03-02 03:07:12 +0800 CST
  • Martin Hope
    gunwin Como lidar com um servidor comprometido? 2011-01-03 13:31:27 +0800 CST
  • Martin Hope
    Tom Feiner Como posso classificar a saída du -h por tamanho 2009-02-26 05:42:42 +0800 CST
  • Martin Hope
    Noah Goodrich O que é um arquivo Pem e como ele difere de outros formatos de arquivo de chave gerada pelo OpenSSL? 2009-05-19 18:24:42 +0800 CST
  • Martin Hope
    Brent Como determinar se uma variável bash está vazia? 2009-05-13 09:54:48 +0800 CST

Hot tag

linux nginx windows networking ubuntu domain-name-system amazon-web-services active-directory apache-2.4 ssh

Explore

  • Início
  • Perguntas
    • Recentes
    • Highest score
  • tag
  • help

Footer

AskOverflow.Dev

About Us

  • About Us
  • Contact Us

Legal Stuff

  • Privacy Policy

Language

  • Pt
  • Server
  • Unix

© 2023 AskOverflow.DEV All Rights Reserve