Last active
December 15, 2015 09:18
-
-
Save Pipeliner/5236873 to your computer and use it in GitHub Desktop.
This file contains 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
linux-0.2.img | |
x86-linux.log |
This file contains 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
wget http://wiki.qemu.org/download/linux-0.2.img.bz2 | |
bunzip2 linux-0.2.img.bz2 |
This file contains 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
#!/usr/bin/env ruby | |
require 'awesome_print' | |
lens = [] | |
curlen = 0 | |
prev_line = "" | |
opcodes = Hash.new(0) | |
open("x86-linux.log").read.lines do |line| | |
line.chomp! | |
if line =~ /^0x/ | |
curlen += 1 | |
elsif line == "IN: " | |
curlen = 0 | |
elsif curlen != 0 | |
lens << curlen | |
end | |
if line == "" | |
# last instruction of block | |
# alike "0xfffffff0: ljmp $0xf000,$0xe05b" | |
last_opcode = prev_line[13,7] | |
opcodes[last_opcode] += 1 | |
#p prev_line if prev_line[13,7] == "mov " | |
end | |
prev_line = line | |
end | |
#p lens.length | |
#p lens.inject(:+) | |
#p lens.inject(:+) / (lens.length + 0.0) | |
opcodes_r = Hash[opcodes.map{|k, v| [v,k]}] | |
ap opcodes_r, :sort_keys => true |
This file contains 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
[ -r x86-linux.log ] || qemu -d in_asm -D x86-linux.log linux-0.2.img | |
./qemu_in_asm_parser.rb | sort -k1 -rn |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment