添加身份验证并增强任何现有服务/协议的安全性
socket-gatekeeper的Python项目详细描述
插座守门员
- socket gatekeeper提供了一种密码保护和路由任意套接字的方法。它可以为现有的提供无/弱认证的服务添加安全性,
- 并用一个入口点替换几个通向外部世界的端口。
它监听套接字并等待连接。连接后,它会向客户端发送一个1024位rsa公钥。 客户机使用此公钥加密密码并将其通过线路发送回来。 该密码使用sha-256进行散列,并与提供的映射文件进行比较。此映射文件指定密码的位置 将被路由。例如,给密码“abc”可以路由到一个端口上的一些管理信息,给不同的密码“foo”可以 路由到运行在其他地方的信息服务。提供未映射的密码将导致连接终止。 客户机没有任何信息来描述在何处运行的内容,或者这甚至是一个网关守护器套接字(用于安全性)。
您可以使用socket gatekeeper执行许多任务:
- 保护不具有任何继承安全性的协议
- 在运行多个管理服务的计算机上只打开一个端口。管理员有自己独特的密码来访问他们需要的服务
- 打开通向外部世界的端口,然后使用安全密码将其路由到任意数量的内部服务
- 其他几个!
映射文件(配置)
守护进程提供的路由由映射文件控制。
此文件的格式为:
sha256sum=Addr:Port
例如,对于要路由到本地主机端口6379的密码“abc”,请使用:
ba7816bf8f01cfea414140de5dae2223b00361a396177a9cb410ff61f20015ad = 127.0.0.1:6379
可以使用以下脚本导出SHA256和:
echo -n “your_password_here” | sha256sum | awk {‘print $1’}
可能有多个密码指向同一个端点,但单个密码可能只指向一个端点。
启动服务器(在其他服务之前)
使用提供的命令socket gatekeeperd启动一个gatekeeper守护进程。
必需参数:
You must provide “–mappings=/path/to/file” (or “-m /path/to/file”) to the mapping file. You must also provide “–bind=addr:port” (or “-b addr:port”) example: 127.0.0.1:50001
其他参数:
--client-buffer-len=X This will use X as the number of bytes transmitted/received at one time to/from the client --endpoint-buffer-len=X This will use X as the number of bytes transmitted/received at one time to/from the endpoint Both buffer arguments default to 4096.
—enable-quit This will intercept the messages “quit” and “exit” and cause them to terminate the connection.
连接到服务器(telnet样式)
一旦服务器启动并运行,就可以使用提供的socket gatekeeper connect程序连接到它。
指定要连接的地址和端口,并处理rsa部分,提示输入不回显的密码 到屏幕,然后充当到您和端点之间的中间人。
Usage: ./socket-gatekeeper-connect Addr:port
Connects to a gatekeeper socket. This is basically the same as telnetting to the socket, except it will not echo the password back on the screen, so this is more secure.
集成到应用程序中(插座式)
socket gatekeeperd位于守护进程前面,为任何协议添加安全性。
<>但是你想用现有的工具连接到那个服务吗?你应该使用socket_gatekeepersocket.gatekeepersocket。它使用执行握手的方法扩展了标准python“socket”。
给定的密码,或提示用户并以这种方式执行握手。身份验证之后,它的行为就像一个普通的套接字。因此,您可以
通过用GateKeepSocket替换Socket来扩展任何代码。
要将其他语言用作客户端,请参见gateKeepSocket以了解握手的简单实现。它应该易于在中实现
其他语言。
示例:
sock = GatekeeperSocket(socket.AF_INET, socket.SOCK_STREAM)
try:
sock.connect( (addrSplit[0], int(addrSplit[1])) )除了套接字。错误:
sys.stderr.write(‘Failed to connect to %sn’ %(sys.argv[1],))
sys.exit(1)
sock.doAuthenticationFrominput()
依赖关系
取决于python 2.7和argumentparser(https://pypi.python.org/pypi/argumentparser)以及pycrypto(https://pypi.python.org/pypi/pycrypto)