GithubHelp home page GithubHelp logo

debugger's Introduction

DEBUGGER

The project's objective is to make our debugger print A breakpoint has been hit before our word generator program prints a random string.

Rewriting registers and writing data to a specific address was done using Ptrace.

Building

Prerequisites:

  1. Ensure you have the Go tools installed.

Option A : Using Go build commands

  1. Clone DEBUGGER via Git

  2. Open a terminal in the cloned repository and run export GOBIN=[PATH OF CLONED REPOSITORY]

  3. Run go install WordGenerator.go

  4. Run go run main.go

TODO.

Implement Cirrus Test

Implement Go Linter Tests

The bash script for the test does work as expected when executed manually.

Information About The Program

Since we want to print A breakpoint has been hit before our Word Generator program prints a random string we need to pause the Word Generator before it prints.

Line 21 is where the printing occurs, thus we need to establish a breakpoint there. The instruction address on line 21 will be used to set the breakpoint.

The command : objdump --dwarf=decodedline ./WordGenerator will be used to get the address of line 21. (The command: go install WordGenerator.go must before executed beforehand.)

We use PtracePeekData to read the memory first since it will be used later. Then, we use PtracePokeData to replace the data at the address with 0xCC, causing the CPU to halt the application anytime it detects data int 3.

We need the program to continue running normally once the breakpoint is reached. The application doesn't function normally since we previously changed the data at the address. As a result, original data must be used to replace the int 3. Since we captured the original data using PtracePeekData, we just revert to the original data.

We have to execute the instruction at the address once more because it has already been executed. Once the instruction pointer is set to the address, the CPU will once more execute it. PtraceGetRegs and PtraceSetRegs are commands used for manipulating CPU registers.

Since we changed the register, the program will now run according to its usual flow if we continue. However, we want to hit the breakpoint once again, so we'll ask ptrace to carry out only the subsequent instruction before setting the breakpoint once more. PtraceSingleStep allows us to execute only one instruction.

Before our WordGenerator program prints a random string during execution, the message A breakpoint has been hit is printed. The software performs as intended. pro

debugger's People

Contributors

robertmin1 avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.