Forum Moderators: coopster
function IptablesDrop() {
$ip=$_SERVER['REMOTE_ADDR'];
#return(exec("sudo /usr/sbin/iptables -I Dynamic -s $ip -p tcp --dport 443 -j DROP"));
#return(exec("iptables -I Dynamic -s $ip -p tcp -j DROP"));
#return(exec("/home/linkcheck/prg/phpiptable $ip"));
return(exec("/srv/phpiptable $ip"));
} ip=$1
sudo /usr/sbin/iptables -I Dynamic -s $ip -p tcp -j DROP
#/usr/sbin/iptables -I Dynamic -s $ip -p tcp -j DROP user ALL=(ALL:ALL) ALL
root ALL=NOPASSWD: /usr/sbin/iptables
www-data ALL=NOPASSWD: /usr/sbin/iptables sudo: effective uid is not 0, is /usr/bin/sudo on a file system with the 'nosuid' option set or an NFS file system without root privileges
RewriteEngine on
<Directory />
AllowOverride none
</Directory>
RewriteCond %{HTTP_COOKIE} !keyname=[random 32 character key that I preset with a PHP script]
#List of potential attacks; this is just a short list of what I have
RewriteCond %{REQUEST_URI} ^/wp [NC,OR]
RewriteCond %{REQUEST_URI} ^/wordpress [NC,OR]
RewriteCond %{REQUEST_URI} /wp[2-]+\w+\.php [NC]
RewriteRule ^ - [F] #!/bin/bash
# script name: phptab
# read ip(s) from file and add to iptables; do not save dups
gotit=""
while read -r ip
do
if [ "$ip" != "" ]; then
if [ "$ip" != "$gotit" ]; then
gotit=$ip
# echo $ip
iptables -I Dynamic -s $ip -p tcp -j DROP
fi
fi
done < /srv/mts-ip.txt
require_once("/var/www/tools/MTS/MTS/EnableMTS.php");
...
...
// =======================
function do_iptable($ip) {
$filspec="/srv/mts-ip.txt";
// save IP to file
$fh=fopen($filspec,"a");
fwrite($fh,"$ip\n");
fclose($fh);
// open shell...
$shellObj= \MTS\Factories::getDevices()->getLocalHost()->getShell('bash', false);
// Pass the shellObj to the following function with root credentials.
\MTS\Factories::getActions()->getRemoteUsers()->changeUser($shellObj, 'root', 'password');
// no actual return but in case future...
$rtn = $shellObj->exeCmd('/srv/phptab');
// delete temp file...
unlink($filspec);
return($rtn);
}
// =======================
iptables -F Dynamic The plugin is vulnerable to Cross-Site Request Forgery (CSRF) vulnerability that could allow an unauthenticated attacker to add or remove arbitrary IP addresses from the block, allow lists. For a successful attack, a privileged authenticated WordPress user would need to visit a page the attack controls, for the CSRF attack to be executed.(from https://wpscan.com/vulnerability/c736713a-3a40-4652-ad56-33c412240588 ) Apparently the risk is considered low because it would require an authenticated user to click a link.