import os,sys
from unrar import rarfile
import datetime
date_list = []
def rar_cracking2():
fp = rarfile.RarFile('pwd.rar')
# fpPwd = open('pwd.txt')
for pwd in date_list:
pwd = pwd.rstrip()
print(pwd)
try:
fp.extractall( pwd=pwd )
# fp.extractall(path='x', pwd=pwd.encode())
print('[+] Find the password: '+pwd)
fp.close()
break
except:
# print('error: '+pwd)
pass
# fpPwd.close()
def rar_cracking():
# fpPwd = open('pwd.txt')
for pwd in date_list:
pwd = pwd.rstrip()
print(pwd)
try:
fp = rarfile.RarFile('x.rar', mode='r', pwd=pwd)
# fp.extractall( pwd=pwd )
# fp.extractall(path='x', pwd=pwd.encode())
print('[+] Find the password: '+pwd)
fp.close()
break
except:
# print('error: '+pwd)
pass
# fpPwd.close()
def genpwd():
# 导入datetime模块
# 定义开始日期和结束日期
start_date = datetime.date(2022, 3, 1)
end_date = datetime.date(2022, 5, 30)
# 使用while循环,从开始日期逐天增加,直到结束日期
while start_date <= end_date:
# 将日期转换为字符串,格式为YYYYMMDD
date_str = start_date.strftime("%Y-%m-%d")
# 将字符串添加到列表中
date_list.append(date_str)
# 将开始日期增加一天
start_date += datetime.timedelta(days=1)
start_date = datetime.date(2023, 3, 1)
end_date = datetime.date(2023, 5, 30)
# 使用while循环,从开始日期逐天增加,直到结束日期
while start_date <= end_date:
# 将日期转换为字符串,格式为YYYYMMDD
date_str = start_date.strftime("%Y-%m-%d")
# 将字符串添加到列表中
date_list.append(date_str)
# 将开始日期增加一天
start_date += datetime.timedelta(days=1)
start_date = datetime.date(2022, 3, 1)
end_date = datetime.date(2022, 5, 30)
# 使用while循环,从开始日期逐天增加,直到结束日期
while start_date <= end_date:
# 将日期转换为字符串,格式为YYYYMMDD
date_str = start_date.strftime("%y-%m-%d")
# 将字符串添加到列表中
date_list.append(date_str)
# 将开始日期增加一天
start_date += datetime.timedelta(days=1)
start_date = datetime.date(2023, 3, 1)
end_date = datetime.date(2023, 5, 30)
# 使用while循环,从开始日期逐天增加,直到结束日期
while start_date <= end_date:
# 将日期转换为字符串,格式为YYYYMMDD
date_str = start_date.strftime("%y-%m-%d")
# 将字符串添加到列表中
date_list.append(date_str)
# 将开始日期增加一天
start_date += datetime.timedelta(days=1)
# 打印列表
print(date_list)
if __name__=='__main__':
# filename = sys.argv[1]
# filename = sys.argv[1]
# if os.path.isfile(filename) and filename.endswith('.rar'):
# rar_cracking( )genpwd
# rar_cracking(filename)
# else:
# print('Not a rar file')
genpwd()
rar_cracking( )