Skip to content

Instantly share code, notes, and snippets.

@basicxman
Created June 11, 2010 15:46
Show Gist options
  • Save basicxman/434664 to your computer and use it in GitHub Desktop.
Save basicxman/434664 to your computer and use it in GitHub Desktop.
Changes grab.php from the InfoLeakNotify repo.
<?php
/*
@author: Andrew Horsman
@description: Grabs new content from Information Leak
@prerequisites:
Ubuntu 9.04+ (Notification Systray)
libnotify-bin (install via sudo apt-get install libnotify-bin)
Firefox (with an binary or symlink in /usr/bin)
PHP 5+
@install:
Create a cron job which executes this script (needs to be run with some sort of output, i.e. X)
*/
// ~~~Functions~~~
function infoleak_connect() {
if (!($infoleak = fsockopen("informationleak.org", 80, $errno, $errstr, 20)))
die("Error #$errno: $errstr\n");
return $infoleak;
}
function infoleak_login($user, $pass) {
$il = infoleak_connect();
$loginInfoLeak =
"POST /ucp.php?mode=login HTTP/1.1\r\n" .
"Host: informationleak.org\r\n" .
"Keep-Alive: 115\r\n" .
"Connection: keep-alive\r\n" .
"Content-Type: application/x-www-form-urlencoded\r\n" .
"Content-Length: " . strlen(($cred = "username=" . urlencode($user) . "&password=" . urlencode($pass) . "&login=Login")) .
"\r\n\r\n$cred";
fwrite($il, $loginInfoLeak);
while (!feof($il))
if (preg_match("^phpbb3_okosr_sid=([[:xdigit:]]+)^", fgets($il), $matches)) $sid = $matches[0];
fclose($il); return $sid;
}
function infoleak_newPosts($sid) {
$il = infoleak_connect();
$newPostsInfoLeak =
"GET /search.php?search_id=activetopics&sid=" . substr($sid, 17, strlen($sid) - 17) . " HTTP/1.1\r\n" .
"Keep-Alive: 115\r\n" .
"Connection: keep-alive\r\n" .
"Host: informationleak.org\r\n" .
"Cookie: $sid\r\n\r\n";
fwrite($il, $newPostsInfoLeak);
$logfile = file_get_contents("~/notify/grablog.txt");
$logP = fopen("~/notify/grablog.txt", "a");
$count = 0;
while (!feof($il))
if (preg_match("^viewtopic\.php.*view=unread?^", fgets($il), $matches))
foreach ($matches as $l)
if (strpos($logfile, $l) === false) { ++$count; fwrite($logP, $l); }
fclose($il); fclose($logP); return $count;
}
function notifyUser($message, $url) {
$command = '/usr/bin/notify-send "Interwebs" "' . $message . '" -i notification-message-im';
if (isset($url)) $command .= ' | /usr/bin/firefox ' . $url;
`$command`;
}
// ~~~End Functions~~~
if ($argc != 3) die("Not enough arguments");
$user = $argv[1]; $pass = $argv[2];
if (($count = infoleak_newPosts(infoleak_login($user, $pass))) > 0)
notifyUser($count . " New Posts on Information Leak.", "http://informationleak.org/search.php?search_id=newposts");
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment