[GPL] Shipped rom extractor (Linux) - Android Software Development

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!

Related

How to patch drivers (on WM5) ?

Hi,
I'm trying to patch the keyboard driver on my HTC Universal to still work if the clam is closed.
I patched one byte in the dll to change the return value of a specific function, and re-signed it using some kind of signing package with the sign.bat.
However, upon copying it to my device, after a soft-reset it seems like the keyboard driver just wouldn't load.
None of the keys worked, and in the start menu all shortcuts with shortkeys were prefixed with a & character.
Is there anything special I need to do to get this driver to load ?
Thanks,
TB
We have seen the same thing. As I understand it, under WM5 drivers have to be signed to be loaded, by changing the byte you've probably invalidated the signing on the DLL thus stopping it loading.
undergrid said:
We have seen the same thing. As I understand it, under WM5 drivers have to be signed to be loaded, by changing the byte you've probably invalidated the signing on the DLL thus stopping it loading.
Click to expand...
Click to collapse
As I said, I (tried to) re-sign it using some kind of sign.bat
Source of sign.bat is:
Code:
@echo off
if "%1" == "" goto oops
if not exist %1 goto oops2
signcode -spc TestCert_Privileged.cer -v TestCert_Privileged.pvk %1
goto exit
:oops
echo Usage: sign [filename]
goto exit
:oops2
echo %1 not found.
echo.
:exit
You have to make sure that the certificate is known to the device.
Even test certificates that come with MS Visual studio need to be registered on the device before you can use them.
Search this forum on how to add certificates to devices (there are several threads on this)
Got tired of trying to import a patched keybddr.dll,
So instead I wrote an app to patch the driver when already loaded, mwuhahaha!

[APP] fortune-mod-1.99.1 for Android (native)

Introduction
I've compiled a native version of the famous fortune (fortune-mod)!
This is the command line fortune that some seasoned *nix programmers / admins might remember from the past (when you log into and a small text message appeared on the console).
You need root and bash installed on the phone (bash is not mandatory, but is easy to add a line to the bash_profile and have the fortune display each time you login via PuTTY).
How it looks
Using droidsshd, this is how the UI looks when you connect with PuTTY:
Code:
login as: root
[email protected]'s password:
Hug me now, you mad, impetuous fool!!
Oh wait...
I'm a computer, and you're a person. It would never work out.
Never mind.
[[email protected]]/sdcard#
It also works with the terminal emulator
Download
fortune-mod-1.99.1.tar.gz
It contains also the offensive fortunes!
Install
To install it, you need to be root of course. The archive contains the structure that has to be copied as is to the phone:
Code:
/system/bin/fortune <- main executable
/system/usr/share/games/fortunes/ <- folder where fortune files have to be unpacked
After you copy everything to the correct location, two more things to be done:
Code:
chmod 755 /system/bin/fortune
vi /sdcard/bash_profile
// add the line below as the last line of the file
/system/bin/fortune
If you want the offensive fortunes, give "-o" as argument to fortune, in the last line.
Observations
a) It works with English only I believe, since I had to disable internationalization to get it to compile (no support in NDK for this).
b) I've only tested it on my X10, but I'm very curious if it works on other phones too so please let me know!
For geeks only!

[UPDATE 2/12/2010] Terminal IDE - Full 'on device' Java / Android IDE

