项目作者: ysan

项目描述 :
UPnP Device Architecture protocol sniffer
高级语言: Python
项目地址: git://github.com/ysan/upnp_da_check.git
创建时间: 2015-12-13T11:28:27Z
项目社区:https://github.com/ysan/upnp_da_check

开源协议:MIT License

下载


upnp da check (UPnP Device Architecture protocol sniffer)

The tool is intended to perform control for devices that perform user with various functions as a UPnP Device Architecture is a control point.

Setup

  1. $ git clone https://github.com/ysan/upnp_da_check.git
  2. $ cd upnp_da_check
  3. $ pip2 install -r requirements.txt

Usage

  1. $ ./upnp_da_check.py interface_name

on the command line. Execution path you are free.

Example of use

Console will rise when you start the program.

  1. $ ./upnp_da_check.py eth0
  2. == UPnP DA checktool (sniffer) ==
  3. --------------------------------
  4. interface: [eth0 (43.3.177.96)]
  5. workerThread queue: [Hi:0, Mid:0, Lo:0]
  6. UPnP multicast receive: [running]
  7. cache-control(max-age): [enable]
  8. debug print: [off]
  9. --------------------------------
  10. console start...
  11. >
  12. >
  13. >

You can execute M-SEARCH with sc command.

  1. > sc
  2. >

