Advertisement
Guest User

Untitled

a guest
Mar 26th, 2015
1,044
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 5.69 KB | None | 0 0
  1. -- Not optimized at all. Use at your own risk.
  2.  
  3. BraxScan = BraxScan or {}
  4.  
  5. BraxScan.Trigger = {
  6.    
  7.     -- external sources
  8.     "http\\.",
  9.     "HTTP",
  10.     "HTML",
  11.     "OpenURL",
  12.     "sound.PlayURL",
  13.    
  14.     -- people don't use this for legit purposes
  15.     "CompileString",
  16.     "CompileFile",
  17.     "RunString",
  18.     "RunStringEx",
  19.     "%(_G%)",
  20.     "setmetatable",
  21.    
  22.     -- databases
  23.     "sql",
  24.     "MySQLite",
  25.     "mysqloo",
  26.     "tmysql",
  27.    
  28.     -- encryption
  29.     "Base64Encode",
  30.     "Base64Decode",
  31.     "CRC",
  32.    
  33.     -- superiority complex
  34.     ":Ban\\(",
  35.     ":Kick\\(",
  36.    
  37.     -- players
  38.     "player.GetByUniqueID",
  39.     "SetUserGroup",
  40.     "setroot",
  41.     "setrank",
  42.    
  43.     -- workshop
  44.     "steamworks.Subscribe",
  45.     "steamworks.ViewFile",
  46.     "steamworks.OpenWorkshop",
  47.     "resource.AddWorkshop",
  48.    
  49.     -- screen
  50.     "render.Capture",
  51.     "render.CapturePixels",
  52.     "render.ReadPixel",
  53.    
  54.     -- configs and cheats
  55.     "hostip",
  56.     "hostname",
  57.     "server.cfg",
  58.     "autoexec.cfg",
  59.     "\\.dll",
  60.     "\\.exe",
  61.     "bind\\ ",
  62.     "connect\\ ",
  63.     "point_servercommand",
  64.     "lua_run",
  65.     "\"rcon",
  66.     "\"rcon_password",
  67.     "\"sv_password",
  68.     "\"sv_cheats"
  69.    
  70. }
  71.  
  72. BraxScan.Version = 0.2
  73.  
  74. print("♫ BraxScan initialized on ".. (SERVER and "server" or "client") ..". Use 'braxscan' to scan.")
  75.  
  76. local LogBuffer = "\n"
  77.  
  78. function BraxScan.Print(color, text)
  79.     if(type(color) == "table") then
  80.         MsgC(color,text.."\n")
  81.         BraxScan.LogAdd(text)
  82.     else
  83.         MsgN(color)
  84.         BraxScan.LogAdd(color)
  85.     end
  86. end
  87.  
  88. function BraxScan.LogNew()
  89.     LogBuffer = ""
  90. end
  91.  
  92. function BraxScan.LogAdd(text)
  93.     LogBuffer = LogBuffer .. text .. "\n"
  94. end
  95.  
  96. function BraxScan.LogSave()
  97.     file.Write("braxscan/scan_"..os.date("%y-%m-%d_%H-%M-%S")..".txt", LogBuffer)
  98. end
  99.  
  100. file.CreateDir("braxscan")
  101.  
  102. function BraxScan.ScanAddon(addon)
  103.     BraxScan.Print(Color(0,255,255), "♫ "..addon.title.." ♫")
  104.     BraxScan.Print(Color(200,200,200), "File: "..addon.file)
  105.     BraxScan.Print(Color(200,200,200), "ID: "..addon.wsid)
  106.    
  107.     MsgN("")
  108.    
  109.     local luafiles = 0
  110.     local found = 0
  111.    
  112.     Files = {}
  113.     local function Recurs(f,a)
  114.        
  115.         local files, folders = file.Find(f .. "*", a)
  116.        
  117.         for k,v in pairs(files) do
  118.             local s = string.Split(v,".")
  119.            
  120.             if s[#s] == "dll" then
  121.                 BraxScan.Print(Color(255,0,0), "\n\n!!! Found DLL file in addon "..a.." !!!\n")
  122.             end
  123.            
  124.             if s[#s] == "lua" then
  125.                 table.insert(Files,f..v) -- add file to list
  126.                
  127.                 local luafile = file.Read(f..v, "GAME")
  128.                
  129.                 if not luafile then print("cannot read lua file") continue end
  130.                
  131.                 local lines = string.Split(luafile,"\n")
  132.                
  133.                 if not lines then continue end
  134.                
  135.                 if #lines == 1 then
  136.                     BraxScan.Print(Color(255,0,0), "+-- Only one line in "..f..v.." --")
  137.                     BraxScan.Print(Color(0,255,0), "| 1 | "..lines[1].."\n")
  138.                     found = found + 1
  139.                 end
  140.                
  141.                 for linenr, line in pairs(lines) do
  142.                    
  143.                     -- find trigger words
  144.                     for _, w in pairs(BraxScan.Trigger) do
  145.                    
  146.                         if string.find(line, w, 0, false) then
  147.                             BraxScan.Print(Color(255,0,0), "┌── Found '"..w.."' in "..f..v.." on line "..linenr.." ──")
  148.                             for i=math.Clamp(linenr-3,0,9999),math.Clamp(linenr+3,0,#lines) do
  149.                                 if not lines[i] then continue end
  150.                                 BraxScan.Print(i == linenr and Color(0,255,0) or Color(255,255,0), "│ "..i.." | "..lines[i])
  151.                             end
  152.                             BraxScan.Print(Color(255,0,0), "└───●")
  153.                             BraxScan.Print("\n")
  154.                             found = found + 1
  155.                         end                        
  156.                    
  157.                     end
  158.                    
  159.                     -- find steamids in plain text
  160.                     local steamid = string.match(line, "(STEAM_[0-9]:[0-9]:[0-9]+)")
  161.                     if steamid then
  162.                         BraxScan.Print(Color(255,0,0), "┌── Found SteamID "..steamid.." at line "..linenr.." in "..f..v.." ──")
  163.                         for i=math.Clamp(linenr-3,0,9999),math.Clamp(linenr+3,0,#lines) do
  164.                             BraxScan.Print(i == linenr and Color(0,255,0) or Color(255,255,0), "│ "..i.." | "..lines[i])
  165.                         end
  166.                         BraxScan.Print(Color(255,0,0), "└───●")
  167.                         BraxScan.Print("\n")
  168.                         found = found + 1
  169.                     end
  170.                
  171.                 end
  172.                
  173.                 luafiles = luafiles + 1
  174.                
  175.             end
  176.         end
  177.        
  178.         for k,v in pairs(folders) do
  179.             Recurs(f..v.."/",a)
  180.         end
  181.        
  182.     end
  183.     Recurs("",addon.title)
  184.    
  185.     BraxScan.Print(Color(200,200,128), "⌐ Lua files:          "..luafiles)
  186.     BraxScan.Print(Color(200,200,128), "⌐ Suspicious things:  "..found)
  187.    
  188.     BraxScan.Print("")
  189. end
  190.  
  191. concommand.Add("braxscan", function(ply,com,arg)
  192.  
  193.     if not arg[1] then
  194.         print("\n---------- BraxScan "..BraxScan.Version.." ----------\n")
  195.         print("To search all addons: braxscan all 1")
  196.         print("To search a specific addon: braxscan *ID* 1")
  197.         print("Last argument is whether to save log or not.")
  198.         print("\n----------------------------------")
  199.         return
  200.     end
  201.    
  202.     local savelog = arg[2] == "1" and true or false
  203.    
  204.     local addons = engine.GetAddons()
  205.    
  206.     print("\n---------- BraxScan "..BraxScan.Version.." ----------\n")
  207.    
  208.     print("Addons installed: "..#addons)
  209.     print("\nStarting search...\n")
  210.    
  211.     if not BraxScan.Trigger then
  212.         MsgC(Color(255,0,0), "No definitions file, odd.\n")
  213.         return
  214.     end
  215.    
  216.     if arg[1] == "all" then
  217.  
  218.         BraxScan.LogNew()
  219.         for anum, addon in pairs(addons) do
  220.             BraxScan.ScanAddon(addon)
  221.         end
  222.        
  223.         if savelog then BraxScan.LogSave() end
  224.    
  225.     else
  226.    
  227.         BraxScan.LogNew()
  228.        
  229.         print("Specific search for ID "..arg[1].."...")
  230.        
  231.         local found = false
  232.  
  233.         for anum, addon in pairs(addons) do
  234.             if addon.wsid == arg[1] then
  235.                 BraxScan.ScanAddon(addon)
  236.                 found = true
  237.                 break
  238.             end
  239.         end
  240.        
  241.         if savelog then BraxScan.LogSave() end
  242.        
  243.         if not found then MsgC(Color(255,0,0), "No addon with that ID installed.\n\n") end
  244.    
  245.     end
  246.  
  247.     MsgC(Color(0,255,0), "All done.")
  248.     if savelog then MsgC(Color(0,255,0), "\nLog file saved to data directory.") end
  249.    
  250.     print("\n\n----------------------------------")
  251.  
  252. end)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement