Post

LTFO

Python script that duplicates a file in all subdirectories to encourage my fellow students to log out next time.

LTFO

About LTFO

LTFO was originally named Logout Reminder. I created the python script in early 2019, simply due to the majority of students leaving their sessions logged in on the college computers. Logout Reminder’s goal was to not only remind the said students to logout, but make sure they wouldn’t forget.

1
2
3
4
5
6
7
8
 _                             _     _____                _           _
| |                           | |   |  __ \              (_)         | |
| |     ___   __ _  ___  _   _| |_  | |__) |___ _ __ ___  _ _ __   __| | ___ _ __
| |    / _ \ / _` |/ _ \| | | | __| |  _  // _ \ '_ ` _ \| | '_ \ / _` |/ _ \ '__|
| |___| (_) | (_| | (_) | |_| | |_  | | \ \  __/ | | | | | | | | | (_| |  __/ |
|______\___/ \__, |\___/ \__,_|\__| |_|  \_\___|_| |_| |_|_|_| |_|\__,_|\___|_|
              __/ |
             |___/

I achieved this by creating a script that would generate a READ_ME.txt file in all folders on their student partition of the college server (which had its own drive letter).

The READ_ME.txt files would have a random number in their filename so that removing the files was safe. The files would contain a message along the lines of:

You forgot to logout!

Removal instructions: Search β€˜READ_ME#374.txt’ in the root of your drive, select all, and delete.

The script had no options whatsoever. You would simply run it from a USB on the logged in session; it would generate the files, and then it would close.

A friend had asked to have a copy of the script, but the computer it was on had corrupt RAM. Because of this, I had no way to get the script off of the hard drive. The following Saturday, I rewrote the entire script.

The new rewrite of the script included many new features not present in the original version including:

  • Ability to select a drive to flood with files (originally hard-coded within the script)
  • Ability to go back and forth between menus
  • Final randomly-generated confirmation code to reduce accidents
  • Generating an automatic removal script [Build 3 - v2.1.2]
  • Automatically check for updates [v2.1.0 - v2.1.3]

The name change

Logout Reminder’s project name was changed to LTFO [v3.0.0] with inspiration from Leo Riviera on GitHub, who also contributed to the LTFO project by helping me learn about dictionaries, f-strings, and removing global variables from the code altogether.

1
2
3
4
5
6
β–ˆβ–ˆβ•—  β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ•—β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ•— β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ•— 
β–ˆβ–ˆβ•‘  β•šβ•β•β–ˆβ–ˆβ•”β•β•β•β–ˆβ–ˆβ•”β•β•β•β•β•β–ˆβ–ˆβ•”β•β•β•β–ˆβ–ˆβ•—
β–ˆβ–ˆβ•‘     β–ˆβ–ˆβ•‘   β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ•—  β–ˆβ–ˆβ•‘   β–ˆβ–ˆβ•‘
β–ˆβ–ˆβ•‘     β–ˆβ–ˆβ•‘   β–ˆβ–ˆβ•”β•β•β•  β–ˆβ–ˆβ•‘   β–ˆβ–ˆβ•‘
β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ•—β–ˆβ–ˆβ•‘   β–ˆβ–ˆβ•‘     β•šβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ•”β•
β•šβ•β•β•β•β•β•β•β•šβ•β•   β•šβ•β•      β•šβ•β•β•β•β•β• 

It was at this point that that LTFO began to receive many new features including:

  • Using my internal API [v3.0.1 - v3.0.2]

    When changing Logout Reminder’s project name to LTFO, I encountered a serious backwards compatibility issue where the update code in Logout Reminder would fail to update to LTFO. This was why I created my API

  • Custom messages completely replaced the contents of the flooded files [v4.0.0]

    Prior to v4.0.0, LTFO has treated custom messages as so:

    1
    2
    3
    4
    5
    6
    
    You forgot to logout!
        
    Custom message:  
    This is an example of a custom message!
        
    Removal instructions: Search 'READ\_ME#374.txt' in the root of your drive, select all, and delete.
    

    With v4.0.0, LTFO treated custom messages as so:

    1
    2
    3
    
    This is an example of a custom message!
        
    Removal instructions: Search 'READ\_ME#374.txt' in the root of your drive, select all, and delete.
    
  • Introduced {variables} for all message types [v4.0.0]

    Variables allowed for powerful automation with LTFO such as including the time, date, computer name and even the logged in username. These variables would allow for messages like this:

    1
    2
    3
    
    {username}, you forgot to logout of {computer} at {time} - {date}
        
    Dave, you forgot to logout of Computer-3 at 11:36 - 23.11.19
    
  • Comments & formatting from Leo Riviera

    It was at this point that I learnt how to use dictionaries and f-strings

  • Custom file selection via a GUI or with the $path/to/file command [v5.0.0]

So, what can it do?

LTFO is essentially a python script that duplicates a file into all subdirectories on the specified drive.

It has however, evolved into much more than just a tool to remind colleagues to logout. It was designed to be eye-catching and hence generates files in all sub-directories (you can’t really miss it!). This means that by creating a text document with a note inside it (into all sub-directories on a drive you have access to), LTFO can just about remind anyone about anything.

What users have to say

β€˜The removal script was a nice touch’ -Ross

β€˜Bomb ass coder. Work on your commenting tho’ -Leo Riviera

Features

  • Automatic updates
  • Copy/generate a file in subdirectories on a specific drive
  • Contents of generated files are completely customisable!
  • Custom variables such as {computer} and {username} which can be used in generated files
  • GUI file picker for selecting a file to copy
  • $path/to/file function for automation
  • Select a drive to flood with randomly generated files
  • Final randomly-generated confirmation code to prevent accidents
  • Generate removal/cleanup script to automatically remove all files generated

Installation

The script is designed to be ran from a USB drive, but you can also download the latest release directly onto the target machine.

Requirements

  • Python 3.6+

    If you are planning to use a python install from the USB, please create a shortcut to run the script using Python on the flash drive.

  • Windows

Screenshots

LTFO create message terminal window LTFO confirm all terminal window LTFO file generation terminal window LTFO removal tool terminal window LTFO default file contents
LTFO file explorer


This script was written and tested using Python 3.7 on Windows 10 and may not function as intended using different versions of Python or Windows.

This post is licensed under CC BY 4.0 by the author.