File: setkey2esp-secrets.pl

package info (click to toggle)
tcpdump 4.99.5-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 19,420 kB
  • sloc: ansic: 84,547; sh: 3,793; makefile: 489; perl: 319; awk: 123
file content (24 lines) | stat: -rwxr-xr-x 399 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
#!/usr/local/bin/perl
#
# usage:
#	setkey -D | perl thisfile > secrets.txt
#	tcpdump -n -E "file secrets.txt"
#
while (<>) {
	if (/^(\S+)\s+(\S+)/) {
		$src = $1;
		$dst = $2;
		next;
	}
	if (/^\s+esp.*spi=(\d+)/) {
		$spi = $1;
		next;
	}
	if (/^\s+E:\s+(\S+)\s+(.*)$/) {
		$algo = $1. "-hmac96";
		($secret = $2) =~ s/\s+//g;

		printf"0x%x@%s %s:0x%s\n", $spi, $dst, $algo, $secret;
		next;
	}
}