Changeset 363
- Timestamp:
- 23.02.2010 17:07:18 (5 months ago)
- File:
-
- 1 edited
-
tools/ruby-script-encrypt (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
tools/ruby-script-encrypt
r362 r363 1 1 #!/usr/bin/env ruby 2 2 # vi: set fileencoding=utf-8 : 3 4 # XXX Broken if input file size >= 32 byte. Should be connected to AES5 # block size. Debug anyone?6 7 3 =begin 8 This script encrypts another one with 256 Bit AES, "swordfish" (the 9 marx one) as password and zero IV and outputs another script, which 10 decrypts the containing cipher and runs the code. 11 Disclaimer: This was written just for fun and may contain meaningless 12 use of cryptography. If you can not stand it, send complains to 13 henning on the honerable orgizm.net server. 4 This script encrypts another one with 256 Bit AES, 5 "swordfish" (the marx one) as password and zero IV and 6 outputs another script, which decrypts the containing 7 cipher and runs the code. 8 Disclaimer: This was written just for fun and may 9 contain meaningless use of cryptography. If you can not 10 stand it, send complains to henning on the honerable 11 orgizm.net server. 14 12 =end 15 16 ARGV[0] ? nil:($stderr<<"#{$0} <script>\n";exit) 17 %w[base64 openssl].each{|r| require r} 18 def a(m,k,t) 19 (a=OpenSSL::Cipher::Cipher.new('aes-256-cbc').send(m)).key=Digest::SHA256.digest(k) 20 a.update(t)<<a.final 21 end 22 puts DATA.readlines,Base64.encode64(a :encrypt,:swordfish,File.new(ARGV[0]).readlines.join) 13 ARGV[0] ? nil: ($stderr<<"#{$0} <script>\n";exit); %w[base64 14 openssl].each{|r| require r};(a=OpenSSL::Cipher::Cipher.new( 15 'aes-256-cbc').encrypt).key=Digest::SHA256.digest(:swordfish 16 ); puts DATA.readlines, Base64.encode64( a.update( File.new( 17 ARGV[0]).readlines.join)<<a.final) 23 18 __END__ 24 19 #!/usr/bin/env ruby 25 %w[base64 openssl].each {|r| require r} 26 def a(m,k,t) 27 (a=OpenSSL::Cipher::Cipher.new('aes-256-cbc').send(m)).key=Digest::SHA256.digest(k) 28 a.update(t.unpack('m')[0])<<a.final 29 end 30 eval a :decrypt,:swordfish,DATA.readlines.to_s 20 %w[base64 openssl].each{|r| require r}; (a=OpenSSL::Cipher:: 21 Cipher.new('aes-256-cbc').decrypt).key= Digest::SHA2.digest( 22 :swordfish); eval( a.update( Base64.decode64( DATA.readlines 23 .join))<<a.final) 31 24 __END__
Note: See TracChangeset
for help on using the changeset viewer.

