Ejemplo n.º 1
0
 def testEsc1(self):
     d = Dump(0)
     self.assertEqual(d.esc[0], 0)
     d.add([0xdb, 0xdc])
     self.assertEqual(d.len, 1)
     self.assertEqual(d.esc[0], 1)
     self.assertEqual(d.data, [0xc0])
Ejemplo n.º 2
0
 def testEsc2(self):
     d = Dump(0)
     self.assertEqual(d.esc[1], 0)
     d.add([0xdb, 0xdd])
     self.assertEqual(d.len, 1)
     self.assertEqual(d.esc[1], 1)
     self.assertEqual(d.data, [0xdb])
Ejemplo n.º 3
0
    def testDumpProperties(self):
        dump = Dump(13)
        dump.data = bytearray(
            x2a('2E 02 00 00 01 00 D0 00 00 00 AB CD EF 12 34 56'))

        self.assertEqual(dump.serial, 'ABCDEF123456')
        self.assertEqual(dump.trackerType, 86)
Ejemplo n.º 4
0
 def testEsc2(self):
     d = Dump(0)
     self.assertEqual(d.esc[1], 0)
     d.add(bytearray([0xdb, 0xdd]))
     self.assertEqual(d.len, 1)
     self.assertEqual(d.esc[1], 1)
     self.assertEqual(d.data, b'\xdb')
Ejemplo n.º 5
0
 def testEsc1(self):
     d = Dump(0)
     self.assertEqual(d.esc[0], 0)
     d.add(bytearray([0xdb, 0xdc]))
     self.assertEqual(d.len, 1)
     self.assertEqual(d.esc[0], 1)
     self.assertEqual(d.data, b'\xc0')
Ejemplo n.º 6
0
 def testFooterIsSet(self):
     d = Dump(0)
     self.assertEqual(len(d.footer), 0)
     footer = b'\xc0' + bytearray(range(5))
     d.add(footer)
     self.assertEqual(d.len, 0)
     self.assertEqual(d.footer, footer)
Ejemplo n.º 7
0
def main():
    parser = argparse.ArgumentParser(
        description='Decrypt dumps collected earlier')
    parser.add_argument('trackerId')
    args = parser.parse_args()

    dumpDir = '~/.galileo'

    db = LocalDatabase(dumpDir)

    trackerId = args.trackerId
    trackerDumpDir = db.getDeviceDirectoryName(trackerId)
    key = db.loadKey(trackerId)

    files = os.listdir(trackerDumpDir)
    files = [x for x in files if not 'dec' in x]
    for filename in files:
        dumpname = os.path.join(trackerDumpDir, filename)
        file = open(dumpname)

        data = file.read()

        pieces = data.split('\n\n')

        responsePresent = len(pieces) == 2
        if responsePresent:
            [megadumpData, megadumpResponseData] = pieces
        else:
            [megadumpData] = pieces

        megadump = Dump(MEGADUMP)
        megadump.data = bytearray(x2a(megadumpData))
        megadump.megadump()

        try:
            decrypt(megadump, key)
        except UnknownDumpTypeError:
            print('Encountered an UnknownDumpTypeError in the dump of file: ' +
                  filename)
        megadump.toFile(dumpname.replace('.txt', '_dec.txt'))

        if responsePresent:
            CHUNK_LEN = 20
            megadumpResponse = DumpResponse(x2a(megadumpResponseData),
                                            CHUNK_LEN)

            megadumpResponse.megadump()
            try:
                decrypt(megadumpResponse, key, offset=10)
            except UnknownDumpTypeError:
                print(
                    'Encountered an UnknownDumpTypeError in the responsedump of file: '
                    + filename)
            megadumpResponse.toFile(dumpname.replace('.txt', '_resp_dec.txt'))
Ejemplo n.º 8
0
 def testValid(self):
     d = Dump(0)
     d.add(range(10))
     d.add([0xc0]+[0, 0, 0x78, 0x23, 10, 0])
     self.assertTrue(d.isValid())
Ejemplo n.º 9
0
 def testNonValidLen(self):
     d = Dump(0)
     d.add(range(10))
     d.add([0xc0]+[0, 0, 0x78, 0x23, 0, 0])
     self.assertFalse(d.isValid())
Ejemplo n.º 10
0
 def testEmptyNonValid(self):
     d = Dump(6)
     self.assertFalse(d.isValid())
Ejemplo n.º 11
0
 def testNonValidDataType(self):
     d = Dump(0)
     d.add(range(10))
     d.add([0xc0]+[0, 3])
     self.assertFalse(d.isValid())
Ejemplo n.º 12
0
 def testToBase64(self):
     d = Dump(0)
     d.add(range(10))
     d.add([0xc0] + list(range(8)))
     self.assertEqual(d.toBase64(), 'AAECAwQFBgcICcAAAQIDBAUGBw==')
Ejemplo n.º 13
0
 def testOnlyFooterInvalid(self):
     """ A dump with only a footer is an invalid dump """
     d = Dump(0)
     d.add([0xc0] + list(range(5)))
     self.assertFalse(d.isValid())
Ejemplo n.º 14
0
 def testFooterIsSet(self):
     d = Dump(0)
     self.assertEqual(d.footer, [])
     d.add([0xc0] + list(range(5)))
     self.assertEqual(d.len, 0)
     self.assertEqual(d.footer, [0xc0] + list(range(5)))
Ejemplo n.º 15
0
 def testAddIncreasesLen(self):
     d = Dump(5)
     self.assertEqual(d.len, 0)
     d.add(range(10))
     self.assertEqual(d.len, 10)
Ejemplo n.º 16
0
 def testHugeDump(self):
     # issue 177
     d = Dump(0)
     d.add([5] * 71318)
     d.add([0xc0] + [0, 0, 0x44, 0x95, 0x96, 0x16, 0x01, 0x00])
     self.assertTrue(d.isValid())