1   
  2   
  3   
  4   
  5   
  6   
  7   
  8   
  9   
 10   
 11   
 12   
 13   
 14   
 15   
 16   
 17   
 18   
 19   
 20   
 21   
 22   
 23  """This is an address space for the Lime file format. 
 24   
 25  Note that Lime is an ad-hoc file format produced by the Lime Linux memory 
 26  acquisition tool (https://github.com/504ensicsLabs/LiME). The format does not 
 27  really offer any advantages over the standard ELF core dump format and should 
 28  therefore be avoided. This address space simply allows Rekall to read images 
 29  produced by Lime in case you have such an image about. 
 30  """ 
 31   
 32  from rekall import addrspace 
 33  from rekall.plugins.overlays import basic 
 34   
 35   
 36 -class LimeProfile(basic.ProfileLP64, basic.BasicClasses): 
  37      """A profile for Lime files.""" 
 38   
 40          super(LimeProfile, self).__init__(**kwargs) 
 41          self.add_overlay({ 
 42              'lime_header': [0x20, { 
 43                  'magic': [0x0, ['String', dict(length=4)]], 
 44                  'version': [0x4, ['unsigned int']], 
 45   
 46                   
 47                   
 48                   
 49                  'start': [0x8, ['unsigned long long']], 
 50                  'end': [0x10, ['unsigned long long']], 
 51   
 52                   
 53                   
 54                   
 55                   
 56                  'size': lambda x: x.end - x.start + 1, 
 57   
 58                   
 59                  'next': lambda x: x.cast( 
 60                      "lime_header", 
 61                      offset=x.obj_offset + x.size + x.obj_size), 
 62              }] 
 63          }) 
   64   
 65   
 67      """An Address Space to read from lime images.""" 
 68   
 69      name = "lime" 
 70      __image = True 
 71   
 72      order = 50 
 73   
 85   
 86 -    def vtop(self, addr): 
  87          """I have no idea why this is needed. 
 88   
 89          This hack is also present in the Volatility address space without 
 90          suitable explanation, so we just blindly add it here. 
 91          """ 
 92          smallest_address = self.runs.get_next_range_start(-1) 
 93   
 94          if addr < smallest_address: 
 95              addr = smallest_address + addr 
 96   
 97          return super(LimeAddressSpace, self).vtop(addr) 
  98   
 99 -    def read(self, addr, length): 
 100          smallest_address = self.runs.get_next_range_start(-1) 
101          if addr > 0 and addr < smallest_address: 
102              addr = smallest_address + addr 
103   
104          return super(LimeAddressSpace, self).read(addr, length) 
  105