All posts by admin

How to Fix a Hacked WordPress Website

Problem:

When you visit your WordPress website you are randomly redirected to unwanted websites.

Verification:
  • Log in your website as an Administrator.
  • Go to Appearance >> Theme File Editor.
  • Click on the Theme Functions link on the right side.
  • Verify if malicious code was injected into the functions.php file. Example of malicious code:
    <?php @ini_set('display_errors', '0'); 
    error_reporting(0); 
    global $zeeta;
  • Download the wp-config.php file to your machine via FTP or SSH.
  • Verify if malicious code was injected into the wp-config.php file. Example of malicious code:
    include_once(ABSPATH . WPINC . '/header.php');
Solution:
  • Stop the website.
  • Download the whole website to your local machine.
    cd /var/hosting/huybien.com
    ls
    sudo zip -r huybien.zip /var/hosting/huybien.com/html
Configuration:
  • Log in your website as an Administrator.
  • Change your Administrator’s password.
  • Change file owner and group to www-data:
    sudo chown -R www-data:www-data /var/hosting/huybien.com/html
  • IMPORTANT STEP – Set minimum permissions for folders and files:
    cd /var/hosting/huybien.com/html
    sudo find . -type d -exec chmod 755 {} \; # directory permissions rwxr-xr-x
    sudo find . -type f -exec chmod 644 {} \; # file permissions rw-r--r--
  • Remove all the unused plug-ins or themes.
  • Install, activate and configure a CAPTCHA plug-in to protect Login Form, Registration Form, Lost Password Form, Reset Password Form and Comment Form if there is no one.
  • Disable insecure FTP access if there is one.
  • Install and activate the Simple History plugin to review access to your website. After 1 or 2 days, review the access information, and possibly block the malicious IP addresses using the Windows Firewall.
  • Install, activate and configure Cerber Security plug-in to automatically detect and block the malicious IP addresses.
  • Back up database.
    cd /home/ubuntu
    ls
    mysqldump -u root -p -h localhost huybiencomwp > huybiencomwp.sql
  • Back up files.
    cd /home/ubuntu
    ls
    sudo zip -r /home/ubuntu/huybien.zip /var/hosting/huybien.com/html
  • Download database and files backup.
  • Remove the backups.
    sudo rm -rf /home/ubuntu/huybiencomwp.sql
    sudo rm -rf /home/ubuntu/huybien.zip
    ls

 

How to Fix “The parameter is incorrect” Issue When Disabling the Sync Host OneSyncSvc Service

Problem:

The Sync Host OneSyncSvc service was not started correctly and caused error in the Server Manager.

You wanted to disable this service. However you got the “The parameter is incorrect” error message when disabling it.

Solution:
  1. Click on the Search icon, type regedit, press Enter.
  2. Locate the key below
Computer\HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\OneSyncSvc

3.  Change the Start value from 2 to 4 (Disabled).

4. Restart the server.

 

How to Fix the “We can’t sign into your account” Issue in Windows

Problem:

You remotely connect o a computer using a Windows Domain account and get the error message below.

We can't sign into your account
Solution:
  1. Login the computer as a Local Administrator.
  2. Open C:\Users and delete the folder of the Windows Domain account.
  3. Click Search icon, enter regedit, and press Enter.
  4. Navigate to the path below.
HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\ProfileList

4. Look for the Profile of the Windows Domain account by reviewing the ProfileImagePath value.

5. Delete the Profile key of the Windows Domain account.

6. Restart the machine.

How to Manually Install PHP 7.4 on Windows Server 2019

Motivation:

  • You want to deploy a PHP application or WordPress on Windows Server 2019.
  • You want to update PHP to any version to address compatibility or security issues in Windows.
  • You want to understand how PHP works with IIS.

Solution:

  • Install CGI for IIS on Turn Windows features on or off > Internet Information Services > World Wide Web Services > Application Development Features > CGI.
  • Download VC15 x86 Non Thread Safe package here or under PHP 7.4 section from http://windows.php.net/download/
  • Extract the ZIP file to the C:\Program Files (x86)\php-7.4.9-nts-Win32-vc15-x86 folder.
  • Rename the php-.ini-development file to php.ini.
  • Open the php.ini file and add the following line at the end of the file.
    extension=php_wincache.dll
  • Uncomment the following lines
    fastcgi.impersonate = 1;
    
    cgi.fix_pathinfo=1;
    cgi.force_redirect = 1 (and change the value to 0, i.e. cgi.force_redirect = 0)
    
    extension_dir = "C:\Program Files (x86)\php-7.4.9-nts-Win32-vc15-x86\ext"
    
    extension=php_curl.dll
    extension=php_fileinfo.dll
    extension=php_mbstring.dll
    extension=php_exif.dll
    extension=php_mysqli.dll
    extension=php_pdo_mysql.dll
    extension=php_openssl.dll
    
    error_log = "C:\Program Files (x86)\php-7.4.9-nts-Win32-vc15-x86\php_errors.log"
    
    error_log = syslog
  • A sample php.ini file can be download here.
  • Add C:\Program Files (x86)\php-7.4.9-nts-Win32-vc15-x86 to System Path.
  • Download x86 package of WinCache 2.0 for PHP 7.4 here or from https://sourceforge.net/projects/wincache/.
  • Extract and copy the php_wincache.dll file to C:\Program Files (x86)\php-7.4.9-nts-Win32-vc15-x86\ext
    folder.
  • Open IIS, click on Server name, double click on Handler Mappings, click on Add Module Mapping, and enter below information.
    Request path = *.php
    
    Module = FastCgiModule
    
    Executable = "C:\Program Files (x86)\php-7.4.9-nts-Win32-vc15-x86\php-cgi.exe"
    
    Name = PHP 7.4
    
    Request Restrictions = File or folder
  • Download and install VC_redist.x86.exe of Microsoft Visual C++ Redistributable for Visual Studio 2019 here or on https://visualstudio.microsoft.com/downloads/#microsoft-visual-c-redistributable-for-visual-studio-2019
  • en a Command Prompt, execute below command and ensure that NO WARNINGS APPEAR.
    php --version
  • Create phpinfo.php file with below content in the root website folder.
    <?php phpinfo(); ?>
  • Open http://localhost/phpinfo.php URL and verify PHP information.

 

How to Run Docker on a Windows 10 Hyper-V Virtual Machine

Motivation:

You want to have an environment with Docker for development and testing  without interfering your stable machine.

Context:

You have enabled Hyper-V, created a virtual machine and install Windows 10 to the virtual machine.
When installing Docker in the virtual machine, Docker requires that the Nested Virtualization feature must be enabled for the virtual machine.
You open PowerShell, execute below command in the virtual machine:

Get-ComputerInfo -property "HyperV*"

You find that find that the HyperVRequirementVirtualizationFirmwareEnabled feature is not available.

Procedure:

1. Download this PowerShell script. The main interesting command in this script is the command below that enables Nested Virtualization for a virtual machine.

On the host machine execute below command:

Set-VMProcessor -VMName $vmName -ExposeVirtualizationExtensions $true

2. Open PowerShell as Administrator and execute 2 commands below.

Set-ExecutionPolicy -ExecutionPolicy "Unrestricted"
.\Enable-NestedVm.ps1 "Windows 10 Dev"

"Windows 10 Dev" is the virtual machine name without quotes.

3. Install Docker. Restart the virtual machine.

4. Install any additional software if needed, restart the virtual machine again.

5. Open a Command Prompt and test Docker installation.

docker pull hello-world && docker run hello-world

Rerun the command if you get an issue in the first run.

 

 

How to Enable Processor Resource Controls in Hyper-V

Context:

You got a warning message below when configuring Number of virtual processors in Hyper-V.

Hyper-V is not configured to enable processor resource controls.

Problem:

How do you enable processor resource controls in Hyper-V?

Solution:

1. What is the difference between core and logical processor?

  • A socket is a slot contains one or more mechanical components providing mechanical and electrical connections between a microprocessor and a printed circuit board (PCB). This allows for placing and replacing the central processing unit (CPU) without soldering.
  • A core is a physical processor unit (hardware component) inside your processor.
  • Logical processor or logical core is the processor as seen by the operating system. Logical processor does not exist physically.

