ここにいくつかの基本的な機能を持つスクリプトがあります: 関数1 - wget、Webページを開いてローカル変数に保存して閉じます。 機能2 - このWebページでmd5ハッシュ値をスクレイプします。 関数3 - ハッシュ値を取得し、よく使用されるパスワードの辞書を使用してハッシュ値をクラックします。ある関数の出力を他の関数の入力として入力する方法がわかりません
私の問題は、関数2の出力を関数3に挿入することです。これは、関数2の出力がリストであり、関数3がハッシュ値だけを探していることが原因です。
皆さんは私のコードを読めばもっと理解できるはずですが、これまでのところ私のコードです。
import sys, hashlib, re, urllib
def wget(url): # could import webpage_get and use wget() from there instead
'''Read the contents of a webpage from a specified URL'''
print '[+]---------------------------------------------------------------------------- ' #CHANGE THIS
# open URL
webpage = urllib.urlopen(url) # opens url like a file
# get page contents
page_contents = webpage.read() # reads content of webpage
return page_contents
page_contents = webpage.close() # close webpage
def findmd5(text):
'''Find all md5 hash values'''
md5value = re.findall(r'([a-fA-F\d]{32})', text)
count = len(md5value)
print "[+] Total number of md5 hash values found: %s" % count
for x in md5value:
print x
def dict_attack(passwd_hash):
dic = ['123','1234','12345','123456','1234567','12345678','password','qwerty','abc','abcd','abc123','111111','monkey','arsenal','letmein','trustno1','dragon','baseball','superman','iloveyou','starwars','montypython','cheese','123123','football','password','batman']
passwd_found = False
for value in dic:
hashvalue = hashlib.md5(value).hexdigest()
if hashvalue == passwd_hash:
passwd_found = True
recovered_password = value
if passwd_found == True:
print '[+] Password recovered: %s'% (recovered_password)
else:
print '[-] Password not recovered'
def main():
# temp testing url argument
sys.argv.append('URL HERE!')
# Check args
if len(sys.argv) != 2:
print '[-] Usage: email_analysis URL/filename'
return
#call functions
try:
print '[+] md5 values found: '
print findmd5(wget(sys.argv[1]))
print '[+] Cracking hash values: '
except IOError:
print 'Error'
if __name__ == '__main__':
main()
ご協力いただきありがとうございます。
1時間以内にこの同じ割り当てについて質問がありました。あなたはクラスメートと一緒に仕事ができますか? – TigerhawkT3