shell-script-pt
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Logando Atividades no Shell


From: Leandro Lustosa
Subject: Logando Atividades no Shell
Date: Mon, 03 Apr 2006 23:13:27 -0300
User-agent: Thunderbird 1.5 (X11/20060112)

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Fiz alguns testes básicos com ele...

1) Logando com o usuário que irá ser monitorado

teste@slackuser_ [~ $ ls -la
total 16
drwx--x--x  2 teste users  176 2006-04-03 22:26 .
drwxr-xr-x  9 root  root   248 2006-04-03 22:24 ..
- -rw-------  1 teste users  150 2006-04-03 22:30 .bash_history
- -rw-r--r--  1 *root  root*    63 2006-04-03 22:24 .bash_logout
- -rw-r--r--  1 *root  root*    58 2006-04-03 22:24 .bash_profile
- -rw-r--r--  1 teste users 3729 2006-04-03 22:24 .screenrc
teste@slackuser_ [/var/log $ rm shell-comands.log
rm: imposível remover `shell-comands.log': Permissão negada
teste@slackuser_ [/var/log $ rm -f shell-comands.log
rm: imposível remover `shell-comands.log': Permissão negada
teste@slackuser_ [/var/log $

**** adiciono as permissoes junto com o comando para criar usuario,
assim as permissoes
sao setadas automaticamente. ( *chown* )

teste@slackuser_ [~ $ ps -aux | grep script
Warning: bad ps syntax, perhaps a bogus '-'? See
http://procps.sf.net/faq.html
teste     7456  0.0  0.1   1696   536 pts/1    S+   22:31   0:00
script -afq /var/log/shell-comands.log
teste     7457  0.0  0.1   1980   592 pts/1    S+   22:31   0:00
script -afq /var/log/shell-comands.log
teste     7475  0.0  0.1   1780   728 pts/2    S+   22:36   0:00 grep
script
teste@slackuser_ [~ $ kill -9 7456 7457
Connection to localhost closed.
** se matar os processos do comando "*script*" ele mata sua propria
conexao.

teste@slackuser_ [~ $ echo CRTL+D em acao!
CRTL+D em acao!
teste@slackuser_ [~ $ Connection to localhost closed.
bash-3.00$
** dando crtl+d, perde conexao!

teste@slackuser_ [~ $ echo digitando exit
digitando exit
teste@slackuser_ [~ $ exit
Connection to localhost closed.
bash-3.00$
** exit tambem

teste@slackuser_ [~ $ logout
bash: logout: not login shell: use `exit'
teste@slackuser_ [~ $ exit
Connection to localhost closed.
bash-3.00$

Bom, posso fica brincando de monitora os comandos em tempo real com
tail, manda as acoes pro meu e-mail, celula, pager, mas fiz pensando
em outras coisas. E claro eu tranformei os comandos em binarios par
nao deixar as linhas de comando explicitas ( expostas ) para saber o
que estou fazendo:

Transformando em binario tanto o s comandos do .bash_profile quanto os
comandos do .bash_logout, abaixo segue exemplo de como fiz:

### INICIO DO AQUIVO.C
#include <stdio.h>
#include <unistd.h>
int main()
{

system ("script -afq /var/log/shell-comands.log ; logout");

}
### FIM DO AQUIVO.C

Obs.: dae so compilar com: gcc -o nome-do-binario arquivo.c

[]s,
Leandro ( slackuser_ )
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.2.2 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org

iD8DBQFEMdZGVNBR/9aHBYwRAqKcAJ4xwr5+NA//TZ87pTYACUwr5u7VogCghOjN
807fX+1FHQAis5gxg9Rk79A=
=0QJU
-----END PGP SIGNATURE-----



reply via email to

[Prev in Thread] Current Thread [Next in Thread]