惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

Vercel News
Vercel News
SecWiki News
SecWiki News
WordPress大学
WordPress大学
小众软件
小众软件
博客园 - 司徒正美
酷 壳 – CoolShell
酷 壳 – CoolShell
V
Visual Studio Blog
Y
Y Combinator Blog
freeCodeCamp Programming Tutorials: Python, JavaScript, Git & More
云风的 BLOG
云风的 BLOG
MyScale Blog
MyScale Blog
K
Kaspersky official blog
T
The Exploit Database - CXSecurity.com
腾讯CDC
Scott Helme
Scott Helme
I
InfoQ
Cyberwarzone
Cyberwarzone
Cyber Security Advisories - MS-ISAC
Cyber Security Advisories - MS-ISAC
Security Latest
Security Latest
The Register - Security
The Register - Security
Project Zero
Project Zero
F
Fortinet All Blogs
C
CERT Recently Published Vulnerability Notes
A
Arctic Wolf
C
Cisco Blogs
L
LINUX DO - 热门话题
P
Privacy International News Feed
IT之家
IT之家
U
Unit 42
P
Privacy & Cybersecurity Law Blog
H
Help Net Security
K
KPMG report finds enterprise disconnect between AI and its ROI | CIO
C
Cyber Attacks, Cyber Crime and Cyber Security
P
Palo Alto Networks Blog
F
Full Disclosure
宝玉的分享
宝玉的分享
Simon Willison's Weblog
Simon Willison's Weblog
L
Lohrmann on Cybersecurity
Google DeepMind News
Google DeepMind News
cs.CL updates on arXiv.org
cs.CL updates on arXiv.org
H
Hacker News: Front Page
Know Your Adversary
Know Your Adversary
PCI Perspectives
PCI Perspectives
Hugging Face - Blog
Hugging Face - Blog
AWS News Blog
AWS News Blog
MongoDB | Blog
MongoDB | Blog
S
Schneier on Security
Recent Announcements
Recent Announcements
Forbes - Security
Forbes - Security
Cisco Talos Blog
Cisco Talos Blog

打工人日志

2026-05-28 打工人日报 2026-05-27 打工人日报 2026-05-26 打工人日报 2026-05-25 打工人日报 2026-05-24 打工人日报 2026-05-23 打工人日报 2026-05-22 打工人日报 2026-05-21 打工人日报 2026-05-20 打工人日报 2026-05-19 打工人日报 2026-05-18 打工人日报 2026-05-17 打工人日报 2026-05-16 打工人日报 2026-05-15 打工人日报 2026-05-14 打工人日报 2026-05-13 打工人日报 2026-05-12 打工人日报 2026-05-11 打工人日报 2026-05-10 打工人日报 2026-05-09 打工人日报 2026-05-08 打工人日报 2026-05-07 打工人日报 2026-05-06 打工人日报 2026-05-05 打工人日报 2026-05-04 打工人日报 2026-05-03 打工人日报 2026-05-02 打工人日报 2026-05-01 打工人日报 2026-04-30 打工人日报 2026-04-29 打工人日报 2026-04-28 打工人日报 2026-04-27 打工人日报 2026-04-26 打工人日报 2026-04-25 打工人日报 2026-04-24 打工人日报 2026-04-23 打工人日报 2026-04-22 打工人日报 2026-04-21 打工人日报 2026-04-20 打工人日报 2026-04-19 打工人日报 2026-04-18 打工人日报 2026-04-17 打工人日报 2026-04-16 打工人日报 2026-04-15 打工人日报 2026-04-14 打工人日报 2026-04-13 打工人日报 2026-04-12 打工人日报 2026-04-11 打工人日报 2026-04-10 打工人日报 2026-04-09 打工人日报 2026-04-08 打工人日报 2026-04-07 打工人日报 2026-04-06 打工人日报 2026-04-05 打工人日报 2026-04-04 打工人日报 2026-04-03 打工人日报 2026-04-02 打工人日报 2026-04-01 打工人日报 2026-03-31 打工人日报 2026-03-30 打工人日报 2026-03-29 打工人日报 2026-03-28 打工人日报 2026-03-27 打工人日报 2026-03-26 打工人日报 2026-03-25 打工人日报 2026-03-24 打工人日报 2026-03-23 打工人日报 2026-03-22 打工人日报 2026-03-21 打工人日报 2026-03-20 打工人日报 2026-03-19 打工人日报 2026-03-18 打工人日报 2026-03-17 打工人日报 2026-03-16 打工人日报 2026-03-15 打工人日报 2026-03-14 打工人日报 2026-03-13 打工人日报 2026-03-12 打工人日报 2026-03-11 打工人日报 2026-03-10 打工人日报 2026-03-09 打工人日报 2026-03-08 打工人日报 2026-03-07 打工人日报 2026-03-06 打工人日报 2026-03-05 打工人日报 2026-03-04 打工人日报 2026-03-03 打工人日报 2026-03-02 打工人日报 2026-03-01 打工人日报 2026-02-28 打工人日报 2026-02-27 打工人日报 2026-02-26 打工人日报 2026-02-25 打工人日报 2026-02-24 打工人日报 2026-02-23 打工人日报 2026-02-22 打工人日报 2026-02-21 打工人日报 2026-02-20 打工人日报 2026-02-19 打工人日报 2026-02-18 打工人日报
异常流量分析:图片库服务黑客入侵
2025-03-25 · via 打工人日志

背景

最近这两天prometheus一直再对服务器的下行带宽告警,检查告警发现是一台图片服务器,这台图片服务器是很早部署的一台nginx反向代理本地静态文件的服务器,当时没有做任何的安全防护,只是简单做了一个上传接口暴露给外网,导致这台服务器被黑客入侵,上传了大量文件,同时对这些文件有大量的下载请求,导致服务器的带宽被打满,同时也导致了prometheus的告警。

发现

  1. 发现这台服务器的带宽被打满了,所以只能先从这台服务器开始排查。先检查nginx所有大量请求的日志
1cd /var/log/nginx
2awk '{print $7}' access.log | sort | uniq -c | sort -nr | head -n 10

server-log

  1. 这个是一个图片服务器,看起来都是图片的请求,好像没有发现异常的请求。但是这个图片为什么有那么高的流量呢?检查这个图片,发现图片无法打开,所以我换二进制的方式打开图片
    hex-open

发现图片的二进制头部是 FFmpeg, 所以这是一个伪装成图片的视频文件

解决

  1. 检查nginx的配置文件,上传接口拒绝所有外部请求
server{
    location /upload {
        proxy_pass http://192.168.1.1:8080;

        # 拒绝所有外部请求
        allow 192.168.1.0/24;
        deny all;
    }
}
  1. 查找最早上传的文件,创建python文件,并在图片服务器执行
import os

# 查找最早包含 FFmpeg 的 JPG 文件
def find_earliest_jpg_with_ffmpeg(directory):
    earliest_file = None
    earliest_timestamp = float('inf')

    for root, dirs, files in os.walk(directory):
        for file in files:
            if file.lower().endswith('.jpg'):
                file_path = os.path.join(root, file)
                try:
                    with open(file_path, 'rb') as f:
                        file_header = f.read(55)
                        print(file_header)
                        f.close()
                        if b'FFmpeg\tService01' in file_header:
                            timestamp = os.path.getmtime(file_path)
                            if timestamp < earliest_timestamp:
                                earliest_timestamp = timestamp
                                earliest_file = file_path
                except Exception as e:
                    print(f"Error processing file {file_path}: {e}")

    if earliest_file:
        print(f"最早的包含 FFmpeg 的 JPG 文件是: {earliest_file}")

# 调用函数并传入目录路径
find_earliest_jpg_with_ffmpeg('/var/www/html/images/')
  1. 删除这些FFmpeg文件,创建python文件,并在图片服务器执行
import os

# 检查文件头是否包含 FFmpeg
def delete_file_if_header_contains_ffmpeg(file_path):
    try:
        with open(file_path, 'rb') as file:
            file_header = file.read(55)
            print(f"检查文件: {file_path},文件头: {file_header}")
            file.close()
            if b'FFmpeg\tService01' in file_header:
                os.remove(file_path)
                print(f"文件 {file_path} 已被删除")
            else:
                print(f"文件 {file_path} 不符合删除条件")
    except FileNotFoundError:
        print(f"文件 {file_path} 找不到")
    except Exception as e:
        print(f"发生错误: {e}")

# 遍历目录并删除 JPG 文件
def traverse_and_delete_jpg_files(directory):
    try:
        for root, dirs, files in os.walk(directory):
            for file in files:
                if file.lower().endswith('.jpg'):
                    file_path = os.path.join(root, file)
                    delete_file_if_header_contains_ffmpeg(file_path)
    except Exception as e:
        print(f"遍历目录时发生错误: {e}")

# 调用函数并传入目录路径
traverse_and_delete_jpg_files('/var/www/html/images/')

总结

大家一定要增加服务器权限的管控,开放到外部的接口,一定要做好访问权限控制,避免被有心人利用。