updated on Wed Jan 18 04:00:29 UTC 2012
[aur-mirror.git] / exploit-db / exploit-db.sh
blobf4f958cec8dc9a4b38145a0cc257101fa21232ad
1 #!/bin/bash
2 #download, update and query local exploit database from exploit-db.com
3 target_dir="/opt/exploit-db"
5 case "$1" in
6 update)
7 if [ $UID != 0 ]; then
8 echo You must run exploit-db update as root!;
9 exit;
10 fi;
11 echo "Downloading exploit archive from exploit-db.com..."
12 mkdir -p "$target_dir"
13 cd "$target_dir";
14 wget "http://www.exploit-db.com/archive.tar.bz2"
15 echo "Extracting archive..."
16 tar jxpf archive.tar.bz2
17 rm archive.tar.bz2
18 chmod -R a+r *
20 search)
21 cat "$target_dir/files.csv" | grep -i "$2" | while read line; do
22 echo $target_dir$(echo $line | sed -r 's/^[0-9]+,([^,]+),"([^"]*)",([0-9-]+),.*/\/opt\/exploit-db\/\1 \2 (\3)/')
23 done;
25 usearch)
26 $0 update
27 $0 search "$2"
30 echo 'Local exploit-db.com exploit database tool by Deeno9 2010'
31 echo 'based on:'
32 echo ' Local Milw0rm.com exploit database tool by Harvie 2009 ( http://blog.harvie.cz/ )'
33 echo
34 echo "Target directory: $target_dir"
35 echo "usage: $0 {update|search regexp|usearch regexp}"
36 esac