- Top 10 credentials, all time
- Newest 10 credentials
- Connections per Year
- Connections per Day of Week
- Connections per Hour of Day
[insert_php]
$servername = „db683540042.db.1and1.com“;
$username = „dbo683540042“;
$password = „ibiudbd“;
try {
$conn = new PDO(„mysql:host=$servername;dbname=db683540042;port=3306″, $username, $password);
// set the PDO error mode to exception
$conn->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
}
catch(PDOException $e)
{
die();
}
$byYearAndMonth = [];
$byYearAndMonth[0] = [“];
$minMonth = 12;
$maxMonth = 1;
$minYear = 9999;
$maxYear = 0;
$statement = $conn->prepare(„SELECT
MONTH(time) as m,
YEAR(time) as y,
COUNT(*) as c
FROM hpConnects
GROUP BY
MONTH(time),
YEAR(time)“);
$statement->execute();
$rows = $statement->fetchAll();
foreach ($rows as $row)
{
// echo „“.$row[‚m‘].“/“.$row[‚y‘].“ -> „.$row[‚c‘].“\r\n
„;
if ($minYear > $row[‚y‘])
$minYear = $row[‚y‘];
if ($maxYear < $row['y'])
$maxYear = $row['y'];
if ($minMonth > $row[‚m‘])
$minMonth = $row[‚m‘];
if ($maxMonth < $row['m'])
$maxMonth = $row['m'];
if ( $byYearAndMonth[$row['m']] == null)
{
$byYearAndMonth[$row['m']] = [];
$byYearAndMonth[$row['m']][$row['y']] = $row['c'];
}
}
//print_r($byYearAndMonth);
$statement = $conn->prepare(„SELECT
HOUR(time) as h,
COUNT(*) as c
FROM hpConnects
GROUP BY
HOUR(time)“);
$statement->execute();
$rows = $statement->fetchAll();
$byHourOfDay = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0];
foreach ($rows as $row)
{
$byHourOfDay[$row[‚h‘]] = $row[‚c‘];
}
//print_r($byHourOfDay);
$statement = $conn->prepare(„SELECT
WEEKDAY(time) as d,
COUNT(*) as c
FROM hpConnects
GROUP BY
WEEKDAY(time)“);
$statement->execute();
$rows = $statement->fetchAll();
$byDayOfWeek= [0, 0, 0, 0, 0, 0, 0];
foreach ($rows as $row)
{
$byDayOfWeek[$row[‚d‘]] = $row[‚c‘];
}
//print_r($byDayOfWeek);
$statement = $conn->prepare(„SELECT count(DISTINCT password, user) as countD, count(*) as countA FROM hpCredentials“);
$statement->execute(array(
„hash“ => $hash));
$row = $statement->fetch();
if ($row != null)
{
$totalLogins = $row[„countA“];
$distinctCredentials = $row[„countD“];
echo $row[„countD“].“ distinct Username / Password combinations observed
„;
echo $row[„countA“].“ login requests
„;
}
echo „
Top 10 Credentials (all time)
show all
„;
$statement = $conn->prepare(„SELECT a.connect, a.password, a.user, count(a.user + a.password) as count, b.content as pw, c.content as us, MIN(d.time) as firstseen, MAX(d.time) as lastseen FROM hpCredentials a LEFT JOIN hpStrings b ON (b.id = a.password) LEFT JOIN hpStrings c ON (c.id = a.user) LEFT JOIN hpConnects d ON (a.connect = d.id) GROUP BY a.password, a.user order by count desc LIMIT 10“);
$statement->execute(array(
„hash“ => $hash));
$rows = $statement->fetchAll();
echo „
| Username | Password | # of uses | % of all login tries | first seen | last seen |
|---|---|---|---|---|---|
| „.$row[‚us‘].“ | „.$row[‚pw‘].“ | „.$row[‚count‘].“ | „. $percent.“ | „.$row[‚firstseen‘].“ | „.$row[‚lastseen‘].“ |
„;
echo „
Newest 10 Credentials (all time)
show all
„;
$statement = $conn->prepare(„SELECT a.connect, a.password, a.user, count(a.user + a.password) as count, b.content as pw, c.content as us, MIN(d.time) as firstseen, MAX(d.time) as lastseen FROM hpCredentials a LEFT JOIN hpStrings b ON (b.id = a.password) LEFT JOIN hpStrings c ON (c.id = a.user) LEFT JOIN hpConnects d ON (a.connect = d.id) GROUP BY a.password, a.user order by firstseen desc LIMIT 10“);
$statement->execute(array(
„hash“ => $hash));
$rows = $statement->fetchAll();
echo „
| Username | Password | # of uses | % of all login tries | first seen | last seen |
|---|---|---|---|---|---|
| „.$row[‚us‘].“ | „.$row[‚pw‘].“ | „.$row[‚count‘].“ | „. $percent.“ | „.$row[‚firstseen‘].“ | „.$row[‚lastseen‘].“ |
„;
[/insert_php]