Skip to content

Instantly share code, notes, and snippets.

#coding=utf-8
from subprocess import Popen,STDOUT,PIPE # Python 2.4以上が必要
import os
def next_line(stdout):
line = ""
while True:
r = stdout.read(1)
if r == '\n':
break
#coding=utf-8
import sys,os
import re
from collections import namedtuple
Code = namedtuple('Code',['address','binary','opecode','operand'])
def load_assembler(file_name):
part = re.compile(r"\s(?P<address>\w+):\s+(?P<binary>(\w\w\s)+)\s+((?P<opecode>\w+)(\s+(?P<operand>.*))?)?$")
data = [i.strip('\n') for i in open(file_name)]
#coding=utf-8
import sys,os
import re
from collections import namedtuple
from itertools import *
class Asm(object):
def __init__(self,address,binary,opecode,operand):
self.address = address
Disassembly of section .text:
------------------------------
------------------------------
8048850: 31 ed xor ebp,ebp;
8048852: 5e pop esi;
8048853: 89 e1 mov ecx,esp;
8048855: 83 e4 f0 and esp,0xfffffff0;
8048858: 50 push eax;
8048859: 54 push esp;
804885a: 52 push edx;
------------------------------
8048d1c: 55 push ebp;
8048d1d: 89 e5 mov ebp,esp;
8048d1f: 57 push edi;
8048d20: 53 push ebx;
8048d21: 81 ec a0 02 00 00 sub esp,0x2a0;
8048d27: 8b 45 08 mov eax,DWORD PTR [ebp+0x8];
8048d2a: 89 85 84 fd ff ff mov DWORD PTR [ebp-0x27c],eax;
8048d30: 65 a1 14 00 00 00 mov eax,gs:0x14;
8048d36: 89 45 f4 mov DWORD PTR [ebp-0xc],eax;
------------------------------
8048d1c: 55 push ebp;
8048d1d: 89 e5 mov ebp,esp;
8048d1f: 57 push edi;
8048d20: 53 push ebx;
8048d21: 81 ec a0 02 00 00 sub esp,0x2a0;
8048d27: 8b 45 08 mov eax,DWORD PTR [ebp+0x8];
8048d2a: 89 85 84 fd ff ff mov DWORD PTR [ebp-0x27c],eax;
8048d30: 65 a1 14 00 00 00 mov eax,gs:0x14;
8048d36: 89 45 f4 mov DWORD PTR [ebp-0xc],eax;
#coding=utf-8
import sys,os
import re
from collections import defaultdict
from itertools import *
def scc(edges,redges):
def dfs(v):
used.add(v)
if v in edges:
#coding=utf-8
import sys,os
import re
from collections import defaultdict,namedtuple
from itertools import *
def scc(edges,redges):
def dfs(v):
used.add(v)
if v in edges:
.......
.......
8049c21: 8d 44 24 2c lea eax,[esp+0x2c];
8049c25: 83 c0 05 add eax,0x5;
8049c28: 89 04 24 mov DWORD PTR [esp],eax;
8049c2b: e8 15 f9 ff ff call 8049545 <calloc@plt+0xd05>;
8049c30: eb 0c jmp 8049c3e <calloc@plt+0x13fe>;
8049c32: c7 04 24 c1 a0 04 08 mov DWORD PTR [esp],0x804a0c1;
#coding=utf-8
import sys,os
import re
from collections import defaultdict,namedtuple
from itertools import *
def scc(edges,redges):
def dfs(v):
used.add(v)
if v in edges: