Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Handle no action being present in the SOAP message #82

Merged
merged 1 commit into from
Jan 24, 2025
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 12 additions & 4 deletions wsdiscovery/message.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,9 @@
from .actions import *
from xml.dom import minidom

import logging

logger = logging.getLogger(__name__)

def createSOAPMessage(env):
"serialize SOAP envelopes into XML strings"
Expand All @@ -27,15 +30,20 @@ def parseSOAPMessage(data, ipAddr):
"deserialize XML message strings into SOAP envelope objects"
try:
dom = minidom.parseString(data)
except Exception:
#print('Failed to parse message from %s\n"%s": %s' % (ipAddr, data, ex), file=sys.stderr)
except Exception as ex:
logger.debug('Failed to parse message from %s\n%s: %s', ipAddr, data, ex)
return None

if dom.getElementsByTagNameNS(NS_SOAPENV, "Fault"):
#print('Fault received from %s %s:' % (ipAddr, data), file=sys.stderr)
logger.debug('Fault received from %s: %s', ipAddr, data)
return None

actions = dom.getElementsByTagNameNS(NS_ADDRESSING, "Action")
if len(actions) == 0:
logger.warning('No action received from %s: %s', ipAddr, data)
return None

soapAction = dom.getElementsByTagNameNS(NS_ADDRESSING, "Action")[0].firstChild.data.strip()
soapAction = actions[0].firstChild.data.strip()
if soapAction == NS_ACTION_PROBE:
return parseProbeMessage(dom)
elif soapAction == NS_ACTION_PROBE_MATCH:
Expand Down
Loading