[Soot-list] Modifying initial values fields of method.
Roman Petriev
vvpiroman at gmail.com
Tue Feb 17 16:06:55 EST 2015
Thanks! I will follow your advice.
But we still have a question to discuss - "ldc" instruction use strings
from constant pool. I want to modify values in pool with soot.
2015-02-17 21:47 GMT+03:00 Steven Arzt <Steven.Arzt at cased.de>:
> If the ldc instruction is there, Soot will transform it into the
> respective Jimple instruction.
>
>
>
> However, you code is overly complex. Try this:
>
>
>
> SootMethod sm = Scene.v().getMethod(“<Decomp: void <clinit>>”);
>
> For (Unit u : sm.getActiveBody.getUnits())
>
> System.out.println(u);
>
>
>
> This assumes that your class Decomp does not reside in a package,
> otherwise you need to add that to the method signature passed to
> getMethod().
>
>
>
> Put this code into the internalTransform method of a SceneTransformer. You
> don’t need a callgraph for this, that just makes the whole thing much more
> complex than necessary.
>
>
>
> *Von:* soot-list-bounces at CS.McGill.CA [mailto:
> soot-list-bounces at CS.McGill.CA] *Im Auftrag von *Roman Petriev
> *Gesendet:* Dienstag, 17. Februar 2015 19:07
> *An:* Sam Blackshear
> *Cc:* soot-list at cs.mcgill.ca
> *Betreff:* Re: [Soot-list] Modifying initial values fields of method.
>
>
>
> Thanks, Sam. I saw "ldc" instruction in byte code. (Description: push a
> constant *#index* from a constant pool (String, int or float) onto the
> stack)
>
> So ... I need to modify constant pool, isn't it? Could I do it with soot?
> How?
>
>
>
> 2015-02-17 20:16 GMT+03:00 Sam Blackshear <samuel.blackshear at colorado.edu
> >:
>
> Hi Roman,
>
> I think the reason that your transformation isn't working is that javac
> is optimizing away your fields. Inlining of static final field reads for
> fields with primitive or String types is one of the only compile-time
> optimizations the Java compiler knows how to do. You may be able to get
> around this in some other way, but I don't think you'll see those field
> reads in the bytecode.
>
>
>
> - Sam
>
>
>
> On Tue, Feb 17, 2015 at 10:10 AM, Roman Petriev <vvpiroman at gmail.com>
> wrote:
>
> Test class:
>
>
>
> public class Decomp {
>
>
>
> private static final String FUUU = "fdgsfdhsrthd";
>
> private static final String AAAA = "olololo";
>
>
>
> public static void main(String[] args) {
>
>
>
> System.out.println(FUUU);
>
> System.out.println(AAAA);
>
>
>
> }
>
>
>
> }
>
>
>
> Test transformation:
>
>
>
> @Override
>
> protected void internalTransform(Body body, String phaseName,
> Map<String, String> options) {
>
>
>
> System.out.println(body.getMethod().getSignature());
>
>
>
> int weight = soot.jbco.Main.getWeight(phaseName,
> body.getMethod().getSignature());
>
> if (weight == 0){
>
> return;
>
> }
>
>
>
> System.out.println(" --- --- --- --- --- --- ");
>
>
>
> QueueReader<Edge> edgeList = Scene.v().getCallGraph().listener();
>
> while (edgeList.hasNext()) {
>
> Edge edge = edgeList.next();
>
> if(edge.isClinit() &&
> edge.src().getDeclaringClass().getName().equalsIgnoreCase(body.getMethod().getDeclaringClass().getName())){
>
> System.out.println(edge.src().getName());
>
> System.out.println(edge.tgt().getName());
>
>
>
> Iterator<Unit> itu =
> edge.tgt().getActiveBody().getUnits().snapshotIterator();
>
> while(itu.hasNext()){
>
> Unit u = itu.next();
>
> System.out.println(" --- unit : " + u.toString());
>
> }
>
>
>
> System.out.println("PL size : " +
> edge.tgt().getActiveBody().getParameterLocals().size());
>
> System.out.println("DB size : " +
> edge.tgt().getActiveBody().getDefBoxes().size());
>
> }
>
>
>
> }
>
> System.out.println(" --- --- --- --- --- --- ");
>
> }
>
>
>
>
>
> Hope this helps.
>
>
>
>
>
> 2015-02-17 9:25 GMT+03:00 Bodden, Eric <eric.bodden at sit.fraunhofer.de>:
>
> Roman can you post here the entire and unmodified source code of the
> respective class?
>
> Cheers,
> Eric
>
>
> > On 16.02.2015, at 23:52, Roman Petriev <vvpiroman at gmail.com> wrote:
> >
> > I tried to use call graph from scene and I found clinit!
> > But ... It contains in my test app:
> >
> > staticinvoke <java.lang.Object: void registerNatives()>()
> > return
> >
> > or
> >
> > staticinvoke <java.lang.System: void registerNatives()>()
> > <java.lang.System: java.io.InputStream in> = null
> > <java.lang.System: java.io.PrintStream out> = null
> > <java.lang.System: java.io.PrintStream err> = null
> > <java.lang.System: java.lang.SecurityManager security> = null
> > <java.lang.System: java.io.Console cons> = null
> > return
> >
> > But I want to get/set String constant ...
> >
> >
> > P.s. Thanks for any help!
> >
> >
> > 2015-02-17 0:29 GMT+03:00 Marc Miltenberger <Marc.Miltenberger at cased.de
> >:
> > The method is called <clinit> and has the subsignature
> > void <clinit>()
> >
> > Am 16.02.2015 um 21:56 schrieb Roman Petriev:
> > > Well ... How can I get access to clinit with soot? BodyTransformer
> > > couldn't find this method.
> > >
> > > 2015-02-16 21:58 GMT+03:00 Marc-André Laverdière
> > > <marc-andre.laverdiere-papineau at polymtl.ca
> > > <mailto:marc-andre.laverdiere-papineau at polymtl.ca>>:
> > >
> > > If the field is static, then it will be in clinit...
> > >
> > > Marc-André Laverdière-Papineau
> > > Doctorant - PhD Candidate
> > >
> > > On 16/02/15 01:25 PM, Roman Petriev wrote:
> > > > Unfortunately, it didn't help :( ....
> > > >
> > > > Simplest <init> contains 3 items, e.g.:
> > > >
> > > > r0 := @this: decomp.Decomp
> > > > specialinvoke r0.<java.lang.Object: void <init>()>()
> > > > return
> > > >
> > > > Decomp class contains 2 constants.
> > > >
> > > > Do you have any ideas else?
> > > >
> > > > P.s. javap:
> > > >
> > > > private static final java.lang.String FUUU;
> > > > Signature: Ljava/lang/String;
> > > > flags: ACC_PRIVATE, ACC_STATIC, ACC_FINAL
> > > >
> > > > ConstantValue: String fdgsfdhsrthd
> > > >
> > > >
> > > > private static final java.lang.String AAAA;
> > > > Signature: Ljava/lang/String;
> > > > flags: ACC_PRIVATE, ACC_STATIC, ACC_FINAL
> > > >
> > > > ConstantValue: String olololo
> > > >
> > > > Probably, constants were initialized somewhere else ...
> > > >
> > > >
> > > > 2015-02-16 14:22 GMT+03:00 Bodden, Eric <
> eric.bodden at sit.fraunhofer.de <mailto:eric.bodden at sit.fraunhofer.de>
> > > > <mailto:eric.bodden at sit.fraunhofer.de
> > > <mailto:eric.bodden at sit.fraunhofer.de>>>:
> > > >
> > > > Hi Roman.
> > > >
> > > > You will find the appropriate assignment within the body of
> the
> > > > method <init> within SomeClass. You need to modify the
> assignment there.
> > > >
> > > > Hope this helps,
> > > > Eric
> > > >
> > > > > On 16.02.2015, at 11:15, Roman Petriev <
> vvpiroman at gmail.com <mailto:vvpiroman at gmail.com>
> > > > <mailto:vvpiroman at gmail.com <mailto:vvpiroman at gmail.com>>>
> wrote:
> > > > >
> > > > > I do body transformation (Jimple) for JBCO, and I need to
> do this
> > > > for code obfuscation.
> > > > >
> > > > > 2015-02-16 13:10 GMT+03:00 Roman Petriev <
> vvpiroman at gmail.com <mailto:vvpiroman at gmail.com>
> > > > <mailto:vvpiroman at gmail.com <mailto:vvpiroman at gmail.com>>>:
> > > > > Ok.
> > > > >
> > > > > E.g.:
> > > > >
> > > > > public class SomeClass{
> > > > >
> > > > > //I want to get/set value of this constant.
> > > > > private final String SOME_PARAMETER = "value";
> > > > >
> > > > > public static void main(String[] args) {
> > > > >
> > > > > //................
> > > > >
> > > > > }
> > > > > }
> > > > >
> > > > > It's possible?
> > > > >
> > > > >
> > > > > 2015-02-16 9:26 GMT+03:00 Bodden, Eric
> > > > <eric.bodden at sit.fraunhofer.de
> > > <mailto:eric.bodden at sit.fraunhofer.de>
> > > <mailto:eric.bodden at sit.fraunhofer.de
> > > <mailto:eric.bodden at sit.fraunhofer.de>>>:
> > > > > Hi Roman.
> > > > >
> > > > > If you describe your problem in more detail then there is
> a
> > > > better chance that people will be able to help you out.
> > > > >
> > > > > Best wishes,
> > > > > Eric Bodden
> > > > >
> > > > > > On 15.02.2015, at 22:22, Roman Petriev <
> vvpiroman at gmail.com <mailto:vvpiroman at gmail.com>
> > > > <mailto:vvpiroman at gmail.com <mailto:vvpiroman at gmail.com>>>
> wrote:
> > > > > >
> > > > > > Hi all!
> > > > > >
> > > > > > I want to get/set initial value of method field
> > > > (java.lang.String). How I can do it?
> > > > > >
> > > > > > Best regards,
> > > > > > Roman.
> > > > > >
> > > > > > _______________________________________________
> > > > > > Soot-list mailing list
> > > > > > Soot-list at CS.McGill.CA <mailto:Soot-list at CS.McGill.CA>
> > > <mailto:Soot-list at CS.McGill.CA <mailto:Soot-list at CS.McGill.CA>>
> > > > > > https://mailman.CS.McGill.CA/mailman/listinfo/soot-list
> > > > >
> > > > > --
> > > > > Prof. Eric Bodden, Ph.D., http://sse.ec-spride.de/
> > > http://bodden.de/
> > > > > Head of Secure Software Engineering at Fraunhofer SIT, TU
> > > > Darmstadt and EC SPRIDE
> > > > > Tel: +49 6151 16-75422 Fax: +49 6151 869-127
> > > > > Room B5.11, Fraunhofer SIT, Rheinstraße 75, 64295
> Darmstadt
> > > > >
> > > > >
> > > > >
> > > >
> > > > --
> > > > Prof. Eric Bodden, Ph.D., http://sse.ec-spride.de/
> > > http://bodden.de/
> > > > Head of Secure Software Engineering at Fraunhofer SIT, TU
> > > Darmstadt
> > > > and EC SPRIDE
> > > > Tel: +49 6151 16-75422 Fax: +49 6151 869-127
> > > > Room B5.11, Fraunhofer SIT, Rheinstraße 75, 64295 Darmstadt
> > > >
> > > >
> > > >
> > > >
> > > > _______________________________________________
> > > > Soot-list mailing list
> > > > Soot-list at CS.McGill.CA <mailto:Soot-list at CS.McGill.CA>
> > > > https://mailman.CS.McGill.CA/mailman/listinfo/soot-list
> > > >
> > > _______________________________________________
> > > Soot-list mailing list
> > > Soot-list at CS.McGill.CA <mailto:Soot-list at CS.McGill.CA>
> > > https://mailman.CS.McGill.CA/mailman/listinfo/soot-list
> > >
> > >
> > >
> > >
> > > _______________________________________________
> > > Soot-list mailing list
> > > Soot-list at CS.McGill.CA
> > > https://mailman.CS.McGill.CA/mailman/listinfo/soot-list
> > >
> >
> > _______________________________________________
> > Soot-list mailing list
> > Soot-list at CS.McGill.CA
> > https://mailman.CS.McGill.CA/mailman/listinfo/soot-list
> >
> > _______________________________________________
> > Soot-list mailing list
> > Soot-list at CS.McGill.CA
> > https://mailman.CS.McGill.CA/mailman/listinfo/soot-list
>
> --
> Prof. Eric Bodden, Ph.D., http://sse.ec-spride.de/ http://bodden.de/
> Head of Secure Software Engineering at Fraunhofer SIT, TU Darmstadt and EC
> SPRIDE
> Tel: +49 6151 16-75422 Fax: +49 6151 869-127
> Room B5.11, Fraunhofer SIT, Rheinstraße 75, 64295 Darmstadt
>
>
>
>
> _______________________________________________
> Soot-list mailing list
> Soot-list at CS.McGill.CA
> https://mailman.CS.McGill.CA/mailman/listinfo/soot-list
>
>
>
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: https://mailman.CS.McGill.CA/pipermail/soot-list/attachments/20150218/333fd3a1/attachment-0001.html
More information about the Soot-list
mailing list