GithubHelp home page GithubHelp logo

pylibemu's Issues

Error trying to install, same error using pip and manual install

Hello,

I am trying to install the program and have tried both pip install pylibemu and also using the files recursively grabbed from git and I am getting the following error and could use some help.

Package libemu was not found in the pkg-config search path.
Perhaps you should add the directory containing `libemu.pc'
to the PKG_CONFIG_PATH environment variable
No package 'libemu' found

Now I have looked for the file libemu.pc and I cannot seem to find it in this git. Can anyone assist me?

Disassemble eip

With current pylibemu, Is it possible to disassemble eip (to assembly)?

Error with install: autoreconf fails to run aclocal

This is on macOS High Sierra (10.13.6). The initial issue was an install error with "pip install thug" the error was for the pylibemu dependency. I wasn't sure if there was a better place to report this error or seek assistance. Can someone please advise on how I might be able to fix this error? Thanks in advance!

Steps taken:
sudo git clone --recursive https://github.com/buffer/pylibemu.git
sudo python setup.py install

Output (Error):

running install
running build
running build_clib
running 'autoreconf -v -i -f' for library 'emu'
autoreconf: Entering directory `.'
autoreconf: configure.ac: not using Gettext
autoreconf: running: aclocal --output=aclocal.m4t
Can't exec "aclocal": No such file or directory at /usr/local/Cellar/autoconf/2.69/share/autoconf/Autom4te/FileUtils.pm line 326.
autoreconf: failed to run aclocal: No such file or directory
Traceback (most recent call last):
File "setup.py", line 244, in
libraries = ["emu"]
File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/distutils/core.py", line 151, in setup
dist.run_commands()
File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/distutils/dist.py", line 953, in run_commands
self.run_command(cmd)
File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/distutils/dist.py", line 972, in run_command
cmd_obj.run()
File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/distutils/command/install.py", line 573, in run
self.run_command('build')
File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/distutils/cmd.py", line 326, in run_command
self.distribution.run_command(command)
File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/distutils/dist.py", line 972, in run_command
cmd_obj.run()
File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/distutils/command/build.py", line 127, in run
self.run_command(cmd_name)
File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/distutils/cmd.py", line 326, in run_command
self.distribution.run_command(command)
File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/distutils/dist.py", line 971, in run_command
cmd_obj.ensure_finalized()
File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/distutils/cmd.py", line 109, in ensure_finalized
self.finalize_options()
File "setup.py", line 88, in finalize_options
check_call(['autoreconf', '-v', '-i', '-f'], cwd = build_info['local_source'], env = env)
File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/subprocess.py", line 540, in check_call
raise CalledProcessError(retcode, cmd)
subprocess.CalledProcessError: Command '['autoreconf', '-v', '-i', '-f']' returned non-zero exit status 1

pylibemu and pyqt4

Hi.

About 3 weeks ago I had a problem with dumping the result of the emulator into my GUI which I created using PyQt4.

Now, with the modified pylibemu, my problem was solved. Here's what I did.

def runShellcode(shellcode):

emulator = Emulator()
text = ""
    shellcode=str(shellcode)

    if shellcode == "":
        return "Empty Field. Please enter shellcode."

    shellcode = shellcode.decode("hex")

emulator.new()
    offset = emulator.shellcode_getpc_test(shellcode)
    if offset < 0:
        offset = 0

    text += "Offset: " + str(offset) +"\n"
    emulator.prepare(shellcode, offset)
emulator.test()
text += emulator.emu_profile_output
    emulator.free()
return text

The emulated shellcode appears perfectly on my GUI. :)

Memory leaks in emulator memory

These are issues not related to my previous PR.

It appears that a small amount of memory is leaking when running tests/cpu_mem_test.py which can be identified with valgrind in the following functions:

  • memory_read_string
  • memory_read_block

I have not identified a fix for these at this time.

Seg fault for memory read

Always got Segmentation fault (core dumped) for function
memory_read_byte,
memory_read_dword,
memory_read_word
memory_read_string

