Python Forum
Thread Rating:
  • 4 Vote(s) - 2.75 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Python Hash list check
#1
Hi All, 

First post!

I'm Looking for a bit of help with a small task. 


I am pretty new to python and have a program which generates a list of hashes in either md5 or sha256 (users choice) for every file in a directory and subdirectories using oswalk then outputs that list to a report, example below.

('Format = hash,filename ', '/users')
284d3b132b8586183474ff8c5e396d3a62b9b9fd7cafb448e137d0ec493ad5ce         /users/"username"/.bash_history

I'm look for help on how to compare the hashes in the report file with a list list of known good ones. I'm completely stuck on how to get this started.

Any help would be greatly appreciated.
Reply
#2
Perhaps a good way to get started is with a clearer definition of the problem. Planning a largely underestimated skill in programming. What is a "good hash"? What sort of comparison are you trying to do?
Craig "Ichabod" O'Brien - xenomind.com
I wish you happiness.
Recommended Tutorials: BBCode, functions, classes, text adventures
Reply
#3
(Feb-26-2017, 08:54 PM)ichabod801 Wrote: Perhaps a good way to get started is with a clearer definition of the problem. Planning a largely underestimated skill in programming. What is a "good hash"? What sort of comparison are you trying to do?

Sorry I should have expanded:

This is in relation to Digital Forensics, the exported list as mentioned in the OP contains hashes for all files in any given/specified directory and subdirectories. What I need to do is compare this list of hashes with a list of known good hashes i.e. perform an md5checksum or equivalent check on sha256 this will (at the end of the program) output three files containing known good hashes, known bad hashes and a list that requires further investigation

A list of known good hashes can be found at https://www.owasp.org/index.php/OWASP_Fi...Repository, the questions I have is how do I start coding python to read in the hashes and compare them to the above database (as an example) and flag up if it's good or not?

Hope that makes sense.
Reply
#4
Read the list of known good ones into a dictionary (keys: file paths, values, hashes). Then once you have recomputed the hash of a file, retrieve the expected hash from the dictionary using the file path, and compare the two.
Unless noted otherwise, code in my posts should be understood as "coding suggestions", and its use may require more neurones than the two necessary for Ctrl-C/Ctrl-V.
Your one-stop place for all your GIMP needs: gimp-forum.net
Reply
#5
(Feb-27-2017, 09:35 AM)Ofnuts Wrote: Read the list of known good ones into a dictionary (keys: file paths, values, hashes). Then once you have recomputed the hash of a file, retrieve the expected hash from the dictionary using the file path, and compare the two.

Thanks, that makes some degree of sense, i'll look into that  Thumbs Up
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  Help with to check an Input list data with a data read from an external source sacharyya 3 415 Mar-09-2024, 12:33 PM
Last Post: Pedroski55
  [solved] list content check paul18fr 6 718 Jan-04-2024, 11:32 AM
Last Post: deanhystad
  [SOLVED] How to crack hash with hashlib Milan 0 1,421 Mar-09-2023, 08:25 PM
Last Post: Milan
  check if element is in a list in a dictionary value ambrozote 4 1,986 May-11-2022, 06:05 PM
Last Post: deanhystad
  How to check if a list is in another list finndude 4 1,844 Jan-17-2022, 05:04 PM
Last Post: bowlofred
Question Problem: Check if a list contains a word and then continue with the next word Mangono 2 2,517 Aug-12-2021, 04:25 PM
Last Post: palladium
  how to check if string contains ALL words from the list? zarize 6 7,247 Jul-22-2020, 07:04 PM
Last Post: zarize
  Hash command works differently for me in CMD and Spyder ZweiDCG 3 2,360 Sep-10-2019, 01:10 PM
Last Post: DeaD_EyE
  length constraint on phrase hash to password javaben 0 1,922 Aug-21-2019, 05:34 PM
Last Post: javaben
  Create file archive that contains crypto hash ED209 1 2,064 May-29-2019, 03:05 AM
Last Post: heiner55

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020