#Packager: Frédéric Galusik <fredg~at~salixos~dot~org>
#
# source location:http://hashcat.net/hashcat/#downloadlatest
# No way to get them with wget/curl
#
pkgname=hashcat
pkgver=0.35
pkgrel=1fg
# You need a CPU capable of SSE2 instruction set so arch > i486
arch=i686
source=(http://people.salixos.org/fredg/packages/hashcat/$pkgver/hashcat-$pkgver.rar)
sourcetemplate=http://people.salixos.org/fredg/packages/$pkgname/$pkgver/
url=http://hashcat.net/hashcat

slackdesc=\
(
#|-----handy-ruler------------------------------------------------------|
"haschcat (Advanced password recovery)"
"Hashcat is a Multithreaded cross platform hash cracker."
"Some features:"
"All Attack-Modes except Brute-Force and Permutation can be extended"
"by rules, very fast Rule-engine Rules mostly compatible with JTR and"
"PasswordsPro, Possible to resume or limit session, automatically"
"recognizes recovered hashes from outfile at startup, 33+ Algorithms"
"implemented with performance in mind, ... and much more"
""
"Warning: this software is free to use, but is NOT OpenSource."
)

build() {
    cd $startdir
    unrar x $pkgname-$pkgver.rar
    mkdir -p $startdir/pkg/usr/bin
    mkdir -p $startdir/pkg/usr/lib${LIBDIRSUFFIX}/$pkgname-$pkgver
    mkdir -p $startdir/pkg/usr/doc/$pkgname-$pkgver
    cp -Rf $pkgname-$pkgver/{examples,rules,salts} \
        $startdir/pkg/usr/lib${LIBDIRSUFFIX}/$pkgname-$pkgver
    cp $pkgname-$pkgver/docs/* $startdir/pkg/usr/doc/$pkgname-$pkgver

    if [ "$arch" = "i686" ]; then
        hashsuffix=32
    else
        hashsuffix=64
    fi

    cp $pkgname-$pkgver/hashcat-cli${hashsuffix}.bin \
        $startdir/pkg/usr/lib${LIBDIRSUFFIX}/$pkgname-$pkgver/hashcat-cli.bin

    echo "#!/bin/sh" > $startdir/pkg/usr/bin/hashcat
    echo "exec /usr/lib${LIBDIRSUFFIX}/$pkgname-$pkgver/hashcat-cli.bin \"\$@\"" >> \
        $startdir/pkg/usr/bin/hashcat
    echo "Hashcat is free to use but it is NOT Open Source." > \
        $startdir/pkg/usr/doc/$pkgname-$pkgver/LICENCE
    echo "It is a proprietary software." >> \
        $startdir/pkg/usr/doc/$pkgname-$pkgver/LICENCE
    echo "Use it at your own risk." >> \
        $startdir/pkg/usr/doc/$pkgname-$pkgver/LICENCE
    echo "" >> $startdir/pkg/usr/doc/$pkgname-$pkgver/LICENCE
    echo "Visit http://hashcat.net/hashcat/ for more informations" >> \
        $startdir/pkg/usr/doc/$pkgname-$pkgver/LICENCE

    cd $startdir/pkg/usr/lib${LIBDIRSUFFIX}/$pkgname-$pkgver
    find . -type f -exec chmod 644 '{}' +
    find . -type d -exec chmod 755 '{}' +

    chmod 755 $startdir/pkg/usr/bin/hashcat
    chmod 755 $startdir/pkg/usr/lib${LIBDIRSUFFIX}/$pkgname-$pkgver/hashcat-cli.bin
}