-
-
Notifications
You must be signed in to change notification settings - Fork 24
/
bop
executable file
·44 lines (40 loc) · 1022 Bytes
/
bop
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
41
42
43
#!/usr/bin/perl
# Buffer Overflow Pattern generator v 1.0
# Written by Wireghoul - http://www.justanotherhacker.com
use strict;
use warnings;
sub generate {
my $len=shift;
my $pattern='Aa0';
my $out = '';
while (length($out) < $len) {
$out.=$pattern;
$pattern++;
}
return substr($out,0,$len);
}
sub search {
my $string = shift;
# If we get a hex string, decode and reverse it
if ($string =~ /0x/) {
$string =~ s/([a-fA-F0-9][a-fA-F0-9])/chr(hex($1))/eg;
$string =~ s/0x//;
$string = reverse $string;
}
my $pat = 'Aa0';
my $out = '';
while ($out !~ m/$string/) {
$out.=$pat;
$pat++;
}
return index($out, $string);
}
if (!$ARGV[0]) {
print "Buffer overflow pattern generator by Wireghoul\n$0 <size> creates pattern of size characters\n$0 string finds offset of string in pattern\n";
exit 0 ;
}
if ($ARGV[0] =~ m/^\d+$/) {
print generate($ARGV[0]);
} else {
print search($ARGV[0])."\n";
}