# -*- coding: utf-8; mode: tcl; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- vim:fenc=utf-8:ft=tcl:et:sw=4:ts=4:sts=4
# $Id: Portfile 106176 2013-05-17 23:06:56Z ryandesign@macports.org $

PortSystem          1.0

name                reaver
version             1.4
categories          security net
platforms           darwin
maintainers         ryandesign openmaintainer
license             GPL-2+

description         Brute-force attack against Wi-Fi Protected Setup

long_description    Reaver implements a brute-force attack against Wi-Fi \
                    Protected Setup which can crack the WPS PIN of a wireless \
                    access point in a matter of hours and subsequently recover \
                    the WPA/WPA2 passphrase. Reaver includes Wash, a utility \
                    for identifying potentially vulnerable access points.

homepage            http://code.google.com/p/reaver-wps/
master_sites        googlecode:reaver-wps

checksums           rmd160  190f4481987c57d3ee956e5800287d5a69fd0516 \
                    sha256  add3050a4a05fe0ab6bfb291ee2de8e9b8a85f1e64ced93ee27a75744954b22d

depends_lib         port:libpcap \
                    port:sqlite3

patch.dir           ${worksrcpath}/src
configure.dir       ${patch.dir}
build.dir           ${configure.dir}

patchfiles          patch-Makefile.in.diff \
                    reaver_osx.diff

# Disable silent rules.
build.args          V=1

post-destroot {
    xinstall -d ${destroot}${prefix}/share/doc
    copy ${worksrcpath}/docs ${destroot}${prefix}/share/doc/${name}
    move ${destroot}${prefix}/share/doc/${name}/reaver.1.gz ${destroot}${prefix}/share/man/man1
    move ${destroot}${prefix}/etc/reaver/reaver.db ${destroot}${prefix}/etc/reaver/reaver.db.empty
}

post-activate {
    if {![file exists ${prefix}/etc/reaver/reaver.db]} {
        copy ${prefix}/etc/reaver/reaver.db.empty ${prefix}/etc/reaver/reaver.db
    }
}

# TODO: Does not consistently use -arch flags or the requested compiler.
universal_variant   no

notes "
Reaver is only supported on Linux. This expiremental OS X port uses patches\
submitted to the developers of Reaver but not yet incorporated into their\
code. On OS X, the reaver and wash tools must be run as root, and you will be\
disassociated from your normal wireless network while using them.
"
