Skip to main content

ARM buffer overflow: chapter 2 ( ° ͜ʖ °) (day 59)



Back again with the ARM buffer overflow tutorial. In this post, we will try to redirect the flow of program execution by hijacking the PC (EIP) register inside the program

for proof of concept we are going to use the following code from stack4 protostar:

#include <stdio.h>

void win()
{
  printf("code flow successfully changed\n");
}

int main(int argc, char **argv)
{
  char buffer[64];

  gets(buffer);
}

It is pretty clear that we need to redirect the flow of the execution to win() function. Ok! first we need to compile the code with the following flag.






The next step is to find how many offsets of bytes that we need to overwrite the PC register. Since my raspberry pi doesn't have an internet connection to download the usual tool, it looks like we need to create our own pattern generator.




the following python script will generate all alphabets including lowercase and uppercase and also digits. Each loop will multiply each character into 4 so we will have enough character to try




Put it into your program and run gdb along with it

 

cool so we crash the program and we can translate the following hex code with python.



from this result, we can see that we need 68 bytes of offsets to overflow the PC register. Let's try to check if we got the right count





We got the offset right. Next is to find the location of win() function inside the program.



we got the location and update the python script into:

import struct

padding = "A" * 68
win_function = struct.pack(0x01044c)

print padding + win_function

 

ok so we try the exploit at gdb environment and it works flawlessly and in the end, you can try it outside the gdb


Well! that's the end of part 2 as you can see it's a pretty short post since the flow of the exploitation is actually the same when we do buffer overflow in intel x86

Hope you enjoy this post :)

Comments

Popular posts from this blog

Having fun analyzing nginx log to find malicious attacker in the net (ง'̀-'́)ง (day 37)

  What makes you sleepless at night? is it because of a ghost or scary stories? is it because you have an important meeting tomorrow? or is it because you have an exam? For me, what keeps me up all night is that I keep thinking about what happens to a website that I just created, is it safe from an attacker (certainly not) or did I missing some security adjustments that lead to vulnerability? well I'm not the best secure programmer in the world, I'm still learning and there is a big possibility that I can make a mistake but for me, a mistake can be a valuable investment to myself or yourself to be better so from this idea, I want to know more about what attackers casually do when attacking a website. Here in this post, I'm going to show you how I analyzed attack to the website that I have permission to design and also some interesting findings that I could get from the analysis Background: All of this analysis comes from the traffic that is targeted to th...

Utilize Pwntools for crafting ROP chain :') (day 69)

who doesn't like pwntools? it is a very versatile tool and can be customized according to our need using the python script but did you need to know that pwntools itself can help us to automatically craft a rop chain for us? so in this post, I will show you how to make rop chain less painful and make pwntools do all the heavy lifting. To demonstrate this I will use the binary challenge callme 64 bit from ropemporium link: https://ropemporium.com/challenge/callme.html Crashing the app: Like any other exploitation process, we need to crash the program by generating a long string pattern to determine the offset. based on the information from the above figure we can see that we required to provide 40 bytes of offset Fun stuff: now this where the fun stuff began write the following python script: as in the guideline of the challenged said we need to chain the function call by first to call the callme_one function, callme_two function and then callme_three funct...

Why you should always cautious on your VPN: Study Case on Broken Cryptography of Android VPN (day 91) ಠ_ಠ

source: https://me.me/i/when-you-make-a-meme-in-europe-but-you-use-22778509 Disclaimer: This blog post is heavily based on https://www.youtube.com/watch?v=ofTts7jlC2Y&t=177s created by Lukas Stefanko. I strongly suggest you guys check his youtube videos it contain many great android security study cases that you can learn free Background: Who doesn't know VPN, right?! It is a wonderful program that lets us maintain the confidentiality of our identity and information while surfing the internet. It is fast and more importantly is "FREE!" there are tons of free VPN applications that you can download in play store and use it in a click of a button. The workflow is also not really that difficult to understand: Source: https://blog.sucuri.net/2020/03/vpn-secure-online-work-environment.html Pay attention to the above figure, this diagram explains the difference in our connection when using a VPN and not using VPN. When using a VPN before we connect to ...