Advertisement
Guest User

Untitled

a guest
Jul 29th, 2012
507
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 11.39 KB | None | 0 0
  1. new PlVers:__version = 5;
  2. new Float:NULL_VECTOR[3];
  3. new String:NULL_STRING[1];
  4. new Extension:__ext_core = 64;
  5. new MaxClients;
  6. new Extension:__ext_sdktools = 180;
  7. new Extension:__ext_cstrike = 224;
  8. new String:xbox_autothrottleValue[256][64];
  9. new Handle:sprotect_site;
  10. new Handle:g_hDb;
  11. public Plugin:myinfo =
  12. {
  13. name = "SteamID Protect System",
  14. description = "Protect SteamID from hacking",
  15. author = "igodsewer and S. Yakupov | Original plugin by SemJeF",
  16. version = "1.0b",
  17. url = "http://alliedmods.net"
  18. };
  19. public __ext_core_SetNTVOptional()
  20. {
  21. MarkNativeAsOptional("GetFeatureStatus");
  22. MarkNativeAsOptional("RequireFeature");
  23. MarkNativeAsOptional("AddCommandListener");
  24. MarkNativeAsOptional("RemoveCommandListener");
  25. VerifyCoreVersion();
  26. return 0;
  27. }
  28.  
  29. bool:StrEqual(String:str1[], String:str2[], bool:caseSensitive)
  30. {
  31. return strcmp(str1, str2, caseSensitive) == 0;
  32. }
  33.  
  34. public OnPluginStart()
  35. {
  36. RegConsoleCmd("secure", Command_Protect, "", 0);
  37. CreateConVar("sm_sprotect_version", "1.0", "", 0, false, 0, false, 0);
  38. sprotect_site = CreateConVar("sm_sprotect_site", "http://yoursite.net/", "Link to password retrieve script", 262144, false, 0, false, 0);
  39. db_setupDatabase();
  40. AutoExecConfig(true, "plugin_protect", "sourcemod");
  41. return 0;
  42. }
  43.  
  44. public Action:Command_Protect(client, args)
  45. {
  46. if (args != 2)
  47. {
  48. PrintToChat(client, "%s Errors in input! Example: /secure \"pass\" \"secret phrase\"", "[SPS]");
  49. return Action:3;
  50. }
  51. decl String:szSteamId[32];
  52. GetClientAuthString(client, szSteamId, 32);
  53. decl String:query[256];
  54. Format(query, 255, "SELECT pass FROM protect WHERE steamid ='%s'", szSteamId);
  55. new Handle:hquery = SQL_Query(g_hDb, query, -1);
  56. new var1;
  57. if (hquery)
  58. {
  59. PrintToChat(client, "%s You are already registered!", "[SPS]");
  60. return Action:3;
  61. }
  62. CloseHandle(hquery);
  63. decl String:newpass[256];
  64. decl String:kod[256];
  65. decl String:Safenewpass5[256];
  66. decl String:Safekod5[256];
  67. GetCmdArg(1, newpass, 255);
  68. GetCmdArg(2, kod, 255);
  69. decl String:Safekod[512];
  70. SQL_EscapeString(g_hDb, kod, Safekod, 511, 0);
  71. decl String:Safenewpass[512];
  72. SQL_EscapeString(g_hDb, newpass, Safenewpass, 511, 0);
  73. MD5String(Safenewpass, Safenewpass5, 255);
  74. MD5String(Safekod, Safekod5, 255);
  75. Format(query, 255, "INSERT INTO protect (steamid, pass, kod) VALUES('%s', '%s', '%s');", szSteamId, Safenewpass5, Safekod5);
  76. SQL_TQuery(g_hDb, SQLTCallback:9, query, any:0, DBPriority:1);
  77. decl String:SiteStr[256];
  78. GetConVarString(sprotect_site, SiteStr, 256);
  79. PrintToChat(client, "%s Your SteamID sucessfully secured! Password: %s", "[SPS]", newpass, kod);
  80. PrintToChat(client, "%s Don't forget to type in console xbox_autothrottle \"%s\" ", "[SPS]", newpass);
  81. PrintToChat(client, "%s Enjoy! Password retrive link: %s", "[SPS]", SiteStr);
  82. return Action:3;
  83. }
  84.  
  85. public db_setupDatabase()
  86. {
  87. decl String:szError[256];
  88. g_hDb = SQL_Connect("Protect", false, szError, 255);
  89. if (g_hDb)
  90. {
  91. db_createTables();
  92. return 0;
  93. }
  94. LogError("[Protect] Unable to connect to database (%s)", szError);
  95. PrintToServer("[Protect] Unable to connect to database");
  96. return 0;
  97. }
  98.  
  99. public db_createTables()
  100. {
  101. SQL_LockDatabase(g_hDb);
  102. SQL_FastQuery(g_hDb, "CREATE TABLE IF NOT EXISTS protect (steamid VARCHAR(32) PRIMARY KEY, pass VARCHAR(128), kod VARCHAR(128));", -1);
  103. SQL_UnlockDatabase(g_hDb);
  104. return 0;
  105. }
  106.  
  107. public SQL_CheckCallback(Handle:owner, Handle:hndl, String:error[], data)
  108. {
  109. if (!hndl)
  110. {
  111. LogError("%s Error inserting into database (%s)", "[SPS]", error);
  112. }
  113. return 0;
  114. }
  115.  
  116. public OnClientPutInServer(client)
  117. {
  118. QueryClientConVar(client, "xbox_autothrottle", ConVarQueryFinished:1, client);
  119. return 0;
  120. }
  121.  
  122. public ClientConVar(QueryCookie:cookie, client, ConVarQueryResult:result, String:cvarName[], String:cvarValue[])
  123. {
  124. strcopy(xbox_autothrottleValue[client][0][0], 255, cvarValue);
  125. db_selectPlayer(client);
  126. return 0;
  127. }
  128.  
  129. public db_selectPlayer(client)
  130. {
  131. decl String:szQuery[256];
  132. decl String:szSteamId[32];
  133. GetClientAuthString(client, szSteamId, 32);
  134. Format(szQuery, 255, "SELECT pass FROM protect WHERE steamid ='%s'", szSteamId);
  135. SQL_TQuery(g_hDb, SQLTCallback:11, szQuery, client, DBPriority:1);
  136. return 0;
  137. }
  138.  
  139. public SQL_SelectPlayerCallback(Handle:owner, Handle:hndl, String:error[], data)
  140. {
  141. if (hndl)
  142. {
  143. decl String:sValue[256];
  144. new client = data;
  145. decl String:xbox_autothrottleValue5[256];
  146. new var1;
  147. if (SQL_HasResultSet(hndl))
  148. {
  149. SQL_FetchString(hndl, 0, sValue, 256, 0);
  150. MD5String(xbox_autothrottleValue[client][0][0], xbox_autothrottleValue5[client], 256);
  151. if (StrEqual(sValue, xbox_autothrottleValue5[client], false))
  152. {
  153. PrintToChat(client, "%s Вы прошли авторизацию!", "[SPS]");
  154. }
  155. else
  156. {
  157. KickHim(client);
  158. }
  159. }
  160. return 0;
  161. }
  162. else
  163. {
  164. LogError("[%s Error loading player (%s)", "[SPS]", error);
  165. }
  166. return 0;
  167. }
  168.  
  169. KickHim(client)
  170. {
  171. decl String:SiteStr[256];
  172. GetConVarString(sprotect_site, SiteStr, 256);
  173. KickClient(client, "%s This SteamID is secured. If you forgot password follow this link: %s", "[SPS]", SiteStr);
  174. return 0;
  175. }
  176.  
  177. MD5String(String:str[], String:output[], maxlen)
  178. {
  179. decl x[2];
  180. decl buf[4];
  181. decl input[64];
  182. new i = 0;
  183. new ii = 0;
  184. new len = strlen(str);
  185. x[4] = 0;
  186. x[0] = 0;
  187. buf[0] = 1732584193;
  188. buf[4] = -271733879;
  189. buf[8] = -1732584194;
  190. buf[12] = 271733878;
  191. decl in[16];
  192. in[56] = x[0];
  193. in[60] = x[4];
  194. new mdi = x[0] >> 3 & 63;
  195. if (x[0] > len << 3 + x[0])
  196. {
  197. x[4] += 1;
  198. }
  199. x[0] = len << 3 + x[0];
  200. new var2 = x[4];
  201. var2 = len >> 29 + var2;
  202. new c = 0;
  203. len--;
  204. while (len)
  205. {
  206. input[mdi] = str[c];
  207. mdi += 1;
  208. c += 1;
  209. if (mdi == 64)
  210. {
  211. i = 0;
  212. ii = 0;
  213. while (i < 16)
  214. {
  215. in[i] = input[ii] | input[ii + 1] << 8 | input[ii + 2] << 16 | input[ii + 3] << 24;
  216. i++;
  217. ii += 4;
  218. }
  219. MD5Transform(buf, in);
  220. mdi = 0;
  221. }
  222. }
  223. decl padding[64];
  224. decl inx[16];
  225. inx[56] = x[0];
  226. inx[60] = x[4];
  227. mdi = x[0] >> 3 & 63;
  228. new var1;
  229. if (mdi < 56)
  230. {
  231. var1 = 56 - mdi;
  232. }
  233. else
  234. {
  235. var1 = 120 - mdi;
  236. }
  237. len = var1;
  238. in[56] = x[0];
  239. in[60] = x[4];
  240. mdi = x[0] >> 3 & 63;
  241. if (x[0] > len << 3 + x[0])
  242. {
  243. x[4] += 1;
  244. }
  245. x[0] = len << 3 + x[0];
  246. new var3 = x[4];
  247. var3 = len >> 29 + var3;
  248. c = 0;
  249. len--;
  250. while (len)
  251. {
  252. input[mdi] = padding[c];
  253. mdi += 1;
  254. c += 1;
  255. if (mdi == 64)
  256. {
  257. i = 0;
  258. ii = 0;
  259. while (i < 16)
  260. {
  261. in[i] = input[ii] | input[ii + 1] << 8 | input[ii + 2] << 16 | input[ii + 3] << 24;
  262. i++;
  263. ii += 4;
  264. }
  265. MD5Transform(buf, in);
  266. mdi = 0;
  267. }
  268. }
  269. i = 0;
  270. ii = 0;
  271. while (i < 14)
  272. {
  273. inx[i] = input[ii] | input[ii + 1] << 8 | input[ii + 2] << 16 | input[ii + 3] << 24;
  274. i++;
  275. ii += 4;
  276. }
  277. MD5Transform(buf, inx);
  278. decl digest[16];
  279. i = 0;
  280. ii = 0;
  281. while (i < 4)
  282. {
  283. digest[ii] = buf[i] & 255;
  284. digest[ii + 1] = buf[i] >> 8 & 255;
  285. digest[ii + 2] = buf[i] >> 16 & 255;
  286. digest[ii + 3] = buf[i] >> 24 & 255;
  287. i++;
  288. ii += 4;
  289. }
  290. FormatEx(output, maxlen, "%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x", digest, digest[4], digest[8], digest[12], digest[16], digest[20], digest[24], digest[28], digest[32], digest[36], digest[40], digest[44], digest[48], digest[52], digest[56], digest[60]);
  291. return 0;
  292. }
  293.  
  294. MD5Transform_FF(&a, &b, &c, &d, x, s, ac)
  295. {
  296. a = d & ~b | c & b + x + ac + a;
  297. a = a >> 32 - s | a << s;
  298. a = b + a;
  299. return 0;
  300. }
  301.  
  302. MD5Transform_GG(&a, &b, &c, &d, x, s, ac)
  303. {
  304. a = ~d & c | d & b + x + ac + a;
  305. a = a >> 32 - s | a << s;
  306. a = b + a;
  307. return 0;
  308. }
  309.  
  310. MD5Transform_HH(&a, &b, &c, &d, x, s, ac)
  311. {
  312. a = d ^ c ^ b + x + ac + a;
  313. a = a >> 32 - s | a << s;
  314. a = b + a;
  315. return 0;
  316. }
  317.  
  318. MD5Transform_II(&a, &b, &c, &d, x, s, ac)
  319. {
  320. a = ~d | b ^ c + x + ac + a;
  321. a = a >> 32 - s | a << s;
  322. a = b + a;
  323. return 0;
  324. }
  325.  
  326. MD5Transform(buf[], in[])
  327. {
  328. new a = buf[0];
  329. new b = buf[4];
  330. new c = buf[8];
  331. new d = buf[12];
  332. MD5Transform_FF(a, b, c, d, in[0], 7, -680876936);
  333. MD5Transform_FF(d, a, b, c, in[4], 12, -389564586);
  334. MD5Transform_FF(c, d, a, b, in[8], 17, 606105819);
  335. MD5Transform_FF(b, c, d, a, in[12], 22, -1044525330);
  336. MD5Transform_FF(a, b, c, d, in[16], 7, -176418897);
  337. MD5Transform_FF(d, a, b, c, in[20], 12, 1200080426);
  338. MD5Transform_FF(c, d, a, b, in[24], 17, -1473231341);
  339. MD5Transform_FF(b, c, d, a, in[28], 22, -45705983);
  340. MD5Transform_FF(a, b, c, d, in[32], 7, 1770035416);
  341. MD5Transform_FF(d, a, b, c, in[36], 12, -1958414417);
  342. MD5Transform_FF(c, d, a, b, in[40], 17, -42063);
  343. MD5Transform_FF(b, c, d, a, in[44], 22, -1990404162);
  344. MD5Transform_FF(a, b, c, d, in[48], 7, 1804603682);
  345. MD5Transform_FF(d, a, b, c, in[52], 12, -40341101);
  346. MD5Transform_FF(c, d, a, b, in[56], 17, -1502002290);
  347. MD5Transform_FF(b, c, d, a, in[60], 22, 1236535329);
  348. MD5Transform_GG(a, b, c, d, in[4], 5, -165796510);
  349. MD5Transform_GG(d, a, b, c, in[24], 9, -1069501632);
  350. MD5Transform_GG(c, d, a, b, in[44], 14, 643717713);
  351. MD5Transform_GG(b, c, d, a, in[0], 20, -373897302);
  352. MD5Transform_GG(a, b, c, d, in[20], 5, -701558691);
  353. MD5Transform_GG(d, a, b, c, in[40], 9, 38016083);
  354. MD5Transform_GG(c, d, a, b, in[60], 14, -660478335);
  355. MD5Transform_GG(b, c, d, a, in[16], 20, -405537848);
  356. MD5Transform_GG(a, b, c, d, in[36], 5, 568446438);
  357. MD5Transform_GG(d, a, b, c, in[56], 9, -1019803690);
  358. MD5Transform_GG(c, d, a, b, in[12], 14, -187363961);
  359. MD5Transform_GG(b, c, d, a, in[32], 20, 1163531501);
  360. MD5Transform_GG(a, b, c, d, in[52], 5, -1444681467);
  361. MD5Transform_GG(d, a, b, c, in[8], 9, -51403784);
  362. MD5Transform_GG(c, d, a, b, in[28], 14, 1735328473);
  363. MD5Transform_GG(b, c, d, a, in[48], 20, -1926607734);
  364. MD5Transform_HH(a, b, c, d, in[20], 4, -378558);
  365. MD5Transform_HH(d, a, b, c, in[32], 11, -2022574463);
  366. MD5Transform_HH(c, d, a, b, in[44], 16, 1839030562);
  367. MD5Transform_HH(b, c, d, a, in[56], 23, -35309556);
  368. MD5Transform_HH(a, b, c, d, in[4], 4, -1530992060);
  369. MD5Transform_HH(d, a, b, c, in[16], 11, 1272893353);
  370. MD5Transform_HH(c, d, a, b, in[28], 16, -155497632);
  371. MD5Transform_HH(b, c, d, a, in[40], 23, -1094730640);
  372. MD5Transform_HH(a, b, c, d, in[52], 4, 681279174);
  373. MD5Transform_HH(d, a, b, c, in[0], 11, -358537222);
  374. MD5Transform_HH(c, d, a, b, in[12], 16, -722521979);
  375. MD5Transform_HH(b, c, d, a, in[24], 23, 76029189);
  376. MD5Transform_HH(a, b, c, d, in[36], 4, -640364487);
  377. MD5Transform_HH(d, a, b, c, in[48], 11, -421815835);
  378. MD5Transform_HH(c, d, a, b, in[60], 16, 530742520);
  379. MD5Transform_HH(b, c, d, a, in[8], 23, -995338651);
  380. MD5Transform_II(a, b, c, d, in[0], 6, -198630844);
  381. MD5Transform_II(d, a, b, c, in[28], 10, 1126891415);
  382. MD5Transform_II(c, d, a, b, in[56], 15, -1416354905);
  383. MD5Transform_II(b, c, d, a, in[20], 21, -57434055);
  384. MD5Transform_II(a, b, c, d, in[48], 6, 1700485571);
  385. MD5Transform_II(d, a, b, c, in[12], 10, -1894986606);
  386. MD5Transform_II(c, d, a, b, in[40], 15, -1051523);
  387. MD5Transform_II(b, c, d, a, in[4], 21, -2054922799);
  388. MD5Transform_II(a, b, c, d, in[32], 6, 1873313359);
  389. MD5Transform_II(d, a, b, c, in[60], 10, -30611744);
  390. MD5Transform_II(c, d, a, b, in[24], 15, -1560198380);
  391. MD5Transform_II(b, c, d, a, in[52], 21, 1309151649);
  392. MD5Transform_II(a, b, c, d, in[16], 6, -145523070);
  393. MD5Transform_II(d, a, b, c, in[44], 10, -1120210379);
  394. MD5Transform_II(c, d, a, b, in[8], 15, 718787259);
  395. MD5Transform_II(b, c, d, a, in[36], 21, -343485551);
  396. new var1 = buf;
  397. var1[0] = var1[0] + a;
  398. buf[4] += b;
  399. buf[8] += c;
  400. buf[12] += d;
  401. return 0;
  402. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement