Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Keep Calm, it's Reverse Engineering Time - PyTN2016

Alissa Bonas
February 07, 2016

Keep Calm, it's Reverse Engineering Time - PyTN2016

As developers, sometimes we have to investigate a bug, or add a new feature in a codebase that is completely new to us. Sometimes it can be even developed in technology that we are unfamiliar with, often with no one available to ask anything about that code. How can we do this?
In this talk I would like to share some ideas, tips and tools related to reverse engineering of various code components (server side, frontend, etc) – that can help developers to successfully overcome this challenge.

Alissa Bonas

February 07, 2016
Tweet

More Decks by Alissa Bonas

Other Decks in Technology

Transcript

  1. When is it needed? • Add a new feature •

    Fix a bug • Investigate a problem • Maintain legacy code • Integration with another system or component
  2. “My momma always said, life was like a box of

    chocolates. You never know what you’re gonna get”
  3. Is it an open source project? • Check the docs

    / wiki • Ask in the community ◦ mailing list ◦ forum ◦ irc ◦ open an issue / ticket with a question
  4. Back to basics • Technology / Programming language • Source

    control • Running tests • Build / Run / Deploy
  5. Look for more hints • Requirements.txt / setup.py • pom.xml

    / build.xml • Gemfile / gemspec • bower.json
  6. Minor changes • Fix typos • Add more info to

    a log statement • Persist a field that already exists in an object
  7. In search we trust • Search for strings in the

    code repository • Search existing logs for object names
  8. Medium size changes • Add a new field to an

    object / model ◦ process and persist ◦ use it in all code layers • Upgrade the version of a third party library ◦ regression is your nemesis ◦ minor version upgrade != major version upgrade
  9. Follow the trail • Follow existing fields ◦ understand the

    flow • Follow the tests ◦ learn how to add new tests ◦ check if tests pass after code changes
  10. Major changes • Refactor a module / component • Add

    a new functionality which requires a deep understanding of the system • Performance is key and must not be harmed
  11. Understand • The architecture of the system • Relevant flows

    and use cases • The main path • Fallback, retries, etc.
  12. Goal: Identify entry points • UI / REST / Backend

    • Class hierarchy • Identify and learn frameworks
  13. Get to know the code better • Is there a

    dependency injection mechanism? • How do the components communicate • Configuration keys to enable more info in the logs
  14. Get to know the system better • Identify persistency ◦

    data store type ◦ how the data is stored • Know your container ◦ web server ◦ application server
  15. Product configuration files • Static files location • Check how

    they are used and changed ◦ directly ◦ loaded into the database
  16. Multi process system • Identify the processes • How do

    they communicate with each other • High availability / symmetric
  17. Creating anchors “In climbing, a piton (/ˈpiːtɒn/; also called a

    pin or peg) is a metal spike (usually steel) that is driven into a crack or seam in the rock with a hammer, and which acts as an anchor to protect the climber against the consequences of a fall, or to assist progress in aid climbing” (wikipedia)
  18. Creating anchors • Read the code • If we can

    debug - put breakpoints • Read existing logs • Understand through unitests
  19. Creating anchors continued • Change the log level • Add

    more logging statements • Check history in source control - commits and comments
  20. Getting more hints • Explore threads names • Thread dump

    - check thread source • Take a heap dump - explore classes • Check which objects a map contains
  21. Network analyzer / packet sniffer • Software that intercepts and

    logs traffic ◦ decodes data ◦ shows packet fields • For example - Wireshark • Define filters for efficiency
  22. Goal • Send a SOA envelope to a service •

    Sender - Ruby code • Target - Java SOA service
  23. Reports Engine 1 Reports Engine 2 Reports Engine 3 UI

    Reports Engine 4 http /engine1 http /engine2 http /engine3 http /engine4 SOA Tomcat SOA SOA SOA SOA
  24. Steps • Basic understanding what SOA is • Intercept traffic

    of the existing Java code • Learn how a SOA envelope should look like • Write Ruby code to create a SOA envelope
  25. Frontend • Which libraries are used • Search for strings

    / translation files • Search for icon files location and usage • Learn how UI calls backend
  26. Following the code • Which css and js are downloaded

    • Add watches in the script tab • Set a breakpoint ◦ Use ‘debugger;’ keyword in code ◦ Set a breakpoint • Inspect elements
  27. Inspect the logo 160px * 159px File type and location

    Press here to switch to element selection mode Inspecting elements
  28. Useful options • Network tab • Copy as curl •

    Copy response • Copy link address
  29. Graphics credits • Signpost by Lubos Volkov • Clock by

    Kid Mountain • Idea by Matt Wasser • Gauge by Joel Avery from the Noun Project • Tomcat-logo by The Apache Tomcat Project Team • Loop by useiconic.com from the Noun Project • Magnifying Glass by Musket from the Noun Project • Puzzle Piece by icon 54 from the Noun Project • Writing by Creative Stall from the Noun Project • Sherlock by James Keuning, the Noun Project • Twitter by Lubos Volkov, the Noun Project • Mug by Alex Getty from the Noun Project • Diamond by MarkieAnn Packer from the Noun Project • Light Bulb by artworkbean, the Noun Project • Questions by Rediffusion from the Noun Project • cancel by Jevgeni Striganov from the Noun Project • Movies posters - http://www.impawards.com/