本文整理匯總了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))