Question: To interact with any level you will send raw bytes over stdin to this program. To efficiently solve these problems, first run it to see
To interact with any level you will send raw bytes over stdin to this program.
To efficiently solve these problems, first run it to see the challenge instructions.
Then craft, assemble, and pipe your bytes to this program.
For instance, if you write your assembly code in the file asm.S you can assemble that to an object file:
as o asm.o asm.S
Note that if you want to use Intel syntax for xwhich of course, you do you'll need to add the following to the start of asm.S:
intelsyntax noprefix
Then, you can copy the text section your code to the file asm.bin:
objcopy O binary onlysectiontext asm.o asm.bin
And finally, send that to the challenge:
cat asmbin challengerun
You can even run this as one command:
as o asm.o asm.S && objcopy O binary onlysectiontext asmo asmbin && cat asmbin challengerun
In this level you will be working with control flow manipulation. This involves using instructions
to both indirectly and directly control the special register rip the instruction pointer.
You will use instructions such as: jmp call, cmp and their alternatives to implement the requested behavior.
We will be testing your code multiple times in this level with dynamic values! This means we will
be running your code in a variety of random ways to verify that the logic is robust enough to
survive normal use.
In previous levels you discovered the forloop to iterate for a number of times, both dynamically and
statically known, but what happens when you want to iterate until you meet a condition?
A second loop structure exists called the whileloop to fill this demand.
In the whileloop you iterate until a condition is met.
As an example, say we had a location in memory with adjacent numbers and we wanted
to get the average of all the numbers until we find one bigger or equal to xff:
average
i
while xixff:
average xi
i
average i
Using the above knowledge, please perform the following:
Count the consecutive nonzero bytes in a contiguous region of memory, where:
rdi memory address of the st byte
rax number of consecutive nonzero bytes
Additionally, if rdi then set rax we will check
An example testcase, let:
rdi x
xx
xx
xx
xx
then: rax should be set
We will now run multiple tests on your code, here is an example run:
datax random bytes
rdi x
Please give me your assembly in bytes up to x bytes:
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
