The Curly Braces Abijeet Patro

Disinfecting a Windows 8.1 machine

So last weekend my sister came to me with a slow performing Windows 8.1 Acer laptop. She wanted me to format it and install a new copy of Windows 8.1.

I've been using Debian for the last 3 years. Previously I was dual booting between Windows and Debian in-order to play DOTA 2 with my friends, but since Valve released DOTA 2 on Linux, I've had little reason to open my Windows installation. As you'd expect I didn't have a Windows 8.1 setup disc or ISO lying around. I debated whether to shift her to a clean KDE based Debian machine and she agreed as long as her desktop looked nice but I soon changed my mind when I saw the software she was using -

  1. Cyberlink PowerDirector Pro
  2. Cyberlink PhotoDirector
  3. Bunch of free games

I'm sure I'd be able to find alternatives for the above, but it'd be too much of a learning curve for her, plus setting up a KDE machine from scratch would take some time.

I decided to investigate the reason for slowness, and possibly fix the problem itself. Upon further discussion with her, I found out that the laptop was not only slow, but was infected with some sort of a malware. She was getting permission errors while opening certain folders, and a lot of the folders were hidden.

I've been using Linux as my primary OS for the past 4 years, and haven't had to worry about this sort of a problem. Even so, cleaning up the system was quite simple. This blog gives an outline of the steps I followed to do so.

  1. Stop unwanted and suspicious running processes
  2. Remove unwanted startup programs
  3. Remove other antivirus
  4. Remove unnecessary and suspicious software
  5. Cleaning up trouble some software
  6. Remove unnecessary Chrome extensions
  7. Update Windows
  8. Reactivate Windows security features
  9. Full scan via Windows defender
  10. Windows proxy

Stop unwanted and suspicious running processes

First step is to find out what programs / processes are running that shouldn't be. The Windows task manager is a good place to start looking.

Kill dangerous processes

Kill dangerous services

Somethings will shout out - I don't belong here. Other's might not be so obvious. If something seems suspicious but you're not sure if its needed, just Google the process name and you should have your answer.

You want to do this first because certain applications / processes will detect that you're uninstalling them and then perform some malicious action.

Remove unwanted startup programs

I used services.msc to determine which services were running. Going through the description of the service will likely give you enough information on whether the service is needed.

You can start services.msc by,

  1. Press Windows Key + R on your Windows desktop.
  2. Type services.msc
  3. Press enter

Disable the dangerous services

While I was here, I removed the various services related to the anti-virus applications that my sister had tried to install. In addition, whatever suspicious processes I had stopped earlier, I tried to find any services related to those.

Remove other antivirus

The gut reaction of a person who knows that they have been infected by virus or a malware is to install an antivirus and try to get rid of the problem. And if the first one doesn't work, we try it with another one.

When I got my sister's laptop, she had a couple of anti-viruses installed - Kaspersky, and Avast. Avast was fairly simple to remove via Windows Add / Remove program, but I was having troubles removing Kaspersky. During uninstall Kaspersky would tell me that I did not have enough privileges to uninstall the application.

Eventually I got rid of it by using the Kaspersky removal tool.

Remove unnecessary and suspicious software

This was a little painful to do since Windows does not allow you to uninstall multiple applications at once.

I uninstalled all the applications that I'd disabled earlier, one by one. Almost all of them were fairly straight forward to uninstall. I'll be discussing the one that was not so easy to uninstall below.

Cleaning up troublesome software

MPC Cleaner gave me a hard time. There was no uninstaller for it in the Windows Add / Remove program and the install directory did not have an uninstaller either.

It doesn't turn out to be a harmful program, but it is clearly an unwanted software that doesn't want to get uninstalled.

Googling around revealed that you've to boot your system into safe mode and then remove it. That's just too much work. The other way to remove it was to install AdwCleaner.

This is the approach I followed. In addition to removing MPC Cleaner, I removed browser cookies, local cache and history using AdwCleaner

Disinfecting using AdwCleaner

Remove unnecessary Chrome extensions

Next I tackled the browser, and removed all unnecessary extensions installed. AdwCleaner also helped remove unnecessary toolbars and a homepage that had been added to Chrome. This step was quite easy and went without any hiccups.

This process will defer if you are using a different browser but AdwCleaner support other popular browsers like Internet Explorer and Firefox as well.

Update Windows

I then updated Windows. I selected all the important updates, and downloaded latest definitions for Windows Defender. This took quite some time but went without any issues.

Reactivated Windows security features

I personally feel that Windows built in firewall and Defender are together good enough to handle any average users security needs. Hence I went ahead and activated these. These had been disabled by the previous antivirus software that my sister had installed.

Full scan via Windows Defender

So now that we had an updated version of Windows Defender, I ran a full system scan. Please note that this will take quite some time so feel free to go do your thing while Windows Defender does its.

