Advertisement
Frost1

sv cobalt anticheat

Nov 1st, 2014
224
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 16.59 KB | None | 0 0
  1. TODAY I BRING TO YOU THE SERVERSIDE PORTION OF COBALT ANTICHEAT™
  2. IT TOOK MANY MONTHS OF PLANNING TO ACQUIRE THIS UNSTEALABLE FILE
  3. THIS IS GUARANTEED TO STOP 100% OF HACKERS
  4. ENJOY THIS HIGH-CALIBER SCRIPT RELEASE
  5.  
  6. 9:01 PM - YVL: its not really a high caliber script
  7. 9:02 PM - YVL: took me like 20 mins
  8.  
  9.  
  10. local hax = {}
  11.  
  12. local whitelist = {}
  13. local tounban = {}
  14.  
  15. util.AddNetworkString( "SendBan" )
  16. util.AddNetworkString( "SendClientFile" )
  17.  
  18. function hax.Init()
  19. if not file.Exists( "hax", "DATA" ) then
  20. file.CreateDir( "hax" )
  21. end
  22. if not file.Exists( "hax/logs", "DATA" ) then
  23. file.CreateDir( "hax/logs" )
  24. end
  25. if not file.Exists( "hax/logs/logs.txt", "DATA" ) then
  26. file.Write( "hax/logs/logs.txt" )
  27. end
  28. end
  29.  
  30. function hax.Add( ply )
  31. if not table.HasValue( whitelist, ply ) then
  32. table.insert( whitelist, ply )
  33. end
  34. end
  35.  
  36. concommand.Add( "hax_whitelist", function( ply, cmd, args )
  37. local pl = args[ 1 ]
  38. if ply:IsValid() and not ply:IsSuperAdmin() then
  39. if ply:IsValid() then
  40. ply:ChatPrint( "Invalid permissions." )
  41. else
  42. MsgN( "Invalid permissions." )
  43. end
  44. for k, v in next, player.GetAll() do
  45. if v:IsAdmin() then
  46. v:ChatPrint( "User " .. ply:Nick() .. " attempted to whitelist " .. pl )
  47. end
  48. end
  49. return
  50. end
  51. local user
  52. for k, v in next, player.GetAll() do
  53. if string.find( v:Nick():lower(), pl:lower() ) then
  54. user = v
  55. end
  56. end
  57. if user then
  58. hax.Add( user )
  59. if ply:IsValid() then
  60. ply:ChatPrint( user:Nick() .. " has been added to the whitelist" )
  61. else
  62. MsgN( user:Nick() .. " has been added to the whitelist" )
  63. end
  64. else
  65. if ply:IsValid() then
  66. ply:ChatPrint( "No users found" )
  67. else
  68. MsgN( "No users found" )
  69. end
  70. end
  71. end )
  72.  
  73. concommand.Add( "hax_unban", function( ply, cmd, args )
  74. local steamid = args[ 1 ]
  75. if ply:IsValid() and not ply:IsSuperAdmin() then
  76. if ply:IsValid() then
  77. ply:ChatPrint( "Invalid permissions." )
  78. else
  79. MsgN( "Invalid permissions." )
  80. end
  81. for k, v in next, player.GetAll() do
  82. if v:IsAdmin() then
  83. v:ChatPrint( "User " .. ply:Nick() .. " attempted to unban " .. steamid )
  84. end
  85. end
  86. return
  87. end
  88. if not ULib.isValidSteamID( steamid ) then
  89. if ply:IsValid() then
  90. ply:ChatPrint( "Invalid steamid" )
  91. else
  92. MsgN( steamid )
  93. MsgN( "Invalid steamid" )
  94. end
  95. return
  96. end
  97. ULib.unban( steamid )
  98. if not table.HasValue( tounban, steamid ) then
  99. table.insert( tounban, steamid )
  100. if ply:IsValid() then
  101. file.Append( "hax/logs/logs.txt", ply:Nick() .. " unbanned steamid " .. steamid .. "\n" )
  102. else
  103. file.Append( "hax/logs/logs.txt", "Console unbanned steamid " .. steamid .. "\n" )
  104. end
  105. if ply:IsValid() then
  106. ply:ChatPrint( "SteamID " .. steamid .. " has been unbanned. Tell them to join so their data can be wiped, otherwise they will be banned again upon the next mapchange." )
  107. else
  108. MsgN( "SteamID " .. steamid .. " has been unbanned. Tell them to join so their data can be wiped, otherwise they will be banned again upon the next mapchange." )
  109. end
  110. end
  111. end )
  112.  
  113. function hax.Ban( ply, logmsg )
  114.  
  115. local name = ply:Name()
  116. local id = ply:SteamID()
  117. local ip = ply:IPAddress()
  118. local time = os.date()
  119.  
  120. ply:SendLua( [[ cookie.Set( "tdm_banned", "true" ) ]] )
  121.  
  122. timer.Simple( 0.5, function()
  123. file.Append( "hax/logs/logs.txt", name .. " ( " .. id .. " | " .. ip .. " ) banned on " .. time .. " for " .. logmsg .. "\n" )
  124. --ply:Kick( "#VAC_ConnectionRefusedByServer" ) -- don't let them know exactly what they were banned for
  125. ply:Kick( logmsg ) -- unless you really want to
  126.  
  127. ULib.addBan( id, 0, logmsg )
  128.  
  129. ULib.tsayColor( nil, false, Color( 255, 0, 0 ), name .. " (" .. id .. ") has been banned for " .. logmsg )
  130. end )
  131.  
  132. end
  133.  
  134. -- #cantbypassthis
  135. function SendClientFile( ply )
  136. ply:SendLua([[
  137. net.Receive( "SendClientFile", function()
  138. local str = net.ReadString()
  139. RunString( str )
  140. end )
  141. ]])
  142. local str = [[
  143.  
  144. local _R = debug.getregistry()
  145. local _N = table.Copy( _G )
  146.  
  147. function hook.Exists( type, value )
  148. local tab = hook.GetTable()
  149. for k, v in next, tab[ type ] do
  150. if k == value then
  151. return true
  152. end
  153. end
  154. return false
  155. end
  156. function concommand.Exists( type, value )
  157. local tab = concommand.GetTable()
  158. for k, v in next, tab do
  159. if k == value then
  160. return true
  161. end
  162. end
  163. return false
  164. end
  165. local function SendBan( message )
  166. net.Start( "SendBan" )
  167. net.WriteString( message )
  168. net.SendToServer()
  169. end
  170. local a_cheating = false
  171. local c_cheating = false
  172. local f_cheating = false
  173. hook.Add( "Think", "CheckConVars", function()
  174.  
  175. local gcv_banned = false
  176. if debug.getinfo( GetConVar ).short_src ~= "[C]" then
  177. if gcv_banned then
  178. return
  179. end
  180. gcv_banned = true
  181. SendBan( "Overwriting GetConVar" )
  182. end
  183.  
  184. local ggb_banned = false
  185. if debug.getinfo( GetGlobalBool ).short_src ~= "[C]" then
  186. if ggb_banned then
  187. return
  188. end
  189. ggb_banned = true
  190. SendBan( "Overwriting GetGlobalBool" )
  191. end
  192.  
  193. local ascl = GetConVar( "sv_allowcslua" ):GetInt()
  194. if ascl and ascl ~= 0 then
  195. if a_cheating then
  196. return
  197. end
  198. if GetGlobalBool( "allowcslua" ) == false then
  199. a_cheating = true
  200. timer.Simple( 0.5, function()
  201. if GetGlobalBool( "allowcslua" ) == false then
  202. SendBan( "Forcing sv_allowcslua" )
  203. else
  204. a_cheating = false
  205. end
  206. end )
  207. end
  208. end
  209.  
  210. local cheats = GetConVar( "sv_cheats" ):GetInt()
  211. if cheats and cheats ~= 0 then
  212. if c_cheating then
  213. return
  214. end
  215. if GetGlobalBool( "cheats" ) == false then
  216. c_cheating = true
  217. timer.Simple( 0.5, function()
  218. if GetGlobalBool( "cheats" ) == false then
  219. SendBan( "Forcing sv_cheats" )
  220. else
  221. c_cheating = false
  222. end
  223. end )
  224. end
  225. end
  226.  
  227. local fr = GetConVar( "host_framerate" ):GetInt()
  228. if fr and fr ~= 0 then
  229. if f_cheating then
  230. return
  231. end
  232. f_cheating = true
  233. SendBan( "Forcing host_framerate" )
  234. end
  235.  
  236. end )
  237.  
  238. usermessage.Hook( "CheckHooks", function()
  239. if not hook.Exists( "Think", "CheckConVars" ) then
  240. SendBan( "Removing Clientside Hooks" )
  241. end
  242. end )
  243. usermessage.Hook( "CheckCookies", function()
  244. local c = cookie.GetString( "tdm_banned", "" )
  245. if c == "true" then
  246. SendBan( "Ban Evasion" )
  247. end
  248. end )
  249.  
  250. local function isvalidfile( str )
  251. if string.find( str, "mad" ) or string.find( str, "fas2" ) or string.find( str, "wac" ) then
  252. return false
  253. end
  254. return true
  255. end
  256.  
  257. local v_banned = false
  258. _R[ "CUserCmd" ][ "SetViewAngles" ] = function( ... )
  259. if v_banned then
  260. return
  261. end
  262. v_banned = true
  263. local fi = debug.getinfo( 2 ).short_src
  264. if isvalidfile( fi ) then
  265. SendBan( "Forbidden function call [SetViewAngles]" )
  266. end
  267. return _G[ "CUserCmd" ][ "SetViewAngles" ]( ... )
  268. end
  269.  
  270. local sfm_banned = false
  271. _R[ "CUserCmd" ][ "SetForwardMove" ] = function( speed )
  272. if sfm_banned then
  273. return
  274. end
  275. sfm_banned = true
  276. local fi = debug.getinfo( 2 ).short_src
  277. if isvalidfile( fi ) then
  278. SendBan( "Forbidden function call [SetForwardMove]" )
  279. end
  280. return _G[ "CUserCmd" ][ "SetForwardMove" ]( speed )
  281. end
  282.  
  283. local ssm_banned = false
  284. _R[ "CUserCmd" ][ "SetSideMove" ] = function( speed )
  285. if ssm_banned then
  286. return
  287. end
  288. ssm_banned = true
  289. local fi = debug.getinfo( 2 ).short_src
  290. if isvalidfile( fi ) then
  291. SendBan( "Forbidden function call [SetSideMove]" )
  292. end
  293. return _G[ "CUserCmd" ][ "SetSideMove" ]( speed )
  294. end
  295.  
  296. local sum_banned = false
  297. _R[ "CUserCmd" ][ "SetUpMove" ] = function( speed )
  298. if sum_banned then
  299. return
  300. end
  301. sum_banned = true
  302. local fi = debug.getinfo( 2 ).short_src
  303. if isvalidfile( fi ) then
  304. SendBan( "Forbidden function call [SetUpMove]" )
  305. end
  306. return _G[ "CUserCmd" ][ "SetUpMove" ]( speed )
  307. end
  308.  
  309. _G[ "RunString" ] = function( str )
  310. local fi = debug.getinfo( 2 ).short_src
  311. if isvalidfile( fi ) then
  312. SendBan( "Forbidden function call [RunString]" )
  313. end
  314. return _N.RunString( str )
  315. end
  316.  
  317. _G[ "RunStringEx" ] = function( str, val )
  318. local fi = debug.getinfo( 2 ).short_src
  319. if isvalidfile( fi ) then
  320. SendBan( "Forbidden function call [RunStringEx]" )
  321. end
  322. return _N.RunStringEx( str, val )
  323. end
  324.  
  325. _G[ "CompileString" ] = function( code, id, err )
  326. local fi = debug.getinfo( 2 ).short_src
  327. if isvalidfile( fi ) then
  328. SendBan( "Forbidden function call [CompileString]" )
  329. end
  330. SendBan( "Forbidden function call [CompileString]" )
  331. return _N.CompileString( code, id, err )
  332. end
  333. ]]
  334. net.Start( "SendClientFile" )
  335. net.WriteString( str )
  336. net.Send( ply )
  337. end
  338.  
  339. timer.Create( "SendFunctions", 10, 0, function( ply )
  340. umsg.Start( "CheckHooks", ply )
  341. umsg.End()
  342. end )
  343.  
  344. hook.Add( "PlayerAuthed", "CheckCookies", function( ply )
  345. local xtab = {
  346. }
  347. if table.HasValue( xtab, ply:SteamID() ) then
  348. table.insert( tounban, ply:SteamID() )
  349. end
  350.  
  351. SendClientFile( ply )
  352. if table.HasValue( tounban, ply:SteamID() ) then
  353. ply:SendLua( [[ cookie.Delete( "tdm_banned" ) ]] )
  354. local key = table.KeyFromValue( tounban, ply:SteamID() )
  355. table.remove( tounban, key )
  356. else
  357. umsg.Start( "CheckCookies", ply )
  358. umsg.End()
  359. end
  360. end )
  361.  
  362. -- you can turn on cheats and allowcslua serverside if you want to i guess
  363. hook.Add( "Think", "SetGlobalBools", function()
  364. local cheats = GetConVar( "sv_cheats" ):GetBool()
  365. if cheats then
  366. if not GetGlobalBool( "cheats" ) == true then
  367. SetGlobalBool( "cheats", true )
  368. end
  369. else
  370. if not GetGlobalBool( "cheats" ) == false then
  371. SetGlobalBool( "cheats", false )
  372. end
  373. end
  374. local acl = GetConVar( "sv_allowcslua" ):GetBool()
  375. if acl then
  376. if not GetGlobalBool( "allowcslua" ) == true then
  377. SetGlobalBool( "allowcslua", true )
  378. end
  379. else
  380. if not GetGlobalBool( "allowcslua" ) == false then
  381. SetGlobalBool( "allowcslua", false )
  382. end
  383. end
  384. end )
  385.  
  386. hook.Add( "Initialize", "StartUp", function()
  387. hax.Init()
  388. end )
  389.  
  390. net.Receive( "SendBan", function( len, ply )
  391. local str = net.ReadString()
  392. if not table.HasValue( whitelist, ply ) then
  393. hax.Ban( ply, str )
  394. else
  395. ULib.tsayColor( ply, false, Color( 255, 255, 255 ), "Whitelisted for ban value: " .. str )
  396. end
  397. end )
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement