Hi, First of all thanks for the answers. I've read the mentioned article but it tells how to add an instruction inside a data segment right ? and I like to know how to add instructions inside a text segment. besides like pancake has said this article uses r1 and I thought I could do this with r2.
When I use -w flag to open a program in read-write mode and use 'wa' or 'wx' to write an instruction, it will change current instructions and this don't solve my problem because I don't want to change instructions, I just want to add instructions without change its funcionality I hope r2 could do all reallocations needed to allow to add instructions without segmentation faults. Rafael de Oliveira Costa, M.Sc. Student PPGI - UFRJ Rio de Janeiro, RJ, Brazil http://www.labnet.nce.ufrj.br "If the doors of perception were cleansed every thing would appear to man as it is, infinite", William Blake On Mon, Jan 9, 2012 at 12:43 PM, pancake <[email protected]> wrote: > You can resize a section like this: > > $ rabin2 -O r/.data/1024 a.out > > but bear in mind that if you resize .text, all the refs from the following > sections will > need to be reallocated, and this will require some more work reassembling > code. > > If you want to write code in your binary use the -w flag to open in > read-write. > > then use 'wa' to write assembly, or 'wx' to write hexpairs. > > You can use 'rasm2' from commandline to assemble instructions, but from > commandline > you'll have to provide the offset to avoid writing invalid patches. > > As Pete pointed, you may check the article I wrote for the phrack, but > bear in mind that > the paper is based on r1, not r2. I encourage you to use r2 in order to > find bugs and report > issues or missing things, so we can deprecate r1 :) > > --pancake > > > On 01/06/12 01:41, Pete Smith wrote: > >> Hi, >> >> From what I have read if you're adding a largish section of code it's >> better to make a small modification to the code segment which will load >> your new code out of the data segment into rwx memory. >> >> There's a great article on Phrack that pancake wrote that explains some >> of the things you can do to achieve this. >> >> Phrack 66: manual binary mangling with radare >> >> http://www.phrack.org/issues.**html?issue=66&id=14<http://www.phrack.org/issues.html?issue=66&id=14>< >> http://www.phrack.org/issues.**html?issue=66&id=14<http://www.phrack.org/issues.html?issue=66&id=14> >> > >> >> Cheers, >> Pete >> >> >> On 6 January 2012 03:35, Rafael de Oliveira Costa < >> rafaeldeoliveiracosta@gmail.**com <[email protected]><mailto: >> rafaeldeoliveiracosta@**gmail.com <[email protected]>>> >> wrote: >> >> Hi, >> >> I don't know if here is the right place to ask this but I would >> like to know if radare2 can help me to add instructions on text >> segment of a program. I know that this task can cause problems. >> >> I've looked resize command of radare2 and I can insert bytes but >> this bytes are inserted in data segment. >> >> Rafael de Oliveira Costa,M.Sc. Student >> >> PPGI - UFRJ >> Rio de Janeiro, RJ, Brazil >> http://www.labnet.nce.ufrj.br >> <http://www.labnet.nce.ufrj.**br/<http://www.labnet.nce.ufrj.br/> >> > >> >> "If the doors of perception were cleansed every thing would appear >> to man as it is, infinite", William Blake >> >> >> >> ______________________________**_________________ >> radare mailing list >> [email protected] >> <mailto:[email protected].**org<[email protected]> >> > >> >> http://lists.nopcode.org/**listinfo.cgi/radare-nopcode.**org<http://lists.nopcode.org/listinfo.cgi/radare-nopcode.org> >> >> >> >> >> >> ______________________________**_________________ >> radare mailing list >> [email protected] >> http://lists.nopcode.org/**listinfo.cgi/radare-nopcode.**org<http://lists.nopcode.org/listinfo.cgi/radare-nopcode.org> >> > > ______________________________**_________________ > radare mailing list > [email protected] > http://lists.nopcode.org/**listinfo.cgi/radare-nopcode.**org<http://lists.nopcode.org/listinfo.cgi/radare-nopcode.org> >
_______________________________________________ radare mailing list [email protected] http://lists.nopcode.org/listinfo.cgi/radare-nopcode.org