Windows proxy

After the scan had been done, everything was looking good. No more permission issues, no more slowness but we were still having issues connecting to the Internet intermittently. I checked the proxy settings for Windows and for some reason found this there - http://unstops.net/wpad.dat. Apparently this is a browser hijacker and shows users ads and redirects their browser session. Removing this resolved the Internet connectivity issues.


The points mentioned here although run on a Windows 8.1 machine, are applicable to other versions of Windows too. The entire process took less than 2 hours of my time, out of which removing the unwanted software one by one took the longest. Most of the stuff happened in the background, without much of my intervention. I'm glad I went down this route rather than formatting the entire system. It was less work, and everything was still setup exactly the way it was earlier.

I had a chat with my sister and asked her not to install any more performance improving software. I also asked her to read carefully before pressing the next button while installing new software. Staying clean on a Windows machine is quite easy if you keep it up to date with security updates, have Windows firewall on and Defender running.

Renewing Let's Encrypt certificate

Have the following command setup in my crontab to renew the certificate for this blog, and for the main website - thecurlybraces.com

30 3 1 */2 *  /opt/letsencrypt/certbot-auto renew --pre-hook "service nginx stop" --post-hook "service nginx start"  

This causes the command to run,

At 03:30 on day-of-month 1 in every 2nd month.

Output

Upgrading certbot-auto 0.12.0 to 0.14.1...  
Replacing certbot-auto...  
Creating virtual environment...  
Installing Python packages...  
Installation succeeded.  
Saving debug log to /var/log/letsencrypt/letsencrypt.log

-------------------------------------------------------------------------------
Processing /etc/letsencrypt/renewal/thecurlybraces.com.conf  
-------------------------------------------------------------------------------
Cert is due for renewal, auto-renewing...  
Running pre-hook command: service nginx stop  
Renewing an existing certificate  
Performing the following challenges:  
http-01 challenge for thecurlybraces.com  
http-01 challenge for blog.thecurlybraces.com  
Waiting for verification...  
Cleaning up challenges

-------------------------------------------------------------------------------
new certificate deployed without reload, fullchain is  
/etc/letsencrypt/live/thecurlybraces.com/fullchain.pem
-------------------------------------------------------------------------------

Congratulations, all renewals succeeded. The following certs have been renewed:  
  /etc/letsencrypt/live/thecurlybraces.com/fullchain.pem (success)
Running post-hook command: service nginx start  

Just putting this here for reference, and with the hope that it might be useful for someone else.

Setting up a website using Ghost on Debian

My web hosting's annual payment date was drawing close, and instead of renewing it, I decided I'd rent a server on Digital Ocean for 10$ a month. It turns out to be a lot more expensive but gives me the option to use the server for something other than just blogging and running PHP application.

After shifting to this new server, the first thing to do was to migrate my blog here. WordPress is an amazing platform, but over the years it has evolved to something a lot more than just a blogging tool. Besides the new kid on the block - Ghost, was creating a lot of buzz for its simplicity. I wanted to give it a try.

I setup my Digital Ocean server with Debian (Jessie 8.2). Node.js is required to run Ghost. Since I wanted to use this server for multiple applications, I decided I'd put nginx as a front facing proxy/compression server.

This blog item is a guide for setting up Ghost on a server running Debian. Let's start,

Setting up the server

After logging onto the server for the first time, I noticed that sudo was missing, so this was the first thing to do.

apt-get install sudo  

Next, I decided to create a normal sudo user to do my work as, working as the root user at all times is probably not the best idea.

adduser --shell /bin/bash --gecos 'Primary account' abijeet  
usermod -aG sudo abijeet  
su abijeet  

I then proceeded to install nginx-light since the features in it sufficed my needs.

sudo apt-get install nginx-light  

I decided to build the Node.js source and for this, I needed g++ and make

sudo apt-get install g++ make  

I then grabbed the Node.js source from their website, and proceeded to build it. Do note that this approach does take a while, for me it took about 30 minutes. Ghost.js recommends that we use the LTS version of Node.js

wget https://nodejs.org/dist/v4.2.4/node-v4.2.4.tar.xz  
tar xf node*  
cd node-v4.2.4  
./configure
make  
make install  

Ok, so that's the base setup done, let's now setup Ghost.

Setting up Ghost

Let's first grab Ghost from their website

wget https://ghost.org/zip/ghost-0.7.5.zip  

We'll need to install unzip to run Ghost.

sudo apt-get install unzip  
unzip ghost-0.7.5.zip -d www.mywebsite.com  

Then move the whole extracted folder to the /var/www/html folder where web applications are traditionally kept.

mv www.mywebsite.com /var/www/html/  

Running your Node.js application as a root user is generally a bad idea. If your website gets hacked, the hacker will have root access to your machine. We'll create a system user that will run just our website. We will then shift to that user to work with our website. For our guide purpose, let's name the user as website-user

