Client String Execution - roblox

I'm trying to allow players to execute scripts from a local script on my game.
(Not for malicious purposes, I'm trying to make a challenge to expose game weaknesses.)
loadstring doesn't work from the client, is there anything else I can do?

Try this module right here. Insert the module into your local script, and require it:
-- at beginning of code
local loadstring = require(script:WaitForChild("Loadstring"))
-- an example
code = [[print("Hello world!")]]
local executable, compileFailReason = loadstring(code)
executable()
-- or simply...
loadstring(code)()

Related

JupyterHub populate user home with notebooks (and data)

I have a JupyterHub server hosted on an Ubuntu machine.
(Mainly) since I want to avoid adding hundreds of potential users to the machine I opted to use c.JupyterHub.authenticator_class = 'jupyterhub.auth.DummyAuthenticator' (with a password)
The Spawner I use is
c.JupyterHub.spawner_class = 'jupyterhub.spawner.SimpleLocalProcessSpawner' although I also tried 'jupyterhub.spawner.LocalProcessSpawner'.
I want users to have some pre-populated notebooks once they log in.
I first tried https://tljh.jupyter.org/en/latest/howto/content/share-data.html putting the data in /etc/skel put it wasn't copied.
Then, according to various docs I could set c.Spawner.pre_spawn_hook = populate_user_home (tried also c.SimpleLocalProcessSpawner.pre_spawn_hook = populate_user_home) and have that method copy the files I want over to the user's home.
The method I have looks something like:
def populate_user_home(spawner):
username = spawner.user.name
# DummyAuthenticator creates users in /tmp
volume_path = os.path.join('/tmp', username)
if not os.path.exists(volume_path):
os.mkdir(volume_path, 0o777)
copyDirectory(<path_to_tutorials>, os.path.join(volume_path, 'tutorials'))
Problem is that this method is never called!
What am I doing wrong?
Is there another (simpler?) way to populate the home of new users?
The problem was not pre_spawn_hook, but several other small issues.
Calling print in the hook's code doesn't reach the log. Method was called.
Apparently SimpleLocalProcessSpawner creates the user folder before calling the hook, so copy was never called
the os.mkdir actually causes copytree to fail because dest folder exists

Roblox ModuleScript reporting Infinite yield possible on

Helping my kid learn to develop. Using Roblox as the tool.
We are in the ServerScriptService folder and in a file called OverheadRankScript. I have a line of code like this:
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local DataModule = require(ReplicatedStorage:WaitForChild("DataModule"))
My ModuleScript is in ReplicatedStorage folder and it is new and looks like this.
local module = {}
return module
I get the following error
Infinite yield possible on
'ReplicatedStorage:WaitForChild("DataModule")'
I copied the example from this link
https://developer.roblox.com/en-us/articles/Scope
Does ModuleScript script need to be in Replicated Storage or is Server Script Service the correct area?
Not sure what I am doing wrong should the file name be DataModule or is ModuleScript ok?
Does the variable need to change not sure the example provided in the documentation does not seem to work.
It's just a warning, but you can add a timeout to it for the warning to stop showing up.
local DataModule = require(ReplicatedStorage:WaitForChild("DataModule", 10))
The 10 is the optional timeout parameter that you can change to whatever you'd like to.
Actually what I found out was the DataModule needs to be renamed to ModuleScript. That Is the file name and it is referencing the file name. The example referenced in the link does not mention this at all. Infinite yield possible was misleading and it could not find the file.

Ida pro gragh output batch mode

Can anyone let me know how we are going to output all the subroutine's graphs in batch mode suing IDC. i.e. I have 447 subroutine's and wanna be output them all and I would like to make sure I first retrieve all the routines address automatically, cuz by knowing the address I can simply use GenFuncCall.
P.S: Is this the only cfg that I can get from Ida Pro given a binary dis-assembled file?
I needed a CFG of my whole program,the base example I started from was:
https://code.google.com/p/idapython/source/browse/trunk/examples/ex_gdl_qflow_chart.py
It uses the flow chart class:
https://www.hex-rays.com/products/ida/support/idapython_docs/idaapi.FlowChart-class.html
also worth noting to trigger in batch mode, you'll want something like this
idal64 -A -S{yourscriptname}.py {yourbinary}
Tips:
Prototype the script in the IDAPro gui first
Opening of the graph processor can cause timing issues, its hacky, but something like delaying execution of the script seemed to help, e.g.
idaapi.autoWait()
Timer(2, idacfg).start()
where idacfg is your python function from the example
print to stdout doesn't seem to work in batch mode, so you'll want to set stdout to a file for your debugging.
Closing the GUI in batch mode is still an issue for me.
Hope that helps.
If you just want the address of all known functions in the IDB, you could use something like this using IDAPython (just an example):
def main():
for count, func_ea in enumerate(Functions()):
if func_ea == BADADDR:
break
func_name = GetFunctionName(funcea)
func_start = func_ea
print("[{:4}] name: {}; start address: {:#x}".format(count, func_name, func_start))
if __name__ == "__main__":
main()

How to store and call a simple mongodb procedure

I often call the same commands in MongoDb command shell, for example :
db.user().find().pretty();
How would you store and call back this command ?
Ideally converting it to something like this :
db.findp( 'user' );
I believe this is NOT what your looking for, now that I read your question again: http://docs.mongodb.org/manual/applications/server-side-javascript/
Instead you are looking to modify the console in such a manner to make your life easier.
I should note, right now, that there is actually an extension which can do this sort of auto-formatting for you made by 10gen: https://github.com/TylerBrock/mongo-hacker
However if you wish to modify the files behind MongoDBs console a little more then you will need to do some manual labour.
There is a rc script in your home directory called .mongorc.js. In this file you can place any custom code you like (as #Asya mentioned) and it will actually become a command within the console.
In you rc file you could place a function like:
DB.prototype.pfind = function(col){
return this[col].find().pretty();
};
Or you could write:
DBCollection.prototype.pfind = function(){
return this.find().pretty();
};
Then you should be able to do:
db.pfind('users');
Or with the second command:
db.users.pfind();
Of course this method is for Linux, I am unsure about Windows, however, Windows should have an rc type script somewhere I believe.

Import AppleScript methods in another AppleScript?

Is there a way to use defined AppleScript methods in other AppleScripts which reference the original AppleScript with something similar to import (f.e. in PHP)?
I wrote a methode to set Skype status and mood-text:
on setSkypeStatus(status, mood_text)
tell application "System Events"
set skypeRunning to count (every process whose name is "Skype")
if skypeRunning > 0 then --only set status if skype is running
tell application "Skype"
set myStatus to "SET USERSTATUS " & status
set myMood to "SET PROFILE MOOD_TEXT " & mood_text
send command myStatus script name "AppleScript"
send command myMood script name "AppleScript"
return skypeRunning
end tell
else
return skypeRunning
end if
end tell
end setSkypeStatus
now I'm searching for something like import skype_methods.scpt. Is there such a functionality. I can't something related with Google.
One way to import another script as a library is to define a property which is initialized by loading the library as a script object. You can then use the tell command to invoke the library functions.
property pSkypeLibrary : load script POSIX file "/Users/sakra/Desktop/skype_methods.scpt"
tell pSkypeLibrary
setSkypeStatus("status", "mood")
end tell
Script Foo.scpt
set theBar to "path:to:Bar.scpt" as alias
run script (theBar)
Script Bar.scpt
display dialog "Bar"
Result: A window that displays "Bar"
There is a more elegant way of doing this. You can save your skype_methods.scpt file inside a Script Libraries folder on your computer.
Depending on how you want to define the availability of this library, you use a different folder.
Place the skype_methods.scpt file inside the /Library/Script Libraries folder to make it available for all users on the computer.
Place it in the ~/Library/Script Libraries folder to make it available for a specific user only.
You can then use all the handlers in that library as follows:
property Skype : script "skype_methods"
Skype's setSkypeStatus("status","mood")
This prevents the need of numerous tell blocks when using handlers from different libraries.
You can follow this repo https://github.com/abbeycode/AppleScripts which organises its scripts into libraries
Here is an example https://github.com/abbeycode/AppleScripts/blob/master/Scripts/Download%20Chase%20Activity.applescript
property LibLoader : load script file ((path to scripts folder from user domain as text) & "Libraries:Library Loader.scpt")
property TransmissionLib : LibLoader's loadScript("Libraries:Transmission.applescript")
property GrowlLib : LibLoader's loadScript("Libraries:Growl.applescript")
property SafariLib : LibLoader's loadScript("Libraries:Safari.applescript")
property DatesLib : LibLoader's loadScript("Libraries:Dates.applescript")