逆向-还原代码之url_encode (Interl 32)
#include <stdio.h>
void url_encode_char(char *va, char vb) { /*80484d0: 55 push %ebp 80484d1: 89 e5 mov %esp,%ebp 80484d3: 83 ec 28 sub $0x28,%esp 80484d6: 8b 45 0c mov 0xc(%ebp),%eax // parameter1, 8,9,a,b,c 80484d9: 88 45 e4 mov %al,-0x1c(%ebp) // parameter2 80484dc: c7 45 e8 30 31 32 33 movl $0x33323130,-0x18(%ebp) 80484e3: c7 45 ec 34 35 36 37 movl $0x37363534,-0x14(%ebp) 80484ea: c7 45 f0 38 39 41 42 movl $0x42413938,-0x10(%ebp) 80484f1: c7 45 f4 43 44 46 00 movl $0x464443,-0xc(%ebp)*/ char str[]="0123456789ABCDF";
/*80484f8: 8b 45 08 mov 0x8(%ebp),%eax 80484fb: c6 00 25 movb $0x25,(%eax)*/ va[0] = %;
/*80484fe: 8b 45 08 mov 0x8(%ebp),%eax 8048501: 8d 50 01 lea 0x1(%eax),%edx 8048504: 0f b6 45 e4 movzbl -0x1c(%ebp),%eax 8048508: c0 f8 04 sar $0x4,%al 804850b: 0f be c0 movsbl %al,%eax 804850e: 83 e0 0f and $0xf,%eax 8048511: 0f b6 44 05 e8 movzbl -0x18(%ebp,%eax,1),%eax 8048516: 88 02 mov %al,(%edx)*/ va[1] = str[(vb>>4)&0x0f];
/*8048518: 8b 45 08 mov 0x8(%ebp),%eax 804851b: 83 c0 01 add $0x1,%eax 804851e: 0f b6 00 movzbl (%eax),%eax 8048521: 0f be c0 movsbl %al,%eax 8048524: 89 44 24 04 mov %eax,0x4(%esp) 8048528: c7 04 24 24 86 04 08 movl $0x8048624,(%esp) 804852f: e8 5c fe ff ff call 8048390 <printf@plt>*/ printf("%c ", va[1]);
/*8048534: 8b 45 08 mov 0x8(%ebp),%eax 8048537: 8d 50 02 lea 0x2(%eax),%edx 804853a: 0f be 45 e4 movsbl -0x1c(%ebp),%eax 804853e: 83 e0 0f and $0xf,%eax 8048541: 0f b6 44 05 e8 movzbl -0x18(%ebp,%eax,1),%eax 8048546: 88 02 mov %al,(%edx)*/ va[2] = str[(vb&0xf)];
//8048548: c9 leave //8048549: c3 ret }
int main() { /*804854a: 55 push %ebp 804854b: 89 e5 mov %esp,%ebp 804854d: 83 e4 f0 and $0xfffffff0,%esp 8048550: 83 ec 20 sub $0x20,%esp 8048553: c7 44 24 1b 00 00 00 movl $0x0,0x1b(%esp) 804855a: 00 804855b: c6 44 24 1f 00 movb $0x0,0x1f(%esp)*/ char str[5] = {0};
/*8048560: c7 44 24 04 61 00 00 movl $0x61,0x4(%esp) 8048567: 00 8048568: 8d 44 24 1b lea 0x1b(%esp),%eax 804856c: 89 04 24 mov %eax,(%esp) 804856f: e8 5c ff ff ff call 80484d0 <url_encode_char>*/ url_encode_char(str, a);
/*8048574: 8d 44 24 1b lea 0x1b(%esp),%eax 8048578: 89 44 24 04 mov %eax,0x4(%esp) 804857c: c7 04 24 28 86 04 08 movl $0x8048628,(%esp) 8048583: e8 08 fe ff ff call 8048390 <printf@plt>*/ printf("%s ", str);
/*8048588: b8 00 00 00 00 mov $0x0,%eax 804858d: c9 leave 804858e: c3 ret 804858f: 90 nop*/ }
// code static void url_encode_char(char *b, char c) { char hex_table[] = "0123456789ABCDF"; b[0] = %; b[1] = hex_table[(c >> 4) & 0x0F]; printf("%c ", b[1]); // 6 b[2] = hex_table[c & 0x0F]; } int main() { char b[5] = {0}; url_encode_char(b, a); printf("main = %s ", b); // %61 return 0; }
