Remove iThemes Security Lockouts Script

I decided to create a command line PHP script that would list the current iThemes Security Logs and also allow you to remove them based on IP Address. Here is the script which I’ve called “ithemes-clearip.php” and it’s Github link, its dirty and really was made in like 15 minutes.

https://github.com/jordantrizz/wordpress-scripts

<?
// List and remove iThemes Security Log entries based on IP Address
// Options
$shortopts ="d:";
$shortopts .="l";
$options = getopt($shortopts);
//Database Connect
require_once("wp-config.php");
$link = new mysqli(DB_HOST, DB_USER, DB_PASSWORD, DB_NAME);
$database_name = DB_NAME;
if ($conn->connect_error) {
  die("Cant connect to database using wp-config.php details - Connection failed: " . $conn->connect_error);
}
if(!$options) {
  print "There was a problem reading in the options.\n\n";
  exit(1);
}
if(array_key_exists("d",$options)) {
  $ip = $options["d"];
  if(filter_var($ip, FILTER_VALIDATE_IP)){
    echo "Deleting all entries for IP Address ". $options["d"] ." in $database_name\n\n";
    $sql="delete from ".$database_name.".wp_itsec_log where log_host = \"".$ip."\"\n\n";
    echo $sql;
    if($link->query($sql) === TRUE) {
      echo "Deleted ". mysqli_affected_rows($link)." rows\n\n";
    } else {
      echo "Error deleting record: " . $conn->error;
    }
  } else {
    print "You didn't specify a correct IP Address.\n\n";
    exit(1);
  }
} elseif(empty($options["l"])) {
  $sql = 'SELECT log_host,log_date from wp_itsec_log';
  $result = $link->query($sql) or die(mysql_error());
  if (!$result) {
    print 'Could not run query: ' . mysql_error();
    exit;
  }
  print "\nLog Host\tLog Date";
  print "\n-----------------------------------";
  while($row = mysqli_fetch_row($result)) {
    print "\n".$row['0']."\t".$row['1'];
  }
  print "\n";
  mysqli_close($link);
}
?>

 

 

Nagios NRPE Disk Check Error on Plesk

If you’re monitoring a server with Nagios NRPE that is running Plesk, you might have run into the following issue. The disck_check command may return the following lovely error message.

DISK CRITICAL – /var/named/chroot/etc/named is not accessible: Permission denied

The fix is rather simple, you just need to modify the /etc/nagios/nrpe.cfg file and change your disk_check command to include the following

-x /var/named/chroot/etc/named -x /var/named/chroot/var/named -x /var/named/chroot/etc/named.rfc1912.zones -x /var/named/chroot/etc/rndc.key -x /var/named/chroot/usr/lib64/bind -x /var/named/chroot/etc/named.iscdlv.key -x /var/named/chroot/etc/named.root.key

Which will exclude the chrooted locations that the NRPE daemon doesn’t have access to it.

Setting up MikroTik/RouterOS with Conditional DNS Forwarding (UnoTelly/UnblockUS)

I have a MikroTik RouterOS device that has some custom DNS settings and therefore I cannot change the DNS servers it provides to clients, which is a requirement to use UnoTelly or Unblockus. Instead I found the following article very helpful, it allows you to configure Conditional DNS forwarding for specific domains.

https://www.dalemacartney.com/2012/12/29/dns-conditional-forwarders-with-mikrotik-routeros/

This works well because I use MediaHint to swap back and forth for NetFlix US and Canada, but use only the US Amazon Prime.

/ip firewall layer7-protocol add name=domain.com regexp=domain.com
/ip firewall mangle add chain=prerouting dst-address=<routeripaddress> layer7-protocol=domain.com action=mark-connection new-connection-mark=domain.com-forward protocol=tcp dst-port=53
/ip firewall mangle add chain=prerouting dst-address=<routeripaddress> layer7-protocol=domain.com action=mark-connection new-connection-mark=domain.com-forward protocol=udp dst-port=53
/ip firewall nat add action=dst-nat chain=dstnat connection-mark=domain.com-forward to-addresses=<UnoTellyDNSServerIPAddress>
/ip firewall nat add action=masquerade chain=srcnat connection-mark=domain.com-forward

 

