Guest User

List Linux sockets accessible by this user. (2)

a guest
May 19th, 2026
63
0
339 days
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.43 KB | Software | 0 0
  1. #include <stdio.h>
  2. #include <string.h>
  3. #include <sys/socket.h>
  4. #include <errno.h>
  5. int main()
  6. {
  7.     for (int i = 0; i <= 256; i++)
  8.     {
  9.         errno = 0;
  10.         int s = socket(i,0,0);
  11.         if (s == -1) {
  12.             if (errno == 97) {continue;}
  13.             if (errno ==  1) {printf("socket(%02i) -> %03i: This user does not have access to this socket.\n",i,errno); continue;}
  14.         }
  15.         printf("socket(%02i) -> %03i: This user has access to this socket.\n",i,errno);
  16.     }
  17. }
Advertisement
Add Comment
Please, Sign In to add comment