socket数据流丢失_如何在数据丢失防护中使用备用数据流

socket数据流丢失

Have you ever wanted to try out alternate data streams in a legitimate data loss prevention case?

您是否曾经想过在合法的数据丢失防护案例中尝试备用数据流?

I’ve finally had some time this weekend to try out NTFS Alternate Data Streams (ADS) in various network DLP based applications. Although this isn’t really new or surprising to the rest of us security professionals, it is a nifty way to potentially use these technologies in identifying files that may be attempting to leave the perimeter through watermarking. As always, this is merely for informational purposes only, your mileage may vary on applicability and results.

我终于在这个周末有一些时间来尝试各种基于网络DLP的应用程序中的NTFS备用数据流 (ADS)。 尽管这对于我们其余的安全专业人员来说并不是什么新奇的事情或让您感到惊讶,但这是潜在地使用这些技术来识别可能试图通过加水印离开外围的文件的好方法。 与往常一样,这仅出于提供信息的目的,您的里程可能因适用性和结果而异。

This weekend’s mini project provides readers with the following abilities:

这个周末的迷你项目为读者提供以下功能:

  • Allows an administrator to recurse through selected files and automatically add in a hashed string into an alternate data stream for Windows NTFS enabled hosts

    允许管理员递归浏览选定的文件,并自动将散列的字符串添加到启用Windows NTFS的主机的备用数据流中
  • Utilizes a Snort IDS example signature to detect the hash when it is traversing or leaving the network

    利用Snort IDS示例签名在遍历或离开网络时检测哈希
  • General information and cautions using ADS for DLP applications

    将ADS用于DLP应用程序的一般信息和注意事项

为什么选择ADS for DLP? (Why ADS for DLP?)

You might be asking why ADS over water-marking a file directly or some other method (perhaps even MiTM packet based marking). There’s a few reasons for this:

您可能会问,为什么ADS会直接对文件加水印或其他方法(甚至是基于MiTM数据包的标记)。 这有几个原因:

  • In an Windows enterprise environment, any sensitive data that isn’t already encrypted are very likely in various Office document formats (.docx, .pptx, .xlsx) and so forth. These documents have their own structures and do not act like normal CSV or other text only files where you can just append additional information. Attempting to do this corrupts the file structure rendering the data unreadable when opening in the Office suite

    在Windows企业环境中,任何尚未加密的敏感数据很可能以各种Office文档格式 (.docx,.pptx,.xlsx)等等。 这些文档具有自己的结构,不能像普通的CSV或其他仅纯文本的文件那样工作,您可以在其中附加附加信息。 尝试执行此操作会损坏文件结构,从而在Office套件中打开时无法读取数据

  • To actually add data properly to Office based documents requires different scripts and is dependent on the actual format itself for each type. This creates hassle in trying to account for various file types and testing

    要将数据正确正确地添加到基于Office的文档中,需要使用不同的脚本,并且每种类型都取决于实际的格式本身。 这在尝试考虑各种文件类型和测试时带来麻烦

  • In addition, your users or customers may not want to even see something added on such as a file hash anywhere on their document or file for cosmetic or even parsing reasons

    另外,出于修饰甚至分析的原因,您的用户或客户可能甚至不想在其文档或文件的任何位置看到添加的内容,例如文件哈希
  • Hashes can offer very specific content to search based on your data classification level or anything else you want to alert on

    哈希可以根据您的数据分类级别或您要提醒的其他内容提供非常具体的内容以进行搜索

在DLP中不使用ADS的注意事项 (Considerations for not using ADS in DLP)

  • NTFS based ADS specifically is only supported in NTFS based file systems and may not be applicable to all environments. There are other forms of alternate data streams between file systems

    仅基于NTFS的文件系统仅支持基于NTFS的ADS,并且可能不适用于所有环境。 文件系统之间还有其他形式的备用数据流
  • Applications may strip out ADS due to security related practices, support, or other numerous reasons. Examples in our cases I’ve tested this to be true included FileZilla’s FTP client, TeamViewer, some Antivirus vendors, and Skype.

    由于安全相关的做法,支持或其他许多原因,应用程序可能会剥离ADS。 在我们的案例中,我测试过的示例包括FileZilla的FTP客户端,TeamViewer,一些防病毒供应商和Skype。
  • The detection of ADS using “DIR /R” is available in Vista hosts and newer. Additionally, conventional display of a file using standard out does not show your ADS contents. Using pipes and other methods can be used as a work around.

    Vista主机及更高版本中提供了使用“ DIR / R”检测ADS的功能。 此外,使用标准输出的常规文件显示不会显示您的ADS内容。 使用管道和其他方法可以解决。

  • Performance considerations for adding extra work for your network IDS or IPS

    为网络IDS或IPS添加额外工作的性能注意事项

案例测试实验室设置: (Case Test Lab Setup:)

  • Mac and Windows host on the same virtualized network segment using SMB over TCP and SAMBA

    Mac和Windows使用TCP和SAMBA上的SMB托管在同一虚拟网段上
  • Snort 2.9.6.1 , Snort.conf “tuned down” to exclude dynamic pre-procs, all other rules, fast alerting on, and local.rules to include an example custom signature.

    Snort 2.9.6.1,“ Snort.conf”已“调低”以排除动态预进程,所有其他规则,快速警报开启以及local.rules以包括示例自定义签名。
  • Wireshark

    Wireshark
  • Online Text to SHA 256 Converter (or any other hashing tool)

    在线文本转SHA 256转换器 (或任何其他哈希工具)

强调: (Highlights:)

We start off by creating an alternate data stream on some test files. It doesn’t matter what file you use, or what name, or even what hash. We simply redirect the contents of hash.txt into a new data stream. Using find or findstr with a negate switch can show us our hash within the stream created.

我们首先在一些测试文件上创建备用数据流。 使用什么文件,什么名称,甚至什么哈希都没有关系。 我们只需将hash.txt的内容重定向到新的数据流中。 将find或findstr与否定开关一起使用可以向我们显示创建的流中的哈希。

Next, we can create a example Snort rule to detect that string for DLP purposes. Note, that this is only an example rule and is NOT tuned for performance. You should use content modifiers depending on the type and size of data you’re using in accordance with your sensor performance:. Notice that I used rawbytes; as your Snort pre-processors may not always parse the ADS in the manner you want.

接下来,我们可以创建一个示例Snort规则来检测该字符串以用于DLP。 请注意,这只是一个示例规则,并未针对性能进行调整。 您应该根据传感器的性能,根据所使用数据的类型和大小使用内容修饰符: 注意,我使用了rawbytes。 因为您的Snort预处理器可能并不总是以您想要的方式解析ADS。

Image for post

Next, setup a simple CIFS/SMB/SAMBA share or any other clear text protocol that you can detect and start a capture between the hosts. You should notice that while the data streams are different being traversed over, this should still be within the same TCP stream.

接下来,设置一个简单的CIFS / SMB / SAMBA共享或任何其他可检测到并在主机之间进行捕获的明文协议。 您应注意,尽管遍历数据流不同,但它们仍应位于同一TCP流中。

Image for post

Reconstruct the stream and now you can see both the original text AND the hash that you’ve added.

重建流,现在您既可以看到原始文本,也可以看到添加的哈希。

Image for post
Image for post

Either save your pcap and run it with snort in read mode or have in NIDS mode. Using the signature we created earlier, we can see numerous alerts.

保存您的pcap并在读取模式下以snort方式运行它,或者在NIDS模式下运行。 使用我们之前创建的签名,我们可以看到大量警报。

Image for post

自动化 (Automation)

If you’re thinking “So what? You’ve added a hash that can be detected via ADS to ONE file. how am I supposed to do this as a mass? How do I even know which files to perform ADS on?” Well, that’s really dependent on your organizational requirements and resources. You’ll have to work on identifying and discovering data to classify and tag.

