Skip to content

GCC Compiler – How to install the GCC Compiler on Windows 7 and create a Buffer Overflow – The Visual Guide

02/12/2013

The GCC Compiler runs on Windows 7, this is how to install it.

Step 1 – Download GCC Compiler

http://sourceforge.net/projects/mingwbuilds/files/mingw-builds-install/mingw-builds-install.exe/download

GCC download

gcc installer

Step 2 – Run Installer

Right click the install.exe and “Run as Administrator”

gcc installer

NEXTgcc 1

Select 32 or 64 bit Architecture (defaults is 32 bit)

NEXT

installer 2Next

Allow some time to download > Next

installer 3

installer finish

That’s it – GCC is now installed.

******

Step 3 – Download Notepad++

Download it here:

http://notepad-plus-plus.org/download/v6.5.1.html

Save your programs as *filename.c

(.c is for c programs).

notepad

Step 4 – Write a Buffer Overflow in Notepad++

Copy this program into Notepad++ to test out your GCC compiler.

bufferc

When you run the buffer.c program – it will crash.

****

Code – for buffer overflow

#include <stdio.h>

int main (int argc, char* argv[]) //start of main
{
char smallbuff[8]; //8 chars in buffer
strcpy(smallbuff, argv[1]);
printf(“%s\n”, smallbuff);
return 0;
}//end of main

******

Step 5 – Launch the GCC Compiler

Start > All Programs

MinGw > x64-4.8.1 > Run Terminal

I created c: test directory to store all notepad programs. Note c:\test\buffer.c

menuterminal

cd c:\test (to get to our test directory)

Now we compile and generate buffer.exe – which we run.

gcc buffer.c -o buffer.exe

buffer.exe

 

gcc buffer

Don’t forget buffer.exe to run your program.

Did the program crash?

crash

Advertisements
2 Comments
  1. Kuman Kothiya permalink

    Thnx for the blog, really helpful.

    Like

    • Hi Kuman,

      Thanks for commenting. It’s always nice to hear that the blog is appreciated. Take care.

      Like

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: