Giter Site home page Giter Site logo

vurv78 / autorun-rs Goto Github PK

View Code? Open in Web Editor NEW
86.0 6.0 10.0 236 KB

Modern scripthook with lua execution and filesteal. Replacement for gluasteal and most lua executors

License: Apache License 2.0

Batchfile 0.69% Rust 95.18% Lua 4.12%
garrysmod gmod lua glua scripthook dll script game-hacking reverse-engineering windows

autorun-rs's Introduction

Autorun

Release Shield License CI github/Vurv78

Garrysmod Lua Dumper & Runner, written in Rust.

Features

  • Dumping all lua scripts to C:\Users\<User>\autorun\lua_dumps\<ServerIP>\.. (asynchronously to avoid i/o lag)
  • Runtime lua loading through lua_run and lua_openscript in an external console
  • Supports both 32* and 64 bit branches (*See #22)
  • Running a script before autorun (autorun.lua), to detour and bypass any 'anticheats'
  • Scripthook, stop & run scripts before anything runs on you, gives information & functions to assist in a safe separate lua environment
  • File logging (to autorun/logs)
  • Plugin system (autorun/plugins)
  • Settings using TOML

๐Ÿค” Usage

๐Ÿงฉ Menu Plugin

Autorun can also be used as a menu plugin / required from lua automatically from the menu state.

  1. Put the dll gmsv_autorun_win<arch>.dll file into your garrysmod/lua/bin folder.
  2. Add require("autorun") at the bottom of garrysmod/lua/menu/menu.lua
    It will now run automatically when garrysmod loads at the menu.

๐Ÿ’‰ Injecting

The traditional (but more inconvenient) method to use this is to just inject it.

  1. Get an injector (Make sure it's compatible to inject 32/64 bit code depending on your use).
  2. Inject the dll into gmod while you're in the menu

๐Ÿ“œ Scripthook

Autorun features scripthook, which means we'll run your script before any other garrysmod script executes to verify if you want the code to run by running your own hook script. *This runs in a separate environment from _G, so to modify globals, do _G.foo = bar

Also note that if you are running in autorun.lua Functions like http.Fetch & file.Write won't exist.
Use their C counterparts (HTTP and file.Open)

See an example project using the scripthook here.

๐Ÿ“ File Structure

C:\Users\<User>\autorun
โ”œโ”€โ”€ \autorun.lua # Runs *once* before autorun
โ”œโ”€โ”€ \hook.lua # Runs for every script
โ”œโ”€โ”€ \lua_dumps\ # Each server gets a folder with their IP as the name.
โ”‚   โ”œโ”€โ”€ \192.168.1.55_27015\
โ”‚   โ””โ”€โ”€ \X.Y.Z.W_PORT\
โ”œโ”€โ”€ \logs\ # Logs are saved here
โ”‚   โ””โ”€โ”€ YYYY-MM-DD.log
โ”œโ”€โ”€ \bin\ # Store binary modules to be used with Autorun.requirebin
โ”‚   โ””โ”€โ”€ gmcl_vistrace_win64.dll
โ”œโ”€โ”€ \plugins\ # Folder for Autorun plugins, same behavior as above autorun and hook.lua, but meant for plugin developers.
โ”‚   โ””โ”€โ”€ \Safety\
โ”‚       โ”œโ”€โ”€ \src\
|       |   โ”œโ”€โ”€ autorun.lua
|       |   โ””โ”€โ”€ hook.lua
โ”‚       โ””โ”€โ”€ plugin.toml
โ”œโ”€โ”€ settings.toml # See autorun/src/configs/settings.toml
โ””โ”€โ”€ ...

๐Ÿ—ƒ๏ธ Fields

You can find what is passed to the scripthook environment in fields.lua as an EmmyLua definitions file.
This could be used with something like a vscode lua language server extension for intellisense ๐Ÿ‘

โœ๏ธ Examples

hook.lua
This file runs before every single lua script run on your client from addons and servers. You can return true to not run the script, or a string to replace it.

-- Replace all 'while true do end' scripts with 'while false do end' ๐Ÿ˜Ž
local script = Autorun.CODE
if script:find("while true do end") then
	Autorun.log("Found an evil script!")
	return string.Replace(script, "while true do end", "while false do end")
end

You can find more here

โฌ‡๏ธ Downloading

๐Ÿฆบ Stable

You can get a 'stable' release from the releases.

๐Ÿฉธ Bleeding Edge

You can get the absolute latest download (from code in the repo) in the Github Actions tab
Note it may not work as expected (but I'd advise to try this out before trying to report an issue to see if it has been fixed)

If you are using this as a menu plugin ๐Ÿงฉ, make sure the DLL is named gmsv_autorun_win<arch>.dll

๐Ÿ› ๏ธ Building

You may want to build this yourself if you want to make changes / contribute (or don't trust github actions for whatever reason..)

  1. Setup Rust & Cargo
  2. Use build_win_32.bat or build_win_64.bat.

autorun-rs's People

Contributors

aholicknight avatar exotic0015 avatar moskalyka avatar notloof avatar vurv78 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

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar

autorun-rs's Issues

Linux Support

First step is to make a very barebones feature set to avoid all windows dependencies (winapi, trayicon).

Gonna be pretty tough ๐Ÿฅฒ

Autorun.require but for binary modules

This has been requested on the discord but putting here as a reminder.

Could either add support for it in the existing function or have it as a separate one, like Autorun.requirebin or something.

require dll module

I want to load external modules which are located in my lua/bin folder but I don't understand how to do it with autorun.

yet in my lua file I indicate :

require("enginepred")

but the external console spits me "RunString:1: Module not found!

What to do ? I missed a step ? mhummmm

Illegal Instruction Error after commit 5fa4802804fb169927e741da44dea53fbbc408e9

Not sure if this has to do with Edition 2021 / Nightly rust / Nightly rustc. Error is incredibly cryptic and nothing is helping.. (Couldn't even find anything at the address given where this error happened)

[profile.dev]
debug = 0

Seems to have worked a little bit. Same error but it doesn't happen if gmod13_open entrypoint is cleared

C FFI is actually a nightmare

Note

There hasn't been a release containing this commit so the latest release will work fine. Just not the generated builds in the actions tab.

Exploit

When using the second argument in (RunString, RunStringEx, CompileString) filesteal allows you to create files in any directory on disk

Example

lua_run RunString([[print("wtf")]], "../../autorun.lua")
lua_run RunString([[print("wtf")]], "../../../../../../Program Files (x86)/Steam/steamapps/common/GarrysMod/garrysmod/lua/autorun/autorun.lua")

lua dumps server filename

we need filesteal seartch by server name,
the option is set in the configuration file (aka settings.toml) however it returns a CLIENT in lua_dumps

it would be necessary to implement correct work so that all this functions suitably and finally to be able to excavate in different name of file by name of server.

Remove the need for the init_file_steal command

Instead just hook game.getIPAddress or use the actual engine net functions to get server addresses when dumping lua files
Will make it so we don't need to do the stupid init_file_steal call anymore.

Depends on #1 so.

Crashing whenever i leave a server

After injecting or requiring autorun, leaving any server instantly crashes/closes my game. No warning no error.
The version i used is 0.7.0 latest release.

Error Reason: Could not open library

thread '' panicked at 'Path DLL tried to load: C:\Program Files (x86)\Steam\steamapps\common\GarrysMod\bin\lua_shared.dll, Error Reason: Could not open library: Module not found. (os error 126). Report this on github.', src\lib.rs:82:25

Plugins 2.0 (and Plugins Workshop)

There needs to be a general plugin command:

  • list subcommand to list currently installed plugins
  • disable|enable subcommands to disable/enable.
  • remove subcommand to delete a plugin

Also, maybe there could be better integration than just dragging and dropping a folder into Autorun.

  • download subcommand to directly download a plugin from github
  • update subcommand to update a downloaded plugin

Will add one field to the existing plugin.toml layout, being repo for github (potentially gitlab and others, later.) repo.

Don't want to get too complex for this to never happen, but there could also be automatic updates. Although this would be opt-in/out

Crash on joining

<---> Autorun-rs <--->
Type [help] for the list of commands
Failed to allocate console. 5
<---> Autorun-rs <--->
Type [help] for the list of commands
Failed to open Autorun module. [Failed to set sender.]
Loaded into menu state.
Joining Server with IP XXXXXXXXXX!
warning: Unknown nb_ctl request:  4
warning: Unknown nb_ctl request:  4
warning: Unknown nb_ctl request:  4
warning: Unknown nb_ctl request:  4
warning: Unknown nb_ctl request:  4
warning: Unknown nb_ctl request:  4
thread '<unnamed>' panicked at 'byte index 3 is not a char boundary; it is inside '?' (bytes 2..3) of `note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
fatal runtime error: Rust panics must be rethrown

It crashed right after I loaded in, I was able to see a motd & the game in the background.

Using https://github.com/Vurv78/Autorun-rs/releases/tag/v0.6.0

[Suggestion] Add a way to hide / close the CLI mid game.

Small nitpicky suggestion but i might as well try.

Closing the console mid game currently results in:
image

It would add some QoL if you could close / hide it mid game so you don't have to have it open constantly. It currently makes tabbing into gmod annyoing and it would allow for a more permanent embed in gmod so you don't have to turn it on or off if you want to use it.

0.2.0

Already done.

Making an issue because rust dlopen doesn't allow fields with the WrapperApi derived to be public, which kind of doesn't allow this.

Pretty much the only thing keeping this from 0.2.0, and cargo isn't playing nice to import my own fork to test and maybe fix it for them...
szymonwieloch/rust-dlopen#31

Here's what's already added and being held back:

  • Scripthook / Running a script right before any lua file runs in an isolated env sautorun/hook.lua. Letting you control whether it runs by returning true in it.
  • Running a script sautorun/autorun.lua before autorun

A way to get a file's contents

Make a /data/ folder in sautorun-rs for binary / text / images / whatever to be stored.

Then add sautorun.readFile() or sautorun.openFile

Check for updates

Automatically check for updates and print to your console if any are found.

Potentially could have it update itself but not sure if that'll be possible with the dll trying to replace itself..

Spawnmenu Break + Game Crashing.

Happens on both the Latest official branch and latest beta branch.

Using x64 architecture release for both branches, x64 beta branch for the game as well, and obviously yes, my PC is x64 architecture.

Latest Log:
March 02, 2022 04-11 pm.log

Here is the configuration I use.
cfg.zip

Only happened with the use of https://github.com/Vurv78/Safety May be coupled with this so I'm listing this here.

Interesting Note: No crashing happened if I loaded a singleplayer session and then went into a multiplayer, this also didn't affect gamemodes other than sandbox (I tried zombie survival)

Autorun-rs v1.0.0-beta failed injection problem

the last update seems to break, I inject and the external console does not appear yet the injector confirms me that the injection was a success,

I use extrem injector v3.7.3 , I am on the 64 bit version of gmod

Menu Presence / ROC / ROM

Have a menu.lua file that will be run when the game launches in all plugins

Essentially could act as a replacement for https://github.com/glua/gmod-menu-plugins

As well as for ROC (https://github.com/glua/gm_roc), except this would be between both realms.

Then there'd be ability to communicate with Autorun, with an api potentially like:

-- CLIENT
Autorun.sendToMenu(55, "hello", "world")
Autorun.getFromMenu(print)

-- MENU
Autorun.getFromClient(function(xyz)
	print(xyz)
end)
Autorun.sendToClient(55)

--[[
Or an event based design
]]

-- CLIENT or MENU
Autorun.onEvent("xyz", function()

end)

-- CLIENT or MENU
Autorun.runEvent("xyz", 55)

Feel free to give API design ideas in here or on the discord.

32 Bit is broken

Since 0.4.0, x86/32 Bit would just not open the Autorun console. Now with 0.6.0 it closes your game. Need to fix this

Thanks to @Xandertron for originally reporting this on the discord

Code override / Source manipulation

Add overriding code (If you return a string in hook.lua, it will run that code rather than sautorun.CODE)

This will be on hold until #12 is hopefully resolved, if that takes too long it will be implemented and pushed.

Better logger

We should have

  • Colored logging
  • Logging that saves to (a) file(s)
  • Shouldn't interrupt command usage :/

t pose and streched models

with autorun required from menu.lua and on a server with custom pms, models will be in a tpose and have extremly streched bone
gmod_5QOmqUdxfx
gmod_4rjTmj43HF

Async File IO

Already added async-fs as a dependency, should be relatively easy to use that for asynchronous file i/o for lua dumping.

This will have all of the lua dumping take place in a different thread as to not affect the experience in game.

Add sautorun.require

Would allow for people to actually structure their code in modules rather than a massive single file. Safety is getting pretty huge

Still not sure about adding this kind of stuff because I'm afraid some might leak these to the global table where the functions could be abused.

Add colors to external console

it would be necessary to add colors in the external console for the different things as for example the information of launching or the titles as for example the plugins load ect, it's certainly a lot of detail but I think it's important

Plugin / Addon system

Have a folder dedicated for plugins/addons.
You could enable, disable these at any time through the cli

Additional potential features that are non-blocking to this issue

  • Maybe these could be linked to github repos and updated on demand.
  • Settings system linked to cli
  • Preprocessor? Using typed lua or adding some basic signature with comments to change the behavior of Autorun

Thinking of the structure being like this:

C:\Users\<User>\autorun
โ”œโ”€โ”€ \plugins\ # Main plugins folder
โ”‚   โ”œโ”€โ”€ \Safety\
โ”‚   โ”‚   โ”œโ”€โ”€ \scripts\ # Localized \scripts\ folder like the current system.
โ”‚   โ”‚   โ””โ”€โ”€ main.lua # Entrypoint
โ”‚   โ”‚   โ””โ”€โ”€ plugin.toml # Defines name, author, source, license, settings, etc.

Proper filesystem

I've been avoiding this for a while but now that #25 was done it should be relatively simple.

Need to have a 'filesystem' or at least a way to Autorun.require and later use #24's file opening local to plugin's directories.

This should be relatively simple? Just set a string somewhere in the Autorun env that'll define where the lua file is local to the autorun folder.

Then you'd be able to properly do
Autorun.require("bar.lua") for example inside of your plugin/src/autorun.lua file to run plugin/src/bar.lua instead of needing it to be in the autorun/scripts directory.

Now that I think about it this is kind of similar to lua's package.path ๐Ÿค”

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.