vbuell / python-javaobj Goto Github PK
View Code? Open in Web Editor NEWpython-javaobj is a python library that provides functions for reading of Java objects serialized ObjectOutputStream.
License: Apache License 2.0
python-javaobj is a python library that provides functions for reading of Java objects serialized ObjectOutputStream.
License: Apache License 2.0
Bugfix (python 2.7):
File "javaobj.py", line 36, in load
return marshaller.readObject()
File "javaobj.py", line 194, in readObject
self._oops_dump_state()
File "javaobj.py", line 485, in _oops_dump_state
self.object_stream.seek(-16, mode=1)
TypeError: seek() takes no keyword arguments
Original issue reported on code.google.com by [email protected]
on 16 Nov 2011 at 2:28
Attachments:
What is the expected output? What do you see instead?
The output that I expect is deserialize java object that is serialized by Java
ObjectOutputStream and read from the socket by socket python method. recv
I see this error:
No handlers could be found for logger "javaobj"
Traceback (most recent call last):
File "/home/aledani85/workspace/tesiinf2/src/cspackage/ClientSock.py", line 28, in <module>
stringa=javaobj.loads(pippo)
File "/home/aledani85/Scaricati/javaobj-0.1.0-py2.6.egg/javaobj.py", line 45, in loads
File "/home/aledani85/Scaricati/javaobj-0.1.0-py2.6.egg/javaobj.py", line 159, in readObject
File "/home/aledani85/Scaricati/javaobj-0.1.0-py2.6.egg/javaobj.py", line 181, in _read_and_exec_opcode
File "/home/aledani85/Scaricati/javaobj-0.1.0-py2.6.egg/javaobj.py", line 190, in _readStruct
struct.error: unpack requires a string argument of length 1
What version of the product are you using? On what operating system?
The version used is:0.1.0.The operating system is Ubuntu karmic 8.04
Please provide any additional information below.
is possible using this form deserialize Java objects into python objects? I
will have to pass along a serialized Java objects form python.This form must
then serialize the object before bed to send a second Java class which will
read the object.
Thanks for the help. Congratulations on this very interesting form.
Original issue reported on code.google.com by [email protected]
on 1 Apr 2011 at 4:06
Attachments:
Only instance of 0x7a in my input (sorry I can't supply full sample):
0000030: 6465 828f ef98 c366 2308 0c00 0078 707a
Any advice on how to implement un-implemented opcodes?
Full trace:
File "javaobj.py", line 36, in load
return marshaller.readObject()
File "javaobj.py", line 181, in readObject
opcode, res = self._read_and_exec_opcode(ident=0) # TODO: add expects
File "javaobj.py", line 213, in _read_and_exec_opcode
return (opid, handler(ident=ident))
File "javaobj.py", line 365, in do_object
opcode, obj = self._read_and_exec_opcode(ident=ident+1) # , expect=[self.TC_ENDBLOCKDATA, self.TC_BLOCKDATA, self.TC_OBJECT, self.TC_NULL, self.TC_REFERENCE])
File "javaobj.py", line 212, in _read_and_exec_opcode
raise RuntimeError("Unknown OpCode in the stream: 0x%x" % opid)
RuntimeError: Unknown OpCode in the stream: 0x7a
Original issue reported on code.google.com by [email protected]
on 16 Nov 2011 at 3:20
This is a pretty good library, but it doesn't seem to work with objects serialised by Java 11 (openjdk 11.0.6), I get the error: ValueError: Invalid file magic: 0x696d
.
This is happening at an instruction like: pobj = javaobj.load ( fd )
, using Python 3.8.
import javaobj
with open("/Users/0x101/safe/mytools_10012106/pwnjvm/test/8848.bin", "rb") as fd:
jobj = fd.read()
pobj = javaobj.loads(jobj)
print(pobj)
python test.py
Traceback (most recent call last):
File "test.py", line 5, in <module>
pobj = javaobj.loads(jobj)
File "/usr/local/lib/python2.7/site-packages/javaobj.py", line 44, in loads
marshaller = JavaObjectUnmarshaller(f)
File "/usr/local/lib/python2.7/site-packages/javaobj.py", line 155, in __init__
self._readStreamHeader()
File "/usr/local/lib/python2.7/site-packages/javaobj.py", line 178, in _readStreamHeader
raise IOError("The stream is not java serialized object. Invalid stream header: %04X%04X" % (magic, version))
IOError: The stream is not java serialized object. Invalid stream header: ACED0573
A simple fix is prepending the standard serialization header: 0xaced0005. The output files I'm seeing created with JavaObjectMarashaller
are missing this header.
I Have a 10 Years old Java Client/Server application which communicate via
serialized JavaObj. My first problem is that my network dumps have no
STREAM_MAGIC + STREAM_VERSION. Further it includes TC_RESET bytes which seems
to be not supported by your module.
Would it be possible to add it or just tell me how to do it simply?
Here is my example dump:
y s r j a v a . l a n g . I n t e g e r �
� � � � � 8
I v a l u e x r j a v a . l a n g . N u m b e r � � �
� � � x p y t s u c c e s s y
79:73:72:00:11:6a:61:76 61:2e:6c:61:6e:67:2e:49 6e:74:65:67:65:72:12:e2
a0:a4:f7:81:87:38:02:00
01:49:00:05:76:61:6c:75 65:78:72:00:10:6a:61:76 61:2e:6c:61:6e:67:2e:4e
75:6d:62:65:72:86:ac:95
1d:0b:94:e0:8b:02:00:00 78:70:00:00:00:01:79:74 00:07:73:75:63:63:65:73 73:79
Thanks
Frank
Original issue reported on code.google.com by [email protected]
on 13 Sep 2013 at 1:21
Attachments:
In Java I create an ArrayList of two Integers, e.g.,
List<Integer> data = new ArrayList<>();
data.add(1)
data.add(2)
which serializes to
b'\xac\xed\x00\x05sr\x00\x13java.util.ArrayListx\x81\xd2\x1d\x99\xc7a\x9d\x03\x00\x01I\x00\x04sizexp\x00\x00\x00\x02w\x04\x00\x00\x00\x02sr\x00\x11java.lang.Integer\x12\xe2\xa0\xa4\xf7\x81\x878\x02\x00\x01I\x00\x05valuexr\x00\x10java.lang.Number\x86\xac\x95\x1d\x0b\x94\xe0\x8b\x02\x00\x00xp\x00\x00\x00\x01sq\x00~\x00\x02\x00\x00\x00\x02x'
javaobj.loads(bytes)
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "javaobj.py", line 190, in loads
ignore_remaining_data=ignore_remaining_data)
File "javaobj.py", line 171, in load
return marshaller.readObject(ignore_remaining_data=ignore_remaining_data)
File "javaobj.py", line 501, in readObject
_, res = self._read_and_exec_opcode(ident=0)
File "javaobj.py", line 568, in _read_and_exec_opcode
return opid, handler(ident=ident)
File "javaobj.py", line 833, in do_object
opcode, obj = self._read_and_exec_opcode(ident=ident + 1)
File "javaobj.py", line 564, in _read_and_exec_opcode
.format(opid, position))
RuntimeError: Unknown OpCode in the stream: 0x0 (at offset 0x8C)
If I only have one integer in the list then it loads fine. I have the problem with Doubles as well as Integers. Strings seem to work fine though.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.