Permalink
Browse files

[Release] Version 0.2 (Security Fix)

  • Loading branch information...
1 parent d8c1240 commit 6fd9ee336b7b652db3cb276416b81e67617e5dd0 @ptkdev committed May 5, 2012
Showing with 174 additions and 27 deletions.
  1. +50 −0 src/confirm.php
  2. +72 −27 src/query/class.php
  3. +2 −0 src/query/db.sql
  4. +50 −0 src/sendmail.php
View
@@ -0,0 +1,50 @@
+<!DOCTYPE html>
+<?php
+/*
+ * TorEngine (HackingGame)
+ * Copyright (C) 2012 PTKDev
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Affero General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Affero General Public License for more details.
+ *
+ * You should have received a copy of the GNU Affero General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ *
+*/
+ $dot = ".";
+ include "$dot/query/config.php";
+ include "$dot/query/class.php";
+ $get = new hackme();
+?>
+<html>
+ <head>
+ <title>HackGame - TorEngine</title>
+ <meta charset="utf-8">
+ <link rel="icon" href="http://www.torengine.it/favicon.png" type="image/png" />
+ <link rel="icon" href="http://www.torengine.it/favicon.ico" type="image/ico" />
+ <link rel="stylesheet" type="text/css" href="<?php echo $dot; ?>/css/main.css" />
+ <script type="text/javascript" src="<?php echo $dot; ?>/js/menu.js"></script>
+ <script type="text/javascript" src="<?php echo $dot; ?>/js/jquery.js"></script>
+ <script type="text/javascript" src="<?php echo $dot; ?>/js/typewriter.js"></script>
+ </head>
+
+ <body>
+ <p id="line1">TorEngine - Verifica Email </p>
+ <p>
+ <?php
+ if(!empty($_GET['hash']) && !empty($_GET['mail'])){
+ $get->enable($_GET['hash'],$_GET['mail']);
+ }
+ ?>
+ </p>
+
+ <br />
+ </body>
+</html>
View
@@ -20,10 +20,43 @@
class hackme
{
+ public function sendmail()
+ {
+ $sql = "SELECT mail FROM torengine_hackgame";
+ $array = mysql_query($sql) or die(mysql_error());
+ $row = mysql_fetch_array($array);
+
+ while($row = mysql_fetch_array($array)){
+ mail($row['mail'], "HackingGame TorEngine - Nuovo Checkpoint Disponibile", "E' disponibile un nuovo checkpoint, divertiti! http://hackme.torengine.it/");
+ }
+
+
+ return 0;
+ }
+
+ public function enable($hash,$mail)
+ {
+ $sql = "SELECT ID FROM torengine_hackgame WHERE mail = '$mail' AND hash = '$hash'";
+ $array = mysql_query($sql) or die(mysql_error());
+ $row = mysql_fetch_array($array);
+
+ if(!empty($row['ID'])){
+ $sql = "UPDATE torengine_hackgame SET hide = '1'";
+ $result = mysql_query($sql) or die(mysql_error());
+
+ echo "OK";
+ }else{
+ echo "Error: contatta ptkdev@gmail.com";
+ }
+
+
+ return 0;
+ }
+
public function checkpoint($id)
{
- $sql = "SELECT nick,nome,fb,tw FROM torengine_hackgame ORDER BY ID";
+ $sql = "SELECT nick,nome,fb,tw,hide FROM torengine_hackgame ORDER BY ID";
$array = mysql_query($sql) or die(mysql_error());
echo "HACKERS CHECKPOINT ".$id.":\n";
@@ -33,26 +66,27 @@ public function checkpoint($id)
$i = 0;
while($row = mysql_fetch_array($array)){
- $i=1;
- echo "<tr>\n";
- echo "<td>NickName: ".$row['nick']."</td>\n";
-
- echo "<td>&nbsp;&nbsp;|&nbsp;&nbsp;</td>\n";
-
- echo "<td>Nome: ".$row['nome']."</td>\n";
-
- echo "<td>&nbsp;&nbsp;|&nbsp;&nbsp;</td>\n";
-
- if(!empty($row['fb'])){
- echo "<td><a href='http://www.fb.me/".$row['fb']."'><img src='./img/fb.png' /></a>&nbsp;&nbsp;</td>\n";
- }
-
- if(!empty($row['tw'])){
- echo "<td><a href='http://www.twitter.com/".$row['tw']."'><img src='./img/tw.png' /></a>&nbsp;&nbsp;</td>\n";
+ if($row['hide']==1){
+ $i=1;
+ echo "<tr>\n";
+ echo "<td>NickName: ".$row['nick']."</td>\n";
+
+ echo "<td>&nbsp;&nbsp;|&nbsp;&nbsp;</td>\n";
+
+ echo "<td>Nome: ".$row['nome']."</td>\n";
+
+ echo "<td>&nbsp;&nbsp;|&nbsp;&nbsp;</td>\n";
+
+ if(!empty($row['fb'])){
+ echo "<td><a href='http://www.fb.me/".$row['fb']."'><img src='./img/fb.png' /></a>&nbsp;&nbsp;</td>\n";
+ }
+
+ if(!empty($row['tw'])){
+ echo "<td><a href='http://www.twitter.com/".$row['tw']."'><img src='./img/tw.png' /></a>&nbsp;&nbsp;</td>\n";
+ }
+
+ echo "</tr>\n";
}
-
- echo "</tr>\n";
-
}
if($i==0){
@@ -86,32 +120,43 @@ public function add($nick,$nome,$fb,$tw,$mail,$pass,$ip,$iphost,$iptime,$check)
}
}
- $sql = "SELECT ID FROM torengine_hackgame WHERE pass = '$pass' AND mail = '$mail' AND checkpoint = '$check'";
- $array = mysql_query($sql) or die(mysql_error());
- $row = mysql_fetch_array($array);
if($returned == 1){
+
+ $hash = "$mail$pass$check";
+ $hash = md5($hash);
+
+ $sql = "SELECT ID FROM torengine_hackgame WHERE pass = '$pass' AND mail = '$mail' AND checkpoint = '$check'";
+ $array = mysql_query($sql) or die(mysql_error());
+ $row = mysql_fetch_array($array);
+
if(!empty($row['ID'])){
- $sql = "UPDATE torengine_hackgame SET nick = '$nick', nome = '$nome', fb = '$fb', tw = '$tw', mail = '$mail', pass = '$pass',ip = '$ip',iphost = '$iphost',iptime = '$iptime', checkpoint = '$check' WHERE ID = '".$row['ID']."'";
+ if(empty($hash)){
+ $hash = "$mail$pass$check";
+ $hash = md5($hash);
+ }
+ $sql = "UPDATE torengine_hackgame SET nick = '$nick', nome = '$nome', fb = '$fb', tw = '$tw', mail = '$mail', pass = '$pass',ip = '$ip',iphost = '$iphost',iptime = '$iptime', checkpoint = '$check', hash = '$hash' WHERE ID = '".$row['ID']."'";
$result = mysql_query($sql) or die(mysql_error());
}else{
$sql = "SELECT ID FROM torengine_hackgame WHERE mail = '$mail'";
$array = mysql_query($sql) or die(mysql_error());
$row = mysql_fetch_array($array);
if(empty($row['ID'])){
mysql_query("INSERT INTO
- torengine_hackgame (`nick`,`nome`,`fb`,`tw`,`mail`,`pass`,`ip`,`iphost`,`iptime`,`checkpoint`)
- VALUES ('$nick','$nome','$fb','$tw','$mail','$pass','$ip','$iphost','$iptime','$check')
+ torengine_hackgame (`nick`,`nome`,`fb`,`tw`,`mail`,`pass`,`ip`,`iphost`,`iptime`,`checkpoint`,`hash`,`hide`)
+ VALUES ('$nick','$nome','$fb','$tw','$mail','$pass','$ip','$iphost','$iptime','$check','$hash','0')
")
or die(mysql_error());
+
+ mail($mail, "HackingGame TorEngine - Verifica Email", "Conferma il checkpoint clickando qui: http://hackme.torengine.it/confirm.php?hash=$hash&mail=$mail");
}else{
$returned = 2;
}
}
}
if($returned == 1){
- echo "Hai aggiunto il tuo checkpoint con successo";
+ echo "Hai aggiunto il tuo checkpoint con successo.<br/>Conferma l'email per apparire in homepage.";
}else{
if($returned == 2){
echo "Errore: Email già presente nel database";
View
@@ -28,5 +28,7 @@ CREATE TABLE `torengine_hackgame` (
`iphost` varchar(100) NOT NULL default '',
`iptime` varchar(100) NOT NULL default '',
`checkpoint` bigint(20) NOT NULL default '0',
+ `hash` varchar(100) NOT NULL default '',
+ `hide` bigint(20) NOT NULL default '0',
PRIMARY KEY (`ID`)
) ENGINE=MyISAM AUTO_INCREMENT=1 DEFAULT CHARSET=utf8 AUTO_INCREMENT=1;
View
@@ -0,0 +1,50 @@
+<!DOCTYPE html>
+<?php
+/*
+ * TorEngine (HackingGame)
+ * Copyright (C) 2012 PTKDev
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Affero General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Affero General Public License for more details.
+ *
+ * You should have received a copy of the GNU Affero General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ *
+*/
+ $dot = ".";
+ include "$dot/query/config.php";
+ include "$dot/query/class.php";
+ $get = new hackme();
+?>
+<html>
+ <head>
+ <title>HackGame - TorEngine</title>
+ <meta charset="utf-8">
+ <link rel="icon" href="http://www.torengine.it/favicon.png" type="image/png" />
+ <link rel="icon" href="http://www.torengine.it/favicon.ico" type="image/ico" />
+ <link rel="stylesheet" type="text/css" href="<?php echo $dot; ?>/css/main.css" />
+ <script type="text/javascript" src="<?php echo $dot; ?>/js/menu.js"></script>
+ <script type="text/javascript" src="<?php echo $dot; ?>/js/jquery.js"></script>
+ <script type="text/javascript" src="<?php echo $dot; ?>/js/typewriter.js"></script>
+ </head>
+
+ <body>
+ <p id="line1">TorEngine - Verifica Email </p>
+ <p>
+ <?php
+ if(!empty($_GET['hash']) && !empty($_GET['mail'])){
+ $get->sendmail();
+ }
+ ?>
+ </p>
+
+ <br />
+ </body>
+</html>

0 comments on commit 6fd9ee3

Please sign in to comment.