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

Function findLocalPort

lib/core/common.py:2891–2915  ·  view source on GitHub ↗

Find the first opened localhost port from a given list of ports (e.g. for Tor port checks)

(ports)

Source from the content-addressed store, hash-verified

2889 return retVal
2890
2891def findLocalPort(ports):
2892 """
2893 Find the first opened localhost port from a given list of ports (e.g. for Tor port checks)
2894 """
2895
2896 retVal = None
2897
2898 for port in ports:
2899 try:
2900 try:
2901 s = socket._orig_socket(socket.AF_INET, socket.SOCK_STREAM)
2902 except AttributeError:
2903 s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
2904 s.connect((LOCALHOST, port))
2905 retVal = port
2906 break
2907 except socket.error:
2908 pass
2909 finally:
2910 try:
2911 s.close()
2912 except socket.error:
2913 pass
2914
2915 return retVal
2916
2917def findMultipartPostBoundary(post):
2918 """

Callers 2

_setTorHttpProxySettingsFunction · 0.90

Calls 2

connectMethod · 0.45
closeMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…