[INC] Md5 Security Plugin

For scripting examples for learning how to use AMXX.
User avatar
Archive-Poster
Posts: 1189
Gender:
United States of America

[INC] Md5 Security Plugin

Post by Archive-Poster »

Hi I was making a plugin for the server and I figured I could make the .inc to avoid putting it every time that I wanted to protect a plugin, and I created this; no big deal; let's explain this out .

Description
It's really simple, a md5 is created from the server Ip (port included), adding a letter/number in any position you choose and making another md5 again; this is saved in a file, in "Configs" folder.
Change name file
We open the file security.inc and search for the constant called "ValidationFile" and we change the string;
Change error name
We open the file security.inc and search for the constant called "FailStateSay" and we change the string;
Create validation file
A really minmum amount of knowledge is needed to create the validation code. It's as simple as this

Code: Select all

#include <amxmodx>
#include <security>

#define PLUGIN "Create Validation Code"
#define VERSION "1.0"
#define AUTHOR "[R]ak"

public plugin_init() {
    register_plugin(PLUGIN, VERSION, AUTHOR)
    
    security_md5_create_file("7", 17) 
    // "7" value to add to the first md5
    // 17 position where is alocated "7"
    // if you want create a custom validation key use the stock in this form
    // security_md5_create_file("7", 17, "192.168.1.1:27015")
} 
After running this plugin we won't need it anymore; we just must remember the values used to add them to our plugin later
Protect our plugin
With the validation file created we just need to add to our plugin it's protection; this is so simple like attaching an include and set a stock.

Code: Select all

#include <amxmodx>
#include <security>

#define PLUGIN "Protected Plugin"
#define VERSION "1.0"
#define AUTHOR "[R]ak"

public plugin_init() {
    register_plugin(PLUGIN, VERSION, AUTHOR)
    
    security_md5("7", 17) // in the last example this parameter is explained.
} 
Now, if the file doesn't exist, or de code is different, the message alocated in the constant "FailStateSay" will pop up; which in my case would be "Invalid Activation code".

Just a piece of cake (:,

Enjoy!
Attachments
security.inc.zip
(983 Bytes) Downloaded 3 times

Who is online

Users browsing this forum: No registered users and 1 guest