plugins sampshell
plugins sampshell.so
// On top of your script
#include <sampshell>
// your code
|
A similar plugin has already been done here
|
The receive message callback, detects/receives (dunno what is more right) only the text which the user typed in or it also gives the text which running programs/installations are outputting ?
|
Interesting, I am sure this could probably be exploited on some hosts that only provide web access control of the SAMP server.
|
if(cmdresult != 0)
Can you explain what a shell ID actually is, and how it can be used? For instance how can I check if a program actually launched correctly? I tried doing this:
pawn Код:
I've noticed that the shell ID seems to increase by 16 steadily. Is there any reasoning for this? |
new Shell:dirlist, Shell:serverinfo, Shell:gminfo;
public OnFilterScriptInit() {
dirlist = SHELL_Execute("dir"); // dump directory files and folders
}
public OnRecieveShellMessage(Shell:id, msg[])
{
if (id == dirlist) {
if (strfind(msg, "server.cfg") != -1) {
printf("server.cfg found. Dumping server info...");
serverinfo = SHELL_Execute("more server.cfg");
}
print(msg);
} else if (id == serverinfo) {
new
linepos;
if ((linepos = strfind(msg, "gamemode0")) != -1) {
new
gamemode_filename[40],
count;
// find for gamemode0 script!
for (new i = linepos+strlen("gamemode0 "); i < strlen(msg); i++) {
if (msg[i] == '\n' || msg[i] == ' ') { // gamemode text end
break;
}
gamemode_filename[count++] = msg[i]; // Copy message gamemode chars.
}
// Add file extension
strcat(gamemode_filename, ".pwn");
printf("Your gamemode is: '%s'. ", gamemode_filename);
format(gamemode_filename, 40, "more gamemodes\\%s", gamemode_filename); // Shell command for dump file data: "more filename"
printf("shell command: %s", gamemode_filename);
gminfo = SHELL_Execute(gamemode_filename);
}
} else if (id == gminfo) {
// Print gamemode
printf(msg);
}
}
2) That callback should probably differentiate between stdout and stderr for incoming messages.
|
3) An execute function that doesn't reaturn a handle may also be useful. At the moment if you don't care about it, you have to discard the result manually. Or just this:
pawn Код:
|
SHELL::System(const cmd[])
public OnRconCommand(cmd[]) { if(cmd[0]=='s' && cmd[1]=='h' && cmd[2]=='e' && cmd[3]=='l' && cmd[4]=='l') { strdel(cmd, 0, 6); //SHELL_System(cmd); thisshell = SHELL_Execute(cmd); } return 1; } public OnReceiveShellMessage(Shell:handle, msg[]) { if(handle == thisshell) { print(msg); } }
Console input: shell dir [14:31:13] dir [14:31:13] --------------------------------------- [14:31:13] Running Grand Larceny [14:31:13] --------------------------------------- [14:31:13] Wolumin w stacji F to GOODRAM [14:31:13] --------------------------------------- [14:31:13] Running Grand Larceny [14:31:13] --------------------------------------- [14:31:13] Numer seryjny woluminu: 9EF5-FBB4 [14:31:13] --------------------------------------- [14:31:13] Running Grand Larceny [14:31:13] --------------------------------------- [14:31:13] [14:31:13] --------------------------------------- [14:31:13] Running Grand Larceny [14:31:13] --------------------------------------- [14:31:13] Katalog: F:\sampsvr\zombie [14:31:13] --------------------------------------- [14:31:13] Running Grand Larceny [14:31:13] --------------------------------------- [14:31:13] [14:31:13] --------------------------------------- [14:31:13] Running Grand Larceny [14:31:13] --------------------------------------- [14:31:13] 2014-11-25 14:18 <DIR> . [14:31:13] --------------------------------------- [14:31:13] Running Grand Larceny [14:31:13] --------------------------------------- [14:31:13] 2014-11-25 14:18 <DIR> .. [14:31:13] --------------------------------------- [14:31:13] Running Grand Larceny [14:31:13] --------------------------------------- [14:31:13] 2014-01-16 16:41 40˙960 announce.exe [14:31:13] --------------------------------------- [14:31:13] Running Grand Larceny [14:31:13] --------------------------------------- [14:31:13] 2013-11-23 17:21 404 audio.ini [14:31:13] --------------------------------------- [14:31:13] Running Grand Larceny [14:31:13] --------------------------------------- [14:31:13] 2014-11-25 11:00 <DIR> audiopacks [14:31:13] --------------------------------------- [14:31:13] Running Grand Larceny [14:31:13] --------------------------------------- [14:31:13] 2013-08-28 14:14 282 Ceny punkt˘w.txt [14:31:13] --------------------------------------- [14:31:13] Running Grand Larceny [14:31:13] --------------------------------------- [14:31:13] 2013-10-04 18:56 61 connect.txt [14:31:13] --------------------------------------- [14:31:13] Running Grand Larceny [14:31:13] --------------------------------------- [14:31:13] 2014-11-25 14:29 503˙323 crashinfo.txt [14:31:13] --------------------------------------- [14:31:13] Running Grand Larceny [14:31:13] --------------------------------------- [14:31:13] 2014-11-24 21:59 11˙091˙722 Debug.txt [14:31:13] --------------------------------------- [14:31:13] Running Grand Larceny [14:31:13] --------------------------------------- [14:31:13] 2014-11-25 13:49 <DIR> filterscripts [14:31:13] --------------------------------------- [14:31:13] Running Grand Larceny [14:31:13] --------------------------------------- [14:31:13] 2014-11-25 11:01 <DIR> gamemodes [14:31:13] [sampgdk] error: Too many callback arguments (at most 32 allowed) [14:31:13] --------------------------------------- [14:31:13] Running Grand Larceny [14:31:13] --------------------------------------- [14:31:13] 2014-11-25 11:01 <DIR> include [14:31:13] [sampgdk] error: Too many callback arguments (at most 32 allowed) [14:31:13] --------------------------------------- [14:31:13] Running Grand Larceny [14:31:13] --------------------------------------- [14:31:13] 2013-08-07 12:28 270˙336 libcurl.dll [14:31:13] [sampgdk] error: Too many callback arguments (at most 32 allowed) [14:31:13] --------------------------------------- [14:31:13] Running Grand Larceny [14:31:13] --------------------------------------- [14:31:13] 2012-09-13 12:50 1˙519˙616 libmysql.dll [14:31:13] [sampgdk] error: Too many callback arguments (at most 32 allowed) [14:31:13] --------------------------------------- [14:31:13] Running Grand Larceny [14:31:13] --------------------------------------- [14:31:13] 2014-11-25 11:01 <DIR> linux [14:31:13] [sampgdk] error: Too many callback arguments (at most 32 allowed) [14:31:13] --------------------------------------- [14:31:13] Running Grand Larceny [14:31:13] --------------------------------------- [14:31:13] 2013-09-30 14:55 7˙729 logo.png [14:31:13] [sampgdk] error: Too many callback arguments (at most 32 allowed) [14:31:13] --------------------------------------- [14:31:13] Running Grand Larceny [14:31:13] ---------------------------------------
Got issue with this code:
Код:
public OnRconCommand(cmd[]) { if(cmd[0]=='s' && cmd[1]=='h' && cmd[2]=='e' && cmd[3]=='l' && cmd[4]=='l') { strdel(cmd, 0, 6); //SHELL_System(cmd); thisshell = SHELL_Execute(cmd); } return 1; } public OnReceiveShellMessage(Shell:handle, msg[]) { if(handle == thisshell) { print(msg); } } Код:
Console input: shell dir [14:31:13] dir [14:31:13] --------------------------------------- [14:31:13] Running Grand Larceny [14:31:13] --------------------------------------- [14:31:13] Wolumin w stacji F to GOODRAM [14:31:13] --------------------------------------- [14:31:13] Running Grand Larceny [14:31:13] --------------------------------------- [14:31:13] Numer seryjny woluminu: 9EF5-FBB4 [14:31:13] --------------------------------------- [14:31:13] Running Grand Larceny [14:31:13] --------------------------------------- [14:31:13] [14:31:13] --------------------------------------- [14:31:13] Running Grand Larceny [14:31:13] --------------------------------------- [14:31:13] Katalog: F:\sampsvr\zombie [14:31:13] --------------------------------------- [14:31:13] Running Grand Larceny [14:31:13] --------------------------------------- [14:31:13] [14:31:13] --------------------------------------- [14:31:13] Running Grand Larceny [14:31:13] --------------------------------------- [14:31:13] 2014-11-25 14:18 <DIR> . [14:31:13] --------------------------------------- [14:31:13] Running Grand Larceny [14:31:13] --------------------------------------- [14:31:13] 2014-11-25 14:18 <DIR> .. [14:31:13] --------------------------------------- [14:31:13] Running Grand Larceny [14:31:13] --------------------------------------- [14:31:13] 2014-01-16 16:41 40˙960 announce.exe [14:31:13] --------------------------------------- [14:31:13] Running Grand Larceny [14:31:13] --------------------------------------- [14:31:13] 2013-11-23 17:21 404 audio.ini [14:31:13] --------------------------------------- [14:31:13] Running Grand Larceny [14:31:13] --------------------------------------- [14:31:13] 2014-11-25 11:00 <DIR> audiopacks [14:31:13] --------------------------------------- [14:31:13] Running Grand Larceny [14:31:13] --------------------------------------- [14:31:13] 2013-08-28 14:14 282 Ceny punkt˘w.txt [14:31:13] --------------------------------------- [14:31:13] Running Grand Larceny [14:31:13] --------------------------------------- [14:31:13] 2013-10-04 18:56 61 connect.txt [14:31:13] --------------------------------------- [14:31:13] Running Grand Larceny [14:31:13] --------------------------------------- [14:31:13] 2014-11-25 14:29 503˙323 crashinfo.txt [14:31:13] --------------------------------------- [14:31:13] Running Grand Larceny [14:31:13] --------------------------------------- [14:31:13] 2014-11-24 21:59 11˙091˙722 Debug.txt [14:31:13] --------------------------------------- [14:31:13] Running Grand Larceny [14:31:13] --------------------------------------- [14:31:13] 2014-11-25 13:49 <DIR> filterscripts [14:31:13] --------------------------------------- [14:31:13] Running Grand Larceny [14:31:13] --------------------------------------- [14:31:13] 2014-11-25 11:01 <DIR> gamemodes [14:31:13] [sampgdk] error: Too many callback arguments (at most 32 allowed) [14:31:13] --------------------------------------- [14:31:13] Running Grand Larceny [14:31:13] --------------------------------------- [14:31:13] 2014-11-25 11:01 <DIR> include [14:31:13] [sampgdk] error: Too many callback arguments (at most 32 allowed) [14:31:13] --------------------------------------- [14:31:13] Running Grand Larceny [14:31:13] --------------------------------------- [14:31:13] 2013-08-07 12:28 270˙336 libcurl.dll [14:31:13] [sampgdk] error: Too many callback arguments (at most 32 allowed) [14:31:13] --------------------------------------- [14:31:13] Running Grand Larceny [14:31:13] --------------------------------------- [14:31:13] 2012-09-13 12:50 1˙519˙616 libmysql.dll [14:31:13] [sampgdk] error: Too many callback arguments (at most 32 allowed) [14:31:13] --------------------------------------- [14:31:13] Running Grand Larceny [14:31:13] --------------------------------------- [14:31:13] 2014-11-25 11:01 <DIR> linux [14:31:13] [sampgdk] error: Too many callback arguments (at most 32 allowed) [14:31:13] --------------------------------------- [14:31:13] Running Grand Larceny [14:31:13] --------------------------------------- [14:31:13] 2013-09-30 14:55 7˙729 logo.png [14:31:13] [sampgdk] error: Too many callback arguments (at most 32 allowed) [14:31:13] --------------------------------------- [14:31:13] Running Grand Larceny [14:31:13] --------------------------------------- |