Advertisement
TheRockettek

Untitled

Feb 12th, 2017
126
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 7.76 KB | None | 0 0
  1. string = require("string")
  2. table = require("table")
  3. os = require("os")
  4. coroutine = require("coroutine")
  5. unpack = table.unpack
  6. local chars = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789"
  7. characters = {}
  8. for i=1,#chars,1 do
  9. table.insert(characters,string.sub(chars,i,i))
  10. end
  11. -- SHA-256, HMAC and PBKDF2 functions in ComputerCraft
  12. -- By Anavrins
  13. local mod32 = 2^32
  14. local sha_hashlen = 32
  15. local sha_blocksize = 64
  16.  
  17. local band = bit32 and bit32.band or bit.band
  18. local bnot = bit32 and bit32.bnot or bit.bnot
  19. local bxor = bit32 and bit32.bxor or bit.bxor
  20. local blshift = bit32 and bit32.lshift or bit.blshift
  21. local upack = unpack
  22.  
  23. local function rrotate(n, b)
  24. local s = n/(2^b)
  25. local f = s%1
  26. return (s-f) + f*mod32
  27. end
  28. local function brshift(int, by) -- Thanks bit32 for bad rshift
  29. local s = int / (2^by)
  30. return s - s%1
  31. end
  32.  
  33. local H = {
  34. 0x6a09e667, 0xbb67ae85, 0x3c6ef372, 0xa54ff53a,
  35. 0x510e527f, 0x9b05688c, 0x1f83d9ab, 0x5be0cd19,
  36. }
  37.  
  38. local K = {
  39. 0x428a2f98, 0x71374491, 0xb5c0fbcf, 0xe9b5dba5, 0x3956c25b, 0x59f111f1, 0x923f82a4, 0xab1c5ed5,
  40. 0xd807aa98, 0x12835b01, 0x243185be, 0x550c7dc3, 0x72be5d74, 0x80deb1fe, 0x9bdc06a7, 0xc19bf174,
  41. 0xe49b69c1, 0xefbe4786, 0x0fc19dc6, 0x240ca1cc, 0x2de92c6f, 0x4a7484aa, 0x5cb0a9dc, 0x76f988da,
  42. 0x983e5152, 0xa831c66d, 0xb00327c8, 0xbf597fc7, 0xc6e00bf3, 0xd5a79147, 0x06ca6351, 0x14292967,
  43. 0x27b70a85, 0x2e1b2138, 0x4d2c6dfc, 0x53380d13, 0x650a7354, 0x766a0abb, 0x81c2c92e, 0x92722c85,
  44. 0xa2bfe8a1, 0xa81a664b, 0xc24b8b70, 0xc76c51a3, 0xd192e819, 0xd6990624, 0xf40e3585, 0x106aa070,
  45. 0x19a4c116, 0x1e376c08, 0x2748774c, 0x34b0bcb5, 0x391c0cb3, 0x4ed8aa4a, 0x5b9cca4f, 0x682e6ff3,
  46. 0x748f82ee, 0x78a5636f, 0x84c87814, 0x8cc70208, 0x90befffa, 0xa4506ceb, 0xbef9a3f7, 0xc67178f2,
  47. }
  48.  
  49. local function counter(incr)
  50. local t1, t2 = 0, 0
  51. if 0xFFFFFFFF - t1 < incr then
  52. t2 = t2 + 1
  53. t1 = incr - (0xFFFFFFFF - t1) - 1
  54. else t1 = t1 + incr
  55. end
  56. return t2, t1
  57. end
  58.  
  59. local function BE_toInt(bs, i)
  60. return blshift((bs[i] or 0), 24) + blshift((bs[i+1] or 0), 16) + blshift((bs[i+2] or 0), 8) + (bs[i+3] or 0)
  61. end
  62.  
  63. local function preprocess(data)
  64. local len = #data
  65. local proc = {}
  66. data[#data+1] = 0x80
  67. while #data%64~=56 do data[#data+1] = 0 end
  68. local blocks = math.ceil(#data/64)
  69. for i = 1, blocks do
  70. proc[i] = {}
  71. for j = 1, 16 do
  72. proc[i][j] = BE_toInt(data, 1+((i-1)*64)+((j-1)*4))
  73. end
  74. end
  75. proc[blocks][15], proc[blocks][16] = counter(len*8)
  76. return proc
  77. end
  78.  
  79. local function digestblock(w, C)
  80. for j = 17, 64 do
  81. local v = w[j-15]
  82. local s0 = bxor(bxor(rrotate(w[j-15], 7), rrotate(w[j-15], 18)), brshift(w[j-15], 3))
  83. local s1 = bxor(bxor(rrotate(w[j-2], 17), rrotate(w[j-2], 19)), brshift(w[j-2], 10))
  84. w[j] = (w[j-16] + s0 + w[j-7] + s1)%mod32
  85. end
  86. local a, b, c, d, e, f, g, h = upack(C)
  87. for j = 1, 64 do
  88. local S1 = bxor(bxor(rrotate(e, 6), rrotate(e, 11)), rrotate(e, 25))
  89. local ch = bxor(band(e, f), band(bnot(e), g))
  90. local temp1 = (h + S1 + ch + K[j] + w[j])%mod32
  91. local S0 = bxor(bxor(rrotate(a, 2), rrotate(a, 13)), rrotate(a, 22))
  92. local maj = bxor(bxor(band(a, b), band(a, c)), band(b, c))
  93. local temp2 = (S0 + maj)%mod32
  94. h, g, f, e, d, c, b, a = g, f, e, (d+temp1)%mod32, c, b, a, (temp1+temp2)%mod32
  95. end
  96. C[1] = (C[1] + a)%mod32
  97. C[2] = (C[2] + b)%mod32
  98. C[3] = (C[3] + c)%mod32
  99. C[4] = (C[4] + d)%mod32
  100. C[5] = (C[5] + e)%mod32
  101. C[6] = (C[6] + f)%mod32
  102. C[7] = (C[7] + g)%mod32
  103. C[8] = (C[8] + h)%mod32
  104. return C
  105. end
  106.  
  107. local mt = {
  108. __tostring = function(a) return string.char(unpack(a)) end,
  109. __index = {
  110. toHex = function(self, s) return ("%02x"):rep(#self):format(unpack(self)) end,
  111. isEqual = function(self, t)
  112. if type(t) ~= "table" then return false end
  113. if #self ~= #t then return false end
  114. local ret = 0
  115. for i = 1, #self do
  116. ret = bit32.bor(ret, bxor(self[i], t[i]))
  117. end
  118. return ret == 0
  119. end
  120. }
  121. }
  122.  
  123. local function toBytes(t, n)
  124. local b = {}
  125. for i = 1, n do
  126. b[(i-1)*4+1] = band(brshift(band(t[i], 0xFF000000), 24), 0xFF)
  127. b[(i-1)*4+2] = band(brshift(band(t[i], 0xFF0000), 16), 0xFF)
  128. b[(i-1)*4+3] = band(brshift(band(t[i], 0xFF00), 8), 0xFF)
  129. b[(i-1)*4+4] = band(t[i], 0xFF)
  130. end
  131. return setmetatable(b, mt)
  132. end
  133.  
  134. function digest(data)
  135. data = data or ""
  136. data = type(data) == "string" and {data:byte(1,-1)} or data
  137.  
  138. data = preprocess(data)
  139. local C = {upack(H)}
  140. for i = 1, #data do C = digestblock(data[i], C) end
  141. return toBytes(C, 8)
  142. end
  143. function sha256(hash)
  144. hashes = hashes + 1
  145. return digest(hash):toHex()
  146. end
  147. local function makeaddressbyte(j)
  148. if j <= 6 then return "0"
  149. elseif j <= 13 then return "1"
  150. elseif j <= 20 then return "2"
  151. elseif j <= 27 then return "3"
  152. elseif j <= 34 then return "4"
  153. elseif j <= 41 then return "5"
  154. elseif j <= 48 then return "6"
  155. elseif j <= 55 then return "7"
  156. elseif j <= 62 then return "8"
  157. elseif j <= 69 then return "9"
  158. elseif j <= 76 then return "a"
  159. elseif j <= 83 then return "b"
  160. elseif j <= 90 then return "c"
  161. elseif j <= 97 then return "d"
  162. elseif j <= 104 then return "e"
  163. elseif j <= 111 then return "f"
  164. elseif j <= 118 then return "g"
  165. elseif j <= 125 then return "h"
  166. elseif j <= 132 then return "i"
  167. elseif j <= 139 then return "j"
  168. elseif j <= 146 then return "k"
  169. elseif j <= 153 then return "l"
  170. elseif j <= 160 then return "m"
  171. elseif j <= 167 then return "n"
  172. elseif j <= 174 then return "o"
  173. elseif j <= 181 then return "p"
  174. elseif j <= 188 then return "q"
  175. elseif j <= 195 then return "r"
  176. elseif j <= 202 then return "s"
  177. elseif j <= 209 then return "t"
  178. elseif j <= 216 then return "u"
  179. elseif j <= 223 then return "v"
  180. elseif j <= 230 then return "w"
  181. elseif j <= 237 then return "x"
  182. elseif j <= 244 then return "y"
  183. elseif j <= 251 then return "z"
  184. else return "e"
  185. end
  186. end
  187. function makev2address(password)
  188. local key = sha256("KRISTWALLET" .. password) .. "-000"
  189. local protein = {}
  190. local stick = sha256(sha256(key))
  191. local n = 0
  192. local link = 0
  193. local v2 = "k"
  194. repeat
  195. if n < 9 then protein[n] = string.sub(stick,0,2)
  196. stick = sha256(sha256(stick)) end
  197. n = n + 1
  198. until n == 9
  199. n = 0
  200. repeat
  201. link = tonumber(string.sub(stick,1+(2*n),2+(2*n)),16) % 9
  202. if string.len(protein[link]) ~= 0 then
  203. v2 = v2 .. makeaddressbyte(tonumber(protein[link],16))
  204. protein[link] = ''
  205. n = n + 1
  206. else
  207. stick = sha256(stick)
  208. end
  209. until n == 9
  210. return v2
  211. end
  212. function cycle(t)
  213. for i=1,#characters,1 do
  214. if t == characters[i] then
  215. if i+1>#characters then
  216. return "!"
  217. else
  218. return characters[i+1]
  219. end
  220. end
  221. end
  222. end
  223. function cycletbl(tbl)
  224. tbl[1] = cycle(tbl[1])
  225. for i=1,#tbl,1 do
  226. if tbl[i] == "!" then
  227. tbl[i] = characters[1]
  228. if tbl[i+1] then
  229. tbl[i+1] = cycle(tbl[i+1])
  230. else
  231. tbl[i+1] = characters[1]
  232. end
  233. end
  234. end
  235. return tbl
  236. end
  237.  
  238. chartbl = {"a"}
  239. print("ENTER WANTED ADDRESS:")
  240. add = io.read()
  241. address = ""
  242. done=0
  243. ttw = os.time()+80
  244. hashes = 0
  245. while address ~= add do
  246. chartbl = cycletbl(chartbl)
  247. address = makev2address(table.unpack(chartbl))
  248. done=done+1
  249. if os.time() >= ttw then
  250. print(done .. " Addresses/s | " .. hashes .."h/s | " .. table.concat(chartbl,""))
  251. done = 0
  252. coroutine.yield()
  253. hashes = 0
  254. ttw = os.time() + 80
  255. end
  256. end
  257. print("DONE! " .. table.concat(chartbl,""))
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement