Advertisement
labyrinth-servers1

Access Port

Mar 27th, 2019
239
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Ruby 3.55 KB | None | 0 0
  1. #!/usr/bin/env ruby
  2. =begin
  3. Labyrinth Copyright (C) 2018 Grathium Sofwares <grathiumsoftwears@gmail.com>
  4. This program comes with ABSOLUTELY NO WARRANTY
  5. This is a free software, and you are welcome to redistribute it under certain
  6. conditions.
  7. =end
  8.  
  9. require 'net/http'
  10. require 'webrick'
  11. require 'webrick/https'
  12. require 'securerandom'
  13.  
  14. class Encryptor
  15.     $end_file=''
  16.     $websiteKey = SecureRandom.hex
  17.  
  18.     def cipher(rotation)
  19.         characters = (' '..'z').to_a
  20.         offset_characters = characters.rotate(rotation)
  21.         pairs = characters.zip(offset_characters)
  22.         Hash[pairs]
  23.  
  24.     end
  25.  
  26.     def encrypt_letter(letter,rotation)
  27.         cipher_for_rotation = cipher(rotation)
  28.         cipher_for_rotation[letter]
  29.     end
  30.  
  31.     def encrypt(string,rotation)
  32.         letters = string.split('')
  33.  
  34.         results = letters.collect do |letter|
  35.             encrypted_letter = encrypt_letter(letter, rotation)
  36.         end
  37.            
  38.         results.join
  39.  
  40.     end
  41.  
  42.     def decrypt(string, rotation)
  43.         rotation = -(rotation)
  44.         letters = string.split('')
  45.  
  46.         results = letters.collect do |letter|
  47.             encrypted_letter = encrypt_letter(letter, rotation)
  48.         end
  49.  
  50.         results.join
  51.         results = results.to_s
  52.         results.delete! '[]""'
  53.         results.gsub! 'nil', ''
  54.         return results
  55.     end
  56.  
  57.   def decrypt_file(filename, rotation)
  58.  
  59.     # Create the file handle to the encrypted file
  60.     message = File.open(filename, "r")
  61.     # Read the encrypted text
  62.     read_message = message.read
  63.     # Decrypt the text by passing in the text and rotation
  64.     decrypted_message = decrypt(read_message, rotation)
  65.     # Create a name for the decrypted file
  66.     decrypted_filename = filename.gsub("encrypted", "decrypted")
  67.     # Create an output file handle
  68.     output_message = File.open(decrypted_filename, "w")
  69.     # Write out the text
  70.     output_message.write(decrypted_message)
  71.     # Close the file
  72.     output_message.close
  73.  
  74.   end
  75.  
  76.     def get_lambda(char)
  77.     val = char.sum
  78.    
  79.     dynamicvar = $c
  80.     if (dynamicvar=="" || dynamicvar==nil)
  81.         dynamicvar = 1
  82.     else
  83.         if (dynamicvar==0)
  84.             dynamicvar = 1
  85.         end
  86.     end
  87.    
  88.     #$c = (dynamicvar * val)/2*(1-(dynamicvar * val)/2)/((dynamicvar * dynamicvar) *2)
  89.     decrypted_char = decrypt(char, $c)
  90.     return decrypted_char
  91.   end
  92.  
  93.   def read_file(filename)
  94.     clear = File.open(filename) #open the file and set it as a variable
  95.     cleartxt = clear.read
  96.    
  97.     #read the file letter by letter and get the corrosponding lambda
  98.     i = 0
  99.     while i <= cleartxt.size
  100.        
  101.         encchar = cleartxt[i..i]
  102.         $end_file = $end_file + get_lambda(encchar)
  103.        
  104.         system "cls"
  105.         puts "#$end_file"
  106.         i+=1
  107.     end
  108.    
  109.     clear.close
  110.   end
  111.  
  112. end
  113.  
  114. class Webbrowser
  115.  
  116.     def local_server(sitename)
  117.         cert_name = [
  118.             %w[CN localhost],
  119.         ]
  120.    
  121.         server = WEBrick::HTTPServer.new(
  122.             :Port => 8443,
  123.             :SSLEnable => true,
  124.             :SSLCertName => cert_name
  125.         )
  126.  
  127.         server.mount_proc '/' + $websiteKey + '.lab' do |req, res|
  128.             res.body = $end_file
  129.         end
  130.        
  131.         system "cls"
  132.         puts "Client Ready!"
  133.         system 'start chrome.exe --incognito "https://localhost:8443/' + $websiteKey + '.lab"'
  134.         server.start
  135.     end
  136.  
  137. end
  138.  
  139. $end_file=''
  140. w = Webbrowser.new
  141. e = Encryptor.new
  142.  
  143. #this gets what the website should be saved as
  144. file_name = SecureRandom.hex + ".lab"
  145.  
  146. puts "
  147. Hidden key identifier?"
  148. print "> "
  149. file_to_decrypt = gets.chomp
  150.  
  151. puts "
  152. Secure File Password,"
  153. print "> "
  154. $c = gets.chomp.sum.to_i
  155.  
  156. source = Net::HTTP.get('pastebin.com', '/raw/' + file_to_decrypt)
  157. encrypt_source = File.open(file_name, "w")
  158. encrypt_source.write(source)
  159. encrypt_source.close
  160.  
  161.  
  162. #decrypt the source file
  163. e.read_file(file_name)
  164. sleep(1)
  165.  
  166. w.local_server(file_name)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement