Jump to content
  • Entries

    16114
  • Comments

    7952
  • Views

    86375753

Contributors to this blog

  • HireHackking 16114

About this blog

Hacking techniques include penetration testing, network security, reverse cracking, malware analysis, vulnerability exploitation, encryption cracking, social engineering, etc., used to identify and fix security flaws in systems.

0x00 前言本文將要介紹在禁用元數據發布(MEX)時WCF開發的相關內容,給出文章《Abusing Insecure Windows Communication Foundation (WCF) Endpoints》 的完整代碼示例。

0x01 簡介本文將要介紹以下內容:

禁用MEX實現WCF

文章完整代碼示例

0x02 禁用MEX實現WCF禁用MEX時,需要根據服務端的代碼手動編寫客戶端代碼

本節採用命令行實現WCF的方式作為示例

開發工具:Visual Studio 2015

1.服務端編寫(1)新建項目

選擇Visual C#-Console Application,名稱為NBTServer

(2)新建WCF服務

選擇Add-New Item.選擇WCF Service,名稱為Service1.cs

(3)修改service1.cs

添加DoWork的實現代碼,代碼示例:

image.png

(4)修改Program.cs

添加引用System.ServiceModel

添加啟動代碼,代碼示例:

image.png

(5)修改App.config

image.png

(6)編譯運行

命令行輸出地址:net.tcp://localhost/vulnservice/runme

(7)測試

此時無法使用WcfTestClient進行測試

2.客戶端編寫(1)新建項目

選擇Visual C#-Console Application,名稱為NBTClient

(2)修改Program.cs

添加引用System.ServiceModel

代碼示例:

image.png

0x03 文章完整代碼示例代碼示例:

https://github.com/VerSprite/research/tree/master/projects/wcf/VulnWCFService

相關介紹:

https://versprite.com/blog/security-research/abusing-insecure-wcf-endpoints/

代碼示例實現了WCF的服務端,但是缺少安裝部分和客戶端的編寫,這裡給出完整示例

1.服務端編寫(1)下載代碼

https://github.com/VerSprite/research/tree/master/projects/wcf/VulnWCFService

(2)新建Windows Service

選擇Add-New Item.選擇Windows Service,名稱為Service1.cs

(3)設置服務信息

選中Service1.cs,右鍵-Add Installer

項目中自動創建ProjectInstaller.cs文件,該文件會添加倆個組件serviceProcessInstaller1和serviceInstaller1

選中serviceProcessInstaller1組件,查看屬性,設置account為LocalSystem

選中serviceInstaller1組件,查看屬性,設置ServiceName為VulService1

(4)啟動服務

編譯生成VulnWCFService.exe

安裝服務:

image.png

啟動服務:

image.png

補充:卸載服務

image.png

2.客戶端編寫(1)新建項目

選擇Visual C#-Console Application,名稱為VulnWCFClient

(2)修改Program.cs

添加引用System.ServiceModel

代碼示例:

image.png

(3)編譯運行

編譯生成VulnWCFClient,運行後彈出System權限的計算器,測試成功

0x04 小結本文介紹了禁用元數據發布(MEX)時WCF開發的相關內容,給出文章《Abusing Insecure Windows Communication Foundation (WCF) Endpoints》 的完整代碼示例,便於WCF相關知識的研究。