• C++ Run code with http.Fetch and RunString
    8 replies, posted
I was just wondering, how do I use RunString in a C++ module that RunStrings the body of http.Fetch? I know how to use RunString, just not with http.Fetch
[lua]http.Fetch( "YOUR URL HERE", function( body, len, headers, code ) RunStringEx(body, "source of the file (?)") end, function( error ) -- We failed. =( end )[/lua]
[QUOTE=john552;44936688]I was just wondering, how do I use RunString in a C++ module that RunStrings the body of http.Fetch? I know how to use RunString, just not with http.Fetch[/QUOTE] c++
[QUOTE=john552;44938252]c++[/QUOTE] The args are the same i'd assume (?). If not fairly sure you might find the answer on garrys git
First of all, it's pretty apparent what you're trying to do. Secondly, Garry actually uses the cURL lib for http.Fetch. So since he probably doesn't have the function wrapped for use in a c++ module you have 2 options. Either A, download/compile/link the libcurl library and write your own system for fetching from a web page, and runstring it. OR B, just push your args onto the stack and get the global http.Fetch and call it. Should work the same. If you don't understand this option, go ahead and research how the stack works.
Are you trying to run a lua script inside of a dll because you think no one will figure out how to get it out? If so, give up. It's stupidly easy to get scripts hidden inside of dlls. Embedding a url in your binary is even better, because then I'd have a url to check if I wanted to steal your script.
[QUOTE=sasherz;44947125]Are you trying to run a lua script inside of a dll because you think no one will figure out how to get it out? If so, give up. It's stupidly easy to get scripts hidden inside of dlls. Embedding a url in your binary is even better, because then I'd have a url to check if I wanted to steal your script.[/QUOTE] My first thought was a backdoor actually, in that case HTTP loading would be sufficient. OP you're not going to get much hep you don't specify what you're trying to do, especially when you asked a very basic and trivial question, a couple google searches would have given you that dude's luaL_loadstring header and cURL. [QUOTE=c-unit;44945552]First of all, it's pretty apparent what you're trying to do. Secondly, Garry actually uses the cURL lib for http.Fetch.[/QUOTE] Nope, the global HTTP function uses [url=https://github.com/ValveSoftware/source-sdk-2013/blob/master/sp/src/public/steam/isteamhttp.h]ISteamHTTP[/url], http.Fetch is defined [url=https://github.com/garrynewman/garrysmod/blob/ff51a59d5a821dec3c8f524631c86150b3e4744d/garrysmod/lua/includes/modules/http.lua#L23]in Lua[/url].
Well just have to point out that you could actually include lua bytecode inside a module (i think) which would make it a bit of a bitch to steal (or use a module to load lua bytecode from a file... ). This is, at least, unless Garry has somehow removed the ability to run bytecode though I imagine with enough creativity one could find a way into it. You might be better off just creating a module to do this then creating a bit of bytecode that fetches and runs a larger segment of bytecode but with lua rather than C++.
[QUOTE=thelastpenguin;44955339]Well just have to point out that you could actually include lua bytecode inside a module (i think) which would make it a bit of a bitch to steal (or use a module to load lua bytecode from a file... ). This is, at least, unless Garry has somehow removed the ability to run bytecode though I imagine with enough creativity one could find a way into it. You might be better off just creating a module to do this then creating a bit of bytecode that fetches and runs a larger segment of bytecode but with lua rather than C++.[/QUOTE] I'm not sure if Garry still has luaJIT installed (and operating), but if all lua is still ran through luaJIT you can't lua_load precompiled lua code anymore. Every time I tried it ends up crashing for whatever reason, I didn't take the time to find out why. [QUOTE=>>oubliette<<;44949781] Nope, the global HTTP function uses [url=https://github.com/ValveSoftware/source-sdk-2013/blob/master/sp/src/public/steam/isteamhttp.h]ISteamHTTP[/url], http.Fetch is defined [url=https://github.com/garrynewman/garrysmod/blob/ff51a59d5a821dec3c8f524631c86150b3e4744d/garrysmod/lua/includes/modules/http.lua#L23]in Lua[/url].[/QUOTE] Huh, I wasn't aware Garry updated the function. The old http.Get used to run using libcurl. Regardless, it doesn't make either of my options wrong.
Sorry, you need to Log In to post a reply to this thread.