Passing command line arguments to Soot binary in Windows doesn't accept any classpath?

200 views
Skip to first unread message

James Hatton

unread,
Jun 7, 2013, 4:00:09 PM6/7/13
to dare-a...@googlegroups.com
Hi,

I have successfully set up Dare on Ubuntu Linux VM and seems to be working well for me. However I attempted to translate this across to run inside Windows Native console (command prompt). In the past I have had some success to with porting some apps to windows with helper scripts etc. I understand that there are limitations in this area being Windows but I thought I would like to at least try. I managed to exec dare via its main thread by passing some arguments via Windows batch script. This has worked for several java apps running under Win.....the beauty of java cross platform :)

Anyway the issue I have had mainly is that SOOT cannot resolve the class path? I have read the documentation and done everything by the book as far as set up is concerned...only that it is is Windows. I went as far as moving everything to the root of C:\ too so that there were no spaces in my path and that the Soot application got first allocation for the JAVA env variables. Instead of it trying to resolve the C:\Program Files or C:\Program Files (x86) with spaces in the path, which initially it didn't?.

I have the JDK bin folder on the standard windows path so I can also call Java from everywhere in the system? Soot for some reason cannot find Java? Java can find it no problems. I can write all the settngs/help output to the console/command line too. 

Running Soot independently in the Ubuntu VM also proved to process the same errors of not finding the classpath even though JAVA is set 100% correct? Soot seems to be able to ignore these errors and continue

Lastly I went as far as compiling my own version of Soot in Eclipse built native for Windows, I was hoping that the Windows Environment variables would not become an issue if it was built from sources in Windows?.....I get an endless see of faults when trying to compile? Soot ignores all arguments pass to it for the class path in both Windows and linux, so following the help to set it manually plain just doesn't work? In Linux, it seems to pickup where it left over, on Windows on the other hand causes a major error and quits the console.

Tips on compiling Soot or resolving class path to Windows env?

Thanks in advance!

Dalvik Retargeting (Dare)

unread,
Jun 11, 2013, 4:28:49 AM6/11/13
to dare-a...@googlegroups.com
Hi,

Can you post the error messages you are getting from Soot (both on Windows and in your Ubuntu VM)?

Thanks,
Damien


--
You received this message because you are subscribed to the Google Groups "dare" group.
To unsubscribe from this group and stop receiving emails from it, send an email to dare-android...@googlegroups.com.
To post to this group, send email to dare-a...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/dare-android/18b6b9e7-ac17-4970-a7c7-a1f23ca374fb%40googlegroups.com?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.
 
 

James Hatton

unread,
Jun 17, 2013, 7:52:14 PM6/17/13
to dare-a...@googlegroups.com

Hi,

I had issues with Soot in Ubuntu with errors like “Are you sure soot is on the classpath?” and or quite often than not Soot gets caught in an endless loop trying to perform some action over and over.

I have found that I can usually get some java code out by running the tests twice. One with this code:

./dare -c -p -b -d <directory> <app>.apk

 

If that does not produce .java (even though I give it the –d switch) I will run it again with this:

./dare -p -e -c -o –d <directory> <app>.apk

This almost always produces .java output.

In Windows it never initiates because it cannot establish a classpath? I can even run it inside the java directory next to the exe and Soot cannot locate the classpath? Is this similar to Python with its Pth file? Does Linux Java have its one internal environment settings? I believe theses are initiated at boottime via fstab or something like that? For what ever reason the Soot does not find the classpath. The other two do, both Jasmin and .dare (and dava) as a whole manage to find the class path, either that or they don’t bitch and whinge about not seeing it?

Inside of Windows I am always getting a binary error for dare-1.0.2-launcher? Even though I call dare with

java –jar  dare -c -p -b -d <directory> <app>.apk

I get the error “Error:  Invalid or corrupt jar file”.

Running inside of Cygwin I get this:
:dare line 51 dare-launcher-1.0.2: cannot execute binary file

I initially had line ending problems with the scripts being run inside Cygwin. So I run my own clean routine on the scripts and this allows them to execute.

This is my cmd batch script called clean. That sits right next to a linux bash script also called clean.sh

@echo off

setlocal

 

if not exist "%~dpn0.sh" echo Script "%~dpn0.sh" not found & exit 2

 

set _CYGBIN=C:\cygwin\bin

if not exist "%_CYGBIN%" echo Couldn't find Cygwin at "%_CYGBIN%" & exit 3

 

:: Resolve ___.sh to /cygdrive based *nix path and store in %_CYGSCRIPT%

for /f "delims=" %%A in ('%_CYGBIN%\cygpath.exe "%~dpn0.sh"') do set _CYGSCRIPT=%%A

 

:: Throw away temporary env vars and invoke script, passing any args that were passed to us

endlocal & %_CYGBIN%\bash --login "%_CYGSCRIPT%" %*

pause

ren dare dare_backup

ren dare.sh dare

ren dare-1.0.2 dare-1.0.2_backup

ren dare-1.0.2.sh dare-1.0.2

ren dex-preopt dex-preopt_backup

ren dex-preopt.sh dex-preopt

ren dare-launcher-1.0.2 dare-launcher-1.0.2_backup

ren dare-launcher-1.0.2.sh dare-launcher-1.0.2

exit

This script is run from Command prompt in the same location as bash shell but prior running anything else. It creates a backup of the files, cleans the line endings with sed and produces new bash shell scripts and renamed back to the same executables as was started with.

#!/bin/sh

echo "Cleaning Dare bash scripts"

cd dare && cat dare | sed '/\015/d' >dare.sh && cat dex-preopt | sed '/\015/d' >dex-preopt.sh && cat dare-1.0.2 | sed '/\015/d' >dare-1.0.2.sh && cat dare-launcher-1.0.2 | sed '/\015/d' >dare-launcher-1.0.2.sh

 

After this however the dare-launcher-1.0.2 script when I open it to view is corrupted badly? Even after several downloads from both chrome and IE browsers produce the same corrupted file?
I assume that this is the same corrupt error that I am getting from within command prompt?


How this provides some insight. I really hope to port this properly over to Windows so I can eventually work on polishing something that can be rerun inside Eclipse. To date I believe that there is only JEB (which is super expensive) that is capable of achieving this?

I have been using these tools to target Malware. Just last week I was able to identify two new Malware apps on Google Play store that have been there for months undetected. I also logged one with adb attempting to send a mass payload outgoing sms to premium sms fraud site. Your application has been instrumental in helping me break down this otherwise difficult to read code. It also helps me get an understanding of what smali is doing and I don't have to sit there with a freakin hex calculator trying to get number strings for variables lol.

So thank you in advance. I appreciate all that you guys are doing. I hope I can serve to help more people cross platforms :)



Regards


James




--
You received this message because you are subscribed to a topic in the Google Groups "dare" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/dare-android/RCn-DUI-Rnk/unsubscribe?hl=en.
To unsubscribe from this group and all its topics, send an email to dare-android...@googlegroups.com.

To post to this group, send email to dare-a...@googlegroups.com.

Dalvik Retargeting (Dare)

unread,
Jul 2, 2013, 1:48:45 AM7/2/13
to dare-a...@googlegroups.com
Hi James,

Sorry about the slow replies.

For decompilation, you should use the -e flag. There is no need to run the command twice. The second command you are using should work, although you can avoid using the -o flag ,as the -c flag activates both optimization and decompilation. That should save you a lot of processing time.

The thing you're seeing when Soot seems to be doing the same thing many times is just Soot decompiling classes one after the other. It should eventually terminate. Note that you shouldn't run Soot twice on the same application to the same output directory, as Soot will decompile the same classes twice.

Note that the reason why I asked about the error message is that there is a known issues with the version of Soot that is distributed with Dare, which relates to classpath errors. It was fixed in the main Soot repository, and we will integrate the fix in a future release of Dare.

I'm afraid I can't help you with Windows, as I've never tried it on Cygwin myself. I'm not sure that there's a way to run binaries compiled on Ubuntu with Cygwin. That would explain the error message you're seeing. Note that dare-launcher-1.0.2 and dare-1.0.2 are not scripts, there are binaries compiled from C++ source code. What you are seeing is not a corrupted script, it is a binary file.

Regards,
Damien


James Hatton

unread,
Jul 6, 2013, 9:54:53 AM7/6/13
to dare-a...@googlegroups.com

James Hatton

unread,
Jul 6, 2013, 10:08:39 AM7/6/13
to dare-a...@googlegroups.com
Hi,
I have successfully set up Dare on Ubuntu Linux VM and seems to be working well for me. However I attempted to translate this across to run inside Windows Native console (command prompt). In the past I have had some success to with porting some apps to windows with helper scripts etc. I understand that there are limitations in this area being Windows but I thought I would like to at least try. I managed to exec dare via its main thread by passing some arguments via Windows batch script. This has worked for several java apps running under Win.....the beauty of java cross platform :)

Anyway the issue I have had mainly is that SOOT cannot resolve the class path? I have read the documentation and done everything by the book as far as set up is concerned...only that it is is Windows. I went as far as moving everything to the root of C:\ too so that there were no spaces in my path and that the Soot application got first allocation for the JAVA env variables. Instead of it trying to resolve the C:\Program Files or C:\Program Files (x86) with spaces in the path, which initially it didn't?
I have the JDK bin folder on the standard windows path so I can also call Java from everywhere in the system? Soot for some reason cannot find Java? Java can find it no problems. I can write all the settngs/help output to the console/command line too. 
Running Soot independently in the Ubuntu VM also proved to process the same errors of not finding the classpath even though JAVA is set 100% correct? Soot seems to be able to ignore these errors and continue

Edit: Sorry one of my posts that I thought I had lost has somehow submitted it's self now? You have already answered some of the questions I had and thank you. Basically to sum things up, I can get Dare to work fin in Ubuntu, and i have managed to get both Jasmin and other Java command line apps working no problems in Window, so I guess at some point in the future this could also be possible for Dare to be fully cross platform. Fingers crossed for you guys if you can get an update on the Soot build for Dare. That would be fantastic!

I am not sure if I explained in my posts anywhere yet, but I had initially used Dare for my own self investigations of suspected Malware, and I still do use it for that. However, I am currently unemployer and been offered to take the position with a Mobile development company to fill the place of a developer that kind of jump shipper and moved out of the country. In doing so he has taken the source code with him and I am having a hell of a time trying to locate anything like this. They are Android wallpapers, based on the older frame animation canvas wallpapers (touch and shake activated). Worse part for me is that the internet has basically packed up and moved on to bigger and better things such as 3D GL rendering. So it is hard to find sources anywhere for these wallpapers I am meant to re-produce?
So my question is, has anyone from your team managed to decompile sources to a high enough quality in order for them to recompile inside Eclipse? If so do you have any specific instructions or tips you can share in order to achieve this? I will be willing to donate what little money I do have for assistance in this regard. This is a legitament reversing project, this isn't for hacking purposes or anything like that.

Please feel free to contact me, and will be happy to jump on Skype if needs be (at any time of the day or night that suits).

I look forward to hearing from you.

Kind regards

James
Reply all
Reply to author
Forward
0 new messages