Advertisement
Guest User

Untitled

a guest
Jan 20th, 2018
89
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Bash 1.57 KB | None | 0 0
  1. #!/bin/bash
  2.  
  3. touch FWOA_tmp.txt
  4. echo "Wpisz swojego maila:"
  5. read usermail
  6.  
  7.  
  8. if [ "$#" -ne 0 ];then
  9.     case $1 in
  10.         -u | --user )
  11.         oIFS=$IFS
  12.         IFS=","
  13.         users=$2
  14.         IFS=$oIFS
  15.  
  16.         for user in $users
  17.         do
  18.         echo "######################$user#####################" >> FWOA_tmp.txt
  19.         find / -type f -user "$user" -perm /333 2>/dev/null  >> FWOA_tmp.txt
  20.         done
  21.         echo "THIS IS FILE ACCESS RAPORT FROM $(date)" | mail -s "FILE ACCESS $(hostname) FROM $(date)" "$usermail" < ~/Dokumenty/FWOA_tmp.txt
  22.        
  23.                                
  24.                                 ;;
  25.         -g | --group )
  26.             oIFS=$IFS
  27.         IFS=","
  28.         groups=$2
  29.         IFS=$oIFS
  30.  
  31.         for group in $groups
  32.         do
  33.         echo "######################$group#####################" >> FWOA_tmp.txt
  34.         find / -type f -group "$group" -perm /333 2>/dev/null  >> FWOA_tmp.txt
  35.         done
  36.         echo "THIS IS FILE ACCESS RAPORT FROM $(date)" | mail -s "FILE ACCESS $(hostname) FROM $(date)" "$usermail" < ~/Dokumenty/FWOA_tmp.txt
  37.        
  38.                                 ;;
  39.         -h | --help )          
  40.     echo "to jest pomoc"
  41.                                 exit
  42.                                 ;;
  43.    
  44.     esac
  45. fi
  46.  
  47. users="$(awk -F'[/:]' '{if ($3 >= 1000 && $3 != 65534) print $1}' /etc/passwd)"
  48.  
  49.     echo "$users"
  50.  
  51.     for user in $users
  52.     do
  53.     echo "######################$user#####################" >> FWOA_tmp.txt
  54.     find / -type f -user "$user" -perm /333 2>/dev/null >> FWOA_tmp.txt
  55.     done
  56.  
  57.     echo "THIS IS FILE ACCESS RAPORT FROM $(date) " | mail -s "FILE ACCESS $(whoami) FROM $(date)" "$usermail" < ~/Dokumenty/FWOA_tmp.txt
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement