•
•
•
•
What is DaniWeb IT Discussion Community?
You're currently browsing the Perl section within the Software Development category of DaniWeb, a massive community of 402,787 software developers, web developers, Internet marketers, and tech gurus who are all enthusiastic about making contacts, networking, and learning from each other. In fact, there are 2,819 IT professionals currently interacting right now! Registration is free, only takes a minute and lets you enjoy all of the interactive features of the site.
Please support our Perl advertiser: Programming Forums
Views: 418 | Replies: 3
![]() |
•
•
Join Date: Jul 2008
Posts: 1
Reputation:
Rep Power: 0
Solved Threads: 0
For a challenge, we have to code a script that can pull information from a web page and then use it to automate an action on that site. What I've chosen to try and do is code an IPB Forum Advertiser. The process is easy, but I can't seem to get it to work.
The Problem: so far I can't seem to get it to login and not sure what I'm doing wrong.
The Problem: so far I can't seem to get it to login and not sure what I'm doing wrong.
perl Syntax (Toggle Plain Text)
#!/usr/bin/perl use LWP::UserAgent; use HTTP::Cookies; $host = @ARGV[0]; @badID = (1,2,3,4,5); $arrSize = @badID; $i = 2; if (@ARGV < 1) { print "\n\n [-] Specify a host"; print "\n\n [!] Example: pm.pl http://www.sitename.com/path/\n\n"; exit(0); } loginPrompt(); sub login($$) { $browser = LWP::UserAgent->new(agent => 'Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.0; T312461)' , ); $cookie_jar = HTTP::Cookies->new(); $browser->cookie_jar($cookie_jar); $response = $browser->post( $host.'/index.php?act=Login&CODE=01', [ 'referer' => '', 'UserName' =>$_[0], 'PassWord'=>$_[1], 'CookieDate' => '1', 'Privacy' => '1', 'submit'=>'Log me in' ] ); $content = $response->content; if ($content =~ /<head>/gmi) {print "\n[-] INCORRECT LOGIN\n"; loginPrompt()} else{msgInfo()} } sub spam() { for ($j = 0; $j <= $arrSize + 1; $j++) { if ($i > $uid){ print "\n\n * Spamming Completed\n"; exit(0) } if ($badID[$j] eq $i) { $i++; spam() } } sleep(15); $res = $browser->get("$host/index.php?act=Msg&CODE=4&MID=$i"); $results = $res->content; if ($results =~ /name="post_key" value="([a-f0-9]{32})"(.*)/){$postkey = $1;} if ($results =~ /name="auth_key" value="([a-f0-9]{32})"(.*)/){$authkey = $2;} if ($results =~ /name="entered_name"(.*) value="(.*?)"(.*)/gmi){$name = $3;} $resp = $browser->post( "$host/index.php?act=msg", [ 'removeattachid'=> '0', 'OID'=>'', 'act'=>'Msg', 'CODE'=>'04', 'MODE'=>'01', 'post_key'=> $postkey, 'auth_key'=>$authkey, 'entered_name'=>$name, 'msg_title'=> $subj, 'Post'=> $msg, 'post'=>'Submit', Referer => $host ] ); print "\n [!] Message Sent to: $name with SID $SID"; if ($i > $uid){print "\n\n * Spamming Completed\n"; exit(0)} else{$i++;spam()} } sub loginPrompt() { print "\nEnter your login name: "; chomp($id = <STDIN>); print "\nEnter your password: "; chomp($pass = <STDIN>); login($id, $pass); } sub msgInfo() { print "\nEnter message subject: "; chomp($subj = <STDIN>); print "\nEnter your message: "; chomp($msg = <STDIN>); print "\nEnter highest uid: "; chomp($uid = <STDIN>); spam(); }
![]() |
•
•
•
•
•
•
•
•
DaniWeb Perl Marketplace
•
•
•
•
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
Similar Threads
- HP Pavilion ze5155 BIOS problem... (Troubleshooting Dead Machines)
- Find out the problem of my code. (Java)
- reversing number problem. (C)
- Cannot Find Server or DNS Error - Secure Sites Pls Review HiJacks Log (Viruses, Spyware and other Nasties)
- Desktop background hijacked-NEW Problem (Web Browsers)
- cannot find server - Microsoft Internet Explorer afterdownloading Win Service pack 2 (Networking Hardware Configuration)
- Ideas needed for problem with trailing whitespaces (C++)
- Find and Replace (Database Design)
- Install problem~ (Windows NT / 2000 / XP / 2003)
- Monitor/video card problem (Monitors, Displays and Video Cards)
Other Threads in the Perl Forum
- Previous Thread: problem
- Next Thread: Script to Remove duplicate lines from a text file.


Linear Mode