Jump to content

WAIT_FOR_PRESENT if statement?


Elaina

Recommended Posts

Hey I was wondering if it was possible to use the Bash Bunny Command WAIT_FOR_PRESENT in a if statement so instead of stopping the code and searching for a device name it would simply check for one and if not found move on. Sorry if this is an easy question to answer, I'm a little new to this and thanks for your time.

Link to comment
Share on other sites

Why do you want to use it along with an if statement? I get the idea in general. I would probably not rush over that if statement in that case but rather wait for a while since a quick "check and run" might miss a device nearby. Perhaps a "while" or "for" with some delays before skipping it and continuing with the code execution.

Link to comment
Share on other sites

@dark_pyrro I want this so I can run different payloads depending on what device I trigger it from, I also see the sense of delays but in the end I'm looking for a way to check for a Bluetooth device for lets say 5 seconds and if not picked up then go check for the next one. and the while loop makes it constantly check for devices. Making a way to run different payloads depending on what trigger is used.

Link to comment
Share on other sites

@dark_pyrro Thanks a lot, It seems to work although I wouldn't call it pretty. Here it is, just want your opinion on it as you know a lot more than I do.

#!/bin/bash

WAIT_FOR_BLUETOOTH() {
    stty -F /dev/ttyS1 speed 115200 cs8 -cstopb -parenb -echo -ixon -icanon -opost 
    stty -F /dev/ttyS1 speed 115200 cs8 -cstopb -parenb -echo -ixon -icanon -opost 
    sleep 1
    echo -n -e "AT+ROLE=2" > /dev/ttyS1
    echo -n -e "AT+RESET" > /dev/ttyS1
    timeout 5s cat /dev/ttyS1 > /tmp/bt_observation
}

ATTACKMODE HID

device="attack1"
otherdevice="attack2"

while true; do
    LED W

    WAIT_FOR_BLUETOOTH

    LED Y

    if grep -qao $device /tmp/bt_observation; then

        LED G

        Q GUI r

        Q DELAY 100

        Q STRING "notepad"

        Q ENTER

        Q DELAY 200

        Q STRING "attack1"

        Q ENTER

        break
        fi

    sleep 1

    if grep -qao $otherdevice /tmp/bt_observation; then

        LED B

        Q GUI r

        Q DELAY 100

        Q STRING "notepad"

        Q ENTER

        Q DELAY 200

        Q STRING "attack2"

        Q ENTER

        break
        fi

    sleep 1
done

Q DELAY 2000

LED M

 

Link to comment
Share on other sites

I have no opinion really. Or to be more exact, I don't have the time to look more in detail. Just test it and verify that it runs as expected. The thing that I probably would focus on (as long as the code is OK) is the delays just so that the Bluetooth communication gets the time it needs to "see" any BT device nearby.

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...