Saturday, January 20, 2018

Goodbye Ads & Viruses - Hosts file solution

Hey guys!

So today, I was watching a video and these pop-up ads would not stop firing! I mean seriously, this is ridiculous! I was clicking on 'X' buttons for like 2 solid minutes. Note: I am already using an ad-blocker in my browser!

When the content of a webpage is loading (along with the ads), the ad-blockers are using smart algorithms to prevent ads from loading (html,js,css,etc). However, advertisers are getting smart too and they actually manage to fool some ad-blockers.

The happy scenario is that you accidentally click on an advert, visit their website, close the window and then continue with your day. However, that's not the case! Most viruses, trojans & adware/spyware programs derive from those websites that you accidentally click.

What if someone could block the network call to external websites that are known to be advertisers ? If the IP of the advertiser gets blocked by the client (ie. your web browser) then the content won't be even loaded. Is there any way to do that ? Yes there is! The only way to do that is through your HOSTS file inside your Operating System.

When you are trying to visit a website, your computer is firstly scanning your HOSTS file. This file contains a map of IPs and url addresses. For example, 127.0.0.1 maps to localhost. So, when you type localhost into your browser it gets mapped to 127.0.0.1. If you add an entry in your HOSTS file that maps www.google.com to 1.2.3.4, this means that when you try to type www.google.com in your browser, it will try to make a call to the IP 1.2.3.4 instead of the Google's one (that gets mapped from the DNS in the internet). This is the easiest way to control the traffic of your computer. My school tried to do that, but I found my way around it :D

If we had all the IP addresses of the most known advertisers and map them to our local IP (127.0.0.1 or 0.0.0.0) then their ads would never be loaded, because the calls to their websites would be re-routed into our computer, without traveling the web, without asking for their real IP! Ok, that's cool, but is it a realistic scenario ? How can you even collect all the IPs of the most known advertisers ? There are so many that someone must dedicate lots of time and effort to track them ! Is there anyone who did that ?

Well guess what! There are some people that are tracking advertisers. It's an on-going process, where people collect unwanted IPs. They created a HOSTS file (Note: they try to keep it up to date) that maps the unwanted IPs to your computer (127.0.0.1 or 0.0.0.0).

Their website is https://winhelp2002.mvps.org/hosts.htm! There you can find more information on how to import the HOSTS file into your operating system and get a full explanation of what they are doing and what you can achieve by using it. Cheers to these guys!


Tuesday, January 9, 2018

Maven Dependency to WAR module

So today, I had to create a new project, which was needed to have a dependency on another internal WAR module. 

The way to do that, is through the WAR module itself.

In the build tag, inside my WAR pom, under plugins I added:

<plugin>
   <artifactId>maven-war-plugin</artifactId>
   <version>2.1-beta-1</version>
   <configuration>
       <attachClasses>true</attachClasses>
   </configuration>
 </plugin>

When deploying your WAR module, the above plugin creates a JAR file with all the classes of your project (along with your WAR). This JAR will be accessible to your new project. In my case, I am deploying in an internal repository server (Apache Archiva). Bellow you can see the contents of my module directory inside Apache Archiva after deploying.

 
WAR module - Apache Archiva directory
WAR module - Apache Archiva directory


In the POM of my new project under the dependencies tag, I added the dependency to my WAR module as seen bellow:

<dependency>
   <groupId>${project.groupId}</groupId>
   <artifactId>e-receipt-api</artifactId>
   <version>1.2</version>
   <classifier>classes</classifier>
 </dependency>

The above code snippet resulted to including the produced JAR file with its classes.

Saturday, December 30, 2017

Sql Server Management Studio - Column names retrieval

One of the most common things that I do in Sql Server Management Studio, is to get all the column names from a certain table. To achieve that I navigate through the Object Explorer, select my desired table and then script its create statement. I have to admit its quite annoying and I have been doing this since... forever actually.

So, today while I was staring at the screen, I kinda played with the mouse dragging & dropping stuff from the Object Explorer to the Query Window and to my amazement I had accomplished the impossible. I had all the column names in my query window without any effort! Who could imagine that you can simply drag and drop the Columns folder of a certain table into the Query Window and voila! You can now have all column names without cutting and pasting from create statements scripts, etc. 



Rethinking the whole process, it seems very obvious as an action. However, I never thought that it could work and neither did my colleagues :D.

Did you know that you could do that in Sql Server Management Studio ? Do you have any tricks & trips you would like to share ?