Конвертер *.cap в *.hccap

Discussion in 'Беспроводные технологии/Wi-Fi/Wardriving' started by i~DOS, 9 Aug 2015.

  1. i~DOS

    i~DOS Member

    Joined:
    26 Mar 2009
    Messages:
    42
    Likes Received:
    40
    Reputations:
    4
    В соседней теме поступила просьба написать bash скрипт для автоматизации конвертирования .cap файлов в .hccap. Сегодня наткнулся на немного более продвинутую версию подобного скрипта, немного подредактировал и теперь спешу поделиться.

    Как использовать (пути указывать без слеша в конце):
    Code:
     bash scriptname.sh каталог_с_cap каталог_для_результата 
    Суть такова: скрипт берет все .cap файлы из входной директории, сортирует, берет уникальные, прогоняет через wpaclean, кладёт плохие файлы отдельно, а уникальные перегоняет через "aircrack-ng -J".

    Code:
    #Script_it, a simple script which simply tidy your .cap packets collection and prepare them for cracking with oclHashcat-Plus.
    #You're free to redistribute this script anywhere you want, but keep the original credits. Thank You.
    #Concept by Hash-IT
    #Code by SmilingWolf edited by i~DOS
    #You're using the v1.0 of Script_it, codename Strike Of The Ninja
    echo "Script_it, a simple script which simply tidy your .cap packets collection and prepare them for cracking with oclHashcat-Plus."
    echo "You're free to redistribute this script anywhere you want, but keep the original credits. Thank You."
    echo "Concept by Hash-IT"
    echo "Code by SmilingWolf edited by i~DOS"
    echo "You're using the v1.0 of Script_it, codename Strike Of The Ninja"
    sleep 3
    clear;
    if [ $# -ne 2 ]
    then
       echo "ERROR: should have 2 command-line parameters"
       echo "USING: bash $0 input_folder output_folder"
    fi
    mkdir -p $2/OriginalCaps
    OriginalCaps=0
    for f in $1/*.cap
    do
    CorrectString=`file "$f" | grep -o "tcpdump capture file"`
      if [ "$CorrectString" == 'tcpdump capture file' ];
      then
      cp "$f" $2/OriginalCaps/
      OriginalCaps=$(($OriginalCaps + 1))
      fi
    done
    echo "Deleting duplicated packets..."
    mkdir $2/UniqueCaps
    md5sum $2/OriginalCaps/* > /tmp/hashes_files.tmp
    LIST=`md5sum $2/OriginalCaps/* | cut -d ' ' -f 1 | sort | uniq`
    for MD5 in $LIST
      do
      ULIST=`grep $MD5 /tmp/hashes_files.tmp | head -1 | cut -d ' ' -f 3-`
      cp "$ULIST" $2/UniqueCaps/
    done
    rm /tmp/hashes_files.tmp
    echo "Done."
    mkdir $2/BadCaps
    BadCaps=0
    for f in $2/UniqueCaps/*
      do
      l=`wpaclean /dev/null "$f" | wc -l`
      if [ $l == 2 ];
      then
      NewPos=`echo -n "$f" | cut -b 14-`
      echo "Bad capture file found!!! Moving it to $2/BadCaps/$NewPos"
      mv "$f" $2/BadCaps/
      BadCaps=$(($BadCaps + 1))
      fi  
    done
    mkdir $2/ReallyUniqueCaps
    UniqueCaps=0
    for f in $2/UniqueCaps/*
      do
      BSSID=`wpaclean /dev/null "$f" | cut -d ' ' -f 2 | tail -2 | head -1`
      echo "$BSSID $f">> /tmp/bssids_files.tmp
    done
    LIST=`cat /tmp/bssids_files.tmp | cut -d ' ' -f 1 | sort | uniq`
    for BSSIDS in $LIST
      do
      ULIST=`grep $BSSIDS /tmp/bssids_files.tmp | head -1 | cut -d ' ' -f 2-`
      cp "$ULIST" $2/ReallyUniqueCaps/
      UniqueCaps=$(($UniqueCaps + 1 ))
    done
    rm /tmp/bssids_files.tmp
    mkdir $2/CleanCaps
    CleanCaps=0
    c=1
    for f in $2/ReallyUniqueCaps/*
      do
      l=`wpaclean /dev/null "$f" | tail -2 | head -1 | cut -d ' ' -f 3-`
      if [ -e "$2/CleanCaps/$l clean.cap" ];
      then
      if [ -e "$2/CleanCaps/$l ($c) clean.cap" ];
      then
      c=$(( $c + 1 ))
      else
      wpaclean "$2/CleanCaps/$l ($c) clean.cap" "$f"
      fi
      else
      wpaclean "$2/CleanCaps/$l clean.cap" "$f"
      c=1
      fi
      CleanCaps=$(($CleanCaps + 1))
    done
    mkdir $2/HCcaps
    HCcaps=0
    for f in $2/CleanCaps/*
      do
      echo $n
      n=`echo -n "$f" | cut -b $((${#2} + 12))- | sed s/\ clean\.cap//g`
      aircrack-ng "$f" -J "$2/HCcaps/$n" >> /dev/null
      echo "Converting $f to $2/HCcaps/$n.hccap"
      HCcaps=$(($HCcaps + 1))
    done
    sleep 3
    clear;
    echo ""
    echo "Report Time!"
    echo "Starting number of .cap files: $OriginalCaps"
    echo "They are in $2/OriginalCaps"
    echo "Corrupted Caps found: $BadCaps"
    echo "They are in $2/BadCaps"
    echo "Unique Caps found: $UniqueCaps"
    echo "They are in $2/ReallyUniqueCaps"
    echo "Clean Caps obtained: $CleanCaps"
    echo "They are in $2/CleanCaps"
    echo "Caps converted to HCcaps: $HCcaps"
    echo "They are in $2/HCcaps"
    
     
    #1 i~DOS, 9 Aug 2015
    Last edited: 9 Aug 2015
    chernec likes this.
  2. valokorden

    valokorden Member

    Joined:
    8 Sep 2011
    Messages:
    64
    Likes Received:
    12
    Reputations:
    0
    Проверим

    Чистить чистит, а вот не конвертирует в hccap, хотя пишет что сделал))
     
    #2 valokorden, 9 Aug 2015
    Last edited: 9 Aug 2015
  3. i~DOS

    i~DOS Member

    Joined:
    26 Mar 2009
    Messages:
    42
    Likes Received:
    40
    Reputations:
    4
    Эту часть оригинальног скрипта даже не трогал, не думал, что там могут быть ошибки. Сейчас вроде пофиксил, должно работать. Если будут ещё проблемы, то лучше в личку, дабы не засорять пост.

    up: пофиксил ещё пару мелких багов, теперь уж точно заботает как надо
     
    #3 i~DOS, 9 Aug 2015
    Last edited: 9 Aug 2015
  4. valokorden

    valokorden Member

    Joined:
    8 Sep 2011
    Messages:
    64
    Likes Received:
    12
    Reputations:
    0
    Вот щас пашет!!!