Jump to content

Is there any way to check if the SJC is connected already to some port?


catx0rr

Recommended Posts

Hi,

As I try experimenting the payload to use a while loop to not turn it off and on, i made some validation checks to see if shark is connected before executing the payload / script.

at the end of the script:

 

while true; do
    LED B SLOW
    DELAY ${MAIN_SLEEP}
    if [ `CHECK_PORT` == "yes" ]; then
        RESTART_NETWORK
        CREATE_LOOT_DIR
        SETUP_START
        EXECUTE_DHCP_CHECK
    fi
done

Check port is:

function CHECK_PORT() {
     ethtool eth0 | grep Link | awk '{print $3}'
}

eth tool will check if the link is detected:

# ethtool eth0 | grep Link
   Link detected: yes

Also tried: cat /sys/class/net/eth0/carrier to see if carrier value is 1.

It appears to be always connected because of the rj45 head of SharkJack?

Link to comment
Share on other sites

Found it. it was

# swconfig dev switch0 show | grep link


link: port:0 link:down
link: port:1 link:down
link: port:2 link:down
link: port:3 link:down
link: port:4 link:down
link: port:5 link:down
link: port:6 link:up speed: 1000baseT full-duplex

 

# swconfig dev switch0 show | grep port:0 | awk '{print $3}' | cut -d':' -f2

It appears that eth0 is in link port 0, so made a validation check if it is connected.

function CHECK_LINK_PORT() {
     swconfig dev switch0 show | grep port:0 | awk '{print $3}' | cut -d':' -f2
}

 

while true; do
    LED B SLOW
    DELAY ${MAIN_SLEEP}
    if [ `CHECK_LINK_PORT` == "up" ]; then
        RESTART_NETWORK
        CREATE_LOOT_DIR  
        SETUP_START
        EXECUTE_DHCP_CHECK
    fi
done

Connected SJC to serial port on mobile terminal.. there i was able to check if the device is connected or not.

 

Edited by catx0rr
Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

  • Recently Browsing   0 members

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