[Soot-list] Generating code for enumaration

Daniele Altomare daniele.altomare at sysmosoft.com
Tue Feb 3 03:46:06 EST 2015


Hi Steven,

the Proxy class is the standard java.net.Proxy class, which defines a public enum Type.

I have the Jimple source for an example where I set the Proxy: this is the trace I'm using to try to inject it in a class where a Proxy is not set.
Probably I'm not assigning $r6 in the correct way.


Thanks again for your help,
Daniele

-------
...
        java.lang.String[] $r1;
        byte[] $r2;
        java.io.IOException $r3;
        java.io.FileOutputStream $r4;
        java.net.Proxy $r5;
        java.net.Proxy$Type $r6;
        java.net.InetSocketAddress $r7;
        java.net.URLConnection $r8;
        java.net.URL $r9;
        java.lang.String $r10;
        java.net.HttpURLConnection $r11;
        java.io.File $r12, $r14;
        com.sysmosoft.soottarget.MainActivity $r13;
        java.io.InputStream $r15;
        int $i0;
        boolean $z0;

        $r0 := @this: com.sysmosoft.soottarget.MainActivity$DownloadFileFromURLAsyncTask;

        $r1 := @parameter0: java.lang.String[];

        $r5 = new java.net.Proxy;

        $r6 = <java.net.Proxy$Type: java.net.Proxy$Type HTTP>;

        $r7 = new java.net.InetSocketAddress;

     label01:
        specialinvoke $r7.<java.net.InetSocketAddress: void <init>(java.lang.String,int)>("http://proxyclipse.info/", 8080);

        specialinvoke $r5.<java.net.Proxy: void <init>(java.net.Proxy$Type,java.net.SocketAddress)>($r6, $r7);

     label02:
        $r9 = new java.net.URL;

     label03:
        $r10 = $r1[0];

        specialinvoke $r9.<java.net.URL: void <init>(java.lang.String)>($r10);

        $r8 = virtualinvoke $r9.<java.net.URL: java.net.URLConnection openConnection(java.net.Proxy)>($r5);

     label04:
        $r11 = (java.net.HttpURLConnection) $r8;
...
-------




________________________________
From: Steven Arzt [Steven.Arzt at cased.de]
Sent: Tuesday, February 03, 2015 9:25 AM
To: Daniele Altomare; 'Bodden, Eric'
Cc: 'soot-list at CS.McGill.CA'
Subject: AW: [Soot-list] Generating code for enumaration

Hi Daniele,

Isn’t there a variable holding the HTTP constant for the enum type? Can you send us the Proxy class as complete Jimple source? My guess is that there is some field from which you can get the correct values for the enum instances and assign them to your local.

Best regards,
  Steven

Von: soot-list-bounces at CS.McGill.CA [mailto:soot-list-bounces at CS.McGill.CA] Im Auftrag von Daniele Altomare
Gesendet: Dienstag, 3. Februar 2015 09:21
An: Bodden, Eric
Cc: soot-list at CS.McGill.CA; Steven Arzt
Betreff: Re: [Soot-list] Generating code for enumaration

Thanks Eric,

in fact I added -validate to the command and I've got a "no defs for value: proxyType!" error

To get rid of it, I tried to assign to proxyType a value but I think something is wrong, because I don't think it's the correct value to set a enum value to a Local.

My code:

SootClass clsProxyType = Scene.v().getSootClass("java.net.Proxy$Type");

Local proxyType = Jimple.v().newLocal("proxyType", RefType.v(clsProxyType));

b.getLocals().add(proxyType);

probe.add(Jimple.v().newAssignStmt(proxyType, Jimple.v().

newNewExpr(clsProxyType.getType())));





What a correct assignment is represented in Jimple:

$r6 = <java.net.Proxy$Type: java.net.Proxy$Type HTTP>;



Basically I just need to pass enum value Proxy.Type.HTTP as a parameter of the Proxy constructor method.


Thanks,
Daniele


________________________________________
From: Bodden, Eric [eric.bodden at sit.fraunhofer.de]
Sent: Monday, February 02, 2015 11:09 PM
To: Daniele Altomare
Cc: Steven Arzt; soot-list at CS.McGill.CA<mailto:soot-list at CS.McGill.CA>
Subject: Re: [Soot-list] Generating code for enumaration

