Giter Club home page Giter Club logo

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 examples/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.

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.