MCPcopy Index your code
hub / github.com/sqlmapproject/sqlmap / socksocket

Class socksocket

thirdparty/socks/socks.py:124–395  ·  view source on GitHub ↗

socksocket([family[, type[, proto]]]) -> socket object Open a SOCKS enabled socket. The parameters are the same as those of the standard socket init. In order for SOCKS to work, you must specify family=AF_INET, type=SOCK_STREAM and proto=0.

Source from the content-addressed store, hash-verified

122 module.socket.create_connection = _orgcreateconnection
123
124class socksocket(socket.socket):
125 """socksocket([family[, type[, proto]]]) -> socket object
126 Open a SOCKS enabled socket. The parameters are the same as
127 those of the standard socket init. In order for SOCKS to work,
128 you must specify family=AF_INET, type=SOCK_STREAM and proto=0.
129 """
130
131 def __init__(self, family=socket.AF_INET, type=socket.SOCK_STREAM, proto=0, _sock=None):
132 _orgsocket.__init__(self, family, type, proto, _sock)
133 if _defaultproxy != None:
134 self.__proxy = _defaultproxy
135 else:
136 self.__proxy = (None, None, None, None, None, None)
137 self.__proxysockname = None
138 self.__proxypeername = None
139
140 def __recvall(self, count):
141 """__recvall(count) -> data
142 Receive EXACTLY the number of bytes requested from the socket.
143 Blocks until the required number of bytes have been received.
144 """
145 data = self.recv(count)
146 while len(data) < count:
147 d = self.recv(count-len(data))
148 if not d: raise GeneralProxyError((0, "connection closed unexpectedly"))
149 data = data + d
150 return data
151
152 def setproxy(self, proxytype=None, addr=None, port=None, rdns=True, username=None, password=None):
153 """setproxy(proxytype, addr[, port[, rdns[, username[, password]]]])
154 Sets the proxy to be used.
155 proxytype - The type of the proxy to be used. Three types
156 are supported: PROXY_TYPE_SOCKS4 (including socks4a),
157 PROXY_TYPE_SOCKS5 and PROXY_TYPE_HTTP
158 addr - The address of the server (IP or DNS).
159 port - The port of the server. Defaults to 1080 for SOCKS
160 servers and 8080 for HTTP proxy servers.
161 rdns - Should DNS queries be preformed on the remote side
162 (rather than the local side). The default is True.
163 Note: This has no effect with SOCKS4 servers.
164 username - Username to authenticate with to the server.
165 The default is no authentication.
166 password - Password to authenticate with to the server.
167 Only relevant when username is also provided.
168 """
169 self.__proxy = (proxytype, addr, port, rdns, username, password)
170
171 def __negotiatesocks5(self, destaddr, destport):
172 """__negotiatesocks5(self,destaddr,destport)
173 Negotiates a connection through a SOCKS5 server.
174 """
175 # First we'll send the authentication packages we support.
176 if (self.__proxy[4]!=None) and (self.__proxy[5]!=None):
177 # The username/password details were supplied to the
178 # setproxy method so we support the USERNAME/PASSWORD
179 # authentication (in addition to the standard none).
180 self.sendall(struct.pack('BBBB', 0x05, 0x02, 0x00, 0x02))
181 else:

Callers 1

create_connectionFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…