• New tool: convert-ts-bash-history.py, (Fri, Sep 26th) SANS Internet Storm Center, InfoCON: green
    • Volvo Employee SSNs Stolen in Supplier Ransomware Attack darkreadingNate Nelson, Contributing Writer
    • Researchers Expose SVG and PureRAT Phishing Threats Targeting Ukraine and Vietnam The Hacker [email protected] (The Hacker News)
    • Iranian State Hackers Use SSL.com Certificates to Sign Malware darkreadingRob Wright
    • Prep is Underway, But 2026 FIFA World Cup Poses Significant Cyber Challenges darkreadingRobert Lemos, Contributing Writer
    • The Beginner’s Guide to Using AI: 5 Easy Ways to Get Started (Without Accidentally Summoning Skynet)
      by Tech Jacks
      March 29, 2025
    • Tips and Tricks to Enhance Your Incident Response Procedures
      by Tech Jacks
      March 17, 2025
    • Building a Security Roadmap for Your Company: Strategic Precision for Modern Enterprises 
      by Tech Jacks
      March 10, 2025
    • The Power of Policy: How Creating Strong Standard Operating Procedures Expedites Security Initiatives
      by Tech Jacks
      March 6, 2025
    • Building a Future-Proof SOC: Strategies for CISOs and Infosec Leaders 
      by Tech Jacks
      March 3, 2025
    • Security Gate Keeping – Annoying – Unhelpful
      by Tech Jacks
      November 13, 2024

  • Home
  • Blog & Observations
  • Articles
    • Guest Author
      • Peter Ramadan
        • SOC IT to ME
        • The Power of Policy
        • CISO Elite
  • In The News
  • Podcast & Vlogs
    • Podcast Videos
    • Security Unfiltered Podcast Information
  • Training & Videos
    • AI
      • AI Governance
    • Cloud
      • AWS
      • Azure
      • Google Cloud
    • Networking
    • Scripting
    • Security
      • Application Security
      • Cloud Security
      • Incident Response
      • Pentesting Information
      • Risk Management
      • Security Policy
    • Servers
    • Microsoft SCCM
    • ISC2
  • Services

New tool: convert-ts-bash-history.py, (Fri, Sep 26th) SANS Internet Storm Center, InfoCON: green

September 26, 2025

In SANS FOR577&#;x26;#;x5b;1&#;x26;#;x5d;, we talk about timelines on day 5, both filesystem and super-timelines. but sometimes, I want something quick and dirty and rather than fire up plaso, just to create a timeline of .bash&#;x26;#;x5f;history data, it is nice to just be able to parse them and, if timestamps are enabled, see them in a human-readable form. I&#;x26;#;39;ve had some students in class write scripts to do this and even had one promise to share it with me after class, but I never ended up getting it so I decided to write my own. This script takes the path to 1 or more .bash&#;x26;#;x5f;history files and returns a PSV (pipe separated values) list (on stdout) in the form: || where the is in ISO-8601 format (the one true date time format, but only to 1 sec resolution since that his the best that the .bash&#;x26;#;x5f;history file will give us). In a future version I will probably offer an option to change from PSV to CSV. 

In SANS FOR577[1], we talk about timelines on day 5, both filesystem and super-timelines. but sometimes, I want something quick and dirty and rather than fire up plaso, just to create a timeline of .bash_history data, it is nice to just be able to parse them and, if timestamps are enabled, see them in a human-readable form. I’ve had some students in class write scripts to do this and even had one promise to share it with me after class, but I never ended up getting it so I decided to write my own. This script takes the path to 1 or more .bash_history files and returns a PSV (pipe separated values) list (on stdout) in the form: <filename>|<datetime>|<command> where the <datetime> is in ISO-8601 format (the one true date time format, but only to 1 sec resolution since that his the best that the .bash_history file will give us). In a future version I will probably offer an option to change from PSV to CSV. 

One of the ways I have used it is by piping the output through sort, in particular | sort -t '|' -k 2 to take a bunch of bash history files and sort them in time order. I’ve gone back and forth on whether or not to swap the first 2 columns, but since I encounter so many more history files without timestamps than with, having the path to the particular file that contains the command first has been quite useful. I might also add a switch to leave the file path off. I welcome comments/thoughts from others out there who might use it. There is a reason that this is v0.9, not yet v1.0.

The script (as seen in the title) is called convert-ts-bash-history.py[2], and here are a couple of screenshots to show its usage. You can find it in my github scripts repo[3].

usage info

And, the following 2 show the bash history before and after I turned on timestamps

screenshot of script run on bash history without timestamps

and

screenshot of tool run against bash history file with timestamps enabled

Finally, a reminder, as we point out in class, the bash history files are written when the shell exits, so if you are grabbing a triage on a live system and a shell is still open, the history will only be in memory, not on the disk (yet). If you want to learn more about Linux incident response and forensics, I’m teaching FOR577 one more time this year at one of my favorite conferences, SANS DFIRCON[4] in Miami in Nov, I’d love to see you there.

References:

[1] https://www.sans.org/cyber-security-courses/linux-threat-hunting-incident-response

[2] https://github.com/clausing/scripts/blob/master/convert-ts-bash-history.py

[3] https://github.com/clausing/scripts

[4] https://www.sans.org/cyber-security-training-events/dfircon-miami-2025

—————
Jim Clausing, GIAC GSE #26
jclausing –at– isc [dot] sans (dot) edu

(c) SANS Internet Storm Center. https://isc.sans.edu Creative Commons Attribution-Noncommercial 3.0 United States License. 

​Read More

Share this:

  • Click to share on X (Opens in new window) X
  • Click to share on Reddit (Opens in new window) Reddit
  • Click to share on LinkedIn (Opens in new window) LinkedIn
  • Click to share on Facebook (Opens in new window) Facebook
  • Click to email a link to a friend (Opens in new window) Email

Like this:

Like Loading...
Share

In The News

Tech Jacks
Derrick Jackson is a IT Security Professional with over 10 years of experience in Cybersecurity, Risk, & Compliance and over 15 Years of Experience in Enterprise Information Technology

Leave A Reply


Leave a Reply Cancel reply

You must be logged in to post a comment.

This site uses Akismet to reduce spam. Learn how your comment data is processed.

  • Blog

    • Security Gate Keeping - Annoying - Unhelpful
      November 13, 2024
    • 15 Years on LinkedIn: An Authentic Reflection(or a Beauty...
      October 24, 2024
    • Podcast & Cloud Security Governance
      February 24, 2021
    • The Journey Continues - Moving through 2021
      January 5, 2021
    • CISSP Journey
      February 22, 2019




  • About TechJacks
  • Privacy Policy
  • Gaming Kaiju
© Copyright Tech Jacks Solutions 2025

%d