Thursday, January 16, 2014

The Malware used at Target

Brian Kreb's tweeted isight "pick nits in my story" about the POS malware used at Target. Guess people forget about hardware vulnerabilities.

https://www.isightpartners.com/2014/01/kaptoxa-pos-report-faq/

His blog here with a first look at functionality: http://krebsonsecurity.com/2014/01/a-first-look-at-the-target-intrusion-malware/ There's a great analysis on the malware itself for those that are inclined to view it

Monday, January 13, 2014

From Nigerian Princes to Dark Comets

I hope we're all familiar with 419 emails.  These are one of the most common types of fraud/confidence scams.  The "419" corresponds with the criminal code dealing with fraud in Nigeria and the emails normally involves a prince or someone oversees attempting to make you a promise on thousands or even millions of dollars if you wire them a little bit of money.  Of course your wishes of vast riches from African royalty will end in disappointment if you ever choose to respond to one of these emails, but have you ever wondered what happens if these operators ever got a hold of malware?

There's been a recent campaign of  "Payment Advice" themed emails which fit under these 419 variations.  I had a chance to dive a bit deeper and realized that the attachment they sent seemed to be a commodity based DarkComet RAT (Remote Access Tool) which currently is not in VirusTotal. (PM me off list for samples and MD5s).  Older variation and sample can be located here:

https://www.virustotal.com/en/file/c8c69009509dd5665e3913e164f95ccccf0c818c4c832c06755f4849e54a5fa1/analysis/

Getting right into it let's just pretend you received an email with a body message with something like this:

"... Good day, If you are the owner of this email address and contact above, I wish to inform you that the sum of $45,000,000.00 USD was deposited in our bank...
If you are a true relation to the depositor please download payment advice report on attachment..."

Oh happy day $45 million in my bank account?! I can't wait!... I'm sure all of you look at file metadata up close before you execute things so here you go.

File:     MalwareFile.exe
Size:     942592
MD5:      [redacted]
Verified:       Unsigned
Link date:      5:22 PM 6/19/1992

Compiled: Fri, Jun 19 1992, 22:22:17  - 32 Bit EXE
File Modification Date/Time     : 2014:01:13 11:44:18-05:00
File Access Date/Time           : 2014:01:13 15:09:05-05:00
File Creation Date/Time         : 2014:01:13 15:09:05-05:00
File Permissions                : rw-rw-rw-
File Type                       : Win32 EXE
MIME Type                       : application/octet-stream
Machine Type                    : Intel 386 or later, and compatibles
Time Stamp                      : 1992:06:19 18:22:17-04:00
PE Type                         : PE32
Linker Version                  : 2.25
Code Size                       : 819200
Initialized Data Size           : 126976
Uninitialized Data Size         : 2965504
Entry Point                     : 0x39c060
OS Version                      : 4.0
Image Version                   : 0.0
Subsystem Version               : 4.0
Subsystem                       : Windows GUI 

Pay close attention to that compile time which we can assume was compiled in 1992 (though this field may be spoofed from time to time)

Now for the juicy part. While paying attention to both host based and network based behavior I'm going to be running this on a fully patched Windows 7 virtual machine with admin privileges.  I wont go into debugging on this post, but this was pretty straight forward.

After detonation this malware drops its payload directly into:

C:\Users\~\Documents\MSDCSC\msdcsc.exe
MD5: [redacted]
Size:     942592
Compiled: Fri, Jun 19 1992, 22:22:17  - 32 Bit EXE

which then executes a bogus notepad.exe and runs it in memory under it's parent process of msdcsc.exe

Keep in mind MSDCSC is a common path used by DarkComet and most likely a default path in the builder.
This malware then establishes its persistence mechanism here:

\REGISTRY\USER\S-1-5-21-2410237121-4616876-267966928-1001\Software\Microsoft\Windows\CurrentVersion\Run\MicroUpdate

Why is this all important?  Well i'm glad you asked, this is where this malicious remote access tool installs and persists itself in your machine and depending on detection capabilities you may have in your enterprise environment this is what modern access protection will track and detect on.  For bonus points you can try and pull the configuration in memory since most of it will be in memory once the binary is unpacked, but I'll try to keep this as simple as possible due to the audience most likely reading this.

After installation the malware will "phone home" which in this particular case the server will attempt to connect over TCP to the chosen IP/domain over the chosen port.  This traffic will be encrypted via RC4-256 which is fairly common for commodity based malware, but if no active command and control traffic occurs the network connection is maintained with a series of TCP requests [PSH, ACK]  containing the word "KeepAlive" (no spaces), followed by a string of 7 digits.

All command and control traffic is encrypted with a form of this RC4-256 algorithm and depending on which version malware you received the key will be different.  At default the encryption key will be as follows

Version 4 Key:  #KCMDDC4#-890
Version 3 Key:  #KCMDDC2#-890

If a security password is provided during the server build stage the password will be appended to the default key, so for example for version 4 with the default password enabled, the encryption key would become #KCMDDC4#-8900123456789

An example of a decoded packet capture is followed in this example (for those who care, the location of the encryption key is stored in the EAX register at offset [Imagebase + 00003104]):

Client Says: IDTYPE

Server Says:   SERVER

Client Says: GetSIN192.168.93.130|120826718

Server Says:   infoesGuest16|192.168.93.130 / [192.168.93.130] : 1604|XP-CLIENT / Administrator|120826718|0s|Windows XP Service Pack 2 [2600] 32 bit ( C:\ )|x||US|Program Manager|b4c7d186b435fc77626a5ae904879815|275.65 MB/511.48 MB [235.84 MB Free]|English (United States) US /  -- |9/22/2011 at 2:58:57 PM

As you can see your encrypted computer information is being passed back to the configured command and control server which the advisory is most likely logging.  From here on out your machine is now compromised and is at the mercy of the operator which had sent it.  For a full list of commands and functionality the DarkComet RAT offers see here:

http://contextis.com/research/blog/malware-analysis-dark-comet-rat/

Conclusion:
I can't really say what will happen once the operator is on your machine, as motivations will differ between hackers and countries of origin, (the last time I let malware talk out live on a honeypot, my VM was reformatted lol)  but from my experience commodity based malware operators are the most interested in monetary gain rather than proprietary intelligence, so remember don't click on links or open attachments you don't know about and keep your data safe!  Thanks for reading.

Friday, August 23, 2013

Android Vulnerability

Two Android vulnerabilities (“master key” and “extra field”) with samples attached originally discovered by Bluebox Security and presented at the most recent black hat. (http://vrt-blog.snort.org/)

·         The “master-key vulnerability” takes advantage of the way Android application packages are signed, allowing the contents of a package to be modified (potentially to introduce malware) without invalidating the signatures that had been placed by the original developer. In short, essentially the vulnerability is exploited by having multiple files with the same name in an APK. Android's verifier and loader handle duplicate entries differently. The verifier will check only the last duplicate entry against the SHA1 digest stored in META-INF/MANIFEST.MF. The loader will load the first entry. 
·        
The “extra field” vulnerability is exploited by a signed / unsigned handling error in the Android's verifier. A Zip file's central directory points to all of the files stored in the archive. Each file has a header which has extra space available, called the extra_field. The extra_field, when present, is between a file's header and the stored file. When its size is interpreted as a negative value, the verifier will try to skip past it to the file bytes by jumping backward. If you store the original file at the location the verifier jumps backward to, it will be verified. Then you can place some arbitrary file into the original file's position, causing the new file to be loaded.

Below is the variation of the “extra field” attack which is different in its execution, but does the same basic trick of fooling Android's APK-reading routines into thinking an APK has been properly signed by using a copy of correctly signed data in one location and tricking the system into running an unsigned modified version of that data stored in another location. The Bluebox approach exploited a flaw that allowed two copies of the same file to be present in a ZIP archive.  This new Chinese attack works by modifying the classes.dex file which contains an application’s compiled code within the Android APK file.  This file's header includes a variable-sized space between the header, which includes the file name with a .dex extension and the class files for an "extra field". It is into the last three characters of the file name and the extra field that the original class files are copied, with the length of the extra field set to 0xFFFD.

Injection Description

After this, padding is added and then the attackers' own class files can be included. When validating, a bug in the reading code means that 0xFFFD is converted to -3 and the validation takes places starting at the "dex" part of the file name extension which also happens to be the opening header of the dex file format. When being loaded though, the reading code follows 0xFFFD correctly and reads the modified code.

Reference:  Chinese “The android security team” blog - http://blog.sina.com.cn/s/blog_be6dacae0101bksm.html


Currently both the bugs are fully public, with a patch deployed to CyanogenMod 10.1.2, an open distribution of Android.  The problem lies with how to get phone manufacturers to ship out firmware updates that will correct both issues as these problems date back as far as Android 1.6.

Wednesday, June 26, 2013

Tired of the Xbox One vs PS4 debate

Reference originally from some post on reddit.  A basic summary for those unable to watch the video (or who were turned off by the fact that the guy in the video kept referring to DDR5...)

PS4
8 GB of GDDR5 memory
256 bit bus
~5.5 Ghz data rate
Peak bandwidth - ~176 GB/s.

Xbox One
8 GB of DDR3 memory
256 bit bus
~2.1 Ghz data rate
Peak bandwidth - ~68.3 GB/s

Additionally, the Xbox One has embedded SRAM (eSRAM) on the die. Reports suggest that there's approximately 50 GB/s of bandwidth in both directions for the embedded SRAM. We're still not quite sure how the eSRAM is being used - if it's being used as a cache, for example, the Xbox One could come close to matching the PS4's total memory bandwidth. Here's an article from AnandTech that provides a bit more detail.

Memory demands from the OS
Reportedly, the PS4 OS requires about 1 GB of memory, leaving 7 GB for developers. The Xbox One employs 3 different software elements - the Xbox OS, the Windows 8 kernel (thanks amxn), with both being tied together and managed by a hypervisor. The Windows 8 partition reportedly boots when the system is powered on and runs indefinitely until the system powers down. The Xbox OS partition, on the other hand, is booted only when you're playing a game. The hypervisor manages both of these seamlessly, allowing you to multitask between gaming and other entertainment features. It's being speculated that all three software elements consume 3 GB of memory, leaving 5 GB available for developers.

Differences in the types of memory
GDDR5 and DDR3 transmit data in different ways. GDDR5 has a relatively higher latency, but delivers data in larger chunks - exactly what you would want for a GPU, but not necessarily ideal for a CPU. On the other hand, DDR3, the memory type employed by the Xbox One, transmits smaller amounts of data more quickly - this is ideal for a CPU, but not exactly the best option for a GPU.

The architectures of these systems are quite profound, as they reveal the overarching philosophies of both companies. Sony's approach with the GDDR5 is ideal for gaming, as it augments the GPU and is great for developers. Microsoft's choice for DDR3 (and the eSRAM) favors the CPU a bit more and, as a result, is better for activities like multitasking.

Aside from the memory subsystems, it should be noted that the PS4 simply does have more power under the hood, with 50% more raw shader power - 768 SPs at 800mhz for the Xbox One, versus 1152 SPs at 800 mhz for the PS4. Unlike the Playstation 3, this isn't a complicated architecture to understand, and it may not take anywhere near 3+ years for developers to harness this power.

Both systems, however, are exponentially more powerful than the 360/PS3. One of the key features of both next gen systems is that they have unified memory pools. In your current computer, you have system memory, but your graphics card (if it's dedicated) has its own pool of memory as well. As a result, your system has to copy data from one pool of memory to the other, which takes time and can hinder peformance.

The 8 GB memory pools in the PS4/One are unified - meaning, quite simply, that both the CPU and GPU inside the PS4/One access the same pool of memory. This can provide significant performance increases (ie, the CPU can load textures into the memory, while the GPU is rendering). If you're interested in learning more about this, simply perform a search for "hUMA" (heterogeneous unified memory access).

And, even if you only game on a PC, and not a console, you should still be pretty excited, as the new consoles will only raise the bar for PC games. Porting games among the PC, PS4, and Xbox One is going to be far easier. In fact, the developer of Warframe recently said in an interview that Sony asked only 3 months ago if they wanted to bring the game to the PS4. They agreed, Sony sent devkits, and 3 months later, they showed off Warframe footage running on PS4 devkits at E3.

Here's a link to the interview

Friday, March 29, 2013

Deciphering Credit Card Information


This was an interesting article in reference to one made by  Brad Antoniewicz from opensecurityresearch.com
  1. Physical
  2. MagStripe Data
  3. RFID/NFC Data
This obviously varies from bank to bank and card manufacturer to card manufacturer. The purpose of this post is to evaluate all three interfaces of the card and see how they differ. Note that some data has been changed to protect the card holder's (my) information.

Physical Attributes

This interface is probably the most widely known and understood because its been around the longest and its the easiest to inspect. It's sort of good to understand the components of this interface because they're present in to the other interfaces (but a little different).

From a physical perspective, your card should have four main attributes:
  1. Name
  2. Expiration Date
  3. Credit Card Number
  4. Card Verification Value
Names and Expiration dates are pretty straightforward and don't need much explaining.

Credit Card Number - Also known as "Primary Account Number" (PAN). The one thing to point out is that credit card numbers have some unique properties. For instance, the first number of the card number will vary depending on the type of card.

CardStarting Number
Visa4
MasterCard5
Discover6


A great article about credit card numbers is "Anatomy of Credit Card Numbers."

Another notable thing about the card number is it is actually created using a particular algorithm and thus there is a check, called the Luhn 10 check that verifies that the card number was generated in accordance with this algorithm. More info can be found here -

http://www.visacemea.com/ac/ais/uploads/ais_guide_stepspcicompliant.pdf [PDF]

Card Verification Value (CVV2) - Note the version number. This is a three (MasterCard, Visa, Discover) or four (American Express, called the "CID") code printed on the card to help prevent against fraud. The idea behind it, is it proves possession of the card and is required when the card is not present. On American Express cards, this value is printed on the front, while MasterCard, Visa, and Discover cards have it printed on the back, usually in the signature box.

MagStripe Data

The magnetic stripe on the back of the card is broken up horizontally into three "tracks", the tracks often contain duplicate data and most times track 3 doesn't really contain any data.

ISO/IEC 7813 Defines the attributes of this data, and these sites describe the data available on each track in detail:
  • http://en.wikipedia.org/wiki/ISO/IEC_7813
  • http://www.gae.ucm.es/~padilla/extrawork/tracks.html
  • http://www.tech-faq.com/layout-of-data-on-magnetic-stripe-cards.html
To read the data, you'll need a magstripe reader that will support reading all three tracks. Most magstripe readers emulate a HID (human input device), so its surprisingly easy to read from them - just open a text capturing program and swipe a card.

The reader I'm using is the MagTek SureSwipe 21040145.

So lets see what data we'll get from the magstripe:

%B5XXXXXXXXXXXXXX2^ANTONIEWICZ/BRAD^1103101000000001000000003000000?;5XXXXXXXXXXX11031010000003XXX2=

Lets break down this data:

Track 1 Data
Track DataValue
%Start
BFormat Code (B=Bank)
5XXXXXXXXXXXXXX2Primary Account Number (PAN)
^Separator
ANTONIEWICZLast Name
/Name Separator
BRADFirst Name
^Separator
11Expiration Year
03Expiration Month
101Service Code
000000001000000003000000Discretionary Data
?End
Track 2 Data
;Start Track 2 Data
5XXXXXXXXXXXXXX2Primary Account Number (PAN)
=Separator
11Expiration Year
03Expiration Month
101Service Code
000000300001Discretionary Data
?End


So you can see that Track 2 actually contains much data already present in track 1. You'll also notice that there is a difference in the discretionary data between track 1 and 2.

But where the heck is that Track 3 data? Well.. it doesn't appear that any data is written to it, or at least my reader isn't picking it up.


RFID Interface (EMV Chip)


In the last couple of years, the RFID Interface has been most talked about. Something about the idea of an attacker reading your credit card out of your pocket, seems to bother people :)

The RFID Interface specifications were designed by a group of representatives from Europay, MasterCard, and Visa (EMV) and is thus often referenced as the "EMV Chip" or just "EMV". The three things that differentiate this interface from the others are:
Card Holder Name - On most cards the cardholder name is not stored within the chip, instead its replaced by something like "VALUED CUSTOMER" or "NOT SUPPLIED"
Service Code - The service code that permits where the card is used (and for what) changes on the contactless interface.
iCVV or Dynamic CVV - Rather then using the same CVV that is stored on the MagStripe, the smartcard capabilities allows for extended functionality, and so the designers created something called a Dynamic CVV. This CVV changes which each read of the card.
The RFID Interface is defined mostly in ISO/IEC 7816 and the EMV Specifications.

VivoPay 4500
Probably the easiest way to read the RFID interface of a credit card is to buy an equipped point of sale (POS) reader and connect it up to your computer. The VivoPay 4500 will handle all of the RFID communication and output the data on the RFID interface in plaintext over it's serial connection.

Prolific PL-2303
The Prolific PL-2303 is a USB to Serial adapter which helps when connecting to the VivoPay's Serial output. If you want to make this all work on Mac OS X 10.7.3 (like i am) you have to do a little bit of work:

First download the 64-bit open source PL2303 driver:
  • http://sourceforge.net/tracker/download.php?group_id=157692&atid=804837&file_id=363913&aid=2952982
Then decompress and install:
  •  unzip osx-pl2303.kext.zip  
  •  sudo cp -R osx-pl2303.kext /System/Library/Extensions/  
  •  cd /System/Library/Extensions/  
  •  sudo kextload osx-pl2303.kext  
Insert your USB adapter then check to make sure the driver created a device interface (your interface might be named differently):
  •  system:Extensions user$ ls /dev/tty.PL*  
  •  /dev/tty.PL2303-000013FA  

pwnpass.py

pwnpass.py is a python script created by Eric Johnson (and others) which allows you to interact with VivoPay Devices. To use it, you may have to first install py-serial to get it running. I'm using mac ports to manage all of the python packages.
  •  sudo port install python26 py26-serial
Next edit line 103 of pwnpass.py so that your device is appropriately defined. The default timeout for the open source driver is 1 second, I've changed it to 0.3 which seems to work better.
  • return serial.Serial('/dev/tty.PL2303-000011FD', 19200, timeout=0.3)
So if we run it on the same card we used before, we see the following raw data:

 %B5XXXXXXXXXXXXXX2^SUPPLIED/NOT^1103502000000001000000637291901?;5XXXXXXXXXXXXXX2=

OmniKey CardMan 5321 Config

If you want to be a little more conventional, you can use a standard, off the shelf RFID reader, like the OmniKey CardMan 5321.

The Touchatag reader is another commercial off the shelf reader like the Omnikey Cardman 5321. It's popular because of its libNFC support, however with the tasks we're doing using RFIDiot, it doesn't really matter. I'm providing configuration information here for diversity. Once you connect the reader to your system, you'll likely notice its light seems to blink rather then staying lit. To fix this, it will require a quick little driver configuration change:

 sudo vi /usr/libexec/SmartCardServices/drivers/ifd-acsccid.bundle/Contents/Info.plist  
On line 53 (under ifdDriverOptions) 

change

      <string>0x00C0</string>
    
to this:

      <string>0x0005</string>  

Then to make sure its working properly:

 ~ user$ nfc-list   
 nfc-list use libnfc 1.4.0 (r833)  
 Connected to NFC device: ACS ACR38U-CCID 00 00 / ACR122U102 - PN532 v1.4 (0x07)  

Once that's all set up, just start pcscd if its not already running:

sudo pcscd  

and then check RFIDiot's cardselect.py:

 RFIDIOt-1.0a user$ python2.6 cardselect.py -L  
 PCSC devices:  
   No: 0          ACS ACR38U-CCID 00 00  

TouchaTag (ACR122U) Reader Config

The Touchatag reader is another commercial off the shelf reader like the Omnikey Cardman 5321. It's popular because of its libNFC support, however with the tasks we're doing using RFIDiot, it doesn't really matter. I'm providing configuration information here for diversity. Once you connect the reader to your system, you'll likely notice its light seems to blink rather then staying lit. To fix this, it will require a quick little driver configuration change:

 sudo vi /usr/libexec/SmartCardServices/drivers/ifd-acsccid.bundle/Contents/Info.plist 

On line 53 (under ifdDriverOptions) 

change

      <string>0x00C0</string>  
  
to this:
      <string>0x0005</string>  

Then to make sure its working properly:
 ~ user$ nfc-list   
 nfc-list use libnfc 1.4.0 (r833)  
 Connected to NFC device: ACS ACR38U-CCID 00 00 / ACR122U102 - PN532 v1.4 (0x07)  

Once that's all set up, just start pcscd if its not already running:

 sudo pcscd  

and then check RFIDiot's cardselect.py:

 RFIDIOt-1.0a user$ python2.6 cardselect.py -L  
 PCSC devices:  
   No: 0          ACS ACR38U-CCID 00 00  

Using RFIDiot to Read Card Data

In most situations, RFIDiot's ChAP.py should be able to query the card's data. On an RFID level, the card is first queried with a generic "tell me your file structure" method, and if the card doesn't respond, the reader sends requests for specific application ID's (AIDs) that are known structures for different vendors (Mastercard, Visa, etc...). In the rare case that ChAP.py doesn't work well, you may have to define your own specific AID in ChAP.py or write your own parser like I did for the Chase Visa PayPass cards. 

By default ChAP.py will attempt to parse the data from the card and translate it so we can make sense out of each byte. Instead, I'll tell ChAP.py not do that and just display the raw data (-r).

 RFIDIOt-1.0a user$ python2.6 ChAP.py -r  
 insert a card within 10s  
  Found AID: MASTERCARD - a0 00 00 00 04 10 10  
 6f 17 84 07 a0 00 00 00 04 10 10 a5 0c 50 0a 4d 61 73 74 65 72 43 61 72 64  
 o............P.MasterCard  
  Processing Options: 77 0a 82 02 00 00 94 04 08 01 01 00  
 w...........  
   SFI 01: starting record 01, ending record 01; 00 offline data authentication records  
    record 01: 70 81 90 9f 6c 02 00 01 9f 62 06 00 00 00 00 01 c0 9f 63 06 00 00 00 00 00 3c 56 3e 42 35 34 36 35 30 33 32 30 36 38 39 39 38 30 31 32 5e 53 55 50 50 4c 49 45 44 2f 4e 4f 54 5e 31 31 30 33 35 30 32 30 30 30 30 30 30 30 30 31 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 9f 64 01 03 9f 65 02 00 e0 9f 66 02 00 1e 9f 6b 13 5X XX XX XX XX XX X2 d1 10 35 02 00 00 00 00 00 00 0f 9f 67 01 03 9f 68 0e 00 00 00 00 00 00 00 00 5e 03 42 03 1f 03  
 p...l....b........c......<V>B5XXXXXXXXXXXXXX2^SUPPLIED/NOT^1103502000000001000000000000000.d...e....f....k.Te. h.....5.........g...h.........^.B...  

An important thing to note here is the ChAP.py isn't pulling the track two data by default. 

FID vs MagStripe

Lets look at the differences between the raw data obtained from the RFID interface with the VivoPay and that from the MagStripe. Here's the VivoPay data:

 %B5XXXXXXXXXXXXXX2^SUPPLIED/NOT^1103502000000001000000637291901?;5XXXXXXXXXXXXXX2=11035020000072029191?I  

The following table breaks out the raw data from the magstripe and RFID interface to make it a little easier when comparing the two. 

Track 1 Data
MagStripe
RFID
Value
%
%
Start
B
B
Format Code (B=Bank)
5XXXXXXXXXXXXXX2
5XXXXXXXXXXXXXX2
Primary Account Number (PAN)
^
^
Separator
ANTONIEWICZ
SUPPLIED
Last Name
/
/
Name Separator
BRAD
NOT
First Name
^
^
Separator
11
11
Expiration Year
03
03
Expiration Month
101
502
Service Code
000000001000000003000000
000000001000000637291901
Discretionary Data
?
?
End
Track 2 Data
;
;
Start Track 2 Data
5XXXXXXXXXXXXXX2
5XXXXXXXXXXXXXX2
Primary Account Number (PAN)
=
=
Separator
11
11
Expiration Year
03
03
Expiration Month
101
502
Service Code
000000300001
0000072029191
Discretionary Data
?
?
End
N/A
I
Trailing Data (Unknown)

Service Code - One interesting thing to note is the Service code differs. According to ISO/IEC 7813:2006(E), page 6, the service codes break down to: 

  • 101 - Can be used internationally with normal authorization, for any goods, with no PIN requirements
  • 502 - Can be used nationally with normal authorization, for goods and services with no PIN requirements

So there are clearly some restrictions for where and how you can use the card. 

You'll notice that the discretionary data on both track 1 and track 2 differ from that of the magstripe. Although the contents of the data stored within the discretionary data field are particular to the card manufacturer, we know that in here is where the CVV is stored. On the magstripe, CVV1 is used, while the RFID interface uses iCVV or Dynamic CVV. 

Look what happens if we query the RFID interface a couple more times:

 %B5XXXXXXXXXXXXXX2^SUPPLIED/NOT^1103502000000001000000294292801?;5XXXXXXXXXXXXXX2=11035020000018129281?E  

 %B5XXXXXXXXXXXXXX2^SUPPLIED/NOT^1103502000000001000000939293101?;5XXXXXXXXXXXXXX2=11035020000054629311?;?  

 %B5XXXXXXXXXXXXXX2^SUPPLIED/NOT^1103502000000001000000191297701?;5XXXXXXXXXXXXXX2=11035020000099829771???  

You'll notice that the discretionary data changes on both tracks. That's the "dynamic" part of dynamic CVV. 

Kristen Paget just gave a talk a Shmoocon and said that "check digits" (I believe the dynamic CVV is the only check that this applies to) can only be used once and if it is used a second time, the card is immediately frozen and the RFID chip can no longer be used. Overall, there isn't much explanation of exactly how the iCVV or the dynamic CVV is actually generated.

Thursday, March 7, 2013

How Antivirus works


Doing this post on my lunch break at work, so I'll be fast.  While there are many different styles of viruses and attacks, a lot of antivirus software deployed relies on a currently known threats or vulnerabilities. It is hard to defend against an unknown vector of attack (I use virus here generically), but some basic attacks/detections are as follows:

Size
An easy way to detect if a file has been altered is the size of the file. Some viruses like to tack on their malicious code at the end of the file, and that is a dead giveaway when an antivirus scanner scans it. It compares the before and after sizes, and if there has been no modification by the user, it suspects some malicious activity.

Pattern Matching
Viruses often have a telltale signature that they use to infect your computer. It could be couple lines of assembly code that overwrite the stack pointer and then jump to a new line of code, it could be a certain series of commands that throw an error in a common application, or it could be using an unchecked overflow or memory leak to grab an exception thrown. Regardless, a lot of infectious software uses an reproducible exploit that is found on the target operating system or application, and those tell tale signs (because they have been spotted before) go into a huge database of known exploits and vulnerabilities. When your antivirus scans through it checks your programs for these malicious activities.

Detecting Injections
Since viruses like to use these known exploits, malware writers sometimes like to inject code into pre existing programs, like when you 'accidentally' installed that malicous program. These kinds of attacks typically inject code into dead regions of documents or files, and use a jump to go to the malicious code. To explain further, since blocks of memory are allocated to files, sometimes the very end of the memory block does not get used up, or in some cases, there are certain exploits within certain types of files that have legacy sections that are no longer used. This legacy section is a perfect spot to hide malicious code, since it does not increase the size of your program or file. An injection attack uses the initial startup code to 'jump' to the malicious code, and then 'jump' back, making it seem like nothing was ever wrong, and your program boots up perfectly. There are many many variations of this attack, but an antivirus program typically looks for those strange 'jumps' and code that looks like it doesnt belong in certain sections.

Hashing
Some antivirus programs analyze the programs/files byte for byte, and literally compute the sha-1 hash of the item it is detecting. It stores every single hash for everything on your system, and if the program has been modified it will not compute the same hash (that is the whole point of a hash, it changes drastically if only a tiny bit of the program/file changes). This detection is flawed, because if the virus discovers where all the hashes are stored or the algorithm used, it can overwrite the 'secure' hash with the malicious one and the antivirus will never know.

Deeper Threats
Whenever you start your computer, or plug an external device into it (hard drive, cd, usb, there are core drivers or 'code' that runs to setup the connections from your computer to the external device. Some viruses exploit this when the connection is being established, and could either execute arbitrary code (instead of the connection code) or can become a man in the middle, where everything acts fine but the virus is actually the one creating the connection, as well as inserting its own code where ever it feels like. Since these threats can work themselves deep within the operating system and core functions, these are extremely hard to detect. If the deeper OS calls are not compromised, like the antivirus calls to the OS, then these attacks can be detected. If the whole system is compromised, then the virus is embedded so deep that you some times have no choice but to wipe it and hopefully do a fresh install. If the code that starts up your operating system is compromised, you have even bigger problems because wiping will not get rid of it.

Hopefully this is in layman enough terms for anyone to understand, and that I will wake up tomorrow morning and everyone will understand the basics of computer infections and detections.

Thursday, January 17, 2013

Reconnaissance 101

Reconnaissance - A mission undertaken to obtain, by visual observation or other detection methods, information about the activities and resources [of a target].

Just a brief introduction to some of the extremely easy types of reconnaissance techniques used by hackers, keep in mind all of this information is used to further your own knowledge so you may better protect yourself.   Absolutely do not attempt to publish or use any of this information with malicious intent.  I will not be liable for your stupidity.

Google Fu - Search engine recon performed by utilizing well-crafted queries and query tools to discover information about a target
Maltego - Open source web-scouring software used to aggregate and link personally identifiable information
Spokeo - A web-based white pages type tool that also works to gather as much public information about a target as possible

Google-Fu
Google-Fu is a coined term used in "googling" a particular subject or person.  There is tons of information openly available and billions of webpages out there to meet your return on results for vague or generic queries.  Many hackers now and days will use a search engine as a hacking tool making sure to ask the right questions. Here are some useful search directives and operators below.


site:[domain]
Limits the results to those within the provided [domain]. This can be generic, such as “.edu”, or specific, like www.cnn.com

link:[web page]
Shows all sites that link to the given web page, which is useful for determining business relationships

Literal matches (“   ”)
Preserves the order of the words in the query, which helps in finding titles or specific files

Not ( - )
Filters out web pages that contain the given term

Try Googling some of these and see where they lead you:

- filetype:.mysql_history username [this is a query that will show SQL server history with the word "username" in the results, of course you can look up username and password also, but I will let your imagination do that]
- intitle:"active webcam page" site:edu [self explanatory, active webcam pages in schools]
- filetype:sql "MySQL dump" (pass|password|passwd|pwd) [sql dump with variations of the word password in the results]
- intitle:"hp laserjet" inurl:info_configuration.htm [configuration information about a particular printer, sometimes if you look hard enough and get access you may be able to send/print messages to the admin]

Maltego

Maltego is used to determine the relationships and real-world links between people, companies, networks, and websites.  Through these relationships, you can strive to provide a clear “threat picture” of the environment in which an organization resides.  I will demonstrate this tool on an individual, but think about how it would be even more effective against your organization.

Positives

- Social Engineering attacks
- Enable physically locating a target in some cases (enabling attacker to befriend or threaten)
- Improved Dictionary attack
- Most people include something about themselves in their passwords
- Connect unrelated data
- No one search would have returned all of this assorted information, let alone graphed it for you

Negatives
- Overabundance of information makes locating pertinent pieces difficult
- High risk of false positives
- “Zipperer” is not a common last name in the US, but it found six incorrect phone numbers searching on me
- Free version does not contain full functionality\
- It’s much more effective when used against an organization than an individual!

Spokeo
I have got to say this website is awesome.  It is a social network and open source aggrigator which queries 40 sites to compile information about a particular user.  What is even more surprising is the fact that it only uses publically available information and information available via credentials you input.  You would be extremely surprised just how much you can dig up on someone using this.  The paid version of Spokeo will pull email contacts and profile them!

Imagine if a hacker had used a bunch of company emails.  You would be able to quickly profile an entire company to identify easy social engineering targets and provide access to social engineering attack vectors via “common interests” like Pandora playlists, web site postings, Picasa pictures, names, addresses, phone numbers you get the idea.


Securing yourself
After reading all this you may say how do I stop it all?  Well keep in mind everything you put on the internet will leave a footprint and will be stored by someone somewhere.  There are however, a few mitigations you can use to help combat this.

- Avoid storing personal or employee information online, even if it’s in a hidden location or file on your server.
- Be exceedingly wary of any information posted to social sites – assume that anything there is public knowledge!
- Remember that just because a web page has been deleted doesn’t mean it’s gone… Google caches everything (but you may request that they delete it)

Be careful out there!