1 / 14

Fun With Thread Local Storage (part 1)

Fun With Thread Local Storage (part 1). Peter Ferrie Senior Anti-virus Researcher 18 June, 2008. 1. You Can Call Me Al. Thread Local Storage callbacks were discovered in 2000. However, widespread use didn’t occur until 2004. Now, it should be the first place to look for code,

ferris
Download Presentation

Fun With Thread Local Storage (part 1)

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Fun With Thread Local Storage (part 1) Peter Ferrie Senior Anti-virus Researcher 18 June, 2008 1

  2. You Can Call Me Al Thread Local Storage callbacks were discovered in 2000. However, widespread use didn’t occur until 2004. Now, it should be the first place to look for code, since it runs before the main entrypoint. And that can make all the difference… 2 Peter Ferrie, Microsoft Corporation

  3. Empty! Entry Point 3 Peter Ferrie, Microsoft Corporation

  4. Empty! C3 RET 4 Peter Ferrie, Microsoft Corporation

  5. Empty! So the main file does nothing. If we assume that the structure is normal, then we could check the thread local storage table. Just in case. 5 Peter Ferrie, Microsoft Corporation

  6. Empty! TLS is present (size doesn’t matter) 6 Peter Ferrie, Microsoft Corporation

  7. Empty! Callback pointer Callback array 7 Peter Ferrie, Microsoft Corporation

  8. Empty! So the search moves to the callbacks, of which there is only one... or is there? 8 Peter Ferrie, Microsoft Corporation

  9. The One and Only 9 Peter Ferrie, Microsoft Corporation

  10. Am I Missing Something? CODE:00401013 mov ds:TlsCallbacksEnd, offset loc_401000 CODE:0040101D retn Who ever heard of a one-line callback? 10 Peter Ferrie, Microsoft Corporation

  11. Write the Right It’s about what you write, and where you write it. By writing to TlsCallbacksEnd, the array is extended in memory. Now the array contains two entries, not one. 11 Peter Ferrie, Microsoft Corporation

  12. Surprise! 12 Peter Ferrie, Microsoft Corporation

  13. Not OK The second entry is executed after the first one returns. The array can be extended infinitely. Existing entries can be altered at runtime, too. For example, one entry can decrypt the others. 13 Peter Ferrie, Microsoft Corporation

  14. Really Not OK Just a little something to add to the workload. 14 Peter Ferrie, Microsoft Corporation

More Related