This is how I call the function:
print _emu.memory_read_byte(address)

running python 2.7.3 on ubuntu 12.04

Compilation errors

Hello,

It seems the folder emu/ is not pressent and is producing errors in the compilation build:

felmoltor@kali:~/pylibemu$ sudo python setup.py build
running build
running build_ext
building 'pylibemu' extension
gcc -pthread -fno-strict-aliasing -DNDEBUG -g -fwrapv -O2 -Wall -Wstrict-prototypes -fPIC -I/opt/libemu/include -I/usr/include/python2.7 -c src/pylibemu.c -o build/temp.linux-x86_64-2.7/src/pylibemu.o
src/pylibemu.c:319:28: fatal error: emu/emu_string.h: No such file or directory
compilation terminated.
error: command 'gcc' failed with exit status 1

Could you check it?

Thanks.

error: command 'gcc' failed with exit status 1

Hello,

I have a question for pylibemu.

[environment]--------------------------------------------------------------------------------------------------//
Ubuntu 10.10 Desktop

ga9amel@azrael:~$ uname -a
Linux azrael 2.6.35-28-generic #50-Ubuntu SMP Fri Mar 18 19:00:26 UTC 2011 i686 GNU/Linux

ga9amel@azrael:~$ python -V
Python 2.6.6

ga9amel@azrael:$ sudo apt-get install libtool
ga9amel@azrael:
$ sudo apt-get install autoreconf
ga9amel@azrael:$ git clone git://git.carnivore.it/libemu.git
ga9amel@azrael:
$ cd libemu
ga9amel@azrael:$ autoreconf -v -i
ga9amel@azrael:
$ ./configure --prefix=/opt/libemu
ga9amel@azrael:~$ sudo make install
--------------------------------------------------------------------------------------------------//
I don't know why do i get error...