[UPDATE]
BusyBox 1.19.2
Bash 4.2
Midnight Commander 4.8
TMUX 1.5 - That's right, full terminal multiplexer..
Vim 7.3
Terminal IDE ASCII Soft keyboard first round bug fixes complete.
It's the addition of TMUX and MC that really excites..
--------------------------
Well,
As the only people I know who might even be interested in this, I would like to announce the release of Terminal IDE v1.0.
A complete Java / Android Development Environment that runs on the device itself, with a nice telnetd / sshd feature.
For Android. Of course... Eat this you IPhone Hounds..
Woo HOO!!
The application is available on Android Market.
https://market.android.com/details?id=com.spartacusrex.spartacuside
As what I can only describe as 'dark days' finally draw to an end, I am very pleased with this first draft.
PLEASE give it a go, log in over telnet for a smoother ride, and let me know how it goes..
DO THE TUTORIAL! Does it work ?!
I have released the whole project GPLv2! Yeah, Who Knew!?
http://code.google.com/p/terminal-ide/
BOOOOOM!
Spartacus
a link to the app in the market would be usefull.
Interesting. Was just wondering about coding on my tablet.
Pretty freakin sweet
Thanks for putting this out!
Awesome
The full keyboard alone makes it worth downloading, but the IDE as well - wow!
this is best bro.
I randomly found this last night while looking for a decent mobile IDE for my tablet. I was looking for a simple text editor with syntax highlighting and you've taken that extra step to include other tools for ssh, telnet and compilers. Much appreciated.
One question, how do you start the ssh server? sshd doesn't seem to do it. I would like to scp files to my device from my desktop in order to work on my commute.
Thanks
The sshd app is actually called Dropbear.
You also have Dropbearkey.
You use Dropbearkey to generate the sshd certificates you need.
I really need to add a tutorial on setting the sshd keys up
For now Google has a couple of articles on it.
For file transfers you also have busybox FTP but I admit not terribley secure..
Allthough SSH is provided, and I wonder whether an SSH pipe can be created..?
And lastly you can just copy the files over to your sdcard via USB..
Will look into it & add tutorials asap.
Ok. So I now have SSHD working..
But there is a slight issue.. basically when you log in you have to start bash manually.. unless you have the file /etc/shell with the correct shell to use.. Which requires a rooted phone.
Since Terminal IDE is for non-ROOT users, I will have to recompile the code to allow a shell to be specified on the command line.. Soon..
FOR NOW - This is how to connect to the phone via SSH (There are other ways using public keys but this is one way)
So - Once in Terminal IDE
2) You need to create a couple of server ssh keys
Start in $HOME
Code:
cd ~
Create folder
Code:
mkdir .ssh
Give it some secure permissions
Code:
chmod 700 .ssh
Get in there
Code:
cd .ssh
Now create the keys
Code:
dropbearkey -t dss -f dropbear_dss_host_key
dropbearkey -t rsa -f dropbear_rsa_host_key
ok - That's almost it. Just need to start dropbear with the correct parameters now. [Probably want to keep this in a script]
Back HOME
Code:
cd ~
You need to know the UID of your app, which is different per phone - use 'id'
Code:
id
That will tell you your user ID / Group ID. Let's say its 10058.
Now to start DropBear
Code:
dropbear -A -N username -U 10058 -G 10058 -C password -d ~/.ssh/dropbear_dss_host_key -r ~/.ssh/dropbear_rsa_host_key -F -E -p 8090 -P PidFile
This will start it running in the foreground with password set to 'password' on port 8090.
Then you can connect, like telnet, and simply use 'password' for the password.
Now for the issue. It will start a simple shell session in / with no ENVIRONMENT variables or anything..
I'll fix it permanently in a future release, but for now it can be fixed with these 2 commands.
cd into your home dir - Check this is correct on your device
Code:
cd /data/data/com.spartacusrex.spartacuside/files
And start bash with an init file Terminal IDE auto-magically creates..
Code:
./system/bin/bash --init-file ./.init
Everything should now be setup as usual.
Good luck..
Very awesome and thank you sir. Works like a charm.
One thing to clarify for those "braving" this (not that it's all that insane to try)... the '-N' is setting the username (in the case of the example, setting it to 'username').
Also, it gives a permission denied for scp, I'm assuming since it doesn't init/run the shell. Should be fine since FTP is included. Haven't tried this option yet. Not too worried about security at the moment, since I'll only run it on a private network.
May I make a (maybe) small feature request? Is it possible to include a "keep screen awake" option in the options menu? I have my Xoom config'd to turn off the wifi when the screen is off for power saving (can go ~4 days on 1 charge), so it will kill my connections if I let this happen. I know not everyone has this config set, but it'd be a nice option.
NOW, if I wasn't lazy, I could probably add this myself and build since I've dl'd the source. But, lazy and working on a few projects already.
Again, much thanks.
And as if by magic..
Funnily enough I was having the exact same issue last night while using wget to transfer a big file to my device..
NEW VERSION UPLOADED v1.13
Now has 3 non-exclusive lock types available in the options :
- CPU Lock
- SCREEN Lock
- WIFI Lock
Set them as you wish...
Saw that this morning when I was on the bus (Thursday morning here in Hong Kong). Very awesome and much appreciated.
As well, thanks for open-sourcing it. +1 for you sir!
Very cool stuff
Thanks for creating this.
Great app! However I can't compile .java files. I always get an error that it can't unzip a file in /android.policy.jar. Any idea?
Sent from my GT-I9100 using XDA App
Do you think its possible to also support compiling C sources directly in your phone
I've been searching for this ever since I got an android.
THANK YOU.
Says that it's incompatible with my OG Droid. Any idea why?
shpen said:
Says that it's incompatible with my OG Droid. Any idea why?
Click to expand...
Click to collapse
Most likely seems to be due to the ROM you are using and/or the market version
can u post the build.prop here?
/system/build.prop
also, try going back to market 2.x, 3.x market(s) do loads of checks
Does anybody know why I can't compile java files? I always get the following error:
Error reading /system/framework/android_policy.jar cannot read zip file.
Any ideas? Could anyone upload there android_policy.jar because that might cause the error.
Sent from my GT-I9100 using XDA App
Hi Schindler33.
Can I ask, have you followed the tutorials, say the first helloworld example TO THE LETTER?
Does the helloworld example work?
The parameters have to be correct, and as always exact, and the BOOTCLASSPATH variable must be set.
If so, is it a custom ROM?
Does that policy jar file exist and is it readable by non root users?
As much info as possible good..

[Guide] Compiling dropbear 2015.67

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

Kotlin app can't find file even though it exists

I'm working on a Kotlin app where I need to access the Cookies file located at /data/data/com.android.chrome/app_chrome/Default/Cookies. However, when I try to access the file, I get a "file not found" error, even though the file definitely exists at that location.
I've double-checked the file path and made sure there are no typos (I can see the file with adb shell and Amaze File Manager), and I've also checked that the app has permission to access the file (app has root permissions).
First I was trying to open and read the file directly and I got the error:
CODE at https://stackoverflow.com/questions/76064385/kotlin-app-cant-find-file-even-though-it-exists
I though maybe Chrome was running so I couldn't open the file directly so I tried copying it to a temp folder and reading that:
CODE at https://stackoverflow.com/questions/76064385/kotlin-app-cant-find-file-even-though-it-exists
But that still fails:
CODE at https://stackoverflow.com/questions/76064385/kotlin-app-cant-find-file-even-though-it-exists
Is there anything else I can try to troubleshoot this issue?
Something in the code triggers cloudflare and blocks me from posting
Code:
Sorry, you have been blocked
You are unable to access xda-developers.com
Why have I been blocked?
This website is using a security service to protect itself from online attacks. The action you just performed triggered the security solution. There are several actions that could trigger this block including submitting a certain word or phrase, a SQL command or malformed data.
What can I do to resolve this?
You can email the site owner to let them know you were blocked. Please include what you were doing when this page came up and the Cloudflare Ray ID found at the bottom of this page.
Cloudflare Ray ID: 7badda7c6b9486c6 • Your IP: Click to reveal • Performance & security by Cloudflare
SQLite definitely won't open the file. So, your decision to copy it was right.
Firstly, try to split the single command string into an array.
The documentation for ProcessBuilder class has an example:
ProcessBuilder pb = new ProcessBuilder("myCommand", "myArg1", "myArg2");
Or try to use SuFile from the libsu, for example:
AndroidIDeditor/Util.java at 6a62bac0e3e63502e9a7b538217f65189ff85fa4 · sdex/AndroidIDeditor
Android Device ID changer. Contribute to sdex/AndroidIDeditor development by creating an account on GitHub.
github.com
lioce said:
SQLite definitely won't open the file. So, your decision to copy it was right.
Firstly, try to split the single command string into an array.
The documentation for ProcessBuilder class has an example:
ProcessBuilder pb = new ProcessBuilder("myCommand", "myArg1", "myArg2");
Or try to use SuFile from the libsu, for example:
AndroidIDeditor/Util.java at 6a62bac0e3e63502e9a7b538217f65189ff85fa4 · sdex/AndroidIDeditor
Android Device ID changer. Contribute to sdex/AndroidIDeditor development by creating an account on GitHub.
github.com
Click to expand...
Click to collapse
Seems like not even like that can I read the Cookies file from Chrome
Code:
fun copyFile(source: String, destination: String) {
Log.d("CookieSwapLogger", "copyFile '$source' to '$destination'")
val sourceFile = SuFile(source)
if (sourceFile.exists()) {
Log.d("CookieSwapLogger", "sourceFile.exists")
} else {
Log.d("CookieSwapLogger", "sourceFile.notExists")
}
---------------
2023-04-21 18:20:47.440 6347-6347 CookieSwapLogger com.david.cookieswapper D copyFile '/data/data/com.android.chrome/app_chrome/Default/Cookies' to '/data/user/0/com.david.cookieswapper/app_temp/Cookies'
2023-04-21 18:20:47.492 6347-6347 CookieSwapLogger com.david.cookieswapper D sourceFile.notExists

Categories

Resources