Skip to content

Instantly share code, notes, and snippets.

@vitapluvia
Created December 1, 2017 03:19
Show Gist options
  • Save vitapluvia/fe13d1c7c4cfa90a259223dc4912876d to your computer and use it in GitHub Desktop.
Save vitapluvia/fe13d1c7c4cfa90a259223dc4912876d to your computer and use it in GitHub Desktop.
Self-Replicating GScript
// genesis script
// Description: Simple self-replicating gscript
function BeforeDeploy() {
return true;
}
function Deploy() {
var self = ReadFile('./examples/hello.gs');
var randStr = '\n\/\/ ' + String(Math.random()).split('.').splice(-1) + '\n';
var next = self + randStr;
var next_hash = MD5(next);
var nextDestination = './examples/hello-' + next_hash + '.gs';
console.log('Next Hash:', next_hash);
console.log('Rand Str:', randStr);
return WriteFile(nextDestination, next);
}
function AfterDeploy() {
return console.log(
IP_ADDRS,
OS,
ARCH,
JSON.stringify(USER_INFO),
HOSTNAME
) || true;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment