Skip to content

brentlintner/machinator

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

34 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Machinator

<img src=“https://badge.fury.io/rb/machinator.svg” alt=“Gem Version” />

Machinator can perform code obfuscation on file content and directory structures.

It can be paired up with high level language deployment and/or compression routines to keep even Big Brother guessing. Or can it?

rubygems.org/gems/machinator

Terminal usage

As a ruby gem

machinator -h

Or (with the source) you can just:

ruby bin/machinator -h

Obfuscating

Machinator lets you define the schema for obfuscation.

A schema (in YAML) is defined in a .machinator file in the directory being operated on, or a manually specified Hash resource.

A schema has a words and a names hash collection, with each key/pair being a regular expression and strings to replace with any occurences, respectively.

An example:

words: {
    namepsace\.Foo: nameSpace.bar
}

names: {
    SomeFile\.js$: ABC.js
}

Any words are matched against the entire file. File names are obfuscated afterwards (will only be matched once).

Using In Code

require "machinator"
winston = Machinator::Obfuscator.new
winston.neverspeak(source, schema)

The source can be an actual string to obfuscate, a File object, or a directory/file path to operate on. Keep in mind that the Obfuscator module will overwrite any files/directories that matches the schema.

Note: If you specify a string to obfusctate that is actually a valid file/directory path it will operate on that instead.

Manipulating Strings

In the case of passing in a string an obfuscated copy will be returned.

new_string = winston.neverspeak("some string to obfuscate", {
  "words" => {
    /^some\sstring/ => "something"
  }
})

Operating on Files and Directories

You can operate on a single file, where the first matched names key/pair is applied to the file name and any words are applied against the file content.

# renames to foo.foo
winston.neverspeak("foo.bar", {
  "names" => {
    /bar$/ => "foo"
  }
})

If you specify a directory all files and directories inside will be operated on (recursively, bottom up), applying names/words matches to each file.

# let somedir have 'afile' in it
winston.neverspeak("somedir", {
  "names" => {
    /afile$/ => "thefile"
  }
})

Note: This will recurse (fairly deep) so make sure the passed in directory is correct, or you could possibly bring on the apocalypse.

Filtering

You can pass in a block to filter file operations (both words and names).

winston.neverspeak("somedir", schema) { |path|
  true
} # will operate on every file found

Dependencies

None

Versioning

This project ascribes to semantic versioning.

Tests

rake test (need mocha, and rake… if you want)

Author

Copyright 2010 Brent Lintner

The MIT License www.opensource.org/licenses/mit-license.php

About

Sinister code obfuscation.

Resources

Stars

Watchers

Forks

Packages

No packages published

Languages