![](https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhoc-2muVITurTfq92Msx4Ngdx-pb_tItcBCyHRjUTEj7Q8v7iuMLNbeB8aKlgGhOhqr1LxjOCL6gyNXBYtYg014INlp3ER2QsLj5dBze1bz1ve_xrXQ5CqQcviONkVvBrSHBQiXuxMXlg/s640/do+not+delete2.png)
Level19
After logging in with level19 account, check the hint as follows.
![](https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjX2-4njgz6u1u9tzO8Z_k7tgpw7Tt52MAEPHA0_YlKJWVotjY8w-YhCofSeRzgzg9C5-kpvYM1TT8F-wmItx-kv9h3ACNJHywGCv-oFXwf8bHBVUZL6ntJAeayHVY3saB15tflg38XTOU/s640/Screen+Shot+2017-01-26+at+9.27.12+AM.png)
A BOF vulnerability exists because it is a gets function that does not check the length of the input string. I used gdb to analyze the code.
![](https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiZEnXU_A4iKxTw7wA3dYPDFDhB86OG2h35rDzN0Zkfj6lIE9aYw5qMYGZcoJdBFrJzGIUfTlo99UUS8MwPJ9fsVcIInOHnryEmNYLiXd_gc6gOf_ieo2Sz2kHe2yEiYBcmZQW7o9c5uP0/s640/Screen+Shot+2017-01-26+at+9.27.23+AM.png)
The size allocated for memory space is 40 bytes.
If you try to use BOF attack with this information, the shell will run with level19 permissions instead of level20 permissions.
I execute setreuid(3100,3100) and system(“/bin/sh”) to execute a level20 shell.
To this, I use Chaining RTL. The following diagram illustrates the stack.
![](https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEj4yjL0x5QYXdjQ8GQFlqpCo9U5NlrZRtjeTF0zgQ-sg8PzdSmxHLdob1qL_3UIR0lM7tC3k5dzrHwqpi_PdbCIYKZqtQVVZhyphenhyphenu6qiBzFYSw0qg538s6Z5Z4p1e5kShcZVuC6ljr46GOsk/s640/Screen+Shot+2017-01-26+at+9.27.34+AM.png)
First, I find the address of system() and setreuid().
![](https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgrLro55EGTCvCMCMTUg8fm2TCmKFAkpVFJVn405dVJDoyuX7MLNLl_26cbznqpw_KGv2BCN0NDgpFeGfL67zO_hFtqtMqkILuft0woEoIMAGaboQ-WPyC8fOpzBtCGzRKW10mFgSo44m8/s640/Screen+Shot+2017-01-26+at+9.27.49+AM.png)
I use objdump to find pop - pop - ret as follows.
![](https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjN-jD-cNLjLre9LieCkFwrPabYl17NAcOVh8gWKxC7w2V7miVjOmv1S3XV_UpG8GFglwTJFGblumxpcxCwCVOf6xzBd4L1TO-EC3OFBW4lGFLOBdJtDmNfQs2n6y6AaaG1eGvuzwwyfBw/s640/Screen+Shot+2017-01-26+at+9.28.00+AM.png)
Finally I use the code that using in level11 to find the address of /bin/sh.
![](https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjeMlFLCdkzCAn4QcNm9AFOPodI1_4BGPjEyDoBsz0spicX5basbPrF5JQHRYvWH4fLyyXMtfH6iE3e5WF05d9U5VdXFS-Ut2pqYw5boXmCVmiDMvf4_EPeOZVAdfCOhaFoS5ZbQ8_eVGQ/s640/Screen+Shot+2017-01-26+at+9.28.16+AM.png)
After compiling the above code and executing the program, I find the address of /bin/sh.
![](https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjXzCi9MyjERPQAQUuKd-3WsLZ1eQyXSxzPcn3HBZk_xuijtuFtxcT1WZ-f4m4z0MC0J3I701YXma0TgPZZ_F62EILItlU-1ktCKWIgI_C8lc8NvlXZpqLP1KT-LN7REs1QiQZy8Qea4S4/s640/Screen+Shot+2017-01-26+at+9.28.28+AM.png)
Now, I have all the values i need, I type the payload.
![](https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgmVIcapp3laP4GuuRMkehymYLT_j7ppHXO6qRxDOm0cvNQPe3Jj3ozEYGvYpVKAuhsnSYjyKPsMZouUzPA00OBAQYC1-T771LiXBiSBCr-seVYdicgKcZ7IeTXu7k8ZDQsucXNNG-X91s/s640/Screen+Shot+2017-01-26+at+9.28.41+AM.png)
As a result, I execute level20 shell.
No comments:
Post a Comment