Advertisement
Narzew

XORIFY CRYPT SYSTEM (OLD)

Mar 25th, 2013
143
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Ruby 1.42 KB | None | 0 0
  1. # XORIFY CRYPT SYSTEM ... (by Narzew)
  2. # Creative Commons License
  3.  
  4. #Very old..
  5. #Non-safe
  6. #8x more size of the crypted file
  7. #For educational purposes only :)
  8.  
  9. def xorify_crypt(source, destination, key=0x0AEEF6)
  10.     file = File.open(source, "rb")
  11.     data = file.read
  12.     file.close
  13.     s = []
  14.     xorval = key
  15.     data.each_byte{|byte|
  16.     r = byte.to_i ^ xorval
  17.     s << r
  18.     xorval = xorval * 2 + 113 & 0xFFFFFFFF
  19.     }
  20.     $data = s
  21.     file = File.open(destination, 'wb')
  22.     Marshal.dump($data, file)
  23.     file.close
  24.   end
  25.  
  26.   def xorify_decrypt(packed,dest,key=0x0AEEF6)
  27.     file = File.open(packed, 'rb')
  28.     $data = Marshal.load(file)
  29.     s = []
  30.     xorval = key
  31.     $data.each{|x|
  32.     r = x ^ xorval
  33.     s << r
  34.     xorval = xorval * 2 + 113 & 0xFFFFFFFF
  35.     }
  36.     a = []
  37.     s.each{|x|
  38.     a << x.chr
  39.     }
  40.     script = a.to_s
  41.     file = File.open(dest,'wb')
  42.     file.write(script)
  43.     file.close
  44. end
  45.  
  46. def xorify_eval(packed, key=0x0AEEF6, raiseonfailure=0)
  47.     file = File.open(packed, 'rb')
  48.     $data = Marshal.load(file)
  49.     s = []
  50.     xorval = key
  51.     $data.each{|x|
  52.     r = x ^ xorval
  53.     s << r
  54.     xorval = xorval * 2 + 113 & 0xFFFFFFFF
  55.     }
  56.     a = []
  57.     s.each{|x|
  58.     a << x.chr
  59.     }
  60.     script = a.to_s
  61.     begin
  62.       eval(script)
  63.     rescue
  64.       raise("Failed to load script") if raiseonfailure == 1
  65.       print("Failed to load script") if raiseonfailure == 0
  66.     end
  67.   end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement