Workshop 2 doc 2 bw

Workshop 2 doc 2 bw - PRAMOD KUMAR KANTABHATHINA CSC 8410...

Info iconThis preview shows pages 1–5. Sign up to view the full content.

View Full Document Right Arrow Icon
PRAMOD KUMAR KANTABHATHINA CSC – 8410 WORK SHOP -2 Defusing a Databomb
Background image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
→ To defuse this databomb we need to enter 5 passwords one by one. For each password entered, this databomb analyzes the code on the password, by using if loop it manages to show whether the given password is correct or not, like follows if(condion) click(); else Kaboom(); if the given password satisfies the condition then click() function will be called that is the indication of accepting password, if the entered password is wrong the function Kaboom() will be executed, once that function executed then the bomb will explode, so we need to start defusing from starting. Code Analysis → The code contains different functions for different tasks, they are, a) Thinking(): This function is called to delay the password analyzing. It prints out “ analyzing. .” and waits for few seconds by calling the function sleep(), and again “analyzing. ..” is printed out as the loop gets repeated. The code in this function is, void thinking() { int i; int reps; int secs; sleepfor = sleepfor * 2; reps = (sleepfor / 10 < 1 ? 1 : sleepfor / 10); secs = sleepfor / reps; for (i=0; i<reps; i++) { printf("analyzing. ..\n"); sleep(secs); } }
Background image of page 2
b)click() : This function is called when the entered password is the correct one. It calls the function Thinking() and prints out “password accepted”. The code is void click() { thinking(); printf("password accepted\n"); } c) Fizzle() : This function will be called at the end to indicate that the bomb is diffused. It calls Thinking() function and makes the program to run fast by reducing the response and sleep time. At the end it prints “fsssssss. ...”. The code is void fizzle() { sleepfor = sleepfor == 0 ? 0 : 2; thinking(); printf("fsssssss. ..\n"); } d) Kaboom() : This function will be called if any entered password is wrong. It prints “Kaboooo. ..oom!”. The code is void kaboom() { int i; thinking(); printf("\nKaboo"); for (i=0; i<1024; i++) { printf("o"); } printf("m!\n"); exit(-1); } e) prompt() : This function is called at the starting of entering each password. It prints '>'. The code is, void prompt() { printf("> "); } The functions mentioned above will be called from main()
Background image of page 3

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
function, remaining code like conditions for the passwords, calling the correct functions by analyzing the given password etc. .., calling some functions for printing purpose etc … → In the main() function 4 variables are declared of each 8 character size, they are buffer 1, buffer2,buffer3 and buffer4. The entered password will be stored in one of these buffers and the buffer is used for the evaluation of the that password. Code for the declarations is char buffer4[8]; char buffer3[8]; char buffer2[8]; char buffer1[8]; sleepfor = !getenv("accel") * sleepfor; → At the starting of the code four variables P1, P2, P3 and FSIZE are defined for determining the correct password, these variables are used to analyze whether the entered password is correct or wrong. Code is
Background image of page 4
Image of page 5
This is the end of the preview. Sign up to access the rest of the document.

This document was uploaded on 11/08/2010.

Page1 / 13

Workshop 2 doc 2 bw - PRAMOD KUMAR KANTABHATHINA CSC 8410...

This preview shows document pages 1 - 5. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online