Consuming Hidden WCF RIA Services

本文介绍了一种方法,通过Wireshark抓包和Fiddler工具解析低级复制协议,揭示了使用.NET Binary Format编码的私有服务调用方式,实现了不依赖配置的Silverlight应用与隐藏WCF RIA服务之间的交互。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

 原文 http://codeseekah.com/2013/07/05/consuming-hidden-wcf-ria-services/

A Silverlight application made it to my desk yesterday, an application that consumed a remote WCF RIA service running on a Microsoft IIS. The service did not provide a public API, nor did disassembly with dotPeek help get the service manifests to construct a WCF client with. WSDL files weren’t exposed either. A new, custom client was to be written by reverse engineering what was available without any fancy configurations.

Consuming Hidden WCF RIA Services

 

A bit of Wiresharking around and the protocol details became exposed for some low-level replication. The payloads were encoded, and the Content-Type> header hinted at application/msbin1, which made it pretty clear that it was in .NET Binary Format. Decoding was simple by switching to Fiddler and a WCF Binary Inspector. Having retrieved the payloads sending binary to the private service was quite straight-forward in C#.

...

using System.Xml;
using System.Net;

...

/* Write .NET Binary XML */
System.IO.Stream s = new System.IO.MemoryStream();           
XmlWriter binarywriter = XmlDictionaryWriter.CreateBinaryWriter(s);

binarywriter.WriteStartElement("Action1", "http://tempuri.org/");
...
binarywriter.Flush();

s.Seek(0, System.IO.SeekOrigin.Begin);
byte[] b = new byte[s.Length];
s.Read(b, 0, (int)s.Length);

HttpWebRequest request = (HttpWebRequest)WebRequest.Create("hidden.svc/binary/Action1");
request.Method = "POST";
request.ContentType = "application/msbin1";
request.GetRequestStream().Write(b, 0, b.Length);
HttpWebResponse response = (HttpWebResponse)request.GetResponse();

/* Read .NET XML */
b = new byte[response.ContentLength];
response.GetResponseStream().Read(b, 0, b.Length);

XmlReader binaryreader = XmlDictionaryReader.CreateBinaryReader(b, XmlDictionaryReaderQuotas.Max);
XmlDocument xdoc = new XmlDocument();
xdoc.Load(binaryreader);
...

Needs the System, System.Net, System.Runtime.Serialization and System.XML assemblies.

To consume hidden WCF RIA services on other platforms check out xml2wcf.py

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值