Design - ntopper/MD5AwSum GitHub Wiki

Table of Contents

Classes/Modules

md5lib

md5lib will be used to calculate the md5 checksum of a file, given a file path.

Subclasse(s)

    private class Hash   

Method(s)

getHash

    public static Md5Hash md5lib::getHash(file_name)

Returns an instance of the subclass Md5Hash given a file name.

Md5Hash (Subclass of md5lib)

Each instance of Md5Hash represents the Md5 Checksum of a given file.

Property(s)

    private constant string file_path
    private string checksum

Method(s)

Constructor

    Md5Hash::Md5Hash(_path) file_path(_path) 

Instantiates an Md5Hash object for the file at _path.

Digest

    public void Md5Hash::digest() throws (int)

Calculates the md5 checksum of the file specified in the 'file_path' property of an instance. Stores this hash as a string in the 'checksum' property of the instance. Throws an exception if the file could not be opened, or an error occurs while reading the stream.

getChecksum

    public Hash::getChecksum()

Returns the value stored in the 'checksum' property of the instance.

RainbowTable

Each instance of RainbowTable represents the parsed contents of the main hash table.

Property(s)

    private XMLTree tree
    private string file_path

Methods(s)

Constructor

    RainbowTable::RainbowTable()
    (overload)  RainbowTable::RainbowTable(string file_path)

With no arguments: a RainbowTable is instantiated with a `file_path` specified by the singleton instance of the config class.

With one string argument: a RainbowTable is instantiated with a `file_path` specified by the `file_path` paramater.

Parse

    RainbowTable::parse() throws(int)

Attempts to parse the XML document located at 'file_path', if the file is invalid or can not be read, and exemption is thrown. If the parsing is successful, the XML tree object is stored in `tree`

Search

     void RainbowTable::search(string hash)    

Searches all elements of `tree`, and prints out all child elements of any element who's has checksum property matches hash

Add

     void RainbowTable::add(string file_path, string key)    

Adds all elements from the xml hash table located at file_path to the instance's `tree` property, with key of `key`.

Remove

     void RainbowTable::remove(string key)    

Removes all elements from the xml hash table located at file_path to the instance's `tree` property, with key of `key`.

Write

     void RainbowTable::write()    

Overwrites hash table with contents of `tree` property.

Repository Manager

Responsible for making changes to the main hash table and downloading new repositories from the Internet.

Properties

    RainbowTable master

Methods(s)

Constructor

    RepositoryManager::RepositoryManager()

Will create an instance of RainbowTable and store it in the `master` property.

Add

    void RepositoryManager::add(string url)

Takes a string to a url where a hash table is located, downloads the hash table and temporarily puts it in the same directory as the main hash tables. Adds the downloaded hash table to the RainbowTable property `master`. If an exception is thrown, it prints the error, deletes the file, and then terminates the program. Otherwise, it will call the RainbowTable save method.

Remove

    void RepositoryManager::remove(string url)

Will ask the singleton instance config for the key of the specified url and will tell config to remove that url from itself. Will tell RainbowTable to remove everything with that key and then to save.

update

    void RepositoryManager::update(string url)

Would be the same as calling remove, then add.

Config

An abstraction that represents the configuration file.

Properties

    static Config instance
    map<string, string> url_map
    string rainbow_table_path

Methods(s)

Constructor

    Config ::Config ()

Reads from file located at /etc/md5sum/params. The text on the first line of that file gets stored on `rainbow_table_path`. Each next line gets read in and adds it to the map, where the key is the hash of the url string and the value is the key.

initialize

    static void Config ::initialize() 

Initializes the singleton instance of config, whose data is accessed by the non-member functions of this class.

add

    static void Config ::add(string url)

Hashes the url using the Md5 hash class, then adds the url and hash to the `url_map` as a key, value pair.

remove

    static void Config ::remove(string url)

Searches through the `url_map` and removes the key, value pair where the key matches the url.

update

    static void Config::update()

Overwrites the config file with the first line of `rainbow_table_path` and each next line as key, value pairs where the value is hash of the url.

External Files

Hash Table Formatting

Hash tables will take the form of XML documents. The root node of a valid table will be called "rainbow_table". each hash table entry will be called "entry", and will have a "hash" attribute, and a "key" attribute. The key represents the md5sum hash of the downloaded file containing the given element. (note: hash tables from the internet do not need this property, the key is generated by the Config class upon downloading). Any child node of :entry" represents an element of the entry, and will be printed out as a node/content pair.

example

    <rainbow_table>
        <entry hash="{entry_md5_hash}", key="{url_md5_hash}">
             <name>Ubuntu_14.04.iso</name>
             <source>help.ubuntu.com/community/UbuntuHashes</source>
             <foo>bar</foo>
        </entry>
        <entry hash="{entry_md5_hash}", key="{url_md5_hash}">
             <value>money1</value>
             <source>10k-common-passwords.txt</source>
        </entry>
    </rainbow_table>

Config File Formatting

The configuration file will be permanently located at /etc/md5sum/params

This file will specify the location of the local hash table, and the url/key pairs of the downloaded url tables, which are referenced when removing or updating the master table.

The first line will specify the location of the local master repository. Each succeeding line will hold a url and key combo separated by a space

Example

    /etc/md5sum/mastertable.xml
    http://www.mydistro.com/hashes.xml c8fb7b73f49f6badbee903fdf44223b2
    http://www.hashes.com/?v=2.7.4 cc6ed5c1a1ed3fb4c046ff2072f829a5
⚠️ **GitHub.com Fallback** ⚠️