In: , , , ,
On: 2005 / 11 / 09
Shorter URL for this post: http://ozh.in/9n

At work, colleagues and I are working on network shared directories. Just like everybody else I guess : you have a personal directory bound to your login username, and you are granted access to various shared directories where various people also have read / write permissions.

I've been doing some fun experiment these past few days at work : creating an Excel document with an appealing name (say, "salary_augmentation.xls", burried deep into "Confidential\HR\Budget\") and silently logging usernames everytime someone loads this file.

Here is how I did this :

Create a silly file

That's the easy step : create a file with a name so sexy that you're sure anyone seeing it will compulsively double-click it everytime they spot it. Any filename related to human resources and budget will surely trawl some fishes.

Then add some irrelevant content. A flashy red box reading something like "Did you really think I was going to tell you something secret" will do the job : you don't need more than people going "pfff moron" and closing the file.

Add the following Visual Basic

Add the following Visual Basic code to your excel document (the menu should be something like Tools / Macro / Visual Basic Editor)

  1. Private Sub Workbook_Open()
  2.  
  3.     Dim filenum As Integer
  4.     Dim i As Integer
  5.     Dim fic As String
  6.    
  7.     filenum = FreeFile
  8.         '// Get a free file number
  9.    
  10.     logfile = "Z:/path-to/non-appealing/directory/sql.log"
  11.         '// A text file located and named so that it won't be looked at
  12.    
  13.     Open logfile For Append As filenum
  14.         '// open the file
  15.     Print #filenum, Environ("UserName") & Chr(13)
  16.         '// write username to the file
  17.     Close filenum
  18.         '// Close the file
  19.  
  20. End Sub

Be sure to add this macro code to your Excel document and not in your personal Macros (perso.xls). To do so, add the Visual Basic code to ThisWorkBook of your current document.

Create a log text file

Create a blank text file, named and located so that it won't be interesting. Something like sql.log in the most boring directory you'll find. Modify the code above so that logfile points to this file.

Even better, make this file hidden if possible (right click, Properties, check "Hidden file")

Wait.

From now on, everytime someone loads your sexy Excel document, their username will be appended to your log file. Just check back from time to time and just be amazed by the number of employees who just seem to wander from directory to directory, looking for stuff that are normally not of their business :-)

Shorter URL

Want to share or tweet this post? Please use this short URL: http://ozh.in/9n

Metastuff

This entry "Have Fun with Excel : Log Accesses to a File" was posted on 09/11/2005 at 7:30 pm and is tagged with , , , ,
Watch this discussion : Comments RSS 2.0.

4 Blablas

  1. Quadszilla says:

    That's pretty funny. If I still worked in a fortune 500 setting, that would be a fun stunt to pull.

  2. Ozh says:

    hehe BB :) OSEF :)

  3. KickMe says:

    or how to make evil from Visual Basic. Oh, wait, that's not so new, Visual Basic *is* evil.

Leave a Reply

XHTML: You can use these tags: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>
Gravatars: Curious about the little images next to each commenter's name ? Go to Gravatar and sign for a free account
Spam: Various spam plugins may be activated. I'll put pins in a Voodoo doll if you spam me.

Read more ?