-
Notifications
You must be signed in to change notification settings - Fork 0
/
crack.src
101 lines (91 loc) · 2.93 KB
/
crack.src
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
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
// command: crack
// --- Globals ---------------------------------------
NEWLINE = char(10)
crypto = null
// --- Global Functions ------------------------------
// Home dir of active user
get_user_home = function()
if active_user == "root" then return "/root"
return "/home/" + active_user
end function
// Get hash cache
get_hashes_file = function()
config_dir = get_user_home + "/Config"
computer = get_shell.host_computer
hashes_file = computer.File(config_dir + "/Hashes.txt")
if hashes_file == null then
computer.touch(config_dir, "Hashes.txt")
hashes_file = computer.File(config_dir + "/Hashes.txt")
hashes_file.chmod("o-rwx")
hashes_file.chmod("g-rwx")
if active_user == "root" then hashes_file.chmod("u-rwx")
end if
return hashes_file
end function
get_cached_hash_value = function(hash)
hashes_file = get_hashes_file
lines = hashes_file.get_content.split("\n")
for line in lines
line_parts = line.split("=")
if line_parts[0] == hash then return line_parts[1]
end for
return null
end function
save_hash_to_cache = function(hash, hash_value)
hashes_file = get_hashes_file
hash_line = hash + "=" + hash_value
hashes_file_content = hashes_file.get_content
if hashes_file_content != "" then hashes_file_content = hashes_file_content + NEWLINE
hashes_file.set_content(hashes_file_content + hash_line)
end function
get_crypto = function()
if globals.crypto == null then
crypto = include_lib("/lib/crypto.so")
if not crypto then crypto = include_lib(current_path + "/crypto.so")
if not crypto then
exit("<color=#FF0000>Error: Can't find crypto library in the /lib path or the current folder</color>")
end if
globals.crypto = crypto
end if
return globals.crypto
end function
crack = function(hash)
if hash.indexOf(":") != null then hash = hash.split(":")[1]
result = get_cached_hash_value(hash)
if result == null then
result = get_crypto.decipher(hash)
save_hash_to_cache(hash, result)
end if
return result
end function
crack_file = function(file)
contents = file.get_content
print
print("<b>" + file.name + "contents:</b>")
lines = contents.split("\n")
i = 0
for line in lines
if line.trim == "" then continue
print(" <b>[" + i + "]</b> " + line)
i = i + 1
end for
print
choice = 0
if lines.len > 1 then choice = user_input("<b>Decipher which line?</b> ").to_int
if choice != null then
line_tokens = lines[choice].split(":")
user = line_tokens[0]
password = crack(line_tokens[1])
print("<b>User:</b> " + user)
print("<b>Password:</b> " + password)
end if
end function
// --- MAIN ------------------------------------------
path = params[0]
if path[0] != "/" then path = current_path + "/" + path
file = get_shell.host_computer.File(path)
if file != null then
crack_file(file)
else
print("<b>Value:</b> " + crack(params[0]))
end if