Last active
December 29, 2017 07:53
-
-
Save kitsuyui/aa1b9370c42e99d056d071fc60e0e8f5 to your computer and use it in GitHub Desktop.
netcat や nmap を使わずに bash だけでポートの開放をみたい場合のハック (横着) ref: https://qiita.com/kitsuyui/items/7d79fd8940d8910e3862
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$ exec 7<> /dev/tcp/8.8.8.8/53 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$ exec 7<> /dev/tcp/8.8.8.8/54 | |
(しばらく待たされる) | |
-bash: connect: Operation timed out | |
-bash: /dev/tcp/8.8.8.8/54: Operation timed out |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$ exec 7<> /dev/tcp/127.0.0.1/10000 | |
-bash: connect: Connection refused | |
-bash: /dev/tcp/127.0.0.1/10000: Connection refused |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$ check_tcp_port() (bash -c 'trap "exit 2" SIGTERM; (exec 7<> /dev/tcp/'"$1"'/'"$2"' & (sleep 1 && kill 0) & wait %1)' &> /dev/null) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$ check_tcp_port 8.8.8.8 53 ; echo $? | |
0 | |
$ check_tcp_port 8.8.8.8 54 ; echo $? | |
2 | |
$ check_tcp_port 127.0.0.1 10000 ; echo $? | |
1 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment