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