本文整理汇总了Python中socket.IPPROTO_SCTP属性的典型用法代码示例。如果您正苦于以下问题:Python socket.IPPROTO_SCTP属性的具体用法?Python socket.IPPROTO_SCTP怎么用?Python socket.IPPROTO_SCTP使用的例子?那么, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在类socket
的用法示例。
在下文中一共展示了socket.IPPROTO_SCTP属性的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: newSocket
# 需要导入模块: import socket [as 别名]
# 或者: from socket import IPPROTO_SCTP [as 别名]
def newSocket(self):
return socket.socket(socket.AF_INET, socket.SOCK_STREAM,
socket.IPPROTO_SCTP)
示例2: send
# 需要导入模块: import socket [as 别名]
# 或者: from socket import IPPROTO_SCTP [as 别名]
def send(self, data):
try:
if not self.maxsize is None and len(data) > self.maxsize:
data = data[:self.maxsize-1]
if DEBUG:
print("Truncated data to %d byte." % self.maxsize)
if self.session_type == "eth":
self.s.send(data)
elif self.session_type == "file":
self.f.write(data)
elif self.session_type == "stdout":
self.f.write(data + b"\n")
elif self.session_type == "stdout-hex":
self.f.write(binascii.hexlify(data))
elif self.session_type == "cmd":
try:
subprocess.call("%s %s" % (self.cmd, binascii.hexlify(data).upper()), shell=True)
except Exception as e:
raise dizz_sessionException("error on executing %s: '%s'" % (self.cmd, str(e)))
elif self.session_type == "usb-dscr":
self.u = usb.dizzyUSB(self.filename, self.timeout, data=data, fuzz_dscr=self.fuzz_dscr)
self.u.open()
self.u.close()
elif self.session_type == "usb-endp":
if not self.u.opened:
raise dizz_sessionException("usb connection closed...")
try:
self.u.write(data)
except ValueError as e:
raise dizz_sessionException("error sending to endpoint: %s" % str(e))
elif self.session_type == "tcp" or self.session_type == "tls":
if self.server_side:
if not self.cs:
raise dizz_sessionException("no client connection, cant send")
self.cs.send(data)
else:
self.s.send(data)
#~ elif self.session_type == "sctp":
#~ self.s.sendmsg([data], [(socket.IPPROTO_SCTP, self.SCTP_SNDRCV, self.sndrcvinfo)], 0, (self.dest, self.dport))
else:
self.s.sendto(data, (self.dest, self.dport))
except Exception as e:
if self.auto_reopen:
if DEBUG:
print("session got closed '%s', autoreopening..." % str(e))
traceback.print_exc()
self.close()
self.open()
else:
self.close()
raise dizz_sessionException("error on sending '%s', connection closed." % str(e))