ga9amel@azrael:~/buffer-pylibemu-4483b0a$ python setup.py build
running build
running build_ext
building 'pylibemu' extension
gcc -pthread -fno-strict-aliasing -DNDEBUG -g -fwrapv -O2 -Wall -Wstrict-prototypes -fPIC -I/opt/libemu/include -I/usr/include/python2.6 -c src/pylibemu.c -o build/temp.linux-i686-2.6/src/pylibemu.o
src/pylibemu.c:1942:157: macro "strncat" passed 4 arguments, but takes just 3
src/pylibemu.c: In function __pyx_f_8pylibemu_10EmuProfile_build_sep': src/pylibemu.c:1942: warning: assignment from incompatible pointer type src/pylibemu.c:2008:177: macro "strncat" passed 4 arguments, but takes just 3 src/pylibemu.c: In function__pyx_f_8pylibemu_10EmuProfile_log_function_header':
src/pylibemu.c:2008: warning: assignment from incompatible pointer type
src/pylibemu.c:2054:171: macro "strncat" passed 4 arguments, but takes just 3
src/pylibemu.c: In function __pyx_f_8pylibemu_10EmuProfile_log_bracket_closed': src/pylibemu.c:2054: warning: assignment from incompatible pointer type src/pylibemu.c:2099:177: macro "strncat" passed 4 arguments, but takes just 3 src/pylibemu.c: In function__pyx_f_8pylibemu_10EmuProfile_log_array_start':
src/pylibemu.c:2099: warning: assignment from incompatible pointer type
src/pylibemu.c:2144:177: macro "strncat" passed 4 arguments, but takes just 3
src/pylibemu.c: In function __pyx_f_8pylibemu_10EmuProfile_log_array_end': src/pylibemu.c:2144: warning: assignment from incompatible pointer type src/pylibemu.c:2189:177: macro "strncat" passed 4 arguments, but takes just 3 src/pylibemu.c: In function__pyx_f_8pylibemu_10EmuProfile_log_struct_start':
src/pylibemu.c:2189: warning: assignment from incompatible pointer type
src/pylibemu.c:2234:177: macro "strncat" passed 4 arguments, but takes just 3
src/pylibemu.c: In function __pyx_f_8pylibemu_10EmuProfile_log_struct_end': src/pylibemu.c:2234: warning: assignment from incompatible pointer type src/pylibemu.c:2279:177: macro "strncat" passed 4 arguments, but takes just 3 src/pylibemu.c: In function__pyx_f_8pylibemu_10EmuProfile_emu_profile_argument_render_int':
src/pylibemu.c:2279: warning: assignment from incompatible pointer type
src/pylibemu.c:2324:177: macro "strncat" passed 4 arguments, but takes just 3
src/pylibemu.c: In function __pyx_f_8pylibemu_10EmuProfile_emu_profile_argument_render_string': src/pylibemu.c:2324: warning: assignment from incompatible pointer type src/pylibemu.c:2369:177: macro "strncat" passed 4 arguments, but takes just 3 src/pylibemu.c: In function__pyx_f_8pylibemu_10EmuProfile_emu_profile_argument_render_bytea':
src/pylibemu.c:2369: warning: assignment from incompatible pointer type
src/pylibemu.c:2437:177: macro "strncat" passed 4 arguments, but takes just 3
src/pylibemu.c: In function __pyx_f_8pylibemu_10EmuProfile_emu_profile_argument_render_ptr': src/pylibemu.c:2437: warning: assignment from incompatible pointer type src/pylibemu.c:2502:177: macro "strncat" passed 4 arguments, but takes just 3 src/pylibemu.c: In function__pyx_f_8pylibemu_10EmuProfile_emu_profile_argument_render_ip':
src/pylibemu.c:2502: warning: assignment from incompatible pointer type
src/pylibemu.c:2557:177: macro "strncat" passed 4 arguments, but takes just 3
src/pylibemu.c: In function __pyx_f_8pylibemu_10EmuProfile_emu_profile_argument_render_port': src/pylibemu.c:2557: warning: assignment from incompatible pointer type src/pylibemu.c:2602:177: macro "strncat" passed 4 arguments, but takes just 3 src/pylibemu.c: In function__pyx_f_8pylibemu_10EmuProfile_emu_profile_argument_render_none':
src/pylibemu.c:2602: warning: assignment from incompatible pointer type
src/pylibemu.c:2677:177: macro "strncat" passed 4 arguments, but takes just 3
src/pylibemu.c: In function __pyx_f_8pylibemu_10EmuProfile_emu_profile_function_render_int': src/pylibemu.c:2677: warning: assignment from incompatible pointer type src/pylibemu.c:2722:177: macro "strncat" passed 4 arguments, but takes just 3 src/pylibemu.c: In function__pyx_f_8pylibemu_10EmuProfile_emu_profile_function_render_ptr':
src/pylibemu.c:2722: warning: assignment from incompatible pointer type
error: command 'gcc' failed with exit status 1

problems with setup.py

Hello,
I have problems with setup.py.. what am I doing wrong?

running install
running build
running build_clib
running 'autoreconf -v -i -f' for library 'emu'
autoreconf: 'configure.ac' or 'configure.in' is required

method implementation request

Hi,
This is requesting to add new method to class Emulator.
These method will allow me execute shellcode without depending on test(steps) function.

def create_new_env(self):
    self._env = emu_env_new(self._emu)
    self._env.profile = emu_profile_new()


def env_linux_syscall_check_using_class_env(self):
    if self._env is NULL:
        print emu_strerror(self._emu)
        raise RuntimeError('Emulator environment error')

    #  hook = emu_env_linux_syscall_check(_env)
    if emu_env_linux_syscall_check(self._env) is NULL:
        return False

    return True

With above method, the shellcode can be emulate as follow:

    emu.create_new_env()

    for x in range (12):
        if emu.env_w32_hook_check_using_class_env() == True:
            print " eip is a hook function",
        else:
            emu.cpu_debugflag_set(1)
            ret = emu.cpu_parse()
            emu.cpu_debugflag_unset(1)
            if ret != -1:
                instr = emu.cpu_get_cpu_instr_string()
                print instr

                emu.cpu_step()
            else:
                x = "break"

