urg 0.0.0 → 1.0.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (3) hide show
  1. checksums.yaml +4 -4
  2. data/lib/urg.rb +29 -5
  3. metadata +1 -1
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 63a78a2b0eade44bfc04878f4b683e5276649ca4d96f5fb7da5064446219d367
4
- data.tar.gz: ccbd5c29ffb756301334a2af8b54154b972685f3536e6491b694a87477b563b1
3
+ metadata.gz: ab5fdbf2ded7cae1dcab226132f54a5288df63fe5211517cedf8fd78d0581c3d
4
+ data.tar.gz: 28ecb8f88aa4c8a0c503aa9390747af06f7a50afa3927df8ce992b0398c8da85
5
5
  SHA512:
6
- metadata.gz: 2570a0f714960f307077e19095ede1242c6af384f26712eee95bc7e62a3edf39bf98e3df55925d838faf78cdf51080f754165ce0007ccfef85e460bdb9ee90a5
7
- data.tar.gz: a7ce219d70084a3f2c496e0256f40da8f5d62cf8b955174cccd14096943f0dad27411482969053d3e005088a20bd8132de98b8b42bbe4e5a7746ff51800f0b0e
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
- def self.exfil(object)
6
- str = Base64.encode64(Zlib::Deflate.deflate(Marshal.dump(object)))
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
- Marshal.load(Zlib::Inflate.inflate(Base64.decode64(str)))
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
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: urg
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.0
4
+ version: 1.0.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Lawson Kurtz