ernw / python-wcfbin Goto Github PK
View Code? Open in Web Editor NEWA python library for converting between WCF binary xml and plain xml.
License: BSD 3-Clause "New" or "Revised" License
A python library for converting between WCF binary xml and plain xml.
License: BSD 3-Clause "New" or "Revised" License
This change: bc3b32e
Due to Python Issue 19099, struck.pack
can't handle string objects other than native str
properly until Python 2.7.7. So if you want to be compatible with all versions of Python 2.7, you'd better use struct.unpack(b'<BBB', fp.read(3))
instead of struct.unpack('<BBB', fp.read(3))
.
I use your project to communicate with Microsoft servers, it works fine except when using Serialization/Arrays :
<s:Envelope xmlns:s="http://www.w3.org/2003/05/soap-envelope" xmlns:a="http://www.w3.org/2005/08/addressing">
<s:Header>
<a:Action s:mustUnderstand="1">http://schemas.microsoft.com/online/aws/change/2010/01/IProvisioningWebService/ProvisionAzureADSyncObjects</a:Action>
<SyncToken s:role="urn:microsoft.online.administrativeservice" xmlns="urn:microsoft.online.administrativeservice" xmlns:i="http://www.w3.org/2001/XMLSchema-instance">
<ApplicationId xmlns="http://schemas.microsoft.com/online/aws/change/2010/01">1651564e-7ce4-4d99-88be-0a65050d8dc3</ApplicationId>
<BearerToken xmlns="http://schemas.microsoft.com/online/aws/change/2010/01">token</BearerToken>
<ClientVersion xmlns="http://schemas.microsoft.com/online/aws/change/2010/01">8.0</ClientVersion>
<DirSyncBuildNumber xmlns="http://schemas.microsoft.com/online/aws/change/2010/01">1.5.29.0</DirSyncBuildNumber>
<FIMBuildNumber xmlns="http://schemas.microsoft.com/online/aws/change/2010/01">1.5.29.0</FIMBuildNumber>
<IsInstalledOnDC xmlns="http://schemas.microsoft.com/online/aws/change/2010/01">False</IsInstalledOnDC>
<IssueDateTime xmlns="http://schemas.microsoft.com/online/aws/change/2010/01">0001-01-01T00:00:00</IssueDateTime>
<LanguageId xmlns="http://schemas.microsoft.com/online/aws/change/2010/01">en-US</LanguageId>
<LiveToken xmlns="http://schemas.microsoft.com/online/aws/change/2010/01"/>
<ProtocolVersion xmlns="http://schemas.microsoft.com/online/aws/change/2010/01">2.0</ProtocolVersion>
<RichCoexistenceEnabled xmlns="http://schemas.microsoft.com/online/aws/change/2010/01">False</RichCoexistenceEnabled>
<TrackingId xmlns="http://schemas.microsoft.com/online/aws/change/2010/01">da890d67-152c-498a-8272-a4b5fbf1c023</TrackingId>
</SyncToken>
<a:MessageID>urn:uuid:da890d67-152c-498a-8272-a4b5fbf1c023</a:MessageID>
<a:ReplyTo>
<a:Address>http://www.w3.org/2005/08/addressing/anonymous</a:Address>
</a:ReplyTo>
<a:To s:mustUnderstand="1">https://adminwebservice.microsoftonline.com/provisioningservice.svc</a:To>
</s:Header>
<s:Body>
<ProvisionAzureADSyncObjects xmlns="http://schemas.microsoft.com/online/aws/change/2010/01">
<syncRequest xmlns:b="http://schemas.microsoft.com/online/aws/change/2014/06" xmlns:i="http://www.w3.org/2001/XMLSchema-instance">
<b:SyncObjects>
<b:AzureADSyncObject>
<b:PropertyValues xmlns:c="http://schemas.microsoft.com/2003/10/Serialization/Arrays">
<c:KeyValueOfstringanyType><c:Key>SourceAnchor</c:Key><c:Value i:type="d:string" xmlns:d="http://www.w3.org/2001/XMLSchema">test</c:Value></c:KeyValueOfstringanyType>
<c:KeyValueOfstringanyType><c:Key>displayName</c:Key><c:Value i:type="d:string" xmlns:d="http://www.w3.org/2001/XMLSchema">testsf41</c:Value></c:KeyValueOfstringanyType>
<c:KeyValueOfstringanyType><c:Key>userPrincipalName</c:Key><c:Value i:type="d:string" xmlns:d="http://www.w3.org/2001/XMLSchema">[email protected]</c:Value></c:KeyValueOfstringanyType>
</b:PropertyValues>
<b:SyncObjectType>User</b:SyncObjectType>
<b:SyncOperation>Set</b:SyncOperation>
</b:AzureADSyncObject>
</b:SyncObjects>
</syncRequest>
</ProvisionAzureADSyncObjects>
</s:Body>
</s:Envelope>
Answer :
The formatter threw an exception while trying to deserialize the message: There was an error while trying to deserialize parameter http://schemas.microsoft.com/online/aws/change/2010/01:syncRequest. The InnerException message was 'Element 'http://schemas.microsoft.com/2003/10/Serialization/Arrays:Value' contains data from a type that maps to the name ':mustUnderstand'. The deserializer has no knowledge of any type that maps to this name. Consider using a DataContractResolver if you are using DataContractSerializer or add the type corresponding to 'mustUnderstand' to the list of known types - for example, by using the KnownTypeAttribute attribute or by adding it to the list of known types passed to the serializer.'. Please see InnerException for more details.
I tried to look but I admit that I did not find
the project :
I am trying to run wcf2xml on a file, but I get this warning and no output. How do I help you help me proceed?
from wcf.records import Record, print_records
data = requests.post('http://106.37.208.233:20035/ClientBin/Env-CnemcPublish-RiaServices-EnvCnemcPublishDomainService.svc/binary/GetAllCityDayAQIModels').content
records = Record.parse(data)
but error:
File "D:\untitled\wcf\records\base.py", line 126, in parse
log.debug('Value: %s' % str(obj))
TypeError: str returned non-string (type bytes)
I have searched it on pypi.python.org but could not find it.
Error encode binaryxml with utf8 symbols.
Sample file:
https://www.dropbox.com/s/1i6tuztv2tx7lpz/re4.bin?dl=0
Errors:
./wcf2xml.py re4 >re4.xml
Traceback (most recent call last):
File "./wcf2xml.py", line 44, in
print_records(records)
File "/home/python-wcfbin/wcf/records/init.py", line 68, in print_records
new_line = print_records(r.childs, skip+1, fp, False)
File "/home/python-wcfbin/wcf/records/init.py", line 68, in print_records
new_line = print_records(r.childs, skip+1, fp, False)
File "/home/python-wcfbin/wcf/records/init.py", line 68, in print_records
new_line = print_records(r.childs, skip+1, fp, False)
File "/home/python-wcfbin/wcf/records/init.py", line 68, in print_records
new_line = print_records(r.childs, skip+1, fp, False)
File "/home/python-wcfbin/wcf/records/init.py", line 68, in print_records
new_line = print_records(r.childs, skip+1, fp, False)
File "/home/python-wcfbin/wcf/records/init.py", line 68, in print_records
new_line = print_records(r.childs, skip+1, fp, False)
File "/home/python-wcfbin/wcf/records/init.py", line 68, in print_records
new_line = print_records(r.childs, skip+1, fp, False)
File "/home/python-wcfbin/wcf/records/init.py", line 68, in print_records
new_line = print_records(r.childs, skip+1, fp, False)
File "/home/python-wcfbin/wcf/records/init.py", line 68, in print_records
new_line = print_records(r.childs, skip+1, fp, False)
File "/home/python-wcfbin/wcf/records/init.py", line 64, in print_records
fp.write(str(r))
UnicodeEncodeError: 'ascii' codec can't encode characters in position 0-3: ordinal not in range(128)
I'm trying the code on the packet dump included in the blog post:
https://insinuator.net/2016/08/pentesting-webservices-with-net-tcp-binding/
I've exported the packet from 0x141 to a binary file:
python -c 'import binascii; print binascii.unhexlify("06db010056020b0173040b0161065608440a1e0082ab01400a41637469766974794964040d436f7272656c6174696f6e4964982436393837373766652d653637322d346163322d623163642d623962373464313437396538083d687474703a2f2f736368656d61732e6d6963726f736f66742e636f6d2f323030342f30392f536572766963654d6f64656c2f446961676e6f7374696373b1bef9db6d9c998b4e9a140ebf2d6941a24412adf843211e834c8f4e8f0ce47db9cf3a67440c1e0082ab1401560e42030a054207990e596f7520656e74657265643a2030010101"),' > test.bin
Running wcf2bin.py test.bin
gives the following error:
Traceback (most recent call last):
File "wcf2xml.py", line 43, in <module>
records = Record.parse(fp)
File ".../python-wcfbin/wcf/records/base.py", line 111, in parse
obj = Record.records[type].parse(fp)
File ".../python-wcfbin/wcf/records/attributes.py", line 174, in parse
value = Record.records[type].parse(fp)
KeyError: 0
Even if I add exception handling to the affected parts of the code KeyErrors pop up at other parts of the application, that indicates that this is not a bug, but more like a user error... What am I missing?
i have met one problem "Possible false interpretation" when i call wcf2xml.py file.svc, which leads the xml result doesn't work.
I'm not sure i understand the code, why it doesn't work for Decimal interpretation?
datatypes.py:181
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.