Issue on env_w32_hook_check

emu_profile_output() result will be flush out if call env_w32_hook_check().

---code begin-----------
01 import pylibemu
02
03 emu = pylibemu.Emulator()
04 '''
05 00000000 B8 6D 13 86 7C mov eax, 0x7C86136D
06 00000005 FF D0 call eax
07 00000007 31 C0 xor eax, eax
08 '''
09 emu.prepare('\xb8\x6d\x13\x86\x7c\xff\xd0\x31\xc0', 0)
10
11 for x in range(1,3):
12 print "eip:", hex(emu.cpu_eip_get())
13 emu.test(1)
14 print x, ') EMU PROFILE OUTPUT:'
15 print emu.emu_profile_output
16
17 #emu.env_w32_hook_check()
18 print "eip:", hex(emu.cpu_eip_get())
19 emu.test(1)
20 print x, ') EMU PROFILE OUTPUT:'
21 print emu.emu_profile_output
-----code end-----------

--------------output-begin---------
eip: 0x417000L
1 ) EMU PROFILE OUTPUT:

eip: 0x417005L
2 ) EMU PROFILE OUTPUT:

eip: 0x7c86136dL
2 ) EMU PROFILE OUTPUT:
UINT WINAPI WinExec (
LPCSTR = 0x01543340 =>
= "";
UINT uCmdShow = 835780476;
) = 32;
---------------output--end--------

Try to uncomment line 17 '#emu.env_w32_hook_check()'.
You will find emu_profile_output result is empty.

test function is quit expensive

Hi,

currently, my work need me to call test repeatedly
for i in range(x):
   #do something
   pylibemu.Emulator().test(1)
   #continue do something

if x less than 5000, its working fine. But when x getting bigger, such as 1000000, my whole desktop freeze :)

looking at test() implementation, it seem quite expensive.
Is it possible to expose/wrap all needed variable to allow my code instrument emu_cpu_parse() and emu_cpu_step() so it wont using the built in function test()?

or if possible add callback function in test(), so I can execute my function in each loop before execute emu_cpu_step().

cannot open shared object file

root@bt:/Desktop/pylibemu-master# python setup.py build
running build
running build_ext
building 'pylibemu' extension
creating build
creating build/temp.linux-i686-2.6
creating build/temp.linux-i686-2.6/src
gcc -pthread -fno-strict-aliasing -DNDEBUG -g -fwrapv -O2 -Wall -Wstrict-prototypes -fPIC -I/opt/libemu/include -I/usr/include/python2.6 -c src/pylibemu.c -o build/temp.linux-i686-2.6/src/pylibemu.o
creating build/lib.linux-i686-2.6
gcc -pthread -shared -Wl,-O1 -Wl,-Bsymbolic-functions build/temp.linux-i686-2.6/src/pylibemu.o -L/opt/libemu/lib -lemu -o build/lib.linux-i686-2.6/pylibemu.so
root@bt:
/Desktop/pylibemu-master# python setup.py install
running install
running build
running build_ext
running install_lib
copying build/lib.linux-i686-2.6/pylibemu.so -> /usr/local/lib/python2.6/dist-packages
running install_egg_info
Writing /usr/local/lib/python2.6/dist-packages/pylibemu-0.2.6.egg-info
root@bt:~/Desktop/pylibemu-master# python
Python 2.6.5 (r265:79063, Apr 16 2010, 13:09:56)
[GCC 4.4.3] on linux2
Type "help", "copyright", "credits" or "license" for more information.

import pylibemu
Traceback (most recent call last):
File "", line 1, in
ImportError: libemu.so.2: cannot open shared object file: No such file or directory
import pylibemu;
Traceback (most recent call last):
File "", line 1, in
ImportError: libemu.so.2: cannot open shared object file: No such file or directory

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.