Hello, my name is Stephen.
And in this lecture we will move our program to the next phase here.
So let's revisit the insights you gained in our previous lecture.
And remember in the initial instruction mov rax one.
Uh, the presence of zeros stemmed from our attempt to move a single byte, which is eight bits into
a 64 bit register.
So this caused the remaining bits to be populated with zeros.
And to address this, we adopted move L1 approach, so which focused exclusively on the eight bit segment
of the Rax register.
So our verification process involves the command Objdump, DM, Intel Helloworld here.
So let's actually we actually did this compile here, so source and it should be somewhere Shellcode.
And here we.
What we're going to do is we will use the objdump.
The Intel.
Hello, world.
Oops.
Hello, World.
Yes.
And as you can see here, what we have is B0 zero one.
Now our verification.
We have verified that with Objdump here and solidifying the elimination of problematic characters from
the opening instruction.
And now let's delve deeper and explore an alternative strategy for the second instruction, one that
involves arithmetic operations like addition or subtraction.
So to initiate this technique, we take the essential step of clearing the register using XOR instruction.
So note this XOR here.
We need to do that again.
So this translates to Xor R.D. effectively setting the R.D. register to contain only zeros.
Subsequently, we embark on the process of incrementing its value.
So this involves employing the Add instruction to the argument, the contents of R.D. register by one.
So here what we're going to do is, as you can see, we have the move.
One, we will not change this also.
We will not change this this here.
And but after this move instruction, what we're going to do is we will use the xor xor.
R d i or r d x here and r d x.
Now, with this, you will see what will change here.
And also we will, instead of using length variable here, we will just delete that.
Let's actually count the length of our hello world.
One, two, three, four, five, six, seven, eight.
Nine, ten, 11.
So we will write it.
12 year.
Yeah.
12 yea.
And one for the end string here.
Null terminated string.
So it so 11 plus 112 here and that's why we wrote it.
And after that we will use syscall.
And here we will also change this on the termination side of our program.
So X or.
We will use racks.
Racks again.
Rags.
Rags and add.
Racks here.
60.
And X or.
Are the.
Or die.
And after that, syscall we are calling the syscall here.
Now, what we're going to do is we will let's actually assemble and link this file.
Remember the Hello Asem.
Let's actually remove all the old files here.
So ram a lot of ram.
Hello?
No, actually, not need to remove that.
So what we're going to do is we will use the Nasm FL 64.
Hello, world Dot.
Hello, World dot.
No, it's actually.
Hello dot ASM.
And hello that output.
Output file is going to be hello world.org here and let's actually create a linking file so ld hello
world dot o here and let's actually create the executable.
Right.
Hello world.
And that's it.
So as you can see, we this is just a warning.
There is no error here.
So if we just run this here, we will.
Get our message.
And as you can see, it runs successfully.
Oops.
Actually, yeah, we saved this.
Right?
So let's actually, I'm not sure about that, but let's actually compile it and.
Now we need to first use NSM and then LD.
That's it.
And now what are we going to do is we will objdump and to see the.
Compiled and executable program.
Here we will use Intel instruction.
Hello world.
And that's it.
So as you can see here, we managed to remove all the bad characters from our shellcode, which leaves
us with how to deal with addresses when copying.
Strings.
In our first lecture, we actually managed to remove this.
No characters here.
2AL, And then we fix that in a second lecture also here and in this lecture here.
So we have fixed code.
We manage to remove all the bad characters.
And as you can see, we use sorry.
And as you can see here, we don't need anything like a X or something here.
Instead we just have the X here.
But this is necessary.
And as you can see here, we are using the required instructions and registers for each of our instructions
here.