Last active
January 2, 2017 04:00
-
-
Save tagroup/36c58bb10437cb39e5e151f6cd9d5617 to your computer and use it in GitHub Desktop.
Setup script to view what http traffic is coming to an ip address / server.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
apt-get update && apt-get upgrade -y | |
apt-get install -y apache2 php5 | |
echo '' > /etc/apache2/sites-available/000-default.conf | |
echo '<VirtualHost *:80> | |
ServerAdmin webmaster@localhost | |
DocumentRoot /var/www/html | |
<Directory "/var/www/html"> | |
AllowOverride All | |
</Directory> | |
ErrorLog ${APACHE_LOG_DIR}/error.log | |
CustomLog ${APACHE_LOG_DIR}/access.log combined | |
</VirtualHost> | |
# vim: syntax=apache ts=4 sw=4 sts=4 sr noet' > /etc/apache2/sites-available/000-default.conf | |
a2enmod rewrite | |
echo 'RewriteEngine on | |
RewriteCond %{REQUEST_FILENAME} !-d | |
RewriteCond %{REQUEST_FILENAME} !-f | |
RewriteRule ^(.*)$ index.php/$1?%{QUERY_STRING} [L]' > /var/www/html/.htaccess | |
echo '<?php | |
$data["server"]=$_SERVER; | |
$data["post"]=$_POST; | |
$data["get"]=$_GET; | |
$data["cookies"]=$_COOKIES; | |
$data["rawdata"]=file_get_contents("php://input"); | |
if(isset($_SERVER["HTTP_HOST"])) | |
file_put_contents("../host.txt",$_SERVER["HTTP_HOST"]."\n\n---\n\n" , FILE_APPEND | LOCK_EX); | |
file_put_contents("../log.txt",json_encode($data, JSON_PRETTY_PRINT)."\n\n---\n\n" , FILE_APPEND | LOCK_EX); | |
exit;' > /var/www/html/index.php | |
rm /var/www/html/index.html | |
touch /var/www/log.txt | |
touch /var/www/host.txt | |
chown www-data:www-data /var/www/*.txt | |
service apache2 restart | |
tail -f /var/www/log.txt |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment