GithubHelp home page GithubHelp logo

wsym's Introduction

wsym

Adds symbols to an ELF file. Sort of the opposite of strip. This is in a very early stage of development and should be considered PoC/beta software.

why

I made this because I wanted gdb to know about the symbols I defined in IDA when reverse engineering. I really think there should be an easier way to do this but I couldn't find anything that gdb understands except ELF, so yeah... overkill. Please let me know if there is an easier way to tell gdb about user defined symbols.

However this tool might be useful anyway since it is a more generic solution.

how to use

usage: wsym.py [-h] [-v] [-f SYMBOLS] [-i SYMBOLS] [-n SYMBOLS] input output

There are multiple ways to provide symbols that should be added to the binary.

-f, --flat

This is a very simple flat file format, one symbol per line:

hex_addr name [hex_size]

-i, --ida

Using this option you can provide a .map file generated by IDA.

File > Produce File > Create MAP File -> segmentation & local

-n, --nm

This is the output of nm, the flags outputted by nm to describe each symbol are ignored.

wsym will generate a new ELF file which can be directly run under gdb, or you can use the add-symbol-file command in order to load the symbols from the generated file while debugging the original one.

Warning: running wsym repeatedly on a binary generated by itself will keep increasing the file size and is probably a bad idea. Always rerun on the original file.

how this works

We recreate the section header table at the end of the file. Adding original sections if there are any and re-adjusting their sh_link and sh_info if needed.

We also add a GHOST section for each segment, this covers the whole segment in case no other sections are present.

We create a new symtab called .wsymtab containing the provided symbols. A new strtab for this symtab is added but we also make a new shstrtab for all section names. This allows us to touch the original file as little as possible.

future work

  • MORE TESTING: IIRC there is some weird stuff going on with symtabs and entries need to be in a particular order for it to work etc, etc... Maybe we should be nice and do this for the user.

  • Add a parser for another IDA output format in order to have sizes

  • Allow for symbol types (data would be nice)

  • Link a symbol to the smallest section containing said symbol (instead of taking the first one that matches the address)

wsym's People

Contributors

ret5et avatar wapiflapi avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  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.