ToKeiChun

Socket Server with Perl

Jun 1st, 2021 (edited)
901
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Perl 0.62 KB | None | 0 0
  1. #!/usr/bin/perl -w
  2. # source : https://pastebin.com/zk8v8jp6
  3. use strict;
  4. use IO::Socket;
  5.  
  6. sub Wait {
  7.     wait; # wait needed to keep <defunct> pids from building up
  8. }
  9.  
  10. $SIG{CHLD} = \&Wait;
  11.  
  12. my $server = IO::Socket::INET->new(
  13.     LocalPort   => 1337,    # set port
  14.     Type        => SOCK_STREAM,
  15.     Reuse       => 1,
  16.     Listen      => 10) or die "$@\n";
  17. my $client ;
  18.  
  19. while($client = $server->accept()) {
  20.     select $client;
  21.     print $client "HTTP/1.0 200 OK\r\n";
  22.     print $client "Content-type: text/html\r\n\r\n";
  23.     print $client 'Hacked by ./tokeichun'; # set your html content
  24. }
  25. continue {
  26.     close($client); #kills hangs
  27.     kill CHLD => -$$;
  28. }
Add Comment
Please, Sign In to add comment