AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   [Orpheu] Retrieving player's IP address (https://forums.alliedmods.net/showthread.php?t=336288)

Shadows Adi 02-09-2022 13:30

[Orpheu] Retrieving player's IP address
 
Hello,
I am trying to get connecting player's IP address while in SV_ConnectClient state in HLDS ( build 8684 ).
Hook SV_ConnectClient ( signature works ) :
PHP Code:

OrpheuRegisterHook(OrpheuGetFunction("SV_ConnectClient"), "SV_ConnectClient_Pre"OrpheuHookPre)
    
OrpheuRegisterHook(OrpheuGetFunction("SV_ConnectClient"), "SV_ConnectClient_Post"OrpheuHookPost

Signature:
PHP Code:

{
    
"name" "SV_ConnectClient",
    
"library" "engine",
    
"identifiers" :
    [
        {
            
"os" "windows",
            
"value" : [0x55,0x8B,0xEC,0x81,"*","*","*","*","*",0x53,0x56,0x57,0xB9,0x05,0x00,0x00,0x00,0xBE,"*","*","*","*",0x8D,"*","*",0x33,0xDB,0x68,"*","*","*","*"]
        },
        {
            
"os" "linux",
            
"value" "SV_ConnectClient"
        
}
    ]


Thinked about hooking the Net_AdrToString, but it don't works as intended:

Code:
Code:
// This hook is registered inside the SV_ConnectClient_Pre and unhooked in SV_ConnectClient_Post OrpheuRegisterHook(OrpheuGetFunction("NET_AdrToString"), "NET_AdrToString_Post", OrpheuHookPost) public NET_AdrToString_Post() {     new szTemp[19]     OrpheuGetReturn(szTemp, charsmax(szTemp))     server_print("temp: %s", szTemp) }

Using this code I get the following result:
PHP Code:

temp84d4c505:008b8c020 

Signature ( working ):
PHP Code:

{
    
"name" "NET_AdrToString",
    
"library" "engine",
    
"return" 
    {
        
"type" "char *"
    
},
    
"identifiers" :
    [
        {
            
"os" "windows",
            
"value" 0x58B00
        
},
        {
            
"os" "linux",
            
"value" "NET_AdrToString"
        
}
    ]


Next, I thinked about pfnConnectionlessPacket:

Signature:
PHP Code:

{
    
"name" "pfnConnectionlessPacket",
    
"library" "engine",
    
"arguments" :
    [
        {
            
"type" "netadr_s *"
        
},
        {
            
"type" "char *"
        
},
        {
            
"type" "char *"
        
},
        {
            
"type" "int"
        
},
    ]


Code:
PHP Code:

g_hConnectionlessPacket OrpheuGetDLLFunction("pfnConnectionlessPacket""pfnConnectionlessPacket"

But I get this error:
PHP Code:

[ORPHEUStructure "DLL_FUNCTIONS *" doesn't have a member named "pfnConnectionlessPacket" 

Any suggestions, what function should I hook?

HamletEagle 02-11-2022 11:40

Re: [Orpheu] Retrieving player's IP address
 
Try this signature for NET_AdrToString:

Code:

{
    "name" : "NET_AdrToString",
    "library" : "engine",
    "arguments" :
    [
        {
            "type" : "pointer"
        }
    ],
    "return" :
    {
        "type" : "char *"
    },
    "identifiers" :
    [
        {
            "os" : "windows",
            "value" :[0x55,0x8B,"*",0x6A,"*",0x6A,"*",0x68,"*","*","*","*",0xE8,"*","*","*","*",0x8B,"*","*",0x83,"*","*",0x83,"*","*",0x75,"*",0x68,"*","*","*","*",0x6A,"*",0x68,"*","*","*","*",0xE8,"*","*","*","*",0x83,"*","*",0xB8,"*","*","*","*",0x5D,0xC3,0x83,"*","*",0x75,"*",0x8B,"*","*",0x50,0xE8,"*","*","*","*",0x8B,"*","*",0x8B,"*","*",0x25]
        },
        {
            "os" : "linux",
            "value" : "NET_AdrToString"
        }
    ]
}

Note that the signature file is not entirely correct, but it appears to be working. The issue is with the first argument: const netadr_t& a. Orpheu doesn't have support for netadr_t structure as far as I know, so you don't have a corresponding type. I declared it as pointer and it appears to be fine, but please know this isn't a pointer(if it was, things would be so much easier) so do not try to read data from it.

Shadows Adi 02-11-2022 13:43

Re: [Orpheu] Retrieving player's IP address
 
It doesn't return the correct string and it seems that it modify the net_from var after hooking it:
Code:

temp: 224.235.24.0:35842
temp: 224.235.24.0:35842
224.235.24.0:35842:reconne
temp: 224.235.24.0:35842
temp: 224.235.24.0:35842
temp: 216.235.24.0:35842
temp: 216.235.24.0:35842
temp: 224.235.24.0:35842
temp: 224.235.24.0:35842

Real Address: 127.0.0.1:27005


All times are GMT -4. The time now is 11:38.

Powered by vBulletin®
Copyright ©2000 - 2024, vBulletin Solutions, Inc.