sudo adduser --shell /bin/bash --gecos 'Website user' website-user

# Give ownership of the website's folder to the user.
sudo chown -R website-user:website-user /var/www/html/www.mywebsite.com  
su website-user   # Start using that user.  
cd /var/www/html/www.mywebsite.com  

Install the modules that Ghost needs to run in production mode.

npm install --production  

Start and then stop the server, so that it creates a base config.js file that we will then tweak.

npm start  
# The type Ctrl + C to stop the server

Ok, time to make modifications to the config.js file. The following needs to be modified -

  • Set the url to http://www.mywebsite.com
  • Under connection, set filename to www.mywebsite.com.db
  • Under server, set the host as 127.0.0.1
  • Under server, set the port as 3001
  • Turn off gzipping, set compress as false. We'll set it up using nginx later.

Change the website-user's .profile file and add the following at the end of it to run Ghost in production mode. This file is usually in the home directory of the user.

nano ~/.profile  

then,

export NODE_ENV=production  

Now change to the sudo user (abijeet) that we had added initially and install pm2. We'll use pm2 to monitor our app, and restart it in case of a crash.

su abijeet  
sudo npm install -g pm2  
# pm2 installed, go back to the website-user
su website-user  

Start running the server using pm2

cd /var/www/html/www.mywebsite.com  
pm2 start index.js --name "website name"  

Finally, we'll instruct pm2 to restart the Ghost application whenever the server is restarted.

sudo env PATH=$PATH:/usr/local/bin pm2 startup ubuntu -u website-user  

Next, its time to setup routing and compression on nginx.

Setting up nginx

Create a file under /etc/nginx/sites-available

su abijeet  
sudo nano /etc/nginx/sites-available/www.mywebsite.com  

Put the following content in the file,

server {  
  listen 80;
  server_name www.mywebsite.com;
  location / {
      proxy_set_header   X-Real-IP $remote_addr;
      proxy_set_header   Host      $http_host;
      proxy_pass         http://127.0.0.1:3001; # This should match the port where the Ghost server is running.

  }
}

Create a symbolic link to this file under /etc/nginx/sites-enabled.

sudo ln -s /etc/nginx/sites-available/www.mywebsite.com /etc/nginx/sites-enabled/www.mywebsite.com  

Remember to remove the default file present under /etc/nginx/sites-enabled/ and /etc/nginx/sites-available/.

Turn on gzipping for nginx. The following goes into the /etc/nginx/nginx.conf

# Turning on gzip.
gzip on;  
gzip_proxied any;  
gzip_min_length  1000;  
gzip_types text/plain text/css application/json application/x-javascript text/xml application/xml application/xml+rss text/javascript;  
gzip_vary on;  
gzip_comp_level 6;  

This section might already be present under the nginx.conf file, so search before you add it.

Also add the following to nginx, to prevent it from sending the version number in HTTP response headers.

server_token:off  

Alright, once all that is done, time to restart nginx. But first we'll check the configurations.

nginx -t  
# If all is good, restart nginx
nginx -s reload  

We're done. Type in the URL of your website in a browser, and you should see Ghost's startup page.

Migration over

Hi all, I'm migrating my blog to Ghost and all the old content will be back within a very short time. Stay tuned!

Update (2016-01-17)

Migration over.

My tools on Linux

Update 2016-01-16

Development of Crunchbang has now stopped. There are a few community spin-offs available, Bunsen Labs and Crunchbang++. I'm now using a netinst version of Debian at home with the i3 window manager, and Bunsen Labs on my office laptop. Both are working well. I'm still using the same set of software for my work, in addition to a few more, so this post is still valid.


I've been using Linux at home and work for over 5 months now. I'm using a Debian based distribution called Crunchbang. Over these past few months I've developed/programmed using multiple technologies and have gathered a collection of tools, that I use on a daily basis.

Name Type Link
Eclipse with NodeEclipse - Check Update IDE for Node.js Link
Netbeans IDE for PHP Link
Dbeaver GUI client for Cassandra and others Link
MySQL Workbench MySQL/MariaDB GUI client Link
Dia Flowchart and Diagrams Link
SoapUI Testing - API and Web Services Link
Tilda Drop down terminal Link
Meld Mergetool Link
Remmina GTK RDP Client Link
Tomboy Note Taking App Link
GMTP MTP Client Link
GIMP Image manipulation Link

Integrated Development Environment

Eclipse

Update 2015-10-23 - I'm now using VSCode to develop Node.JS applications.

Linkhttps://eclipse.org/kepler/
Used for Node.JS. Cross Platform.

For Node.JS, Eclipse with Eclipse Web Tools Platform, EGit and the NodeEclipse plugin work quite well. It supports debugging although you don't have a Visual Studio esque Immediate Window. I'm using EJS as my templating language and with a little configuration I was able to set up Eclipse to highlight an EJS file as an HTML file.

