Wednesday, 26 June 2013

Assembly Language starter

Hello to all, my wireless card still hasn't arrived, so i'm going to do a quick post on what i am currently working on.

Background

Although i do a lot of wireless, i still don't understand how it works, how one pulse of current travels from one device and ends up at the other, my eventual aim is to be able to create my own wireless communication device out of very basic parts using a arduino. As a result i have been looking into assembly programming, which is what i'm going to do some of today.

Take yourself back about 40 years, computers where at their births, for the first time there where teams of people striving to advance the technology within, but they still used machine code {0+1}, which is great to a computer because a computer only understands machine code, but what human can flawlessly and quickly? As a result, assembly language was born, now assembly language is the most basic of computer languages, there are no print commands and conditional statements like if statements and for loops.

Assembly language statements

Assembly language is key to every other language, it is the foundation stone, and it converts directly into machine code. By this i mean that every statement in assembly has a machine code equivalent that is run on the processor.
As a result it is the closest to machine code we have to understand today. All HLL (high level languages like C, C++, C#, Fortran, Pascal, VB, COBALT etc.) are converted into assembly by the compiler(this is not the only thing the compiler does, but it is all i am interested in in this post). But what are the statements?
Computers where created by mathematicians for solving complex maths in little time. A calculation which takes us about 5 minutes takes a computer nano-seconds. It is for this reason a lot of the commands are mathematics based.
  • ADD : This merely adds one memory address to another
  • MOV : This command moves the bits from one memory address to another
  • CMP : This compares two memory addresses.
  • JLE : This jumps if the address is less than or equal to.
  • INC : This increments the memory locations content.


These are just a few basic commands, if you wish to, there is a book i highly recommend from Jon Erickson called "Hacking: Art of exploitation" which is worth its weight in gold just for the sections on assembly, providing a very in depth, interactive look at assembly language.

Hopefully this post has made a few people think about learning assembly language (or at least partially). If nothing else it will look brilliant on a CV for a computer based job.
-Spectr3

Friday, 21 June 2013

Wireless Card Broke

Wireless card broke!



Okay, so first of all, apologies to everyone, this post was supposed to go up last Wednesday, but a very close friend of mine was involved in a very serious traffic collision on his way home from my house. As a result, I've been preoccupied
I was going to do a post on using aircrack-ng to break into a home made wireless WPA network, but my card appears to have died (it belongs in the bottom of my laptop rucksack and as a result endures alot of punishment. As a result, i will be taking some time away and will post again once my new card comes through the post (approx. 1week3days.)
Again, apologies all, this weeks feels like i have let you down alot, but do not despair, the next post will include the capture files i use so you can follow along aswell :).
-Spectr3

Wednesday, 12 June 2013

Wireless Part 6

4-Way handshake


So this week i thought i would continue on with handshakes, and more importantly the most important handshake in wireless you would ever learn which is the 4-Way handshake. Now the 4-way handshake is merely the connection between the wireless client and the wireless AP, but its incredibly important when we get into WPA (which will be done in more detail than WEP as it is seen more, making it more important to understand, it also gives the basis of WPA-Enterprise).

There are 5 parts of the handshake, that's 5 important bit sequences
  • ANounce
  • Snounce
  • MIC
  • GTK
  • Ack


These are absolutely key for our understanding, they are the main blocks of the handshake.
The handshake itself is just 4 EAPOL packets. The structure is as follows
  1. AP sends client ANounce
  2. Client uses this to construct the PTK (pairwise transient key), replying with a SNounce + MIC
  3. AP uses this to construct a PTK, replying with GTK + MIC
  4. Client replies with Ack
  5. Connection Made!


So what happened?
The client attempts to connect with the access point, and has a pre-shared key to use to connect.
The client can now send the pre-shared key it has been told. To do this, the client applys PBKDF2 to create a 256-bit pre-shared key. PDKDF2, is a hashing algorithm, using 4 inputs, the pre-shared key, SSID (and SSID length), then 2 numbers, 4096 + 256. The 4096 is important as the passphrase is hashed 4096 times, making it completely one way, and 256 is the size of the output. The AP already has its own version.

But this key cannot be sent yet, so first of all, ANounce, all the ANounce is, is the authenticator (AP) Nounce (Nounce being a large random value). This is sent by the AP to the client. The client, or supplicant, can then create a SNounce, which is just a Supplicant Nounce. These are both used to create a PTK (pair-wise transient key). This is a dynamic key (making this handshake more secure as it is not guessable).

Now the PTK must be derived. It is just a function using the 256-bit pre-shared key from before, the ANounce, the SNounce, the Authenticator MAC and the Supplicant MAC. This is kept for later.

Next is message 2, this is just the SNounce and MIC, being sent to the AP. The MIC is the message integrity check, which is basically a checksum on the PTK.

At this stage, both the client and the AP both know the 256-bit pre-shared key, the SNounce, the ANounce, the Authenticator (AP) MAC address and the Supplicant (Client) MAC address. As a result, both can create the exact same PTK. As a result, when the authenticator creates its own MIC (based on the Authenticators PTK), the resulting MIC should be the same if the connection is legitimate. Thus, the pre-shared key should be the same.

If the connection is legitimate, the key installation is done, and finally, the key install is acknowledged with a ACK.

I don't think that until now i have properly explained, that was the connection in a WPA environment. Its nothing complex. I personally like to imagine it like 2 spies talking to eachother, checking if the other has the same information without saying what that information is (but i'm abit strange like that).

Anyway, I think that that is enough for this week, so i shall see you all next week for another installment.
-Spectr3

Wednesday, 5 June 2013

Wireless Part 5

Hey all, welcome back to part 5 of my wireless hacking set. Last week we looked at breaking WEP, so today i thought i would show how the handshake worked. Handshakes are key, they are the agreement and connection between the AP and the client. Without them there would be no connection at all.

Ethernet Frames

First important thing to understand is Ethernet frames. In a Ethernet packet (either wireless or wired), you have a number of sections.
  • Preamble

    This is 7 bytes and is for bit synchronization.
  • Start frame delimiter

    A single byte, used as a flag, and is the start of the frame
  • Destination Address

    48-bits, this is the MAC address for the packet's end point, used by routers to determine exactly what device for the packet to end up at.
  • Source address

    48-bits, this is the MAC address for the packets start point, so the end point knows who sent it. Also this is used so if the packet is corrupted or the endpoint is not found, a message can be sent to the sender so the sender isn't waiting for a reply forever.
  • Length/Ethernet Type

    This gives the ethernet type (Ethernet or Ethernet II). In 802.3(Ethernet), this would give the length of the data section (maximum 1500 bytes).
  • Data

    Exactly what it sounds like, this is the data being sent, up to 1500 bytes, in WEP which we talked about over the last few weeks, this would be the WEP packet we spoke of, so the IV + cypher text.
  • Padding

    For reasons related to CSMA/CD (which i won't get into today), a packet must be at least 64 bytes in total. If the data field + other fields do not fulfill this requirement, the padding is used to make sure the packet meets it minimum required length.
  • Checksum

    The Checksum, the saving grace of any packet of data, this is the answer to a simple one way algorithm run on the data to ensure when it reaches its end point it is still correct, and there are no 1's becoming 0's and vice versa.


Now as part of the start frame delimiter, there are some flags, these are just little extra bits that are sent in the frame, each is just a 1 or 0, indicating yes or no, just a couple of flags are SYN, ACK, RST and FIN, today we will focus on SYN and ACK.

The basic TCP handshake

For short, SYN is synchronize and ACK for acknowledge.

The 3-way TCP handshake is very simple, as as a result i am leaving it as the first handshake we will cover, and is the basis i used to learn the 4-Way Handshake. The basis of the hand shake is as follows
SYN
SYN,ACK
ACK

All this is is a ask, a reply and a acknowledgement that the reply has been received.

I'm going to leave this here for this week as i am extremely tired from doing my CBT earlier today (british compulsory bike training, so i can get a motorbike, which of course will have a Yagi antenna strapped to it for a bit of war driving :) ).
-Spectr3

Tuesday, 28 May 2013

Wireless Part 4

Okay, so last time we saw exactly how WEP was working, and hopefully you will have noticed where some of the vulnerabilities are. In this post we will be looking a bit at some of them and exactly where they are and how we can get past them.

IV's

So the first major vulnerability is the IV's. If anyone here has ever done some wireless WEP cracking in the past using a program to do it for you will have heard of IV's before, basically a program from your perspective gets a lot of these then does some calculation and spits back a password. This isn't the real case. As we saw IV's are the randomized initialization vector's put into the RC4 algorithm to generate the key stream to be XOR'ed to the plain text data. Then so the AP can view the data, the secret key + IV from the packet is run through RC4 by the router and the key stream and the data and checksum are worked out. This is the vulnerability you use when your capturing IV's. What vulnerability is there you might ask, well allow me to explain.

The only 2 things being kept secret in WEP is the data + secret key. Now the beauty of RC4 is every time you run that operation you will always get the same result. So if you separate the key stream from the data, you have the result of RC4. Now RC4 read in 2 items of information, the IV and the secret key and we have the IV. Using thousands of these calculation results we can begin to reverse the hash function, and thus we have our secret key, and this is exactly what is going on behind the scenes on a WEP cracking program, the key streams are being captured, then thousands of IV's are being used with their keystreams to reverse the RC4 algorithm to get the secret key, simple really.

This is the basic method used from 2001 onwards. Now i know this post was very short but as i am still unpacking from moving and trying to get a job i don't have a lot of time to spare at current, although you can still email me questions to martyncprice@gmail.com (yes my real name is Martyn Price, anybody who has decided to follow me on twitter should have found this out already @Spectr3Sec ), or you can ask in the comments section, until next week, hack well and prosper
-Spectr3

Wednesday, 22 May 2013

Back in a week

Hey all, i know i have normally posted by now, but its going to have to be next week as i am so busy moving houses, see you all in a week

-Spectr3

Wednesday, 15 May 2013

Wireless Part 3

WEP (Wired Equivalent Privacy)

In September 1999 802.11(legacy) was released. This was the beginning of wireless LAN communications, but required some security, otherwise anybody could intercept/sniff passwords, usernames or any other data which was desired out the the airwaves. Thus WEP was created, with the intention of privacy, allowing for a passkey to encrypt wireless traffic. The major problem with WEP was it was broken before it was implemented, in other words it was never secure, when it was first proposed their were papers being published talking about flaws.

How it works

WEP uses RC4 algorithm which is a symmetric key algorithm, meaning that both parties have identical keys which are used to encrypt and decrypt the data. It is also worth noting that due to things like this, WEP was very low resource usage on the device which was using it, allowing for basic hardware to run it, thus it is still used today in some cases.

WEP is only used in the frame body of a packet. This frame body is split into 3 parts, IV, Data and ICV. IV or initialization vector is a non-encrypted part (which we will come to why later), which begins to show some vulnerability. One of the fields of this was for key id's and was 2-bits large, allowing for 4 different pass phrases to be used. Finally the IV was 24-bits large (important in a minute).

The next part was the data. This is just the data which you wish to send (nothing majorly important here for the purposes of cracking WEP.

Finally we have the ICV. This is the Integrity Check Value. This is also encrypted in WEP. The ICV merely acts as a check-sum to verify that the data has been sent/received correctly.

The steps of WEP

  1. First the IV is generated at random, this is a 24-bit value. This is added to the WEP key which can be either 40-bits or 104-bits. This provides us with a value of 64-bits or 128-bits (which is why its length being 24-bits was important before). This is then inputted into the RC4 algorithm, giving us a random key stream.
  2. At the same time, CRC-32 is applied to the data. This is a basic algorithm using a 32-bit chunk of data and applying a mathematical operation to give a value, which is then appended to the data.
  3. Finally with a key stream the same size as the data to be sent + the ICV, a XOR operation is applied to both the result of step 1 and the result of step 2. This gives us our final cipher text. Now this data should be completely impossible to read, whether your the AP or client, which is a problem, so the IV is put infront of the cipher text, giving us the completed data set for the frame body.


Now if that was abit hard to keep up with, don't fret as there is a diagram incoming :)

This image was lifted from another blogger called Zero-Krangkaian

I think this is enough for this week, and next week I shall begin the basics on where the vulnerabilities are exactly, and how to get past them.

As always thanks for reading :) - Spectr3