How to Disable the Displet Pop WordPress Plugin on Specific Pages

You won’t find much within the support forums in-regards to how to stop the Displet Pop plugin from loading on specific pages. However, I was able to find some pre-created code that does accomplish the task and just modified it for the Displet Pop plugin.

function remove_displet_pop() {
$ids = array(1358,1226); // ID's of the pages you don't want displet pop to run on
if(is_page($ids)):
remove_action('wp_print_styles', 'displetpop_scripts');
remove_action('wp_head', 'displetpop_action');
wp_dequeue_script( 'displetpop_scripts' );
endif;
}
add_action('wp_head', 'remove_displet_pop', 1);

 

 

WordPress Plugin Wordtwit Add Twitter Account Not Working (Setup Instructions)

If you’ve recently upgraded Wordtwit, you’ll notice some changes which are specifically to address the old Twitter API being deprecated. You will need to create a Twitter Application for Wordtwit to be able to add a Twitter account.

The developer has provided some instructions on how to correctly create a Twitter application for Wordtwit:Creating a custom application for WordTwit

Make sure that you set the callback URL to your websites URL, which is what I had skipped and caused the “Add Account” button under Twitter accounts to not function at all.

 

 

Receiving Windows 7 File In Use Errors or File Locked By Process Errors

For some reason I’ve been getting issues with applications trying to update themselves, file lock errors will occur. Today it started happening with Steam, it downloaded an update and tried to run but was unable to remove the Steam.exe file stating that it was in use.

I did a bit of googling and found that this may occur if the Application Experience service is disabled, of which it was. Once I set it to “Manual” and started the service, Steam could update correctly with any file lock errors.

As for how this was disabled, I have no idea but I believe it may have been an SSD guide or a guide on how to disable non-essential Windows 7 services.

Export DHCP Leases to HTML or CSV in Windows Server 2003/2008

If you’re looking to export your DHCP leases on your Windows Server into a readable format, then the following article will help.

http://theadminguy.com/2009/10/14/export-dhcp-leases-to-html-using-powershell/

You can also simply run the following command and copy and paste it into excel and it should match the columns correctly.

netsh dhcp server 1.1.1.1 scope 1.1.1.0 show clients 1

 

 

OpenClinica Tomcat Error When Setting JAVA_OPTS on Ubuntu 10.04

I’ve setup OpenClinica a number of time and never really touched the JAVA_OPTS for Tomcat because I’ve never really had any issues. On the OpenClinica Installation Documentation it states that the JVM performs well when using the following JAVA_OPTS

https://docs.openclinica.com/3.1/installation/installation-linux#content-title-5460

export JAVA_OPTS="$JAVA_OPTS   -Xmx1280m -XX:+UseParallelGC -XX:ParallelGCThreads=2 -XX:MaxPermSize=180m -XX:+CMSClassUnloadingEnabled"

 

However, if you’re running Ubuntu 10.04 LTS, you will receive an error when modifying the /etc/default/tomcat6 JAVA_OPTS.

Conflicting collector combinations in option list; please refer to the release notes for the combinations allowed

 

The two options that cause this error are “-XX:+UseParallelGC -XX:ParallelGCThreads=2”, if you remove these then the errors go away. Looking into this further, I’ve found some documentation but not much. The commands are related to garbage collection, and the following article sheds some light on the above two commands as well as “-XX:+UseParNewGC”

http://stackoverflow.com/questions/2101518/difference-between-xxuseparallelgc-and-xxuseparnewgc

Upon remove the two recommended options and adding “-XX:+UseParNewGC” tomcat6 starts without error.

If anyone has any information on why this is, it would be great to know.

Apache Tomcat Native library Not Found Error on Ubuntu

Sometimes you might get the following error message in your logs for your Tomcat instance under Ubuntu.

The APR based Apache Tomcat Native library which allows optimal performance in production environments was not found

 

To fix this issue, simply run the following command to install the appropriate library.

apt-get install libtcnative-1

 

The error should go away!