Project Icon

endlessh-go

Go语言实现的SSH蜜罐工具 支持Prometheus指标和Grafana可视化

endlessh-go是一个Go语言实现的SSH蜜罐工具,用于阻止暴力破解攻击并消耗攻击者时间。它支持导出Prometheus指标,通过Grafana仪表板可视化攻击源地理位置和统计数据。该项目易于部署,支持Docker,提供灵活配置。endlessh-go适合需要监控SSH攻击模式的安全专业人员使用。

endlessh-go

A golang implementation of endlessh exporting Prometheus metrics, visualized by a Grafana dashboard.

screenshot

Introduction

Endlessh is a great idea that not only blocks the brute force SSH attacks, but also wastes attackers time as a kind of counter-attack. Besides trapping the attackers, I also want to visualize the Geolocations and other statistics of the sources of attacks. Unfortunately the wonderful original C implementation of endlessh only provides text based log, but I do not like the solution that writes extra scripts to parse the log outputs, then exports the results to a dashboard, because it would introduce extra layers in my current setup and it would depend on the format of the text log file rather than some structured data. Thus I create this golang implementation of endlessh to export Prometheus metrics and a Grafana dashboard to visualize them.

If you want a dashboard of sources of attacks and do not mind the endlessh server, besides trapping the attackers, does extra things including: translating IP to Geohash, exporting Prometheus metrics, and using more memory (about 10MB), this is the solution for you.

Getting Started

Clone the repo then build from source:

go build .
./endlessh-go &

Alternatively, you can use the docker image:

docker run -d -p 2222:2222 shizunge/endlessh-go -logtostderr -v=1

It listens to port 2222 by default.

Then you can try to connect to the endlessh server. Your SSH client should hang there.

ssh -p 2222 localhost

If you want log like the C implementation, you need to set both CLI arguments -logtostderr and -v=1, then the log will go to stderr. You can set different log destinations via CLI arguments.

Also check out examples for the setup of the full stack.

Usage

./endlessh-go --help

Usage of ./endlessh-go
  -alsologtostderr
        log to standard error as well as files
  -conn_type string
        Connection type. Possible values are tcp, tcp4, tcp6 (default "tcp")
  -enable_prometheus
        Enable prometheus
  -geoip_supplier string
        Supplier to obtain Geohash of IPs. Possible values are "off", "ip-api", "max-mind-db" (default "off")
  -host string
        SSH listening address (default "0.0.0.0")
  -interval_ms int
        Message millisecond delay (default 1000)
  -line_length int
        Maximum banner line length (default 32)
  -log_backtrace_at value
        when logging hits line file:N, emit a stack trace
  -log_dir string
        If non-empty, write log files in this directory
  -log_link string
        If non-empty, add symbolic links in this directory to the log files
  -logbuflevel int
        Buffer log messages logged at this level or lower (-1 means don't buffer; 0 means buffer INFO only; ...). Has limited applicability on non-prod platforms.
  -logtostderr
        log to standard error instead of files
  -max_clients int
        Maximum number of clients (default 4096)
  -max_mind_db string
        Path to the MaxMind DB file.
  -port value
        SSH listening port. You may provide multiple -port flags to listen to multiple ports. (default "2222")
  -prometheus_clean_unseen_seconds int
        Remove series if the IP is not seen for the given time. Set to 0 to disable. (default 0)
  -prometheus_entry string
        Entry point for prometheus (default "metrics")
  -prometheus_host string
        The address for prometheus (default "0.0.0.0")
  -prometheus_port string
        The port for prometheus (default "2112")
  -stderrthreshold value
        logs at or above this threshold go to stderr (default 2)
  -v value
        log level for V logs
  -vmodule value
        comma-separated list of pattern=N settings for file-filtered logging

Metrics

Endlessh-go exports the following Prometheus metrics.

MetricTypeDescription
endlessh_client_open_count_totalcountTotal number of clients that tried to connect to this host.
endlessh_client_closed_count_totalcountTotal number of clients that stopped connecting to this host.
endlessh_sent_bytes_totalcountTotal bytes sent to clients that tried to connect to this host.
endlessh_trapped_time_seconds_totalcountTotal seconds clients spent on endlessh.
endlessh_client_open_countcountNumber of connections of clients.
Labels:
  • ip: Remote IP of the client
  • local_port: Local port the program listens to
  • country: Country of the IP
  • location: Country, Region, and City
  • geohash: Geohash of the location
endlessh_client_trapped_time_secondscountSeconds a client spends on endlessh.
Labels:
  • ip: Remote IP of the client
  • local_port: Local port the program listens to

The metrics is off by default, you can turn it via the CLI argument -enable_prometheus.

It listens to port 2112 and entry point is /metrics by default. The port and entry point can be changed via CLI arguments.

The endlessh-go server stores the geohash of attackers as a label on endlessh_client_open_count, which is also off by default. You can turn it on via the CLI argument -geoip_supplier. The endlessh-go uses service from ip-api, which may enforce a query rate and limit commercial use. Visit their website for their terms and policies.

You could also use an offline GeoIP database from MaxMind by setting -geoip_supplier to max-mind-db and -max_mind_db to the path of the database file.

Dashboard

The dashboard requires Grafana 8.2.

You can import the dashboard from Grafana.com using ID 15156

The dashboard visualizes data for the selected time range.

The IP addresses are clickable and link you to the ARIN database.

Contacts

If you have any problems or questions, please contact me through a GitHub issue

项目侧边栏1项目侧边栏2
推荐项目
Project Cover

豆包MarsCode

豆包 MarsCode 是一款革命性的编程助手,通过AI技术提供代码补全、单测生成、代码解释和智能问答等功能,支持100+编程语言,与主流编辑器无缝集成,显著提升开发效率和代码质量。

Project Cover

AI写歌

Suno AI是一个革命性的AI音乐创作平台,能在短短30秒内帮助用户创作出一首完整的歌曲。无论是寻找创作灵感还是需要快速制作音乐,Suno AI都是音乐爱好者和专业人士的理想选择。

Project Cover

白日梦AI

白日梦AI提供专注于AI视频生成的多样化功能,包括文生视频、动态画面和形象生成等,帮助用户快速上手,创造专业级内容。

Project Cover

有言AI

有言平台提供一站式AIGC视频创作解决方案,通过智能技术简化视频制作流程。无论是企业宣传还是个人分享,有言都能帮助用户快速、轻松地制作出专业级别的视频内容。

Project Cover

Kimi

Kimi AI助手提供多语言对话支持,能够阅读和理解用户上传的文件内容,解析网页信息,并结合搜索结果为用户提供详尽的答案。无论是日常咨询还是专业问题,Kimi都能以友好、专业的方式提供帮助。

Project Cover

讯飞绘镜

讯飞绘镜是一个支持从创意到完整视频创作的智能平台,用户可以快速生成视频素材并创作独特的音乐视频和故事。平台提供多样化的主题和精选作品,帮助用户探索创意灵感。

Project Cover

讯飞文书

讯飞文书依托讯飞星火大模型,为文书写作者提供从素材筹备到稿件撰写及审稿的全程支持。通过录音智记和以稿写稿等功能,满足事务性工作的高频需求,帮助撰稿人节省精力,提高效率,优化工作与生活。

Project Cover

阿里绘蛙

绘蛙是阿里巴巴集团推出的革命性AI电商营销平台。利用尖端人工智能技术,为商家提供一键生成商品图和营销文案的服务,显著提升内容创作效率和营销效果。适用于淘宝、天猫等电商平台,让商品第一时间被种草。

Project Cover

AIWritePaper论文写作

AIWritePaper论文写作是一站式AI论文写作辅助工具,简化了选题、文献检索至论文撰写的整个过程。通过简单设定,平台可快速生成高质量论文大纲和全文,配合图表、参考文献等一应俱全,同时提供开题报告和答辩PPT等增值服务,保障数据安全,有效提升写作效率和论文质量。

投诉举报邮箱: service@vectorlightyear.com
@2024 懂AI·鲁ICP备2024100362号-6·鲁公网安备37021002001498号