urg 0.0.0 → 1.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/urg.rb +29 -5
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: ab5fdbf2ded7cae1dcab226132f54a5288df63fe5211517cedf8fd78d0581c3d
|
4
|
+
data.tar.gz: 28ecb8f88aa4c8a0c503aa9390747af06f7a50afa3927df8ce992b0398c8da85
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 0d08ab8c416deff8ed5a3aa5bbe573126ed7e9073dc4b2cb550def06b0b6017862076052932958f24ea43009940f3da2f5d4d424aed5d2f7632068c662c5fed3
|
7
|
+
data.tar.gz: 958dc223cea12f3b756496e7063ce05157cf8ec4817ecefef0fbc4b97870a2d6bae2e6f49c846ae0e589f7c8683ef9a8f59a8760ffe29291e1d367a47ae8fa83
|
data/lib/urg.rb
CHANGED
@@ -1,15 +1,39 @@
|
|
1
1
|
require "base64"
|
2
2
|
require "zlib"
|
3
|
+
require "openssl"
|
4
|
+
require "open-uri"
|
3
5
|
|
4
6
|
module Urg
|
5
|
-
|
6
|
-
|
7
|
+
DEFAULT_PUBLIC_KEY_URI = "https://urg-public-keys.s3-us-west-2.amazonaws.com/urg-exfil.pub"
|
8
|
+
|
9
|
+
def self.exfil(object, key: DEFAULT_PUBLIC_KEY_URI)
|
10
|
+
if key
|
11
|
+
public_key_uri = URI.parse(key)
|
12
|
+
public_key = OpenSSL::PKey::RSA.new(public_key_uri.read)
|
13
|
+
str = Base64.encode64(public_key.public_encrypt(Base64.encode64(Zlib::Deflate.deflate(Marshal.dump(object))), OpenSSL::PKey::RSA::PKCS1_OAEP_PADDING))
|
14
|
+
key_arg = key == DEFAULT_PUBLIC_KEY_URI ? "\"#{key}\"" : "YOUR_PRIVATE_KEY_LOCATION"
|
15
|
+
else
|
16
|
+
str = Base64.encode64(Zlib::Deflate.deflate(Marshal.dump(object)))
|
17
|
+
key_arg = "nil"
|
18
|
+
end
|
19
|
+
|
7
20
|
puts "🚀"*20
|
8
|
-
puts "Urg.infil(\"#{str}\")"
|
21
|
+
puts "Urg.infil(\"#{str}\", key: #{key_arg})"
|
9
22
|
puts "🚀"*20
|
10
23
|
end
|
11
24
|
|
12
|
-
def self.infil(str)
|
13
|
-
|
25
|
+
def self.infil(str, key:nil)
|
26
|
+
unless key
|
27
|
+
return Marshal.load(Zlib::Inflate.inflate(Base64.decode64(str)))
|
28
|
+
end
|
29
|
+
|
30
|
+
if key == DEFAULT_PUBLIC_KEY_URI
|
31
|
+
private_key_content = ENV["URG_EXFIL_PRIVATE_KEY"]
|
32
|
+
else
|
33
|
+
private_key_content = open(key)
|
34
|
+
end
|
35
|
+
|
36
|
+
private_key = OpenSSL::PKey::RSA.new(private_key_content)
|
37
|
+
Marshal.load(Zlib::Inflate.inflate(Base64.decode64(private_key.private_decrypt(Base64.decode64(str), OpenSSL::PKey::RSA::PKCS1_OAEP_PADDING))))
|
14
38
|
end
|
15
39
|
end
|