如果您在想“那又如何? 您已将可以通过ADS检测到的哈希添加到一个文件中。 我应该怎么做? 我什至不知道要对哪些文件执行ADS?” 好吧,这实际上取决于您的组织要求和资源。 您将不得不识别和发现数据以进行分类和标记。

You might be able to use a dirty words list or other indicators and perform counts per file and use basic probability to help ID data you need to mark. To assist with performing ADS on multiple directories and folders recursively, I’ve started a small batch script to assist with this. I can’t stress enough that you need to test, tune, and validate before you use this on any production data. Make sure to have backups!

您可能可以使用脏话列表或其他指标,并对每个文件进行计数,并使用基本概率来帮助您标记所需的ID数据。 为了帮助递归地在多个目录和文件夹上执行ADS,我启动了一个小批处理脚本来协助完成此任务。 我无法承受太大的压力,您需要先对它们进行测试,调整和验证,然后再将其用于任何生产数据。 确保有备份!

Image for post
Image for post

ADS的其他用例 (Other Use Cases for ADS)

There are also not so legitimate use cases for ADS. One method is to hide data in different files by payload injection and to call it externally from other shell commands or exploits. The researcher, enigma0x3 show cases his solution involving Powershell scripts to inject ADS based payload in user and administrative context methods. The full write up can be found here.

ADS也没有那么合法的用例。 一种方法是通过有效负载注入将数据隐藏在不同的文件中,并从其他Shell命令或漏洞利用程序外部调用它。 研究人员enigma0x3展示了他的解决方案,其中涉及使用Powershell脚本在用户和管理上下文方法中注入基于ADS的有效负载。 完整的文章可以在这里找到。

Find out about more ways to bolster your cyber defense operations at: www.scissecurity.com

www.scissecurity.com上找到有关增强网络防御运营的更多方法的信息。

翻译自: https://medium.com/swlh/using-alternate-data-streams-in-data-loss-prevention-ff0c2e57af6c

