This repository has been archived by the owner on Jul 24, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathusr.py
72 lines (64 loc) · 1.53 KB
/
usr.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
#! /usr/bin/env python
import os
import sys
import subprocess
last = ""
files = {""}
pkgs = {""}
hash = {}
size = {}
hashe = {""}
sizee = {""}
opene = {""}
for root, dirs, filesw in os.walk("/"):
flg = False
for arg in sys.argv[1:]:
if(root[0:len("/" + arg)] == "/" + arg):
flg = True
if(flg): continue
for f in filesw:
files.add(root + "/" + f)
last = root + "/" + f
try:
size[last] = os.stat(last).st_size
hash[last] = subprocess.check_output(["/bin/sha256", last]).decode("utf-8").split(" ")[- 1]
except:
opene.add(root + "/" + f)
for root, dirs, filesw in os.walk("./"):
flg = False
for arg in sys.argv[1:]:
if(root[1:len("/" + arg) + 1] == "/" + arg):
flg = True
if(flg): continue
for f in filesw:
pkgs.add(root[1:] + "/" + f)
last = root[1:] + "/" + f
try:
if(hash[last] != subprocess.check_output(["/bin/sha256", root + "/" + f]).decode("utf-8").split(" ")[- 1]):
hashe.add(last)
if(size[last] != os.stat(root + "/" + f).st_size):
sizee.add(last)
except:
opene.add(root + "/" + f)
print("")
print("/ - ./")
for line in sorted(list(files - pkgs)):
if(line[- 1] != "/"):
print(line)
print("")
print("./ - /")
for line in sorted(list(pkgs - files)):
if(line[- 1] != "/"):
print(line)
print("")
print("hash error")
for line in sorted(list(hashe)):
print(line)
print("")
print("size error")
for line in sorted(list(sizee)):
print(line)
print("")
print("open error")
for line in sorted(list(opene)):
print(line)