Beefy Boxes and Bandwidth Generously Provided by pair Networks
go ahead... be a heretic
 
PerlMonks  

Watching my Users

by Poetic Justice (Monk)
on Jun 18, 2000 at 09:25 UTC ( [id://18699]=CUFP: print w/replies, xml ) Need Help??

When I'm away on the weekend, I like to know what's been happening on my network. I used the Net::SMTP to have my Wintel machines email me as soon as the user Logs on. What I've done is not original and as soon as I finished this snippet, I've thought of other uses for this little trick. Big thanks to St. Larry and Company.
#! perl -w # fn_with_me.pl # A quick and dirty way to tell if someone is messing with My Computer +s use Net::SMTP; use Sys::Hostname; $host = hostname; $smtp = Net::SMTP -> new('your.mailhost.net'); #Connect to a mail serv +er $smtp -> mail( 'anysender@theirmailhost.net'); #Sender's name $smtp -> to('myemail@mymailhost.net'); #Receivers name $smtp -> data(); # Send the header $smtp -> datasend("To: myemail\@mymailhost.net\n"); $smtp -> datasend("From: theiremail\@mymailhost.net\n"); $smtp -> datasend("\n"); # Send the Body $smtp -> datasend("Somebody's using ".$host); $smtp -> dataend(); $smtp -> quit;

Replies are listed 'Best First'.
RE: Watching my Users
by httptech (Chaplain) on Jun 18, 2000 at 15:47 UTC
    It might also be useful to know who is using the machine:
    #! perl -w # fn_with_me.pl # A quick and dirty way to tell if someone is messing with My Computer +s use Net::SMTP; use Sys::Hostname; use Win32; $host = hostname; $user = Win32::LoginName(); $smtp = Net::SMTP -> new('your.mailhost.net'); #Connect to a mail serv +er $smtp -> mail( 'anysender@theirmailhost.net'); #Sender's name $smtp -> to('myemail@mymailhost.net'); #Receivers name $smtp -> data(); # Send the header $smtp -> datasend("To: myemail\@mymailhost.net\n"); $smtp -> datasend("From: theiremail\@mymailhost.net\n"); $smtp -> datasend("\n"); # Send the Body $smtp -> datasend("$user is using $host"); $smtp -> dataend(); $smtp -> quit;
      Thanks for the comment. I've inherited this system from a previous sysadmin and his policy was very loose. Once I implement my new security measures, I'll be able to extract the user name from their login. When I fix the code, I'll repost.

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: CUFP [id://18699]
Approved by root
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others rifling through the Monastery: (7)
As of 2024-04-25 11:08 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found