Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[bug] Python Crashes when attaching udb to AndroidNativeEmu #8

Open
CypherpunkSamurai opened this issue Jun 29, 2022 · 10 comments
Open

Comments

@CypherpunkSamurai
Copy link

So, I'm trying to use udbserver with AndroidNativeEmu (androidemu) on Windows, with Python 3.7.

I have the following code:

import logging
import posixpath
import sys

from unicorn import UcError, UC_HOOK_MEM_UNMAPPED, UC_HOOK_CODE, UC_HOOK_MEM_READ, UC_HOOK_MEM_WRITE
from unicorn.arm_const import *


import sys
sys.path.append("emulator") # Adds higher directory to python modules path.
# for loading changed module

from androidemu.emulator import Emulator
from androidemu.java.java_class_def import JavaClassDef
from androidemu.java.java_method_def import java_method_def

from udbserver import udbserver

# .............................. Code here ..................................

emulator.uc.hook_add(UC_HOOK_MEM_UNMAPPED, debug_utils.hook_unmapped)

# Register Java class.
emulator.java_classloader.add_class(EncryptorUtil)

# Load all libraries.
emulator.load_library("emulator/libdl.so")
emulator.load_library("emulator/libc.so")
emulator.load_library("emulator/libstdc++.so")
emulator.load_library("emulator/libm.so")

lib_module = emulator.load_library("emulator/libEncryptor.so")

# ......................... Code Here ........................
udbserver(emulator.uc, 1337, 0xcbbd2dec)

and Python crashes and stops working as soon as line udbserver(emulator.uc, 1337, 0xcbbd2dec) is run.

Is there any reason for this? also, what is 0xcbbd2dec here, am i supposed to use it according to my library?

@bet4it
Copy link
Owner

bet4it commented Jun 29, 2022

Do you use the git version of udbserver? I fixed a bug mentioned in #5, which looks like what you describe.

@CypherpunkSamurai
Copy link
Author

Do you use the git version of udbserver? I fixed a bug mentioned in #5, which looks like what you describe.

Yes. I compiled by cloning the repo from most recent commit (commit 96cca70).

@bet4it
Copy link
Owner

bet4it commented Jun 29, 2022

What about udbserver(emulator.uc, 1337, 0)?

@CypherpunkSamurai
Copy link
Author

Still crashes.

@bet4it
Copy link
Owner

bet4it commented Jun 29, 2022

Oh you may need to debug it by yourself😅

@CypherpunkSamurai
Copy link
Author

How can i know why it's segfaulting like the other person? 😄

@CypherpunkSamurai
Copy link
Author

CypherpunkSamurai commented Jun 29, 2022

MSVC Debugger gives the following message:
Unhandled exception at 0x00007FFD5A3CBCA0 (unicorn.dll) in python.exe: 0xC0000005: Access violation reading location 0x0000000000000001.

Callstack:

>	unicorn.dll!00007ffd5a3cbca0()	Unknown
 	libunicorn.dll!00007ffd58bd6346()	Unknown
 	libunicorn.dll!00007ffd58bd4d5c()	Unknown
 	udbserver.dll!00007ffd5af0b61c()	Unknown
 	udbserver.dll!00007ffd5aeff771()	Unknown
 	udbserver.cp37-win_amd64.pyd!00007ffd6c4d1626()	Unknown

@bet4it
Copy link
Owner

bet4it commented Jun 30, 2022

Can example.py work?

@CypherpunkSamurai
Copy link
Author

No. It's crashing as well.

@bet4it
Copy link
Owner

bet4it commented Mar 6, 2024

Could you try this?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants