[Ajuda] obter .AMX em hexadecimal
#1

@RESOLVIDO

Quote:

para fazer isto o binario tem de ser divisivel por 4!



estou seguindo um exemplo do ******, que possibilita que um script "injete" um FS, e carrege pelo prуprio GM, mas para sua escrita nгo pode ser em string porque o encode pode denegrir o caracteres de algumas celulas.

este й um exemplo que ****** fez e ficou correto
https://github.com/Open-GTO/sa-mp-fixes/issues/80
PHP код:
//codigo source:
forward OnRconCommand(const cmd[]);
public 
OnRconCommand(const cmd[]) return 0;
//hexadecimal:
static BIN[] = {0x000000570x0808F1E00x000800140x000000500x000000640x000000640x000040640xFFFFFFFF0x000000380x000000400x000000400x000000400x000000400x000000400x000000080x000000420x6E4F001F0x6E6F63520x6D6D6F430x00646E610x2E0078800x00305980};
//string resultado do hexadecimal:
[   ас  P   l   l   l@  яяяя8   @   @   @   @   @      B    OnRconCommand Ђx .Ѓ    Ѓ    ЂY0Ѓ   пс                    RCMD.pwn                         cmd                         OnRconCommand   _  bool        
//string esperado:
[   ас  P   l   l   l@  яяяя8   @   @   @   @   @      B    OnRconCommand Ђx .Ѓ    Ѓ    ЂY0Ѓ   пс                    RCMD.pwn                         cmd                         OnRconCommand   _  bool 
como podem ver, o resultado ficou exatamente igual e sem falhas.

mas pela todas as formas que tentei a string gerada pelo codigo hexadecimal fica diferente, do compilador:
Код:
//codigo fonte:
native CallRemoteFunction(const function[], const format[], {Float,_}:...);
forward OnRconCommand(const cmd[]);

public OnRconCommand(const cmd[])
	return CallRemoteFunction("I_RCMD", "s", cmd);

//resultado esperado:
’   ас  l   ґ   Ш   Ш@  яяяя8   @   H   H   H   H      J       X    OnRconCommand CallRemoteFunction  Ђx .Ѓ	Ѓ	)'' 'Ђ{ ,0ЂIЂ_ЂRЂCЂMЂD Ђs ‰   пс		            RCMD.pwn                     H    cmd               H   	   OnRconCommand   _  bool  Float    
//tentativa 1: sublime hexadecimal encode:
 ’      са           l       ґ       Ш      @Ш      яя  яя   8       @       H       H       H       H              J               X         nO  cR  no  oC  mm  na   d  aC  ll  eR  om  et  uF  cn  it  no      xЂ  .   	Ѓ  	Ѓ  )  '   '  '  {Ђ  ,   0  IЂ  _Ђ  RЂ  CЂ  MЂ  DЂ  Ђ    s   ‰      сп  		                                CR  DM  p.  nw                                                H            c   dm                                H       	       O   Rn  oc  Cn  mo  am  dn      _      b   oo   l     lF  ao   t      
