# Exercises - patching

## Task 1

You are given a snippet in assembly: 

+ [task1/patching1.asm](task1/patching1.asm)

Compile it using MASM. Check how it works.

1. To compile use:

```
ml patching1.asm
```

or:

```
ml \c patching1.asm
link patching1.obj
```

+ Q: Why you don't have to supply any libraries to the linker this time?

+ You task is to patch the assembly file in such a way that it will give you the flag. Any working patch is allowed, but try to make it as simple as possible.

## Task 2

You are given a compiled application:

+ [task2/expired_flag.exe](task2/expired_flag.exe)

1. Open the exe in IDA and analyze what is happening there, what conditions are checked, etc.

2. Using a debugger of your choice (x64dbg is recommended) change the checked flags, to bypass the checked conditions, and bypass the "Expired" MessageBox

3. Try to achieve the same goal like 2, but without touching the flags registers, but the actual values that are filled by the relevant function call. Keep trying various bypasses until you get the flag pop up.

4. Write a x64dbg script that will repeat the steps that you have done in a debugger in order to obtain the flag pop up.

5. Make patches in the compiled application to make it always display the flag.

6. Q: What are the other ideas for patching that could be applied in such case?

## Answers

For the answers go to [solutions](solutions)
