Anashel commited on
Commit
cfd1255
1 Parent(s): 6d20482

Delete PickelScan-SafeResult

Browse files
PickelScan-SafeResult/PickleScan-Instructions.txt DELETED
@@ -1,6 +0,0 @@
1
- Scan model for Pickle issues. Put the pickle_scan.py at the root of your Automatic1111 folder. Open a windows command prompt window and enter the following command. Replace the <insert your path> with the location of your Automatic1111 folder. You need to have SD WebUI running for the path \venv\ to work. Keep the "" in the 2nd command. The result of the scan will be in your Automatic1111 root folder under the name scan_output.txt.
2
-
3
-
4
- Command 1: CD <Insert your path>\stable-diffusion-webui\
5
-
6
- Command 2: "<Insert your path>\stable-diffusion-webui\venv\Scripts\Python.exe" pickle_scan.py models > scan_output.txt
 
 
 
 
 
 
 
PickelScan-SafeResult/RPG-v2-PickleScanResult.txt DELETED
@@ -1,7 +0,0 @@
1
- checking dir: models
2
-
3
- ...models/Stable-diffusion/RPG-v2-pruned.ckpt
4
- SCAN PASSED!
5
-
6
- ...models/Stable-diffusion/RPG-v2.ckpt
7
- SCAN PASSED!
 
 
 
 
 
 
 
 
PickelScan-SafeResult/pickle_scan.py DELETED
@@ -1,77 +0,0 @@
1
- # copyright zxix 2022
2
- # https://creativecommons.org/licenses/by-nc-sa/4.0/
3
- import torch
4
- import pickle_inspector
5
- import sys
6
- from pathlib import Path
7
-
8
- debug = len(sys.argv) == 3
9
-
10
- dir = sys.argv[1]
11
- print("checking dir: " + dir)
12
-
13
- BASE_DIR = Path(dir)
14
- EXTENSIONS = {'.pt', '.bin', '.ckpt'}
15
- BAD_CALLS = {'os', 'shutil', 'sys', 'requests', 'net'}
16
- BAD_SIGNAL = {'rm ', 'cat ', 'nc ', '/bin/sh '}
17
-
18
- for path in BASE_DIR.glob(r'**/*'):
19
- if path.suffix in EXTENSIONS:
20
- print("")
21
- print("..." + path.as_posix())
22
- result = torch.load(path.as_posix(), pickle_module=pickle_inspector.pickle)
23
- result_total = 0
24
- result_other = 0
25
- result_calls = {}
26
- result_signals = {}
27
- result_output = ""
28
-
29
- for call in BAD_CALLS:
30
- result_calls[call] = 0
31
-
32
- for signal in BAD_SIGNAL:
33
- result_signals[signal] = 0
34
-
35
- for c in result.calls:
36
- for call in BAD_CALLS:
37
- if (c.find(call + ".") == 0):
38
- result_calls[call] += 1
39
- result_total += 1
40
- result_output += "\n--- found lib call (" + call + ") ---\n"
41
- result_output += c
42
- result_output += "\n---------------\n"
43
- break
44
- for signal in BAD_SIGNAL:
45
- if (c.find(signal) > -1):
46
- result_signals[signal] += 1
47
- result_total += 1
48
- result_output += "\n--- found malicious signal (" + signal + ") ---\n"
49
- result_output += c
50
- result_output += "\n---------------\n"
51
- break
52
-
53
- if (
54
- c.find("numpy.") != 0 and
55
- c.find("_codecs.") != 0 and
56
- c.find("collections.") != 0 and
57
- c.find("torch.") != 0):
58
- result_total += 1
59
- result_other += 1
60
- result_output += "\n--- found non-standard lib call ---\n"
61
- result_output += c
62
- result_output += "\n---------------\n"
63
-
64
- if (result_total > 0):
65
- for call in BAD_CALLS:
66
- print("library call (" + call + ".): " + str(result_calls[call]))
67
- for signal in BAD_SIGNAL:
68
- print("malicious signal (" + signal + "): " + str(result_signals[signal]))
69
- print("non-standard calls: " + str(result_other))
70
- print("total: " + str(result_total))
71
- print("")
72
- print("SCAN FAILED")
73
-
74
- if (debug):
75
- print(result_output)
76
- else:
77
- print("SCAN PASSED!")