def getDetails(self, path): """ Read and return Shared Object. """ lso = sol.load(path) return lso
def read_flashcookies(self): self.flashcookies_files = [] for base_path in self.get_base_paths(): user_dir = {} for entry in os.listdir(base_path): target = os.path.join(base_path, entry) if os.path.isdir(target): user_dir['randomized'] = entry for dirpath, dirnames, filenames in os.walk(base_path): self.visit_flashcookies_files(user_dir, dirpath, filenames) # os.path.walk(base_path, self.visit_flashcookies_files, user_dir) self.flashcookies = {} for item in self.flashcookies_files: try: dirname, entry, randomized = item filename = os.path.join(dirname, entry) n = dirname.find(randomized) if n > -1: domain = dirname[n+len(randomized)+1:] n = domain.find(os.path.sep) if n > -1: domain = domain[:n] if domain not in self.flashcookies: self.flashcookies[domain] = [] lso = sol.load(filename) self.flashcookies[domain].append(lso) except Exception as error: self.framework.report_exception(error) return self.flashcookies
def solToJson(infile): '''Open a Local Shared Object, convert it to a json, dump it to a file.''' open(infile, 'rb') lso = sol.load(infile) with open(infile[:-4] + '.json', 'w') as outfile: json.dump(lso, outfile, indent=4, separators=(',', ': '))
def parse_strace_logs(visit_info, test_lso=None): events = [] lines_seen = Set() # cm.print_log(visit_info, visit_info.sys_log, cm.LOG_DEBUG) for line in fu.gen_cat_file(visit_info.sys_log): if (".macromedia/Flash_Player/#SharedObjects" not in line or (line in lines_seen)): continue lines_seen.add(line) try: pieces = line.split("#SharedObjects/")[1].split("/") lso_file, mode_str = pieces[-1].split("\"") if "O_RDWR" in mode_str: mode = cm.ACCESS_MODE_READ_WRITE else: mode = cm.ACCESS_MODE_READ_ONLY domain = pieces[1] filename = line.split("\"")[1] file_ext = filename.rsplit(".", 1)[-1] # We observe .sxx extension for LSOs instead of .sol in strace logs # We recover the real filename by replacing # [pid 26407] open("/home/xyz/.macromedia/Flash_Player/#SharedObjects/GWZSHMBL/securehomes.esat.kuleuven.be/FlashCookie.sxx", O_RDWR|O_CREAT|O_APPEND, 0666) = 18 # noqa # [pid 26407] write(18, "\0\277\0\0\0-TCSO\0\4\0\0\0\0\0\vFlashCookie\0\0\0\3\21test_key\6\rjb0uf9\0", 51) = 51 # noqa # the only file in SharedObjects/GWZSHMBL/securehomes.esat.kuleuven.be would be a .sol file, which is not in the strace logs if it's created on this visit. # noqa if file_ext == "sxx": filename = filename.replace(".sxx", ".sol") if test_lso is not None: # just to simplify tests filename = test_lso # override the lso filename if not filename.endswith(".sol"): print "Unexpected LSO file extension", filename, file_ext, line continue if not os.path.isfile(filename): # Happens when the (temp) LSO is removed before the visit ends. print "Cannot find LSO file", filename, file_ext, line continue except ValueError: continue # TODO: move below code to a separate function try: lso_dict = sol.load(filename) for k, v in lso_dict.iteritems(): be = cm.BrowserEvent() be.event_type = cm.EVENT_FLASH_LSO be.js_file = lso_file be.initiator = domain be.mode = mode # this doesn't seem to work be.cookie_path = filename.split("#SharedObjects/")[1] be.key = unicode(k) try: be.log_text = unicode(v) except UnicodeDecodeError: # obj is byte string ascii_text = str(v).encode('string_escape') be.log_text = unicode(ascii_text) events.append(be) except Exception as exc: cm.print_log(visit_info, "Error parsing LSO %s %s" % (filename, exc)) return events
def test_load_name(self): fp = self._load() fp.close() s = sol.load(self.file_name) self.assertEqual(s.name, 'hello') self.assertEqual(s, {'name': 'value', 'spam': 'eggs'})
def test_load_name(self): fp = self._load() fp.close() s = sol.load(self.file_name) self.assertEquals(s.name, 'hello') self.assertEquals(s, {'name': 'value', 'spam': 'eggs'})
def test_load_name(self): fp = self._load() fp.close() s = sol.load(self.file_name) self.assertEquals(s.name, "hello") self.assertEquals(s, {"name": "value", "spam": "eggs"})
def test_load_file(self): fp = self._load() y = fp.tell() fp.seek(0) s = sol.load(fp) self.assertEquals(s.name, "hello") self.assertEquals(s, {"name": "value", "spam": "eggs"}) self.assertEquals(y, fp.tell())
def test_load_file(self): fp = self._load() y = fp.tell() fp.seek(0) s = sol.load(fp) self.assertEqual(s.name, 'hello') self.assertEqual(s, {'name': 'value', 'spam': 'eggs'}) self.assertEqual(y, fp.tell())
def test_load_file(self): fp = self._load() y = fp.tell() fp.seek(0) s = sol.load(fp) self.assertEquals(s.name, 'hello') self.assertEquals(s, {'name': 'value', 'spam': 'eggs'}) self.assertEquals(y, fp.tell())
def __init__(self, *args): if len(args) < 2: raise Framework.exceptions.FrameworkException('AMF.SOL() requires at least two arguments') #TODO: Paths for Linux & Windows sol_path = os.path.expanduser("~/Library/Preferences/Macromedia/Flash Player/#SharedObjects") subdir = [d for d in os.listdir(sol_path) if re.match("^[A-Z0-9]{8}$", d)][0] # hopefully there's only one... self._path = os.path.join(sol_path, subdir, *args) + '.sol' if os.path.exists(self._path): self._sol = sol.load(self._path) else: self._sol = sol.SOL(args[-1])
def gen_flash_cookies(lso_dirs=COMMON_LSO_DIRS, mod_since=0): """Return a generator of Flash cookies (Local Shared Objects).""" for top_dir in lso_dirs: top_dir = os.path.expanduser(top_dir) for lso_file in fu.gen_find_files("*.sol", top_dir): mtime = os.path.getmtime(lso_file) if mtime > mod_since: try: lso_content = sol.load(lso_file) # lso_content is a dict that need to be parsed except: print "Exception reading", lso_file else: yield lso_content, lso_file
def get_uid(self): if not GOT_PYAMF: if DEBUG: log('lso::get_uid: mising pyamf') return path = self.build_path(self.root, self.name) if DEBUG: log('lso::get_uid: path', path) uid = None try: if path is not None and os.path.isfile(path): lso = sol.load(path) if DEBUG: log('lso::get_uid: file found, try to load: path', path, 'data', lso) if lso.has_key('uid'): uid = lso['uid'] if DEBUG: log('lso::get_uid: successfullly loaded: uid', uid, 'path', path) elif DEBUG: log('lso::get_uid: file not found: path', path) except: if DEBUG: print_exc() if uid is None: uid = self.create_uid() if DEBUG: log('lso::get_uid: create new uid:', uid) if path is not None and uid is not None: try: d = os.path.dirname(path) if not os.path.isdir(d): os.mkdir(d) lso = sol.SOL(self.name) lso['uid'] = uid if DEBUG: log('lso::get_uid: save to file: path', path, 'data', lso) sol.save(lso, path) except: if DEBUG: print_exc() return uid
def parse_flash_cookies(lso_file): lso_dict = sol.load(lso_file) flash_cookies = list() for k, v in lso_dict.iteritems(): flash_cookie = FlashCookie() flash_cookie.local_path = lso_file.split("#SharedObjects/")[1] flash_cookie.filename = os.path.basename(lso_file) flash_cookie.domain = lso_file.split("#SharedObjects/")[1].split("/")[1] flash_cookie.key = unicode(k) try: flash_cookie.content = unicode(v) except UnicodeDecodeError: # obj is byte string ascii_text = str(v).encode('string_escape') flash_cookie.content = unicode(ascii_text) flash_cookies.append(flash_cookie) return flash_cookies
def read(self, signature: str, length: int) -> tuple: return struct.unpack(signature, self.consume(length)) def read_one(self, record_type: Type[Record]) -> Record: return record_type( *self.read(record_type.signature(), record_type.length())) def read_many(self, record_type: Type[Record]) -> Iterable[Record]: [num_records] = self.read('>H', 2) records = [] for _i in range(num_records): records.append(self.read_one(record_type)) return records @staticmethod def _get_bytes(savedata: str) -> bytes: decoded = base64.b64decode(savedata[4:-2]) decompressed = zlib.decompress(decoded, 15) key = b'therealmisalie' deciphered = b'' for i, byte in enumerate(decompressed): deciphered += bytes([byte ^ key[i % len(key)]]) return deciphered SAVE_FILE = 'C:/Users/James/AppData/Roaming/com.kongregate.mobile.realmgrinder.air/Local Store/#SharedObjects/RealmGrinderDesktop.swf/realm-grinder.sol' Serializer.deserialize(sol.load(SAVE_FILE)['save'])
import json from GUIAMULET import * from threading import Thread import subprocess import time from pyamf import sol import sys from proxymanager import ProxyManager from amulet import * app = wx.App(False) frame1 = MyFrame2(None) frame2 = MyFrame1(None) frame3 = ProxyManager() d = dict(sol.load('items.sol')) d['1000 cents'] = '1000cents' d['300 cents'] = '300cents' d['50 cents'] = '50cents' d['10 cents'] = '10cents' d['100 cents'] = '100cents' d['30 cents'] = '30cents' keys = d.keys() keys = sorted(keys) m_checkList2 = wx.CheckListBox(frame2, wx.ID_ANY, wx.DefaultPosition, wx.DefaultSize, keys, 0) frame2.bSizer1.Add(m_checkList2, 1, wx.ALL | wx.EXPAND, 5) frame2.Layout() frame2.m_checklist = m_checkList2 itemsarray = {} idsarray = d for q in d: itemsarray[d[q]] = q
#!/usr/bin/python import sys import yaml from pyamf import sol, AMF3 solfile = str(sys.argv[1]) outfile = open(str(sys.argv[2]), "w") lsodata = sol.load(solfile) yaml.dump(lsodata, outfile, default_flow_style=False) outfile.close()