kill command [1.5]

Page 1 of 2 12 LastLast
Results 1 to 15 of 20
  1. #1
    Yaaay! Tannous is offline
    MemberRank
    Jul 2012 Join Date
    KonohaLocation
    840Posts

    kill command [1.5]

    Hello again, imma make this really fast, since i've been asked 3 times in pm about this command, and some more command.
    So just a NOTE: all other commands such as /freeze <player> or /respawn <player> as some guys wanted, it's the same as this one, so just do the same things, i'm not gonna do them all, too lazy XD !!!
    Usage: /kill <player>
    Gunz/ZChat_Cmds.cpp
    Code:
    void ChatCmd_Kill(const char* line, const int argc, char **const argv);
    Code:
    _CC_AC("kill", &ChatCmd_Kill, CCF_ADMIN|CCF_GAME, ARGVNoMin, 1, true, "/kill <charname>", "");
    Code:
    void ChatCmd_Kill(const char* line, const int argc, char **const argv)
    {
    	if(argc < 2)
    	{
    		ZChatOutput("Usage: /kill <charname>", ZChat::CMT_SYSTEM);
    		return;
    	}
    	ZPOSTCMD2(MC_KILL_THIS_PLAYER, MCmdParamStr(""), MCmdParamStr(argv[1]));
    }
    Gunz/ZGameClient_OnCommand.cpp
    Code:
    case MC_KILL_THIS_PLAYER:
    {
    	char AdminName[256] = "";
    	char TargetName[256] = "";
    	char szMsg[256];
    
            if(ZGetMyInfo()->IsAdminGrade())
    		break;
    
            pCommand->GetParameter(AdminName, 0, MPT_STR, sizeof(AdminName));
    	pCommand->GetParameter(TargetName, 1, MPT_STR, sizeof(TargetName));
            ZCharacterManager *pZCharacterManager = ZGetCharacterManager();
            if (pZCharacterManager != NULL) 
            {
                 for (ZCharacterManager::iterator itor = pZCharacterManager->begin(); itor != pZCharacterManager->end(); ++itor) 
                 {
                      ZCharacter* pCharacter = (*itor).second;
                      if (strcmp(pCharacter->GetProperty()->GetName(), TargetName) == 0)
    				pCharacter->SetHP(0);
                 }
            }
    	sprintf(szMsg, "^2%s has slained %s", AdminName, TargetName);
    	ZChatOutput(szMsg);
    }
    break;
    CSCommon/MMatchServer_OnCommand.cpp
    Code:
    case MC_KILL_THIS_PLAYER:
    {
    	char AdminName[256] = "";
    	char TargetName[256] = "";
    	char szMsg[256];
    
    	if(!pCommand->GetParameter(AdminName, 0, MPT_STR))
    		break;
    	MMatchObject* pChar = GetObjectA(pCommand->GetSenderUID());
    	pCommand->GetParameter(TargetName, 1, MPT_STR, sizeof(TargetName));
    				
    	if(pChar == NULL)
    		break;
    	if(!IsAdminGrade(pChar))
    		break;
    
    	MCommand* pCmd = CreateCommand(MC_KILL_THIS_PLAYER, MUID(0,0));
    	pCmd->AddParameter(new MCmdParamStr(pChar->GetName()));
    	pCmd->AddParameter(new MCmdParamStr(TargetName));
    	RouteToStage(pChar->GetStageUID(), pCmd);
    	sprintf(szMsg, "^2You have slained %s", TargetName);
    	Announce(pChar->GetUID(), szMsg);
    }
    break;
    CSCommon/MSharedCommandTable.cpp
    Code:
    C(MC_KILL_THIS_PLAYER, "Admin.KillPlayer", "", MCDT_MACHINE2MACHINE)
            P(MPT_STR, "AdminName")
    	P(MPT_STR, "TargetName")
    CSCommon/MSharedCommandTable.h
    Code:
    #define MC_KILL_THIS_PLAYER        XXXXXX // Here put a new ID (not found in the file)
    Forgive me if it could have been done shorter, but I did it real quick in my way, without looking twice on code, just for those who pm'd me, and ofc for who need this
    PEACE MATES
    Last edited by Tannous; 08-08-14 at 09:01 PM.


  2. #2
    Apprentice TheCosmos is offline
    MemberRank
    Apr 2014 Join Date
    23Posts

    Re: kill command [1.5]

    Took a quick glance through it.

    Code:
            if(ZGetMyInfo()->IsAdminGrade())
                  break;
    Within the client's OnCommand handler, what.

    Also, any peer can still send the packet directly to every peer on the stage and automatically kill everyone. Hell, the admin name parameter could be spoofed.
    Why not have the MatchServer route the packet directly to the target client, or simply keep it entirely P2P and simply validate the UGrade?
    Last edited by TheCosmos; 08-08-14 at 10:39 AM.

  3. #3
    Yaaay! Tannous is offline
    MemberRank
    Jul 2012 Join Date
    KonohaLocation
    840Posts

    Re: kill command [1.5]

    Hahaha LOL, thanks for the note didn't think of that
    Anyways they can still do what you've said, a code can be done in many ways, and i did it real quick, didn't have much time cuz of freaking HWs XD
    Thanks again for the note mate.
    Appreciated

  4. #4
    Valued Member Killer1478 is offline
    MemberRank
    Apr 2011 Join Date
    101Posts

    Re: kill command [1.5]

    You should have a request and response packet, it would make more sense that way.

    And could help you clean the code. There is no need to iterate through the whole ZCharacterManager just because someone got slapped.
    Easier yet, your response packet could have the victim's UID in it.
    Edit: If you sent back both UID's you could do something like

    ZPostDie(AdminUID);
    Even without any of that you could've done this simply:

    Code:
    case MC_KILL_THIS_PLAYER:
    {
    	char AdminName[32] = "";
    	char TargetName[32] = ""; //Make sure not to allocate more than you need 32/64  should be the maximum for a character name anyway. 
    	char szMsg[256];
    
            if(ZGetMyInfo()->IsAdminGrade()) //This could be easily spoofed by any hacker who can spoof their ugrade.
    		break;
    
            pCommand->GetParameter(AdminName, 0, MPT_STR, sizeof(AdminName));
    	pCommand->GetParameter(TargetName, 1, MPT_STR, sizeof(TargetName));
    if(strcmp(TargetName, m_pmycharacter->szName) ==0) m_pmycharacter->SetHP(0);    //Something like this im doing it off the top of my head     
    
    	sprintf(szMsg, "^2%s has killed %s", AdminName, TargetName); //Not necessary but ok
    	ZChatOutput(szMsg);
    }
    break;

  5. #5
    Yaaay! Tannous is offline
    MemberRank
    Jul 2012 Join Date
    KonohaLocation
    840Posts

    Re: kill command [1.5]

    Quote Originally Posted by Killer1478 View Post
    You should have a request and response packet, it would make more sense that way.

    And could help you clean the code. There is no need to iterate through the whole ZCharacterManager just because someone got slapped.
    Easier yet, your response packet could have the victim's UID in it.
    Edit: If you sent back both UID's you could do something like



    Even without any of that you could've done this simply:

    Code:
    case MC_KILL_THIS_PLAYER:
    {
    	char AdminName[32] = "";
    	char TargetName[32] = ""; //Make sure not to allocate more than you need 32/64  should be the maximum for a character name anyway. 
    	char szMsg[256];
    
            if(ZGetMyInfo()->IsAdminGrade()) //This could be easily spoofed by any hacker who can spoof their ugrade.
    		break;
    
            pCommand->GetParameter(AdminName, 0, MPT_STR, sizeof(AdminName));
    	pCommand->GetParameter(TargetName, 1, MPT_STR, sizeof(TargetName));
    if(strcmp(TargetName, m_pmycharacter->szName) ==0) m_pmycharacter->SetHP(0);    //Something like this im doing it off the top of my head     
    
    	sprintf(szMsg, "^2%s has killed %s", AdminName, TargetName); //Not necessary but ok
    	ZChatOutput(szMsg);
    }
    break;
    Hmm, yeah about the array size you are right, i'm blowing up the memory like this hahaha XD
    So, could u explain what did you mean by this part:
    ZPostDie(AdminUID);
    and yeah, about this:
    if(ZGetMyInfo()->IsAdminGrade())
    the player can't use the command anyways cuz of CCF_ADMIN, unless you mean bypassing this by ASM (ollydbg or so) ??!
    And thanks for the notes you guys help me alot, I am still in the learning progress I like to know what mistakes I do so I will learn and improve my self..
    Thank you guys <3

  6. #6
    Apprentice TheCosmos is offline
    MemberRank
    Apr 2014 Join Date
    23Posts

    Re: kill command [1.5]

    Quote Originally Posted by Killer1478 View Post
    You should have a request and response packet, it would make more sense that way.

    And could help you clean the code. There is no need to iterate through the whole ZCharacterManager just because someone got slapped.
    Easier yet, your response packet could have the victim's UID in it.
    Edit: If you sent back both UID's you could do something like



    Even without any of that you could've done this simply:

    Code:
    case MC_KILL_THIS_PLAYER:
    {
        char AdminName[32] = "";
        char TargetName[32] = ""; //Make sure not to allocate more than you need 32/64  should be the maximum for a character name anyway. 
        char szMsg[256];
    
            if(ZGetMyInfo()->IsAdminGrade()) //This could be easily spoofed by any hacker who can spoof their ugrade.
            break;
    
            pCommand->GetParameter(AdminName, 0, MPT_STR, sizeof(AdminName));
        pCommand->GetParameter(TargetName, 1, MPT_STR, sizeof(TargetName));
    if(strcmp(TargetName, m_pmycharacter->szName) ==0) m_pmycharacter->SetHP(0);    //Something like this im doing it off the top of my head     
    
        sprintf(szMsg, "^2%s has killed %s", AdminName, TargetName); //Not necessary but ok
        ZChatOutput(szMsg);
    }
    break;
    Code:
            if(ZGetMyInfo()->IsAdminGrade()) //This could be easily spoofed by any hacker who can spoof their ugrade.
            break;
    Your comment is right, but that chunk of code shouldn't even be there.

  7. #7
    Yaaay! Tannous is offline
    MemberRank
    Jul 2012 Join Date
    KonohaLocation
    840Posts

    Re: kill command [1.5]

    Quote Originally Posted by TheCosmos View Post
    Code:
            if(ZGetMyInfo()->IsAdminGrade()) //This could be easily spoofed by any hacker who can spoof their ugrade.
            break;
    Your comment is right, but that chunk of code shouldn't even be there.
    Yeah that's right it should be deleted.. wasn't needed xD

  8. #8
    Apprentice TheCosmos is offline
    MemberRank
    Apr 2014 Join Date
    23Posts

    Re: kill command [1.5]

    Quote Originally Posted by Tannous View Post
    Yeah that's right it should be deleted.. wasn't needed xD
    After a quick re-read, I can see why it's there. Still, the entire thing could be changed to just:
    Check current character name (although using the target's MUID would be far more optimal) against the TargetName -> If it matches, suicide.
    If not -> Simply print the message
    There's no need to iterate through every single character in the room for that.

  9. #9
    Valued Member a1tl4 is offline
    MemberRank
    Sep 2012 Join Date
    BrazilLocation
    112Posts

    Re: kill command [1.5]

    Well, correcting some useless things..

    Client
    PHP Code:
    case MC_KILL_THIS_PLAYER:
    {
        
    char AdminName[256] = "";
        
    char TargetName[256] = "";
        
    char szMsg[256];

            if(
    ZGetMyInfo()->IsAdminGrade())
            break;

            
    pCommand->GetParameter(AdminName0MPT_STRsizeof(AdminName));
            
    pCommand->GetParameter(TargetName1MPT_STRsizeof(TargetName));
            
    ZGetGame()->m_pMyCharacter->SetHP(0);
            
    sprintf(szMsg"^2%s has slained %s"AdminNameTargetName);
            
    ZChatOutput(szMsg);
    }
    break; 
    MatchServer
    PHP Code:
    case MC_KILL_THIS_PLAYER:
    {
        
    char AdminName[256] = "";
        
    char TargetName[256] = "";
        
    char szMsg[256];

        if(!
    pCommand->GetParameter(AdminName0MPT_STR))
            break;
        
    MMatchObjectpChar GetObjectA(pCommand->GetSenderUID());
        
    pCommand->GetParameter(TargetName1MPT_STRsizeof(TargetName));
        
        
        
    MMatchObjectpTarget GetPlayerByName(TargetName);
        
        if(
    pChar == NULL)
            break;
        if(!
    IsAdminGrade(pChar))
            break;

        
    MCommandpCmd CreateCommand(MC_KILL_THIS_PLAYERMUID(0,0));
        
    pCmd->AddParameter(new MCmdParamStr(pChar->GetName()));
        
    pCmd->AddParameter(new MCmdParamStr(""));
        
    RouteToListener(pTargetpCmd);
        
    sprintf(szMsg"^2You have slained %s"TargetName);
        
    Announce(pChar->GetUID(), szMsg);
    }
    break; 
    @Sended by a mobile

  10. #10
    Apprentice TheCosmos is offline
    MemberRank
    Apr 2014 Join Date
    23Posts

    Re: kill command [1.5]

    Quote Originally Posted by a1tl4 View Post
    Well, correcting some useless things..

    Client
    PHP Code:
    case MC_KILL_THIS_PLAYER:
    {
        
    char AdminName[256] = "";
        
    char TargetName[256] = "";
        
    char szMsg[256];

            if(
    ZGetMyInfo()->IsAdminGrade())
            break;

            
    pCommand->GetParameter(AdminName0MPT_STRsizeof(AdminName));
            
    pCommand->GetParameter(TargetName1MPT_STRsizeof(TargetName));
            
    ZGetGame()->m_pMyCharacter->SetHP(0);
            
    sprintf(szMsg"^2%s has slained %s"AdminNameTargetName);
            
    ZChatOutput(szMsg);
    }
    break; 
    MatchServer
    PHP Code:
    case MC_KILL_THIS_PLAYER:
    {
        
    char AdminName[256] = "";
        
    char TargetName[256] = "";
        
    char szMsg[256];

        if(!
    pCommand->GetParameter(AdminName0MPT_STR))
            break;
        
    MMatchObjectpChar GetObjectA(pCommand->GetSenderUID());
        
    pCommand->GetParameter(TargetName1MPT_STRsizeof(TargetName));
        
        
        
    MMatchObjectpTarget GetPlayerByName(TargetName);
        
        if(
    pChar == NULL)
            break;
        if(!
    IsAdminGrade(pChar))
            break;

        
    MCommandpCmd CreateCommand(MC_KILL_THIS_PLAYERMUID(0,0));
        
    pCmd->AddParameter(new MCmdParamStr(pChar->GetName()));
        
    pCmd->AddParameter(new MCmdParamStr(""));
        
    RouteToListener(pTargetpCmd);
        
    sprintf(szMsg"^2You have slained %s"TargetName);
        
    Announce(pChar->GetUID(), szMsg);
    }
    break; 
    @Sended by a mobile
    Still doesn't fix the vulnerability. You should add the packet ID to the UDP blacklist.
    Last edited by TheCosmos; 08-08-14 at 06:28 PM.

  11. #11
    Yaaay! Tannous is offline
    MemberRank
    Jul 2012 Join Date
    KonohaLocation
    840Posts

    Re: kill command [1.5]

    Quote Originally Posted by TheCosmos View Post
    After a quick re-read, I can see why it's there. Still, the entire thing could be changed to just:
    Check current character name (although using the target's MUID would be far more optimal) against the TargetName -> If it matches, suicide.
    If not -> Simply print the message
    There's no need to iterate through every single character in the room for that.
    By the way, if you mean like call the suicide function it would be much easier, but then I have to send the time to be the less to make it die fast, anyways you're right there is still vulnerability, hmm but I no longer care about gunz, i just posted this for those people who wanted it
    Thanks for the notes guys :D

  12. #12
    Apprentice TheCosmos is offline
    MemberRank
    Apr 2014 Join Date
    23Posts

    Re: kill command [1.5]

    Quote Originally Posted by Tannous View Post
    By the way, if you mean like call the suicide function it would be much easier, but then I have to send the time to be the less to make it die fast, anyways you're right there is still vulnerability, hmm but I no longer care about gunz, i just posted this for those people who wanted it
    Thanks for the notes guys :D
    Just set m_pMyCharacter's HP to 0 on the targetted client.

  13. #13
    Valued Member a1tl4 is offline
    MemberRank
    Sep 2012 Join Date
    BrazilLocation
    112Posts

    Re: kill command [1.5]

    Quote Originally Posted by TheCosmos View Post
    Still doesn't fix the vulnerability. You should add the packet ID to the UDP blacklist.
    I mean useless things

  14. #14
    Valued Member Killer1478 is offline
    MemberRank
    Apr 2011 Join Date
    101Posts

    Re: kill command [1.5]

    Quote Originally Posted by TheCosmos View Post
    Code:
            if(ZGetMyInfo()->IsAdminGrade()) //This could be easily spoofed by any hacker who can spoof their ugrade.
            break;
    Your comment is right, but that chunk of code shouldn't even be there.
    That chunk of code is there so if an "admin" is slapped it won't kill them.
    But its a client level check.

  15. #15
    Apprentice TheCosmos is offline
    MemberRank
    Apr 2014 Join Date
    23Posts

    Re: kill command [1.5]

    Quote Originally Posted by Killer1478 View Post
    That chunk of code is there so if an "admin" is slapped it won't kill them.
    But its a client level check.
    Yep, didn't read it carefully enough the first time around.



Page 1 of 2 12 LastLast

Advertisement