diff --git a/README.md b/README.md new file mode 100644 index 0000000..928072d --- /dev/null +++ b/README.md @@ -0,0 +1,2 @@ +#### List of Tools +- **generate_invite_code.rb** - generates an invite code for hackthebox.eu diff --git a/generate_invite_code.rb b/generate_invite_code.rb new file mode 100755 index 0000000..2983b3c --- /dev/null +++ b/generate_invite_code.rb @@ -0,0 +1,18 @@ +#!/usr/bin/env ruby + +require 'net/http' +require 'json' +require 'base64' + +# send the POST request to generate the code +uri = URI('https://www.hackthebox.eu/api/invite/generate') +res = Net::HTTP.post_form(uri, 'q' => 'ruby', 'max' => '50') + +# parse through the http response from our POST request and extract just the +# base64 encode data + +json = JSON.parse res.body + +# base64 decode it +invite_code = Base64.decode64(json['data']['code']) +puts invite_code