#!/usr/bin/perl # # ibProBattle Bot # (c) Mindfuck 2007 # # This Bot automates the Invision Power Board -Board Game ibP-Battle # # Features & HowTo: rtfm! # ####################### use strict; use warnings; use WWW::Mechanize; use HTML::TokeParser; use HTTP::Cookies; use Term::ANSIColor; ############################## CONFIG ######################################### my $guild = "0"; # Use guild mode? # NOT Implemented... my $DEBUG = "1"; # Show debug messages? my $username = "Mindfuck"; # ipB Login my $password = "Gehaim"; # Your Password my $url = "usb.unitedsb.de"; # ipB Url my $protection = '1'; # Use suicide Protection? my $deathtimer = '5'; # Check timer when youre dead... my @friends = (10202,7222); # Friend Id's my $healthwatcher = '1'; # fork() and check if we need Hp? my $delay = '151'; # Delay between Attacks my $max_attacks = '5'; # How many Attacks should we do? my $watchdelay = '60'; # Time between Health-Checks in seconds my $watchlog = '0'; # Show Healthwatcher messages? my $spread = '15'; # Randomize our timers :) ################# NO NEED TO EDIT BELOW THIS LINE ############################# my $agent = WWW::Mechanize->new(); $agent->cookie_jar(HTTP::Cookies->new); my $count = '1'; our $stop = '0'; my $version = "0.2b"; sub gettime { chomp(my @time = localtime); my $time2 = "$time[2]:$time[1]:$time[0] "; return $time2; } sub randomizer { my $seconds = shift; my $rand_number = int(rand($spread)); my $twisted = ($seconds + $rand_number); return $twisted; } sub timer { my $minutes = shift; my $seconds = ($minutes * 60); my $magic = randomizer($seconds); print gettime(); print("Sleeping for $minutes minutes\n"); sleep($magic); } sub id2nick { my $id = shift; $agent->get("http://$url/index.php?showuser=$id"); my $nick = $agent->content =~ m/(.+) - Profil ansehen<\/title>/; my $dood = $1; return $dood; } sub logmein { CONNECT: if ($DEBUG == '1') { print("DEBUG: Accessing $url\n");} $agent->get("http://$url/index.php?act=Login&CODE=00"); $agent->success or (sleep(600) and (goto CONNECT)); $agent->form_name('LOGIN') or goto SLEEP; $agent->field('UserName',$username); $agent->field('PassWord',$password); if ($DEBUG == '1') { print("DEBUG: Logging in...\n");} $agent->submit(); print("Send User\/Pass to $url\n"); } sub attack { $agent->get("http://$url/index.php?act=atkshop&do=target"); my @targetsite = $agent->content; if ($DEBUG == '1') { print("DEBUG: Parsing Victims...\n");} my @targets; foreach (@targetsite) { push @targets, $_ =~ m/act=attack&m=(\d+)/gs; } if ($DEBUG == '1') { print ("DEBUG: Found Target: @targets\n");} if ($DEBUG == '1') { print("DEBUG: Attacking...\n");} foreach (@targets) { my $target = $_; $agent->get("http://$url/index.php?act=attack&m=$target"); if ($DEBUG == '1') { print("DEBUG: Choosing best Weapon...\n");} my @weaponlist = $agent->content =~ m/.+&w=(\d)/; my @weapons = sort(@weaponlist); if ((defined $weapons[0]) and ($stop == '0') and ($target != @friends)) { if ($DEBUG == '1') { print("DEBUG: Attack \#$count\n");} $agent->get("http://$url/index.php?act=attack&m=$target&w=$weapons[0]"); print gettime(); print("\#$count $username Attacked Target id "); print id2nick($target); print(" with Weapon $weapons[0]\n"); $count++; healcheck(); } else { print gettime(); print("Cant attack "); print id2nick($_); print(" \(Id: $_\), moving on to next Victim\n") } if ($count == $max_attacks) { print gettime(); print("Attacked $max_attacks Targets, stopping...\n"); healcheck(); goto SLEEP; } } if ($DEBUG == '1') { print("DEBUG: Attack finished\n");} } sub healcheck { if ($DEBUG == '1') { print gettime(); print("DEBUG: Checking if we need a Potion\n");} $agent->get("http://$url/index.php?act=atkshop&do=target"); my @hpmaxhp = $agent->content =~ m/.+<strong>Hp: <\/strong> (\d+)\/(\d+)/; my $hp = $hpmaxhp[0]; my $maxhp = $hpmaxhp[1]; my $prozente = $hp * 100 / $maxhp; if ($prozente == '0') { if ($DEBUG == '1') { print("DEBUG: Im Dead!\n");} my $deathsleep = ($deathtimer * 60); print gettime(); print("!!!YOU ARE DEAD!!!\n"); print gettime(); print("Sleeping for $deathtimer minutes\n"); sleep($deathsleep); goto START; } elsif ($prozente < '25') { if ($DEBUG == '1') { print("DEBUG: Health below 25%, trying to use middle potion.\n");} heal("25"); } elsif ($prozente < '101') { if ($DEBUG == '1') { print("DEBUG: Health below 55%, trying to use small potion.\n");} heal("50"); } } sub heal { my $pro = shift; if ($pro == '50') { print("Got 50 procent\n"); $agent->get("http://$url/index.php?act=atkshop"); my @shopsite = $agent->content; my $money1 = $shopsite[0]; my ($money) = $money1 =~ m/Euro:<\/strong> (\d+(?:,\d+)?)/; $money = ~ m/.+Euro:<\/strong> (\d+)<br>/; my $s_potions = $shopsite[0]; $s_potions =~ m/.+>War Pills \((\d+)\)</; print("Money: $money \| Small Potions: $s_potions\n"); if ($s_potions > 1) { print gettime(); print("Using small Potion\n"); $agent->get("http://$url/index.php?act=atkshop&do=use&item=1"); } elsif (($s_potions == '0') and ($money > '125')) { print gettime(); print("Buying small Potion\n"); $agent->get("http://$url/index.php?act=atkshop&do=buy&item=1"); print gettime(); print("Using small Potion\n"); $agent->get("http://$url/index.php?act=atkshop&do=use&item=1"); } elsif (($s_potions == '0') and ($money < '125')) { print gettime(); print("No Money, No Potions, sleeping...\n"); goto SLEEP; } } elsif ($pro == '25') { print("Got 25 procent\n"); $agent->get("http://$url/index.php?act=atkshop"); my @shopsite = $agent->content; my $money1 = $shopsite[0]; my ($money) = $money1 =~ m/Euro:<\/strong> (\d+(?:,\d+)?)/; my $s_potions = $shopsite[0]; $s_potions =~ m/.+>War Pills \((\d+)\)</; print("Money: $money \| Small Potions: $s_potions\n"); if ($s_potions > '1') { print gettime(); print("Using small Potion\n"); $agent->get("http://$url/index.php?act=atkshop&do=use&item=1"); } elsif (($s_potions == '0') and ($money > '125')) { print gettime(); print("Buying small Potion\n"); $agent->get("http://$url/index.php?act=atkshop&do=buy&item=1"); print gettime(); print("Using small Potion\n"); $agent->get("http://$url/index.php?act=atkshop&do=use&item=1"); } elsif (($s_potions == '0') and ($money < '125')) { print gettime(); print("No Money, No Potions, sleeping...\n"); goto SLEEP; } } } sub healthwatch { logmein(); WATCHER: if ($watchlog == '1') { print gettime(); print("Checking if we need a Potion\n"); } healcheck(); sleep($watchdelay); goto WATCHER; } main { # system("clear"); if ($DEBUG == '1') { print gettime(); print("DEBUGGING STARTED\n\n");} print color("white"), "Mindfucks ipB Battle Bot version $version\n", color("reset"); if ($healthwatcher == '1') { if(! defined(my $pid= fork())){ die "Error on Fork\n";} elsif($pid==0){ healthwatch(); } else{ START: logmein(); healcheck(); attack(); if ($DEBUG == '1') { print gettime(); print("DEBUGGING ENDED\n");} SLEEP: timer($delay); goto START; } } else { START: logmein(); healcheck(); attack(); if ($DEBUG == '1') { print("DEBUGGING ENDED\n");} SLEEP: timer($delay); goto START; } }