I'm also using the AngularJS Eclipse plugin for my frontend development.

The UI organization in Eclipse is very good. If you are new to Eclipse, you can save yourself some headache by learning about Perspectives.

Netbeans

Linkhttps://netbeans.org/features/php/
Used for PHP, Cross platform.

For PHP, Netbeans takes the cake. It comes pre-installed with a PHP debugger which can be easily configured by modifying your php.ini file. In addition it has support for Git and SVN out of the box (requires plugins but they come preinstalled). I've added support for AngularJS via a plugin. There isn't much configuration to talk about when it comes to Netbeans, so I'll just leave a few images that should help you setup debugging. I would have liked to use Netbeans for NodeJS as well, but the NodeJS plugin doesn't seem to be actively maintained. I'll probably revisit it again in the future.

Database

Dbeaver

Link - http://dbeaver.jkiss.org/
For wide variety of databases. Cross platform.

For one of my recent projects, I've had to work with Cassandra and MariaDB. Dbeaver is a no - nonsense tool that allows me to work with both. The UI is similar to Eclipse (lacks Perspectives). In addition to MariaSQL/MySQL and Cassandra, dbeaver also supports a ton of other database systems.

MySQL WorkBench

Linkhttp://www.mysql.com/products/workbench/
Cross platform.

For more advanced stuff related to MariaDB/MySQL I prefer to use MySQLWorkbench. I use it to manage users and permissions. Managing import/export, database configurations is also quite easy. I've also used it to generate beautiful schema diagrams.

Flowchart and Diagrams

Dia

Link - http://dia-installer.de/
Cross platform.

Drawing flowcharts and other diagrams is easy with Dia. It isn't the prettiest looking software, but it gets the job done. It creates diagrams in the .dia format but these can then be exported into various formats such as transperent PNG and SVG.

Testing

SoapUI

Link - http://www.soapui.org/
Cross platform.

SoapUI is an API testing tool. I use SoapUI to look at responses from a third party Web Services (both SOAP based or REST). In addition, I also use it to test and load test my REST based APIs and Web Services. You can setup test cases and run these after every deployment.

Here's a video that will help you get started.

Miscelleanous

Tilda

Link - https://github.com/lanoxx/tilda
Type - Dropdown Terminal
Linux and Unix only

Tilda is an awesome GTK based dropdown terminal. I have it hooked to the F1 key on my keyboard. Whenever I want to run a quick command, I hit the F1 key and out pops the terminal. You can even open multiple tabs inside it. You can change it's height and width, transperency levels, animation, font, color schemes among other stuff.

Meld

Linkhttp://meldmerge.org/
Type - Merge-tool
Cross platform

Meld is a merge-tool that I use with Git and SVN. It supports three way merging but that requires a bit of tweaking. Meld can also be used to compare files that are not a part of a versioning system.

It has a help guide and this video should get you started.

Remmina

Linkhttp://remmina.sourceforge.net/
Type - Remote Desktop Client
Cross Platform

I use Remmina to connect to my PC at work, and other Windows systems to test my web applications on a Windows platform and Internet Explorer. It's easy to setup and use. I would urge Windows user to check this software out since it adds some more features on top of the vanilla mstsc application.

Check it out here.

Tomboy

Linkhttps://wiki.gnome.org/Apps/Tomboy
Type - Note taking application.
Cross Platform

Tomboy is a pretty amazing note taking app. I use it along with Dropbox to sync notes between work and home. You can link notes together and notes can be categorized into notebooks. It supports some amount of formatting as well (bold, italics, underline, font size and such). There is also an Android version of the app, but I had trouble getting it to sync with my PC notes via Dropbox.

There are a couple of things I'd like to have though.

  1. Save certain notebooks in a different location so I can avoid syncing all my notes to my office PC.
  2. Markdown support.

GMTP

Linkhttp://gmtp.sourceforge.net/index.html
Type - MTP Client
Linux and Unix only

When you search on Google, you'll find a lot of people complaining about their Nexus 7's not being detected on Linux.  It uses libmtp and allows transfer to and from media devices. It's not very stable, and you have to be "gentle" when you use it,  but it gets the job done.

GIMP

Linkhttp://www.gimp.org/
Type - Image manipulation
Cross Platform

I'm mainly a programmer, so I don't do much image editing but for times when I do need an image editing application, GIMP works well. It's got a slight learning curve, but it comes with the benefit that I can do more "advanced" stuff with it, without having to move to another app. If you are looking for something simpler and more like Windows Paint, I'd recommend giving Pinta a try.

That's it for now. I hope to keep making more posts of this kind as time passes by and I gain more experience with Linux. I'm sure I'll have many more things to share/catalog in the future.

Older Posts