Hi Daniele.

It looks to me like the Jimple code you generate is ill-structured. Try to enable the -validate command line switch in Soot. That might help you pinpoint the problem.

Cheers,
Eric

> On 02.02.2015, at 15:37, Daniele Altomare <daniele.altomare at sysmosoft.com<mailto:daniele.altomare at sysmosoft.com>> wrote:
>
> Hi Steven,
>
> thanks for getting back to me. If I run the transformed executable (APK) I get a java.lang.VerifyError exception and this is the root cause:
>
> 02-02 15:49:39.170: W/dalvikvm(19074): VFY: register1 v7 holds uninitialized ref
> 02-02 15:49:39.170: W/dalvikvm(19074): VFY: bad arg 1 (into Ljava/net/Proxy$Type;)
> 02-02 15:49:39.170: W/dalvikvm(19074): VFY: rejecting call to Ljava/net/Proxy;.<init> (Ljava/net/Proxy$Type;Ljava/net/SocketAddress;)V
> 02-02 15:49:39.170: W/dalvikvm(19074): VFY: rejecting opcode 0x70 at 0x0015
> 02-02 15:49:39.170: W/dalvikvm(19074): VFY: rejected
>
> Please notice that I'm trying to init a Proxy instance:
> specialinvoke $r5.<java.net.Proxy: void <init>(java.net.Proxy$Type,java.net.SocketAddress)>($r6, $r7);
>
>
> If I run the driver class on this transformed APK (so I can print the body to check my transformation), I get this error:
> local type not allowed in final code: bottom_type local: $r6
>
>
> In fact, if I check the body I see "bottom_type $r6;" instead of "java.net.Proxy$Type $r6;" as expected.
>
>
> Thanks again,
> Daniele
>
> From: Steven Arzt [Steven.Arzt at cased.de]
> Sent: Monday, February 02, 2015 5:16 PM
> To: Daniele Altomare; soot-list at CS.McGill.CA<mailto:soot-list at CS.McGill.CA>
> Subject: AW: [Soot-list] Generating code for enumaration
>
> Hi Daniele,
>
> To answer this question, we would need more information. What do you mean by “does not work”? The code you wrote should give you a new local of the correct type – but it’s hard to tell what else may be wrong if one does not know how you use this local and where the problem shows up.
>
> Best regards,
> Steven
>
>
> M.Sc. M.Sc. Steven Arzt
> Secure Software Engineering Group (SSE)
> European Center for Security and Privacy by Design (EC SPRIDE)
> Rheinstraße 75
> D-64293 Darmstadt
> Phone: +49 61 51 869-336
> Fax: +49 61 51 16-72118
> eMail: steven.arzt at ec-spride.de<mailto:steven.arzt at ec-spride.de>
> Web: http://sse.ec-spride.de
>
>
>
> Von: soot-list-bounces at CS.McGill.CA<mailto:soot-list-bounces at CS.McGill.CA> [mailto:soot-list-bounces at CS.McGill.CA] Im Auftrag von Daniele Altomare
> Gesendet: Montag, 2. Februar 2015 17:14
> An: soot-list at CS.McGill.CA<mailto:soot-list at CS.McGill.CA>
> Betreff: [Soot-list] Generating code for enumaration
>
> Hi all,
>
> I'm getting stuck at generating code for an enum in a BodyTransformer.
>
> I have to pass the the proxy type to a method and that's defined by an enum.
> If I run the driver class for a java program where I define the proxy (so I can see the Jimple code) I get this for the method body:
>
> $r6 = <java.net.Proxy$Type: java.net.Proxy$Type HTTP>;
>
>
>
> I've tried in this way but it doesn't work:
>
> SootClass clsProxyType = Scene.v().getSootClass("java.net.Proxy$Type");
>
> Local proxyType = Jimple.v().newLocal("proxyType", RefType.v(clsProxyType));
>
> b.getLocals().add(proxyType);
>
>
>
> Can someone help me with this?
>
>
>
> Thanks!
>
> Daniele
>
>
> _______________________________________________
> 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

--
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
-------------- next part --------------
An HTML attachment was scrubbed...
URL: https://mailman.CS.McGill.CA/pipermail/soot-list/attachments/20150203/bc1dc4ce/attachment.html 


More information about the Soot-list mailing list