//tentativa 2: https://pastebin.com/vNmTh8va 
’   а   с               l   ґ   Ш   Ш   @   я   я   я   я   8   @   H   H   H   H      J   X      O   n   R   c   o   n   C   o   m   m   a   n   d   C   a   l   l   R   e   m   o   t   e   F   u   n   c   t   i   o   n   Ђ   x   .   Ѓ   	   Ѓ   	   )      '      '   '      Ђ   {   ,      0   Ђ   I   Ђ   _   Ђ   R   Ђ   C   Ђ   M   Ђ   D   Ђ   s   ‰   п   с   	   	                     R   C   M   D   .   p   w   n                     H            c   m   d         H   	   O   n   R   c   o   n   C   o   m   m   a   n   d   _      b   o   o   l      F   l   o   a   t   я   я   я   8   @   H   H   H   H      J   X      O   n   R   c   o   n   C   o   m   m   a   n   d   C   a   l   l   R   e   m   o   t   e   F   u   n   c   t   i   o   n   Ђ   x   .   Ѓ   	   Ѓ   	   )      '      '   '      Ђ   {   ,      0   Ђ   I   Ђ   _   Ђ   R   Ђ   C   Ђ   M   Ђ   D   Ђ   s   ‰   п   с   	   	                     R   C   M   D   .   p   w   n                     H            c   m   d         H   	   O   n   R   c   o   n   C   o   m   m   a   n                   
//tenho outras 3 tentativas diferentes, mas todas dгo resultado diferente do esperado!
se alguem descobrir como ****** chegou naquele resultado, ajude, que estou tentando melhorar um dos meus realeses para a board!
Reply
#2

[19:13] ThreeKingz: I think this is what you might be looking for:
[19:14] ThreeKingz:
PHP код:
    new buf[1024], source[128];
    new 
BRW:handle BRW::Open("Binary/foo.amx"bin_read);
    new 
len BRW::GetTotalBytes(handle);
    while(
BRW::GetCurrentBytes(handle) != len)
    {
        
format(source128"0x%08x, "BRW::ReadInt32(handle));
        
strcat(bufsource);
    }
    
BRW::Close(handle);
    print(
buf);
    new 
data[] = {0x000000900x0808F1E00x000800040x0000006C0x000000B00x000000D40x000040D40xFFFFFFFF0x000000380x000000400x000000480x000000480x000000480x000000480x000000080x0000004A0x000000000x000000580x6E4F001F0x6E6F63520x6D6D6F430x00646E610x6C6C61430x6F6D65520x754665740x6974636E0x00006E6F0x2E0078800x0C2909810x00271C270x7B800C270x30102C000x5F8049800x438052800x44804D800x00738000};
    
handle BRW::Open("Binary/testfoo.amx"bin_write);
    for(new 
0sizeof(data); i++)
    {
        
BRW::WriteInt32(handledata[i]);
    }
    
BRW::Close(handle); 
https://github.com/ThreeKingz/BRW
Credits to ThePhenix
Reply
#3

Quote:
Originally Posted by Dayvison_
Посмотреть сообщение
...
Код:
//esperado:
’   ас  l   ґ   Ш   Ш@  яяяя8   @   H   H   H   H      J       X    OnRconCommand CallRemoteFunction  Ђx .Ѓ	Ѓ	)'' 'Ђ{ ,0ЂIЂ_ЂRЂCЂMЂD Ђs ‰   пс		            RCMD.pwn                     H    cmd               H   	   OnRconCommand   _  bool  Float    
//resultado:
’   а   с               l   ґ   Ш   Ш   @   я   я   я   я   8   @   H   H   H   H      J   X      O   n   R   c   o   n   C   o   m   m   a   n   d   C   a   l   l   R   e   m   o   t   e   F   u   n   c   t   i   o   n   Ђ   x   .   Ѓ   	   Ѓ   	   )      '      '   '      Ђ   {   ,      0   Ђ   I   Ђ   _   Ђ   R   Ђ   C   Ђ
ficou bem proximo do original, porem ainda tem 1 espaзo em cada celular -. e nгo achei o valor repetido muitas vezes:
PHP код:
0x000000920x000000E00x000000F10x000000080x000000080x000000060x000000080x0000006C0x000000B40x000000D80x000000D80x000000400x000000FF,
0x000000FF0x000000FF0x000000FF0x000000380x000000400x000000480x000000480x000000480x000000480x000000080x0000004A0x000000580x0000001F
0x0000004F0x0000006E0x000000520x000000630x0000006F0x0000006E0x000000430x0000006F0x0000006D0x0000006D0x000000610x0000006E0x00000064
0x000000430x000000610x0000006C0x0000006C0x000000520x000000650x0000006D0x0000006F0x000000740x000000650x000000460x000000750x0000006E,
0x000000630x000000740x000000690x0000006F0x0000006E0x000000800x000000780x0000002E0x000000810x000000090x000000810x000000090x00000029
0x0000000C0x000000270x0000001C0x000000270x000000270x0000000C0x000000800x0000007B0x0000002C0x000000100x000000300x000000800x00000049,
0x000000800x0000005F0x000000800x000000520x000000800x000000430x000000800x0 
especulo que seja um char valendo por uma letra e um espaзo 'A ', mas nгo entendo muito destas manipulaзхes
Reply
#4

Note that this won't work if the size of the .amx file is not divisible by 4. Sorry for speaking english in this section.
Reply
#5

Quote:
Originally Posted by ThePhenix
Посмотреть сообщение
Note that this won't work if the size of the .amx file is not divisible by 4.
How can I have this control?

Quote:
Originally Posted by RazorGuigo
Посмотреть сообщение
PHP код:
//source code:
native CallRemoteFunction(const function[], const format[], {Float,_}:...);
forward OnRconCommand(const cmd[]);
public 
OnRconCommand(const cmd[])
    return 
CallRemoteFunction("I_RCMD""s"cmd); 
Reply
#6

Quote:
Originally Posted by RazorGuigo
Посмотреть сообщение
How can I have this control?
If you were reading and writing to the file byte by byte then this wouldn't be a problem. However, what you can do is write the number of bytes from the .amx file that are divisible by 4 and treat the remainder bytes in a different way.

For instance, if a file has a size of 131 bytes, you could write or read the first 128 bytes (divisible by 4) and you have a remainder of 3 bytes that you can read or write separately. Note that we're using little endian order.
Reply
#7

Quote:
Originally Posted by ThePhenix
Посмотреть сообщение
If you were reading and writing to the file byte by byte then this wouldn't be a problem. However, what you can do is write the number of bytes from the .amx file that are divisible by 4 and treat the remainder bytes in a different way.

For instance, if a file has a size of 131 bytes, you could write or read the first 128 bytes (divisible by 4) and you have a remainder of 3 bytes that you can read or write separately. Note that we're using little endian order.
oks, thank you, I was able to make it work adding bits until it was divisible by 4
Reply


Forum Jump:


Users browsing this thread: 2 Guest(s)