socket数据流丢失

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
【优质项目推荐】 1、项目代码均经过严格本地测试,运行OK,确保功能稳定后才上传平台。可放心下载并立即投入使用,若遇到任何使用问题,随时欢迎私信反馈与沟通,博主会第一时间回复。 2、项目适用于计算机相关专业(如计科、信息安全、数据科学、人工智能、通信、物联网、自动化、电子信息等)的在校学生、专业教师,或企业员工,小白入门等都适用。 3、该项目不仅具有很高的学习借鉴价值,对于初学者来说,也是入门进阶的绝佳选择;当然也可以直接用于 毕设、课设、期末大作业或项目初期立项演示等。 3、开放创新:如果您有一定基础,且热爱探索钻研,可以在此代码基础上二次开发,进行修改、扩展,创造出属于自己的独特应用。 欢迎下载使用优质资源!欢迎借鉴使用,并欢迎学习交流,共同探索编程的无穷魅力! 基于业务逻辑生成特征变量python实现源码+数据集+超详细注释.zip基于业务逻辑生成特征变量python实现源码+数据集+超详细注释.zip基于业务逻辑生成特征变量python实现源码+数据集+超详细注释.zip基于业务逻辑生成特征变量python实现源码+数据集+超详细注释.zip基于业务逻辑生成特征变量python实现源码+数据集+超详细注释.zip基于业务逻辑生成特征变量python实现源码+数据集+超详细注释.zip基于业务逻辑生成特征变量python实现源码+数据集+超详细注释.zip 基于业务逻辑生成特征变量python实现源码+数据集+超详细注释.zip 基于业务逻辑生成特征变量python实现源码+数据集+超详细注释.zip
提供的源码资源涵盖了安卓应用、小程序、Python应用和Java应用等多个领域,每个领域都包含了丰富的实例和项目。这些源码都是基于各自平台的最新技术和标准编写,确保了在对应环境下能够无缝运行。同时,源码配备了详细的注释和文档,帮助用户快速理解代码结构和实现逻辑。 适用人群: 这些源码资源特别适合大学生群体。无论你是计算机相关专业的学生,还是对其他领域编程感兴趣的学生,这些资源都能为你提供宝贵的学习和实践机会。通过学习和运行这些源码,你可以掌握各平台开发的基础知识,提升编程能力和项目实战经验。 使用场景及目标: 在学习阶段,你可以利用这些源码资源进行课程实践、课外项目或毕业设计。通过分析和运行源码,你将深入了解各平台开发的技术细节和最佳实践,逐步培养起自己的项目开发和问题解决能力。此外,在求职或创业过程,具备跨平台开发能力的大学生将更具竞争力。 其他说明: 为了确保源码资源的可运行性和易用性,特别注意了以下几点:首先,每份源码都提供了详细的运行环境和依赖说明,确保用户能够轻松搭建起开发环境;其次,源码的注释和文档都非常完善,方便用户快速上手和理解代码;最后,我会定期更新这些源码资源,以适应各平台技术的最新发展和市场需求。
以下是一个使用 socket 自定义数据帧传输视频流的示例代码: ```python import cv2 import numpy as np import struct import socket # 定义视频编解码器 fourcc = cv2.VideoWriter_fourcc(*'XVID') # 打开本地摄像头 cap = cv2.VideoCapture(0) # 设置视频帧大小 cap.set(cv2.CAP_PROP_FRAME_WIDTH, 640) cap.set(cv2.CAP_PROP_FRAME_HEIGHT, 480) # 定义数据帧头部 HEADERSIZE = 4 # 定义服务器 IP 和端口号 SERVER_IP = 'localhost' SERVER_PORT = 1234 # 创建 socket 对象 s = socket.socket(socket.AF_INET, socket.SOCK_STREAM) s.connect((SERVER_IP, SERVER_PORT)) # 不断读取视频帧并传输 while True: # 读取视频帧 ret, frame = cap.read() # 编码视频帧 _, img_encoded = cv2.imencode('.jpg', frame, [cv2.IMWRITE_JPEG_QUALITY, 90]) # 构造数据帧 msg = struct.pack('>I', len(img_encoded)) + img_encoded # 发送数据帧 s.sendall(msg) # 接收服务器确认信息 data = s.recv(1024) print(data.decode()) # 关闭 socket 对象和摄像头 s.close() cap.release() ``` 在服务器端,我们可以使用以下代码来接收数据帧并显示视频流: ```python import cv2 import numpy as np import struct import socket # 定义视频编解码器 fourcc = cv2.VideoWriter_fourcc(*'XVID') # 创建 VideoWriter 对象 out = cv2.VideoWriter('output.avi', fourcc, 20.0, (640, 480)) # 定义数据帧头部 HEADERSIZE = 4 # 定义服务器 IP 和端口号 SERVER_IP = 'localhost' SERVER_PORT = 1234 # 创建 socket 对象并绑定端口号 s = socket.socket(socket.AF_INET, socket.SOCK_STREAM) s.bind((SERVER_IP, SERVER_PORT)) s.listen(1) # 等待客户端连接 conn, addr = s.accept() print('Connected by', addr) # 不断接收数据帧并显示 while True: # 接收数据帧头部 data = conn.recv(HEADERSIZE) # 如果头部为空,说明客户端已经关闭连接 if not data: break # 解析数据帧头部,获取数据帧大小 msglen = struct.unpack('>I', data)[0] # 接收数据帧 data = conn.recv(msglen) # 将数据帧转换成图像 img = cv2.imdecode(np.frombuffer(data, np.uint8), cv2.IMREAD_COLOR) # 显示图像 cv2.imshow('frame', img) # 写入视频文件 out.write(img) # 发送确认信息 conn.sendall(b'OK') # 按下 q 键退出循环 if cv2.waitKey(1) & 0xFF == ord('q'): break # 关闭 socket 对象和视频文件 conn.close() s.close() out.release() cv2.destroyAllWindows() ``` 注意:这只是一个简单的示例代码,实际应用需要考虑数据丢失和重传,以及帧率、码率等问题。

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值