Logical Processor = (# of Core) * (# of Thread in each Core) = 4 * 2 = 8

Example:

2. What is SMT?

Simultaneous multithreading, or SMT, is a technique utilized in modern processor designs that allows the processor’s resources to be shared by separate, independent execution threads.

Processors supporting SMT are available from both Intel and AMD. Intel refers to their SMT offerings as Intel Hyper Threading Technology, or Intel HT.

3. How does Hyper-V virtualize processors?

  • Hyper-V creates and manages virtual machine partitions, across which compute resources are allocated and shared, under control of the hypervisor. Partitions provide strong isolation boundaries between all guest virtual machines, and between guest VMs and the root partition.
  • The root partition is itself a virtual machine partition, although it has unique properties and much greater privileges than guest virtual machines. The root partition provides the management services that control all guest virtual machines, provides virtual device support for guests, and manages all device I/O for guest virtual machines. Microsoft strongly recommends not running any application workloads in the root partition.
  • Each virtual processor (VP) of the root partition is mapped 1:1 to an underlying logical processor (LP). A host VP always runs on the same underlying LP – there is no migration of the root partition’s VPs.
  • By default, the LPs on which host VPs run can also run guest VPs.
  • A guest VP may be scheduled by the hypervisor to run on any available logical processor. While the hypervisor scheduler takes care to consider temporal cache locality, NUMA topology, and many other factors when scheduling a guest VP, ultimately the VP could be scheduled on any host LP.

4. What are Hyper-V hypervisor scheduler types?

Starting with Windows Server 2016, the Hyper-V hypervisor supports several modes of scheduler logic, which determine how the hypervisor schedules virtual processors on the underlying logical processors. These scheduler types are:

  • The classic scheduler provides a fair share, preemptive round- robin scheduling model for guest virtual processors.
  • The core scheduler offers a strong security boundary for guest workload isolation, and reduced performance variability for workloads inside of VMs that are running on an SMT-enabled virtualization host.
  • The root scheduler cedes control of work scheduling to the root partition. The NT scheduler in the root partition’s OS instance manages all aspects of scheduling work to system LPs.

5. Determine your current Hyper-V Hypervisor Scheduler Type

Execute the command below.

Get-WinEvent -FilterHashTable @{ProviderName="Microsoft-Windows-Hyper-V-Hypervisor"; ID=2} -MaxEvents 1

  • 1 = Classic scheduler, SMT disabled
  • 2 = Classic scheduler
  • 3 = Core scheduler
  • 4 = Root scheduler

6. Enable processor resource controls in Hyper-V by setting Scheduler Type to Core or Classic.

  • Open a Command Prompt as Administrator.
  • Execute the command below.
C:\Windows\System32\bcdedit.exe /set hypervisorschedulertype Core

  • Restart the computer.

 

 

How to Convert MP4 or MKV File to MP3 or M4A File

Motivation:

You have downloaded some MP4 or MKV video files.

You want to extract audio parts so that you could copy them to your iPhone to listen to them while turning off the display of your phone.

Procedure:

  • Download this portable application to your Windows.
  • Unzip the files to a location.
  • Open Mp4ToMp3_64.exe.
  • Click on the Add files button to add MP4 or MKV files to the application.
  • If you want to extract the original audio (for example the M4A format) then select Try extract original audio stream option below the Audio section on the right panel.
  • Click the Convert button.
  • Copy the MP3 or M4A files to your phone.

This procedure can be used for extracting audio from M4B (Apple audiobook file format) file to M4A or MP3 file too.

 

How to Install a Clean iOS

Motivation:

You want to sell or give away your iPhone. You want to ensure that the new owner will not access any of your data.

You may also need to give your iPhone to a technician to fix the broken display of your iPhone. You want to ensure that the technician cannot access any of your data.

You may also have so many buggy applications on your iPhone and want to increase stability and performance of your iOS.

Procedure:

  • Import your Photos to a MacBook.
  • Create a backup of data. It is best to let your iPhone synchronize everything with iCloud, including Photos and Contacts.
  • Turn off Find My iPhone.
  • Plug your iPhone to a MacBook.
  • Open Finder. Click on your iPhone on the left panel.
  • Click Restore iPhone… button.
  • Click Backup button.
  • Click Restore and Update button. Click Next button. Click Agree button.
  • Follow the instructions to install a clean iOS to your iPhone.

Post Installation Configuration:

  • Setup your iPhone.
  • Activate your iPhone.
  • Setup Face ID.
  • Restore your Apps & Data from iCloud backup.
  • Synchronize music to your iPhone.
  • Go to Settings > Generals > Software Update > Automatic Updates. Turn off Automatic Updates.
  • Go to Settings > Generals > Display & Brightness > Text Size. Drag the slider to the right to increase text size.
  • Go to Settings > Messages. Enable iMessage.

How to Trim, Cut or Combine MP4 or MP3 Files Without Re-Encoding

Motivation:

  • You have MP4 files with unwanted portions. You want to trim these portions.
  • You want to cut a MP4 file into files with equivalent length for uploading to specific storage that limits length of an uploaded video.
  • You want to combine multiple MP4 files into single file for copying to specific storage in a single upload.
  • You want to trim start and end portion of MP3 file.

Trimming MP4 file:

  1. Download XMedia Recode.
  2. Unzip the downloaded package.
  3. Click on the XMedia Recode.exe file to open the application.
  4. Open a MP4 file.
  5. Under the Format tab set
    Profile = Custom
    Format = MP4
    File Extension = mp4
  6. Click the Video tab and set Mode = Copy on the middle panel.
  7. Click the Audio tab and set Mode = Copy on the middle panel.
  8. Click the Filters/Preview tab and set Start Time and to (End Time) value text boxes.
  9. Click the Add to queue button (with the + icon) on the tool bar.
  10. Click the Encode button on the tool bar.

Splitting MP4 file to multiple files with equivalent length:

    1. Download XMedia Recode.
    2. Unzip the downloaded package.
    3. Click on the XMedia Recode.exe file to open the application.
    4. Open a MP4 file.
    5. Under the Format tab set
      Profile = Custom
      Format = MP4
      File Extension = mp4
    6. Click the Video tab and set Mode = Copy on the middle panel.
    7. Click the Audio tab and set Mode = Copy on the middle panel.
    8. Click the Filters/Preview tab and specify appropriate time range for each file, for example from 00:00:00:0000 to 00:09:00:0000.
    9. Click the Add to queue button (with the + icon) on the tool bar.
    10. Click the Encode button.

    Repeat the procedure for the same file with different time ranges.

    For example use time range from 00:09:00:0000 to 00:18:00:0000 for creating the second file, then time range from 00:18:00:0000 to 00:27:00:0000 for creating the third file, etc.

    Combining multiple MP4 files into single MP4 file:

    1. Download ffmpeg.
    2. Unzip the downloaded package.
    3. Copy MP4 files to the bin folder.
    4. Create vidlist.txt with the content below in the bin folder.
    file 'Part 1.mp4'
    file 'Part 2.mp4'
    file 'Part 3.mp4'
    file 'Part 4.mp4'
    file 'Part 5.mp4'
    file 'Part 6.mp4'

    4. Open Command Prompt, navigate to the bin folder and execute the command below.

    ffmpeg -f concat -safe 0 -i vidlist.txt -c copy output.mp4

    Trimming start and end portion of MP3 file:

    1. Download ffmpeg.
    2. Unzip the downloaded package.
    3. Copy MP3 file to the bin folder.
    4. Execute the command below:
    ffmpeg -ss 671 -t 2169 -i 01.mp3 -c:a copy out_01.mp3
    # -s: start position (in seconds)
    # -t: end position (in seconds) 
    # -c:a copy: no reencoding.

     

     

    How to Put Your eBooks into Kindle or Apple Books or Google Play Books

    Motivation:

    You have an ebook with .epub or .mobi format in your MacBook or PC.
    You want to put it into your iPhone or iPAD so that you can read it on the go.

    Solution 1:

    1. Upload your ebook to iCloud Drive.
    2. Install Kindle or Apple Books or Google Play Books on your iPhone or iPAD.
    3. Login your Kindle or Apple or Google account.
    4. Open the Files app to go to iCloud Drive.
    5. Open the ebook.
    6. Tap the Share icon in the lower left hand corner.
    7. Select Kindle or Open in iBooks or Play Books.

    Solution for Google Play Books:

    1. Install Google Play Books on your iPhone or iPAD..
    2. Log in Google Play Book website using your Google account.
    3. Upload your ebook in EPUB format to Google Play Book website.
    4. Open Google Play Books on your iPhone or iPAD.