| 1 | #!/usr/bin/env ruby |
|---|
| 2 | # vi: set fileencoding=utf-8 : |
|---|
| 3 | |
|---|
| 4 | =begin |
|---|
| 5 | This script encrypts another one with 256 Bit AES, "swordfish" (the |
|---|
| 6 | marx one) as password and zero IV and outputs another script, which |
|---|
| 7 | decrypts the containing cipher and runs the code. |
|---|
| 8 | Disclaimer: This was written just for fun and may contain meaningless |
|---|
| 9 | use of cryptography. If you can not stand it, send complains to |
|---|
| 10 | henning on the honerable orgizm.net server. |
|---|
| 11 | =end |
|---|
| 12 | |
|---|
| 13 | %w[base64 openssl].each {|r| require r} |
|---|
| 14 | def a(m,k,t) |
|---|
| 15 | (a=OpenSSL::Cipher::Cipher.new('aes-256-cbc').send(m)).key=Digest::SHA256.digest(k) |
|---|
| 16 | #a.iv=File.open('/dev/random').read(32) |
|---|
| 17 | a.update(t)<<a.final |
|---|
| 18 | end |
|---|
| 19 | puts DATA.readlines,Base64.encode64(a :encrypt,:swordfish,File.new(ARGV[0]).readlines.join) |
|---|
| 20 | __END__ |
|---|
| 21 | %w[base64 openssl].each {|r| require r} |
|---|
| 22 | def a(m,k,t) |
|---|
| 23 | (a=OpenSSL::Cipher::Cipher.new('aes-256-cbc').send(m)).key=Digest::SHA256.digest(k) |
|---|
| 24 | a.update(t.unpack('m')[0])<<a.final |
|---|
| 25 | end |
|---|
| 26 | eval a :decrypt,:swordfish,DATA.readlines.to_s |
|---|
| 27 | __END__ |
|---|
| 28 | end |
|---|
| 29 | puts DATA.readlines,Base64.encode64(a :encrypt,:swordfish,File.new(ARGV[0]).readlines.join) |
|---|
| 30 | __END__ |
|---|
| 31 | %w[base64 openssl].each {|r| require r} |
|---|
| 32 | def a(m,k,t) |
|---|
| 33 | (a=OpenSSL::Cipher::Cipher.new('aes-256-cbc').send(m)).key=Digest::SHA256.digest(k) |
|---|
| 34 | a.update(t.unpack('m')[0])<<a.final |
|---|
| 35 | end |
|---|
| 36 | eval a :decrypt,:swordfish,DATA.readlines.to_s |
|---|
| 37 | __END__ |
|---|