-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added TCP proxy to proxy to different site
- Loading branch information
Showing
1 changed file
with
39 additions
and
0 deletions.
There are no files selected for viewing
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
package main | ||
|
||
import ( | ||
"io" | ||
"log" | ||
"net" | ||
) | ||
|
||
func handle(conn net.Conn) { | ||
destConn, err := net.Dial("tcp", "scanme.nmap.org:80") | ||
if err != nil { | ||
log.Fatalln("Unable to connect to scan me ", err) | ||
} | ||
go func() { | ||
_, err = io.Copy(destConn, conn) | ||
if err != nil { | ||
log.Fatalln("Unable to copy to dest writer ", err) | ||
} | ||
}() | ||
|
||
_, err = io.Copy(conn, destConn) | ||
if err != nil { | ||
log.Fatalln("unable to copy response to source writer ", err) | ||
} | ||
} | ||
|
||
func main() { | ||
listener, err := net.Listen("tcp", ":9091") | ||
if err != nil { | ||
log.Fatalln("Unable to listen ", err) | ||
} | ||
for { | ||
conn, err2 := listener.Accept() | ||
if err2 != nil { | ||
log.Fatalln("Unable to accept ", err2) | ||
} | ||
go handle(conn) | ||
} | ||
} |