Commit 2702d96b authored by Cool Fire's avatar Cool Fire

Created initial deobfus path

parent d0f2c480
Pipeline #243 passed with stage
in 36 seconds
...@@ -6,26 +6,38 @@ require_relative 'LexerFunctions.rb' ...@@ -6,26 +6,38 @@ require_relative 'LexerFunctions.rb'
# Main class for the PHP lexer # Main class for the PHP lexer
class Lexer < LexerFunctions class Lexer < LexerFunctions
require 'thread'
require_relative 'LexerConstants.rb' require_relative 'LexerConstants.rb'
attr_accessor :input attr_accessor :input, :output
attr_reader :start, :pos attr_reader :start, :pos
def initialize(debug)
puts 'New Lexer initialized' if debug
@debug = debug
end
# Kickstart the lexer # Kickstart the lexer
def start def start(filename, queue)
@input = read_file(filename)
@start = 0 @start = 0
@pos = 0 @pos = 0
@queue = queue
lex method :lex_text lex method :lex_text
end end
# Main lexer function loop # Main lexer function loop
def lex(state) def lex(state)
state = state.call until state.nil? Thread.new do
state = state.call until state.nil?
end
emit nil
end end
# Send lex token to parser queue # Send lex token to parser queue
def emit(type) def emit(type)
# Put input[start..pos] into queue # Put input[start..pos] into queue
@queue.push type
end end
# Get next char # Get next char
...@@ -49,9 +61,11 @@ class Lexer < LexerFunctions ...@@ -49,9 +61,11 @@ class Lexer < LexerFunctions
backup backup
c c
end end
end
l = Lexer.new # Try to read file to lex
l.input = '<?php print("test\n"); ?>' def read_file(filename)
l.start filename = File.expand_path filename
puts l.input @input = File.read filename
puts "Read #{filename}" if @debug
end
end
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment