一位计算机科学工程师,作为加密世界的一部分,必须了解黑客的基础知识。黑客是指获取对我们来说不应该拥有的系统访问权限的过程。

比如,未经授权登录电子邮件账户是黑客行为的一部分。未经授权访问计算机或手机也是黑客行为。用户可以使用多种方式黑入系统,但黑客的基本概念是相同的,即未经任何身份验证就侵入系统。

道德黑客

道德黑客不仅限于破解密码或窃取数据。道德黑客用于扫描漏洞并发现计算机系统或网络上的潜在威胁。道德黑客会找到系统、应用程序或网络的弱点或漏洞,并将其报告给组织。

有不同类型的黑客,以下是一些:

  • 黑帽黑客 黑帽黑客是以不道德的方式进入网站,窃取管理员门户网站上的数据或篡改数据的人。他们通常出于个人利润或滥用个人数据的目的而这样做。他们的主要目的是对公司造成严重损害,这甚至可能导致危险后果。
  • 白帽黑客 这类黑客的工作是寻找漏洞并合法地向组织或公司报告它们。他们被授权为测试和检查网络或网站中的漏洞的用户,并将结果报告给开发人员或授权人。白帽黑客通常会从公司本身获得有关他们正在测试的网站或网络系统的所有所需信息。他们在获得授权后才入侵系统。他们这样做是为了能够在将来防止恶意黑客入侵网站。
  • 灰帽黑客 这类黑客获取网站或网络的数据并违反了网络法律。但他们与黑帽黑客的意图不同。他们为了公共利益入侵系统,但与白帽黑客不同的是,他们公开利用漏洞,而白帽黑客则为公司或组织私下解决问题。

为什么用户应该使用Python编程进行黑客攻击?

Python语言通常用于一般用途,它是一种高级编程语言。它是一种非常简单和强大的脚本语言,是开源的并且面向对象。Python具有内置库,可用于各种功能,包括黑客攻击。Python非常受欢迎,在市场上有很大的需求。学习如何使用Python进行黑客攻击将有助于更好地理解这种语言。

如何破解密码?

我们知道,网站或文件的密码不以纯文本形式存储在数据库中。在本教程中,我们将破解受密码保护的纯文本密码,这些密码以散列(md5)格式存储。

因此,用户必须输入input_hashed(存储在数据库中的散列密码),然后尝试将其与密码文件中的每个纯文本密码的hashed(md5)进行比较。

当找到散列密码的匹配项时,用户可以显示存储在密码文件中的纯文本密码。但如果在输入密码文件中找不到密码,则会显示“未找到密码”,这只会在发生缓冲区溢出时发生。

这些类型的黑客攻击被视为“字典攻击”。

示例:

import hashlib  
print("# # # # # #  Password Hacking # # # # # #")  
          
# to check if the password is found or not in the text file.  
password_found = 0                                       
   
inputinput_hashed = input(" Please enter the hashed password: ")  
   
password_document = input(" \n Please enter the passwords file name including its path (root / home/): ")  
    
try:  
    # here, we will try to open the passwords text file.  
    password_file = open(password_document, 'r')               
except:  
    print("Error: ")  
    print(password_document, "is not found.\n Please enter the path of file correctly.")  
    quit()  
   
   
# now, for comparing the input_hashed with the hashes of the words present in the password text file for finding the password.  
   
for word in password_file:  
    # to encode the word into utf-8 format  
    encoding_word = word.encode('utf-8')   
               
    # to Hash the word into md5 hash  
    hashed_word = hashlib.md5(encoding_word.strip())    
    
    # to digest that the hash into the hexadecimal value      
    digesting = hashed_word.hexdigest()          
        
    if digesting == input_hashed:  
        # to compare the hashes  
        print ("Password found.\n The required password is: ", word)    
        password_found = 1  
        break  
   
# if the password is not found in the text file.  
if not password_found:  
    print(" The password is not found in the ", password_document, "file")    
    print('\n')  
print(" # # # # # # Thank you # # # # # # ")  

输入 1:

# # # # # #  Password Hacking # # # # # #  
 Please enter the hashed password:  1f23a6ea2da3425697d6446cf3402124  
   
Please enter the passwords file name including its path (root / home/):  passwords.txt  

输出:

Password found.
 The required password is:  manchester123

 # # # # # # Thank you # # # # # #

输入 2:

# # # # # #  Password Hacking # # # # # #  
 Please enter the hashed password:  b24aefc835df9ff09ef4dddc4f817737  
   
 Please enter the passwords file name including its path (root / home/):  passwords.txt  

输出:

Password found.
 The required password is:  heartbreaker07

 # # # # # # Thank you # # # # # #

输入 3:

# # # # # # Password Hacking # # # # # #
Please enter the hashed password: 33816712db4f3913ee967469fe7ee982

Please enter the passwords file name including its path (root / home/): passwords.txt

输出:

The password is not found in the passwords.txt file.

解释:

在上面的代码中,我们首先导入了“hashlib”模块,因为它包含可以以加密方式处理任何原始消息的各种方法。然后用户必须输入散列密码和密码文本文件的位置。然后,用户试图打开文本文件,但如果文本文件在指定位置找不到,它将打印“文件未找到”错误。

然后,我们将输入散列密码与文本文件中的散列单词进行比较以找到正确的密码;为此,我们必须将单词编码为utf-8格式,然后将单词哈希为md5哈希。然后消化哈希单词为十六进制值。

如果消化值等于输入散列密码,它将打印找到的密码并打印正确的密码值。但如果找不到密码,这意味着消化值与输入散列密码不匹配。它将打印“未找到密码”。

结论

在本教程中,我们讨论了Python中的道德黑客,并展示了如何破解密码的示例。

标签: Tkinter教程, Tkinter安装, Tkinter库, Tkinter入门, Tkinter学习, Tkinter入门教程, Tkinter, Tkinter进阶, Tkinter指南, Tkinter学习指南, Tkinter进阶教程, Tkinter编程