Part 46 – Hacking Pre-Decrement Operator

For a complete table of contents of all the lessons please click below as it will give you a brief of each lesson in addition to the topics it will cover. https://github.com/mytechnotalent/Reverse-Engineering-Tutorial

Let’s re-examine our code.

  1. #include <iostream>
  2. int main(void) {
  3. int myNumber = 16;
  4. int myNewNumber = --myNumber;
  5. std::cout << myNewNumber << std::endl;
  6. std::cout << myNumber << std::endl;
  7. return 0;
  8. }

We remember when we compile we get 15.

Let’s debug.

Part 46 – Hacking Pre-Decrement Operator - 图1

Let’s break.

Part 46 – Hacking Pre-Decrement Operator - 图2

Let’s review what is inside r3 and hack it.

Part 46 – Hacking Pre-Decrement Operator - 图3

Now as we continue we see it did not successfully hack why is that?

Part 46 – Hacking Pre-Decrement Operator - 图4

We re-run the binary and break and see the value here at r1 hold 15.

Part 46 – Hacking Pre-Decrement Operator - 图5

When we continue we see 15 which we don’t want.

Part 46 – Hacking Pre-Decrement Operator - 图6

Now we break again and print the value.

Part 46 – Hacking Pre-Decrement Operator - 图7

This time we set r1 and we can see we have successfully hacked!

Part 46 – Hacking Pre-Decrement Operator - 图8

This is your first experience with really breaking down the registers and seeing where things are stored and how it can affect outcome. Take time and run this yourself so you really have a firm handle on this.

Next week we will dive into the Post-Decrement Operator.