Guest User

List Linux sockets accessible by this user. (2) (Python)

a guest
May 19th, 2026
110
0
224 days
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.33 KB | Software | 0 0
  1. #!/bin/python
  2. import socket
  3. import errno
  4.  
  5. for i in range(256):
  6.     try:
  7.         s = socket.socket(i, 0, 0)
  8.     except OSError as e:
  9.         if e.errno == 97:
  10.             continue
  11.         elif e.errno == 1:
  12.             print(f"socket({i:02d}): This user does not have access to this socket.")
  13.             continue
  14.     print(f"socket({i:02d}): This user has access to this socket.")
Advertisement
Add Comment
Please, Sign In to add comment