as long as it receives the discover packet and keeps the information to the device list.
You have to display a list with the ls command.
This is when there is some upnp enabled devices on the LAN if.

  1. > ls
  2. UDN AGE S/S FriendlyName ManufactureName LocationUrl
  3. --------------------------------------------- ----- ---- ---------------------- ---------------------- -------------------------------------
  4. uuid:55076f6e-6b79-1d65-a497-xxxxxxxxxxxx 1808 3/3 [TomServer ] [PacketVideo ] http://43.3.183.246:9000/dev0/desc.xml
  5. uuid:af75600b-2db7-428a-968a-xxxxxxxxxxxx 1797 2/2 [KDL-50W800C] ] [Sony Corporation ] http://43.31.111.140:34278/sony/webapi/ssdp/dd.xml
  6. uuid:13814000-8752-1052-bfff-xxxxxxxxxxxx 1799 -/- [ ] [ ] http://43.2.18.222:52323/upnp_description.xml
  7. uuid:434c8e6b-44ea-439a-81a4-xxxxxxxxxxxx 1791 2/2 [KDL-GN2 ] [Sony Corporation ] http://43.31.109.4:12725/sony/webapi/ssdp/dd.xml
  8. uuid:4326e843-52e7-43d8-9e61-xxxxxxxxxxxx 1797 1/1 [KDL-50W800C ] [Sony Corporation ] http://43.31.111.140:43733/dd.xml
  9. uuid:5D076f6e-6b79-1d65-a497-xxxxxxxxxxxx 1808 0/0 [Twonky NMC Queue Han] [PacketVideo ] http://43.3.183.246:9000/dev1/desc.xml
  10. uuid:cfe92100-67c4-11d4-a45f-xxxxxxxxxxxx 1797 2/2 [EPSON52DBB0 ] [EPSON ] http://43.2.60.163/DEVICE/PRINTER1.XML
  11. uuid:23456789-1234-1010-8000-xxxxxxxxxxxx 1791 3/3 [KD-65S8505C ] [Sony Corporation ] http://43.3.173.179:52323/MediaRenderer.xml
  12. uuid:4D454930-0100-1000-8000-xxxxxxxxxxxx 1799 -/- [ ] [ ] http://43.31.111.141:60606/A81374451162/Server0/ddd
  13. uuid:5B076f6e-6b79-1d65-a497-xxxxxxxxxxxx 1808 0/0 [TwonkyProxy [JPC2031] [PacketVideo ] http://43.3.183.246:9000/dev2/desc.xml
  14. uuid:a36e2757-2f7f-491b-8b4a-xxxxxxxxxxxx 899 3/3 [JPC00141623: 0000131] [Microsoft Corporatio] http://43.31.105.114:2869/upnphost/udhisapi.dll?content=uuid:a36e2757-2f7f-491b-8b4a-b4ae5dfbe4f8
  15. ---------
  16. 11 items.
  17. >

If you pass the argument UDN to info command, detailed information for that device appears.
(Display content here it will omitted.)
- Discover the contents of the packet
- Location overview of the content of
- The Published service list
- In-service there is what kind of action, and information of the argument to pass to the action
etc…

  1. > info uuid:cfe92100-67c4-11d4-a45f-xxxxxxxxxxxx
  2. ===============================
  3. ==== Detail Info ====
  4. ===============================
  5. ---- Discover Packet ----
  6. .
  7. .
  8. .
  9. ---- Location Info ----
  10. .
  11. .
  12. .
  13. ---- Service List ----
  14. .
  15. .
  16. .

If you pass the argument UDN to act command, you can perform the action of the public service for the equipment.
You choose whether first how to service.

  1. > act uuid:cfe92100-67c4-11d4-a45f-xxxxxxxxxxxx
  2. ____________________
  3. Select service type.
  4. --------------------
  5. 1. urn:schemas-upnp-org:service:PrintBasic:1
  6. 2. urn:schemas-upnp-org:service:PrintEnhanced:1
  7. Enter No. -->

After selecting the service, you will select the action.

  1. Enter No. --> 2
  2. service type is [urn:schemas-upnp-org:service:PrintEnhanced:1].
  3. Select action.
  4. 1. GetPrinterAttributesV2
  5. 2. X_GetPrinterStatusString
  6. 3. CreateJob
  7. 4. GetJobAttributes
  8. 5. CreateJobV2
  9. 6. GetMargins
  10. 7. CancelJob
  11. 8. CreateURIJob
  12. 9. GetMediaList
  13. 10. GetPrinterAttributes
  14. Enter No. -->

select the action.

  1. Enter No. --> 2
  2. action is [X_GetPrinterStatusString].
  3. Response. >>>status:[200 OK]
  4. >>>body: <s:Envelope xmlns:s="http://schemas.xmlsoap.org/soap/envelope/" s:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"><s:Body><u:X_GetPrinterStatusStringResponse xmlns:u="urn:schemas-upnp-org:service:PrintEnhanced:1"><X_PrinterStatusString>paSl86WvpKy7xKTqvq+kyqSvpMqkw6TGpKSk3qS5oaM=</X_PrinterStatusString><X_ErrorReason>noerror</X_ErrorReason></u:X_GetPrinterStatusStringResponse></s:Body></s:Envelope>
  5. --- X_PrinterStatusString:[paSl86WvpKy7xKTqvq+kyqSvpMqkw6TGpKSk3qS5oaM=] ---
  6. --- X_ErrorReason:[noerror] ---
  7. Hit Enter. (return to -Select service type.-)

Result of action has been returned.
You can view the contents of the HTTP status code and the body, you have to display the value obtained in the action.
“X_PrinterStatusString” results I have indicates that the ink is running low.

When the exit from the console, enter the “q”.

  1. ____________________
  2. Select service type.
  3. --------------------
  4. 1. urn:schemas-upnp-org:service:PrintBasic:1
  5. 2. urn:schemas-upnp-org:service:PrintEnhanced:1
  6. Enter No. --> q
  7. >
  8. > q
  9. console end.
  10. $
  11. $

Tool in the command

  1. ls [UDN|ipaddr|friendlyName]
  2. show device list (friendlyName can be specified by wildcard.)
  3. an UDN
  4. analyze device (connect to device and get device info.)
  5. info UDN
  6. show device info
  7. act UDN
  8. send action to device
  9. r
  10. join UPnP multicast group (toggle on(default)/off)
  11. t
  12. cache-control (toggle enable(default)/disable)
  13. sc [ipaddr]
  14. send SSDP M-SEARCH
  15. sd http-url
  16. simple HTTP downloader
  17. ss
  18. show status
  19. c
  20. show command hitory
  21. h
  22. show command referense
  23. d
  24. debug log (toggle on/off(default))
  25. q
  26. exit from console

Platforms

Generic Linux/Windows will be ok. (confirmed worked on Ubuntu, Fedora, Windows8)
python 2.7