Related
For the first time, I today attempted to extract a rom.zip from a shipped rom release (.exe) on Linux.
The process is problematic as, after launching the executable using wine, the application crashes, deleting all its files. You therefore have to be *very* quick looking inside the ~/.wine/users/username/Temp folder for the rom.zip.
Anyway, I have knocked up a quick python script that will monitor this directory for rom.zip and copy it to your home folder.
The only modification you need to make before running is to change the username field to your own username. I would have used getpass to obtain this but, for some reason, on certain systems you need to use sudo which messes this up.
Usage:
1.) Change username in script
2.) Run script
3.) Run RUU_xxxxxx.exe
4.) Get rom.zip from home folder
Anyway, I hope this is helpful and look forward to hearing feedback.
Best,
Martin
Code:
#!/usr/bin/python
'''
ROM Extractor Copyright (c) 2010 Martin Paul Eve
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
'''
import os
import pyinotify
import io
# USERNAME IS REQUIRED (you may have to run as root using sudo)
username = "martin"
# Modify these if using a different wine location or rom name; HTC seem to use rom.zip
filename = "rom.zip"
monitor_path = "~/.wine/drive_c/users/%s/Temp/" % username
wm = pyinotify.WatchManager()
mask = pyinotify.IN_CREATE | pyinotify.IN_MODIFY | pyinotify.IN_DELETE | pyinotify.IN_MOVED_TO
bd = None
class RExtract(pyinotify.ProcessEvent):
def process_IN_MOVED_TO(self, event):
# this seems to be the event fired; IN_CREATE is included just in case, though
if event.name.endswith(filename):
print "Found ROM. Awaiting completion of modification."
self.f = open(os.path.join(event.path, event.name), "r")
self.bd = self.f.read()
def process_IN_CREATE(self, event):
if event.name.endswith(filename):
print "Found ROM. Awaiting completion of modification."
self.f = open(os.path.join(event.path, event.name), "r")
def process_IN_MODIFY(self, event):
# on modify, append to the file
if event.name.endswith(filename):
if hasattr(self, "bd"):
self.bd = self.bd + self.f.read()
else:
self.bd = self.f.read()
def process_IN_DELETE(self, event):
if event.name.endswith(filename):
self.f.close()
self.f = open(os.path.join("/home/%s/" % username, "rom.zip"), "w")
self.f.write(self.bd)
self.f.close()
print "ROM Copied to /home/%s/rom.zip" % username
raise KeyboardInterrupt
notifier = pyinotify.Notifier(wm, RExtract())
print "ROM Extractor Copyright (c) 2010 Martin Paul Eve"
print "This program comes with ABSOLUTELY NO WARRANTY."
print "This is free software, and you are welcome to redistribute it under certain conditions; see the included licence statement"
print ""
print "Monitoring: %(path)s for %(filename)s" % {"path": os.path.expanduser(monitor_path), "filename": filename}
print "Press CTRL+C to exit"
wdd = wm.add_watch(os.path.expanduser(monitor_path), mask, rec=True, auto_add=True)
while True:
try:
notifier.process_events()
if notifier.check_events():
notifier.read_events()
except KeyboardInterrupt:
notifier.stop()
break
Hey Martin there is a tool already available for this here in Forums... dint work for me for some reason.. Just informing you so that u do not reinvent the wheel ..
EDIT :: here it is: http://forum.xda-developers.com/showthread.php?t=711298
Regards
Ahh! Finally one that works!
Thanks!
TheDeadCpu said:
Ahh! Finally one that works!
Thanks!
Click to expand...
Click to collapse
Excellent; glad that my effort wasn't wasted then
I can't make it work but thanks for your job !
(and for your soft-root too !!)
voodka2007 said:
I can't make it work but thanks for your job !
(and for your soft-root too !!)
Click to expand...
Click to collapse
Could you be more specific about what happens when you run it and it doesn't work? You need python-py-inotify for it to detect the file...
Sent from my HTC Wildfire using XDA App
Script can be run, it just can't found rom.zip... i have install python-pyinotify package, and it's same.
I have try 2 monitoring path :
~/.wine/dosdevices/c:/windows/temp
and
~/.wine/drive_c/windows/temp
I have try with root, sudo, check username, chmod the script, and it's same.
voodka2007 said:
Script can be run, it just can't found rom.zip... i have install python-pyinotify package, and it's same.
I have try 2 monitoring path :
~/.wine/dosdevices/c:/windows/temp
and
~/.wine/drive_c/windows/temp
I have try with root, sudo, check username, chmod the script, and it's same.
Click to expand...
Click to collapse
Check the format of your path. It should be like this:
monitor_path = "~/.wine/drive_c/users/%s/Temp/" % username
This is because it won't extract to c:\Windows\Temp but to c:\Users\Username\Temp
Try leaving monitor path just as it was (but change the username)...
Code:
[Pyinotify ERROR] add_watch: cannot watch /home/voodka/.wine/drive_c/users/voodka/Temp/ (WD=-1)
I haven't users folder in my .wine/drive_c/
What version of windows have you set in winecfg?
Sent from my HTC Wildfire using XDA App
Thanks for your perseverance !
In my wincfg i use Windows XP
But i have try with Windows 7 and it's always same...
Do this problem can come from Wine 1.2 ? (i don't use 1.0)
Thanks...
PERFECT
i must buy you a beer
Worked for me.
Radio_13.53.55.24H_3.35.19.25_release_151892_signed.exe and Ubuntu 10.10
thanks!
Hi all,
ChkBugReport is a tool that helps you analyze your crash files. Because this tool is such a great help for our internal developers at Sony Ericsson, and as a part of our ambition to step up our open source activities, we want to give all of you the chance to use it by making it open source. Pál Szász (XDA username: pal.szasz), a software developer at Sony Ericsson, is the creator of this tool and will monitor this thread for questions, discussions and suggestions. Feel free to have a look at the open source project and contribute to make it even better!
https://github.com/sonyericssondev/ChkBugReport
For the full story follow the full story in Developer World
/Karl-Johan Dahlström
Sony Ericsson Developer Program
Nice. Any intention of integrating this into some IDE ?
I haven't thought about IDE integration. What do you have in mind exactly?
What I'm working on is automatically opening the result in a browser when processing done (already in the source code, although I tested only in osx at the moment).
Another functionality in progress (not uploaded yet) is to use ADB to automatically save a bugreport. So you would just execute
Code:
chkbugreport --browser adb://
and it will save the bugreport, analyze it and open the result in a browser (as a bonus a screenshot is saved as well).
When this would be implemented I think it would be easy to add it as an external tool in eclipse and launch it from there.
pal.szasz said:
I haven't thought about IDE integration. What do you have in mind exactly?
What I'm working on is automatically opening the result in a browser when processing done (already in the source code, although I tested only in osx at the moment).
Another functionality in progress (not uploaded yet) is to use ADB to automatically save a bugreport. So you would just execute
Code:
chkbugreport --browser adb://
and it will save the bugreport, analyze it and open the result in a browser (as a bonus a screenshot is saved as well).
When this would be implemented I think it would be easy to add it as an external tool in eclipse and launch it from there.
Click to expand...
Click to collapse
One possible IDE integration would be for the report to have linkable parts to the source code when applicable.
Also selecting the process from a windows, having UI buttons starting and stopping the capture of profiling data would be a bonus.
Anyway, the application works very well, and thumbs up for open sourcing this tool .
BTW in my case I've came across some missing resources when generating output:
Code:
Writing chapter: Trace charts/Thread-17 (Thread-18)...
Writing chapter: Main thread activity...
Writing footer...
Cannot find resource: /style.css
Cannot find resource: /icons.png
Cannot find resource: /ftrace-legend-dred.png
Cannot find resource: /ftrace-legend-black.png
Cannot find resource: /ftrace-legend-yellow.png
Cannot find resource: /ftrace-legend-red.png
Cannot find resource: /ftrace-legend-cyan.png
Cannot find resource: /ftrace-legend-dcyan.png
Cannot find resource: /pcy_p0.png
Cannot find resource: /pcy_p1.png
Cannot find resource: /pcy_p2.png
Copying extra resources...
Cannot find resource: /pcy_p3.png
Cannot find resource: /pcy_p4.png
Cannot find resource: /pcy_un.png
Cannot find resource: /pcy_rt.png
Cannot find resource: /pcy_fg.png
Cannot find resource: /pcy_bg.png
Cannot find resource: /main.js
Cannot find resource: /jquery.js
Cannot find resource: /jquery.cookie.js
Cannot find resource: /jquery.jstree.js
Cannot find resource: /jquery.hotkeys.js
Cannot find resource: /jquery.tablesorter.js
Cannot find resource: /jquery.tablednd.js
Cannot find resource: /themes/classic/d.png
Cannot find resource: /themes/classic/dot_for_ie.gif
Cannot find resource: /themes/classic/throbber.gif
Cannot find resource: /themes/classic/style.css
Cannot find resource: /themes/blue/desc.gif
Cannot find resource: /themes/blue/bg.gif
Cannot find resource: /themes/blue/style.css
Cannot find resource: /themes/blue/asc.gif
DONE!
Regarding the resource errors: did you used the precompiled binary or compiled the source code yourself? If it's the later one, how did you compile it? While developing I use eclipse, and I have the "res" folder added a source folder as well. This way the contents of the res folder will be copied to the jar. If you compiled it in some other way, then probably the resources from "res" where not packed into the jar. Building with the ant file should work as well ("ant -f chkbugreport.xml" if I remember correctly)
Regarding the IDE integration: yes, linking/binding the source code would be nice. For tracing data there is already something in progress: running "chkbugreport -t adb://" will show a window to select a process and start/stop it's profiling, but since that code uses code from the android sdk, I need to check how I can link the two codes together (since one of the codes is GPL, the other is Apache) before I can publish it.
I uploaded the changes for adb support. Now an extra jar file is needed: ddmlib.jar. You can find this either in the source code repo, or in the android sdk (a recent one is needed).
I updated the wrapper script as well, to use ddmlib.jar. However if the ddmlib.jar is missing, then the tool will still work like before, simply the new functionality will be missing, which is:
Code:
chkbugreport --browser adb://
The above command will run the bugreport tool on the phone (if it's connected to the PC, of course), processes it and open the result in the browser. As extra bonus, a screenshot is saved as well ;-)
Code:
chkbugreport --browser -t adb://
This will show a window, where you can select which process to trace. Click START then STOP, and the tracefile will be created and processed (and opened in the browser). BUT: there are some limitations:
* adb must be run as root (the tracefile is saved to the /data partition), which means either run en ENG build or USERDEBUG (but then you must first execute "adb root")
* it seems that the fileformat for traceview files have changed, the tool currently supports only version 1, so this will not work if you have a recent android version. I'll fix this later.
pal.szasz said:
Regarding the resource errors: did you used the precompiled binary or compiled the source code yourself? If it's the later one, how did you compile it? While developing I use eclipse, and I have the "res" folder added a source folder as well. This way the contents of the res folder will be copied to the jar. If you compiled it in some other way, then probably the resources from "res" where not packed into the jar. Building with the ant file should work as well ("ant -f chkbugreport.xml" if I remember correctly)
Regarding the IDE integration: yes, linking/binding the source code would be nice. For tracing data there is already something in progress: running "chkbugreport -t adb://" will show a window to select a process and start/stop it's profiling, but since that code uses code from the android sdk, I need to check how I can link the two codes together (since one of the codes is GPL, the other is Apache) before I can publish it.
Click to expand...
Click to collapse
I compiled my own using IDEA, but since I didn't get any errors during compilation (I think) I didn't assume I was missing something in the compilation process.
About the other changes, why not output the traces to /sdcard ? Since that one is always R/W to all users should work right? I say this without actually having looked at the code behind the magic, so perhaps is not a valid suggestion.
I am planning to add support for that as well (i.e. the user can select where to save the tracelogs). AFAIK the sdcard is only readable for everyone by default, apps need to have a certain permission (something with WRITE_EXTERNAL_STORAGE) in order to be able to write to sdcard. But if you are debugging your own app, that's not a problem.
I haven't updated this thread in a looong time. I'm pretty close to put up some more detailed documentation and examples, hopefully I can do it tomorrow.
Meanwhile as a teaser here is an example report generated from a bugreport: http://sonyericssondev.github.com/ChkBugReport/examples/bugreport_aidldeadlock_out/index.html
The shell user does have permissions to write to sdcard, so if you're doing that via adb it should be good.
Sent from my GT-P1000
Well, finally I had time to add some documentation: https://github.com/sonyxperiadev/ChkBugReport/wiki (it's not complete, but at least a good start)
Also source code is pushed and added a new precompiled jar (I started to add the version number in the filename so I can keep the old versions as well): https://github.com/sonyxperiadev/ChkBugReport/downloads
And as usual, any kind of feedback is welcome
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
New link: https://github.com/sonyxperiadev/ChkBugReport
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
Since I cannot edit the first post (since it was not created by me), and the link is broken, I started a new thread: http://forum.xda-developers.com/showthread.php?p=34960691
clear post
pal.szasz said:
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
New link: https://github.com/sonyxperiadev/ChkBugReport
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
Click to expand...
Click to collapse
There are many people, new to development.
Always try to post step by step instruction which will help others....
Is there anyone here that can look at a bug report that popped up on my friend's phone and be able to tell who hacked her phone? She is in bitter custody battle and we are trying to prove it is the ex doing this with intent for court purposes. Please help! If willing please respond and I will give a private email address to private message due to complex circumstances and we all fear for child and our lives. Thanks in advance.
Hi, what are these colorful icons mean in the VM traces info?
Hello again,
while I´m still working on my PDF to Office app I found out how to use <Capability Name="ID_CAP_OEM_DEPLOYMENT" />.
Using this capability lets you launch any deployed app within another app or lets you get the applist of all deployed apps (sadly less system apps like Office) including appname, uri, appicon and so on.
1. add
Code:
<Capability Name="ID_CAP_OEM_DEPLOYMENT" />
to your WMAppManifestXML
Add to your *xaml.cs file:
2.
Code:
using Windows.ApplicationModel;
using Windows.Phone.Management.Deployment;
3.
Code:
public Package GetPackageByID(string id)
{
return InstallationManager.FindPackages().FirstOrDefault(p => p.Id.ProductId.ToLower().Equals(id.ToLower()));
}
=> the code will return the package (app) you want to launch if it exists
4.
Code:
private void LaunchAR_Click(object sender, System.Windows.Input.GestureEventArgs e)
{
Package packageById = GetPackageByID("{134E363E-8811-44BE-B1E3-D8A0C60D4692}");
if (packageById != null)
{
packageById.Launch(string.Empty);
}
else
{
// do something if the app doesn´t exist
}
}
=> this sample code will launch Adobe Reader if the app is present on your device
With some simple modifications of the above code you will easyly be able to make visible the whole applist in a ScrollistViewer or Listbox.
=> this could be useful for coding a new AppData backup app for interop-unlocked devices.
Cheers
contable
contable said:
Hello again,
while I´m still working on my PDF to Office app I found out how to use <Capability Name="ID_CAP_OEM_DEPLOYMENT" />.
Using this capability lets you launch any deployed app within another app or lets you get the applist of all deployed apps (sadly less system apps like Office) including appname, uri, appicon and so on.
1. add
Code:
<Capability Name="ID_CAP_OEM_DEPLOYMENT" />
to your WMAppManifestXML
Add to your *xaml.cs file:
2.
Code:
using Windows.ApplicationModel;
using Windows.Phone.Management.Deployment;
3.
Code:
public Package GetPackageByID(string id)
{
using (List<Package>.Enumerator enumerator = new List<Package>(InstallationManager.FindPackages()).GetEnumerator())
{
while (enumerator.MoveNext())
{
Package current = enumerator.Current;
try
{
if (current.Id.ProductId.Contains(id))
return current;
}
catch (Exception ex)
{
}
}
}
return (Package)null;
}
=> the code will return the package (app) you want to launch if it exists
4.
Code:
private void LaunchAR_Click(object sender, System.Windows.Input.GestureEventArgs e)
{
Package packageById = GetPackageByID("{134E363E-8811-44BE-B1E3-D8A0C60D4692}");
if (packageById != null)
{
packageById.Launch(string.Empty);
}
else
{
// do something if the app doesn´t exist
}
}
=> this sample code will launch Adobe Reader if the app is present on your device
With some simple modifications of the above code you will easyly be able to make visible the whole applist in a ScrollistViewer or Listbox.
=> this could be useful for coding a new AppData backup app for interop-unlocked devices.
Cheers
contable
Click to expand...
Click to collapse
Yep! This is used in Samsung AppFolder
-W_O_L_F- said:
Yep! This is used in Samsung AppFolder
Click to expand...
Click to collapse
Exactly.
Do you you know how "InstallationManager.AddPackageAsync" works ?
contable said:
Exactly.
Do you you know how "InstallationManager.AddPackageAsync" works ?
Click to expand...
Click to collapse
I am hoping to learn that myself. I know that Nokia's "Extras & Info" app uses this API for their "SilentInstaller". Nokia's "SilentInstaller" has the ability to install interop-unlocked apps as long as they are fully and properly signed with the appropriate license.xml and wmprheader.xml.
Microsoft has some documentation about this API at http://msdn.microsoft.com/en-us/library/windowsphone/develop/jj207248(v=vs.105).aspx
**EDIT**
Found it! (I think)
we can deploy apps with InstallationManager.AddPackageAsync(String title, Uri sourceLocation, String instanceId, String offerId, Uri license)
This info matches EVERYTHING that is included with a valid xap signed by Microsoft. All the data is contained in the xap's provxml, too (albeit in the wrong order)
Info about this "undocumented" api is at http://msdn.microsoft.com/en-us/library/windowsphone/develop/jj662948(v=vs.105).aspx
The million-dollar questions are what privileges are required to access this API, and can we use it without interop unlock?
Really wishing I had my phone back! (won't be here until tomorrow)
Very nice, thanks for publishing! I was going to pull apart App Folder and see how it works myself; thanks for taking the time to do that for me and share it with us all!
For what it's worth, a foreach loop will read more cleanly than explicitly calling GetEnumerator() and then iterating over it, but the basic structure of the code is fine (and I think the MSIL is the same anyhow - foreach being just syntactic sugar - so they probably did it that way when actually writing the app and your decompiler just produced the more verbose version from the MSIL).
Note that this can also, of course, be used to create launcher apps. An alternative to the Start screen, potentially, even (with some other hackery to hook it in where needed). To use it in Backup apps, though, we'll need access to the app's storage folder too (or a way to activate the SeBackup privilege in the app's token...)
Well... already known when I decompiled samsung's app folder app.
---------- Post added at 12:37 PM ---------- Previous post was at 12:29 PM ----------
compu829 said:
I am hoping to learn that myself. I know that Nokia's "Extras & Info" app uses this API for their "SilentInstaller". Nokia's "SilentInstaller" has the ability to install interop-unlocked apps as long as they are fully and properly signed with the appropriate license.xml and wmprheader.xml.
Microsoft has some documentation about this API at http://msdn.microsoft.com/en-us/library/windowsphone/develop/jj207248(v=vs.105).aspx
**EDIT**
Found it! (I think)
we can deploy apps with InstallationManager.AddPackageAsync(String title, Uri sourceLocation, String instanceId, String offerId, Uri license)
This info matches EVERYTHING that is included with a valid xap signed by Microsoft. All the data is contained in the xap's provxml, too (albeit in the wrong order)
Info about this "undocumented" api is at http://msdn.microsoft.com/en-us/library/windowsphone/develop/jj662948(v=vs.105).aspx
The million-dollar questions are what privileges are required to access this API, and can we use it without interop unlock?
Really wishing I had my phone back! (won't be here until tomorrow)
Click to expand...
Click to collapse
see nokia extra+info app's capability
You can use Shell Chrome API directly to launch any URI, just 2 lines code
reker said:
You can use Shell Chrome API directly to launch any URI, just 2 lines code
Click to expand...
Click to collapse
So please post the two lines of code so that I can launch any URI without using a Toast.
DELETED
GoodDayToDie said:
Very nice, thanks for publishing! I was going to pull apart App Folder and see how it works myself; thanks for taking the time to do that for me and share it with us all!
For what it's worth, a foreach loop will read more cleanly than explicitly calling GetEnumerator() and then iterating over it, but the basic structure of the code is fine (and I think the MSIL is the same anyhow - foreach being just syntactic sugar - so they probably did it that way when actually writing the app and your decompiler just produced the more verbose version from the MSIL).
Note that this can also, of course, be used to create launcher apps. An alternative to the Start screen, potentially, even (with some other hackery to hook it in where needed). To use it in Backup apps, though, we'll need access to the app's storage folder too (or a way to activate the SeBackup privilege in the app's token...)
Click to expand...
Click to collapse
Here an improved code:
Code:
public Package GetPackageByID(string id)
{
List<Package> packages = new List<Package>(InstallationManager.FindPackages());
foreach (var cpackage in packages)
{
if (cpackage.Id.ProductId.Contains(id))
return cpackage;
}
return (Package)null;
}
Indeed to create an AppData Backup app we need access to the app´s storage folder first. Atm we only can copy files from the app´s storage folder with another RPCComponent discovered by -W_O_L_F-. But when the time comes a Backup app can be created in a few hours...
Oneliner (untested)
Code:
public Package LinqGetPackageByID(string id)
{
return InstallationManager.FindPackages().FirstOrDefault(p => p.Id.ProductId.ToLower().Equals(id.ToLower()));
}
jessenic said:
Oneliner (untested)
Code:
public Package LinqGetPackageByID(string id)
{
return InstallationManager.FindPackages().FirstOrDefault(p => p.Id.ProductId.ToLower().Equals(id.ToLower()));
}
Click to expand...
Click to collapse
Thanks. The oneliner works fine. :good:
Edit:
post #1 updated with the oneliner....
jessenic said:
Oneliner (untested)
Code:
public Package LinqGetPackageByID(string id)
{
return InstallationManager.FindPackages().FirstOrDefault(p => p.Id.ProductId.ToLower().Equals(id.ToLower()));
}
Click to expand...
Click to collapse
Is it also possible to check if an app is installed and if yes, which version? that would be nice...
gipfelgoas said:
Is it also possible to check if an app is installed and if yes, which version? that would be nice...
Click to expand...
Click to collapse
Yes. With this method you can get all informations about an installed package: version, publisher and so on...
Hi,
This is a guide on compiling the latest (as of 2015-06-24) dropbear SSH daemon (2015.67) for the Nexus 7 2013 but should also work for other ARM architecture Android devices. The guide is mainly based off the work from the blog http://blog.xulforum.org/index.php?post/2013/12/19/Compiling-Dropbear-for-a-Nexus-7-tablet which is an excellent guide to getting an older version of dropbear running on ARM Android devices.
I've modified the patch made by the original author to work on the latest dropbear version. There are not much changes from ver 2013.58 to 2015.67. The main difference seems to be the support for Elliptical Curve encryption.
** START DISCLAIMER **
I did not write the original codes/patch myself and have not scrutinized it for any security issues. USE IT AT YOUR OWN RISK.
** END DISCLAIMER **
Here's the list of requirements :-
1) Dropbear 2015.67 source code - dropbear-2015.67.tar.bz2 (https://matt.ucc.asn.au/dropbear/releases/dropbear-2015.67.tar.bz2)
2) Patch to compile for Android - dropbear-v67-android-patch-20150630 (https://goo.gl/Obo6kT) OR alternatively, you can use the patch from user serasihay (https://goo.gl/ip6Tkb).
3) A recent Linux distro (I use Ubuntu 14.04.2 LTS).
4) Development tools i.e. C compiler, linker, etc... all the necessary tools to run configure, make, etc..
5) Android NDK (I'm using rev 10e) installed & setup on Linux.
Steps :-
(1) Extract the source code to a directory of its own :-
Code:
tar xjf dropbear-2015.67.tar.bz2
cd dropbear-2015.67
(2) Patch the source :-
Code:
patch -p1 < dropbear-v67-android-patch-20150630
(3) Run configure :-
Code:
./configure --build=x86_64-unknown-linux-gnu --host=arm-linux-androideabi \
--disable-zlib --disable-largefile --disable-loginfunc \
--disable-shadow --disable-utmp --disable-utmpx --disable-wtmp \
--disable-wtmpx --disable-pututline --disable-pututxline --disable-lastlog
(4) Edit config.h, search for USE_DEV_PTMX and add the following line after that :-
Code:
#define USE_DEV_PTMX 1
(5) Run make :-
Code:
STATIC=1 MULTI=1 SCPPROGRESS=0 PROGRAMS="dropbear dropbearkey scp dbclient" make strip
(6) You should end up with a single static binary "dropbearmulti" which you should link dropbear, dbclient/ssh, dropbearkey and scp to.
Code:
./dropbear -h
Dropbear server v2015.67 https://matt.ucc.asn.au/dropbear/dropbear.html
Usage: ./dropbear [options]
-A Android Mode, specify a user explicitly
-N Android Mode, user name
-C Android Mode, password
-R Android Mode, public key file (authorized_keys)
-U Android Mode, UID
-G Android Mode, GID
-b bannerfile Display the contents of bannerfile before user login
(default: none)
-r keyfile Specify hostkeys (repeatable)
defaults:
dss /etc/dropbear/dropbear_dss_host_key
rsa /etc/dropbear/dropbear_rsa_host_key
ecdsa /etc/dropbear/dropbear_ecdsa_host_key
-F Don't fork into background
-E Log to stderr rather than syslog
-m Don't display the motd on login
-w Disallow root logins
-s Disable password logins
-g Disable password logins for root
-B Allow blank password logins
-j Disable local port forwarding
-k Disable remote port forwarding
-a Allow connections to forwarded ports from any host
-p [address:]port
Listen on specified tcp port (and optionally address),
up to 10 can be specified
(default port is 22 if none specified)
-P PidFile Create pid file PidFile
(default /var/run/dropbear.pid)
-i Start for inetd
-W <receive_window_buffer> (default 24576, larger may be faster, max 1MB)
-K <keepalive> (0 is never, default 0, in seconds)
-I <idle_timeout> (0 is never, default 0, in seconds)
-V Version
I will assume you know what to do with the binary file generated so will not elaborate on the process.
Hope it works for you guys. I'll be happy to help out anyone who needs more details.
NOTE: I have posted a similar guide for building dropbear for an x86 Android device in the Zenfone 2 forum (http://forum.xda-developers.com/zenfone2/general/compiling-dropbear-2015-67-zenfone-2-t3142222). The steps are mostly similar.
Cheers.
UPDATE: 2015-06-29
- I've updated the patch to fix dbclient/ssh client using password authentication.
UPDATE: 2015-06-30
- Reverted the patch for the dbclient fix as NDK does not have getpass() function. Looks like dbclient with password auth will seg fault until we can find an alternative to getpass().
UPDATE: 2015-06-30 (2)
- Uploaded yet another update to the patch to include a version of getpass(). Hopefully it works
UPDATE: 2015-07-02
- Added alternate dropbear patch by serasihay (Thanks!). Details of changes can be found here :- http://forum.xda-developers.com/showpost.php?p=61649194&postcount=14
Thank you for the guide, wolfdude!
I'm more interested in the client rather than the server, though.
Have you tried it? Does it work for you? For me, it doesn't.
I'm tying to connect to a remote host using the password authentication, but a segmentation fault occurs just after accepting the key of the remote host. It doesn't get to ask for the password.
The crosscompilation process goes without errors. I copy the binary to the Nexus, I do the symlinks in /system/xbin, etc.
I run the client from Terminal Emulator, and the remote host key is correctly stored in .ssh/known_hosts, inside the app's "app_HOME" directory found in /data.
On the remote server I can see that the connection request is received, the provided user is successfully identified as valid/existing; and the key algorithm exchange seems to succeed, too... But after that the connection is closed by the client... :-?
Hi serasihay,
Yes, I'm getting a Seg Fault too when I use the SSH client and using password auth. When I use an identity file, I don't get a SegFault and it connects successfully. I'm not sure what's causing the Seg Fault. When I get some time, I might have to run it through a debugger to find out. There might be more patches required to get the client working.
Cheers.
Thank you for confirming it, wolfdude.
I also think that there's more code to be patched.
I'm reading to learn how to debug the binary... Never done this on Android...
Thanks again for your time!
Hi Serasihay,
I've updated the patch to fix the seg fault issue. Turns out that the original patch commented out a chunk of code that was required for password authentication. Please test it out and hopefully this works well for you.
Cheers.
It looks like you've uploaded the old patch again by mistake... I diffed both files and they are exactly the same.
Yesterday I made good progress learning how to debug remotely a binary running on an Android device. I had to recompile the binary without striping the symbols, etc.
I'm a bit out of my depth here, but I'll continue trying to understand where's the flaw.
Code:
$ adb forward tcp:5039 tcp:5039
$ ./android-ndk-r10e/toolchains/arm-linux-androideabi-4.8/prebuilt/linux-x86_64/bin/arm-linux-androideabi-gdb
[...]
(gdb) target remote :5039
(gdb) symbol-file dropbear-2015.67/dropbearmulti
Reading symbols from dropbear-2015.67/dropbearmulti...done.
(gdb) run
The "remote" target does not support "run". Try "help target" or "continue".
(gdb) continue
Continuing.
Program received signal SIGSEGV, Segmentation fault.
0x000527cc in strlen (s=0x0) at bionic/libc/arch-arm/bionic/strlen.c:62
62 bionic/libc/arch-arm/bionic/strlen.c: No such file or directory.
(gdb) backtrace
#0 0x000527cc in strlen (s=0x0) at bionic/libc/arch-arm/bionic/strlen.c:62
#1 0x0000aff0 in cli_auth_password ()
#2 0x0000a7ec in cli_auth_try ()
#3 0x0000f534 in cli_sessionloop ()
#4 0x000161a0 in session_loop ()
#5 0x0000f16c in cli_session ()
#6 0x0000d604 in cli_main ()
#7 0x00008228 in main ()
(gdb) frame 1
#1 0x0000aff0 in cli_auth_password ()
(gdb) info frame
Stack level 1, frame at 0xbecbf848:
pc = 0xaff0 in cli_auth_password; saved pc = 0xa7ec
called by frame at 0xbecbf860, caller of frame at 0xbecbf7d0
Arglist at 0xbecbf844, args:
Locals at 0xbecbf844, Previous frame's sp is 0xbecbf848
Saved registers:
r4 at 0xbecbf834, r5 at 0xbecbf838, r6 at 0xbecbf83c, r11 at 0xbecbf840, lr at 0xbecbf844
(gdb)
I guess the code commented out in the patch that you are referring to is the one that, in cli-auth.c, does the following aasignement:
Code:
password = getpass(prompt);
It makes sense, because from the debugging "session" I posted int my previous post, one could deduce that the problem is that a null string is passed to cli_auth_password ()...
But, unhappily, the function getpass is not provided by the Android C library (Bionic). If you try to build with a "corrected" patch, you end up with this error:
Code:
cli-auth.o:cli-auth.c:function getpass_or_cancel: error: undefined reference to 'getpass'
I'll try to find a workaround. Any help will be appreciated!
serasihay said:
I guess the code commented out in the patch that you are referring to is the one that, in cli-auth.c, does the following aasignement:
...
I'll try to find a workaround. Any help will be appreciated!
Click to expand...
Click to collapse
Hi serasihay,
You're on the right track That is indeed the function causing the seg fault. I've updated the post to have the correct URL to the CORRECT patch now. Please try again and let me know how it goes.
Cheers.
Hi wolfdude,
The corrected patch you've uploaded is like the one I already tried. As I was saying in my previous post:
serasihay said:
But, unhappily, the function getpass is not provided by the Android C library (Bionic). If you try to build with a "corrected" patch, you end up with this error:
Code:
cli-auth.o:cli-auth.c:function getpass_or_cancel: error: undefined reference to 'getpass'
Click to expand...
Click to collapse
So, in my opinion, it's a matter of finding an alternative to "getpass", or implementing a new one... I'm reading what would be the better solution.
Thank you again for your time!
Cheers.
Ahh... apologies for not reading correctly. I see what you meant now. I did my compile/build on an x86 android device and I assumed that it would also work for ARM using the NDK. Let us know how you go with the getpass() alternative.
Thanks.
Hi serasihay,
Ok... I've uploaded another patch this time to include a getpass() function which I pinched & modified from the GLIBC library. Hopefully it works as expected. Again... I didn't audit it for any security issues so use at your own risk
Cheers.
Thank you very much for your help and efforts, wolfdude.
I've taken my chances with your new patch... But the code doesn't compile, either.
Now the problem is with the "getline" function:
Code:
cli-auth.o:cli-auth.c:function getpass: error: undefined reference to 'getline'
I'll keep struggling with it as time allows...
Edit:
I've found a working getpass function. The code compiles and allows me to successfuly login to my remote machine!
https://github.com/CyanogenMod/android_external_dropbear/blob/cm-12.0/netbsd_getpass.c
When I get time I'll see if it is secure to include it and what would be the proper way to do so. I'm out of my depth here. Of course, feel free to make a new patch or whatever you consider appropriate, surely you're more experienced than I am!
Good to know you have it working now. I'm no developer too so can't really comment on which ever is better. As long as it works right
Cheers.
I've uploaded the patch that makes the dropbear client work for me.
https://goo.gl/ip6Tkb
Basically, it is the one you uploaded initially, but it corrects the problem with the getpass function by using the one implemented in the file netbsd_getpass.c.
To sum it up, my patch differs from your first one in that:
* Adds two new files, netbsd_getpass.h and netbsd_getpass.c.
* Modifies cli-auth.c to include the netbsd_getpass.h in order to use its getpass function.
* Modifies the Makefile.in so that the netbsd_getpass.c object is compiled and included into the dropbearmulti binary.
* Modifies options.h to change the path of the SSH which is used in scp.c to: _PATH_SSH_PROGRAM "/system/xbin/dbclient"; i.e.: it assumes that you do the appropiate symlink in /system/xbin...
Cheers!
Good stuff! I'll update the original post to have a link to your patch.
Thanks.
I'll be happy if it helps anyone.
Thank you!
If you have openssl ported to Android, there's a simple, useful patch that substitutes crypt with openssl's DES_crypt.
Link to the description (which contains a link to the patch) is here: http://www.gossamer-threads.com/lists/openssh/bugs/55836
Note: DES encryption isn't the best, but it's better than cleartext. I did look through the openssl headers/libs for an AES_crypt or 3DES_crypt but couldn;t find anything
static compile... 'No such file or directory" error
Excellent guide -- wolfdude & serasihay thank-you. I'm new to andriod and was clueless on how to do this.
I have the dbclient running, but only if I compile without the STATIC=1. Whenever I use static I get an "sh: ./dbclient: No such file or directory" error immediately upon execution. Any idea why this is happening?
I'm using a Motorola Moto G (the new Moto G sometimes called the Moto G2). As the non-static is quite a bit smaller and seems to run okay I'm wondering if not using static will bomb on other devices and I'm just lucky with the Moto G.
Hi,
No idea why you can't compile it as static... but if the dynamic executable works for you then it should be ok.
Cheers.
I have tried to compile dropbear with both patches. But everytime it shows ::
gcc -I./libtomcrypt/src/headers/ -I. -I. -Os -W -Wall -Wno-pointer-sign -DDROPBEAR_SERVER -DDROPBEAR_CLIENT -DDBMULTI_dropbear -DDBMULTI_dbclient -DDBMULTI_dropbearkey -DDBMULTI_dropbearconvert -DDBMULTI_scp -DDROPBEAR_MULTI -c -o netbsd_getpass.o netbsd_getpass.c
netbsd_getpass.c: In function 'getpass':
netbsd_getpass.c:68:18: error: '_PASSWORD_LEN' undeclared (first use in this function)
netbsd_getpass.c:68:18: note: each undeclared identifier is reported only once for each function it appears in
netbsd_getpass.c:68:14: warning: unused variable 'buf' [-Wunused-variable]
netbsd_getpass.c:114:1: warning: control reaches end of non-void function [-Wreturn-type]
make: *** [netbsd_getpass.o] Error 1
Click to expand...
Click to collapse
I try to get shared preferences in the exposed class.
This is a straight forward issue in android java. I do not know whether the permissions are the problem but things are not as straight with Xposed.
Xposed asks to provide the name of the file and the package at init Zigote. I have tried many versions and none of them seems to work. Also, the file which I make may not be available when init Zygote is called, however, I take XposedBridge wants to just register the name of the file and, probably, to prepare to override some permissions when the file is created.
I also try to double the call to the Xposed Shared Method inside the hooked method. I check for the existence of the shared preference file before. Everything is there but the reload method does not seem to reload and the file is not read but defaults are loaded by getInt and getFloat.
There is probably something more to be done, although the examples I have seen do not do anything, yet they override other methods inside init Zygote which I do not need to do.
All I need is to read a simple file from an Xposed Module.
PLEASE, INFORM.
Here is what I have tried :
I have tried many different variation and XposedBridge methods for 4 hours. I have also
tried many name variations with and without .xml.
In the standard Java for Android, there is just one get method to read a shared
preferences file. This does not seem to be the case with exposed.
I do have :
@override
public void initZygote(StartupParam startupParam) throws Throwable {
MODULE_PATH = startupParam.modulePath;
prefs = new XSharedPreferences("PackageName", "SharedPreferenceFileNameWithotDotXml");
}
MODULE_PATH is not used, although I have tried many other methods where was.
Because the file changes on the fly, I called :
prefs.reload();
before I read the data. I tried without this call too. I also tried to get another
prefs before the reload :
prefs = new XSharedPreferences("PackageName", "SharedPreferenceFileNameWithotDotXml");
prefs.reload();
Then I try to read the data from the file :
theStart=prefs.getInt("Start", 2);
theValue=prefs.getFloat("Value", 102.0f);
I always get the defaults 2 and 102.0 although the file is there and the values of the
file are different. I have read the file.
In standard java for android philosophy, just the initialisation in init zygote and
prefs.reload() are sufficient to load the changing values of the shared preferences
file into prefs and then into the variables.
Xposed seems to be different.
I have been told there is a way to read the data from the file. I have tried most
anything and cannot. What is the way to do so. Must be simple and straight as in the
standard java for android. I must not do everything necessary.
Please, inform.
I have also tried to read the file manually from the Xposed class. Access denied. Tried
just in cases. Access denied, again.
Tried to make the shared preferences file with Activity.MODE_WORLD_READABLE. Still
access denied to be read manually.
Even with Activity.MODE_WORLD_READABLE, Xposed cannot read the file as previously
explained.
Tried :
@override
public void initZygote(StartupParam startupParam) throws Throwable {
prefs = new XSharedPreferences(TheNameOfTheXposedClass.class.getPackage().getName
());
prefs.makeWorldReadable();
}
Then, in the hooked method :
prefs.reload();
theStart = prefs.getInt("Start", 2);
theValue = prefs.getFloat("Value", 102.0f);
Still returns only the default, although the file is there. I think, in all attempts,
XSharedPreferences() cannot get the name of the package and or or the name of the file.
The file is in /data/data/NameOfPackage/shared_prefs/NameOfFile.xml
Tried :
@override
public void initZygote(StartupParam startupParam) throws Throwable {
prefs = new XSharedPreferences
("/data/data/NameOfPackage/shared_prefs/NameOfFile.xml");
prefs.makeWorldReadable();
}
with and without .xml
Still nothing.
PROBLEM SOLVED.
Thank you for your reply. Everything was WORLD READABLE : in the non Xposed class and in the Xposed class on a number of occasions.
Also, I have used the hard values for the package and path.
The problem was not related to Java and Android but to Android arrangements and how much Xposed can cope with. The Android permissions for to access the file from the Xposed class had to be elevated which is unusual but this is what solved the problem, I think. Someone also reported the same problem and the same solution : http://forum.xda-developers.com/xposed/development-xsharedpreferences-issue-t2931396
In the non Xposed class, I have used the same solution just with a hard coded path and file. After I make the shared preferences file in the non Xposed class, I gave more permissions by :
File theSharedPrefsFile;
theSharedPrefsFile = new File("/data/data/PackageName/shared_prefs/FileName.xml");
theSharedPrefsFile.setReadable(true, false);
This seems to have solved the problem.
I am not sure of how reliable the solution is, though. I still check in the Xposed class whethere there is such a file or not. I have not tested what happens when the file is not there initially. Must do.
theXposedCommunicationPreferenceFile = new File("/data/data/PackageName/shared_prefs/FileName.xml");
if (theXposedCommunicationPreferenceFile.exists() == false) XposedBridge.log("Check in hooked method cannot find the file");
Hope everything would be OK.
Even though everything should be OK, I am not sure how reliable the dependence of permissions is.
I have also tried the secure reload :
StrictMode.ThreadPolicy oldPolicy;
oldPolicy = StrictMode.allowThreadDiskReads();
try {
prefs.reload();
} finally {
StrictMode.setThreadPolicy(oldPolicy);
}
I am not sure how reliable this is either so I put another simple reload on top :
prefs.reload();
StrictMode.ThreadPolicy oldPolicy;
oldPolicy = StrictMode.allowThreadDiskReads();
try {
prefs.reload();
} finally {
StrictMode.setThreadPolicy(oldPolicy);
}
I think, neither of these has made any difference and the real solution was the higher permissions to access the shared preference file given in the non Xposed class, again :
File theSharedPrefsFile;
theSharedPrefsFile = new File("/data/data/PackageName/shared_prefs/FileName.xml");
theSharedPrefsFile.setReadable(true, false);
Pretty nasty problem and difficult to find solution although published in the XDA Forum the searchability of post in the said forum is not very good.
Yet another sleepless night.
StevenStanleyBayes said:
I think, neither of these has made any difference and the real solution was the higher permissions to access the shared preference file given in the non Xposed class, again :
Click to expand...
Click to collapse
I know this is a pretty old thread but I have elevated the permission level to 777 of both the dir and preferences file and yet cannot access the file from the xposedClass is there any chance you are still developing xposed modules and can help