本文整理汇总了Python中cowrie.core.config.CONFIG.items方法的典型用法代码示例。如果您正苦于以下问题:Python CONFIG.items方法的具体用法?Python CONFIG.items怎么用?Python CONFIG.items使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类cowrie.core.config.CONFIG
的用法示例。
在下文中一共展示了CONFIG.items方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: cowrieOpenConnectForwardingClient
# 需要导入模块: from cowrie.core.config import CONFIG [as 别名]
# 或者: from cowrie.core.config.CONFIG import items [as 别名]
def cowrieOpenConnectForwardingClient(remoteWindow, remoteMaxPacket, data, avatar):
"""
This function will redirect an SSH forward request to another address
or will log the request and do nothing
"""
remoteHP, origHP = forwarding.unpackOpen_direct_tcpip(data)
log.msg(eventid='cowrie.direct-tcpip.request',
format='direct-tcp connection request to %(dst_ip)s:%(dst_port)s from %(src_ip)s:%(src_port)s',
dst_ip=remoteHP[0], dst_port=remoteHP[1],
src_ip=origHP[0], src_port=origHP[1])
# Forward redirect
redirectEnabled = CONFIG.getboolean('ssh', 'forward_redirect', fallback=False)
if redirectEnabled:
redirects = {}
items = CONFIG.items('ssh')
for i in items:
if i[0].startswith('forward_redirect_'):
destPort = i[0].split('_')[-1]
redirectHP = i[1].split(':')
redirects[int(destPort)] = (redirectHP[0], int(redirectHP[1]))
if remoteHP[1] in redirects:
remoteHPNew = redirects[remoteHP[1]]
log.msg(eventid='cowrie.direct-tcpip.redirect',
format='redirected direct-tcp connection request from %(src_ip)s:%(src_port)' +
'd to %(dst_ip)s:%(dst_port)d to %(new_ip)s:%(new_port)d',
new_ip=remoteHPNew[0], new_port=remoteHPNew[1],
dst_ip=remoteHP[0], dst_port=remoteHP[1],
src_ip=origHP[0], src_port=origHP[1])
return SSHConnectForwardingChannel(remoteHPNew, remoteWindow=remoteWindow, remoteMaxPacket=remoteMaxPacket)
# TCP tunnel
tunnelEnabled = CONFIG.getboolean('ssh', 'forward_tunnel', fallback=False)
if tunnelEnabled:
tunnels = {}
items = CONFIG.items('ssh')
for i in items:
if i[0].startswith('forward_tunnel_'):
destPort = i[0].split('_')[-1]
tunnelHP = i[1].split(':')
tunnels[int(destPort)] = (tunnelHP[0], int(tunnelHP[1]))
if remoteHP[1] in tunnels:
remoteHPNew = tunnels[remoteHP[1]]
log.msg(eventid='cowrie.direct-tcpip.tunnel',
format='tunneled direct-tcp connection request %(src_ip)s:%(src_port)' +
'd->%(dst_ip)s:%(dst_port)d to %(new_ip)s:%(new_port)d',
new_ip=remoteHPNew[0], new_port=remoteHPNew[1],
dst_ip=remoteHP[0], dst_port=remoteHP[1],
src_ip=origHP[0], src_port=origHP[1])
return TCPTunnelForwardingChannel(remoteHPNew,
remoteHP,
remoteWindow=remoteWindow,
remoteMaxPacket=remoteMaxPacket)
return FakeForwardingChannel(remoteHP, remoteWindow=remoteWindow, remoteMaxPacket=remoteMaxPacket)