File: dbg

package info (click to toggle)
radare2 0.9.6-3.1%2Bdeb8u1
  • links: PTS, VCS
  • area: main
  • in suites: jessie
  • size: 17,496 kB
  • ctags: 45,959
  • sloc: ansic: 240,999; sh: 3,645; makefile: 2,520; python: 1,212; asm: 312; ruby: 214; awk: 209; perl: 188; lisp: 169; java: 23; xml: 17; php: 6
file content (40 lines) | stat: -rwxr-xr-x 588 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
#!/usr/bin/awk -f r2.awk -f

function getreg(x) {
	ret=r2cmd(o,"?v $"x);
	if(ret==0) {
		print("Cannot debug program")
		exit(1)
	}
	return num(ret)
}
function step(count) {
	r2cmd(o,"ds "count)
	r2cmd(o,".dr*")
}

BEGIN {
	target="/bin/ls"
	file="dbg://"target
	if ((o=r2open())==0) {
		print("Cannot open program for debugging")
		exit(1)
	}

	pc=getreg("pc")
	sp=getreg("sp")
	bp=getreg("bp")

	print("PC="pc)
	print("SP="sp)
	print("BP="bp)
	print(r2cmd(o,"dr="))
	print(r2cmd(o,"pdi 5@$pc"))

	step(4)

	print("Analyzing code...")
	r2cmd(o,"af")
	print(r2cmd(o,"pdf"))
	r2close(o)
}