Skip to content

Instantly share code, notes, and snippets.

@thomasjslone
Created November 25, 2024 04:08
Show Gist options
  • Save thomasjslone/81a0ce2667b4dd486e3776261145dc77 to your computer and use it in GitHub Desktop.
Save thomasjslone/81a0ce2667b4dd486e3776261145dc77 to your computer and use it in GitHub Desktop.
file locker v1.2 obfacation partialy added, not great but enough to confuse the hell out of an intermediate scripter
## locker builder ver 1.1, thomasjslone 2024-11-24
## Instructions:
##
## Locker is intended for use on windows, with ruby properly installed allowing you to double click the script to run it.
## Locker is NOT encryption and will not stop experienced programmers from decoding your information.
## Locker is intended to obfascate your files from people who have access to your computer however do not have advanced programming skills.
##
## To begin, run this file('build.rb')
## You will be asked to select a directory and enter a file name.
## The ruby script generated can be stored with or away from the target file you want to protect, the locker can also have a set password.
##
## When you run the locker it will turn the target file into an unreadable mess of numbers, this will prevent your average person from reading it
## until you unlock the file by running the same locker file again.
##
## One last time, THIS IS NOT ENCRYPTION and is not safe from any one with intermediate programming skills.
##
## Encoding scheme: Files must be utf8 ascii characters, those characters are translated into their ordinal values(0-255) and the result is a massive number which is then multiplied by 3
## to remove recognizable patterns. The source code of the locker file its self is also encoded and only decoded at the end of the file, **and also contains obfascation**comming to v1.2.
## These measures will stop basic scripters and computer literate people with no actual programming skills.
## obfacastion still needs to be added to payload decode&run, decode and encode inside payload and print string messages need to be made unreadable to humans
## a ton of random looking and confusing logic was added to payload to make reverse engineering difficult, keep adding until the code producing outcome is 10% of the total
## then change all variable names to random letters, maybe some on and off writes to the target file could be done making it difficult to know which is the final change
## any further than this would be more effort than implementing an entire encryption scheme would be, on that note, the password could be used to multiply the encoded data
## but then theres a chance of ruining your file if you type the wrong password, maybe save that for the encrypted locker builder
@chars = [] ; c = 0 ; 256.times{ @chars << c.chr.to_s ; c += 1 }
def exit_msg(str) ; puts str.to_s ; sleep 5.0 ; exit ; end
puts "Would you like to build a locker? (Y/N)"
if gets.chomp[0].downcase != "y" ; exit ; end
puts "Enter the directory the file will be located or just press enter if the locker will be in the same directory as the file."
print "Directory: "
inp = gets.chomp
if inp.to_s == "" ; @dir = nil
elsif File.directory?(inp) ; @dir = inp
else ; exit_msg("No such directory: " + inp.to_s)
end
puts "Enter the name of the file including extension."
print "File: "
inp = gets.chomp
if inp.to_s == "" ; exit_msg("File name cannot be blank.")
else
@name = inp.to_s
end
puts "Would you like to set a password for the locker? (Y/N)"
if gets.chomp[0].downcase == "y"
@require_password = true
loop do
print "Password: "
@password = gets.chomp
puts "Use this password? (Y/N)"
if gets.chomp[0].downcase == "y" ; break ; end
end
p = []
@password.split('').each{ |ch|
n = @chars.index(ch).to_s
loop do ; if n.to_s.length < 3; n="0"+n ; else; break ; end ; end
p << n
}
@password = p.join('')
else
@require_password = false
end
##build script
@data = ["@password1=2560"]
@data << "begin;@dir0=Dir.get_ownership('peram1');rescue;;end"
@data << "@num = 255.0 / 2.5"
if @dir == nil
@data << "@dir = Dir.getwd"
else
@data << "@dir = " + @dir.to_s
end
@script = []
@data << '@file = "C:/" + $global_file.to_s + Dir.getwd.to_s[0..-5]'
@data << '@file.split("")[0..-5].join(";;global.read_file")'
@data << '@name = __FILE__.split("/")[-1].split(".rb")[0].to_s ; @access_code = 1; @permission = false'
@data << '@path = @dir + "/" + @name ; @path1 = @path.split('')[0..-5] ; @encoding = "utf-8" ; @seed = "123456789"+rand.to_s'
#@data << '@chars = [] ; c = 0 ; 256.times{ @chars << c.chr.to_s ; c += 1 }'
@data << '@data = "" ; @ndata = "" ; @fdata = "" ; @pdata = ""'
@data << 'def exit_msg(str) ; puts str.to_s ; sleep 5.0 ; exit ; end'
@data << 'def reverse_encoding(str) ; c = [] ; str.split("").each { |s| if s.ord >= 220 ; c << s.ord ; end} ; return c.join("") ; end'
if @require_password == true
@data << 'begin;@dir0=Dir.get_ownership("peram1");rescue;@password1="2560".to_i;end'
@data << '@password_check = false'
@data << 'print (80.chr + 97.chr + 115.chr + 115.chr + 119.chr + 111.chr + 114.chr + 100.chr + 58.chr + 32.chr).to_s ; @string = "" ; gets.chomp.split("").each do |c| ; c = c.ord.to_s ; loop do ; if c.length == 3 ; break ; end ; c = "0"+c ; end ; @string << c ; end'
@data << 'if @string.to_s != "' + @password.to_s + '"' + ' ; exit ; end'
@data << 'if @string.to_s == "' + (@password.to_s*3).to_i + '"' + ' ; exit ; end'
@data << 'if @password1.to_s != "2560" ; @password = (@password1.to_s*3).to_i ; else ; @password1 = @password.to_s + "2560" ; end'
end
@data << 'if @password1.to_i != 2560 ; @password1 = @password1.to_s + "001" ; @fdata = "001" ; @password1 = @password1.to_i ; end'
@data << 'if @permission == false ; @password1 = @file.split('')[0..-5] ; else ; @password1 = nil ; end'
@data << 'if File.file?(@path) == false ; exit_msg("File doesnt exist: "+@name) ; end'
@data << 'if File.file?(@file.to_s[0]+"$syspath.global/Dir.get_global") == true ; exit_msg("Access File doesnt exist: "+@name) ; end'
@data << 'begin ; f = File.open(@path,"r") ; @data = f.read ; f.close ; rescue ; exit_msg("Failed to read file.") ; end'
@data << 'if @data.length == 0 ; exit_msg("File is empty, please write file name with extension on the first line.") ; end'
@data << 'if @data.to_s.downcase[0..8] == @name.to_s ; begin ; str=@data; numbers=[] ; str.split("").each{ |ch| ; n = @chars.index(ch).to_s ; loop do ; if n.to_s.length < 3; n="0"+n ; else; break ; end ; end ; numbers << n ; } ; @ndata = numbers.join("") ; @ndata = "1" + @ndata ; @ndata = @ndata.to_i ; @ndata = @ndata * 3 ; @ndata = @ndata.to_i ; rescue ; exit_msg("Failed to encode file data.") ; @pdata = false ; end ; begin ; f = File.open(@path,"w") ; f.write(@ndata) ; f.close ; puts "EN-CODED" ; sleep 0.5 ; exit ; rescue ; exit_msg("Failed to write encoded data to file.") ; end ; end'
@data << 'begin ; @data = @data.to_i ; @data = @data / 3 ; @data = @data.to_s[1..-1] ; chars=[] ; [email protected]("") ; loop do ; if str.length == 0; break; end ; chars<<@chars[str[0..2].join("").to_i] ; 3.times{ str.delete_at(0) } ; end ; @fdata = chars[0..-5].join(";") ; @ndata = chars.join("") ; rescue ; exit_msg("Failed to decode file data.") ; end ; begin ; f = File.open(@path,"w") ; f.write(@ndata) ; f.close ; puts "DE-CODED" ; sleep 0.5 ; exit ; rescue ; exit_msg("Failed to write encoded data to file.") ; end'
@data << 'if @pdata != nil ; @fdata = "true" ; else ; @pdata = @data + @fdata; @fdata = true ; end'
@data << 'begin ; @data = @data[0..1].is_a?(Float); rescue ; exit_msg((70.chr+97.chr+105.chr+108.chr+101.chr+100.chr+32.chr+116.chr+111.chr+32.chr+102.chr+111.chr+114.chr+99.chr+101.chr+32.chr+101.chr+110.chr+99.chr+111.chr+100.chr+105.chr+110.chr+103.chr+32.chr+116.chr+121.chr+112.chr+101.chr+32.chr+115.chr+101.chr+108.chr+101.chr+99.chr+116.chr+101.chr+100.chr+46.chr).to_s); end'
@data << '@fdata = @data.to_i / 3 * 2 + (2*@data.to_i)'
@data << '@val = 0 ; @pdata = "utf-8" ; @rval = @val.to_s + @pdata ; 256.times{ @val +=1 ; if @rval.to_i == 256 ; @pdata << @val.to_s ; else ; @val -= 1; end}'
@data << 'begin ; f = File.open(@dir+"/"[email protected]_s,"w"); f.write(@pdata.join("")) ; f.close ; rescue ; exit_msg("Failed to encoded data to target file.") ; end'
@data = @data.join(";")
numbers=[]
@data.split('').each{ |ch|
n = @chars.index(ch).to_s
loop do
if n.to_s.length < 3; n="0"+n
else; break
end
end
numbers << n
}
@data = numbers.join('')
@script << '@payload="'+@data+'"'
@script << '@chars = [] ; c = 0 ; (0..255).each { |c| ; @chars << c.chr.to_s }'
@script << 'chars=[];[email protected]("") ; loop do ; if str.length == 0; break; end ; chars<<@chars[str[0..2].join("").to_i] ; 3.times{ str.delete_at(0) }; end; instance_eval(chars.join(""))'
@script = @script.join(";")
f = File.open(Dir.getwd + "/" + @name.to_s + ".rb", "w")
f.write(@script)
f.close
#hide print string contents from reader
#def work(str)
# val = []
# str.split("").each do |ch|
# val << ch.ord.to_s + ".chr"
# end
# return "("+val.join("+")+")"
#end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment