rev-symbol - Symbol Recovery
Analyze function code characteristics to recover/identify function symbols and names.
Pre-check
Determine which IDA access method is available:
Option A — IDA Pro MCP (preferred if connected):
Check if the IDA Pro MCP server is connected (look for an active ida-pro or equivalent MCP connection). If connected, you can query IDA directly via MCP tools — no exported files needed. Proceed with the analysis using MCP.
Option B — IDA-NO-MCP exported data:
If MCP is not connected, check if IDA-NO-MCP exported data exists in the current directory:
- Check if
decompile/ directory exists
- Check if there are
.c files inside
If neither MCP nor exported data is available, prompt the user:
No IDA access method detected. Choose one of the following:
Option A — IDA Pro MCP (recommended):
Connect the IDA Pro MCP server so Claude can query IDA directly.
Option B — IDA-NO-MCP export:
1. Download plugin: https://github.com/P4nda0s/IDA-NO-MCP
2. Copy INP.py to IDA plugins directory
3. Press Ctrl-Shift-E in IDA to export
4. Open the exported directory with Claude Code
Export Directory Structure
./
├── decompile/ # Decompiled C code directory
│ ├── 0x401000.c # One file per function, named by hex address
│ ├── 0x401234.c
│ └── ...
├── decompile_failed.txt # Failed decompilation list
├── decompile_skipped.txt # Skipped functions list
├── strings.txt # String table (address, length, type, content)
├── imports.txt # Import table (address:function_name)
├── exports.txt # Export table (address:function_name)
└── memory/ # Memory hexdump (1MB chunks)
Function File Format (decompile/*.c)
Each .c file contains function metadata comments and decompiled code:
/*
* func-name: sub_401000
* func-address: 0x401000
* callers: 0x402000, 0x403000 // List of functions that call this function
* callees: 0x404000, 0x405000 // List of functions called by this function
*/
int __fastcall sub_401000(int a1, int a2)
{
// Decompiled code...
}
Symbol Recovery Steps
Step 1: Analyze Internal Characteristics
Carefully examine the target function for:
- String constants: Strings used in the function may reveal its purpose
- Numeric constants / Magic Numbers:
- MD5:
0x67452301, 0xEFCDAB89, 0x98BADCFE, 0x10325476
- CRC32:
0xEDB88320
- Base64 charset:
ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/
- AES S-Box:
0x63, 0x7C, 0x77, 0x7B...
- Zlib:
0x78, 0x9C (compression header)
- other constants/magic numbers...
- Code structure: Loop patterns, bitwise operations, specific algorithm flows
If you can identify a known algorithm through constants/structure, tell the user directly.
Step 2: Analyze Cross-References
Analyze Callees (called functions):
Read functions in the callees list
For each callee, check if its address exists in imports.txt
Recognize call patterns even when symbols are missing:
Paired function patterns (identify by matching call pairs):
// malloc/free, new/delete, alloc/dealloc
xx = sub_A(0x100); // alloc: takes size, returns pointer
...
sub_B(xx); // free: takes the same pointer
// mutex_lock/mutex_unlock, pthread_mutex_lock/unlock
sub_A(lock_ptr); // lock
... // critical section
sub_B(lock_ptr); // unlock (same lock object)
// open/close, fopen/fclose, CreateFile/CloseHandle
fd = sub_A("/path", 0); // open: path + flags, returns handle
...
sub_B(fd); // close: takes the handle
// pthread_create/pthread_join
sub_A(&tid, 0, func, arg); // create: out param, attr, func, arg
...
sub_B(tid, &ret); // join: tid, out param
**Argument pattern recognition:**
```c
// socket(AF_INET, SOCK_STREAM, 0) - fixed constants
sub_XXX(2, 1, 0); // socket: domain=2, type=1, protocol=0
// connect/bind(sockfd, addr, addrlen)
sub_XXX(fd, &var, 16); // addr struct, len=16 for IPv4
// memcpy/memmove(dst, src, size)
sub_XXX(dst, src, n); // 3 params: dst, src, count
// memset(ptr, value, size)
sub_XXX(ptr, 0, 0x100); // 3 params: ptr, byte value, count
// read/write(fd, buf, count)
ret = sub_XXX(fd, buf, n); // returns bytes read/written
// strcmp/strncmp(s1, s2) or (s1, s2, n)
if (sub_XXX(s1, s2) == 0) // returns 0 on equal
Return value patterns:
// file/socket operations: -1 on error
if ((fd = sub_XXX(...)) == -1) goto error;
// allocation: NULL on failure
if (!(ptr = sub_XXX(size))) goto error;
// success/error: 0 = success
if (sub_XXX(...) != 0) goto error;
// strlen: returns size_t
len = sub_XXX(str);
sub_YYY(dst, src, len); // len used in memcpy
Analyze Callers (calling functions):
- Read functions in the callers list
- If a caller has a symbol (check exports.txt), infer the callee's purpose from context
- Recursive check: trace up the call chain until you find a function with a symbol
- Analyze how the return value is used by callers
Step 3: Information Gathering and Search
Collect the following information:
- Strings in the function (check
strings.txt for addresses used in the function)
- Magic Numbers / constants
- Known imports called (cross-reference callees with
imports.txt)
- Caller/callee symbols from
exports.txt
- Paired function patterns identified
Based on collected information:
First attempt local reasoning based on:
- Function signature (number and types of parameters)
- Paired call patterns (alloc/free, lock/unlock)
- Known imports in the call chain
- Code structure similarity to known algorithms
If uncertain, use Web Search to search:
- Search Magic Numbers:
0x67452301 0xEFCDAB89 algorithm
- Search code patterns:
rotate left xor constant algorithm
- Search unique strings found in the function
- Search parameter patterns:
function(int, int, 0) socket
Output Format
## Symbol Recovery Analysis: <function_address>
### Function Characteristics
- Strings: <list discovered strings>
- Constants: <list key constants>
- Called imports: <list>
### Cross-Reference Analysis
- Callers: <callers and their symbols>
- Callees: <callees and their symbols>
### Inference Result
- **Suggested symbol name**: <suggested_name>
- **Confidence**: High / Medium / Low
- **Reasoning**: <explain why this name is suggested>
### Similar Open Source Implementation
- <if similar open source code is found, provide link>
1---
2name: rev-symbol
3description: Restore function symbols by analyzing code patterns, strings, constants, and cross-references
4metadata:
5 source: https://skillmd.com/skills/om-scogo/rev-symbol
6---
7
8# rev-symbol - Symbol Recovery
9
10Analyze function code characteristics to recover/identify function symbols and names.
11
12## Pre-check
13
14**Determine which IDA access method is available:**
15
16**Option A — IDA Pro MCP (preferred if connected):**
17Check if the IDA Pro MCP server is connected (look for an active `ida-pro` or equivalent MCP connection). If connected, you can query IDA directly via MCP tools — no exported files needed. Proceed with the analysis using MCP.
18
19**Option B — IDA-NO-MCP exported data:**
20If MCP is not connected, check if IDA-NO-MCP exported data exists in the current directory:
21
221. Check if `decompile/` directory exists
232. Check if there are `.c` files inside
24
25If neither MCP nor exported data is available, prompt the user:
26```
27No IDA access method detected. Choose one of the following:
28
29Option A — IDA Pro MCP (recommended):
30 Connect the IDA Pro MCP server so Claude can query IDA directly.
31
32Option B — IDA-NO-MCP export:
33 1. Download plugin: https://github.com/P4nda0s/IDA-NO-MCP
34 2. Copy INP.py to IDA plugins directory
35 3. Press Ctrl-Shift-E in IDA to export
36 4. Open the exported directory with Claude Code
37```
38
39---
40
41## Export Directory Structure
42
43```
44./
45├── decompile/ # Decompiled C code directory
46│ ├── 0x401000.c # One file per function, named by hex address
47│ ├── 0x401234.c
48│ └── ...
49├── decompile_failed.txt # Failed decompilation list
50├── decompile_skipped.txt # Skipped functions list
51├── strings.txt # String table (address, length, type, content)
52├── imports.txt # Import table (address:function_name)
53├── exports.txt # Export table (address:function_name)
54└── memory/ # Memory hexdump (1MB chunks)
55```
56
57## Function File Format (decompile/*.c)
58
59Each `.c` file contains function metadata comments and decompiled code:
60
61```c
62/*
63 * func-name: sub_401000
64 * func-address: 0x401000
65 * callers: 0x402000, 0x403000 // List of functions that call this function
66 * callees: 0x404000, 0x405000 // List of functions called by this function
67 */
68
69int __fastcall sub_401000(int a1, int a2)
70{
71 // Decompiled code...
72}
73```
74
75---
76
77## Symbol Recovery Steps
78
79### Step 1: Analyze Internal Characteristics
80
81Carefully examine the target function for:
82
83- **String constants**: Strings used in the function may reveal its purpose
84- **Numeric constants / Magic Numbers**:
85 - MD5: `0x67452301`, `0xEFCDAB89`, `0x98BADCFE`, `0x10325476`
86 - CRC32: `0xEDB88320`
87 - Base64 charset: `ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/`
88 - AES S-Box: `0x63, 0x7C, 0x77, 0x7B...`
89 - Zlib: `0x78`, `0x9C` (compression header)
90 - other constants/magic numbers...
91- **Code structure**: Loop patterns, bitwise operations, specific algorithm flows
92
93If you can identify a known algorithm through constants/structure, tell the user directly.
94
95### Step 2: Analyze Cross-References
96
97**Analyze Callees (called functions):**
98- Read functions in the callees list
99- For each callee, check if its address exists in `imports.txt`
100- Recognize call patterns even when symbols are missing:
101
102 **Paired function patterns (identify by matching call pairs):**
103 ```c
104 // malloc/free, new/delete, alloc/dealloc
105 xx = sub_A(0x100); // alloc: takes size, returns pointer
106 ...
107 sub_B(xx); // free: takes the same pointer
108
109 // mutex_lock/mutex_unlock, pthread_mutex_lock/unlock
110 sub_A(lock_ptr); // lock
111 ... // critical section
112 sub_B(lock_ptr); // unlock (same lock object)
113
114 // open/close, fopen/fclose, CreateFile/CloseHandle
115 fd = sub_A("/path", 0); // open: path + flags, returns handle
116 ...
117 sub_B(fd); // close: takes the handle
118
119 // pthread_create/pthread_join
120 sub_A(&tid, 0, func, arg); // create: out param, attr, func, arg
121 ...
122 sub_B(tid, &ret); // join: tid, out param
123
124
125 **Argument pattern recognition:**
126 ```c
127 // socket(AF_INET, SOCK_STREAM, 0) - fixed constants
128 sub_XXX(2, 1, 0); // socket: domain=2, type=1, protocol=0
129
130 // connect/bind(sockfd, addr, addrlen)
131 sub_XXX(fd, &var, 16); // addr struct, len=16 for IPv4
132
133 // memcpy/memmove(dst, src, size)
134 sub_XXX(dst, src, n); // 3 params: dst, src, count
135
136 // memset(ptr, value, size)
137 sub_XXX(ptr, 0, 0x100); // 3 params: ptr, byte value, count
138
139 // read/write(fd, buf, count)
140 ret = sub_XXX(fd, buf, n); // returns bytes read/written
141
142 // strcmp/strncmp(s1, s2) or (s1, s2, n)
143 if (sub_XXX(s1, s2) == 0) // returns 0 on equal
144 ```
145
146 **Return value patterns:**
147 ```c
148 // file/socket operations: -1 on error
149 if ((fd = sub_XXX(...)) == -1) goto error;
150
151 // allocation: NULL on failure
152 if (!(ptr = sub_XXX(size))) goto error;
153
154 // success/error: 0 = success
155 if (sub_XXX(...) != 0) goto error;
156
157 // strlen: returns size_t
158 len = sub_XXX(str);
159 sub_YYY(dst, src, len); // len used in memcpy
160 ```
161
162**Analyze Callers (calling functions):**
163- Read functions in the callers list
164- If a caller has a symbol (check exports.txt), infer the callee's purpose from context
165- Recursive check: trace up the call chain until you find a function with a symbol
166- Analyze how the return value is used by callers
167
168### Step 3: Information Gathering and Search
169
170Collect the following information:
171- Strings in the function (check `strings.txt` for addresses used in the function)
172- Magic Numbers / constants
173- Known imports called (cross-reference callees with `imports.txt`)
174- Caller/callee symbols from `exports.txt`
175- Paired function patterns identified
176
177Based on collected information:
1781. First attempt local reasoning based on:
179 - Function signature (number and types of parameters)
180 - Paired call patterns (alloc/free, lock/unlock)
181 - Known imports in the call chain
182 - Code structure similarity to known algorithms
183
1842. If uncertain, use **Web Search** to search:
185 - Search Magic Numbers: `0x67452301 0xEFCDAB89 algorithm`
186 - Search code patterns: `rotate left xor constant algorithm`
187 - Search unique strings found in the function
188 - Search parameter patterns: `function(int, int, 0) socket`
189
190---
191
192## Output Format
193
194```
195## Symbol Recovery Analysis: <function_address>
196
197### Function Characteristics
198- Strings: <list discovered strings>
199- Constants: <list key constants>
200- Called imports: <list>
201
202### Cross-Reference Analysis
203- Callers: <callers and their symbols>
204- Callees: <callees and their symbols>
205
206### Inference Result
207- **Suggested symbol name**: <suggested_name>
208- **Confidence**: High / Medium / Low
209- **Reasoning**: <explain why this name is suggested>
210
211### Similar Open Source Implementation
212- <if similar open source code is found, provide link>
213```