Skip to content

SSH copy files

the first folder is the from directory, then the next is the

cp -R /share/Multimedia/Videos/ /share/USBDisk2/Backup-3_2019/Multimedia/

Then, fix the permissions:

chmod -R 777 /share/USBDisk2/-Backup-3_2019/

Picking ionic back up

OK, so it’s been a while and you have to pick back up from where you last left off with your ionic app. He’s how to go about that on Mac with Git.

  1. Pull from Git
  2. Run “npm install” to get all the modules
  3. Run “ionic cordova platform add ios”
  4. Run “ionic cordova prepare” to install plugins
  5. Run “ionic cordova resources” to generate splash and icons

If you need to redo your signing, you can follow these steps

  1. Select a development team
  2. If you invalid errors, make sure your system clock has the correct date

Hopefully that did the trick and you’re ready to go, I’ll add any errors and fixes I come across to the end of the article, but here’s how to go about testing.

Emulator testing:

  1. Just run ‘ ionic cordova emulate ios  -l — –buildFlag=”-UseModernBuildSystem=0″ ‘ to start it up in the emulator

Ad hoc Device testing:

  1. Open Xcode
  2. Open the iOS project, probably something like “~/Documents/app/platform/ios/App.xcworkspace”
  3. Login to developer account under Xcode>settings>accounts
  4. Select “Generic iOS Device” as device
  5. Choose Product->Build For->Testing
  6. Product->Archive
  7. Click the “Export…” button and choose Development and choose where to export the IPA
  8. Upload the IPA to, then install on device


To fix “‘xcodebuild’ requires Xcode” errors

  • Run Xcode from applications directory
  • xcode-select –install # Install Command Line Tools if you haven’t already.
  • sudo xcode-select –switch /Library/Developer/CommandLineTools # Enable command line tools
  • sudo xcode-select -s /Applications/

Engintron and mirrors

This is pretty much the same thing as what I did in a previous post, but with Engintron vs NGINX CP.  I had to do a lot of server updates to get PHP7 running, and the process broke NGINX CP, so I had to switch to Engintron.  NGINX by itself is much more efficient than Apache, and thus far has been plenty to keep the server running even when traffic spikes.  But for special occasions I do like to have a back-up plan in case the system gets overloaded so I have a mirror set and ready to go.

To first install Engintron you can follow these instructions:

  1. cd /
  2. rm -f
  3. wget –no-check-certificate
  4. bash install

One thing I found out is caching is not on for dynamic pages by default, in order to turn that on go to the Enigtron interface from WHM, then click on “Edit default.conf” find this code:


and set it to:


“bypass_for_dynamic” will essentially turn off caching for dynamic pages, if your dynamic pages aren’t being updated very often it’s best to have caching on.  If you have a specific page that cannot by cached you can turn the bypass back on using something like this:

 if ($SITE_URI ~* "") {

Like previously I’m using  the split clients module to spread out traffic to a mirror.  The logic here is a bit more tricky then in NGINX CP and I only have one mirror, so the $mirror variable is just determining whether or not I’ll be redirecting that user.  The code looks essentially like this:

split_clients "${remote_addr}-{$query_string}" $mirror {
   5% "y";
   * "n";
server {
   if ($SITE_URI ~* "") {
      set $mirror "${mirror}maindomain";
   if ($http_referer = "") {
      set $mirror "n";
   if ($mirror = "ymaindomain") {
      return 302 "";

So here the split_clients will set the $mirror variable to “y” 5% of the time.  Then, if the domain is “” it will set the $mirror variable to either “ymaindomain” or “nmaindomain” and the http_referer is just stopping all direct traffic from being redirected to the mirror.  The reason I’m changing the variable is so I don’t end up mirroring subdomains, and I could use that to have different mirrors for different subdomains or specific pages.

How to Package cordova app

Just a simple step by step reference for packaging a cordova app:

  1. CD to the directory containing your app in the console
  2. export PATH=$PATH:”/cygdrive/P/Programs/Android/SDK/tools”
    export PATH=$PATH:”/cygdrive/P/Programs/Java/jdk1.8.0_121/bin”
    export PATH=$PATH:”/cygdrive/P/Programs/Android/SDK/build-tools/25.0.1″
    export ANDROID_HOME=/cygdrive/P/Programs/Android/SDK/
    export PATH=${PATH}:$ANDROID_HOME/tools:$ANDROID_HOME/platform-tools
    This is specific to my system, you may not need to do something like this
  3. cordova build –release android
    This will create platforms\android\build\outputs\apk\android-release-unsigned.apk
  4. CD and copy your keystore to platforms\android\build\outputs\apk
  5. jarsigner -verbose -sigalg SHA1withDSA -digestalg SHA1 -keystore your.keystore android-release-unsigned.apk keystorename
    sign it with your keystore, you may need to use a different signing method
  6. zipalign -v 4 android-release-unsigned.apk android-release-signed.apk

All done!

How to clean up a File Inclusion attack

I recently helped out a friend clean up an infection from their website.  A hacker took advantage of some outdated plugins to sneak in some malicious code to their website.  Following these steps I was able to find all the infected files, fix the vulnerability, and block the attackers IP.

Find infected files

Hop on the shell, and run this script to review all recently added files:

find ~/websitedirectory/ -name "*.php" -type f -ctime -30  | less

That will list all php files added to the server in the past 30 days.

Also, if you have webalizer or awstats available through your host, go through the logs and search for all files ending in php, any core files or files with random strings for names should be reviewed.

Open one of the infected files, it may be including another file they slipped into your account so track that down and delete it.  Also, try to find something particular in the code so you can use it as another method to track down any infected files.  In the shell this code with search the contents of all php files for SOMETHING:

find ~/websitedirectory/ -name "*.php" -exec grep -l "SOMETHING" {} \;

Make a list of all the locations of backdoor files that the hacker created, we’ll be using those later.

Clean the infection

If possible, delete the entire website and upload from an earlier version before the attack.  If you can’t delete everything, delete and re-upload as many folders as you can.  And for any folder you can’t delete, take whatever steps you need to fix the infected files, this will vary based on the malicious code.

Prevent further infection

Update all your software and plugins to the latest version, if you’re running something out of date that’s likely where they got in. Also, make sure your files all have the proper permissions, these lines will set the proper CHMOD for all files and folders:

find ~/websitedirectory -type f ! -perm 644 -exec chmod 644 {} \;
find ~/websitedirectory -type d ! -perm 755 -exec chmod 755 {} \;

Reset all FTP and CMS account passwords.

And, as an added bonus, use that list of backdoor files to record the IP of the attackers.  If you were able to get correct IP addresses from webalizer and awstats then you can simply block those.  If you’re running cpanel you can block IPs in Security > IP Deny Manager.  If they didn’t record the correct IPs or you don’t have those services, you can use that list of backdoor files to capture the hackers IP.  Replace the code in those files with something like this:

file_put_contents('/home/websitedirectory/hackers.log', $line . PHP_EOL, FILE_APPEND);

That will record the IP of anyone who visits those files in a hackers.log file so you can block them and stop them from fishing around in the future.

Hopefully, that’ll do it!

It may not work in all infections, but it did the trick in this case. You’ll want to replace ~/websitedirectory and /home/websitedirectory/hackers.log with URLs that are relevant to your web server.  Good luck!