forked from hhrhhr/Lua-utils-for-Rebel-Galaxy
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathhash_brut.lua
More file actions
79 lines (67 loc) · 1.6 KB
/
Copy pathhash_brut.lua
File metadata and controls
79 lines (67 loc) · 1.6 KB
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
local hash_needed = tonumber(arg[1]) or 0
local start_value = arg[2] or "A"
local depth = tonumber(arg[3]) or 1
local dict_str = "ABCDEFGHIJKLMNOPQRSTUVWXYZ_1234567890"
--local dict_str = "ABCD"
local diclen = #dict_str
local dict = {}
for i = 1, #dict_str do
table.insert(dict, dict_str:sub(i, i):byte())
end
local strlen = #start_value
local str = {}
for i = 1, strlen do
local s = start_value:sub(i, i)
for j = 1, diclen do
if s == dict_str:sub(j, j) then
str[i] = j
break
end
end
end
for i = 1, depth do
table.insert(str, 1)
end
strlen = strlen + depth
--print(table.concat(str, ":"))
local function show_str()
local s = {}
for i = 1, strlen do
table.insert(s, string.char(dict[str[i]]))
end
print(table.concat(s))
end
--show_str()
local function hash(s)
local res = #s
for i = 1, res do
local byte = rawget(dict, rawget(s, i))
res = res << 0x05 & 0xFFFFFFFF ~ byte ~ res >> 0x1B
end
return res
end
--[[ start brute ]]-------------------------------------------------------------
local found = 0
local function brute(l)
for i = 1, diclen do
str[l] = i
if (strlen - l + 1) < depth then
brute(l-1)
else
--show_str()
local h = hash(str)
if (h == hash_needed) then
found = found + 1
io.write(h)
io.write(" ")
show_str()
end
end
end
end
brute(strlen)
if found == 0 then
print("brute unsuccesfull :(")
else
print("keys founded: " .. found)
end