📜  Python取证-基本取证应用

📅  最后修改于: 2020-11-06 05:27:41             🧑  作者: Mango


对于根据法医准则创建应用程序,了解并遵循其命名约定和模式非常重要。

命名约定

下表描述了在开发Python取证应用程序时要遵循的规则和约定。

Constants Uppercase with underscore separation HIGH_TEMPERATURE
Local variable name Lowercase with bumpy caps (underscores are optional) currentTemperature
Global variable name Prefix gl lowercase with bumpy caps (underscores are optional) gl_maximumRecordedTemperature
Functions name Uppercase with bumpy caps (underscores optional) with active voice ConvertFarenheitToCentigrade(…)
Object name Prefix ob_ lowercase with bumpy caps ob_myTempRecorder
Module An underscore followed by lowercase with bumpy caps _tempRecorder
Class names Prefix class_ then bumpy caps and keep brief class_TempSystem

让我们以一个场景来理解在计算取证中命名约定的重要性。假设我们有一个通常用于加密数据的哈希算法。单向哈希算法将输入作为二进制数据流。这可以是密码,文件,二进制数据或任何数字数据。然后,哈希算法针对输入中接收到的数据生成消息摘要(md)。

创建新的二进制输入来生成给定的消息摘要实际上是不可能的。即使更改了二进制输入数据的单个位,也将生成唯一的消息,该消息与前一个不同。

看一下遵循上述约定的以下示例程序。

import sys, string, md5   # necessary libraries
print "Please enter your full name"
line = sys.stdin.readline()
line = line.rstrip()
md5_object = md5.new()
md5_object.update(line)
print md5_object.hexdigest()   # Prints the output as per the hashing algorithm i.e. md5
exit

上面的程序产生以下输出。

命名约定示例

在此程序中, Python脚本接受输入(您的全名)并根据md5哈希算法将其转换。如果需要,它会加密数据并保护信息。根据法医指南,可以以这种方式确保证据名称或任何其他证据的安全。