我正在学习戈朗,并想要建立一个带有SOCKS5代理的TCP端口扫描仪,作为大规模扫描的中继。
虽然所有的S5代理都是检查每一个目标扫描,有时会有一些假阳性-我找不到原因。
准备proxyDialer:
func create_socks5_tcp_dialer(socks5_addr string) proxy.Dialer {
//socks5_dialer_tcp, err := proxy.SOCKS5("tcp", socks5_addr, nil, proxy.Direct)
socks5_dialer_tcp, err := proxy.SOCKS5("tcp", socks5_addr, nil, &net.Dialer{Timeout: 5 * time.Second, KeepAlive: 5 * time.Second})
if err != nil {
fmt.Println("Error connecting to proxy:", err)
}
return socks5_dialer_tcp
}验证socks5地址:
func socks5_validator(socks5_addr, vps_opened, vps_closed string) (bool, string) {
/* Check if SOCKS5 proxy is valid.
1. Connect to the open port on the server under my control using proxy.
2. Connect to the closed port on the server under my control using proxy.
- If both checks are true then, SOCKS5 proxy is considered as valid.
- If one of the check is false, SOCKS5 proxy is considered as invalid.
3. Returns true/false and s5_addr.
*/
// Create SOCKS5 dialer
socks5_dialer_tcp := create_socks5_tcp_dialer(socks5_addr)
// Make connection using SOCKS5 proxy to the opened port on the vps.
conn_1, err := socks5_dialer_tcp.Dial("tcp", vps_opened)
// If it was successful and not generate any error then check1 is passed.
if err == nil {
//fmt.Println("CHECK 1: PASSED")
conn_1.Close()
// If error was generated then check is not passed and do not make check2.
} else {
//fmt.Println("CHECK 1: NOT PASSED")
return false, socks5_addr
}
// Make connection using SOCKS5 proxy to the closed port on the vps.
conn_2, err := socks5_dialer_tcp.Dial("tcp", vps_closed)
// If it was unsuccessful and error was generated then check2 is passed.
if err != nil {
//fmt.Println("CHECK 2: PASSED")
// If both checks were passed then return false.
return true, socks5_addr
// If error was not generated then check2 is not passed.
} else {
//fmt.Println("CHECK 2: NOT PASSED")
conn_2.Close()
return false, socks5_addr
}
}端口扫描
s5_dialer_tcp := create_socks5_tcp_dialer(socks5_addr)
// Scan target using s5
conn, err := s5_dialer_tcp.Dial("tcp", target)
if err != nil {
//open
} else {
//closed
}我的问题是:我是否通过SOCKS5代理正确地扫描TCP服务,以及是否正确地验证了该代理?
发布于 2022-01-31 03:17:32
我不认为这些是真正的假阳性。相反,您对这些代理的工作方式有错误的假设:假设在特定时间对特定端口打开(连接成功)和特定端口关闭(连接失败)的单个检查成功,则可以使用代理在任意时间可靠地检查任意服务器上的许多任意端口。
这种假设可能是无效的,特别是考虑到您似乎使用了超出您控制范围的代理。
这类代理的一个常见行为是它们只提供受限的访问,例如HTTP和HTTPS这样的公共端口将工作,而其他端口将被阻塞。代理也可能采用速率限制,因此它们将在一段时间后拒绝通过代理进行访问。一些列表中的免费代理通常会在一段时间后停止工作。
https://stackoverflow.com/questions/70919958
复制相似问题