Last active
February 25, 2025 08:32
-
-
Save chiro-hiro/ee143872e0ca02920d7c7f3791d4fced to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <stdlib.h> | |
#include <stdio.h> | |
#define DATA_TYPE_ADDRESS 1 | |
#define DATA_TYPE_UINT256 2 | |
int is_match(char *a, char *b) | |
{ | |
return !(a[0] ^ b[0] | a[1] ^ b[1] | a[2] ^ b[2] | a[3] ^ b[3]); | |
} | |
/* | |
Result: | |
Method name: Transfer | |
Number of parameters: 2 | |
To address: 0x97fb750807bf06a1553b6436763d29767a1f73d9 | |
Value: 0x1f0dd440 | |
*/ | |
int main() | |
{ | |
char sig[] = {0xa9, 0x05, 0x9c, 0xbb, 0x8, 'T', 'r', 'a', 'n', 's', 'f', 'e', 'r', 0x2, DATA_TYPE_ADDRESS, DATA_TYPE_UINT256}; | |
char tx[] = {0xa9, 0x05, 0x9c, 0xbb, | |
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x97, 0xfb, 0x75, 0x08, 0x07, 0xbf, 0x06, 0xa1, 0x55, 0x3b, 0x64, 0x36, 0x76, 0x3d, 0x29, 0x76, 0x7a, 0x1f, 0x73, 0xd9, | |
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x1f, 0x0d, 0xd4, 0x40}; | |
int tx_seek = 4; | |
int sig_seek = 4; | |
if (is_match(sig, tx)) | |
{ | |
int sig_seek_end = sig_seek + sig[sig_seek]; | |
int tx_seek_end = tx_seek; | |
sig_seek += 1; | |
sig_seek_end += 1; | |
printf("Method name: "); | |
for (; sig_seek < sig_seek_end; sig_seek++) | |
{ | |
printf("%c", sig[sig_seek]); | |
} | |
printf("\nNumber of parameters: %d\n", sig[sig_seek]); | |
sig_seek_end = sig_seek + sig[sig_seek]; | |
sig_seek += 1; | |
for (; sig_seek <= sig_seek_end; sig_seek++) | |
{ | |
if (sig[sig_seek] == DATA_TYPE_ADDRESS) | |
{ | |
tx_seek += 12; | |
tx_seek_end = tx_seek + 20; | |
printf("To address: 0x"); | |
for (; tx_seek < tx_seek_end; tx_seek++) | |
{ | |
printf("%.2x", tx[tx_seek]); | |
} | |
printf("\n"); | |
} | |
if (sig[sig_seek] == DATA_TYPE_UINT256) | |
{ | |
tx_seek_end += 32; | |
printf("Value: 0x"); | |
for (; tx_seek < tx_seek_end; tx_seek++) | |
{ | |
if (tx[tx_seek] > 0) | |
{ | |
printf("%.2x", tx[tx_seek]); | |
} | |
} | |
printf("\n"); | |
} | |
} | |
} | |
return EXIT_SUCCESS; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment