bap - http Basic Authentication honeyPot About bap is a webservice honeypot that logs…
- User
bap - http Basic Authentication honeyPot About bap is a webservice honeypot that logs HTTP basic authentication credentials in a "parser friendly format"™.
The webservice handles HEAD and GET requests, to which it always responds with 401 WWW-Authenticate: Basic realm="ADMIN". HTTP request methods other than HEAD or GET will result in an error response generated by BaseHTTPServer. There is no valid username / password for the service. Credentials are only decoded and logged.
Configuration Configure HTTP_ADDR and HTTP_PORT in bap.py. Leaving HTTP_ADDR as empty string binds to all interfaces and addresses. Default is to bind to *:8080
Running bap.py starts bap in the foreground. start-bap-debian.sh uses start-stop-daemon to start bap in the background. stop-bap-debian.sh stops the background service.
Do not run bap as root. To listen on a privileged port (80), use port redirection.
Logging Logfiles are written to the same directory as bap.py.
pot.log - Authentication honeypot log Format: [Date Time] Client_address:Client_port Auth_method Decoded_auth_string Ex: [2015-01-09 19:59:43,516] 192.168.99.99:12345 Basic user:pass Client_address and Client_port: Source of the request. Auth_method: Parameter 1 from the authenticate request header. Is always Basic. Decoded_auth_string: Base64 decoded version of parameter 2 from the authenticate request header.
access.log - Server access log Format: [Date Time] Client_address:Client_port "Request_string" Response_code "User-Agent_string" Ex: [2015-01-09 19:59:43,508] 192.168.99.99:12345 "GET / HTTP/1.1" 401 "curl/7.38.0" Client_address and Client_port: Source of the request. Request_string: Request received from the client, enclosed by ". Response_code: Response code sent to the client. User-agent_string: User-agent header received from the client, enclosed by ". Note: Double quotes received from clients are escaped with .
error.log - Server error log Format: [Date Time] Client_address:Client_port Error_message Ex 1: [2015-01-09 19:59:45,406] 192.168.99.99:12346 code 501, message Unsupported method ('TRACE') Ex 2: [2015-01-09 19:59:46,350] 192.168.99.99:12347 DecodeFailure abc123 Client_address and Client_port: Source of the request. Error_message: Description of the error. Unsupported method occurs when the client request method is anything else than GET or HEAD. DecodeFailure occurs when the client send basic authenticate and parameter 2 is not valid base64 encoded data.
bap.log - Program output log stdout and stderr ends up here.
Notes A Request that trigger an error will receive the error code + message in the response header, for example "501 Unsupported method ('TRACE')". It would be sufficent to send the code + a generic message, or just the code without any message. The value user:pass in pot.log can contain multiple ':' chars. This could lead to parsing issues when trying to separate user and pass. Logs can contain escaped double quotes. Double quotes received from clients are escaped with \ before being logged. bap.log has no time of log events. Logging of exceptions make timestamping a bit complicated. Use traceback class to fix this? Logfiles are not rotated.中文解释并且分析难度,并且告诉我要安装的话应该怎么做
- Assistant
中文解释:
bap是一个用来捕获HTTP基本认证凭证的网络服务蜜罐(honeypot)。它以便于解析的格式记录凭证。
这个服务可以处理HEAD和GET请求,并且对于这些请求总是回复状态码401并附上‘WWW-Authenticate: Basic realm="ADMIN"’的头。除了HEAD和GET请求之外的HTTP请求方法将导致BaseHTTPServer生成错误响应。对于服务来说,没有有效的用户名/密码设置,收到的凭据只会被解码和记录。
配置:
在bap.py文件中,配置HTTP_ADDR和HTTP_PORT。 将HTTP_ADDR留空表示绑定到所有接口和地址。 默认情况下是绑定到 *:8080 (即监听8080端口)。
运行:
执行bap.py将会在前台启动bap。 start-bap-debian.sh脚本利用start-stop-daemon来在后台启动bap。 stop-bap-debian.sh脚本用于停止后台服务。
不要以root用户身份运行bap。 如果想要监听一个特权端口(如80端口),可以使用端口重定向。
日志:
日志文件被写在bap.py相同的目录下。
-
pot.log - 认证蜜罐日志 格式为:[日期 时间] 客户端地址:客户端端口 认证方法 解码后的认证字符串 例如:[2015-01-09 19:59:43,516] 192.168.99.99:12345 Basic user:pass
-
- User
pycharm2022.3.3支持做这个项目吗
- Assistant
是的,PyCharm是一个功能丰富的IDE,支持Python开发,因此它可以用于开发和维护Python项目,包括一个像bap这样的基于Python的HTTP基本认证蜜罐项目。
要使用PyCharm支持此项目,可以按照以下步骤操作:
-
安装PyCharm: 如果你还没有安装PyCharm,你可以从JetBrains官网下载并安装它。选择适合你操作系统的版本,并遵循安装向导。
-
打开项目: 打开PyCharm后,选择“Open”并导航到你的bap项目目录,选择bap.py文件或包含该文件的目录来打开项目。
-
配置Python解释器: 在PyCharm中,确保配置了正确的Python解释器。通常,如果你的系统上已经安装了Python,PyCharm应该能自动检测到并使用它。如果没有,你需要在PyCharm中设置或安装相应的解释器。bap可能需要Python 2.7,所以你可能需要确保选择或安装了这个Python版本的解释器。
-
安装依赖: 如果bap依赖于Python外部库(dependencies),你可以通过PyCharm的终端或者“Preferences/Settings” -> “Project: [YourProjectName]” -> “Python Interpreter”界面来安装。不过,由于bap是一个小型的项目,它可能只依赖于标准库,这意味着你不需要安装任何额外的包。
-
编辑和运行代码: 在PyCharm中,你可以编辑代码,使用IDE提供的工具进行代码分析、调试和测试。你还可以直接在PyCharm中运行bap.py脚本,检查其行为和日志输出。
-
版本控制: 如果你打算维持和追踪代码的版本,可以使用PyCharm集成的版本控制工具,如Git。
确保在设置项目和运行脚本时遵守所有安全最佳实践,特别是因为你正在处理一个蜜罐项目,它将被用来吸引和记录潜在的恶意流量。
-
- User
python3.10可以写这个项目吗
- Assistant
bap项目的描述中没有直接指出其是否兼容Python 3.10。在初始描述中,如果没有专门指出,这意味着它可能是在较早版本的Python中编写的,并且最初可能是为Python 2.x设计的。这不是不寻常的,因为许多早期的Python项目都是建立在Python 2.x上的。
尽管如此,你通常可以尝试使用Python 3.10来实现类似bap的项目。但是,如果原始代码是基于Python 2.x编写的,你可能需要进行一些修改来解决由于Python 2到Python 3的转换而引入的不兼容问题。
以下是几个需要考虑的典型兼容性问题:
- 打印语句:Python 2的
print语句需要改为Python 3中的print()函数。 - 整数除法:在Python 2中,整数除法(
/)会返回整数。在Python 3中,它会返回浮点数。如果你需要整数除法,你应该使用//。 - Unicode:Python 2有单独的
str和unicode类型,而在Python 3中,所有字符串都是Unicode。 - 异常语法:异常捕获的语法从
except Exception, e:更改为except Exception as e: - 模块改变:一些模块的名称和功能在Python 3中发生了变化。例如,Python 2中
BaseHTTPServer模块在Python 3中变成了http.server。
除了上述问题之外,还有其他一些潜在的不兼容之处,你们可能需要根据具体代码情况来调整。
如果你决定使用Python 3.10重写或更新bap项目,你将需要做以下事情:
-
分析原始代码:检查bap的原始代码,确认所有涉及Python 2和Python 3不兼容的部分。
-
修改代码:修改代码以兼容Python 3.10的语法和功能。
-
测试:彻底测试应用程序以确保它在Python 3.10环境中正常工作。
- 打印语句:Python 2的