node-marshal

This gem is designed for transformation of Ruby source code (eiher in the form of files or strings) to the Ruby nodes (syntax trees) used by Ruby MRI internals. Obtained nodes can be serialized to the platform-dependent binary or ASCII strings and restored and launched from serialized format. Such kind of transformation is irreversible and can be used for source code protection; the similar principle is used by RubyEncoder commercial software. It also contains some subroutines that can be useful for code obfuscation by renaming symbols inside the program.

The key features of node-marshal gem:

  • Irreversible conversion of a source code to the Ruby node (abstract syntax tree)

  • Ruby 1.9.3, 2.2.x and 2.3.x support (only MRI)

  • Active usage of Ruby internals (mainly AST) and Ruby standard library (Marshal and Zlib)

  • Set of tests for easy addition of new Ruby versions

  • Result of compilation depends on Ruby version and used platform (x86, x64 etc.)

  • Subroutines for obfuscation

  • 2-clause BSD license suitable for creation of custom source code protection system

Changelog:

  • 01.MAY.2017 - 0.2.2

    - Bugfix: NODE_KW_ARG processing implementation. Allows to use keyword (named) arguments
      in Ruby 2.x. (thanks to Jaros
  • 16.MAR.2016 - 0.2.1

    - Bugfix: garbage collection of symbols kept in the literals table of the node dump
      is now prohibited. Such GC caused hardly reproducible bugs after code loading.
      (thanks to Gregory Siehie
  • 11.JAN.2016 - 0.2.0

    - Bugfix: || and && in NODE_OP_ASGN1 (e.g. in x['a'] ||= 'b' or x['b'] &&= false)
      (this bug caused segfaults in some cases)
    - Bugfix: NodeMarshal#dump_node_short
    - Format version changed to NODEMARSHAL11 (support of symbols not representable in
      the form of String is added)
    - show_offsets property for controlling verbosity of NodeMarshal#dump_node_short output
    - Improved information about licenses
    - Improved rdoc documentation
    
  • 24.DEC.2015 - 0.1.2

    - Ruby 2.3.x preliminary support (including &. safe navigation operator)
    - Bugfix: NODE_MATCH3 (a =~ /abc/) issue (reported by Gregory Siehie
  • 04.MAY.2015 - 0.1.1 - first public version