RN-QQHFzQYtPGkUCfyu8eve2qf0

Wednesday, 13 August 2014

Reading Wifite Source : Coding Hacking Tools In Python

0 comments


Today I have a series of tasks for those who want to go a step further and write tools and scripts for others. In this tutorial we will take a look at the source code of Wifite and examine it to see how we can also create our own tools. There are various programming/scripting languages that can be used to accomplish the tasks. Wifite uses python, and that's what we'll start with.



Tasks

  1. Get some basic idea about Python - Take a look here - http://www.codecademy.com/en/tracks/python
  2. Get an idea about GNU General Public License - A good resource here or just take a look at wifite's license terms (optional step but if you're using Linux then it's important to know that the foundation of Linux is on concept of open source software and GNU GPL.
  3. Get a general idea about linux scripting. Use google for that. A comprehensive guide can be found here.
  4. Finally, take a look at the source code of Wifite (it's worth noting that the source code is available openly on because of the fact the it has GNU general public license). 
It's important that you follow the first three steps. The tutorial is about the codes which are important for any hacking tool. I don't cover everything. After reading this tutorial you'll know about the mandatory sections in any hacking tool. If you leave the first three steps (the 4th step is covered by me in this tutorial), then  you won't be able to code your hacking tool.



The wifite code

Now, a few thing which you will observe about Wifite-
  1. It is written in Python.
  2. It is licensed under the GNU General Public License Version 2 (GNU GPL v2).
  3. It is written by Derv Merkler.
  4. The source is quite well documented and easy to read.
Now lets take a look at the source in parts


#!/usr/bin/python

The #! is always going to be the first two letters of any script in linux. It tells linux to treat the code that follows as executable. The next words tell what the scripting language is, for example-
#!/usr/bin/php    for php
#!/usr/bin/perl    for perl
#!/usr/bin/python    for python
#!/bin/bash             for bash scripting
This part is called a shebang.





# -*- coding: utf-8 -*-

This is specific to python. Python recommends that we define the encoding that we'll be using. Take a look here if you need to know more about this - http://legacy.python.org/dev/peps/pep-0263/


General information

A lot of general information and to-do stuff has been written inside a comment. Take a read if you like.

After that there's a list of libraries that were imported. (Quite similar to other languages)
Then all the global variables have been declared. To enhance readability, all the global variables are CAPITAL.

Conditions

At a lot of places conditional statements are used to ensure correct functionality and also that all requirements are met before starting
if os.getuid() != 0:
        print R+' [!]'+O+' ERROR:'+G+' wifite'+O+' must be run as '+R+'root'+W
        print R+' [!]'+O+' login as root ('+W+'su root'+O+') or try '+W+'sudo ./wifite.py'+W
        exit(1)

if not os.uname()[0].startswith("Linux") and not 'Darwin' in os.uname()[0]: # OSX support, 'cause why not?
        print O+' [!]'+R+' WARNING:'+G+' wifite'+W+' must be run on '+O+'linux'+W
        exit(1)
The getuid returns the privilege. If it's not root (0), then wifite returns error and exits. The OS has to be linux.

This code ensures that the output of all the tools doesn't get printed to the wifite screen.

# Create temporary directory to work in
from tempfile import mkdtemp
temp = mkdtemp(prefix='wifite')
if not temp.endswith(os.sep):
        temp += os.sep

# /dev/null, send output from programs so they don't print to screen.
DN = open(os.devnull, 'w')


This is followed by 

###################
# DATA STRUCTURES #
###################

class CapFile:
        """
                Holds data about an access point's .cap file, including AP's ESSID & BSSID.
        """
        def __init__(self, filename, ssid, bssid):
                self.filename = filename
                self.ssid = ssid
                self.bssid = bssid

class Target:
        """
                Holds data for a Target (aka Access Point aka Router)
        """
        def __init__(self, bssid, power, data, channel, encryption, ssid):
                self.bssid = bssid
                self.power = power
                self.data  = data
                self.channel = channel
                self.encryption = encryption
                self.ssid = ssid
                self.wps = False # Default to non-WPS-enabled router.
                self.key = ''

class Client:
        """
                Holds data for a Client (device connected to Access Point/Router)
        """
        def __init__(self, bssid, station, power):
                self.bssid   = bssid
                self.station = station
                self.power   = power


The purpose of the classes is already stated by the author in comments (green).
##################
# MAIN FUNCTIONS #
##################

def main():
        """
                Where the magic happens.
        """

We will have to skim through a lot of code here. Can't cover everything. Some of the code that's easy to understand is shown and explained here.

Checking for the required tools

Wifite does not work independently and uses a lot of tools. For this, the following code is used which checks whether the required programs are installed. It uses conditional statements (if) and looping (for loop). If a program is not found, a prompt is crated. All the aircrack-ng suite tools are clubbed together in one condition, then there's a conditional statement for reaver. If aircrack-ng is not found, the program exits. However, Reaver's absence results in disabling of WPS attack mode only. Then there's code for checking the presense of Pyrit, Cowpatty and tshark. They are optional.

def initial_check():
        """
                Ensures required programs are installed.
        """
        global WPS_DISABLE
        airs = ['aircrack-ng', 'airodump-ng', 'aireplay-ng', 'airmon-ng', 'packetforge-ng']
        for air in airs:
                if program_exists(air): continue
                print R+' [!]'+O+' required program not found: %s' % (R+air+W)
                print R+' [!]'+O+' this program is bundled with the aircrack-ng suite:'+W
                print R+' [!]'+O+'        '+C+'http://www.aircrack-ng.org/'+W
                print R+' [!]'+O+' or: '+W+'sudo apt-get install aircrack-ng\n'+W
                exit_gracefully(1)
       
        if not program_exists('iw'):
                print R+' [!]'+O+' airmon-ng requires the program %s\n' % (R+'iw'+W)
                exit_gracefully(1)
       
        printed = False
        # Check reaver
        if not program_exists('reaver'):
                printed = True
                print R+' [!]'+O+' the program '+R+'reaver'+O+' is required for WPS attacks'+W
                print R+'    '+O+'   available at '+C+'http://code.google.com/p/reaver-wps'+W
                WPS_DISABLE = True
        elif not program_exists('walsh') and not program_exists('wash'):
                printed = True
                print R+' [!]'+O+' reaver\'s scanning tool '+R+'walsh'+O+' (or '+R+'wash'+O+') was not found'+W
                print R+' [!]'+O+' please re-install reaver or install walsh/wash separately'+W

        # Check handshake-checking apps
        recs = ['tshark', 'pyrit', 'cowpatty']
        for rec in recs:
                if program_exists(rec): continue
                printed = True
                print R+' [!]'+O+' the program %s is not required, but is recommended%s' % (R+rec+O, W)
        if printed: print ''    

Exiting when ctrl+c is pressed

        except KeyboardInterrupt:
                print '\n '+R+'(^C)'+O+' interrupted\n'
                exit_gracefully(0)
Also, it is necessary to define the exit_gracefully function at a later stage-

def exit_gracefully(code=0):
        """
                We may exit the program at any time.
                We want to remove the temp folder and any files contained within it.
                Removes the temp files/folder and exists with error code "code".
        """
        # Remove temp files and folder
        if os.path.exists(temp):
                for file in os.listdir(temp):
                        os.remove(temp + file)
                os.rmdir(temp)
        # Disable monitor mode if enabled by us
        disable_monitor_mode()
        # Change MAC address back if spoofed
        mac_change_back()
        print GR+" [+]"+W+" quitting" # wifite will now exit"
        print ''
        # GTFO
        exit(code)

This code makes the program exit properly (i.e. clean every file it created and changes it made, and disable monitor mode) when ctrl+c is pressed. Take a look at the following resources for information about except here-

Conclusion


We now know the basics that we need. It's quite impractical to explain the whole code here. The important part is knowing that the code does the following things-
  1. Starts with the shebang
  2. (Optional) Specify the encoding
  3. Add some comments about the author and licensing stuff
  4. Add important conditions, i.e., whether or not root privileges are available (unless they aren't required to execute your code), and whether the code is executed on a linux environment.
  5. Also check that the programs used by your script are installed in the OS.
  6. Define the required classes to organize data and functioning.
  7. Ensure that your programs exits properly when ctrl+c is pressed.
  8. Do the main coding (depends on what you are making).
It might be worth noting here that we just covered some basics here, which would be common to most tools. With this knowledge you can easily code your own tools.

Tuesday, 5 August 2014

How To Whiten Your Teeth At Home In 2 Minutes

0 comments
Top 3 Methods ( ✔ Verified by Dentists) To Whiten Your Teeth At Home.White Your Teeth Naturally In 2 Minutes(Works 100%).

  ☞ How To Whiten Your Teeth At Home In 2 Minutes ☜



Share this video:-

http://youtu.be/obkxZcuXDg8

☺Method 1:- Whiten Your Teeth With Hydrogen Peroxide.

➫ How to Whiten Your Teeth At Home

☺Method 2:- Whiten Your Teeth With Baking Soda.

➫ How to Whiten Your Teeth At Home

☺Method 3:- Whiten Your Teeth With Lime † Baking Soda.

➫ How to Whiten Your Teeth At Home


Watch The Video:-


Links:-
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~­~~~~~~~~~~­~~~~~~~~
http://facebook.com/suraj.p...
http://instagram.com/canugod
http://itstrickszone.blogsp...
http://youtube.com/jptv1dz

Make You Android Fast By 10x:- https://www.youtube.com/wat...

Speed up youtube videos:- https://www.youtube.com/wat......

Speed up your google chrome:- https://www.youtube.com/wat......

Thank you http://www.ravenprodesign.com/ for intro...

How To Whiten Your Teeth At Home In 2 Minutes


More Tags:- How to Have Natural White Teeth In 3 minutes
                  How to get really white teeth
                  How to whiten teeth for free
                  How to get white teeth
                  How To Whiten Your Teeth At Home In 2 Minutes

Wednesday, 16 July 2014

Tutorial on Hacking With Kali Linux

0 comments

Hacking With Kali Linux


Why Kali Linux?


With Kali Linux, hacking becomes much easier since you have all the tools (more than 300 pre-installed tools) you are probably ever gonna need. Others can be downloaded easily. Now this tutorial will get you started and you'll be hacking with Kali Linux before you know it.




The problem with beginners

Now, I've been dealing with beginners since a long time. What they want is magic. A tool which is easy to use, works on Windows, can be download by searching on Google and clicking on the first link we see, and will do all the hacking itself on the push of a button. Sadly, no such tool exists. Hacking is an art, and it takes years of practice to master it. So how to get started? Having no idea about hacking is okay, but being a newbie with computers in general is not allowed. When I say beginner, I mean someone who has no experience with programming and with hacking methodologies. I didn't mean someone who needs a 1 page guide on how to download a tool. If you want to be a hacker, you have to work hard. So how to get started? If you have installed Kali Linux,  click here to skip past the installation paragraphs and go to hacking section of this post)






Getting Started

Now, I am not boring you with theory (^ As if all this wasn't enough theory). My aim is to get you to the point where you can start hacking with Kali Linux as soon as possible. What I'm gonna do is tell you what to do. The process is rather simple :-


Things get tough now

If you have no previous experience with Linux and virtual machines and all that stuff, getting Kali Linux up and running won't be a piece of cake.You have 2 options :


1. Read the Kali official documentation

That will give you an idea about what is a virtual machine, how OS can be run from USB, and how to create a partition and run 2 OS simultaneously. This is what I recommend. For that, go to Kali Official Documentation . 

2. Read my modified version of Kali documentation

The second option is to look at these posts, which are just sparingly modified versions of the Kali docs, and offer no advantage other than saving your time as their documentations cover much more than what the ones here do, and you don't really need to know all so much... yet. I'm linking them up here:



    Command Line Interface

    Some bash commands
    Now, if you are really sure about becoming a hacker, you have to get used to linux, and specifically the command line interface. It is often compared to (and rightly so) to command prompt of Windows, but Linux' cli is much efficient and better than command prompt. What you have to do is do all the usual tasks you do in Windows in cli of Linux. Use cd to navigate, poweroff to shutdown, etc.
    A pretty awesome site for that is - http://linuxcommand.org/
    Going through the complete site is on its own enough exercise to keep you occupied for a month, but you can proceed gradually. The first few tutorials here will keep in mind that you don't have much info about cli, and will be really beginner friendly.



      Some Useful Commands:

      If you don't plan on learning all of linux cli commands, here are a few that will keep your boat afloat.
      1. The default username and password is 'root' and 'toor'. 
      2. Type 'poweroff' in the terminal to shutdown. 
      3. apt-get command can be used to install tools and updates. 
      4. apt-get update and apt-get upgrade will update all the programs installed on your machine. 
      5. apt-get dist-upgrade will install the latest distribution of Kali(i.e. it upgrades your OS).

      PS : Tapping <tab> while typing makes Kali complete the word for you . Double tapping <tab> makes it display all possible words starting with the incomplete word. Ctrl+c stops the functioning of any tool that is running. Pressing the up arrow key shows the command you last typed.


      Some Real Hacking With Kali Linux

      Assuming you've gone through the above steps and are comfortable with your new hacking environment, its time to do some real hacking with Kali Linux. My recommendation would be to start by hacking a wifi, then do some penetration testing, and maybe read something on Denial of Service when you have free time. Links here-

      Hack wireless networks in Kali Linux using aircrack 

      Penetration Testing In Kali For Beginners

      Denial Of Service Attacks



        Monday, 14 July 2014

        Evil Twin Tutorial

        0 comments

        Prerequisites

        1. Kali Linux
        2. Prior experience with wireless hacking
        You will also need to install a tool (bridge utils) which doesn't come pre-installed in Kali. No big deal-
        apt-get install bridge-utils

        Objectives

        The whole process can be broken down into the following steps-
        1. Finding out about the access point (AP) you want to imitate, and then actually imitating it (i.e. creating another access point with the same SSID and everything). We'll use airmon-ng for finding necessary info about the network, and airbase-ng to create it's twin.
        2. Forcing the client to disconnect from the real AP and connecting to yours. We'll use aireplay-ng to deauthenticate the client, and strong signal strength to make it connect to our network.
        3. Making sure the client doesn't notice that he connected to a fake AP. That basically means that we have to provide internet access to our client after he has connected to the fake wireless network. For that we will need to have internet access ourselves, which can be routed to out client.
        4. Have fun - monitor traffic from the client, maybe hack into his computer using metasploit. 
        PS: The first 3 are primary objectives, the last one is optional and not a part of evil twin attack as such. It is rather a man in the middle attack. Picture credits : firewalls.com


        Information Gathering - airmon-ng

        To see available wireless interfaces-
        iwconfig



        To start monitor mode on the available wireless interface (say wlan0)-
        airmon-ng start wlan0
        To capture packets from the air on monitor mode interface (mon0)
         airodump-ng mon0
         After about 30-40 seconds, press ctrl+c and leave the terminal as is. Open a new terminal.


        Creating the twin

        Now we will use airbase-ng to create the twin network of one of the networks that showed up in the airodump-ng list. Remember, you need to have a client connected to the network (this client will be forced to disconnect from that network and connect to ours), so choose the network accordingly. Now after you have selected the network, take a note of it's ESSID and BSSID. Replace them in given code-

        airbase-ng -a <BSSID here> --essid <ESSID here> -c <channel here> <interface name>
        If you face any problems, a shorter code will be-
        airbase-ng --essid <name of network> mon0 
        Remove the angular brackets (< & >) and choose any channel that you want. Also, the BSSID can be randomly selected too, and doesn't have to match with the target. The interface would be mon0 (or whatever is the card you want to use) . The only thing identical about the twins has to be their ESSIDs (which is the name of the network). However, it is better to keep all parameters same to make it look more real. After you are done entering the parameters and running the command, you'll see that airbase turned your wireless adapter into an access point.
        Note : We will need to provide internet access to our client at a later stage. Make sure you have a method of connecting to the net other than wireless internet, because your card will be busy acting like an AP, and won't be able to provide you with internet connectivity. So, either you need another card, or broadband/ADSL/3G/4G/2G internet.

        Man in the middle attack : Pic Credits:  owasp.net

        Telling the client to get lost

        Now we have to ask the client to disconnect from that AP. Our twin won't work if the client is connected to the other network. We need to force it to disconnect from the real network and connect to the twin.
        For this, the first part is to force it to disconnect. Aireplay will do that for us-
        aireplay-ng --deauth 0 -a <BSSID> mon0 --ignore-negative-one


        The 0 species the time internal at which to send the deauth request. 0 means extremely fast, 1 would mean send a packet every 1 seconds, 2 would mean a packet every 2 seconds, and so on. If you keep it as 0, then your client would be disconnected in a matter of seconds, so fire up the command, and press ctrl+c after a few seconds only. Note that the deauth is sent on broadcast, so all the clients (not just one) connected to the network will disconnect. Disconnecting a specific client is also possible.

        Not the real one, but why the fake one

        Even after being disconnected from the real AP, the client may choose to keep trying to connect to the same AP a few more times, instead of trying to connect to ours. We need to make our AP stand out, and for that, we need more signal strength. There are 2 ways to do that-

        1. Physically move closer to the client.
        2. Power up your wireless card to transmit at more power. 
        The latter can be done with the following command -
        iwconfig wlan0 txpower 27
        Here 27 is the transmission power in dBm. Some cards can't transmit at high power, and some can transmit at extremely high power. Alfa cards usually support upto 30dBm, but many countries don't allow the card to transmit at such powers. Try changing 27 to 30 and you'll see what I mean. In Bolivia, however, you can transmit at 30dBm, and by changing the regulatory domain, we can overcome the power limitation.
        iw reg set BO
        iwconfig wlan0 txpower 30
        It is strongly advised to not break laws as the transmission limits are there for a reason, and very high power can be harmful to health (I have no experimental evidence). Nevertheless, the client should connect to you if your signal strength is stronger than that you the real twin.

        Note : If you are unable to get your client to connect to you, there is another option. You can leave him with no options. If you keep transmitting the deauth packets continuously (i.e. don't press ctrl+c after the client has disconnected), he will have no choice but to connect to you. However, this is quite an unstable situation, and the client will go back to the real twin as soon as it gets the chance.


        Give the fake AP internet access

        Now we need to provide internet access to the fake AP. This can be done in various ways. In this tutorial, we will consider that we have an interface x0 which has internet connectivity. Now, if you are connected to net via wireless, replace x0 with wlan1 or wlan0, a 3G modem will show up as ppp0. Nevertheless, you just have to know which interface is providing you with internet, and you can route the internet access to your client.

        Interfaces

        • x0 - This has internet access
        • at0 - This is create by airbase-ng (wired face of the wireless access point). If you can somehow give internet access to at0, then the clients connected to your fake wireless network can connect to the net.
        • evil - This is an interface that we will create, whose job will be to actually bridge the networks.

        Creating evil

        We will use Bridge control utility provided by Kali, brctl. Execute the following code-
        brctl addbr evil
        This will create the bridge. Now we have to specify which two interfaces have to be bridged-
        brctl addif evil x0
        brctl addif evil at0
        We can assign an IP to the interfaces and bring them up using-
        ifconfig x0 0.0.0.0 up 
        ifconfig at0 0.0.0.0 up
         Also bring up the evil interface (the interfaces aren't always up by default so we have to do this many times)
        ifconfig evil up
        Now to auto configure all the complicated DHCP settings, we'll use dhclient
        dhclient3 evil & 
        Finally, all the configurations have been completed. You can execute ifconfig and see the results, which will show you all the interfaces you have created.
        Officially, the evil twin attack is complete. The client is now connected to your fake network, and can use the internet pretty easily. He will not have any way to find out what went wrong. However, the last objective remains.

        Have fun

        Now that the client is using the internet via our evil interface, we can do some evil stuff. This actually comes under a Man In The Middle attack (MITM), and I'll write a detailed tutorial for it later. However, for the time being, I will give you some idea what you can do.

        Sniffing using Wireshark

        Now all the packets that go from the user to the internet pass through out evil interface, and these packets can be monitored via wireshark. I won't teach you how to use it here, since it is a GUI tool. You can take a look at their website to get an idea on how to use wireshark. Pic credits: The picture on the right has been directly taken from their website. 

        Special Thanks

        Matthew Bernard for his useful comment with some tips and a number of corrections http://www.kalitutorials.net/2014/07/evil-twin-tutorial.html?showComment=1406591245609#c5539483407421385761
        The screenshots have also been taken by him and provided to me for usage (I would love to see more helpful visitors like him).