Command Injection Projekt: Unterschied zwischen den Versionen

Aus Xinux Wiki
Zur Navigation springen Zur Suche springen
Zeile 8: Zeile 8:
 
=Beispiele==
 
=Beispiele==
 
==ping.php==
 
==ping.php==
  <!DOCTYPE html>
+
  <syntaxhighlight lang="html">
<html>
+
<!DOCTYPE html>
<body>
+
<html>
<h2>PING</h2>
+
<body>
<form method="post">
+
<h2>PING</h2>
<label for="fname">IP</label><br>
+
<form method="post">
<input type="text" name="ip"><br>
+
<label for="fname">IP</label><br>
<input type="submit" name="submit" value="submit">
+
<input type="text" name="ip"><br>
</form>
+
<input type="submit" name="submit" value="submit">
<br>
+
</form>
<?php
+
<br>
if(isset($_POST['submit'])){
+
<?php
$ip = $_POST['ip'];
+
if(isset($_POST['submit'])){
$cmd = 'ping -c 4 ' . $ip;
+
$ip = $_POST['ip'];
$output = shell_exec($cmd);
+
$cmd = 'ping -c 4 ' . $ip;
echo "<pre> $output</pre>";
+
$output = shell_exec($cmd);
}
+
echo "<pre> $output</pre>";
?>
+
}
</body>
+
?>
</html>
+
</body>
 +
</html>
 +
</syntaxhighlight>

Version vom 23. April 2025, 05:05 Uhr

Installation

  • sudo apt update
  • sudo apt install apache2 php libapache2-mod-php
  • sudo systemctl restart apache2

Test

Beispiele=

ping.php

<!DOCTYPE html>
<html>
<body>
<h2>PING</h2>
<form method="post">
<label for="fname">IP</label><br>
<input type="text" name="ip"><br>
<input type="submit" name="submit" value="submit">
</form>
<br>
<?php
if(isset($_POST['submit'])){
	$ip = $_POST['ip'];
	$cmd = 'ping -c 4 ' . $ip;
	$output = shell_exec($cmd);
	echo "<pre> $output</pre>";
}
?>
</body>
</html>