-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathexample.py
86 lines (77 loc) · 3.28 KB
/
example.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
#!/usr/bin/python
# =======================
# pyShadow - Example Codes
# =======================
from src.reshadow import ReShadowCode, TerminalColor
# Global variables
TerminalColor.__init__()
shadowcopy_list = ReShadowCode.VSS_ListShadows()
def rescue_file(src, dst, disk):
try:
print("=============================================================")
for shadowlist in shadowcopy_list:
print("ID : " + str(shadowlist["id"]).replace("{", "").replace("}", "") + "\nDate : " + shadowlist["creation_time"] + "\n")
print("=============================================================")
id = str(input("Recover ID : "))
if id is None or id == "":
return "ERROR : ID is empty"
else:
print(ReShadowCode.VSS_Create_PipeForeach(disk + ":\\" + id, shadowlist["shadowcopy"]))
# Rescue file from ShadowCopy
ReShadowCode.VSS_CopyFile(disk + ":\\" + id + "\\" + src, dst)
ReShadowCode.VSS_RemoveSymlink(disk + ":\\" + id)
print("File recovered successfully")
except Exception as e:
print(f"Error: {e}")
def create_pipe(disk):
try:
for shadowlist in shadowcopy_list:
print("ID : " + shadowlist["id"] + "\nCreation Date : " + shadowlist["creation_time"] + "\nShadow Copy Location : " + shadowlist["shadowcopy"] + "\n")
ReShadowCode.VSS_Create_PipeForeach(disk + ":\\" + shadowlist["id"].replace("{", "").replace("}", ""), shadowlist["shadowcopy"])
except Exception as e:
print(f"Error: {e}")
def list_shadowcopy():
try:
for shadowlist in shadowcopy_list:
print("ID : " + shadowlist["id"] + "\nCreation Date : " + shadowlist["creation_time"] + "\nShadow Copy Location : " + shadowlist["shadowcopy"] + "\n")
except Exception as e:
print(f"Error: {e}")
def create_vss():
try:
ReShadowCode.VSS_Create()
except Exception as e:
print(f"Error: {e}")
def main():
print("=============================================================")
print(" pyShadow - The ShadowCopy Extractor / File Rescue Tool\n Version 1.0.0\n Copyright (c) 2024, Reshadow")
print("=============================================================")
print("1. Rescue File from ShadowCopy (Testing)")
print("2. Create Pipe / Symlink for ShadowCopy")
print("3. List ShadowCopy")
print("4. Create VSS")
print("5. Exit")
choice = int(input("Enter your choice : "))
if choice == 1:
disk = input("Write Windows Disk Drive (Example : C, D, E) : ")
if len(disk) >= 2:
return main()
else:
src = input("Directory of the file to be recovered : ")
dest = input("The directory to which the recovered files will be copied : ")
rescue_file(src, dest, disk.upper())
elif choice == 2:
disk = input("Write Windows Disk Drive (Example : C, D, E) : ")
if len(disk) >= 2:
return main()
else:
create_pipe(disk.upper())
elif choice == 3:
list_shadowcopy()
elif choice == 4:
create_vss()
elif choice == 5:
exit()
else:
return main()
if __name__ == '__main__':
main()