[Soot-list] Replace byte code in java class file

Marc-André Laverdière marc-andre.laverdiere-papineau at polymtl.ca
Mon Sep 16 09:03:20 EDT 2013


Hello,

The process you described is a bit more complex than it need be.
Soot transforms your .class into Jimple automatically, so you don't need
to do many output/input steps.

Soot can do the transformations you describe. It can do a whole more
than that, but it works.

The thing is, how different will the arbitrary statement compared to the
original? If you need to create new variables and the like, then that is
extra code that needs to be injected. Soot can do it, but keep in mind
that it is a bit more work than you think.

BTW, regarding the change that you suggest, I think Al is right. If you
just want to change a class name, then Soot is really overkill. My
knowledge of Java bytecode is limited, but this is what I understand:
using a bytecode-level tool, you could just change that in the constant
pool and be done with it.

So the answer is really how much more than that substitution you want to do.

Marc-André Laverdière-Papineau
Doctorant - PhD Candidate

On 09/15/2013 06:39 PM, Jun Liu wrote:
> Hi all
> 
> I appreciate if anyone can give some advices of the issue I encountered.
> 
> I'm new to soot, I've been searching for materials of soot online for
> the last few days and tried to read all online documentations. However,
> I haven't find an answer about whether soot can do exactly what I want.
> 
> 
> So my problem is that is it possible soot can read a java class file and
> update an arbitrary statement in the class file (for instance, replace
> java.sql.DriverManager with xx.xxx.DriverManager) and then output to a
> new .class file. So far  I can only do this by generating a jimple file
> first, read jimple file as string into java code and then replace, e.g.,
> DriverManager, with xxx.xxx.DriverManager, and then run soot again to
> generate a new class file for me.
> 
> 
> I'm wondering if anyone know is there a way to do this in Java?? 
> 
> 
> /
> 
> *Email Disclaimer*
> 
> /"This e-mail and any files transmitted with it are confidential and are
> intended solely for use by the addressee. Any unauthorised
> dissemination, distribution or copying of this message and any
> attachments is strictly prohibited. If you have received this e-mail in
> error, please notify the sender and delete the message. Any views or
> opinions presented in this e-mail may solely be the views of the author
> and cannot be relied upon as being those of Dublin City University.
> E-mail communications such as this cannot be guaranteed to be
> virus-free, timely, secure or error-free and Dublin City University does
> not accept liability for any such matters or their consequences. Please
> consider the environment before printing this e-mail."/
> 
> *Séanadh Ríomhphoist*
> 
> /"Tá an ríomhphost seo agus aon chomhad a sheoltar leis faoi rún agus is
> lena úsáid ag an seolaí agus sin amháin é. Tá cosc iomlán ar scaipeadh,
> dháileadh nó chóipeáil neamhúdaraithe ar an teachtaireacht seo agus ar
> aon cheangaltán atá ag dul leis. Má tá an ríomhphost seo faighte agat
> trí dhearmad cuir sin in iúl le do thoil don seoltóir agus scrios an
> teachtaireacht. D’fhéadfadh sé gurb iad tuairimí an údair agus sin
> amháin atá in aon tuairimí no dearcthaí atá curtha i láthair sa
> ríomhphost seo agus níor chóir glacadh leo mar thuairimí nó dhearcthaí
> Ollscoil Chathair Bhaile Átha Cliath. Ní ghlactar leis go bhfuil
> cumarsáid ríomhphoist den sórt seo saor ó víreas, in am, slán, nó saor ó
> earráid agus ní ghlacann Ollscoil Chathair Bhaile Átha Cliath le
> dliteanas in aon chás den sórt sin ná as aon iarmhairt a d’eascródh
> astu. Cuimhnigh ar an timpeallacht le do thoil sula gcuireann tú an
> ríomhphost seo i gcló."/
> 
> /
> 
> 
> 
> _______________________________________________
> Soot-list mailing list
> Soot-list at sable.mcgill.ca
> http://mailman.cs.mcgill.ca/mailman/listinfo/soot-list
> 


More information about the Soot-list mailing list