How to use get_packed method in autotest

Best Python code snippet using autotest_python

PyOS.py

Source:PyOS.py Github

copy

Full Screen

...137 #138 # get_packed: Packs all our values, since we are not using any139 # nothing much goes on140 #141 def get_packed(self):142 packeddata = ""143 144 # NULL it out for now145 packeddata = "\x00" * 0x20c146 147 return packeddata148 149 '''150 __LDR:151 152 A LDR_DATA class for the future! and beyond!153 ''' 154 class __LDR:155 def __init__(self):156 self.Address = 0x0000000157 158 # I need to add the LDR_DATA elements159 160 #161 # get_packed: Packs all our values, since we are not using any162 # nothing much goes on163 # 164 def get_packed(self):165 packeddata = ""166 167 # NULL it out for now168 packeddata = "\x00" * 0x28169 170 return packeddata171 172 '''173 __THREAD:174 175 A THREAD class which contains our TEB and LDT. This has been176 implemented to allow access to the SEH and selectors of the177 current thread. This is not complete and simply a "good enough"178 implementation.179 '''180 class __THREAD:181 def __init__(self):182 183 # Initialize a TEB and LDT184 self.TEB = self.__TEB()185 self.LDT = self.__LDT()186 187 #188 # load_teb: Handles getting memory for the TEB and setting values189 #190 def load_teb(self, emu, address):191 self.TEB.Address = address192 193 emu.memory.allocate_page(self.TEB.Address)194 # Store our TEB in actual memory195 emu.set_memory(self.TEB.Address, self.TEB.get_packed())196 197 return True198 199 #200 # load_stack: Responsible for setting TIB stack values201 #202 def load_stack(self, emu, stackbase, stacklimit):203 # Fetch a page into cache for our stack204 emu.memory.allocate_page(stacklimit)205 206 self.TEB.TIB.StackBase = stackbase207 self.TEB.TIB.StackLimit = stacklimit208 209 return True210 211 #212 # load_exceptions: Responsible for setting TIB exception values213 #214 def load_exceptions(self, emu):215 # A generic address to get us started216 self.TEB.TIB.ExceptionList = self.TEB.TIB.StackBase - 0x24217 218 # Init a LDT entry four our TIB selector219 selector = self.LDT.get_selector(0x3b)220 selector.base = self.TEB.TIB.ExceptionList221 222 # Store the exception entry in actual memory223 emu.set_memory(self.TEB.TIB.ExceptionList, 0xffffffff)224 emu.set_memory(self.TEB.TIB.ExceptionList + 0x4, 0xdeadbeef)225 226 return True227 228 '''229 __TEB:230 231 A class to represent the TEB. The only thing we are232 currently interested in is the TIB so the rest of the TEB233 is faked234 ''' 235 class __TEB:236 def __init__(self):237 self.Address = 0x00000000238 239 # Initialize a new TIB (this is offset 0x0 in _TEB 240 self.TIB = self.__TIB()241 242 # Rest of the TEB would go here243 #244 # get_packed: Packs all our values, since we are not using any245 # besides the TIB we do that then pad the rest246 #247 def get_packed(self):248 packeddata = ""249 250 # Pack and pad251 packeddata = self.TIB.get_packed()252 packeddata += "\x00" * (0xfb6 - len(packeddata))253 254 return packeddata255 256 '''257 __TIB:258 259 A class to store the import TIB information. This includes260 our stack boundaries and seh chain261 '''262 class __TIB:263 def __init__(self):264 self.ExceptionList = 0x00000000265 self.StackBase = 0x00000000266 self.StackLimit = 0x00000000267 self.SubSystemTib = 0x00000000268 self.FiberData = 0x00000000269 self.ArbitraryUserPointer = 0x00000000270 self.Self = 0x00000000271 272 #273 # get_packed: Packs all our values, im sure there is a274 # much better way to do this.275 # 276 def get_packed(self):277 packeddata = ""278 279 packeddata = struct.pack("<L", self.ExceptionList)280 packeddata += struct.pack("<L", self.StackBase)281 packeddata += struct.pack("<L", self.StackLimit)282 packeddata += struct.pack("<L", self.SubSystemTib)283 packeddata += struct.pack("<L", self.FiberData)284 packeddata += struct.pack("<L", self.ArbitraryUserPointer)285 packeddata += struct.pack("<L", self.Self)286 287 return packeddata288 289 '''290 __EXCEPTION_RECORD:291 292 A class for handling exception records. Currently293 this is not used, but I like to type.294 '''295 class __EXCEPTION_RECORD:296 def __init__(self):297 self.Next = 0x00000000298 self.Handler = 0x00000000299 300 def get_packed(self):301 packeddata = ""302 303 packeddata = struct.pack("<L", self.Next)304 packeddata += struct.pack("<L", self.Handler)305 306 return packeddata307 308 '''309 __LDT:310 311 A local descriptor table per thread. This is to allow us to312 access the TIB selector for exception handling.313 ''' 314 class __LDT:...

Full Screen

Full Screen

ServiceCode.pys

Source:ServiceCode.pys Github

copy

Full Screen

...19 raise Ex.MediaExpired20 title = html.xpath('//input[@name="fname"]/@value')21 if not title:22 raise Ex.MediaExpired23 page = get_packed(get_page(url))24 rt = RE_THUMB.search(page)25 rd = RE_DUR.search(page)26 thumb = rt.group(1) if rt else FALLBACK27 return VideoClipObject(28 title=title[0].strip(),29 duration=int(rd.group(1)) * 1000 if rd else None,30 thumb=Resource.ContentsOfURLWithFallback([thumb, FALLBACK]),31 source_title='Streamin'32 )33####################################################################################################34def MediaObjectsForURL(url):35 return [36 MediaObject(37 audio_channels=2,38 optimized_for_streaming=False,39 parts=[40 PartObject(key=Callback(PlayVideo, url=url))41 ]42 )43 ]44####################################################################################################45@indirect46def PlayVideo(url, **kwargs):47 r = RE_FILE.search(get_packed(get_page(url)))48 if r:49 Log.Debug(u"* PlayVideo URL = {0}".format(r.group(1)))50 return IndirectResponse(VideoClipObject, key=r.group(1))51 raise Ex.MediaNotAvailable52####################################################################################################53def get_packed(page):54 packed = RE_PACKED.search(page)55 if packed:56 page = Unpack(packed.group(1))57 return page58####################################################################################################59def get_page(url):60 try:61 page = HTTP.Request(url, cacheTime=10).content62 except:63 Log.Exception(u"* Error: Cannot open '{0}' >>>".format(url))64 raise Ex.MediaNotAvailable...

Full Screen

Full Screen

Automation Testing Tutorials

Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.

LambdaTest Learning Hubs:

YouTube

You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.

Run autotest automation tests on LambdaTest cloud grid

Perform automation testing on 3000+ real desktop and mobile devices online.

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?

Helpful

NotHelpful