https://tryhackme.com/room/introtopwntools
So I’m connected with ssh on the box:

Checksec
- Does Intro2pwn1 have FULL RELRO
Full RELRO makes the entire GOT read-only which removes the ability to perform a “GOT overwrite” attack, where the GOT address of a function is overwritten with the location of another function or a ROP gadget an attacker wants to run.
So it’s more secure and eliminate the risk of buffer overflows.
https://ctf101.org/binary-exploitation/relocation-read-only/
1 | checksec intro2pwn1 |

YES
- Does Intro2pwn1 have RWX segments
RWX: Tells us, if the binary has segments
We don’t see it in the output of checksec.
NO
Does Intro2pwn2 have a stack canary

Stack canaries are tokens placed after a stack to detect a stack overflow.
This allows the program to detect a buffer overflow and shut down.
NO
- Does Intro2pwn2 not have PIE
PIE stands for Position Independent Executable.
This loads the program dependencies into random locations
Exemple without PIE:
He create a shared library
1 | $ cc -fpic -shared -I. -nostdlib |
Then recompile it
1 | $ cc -nostdlib -nodefaultlibs -I. |

Cause a buffer overflow on intro2pwn1 by inputting a long string such as AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA. What was detected?

A stack buffer overflow can be caused deliberately as part of an attack known as stack smashing. it’s mean you can use it to gain acess on a machine
Now cause a buffer overflow on intro2pwn2. What error do you get?

so, if there is no stack smashing, can i use it to gain acess on the mavhine ?
cyclic
In this chapter we learn to do a bufferoverflow when the canary protection is missing.
you can see that with checksec.

We alsolern how to convert from hex to ascii, and acsii to hex.
With gdb you can locate the function print_flag() like this.
1 | info function |

Or like this:
1 | print& print_flag |

Then in a python script we have to change the value of eip:
1 | from pwn import * |
The output of payload should be printed in a file to be used later:
1 | python pwn_cyclic.py > attack |
in this file it’s looking like this:aaaabaaacaaadaaaeaaafaaagaaahaaaiaaa6

Networking
1 | Dear buzz, |

So we have a copy of the service on the port 1336 of the service on the port 1337.
In this exemple we don’t have to change the payload or add nops, it’s just to show how to use the network.
1 | from pwn import * |
Shellcraft
For this challenge we nee d to disable ASLR (address space layout randomization).
This randomise where in memory the executable is loaded, so if we found the location of a function, the next time we run it the function will be somewhere else.
1 | echo 0 | sudo tee /proc/sys/kernel/randomize_va_space |
ok, we don’t have the right to do it.
use the script instead.
1 | sudo ./disable_aslr.sh |

Let’s find the EIP, I’m creating a string with cyclic 100, then I open the program with gdb an past the string.
The EIP is at taaa


So I have to print 77*”A” and rest for the EIP.
Now we gonna use a python script:
1 | from pwn import * |
I put the output in the file payload:

Now let’s create the shellcode wih shellcraft.
1 | shellcraft i386.linux.execve "/bin///sh" "['sh', '-p']" -f a |

1 | from pwn import * |
My EIP was wrong, didn’t say the value 0xffffd510 in gdb.