File tree Expand file tree Collapse file tree 1 file changed +8
-5
lines changed
Expand file tree Collapse file tree 1 file changed +8
-5
lines changed Original file line number Diff line number Diff line change @@ -15,7 +15,10 @@ import (
1515
1616// A very basic reverse/bind shell handler.
1717func Basic (conn net.Conn ) {
18- var shutdown int32 = 0
18+
19+ var shutdown atomic.Bool
20+ shutdown .Store (false )
21+
1922 // Create channels for communication between goroutines.
2023 responseCh := make (chan string )
2124
@@ -29,11 +32,11 @@ func Basic(conn net.Conn) {
2932 defer func (){
3033 // Signals for both routines to stop, this should get triggered when socket is closed
3134 // and causes it to fail the read
32- atomic . StoreInt32 ( & shutdown , 1 )
35+ shutdown . Store ( true )
3336 }()
3437 responseBuffer := make ([]byte , 1024 )
3538 for {
36- if atomic . LoadInt32 ( & shutdown ) == 1 {
39+ if shutdown . Load () {
3740 return
3841 }
3942 select {
@@ -61,7 +64,7 @@ func Basic(conn net.Conn) {
6164 go func () {
6265 defer wg .Done ()
6366 for {
64- if atomic . LoadInt32 ( & shutdown ) == 1 {
67+ if shutdown . Load () {
6568 return
6669 }
6770 select {
@@ -81,7 +84,7 @@ func Basic(conn net.Conn) {
8184 for {
8285 reader := bufio .NewReader (os .Stdin )
8386 command ,_ := reader .ReadString ('\n' )
84- if atomic . LoadInt32 ( & shutdown ) == 1 {
87+ if shutdown . Load () {
8588 break
8689 }
8790 ok := protocol .TCPWrite (conn , []byte (command ))
You can’t perform that action at this time.
0 commit comments