Scan all files and directories in lua directory

Posts 1–13 of 13 · Page 1 of 1
Scan all files and directories in lua directory
So I was on the GmodZ server and was looking for exploits when I found a net message named "AntCheatCheck". Curious I wanted to look through all the files one by one and realized I was doing bullshit work. So I decided to code a full directory scanner. Took a while because I had file.Open and file.Find mixed up for some stupid ass reason, but here you go. You can use this for whatever. I'll use it to find a string in a particular lua file on the go. This can also be used for other things, but I might as well release it. Mostly useful for exploit finding. Have fun

Code:
local function Scan( returnfiles, path )
	local files, dirs = file.Find( (returnfiles and ((path and path.."/" or "").."*.lua") or (path and path or "").."*"), "lsv", "namedesc" );
	
	return (returnfiles and files or dirs);
end

local function ReadFile( filename, mode ) --Custom file.Read function since I overwrite mine. I'll leave this in here so you understand how it works.
	local f = file.Open( filename, "r", mode );
	
	if (!f) then return end
	
	local contents = f:Read( f:Size() );
	f:Close()
	
	return contents;
end

local dirs = Scan( );
local i = 0;
local currentdir = dirs[1];

repeat
	i=i+1
	currentdir = dirs[i] or false;
	
	if (currentdir) then
	
		local scanneddir = Scan( false, currentdir.."/" ) or {};
		
		for k, v in pairs( scanneddir ) do
			scanneddir[k] = tostring(dirs[i]).."/"..v
		end
		
		table.Add( dirs, scanneddir );
	end
until currentdir == false or i == 1000 --Have a safe at 1000 so you don't crash

for _, file in pairs( Scan( true ) ) do --Go through normal lua folder
	print( ReadFile( file, "lsv" ) or "" );
end

for _, dir in pairs( dirs ) do --Go through all the directories we just made
	local files = Scan( true, dir ); --Get the table of all the files
	
	for _, file in pairs( files ) do --Go through all the files
		print( ReadFile( dir.."/"..file, "lsv" ) ); --Print the contents of the file.
	end
end
The anti cheat is shitty.
You can:
1. Destroy the timer that runs every 30 seconds
2. Run your script like this: sv_allowcslua 1;runscriptshithere;sv_allowcslua

A few other useless methods not worth posting.
The AC is literally 8 lines of code, I have seen it myself.
So no point in detouring dem hooks, because it just check if sv_allowfcslua and sv_cheats is on 1 or not ran by the 30 second timer mentioned above.
Fail coder is fail.
Already intercepted the code and posted how to bypass. Ultra shitty method is ultra shitty.
Just wondering... is there any way to save the file into your lua folder or something?
Quote Originally Posted by MeepDarknessMeep View Post
Just wondering... is there any way to save the file into your lua folder or something?
Not unless you want to code your own module.
*cough* Like that one tyler has *cough*
If you use this code correctly, you can grab the lua files the server sends to you and save them. I'm not releasing that code though and I recommend no one else does so people have to figure it out.
I got the script but what do I type in console?
This is the method i use. I think its quite a bit simpler but i believe it accomplishes the same thing.

Code:
function ShowLua()
	local function recursion(directory)
		local files, directories = file.Find( directory.."*", "LUA" )
		
		for k,v in pairs(files) do
			MsgN("Directory is "..directory..v)
			local f = file.Open(directory..v, "r", "LUA")
			MsgN(f:Read(f:Size()))
			f:Close()
			MsgN("\n\n\n\n\n\n")
		end
		
		for k,v in pairs(directories) do
			recursion(directory..v.."/")
		end	
	end
	recursion("")
end
Quote Originally Posted by Atheon View Post
This is the method i use. I think its quite a bit simpler but i believe it accomplishes the same thing.

Code:
function ShowLua()
	local function recursion(directory)
		local files, directories = file.Find( directory.."*", "LUA" )
		
		for k,v in pairs(files) do
			MsgN("Directory is "..directory..v)
			local f = file.Open(directory..v, "r", "LUA")
			MsgN(f:Read(f:Size()))
			f:Close()
			MsgN("\n\n\n\n\n\n")
		end
		
		for k,v in pairs(directories) do
			recursion(directory..v.."/")
		end	
	end
	recursion("")
end
Yours scans all the files, not just lua files. And mine is more complicated because I don't ever release final versions of scripts here. I usually release shitty versions so people have to fix them up.
this is when i wish i had taked some time to learn LUA better late then never
Finally figured out how to use this. Thanks so much for the code
Just wondering, how do you use this exactly?
Posts 1–13 of 13 · Page 1 of 1
This thread is closed for replies.

Similar Threads

Tags for this Thread

None

Need help?